Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d964195c authored by Sujeev Dias's avatar Sujeev Dias Committed by Gerrit - the friendly Code Review server
Browse files

mhi: dev: netdev: add debug stats to monitor buffers allocated



For debugging purpose, keep track of number of buffers that
are queued using recycle pool, atomic pool, and background pool.

CRs-Fixed: 2468499
Change-Id: I26e7bf0ac0fd21e74f6255fc266c701042961a03
Signed-off-by: default avatarSujeev Dias <sdias@codeaurora.org>
parent 69d68012
Loading
Loading
Loading
Loading
+34 −0
Original line number Diff line number Diff line
@@ -108,6 +108,9 @@ struct mhi_netdev {
	enum MHI_DEBUG_LEVEL msg_lvl;
	enum MHI_DEBUG_LEVEL ipc_log_lvl;
	void *ipc_log;

	/* debug stats */
	u32 abuffers, kbuffers, rbuffers;
};

struct mhi_netdev_priv {
@@ -219,6 +222,7 @@ static int mhi_netdev_tmp_alloc(struct mhi_netdev *mhi_netdev,
			__free_pages(mhi_buf->page, order);
			return ret;
		}
		mhi_netdev->abuffers++;
	}

	return 0;
@@ -259,6 +263,7 @@ static int mhi_netdev_queue_bg_pool(struct mhi_netdev *mhi_netdev,
			break;
		}
		list_del(&mhi_buf->node);
		mhi_netdev->kbuffers++;
	}

	/* add remaining buffers back to main pool */
@@ -330,6 +335,7 @@ static void mhi_netdev_queue(struct mhi_netdev *mhi_netdev,
			list_add(&mhi_buf->node, pool);
			return;
		}
		mhi_netdev->rbuffers++;
	}

	/* recycling did not work, buffers are still busy use bg pool */
@@ -835,6 +841,31 @@ static void mhi_netdev_status_cb(struct mhi_device *mhi_dev, enum MHI_CB mhi_cb)

struct dentry *dentry;

static int mhi_netdev_debugfs_stats_show(struct seq_file *m, void *d)
{
	struct mhi_netdev *mhi_netdev = m->private;

	seq_printf(m,
		   "mru:%u order:%u pool_size:%d, bg_pool_size:%d bg_pool_limit:%d abuf:%u kbuf:%u rbuf:%u\n",
		   mhi_netdev->mru, mhi_netdev->order, mhi_netdev->pool_size,
		   mhi_netdev->bg_pool_size, mhi_netdev->bg_pool_limit,
		   mhi_netdev->abuffers, mhi_netdev->kbuffers,
		   mhi_netdev->rbuffers);

	return 0;
}

static int mhi_netdev_debugfs_stats_open(struct inode *inode, struct file *fp)
{
	return single_open(fp, mhi_netdev_debugfs_stats_show, inode->i_private);
}

static const struct file_operations debugfs_stats = {
	.open = mhi_netdev_debugfs_stats_open,
	.release = single_release,
	.read = seq_read,
};

static void mhi_netdev_create_debugfs(struct mhi_netdev *mhi_netdev)
{
	char node_name[32];
@@ -851,6 +882,9 @@ static void mhi_netdev_create_debugfs(struct mhi_netdev *mhi_netdev)
	mhi_netdev->dentry = debugfs_create_dir(node_name, dentry);
	if (IS_ERR_OR_NULL(mhi_netdev->dentry))
		return;

	debugfs_create_file_unsafe("stats", 0444, mhi_netdev->dentry,
				   mhi_netdev, &debugfs_stats);
}

static void mhi_netdev_create_debugfs_dir(void)