Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1432927ybz; Sat, 25 Apr 2020 19:17:17 -0700 (PDT) X-Google-Smtp-Source: APiQypJXt0DP7JfvrC06aulsdaG0oARx7Mx0LC02n5XfvkUsN51Mxo7mDuEKCC4tj2bxu4qW7P+Z X-Received: by 2002:a17:906:2b96:: with SMTP id m22mr13628555ejg.330.1587867437308; Sat, 25 Apr 2020 19:17:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587867437; cv=none; d=google.com; s=arc-20160816; b=oqWIh4Foc1HA+hHjN4bd4QnlWpoP3gQuCLrh+8iokcXrVOClWNDh90O4zPM3mLliZX FmjzJUi1O7V5yfUDb7SPDrK7To3G8cbfGWg06Gi9rLhrVp3MJ/w95BcvbSKTGH54a2h4 bcYZPDI6zEZvyEducKjwwTLQ1rw/v2tLQQ8n9PtHqnrTPXEHjaoKt5CU7RuD7F6xShc9 JtmPbm/1Y1ajoL55kRJC1DLtafLRpIE5G+rgnYdwZ2HDpSfiEAbxQcPRW8cIBcFwlAzH UVKEvCz7IQH2/cIy20zVACEX5fpKR6UYc66vQgIsHffXP34CkfEzfiZba0YOGyaFXk2R v4+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=b26UddVoBDmwbMZb+x32jc3JhaJ4izNRp5Dlcxosuks=; b=OLv3j9/BagFayrK40eLkYrwQzfUUIO6OoJs1URZpAgQTpq35HgoBHesLVHfcIfLrAt nM/KTo6Z/ixfvx1sosFvhF6i9M/ECcH+6DsLd1anCyEqhPJHisu1DONzx0h1poWvyHqk nthKdG2rHfIFSW6MZdvigi0QORnYXxXDG9lLWn2JmfsOcoBovcTs2GOS5vWoM3YPtHEd FgXz7MsipXw4s3Vb+zNNcuvwjC/SGHKdkM4X55E9DFfyXmA++X0Mm3v7qQVnk+sP+FXe q9mrNt/QdXbvqk8aXrsNQQMP9VdaT5Cn+Lx953JafoOQjbchGYHA4ROmmvaCkr9ZV1a9 c2cw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dn15si5713584edb.555.2020.04.25.19.16.53; Sat, 25 Apr 2020 19:17:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726400AbgDZCPV (ORCPT + 99 others); Sat, 25 Apr 2020 22:15:21 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:3294 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726196AbgDZCPN (ORCPT ); Sat, 25 Apr 2020 22:15:13 -0400 Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 26F4AEB0D30F6222F3A2; Sun, 26 Apr 2020 10:15:12 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.487.0; Sun, 26 Apr 2020 10:15:01 +0800 From: Huazhong Tan To: CC: , , , , , , Jian Shen , Huazhong Tan Subject: [PATCH V2 net-next 5/9] net: hns3: add support for dumping UC and MC MAC list Date: Sun, 26 Apr 2020 10:13:44 +0800 Message-ID: <1587867228-9955-6-git-send-email-tanhuazhong@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1587867228-9955-1-git-send-email-tanhuazhong@huawei.com> References: <1587867228-9955-1-git-send-email-tanhuazhong@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jian Shen 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 Signed-off-by: Huazhong Tan --- drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c | 2 + .../ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c | 51 ++++++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c index c934f32..fe7fb56 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c @@ -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 \n"); + dev_info(&h->pdev->dev, "dump mc mac list \n"); memset(printf_buf, 0, HNS3_DBG_BUF_LEN); strncat(printf_buf, "dump reg [[bios common] [ssu ]", diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c index 66c1ad3..6cfa825 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c @@ -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; -- 2.7.4