Skip to content

Commit 850bfb9

Browse files
Hao Chendavem330
authored andcommitted
net: hns3: debugfs add support dumping page pool info
Add a file node "page_pool_info" for debugfs, then cat this file node to dump page pool info as below: QUEUE_ID ALLOCATE_CNT FREE_CNT POOL_SIZE(PAGE_NUM) ORDER NUMA_ID MAX_LEN 0 512 0 512 0 2 4K 1 512 0 512 0 2 4K 2 512 0 512 0 2 4K 3 512 0 512 0 2 4K 4 512 0 512 0 2 4K Signed-off-by: Hao Chen <[email protected]> Signed-off-by: Guangbin Huang <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 25b90c1 commit 850bfb9

File tree

2 files changed

+75
-0
lines changed

2 files changed

+75
-0
lines changed

drivers/net/ethernet/hisilicon/hns3/hnae3.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ enum hnae3_dbg_cmd {
298298
HNAE3_DBG_CMD_MAC_TNL_STATUS,
299299
HNAE3_DBG_CMD_SERV_INFO,
300300
HNAE3_DBG_CMD_UMV_INFO,
301+
HNAE3_DBG_CMD_PAGE_POOL_INFO,
301302
HNAE3_DBG_CMD_UNKNOWN,
302303
};
303304

drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,13 @@ static struct hns3_dbg_cmd_info hns3_dbg_cmd[] = {
336336
.buf_len = HNS3_DBG_READ_LEN,
337337
.init = hns3_dbg_common_file_init,
338338
},
339+
{
340+
.name = "page_pool_info",
341+
.cmd = HNAE3_DBG_CMD_PAGE_POOL_INFO,
342+
.dentry = HNS3_DBG_DENTRY_COMMON,
343+
.buf_len = HNS3_DBG_READ_LEN,
344+
.init = hns3_dbg_common_file_init,
345+
},
339346
};
340347

341348
static struct hns3_dbg_cap_info hns3_dbg_cap[] = {
@@ -941,6 +948,69 @@ static int hns3_dbg_dev_info(struct hnae3_handle *h, char *buf, int len)
941948
return 0;
942949
}
943950

951+
static const struct hns3_dbg_item page_pool_info_items[] = {
952+
{ "QUEUE_ID", 2 },
953+
{ "ALLOCATE_CNT", 2 },
954+
{ "FREE_CNT", 6 },
955+
{ "POOL_SIZE(PAGE_NUM)", 2 },
956+
{ "ORDER", 2 },
957+
{ "NUMA_ID", 2 },
958+
{ "MAX_LEN", 2 },
959+
};
960+
961+
static void hns3_dump_page_pool_info(struct hns3_enet_ring *ring,
962+
char **result, u32 index)
963+
{
964+
u32 j = 0;
965+
966+
sprintf(result[j++], "%u", index);
967+
sprintf(result[j++], "%u", ring->page_pool->pages_state_hold_cnt);
968+
sprintf(result[j++], "%u",
969+
atomic_read(&ring->page_pool->pages_state_release_cnt));
970+
sprintf(result[j++], "%u", ring->page_pool->p.pool_size);
971+
sprintf(result[j++], "%u", ring->page_pool->p.order);
972+
sprintf(result[j++], "%d", ring->page_pool->p.nid);
973+
sprintf(result[j++], "%uK", ring->page_pool->p.max_len / 1024);
974+
}
975+
976+
static int
977+
hns3_dbg_page_pool_info(struct hnae3_handle *h, char *buf, int len)
978+
{
979+
char data_str[ARRAY_SIZE(page_pool_info_items)][HNS3_DBG_DATA_STR_LEN];
980+
char *result[ARRAY_SIZE(page_pool_info_items)];
981+
struct hns3_nic_priv *priv = h->priv;
982+
char content[HNS3_DBG_INFO_LEN];
983+
struct hns3_enet_ring *ring;
984+
int pos = 0;
985+
u32 i;
986+
987+
if (!priv->ring) {
988+
dev_err(&h->pdev->dev, "priv->ring is NULL\n");
989+
return -EFAULT;
990+
}
991+
992+
for (i = 0; i < ARRAY_SIZE(page_pool_info_items); i++)
993+
result[i] = &data_str[i][0];
994+
995+
hns3_dbg_fill_content(content, sizeof(content), page_pool_info_items,
996+
NULL, ARRAY_SIZE(page_pool_info_items));
997+
pos += scnprintf(buf + pos, len - pos, "%s", content);
998+
for (i = 0; i < h->kinfo.num_tqps; i++) {
999+
if (!test_bit(HNS3_NIC_STATE_INITED, &priv->state) ||
1000+
test_bit(HNS3_NIC_STATE_RESETTING, &priv->state))
1001+
return -EPERM;
1002+
ring = &priv->ring[(u32)(i + h->kinfo.num_tqps)];
1003+
hns3_dump_page_pool_info(ring, result, i);
1004+
hns3_dbg_fill_content(content, sizeof(content),
1005+
page_pool_info_items,
1006+
(const char **)result,
1007+
ARRAY_SIZE(page_pool_info_items));
1008+
pos += scnprintf(buf + pos, len - pos, "%s", content);
1009+
}
1010+
1011+
return 0;
1012+
}
1013+
9441014
static int hns3_dbg_get_cmd_index(struct hns3_dbg_data *dbg_data, u32 *index)
9451015
{
9461016
u32 i;
@@ -982,6 +1052,10 @@ static const struct hns3_dbg_func hns3_dbg_cmd_func[] = {
9821052
.cmd = HNAE3_DBG_CMD_TX_QUEUE_INFO,
9831053
.dbg_dump = hns3_dbg_tx_queue_info,
9841054
},
1055+
{
1056+
.cmd = HNAE3_DBG_CMD_PAGE_POOL_INFO,
1057+
.dbg_dump = hns3_dbg_page_pool_info,
1058+
},
9851059
};
9861060

9871061
static int hns3_dbg_read_cmd(struct hns3_dbg_data *dbg_data,

0 commit comments

Comments
 (0)