Commit 28d3bada authored by Guangbin Huang's avatar Guangbin Huang Committed by David S. Miller

net: hns3: refactor dump qos pri map of debugfs

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

To optimize it, create a single file "qos_pri_map" 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_pri_map
vlan_to_pri: 0
PRI    TC
0       0
1       1
2       2
3       3
4       0
5       1
6       2
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 6571ec2e
...@@ -259,6 +259,7 @@ enum hnae3_dbg_cmd { ...@@ -259,6 +259,7 @@ enum hnae3_dbg_cmd {
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_QOS_PAUSE_CFG,
HNAE3_DBG_CMD_QOS_PRI_MAP,
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,
......
...@@ -99,6 +99,13 @@ static struct hns3_dbg_cmd_info hns3_dbg_cmd[] = { ...@@ -99,6 +99,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_pri_map",
.cmd = HNAE3_DBG_CMD_QOS_PRI_MAP,
.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,
...@@ -752,7 +759,6 @@ static void hns3_dbg_help(struct hnae3_handle *h) ...@@ -752,7 +759,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 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");
dev_info(&h->pdev->dev, "dump qs shaper [qs id]\n"); dev_info(&h->pdev->dev, "dump qs shaper [qs id]\n");
......
...@@ -1053,32 +1053,41 @@ static int hclge_dbg_dump_qos_pause_cfg(struct hclge_dev *hdev, char *buf, ...@@ -1053,32 +1053,41 @@ static int hclge_dbg_dump_qos_pause_cfg(struct hclge_dev *hdev, char *buf,
return 0; return 0;
} }
static void hclge_dbg_dump_qos_pri_map(struct hclge_dev *hdev) static int hclge_dbg_dump_qos_pri_map(struct hclge_dev *hdev, char *buf,
int len)
{ {
#define HCLGE_DBG_TC_MASK 0x0F
#define HCLGE_DBG_TC_BIT_WIDTH 4
struct hclge_qos_pri_map_cmd *pri_map; struct hclge_qos_pri_map_cmd *pri_map;
struct hclge_desc desc; struct hclge_desc desc;
int pos = 0;
u8 *pri_tc;
u8 tc, i;
int ret; int ret;
hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_PRI_TO_TC_MAPPING, true); hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_PRI_TO_TC_MAPPING, 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, dev_err(&hdev->pdev->dev,
"dump qos pri map fail, ret = %d\n", ret); "failed to dump qos pri map, ret = %d\n", ret);
return; return ret;
} }
pri_map = (struct hclge_qos_pri_map_cmd *)desc.data; pri_map = (struct hclge_qos_pri_map_cmd *)desc.data;
dev_info(&hdev->pdev->dev, "dump qos pri map\n");
dev_info(&hdev->pdev->dev, "vlan_to_pri: 0x%x\n", pri_map->vlan_pri); pos += scnprintf(buf + pos, len - pos, "vlan_to_pri: 0x%x\n",
dev_info(&hdev->pdev->dev, "pri_0_to_tc: 0x%x\n", pri_map->pri0_tc); pri_map->vlan_pri);
dev_info(&hdev->pdev->dev, "pri_1_to_tc: 0x%x\n", pri_map->pri1_tc); pos += scnprintf(buf + pos, len - pos, "PRI TC\n");
dev_info(&hdev->pdev->dev, "pri_2_to_tc: 0x%x\n", pri_map->pri2_tc);
dev_info(&hdev->pdev->dev, "pri_3_to_tc: 0x%x\n", pri_map->pri3_tc); pri_tc = (u8 *)pri_map;
dev_info(&hdev->pdev->dev, "pri_4_to_tc: 0x%x\n", pri_map->pri4_tc); for (i = 0; i < HNAE3_MAX_TC; i++) {
dev_info(&hdev->pdev->dev, "pri_5_to_tc: 0x%x\n", pri_map->pri5_tc); tc = pri_tc[i >> 1] >> ((i & 1) * HCLGE_DBG_TC_BIT_WIDTH);
dev_info(&hdev->pdev->dev, "pri_6_to_tc: 0x%x\n", pri_map->pri6_tc); tc &= HCLGE_DBG_TC_MASK;
dev_info(&hdev->pdev->dev, "pri_7_to_tc: 0x%x\n", pri_map->pri7_tc); pos += scnprintf(buf + pos, len - pos, "%u %u\n", i, tc);
}
return 0;
} }
static int hclge_dbg_dump_tx_buf_cfg(struct hclge_dev *hdev) static int hclge_dbg_dump_tx_buf_cfg(struct hclge_dev *hdev)
...@@ -1896,9 +1905,7 @@ int hclge_dbg_run_cmd(struct hnae3_handle *handle, const char *cmd_buf) ...@@ -1896,9 +1905,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 pri map", 16) == 0) { if (strncmp(cmd_buf, "dump qos buf cfg", 16) == 0) {
hclge_dbg_dump_qos_pri_map(hdev);
} 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);
} else if (strncmp(cmd_buf, "dump serv info", 14) == 0) { } else if (strncmp(cmd_buf, "dump serv info", 14) == 0) {
hclge_dbg_dump_serv_info(hdev); hclge_dbg_dump_serv_info(hdev);
...@@ -1948,6 +1955,10 @@ static const struct hclge_dbg_func hclge_dbg_cmd_func[] = { ...@@ -1948,6 +1955,10 @@ static const struct hclge_dbg_func hclge_dbg_cmd_func[] = {
.cmd = HNAE3_DBG_CMD_QOS_PAUSE_CFG, .cmd = HNAE3_DBG_CMD_QOS_PAUSE_CFG,
.dbg_dump = hclge_dbg_dump_qos_pause_cfg, .dbg_dump = hclge_dbg_dump_qos_pause_cfg,
}, },
{
.cmd = HNAE3_DBG_CMD_QOS_PRI_MAP,
.dbg_dump = hclge_dbg_dump_qos_pri_map,
},
{ {
.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