Commit 6571ec2e authored by Guangbin Huang's avatar Guangbin Huang Committed by David S. Miller

net: hns3: refactor dump qos pause cfg of debugfs

Currently, user gets pause config by implementing debugfs command
"echo dump qos pause cfg > cmd", this command will dump info in dmesg.
It's unnecessary and heavy.

To optimize it, create a single file "qos_pause_cfg" in tm directory
and use cat command to get info. It will return info to userspace,
rather than record in dmesg.

The display style is below:
$ cat qos_pause_cfg
pause_trans_gap: 0x7f
pause_trans_time: 0xffff
Signed-off-by: default avatarGuangbin Huang <huangguangbin2@huawei.com>
Signed-off-by: default avatarHuazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 0e32038d
...@@ -258,6 +258,7 @@ enum hnae3_dbg_cmd { ...@@ -258,6 +258,7 @@ enum hnae3_dbg_cmd {
HNAE3_DBG_CMD_TM_PG, HNAE3_DBG_CMD_TM_PG,
HNAE3_DBG_CMD_TM_PORT, HNAE3_DBG_CMD_TM_PORT,
HNAE3_DBG_CMD_TC_SCH_INFO, HNAE3_DBG_CMD_TC_SCH_INFO,
HNAE3_DBG_CMD_QOS_PAUSE_CFG,
HNAE3_DBG_CMD_DEV_INFO, HNAE3_DBG_CMD_DEV_INFO,
HNAE3_DBG_CMD_TX_BD, HNAE3_DBG_CMD_TX_BD,
HNAE3_DBG_CMD_RX_BD, HNAE3_DBG_CMD_RX_BD,
......
...@@ -92,6 +92,13 @@ static struct hns3_dbg_cmd_info hns3_dbg_cmd[] = { ...@@ -92,6 +92,13 @@ static struct hns3_dbg_cmd_info hns3_dbg_cmd[] = {
.buf_len = HNS3_DBG_READ_LEN, .buf_len = HNS3_DBG_READ_LEN,
.init = hns3_dbg_common_file_init, .init = hns3_dbg_common_file_init,
}, },
{
.name = "qos_pause_cfg",
.cmd = HNAE3_DBG_CMD_QOS_PAUSE_CFG,
.dentry = HNS3_DBG_DENTRY_TM,
.buf_len = HNS3_DBG_READ_LEN,
.init = hns3_dbg_common_file_init,
},
{ {
.name = "dev_info", .name = "dev_info",
.cmd = HNAE3_DBG_CMD_DEV_INFO, .cmd = HNAE3_DBG_CMD_DEV_INFO,
...@@ -745,7 +752,6 @@ static void hns3_dbg_help(struct hnae3_handle *h) ...@@ -745,7 +752,6 @@ static void hns3_dbg_help(struct hnae3_handle *h)
if (!hns3_is_phys_func(h->pdev)) if (!hns3_is_phys_func(h->pdev))
return; return;
dev_info(&h->pdev->dev, "dump qos pause cfg\n");
dev_info(&h->pdev->dev, "dump qos pri map\n"); dev_info(&h->pdev->dev, "dump qos pri map\n");
dev_info(&h->pdev->dev, "dump qos buf cfg\n"); dev_info(&h->pdev->dev, "dump qos buf cfg\n");
dev_info(&h->pdev->dev, "dump mac tnl status\n"); dev_info(&h->pdev->dev, "dump mac tnl status\n");
......
...@@ -1028,27 +1028,29 @@ static int hclge_dbg_dump_tm_qset(struct hclge_dev *hdev, char *buf, int len) ...@@ -1028,27 +1028,29 @@ static int hclge_dbg_dump_tm_qset(struct hclge_dev *hdev, char *buf, int len)
return 0; return 0;
} }
static void hclge_dbg_dump_qos_pause_cfg(struct hclge_dev *hdev) static int hclge_dbg_dump_qos_pause_cfg(struct hclge_dev *hdev, char *buf,
int len)
{ {
struct hclge_cfg_pause_param_cmd *pause_param; struct hclge_cfg_pause_param_cmd *pause_param;
struct hclge_desc desc; struct hclge_desc desc;
int pos = 0;
int ret; int ret;
hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_CFG_MAC_PARA, true); hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_CFG_MAC_PARA, true);
ret = hclge_cmd_send(&hdev->hw, &desc, 1); ret = hclge_cmd_send(&hdev->hw, &desc, 1);
if (ret) { if (ret) {
dev_err(&hdev->pdev->dev, "dump checksum fail, ret = %d\n", dev_err(&hdev->pdev->dev,
ret); "failed to dump qos pause, ret = %d\n", ret);
return; return ret;
} }
pause_param = (struct hclge_cfg_pause_param_cmd *)desc.data; pause_param = (struct hclge_cfg_pause_param_cmd *)desc.data;
dev_info(&hdev->pdev->dev, "dump qos pause cfg\n");
dev_info(&hdev->pdev->dev, "pause_trans_gap: 0x%x\n", pos += scnprintf(buf + pos, len - pos, "pause_trans_gap: 0x%x\n",
pause_param->pause_trans_gap); pause_param->pause_trans_gap);
dev_info(&hdev->pdev->dev, "pause_trans_time: 0x%x\n", pos += scnprintf(buf + pos, len - pos, "pause_trans_time: 0x%x\n",
le16_to_cpu(pause_param->pause_trans_time)); le16_to_cpu(pause_param->pause_trans_time));
return 0;
} }
static void hclge_dbg_dump_qos_pri_map(struct hclge_dev *hdev) static void hclge_dbg_dump_qos_pri_map(struct hclge_dev *hdev)
...@@ -1894,9 +1896,7 @@ int hclge_dbg_run_cmd(struct hnae3_handle *handle, const char *cmd_buf) ...@@ -1894,9 +1896,7 @@ int hclge_dbg_run_cmd(struct hnae3_handle *handle, const char *cmd_buf)
struct hclge_vport *vport = hclge_get_vport(handle); struct hclge_vport *vport = hclge_get_vport(handle);
struct hclge_dev *hdev = vport->back; struct hclge_dev *hdev = vport->back;
if (strncmp(cmd_buf, "dump qos pause cfg", 18) == 0) { if (strncmp(cmd_buf, "dump qos pri map", 16) == 0) {
hclge_dbg_dump_qos_pause_cfg(hdev);
} else if (strncmp(cmd_buf, "dump qos pri map", 16) == 0) {
hclge_dbg_dump_qos_pri_map(hdev); hclge_dbg_dump_qos_pri_map(hdev);
} else if (strncmp(cmd_buf, "dump qos buf cfg", 16) == 0) { } else if (strncmp(cmd_buf, "dump qos buf cfg", 16) == 0) {
hclge_dbg_dump_qos_buf_cfg(hdev); hclge_dbg_dump_qos_buf_cfg(hdev);
...@@ -1944,6 +1944,10 @@ static const struct hclge_dbg_func hclge_dbg_cmd_func[] = { ...@@ -1944,6 +1944,10 @@ static const struct hclge_dbg_func hclge_dbg_cmd_func[] = {
.cmd = HNAE3_DBG_CMD_TC_SCH_INFO, .cmd = HNAE3_DBG_CMD_TC_SCH_INFO,
.dbg_dump = hclge_dbg_dump_tc, .dbg_dump = hclge_dbg_dump_tc,
}, },
{
.cmd = HNAE3_DBG_CMD_QOS_PAUSE_CFG,
.dbg_dump = hclge_dbg_dump_qos_pause_cfg,
},
{ {
.cmd = HNAE3_DBG_CMD_MAC_UC, .cmd = HNAE3_DBG_CMD_MAC_UC,
.dbg_dump = hclge_dbg_dump_mac_uc, .dbg_dump = hclge_dbg_dump_mac_uc,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment