Skip to contentSkip to conversation

common/idpf: rework single queue Tx function

PATCH Superseded Simei Su 4 participants 16 messages Aug 25, 2023 – Sep 14, 2023 Network drivers

lore
Share & tools
lore

Simei Su

author
#0 lore raw

PATCH 1/1 common/idpf: rework single queue Tx function

This patch replaces flex Tx descriptor structure with base Tx descriptor.

---
 drivers/common/idpf/idpf_common_rxtx.c        | 72 +++++++++++++------
 drivers/common/idpf/idpf_common_rxtx.h        |  2 +-
 drivers/common/idpf/idpf_common_rxtx_avx512.c | 36 +++++-----
 drivers/net/idpf/idpf_rxtx.c                  |  2 +-
 4 files changed, 69 insertions(+), 43 deletions(-)
drivers/common/idpf/idpf_common_rxtx.c +49 -23
index fc87e3e243..67c124a614 100644
@@ -276,14 +276,14 @@ idpf_qc_single_tx_queue_reset(struct idpf_tx_queue *txq)
 	}
 
 	txe = txq->sw_ring;
-	size = sizeof(struct idpf_flex_tx_desc) * txq->nb_tx_desc;
+	size = sizeof(struct idpf_base_tx_desc) * txq->nb_tx_desc;
 	for (i = 0; i < size; i++)
 		((volatile char *)txq->tx_ring)[i] = 0;
 
 	prev = (uint16_t)(txq->nb_tx_desc - 1);
 	for (i = 0; i < txq->nb_tx_desc; i++) {
-		txq->tx_ring[i].qw1.cmd_dtype =
-			rte_cpu_to_le_16(IDPF_TX_DESC_DTYPE_DESC_DONE);
+		txq->tx_ring[i].qw1 =
+			rte_cpu_to_le_64(IDPF_TX_DESC_DTYPE_DESC_DONE);
 		txe[i].mbuf =  NULL;
 		txe[i].last_id = i;
 		txe[prev].next_id = i;
@@ -823,6 +823,33 @@ idpf_calc_context_desc(uint64_t flags)
 	return 0;
 }
 
+/* set TSO context descriptor for single queue
+ */
+static inline void
+idpf_set_singleq_tso_ctx(struct rte_mbuf *mbuf,
+			union idpf_tx_offload tx_offload,
+			volatile struct idpf_base_tx_ctx_desc *ctx_desc)
+{
+	uint16_t cmd_dtype;
+	uint32_t tso_len;
+	uint8_t hdr_len;
+
+	if (tx_offload.l4_len == 0) {
+		TX_LOG(DEBUG, "L4 length set to 0");
+		return;
+	}
+
+	hdr_len = tx_offload.l2_len +
+		tx_offload.l3_len +
+		tx_offload.l4_len;
+	cmd_dtype = IDPF_TX_CTX_DESC_TSO;
+	tso_len = mbuf->pkt_len - hdr_len;
+
+	ctx_desc->qw1 |= ((uint64_t)cmd_dtype << IDPF_TXD_CTX_QW1_CMD_S) |
+		((uint64_t)tso_len << IDPF_TXD_CTX_QW1_TSO_LEN_S) |
+		((uint64_t)mbuf->tso_segsz << IDPF_TXD_CTX_QW1_MSS_S);
+}
+
 /* set TSO context descriptor
  */
 static inline void
@@ -1307,17 +1334,16 @@ idpf_xmit_cleanup(struct idpf_tx_queue *txq)
 	uint16_t nb_tx_to_clean;
 	uint16_t i;
 
-	volatile struct idpf_flex_tx_desc *txd = txq->tx_ring;
+	volatile struct idpf_base_tx_desc *txd = txq->tx_ring;
 
 	desc_to_clean_to = (uint16_t)(last_desc_cleaned + txq->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;
-	/* In the writeback Tx desccriptor, the only significant fields are the 4-bit DTYPE */
-	if ((txd[desc_to_clean_to].qw1.cmd_dtype &
-	     rte_cpu_to_le_16(IDPF_TXD_QW1_DTYPE_M)) !=
-	    rte_cpu_to_le_16(IDPF_TX_DESC_DTYPE_DESC_DONE)) {
+	if ((txd[desc_to_clean_to].qw1 &
+	     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 "
 		       "(port=%d queue=%d)", desc_to_clean_to,
 		       txq->port_id, txq->queue_id);
@@ -1331,10 +1357,7 @@ idpf_xmit_cleanup(struct idpf_tx_queue *txq)
 		nb_tx_to_clean = (uint16_t)(desc_to_clean_to -
 					    last_desc_cleaned);
 
-	txd[desc_to_clean_to].qw1.cmd_dtype = 0;
-	txd[desc_to_clean_to].qw1.buf_size = 0;
-	for (i = 0; i < RTE_DIM(txd[desc_to_clean_to].qw1.flex.raw); i++)
-		txd[desc_to_clean_to].qw1.flex.raw[i] = 0;
+	txd[desc_to_clean_to].qw1 = 0;
 
 	txq->last_desc_cleaned = desc_to_clean_to;
 	txq->nb_free = (uint16_t)(txq->nb_free + nb_tx_to_clean);
@@ -1347,8 +1370,8 @@ uint16_t
 idpf_dp_singleq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 			  uint16_t nb_pkts)
 {
-	volatile struct idpf_flex_tx_desc *txd;
-	volatile struct idpf_flex_tx_desc *txr;
+	volatile struct idpf_base_tx_desc *txd;
+	volatile struct idpf_base_tx_desc *txr;
 	union idpf_tx_offload tx_offload = {0};
 	struct idpf_tx_entry *txe, *txn;
 	struct idpf_tx_entry *sw_ring;
@@ -1356,6 +1379,7 @@ idpf_dp_singleq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 	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;
@@ -1382,6 +1406,7 @@ idpf_dp_singleq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 
 	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);
@@ -1428,8 +1453,8 @@ 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 *)
+			volatile struct idpf_base_tx_ctx_desc *ctx_txd =
+				(volatile struct idpf_base_tx_ctx_desc *)
 				&txr[tx_id];
 
 			txn = &sw_ring[txe->next_id];
@@ -1441,7 +1466,7 @@ idpf_dp_singleq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 
 			/* TSO enabled */
 			if ((ol_flags & RTE_MBUF_F_TX_TCP_SEG) != 0)
-				idpf_set_splitq_tso_ctx(tx_pkt, tx_offload,
+				idpf_set_singleq_tso_ctx(tx_pkt, tx_offload,
 							ctx_txd);
 
 			txe->last_id = tx_last;
@@ -1462,9 +1487,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->buf_addr = rte_cpu_to_le_64(buf_dma_addr);
-			txd->qw1.buf_size = slen;
-			txd->qw1.cmd_dtype = rte_cpu_to_le_16(IDPF_TX_DESC_DTYPE_FLEX_DATA <<
-							      IDPF_FLEX_TXD_QW1_DTYPE_S);
+			txd->qw1 = 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));
 
 			txe->last_id = tx_last;
 			tx_id = txe->next_id;
@@ -1473,7 +1499,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_FLEX_DESC_CMD_EOP;
+		td_cmd |= IDPF_TX_DESC_CMD_EOP;
 		txq->nb_used = (uint16_t)(txq->nb_used + nb_used);
 		txq->nb_free = (uint16_t)(txq->nb_free - nb_used);
 
@@ -1482,7 +1508,7 @@ 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_FLEX_DESC_CMD_RS;
+			td_cmd |= IDPF_TX_DESC_CMD_RS;
 
 			/* Update txq RS bit counters */
 			txq->nb_used = 0;
@@ -1491,7 +1517,7 @@ idpf_dp_singleq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 		if (ol_flags & IDPF_TX_CKSUM_OFFLOAD_MASK)
 			td_cmd |= IDPF_TX_FLEX_DESC_CMD_CS_EN;
 
-		txd->qw1.cmd_dtype |= rte_cpu_to_le_16(td_cmd << IDPF_FLEX_TXD_QW1_CMD_S);
+		txd->qw1 |= rte_cpu_to_le_16(td_cmd << IDPF_TXD_QW1_CMD_S);
 	}
 
 end_of_tx:
drivers/common/idpf/idpf_common_rxtx.h +1 -1
index 6cb83fc0a6..b49b1ed737 100644
@@ -157,7 +157,7 @@ struct idpf_tx_entry {
 /* Structure associated with each TX queue. */
 struct idpf_tx_queue {
 	const struct rte_memzone *mz;		/* memzone for Tx ring */
-	volatile struct idpf_flex_tx_desc *tx_ring;	/* Tx ring virtual address */
+	volatile struct idpf_base_tx_desc *tx_ring;	/* Tx ring virtual address */
 	volatile union {
 		struct idpf_flex_tx_sched_desc *desc_ring;
 		struct idpf_splitq_tx_compl_desc *compl_ring;
drivers/common/idpf/idpf_common_rxtx_avx512.c +18 -18
index 81312617cc..36ff2af966 100644
@@ -1005,7 +1005,7 @@ idpf_tx_singleq_free_bufs_avx512(struct idpf_tx_queue *txq)
 	struct rte_mbuf *m, *free[txq->rs_thresh];
 
 	/* check DD bits on threshold descriptor */
-	if ((txq->tx_ring[txq->next_dd].qw1.cmd_dtype &
+	if ((txq->tx_ring[txq->next_dd].qw1 &
 			rte_cpu_to_le_64(IDPF_TXD_QW1_DTYPE_M)) !=
 			rte_cpu_to_le_64(IDPF_TX_DESC_DTYPE_DESC_DONE))
 		return 0;
@@ -1115,13 +1115,13 @@ tx_backlog_entry_avx512(struct idpf_tx_vec_entry *txep,
 
 #define IDPF_FLEX_TXD_QW1_BUF_SZ_S 48
 static __rte_always_inline void
-idpf_singleq_vtx1(volatile struct idpf_flex_tx_desc *txdp,
+idpf_singleq_vtx1(volatile struct idpf_base_tx_desc *txdp,
 	  struct rte_mbuf *pkt, uint64_t flags)
 {
 	uint64_t high_qw =
-		(IDPF_TX_DESC_DTYPE_FLEX_DATA << IDPF_FLEX_TXD_QW1_DTYPE_S |
-		 ((uint64_t)flags  << IDPF_FLEX_TXD_QW1_CMD_S) |
-		 ((uint64_t)pkt->data_len << IDPF_FLEX_TXD_QW1_BUF_SZ_S));
+		(IDPF_TX_DESC_DTYPE_DATA |
+		 ((uint64_t)flags  << IDPF_TXD_QW1_CMD_S) |
+		 ((uint64_t)pkt->data_len << IDPF_TXD_QW1_TX_BUF_SZ_S));
 
 	__m128i descriptor = _mm_set_epi64x(high_qw,
 					    pkt->buf_iova + pkt->data_off);
@@ -1131,11 +1131,11 @@ idpf_singleq_vtx1(volatile struct idpf_flex_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_flex_tx_desc *txdp,
+idpf_singleq_vtx(volatile struct idpf_base_tx_desc *txdp,
 	 struct rte_mbuf **pkt, uint16_t nb_pkts,  uint64_t flags)
 {
-	const uint64_t hi_qw_tmpl = (IDPF_TX_DESC_DTYPE_FLEX_DATA  |
-			((uint64_t)flags  << IDPF_FLEX_TXD_QW1_CMD_S));
+	const uint64_t hi_qw_tmpl = (IDPF_TX_DESC_DTYPE_DATA  |
+			((uint64_t)flags  << IDPF_TXD_QW1_CMD_S));
 
 	/* if unaligned on 32-bit boundary, do one to align */
 	if (((uintptr_t)txdp & 0x1F) != 0 && nb_pkts != 0) {
@@ -1148,19 +1148,19 @@ idpf_singleq_vtx(volatile struct idpf_flex_tx_desc *txdp,
 		uint64_t hi_qw3 =
 			hi_qw_tmpl |
 			((uint64_t)pkt[3]->data_len <<
-			 IDPF_FLEX_TXD_QW1_BUF_SZ_S);
+			 IDPF_TXD_QW1_TX_BUF_SZ_S);
 		uint64_t hi_qw2 =
 			hi_qw_tmpl |
 			((uint64_t)pkt[2]->data_len <<
-			 IDPF_FLEX_TXD_QW1_BUF_SZ_S);
+			 IDPF_TXD_QW1_TX_BUF_SZ_S);
 		uint64_t hi_qw1 =
 			hi_qw_tmpl |
 			((uint64_t)pkt[1]->data_len <<
-			 IDPF_FLEX_TXD_QW1_BUF_SZ_S);
+			 IDPF_TXD_QW1_TX_BUF_SZ_S);
 		uint64_t hi_qw0 =
 			hi_qw_tmpl |
 			((uint64_t)pkt[0]->data_len <<
-			 IDPF_FLEX_TXD_QW1_BUF_SZ_S);
+			 IDPF_TXD_QW1_TX_BUF_SZ_S);
 
 		__m512i desc0_3 =
 			_mm512_set_epi64
@@ -1187,11 +1187,11 @@ idpf_singleq_xmit_fixed_burst_vec_avx512(void *tx_queue, struct rte_mbuf **tx_pk
 					 uint16_t nb_pkts)
 {
 	struct idpf_tx_queue *txq = tx_queue;
-	volatile struct idpf_flex_tx_desc *txdp;
+	volatile struct idpf_base_tx_desc *txdp;
 	struct idpf_tx_vec_entry *txep;
 	uint16_t n, nb_commit, tx_id;
-	uint64_t flags = IDPF_TX_FLEX_DESC_CMD_EOP;
-	uint64_t rs = IDPF_TX_FLEX_DESC_CMD_RS | flags;
+	uint64_t flags = IDPF_TX_DESC_CMD_EOP;
+	uint64_t rs = IDPF_TX_DESC_CMD_RS | flags;
 
 	/* cross rx_thresh boundary is not allowed */
 	nb_pkts = RTE_MIN(nb_pkts, txq->rs_thresh);
@@ -1238,9 +1238,9 @@ 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->next_rs) {
-		txq->tx_ring[txq->next_rs].qw1.cmd_dtype |=
-			rte_cpu_to_le_64(((uint64_t)IDPF_TX_FLEX_DESC_CMD_RS) <<
-					 IDPF_FLEX_TXD_QW1_CMD_S);
+		txq->tx_ring[txq->next_rs].qw1 |=
+			rte_cpu_to_le_64(((uint64_t)IDPF_TX_DESC_CMD_RS) <<
+					 IDPF_TXD_QW1_CMD_S);
 		txq->next_rs =
 			(uint16_t)(txq->next_rs + txq->rs_thresh);
 	}
drivers/net/idpf/idpf_rxtx.c +1 -1
index 3e3d81ca6d..64f2235580 100644
@@ -74,7 +74,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_flex_tx_desc),
+			ring_size = RTE_ALIGN(len * sizeof(struct idpf_base_tx_desc),
 					      IDPF_DMA_MEM_ALIGN);
 		rte_memcpy(ring_name, "idpf Tx ring", sizeof("idpf Tx ring"));
 		break;
Signature · 1 line
2.25.1
#1 lore raw
Quoted 58 lines

-----Original Message-----
From: Su, Simei <[email protected]>
Sent: Friday, August 25, 2023 3:21 PM
To: Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; Zhang, Qi Z <[email protected]>
Cc: [email protected]; Wu, Wenjun1 <[email protected]>; Su, Simei <[email protected]>
Subject: [PATCH] common/idpf: rework single queue Tx function

This patch replaces flex Tx descriptor structure with base Tx descriptor.

---
 drivers/common/idpf/idpf_common_rxtx.c        | 72 +++++++++++++------
 drivers/common/idpf/idpf_common_rxtx.h        |  2 +-
 drivers/common/idpf/idpf_common_rxtx_avx512.c | 36 +++++-----
 drivers/net/idpf/idpf_rxtx.c                  |  2 +-
 4 files changed, 69 insertions(+), 43 deletions(-)
drivers/common/idpf/idpf_common_rxtx.c +3 -3
index fc87e3e243..67c124a614 100644
@@ -276,14 +276,14 @@ idpf_qc_single_tx_queue_reset(struct
 idpf_tx_queue *txq)
 	}
 
 	txe = txq->sw_ring;
-	size = sizeof(struct idpf_flex_tx_desc) * txq->nb_tx_desc;
+	size = sizeof(struct idpf_base_tx_desc) * txq->nb_tx_desc;
 	for (i = 0; i < size; i++)
 		((volatile char *)txq->tx_ring)[i] = 0;
 
 	prev = (uint16_t)(txq->nb_tx_desc - 1);
 	for (i = 0; i < txq->nb_tx_desc; i++) {
-		txq->tx_ring[i].qw1.cmd_dtype =
-
 	rte_cpu_to_le_16(IDPF_TX_DESC_DTYPE_DESC_DONE);
+		txq->tx_ring[i].qw1 =
+
 	rte_cpu_to_le_64(IDPF_TX_DESC_DTYPE_DESC_DONE);
drivers/common/idpf/idpf_common_rxtx.c +7 -0
 		txe[i].mbuf =  NULL;
 		txe[i].last_id = i;
 		txe[prev].next_id = i;
@@ -823,6 +823,33 @@ idpf_calc_context_desc(uint64_t flags)
 	return 0;
 }
 
+/* set TSO context descriptor for single queue  */ static inline void
+idpf_set_singleq_tso_ctx(struct rte_mbuf *mbuf,
+			union idpf_tx_offload tx_offload,
+			volatile struct idpf_base_tx_ctx_desc *ctx_desc) {
+	uint16_t cmd_dtype;
+	uint32_t tso_len;
+	uint8_t hdr_len;

drivers/common/idpf/idpf_common_rxtx.c idpf_calc_context_desc(uint64_t flags) · line 842

Quoted 10 lines
drivers/common/idpf/idpf_common_rxtx.c +10 -0
+
+	if (tx_offload.l4_len == 0) {
+		TX_LOG(DEBUG, "L4 length set to 0");
+		return;
+	}
+
+	hdr_len = tx_offload.l2_len +
+		tx_offload.l3_len +
+		tx_offload.l4_len;
+	cmd_dtype = IDPF_TX_CTX_DESC_TSO;

The cmd_dtype for base mode context TSO descriptor should be cmd_dtype = IDPF_TX_DESC_DTYPE_CTX | IDPF_TX_CTX_DESC_TSO << IDPF_TXD_QW1_CMD_S;

Quoted 7 lines
drivers/common/idpf/idpf_common_rxtx.c +3 -0
+	tso_len = mbuf->pkt_len - hdr_len;
+
+	ctx_desc->qw1 |= ((uint64_t)cmd_dtype <<

IDPF_TXD_CTX_QW1_CMD_S) |

drivers/common/idpf/idpf_common_rxtx.c +2 -0
+		((uint64_t)tso_len << IDPF_TXD_CTX_QW1_TSO_LEN_S) |
+		((uint64_t)mbuf->tso_segsz <<

IDPF_TXD_CTX_QW1_MSS_S); }

It seems better to add mask & here to avoid crossing.

Quoted 1 line

...

Regards,
Wenjun

#2 lore raw
In reply to Simei Su
Quoted 11 lines

-----Original Message-----
From: Su, Simei <[email protected]>
Sent: Friday, August 25, 2023 3:21 PM
To: Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; Zhang, Qi Z <[email protected]>
Cc: [email protected]; Wu, Wenjun1 <[email protected]>; Su, Simei <[email protected]>
Subject: [PATCH] common/idpf: rework single queue Tx function

Quoted 1 line

This patch replaces flex Tx descriptor structure with base Tx descriptor.

Could you add some description about why we need this?

For example:
It could be to fix some bug
A pre-condition for some new feature enabling
Or just code refactor to align with kernel driver implementation.
...

author
#3 lore raw

PATCH v2 1/1 common/idpf: refactor single queue Tx function

In reply to Simei Su

This patch replaces flex Tx descriptor with base Tx descriptor to align with kernel driver practice.

---
v2:
* Refine commit title and commit log.
* Remove redundant definition.
* Modify base mode context TSO descriptor.

 drivers/common/idpf/idpf_common_rxtx.c        | 76 +++++++++++++------
 drivers/common/idpf/idpf_common_rxtx.h        |  2 +-
 drivers/common/idpf/idpf_common_rxtx_avx512.c | 37 +++++----
 drivers/net/idpf/idpf_rxtx.c                  |  2 +-
 4 files changed, 73 insertions(+), 44 deletions(-)
drivers/common/idpf/idpf_common_rxtx.c +53 -23
index fc87e3e243..01a8685ea3 100644
@@ -276,14 +276,14 @@ idpf_qc_single_tx_queue_reset(struct idpf_tx_queue *txq)
 	}
 
 	txe = txq->sw_ring;
-	size = sizeof(struct idpf_flex_tx_desc) * txq->nb_tx_desc;
+	size = sizeof(struct idpf_base_tx_desc) * txq->nb_tx_desc;
 	for (i = 0; i < size; i++)
 		((volatile char *)txq->tx_ring)[i] = 0;
 
 	prev = (uint16_t)(txq->nb_tx_desc - 1);
 	for (i = 0; i < txq->nb_tx_desc; i++) {
-		txq->tx_ring[i].qw1.cmd_dtype =
-			rte_cpu_to_le_16(IDPF_TX_DESC_DTYPE_DESC_DONE);
+		txq->tx_ring[i].qw1 =
+			rte_cpu_to_le_64(IDPF_TX_DESC_DTYPE_DESC_DONE);
 		txe[i].mbuf =  NULL;
 		txe[i].last_id = i;
 		txe[prev].next_id = i;
@@ -823,6 +823,37 @@ idpf_calc_context_desc(uint64_t flags)
 	return 0;
 }
 
+/* set TSO context descriptor for single queue
+ */
+static inline void
+idpf_set_singleq_tso_ctx(struct rte_mbuf *mbuf,
+			union idpf_tx_offload tx_offload,
+			volatile struct idpf_base_tx_ctx_desc *ctx_desc)
+{
+	uint32_t tso_len;
+	uint8_t hdr_len;
+	uint64_t qw1;
+
+	if (tx_offload.l4_len == 0) {
+		TX_LOG(DEBUG, "L4 length set to 0");
+		return;
+	}
+
+	hdr_len = tx_offload.l2_len +
+		tx_offload.l3_len +
+		tx_offload.l4_len;
+	tso_len = mbuf->pkt_len - hdr_len;
+	qw1 = (uint64_t)IDPF_TX_DESC_DTYPE_CTX;
+
+	qw1 |= IDPF_TX_CTX_DESC_TSO << IDPF_TXD_CTX_QW1_CMD_S;
+	qw1 |= ((uint64_t)tso_len << IDPF_TXD_CTX_QW1_TSO_LEN_S) &
+		IDPF_TXD_CTX_QW1_TSO_LEN_M;
+	qw1 |= ((uint64_t)mbuf->tso_segsz << IDPF_TXD_CTX_QW1_MSS_S) &
+		IDPF_TXD_CTX_QW1_MSS_M;
+
+	ctx_desc->qw1 = rte_cpu_to_le_64(qw1);
+}
+
 /* set TSO context descriptor
  */
 static inline void
@@ -1307,17 +1338,16 @@ idpf_xmit_cleanup(struct idpf_tx_queue *txq)
 	uint16_t nb_tx_to_clean;
 	uint16_t i;
 
-	volatile struct idpf_flex_tx_desc *txd = txq->tx_ring;
+	volatile struct idpf_base_tx_desc *txd = txq->tx_ring;
 
 	desc_to_clean_to = (uint16_t)(last_desc_cleaned + txq->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;
-	/* In the writeback Tx desccriptor, the only significant fields are the 4-bit DTYPE */
-	if ((txd[desc_to_clean_to].qw1.cmd_dtype &
-	     rte_cpu_to_le_16(IDPF_TXD_QW1_DTYPE_M)) !=
-	    rte_cpu_to_le_16(IDPF_TX_DESC_DTYPE_DESC_DONE)) {
+	if ((txd[desc_to_clean_to].qw1 &
+	     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 "
 		       "(port=%d queue=%d)", desc_to_clean_to,
 		       txq->port_id, txq->queue_id);
@@ -1331,10 +1361,7 @@ idpf_xmit_cleanup(struct idpf_tx_queue *txq)
 		nb_tx_to_clean = (uint16_t)(desc_to_clean_to -
 					    last_desc_cleaned);
 
-	txd[desc_to_clean_to].qw1.cmd_dtype = 0;
-	txd[desc_to_clean_to].qw1.buf_size = 0;
-	for (i = 0; i < RTE_DIM(txd[desc_to_clean_to].qw1.flex.raw); i++)
-		txd[desc_to_clean_to].qw1.flex.raw[i] = 0;
+	txd[desc_to_clean_to].qw1 = 0;
 
 	txq->last_desc_cleaned = desc_to_clean_to;
 	txq->nb_free = (uint16_t)(txq->nb_free + nb_tx_to_clean);
@@ -1347,8 +1374,8 @@ uint16_t
 idpf_dp_singleq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 			  uint16_t nb_pkts)
 {
-	volatile struct idpf_flex_tx_desc *txd;
-	volatile struct idpf_flex_tx_desc *txr;
+	volatile struct idpf_base_tx_desc *txd;
+	volatile struct idpf_base_tx_desc *txr;
 	union idpf_tx_offload tx_offload = {0};
 	struct idpf_tx_entry *txe, *txn;
 	struct idpf_tx_entry *sw_ring;
@@ -1356,6 +1383,7 @@ idpf_dp_singleq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 	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;
@@ -1382,6 +1410,7 @@ idpf_dp_singleq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 
 	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);
@@ -1428,8 +1457,8 @@ 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 *)
+			volatile struct idpf_base_tx_ctx_desc *ctx_txd =
+				(volatile struct idpf_base_tx_ctx_desc *)
 				&txr[tx_id];
 
 			txn = &sw_ring[txe->next_id];
@@ -1441,7 +1470,7 @@ idpf_dp_singleq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 
 			/* TSO enabled */
 			if ((ol_flags & RTE_MBUF_F_TX_TCP_SEG) != 0)
-				idpf_set_splitq_tso_ctx(tx_pkt, tx_offload,
+				idpf_set_singleq_tso_ctx(tx_pkt, tx_offload,
 							ctx_txd);
 
 			txe->last_id = tx_last;
@@ -1462,9 +1491,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->buf_addr = rte_cpu_to_le_64(buf_dma_addr);
-			txd->qw1.buf_size = slen;
-			txd->qw1.cmd_dtype = rte_cpu_to_le_16(IDPF_TX_DESC_DTYPE_FLEX_DATA <<
-							      IDPF_FLEX_TXD_QW1_DTYPE_S);
+			txd->qw1 = 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));
 
 			txe->last_id = tx_last;
 			tx_id = txe->next_id;
@@ -1473,7 +1503,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_FLEX_DESC_CMD_EOP;
+		td_cmd |= IDPF_TX_DESC_CMD_EOP;
 		txq->nb_used = (uint16_t)(txq->nb_used + nb_used);
 		txq->nb_free = (uint16_t)(txq->nb_free - nb_used);
 
@@ -1482,7 +1512,7 @@ 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_FLEX_DESC_CMD_RS;
+			td_cmd |= IDPF_TX_DESC_CMD_RS;
 
 			/* Update txq RS bit counters */
 			txq->nb_used = 0;
@@ -1491,7 +1521,7 @@ idpf_dp_singleq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 		if (ol_flags & IDPF_TX_CKSUM_OFFLOAD_MASK)
 			td_cmd |= IDPF_TX_FLEX_DESC_CMD_CS_EN;
 
-		txd->qw1.cmd_dtype |= rte_cpu_to_le_16(td_cmd << IDPF_FLEX_TXD_QW1_CMD_S);
+		txd->qw1 |= rte_cpu_to_le_16(td_cmd << IDPF_TXD_QW1_CMD_S);
 	}
 
 end_of_tx:
drivers/common/idpf/idpf_common_rxtx.h +1 -1
index 6cb83fc0a6..b49b1ed737 100644
@@ -157,7 +157,7 @@ struct idpf_tx_entry {
 /* Structure associated with each TX queue. */
 struct idpf_tx_queue {
 	const struct rte_memzone *mz;		/* memzone for Tx ring */
-	volatile struct idpf_flex_tx_desc *tx_ring;	/* Tx ring virtual address */
+	volatile struct idpf_base_tx_desc *tx_ring;	/* Tx ring virtual address */
 	volatile union {
 		struct idpf_flex_tx_sched_desc *desc_ring;
 		struct idpf_splitq_tx_compl_desc *compl_ring;
drivers/common/idpf/idpf_common_rxtx_avx512.c +18 -19
index 81312617cc..afb0014a13 100644
@@ -1005,7 +1005,7 @@ idpf_tx_singleq_free_bufs_avx512(struct idpf_tx_queue *txq)
 	struct rte_mbuf *m, *free[txq->rs_thresh];
 
 	/* check DD bits on threshold descriptor */
-	if ((txq->tx_ring[txq->next_dd].qw1.cmd_dtype &
+	if ((txq->tx_ring[txq->next_dd].qw1 &
 			rte_cpu_to_le_64(IDPF_TXD_QW1_DTYPE_M)) !=
 			rte_cpu_to_le_64(IDPF_TX_DESC_DTYPE_DESC_DONE))
 		return 0;
@@ -1113,15 +1113,14 @@ tx_backlog_entry_avx512(struct idpf_tx_vec_entry *txep,
 		txep[i].mbuf = tx_pkts[i];
 }
 
-#define IDPF_FLEX_TXD_QW1_BUF_SZ_S 48
 static __rte_always_inline void
-idpf_singleq_vtx1(volatile struct idpf_flex_tx_desc *txdp,
+idpf_singleq_vtx1(volatile struct idpf_base_tx_desc *txdp,
 	  struct rte_mbuf *pkt, uint64_t flags)
 {
 	uint64_t high_qw =
-		(IDPF_TX_DESC_DTYPE_FLEX_DATA << IDPF_FLEX_TXD_QW1_DTYPE_S |
-		 ((uint64_t)flags  << IDPF_FLEX_TXD_QW1_CMD_S) |
-		 ((uint64_t)pkt->data_len << IDPF_FLEX_TXD_QW1_BUF_SZ_S));
+		(IDPF_TX_DESC_DTYPE_DATA |
+		 ((uint64_t)flags  << IDPF_TXD_QW1_CMD_S) |
+		 ((uint64_t)pkt->data_len << IDPF_TXD_QW1_TX_BUF_SZ_S));
 
 	__m128i descriptor = _mm_set_epi64x(high_qw,
 					    pkt->buf_iova + pkt->data_off);
@@ -1131,11 +1130,11 @@ idpf_singleq_vtx1(volatile struct idpf_flex_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_flex_tx_desc *txdp,
+idpf_singleq_vtx(volatile struct idpf_base_tx_desc *txdp,
 	 struct rte_mbuf **pkt, uint16_t nb_pkts,  uint64_t flags)
 {
-	const uint64_t hi_qw_tmpl = (IDPF_TX_DESC_DTYPE_FLEX_DATA  |
-			((uint64_t)flags  << IDPF_FLEX_TXD_QW1_CMD_S));
+	const uint64_t hi_qw_tmpl = (IDPF_TX_DESC_DTYPE_DATA  |
+			((uint64_t)flags  << IDPF_TXD_QW1_CMD_S));
 
 	/* if unaligned on 32-bit boundary, do one to align */
 	if (((uintptr_t)txdp & 0x1F) != 0 && nb_pkts != 0) {
@@ -1148,19 +1147,19 @@ idpf_singleq_vtx(volatile struct idpf_flex_tx_desc *txdp,
 		uint64_t hi_qw3 =
 			hi_qw_tmpl |
 			((uint64_t)pkt[3]->data_len <<
-			 IDPF_FLEX_TXD_QW1_BUF_SZ_S);
+			 IDPF_TXD_QW1_TX_BUF_SZ_S);
 		uint64_t hi_qw2 =
 			hi_qw_tmpl |
 			((uint64_t)pkt[2]->data_len <<
-			 IDPF_FLEX_TXD_QW1_BUF_SZ_S);
+			 IDPF_TXD_QW1_TX_BUF_SZ_S);
 		uint64_t hi_qw1 =
 			hi_qw_tmpl |
 			((uint64_t)pkt[1]->data_len <<
-			 IDPF_FLEX_TXD_QW1_BUF_SZ_S);
+			 IDPF_TXD_QW1_TX_BUF_SZ_S);
 		uint64_t hi_qw0 =
 			hi_qw_tmpl |
 			((uint64_t)pkt[0]->data_len <<
-			 IDPF_FLEX_TXD_QW1_BUF_SZ_S);
+			 IDPF_TXD_QW1_TX_BUF_SZ_S);
 
 		__m512i desc0_3 =
 			_mm512_set_epi64
@@ -1187,11 +1186,11 @@ idpf_singleq_xmit_fixed_burst_vec_avx512(void *tx_queue, struct rte_mbuf **tx_pk
 					 uint16_t nb_pkts)
 {
 	struct idpf_tx_queue *txq = tx_queue;
-	volatile struct idpf_flex_tx_desc *txdp;
+	volatile struct idpf_base_tx_desc *txdp;
 	struct idpf_tx_vec_entry *txep;
 	uint16_t n, nb_commit, tx_id;
-	uint64_t flags = IDPF_TX_FLEX_DESC_CMD_EOP;
-	uint64_t rs = IDPF_TX_FLEX_DESC_CMD_RS | flags;
+	uint64_t flags = IDPF_TX_DESC_CMD_EOP;
+	uint64_t rs = IDPF_TX_DESC_CMD_RS | flags;
 
 	/* cross rx_thresh boundary is not allowed */
 	nb_pkts = RTE_MIN(nb_pkts, txq->rs_thresh);
@@ -1238,9 +1237,9 @@ 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->next_rs) {
-		txq->tx_ring[txq->next_rs].qw1.cmd_dtype |=
-			rte_cpu_to_le_64(((uint64_t)IDPF_TX_FLEX_DESC_CMD_RS) <<
-					 IDPF_FLEX_TXD_QW1_CMD_S);
+		txq->tx_ring[txq->next_rs].qw1 |=
+			rte_cpu_to_le_64(((uint64_t)IDPF_TX_DESC_CMD_RS) <<
+					 IDPF_TXD_QW1_CMD_S);
 		txq->next_rs =
 			(uint16_t)(txq->next_rs + txq->rs_thresh);
 	}
drivers/net/idpf/idpf_rxtx.c +1 -1
index 3e3d81ca6d..64f2235580 100644
@@ -74,7 +74,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_flex_tx_desc),
+			ring_size = RTE_ALIGN(len * sizeof(struct idpf_base_tx_desc),
 					      IDPF_DMA_MEM_ALIGN);
 		rte_memcpy(ring_name, "idpf Tx ring", sizeof("idpf Tx ring"));
 		break;
Signature · 1 line
2.25.1
author
#4 lore raw

PATCH v3 1/1 common/idpf: refactor single queue Tx function

This patch replaces flex Tx descriptor with base Tx descriptor to align with kernel driver practice.

---
v3:
* Change context TSO descriptor from base mode to flex mode.

v2:
* Refine commit title and commit log.
* Remove redundant definition.
* Modify base mode context TSO descriptor.

 drivers/common/idpf/idpf_common_rxtx.c        | 39 +++++++++----------
 drivers/common/idpf/idpf_common_rxtx.h        |  2 +-
 drivers/common/idpf/idpf_common_rxtx_avx512.c | 37 +++++++++---------
 drivers/net/idpf/idpf_rxtx.c                  |  2 +-
 4 files changed, 39 insertions(+), 41 deletions(-)
drivers/common/idpf/idpf_common_rxtx.c +19 -20
index fc87e3e243..e6d2486272 100644
@@ -276,14 +276,14 @@ idpf_qc_single_tx_queue_reset(struct idpf_tx_queue *txq)
 	}
 
 	txe = txq->sw_ring;
-	size = sizeof(struct idpf_flex_tx_desc) * txq->nb_tx_desc;
+	size = sizeof(struct idpf_base_tx_desc) * txq->nb_tx_desc;
 	for (i = 0; i < size; i++)
 		((volatile char *)txq->tx_ring)[i] = 0;
 
 	prev = (uint16_t)(txq->nb_tx_desc - 1);
 	for (i = 0; i < txq->nb_tx_desc; i++) {
-		txq->tx_ring[i].qw1.cmd_dtype =
-			rte_cpu_to_le_16(IDPF_TX_DESC_DTYPE_DESC_DONE);
+		txq->tx_ring[i].qw1 =
+			rte_cpu_to_le_64(IDPF_TX_DESC_DTYPE_DESC_DONE);
 		txe[i].mbuf =  NULL;
 		txe[i].last_id = i;
 		txe[prev].next_id = i;
@@ -1307,17 +1307,16 @@ idpf_xmit_cleanup(struct idpf_tx_queue *txq)
 	uint16_t nb_tx_to_clean;
 	uint16_t i;
 
-	volatile struct idpf_flex_tx_desc *txd = txq->tx_ring;
+	volatile struct idpf_base_tx_desc *txd = txq->tx_ring;
 
 	desc_to_clean_to = (uint16_t)(last_desc_cleaned + txq->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;
-	/* In the writeback Tx desccriptor, the only significant fields are the 4-bit DTYPE */
-	if ((txd[desc_to_clean_to].qw1.cmd_dtype &
-	     rte_cpu_to_le_16(IDPF_TXD_QW1_DTYPE_M)) !=
-	    rte_cpu_to_le_16(IDPF_TX_DESC_DTYPE_DESC_DONE)) {
+	if ((txd[desc_to_clean_to].qw1 &
+	     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 "
 		       "(port=%d queue=%d)", desc_to_clean_to,
 		       txq->port_id, txq->queue_id);
@@ -1331,10 +1330,7 @@ idpf_xmit_cleanup(struct idpf_tx_queue *txq)
 		nb_tx_to_clean = (uint16_t)(desc_to_clean_to -
 					    last_desc_cleaned);
 
-	txd[desc_to_clean_to].qw1.cmd_dtype = 0;
-	txd[desc_to_clean_to].qw1.buf_size = 0;
-	for (i = 0; i < RTE_DIM(txd[desc_to_clean_to].qw1.flex.raw); i++)
-		txd[desc_to_clean_to].qw1.flex.raw[i] = 0;
+	txd[desc_to_clean_to].qw1 = 0;
 
 	txq->last_desc_cleaned = desc_to_clean_to;
 	txq->nb_free = (uint16_t)(txq->nb_free + nb_tx_to_clean);
@@ -1347,8 +1343,8 @@ uint16_t
 idpf_dp_singleq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 			  uint16_t nb_pkts)
 {
-	volatile struct idpf_flex_tx_desc *txd;
-	volatile struct idpf_flex_tx_desc *txr;
+	volatile struct idpf_base_tx_desc *txd;
+	volatile struct idpf_base_tx_desc *txr;
 	union idpf_tx_offload tx_offload = {0};
 	struct idpf_tx_entry *txe, *txn;
 	struct idpf_tx_entry *sw_ring;
@@ -1356,6 +1352,7 @@ idpf_dp_singleq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 	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;
@@ -1382,6 +1379,7 @@ idpf_dp_singleq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 
 	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);
@@ -1462,9 +1460,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->buf_addr = rte_cpu_to_le_64(buf_dma_addr);
-			txd->qw1.buf_size = slen;
-			txd->qw1.cmd_dtype = rte_cpu_to_le_16(IDPF_TX_DESC_DTYPE_FLEX_DATA <<
-							      IDPF_FLEX_TXD_QW1_DTYPE_S);
+			txd->qw1 = 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));
 
 			txe->last_id = tx_last;
 			tx_id = txe->next_id;
@@ -1473,7 +1472,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_FLEX_DESC_CMD_EOP;
+		td_cmd |= IDPF_TX_DESC_CMD_EOP;
 		txq->nb_used = (uint16_t)(txq->nb_used + nb_used);
 		txq->nb_free = (uint16_t)(txq->nb_free - nb_used);
 
@@ -1482,7 +1481,7 @@ 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_FLEX_DESC_CMD_RS;
+			td_cmd |= IDPF_TX_DESC_CMD_RS;
 
 			/* Update txq RS bit counters */
 			txq->nb_used = 0;
@@ -1491,7 +1490,7 @@ idpf_dp_singleq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 		if (ol_flags & IDPF_TX_CKSUM_OFFLOAD_MASK)
 			td_cmd |= IDPF_TX_FLEX_DESC_CMD_CS_EN;
 
-		txd->qw1.cmd_dtype |= rte_cpu_to_le_16(td_cmd << IDPF_FLEX_TXD_QW1_CMD_S);
+		txd->qw1 |= rte_cpu_to_le_16(td_cmd << IDPF_TXD_QW1_CMD_S);
 	}
 
 end_of_tx:
drivers/common/idpf/idpf_common_rxtx.h +1 -1
index 6cb83fc0a6..b49b1ed737 100644
@@ -157,7 +157,7 @@ struct idpf_tx_entry {
 /* Structure associated with each TX queue. */
 struct idpf_tx_queue {
 	const struct rte_memzone *mz;		/* memzone for Tx ring */
-	volatile struct idpf_flex_tx_desc *tx_ring;	/* Tx ring virtual address */
+	volatile struct idpf_base_tx_desc *tx_ring;	/* Tx ring virtual address */
 	volatile union {
 		struct idpf_flex_tx_sched_desc *desc_ring;
 		struct idpf_splitq_tx_compl_desc *compl_ring;
drivers/common/idpf/idpf_common_rxtx_avx512.c +18 -19
index 81312617cc..afb0014a13 100644
@@ -1005,7 +1005,7 @@ idpf_tx_singleq_free_bufs_avx512(struct idpf_tx_queue *txq)
 	struct rte_mbuf *m, *free[txq->rs_thresh];
 
 	/* check DD bits on threshold descriptor */
-	if ((txq->tx_ring[txq->next_dd].qw1.cmd_dtype &
+	if ((txq->tx_ring[txq->next_dd].qw1 &
 			rte_cpu_to_le_64(IDPF_TXD_QW1_DTYPE_M)) !=
 			rte_cpu_to_le_64(IDPF_TX_DESC_DTYPE_DESC_DONE))
 		return 0;
@@ -1113,15 +1113,14 @@ tx_backlog_entry_avx512(struct idpf_tx_vec_entry *txep,
 		txep[i].mbuf = tx_pkts[i];
 }
 
-#define IDPF_FLEX_TXD_QW1_BUF_SZ_S 48
 static __rte_always_inline void
-idpf_singleq_vtx1(volatile struct idpf_flex_tx_desc *txdp,
+idpf_singleq_vtx1(volatile struct idpf_base_tx_desc *txdp,
 	  struct rte_mbuf *pkt, uint64_t flags)
 {
 	uint64_t high_qw =
-		(IDPF_TX_DESC_DTYPE_FLEX_DATA << IDPF_FLEX_TXD_QW1_DTYPE_S |
-		 ((uint64_t)flags  << IDPF_FLEX_TXD_QW1_CMD_S) |
-		 ((uint64_t)pkt->data_len << IDPF_FLEX_TXD_QW1_BUF_SZ_S));
+		(IDPF_TX_DESC_DTYPE_DATA |
+		 ((uint64_t)flags  << IDPF_TXD_QW1_CMD_S) |
+		 ((uint64_t)pkt->data_len << IDPF_TXD_QW1_TX_BUF_SZ_S));
 
 	__m128i descriptor = _mm_set_epi64x(high_qw,
 					    pkt->buf_iova + pkt->data_off);
@@ -1131,11 +1130,11 @@ idpf_singleq_vtx1(volatile struct idpf_flex_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_flex_tx_desc *txdp,
+idpf_singleq_vtx(volatile struct idpf_base_tx_desc *txdp,
 	 struct rte_mbuf **pkt, uint16_t nb_pkts,  uint64_t flags)
 {
-	const uint64_t hi_qw_tmpl = (IDPF_TX_DESC_DTYPE_FLEX_DATA  |
-			((uint64_t)flags  << IDPF_FLEX_TXD_QW1_CMD_S));
+	const uint64_t hi_qw_tmpl = (IDPF_TX_DESC_DTYPE_DATA  |
+			((uint64_t)flags  << IDPF_TXD_QW1_CMD_S));
 
 	/* if unaligned on 32-bit boundary, do one to align */
 	if (((uintptr_t)txdp & 0x1F) != 0 && nb_pkts != 0) {
@@ -1148,19 +1147,19 @@ idpf_singleq_vtx(volatile struct idpf_flex_tx_desc *txdp,
 		uint64_t hi_qw3 =
 			hi_qw_tmpl |
 			((uint64_t)pkt[3]->data_len <<
-			 IDPF_FLEX_TXD_QW1_BUF_SZ_S);
+			 IDPF_TXD_QW1_TX_BUF_SZ_S);
 		uint64_t hi_qw2 =
 			hi_qw_tmpl |
 			((uint64_t)pkt[2]->data_len <<
-			 IDPF_FLEX_TXD_QW1_BUF_SZ_S);
+			 IDPF_TXD_QW1_TX_BUF_SZ_S);
 		uint64_t hi_qw1 =
 			hi_qw_tmpl |
 			((uint64_t)pkt[1]->data_len <<
-			 IDPF_FLEX_TXD_QW1_BUF_SZ_S);
+			 IDPF_TXD_QW1_TX_BUF_SZ_S);
 		uint64_t hi_qw0 =
 			hi_qw_tmpl |
 			((uint64_t)pkt[0]->data_len <<
-			 IDPF_FLEX_TXD_QW1_BUF_SZ_S);
+			 IDPF_TXD_QW1_TX_BUF_SZ_S);
 
 		__m512i desc0_3 =
 			_mm512_set_epi64
@@ -1187,11 +1186,11 @@ idpf_singleq_xmit_fixed_burst_vec_avx512(void *tx_queue, struct rte_mbuf **tx_pk
 					 uint16_t nb_pkts)
 {
 	struct idpf_tx_queue *txq = tx_queue;
-	volatile struct idpf_flex_tx_desc *txdp;
+	volatile struct idpf_base_tx_desc *txdp;
 	struct idpf_tx_vec_entry *txep;
 	uint16_t n, nb_commit, tx_id;
-	uint64_t flags = IDPF_TX_FLEX_DESC_CMD_EOP;
-	uint64_t rs = IDPF_TX_FLEX_DESC_CMD_RS | flags;
+	uint64_t flags = IDPF_TX_DESC_CMD_EOP;
+	uint64_t rs = IDPF_TX_DESC_CMD_RS | flags;
 
 	/* cross rx_thresh boundary is not allowed */
 	nb_pkts = RTE_MIN(nb_pkts, txq->rs_thresh);
@@ -1238,9 +1237,9 @@ 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->next_rs) {
-		txq->tx_ring[txq->next_rs].qw1.cmd_dtype |=
-			rte_cpu_to_le_64(((uint64_t)IDPF_TX_FLEX_DESC_CMD_RS) <<
-					 IDPF_FLEX_TXD_QW1_CMD_S);
+		txq->tx_ring[txq->next_rs].qw1 |=
+			rte_cpu_to_le_64(((uint64_t)IDPF_TX_DESC_CMD_RS) <<
+					 IDPF_TXD_QW1_CMD_S);
 		txq->next_rs =
 			(uint16_t)(txq->next_rs + txq->rs_thresh);
 	}
drivers/net/idpf/idpf_rxtx.c +1 -1
index 3e3d81ca6d..64f2235580 100644
@@ -74,7 +74,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_flex_tx_desc),
+			ring_size = RTE_ALIGN(len * sizeof(struct idpf_base_tx_desc),
 					      IDPF_DMA_MEM_ALIGN);
 		rte_memcpy(ring_name, "idpf Tx ring", sizeof("idpf Tx ring"));
 		break;
Signature · 1 line
2.25.1
Acked-by on v3 1/1
#5 lore raw

RE: [PATCH v3] common/idpf: refactor single queue Tx function

Quoted 315 lines

-----Original Message-----
From: Su, Simei <[email protected]>
Sent: Friday, September 8, 2023 6:28 PM
To: Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; Zhang, Qi Z <[email protected]>
Cc: [email protected]; Wu, Wenjun1 <[email protected]>; Su, Simei <[email protected]>
Subject: [PATCH v3] common/idpf: refactor single queue Tx function

This patch replaces flex Tx descriptor with base Tx descriptor to align with kernel driver practice.

---
v3:
* Change context TSO descriptor from base mode to flex mode.

v2:
* Refine commit title and commit log.
* Remove redundant definition.
* Modify base mode context TSO descriptor.

 drivers/common/idpf/idpf_common_rxtx.c        | 39 +++++++++----------
 drivers/common/idpf/idpf_common_rxtx.h        |  2 +-
 drivers/common/idpf/idpf_common_rxtx_avx512.c | 37 +++++++++---------
 drivers/net/idpf/idpf_rxtx.c                  |  2 +-
 4 files changed, 39 insertions(+), 41 deletions(-)
drivers/common/idpf/idpf_common_rxtx.c +3 -3
index fc87e3e243..e6d2486272 100644
@@ -276,14 +276,14 @@ idpf_qc_single_tx_queue_reset(struct
 idpf_tx_queue *txq)
 	}
 
 	txe = txq->sw_ring;
-	size = sizeof(struct idpf_flex_tx_desc) * txq->nb_tx_desc;
+	size = sizeof(struct idpf_base_tx_desc) * txq->nb_tx_desc;
 	for (i = 0; i < size; i++)
 		((volatile char *)txq->tx_ring)[i] = 0;
 
 	prev = (uint16_t)(txq->nb_tx_desc - 1);
 	for (i = 0; i < txq->nb_tx_desc; i++) {
-		txq->tx_ring[i].qw1.cmd_dtype =
-
 	rte_cpu_to_le_16(IDPF_TX_DESC_DTYPE_DESC_DONE);
+		txq->tx_ring[i].qw1 =
+
 	rte_cpu_to_le_64(IDPF_TX_DESC_DTYPE_DESC_DONE);
drivers/common/idpf/idpf_common_rxtx.c +1 -2
 		txe[i].mbuf =  NULL;
 		txe[i].last_id = i;
 		txe[prev].next_id = i;
@@ -1307,17 +1307,16 @@ idpf_xmit_cleanup(struct idpf_tx_queue *txq)
 	uint16_t nb_tx_to_clean;
 	uint16_t i;
 
-	volatile struct idpf_flex_tx_desc *txd = txq->tx_ring;
+	volatile struct idpf_base_tx_desc *txd = txq->tx_ring;
 
 	desc_to_clean_to = (uint16_t)(last_desc_cleaned + txq->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;
-	/* In the writeback Tx desccriptor, the only significant fields are the 4-

bit DTYPE */

drivers/common/idpf/idpf_common_rxtx.c +4 -7
-	if ((txd[desc_to_clean_to].qw1.cmd_dtype &
-	     rte_cpu_to_le_16(IDPF_TXD_QW1_DTYPE_M)) !=
-	    rte_cpu_to_le_16(IDPF_TX_DESC_DTYPE_DESC_DONE)) {
+	if ((txd[desc_to_clean_to].qw1 &
+	     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 "
 		       "(port=%d queue=%d)", desc_to_clean_to,
 		       txq->port_id, txq->queue_id);
@@ -1331,10 +1330,7 @@ idpf_xmit_cleanup(struct idpf_tx_queue *txq)
 		nb_tx_to_clean = (uint16_t)(desc_to_clean_to -
 					    last_desc_cleaned);
 
-	txd[desc_to_clean_to].qw1.cmd_dtype = 0;
-	txd[desc_to_clean_to].qw1.buf_size = 0;
-	for (i = 0; i < RTE_DIM(txd[desc_to_clean_to].qw1.flex.raw); i++)
-		txd[desc_to_clean_to].qw1.flex.raw[i] = 0;
+	txd[desc_to_clean_to].qw1 = 0;
 
 	txq->last_desc_cleaned = desc_to_clean_to;
 	txq->nb_free = (uint16_t)(txq->nb_free + nb_tx_to_clean); @@ -

1347,8 +1343,8 @@ uint16_t idpf_dp_singleq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,

drivers/common/idpf/idpf_common_rxtx.c +3 -2
 			  uint16_t nb_pkts)
 {
-	volatile struct idpf_flex_tx_desc *txd;
-	volatile struct idpf_flex_tx_desc *txr;
+	volatile struct idpf_base_tx_desc *txd;
+	volatile struct idpf_base_tx_desc *txr;
 	union idpf_tx_offload tx_offload = {0};
 	struct idpf_tx_entry *txe, *txn;
 	struct idpf_tx_entry *sw_ring;
@@ -1356,6 +1352,7 @@ idpf_dp_singleq_xmit_pkts(void *tx_queue, struct
 rte_mbuf **tx_pkts,
 	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;
drivers/common/idpf/idpf_common_rxtx.c +1 -0
 	uint16_t nb_used;
@@ -1382,6 +1379,7 @@ idpf_dp_singleq_xmit_pkts(void *tx_queue, struct
 rte_mbuf **tx_pkts,
 
 	for (nb_tx = 0; nb_tx < nb_pkts; nb_tx++) {
 		td_cmd = 0;
+		td_offset = 0;
 
 		tx_pkt = *tx_pkts++;
drivers/common/idpf/idpf_common_rxtx.c +0 -2
 		RTE_MBUF_PREFETCH_TO_FREE(txe->mbuf);
@@ -1462,9 +1460,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->buf_addr = rte_cpu_to_le_64(buf_dma_addr);
-			txd->qw1.buf_size = slen;
-			txd->qw1.cmd_dtype =

rte_cpu_to_le_16(IDPF_TX_DESC_DTYPE_FLEX_DATA <<
-
IDPF_FLEX_TXD_QW1_DTYPE_S);

drivers/common/idpf/idpf_common_rxtx.c +1 -0
+			txd->qw1 =

rte_cpu_to_le_64(IDPF_TX_DESC_DTYPE_DATA |

drivers/common/idpf/idpf_common_rxtx.c +1 -0
+				((uint64_t)td_cmd  <<

IDPF_TXD_QW1_CMD_S) |

drivers/common/idpf/idpf_common_rxtx.c +1 -0
+				((uint64_t)td_offset <<

IDPF_TXD_QW1_OFFSET_S) |

drivers/common/idpf/idpf_common_rxtx.c +1 -0
+				((uint64_t)slen <<

IDPF_TXD_QW1_TX_BUF_SZ_S));

drivers/common/idpf/idpf_common_rxtx.c +1 -1
 			txe->last_id = tx_last;
 			tx_id = txe->next_id;
@@ -1473,7 +1472,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_FLEX_DESC_CMD_EOP;
+		td_cmd |= IDPF_TX_DESC_CMD_EOP;
 		txq->nb_used = (uint16_t)(txq->nb_used + nb_used);
drivers/common/idpf/idpf_common_rxtx.c +1 -1
 		txq->nb_free = (uint16_t)(txq->nb_free - nb_used);
@@ -1482,7 +1481,7 @@ 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_FLEX_DESC_CMD_RS;
+			td_cmd |= IDPF_TX_DESC_CMD_RS;
 
 			/* Update txq RS bit counters */
drivers/common/idpf/idpf_common_rxtx.c +1 -1
 			txq->nb_used = 0;
@@ -1491,7 +1490,7 @@ idpf_dp_singleq_xmit_pkts(void *tx_queue, struct
 rte_mbuf **tx_pkts,
 		if (ol_flags & IDPF_TX_CKSUM_OFFLOAD_MASK)
 			td_cmd |= IDPF_TX_FLEX_DESC_CMD_CS_EN;
 
-		txd->qw1.cmd_dtype |= rte_cpu_to_le_16(td_cmd <<
 IDPF_FLEX_TXD_QW1_CMD_S);
+		txd->qw1 |= rte_cpu_to_le_16(td_cmd <<
 IDPF_TXD_QW1_CMD_S);
drivers/common/idpf/idpf_common_rxtx.c +0 -0
 	}
 
 end_of_tx:
drivers/common/idpf/idpf_common_rxtx.h +0 -1
index 6cb83fc0a6..b49b1ed737 100644
@@ -157,7 +157,7 @@ struct idpf_tx_entry {
 /* Structure associated with each TX queue. */  struct idpf_tx_queue {
 	const struct rte_memzone *mz;		/* memzone for Tx ring */
-	volatile struct idpf_flex_tx_desc *tx_ring;	/* Tx ring virtual

address */

drivers/common/idpf/idpf_common_rxtx.h +1 -0
+	volatile struct idpf_base_tx_desc *tx_ring;	/* Tx ring virtual

address */

drivers/common/idpf/idpf_common_rxtx.h +0 -0
 	volatile union {
 		struct idpf_flex_tx_sched_desc *desc_ring;
 		struct idpf_splitq_tx_compl_desc *compl_ring; diff --git

a/drivers/common/idpf/idpf_common_rxtx_avx512.c
b/drivers/common/idpf/idpf_common_rxtx_avx512.c
index 81312617cc..afb0014a13 100644

drivers/common/idpf/idpf_common_rxtx_avx512.c +1 -1
@@ -1005,7 +1005,7 @@ idpf_tx_singleq_free_bufs_avx512(struct
 idpf_tx_queue *txq)
 	struct rte_mbuf *m, *free[txq->rs_thresh];
 
 	/* check DD bits on threshold descriptor */
-	if ((txq->tx_ring[txq->next_dd].qw1.cmd_dtype &
+	if ((txq->tx_ring[txq->next_dd].qw1 &
 			rte_cpu_to_le_64(IDPF_TXD_QW1_DTYPE_M)) !=
 
	rte_cpu_to_le_64(IDPF_TX_DESC_DTYPE_DESC_DONE))
drivers/common/idpf/idpf_common_rxtx_avx512.c +1 -3
 		return 0;
@@ -1113,15 +1113,14 @@ tx_backlog_entry_avx512(struct
 idpf_tx_vec_entry *txep,
 		txep[i].mbuf = tx_pkts[i];
 }
 
-#define IDPF_FLEX_TXD_QW1_BUF_SZ_S 48
 static __rte_always_inline void
-idpf_singleq_vtx1(volatile struct idpf_flex_tx_desc *txdp,
+idpf_singleq_vtx1(volatile struct idpf_base_tx_desc *txdp,
 	  struct rte_mbuf *pkt, uint64_t flags)  {
 	uint64_t high_qw =
-		(IDPF_TX_DESC_DTYPE_FLEX_DATA <<

IDPF_FLEX_TXD_QW1_DTYPE_S |

drivers/common/idpf/idpf_common_rxtx_avx512.c +0 -2
-		 ((uint64_t)flags  << IDPF_FLEX_TXD_QW1_CMD_S) |
-		 ((uint64_t)pkt->data_len <<

IDPF_FLEX_TXD_QW1_BUF_SZ_S));

drivers/common/idpf/idpf_common_rxtx_avx512.c +3 -0
+		(IDPF_TX_DESC_DTYPE_DATA |
+		 ((uint64_t)flags  << IDPF_TXD_QW1_CMD_S) |
+		 ((uint64_t)pkt->data_len << IDPF_TXD_QW1_TX_BUF_SZ_S));
 
 	__m128i descriptor = _mm_set_epi64x(high_qw,
 					    pkt->buf_iova + pkt->data_off);
@@ -1131,11 +1130,11 @@ idpf_singleq_vtx1(volatile struct

idpf_flex_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_flex_tx_desc *txdp,

drivers/common/idpf/idpf_common_rxtx_avx512.c +11 -9
+idpf_singleq_vtx(volatile struct idpf_base_tx_desc *txdp,
 	 struct rte_mbuf **pkt, uint16_t nb_pkts,  uint64_t flags)  {
-	const uint64_t hi_qw_tmpl = (IDPF_TX_DESC_DTYPE_FLEX_DATA  |
-			((uint64_t)flags  << IDPF_FLEX_TXD_QW1_CMD_S));
+	const uint64_t hi_qw_tmpl = (IDPF_TX_DESC_DTYPE_DATA  |
+			((uint64_t)flags  << IDPF_TXD_QW1_CMD_S));
 
 	/* if unaligned on 32-bit boundary, do one to align */
 	if (((uintptr_t)txdp & 0x1F) != 0 && nb_pkts != 0) { @@ -1148,19
+1147,19 @@ idpf_singleq_vtx(volatile struct idpf_flex_tx_desc *txdp,
 		uint64_t hi_qw3 =
 			hi_qw_tmpl |
 			((uint64_t)pkt[3]->data_len <<
-			 IDPF_FLEX_TXD_QW1_BUF_SZ_S);
+			 IDPF_TXD_QW1_TX_BUF_SZ_S);
 		uint64_t hi_qw2 =
 			hi_qw_tmpl |
 			((uint64_t)pkt[2]->data_len <<
-			 IDPF_FLEX_TXD_QW1_BUF_SZ_S);
+			 IDPF_TXD_QW1_TX_BUF_SZ_S);
 		uint64_t hi_qw1 =
 			hi_qw_tmpl |
 			((uint64_t)pkt[1]->data_len <<
-			 IDPF_FLEX_TXD_QW1_BUF_SZ_S);
+			 IDPF_TXD_QW1_TX_BUF_SZ_S);
 		uint64_t hi_qw0 =
 			hi_qw_tmpl |
 			((uint64_t)pkt[0]->data_len <<
-			 IDPF_FLEX_TXD_QW1_BUF_SZ_S);
+			 IDPF_TXD_QW1_TX_BUF_SZ_S);
 
 		__m512i desc0_3 =
 			_mm512_set_epi64
@@ -1187,11 +1186,11 @@ idpf_singleq_xmit_fixed_burst_vec_avx512(void
 *tx_queue, struct rte_mbuf **tx_pk
 					 uint16_t nb_pkts)
 {
 	struct idpf_tx_queue *txq = tx_queue;
-	volatile struct idpf_flex_tx_desc *txdp;
+	volatile struct idpf_base_tx_desc *txdp;
 	struct idpf_tx_vec_entry *txep;
 	uint16_t n, nb_commit, tx_id;
-	uint64_t flags = IDPF_TX_FLEX_DESC_CMD_EOP;
-	uint64_t rs = IDPF_TX_FLEX_DESC_CMD_RS | flags;
+	uint64_t flags = IDPF_TX_DESC_CMD_EOP;
+	uint64_t rs = IDPF_TX_DESC_CMD_RS | flags;
 
 	/* cross rx_thresh boundary is not allowed */

nb_pkts = RTE_MIN(nb_pkts, txq->rs_thresh); @@ -1238,9 +1237,9
@@ idpf_singleq_xmit_fixed_burst_vec_avx512(void *tx_queue, struct rte_mbuf **tx_pk

drivers/common/idpf/idpf_common_rxtx_avx512.c +0 -2
 	tx_id = (uint16_t)(tx_id + nb_commit);
 	if (tx_id > txq->next_rs) {
-		txq->tx_ring[txq->next_rs].qw1.cmd_dtype |=
-
	rte_cpu_to_le_64(((uint64_t)IDPF_TX_FLEX_DESC_CMD_RS) <<
drivers/common/idpf/idpf_common_rxtx_avx512.c +2 -1
-					 IDPF_FLEX_TXD_QW1_CMD_S);
+		txq->tx_ring[txq->next_rs].qw1 |=
+
	rte_cpu_to_le_64(((uint64_t)IDPF_TX_DESC_CMD_RS) <<
drivers/common/idpf/idpf_common_rxtx_avx512.c +1 -0
+					 IDPF_TXD_QW1_CMD_S);
 		txq->next_rs =
 			(uint16_t)(txq->next_rs + txq->rs_thresh);
 	}
drivers/net/idpf/idpf_rxtx.c index renamed from drivers/net/idpf/idpf_rxtx.c +0 -0

3e3d81ca6d..64f2235580 100644

drivers/net/idpf/idpf_rxtx.c +1 -1
@@ -74,7 +74,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_flex_tx_desc),
+			ring_size = RTE_ALIGN(len * sizeof(struct

idpf_base_tx_desc),

drivers/net/idpf/idpf_rxtx.c +0 -1
 					      IDPF_DMA_MEM_ALIGN);
 		rte_memcpy(ring_name, "idpf Tx ring", sizeof("idpf Tx ring"));
 		break;
--
Quoted 1 line

2.25.1

Applied
#6 lore raw

RE: [PATCH v3] common/idpf: refactor single queue Tx function

Quoted 328 lines

-----Original Message-----
From: Wu, Wenjun1 <[email protected]>
Sent: Wednesday, September 13, 2023 1:57 PM
To: Su, Simei <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; Zhang, Qi Z <[email protected]>
Cc: [email protected]
Subject: RE: [PATCH v3] common/idpf: refactor single queue Tx function

Quoted 55 lines

-----Original Message-----
From: Su, Simei <[email protected]>
Sent: Friday, September 8, 2023 6:28 PM
To: Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; Zhang, Qi Z <[email protected]>
Cc: [email protected]; Wu, Wenjun1 <[email protected]>; Su, Simei <[email protected]>
Subject: [PATCH v3] common/idpf: refactor single queue Tx function

This patch replaces flex Tx descriptor with base Tx descriptor to align with kernel driver practice.

---
v3:
* Change context TSO descriptor from base mode to flex mode.

v2:
* Refine commit title and commit log.
* Remove redundant definition.
* Modify base mode context TSO descriptor.

 drivers/common/idpf/idpf_common_rxtx.c        | 39 +++++++++----------
 drivers/common/idpf/idpf_common_rxtx.h        |  2 +-
 drivers/common/idpf/idpf_common_rxtx_avx512.c | 37 +++++++++---------
 drivers/net/idpf/idpf_rxtx.c                  |  2 +-
 4 files changed, 39 insertions(+), 41 deletions(-)
drivers/common/idpf/idpf_common_rxtx.c +3 -3
index fc87e3e243..e6d2486272 100644
@@ -276,14 +276,14 @@ idpf_qc_single_tx_queue_reset(struct
 idpf_tx_queue *txq)
 	}
 
 	txe = txq->sw_ring;
-	size = sizeof(struct idpf_flex_tx_desc) * txq->nb_tx_desc;
+	size = sizeof(struct idpf_base_tx_desc) * txq->nb_tx_desc;
 	for (i = 0; i < size; i++)
 		((volatile char *)txq->tx_ring)[i] = 0;
 
 	prev = (uint16_t)(txq->nb_tx_desc - 1);
 	for (i = 0; i < txq->nb_tx_desc; i++) {
-		txq->tx_ring[i].qw1.cmd_dtype =
-
 	rte_cpu_to_le_16(IDPF_TX_DESC_DTYPE_DESC_DONE);
+		txq->tx_ring[i].qw1 =
+
 	rte_cpu_to_le_64(IDPF_TX_DESC_DTYPE_DESC_DONE);
drivers/common/idpf/idpf_common_rxtx.c +0 -0
 		txe[i].mbuf =  NULL;
 		txe[i].last_id = i;
 		txe[prev].next_id = i;

drivers/common/idpf/idpf_common_rxtx.c idpf_xmit_cleanup(struct idpf_tx_queue *txq) · line 1314

Quoted 9 lines
drivers/common/idpf/idpf_common_rxtx.c +1 -1
@@ -1307,17 +1307,16 @@ idpf_xmit_cleanup(struct idpf_tx_queue *txq)
 	uint16_t nb_tx_to_clean;
 	uint16_t i;
 
-	volatile struct idpf_flex_tx_desc *txd = txq->tx_ring;
+	volatile struct idpf_base_tx_desc *txd = txq->tx_ring;
 
 	desc_to_clean_to = (uint16_t)(last_desc_cleaned + txq->rs_thresh);
 	if (desc_to_clean_to >= nb_tx_desc)
 		desc_to_clean_to = (uint16_t)(desc_to_clean_to -

nb_tx_desc);

drivers/common/idpf/idpf_common_rxtx.c idpf_dp_singleq_xmit_pkts(void *tx_queue,

Quoted 37 lines
drivers/common/idpf/idpf_common_rxtx.c +0 -1
 	desc_to_clean_to = sw_ring[desc_to_clean_to].last_id;
-	/* In the writeback Tx desccriptor, the only significant fields are the 4-

bit DTYPE */

drivers/common/idpf/idpf_common_rxtx.c +3 -3
-	if ((txd[desc_to_clean_to].qw1.cmd_dtype &
-	     rte_cpu_to_le_16(IDPF_TXD_QW1_DTYPE_M)) !=
-	    rte_cpu_to_le_16(IDPF_TX_DESC_DTYPE_DESC_DONE)) {
+	if ((txd[desc_to_clean_to].qw1 &
+	     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 "
 		       "(port=%d queue=%d)", desc_to_clean_to,
 		       txq->port_id, txq->queue_id); @@ -1331,10 +1330,7 @@

idpf_xmit_cleanup(struct idpf_tx_queue *txq)

drivers/common/idpf/idpf_common_rxtx.c +1 -4
 		nb_tx_to_clean = (uint16_t)(desc_to_clean_to -
 					    last_desc_cleaned);
 
-	txd[desc_to_clean_to].qw1.cmd_dtype = 0;
-	txd[desc_to_clean_to].qw1.buf_size = 0;
-	for (i = 0; i < RTE_DIM(txd[desc_to_clean_to].qw1.flex.raw); i++)
-		txd[desc_to_clean_to].qw1.flex.raw[i] = 0;
+	txd[desc_to_clean_to].qw1 = 0;
 
 	txq->last_desc_cleaned = desc_to_clean_to;
 	txq->nb_free = (uint16_t)(txq->nb_free + nb_tx_to_clean); @@ -

1347,8 +1343,8 @@ uint16_t idpf_dp_singleq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,

drivers/common/idpf/idpf_common_rxtx.c +2 -2
 			  uint16_t nb_pkts)
 {
-	volatile struct idpf_flex_tx_desc *txd;
-	volatile struct idpf_flex_tx_desc *txr;
+	volatile struct idpf_base_tx_desc *txd;
+	volatile struct idpf_base_tx_desc *txr;
 	union idpf_tx_offload tx_offload = {0};
 	struct idpf_tx_entry *txe, *txn;
 	struct idpf_tx_entry *sw_ring;
@@ -1356,6 +1352,7 @@ idpf_dp_singleq_xmit_pkts(void *tx_queue,

struct

drivers/common/idpf/idpf_common_rxtx.c idpf_dp_singleq_xmit_pkts(void *tx_queue,

Quoted 9 lines
drivers/common/idpf/idpf_common_rxtx.c +1 -0
 rte_mbuf **tx_pkts,
 	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;
drivers/common/idpf/idpf_common_rxtx.c +0 -0
 	uint16_t nb_used;
@@ -1382,6 +1379,7 @@ idpf_dp_singleq_xmit_pkts(void *tx_queue,

struct

drivers/common/idpf/idpf_common_rxtx.c idpf_dp_singleq_xmit_pkts(void *tx_queue,

Quoted 30 lines
drivers/common/idpf/idpf_common_rxtx.c +1 -0
 rte_mbuf **tx_pkts,
 
 	for (nb_tx = 0; nb_tx < nb_pkts; nb_tx++) {
 		td_cmd = 0;
+		td_offset = 0;
 
 		tx_pkt = *tx_pkts++;
drivers/common/idpf/idpf_common_rxtx.c +0 -2
 		RTE_MBUF_PREFETCH_TO_FREE(txe->mbuf);
@@ -1462,9 +1460,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->buf_addr = rte_cpu_to_le_64(buf_dma_addr);
-			txd->qw1.buf_size = slen;
-			txd->qw1.cmd_dtype =

rte_cpu_to_le_16(IDPF_TX_DESC_DTYPE_FLEX_DATA <<
-
IDPF_FLEX_TXD_QW1_DTYPE_S);

drivers/common/idpf/idpf_common_rxtx.c +1 -0
+			txd->qw1 =

rte_cpu_to_le_64(IDPF_TX_DESC_DTYPE_DATA |

drivers/common/idpf/idpf_common_rxtx.c +1 -0
+				((uint64_t)td_cmd  <<

IDPF_TXD_QW1_CMD_S) |

drivers/common/idpf/idpf_common_rxtx.c +1 -0
+				((uint64_t)td_offset <<

IDPF_TXD_QW1_OFFSET_S) |

drivers/common/idpf/idpf_common_rxtx.c +1 -0
+				((uint64_t)slen <<

IDPF_TXD_QW1_TX_BUF_SZ_S));

drivers/common/idpf/idpf_common_rxtx.c +0 -0
 			txe->last_id = tx_last;
 			tx_id = txe->next_id;
@@ -1473,7 +1472,7 @@ idpf_dp_singleq_xmit_pkts(void *tx_queue,

struct

drivers/common/idpf/idpf_common_rxtx.c idpf_dp_singleq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,

Quoted 4 lines
drivers/common/idpf/idpf_common_rxtx.c +0 -0
 rte_mbuf **tx_pkts,
 		} while (m_seg);
 
 		/* The last packet data descriptor needs End Of Packet (EOP)

*/

drivers/common/idpf/idpf_common_rxtx.c idpf_dp_singleq_xmit_pkts(void *tx_queue,

Quoted 6 lines
drivers/common/idpf/idpf_common_rxtx.c +1 -1
-		td_cmd |= IDPF_TX_FLEX_DESC_CMD_EOP;
+		td_cmd |= IDPF_TX_DESC_CMD_EOP;
 		txq->nb_used = (uint16_t)(txq->nb_used + nb_used);
 		txq->nb_free = (uint16_t)(txq->nb_free - nb_used);
@@ -1482,7 +1481,7 @@ idpf_dp_singleq_xmit_pkts(void *tx_queue,

struct

drivers/common/idpf/idpf_common_rxtx.c idpf_dp_singleq_xmit_pkts(void *tx_queue,

Quoted 10 lines
drivers/common/idpf/idpf_common_rxtx.c +1 -1
 rte_mbuf **tx_pkts,
 			       "%4u (port=%d queue=%d)",
 			       tx_last, txq->port_id, txq->queue_id);
 
-			td_cmd |= IDPF_TX_FLEX_DESC_CMD_RS;
+			td_cmd |= IDPF_TX_DESC_CMD_RS;
 
 			/* Update txq RS bit counters */
drivers/common/idpf/idpf_common_rxtx.c +0 -0
 			txq->nb_used = 0;
@@ -1491,7 +1490,7 @@ idpf_dp_singleq_xmit_pkts(void *tx_queue,

struct

Quoted 63 lines
drivers/common/idpf/idpf_common_rxtx.c +1 -1
 rte_mbuf **tx_pkts,
 		if (ol_flags & IDPF_TX_CKSUM_OFFLOAD_MASK)
 			td_cmd |= IDPF_TX_FLEX_DESC_CMD_CS_EN;
 
-		txd->qw1.cmd_dtype |= rte_cpu_to_le_16(td_cmd <<
 IDPF_FLEX_TXD_QW1_CMD_S);
+		txd->qw1 |= rte_cpu_to_le_16(td_cmd <<
 IDPF_TXD_QW1_CMD_S);
drivers/common/idpf/idpf_common_rxtx.c +0 -0
 	}
 
 end_of_tx:
drivers/common/idpf/idpf_common_rxtx.h +0 -1
index 6cb83fc0a6..b49b1ed737 100644
@@ -157,7 +157,7 @@ struct idpf_tx_entry {
 /* Structure associated with each TX queue. */  struct idpf_tx_queue {
 	const struct rte_memzone *mz;		/* memzone for Tx ring */
-	volatile struct idpf_flex_tx_desc *tx_ring;	/* Tx ring virtual

address */

drivers/common/idpf/idpf_common_rxtx.h +1 -0
+	volatile struct idpf_base_tx_desc *tx_ring;	/* Tx ring virtual

address */

drivers/common/idpf/idpf_common_rxtx.h +0 -0
 	volatile union {
 		struct idpf_flex_tx_sched_desc *desc_ring;
 		struct idpf_splitq_tx_compl_desc *compl_ring; diff --git

a/drivers/common/idpf/idpf_common_rxtx_avx512.c
b/drivers/common/idpf/idpf_common_rxtx_avx512.c
index 81312617cc..afb0014a13 100644

drivers/common/idpf/idpf_common_rxtx_avx512.c +1 -1
@@ -1005,7 +1005,7 @@ idpf_tx_singleq_free_bufs_avx512(struct
 idpf_tx_queue *txq)
 	struct rte_mbuf *m, *free[txq->rs_thresh];
 
 	/* check DD bits on threshold descriptor */
-	if ((txq->tx_ring[txq->next_dd].qw1.cmd_dtype &
+	if ((txq->tx_ring[txq->next_dd].qw1 &
 			rte_cpu_to_le_64(IDPF_TXD_QW1_DTYPE_M)) !=
 
	rte_cpu_to_le_64(IDPF_TX_DESC_DTYPE_DESC_DONE))
drivers/common/idpf/idpf_common_rxtx_avx512.c +1 -2
 		return 0;
@@ -1113,15 +1113,14 @@ tx_backlog_entry_avx512(struct
 idpf_tx_vec_entry *txep,
 		txep[i].mbuf = tx_pkts[i];
 }
 
-#define IDPF_FLEX_TXD_QW1_BUF_SZ_S 48  static __rte_always_inline
 void -idpf_singleq_vtx1(volatile struct idpf_flex_tx_desc *txdp,
+idpf_singleq_vtx1(volatile struct idpf_base_tx_desc *txdp,
 	  struct rte_mbuf *pkt, uint64_t flags)  {
 	uint64_t high_qw =
-		(IDPF_TX_DESC_DTYPE_FLEX_DATA <<

IDPF_FLEX_TXD_QW1_DTYPE_S |

drivers/common/idpf/idpf_common_rxtx_avx512.c +0 -2
-		 ((uint64_t)flags  << IDPF_FLEX_TXD_QW1_CMD_S) |
-		 ((uint64_t)pkt->data_len <<

IDPF_FLEX_TXD_QW1_BUF_SZ_S));

drivers/common/idpf/idpf_common_rxtx_avx512.c +3 -0
+		(IDPF_TX_DESC_DTYPE_DATA |
+		 ((uint64_t)flags  << IDPF_TXD_QW1_CMD_S) |
+		 ((uint64_t)pkt->data_len << IDPF_TXD_QW1_TX_BUF_SZ_S));
 
 	__m128i descriptor = _mm_set_epi64x(high_qw,
 					    pkt->buf_iova + pkt->data_off);
(quoted diff) +0 -0
@@ -1131,11 +1130,11 @@

drivers/common/idpf/idpf_common_rxtx_avx512.c

Quoted 38 lines

idpf_singleq_vtx1(volatile struct idpf_flex_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_flex_tx_desc *txdp,

drivers/common/idpf/idpf_common_rxtx_avx512.c +8 -6
+idpf_singleq_vtx(volatile struct idpf_base_tx_desc *txdp,
 	 struct rte_mbuf **pkt, uint16_t nb_pkts,  uint64_t flags)  {
-	const uint64_t hi_qw_tmpl = (IDPF_TX_DESC_DTYPE_FLEX_DATA  |
-			((uint64_t)flags  << IDPF_FLEX_TXD_QW1_CMD_S));
+	const uint64_t hi_qw_tmpl = (IDPF_TX_DESC_DTYPE_DATA  |
+			((uint64_t)flags  << IDPF_TXD_QW1_CMD_S));
 
 	/* if unaligned on 32-bit boundary, do one to align */
 	if (((uintptr_t)txdp & 0x1F) != 0 && nb_pkts != 0) { @@ -1148,19
+1147,19 @@ idpf_singleq_vtx(volatile struct idpf_flex_tx_desc *txdp,
 		uint64_t hi_qw3 =
 			hi_qw_tmpl |
 			((uint64_t)pkt[3]->data_len <<
-			 IDPF_FLEX_TXD_QW1_BUF_SZ_S);
+			 IDPF_TXD_QW1_TX_BUF_SZ_S);
 		uint64_t hi_qw2 =
 			hi_qw_tmpl |
 			((uint64_t)pkt[2]->data_len <<
-			 IDPF_FLEX_TXD_QW1_BUF_SZ_S);
+			 IDPF_TXD_QW1_TX_BUF_SZ_S);
 		uint64_t hi_qw1 =
 			hi_qw_tmpl |
 			((uint64_t)pkt[1]->data_len <<
-			 IDPF_FLEX_TXD_QW1_BUF_SZ_S);
+			 IDPF_TXD_QW1_TX_BUF_SZ_S);
 		uint64_t hi_qw0 =
 			hi_qw_tmpl |
 			((uint64_t)pkt[0]->data_len <<
-			 IDPF_FLEX_TXD_QW1_BUF_SZ_S);
+			 IDPF_TXD_QW1_TX_BUF_SZ_S);
 
 		__m512i desc0_3 =
 			_mm512_set_epi64
@@ -1187,11 +1186,11 @@

idpf_singleq_xmit_fixed_burst_vec_avx512(void

Quoted 14 lines
drivers/common/idpf/idpf_common_rxtx_avx512.c +3 -3
 *tx_queue, struct rte_mbuf **tx_pk
 					 uint16_t nb_pkts)
 {
 	struct idpf_tx_queue *txq = tx_queue;
-	volatile struct idpf_flex_tx_desc *txdp;
+	volatile struct idpf_base_tx_desc *txdp;
 	struct idpf_tx_vec_entry *txep;
 	uint16_t n, nb_commit, tx_id;
-	uint64_t flags = IDPF_TX_FLEX_DESC_CMD_EOP;
-	uint64_t rs = IDPF_TX_FLEX_DESC_CMD_RS | flags;
+	uint64_t flags = IDPF_TX_DESC_CMD_EOP;
+	uint64_t rs = IDPF_TX_DESC_CMD_RS | flags;
 
 	/* cross rx_thresh boundary is not allowed */
Quoted 1 line

nb_pkts = RTE_MIN(nb_pkts, txq->rs_thresh); @@ -1238,9 +1237,9

@@

Quoted 30 lines

idpf_singleq_xmit_fixed_burst_vec_avx512(void *tx_queue, struct rte_mbuf **tx_pk

drivers/common/idpf/idpf_common_rxtx_avx512.c +0 -2
 	tx_id = (uint16_t)(tx_id + nb_commit);
 	if (tx_id > txq->next_rs) {
-		txq->tx_ring[txq->next_rs].qw1.cmd_dtype |=
-
	rte_cpu_to_le_64(((uint64_t)IDPF_TX_FLEX_DESC_CMD_RS) <<
drivers/common/idpf/idpf_common_rxtx_avx512.c +2 -1
-					 IDPF_FLEX_TXD_QW1_CMD_S);
+		txq->tx_ring[txq->next_rs].qw1 |=
+
	rte_cpu_to_le_64(((uint64_t)IDPF_TX_DESC_CMD_RS) <<
drivers/common/idpf/idpf_common_rxtx_avx512.c +1 -0
+					 IDPF_TXD_QW1_CMD_S);
 		txq->next_rs =
 			(uint16_t)(txq->next_rs + txq->rs_thresh);
 	}
(quoted diff) +0 -0

b/drivers/net/idpf/idpf_rxtx.c index
3e3d81ca6d..64f2235580 100644

drivers/net/idpf/idpf_rxtx.c +1 -1
@@ -74,7 +74,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_flex_tx_desc),
+			ring_size = RTE_ALIGN(len * sizeof(struct
Quoted 8 lines
Quoted 6 lines

idpf_base_tx_desc),

drivers/net/idpf/idpf_rxtx.c +0 -1
 					      IDPF_DMA_MEM_ALIGN);
 		rte_memcpy(ring_name, "idpf Tx ring", sizeof("idpf Tx ring"));
 		break;
--

2.25.1

Applied to dpdk-next-net-intel.

Thanks
Qi

#7 lore raw

RE: [PATCH v3] common/idpf: refactor single queue Tx function

Quoted 351 lines

-----Original Message-----
From: Zhang, Qi Z <[email protected]>
Sent: Wednesday, September 13, 2023 3:46 PM
To: Wu, Wenjun1 <[email protected]>; Su, Simei <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>
Cc: [email protected]
Subject: RE: [PATCH v3] common/idpf: refactor single queue Tx function

Quoted 36 lines

-----Original Message-----
From: Wu, Wenjun1 <[email protected]>
Sent: Wednesday, September 13, 2023 1:57 PM
To: Su, Simei <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; Zhang, Qi Z <[email protected]>
Cc: [email protected]
Subject: RE: [PATCH v3] common/idpf: refactor single queue Tx function

Quoted 25 lines

-----Original Message-----
From: Su, Simei <[email protected]>
Sent: Friday, September 8, 2023 6:28 PM
To: Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; Zhang, Qi Z <[email protected]>
Cc: [email protected]; Wu, Wenjun1 <[email protected]>; Su, Simei <[email protected]>
Subject: [PATCH v3] common/idpf: refactor single queue Tx function

This patch replaces flex Tx descriptor with base Tx descriptor to align with kernel driver practice.

---
v3:
* Change context TSO descriptor from base mode to flex mode.

v2:
* Refine commit title and commit log.
* Remove redundant definition.
* Modify base mode context TSO descriptor.

 drivers/common/idpf/idpf_common_rxtx.c        | 39 +++++++++----------
 drivers/common/idpf/idpf_common_rxtx.h        |  2 +-
 drivers/common/idpf/idpf_common_rxtx_avx512.c | 37 +++++++++--------

-

Quoted 18 lines
Quoted 18 lines
 drivers/net/idpf/idpf_rxtx.c                  |  2 +-
 4 files changed, 39 insertions(+), 41 deletions(-)
drivers/common/idpf/idpf_common_rxtx.c +1 -1
index fc87e3e243..e6d2486272 100644
@@ -276,14 +276,14 @@ idpf_qc_single_tx_queue_reset(struct
 idpf_tx_queue *txq)
 	}
 
 	txe = txq->sw_ring;
-	size = sizeof(struct idpf_flex_tx_desc) * txq->nb_tx_desc;
+	size = sizeof(struct idpf_base_tx_desc) * txq->nb_tx_desc;
 	for (i = 0; i < size; i++)
 		((volatile char *)txq->tx_ring)[i] = 0;
 
Quoted 12 lines

drivers/common/idpf/idpf_common_rxtx.c idpf_xmit_cleanup(struct idpf_tx_queue

Quoted 12 lines
drivers/common/idpf/idpf_common_rxtx.c +2 -2
 	prev = (uint16_t)(txq->nb_tx_desc - 1);
 	for (i = 0; i < txq->nb_tx_desc; i++) {
-		txq->tx_ring[i].qw1.cmd_dtype =
-
 	rte_cpu_to_le_16(IDPF_TX_DESC_DTYPE_DESC_DONE);
+		txq->tx_ring[i].qw1 =
+
 	rte_cpu_to_le_64(IDPF_TX_DESC_DTYPE_DESC_DONE);
drivers/common/idpf/idpf_common_rxtx.c +0 -0
 		txe[i].mbuf =  NULL;
 		txe[i].last_id = i;
 		txe[prev].next_id = i;
@@ -1307,17 +1307,16 @@ idpf_xmit_cleanup(struct idpf_tx_queue

*txq)

Quoted 262 lines

drivers/common/idpf/idpf_common_rxtx.c idpf_xmit_cleanup(struct idpf_tx_queue *txq)

Quoted 9 lines
drivers/common/idpf/idpf_common_rxtx.c +1 -1
 	uint16_t nb_tx_to_clean;
 	uint16_t i;
 
-	volatile struct idpf_flex_tx_desc *txd = txq->tx_ring;
+	volatile struct idpf_base_tx_desc *txd = txq->tx_ring;
 
 	desc_to_clean_to = (uint16_t)(last_desc_cleaned + txq->rs_thresh);
 	if (desc_to_clean_to >= nb_tx_desc)
 		desc_to_clean_to = (uint16_t)(desc_to_clean_to -

nb_tx_desc);

drivers/common/idpf/idpf_common_rxtx.c idpf_dp_singleq_xmit_pkts(void *tx_queue,

Quoted 37 lines
drivers/common/idpf/idpf_common_rxtx.c +0 -1
 	desc_to_clean_to = sw_ring[desc_to_clean_to].last_id;
-	/* In the writeback Tx desccriptor, the only significant fields are the 4-

bit DTYPE */

drivers/common/idpf/idpf_common_rxtx.c +3 -3
-	if ((txd[desc_to_clean_to].qw1.cmd_dtype &
-	     rte_cpu_to_le_16(IDPF_TXD_QW1_DTYPE_M)) !=
-	    rte_cpu_to_le_16(IDPF_TX_DESC_DTYPE_DESC_DONE)) {
+	if ((txd[desc_to_clean_to].qw1 &
+	     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 "
 		       "(port=%d queue=%d)", desc_to_clean_to,
 		       txq->port_id, txq->queue_id); @@ -1331,10 +1330,7 @@

idpf_xmit_cleanup(struct idpf_tx_queue *txq)

drivers/common/idpf/idpf_common_rxtx.c +1 -4
 		nb_tx_to_clean = (uint16_t)(desc_to_clean_to -
 					    last_desc_cleaned);
 
-	txd[desc_to_clean_to].qw1.cmd_dtype = 0;
-	txd[desc_to_clean_to].qw1.buf_size = 0;
-	for (i = 0; i < RTE_DIM(txd[desc_to_clean_to].qw1.flex.raw); i++)
-		txd[desc_to_clean_to].qw1.flex.raw[i] = 0;
+	txd[desc_to_clean_to].qw1 = 0;
 
 	txq->last_desc_cleaned = desc_to_clean_to;
 	txq->nb_free = (uint16_t)(txq->nb_free + nb_tx_to_clean); @@ -

1347,8 +1343,8 @@ uint16_t idpf_dp_singleq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,

drivers/common/idpf/idpf_common_rxtx.c +2 -2
 			  uint16_t nb_pkts)
 {
-	volatile struct idpf_flex_tx_desc *txd;
-	volatile struct idpf_flex_tx_desc *txr;
+	volatile struct idpf_base_tx_desc *txd;
+	volatile struct idpf_base_tx_desc *txr;
 	union idpf_tx_offload tx_offload = {0};
 	struct idpf_tx_entry *txe, *txn;
 	struct idpf_tx_entry *sw_ring;
@@ -1356,6 +1352,7 @@ idpf_dp_singleq_xmit_pkts(void *tx_queue,

struct

drivers/common/idpf/idpf_common_rxtx.c idpf_dp_singleq_xmit_pkts(void *tx_queue,

Quoted 9 lines
drivers/common/idpf/idpf_common_rxtx.c +1 -0
 rte_mbuf **tx_pkts,
 	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;
drivers/common/idpf/idpf_common_rxtx.c +0 -0
 	uint16_t nb_used;
@@ -1382,6 +1379,7 @@ idpf_dp_singleq_xmit_pkts(void *tx_queue,

struct

drivers/common/idpf/idpf_common_rxtx.c idpf_dp_singleq_xmit_pkts(void *tx_queue,

Quoted 30 lines
drivers/common/idpf/idpf_common_rxtx.c +1 -0
 rte_mbuf **tx_pkts,
 
 	for (nb_tx = 0; nb_tx < nb_pkts; nb_tx++) {
 		td_cmd = 0;
+		td_offset = 0;
 
 		tx_pkt = *tx_pkts++;
drivers/common/idpf/idpf_common_rxtx.c +0 -2
 		RTE_MBUF_PREFETCH_TO_FREE(txe->mbuf);
@@ -1462,9 +1460,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->buf_addr = rte_cpu_to_le_64(buf_dma_addr);
-			txd->qw1.buf_size = slen;
-			txd->qw1.cmd_dtype =

rte_cpu_to_le_16(IDPF_TX_DESC_DTYPE_FLEX_DATA <<
-
IDPF_FLEX_TXD_QW1_DTYPE_S);

drivers/common/idpf/idpf_common_rxtx.c +1 -0
+			txd->qw1 =

rte_cpu_to_le_64(IDPF_TX_DESC_DTYPE_DATA |

drivers/common/idpf/idpf_common_rxtx.c +1 -0
+				((uint64_t)td_cmd  <<

IDPF_TXD_QW1_CMD_S) |

drivers/common/idpf/idpf_common_rxtx.c +1 -0
+				((uint64_t)td_offset <<

IDPF_TXD_QW1_OFFSET_S) |

drivers/common/idpf/idpf_common_rxtx.c +1 -0
+				((uint64_t)slen <<

IDPF_TXD_QW1_TX_BUF_SZ_S));

drivers/common/idpf/idpf_common_rxtx.c +0 -0
 			txe->last_id = tx_last;
 			tx_id = txe->next_id;
@@ -1473,7 +1472,7 @@ idpf_dp_singleq_xmit_pkts(void *tx_queue,

struct

drivers/common/idpf/idpf_common_rxtx.c idpf_dp_singleq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,

Quoted 4 lines
drivers/common/idpf/idpf_common_rxtx.c +0 -0
 rte_mbuf **tx_pkts,
 		} while (m_seg);
 
 		/* The last packet data descriptor needs End Of Packet (EOP)

*/

drivers/common/idpf/idpf_common_rxtx.c idpf_dp_singleq_xmit_pkts(void *tx_queue,

Quoted 6 lines
drivers/common/idpf/idpf_common_rxtx.c +1 -1
-		td_cmd |= IDPF_TX_FLEX_DESC_CMD_EOP;
+		td_cmd |= IDPF_TX_DESC_CMD_EOP;
 		txq->nb_used = (uint16_t)(txq->nb_used + nb_used);
 		txq->nb_free = (uint16_t)(txq->nb_free - nb_used);
@@ -1482,7 +1481,7 @@ idpf_dp_singleq_xmit_pkts(void *tx_queue,

struct

drivers/common/idpf/idpf_common_rxtx.c idpf_dp_singleq_xmit_pkts(void *tx_queue,

Quoted 10 lines
drivers/common/idpf/idpf_common_rxtx.c +1 -1
 rte_mbuf **tx_pkts,
 			       "%4u (port=%d queue=%d)",
 			       tx_last, txq->port_id, txq->queue_id);
 
-			td_cmd |= IDPF_TX_FLEX_DESC_CMD_RS;
+			td_cmd |= IDPF_TX_DESC_CMD_RS;
 
 			/* Update txq RS bit counters */
drivers/common/idpf/idpf_common_rxtx.c +0 -0
 			txq->nb_used = 0;
@@ -1491,7 +1490,7 @@ idpf_dp_singleq_xmit_pkts(void *tx_queue,

struct

Quoted 63 lines
drivers/common/idpf/idpf_common_rxtx.c +1 -1
 rte_mbuf **tx_pkts,
 		if (ol_flags & IDPF_TX_CKSUM_OFFLOAD_MASK)
 			td_cmd |= IDPF_TX_FLEX_DESC_CMD_CS_EN;
 
-		txd->qw1.cmd_dtype |= rte_cpu_to_le_16(td_cmd <<
 IDPF_FLEX_TXD_QW1_CMD_S);
+		txd->qw1 |= rte_cpu_to_le_16(td_cmd <<
 IDPF_TXD_QW1_CMD_S);
drivers/common/idpf/idpf_common_rxtx.c +0 -0
 	}
 
 end_of_tx:
drivers/common/idpf/idpf_common_rxtx.h +0 -1
index 6cb83fc0a6..b49b1ed737 100644
@@ -157,7 +157,7 @@ struct idpf_tx_entry {
 /* Structure associated with each TX queue. */  struct idpf_tx_queue {
 	const struct rte_memzone *mz;		/* memzone for Tx ring */
-	volatile struct idpf_flex_tx_desc *tx_ring;	/* Tx ring virtual

address */

drivers/common/idpf/idpf_common_rxtx.h +1 -0
+	volatile struct idpf_base_tx_desc *tx_ring;	/* Tx ring virtual

address */

drivers/common/idpf/idpf_common_rxtx.h +0 -0
 	volatile union {
 		struct idpf_flex_tx_sched_desc *desc_ring;
 		struct idpf_splitq_tx_compl_desc *compl_ring; diff --git

a/drivers/common/idpf/idpf_common_rxtx_avx512.c
b/drivers/common/idpf/idpf_common_rxtx_avx512.c
index 81312617cc..afb0014a13 100644

drivers/common/idpf/idpf_common_rxtx_avx512.c +1 -1
@@ -1005,7 +1005,7 @@ idpf_tx_singleq_free_bufs_avx512(struct
 idpf_tx_queue *txq)
 	struct rte_mbuf *m, *free[txq->rs_thresh];
 
 	/* check DD bits on threshold descriptor */
-	if ((txq->tx_ring[txq->next_dd].qw1.cmd_dtype &
+	if ((txq->tx_ring[txq->next_dd].qw1 &
 			rte_cpu_to_le_64(IDPF_TXD_QW1_DTYPE_M)) !=
 
	rte_cpu_to_le_64(IDPF_TX_DESC_DTYPE_DESC_DONE))
drivers/common/idpf/idpf_common_rxtx_avx512.c +1 -2
 		return 0;
@@ -1113,15 +1113,14 @@ tx_backlog_entry_avx512(struct
 idpf_tx_vec_entry *txep,
 		txep[i].mbuf = tx_pkts[i];
 }
 
-#define IDPF_FLEX_TXD_QW1_BUF_SZ_S 48  static __rte_always_inline
 void -idpf_singleq_vtx1(volatile struct idpf_flex_tx_desc *txdp,
+idpf_singleq_vtx1(volatile struct idpf_base_tx_desc *txdp,
 	  struct rte_mbuf *pkt, uint64_t flags)  {
 	uint64_t high_qw =
-		(IDPF_TX_DESC_DTYPE_FLEX_DATA <<

IDPF_FLEX_TXD_QW1_DTYPE_S |

drivers/common/idpf/idpf_common_rxtx_avx512.c +0 -2
-		 ((uint64_t)flags  << IDPF_FLEX_TXD_QW1_CMD_S) |
-		 ((uint64_t)pkt->data_len <<

IDPF_FLEX_TXD_QW1_BUF_SZ_S));

drivers/common/idpf/idpf_common_rxtx_avx512.c +3 -0
+		(IDPF_TX_DESC_DTYPE_DATA |
+		 ((uint64_t)flags  << IDPF_TXD_QW1_CMD_S) |
+		 ((uint64_t)pkt->data_len << IDPF_TXD_QW1_TX_BUF_SZ_S));
 
 	__m128i descriptor = _mm_set_epi64x(high_qw,
 					    pkt->buf_iova + pkt->data_off);
(quoted diff) +0 -0
@@ -1131,11 +1130,11 @@

drivers/common/idpf/idpf_common_rxtx_avx512.c

Quoted 39 lines

idpf_singleq_vtx1(volatile struct idpf_flex_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_flex_tx_desc *txdp,

drivers/common/idpf/idpf_common_rxtx_avx512.c +9 -6
+idpf_singleq_vtx(volatile struct idpf_base_tx_desc *txdp,
 	 struct rte_mbuf **pkt, uint16_t nb_pkts,  uint64_t flags)  {
-	const uint64_t hi_qw_tmpl = (IDPF_TX_DESC_DTYPE_FLEX_DATA  |
-			((uint64_t)flags  << IDPF_FLEX_TXD_QW1_CMD_S));
+	const uint64_t hi_qw_tmpl = (IDPF_TX_DESC_DTYPE_DATA  |
+			((uint64_t)flags  << IDPF_TXD_QW1_CMD_S));
 
 	/* if unaligned on 32-bit boundary, do one to align */
 	if (((uintptr_t)txdp & 0x1F) != 0 && nb_pkts != 0) { @@ -1148,19
+1147,19 @@ idpf_singleq_vtx(volatile struct idpf_flex_tx_desc
+*txdp,
 		uint64_t hi_qw3 =
 			hi_qw_tmpl |
 			((uint64_t)pkt[3]->data_len <<
-			 IDPF_FLEX_TXD_QW1_BUF_SZ_S);
+			 IDPF_TXD_QW1_TX_BUF_SZ_S);
 		uint64_t hi_qw2 =
 			hi_qw_tmpl |
 			((uint64_t)pkt[2]->data_len <<
-			 IDPF_FLEX_TXD_QW1_BUF_SZ_S);
+			 IDPF_TXD_QW1_TX_BUF_SZ_S);
 		uint64_t hi_qw1 =
 			hi_qw_tmpl |
 			((uint64_t)pkt[1]->data_len <<
-			 IDPF_FLEX_TXD_QW1_BUF_SZ_S);
+			 IDPF_TXD_QW1_TX_BUF_SZ_S);
 		uint64_t hi_qw0 =
 			hi_qw_tmpl |
 			((uint64_t)pkt[0]->data_len <<
-			 IDPF_FLEX_TXD_QW1_BUF_SZ_S);
+			 IDPF_TXD_QW1_TX_BUF_SZ_S);
 
 		__m512i desc0_3 =
 			_mm512_set_epi64
@@ -1187,11 +1186,11 @@

idpf_singleq_xmit_fixed_burst_vec_avx512(void

Quoted 14 lines
drivers/common/idpf/idpf_common_rxtx_avx512.c +3 -3
 *tx_queue, struct rte_mbuf **tx_pk
 					 uint16_t nb_pkts)
 {
 	struct idpf_tx_queue *txq = tx_queue;
-	volatile struct idpf_flex_tx_desc *txdp;
+	volatile struct idpf_base_tx_desc *txdp;
 	struct idpf_tx_vec_entry *txep;
 	uint16_t n, nb_commit, tx_id;
-	uint64_t flags = IDPF_TX_FLEX_DESC_CMD_EOP;
-	uint64_t rs = IDPF_TX_FLEX_DESC_CMD_RS | flags;
+	uint64_t flags = IDPF_TX_DESC_CMD_EOP;
+	uint64_t rs = IDPF_TX_DESC_CMD_RS | flags;
 
 	/* cross rx_thresh boundary is not allowed */
Quoted 1 line

nb_pkts = RTE_MIN(nb_pkts, txq->rs_thresh); @@ -1238,9 +1237,9

@@

Quoted 30 lines

idpf_singleq_xmit_fixed_burst_vec_avx512(void *tx_queue, struct rte_mbuf **tx_pk

drivers/common/idpf/idpf_common_rxtx_avx512.c +0 -2
 	tx_id = (uint16_t)(tx_id + nb_commit);
 	if (tx_id > txq->next_rs) {
-		txq->tx_ring[txq->next_rs].qw1.cmd_dtype |=
-
	rte_cpu_to_le_64(((uint64_t)IDPF_TX_FLEX_DESC_CMD_RS) <<
drivers/common/idpf/idpf_common_rxtx_avx512.c +2 -1
-					 IDPF_FLEX_TXD_QW1_CMD_S);
+		txq->tx_ring[txq->next_rs].qw1 |=
+
	rte_cpu_to_le_64(((uint64_t)IDPF_TX_DESC_CMD_RS) <<
drivers/common/idpf/idpf_common_rxtx_avx512.c +1 -0
+					 IDPF_TXD_QW1_CMD_S);
 		txq->next_rs =
 			(uint16_t)(txq->next_rs + txq->rs_thresh);
 	}
(quoted diff) +0 -0

b/drivers/net/idpf/idpf_rxtx.c index
3e3d81ca6d..64f2235580 100644

drivers/net/idpf/idpf_rxtx.c +1 -1
@@ -74,7 +74,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_flex_tx_desc),
+			ring_size = RTE_ALIGN(len * sizeof(struct
Quoted 8 lines
Quoted 6 lines

idpf_base_tx_desc),

drivers/net/idpf/idpf_rxtx.c +0 -1
 					      IDPF_DMA_MEM_ALIGN);
 		rte_memcpy(ring_name, "idpf Tx ring", sizeof("idpf Tx ring"));
 		break;
--

2.25.1

Quoted 1 line

Applied to dpdk-next-net-intel.

Reverted due to new change request.

#8 lore raw

RE: [PATCH v3] common/idpf: refactor single queue Tx function

In reply to Simei Su
Quoted 45 lines

-----Original Message-----
From: Su, Simei <[email protected]>
Sent: Friday, September 8, 2023 6:28 PM
To: Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; Zhang, Qi Z <[email protected]>
Cc: [email protected]; Wu, Wenjun1 <[email protected]>; Su, Simei <[email protected]>
Subject: [PATCH v3] common/idpf: refactor single queue Tx function

This patch replaces flex Tx descriptor with base Tx descriptor to align with kernel driver practice.

---
v3:
* Change context TSO descriptor from base mode to flex mode.

v2:
* Refine commit title and commit log.
* Remove redundant definition.
* Modify base mode context TSO descriptor.

 drivers/common/idpf/idpf_common_rxtx.c        | 39 +++++++++----------
 drivers/common/idpf/idpf_common_rxtx.h        |  2 +-
 drivers/common/idpf/idpf_common_rxtx_avx512.c | 37 +++++++++---------
 drivers/net/idpf/idpf_rxtx.c                  |  2 +-
 4 files changed, 39 insertions(+), 41 deletions(-)
drivers/net/idpf/idpf_rxtx.c index renamed from drivers/net/idpf/idpf_rxtx.c +0 -0

3e3d81ca6d..64f2235580 100644

drivers/net/idpf/idpf_rxtx.c +1 -1
@@ -74,7 +74,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_flex_tx_desc),
+			ring_size = RTE_ALIGN(len * sizeof(struct
Quoted 1 line

idpf_base_tx_desc),

Check if idpf_flex_tx_desc is used in cpfl PMD.

Quoted 5 lines
drivers/net/idpf/idpf_rxtx.c +0 -1
 					      IDPF_DMA_MEM_ALIGN);
 		rte_memcpy(ring_name, "idpf Tx ring", sizeof("idpf Tx ring"));
 		break;
--

2.25.1

author
#9 lore raw

v4 cover refactor single queue Tx data path

In reply to Simei Su

1. Refine single queue Tx data path for idpf common module.
2. Refine Tx queue setup for idpf pmd.
3. Refine Tx queue setup for cpfl pmd.

v4:
* Split one patch into patchset.
* Refine commit title and commit log.

v3:
* Change context TSO descriptor from base mode to flex mode.

v2:
* Refine commit title and commit log.
* Remove redundant definition.
* Modify base mode context TSO descriptor.

Simei Su (3):
common/idpf: refactor single queue Tx data path
net/idpf: refine Tx queue setup
net/cpfl: refine Tx queue setup

 drivers/common/idpf/idpf_common_rxtx.c        | 39 +++++++++----------
 drivers/common/idpf/idpf_common_rxtx.h        |  2 +-
 drivers/common/idpf/idpf_common_rxtx_avx512.c | 37 +++++++++---------
 drivers/net/cpfl/cpfl_rxtx.c                  |  2 +-
 drivers/net/idpf/idpf_rxtx.c                  |  2 +-
 5 files changed, 40 insertions(+), 42 deletions(-)
Signature · 1 line
2.25.1
author
#10 lore raw

PATCH v4 1/3 common/idpf: refactor single queue Tx data path

Currently, single queue Tx data path uses flex Tx data descriptor which is changed in the latest idpf spec. This patch replaces flex Tx data descriptor with base Tx data descriptor for single queue Tx data path.

---
 drivers/common/idpf/idpf_common_rxtx.c        | 39 +++++++++----------
 drivers/common/idpf/idpf_common_rxtx.h        |  2 +-
 drivers/common/idpf/idpf_common_rxtx_avx512.c | 37 +++++++++---------
 3 files changed, 38 insertions(+), 40 deletions(-)
drivers/common/idpf/idpf_common_rxtx.c +19 -20
index fc87e3e243..e6d2486272 100644
@@ -276,14 +276,14 @@ idpf_qc_single_tx_queue_reset(struct idpf_tx_queue *txq)
 	}
 
 	txe = txq->sw_ring;
-	size = sizeof(struct idpf_flex_tx_desc) * txq->nb_tx_desc;
+	size = sizeof(struct idpf_base_tx_desc) * txq->nb_tx_desc;
 	for (i = 0; i < size; i++)
 		((volatile char *)txq->tx_ring)[i] = 0;
 
 	prev = (uint16_t)(txq->nb_tx_desc - 1);
 	for (i = 0; i < txq->nb_tx_desc; i++) {
-		txq->tx_ring[i].qw1.cmd_dtype =
-			rte_cpu_to_le_16(IDPF_TX_DESC_DTYPE_DESC_DONE);
+		txq->tx_ring[i].qw1 =
+			rte_cpu_to_le_64(IDPF_TX_DESC_DTYPE_DESC_DONE);
 		txe[i].mbuf =  NULL;
 		txe[i].last_id = i;
 		txe[prev].next_id = i;
@@ -1307,17 +1307,16 @@ idpf_xmit_cleanup(struct idpf_tx_queue *txq)
 	uint16_t nb_tx_to_clean;
 	uint16_t i;
 
-	volatile struct idpf_flex_tx_desc *txd = txq->tx_ring;
+	volatile struct idpf_base_tx_desc *txd = txq->tx_ring;
 
 	desc_to_clean_to = (uint16_t)(last_desc_cleaned + txq->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;
-	/* In the writeback Tx desccriptor, the only significant fields are the 4-bit DTYPE */
-	if ((txd[desc_to_clean_to].qw1.cmd_dtype &
-	     rte_cpu_to_le_16(IDPF_TXD_QW1_DTYPE_M)) !=
-	    rte_cpu_to_le_16(IDPF_TX_DESC_DTYPE_DESC_DONE)) {
+	if ((txd[desc_to_clean_to].qw1 &
+	     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 "
 		       "(port=%d queue=%d)", desc_to_clean_to,
 		       txq->port_id, txq->queue_id);
@@ -1331,10 +1330,7 @@ idpf_xmit_cleanup(struct idpf_tx_queue *txq)
 		nb_tx_to_clean = (uint16_t)(desc_to_clean_to -
 					    last_desc_cleaned);
 
-	txd[desc_to_clean_to].qw1.cmd_dtype = 0;
-	txd[desc_to_clean_to].qw1.buf_size = 0;
-	for (i = 0; i < RTE_DIM(txd[desc_to_clean_to].qw1.flex.raw); i++)
-		txd[desc_to_clean_to].qw1.flex.raw[i] = 0;
+	txd[desc_to_clean_to].qw1 = 0;
 
 	txq->last_desc_cleaned = desc_to_clean_to;
 	txq->nb_free = (uint16_t)(txq->nb_free + nb_tx_to_clean);
@@ -1347,8 +1343,8 @@ uint16_t
 idpf_dp_singleq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 			  uint16_t nb_pkts)
 {
-	volatile struct idpf_flex_tx_desc *txd;
-	volatile struct idpf_flex_tx_desc *txr;
+	volatile struct idpf_base_tx_desc *txd;
+	volatile struct idpf_base_tx_desc *txr;
 	union idpf_tx_offload tx_offload = {0};
 	struct idpf_tx_entry *txe, *txn;
 	struct idpf_tx_entry *sw_ring;
@@ -1356,6 +1352,7 @@ idpf_dp_singleq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 	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;
@@ -1382,6 +1379,7 @@ idpf_dp_singleq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 
 	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);
@@ -1462,9 +1460,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->buf_addr = rte_cpu_to_le_64(buf_dma_addr);
-			txd->qw1.buf_size = slen;
-			txd->qw1.cmd_dtype = rte_cpu_to_le_16(IDPF_TX_DESC_DTYPE_FLEX_DATA <<
-							      IDPF_FLEX_TXD_QW1_DTYPE_S);
+			txd->qw1 = 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));
 
 			txe->last_id = tx_last;
 			tx_id = txe->next_id;
@@ -1473,7 +1472,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_FLEX_DESC_CMD_EOP;
+		td_cmd |= IDPF_TX_DESC_CMD_EOP;
 		txq->nb_used = (uint16_t)(txq->nb_used + nb_used);
 		txq->nb_free = (uint16_t)(txq->nb_free - nb_used);
 
@@ -1482,7 +1481,7 @@ 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_FLEX_DESC_CMD_RS;
+			td_cmd |= IDPF_TX_DESC_CMD_RS;
 
 			/* Update txq RS bit counters */
 			txq->nb_used = 0;
@@ -1491,7 +1490,7 @@ idpf_dp_singleq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 		if (ol_flags & IDPF_TX_CKSUM_OFFLOAD_MASK)
 			td_cmd |= IDPF_TX_FLEX_DESC_CMD_CS_EN;
 
-		txd->qw1.cmd_dtype |= rte_cpu_to_le_16(td_cmd << IDPF_FLEX_TXD_QW1_CMD_S);
+		txd->qw1 |= rte_cpu_to_le_16(td_cmd << IDPF_TXD_QW1_CMD_S);
 	}
 
 end_of_tx:
drivers/common/idpf/idpf_common_rxtx.h +1 -1
index 6cb83fc0a6..b49b1ed737 100644
@@ -157,7 +157,7 @@ struct idpf_tx_entry {
 /* Structure associated with each TX queue. */
 struct idpf_tx_queue {
 	const struct rte_memzone *mz;		/* memzone for Tx ring */
-	volatile struct idpf_flex_tx_desc *tx_ring;	/* Tx ring virtual address */
+	volatile struct idpf_base_tx_desc *tx_ring;	/* Tx ring virtual address */
 	volatile union {
 		struct idpf_flex_tx_sched_desc *desc_ring;
 		struct idpf_splitq_tx_compl_desc *compl_ring;
drivers/common/idpf/idpf_common_rxtx_avx512.c +18 -19
index 2ac46fb1d2..f65e8d512b 100644
@@ -1005,7 +1005,7 @@ idpf_tx_singleq_free_bufs_avx512(struct idpf_tx_queue *txq)
 	struct rte_mbuf *m, *free[txq->rs_thresh];
 
 	/* check DD bits on threshold descriptor */
-	if ((txq->tx_ring[txq->next_dd].qw1.cmd_dtype &
+	if ((txq->tx_ring[txq->next_dd].qw1 &
 			rte_cpu_to_le_64(IDPF_TXD_QW1_DTYPE_M)) !=
 			rte_cpu_to_le_64(IDPF_TX_DESC_DTYPE_DESC_DONE))
 		return 0;
@@ -1113,15 +1113,14 @@ tx_backlog_entry_avx512(struct idpf_tx_vec_entry *txep,
 		txep[i].mbuf = tx_pkts[i];
 }
 
-#define IDPF_FLEX_TXD_QW1_BUF_SZ_S 48
 static __rte_always_inline void
-idpf_singleq_vtx1(volatile struct idpf_flex_tx_desc *txdp,
+idpf_singleq_vtx1(volatile struct idpf_base_tx_desc *txdp,
 	  struct rte_mbuf *pkt, uint64_t flags)
 {
 	uint64_t high_qw =
-		(IDPF_TX_DESC_DTYPE_FLEX_DATA << IDPF_FLEX_TXD_QW1_DTYPE_S |
-		 ((uint64_t)flags  << IDPF_FLEX_TXD_QW1_CMD_S) |
-		 ((uint64_t)pkt->data_len << IDPF_FLEX_TXD_QW1_BUF_SZ_S));
+		(IDPF_TX_DESC_DTYPE_DATA |
+		 ((uint64_t)flags  << IDPF_TXD_QW1_CMD_S) |
+		 ((uint64_t)pkt->data_len << IDPF_TXD_QW1_TX_BUF_SZ_S));
 
 	__m128i descriptor = _mm_set_epi64x(high_qw,
 					    pkt->buf_iova + pkt->data_off);
@@ -1131,11 +1130,11 @@ idpf_singleq_vtx1(volatile struct idpf_flex_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_flex_tx_desc *txdp,
+idpf_singleq_vtx(volatile struct idpf_base_tx_desc *txdp,
 	 struct rte_mbuf **pkt, uint16_t nb_pkts,  uint64_t flags)
 {
-	const uint64_t hi_qw_tmpl = (IDPF_TX_DESC_DTYPE_FLEX_DATA  |
-			((uint64_t)flags  << IDPF_FLEX_TXD_QW1_CMD_S));
+	const uint64_t hi_qw_tmpl = (IDPF_TX_DESC_DTYPE_DATA  |
+			((uint64_t)flags  << IDPF_TXD_QW1_CMD_S));
 
 	/* if unaligned on 32-bit boundary, do one to align */
 	if (((uintptr_t)txdp & 0x1F) != 0 && nb_pkts != 0) {
@@ -1148,19 +1147,19 @@ idpf_singleq_vtx(volatile struct idpf_flex_tx_desc *txdp,
 		uint64_t hi_qw3 =
 			hi_qw_tmpl |
 			((uint64_t)pkt[3]->data_len <<
-			 IDPF_FLEX_TXD_QW1_BUF_SZ_S);
+			 IDPF_TXD_QW1_TX_BUF_SZ_S);
 		uint64_t hi_qw2 =
 			hi_qw_tmpl |
 			((uint64_t)pkt[2]->data_len <<
-			 IDPF_FLEX_TXD_QW1_BUF_SZ_S);
+			 IDPF_TXD_QW1_TX_BUF_SZ_S);
 		uint64_t hi_qw1 =
 			hi_qw_tmpl |
 			((uint64_t)pkt[1]->data_len <<
-			 IDPF_FLEX_TXD_QW1_BUF_SZ_S);
+			 IDPF_TXD_QW1_TX_BUF_SZ_S);
 		uint64_t hi_qw0 =
 			hi_qw_tmpl |
 			((uint64_t)pkt[0]->data_len <<
-			 IDPF_FLEX_TXD_QW1_BUF_SZ_S);
+			 IDPF_TXD_QW1_TX_BUF_SZ_S);
 
 		__m512i desc0_3 =
 			_mm512_set_epi64
@@ -1187,11 +1186,11 @@ idpf_singleq_xmit_fixed_burst_vec_avx512(void *tx_queue, struct rte_mbuf **tx_pk
 					 uint16_t nb_pkts)
 {
 	struct idpf_tx_queue *txq = tx_queue;
-	volatile struct idpf_flex_tx_desc *txdp;
+	volatile struct idpf_base_tx_desc *txdp;
 	struct idpf_tx_vec_entry *txep;
 	uint16_t n, nb_commit, tx_id;
-	uint64_t flags = IDPF_TX_FLEX_DESC_CMD_EOP;
-	uint64_t rs = IDPF_TX_FLEX_DESC_CMD_RS | flags;
+	uint64_t flags = IDPF_TX_DESC_CMD_EOP;
+	uint64_t rs = IDPF_TX_DESC_CMD_RS | flags;
 
 	/* cross rx_thresh boundary is not allowed */
 	nb_pkts = RTE_MIN(nb_pkts, txq->rs_thresh);
@@ -1238,9 +1237,9 @@ 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->next_rs) {
-		txq->tx_ring[txq->next_rs].qw1.cmd_dtype |=
-			rte_cpu_to_le_64(((uint64_t)IDPF_TX_FLEX_DESC_CMD_RS) <<
-					 IDPF_FLEX_TXD_QW1_CMD_S);
+		txq->tx_ring[txq->next_rs].qw1 |=
+			rte_cpu_to_le_64(((uint64_t)IDPF_TX_DESC_CMD_RS) <<
+					 IDPF_TXD_QW1_CMD_S);
 		txq->next_rs =
 			(uint16_t)(txq->next_rs + txq->rs_thresh);
 	}
Signature · 1 line
2.25.1
author
#11 lore raw

PATCH v4 2/3 net/idpf: refine Tx queue setup

In reply to Simei Su

This patch refines Tx single queue setup to align with Tx data path.

---
 drivers/net/idpf/idpf_rxtx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/idpf/idpf_rxtx.c +1 -1
index 3e3d81ca6d..64f2235580 100644
@@ -74,7 +74,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_flex_tx_desc),
+			ring_size = RTE_ALIGN(len * sizeof(struct idpf_base_tx_desc),
 					      IDPF_DMA_MEM_ALIGN);
 		rte_memcpy(ring_name, "idpf Tx ring", sizeof("idpf Tx ring"));
 		break;
Signature · 1 line
2.25.1
author
#12 lore raw

PATCH v4 3/3 net/cpfl: refine Tx queue setup

In reply to Simei Su

This patch refines Tx single queue setup to align with Tx data path.

---
 drivers/net/cpfl/cpfl_rxtx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/cpfl/cpfl_rxtx.c +1 -1
index 2ef6871a85..ab8bec4645 100644
@@ -135,7 +135,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_flex_tx_desc),
+			ring_size = RTE_ALIGN(len * sizeof(struct idpf_base_tx_desc),
 					      CPFL_DMA_MEM_ALIGN);
 		memcpy(ring_name, "cpfl Tx ring", sizeof("cpfl Tx ring"));
 		break;
Signature · 1 line
2.25.1
Acked-by on the v4 series
#13 lore raw

RE: [PATCH v4 0/3] refactor single queue Tx data path

In reply to Simei Su
Quoted 39 lines

-----Original Message-----
From: Su, Simei <[email protected]>
Sent: Thursday, September 14, 2023 9:50 AM
To: Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; Zhang, Qi Z <[email protected]>
Cc: [email protected]; Wu, Wenjun1 <[email protected]>; Su, Simei <[email protected]>
Subject: [PATCH v4 0/3] refactor single queue Tx data path

1. Refine single queue Tx data path for idpf common module.
2. Refine Tx queue setup for idpf pmd.
3. Refine Tx queue setup for cpfl pmd.

v4:
* Split one patch into patchset.
* Refine commit title and commit log.

v3:
* Change context TSO descriptor from base mode to flex mode.

v2:
* Refine commit title and commit log.
* Remove redundant definition.
* Modify base mode context TSO descriptor.

Simei Su (3):
common/idpf: refactor single queue Tx data path
net/idpf: refine Tx queue setup
net/cpfl: refine Tx queue setup

 drivers/common/idpf/idpf_common_rxtx.c        | 39 +++++++++----------
 drivers/common/idpf/idpf_common_rxtx.h        |  2 +-
 drivers/common/idpf/idpf_common_rxtx_avx512.c | 37 +++++++++---------
 drivers/net/cpfl/cpfl_rxtx.c                  |  2 +-
 drivers/net/idpf/idpf_rxtx.c                  |  2 +-
 5 files changed, 40 insertions(+), 42 deletions(-)
Quoted 2 lines

--
2.25.1

author
#14 lore raw

PATCH v5 1/1 common/idpf: refactor single queue Tx data path

In reply to Simei Su

Currently, single queue Tx data path uses flex Tx data descriptor(DTYPE3) which is removed in the latest idpf spec. This patch replaces flex Tx data descriptor with base Tx data descriptor for single queue Tx data path and refines Tx single queue setup to align with Tx data path.

---
 drivers/common/idpf/idpf_common_rxtx.c        | 39 +++++++++----------
 drivers/common/idpf/idpf_common_rxtx.h        |  2 +-
 drivers/common/idpf/idpf_common_rxtx_avx512.c | 37 +++++++++---------
 drivers/net/cpfl/cpfl_rxtx.c                  |  2 +-
 drivers/net/idpf/idpf_rxtx.c                  |  2 +-
 5 files changed, 40 insertions(+), 42 deletions(-)
drivers/common/idpf/idpf_common_rxtx.c +19 -20
index fc87e3e243..e6d2486272 100644
@@ -276,14 +276,14 @@ idpf_qc_single_tx_queue_reset(struct idpf_tx_queue *txq)
 	}
 
 	txe = txq->sw_ring;
-	size = sizeof(struct idpf_flex_tx_desc) * txq->nb_tx_desc;
+	size = sizeof(struct idpf_base_tx_desc) * txq->nb_tx_desc;
 	for (i = 0; i < size; i++)
 		((volatile char *)txq->tx_ring)[i] = 0;
 
 	prev = (uint16_t)(txq->nb_tx_desc - 1);
 	for (i = 0; i < txq->nb_tx_desc; i++) {
-		txq->tx_ring[i].qw1.cmd_dtype =
-			rte_cpu_to_le_16(IDPF_TX_DESC_DTYPE_DESC_DONE);
+		txq->tx_ring[i].qw1 =
+			rte_cpu_to_le_64(IDPF_TX_DESC_DTYPE_DESC_DONE);
 		txe[i].mbuf =  NULL;
 		txe[i].last_id = i;
 		txe[prev].next_id = i;
@@ -1307,17 +1307,16 @@ idpf_xmit_cleanup(struct idpf_tx_queue *txq)
 	uint16_t nb_tx_to_clean;
 	uint16_t i;
 
-	volatile struct idpf_flex_tx_desc *txd = txq->tx_ring;
+	volatile struct idpf_base_tx_desc *txd = txq->tx_ring;
 
 	desc_to_clean_to = (uint16_t)(last_desc_cleaned + txq->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;
-	/* In the writeback Tx desccriptor, the only significant fields are the 4-bit DTYPE */
-	if ((txd[desc_to_clean_to].qw1.cmd_dtype &
-	     rte_cpu_to_le_16(IDPF_TXD_QW1_DTYPE_M)) !=
-	    rte_cpu_to_le_16(IDPF_TX_DESC_DTYPE_DESC_DONE)) {
+	if ((txd[desc_to_clean_to].qw1 &
+	     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 "
 		       "(port=%d queue=%d)", desc_to_clean_to,
 		       txq->port_id, txq->queue_id);
@@ -1331,10 +1330,7 @@ idpf_xmit_cleanup(struct idpf_tx_queue *txq)
 		nb_tx_to_clean = (uint16_t)(desc_to_clean_to -
 					    last_desc_cleaned);
 
-	txd[desc_to_clean_to].qw1.cmd_dtype = 0;
-	txd[desc_to_clean_to].qw1.buf_size = 0;
-	for (i = 0; i < RTE_DIM(txd[desc_to_clean_to].qw1.flex.raw); i++)
-		txd[desc_to_clean_to].qw1.flex.raw[i] = 0;
+	txd[desc_to_clean_to].qw1 = 0;
 
 	txq->last_desc_cleaned = desc_to_clean_to;
 	txq->nb_free = (uint16_t)(txq->nb_free + nb_tx_to_clean);
@@ -1347,8 +1343,8 @@ uint16_t
 idpf_dp_singleq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 			  uint16_t nb_pkts)
 {
-	volatile struct idpf_flex_tx_desc *txd;
-	volatile struct idpf_flex_tx_desc *txr;
+	volatile struct idpf_base_tx_desc *txd;
+	volatile struct idpf_base_tx_desc *txr;
 	union idpf_tx_offload tx_offload = {0};
 	struct idpf_tx_entry *txe, *txn;
 	struct idpf_tx_entry *sw_ring;
@@ -1356,6 +1352,7 @@ idpf_dp_singleq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 	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;
@@ -1382,6 +1379,7 @@ idpf_dp_singleq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 
 	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);
@@ -1462,9 +1460,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->buf_addr = rte_cpu_to_le_64(buf_dma_addr);
-			txd->qw1.buf_size = slen;
-			txd->qw1.cmd_dtype = rte_cpu_to_le_16(IDPF_TX_DESC_DTYPE_FLEX_DATA <<
-							      IDPF_FLEX_TXD_QW1_DTYPE_S);
+			txd->qw1 = 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));
 
 			txe->last_id = tx_last;
 			tx_id = txe->next_id;
@@ -1473,7 +1472,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_FLEX_DESC_CMD_EOP;
+		td_cmd |= IDPF_TX_DESC_CMD_EOP;
 		txq->nb_used = (uint16_t)(txq->nb_used + nb_used);
 		txq->nb_free = (uint16_t)(txq->nb_free - nb_used);
 
@@ -1482,7 +1481,7 @@ 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_FLEX_DESC_CMD_RS;
+			td_cmd |= IDPF_TX_DESC_CMD_RS;
 
 			/* Update txq RS bit counters */
 			txq->nb_used = 0;
@@ -1491,7 +1490,7 @@ idpf_dp_singleq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 		if (ol_flags & IDPF_TX_CKSUM_OFFLOAD_MASK)
 			td_cmd |= IDPF_TX_FLEX_DESC_CMD_CS_EN;
 
-		txd->qw1.cmd_dtype |= rte_cpu_to_le_16(td_cmd << IDPF_FLEX_TXD_QW1_CMD_S);
+		txd->qw1 |= rte_cpu_to_le_16(td_cmd << IDPF_TXD_QW1_CMD_S);
 	}
 
 end_of_tx:
drivers/common/idpf/idpf_common_rxtx.h +1 -1
index 6cb83fc0a6..b49b1ed737 100644
@@ -157,7 +157,7 @@ struct idpf_tx_entry {
 /* Structure associated with each TX queue. */
 struct idpf_tx_queue {
 	const struct rte_memzone *mz;		/* memzone for Tx ring */
-	volatile struct idpf_flex_tx_desc *tx_ring;	/* Tx ring virtual address */
+	volatile struct idpf_base_tx_desc *tx_ring;	/* Tx ring virtual address */
 	volatile union {
 		struct idpf_flex_tx_sched_desc *desc_ring;
 		struct idpf_splitq_tx_compl_desc *compl_ring;
drivers/common/idpf/idpf_common_rxtx_avx512.c +18 -19
index 2ac46fb1d2..f65e8d512b 100644
@@ -1005,7 +1005,7 @@ idpf_tx_singleq_free_bufs_avx512(struct idpf_tx_queue *txq)
 	struct rte_mbuf *m, *free[txq->rs_thresh];
 
 	/* check DD bits on threshold descriptor */
-	if ((txq->tx_ring[txq->next_dd].qw1.cmd_dtype &
+	if ((txq->tx_ring[txq->next_dd].qw1 &
 			rte_cpu_to_le_64(IDPF_TXD_QW1_DTYPE_M)) !=
 			rte_cpu_to_le_64(IDPF_TX_DESC_DTYPE_DESC_DONE))
 		return 0;
@@ -1113,15 +1113,14 @@ tx_backlog_entry_avx512(struct idpf_tx_vec_entry *txep,
 		txep[i].mbuf = tx_pkts[i];
 }
 
-#define IDPF_FLEX_TXD_QW1_BUF_SZ_S 48
 static __rte_always_inline void
-idpf_singleq_vtx1(volatile struct idpf_flex_tx_desc *txdp,
+idpf_singleq_vtx1(volatile struct idpf_base_tx_desc *txdp,
 	  struct rte_mbuf *pkt, uint64_t flags)
 {
 	uint64_t high_qw =
-		(IDPF_TX_DESC_DTYPE_FLEX_DATA << IDPF_FLEX_TXD_QW1_DTYPE_S |
-		 ((uint64_t)flags  << IDPF_FLEX_TXD_QW1_CMD_S) |
-		 ((uint64_t)pkt->data_len << IDPF_FLEX_TXD_QW1_BUF_SZ_S));
+		(IDPF_TX_DESC_DTYPE_DATA |
+		 ((uint64_t)flags  << IDPF_TXD_QW1_CMD_S) |
+		 ((uint64_t)pkt->data_len << IDPF_TXD_QW1_TX_BUF_SZ_S));
 
 	__m128i descriptor = _mm_set_epi64x(high_qw,
 					    pkt->buf_iova + pkt->data_off);
@@ -1131,11 +1130,11 @@ idpf_singleq_vtx1(volatile struct idpf_flex_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_flex_tx_desc *txdp,
+idpf_singleq_vtx(volatile struct idpf_base_tx_desc *txdp,
 	 struct rte_mbuf **pkt, uint16_t nb_pkts,  uint64_t flags)
 {
-	const uint64_t hi_qw_tmpl = (IDPF_TX_DESC_DTYPE_FLEX_DATA  |
-			((uint64_t)flags  << IDPF_FLEX_TXD_QW1_CMD_S));
+	const uint64_t hi_qw_tmpl = (IDPF_TX_DESC_DTYPE_DATA  |
+			((uint64_t)flags  << IDPF_TXD_QW1_CMD_S));
 
 	/* if unaligned on 32-bit boundary, do one to align */
 	if (((uintptr_t)txdp & 0x1F) != 0 && nb_pkts != 0) {
@@ -1148,19 +1147,19 @@ idpf_singleq_vtx(volatile struct idpf_flex_tx_desc *txdp,
 		uint64_t hi_qw3 =
 			hi_qw_tmpl |
 			((uint64_t)pkt[3]->data_len <<
-			 IDPF_FLEX_TXD_QW1_BUF_SZ_S);
+			 IDPF_TXD_QW1_TX_BUF_SZ_S);
 		uint64_t hi_qw2 =
 			hi_qw_tmpl |
 			((uint64_t)pkt[2]->data_len <<
-			 IDPF_FLEX_TXD_QW1_BUF_SZ_S);
+			 IDPF_TXD_QW1_TX_BUF_SZ_S);
 		uint64_t hi_qw1 =
 			hi_qw_tmpl |
 			((uint64_t)pkt[1]->data_len <<
-			 IDPF_FLEX_TXD_QW1_BUF_SZ_S);
+			 IDPF_TXD_QW1_TX_BUF_SZ_S);
 		uint64_t hi_qw0 =
 			hi_qw_tmpl |
 			((uint64_t)pkt[0]->data_len <<
-			 IDPF_FLEX_TXD_QW1_BUF_SZ_S);
+			 IDPF_TXD_QW1_TX_BUF_SZ_S);
 
 		__m512i desc0_3 =
 			_mm512_set_epi64
@@ -1187,11 +1186,11 @@ idpf_singleq_xmit_fixed_burst_vec_avx512(void *tx_queue, struct rte_mbuf **tx_pk
 					 uint16_t nb_pkts)
 {
 	struct idpf_tx_queue *txq = tx_queue;
-	volatile struct idpf_flex_tx_desc *txdp;
+	volatile struct idpf_base_tx_desc *txdp;
 	struct idpf_tx_vec_entry *txep;
 	uint16_t n, nb_commit, tx_id;
-	uint64_t flags = IDPF_TX_FLEX_DESC_CMD_EOP;
-	uint64_t rs = IDPF_TX_FLEX_DESC_CMD_RS | flags;
+	uint64_t flags = IDPF_TX_DESC_CMD_EOP;
+	uint64_t rs = IDPF_TX_DESC_CMD_RS | flags;
 
 	/* cross rx_thresh boundary is not allowed */
 	nb_pkts = RTE_MIN(nb_pkts, txq->rs_thresh);
@@ -1238,9 +1237,9 @@ 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->next_rs) {
-		txq->tx_ring[txq->next_rs].qw1.cmd_dtype |=
-			rte_cpu_to_le_64(((uint64_t)IDPF_TX_FLEX_DESC_CMD_RS) <<
-					 IDPF_FLEX_TXD_QW1_CMD_S);
+		txq->tx_ring[txq->next_rs].qw1 |=
+			rte_cpu_to_le_64(((uint64_t)IDPF_TX_DESC_CMD_RS) <<
+					 IDPF_TXD_QW1_CMD_S);
 		txq->next_rs =
 			(uint16_t)(txq->next_rs + txq->rs_thresh);
 	}
drivers/net/cpfl/cpfl_rxtx.c +1 -1
index 2ef6871a85..ab8bec4645 100644
@@ -135,7 +135,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_flex_tx_desc),
+			ring_size = RTE_ALIGN(len * sizeof(struct idpf_base_tx_desc),
 					      CPFL_DMA_MEM_ALIGN);
 		memcpy(ring_name, "cpfl Tx ring", sizeof("cpfl Tx ring"));
 		break;
drivers/net/idpf/idpf_rxtx.c +1 -1
index 3e3d81ca6d..64f2235580 100644
@@ -74,7 +74,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_flex_tx_desc),
+			ring_size = RTE_ALIGN(len * sizeof(struct idpf_base_tx_desc),
 					      IDPF_DMA_MEM_ALIGN);
 		rte_memcpy(ring_name, "idpf Tx ring", sizeof("idpf Tx ring"));
 		break;
Signature · 1 line
2.25.1
Applied
#15 lore raw

RE: [PATCH v5] common/idpf: refactor single queue Tx data path

Quoted 17 lines

-----Original Message-----
From: Su, Simei <[email protected]>
Sent: Thursday, September 14, 2023 2:37 PM
To: Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; Zhang, Qi Z <[email protected]>
Cc: [email protected]; Wu, Wenjun1 <[email protected]>; Su, Simei <[email protected]>
Subject: [PATCH v5] common/idpf: refactor single queue Tx data path

Currently, single queue Tx data path uses flex Tx data descriptor(DTYPE3) which is removed in the latest idpf spec. This patch replaces flex Tx data descriptor with base Tx data descriptor for single queue Tx data path and refines Tx single queue setup to align with Tx data path.

Quoted 3 lines

Applied to dpdk-next-net-intel.

Thanks
Qi