[v1] net/iavf: support to config VLAN filter

Message ID 20210125070446.53506-1-haiyue.wang@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Qi Zhang
Headers
Series [v1] net/iavf: support to config VLAN filter |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-intel-Performance fail Performance Testing issues
ci/iol-intel-Functional success Functional Testing PASS
ci/intel-Testing success Testing PASS
ci/iol-mellanox-Functional success Functional Testing PASS
ci/iol-testing warning Testing issues

Commit Message

Wang, Haiyue Jan. 25, 2021, 7:04 a.m. UTC
  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(+)
  

Patch

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)
 {