All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Min Hu (Connor)" <humin29@huawei.com>
To: <dev@dpdk.org>
Cc: <ferruh.yigit@intel.com>
Subject: [dpdk-dev] [PATCH 2/4] net/hns3: support for VF modify VLAN filter state
Date: Sun, 13 Jun 2021 11:05:06 +0800	[thread overview]
Message-ID: <1623553508-5478-3-git-send-email-humin29@huawei.com> (raw)
In-Reply-To: <1623553508-5478-1-git-send-email-humin29@huawei.com>

From: Chengchang Tang <tangchengchang@huawei.com>

Since the HW limitation for VF, the VLAN filter is default enabled, and
is not allowed to be closed. Now, the limitation has been removed in
Kunpeng930 network engine, so this patch add support for VF to modify the
VLAN filter state.

A capabilities bit is added to differentiate between different platforms
and achieve compatibility. When the VF runs on an incomatible platform or
an incompatible kernel-mode driver version is used, the VF behavior is
the same as that before.

Signed-off-by: Chengchang Tang <tangchengchang@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
 drivers/net/hns3/hns3_cmd.h       |  9 ++++++++
 drivers/net/hns3/hns3_ethdev.h    |  4 ++++
 drivers/net/hns3/hns3_ethdev_vf.c | 48 ++++++++++++++++++++++++++++++++++++---
 drivers/net/hns3/hns3_mbx.h       |  1 +
 4 files changed, 59 insertions(+), 3 deletions(-)

diff --git a/drivers/net/hns3/hns3_cmd.h b/drivers/net/hns3/hns3_cmd.h
index eafa365..a762158 100644
--- a/drivers/net/hns3/hns3_cmd.h
+++ b/drivers/net/hns3/hns3_cmd.h
@@ -321,6 +321,15 @@ enum HNS3_CAPS_BITS {
 	HNS3_CAPS_RXD_ADV_LAYOUT_B = 15,
 };
 
+/* Capabilities of VF dependent on the PF */
+enum HNS3VF_CAPS_BITS {
+	/*
+	 * The following capability index definitions must be the same as those
+	 * in kernel side PF.
+	 */
+	HNS3VF_CAPS_VLAN_FLT_MOD_B = 0,
+};
+
 enum HNS3_API_CAP_BITS {
 	HNS3_API_CAP_FLEX_RSS_TBL_B,
 };
diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h
index ee84519..b8347c2 100644
--- a/drivers/net/hns3/hns3_ethdev.h
+++ b/drivers/net/hns3/hns3_ethdev.h
@@ -869,8 +869,12 @@ enum {
 	HNS3_DEV_SUPPORT_RXD_ADV_LAYOUT_B,
 	HNS3_DEV_SUPPORT_OUTER_UDP_CKSUM_B,
 	HNS3_DEV_SUPPORT_RAS_IMP_B,
+	HNS3_DEV_SUPPORT_VF_VLAN_FLT_MOD_B,
 };
 
+#define hns3_dev_vf_vlan_flt_supported(hw) \
+		hns3_get_bit((hw)->capability, HNS3_DEV_SUPPORT_VF_VLAN_FLT_MOD_B)
+
 #define hns3_dev_dcb_supported(hw) \
 	hns3_get_bit((hw)->capability, HNS3_DEV_SUPPORT_DCB_B)
 
diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c
index dc95e71..8f3be64 100644
--- a/drivers/net/hns3/hns3_ethdev_vf.c
+++ b/drivers/net/hns3/hns3_ethdev_vf.c
@@ -1408,6 +1408,14 @@ hns3vf_get_queue_depth(struct hns3_hw *hw)
 	return 0;
 }
 
+static void
+hns3vf_update_caps(struct hns3_hw *hw, uint32_t caps)
+{
+	if (hns3_get_bit(caps, HNS3VF_CAPS_VLAN_FLT_MOD_B))
+		hns3_set_bit(hw->capability,
+				HNS3_DEV_SUPPORT_VF_VLAN_FLT_MOD_B, 1);
+}
+
 static int
 hns3vf_get_num_tc(struct hns3_hw *hw)
 {
@@ -1440,7 +1448,7 @@ hns3vf_get_basic_info(struct hns3_hw *hw)
 	hw->hw_tc_map = basic_info->hw_tc_map;
 	hw->num_tc = hns3vf_get_num_tc(hw);
 	hw->pf_vf_if_version = basic_info->pf_vf_if_version;
-
+	hns3vf_update_caps(hw, basic_info->caps);
 
 	return 0;
 }
@@ -1611,6 +1619,26 @@ hns3vf_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
 }
 
 static int
+hns3vf_en_vlan_filter(struct hns3_hw *hw, bool enable)
+{
+	uint8_t msg_data;
+	int ret;
+
+	if (!hns3_dev_vf_vlan_flt_supported(hw))
+		return 0;
+
+	msg_data = enable ? 1 : 0;
+	ret = hns3_send_mbx_msg(hw, HNS3_MBX_SET_VLAN,
+			HNS3_MBX_ENABLE_VLAN_FILTER, &msg_data,
+			sizeof(msg_data), true, NULL, 0);
+	if (ret)
+		hns3_err(hw, "%s vlan filter failed, ret = %d.",
+				enable ? "enable" : "disable", ret);
+
+	return ret;
+}
+
+static int
 hns3vf_en_hw_strip_rxvtag(struct hns3_hw *hw, bool enable)
 {
 	uint8_t msg_data;
@@ -1641,6 +1669,19 @@ hns3vf_vlan_offload_set(struct rte_eth_dev *dev, int mask)
 	}
 
 	tmp_mask = (unsigned int)mask;
+
+	if (tmp_mask & ETH_VLAN_FILTER_MASK) {
+		rte_spinlock_lock(&hw->lock);
+		/* Enable or disable VLAN filter */
+		if (dev_conf->rxmode.offloads & DEV_RX_OFFLOAD_VLAN_FILTER)
+			ret = hns3vf_en_vlan_filter(hw, true);
+		else
+			ret = hns3vf_en_vlan_filter(hw, false);
+		rte_spinlock_unlock(&hw->lock);
+		if (ret)
+			return ret;
+	}
+
 	/* Vlan stripping setting */
 	if (tmp_mask & ETH_VLAN_STRIP_MASK) {
 		rte_spinlock_lock(&hw->lock);
@@ -1738,9 +1779,10 @@ hns3vf_dev_configure_vlan(struct rte_eth_dev *dev)
 	}
 
 	/* Apply vlan offload setting */
-	ret = hns3vf_vlan_offload_set(dev, ETH_VLAN_STRIP_MASK);
+	ret = hns3vf_vlan_offload_set(dev, ETH_VLAN_STRIP_MASK |
+					ETH_VLAN_FILTER_MASK);
 	if (ret)
-		hns3_err(hw, "dev config vlan offload failed, ret =%d", ret);
+		hns3_err(hw, "dev config vlan offload failed, ret = %d.", ret);
 
 	return ret;
 }
diff --git a/drivers/net/hns3/hns3_mbx.h b/drivers/net/hns3/hns3_mbx.h
index f07dbe3..f868e33 100644
--- a/drivers/net/hns3/hns3_mbx.h
+++ b/drivers/net/hns3/hns3_mbx.h
@@ -71,6 +71,7 @@ enum hns3_mbx_vlan_cfg_subcode {
 	HNS3_MBX_VLAN_TX_OFF_CFG,               /* set tx side vlan offload */
 	HNS3_MBX_VLAN_RX_OFF_CFG,               /* set rx side vlan offload */
 	HNS3_MBX_GET_PORT_BASE_VLAN_STATE = 4,  /* get port based vlan state */
+	HNS3_MBX_ENABLE_VLAN_FILTER,            /* set vlan filter state */
 };
 
 enum hns3_mbx_tbl_cfg_subcode {
-- 
2.7.4


  parent reply	other threads:[~2021-06-13  3:05 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-13  3:05 [dpdk-dev] [PATCH 0/4] features for hns3 PMD Min Hu (Connor)
2021-06-13  3:05 ` [dpdk-dev] [PATCH 1/4] net/hns3: add query basic info support for VF Min Hu (Connor)
2021-06-13  3:05 ` Min Hu (Connor) [this message]
2021-06-13  3:05 ` [dpdk-dev] [PATCH 3/4] net/hns3: support multiple TC MAC pause Min Hu (Connor)
2021-06-13  3:05 ` [dpdk-dev] [PATCH 4/4] net/hns3: supports disabling PFC by dev configure API Min Hu (Connor)
2021-06-14 14:59   ` Andrew Rybchenko
2021-06-14 15:00 ` [dpdk-dev] [PATCH 0/4] features for hns3 PMD Andrew Rybchenko
2021-07-09  1:32   ` Min Hu (Connor)
2021-07-09  9:20     ` Andrew Rybchenko
2021-07-10  1:59       ` Min Hu (Connor)
2021-07-10  1:58 ` [dpdk-dev] [PATCH v2 0/3] " Min Hu (Connor)
2021-07-10  1:58   ` [dpdk-dev] [PATCH v2 1/3] net/hns3: add query basic info support for VF Min Hu (Connor)
2021-07-10  1:58   ` [dpdk-dev] [PATCH v2 2/3] net/hns3: support for VF modify VLAN filter state Min Hu (Connor)
2021-07-10  1:58   ` [dpdk-dev] [PATCH v2 3/3] net/hns3: support multiple TC MAC pause Min Hu (Connor)
2021-07-13  9:43   ` [dpdk-dev] [PATCH v2 0/3] features for hns3 PMD Andrew Rybchenko

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=1623553508-5478-3-git-send-email-humin29@huawei.com \
    --to=humin29@huawei.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.