From patchwork Fri Nov 9 22:07:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salil Mehta X-Patchwork-Id: 150702 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp393372ljp; Fri, 9 Nov 2018 14:10:02 -0800 (PST) X-Google-Smtp-Source: AJdET5cbVBLVEOFfw1N4psnxxeXM7FYYPfNRn/BvmrwxpM2bO/UqAIvT9ahIeJRueMrKODfnqlpH X-Received: by 2002:a17:902:1105:: with SMTP id d5-v6mr11009998pla.28.1541801402854; Fri, 09 Nov 2018 14:10:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541801402; cv=none; d=google.com; s=arc-20160816; b=wOlakZU6IR76p/VCNfzV6t4uAA6nH0hyujPn6XJX/rGgyCI98n+Bv89kl3olfXD5Y9 gRpRGfUDhai4Tk/2C5sl/9HXJCmuWVGe8JI6SRK2rcmOoLMzfBLpi6DpNz+2Ky/wufm0 HHFHqCHkqv5cyRho+RE5XlDI6N8ENdLeToL891eEwkV3ce9sG2IpFbYLB954G71DAyxR mCQ0msTlkZh+3nZUdrLyuWjoAK4Jp543d/vINh7FLcyHKynkx7uMef9HjE6yDntpIYix x9PIDetrP9Rd9VlcU391aV+cBlke765TMNaTVxqGsUxgqOm/SUxHsrzuNcmgsLAy+Uc0 mnXQ== 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=uBhZx4V4YYRasnvoHhMKQ6Htw1R5KiUIIgDd/YVQFiw=; b=oRLQ9zDugz+ES2URA8/95L9NQSO7QCjBx7UVB5Ovsi04/csq2B9r9ycXU3zfk8Dzg2 CEVg7u26mH8ktoagiD+1X5fvCSPKLk0UCFlZpVVUAXnI5KLn0ceonrXxj2oSHdkSpt7u Sz9TXQ1uKrLMZoF4fM+Go3S4WPqj5wPMFs3FYh5CwpaMEE4mvRTGTiH/1SEH4IC8Su/D 5+NTQW12jOEfQHmgsmurq9yihsigI8jQneZS2968XscFmlflVchme3unbUDDfDaEh7wQ 8KviTuYgAPIvI7T3sIKWDZ5bK78o+vgqm3T50q1TPENlaOWn8vfwo/EP0rtZ1FKuBpiG tFkw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u129-v6si1382718pfb.201.2018.11.09.14.10.02; Fri, 09 Nov 2018 14:10:02 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728947AbeKJHwb (ORCPT + 32 others); Sat, 10 Nov 2018 02:52:31 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:43848 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728651AbeKJHve (ORCPT ); Sat, 10 Nov 2018 02:51:34 -0500 Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id A3D5B4F566EBB; Sat, 10 Nov 2018 06:08:58 +0800 (CST) Received: from S00293818-DELL1.china.huawei.com (10.202.226.54) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.408.0; Sat, 10 Nov 2018 06:08:49 +0800 From: Salil Mehta To: CC: , , , , , , , , , , , liuzhongzhu Subject: [RFC PATCH 04/10] net: hns3: Add "promisc mode" config info query function Date: Fri, 9 Nov 2018 22:07:37 +0000 Message-ID: <20181109220743.10264-5-salil.mehta@huawei.com> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20181109220743.10264-1-salil.mehta@huawei.com> References: <20181109220743.10264-1-salil.mehta@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.202.226.54] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: liuzhongzhu This patch prints promiscuous mode status. debugfs command: echo dump promisc 0 > cmd Sample Output: root@(none)# echo dump promisc 0 > cmd hns3 0000:7d:00.0: vf(0) promisc mode hns3 0000:7d:00.0: uc: disable hns3 0000:7d:00.0: mc: disable hns3 0000:7d:00.0: bc: disable root@(none)# Signed-off-by: liuzhongzhu Signed-off-by: Salil Mehta --- drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c | 1 + .../ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c | 53 ++++++++++++++++++++++ 2 files changed, 54 insertions(+) -- 2.7.4 diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c index 0bc2f59..47afdcd 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c @@ -129,6 +129,7 @@ static void hns3_dbg_help(struct hnae3_handle *h) dev_info(&h->pdev->dev, "available commands\n"); dev_info(&h->pdev->dev, "queue info [number]\n"); dev_info(&h->pdev->dev, "dump fd tcam\n"); + dev_info(&h->pdev->dev, "dump promisc [vf id]\n"); } static ssize_t hns3_dbg_cmd_read(struct file *filp, char __user *buffer, diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c index feaf332..0a12473 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c @@ -7,6 +7,57 @@ #include "hclge_main.h" #include "hnae3.h" +static void hclge_print(struct hclge_dev *hdev, bool flag, char *true_buf, + char *false_buf) +{ + if (flag) + dev_info(&hdev->pdev->dev, "%s\n", true_buf); + else + dev_info(&hdev->pdev->dev, "%s\n", false_buf); +} + +static void hclge_dbg_dump_promisc_cfg(struct hclge_dev *hdev, char *cmd_buf) +{ +#define HCLGE_DBG_UC_MODE_B BIT(1) +#define HCLGE_DBG_MC_MODE_B BIT(2) +#define HCLGE_DBG_BC_MODE_B BIT(3) + + struct hclge_promisc_cfg_cmd *req; + struct hclge_desc desc; + u16 vf_id; + int ret; + + ret = kstrtou16(&cmd_buf[13], 10, &vf_id); + if (ret) + vf_id = 0; + + if (vf_id >= hdev->num_req_vfs) { + dev_err(&hdev->pdev->dev, "vf_id (%u) is out of range(%u)\n", + vf_id, hdev->num_req_vfs); + return; + } + + hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_CFG_PROMISC_MODE, true); + req = (struct hclge_promisc_cfg_cmd *)desc.data; + req->vf_id = (u8)vf_id; + + ret = hclge_cmd_send(&hdev->hw, &desc, 1); + if (ret) { + dev_err(&hdev->pdev->dev, + "dump promisc mode fail, status is %d.\n", ret); + return; + } + + dev_info(&hdev->pdev->dev, "vf(%u) promisc mode\n", req->vf_id); + + hclge_print(hdev, req->flag & HCLGE_DBG_UC_MODE_B, + "uc: enable", "uc: disable"); + hclge_print(hdev, req->flag & HCLGE_DBG_MC_MODE_B, + "mc: enable", "mc: disable"); + hclge_print(hdev, req->flag & HCLGE_DBG_BC_MODE_B, + "bc: enable", "bc: disable"); +} + static void hclge_dbg_fd_tcam_read(struct hclge_dev *hdev, u8 stage, bool sel_x, u32 loc) { @@ -68,6 +119,8 @@ int hclge_dbg_run_cmd(struct hnae3_handle *handle, char *cmd_buf) if (strncmp(cmd_buf, "dump fd tcam", 12) == 0) { hclge_dbg_fd_tcam(hdev); + } else if (strncmp(cmd_buf, "dump promisc", 12) == 0) { + hclge_dbg_dump_promisc_cfg(hdev, cmd_buf); } else { dev_info(&hdev->pdev->dev, "unknown command\n"); return -EINVAL;