Skip to content

Commit 08a6476

Browse files
IronShenkuba-moo
authored andcommitted
net: hns3: use seq_file for files in tm/ in debugfs
Use seq_file for files in debugfs. This is the first modification for reading in hclge_debugfs.c. This patch use seq_file for the following nodes: tm_nodes/tm_priority/tm_qset/tm_map/tm_pg/tm_port/tc_sch_info/ qos_pause_cfg/qos_pri_map/qos_dscp_map/qos_buf_cfg Signed-off-by: Jian Shen <[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 2b65524 commit 08a6476

File tree

6 files changed

+236
-334
lines changed

6 files changed

+236
-334
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,8 @@ typedef int (*read_func)(struct seq_file *s, void *data);
601601
* Get wake on lan info
602602
* set_wol
603603
* Config wake on lan
604+
* dbg_get_read_func
605+
* Return the read func for debugfs seq file
604606
*/
605607
struct hnae3_ae_ops {
606608
int (*init_ae_dev)(struct hnae3_ae_dev *ae_dev);
@@ -803,6 +805,9 @@ struct hnae3_ae_ops {
803805
struct ethtool_wolinfo *wol);
804806
int (*set_wol)(struct hnae3_handle *handle,
805807
struct ethtool_wolinfo *wol);
808+
int (*dbg_get_read_func)(struct hnae3_handle *handle,
809+
enum hnae3_dbg_cmd cmd,
810+
read_func *func);
806811
};
807812

808813
struct hnae3_dcb_ops {

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

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,84 +43,85 @@ static struct hns3_dbg_dentry_info hns3_dbg_dentry[] = {
4343
static int hns3_dbg_bd_file_init(struct hnae3_handle *handle, u32 cmd);
4444
static int hns3_dbg_common_file_init(struct hnae3_handle *handle, u32 cmd);
4545
static int hns3_dbg_common_init_t1(struct hnae3_handle *handle, u32 cmd);
46+
static int hns3_dbg_common_init_t2(struct hnae3_handle *handle, u32 cmd);
4647

4748
static struct hns3_dbg_cmd_info hns3_dbg_cmd[] = {
4849
{
4950
.name = "tm_nodes",
5051
.cmd = HNAE3_DBG_CMD_TM_NODES,
5152
.dentry = HNS3_DBG_DENTRY_TM,
5253
.buf_len = HNS3_DBG_READ_LEN,
53-
.init = hns3_dbg_common_file_init,
54+
.init = hns3_dbg_common_init_t2,
5455
},
5556
{
5657
.name = "tm_priority",
5758
.cmd = HNAE3_DBG_CMD_TM_PRI,
5859
.dentry = HNS3_DBG_DENTRY_TM,
5960
.buf_len = HNS3_DBG_READ_LEN,
60-
.init = hns3_dbg_common_file_init,
61+
.init = hns3_dbg_common_init_t2,
6162
},
6263
{
6364
.name = "tm_qset",
6465
.cmd = HNAE3_DBG_CMD_TM_QSET,
6566
.dentry = HNS3_DBG_DENTRY_TM,
6667
.buf_len = HNS3_DBG_READ_LEN_1MB,
67-
.init = hns3_dbg_common_file_init,
68+
.init = hns3_dbg_common_init_t2,
6869
},
6970
{
7071
.name = "tm_map",
7172
.cmd = HNAE3_DBG_CMD_TM_MAP,
7273
.dentry = HNS3_DBG_DENTRY_TM,
7374
.buf_len = HNS3_DBG_READ_LEN_1MB,
74-
.init = hns3_dbg_common_file_init,
75+
.init = hns3_dbg_common_init_t2,
7576
},
7677
{
7778
.name = "tm_pg",
7879
.cmd = HNAE3_DBG_CMD_TM_PG,
7980
.dentry = HNS3_DBG_DENTRY_TM,
8081
.buf_len = HNS3_DBG_READ_LEN,
81-
.init = hns3_dbg_common_file_init,
82+
.init = hns3_dbg_common_init_t2,
8283
},
8384
{
8485
.name = "tm_port",
8586
.cmd = HNAE3_DBG_CMD_TM_PORT,
8687
.dentry = HNS3_DBG_DENTRY_TM,
8788
.buf_len = HNS3_DBG_READ_LEN,
88-
.init = hns3_dbg_common_file_init,
89+
.init = hns3_dbg_common_init_t2,
8990
},
9091
{
9192
.name = "tc_sch_info",
9293
.cmd = HNAE3_DBG_CMD_TC_SCH_INFO,
9394
.dentry = HNS3_DBG_DENTRY_TM,
9495
.buf_len = HNS3_DBG_READ_LEN,
95-
.init = hns3_dbg_common_file_init,
96+
.init = hns3_dbg_common_init_t2,
9697
},
9798
{
9899
.name = "qos_pause_cfg",
99100
.cmd = HNAE3_DBG_CMD_QOS_PAUSE_CFG,
100101
.dentry = HNS3_DBG_DENTRY_TM,
101102
.buf_len = HNS3_DBG_READ_LEN,
102-
.init = hns3_dbg_common_file_init,
103+
.init = hns3_dbg_common_init_t2,
103104
},
104105
{
105106
.name = "qos_pri_map",
106107
.cmd = HNAE3_DBG_CMD_QOS_PRI_MAP,
107108
.dentry = HNS3_DBG_DENTRY_TM,
108109
.buf_len = HNS3_DBG_READ_LEN,
109-
.init = hns3_dbg_common_file_init,
110+
.init = hns3_dbg_common_init_t2,
110111
},
111112
{
112113
.name = "qos_dscp_map",
113114
.cmd = HNAE3_DBG_CMD_QOS_DSCP_MAP,
114115
.dentry = HNS3_DBG_DENTRY_TM,
115116
.buf_len = HNS3_DBG_READ_LEN,
116-
.init = hns3_dbg_common_file_init,
117+
.init = hns3_dbg_common_init_t2,
117118
},
118119
{
119120
.name = "qos_buf_cfg",
120121
.cmd = HNAE3_DBG_CMD_QOS_BUF_CFG,
121122
.dentry = HNS3_DBG_DENTRY_TM,
122123
.buf_len = HNS3_DBG_READ_LEN,
123-
.init = hns3_dbg_common_file_init,
124+
.init = hns3_dbg_common_init_t2,
124125
},
125126
{
126127
.name = "dev_info",
@@ -1144,6 +1145,28 @@ static int hns3_dbg_common_init_t1(struct hnae3_handle *handle, u32 cmd)
11441145
return 0;
11451146
}
11461147

1148+
static int hns3_dbg_common_init_t2(struct hnae3_handle *handle, u32 cmd)
1149+
{
1150+
const struct hnae3_ae_ops *ops = hns3_get_ops(handle);
1151+
struct device *dev = &handle->pdev->dev;
1152+
struct dentry *entry_dir;
1153+
read_func func;
1154+
int ret;
1155+
1156+
if (!ops->dbg_get_read_func)
1157+
return 0;
1158+
1159+
ret = ops->dbg_get_read_func(handle, hns3_dbg_cmd[cmd].cmd, &func);
1160+
if (ret)
1161+
return ret;
1162+
1163+
entry_dir = hns3_dbg_dentry[hns3_dbg_cmd[cmd].dentry].dentry;
1164+
debugfs_create_devm_seqfile(dev, hns3_dbg_cmd[cmd].name, entry_dir,
1165+
func);
1166+
1167+
return 0;
1168+
}
1169+
11471170
int hns3_dbg_init(struct hnae3_handle *handle)
11481171
{
11491172
struct hnae3_ae_dev *ae_dev = hns3_get_ae_dev(handle);

0 commit comments

Comments
 (0)