@@ -920,6 +920,51 @@ iavf_config_vlan_strip_v2(struct iavf_adapter *adapter, bool enable)
920920 return ret ;
921921}
922922
923+ int
924+ iavf_config_outer_vlan_insert_v2 (struct iavf_adapter * adapter , bool enable )
925+ {
926+ struct iavf_info * vf = IAVF_DEV_PRIVATE_TO_VF (adapter );
927+ struct virtchnl_vlan_supported_caps * insertion_caps ;
928+ struct virtchnl_vlan_setting vlan_insert ;
929+ uint8_t msg_buf [IAVF_AQ_BUF_SZ ] = {0 };
930+ struct iavf_cmd_info args ;
931+ uint32_t * ethertype ;
932+ int ret ;
933+
934+ memset (& vlan_insert , 0 , sizeof (vlan_insert ));
935+ insertion_caps = & vf -> vlan_v2_caps .offloads .insertion_support ;
936+
937+ if ((insertion_caps -> outer & VIRTCHNL_VLAN_ETHERTYPE_88A8 ) &&
938+ (insertion_caps -> outer & VIRTCHNL_VLAN_TOGGLE ) &&
939+ adapter -> tpid == RTE_ETHER_TYPE_QINQ ) {
940+ ethertype = & vlan_insert .outer_ethertype_setting ;
941+ * ethertype = VIRTCHNL_VLAN_ETHERTYPE_88A8 ;
942+ } else if ((insertion_caps -> outer & VIRTCHNL_VLAN_ETHERTYPE_8100 ) &&
943+ (insertion_caps -> outer & VIRTCHNL_VLAN_TOGGLE ) &&
944+ adapter -> tpid == RTE_ETHER_TYPE_VLAN ) {
945+ ethertype = & vlan_insert .outer_ethertype_setting ;
946+ * ethertype = VIRTCHNL_VLAN_ETHERTYPE_8100 ;
947+ } else {
948+ return - ENOTSUP ;
949+ }
950+
951+ vlan_insert .vport_id = vf -> vsi_res -> vsi_id ;
952+
953+ args .ops = enable ? VIRTCHNL_OP_ENABLE_VLAN_INSERTION_V2 :
954+ VIRTCHNL_OP_DISABLE_VLAN_INSERTION_V2 ;
955+ args .in_args = (uint8_t * )& vlan_insert ;
956+ args .in_args_size = sizeof (vlan_insert );
957+ args .out_buffer = msg_buf ;
958+ args .out_size = IAVF_AQ_BUF_SZ ;
959+ ret = iavf_execute_vf_cmd_safe (adapter , & args );
960+ if (ret )
961+ PMD_DRV_LOG (ERR , "fail to execute command %s" ,
962+ enable ? "VIRTCHNL_OP_ENABLE_VLAN_INSERTION_V2" :
963+ "VIRTCHNL_OP_DISABLE_VLAN_INSERTION_V2" );
964+
965+ return ret ;
966+ }
967+
923968int
924969iavf_config_vlan_insert_v2 (struct iavf_adapter * adapter , bool enable )
925970{
@@ -929,14 +974,21 @@ iavf_config_vlan_insert_v2(struct iavf_adapter *adapter, bool enable)
929974 uint8_t msg_buf [IAVF_AQ_BUF_SZ ] = {0 };
930975 struct iavf_cmd_info args ;
931976 uint32_t * ethertype ;
977+ bool qinq = adapter -> dev_data -> dev_conf .rxmode .offloads &
978+ RTE_ETH_RX_OFFLOAD_VLAN_EXTEND ;
979+ bool insert_qinq = adapter -> dev_data -> dev_conf .txmode .offloads &
980+ RTE_ETH_TX_OFFLOAD_QINQ_INSERT ;
932981 int ret ;
933982
983+ if (qinq && insert_qinq )
984+ iavf_config_outer_vlan_insert_v2 (adapter , enable );
985+
934986 insertion_caps = & vf -> vlan_v2_caps .offloads .insertion_support ;
935987
936- if ((insertion_caps -> outer & VIRTCHNL_VLAN_ETHERTYPE_8100 ) &&
988+ if (! qinq && (insertion_caps -> outer & VIRTCHNL_VLAN_ETHERTYPE_8100 ) &&
937989 (insertion_caps -> outer & VIRTCHNL_VLAN_TOGGLE ))
938990 ethertype = & vlan_insert .outer_ethertype_setting ;
939- else if ((insertion_caps -> inner & VIRTCHNL_VLAN_ETHERTYPE_8100 ) &&
991+ else if (qinq && (insertion_caps -> inner & VIRTCHNL_VLAN_ETHERTYPE_8100 ) &&
940992 (insertion_caps -> inner & VIRTCHNL_VLAN_TOGGLE ))
941993 ethertype = & vlan_insert .inner_ethertype_setting ;
942994 else
0 commit comments