DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Min Hu (Connor)" <humin29@huawei.com>
To: <dev@dpdk.org>
Cc: "Min Hu (Connor)" <humin29@huawei.com>,
	Yisen Zhuang <yisen.zhuang@huawei.com>,
	Lijun Ou <oulijun@huawei.com>
Subject: [PATCH 6/9] net/hns3: dump VLAN configuration info
Date: Fri, 11 Feb 2022 12:49:27 +0800	[thread overview]
Message-ID: <20220211044930.2449-7-humin29@huawei.com> (raw)
In-Reply-To: <20220211044930.2449-1-humin29@huawei.com>

This patch dump VLAN filter, strip related info and Pvid info for debug.

Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
 drivers/net/hns3/hns3_ethdev_dump.c | 196 ++++++++++++++++++++++++++++
 1 file changed, 196 insertions(+)

diff --git a/drivers/net/hns3/hns3_ethdev_dump.c b/drivers/net/hns3/hns3_ethdev_dump.c
index f9647e6007..a08f8418a2 100644
--- a/drivers/net/hns3/hns3_ethdev_dump.c
+++ b/drivers/net/hns3/hns3_ethdev_dump.c
@@ -361,6 +361,201 @@ get_rxtx_queue_info(FILE *file, struct rte_eth_dev *dev)
 	get_rxtx_queue_enable_state(file, dev);
 }
 
+static int
+get_vlan_filter_cfg(FILE *file, struct hns3_hw *hw)
+{
+#define HNS3_FILTER_TYPE_VF		0
+#define HNS3_FILTER_TYPE_PORT		1
+#define HNS3_FILTER_FE_NIC_INGRESS_B	BIT(0)
+#define HNS3_FILTER_FE_NIC_EGRESS_B	BIT(1)
+	struct hns3_vlan_filter_ctrl_cmd *req;
+	struct hns3_cmd_desc desc;
+	uint8_t i;
+	int ret;
+
+	static const uint32_t vlan_filter_type[] = {
+		HNS3_FILTER_TYPE_PORT,
+		HNS3_FILTER_TYPE_VF
+	};
+
+	for (i = 0; i < RTE_DIM(vlan_filter_type); i++) {
+		hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_VLAN_FILTER_CTRL,
+						true);
+		req = (struct hns3_vlan_filter_ctrl_cmd *)desc.data;
+		req->vlan_type = vlan_filter_type[i];
+		req->vf_id = HNS3_PF_FUNC_ID;
+		ret = hns3_cmd_send(hw, &desc, 1);
+		if (ret != 0) {
+			hns3_err(hw,
+				"NIC IMP exec ret=%d desc_num=%d optcode=0x%x!",
+				ret, 1, rte_le_to_cpu_16(desc.opcode));
+			return ret;
+		}
+		fprintf(file,
+			"\t  -- %s VLAN filter configuration\n"
+			"\t       nic_ingress           :%s\n"
+			"\t       nic_egress            :%s\n",
+			req->vlan_type == HNS3_FILTER_TYPE_PORT ?
+			"Port" : "VF",
+			req->vlan_fe & HNS3_FILTER_FE_NIC_INGRESS_B ?
+			"Enable" : "Disable",
+			req->vlan_fe & HNS3_FILTER_FE_NIC_EGRESS_B ?
+			"Enable" : "Disable");
+	}
+
+	return 0;
+}
+
+static int
+get_vlan_rx_offload_cfg(FILE *file, struct hns3_hw *hw)
+{
+	struct hns3_vport_vtag_rx_cfg_cmd *req;
+	struct hns3_cmd_desc desc;
+	uint16_t vport_id;
+	uint8_t bitmap;
+	int ret;
+
+	hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_VLAN_PORT_RX_CFG, true);
+	req = (struct hns3_vport_vtag_rx_cfg_cmd *)desc.data;
+	vport_id = HNS3_PF_FUNC_ID;
+	req->vf_offset = vport_id / HNS3_VF_NUM_PER_CMD;
+	bitmap = 1 << (vport_id % HNS3_VF_NUM_PER_BYTE);
+	req->vf_bitmap[req->vf_offset] = bitmap;
+
+	/*
+	 * current version VF is not supported when PF is driven by DPDK driver,
+	 * just need to configure rx parameters for PF vport.
+	 */
+	ret = hns3_cmd_send(hw, &desc, 1);
+	if (ret != 0) {
+		hns3_err(hw,
+			"NIC IMP exec ret=%d desc_num=%d optcode=0x%x!",
+			ret, 1, rte_le_to_cpu_16(desc.opcode));
+		return ret;
+	}
+
+	fprintf(file,
+		"\t  -- RX VLAN configuration\n"
+		"\t       vlan1_strip_en        :%s\n"
+		"\t       vlan2_strip_en        :%s\n"
+		"\t       vlan1_vlan_prionly    :%s\n"
+		"\t       vlan2_vlan_prionly    :%s\n"
+		"\t       vlan1_strip_discard   :%s\n"
+		"\t       vlan2_strip_discard   :%s\n",
+		hns3_get_bit(req->vport_vlan_cfg,
+			HNS3_REM_TAG1_EN_B) ? "Enable" : "Disable",
+		hns3_get_bit(req->vport_vlan_cfg,
+			HNS3_REM_TAG2_EN_B) ? "Enable" : "Disable",
+		hns3_get_bit(req->vport_vlan_cfg,
+			HNS3_SHOW_TAG1_EN_B) ? "Enable" : "Disable",
+		hns3_get_bit(req->vport_vlan_cfg,
+			HNS3_SHOW_TAG2_EN_B) ? "Enable" : "Disable",
+		hns3_get_bit(req->vport_vlan_cfg,
+			HNS3_DISCARD_TAG1_EN_B) ? "Enable" : "Disable",
+		hns3_get_bit(req->vport_vlan_cfg,
+			HNS3_DISCARD_TAG2_EN_B) ? "Enable" : "Disable");
+
+	return 0;
+}
+
+static void
+parse_tx_vlan_cfg(FILE *file, struct hns3_vport_vtag_tx_cfg_cmd *req)
+{
+#define VLAN_VID_MASK 0x0fff
+#define VLAN_PRIO_SHIFT 13
+
+	fprintf(file,
+		"\t  -- TX VLAN configuration\n"
+		"\t       accept_tag1           :%s\n"
+		"\t       accept_untag1         :%s\n"
+		"\t       insert_tag1_en        :%s\n"
+		"\t       default_vlan_tag1 = %d, qos = %d\n"
+		"\t       accept_tag2           :%s\n"
+		"\t       accept_untag2         :%s\n"
+		"\t       insert_tag2_en        :%s\n"
+		"\t       default_vlan_tag2 = %d, qos = %d\n"
+		"\t       vlan_shift_mode       :%s\n",
+		hns3_get_bit(req->vport_vlan_cfg,
+			HNS3_ACCEPT_TAG1_B) ? "Enable" : "Disable",
+		hns3_get_bit(req->vport_vlan_cfg,
+			HNS3_ACCEPT_UNTAG1_B) ? "Enable" : "Disable",
+		hns3_get_bit(req->vport_vlan_cfg,
+			HNS3_PORT_INS_TAG1_EN_B) ? "Enable" : "Disable",
+		req->def_vlan_tag1 & VLAN_VID_MASK,
+		req->def_vlan_tag1 >> VLAN_PRIO_SHIFT,
+		hns3_get_bit(req->vport_vlan_cfg,
+			HNS3_ACCEPT_TAG2_B) ? "Enable" : "Disable",
+		hns3_get_bit(req->vport_vlan_cfg,
+			HNS3_ACCEPT_UNTAG2_B) ? "Enable" : "Disable",
+		hns3_get_bit(req->vport_vlan_cfg,
+			HNS3_PORT_INS_TAG2_EN_B) ? "Enable" : "Disable",
+		req->def_vlan_tag2 & VLAN_VID_MASK,
+		req->def_vlan_tag2 >> VLAN_PRIO_SHIFT,
+		hns3_get_bit(req->vport_vlan_cfg,
+			HNS3_TAG_SHIFT_MODE_EN_B) ? "Enable" :
+			"Disable");
+}
+
+static int
+get_vlan_tx_offload_cfg(FILE *file, struct hns3_hw *hw)
+{
+	struct hns3_vport_vtag_tx_cfg_cmd *req;
+	struct hns3_cmd_desc desc;
+	uint16_t vport_id;
+	uint8_t bitmap;
+	int ret;
+
+	hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_VLAN_PORT_TX_CFG, true);
+	req = (struct hns3_vport_vtag_tx_cfg_cmd *)desc.data;
+	vport_id = HNS3_PF_FUNC_ID;
+	req->vf_offset = vport_id / HNS3_VF_NUM_PER_CMD;
+	bitmap = 1 << (vport_id % HNS3_VF_NUM_PER_BYTE);
+	req->vf_bitmap[req->vf_offset] = bitmap;
+	/*
+	 * current version VF is not supported when PF is driven by DPDK driver,
+	 * just need to configure tx parameters for PF vport.
+	 */
+	ret = hns3_cmd_send(hw, &desc, 1);
+	if (ret != 0) {
+		hns3_err(hw,
+			"NIC IMP exec ret=%d desc_num=%d optcode=0x%x!",
+			ret, 1, rte_le_to_cpu_16(desc.opcode));
+		return ret;
+	}
+
+	parse_tx_vlan_cfg(file, req);
+
+	return 0;
+}
+
+static void
+get_port_pvid_info(FILE *file, struct hns3_hw *hw)
+{
+	fprintf(file, "\t  -- pvid status: %s\n",
+		hw->port_base_vlan_cfg.state ? "on" : "off");
+}
+
+static void
+get_vlan_config_info(FILE *file, struct hns3_hw *hw)
+{
+	int ret;
+
+	fprintf(file, "  - VLAN Config Info:\n");
+	ret = get_vlan_filter_cfg(file, hw);
+	if (ret < 0)
+		return;
+
+	ret = get_vlan_rx_offload_cfg(file, hw);
+	if (ret < 0)
+		return;
+
+	ret = get_vlan_tx_offload_cfg(file, hw);
+	if (ret < 0)
+		return;
+
+	get_port_pvid_info(file, hw);
+}
+
 int
 hns3_eth_dev_priv_dump(struct rte_eth_dev *dev, FILE *file)
 {
@@ -376,6 +571,7 @@ hns3_eth_dev_priv_dump(struct rte_eth_dev *dev, FILE *file)
 
 	get_dev_mac_info(file, hns);
 	get_rxtx_queue_info(file, dev);
+	get_vlan_config_info(file, hw);
 
 	return 0;
 }
-- 
2.33.0


  parent reply	other threads:[~2022-02-11  4:50 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-11  4:49 [PATCH 0/9] dump device info Min Hu (Connor)
2022-02-11  4:49 ` [PATCH v4 1/9] ethdev: introduce dump API Min Hu (Connor)
2022-02-11 10:41   ` Ferruh Yigit
2022-02-11  4:49 ` [PATCH 2/9] net/hns3: dump device basic info Min Hu (Connor)
2022-02-11  4:49 ` [PATCH 3/9] net/hns3: dump device feature capability Min Hu (Connor)
2022-02-11  4:49 ` [PATCH 4/9] net/hns3: dump device MAC info Min Hu (Connor)
2022-02-11  4:49 ` [PATCH 5/9] net/hns3: dump queue info Min Hu (Connor)
2022-02-11  4:49 ` Min Hu (Connor) [this message]
2022-02-11  4:49 ` [PATCH 7/9] net/hns3: dump flow director basic info Min Hu (Connor)
2022-02-11  4:49 ` [PATCH 8/9] net/hns3: dump TM configuration info Min Hu (Connor)
2022-02-11  4:49 ` [PATCH 9/9] net/hns3: dump flow control info Min Hu (Connor)
2022-02-11 18:04 ` [PATCH 0/9] dump device info Ferruh Yigit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220211044930.2449-7-humin29@huawei.com \
    --to=humin29@huawei.com \
    --cc=dev@dpdk.org \
    --cc=oulijun@huawei.com \
    --cc=yisen.zhuang@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).