Skip to content

Commit 00f9ea2

Browse files
liuyonglong86kuba-moo
authored andcommitted
net: hns3: use seq_file for files in mac_list/ in debugfs
This patch use seq_file for the following nodes: uc/mc Signed-off-by: Yonglong Liu <[email protected]> Signed-off-by: Jijie Shao <[email protected]> Reviewed-by: Andrew Lunn <[email protected]> Acked-by: Arnd Bergmann <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 08a6476 commit 00f9ea2

File tree

2 files changed

+20
-41
lines changed

2 files changed

+20
-41
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,14 +149,14 @@ static struct hns3_dbg_cmd_info hns3_dbg_cmd[] = {
149149
.cmd = HNAE3_DBG_CMD_MAC_UC,
150150
.dentry = HNS3_DBG_DENTRY_MAC,
151151
.buf_len = HNS3_DBG_READ_LEN_128KB,
152-
.init = hns3_dbg_common_file_init,
152+
.init = hns3_dbg_common_init_t2,
153153
},
154154
{
155155
.name = "mc",
156156
.cmd = HNAE3_DBG_CMD_MAC_MC,
157157
.dentry = HNS3_DBG_DENTRY_MAC,
158158
.buf_len = HNS3_DBG_READ_LEN,
159-
.init = hns3_dbg_common_file_init,
159+
.init = hns3_dbg_common_init_t2,
160160
},
161161
{
162162
.name = "mng_tbl",

drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c

Lines changed: 18 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2482,50 +2482,29 @@ hclge_dbg_dump_mac_tnl_status(struct hclge_dev *hdev, char *buf, int len)
24822482
return 0;
24832483
}
24842484

2485-
2486-
static const struct hclge_dbg_item mac_list_items[] = {
2487-
{ "FUNC_ID", 2 },
2488-
{ "MAC_ADDR", 12 },
2489-
{ "STATE", 2 },
2490-
};
2491-
2492-
static void hclge_dbg_dump_mac_list(struct hclge_dev *hdev, char *buf, int len,
2493-
bool is_unicast)
2485+
static void hclge_dbg_dump_mac_list(struct seq_file *s, bool is_unicast)
24942486
{
2495-
char data_str[ARRAY_SIZE(mac_list_items)][HCLGE_DBG_DATA_STR_LEN];
2496-
char content[HCLGE_DBG_INFO_LEN], str_id[HCLGE_DBG_ID_LEN];
2497-
char *result[ARRAY_SIZE(mac_list_items)];
2487+
struct hclge_dev *hdev = hclge_seq_file_to_hdev(s);
24982488
struct hclge_mac_node *mac_node, *tmp;
24992489
struct hclge_vport *vport;
25002490
struct list_head *list;
2501-
u32 func_id, i;
2502-
int pos = 0;
2491+
u32 func_id;
25032492

2504-
for (i = 0; i < ARRAY_SIZE(mac_list_items); i++)
2505-
result[i] = &data_str[i][0];
2506-
2507-
pos += scnprintf(buf + pos, len - pos, "%s MAC_LIST:\n",
2508-
is_unicast ? "UC" : "MC");
2509-
hclge_dbg_fill_content(content, sizeof(content), mac_list_items,
2510-
NULL, ARRAY_SIZE(mac_list_items));
2511-
pos += scnprintf(buf + pos, len - pos, "%s", content);
2493+
seq_printf(s, "%s MAC_LIST:\n", is_unicast ? "UC" : "MC");
2494+
seq_puts(s, "FUNC_ID MAC_ADDR STATE\n");
25122495

25132496
for (func_id = 0; func_id < hdev->num_alloc_vport; func_id++) {
25142497
vport = &hdev->vport[func_id];
25152498
list = is_unicast ? &vport->uc_mac_list : &vport->mc_mac_list;
25162499
spin_lock_bh(&vport->mac_list_lock);
25172500
list_for_each_entry_safe(mac_node, tmp, list, node) {
2518-
i = 0;
2519-
result[i++] = hclge_dbg_get_func_id_str(str_id,
2520-
func_id);
2521-
sprintf(result[i++], "%pM", mac_node->mac_addr);
2522-
sprintf(result[i++], "%5s",
2523-
hclge_mac_state_str[mac_node->state]);
2524-
hclge_dbg_fill_content(content, sizeof(content),
2525-
mac_list_items,
2526-
(const char **)result,
2527-
ARRAY_SIZE(mac_list_items));
2528-
pos += scnprintf(buf + pos, len - pos, "%s", content);
2501+
if (func_id)
2502+
seq_printf(s, "vf%-7u", func_id - 1U);
2503+
else
2504+
seq_puts(s, "pf ");
2505+
seq_printf(s, "%pM ", mac_node->mac_addr);
2506+
seq_printf(s, "%5s\n",
2507+
hclge_mac_state_str[mac_node->state]);
25292508
}
25302509
spin_unlock_bh(&vport->mac_list_lock);
25312510
}
@@ -2893,16 +2872,16 @@ static int hclge_dbg_dump_ptp_info(struct hclge_dev *hdev, char *buf, int len)
28932872
return 0;
28942873
}
28952874

2896-
static int hclge_dbg_dump_mac_uc(struct hclge_dev *hdev, char *buf, int len)
2875+
static int hclge_dbg_dump_mac_uc(struct seq_file *s, void *data)
28972876
{
2898-
hclge_dbg_dump_mac_list(hdev, buf, len, true);
2877+
hclge_dbg_dump_mac_list(s, true);
28992878

29002879
return 0;
29012880
}
29022881

2903-
static int hclge_dbg_dump_mac_mc(struct hclge_dev *hdev, char *buf, int len)
2882+
static int hclge_dbg_dump_mac_mc(struct seq_file *s, void *data)
29042883
{
2905-
hclge_dbg_dump_mac_list(hdev, buf, len, false);
2884+
hclge_dbg_dump_mac_list(s, false);
29062885

29072886
return 0;
29082887
}
@@ -2954,11 +2933,11 @@ static const struct hclge_dbg_func hclge_dbg_cmd_func[] = {
29542933
},
29552934
{
29562935
.cmd = HNAE3_DBG_CMD_MAC_UC,
2957-
.dbg_dump = hclge_dbg_dump_mac_uc,
2936+
.dbg_read_func = hclge_dbg_dump_mac_uc,
29582937
},
29592938
{
29602939
.cmd = HNAE3_DBG_CMD_MAC_MC,
2961-
.dbg_dump = hclge_dbg_dump_mac_mc,
2940+
.dbg_read_func = hclge_dbg_dump_mac_mc,
29622941
},
29632942
{
29642943
.cmd = HNAE3_DBG_CMD_MNG_TBL,

0 commit comments

Comments
 (0)