Skip to content

Commit 2a7bebf

Browse files
cloftusbruce-richardson
authored andcommitted
net/iavf: fix tag insert with both VLAN and QinQ mbuf flags
Fix an issue that would arise in the event an mbuf had both the VLAN and QinQ insertion offload flags set. In this case the L2TAG2 field would be written to twice and could cause the tag to be corrupted. Reorder the logic of populating the L2TAG2 field and ensure that the field is only written to once. Fixes: 3aa4efa ("net/iavf: support VLAN insertion in AVX512 Tx") Signed-off-by: Ciara Loftus <[email protected]> Acked-by: Bruce Richardson <[email protected]>
1 parent 07d5607 commit 2a7bebf

File tree

2 files changed

+15
-20
lines changed

2 files changed

+15
-20
lines changed

drivers/net/intel/iavf/iavf_rxtx_vec_avx512.c

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2136,20 +2136,19 @@ ctx_vtx(volatile struct iavf_tx_desc *txdp,
21362136

21372137
#ifdef IAVF_TX_VLAN_QINQ_OFFLOAD
21382138
if (offload) {
2139-
if (pkt[1]->ol_flags & RTE_MBUF_F_TX_VLAN &&
2140-
vlan_flag & IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG2) {
2141-
hi_ctx_qw1 |=
2142-
IAVF_TX_CTX_DESC_IL2TAG2 << IAVF_TXD_CTX_QW1_CMD_SHIFT;
2143-
low_ctx_qw1 |=
2144-
(uint64_t)pkt[1]->vlan_tci << IAVF_TXD_CTX_QW0_L2TAG2_PARAM;
2145-
}
21462139
if (pkt[1]->ol_flags & RTE_MBUF_F_TX_QINQ) {
21472140
uint64_t qinq_tag = vlan_flag & IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG2 ?
21482141
(uint64_t)pkt[1]->vlan_tci :
21492142
(uint64_t)pkt[1]->vlan_tci_outer;
21502143
hi_ctx_qw1 |= IAVF_TX_CTX_DESC_IL2TAG2 <<
21512144
IAVF_TXD_CTX_QW1_CMD_SHIFT;
21522145
low_ctx_qw1 |= qinq_tag << IAVF_TXD_CTX_QW0_L2TAG2_PARAM;
2146+
} else if (pkt[1]->ol_flags & RTE_MBUF_F_TX_VLAN &&
2147+
vlan_flag & IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG2) {
2148+
hi_ctx_qw1 |=
2149+
IAVF_TX_CTX_DESC_IL2TAG2 << IAVF_TXD_CTX_QW1_CMD_SHIFT;
2150+
low_ctx_qw1 |=
2151+
(uint64_t)pkt[1]->vlan_tci << IAVF_TXD_CTX_QW0_L2TAG2_PARAM;
21532152
}
21542153
}
21552154
#endif
@@ -2159,20 +2158,19 @@ ctx_vtx(volatile struct iavf_tx_desc *txdp,
21592158

21602159
#ifdef IAVF_TX_VLAN_QINQ_OFFLOAD
21612160
if (offload) {
2162-
if (pkt[0]->ol_flags & RTE_MBUF_F_TX_VLAN &&
2163-
vlan_flag & IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG2) {
2164-
hi_ctx_qw0 |=
2165-
IAVF_TX_CTX_DESC_IL2TAG2 << IAVF_TXD_CTX_QW1_CMD_SHIFT;
2166-
low_ctx_qw0 |=
2167-
(uint64_t)pkt[0]->vlan_tci << IAVF_TXD_CTX_QW0_L2TAG2_PARAM;
2168-
}
21692161
if (pkt[0]->ol_flags & RTE_MBUF_F_TX_QINQ) {
21702162
uint64_t qinq_tag = vlan_flag & IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG2 ?
21712163
(uint64_t)pkt[0]->vlan_tci :
21722164
(uint64_t)pkt[0]->vlan_tci_outer;
21732165
hi_ctx_qw0 |= IAVF_TX_CTX_DESC_IL2TAG2 <<
21742166
IAVF_TXD_CTX_QW1_CMD_SHIFT;
21752167
low_ctx_qw0 |= qinq_tag << IAVF_TXD_CTX_QW0_L2TAG2_PARAM;
2168+
} else if (pkt[0]->ol_flags & RTE_MBUF_F_TX_VLAN &&
2169+
vlan_flag & IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG2) {
2170+
hi_ctx_qw0 |=
2171+
IAVF_TX_CTX_DESC_IL2TAG2 << IAVF_TXD_CTX_QW1_CMD_SHIFT;
2172+
low_ctx_qw0 |=
2173+
(uint64_t)pkt[0]->vlan_tci << IAVF_TXD_CTX_QW0_L2TAG2_PARAM;
21762174
}
21772175
}
21782176
#endif

drivers/net/intel/iavf/iavf_rxtx_vec_common.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -227,12 +227,6 @@ iavf_txd_enable_offload(__rte_unused struct rte_mbuf *tx_pkt,
227227
#endif
228228

229229
#ifdef IAVF_TX_VLAN_QINQ_OFFLOAD
230-
if (ol_flags & RTE_MBUF_F_TX_VLAN && vlan_flag & IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG1) {
231-
td_cmd |= IAVF_TX_DESC_CMD_IL2TAG1;
232-
*txd_hi |= ((uint64_t)tx_pkt->vlan_tci <<
233-
IAVF_TXD_QW1_L2TAG1_SHIFT);
234-
}
235-
236230
if (ol_flags & RTE_MBUF_F_TX_QINQ) {
237231
td_cmd |= IAVF_TX_DESC_CMD_IL2TAG1;
238232
/* vlan_flag specifies outer tag location for QinQ. */
@@ -242,6 +236,9 @@ iavf_txd_enable_offload(__rte_unused struct rte_mbuf *tx_pkt,
242236
else
243237
*txd_hi |= ((uint64_t)tx_pkt->vlan_tci <<
244238
IAVF_TXD_QW1_L2TAG1_SHIFT);
239+
} else if (ol_flags & RTE_MBUF_F_TX_VLAN && vlan_flag & IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG1) {
240+
td_cmd |= IAVF_TX_DESC_CMD_IL2TAG1;
241+
*txd_hi |= ((uint64_t)tx_pkt->vlan_tci << IAVF_TXD_QW1_L2TAG1_SHIFT);
245242
}
246243
#endif
247244

0 commit comments

Comments
 (0)