Skip to contentSkip to conversation

combine multiple Intel scalar Tx paths

RFC PATCH Superseded Bruce Richardson 6 participants 274 messages Dec 19, 2025 – Feb 12 Network drivers Page 3 of 4

lore
Share & tools
lore
#105 lore raw

PATCH v3 13/36 net/i40e: use common scalar Tx function

In reply to Bruce Richardson

Following earlier rework, the scalar transmit function for i40e can use the common function previously moved over from ice driver. This saves hundreds of duplicated lines of code.

---
 drivers/net/intel/i40e/i40e_rxtx.c | 208 +----------------------------
 1 file changed, 2 insertions(+), 206 deletions(-)
drivers/net/intel/i40e/i40e_rxtx.c +2 -206
index 1ad445c47b..81fdeb72cb 100644
@@ -1018,212 +1018,8 @@ get_context_desc(uint64_t ol_flags, const struct rte_mbuf *tx_pkt,
 uint16_t
 i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 {
-	struct ci_tx_queue *txq;
-	struct ci_tx_entry *sw_ring;
-	struct ci_tx_entry *txe, *txn;
-	volatile struct ci_tx_desc *txd;
-	volatile struct ci_tx_desc *txr;
-	struct rte_mbuf *tx_pkt;
-	struct rte_mbuf *m_seg;
-	uint16_t tx_id;
-	uint16_t nb_tx;
-	uint32_t td_cmd;
-	uint32_t td_offset;
-	uint32_t td_tag;
-	uint64_t ol_flags;
-	uint16_t nb_used;
-	uint16_t nb_ctx;
-	uint16_t tx_last;
-	uint16_t slen;
-	uint16_t l2_len;
-	uint64_t buf_dma_addr;
-	union ci_tx_offload tx_offload = {0};
-
-	txq = tx_queue;
-	sw_ring = txq->sw_ring;
-	txr = txq->ci_tx_ring;
-	tx_id = txq->tx_tail;
-	txe = &sw_ring[tx_id];
-
-	/* Check if the descriptor ring needs to be cleaned. */
-	if (txq->nb_tx_free < txq->tx_free_thresh)
-		(void)ci_tx_xmit_cleanup(txq);
-
-	for (nb_tx = 0; nb_tx < nb_pkts; nb_tx++) {
-		tx_pkt = *tx_pkts++;
-		RTE_MBUF_PREFETCH_TO_FREE(txe->mbuf);
-
-		ol_flags = tx_pkt->ol_flags;
-		td_cmd = 0;
-		td_tag = 0;
-		l2_len = ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK ?
-				tx_pkt->outer_l2_len : tx_pkt->l2_len;
-		td_offset = (l2_len >> 1) << CI_TX_DESC_LEN_MACLEN_S;
-		tx_offload.l2_len = tx_pkt->l2_len;
-		tx_offload.l3_len = tx_pkt->l3_len;
-		tx_offload.outer_l2_len = tx_pkt->outer_l2_len;
-		tx_offload.outer_l3_len = tx_pkt->outer_l3_len;
-		tx_offload.l4_len = tx_pkt->l4_len;
-		tx_offload.tso_segsz = tx_pkt->tso_segsz;
-
-		/* Calculate the number of context descriptors needed. */
-		uint64_t cd_qw0 = 0, cd_qw1 = 0;
-		nb_ctx = get_context_desc(ol_flags, tx_pkt, &tx_offload, txq,
-				&cd_qw0, &cd_qw1);
-
-		/**
-		 * The number of descriptors that must be allocated for
-		 * a packet equals to the number of the segments of that
-		 * packet plus 1 context descriptor if needed.
-		 * Recalculate the needed tx descs when TSO enabled in case
-		 * the mbuf data size exceeds max data size that hw allows
-		 * per tx desc.
-		 */
-		if (ol_flags & RTE_MBUF_F_TX_TCP_SEG)
-			nb_used = (uint16_t)(ci_calc_pkt_desc(tx_pkt) + nb_ctx);
-		else
-			nb_used = (uint16_t)(tx_pkt->nb_segs + nb_ctx);
-		tx_last = (uint16_t)(tx_id + nb_used - 1);
-
-		/* Circular ring */
-		if (tx_last >= txq->nb_tx_desc)
-			tx_last = (uint16_t)(tx_last - txq->nb_tx_desc);
-
-		if (nb_used > txq->nb_tx_free) {
-			if (ci_tx_xmit_cleanup(txq) != 0) {
-				if (nb_tx == 0)
-					return 0;
-				goto end_of_tx;
-			}
-			if (unlikely(nb_used > txq->tx_rs_thresh)) {
-				while (nb_used > txq->nb_tx_free) {
-					if (ci_tx_xmit_cleanup(txq) != 0) {
-						if (nb_tx == 0)
-							return 0;
-						goto end_of_tx;
-					}
-				}
-			}
-		}
-
-		/* Descriptor based VLAN insertion */
-		if (ol_flags & (RTE_MBUF_F_TX_VLAN | RTE_MBUF_F_TX_QINQ)) {
-			td_cmd |= CI_TX_DESC_CMD_IL2TAG1;
-			td_tag = tx_pkt->vlan_tci;
-		}
-
-		/* Always enable CRC offload insertion */
-		td_cmd |= CI_TX_DESC_CMD_ICRC;
-
-		/* Enable checksum offloading */
-		if (ol_flags & CI_TX_CKSUM_OFFLOAD_MASK)
-			ci_txd_enable_checksum(ol_flags, &td_cmd,
-						 &td_offset, tx_offload);
-
-		if (nb_ctx) {
-			/* Setup TX context descriptor if required */
-			uint64_t *desc = RTE_CAST_PTR(uint64_t *, &txr[tx_id]);
-
-			txn = &sw_ring[txe->next_id];
-			RTE_MBUF_PREFETCH_TO_FREE(txn->mbuf);
-			if (txe->mbuf != NULL) {
-				rte_pktmbuf_free_seg(txe->mbuf);
-				txe->mbuf = NULL;
-			}
-
-			desc[0] = cd_qw0;
-			desc[1] = cd_qw1;
-
-			PMD_TX_LOG(DEBUG, "mbuf: %p, TCD[%u]: "
-				"qw0: %#"PRIx64"; "
-				"qw1: %#"PRIx64";",
-				tx_pkt, tx_id, cd_qw0, cd_qw1);
-
-			txe->last_id = tx_last;
-			tx_id = txe->next_id;
-			txe = txn;
-		}
-
-		m_seg = tx_pkt;
-		do {
-			txd = &txr[tx_id];
-			txn = &sw_ring[txe->next_id];
-
-			if (txe->mbuf)
-				rte_pktmbuf_free_seg(txe->mbuf);
-			txe->mbuf = m_seg;
-
-			/* Setup TX Descriptor */
-			slen = m_seg->data_len;
-			buf_dma_addr = rte_mbuf_data_iova(m_seg);
-
-			while ((ol_flags & RTE_MBUF_F_TX_TCP_SEG) &&
-				unlikely(slen > CI_MAX_DATA_PER_TXD)) {
-				txd->buffer_addr =
-					rte_cpu_to_le_64(buf_dma_addr);
-				txd->cmd_type_offset_bsz =
-					i40e_build_ctob(td_cmd,
-					td_offset, CI_MAX_DATA_PER_TXD,
-					td_tag);
-
-				buf_dma_addr += CI_MAX_DATA_PER_TXD;
-				slen -= CI_MAX_DATA_PER_TXD;
-
-				txe->last_id = tx_last;
-				tx_id = txe->next_id;
-				txe = txn;
-				txd = &txr[tx_id];
-				txn = &sw_ring[txe->next_id];
-			}
-			PMD_TX_LOG(DEBUG, "mbuf: %p, TDD[%u]: "
-				"buf_dma_addr: %#"PRIx64"; "
-				"td_cmd: %#x; "
-				"td_offset: %#x; "
-				"td_len: %u; "
-				"td_tag: %#x;",
-				tx_pkt, tx_id, buf_dma_addr,
-				td_cmd, td_offset, slen, td_tag);
-
-			txd->buffer_addr = rte_cpu_to_le_64(buf_dma_addr);
-			txd->cmd_type_offset_bsz = i40e_build_ctob(td_cmd,
-						td_offset, slen, td_tag);
-			txe->last_id = tx_last;
-			tx_id = txe->next_id;
-			txe = txn;
-			m_seg = m_seg->next;
-		} while (m_seg != NULL);
-
-		/* The last packet data descriptor needs End Of Packet (EOP) */
-		td_cmd |= CI_TX_DESC_CMD_EOP;
-		txq->nb_tx_used = (uint16_t)(txq->nb_tx_used + nb_used);
-		txq->nb_tx_free = (uint16_t)(txq->nb_tx_free - nb_used);
-
-		if (txq->nb_tx_used >= txq->tx_rs_thresh) {
-			PMD_TX_LOG(DEBUG,
-				   "Setting RS bit on TXD id="
-				   "%4u (port=%d queue=%d)",
-				   tx_last, txq->port_id, txq->queue_id);
-
-			td_cmd |= CI_TX_DESC_CMD_RS;
-
-			/* Update txq RS bit counters */
-			txq->nb_tx_used = 0;
-		}
-
-		txd->cmd_type_offset_bsz |=
-			rte_cpu_to_le_64(((uint64_t)td_cmd) << CI_TXD_QW1_CMD_S);
-	}
-
-end_of_tx:
-	PMD_TX_LOG(DEBUG, "port_id=%u queue_id=%u tx_tail=%u nb_tx=%u",
-		   (unsigned) txq->port_id, (unsigned) txq->queue_id,
-		   (unsigned) tx_id, (unsigned) nb_tx);
-
-	rte_io_wmb();
-	I40E_PCI_REG_WC_WRITE_RELAXED(txq->qtx_tail, tx_id);
-	txq->tx_tail = tx_id;
-
-	return nb_tx;
+	/* i40e does not support timestamp queues, so pass NULL for ts_fns */
+	return ci_xmit_pkts(tx_queue, tx_pkts, nb_pkts, get_context_desc, NULL);
 }
 
 static __rte_always_inline int
Signature · 1 line
2.51.0
#106 lore raw

PATCH v3 14/36 net/intel: add IPsec hooks to common Tx function

In reply to Bruce Richardson

The iavf driver has IPsec offload support on Tx, so add hooks to the common Tx function to support that. Do so in a way that has zero performance impact for drivers which do not have IPSec support, by passing in compile-time NULL constants for the function pointers, which can be optimized away by the compiler.

---
 drivers/net/intel/common/tx_scalar_fns.h | 60 ++++++++++++++++++++++--
 drivers/net/intel/i40e/i40e_rxtx.c       |  4 +-
 drivers/net/intel/ice/ice_rxtx.c         |  4 +-
 3 files changed, 60 insertions(+), 8 deletions(-)
drivers/net/intel/common/tx_scalar_fns.h +56 -4
index 6d01c14283..2fe503a548 100644
@@ -147,6 +147,24 @@ typedef uint16_t (*ci_get_ctx_desc_fn)(uint64_t ol_flags, const struct rte_mbuf
 		const union ci_tx_offload *tx_offload, const struct ci_tx_queue *txq,
 		uint64_t *qw0, uint64_t *qw1);
 
+/* gets IPsec descriptor information and returns number of descriptors needed (0 or 1) */
+typedef uint16_t (*get_ipsec_desc_t)(const struct rte_mbuf *mbuf,
+		const struct ci_tx_queue *txq,
+		void **ipsec_metadata,
+		uint64_t *qw0,
+		uint64_t *qw1);
+/* calculates segment length for IPsec + TSO combinations */
+typedef uint16_t (*calc_ipsec_segment_len_t)(const struct rte_mbuf *mb_seg,
+		uint64_t ol_flags,
+		const void *ipsec_metadata,
+		uint16_t tlen);
+
+/** IPsec descriptor operations for drivers that support inline IPsec crypto. */
+struct ci_ipsec_ops {
+	get_ipsec_desc_t get_ipsec_desc;
+	calc_ipsec_segment_len_t calc_segment_len;
+};
+
 /* gets current timestamp tail index */
 typedef uint16_t (*get_ts_tail_t)(struct ci_tx_queue *txq);
 /* writes a timestamp descriptor and returns new tail index */
@@ -166,6 +184,7 @@ ci_xmit_pkts(struct ci_tx_queue *txq,
 	     struct rte_mbuf **tx_pkts,
 	     uint16_t nb_pkts,
 	     ci_get_ctx_desc_fn get_ctx_desc,
+	     const struct ci_ipsec_ops *ipsec_ops,
 	     const struct ci_timesstamp_queue_fns *ts_fns)
 {
 	volatile struct ci_tx_desc *ci_tx_ring;
@@ -202,6 +221,9 @@ ci_xmit_pkts(struct ci_tx_queue *txq,
 		(void)ci_tx_xmit_cleanup(txq);
 
 	for (nb_tx = 0; nb_tx < nb_pkts; nb_tx++) {
+		void *ipsec_md = NULL;
+		uint16_t nb_ipsec = 0;
+		uint64_t ipsec_qw0 = 0, ipsec_qw1 = 0;
 		uint64_t cd_qw0, cd_qw1;
 		tx_pkt = *tx_pkts++;
 
@@ -223,17 +245,22 @@ ci_xmit_pkts(struct ci_tx_queue *txq,
 		/* Calculate the number of context descriptors needed. */
 		nb_ctx = get_ctx_desc(ol_flags, tx_pkt, &tx_offload, txq, &cd_qw0, &cd_qw1);
 
+		/* Get IPsec descriptor information if IPsec ops provided */
+		if (ipsec_ops != NULL)
+			nb_ipsec = ipsec_ops->get_ipsec_desc(tx_pkt, txq, &ipsec_md,
+					&ipsec_qw0, &ipsec_qw1);
+
 		/* The number of descriptors that must be allocated for
 		 * a packet equals to the number of the segments of that
-		 * packet plus the number of context descriptor if needed.
+		 * packet plus the number of context and IPsec descriptors if needed.
 		 * Recalculate the needed tx descs when TSO enabled in case
 		 * the mbuf data size exceeds max data size that hw allows
 		 * per tx desc.
 		 */
 		if (ol_flags & (RTE_MBUF_F_TX_TCP_SEG | RTE_MBUF_F_TX_UDP_SEG))
-			nb_used = (uint16_t)(ci_calc_pkt_desc(tx_pkt) + nb_ctx);
+			nb_used = (uint16_t)(ci_calc_pkt_desc(tx_pkt) + nb_ctx + nb_ipsec);
 		else
-			nb_used = (uint16_t)(tx_pkt->nb_segs + nb_ctx);
+			nb_used = (uint16_t)(tx_pkt->nb_segs + nb_ctx + nb_ipsec);
 		tx_last = (uint16_t)(tx_id + nb_used - 1);
 
 		/* Circular ring */
@@ -286,6 +313,26 @@ ci_xmit_pkts(struct ci_tx_queue *txq,
 			tx_id = txe->next_id;
 			txe = txn;
 		}
+
+		if (ipsec_ops != NULL && nb_ipsec > 0) {
+			/* Setup TX IPsec descriptor if required */
+			uint64_t *ipsec_txd = RTE_CAST_PTR(uint64_t *, &ci_tx_ring[tx_id]);
+
+			txn = &sw_ring[txe->next_id];
+			RTE_MBUF_PREFETCH_TO_FREE(txn->mbuf);
+			if (txe->mbuf) {
+				rte_pktmbuf_free_seg(txe->mbuf);
+				txe->mbuf = NULL;
+			}
+
+			ipsec_txd[0] = ipsec_qw0;
+			ipsec_txd[1] = ipsec_qw1;
+
+			txe->last_id = tx_last;
+			tx_id = txe->next_id;
+			txe = txn;
+		}
+
 		m_seg = tx_pkt;
 
 		do {
@@ -297,7 +344,12 @@ ci_xmit_pkts(struct ci_tx_queue *txq,
 			txe->mbuf = m_seg;
 
 			/* Setup TX Descriptor */
-			slen = m_seg->data_len;
+			/* Calculate segment length, using IPsec callback if provided */
+			if (ipsec_ops != NULL)
+				slen = ipsec_ops->calc_segment_len(m_seg, ol_flags, ipsec_md, 0);
+			else
+				slen = m_seg->data_len;
+
 			buf_dma_addr = rte_mbuf_data_iova(m_seg);
 
 			while ((ol_flags & (RTE_MBUF_F_TX_TCP_SEG | RTE_MBUF_F_TX_UDP_SEG)) &&
drivers/net/intel/i40e/i40e_rxtx.c +2 -2
index 81fdeb72cb..e7dd637931 100644
@@ -1018,8 +1018,8 @@ get_context_desc(uint64_t ol_flags, const struct rte_mbuf *tx_pkt,
 uint16_t
 i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 {
-	/* i40e does not support timestamp queues, so pass NULL for ts_fns */
-	return ci_xmit_pkts(tx_queue, tx_pkts, nb_pkts, get_context_desc, NULL);
+	/* i40e does not support IPsec or timestamp queues, so pass NULL for both */
+	return ci_xmit_pkts(tx_queue, tx_pkts, nb_pkts, get_context_desc, NULL, NULL);
 }
 
 static __rte_always_inline int
drivers/net/intel/ice/ice_rxtx.c +2 -2
index d805bee4f0..eea83bbae1 100644
@@ -3105,9 +3105,9 @@ ice_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 	struct ci_tx_queue *txq = (struct ci_tx_queue *)tx_queue;
 
 	if (txq->tsq != NULL && txq->tsq->ts_flag > 0)
-		return ci_xmit_pkts(txq, tx_pkts, nb_pkts, get_context_desc, &ts_fns);
+		return ci_xmit_pkts(txq, tx_pkts, nb_pkts, get_context_desc, NULL, &ts_fns);
 
-	return ci_xmit_pkts(txq, tx_pkts, nb_pkts, get_context_desc, NULL);
+	return ci_xmit_pkts(txq, tx_pkts, nb_pkts, get_context_desc, NULL, NULL);
 }
 
 static __rte_always_inline int
Signature · 1 line
2.51.0
#107 lore raw

PATCH v3 15/36 net/intel: support configurable VLAN tag insertion on Tx

In reply to Bruce Richardson

Make the VLAN tag insertion logic configurable in the common code, as to where inner/outer tags get placed.

---
 drivers/net/intel/common/tx.h            | 10 ++++++++++
 drivers/net/intel/common/tx_scalar_fns.h |  9 +++++++--
 drivers/net/intel/i40e/i40e_rxtx.c       |  6 +++---
 drivers/net/intel/ice/ice_rxtx.c         |  5 +++--
 4 files changed, 23 insertions(+), 7 deletions(-)
drivers/net/intel/common/tx.h +10 -0
index 928fad1df5..faa9bb9559 100644
@@ -45,6 +45,16 @@
 #define CI_TX_CTX_DESC_TSYN             0x02
 #define CI_TX_CTX_DESC_IL2TAG2          0x04
 
+/**
+ * L2TAG1 Field Source Selection
+ * Specifies which mbuf VLAN field to use for the L2TAG1 field in data descriptors.
+ * Context descriptor VLAN handling (L2TAG2) is managed by driver-specific callbacks.
+ */
+enum ci_tx_l2tag1_field {
+	CI_VLAN_IN_L2TAG1,       /**< For VLAN (not QinQ), use L2Tag1 field in data desc */
+	CI_VLAN_IN_L2TAG2,       /**< For VLAN (not QinQ), use L2Tag2 field in ctx desc */
+};
+
 /* Common TX Descriptor Length Field Shifts */
 #define CI_TX_DESC_LEN_MACLEN_S         0  /* 7 BITS */
 #define CI_TX_DESC_LEN_IPLEN_S          7  /* 7 BITS */
drivers/net/intel/common/tx_scalar_fns.h +7 -2
index 2fe503a548..92eed4a476 100644
@@ -183,6 +183,7 @@ static inline uint16_t
 ci_xmit_pkts(struct ci_tx_queue *txq,
 	     struct rte_mbuf **tx_pkts,
 	     uint16_t nb_pkts,
+	     enum ci_tx_l2tag1_field l2tag1_field,
 	     ci_get_ctx_desc_fn get_ctx_desc,
 	     const struct ci_ipsec_ops *ipsec_ops,
 	     const struct ci_timesstamp_queue_fns *ts_fns)
@@ -284,8 +285,12 @@ ci_xmit_pkts(struct ci_tx_queue *txq,
 			}
 		}
 
-		/* Descriptor based VLAN insertion */
-		if (ol_flags & (RTE_MBUF_F_TX_VLAN | RTE_MBUF_F_TX_QINQ)) {
+		/* Descriptor based VLAN/QinQ insertion */
+		/* for single vlan offload, only insert in data desc with VLAN_IN_L2TAG1 is set
+		 * for qinq offload, we always put inner tag in L2Tag1
+		 */
+		if (((ol_flags & RTE_MBUF_F_TX_VLAN) && l2tag1_field == CI_VLAN_IN_L2TAG1) ||
+				(ol_flags & RTE_MBUF_F_TX_QINQ)) {
 			td_cmd |= CI_TX_DESC_CMD_IL2TAG1;
 			td_tag = tx_pkt->vlan_tci;
 		}
drivers/net/intel/i40e/i40e_rxtx.c +3 -3
index e7dd637931..4e2071c024 100644
@@ -1004,8 +1004,7 @@ get_context_desc(uint64_t ol_flags, const struct rte_mbuf *tx_pkt,
 	/* TX context descriptor based double VLAN insert */
 	if (ol_flags & RTE_MBUF_F_TX_QINQ) {
 		cd_l2tag2 = tx_pkt->vlan_tci_outer;
-		cd_type_cmd_tso_mss |=
-				((uint64_t)I40E_TX_CTX_DESC_IL2TAG2 << I40E_TXD_CTX_QW1_CMD_SHIFT);
+		cd_type_cmd_tso_mss |= (I40E_TX_CTX_DESC_IL2TAG2 << I40E_TXD_CTX_QW1_CMD_SHIFT);
 	}
 
 	*qw0 = rte_cpu_to_le_32(cd_tunneling_params) |
@@ -1019,7 +1018,8 @@ uint16_t
 i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 {
 	/* i40e does not support IPsec or timestamp queues, so pass NULL for both */
-	return ci_xmit_pkts(tx_queue, tx_pkts, nb_pkts, get_context_desc, NULL, NULL);
+	return ci_xmit_pkts(tx_queue, tx_pkts, nb_pkts, CI_VLAN_IN_L2TAG1,
+			get_context_desc, NULL, NULL);
 }
 
 static __rte_always_inline int
drivers/net/intel/ice/ice_rxtx.c +3 -2
index eea83bbae1..79b021a58f 100644
@@ -3105,9 +3105,10 @@ ice_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 	struct ci_tx_queue *txq = (struct ci_tx_queue *)tx_queue;
 
 	if (txq->tsq != NULL && txq->tsq->ts_flag > 0)
-		return ci_xmit_pkts(txq, tx_pkts, nb_pkts, get_context_desc, NULL, &ts_fns);
+		return ci_xmit_pkts(txq, tx_pkts, nb_pkts, CI_VLAN_IN_L2TAG1,
+				get_context_desc, NULL, &ts_fns);
 
-	return ci_xmit_pkts(txq, tx_pkts, nb_pkts, get_context_desc, NULL, NULL);
+	return ci_xmit_pkts(txq, tx_pkts, nb_pkts, CI_VLAN_IN_L2TAG1, get_context_desc, NULL, NULL);
 }
 
 static __rte_always_inline int
Signature · 1 line
2.51.0
#108 lore raw

PATCH v3 16/36 net/iavf: use common scalar Tx function

In reply to Bruce Richardson

Now that the common scalar Tx function has all necessary hooks for the features supported by the iavf driver, use the common function to avoid duplicated code.

---
 drivers/net/intel/common/tx_scalar_fns.h |   3 +-
 drivers/net/intel/iavf/iavf_rxtx.c       | 534 +++++------------------
 2 files changed, 111 insertions(+), 426 deletions(-)
drivers/net/intel/common/tx_scalar_fns.h +2 -1
index 92eed4a476..5e301699be 100644
@@ -231,7 +231,8 @@ ci_xmit_pkts(struct ci_tx_queue *txq,
 		ol_flags = tx_pkt->ol_flags;
 		td_cmd = CI_TX_DESC_CMD_ICRC;
 		td_tag = 0;
-		l2_len = ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK ?
+		l2_len = (ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK &&
+					!(ol_flags & RTE_MBUF_F_TX_SEC_OFFLOAD)) ?
 				tx_pkt->outer_l2_len : tx_pkt->l2_len;
 		td_offset = (l2_len >> 1) << CI_TX_DESC_LEN_MACLEN_S;
 
drivers/net/intel/iavf/iavf_rxtx.c +109 -425

600 lines not on this page · raw message

Signature · 1 line
2.51.0
#109 lore raw

PATCH v3 17/36 net/i40e: document requirement for QinQ support

In reply to Bruce Richardson

In order to get multiple VLANs inserted in an outgoing packet with QinQ offload the i40e driver needs to be set to double vlan mode. This is done by using the VLAN_EXTEND Rx config flag. Add a code check for this dependency and update the docs about it.

---
 doc/guides/nics/i40e.rst           | 18 ++++++++++++++++++
 drivers/net/intel/i40e/i40e_rxtx.c |  9 +++++++++
 2 files changed, 27 insertions(+)
doc/guides/nics/i40e.rst +18 -0
index 45dc083c94..cbfaddbdd8 100644
@@ -245,6 +245,24 @@ Runtime Configuration
   * ``segment``: Check number of mbuf segments not exceed hw limitation.
   * ``offload``: Check any unsupported offload flag.
 
+QinQ Configuration
+~~~~~~~~~~~~~~~~~~
+
+When using QinQ TX offload (``RTE_ETH_TX_OFFLOAD_QINQ_INSERT``), you must also
+enable ``RTE_ETH_RX_OFFLOAD_VLAN_EXTEND`` to configure the hardware for double
+VLAN mode. Without this, only the inner VLAN tag will be inserted.
+
+Example::
+
+  struct rte_eth_conf port_conf = {
+      .rxmode = {
+          .offloads = RTE_ETH_RX_OFFLOAD_VLAN_EXTEND,
+      },
+      .txmode = {
+          .offloads = RTE_ETH_TX_OFFLOAD_QINQ_INSERT,
+      },
+  };
+
 Vector RX Pre-conditions
 ~~~~~~~~~~~~~~~~~~~~~~~~
 For Vector RX it is assumed that the number of descriptor rings will be a power
drivers/net/intel/i40e/i40e_rxtx.c +9 -0
index 4e2071c024..49ec4dd8a1 100644
@@ -2182,6 +2182,15 @@ i40e_dev_tx_queue_setup(struct rte_eth_dev *dev,
 	vsi = i40e_pf_get_vsi_by_qindex(pf, queue_idx);
 	if (!vsi)
 		return -EINVAL;
+
+	/* Check if QinQ TX offload requires VLAN extend mode */
+	if ((offloads & RTE_ETH_TX_OFFLOAD_QINQ_INSERT) &&
+			!(dev->data->dev_conf.rxmode.offloads & RTE_ETH_RX_OFFLOAD_VLAN_EXTEND)) {
+		PMD_DRV_LOG(WARNING, "Port %u: QinQ TX offload is enabled but VLAN extend mode is not set. ",
+				dev->data->port_id);
+		PMD_DRV_LOG(WARNING, "Double VLAN insertion may not work correctly without RTE_ETH_RX_OFFLOAD_VLAN_EXTEND set in Rx configuration.");
+	}
+
 	q_offset = i40e_get_queue_offset_by_qindex(pf, queue_idx);
 	if (q_offset < 0)
 		return -EINVAL;
Signature · 1 line
2.51.0
#110 lore raw

PATCH v3 18/36 net/idpf: use common scalar Tx function

In reply to Bruce Richardson

Update idpf driver to use the common scalar Tx function in single-queue configuration.

---
 drivers/net/intel/idpf/idpf_common_rxtx.c | 178 ++--------------------
 1 file changed, 10 insertions(+), 168 deletions(-)
drivers/net/intel/idpf/idpf_common_rxtx.c +10 -168
index b34d545a0a..bca5f13c8e 100644
@@ -8,7 +8,6 @@
 
 #include "idpf_common_rxtx.h"
 #include "idpf_common_device.h"
-#include "../common/rx.h"
 
 int idpf_timestamp_dynfield_offset = -1;
 uint64_t idpf_timestamp_dynflag;
@@ -848,9 +847,10 @@ idpf_calc_context_desc(uint64_t flags)
 /* set TSO context descriptor, returns 0 if no context needed, 1 if context set
  */
 static inline uint16_t
-idpf_set_tso_ctx(uint64_t ol_flags, struct rte_mbuf *mbuf,
-			union ci_tx_offload tx_offload,
-			uint64_t *qw0, uint64_t *qw1)
+idpf_set_tso_ctx(uint64_t ol_flags, const struct rte_mbuf *mbuf,
+		 const union ci_tx_offload *tx_offload,
+		 const struct ci_tx_queue *txq __rte_unused,
+		 uint64_t *qw0, uint64_t *qw1)
 {
 	uint16_t cmd_dtype = IDPF_TX_DESC_DTYPE_FLEX_TSO_CTX | IDPF_TX_FLEX_CTX_DESC_CMD_TSO;
 	uint16_t tso_segsz = mbuf->tso_segsz;
@@ -861,12 +861,12 @@ idpf_set_tso_ctx(uint64_t ol_flags, struct rte_mbuf *mbuf,
 		return 0;
 
 	/* TSO context descriptor setup */
-	if (tx_offload.l4_len == 0) {
+	if (tx_offload->l4_len == 0) {
 		TX_LOG(DEBUG, "L4 length set to 0");
 		return 0;
 	}
 
-	hdr_len = tx_offload.l2_len + tx_offload.l3_len + tx_offload.l4_len;
+	hdr_len = tx_offload->l2_len + tx_offload->l3_len + tx_offload->l4_len;
 	tso_len = mbuf->pkt_len - hdr_len;
 
 	*qw0 = rte_cpu_to_le_32(tso_len & IDPF_TXD_FLEX_CTX_MSS_RT_M) |
@@ -933,7 +933,8 @@ idpf_dp_splitq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 		tx_offload.tso_segsz = tx_pkt->tso_segsz;
 		/* Calculate the number of context descriptors needed. */
 		uint64_t cd_qw0, cd_qw1;
-		nb_ctx = idpf_set_tso_ctx(ol_flags, tx_pkt, tx_offload, &cd_qw0, &cd_qw1);
+		nb_ctx = idpf_set_tso_ctx(ol_flags, tx_pkt, &tx_offload, txq,
+					  &cd_qw0, &cd_qw1);
 
 		/* Calculate the number of TX descriptors needed for
 		 * each packet. For TSO packets, use ci_calc_pkt_desc as
@@ -1339,167 +1340,8 @@ uint16_t
 idpf_dp_singleq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 			  uint16_t nb_pkts)
 {
-	volatile struct ci_tx_desc *txd;
-	volatile struct ci_tx_desc *txr;
-	union ci_tx_offload tx_offload = {0};
-	struct ci_tx_entry *txe, *txn;
-	struct ci_tx_entry *sw_ring;
-	struct ci_tx_queue *txq;
-	struct rte_mbuf *tx_pkt;
-	struct rte_mbuf *m_seg;
-	uint64_t buf_dma_addr;
-	uint32_t td_offset;
-	uint64_t ol_flags;
-	uint16_t tx_last;
-	uint16_t nb_used;
-	uint16_t nb_ctx;
-	uint16_t td_cmd;
-	uint16_t tx_id;
-	uint16_t nb_tx;
-	uint16_t slen;
-
-	nb_tx = 0;
-	txq = tx_queue;
-
-	if (unlikely(txq == NULL))
-		return nb_tx;
-
-	sw_ring = txq->sw_ring;
-	txr = txq->ci_tx_ring;
-	tx_id = txq->tx_tail;
-	txe = &sw_ring[tx_id];
-
-	/* Check if the descriptor ring needs to be cleaned. */
-	if (txq->nb_tx_free < txq->tx_free_thresh)
-		(void)ci_tx_xmit_cleanup(txq);
-
-	for (nb_tx = 0; nb_tx < nb_pkts; nb_tx++) {
-		td_cmd = 0;
-		td_offset = 0;
-
-		tx_pkt = *tx_pkts++;
-		RTE_MBUF_PREFETCH_TO_FREE(txe->mbuf);
-
-		ol_flags = tx_pkt->ol_flags;
-		tx_offload.l2_len = tx_pkt->l2_len;
-		tx_offload.l3_len = tx_pkt->l3_len;
-		tx_offload.l4_len = tx_pkt->l4_len;
-		tx_offload.tso_segsz = tx_pkt->tso_segsz;
-		/* Calculate the number of context descriptors needed. */
-		uint64_t cd_qw0, cd_qw1;
-		nb_ctx = idpf_set_tso_ctx(ol_flags, tx_pkt, tx_offload, &cd_qw0, &cd_qw1);
-
-		/* The number of descriptors that must be allocated for
-		 * a packet. For TSO packets, use ci_calc_pkt_desc as
-		 * the mbuf data size might exceed max data size that hw allows
-		 * per tx desc.
-		 */
-		if (ol_flags & RTE_MBUF_F_TX_TCP_SEG)
-			nb_used = (uint16_t)(ci_calc_pkt_desc(tx_pkt) + nb_ctx);
-		else
-			nb_used = (uint16_t)(tx_pkt->nb_segs + nb_ctx);
-		tx_last = (uint16_t)(tx_id + nb_used - 1);
-
-		/* Circular ring */
-		if (tx_last >= txq->nb_tx_desc)
-			tx_last = (uint16_t)(tx_last - txq->nb_tx_desc);
-
-		TX_LOG(DEBUG, "port_id=%u queue_id=%u"
-		       " tx_first=%u tx_last=%u",
-		       txq->port_id, txq->queue_id, tx_id, tx_last);
-
-		if (nb_used > txq->nb_tx_free) {
-			if (ci_tx_xmit_cleanup(txq) != 0) {
-				if (nb_tx == 0)
-					return 0;
-				goto end_of_tx;
-			}
-			if (unlikely(nb_used > txq->tx_rs_thresh)) {
-				while (nb_used > txq->nb_tx_free) {
-					if (ci_tx_xmit_cleanup(txq) != 0) {
-						if (nb_tx == 0)
-							return 0;
-						goto end_of_tx;
-					}
-				}
-			}
-		}
-
-		if (ol_flags & CI_TX_CKSUM_OFFLOAD_MASK)
-			td_cmd |= IDPF_TX_FLEX_DESC_CMD_CS_EN;
-
-		if (nb_ctx != 0) {
-			/* Setup TX context descriptor if required */
-			uint64_t *ctx_txd = RTE_CAST_PTR(uint64_t *, &txr[tx_id]);
-
-			txn = &sw_ring[txe->next_id];
-			RTE_MBUF_PREFETCH_TO_FREE(txn->mbuf);
-			if (txe->mbuf != NULL) {
-				rte_pktmbuf_free_seg(txe->mbuf);
-				txe->mbuf = NULL;
-			}
-
-			ctx_txd[0] = cd_qw0;
-			ctx_txd[1] = cd_qw1;
-
-			txe->last_id = tx_last;
-			tx_id = txe->next_id;
-			txe = txn;
-		}
-
-		m_seg = tx_pkt;
-		do {
-			txd = &txr[tx_id];
-			txn = &sw_ring[txe->next_id];
-
-			if (txe->mbuf != NULL)
-				rte_pktmbuf_free_seg(txe->mbuf);
-			txe->mbuf = m_seg;
-
-			/* Setup TX Descriptor */
-			slen = m_seg->data_len;
-			buf_dma_addr = rte_mbuf_data_iova(m_seg);
-			txd->buffer_addr = rte_cpu_to_le_64(buf_dma_addr);
-			txd->cmd_type_offset_bsz = rte_cpu_to_le_64(CI_TX_DESC_DTYPE_DATA |
-				((uint64_t)td_cmd  << CI_TXD_QW1_CMD_S) |
-				((uint64_t)td_offset << CI_TXD_QW1_OFFSET_S) |
-				((uint64_t)slen << CI_TXD_QW1_TX_BUF_SZ_S));
-
-			txe->last_id = tx_last;
-			tx_id = txe->next_id;
-			txe = txn;
-			m_seg = m_seg->next;
-		} while (m_seg);
-
-		/* The last packet data descriptor needs End Of Packet (EOP) */
-		td_cmd |= CI_TX_DESC_CMD_EOP;
-		txq->nb_tx_used = (uint16_t)(txq->nb_tx_used + nb_used);
-		txq->nb_tx_free = (uint16_t)(txq->nb_tx_free - nb_used);
-
-		if (txq->nb_tx_used >= txq->tx_rs_thresh) {
-			TX_LOG(DEBUG, "Setting RS bit on TXD id="
-			       "%4u (port=%d queue=%d)",
-			       tx_last, txq->port_id, txq->queue_id);
-
-			td_cmd |= CI_TX_DESC_CMD_RS;
-
-			/* Update txq RS bit counters */
-			txq->nb_tx_used = 0;
-		}
-
-		txd->cmd_type_offset_bsz |= rte_cpu_to_le_16(td_cmd << CI_TXD_QW1_CMD_S);
-	}
-
-end_of_tx:
-	rte_wmb();
-
-	TX_LOG(DEBUG, "port_id=%u queue_id=%u tx_tail=%u nb_tx=%u",
-	       txq->port_id, txq->queue_id, tx_id, nb_tx);
-
-	IDPF_PCI_REG_WRITE(txq->qtx_tail, tx_id);
-	txq->tx_tail = tx_id;
-
-	return nb_tx;
+	return ci_xmit_pkts(tx_queue, tx_pkts, nb_pkts, CI_VLAN_IN_L2TAG1,
+			idpf_set_tso_ctx, NULL, NULL);
 }
 
 /* TX prep functions */
Signature · 1 line
2.51.0
#111 lore raw

PATCH v3 19/36 net/intel: avoid writing the final pkt descriptor twice

In reply to Bruce Richardson

In the scalar datapath, there is a loop to handle multi-segment, and multi-descriptor packets on Tx. After that loop, the end-of-packet bit was written to the descriptor separately, meaning that for each single-descriptor packet there were two writes to the second quad-word - basically 3 x 64-bit writes rather than just 2. Adjusting the code to compute the EOP bit inside the loop saves that extra write per packet and so improves performance.

---
 drivers/net/intel/common/tx_scalar_fns.h | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/net/intel/common/tx_scalar_fns.h +6 -6
index 5e301699be..bd8053f58c 100644
@@ -377,6 +377,10 @@ ci_xmit_pkts(struct ci_tx_queue *txq,
 				txn = &sw_ring[txe->next_id];
 			}
 
+			/* fill the last descriptor with End of Packet (EOP) bit */
+			if (m_seg->next == NULL)
+				td_cmd |= CI_TX_DESC_CMD_EOP;
+
 			txd->buffer_addr = rte_cpu_to_le_64(buf_dma_addr);
 			txd->cmd_type_offset_bsz = rte_cpu_to_le_64(CI_TX_DESC_DTYPE_DATA |
 				((uint64_t)td_cmd << CI_TXD_QW1_CMD_S) |
@@ -389,21 +393,17 @@ ci_xmit_pkts(struct ci_tx_queue *txq,
 			txe = txn;
 			m_seg = m_seg->next;
 		} while (m_seg);
-
-		/* fill the last descriptor with End of Packet (EOP) bit */
-		td_cmd |= CI_TX_DESC_CMD_EOP;
 		txq->nb_tx_used = (uint16_t)(txq->nb_tx_used + nb_used);
 		txq->nb_tx_free = (uint16_t)(txq->nb_tx_free - nb_used);
 
 		/* set RS bit on the last descriptor of one packet */
 		if (txq->nb_tx_used >= txq->tx_rs_thresh) {
-			td_cmd |= CI_TX_DESC_CMD_RS;
+			txd->cmd_type_offset_bsz |=
+					rte_cpu_to_le_64(CI_TX_DESC_CMD_RS << CI_TXD_QW1_CMD_S);
 
 			/* Update txq RS bit counters */
 			txq->nb_tx_used = 0;
 		}
-		txd->cmd_type_offset_bsz |=
-				rte_cpu_to_le_64(((uint64_t)td_cmd) << CI_TXD_QW1_CMD_S);
 
 		if (ts_fns != NULL)
 			ts_id = ts_fns->write_ts_desc(txq, tx_pkt, tx_id, ts_id);
Signature · 1 line
2.51.0
#112 lore raw

PATCH v3 20/36 eal: add macro for marking assumed alignment

In reply to Bruce Richardson

Provide a common DPDK macro for the gcc/clang builtin __rte_assume_aligned to mark pointers as pointing to something with known minimum alignment.

---
 lib/eal/include/rte_common.h | 6 ++++++
 1 file changed, 6 insertions(+)
lib/eal/include/rte_common.h +6 -0
index 573bf4f2ce..51a2eaf8b4 100644
@@ -121,6 +121,12 @@ extern "C" {
 #define __rte_aligned(a) __attribute__((__aligned__(a)))
 #endif
 
+#ifdef RTE_TOOLCHAIN_MSVC
+#define __rte_assume_aligned(ptr, align) (ptr)
+#else
+#define __rte_assume_aligned __builtin_assume_aligned
+#endif
+
 #ifdef RTE_ARCH_STRICT_ALIGN
 typedef uint64_t unaligned_uint64_t __rte_aligned(1);
 typedef uint32_t unaligned_uint32_t __rte_aligned(1);
Signature · 1 line
2.51.0
#113 lore raw

PATCH v3 21/36 net/intel: write descriptors using non-volatile pointers

In reply to Bruce Richardson

Use a non-volatile uint64_t pointer to store to the descriptor ring. This will allow the compiler to optionally merge the stores as it sees best.

---
 drivers/net/intel/common/tx_scalar_fns.h | 24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)
drivers/net/intel/common/tx_scalar_fns.h +16 -8
index bd8053f58c..ee93ce5811 100644
@@ -179,6 +179,15 @@ struct ci_timesstamp_queue_fns {
 	write_ts_tail_t write_ts_tail;
 };
 
+static inline void
+write_txd(volatile void *txd, uint64_t qw0, uint64_t qw1)
+{
+	uint64_t *txd_qw = __rte_assume_aligned(RTE_CAST_PTR(void *, txd), 16);
+
+	txd_qw[0] = rte_cpu_to_le_64(qw0);
+	txd_qw[1] = rte_cpu_to_le_64(qw1);
+}
+
 static inline uint16_t
 ci_xmit_pkts(struct ci_tx_queue *txq,
 	     struct rte_mbuf **tx_pkts,
@@ -312,8 +321,7 @@ ci_xmit_pkts(struct ci_tx_queue *txq,
 				txe->mbuf = NULL;
 			}
 
-			ctx_txd[0] = cd_qw0;
-			ctx_txd[1] = cd_qw1;
+			write_txd(ctx_txd, cd_qw0, cd_qw1);
 
 			txe->last_id = tx_last;
 			tx_id = txe->next_id;
@@ -360,12 +368,12 @@ ci_xmit_pkts(struct ci_tx_queue *txq,
 
 			while ((ol_flags & (RTE_MBUF_F_TX_TCP_SEG | RTE_MBUF_F_TX_UDP_SEG)) &&
 					unlikely(slen > CI_MAX_DATA_PER_TXD)) {
-				txd->buffer_addr = rte_cpu_to_le_64(buf_dma_addr);
-				txd->cmd_type_offset_bsz = rte_cpu_to_le_64(CI_TX_DESC_DTYPE_DATA |
+				const uint64_t cmd_type_offset_bsz = CI_TX_DESC_DTYPE_DATA |
 					((uint64_t)td_cmd << CI_TXD_QW1_CMD_S) |
 					((uint64_t)td_offset << CI_TXD_QW1_OFFSET_S) |
 					((uint64_t)CI_MAX_DATA_PER_TXD << CI_TXD_QW1_TX_BUF_SZ_S) |
-					((uint64_t)td_tag << CI_TXD_QW1_L2TAG1_S));
+					((uint64_t)td_tag << CI_TXD_QW1_L2TAG1_S);
+				write_txd(txd, buf_dma_addr, cmd_type_offset_bsz);
 
 				buf_dma_addr += CI_MAX_DATA_PER_TXD;
 				slen -= CI_MAX_DATA_PER_TXD;
@@ -381,12 +389,12 @@ ci_xmit_pkts(struct ci_tx_queue *txq,
 			if (m_seg->next == NULL)
 				td_cmd |= CI_TX_DESC_CMD_EOP;
 
-			txd->buffer_addr = rte_cpu_to_le_64(buf_dma_addr);
-			txd->cmd_type_offset_bsz = rte_cpu_to_le_64(CI_TX_DESC_DTYPE_DATA |
+			const uint64_t cmd_type_offset_bsz = CI_TX_DESC_DTYPE_DATA |
 				((uint64_t)td_cmd << CI_TXD_QW1_CMD_S) |
 				((uint64_t)td_offset << CI_TXD_QW1_OFFSET_S) |
 				((uint64_t)slen << CI_TXD_QW1_TX_BUF_SZ_S) |
-				((uint64_t)td_tag << CI_TXD_QW1_L2TAG1_S));
+				((uint64_t)td_tag << CI_TXD_QW1_L2TAG1_S);
+			write_txd(txd, buf_dma_addr, cmd_type_offset_bsz);
 
 			txe->last_id = tx_last;
 			tx_id = txe->next_id;
Signature · 1 line
2.51.0
#114 lore raw

PATCH v3 22/36 net/intel: remove unnecessary flag clearing

In reply to Bruce Richardson

When cleaning the Tx ring, there is no need to zero out the done flag from the completed entry. That flag will be automatically cleared when the descriptor is next written. This gives a small performance benefit.

---
 drivers/net/intel/common/tx_scalar_fns.h | 7 -------
 1 file changed, 7 deletions(-)
drivers/net/intel/common/tx_scalar_fns.h +0 -7
index ee93ce5811..90dc6ae423 100644
@@ -51,13 +51,6 @@ ci_tx_xmit_cleanup(struct ci_tx_queue *txq)
 	else
 		nb_tx_to_clean = (uint16_t)(desc_to_clean_to - last_desc_cleaned);
 
-	/* The last descriptor to clean is done, so that means all the
-	 * descriptors from the last descriptor that was cleaned
-	 * up to the last descriptor with the RS bit set
-	 * are done. Only reset the threshold descriptor.
-	 */
-	txd[desc_to_clean_to].cmd_type_offset_bsz = 0;
-
 	/* Update the txq to reflect the last descriptor that was cleaned */
 	txq->last_desc_cleaned = desc_to_clean_to;
 	txq->nb_tx_free = (uint16_t)(txq->nb_tx_free + nb_tx_to_clean);
Signature · 1 line
2.51.0
#115 lore raw

PATCH v3 23/36 net/intel: mark mid-burst ring cleanup as unlikely

In reply to Bruce Richardson

It should rarely be the case that we need to cleanup the descriptor ring mid-burst, so mark as unlikely to help performance.

---
 drivers/net/intel/common/tx_scalar_fns.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/intel/common/tx_scalar_fns.h +1 -1
index 90dc6ae423..488130c813 100644
@@ -271,7 +271,7 @@ ci_xmit_pkts(struct ci_tx_queue *txq,
 		if (tx_last >= txq->nb_tx_desc)
 			tx_last = (uint16_t)(tx_last - txq->nb_tx_desc);
 
-		if (nb_used > txq->nb_tx_free) {
+		if (unlikely(nb_used > txq->nb_tx_free)) {
 			if (ci_tx_xmit_cleanup(txq) != 0) {
 				if (nb_tx == 0)
 					return 0;
Signature · 1 line
2.51.0
#116 lore raw

PATCH v3 24/36 net/intel: add special handling for single desc packets

In reply to Bruce Richardson

Within the scalar packets, add a shortcut path for packets that don't use TSO and have only a single data descriptor.

---
 drivers/net/intel/common/tx_scalar_fns.h | 26 ++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
drivers/net/intel/common/tx_scalar_fns.h +26 -0
index 488130c813..8c4086296e 100644
@@ -303,6 +303,31 @@ ci_xmit_pkts(struct ci_tx_queue *txq,
 			ci_txd_enable_checksum(ol_flags, &td_cmd,
 						&td_offset, tx_offload);
 
+		/* special case for single descriptor packet, without TSO offload */
+		if (nb_used == 1 &&
+				(ol_flags & (RTE_MBUF_F_TX_TCP_SEG | RTE_MBUF_F_TX_UDP_SEG)) == 0) {
+			txd = &ci_tx_ring[tx_id];
+			tx_id = txe->next_id;
+
+			if (txe->mbuf)
+				rte_pktmbuf_free_seg(txe->mbuf);
+			*txe = (struct ci_tx_entry){
+				.mbuf = tx_pkt, .last_id = tx_last, .next_id = tx_id
+			};
+
+			/* Setup TX Descriptor */
+			td_cmd |= CI_TX_DESC_CMD_EOP;
+			const uint64_t cmd_type_offset_bsz = CI_TX_DESC_DTYPE_DATA |
+				((uint64_t)td_cmd << CI_TXD_QW1_CMD_S) |
+				((uint64_t)td_offset << CI_TXD_QW1_OFFSET_S) |
+				((uint64_t)tx_pkt->data_len << CI_TXD_QW1_TX_BUF_SZ_S) |
+				((uint64_t)td_tag << CI_TXD_QW1_L2TAG1_S);
+			write_txd(txd, rte_mbuf_data_iova(tx_pkt), cmd_type_offset_bsz);
+
+			txe = &sw_ring[tx_id];
+			goto end_pkt;
+		}
+
 		if (nb_ctx) {
 			/* Setup TX context descriptor if required */
 			uint64_t *ctx_txd = RTE_CAST_PTR(uint64_t *, &ci_tx_ring[tx_id]);
@@ -394,6 +419,7 @@ ci_xmit_pkts(struct ci_tx_queue *txq,
 			txe = txn;
 			m_seg = m_seg->next;
 		} while (m_seg);
+end_pkt:
 		txq->nb_tx_used = (uint16_t)(txq->nb_tx_used + nb_used);
 		txq->nb_tx_free = (uint16_t)(txq->nb_tx_free - nb_used);
 
Signature · 1 line
2.51.0
#117 lore raw

PATCH v3 25/36 net/intel: use separate array for desc status tracking

In reply to Bruce Richardson

Rather than writing a last_id for each individual descriptor, we can write one only for places where the "report status" (RS) bit is set, i.e. the descriptors which will be written back when done. The method used for marking what descriptors are free is also changed in the process, even if the last descriptor with the "done" bits set is past the expected point, we only track up to the expected point, and leave the rest to be counted as freed next time. This means that we always have the RS/DD bits set at fixed intervals, and we always track free slots in units of the same tx_free_thresh intervals.

---
 drivers/net/intel/common/tx.h             |  4 ++
 drivers/net/intel/common/tx_scalar_fns.h  | 62 ++++++++++-------------
 drivers/net/intel/cpfl/cpfl_rxtx.c        | 17 +++++++
 drivers/net/intel/i40e/i40e_rxtx.c        | 20 ++++++++
 drivers/net/intel/iavf/iavf_rxtx.c        | 19 +++++++
 drivers/net/intel/ice/ice_rxtx.c          | 20 ++++++++
 drivers/net/intel/idpf/idpf_common_rxtx.c |  7 +++
 drivers/net/intel/idpf/idpf_rxtx.c        | 13 +++++
 8 files changed, 128 insertions(+), 34 deletions(-)
drivers/net/intel/common/tx.h +4 -0
index faa9bb9559..a1372b145f 100644
@@ -127,6 +127,8 @@ struct ci_tx_queue {
 		struct ci_tx_entry *sw_ring; /* virtual address of SW ring */
 		struct ci_tx_entry_vec *sw_ring_vec;
 	};
+	/* Scalar TX path: Array tracking last_id at each RS threshold boundary */
+	uint16_t *rs_last_id;
 	uint16_t nb_tx_desc;           /* number of TX descriptors */
 	uint16_t tx_tail; /* current value of tail register */
 	uint16_t nb_tx_used; /* number of TX desc used since RS bit set */
@@ -140,6 +142,8 @@ struct ci_tx_queue {
 	uint16_t tx_free_thresh;
 	/* Number of TX descriptors to use before RS bit is set. */
 	uint16_t tx_rs_thresh;
+	/* Scalar TX path: log2 of tx_rs_thresh for efficient bit operations */
+	uint8_t log2_rs_thresh;
 	uint16_t port_id;  /* Device port identifier. */
 	uint16_t queue_id; /* TX queue index. */
 	uint16_t reg_idx;
drivers/net/intel/common/tx_scalar_fns.h +28 -34

128 lines not on this page · raw message

drivers/net/intel/cpfl/cpfl_rxtx.c +17 -0
index bc5bec65f0..e7a98ed4f6 100644
@@ -5,6 +5,7 @@
 #include <ethdev_driver.h>
 #include <rte_net.h>
 #include <rte_vect.h>
+#include <rte_bitops.h>
 
 #include "cpfl_ethdev.h"
 #include "cpfl_rxtx.h"
@@ -330,6 +331,7 @@ cpfl_tx_queue_release(void *txq)
 
 	ci_txq_release_all_mbufs(q, q->vector_tx);
 	rte_free(q->sw_ring);
+	rte_free(q->rs_last_id);
 	rte_memzone_free(q->mz);
 	rte_free(cpfl_txq);
 }
@@ -572,6 +574,7 @@ cpfl_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 
 	txq->nb_tx_desc = nb_desc;
 	txq->tx_rs_thresh = tx_rs_thresh;
+	txq->log2_rs_thresh = rte_log2_u32(tx_rs_thresh);
 	txq->tx_free_thresh = tx_free_thresh;
 	txq->queue_id = vport->chunks_info.tx_start_qid + queue_idx;
 	txq->port_id = dev->data->port_id;
@@ -605,6 +608,17 @@ cpfl_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 		goto err_sw_ring_alloc;
 	}
 
+	/* Allocate RS last_id tracking array */
+	uint16_t num_rs_buckets = nb_desc / tx_rs_thresh;
+	txq->rs_last_id = rte_zmalloc_socket("cpfl tx rs_last_id",
+			sizeof(txq->rs_last_id[0]) * num_rs_buckets,
+			RTE_CACHE_LINE_SIZE, socket_id);
+	if (txq->rs_last_id == NULL) {
+		PMD_INIT_LOG(ERR, "Failed to allocate memory for RS last_id array");
+		ret = -ENOMEM;
+		goto err_rs_last_id_alloc;
+	}
+
 	if (!is_splitq) {
 		txq->ci_tx_ring = mz->addr;
 		idpf_qc_single_tx_queue_reset(txq);
@@ -628,6 +642,9 @@ cpfl_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 	return 0;
 
 err_complq_setup:
+	rte_free(txq->rs_last_id);
+err_rs_last_id_alloc:
+	rte_free(txq->sw_ring);
 err_sw_ring_alloc:
 	cpfl_dma_zone_release(mz);
 err_mz_reserve:
drivers/net/intel/i40e/i40e_rxtx.c +20 -0
index 49ec4dd8a1..4fcc5c2f54 100644
@@ -24,6 +24,7 @@
 #include <rte_ip.h>
 #include <rte_net.h>
 #include <rte_vect.h>
+#include <rte_bitops.h>
 
 #include "i40e_logs.h"
 #include "base/i40e_prototype.h"
@@ -2280,6 +2281,13 @@ i40e_dev_tx_queue_setup(struct rte_eth_dev *dev,
 			     (int)queue_idx);
 		return I40E_ERR_PARAM;
 	}
+	if (!rte_is_power_of_2(tx_rs_thresh)) {
+		PMD_INIT_LOG(ERR, "tx_rs_thresh must be a power of 2. (tx_rs_thresh=%u port=%d queue=%d)",
+			     (unsigned int)tx_rs_thresh,
+			     (int)dev->data->port_id,
+			     (int)queue_idx);
+		return I40E_ERR_PARAM;
+	}
 	if ((tx_rs_thresh > 1) && (tx_conf->tx_thresh.wthresh != 0)) {
 		PMD_INIT_LOG(ERR, "TX WTHRESH must be set to 0 if "
 			     "tx_rs_thresh is greater than 1. "
@@ -2321,6 +2329,7 @@ i40e_dev_tx_queue_setup(struct rte_eth_dev *dev,
 	txq->mz = tz;
 	txq->nb_tx_desc = nb_desc;
 	txq->tx_rs_thresh = tx_rs_thresh;
+	txq->log2_rs_thresh = rte_log2_u32(tx_rs_thresh);
 	txq->tx_free_thresh = tx_free_thresh;
 	txq->queue_id = queue_idx;
 	txq->reg_idx = reg_idx;
@@ -2346,6 +2355,16 @@ i40e_dev_tx_queue_setup(struct rte_eth_dev *dev,
 		return -ENOMEM;
 	}
 
+	/* Allocate RS last_id tracking array */
+	uint16_t num_rs_buckets = nb_desc / tx_rs_thresh;
+	txq->rs_last_id = rte_zmalloc_socket(NULL, sizeof(txq->rs_last_id[0]) * num_rs_buckets,
+			RTE_CACHE_LINE_SIZE, socket_id);
+	if (txq->rs_last_id == NULL) {
+		i40e_tx_queue_release(txq);
+		PMD_DRV_LOG(ERR, "Failed to allocate memory for RS last_id array");
+		return -ENOMEM;
+	}
+
 	i40e_reset_tx_queue(txq);
 	txq->q_set = TRUE;
 
@@ -2391,6 +2410,7 @@ i40e_tx_queue_release(void *txq)
 
 	ci_txq_release_all_mbufs(q, false);
 	rte_free(q->sw_ring);
+	rte_free(q->rs_last_id);
 	rte_memzone_free(q->mz);
 	rte_free(q);
 }
drivers/net/intel/iavf/iavf_rxtx.c +19 -0
index 2ea00e1975..e7187f713d 100644
@@ -25,6 +25,7 @@
 #include <rte_ip.h>
 #include <rte_net.h>
 #include <rte_vect.h>
+#include <rte_bitops.h>
 #include <rte_vxlan.h>
 #include <rte_gtp.h>
 #include <rte_geneve.h>
@@ -194,6 +195,11 @@ check_tx_thresh(uint16_t nb_desc, uint16_t tx_rs_thresh,
 			     tx_rs_thresh, nb_desc);
 		return -EINVAL;
 	}
+	if (!rte_is_power_of_2(tx_rs_thresh)) {
+		PMD_INIT_LOG(ERR, "tx_rs_thresh must be a power of 2. (tx_rs_thresh=%u)",
+			     tx_rs_thresh);
+		return -EINVAL;
+	}
 
 	return 0;
 }
@@ -801,6 +807,7 @@ iavf_dev_tx_queue_setup(struct rte_eth_dev *dev,
 
 	txq->nb_tx_desc = nb_desc;
 	txq->tx_rs_thresh = tx_rs_thresh;
+	txq->log2_rs_thresh = rte_log2_u32(tx_rs_thresh);
 	txq->tx_free_thresh = tx_free_thresh;
 	txq->queue_id = queue_idx;
 	txq->port_id = dev->data->port_id;
@@ -826,6 +833,17 @@ iavf_dev_tx_queue_setup(struct rte_eth_dev *dev,
 		return -ENOMEM;
 	}
 
+	/* Allocate RS last_id tracking array */
+	uint16_t num_rs_buckets = nb_desc / tx_rs_thresh;
+	txq->rs_last_id = rte_zmalloc_socket(NULL, sizeof(txq->rs_last_id[0]) * num_rs_buckets,
+			RTE_CACHE_LINE_SIZE, socket_id);
+	if (txq->rs_last_id == NULL) {
+		PMD_INIT_LOG(ERR, "Failed to allocate memory for RS last_id array");
+		rte_free(txq->sw_ring);
+		rte_free(txq);
+		return -ENOMEM;
+	}
+
 	/* Allocate TX hardware ring descriptors. */
 	ring_size = sizeof(struct ci_tx_desc) * IAVF_MAX_RING_DESC;
 	ring_size = RTE_ALIGN(ring_size, IAVF_DMA_MEM_ALIGN);
@@ -1050,6 +1068,7 @@ iavf_dev_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid)
 
 	ci_txq_release_all_mbufs(q, q->use_ctx);
 	rte_free(q->sw_ring);
+	rte_free(q->rs_last_id);
 	rte_memzone_free(q->mz);
 	rte_free(q);
 }
drivers/net/intel/ice/ice_rxtx.c +20 -0
index 79b021a58f..32cb938c84 100644
@@ -5,6 +5,7 @@
 #include <ethdev_driver.h>
 #include <rte_net.h>
 #include <rte_vect.h>
+#include <rte_bitops.h>
 
 #include "ice_rxtx.h"
 #include "ice_rxtx_vec_common.h"
@@ -1589,6 +1590,13 @@ ice_tx_queue_setup(struct rte_eth_dev *dev,
 			     (int)queue_idx);
 		return -EINVAL;
 	}
+	if (!rte_is_power_of_2(tx_rs_thresh)) {
+		PMD_INIT_LOG(ERR, "tx_rs_thresh must be a power of 2. (tx_rs_thresh=%u port=%d queue=%d)",
+			     (unsigned int)tx_rs_thresh,
+			     (int)dev->data->port_id,
+			     (int)queue_idx);
+		return -EINVAL;
+	}
 	if (tx_rs_thresh > 1 && tx_conf->tx_thresh.wthresh != 0) {
 		PMD_INIT_LOG(ERR, "TX WTHRESH must be set to 0 if "
 			     "tx_rs_thresh is greater than 1. "
@@ -1631,6 +1639,7 @@ ice_tx_queue_setup(struct rte_eth_dev *dev,
 	txq->mz = tz;
 	txq->nb_tx_desc = nb_desc;
 	txq->tx_rs_thresh = tx_rs_thresh;
+	txq->log2_rs_thresh = rte_log2_u32(tx_rs_thresh);
 	txq->tx_free_thresh = tx_free_thresh;
 	txq->queue_id = queue_idx;
 
@@ -1657,6 +1666,16 @@ ice_tx_queue_setup(struct rte_eth_dev *dev,
 		return -ENOMEM;
 	}
 
+	/* Allocate RS last_id tracking array */
+	uint16_t num_rs_buckets = nb_desc / tx_rs_thresh;
+	txq->rs_last_id = rte_zmalloc_socket(NULL, sizeof(txq->rs_last_id[0]) * num_rs_buckets,
+			RTE_CACHE_LINE_SIZE, socket_id);
+	if (txq->rs_last_id == NULL) {
+		ice_tx_queue_release(txq);
+		PMD_INIT_LOG(ERR, "Failed to allocate memory for RS last_id array");
+		return -ENOMEM;
+	}
+
 	if (vsi->type == ICE_VSI_PF && (offloads & RTE_ETH_TX_OFFLOAD_SEND_ON_TIMESTAMP)) {
 		if (hw->phy_model != ICE_PHY_E830) {
 			ice_tx_queue_release(txq);
@@ -1729,6 +1748,7 @@ ice_tx_queue_release(void *txq)
 
 	ci_txq_release_all_mbufs(q, false);
 	rte_free(q->sw_ring);
+	rte_free(q->rs_last_id);
 	if (q->tsq) {
 		rte_memzone_free(q->tsq->ts_mz);
 		rte_free(q->tsq);
drivers/net/intel/idpf/idpf_common_rxtx.c +7 -0
index bca5f13c8e..8859bcca86 100644
@@ -5,6 +5,7 @@
 #include <eal_export.h>
 #include <rte_mbuf_dyn.h>
 #include <rte_errno.h>
+#include <rte_bitops.h>
 
 #include "idpf_common_rxtx.h"
 #include "idpf_common_device.h"
@@ -73,6 +74,11 @@ idpf_qc_tx_thresh_check(uint16_t nb_desc, uint16_t tx_rs_thresh,
 			tx_rs_thresh, nb_desc);
 		return -EINVAL;
 	}
+	if (!rte_is_power_of_2(tx_rs_thresh)) {
+		DRV_LOG(ERR, "tx_rs_thresh must be a power of 2. (tx_rs_thresh=%u)",
+			tx_rs_thresh);
+		return -EINVAL;
+	}
 
 	return 0;
 }
@@ -333,6 +339,7 @@ idpf_qc_tx_queue_release(void *txq)
 	}
 
 	ci_txq_release_all_mbufs(q, false);
+	rte_free(q->rs_last_id);
 	rte_free(q->sw_ring);
 	rte_memzone_free(q->mz);
 	rte_free(q);
drivers/net/intel/idpf/idpf_rxtx.c +13 -0
index 0de54d9305..9420200f6d 100644
@@ -447,6 +447,7 @@ idpf_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 
 	txq->nb_tx_desc = nb_desc;
 	txq->tx_rs_thresh = tx_rs_thresh;
+	txq->log2_rs_thresh = rte_log2_u32(tx_rs_thresh);
 	txq->tx_free_thresh = tx_free_thresh;
 	txq->queue_id = vport->chunks_info.tx_start_qid + queue_idx;
 	txq->port_id = dev->data->port_id;
@@ -480,6 +481,15 @@ idpf_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 		goto err_sw_ring_alloc;
 	}
 
+	txq->rs_last_id = rte_zmalloc_socket("idpf tx rs_last_id",
+			sizeof(txq->rs_last_id[0]) * (nb_desc >> txq->log2_rs_thresh),
+			RTE_CACHE_LINE_SIZE, socket_id);
+	if (txq->rs_last_id == NULL) {
+		PMD_INIT_LOG(ERR, "Failed to allocate memory for TX RS tracking");
+		ret = -ENOMEM;
+		goto err_rs_last_id_alloc;
+	}
+
 	if (!is_splitq) {
 		txq->ci_tx_ring = mz->addr;
 		idpf_qc_single_tx_queue_reset(txq);
@@ -502,6 +512,9 @@ idpf_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 	return 0;
 
 err_complq_setup:
+	rte_free(txq->rs_last_id);
+err_rs_last_id_alloc:
+	rte_free(txq->sw_ring);
 err_sw_ring_alloc:
 	idpf_dma_zone_release(mz);
 err_mz_reserve:
Signature · 1 line
2.51.0
#118 lore raw

PATCH v3 26/36 net/ixgbe: use separate array for desc status tracking

In reply to Bruce Richardson

Due to significant differences in the ixgbe transmit descriptors, the ixgbe driver does not use the common scalar Tx functionality. Update the driver directly so its use of the rs_last_id array matches that of the common Tx code.

---
 drivers/net/intel/ixgbe/ixgbe_rxtx.c | 86 +++++++++++++++-------------
 1 file changed, 47 insertions(+), 39 deletions(-)
drivers/net/intel/ixgbe/ixgbe_rxtx.c +47 -39
index 0af04c9b0d..3e37ccc50d 100644
@@ -43,6 +43,7 @@
 #include <rte_ip.h>
 #include <rte_net.h>
 #include <rte_vect.h>
+#include <rte_bitops.h>
 
 #include "ixgbe_logs.h"
 #include "base/ixgbe_api.h"
@@ -571,57 +572,35 @@ tx_desc_ol_flags_to_cmdtype(uint64_t ol_flags)
 static inline int
 ixgbe_xmit_cleanup(struct ci_tx_queue *txq)
 {
-	struct ci_tx_entry *sw_ring = txq->sw_ring;
 	volatile union ixgbe_adv_tx_desc *txr = txq->ixgbe_tx_ring;
-	uint16_t last_desc_cleaned = txq->last_desc_cleaned;
-	uint16_t nb_tx_desc = txq->nb_tx_desc;
-	uint16_t desc_to_clean_to;
-	uint16_t nb_tx_to_clean;
-	uint32_t status;
+	const uint16_t last_desc_cleaned = txq->last_desc_cleaned;
+	const uint16_t nb_tx_desc = txq->nb_tx_desc;
 
-	/* Determine the last descriptor needing to be cleaned */
-	desc_to_clean_to = (uint16_t)(last_desc_cleaned + txq->tx_rs_thresh);
-	if (desc_to_clean_to >= nb_tx_desc)
-		desc_to_clean_to = (uint16_t)(desc_to_clean_to - nb_tx_desc);
+	const uint16_t rs_idx = (last_desc_cleaned == nb_tx_desc - 1) ?
+			0 :
+			(last_desc_cleaned + 1) >> txq->log2_rs_thresh;
+	uint16_t desc_to_clean_to = (rs_idx << txq->log2_rs_thresh) + (txq->tx_rs_thresh - 1);
 
-	/* Check to make sure the last descriptor to clean is done */
-	desc_to_clean_to = sw_ring[desc_to_clean_to].last_id;
-	status = txr[desc_to_clean_to].wb.status;
+	uint32_t status = txr[txq->rs_last_id[rs_idx]].wb.status;
 	if (!(status & rte_cpu_to_le_32(IXGBE_TXD_STAT_DD))) {
 		PMD_TX_LOG(DEBUG,
 			   "TX descriptor %4u is not done"
 			   "(port=%d queue=%d)",
-			   desc_to_clean_to,
+			   txq->rs_last_id[rs_idx],
 			   txq->port_id, txq->queue_id);
 		/* Failed to clean any descriptors, better luck next time */
 		return -(1);
 	}
 
-	/* Figure out how many descriptors will be cleaned */
-	if (last_desc_cleaned > desc_to_clean_to)
-		nb_tx_to_clean = (uint16_t)((nb_tx_desc - last_desc_cleaned) +
-							desc_to_clean_to);
-	else
-		nb_tx_to_clean = (uint16_t)(desc_to_clean_to -
-						last_desc_cleaned);
-
 	PMD_TX_LOG(DEBUG,
 		   "Cleaning %4u TX descriptors: %4u to %4u "
 		   "(port=%d queue=%d)",
-		   nb_tx_to_clean, last_desc_cleaned, desc_to_clean_to,
+		   txq->tx_rs_thresh, last_desc_cleaned, desc_to_clean_to,
 		   txq->port_id, txq->queue_id);
 
-	/*
-	 * The last descriptor to clean is done, so that means all the
-	 * descriptors from the last descriptor that was cleaned
-	 * up to the last descriptor with the RS bit set
-	 * are done. Only reset the threshold descriptor.
-	 */
-	txr[desc_to_clean_to].wb.status = 0;
-
 	/* Update the txq to reflect the last descriptor that was cleaned */
 	txq->last_desc_cleaned = desc_to_clean_to;
-	txq->nb_tx_free = (uint16_t)(txq->nb_tx_free + nb_tx_to_clean);
+	txq->nb_tx_free = (uint16_t)(txq->nb_tx_free + txq->tx_rs_thresh);
 
 	/* No Error */
 	return 0;
@@ -749,6 +728,9 @@ ixgbe_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 		if (tx_last >= txq->nb_tx_desc)
 			tx_last = (uint16_t) (tx_last - txq->nb_tx_desc);
 
+		/* Track the RS threshold bucket at packet start */
+		uint16_t pkt_rs_idx = (uint16_t)(tx_id >> txq->log2_rs_thresh);
+
 		PMD_TX_LOG(DEBUG, "port_id=%u queue_id=%u pktlen=%u"
 			   " tx_first=%u tx_last=%u",
 			   (unsigned) txq->port_id,
@@ -876,7 +858,6 @@ ixgbe_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 					tx_offload,
 					rte_security_dynfield(tx_pkt));
 
-				txe->last_id = tx_last;
 				tx_id = txe->next_id;
 				txe = txn;
 			}
@@ -922,7 +903,6 @@ ixgbe_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 				rte_cpu_to_le_32(cmd_type_len | slen);
 			txd->read.olinfo_status =
 				rte_cpu_to_le_32(olinfo_status);
-			txe->last_id = tx_last;
 			tx_id = txe->next_id;
 			txe = txn;
 			m_seg = m_seg->next;
@@ -935,8 +915,18 @@ ixgbe_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 		txq->nb_tx_used = (uint16_t)(txq->nb_tx_used + nb_used);
 		txq->nb_tx_free = (uint16_t)(txq->nb_tx_free - nb_used);
 
-		/* Set RS bit only on threshold packets' last descriptor */
-		if (txq->nb_tx_used >= txq->tx_rs_thresh) {
+		/*
+		 * Check if packet crosses into a new RS threshold bucket.
+		 * The RS bit is set on the last descriptor when we move from one bucket to another.
+		 * For example, with tx_rs_thresh=32 and a 5-descriptor packet using slots 30-34:
+		 *   - pkt_rs_idx = 30 >> 5 = 0 (started in bucket 0)
+		 *   - tx_last = 34, so 35 >> 5 = 1 (next packet is in bucket 1)
+		 *   - Since 0 != 1, set RS bit on descriptor 34, and record rs_last_id[0] = 34
+		 */
+		uint16_t next_rs_idx = ((tx_last + 1) >> txq->log2_rs_thresh);
+
+		if (next_rs_idx != pkt_rs_idx) {
+			/* Packet crossed into a new bucket - set RS bit on last descriptor */
 			PMD_TX_LOG(DEBUG,
 				   "Setting RS bit on TXD id="
 				   "%4u (port=%d queue=%d)",
@@ -944,9 +934,8 @@ ixgbe_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 
 			cmd_type_len |= IXGBE_TXD_CMD_RS;
 
-			/* Update txq RS bit counters */
-			txq->nb_tx_used = 0;
-			txp = NULL;
+			/* Record the last descriptor ID for the bucket we're leaving */
+			txq->rs_last_id[pkt_rs_idx] = tx_last;
 		} else
 			txp = txd;
 
@@ -2521,6 +2510,7 @@ ixgbe_tx_queue_release(struct ci_tx_queue *txq)
 	if (txq != NULL && txq->ops != NULL) {
 		ci_txq_release_all_mbufs(txq, false);
 		txq->ops->free_swring(txq);
+		rte_free(txq->rs_last_id);
 		rte_memzone_free(txq->mz);
 		rte_free(txq);
 	}
@@ -2825,6 +2815,13 @@ ixgbe_dev_tx_queue_setup(struct rte_eth_dev *dev,
 			     (int)dev->data->port_id, (int)queue_idx);
 		return -(EINVAL);
 	}
+	if (!rte_is_power_of_2(tx_rs_thresh)) {
+		PMD_INIT_LOG(ERR, "tx_rs_thresh must be a power of 2. (tx_rs_thresh=%u port=%d queue=%d)",
+			     (unsigned int)tx_rs_thresh,
+			     (int)dev->data->port_id,
+			     (int)queue_idx);
+		return -(EINVAL);
+	}
 
 	/*
 	 * If rs_bit_thresh is greater than 1, then TX WTHRESH should be
@@ -2870,6 +2867,7 @@ ixgbe_dev_tx_queue_setup(struct rte_eth_dev *dev,
 	txq->mz = tz;
 	txq->nb_tx_desc = nb_desc;
 	txq->tx_rs_thresh = tx_rs_thresh;
+	txq->log2_rs_thresh = rte_log2_u32(tx_rs_thresh);
 	txq->tx_free_thresh = tx_free_thresh;
 	txq->pthresh = tx_conf->tx_thresh.pthresh;
 	txq->hthresh = tx_conf->tx_thresh.hthresh;
@@ -2913,6 +2911,16 @@ ixgbe_dev_tx_queue_setup(struct rte_eth_dev *dev,
 	PMD_INIT_LOG(DEBUG, "sw_ring=%p hw_ring=%p dma_addr=0x%"PRIx64,
 		     txq->sw_ring, txq->ixgbe_tx_ring, txq->tx_ring_dma);
 
+	/* Allocate RS last_id tracking array */
+	uint16_t num_rs_buckets = nb_desc / tx_rs_thresh;
+	txq->rs_last_id = rte_zmalloc_socket(NULL, sizeof(txq->rs_last_id[0]) * num_rs_buckets,
+			RTE_CACHE_LINE_SIZE, socket_id);
+	if (txq->rs_last_id == NULL) {
+		ixgbe_tx_queue_release(txq);
+		PMD_DRV_LOG(ERR, "Failed to allocate memory for RS last_id array");
+		return -ENOMEM;
+	}
+
 	/* set up vector or scalar TX function as appropriate */
 	ixgbe_set_tx_function(dev, txq);
 
Signature · 1 line
2.51.0
#119 lore raw

PATCH v3 27/36 net/intel: drop unused Tx queue used count

In reply to Bruce Richardson

Since drivers now track the setting of the RS bit based on fixed thresholds rather than after a fixed number of descriptors, we no longer need to track the number of descriptors used from one call to another. Therefore we can remove the tx_used value in the Tx queue structure.

This value was still being used inside the IDPF splitq scalar code, however, the ipdf driver-specific section of the Tx queue structure also had an rs_compl_count value that was only used for the vector code paths, so we can use it to replace the old tx_used value in the scalar path.

---
 drivers/net/intel/common/tx.h                   | 1 -
 drivers/net/intel/common/tx_scalar_fns.h        | 1 -
 drivers/net/intel/i40e/i40e_rxtx.c              | 1 -
 drivers/net/intel/iavf/iavf_rxtx.c              | 1 -
 drivers/net/intel/ice/ice_dcf_ethdev.c          | 1 -
 drivers/net/intel/ice/ice_rxtx.c                | 1 -
 drivers/net/intel/idpf/idpf_common_rxtx.c       | 8 +++-----
 drivers/net/intel/ixgbe/ixgbe_rxtx.c            | 8 --------
 drivers/net/intel/ixgbe/ixgbe_rxtx_vec_common.c | 1 -
 9 files changed, 3 insertions(+), 20 deletions(-)
drivers/net/intel/common/tx.h +0 -1
index a1372b145f..0d11fcc142 100644
@@ -131,7 +131,6 @@ struct ci_tx_queue {
 	uint16_t *rs_last_id;
 	uint16_t nb_tx_desc;           /* number of TX descriptors */
 	uint16_t tx_tail; /* current value of tail register */
-	uint16_t nb_tx_used; /* number of TX desc used since RS bit set */
 	/* index to last TX descriptor to have been cleaned */
 	uint16_t last_desc_cleaned;
 	/* Total number of TX descriptors ready to be allocated. */
drivers/net/intel/common/tx_scalar_fns.h +0 -1
index f0f89e5e9e..f82331101a 100644
@@ -405,7 +405,6 @@ ci_xmit_pkts(struct ci_tx_queue *txq,
 			m_seg = m_seg->next;
 		} while (m_seg);
 end_pkt:
-		txq->nb_tx_used = (uint16_t)(txq->nb_tx_used + nb_used);
 		txq->nb_tx_free = (uint16_t)(txq->nb_tx_free - nb_used);
 
 		/* Check if packet crosses into a new RS threshold bucket.
drivers/net/intel/i40e/i40e_rxtx.c +0 -1
index 4fcc5c2f54..33a0ae332a 100644
@@ -2645,7 +2645,6 @@ i40e_reset_tx_queue(struct ci_tx_queue *txq)
 	txq->tx_next_rs = (uint16_t)(txq->tx_rs_thresh - 1);
 
 	txq->tx_tail = 0;
-	txq->nb_tx_used = 0;
 
 	txq->last_desc_cleaned = (uint16_t)(txq->nb_tx_desc - 1);
 	txq->nb_tx_free = (uint16_t)(txq->nb_tx_desc - 1);
drivers/net/intel/iavf/iavf_rxtx.c +0 -1
index e7187f713d..3fcb8d7b79 100644
@@ -288,7 +288,6 @@ reset_tx_queue(struct ci_tx_queue *txq)
 	}
 
 	txq->tx_tail = 0;
-	txq->nb_tx_used = 0;
 
 	txq->last_desc_cleaned = txq->nb_tx_desc - 1;
 	txq->nb_tx_free = txq->nb_tx_desc - 1;
drivers/net/intel/ice/ice_dcf_ethdev.c +0 -1
index 4ceecc15c6..02a23629d6 100644
@@ -414,7 +414,6 @@ reset_tx_queue(struct ci_tx_queue *txq)
 	}
 
 	txq->tx_tail = 0;
-	txq->nb_tx_used = 0;
 
 	txq->last_desc_cleaned = txq->nb_tx_desc - 1;
 	txq->nb_tx_free = txq->nb_tx_desc - 1;
drivers/net/intel/ice/ice_rxtx.c +0 -1
index 32cb938c84..14c4683ad7 100644
@@ -1130,7 +1130,6 @@ ice_reset_tx_queue(struct ci_tx_queue *txq)
 	txq->tx_next_rs = (uint16_t)(txq->tx_rs_thresh - 1);
 
 	txq->tx_tail = 0;
-	txq->nb_tx_used = 0;
 
 	txq->last_desc_cleaned = (uint16_t)(txq->nb_tx_desc - 1);
 	txq->nb_tx_free = (uint16_t)(txq->nb_tx_desc - 1);
drivers/net/intel/idpf/idpf_common_rxtx.c +3 -5
index 8859bcca86..95f2e1deea 100644
@@ -224,7 +224,6 @@ idpf_qc_split_tx_descq_reset(struct ci_tx_queue *txq)
 	}
 
 	txq->tx_tail = 0;
-	txq->nb_tx_used = 0;
 
 	/* Use this as next to clean for split desc queue */
 	txq->last_desc_cleaned = 0;
@@ -284,7 +283,6 @@ idpf_qc_single_tx_queue_reset(struct ci_tx_queue *txq)
 	}
 
 	txq->tx_tail = 0;
-	txq->nb_tx_used = 0;
 
 	txq->last_desc_cleaned = txq->nb_tx_desc - 1;
 	txq->nb_tx_free = txq->nb_tx_desc - 1;
@@ -992,12 +990,12 @@ idpf_dp_splitq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 		txd->qw1.cmd_dtype |= IDPF_TXD_FLEX_FLOW_CMD_EOP;
 
 		txq->nb_tx_free = (uint16_t)(txq->nb_tx_free - nb_used);
-		txq->nb_tx_used = (uint16_t)(txq->nb_tx_used + nb_used);
+		txq->rs_compl_count += nb_used;
 
-		if (txq->nb_tx_used >= 32) {
+		if (txq->rs_compl_count >= 32) {
 			txd->qw1.cmd_dtype |= IDPF_TXD_FLEX_FLOW_CMD_RE;
 			/* Update txq RE bit counters */
-			txq->nb_tx_used = 0;
+			txq->rs_compl_count = 0;
 		}
 	}
 
drivers/net/intel/ixgbe/ixgbe_rxtx.c +0 -8
index 3e37ccc50d..ea609d926a 100644
@@ -708,12 +708,6 @@ ixgbe_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 		 */
 		nb_used = (uint16_t)(tx_pkt->nb_segs + new_ctx);
 
-		if (txp != NULL &&
-				nb_used + txq->nb_tx_used >= txq->tx_rs_thresh)
-			/* set RS on the previous packet in the burst */
-			txp->read.cmd_type_len |=
-				rte_cpu_to_le_32(IXGBE_TXD_CMD_RS);
-
 		/*
 		 * The number of descriptors that must be allocated for a
 		 * packet is the number of segments of that packet, plus 1
@@ -912,7 +906,6 @@ ixgbe_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 		 * The last packet data descriptor needs End Of Packet (EOP)
 		 */
 		cmd_type_len |= IXGBE_TXD_CMD_EOP;
-		txq->nb_tx_used = (uint16_t)(txq->nb_tx_used + nb_used);
 		txq->nb_tx_free = (uint16_t)(txq->nb_tx_free - nb_used);
 
 		/*
@@ -2551,7 +2544,6 @@ ixgbe_reset_tx_queue(struct ci_tx_queue *txq)
 	txq->tx_next_rs = (uint16_t)(txq->tx_rs_thresh - 1);
 
 	txq->tx_tail = 0;
-	txq->nb_tx_used = 0;
 	/*
 	 * Always allow 1 descriptor to be un-allocated to avoid
 	 * a H/W race condition
drivers/net/intel/ixgbe/ixgbe_rxtx_vec_common.c +0 -1
index eb7c79eaf9..63c7cb50d3 100644
@@ -47,7 +47,6 @@ ixgbe_reset_tx_queue_vec(struct ci_tx_queue *txq)
 	txq->tx_next_rs = (uint16_t)(txq->tx_rs_thresh - 1);
 
 	txq->tx_tail = 0;
-	txq->nb_tx_used = 0;
 	/*
 	 * Always allow 1 descriptor to be un-allocated to avoid
 	 * a H/W race condition
Signature · 1 line
2.51.0
#120 lore raw

PATCH v3 28/36 net/intel: remove index for tracking end of packet

In reply to Bruce Richardson

The last_id value in each tx_sw_queue entry was no longer used in the datapath, remove it and its initialization. For the function releasing packets back, rather than relying on "last_id" to identify end of packet, instead check for the next pointer being NULL.

---
 drivers/net/intel/common/tx.h             | 1 -
 drivers/net/intel/i40e/i40e_rxtx.c        | 8 +++-----
 drivers/net/intel/iavf/iavf_rxtx.c        | 9 ++++-----
 drivers/net/intel/ice/ice_dcf_ethdev.c    | 1 -
 drivers/net/intel/ice/ice_rxtx.c          | 9 ++++-----
 drivers/net/intel/idpf/idpf_common_rxtx.c | 2 --
 drivers/net/intel/ixgbe/ixgbe_rxtx.c      | 9 ++++-----
 7 files changed, 15 insertions(+), 24 deletions(-)
drivers/net/intel/common/tx.h +0 -1
index 0d11fcc142..16f8256304 100644
@@ -105,7 +105,6 @@ struct ci_tx_queue;
 struct ci_tx_entry {
 	struct rte_mbuf *mbuf; /* mbuf associated with TX desc, if any. */
 	uint16_t next_id; /* Index of next descriptor in ring. */
-	uint16_t last_id; /* Index of last scattered descriptor. */
 };
 
 /**
drivers/net/intel/i40e/i40e_rxtx.c +3 -5
index 33a0ae332a..792fb5a86a 100644
@@ -2536,14 +2536,13 @@ i40e_tx_done_cleanup_full(struct ci_tx_queue *txq,
 			pkt_cnt < free_cnt &&
 			tx_id != tx_last; i++) {
 			if (swr_ring[tx_id].mbuf != NULL) {
-				rte_pktmbuf_free_seg(swr_ring[tx_id].mbuf);
-				swr_ring[tx_id].mbuf = NULL;
-
 				/*
 				 * last segment in the packet,
 				 * increment packet count
 				 */
-				pkt_cnt += (swr_ring[tx_id].last_id == tx_id);
+				pkt_cnt += (swr_ring[tx_id].mbuf->next == NULL) ? 1 : 0;
+				rte_pktmbuf_free_seg(swr_ring[tx_id].mbuf);
+				swr_ring[tx_id].mbuf = NULL;
 			}
 
 			tx_id = swr_ring[tx_id].next_id;
@@ -2636,7 +2635,6 @@ i40e_reset_tx_queue(struct ci_tx_queue *txq)
 		txd->cmd_type_offset_bsz =
 			rte_cpu_to_le_64(CI_TX_DESC_DTYPE_DESC_DONE);
 		txe[i].mbuf =  NULL;
-		txe[i].last_id = i;
 		txe[prev].next_id = i;
 		prev = i;
 	}
drivers/net/intel/iavf/iavf_rxtx.c +4 -5
index 3fcb8d7b79..cb3b579d20 100644
@@ -282,7 +282,6 @@ reset_tx_queue(struct ci_tx_queue *txq)
 		txq->ci_tx_ring[i].cmd_type_offset_bsz =
 			rte_cpu_to_le_64(CI_TX_DESC_DTYPE_DESC_DONE);
 		txe[i].mbuf =  NULL;
-		txe[i].last_id = i;
 		txe[prev].next_id = i;
 		prev = i;
 	}
@@ -3960,14 +3959,14 @@ iavf_tx_done_cleanup_full(struct ci_tx_queue *txq,
 	while (pkt_cnt < free_cnt) {
 		do {
 			if (swr_ring[tx_id].mbuf != NULL) {
-				rte_pktmbuf_free_seg(swr_ring[tx_id].mbuf);
-				swr_ring[tx_id].mbuf = NULL;
-
 				/*
 				 * last segment in the packet,
 				 * increment packet count
 				 */
-				pkt_cnt += (swr_ring[tx_id].last_id == tx_id);
+				pkt_cnt += (swr_ring[tx_id].mbuf->next == NULL) ? 1 : 0;
+				rte_pktmbuf_free_seg(swr_ring[tx_id].mbuf);
+				swr_ring[tx_id].mbuf = NULL;
+
 			}
 
 			tx_id = swr_ring[tx_id].next_id;
drivers/net/intel/ice/ice_dcf_ethdev.c +0 -1
index 02a23629d6..abd7875e7b 100644
@@ -408,7 +408,6 @@ reset_tx_queue(struct ci_tx_queue *txq)
 		txq->ci_tx_ring[i].cmd_type_offset_bsz =
 			rte_cpu_to_le_64(CI_TX_DESC_DTYPE_DESC_DONE);
 		txe[i].mbuf =  NULL;
-		txe[i].last_id = i;
 		txe[prev].next_id = i;
 		prev = i;
 	}
drivers/net/intel/ice/ice_rxtx.c +4 -5
index 14c4683ad7..b79e195b5c 100644
@@ -1121,7 +1121,6 @@ ice_reset_tx_queue(struct ci_tx_queue *txq)
 		txd->cmd_type_offset_bsz =
 			rte_cpu_to_le_64(CI_TX_DESC_DTYPE_DESC_DONE);
 		txe[i].mbuf =  NULL;
-		txe[i].last_id = i;
 		txe[prev].next_id = i;
 		prev = i;
 	}
@@ -3201,14 +3200,14 @@ ice_tx_done_cleanup_full(struct ci_tx_queue *txq,
 			pkt_cnt < free_cnt &&
 			tx_id != tx_last; i++) {
 			if (swr_ring[tx_id].mbuf != NULL) {
-				rte_pktmbuf_free_seg(swr_ring[tx_id].mbuf);
-				swr_ring[tx_id].mbuf = NULL;
-
 				/*
 				 * last segment in the packet,
 				 * increment packet count
 				 */
-				pkt_cnt += (swr_ring[tx_id].last_id == tx_id);
+				pkt_cnt += swr_ring[tx_id].mbuf->next == NULL ? 1 : 0;
+				rte_pktmbuf_free_seg(swr_ring[tx_id].mbuf);
+				swr_ring[tx_id].mbuf = NULL;
+
 			}
 
 			tx_id = swr_ring[tx_id].next_id;
drivers/net/intel/idpf/idpf_common_rxtx.c +0 -2
index 95f2e1deea..bd77113551 100644
@@ -218,7 +218,6 @@ idpf_qc_split_tx_descq_reset(struct ci_tx_queue *txq)
 	prev = (uint16_t)(txq->sw_nb_desc - 1);
 	for (i = 0; i < txq->sw_nb_desc; i++) {
 		txe[i].mbuf = NULL;
-		txe[i].last_id = i;
 		txe[prev].next_id = i;
 		prev = i;
 	}
@@ -277,7 +276,6 @@ idpf_qc_single_tx_queue_reset(struct ci_tx_queue *txq)
 		txq->ci_tx_ring[i].cmd_type_offset_bsz =
 			rte_cpu_to_le_64(CI_TX_DESC_DTYPE_DESC_DONE);
 		txe[i].mbuf =  NULL;
-		txe[i].last_id = i;
 		txe[prev].next_id = i;
 		prev = i;
 	}
drivers/net/intel/ixgbe/ixgbe_rxtx.c +4 -5
index ea609d926a..dc9fda8e21 100644
@@ -2407,14 +2407,14 @@ ixgbe_tx_done_cleanup_full(struct ci_tx_queue *txq, uint32_t free_cnt)
 			pkt_cnt < free_cnt &&
 			tx_id != tx_last; i++) {
 			if (swr_ring[tx_id].mbuf != NULL) {
-				rte_pktmbuf_free_seg(swr_ring[tx_id].mbuf);
-				swr_ring[tx_id].mbuf = NULL;
-
 				/*
 				 * last segment in the packet,
 				 * increment packet count
 				 */
-				pkt_cnt += (swr_ring[tx_id].last_id == tx_id);
+				pkt_cnt += swr_ring[tx_id].mbuf->next == NULL ? 1 : 0;
+				rte_pktmbuf_free_seg(swr_ring[tx_id].mbuf);
+				swr_ring[tx_id].mbuf = NULL;
+
 			}
 
 			tx_id = swr_ring[tx_id].next_id;
@@ -2535,7 +2535,6 @@ ixgbe_reset_tx_queue(struct ci_tx_queue *txq)
 
 		txd->wb.status = rte_cpu_to_le_32(IXGBE_TXD_STAT_DD);
 		txe[i].mbuf = NULL;
-		txe[i].last_id = i;
 		txe[prev].next_id = i;
 		prev = i;
 	}
Signature · 1 line
2.51.0
#121 lore raw

PATCH v3 29/36 net/intel: merge ring writes in simple Tx for ice and i40e

In reply to Bruce Richardson

The ice and i40e drivers have identical code for writing ring entries in the simple Tx path, so merge in the descriptor writing code.

---
 drivers/net/intel/common/tx.h                 |  6 ++
 drivers/net/intel/common/tx_scalar_fns.h      | 60 ++++++++++++++
 drivers/net/intel/i40e/i40e_rxtx.c            | 79 +------------------
 drivers/net/intel/i40e/i40e_rxtx.h            |  3 -
 .../net/intel/i40e/i40e_rxtx_vec_altivec.c    |  4 +-
 drivers/net/intel/i40e/i40e_rxtx_vec_avx2.c   |  4 +-
 drivers/net/intel/i40e/i40e_rxtx_vec_avx512.c |  4 +-
 drivers/net/intel/i40e/i40e_rxtx_vec_neon.c   |  4 +-
 drivers/net/intel/ice/ice_rxtx.c              | 69 +---------------
 drivers/net/intel/ice/ice_rxtx.h              |  2 -
 drivers/net/intel/ice/ice_rxtx_vec_avx2.c     |  4 +-
 drivers/net/intel/ice/ice_rxtx_vec_avx512.c   |  4 +-
 12 files changed, 86 insertions(+), 157 deletions(-)
drivers/net/intel/common/tx.h +6 -0
index 16f8256304..0f545631af 100644
@@ -63,6 +63,12 @@ enum ci_tx_l2tag1_field {
 /* Common maximum data per TX descriptor */
 #define CI_MAX_DATA_PER_TXD     (CI_TXD_QW1_TX_BUF_SZ_M >> CI_TXD_QW1_TX_BUF_SZ_S)
 
+/* Common TX maximum burst size for chunked transmission in simple paths */
+#define CI_TX_MAX_BURST 32
+
+/* Common TX descriptor command flags for simple transmit */
+#define CI_TX_DESC_CMD_DEFAULT (CI_TX_DESC_CMD_ICRC | CI_TX_DESC_CMD_EOP)
+
 /* Checksum offload mask to identify packets requesting offload */
 #define CI_TX_CKSUM_OFFLOAD_MASK (RTE_MBUF_F_TX_IP_CKSUM |		 \
 				   RTE_MBUF_F_TX_L4_MASK |		 \
drivers/net/intel/common/tx_scalar_fns.h +60 -0

66 lines not on this page · raw message

drivers/net/intel/i40e/i40e_rxtx.c +4 -75

114 lines not on this page · raw message

drivers/net/intel/i40e/i40e_rxtx.h +0 -3
index 307ffa3049..0977342064 100644
@@ -47,9 +47,6 @@
 #define I40E_RX_DESC_EXT_STATUS_FLEXBL_MASK   0x03
 #define I40E_RX_DESC_EXT_STATUS_FLEXBL_FLEX   0x01
 
-#define I40E_TD_CMD (CI_TX_DESC_CMD_ICRC |\
-		     CI_TX_DESC_CMD_EOP)
-
 enum i40e_header_split_mode {
 	i40e_header_split_none = 0,
 	i40e_header_split_enabled = 1,
drivers/net/intel/i40e/i40e_rxtx_vec_altivec.c +2 -2
index 4c36748d94..68667bdc9b 100644
@@ -476,8 +476,8 @@ i40e_xmit_fixed_burst_vec(void *tx_queue, struct rte_mbuf **tx_pkts,
 	volatile struct ci_tx_desc *txdp;
 	struct ci_tx_entry_vec *txep;
 	uint16_t n, nb_commit, tx_id;
-	uint64_t flags = I40E_TD_CMD;
-	uint64_t rs = CI_TX_DESC_CMD_RS | I40E_TD_CMD;
+	uint64_t flags = CI_TX_DESC_CMD_DEFAULT;
+	uint64_t rs = CI_TX_DESC_CMD_RS | CI_TX_DESC_CMD_DEFAULT;
 	int i;
 
 	if (txq->nb_tx_free < txq->tx_free_thresh)
drivers/net/intel/i40e/i40e_rxtx_vec_avx2.c +2 -2
index 502a1842c6..e1672c4371 100644
@@ -741,8 +741,8 @@ i40e_xmit_fixed_burst_vec_avx2(void *tx_queue, struct rte_mbuf **tx_pkts,
 	volatile struct ci_tx_desc *txdp;
 	struct ci_tx_entry_vec *txep;
 	uint16_t n, nb_commit, tx_id;
-	uint64_t flags = I40E_TD_CMD;
-	uint64_t rs = CI_TX_DESC_CMD_RS | I40E_TD_CMD;
+	uint64_t flags = CI_TX_DESC_CMD_DEFAULT;
+	uint64_t rs = CI_TX_DESC_CMD_RS | CI_TX_DESC_CMD_DEFAULT;
 
 	if (txq->nb_tx_free < txq->tx_free_thresh)
 		ci_tx_free_bufs_vec(txq, i40e_tx_desc_done, false);
drivers/net/intel/i40e/i40e_rxtx_vec_avx512.c +2 -2
index d48ff9f51e..bceb95ad2d 100644
@@ -801,8 +801,8 @@ i40e_xmit_fixed_burst_vec_avx512(void *tx_queue, struct rte_mbuf **tx_pkts,
 	volatile struct ci_tx_desc *txdp;
 	struct ci_tx_entry_vec *txep;
 	uint16_t n, nb_commit, tx_id;
-	uint64_t flags = I40E_TD_CMD;
-	uint64_t rs = CI_TX_DESC_CMD_RS | I40E_TD_CMD;
+	uint64_t flags = CI_TX_DESC_CMD_DEFAULT;
+	uint64_t rs = CI_TX_DESC_CMD_RS | CI_TX_DESC_CMD_DEFAULT;
 
 	if (txq->nb_tx_free < txq->tx_free_thresh)
 		ci_tx_free_bufs_vec(txq, i40e_tx_desc_done, false);
drivers/net/intel/i40e/i40e_rxtx_vec_neon.c +2 -2
index be4c64942e..debc9bda28 100644
@@ -626,8 +626,8 @@ i40e_xmit_fixed_burst_vec(void *__rte_restrict tx_queue,
 	volatile struct ci_tx_desc *txdp;
 	struct ci_tx_entry_vec *txep;
 	uint16_t n, nb_commit, tx_id;
-	uint64_t flags = I40E_TD_CMD;
-	uint64_t rs = CI_TX_DESC_CMD_RS | I40E_TD_CMD;
+	uint64_t flags = CI_TX_DESC_CMD_DEFAULT;
+	uint64_t rs = CI_TX_DESC_CMD_RS | CI_TX_DESC_CMD_DEFAULT;
 	int i;
 
 	if (txq->nb_tx_free < txq->tx_free_thresh)
drivers/net/intel/ice/ice_rxtx.c +4 -65

98 lines not on this page · raw message

drivers/net/intel/ice/ice_rxtx.h +0 -2
index cd5fa93d1c..ddcd012e8b 100644
@@ -46,8 +46,6 @@
 
 #define ICE_SUPPORT_CHAIN_NUM 5
 
-#define ICE_TD_CMD                      CI_TX_DESC_CMD_EOP
-
 #define ICE_VPMD_RX_BURST            CI_VPMD_RX_BURST
 #define ICE_VPMD_TX_BURST            32
 #define ICE_VPMD_RXQ_REARM_THRESH    CI_VPMD_RX_REARM_THRESH
drivers/net/intel/ice/ice_rxtx_vec_avx2.c +2 -2
index 2922671158..d03f2e5b36 100644
@@ -845,8 +845,8 @@ ice_xmit_fixed_burst_vec_avx2(void *tx_queue, struct rte_mbuf **tx_pkts,
 	volatile struct ci_tx_desc *txdp;
 	struct ci_tx_entry_vec *txep;
 	uint16_t n, nb_commit, tx_id;
-	uint64_t flags = ICE_TD_CMD;
-	uint64_t rs = CI_TX_DESC_CMD_RS | ICE_TD_CMD;
+	uint64_t flags = CI_TX_DESC_CMD_DEFAULT;
+	uint64_t rs = CI_TX_DESC_CMD_RS | CI_TX_DESC_CMD_DEFAULT;
 
 	/* cross rx_thresh boundary is not allowed */
 	nb_pkts = RTE_MIN(nb_pkts, txq->tx_rs_thresh);
drivers/net/intel/ice/ice_rxtx_vec_avx512.c +2 -2
index e64b6e227b..004c01054a 100644
@@ -909,8 +909,8 @@ ice_xmit_fixed_burst_vec_avx512(void *tx_queue, struct rte_mbuf **tx_pkts,
 	volatile struct ci_tx_desc *txdp;
 	struct ci_tx_entry_vec *txep;
 	uint16_t n, nb_commit, tx_id;
-	uint64_t flags = ICE_TD_CMD;
-	uint64_t rs = CI_TX_DESC_CMD_RS | ICE_TD_CMD;
+	uint64_t flags = CI_TX_DESC_CMD_DEFAULT;
+	uint64_t rs = CI_TX_DESC_CMD_RS | CI_TX_DESC_CMD_DEFAULT;
 
 	/* cross rx_thresh boundary is not allowed */
 	nb_pkts = RTE_MIN(nb_pkts, txq->tx_rs_thresh);
Signature · 1 line
2.51.0
#122 lore raw

PATCH v3 30/36 net/intel: consolidate ice and i40e buffer free function

In reply to Bruce Richardson

The buffer freeing function for the simple scalar Tx path is almost identical in both ice and i40e drivers, except that the i40e has batching for the FAST_FREE case. Consolidate both functions into a common one based off the better i40e version.

---
 drivers/net/intel/common/tx.h            |  3 ++
 drivers/net/intel/common/tx_scalar_fns.h | 58 ++++++++++++++++++++++
 drivers/net/intel/i40e/i40e_rxtx.c       | 63 +-----------------------
 drivers/net/intel/ice/ice_rxtx.c         | 45 +----------------
 4 files changed, 65 insertions(+), 104 deletions(-)
drivers/net/intel/common/tx.h +3 -0
index 0f545631af..3c388857a7 100644
@@ -66,6 +66,9 @@ enum ci_tx_l2tag1_field {
 /* Common TX maximum burst size for chunked transmission in simple paths */
 #define CI_TX_MAX_BURST 32
 
+/* Common TX maximum free buffer size for batched bulk freeing */
+#define CI_TX_MAX_FREE_BUF_SZ 64
+
 /* Common TX descriptor command flags for simple transmit */
 #define CI_TX_DESC_CMD_DEFAULT (CI_TX_DESC_CMD_ICRC | CI_TX_DESC_CMD_EOP)
 
drivers/net/intel/common/tx_scalar_fns.h +58 -0

64 lines not on this page · raw message

drivers/net/intel/i40e/i40e_rxtx.c +2 -61

81 lines not on this page · raw message

drivers/net/intel/ice/ice_rxtx.c +2 -43

63 lines not on this page · raw message

Signature · 1 line
2.51.0
#123 lore raw

PATCH v3 31/36 net/intel: complete merging simple Tx paths

In reply to Bruce Richardson

Complete the deduplication/merger of the ice and i40e Tx simple scalar paths.

---
 drivers/net/intel/common/tx_scalar_fns.h | 87 ++++++++++++++++++++++++
 drivers/net/intel/i40e/i40e_rxtx.c       | 74 +-------------------
 drivers/net/intel/ice/ice_rxtx.c         | 74 +-------------------
 3 files changed, 89 insertions(+), 146 deletions(-)
drivers/net/intel/common/tx_scalar_fns.h +87 -0
index 185fcdfa72..5c4f09c197 100644
@@ -130,6 +130,93 @@ ci_tx_free_bufs(struct ci_tx_queue *txq)
 	return rs_thresh;
 }
 
+/* Simple burst transmit for descriptor-based simple Tx path
+ *
+ * Transmits a burst of packets by filling hardware descriptors with mbuf
+ * data. Handles ring wrap-around and RS bit management. Performs descriptor
+ * cleanup when tx_free_thresh is reached.
+ *
+ * Returns: number of packets transmitted
+ */
+static inline uint16_t
+ci_xmit_burst_simple(struct ci_tx_queue *txq,
+		     struct rte_mbuf **tx_pkts,
+		     uint16_t nb_pkts)
+{
+	volatile struct ci_tx_desc *txr = txq->ci_tx_ring;
+	uint16_t n = 0;
+
+	/**
+	 * Begin scanning the H/W ring for done descriptors when the number
+	 * of available descriptors drops below tx_free_thresh. For each done
+	 * descriptor, free the associated buffer.
+	 */
+	if (txq->nb_tx_free < txq->tx_free_thresh)
+		ci_tx_free_bufs(txq);
+
+	/* Use available descriptor only */
+	nb_pkts = (uint16_t)RTE_MIN(txq->nb_tx_free, nb_pkts);
+	if (unlikely(!nb_pkts))
+		return 0;
+
+	txq->nb_tx_free = (uint16_t)(txq->nb_tx_free - nb_pkts);
+	if ((txq->tx_tail + nb_pkts) > txq->nb_tx_desc) {
+		n = (uint16_t)(txq->nb_tx_desc - txq->tx_tail);
+		ci_tx_fill_hw_ring(txq, tx_pkts, n);
+		txr[txq->tx_next_rs].cmd_type_offset_bsz |=
+			rte_cpu_to_le_64(((uint64_t)CI_TX_DESC_CMD_RS) <<
+					  CI_TXD_QW1_CMD_S);
+		txq->tx_next_rs = (uint16_t)(txq->tx_rs_thresh - 1);
+		txq->tx_tail = 0;
+	}
+
+	/* Fill hardware descriptor ring with mbuf data */
+	ci_tx_fill_hw_ring(txq, tx_pkts + n, (uint16_t)(nb_pkts - n));
+	txq->tx_tail = (uint16_t)(txq->tx_tail + (nb_pkts - n));
+
+	/* Determine if RS bit needs to be set */
+	if (txq->tx_tail > txq->tx_next_rs) {
+		txr[txq->tx_next_rs].cmd_type_offset_bsz |=
+			rte_cpu_to_le_64(((uint64_t)CI_TX_DESC_CMD_RS) <<
+					  CI_TXD_QW1_CMD_S);
+		txq->tx_next_rs =
+			(uint16_t)(txq->tx_next_rs + txq->tx_rs_thresh);
+		if (txq->tx_next_rs >= txq->nb_tx_desc)
+			txq->tx_next_rs = (uint16_t)(txq->tx_rs_thresh - 1);
+	}
+
+	if (txq->tx_tail >= txq->nb_tx_desc)
+		txq->tx_tail = 0;
+
+	/* Update the tx tail register */
+	rte_write32_wc((uint32_t)txq->tx_tail, txq->qtx_tail);
+
+	return nb_pkts;
+}
+
+static __rte_always_inline uint16_t
+ci_xmit_pkts_simple(struct ci_tx_queue *txq,
+		     struct rte_mbuf **tx_pkts,
+		     uint16_t nb_pkts)
+{
+	uint16_t nb_tx = 0;
+
+	if (likely(nb_pkts <= CI_TX_MAX_BURST))
+		return ci_xmit_burst_simple(txq, tx_pkts, nb_pkts);
+
+	while (nb_pkts) {
+		uint16_t ret, num = RTE_MIN(nb_pkts, CI_TX_MAX_BURST);
+
+		ret = ci_xmit_burst_simple(txq, &tx_pkts[nb_tx], num);
+		nb_tx += ret;
+		nb_pkts -= ret;
+		if (ret < num)
+			break;
+	}
+
+	return nb_tx;
+}
+
 /*
  * Common transmit descriptor cleanup function for Intel drivers.
  * Used by ice, i40e, iavf, and idpf drivers.
drivers/net/intel/i40e/i40e_rxtx.c +1 -73

85 lines not on this page · raw message

drivers/net/intel/ice/ice_rxtx.c +1 -73

85 lines not on this page · raw message

Signature · 1 line
2.51.0
#124 lore raw

PATCH v3 32/36 net/intel: use non-volatile stores in simple Tx function

In reply to Bruce Richardson

The simple Tx code path can be reworked to use non-volatile stores - as is the case with the full-featured Tx path - by reusing the existing write_txd function (which just needs to be moved up in the header file). This gives a small performance boost.

---
 drivers/net/intel/common/tx_scalar_fns.h | 55 +++++++-----------------
 1 file changed, 16 insertions(+), 39 deletions(-)
drivers/net/intel/common/tx_scalar_fns.h +16 -39
index 5c4f09c197..579206f7ab 100644
@@ -12,35 +12,13 @@
 /* depends on common Tx definitions. */
 #include "tx.h"
 
-/* Populate 4 descriptors with data from 4 mbufs */
 static inline void
-ci_tx_fill_hw_ring_tx4(volatile struct ci_tx_desc *txdp, struct rte_mbuf **pkts)
+write_txd(volatile void *txd, uint64_t qw0, uint64_t qw1)
 {
-	uint64_t dma_addr;
-	uint32_t i;
-
-	for (i = 0; i < 4; i++, txdp++, pkts++) {
-		dma_addr = rte_mbuf_data_iova(*pkts);
-		txdp->buffer_addr = rte_cpu_to_le_64(dma_addr);
-		txdp->cmd_type_offset_bsz =
-			rte_cpu_to_le_64(CI_TX_DESC_DTYPE_DATA |
-				((uint64_t)CI_TX_DESC_CMD_DEFAULT << CI_TXD_QW1_CMD_S) |
-				((uint64_t)(*pkts)->data_len << CI_TXD_QW1_TX_BUF_SZ_S));
-	}
-}
+	uint64_t *txd_qw =  __rte_assume_aligned(RTE_CAST_PTR(void *, txd), 16);
 
-/* Populate 1 descriptor with data from 1 mbuf */
-static inline void
-ci_tx_fill_hw_ring_tx1(volatile struct ci_tx_desc *txdp, struct rte_mbuf **pkts)
-{
-	uint64_t dma_addr;
-
-	dma_addr = rte_mbuf_data_iova(*pkts);
-	txdp->buffer_addr = rte_cpu_to_le_64(dma_addr);
-	txdp->cmd_type_offset_bsz =
-		rte_cpu_to_le_64(CI_TX_DESC_DTYPE_DATA |
-			((uint64_t)CI_TX_DESC_CMD_DEFAULT << CI_TXD_QW1_CMD_S) |
-			((uint64_t)(*pkts)->data_len << CI_TXD_QW1_TX_BUF_SZ_S));
+	txd_qw[0] = rte_cpu_to_le_64(qw0);
+	txd_qw[1] = rte_cpu_to_le_64(qw1);
 }
 
 /* Fill hardware descriptor ring with mbuf data */
@@ -60,14 +38,22 @@ ci_tx_fill_hw_ring(struct ci_tx_queue *txq, struct rte_mbuf **pkts,
 	for (i = 0; i < mainpart; i += N_PER_LOOP) {
 		for (j = 0; j < N_PER_LOOP; ++j)
 			(txep + i + j)->mbuf = *(pkts + i + j);
-		ci_tx_fill_hw_ring_tx4(txdp + i, pkts + i);
+		for (j = 0; j < N_PER_LOOP; ++j)
+			write_txd(txdp + i + j, rte_mbuf_data_iova(*(pkts + i + j)),
+				CI_TX_DESC_DTYPE_DATA |
+				((uint64_t)CI_TX_DESC_CMD_DEFAULT << CI_TXD_QW1_CMD_S) |
+				((uint64_t)(*(pkts + i + j))->data_len << CI_TXD_QW1_TX_BUF_SZ_S));
 	}
 
 	if (unlikely(leftover > 0)) {
 		for (i = 0; i < leftover; ++i) {
-			(txep + mainpart + i)->mbuf = *(pkts + mainpart + i);
-			ci_tx_fill_hw_ring_tx1(txdp + mainpart + i,
-					       pkts + mainpart + i);
+			uint16_t idx = mainpart + i;
+			(txep + idx)->mbuf = *(pkts + idx);
+			write_txd(txdp + idx, rte_mbuf_data_iova(*(pkts + idx)),
+				CI_TX_DESC_DTYPE_DATA |
+				((uint64_t)CI_TX_DESC_CMD_DEFAULT << CI_TXD_QW1_CMD_S) |
+				((uint64_t)(*(pkts + idx))->data_len << CI_TXD_QW1_TX_BUF_SZ_S));
+
 		}
 	}
 }
@@ -365,15 +351,6 @@ struct ci_timesstamp_queue_fns {
 	write_ts_tail_t write_ts_tail;
 };
 
-static inline void
-write_txd(volatile void *txd, uint64_t qw0, uint64_t qw1)
-{
-	uint64_t *txd_qw = __rte_assume_aligned(RTE_CAST_PTR(void *, txd), 16);
-
-	txd_qw[0] = rte_cpu_to_le_64(qw0);
-	txd_qw[1] = rte_cpu_to_le_64(qw1);
-}
-
 static inline uint16_t
 ci_xmit_pkts(struct ci_tx_queue *txq,
 	     struct rte_mbuf **tx_pkts,
Signature · 1 line
2.51.0
#125 lore raw

PATCH v3 33/36 net/intel: align scalar simple Tx path with vector logic

In reply to Bruce Richardson

The scalar simple Tx path has the same restrictions as the vector Tx path, so we can use the same logic flow in both, to try and ensure we get best performance from the scalar path.

---
 drivers/net/intel/common/tx_scalar_fns.h | 54 +++++++++++++++---------
 1 file changed, 34 insertions(+), 20 deletions(-)
drivers/net/intel/common/tx_scalar_fns.h +34 -20
index 579206f7ab..3f02fc00d6 100644
@@ -21,13 +21,11 @@ write_txd(volatile void *txd, uint64_t qw0, uint64_t qw1)
 	txd_qw[1] = rte_cpu_to_le_64(qw1);
 }
 
-/* Fill hardware descriptor ring with mbuf data */
+/* Fill hardware descriptor ring with mbuf data (simple path) */
 static inline void
-ci_tx_fill_hw_ring(struct ci_tx_queue *txq, struct rte_mbuf **pkts,
-		   uint16_t nb_pkts)
+ci_tx_fill_hw_ring_simple(volatile struct ci_tx_desc *txdp, struct rte_mbuf **pkts,
+			  uint16_t nb_pkts)
 {
-	volatile struct ci_tx_desc *txdp = &txq->ci_tx_ring[txq->tx_tail];
-	struct ci_tx_entry *txep = &txq->sw_ring[txq->tx_tail];
 	const int N_PER_LOOP = 4;
 	const int N_PER_LOOP_MASK = N_PER_LOOP - 1;
 	int mainpart, leftover;
@@ -36,8 +34,6 @@ ci_tx_fill_hw_ring(struct ci_tx_queue *txq, struct rte_mbuf **pkts,
 	mainpart = nb_pkts & ((uint32_t)~N_PER_LOOP_MASK);
 	leftover = nb_pkts & ((uint32_t)N_PER_LOOP_MASK);
 	for (i = 0; i < mainpart; i += N_PER_LOOP) {
-		for (j = 0; j < N_PER_LOOP; ++j)
-			(txep + i + j)->mbuf = *(pkts + i + j);
 		for (j = 0; j < N_PER_LOOP; ++j)
 			write_txd(txdp + i + j, rte_mbuf_data_iova(*(pkts + i + j)),
 				CI_TX_DESC_DTYPE_DATA |
@@ -48,12 +44,10 @@ ci_tx_fill_hw_ring(struct ci_tx_queue *txq, struct rte_mbuf **pkts,
 	if (unlikely(leftover > 0)) {
 		for (i = 0; i < leftover; ++i) {
 			uint16_t idx = mainpart + i;
-			(txep + idx)->mbuf = *(pkts + idx);
 			write_txd(txdp + idx, rte_mbuf_data_iova(*(pkts + idx)),
 				CI_TX_DESC_DTYPE_DATA |
 				((uint64_t)CI_TX_DESC_CMD_DEFAULT << CI_TXD_QW1_CMD_S) |
 				((uint64_t)(*(pkts + idx))->data_len << CI_TXD_QW1_TX_BUF_SZ_S));
-
 		}
 	}
 }
@@ -130,6 +124,9 @@ ci_xmit_burst_simple(struct ci_tx_queue *txq,
 		     uint16_t nb_pkts)
 {
 	volatile struct ci_tx_desc *txr = txq->ci_tx_ring;
+	volatile struct ci_tx_desc *txdp;
+	struct ci_tx_entry *txep;
+	uint16_t tx_id;
 	uint16_t n = 0;
 
 	/**
@@ -145,23 +142,41 @@ ci_xmit_burst_simple(struct ci_tx_queue *txq,
 	if (unlikely(!nb_pkts))
 		return 0;
 
+	tx_id = txq->tx_tail;
+	txdp = &txr[tx_id];
+	txep = &txq->sw_ring[tx_id];
+
 	txq->nb_tx_free = (uint16_t)(txq->nb_tx_free - nb_pkts);
-	if ((txq->tx_tail + nb_pkts) > txq->nb_tx_desc) {
-		n = (uint16_t)(txq->nb_tx_desc - txq->tx_tail);
-		ci_tx_fill_hw_ring(txq, tx_pkts, n);
+
+	if ((tx_id + nb_pkts) > txq->nb_tx_desc) {
+		n = (uint16_t)(txq->nb_tx_desc - tx_id);
+
+		/* Store mbufs in backlog */
+		ci_tx_backlog_entry(txep, tx_pkts, n);
+
+		/* Write descriptors to HW ring */
+		ci_tx_fill_hw_ring_simple(txdp, tx_pkts, n);
+
 		txr[txq->tx_next_rs].cmd_type_offset_bsz |=
 			rte_cpu_to_le_64(((uint64_t)CI_TX_DESC_CMD_RS) <<
 					  CI_TXD_QW1_CMD_S);
 		txq->tx_next_rs = (uint16_t)(txq->tx_rs_thresh - 1);
-		txq->tx_tail = 0;
+
+		tx_id = 0;
+		txdp = &txr[tx_id];
+		txep = &txq->sw_ring[tx_id];
 	}
 
-	/* Fill hardware descriptor ring with mbuf data */
-	ci_tx_fill_hw_ring(txq, tx_pkts + n, (uint16_t)(nb_pkts - n));
-	txq->tx_tail = (uint16_t)(txq->tx_tail + (nb_pkts - n));
+	/* Store remaining mbufs in backlog */
+	ci_tx_backlog_entry(txep, tx_pkts + n, (uint16_t)(nb_pkts - n));
+
+	/* Write remaining descriptors to HW ring */
+	ci_tx_fill_hw_ring_simple(txdp, tx_pkts + n, (uint16_t)(nb_pkts - n));
+
+	tx_id = (uint16_t)(tx_id + (nb_pkts - n));
 
 	/* Determine if RS bit needs to be set */
-	if (txq->tx_tail > txq->tx_next_rs) {
+	if (tx_id > txq->tx_next_rs) {
 		txr[txq->tx_next_rs].cmd_type_offset_bsz |=
 			rte_cpu_to_le_64(((uint64_t)CI_TX_DESC_CMD_RS) <<
 					  CI_TXD_QW1_CMD_S);
@@ -171,11 +186,10 @@ ci_xmit_burst_simple(struct ci_tx_queue *txq,
 			txq->tx_next_rs = (uint16_t)(txq->tx_rs_thresh - 1);
 	}
 
-	if (txq->tx_tail >= txq->nb_tx_desc)
-		txq->tx_tail = 0;
+	txq->tx_tail = tx_id;
 
 	/* Update the tx tail register */
-	rte_write32_wc((uint32_t)txq->tx_tail, txq->qtx_tail);
+	rte_write32_wc((uint32_t)tx_id, txq->qtx_tail);
 
 	return nb_pkts;
 }
Signature · 1 line
2.51.0
#126 lore raw

PATCH v3 34/36 net/intel: use vector SW ring entry for simple path

In reply to Bruce Richardson

The simple scalar Tx path does not need to use the full sw_entry structure that the full Tx path uses, so rename the flag for "vector_tx" to instead be "use_vec_entry" since its sole purpose is to flag the use of the smaller tx_entry_vec structure. Then set this flag for the simple Tx path, giving us a perf boost.

---
 drivers/net/intel/common/tx.h                    |  6 ++++--
 drivers/net/intel/common/tx_scalar_fns.h         | 14 +++++++-------
 drivers/net/intel/cpfl/cpfl_rxtx.c               |  4 ++--
 drivers/net/intel/i40e/i40e_rxtx.c               |  2 +-
 drivers/net/intel/iavf/iavf_rxtx_vec_avx2.c      |  2 +-
 drivers/net/intel/ice/ice_rxtx.c                 |  2 +-
 drivers/net/intel/idpf/idpf_common_rxtx_avx512.c |  2 +-
 drivers/net/intel/ixgbe/ixgbe_rxtx_vec_common.c  |  2 +-
 8 files changed, 18 insertions(+), 16 deletions(-)
drivers/net/intel/common/tx.h +4 -2
index 3c388857a7..dc21a4c906 100644
@@ -166,7 +166,7 @@ struct ci_tx_queue {
 	rte_iova_t tx_ring_dma;        /* TX ring DMA address */
 	bool tx_deferred_start; /* don't start this queue in dev start */
 	bool q_set;             /* indicate if tx queue has been configured */
-	bool vector_tx;         /* port is using vector TX */
+	bool use_vec_entry;     /* use sw_ring_vec (true for vector and simple paths) */
 	union {                  /* the VSI this queue belongs to */
 		struct i40e_vsi *i40e_vsi;
 		struct iavf_vsi *iavf_vsi;
@@ -354,7 +354,8 @@ ci_txq_release_all_mbufs(struct ci_tx_queue *txq, bool use_ctx)
 	if (unlikely(!txq || !txq->sw_ring))
 		return;
 
-	if (!txq->vector_tx) {
+	if (!txq->use_vec_entry) {
+		/* Regular scalar path uses sw_ring with ci_tx_entry */
 		for (uint16_t i = 0; i < txq->nb_tx_desc; i++) {
 			if (txq->sw_ring[i].mbuf != NULL) {
 				rte_pktmbuf_free_seg(txq->sw_ring[i].mbuf);
@@ -365,6 +366,7 @@ ci_txq_release_all_mbufs(struct ci_tx_queue *txq, bool use_ctx)
 	}
 
 	/**
+	 *  Vector and simple paths use sw_ring_vec (ci_tx_entry_vec).
 	 *  vPMD tx will not set sw_ring's mbuf to NULL after free,
 	 *  so determining buffers to free is a little more complex.
 	 */
drivers/net/intel/common/tx_scalar_fns.h +7 -7
index 3f02fc00d6..c8d370a921 100644
@@ -60,14 +60,14 @@ ci_tx_free_bufs(struct ci_tx_queue *txq)
 	const uint16_t k = RTE_ALIGN_FLOOR(rs_thresh, CI_TX_MAX_FREE_BUF_SZ);
 	const uint16_t m = rs_thresh % CI_TX_MAX_FREE_BUF_SZ;
 	struct rte_mbuf *free[CI_TX_MAX_FREE_BUF_SZ];
-	struct ci_tx_entry *txep;
+	struct ci_tx_entry_vec *txep;
 
 	if ((txq->ci_tx_ring[txq->tx_next_dd].cmd_type_offset_bsz &
 			rte_cpu_to_le_64(CI_TXD_QW1_DTYPE_M)) !=
 			rte_cpu_to_le_64(CI_TX_DESC_DTYPE_DESC_DONE))
 		return 0;
 
-	txep = &txq->sw_ring[txq->tx_next_dd - (rs_thresh - 1)];
+	txep = &txq->sw_ring_vec[txq->tx_next_dd - (rs_thresh - 1)];
 
 	struct rte_mempool *fast_free_mp =
 			likely(txq->fast_free_mp != (void *)UINTPTR_MAX) ?
@@ -125,7 +125,7 @@ ci_xmit_burst_simple(struct ci_tx_queue *txq,
 {
 	volatile struct ci_tx_desc *txr = txq->ci_tx_ring;
 	volatile struct ci_tx_desc *txdp;
-	struct ci_tx_entry *txep;
+	struct ci_tx_entry_vec *txep;
 	uint16_t tx_id;
 	uint16_t n = 0;
 
@@ -144,7 +144,7 @@ ci_xmit_burst_simple(struct ci_tx_queue *txq,
 
 	tx_id = txq->tx_tail;
 	txdp = &txr[tx_id];
-	txep = &txq->sw_ring[tx_id];
+	txep = &txq->sw_ring_vec[tx_id];
 
 	txq->nb_tx_free = (uint16_t)(txq->nb_tx_free - nb_pkts);
 
@@ -152,7 +152,7 @@ ci_xmit_burst_simple(struct ci_tx_queue *txq,
 		n = (uint16_t)(txq->nb_tx_desc - tx_id);
 
 		/* Store mbufs in backlog */
-		ci_tx_backlog_entry(txep, tx_pkts, n);
+		ci_tx_backlog_entry_vec(txep, tx_pkts, n);
 
 		/* Write descriptors to HW ring */
 		ci_tx_fill_hw_ring_simple(txdp, tx_pkts, n);
@@ -164,11 +164,11 @@ ci_xmit_burst_simple(struct ci_tx_queue *txq,
 
 		tx_id = 0;
 		txdp = &txr[tx_id];
-		txep = &txq->sw_ring[tx_id];
+		txep = &txq->sw_ring_vec[tx_id];
 	}
 
 	/* Store remaining mbufs in backlog */
-	ci_tx_backlog_entry(txep, tx_pkts + n, (uint16_t)(nb_pkts - n));
+	ci_tx_backlog_entry_vec(txep, tx_pkts + n, (uint16_t)(nb_pkts - n));
 
 	/* Write remaining descriptors to HW ring */
 	ci_tx_fill_hw_ring_simple(txdp, tx_pkts + n, (uint16_t)(nb_pkts - n));
drivers/net/intel/cpfl/cpfl_rxtx.c +2 -2
index e7a98ed4f6..b5b9015310 100644
@@ -329,7 +329,7 @@ cpfl_tx_queue_release(void *txq)
 		rte_free(q->complq);
 	}
 
-	ci_txq_release_all_mbufs(q, q->vector_tx);
+	ci_txq_release_all_mbufs(q, q->use_vec_entry);
 	rte_free(q->sw_ring);
 	rte_free(q->rs_last_id);
 	rte_memzone_free(q->mz);
@@ -1364,7 +1364,7 @@ cpfl_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id)
 	}
 
 	txq = &cpfl_txq->base;
-	ci_txq_release_all_mbufs(txq, txq->vector_tx);
+	ci_txq_release_all_mbufs(txq, txq->use_vec_entry);
 	if (vport->txq_model == VIRTCHNL2_QUEUE_MODEL_SINGLE) {
 		idpf_qc_single_tx_queue_reset(txq);
 	} else {
drivers/net/intel/i40e/i40e_rxtx.c +1 -1
index b286e89b1b..ba63d42b85 100644
@@ -1451,7 +1451,7 @@ i40e_dev_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id)
 		PMD_DRV_LOG(WARNING, "TX queue %u is deferred start",
 			    tx_queue_id);
 
-	txq->vector_tx = ad->tx_vec_allowed;
+	txq->use_vec_entry = ad->tx_vec_allowed || ad->tx_simple_allowed;
 
 	/*
 	 * tx_queue_id is queue id application refers to, while
drivers/net/intel/iavf/iavf_rxtx_vec_avx2.c +1 -1
index cea4ee9863..374c713a94 100644
@@ -1803,7 +1803,7 @@ iavf_xmit_pkts_vec_avx2_offload(void *tx_queue, struct rte_mbuf **tx_pkts,
 int __rte_cold
 iavf_txq_vec_setup(struct ci_tx_queue *txq)
 {
-	txq->vector_tx = true;
+	txq->use_vec_entry = true;
 	return 0;
 }
 
drivers/net/intel/ice/ice_rxtx.c +1 -1
index eae57a08fc..94951369fb 100644
@@ -882,7 +882,7 @@ ice_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id)
 		}
 
 	/* record what kind of descriptor cleanup we need on teardown */
-	txq->vector_tx = ad->tx_vec_allowed;
+	txq->use_vec_entry = ad->tx_vec_allowed || ad->tx_simple_allowed;
 
 	if (txq->tsq != NULL && txq->tsq->ts_flag > 0) {
 		struct ice_aqc_set_txtime_qgrp *ts_elem;
drivers/net/intel/idpf/idpf_common_rxtx_avx512.c +1 -1
index 49ace35615..666ad1a4dd 100644
@@ -1365,6 +1365,6 @@ idpf_qc_tx_vec_avx512_setup(struct ci_tx_queue *txq)
 	if (!txq)
 		return 0;
 
-	txq->vector_tx = true;
+	txq->use_vec_entry = true;
 	return 0;
 }
drivers/net/intel/ixgbe/ixgbe_rxtx_vec_common.c +1 -1
index 63c7cb50d3..c42b8fc96b 100644
@@ -111,7 +111,7 @@ ixgbe_txq_vec_setup(struct ci_tx_queue *txq)
 	/* leave the first one for overflow */
 	txq->sw_ring_vec = txq->sw_ring_vec + 1;
 	txq->ops = &vec_txq_ops;
-	txq->vector_tx = 1;
+	txq->use_vec_entry = true;
 
 	return 0;
 }
Signature · 1 line
2.51.0
#127 lore raw

PATCH v3 35/36 net/intel: use vector mbuf cleanup from simple scalar path

In reply to Bruce Richardson

Since the simple scalar path now uses the vector Tx entry struct, we can leverage the vector mbuf cleanup function from that path and avoid having a separate cleanup function for it.

---
 drivers/net/intel/common/tx_scalar_fns.h | 74 +++++-------------------
 drivers/net/intel/i40e/i40e_rxtx.c       |  2 +-
 drivers/net/intel/ice/ice_rxtx.c         |  2 +-
 3 files changed, 17 insertions(+), 61 deletions(-)
drivers/net/intel/common/tx_scalar_fns.h +15 -59
index c8d370a921..27a07cf9e9 100644
@@ -21,6 +21,20 @@ write_txd(volatile void *txd, uint64_t qw0, uint64_t qw1)
 	txd_qw[1] = rte_cpu_to_le_64(qw1);
 }
 
+static __rte_always_inline int
+ci_tx_desc_done_simple(struct ci_tx_queue *txq, uint16_t idx)
+{
+	return (txq->ci_tx_ring[idx].cmd_type_offset_bsz & rte_cpu_to_le_64(CI_TXD_QW1_DTYPE_M)) ==
+			rte_cpu_to_le_64(CI_TX_DESC_DTYPE_DESC_DONE);
+}
+
+/* Free transmitted mbufs using vector-style cleanup */
+static __rte_always_inline int
+ci_tx_free_bufs_simple(struct ci_tx_queue *txq)
+{
+	return ci_tx_free_bufs_vec(txq, ci_tx_desc_done_simple, false);
+}
+
 /* Fill hardware descriptor ring with mbuf data (simple path) */
 static inline void
 ci_tx_fill_hw_ring_simple(volatile struct ci_tx_desc *txdp, struct rte_mbuf **pkts,
@@ -52,64 +66,6 @@ ci_tx_fill_hw_ring_simple(volatile struct ci_tx_desc *txdp, struct rte_mbuf **pk
 	}
 }
 
-/* Free transmitted mbufs from descriptor ring with bulk freeing for Tx simple path */
-static __rte_always_inline int
-ci_tx_free_bufs(struct ci_tx_queue *txq)
-{
-	const uint16_t rs_thresh = txq->tx_rs_thresh;
-	const uint16_t k = RTE_ALIGN_FLOOR(rs_thresh, CI_TX_MAX_FREE_BUF_SZ);
-	const uint16_t m = rs_thresh % CI_TX_MAX_FREE_BUF_SZ;
-	struct rte_mbuf *free[CI_TX_MAX_FREE_BUF_SZ];
-	struct ci_tx_entry_vec *txep;
-
-	if ((txq->ci_tx_ring[txq->tx_next_dd].cmd_type_offset_bsz &
-			rte_cpu_to_le_64(CI_TXD_QW1_DTYPE_M)) !=
-			rte_cpu_to_le_64(CI_TX_DESC_DTYPE_DESC_DONE))
-		return 0;
-
-	txep = &txq->sw_ring_vec[txq->tx_next_dd - (rs_thresh - 1)];
-
-	struct rte_mempool *fast_free_mp =
-			likely(txq->fast_free_mp != (void *)UINTPTR_MAX) ?
-				txq->fast_free_mp :
-				(txq->fast_free_mp = txep[0].mbuf->pool);
-
-	if (fast_free_mp) {
-		if (k) {
-			for (uint16_t j = 0; j != k; j += CI_TX_MAX_FREE_BUF_SZ) {
-				for (uint16_t i = 0; i < CI_TX_MAX_FREE_BUF_SZ; ++i, ++txep) {
-					free[i] = txep->mbuf;
-					txep->mbuf = NULL;
-				}
-				rte_mbuf_raw_free_bulk(fast_free_mp, free, CI_TX_MAX_FREE_BUF_SZ);
-			}
-		}
-
-		if (m) {
-			for (uint16_t i = 0; i < m; ++i, ++txep) {
-				free[i] = txep->mbuf;
-				txep->mbuf = NULL;
-			}
-			rte_mbuf_raw_free_bulk(fast_free_mp, free, m);
-		}
-	} else {
-		for (uint16_t i = 0; i < rs_thresh; ++i, ++txep)
-			rte_prefetch0((txep + i)->mbuf);
-
-		for (uint16_t i = 0; i < rs_thresh; ++i, ++txep) {
-			rte_pktmbuf_free_seg(txep->mbuf);
-			txep->mbuf = NULL;
-		}
-	}
-
-	txq->nb_tx_free = (uint16_t)(txq->nb_tx_free + rs_thresh);
-	txq->tx_next_dd = (uint16_t)(txq->tx_next_dd + rs_thresh);
-	if (txq->tx_next_dd >= txq->nb_tx_desc)
-		txq->tx_next_dd = (uint16_t)(rs_thresh - 1);
-
-	return rs_thresh;
-}
-
 /* Simple burst transmit for descriptor-based simple Tx path
  *
  * Transmits a burst of packets by filling hardware descriptors with mbuf
@@ -135,7 +91,7 @@ ci_xmit_burst_simple(struct ci_tx_queue *txq,
 	 * descriptor, free the associated buffer.
 	 */
 	if (txq->nb_tx_free < txq->tx_free_thresh)
-		ci_tx_free_bufs(txq);
+		ci_tx_free_bufs_simple(txq);
 
 	/* Use available descriptor only */
 	nb_pkts = (uint16_t)RTE_MIN(txq->nb_tx_free, nb_pkts);
drivers/net/intel/i40e/i40e_rxtx.c +1 -1
index ba63d42b85..6ea6ffbb2f 100644
@@ -2377,7 +2377,7 @@ i40e_tx_done_cleanup_simple(struct ci_tx_queue *txq,
 		if (txq->nb_tx_desc - txq->nb_tx_free < txq->tx_rs_thresh)
 			break;
 
-		n = ci_tx_free_bufs(txq);
+		n = ci_tx_free_bufs_simple(txq);
 
 		if (n == 0)
 			break;
drivers/net/intel/ice/ice_rxtx.c +1 -1
index 94951369fb..ece6ef6e2d 100644
@@ -3218,7 +3218,7 @@ ice_tx_done_cleanup_simple(struct ci_tx_queue *txq,
 		if (txq->nb_tx_desc - txq->nb_tx_free < txq->tx_rs_thresh)
 			break;
 
-		n = ci_tx_free_bufs(txq);
+		n = ci_tx_free_bufs_simple(txq);
 
 		if (n == 0)
 			break;
Signature · 1 line
2.51.0
#128 lore raw

PATCH v3 36/36 net/idpf: enable simple Tx function

In reply to Bruce Richardson

The common "simple Tx" function - in some ways a scalar version of the vector Tx functions - can be used by the idpf driver as well as i40e and ice, so add support for it to the driver.

---
 drivers/net/intel/idpf/idpf_common_device.h |  2 ++
 drivers/net/intel/idpf/idpf_common_rxtx.c   | 19 +++++++++++++++
 drivers/net/intel/idpf/idpf_common_rxtx.h   |  3 +++
 drivers/net/intel/idpf/idpf_rxtx.c          | 26 ++++++++++++++++++++-
 4 files changed, 49 insertions(+), 1 deletion(-)
drivers/net/intel/idpf/idpf_common_device.h +2 -0
index 31915a03d4..527aa9b3dc 100644
@@ -78,6 +78,7 @@ enum idpf_rx_func_type {
 enum idpf_tx_func_type {
 	IDPF_TX_DEFAULT,
 	IDPF_TX_SINGLEQ,
+	IDPF_TX_SINGLEQ_SIMPLE,
 	IDPF_TX_SINGLEQ_AVX2,
 	IDPF_TX_AVX512,
 	IDPF_TX_SINGLEQ_AVX512,
@@ -100,6 +101,7 @@ struct idpf_adapter {
 
 	bool is_tx_singleq; /* true - single queue model, false - split queue model */
 	bool is_rx_singleq; /* true - single queue model, false - split queue model */
+	bool tx_simple_allowed; /* true if all queues support simple TX */
 
 	/* For timestamp */
 	uint64_t time_hw;
drivers/net/intel/idpf/idpf_common_rxtx.c +19 -0
index bd77113551..0da2506bf0 100644
@@ -1347,6 +1347,15 @@ idpf_dp_singleq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 			idpf_set_tso_ctx, NULL, NULL);
 }
 
+RTE_EXPORT_INTERNAL_SYMBOL(idpf_dp_singleq_xmit_pkts_simple)
+uint16_t
+idpf_dp_singleq_xmit_pkts_simple(void *tx_queue, struct rte_mbuf **tx_pkts,
+				   uint16_t nb_pkts)
+{
+	return ci_xmit_pkts_simple(tx_queue, tx_pkts, nb_pkts);
+}
+
+
 /* TX prep functions */
 RTE_EXPORT_INTERNAL_SYMBOL(idpf_dp_prep_pkts)
 uint16_t
@@ -1532,6 +1541,16 @@ const struct ci_tx_path_info idpf_tx_path_infos[] = {
 			.single_queue = true
 		}
 	},
+	[IDPF_TX_SINGLEQ_SIMPLE] = {
+		.pkt_burst = idpf_dp_singleq_xmit_pkts_simple,
+		.info = "Single Queue Scalar Simple",
+		.features = {
+			.tx_offloads = IDPF_TX_VECTOR_OFFLOADS,
+			.single_queue = true,
+			.simple_tx = true,
+		}
+	},
+
 #ifdef RTE_ARCH_X86
 	[IDPF_TX_SINGLEQ_AVX2] = {
 		.pkt_burst = idpf_dp_singleq_xmit_pkts_avx2,
drivers/net/intel/idpf/idpf_common_rxtx.h +3 -0
index fe7094d434..914cab0f25 100644
@@ -221,6 +221,9 @@ __rte_internal
 uint16_t idpf_dp_singleq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 				   uint16_t nb_pkts);
 __rte_internal
+uint16_t idpf_dp_singleq_xmit_pkts_simple(void *tx_queue, struct rte_mbuf **tx_pkts,
+				   uint16_t nb_pkts);
+__rte_internal
 uint16_t idpf_dp_prep_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 			   uint16_t nb_pkts);
 __rte_internal
drivers/net/intel/idpf/idpf_rxtx.c +25 -1
index 9420200f6d..f2e202d57d 100644
@@ -509,6 +509,22 @@ idpf_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 	txq->q_set = true;
 	dev->data->tx_queues[queue_idx] = txq;
 
+	/* Set tx_simple_allowed flag based on queue configuration.
+	 * For queue 0: explicitly set the flag based on its configuration.
+	 * For other queues: only set to false if this queue cannot use simple_tx.
+	 */
+	if (vport->txq_model == VIRTCHNL2_QUEUE_MODEL_SPLIT)
+		goto out;
+
+	/* for first queue, default to true, disable later if any queue can't meet conditions */
+	if (queue_idx == 0)
+		adapter->tx_simple_allowed = true;
+
+	if ((txq->offloads != (txq->offloads & RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE)) ||
+			txq->tx_rs_thresh < IDPF_VPMD_TX_MAX_BURST)
+		adapter->tx_simple_allowed = false;
+
+out:
 	return 0;
 
 err_complq_setup:
@@ -651,6 +667,7 @@ int
 idpf_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id)
 {
 	struct idpf_vport *vport = dev->data->dev_private;
+	struct idpf_adapter *ad = vport->adapter;
 	struct ci_tx_queue *txq = dev->data->tx_queues[tx_queue_id];
 	int err = 0;
 
@@ -667,6 +684,12 @@ idpf_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id)
 		return err;
 	}
 
+	/* Record what kind of descriptor cleanup we need on teardown.
+	 * For single queue mode, vector or simple tx paths use vec entry format.
+	 */
+	if (vport->txq_model == VIRTCHNL2_QUEUE_MODEL_SINGLE)
+		txq->use_vec_entry = ad->tx_simple_allowed;
+
 	/* Ready to switch the queue on */
 	err = idpf_vc_queue_switch(vport, tx_queue_id, false, true,
 							VIRTCHNL2_QUEUE_TYPE_TX);
@@ -847,7 +870,8 @@ idpf_set_tx_function(struct rte_eth_dev *dev)
 	struct ci_tx_path_features req_features = {
 		.tx_offloads = dev->data->dev_conf.txmode.offloads,
 		.simd_width = RTE_VECT_SIMD_DISABLED,
-		.single_queue = (vport->txq_model == VIRTCHNL2_QUEUE_MODEL_SINGLE)
+		.single_queue = (vport->txq_model == VIRTCHNL2_QUEUE_MODEL_SINGLE),
+		.simple_tx = ad->tx_simple_allowed
 	};
 
 	/* The primary process selects the tx path for all processes. */
Signature · 1 line
2.51.0
#129 lore raw

[REVIEW] net/idpf: enable simple Tx function

AI-generated review of bundle-1715-intel-scalar.mbox Reviewed using Claude (claude-opus-4-5-20251101) on 2026-01-30

This is an automated review. Please verify all suggestions.

---

=============================================================== Patch 1/36 ===

## Patch Review: [PATCH v3 01/36] net/intel: create common Tx descriptor structure

### Overall Assessment
This patch creates a common Tx descriptor structure (struct ci_tx_desc) shared across i40e, iavf, ice, and idpf drivers. The change is well-structured and follows DPDK conventions.

---

### Errors

None identified.

---

### Warnings

1. **Missing release notes for internal API change**

While this is an internal structure change (not public API), the patch introduces a new common structure (struct ci_tx_desc) that affects multiple drivers. Consider documenting this refactoring in the release notes under a "drivers/net/intel" section, especially since this is patch 1 of a 36-patch series that likely represents significant internal restructuring.

---

### Info

1. **Consistent naming convention**

The ci_ prefix (common intel) is used consistently throughout the change, matching the existing ci_tx_queue and ci_tx_entry patterns. This is good practice.

2. **Field naming**

The new structure uses buffer_addr and cmd_type_offset_bsz which matches the ice/i40e naming. The idpf driver previously used buf_addr and qw1 - the patch correctly updates all idpf references to use the new field names.

3. **Base code preservation**

The commit message correctly notes that original struct definitions in base code are left in place. This is appropriate for vendor-shared base code.

4. **Line length in idpf_common_rxtx.c**

Line 1494-1495 creates a long line after the field rename:

   ```c
   txd->cmd_type_offset_bsz = rte_cpu_to_le_64(IDPF_TX_DESC_DTYPE_DATA |
   ```

This appears to remain within the 100-character limit but is close. The existing style is maintained which is acceptable.

---

### Summary

This is a clean refactoring patch that consolidates identical descriptor structures across Intel drivers. The implementation is correct and follows existing code patterns. The only suggestion is to consider adding release notes documentation for this driver restructuring work.

=== Patch 2/36 ===

## Review of DPDK Patch 2/36: "net/intel: use common Tx ring structure"

### Summary
This patch consolidates multiple per-driver TX ring pointers (i40e_tx_ring, iavf_tx_ring, ice_tx_ring, idpf_tx_ring) into a single ci_tx_ring pointer, since they all use the same struct ci_tx_desc type.

---

### Errors

None identified.

---

### Warnings

1. **DMA zone name change may affect ABI/debugging**

The patch changes DMA zone names from driver-specific names to a generic name:

   ```c
   -	tz = rte_eth_dma_zone_reserve(dev, "i40e_tx_ring", queue_idx,
   +	tz = rte_eth_dma_zone_reserve(dev, "ci_tx_ring", queue_idx,
   ```

This change affects i40e, iavf, and ice drivers. While not strictly an error, this could impact debugging tools or scripts that look for driver-specific zone names. Consider documenting this change in the commit message.

---

### Info

1. **Clean refactoring** - The consolidation from four separate union members to one is a sensible simplification given the common descriptor type introduced in the previous patch.

2. **Consistent naming** - All references are consistently updated across all affected files (23 files modified).

3. **Variable rename in ice_xmit_pkts** - The local variable rename from ice_tx_ring to ci_tx_ring (lines 3151, 3174) maintains consistency with the structure member name change.

---

### Overall Assessment

This is a straightforward mechanical refactoring patch. The changes are consistent across all affected drivers and vector implementations. The commit message adequately explains the rationale for the change.

=== Patch 3/36 ===

## Review of DPDK Patch 3/36: net/intel: create common post-Tx cleanup function

### Summary
This patch deduplicates the TX descriptor cleanup function across ice, iavf, idpf, and i40e drivers by moving it to a common header file.

---

### Errors

None found.

---

### Warnings

1. **Loss of debug logging in common function**

The original driver-specific functions included debug logging when descriptors were not yet processed:

   ```c
   PMD_TX_LOG(DEBUG, "TX descriptor %4u is not done "
              "(port=%d queue=%d)", desc_to_clean_to,
              txq->port_id, txq->queue_id);
   ```

The new common function silently returns -1 without any debug output. This could make debugging hardware issues more difficult. Consider adding a generic debug log mechanism or documenting why debug logging was intentionally removed.

2. **Comment accuracy regarding descriptor done value**

Line 287 in tx.h states:

   ```c
   /* Check if descriptor is done - all drivers use 0xF as done value in bits 3:0 */
   ```

The original drivers used different masks:
- i40e: I40E_TXD_QW1_DTYPE_MASK / I40E_TX_DESC_DTYPE_DESC_DONE
- iavf: IAVF_TXD_QW1_DTYPE_MASK / IAVF_TX_DESC_DTYPE_DESC_DONE
- ice: ICE_TX_DESC_DTYPE_DESC_DONE
- idpf: IDPF_TXD_QW1_DTYPE_M / IDPF_TX_DESC_DTYPE_DESC_DONE

While the hardcoded 0xF value may be correct for all these drivers, the comment should reference the actual descriptor type definitions or verify that 0xF is indeed the universal done value across all supported hardware.

---

### Info

1. **Code deduplication is well-executed**

The patch successfully removes ~160 lines of duplicated code across four drivers while maintaining identical functionality.

2. **Function placement in header file**

Using static __rte_always_inline in the common header is appropriate for this performance-critical path, avoiding function call overhead.

3. **Consistent style**

The new common function follows DPDK coding conventions with proper comment formatting and explicit comparisons.

=== Patch 4/36 ===

## Code Review for Patch 4/36: net/intel: consolidate definitions for Tx desc fields

### Overview
This patch consolidates TX descriptor field definitions across i40e, iavf, ice, and idpf drivers into a common tx.h header, eliminating duplicate definitions.

### Errors
None found.

### Warnings

1. **Missing Doxygen documentation for new public macros and union**
- The new CI_TXD_QW1_*, CI_TX_DESC_*, and CI_TX_CTX_DESC_* macros in drivers/net/intel/common/tx.h lack documentation comments explaining their purpose and valid values.
- The union ci_tx_offload has brief field comments but could benefit from a more complete description of usage context.

2. **Inconsistent use of IAVF_TX_DESC_CMD_IL2TAG1 vs CI_TX_DESC_CMD_IL2TAG1**
- In drivers/net/intel/iavf/iavf_rxtx_vec_common.h line 197-198, the code still uses IAVF_TX_DESC_CMD_IL2TAG1 while other similar usages in the same file were converted to CI_TX_DESC_CMD_IL2TAG1.

   ```c
   /* Line 197-198 still uses old define */
   td_cmd |= IAVF_TX_DESC_CMD_IL2TAG1;
   ```

3. **Inconsistent macro usage in iavf_rxtx_vec_avx512.c**
- Lines 2127, 2130, 2139, 2147, 2150 mix CI_TXD_QW1_CMD_S with IAVF_TXD_CTX_QW1_CMD_SHIFT in the same expressions. While this may be intentional (context descriptor vs data descriptor), the inconsistency could be confusing.

4. **Unused old macros remain in headers**
- The commit message states "Original definitions are in base code, and are left in place because of that, but are unused." Consider adding a comment in the code explaining this to prevent future cleanup attempts that could break base code compatibility.

### Info

1. **Code style improvement**
- The patch improves code formatting in several places by reducing line length and improving readability of multi-line expressions (e.g., in ice_rxtx_vec_avx512.c and iavf_rxtx_vec_avx512.c).

2. **Comment update in ice_rxtx_vec_common.h**
- Line 166 changes comment from "Tx VLAN insertion Offload" to "Tx VLAN/QINQ insertion Offload" - this is a documentation improvement that accurately reflects the code's behavior.

3. **Naming convention**
- The CI_ prefix is consistent with the common Intel driver namespace established in earlier patches of this series.

4. **Macro suffix conventions**
- The new macros use _S for shift values and _M for masks, which is consistent with existing DPDK Intel driver conventions.

### Summary
The patch successfully consolidates duplicate TX descriptor definitions into a common location. The main concern is the incomplete conversion in iavf_rxtx_vec_common.h where IAVF_TX_DESC_CMD_IL2TAG1 is still used instead of the new CI_TX_DESC_CMD_IL2TAG1. This should be verified as intentional or corrected for consistency.

=== Patch 5/36 ===

## Review of Patch 5/36: net/intel: create separate header for Tx scalar fns

### Errors

1. **Copyright year in future**: The new file tx_scalar_fns.h has copyright year 2025, but the current date is 2026. This should be corrected to 2026.

### Warnings

1. **Circular include dependency**: The new file tx_scalar_fns.h includes tx.h at line 13, but tx.h includes tx_scalar_fns.h at line 443. While header guards prevent infinite recursion, this creates a confusing circular dependency. Consider restructuring so that tx_scalar_fns.h is truly standalone or moving shared definitions to a separate base header.

2. **Comment style inconsistency**: In tx.h line 440-442, the multi-line comment uses lowercase start after /*:

   ```c
   /* include the scalar functions at the end, so they can use the common definitions.
    * This is done so drivers can use all functions just by including tx.h
    */
   ```

Per DPDK style, multi-line comments that are "VERY important" or explanatory should start with a capital letter and be complete sentences.

### Info

1. The patch cleanly moves code without modification, which is good for reviewability. The ci_tx_xmit_cleanup function appears identical in both the removed and added sections.

2. The approach of including the scalar functions header at the end of tx.h is a reasonable way to maintain a single include point for drivers while organizing the code into separate files.

### Summary

The patch is a straightforward code reorganization moving the ci_tx_xmit_cleanup function to a new header file. The main issue is the copyright year which should be 2026. The circular include pattern, while functional, could be improved architecturally but is not a blocking issue.

=== Patch 6/36 ===

## Code Review: Patch 6/36 - net/intel: add common fn to calculate needed descriptors

### Overall Assessment
This patch consolidates duplicate descriptor calculation logic into common code and fixes a bug in the idpf driver. The implementation is clean and well-structured.

---

### Errors
None.

---

### Warnings

1. **Extra blank line at end of function block**

In drivers/net/intel/common/tx_scalar_fns.h, there are two blank lines before #endif:

   ```c
   	return count;
   }
   
   
   #endif /* _COMMON_INTEL_TX_SCALAR_FNS_H_ */
   ```

**Suggested fix**: Remove one blank line to have just a single blank line before the #endif.

2. **Function parameter could use const qualifier**

The original driver functions used struct rte_mbuf *tx_pkt (non-const), but the new common function correctly uses const struct rte_mbuf *tx_pkt. However, this means the callers are now passing non-const pointers to a const parameter, which is fine, but worth noting the improvement in const-correctness.

3. **Missing release notes for bug fix**

The commit message mentions "fix idpf driver calculation for the TSO case" - this is a bug fix that affects the idpf driver's TSO functionality. Bug fixes that affect driver behavior should typically have release notes.

**Suggested fix**: Consider adding a note to the release notes about the idpf TSO descriptor calculation fix.

---

### Info

1. **Good consolidation of duplicate code**

The patch removes identical i40e_calc_pkt_desc, iavf_calc_pkt_desc, and ice_calc_pkt_desc functions and replaces them with a single ci_calc_pkt_desc function. This is good code hygiene.

2. **Useful helper function added**

The ci_div_roundup16 function is a reasonable addition for 16-bit division with rounding up, avoiding potential issues with the generic DIV_ROUND_UP macro.

3. **Bug fix for idpf is a good catch**

The idpf driver was previously not accounting for TSO packets potentially needing more descriptors than segments. The fix aligns it with the other Intel drivers.

---

### Summary

The patch is well-constructed and achieves its goal of consolidating common code while fixing a bug. The only items to address are the extra blank line in the header file and potentially adding release notes for the idpf TSO fix.

=== Patch 7/36 ===

## Review of Patch 7/36: net/ice: refactor context descriptor handling

### Overall Assessment
This patch refactors the context descriptor handling in the ice driver by consolidating the logic into a single get_context_desc() function. The refactoring is generally well done, but there are some issues to address.

---

### Errors

**1. Extra blank line in function**
Line 3092-3093 has two consecutive blank lines inside get_context_desc(), which is inconsistent with DPDK style.

```c
			((ptp_tx_index << ICE_TXD_CTX_QW1_TSYN_S) & ICE_TXD_CTX_QW1_TSYN_M);


	/* TX context descriptor based double VLAN insert */
```

**Suggested fix:** Remove one of the blank lines.

---

### Warnings

**1. Blank line removal at start of function changes code unnecessarily**
At line 2969, there's now a blank line at the start of ice_txd_enable_checksum() after the code removal. While not strictly wrong, a function should not start with a blank line before any statements.

```c
{
-	/* Set MACLEN */
-	if (!(ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK))
-		*td_offset |= (tx_offload.l2_len >> 1)
-			<< CI_TX_DESC_LEN_MACLEN_S;

	/* Enable L3 checksum offloads */
```

**Suggested fix:** Remove the extra blank line that remains after deleting the MACLEN code block.

**2. Function parameter alignment inconsistency**
In get_context_desc() definition (line 3082-3084), the continuation lines use single tab indentation rather than aligning with the opening parenthesis or using double indentation for continuation:

```c
static __rte_always_inline uint16_t
get_context_desc(uint64_t ol_flags, const struct rte_mbuf *tx_pkt,
	const union ci_tx_offload *tx_offload, const struct ci_tx_queue *txq,
	uint64_t *qw0, uint64_t *qw1)
```

**Suggested fix:** Use double-tab indentation for continuation lines in function parameters for consistency.

**3. Variable initialization**
Line 3085 initializes cd_l2tag2 to 0, but it's only written when RTE_MBUF_F_TX_QINQ is set. The early return at line 3091 means this initialization is necessary for correctness, so this is acceptable. However, cd_type_cmd_tso_mss could be left uninitialized until after the early return check for better compiler analysis.

---

### Info

**1. Casting approach**
Line 3223 uses RTE_CAST_PTR macro:

```c
uint64_t *ctx_txd = RTE_CAST_PTR(uint64_t *, &ci_tx_ring[tx_id]);
```

This is cleaner than the previous volatile struct pointer cast. The change from using struct field names (tunneling_params, l2tag2, qw1) to raw uint64_t array access (ctx_txd[0], ctx_txd[1]) is less self-documenting but acceptable for performance-critical code.

**2. Function return type**
The function returns uint16_t but only ever returns 0 or 1. A bool or int might be more semantically appropriate, though uint16_t matches nb_ctx usage which is fine.

---

### Summary

The refactoring consolidates context descriptor logic well and should improve maintainability. The main issues are:
- Double blank line inside get_context_desc()
- Residual blank line in ice_txd_enable_checksum()

=== Patch 8/36 ===

## Review of DPDK Patch 8/36: net/i40e: refactor context descriptor handling

### Errors

1. **Commit message body starts with lowercase**
- The body begins with "move all context descriptor handling..." which should be capitalized: "Move all context descriptor handling..."

### Warnings

1. **Subject line capitalization**
- Subject uses lowercase "refactor" which is acceptable, but the body starting with lowercase "move" is inconsistent with standard English sentence structure.

2. **Missing explicit NULL comparison**
- Line 1040: if (i40e_calc_context_desc(ol_flags) == 0) - This is correct and explicit.
- However, note that the function returns uint16_t, so comparing with 0 is appropriate.

3. **Declaration in middle of block**
- Lines 1125-1127: Variables cd_qw0 and cd_qw1 are declared in the middle of the function body, after statements. While C99 allows this, it's mixed with the existing declaration-at-top style in this function. Consider moving these declarations to the top of the for loop block or function for consistency.

   ```c
   /* Calculate the number of context descriptors needed. */
   uint64_t cd_qw0 = 0, cd_qw1 = 0;
   nb_ctx = get_context_desc(ol_flags, tx_pkt, &tx_offload, txq,
           &cd_qw0, &cd_qw1);
   ```

4. **Unused parameter annotation style**
- Line 1034: The txq parameter is marked __rte_unused. This is acceptable, but consider whether this parameter will be needed in future development given this is a refactoring patch meant to align with the ice driver.

### Info

1. **Code consolidation is well-structured**
- The new get_context_desc() function provides a clean abstraction matching the ice driver pattern as mentioned in the commit message.

2. **MACLEN handling moved appropriately**
- The MACLEN calculation was removed from i40e_txd_enable_checksum() and moved to the main transmit loop where td_offset is initialized. This correctly handles both tunneled and non-tunneled cases in a single location.

3. **RTE_CAST_PTR usage**
- Line 1180: RTE_CAST_PTR(uint64_t *, &txr[tx_id]) - Good use of the DPDK cast macro.

4. **Debug logging simplified**
- The PMD_TX_LOG message was simplified from printing individual context descriptor fields to printing the raw qw0/qw1 values. This is a reasonable simplification for debugging purposes.

### Summary

The patch is a reasonable refactoring that consolidates context descriptor handling into a single function. The main issue is the lowercase start of the commit message body. The code changes are well-structured and follow the existing patterns in the codebase.

=== Patch 9/36 ===

## Review of DPDK Patch: net/idpf: refactor context descriptor handling

### Errors

1. **Subject line starts with lowercase after prefix**
- Subject: "move all context descriptor handling to a single function, as with the ice driver."
- The commit body starts with lowercase "move" which is acceptable, but this is the first line of the body and should not start with a lowercase word in this context. The sentence should be capitalized: "Move all context descriptor handling..."

2. **Body line potentially exceeds 75 characters**
- Line: "move all context descriptor handling to a single function, as with the ice driver."
- This line is 78 characters. Should be wrapped at 75 characters.

### Warnings

1. **Variable declaration in the middle of a block**
- At lines where uint64_t cd_qw0, cd_qw1; is declared after executable statements:

   ```c
   tx_offload.tso_segsz = tx_pkt->tso_segsz;
   /* Calculate the number of context descriptors needed. */
   uint64_t cd_qw0, cd_qw1;
   nb_ctx = idpf_set_tso_ctx(ol_flags, tx_pkt, tx_offload, &cd_qw0, &cd_qw1);
   ```

While C99 allows mixed declarations, DPDK style prefers declarations at the start of blocks or in inner blocks. Consider moving the declaration to the beginning of the loop or creating an inner block.

2. **Potential uninitialized variable usage**
- cd_qw0 and cd_qw1 are used when nb_ctx != 0, but if idpf_set_tso_ctx() returns 0 due to the early return at line 857 (if (tx_offload.l4_len == 0)), the function returns 0 without setting *qw0 and *qw1. However, since nb_ctx would be 0 in this case, the values wouldn't be used. This is correct but could be clearer - consider initializing the output parameters to 0 at the start of idpf_set_tso_ctx() for defensive programming.

3. **Inconsistent function naming**
- The function was renamed from idpf_set_splitq_tso_ctx to idpf_set_tso_ctx, which is good as it's now used by both splitq and singleq paths. However, the comment on line 848 still only mentions "TSO context descriptor" - consider documenting that this handles the context descriptor for both queue types.

### Info

1. **Good refactoring pattern**
- The consolidation of context descriptor handling into a single function that returns quad-word values rather than writing directly to volatile memory is a clean approach that mirrors the ice driver pattern mentioned in the commit message.

2. **Code simplification**
- The removal of the separate if ((ol_flags & RTE_MBUF_F_TX_TCP_SEG) != 0) checks in both transmit functions is a good cleanup, as the check is now internal to idpf_set_tso_ctx().

### Summary

The patch performs a reasonable refactoring to consolidate context descriptor handling. The main issues are:
- Commit message body formatting (first word capitalization, line length)
- Variable declarations could be moved to block start for style consistency

=== Patch 10/36 ===

## Review of Patch 10/36: net/intel: consolidate checksum mask definition

### Overall Assessment
This patch consolidates duplicate checksum offload mask definitions across multiple Intel drivers into a common header. The change is clean and improves maintainability.

---

### Errors
None identified.

---

### Warnings

**1. Inconsistent flags in consolidated mask vs. original i40e/ice masks**

The new CI_TX_CKSUM_OFFLOAD_MASK includes RTE_MBUF_F_TX_OUTER_UDP_CKSUM which was NOT present in the original I40E_TX_CKSUM_OFFLOAD_MASK or ICE_TX_CKSUM_OFFLOAD_MASK:

Original i40e:

```c
#define I40E_TX_CKSUM_OFFLOAD_MASK (RTE_MBUF_F_TX_IP_CKSUM |
		RTE_MBUF_F_TX_L4_MASK |
		RTE_MBUF_F_TX_TCP_SEG |
		RTE_MBUF_F_TX_OUTER_IP_CKSUM)
```

Original ice:

```c
#define ICE_TX_CKSUM_OFFLOAD_MASK (RTE_MBUF_F_TX_IP_CKSUM |
		RTE_MBUF_F_TX_L4_MASK |
		RTE_MBUF_F_TX_TCP_SEG |
		RTE_MBUF_F_TX_UDP_SEG |
		RTE_MBUF_F_TX_OUTER_IP_CKSUM)
```

New common mask:

```c
#define CI_TX_CKSUM_OFFLOAD_MASK (RTE_MBUF_F_TX_IP_CKSUM |
				   RTE_MBUF_F_TX_L4_MASK |
				   RTE_MBUF_F_TX_TCP_SEG |
				   RTE_MBUF_F_TX_UDP_SEG |
				   RTE_MBUF_F_TX_OUTER_IP_CKSUM |
				   RTE_MBUF_F_TX_OUTER_UDP_CKSUM)  /* NEW for i40e/ice */
```

Also, i40e didn't have RTE_MBUF_F_TX_UDP_SEG. This expands the behavior for i40e and ice drivers. Please confirm this is intentional and won't cause issues with hardware that doesn't support these offloads.

**2. Alignment inconsistency in macro definition**

The continuation lines in CI_TX_CKSUM_OFFLOAD_MASK use inconsistent alignment with extra spaces:

```c
#define CI_TX_CKSUM_OFFLOAD_MASK (RTE_MBUF_F_TX_IP_CKSUM |		 \
				   RTE_MBUF_F_TX_L4_MASK |		 \
```

Should align using tabs consistently per DPDK style, matching the pattern used in the removed driver-specific macros.

---

### Info

**1. Commit message could mention behavioral change**

Since the consolidated mask is a superset of some driver-specific masks, the commit message could note that this extends the checksum offload flags checked for i40e and ice drivers (adding RTE_MBUF_F_TX_OUTER_UDP_CKSUM to both, and RTE_MBUF_F_TX_UDP_SEG to i40e).

---

### Summary
The consolidation approach is good for maintainability. The main concern is whether the expanded flag mask is intentional for i40e and ice drivers, as this changes behavior by checking additional offload flags. If intentional, a brief mention in the commit message would be helpful.

=== Patch 11/36 ===

## Review of Patch 11/36: net/intel: create common checksum Tx offload function

### Errors

None identified.

### Warnings

1. **Minor alignment inconsistency in function call (i40e_rxtx.c)**

The replacement call has inconsistent alignment:

   ```c
   ci_txd_enable_checksum(ol_flags, &td_cmd,
   					 &td_offset, tx_offload);
   ```
   The continuation line uses tabs that don't align with the opening parenthesis. This should be aligned consistently:
   ```c
   ci_txd_enable_checksum(ol_flags, &td_cmd,
   			&td_offset, tx_offload);
   ```

2. **Functional difference between merged implementations**

The original i40e_txd_enable_checksum() did NOT handle RTE_MBUF_F_TX_UDP_SEG, but ice_txd_enable_checksum() did. The new common function includes the UDP segmentation handling (lines 93-98 of the new header). This extends i40e's behavior - verify this is intentional and that i40e hardware supports UDP segmentation offload in this manner.

### Info

1. **Well-structured consolidation**

The patch effectively merges two nearly identical functions into a shared implementation, reducing code duplication between i40e and ice drivers.

2. **Commit message is clear and appropriate**

The subject is within 60 characters, uses correct prefix format (net/intel:), and the body adequately explains the change and notes future extensibility.

3. **Code follows DPDK style**

The new ci_txd_enable_checksum() function follows proper formatting with return type on its own line and consistent brace/indentation style.

=== Patch 12/36 ===

## DPDK Patch Review: net/intel: create a common scalar Tx function

### Overall Summary
This patch moves the ice driver's transmit function into a common location for reuse by other Intel drivers. The refactoring is generally well-done, but there are a few issues to address.

---

### Errors

**1. Typo in struct name: "timesstamp" should be "timestamp"**

The struct ci_timesstamp_queue_fns has a spelling error ("timesstamp" with double 's'):

```c
struct ci_timesstamp_queue_fns {
```

Should be:

```c
struct ci_timestamp_queue_fns {
```

This typo appears in both the header file and the ice_rxtx.c usage.

---

### Warnings

**1. Behavioral change: td_cmd initialization differs between original and common code**

In the original ice_xmit_pkts():

```c
td_cmd = 0;
```

In the new ci_xmit_pkts():

```c
td_cmd = CI_TX_DESC_CMD_ICRC;
```

This changes the behavior - the ice driver previously did not set the ICRC bit initially. This may be intentional for consolidation across drivers, but should be verified and documented in the commit message if it's a functional change.

**2. Unnecessary cast of void pointer**

In ice_xmit_pkts():

```c
struct ci_tx_queue *txq = (struct ci_tx_queue *)tx_queue;
```

The cast from void * is unnecessary in C:

```c
struct ci_tx_queue *txq = tx_queue;
```

**3. Missing null check in ice_get_ts_tail()**

The function directly dereferences txq->tsq without checking for NULL:

```c
static uint16_t
ice_get_ts_tail(struct ci_tx_queue *txq)
{
    return txq->tsq->ts_tail;
}
```

While the caller checks txq->tsq != NULL before passing &ts_fns, this creates a fragile API contract. Consider adding a defensive check or documenting the precondition.

**4. Double blank line in header file**

Line 205-206 in tx_scalar_fns.h has an extra blank line before the #endif:

```c
	return nb_tx;
}


#endif /* _COMMON_INTEL_TX_SCALAR_FNS_H_ */
```

Should be a single blank line.

---

### Info

**1. Good refactoring pattern**

The use of function pointers for timestamp handling (ci_timesstamp_queue_fns) is a clean way to abstract driver-specific behavior while sharing the common transmit logic.

**2. Removed debug logging**

The original code had:

```c
PMD_TX_LOG(DEBUG, "Setting RS bit on TXD id=%4u ...", ...);
```

This debug log statement was removed in the refactoring. This is acceptable but worth noting if debug tracing is important for the ice driver.

**3. Consider const correctness for function pointer struct**

The ts_fns local variable in ice_xmit_pkts() is already const, which is good practice.

---

### Summary

The main issues to address:
1. **Error**: Fix the "timesstamp" typo to "timestamp"
2. **Warning**: Verify the CI_TX_DESC_CMD_ICRC behavioral change is intentional
3. **Warning**: Remove unnecessary void* cast

=== Patch 13/36 ===

# DPDK Patch Review: net/i40e: use common scalar Tx function

## Summary
This patch refactors the i40e driver to use a common scalar transmit function (ci_xmit_pkts) that was previously moved from the ice driver, eliminating approximately 206 lines of duplicated code.

---

## Errors
None identified.

---

## Warnings

### 1. Missing Release Notes
**Issue**: This patch removes significant driver code (206 lines) and changes the internal implementation of the transmit path. While this is an internal refactoring, changes to driver implementation that could affect behavior typically warrant release notes.

**Assessment**: Since this is purely internal refactoring with no public API changes and the commit message indicates the behavior should be identical, this may be acceptable without release notes. However, if there are any observable differences (e.g., performance characteristics), release notes would be appropriate.

---

## Info

### 1. Code Consolidation
The patch correctly consolidates duplicated transmit logic into a common function ci_xmit_pkts(). The comment explaining the NULL parameter for timestamp functions is helpful:

```c
/* i40e does not support timestamp queues, so pass NULL for ts_fns */
return ci_xmit_pkts(tx_queue, tx_pkts, nb_pkts, get_context_desc, NULL);
```

### 2. Commit Message Quality
The commit message is well-written:
- Clear subject line within 60 characters
- Explains the rationale (code deduplication)
- Mentions the benefit (saves hundreds of duplicated lines)
- Proper Signed-off-by tag

---

## Review Checklist

| Item | Status |
|------|--------|
| Subject line ≤60 characters | ✓ Pass (44 chars) |
| Subject lowercase after prefix | ✓ Pass |
| Correct component prefix (`net/i40e:`) | ✓ Pass |
| Imperative mood | ✓ Pass |
| No trailing period | ✓ Pass |
| Body wrapped appropriately | ✓ Pass |
| Signed-off-by present | ✓ Pass |
| SPDX/Copyright (no new files) | N/A |
| Code style | ✓ Pass |
| No forbidden tokens | ✓ Pass |

---

## Overall Assessment

**APPROVE** - This is a clean refactoring patch that reduces code duplication by leveraging a common transmit function. The implementation is straightforward, the comment explaining the NULL parameter is helpful, and the commit message adequately describes the change. The patch follows DPDK coding standards and contribution guidelines.

=== Patch 14/36 ===

## Review of Patch 14/36: net/intel: add IPsec hooks to common Tx function

### Commit Message

**No issues found.** The subject line is within 60 characters, uses correct prefix format, imperative mood, and lowercase. The body adequately explains the change and its design rationale. Signed-off-by is present.

### Code Review

#### Errors

None identified.

#### Warnings

1. **Unnecessary NULL check before IPsec operations in segment length calculation (line 347-350)**

The calc_segment_len callback is called unconditionally when ipsec_ops != NULL, but the original simple assignment (slen = m_seg->data_len) would be correct for non-IPsec packets even when IPsec ops are provided. The callback must handle the non-IPsec case internally.

Consider whether passing ipsec_md (which may be NULL) and ol_flags is sufficient for the callback to determine the correct behavior, or if the check should be if (ipsec_ops != NULL && ipsec_md != NULL) instead.

2. **Missing parameter documentation in typedef comments**

The tlen parameter in calc_ipsec_segment_len_t typedef (line 131) is not documented in the comment. Its purpose is unclear from context.

#### Info

1. **Consistent NULL check pattern**

The code correctly uses compile-time NULL checks that can be optimized away:

   ```c
   if (ipsec_ops != NULL)
   ```

This is good for the stated zero-performance-impact goal.

2. **Extra blank line (line 334)**

There's a blank line after the closing brace of the IPsec descriptor block that creates inconsistent spacing. While not strictly wrong, it differs from the style of the context descriptor block above it.

3. **Comment style consistency**

The inline comment at line 347 (/* Calculate segment length, using IPsec callback if provided */) is helpful but extends the visual complexity. Consider whether this level of documentation is needed given the self-documenting nature of calc_segment_len.

### Summary

This patch cleanly extends the common Tx function to support IPsec offload through a callback mechanism. The design of passing compile-time NULL constants for drivers without IPsec support is sound for optimization. The main concern is ensuring the calc_segment_len callback correctly handles the case where IPsec descriptors are available but not used for a particular packet.

=== Patch 15/36 ===

## Review of Patch 15/36: net/intel: support configurable VLAN tag insertion on Tx

### Errors

None identified.

### Warnings

1. **Commit body line potentially exceeds 75 characters**
- Line "Make the VLAN tag insertion logic configurable in the common code, as to" appears to be close to or at the 75 character limit. Consider rewording for better readability.

2. **Comment style inconsistency in tx_scalar_fns.h**
- Lines 288-290 use a non-standard multi-line comment format:

   ```c
   /* Descriptor based VLAN/QinQ insertion */
   /* for single vlan offload, only insert in data desc with VLAN_IN_L2TAG1 is set
    * for qinq offload, we always put inner tag in L2Tag1
    */
   ```

The second comment should either be a proper multi-line comment starting with /* on its own line or merged with the first. Also, comments should be proper sentences (capitalize "For", end with period).

3. **Inconsistent condition formatting**
- In tx_scalar_fns.h lines 291-292, the condition continuation uses double-indent with tabs, but the alignment appears inconsistent:

   ```c
   if (((ol_flags & RTE_MBUF_F_TX_VLAN) && l2tag1_field == CI_VLAN_IN_L2TAG1) ||
   				(ol_flags & RTE_MBUF_F_TX_QINQ)) {
   ```

The continuation line appears to use excessive indentation.

4. **Cast in i40e_rxtx.c may have been unintentionally removed**
- The change from ((uint64_t)I40E_TX_CTX_DESC_IL2TAG2 << ...) to (I40E_TX_CTX_DESC_IL2TAG2 << ...) removes an explicit cast. This should be verified to ensure no truncation or sign-extension issues occur. If the cast was unnecessary, this is acceptable cleanup; otherwise it could be a bug.

### Info

1. **Enum naming convention**
- The enum values CI_VLAN_IN_L2TAG1 and CI_VLAN_IN_L2TAG2 follow DPDK uppercase naming conventions correctly.

2. **Doxygen documentation is well-formed**
- The documentation for enum ci_tx_l2tag1_field is clear and properly formatted.

3. **Function parameter order**
- Adding l2tag1_field as the 4th parameter (after nb_pkts, before callback functions) is a reasonable placement in the API.

### Summary

The patch is mostly well-formed. The main concerns are the comment style in the modified code section, the condition line indentation, and verifying that the removed uint64_t cast in i40e_rxtx.c is intentional and safe. The commit message and overall structure are acceptable.

=== Patch 16/36 ===

# Code Review: DPDK Patch 16/36

## Review Summary

This patch refactors the iavf driver to use the common scalar Tx function, eliminating duplicated code. The approach is sound - creating callbacks for IPsec and context descriptor handling to integrate with the common infrastructure.

---

## Errors

None found.

---

## Warnings

### 1. Potential NULL Pointer Dereference in iavf_get_ipsec_desc

**File:** drivers/net/intel/iavf/iavf_rxtx.c, lines 2477-2480

The RTE_MBUF_DYNFIELD macro returns a pointer computed from the mbuf address and offset. The check if (!md) after this call is ineffective - the macro will return a non-NULL pointer even if the dynfield doesn't contain valid data.

```c
md = RTE_MBUF_DYNFIELD(mbuf, txq->ipsec_crypto_pkt_md_offset,
                       struct iavf_ipsec_crypto_pkt_metadata *);
if (!md)
    return 0;
```

The NULL check should verify that ipsec_crypto_pkt_md_offset is valid (not -1 or similar sentinel) rather than checking md.

### 2. Unused Variable with Suppression Comment

**File:** drivers/net/intel/iavf/iavf_rxtx.c, line 2558

```c
tlen = iavf_fill_ctx_desc_segmentation_field(&cd_type_cmd,
                                             mbuf, ipsec_md);
(void)tlen; /* Suppress unused variable warning */
```

If tlen is not used, consider whether the function call is necessary or if the code is incomplete. The cast to void works but suggests the return value should either be used or the function redesigned.

### 3. Implicit Boolean Conversion

**File:** drivers/net/intel/iavf/iavf_rxtx.c, line 2543

```c
if (ol_flags & RTE_MBUF_F_TX_SEC_OFFLOAD && ipsec_md) {
```

Per guidelines, pointer checks should use explicit comparison: ipsec_md != NULL.

### 4. Stack-Allocated Callback Structure

**File:** drivers/net/intel/iavf/iavf_rxtx.c, lines 2601-2604

```c
const struct ci_ipsec_ops ipsec_ops = {
    .get_ipsec_desc = iavf_get_ipsec_desc,
    .calc_segment_len = iavf_calc_ipsec_segment_len,
};
```

While this works, creating this structure on every function call adds unnecessary overhead. Consider making this a static const at file scope.

---

## Info

### 1. Significant Code Reduction

The patch removes ~220 lines of code by leveraging the common Tx function, which is a good consolidation effort.

### 2. Consistent Refactoring Pattern

The callback-based approach for iavf_get_context_desc, iavf_get_ipsec_desc, and iavf_calc_ipsec_segment_len provides clean integration points with the common code.

### 3. Function Signature Improvement

Good change making iavf_calc_context_desc take const struct rte_mbuf * instead of non-const, indicating the function doesn't modify the mbuf.

---

## Summary

The patch is well-structured and achieves its goal of code deduplication. The main concerns are:
1. The ineffective NULL check on the dynfield result
2. Minor style issues with implicit boolean comparisons
3. Performance consideration for the stack-allocated callback structure

=== Patch 17/36 ===

## Review of Patch 17/36: net/i40e: document requirement for QinQ support

### Commit Message

**No issues found.** The commit message is well-formed:
- Subject line is 52 characters, within the 60-character limit
- Uses correct prefix net/i40e:
- Lowercase after colon, imperative mood, no trailing period
- Body explains the issue and solution clearly
- Signed-off-by tag present

### Code Review

#### Errors

None identified.

#### Warnings

1. **Line length exceeds 100 characters in driver code**

The warning log messages exceed the 100-character limit:

   ```c
   PMD_DRV_LOG(WARNING, "Port %u: QinQ TX offload is enabled but VLAN extend mode is not set. ",
   ```

This line is approximately 107 characters.

**Suggested fix:** Break the format string:

   ```c
   PMD_DRV_LOG(WARNING,
       "Port %u: QinQ TX offload enabled but VLAN extend mode not set",
       dev->data->port_id);
   PMD_DRV_LOG(WARNING,
       "Double VLAN insertion requires RTE_ETH_RX_OFFLOAD_VLAN_EXTEND in Rx config");
   ```

2. **Trailing space in log message**

The first PMD_DRV_LOG format string ends with a trailing space before the closing quote:

   ```c
   "...VLAN extend mode is not set. ",
   ```

**Suggested fix:** Remove the trailing space.

3. **Consider combining log messages or returning an error**

Two separate WARNING logs for a single condition is unusual. Consider either:
- Combining into a single log message
- Returning an error (-EINVAL) since the configuration is invalid, rather than just warning

#### Info

1. **Documentation improvement is good**

Adding explicit documentation about the QinQ/VLAN_EXTEND dependency is helpful for users.

2. **Code example in documentation**

The RST code example is clear and demonstrates proper configuration.

### Summary

The patch adds useful documentation and a runtime check for a hardware requirement. The main issues are:
- Line length violations in the warning messages
- Trailing whitespace in a string literal
- Consider whether this should be an error rather than a warning (if the configuration truly won't work)

=== Patch 18/36 ===

## Review of Patch 18/36: net/idpf: use common scalar Tx function

### Overall Assessment
This patch refactors the IDPF driver's single-queue transmit function to use a common scalar Tx implementation. The changes are straightforward code consolidation.

---

### Errors
None identified.

---

### Warnings

1. **Function signature change for idpf_set_tso_ctx may need documentation**

The idpf_set_tso_ctx function signature changed significantly:
- tx_offload changed from pass-by-value to const pointer
- Added const struct ci_tx_queue *txq __rte_unused parameter

This appears to be adapting to a common callback interface. If this callback signature is part of a documented internal API, ensure consistency is maintained across all drivers using it.

2. **Removed include may affect other code paths**

The removal of #include "../common/rx.h" should be verified to not break any dependencies. If this header was only used by the removed code, this is fine.

---

### Info

1. **Significant code reduction**

This patch removes ~168 lines of driver-specific Tx code and replaces it with a 3-line call to ci_xmit_pkts(). This is good for maintainability.

2. **Parameter formatting improvement**

The reformatting of idpf_set_tso_ctx parameters to align properly is a style improvement.

3. **Minor style note on function call**

In the new implementation:

   ```c
   return ci_xmit_pkts(tx_queue, tx_pkts, nb_pkts, CI_VLAN_IN_L2TAG1,
   		idpf_set_tso_ctx, NULL, NULL);
   ```

The continuation line uses tabs for indentation which is correct per DPDK style.

---

### Commit Message Review
- **Subject line**: "net/idpf: use common scalar Tx function" - 40 characters, good format
- **Body**: Describes the change adequately
- **Signed-off-by**: Present with valid format

The commit message is acceptable, though it could mention this is specifically for "single-queue configuration" which is mentioned in the body but adds useful context.

---

### Summary
This is a clean refactoring patch that consolidates driver-specific Tx code into a common implementation. No blocking issues identified.

=== Patch 19/36 ===

## Review of Patch 19/36: net/intel: avoid writing the final pkt descriptor twice

### Overall Assessment
This is a well-structured optimization patch that reduces memory writes in the scalar Tx datapath.

---

### Errors
None identified.

---

### Warnings

1. **Subject line is 62 characters (exceeds 60 character limit)**

Current: net/intel: avoid writing the final pkt descriptor twice

Suggested shorter alternatives:
- net/intel: avoid double write to final Tx descriptor (51 chars)
- net/intel: reduce writes for final pkt descriptor (50 chars)

---

### Info

1. **Clear optimization with good explanation**

The commit message effectively explains the performance issue (3 x 64-bit writes instead of 2) and how the fix addresses it by computing the EOP bit inside the loop.

2. **Code change is straightforward and correct**

The logic change moves the EOP bit computation inside the do...while loop, adding it only when m_seg->next == NULL (i.e., the last segment). This correctly handles both single-segment and multi-segment packets while eliminating the redundant write.

3. **RS bit handling is appropriately updated**

The RS (Report Status) bit handling is correctly updated to use a direct OR operation on the already-written descriptor rather than going through td_cmd, since td_cmd is no longer written after the loop.

---

### Summary
This is a clean optimization patch. The only issue is the subject line length being 2 characters over the 60-character limit.

=== Patch 20/36 ===

## Review of Patch 20/36: "eal: add macro for marking assumed alignment"

### Overall Assessment
This patch adds a portability macro wrapping __builtin_assume_aligned for use across different toolchains. The implementation is straightforward and appropriate.

---

### Errors
None.

---

### Warnings

1. **Missing documentation for new macro**

The new __rte_assume_aligned macro lacks a Doxygen comment explaining its purpose, parameters, and usage. Public macros in rte_common.h should be documented.

**Suggested fix:**

   ```c
   /**
    * Mark a pointer as having a known minimum alignment.
    *
    * This allows the compiler to optimize code based on the alignment assumption.
    *
    * @param ptr
    *   Pointer to mark as aligned.
    * @param align
    *   Minimum alignment in bytes (must be a power of 2).
    * @return
    *   The pointer, with alignment information for the compiler.
    */
   #ifdef RTE_TOOLCHAIN_MSVC
   #define __rte_assume_aligned(ptr, align) (ptr)
   #else
   #define __rte_assume_aligned __builtin_assume_aligned
   #endif
   ```

2. **Commit message could be more descriptive**

The commit body mentions this is for "gcc/clang builtin __rte_assume_aligned" but the builtin is actually __builtin_assume_aligned. The description also doesn't explain why this macro is needed or what benefits it provides.

---

### Info

1. **MSVC fallback is a no-op**

The MSVC implementation simply returns the pointer unchanged, meaning MSVC builds won't benefit from alignment hints. This is acceptable as a portability measure, but could be noted in documentation. MSVC has __assume which could potentially be used, though it works differently.

2. **Consider including __builtin_assume_aligned behavior note**

The GCC/Clang builtin can take an optional third parameter for offset. The current macro alias supports this implicitly since it directly maps to the builtin, which is good for flexibility.

---

### Summary
The patch is functionally correct and follows coding style guidelines. The main suggestion is to add Doxygen documentation for the new macro, which is expected for public API additions in DPDK header files.

=== Patch 21/36 ===

## Review of Patch 21/36: net/intel: write descriptors using non-volatile pointers

### Commit Message

**Subject Line:**
- Length: 59 characters ✓ (within 60 character limit)
- Format: Correct prefix net/intel: ✓
- Lowercase after prefix ✓
- Imperative mood ✓
- No trailing period ✓

**Body:**
- Describes the change and rationale adequately ✓
- Lines within 75 characters ✓
- Does not start with "It" ✓

**Tags:**
- Signed-off-by present with valid format ✓

### License/Copyright

This patch modifies an existing file without adding new copyright - this is acceptable as it's a modification to existing Intel code.

### Code Style Review

**Errors:** None

**Warnings:**

1. **Variable declaration placement in loop body (lines ~370, ~392)**

The const uint64_t cmd_type_offset_bsz declarations appear in the middle of statement blocks. While C99 allows this, DPDK style prefers declarations at the start of blocks for consistency. However, since these are inside loops and immediately used, this is acceptable.

2. **Casting away volatile in write_txd() function**

The function casts away volatile from txd:

   ```c
   uint64_t *txd_qw = __rte_assume_aligned(RTE_CAST_PTR(void *, txd), 16);
   ```

This is intentional per the commit message ("allow the compiler to optionally merge the stores"), but deserves scrutiny. The comment in the commit message explains the rationale, which is acceptable for TX descriptors where the volatile was likely overly conservative.

**Info:**

1. **Function placement consideration**

The new write_txd() function is static inline and placed appropriately before its first use. Good.

2. **Consistency improvement**

The patch consistently replaces three separate direct descriptor write locations with the unified write_txd() function, improving maintainability.

### Technical Observations

1. The use of RTE_CAST_PTR to remove volatile and then using __rte_assume_aligned is a clean way to handle the cast while providing alignment hints to the compiler.

2. The byte-ordering conversion (rte_cpu_to_le_64) is correctly moved into the write_txd() function, which centralizes this logic.

3. The change from:

   ```c
   ctx_txd[0] = cd_qw0;
   ctx_txd[1] = cd_qw1;
   ```
   to:
   ```c
   write_txd(ctx_txd, cd_qw0, cd_qw1);
   ```

Note that the original code did NOT have rte_cpu_to_le_64() on the context descriptor writes, but the new write_txd() function adds it. This could be a behavioral change if cd_qw0 and cd_qw1 were already in little-endian format.

### Potential Issue

**Warning: Possible double byte-swap for context descriptors**

Looking at line 315 where write_txd(ctx_txd, cd_qw0, cd_qw1) is called - the original code did not apply rte_cpu_to_le_64() to cd_qw0 and cd_qw1. If these values are already constructed in little-endian format elsewhere, the new code would incorrectly byte-swap them on big-endian systems.

The reviewer should verify that cd_qw0 and cd_qw1 are constructed in host byte order and need conversion, or if they're already in little-endian and this introduces a bug.

### Summary

The patch is generally well-formed and follows DPDK conventions. The main concern is verifying that the byte-ordering change for context descriptors (ctx_txd) is intentional and correct.

=== Patch 22/36 ===

## DPDK Patch Review: net/intel: remove unnecessary flag clearing

### Overall Assessment
This patch is well-structured and follows DPDK guidelines. It removes unnecessary code that clears a flag during Tx ring cleanup, with the rationale that the flag will be automatically cleared during subsequent descriptor writes.

---

### Commit Message Review

**No issues found.**

- **Subject line**: "net/intel: remove unnecessary flag clearing" (45 characters) ✓
- **Format**: Correct prefix net/intel:, lowercase, imperative mood, no trailing period ✓
- **Body**: Clearly explains what is being removed and why (performance benefit) ✓
- **Line length**: Body lines are within 75 characters ✓
- **Signed-off-by**: Present with proper format ✓

---

### Code Review

**No issues found.**

The change is straightforward and correct:
- Removes a memset-style zeroing operation (txd[desc_to_clean_to].cmd_type_offset_bsz = 0) that is unnecessary
- The removed comment correctly explains the original intent, and the commit message explains why this is no longer needed
- The logic for updating last_desc_cleaned and nb_tx_free is preserved

---

### License/Copyright

**Not applicable** - This patch only modifies existing code; no new files are added, so no SPDX or copyright changes are expected.

---

### Documentation

**Info**: The patch claims "a small performance benefit" - while release notes are not strictly required for performance optimizations in internal code paths, if this is part of a larger series with measurable performance improvements, consider documenting the cumulative benefit in the release notes for the series.

---

### Summary

This is a clean patch that removes unnecessary code. No errors or warnings.

=== Patch 23/36 ===

## DPDK Patch Review: net/intel: mark mid-burst ring cleanup as unlikely

### Summary
This patch adds an unlikely() hint to a conditional check in the transmit path to help branch prediction when the descriptor ring cleanup is needed mid-burst.

---

### Errors
None identified.

---

### Warnings
None identified.

---

### Info

1. **Simple and focused change**: This is a straightforward performance optimization that adds appropriate branch prediction hints. The rationale in the commit message is clear - mid-burst cleanup should be rare, so marking it unlikely is sensible.

2. **Commit message is well-formed**:
- Subject line: "net/intel: mark mid-burst ring cleanup as unlikely" (52 characters, within limit)
- Proper component prefix (net/intel:)
- Lowercase after colon
- Imperative mood
- Body explains the "why" concisely
- Signed-off-by present with valid name and email

3. **Code change is appropriate**: The unlikely() macro is the standard DPDK way to provide branch hints, and the usage here follows the pattern of wrapping a comparison with explicit operators (>), which is correct.

---

### Verdict
This patch appears to comply with DPDK coding standards and contribution guidelines. The change is minimal, well-justified, and correctly implemented.

=== Patch 24/36 ===

## Review of Patch 24/36: net/intel: add special handling for single desc packets

### Overall Assessment
This patch adds an optimization for single-descriptor packets without TSO. The implementation is functional but has some style issues.

---

### Errors

None identified.

---

### Warnings

1. **Variable declaration after statement (C99 style in middle of block)**

   ```c
   const uint64_t cmd_type_offset_bsz = CI_TX_DESC_DTYPE_DATA |
   ```
   This declaration appears after executable statements within the same block (`if (txe->mbuf)` and the assignment to `*txe`). While C99 allows this, DPDK style prefers declarations at the start of a block or using an inner block. Consider:
   ```c
   if (nb_used == 1 && ...) {
       uint64_t cmd_type_offset_bsz;
       
       txd = &ci_tx_ring[tx_id];
       /* ... */
       cmd_type_offset_bsz = CI_TX_DESC_DTYPE_DATA | ...;
   }
   ```

2. **Use of goto for control flow**
The goto end_pkt; pattern, while sometimes acceptable for error handling, is used here as a shortcut past the normal path. This is a minor readability concern, though it may be justified for performance in a hot path. Consider documenting why this approach was chosen if it's performance-critical.

3. **Line length close to limit**
The lines building cmd_type_offset_bsz are long (around 75-80 characters), which is acceptable but approaches readability limits. The formatting is adequate.

---

### Info

1. **Comment style suggestion**
The comment /* special case for single descriptor packet, without TSO offload */ could end with a period for consistency with multi-line comment style, though single-line comments without periods are acceptable.

2. **Compound literal for structure assignment**
The use of a compound literal for *txe assignment is clean and modern C:

   ```c
   *txe = (struct ci_tx_entry){
       .mbuf = tx_pkt, .last_id = tx_last, .next_id = tx_id
   };
   ```

This is good practice with designated initializers.

3. **Label placement**
The end_pkt: label placement is correct, appearing at the appropriate indentation level before the common exit code.

---

### Summary

The patch is acceptable. The main concern is the variable declaration style within the conditional block, which could be improved for clarity. The goto usage is a debatable style choice but is a common pattern in performance-critical packet processing code. The commit message is clear and the implementation appears correct for the stated optimization goal.

=== Patch 25/36 ===

## Code Review: Patch 25/36 - net/intel: use separate array for desc status tracking

### Overview
This patch changes the TX descriptor status tracking mechanism to use a separate array indexed by RS threshold boundaries instead of storing last_id in each software ring entry.

### Errors

1. **Variable declaration in middle of block after statements (C99 style inconsistency)**

In ci_xmit_pkts() function in tx_scalar_fns.h:

   ```c
   txq->nb_tx_free = (uint16_t)(txq->nb_tx_free - nb_used);

   /* Check if packet crosses into a new RS threshold bucket... */
   uint16_t next_rs_idx = ((tx_last + 1) >> txq->log2_rs_thresh);
   ```

While C99 allows this, mixing declaration styles within the same function (declarations at start and in the middle) can reduce consistency. More importantly, pkt_rs_idx is declared at line ~219 inside the loop, which is fine, but the pattern should be consistent.

2. **Missing sw_ring free in error path for cpfl**

In cpfl_tx_queue_setup(), the error handling at err_rs_last_id_alloc correctly frees sw_ring, but this wasn't in the original error path - good catch on fixing this.

### Warnings

1. **Implicit assumption that nb_desc is a power of 2**

The RS bucket calculation assumes nb_desc / tx_rs_thresh divides evenly. While tx_rs_thresh is now required to be power-of-2, the code should verify nb_desc is also suitable. Looking at the checks:

   ```c
   if (nb_desc % tx_rs_thresh != 0) {
       // error
   }
   ```

This check exists in some drivers but should be verified in all affected drivers to ensure num_rs_buckets calculation is correct.

2. **Inconsistent error handling patterns across drivers**

- i40e_rxtx.c: Calls i40e_tx_queue_release(txq) which will try to free rs_last_id even if allocation failed
- ice_rxtx.c: Same pattern with ice_tx_queue_release(txq)
- iavf_rxtx.c: Manually frees sw_ring and txq but doesn't call a release function

The release functions should handle NULL rs_last_id safely (which rte_free(NULL) does), but the inconsistency could lead to maintenance issues.

3. **Missing documentation update**

This is a significant change to the TX path algorithm. Consider adding or updating documentation about the RS threshold requirements (power-of-2 constraint) in the relevant driver documentation.

4. **Potential integer overflow in bucket index calculation**

In ci_tx_xmit_cleanup():

   ```c
   const uint16_t rs_idx = (last_desc_cleaned == nb_tx_desc - 1) ?
           0 :
           (last_desc_cleaned + 1) >> txq->log2_rs_thresh;
   ```

If last_desc_cleaned is UINT16_MAX (though unlikely given it's bounded by nb_tx_desc), adding 1 could overflow. The bounds should be safe given the context, but explicit casting or comments would clarify intent.

### Info

1. **Algorithm change is well-documented**

The commit message clearly explains the change from per-descriptor tracking to bucket-based tracking. The inline comments in ci_xmit_pkts() explaining the bucket crossing logic are helpful.

2. **Consistent field additions**

The new fields rs_last_id and log2_rs_thresh are added consistently to the ci_tx_queue structure and initialized across all affected drivers.

3. **Memory allocation uses appropriate socket**

All rte_zmalloc_socket() calls correctly use the socket_id parameter for NUMA-aware allocation.

4. **The removal of last_id assignments throughout the xmit loop**

The changes removing txe->last_id = tx_last; assignments are consistent with the new design where only RS boundary tracking is needed.

### Summary

The patch is well-structured and implements a cleaner tracking mechanism. The main concerns are:
- Ensuring error handling is consistent across all driver implementations
- Verifying the power-of-2 requirement for tx_rs_thresh is enforced in all code paths before this change takes effect
- The pattern of calling release functions during setup failures when allocations are partial needs careful review to ensure no double-frees or null pointer issues

=== Patch 26/36 ===

## Review of Patch 26/36: net/ixgbe: use separate array for desc status tracking

### Commit Message

**No Issues Found**

- Subject line: "net/ixgbe: use separate array for desc status tracking" (54 characters) ✓
- Correct component prefix net/ixgbe: ✓
- Lowercase after colon ✓
- Imperative mood ✓
- No trailing period ✓
- Body explains the change and its purpose ✓
- Signed-off-by present ✓

### Code Review

#### Errors

1. **Missing check for division by zero / invalid tx_rs_thresh**

   ```c
   uint16_t num_rs_buckets = nb_desc / tx_rs_thresh;
   ```

While there is a power-of-2 check added, if tx_rs_thresh is 0, this would cause division by zero. The existing validation should catch this, but it's worth verifying the check order.

2. **Potential integer overflow in rs_idx calculation**

   ```c
   const uint16_t rs_idx = (last_desc_cleaned == nb_tx_desc - 1) ?
           0 :
           (last_desc_cleaned + 1) >> txq->log2_rs_thresh;
   ```

When last_desc_cleaned equals nb_tx_desc - 1, the code returns 0. However, when it doesn't, (last_desc_cleaned + 1) could be nb_tx_desc, and the subsequent shift and array access txq->rs_last_id[rs_idx] should be validated to ensure it stays within bounds.

3. **Variable txp update logic may be incomplete**

   ```c
   if (next_rs_idx != pkt_rs_idx) {
       /* ... */
       txq->rs_last_id[pkt_rs_idx] = tx_last;
   } else
       txp = txd;
   ```

In the original code, when RS bit was set, txp = NULL was executed. The new code removes this, but txp is used later for setting IXGBE_TXD_CMD_RS on the last descriptor. This logic change needs verification that the transmit completion still works correctly.

#### Warnings

1. **Missing braces for multi-statement else block style**

   ```c
   if (next_rs_idx != pkt_rs_idx) {
       /* multiple statements */
   } else
       txp = txd;
   ```

Per coding style, when the if block has braces, the else block should also have braces for consistency.

2. **C99-style declaration in the middle of code block**

   ```c
   /* Track the RS threshold bucket at packet start */
   uint16_t pkt_rs_idx = (uint16_t)(tx_id >> txq->log2_rs_thresh);
   ```

While C99 declarations are acceptable, this is inconsistent with the existing code in this function which declares variables at the start of the function. Consider moving to function start or ensuring consistency.

3. **Implicit comparison with zero**

   ```c
   if (!(status & rte_cpu_to_le_32(IXGBE_TXD_STAT_DD)))
   ```

This is a bitwise operation result being used in a boolean context. While common, explicit comparison == 0 would be clearer.

4. **Array bounds validation for rs_last_id access**

   ```c
   status = txr[txq->rs_last_id[rs_idx]].wb.status;
   ```

The rs_idx calculation should be verified to never exceed num_rs_buckets - 1. Consider adding a bounds check or assertion in debug builds.

5. **Missing initialization of rs_last_id array values**
The array is allocated with rte_zmalloc_socket() which zeros it, but the cleanup function ixgbe_xmit_cleanup accesses txq->rs_last_id[rs_idx] which will be 0 initially. Verify this is safe for the first cleanup pass.

### Info

- The removal of txe->last_id assignments and nb_tx_to_clean calculation simplifies the code, assuming the bucket-based tracking is correct.
- The comment explaining the RS bit bucket logic is helpful for understanding the algorithm.

### Summary

The patch makes significant changes to the descriptor status tracking mechanism. The main concerns are around the txp handling logic change and ensuring array bounds are respected for rs_last_id accesses. The power-of-2 requirement for tx_rs_thresh is a reasonable addition to support the log2_rs_thresh optimization.

=== Patch 27/36 ===

## Review of Patch 27/36: net/intel: drop unused Tx queue used count

### Commit Message Analysis

**Subject Line:**
- "net/intel: drop unused Tx queue used count" = 45 characters ✓
- Lowercase after prefix ✓
- No trailing period ✓
- Imperative mood ✓

**Body:**
- Explains the rationale clearly
- Lines appear within 75 character limit ✓
- Does not start with "It" ✓
- Properly signed off ✓

### Issues Found

#### Errors

None identified.

#### Warnings

1. **Potential typo in commit message body:**
The commit message contains "ipdf driver" which should be "idpf driver" (line 2 of the second paragraph).

2. **Variable type mismatch in IDPF code:**
In drivers/net/intel/idpf/idpf_common_rxtx.c, the replacement code uses:

   ```c
   txq->rs_compl_count += nb_used;
   ```
   The original code used explicit casting:
   ```c
   txq->nb_tx_used = (uint16_t)(txq->nb_tx_used + nb_used);
   ```

If rs_compl_count is a different type than uint16_t, this could represent a change in overflow behavior. The review cannot determine the type of rs_compl_count from this patch alone, but this should be verified to ensure consistent behavior.

3. **Magic number in code:**
The threshold 32 in the IDPF split queue code:

   ```c
   if (txq->rs_compl_count >= 32) {
   ```

This magic number should ideally be a named constant for maintainability, though this is pre-existing code not introduced by this patch.

#### Info

1. **Clean refactoring:** The patch cleanly removes the nb_tx_used field from the structure and all its usages across multiple driver files. The IDPF splitq case appropriately repurposes an existing field (rs_compl_count) that was previously only used in vector code paths.

2. **No release notes needed:** This is an internal implementation change that doesn't affect the public API.

### Summary

The patch is well-structured and accomplishes its stated goal. The main concern is the typo "ipdf" in the commit message which should be corrected to "idpf". The code changes appear correct and consistent across all affected files.

=== Patch 28/36 ===

## Review of Patch 28/36: net/intel: remove index for tracking end of packet

### Commit Message

**Subject Line:**
- Length: 54 characters ✓
- Format: net/intel: remove index for tracking end of packet - proper prefix and lowercase ✓
- Imperative mood ✓
- No trailing period ✓

**Body:**
- Explains the change clearly - removing last_id field and using mbuf->next == NULL check instead
- Lines within 75 characters ✓
- Does not start with "It" ✓
- Signed-off-by present ✓

### Code Review

**Errors:** None identified.

**Warnings:**

1. **Inconsistent ternary expression style across files:**
- In i40e_rxtx.c: (swr_ring[tx_id].mbuf->next == NULL) ? 1 : 0
- In ice_rxtx.c, ixgbe_rxtx.c, iavf_rxtx.c: swr_ring[tx_id].mbuf->next == NULL ? 1 : 0

Some have parentheses around the condition, some don't. Should be consistent across all files.

2. **Inconsistent blank line placement:**
- In iavf_rxtx.c (lines ~3966-3969) and ice_rxtx.c (lines ~3206-3209) and ixgbe_rxtx.c (lines ~2413-2416): There's a blank line after swr_ring[tx_id].mbuf = NULL; before the closing brace
- In i40e_rxtx.c: No such blank line

Consistency within the patch would be preferred.

**Info:**

1. **Simplification opportunity:** The ternary condition ? 1 : 0 could be simplified to just (condition) since a boolean comparison already yields 0 or 1 in C. For example:

   ```c
   pkt_cnt += (swr_ring[tx_id].mbuf->next == NULL);
   ```

This is more idiomatic and slightly cleaner.

2. **Logic correctness:** The change correctly moves the mbuf->next check before rte_pktmbuf_free_seg() since the mbuf data is needed to determine if it's the last segment. This is a necessary reordering.

### Summary

The patch cleanly removes the last_id tracking mechanism and replaces it with a direct check of the mbuf's next pointer. The approach is sound - checking mbuf->next == NULL to identify the last segment of a packet is correct. The main suggestions are minor style consistency issues across the different driver files being modified.

=== Patch 29/36 ===

## Review of DPDK Patch 29/36: net/intel: merge ring writes in simple Tx for ice and i40e

### Commit Message Analysis

**Subject Line:**
- "net/intel: merge ring writes in simple Tx for ice and i40e" = 56 characters ✓
- Format and case are correct ✓
- Imperative mood ✓

**Body:**
- Clear description of the change
- Properly wrapped
- Signed-off-by present ✓

### Code Review

#### Errors

None identified.

#### Warnings

1. **Missing SPDX header in new header file content (tx_scalar_fns.h additions)**

While the file already exists, the new functions being added should maintain consistency. The file appears to already have proper SPDX licensing from a previous patch in the series - this is fine.

2. **Inconsistency between ICE_TD_CMD and CI_TX_DESC_CMD_DEFAULT**

In ice_rxtx.h, ICE_TD_CMD was defined as only CI_TX_DESC_CMD_EOP, but the new CI_TX_DESC_CMD_DEFAULT includes both CI_TX_DESC_CMD_ICRC | CI_TX_DESC_CMD_EOP. This changes the behavior for ICE vector paths:

   ```c
   // OLD ICE definition:
   #define ICE_TD_CMD  CI_TX_DESC_CMD_EOP
   
   // NEW common definition:
   #define CI_TX_DESC_CMD_DEFAULT (CI_TX_DESC_CMD_ICRC | CI_TX_DESC_CMD_EOP)
   ```

The i40e definition included ICRC, but ICE did not. This functional change should be explicitly mentioned in the commit message if intentional, or investigated if not. The ICE vector paths (ice_rxtx_vec_avx2.c, ice_rxtx_vec_avx512.c) now include ICRC when they previously did not.

3. **Removed function i40e_build_ctob may be needed elsewhere**

The function i40e_build_ctob was removed but it handles td_offset and td_tag parameters that the new common functions don't support. Verify this function isn't called from other code paths that need those parameters.

#### Info

1. **Good code consolidation**: The patch successfully merges identical code from ice and i40e drivers into a common implementation.

2. **Minor style inconsistency**: In the original i40e code:

   ```c
   mainpart = (nb_pkts & ((uint32_t) ~N_PER_LOOP_MASK));
   ```
   The new common code has slightly different spacing:
   ```c
   mainpart = nb_pkts & ((uint32_t)~N_PER_LOOP_MASK);
   ```

This is fine and actually cleaner.

3. **Removed comment in ice version**: The original ICE code had a comment explaining the loop:

   ```c
   /**
    * Process most of the packets in chunks of N pkts.  Any
    * leftover packets will get processed one at a time.
    */
   ```

This explanatory comment could be preserved in the common function for maintainability.

### Summary

The patch is well-structured for code consolidation. The main concern is the **behavioral change for ICE vector transmit paths** where CI_TX_DESC_CMD_ICRC is now being set when it wasn't before. This should be verified as intentional and documented in the commit message if it's a deliberate fix.

=== Patch 30/36 ===

## Review of Patch 30/36: net/intel: consolidate ice and i40e buffer free function

### Commit Message

**Subject Line**: net/intel: consolidate ice and i40e buffer free function
- Length: 56 characters ✓
- Format: Correct prefix, lowercase, imperative mood ✓
- No trailing period ✓

**Body**: Well-written explanation of the consolidation and notes that the i40e version with batching is used as the base.

**Tags**: Signed-off-by present ✓

### Code Review

#### drivers/net/intel/common/tx.h

The new constant definition is appropriate:

```c
#define CI_TX_MAX_FREE_BUF_SZ 64
```

#### drivers/net/intel/common/tx_scalar_fns.h - ci_tx_free_bufs()

**Warning: Double increment of txep in else branch**

In the non-fast-free path:

```c
} else {
    for (uint16_t i = 0; i < rs_thresh; ++i, ++txep)
        rte_prefetch0((txep + i)->mbuf);

    for (uint16_t i = 0; i < rs_thresh; ++i, ++txep) {
        rte_pktmbuf_free_seg(txep->mbuf);
        txep->mbuf = NULL;
    }
}
```

The first loop increments txep rs_thresh times, then the second loop starts from the wrong position. After the prefetch loop, txep points past the last element. This is a bug introduced during consolidation.

The original i40e code had the same structure, but looking at ice's original code, it correctly used separate index variables. This appears to be a latent bug carried over from i40e.

**Suggested fix**:

```c
} else {
    for (uint16_t i = 0; i < rs_thresh; i++)
        rte_prefetch0((txep + i)->mbuf);

    for (uint16_t i = 0; i < rs_thresh; ++i, ++txep) {
        rte_pktmbuf_free_seg(txep->mbuf);
        txep->mbuf = NULL;
    }
}
```

Remove ++txep from the prefetch loop (use only i for indexing).

**Info: Variable declaration style**

The function uses C99 style variable declarations inside for-loops (uint16_t i, uint16_t j), which is acceptable per guidelines.

**Info: Explicit NULL comparison**

```c
if (fast_free_mp) {
```

Could be if (fast_free_mp != NULL) for consistency with guidelines, though this is a minor style point since fast_free_mp is used as a boolean condition.

### Summary

**Errors**: None

**Warnings**:
1. **Bug in else branch**: The prefetch loop increments txep but shouldn't - this will cause the subsequent free loop to access memory beyond the intended range, potentially causing memory corruption or crashes. Remove ++txep from the prefetch for-loop.

**Info**:
1. Consider using explicit != NULL comparison for pointer check on line with if (fast_free_mp)

=== Patch 31/36 ===

## Patch Review: net/intel: complete merging simple Tx paths

### Commit Message

**No issues found.** The commit message is well-formed:
- Subject line is 47 characters, within the 60 character limit
- Correct prefix net/intel:
- Lowercase after colon
- Imperative mood, no trailing period
- Body adequately describes the change
- Signed-off-by present with valid format

### License/Copyright

**No issues.** This patch modifies existing files and does not add new files requiring SPDX headers.

### Code Style Issues

#### Errors

None identified.

#### Warnings

1. **Inconsistent alignment in function parameters** (tx_scalar_fns.h, lines 137-139 and 195-197):
The continuation lines use extra spaces for alignment which is fine, but the spacing is slightly inconsistent with typical DPDK style. This is minor.

2. **Implicit integer conversion** (tx_scalar_fns.h, line 208):

   ```c
   nb_pkts -= ret;
   ```

While technically fine since both are uint16_t, this differs from the original code which used explicit casts like nb_pkts = (uint16_t)(nb_pkts - ret). Consider maintaining consistency with surrounding code style.

3. **Missing explicit cast in RTE_MIN** (tx_scalar_fns.h, line 205):

   ```c
   uint16_t ret, num = RTE_MIN(nb_pkts, CI_TX_MAX_BURST);
   ```

The original i40e code used (uint16_t)RTE_MIN(...). While likely unnecessary if the macro handles this, consistency with the existing codebase is preferred.

### Functional Observations

1. **Register write macro change**: The original code used driver-specific macros (I40E_PCI_REG_WC_WRITE and ICE_PCI_REG_WC_WRITE), while the common code uses rte_write32_wc(). This appears intentional for the common path but should be verified that the semantics are identical.

2. **Code deduplication is correct**: The common ci_xmit_burst_simple and ci_xmit_pkts_simple functions properly consolidate the nearly-identical implementations from both drivers.

### Documentation

No documentation updates appear necessary for this internal refactoring.

### Summary

This patch is a straightforward code consolidation that moves duplicated Tx simple path code into a common header. The implementation is functionally equivalent to the original driver-specific versions. The patch is ready for merge with only minor style considerations noted above.

=== Patch 32/36 ===

## Review of DPDK Patch 32/36: net/intel: use non-volatile stores in simple Tx function

### Commit Message

**Subject Line:** net/intel: use non-volatile stores in simple Tx function
- Length: 54 characters ✓
- Format: Correct prefix and lowercase after colon ✓
- Imperative mood ✓
- No trailing period ✓

**Body:**
- Explains the change and motivation clearly ✓
- Lines within 75 characters ✓
- Does not start with "It" ✓

**Tags:**
- Signed-off-by present with valid format ✓

### Code Review

**File: drivers/net/intel/common/tx_scalar_fns.h**

#### Info: Code Simplification
The refactoring removes redundant ci_tx_fill_hw_ring_tx4() and ci_tx_fill_hw_ring_tx1() functions and consolidates them into calls to the existing write_txd() function. This is a good code deduplication.

#### Warning: Extra whitespace in write_txd()

```c
	uint64_t *txd_qw =  __rte_assume_aligned(RTE_CAST_PTR(void *, txd), 16);
```

There are two spaces between = and __rte_assume_aligned. Should be single space.

#### Warning: Trailing blank line in code block

```c
			write_txd(txdp + idx, rte_mbuf_data_iova(*(pkts + idx)),
				CI_TX_DESC_DTYPE_DATA |
				((uint64_t)CI_TX_DESC_CMD_DEFAULT << CI_TXD_QW1_CMD_S) |
				((uint64_t)(*(pkts + idx))->data_len << CI_TXD_QW1_TX_BUF_SZ_S));

		}
```

There is a trailing blank line before the closing brace in the leftover handling block.

#### Info: Long lines in function calls
The write_txd() calls have long lines due to the descriptor construction expressions. While these are within the 100-character limit, consider whether extracting the descriptor construction to a local variable would improve readability.

### Summary

The patch is well-structured and achieves its goal of consolidating descriptor writes through a single function to enable non-volatile stores. The changes are functionally correct and the commit message adequately explains the purpose.

**Errors:** None

**Warnings:**
1. Double space in write_txd() function at the assignment (line with uint64_t *txd_qw)
2. Extra blank line before closing brace in the leftover handling block

=== Patch 33/36 ===

## Review of Patch 33/36: net/intel: align scalar simple Tx path with vector logic

### Commit Message

**No Issues Found**

- Subject line: "net/intel: align scalar simple Tx path with vector logic" (59 characters) ✓
- Uses correct prefix format net/intel: ✓
- Lowercase after colon ✓
- Imperative mood ✓
- No trailing period ✓
- Body explains the rationale for the change ✓
- Signed-off-by present ✓

### Code Review

**No Errors or Warnings Found**

The patch makes reasonable changes to align the scalar simple Tx path with the vector logic:

1. **Function refactoring**: The ci_tx_fill_hw_ring() function is renamed to ci_tx_fill_hw_ring_simple() and now takes a txdp pointer directly instead of computing it from txq->tx_tail. This separates concerns appropriately.

2. **Backlog entry handling moved to caller**: The mbuf storage in the sw_ring (via ci_tx_backlog_entry()) is now done in ci_xmit_burst_simple() rather than inside the fill function. This matches the vector path approach.

3. **Local variable usage**: The function now uses a local tx_id variable rather than repeatedly accessing txq->tx_tail, which can improve performance.

4. **Removed unnecessary blank line**: Line 52 in the original had an extra blank line that was removed - this is correct cleanup.

5. **Logic preservation**: The RS (Report Status) bit setting logic and ring wraparound handling remain functionally equivalent while being restructured to match the vector path.

6. **Final write optimization**: The final rte_write32_wc() now uses tx_id directly rather than txq->tx_tail, which is consistent since tx_id has just been assigned to txq->tx_tail.

### Info

- The comment change from /* Fill hardware descriptor ring with mbuf data */ to /* Fill hardware descriptor ring with mbuf data (simple path) */ helps clarify this is for the simple path specifically, which is good documentation practice given the refactoring context.

=== Patch 34/36 ===

# Code Review: DPDK Patch 34/36

## Patch Overview
This patch renames the vector_tx flag to use_vec_entry to more accurately reflect its purpose - indicating use of the smaller tx_entry_vec structure. It also extends this flag's usage to the simple TX path for performance benefits.

## Review Items

### Commit Message
**Status: OK**

- Subject line: "net/intel: use vector SW ring entry for simple path" (53 characters) ✓
- Lowercase after prefix ✓
- Imperative mood ✓
- No trailing period ✓
- Body explains the change adequately ✓
- Signed-off-by present ✓

### Code Review

#### Info: Comment formatting inconsistency in tx.h

In drivers/net/intel/common/tx.h at line 368-370:

```c
	/**
	 *  vPMD tx will not set sw_ring's mbuf to NULL after free,
```

The /** style is typically for Doxygen documentation of APIs. For implementation comments, a regular /* would be more appropriate. This is minor and consistent with existing code, so just noting it.

#### Warning: Potential inconsistency in cpfl_tx_queue_release call

In drivers/net/intel/cpfl/cpfl_rxtx.c at line 329:

```c
	ci_txq_release_all_mbufs(q, q->use_vec_entry);
```

The function ci_txq_release_all_mbufs takes a use_ctx parameter (as seen in the header), but here it's being passed use_vec_entry. Looking at the original code, it was q->vector_tx. This appears to be passing the wrong semantic meaning - use_ctx likely refers to whether context descriptors are used, not whether vector entries are used.

However, reviewing the function signature in tx.h shows ci_txq_release_all_mbufs(struct ci_tx_queue *txq, bool use_ctx) - the parameter name suggests it's for context tracking. The patch doesn't modify this function's signature or semantics, so this may have been a pre-existing issue where vector_tx was being used to approximate use_ctx. This should be verified but is outside the scope of this patch.

#### Info: Boolean assignment style in ixgbe

In drivers/net/intel/ixgbe/ixgbe_rxtx_vec_common.c at line 114:

```c
-	txq->vector_tx = 1;
+	txq->use_vec_entry = true;
```

Good change - using true for a boolean field is cleaner than using 1.

### Code Correctness

The logic changes appear correct:
- i40e_rxtx.c and ice_rxtx.c now set use_vec_entry when either vector TX OR simple TX is allowed, which aligns with the stated purpose
- The simple TX path in tx_scalar_fns.h now uses sw_ring_vec and ci_tx_entry_vec types consistently
- The cleanup path in ci_txq_release_all_mbufs is updated to use the new flag name

### Documentation

No documentation updates required for this internal refactoring.

## Summary

**Errors**: None

**Warnings**: None identified as definitive issues

**Info**:
- The patch is a well-structured internal refactoring
- The rename from vector_tx to use_vec_entry improves code clarity by describing what the flag actually controls
- All usages are consistently updated across the affected drivers

The patch looks correct and ready for integration.

=== Patch 35/36 ===

## Review of Patch 35/36: net/intel: use vector mbuf cleanup from simple scalar path

### Commit Message Analysis

**Subject Line:**
- "net/intel: use vector mbuf cleanup from simple scalar path" = 58 characters ✓
- Proper prefix format ✓
- Lowercase after colon ✓
- Imperative mood ✓
- No trailing period ✓

**Body:**
- Explains the rationale clearly ✓
- Does not start with "It" ✓
- Properly signed off ✓

### Code Review

**Info: Good Code Consolidation**

This patch simplifies the codebase by removing the separate ci_tx_free_bufs() function (approximately 50 lines) and replacing it with a thin wrapper (ci_tx_free_bufs_simple()) that calls the existing vector cleanup function. This reduces code duplication, which is positive.

**File: drivers/net/intel/common/tx_scalar_fns.h**

1. **Style - Function declarations look correct:**
- ci_tx_desc_done_simple() - properly uses __rte_always_inline ✓
- ci_tx_free_bufs_simple() - properly uses __rte_always_inline ✓

2. **Line length check on lines 24-25:**

   ```c
   return (txq->ci_tx_ring[idx].cmd_type_offset_bsz & rte_cpu_to_le_64(CI_TXD_QW1_DTYPE_M)) ==
   		rte_cpu_to_le_64(CI_TX_DESC_DTYPE_DESC_DONE);
   ```

The first line appears to be around 95-100 characters which is within the 100 character limit. The continuation uses double-indent (tabs) which is correct for continuation lines. ✓

3. **No SPDX header visible in this diff** - This is a modification to an existing file, so the header should already be present at the top of the file. ✓

4. **Function comment style:**
- Line 29: /* Free transmitted mbufs using vector-style cleanup */ - Good single-line comment style ✓

5. **Dependency concern:** The new function ci_tx_free_bufs_simple() calls ci_tx_free_bufs_vec(). This implies ci_tx_free_bufs_vec() must be defined/declared before this header is included. Since this is patch 35/36 in a series, this dependency should have been established in earlier patches.

**Files: drivers/net/intel/i40e/i40e_rxtx.c and drivers/net/intel/ice/ice_rxtx.c**

The changes are straightforward function renames from ci_tx_free_bufs() to ci_tx_free_bufs_simple() - correct and consistent.

### Summary

**Errors:** None

**Warnings:** None

**Info:**
- This is a good refactoring patch that removes code duplication by leveraging existing vector cleanup infrastructure for the scalar path. The approach is sound and the implementation is clean.

=== Patch 36/36 ===

## Review of DPDK Patch: net/idpf: enable simple Tx function

### Commit Message

**No Issues Found**

- Subject line: "net/idpf: enable simple Tx function" (39 characters) ✓
- Lowercase after colon ✓
- Correct component prefix net/idpf: ✓
- Imperative mood ✓
- No trailing period ✓
- Body adequately describes the change ✓
- Signed-off-by present with valid format ✓

### Code Review

#### Errors

None identified.

#### Warnings

1. **Extra blank line in idpf_common_rxtx.c**

There are two consecutive blank lines after the idpf_dp_singleq_xmit_pkts_simple function (line 1357) and also after the IDPF_TX_SINGLEQ_SIMPLE entry (line 1552). DPDK style prefers single blank lines between functions/blocks.

   ```c
   }
   
   
   /* TX prep functions */
   ```
   Should be:
   ```c
   }
   
   /* TX prep functions */
   ```

2. **Inconsistent alignment in function parameter**

In idpf_common_rxtx.c line 1350-1351, the continuation line uses extra spaces for alignment:

   ```c
   idpf_dp_singleq_xmit_pkts_simple(void *tx_queue, struct rte_mbuf **tx_pkts,
   				   uint16_t nb_pkts)
   ```

The same inconsistent alignment appears in the header file declaration. The parameters should align consistently with the opening parenthesis or use standard double-indent for continuation.

3. **Missing release notes**

This patch adds new functionality (simple Tx support for idpf driver). Consider adding a note to the release notes for this feature enhancement, as it's a user-visible performance optimization path.

#### Info

1. **Comment style suggestion**

In idpf_rxtx.c lines 512-515, the comment block could use the multi-line format:

   ```c
   /*
    * Set tx_simple_allowed flag based on queue configuration.
    * For queue 0: explicitly set the flag based on its configuration.
    * For other queues: only set to false if this queue cannot use simple_tx.
    */
   ```

This is a minor style preference - the current format is acceptable.

2. **goto label naming**

The goto out; at line 524 jumps to out: at line 528, but this label only precedes a return 0;. While functional, this could be simplified to just return 0; directly, avoiding the goto. However, this may be intentional for future extensibility or consistency with other queue setup functions.

### Summary

The patch is well-structured and follows DPDK conventions. The main issues are minor style inconsistencies (extra blank lines and parameter alignment). The code logic for enabling the simple Tx path based on queue configuration appears correct.

#130 lore raw

v4 cover combine multiple Intel scalar Tx paths

In reply to Bruce Richardson

The scalar Tx paths, with support for offloads and multiple mbufs per packet, are almost identical across drivers ice, i40e, iavf and the single-queue mode of idpf. Therefore, we can do some rework to combine these code paths into a single function which is parameterized by compile-time constants, allowing code saving to give us a single path to optimize and maintain - apart from edge cases like IPSec support in iavf.

The ixgbe driver has a number of similarities too, which we take advantage of where we can, but the overall descriptor format is sufficiently different that its main scalar code path is kept separate.

Once merged, we can then optimize the drivers a bit to improve performance, and also easily extend some drivers to use additional paths for better performance, e.g. add the "simple scalar" path to IDPF driver for better performance on platforms without AVX.

V4:
- Updates following review:
- merged patches 3 and 5
- renamed new file to tx_scalar.h
- added UDP_TSO flag to drivers
- other minor fixups

V3:
- rebase on top of latest next-net-intel tree
- fix issues with iavf and cpfl drivers seen in some testing

V2:
- reworked the simple-scalar path as well as full scalar one
- added simple scalar path support to idpf driver
- small cleanups, e.g. issues flagged by checkpatch

Bruce Richardson (35):
net/intel: create common Tx descriptor structure net/intel: use common Tx ring structure net/intel: create common post-Tx cleanup function net/intel: consolidate definitions for Tx desc fields net/intel: add common fn to calculate needed descriptors net/ice: refactor context descriptor handling net/i40e: refactor context descriptor handling net/idpf: refactor context descriptor handling net/intel: consolidate checksum mask definition net/intel: create common checksum Tx offload function net/intel: create a common scalar Tx function net/i40e: use common scalar Tx function net/intel: add IPsec hooks to common Tx function net/intel: support configurable VLAN tag insertion on Tx net/iavf: use common scalar Tx function net/i40e: document requirement for QinQ support net/idpf: use common scalar Tx function net/intel: avoid writing the final pkt descriptor twice
eal: add macro for marking assumed alignment net/intel: write descriptors using non-volatile pointers net/intel: remove unnecessary flag clearing net/intel: mark mid-burst ring cleanup as unlikely net/intel: add special handling for single desc packets net/intel: use separate array for desc status tracking net/ixgbe: use separate array for desc status tracking net/intel: drop unused Tx queue used count net/intel: remove index for tracking end of packet net/intel: merge ring writes in simple Tx for ice and i40e net/intel: consolidate ice and i40e buffer free function net/intel: complete merging simple Tx paths net/intel: use non-volatile stores in simple Tx function net/intel: align scalar simple Tx path with vector logic net/intel: use vector SW ring entry for simple path net/intel: use vector mbuf cleanup from simple scalar path net/idpf: enable simple Tx function

 doc/guides/nics/i40e.rst                      |  18 +
 drivers/net/intel/common/tx.h                 | 117 ++-
 drivers/net/intel/common/tx_scalar.h          | 593 ++++++++++++++
 drivers/net/intel/cpfl/cpfl_rxtx.c            |  25 +-
 drivers/net/intel/i40e/i40e_fdir.c            |  34 +-
 drivers/net/intel/i40e/i40e_rxtx.c            | 673 +++-------------
 drivers/net/intel/i40e/i40e_rxtx.h            |  17 +-
 .../net/intel/i40e/i40e_rxtx_vec_altivec.c    |  25 +-
 drivers/net/intel/i40e/i40e_rxtx_vec_avx2.c   |  36 +-
 drivers/net/intel/i40e/i40e_rxtx_vec_avx512.c |  52 +-
 drivers/net/intel/i40e/i40e_rxtx_vec_common.h |   6 +-
 drivers/net/intel/i40e/i40e_rxtx_vec_neon.c   |  25 +-
 drivers/net/intel/iavf/iavf_rxtx.c            | 642 ++++-----------
 drivers/net/intel/iavf/iavf_rxtx.h            |  31 +-
 drivers/net/intel/iavf/iavf_rxtx_vec_avx2.c   |  55 +-
 drivers/net/intel/iavf/iavf_rxtx_vec_avx512.c | 104 +--
 drivers/net/intel/iavf/iavf_rxtx_vec_common.h |  36 +-
 drivers/net/intel/ice/ice_dcf_ethdev.c        |  10 +-
 drivers/net/intel/ice/ice_rxtx.c              | 740 ++++--------------
 drivers/net/intel/ice/ice_rxtx.h              |  16 +-
 drivers/net/intel/ice/ice_rxtx_vec_avx2.c     |  55 +-
 drivers/net/intel/ice/ice_rxtx_vec_avx512.c   |  53 +-
 drivers/net/intel/ice/ice_rxtx_vec_common.h   |  43 +-
 drivers/net/intel/idpf/idpf_common_device.h   |   2 +
 drivers/net/intel/idpf/idpf_common_rxtx.c     | 314 ++------
 drivers/net/intel/idpf/idpf_common_rxtx.h     |  24 +-
 .../net/intel/idpf/idpf_common_rxtx_avx2.c    |  53 +-
 .../net/intel/idpf/idpf_common_rxtx_avx512.c  |  55 +-
 drivers/net/intel/idpf/idpf_rxtx.c            |  43 +-
 drivers/net/intel/idpf/idpf_rxtx_vec_common.h |   6 +-
 drivers/net/intel/ixgbe/ixgbe_rxtx.c          | 103 ++-
 .../net/intel/ixgbe/ixgbe_rxtx_vec_common.c   |   3 +-
 lib/eal/include/rte_common.h                  |   6 +
 33 files changed, 1579 insertions(+), 2436 deletions(-)
 create mode 100644 drivers/net/intel/common/tx_scalar.h

--
2.51.0

#131 lore raw

PATCH v4 1/35 net/intel: create common Tx descriptor structure

The Tx descriptors used by the i40e, iavf, ice and idpf drivers are all identical 16-byte descriptors, so define a common struct for them. Since original struct definitions are in base code, leave them in place, but only use the new structs in DPDK code.

---
 drivers/net/intel/common/tx.h                 | 16 ++++++---
 drivers/net/intel/cpfl/cpfl_rxtx.c            |  2 +-
 drivers/net/intel/i40e/i40e_fdir.c            |  4 +--
 drivers/net/intel/i40e/i40e_rxtx.c            | 26 +++++++-------
 .../net/intel/i40e/i40e_rxtx_vec_altivec.c    |  6 ++--
 drivers/net/intel/i40e/i40e_rxtx_vec_avx2.c   |  6 ++--
 drivers/net/intel/i40e/i40e_rxtx_vec_avx512.c |  6 ++--
 drivers/net/intel/i40e/i40e_rxtx_vec_neon.c   |  6 ++--
 drivers/net/intel/iavf/iavf_rxtx.c            | 16 ++++-----
 drivers/net/intel/iavf/iavf_rxtx.h            |  2 +-
 drivers/net/intel/iavf/iavf_rxtx_vec_avx2.c   |  6 ++--
 drivers/net/intel/iavf/iavf_rxtx_vec_avx512.c | 12 +++----
 drivers/net/intel/ice/ice_dcf_ethdev.c        |  2 +-
 drivers/net/intel/ice/ice_rxtx.c              | 36 +++++++++----------
 drivers/net/intel/ice/ice_rxtx_vec_avx2.c     |  6 ++--
 drivers/net/intel/ice/ice_rxtx_vec_avx512.c   |  6 ++--
 drivers/net/intel/idpf/idpf_common_rxtx.c     | 20 +++++------
 drivers/net/intel/idpf/idpf_common_rxtx.h     |  2 +-
 .../net/intel/idpf/idpf_common_rxtx_avx2.c    |  8 ++---
 .../net/intel/idpf/idpf_common_rxtx_avx512.c  |  8 ++---
 drivers/net/intel/idpf/idpf_rxtx.c            |  2 +-
 drivers/net/intel/idpf/idpf_rxtx_vec_common.h |  2 +-
 22 files changed, 104 insertions(+), 96 deletions(-)
drivers/net/intel/common/tx.h +12 -4
index e295d83e3a..d7561a2bbb 100644
@@ -10,6 +10,14 @@
 #include <rte_ethdev.h>
 #include <rte_vect.h>
 
+/*
+ * Structure of a 16-byte Tx descriptor common across i40e, ice, iavf and idpf drivers
+ */
+struct ci_tx_desc {
+	uint64_t buffer_addr; /* Address of descriptor's data buf */
+	uint64_t cmd_type_offset_bsz;
+};
+
 /* forward declaration of the common intel (ci) queue structure */
 struct ci_tx_queue;
 
@@ -33,10 +41,10 @@ typedef void (*ice_tx_release_mbufs_t)(struct ci_tx_queue *txq);
 
 struct ci_tx_queue {
 	union { /* TX ring virtual address */
-		volatile struct i40e_tx_desc *i40e_tx_ring;
-		volatile struct iavf_tx_desc *iavf_tx_ring;
-		volatile struct ice_tx_desc *ice_tx_ring;
-		volatile struct idpf_base_tx_desc *idpf_tx_ring;
+		volatile struct ci_tx_desc *i40e_tx_ring;
+		volatile struct ci_tx_desc *iavf_tx_ring;
+		volatile struct ci_tx_desc *ice_tx_ring;
+		volatile struct ci_tx_desc *idpf_tx_ring;
 		volatile union ixgbe_adv_tx_desc *ixgbe_tx_ring;
 	};
 	volatile uint8_t *qtx_tail;               /* register address of tail */
drivers/net/intel/cpfl/cpfl_rxtx.c +1 -1
index d0438b5da0..78bc3e9b49 100644
@@ -131,7 +131,7 @@ cpfl_dma_zone_reserve(struct rte_eth_dev *dev, uint16_t queue_idx,
 			ring_size = RTE_ALIGN(len * sizeof(struct idpf_flex_tx_sched_desc),
 					      CPFL_DMA_MEM_ALIGN);
 		else
-			ring_size = RTE_ALIGN(len * sizeof(struct idpf_base_tx_desc),
+			ring_size = RTE_ALIGN(len * sizeof(struct ci_tx_desc),
 					      CPFL_DMA_MEM_ALIGN);
 		memcpy(ring_name, "cpfl Tx ring", sizeof("cpfl Tx ring"));
 		break;
drivers/net/intel/i40e/i40e_fdir.c +2 -2
index 55d18c5d4a..605df73c9e 100644
@@ -1377,7 +1377,7 @@ i40e_find_available_buffer(struct rte_eth_dev *dev)
 	 */
 	if (fdir_info->txq_available_buf_count <= 0) {
 		uint16_t tmp_tail;
-		volatile struct i40e_tx_desc *tmp_txdp;
+		volatile struct ci_tx_desc *tmp_txdp;
 
 		tmp_tail = txq->tx_tail;
 		tmp_txdp = &txq->i40e_tx_ring[tmp_tail + 1];
@@ -1628,7 +1628,7 @@ i40e_flow_fdir_filter_programming(struct i40e_pf *pf,
 	struct ci_tx_queue *txq = pf->fdir.txq;
 	struct ci_rx_queue *rxq = pf->fdir.rxq;
 	const struct i40e_fdir_action *fdir_action = &filter->action;
-	volatile struct i40e_tx_desc *txdp;
+	volatile struct ci_tx_desc *txdp;
 	volatile struct i40e_filter_program_desc *fdirdp;
 	uint32_t td_cmd;
 	uint16_t vsi_id;
drivers/net/intel/i40e/i40e_rxtx.c +13 -13
index 1c3586778c..92d49ccb79 100644
@@ -388,7 +388,7 @@ static inline int
 i40e_xmit_cleanup(struct ci_tx_queue *txq)
 {
 	struct ci_tx_entry *sw_ring = txq->sw_ring;
-	volatile struct i40e_tx_desc *txd = txq->i40e_tx_ring;
+	volatile struct ci_tx_desc *txd = txq->i40e_tx_ring;
 	uint16_t last_desc_cleaned = txq->last_desc_cleaned;
 	uint16_t nb_tx_desc = txq->nb_tx_desc;
 	uint16_t desc_to_clean_to;
@@ -1092,8 +1092,8 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 	struct ci_tx_queue *txq;
 	struct ci_tx_entry *sw_ring;
 	struct ci_tx_entry *txe, *txn;
-	volatile struct i40e_tx_desc *txd;
-	volatile struct i40e_tx_desc *txr;
+	volatile struct ci_tx_desc *txd;
+	volatile struct ci_tx_desc *txr;
 	struct rte_mbuf *tx_pkt;
 	struct rte_mbuf *m_seg;
 	uint32_t cd_tunneling_params;
@@ -1398,7 +1398,7 @@ i40e_tx_free_bufs(struct ci_tx_queue *txq)
 
 /* Populate 4 descriptors with data from 4 mbufs */
 static inline void
-tx4(volatile struct i40e_tx_desc *txdp, struct rte_mbuf **pkts)
+tx4(volatile struct ci_tx_desc *txdp, struct rte_mbuf **pkts)
 {
 	uint64_t dma_addr;
 	uint32_t i;
@@ -1414,7 +1414,7 @@ tx4(volatile struct i40e_tx_desc *txdp, struct rte_mbuf **pkts)
 
 /* Populate 1 descriptor with data from 1 mbuf */
 static inline void
-tx1(volatile struct i40e_tx_desc *txdp, struct rte_mbuf **pkts)
+tx1(volatile struct ci_tx_desc *txdp, struct rte_mbuf **pkts)
 {
 	uint64_t dma_addr;
 
@@ -1431,7 +1431,7 @@ i40e_tx_fill_hw_ring(struct ci_tx_queue *txq,
 		     struct rte_mbuf **pkts,
 		     uint16_t nb_pkts)
 {
-	volatile struct i40e_tx_desc *txdp = &txq->i40e_tx_ring[txq->tx_tail];
+	volatile struct ci_tx_desc *txdp = &txq->i40e_tx_ring[txq->tx_tail];
 	struct ci_tx_entry *txep = &txq->sw_ring[txq->tx_tail];
 	const int N_PER_LOOP = 4;
 	const int N_PER_LOOP_MASK = N_PER_LOOP - 1;
@@ -1459,7 +1459,7 @@ tx_xmit_pkts(struct ci_tx_queue *txq,
 	     struct rte_mbuf **tx_pkts,
 	     uint16_t nb_pkts)
 {
-	volatile struct i40e_tx_desc *txr = txq->i40e_tx_ring;
+	volatile struct ci_tx_desc *txr = txq->i40e_tx_ring;
 	uint16_t n = 0;
 
 	/**
@@ -2616,7 +2616,7 @@ i40e_dev_tx_queue_setup(struct rte_eth_dev *dev,
 	}
 
 	/* Allocate TX hardware ring descriptors. */
-	ring_size = sizeof(struct i40e_tx_desc) * I40E_MAX_RING_DESC;
+	ring_size = sizeof(struct ci_tx_desc) * I40E_MAX_RING_DESC;
 	ring_size = RTE_ALIGN(ring_size, I40E_DMA_MEM_ALIGN);
 	tz = rte_eth_dma_zone_reserve(dev, "i40e_tx_ring", queue_idx,
 			      ring_size, I40E_RING_BASE_ALIGN, socket_id);
@@ -2640,7 +2640,7 @@ i40e_dev_tx_queue_setup(struct rte_eth_dev *dev,
 	txq->tx_deferred_start = tx_conf->tx_deferred_start;
 
 	txq->tx_ring_dma = tz->iova;
-	txq->i40e_tx_ring = (struct i40e_tx_desc *)tz->addr;
+	txq->i40e_tx_ring = (struct ci_tx_desc *)tz->addr;
 
 	/* Allocate software ring */
 	txq->sw_ring =
@@ -2913,13 +2913,13 @@ i40e_reset_tx_queue(struct ci_tx_queue *txq)
 	}
 
 	txe = txq->sw_ring;
-	size = sizeof(struct i40e_tx_desc) * txq->nb_tx_desc;
+	size = sizeof(struct ci_tx_desc) * txq->nb_tx_desc;
 	for (i = 0; i < size; i++)
 		((volatile char *)txq->i40e_tx_ring)[i] = 0;
 
 	prev = (uint16_t)(txq->nb_tx_desc - 1);
 	for (i = 0; i < txq->nb_tx_desc; i++) {
-		volatile struct i40e_tx_desc *txd = &txq->i40e_tx_ring[i];
+		volatile struct ci_tx_desc *txd = &txq->i40e_tx_ring[i];
 
 		txd->cmd_type_offset_bsz =
 			rte_cpu_to_le_64(I40E_TX_DESC_DTYPE_DESC_DONE);
@@ -3221,7 +3221,7 @@ i40e_fdir_setup_tx_resources(struct i40e_pf *pf)
 	}
 
 	/* Allocate TX hardware ring descriptors. */
-	ring_size = sizeof(struct i40e_tx_desc) * I40E_FDIR_NUM_TX_DESC;
+	ring_size = sizeof(struct ci_tx_desc) * I40E_FDIR_NUM_TX_DESC;
 	ring_size = RTE_ALIGN(ring_size, I40E_DMA_MEM_ALIGN);
 
 	tz = rte_eth_dma_zone_reserve(dev, "fdir_tx_ring",
@@ -3240,7 +3240,7 @@ i40e_fdir_setup_tx_resources(struct i40e_pf *pf)
 	txq->i40e_vsi = pf->fdir.fdir_vsi;
 
 	txq->tx_ring_dma = tz->iova;
-	txq->i40e_tx_ring = (struct i40e_tx_desc *)tz->addr;
+	txq->i40e_tx_ring = (struct ci_tx_desc *)tz->addr;
 
 	/*
 	 * don't need to allocate software ring and reset for the fdir
drivers/net/intel/i40e/i40e_rxtx_vec_altivec.c +3 -3
index bbb6d907cf..ef5b252898 100644
@@ -446,7 +446,7 @@ i40e_recv_scattered_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
 }
 
 static inline void
-vtx1(volatile struct i40e_tx_desc *txdp,
+vtx1(volatile struct ci_tx_desc *txdp,
 	struct rte_mbuf *pkt, uint64_t flags)
 {
 	uint64_t high_qw = (I40E_TX_DESC_DTYPE_DATA |
@@ -459,7 +459,7 @@ vtx1(volatile struct i40e_tx_desc *txdp,
 }
 
 static inline void
-vtx(volatile struct i40e_tx_desc *txdp,
+vtx(volatile struct ci_tx_desc *txdp,
 	struct rte_mbuf **pkt, uint16_t nb_pkts,  uint64_t flags)
 {
 	int i;
@@ -473,7 +473,7 @@ i40e_xmit_fixed_burst_vec(void *tx_queue, struct rte_mbuf **tx_pkts,
 			  uint16_t nb_pkts)
 {
 	struct ci_tx_queue *txq = (struct ci_tx_queue *)tx_queue;
-	volatile struct i40e_tx_desc *txdp;
+	volatile struct ci_tx_desc *txdp;
 	struct ci_tx_entry_vec *txep;
 	uint16_t n, nb_commit, tx_id;
 	uint64_t flags = I40E_TD_CMD;
drivers/net/intel/i40e/i40e_rxtx_vec_avx2.c +3 -3
index 4e398b3140..137c1f9765 100644
@@ -681,7 +681,7 @@ i40e_recv_scattered_pkts_vec_avx2(void *rx_queue, struct rte_mbuf **rx_pkts,
 
 
 static inline void
-vtx1(volatile struct i40e_tx_desc *txdp,
+vtx1(volatile struct ci_tx_desc *txdp,
 		struct rte_mbuf *pkt, uint64_t flags)
 {
 	uint64_t high_qw = (I40E_TX_DESC_DTYPE_DATA |
@@ -694,7 +694,7 @@ vtx1(volatile struct i40e_tx_desc *txdp,
 }
 
 static inline void
-vtx(volatile struct i40e_tx_desc *txdp,
+vtx(volatile struct ci_tx_desc *txdp,
 		struct rte_mbuf **pkt, uint16_t nb_pkts,  uint64_t flags)
 {
 	const uint64_t hi_qw_tmpl = (I40E_TX_DESC_DTYPE_DATA |
@@ -739,7 +739,7 @@ i40e_xmit_fixed_burst_vec_avx2(void *tx_queue, struct rte_mbuf **tx_pkts,
 			  uint16_t nb_pkts)
 {
 	struct ci_tx_queue *txq = (struct ci_tx_queue *)tx_queue;
-	volatile struct i40e_tx_desc *txdp;
+	volatile struct ci_tx_desc *txdp;
 	struct ci_tx_entry_vec *txep;
 	uint16_t n, nb_commit, tx_id;
 	uint64_t flags = I40E_TD_CMD;
drivers/net/intel/i40e/i40e_rxtx_vec_avx512.c +3 -3
index 571987d27a..6971488750 100644
@@ -750,7 +750,7 @@ i40e_recv_scattered_pkts_vec_avx512(void *rx_queue,
 }
 
 static inline void
-vtx1(volatile struct i40e_tx_desc *txdp, struct rte_mbuf *pkt, uint64_t flags)
+vtx1(volatile struct ci_tx_desc *txdp, struct rte_mbuf *pkt, uint64_t flags)
 {
 	uint64_t high_qw = (I40E_TX_DESC_DTYPE_DATA |
 		((uint64_t)flags  << I40E_TXD_QW1_CMD_SHIFT) |
@@ -762,7 +762,7 @@ vtx1(volatile struct i40e_tx_desc *txdp, struct rte_mbuf *pkt, uint64_t flags)
 }
 
 static inline void
-vtx(volatile struct i40e_tx_desc *txdp,
+vtx(volatile struct ci_tx_desc *txdp,
 	struct rte_mbuf **pkt, uint16_t nb_pkts,  uint64_t flags)
 {
 	const uint64_t hi_qw_tmpl = (I40E_TX_DESC_DTYPE_DATA |
@@ -807,7 +807,7 @@ i40e_xmit_fixed_burst_vec_avx512(void *tx_queue, struct rte_mbuf **tx_pkts,
 				 uint16_t nb_pkts)
 {
 	struct ci_tx_queue *txq = (struct ci_tx_queue *)tx_queue;
-	volatile struct i40e_tx_desc *txdp;
+	volatile struct ci_tx_desc *txdp;
 	struct ci_tx_entry_vec *txep;
 	uint16_t n, nb_commit, tx_id;
 	uint64_t flags = I40E_TD_CMD;
drivers/net/intel/i40e/i40e_rxtx_vec_neon.c +3 -3
index b5be0c1b59..6404b70c56 100644
@@ -597,7 +597,7 @@ i40e_recv_scattered_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
 }
 
 static inline void
-vtx1(volatile struct i40e_tx_desc *txdp,
+vtx1(volatile struct ci_tx_desc *txdp,
 		struct rte_mbuf *pkt, uint64_t flags)
 {
 	uint64_t high_qw = (I40E_TX_DESC_DTYPE_DATA |
@@ -609,7 +609,7 @@ vtx1(volatile struct i40e_tx_desc *txdp,
 }
 
 static inline void
-vtx(volatile struct i40e_tx_desc *txdp, struct rte_mbuf **pkt,
+vtx(volatile struct ci_tx_desc *txdp, struct rte_mbuf **pkt,
 		uint16_t nb_pkts,  uint64_t flags)
 {
 	int i;
@@ -623,7 +623,7 @@ i40e_xmit_fixed_burst_vec(void *__rte_restrict tx_queue,
 	struct rte_mbuf **__rte_restrict tx_pkts, uint16_t nb_pkts)
 {
 	struct ci_tx_queue *txq = (struct ci_tx_queue *)tx_queue;
-	volatile struct i40e_tx_desc *txdp;
+	volatile struct ci_tx_desc *txdp;
 	struct ci_tx_entry_vec *txep;
 	uint16_t n, nb_commit, tx_id;
 	uint64_t flags = I40E_TD_CMD;
drivers/net/intel/iavf/iavf_rxtx.c +8 -8
index 4b763627bc..e4421a9932 100644
@@ -267,7 +267,7 @@ reset_tx_queue(struct ci_tx_queue *txq)
 	}
 
 	txe = txq->sw_ring;
-	size = sizeof(struct iavf_tx_desc) * txq->nb_tx_desc;
+	size = sizeof(struct ci_tx_desc) * txq->nb_tx_desc;
 	for (i = 0; i < size; i++)
 		((volatile char *)txq->iavf_tx_ring)[i] = 0;
 
@@ -827,7 +827,7 @@ iavf_dev_tx_queue_setup(struct rte_eth_dev *dev,
 	}
 
 	/* Allocate TX hardware ring descriptors. */
-	ring_size = sizeof(struct iavf_tx_desc) * IAVF_MAX_RING_DESC;
+	ring_size = sizeof(struct ci_tx_desc) * IAVF_MAX_RING_DESC;
 	ring_size = RTE_ALIGN(ring_size, IAVF_DMA_MEM_ALIGN);
 	mz = rte_eth_dma_zone_reserve(dev, "iavf_tx_ring", queue_idx,
 				      ring_size, IAVF_RING_BASE_ALIGN,
@@ -839,7 +839,7 @@ iavf_dev_tx_queue_setup(struct rte_eth_dev *dev,
 		return -ENOMEM;
 	}
 	txq->tx_ring_dma = mz->iova;
-	txq->iavf_tx_ring = (struct iavf_tx_desc *)mz->addr;
+	txq->iavf_tx_ring = (struct ci_tx_desc *)mz->addr;
 
 	txq->mz = mz;
 	reset_tx_queue(txq);
@@ -2333,7 +2333,7 @@ iavf_xmit_cleanup(struct ci_tx_queue *txq)
 	uint16_t desc_to_clean_to;
 	uint16_t nb_tx_to_clean;
 
-	volatile struct iavf_tx_desc *txd = txq->iavf_tx_ring;
+	volatile struct ci_tx_desc *txd = txq->iavf_tx_ring;
 
 	desc_to_clean_to = (uint16_t)(last_desc_cleaned + txq->tx_rs_thresh);
 	if (desc_to_clean_to >= nb_tx_desc)
@@ -2723,7 +2723,7 @@ iavf_calc_pkt_desc(struct rte_mbuf *tx_pkt)
 }
 
 static inline void
-iavf_fill_data_desc(volatile struct iavf_tx_desc *desc,
+iavf_fill_data_desc(volatile struct ci_tx_desc *desc,
 	uint64_t desc_template,	uint16_t buffsz,
 	uint64_t buffer_addr)
 {
@@ -2756,7 +2756,7 @@ uint16_t
 iavf_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 {
 	struct ci_tx_queue *txq = tx_queue;
-	volatile struct iavf_tx_desc *txr = txq->iavf_tx_ring;
+	volatile struct ci_tx_desc *txr = txq->iavf_tx_ring;
 	struct ci_tx_entry *txe_ring = txq->sw_ring;
 	struct ci_tx_entry *txe, *txn;
 	struct rte_mbuf *mb, *mb_seg;
@@ -2774,7 +2774,7 @@ iavf_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 	txe = &txe_ring[desc_idx];
 
 	for (idx = 0; idx < nb_pkts; idx++) {
-		volatile struct iavf_tx_desc *ddesc;
+		volatile struct ci_tx_desc *ddesc;
 		struct iavf_ipsec_crypto_pkt_metadata *ipsec_md;
 
 		uint16_t nb_desc_ctx, nb_desc_ipsec;
@@ -2895,7 +2895,7 @@ iavf_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 		mb_seg = mb;
 
 		do {
-			ddesc = (volatile struct iavf_tx_desc *)
+			ddesc = (volatile struct ci_tx_desc *)
 					&txr[desc_idx];
 
 			txn = &txe_ring[txe->next_id];
drivers/net/intel/iavf/iavf_rxtx.h +1 -1
index e1f78dcde0..dd6d884fc1 100644
@@ -678,7 +678,7 @@ void iavf_dump_tx_descriptor(const struct ci_tx_queue *txq,
 			    const volatile void *desc, uint16_t tx_id)
 {
 	const char *name;
-	const volatile struct iavf_tx_desc *tx_desc = desc;
+	const volatile struct ci_tx_desc *tx_desc = desc;
 	enum iavf_tx_desc_dtype_value type;
 
 
drivers/net/intel/iavf/iavf_rxtx_vec_avx2.c +3 -3
index e29958e0bc..5b62d51cf7 100644
@@ -1630,7 +1630,7 @@ iavf_recv_scattered_pkts_vec_avx2_flex_rxd_offload(void *rx_queue,
 
 
 static __rte_always_inline void
-iavf_vtx1(volatile struct iavf_tx_desc *txdp,
+iavf_vtx1(volatile struct ci_tx_desc *txdp,
 	  struct rte_mbuf *pkt, uint64_t flags, bool offload, uint8_t vlan_flag)
 {
 	uint64_t high_qw =
@@ -1646,7 +1646,7 @@ iavf_vtx1(volatile struct iavf_tx_desc *txdp,
 }
 
 static __rte_always_inline void
-iavf_vtx(volatile struct iavf_tx_desc *txdp,
+iavf_vtx(volatile struct ci_tx_desc *txdp,
 	 struct rte_mbuf **pkt, uint16_t nb_pkts,  uint64_t flags, bool offload, uint8_t vlan_flag)
 {
 	const uint64_t hi_qw_tmpl = (IAVF_TX_DESC_DTYPE_DATA |
@@ -1713,7 +1713,7 @@ iavf_xmit_fixed_burst_vec_avx2(void *tx_queue, struct rte_mbuf **tx_pkts,
 			       uint16_t nb_pkts, bool offload)
 {
 	struct ci_tx_queue *txq = (struct ci_tx_queue *)tx_queue;
-	volatile struct iavf_tx_desc *txdp;
+	volatile struct ci_tx_desc *txdp;
 	struct ci_tx_entry_vec *txep;
 	uint16_t n, nb_commit, tx_id;
 	/* bit2 is reserved and must be set to 1 according to Spec */
drivers/net/intel/iavf/iavf_rxtx_vec_avx512.c +6 -6
index 7c0907b7cf..d79d96c7b7 100644
@@ -1840,7 +1840,7 @@ tx_backlog_entry_avx512(struct ci_tx_entry_vec *txep,
 }
 
 static __rte_always_inline void
-iavf_vtx1(volatile struct iavf_tx_desc *txdp,
+iavf_vtx1(volatile struct ci_tx_desc *txdp,
 	  struct rte_mbuf *pkt, uint64_t flags,
 	  bool offload, uint8_t vlan_flag)
 {
@@ -1859,7 +1859,7 @@ iavf_vtx1(volatile struct iavf_tx_desc *txdp,
 #define IAVF_TX_LEN_MASK 0xAA
 #define IAVF_TX_OFF_MASK 0x55
 static __rte_always_inline void
-iavf_vtx(volatile struct iavf_tx_desc *txdp,
+iavf_vtx(volatile struct ci_tx_desc *txdp,
 		struct rte_mbuf **pkt, uint16_t nb_pkts,  uint64_t flags,
 		bool offload, uint8_t vlan_flag)
 {
@@ -2068,7 +2068,7 @@ iavf_fill_ctx_desc_tunnelling_field(volatile uint64_t *qw0,
 }
 
 static __rte_always_inline void
-ctx_vtx1(volatile struct iavf_tx_desc *txdp, struct rte_mbuf *pkt,
+ctx_vtx1(volatile struct ci_tx_desc *txdp, struct rte_mbuf *pkt,
 		uint64_t flags, bool offload, uint8_t vlan_flag)
 {
 	uint64_t high_ctx_qw = IAVF_TX_DESC_DTYPE_CONTEXT;
@@ -2106,7 +2106,7 @@ ctx_vtx1(volatile struct iavf_tx_desc *txdp, struct rte_mbuf *pkt,
 }
 
 static __rte_always_inline void
-ctx_vtx(volatile struct iavf_tx_desc *txdp,
+ctx_vtx(volatile struct ci_tx_desc *txdp,
 		struct rte_mbuf **pkt, uint16_t nb_pkts,  uint64_t flags,
 		bool offload, uint8_t vlan_flag)
 {
@@ -2203,7 +2203,7 @@ iavf_xmit_fixed_burst_vec_avx512(void *tx_queue, struct rte_mbuf **tx_pkts,
 				 uint16_t nb_pkts, bool offload)
 {
 	struct ci_tx_queue *txq = (struct ci_tx_queue *)tx_queue;
-	volatile struct iavf_tx_desc *txdp;
+	volatile struct ci_tx_desc *txdp;
 	struct ci_tx_entry_vec *txep;
 	uint16_t n, nb_commit, tx_id;
 	/* bit2 is reserved and must be set to 1 according to Spec */
@@ -2271,7 +2271,7 @@ iavf_xmit_fixed_burst_vec_avx512_ctx(void *tx_queue, struct rte_mbuf **tx_pkts,
 				 uint16_t nb_pkts, bool offload)
 {
 	struct ci_tx_queue *txq = (struct ci_tx_queue *)tx_queue;
-	volatile struct iavf_tx_desc *txdp;
+	volatile struct ci_tx_desc *txdp;
 	struct ci_tx_entry_vec *txep;
 	uint16_t n, nb_commit, nb_mbuf, tx_id;
 	/* bit2 is reserved and must be set to 1 according to Spec */
drivers/net/intel/ice/ice_dcf_ethdev.c +1 -1
index 81da5a4656..ab1d499cef 100644
@@ -399,7 +399,7 @@ reset_tx_queue(struct ci_tx_queue *txq)
 	}
 
 	txe = txq->sw_ring;
-	size = sizeof(struct ice_tx_desc) * txq->nb_tx_desc;
+	size = sizeof(struct ci_tx_desc) * txq->nb_tx_desc;
 	for (i = 0; i < size; i++)
 		((volatile char *)txq->ice_tx_ring)[i] = 0;
 
drivers/net/intel/ice/ice_rxtx.c +18 -18
index f3bc79423d..74b80e7df3 100644
@@ -1115,13 +1115,13 @@ ice_reset_tx_queue(struct ci_tx_queue *txq)
 	}
 
 	txe = txq->sw_ring;
-	size = sizeof(struct ice_tx_desc) * txq->nb_tx_desc;
+	size = sizeof(struct ci_tx_desc) * txq->nb_tx_desc;
 	for (i = 0; i < size; i++)
 		((volatile char *)txq->ice_tx_ring)[i] = 0;
 
 	prev = (uint16_t)(txq->nb_tx_desc - 1);
 	for (i = 0; i < txq->nb_tx_desc; i++) {
-		volatile struct ice_tx_desc *txd = &txq->ice_tx_ring[i];
+		volatile struct ci_tx_desc *txd = &txq->ice_tx_ring[i];
 
 		txd->cmd_type_offset_bsz =
 			rte_cpu_to_le_64(ICE_TX_DESC_DTYPE_DESC_DONE);
@@ -1623,7 +1623,7 @@ ice_tx_queue_setup(struct rte_eth_dev *dev,
 	}
 
 	/* Allocate TX hardware ring descriptors. */
-	ring_size = sizeof(struct ice_tx_desc) * ICE_MAX_NUM_DESC_BY_MAC(hw);
+	ring_size = sizeof(struct ci_tx_desc) * ICE_MAX_NUM_DESC_BY_MAC(hw);
 	ring_size = RTE_ALIGN(ring_size, ICE_DMA_MEM_ALIGN);
 	tz = rte_eth_dma_zone_reserve(dev, "ice_tx_ring", queue_idx,
 				      ring_size, ICE_RING_BASE_ALIGN,
@@ -2619,7 +2619,7 @@ ice_fdir_setup_tx_resources(struct ice_pf *pf)
 	}
 
 	/* Allocate TX hardware ring descriptors. */
-	ring_size = sizeof(struct ice_tx_desc) * ICE_FDIR_NUM_TX_DESC;
+	ring_size = sizeof(struct ci_tx_desc) * ICE_FDIR_NUM_TX_DESC;
 	ring_size = RTE_ALIGN(ring_size, ICE_DMA_MEM_ALIGN);
 
 	tz = rte_eth_dma_zone_reserve(dev, "fdir_tx_ring",
@@ -2638,7 +2638,7 @@ ice_fdir_setup_tx_resources(struct ice_pf *pf)
 	txq->ice_vsi = pf->fdir.fdir_vsi;
 
 	txq->tx_ring_dma = tz->iova;
-	txq->ice_tx_ring = (struct ice_tx_desc *)tz->addr;
+	txq->ice_tx_ring = (struct ci_tx_desc *)tz->addr;
 	/*
 	 * don't need to allocate software ring and reset for the fdir
 	 * program queue just set the queue has been configured.
@@ -3027,7 +3027,7 @@ static inline int
 ice_xmit_cleanup(struct ci_tx_queue *txq)
 {
 	struct ci_tx_entry *sw_ring = txq->sw_ring;
-	volatile struct ice_tx_desc *txd = txq->ice_tx_ring;
+	volatile struct ci_tx_desc *txd = txq->ice_tx_ring;
 	uint16_t last_desc_cleaned = txq->last_desc_cleaned;
 	uint16_t nb_tx_desc = txq->nb_tx_desc;
 	uint16_t desc_to_clean_to;
@@ -3148,8 +3148,8 @@ uint16_t
 ice_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 {
 	struct ci_tx_queue *txq;
-	volatile struct ice_tx_desc *ice_tx_ring;
-	volatile struct ice_tx_desc *txd;
+	volatile struct ci_tx_desc *ice_tx_ring;
+	volatile struct ci_tx_desc *txd;
 	struct ci_tx_entry *sw_ring;
 	struct ci_tx_entry *txe, *txn;
 	struct rte_mbuf *tx_pkt;
@@ -3312,7 +3312,7 @@ ice_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 
 			while ((ol_flags & (RTE_MBUF_F_TX_TCP_SEG | RTE_MBUF_F_TX_UDP_SEG)) &&
 				unlikely(slen > ICE_MAX_DATA_PER_TXD)) {
-				txd->buf_addr = rte_cpu_to_le_64(buf_dma_addr);
+				txd->buffer_addr = rte_cpu_to_le_64(buf_dma_addr);
 				txd->cmd_type_offset_bsz =
 				rte_cpu_to_le_64(ICE_TX_DESC_DTYPE_DATA |
 				((uint64_t)td_cmd << ICE_TXD_QW1_CMD_S) |
@@ -3331,7 +3331,7 @@ ice_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 				txn = &sw_ring[txe->next_id];
 			}
 
-			txd->buf_addr = rte_cpu_to_le_64(buf_dma_addr);
+			txd->buffer_addr = rte_cpu_to_le_64(buf_dma_addr);
 			txd->cmd_type_offset_bsz =
 				rte_cpu_to_le_64(ICE_TX_DESC_DTYPE_DATA |
 				((uint64_t)td_cmd << ICE_TXD_QW1_CMD_S) |
@@ -3563,14 +3563,14 @@ ice_tx_done_cleanup(void *txq, uint32_t free_cnt)
 
 /* Populate 4 descriptors with data from 4 mbufs */
 static inline void
-tx4(volatile struct ice_tx_desc *txdp, struct rte_mbuf **pkts)
+tx4(volatile struct ci_tx_desc *txdp, struct rte_mbuf **pkts)
 {
 	uint64_t dma_addr;
 	uint32_t i;
 
 	for (i = 0; i < 4; i++, txdp++, pkts++) {
 		dma_addr = rte_mbuf_data_iova(*pkts);
-		txdp->buf_addr = rte_cpu_to_le_64(dma_addr);
+		txdp->buffer_addr = rte_cpu_to_le_64(dma_addr);
 		txdp->cmd_type_offset_bsz =
 			ice_build_ctob((uint32_t)ICE_TD_CMD, 0,
 				       (*pkts)->data_len, 0);
@@ -3579,12 +3579,12 @@ tx4(volatile struct ice_tx_desc *txdp, struct rte_mbuf **pkts)
 
 /* Populate 1 descriptor with data from 1 mbuf */
 static inline void
-tx1(volatile struct ice_tx_desc *txdp, struct rte_mbuf **pkts)
+tx1(volatile struct ci_tx_desc *txdp, struct rte_mbuf **pkts)
 {
 	uint64_t dma_addr;
 
 	dma_addr = rte_mbuf_data_iova(*pkts);
-	txdp->buf_addr = rte_cpu_to_le_64(dma_addr);
+	txdp->buffer_addr = rte_cpu_to_le_64(dma_addr);
 	txdp->cmd_type_offset_bsz =
 		ice_build_ctob((uint32_t)ICE_TD_CMD, 0,
 			       (*pkts)->data_len, 0);
@@ -3594,7 +3594,7 @@ static inline void
 ice_tx_fill_hw_ring(struct ci_tx_queue *txq, struct rte_mbuf **pkts,
 		    uint16_t nb_pkts)
 {
-	volatile struct ice_tx_desc *txdp = &txq->ice_tx_ring[txq->tx_tail];
+	volatile struct ci_tx_desc *txdp = &txq->ice_tx_ring[txq->tx_tail];
 	struct ci_tx_entry *txep = &txq->sw_ring[txq->tx_tail];
 	const int N_PER_LOOP = 4;
 	const int N_PER_LOOP_MASK = N_PER_LOOP - 1;
@@ -3627,7 +3627,7 @@ tx_xmit_pkts(struct ci_tx_queue *txq,
 	     struct rte_mbuf **tx_pkts,
 	     uint16_t nb_pkts)
 {
-	volatile struct ice_tx_desc *txr = txq->ice_tx_ring;
+	volatile struct ci_tx_desc *txr = txq->ice_tx_ring;
 	uint16_t n = 0;
 
 	/**
@@ -4882,7 +4882,7 @@ ice_fdir_programming(struct ice_pf *pf, struct ice_fltr_desc *fdir_desc)
 	struct ci_tx_queue *txq = pf->fdir.txq;
 	struct ci_rx_queue *rxq = pf->fdir.rxq;
 	volatile struct ice_fltr_desc *fdirdp;
-	volatile struct ice_tx_desc *txdp;
+	volatile struct ci_tx_desc *txdp;
 	uint32_t td_cmd;
 	uint16_t i;
 
@@ -4892,7 +4892,7 @@ ice_fdir_programming(struct ice_pf *pf, struct ice_fltr_desc *fdir_desc)
 	fdirdp->dtype_cmd_vsi_fdid = fdir_desc->dtype_cmd_vsi_fdid;
 
 	txdp = &txq->ice_tx_ring[txq->tx_tail + 1];
-	txdp->buf_addr = rte_cpu_to_le_64(pf->fdir.dma_addr);
+	txdp->buffer_addr = rte_cpu_to_le_64(pf->fdir.dma_addr);
 	td_cmd = ICE_TX_DESC_CMD_EOP |
 		ICE_TX_DESC_CMD_RS  |
 		ICE_TX_DESC_CMD_DUMMY;
drivers/net/intel/ice/ice_rxtx_vec_avx2.c +3 -3
index 0ba1d557ca..bef7bb00ba 100644
@@ -774,7 +774,7 @@ ice_recv_scattered_pkts_vec_avx2_offload(void *rx_queue,
 }
 
 static __rte_always_inline void
-ice_vtx1(volatile struct ice_tx_desc *txdp,
+ice_vtx1(volatile struct ci_tx_desc *txdp,
 	 struct rte_mbuf *pkt, uint64_t flags, bool offload)
 {
 	uint64_t high_qw =
@@ -789,7 +789,7 @@ ice_vtx1(volatile struct ice_tx_desc *txdp,
 }
 
 static __rte_always_inline void
-ice_vtx(volatile struct ice_tx_desc *txdp,
+ice_vtx(volatile struct ci_tx_desc *txdp,
 	struct rte_mbuf **pkt, uint16_t nb_pkts,  uint64_t flags, bool offload)
 {
 	const uint64_t hi_qw_tmpl = (ICE_TX_DESC_DTYPE_DATA |
@@ -852,7 +852,7 @@ ice_xmit_fixed_burst_vec_avx2(void *tx_queue, struct rte_mbuf **tx_pkts,
 			      uint16_t nb_pkts, bool offload)
 {
 	struct ci_tx_queue *txq = (struct ci_tx_queue *)tx_queue;
-	volatile struct ice_tx_desc *txdp;
+	volatile struct ci_tx_desc *txdp;
 	struct ci_tx_entry_vec *txep;
 	uint16_t n, nb_commit, tx_id;
 	uint64_t flags = ICE_TD_CMD;
drivers/net/intel/ice/ice_rxtx_vec_avx512.c +3 -3
index 7c6fe82072..1f6bf5fc8e 100644
@@ -847,7 +847,7 @@ ice_recv_scattered_pkts_vec_avx512_offload(void *rx_queue,
 }
 
 static __rte_always_inline void
-ice_vtx1(volatile struct ice_tx_desc *txdp,
+ice_vtx1(volatile struct ci_tx_desc *txdp,
 	 struct rte_mbuf *pkt, uint64_t flags, bool do_offload)
 {
 	uint64_t high_qw =
@@ -863,7 +863,7 @@ ice_vtx1(volatile struct ice_tx_desc *txdp,
 }
 
 static __rte_always_inline void
-ice_vtx(volatile struct ice_tx_desc *txdp, struct rte_mbuf **pkt,
+ice_vtx(volatile struct ci_tx_desc *txdp, struct rte_mbuf **pkt,
 	uint16_t nb_pkts,  uint64_t flags, bool do_offload)
 {
 	const uint64_t hi_qw_tmpl = (ICE_TX_DESC_DTYPE_DATA |
@@ -916,7 +916,7 @@ ice_xmit_fixed_burst_vec_avx512(void *tx_queue, struct rte_mbuf **tx_pkts,
 				uint16_t nb_pkts, bool do_offload)
 {
 	struct ci_tx_queue *txq = (struct ci_tx_queue *)tx_queue;
-	volatile struct ice_tx_desc *txdp;
+	volatile struct ci_tx_desc *txdp;
 	struct ci_tx_entry_vec *txep;
 	uint16_t n, nb_commit, tx_id;
 	uint64_t flags = ICE_TD_CMD;
drivers/net/intel/idpf/idpf_common_rxtx.c +10 -10
index 797ee515dd..be3c1ef216 100644
@@ -264,13 +264,13 @@ idpf_qc_single_tx_queue_reset(struct ci_tx_queue *txq)
 	}
 
 	txe = txq->sw_ring;
-	size = sizeof(struct idpf_base_tx_desc) * txq->nb_tx_desc;
+	size = sizeof(struct ci_tx_desc) * txq->nb_tx_desc;
 	for (i = 0; i < size; i++)
 		((volatile char *)txq->idpf_tx_ring)[i] = 0;
 
 	prev = (uint16_t)(txq->nb_tx_desc - 1);
 	for (i = 0; i < txq->nb_tx_desc; i++) {
-		txq->idpf_tx_ring[i].qw1 =
+		txq->idpf_tx_ring[i].cmd_type_offset_bsz =
 			rte_cpu_to_le_64(IDPF_TX_DESC_DTYPE_DESC_DONE);
 		txe[i].mbuf =  NULL;
 		txe[i].last_id = i;
@@ -1335,14 +1335,14 @@ idpf_xmit_cleanup(struct ci_tx_queue *txq)
 	uint16_t desc_to_clean_to;
 	uint16_t nb_tx_to_clean;
 
-	volatile struct idpf_base_tx_desc *txd = txq->idpf_tx_ring;
+	volatile struct ci_tx_desc *txd = txq->idpf_tx_ring;
 
 	desc_to_clean_to = (uint16_t)(last_desc_cleaned + txq->tx_rs_thresh);
 	if (desc_to_clean_to >= nb_tx_desc)
 		desc_to_clean_to = (uint16_t)(desc_to_clean_to - nb_tx_desc);
 
 	desc_to_clean_to = sw_ring[desc_to_clean_to].last_id;
-	if ((txd[desc_to_clean_to].qw1 &
+	if ((txd[desc_to_clean_to].cmd_type_offset_bsz &
 	     rte_cpu_to_le_64(IDPF_TXD_QW1_DTYPE_M)) !=
 	    rte_cpu_to_le_64(IDPF_TX_DESC_DTYPE_DESC_DONE)) {
 		TX_LOG(DEBUG, "TX descriptor %4u is not done "
@@ -1358,7 +1358,7 @@ idpf_xmit_cleanup(struct ci_tx_queue *txq)
 		nb_tx_to_clean = (uint16_t)(desc_to_clean_to -
 					    last_desc_cleaned);
 
-	txd[desc_to_clean_to].qw1 = 0;
+	txd[desc_to_clean_to].cmd_type_offset_bsz = 0;
 
 	txq->last_desc_cleaned = desc_to_clean_to;
 	txq->nb_tx_free = (uint16_t)(txq->nb_tx_free + nb_tx_to_clean);
@@ -1372,8 +1372,8 @@ uint16_t
 idpf_dp_singleq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 			  uint16_t nb_pkts)
 {
-	volatile struct idpf_base_tx_desc *txd;
-	volatile struct idpf_base_tx_desc *txr;
+	volatile struct ci_tx_desc *txd;
+	volatile struct ci_tx_desc *txr;
 	union idpf_tx_offload tx_offload = {0};
 	struct ci_tx_entry *txe, *txn;
 	struct ci_tx_entry *sw_ring;
@@ -1491,8 +1491,8 @@ idpf_dp_singleq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 			/* Setup TX Descriptor */
 			slen = m_seg->data_len;
 			buf_dma_addr = rte_mbuf_data_iova(m_seg);
-			txd->buf_addr = rte_cpu_to_le_64(buf_dma_addr);
-			txd->qw1 = rte_cpu_to_le_64(IDPF_TX_DESC_DTYPE_DATA |
+			txd->buffer_addr = rte_cpu_to_le_64(buf_dma_addr);
+			txd->cmd_type_offset_bsz = rte_cpu_to_le_64(IDPF_TX_DESC_DTYPE_DATA |
 				((uint64_t)td_cmd  << IDPF_TXD_QW1_CMD_S) |
 				((uint64_t)td_offset << IDPF_TXD_QW1_OFFSET_S) |
 				((uint64_t)slen << IDPF_TXD_QW1_TX_BUF_SZ_S));
@@ -1519,7 +1519,7 @@ idpf_dp_singleq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 			txq->nb_tx_used = 0;
 		}
 
-		txd->qw1 |= rte_cpu_to_le_16(td_cmd << IDPF_TXD_QW1_CMD_S);
+		txd->cmd_type_offset_bsz |= rte_cpu_to_le_16(td_cmd << IDPF_TXD_QW1_CMD_S);
 	}
 
 end_of_tx:
drivers/net/intel/idpf/idpf_common_rxtx.h +1 -1
index 7c6ff5d047..2f2fa153b2 100644
@@ -182,7 +182,7 @@ union idpf_tx_offload {
 };
 
 union idpf_tx_desc {
-	struct idpf_base_tx_desc *tx_ring;
+	struct ci_tx_desc *tx_ring;
 	struct idpf_flex_tx_sched_desc *desc_ring;
 	struct idpf_splitq_tx_compl_desc *compl_ring;
 };
drivers/net/intel/idpf/idpf_common_rxtx_avx2.c +4 -4
index 21c8f79254..5f5d538dcb 100644
@@ -483,7 +483,7 @@ idpf_dp_singleq_recv_pkts_avx2(void *rx_queue, struct rte_mbuf **rx_pkts, uint16
 }
 
 static inline void
-idpf_singleq_vtx1(volatile struct idpf_base_tx_desc *txdp,
+idpf_singleq_vtx1(volatile struct ci_tx_desc *txdp,
 		  struct rte_mbuf *pkt, uint64_t flags)
 {
 	uint64_t high_qw =
@@ -497,7 +497,7 @@ idpf_singleq_vtx1(volatile struct idpf_base_tx_desc *txdp,
 }
 
 static inline void
-idpf_singleq_vtx(volatile struct idpf_base_tx_desc *txdp,
+idpf_singleq_vtx(volatile struct ci_tx_desc *txdp,
 		 struct rte_mbuf **pkt, uint16_t nb_pkts,  uint64_t flags)
 {
 	const uint64_t hi_qw_tmpl = (IDPF_TX_DESC_DTYPE_DATA |
@@ -556,7 +556,7 @@ idpf_singleq_xmit_fixed_burst_vec_avx2(void *tx_queue, struct rte_mbuf **tx_pkts
 				       uint16_t nb_pkts)
 {
 	struct ci_tx_queue *txq = (struct ci_tx_queue *)tx_queue;
-	volatile struct idpf_base_tx_desc *txdp;
+	volatile struct ci_tx_desc *txdp;
 	struct ci_tx_entry_vec *txep;
 	uint16_t n, nb_commit, tx_id;
 	uint64_t flags = IDPF_TX_DESC_CMD_EOP;
@@ -604,7 +604,7 @@ idpf_singleq_xmit_fixed_burst_vec_avx2(void *tx_queue, struct rte_mbuf **tx_pkts
 
 	tx_id = (uint16_t)(tx_id + nb_commit);
 	if (tx_id > txq->tx_next_rs) {
-		txq->idpf_tx_ring[txq->tx_next_rs].qw1 |=
+		txq->idpf_tx_ring[txq->tx_next_rs].cmd_type_offset_bsz |=
 			rte_cpu_to_le_64(((uint64_t)IDPF_TX_DESC_CMD_RS) <<
 					 IDPF_TXD_QW1_CMD_S);
 		txq->tx_next_rs =
drivers/net/intel/idpf/idpf_common_rxtx_avx512.c +4 -4
index bc2cadd738..c1ec3d1222 100644
@@ -1000,7 +1000,7 @@ idpf_dp_splitq_recv_pkts_avx512(void *rx_queue, struct rte_mbuf **rx_pkts,
 }
 
 static __rte_always_inline void
-idpf_singleq_vtx1(volatile struct idpf_base_tx_desc *txdp,
+idpf_singleq_vtx1(volatile struct ci_tx_desc *txdp,
 	  struct rte_mbuf *pkt, uint64_t flags)
 {
 	uint64_t high_qw =
@@ -1016,7 +1016,7 @@ idpf_singleq_vtx1(volatile struct idpf_base_tx_desc *txdp,
 #define IDPF_TX_LEN_MASK 0xAA
 #define IDPF_TX_OFF_MASK 0x55
 static __rte_always_inline void
-idpf_singleq_vtx(volatile struct idpf_base_tx_desc *txdp,
+idpf_singleq_vtx(volatile struct ci_tx_desc *txdp,
 	 struct rte_mbuf **pkt, uint16_t nb_pkts,  uint64_t flags)
 {
 	const uint64_t hi_qw_tmpl = (IDPF_TX_DESC_DTYPE_DATA  |
@@ -1072,7 +1072,7 @@ idpf_singleq_xmit_fixed_burst_vec_avx512(void *tx_queue, struct rte_mbuf **tx_pk
 					 uint16_t nb_pkts)
 {
 	struct ci_tx_queue *txq = tx_queue;
-	volatile struct idpf_base_tx_desc *txdp;
+	volatile struct ci_tx_desc *txdp;
 	struct ci_tx_entry_vec *txep;
 	uint16_t n, nb_commit, tx_id;
 	uint64_t flags = IDPF_TX_DESC_CMD_EOP;
@@ -1123,7 +1123,7 @@ idpf_singleq_xmit_fixed_burst_vec_avx512(void *tx_queue, struct rte_mbuf **tx_pk
 
 	tx_id = (uint16_t)(tx_id + nb_commit);
 	if (tx_id > txq->tx_next_rs) {
-		txq->idpf_tx_ring[txq->tx_next_rs].qw1 |=
+		txq->idpf_tx_ring[txq->tx_next_rs].cmd_type_offset_bsz |=
 			rte_cpu_to_le_64(((uint64_t)IDPF_TX_DESC_CMD_RS) <<
 					 IDPF_TXD_QW1_CMD_S);
 		txq->tx_next_rs =
drivers/net/intel/idpf/idpf_rxtx.c +1 -1
index cee454244f..8aa44585fe 100644
@@ -72,7 +72,7 @@ idpf_dma_zone_reserve(struct rte_eth_dev *dev, uint16_t queue_idx,
 			ring_size = RTE_ALIGN(len * sizeof(struct idpf_flex_tx_sched_desc),
 					      IDPF_DMA_MEM_ALIGN);
 		else
-			ring_size = RTE_ALIGN(len * sizeof(struct idpf_base_tx_desc),
+			ring_size = RTE_ALIGN(len * sizeof(struct ci_tx_desc),
 					      IDPF_DMA_MEM_ALIGN);
 		rte_memcpy(ring_name, "idpf Tx ring", sizeof("idpf Tx ring"));
 		break;
drivers/net/intel/idpf/idpf_rxtx_vec_common.h +1 -1
index 425f0792a1..4702061484 100644
@@ -31,7 +31,7 @@ idpf_tx_desc_done(struct ci_tx_queue *txq, uint16_t idx)
 	if (txq->complq != NULL)
 		return 1;
 
-	return (txq->idpf_tx_ring[idx].qw1 &
+	return (txq->idpf_tx_ring[idx].cmd_type_offset_bsz &
 			rte_cpu_to_le_64(IDPF_TXD_QW1_DTYPE_M)) ==
 				rte_cpu_to_le_64(IDPF_TX_DESC_DTYPE_DESC_DONE);
 }
Signature · 1 line
2.51.0
#132 lore raw

PATCH v4 2/35 net/intel: use common Tx ring structure

In reply to Bruce Richardson

Rather than having separate per-driver ring pointers in a union, since we now have a common descriptor type, we can merge all but the ixgbe pointer into one value.

---
 drivers/net/intel/common/tx.h                 |  5 +--
 drivers/net/intel/cpfl/cpfl_rxtx.c            |  2 +-
 drivers/net/intel/i40e/i40e_fdir.c            |  6 ++--
 drivers/net/intel/i40e/i40e_rxtx.c            | 22 ++++++------
 .../net/intel/i40e/i40e_rxtx_vec_altivec.c    |  6 ++--
 drivers/net/intel/i40e/i40e_rxtx_vec_avx2.c   |  6 ++--
 drivers/net/intel/i40e/i40e_rxtx_vec_avx512.c |  6 ++--
 drivers/net/intel/i40e/i40e_rxtx_vec_common.h |  2 +-
 drivers/net/intel/i40e/i40e_rxtx_vec_neon.c   |  6 ++--
 drivers/net/intel/iavf/iavf_rxtx.c            | 14 ++++----
 drivers/net/intel/iavf/iavf_rxtx_vec_avx2.c   |  6 ++--
 drivers/net/intel/iavf/iavf_rxtx_vec_avx512.c | 12 +++----
 drivers/net/intel/iavf/iavf_rxtx_vec_common.h |  2 +-
 drivers/net/intel/ice/ice_dcf_ethdev.c        |  4 +--
 drivers/net/intel/ice/ice_rxtx.c              | 34 +++++++++----------
 drivers/net/intel/ice/ice_rxtx_vec_avx2.c     |  6 ++--
 drivers/net/intel/ice/ice_rxtx_vec_avx512.c   |  6 ++--
 drivers/net/intel/ice/ice_rxtx_vec_common.h   |  2 +-
 drivers/net/intel/idpf/idpf_common_rxtx.c     |  8 ++---
 .../net/intel/idpf/idpf_common_rxtx_avx2.c    |  6 ++--
 .../net/intel/idpf/idpf_common_rxtx_avx512.c  |  6 ++--
 drivers/net/intel/idpf/idpf_rxtx.c            |  2 +-
 drivers/net/intel/idpf/idpf_rxtx_vec_common.h |  2 +-
 23 files changed, 84 insertions(+), 87 deletions(-)
drivers/net/intel/common/tx.h +1 -4
index d7561a2bbb..8cf63e59ab 100644
@@ -41,10 +41,7 @@ typedef void (*ice_tx_release_mbufs_t)(struct ci_tx_queue *txq);
 
 struct ci_tx_queue {
 	union { /* TX ring virtual address */
-		volatile struct ci_tx_desc *i40e_tx_ring;
-		volatile struct ci_tx_desc *iavf_tx_ring;
-		volatile struct ci_tx_desc *ice_tx_ring;
-		volatile struct ci_tx_desc *idpf_tx_ring;
+		volatile struct ci_tx_desc *ci_tx_ring;
 		volatile union ixgbe_adv_tx_desc *ixgbe_tx_ring;
 	};
 	volatile uint8_t *qtx_tail;               /* register address of tail */
drivers/net/intel/cpfl/cpfl_rxtx.c +1 -1
index 78bc3e9b49..bc5bec65f0 100644
@@ -606,7 +606,7 @@ cpfl_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 	}
 
 	if (!is_splitq) {
-		txq->idpf_tx_ring = mz->addr;
+		txq->ci_tx_ring = mz->addr;
 		idpf_qc_single_tx_queue_reset(txq);
 	} else {
 		txq->desc_ring = mz->addr;
drivers/net/intel/i40e/i40e_fdir.c +3 -3
index 605df73c9e..8a01aec0e2 100644
@@ -1380,7 +1380,7 @@ i40e_find_available_buffer(struct rte_eth_dev *dev)
 		volatile struct ci_tx_desc *tmp_txdp;
 
 		tmp_tail = txq->tx_tail;
-		tmp_txdp = &txq->i40e_tx_ring[tmp_tail + 1];
+		tmp_txdp = &txq->ci_tx_ring[tmp_tail + 1];
 
 		do {
 			if ((tmp_txdp->cmd_type_offset_bsz &
@@ -1637,7 +1637,7 @@ i40e_flow_fdir_filter_programming(struct i40e_pf *pf,
 
 	PMD_DRV_LOG(INFO, "filling filter programming descriptor.");
 	fdirdp = (volatile struct i40e_filter_program_desc *)
-				(&txq->i40e_tx_ring[txq->tx_tail]);
+				(&txq->ci_tx_ring[txq->tx_tail]);
 
 	fdirdp->qindex_flex_ptype_vsi =
 			rte_cpu_to_le_32((fdir_action->rx_queue <<
@@ -1707,7 +1707,7 @@ i40e_flow_fdir_filter_programming(struct i40e_pf *pf,
 	fdirdp->fd_id = rte_cpu_to_le_32(filter->soft_id);
 
 	PMD_DRV_LOG(INFO, "filling transmit descriptor.");
-	txdp = &txq->i40e_tx_ring[txq->tx_tail + 1];
+	txdp = &txq->ci_tx_ring[txq->tx_tail + 1];
 	txdp->buffer_addr = rte_cpu_to_le_64(pf->fdir.dma_addr[txq->tx_tail >> 1]);
 
 	td_cmd = I40E_TX_DESC_CMD_EOP |
drivers/net/intel/i40e/i40e_rxtx.c +11 -11
index 92d49ccb79..210fc0201e 100644
@@ -388,7 +388,7 @@ static inline int
 i40e_xmit_cleanup(struct ci_tx_queue *txq)
 {
 	struct ci_tx_entry *sw_ring = txq->sw_ring;
-	volatile struct ci_tx_desc *txd = txq->i40e_tx_ring;
+	volatile struct ci_tx_desc *txd = txq->ci_tx_ring;
 	uint16_t last_desc_cleaned = txq->last_desc_cleaned;
 	uint16_t nb_tx_desc = txq->nb_tx_desc;
 	uint16_t desc_to_clean_to;
@@ -1112,7 +1112,7 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 
 	txq = tx_queue;
 	sw_ring = txq->sw_ring;
-	txr = txq->i40e_tx_ring;
+	txr = txq->ci_tx_ring;
 	tx_id = txq->tx_tail;
 	txe = &sw_ring[tx_id];
 
@@ -1347,7 +1347,7 @@ i40e_tx_free_bufs(struct ci_tx_queue *txq)
 	const uint16_t k = RTE_ALIGN_FLOOR(tx_rs_thresh, I40E_TX_MAX_FREE_BUF_SZ);
 	const uint16_t m = tx_rs_thresh % I40E_TX_MAX_FREE_BUF_SZ;
 
-	if ((txq->i40e_tx_ring[txq->tx_next_dd].cmd_type_offset_bsz &
+	if ((txq->ci_tx_ring[txq->tx_next_dd].cmd_type_offset_bsz &
 			rte_cpu_to_le_64(I40E_TXD_QW1_DTYPE_MASK)) !=
 			rte_cpu_to_le_64(I40E_TX_DESC_DTYPE_DESC_DONE))
 		return 0;
@@ -1431,7 +1431,7 @@ i40e_tx_fill_hw_ring(struct ci_tx_queue *txq,
 		     struct rte_mbuf **pkts,
 		     uint16_t nb_pkts)
 {
-	volatile struct ci_tx_desc *txdp = &txq->i40e_tx_ring[txq->tx_tail];
+	volatile struct ci_tx_desc *txdp = &txq->ci_tx_ring[txq->tx_tail];
 	struct ci_tx_entry *txep = &txq->sw_ring[txq->tx_tail];
 	const int N_PER_LOOP = 4;
 	const int N_PER_LOOP_MASK = N_PER_LOOP - 1;
@@ -1459,7 +1459,7 @@ tx_xmit_pkts(struct ci_tx_queue *txq,
 	     struct rte_mbuf **tx_pkts,
 	     uint16_t nb_pkts)
 {
-	volatile struct ci_tx_desc *txr = txq->i40e_tx_ring;
+	volatile struct ci_tx_desc *txr = txq->ci_tx_ring;
 	uint16_t n = 0;
 
 	/**
@@ -2421,7 +2421,7 @@ i40e_dev_tx_descriptor_status(void *tx_queue, uint16_t offset)
 			desc -= txq->nb_tx_desc;
 	}
 
-	status = &txq->i40e_tx_ring[desc].cmd_type_offset_bsz;
+	status = &txq->ci_tx_ring[desc].cmd_type_offset_bsz;
 	mask = rte_le_to_cpu_64(I40E_TXD_QW1_DTYPE_MASK);
 	expect = rte_cpu_to_le_64(
 		I40E_TX_DESC_DTYPE_DESC_DONE << I40E_TXD_QW1_DTYPE_SHIFT);
@@ -2618,7 +2618,7 @@ i40e_dev_tx_queue_setup(struct rte_eth_dev *dev,
 	/* Allocate TX hardware ring descriptors. */
 	ring_size = sizeof(struct ci_tx_desc) * I40E_MAX_RING_DESC;
 	ring_size = RTE_ALIGN(ring_size, I40E_DMA_MEM_ALIGN);
-	tz = rte_eth_dma_zone_reserve(dev, "i40e_tx_ring", queue_idx,
+	tz = rte_eth_dma_zone_reserve(dev, "ci_tx_ring", queue_idx,
 			      ring_size, I40E_RING_BASE_ALIGN, socket_id);
 	if (!tz) {
 		i40e_tx_queue_release(txq);
@@ -2640,7 +2640,7 @@ i40e_dev_tx_queue_setup(struct rte_eth_dev *dev,
 	txq->tx_deferred_start = tx_conf->tx_deferred_start;
 
 	txq->tx_ring_dma = tz->iova;
-	txq->i40e_tx_ring = (struct ci_tx_desc *)tz->addr;
+	txq->ci_tx_ring = (struct ci_tx_desc *)tz->addr;
 
 	/* Allocate software ring */
 	txq->sw_ring =
@@ -2915,11 +2915,11 @@ i40e_reset_tx_queue(struct ci_tx_queue *txq)
 	txe = txq->sw_ring;
 	size = sizeof(struct ci_tx_desc) * txq->nb_tx_desc;
 	for (i = 0; i < size; i++)
-		((volatile char *)txq->i40e_tx_ring)[i] = 0;
+		((volatile char *)txq->ci_tx_ring)[i] = 0;
 
 	prev = (uint16_t)(txq->nb_tx_desc - 1);
 	for (i = 0; i < txq->nb_tx_desc; i++) {
-		volatile struct ci_tx_desc *txd = &txq->i40e_tx_ring[i];
+		volatile struct ci_tx_desc *txd = &txq->ci_tx_ring[i];
 
 		txd->cmd_type_offset_bsz =
 			rte_cpu_to_le_64(I40E_TX_DESC_DTYPE_DESC_DONE);
@@ -3240,7 +3240,7 @@ i40e_fdir_setup_tx_resources(struct i40e_pf *pf)
 	txq->i40e_vsi = pf->fdir.fdir_vsi;
 
 	txq->tx_ring_dma = tz->iova;
-	txq->i40e_tx_ring = (struct ci_tx_desc *)tz->addr;
+	txq->ci_tx_ring = (struct ci_tx_desc *)tz->addr;
 
 	/*
 	 * don't need to allocate software ring and reset for the fdir
drivers/net/intel/i40e/i40e_rxtx_vec_altivec.c +3 -3
index ef5b252898..81e9e2bc0b 100644
@@ -489,7 +489,7 @@ i40e_xmit_fixed_burst_vec(void *tx_queue, struct rte_mbuf **tx_pkts,
 		return 0;
 
 	tx_id = txq->tx_tail;
-	txdp = &txq->i40e_tx_ring[tx_id];
+	txdp = &txq->ci_tx_ring[tx_id];
 	txep = &txq->sw_ring_vec[tx_id];
 
 	txq->nb_tx_free = (uint16_t)(txq->nb_tx_free - nb_pkts);
@@ -509,7 +509,7 @@ i40e_xmit_fixed_burst_vec(void *tx_queue, struct rte_mbuf **tx_pkts,
 		txq->tx_next_rs = (uint16_t)(txq->tx_rs_thresh - 1);
 
 		/* avoid reach the end of ring */
-		txdp = &txq->i40e_tx_ring[tx_id];
+		txdp = &txq->ci_tx_ring[tx_id];
 		txep = &txq->sw_ring_vec[tx_id];
 	}
 
@@ -519,7 +519,7 @@ i40e_xmit_fixed_burst_vec(void *tx_queue, struct rte_mbuf **tx_pkts,
 
 	tx_id = (uint16_t)(tx_id + nb_commit);
 	if (tx_id > txq->tx_next_rs) {
-		txq->i40e_tx_ring[txq->tx_next_rs].cmd_type_offset_bsz |=
+		txq->ci_tx_ring[txq->tx_next_rs].cmd_type_offset_bsz |=
 			rte_cpu_to_le_64(((uint64_t)I40E_TX_DESC_CMD_RS) <<
 						I40E_TXD_QW1_CMD_SHIFT);
 		txq->tx_next_rs =
drivers/net/intel/i40e/i40e_rxtx_vec_avx2.c +3 -3
index 137c1f9765..f054bd41bf 100644
@@ -753,7 +753,7 @@ i40e_xmit_fixed_burst_vec_avx2(void *tx_queue, struct rte_mbuf **tx_pkts,
 		return 0;
 
 	tx_id = txq->tx_tail;
-	txdp = &txq->i40e_tx_ring[tx_id];
+	txdp = &txq->ci_tx_ring[tx_id];
 	txep = &txq->sw_ring_vec[tx_id];
 
 	txq->nb_tx_free = (uint16_t)(txq->nb_tx_free - nb_pkts);
@@ -774,7 +774,7 @@ i40e_xmit_fixed_burst_vec_avx2(void *tx_queue, struct rte_mbuf **tx_pkts,
 		txq->tx_next_rs = (uint16_t)(txq->tx_rs_thresh - 1);
 
 		/* avoid reach the end of ring */
-		txdp = &txq->i40e_tx_ring[tx_id];
+		txdp = &txq->ci_tx_ring[tx_id];
 		txep = &txq->sw_ring_vec[tx_id];
 	}
 
@@ -784,7 +784,7 @@ i40e_xmit_fixed_burst_vec_avx2(void *tx_queue, struct rte_mbuf **tx_pkts,
 
 	tx_id = (uint16_t)(tx_id + nb_commit);
 	if (tx_id > txq->tx_next_rs) {
-		txq->i40e_tx_ring[txq->tx_next_rs].cmd_type_offset_bsz |=
+		txq->ci_tx_ring[txq->tx_next_rs].cmd_type_offset_bsz |=
 			rte_cpu_to_le_64(((uint64_t)I40E_TX_DESC_CMD_RS) <<
 						I40E_TXD_QW1_CMD_SHIFT);
 		txq->tx_next_rs =
drivers/net/intel/i40e/i40e_rxtx_vec_avx512.c +3 -3
index 6971488750..9a967faeee 100644
@@ -821,7 +821,7 @@ i40e_xmit_fixed_burst_vec_avx512(void *tx_queue, struct rte_mbuf **tx_pkts,
 		return 0;
 
 	tx_id = txq->tx_tail;
-	txdp = &txq->i40e_tx_ring[tx_id];
+	txdp = &txq->ci_tx_ring[tx_id];
 	txep = (void *)txq->sw_ring;
 	txep += tx_id;
 
@@ -843,7 +843,7 @@ i40e_xmit_fixed_burst_vec_avx512(void *tx_queue, struct rte_mbuf **tx_pkts,
 		txq->tx_next_rs = (uint16_t)(txq->tx_rs_thresh - 1);
 
 		/* avoid reach the end of ring */
-		txdp = txq->i40e_tx_ring;
+		txdp = txq->ci_tx_ring;
 		txep = (void *)txq->sw_ring;
 	}
 
@@ -853,7 +853,7 @@ i40e_xmit_fixed_burst_vec_avx512(void *tx_queue, struct rte_mbuf **tx_pkts,
 
 	tx_id = (uint16_t)(tx_id + nb_commit);
 	if (tx_id > txq->tx_next_rs) {
-		txq->i40e_tx_ring[txq->tx_next_rs].cmd_type_offset_bsz |=
+		txq->ci_tx_ring[txq->tx_next_rs].cmd_type_offset_bsz |=
 			rte_cpu_to_le_64(((uint64_t)I40E_TX_DESC_CMD_RS) <<
 						I40E_TXD_QW1_CMD_SHIFT);
 		txq->tx_next_rs =
drivers/net/intel/i40e/i40e_rxtx_vec_common.h +1 -1
index 14651f2f06..1fd7fc75bf 100644
@@ -15,7 +15,7 @@
 static inline int
 i40e_tx_desc_done(struct ci_tx_queue *txq, uint16_t idx)
 {
-	return (txq->i40e_tx_ring[idx].cmd_type_offset_bsz &
+	return (txq->ci_tx_ring[idx].cmd_type_offset_bsz &
 			rte_cpu_to_le_64(I40E_TXD_QW1_DTYPE_MASK)) ==
 				rte_cpu_to_le_64(I40E_TX_DESC_DTYPE_DESC_DONE);
 }
drivers/net/intel/i40e/i40e_rxtx_vec_neon.c +3 -3
index 6404b70c56..0b95152232 100644
@@ -638,7 +638,7 @@ i40e_xmit_fixed_burst_vec(void *__rte_restrict tx_queue,
 		return 0;
 
 	tx_id = txq->tx_tail;
-	txdp = &txq->i40e_tx_ring[tx_id];
+	txdp = &txq->ci_tx_ring[tx_id];
 	txep = &txq->sw_ring_vec[tx_id];
 
 	txq->nb_tx_free = (uint16_t)(txq->nb_tx_free - nb_pkts);
@@ -658,7 +658,7 @@ i40e_xmit_fixed_burst_vec(void *__rte_restrict tx_queue,
 		txq->tx_next_rs = (uint16_t)(txq->tx_rs_thresh - 1);
 
 		/* avoid reach the end of ring */
-		txdp = &txq->i40e_tx_ring[tx_id];
+		txdp = &txq->ci_tx_ring[tx_id];
 		txep = &txq->sw_ring_vec[tx_id];
 	}
 
@@ -668,7 +668,7 @@ i40e_xmit_fixed_burst_vec(void *__rte_restrict tx_queue,
 
 	tx_id = (uint16_t)(tx_id + nb_commit);
 	if (tx_id > txq->tx_next_rs) {
-		txq->i40e_tx_ring[txq->tx_next_rs].cmd_type_offset_bsz |=
+		txq->ci_tx_ring[txq->tx_next_rs].cmd_type_offset_bsz |=
 			rte_cpu_to_le_64(((uint64_t)I40E_TX_DESC_CMD_RS) <<
 						I40E_TXD_QW1_CMD_SHIFT);
 		txq->tx_next_rs =
drivers/net/intel/iavf/iavf_rxtx.c +7 -7
index e4421a9932..807bc92a45 100644
@@ -269,11 +269,11 @@ reset_tx_queue(struct ci_tx_queue *txq)
 	txe = txq->sw_ring;
 	size = sizeof(struct ci_tx_desc) * txq->nb_tx_desc;
 	for (i = 0; i < size; i++)
-		((volatile char *)txq->iavf_tx_ring)[i] = 0;
+		((volatile char *)txq->ci_tx_ring)[i] = 0;
 
 	prev = (uint16_t)(txq->nb_tx_desc - 1);
 	for (i = 0; i < txq->nb_tx_desc; i++) {
-		txq->iavf_tx_ring[i].cmd_type_offset_bsz =
+		txq->ci_tx_ring[i].cmd_type_offset_bsz =
 			rte_cpu_to_le_64(IAVF_TX_DESC_DTYPE_DESC_DONE);
 		txe[i].mbuf =  NULL;
 		txe[i].last_id = i;
@@ -829,7 +829,7 @@ iavf_dev_tx_queue_setup(struct rte_eth_dev *dev,
 	/* Allocate TX hardware ring descriptors. */
 	ring_size = sizeof(struct ci_tx_desc) * IAVF_MAX_RING_DESC;
 	ring_size = RTE_ALIGN(ring_size, IAVF_DMA_MEM_ALIGN);
-	mz = rte_eth_dma_zone_reserve(dev, "iavf_tx_ring", queue_idx,
+	mz = rte_eth_dma_zone_reserve(dev, "ci_tx_ring", queue_idx,
 				      ring_size, IAVF_RING_BASE_ALIGN,
 				      socket_id);
 	if (!mz) {
@@ -839,7 +839,7 @@ iavf_dev_tx_queue_setup(struct rte_eth_dev *dev,
 		return -ENOMEM;
 	}
 	txq->tx_ring_dma = mz->iova;
-	txq->iavf_tx_ring = (struct ci_tx_desc *)mz->addr;
+	txq->ci_tx_ring = (struct ci_tx_desc *)mz->addr;
 
 	txq->mz = mz;
 	reset_tx_queue(txq);
@@ -2333,7 +2333,7 @@ iavf_xmit_cleanup(struct ci_tx_queue *txq)
 	uint16_t desc_to_clean_to;
 	uint16_t nb_tx_to_clean;
 
-	volatile struct ci_tx_desc *txd = txq->iavf_tx_ring;
+	volatile struct ci_tx_desc *txd = txq->ci_tx_ring;
 
 	desc_to_clean_to = (uint16_t)(last_desc_cleaned + txq->tx_rs_thresh);
 	if (desc_to_clean_to >= nb_tx_desc)
@@ -2756,7 +2756,7 @@ uint16_t
 iavf_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 {
 	struct ci_tx_queue *txq = tx_queue;
-	volatile struct ci_tx_desc *txr = txq->iavf_tx_ring;
+	volatile struct ci_tx_desc *txr = txq->ci_tx_ring;
 	struct ci_tx_entry *txe_ring = txq->sw_ring;
 	struct ci_tx_entry *txe, *txn;
 	struct rte_mbuf *mb, *mb_seg;
@@ -4462,7 +4462,7 @@ iavf_dev_tx_desc_status(void *tx_queue, uint16_t offset)
 			desc -= txq->nb_tx_desc;
 	}
 
-	status = &txq->iavf_tx_ring[desc].cmd_type_offset_bsz;
+	status = &txq->ci_tx_ring[desc].cmd_type_offset_bsz;
 	mask = rte_le_to_cpu_64(IAVF_TXD_QW1_DTYPE_MASK);
 	expect = rte_cpu_to_le_64(
 		 IAVF_TX_DESC_DTYPE_DESC_DONE << IAVF_TXD_QW1_DTYPE_SHIFT);
drivers/net/intel/iavf/iavf_rxtx_vec_avx2.c +3 -3
index 5b62d51cf7..89ce841b9e 100644
@@ -1729,7 +1729,7 @@ iavf_xmit_fixed_burst_vec_avx2(void *tx_queue, struct rte_mbuf **tx_pkts,
 	nb_commit = nb_pkts;
 
 	tx_id = txq->tx_tail;
-	txdp = &txq->iavf_tx_ring[tx_id];
+	txdp = &txq->ci_tx_ring[tx_id];
 	txep = &txq->sw_ring_vec[tx_id];
 
 	txq->nb_tx_free = (uint16_t)(txq->nb_tx_free - nb_pkts);
@@ -1750,7 +1750,7 @@ iavf_xmit_fixed_burst_vec_avx2(void *tx_queue, struct rte_mbuf **tx_pkts,
 		txq->tx_next_rs = (uint16_t)(txq->tx_rs_thresh - 1);
 
 		/* avoid reach the end of ring */
-		txdp = &txq->iavf_tx_ring[tx_id];
+		txdp = &txq->ci_tx_ring[tx_id];
 		txep = &txq->sw_ring_vec[tx_id];
 	}
 
@@ -1760,7 +1760,7 @@ iavf_xmit_fixed_burst_vec_avx2(void *tx_queue, struct rte_mbuf **tx_pkts,
 
 	tx_id = (uint16_t)(tx_id + nb_commit);
 	if (tx_id > txq->tx_next_rs) {
-		txq->iavf_tx_ring[txq->tx_next_rs].cmd_type_offset_bsz |=
+		txq->ci_tx_ring[txq->tx_next_rs].cmd_type_offset_bsz |=
 			rte_cpu_to_le_64(((uint64_t)IAVF_TX_DESC_CMD_RS) <<
 					 IAVF_TXD_QW1_CMD_SHIFT);
 		txq->tx_next_rs =
drivers/net/intel/iavf/iavf_rxtx_vec_avx512.c +6 -6
index d79d96c7b7..ad1b0b90cd 100644
@@ -2219,7 +2219,7 @@ iavf_xmit_fixed_burst_vec_avx512(void *tx_queue, struct rte_mbuf **tx_pkts,
 	nb_commit = nb_pkts;
 
 	tx_id = txq->tx_tail;
-	txdp = &txq->iavf_tx_ring[tx_id];
+	txdp = &txq->ci_tx_ring[tx_id];
 	txep = (void *)txq->sw_ring;
 	txep += tx_id;
 
@@ -2241,7 +2241,7 @@ iavf_xmit_fixed_burst_vec_avx512(void *tx_queue, struct rte_mbuf **tx_pkts,
 		txq->tx_next_rs = (uint16_t)(txq->tx_rs_thresh - 1);
 
 		/* avoid reach the end of ring */
-		txdp = &txq->iavf_tx_ring[tx_id];
+		txdp = &txq->ci_tx_ring[tx_id];
 		txep = (void *)txq->sw_ring;
 		txep += tx_id;
 	}
@@ -2252,7 +2252,7 @@ iavf_xmit_fixed_burst_vec_avx512(void *tx_queue, struct rte_mbuf **tx_pkts,
 
 	tx_id = (uint16_t)(tx_id + nb_commit);
 	if (tx_id > txq->tx_next_rs) {
-		txq->iavf_tx_ring[txq->tx_next_rs].cmd_type_offset_bsz |=
+		txq->ci_tx_ring[txq->tx_next_rs].cmd_type_offset_bsz |=
 			rte_cpu_to_le_64(((uint64_t)IAVF_TX_DESC_CMD_RS) <<
 					 IAVF_TXD_QW1_CMD_SHIFT);
 		txq->tx_next_rs =
@@ -2288,7 +2288,7 @@ iavf_xmit_fixed_burst_vec_avx512_ctx(void *tx_queue, struct rte_mbuf **tx_pkts,
 
 	nb_pkts = nb_commit >> 1;
 	tx_id = txq->tx_tail;
-	txdp = &txq->iavf_tx_ring[tx_id];
+	txdp = &txq->ci_tx_ring[tx_id];
 	txep = (void *)txq->sw_ring;
 	txep += (tx_id >> 1);
 
@@ -2309,7 +2309,7 @@ iavf_xmit_fixed_burst_vec_avx512_ctx(void *tx_queue, struct rte_mbuf **tx_pkts,
 		txq->tx_next_rs = (uint16_t)(txq->tx_rs_thresh - 1);
 		tx_id = 0;
 		/* avoid reach the end of ring */
-		txdp = txq->iavf_tx_ring;
+		txdp = txq->ci_tx_ring;
 		txep = (void *)txq->sw_ring;
 	}
 
@@ -2320,7 +2320,7 @@ iavf_xmit_fixed_burst_vec_avx512_ctx(void *tx_queue, struct rte_mbuf **tx_pkts,
 	tx_id = (uint16_t)(tx_id + nb_commit);
 
 	if (tx_id > txq->tx_next_rs) {
-		txq->iavf_tx_ring[txq->tx_next_rs].cmd_type_offset_bsz |=
+		txq->ci_tx_ring[txq->tx_next_rs].cmd_type_offset_bsz |=
 			rte_cpu_to_le_64(((uint64_t)IAVF_TX_DESC_CMD_RS) <<
 					 IAVF_TXD_QW1_CMD_SHIFT);
 		txq->tx_next_rs =
drivers/net/intel/iavf/iavf_rxtx_vec_common.h +1 -1
index f1ea57034f..1832b76f89 100644
@@ -14,7 +14,7 @@
 static inline int
 iavf_tx_desc_done(struct ci_tx_queue *txq, uint16_t idx)
 {
-	return (txq->iavf_tx_ring[idx].cmd_type_offset_bsz &
+	return (txq->ci_tx_ring[idx].cmd_type_offset_bsz &
 			rte_cpu_to_le_64(IAVF_TXD_QW1_DTYPE_MASK)) ==
 				rte_cpu_to_le_64(IAVF_TX_DESC_DTYPE_DESC_DONE);
 }
drivers/net/intel/ice/ice_dcf_ethdev.c +2 -2
index ab1d499cef..5f537b4c12 100644
@@ -401,11 +401,11 @@ reset_tx_queue(struct ci_tx_queue *txq)
 	txe = txq->sw_ring;
 	size = sizeof(struct ci_tx_desc) * txq->nb_tx_desc;
 	for (i = 0; i < size; i++)
-		((volatile char *)txq->ice_tx_ring)[i] = 0;
+		((volatile char *)txq->ci_tx_ring)[i] = 0;
 
 	prev = (uint16_t)(txq->nb_tx_desc - 1);
 	for (i = 0; i < txq->nb_tx_desc; i++) {
-		txq->ice_tx_ring[i].cmd_type_offset_bsz =
+		txq->ci_tx_ring[i].cmd_type_offset_bsz =
 			rte_cpu_to_le_64(IAVF_TX_DESC_DTYPE_DESC_DONE);
 		txe[i].mbuf =  NULL;
 		txe[i].last_id = i;
drivers/net/intel/ice/ice_rxtx.c +17 -17
index 74b80e7df3..e3ffbdb587 100644
@@ -1117,11 +1117,11 @@ ice_reset_tx_queue(struct ci_tx_queue *txq)
 	txe = txq->sw_ring;
 	size = sizeof(struct ci_tx_desc) * txq->nb_tx_desc;
 	for (i = 0; i < size; i++)
-		((volatile char *)txq->ice_tx_ring)[i] = 0;
+		((volatile char *)txq->ci_tx_ring)[i] = 0;
 
 	prev = (uint16_t)(txq->nb_tx_desc - 1);
 	for (i = 0; i < txq->nb_tx_desc; i++) {
-		volatile struct ci_tx_desc *txd = &txq->ice_tx_ring[i];
+		volatile struct ci_tx_desc *txd = &txq->ci_tx_ring[i];
 
 		txd->cmd_type_offset_bsz =
 			rte_cpu_to_le_64(ICE_TX_DESC_DTYPE_DESC_DONE);
@@ -1625,7 +1625,7 @@ ice_tx_queue_setup(struct rte_eth_dev *dev,
 	/* Allocate TX hardware ring descriptors. */
 	ring_size = sizeof(struct ci_tx_desc) * ICE_MAX_NUM_DESC_BY_MAC(hw);
 	ring_size = RTE_ALIGN(ring_size, ICE_DMA_MEM_ALIGN);
-	tz = rte_eth_dma_zone_reserve(dev, "ice_tx_ring", queue_idx,
+	tz = rte_eth_dma_zone_reserve(dev, "ci_tx_ring", queue_idx,
 				      ring_size, ICE_RING_BASE_ALIGN,
 				      socket_id);
 	if (!tz) {
@@ -1649,7 +1649,7 @@ ice_tx_queue_setup(struct rte_eth_dev *dev,
 	txq->tx_deferred_start = tx_conf->tx_deferred_start;
 
 	txq->tx_ring_dma = tz->iova;
-	txq->ice_tx_ring = tz->addr;
+	txq->ci_tx_ring = tz->addr;
 
 	/* Allocate software ring */
 	txq->sw_ring =
@@ -2555,7 +2555,7 @@ ice_tx_descriptor_status(void *tx_queue, uint16_t offset)
 			desc -= txq->nb_tx_desc;
 	}
 
-	status = &txq->ice_tx_ring[desc].cmd_type_offset_bsz;
+	status = &txq->ci_tx_ring[desc].cmd_type_offset_bsz;
 	mask = rte_cpu_to_le_64(ICE_TXD_QW1_DTYPE_M);
 	expect = rte_cpu_to_le_64(ICE_TX_DESC_DTYPE_DESC_DONE <<
 				  ICE_TXD_QW1_DTYPE_S);
@@ -2638,7 +2638,7 @@ ice_fdir_setup_tx_resources(struct ice_pf *pf)
 	txq->ice_vsi = pf->fdir.fdir_vsi;
 
 	txq->tx_ring_dma = tz->iova;
-	txq->ice_tx_ring = (struct ci_tx_desc *)tz->addr;
+	txq->ci_tx_ring = (struct ci_tx_desc *)tz->addr;
 	/*
 	 * don't need to allocate software ring and reset for the fdir
 	 * program queue just set the queue has been configured.
@@ -3027,7 +3027,7 @@ static inline int
 ice_xmit_cleanup(struct ci_tx_queue *txq)
 {
 	struct ci_tx_entry *sw_ring = txq->sw_ring;
-	volatile struct ci_tx_desc *txd = txq->ice_tx_ring;
+	volatile struct ci_tx_desc *txd = txq->ci_tx_ring;
 	uint16_t last_desc_cleaned = txq->last_desc_cleaned;
 	uint16_t nb_tx_desc = txq->nb_tx_desc;
 	uint16_t desc_to_clean_to;
@@ -3148,7 +3148,7 @@ uint16_t
 ice_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 {
 	struct ci_tx_queue *txq;
-	volatile struct ci_tx_desc *ice_tx_ring;
+	volatile struct ci_tx_desc *ci_tx_ring;
 	volatile struct ci_tx_desc *txd;
 	struct ci_tx_entry *sw_ring;
 	struct ci_tx_entry *txe, *txn;
@@ -3171,7 +3171,7 @@ ice_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 
 	txq = tx_queue;
 	sw_ring = txq->sw_ring;
-	ice_tx_ring = txq->ice_tx_ring;
+	ci_tx_ring = txq->ci_tx_ring;
 	tx_id = txq->tx_tail;
 	txe = &sw_ring[tx_id];
 
@@ -3257,7 +3257,7 @@ ice_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 			/* Setup TX context descriptor if required */
 			volatile struct ice_tx_ctx_desc *ctx_txd =
 				(volatile struct ice_tx_ctx_desc *)
-					&ice_tx_ring[tx_id];
+					&ci_tx_ring[tx_id];
 			uint16_t cd_l2tag2 = 0;
 			uint64_t cd_type_cmd_tso_mss = ICE_TX_DESC_DTYPE_CTX;
 
@@ -3299,7 +3299,7 @@ ice_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 		m_seg = tx_pkt;
 
 		do {
-			txd = &ice_tx_ring[tx_id];
+			txd = &ci_tx_ring[tx_id];
 			txn = &sw_ring[txe->next_id];
 
 			if (txe->mbuf)
@@ -3327,7 +3327,7 @@ ice_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 				txe->last_id = tx_last;
 				tx_id = txe->next_id;
 				txe = txn;
-				txd = &ice_tx_ring[tx_id];
+				txd = &ci_tx_ring[tx_id];
 				txn = &sw_ring[txe->next_id];
 			}
 
@@ -3410,7 +3410,7 @@ ice_tx_free_bufs(struct ci_tx_queue *txq)
 	struct ci_tx_entry *txep;
 	uint16_t i;
 
-	if ((txq->ice_tx_ring[txq->tx_next_dd].cmd_type_offset_bsz &
+	if ((txq->ci_tx_ring[txq->tx_next_dd].cmd_type_offset_bsz &
 	     rte_cpu_to_le_64(ICE_TXD_QW1_DTYPE_M)) !=
 	    rte_cpu_to_le_64(ICE_TX_DESC_DTYPE_DESC_DONE))
 		return 0;
@@ -3594,7 +3594,7 @@ static inline void
 ice_tx_fill_hw_ring(struct ci_tx_queue *txq, struct rte_mbuf **pkts,
 		    uint16_t nb_pkts)
 {
-	volatile struct ci_tx_desc *txdp = &txq->ice_tx_ring[txq->tx_tail];
+	volatile struct ci_tx_desc *txdp = &txq->ci_tx_ring[txq->tx_tail];
 	struct ci_tx_entry *txep = &txq->sw_ring[txq->tx_tail];
 	const int N_PER_LOOP = 4;
 	const int N_PER_LOOP_MASK = N_PER_LOOP - 1;
@@ -3627,7 +3627,7 @@ tx_xmit_pkts(struct ci_tx_queue *txq,
 	     struct rte_mbuf **tx_pkts,
 	     uint16_t nb_pkts)
 {
-	volatile struct ci_tx_desc *txr = txq->ice_tx_ring;
+	volatile struct ci_tx_desc *txr = txq->ci_tx_ring;
 	uint16_t n = 0;
 
 	/**
@@ -4887,11 +4887,11 @@ ice_fdir_programming(struct ice_pf *pf, struct ice_fltr_desc *fdir_desc)
 	uint16_t i;
 
 	fdirdp = (volatile struct ice_fltr_desc *)
-		(&txq->ice_tx_ring[txq->tx_tail]);
+		(&txq->ci_tx_ring[txq->tx_tail]);
 	fdirdp->qidx_compq_space_stat = fdir_desc->qidx_compq_space_stat;
 	fdirdp->dtype_cmd_vsi_fdid = fdir_desc->dtype_cmd_vsi_fdid;
 
-	txdp = &txq->ice_tx_ring[txq->tx_tail + 1];
+	txdp = &txq->ci_tx_ring[txq->tx_tail + 1];
 	txdp->buffer_addr = rte_cpu_to_le_64(pf->fdir.dma_addr);
 	td_cmd = ICE_TX_DESC_CMD_EOP |
 		ICE_TX_DESC_CMD_RS  |
drivers/net/intel/ice/ice_rxtx_vec_avx2.c +3 -3
index bef7bb00ba..0a1df0b2f6 100644
@@ -869,7 +869,7 @@ ice_xmit_fixed_burst_vec_avx2(void *tx_queue, struct rte_mbuf **tx_pkts,
 		return 0;
 
 	tx_id = txq->tx_tail;
-	txdp = &txq->ice_tx_ring[tx_id];
+	txdp = &txq->ci_tx_ring[tx_id];
 	txep = &txq->sw_ring_vec[tx_id];
 
 	txq->nb_tx_free = (uint16_t)(txq->nb_tx_free - nb_pkts);
@@ -890,7 +890,7 @@ ice_xmit_fixed_burst_vec_avx2(void *tx_queue, struct rte_mbuf **tx_pkts,
 		txq->tx_next_rs = (uint16_t)(txq->tx_rs_thresh - 1);
 
 		/* avoid reach the end of ring */
-		txdp = &txq->ice_tx_ring[tx_id];
+		txdp = &txq->ci_tx_ring[tx_id];
 		txep = &txq->sw_ring_vec[tx_id];
 	}
 
@@ -900,7 +900,7 @@ ice_xmit_fixed_burst_vec_avx2(void *tx_queue, struct rte_mbuf **tx_pkts,
 
 	tx_id = (uint16_t)(tx_id + nb_commit);
 	if (tx_id > txq->tx_next_rs) {
-		txq->ice_tx_ring[txq->tx_next_rs].cmd_type_offset_bsz |=
+		txq->ci_tx_ring[txq->tx_next_rs].cmd_type_offset_bsz |=
 			rte_cpu_to_le_64(((uint64_t)ICE_TX_DESC_CMD_RS) <<
 					 ICE_TXD_QW1_CMD_S);
 		txq->tx_next_rs =
drivers/net/intel/ice/ice_rxtx_vec_avx512.c +3 -3
index 1f6bf5fc8e..d42f41461f 100644
@@ -933,7 +933,7 @@ ice_xmit_fixed_burst_vec_avx512(void *tx_queue, struct rte_mbuf **tx_pkts,
 		return 0;
 
 	tx_id = txq->tx_tail;
-	txdp = &txq->ice_tx_ring[tx_id];
+	txdp = &txq->ci_tx_ring[tx_id];
 	txep = (void *)txq->sw_ring;
 	txep += tx_id;
 
@@ -955,7 +955,7 @@ ice_xmit_fixed_burst_vec_avx512(void *tx_queue, struct rte_mbuf **tx_pkts,
 		txq->tx_next_rs = (uint16_t)(txq->tx_rs_thresh - 1);
 
 		/* avoid reach the end of ring */
-		txdp = txq->ice_tx_ring;
+		txdp = txq->ci_tx_ring;
 		txep = (void *)txq->sw_ring;
 	}
 
@@ -965,7 +965,7 @@ ice_xmit_fixed_burst_vec_avx512(void *tx_queue, struct rte_mbuf **tx_pkts,
 
 	tx_id = (uint16_t)(tx_id + nb_commit);
 	if (tx_id > txq->tx_next_rs) {
-		txq->ice_tx_ring[txq->tx_next_rs].cmd_type_offset_bsz |=
+		txq->ci_tx_ring[txq->tx_next_rs].cmd_type_offset_bsz |=
 			rte_cpu_to_le_64(((uint64_t)ICE_TX_DESC_CMD_RS) <<
 					 ICE_TXD_QW1_CMD_S);
 		txq->tx_next_rs =
drivers/net/intel/ice/ice_rxtx_vec_common.h +1 -1
index ff46a8fb49..8ba591e403 100644
@@ -11,7 +11,7 @@
 static inline int
 ice_tx_desc_done(struct ci_tx_queue *txq, uint16_t idx)
 {
-	return (txq->ice_tx_ring[idx].cmd_type_offset_bsz &
+	return (txq->ci_tx_ring[idx].cmd_type_offset_bsz &
 			rte_cpu_to_le_64(ICE_TXD_QW1_DTYPE_M)) ==
 				rte_cpu_to_le_64(ICE_TX_DESC_DTYPE_DESC_DONE);
 }
drivers/net/intel/idpf/idpf_common_rxtx.c +4 -4
index be3c1ef216..51074bda3a 100644
@@ -266,11 +266,11 @@ idpf_qc_single_tx_queue_reset(struct ci_tx_queue *txq)
 	txe = txq->sw_ring;
 	size = sizeof(struct ci_tx_desc) * txq->nb_tx_desc;
 	for (i = 0; i < size; i++)
-		((volatile char *)txq->idpf_tx_ring)[i] = 0;
+		((volatile char *)txq->ci_tx_ring)[i] = 0;
 
 	prev = (uint16_t)(txq->nb_tx_desc - 1);
 	for (i = 0; i < txq->nb_tx_desc; i++) {
-		txq->idpf_tx_ring[i].cmd_type_offset_bsz =
+		txq->ci_tx_ring[i].cmd_type_offset_bsz =
 			rte_cpu_to_le_64(IDPF_TX_DESC_DTYPE_DESC_DONE);
 		txe[i].mbuf =  NULL;
 		txe[i].last_id = i;
@@ -1335,7 +1335,7 @@ idpf_xmit_cleanup(struct ci_tx_queue *txq)
 	uint16_t desc_to_clean_to;
 	uint16_t nb_tx_to_clean;
 
-	volatile struct ci_tx_desc *txd = txq->idpf_tx_ring;
+	volatile struct ci_tx_desc *txd = txq->ci_tx_ring;
 
 	desc_to_clean_to = (uint16_t)(last_desc_cleaned + txq->tx_rs_thresh);
 	if (desc_to_clean_to >= nb_tx_desc)
@@ -1398,7 +1398,7 @@ idpf_dp_singleq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 		return nb_tx;
 
 	sw_ring = txq->sw_ring;
-	txr = txq->idpf_tx_ring;
+	txr = txq->ci_tx_ring;
 	tx_id = txq->tx_tail;
 	txe = &sw_ring[tx_id];
 
drivers/net/intel/idpf/idpf_common_rxtx_avx2.c +3 -3
index 5f5d538dcb..04efee3722 100644
@@ -573,7 +573,7 @@ idpf_singleq_xmit_fixed_burst_vec_avx2(void *tx_queue, struct rte_mbuf **tx_pkts
 		return 0;
 
 	tx_id = txq->tx_tail;
-	txdp = &txq->idpf_tx_ring[tx_id];
+	txdp = &txq->ci_tx_ring[tx_id];
 	txep = &txq->sw_ring_vec[tx_id];
 
 	txq->nb_tx_free = (uint16_t)(txq->nb_tx_free - nb_pkts);
@@ -594,7 +594,7 @@ idpf_singleq_xmit_fixed_burst_vec_avx2(void *tx_queue, struct rte_mbuf **tx_pkts
 		txq->tx_next_rs = (uint16_t)(txq->tx_rs_thresh - 1);
 
 		/* avoid reach the end of ring */
-		txdp = &txq->idpf_tx_ring[tx_id];
+		txdp = &txq->ci_tx_ring[tx_id];
 		txep = &txq->sw_ring_vec[tx_id];
 	}
 
@@ -604,7 +604,7 @@ idpf_singleq_xmit_fixed_burst_vec_avx2(void *tx_queue, struct rte_mbuf **tx_pkts
 
 	tx_id = (uint16_t)(tx_id + nb_commit);
 	if (tx_id > txq->tx_next_rs) {
-		txq->idpf_tx_ring[txq->tx_next_rs].cmd_type_offset_bsz |=
+		txq->ci_tx_ring[txq->tx_next_rs].cmd_type_offset_bsz |=
 			rte_cpu_to_le_64(((uint64_t)IDPF_TX_DESC_CMD_RS) <<
 					 IDPF_TXD_QW1_CMD_S);
 		txq->tx_next_rs =
drivers/net/intel/idpf/idpf_common_rxtx_avx512.c +3 -3
index c1ec3d1222..d5e5a2ca5f 100644
@@ -1090,7 +1090,7 @@ idpf_singleq_xmit_fixed_burst_vec_avx512(void *tx_queue, struct rte_mbuf **tx_pk
 		return 0;
 
 	tx_id = txq->tx_tail;
-	txdp = &txq->idpf_tx_ring[tx_id];
+	txdp = &txq->ci_tx_ring[tx_id];
 	txep = (void *)txq->sw_ring;
 	txep += tx_id;
 
@@ -1112,7 +1112,7 @@ idpf_singleq_xmit_fixed_burst_vec_avx512(void *tx_queue, struct rte_mbuf **tx_pk
 		txq->tx_next_rs = (uint16_t)(txq->tx_rs_thresh - 1);
 
 		/* avoid reach the end of ring */
-		txdp = &txq->idpf_tx_ring[tx_id];
+		txdp = &txq->ci_tx_ring[tx_id];
 		txep = (void *)txq->sw_ring;
 		txep += tx_id;
 	}
@@ -1123,7 +1123,7 @@ idpf_singleq_xmit_fixed_burst_vec_avx512(void *tx_queue, struct rte_mbuf **tx_pk
 
 	tx_id = (uint16_t)(tx_id + nb_commit);
 	if (tx_id > txq->tx_next_rs) {
-		txq->idpf_tx_ring[txq->tx_next_rs].cmd_type_offset_bsz |=
+		txq->ci_tx_ring[txq->tx_next_rs].cmd_type_offset_bsz |=
 			rte_cpu_to_le_64(((uint64_t)IDPF_TX_DESC_CMD_RS) <<
 					 IDPF_TXD_QW1_CMD_S);
 		txq->tx_next_rs =
drivers/net/intel/idpf/idpf_rxtx.c +1 -1
index 8aa44585fe..0de54d9305 100644
@@ -481,7 +481,7 @@ idpf_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 	}
 
 	if (!is_splitq) {
-		txq->idpf_tx_ring = mz->addr;
+		txq->ci_tx_ring = mz->addr;
 		idpf_qc_single_tx_queue_reset(txq);
 	} else {
 		txq->desc_ring = mz->addr;
drivers/net/intel/idpf/idpf_rxtx_vec_common.h +1 -1
index 4702061484..b5e8574667 100644
@@ -31,7 +31,7 @@ idpf_tx_desc_done(struct ci_tx_queue *txq, uint16_t idx)
 	if (txq->complq != NULL)
 		return 1;
 
-	return (txq->idpf_tx_ring[idx].cmd_type_offset_bsz &
+	return (txq->ci_tx_ring[idx].cmd_type_offset_bsz &
 			rte_cpu_to_le_64(IDPF_TXD_QW1_DTYPE_M)) ==
 				rte_cpu_to_le_64(IDPF_TX_DESC_DTYPE_DESC_DONE);
 }
Signature · 1 line
2.51.0
#133 lore raw

PATCH v4 3/35 net/intel: create common post-Tx cleanup function

In reply to Bruce Richardson

The code used in ice, iavf, idpf and i40e for doing cleanup of mbufs after they had been transmitted was identical. Therefore deduplicate it by moving to common and remove the driver-specific versions.

Rather than having all Tx code in the one file, which could start getting rather long, create a new header file for scalar datapath functions.

---
 drivers/net/intel/common/tx.h             |  5 ++
 drivers/net/intel/common/tx_scalar.h      | 62 +++++++++++++++++++++++
 drivers/net/intel/i40e/i40e_rxtx.c        | 49 ++----------------
 drivers/net/intel/iavf/iavf_rxtx.c        | 50 ++----------------
 drivers/net/intel/ice/ice_rxtx.c          | 60 ++--------------------
 drivers/net/intel/idpf/idpf_common_rxtx.c | 46 ++---------------
 6 files changed, 85 insertions(+), 187 deletions(-)
 create mode 100644 drivers/net/intel/common/tx_scalar.h
drivers/net/intel/common/tx.h +5 -0
index 8cf63e59ab..558c861df0 100644
@@ -377,4 +377,9 @@ ci_tx_path_select(const struct ci_tx_path_features *req_features,
 	return idx;
 }
 
+/* include the scalar functions at the end, so they can use the common definitions.
+ * This is done so drivers can use all functions just by including tx.h
+ */
+#include "tx_scalar.h"
+
 #endif /* _COMMON_INTEL_TX_H_ */
drivers/net/intel/common/tx_scalar.h new file +62 -0

62 lines not on this page · raw message

drivers/net/intel/i40e/i40e_rxtx.c +5 -44

85 lines not on this page · raw message

drivers/net/intel/iavf/iavf_rxtx.c +5 -45

86 lines not on this page · raw message

drivers/net/intel/ice/ice_rxtx.c +5 -55

96 lines not on this page · raw message

drivers/net/intel/idpf/idpf_common_rxtx.c +3 -43

70 lines not on this page · raw message

Signature · 1 line
2.51.0
Acked-by on v4 3/35
#134 lore raw

Re: [PATCH v4 03/35] net/intel: create common post-Tx cleanup function

Quoted 10 lines · Bruce Richardson

The code used in ice, iavf, idpf and i40e for doing cleanup of mbufs after they had been transmitted was identical. Therefore deduplicate it by moving to common and remove the driver-specific versions.

Rather than having all Tx code in the one file, which could start getting rather long, create a new header file for scalar datapath functions.

---

<snip>

Quoted 9 lines
drivers/net/intel/common/tx_scalar.h new file +9 -0
+static __rte_always_inline int
+ci_tx_xmit_cleanup(struct ci_tx_queue *txq)
+{
+	struct ci_tx_entry *sw_ring = txq->sw_ring;
+	volatile struct ci_tx_desc *txd = txq->ci_tx_ring;
+	uint16_t last_desc_cleaned = txq->last_desc_cleaned;
+	uint16_t nb_tx_desc = txq->nb_tx_desc;
+	uint16_t desc_to_clean_to;
+	uint16_t nb_tx_to_clean;

drivers/net/intel/common/tx_scalar.h line 39

Quoted 10 lines
drivers/net/intel/common/tx_scalar.h new file +10 -0
+
+	/* Determine the last descriptor needing to be cleaned */
+	desc_to_clean_to = (uint16_t)(last_desc_cleaned + txq->tx_rs_thresh);
+	if (desc_to_clean_to >= nb_tx_desc)
+		desc_to_clean_to = (uint16_t)(desc_to_clean_to - nb_tx_desc);
+
+	/* Check if descriptor is done - all drivers use 0xF as done value in bits 3:0 */
+	desc_to_clean_to = sw_ring[desc_to_clean_to].last_id;
+	if ((txd[desc_to_clean_to].cmd_type_offset_bsz & rte_cpu_to_le_64(0x0FUL)) !=
+			rte_cpu_to_le_64(0x0FUL))

Kind of a nitpick - we do this kind of "(value & mask) == mask" in a lot of places, and occasionally it needs these byteswaps and whatnot, which IMO hurts readability as there's too much going on on a single line.

I think it would be good to add a helper function e.g.

uint64_t desc_done_msk = rte_cpu_to_le_64(0x0FUL);
if (mask_is_set(txd[desc_to_clean_to].cmd_type_offset_bsz, desc_done_msk)) ....

and use it where we can to make the code a bit more semantically meaningful.

That said, not a biggie, so

Signature · 2 lines
Thanks,
Anatoly
#135 lore raw

PATCH v4 4/35 net/intel: consolidate definitions for Tx desc fields

In reply to Bruce Richardson

The offsets of the various fields within the Tx descriptors are common for i40e, iavf, ice and idpf, so put a single set of defines in tx.h and use those throughout all drivers. (NOTE: there was a small difference in mask of CMD field between drivers depending on whether reserved fields or not were included. Those can be ignored as those bits are unused in the drivers for which they are reserved). Similarly, the various flag fields, such as End-of-packet (EOP) and Report-status (RS) are the same, as are offload definitions so consolidate them.

Original definitions are in base code, and are left in place because of that, but are unused.

---
 drivers/net/intel/common/tx.h                 |  60 ++++++++
 drivers/net/intel/common/tx_scalar.h          |   6 +-
 drivers/net/intel/i40e/i40e_fdir.c            |  24 +--
 drivers/net/intel/i40e/i40e_rxtx.c            |  92 ++++++------
 drivers/net/intel/i40e/i40e_rxtx.h            |  17 +--
 .../net/intel/i40e/i40e_rxtx_vec_altivec.c    |  11 +-
 drivers/net/intel/i40e/i40e_rxtx_vec_avx2.c   |  22 ++-
 drivers/net/intel/i40e/i40e_rxtx_vec_avx512.c |  38 ++---
 drivers/net/intel/i40e/i40e_rxtx_vec_common.h |   4 +-
 drivers/net/intel/i40e/i40e_rxtx_vec_neon.c   |  11 +-
 drivers/net/intel/iavf/iavf_rxtx.c            |  68 +++++----
 drivers/net/intel/iavf/iavf_rxtx.h            |  20 +--
 drivers/net/intel/iavf/iavf_rxtx_vec_avx2.c   |  41 ++----
 drivers/net/intel/iavf/iavf_rxtx_vec_avx512.c |  80 ++++------
 drivers/net/intel/iavf/iavf_rxtx_vec_common.h |  34 ++---
 drivers/net/intel/ice/ice_dcf_ethdev.c        |   2 +-
 drivers/net/intel/ice/ice_rxtx.c              | 137 ++++++++----------
 drivers/net/intel/ice/ice_rxtx.h              |  15 +-
 drivers/net/intel/ice/ice_rxtx_vec_avx2.c     |  41 ++----
 drivers/net/intel/ice/ice_rxtx_vec_avx512.c   |  39 ++---
 drivers/net/intel/ice/ice_rxtx_vec_common.h   |  41 +++---
 drivers/net/intel/idpf/idpf_common_rxtx.c     |  22 +--
 drivers/net/intel/idpf/idpf_common_rxtx.h     |  12 --
 .../net/intel/idpf/idpf_common_rxtx_avx2.c    |  41 ++----
 .../net/intel/idpf/idpf_common_rxtx_avx512.c  |  41 ++----
 drivers/net/intel/idpf/idpf_rxtx_vec_common.h |   4 +-
 26 files changed, 409 insertions(+), 514 deletions(-)
drivers/net/intel/common/tx.h +60 -0
index 558c861df0..091f220f1c 100644
@@ -10,6 +10,66 @@
 #include <rte_ethdev.h>
 #include <rte_vect.h>
 
+/* Common TX Descriptor QW1 Field Definitions */
+#define CI_TXD_QW1_DTYPE_S      0
+#define CI_TXD_QW1_DTYPE_M      (0xFUL << CI_TXD_QW1_DTYPE_S)
+#define CI_TXD_QW1_CMD_S        4
+#define CI_TXD_QW1_CMD_M        (0xFFFUL << CI_TXD_QW1_CMD_S)
+#define CI_TXD_QW1_OFFSET_S     16
+#define CI_TXD_QW1_OFFSET_M     (0x3FFFFULL << CI_TXD_QW1_OFFSET_S)
+#define CI_TXD_QW1_TX_BUF_SZ_S  34
+#define CI_TXD_QW1_TX_BUF_SZ_M  (0x3FFFULL << CI_TXD_QW1_TX_BUF_SZ_S)
+#define CI_TXD_QW1_L2TAG1_S     48
+#define CI_TXD_QW1_L2TAG1_M     (0xFFFFULL << CI_TXD_QW1_L2TAG1_S)
+
+/* Common Descriptor Types */
+#define CI_TX_DESC_DTYPE_DATA           0x0
+#define CI_TX_DESC_DTYPE_CTX            0x1
+#define CI_TX_DESC_DTYPE_DESC_DONE      0xF
+
+/* Common TX Descriptor Command Flags */
+#define CI_TX_DESC_CMD_EOP              0x0001
+#define CI_TX_DESC_CMD_RS               0x0002
+#define CI_TX_DESC_CMD_ICRC             0x0004
+#define CI_TX_DESC_CMD_IL2TAG1          0x0008
+#define CI_TX_DESC_CMD_DUMMY            0x0010
+#define CI_TX_DESC_CMD_IIPT_IPV6        0x0020
+#define CI_TX_DESC_CMD_IIPT_IPV4        0x0040
+#define CI_TX_DESC_CMD_IIPT_IPV4_CSUM   0x0060
+#define CI_TX_DESC_CMD_L4T_EOFT_TCP     0x0100
+#define CI_TX_DESC_CMD_L4T_EOFT_SCTP    0x0200
+#define CI_TX_DESC_CMD_L4T_EOFT_UDP     0x0300
+
+/* Common TX Context Descriptor Commands */
+#define CI_TX_CTX_DESC_TSO              0x01
+#define CI_TX_CTX_DESC_TSYN             0x02
+#define CI_TX_CTX_DESC_IL2TAG2          0x04
+
+/* Common TX Descriptor Length Field Shifts */
+#define CI_TX_DESC_LEN_MACLEN_S         0  /* 7 BITS */
+#define CI_TX_DESC_LEN_IPLEN_S          7  /* 7 BITS */
+#define CI_TX_DESC_LEN_L4_LEN_S         14 /* 4 BITS */
+
+/* Common maximum data per TX descriptor */
+#define CI_MAX_DATA_PER_TXD     (CI_TXD_QW1_TX_BUF_SZ_M >> CI_TXD_QW1_TX_BUF_SZ_S)
+
+/**
+ * Common TX offload union for Intel drivers.
+ * Supports both basic offloads (l2_len, l3_len, l4_len, tso_segsz) and
+ * extended offloads (outer_l2_len, outer_l3_len) for tunneling support.
+ */
+union ci_tx_offload {
+	uint64_t data;
+	struct {
+		uint64_t l2_len:7;        /**< L2 (MAC) Header Length. */
+		uint64_t l3_len:9;        /**< L3 (IP) Header Length. */
+		uint64_t l4_len:8;        /**< L4 Header Length. */
+		uint64_t tso_segsz:16;    /**< TCP TSO segment size */
+		uint64_t outer_l2_len:8;  /**< outer L2 Header Length */
+		uint64_t outer_l3_len:16; /**< outer L3 Header Length */
+	};
+};
+
 /*
  * Structure of a 16-byte Tx descriptor common across i40e, ice, iavf and idpf drivers
  */
drivers/net/intel/common/tx_scalar.h +3 -3
index 181629d856..6f2024273b 100644
@@ -33,10 +33,10 @@ ci_tx_xmit_cleanup(struct ci_tx_queue *txq)
 	if (desc_to_clean_to >= nb_tx_desc)
 		desc_to_clean_to = (uint16_t)(desc_to_clean_to - nb_tx_desc);
 
-	/* Check if descriptor is done - all drivers use 0xF as done value in bits 3:0 */
+	/* Check if descriptor is done */
 	desc_to_clean_to = sw_ring[desc_to_clean_to].last_id;
-	if ((txd[desc_to_clean_to].cmd_type_offset_bsz & rte_cpu_to_le_64(0x0FUL)) !=
-			rte_cpu_to_le_64(0x0FUL))
+	if ((txd[desc_to_clean_to].cmd_type_offset_bsz & rte_cpu_to_le_64(CI_TXD_QW1_DTYPE_M)) !=
+			rte_cpu_to_le_64(CI_TX_DESC_DTYPE_DESC_DONE))
 		return -1;
 
 	/* Figure out how many descriptors will be cleaned */
drivers/net/intel/i40e/i40e_fdir.c +12 -12
index 8a01aec0e2..3b099d5a9e 100644
@@ -916,11 +916,11 @@ i40e_build_ctob(uint32_t td_cmd,
 		unsigned int size,
 		uint32_t td_tag)
 {
-	return rte_cpu_to_le_64(I40E_TX_DESC_DTYPE_DATA |
-			((uint64_t)td_cmd  << I40E_TXD_QW1_CMD_SHIFT) |
-			((uint64_t)td_offset << I40E_TXD_QW1_OFFSET_SHIFT) |
-			((uint64_t)size  << I40E_TXD_QW1_TX_BUF_SZ_SHIFT) |
-			((uint64_t)td_tag  << I40E_TXD_QW1_L2TAG1_SHIFT));
+	return rte_cpu_to_le_64(CI_TX_DESC_DTYPE_DATA |
+			((uint64_t)td_cmd  << CI_TXD_QW1_CMD_S) |
+			((uint64_t)td_offset << CI_TXD_QW1_OFFSET_S) |
+			((uint64_t)size  << CI_TXD_QW1_TX_BUF_SZ_S) |
+			((uint64_t)td_tag  << CI_TXD_QW1_L2TAG1_S));
 }
 
 /*
@@ -1384,8 +1384,8 @@ i40e_find_available_buffer(struct rte_eth_dev *dev)
 
 		do {
 			if ((tmp_txdp->cmd_type_offset_bsz &
-					rte_cpu_to_le_64(I40E_TXD_QW1_DTYPE_MASK)) ==
-					rte_cpu_to_le_64(I40E_TX_DESC_DTYPE_DESC_DONE))
+					rte_cpu_to_le_64(CI_TXD_QW1_DTYPE_M)) ==
+					rte_cpu_to_le_64(CI_TX_DESC_DTYPE_DESC_DONE))
 				fdir_info->txq_available_buf_count++;
 			else
 				break;
@@ -1710,9 +1710,9 @@ i40e_flow_fdir_filter_programming(struct i40e_pf *pf,
 	txdp = &txq->ci_tx_ring[txq->tx_tail + 1];
 	txdp->buffer_addr = rte_cpu_to_le_64(pf->fdir.dma_addr[txq->tx_tail >> 1]);
 
-	td_cmd = I40E_TX_DESC_CMD_EOP |
-		 I40E_TX_DESC_CMD_RS  |
-		 I40E_TX_DESC_CMD_DUMMY;
+	td_cmd = CI_TX_DESC_CMD_EOP |
+		 CI_TX_DESC_CMD_RS  |
+		 CI_TX_DESC_CMD_DUMMY;
 
 	txdp->cmd_type_offset_bsz =
 		i40e_build_ctob(td_cmd, 0, I40E_FDIR_PKT_LEN, 0);
@@ -1731,8 +1731,8 @@ i40e_flow_fdir_filter_programming(struct i40e_pf *pf,
 	if (wait_status) {
 		for (i = 0; i < I40E_FDIR_MAX_WAIT_US; i++) {
 			if ((txdp->cmd_type_offset_bsz &
-					rte_cpu_to_le_64(I40E_TXD_QW1_DTYPE_MASK)) ==
-					rte_cpu_to_le_64(I40E_TX_DESC_DTYPE_DESC_DONE))
+					rte_cpu_to_le_64(CI_TXD_QW1_DTYPE_M)) ==
+					rte_cpu_to_le_64(CI_TX_DESC_DTYPE_DESC_DONE))
 				break;
 			rte_delay_us(1);
 		}
drivers/net/intel/i40e/i40e_rxtx.c +43 -49

245 lines not on this page · raw message

drivers/net/intel/i40e/i40e_rxtx.h +2 -15
index ed173d8f17..307ffa3049 100644
@@ -47,8 +47,8 @@
 #define I40E_RX_DESC_EXT_STATUS_FLEXBL_MASK   0x03
 #define I40E_RX_DESC_EXT_STATUS_FLEXBL_FLEX   0x01
 
-#define I40E_TD_CMD (I40E_TX_DESC_CMD_ICRC |\
-		     I40E_TX_DESC_CMD_EOP)
+#define I40E_TD_CMD (CI_TX_DESC_CMD_ICRC |\
+		     CI_TX_DESC_CMD_EOP)
 
 enum i40e_header_split_mode {
 	i40e_header_split_none = 0,
@@ -110,19 +110,6 @@ enum i40e_header_split_mode {
 
 #define I40E_TX_VECTOR_OFFLOADS RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE
 
-/** Offload features */
-union i40e_tx_offload {
-	uint64_t data;
-	struct {
-		uint64_t l2_len:7; /**< L2 (MAC) Header Length. */
-		uint64_t l3_len:9; /**< L3 (IP) Header Length. */
-		uint64_t l4_len:8; /**< L4 Header Length. */
-		uint64_t tso_segsz:16; /**< TCP TSO segment size */
-		uint64_t outer_l2_len:8; /**< outer L2 Header Length */
-		uint64_t outer_l3_len:16; /**< outer L3 Header Length */
-	};
-};
-
 int i40e_dev_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id);
 int i40e_dev_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id);
 int i40e_dev_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id);
drivers/net/intel/i40e/i40e_rxtx_vec_altivec.c +5 -6
index 81e9e2bc0b..4c36748d94 100644
@@ -449,9 +449,9 @@ static inline void
 vtx1(volatile struct ci_tx_desc *txdp,
 	struct rte_mbuf *pkt, uint64_t flags)
 {
-	uint64_t high_qw = (I40E_TX_DESC_DTYPE_DATA |
-		((uint64_t)flags  << I40E_TXD_QW1_CMD_SHIFT) |
-		((uint64_t)pkt->data_len << I40E_TXD_QW1_TX_BUF_SZ_SHIFT));
+	uint64_t high_qw = (CI_TX_DESC_DTYPE_DATA |
+		((uint64_t)flags << CI_TXD_QW1_CMD_S) |
+		((uint64_t)pkt->data_len << CI_TXD_QW1_TX_BUF_SZ_S));
 
 	__vector unsigned long descriptor = (__vector unsigned long){
 		pkt->buf_iova + pkt->data_off, high_qw};
@@ -477,7 +477,7 @@ i40e_xmit_fixed_burst_vec(void *tx_queue, struct rte_mbuf **tx_pkts,
 	struct ci_tx_entry_vec *txep;
 	uint16_t n, nb_commit, tx_id;
 	uint64_t flags = I40E_TD_CMD;
-	uint64_t rs = I40E_TX_DESC_CMD_RS | I40E_TD_CMD;
+	uint64_t rs = CI_TX_DESC_CMD_RS | I40E_TD_CMD;
 	int i;
 
 	if (txq->nb_tx_free < txq->tx_free_thresh)
@@ -520,8 +520,7 @@ i40e_xmit_fixed_burst_vec(void *tx_queue, struct rte_mbuf **tx_pkts,
 	tx_id = (uint16_t)(tx_id + nb_commit);
 	if (tx_id > txq->tx_next_rs) {
 		txq->ci_tx_ring[txq->tx_next_rs].cmd_type_offset_bsz |=
-			rte_cpu_to_le_64(((uint64_t)I40E_TX_DESC_CMD_RS) <<
-						I40E_TXD_QW1_CMD_SHIFT);
+			rte_cpu_to_le_64(((uint64_t)CI_TX_DESC_CMD_RS) << CI_TXD_QW1_CMD_S);
 		txq->tx_next_rs =
 			(uint16_t)(txq->tx_next_rs + txq->tx_rs_thresh);
 	}
drivers/net/intel/i40e/i40e_rxtx_vec_avx2.c +10 -12
index f054bd41bf..502a1842c6 100644
@@ -684,9 +684,9 @@ static inline void
 vtx1(volatile struct ci_tx_desc *txdp,
 		struct rte_mbuf *pkt, uint64_t flags)
 {
-	uint64_t high_qw = (I40E_TX_DESC_DTYPE_DATA |
-			((uint64_t)flags  << I40E_TXD_QW1_CMD_SHIFT) |
-			((uint64_t)pkt->data_len << I40E_TXD_QW1_TX_BUF_SZ_SHIFT));
+	uint64_t high_qw = (CI_TX_DESC_DTYPE_DATA |
+			((uint64_t)flags << CI_TXD_QW1_CMD_S) |
+			((uint64_t)pkt->data_len << CI_TXD_QW1_TX_BUF_SZ_S));
 
 	__m128i descriptor = _mm_set_epi64x(high_qw,
 				pkt->buf_iova + pkt->data_off);
@@ -697,8 +697,7 @@ static inline void
 vtx(volatile struct ci_tx_desc *txdp,
 		struct rte_mbuf **pkt, uint16_t nb_pkts,  uint64_t flags)
 {
-	const uint64_t hi_qw_tmpl = (I40E_TX_DESC_DTYPE_DATA |
-			((uint64_t)flags  << I40E_TXD_QW1_CMD_SHIFT));
+	const uint64_t hi_qw_tmpl = (CI_TX_DESC_DTYPE_DATA | (flags << CI_TXD_QW1_CMD_S));
 
 	/* if unaligned on 32-bit boundary, do one to align */
 	if (((uintptr_t)txdp & 0x1F) != 0 && nb_pkts != 0) {
@@ -709,13 +708,13 @@ vtx(volatile struct ci_tx_desc *txdp,
 	/* do two at a time while possible, in bursts */
 	for (; nb_pkts > 3; txdp += 4, pkt += 4, nb_pkts -= 4) {
 		uint64_t hi_qw3 = hi_qw_tmpl |
-				((uint64_t)pkt[3]->data_len << I40E_TXD_QW1_TX_BUF_SZ_SHIFT);
+				((uint64_t)pkt[3]->data_len << CI_TXD_QW1_TX_BUF_SZ_S);
 		uint64_t hi_qw2 = hi_qw_tmpl |
-				((uint64_t)pkt[2]->data_len << I40E_TXD_QW1_TX_BUF_SZ_SHIFT);
+				((uint64_t)pkt[2]->data_len << CI_TXD_QW1_TX_BUF_SZ_S);
 		uint64_t hi_qw1 = hi_qw_tmpl |
-				((uint64_t)pkt[1]->data_len << I40E_TXD_QW1_TX_BUF_SZ_SHIFT);
+				((uint64_t)pkt[1]->data_len << CI_TXD_QW1_TX_BUF_SZ_S);
 		uint64_t hi_qw0 = hi_qw_tmpl |
-				((uint64_t)pkt[0]->data_len << I40E_TXD_QW1_TX_BUF_SZ_SHIFT);
+				((uint64_t)pkt[0]->data_len << CI_TXD_QW1_TX_BUF_SZ_S);
 
 		__m256i desc2_3 = _mm256_set_epi64x(
 				hi_qw3, pkt[3]->buf_iova + pkt[3]->data_off,
@@ -743,7 +742,7 @@ i40e_xmit_fixed_burst_vec_avx2(void *tx_queue, struct rte_mbuf **tx_pkts,
 	struct ci_tx_entry_vec *txep;
 	uint16_t n, nb_commit, tx_id;
 	uint64_t flags = I40E_TD_CMD;
-	uint64_t rs = I40E_TX_DESC_CMD_RS | I40E_TD_CMD;
+	uint64_t rs = CI_TX_DESC_CMD_RS | I40E_TD_CMD;
 
 	if (txq->nb_tx_free < txq->tx_free_thresh)
 		ci_tx_free_bufs_vec(txq, i40e_tx_desc_done, false);
@@ -785,8 +784,7 @@ i40e_xmit_fixed_burst_vec_avx2(void *tx_queue, struct rte_mbuf **tx_pkts,
 	tx_id = (uint16_t)(tx_id + nb_commit);
 	if (tx_id > txq->tx_next_rs) {
 		txq->ci_tx_ring[txq->tx_next_rs].cmd_type_offset_bsz |=
-			rte_cpu_to_le_64(((uint64_t)I40E_TX_DESC_CMD_RS) <<
-						I40E_TXD_QW1_CMD_SHIFT);
+			rte_cpu_to_le_64(((uint64_t)CI_TX_DESC_CMD_RS) << CI_TXD_QW1_CMD_S);
 		txq->tx_next_rs =
 			(uint16_t)(txq->tx_next_rs + txq->tx_rs_thresh);
 	}
drivers/net/intel/i40e/i40e_rxtx_vec_avx512.c +14 -24
index 9a967faeee..d48ff9f51e 100644
@@ -752,9 +752,9 @@ i40e_recv_scattered_pkts_vec_avx512(void *rx_queue,
 static inline void
 vtx1(volatile struct ci_tx_desc *txdp, struct rte_mbuf *pkt, uint64_t flags)
 {
-	uint64_t high_qw = (I40E_TX_DESC_DTYPE_DATA |
-		((uint64_t)flags  << I40E_TXD_QW1_CMD_SHIFT) |
-		((uint64_t)pkt->data_len << I40E_TXD_QW1_TX_BUF_SZ_SHIFT));
+	uint64_t high_qw = (CI_TX_DESC_DTYPE_DATA |
+		((uint64_t)flags << CI_TXD_QW1_CMD_S) |
+		((uint64_t)pkt->data_len << CI_TXD_QW1_TX_BUF_SZ_S));
 
 	__m128i descriptor = _mm_set_epi64x(high_qw,
 				pkt->buf_iova + pkt->data_off);
@@ -765,26 +765,17 @@ static inline void
 vtx(volatile struct ci_tx_desc *txdp,
 	struct rte_mbuf **pkt, uint16_t nb_pkts,  uint64_t flags)
 {
-	const uint64_t hi_qw_tmpl = (I40E_TX_DESC_DTYPE_DATA |
-			((uint64_t)flags  << I40E_TXD_QW1_CMD_SHIFT));
+	const uint64_t hi_qw_tmpl = (CI_TX_DESC_DTYPE_DATA | (flags << CI_TXD_QW1_CMD_S));
 
 	for (; nb_pkts > 3; txdp += 4, pkt += 4, nb_pkts -= 4) {
-		uint64_t hi_qw3 =
-			hi_qw_tmpl |
-			((uint64_t)pkt[3]->data_len <<
-			 I40E_TXD_QW1_TX_BUF_SZ_SHIFT);
-		uint64_t hi_qw2 =
-			hi_qw_tmpl |
-			((uint64_t)pkt[2]->data_len <<
-			 I40E_TXD_QW1_TX_BUF_SZ_SHIFT);
-		uint64_t hi_qw1 =
-			hi_qw_tmpl |
-			((uint64_t)pkt[1]->data_len <<
-			 I40E_TXD_QW1_TX_BUF_SZ_SHIFT);
-		uint64_t hi_qw0 =
-			hi_qw_tmpl |
-			((uint64_t)pkt[0]->data_len <<
-			 I40E_TXD_QW1_TX_BUF_SZ_SHIFT);
+		uint64_t hi_qw3 = hi_qw_tmpl |
+			((uint64_t)pkt[3]->data_len << CI_TXD_QW1_TX_BUF_SZ_S);
+		uint64_t hi_qw2 = hi_qw_tmpl |
+			((uint64_t)pkt[2]->data_len << CI_TXD_QW1_TX_BUF_SZ_S);
+		uint64_t hi_qw1 = hi_qw_tmpl |
+			((uint64_t)pkt[1]->data_len << CI_TXD_QW1_TX_BUF_SZ_S);
+		uint64_t hi_qw0 = hi_qw_tmpl |
+			((uint64_t)pkt[0]->data_len << CI_TXD_QW1_TX_BUF_SZ_S);
 
 		__m512i desc0_3 =
 			_mm512_set_epi64
@@ -811,7 +802,7 @@ i40e_xmit_fixed_burst_vec_avx512(void *tx_queue, struct rte_mbuf **tx_pkts,
 	struct ci_tx_entry_vec *txep;
 	uint16_t n, nb_commit, tx_id;
 	uint64_t flags = I40E_TD_CMD;
-	uint64_t rs = I40E_TX_DESC_CMD_RS | I40E_TD_CMD;
+	uint64_t rs = CI_TX_DESC_CMD_RS | I40E_TD_CMD;
 
 	if (txq->nb_tx_free < txq->tx_free_thresh)
 		ci_tx_free_bufs_vec(txq, i40e_tx_desc_done, false);
@@ -854,8 +845,7 @@ i40e_xmit_fixed_burst_vec_avx512(void *tx_queue, struct rte_mbuf **tx_pkts,
 	tx_id = (uint16_t)(tx_id + nb_commit);
 	if (tx_id > txq->tx_next_rs) {
 		txq->ci_tx_ring[txq->tx_next_rs].cmd_type_offset_bsz |=
-			rte_cpu_to_le_64(((uint64_t)I40E_TX_DESC_CMD_RS) <<
-						I40E_TXD_QW1_CMD_SHIFT);
+			rte_cpu_to_le_64(((uint64_t)CI_TX_DESC_CMD_RS) << CI_TXD_QW1_CMD_S);
 		txq->tx_next_rs =
 			(uint16_t)(txq->tx_next_rs + txq->tx_rs_thresh);
 	}
drivers/net/intel/i40e/i40e_rxtx_vec_common.h +2 -2
index 1fd7fc75bf..292a39501e 100644
@@ -16,8 +16,8 @@ static inline int
 i40e_tx_desc_done(struct ci_tx_queue *txq, uint16_t idx)
 {
 	return (txq->ci_tx_ring[idx].cmd_type_offset_bsz &
-			rte_cpu_to_le_64(I40E_TXD_QW1_DTYPE_MASK)) ==
-				rte_cpu_to_le_64(I40E_TX_DESC_DTYPE_DESC_DONE);
+			rte_cpu_to_le_64(CI_TXD_QW1_DTYPE_M)) ==
+				rte_cpu_to_le_64(CI_TX_DESC_DTYPE_DESC_DONE);
 }
 
 static inline void
drivers/net/intel/i40e/i40e_rxtx_vec_neon.c +5 -6
index 0b95152232..be4c64942e 100644
@@ -600,9 +600,9 @@ static inline void
 vtx1(volatile struct ci_tx_desc *txdp,
 		struct rte_mbuf *pkt, uint64_t flags)
 {
-	uint64_t high_qw = (I40E_TX_DESC_DTYPE_DATA |
-			((uint64_t)flags  << I40E_TXD_QW1_CMD_SHIFT) |
-			((uint64_t)pkt->data_len << I40E_TXD_QW1_TX_BUF_SZ_SHIFT));
+	uint64_t high_qw = (CI_TX_DESC_DTYPE_DATA |
+			((uint64_t)flags << CI_TXD_QW1_CMD_S) |
+			((uint64_t)pkt->data_len << CI_TXD_QW1_TX_BUF_SZ_S));
 
 	uint64x2_t descriptor = {pkt->buf_iova + pkt->data_off, high_qw};
 	vst1q_u64(RTE_CAST_PTR(uint64_t *, txdp), descriptor);
@@ -627,7 +627,7 @@ i40e_xmit_fixed_burst_vec(void *__rte_restrict tx_queue,
 	struct ci_tx_entry_vec *txep;
 	uint16_t n, nb_commit, tx_id;
 	uint64_t flags = I40E_TD_CMD;
-	uint64_t rs = I40E_TX_DESC_CMD_RS | I40E_TD_CMD;
+	uint64_t rs = CI_TX_DESC_CMD_RS | I40E_TD_CMD;
 	int i;
 
 	if (txq->nb_tx_free < txq->tx_free_thresh)
@@ -669,8 +669,7 @@ i40e_xmit_fixed_burst_vec(void *__rte_restrict tx_queue,
 	tx_id = (uint16_t)(tx_id + nb_commit);
 	if (tx_id > txq->tx_next_rs) {
 		txq->ci_tx_ring[txq->tx_next_rs].cmd_type_offset_bsz |=
-			rte_cpu_to_le_64(((uint64_t)I40E_TX_DESC_CMD_RS) <<
-						I40E_TXD_QW1_CMD_SHIFT);
+			rte_cpu_to_le_64(((uint64_t)CI_TX_DESC_CMD_RS) << CI_TXD_QW1_CMD_S);
 		txq->tx_next_rs =
 			(uint16_t)(txq->tx_next_rs + txq->tx_rs_thresh);
 	}
drivers/net/intel/iavf/iavf_rxtx.c +33 -35

168 lines not on this page · raw message

drivers/net/intel/iavf/iavf_rxtx.h +2 -18
index dd6d884fc1..395d97b4ee 100644
@@ -162,10 +162,6 @@
 #define IAVF_TX_OFFLOAD_NOTSUP_MASK \
 		(RTE_MBUF_F_TX_OFFLOAD_MASK ^ IAVF_TX_OFFLOAD_MASK)
 
-/* HW requires that TX buffer size ranges from 1B up to (16K-1)B. */
-#define IAVF_MAX_DATA_PER_TXD \
-	(IAVF_TXD_QW1_TX_BUF_SZ_MASK >> IAVF_TXD_QW1_TX_BUF_SZ_SHIFT)
-
 #define IAVF_TX_LLDP_DYNFIELD "intel_pmd_dynfield_tx_lldp"
 #define IAVF_CHECK_TX_LLDP(m) \
 	((rte_pmd_iavf_tx_lldp_dynfield_offset > 0) && \
@@ -195,18 +191,6 @@ struct iavf_rx_queue_stats {
 	struct iavf_ipsec_crypto_stats ipsec_crypto;
 };
 
-/* Offload features */
-union iavf_tx_offload {
-	uint64_t data;
-	struct {
-		uint64_t l2_len:7; /* L2 (MAC) Header Length. */
-		uint64_t l3_len:9; /* L3 (IP) Header Length. */
-		uint64_t l4_len:8; /* L4 Header Length. */
-		uint64_t tso_segsz:16; /* TCP TSO segment size */
-		/* uint64_t unused : 24; */
-	};
-};
-
 /* Rx Flex Descriptor
  * RxDID Profile ID 16-21
  * Flex-field 0: RSS hash lower 16-bits
@@ -409,7 +393,7 @@ enum iavf_rx_flex_desc_ipsec_crypto_status {
 
 
 #define IAVF_TXD_DATA_QW1_DTYPE_SHIFT	(0)
-#define IAVF_TXD_DATA_QW1_DTYPE_MASK	(0xFUL << IAVF_TXD_QW1_DTYPE_SHIFT)
+#define IAVF_TXD_DATA_QW1_DTYPE_MASK	(0xFUL << CI_TXD_QW1_DTYPE_S)
 
 #define IAVF_TXD_DATA_QW1_CMD_SHIFT	(4)
 #define IAVF_TXD_DATA_QW1_CMD_MASK	(0x3FFUL << IAVF_TXD_DATA_QW1_CMD_SHIFT)
@@ -686,7 +670,7 @@ void iavf_dump_tx_descriptor(const struct ci_tx_queue *txq,
 		rte_le_to_cpu_64(tx_desc->cmd_type_offset_bsz &
 			rte_cpu_to_le_64(IAVF_TXD_DATA_QW1_DTYPE_MASK));
 	switch (type) {
-	case IAVF_TX_DESC_DTYPE_DATA:
+	case CI_TX_DESC_DTYPE_DATA:
 		name = "Tx_data_desc";
 		break;
 	case IAVF_TX_DESC_DTYPE_CONTEXT:
drivers/net/intel/iavf/iavf_rxtx_vec_avx2.c +15 -26

77 lines not on this page · raw message

drivers/net/intel/iavf/iavf_rxtx_vec_avx512.c +30 -50

171 lines not on this page · raw message

drivers/net/intel/iavf/iavf_rxtx_vec_common.h +16 -18
index 1832b76f89..1538a44892 100644
@@ -15,8 +15,8 @@ static inline int
 iavf_tx_desc_done(struct ci_tx_queue *txq, uint16_t idx)
 {
 	return (txq->ci_tx_ring[idx].cmd_type_offset_bsz &
-			rte_cpu_to_le_64(IAVF_TXD_QW1_DTYPE_MASK)) ==
-				rte_cpu_to_le_64(IAVF_TX_DESC_DTYPE_DESC_DONE);
+			rte_cpu_to_le_64(CI_TXD_QW1_DTYPE_M)) ==
+				rte_cpu_to_le_64(CI_TX_DESC_DTYPE_DESC_DONE);
 }
 
 static inline void
@@ -147,26 +147,26 @@ iavf_txd_enable_offload(__rte_unused struct rte_mbuf *tx_pkt,
 	/* Set MACLEN */
 	if (ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK)
 		td_offset |= (tx_pkt->outer_l2_len >> 1)
-			<< IAVF_TX_DESC_LENGTH_MACLEN_SHIFT;
+			<< CI_TX_DESC_LEN_MACLEN_S;
 	else
 		td_offset |= (tx_pkt->l2_len >> 1)
-			<< IAVF_TX_DESC_LENGTH_MACLEN_SHIFT;
+			<< CI_TX_DESC_LEN_MACLEN_S;
 
 	/* Enable L3 checksum offloads */
 	if (ol_flags & RTE_MBUF_F_TX_IP_CKSUM) {
 		if (ol_flags & RTE_MBUF_F_TX_IPV4) {
-			td_cmd |= IAVF_TX_DESC_CMD_IIPT_IPV4_CSUM;
+			td_cmd |= CI_TX_DESC_CMD_IIPT_IPV4_CSUM;
 			td_offset |= (tx_pkt->l3_len >> 2) <<
-				     IAVF_TX_DESC_LENGTH_IPLEN_SHIFT;
+				     CI_TX_DESC_LEN_IPLEN_S;
 		}
 	} else if (ol_flags & RTE_MBUF_F_TX_IPV4) {
-		td_cmd |= IAVF_TX_DESC_CMD_IIPT_IPV4;
+		td_cmd |= CI_TX_DESC_CMD_IIPT_IPV4;
 		td_offset |= (tx_pkt->l3_len >> 2) <<
-			     IAVF_TX_DESC_LENGTH_IPLEN_SHIFT;
+			     CI_TX_DESC_LEN_IPLEN_S;
 	} else if (ol_flags & RTE_MBUF_F_TX_IPV6) {
-		td_cmd |= IAVF_TX_DESC_CMD_IIPT_IPV6;
+		td_cmd |= CI_TX_DESC_CMD_IIPT_IPV6;
 		td_offset |= (tx_pkt->l3_len >> 2) <<
-			     IAVF_TX_DESC_LENGTH_IPLEN_SHIFT;
+			     CI_TX_DESC_LEN_IPLEN_S;
 	}
 
 	/* Enable L4 checksum offloads */
@@ -190,7 +190,7 @@ iavf_txd_enable_offload(__rte_unused struct rte_mbuf *tx_pkt,
 		break;
 	}
 
-	*txd_hi |= ((uint64_t)td_offset) << IAVF_TXD_QW1_OFFSET_SHIFT;
+	*txd_hi |= ((uint64_t)td_offset) << CI_TXD_QW1_OFFSET_S;
 #endif
 
 #ifdef IAVF_TX_VLAN_QINQ_OFFLOAD
@@ -198,17 +198,15 @@ iavf_txd_enable_offload(__rte_unused struct rte_mbuf *tx_pkt,
 		td_cmd |= IAVF_TX_DESC_CMD_IL2TAG1;
 		/* vlan_flag specifies outer tag location for QinQ. */
 		if (vlan_flag & IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG1)
-			*txd_hi |= ((uint64_t)tx_pkt->vlan_tci_outer <<
-					IAVF_TXD_QW1_L2TAG1_SHIFT);
+			*txd_hi |= ((uint64_t)tx_pkt->vlan_tci_outer << CI_TXD_QW1_L2TAG1_S);
 		else
-			*txd_hi |= ((uint64_t)tx_pkt->vlan_tci <<
-					IAVF_TXD_QW1_L2TAG1_SHIFT);
+			*txd_hi |= ((uint64_t)tx_pkt->vlan_tci << CI_TXD_QW1_L2TAG1_S);
 	} else if (ol_flags & RTE_MBUF_F_TX_VLAN && vlan_flag & IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG1) {
-		td_cmd |= IAVF_TX_DESC_CMD_IL2TAG1;
-		*txd_hi |= ((uint64_t)tx_pkt->vlan_tci << IAVF_TXD_QW1_L2TAG1_SHIFT);
+		td_cmd |= CI_TX_DESC_CMD_IL2TAG1;
+		*txd_hi |= ((uint64_t)tx_pkt->vlan_tci << CI_TXD_QW1_L2TAG1_S);
 	}
 #endif
 
-	*txd_hi |= ((uint64_t)td_cmd) << IAVF_TXD_QW1_CMD_SHIFT;
+	*txd_hi |= ((uint64_t)td_cmd) << CI_TXD_QW1_CMD_S;
 }
 #endif
drivers/net/intel/ice/ice_dcf_ethdev.c +1 -1
index 5f537b4c12..4ceecc15c6 100644
@@ -406,7 +406,7 @@ reset_tx_queue(struct ci_tx_queue *txq)
 	prev = (uint16_t)(txq->nb_tx_desc - 1);
 	for (i = 0; i < txq->nb_tx_desc; i++) {
 		txq->ci_tx_ring[i].cmd_type_offset_bsz =
-			rte_cpu_to_le_64(IAVF_TX_DESC_DTYPE_DESC_DONE);
+			rte_cpu_to_le_64(CI_TX_DESC_DTYPE_DESC_DONE);
 		txe[i].mbuf =  NULL;
 		txe[i].last_id = i;
 		txe[prev].next_id = i;
drivers/net/intel/ice/ice_rxtx.c +63 -74

317 lines not on this page · raw message

drivers/net/intel/ice/ice_rxtx.h +1 -14
index c524e9f756..cd5fa93d1c 100644
@@ -46,7 +46,7 @@
 
 #define ICE_SUPPORT_CHAIN_NUM 5
 
-#define ICE_TD_CMD                      ICE_TX_DESC_CMD_EOP
+#define ICE_TD_CMD                      CI_TX_DESC_CMD_EOP
 
 #define ICE_VPMD_RX_BURST            CI_VPMD_RX_BURST
 #define ICE_VPMD_TX_BURST            32
@@ -169,19 +169,6 @@ struct ice_txtime {
 	const struct rte_memzone *ts_mz;
 };
 
-/* Offload features */
-union ice_tx_offload {
-	uint64_t data;
-	struct {
-		uint64_t l2_len:7; /* L2 (MAC) Header Length. */
-		uint64_t l3_len:9; /* L3 (IP) Header Length. */
-		uint64_t l4_len:8; /* L4 Header Length. */
-		uint64_t tso_segsz:16; /* TCP TSO segment size */
-		uint64_t outer_l2_len:8; /* outer L2 Header Length */
-		uint64_t outer_l3_len:16; /* outer L3 Header Length */
-	};
-};
-
 /* Rx Flex Descriptor for Comms Package Profile
  * RxDID Profile ID 22 (swap Hash and FlowID)
  * Flex-field 0: Flow ID lower 16-bits
drivers/net/intel/ice/ice_rxtx_vec_avx2.c +15 -26

78 lines not on this page · raw message

drivers/net/intel/ice/ice_rxtx_vec_avx512.c +14 -25
index d42f41461f..e64b6e227b 100644
@@ -850,10 +850,9 @@ static __rte_always_inline void
 ice_vtx1(volatile struct ci_tx_desc *txdp,
 	 struct rte_mbuf *pkt, uint64_t flags, bool do_offload)
 {
-	uint64_t high_qw =
-		(ICE_TX_DESC_DTYPE_DATA |
-		 ((uint64_t)flags  << ICE_TXD_QW1_CMD_S) |
-		 ((uint64_t)pkt->data_len << ICE_TXD_QW1_TX_BUF_SZ_S));
+	uint64_t high_qw = (CI_TX_DESC_DTYPE_DATA |
+		 ((uint64_t)flags << CI_TXD_QW1_CMD_S) |
+		 ((uint64_t)pkt->data_len << CI_TXD_QW1_TX_BUF_SZ_S));
 
 	if (do_offload)
 		ice_txd_enable_offload(pkt, &high_qw);
@@ -866,32 +865,23 @@ static __rte_always_inline void
 ice_vtx(volatile struct ci_tx_desc *txdp, struct rte_mbuf **pkt,
 	uint16_t nb_pkts,  uint64_t flags, bool do_offload)
 {
-	const uint64_t hi_qw_tmpl = (ICE_TX_DESC_DTYPE_DATA |
-			((uint64_t)flags  << ICE_TXD_QW1_CMD_S));
+	const uint64_t hi_qw_tmpl = (CI_TX_DESC_DTYPE_DATA | (flags << CI_TXD_QW1_CMD_S));
 
 	for (; nb_pkts > 3; txdp += 4, pkt += 4, nb_pkts -= 4) {
-		uint64_t hi_qw3 =
-			hi_qw_tmpl |
-			((uint64_t)pkt[3]->data_len <<
-			 ICE_TXD_QW1_TX_BUF_SZ_S);
+		uint64_t hi_qw3 = hi_qw_tmpl |
+			((uint64_t)pkt[3]->data_len << CI_TXD_QW1_TX_BUF_SZ_S);
 		if (do_offload)
 			ice_txd_enable_offload(pkt[3], &hi_qw3);
-		uint64_t hi_qw2 =
-			hi_qw_tmpl |
-			((uint64_t)pkt[2]->data_len <<
-			 ICE_TXD_QW1_TX_BUF_SZ_S);
+		uint64_t hi_qw2 = hi_qw_tmpl |
+			((uint64_t)pkt[2]->data_len << CI_TXD_QW1_TX_BUF_SZ_S);
 		if (do_offload)
 			ice_txd_enable_offload(pkt[2], &hi_qw2);
-		uint64_t hi_qw1 =
-			hi_qw_tmpl |
-			((uint64_t)pkt[1]->data_len <<
-			 ICE_TXD_QW1_TX_BUF_SZ_S);
+		uint64_t hi_qw1 = hi_qw_tmpl |
+			((uint64_t)pkt[1]->data_len << CI_TXD_QW1_TX_BUF_SZ_S);
 		if (do_offload)
 			ice_txd_enable_offload(pkt[1], &hi_qw1);
-		uint64_t hi_qw0 =
-			hi_qw_tmpl |
-			((uint64_t)pkt[0]->data_len <<
-			 ICE_TXD_QW1_TX_BUF_SZ_S);
+		uint64_t hi_qw0 = hi_qw_tmpl |
+			((uint64_t)pkt[0]->data_len << CI_TXD_QW1_TX_BUF_SZ_S);
 		if (do_offload)
 			ice_txd_enable_offload(pkt[0], &hi_qw0);
 
@@ -920,7 +910,7 @@ ice_xmit_fixed_burst_vec_avx512(void *tx_queue, struct rte_mbuf **tx_pkts,
 	struct ci_tx_entry_vec *txep;
 	uint16_t n, nb_commit, tx_id;
 	uint64_t flags = ICE_TD_CMD;
-	uint64_t rs = ICE_TX_DESC_CMD_RS | ICE_TD_CMD;
+	uint64_t rs = CI_TX_DESC_CMD_RS | ICE_TD_CMD;
 
 	/* cross rx_thresh boundary is not allowed */
 	nb_pkts = RTE_MIN(nb_pkts, txq->tx_rs_thresh);
@@ -966,8 +956,7 @@ ice_xmit_fixed_burst_vec_avx512(void *tx_queue, struct rte_mbuf **tx_pkts,
 	tx_id = (uint16_t)(tx_id + nb_commit);
 	if (tx_id > txq->tx_next_rs) {
 		txq->ci_tx_ring[txq->tx_next_rs].cmd_type_offset_bsz |=
-			rte_cpu_to_le_64(((uint64_t)ICE_TX_DESC_CMD_RS) <<
-					 ICE_TXD_QW1_CMD_S);
+			rte_cpu_to_le_64(((uint64_t)CI_TX_DESC_CMD_RS) << CI_TXD_QW1_CMD_S);
 		txq->tx_next_rs =
 			(uint16_t)(txq->tx_next_rs + txq->tx_rs_thresh);
 	}
drivers/net/intel/ice/ice_rxtx_vec_common.h +20 -21

81 lines not on this page · raw message

drivers/net/intel/idpf/idpf_common_rxtx.c +11 -11
index 23666539ab..587871b54a 100644
@@ -271,7 +271,7 @@ idpf_qc_single_tx_queue_reset(struct ci_tx_queue *txq)
 	prev = (uint16_t)(txq->nb_tx_desc - 1);
 	for (i = 0; i < txq->nb_tx_desc; i++) {
 		txq->ci_tx_ring[i].cmd_type_offset_bsz =
-			rte_cpu_to_le_64(IDPF_TX_DESC_DTYPE_DESC_DONE);
+			rte_cpu_to_le_64(CI_TX_DESC_DTYPE_DESC_DONE);
 		txe[i].mbuf =  NULL;
 		txe[i].last_id = i;
 		txe[prev].next_id = i;
@@ -849,7 +849,7 @@ idpf_calc_context_desc(uint64_t flags)
  */
 static inline void
 idpf_set_splitq_tso_ctx(struct rte_mbuf *mbuf,
-			union idpf_tx_offload tx_offload,
+			union ci_tx_offload tx_offload,
 			volatile union idpf_flex_tx_ctx_desc *ctx_desc)
 {
 	uint16_t cmd_dtype;
@@ -887,7 +887,7 @@ idpf_dp_splitq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 	volatile struct idpf_flex_tx_sched_desc *txr;
 	volatile struct idpf_flex_tx_sched_desc *txd;
 	struct ci_tx_entry *sw_ring;
-	union idpf_tx_offload tx_offload = {0};
+	union ci_tx_offload tx_offload = {0};
 	struct ci_tx_entry *txe, *txn;
 	uint16_t nb_used, tx_id, sw_id;
 	struct rte_mbuf *tx_pkt;
@@ -1334,7 +1334,7 @@ idpf_dp_singleq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 {
 	volatile struct ci_tx_desc *txd;
 	volatile struct ci_tx_desc *txr;
-	union idpf_tx_offload tx_offload = {0};
+	union ci_tx_offload tx_offload = {0};
 	struct ci_tx_entry *txe, *txn;
 	struct ci_tx_entry *sw_ring;
 	struct ci_tx_queue *txq;
@@ -1452,10 +1452,10 @@ idpf_dp_singleq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 			slen = m_seg->data_len;
 			buf_dma_addr = rte_mbuf_data_iova(m_seg);
 			txd->buffer_addr = rte_cpu_to_le_64(buf_dma_addr);
-			txd->cmd_type_offset_bsz = rte_cpu_to_le_64(IDPF_TX_DESC_DTYPE_DATA |
-				((uint64_t)td_cmd  << IDPF_TXD_QW1_CMD_S) |
-				((uint64_t)td_offset << IDPF_TXD_QW1_OFFSET_S) |
-				((uint64_t)slen << IDPF_TXD_QW1_TX_BUF_SZ_S));
+			txd->cmd_type_offset_bsz = rte_cpu_to_le_64(CI_TX_DESC_DTYPE_DATA |
+				((uint64_t)td_cmd  << CI_TXD_QW1_CMD_S) |
+				((uint64_t)td_offset << CI_TXD_QW1_OFFSET_S) |
+				((uint64_t)slen << CI_TXD_QW1_TX_BUF_SZ_S));
 
 			txe->last_id = tx_last;
 			tx_id = txe->next_id;
@@ -1464,7 +1464,7 @@ idpf_dp_singleq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 		} while (m_seg);
 
 		/* The last packet data descriptor needs End Of Packet (EOP) */
-		td_cmd |= IDPF_TX_DESC_CMD_EOP;
+		td_cmd |= CI_TX_DESC_CMD_EOP;
 		txq->nb_tx_used = (uint16_t)(txq->nb_tx_used + nb_used);
 		txq->nb_tx_free = (uint16_t)(txq->nb_tx_free - nb_used);
 
@@ -1473,13 +1473,13 @@ idpf_dp_singleq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 			       "%4u (port=%d queue=%d)",
 			       tx_last, txq->port_id, txq->queue_id);
 
-			td_cmd |= IDPF_TX_DESC_CMD_RS;
+			td_cmd |= CI_TX_DESC_CMD_RS;
 
 			/* Update txq RS bit counters */
 			txq->nb_tx_used = 0;
 		}
 
-		txd->cmd_type_offset_bsz |= rte_cpu_to_le_16(td_cmd << IDPF_TXD_QW1_CMD_S);
+		txd->cmd_type_offset_bsz |= rte_cpu_to_le_16(td_cmd << CI_TXD_QW1_CMD_S);
 	}
 
 end_of_tx:
drivers/net/intel/idpf/idpf_common_rxtx.h +0 -12
index 2f2fa153b2..b88a87402d 100644
@@ -169,18 +169,6 @@ struct idpf_rx_queue {
 	uint32_t hw_register_set;
 };
 
-/* Offload features */
-union idpf_tx_offload {
-	uint64_t data;
-	struct {
-		uint64_t l2_len:7; /* L2 (MAC) Header Length. */
-		uint64_t l3_len:9; /* L3 (IP) Header Length. */
-		uint64_t l4_len:8; /* L4 Header Length. */
-		uint64_t tso_segsz:16; /* TCP TSO segment size */
-		/* uint64_t unused : 24; */
-	};
-};
-
 union idpf_tx_desc {
 	struct ci_tx_desc *tx_ring;
 	struct idpf_flex_tx_sched_desc *desc_ring;
drivers/net/intel/idpf/idpf_common_rxtx_avx2.c +15 -26

71 lines not on this page · raw message

drivers/net/intel/idpf/idpf_common_rxtx_avx512.c +15 -26

71 lines not on this page · raw message

drivers/net/intel/idpf/idpf_rxtx_vec_common.h +2 -2
index b5e8574667..a43d8f78e2 100644
@@ -32,8 +32,8 @@ idpf_tx_desc_done(struct ci_tx_queue *txq, uint16_t idx)
 		return 1;
 
 	return (txq->ci_tx_ring[idx].cmd_type_offset_bsz &
-			rte_cpu_to_le_64(IDPF_TXD_QW1_DTYPE_M)) ==
-				rte_cpu_to_le_64(IDPF_TX_DESC_DTYPE_DESC_DONE);
+			rte_cpu_to_le_64(CI_TXD_QW1_DTYPE_M)) ==
+				rte_cpu_to_le_64(CI_TX_DESC_DTYPE_DESC_DONE);
 }
 
 static inline int
Signature · 1 line
2.51.0
Acked-by on v4 4/35
#136 lore raw

Re: [PATCH v4 04/35] net/intel: consolidate definitions for Tx desc fields

Quoted 8 lines · Bruce Richardson

The offsets of the various fields within the Tx descriptors are common for i40e, iavf, ice and idpf, so put a single set of defines in tx.h and use those throughout all drivers. (NOTE: there was a small difference in mask of CMD field between drivers depending on whether reserved fields or not were included. Those can be ignored as those bits are unused in the drivers for which they are reserved). Similarly, the various flag fields, such as End-of-packet (EOP) and Report-status (RS) are the same, as are offload definitions so consolidate them.

Nitpick: the NOTE should IMO be separated, as otherwise the flow of the commit message is a bit confusing, as the latter part kinda parses as being part of the NOTE section that accidentally got left out of the parens, instead of being a continuation of the pre-NOTE section.

Otherwise, LGTM

Signature · 2 lines
Thanks,
Anatoly
#137 lore raw

Re: [PATCH v4 04/35] net/intel: consolidate definitions for Tx desc fields

Quoted 10 lines · Anatoly
Quoted 8 lines · Bruce Richardson

The offsets of the various fields within the Tx descriptors are common for i40e, iavf, ice and idpf, so put a single set of defines in tx.h and use those throughout all drivers. (NOTE: there was a small difference in mask of CMD field between drivers depending on whether reserved fields or not were included. Those can be ignored as those bits are unused in the drivers for which they are reserved). Similarly, the various flag fields, such as End-of-packet (EOP) and Report-status (RS) are the same, as are offload definitions so consolidate them.

Quoted 5 lines

Nitpick: the NOTE should IMO be separated, as otherwise the flow of the commit message is a bit confusing, as the latter part kinda parses as being part of the NOTE section that accidentally got left out of the parens, instead of being a continuation of the pre-NOTE section.

Splitting into separate paragraphs for v5.

#138 lore raw

PATCH v4 5/35 net/intel: add common fn to calculate needed descriptors

In reply to Bruce Richardson

Multiple drivers used the same logic to calculate how many Tx data descriptors were needed. Move that calculation to common code. In the process of updating drivers, fix idpf driver calculation for the TSO case.

---
 drivers/net/intel/common/tx_scalar.h      | 21 +++++++++++++++++++++
 drivers/net/intel/i40e/i40e_rxtx.c        | 18 +-----------------
 drivers/net/intel/iavf/iavf_rxtx.c        | 17 +----------------
 drivers/net/intel/ice/ice_rxtx.c          | 18 +-----------------
 drivers/net/intel/idpf/idpf_common_rxtx.c | 21 +++++++++++++++++----
 5 files changed, 41 insertions(+), 54 deletions(-)
drivers/net/intel/common/tx_scalar.h +21 -0
index 6f2024273b..573f5136a9 100644
@@ -59,4 +59,25 @@ ci_tx_xmit_cleanup(struct ci_tx_queue *txq)
 	return 0;
 }
 
+static inline uint16_t
+ci_div_roundup16(uint16_t x, uint16_t y)
+{
+	return (uint16_t)((x + y - 1) / y);
+}
+
+/* Calculate the number of TX descriptors needed for each pkt */
+static inline uint16_t
+ci_calc_pkt_desc(const struct rte_mbuf *tx_pkt)
+{
+	uint16_t count = 0;
+
+	while (tx_pkt != NULL) {
+		count += ci_div_roundup16(tx_pkt->data_len, CI_MAX_DATA_PER_TXD);
+		tx_pkt = tx_pkt->next;
+	}
+
+	return count;
+}
+
+
 #endif /* _COMMON_INTEL_TX_SCALAR_H_ */
drivers/net/intel/i40e/i40e_rxtx.c +1 -17
index f96c5c7f1e..b75306931a 100644
@@ -1029,21 +1029,6 @@ i40e_set_tso_ctx(struct rte_mbuf *mbuf, union ci_tx_offload tx_offload)
 	return ctx_desc;
 }
 
-/* Calculate the number of TX descriptors needed for each pkt */
-static inline uint16_t
-i40e_calc_pkt_desc(struct rte_mbuf *tx_pkt)
-{
-	struct rte_mbuf *txd = tx_pkt;
-	uint16_t count = 0;
-
-	while (txd != NULL) {
-		count += DIV_ROUND_UP(txd->data_len, CI_MAX_DATA_PER_TXD);
-		txd = txd->next;
-	}
-
-	return count;
-}
-
 uint16_t
 i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 {
@@ -1106,8 +1091,7 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 		 * per tx desc.
 		 */
 		if (ol_flags & RTE_MBUF_F_TX_TCP_SEG)
-			nb_used = (uint16_t)(i40e_calc_pkt_desc(tx_pkt) +
-					     nb_ctx);
+			nb_used = (uint16_t)(ci_calc_pkt_desc(tx_pkt) + nb_ctx);
 		else
 			nb_used = (uint16_t)(tx_pkt->nb_segs + nb_ctx);
 		tx_last = (uint16_t)(tx_id + nb_used - 1);
drivers/net/intel/iavf/iavf_rxtx.c +1 -16
index 947b6c24d2..885d9309cc 100644
@@ -2666,21 +2666,6 @@ iavf_build_data_desc_cmd_offset_fields(volatile uint64_t *qw1,
 		((uint64_t)l2tag1 << IAVF_TXD_DATA_QW1_L2TAG1_SHIFT));
 }
 
-/* Calculate the number of TX descriptors needed for each pkt */
-static inline uint16_t
-iavf_calc_pkt_desc(struct rte_mbuf *tx_pkt)
-{
-	struct rte_mbuf *txd = tx_pkt;
-	uint16_t count = 0;
-
-	while (txd != NULL) {
-		count += (txd->data_len + CI_MAX_DATA_PER_TXD - 1) / CI_MAX_DATA_PER_TXD;
-		txd = txd->next;
-	}
-
-	return count;
-}
-
 static inline void
 iavf_fill_data_desc(volatile struct ci_tx_desc *desc,
 	uint64_t desc_template,	uint16_t buffsz,
@@ -2766,7 +2751,7 @@ iavf_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 		 * per tx desc.
 		 */
 		if (mb->ol_flags & RTE_MBUF_F_TX_TCP_SEG)
-			nb_desc_required = iavf_calc_pkt_desc(mb) + nb_desc_ctx + nb_desc_ipsec;
+			nb_desc_required = ci_calc_pkt_desc(mb) + nb_desc_ctx + nb_desc_ipsec;
 		else
 			nb_desc_required = nb_desc_data + nb_desc_ctx + nb_desc_ipsec;
 
drivers/net/intel/ice/ice_rxtx.c +1 -17
index 52bbf95967..2a53b614b2 100644
@@ -3075,21 +3075,6 @@ ice_set_tso_ctx(struct rte_mbuf *mbuf, union ci_tx_offload tx_offload)
 	return ctx_desc;
 }
 
-/* Calculate the number of TX descriptors needed for each pkt */
-static inline uint16_t
-ice_calc_pkt_desc(struct rte_mbuf *tx_pkt)
-{
-	struct rte_mbuf *txd = tx_pkt;
-	uint16_t count = 0;
-
-	while (txd != NULL) {
-		count += DIV_ROUND_UP(txd->data_len, CI_MAX_DATA_PER_TXD);
-		txd = txd->next;
-	}
-
-	return count;
-}
-
 uint16_t
 ice_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 {
@@ -3152,8 +3137,7 @@ ice_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 		 * per tx desc.
 		 */
 		if (ol_flags & (RTE_MBUF_F_TX_TCP_SEG | RTE_MBUF_F_TX_UDP_SEG))
-			nb_used = (uint16_t)(ice_calc_pkt_desc(tx_pkt) +
-					     nb_ctx);
+			nb_used = (uint16_t)(ci_calc_pkt_desc(tx_pkt) + nb_ctx);
 		else
 			nb_used = (uint16_t)(tx_pkt->nb_segs + nb_ctx);
 		tx_last = (uint16_t)(tx_id + nb_used - 1);
drivers/net/intel/idpf/idpf_common_rxtx.c +17 -4
index 587871b54a..11d6848430 100644
@@ -934,7 +934,16 @@ idpf_dp_splitq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 		tx_offload.tso_segsz = tx_pkt->tso_segsz;
 		/* Calculate the number of context descriptors needed. */
 		nb_ctx = idpf_calc_context_desc(ol_flags);
-		nb_used = tx_pkt->nb_segs + nb_ctx;
+
+		/* Calculate the number of TX descriptors needed for
+		 * each packet. For TSO packets, use ci_calc_pkt_desc as
+		 * the mbuf data size might exceed max data size that hw allows
+		 * per tx desc.
+		 */
+		if (ol_flags & RTE_MBUF_F_TX_TCP_SEG)
+			nb_used = ci_calc_pkt_desc(tx_pkt) + nb_ctx;
+		else
+			nb_used = tx_pkt->nb_segs + nb_ctx;
 
 		if (ol_flags & IDPF_TX_CKSUM_OFFLOAD_MASK)
 			cmd_dtype = IDPF_TXD_FLEX_FLOW_CMD_CS_EN;
@@ -1382,10 +1391,14 @@ idpf_dp_singleq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 		nb_ctx = idpf_calc_context_desc(ol_flags);
 
 		/* The number of descriptors that must be allocated for
-		 * a packet equals to the number of the segments of that
-		 * packet plus 1 context descriptor if needed.
+		 * a packet. For TSO packets, use ci_calc_pkt_desc as
+		 * the mbuf data size might exceed max data size that hw allows
+		 * per tx desc.
 		 */
-		nb_used = (uint16_t)(tx_pkt->nb_segs + nb_ctx);
+		if (ol_flags & RTE_MBUF_F_TX_TCP_SEG)
+			nb_used = (uint16_t)(ci_calc_pkt_desc(tx_pkt) + nb_ctx);
+		else
+			nb_used = (uint16_t)(tx_pkt->nb_segs + nb_ctx);
 		tx_last = (uint16_t)(tx_id + nb_used - 1);
 
 		/* Circular ring */
Signature · 1 line
2.51.0
Acked-by on v4 5/35
#139 lore raw

Re: [PATCH v4 05/35] net/intel: add common fn to calculate needed descriptors

Quoted 5 lines · Bruce Richardson

Multiple drivers used the same logic to calculate how many Tx data descriptors were needed. Move that calculation to common code. In the process of updating drivers, fix idpf driver calculation for the TSO case.

"Fix TSO for idpf" sounds like a bugfix? Can it be backported to stable?

Otherwise,

Signature · 2 lines
Thanks,
Anatoly
#140 lore raw

Re: [PATCH v4 05/35] net/intel: add common fn to calculate needed descriptors

Quoted 9 lines · Anatoly
Quoted 5 lines · Bruce Richardson

Multiple drivers used the same logic to calculate how many Tx data descriptors were needed. Move that calculation to common code. In the process of updating drivers, fix idpf driver calculation for the TSO case.

"Fix TSO for idpf" sounds like a bugfix? Can it be backported to stable?

Yes, it is a bug fix for a particular edge case. However, as done here, the fix is implied by the code changes in the consolidation, and depends upon them. Any fix for backport would need to be a different, standalone patch, based on this.

/Bruce

#141 lore raw

Re: [PATCH v4 05/35] net/intel: add common fn to calculate needed descriptors

Quoted 8 lines · Bruce Richardson
Quoted 7 lines · Anatoly
Quoted 5 lines · Bruce Richardson

Multiple drivers used the same logic to calculate how many Tx data descriptors were needed. Move that calculation to common code. In the process of updating drivers, fix idpf driver calculation for the TSO case.

Quoted 8 lines
Quoted 2 lines

"Fix TSO for idpf" sounds like a bugfix? Can it be backported to stable?

Yes, it is a bug fix for a particular edge case. However, as done here, the fix is implied by the code changes in the consolidation, and depends upon them. Any fix for backport would need to be a different, standalone patch, based on this.

/Bruce

So the original code didn't have TSO at all? I.e. this can't be fixed as a prerequisite patch to this patchset?

Signature · 2 lines
Thanks,
Anatoly
#142 lore raw

Re: [PATCH v4 05/35] net/intel: add common fn to calculate needed descriptors

Quoted 16 lines · Anatoly
Quoted 15 lines · Bruce Richardson
Quoted 9 lines · Anatoly
Quoted 5 lines · Bruce Richardson

Multiple drivers used the same logic to calculate how many Tx data descriptors were needed. Move that calculation to common code. In the process of updating drivers, fix idpf driver calculation for the TSO case.

"Fix TSO for idpf" sounds like a bugfix? Can it be backported to stable?

Yes, it is a bug fix for a particular edge case. However, as done here, the fix is implied by the code changes in the consolidation, and depends upon them. Any fix for backport would need to be a different, standalone patch, based on this.

Quoted 5 lines
Quoted 1 line

/Bruce

So the original code didn't have TSO at all? I.e. this can't be fixed as a prerequisite patch to this patchset?

Original code did have TSO, it just didn't support the case where a single mbuf segment had more data than the max allowed to be described by a single descriptor, i.e. where we had multiple descriptors for one mbuf segment, so that "nb_descs != mbuf->nb_segs + ctx_descs". The other drivers all solve this by having a separate function that iterated through the descriptors, and to fix this in older releases would be to add such a function to this driver. There is little point adding that function in this series just to delete it later here, so I think for 26.03 the fix here is best and for earlier releases the best fix is to just put the necessary code directly into idpf driver. I've noted this down to do a backported patch after this series goes in.

/Bruce

#143 lore raw

Re: [PATCH v4 05/35] net/intel: add common fn to calculate needed descriptors

Quoted 34 lines · Bruce Richardson
Quoted 16 lines · Anatoly
Quoted 15 lines · Bruce Richardson
Quoted 9 lines · Anatoly
Quoted 5 lines · Bruce Richardson

Multiple drivers used the same logic to calculate how many Tx data descriptors were needed. Move that calculation to common code. In the process of updating drivers, fix idpf driver calculation for the TSO case.

"Fix TSO for idpf" sounds like a bugfix? Can it be backported to stable?

Yes, it is a bug fix for a particular edge case. However, as done here, the fix is implied by the code changes in the consolidation, and depends upon them. Any fix for backport would need to be a different, standalone patch, based on this.

Quoted 5 lines
Quoted 1 line

/Bruce

So the original code didn't have TSO at all? I.e. this can't be fixed as a prerequisite patch to this patchset?

Original code did have TSO, it just didn't support the case where a single mbuf segment had more data than the max allowed to be described by a single descriptor, i.e. where we had multiple descriptors for one mbuf segment, so that "nb_descs != mbuf->nb_segs + ctx_descs". The other drivers all solve this by having a separate function that iterated through the descriptors, and to fix this in older releases would be to add such a function to this driver. There is little point adding that function in this series just to delete it later here, so I think for 26.03 the fix here is best and for earlier releases the best fix is to just put the necessary code directly into idpf driver. I've noted this down to do a backported patch after this series goes in.

Quoted 1 line

/Bruce

Got it, thanks!

Signature · 2 lines
Thanks,
Anatoly
#144 lore raw

PATCH v4 6/35 net/ice: refactor context descriptor handling

In reply to Bruce Richardson

Create a single function to manage all context descriptor handling, which returns either 0 or 1 depending on whether a descriptor is needed or not, as well as returning directly the descriptor contents if relevant.

---
 drivers/net/intel/ice/ice_rxtx.c | 104 +++++++++++++++++--------------
 1 file changed, 57 insertions(+), 47 deletions(-)
drivers/net/intel/ice/ice_rxtx.c +57 -47
index 2a53b614b2..1c789d45da 100644
@@ -2966,10 +2966,6 @@ ice_txd_enable_checksum(uint64_t ol_flags,
 			uint32_t *td_offset,
 			union ci_tx_offload tx_offload)
 {
-	/* Set MACLEN */
-	if (!(ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK))
-		*td_offset |= (tx_offload.l2_len >> 1)
-			<< CI_TX_DESC_LEN_MACLEN_S;
 
 	/* Enable L3 checksum offloads */
 	if (ol_flags & RTE_MBUF_F_TX_IP_CKSUM) {
@@ -3052,7 +3048,7 @@ ice_calc_context_desc(uint64_t flags)
 
 /* set ice TSO context descriptor */
 static inline uint64_t
-ice_set_tso_ctx(struct rte_mbuf *mbuf, union ci_tx_offload tx_offload)
+ice_set_tso_ctx(uint64_t ol_flags, const struct rte_mbuf *mbuf, union ci_tx_offload tx_offload)
 {
 	uint64_t ctx_desc = 0;
 	uint32_t cd_cmd, hdr_len, cd_tso_len;
@@ -3063,7 +3059,7 @@ ice_set_tso_ctx(struct rte_mbuf *mbuf, union ci_tx_offload tx_offload)
 	}
 
 	hdr_len = tx_offload.l2_len + tx_offload.l3_len + tx_offload.l4_len;
-	hdr_len += (mbuf->ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK) ?
+	hdr_len += (ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK) ?
 		   tx_offload.outer_l2_len + tx_offload.outer_l3_len : 0;
 
 	cd_cmd = CI_TX_CTX_DESC_TSO;
@@ -3075,6 +3071,49 @@ ice_set_tso_ctx(struct rte_mbuf *mbuf, union ci_tx_offload tx_offload)
 	return ctx_desc;
 }
 
+/* compute a context descriptor if one is necessary based on the ol_flags
+ *
+ * Returns 0 if no descriptor is necessary.
+ * Returns 1 if one is necessary and the contents of the descriptor are returned
+ *   in the values pointed to by qw0 and qw1.
+ */
+static __rte_always_inline uint16_t
+get_context_desc(uint64_t ol_flags, const struct rte_mbuf *tx_pkt,
+	const union ci_tx_offload *tx_offload, const struct ci_tx_queue *txq,
+	uint64_t *qw0, uint64_t *qw1)
+{
+	uint16_t cd_l2tag2 = 0;
+	uint64_t cd_type_cmd_tso_mss = ICE_TX_DESC_DTYPE_CTX;
+	uint32_t cd_tunneling_params = 0;
+	uint64_t ptp_tx_index = txq->ice_vsi->adapter->ptp_tx_index;
+
+	if (ice_calc_context_desc(ol_flags) == 0)
+		return 0;
+
+	if (ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK)
+		ice_parse_tunneling_params(ol_flags, *tx_offload, &cd_tunneling_params);
+
+	if (ol_flags & (RTE_MBUF_F_TX_TCP_SEG | RTE_MBUF_F_TX_UDP_SEG))
+		cd_type_cmd_tso_mss |= ice_set_tso_ctx(ol_flags, tx_pkt, *tx_offload);
+	else if (ol_flags & RTE_MBUF_F_TX_IEEE1588_TMST)
+		cd_type_cmd_tso_mss |=
+			((uint64_t)CI_TX_CTX_DESC_TSYN << CI_TXD_QW1_CMD_S) |
+			((ptp_tx_index << ICE_TXD_CTX_QW1_TSYN_S) & ICE_TXD_CTX_QW1_TSYN_M);
+
+
+	/* TX context descriptor based double VLAN insert */
+	if (ol_flags & RTE_MBUF_F_TX_QINQ) {
+		cd_l2tag2 = tx_pkt->vlan_tci_outer;
+		cd_type_cmd_tso_mss |= ((uint64_t)CI_TX_CTX_DESC_IL2TAG2 << CI_TXD_QW1_CMD_S);
+	}
+
+	*qw0 = rte_cpu_to_le_32(cd_tunneling_params) |
+		((uint64_t)rte_cpu_to_le_16(cd_l2tag2) << 32);
+	*qw1 = rte_cpu_to_le_64(cd_type_cmd_tso_mss);
+
+	return 1;
+}
+
 uint16_t
 ice_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 {
@@ -3085,7 +3124,6 @@ ice_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 	struct ci_tx_entry *txe, *txn;
 	struct rte_mbuf *tx_pkt;
 	struct rte_mbuf *m_seg;
-	uint32_t cd_tunneling_params;
 	uint16_t tx_id;
 	uint16_t ts_id = -1;
 	uint16_t nb_tx;
@@ -3096,6 +3134,7 @@ ice_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 	uint32_t td_tag = 0;
 	uint16_t tx_last;
 	uint16_t slen;
+	uint16_t l2_len;
 	uint64_t buf_dma_addr;
 	uint64_t ol_flags;
 	union ci_tx_offload tx_offload = {0};
@@ -3114,20 +3153,25 @@ ice_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 		(void)ci_tx_xmit_cleanup(txq);
 
 	for (nb_tx = 0; nb_tx < nb_pkts; nb_tx++) {
+		uint64_t cd_qw0, cd_qw1;
 		tx_pkt = *tx_pkts++;
 
+		ol_flags = tx_pkt->ol_flags;
 		td_cmd = 0;
 		td_tag = 0;
-		td_offset = 0;
-		ol_flags = tx_pkt->ol_flags;
+		l2_len = ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK ?
+				tx_pkt->outer_l2_len : tx_pkt->l2_len;
+		td_offset = (l2_len >> 1) << CI_TX_DESC_LEN_MACLEN_S;
+
 		tx_offload.l2_len = tx_pkt->l2_len;
 		tx_offload.l3_len = tx_pkt->l3_len;
 		tx_offload.outer_l2_len = tx_pkt->outer_l2_len;
 		tx_offload.outer_l3_len = tx_pkt->outer_l3_len;
 		tx_offload.l4_len = tx_pkt->l4_len;
 		tx_offload.tso_segsz = tx_pkt->tso_segsz;
+
 		/* Calculate the number of context descriptors needed. */
-		nb_ctx = ice_calc_context_desc(ol_flags);
+		nb_ctx = get_context_desc(ol_flags, tx_pkt, &tx_offload, txq, &cd_qw0, &cd_qw1);
 
 		/* The number of descriptors that must be allocated for
 		 * a packet equals to the number of the segments of that
@@ -3169,15 +3213,6 @@ ice_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 			td_tag = tx_pkt->vlan_tci;
 		}
 
-		/* Fill in tunneling parameters if necessary */
-		cd_tunneling_params = 0;
-		if (ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK) {
-			td_offset |= (tx_offload.outer_l2_len >> 1)
-				<< CI_TX_DESC_LEN_MACLEN_S;
-			ice_parse_tunneling_params(ol_flags, tx_offload,
-						   &cd_tunneling_params);
-		}
-
 		/* Enable checksum offloading */
 		if (ol_flags & ICE_TX_CKSUM_OFFLOAD_MASK)
 			ice_txd_enable_checksum(ol_flags, &td_cmd,
@@ -3185,11 +3220,7 @@ ice_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 
 		if (nb_ctx) {
 			/* Setup TX context descriptor if required */
-			volatile struct ice_tx_ctx_desc *ctx_txd =
-				(volatile struct ice_tx_ctx_desc *)
-					&ci_tx_ring[tx_id];
-			uint16_t cd_l2tag2 = 0;
-			uint64_t cd_type_cmd_tso_mss = ICE_TX_DESC_DTYPE_CTX;
+			uint64_t *ctx_txd = RTE_CAST_PTR(uint64_t *, &ci_tx_ring[tx_id]);
 
 			txn = &sw_ring[txe->next_id];
 			RTE_MBUF_PREFETCH_TO_FREE(txn->mbuf);
@@ -3198,29 +3229,8 @@ ice_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 				txe->mbuf = NULL;
 			}
 
-			if (ol_flags & (RTE_MBUF_F_TX_TCP_SEG | RTE_MBUF_F_TX_UDP_SEG))
-				cd_type_cmd_tso_mss |=
-					ice_set_tso_ctx(tx_pkt, tx_offload);
-			else if (ol_flags & RTE_MBUF_F_TX_IEEE1588_TMST)
-				cd_type_cmd_tso_mss |=
-					((uint64_t)CI_TX_CTX_DESC_TSYN <<
-					CI_TXD_QW1_CMD_S) |
-					 (((uint64_t)txq->ice_vsi->adapter->ptp_tx_index <<
-					 ICE_TXD_CTX_QW1_TSYN_S) & ICE_TXD_CTX_QW1_TSYN_M);
-
-			ctx_txd->tunneling_params =
-				rte_cpu_to_le_32(cd_tunneling_params);
-
-			/* TX context descriptor based double VLAN insert */
-			if (ol_flags & RTE_MBUF_F_TX_QINQ) {
-				cd_l2tag2 = tx_pkt->vlan_tci_outer;
-				cd_type_cmd_tso_mss |=
-					((uint64_t)CI_TX_CTX_DESC_IL2TAG2 <<
-					 CI_TXD_QW1_CMD_S);
-			}
-			ctx_txd->l2tag2 = rte_cpu_to_le_16(cd_l2tag2);
-			ctx_txd->qw1 =
-				rte_cpu_to_le_64(cd_type_cmd_tso_mss);
+			ctx_txd[0] = cd_qw0;
+			ctx_txd[1] = cd_qw1;
 
 			txe->last_id = tx_last;
 			tx_id = txe->next_id;
Signature · 1 line
2.51.0
#145 lore raw

Re: [PATCH v4 06/35] net/ice: refactor context descriptor handling

Quoted 7 lines · Bruce Richardson

Create a single function to manage all context descriptor handling, which returns either 0 or 1 depending on whether a descriptor is needed or not, as well as returning directly the descriptor contents if relevant.

---

<snip>

Quoted 12 lines
drivers/net/intel/ice/ice_rxtx.c +12 -0
+static __rte_always_inline uint16_t
+get_context_desc(uint64_t ol_flags, const struct rte_mbuf *tx_pkt,
+	const union ci_tx_offload *tx_offload, const struct ci_tx_queue *txq,
+	uint64_t *qw0, uint64_t *qw1)
+{
+	uint16_t cd_l2tag2 = 0;
+	uint64_t cd_type_cmd_tso_mss = ICE_TX_DESC_DTYPE_CTX;
+	uint32_t cd_tunneling_params = 0;
+	uint64_t ptp_tx_index = txq->ice_vsi->adapter->ptp_tx_index;
+
+	if (ice_calc_context_desc(ol_flags) == 0)
+		return 0;

drivers/net/intel/ice/ice_rxtx.c ice_set_tso_ctx(struct rte_mbuf *mbuf, union ci_tx_offload tx_offload) · line 3101

Quoted 10 lines
drivers/net/intel/ice/ice_rxtx.c +10 -0
+
+	if (ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK)
+		ice_parse_tunneling_params(ol_flags, *tx_offload, &cd_tunneling_params);
+
+	if (ol_flags & (RTE_MBUF_F_TX_TCP_SEG | RTE_MBUF_F_TX_UDP_SEG))
+		cd_type_cmd_tso_mss |= ice_set_tso_ctx(ol_flags, tx_pkt, *tx_offload);
+	else if (ol_flags & RTE_MBUF_F_TX_IEEE1588_TMST)
+		cd_type_cmd_tso_mss |=
+			((uint64_t)CI_TX_CTX_DESC_TSYN << CI_TXD_QW1_CMD_S) |
+			((ptp_tx_index << ICE_TXD_CTX_QW1_TSYN_S) & ICE_TXD_CTX_QW1_TSYN_M);

It's tangentially related to this commit but it caught my attention that TSO and timestamping are mutually exclusive here. They *are* mutually exclusive as far as the driver is concerned so that part is fine, but I couldn't find any signs of us enforcing this limitation anywhere in our configuration path, so a well behaved application could theoretically arrive at this combination of mbuf flags without breaking anything.

(if I understand things correctly, this applies to both ice and i40e)

Signature · 2 lines
Thanks,
Anatoly
#146 lore raw

Re: [PATCH v4 06/35] net/ice: refactor context descriptor handling

Quoted 41 lines · Anatoly
Quoted 7 lines · Bruce Richardson

Create a single function to manage all context descriptor handling, which returns either 0 or 1 depending on whether a descriptor is needed or not, as well as returning directly the descriptor contents if relevant.

---

<snip>

Quoted 12 lines
drivers/net/intel/ice/ice_rxtx.c +12 -0
+static __rte_always_inline uint16_t
+get_context_desc(uint64_t ol_flags, const struct rte_mbuf *tx_pkt,
+	const union ci_tx_offload *tx_offload, const struct ci_tx_queue *txq,
+	uint64_t *qw0, uint64_t *qw1)
+{
+	uint16_t cd_l2tag2 = 0;
+	uint64_t cd_type_cmd_tso_mss = ICE_TX_DESC_DTYPE_CTX;
+	uint32_t cd_tunneling_params = 0;
+	uint64_t ptp_tx_index = txq->ice_vsi->adapter->ptp_tx_index;
+
+	if (ice_calc_context_desc(ol_flags) == 0)
+		return 0;

drivers/net/intel/ice/ice_rxtx.c ice_set_tso_ctx(struct rte_mbuf *mbuf, union ci_tx_offload tx_offload) · line 3101

Quoted 10 lines
drivers/net/intel/ice/ice_rxtx.c +10 -0
+
+	if (ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK)
+		ice_parse_tunneling_params(ol_flags, *tx_offload, &cd_tunneling_params);
+
+	if (ol_flags & (RTE_MBUF_F_TX_TCP_SEG | RTE_MBUF_F_TX_UDP_SEG))
+		cd_type_cmd_tso_mss |= ice_set_tso_ctx(ol_flags, tx_pkt, *tx_offload);
+	else if (ol_flags & RTE_MBUF_F_TX_IEEE1588_TMST)
+		cd_type_cmd_tso_mss |=
+			((uint64_t)CI_TX_CTX_DESC_TSYN << CI_TXD_QW1_CMD_S) |
+			((ptp_tx_index << ICE_TXD_CTX_QW1_TSYN_S) & ICE_TXD_CTX_QW1_TSYN_M);

It's tangentially related to this commit but it caught my attention that TSO and timestamping are mutually exclusive here. They *are* mutually exclusive as far as the driver is concerned so that part is fine, but I couldn't find any signs of us enforcing this limitation anywhere in our configuration path, so a well behaved application could theoretically arrive at this combination of mbuf flags without breaking anything.

Quoted 2 lines

(if I understand things correctly, this applies to both ice and i40e)

Yes, you are correct here. However, I'm not sure if we can or should enforce this, as it is completely possible to have a queue where some packets are sent with TSO and others are sent with the timesync flag on them. There is no way for the actual Tx function to flag a bad packet. Best we can possibly do is add a check to the pre-Tx packet prepare function. WDYT?

/Bruce

#147 lore raw

Re: [PATCH v4 06/35] net/ice: refactor context descriptor handling

Quoted 44 lines · Bruce Richardson
Quoted 41 lines · Anatoly
Quoted 7 lines · Bruce Richardson

Create a single function to manage all context descriptor handling, which returns either 0 or 1 depending on whether a descriptor is needed or not, as well as returning directly the descriptor contents if relevant.

---

<snip>

Quoted 12 lines
drivers/net/intel/ice/ice_rxtx.c +12 -0
+static __rte_always_inline uint16_t
+get_context_desc(uint64_t ol_flags, const struct rte_mbuf *tx_pkt,
+	const union ci_tx_offload *tx_offload, const struct ci_tx_queue *txq,
+	uint64_t *qw0, uint64_t *qw1)
+{
+	uint16_t cd_l2tag2 = 0;
+	uint64_t cd_type_cmd_tso_mss = ICE_TX_DESC_DTYPE_CTX;
+	uint32_t cd_tunneling_params = 0;
+	uint64_t ptp_tx_index = txq->ice_vsi->adapter->ptp_tx_index;
+
+	if (ice_calc_context_desc(ol_flags) == 0)
+		return 0;

drivers/net/intel/ice/ice_rxtx.c ice_set_tso_ctx(struct rte_mbuf *mbuf, union ci_tx_offload tx_offload) · line 3101

Quoted 10 lines
drivers/net/intel/ice/ice_rxtx.c +10 -0
+
+	if (ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK)
+		ice_parse_tunneling_params(ol_flags, *tx_offload, &cd_tunneling_params);
+
+	if (ol_flags & (RTE_MBUF_F_TX_TCP_SEG | RTE_MBUF_F_TX_UDP_SEG))
+		cd_type_cmd_tso_mss |= ice_set_tso_ctx(ol_flags, tx_pkt, *tx_offload);
+	else if (ol_flags & RTE_MBUF_F_TX_IEEE1588_TMST)
+		cd_type_cmd_tso_mss |=
+			((uint64_t)CI_TX_CTX_DESC_TSYN << CI_TXD_QW1_CMD_S) |
+			((ptp_tx_index << ICE_TXD_CTX_QW1_TSYN_S) & ICE_TXD_CTX_QW1_TSYN_M);

It's tangentially related to this commit but it caught my attention that TSO and timestamping are mutually exclusive here. They *are* mutually exclusive as far as the driver is concerned so that part is fine, but I couldn't find any signs of us enforcing this limitation anywhere in our configuration path, so a well behaved application could theoretically arrive at this combination of mbuf flags without breaking anything.

Quoted 2 lines

(if I understand things correctly, this applies to both ice and i40e)

Quoted 8 lines

Yes, you are correct here. However, I'm not sure if we can or should enforce this, as it is completely possible to have a queue where some packets are sent with TSO and others are sent with the timesync flag on them. There is no way for the actual Tx function to flag a bad packet. Best we can possibly do is add a check to the pre-Tx packet prepare function. WDYT?

/Bruce

Now that I think of it, I believe these features do not make logical sense together anyway (TSO means segmented packets while timestamping means you have one packet you timestamp) so perhaps this can be considered user error? I mean we could add a check if it doesn't hurt performance, but maybe this isn't a problem we need to solve.

Signature · 2 lines
Thanks,
Anatoly
#148 lore raw

Re: [PATCH v4 06/35] net/ice: refactor context descriptor handling

Quoted 52 lines · Anatoly
Quoted 51 lines · Bruce Richardson
Quoted 41 lines · Anatoly
Quoted 7 lines · Bruce Richardson

Create a single function to manage all context descriptor handling, which returns either 0 or 1 depending on whether a descriptor is needed or not, as well as returning directly the descriptor contents if relevant.

---

<snip>

Quoted 12 lines
drivers/net/intel/ice/ice_rxtx.c +12 -0
+static __rte_always_inline uint16_t
+get_context_desc(uint64_t ol_flags, const struct rte_mbuf *tx_pkt,
+	const union ci_tx_offload *tx_offload, const struct ci_tx_queue *txq,
+	uint64_t *qw0, uint64_t *qw1)
+{
+	uint16_t cd_l2tag2 = 0;
+	uint64_t cd_type_cmd_tso_mss = ICE_TX_DESC_DTYPE_CTX;
+	uint32_t cd_tunneling_params = 0;
+	uint64_t ptp_tx_index = txq->ice_vsi->adapter->ptp_tx_index;
+
+	if (ice_calc_context_desc(ol_flags) == 0)
+		return 0;

drivers/net/intel/ice/ice_rxtx.c ice_set_tso_ctx(struct rte_mbuf *mbuf, union ci_tx_offload tx_offload) · line 3101

Quoted 10 lines
drivers/net/intel/ice/ice_rxtx.c +10 -0
+
+	if (ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK)
+		ice_parse_tunneling_params(ol_flags, *tx_offload, &cd_tunneling_params);
+
+	if (ol_flags & (RTE_MBUF_F_TX_TCP_SEG | RTE_MBUF_F_TX_UDP_SEG))
+		cd_type_cmd_tso_mss |= ice_set_tso_ctx(ol_flags, tx_pkt, *tx_offload);
+	else if (ol_flags & RTE_MBUF_F_TX_IEEE1588_TMST)
+		cd_type_cmd_tso_mss |=
+			((uint64_t)CI_TX_CTX_DESC_TSYN << CI_TXD_QW1_CMD_S) |
+			((ptp_tx_index << ICE_TXD_CTX_QW1_TSYN_S) & ICE_TXD_CTX_QW1_TSYN_M);

It's tangentially related to this commit but it caught my attention that TSO and timestamping are mutually exclusive here. They *are* mutually exclusive as far as the driver is concerned so that part is fine, but I couldn't find any signs of us enforcing this limitation anywhere in our configuration path, so a well behaved application could theoretically arrive at this combination of mbuf flags without breaking anything.

Quoted 2 lines

(if I understand things correctly, this applies to both ice and i40e)

Yes, you are correct here. However, I'm not sure if we can or should enforce this, as it is completely possible to have a queue where some packets are sent with TSO and others are sent with the timesync flag on them. There is no way for the actual Tx function to flag a bad packet. Best we can possibly do is add a check to the pre-Tx packet prepare function. WDYT?

Quoted 8 lines
Quoted 1 line

/Bruce

Now that I think of it, I believe these features do not make logical sense together anyway (TSO means segmented packets while timestamping means you have one packet you timestamp) so perhaps this can be considered user error? I mean we could add a check if it doesn't hurt performance, but maybe this isn't a problem we need to solve.

I wouldn't put a datapath check for this. Maybe one in tx_prepare just, but even then I'm not sure of the cost/benefit.

/Bruce

#149 lore raw

PATCH v4 7/35 net/i40e: refactor context descriptor handling

In reply to Bruce Richardson

Move all context descriptor handling to a single function, as with the ice driver, and use the same function signature as that driver.

---
 drivers/net/intel/i40e/i40e_rxtx.c | 123 +++++++++++++++--------------
 1 file changed, 63 insertions(+), 60 deletions(-)
drivers/net/intel/i40e/i40e_rxtx.c +63 -60
index b75306931a..601d4b98f2 100644
@@ -321,11 +321,6 @@ i40e_txd_enable_checksum(uint64_t ol_flags,
 			uint32_t *td_offset,
 			union ci_tx_offload tx_offload)
 {
-	/* Set MACLEN */
-	if (!(ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK))
-		*td_offset |= (tx_offload.l2_len >> 1)
-			<< CI_TX_DESC_LEN_MACLEN_S;
-
 	/* Enable L3 checksum offloads */
 	if (ol_flags & RTE_MBUF_F_TX_IP_CKSUM) {
 		*td_cmd |= CI_TX_DESC_CMD_IIPT_IPV4_CSUM;
@@ -1004,7 +999,7 @@ i40e_calc_context_desc(uint64_t flags)
 
 /* set i40e TSO context descriptor */
 static inline uint64_t
-i40e_set_tso_ctx(struct rte_mbuf *mbuf, union ci_tx_offload tx_offload)
+i40e_set_tso_ctx(uint64_t ol_flags, const struct rte_mbuf *mbuf, union ci_tx_offload tx_offload)
 {
 	uint64_t ctx_desc = 0;
 	uint32_t cd_cmd, hdr_len, cd_tso_len;
@@ -1015,7 +1010,7 @@ i40e_set_tso_ctx(struct rte_mbuf *mbuf, union ci_tx_offload tx_offload)
 	}
 
 	hdr_len = tx_offload.l2_len + tx_offload.l3_len + tx_offload.l4_len;
-	hdr_len += (mbuf->ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK) ?
+	hdr_len += (ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK) ?
 		   tx_offload.outer_l2_len + tx_offload.outer_l3_len : 0;
 
 	cd_cmd = I40E_TX_CTX_DESC_TSO;
@@ -1029,6 +1024,52 @@ i40e_set_tso_ctx(struct rte_mbuf *mbuf, union ci_tx_offload tx_offload)
 	return ctx_desc;
 }
 
+/* compute a context descriptor if one is necessary based on the ol_flags
+ *
+ * Returns 0 if no descriptor is necessary.
+ * Returns 1 if one is necessary and the contents of the descriptor are returned
+ *   in the values pointed to by qw0 and qw1.
+ */
+static __rte_always_inline uint16_t
+get_context_desc(uint64_t ol_flags, const struct rte_mbuf *tx_pkt,
+		 const union ci_tx_offload *tx_offload,
+		 const struct ci_tx_queue *txq __rte_unused,
+		 uint64_t *qw0, uint64_t *qw1)
+{
+	uint16_t cd_l2tag2 = 0;
+	uint64_t cd_type_cmd_tso_mss = I40E_TX_DESC_DTYPE_CONTEXT;
+	uint32_t cd_tunneling_params = 0;
+
+	if (i40e_calc_context_desc(ol_flags) == 0)
+		return 0;
+
+	if (ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK)
+		i40e_parse_tunneling_params(ol_flags, *tx_offload, &cd_tunneling_params);
+
+	if (ol_flags & RTE_MBUF_F_TX_TCP_SEG) {
+		cd_type_cmd_tso_mss |= i40e_set_tso_ctx(ol_flags, tx_pkt, *tx_offload);
+	} else {
+#ifdef RTE_LIBRTE_IEEE1588
+		if (ol_flags & RTE_MBUF_F_TX_IEEE1588_TMST)
+			cd_type_cmd_tso_mss |=
+				((uint64_t)I40E_TX_CTX_DESC_TSYN << I40E_TXD_CTX_QW1_CMD_SHIFT);
+#endif
+	}
+
+	/* TX context descriptor based double VLAN insert */
+	if (ol_flags & RTE_MBUF_F_TX_QINQ) {
+		cd_l2tag2 = tx_pkt->vlan_tci_outer;
+		cd_type_cmd_tso_mss |=
+				((uint64_t)I40E_TX_CTX_DESC_IL2TAG2 << I40E_TXD_CTX_QW1_CMD_SHIFT);
+	}
+
+	*qw0 = rte_cpu_to_le_32(cd_tunneling_params) |
+		((uint64_t)rte_cpu_to_le_16(cd_l2tag2) << 32);
+	*qw1 = rte_cpu_to_le_64(cd_type_cmd_tso_mss);
+
+	return 1;
+}
+
 uint16_t
 i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 {
@@ -1039,7 +1080,6 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 	volatile struct ci_tx_desc *txr;
 	struct rte_mbuf *tx_pkt;
 	struct rte_mbuf *m_seg;
-	uint32_t cd_tunneling_params;
 	uint16_t tx_id;
 	uint16_t nb_tx;
 	uint32_t td_cmd;
@@ -1050,6 +1090,7 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 	uint16_t nb_ctx;
 	uint16_t tx_last;
 	uint16_t slen;
+	uint16_t l2_len;
 	uint64_t buf_dma_addr;
 	union ci_tx_offload tx_offload = {0};
 
@@ -1064,14 +1105,15 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 		(void)ci_tx_xmit_cleanup(txq);
 
 	for (nb_tx = 0; nb_tx < nb_pkts; nb_tx++) {
-		td_cmd = 0;
-		td_tag = 0;
-		td_offset = 0;
-
 		tx_pkt = *tx_pkts++;
 		RTE_MBUF_PREFETCH_TO_FREE(txe->mbuf);
 
 		ol_flags = tx_pkt->ol_flags;
+		td_cmd = 0;
+		td_tag = 0;
+		l2_len = ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK ?
+				tx_pkt->outer_l2_len : tx_pkt->l2_len;
+		td_offset = (l2_len >> 1) << CI_TX_DESC_LEN_MACLEN_S;
 		tx_offload.l2_len = tx_pkt->l2_len;
 		tx_offload.l3_len = tx_pkt->l3_len;
 		tx_offload.outer_l2_len = tx_pkt->outer_l2_len;
@@ -1080,7 +1122,9 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 		tx_offload.tso_segsz = tx_pkt->tso_segsz;
 
 		/* Calculate the number of context descriptors needed. */
-		nb_ctx = i40e_calc_context_desc(ol_flags);
+		uint64_t cd_qw0 = 0, cd_qw1 = 0;
+		nb_ctx = get_context_desc(ol_flags, tx_pkt, &tx_offload, txq,
+				&cd_qw0, &cd_qw1);
 
 		/**
 		 * The number of descriptors that must be allocated for
@@ -1126,14 +1170,6 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 		/* Always enable CRC offload insertion */
 		td_cmd |= CI_TX_DESC_CMD_ICRC;
 
-		/* Fill in tunneling parameters if necessary */
-		cd_tunneling_params = 0;
-		if (ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK) {
-			td_offset |= (tx_offload.outer_l2_len >> 1)
-					<< CI_TX_DESC_LEN_MACLEN_S;
-			i40e_parse_tunneling_params(ol_flags, tx_offload,
-						    &cd_tunneling_params);
-		}
 		/* Enable checksum offloading */
 		if (ol_flags & I40E_TX_CKSUM_OFFLOAD_MASK)
 			i40e_txd_enable_checksum(ol_flags, &td_cmd,
@@ -1141,12 +1177,7 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 
 		if (nb_ctx) {
 			/* Setup TX context descriptor if required */
-			volatile struct i40e_tx_context_desc *ctx_txd =
-				(volatile struct i40e_tx_context_desc *)\
-							&txr[tx_id];
-			uint16_t cd_l2tag2 = 0;
-			uint64_t cd_type_cmd_tso_mss =
-				I40E_TX_DESC_DTYPE_CONTEXT;
+			uint64_t *desc = RTE_CAST_PTR(uint64_t *, &txr[tx_id]);
 
 			txn = &sw_ring[txe->next_id];
 			RTE_MBUF_PREFETCH_TO_FREE(txn->mbuf);
@@ -1155,41 +1186,13 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 				txe->mbuf = NULL;
 			}
 
-			/* TSO enabled means no timestamp */
-			if (ol_flags & RTE_MBUF_F_TX_TCP_SEG)
-				cd_type_cmd_tso_mss |=
-					i40e_set_tso_ctx(tx_pkt, tx_offload);
-			else {
-#ifdef RTE_LIBRTE_IEEE1588
-				if (ol_flags & RTE_MBUF_F_TX_IEEE1588_TMST)
-					cd_type_cmd_tso_mss |=
-						((uint64_t)I40E_TX_CTX_DESC_TSYN <<
-						 I40E_TXD_CTX_QW1_CMD_SHIFT);
-#endif
-			}
-
-			ctx_txd->tunneling_params =
-				rte_cpu_to_le_32(cd_tunneling_params);
-			if (ol_flags & RTE_MBUF_F_TX_QINQ) {
-				cd_l2tag2 = tx_pkt->vlan_tci_outer;
-				cd_type_cmd_tso_mss |=
-					((uint64_t)I40E_TX_CTX_DESC_IL2TAG2 <<
-						I40E_TXD_CTX_QW1_CMD_SHIFT);
-			}
-			ctx_txd->l2tag2 = rte_cpu_to_le_16(cd_l2tag2);
-			ctx_txd->type_cmd_tso_mss =
-				rte_cpu_to_le_64(cd_type_cmd_tso_mss);
+			desc[0] = cd_qw0;
+			desc[1] = cd_qw1;
 
 			PMD_TX_LOG(DEBUG, "mbuf: %p, TCD[%u]: "
-				"tunneling_params: %#x; "
-				"l2tag2: %#hx; "
-				"rsvd: %#hx; "
-				"type_cmd_tso_mss: %#"PRIx64";",
-				tx_pkt, tx_id,
-				ctx_txd->tunneling_params,
-				ctx_txd->l2tag2,
-				ctx_txd->rsvd,
-				ctx_txd->type_cmd_tso_mss);
+				"qw0: %#"PRIx64"; "
+				"qw1: %#"PRIx64";",
+				tx_pkt, tx_id, cd_qw0, cd_qw1);
 
 			txe->last_id = tx_last;
 			tx_id = txe->next_id;
Signature · 1 line
2.51.0
#150 lore raw

Re: [PATCH v4 07/35] net/i40e: refactor context descriptor handling

Quoted 5 lines · Bruce Richardson

Move all context descriptor handling to a single function, as with the ice driver, and use the same function signature as that driver.

---

<snip>

Quoted 14 lines
drivers/net/intel/i40e/i40e_rxtx.c +14 -0
+static __rte_always_inline uint16_t
+get_context_desc(uint64_t ol_flags, const struct rte_mbuf *tx_pkt,
+		 const union ci_tx_offload *tx_offload,
+		 const struct ci_tx_queue *txq __rte_unused,
+		 uint64_t *qw0, uint64_t *qw1)
+{
+	uint16_t cd_l2tag2 = 0;
+	uint64_t cd_type_cmd_tso_mss = I40E_TX_DESC_DTYPE_CONTEXT;
+	uint32_t cd_tunneling_params = 0;
+
+	if (i40e_calc_context_desc(ol_flags) == 0)
+		return 0;
+
+	if (ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK)

drivers/net/intel/i40e/i40e_rxtx.c i40e_set_tso_ctx(struct rte_mbuf *mbuf, union ci_tx_offload tx_offload) · line 1056

Quoted 10 lines
drivers/net/intel/i40e/i40e_rxtx.c +10 -0
+		i40e_parse_tunneling_params(ol_flags, *tx_offload, &cd_tunneling_params);
+
+	if (ol_flags & RTE_MBUF_F_TX_TCP_SEG) {
+		cd_type_cmd_tso_mss |= i40e_set_tso_ctx(ol_flags, tx_pkt, *tx_offload);
+	} else {
+#ifdef RTE_LIBRTE_IEEE1588
+		if (ol_flags & RTE_MBUF_F_TX_IEEE1588_TMST)
+			cd_type_cmd_tso_mss |=
+				((uint64_t)I40E_TX_CTX_DESC_TSYN << I40E_TXD_CTX_QW1_CMD_SHIFT);
+#endif

I couldn't find any places where we define this, it appears to be some sort of legacy define, making this basically dead code?

Signature · 2 lines
Thanks,
Anatoly
#151 lore raw

Re: [PATCH v4 07/35] net/i40e: refactor context descriptor handling

Quoted 28 lines · Anatoly
Quoted 5 lines · Bruce Richardson

Move all context descriptor handling to a single function, as with the ice driver, and use the same function signature as that driver.

---

<snip>

Quoted 19 lines
drivers/net/intel/i40e/i40e_rxtx.c +19 -0
+static __rte_always_inline uint16_t
+get_context_desc(uint64_t ol_flags, const struct rte_mbuf *tx_pkt,
+		 const union ci_tx_offload *tx_offload,
+		 const struct ci_tx_queue *txq __rte_unused,
+		 uint64_t *qw0, uint64_t *qw1)
+{
+	uint16_t cd_l2tag2 = 0;
+	uint64_t cd_type_cmd_tso_mss = I40E_TX_DESC_DTYPE_CONTEXT;
+	uint32_t cd_tunneling_params = 0;
+
+	if (i40e_calc_context_desc(ol_flags) == 0)
+		return 0;
+
+	if (ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK)
+		i40e_parse_tunneling_params(ol_flags, *tx_offload, &cd_tunneling_params);
+
+	if (ol_flags & RTE_MBUF_F_TX_TCP_SEG) {
+		cd_type_cmd_tso_mss |= i40e_set_tso_ctx(ol_flags, tx_pkt, *tx_offload);
+	} else {
Quoted 9 lines

drivers/net/intel/i40e/i40e_rxtx.c i40e_set_tso_ctx(struct rte_mbuf *mbuf, union ci_tx_offload tx_offload) · line 1056

Quoted 5 lines
drivers/net/intel/i40e/i40e_rxtx.c +5 -0
+#ifdef RTE_LIBRTE_IEEE1588
+		if (ol_flags & RTE_MBUF_F_TX_IEEE1588_TMST)
+			cd_type_cmd_tso_mss |=
+				((uint64_t)I40E_TX_CTX_DESC_TSYN << I40E_TXD_CTX_QW1_CMD_SHIFT);
+#endif

I couldn't find any places where we define this, it appears to be some sort of legacy define, making this basically dead code?

It is legacy, and does need to be fixed, but across all of DPDK I think. Testpmd, for example, has IEEE1588 ifdefs also.

However, for this patch, it's probably harmless enough to remove the ifdef here and always allow this code path to execute.

/Bruce

#152 lore raw

Re: [PATCH v4 07/35] net/i40e: refactor context descriptor handling

Quoted 39 lines · Bruce Richardson
Quoted 28 lines · Anatoly
Quoted 5 lines · Bruce Richardson

Move all context descriptor handling to a single function, as with the ice driver, and use the same function signature as that driver.

---

<snip>

Quoted 19 lines
drivers/net/intel/i40e/i40e_rxtx.c +19 -0
+static __rte_always_inline uint16_t
+get_context_desc(uint64_t ol_flags, const struct rte_mbuf *tx_pkt,
+		 const union ci_tx_offload *tx_offload,
+		 const struct ci_tx_queue *txq __rte_unused,
+		 uint64_t *qw0, uint64_t *qw1)
+{
+	uint16_t cd_l2tag2 = 0;
+	uint64_t cd_type_cmd_tso_mss = I40E_TX_DESC_DTYPE_CONTEXT;
+	uint32_t cd_tunneling_params = 0;
+
+	if (i40e_calc_context_desc(ol_flags) == 0)
+		return 0;
+
+	if (ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK)
+		i40e_parse_tunneling_params(ol_flags, *tx_offload, &cd_tunneling_params);
+
+	if (ol_flags & RTE_MBUF_F_TX_TCP_SEG) {
+		cd_type_cmd_tso_mss |= i40e_set_tso_ctx(ol_flags, tx_pkt, *tx_offload);
+	} else {
Quoted 9 lines

drivers/net/intel/i40e/i40e_rxtx.c i40e_set_tso_ctx(struct rte_mbuf *mbuf, union ci_tx_offload tx_offload) · line 1056

Quoted 5 lines
drivers/net/intel/i40e/i40e_rxtx.c +5 -0
+#ifdef RTE_LIBRTE_IEEE1588
+		if (ol_flags & RTE_MBUF_F_TX_IEEE1588_TMST)
+			cd_type_cmd_tso_mss |=
+				((uint64_t)I40E_TX_CTX_DESC_TSYN << I40E_TXD_CTX_QW1_CMD_SHIFT);
+#endif

I couldn't find any places where we define this, it appears to be some sort of legacy define, making this basically dead code?

Quoted 7 lines

It is legacy, and does need to be fixed, but across all of DPDK I think. Testpmd, for example, has IEEE1588 ifdefs also.

However, for this patch, it's probably harmless enough to remove the ifdef here and always allow this code path to execute.

/Bruce

Sure, but I would've preferred this to be a separate patch as it's semantically different from what you're doing here. Perhaps it can be fixed as one of the early patches in the series as "preparatory work" for this one.

Signature · 2 lines
Thanks,
Anatoly
#153 lore raw

Re: [PATCH v4 07/35] net/i40e: refactor context descriptor handling

Quoted 38 lines · Anatoly
Quoted 37 lines · Bruce Richardson
Quoted 20 lines · Anatoly
Quoted 4 lines · Bruce Richardson

Move all context descriptor handling to a single function, as with the ice driver, and use the same function signature as that driver.

<snip>

Quoted 12 lines

+static __rte_always_inline uint16_t +get_context_desc(uint64_t
ol_flags, const struct rte_mbuf *tx_pkt, + const
union ci_tx_offload *tx_offload, + const struct
ci_tx_queue *txq __rte_unused, + uint64_t *qw0,
uint64_t *qw1) +{ + uint16_t cd_l2tag2 = 0; + uint64_t
cd_type_cmd_tso_mss = I40E_TX_DESC_DTYPE_CONTEXT; + uint32_t
cd_tunneling_params = 0; + + if
(i40e_calc_context_desc(ol_flags) == 0) + return 0; +

(quoted diff) +1 -0
+	if (ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK) +

i40e_parse_tunneling_params(ol_flags, *tx_offload,
&cd_tunneling_params); + + if (ol_flags &
RTE_MBUF_F_TX_TCP_SEG) { + cd_type_cmd_tso_mss |=

Quoted 9 lines
Quoted 5 lines

i40e_set_tso_ctx(ol_flags, tx_pkt, *tx_offload); + } else {
+#ifdef RTE_LIBRTE_IEEE1588 + if (ol_flags &
RTE_MBUF_F_TX_IEEE1588_TMST) + cd_type_cmd_tso_mss
|= + ((uint64_t)I40E_TX_CTX_DESC_TSYN <<
I40E_TXD_CTX_QW1_CMD_SHIFT); +#endif

I couldn't find any places where we define this, it appears to be some sort of legacy define, making this basically dead code?

It is legacy, and does need to be fixed, but across all of DPDK I think. Testpmd, for example, has IEEE1588 ifdefs also.

However, for this patch, it's probably harmless enough to remove the ifdef here and always allow this code path to execute.

Quoted 7 lines
Quoted 1 line

/Bruce

Sure, but I would've preferred this to be a separate patch as it's semantically different from what you're doing here. Perhaps it can be fixed as one of the early patches in the series as "preparatory work" for this one.

I don't think it belongs in this series at all, actually. The IEEE1588 define appears in multiple drivers, not just Intel ones, as well as testpmd (as I previously said). However, if you think it's worth patching it out just for i40e I can add the patch to do so to this set.

/Bruce

#154 lore raw

Re: [PATCH v4 07/35] net/i40e: refactor context descriptor handling

Quoted 47 lines · Bruce Richardson
Quoted 38 lines · Anatoly
Quoted 37 lines · Bruce Richardson
Quoted 20 lines · Anatoly
Quoted 4 lines · Bruce Richardson

Move all context descriptor handling to a single function, as with the ice driver, and use the same function signature as that driver.

<snip>

Quoted 12 lines

+static __rte_always_inline uint16_t +get_context_desc(uint64_t
ol_flags, const struct rte_mbuf *tx_pkt, + const
union ci_tx_offload *tx_offload, + const struct
ci_tx_queue *txq __rte_unused, + uint64_t *qw0,
uint64_t *qw1) +{ + uint16_t cd_l2tag2 = 0; + uint64_t
cd_type_cmd_tso_mss = I40E_TX_DESC_DTYPE_CONTEXT; + uint32_t
cd_tunneling_params = 0; + + if
(i40e_calc_context_desc(ol_flags) == 0) + return 0; +

(quoted diff) +1 -0
+	if (ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK) +

i40e_parse_tunneling_params(ol_flags, *tx_offload,
&cd_tunneling_params); + + if (ol_flags &
RTE_MBUF_F_TX_TCP_SEG) { + cd_type_cmd_tso_mss |=

Quoted 9 lines
Quoted 5 lines

i40e_set_tso_ctx(ol_flags, tx_pkt, *tx_offload); + } else {
+#ifdef RTE_LIBRTE_IEEE1588 + if (ol_flags &
RTE_MBUF_F_TX_IEEE1588_TMST) + cd_type_cmd_tso_mss
|= + ((uint64_t)I40E_TX_CTX_DESC_TSYN <<
I40E_TXD_CTX_QW1_CMD_SHIFT); +#endif

I couldn't find any places where we define this, it appears to be some sort of legacy define, making this basically dead code?

It is legacy, and does need to be fixed, but across all of DPDK I think. Testpmd, for example, has IEEE1588 ifdefs also.

However, for this patch, it's probably harmless enough to remove the ifdef here and always allow this code path to execute.

Quoted 7 lines
Quoted 1 line

/Bruce

Sure, but I would've preferred this to be a separate patch as it's semantically different from what you're doing here. Perhaps it can be fixed as one of the early patches in the series as "preparatory work" for this one.

Quoted 6 lines

I don't think it belongs in this series at all, actually. The IEEE1588 define appears in multiple drivers, not just Intel ones, as well as testpmd (as I previously said). However, if you think it's worth patching it out just for i40e I can add the patch to do so to this set.

/Bruce

I don't have strong feelings about *when* to remove it, but if we are to remove it, IMO we should do it as a separate patch, not as a rolled-in change into this one. However, I don't think it's a big issue so if you think it's not worth the rework then that's fine.

Signature · 2 lines
Thanks,
Anatoly
#155 lore raw

Re: [PATCH v4 07/35] net/i40e: refactor context descriptor handling

Quoted 53 lines · Anatoly
Quoted 52 lines · Bruce Richardson
Quoted 38 lines · Anatoly
Quoted 37 lines · Bruce Richardson
Quoted 20 lines · Anatoly
Quoted 4 lines · Bruce Richardson

Move all context descriptor handling to a single function, as with the ice driver, and use the same function signature as that driver.

<snip>

Quoted 12 lines

+static __rte_always_inline uint16_t +get_context_desc(uint64_t
ol_flags, const struct rte_mbuf *tx_pkt, + const
union ci_tx_offload *tx_offload, + const struct
ci_tx_queue *txq __rte_unused, + uint64_t *qw0,
uint64_t *qw1) +{ + uint16_t cd_l2tag2 = 0; + uint64_t
cd_type_cmd_tso_mss = I40E_TX_DESC_DTYPE_CONTEXT; + uint32_t
cd_tunneling_params = 0; + + if
(i40e_calc_context_desc(ol_flags) == 0) + return 0; +

(quoted diff) +1 -0
+	if (ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK) +

i40e_parse_tunneling_params(ol_flags, *tx_offload,
&cd_tunneling_params); + + if (ol_flags &
RTE_MBUF_F_TX_TCP_SEG) { + cd_type_cmd_tso_mss |=

Quoted 9 lines
Quoted 5 lines

i40e_set_tso_ctx(ol_flags, tx_pkt, *tx_offload); + } else {
+#ifdef RTE_LIBRTE_IEEE1588 + if (ol_flags &
RTE_MBUF_F_TX_IEEE1588_TMST) + cd_type_cmd_tso_mss
|= + ((uint64_t)I40E_TX_CTX_DESC_TSYN <<
I40E_TXD_CTX_QW1_CMD_SHIFT); +#endif

I couldn't find any places where we define this, it appears to be some sort of legacy define, making this basically dead code?

It is legacy, and does need to be fixed, but across all of DPDK I think. Testpmd, for example, has IEEE1588 ifdefs also.

However, for this patch, it's probably harmless enough to remove the ifdef here and always allow this code path to execute.

Quoted 7 lines
Quoted 1 line

/Bruce

Sure, but I would've preferred this to be a separate patch as it's semantically different from what you're doing here. Perhaps it can be fixed as one of the early patches in the series as "preparatory work" for this one.

I don't think it belongs in this series at all, actually. The IEEE1588 define appears in multiple drivers, not just Intel ones, as well as testpmd (as I previously said). However, if you think it's worth patching it out just for i40e I can add the patch to do so to this set.

Quoted 7 lines
Quoted 1 line

/Bruce

I don't have strong feelings about *when* to remove it, but if we are to remove it, IMO we should do it as a separate patch, not as a rolled-in change into this one. However, I don't think it's a big issue so if you think it's not worth the rework then that's fine.

Ack.

#156 lore raw

PATCH v4 8/35 net/idpf: refactor context descriptor handling

In reply to Bruce Richardson

Move all context descriptor handling to a single function, as with the ice and i40e drivers.

---
 drivers/net/intel/idpf/idpf_common_rxtx.c | 61 +++++++++++------------
 1 file changed, 28 insertions(+), 33 deletions(-)
drivers/net/intel/idpf/idpf_common_rxtx.c +28 -33
index 11d6848430..9219ad9047 100644
@@ -845,37 +845,36 @@ idpf_calc_context_desc(uint64_t flags)
 	return 0;
 }
 
-/* set TSO context descriptor
+/* set TSO context descriptor, returns 0 if no context needed, 1 if context set
  */
-static inline void
-idpf_set_splitq_tso_ctx(struct rte_mbuf *mbuf,
+static inline uint16_t
+idpf_set_tso_ctx(uint64_t ol_flags, struct rte_mbuf *mbuf,
 			union ci_tx_offload tx_offload,
-			volatile union idpf_flex_tx_ctx_desc *ctx_desc)
+			uint64_t *qw0, uint64_t *qw1)
 {
-	uint16_t cmd_dtype;
+	uint16_t cmd_dtype = IDPF_TX_DESC_DTYPE_FLEX_TSO_CTX | IDPF_TX_FLEX_CTX_DESC_CMD_TSO;
+	uint16_t tso_segsz = mbuf->tso_segsz;
 	uint32_t tso_len;
 	uint8_t hdr_len;
 
+	if (idpf_calc_context_desc(ol_flags) == 0)
+		return 0;
+
+	/* TSO context descriptor setup */
 	if (tx_offload.l4_len == 0) {
 		TX_LOG(DEBUG, "L4 length set to 0");
-		return;
+		return 0;
 	}
 
-	hdr_len = tx_offload.l2_len +
-		tx_offload.l3_len +
-		tx_offload.l4_len;
-	cmd_dtype = IDPF_TX_DESC_DTYPE_FLEX_TSO_CTX |
-		IDPF_TX_FLEX_CTX_DESC_CMD_TSO;
+	hdr_len = tx_offload.l2_len + tx_offload.l3_len + tx_offload.l4_len;
 	tso_len = mbuf->pkt_len - hdr_len;
 
-	ctx_desc->tso.qw1.cmd_dtype = rte_cpu_to_le_16(cmd_dtype);
-	ctx_desc->tso.qw0.hdr_len = hdr_len;
-	ctx_desc->tso.qw0.mss_rt =
-		rte_cpu_to_le_16((uint16_t)mbuf->tso_segsz &
-				 IDPF_TXD_FLEX_CTX_MSS_RT_M);
-	ctx_desc->tso.qw0.flex_tlen =
-		rte_cpu_to_le_32(tso_len &
-				 IDPF_TXD_FLEX_CTX_MSS_RT_M);
+	*qw0 = rte_cpu_to_le_32(tso_len & IDPF_TXD_FLEX_CTX_MSS_RT_M) |
+	       ((uint64_t)rte_cpu_to_le_16(tso_segsz & IDPF_TXD_FLEX_CTX_MSS_RT_M) << 32) |
+	       ((uint64_t)hdr_len << 48);
+	*qw1 = rte_cpu_to_le_16(cmd_dtype);
+
+	return 1;
 }
 
 RTE_EXPORT_INTERNAL_SYMBOL(idpf_dp_splitq_xmit_pkts)
@@ -933,7 +932,8 @@ idpf_dp_splitq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 		tx_offload.l4_len = tx_pkt->l4_len;
 		tx_offload.tso_segsz = tx_pkt->tso_segsz;
 		/* Calculate the number of context descriptors needed. */
-		nb_ctx = idpf_calc_context_desc(ol_flags);
+		uint64_t cd_qw0, cd_qw1;
+		nb_ctx = idpf_set_tso_ctx(ol_flags, tx_pkt, tx_offload, &cd_qw0, &cd_qw1);
 
 		/* Calculate the number of TX descriptors needed for
 		 * each packet. For TSO packets, use ci_calc_pkt_desc as
@@ -950,12 +950,10 @@ idpf_dp_splitq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 
 		/* context descriptor */
 		if (nb_ctx != 0) {
-			volatile union idpf_flex_tx_ctx_desc *ctx_desc =
-				(volatile union idpf_flex_tx_ctx_desc *)&txr[tx_id];
+			uint64_t *ctx_desc = RTE_CAST_PTR(uint64_t *, &txr[tx_id]);
 
-			if ((ol_flags & RTE_MBUF_F_TX_TCP_SEG) != 0)
-				idpf_set_splitq_tso_ctx(tx_pkt, tx_offload,
-							ctx_desc);
+			ctx_desc[0] = cd_qw0;
+			ctx_desc[1] = cd_qw1;
 
 			tx_id++;
 			if (tx_id == txq->nb_tx_desc)
@@ -1388,7 +1386,8 @@ idpf_dp_singleq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 		tx_offload.l4_len = tx_pkt->l4_len;
 		tx_offload.tso_segsz = tx_pkt->tso_segsz;
 		/* Calculate the number of context descriptors needed. */
-		nb_ctx = idpf_calc_context_desc(ol_flags);
+		uint64_t cd_qw0, cd_qw1;
+		nb_ctx = idpf_set_tso_ctx(ol_flags, tx_pkt, tx_offload, &cd_qw0, &cd_qw1);
 
 		/* The number of descriptors that must be allocated for
 		 * a packet. For TSO packets, use ci_calc_pkt_desc as
@@ -1431,9 +1430,7 @@ idpf_dp_singleq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 
 		if (nb_ctx != 0) {
 			/* Setup TX context descriptor if required */
-			volatile union idpf_flex_tx_ctx_desc *ctx_txd =
-				(volatile union idpf_flex_tx_ctx_desc *)
-				&txr[tx_id];
+			uint64_t *ctx_txd = RTE_CAST_PTR(uint64_t *, &txr[tx_id]);
 
 			txn = &sw_ring[txe->next_id];
 			RTE_MBUF_PREFETCH_TO_FREE(txn->mbuf);
@@ -1442,10 +1439,8 @@ idpf_dp_singleq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 				txe->mbuf = NULL;
 			}
 
-			/* TSO enabled */
-			if ((ol_flags & RTE_MBUF_F_TX_TCP_SEG) != 0)
-				idpf_set_splitq_tso_ctx(tx_pkt, tx_offload,
-							ctx_txd);
+			ctx_txd[0] = cd_qw0;
+			ctx_txd[1] = cd_qw1;
 
 			txe->last_id = tx_last;
 			tx_id = txe->next_id;
Signature · 1 line
2.51.0
Acked-by on v4 8/35
#157 lore raw

Re: [PATCH v4 08/35] net/idpf: refactor context descriptor handling

Quoted 119 lines · Bruce Richardson

Move all context descriptor handling to a single function, as with the ice and i40e drivers.

---
  drivers/net/intel/idpf/idpf_common_rxtx.c | 61 +++++++++++------------
  1 file changed, 28 insertions(+), 33 deletions(-)
drivers/net/intel/idpf/idpf_common_rxtx.c +26 -29
index 11d6848430..9219ad9047 100644
@@ -845,37 +845,36 @@ idpf_calc_context_desc(uint64_t flags)
  	return 0;
  }
 
-/* set TSO context descriptor
+/* set TSO context descriptor, returns 0 if no context needed, 1 if context set
   */
-static inline void
-idpf_set_splitq_tso_ctx(struct rte_mbuf *mbuf,
+static inline uint16_t
+idpf_set_tso_ctx(uint64_t ol_flags, struct rte_mbuf *mbuf,
  			union ci_tx_offload tx_offload,
-			volatile union idpf_flex_tx_ctx_desc *ctx_desc)
+			uint64_t *qw0, uint64_t *qw1)
  {
-	uint16_t cmd_dtype;
+	uint16_t cmd_dtype = IDPF_TX_DESC_DTYPE_FLEX_TSO_CTX | IDPF_TX_FLEX_CTX_DESC_CMD_TSO;
+	uint16_t tso_segsz = mbuf->tso_segsz;
  	uint32_t tso_len;
  	uint8_t hdr_len;
 
+	if (idpf_calc_context_desc(ol_flags) == 0)
+		return 0;
+
+	/* TSO context descriptor setup */
  	if (tx_offload.l4_len == 0) {
  		TX_LOG(DEBUG, "L4 length set to 0");
-		return;
+		return 0;
  	}
 
-	hdr_len = tx_offload.l2_len +
-		tx_offload.l3_len +
-		tx_offload.l4_len;
-	cmd_dtype = IDPF_TX_DESC_DTYPE_FLEX_TSO_CTX |
-		IDPF_TX_FLEX_CTX_DESC_CMD_TSO;
+	hdr_len = tx_offload.l2_len + tx_offload.l3_len + tx_offload.l4_len;
  	tso_len = mbuf->pkt_len - hdr_len;
 
-	ctx_desc->tso.qw1.cmd_dtype = rte_cpu_to_le_16(cmd_dtype);
-	ctx_desc->tso.qw0.hdr_len = hdr_len;
-	ctx_desc->tso.qw0.mss_rt =
-		rte_cpu_to_le_16((uint16_t)mbuf->tso_segsz &
-				 IDPF_TXD_FLEX_CTX_MSS_RT_M);
-	ctx_desc->tso.qw0.flex_tlen =
-		rte_cpu_to_le_32(tso_len &
-				 IDPF_TXD_FLEX_CTX_MSS_RT_M);
+	*qw0 = rte_cpu_to_le_32(tso_len & IDPF_TXD_FLEX_CTX_MSS_RT_M) |
+	       ((uint64_t)rte_cpu_to_le_16(tso_segsz & IDPF_TXD_FLEX_CTX_MSS_RT_M) << 32) |
+	       ((uint64_t)hdr_len << 48);
+	*qw1 = rte_cpu_to_le_16(cmd_dtype);
+
+	return 1;
  }
 
  RTE_EXPORT_INTERNAL_SYMBOL(idpf_dp_splitq_xmit_pkts)
@@ -933,7 +932,8 @@ idpf_dp_splitq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
  		tx_offload.l4_len = tx_pkt->l4_len;
  		tx_offload.tso_segsz = tx_pkt->tso_segsz;
  		/* Calculate the number of context descriptors needed. */
-		nb_ctx = idpf_calc_context_desc(ol_flags);
+		uint64_t cd_qw0, cd_qw1;
+		nb_ctx = idpf_set_tso_ctx(ol_flags, tx_pkt, tx_offload, &cd_qw0, &cd_qw1);
 
  		/* Calculate the number of TX descriptors needed for
  		 * each packet. For TSO packets, use ci_calc_pkt_desc as
@@ -950,12 +950,10 @@ idpf_dp_splitq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 
  		/* context descriptor */
  		if (nb_ctx != 0) {
-			volatile union idpf_flex_tx_ctx_desc *ctx_desc =
-				(volatile union idpf_flex_tx_ctx_desc *)&txr[tx_id];
+			uint64_t *ctx_desc = RTE_CAST_PTR(uint64_t *, &txr[tx_id]);
 
-			if ((ol_flags & RTE_MBUF_F_TX_TCP_SEG) != 0)
-				idpf_set_splitq_tso_ctx(tx_pkt, tx_offload,
-							ctx_desc);
+			ctx_desc[0] = cd_qw0;
+			ctx_desc[1] = cd_qw1;
 
  			tx_id++;
  			if (tx_id == txq->nb_tx_desc)
@@ -1388,7 +1386,8 @@ idpf_dp_singleq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
  		tx_offload.l4_len = tx_pkt->l4_len;
  		tx_offload.tso_segsz = tx_pkt->tso_segsz;
  		/* Calculate the number of context descriptors needed. */
-		nb_ctx = idpf_calc_context_desc(ol_flags);
+		uint64_t cd_qw0, cd_qw1;
+		nb_ctx = idpf_set_tso_ctx(ol_flags, tx_pkt, tx_offload, &cd_qw0, &cd_qw1);
 
  		/* The number of descriptors that must be allocated for
  		 * a packet. For TSO packets, use ci_calc_pkt_desc as
@@ -1431,9 +1430,7 @@ idpf_dp_singleq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 
  		if (nb_ctx != 0) {
  			/* Setup TX context descriptor if required */
-			volatile union idpf_flex_tx_ctx_desc *ctx_txd =
-				(volatile union idpf_flex_tx_ctx_desc *)
-				&txr[tx_id];
+			uint64_t *ctx_txd = RTE_CAST_PTR(uint64_t *, &txr[tx_id]);
 
  			txn = &sw_ring[txe->next_id];
  			RTE_MBUF_PREFETCH_TO_FREE(txn->mbuf);
@@ -1442,10 +1439,8 @@ idpf_dp_singleq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
  				txe->mbuf = NULL;
  			}

drivers/net/intel/idpf/idpf_common_rxtx.c idpf_dp_singleq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, · line 1446

Quoted 10 lines
drivers/net/intel/idpf/idpf_common_rxtx.c +2 -4
 
-			/* TSO enabled */
-			if ((ol_flags & RTE_MBUF_F_TX_TCP_SEG) != 0)
-				idpf_set_splitq_tso_ctx(tx_pkt, tx_offload,
-							ctx_txd);
+			ctx_txd[0] = cd_qw0;
+			ctx_txd[1] = cd_qw1;
 
  			txe->last_id = tx_last;
  			tx_id = txe->next_id;

Yay type safety! :D Gotta love C

Signature · 2 lines
Thanks,
Anatoly
#158 lore raw

PATCH v4 9/35 net/intel: consolidate checksum mask definition

In reply to Bruce Richardson

Create a common definition for checksum masks across iavf, idpf, i40e and ice drivers.

---
 drivers/net/intel/common/tx.h             | 8 ++++++++
 drivers/net/intel/i40e/i40e_rxtx.c        | 7 +------
 drivers/net/intel/iavf/iavf_rxtx.c        | 2 +-
 drivers/net/intel/iavf/iavf_rxtx.h        | 8 --------
 drivers/net/intel/ice/ice_rxtx.c          | 8 +-------
 drivers/net/intel/idpf/idpf_common_rxtx.c | 4 ++--
 drivers/net/intel/idpf/idpf_common_rxtx.h | 7 +------
 7 files changed, 14 insertions(+), 30 deletions(-)
drivers/net/intel/common/tx.h +8 -0
index 091f220f1c..23deabc5d1 100644
@@ -53,6 +53,14 @@
 /* Common maximum data per TX descriptor */
 #define CI_MAX_DATA_PER_TXD     (CI_TXD_QW1_TX_BUF_SZ_M >> CI_TXD_QW1_TX_BUF_SZ_S)
 
+/* Checksum offload mask to identify packets requesting offload */
+#define CI_TX_CKSUM_OFFLOAD_MASK (RTE_MBUF_F_TX_IP_CKSUM |		 \
+				   RTE_MBUF_F_TX_L4_MASK |		 \
+				   RTE_MBUF_F_TX_TCP_SEG |		 \
+				   RTE_MBUF_F_TX_UDP_SEG |		 \
+				   RTE_MBUF_F_TX_OUTER_IP_CKSUM |	 \
+				   RTE_MBUF_F_TX_OUTER_UDP_CKSUM)
+
 /**
  * Common TX offload union for Intel drivers.
  * Supports both basic offloads (l2_len, l3_len, l4_len, tso_segsz) and
drivers/net/intel/i40e/i40e_rxtx.c +1 -6
index 601d4b98f2..12a21407c5 100644
@@ -53,11 +53,6 @@
 #define I40E_TX_IEEE1588_TMST 0
 #endif
 
-#define I40E_TX_CKSUM_OFFLOAD_MASK (RTE_MBUF_F_TX_IP_CKSUM |		 \
-		RTE_MBUF_F_TX_L4_MASK |		 \
-		RTE_MBUF_F_TX_TCP_SEG |		 \
-		RTE_MBUF_F_TX_OUTER_IP_CKSUM)
-
 #define I40E_TX_OFFLOAD_MASK (RTE_MBUF_F_TX_OUTER_IPV4 |	\
 		RTE_MBUF_F_TX_OUTER_IPV6 |	\
 		RTE_MBUF_F_TX_IPV4 |		\
@@ -1171,7 +1166,7 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 		td_cmd |= CI_TX_DESC_CMD_ICRC;
 
 		/* Enable checksum offloading */
-		if (ol_flags & I40E_TX_CKSUM_OFFLOAD_MASK)
+		if (ol_flags & CI_TX_CKSUM_OFFLOAD_MASK)
 			i40e_txd_enable_checksum(ol_flags, &td_cmd,
 						 &td_offset, tx_offload);
 
drivers/net/intel/iavf/iavf_rxtx.c +1 -1
index 885d9309cc..3dbcfd5355 100644
@@ -2596,7 +2596,7 @@ iavf_build_data_desc_cmd_offset_fields(volatile uint64_t *qw1,
 	}
 
 	if ((m->ol_flags &
-	    (IAVF_TX_CKSUM_OFFLOAD_MASK | RTE_MBUF_F_TX_SEC_OFFLOAD)) == 0)
+	    (CI_TX_CKSUM_OFFLOAD_MASK | RTE_MBUF_F_TX_SEC_OFFLOAD)) == 0)
 		goto skip_cksum;
 
 	/* Set MACLEN */
drivers/net/intel/iavf/iavf_rxtx.h +0 -8
index 395d97b4ee..cca5c25119 100644
@@ -136,14 +136,6 @@
 
 #define IAVF_TX_MIN_PKT_LEN 17
 
-#define IAVF_TX_CKSUM_OFFLOAD_MASK (		 \
-		RTE_MBUF_F_TX_IP_CKSUM |		 \
-		RTE_MBUF_F_TX_L4_MASK |		 \
-		RTE_MBUF_F_TX_TCP_SEG |          \
-		RTE_MBUF_F_TX_UDP_SEG |          \
-		RTE_MBUF_F_TX_OUTER_IP_CKSUM |   \
-		RTE_MBUF_F_TX_OUTER_UDP_CKSUM)
-
 #define IAVF_TX_OFFLOAD_MASK (  \
 		RTE_MBUF_F_TX_OUTER_IPV6 |		 \
 		RTE_MBUF_F_TX_OUTER_IPV4 |		 \
drivers/net/intel/ice/ice_rxtx.c +1 -7
index 1c789d45da..63bce7bd9e 100644
@@ -13,12 +13,6 @@
 #include "../common/rx_vec_x86.h"
 #endif
 
-#define ICE_TX_CKSUM_OFFLOAD_MASK (RTE_MBUF_F_TX_IP_CKSUM |		 \
-		RTE_MBUF_F_TX_L4_MASK |		 \
-		RTE_MBUF_F_TX_TCP_SEG |		 \
-		RTE_MBUF_F_TX_UDP_SEG |		 \
-		RTE_MBUF_F_TX_OUTER_IP_CKSUM)
-
 /**
  * The mbuf dynamic field pointer for protocol extraction metadata.
  */
@@ -3214,7 +3208,7 @@ ice_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 		}
 
 		/* Enable checksum offloading */
-		if (ol_flags & ICE_TX_CKSUM_OFFLOAD_MASK)
+		if (ol_flags & CI_TX_CKSUM_OFFLOAD_MASK)
 			ice_txd_enable_checksum(ol_flags, &td_cmd,
 						&td_offset, tx_offload);
 
drivers/net/intel/idpf/idpf_common_rxtx.c +2 -2
index 9219ad9047..b34d545a0a 100644
@@ -945,7 +945,7 @@ idpf_dp_splitq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 		else
 			nb_used = tx_pkt->nb_segs + nb_ctx;
 
-		if (ol_flags & IDPF_TX_CKSUM_OFFLOAD_MASK)
+		if (ol_flags & CI_TX_CKSUM_OFFLOAD_MASK)
 			cmd_dtype = IDPF_TXD_FLEX_FLOW_CMD_CS_EN;
 
 		/* context descriptor */
@@ -1425,7 +1425,7 @@ idpf_dp_singleq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 			}
 		}
 
-		if (ol_flags & IDPF_TX_CKSUM_OFFLOAD_MASK)
+		if (ol_flags & CI_TX_CKSUM_OFFLOAD_MASK)
 			td_cmd |= IDPF_TX_FLEX_DESC_CMD_CS_EN;
 
 		if (nb_ctx != 0) {
drivers/net/intel/idpf/idpf_common_rxtx.h +1 -6
index b88a87402d..fe7094d434 100644
@@ -39,13 +39,8 @@
 #define IDPF_RLAN_CTX_DBUF_S	7
 #define IDPF_RX_MAX_DATA_BUF_SIZE	(16 * 1024 - 128)
 
-#define IDPF_TX_CKSUM_OFFLOAD_MASK (		\
-		RTE_MBUF_F_TX_IP_CKSUM |	\
-		RTE_MBUF_F_TX_L4_MASK |		\
-		RTE_MBUF_F_TX_TCP_SEG)
-
 #define IDPF_TX_OFFLOAD_MASK (			\
-		IDPF_TX_CKSUM_OFFLOAD_MASK |	\
+		CI_TX_CKSUM_OFFLOAD_MASK |	\
 		RTE_MBUF_F_TX_IPV4 |		\
 		RTE_MBUF_F_TX_IPV6)
 
Signature · 1 line
2.51.0
#160 lore raw

PATCH v4 10/35 net/intel: create common checksum Tx offload function

In reply to Bruce Richardson

Since i40e and ice have the same checksum offload logic, merge their functions into one. Future rework should enable this to be used by more drivers also.

---
 drivers/net/intel/common/tx_scalar.h | 58 +++++++++++++++++++++++++++
 drivers/net/intel/i40e/i40e_rxtx.c   | 52 +-----------------------
 drivers/net/intel/i40e/i40e_rxtx.h   |  1 +
 drivers/net/intel/ice/ice_rxtx.c     | 60 +---------------------------
 drivers/net/intel/ice/ice_rxtx.h     |  1 +
 5 files changed, 62 insertions(+), 110 deletions(-)
drivers/net/intel/common/tx_scalar.h +58 -0
index 573f5136a9..cf0dcb4b2c 100644
@@ -59,6 +59,64 @@ ci_tx_xmit_cleanup(struct ci_tx_queue *txq)
 	return 0;
 }
 
+/* Common checksum enable function for Intel drivers (ice, i40e, etc.) */
+static inline void
+ci_txd_enable_checksum(uint64_t ol_flags,
+		       uint32_t *td_cmd,
+		       uint32_t *td_offset,
+		       union ci_tx_offload tx_offload)
+{
+	/* Enable L3 checksum offloads */
+	if (ol_flags & RTE_MBUF_F_TX_IP_CKSUM) {
+		*td_cmd |= CI_TX_DESC_CMD_IIPT_IPV4_CSUM;
+		*td_offset |= (tx_offload.l3_len >> 2) <<
+			CI_TX_DESC_LEN_IPLEN_S;
+	} else if (ol_flags & RTE_MBUF_F_TX_IPV4) {
+		*td_cmd |= CI_TX_DESC_CMD_IIPT_IPV4;
+		*td_offset |= (tx_offload.l3_len >> 2) <<
+			CI_TX_DESC_LEN_IPLEN_S;
+	} else if (ol_flags & RTE_MBUF_F_TX_IPV6) {
+		*td_cmd |= CI_TX_DESC_CMD_IIPT_IPV6;
+		*td_offset |= (tx_offload.l3_len >> 2) <<
+			CI_TX_DESC_LEN_IPLEN_S;
+	}
+
+	if (ol_flags & RTE_MBUF_F_TX_TCP_SEG) {
+		*td_cmd |= CI_TX_DESC_CMD_L4T_EOFT_TCP;
+		*td_offset |= (tx_offload.l4_len >> 2) <<
+			      CI_TX_DESC_LEN_L4_LEN_S;
+		return;
+	}
+
+	if (ol_flags & RTE_MBUF_F_TX_UDP_SEG) {
+		*td_cmd |= CI_TX_DESC_CMD_L4T_EOFT_UDP;
+		*td_offset |= (tx_offload.l4_len >> 2) <<
+			      CI_TX_DESC_LEN_L4_LEN_S;
+		return;
+	}
+
+	/* Enable L4 checksum offloads */
+	switch (ol_flags & RTE_MBUF_F_TX_L4_MASK) {
+	case RTE_MBUF_F_TX_TCP_CKSUM:
+		*td_cmd |= CI_TX_DESC_CMD_L4T_EOFT_TCP;
+		*td_offset |= (sizeof(struct rte_tcp_hdr) >> 2) <<
+			      CI_TX_DESC_LEN_L4_LEN_S;
+		break;
+	case RTE_MBUF_F_TX_SCTP_CKSUM:
+		*td_cmd |= CI_TX_DESC_CMD_L4T_EOFT_SCTP;
+		*td_offset |= (sizeof(struct rte_sctp_hdr) >> 2) <<
+			      CI_TX_DESC_LEN_L4_LEN_S;
+		break;
+	case RTE_MBUF_F_TX_UDP_CKSUM:
+		*td_cmd |= CI_TX_DESC_CMD_L4T_EOFT_UDP;
+		*td_offset |= (sizeof(struct rte_udp_hdr) >> 2) <<
+			      CI_TX_DESC_LEN_L4_LEN_S;
+		break;
+	default:
+		break;
+	}
+}
+
 static inline uint16_t
 ci_div_roundup16(uint16_t x, uint16_t y)
 {
drivers/net/intel/i40e/i40e_rxtx.c +1 -51

64 lines not on this page · raw message

drivers/net/intel/i40e/i40e_rxtx.h +1 -0
index 307ffa3049..db8525d52d 100644
@@ -100,6 +100,7 @@ enum i40e_header_split_mode {
 		RTE_ETH_TX_OFFLOAD_SCTP_CKSUM |		\
 		RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM |	\
 		RTE_ETH_TX_OFFLOAD_TCP_TSO |		\
+		RTE_ETH_TX_OFFLOAD_UDP_TSO |		\
 		RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO |	\
 		RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO |	\
 		RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO |	\
drivers/net/intel/ice/ice_rxtx.c +1 -59

72 lines not on this page · raw message

drivers/net/intel/ice/ice_rxtx.h +1 -0
index cd5fa93d1c..7d6480b410 100644
@@ -112,6 +112,7 @@
 #define ICE_TX_SCALAR_OFFLOADS (		\
 	RTE_ETH_TX_OFFLOAD_VLAN_INSERT |	\
 	RTE_ETH_TX_OFFLOAD_TCP_TSO |		\
+	RTE_ETH_TX_OFFLOAD_UDP_TSO |		\
 	RTE_ETH_TX_OFFLOAD_MULTI_SEGS |		\
 	RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE |	\
 	RTE_ETH_TX_OFFLOAD_QINQ_INSERT |	\
Signature · 1 line
2.51.0
Acked-by on v4 10/35
#161 lore raw

Re: [PATCH v4 10/35] net/intel: create common checksum Tx offload function

Quoted 67 lines · Bruce Richardson

Since i40e and ice have the same checksum offload logic, merge their functions into one. Future rework should enable this to be used by more drivers also.

---
  drivers/net/intel/common/tx_scalar.h | 58 +++++++++++++++++++++++++++
  drivers/net/intel/i40e/i40e_rxtx.c   | 52 +-----------------------
  drivers/net/intel/i40e/i40e_rxtx.h   |  1 +
  drivers/net/intel/ice/ice_rxtx.c     | 60 +---------------------------
  drivers/net/intel/ice/ice_rxtx.h     |  1 +
  5 files changed, 62 insertions(+), 110 deletions(-)
drivers/net/intel/common/tx_scalar.h +46 -0
index 573f5136a9..cf0dcb4b2c 100644
@@ -59,6 +59,64 @@ ci_tx_xmit_cleanup(struct ci_tx_queue *txq)
  	return 0;
  }
 
+/* Common checksum enable function for Intel drivers (ice, i40e, etc.) */
+static inline void
+ci_txd_enable_checksum(uint64_t ol_flags,
+		       uint32_t *td_cmd,
+		       uint32_t *td_offset,
+		       union ci_tx_offload tx_offload)
+{
+	/* Enable L3 checksum offloads */
+	if (ol_flags & RTE_MBUF_F_TX_IP_CKSUM) {
+		*td_cmd |= CI_TX_DESC_CMD_IIPT_IPV4_CSUM;
+		*td_offset |= (tx_offload.l3_len >> 2) <<
+			CI_TX_DESC_LEN_IPLEN_S;
+	} else if (ol_flags & RTE_MBUF_F_TX_IPV4) {
+		*td_cmd |= CI_TX_DESC_CMD_IIPT_IPV4;
+		*td_offset |= (tx_offload.l3_len >> 2) <<
+			CI_TX_DESC_LEN_IPLEN_S;
+	} else if (ol_flags & RTE_MBUF_F_TX_IPV6) {
+		*td_cmd |= CI_TX_DESC_CMD_IIPT_IPV6;
+		*td_offset |= (tx_offload.l3_len >> 2) <<
+			CI_TX_DESC_LEN_IPLEN_S;
+	}
+
+	if (ol_flags & RTE_MBUF_F_TX_TCP_SEG) {
+		*td_cmd |= CI_TX_DESC_CMD_L4T_EOFT_TCP;
+		*td_offset |= (tx_offload.l4_len >> 2) <<
+			      CI_TX_DESC_LEN_L4_LEN_S;
+		return;
+	}
+
+	if (ol_flags & RTE_MBUF_F_TX_UDP_SEG) {
+		*td_cmd |= CI_TX_DESC_CMD_L4T_EOFT_UDP;
+		*td_offset |= (tx_offload.l4_len >> 2) <<
+			      CI_TX_DESC_LEN_L4_LEN_S;
+		return;
+	}
+
+	/* Enable L4 checksum offloads */
+	switch (ol_flags & RTE_MBUF_F_TX_L4_MASK) {
+	case RTE_MBUF_F_TX_TCP_CKSUM:
+		*td_cmd |= CI_TX_DESC_CMD_L4T_EOFT_TCP;
+		*td_offset |= (sizeof(struct rte_tcp_hdr) >> 2) <<
+			      CI_TX_DESC_LEN_L4_LEN_S;
+		break;
+	case RTE_MBUF_F_TX_SCTP_CKSUM:
+		*td_cmd |= CI_TX_DESC_CMD_L4T_EOFT_SCTP;
+		*td_offset |= (sizeof(struct rte_sctp_hdr) >> 2) <<

drivers/net/intel/common/tx_scalar.h ci_tx_xmit_cleanup(struct ci_tx_queue *txq) · line 117

Quoted 10 lines
drivers/net/intel/common/tx_scalar.h +10 -0
+			      CI_TX_DESC_LEN_L4_LEN_S;
+		break;
+	case RTE_MBUF_F_TX_UDP_CKSUM:
+		*td_cmd |= CI_TX_DESC_CMD_L4T_EOFT_UDP;
+		*td_offset |= (sizeof(struct rte_udp_hdr) >> 2) <<
+			      CI_TX_DESC_LEN_L4_LEN_S;
+		break;
+	default:
+		break;
+	}

Nitpick: some of the indentation here is inconststent. Perhaps enabling whitespace view in your editor would help, if you haven't done so?

(the inconsistency was already present in the ice function but that doesn't mean we have to copy it!)

Otherwise,

Signature · 2 lines
Thanks,
Anatoly
#162 lore raw

Re: [PATCH v4 10/35] net/intel: create common checksum Tx offload function

Quoted 58 lines · Anatoly
Quoted 45 lines · Bruce Richardson

Since i40e and ice have the same checksum offload logic, merge their functions into one. Future rework should enable this to be used by more drivers also.

drivers/net/intel/common/tx_scalar.h | 58 +++++++++++++++++++++++++++
drivers/net/intel/i40e/i40e_rxtx.c   | 52 +-----------------------
drivers/net/intel/i40e/i40e_rxtx.h   |  1 +
drivers/net/intel/ice/ice_rxtx.c     | 60 +---------------------------
drivers/net/intel/ice/ice_rxtx.h     |  1 + 5 files changed, 62

insertions(+), 110 deletions(-)

(quoted diff) +0 -0

b/drivers/net/intel/common/tx_scalar.h index 573f5136a9..cf0dcb4b2c 100644 --- a/drivers/net/intel/common/tx_scalar.h +++ b/drivers/net/intel/common/tx_scalar.h @@ -59,6 +59,64 @@ ci_tx_xmit_cleanup(struct ci_tx_queue *txq) return 0; } +/* Common checksum enable function for Intel drivers (ice, i40e, etc.) */ +static inline void +ci_txd_enable_checksum(uint64_t ol_flags, +
uint32_t *td_cmd, + uint32_t *td_offset, +
union ci_tx_offload tx_offload) +{ + /* Enable L3 checksum
offloads */ + if (ol_flags & RTE_MBUF_F_TX_IP_CKSUM) { +
*td_cmd |= CI_TX_DESC_CMD_IIPT_IPV4_CSUM; + *td_offset |=
(tx_offload.l3_len >> 2) << +
CI_TX_DESC_LEN_IPLEN_S; + } else if (ol_flags & RTE_MBUF_F_TX_IPV4) {

(quoted diff) +1 -0
+		*td_cmd |= CI_TX_DESC_CMD_IIPT_IPV4; +		*td_offset

|= (tx_offload.l3_len >> 2) << +
CI_TX_DESC_LEN_IPLEN_S; + } else if (ol_flags & RTE_MBUF_F_TX_IPV6) {

(quoted diff) +1 -0
+		*td_cmd |= CI_TX_DESC_CMD_IIPT_IPV6; +		*td_offset

|= (tx_offload.l3_len >> 2) << +
CI_TX_DESC_LEN_IPLEN_S; + } + + if (ol_flags &
RTE_MBUF_F_TX_TCP_SEG) { + *td_cmd |=
CI_TX_DESC_CMD_L4T_EOFT_TCP; + *td_offset |=
(tx_offload.l4_len >> 2) << +
CI_TX_DESC_LEN_L4_LEN_S; + return; + } + + if
(ol_flags & RTE_MBUF_F_TX_UDP_SEG) { + *td_cmd |=
CI_TX_DESC_CMD_L4T_EOFT_UDP; + *td_offset |=
(tx_offload.l4_len >> 2) << +
CI_TX_DESC_LEN_L4_LEN_S; + return; + } + + /* Enable
L4 checksum offloads */ + switch (ol_flags & RTE_MBUF_F_TX_L4_MASK) {

(quoted diff) +1 -0
+	case RTE_MBUF_F_TX_TCP_CKSUM: +		*td_cmd |=

CI_TX_DESC_CMD_L4T_EOFT_TCP; + *td_offset |=
(sizeof(struct rte_tcp_hdr) >> 2) << +
CI_TX_DESC_LEN_L4_LEN_S; + break; + case
RTE_MBUF_F_TX_SCTP_CKSUM: + *td_cmd |=

Quoted 8 lines

CI_TX_DESC_CMD_L4T_EOFT_SCTP; + *td_offset |=
(sizeof(struct rte_sctp_hdr) >> 2) << +
CI_TX_DESC_LEN_L4_LEN_S; + break; + case
RTE_MBUF_F_TX_UDP_CKSUM: + *td_cmd |=
CI_TX_DESC_CMD_L4T_EOFT_UDP; + *td_offset |=
(sizeof(struct rte_udp_hdr) >> 2) << +
CI_TX_DESC_LEN_L4_LEN_S; + break; + default: +
break; + }

Nitpick: some of the indentation here is inconststent. Perhaps enabling whitespace view in your editor would help, if you haven't done so?

Quoted 3 lines

(the inconsistency was already present in the ice function but that doesn't mean we have to copy it!)

Yep, I suspect the indentation was meant to align with opening braces but that of course gets messed up when renaming things in refactoring (or in this case adding in an extra "*" dereference char). Will clean this up in v5.

/Bruce

#163 lore raw

PATCH v4 11/35 net/intel: create a common scalar Tx function

In reply to Bruce Richardson

Given the similarities between the transmit functions across various Intel drivers, make a start on consolidating them by moving the ice Tx function into common, for reuse by other drivers.

---
 drivers/net/intel/common/tx_scalar.h | 218 +++++++++++++++++++++
 drivers/net/intel/ice/ice_rxtx.c     | 270 ++++++---------------------
 2 files changed, 270 insertions(+), 218 deletions(-)
drivers/net/intel/common/tx_scalar.h +218 -0
index cf0dcb4b2c..4d041fac99 100644
@@ -6,6 +6,7 @@
 #define _COMMON_INTEL_TX_SCALAR_H_
 
 #include <stdint.h>
+#include <rte_io.h>
 #include <rte_byteorder.h>
 
 /* depends on common Tx definitions. */
@@ -137,5 +138,222 @@ ci_calc_pkt_desc(const struct rte_mbuf *tx_pkt)
 	return count;
 }
 
+typedef uint16_t (*ci_get_ctx_desc_fn)(uint64_t ol_flags, const struct rte_mbuf *mbuf,
+		const union ci_tx_offload *tx_offload, const struct ci_tx_queue *txq,
+		uint64_t *qw0, uint64_t *qw1);
+
+/* gets current timestamp tail index */
+typedef uint16_t (*get_ts_tail_t)(struct ci_tx_queue *txq);
+/* writes a timestamp descriptor and returns new tail index */
+typedef uint16_t (*write_ts_desc_t)(struct ci_tx_queue *txq, struct rte_mbuf *mbuf,
+		uint16_t tx_id, uint16_t ts_id);
+/* writes a timestamp tail index - doorbell */
+typedef void (*write_ts_tail_t)(struct ci_tx_queue *txq, uint16_t ts_id);
+
+struct ci_timestamp_queue_fns {
+	get_ts_tail_t get_ts_tail;
+	write_ts_desc_t write_ts_desc;
+	write_ts_tail_t write_ts_tail;
+};
+
+static inline uint16_t
+ci_xmit_pkts(struct ci_tx_queue *txq,
+	     struct rte_mbuf **tx_pkts,
+	     uint16_t nb_pkts,
+	     ci_get_ctx_desc_fn get_ctx_desc,
+	     const struct ci_timestamp_queue_fns *ts_fns)
+{
+	volatile struct ci_tx_desc *ci_tx_ring;
+	volatile struct ci_tx_desc *txd;
+	struct ci_tx_entry *sw_ring;
+	struct ci_tx_entry *txe, *txn;
+	struct rte_mbuf *tx_pkt;
+	struct rte_mbuf *m_seg;
+	uint16_t tx_id;
+	uint16_t ts_id = -1;
+	uint16_t nb_tx;
+	uint16_t nb_used;
+	uint16_t nb_ctx;
+	uint32_t td_cmd = 0;
+	uint32_t td_offset = 0;
+	uint32_t td_tag = 0;
+	uint16_t tx_last;
+	uint16_t slen;
+	uint16_t l2_len;
+	uint64_t buf_dma_addr;
+	uint64_t ol_flags;
+	union ci_tx_offload tx_offload = {0};
+
+	sw_ring = txq->sw_ring;
+	ci_tx_ring = txq->ci_tx_ring;
+	tx_id = txq->tx_tail;
+	txe = &sw_ring[tx_id];
+
+	if (ts_fns != NULL)
+		ts_id = ts_fns->get_ts_tail(txq);
+
+	/* Check if the descriptor ring needs to be cleaned. */
+	if (txq->nb_tx_free < txq->tx_free_thresh)
+		(void)ci_tx_xmit_cleanup(txq);
+
+	for (nb_tx = 0; nb_tx < nb_pkts; nb_tx++) {
+		uint64_t cd_qw0, cd_qw1;
+		tx_pkt = *tx_pkts++;
+
+		ol_flags = tx_pkt->ol_flags;
+		td_cmd = CI_TX_DESC_CMD_ICRC;
+		td_tag = 0;
+		l2_len = ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK ?
+				tx_pkt->outer_l2_len : tx_pkt->l2_len;
+		td_offset = (l2_len >> 1) << CI_TX_DESC_LEN_MACLEN_S;
+
+
+		tx_offload.l2_len = tx_pkt->l2_len;
+		tx_offload.l3_len = tx_pkt->l3_len;
+		tx_offload.outer_l2_len = tx_pkt->outer_l2_len;
+		tx_offload.outer_l3_len = tx_pkt->outer_l3_len;
+		tx_offload.l4_len = tx_pkt->l4_len;
+		tx_offload.tso_segsz = tx_pkt->tso_segsz;
+
+		/* Calculate the number of context descriptors needed. */
+		nb_ctx = get_ctx_desc(ol_flags, tx_pkt, &tx_offload, txq, &cd_qw0, &cd_qw1);
+
+		/* The number of descriptors that must be allocated for
+		 * a packet equals to the number of the segments of that
+		 * packet plus the number of context descriptor if needed.
+		 * Recalculate the needed tx descs when TSO enabled in case
+		 * the mbuf data size exceeds max data size that hw allows
+		 * per tx desc.
+		 */
+		if (ol_flags & (RTE_MBUF_F_TX_TCP_SEG | RTE_MBUF_F_TX_UDP_SEG))
+			nb_used = (uint16_t)(ci_calc_pkt_desc(tx_pkt) + nb_ctx);
+		else
+			nb_used = (uint16_t)(tx_pkt->nb_segs + nb_ctx);
+		tx_last = (uint16_t)(tx_id + nb_used - 1);
+
+		/* Circular ring */
+		if (tx_last >= txq->nb_tx_desc)
+			tx_last = (uint16_t)(tx_last - txq->nb_tx_desc);
+
+		if (nb_used > txq->nb_tx_free) {
+			if (ci_tx_xmit_cleanup(txq) != 0) {
+				if (nb_tx == 0)
+					return 0;
+				goto end_of_tx;
+			}
+			if (unlikely(nb_used > txq->tx_rs_thresh)) {
+				while (nb_used > txq->nb_tx_free) {
+					if (ci_tx_xmit_cleanup(txq) != 0) {
+						if (nb_tx == 0)
+							return 0;
+						goto end_of_tx;
+					}
+				}
+			}
+		}
+
+		/* Descriptor based VLAN insertion */
+		if (ol_flags & (RTE_MBUF_F_TX_VLAN | RTE_MBUF_F_TX_QINQ)) {
+			td_cmd |= CI_TX_DESC_CMD_IL2TAG1;
+			td_tag = tx_pkt->vlan_tci;
+		}
+
+		/* Enable checksum offloading */
+		if (ol_flags & CI_TX_CKSUM_OFFLOAD_MASK)
+			ci_txd_enable_checksum(ol_flags, &td_cmd,
+						&td_offset, tx_offload);
+
+		if (nb_ctx) {
+			/* Setup TX context descriptor if required */
+			uint64_t *ctx_txd = RTE_CAST_PTR(uint64_t *, &ci_tx_ring[tx_id]);
+
+			txn = &sw_ring[txe->next_id];
+			RTE_MBUF_PREFETCH_TO_FREE(txn->mbuf);
+			if (txe->mbuf) {
+				rte_pktmbuf_free_seg(txe->mbuf);
+				txe->mbuf = NULL;
+			}
+
+			ctx_txd[0] = cd_qw0;
+			ctx_txd[1] = cd_qw1;
+
+			txe->last_id = tx_last;
+			tx_id = txe->next_id;
+			txe = txn;
+		}
+		m_seg = tx_pkt;
+
+		do {
+			txd = &ci_tx_ring[tx_id];
+			txn = &sw_ring[txe->next_id];
+
+			if (txe->mbuf)
+				rte_pktmbuf_free_seg(txe->mbuf);
+			txe->mbuf = m_seg;
+
+			/* Setup TX Descriptor */
+			slen = m_seg->data_len;
+			buf_dma_addr = rte_mbuf_data_iova(m_seg);
+
+			while ((ol_flags & (RTE_MBUF_F_TX_TCP_SEG | RTE_MBUF_F_TX_UDP_SEG)) &&
+					unlikely(slen > CI_MAX_DATA_PER_TXD)) {
+				txd->buffer_addr = rte_cpu_to_le_64(buf_dma_addr);
+				txd->cmd_type_offset_bsz = rte_cpu_to_le_64(CI_TX_DESC_DTYPE_DATA |
+					((uint64_t)td_cmd << CI_TXD_QW1_CMD_S) |
+					((uint64_t)td_offset << CI_TXD_QW1_OFFSET_S) |
+					((uint64_t)CI_MAX_DATA_PER_TXD << CI_TXD_QW1_TX_BUF_SZ_S) |
+					((uint64_t)td_tag << CI_TXD_QW1_L2TAG1_S));
+
+				buf_dma_addr += CI_MAX_DATA_PER_TXD;
+				slen -= CI_MAX_DATA_PER_TXD;
+
+				txe->last_id = tx_last;
+				tx_id = txe->next_id;
+				txe = txn;
+				txd = &ci_tx_ring[tx_id];
+				txn = &sw_ring[txe->next_id];
+			}
+
+			txd->buffer_addr = rte_cpu_to_le_64(buf_dma_addr);
+			txd->cmd_type_offset_bsz = rte_cpu_to_le_64(CI_TX_DESC_DTYPE_DATA |
+				((uint64_t)td_cmd << CI_TXD_QW1_CMD_S) |
+				((uint64_t)td_offset << CI_TXD_QW1_OFFSET_S) |
+				((uint64_t)slen << CI_TXD_QW1_TX_BUF_SZ_S) |
+				((uint64_t)td_tag << CI_TXD_QW1_L2TAG1_S));
+
+			txe->last_id = tx_last;
+			tx_id = txe->next_id;
+			txe = txn;
+			m_seg = m_seg->next;
+		} while (m_seg);
+
+		/* fill the last descriptor with End of Packet (EOP) bit */
+		td_cmd |= CI_TX_DESC_CMD_EOP;
+		txq->nb_tx_used = (uint16_t)(txq->nb_tx_used + nb_used);
+		txq->nb_tx_free = (uint16_t)(txq->nb_tx_free - nb_used);
+
+		/* set RS bit on the last descriptor of one packet */
+		if (txq->nb_tx_used >= txq->tx_rs_thresh) {
+			td_cmd |= CI_TX_DESC_CMD_RS;
+
+			/* Update txq RS bit counters */
+			txq->nb_tx_used = 0;
+		}
+		txd->cmd_type_offset_bsz |=
+				rte_cpu_to_le_64(((uint64_t)td_cmd) << CI_TXD_QW1_CMD_S);
+
+		if (ts_fns != NULL)
+			ts_id = ts_fns->write_ts_desc(txq, tx_pkt, tx_id, ts_id);
+	}
+end_of_tx:
+	/* update Tail register */
+	if (ts_fns != NULL)
+		ts_fns->write_ts_tail(txq, ts_id);
+	else
+		rte_write32_wc(tx_id, txq->qtx_tail);
+	txq->tx_tail = tx_id;
+
+	return nb_tx;
+}
 
 #endif /* _COMMON_INTEL_TX_SCALAR_H_ */
drivers/net/intel/ice/ice_rxtx.c +52 -218

282 lines not on this page · raw message

Signature · 1 line
2.51.0
Acked-by on v4 11/35
#164 lore raw

Re: [PATCH v4 11/35] net/intel: create a common scalar Tx function

drivers/net/intel/common/tx_scalar.h ci_calc_pkt_desc(const struct rte_mbuf *tx_pkt) · line 197

Quoted 13 lines · Bruce Richardson

Given the similarities between the transmit functions across various Intel drivers, make a start on consolidating them by moving the ice Tx function into common, for reuse by other drivers.

---

drivers/net/intel/common/tx_scalar.h +6 -0
+	if (ts_fns != NULL)
+		ts_id = ts_fns->get_ts_tail(txq);
+
+	/* Check if the descriptor ring needs to be cleaned. */
+	if (txq->nb_tx_free < txq->tx_free_thresh)
+		(void)ci_tx_xmit_cleanup(txq);

Why (void) ?

<snip>

drivers/net/intel/common/tx_scalar.h ci_calc_pkt_desc(const struct rte_mbuf *tx_pkt) · line 234

Quoted 7 lines
drivers/net/intel/common/tx_scalar.h +7 -0
+		if (ol_flags & (RTE_MBUF_F_TX_TCP_SEG | RTE_MBUF_F_TX_UDP_SEG))
+			nb_used = (uint16_t)(ci_calc_pkt_desc(tx_pkt) + nb_ctx);
+		else
+			nb_used = (uint16_t)(tx_pkt->nb_segs + nb_ctx);
+		tx_last = (uint16_t)(tx_id + nb_used - 1);
+
+		/* Circular ring */

nicholas_cage_you_dont_say.jpg

Signature · 2 lines
Thanks,
Anatoly
#165 lore raw

Re: [PATCH v4 11/35] net/intel: create a common scalar Tx function

Quoted 8 lines · Anatoly
Quoted 6 lines · Bruce Richardson

Given the similarities between the transmit functions across various Intel drivers, make a start on consolidating them by moving the ice Tx function into common, for reuse by other drivers.

---

Quoted 9 lines

drivers/net/intel/common/tx_scalar.h ci_calc_pkt_desc(const struct rte_mbuf *tx_pkt) · line 197

Quoted 6 lines
drivers/net/intel/common/tx_scalar.h +6 -0
+	if (ts_fns != NULL)
+		ts_id = ts_fns->get_ts_tail(txq);
+
+	/* Check if the descriptor ring needs to be cleaned. */
+	if (txq->nb_tx_free < txq->tx_free_thresh)
+		(void)ci_tx_xmit_cleanup(txq);

Why (void) ?

Not sure, it seems superfluous, but I think it may help with some static analysis perhaps? I've seen some tools warn you if you generally check a return value from a function but fail to do so in one place. The other places where the xmit_cleanup function is called here the return value is checked each time, making this the outlier and so an explicit "void" doesn't hurt.

If you feel it should be removed, I can do so though....

Quoted 16 lines

drivers/net/intel/common/tx_scalar.h ci_calc_pkt_desc(const struct rte_mbuf *tx_pkt) · line 234

Quoted 8 lines
drivers/net/intel/common/tx_scalar.h +7 -0
+		if (ol_flags & (RTE_MBUF_F_TX_TCP_SEG | RTE_MBUF_F_TX_UDP_SEG))
+			nb_used = (uint16_t)(ci_calc_pkt_desc(tx_pkt) + nb_ctx);
+		else
+			nb_used = (uint16_t)(tx_pkt->nb_segs + nb_ctx);
+		tx_last = (uint16_t)(tx_id + nb_used - 1);
+
+		/* Circular ring */

nicholas_cage_you_dont_say.jpg

Signature · 2 lines
Thanks,
Anatoly
#166 lore raw

Re: [PATCH v4 11/35] net/intel: create a common scalar Tx function

Quoted 19 lines · Bruce Richardson
Quoted 8 lines · Anatoly
Quoted 6 lines · Bruce Richardson

Given the similarities between the transmit functions across various Intel drivers, make a start on consolidating them by moving the ice Tx function into common, for reuse by other drivers.

---

Quoted 9 lines

drivers/net/intel/common/tx_scalar.h ci_calc_pkt_desc(const struct rte_mbuf *tx_pkt) · line 197

Quoted 6 lines
drivers/net/intel/common/tx_scalar.h +6 -0
+	if (ts_fns != NULL)
+		ts_id = ts_fns->get_ts_tail(txq);
+
+	/* Check if the descriptor ring needs to be cleaned. */
+	if (txq->nb_tx_free < txq->tx_free_thresh)
+		(void)ci_tx_xmit_cleanup(txq);

Why (void) ?

Quoted 8 lines

Not sure, it seems superfluous, but I think it may help with some static analysis perhaps? I've seen some tools warn you if you generally check a return value from a function but fail to do so in one place. The other places where the xmit_cleanup function is called here the return value is checked each time, making this the outlier and so an explicit "void" doesn't hurt.

If you feel it should be removed, I can do so though....

If you need to ignore the value perhaps do RTE_SET_USED()? I mean it's usually used for variables, so perhaps (void) is fine, in which case you can disregard this.

Signature · 2 lines
Thanks,
Anatoly
#167 lore raw

PATCH v4 12/35 net/i40e: use common scalar Tx function

In reply to Bruce Richardson

Following earlier rework, the scalar transmit function for i40e can use the common function previously moved over from ice driver. This saves hundreds of duplicated lines of code.

---
 drivers/net/intel/i40e/i40e_rxtx.c | 208 +----------------------------
 1 file changed, 2 insertions(+), 206 deletions(-)
drivers/net/intel/i40e/i40e_rxtx.c +2 -206
index c318b4c84e..41310b4c6c 100644
@@ -1018,212 +1018,8 @@ get_context_desc(uint64_t ol_flags, const struct rte_mbuf *tx_pkt,
 uint16_t
 i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 {
-	struct ci_tx_queue *txq;
-	struct ci_tx_entry *sw_ring;
-	struct ci_tx_entry *txe, *txn;
-	volatile struct ci_tx_desc *txd;
-	volatile struct ci_tx_desc *txr;
-	struct rte_mbuf *tx_pkt;
-	struct rte_mbuf *m_seg;
-	uint16_t tx_id;
-	uint16_t nb_tx;
-	uint32_t td_cmd;
-	uint32_t td_offset;
-	uint32_t td_tag;
-	uint64_t ol_flags;
-	uint16_t nb_used;
-	uint16_t nb_ctx;
-	uint16_t tx_last;
-	uint16_t slen;
-	uint16_t l2_len;
-	uint64_t buf_dma_addr;
-	union ci_tx_offload tx_offload = {0};
-
-	txq = tx_queue;
-	sw_ring = txq->sw_ring;
-	txr = txq->ci_tx_ring;
-	tx_id = txq->tx_tail;
-	txe = &sw_ring[tx_id];
-
-	/* Check if the descriptor ring needs to be cleaned. */
-	if (txq->nb_tx_free < txq->tx_free_thresh)
-		(void)ci_tx_xmit_cleanup(txq);
-
-	for (nb_tx = 0; nb_tx < nb_pkts; nb_tx++) {
-		tx_pkt = *tx_pkts++;
-		RTE_MBUF_PREFETCH_TO_FREE(txe->mbuf);
-
-		ol_flags = tx_pkt->ol_flags;
-		td_cmd = 0;
-		td_tag = 0;
-		l2_len = ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK ?
-				tx_pkt->outer_l2_len : tx_pkt->l2_len;
-		td_offset = (l2_len >> 1) << CI_TX_DESC_LEN_MACLEN_S;
-		tx_offload.l2_len = tx_pkt->l2_len;
-		tx_offload.l3_len = tx_pkt->l3_len;
-		tx_offload.outer_l2_len = tx_pkt->outer_l2_len;
-		tx_offload.outer_l3_len = tx_pkt->outer_l3_len;
-		tx_offload.l4_len = tx_pkt->l4_len;
-		tx_offload.tso_segsz = tx_pkt->tso_segsz;
-
-		/* Calculate the number of context descriptors needed. */
-		uint64_t cd_qw0 = 0, cd_qw1 = 0;
-		nb_ctx = get_context_desc(ol_flags, tx_pkt, &tx_offload, txq,
-				&cd_qw0, &cd_qw1);
-
-		/**
-		 * The number of descriptors that must be allocated for
-		 * a packet equals to the number of the segments of that
-		 * packet plus 1 context descriptor if needed.
-		 * Recalculate the needed tx descs when TSO enabled in case
-		 * the mbuf data size exceeds max data size that hw allows
-		 * per tx desc.
-		 */
-		if (ol_flags & RTE_MBUF_F_TX_TCP_SEG)
-			nb_used = (uint16_t)(ci_calc_pkt_desc(tx_pkt) + nb_ctx);
-		else
-			nb_used = (uint16_t)(tx_pkt->nb_segs + nb_ctx);
-		tx_last = (uint16_t)(tx_id + nb_used - 1);
-
-		/* Circular ring */
-		if (tx_last >= txq->nb_tx_desc)
-			tx_last = (uint16_t)(tx_last - txq->nb_tx_desc);
-
-		if (nb_used > txq->nb_tx_free) {
-			if (ci_tx_xmit_cleanup(txq) != 0) {
-				if (nb_tx == 0)
-					return 0;
-				goto end_of_tx;
-			}
-			if (unlikely(nb_used > txq->tx_rs_thresh)) {
-				while (nb_used > txq->nb_tx_free) {
-					if (ci_tx_xmit_cleanup(txq) != 0) {
-						if (nb_tx == 0)
-							return 0;
-						goto end_of_tx;
-					}
-				}
-			}
-		}
-
-		/* Descriptor based VLAN insertion */
-		if (ol_flags & (RTE_MBUF_F_TX_VLAN | RTE_MBUF_F_TX_QINQ)) {
-			td_cmd |= CI_TX_DESC_CMD_IL2TAG1;
-			td_tag = tx_pkt->vlan_tci;
-		}
-
-		/* Always enable CRC offload insertion */
-		td_cmd |= CI_TX_DESC_CMD_ICRC;
-
-		/* Enable checksum offloading */
-		if (ol_flags & CI_TX_CKSUM_OFFLOAD_MASK)
-			ci_txd_enable_checksum(ol_flags, &td_cmd,
-						 &td_offset, tx_offload);
-
-		if (nb_ctx) {
-			/* Setup TX context descriptor if required */
-			uint64_t *desc = RTE_CAST_PTR(uint64_t *, &txr[tx_id]);
-
-			txn = &sw_ring[txe->next_id];
-			RTE_MBUF_PREFETCH_TO_FREE(txn->mbuf);
-			if (txe->mbuf != NULL) {
-				rte_pktmbuf_free_seg(txe->mbuf);
-				txe->mbuf = NULL;
-			}
-
-			desc[0] = cd_qw0;
-			desc[1] = cd_qw1;
-
-			PMD_TX_LOG(DEBUG, "mbuf: %p, TCD[%u]: "
-				"qw0: %#"PRIx64"; "
-				"qw1: %#"PRIx64";",
-				tx_pkt, tx_id, cd_qw0, cd_qw1);
-
-			txe->last_id = tx_last;
-			tx_id = txe->next_id;
-			txe = txn;
-		}
-
-		m_seg = tx_pkt;
-		do {
-			txd = &txr[tx_id];
-			txn = &sw_ring[txe->next_id];
-
-			if (txe->mbuf)
-				rte_pktmbuf_free_seg(txe->mbuf);
-			txe->mbuf = m_seg;
-
-			/* Setup TX Descriptor */
-			slen = m_seg->data_len;
-			buf_dma_addr = rte_mbuf_data_iova(m_seg);
-
-			while ((ol_flags & RTE_MBUF_F_TX_TCP_SEG) &&
-				unlikely(slen > CI_MAX_DATA_PER_TXD)) {
-				txd->buffer_addr =
-					rte_cpu_to_le_64(buf_dma_addr);
-				txd->cmd_type_offset_bsz =
-					i40e_build_ctob(td_cmd,
-					td_offset, CI_MAX_DATA_PER_TXD,
-					td_tag);
-
-				buf_dma_addr += CI_MAX_DATA_PER_TXD;
-				slen -= CI_MAX_DATA_PER_TXD;
-
-				txe->last_id = tx_last;
-				tx_id = txe->next_id;
-				txe = txn;
-				txd = &txr[tx_id];
-				txn = &sw_ring[txe->next_id];
-			}
-			PMD_TX_LOG(DEBUG, "mbuf: %p, TDD[%u]: "
-				"buf_dma_addr: %#"PRIx64"; "
-				"td_cmd: %#x; "
-				"td_offset: %#x; "
-				"td_len: %u; "
-				"td_tag: %#x;",
-				tx_pkt, tx_id, buf_dma_addr,
-				td_cmd, td_offset, slen, td_tag);
-
-			txd->buffer_addr = rte_cpu_to_le_64(buf_dma_addr);
-			txd->cmd_type_offset_bsz = i40e_build_ctob(td_cmd,
-						td_offset, slen, td_tag);
-			txe->last_id = tx_last;
-			tx_id = txe->next_id;
-			txe = txn;
-			m_seg = m_seg->next;
-		} while (m_seg != NULL);
-
-		/* The last packet data descriptor needs End Of Packet (EOP) */
-		td_cmd |= CI_TX_DESC_CMD_EOP;
-		txq->nb_tx_used = (uint16_t)(txq->nb_tx_used + nb_used);
-		txq->nb_tx_free = (uint16_t)(txq->nb_tx_free - nb_used);
-
-		if (txq->nb_tx_used >= txq->tx_rs_thresh) {
-			PMD_TX_LOG(DEBUG,
-				   "Setting RS bit on TXD id="
-				   "%4u (port=%d queue=%d)",
-				   tx_last, txq->port_id, txq->queue_id);
-
-			td_cmd |= CI_TX_DESC_CMD_RS;
-
-			/* Update txq RS bit counters */
-			txq->nb_tx_used = 0;
-		}
-
-		txd->cmd_type_offset_bsz |=
-			rte_cpu_to_le_64(((uint64_t)td_cmd) << CI_TXD_QW1_CMD_S);
-	}
-
-end_of_tx:
-	PMD_TX_LOG(DEBUG, "port_id=%u queue_id=%u tx_tail=%u nb_tx=%u",
-		   (unsigned) txq->port_id, (unsigned) txq->queue_id,
-		   (unsigned) tx_id, (unsigned) nb_tx);
-
-	rte_io_wmb();
-	I40E_PCI_REG_WC_WRITE_RELAXED(txq->qtx_tail, tx_id);
-	txq->tx_tail = tx_id;
-
-	return nb_tx;
+	/* i40e does not support timestamp queues, so pass NULL for ts_fns */
+	return ci_xmit_pkts(tx_queue, tx_pkts, nb_pkts, get_context_desc, NULL);
 }
 
 static __rte_always_inline int
Signature · 1 line
2.51.0
#169 lore raw

PATCH v4 13/35 net/intel: add IPsec hooks to common Tx function

In reply to Bruce Richardson

The iavf driver has IPsec offload support on Tx, so add hooks to the common Tx function to support that. Do so in a way that has zero performance impact for drivers which do not have IPSec support, by passing in compile-time NULL constants for the function pointers, which can be optimized away by the compiler.

---
 drivers/net/intel/common/tx_scalar.h | 60 ++++++++++++++++++++++++++--
 drivers/net/intel/i40e/i40e_rxtx.c   |  4 +-
 drivers/net/intel/ice/ice_rxtx.c     |  4 +-
 3 files changed, 60 insertions(+), 8 deletions(-)
drivers/net/intel/common/tx_scalar.h +56 -4
index 4d041fac99..af50bda820 100644
@@ -142,6 +142,24 @@ typedef uint16_t (*ci_get_ctx_desc_fn)(uint64_t ol_flags, const struct rte_mbuf
 		const union ci_tx_offload *tx_offload, const struct ci_tx_queue *txq,
 		uint64_t *qw0, uint64_t *qw1);
 
+/* gets IPsec descriptor information and returns number of descriptors needed (0 or 1) */
+typedef uint16_t (*get_ipsec_desc_t)(const struct rte_mbuf *mbuf,
+		const struct ci_tx_queue *txq,
+		void **ipsec_metadata,
+		uint64_t *qw0,
+		uint64_t *qw1);
+/* calculates segment length for IPsec + TSO combinations */
+typedef uint16_t (*calc_ipsec_segment_len_t)(const struct rte_mbuf *mb_seg,
+		uint64_t ol_flags,
+		const void *ipsec_metadata,
+		uint16_t tlen);
+
+/** IPsec descriptor operations for drivers that support inline IPsec crypto. */
+struct ci_ipsec_ops {
+	get_ipsec_desc_t get_ipsec_desc;
+	calc_ipsec_segment_len_t calc_segment_len;
+};
+
 /* gets current timestamp tail index */
 typedef uint16_t (*get_ts_tail_t)(struct ci_tx_queue *txq);
 /* writes a timestamp descriptor and returns new tail index */
@@ -161,6 +179,7 @@ ci_xmit_pkts(struct ci_tx_queue *txq,
 	     struct rte_mbuf **tx_pkts,
 	     uint16_t nb_pkts,
 	     ci_get_ctx_desc_fn get_ctx_desc,
+	     const struct ci_ipsec_ops *ipsec_ops,
 	     const struct ci_timestamp_queue_fns *ts_fns)
 {
 	volatile struct ci_tx_desc *ci_tx_ring;
@@ -197,6 +216,9 @@ ci_xmit_pkts(struct ci_tx_queue *txq,
 		(void)ci_tx_xmit_cleanup(txq);
 
 	for (nb_tx = 0; nb_tx < nb_pkts; nb_tx++) {
+		void *ipsec_md = NULL;
+		uint16_t nb_ipsec = 0;
+		uint64_t ipsec_qw0 = 0, ipsec_qw1 = 0;
 		uint64_t cd_qw0, cd_qw1;
 		tx_pkt = *tx_pkts++;
 
@@ -218,17 +240,22 @@ ci_xmit_pkts(struct ci_tx_queue *txq,
 		/* Calculate the number of context descriptors needed. */
 		nb_ctx = get_ctx_desc(ol_flags, tx_pkt, &tx_offload, txq, &cd_qw0, &cd_qw1);
 
+		/* Get IPsec descriptor information if IPsec ops provided */
+		if (ipsec_ops != NULL)
+			nb_ipsec = ipsec_ops->get_ipsec_desc(tx_pkt, txq, &ipsec_md,
+					&ipsec_qw0, &ipsec_qw1);
+
 		/* The number of descriptors that must be allocated for
 		 * a packet equals to the number of the segments of that
-		 * packet plus the number of context descriptor if needed.
+		 * packet plus the number of context and IPsec descriptors if needed.
 		 * Recalculate the needed tx descs when TSO enabled in case
 		 * the mbuf data size exceeds max data size that hw allows
 		 * per tx desc.
 		 */
 		if (ol_flags & (RTE_MBUF_F_TX_TCP_SEG | RTE_MBUF_F_TX_UDP_SEG))
-			nb_used = (uint16_t)(ci_calc_pkt_desc(tx_pkt) + nb_ctx);
+			nb_used = (uint16_t)(ci_calc_pkt_desc(tx_pkt) + nb_ctx + nb_ipsec);
 		else
-			nb_used = (uint16_t)(tx_pkt->nb_segs + nb_ctx);
+			nb_used = (uint16_t)(tx_pkt->nb_segs + nb_ctx + nb_ipsec);
 		tx_last = (uint16_t)(tx_id + nb_used - 1);
 
 		/* Circular ring */
@@ -281,6 +308,26 @@ ci_xmit_pkts(struct ci_tx_queue *txq,
 			tx_id = txe->next_id;
 			txe = txn;
 		}
+
+		if (ipsec_ops != NULL && nb_ipsec > 0) {
+			/* Setup TX IPsec descriptor if required */
+			uint64_t *ipsec_txd = RTE_CAST_PTR(uint64_t *, &ci_tx_ring[tx_id]);
+
+			txn = &sw_ring[txe->next_id];
+			RTE_MBUF_PREFETCH_TO_FREE(txn->mbuf);
+			if (txe->mbuf) {
+				rte_pktmbuf_free_seg(txe->mbuf);
+				txe->mbuf = NULL;
+			}
+
+			ipsec_txd[0] = ipsec_qw0;
+			ipsec_txd[1] = ipsec_qw1;
+
+			txe->last_id = tx_last;
+			tx_id = txe->next_id;
+			txe = txn;
+		}
+
 		m_seg = tx_pkt;
 
 		do {
@@ -292,7 +339,12 @@ ci_xmit_pkts(struct ci_tx_queue *txq,
 			txe->mbuf = m_seg;
 
 			/* Setup TX Descriptor */
-			slen = m_seg->data_len;
+			/* Calculate segment length, using IPsec callback if provided */
+			if (ipsec_ops != NULL)
+				slen = ipsec_ops->calc_segment_len(m_seg, ol_flags, ipsec_md, 0);
+			else
+				slen = m_seg->data_len;
+
 			buf_dma_addr = rte_mbuf_data_iova(m_seg);
 
 			while ((ol_flags & (RTE_MBUF_F_TX_TCP_SEG | RTE_MBUF_F_TX_UDP_SEG)) &&
drivers/net/intel/i40e/i40e_rxtx.c +2 -2
index 41310b4c6c..4e362e737e 100644
@@ -1018,8 +1018,8 @@ get_context_desc(uint64_t ol_flags, const struct rte_mbuf *tx_pkt,
 uint16_t
 i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 {
-	/* i40e does not support timestamp queues, so pass NULL for ts_fns */
-	return ci_xmit_pkts(tx_queue, tx_pkts, nb_pkts, get_context_desc, NULL);
+	/* i40e does not support IPsec or timestamp queues, so pass NULL for both */
+	return ci_xmit_pkts(tx_queue, tx_pkts, nb_pkts, get_context_desc, NULL, NULL);
 }
 
 static __rte_always_inline int
drivers/net/intel/ice/ice_rxtx.c +2 -2
index 561a6617a6..9643dd3817 100644
@@ -3105,9 +3105,9 @@ ice_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 	struct ci_tx_queue *txq = (struct ci_tx_queue *)tx_queue;
 
 	if (txq->tsq != NULL && txq->tsq->ts_flag > 0)
-		return ci_xmit_pkts(txq, tx_pkts, nb_pkts, get_context_desc, &ts_fns);
+		return ci_xmit_pkts(txq, tx_pkts, nb_pkts, get_context_desc, NULL, &ts_fns);
 
-	return ci_xmit_pkts(txq, tx_pkts, nb_pkts, get_context_desc, NULL);
+	return ci_xmit_pkts(txq, tx_pkts, nb_pkts, get_context_desc, NULL, NULL);
 }
 
 static __rte_always_inline int
Signature · 1 line
2.51.0
Acked-by on v4 13/35
#170 lore raw

Re: [PATCH v4 13/35] net/intel: add IPsec hooks to common Tx function

Quoted 8 lines · Bruce Richardson

The iavf driver has IPsec offload support on Tx, so add hooks to the common Tx function to support that. Do so in a way that has zero performance impact for drivers which do not have IPSec support, by passing in compile-time NULL constants for the function pointers, which can be optimized away by the compiler.

---

Signature · 2 lines
Thanks,
Anatoly
#171 lore raw

PATCH v4 14/35 net/intel: support configurable VLAN tag insertion on Tx

In reply to Bruce Richardson

Make the VLAN tag insertion logic configurable in the common code, as to where inner/outer tags get placed.

---
 drivers/net/intel/common/tx.h        | 10 ++++++++++
 drivers/net/intel/common/tx_scalar.h |  9 +++++++--
 drivers/net/intel/i40e/i40e_rxtx.c   |  6 +++---
 drivers/net/intel/ice/ice_rxtx.c     |  5 +++--
 4 files changed, 23 insertions(+), 7 deletions(-)
drivers/net/intel/common/tx.h +10 -0
index 23deabc5d1..f0229314a0 100644
@@ -45,6 +45,16 @@
 #define CI_TX_CTX_DESC_TSYN             0x02
 #define CI_TX_CTX_DESC_IL2TAG2          0x04
 
+/**
+ * L2TAG1 Field Source Selection
+ * Specifies which mbuf VLAN field to use for the L2TAG1 field in data descriptors.
+ * Context descriptor VLAN handling (L2TAG2) is managed by driver-specific callbacks.
+ */
+enum ci_tx_l2tag1_field {
+	CI_VLAN_IN_L2TAG1,       /**< For VLAN (not QinQ), use L2Tag1 field in data desc */
+	CI_VLAN_IN_L2TAG2,       /**< For VLAN (not QinQ), use L2Tag2 field in ctx desc */
+};
+
 /* Common TX Descriptor Length Field Shifts */
 #define CI_TX_DESC_LEN_MACLEN_S         0  /* 7 BITS */
 #define CI_TX_DESC_LEN_IPLEN_S          7  /* 7 BITS */
drivers/net/intel/common/tx_scalar.h +7 -2
index af50bda820..3248f9423d 100644
@@ -178,6 +178,7 @@ static inline uint16_t
 ci_xmit_pkts(struct ci_tx_queue *txq,
 	     struct rte_mbuf **tx_pkts,
 	     uint16_t nb_pkts,
+	     enum ci_tx_l2tag1_field l2tag1_field,
 	     ci_get_ctx_desc_fn get_ctx_desc,
 	     const struct ci_ipsec_ops *ipsec_ops,
 	     const struct ci_timestamp_queue_fns *ts_fns)
@@ -279,8 +280,12 @@ ci_xmit_pkts(struct ci_tx_queue *txq,
 			}
 		}
 
-		/* Descriptor based VLAN insertion */
-		if (ol_flags & (RTE_MBUF_F_TX_VLAN | RTE_MBUF_F_TX_QINQ)) {
+		/* Descriptor based VLAN/QinQ insertion */
+		/* for single vlan offload, only insert in data desc with VLAN_IN_L2TAG1 is set
+		 * for qinq offload, we always put inner tag in L2Tag1
+		 */
+		if (((ol_flags & RTE_MBUF_F_TX_VLAN) && l2tag1_field == CI_VLAN_IN_L2TAG1) ||
+				(ol_flags & RTE_MBUF_F_TX_QINQ)) {
 			td_cmd |= CI_TX_DESC_CMD_IL2TAG1;
 			td_tag = tx_pkt->vlan_tci;
 		}
drivers/net/intel/i40e/i40e_rxtx.c +3 -3
index 4e362e737e..35c1b53c1e 100644
@@ -1004,8 +1004,7 @@ get_context_desc(uint64_t ol_flags, const struct rte_mbuf *tx_pkt,
 	/* TX context descriptor based double VLAN insert */
 	if (ol_flags & RTE_MBUF_F_TX_QINQ) {
 		cd_l2tag2 = tx_pkt->vlan_tci_outer;
-		cd_type_cmd_tso_mss |=
-				((uint64_t)I40E_TX_CTX_DESC_IL2TAG2 << I40E_TXD_CTX_QW1_CMD_SHIFT);
+		cd_type_cmd_tso_mss |= (I40E_TX_CTX_DESC_IL2TAG2 << I40E_TXD_CTX_QW1_CMD_SHIFT);
 	}
 
 	*qw0 = rte_cpu_to_le_32(cd_tunneling_params) |
@@ -1019,7 +1018,8 @@ uint16_t
 i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 {
 	/* i40e does not support IPsec or timestamp queues, so pass NULL for both */
-	return ci_xmit_pkts(tx_queue, tx_pkts, nb_pkts, get_context_desc, NULL, NULL);
+	return ci_xmit_pkts(tx_queue, tx_pkts, nb_pkts, CI_VLAN_IN_L2TAG1,
+			get_context_desc, NULL, NULL);
 }
 
 static __rte_always_inline int
drivers/net/intel/ice/ice_rxtx.c +3 -2
index 9643dd3817..111cb5e37f 100644
@@ -3105,9 +3105,10 @@ ice_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 	struct ci_tx_queue *txq = (struct ci_tx_queue *)tx_queue;
 
 	if (txq->tsq != NULL && txq->tsq->ts_flag > 0)
-		return ci_xmit_pkts(txq, tx_pkts, nb_pkts, get_context_desc, NULL, &ts_fns);
+		return ci_xmit_pkts(txq, tx_pkts, nb_pkts, CI_VLAN_IN_L2TAG1,
+				get_context_desc, NULL, &ts_fns);
 
-	return ci_xmit_pkts(txq, tx_pkts, nb_pkts, get_context_desc, NULL, NULL);
+	return ci_xmit_pkts(txq, tx_pkts, nb_pkts, CI_VLAN_IN_L2TAG1, get_context_desc, NULL, NULL);
 }
 
 static __rte_always_inline int
Signature · 1 line
2.51.0
#172 lore raw

Re: [PATCH v4 14/35] net/intel: support configurable VLAN tag insertion on Tx

Quoted 5 lines · Bruce Richardson

Make the VLAN tag insertion logic configurable in the common code, as to where inner/outer tags get placed.

---

Hi Bruce,
I might be missing something obvious, but...

drivers/net/intel/common/tx_scalar.h ci_xmit_pkts(struct ci_tx_queue *txq, · line 291

Quoted 12 lines
drivers/net/intel/common/tx_scalar.h +6 -2
-		/* Descriptor based VLAN insertion */
-		if (ol_flags & (RTE_MBUF_F_TX_VLAN | RTE_MBUF_F_TX_QINQ)) {
+		/* Descriptor based VLAN/QinQ insertion */
+		/* for single vlan offload, only insert in data desc with VLAN_IN_L2TAG1 is set
+		 * for qinq offload, we always put inner tag in L2Tag1
+		 */
+		if (((ol_flags & RTE_MBUF_F_TX_VLAN) && l2tag1_field == CI_VLAN_IN_L2TAG1) ||
+				(ol_flags & RTE_MBUF_F_TX_QINQ)) {
  			td_cmd |= CI_TX_DESC_CMD_IL2TAG1;
  			td_tag = tx_pkt->vlan_tci;
  		}

I can see that we insert VLAN tag on TX_VLAN and VLAN_IN_TAG1. But then...

drivers/net/intel/i40e/i40e_rxtx.c get_context_desc(uint64_t ol_flags, const struct rte_mbuf *tx_pkt, · line 1007

Quoted 7 lines
drivers/net/intel/i40e/i40e_rxtx.c +1 -2
@@ -1004,8 +1004,7 @@ get_context_desc(uint64_t ol_flags, const struct rte_mbuf *tx_pkt,
  	/* TX context descriptor based double VLAN insert */
  	if (ol_flags & RTE_MBUF_F_TX_QINQ) {
  		cd_l2tag2 = tx_pkt->vlan_tci_outer;
-		cd_type_cmd_tso_mss |=
-				((uint64_t)I40E_TX_CTX_DESC_IL2TAG2 << I40E_TXD_CTX_QW1_CMD_SHIFT);
+		cd_type_cmd_tso_mss |= (I40E_TX_CTX_DESC_IL2TAG2 << I40E_TXD_CTX_QW1_CMD_SHIFT);

this logic is only triggered for QinQ. Meaning, there's nowhere we insert VLAN tag on TX_VLAN and VLAN_IN_TAG2?

Signature · 2 lines
Thanks,
Anatoly
#173 lore raw

Re: [PATCH v4 14/35] net/intel: support configurable VLAN tag insertion on Tx

Quoted 25 lines · Anatoly
Quoted 5 lines · Bruce Richardson

Make the VLAN tag insertion logic configurable in the common code, as to where inner/outer tags get placed.

---

Hi Bruce,
I might be missing something obvious, but...

drivers/net/intel/common/tx_scalar.h ci_xmit_pkts(struct ci_tx_queue *txq, · line 291

Quoted 11 lines
drivers/net/intel/common/tx_scalar.h +6 -2
-		/* Descriptor based VLAN insertion */
-		if (ol_flags & (RTE_MBUF_F_TX_VLAN | RTE_MBUF_F_TX_QINQ)) {
+		/* Descriptor based VLAN/QinQ insertion */
+		/* for single vlan offload, only insert in data desc with VLAN_IN_L2TAG1 is set
+		 * for qinq offload, we always put inner tag in L2Tag1
+		 */
+		if (((ol_flags & RTE_MBUF_F_TX_VLAN) && l2tag1_field == CI_VLAN_IN_L2TAG1) ||
+				(ol_flags & RTE_MBUF_F_TX_QINQ)) {
  			td_cmd |= CI_TX_DESC_CMD_IL2TAG1;
  			td_tag = tx_pkt->vlan_tci;
  		}

I can see that we insert VLAN tag on TX_VLAN and VLAN_IN_TAG1. But then...

Quoted 11 lines

drivers/net/intel/i40e/i40e_rxtx.c get_context_desc(uint64_t ol_flags, const struct rte_mbuf *tx_pkt, · line 1007

Quoted 7 lines
drivers/net/intel/i40e/i40e_rxtx.c +1 -2
@@ -1004,8 +1004,7 @@ get_context_desc(uint64_t ol_flags, const struct rte_mbuf *tx_pkt,
  	/* TX context descriptor based double VLAN insert */
  	if (ol_flags & RTE_MBUF_F_TX_QINQ) {
  		cd_l2tag2 = tx_pkt->vlan_tci_outer;
-		cd_type_cmd_tso_mss |=
-				((uint64_t)I40E_TX_CTX_DESC_IL2TAG2 << I40E_TXD_CTX_QW1_CMD_SHIFT);
+		cd_type_cmd_tso_mss |= (I40E_TX_CTX_DESC_IL2TAG2 << I40E_TXD_CTX_QW1_CMD_SHIFT);

this logic is only triggered for QinQ. Meaning, there's nowhere we insert VLAN tag on TX_VLAN and VLAN_IN_TAG2?

For VLAN_IN_L2TAG2 the vlan tag goes in the context descriptor, and creating the context descriptor is the responsibility of each individual driver. The two drivers using this common path, i40e and ice both put the tag in the TAG1 slot, so don't have a path to add it to the TAG2 slot. We make it configurable in this patch so that in the next patches we can add in support for the iavf driver - which does support putting the VLAN tag in the Tag2 slot, in it's context descriptor function.

/Bruce

#174 lore raw

Re: [PATCH v4 14/35] net/intel: support configurable VLAN tag insertion on Tx

Quoted 45 lines · Bruce Richardson
Quoted 25 lines · Anatoly
Quoted 5 lines · Bruce Richardson

Make the VLAN tag insertion logic configurable in the common code, as to where inner/outer tags get placed.

---

Hi Bruce,
I might be missing something obvious, but...

drivers/net/intel/common/tx_scalar.h ci_xmit_pkts(struct ci_tx_queue *txq, · line 291

Quoted 11 lines
drivers/net/intel/common/tx_scalar.h +6 -2
-		/* Descriptor based VLAN insertion */
-		if (ol_flags & (RTE_MBUF_F_TX_VLAN | RTE_MBUF_F_TX_QINQ)) {
+		/* Descriptor based VLAN/QinQ insertion */
+		/* for single vlan offload, only insert in data desc with VLAN_IN_L2TAG1 is set
+		 * for qinq offload, we always put inner tag in L2Tag1
+		 */
+		if (((ol_flags & RTE_MBUF_F_TX_VLAN) && l2tag1_field == CI_VLAN_IN_L2TAG1) ||
+				(ol_flags & RTE_MBUF_F_TX_QINQ)) {
   			td_cmd |= CI_TX_DESC_CMD_IL2TAG1;
   			td_tag = tx_pkt->vlan_tci;
   		}

I can see that we insert VLAN tag on TX_VLAN and VLAN_IN_TAG1. But then...

Quoted 11 lines

drivers/net/intel/i40e/i40e_rxtx.c get_context_desc(uint64_t ol_flags, const struct rte_mbuf *tx_pkt, · line 1007

Quoted 7 lines
drivers/net/intel/i40e/i40e_rxtx.c +1 -2
@@ -1004,8 +1004,7 @@ get_context_desc(uint64_t ol_flags, const struct rte_mbuf *tx_pkt,
   	/* TX context descriptor based double VLAN insert */
   	if (ol_flags & RTE_MBUF_F_TX_QINQ) {
   		cd_l2tag2 = tx_pkt->vlan_tci_outer;
-		cd_type_cmd_tso_mss |=
-				((uint64_t)I40E_TX_CTX_DESC_IL2TAG2 << I40E_TXD_CTX_QW1_CMD_SHIFT);
+		cd_type_cmd_tso_mss |= (I40E_TX_CTX_DESC_IL2TAG2 << I40E_TXD_CTX_QW1_CMD_SHIFT);

this logic is only triggered for QinQ. Meaning, there's nowhere we insert VLAN tag on TX_VLAN and VLAN_IN_TAG2?

For VLAN_IN_L2TAG2 the vlan tag goes in the context descriptor, and creating the context descriptor is the responsibility of each individual driver. The two drivers using this common path, i40e and ice both put the tag in the TAG1 slot, so don't have a path to add it to the TAG2 slot. We make it configurable in this patch so that in the next patches we can add in support for the iavf driver - which does support putting the VLAN tag in the Tag2 slot, in it's context descriptor function.

Quoted 1 line

/Bruce

Perhaps we need to document that more explicitly then, and double-check that all driver paths actually do this in all required cases (i.e. not just for QinQ but also for regular VLAN insertion case).

Signature · 2 lines
Thanks,
Anatoly
#175 lore raw

Re: [PATCH v4 14/35] net/intel: support configurable VLAN tag insertion on Tx

Quoted 46 lines · Anatoly
Quoted 45 lines · Bruce Richardson
Quoted 25 lines · Anatoly
Quoted 5 lines · Bruce Richardson

Make the VLAN tag insertion logic configurable in the common code, as to where inner/outer tags get placed.

---

Hi Bruce,
I might be missing something obvious, but...

drivers/net/intel/common/tx_scalar.h ci_xmit_pkts(struct ci_tx_queue *txq, · line 291

Quoted 11 lines
drivers/net/intel/common/tx_scalar.h +6 -2
-		/* Descriptor based VLAN insertion */
-		if (ol_flags & (RTE_MBUF_F_TX_VLAN | RTE_MBUF_F_TX_QINQ)) {
+		/* Descriptor based VLAN/QinQ insertion */
+		/* for single vlan offload, only insert in data desc with VLAN_IN_L2TAG1 is set
+		 * for qinq offload, we always put inner tag in L2Tag1
+		 */
+		if (((ol_flags & RTE_MBUF_F_TX_VLAN) && l2tag1_field == CI_VLAN_IN_L2TAG1) ||
+				(ol_flags & RTE_MBUF_F_TX_QINQ)) {
   			td_cmd |= CI_TX_DESC_CMD_IL2TAG1;
   			td_tag = tx_pkt->vlan_tci;
   		}

I can see that we insert VLAN tag on TX_VLAN and VLAN_IN_TAG1. But then...

Quoted 11 lines

drivers/net/intel/i40e/i40e_rxtx.c get_context_desc(uint64_t ol_flags, const struct rte_mbuf *tx_pkt, · line 1007

Quoted 7 lines
drivers/net/intel/i40e/i40e_rxtx.c +1 -2
@@ -1004,8 +1004,7 @@ get_context_desc(uint64_t ol_flags, const struct rte_mbuf *tx_pkt,
   	/* TX context descriptor based double VLAN insert */
   	if (ol_flags & RTE_MBUF_F_TX_QINQ) {
   		cd_l2tag2 = tx_pkt->vlan_tci_outer;
-		cd_type_cmd_tso_mss |=
-				((uint64_t)I40E_TX_CTX_DESC_IL2TAG2 << I40E_TXD_CTX_QW1_CMD_SHIFT);
+		cd_type_cmd_tso_mss |= (I40E_TX_CTX_DESC_IL2TAG2 << I40E_TXD_CTX_QW1_CMD_SHIFT);

this logic is only triggered for QinQ. Meaning, there's nowhere we insert VLAN tag on TX_VLAN and VLAN_IN_TAG2?

For VLAN_IN_L2TAG2 the vlan tag goes in the context descriptor, and creating the context descriptor is the responsibility of each individual driver. The two drivers using this common path, i40e and ice both put the tag in the TAG1 slot, so don't have a path to add it to the TAG2 slot. We make it configurable in this patch so that in the next patches we can add in support for the iavf driver - which does support putting the VLAN tag in the Tag2 slot, in it's context descriptor function.

Quoted 6 lines
Quoted 1 line

/Bruce

Perhaps we need to document that more explicitly then, and double-check that all driver paths actually do this in all required cases (i.e. not just for QinQ but also for regular VLAN insertion case).

There's already a comment at the top of the enum definition, but I've also
expanded out the documentation on the L2TAG2 value to clarify that drivers need to set the value themselves rather than relying on the common Tx code.

/Bruce

#176 lore raw

PATCH v4 15/35 net/iavf: use common scalar Tx function

In reply to Bruce Richardson

Now that the common scalar Tx function has all necessary hooks for the features supported by the iavf driver, use the common function to avoid duplicated code.

---
 drivers/net/intel/common/tx_scalar.h |   3 +-
 drivers/net/intel/iavf/iavf_rxtx.c   | 534 ++++++---------------------
 drivers/net/intel/iavf/iavf_rxtx.h   |   1 +
 3 files changed, 112 insertions(+), 426 deletions(-)
drivers/net/intel/common/tx_scalar.h +2 -1
index 3248f9423d..8b503dd4de 100644
@@ -226,7 +226,8 @@ ci_xmit_pkts(struct ci_tx_queue *txq,
 		ol_flags = tx_pkt->ol_flags;
 		td_cmd = CI_TX_DESC_CMD_ICRC;
 		td_tag = 0;
-		l2_len = ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK ?
+		l2_len = (ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK &&
+					!(ol_flags & RTE_MBUF_F_TX_SEC_OFFLOAD)) ?
 				tx_pkt->outer_l2_len : tx_pkt->l2_len;
 		td_offset = (l2_len >> 1) << CI_TX_DESC_LEN_MACLEN_S;
 
drivers/net/intel/iavf/iavf_rxtx.c +109 -425

600 lines not on this page · raw message

drivers/net/intel/iavf/iavf_rxtx.h +1 -0
index cca5c25119..fe3385dcf6 100644
@@ -43,6 +43,7 @@
 		RTE_ETH_TX_OFFLOAD_TCP_CKSUM |		\
 		RTE_ETH_TX_OFFLOAD_SCTP_CKSUM |		\
 		RTE_ETH_TX_OFFLOAD_TCP_TSO |		\
+		RTE_ETH_TX_OFFLOAD_UDP_TSO |		\
 		RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM |	\
 		RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO |	\
 		RTE_ETH_TX_OFFLOAD_QINQ_INSERT |	\
Signature · 1 line
2.51.0
Acked-by on v4 15/35
#177 lore raw

Re: [PATCH v4 15/35] net/iavf: use common scalar Tx function

Quoted 8 lines · Bruce Richardson

Now that the common scalar Tx function has all necessary hooks for the features supported by the iavf driver, use the common function to avoid duplicated code.

---

drivers/net/intel/iavf/iavf_rxtx.c iavf_fill_ipsec_desc(volatile struct iavf_tx_ipsec_desc *desc, · line 2562

Quoted 7 lines
drivers/net/intel/iavf/iavf_rxtx.c +5 -1
+		}
 
-		return;
+		/* TSO segmentation field */
+		tlen = iavf_fill_ctx_desc_segmentation_field(&cd_type_cmd,
+							     mbuf, ipsec_md);
+		(void)tlen; /* Suppress unused variable warning */

RTE_SET_USED?

Signature · 2 lines
Thanks,
Anatoly
#178 lore raw

Re: [PATCH v4 15/35] net/iavf: use common scalar Tx function

Quoted 18 lines · Anatoly
Quoted 8 lines · Bruce Richardson

Now that the common scalar Tx function has all necessary hooks for the features supported by the iavf driver, use the common function to avoid duplicated code.

---

drivers/net/intel/iavf/iavf_rxtx.c iavf_fill_ipsec_desc(volatile struct iavf_tx_ipsec_desc *desc, · line 2562

Quoted 6 lines
drivers/net/intel/iavf/iavf_rxtx.c +5 -1
+		}
-		return;
+		/* TSO segmentation field */
+		tlen = iavf_fill_ctx_desc_segmentation_field(&cd_type_cmd,
+							     mbuf, ipsec_md);
+		(void)tlen; /* Suppress unused variable warning */

RTE_SET_USED?

Quoted 2 lines

since tlen is a local variable and is only used for the return value here, I can just get rid of it, saving having to pretend it's actually being used..

#179 lore raw

PATCH v4 16/35 net/i40e: document requirement for QinQ support

In reply to Bruce Richardson

In order to get multiple VLANs inserted in an outgoing packet with QinQ offload the i40e driver needs to be set to double vlan mode. This is done by using the VLAN_EXTEND Rx config flag. Add a code check for this dependency and update the docs about it.

---
 doc/guides/nics/i40e.rst           | 18 ++++++++++++++++++
 drivers/net/intel/i40e/i40e_rxtx.c |  9 +++++++++
 2 files changed, 27 insertions(+)
doc/guides/nics/i40e.rst +18 -0
index 40be9aa755..750af3c8b3 100644
@@ -245,6 +245,24 @@ Runtime Configuration
   * ``segment``: Check number of mbuf segments not exceed hw limitation.
   * ``offload``: Check any unsupported offload flag.
 
+QinQ Configuration
+~~~~~~~~~~~~~~~~~~
+
+When using QinQ TX offload (``RTE_ETH_TX_OFFLOAD_QINQ_INSERT``), you must also
+enable ``RTE_ETH_RX_OFFLOAD_VLAN_EXTEND`` to configure the hardware for double
+VLAN mode. Without this, only the inner VLAN tag will be inserted.
+
+Example::
+
+  struct rte_eth_conf port_conf = {
+      .rxmode = {
+          .offloads = RTE_ETH_RX_OFFLOAD_VLAN_EXTEND,
+      },
+      .txmode = {
+          .offloads = RTE_ETH_TX_OFFLOAD_QINQ_INSERT,
+      },
+  };
+
 Vector RX Pre-conditions
 ~~~~~~~~~~~~~~~~~~~~~~~~
 For Vector RX it is assumed that the number of descriptor rings will be a power
drivers/net/intel/i40e/i40e_rxtx.c +9 -0
index 35c1b53c1e..dfd2213020 100644
@@ -2182,6 +2182,15 @@ i40e_dev_tx_queue_setup(struct rte_eth_dev *dev,
 	vsi = i40e_pf_get_vsi_by_qindex(pf, queue_idx);
 	if (!vsi)
 		return -EINVAL;
+
+	/* Check if QinQ TX offload requires VLAN extend mode */
+	if ((offloads & RTE_ETH_TX_OFFLOAD_QINQ_INSERT) &&
+			!(dev->data->dev_conf.rxmode.offloads & RTE_ETH_RX_OFFLOAD_VLAN_EXTEND)) {
+		PMD_DRV_LOG(WARNING, "Port %u: QinQ TX offload is enabled but VLAN extend mode is not set. ",
+				dev->data->port_id);
+		PMD_DRV_LOG(WARNING, "Double VLAN insertion may not work correctly without RTE_ETH_RX_OFFLOAD_VLAN_EXTEND set in Rx configuration.");
+	}
+
 	q_offset = i40e_get_queue_offset_by_qindex(pf, queue_idx);
 	if (q_offset < 0)
 		return -EINVAL;
Signature · 1 line
2.51.0
Acked-by on v4 16/35
#180 lore raw

Re: [PATCH v4 16/35] net/i40e: document requirement for QinQ support

Quoted 7 lines · Bruce Richardson

In order to get multiple VLANs inserted in an outgoing packet with QinQ offload the i40e driver needs to be set to double vlan mode. This is done by using the VLAN_EXTEND Rx config flag. Add a code check for this dependency and update the docs about it.

---

Signature · 2 lines
Thanks,
Anatoly
#181 lore raw

PATCH v4 17/35 net/idpf: use common scalar Tx function

In reply to Bruce Richardson

Update idpf driver to use the common scalar Tx function in single-queue configuration.

---
 drivers/net/intel/idpf/idpf_common_rxtx.c | 178 ++--------------------
 1 file changed, 10 insertions(+), 168 deletions(-)
drivers/net/intel/idpf/idpf_common_rxtx.c +10 -168
index b34d545a0a..bca5f13c8e 100644
@@ -8,7 +8,6 @@
 
 #include "idpf_common_rxtx.h"
 #include "idpf_common_device.h"
-#include "../common/rx.h"
 
 int idpf_timestamp_dynfield_offset = -1;
 uint64_t idpf_timestamp_dynflag;
@@ -848,9 +847,10 @@ idpf_calc_context_desc(uint64_t flags)
 /* set TSO context descriptor, returns 0 if no context needed, 1 if context set
  */
 static inline uint16_t
-idpf_set_tso_ctx(uint64_t ol_flags, struct rte_mbuf *mbuf,
-			union ci_tx_offload tx_offload,
-			uint64_t *qw0, uint64_t *qw1)
+idpf_set_tso_ctx(uint64_t ol_flags, const struct rte_mbuf *mbuf,
+		 const union ci_tx_offload *tx_offload,
+		 const struct ci_tx_queue *txq __rte_unused,
+		 uint64_t *qw0, uint64_t *qw1)
 {
 	uint16_t cmd_dtype = IDPF_TX_DESC_DTYPE_FLEX_TSO_CTX | IDPF_TX_FLEX_CTX_DESC_CMD_TSO;
 	uint16_t tso_segsz = mbuf->tso_segsz;
@@ -861,12 +861,12 @@ idpf_set_tso_ctx(uint64_t ol_flags, struct rte_mbuf *mbuf,
 		return 0;
 
 	/* TSO context descriptor setup */
-	if (tx_offload.l4_len == 0) {
+	if (tx_offload->l4_len == 0) {
 		TX_LOG(DEBUG, "L4 length set to 0");
 		return 0;
 	}
 
-	hdr_len = tx_offload.l2_len + tx_offload.l3_len + tx_offload.l4_len;
+	hdr_len = tx_offload->l2_len + tx_offload->l3_len + tx_offload->l4_len;
 	tso_len = mbuf->pkt_len - hdr_len;
 
 	*qw0 = rte_cpu_to_le_32(tso_len & IDPF_TXD_FLEX_CTX_MSS_RT_M) |
@@ -933,7 +933,8 @@ idpf_dp_splitq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 		tx_offload.tso_segsz = tx_pkt->tso_segsz;
 		/* Calculate the number of context descriptors needed. */
 		uint64_t cd_qw0, cd_qw1;
-		nb_ctx = idpf_set_tso_ctx(ol_flags, tx_pkt, tx_offload, &cd_qw0, &cd_qw1);
+		nb_ctx = idpf_set_tso_ctx(ol_flags, tx_pkt, &tx_offload, txq,
+					  &cd_qw0, &cd_qw1);
 
 		/* Calculate the number of TX descriptors needed for
 		 * each packet. For TSO packets, use ci_calc_pkt_desc as
@@ -1339,167 +1340,8 @@ uint16_t
 idpf_dp_singleq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 			  uint16_t nb_pkts)
 {
-	volatile struct ci_tx_desc *txd;
-	volatile struct ci_tx_desc *txr;
-	union ci_tx_offload tx_offload = {0};
-	struct ci_tx_entry *txe, *txn;
-	struct ci_tx_entry *sw_ring;
-	struct ci_tx_queue *txq;
-	struct rte_mbuf *tx_pkt;
-	struct rte_mbuf *m_seg;
-	uint64_t buf_dma_addr;
-	uint32_t td_offset;
-	uint64_t ol_flags;
-	uint16_t tx_last;
-	uint16_t nb_used;
-	uint16_t nb_ctx;
-	uint16_t td_cmd;
-	uint16_t tx_id;
-	uint16_t nb_tx;
-	uint16_t slen;
-
-	nb_tx = 0;
-	txq = tx_queue;
-
-	if (unlikely(txq == NULL))
-		return nb_tx;
-
-	sw_ring = txq->sw_ring;
-	txr = txq->ci_tx_ring;
-	tx_id = txq->tx_tail;
-	txe = &sw_ring[tx_id];
-
-	/* Check if the descriptor ring needs to be cleaned. */
-	if (txq->nb_tx_free < txq->tx_free_thresh)
-		(void)ci_tx_xmit_cleanup(txq);
-
-	for (nb_tx = 0; nb_tx < nb_pkts; nb_tx++) {
-		td_cmd = 0;
-		td_offset = 0;
-
-		tx_pkt = *tx_pkts++;
-		RTE_MBUF_PREFETCH_TO_FREE(txe->mbuf);
-
-		ol_flags = tx_pkt->ol_flags;
-		tx_offload.l2_len = tx_pkt->l2_len;
-		tx_offload.l3_len = tx_pkt->l3_len;
-		tx_offload.l4_len = tx_pkt->l4_len;
-		tx_offload.tso_segsz = tx_pkt->tso_segsz;
-		/* Calculate the number of context descriptors needed. */
-		uint64_t cd_qw0, cd_qw1;
-		nb_ctx = idpf_set_tso_ctx(ol_flags, tx_pkt, tx_offload, &cd_qw0, &cd_qw1);
-
-		/* The number of descriptors that must be allocated for
-		 * a packet. For TSO packets, use ci_calc_pkt_desc as
-		 * the mbuf data size might exceed max data size that hw allows
-		 * per tx desc.
-		 */
-		if (ol_flags & RTE_MBUF_F_TX_TCP_SEG)
-			nb_used = (uint16_t)(ci_calc_pkt_desc(tx_pkt) + nb_ctx);
-		else
-			nb_used = (uint16_t)(tx_pkt->nb_segs + nb_ctx);
-		tx_last = (uint16_t)(tx_id + nb_used - 1);
-
-		/* Circular ring */
-		if (tx_last >= txq->nb_tx_desc)
-			tx_last = (uint16_t)(tx_last - txq->nb_tx_desc);
-
-		TX_LOG(DEBUG, "port_id=%u queue_id=%u"
-		       " tx_first=%u tx_last=%u",
-		       txq->port_id, txq->queue_id, tx_id, tx_last);
-
-		if (nb_used > txq->nb_tx_free) {
-			if (ci_tx_xmit_cleanup(txq) != 0) {
-				if (nb_tx == 0)
-					return 0;
-				goto end_of_tx;
-			}
-			if (unlikely(nb_used > txq->tx_rs_thresh)) {
-				while (nb_used > txq->nb_tx_free) {
-					if (ci_tx_xmit_cleanup(txq) != 0) {
-						if (nb_tx == 0)
-							return 0;
-						goto end_of_tx;
-					}
-				}
-			}
-		}
-
-		if (ol_flags & CI_TX_CKSUM_OFFLOAD_MASK)
-			td_cmd |= IDPF_TX_FLEX_DESC_CMD_CS_EN;
-
-		if (nb_ctx != 0) {
-			/* Setup TX context descriptor if required */
-			uint64_t *ctx_txd = RTE_CAST_PTR(uint64_t *, &txr[tx_id]);
-
-			txn = &sw_ring[txe->next_id];
-			RTE_MBUF_PREFETCH_TO_FREE(txn->mbuf);
-			if (txe->mbuf != NULL) {
-				rte_pktmbuf_free_seg(txe->mbuf);
-				txe->mbuf = NULL;
-			}
-
-			ctx_txd[0] = cd_qw0;
-			ctx_txd[1] = cd_qw1;
-
-			txe->last_id = tx_last;
-			tx_id = txe->next_id;
-			txe = txn;
-		}
-
-		m_seg = tx_pkt;
-		do {
-			txd = &txr[tx_id];
-			txn = &sw_ring[txe->next_id];
-
-			if (txe->mbuf != NULL)
-				rte_pktmbuf_free_seg(txe->mbuf);
-			txe->mbuf = m_seg;
-
-			/* Setup TX Descriptor */
-			slen = m_seg->data_len;
-			buf_dma_addr = rte_mbuf_data_iova(m_seg);
-			txd->buffer_addr = rte_cpu_to_le_64(buf_dma_addr);
-			txd->cmd_type_offset_bsz = rte_cpu_to_le_64(CI_TX_DESC_DTYPE_DATA |
-				((uint64_t)td_cmd  << CI_TXD_QW1_CMD_S) |
-				((uint64_t)td_offset << CI_TXD_QW1_OFFSET_S) |
-				((uint64_t)slen << CI_TXD_QW1_TX_BUF_SZ_S));
-
-			txe->last_id = tx_last;
-			tx_id = txe->next_id;
-			txe = txn;
-			m_seg = m_seg->next;
-		} while (m_seg);
-
-		/* The last packet data descriptor needs End Of Packet (EOP) */
-		td_cmd |= CI_TX_DESC_CMD_EOP;
-		txq->nb_tx_used = (uint16_t)(txq->nb_tx_used + nb_used);
-		txq->nb_tx_free = (uint16_t)(txq->nb_tx_free - nb_used);
-
-		if (txq->nb_tx_used >= txq->tx_rs_thresh) {
-			TX_LOG(DEBUG, "Setting RS bit on TXD id="
-			       "%4u (port=%d queue=%d)",
-			       tx_last, txq->port_id, txq->queue_id);
-
-			td_cmd |= CI_TX_DESC_CMD_RS;
-
-			/* Update txq RS bit counters */
-			txq->nb_tx_used = 0;
-		}
-
-		txd->cmd_type_offset_bsz |= rte_cpu_to_le_16(td_cmd << CI_TXD_QW1_CMD_S);
-	}
-
-end_of_tx:
-	rte_wmb();
-
-	TX_LOG(DEBUG, "port_id=%u queue_id=%u tx_tail=%u nb_tx=%u",
-	       txq->port_id, txq->queue_id, tx_id, nb_tx);
-
-	IDPF_PCI_REG_WRITE(txq->qtx_tail, tx_id);
-	txq->tx_tail = tx_id;
-
-	return nb_tx;
+	return ci_xmit_pkts(tx_queue, tx_pkts, nb_pkts, CI_VLAN_IN_L2TAG1,
+			idpf_set_tso_ctx, NULL, NULL);
 }
 
 /* TX prep functions */
Signature · 1 line
2.51.0
#183 lore raw

PATCH v4 18/35 net/intel: avoid writing the final pkt descriptor twice

In reply to Bruce Richardson

In the scalar datapath, there is a loop to handle multi-segment, and multi-descriptor packets on Tx. After that loop, the end-of-packet bit was written to the descriptor separately, meaning that for each single-descriptor packet there were two writes to the second quad-word - basically 3 x 64-bit writes rather than just 2. Adjusting the code to compute the EOP bit inside the loop saves that extra write per packet and so improves performance.

---
 drivers/net/intel/common/tx_scalar.h | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/net/intel/common/tx_scalar.h +6 -6
index 8b503dd4de..e9e9a826fa 100644
@@ -372,6 +372,10 @@ ci_xmit_pkts(struct ci_tx_queue *txq,
 				txn = &sw_ring[txe->next_id];
 			}
 
+			/* fill the last descriptor with End of Packet (EOP) bit */
+			if (m_seg->next == NULL)
+				td_cmd |= CI_TX_DESC_CMD_EOP;
+
 			txd->buffer_addr = rte_cpu_to_le_64(buf_dma_addr);
 			txd->cmd_type_offset_bsz = rte_cpu_to_le_64(CI_TX_DESC_DTYPE_DATA |
 				((uint64_t)td_cmd << CI_TXD_QW1_CMD_S) |
@@ -384,21 +388,17 @@ ci_xmit_pkts(struct ci_tx_queue *txq,
 			txe = txn;
 			m_seg = m_seg->next;
 		} while (m_seg);
-
-		/* fill the last descriptor with End of Packet (EOP) bit */
-		td_cmd |= CI_TX_DESC_CMD_EOP;
 		txq->nb_tx_used = (uint16_t)(txq->nb_tx_used + nb_used);
 		txq->nb_tx_free = (uint16_t)(txq->nb_tx_free - nb_used);
 
 		/* set RS bit on the last descriptor of one packet */
 		if (txq->nb_tx_used >= txq->tx_rs_thresh) {
-			td_cmd |= CI_TX_DESC_CMD_RS;
+			txd->cmd_type_offset_bsz |=
+					rte_cpu_to_le_64(CI_TX_DESC_CMD_RS << CI_TXD_QW1_CMD_S);
 
 			/* Update txq RS bit counters */
 			txq->nb_tx_used = 0;
 		}
-		txd->cmd_type_offset_bsz |=
-				rte_cpu_to_le_64(((uint64_t)td_cmd) << CI_TXD_QW1_CMD_S);
 
 		if (ts_fns != NULL)
 			ts_id = ts_fns->write_ts_desc(txq, tx_pkt, tx_id, ts_id);
Signature · 1 line
2.51.0
Acked-by on v4 18/35
#184 lore raw

Re: [PATCH v4 18/35] net/intel: avoid writing the final pkt descriptor twice

Quoted 10 lines · Bruce Richardson

In the scalar datapath, there is a loop to handle multi-segment, and multi-descriptor packets on Tx. After that loop, the end-of-packet bit was written to the descriptor separately, meaning that for each single-descriptor packet there were two writes to the second quad-word - basically 3 x 64-bit writes rather than just 2. Adjusting the code to compute the EOP bit inside the loop saves that extra write per packet and so improves performance.

---

Signature · 2 lines
Thanks,
Anatoly
#185 lore raw

PATCH v4 19/35 eal: add macro for marking assumed alignment

In reply to Bruce Richardson

Provide a common DPDK macro for the gcc/clang builtin __rte_assume_aligned to mark pointers as pointing to something with known minimum alignment.

---
 lib/eal/include/rte_common.h | 6 ++++++
 1 file changed, 6 insertions(+)
lib/eal/include/rte_common.h +6 -0
index 573bf4f2ce..51a2eaf8b4 100644
@@ -121,6 +121,12 @@ extern "C" {
 #define __rte_aligned(a) __attribute__((__aligned__(a)))
 #endif
 
+#ifdef RTE_TOOLCHAIN_MSVC
+#define __rte_assume_aligned(ptr, align) (ptr)
+#else
+#define __rte_assume_aligned __builtin_assume_aligned
+#endif
+
 #ifdef RTE_ARCH_STRICT_ALIGN
 typedef uint64_t unaligned_uint64_t __rte_aligned(1);
 typedef uint32_t unaligned_uint32_t __rte_aligned(1);
Signature · 1 line
2.51.0
#186 lore raw

RE: [PATCH v4 19/35] eal: add macro for marking assumed alignment

Quoted 18 lines

From: Bruce Richardson [mailto:[email protected]]
Sent: Monday, 9 February 2026 17.45

Provide a common DPDK macro for the gcc/clang builtin __rte_assume_aligned to mark pointers as pointing to something with known minimum alignment.

---
 lib/eal/include/rte_common.h | 6 ++++++
 1 file changed, 6 insertions(+)
lib/eal/include/rte_common.h +0 -0
index 573bf4f2ce..51a2eaf8b4 100644

lib/eal/include/rte_common.h extern "C" { · line 128

Quoted 8 lines
lib/eal/include/rte_common.h +5 -0
@@ -121,6 +121,12 @@ extern "C" {
 #define __rte_aligned(a) __attribute__((__aligned__(a)))
 #endif
 
+#ifdef RTE_TOOLCHAIN_MSVC
+#define __rte_assume_aligned(ptr, align) (ptr)
+#else
+#define __rte_assume_aligned __builtin_assume_aligned
+#endif

The GCC/Clang macro supports the optional 3rd parameter (offset), but the MSVC doesn't.
Maybe it's better to pass (ptr, align) to the GCC/Clang variant, so the API consistently only supports two parameters.

If the 3rd parameter ever becomes needed, it can be implemented as a new macro.

Also, a short description of the macro would be nice.

Did you look into using e.g. __rte_assume((ptr % 16) == 0) instead?
It's relevant if it has the desired effect for MSVC, which the macro in this patch doesn't.

#187 lore raw

Re: [PATCH v4 19/35] eal: add macro for marking assumed alignment

Quoted 30 lines · Morten Brørup
Quoted 18 lines

From: Bruce Richardson [mailto:[email protected]]
Sent: Monday, 9 February 2026 17.45

Provide a common DPDK macro for the gcc/clang builtin __rte_assume_aligned to mark pointers as pointing to something with known minimum alignment.

---
 lib/eal/include/rte_common.h | 6 ++++++
 1 file changed, 6 insertions(+)
lib/eal/include/rte_common.h +0 -0
index 573bf4f2ce..51a2eaf8b4 100644

lib/eal/include/rte_common.h extern "C" { · line 128

Quoted 8 lines
lib/eal/include/rte_common.h +5 -0
@@ -121,6 +121,12 @@ extern "C" {
 #define __rte_aligned(a) __attribute__((__aligned__(a)))
 #endif
 
+#ifdef RTE_TOOLCHAIN_MSVC
+#define __rte_assume_aligned(ptr, align) (ptr)
+#else
+#define __rte_assume_aligned __builtin_assume_aligned
+#endif

The GCC/Clang macro supports the optional 3rd parameter (offset), but the MSVC doesn't.
Maybe it's better to pass (ptr, align) to the GCC/Clang variant, so the API consistently only supports two parameters.

Quoted 8 lines

If the 3rd parameter ever becomes needed, it can be implemented as a new macro.

Also, a short description of the macro would be nice.

Did you look into using e.g. __rte_assume((ptr % 16) == 0) instead?
It's relevant if it has the desired effect for MSVC, which the macro in this patch doesn't.

Dropping this patch from the series, making the discussion moot, based on your feedback on the next patch. Thanks.

#188 lore raw

PATCH v4 20/35 net/intel: write descriptors using non-volatile pointers

In reply to Bruce Richardson

Use a non-volatile uint64_t pointer to store to the descriptor ring. This will allow the compiler to optionally merge the stores as it sees best.

---
 drivers/net/intel/common/tx_scalar.h | 24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)
drivers/net/intel/common/tx_scalar.h +16 -8
index e9e9a826fa..71f96349c3 100644
@@ -174,6 +174,15 @@ struct ci_timestamp_queue_fns {
 	write_ts_tail_t write_ts_tail;
 };
 
+static inline void
+write_txd(volatile void *txd, uint64_t qw0, uint64_t qw1)
+{
+	uint64_t *txd_qw = __rte_assume_aligned(RTE_CAST_PTR(void *, txd), 16);
+
+	txd_qw[0] = rte_cpu_to_le_64(qw0);
+	txd_qw[1] = rte_cpu_to_le_64(qw1);
+}
+
 static inline uint16_t
 ci_xmit_pkts(struct ci_tx_queue *txq,
 	     struct rte_mbuf **tx_pkts,
@@ -307,8 +316,7 @@ ci_xmit_pkts(struct ci_tx_queue *txq,
 				txe->mbuf = NULL;
 			}
 
-			ctx_txd[0] = cd_qw0;
-			ctx_txd[1] = cd_qw1;
+			write_txd(ctx_txd, cd_qw0, cd_qw1);
 
 			txe->last_id = tx_last;
 			tx_id = txe->next_id;
@@ -355,12 +363,12 @@ ci_xmit_pkts(struct ci_tx_queue *txq,
 
 			while ((ol_flags & (RTE_MBUF_F_TX_TCP_SEG | RTE_MBUF_F_TX_UDP_SEG)) &&
 					unlikely(slen > CI_MAX_DATA_PER_TXD)) {
-				txd->buffer_addr = rte_cpu_to_le_64(buf_dma_addr);
-				txd->cmd_type_offset_bsz = rte_cpu_to_le_64(CI_TX_DESC_DTYPE_DATA |
+				const uint64_t cmd_type_offset_bsz = CI_TX_DESC_DTYPE_DATA |
 					((uint64_t)td_cmd << CI_TXD_QW1_CMD_S) |
 					((uint64_t)td_offset << CI_TXD_QW1_OFFSET_S) |
 					((uint64_t)CI_MAX_DATA_PER_TXD << CI_TXD_QW1_TX_BUF_SZ_S) |
-					((uint64_t)td_tag << CI_TXD_QW1_L2TAG1_S));
+					((uint64_t)td_tag << CI_TXD_QW1_L2TAG1_S);
+				write_txd(txd, buf_dma_addr, cmd_type_offset_bsz);
 
 				buf_dma_addr += CI_MAX_DATA_PER_TXD;
 				slen -= CI_MAX_DATA_PER_TXD;
@@ -376,12 +384,12 @@ ci_xmit_pkts(struct ci_tx_queue *txq,
 			if (m_seg->next == NULL)
 				td_cmd |= CI_TX_DESC_CMD_EOP;
 
-			txd->buffer_addr = rte_cpu_to_le_64(buf_dma_addr);
-			txd->cmd_type_offset_bsz = rte_cpu_to_le_64(CI_TX_DESC_DTYPE_DATA |
+			const uint64_t cmd_type_offset_bsz = CI_TX_DESC_DTYPE_DATA |
 				((uint64_t)td_cmd << CI_TXD_QW1_CMD_S) |
 				((uint64_t)td_offset << CI_TXD_QW1_OFFSET_S) |
 				((uint64_t)slen << CI_TXD_QW1_TX_BUF_SZ_S) |
-				((uint64_t)td_tag << CI_TXD_QW1_L2TAG1_S));
+				((uint64_t)td_tag << CI_TXD_QW1_L2TAG1_S);
+			write_txd(txd, buf_dma_addr, cmd_type_offset_bsz);
 
 			txe->last_id = tx_last;
 			tx_id = txe->next_id;
Signature · 1 line
2.51.0
#189 lore raw

RE: [PATCH v4 20/35] net/intel: write descriptors using non-volatile pointers

drivers/net/intel/common/tx_scalar.h struct ci_timestamp_queue_fns { · line 184

Quoted 9 lines
drivers/net/intel/common/tx_scalar.h +4 -0
+static inline void
+write_txd(volatile void *txd, uint64_t qw0, uint64_t qw1)
+{
+	uint64_t *txd_qw = __rte_assume_aligned(RTE_CAST_PTR(void *,

txd), 16);

drivers/net/intel/common/tx_scalar.h +4 -0
+
+	txd_qw[0] = rte_cpu_to_le_64(qw0);
+	txd_qw[1] = rte_cpu_to_le_64(qw1);
+}

How about using __rte_aligned() instead, something like this (untested):

struct __rte_aligned(16) txd_t {
	uint64_t	qw0;
	uint64_t	qw1;
};
*RTE_CAST_PTR(volatile struct txd_t *, txd) = {
	rte_cpu_to_le_64(qw0),
	rte_cpu_to_le_64(qw1)
};

And why strip the "volatile"?

#190 lore raw

Re: [PATCH v4 20/35] net/intel: write descriptors using non-volatile pointers

Quoted 12 lines · Morten Brørup

drivers/net/intel/common/tx_scalar.h struct ci_timestamp_queue_fns { · line 184

Quoted 9 lines
drivers/net/intel/common/tx_scalar.h +4 -0
+static inline void
+write_txd(volatile void *txd, uint64_t qw0, uint64_t qw1)
+{
+	uint64_t *txd_qw = __rte_assume_aligned(RTE_CAST_PTR(void *,

txd), 16);

drivers/net/intel/common/tx_scalar.h +4 -0
+
+	txd_qw[0] = rte_cpu_to_le_64(qw0);
+	txd_qw[1] = rte_cpu_to_le_64(qw1);
+}

How about using __rte_aligned() instead, something like this (untested):

Quoted 4 lines
struct __rte_aligned(16) txd_t {
	uint64_t	qw0;
	uint64_t	qw1;
};

I can see if this works for us...

Quoted 7 lines

*RTE_CAST_PTR(volatile struct txd_t *, txd) = { rte_cpu_to_le_64(qw0), rte_cpu_to_le_64(qw1) };

And why strip the "volatile"?

For the descriptor writes, it doesn't matter the order in which the descriptors and the descriptor fields are actually written, since the NIC relies upon the tail pointer update - which includes a fence - to inform it of when the descriptors are ready. The volatile is necessary for reads, though, which is why the ring is marked as such, but for Tx it prevents the compiler from opportunistically e.g. converting two 64-byte writes into a 128-byte write.

/Bruce

#191 lore raw

RE: [PATCH v4 20/35] net/intel: write descriptors using non-volatile pointers

Quoted 33 lines

From: Bruce Richardson [mailto:[email protected]]
Sent: Tuesday, 10 February 2026 10.04

Quoted 11 lines · Morten Brørup

drivers/net/intel/common/tx_scalar.h struct ci_timestamp_queue_fns { · line 184

Quoted 9 lines
drivers/net/intel/common/tx_scalar.h +4 -0
+static inline void
+write_txd(volatile void *txd, uint64_t qw0, uint64_t qw1)
+{
+	uint64_t *txd_qw = __rte_assume_aligned(RTE_CAST_PTR(void *,

txd), 16);

drivers/net/intel/common/tx_scalar.h +4 -0
+
+	txd_qw[0] = rte_cpu_to_le_64(qw0);
+	txd_qw[1] = rte_cpu_to_le_64(qw1);
+}

How about using __rte_aligned() instead, something like this

(untested):

Quoted 5 lines
struct __rte_aligned(16) txd_t {
	uint64_t	qw0;
	uint64_t	qw1;
};

I can see if this works for us...

Quoted 2 lines

*RTE_CAST_PTR(volatile struct txd_t *, txd) = {

rte_cpu_to_le_64(qw0),

Quoted 5 lines

rte_cpu_to_le_64(qw1) };

And why strip the "volatile"?

Quoted 11 lines

For the descriptor writes, it doesn't matter the order in which the descriptors and the descriptor fields are actually written, since the NIC
relies upon the tail pointer update - which includes a fence - to inform it
of when the descriptors are ready. The volatile is necessary for reads, though, which is why the ring is marked as such, but for Tx it prevents the
compiler from opportunistically e.g. converting two 64-byte writes into a
128-byte write.

Makes sense.
Suggest that you spread out a few comments about this at the relevant locations in the source code.

#192 lore raw

Re: [PATCH v4 20/35] net/intel: write descriptors using non-volatile pointers

Quoted 45 lines · Morten Brørup
Quoted 33 lines

From: Bruce Richardson [mailto:[email protected]]
Sent: Tuesday, 10 February 2026 10.04

Quoted 11 lines · Morten Brørup

drivers/net/intel/common/tx_scalar.h struct ci_timestamp_queue_fns { · line 184

Quoted 9 lines
drivers/net/intel/common/tx_scalar.h +4 -0
+static inline void
+write_txd(volatile void *txd, uint64_t qw0, uint64_t qw1)
+{
+	uint64_t *txd_qw = __rte_assume_aligned(RTE_CAST_PTR(void *,

txd), 16);

drivers/net/intel/common/tx_scalar.h +4 -0
+
+	txd_qw[0] = rte_cpu_to_le_64(qw0);
+	txd_qw[1] = rte_cpu_to_le_64(qw1);
+}

How about using __rte_aligned() instead, something like this

(untested):

Quoted 5 lines
struct __rte_aligned(16) txd_t {
	uint64_t	qw0;
	uint64_t	qw1;
};

I can see if this works for us...

Quoted 2 lines

*RTE_CAST_PTR(volatile struct txd_t *, txd) = {

rte_cpu_to_le_64(qw0),

Quoted 5 lines

rte_cpu_to_le_64(qw1) };

And why strip the "volatile"?

Quoted 11 lines

For the descriptor writes, it doesn't matter the order in which the descriptors and the descriptor fields are actually written, since the NIC
relies upon the tail pointer update - which includes a fence - to inform it
of when the descriptors are ready. The volatile is necessary for reads, though, which is why the ring is marked as such, but for Tx it prevents the
compiler from opportunistically e.g. converting two 64-byte writes into a
128-byte write.

Quoted 3 lines

Makes sense.
Suggest that you spread out a few comments about this at the relevant locations in the source code.

Adding an explanation as part of the write_txd function, which is where the volatile gets cast away.

/Bruce

#193 lore raw

Re: [PATCH v4 20/35] net/intel: write descriptors using non-volatile pointers

In reply to Morten Brørup
Quoted 17 lines · Morten Brørup

drivers/net/intel/common/tx_scalar.h struct ci_timestamp_queue_fns { · line 184

Quoted 9 lines
drivers/net/intel/common/tx_scalar.h +4 -0
+static inline void
+write_txd(volatile void *txd, uint64_t qw0, uint64_t qw1)
+{
+	uint64_t *txd_qw = __rte_assume_aligned(RTE_CAST_PTR(void *,

txd), 16);

drivers/net/intel/common/tx_scalar.h +4 -0
+
+	txd_qw[0] = rte_cpu_to_le_64(qw0);
+	txd_qw[1] = rte_cpu_to_le_64(qw1);
+}

How about using __rte_aligned() instead, something like this (untested):

struct __rte_aligned(16) txd_t {
	uint64_t	qw0;
	uint64_t	qw1;
};
Quoted 5 lines
*RTE_CAST_PTR(volatile struct txd_t *, txd) = {
	rte_cpu_to_le_64(qw0),
	rte_cpu_to_le_64(qw1)
};

This approach works fine, and allows me to drop the previous patch too. Updating to use a struct type in next revision.

/Bruce

#194 lore raw

PATCH v4 21/35 net/intel: remove unnecessary flag clearing

In reply to Bruce Richardson

When cleaning the Tx ring, there is no need to zero out the done flag from the completed entry. That flag will be automatically cleared when the descriptor is next written. This gives a small performance benefit.

---
 drivers/net/intel/common/tx_scalar.h | 7 -------
 1 file changed, 7 deletions(-)
drivers/net/intel/common/tx_scalar.h +0 -7
index 71f96349c3..3e54cd7607 100644
@@ -46,13 +46,6 @@ ci_tx_xmit_cleanup(struct ci_tx_queue *txq)
 	else
 		nb_tx_to_clean = (uint16_t)(desc_to_clean_to - last_desc_cleaned);
 
-	/* The last descriptor to clean is done, so that means all the
-	 * descriptors from the last descriptor that was cleaned
-	 * up to the last descriptor with the RS bit set
-	 * are done. Only reset the threshold descriptor.
-	 */
-	txd[desc_to_clean_to].cmd_type_offset_bsz = 0;
-
 	/* Update the txq to reflect the last descriptor that was cleaned */
 	txq->last_desc_cleaned = desc_to_clean_to;
 	txq->nb_tx_free = (uint16_t)(txq->nb_tx_free + nb_tx_to_clean);
Signature · 1 line
2.51.0
Acked-by on v4 21/35
#195 lore raw

Re: [PATCH v4 21/35] net/intel: remove unnecessary flag clearing

Quoted 6 lines · Bruce Richardson

When cleaning the Tx ring, there is no need to zero out the done flag from the completed entry. That flag will be automatically cleared when the descriptor is next written. This gives a small performance benefit.

---

Signature · 2 lines
Thanks,
Anatoly
#196 lore raw

PATCH v4 22/35 net/intel: mark mid-burst ring cleanup as unlikely

In reply to Bruce Richardson

It should rarely be the case that we need to cleanup the descriptor ring mid-burst, so mark as unlikely to help performance.

---
 drivers/net/intel/common/tx_scalar.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/intel/common/tx_scalar.h +1 -1
index 3e54cd7607..cee8f11c7f 100644
@@ -266,7 +266,7 @@ ci_xmit_pkts(struct ci_tx_queue *txq,
 		if (tx_last >= txq->nb_tx_desc)
 			tx_last = (uint16_t)(tx_last - txq->nb_tx_desc);
 
-		if (nb_used > txq->nb_tx_free) {
+		if (unlikely(nb_used > txq->nb_tx_free)) {
 			if (ci_tx_xmit_cleanup(txq) != 0) {
 				if (nb_tx == 0)
 					return 0;
Signature · 1 line
2.51.0
#197 lore raw

Re: [PATCH v4 22/35] net/intel: mark mid-burst ring cleanup as unlikely

Quoted 5 lines · Bruce Richardson

It should rarely be the case that we need to cleanup the descriptor ring mid-burst, so mark as unlikely to help performance.

---

Does it measurably help performance? I'm by no means a performance person so this isn't really my wheelhouse, but I remember enough patches removing "unlikely() for performance reasons" to get suspicious!

Signature · 2 lines
Thanks,
Anatoly
#198 lore raw

Re: [PATCH v4 22/35] net/intel: mark mid-burst ring cleanup as unlikely

Quoted 4 lines · Anatoly
Quoted 3 lines · Bruce Richardson

It should rarely be the case that we need to cleanup the descriptor ring mid-burst, so mark as unlikely to help performance.

Quoted 8 lines
Quoted 2 lines

---

Does it measurably help performance? I'm by no means a performance person so this isn't really my wheelhouse, but I remember enough patches removing "unlikely() for performance reasons" to get suspicious!

Yes, I tend to be suspicous too. I will reverify and, if not measurable, will drop this patch from the set.

/Bruce

#199 lore raw

Re: [PATCH v4 22/35] net/intel: mark mid-burst ring cleanup as unlikely

Quoted 8 lines · Bruce Richardson
Quoted 7 lines · Anatoly
Quoted 5 lines · Bruce Richardson

It should rarely be the case that we need to cleanup the descriptor ring mid-burst, so mark as unlikely to help performance.

---

Quoted 8 lines
Quoted 5 lines

Does it measurably help performance? I'm by no means a performance person so this isn't really my wheelhouse, but I remember enough patches removing "unlikely() for performance reasons" to get suspicious!

Yes, I tend to be suspicous too. I will reverify and, if not measurable, will drop this patch from the set.

This patch doesn't help performance when tested at the end of the series. Will drop from v5.

#200 lore raw

PATCH v4 23/35 net/intel: add special handling for single desc packets

In reply to Bruce Richardson

Within the scalar packets, add a shortcut path for packets that don't use TSO and have only a single data descriptor.

---
 drivers/net/intel/common/tx_scalar.h | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
drivers/net/intel/common/tx_scalar.h +26 -0
index cee8f11c7f..342e271c5f 100644
@@ -298,6 +298,31 @@ ci_xmit_pkts(struct ci_tx_queue *txq,
 			ci_txd_enable_checksum(ol_flags, &td_cmd,
 						&td_offset, tx_offload);
 
+		/* special case for single descriptor packet, without TSO offload */
+		if (nb_used == 1 &&
+				(ol_flags & (RTE_MBUF_F_TX_TCP_SEG | RTE_MBUF_F_TX_UDP_SEG)) == 0) {
+			txd = &ci_tx_ring[tx_id];
+			tx_id = txe->next_id;
+
+			if (txe->mbuf)
+				rte_pktmbuf_free_seg(txe->mbuf);
+			*txe = (struct ci_tx_entry){
+				.mbuf = tx_pkt, .last_id = tx_last, .next_id = tx_id
+			};
+
+			/* Setup TX Descriptor */
+			td_cmd |= CI_TX_DESC_CMD_EOP;
+			const uint64_t cmd_type_offset_bsz = CI_TX_DESC_DTYPE_DATA |
+				((uint64_t)td_cmd << CI_TXD_QW1_CMD_S) |
+				((uint64_t)td_offset << CI_TXD_QW1_OFFSET_S) |
+				((uint64_t)tx_pkt->data_len << CI_TXD_QW1_TX_BUF_SZ_S) |
+				((uint64_t)td_tag << CI_TXD_QW1_L2TAG1_S);
+			write_txd(txd, rte_mbuf_data_iova(tx_pkt), cmd_type_offset_bsz);
+
+			txe = &sw_ring[tx_id];
+			goto end_pkt;
+		}
+
 		if (nb_ctx) {
 			/* Setup TX context descriptor if required */
 			uint64_t *ctx_txd = RTE_CAST_PTR(uint64_t *, &ci_tx_ring[tx_id]);
@@ -389,6 +414,7 @@ ci_xmit_pkts(struct ci_tx_queue *txq,
 			txe = txn;
 			m_seg = m_seg->next;
 		} while (m_seg);
+end_pkt:
 		txq->nb_tx_used = (uint16_t)(txq->nb_tx_used + nb_used);
 		txq->nb_tx_free = (uint16_t)(txq->nb_tx_free - nb_used);
 
Signature · 1 line
2.51.0
#202 lore raw

PATCH v4 24/35 net/intel: use separate array for desc status tracking

In reply to Bruce Richardson

Rather than writing a last_id for each individual descriptor, we can write one only for places where the "report status" (RS) bit is set, i.e. the descriptors which will be written back when done. The method used for marking what descriptors are free is also changed in the process, even if the last descriptor with the "done" bits set is past the expected point, we only track up to the expected point, and leave the rest to be counted as freed next time. This means that we always have the RS/DD bits set at fixed intervals, and we always track free slots in units of the same tx_free_thresh intervals.

---
 drivers/net/intel/common/tx.h             |  4 ++
 drivers/net/intel/common/tx_scalar.h      | 66 +++++++++++------------
 drivers/net/intel/cpfl/cpfl_rxtx.c        | 17 ++++++
 drivers/net/intel/i40e/i40e_rxtx.c        | 20 +++++++
 drivers/net/intel/iavf/iavf_rxtx.c        | 19 +++++++
 drivers/net/intel/ice/ice_rxtx.c          | 20 +++++++
 drivers/net/intel/idpf/idpf_common_rxtx.c |  7 +++
 drivers/net/intel/idpf/idpf_rxtx.c        | 13 +++++
 8 files changed, 132 insertions(+), 34 deletions(-)
drivers/net/intel/common/tx.h +4 -0
index f0229314a0..e7d79eb7d0 100644
@@ -127,6 +127,8 @@ struct ci_tx_queue {
 		struct ci_tx_entry *sw_ring; /* virtual address of SW ring */
 		struct ci_tx_entry_vec *sw_ring_vec;
 	};
+	/* Scalar TX path: Array tracking last_id at each RS threshold boundary */
+	uint16_t *rs_last_id;
 	uint16_t nb_tx_desc;           /* number of TX descriptors */
 	uint16_t tx_tail; /* current value of tail register */
 	uint16_t nb_tx_used; /* number of TX desc used since RS bit set */
@@ -140,6 +142,8 @@ struct ci_tx_queue {
 	uint16_t tx_free_thresh;
 	/* Number of TX descriptors to use before RS bit is set. */
 	uint16_t tx_rs_thresh;
+	/* Scalar TX path: log2 of tx_rs_thresh for efficient bit operations */
+	uint8_t log2_rs_thresh;
 	uint16_t port_id;  /* Device port identifier. */
 	uint16_t queue_id; /* TX queue index. */
 	uint16_t reg_idx;
drivers/net/intel/common/tx_scalar.h +32 -34

128 lines not on this page · raw message

drivers/net/intel/cpfl/cpfl_rxtx.c +17 -0
index bc5bec65f0..e7a98ed4f6 100644
@@ -5,6 +5,7 @@
 #include <ethdev_driver.h>
 #include <rte_net.h>
 #include <rte_vect.h>
+#include <rte_bitops.h>
 
 #include "cpfl_ethdev.h"
 #include "cpfl_rxtx.h"
@@ -330,6 +331,7 @@ cpfl_tx_queue_release(void *txq)
 
 	ci_txq_release_all_mbufs(q, q->vector_tx);
 	rte_free(q->sw_ring);
+	rte_free(q->rs_last_id);
 	rte_memzone_free(q->mz);
 	rte_free(cpfl_txq);
 }
@@ -572,6 +574,7 @@ cpfl_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 
 	txq->nb_tx_desc = nb_desc;
 	txq->tx_rs_thresh = tx_rs_thresh;
+	txq->log2_rs_thresh = rte_log2_u32(tx_rs_thresh);
 	txq->tx_free_thresh = tx_free_thresh;
 	txq->queue_id = vport->chunks_info.tx_start_qid + queue_idx;
 	txq->port_id = dev->data->port_id;
@@ -605,6 +608,17 @@ cpfl_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 		goto err_sw_ring_alloc;
 	}
 
+	/* Allocate RS last_id tracking array */
+	uint16_t num_rs_buckets = nb_desc / tx_rs_thresh;
+	txq->rs_last_id = rte_zmalloc_socket("cpfl tx rs_last_id",
+			sizeof(txq->rs_last_id[0]) * num_rs_buckets,
+			RTE_CACHE_LINE_SIZE, socket_id);
+	if (txq->rs_last_id == NULL) {
+		PMD_INIT_LOG(ERR, "Failed to allocate memory for RS last_id array");
+		ret = -ENOMEM;
+		goto err_rs_last_id_alloc;
+	}
+
 	if (!is_splitq) {
 		txq->ci_tx_ring = mz->addr;
 		idpf_qc_single_tx_queue_reset(txq);
@@ -628,6 +642,9 @@ cpfl_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 	return 0;
 
 err_complq_setup:
+	rte_free(txq->rs_last_id);
+err_rs_last_id_alloc:
+	rte_free(txq->sw_ring);
 err_sw_ring_alloc:
 	cpfl_dma_zone_release(mz);
 err_mz_reserve:
drivers/net/intel/i40e/i40e_rxtx.c +20 -0
index dfd2213020..b554bc6c31 100644
@@ -24,6 +24,7 @@
 #include <rte_ip.h>
 #include <rte_net.h>
 #include <rte_vect.h>
+#include <rte_bitops.h>
 
 #include "i40e_logs.h"
 #include "base/i40e_prototype.h"
@@ -2280,6 +2281,13 @@ i40e_dev_tx_queue_setup(struct rte_eth_dev *dev,
 			     (int)queue_idx);
 		return I40E_ERR_PARAM;
 	}
+	if (!rte_is_power_of_2(tx_rs_thresh)) {
+		PMD_INIT_LOG(ERR, "tx_rs_thresh must be a power of 2. (tx_rs_thresh=%u port=%d queue=%d)",
+			     (unsigned int)tx_rs_thresh,
+			     (int)dev->data->port_id,
+			     (int)queue_idx);
+		return I40E_ERR_PARAM;
+	}
 	if ((tx_rs_thresh > 1) && (tx_conf->tx_thresh.wthresh != 0)) {
 		PMD_INIT_LOG(ERR, "TX WTHRESH must be set to 0 if "
 			     "tx_rs_thresh is greater than 1. "
@@ -2321,6 +2329,7 @@ i40e_dev_tx_queue_setup(struct rte_eth_dev *dev,
 	txq->mz = tz;
 	txq->nb_tx_desc = nb_desc;
 	txq->tx_rs_thresh = tx_rs_thresh;
+	txq->log2_rs_thresh = rte_log2_u32(tx_rs_thresh);
 	txq->tx_free_thresh = tx_free_thresh;
 	txq->queue_id = queue_idx;
 	txq->reg_idx = reg_idx;
@@ -2346,6 +2355,16 @@ i40e_dev_tx_queue_setup(struct rte_eth_dev *dev,
 		return -ENOMEM;
 	}
 
+	/* Allocate RS last_id tracking array */
+	uint16_t num_rs_buckets = nb_desc / tx_rs_thresh;
+	txq->rs_last_id = rte_zmalloc_socket(NULL, sizeof(txq->rs_last_id[0]) * num_rs_buckets,
+			RTE_CACHE_LINE_SIZE, socket_id);
+	if (txq->rs_last_id == NULL) {
+		i40e_tx_queue_release(txq);
+		PMD_DRV_LOG(ERR, "Failed to allocate memory for RS last_id array");
+		return -ENOMEM;
+	}
+
 	i40e_reset_tx_queue(txq);
 	txq->q_set = TRUE;
 
@@ -2391,6 +2410,7 @@ i40e_tx_queue_release(void *txq)
 
 	ci_txq_release_all_mbufs(q, false);
 	rte_free(q->sw_ring);
+	rte_free(q->rs_last_id);
 	rte_memzone_free(q->mz);
 	rte_free(q);
 }
drivers/net/intel/iavf/iavf_rxtx.c +19 -0
index 2ea00e1975..e7187f713d 100644
@@ -25,6 +25,7 @@
 #include <rte_ip.h>
 #include <rte_net.h>
 #include <rte_vect.h>
+#include <rte_bitops.h>
 #include <rte_vxlan.h>
 #include <rte_gtp.h>
 #include <rte_geneve.h>
@@ -194,6 +195,11 @@ check_tx_thresh(uint16_t nb_desc, uint16_t tx_rs_thresh,
 			     tx_rs_thresh, nb_desc);
 		return -EINVAL;
 	}
+	if (!rte_is_power_of_2(tx_rs_thresh)) {
+		PMD_INIT_LOG(ERR, "tx_rs_thresh must be a power of 2. (tx_rs_thresh=%u)",
+			     tx_rs_thresh);
+		return -EINVAL;
+	}
 
 	return 0;
 }
@@ -801,6 +807,7 @@ iavf_dev_tx_queue_setup(struct rte_eth_dev *dev,
 
 	txq->nb_tx_desc = nb_desc;
 	txq->tx_rs_thresh = tx_rs_thresh;
+	txq->log2_rs_thresh = rte_log2_u32(tx_rs_thresh);
 	txq->tx_free_thresh = tx_free_thresh;
 	txq->queue_id = queue_idx;
 	txq->port_id = dev->data->port_id;
@@ -826,6 +833,17 @@ iavf_dev_tx_queue_setup(struct rte_eth_dev *dev,
 		return -ENOMEM;
 	}
 
+	/* Allocate RS last_id tracking array */
+	uint16_t num_rs_buckets = nb_desc / tx_rs_thresh;
+	txq->rs_last_id = rte_zmalloc_socket(NULL, sizeof(txq->rs_last_id[0]) * num_rs_buckets,
+			RTE_CACHE_LINE_SIZE, socket_id);
+	if (txq->rs_last_id == NULL) {
+		PMD_INIT_LOG(ERR, "Failed to allocate memory for RS last_id array");
+		rte_free(txq->sw_ring);
+		rte_free(txq);
+		return -ENOMEM;
+	}
+
 	/* Allocate TX hardware ring descriptors. */
 	ring_size = sizeof(struct ci_tx_desc) * IAVF_MAX_RING_DESC;
 	ring_size = RTE_ALIGN(ring_size, IAVF_DMA_MEM_ALIGN);
@@ -1050,6 +1068,7 @@ iavf_dev_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid)
 
 	ci_txq_release_all_mbufs(q, q->use_ctx);
 	rte_free(q->sw_ring);
+	rte_free(q->rs_last_id);
 	rte_memzone_free(q->mz);
 	rte_free(q);
 }
drivers/net/intel/ice/ice_rxtx.c +20 -0
index 111cb5e37f..2915223397 100644
@@ -5,6 +5,7 @@
 #include <ethdev_driver.h>
 #include <rte_net.h>
 #include <rte_vect.h>
+#include <rte_bitops.h>
 
 #include "ice_rxtx.h"
 #include "ice_rxtx_vec_common.h"
@@ -1589,6 +1590,13 @@ ice_tx_queue_setup(struct rte_eth_dev *dev,
 			     (int)queue_idx);
 		return -EINVAL;
 	}
+	if (!rte_is_power_of_2(tx_rs_thresh)) {
+		PMD_INIT_LOG(ERR, "tx_rs_thresh must be a power of 2. (tx_rs_thresh=%u port=%d queue=%d)",
+			     (unsigned int)tx_rs_thresh,
+			     (int)dev->data->port_id,
+			     (int)queue_idx);
+		return -EINVAL;
+	}
 	if (tx_rs_thresh > 1 && tx_conf->tx_thresh.wthresh != 0) {
 		PMD_INIT_LOG(ERR, "TX WTHRESH must be set to 0 if "
 			     "tx_rs_thresh is greater than 1. "
@@ -1631,6 +1639,7 @@ ice_tx_queue_setup(struct rte_eth_dev *dev,
 	txq->mz = tz;
 	txq->nb_tx_desc = nb_desc;
 	txq->tx_rs_thresh = tx_rs_thresh;
+	txq->log2_rs_thresh = rte_log2_u32(tx_rs_thresh);
 	txq->tx_free_thresh = tx_free_thresh;
 	txq->queue_id = queue_idx;
 
@@ -1657,6 +1666,16 @@ ice_tx_queue_setup(struct rte_eth_dev *dev,
 		return -ENOMEM;
 	}
 
+	/* Allocate RS last_id tracking array */
+	uint16_t num_rs_buckets = nb_desc / tx_rs_thresh;
+	txq->rs_last_id = rte_zmalloc_socket(NULL, sizeof(txq->rs_last_id[0]) * num_rs_buckets,
+			RTE_CACHE_LINE_SIZE, socket_id);
+	if (txq->rs_last_id == NULL) {
+		ice_tx_queue_release(txq);
+		PMD_INIT_LOG(ERR, "Failed to allocate memory for RS last_id array");
+		return -ENOMEM;
+	}
+
 	if (vsi->type == ICE_VSI_PF && (offloads & RTE_ETH_TX_OFFLOAD_SEND_ON_TIMESTAMP)) {
 		if (hw->phy_model != ICE_PHY_E830) {
 			ice_tx_queue_release(txq);
@@ -1729,6 +1748,7 @@ ice_tx_queue_release(void *txq)
 
 	ci_txq_release_all_mbufs(q, false);
 	rte_free(q->sw_ring);
+	rte_free(q->rs_last_id);
 	if (q->tsq) {
 		rte_memzone_free(q->tsq->ts_mz);
 		rte_free(q->tsq);
drivers/net/intel/idpf/idpf_common_rxtx.c +7 -0
index bca5f13c8e..8859bcca86 100644
@@ -5,6 +5,7 @@
 #include <eal_export.h>
 #include <rte_mbuf_dyn.h>
 #include <rte_errno.h>
+#include <rte_bitops.h>
 
 #include "idpf_common_rxtx.h"
 #include "idpf_common_device.h"
@@ -73,6 +74,11 @@ idpf_qc_tx_thresh_check(uint16_t nb_desc, uint16_t tx_rs_thresh,
 			tx_rs_thresh, nb_desc);
 		return -EINVAL;
 	}
+	if (!rte_is_power_of_2(tx_rs_thresh)) {
+		DRV_LOG(ERR, "tx_rs_thresh must be a power of 2. (tx_rs_thresh=%u)",
+			tx_rs_thresh);
+		return -EINVAL;
+	}
 
 	return 0;
 }
@@ -333,6 +339,7 @@ idpf_qc_tx_queue_release(void *txq)
 	}
 
 	ci_txq_release_all_mbufs(q, false);
+	rte_free(q->rs_last_id);
 	rte_free(q->sw_ring);
 	rte_memzone_free(q->mz);
 	rte_free(q);
drivers/net/intel/idpf/idpf_rxtx.c +13 -0
index 0de54d9305..9420200f6d 100644
@@ -447,6 +447,7 @@ idpf_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 
 	txq->nb_tx_desc = nb_desc;
 	txq->tx_rs_thresh = tx_rs_thresh;
+	txq->log2_rs_thresh = rte_log2_u32(tx_rs_thresh);
 	txq->tx_free_thresh = tx_free_thresh;
 	txq->queue_id = vport->chunks_info.tx_start_qid + queue_idx;
 	txq->port_id = dev->data->port_id;
@@ -480,6 +481,15 @@ idpf_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 		goto err_sw_ring_alloc;
 	}
 
+	txq->rs_last_id = rte_zmalloc_socket("idpf tx rs_last_id",
+			sizeof(txq->rs_last_id[0]) * (nb_desc >> txq->log2_rs_thresh),
+			RTE_CACHE_LINE_SIZE, socket_id);
+	if (txq->rs_last_id == NULL) {
+		PMD_INIT_LOG(ERR, "Failed to allocate memory for TX RS tracking");
+		ret = -ENOMEM;
+		goto err_rs_last_id_alloc;
+	}
+
 	if (!is_splitq) {
 		txq->ci_tx_ring = mz->addr;
 		idpf_qc_single_tx_queue_reset(txq);
@@ -502,6 +512,9 @@ idpf_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 	return 0;
 
 err_complq_setup:
+	rte_free(txq->rs_last_id);
+err_rs_last_id_alloc:
+	rte_free(txq->sw_ring);
 err_sw_ring_alloc:
 	idpf_dma_zone_release(mz);
 err_mz_reserve:
Signature · 1 line
2.51.0
Acked-by on v4 24/35
#203 lore raw

Re: [PATCH v4 24/35] net/intel: use separate array for desc status tracking

Quoted 18 lines · Bruce Richardson

Rather than writing a last_id for each individual descriptor, we can write one only for places where the "report status" (RS) bit is set, i.e. the descriptors which will be written back when done. The method used for marking what descriptors are free is also changed in the process, even if the last descriptor with the "done" bits set is past the expected point, we only track up to the expected point, and leave the rest to be counted as freed next time. This means that we always have the RS/DD bits set at fixed intervals, and we always track free slots in units of the same tx_free_thresh intervals.

---

  	if (!is_splitq) {
  		txq->ci_tx_ring = mz->addr;
  		idpf_qc_single_tx_queue_reset(txq);

drivers/net/intel/cpfl/cpfl_rxtx.c cpfl_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx, · line 647

Quoted 6 lines
drivers/net/intel/cpfl/cpfl_rxtx.c +3 -0
@@ -628,6 +642,9 @@ cpfl_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
  	return 0;
 
  err_complq_setup:
+	rte_free(txq->rs_last_id);
+err_rs_last_id_alloc:
+	rte_free(txq->sw_ring);

This looks like this free wasn't there before and it should've been. Separate it out as a bugfix to stable?

<snip>

drivers/net/intel/cpfl/cpfl_rxtx.c idpf_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx, · line 517

Quoted 9 lines
drivers/net/intel/cpfl/cpfl_rxtx.c +3 -0
  		txq->ci_tx_ring = mz->addr;
  		idpf_qc_single_tx_queue_reset(txq);
@@ -502,6 +512,9 @@ idpf_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
  	return 0;
 
  err_complq_setup:
+	rte_free(txq->rs_last_id);
+err_rs_last_id_alloc:
+	rte_free(txq->sw_ring);

Same, bugfix to stable?

drivers/net/intel/idpf/idpf_rxtx.c idpf_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx, · line 520

Quoted 3 lines
drivers/net/intel/idpf/idpf_rxtx.c +0 -0
  err_sw_ring_alloc:
  	idpf_dma_zone_release(mz);
  err_mz_reserve:

Otherwise LGTM

Signature · 2 lines
Thanks,
Anatoly
#204 lore raw

PATCH v4 25/35 net/ixgbe: use separate array for desc status tracking

In reply to Bruce Richardson

Due to significant differences in the ixgbe transmit descriptors, the ixgbe driver does not use the common scalar Tx functionality. Update the driver directly so its use of the rs_last_id array matches that of the common Tx code.

---
 drivers/net/intel/ixgbe/ixgbe_rxtx.c | 86 +++++++++++++++-------------
 1 file changed, 47 insertions(+), 39 deletions(-)
drivers/net/intel/ixgbe/ixgbe_rxtx.c +47 -39
index 0af04c9b0d..3e37ccc50d 100644
@@ -43,6 +43,7 @@
 #include <rte_ip.h>
 #include <rte_net.h>
 #include <rte_vect.h>
+#include <rte_bitops.h>
 
 #include "ixgbe_logs.h"
 #include "base/ixgbe_api.h"
@@ -571,57 +572,35 @@ tx_desc_ol_flags_to_cmdtype(uint64_t ol_flags)
 static inline int
 ixgbe_xmit_cleanup(struct ci_tx_queue *txq)
 {
-	struct ci_tx_entry *sw_ring = txq->sw_ring;
 	volatile union ixgbe_adv_tx_desc *txr = txq->ixgbe_tx_ring;
-	uint16_t last_desc_cleaned = txq->last_desc_cleaned;
-	uint16_t nb_tx_desc = txq->nb_tx_desc;
-	uint16_t desc_to_clean_to;
-	uint16_t nb_tx_to_clean;
-	uint32_t status;
+	const uint16_t last_desc_cleaned = txq->last_desc_cleaned;
+	const uint16_t nb_tx_desc = txq->nb_tx_desc;
 
-	/* Determine the last descriptor needing to be cleaned */
-	desc_to_clean_to = (uint16_t)(last_desc_cleaned + txq->tx_rs_thresh);
-	if (desc_to_clean_to >= nb_tx_desc)
-		desc_to_clean_to = (uint16_t)(desc_to_clean_to - nb_tx_desc);
+	const uint16_t rs_idx = (last_desc_cleaned == nb_tx_desc - 1) ?
+			0 :
+			(last_desc_cleaned + 1) >> txq->log2_rs_thresh;
+	uint16_t desc_to_clean_to = (rs_idx << txq->log2_rs_thresh) + (txq->tx_rs_thresh - 1);
 
-	/* Check to make sure the last descriptor to clean is done */
-	desc_to_clean_to = sw_ring[desc_to_clean_to].last_id;
-	status = txr[desc_to_clean_to].wb.status;
+	uint32_t status = txr[txq->rs_last_id[rs_idx]].wb.status;
 	if (!(status & rte_cpu_to_le_32(IXGBE_TXD_STAT_DD))) {
 		PMD_TX_LOG(DEBUG,
 			   "TX descriptor %4u is not done"
 			   "(port=%d queue=%d)",
-			   desc_to_clean_to,
+			   txq->rs_last_id[rs_idx],
 			   txq->port_id, txq->queue_id);
 		/* Failed to clean any descriptors, better luck next time */
 		return -(1);
 	}
 
-	/* Figure out how many descriptors will be cleaned */
-	if (last_desc_cleaned > desc_to_clean_to)
-		nb_tx_to_clean = (uint16_t)((nb_tx_desc - last_desc_cleaned) +
-							desc_to_clean_to);
-	else
-		nb_tx_to_clean = (uint16_t)(desc_to_clean_to -
-						last_desc_cleaned);
-
 	PMD_TX_LOG(DEBUG,
 		   "Cleaning %4u TX descriptors: %4u to %4u "
 		   "(port=%d queue=%d)",
-		   nb_tx_to_clean, last_desc_cleaned, desc_to_clean_to,
+		   txq->tx_rs_thresh, last_desc_cleaned, desc_to_clean_to,
 		   txq->port_id, txq->queue_id);
 
-	/*
-	 * The last descriptor to clean is done, so that means all the
-	 * descriptors from the last descriptor that was cleaned
-	 * up to the last descriptor with the RS bit set
-	 * are done. Only reset the threshold descriptor.
-	 */
-	txr[desc_to_clean_to].wb.status = 0;
-
 	/* Update the txq to reflect the last descriptor that was cleaned */
 	txq->last_desc_cleaned = desc_to_clean_to;
-	txq->nb_tx_free = (uint16_t)(txq->nb_tx_free + nb_tx_to_clean);
+	txq->nb_tx_free = (uint16_t)(txq->nb_tx_free + txq->tx_rs_thresh);
 
 	/* No Error */
 	return 0;
@@ -749,6 +728,9 @@ ixgbe_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 		if (tx_last >= txq->nb_tx_desc)
 			tx_last = (uint16_t) (tx_last - txq->nb_tx_desc);
 
+		/* Track the RS threshold bucket at packet start */
+		uint16_t pkt_rs_idx = (uint16_t)(tx_id >> txq->log2_rs_thresh);
+
 		PMD_TX_LOG(DEBUG, "port_id=%u queue_id=%u pktlen=%u"
 			   " tx_first=%u tx_last=%u",
 			   (unsigned) txq->port_id,
@@ -876,7 +858,6 @@ ixgbe_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 					tx_offload,
 					rte_security_dynfield(tx_pkt));
 
-				txe->last_id = tx_last;
 				tx_id = txe->next_id;
 				txe = txn;
 			}
@@ -922,7 +903,6 @@ ixgbe_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 				rte_cpu_to_le_32(cmd_type_len | slen);
 			txd->read.olinfo_status =
 				rte_cpu_to_le_32(olinfo_status);
-			txe->last_id = tx_last;
 			tx_id = txe->next_id;
 			txe = txn;
 			m_seg = m_seg->next;
@@ -935,8 +915,18 @@ ixgbe_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 		txq->nb_tx_used = (uint16_t)(txq->nb_tx_used + nb_used);
 		txq->nb_tx_free = (uint16_t)(txq->nb_tx_free - nb_used);
 
-		/* Set RS bit only on threshold packets' last descriptor */
-		if (txq->nb_tx_used >= txq->tx_rs_thresh) {
+		/*
+		 * Check if packet crosses into a new RS threshold bucket.
+		 * The RS bit is set on the last descriptor when we move from one bucket to another.
+		 * For example, with tx_rs_thresh=32 and a 5-descriptor packet using slots 30-34:
+		 *   - pkt_rs_idx = 30 >> 5 = 0 (started in bucket 0)
+		 *   - tx_last = 34, so 35 >> 5 = 1 (next packet is in bucket 1)
+		 *   - Since 0 != 1, set RS bit on descriptor 34, and record rs_last_id[0] = 34
+		 */
+		uint16_t next_rs_idx = ((tx_last + 1) >> txq->log2_rs_thresh);
+
+		if (next_rs_idx != pkt_rs_idx) {
+			/* Packet crossed into a new bucket - set RS bit on last descriptor */
 			PMD_TX_LOG(DEBUG,
 				   "Setting RS bit on TXD id="
 				   "%4u (port=%d queue=%d)",
@@ -944,9 +934,8 @@ ixgbe_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 
 			cmd_type_len |= IXGBE_TXD_CMD_RS;
 
-			/* Update txq RS bit counters */
-			txq->nb_tx_used = 0;
-			txp = NULL;
+			/* Record the last descriptor ID for the bucket we're leaving */
+			txq->rs_last_id[pkt_rs_idx] = tx_last;
 		} else
 			txp = txd;
 
@@ -2521,6 +2510,7 @@ ixgbe_tx_queue_release(struct ci_tx_queue *txq)
 	if (txq != NULL && txq->ops != NULL) {
 		ci_txq_release_all_mbufs(txq, false);
 		txq->ops->free_swring(txq);
+		rte_free(txq->rs_last_id);
 		rte_memzone_free(txq->mz);
 		rte_free(txq);
 	}
@@ -2825,6 +2815,13 @@ ixgbe_dev_tx_queue_setup(struct rte_eth_dev *dev,
 			     (int)dev->data->port_id, (int)queue_idx);
 		return -(EINVAL);
 	}
+	if (!rte_is_power_of_2(tx_rs_thresh)) {
+		PMD_INIT_LOG(ERR, "tx_rs_thresh must be a power of 2. (tx_rs_thresh=%u port=%d queue=%d)",
+			     (unsigned int)tx_rs_thresh,
+			     (int)dev->data->port_id,
+			     (int)queue_idx);
+		return -(EINVAL);
+	}
 
 	/*
 	 * If rs_bit_thresh is greater than 1, then TX WTHRESH should be
@@ -2870,6 +2867,7 @@ ixgbe_dev_tx_queue_setup(struct rte_eth_dev *dev,
 	txq->mz = tz;
 	txq->nb_tx_desc = nb_desc;
 	txq->tx_rs_thresh = tx_rs_thresh;
+	txq->log2_rs_thresh = rte_log2_u32(tx_rs_thresh);
 	txq->tx_free_thresh = tx_free_thresh;
 	txq->pthresh = tx_conf->tx_thresh.pthresh;
 	txq->hthresh = tx_conf->tx_thresh.hthresh;
@@ -2913,6 +2911,16 @@ ixgbe_dev_tx_queue_setup(struct rte_eth_dev *dev,
 	PMD_INIT_LOG(DEBUG, "sw_ring=%p hw_ring=%p dma_addr=0x%"PRIx64,
 		     txq->sw_ring, txq->ixgbe_tx_ring, txq->tx_ring_dma);
 
+	/* Allocate RS last_id tracking array */
+	uint16_t num_rs_buckets = nb_desc / tx_rs_thresh;
+	txq->rs_last_id = rte_zmalloc_socket(NULL, sizeof(txq->rs_last_id[0]) * num_rs_buckets,
+			RTE_CACHE_LINE_SIZE, socket_id);
+	if (txq->rs_last_id == NULL) {
+		ixgbe_tx_queue_release(txq);
+		PMD_DRV_LOG(ERR, "Failed to allocate memory for RS last_id array");
+		return -ENOMEM;
+	}
+
 	/* set up vector or scalar TX function as appropriate */
 	ixgbe_set_tx_function(dev, txq);
 
Signature · 1 line
2.51.0
Acked-by on v4 25/35
#205 lore raw

Re: [PATCH v4 25/35] net/ixgbe: use separate array for desc status tracking

Quoted 7 lines · Bruce Richardson

Due to significant differences in the ixgbe transmit descriptors, the ixgbe driver does not use the common scalar Tx functionality. Update the driver directly so its use of the rs_last_id array matches that of the common Tx code.

---

Signature · 2 lines
Thanks,
Anatoly