Skip to content

Commit fbeebcf

Browse files
anuragma2025bruce-richardson
authored andcommitted
net/iavf: add support for QinQ insertion
QinQ insertion with VLAN TPID 0x88a8 support is absent. This patch adds support for QinQ insertion for both Outer VLAN TPIDs 0x88a8 (802.1ad) & 0x8100 (802.1Q). VLAN Extend should be enabled for the same and Outer VLAN TPID should be set properly for TPID 0x88a8. Signed-off-by: Anurag Mandal <anurag.mandal@intel.com> Acked-by: Bruce Richardson <bruce.richardson@intel.com>
1 parent 877686a commit fbeebcf

3 files changed

Lines changed: 74 additions & 2 deletions

File tree

doc/guides/nics/intel_vf.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -823,3 +823,22 @@ To start ``testpmd``, and enable QinQ strip for default TPID on port 0:
823823
824824
testpmd> vlan set extend on 0
825825
testpmd> vlan set qinq_strip on 0
826+
827+
QinQ Configuration
828+
~~~~~~~~~~~~~~~~~~
829+
830+
When using QinQ Tx offload (``RTE_ETH_TX_OFFLOAD_QINQ_INSERT``),
831+
you must also enable ``RTE_ETH_RX_OFFLOAD_VLAN_EXTEND``
832+
to configure the hardware for double VLAN mode.
833+
Without this, only the inner VLAN tag will be inserted.
834+
835+
Example::
836+
837+
struct rte_eth_conf port_conf = {
838+
.rxmode = {
839+
.offloads = RTE_ETH_RX_OFFLOAD_VLAN_EXTEND,
840+
},
841+
.txmode = {
842+
.offloads = RTE_ETH_TX_OFFLOAD_QINQ_INSERT,
843+
},
844+
};

drivers/net/intel/iavf/iavf.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,7 @@ int iavf_get_supported_rxdid(struct iavf_adapter *adapter);
466466
int iavf_config_vlan_strip_v2(struct iavf_adapter *adapter, bool enable);
467467
int iavf_config_outer_vlan_strip_v2(struct iavf_adapter *adapter, bool enable);
468468
int iavf_config_vlan_insert_v2(struct iavf_adapter *adapter, bool enable);
469+
int iavf_config_outer_vlan_insert_v2(struct iavf_adapter *adapter, bool enable);
469470
int iavf_add_del_vlan_v2(struct iavf_adapter *adapter, uint16_t vlanid,
470471
bool add);
471472
int iavf_get_vlan_offload_caps_v2(struct iavf_adapter *adapter);

drivers/net/intel/iavf/iavf_vchnl.c

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
923968
int
924969
iavf_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

Comments
 (0)