@@ -829,6 +829,50 @@ iavf_get_supported_rxdid(struct iavf_adapter *adapter)
829829 return 0 ;
830830}
831831
832+ int
833+ iavf_config_outer_vlan_strip_v2 (struct iavf_adapter * adapter , bool enable )
834+ {
835+ struct iavf_info * vf = IAVF_DEV_PRIVATE_TO_VF (adapter );
836+ struct virtchnl_vlan_supported_caps * stripping_caps ;
837+ struct virtchnl_vlan_setting vlan_strip ;
838+ uint8_t msg_buf [IAVF_AQ_BUF_SZ ] = {0 };
839+ struct iavf_cmd_info args ;
840+ uint32_t * ethertype ;
841+ int ret ;
842+
843+ memset (& vlan_strip , 0 , sizeof (vlan_strip ));
844+ stripping_caps = & vf -> vlan_v2_caps .offloads .stripping_support ;
845+ if ((stripping_caps -> outer & VIRTCHNL_VLAN_ETHERTYPE_88A8 ) &&
846+ (stripping_caps -> outer & VIRTCHNL_VLAN_TOGGLE ) &&
847+ adapter -> tpid == RTE_ETHER_TYPE_QINQ ) {
848+ ethertype = & vlan_strip .outer_ethertype_setting ;
849+ * ethertype = VIRTCHNL_VLAN_ETHERTYPE_88A8 ;
850+ } else if ((stripping_caps -> outer & VIRTCHNL_VLAN_ETHERTYPE_8100 ) &&
851+ (stripping_caps -> outer & VIRTCHNL_VLAN_TOGGLE ) &&
852+ adapter -> tpid == RTE_ETHER_TYPE_VLAN ) {
853+ ethertype = & vlan_strip .outer_ethertype_setting ;
854+ * ethertype = VIRTCHNL_VLAN_ETHERTYPE_8100 ;
855+ } else {
856+ return - ENOTSUP ;
857+ }
858+
859+ vlan_strip .vport_id = vf -> vsi_res -> vsi_id ;
860+
861+ args .ops = enable ? VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2 :
862+ VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2 ;
863+ args .in_args = (uint8_t * )& vlan_strip ;
864+ args .in_args_size = sizeof (vlan_strip );
865+ args .out_buffer = msg_buf ;
866+ args .out_size = IAVF_AQ_BUF_SZ ;
867+ ret = iavf_execute_vf_cmd_safe (adapter , & args );
868+ if (ret )
869+ PMD_DRV_LOG (ERR , "fail to execute command %s" ,
870+ enable ? "VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2" :
871+ "VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2" );
872+
873+ return ret ;
874+ }
875+
832876int
833877iavf_config_vlan_strip_v2 (struct iavf_adapter * adapter , bool enable )
834878{
@@ -838,14 +882,20 @@ iavf_config_vlan_strip_v2(struct iavf_adapter *adapter, bool enable)
838882 uint8_t msg_buf [IAVF_AQ_BUF_SZ ] = {0 };
839883 struct iavf_cmd_info args ;
840884 uint32_t * ethertype ;
885+ int qinq = adapter -> dev_data -> dev_conf .rxmode .offloads &
886+ RTE_ETH_RX_OFFLOAD_VLAN_EXTEND ;
841887 int ret ;
842888
843889 stripping_caps = & vf -> vlan_v2_caps .offloads .stripping_support ;
844890
845- if ((stripping_caps -> outer & VIRTCHNL_VLAN_ETHERTYPE_8100 ) &&
891+ /* When VLAN extend is disabled, Single VLAN mode which is Outer VLAN
892+ * When VLAN extend is enabled, QinQ mode, this API works only on
893+ * Inner VLAN strip which is always 0x8100.
894+ */
895+ if (!qinq && (stripping_caps -> outer & VIRTCHNL_VLAN_ETHERTYPE_8100 ) &&
846896 (stripping_caps -> outer & VIRTCHNL_VLAN_TOGGLE ))
847897 ethertype = & vlan_strip .outer_ethertype_setting ;
848- else if ((stripping_caps -> inner & VIRTCHNL_VLAN_ETHERTYPE_8100 ) &&
898+ else if (qinq && (stripping_caps -> inner & VIRTCHNL_VLAN_ETHERTYPE_8100 ) &&
849899 (stripping_caps -> inner & VIRTCHNL_VLAN_TOGGLE ))
850900 ethertype = & vlan_strip .inner_ethertype_setting ;
851901 else
@@ -921,6 +971,8 @@ iavf_add_del_vlan_v2(struct iavf_adapter *adapter, uint16_t vlanid, bool add)
921971 struct virtchnl_vlan * vlan_setting ;
922972 struct iavf_cmd_info args ;
923973 uint32_t filtering_caps ;
974+ int qinq = adapter -> dev_data -> dev_conf .rxmode .offloads &
975+ RTE_ETH_RX_OFFLOAD_VLAN_EXTEND ;
924976 int err ;
925977
926978 supported_caps = & vf -> vlan_v2_caps .filtering .filtering_support ;
@@ -938,7 +990,10 @@ iavf_add_del_vlan_v2(struct iavf_adapter *adapter, uint16_t vlanid, bool add)
938990 memset (& vlan_filter , 0 , sizeof (vlan_filter ));
939991 vlan_filter .vport_id = vf -> vsi_res -> vsi_id ;
940992 vlan_filter .num_elements = 1 ;
941- vlan_setting -> tpid = RTE_ETHER_TYPE_VLAN ;
993+ if (qinq && adapter -> tpid == RTE_ETHER_TYPE_QINQ )
994+ vlan_setting -> tpid = RTE_ETHER_TYPE_QINQ ;
995+ else
996+ vlan_setting -> tpid = RTE_ETHER_TYPE_VLAN ;
942997 vlan_setting -> tci = vlanid ;
943998
944999 args .ops = add ? VIRTCHNL_OP_ADD_VLAN_V2 : VIRTCHNL_OP_DEL_VLAN_V2 ;
0 commit comments