]> git.baikalelectronics.ru Git - kernel.git/commitdiff
net: hns3: add support for dumping UC and MC MAC list
authorJian Shen <shenjian15@huawei.com>
Fri, 24 Apr 2020 02:23:10 +0000 (10:23 +0800)
committerDavid S. Miller <davem@davemloft.net>
Sun, 26 Apr 2020 03:29:44 +0000 (20:29 -0700)
This patch adds support for dumping entries of UC and MC MAC list,
which help checking whether a MAC address being added into hardware
or not.

Signed-off-by: Jian Shen <shenjian15@huawei.com>
Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c

index c934f328c040277a0518ebdb7efce5c3428d445d..fe7fb565da19743bdc833705bcf54d2822b88f42 100644 (file)
@@ -262,6 +262,8 @@ static void hns3_dbg_help(struct hnae3_handle *h)
        dev_info(&h->pdev->dev, "dump mac tnl status\n");
        dev_info(&h->pdev->dev, "dump loopback\n");
        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");
 
        memset(printf_buf, 0, HNS3_DBG_BUF_LEN);
        strncat(printf_buf, "dump reg [[bios common] [ssu <port_id>]",
index 66c1ad3a156bfcbf35261de6923678ab1a66b1be..6cfa8253eefc30855267269afa9aeda0e872daf0 100644 (file)
@@ -1441,6 +1441,49 @@ static void hclge_dbg_dump_qs_shaper(struct hclge_dev *hdev,
        hclge_dbg_dump_qs_shaper_single(hdev, qsid);
 }
 
+static int hclge_dbg_dump_mac_list(struct hclge_dev *hdev, const char *cmd_buf,
+                                  bool is_unicast)
+{
+       struct hclge_mac_node *mac_node, *tmp;
+       struct hclge_vport *vport;
+       struct list_head *list;
+       u32 func_id;
+       int ret;
+
+       ret = kstrtouint(cmd_buf, 0, &func_id);
+       if (ret < 0) {
+               dev_err(&hdev->pdev->dev,
+                       "dump mac list: bad command string, ret = %d\n", ret);
+               return -EINVAL;
+       }
+
+       if (func_id >= hdev->num_alloc_vport) {
+               dev_err(&hdev->pdev->dev,
+                       "function id(%u) is out of range(0-%u)\n", func_id,
+                       hdev->num_alloc_vport - 1);
+               return -EINVAL;
+       }
+
+       vport = &hdev->vport[func_id];
+
+       list = is_unicast ? &vport->uc_mac_list : &vport->mc_mac_list;
+
+       dev_info(&hdev->pdev->dev, "vport %u %s mac list:\n",
+                func_id, is_unicast ? "uc" : "mc");
+       dev_info(&hdev->pdev->dev, "mac address              state\n");
+
+       spin_lock_bh(&vport->mac_list_lock);
+
+       list_for_each_entry_safe(mac_node, tmp, list, node) {
+               dev_info(&hdev->pdev->dev, "%pM         %d\n",
+                        mac_node->mac_addr, mac_node->state);
+       }
+
+       spin_unlock_bh(&vport->mac_list_lock);
+
+       return 0;
+}
+
 int hclge_dbg_run_cmd(struct hnae3_handle *handle, const char *cmd_buf)
 {
 #define DUMP_REG       "dump reg"
@@ -1485,6 +1528,14 @@ int hclge_dbg_run_cmd(struct hnae3_handle *handle, const char *cmd_buf)
        } else if (strncmp(cmd_buf, "dump qs shaper", 14) == 0) {
                hclge_dbg_dump_qs_shaper(hdev,
                                         &cmd_buf[sizeof("dump qs shaper")]);
+       } else if (strncmp(cmd_buf, "dump uc mac list", 16) == 0) {
+               hclge_dbg_dump_mac_list(hdev,
+                                       &cmd_buf[sizeof("dump uc mac list")],
+                                       true);
+       } else if (strncmp(cmd_buf, "dump mc mac list", 16) == 0) {
+               hclge_dbg_dump_mac_list(hdev,
+                                       &cmd_buf[sizeof("dump mc mac list")],
+                                       false);
        } else {
                dev_info(&hdev->pdev->dev, "unknown command\n");
                return -EINVAL;