DPDK patches and discussions
 help / color / mirror / Atom feed
From: Haiyue Wang <haiyue.wang@intel.com>
To: dev@dpdk.org
Cc: qiming.yang@intel.com, qi.z.zhang@intel.com,
	Haiyue Wang <haiyue.wang@intel.com>,
	Jingjing Wu <jingjing.wu@intel.com>,
	Beilei Xing <beilei.xing@intel.com>
Subject: [dpdk-dev] [PATCH v1] net/iavf: support to config VLAN filter
Date: Mon, 25 Jan 2021 15:04:46 +0800	[thread overview]
Message-ID: <20210125070446.53506-1-haiyue.wang@intel.com> (raw)

Add the VLAN filtering enable/disable configuration according to the VF
successfully negotiated that capability with PF.

Signed-off-by: Haiyue Wang <haiyue.wang@intel.com>
---
 drivers/net/iavf/iavf.h        |  1 +
 drivers/net/iavf/iavf_ethdev.c |  7 ++++++
 drivers/net/iavf/iavf_vchnl.c  | 40 ++++++++++++++++++++++++++++++++++
 3 files changed, 48 insertions(+)

diff --git a/drivers/net/iavf/iavf.h b/drivers/net/iavf/iavf.h
index c934d2e614..9d84e2604d 100644
--- a/drivers/net/iavf/iavf.h
+++ b/drivers/net/iavf/iavf.h
@@ -314,6 +314,7 @@ int iavf_configure_queues(struct iavf_adapter *adapter,
 int iavf_get_supported_rxdid(struct iavf_adapter *adapter);
 int iavf_config_vlan_strip_v2(struct iavf_adapter *adapter, bool enable);
 int iavf_config_vlan_insert_v2(struct iavf_adapter *adapter, bool enable);
+int iavf_config_vlan_filter_v2(struct iavf_adapter *adapter, bool enable);
 int iavf_add_del_vlan_v2(struct iavf_adapter *adapter, uint16_t vlanid,
 			 bool add);
 int iavf_get_vlan_offload_caps_v2(struct iavf_adapter *adapter);
diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c
index cf6ea0b15c..8e741031ec 100644
--- a/drivers/net/iavf/iavf_ethdev.c
+++ b/drivers/net/iavf/iavf_ethdev.c
@@ -1086,6 +1086,13 @@ iavf_dev_vlan_offload_set_v2(struct rte_eth_dev *dev, int mask)
 		enable = !!(rxmode->offloads & DEV_RX_OFFLOAD_VLAN_FILTER);
 
 		iavf_iterate_vlan_filters_v2(dev, enable);
+
+		err = iavf_config_vlan_filter_v2(adapter, enable);
+		/* If not support, the filtering is already disabled by PF */
+		if (err == -ENOTSUP && !enable)
+			err = 0;
+		if (err)
+			return -EIO;
 	}
 
 	if (mask & ETH_VLAN_STRIP_MASK) {
diff --git a/drivers/net/iavf/iavf_vchnl.c b/drivers/net/iavf/iavf_vchnl.c
index 9b8c4d113a..7af143a21b 100644
--- a/drivers/net/iavf/iavf_vchnl.c
+++ b/drivers/net/iavf/iavf_vchnl.c
@@ -604,6 +604,46 @@ iavf_config_vlan_insert_v2(struct iavf_adapter *adapter, bool enable)
 	return ret;
 }
 
+int
+iavf_config_vlan_filter_v2(struct iavf_adapter *adapter, bool enable)
+{
+	struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
+	struct virtchnl_vlan_supported_caps *filtering_caps;
+	struct virtchnl_vlan_setting vlan_filter;
+	struct iavf_cmd_info args;
+	uint32_t *ethertype;
+	int ret;
+
+	filtering_caps = &vf->vlan_v2_caps.filtering.filtering_support;
+
+	if ((filtering_caps->outer & VIRTCHNL_VLAN_ETHERTYPE_8100) &&
+	    (filtering_caps->outer & VIRTCHNL_VLAN_TOGGLE))
+		ethertype = &vlan_filter.outer_ethertype_setting;
+	else if ((filtering_caps->inner & VIRTCHNL_VLAN_ETHERTYPE_8100) &&
+		 (filtering_caps->inner & VIRTCHNL_VLAN_TOGGLE))
+		ethertype = &vlan_filter.inner_ethertype_setting;
+	else
+		return -ENOTSUP;
+
+	memset(&vlan_filter, 0, sizeof(vlan_filter));
+	vlan_filter.vport_id = vf->vsi_res->vsi_id;
+	*ethertype = VIRTCHNL_VLAN_ETHERTYPE_8100;
+
+	args.ops = enable ? VIRTCHNL_OP_ENABLE_VLAN_FILTERING_V2 :
+			    VIRTCHNL_OP_DISABLE_VLAN_FILTERING_V2;
+	args.in_args = (uint8_t *)&vlan_filter;
+	args.in_args_size = sizeof(vlan_filter);
+	args.out_buffer = vf->aq_resp;
+	args.out_size = IAVF_AQ_BUF_SZ;
+	ret = iavf_execute_vf_cmd(adapter, &args);
+	if (ret)
+		PMD_DRV_LOG(ERR, "fail to execute command %s",
+			    enable ? "VIRTCHNL_OP_ENABLE_VLAN_FILTERING_V2" :
+				     "VIRTCHNL_OP_DISABLE_VLAN_FILTERING_V2");
+
+	return ret;
+}
+
 int
 iavf_add_del_vlan_v2(struct iavf_adapter *adapter, uint16_t vlanid, bool add)
 {
-- 
2.30.0


                 reply	other threads:[~2021-01-25  7:20 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20210125070446.53506-1-haiyue.wang@intel.com \
    --to=haiyue.wang@intel.com \
    --cc=beilei.xing@intel.com \
    --cc=dev@dpdk.org \
    --cc=jingjing.wu@intel.com \
    --cc=qi.z.zhang@intel.com \
    --cc=qiming.yang@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 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).