From: Guojia Liao liaoguojia@huawei.com
driver inclusion category: bugfix bugzilla: NA CVE: NA
-------------------------------------
This patch adds support of dumping MAC umv counter in debugfs, which will be helpful for debugging.
Signed-off-by: Guojia Liao liaoguojia@huawei.com Reviewed-by: Peng Li lipeng321@huawei.com Reviewed-by: Weiwei Deng dengweiwei@huawei.com Reviewed-by: Zhaohui Zhong zhongzhaohui@huawei.com Reviewed-by: Junxin Chen chenjunxin1@huawei.com Signed-off-by: Shengzui You youshengzui@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- .../ethernet/hisilicon/hns3/hns3_debugfs.c | 1 + .../hisilicon/hns3/hns3pf/hclge_debugfs.c | 47 +++++++++++++++++++ 2 files changed, 48 insertions(+)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c index 9f4a849107598..98f2142c41bbd 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c @@ -265,6 +265,7 @@ static void hns3_dbg_help(struct hnae3_handle *h) dev_info(&h->pdev->dev, "dump qs shaper [qs id]\n"); dev_info(&h->pdev->dev, "dump uc mac list <func id>\n"); dev_info(&h->pdev->dev, "dump mc mac list <func id>\n"); + dev_info(&h->pdev->dev, "dump umv info <func id>\n"); dev_info(&h->pdev->dev, "dump vlan filter <func id>\n");
memset(printf_buf, 0, HNS3_DBG_BUF_LEN); diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c index 78f13dd77cf1d..fd86a34f36df8 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c @@ -1615,6 +1615,49 @@ static int hclge_dbg_dump_mac_list(struct hclge_dev *hdev, const char *cmd_buf, return 0; }
+static void hclge_dbg_dump_umv_info(struct hclge_dev *hdev, const char *cmd_buf) +{ + struct hclge_vport *vport; + u16 share_umv_size; + u16 priv_umv_size; + u16 used_umv_num; + u32 vf_id; + int ret; + + 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; + } + + 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; + 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); +} + static void hclge_dbg_dump_vlan_filter(struct hclge_dev *hdev, const char *cmd_buf) { @@ -1672,6 +1715,7 @@ int hclge_dbg_run_cmd(struct hnae3_handle *handle, const char *cmd_buf) #define DUMP_REG "dump reg" #define DUMP_LOOPBACK "dump loopback" #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; @@ -1725,6 +1769,9 @@ 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;