From: Jian Shen shenjian15@huawei.com
mainline inclusion from mainline-v5.14-rc1 commit d59daf6a4ceedf342f349e94f1300e1598213252 category: feature bugzilla: NA CVE: NA
----------------------------
This patch adds support of dumping MAC umv counter in debugfs, which will be helpful for debugging.
The display style is below: $ cat umv_info num_alloc_vport : 2 max_umv_size : 256 wanted_umv_size : 256 priv_umv_size : 85 share_umv_size : 86 vport(0) used_umv_num : 1 vport(1) used_umv_num : 1
Signed-off-by: Jian Shen shenjian15@huawei.com Signed-off-by: Guangbin Huang huangguangbin2@huawei.com Signed-off-by: David S. Miller davem@davemloft.net Signed-off-by: Yonglong Liu liuyonglong@huawei.com Reviewed-by: Junxin Chen chenjunxin1@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/net/ethernet/hisilicon/hns3/hnae3.h | 1 + .../ethernet/hisilicon/hns3/hns3_debugfs.c | 8 ++- .../hisilicon/hns3/hns3pf/hclge_debugfs.c | 63 ++++++++----------- 3 files changed, 33 insertions(+), 39 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.h b/drivers/net/ethernet/hisilicon/hns3/hnae3.h index 44ae4e8e0db7d..eff07fa0e3f2f 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hnae3.h +++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.h @@ -216,6 +216,7 @@ enum hnae3_dbg_cmd { HNAE3_DBG_CMD_FD_TCAM, HNAE3_DBG_CMD_MAC_TNL_STATUS, HNAE3_DBG_CMD_SERV_INFO, + HNAE3_DBG_CMD_UMV_INFO, HNAE3_DBG_CMD_UNKNOWN, };
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c index 09c16ff9bc845..d83ac7f37a56b 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c @@ -295,6 +295,13 @@ static struct hns3_dbg_cmd_info hns3_dbg_cmd[] = { .buf_len = HNS3_DBG_READ_LEN, .init = hns3_dbg_common_file_init, }, + { + .name = "umv_info", + .cmd = HNAE3_DBG_CMD_UMV_INFO, + .dentry = HNS3_DBG_DENTRY_COMMON, + .buf_len = HNS3_DBG_READ_LEN, + .init = hns3_dbg_common_file_init, + }, };
static void hns3_dbg_fill_content(char *content, u16 len, @@ -714,7 +721,6 @@ static void hns3_dbg_help(struct hnae3_handle *h) return;
dev_info(&h->pdev->dev, "dump mac tbl\n"); - dev_info(&h->pdev->dev, "dump umv info <func id>\n"); dev_info(&h->pdev->dev, "dump vlan filter <func id>\n"); }
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c index 1c6cdc7816206..0e751272d1d6e 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c @@ -1994,47 +1994,34 @@ static int hclge_dbg_dump_mac_mc(struct hclge_dev *hdev, char *buf, int len) return 0; }
-static void hclge_dbg_dump_umv_info(struct hclge_dev *hdev, const char *cmd_buf) +static int hclge_dbg_dump_umv_info(struct hclge_dev *hdev, char *buf, int len) { + u8 func_num = pci_num_vf(hdev->pdev) + 1; struct hclge_vport *vport; - u16 share_umv_size; - u16 priv_umv_size; - u16 used_umv_num; - u32 vf_id; - int ret; + int pos = 0; + u8 i;
- ret = kstrtouint(cmd_buf, 0, &vf_id); - if (ret < 0) { - dev_err(&hdev->pdev->dev, - "failed to dump umv info: bad command string, ret = %d\n", - ret); - return; - } + pos += scnprintf(buf, len, "num_alloc_vport : %u\n", + hdev->num_alloc_vport); + pos += scnprintf(buf + pos, len - pos, "max_umv_size : %u\n", + hdev->max_umv_size); + pos += scnprintf(buf + pos, len - pos, "wanted_umv_size : %u\n", + hdev->wanted_umv_size); + pos += scnprintf(buf + pos, len - pos, "priv_umv_size : %u\n", + hdev->priv_umv_size);
- if (vf_id >= hdev->num_alloc_vport) { - dev_err(&hdev->pdev->dev, - "vf id(%u) is out of range(0-%u)\n", vf_id, - hdev->num_alloc_vport - 1); - return; - } - - vport = &hdev->vport[vf_id]; mutex_lock(&hdev->vport_lock); - priv_umv_size = hdev->priv_umv_size; - share_umv_size = hdev->share_umv_size; - used_umv_num = vport->used_umv_num; + pos += scnprintf(buf + pos, len - pos, "share_umv_size : %u\n", + hdev->share_umv_size); + for (i = 0; i < func_num; i++) { + vport = &hdev->vport[i]; + pos += scnprintf(buf + pos, len - pos, + "vport(%u) used_umv_num : %u\n", + i, vport->used_umv_num); + } mutex_unlock(&hdev->vport_lock);
- dev_info(&hdev->pdev->dev, "num_alloc_vport : %u\n", - hdev->num_alloc_vport); - dev_info(&hdev->pdev->dev, "max_umv_size : %u\n", - hdev->max_umv_size); - dev_info(&hdev->pdev->dev, "wanted_umv_size : %u\n", - hdev->wanted_umv_size); - dev_info(&hdev->pdev->dev, "priv_umv_size : %u\n", priv_umv_size); - dev_info(&hdev->pdev->dev, "share_umv_size : %u\n", share_umv_size); - dev_info(&hdev->pdev->dev, "vport(%u) used_umv_num : %u\n", - vf_id, used_umv_num); + return 0; }
static void hclge_dbg_dump_vlan_filter(struct hclge_dev *hdev, @@ -2092,7 +2079,6 @@ static void hclge_dbg_dump_vlan_filter(struct hclge_dev *hdev, int hclge_dbg_run_cmd(struct hnae3_handle *handle, const char *cmd_buf) { #define DUMP_VLAN_FILTER "dump vlan filter" -#define DUMP_UMV_INFO "dump umv info"
struct hclge_vport *vport = hclge_get_vport(handle); struct hclge_dev *hdev = vport->back; @@ -2103,9 +2089,6 @@ int hclge_dbg_run_cmd(struct hnae3_handle *handle, const char *cmd_buf) strlen(DUMP_VLAN_FILTER)) == 0) { hclge_dbg_dump_vlan_filter(hdev, &cmd_buf[sizeof(DUMP_VLAN_FILTER)]); - } else if (strncmp(cmd_buf, DUMP_UMV_INFO, - strlen(DUMP_UMV_INFO)) == 0) { - hclge_dbg_dump_umv_info(hdev, &cmd_buf[sizeof(DUMP_UMV_INFO)]); } else { dev_info(&hdev->pdev->dev, "unknown command\n"); return -EINVAL; @@ -2239,6 +2222,10 @@ static const struct hclge_dbg_func hclge_dbg_cmd_func[] = { .cmd = HNAE3_DBG_CMD_SERV_INFO, .dbg_dump = hclge_dbg_dump_serv_info, }, + { + .cmd = HNAE3_DBG_CMD_UMV_INFO, + .dbg_dump = hclge_dbg_dump_umv_info, + }, };
int hclge_dbg_read_cmd(struct hnae3_handle *handle, enum hnae3_dbg_cmd cmd,