[v6,08/23] net/hns3: use mbuf descriptor accessors

Message ID 1709012499-12813-9-git-send-email-roretzla@linux.microsoft.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series stop and remove RTE_MARKER typedefs |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Tyler Retzlaff Feb. 27, 2024, 5:41 a.m. UTC
  RTE_MARKER typedefs are a GCC extension unsupported by MSVC. Use
new rte_mbuf_rearm_data and rte_mbuf_rx_descriptor_fields1 accessors
that provide a compatible type pointer without using the marker fields.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 drivers/net/hns3/hns3_rxtx_vec.c      | 22 +---------------------
 drivers/net/hns3/hns3_rxtx_vec_neon.h | 24 ++++++++----------------
 drivers/net/hns3/hns3_rxtx_vec_sve.c  |  4 ++--
 3 files changed, 11 insertions(+), 39 deletions(-)
  

Patch

diff --git a/drivers/net/hns3/hns3_rxtx_vec.c b/drivers/net/hns3/hns3_rxtx_vec.c
index 9708ec6..d6c9e80 100644
--- a/drivers/net/hns3/hns3_rxtx_vec.c
+++ b/drivers/net/hns3/hns3_rxtx_vec.c
@@ -113,7 +113,6 @@ 
 static void
 hns3_rxq_vec_setup_rearm_data(struct hns3_rx_queue *rxq)
 {
-	uintptr_t p;
 	struct rte_mbuf mb_def = { .buf_addr = 0 }; /* zeroed mbuf */
 
 	mb_def.nb_segs = 1;
@@ -121,28 +120,9 @@ 
 	mb_def.port = rxq->port_id;
 	rte_mbuf_refcnt_set(&mb_def, 1);
 
-	/* compile-time verifies the rearm_data first 8bytes */
-	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, data_off) <
-			 offsetof(struct rte_mbuf, rearm_data));
-	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, refcnt) <
-			 offsetof(struct rte_mbuf, rearm_data));
-	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, nb_segs) <
-			 offsetof(struct rte_mbuf, rearm_data));
-	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, port) <
-			 offsetof(struct rte_mbuf, rearm_data));
-	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, data_off) -
-			 offsetof(struct rte_mbuf, rearm_data) > 6);
-	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, refcnt) -
-			 offsetof(struct rte_mbuf, rearm_data) > 6);
-	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, nb_segs) -
-			 offsetof(struct rte_mbuf, rearm_data) > 6);
-	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, port) -
-			 offsetof(struct rte_mbuf, rearm_data) > 6);
-
 	/* prevent compiler reordering: rearm_data covers previous fields */
 	rte_compiler_barrier();
-	p = (uintptr_t)&mb_def.rearm_data;
-	rxq->mbuf_initializer = *(uint64_t *)p;
+	rxq->mbuf_initializer = *rte_mbuf_rearm_data(&mb_def);
 }
 
 void
diff --git a/drivers/net/hns3/hns3_rxtx_vec_neon.h b/drivers/net/hns3/hns3_rxtx_vec_neon.h
index 0dc6b9f..6f46131 100644
--- a/drivers/net/hns3/hns3_rxtx_vec_neon.h
+++ b/drivers/net/hns3/hns3_rxtx_vec_neon.h
@@ -156,14 +156,6 @@ 
 		0, 0, 0,      /* ignore non-length fields */
 	};
 
-	/* compile-time verifies the shuffle mask */
-	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, pkt_len) !=
-			 offsetof(struct rte_mbuf, rx_descriptor_fields1) + 4);
-	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, data_len) !=
-			 offsetof(struct rte_mbuf, rx_descriptor_fields1) + 8);
-	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, hash.rss) !=
-			 offsetof(struct rte_mbuf, rx_descriptor_fields1) + 12);
-
 	for (pos = 0; pos < nb_pkts; pos += HNS3_DEFAULT_DESCS_PER_LOOP,
 				     rxdp += HNS3_DEFAULT_DESCS_PER_LOOP) {
 		uint64x2x2_t descs[HNS3_DEFAULT_DESCS_PER_LOOP];
@@ -236,23 +228,23 @@ 
 		pkt_mb4 = vreinterpretq_u8_u16(tmp);
 
 		/* save packet info to rx_pkts mbuf */
-		vst1q_u8((void *)&sw_ring[pos + 0].mbuf->rx_descriptor_fields1,
+		vst1q_u8(rte_mbuf_rx_descriptor_fields1(sw_ring[pos + 0].mbuf),
 			 pkt_mb1);
-		vst1q_u8((void *)&sw_ring[pos + 1].mbuf->rx_descriptor_fields1,
+		vst1q_u8(rte_mbuf_rx_descriptor_fields1(sw_ring[pos + 1].mbuf),
 			 pkt_mb2);
-		vst1q_u8((void *)&sw_ring[pos + 2].mbuf->rx_descriptor_fields1,
+		vst1q_u8(rte_mbuf_rx_descriptor_fields1(sw_ring[pos + 2].mbuf),
 			 pkt_mb3);
-		vst1q_u8((void *)&sw_ring[pos + 3].mbuf->rx_descriptor_fields1,
+		vst1q_u8(rte_mbuf_rx_descriptor_fields1(sw_ring[pos + 3].mbuf),
 			 pkt_mb4);
 
 		/* store the first 8 bytes of packets mbuf's rearm_data */
-		*(uint64_t *)&sw_ring[pos + 0].mbuf->rearm_data =
+		*rte_mbuf_rearm_data(sw_ring[pos + 0].mbuf) =
 			rxq->mbuf_initializer;
-		*(uint64_t *)&sw_ring[pos + 1].mbuf->rearm_data =
+		*rte_mbuf_rearm_data(sw_ring[pos + 1].mbuf) =
 			rxq->mbuf_initializer;
-		*(uint64_t *)&sw_ring[pos + 2].mbuf->rearm_data =
+		*rte_mbuf_rearm_data(sw_ring[pos + 2].mbuf) =
 			rxq->mbuf_initializer;
-		*(uint64_t *)&sw_ring[pos + 3].mbuf->rearm_data =
+		*rte_mbuf_rearm_data(sw_ring[pos + 3].mbuf) =
 			rxq->mbuf_initializer;
 
 		rte_prefetch_non_temporal(rxdp + HNS3_DEFAULT_DESCS_PER_LOOP);
diff --git a/drivers/net/hns3/hns3_rxtx_vec_sve.c b/drivers/net/hns3/hns3_rxtx_vec_sve.c
index 8aa4448..f6259d1 100644
--- a/drivers/net/hns3/hns3_rxtx_vec_sve.c
+++ b/drivers/net/hns3/hns3_rxtx_vec_sve.c
@@ -123,9 +123,9 @@ 
 		mbuf_init = svdup_n_u64(rxq->mbuf_initializer);
 		/* save mbuf_initializer */
 		svst1_scatter_u64base_offset_u64(PG64_256BIT, mbp1st,
-			offsetof(struct rte_mbuf, rearm_data), mbuf_init);
+			offsetof(struct rte_mbuf, data_off), mbuf_init);
 		svst1_scatter_u64base_offset_u64(PG64_256BIT, mbp2st,
-			offsetof(struct rte_mbuf, rearm_data), mbuf_init);
+			offsetof(struct rte_mbuf, data_off), mbuf_init);
 
 		next_rxdp = rxdp + HNS3_SVE_DEFAULT_DESCS_PER_LOOP;
 		rte_prefetch_non_temporal(next_rxdp);