The Tx fallback uses the extended header size as the slot stride.
On Leonis this is 12 bytes, but the VLAN fallback writes a 30-byte
header. A single-segment fallback packet consumes two descriptors,
so consecutive headers start 24 bytes apart. The second header
overwrites the first packet's EtherType and VLAN fields.

Use the reserved 32-byte NBL_TX_HEADER_LEN stride for both the
software header pointer and the descriptor DMA address.

Fixes: 9d7757dce874 ("net/nbl: simulate VLAN offload")
Cc: [email protected]
Signed-off-by: Dimon Zhao <[email protected]>
---
 drivers/net/nbl/nbl_hw/nbl_txrx.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/net/nbl/nbl_hw/nbl_txrx.c 
b/drivers/net/nbl/nbl_hw/nbl_txrx.c
index 7beae85..34e62fb 100644
--- a/drivers/net/nbl/nbl_hw/nbl_txrx.c
+++ b/drivers/net/nbl/nbl_hw/nbl_txrx.c
@@ -512,7 +512,7 @@ static u16
 nbl_res_txrx_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, u16 nb_pkts, 
u16 extend_set)
 {
        struct nbl_res_tx_ring *txq;
-       union nbl_tx_extend_head *tx_region;
+       void *tx_region;
        volatile struct nbl_packed_desc *tx_ring;
        struct nbl_tx_entry *sw_ring;
        volatile struct nbl_packed_desc *tx_desc, *head_desc;
@@ -542,6 +542,8 @@ nbl_res_txrx_xmit_pkts(void *tx_queue, struct rte_mbuf 
**tx_pkts, u16 nb_pkts, u
                nbl_tx_free_bufs(txq);
 
        for (nb_xmit_pkts = 0; nb_xmit_pkts < nb_pkts; nb_xmit_pkts++) {
+               size_t hdr_offset = (size_t)desc_index * NBL_TX_HEADER_LEN;
+
                required_headroom = txq->exthdr_len;
                tx_extend_len = txq->exthdr_len;
                addr_offset = 0;
@@ -563,14 +565,14 @@ nbl_res_txrx_xmit_pkts(void *tx_queue, struct rte_mbuf 
**tx_pkts, u16 nb_pkts, u
                                                    -required_headroom);
                } else {
                        can_push = 0;
-                       u = (union nbl_tx_extend_head 
*)(&tx_region[desc_index]);
+                       u = RTE_PTR_ADD(tx_region, hdr_offset);
                }
 
                if (tx_pkt->ol_flags & RTE_MBUF_F_TX_VLAN) {
                        if (likely(can_push)) {
                                if (rte_vlan_insert(&tx_pkt)) {
                                        can_push = 0;
-                                       u = (union nbl_tx_extend_head 
*)(&tx_region[desc_index]);
+                                       u = RTE_PTR_ADD(tx_region, hdr_offset);
                                }
                        }
                        if (unlikely(!can_push)) {
@@ -607,8 +609,7 @@ nbl_res_txrx_xmit_pkts(void *tx_queue, struct rte_mbuf 
**tx_pkts, u16 nb_pkts, u
                        head_flags |= NBL_VRING_DESC_F_NEXT;
                        txe->mbuf = NULL;
                        /* padding */
-                       head_desc->addr = net_hdr_mem +
-                                       RTE_PTR_DIFF(&tx_region[desc_index], 
tx_region);
+                       head_desc->addr = net_hdr_mem + hdr_offset;
                        head_desc->len = tx_extend_len;
                        txe->first_id = head_index;
                        desc_index++;
-- 
2.53.0

Reply via email to