From patchwork Sun Dec 2 23:09:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salil Mehta X-Patchwork-Id: 152666 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp6164066ljp; Sun, 2 Dec 2018 15:11:21 -0800 (PST) X-Google-Smtp-Source: AFSGD/XLy+dxXuXfs/qt0NtdTlza28jWSDqFZnsbz5YX01aMCu9ipqyU2HyLFfqQqi2+lVVd3xeQ X-Received: by 2002:aa7:8045:: with SMTP id y5mr13598960pfm.62.1543792281161; Sun, 02 Dec 2018 15:11:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543792281; cv=none; d=google.com; s=arc-20160816; b=05yyFtQd1CejO3TOnAWPpq/naM+2pTPmX3A6amyRGu14hNHmASOyAfE8HMGeMcWWYL IrSFsieOlefbuyCxt4zoX/6AzaBg/Jh1aBj8saaEslA1ZSwX2Kpi28pYOiM+59YnJaSw Fb9dNAWjMetDA5T0bWHE7sZK+RZxFBLp7R8mud/2ED+iEyDdnFHG45ZxD9P5QG9x76vY xeGN21u14+GWsXtl7JFf053k7pNnxUQjE0cKno3DwpNJ8GvtML55qIFvnDZF1XWMjlJ7 de61n1+7X3rvzMFu+j1fO5oA68yvZia8QCZBX+yQjQpyPVloQM5he+gVZ5dgBI0c7Sm4 tbSw== 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=7dDkD5EsnQxxhtmXyC7MAV+KonZnptPR2EqJ4vwpHRk=; b=xFh8PNrQ8sTnMZ1LlA2F6usQNUOsQSuCoTJSSgJQjCuzl99ru0UCyhJ8JERjA39tmz dgnie7Sz16Jg2CIcyHrNjQXvkmxDzkLc29iwvmvilpRbDpGLCNf7OECG4LjpQh7lNcAv 0l+rc2509+UjmFv7T7ETzDTl+JtGzABo+SuohbaRf5AePF6pT+rIrH6yqM2HxgT0t9C3 abqkpH0LBCY9zIUuX09newaFx9j6JEjHl9Yb2kxymjoLAhbSHZNhJhgAQiTN5cpGGlwl ZWHmvB/Etag9jPEa3iaosewWVbu2XccMboSwjK4PuvJqqOx/ZjlGQbbihcA7VPhAb9ej HDBQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-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 f28si12164848pff.131.2018.12.02.15.11.20; Sun, 02 Dec 2018 15:11:21 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of netdev-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 netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725843AbeLBXLS (ORCPT + 11 others); Sun, 2 Dec 2018 18:11:18 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:15624 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725785AbeLBXLR (ORCPT ); Sun, 2 Dec 2018 18:11:17 -0500 Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 089E658FDAD5; Mon, 3 Dec 2018 07:11:13 +0800 (CST) Received: from S00293818-DELL1.china.huawei.com (10.47.90.156) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.408.0; Mon, 3 Dec 2018 07:11:05 +0800 From: Salil Mehta To: CC: , , , , , , , liuzhongzhu Subject: [RFC net-next 1/9] net: hns3: Add "bd info" query function Date: Sun, 2 Dec 2018 23:09:25 +0000 Message-ID: <20181202230933.15560-2-salil.mehta@huawei.com> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20181202230933.15560-1-salil.mehta@huawei.com> References: <20181202230933.15560-1-salil.mehta@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.47.90.156] X-CFilter-Loop: Reflected Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: liuzhongzhu This patch prints Sending and receiving packet descriptor information. debugfs command: echo dump bd info 1 > cmd Sample Command: root@(none)# echo bd info 1 > cmd hns3 0000:7d:00.0: TX Queue Num: 0, BD Index: 0 hns3 0000:7d:00.0: (TX) addr: 0x0 hns3 0000:7d:00.0: (TX)vlan_tag: 0 hns3 0000:7d:00.0: (TX)send_size: 0 hns3 0000:7d:00.0: (TX)vlan_tso: 0 hns3 0000:7d:00.0: (TX)l2_len: 0 hns3 0000:7d:00.0: (TX)l3_len: 0 hns3 0000:7d:00.0: (TX)l4_len: 0 hns3 0000:7d:00.0: (TX)vlan_tag: 0 hns3 0000:7d:00.0: (TX)tv: 0 hns3 0000:7d:00.0: (TX)vlan_msec: 0 hns3 0000:7d:00.0: (TX)ol2_len: 0 hns3 0000:7d:00.0: (TX)ol3_len: 0 hns3 0000:7d:00.0: (TX)ol4_len: 0 hns3 0000:7d:00.0: (TX)paylen: 0 hns3 0000:7d:00.0: (TX)vld_ra_ri: 0 hns3 0000:7d:00.0: (TX)mss: 0 hns3 0000:7d:00.0: RX Queue Num: 0, BD Index: 120 hns3 0000:7d:00.0: (RX)addr: 0xffee7000 hns3 0000:7d:00.0: (RX)pkt_len: 0 hns3 0000:7d:00.0: (RX)size: 0 hns3 0000:7d:00.0: (RX)rss_hash: 0 hns3 0000:7d:00.0: (RX)fd_id: 0 hns3 0000:7d:00.0: (RX)vlan_tag: 0 hns3 0000:7d:00.0: (RX)o_dm_vlan_id_fb: 0 hns3 0000:7d:00.0: (RX)ot_vlan_tag: 0 hns3 0000:7d:00.0: (RX)bd_base_info: 0 Signed-off-by: liuzhongzhu Signed-off-by: Salil Mehta --- drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c | 79 +++++++++++++++++++++- 1 file changed, 78 insertions(+), 1 deletion(-) -- 2.11.0 diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c index 86d667a3730a..9a026556df0e 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c @@ -52,7 +52,7 @@ static int hns3_dbg_queue_info(struct hnae3_handle *h, char *cmd_buf) test_bit(HNS3_NIC_STATE_RESETTING, &priv->state)) return -EPERM; - ring = ring_data[i + h->kinfo.num_tqps].ring; + ring = ring_data[(u32)(i + h->kinfo.num_tqps)].ring; base_add_h = readl_relaxed(ring->tqp->io_base + HNS3_RING_RX_RING_BASEADDR_H_REG); base_add_l = readl_relaxed(ring->tqp->io_base + @@ -125,10 +125,85 @@ static int hns3_dbg_queue_info(struct hnae3_handle *h, char *cmd_buf) return 0; } +static int hns3_dbg_bd_info(struct hnae3_handle *h, char *cmd_buf) +{ + struct hns3_nic_priv *priv = h->priv; + struct hns3_nic_ring_data *ring_data; + struct hns3_desc *rx_desc, *tx_desc; + struct device *dev = &h->pdev->dev; + struct hns3_enet_ring *ring; + u32 tx_index, rx_index; + u32 q_num, value; + int cnt; + + cnt = sscanf(&cmd_buf[8], "%u %u", &q_num, &tx_index); + if (cnt == 2) { + rx_index = tx_index; + } else if (cnt != 1) { + dev_err(dev, "bd info: bad command string, cnt=%d\n", cnt); + return -EINVAL; + } + + if (q_num >= h->kinfo.num_tqps) { + dev_err(dev, "Queue number(%u) is out of range(%u)\n", q_num, + h->kinfo.num_tqps - 1); + return -EINVAL; + } + + ring_data = priv->ring_data; + ring = ring_data[q_num].ring; + value = readl_relaxed(ring->tqp->io_base + HNS3_RING_TX_RING_TAIL_REG); + tx_index = (cnt == 1) ? value : tx_index; + + if (tx_index >= ring->desc_num) { + dev_err(dev, "bd index (%u) is out of range(%u)\n", tx_index, + ring->desc_num - 1); + return -EINVAL; + } + + tx_desc = &ring->desc[tx_index]; + dev_info(dev, "TX Queue Num: %u, BD Index: %u\n", q_num, tx_index); + dev_info(dev, "(TX) addr: 0x%llx\n", tx_desc->addr); + dev_info(dev, "(TX)vlan_tag: %u\n", tx_desc->tx.vlan_tag); + dev_info(dev, "(TX)send_size: %u\n", tx_desc->tx.send_size); + dev_info(dev, "(TX)vlan_tso: %u\n", tx_desc->tx.type_cs_vlan_tso); + dev_info(dev, "(TX)l2_len: %u\n", tx_desc->tx.l2_len); + dev_info(dev, "(TX)l3_len: %u\n", tx_desc->tx.l3_len); + dev_info(dev, "(TX)l4_len: %u\n", tx_desc->tx.l4_len); + dev_info(dev, "(TX)vlan_tag: %u\n", tx_desc->tx.outer_vlan_tag); + dev_info(dev, "(TX)tv: %u\n", tx_desc->tx.tv); + dev_info(dev, "(TX)vlan_msec: %u\n", tx_desc->tx.ol_type_vlan_msec); + dev_info(dev, "(TX)ol2_len: %u\n", tx_desc->tx.ol2_len); + dev_info(dev, "(TX)ol3_len: %u\n", tx_desc->tx.ol3_len); + dev_info(dev, "(TX)ol4_len: %u\n", tx_desc->tx.ol4_len); + dev_info(dev, "(TX)paylen: %u\n", tx_desc->tx.paylen); + dev_info(dev, "(TX)vld_ra_ri: %u\n", tx_desc->tx.bdtp_fe_sc_vld_ra_ri); + dev_info(dev, "(TX)mss: %u\n", tx_desc->tx.mss); + + ring = ring_data[q_num + h->kinfo.num_tqps].ring; + value = readl_relaxed(ring->tqp->io_base + HNS3_RING_RX_RING_TAIL_REG); + rx_index = (cnt == 1) ? value : tx_index; + rx_desc = &ring->desc[rx_index]; + + dev_info(dev, "RX Queue Num: %u, BD Index: %u\n", q_num, rx_index); + dev_info(dev, "(RX)addr: 0x%llx\n", rx_desc->addr); + dev_info(dev, "(RX)pkt_len: %u\n", rx_desc->rx.pkt_len); + dev_info(dev, "(RX)size: %u\n", rx_desc->rx.size); + dev_info(dev, "(RX)rss_hash: %u\n", rx_desc->rx.rss_hash); + dev_info(dev, "(RX)fd_id: %u\n", rx_desc->rx.fd_id); + dev_info(dev, "(RX)vlan_tag: %u\n", rx_desc->rx.vlan_tag); + dev_info(dev, "(RX)o_dm_vlan_id_fb: %u\n", rx_desc->rx.o_dm_vlan_id_fb); + dev_info(dev, "(RX)ot_vlan_tag: %u\n", rx_desc->rx.ot_vlan_tag); + dev_info(dev, "(RX)bd_base_info: %u\n", rx_desc->rx.bd_base_info); + + return 0; +} + 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, "bd info [q_num] \n"); dev_info(&h->pdev->dev, "dump fd tcam\n"); dev_info(&h->pdev->dev, "dump tc\n"); dev_info(&h->pdev->dev, "dump tm\n"); @@ -205,6 +280,8 @@ static ssize_t hns3_dbg_cmd_write(struct file *filp, const char __user *buffer, hns3_dbg_help(handle); else if (strncmp(cmd_buf, "queue info", 10) == 0) ret = hns3_dbg_queue_info(handle, cmd_buf); + else if (strncmp(cmd_buf, "bd info", 7) == 0) + ret = hns3_dbg_bd_info(handle, cmd_buf); else if (handle->ae_algo->ops->dbg_run_cmd) ret = handle->ae_algo->ops->dbg_run_cmd(handle, cmd_buf); From patchwork Sun Dec 2 23:09:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salil Mehta X-Patchwork-Id: 152667 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp6164136ljp; Sun, 2 Dec 2018 15:11:28 -0800 (PST) X-Google-Smtp-Source: AFSGD/UGip2pcZat5VnLQerLPUt6B7zK2bogDTTMC9sCSM6hz7op7pdgBQBK2Li5Vl0k5ioxLTTK X-Received: by 2002:a17:902:8c91:: with SMTP id t17mr13321824plo.119.1543792288234; Sun, 02 Dec 2018 15:11:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543792288; cv=none; d=google.com; s=arc-20160816; b=PXlTqhCdiRdFyv7GrzcbYUV0AhjOqw7fjHOmhcOI1oS4omMzOBN0mJei3oaNQp9DW0 +tyuZIbtlCmEssHK9J/K1x6AUbPJN3gqOUOq6W0/11e+kjKm4LKmu/U0a0PEQM+/Cxk8 SmP1ce2Q7Kwc13AGtHTndQSyDmMd001i9k6QiZMEdJDI0Dv0BcjhPaQ+5IeD9d2puwx1 HWC53pS/P0N6Jd7b29X1dpUN1iUZeoQkj2Nkqx0w8obndofJuQ/1XgkZGkz0Rz1c3CmR om/+xNtJGGGY/06KAfWy8GHYJRXR5+XFz3FasM4nOjsH2BMnrGjq4CfPXr3qJreUMJvd J+jQ== 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=/OWEPzTGkrXMVhgrnFvsTiceHJTTYsrgVKfujEcQzpQ=; b=Gc9MWxWimEr1mBj+1HOpgOqUJBfQ/+AUppuxyPPZLi3FSAlNqCQItKmPIg4Nv4KcfW b8oaS2mPRGqsNSpdP6XjMclS6mYW3sFS+OfD21+oo/5I5Hk8gndjW9TNA8dB3qLFdrig bMKMgt2W94HaaH8ONMJYMZEsp2N6xsCE5Z5xg+DHCKKJZ7UwXNA8l+px9e4JFt0WgyfD YzdctCBrWeNGZWKx94AJomXOr/87lsvC2YdJiCE6/aem9RQD1RbGZXGY3hJNXKQD2ngc sCWs2JEh+a+xJqTu0qh30Cxs34yHCoGOM9Mv6fmpjKK4jIpzsA4hUb84MdD5BqxGZ86U YQQQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-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 l3si12550569pld.155.2018.12.02.15.11.28; Sun, 02 Dec 2018 15:11:28 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of netdev-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 netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725903AbeLBXLW (ORCPT + 11 others); Sun, 2 Dec 2018 18:11:22 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:52072 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725825AbeLBXLW (ORCPT ); Sun, 2 Dec 2018 18:11:22 -0500 Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 2C24E1FFDE532; Mon, 3 Dec 2018 07:11:18 +0800 (CST) Received: from S00293818-DELL1.china.huawei.com (10.47.90.156) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.408.0; Mon, 3 Dec 2018 07:11:11 +0800 From: Salil Mehta To: CC: , , , , , , , liuzhongzhu Subject: [RFC net-next 3/9] net: hns3: Add "port vlan table" information query function Date: Sun, 2 Dec 2018 23:09:27 +0000 Message-ID: <20181202230933.15560-4-salil.mehta@huawei.com> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20181202230933.15560-1-salil.mehta@huawei.com> References: <20181202230933.15560-1-salil.mehta@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.47.90.156] X-CFilter-Loop: Reflected Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: liuzhongzhu This patch prints port vlan table information. debugfs command: echo dump port vlan tbl > cmd Sample Command: root@(none)# echo dump port vlan tbl > cmd vlan | port filter bitMap: 0000 | 00000000:00000000:00000000:00000000:00000000:00000001 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 | 80 ++++++++++++++++++++++ .../ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.h | 3 + 3 files changed, 84 insertions(+) -- 2.11.0 diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c index e59591b1258b..51af55f34e55 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c @@ -211,6 +211,7 @@ static void hns3_dbg_help(struct hnae3_handle *h) dev_info(&h->pdev->dev, "dump qos pri map\n"); dev_info(&h->pdev->dev, "dump qos buf cfg\n"); dev_info(&h->pdev->dev, "dump mac tbl\n"); + dev_info(&h->pdev->dev, "dump port vlan tbl\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 19b76f5e93d7..4a034a59fcb2 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c @@ -530,6 +530,84 @@ static void hclge_dbg_dump_mac_table(struct hclge_dev *hdev) kfree(mc_mac_tbl); } +static void hclge_dbg_dump_port_vlan_table(struct hclge_dev *hdev) +{ + struct hclge_vlan_filter_pf_cfg_cmd *req; + char printf_buf[HCLGE_DBG_BUF_LEN]; + struct hclge_desc desc; + u32 *vlan_bitmap; + u8 vlan_byte_val; + u8 vlan_offset; + u8 vlan_byte; + int vlan_len; + u32 vlan_id; + int ret, i; + bool flag; + + vlan_len = HCLGE_DBG_VLAN_ID_MAX / 8; + vlan_bitmap = kzalloc(vlan_len, GFP_KERNEL); + if (!vlan_bitmap) { + dev_err(&hdev->pdev->dev, + "port vlan table alloc memory failed\n"); + return; + } + + for (vlan_id = 0; vlan_id < HCLGE_DBG_VLAN_ID_MAX; vlan_id++) { + /* Prevent long-term occupation of the command channel. */ + if ((vlan_id % 100) == 0) + msleep(100); + + hclge_cmd_setup_basic_desc(&desc, + HCLGE_OPC_VLAN_FILTER_PF_CFG, true); + + vlan_offset = vlan_id / 160; + vlan_byte = (vlan_id % 160) / 8; + vlan_byte_val = 1 << (vlan_id % 8); + + req = (struct hclge_vlan_filter_pf_cfg_cmd *)desc.data; + req->vlan_offset = vlan_offset; + req->vlan_offset_bitmap[vlan_byte] = vlan_byte_val; + + ret = hclge_cmd_send(&hdev->hw, &desc, 1); + if (ret) { + dev_err(&hdev->pdev->dev, + "call hclge_cmd_send fail, ret = %d\n", ret); + kfree(vlan_bitmap); + return; + } + + if (req->vlan_cfg != 0) + continue; + + vlan_bitmap[(u32)(vlan_id / 32)] |= 1 << (vlan_id % 32); + } + + dev_info(&hdev->pdev->dev, "vlan | port filter bitMap:\n"); + + for (vlan_id = 0; vlan_id < HCLGE_DBG_VLAN_ID_MAX / 32; + vlan_id += 8) { + memset(printf_buf, 0, HCLGE_DBG_BUF_LEN); + snprintf(printf_buf, HCLGE_DBG_BUF_LEN, + "%04d | ", vlan_id * 32); + flag = false; + + for (i = 7; i >= 0; i--) { + snprintf(printf_buf + strlen(printf_buf), + HCLGE_DBG_BUF_LEN - strlen(printf_buf), + "%08x:", vlan_bitmap[(u32)(vlan_id + i)]); + + if (vlan_bitmap[(u32)(vlan_id + i)] > 0) + flag = true; + } + + printf_buf[strlen(printf_buf) - 1] = '\n'; + if (flag) + dev_info(&hdev->pdev->dev, "%s", printf_buf); + } + + kfree(vlan_bitmap); +} + static void hclge_dbg_fd_tcam_read(struct hclge_dev *hdev, u8 stage, bool sel_x, u32 loc) { @@ -603,6 +681,8 @@ int hclge_dbg_run_cmd(struct hnae3_handle *handle, char *cmd_buf) hclge_dbg_dump_qos_buf_cfg(hdev); } else if (strncmp(cmd_buf, "dump mac tbl", 12) == 0) { hclge_dbg_dump_mac_table(hdev); + } else if (strncmp(cmd_buf, "dump port vlan tbl", 18) == 0) { + hclge_dbg_dump_port_vlan_table(hdev); } else { dev_info(&hdev->pdev->dev, "unknown command\n"); return -EINVAL; diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.h index b5a784506b9a..f0c7ad535fcc 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.h @@ -14,6 +14,9 @@ #define HCLGE_DBG_MAC_TBL_E_PORT 0x3FF #define HCLGE_DBG_MAC_TBL_E_PORT_B BIT(11) +#define HCLGE_DBG_VLAN_ID_MAX 4096 +#define HCLGE_DBG_MNG_TBL_MAX 64 + #pragma pack(1) struct hclge_qos_pri_map_cmd { From patchwork Sun Dec 2 23:09:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salil Mehta X-Patchwork-Id: 152673 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp6164626ljp; Sun, 2 Dec 2018 15:12:07 -0800 (PST) X-Google-Smtp-Source: AFSGD/XRKfdI6RhpOssSmVOZTVE/PO4FeXN0Z0dedwAvnjTY+JLohPM7jKDrrKMpleqbAeBhFeuh X-Received: by 2002:a17:902:b592:: with SMTP id a18mr5231051pls.293.1543792327389; Sun, 02 Dec 2018 15:12:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543792327; cv=none; d=google.com; s=arc-20160816; b=LbL3foEZWpygQsFQlnG5FRJbpvkr5xrETyyeJ+G2iyCgvdKoaQthlzsRRczPhMM7DG V6Zh/mlG4Y9PKQGPnujXaxhIkM/QD6A1LbM1GVHXRxmAqhE2iEHpy84POw11OupCNWY+ Y8rvesXvDRI9DgAdFxpNXapNAHnX0IDx7RVcyzadgBJ9Ti1A9jgdlpmor4IkmmHw7PU9 WVQpWjGFo4uaoxNRuFl3byFZTlh/YUJf7N9vkAGraLgNNPfQTcYanCHSh6oD20XShAgJ /Dt7x3Su+qCvZ0Bf1PRmEUb5lbkFea9cVwdYqkbzLtnvnfHu7bcbkOnrQDyBKVJzI8Ss 5eHA== 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=EKCQcZZtRXg2EHt1eH8Mq9qz7aqK8wWi8v77MQSJIAE=; b=CRGAzYGhbGA9e1jCYpUmH3bVl8I/S8+NsIjzNGfc1lFcsgOU/h2ezIb6krl38JlxPF xwnQRhKzfxfWELH52ET5PGiejnG/tOSX05kQWSldLg9j9Puu+dwQ4tfMeswEEZaj6e07 yh6CbfGzojvAhHFSRFlmHkqTE663dwvx080EVmyIMIcb/CNlipaendpEXvTOnR1AtJzZ eE+F1ZRX2ov7STew/EVgFH6wyebPFGMJ/hrZBCXMXyUVM7xr2Zi8wSJVZu2/RoTTrhe3 u8B+Vv/85yuR+yrYe5n456PNkaJOmKx4sCrieZ4vTJ2mkAYRN6cK21V6q4+scB9louMU rK4g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-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 b3si10857282pgc.587.2018.12.02.15.12.07; Sun, 02 Dec 2018 15:12:07 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of netdev-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 netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725935AbeLBXL3 (ORCPT + 11 others); Sun, 2 Dec 2018 18:11:29 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:15187 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725913AbeLBXL1 (ORCPT ); Sun, 2 Dec 2018 18:11:27 -0500 Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 45B1FF51A21DE; Mon, 3 Dec 2018 07:11:23 +0800 (CST) Received: from S00293818-DELL1.china.huawei.com (10.47.90.156) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.408.0; Mon, 3 Dec 2018 07:11:14 +0800 From: Salil Mehta To: CC: , , , , , , , liuzhongzhu Subject: [RFC net-next 4/9] net: hns3: Add "vf vlan table" information query function Date: Sun, 2 Dec 2018 23:09:28 +0000 Message-ID: <20181202230933.15560-5-salil.mehta@huawei.com> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20181202230933.15560-1-salil.mehta@huawei.com> References: <20181202230933.15560-1-salil.mehta@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.47.90.156] X-CFilter-Loop: Reflected Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: liuzhongzhu This patch prints vf vlan table information. debugfs command: echo dump port vlan tbl 0 > cmd Sample Command: root@(none)# echo dump vf vlan tbl 0 > cmd vlan | vf filter bitMap: 0000 | 00000000:00000000:00000000:00000000:00000000:00000000:00000000:00000001 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 | 93 ++++++++++++++++++++++ 2 files changed, 94 insertions(+) -- 2.11.0 diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c index 51af55f34e55..80a081e87b96 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c @@ -212,6 +212,7 @@ static void hns3_dbg_help(struct hnae3_handle *h) dev_info(&h->pdev->dev, "dump qos buf cfg\n"); dev_info(&h->pdev->dev, "dump mac tbl\n"); dev_info(&h->pdev->dev, "dump port vlan tbl\n"); + dev_info(&h->pdev->dev, "dump vf vlan tbl [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 4a034a59fcb2..20e64abe7c5a 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c @@ -608,6 +608,97 @@ static void hclge_dbg_dump_port_vlan_table(struct hclge_dev *hdev) kfree(vlan_bitmap); } +static void hclge_dbg_dump_vf_vlan_table(struct hclge_dev *hdev, char *cmd_buf) +{ + struct hclge_vlan_filter_vf_cfg_cmd *req0; + struct hclge_vlan_filter_vf_cfg_cmd *req1; + char printf_buf[HCLGE_DBG_BUF_LEN]; + struct hclge_desc desc[2]; + u32 *vlan_bitmap; + u8 vf_byte_val; + u8 vf_bitmap; + int vlan_len; + u32 vlan_id; + int ret, i; + bool flag; + u16 vf_id; + + ret = kstrtou16(&cmd_buf[17], 10, &vf_id); + if (ret) { + dev_err(&hdev->pdev->dev, + "vf id failed. vf id max: %d\n", hdev->num_alloc_vfs); + return; + } + + vlan_len = HCLGE_DBG_VLAN_ID_MAX / 8; + vlan_bitmap = kzalloc(vlan_len, GFP_KERNEL); + if (!vlan_bitmap) { + dev_err(&hdev->pdev->dev, + "port vlan table alloc memory failed\n"); + return; + } + + for (vlan_id = 0; vlan_id < HCLGE_DBG_VLAN_ID_MAX; vlan_id++) { + /* Prevent long-term occupation of the command channel. */ + if ((vlan_id % 100) == 0) + msleep(100); + + hclge_cmd_setup_basic_desc(&desc[0], + HCLGE_OPC_VLAN_FILTER_VF_CFG, true); + desc[0].flag |= cpu_to_le16(HCLGE_CMD_FLAG_NEXT); + hclge_cmd_setup_basic_desc(&desc[1], + HCLGE_OPC_VLAN_FILTER_VF_CFG, true); + + req0 = (struct hclge_vlan_filter_vf_cfg_cmd *)desc[0].data; + req1 = (struct hclge_vlan_filter_vf_cfg_cmd *)desc[1].data; + req0->vlan_id = cpu_to_le16(vlan_id); + + ret = hclge_cmd_send(&hdev->hw, desc, 2); + if (ret) { + dev_err(&hdev->pdev->dev, + "call hclge_cmd_send fail, ret = %d\n", ret); + kfree(vlan_bitmap); + return; + } + + if (vf_id < 128) + vf_bitmap = req0->vf_bitmap[vf_id / 8]; + else + vf_bitmap = req1->vf_bitmap[(vf_id - 128) / 8]; + + vf_byte_val = 1 << (vf_id % 8); + + if (vf_bitmap & vf_byte_val) + vlan_bitmap[(u32)(vlan_id / 32)] |= 1 << (vlan_id % 32); + } + + dev_info(&hdev->pdev->dev, "vlan | vf filter bitMap:\n"); + + for (vlan_id = 0; vlan_id < HCLGE_DBG_VLAN_ID_MAX / 32; vlan_id += 8) { + memset(printf_buf, 0, HCLGE_DBG_BUF_LEN); + snprintf(printf_buf, HCLGE_DBG_BUF_LEN, + "%04d | ", vlan_id * 32); + + flag = false; + + for (i = 7; i >= 0; i--) { + snprintf(printf_buf + strlen(printf_buf), + HCLGE_DBG_BUF_LEN - strlen(printf_buf), + "%08x:", vlan_bitmap[(u32)(vlan_id + i)]); + + if (vlan_bitmap[(u32)(vlan_id + i)] > 0) + flag = true; + } + + printf_buf[strlen(printf_buf) - 1] = '\n'; + + if (flag) + dev_info(&hdev->pdev->dev, "%s", printf_buf); + } + + kfree(vlan_bitmap); +} + static void hclge_dbg_fd_tcam_read(struct hclge_dev *hdev, u8 stage, bool sel_x, u32 loc) { @@ -683,6 +774,8 @@ int hclge_dbg_run_cmd(struct hnae3_handle *handle, char *cmd_buf) hclge_dbg_dump_mac_table(hdev); } else if (strncmp(cmd_buf, "dump port vlan tbl", 18) == 0) { hclge_dbg_dump_port_vlan_table(hdev); + } else if (strncmp(cmd_buf, "dump vf vlan tbl", 16) == 0) { + hclge_dbg_dump_vf_vlan_table(hdev, cmd_buf); } else { dev_info(&hdev->pdev->dev, "unknown command\n"); return -EINVAL;