Skip to contentSkip to conversation

replace GCC marker extension with C11 anonymous unions

PATCH New Tyler Retzlaff 9 participants 177 messages Jan 30, 2024 – Jun 19, 2024 Network drivers Page 1 of 2

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 replace GCC marker extension with C11 anonymous unions

The zero sized RTE_MARKER<n> typedefs are a GCC extension unsupported by MSVC. Replace the use of the RTE_MARKER typedefs with anonymous unions.

both lib/mbuf and consuming drivers have been updated in the same commit to avoid driver build break.

note:
since rte_mbuf is a public structure it might be argued that the removal of the ability to access the fields as an array could be an api break. there is no intended change in the application abi.

Tyler Retzlaff (1):
mbuf: replace GCC marker extension with C11 anonymous unions

 drivers/net/ionic/ionic_lif.c               |   8 +-
 drivers/net/ionic/ionic_rxtx_sg.c           |   4 +-
 drivers/net/ionic/ionic_rxtx_simple.c       |   2 +-
 drivers/net/sfc/sfc_ef100_rx.c              |   8 +-
 drivers/net/sfc/sfc_ef10_rx.c               |  12 +--
 drivers/net/virtio/virtio_rxtx_packed_avx.h |   8 +-
 lib/mbuf/rte_mbuf_core.h                    | 135 +++++++++++++++-------------
 7 files changed, 94 insertions(+), 83 deletions(-)
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH 1/1 mbuf: replace GCC marker extension with C11 anonymous unions

Replace the use of RTE_MARKER<x> with C11 anonymous unions to improve code portability between toolchains.

Update use of rte_mbuf rearm_data field in net/ionic, net/sfc and net/virtio which were accessing field as a zero-length array.

---
 drivers/net/ionic/ionic_lif.c               |   8 +-
 drivers/net/ionic/ionic_rxtx_sg.c           |   4 +-
 drivers/net/ionic/ionic_rxtx_simple.c       |   2 +-
 drivers/net/sfc/sfc_ef100_rx.c              |   8 +-
 drivers/net/sfc/sfc_ef10_rx.c               |  12 +--
 drivers/net/virtio/virtio_rxtx_packed_avx.h |   8 +-
 lib/mbuf/rte_mbuf_core.h                    | 135 +++++++++++++++-------------
 7 files changed, 94 insertions(+), 83 deletions(-)
drivers/net/ionic/ionic_lif.c +4 -4
index 25b490d..fd99f39 100644
@@ -725,8 +725,8 @@
 
 	rte_compiler_barrier();
 
-	RTE_BUILD_BUG_ON(sizeof(rxm.rearm_data[0]) != sizeof(uint64_t));
-	return rxm.rearm_data[0];
+	RTE_BUILD_BUG_ON(sizeof(rxm.rearm_data) != sizeof(uint64_t));
+	return rxm.rearm_data;
 }
 
 static uint64_t
@@ -743,8 +743,8 @@
 
 	rte_compiler_barrier();
 
-	RTE_BUILD_BUG_ON(sizeof(rxm.rearm_data[0]) != sizeof(uint64_t));
-	return rxm.rearm_data[0];
+	RTE_BUILD_BUG_ON(sizeof(rxm.rearm_data) != sizeof(uint64_t));
+	return rxm.rearm_data;
 }
 
 int
drivers/net/ionic/ionic_rxtx_sg.c +2 -2
index ab8e56e..a569dd1 100644
@@ -285,7 +285,7 @@
 	info[0] = NULL;
 
 	/* Set the mbuf metadata based on the cq entry */
-	rxm->rearm_data[0] = rxq->rearm_data;
+	rxm->rearm_data = rxq->rearm_data;
 	rxm->pkt_len = cq_desc_len;
 	rxm->data_len = RTE_MIN(rxq->hdr_seg_size, cq_desc_len);
 	left = cq_desc_len - rxm->data_len;
@@ -298,7 +298,7 @@
 		info[i] = NULL;
 
 		/* Set the chained mbuf metadata */
-		rxm_seg->rearm_data[0] = rxq->rearm_seg_data;
+		rxm_seg->rearm_data = rxq->rearm_seg_data;
 		rxm_seg->data_len = RTE_MIN(rxq->seg_size, left);
 		left -= rxm_seg->data_len;
 
drivers/net/ionic/ionic_rxtx_simple.c +1 -1
index 5f81856..1978610 100644
@@ -256,7 +256,7 @@
 	info[0] = NULL;
 
 	/* Set the mbuf metadata based on the cq entry */
-	rxm->rearm_data[0] = rxq->rearm_data;
+	rxm->rearm_data = rxq->rearm_data;
 	rxm->pkt_len = cq_desc_len;
 	rxm->data_len = cq_desc_len;
 
drivers/net/sfc/sfc_ef100_rx.c +4 -4
index 2677003..23918d5 100644
@@ -553,9 +553,9 @@ struct sfc_ef100_rxq {
 		pkt = sfc_ef100_rx_next_mbuf(rxq);
 		__rte_mbuf_raw_sanity_check(pkt);
 
-		RTE_BUILD_BUG_ON(sizeof(pkt->rearm_data[0]) !=
+		RTE_BUILD_BUG_ON(sizeof(pkt->rearm_data) !=
 				 sizeof(rxq->rearm_data));
-		pkt->rearm_data[0] = rxq->rearm_data;
+		pkt->rearm_data = rxq->rearm_data;
 
 		/* data_off already moved past Rx prefix */
 		rx_prefix = (const efx_xword_t *)sfc_ef100_rx_pkt_prefix(pkt);
@@ -759,8 +759,8 @@ struct sfc_ef100_rxq {
 
 	/* rearm_data covers structure members filled in above */
 	rte_compiler_barrier();
-	RTE_BUILD_BUG_ON(sizeof(m.rearm_data[0]) != sizeof(uint64_t));
-	return m.rearm_data[0];
+	RTE_BUILD_BUG_ON(sizeof(m.rearm_data) != sizeof(uint64_t));
+	return m.rearm_data;
 }
 
 static sfc_dp_rx_qcreate_t sfc_ef100_rx_qcreate;
drivers/net/sfc/sfc_ef10_rx.c +6 -6
index 30a320d..60bc098 100644
@@ -322,8 +322,8 @@ struct sfc_ef10_rxq {
 
 	m = rxd->mbuf;
 
-	RTE_BUILD_BUG_ON(sizeof(m->rearm_data[0]) != sizeof(rxq->rearm_data));
-	m->rearm_data[0] = rxq->rearm_data;
+	RTE_BUILD_BUG_ON(sizeof(m->rearm_data) != sizeof(rxq->rearm_data));
+	m->rearm_data = rxq->rearm_data;
 
 	/* Classify packet based on Rx event */
 	/* Mask RSS hash offload flag if RSS is not enabled */
@@ -377,9 +377,9 @@ struct sfc_ef10_rxq {
 			rxq->completed = pending;
 		}
 
-		RTE_BUILD_BUG_ON(sizeof(m->rearm_data[0]) !=
+		RTE_BUILD_BUG_ON(sizeof(m->rearm_data) !=
 				 sizeof(rxq->rearm_data));
-		m->rearm_data[0] = rxq->rearm_data;
+		m->rearm_data = rxq->rearm_data;
 
 		/* Event-dependent information is the same */
 		m->ol_flags = m0->ol_flags;
@@ -633,8 +633,8 @@ struct sfc_ef10_rxq {
 
 	/* rearm_data covers structure members filled in above */
 	rte_compiler_barrier();
-	RTE_BUILD_BUG_ON(sizeof(m.rearm_data[0]) != sizeof(uint64_t));
-	return m.rearm_data[0];
+	RTE_BUILD_BUG_ON(sizeof(m.rearm_data) != sizeof(uint64_t));
+	return m.rearm_data;
 }
 
 static sfc_dp_rx_qcreate_t sfc_ef10_rx_qcreate;
drivers/net/virtio/virtio_rxtx_packed_avx.h +4 -4
index 584ac72..a9ce53f 100644
@@ -36,10 +36,10 @@
 	/* Load four mbufs rearm data */
 	RTE_BUILD_BUG_ON(REFCNT_BITS_OFFSET >= 64);
 	RTE_BUILD_BUG_ON(SEG_NUM_BITS_OFFSET >= 64);
-	__m256i mbufs = _mm256_set_epi64x(*tx_pkts[3]->rearm_data,
-					  *tx_pkts[2]->rearm_data,
-					  *tx_pkts[1]->rearm_data,
-					  *tx_pkts[0]->rearm_data);
+	__m256i mbufs = _mm256_set_epi64x(tx_pkts[3]->rearm_data,
+					  tx_pkts[2]->rearm_data,
+					  tx_pkts[1]->rearm_data,
+					  tx_pkts[0]->rearm_data);
 
 	/* refcnt=1 and nb_segs=1 */
 	__m256i mbuf_ref = _mm256_set1_epi64x(DEFAULT_REARM_DATA);
lib/mbuf/rte_mbuf_core.h +73 -62

172 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#2 lore raw

RE: [PATCH] mbuf: replace GCC marker extension with C11 anonymous unions

Quoted 11 lines

From: Tyler Retzlaff [mailto:[email protected]]
Sent: Wednesday, 31 January 2024 00.26

Replace the use of RTE_MARKER<x> with C11 anonymous unions to improve code portability between toolchains.

Update use of rte_mbuf rearm_data field in net/ionic, net/sfc and net/virtio which were accessing field as a zero-length array.

---

I have some comments, putting weight on code readability rather than avoiding API breakage.

We can consider my suggested API breaking changes for the next API breaking release, and keep your goal of minimal API breakage with the current changes.

Quoted 16 lines
lib/mbuf/rte_mbuf_core.h +3 -3
index 5688683..d731ea0 100644
@@ -464,9 +464,10 @@ enum {
  * The generic rte_mbuf, containing a packet mbuf.
  */
 struct rte_mbuf {
-	RTE_MARKER cacheline0;
-
-	void *buf_addr;           /**< Virtual address of segment buffer.
 */
+	union {
+	    void *cacheline0;
+	    void *buf_addr;           /**< Virtual address of segment

buffer. */

lib/mbuf/rte_mbuf_core.h

Quoted 1 line
lib/mbuf/rte_mbuf_core.h +1 -0
+	};

I suppose this is the least ugly workaround for not being able to use the RTE_MARKER hack here.

Quoted 19 lines

#if RTE_IOVA_IN_MBUF

lib/mbuf/rte_mbuf_core.h +0 -10
 	/**
 	 * Physical address of segment buffer.
@@ -487,69 +488,77 @@ struct rte_mbuf {
 #endif
 
 	/* next 8 bytes are initialised on RX descriptor rearm */
-	RTE_MARKER64 rearm_data;
-	uint16_t data_off;
-
-	/**
-	 * Reference counter. Its size should at least equal to the size
-	 * of port field (16 bits), to support zero-copy broadcast.
-	 * It should only be accessed using the following functions:
-	 * rte_mbuf_refcnt_update(), rte_mbuf_refcnt_read(), and
-	 * rte_mbuf_refcnt_set(). The functionality of these functions
 (atomic,
-	 * or non-atomic) is controlled by the RTE_MBUF_REFCNT_ATOMIC

flag.

lib/mbuf/rte_mbuf_core.h struct rte_mbuf { · line 492

Quoted 4 lines
lib/mbuf/rte_mbuf_core.h +2 -2
-	 */
-	RTE_ATOMIC(uint16_t) refcnt;
+	union {
+		uint64_t rearm_data;

I consider this union with uint64_t rearm_data an improvement for code readability. Using a marker here was weird.

Quoted 41 lines
lib/mbuf/rte_mbuf_core.h +5 -0
+		struct {
+			uint16_t data_off;
+
+			/**
+			 * Reference counter. Its size should at least equal

to the size

lib/mbuf/rte_mbuf_core.h +1 -0
+			 * of port field (16 bits), to support zero-copy

broadcast.

lib/mbuf/rte_mbuf_core.h +1 -0
+			 * It should only be accessed using the following

functions:

lib/mbuf/rte_mbuf_core.h +1 -0
+			 * rte_mbuf_refcnt_update(), rte_mbuf_refcnt_read(),

and

lib/mbuf/rte_mbuf_core.h +1 -0
+			 * rte_mbuf_refcnt_set(). The functionality of these

functions (atomic,

lib/mbuf/rte_mbuf_core.h +1 -0
+			 * or non-atomic) is controlled by the

RTE_MBUF_REFCNT_ATOMIC flag.

lib/mbuf/rte_mbuf_core.h +2 -2
+			 */
+			RTE_ATOMIC(uint16_t) refcnt;
 
-	/**
-	 * Number of segments. Only valid for the first segment of an

mbuf

lib/mbuf/rte_mbuf_core.h +2 -3
-	 * chain.
-	 */
-	uint16_t nb_segs;
+			/**
+			 * Number of segments. Only valid for the first

segment of an mbuf

lib/mbuf/rte_mbuf_core.h +3 -2
+			 * chain.
+			 */
+			uint16_t nb_segs;
 
-	/** Input port (16 bits to support more than 256 virtual ports).
-	 * The event eth Tx adapter uses this field to specify the output

port.

lib/mbuf/rte_mbuf_core.h +1 -2
-	 */
-	uint16_t port;
+			/** Input port (16 bits to support more than 256

virtual ports).

lib/mbuf/rte_mbuf_core.h +1 -0
+			 * The event eth Tx adapter uses this field to

specify the output port.

lib/mbuf/rte_mbuf_core.h struct rte_mbuf { · line 517

Quoted 5 lines
lib/mbuf/rte_mbuf_core.h +3 -1
+			 */
+			uint16_t port;
 
-	uint64_t ol_flags;        /**< Offload features. */
+			uint64_t ol_flags;        /**< Offload features. */

Either:
1. If the comment about 8 bytes init on rearm is correct: ol_flags should remain outside the struct and union, i.e. at top level, else
2. It would be nice to increase the size of the rearm_data variable to 16 byte, so it covers the entire struct being rearmed. (And the incorrect comment about how many bytes are being rearmed should be fixed.)

Quoted 21 lines
lib/mbuf/rte_mbuf_core.h +2 -0
+		};
+	};
 
 	/* remaining bytes are set on RX when pulling packet from

descriptor */

lib/mbuf/rte_mbuf_core.h +0 -4
-	RTE_MARKER rx_descriptor_fields1;
-
-	/*
-	 * The packet type, which is the combination of outer/inner L2,

L3, L4

lib/mbuf/rte_mbuf_core.h +0 -1
-	 * and tunnel types. The packet_type is about data really present

in the

lib/mbuf/rte_mbuf_core.h +0 -1
-	 * mbuf. Example: if vlan stripping is enabled, a received vlan

packet

lib/mbuf/rte_mbuf_core.h +0 -1
-	 * would have RTE_PTYPE_L2_ETHER and not RTE_PTYPE_L2_VLAN

because the

lib/mbuf/rte_mbuf_core.h +0 -3
-	 * vlan is stripped from the data.
-	 */
 	union {
-		uint32_t packet_type; /**< L2/L3/L4 and tunnel information.

*/

lib/mbuf/rte_mbuf_core.h struct rte_mbuf { · line 523

Quoted 2 lines
lib/mbuf/rte_mbuf_core.h +1 -1
-		__extension__
+		void *rx_descriptor_fields1;

Instead of using void* for rx_descriptor_fields1, it would be nice to make rx_descriptor_fields1 a type of the correct size. It might need to be an uint32_t array to avoid imposing additional alignment requirements.

Quoted 74 lines
lib/mbuf/rte_mbuf_core.h +3 -0
+
+		/*
+		 * The packet type, which is the combination of outer/inner

L2, L3, L4

lib/mbuf/rte_mbuf_core.h +1 -0
+		 * and tunnel types. The packet_type is about data really

present in the

lib/mbuf/rte_mbuf_core.h +1 -0
+		 * mbuf. Example: if vlan stripping is enabled, a received

vlan packet

lib/mbuf/rte_mbuf_core.h +1 -0
+		 * would have RTE_PTYPE_L2_ETHER and not RTE_PTYPE_L2_VLAN

because the

lib/mbuf/rte_mbuf_core.h +3 -9
+		 * vlan is stripped from the data.
+		 */
 		struct {
-			uint8_t l2_type:4;   /**< (Outer) L2 type. */
-			uint8_t l3_type:4;   /**< (Outer) L3 type. */
-			uint8_t l4_type:4;   /**< (Outer) L4 type. */
-			uint8_t tun_type:4;  /**< Tunnel type. */
 			union {
-				uint8_t inner_esp_next_proto;
-				/**< ESP next protocol type, valid if
-				 * RTE_PTYPE_TUNNEL_ESP tunnel type is set
-				 * on both Tx and Rx.
-				 */
+				uint32_t packet_type; /**< L2/L3/L4 and tunnel

information. */

lib/mbuf/rte_mbuf_core.h +1 -4
 				__extension__
 				struct {
-					uint8_t inner_l2_type:4;
-					/**< Inner L2 type. */
-					uint8_t inner_l3_type:4;
-					/**< Inner L3 type. */
+					uint8_t l2_type:4;   /**< (Outer) L2

type. */

lib/mbuf/rte_mbuf_core.h +1 -0
+					uint8_t l3_type:4;   /**< (Outer) L3

type. */

lib/mbuf/rte_mbuf_core.h +1 -0
+					uint8_t l4_type:4;   /**< (Outer) L4

type. */

lib/mbuf/rte_mbuf_core.h +4 -0
+					uint8_t tun_type:4;  /**< Tunnel type. */
+					union {
+						uint8_t inner_esp_next_proto;
+						/**< ESP next protocol type, valid

if

lib/mbuf/rte_mbuf_core.h +1 -0
+						 * RTE_PTYPE_TUNNEL_ESP tunnel type

is set

lib/mbuf/rte_mbuf_core.h +11 -0
+						 * on both Tx and Rx.
+						 */
+						__extension__
+						struct {
+							uint8_t inner_l2_type:4;
+							/**< Inner L2 type. */
+							uint8_t inner_l3_type:4;
+							/**< Inner L3 type. */
+						};
+					};
+					uint8_t inner_l4_type:4; /**< Inner L4

type. */

lib/mbuf/rte_mbuf_core.h +1 -1
 				};
 			};
-			uint8_t inner_l4_type:4; /**< Inner L4 type. */
+			uint32_t pkt_len;         /**< Total pkt len: sum of

all segments. */

lib/mbuf/rte_mbuf_core.h +0 -1
 		};
 	};
 
-	uint32_t pkt_len;         /**< Total pkt len: sum of all

segments. */
uint16_t data_len; /**< Amount of data in segment buffer.
*/

lib/mbuf/rte_mbuf_core.h +0 -0
 	/** VLAN TCI (CPU order), valid if RTE_MBUF_F_RX_VLAN is set. */
 	uint16_t vlan_tci;
@@ -595,21 +604,23 @@ struct rte_mbuf {
 	struct rte_mempool *pool; /**< Pool from which mbuf was

allocated. */

lib/mbuf/rte_mbuf_core.h struct rte_mbuf { · line 608

Quoted 4 lines
lib/mbuf/rte_mbuf_core.h +2 -1
 	/* second cache line - fields only used in slow path or on TX */
-	RTE_MARKER cacheline1 __rte_cache_min_aligned;
+	union {
+		void *cacheline1;

The __rte_cache_min_aligned cannot be removed. It provides cache line alignment for 32 bit platforms, where pointers in the first cache line only use 4 byte.

NB: The rte_mbuf structure could be optimized for 32 bit platforms by moving fields from the second cache line to the holes in the first, but that's another discussion.

Quoted 33 lines

#if RTE_IOVA_IN_MBUF

lib/mbuf/rte_mbuf_core.h +2 -5
-	/**
-	 * Next segment of scattered packet. Must be NULL in the last
-	 * segment or in case of non-segmented packet.
-	 */
-	struct rte_mbuf *next;
+		/**
+		 * Next segment of scattered packet. Must be NULL in the

last

lib/mbuf/rte_mbuf_core.h +3 -3
+		 * segment or in case of non-segmented packet.
+		 */
+		struct rte_mbuf *next;
 #else
-	/**
-	 * Reserved for dynamic fields
-	 * when the next pointer is in first cache line (i.e.

RTE_IOVA_IN_MBUF is 0).

lib/mbuf/rte_mbuf_core.h +3 -2
-	 */
-	uint64_t dynfield2;
+		/**
+		 * Reserved for dynamic fields
+		 * when the next pointer is in first cache line (i.e.

RTE_IOVA_IN_MBUF is 0).

lib/mbuf/rte_mbuf_core.h +3 -1
+		 */
+		uint64_t dynfield2;
 #endif
+	};
 
 	/* fields to support TX offloads */
 	union {
--

1.8.3.1

#3 lore raw

Re: [PATCH] mbuf: replace GCC marker extension with C11 anonymous unions

Quoted 9 lines · Morten Brørup
Quoted 9 lines

From: Tyler Retzlaff [mailto:[email protected]]
Sent: Wednesday, 31 January 2024 00.26

Replace the use of RTE_MARKER<x> with C11 anonymous unions to improve code portability between toolchains.

Update use of rte_mbuf rearm_data field in net/ionic, net/sfc and net/virtio which were accessing field as a zero-length array.

Quoted 6 lines
Quoted 2 lines

---

I have some comments, putting weight on code readability rather than avoiding API breakage.

We can consider my suggested API breaking changes for the next API breaking release, and keep your goal of minimal API breakage with the current changes.

thanks appreciate your help with this one.

Quoted 12 lines
Quoted 12 lines
lib/mbuf/rte_mbuf_core.h +0 -3
index 5688683..d731ea0 100644
@@ -464,9 +464,10 @@ enum {
  * The generic rte_mbuf, containing a packet mbuf.
  */
 struct rte_mbuf {
-	RTE_MARKER cacheline0;
-
-	void *buf_addr;           /**< Virtual address of segment buffer.
Quoted 8 lines

lib/mbuf/rte_mbuf_core.h

Quoted 6 lines
lib/mbuf/rte_mbuf_core.h +3 -0
 */
+	union {
+	    void *cacheline0;
+	    void *buf_addr;           /**< Virtual address of segment

buffer. */

lib/mbuf/rte_mbuf_core.h +1 -0
+	};

I suppose this is the least ugly workaround for not being able to use the RTE_MARKER hack here.

it is but i'm absolutely open to alternatives that work with all toolchains and both C and C++ if there are any.

Quoted 71 lines
Quoted 20 lines

#if RTE_IOVA_IN_MBUF

lib/mbuf/rte_mbuf_core.h +0 -10
 	/**
 	 * Physical address of segment buffer.
@@ -487,69 +488,77 @@ struct rte_mbuf {
 #endif
 
 	/* next 8 bytes are initialised on RX descriptor rearm */
-	RTE_MARKER64 rearm_data;
-	uint16_t data_off;
-
-	/**
-	 * Reference counter. Its size should at least equal to the size
-	 * of port field (16 bits), to support zero-copy broadcast.
-	 * It should only be accessed using the following functions:
-	 * rte_mbuf_refcnt_update(), rte_mbuf_refcnt_read(), and
-	 * rte_mbuf_refcnt_set(). The functionality of these functions
 (atomic,
-	 * or non-atomic) is controlled by the RTE_MBUF_REFCNT_ATOMIC

flag.

lib/mbuf/rte_mbuf_core.h struct rte_mbuf { · line 492

Quoted 4 lines
lib/mbuf/rte_mbuf_core.h +2 -2
-	 */
-	RTE_ATOMIC(uint16_t) refcnt;
+	union {
+		uint64_t rearm_data;

I consider this union with uint64_t rearm_data an improvement for code readability. Using a marker here was weird.

Quoted 44 lines
lib/mbuf/rte_mbuf_core.h +5 -0
+		struct {
+			uint16_t data_off;
+
+			/**
+			 * Reference counter. Its size should at least equal

to the size

lib/mbuf/rte_mbuf_core.h +1 -0
+			 * of port field (16 bits), to support zero-copy

broadcast.

lib/mbuf/rte_mbuf_core.h +1 -0
+			 * It should only be accessed using the following

functions:

lib/mbuf/rte_mbuf_core.h +1 -0
+			 * rte_mbuf_refcnt_update(), rte_mbuf_refcnt_read(),

and

lib/mbuf/rte_mbuf_core.h +1 -0
+			 * rte_mbuf_refcnt_set(). The functionality of these

functions (atomic,

lib/mbuf/rte_mbuf_core.h +1 -0
+			 * or non-atomic) is controlled by the

RTE_MBUF_REFCNT_ATOMIC flag.

lib/mbuf/rte_mbuf_core.h +2 -2
+			 */
+			RTE_ATOMIC(uint16_t) refcnt;
 
-	/**
-	 * Number of segments. Only valid for the first segment of an

mbuf

lib/mbuf/rte_mbuf_core.h +2 -3
-	 * chain.
-	 */
-	uint16_t nb_segs;
+			/**
+			 * Number of segments. Only valid for the first

segment of an mbuf

lib/mbuf/rte_mbuf_core.h +3 -2
+			 * chain.
+			 */
+			uint16_t nb_segs;
 
-	/** Input port (16 bits to support more than 256 virtual ports).
-	 * The event eth Tx adapter uses this field to specify the output

port.

lib/mbuf/rte_mbuf_core.h +1 -2
-	 */
-	uint16_t port;
+			/** Input port (16 bits to support more than 256

virtual ports).

lib/mbuf/rte_mbuf_core.h +1 -0
+			 * The event eth Tx adapter uses this field to

specify the output port.

lib/mbuf/rte_mbuf_core.h +2 -0
+			 */
+			uint16_t port;
Quoted 8 lines

lib/mbuf/rte_mbuf_core.h struct rte_mbuf { · line 517

Quoted 2 lines
lib/mbuf/rte_mbuf_core.h +1 -1
-	uint64_t ol_flags;        /**< Offload features. */
+			uint64_t ol_flags;        /**< Offload features. */

Either:
1. If the comment about 8 bytes init on rearm is correct: ol_flags should remain outside the struct and union, i.e. at top level, else

2. It would be nice to increase the size of the rearm_data variable to 16 byte, so it covers the entire struct being rearmed. (And the incorrect comment about how many bytes are being rearmed should be fixed.)

thanks for picking this up, i think i've actually just got a mistake here. i don't think ol_flags should have been lifted into the union i'll go back and do some double checking.

Quoted 17 lines
Quoted 17 lines
lib/mbuf/rte_mbuf_core.h +2 -0
+		};
+	};
 
 	/* remaining bytes are set on RX when pulling packet from

descriptor */

lib/mbuf/rte_mbuf_core.h +0 -4
-	RTE_MARKER rx_descriptor_fields1;
-
-	/*
-	 * The packet type, which is the combination of outer/inner L2,

L3, L4

lib/mbuf/rte_mbuf_core.h +0 -1
-	 * and tunnel types. The packet_type is about data really present

in the

lib/mbuf/rte_mbuf_core.h +0 -1
-	 * mbuf. Example: if vlan stripping is enabled, a received vlan

packet

lib/mbuf/rte_mbuf_core.h +0 -1
-	 * would have RTE_PTYPE_L2_ETHER and not RTE_PTYPE_L2_VLAN

because the

lib/mbuf/rte_mbuf_core.h +0 -1
-	 * vlan is stripped from the data.
Quoted 8 lines

lib/mbuf/rte_mbuf_core.h struct rte_mbuf { · line 523

Quoted 6 lines
lib/mbuf/rte_mbuf_core.h +0 -2
-	 */
 	union {
-		uint32_t packet_type; /**< L2/L3/L4 and tunnel information.

*/

lib/mbuf/rte_mbuf_core.h +1 -1
-		__extension__
+		void *rx_descriptor_fields1;

Instead of using void* for rx_descriptor_fields1, it would be nice to make rx_descriptor_fields1 a type of the correct size. It might need to be an uint32_t array to avoid imposing additional alignment requirements.

as you've probably guessed i used the type from the original marker in use. for api compat reasons i'll avoid changing type in this series.

Quoted 75 lines
Quoted 75 lines
lib/mbuf/rte_mbuf_core.h +3 -0
+
+		/*
+		 * The packet type, which is the combination of outer/inner

L2, L3, L4

lib/mbuf/rte_mbuf_core.h +1 -0
+		 * and tunnel types. The packet_type is about data really

present in the

lib/mbuf/rte_mbuf_core.h +1 -0
+		 * mbuf. Example: if vlan stripping is enabled, a received

vlan packet

lib/mbuf/rte_mbuf_core.h +1 -0
+		 * would have RTE_PTYPE_L2_ETHER and not RTE_PTYPE_L2_VLAN

because the

lib/mbuf/rte_mbuf_core.h +3 -9
+		 * vlan is stripped from the data.
+		 */
 		struct {
-			uint8_t l2_type:4;   /**< (Outer) L2 type. */
-			uint8_t l3_type:4;   /**< (Outer) L3 type. */
-			uint8_t l4_type:4;   /**< (Outer) L4 type. */
-			uint8_t tun_type:4;  /**< Tunnel type. */
 			union {
-				uint8_t inner_esp_next_proto;
-				/**< ESP next protocol type, valid if
-				 * RTE_PTYPE_TUNNEL_ESP tunnel type is set
-				 * on both Tx and Rx.
-				 */
+				uint32_t packet_type; /**< L2/L3/L4 and tunnel

information. */

lib/mbuf/rte_mbuf_core.h +1 -4
 				__extension__
 				struct {
-					uint8_t inner_l2_type:4;
-					/**< Inner L2 type. */
-					uint8_t inner_l3_type:4;
-					/**< Inner L3 type. */
+					uint8_t l2_type:4;   /**< (Outer) L2

type. */

lib/mbuf/rte_mbuf_core.h +1 -0
+					uint8_t l3_type:4;   /**< (Outer) L3

type. */

lib/mbuf/rte_mbuf_core.h +1 -0
+					uint8_t l4_type:4;   /**< (Outer) L4

type. */

lib/mbuf/rte_mbuf_core.h +4 -0
+					uint8_t tun_type:4;  /**< Tunnel type. */
+					union {
+						uint8_t inner_esp_next_proto;
+						/**< ESP next protocol type, valid

if

lib/mbuf/rte_mbuf_core.h +1 -0
+						 * RTE_PTYPE_TUNNEL_ESP tunnel type

is set

lib/mbuf/rte_mbuf_core.h +11 -0
+						 * on both Tx and Rx.
+						 */
+						__extension__
+						struct {
+							uint8_t inner_l2_type:4;
+							/**< Inner L2 type. */
+							uint8_t inner_l3_type:4;
+							/**< Inner L3 type. */
+						};
+					};
+					uint8_t inner_l4_type:4; /**< Inner L4

type. */

lib/mbuf/rte_mbuf_core.h +1 -1
 				};
 			};
-			uint8_t inner_l4_type:4; /**< Inner L4 type. */
+			uint32_t pkt_len;         /**< Total pkt len: sum of

all segments. */

lib/mbuf/rte_mbuf_core.h +0 -1
 		};
 	};
 
-	uint32_t pkt_len;         /**< Total pkt len: sum of all

segments. */
uint16_t data_len; /**< Amount of data in segment buffer.
*/

lib/mbuf/rte_mbuf_core.h +0 -0
 	/** VLAN TCI (CPU order), valid if RTE_MBUF_F_RX_VLAN is set. */
 	uint16_t vlan_tci;
@@ -595,21 +604,23 @@ struct rte_mbuf {
 	struct rte_mempool *pool; /**< Pool from which mbuf was

allocated. */

Quoted 6 lines

lib/mbuf/rte_mbuf_core.h struct rte_mbuf { · line 608

Quoted 4 lines
lib/mbuf/rte_mbuf_core.h +2 -1
 	/* second cache line - fields only used in slow path or on TX */
-	RTE_MARKER cacheline1 __rte_cache_min_aligned;
+	union {
+		void *cacheline1;

The __rte_cache_min_aligned cannot be removed. It provides cache line alignment for 32 bit platforms, where pointers in the first cache line only use 4 byte.

oh no i forgot i needed to figure this out before submission. now that it's here though i could use some help / suggestions.

the existing __rte_cache_min_aligned (and indeed standard alignas) facilities are not of great utility when applied to anonymous unions, further complicating things is that it also has to work with C++.

i'll take this away and work on it some more but does anyone here have a suggestion on how to align this anonymous union data member to the desired alignment *without* the union being padded to min cache line size and as a consequence causing the rte_mbuf struct to be 3 instead of 2 cache lines? (that's essentially the problem i need help solving).

Quoted 2 lines

NB: The rte_mbuf structure could be optimized for 32 bit platforms by moving fields from the second cache line to the holes in the first, but that's another discussion.

likely could be optimized. a discussion for another time since we can't make breaking abi changes.

Quoted 34 lines
Quoted 34 lines

#if RTE_IOVA_IN_MBUF

lib/mbuf/rte_mbuf_core.h +2 -5
-	/**
-	 * Next segment of scattered packet. Must be NULL in the last
-	 * segment or in case of non-segmented packet.
-	 */
-	struct rte_mbuf *next;
+		/**
+		 * Next segment of scattered packet. Must be NULL in the

last

lib/mbuf/rte_mbuf_core.h +3 -3
+		 * segment or in case of non-segmented packet.
+		 */
+		struct rte_mbuf *next;
 #else
-	/**
-	 * Reserved for dynamic fields
-	 * when the next pointer is in first cache line (i.e.

RTE_IOVA_IN_MBUF is 0).

lib/mbuf/rte_mbuf_core.h +3 -2
-	 */
-	uint64_t dynfield2;
+		/**
+		 * Reserved for dynamic fields
+		 * when the next pointer is in first cache line (i.e.

RTE_IOVA_IN_MBUF is 0).

lib/mbuf/rte_mbuf_core.h +3 -1
+		 */
+		uint64_t dynfield2;
 #endif
+	};
 
 	/* fields to support TX offloads */
 	union {
--

1.8.3.1

#4 lore raw

RE: [PATCH] mbuf: replace GCC marker extension with C11 anonymous unions

Quoted 7 lines

From: Tyler Retzlaff [mailto:[email protected]]
Sent: Wednesday, 31 January 2024 22.09

Quoted 3 lines · Morten Brørup
Quoted 3 lines

From: Tyler Retzlaff [mailto:[email protected]]
Sent: Wednesday, 31 January 2024 00.26

[...]

Quoted 19 lines
Quoted 9 lines

lib/mbuf/rte_mbuf_core.h struct rte_mbuf { · line 608

Quoted 7 lines

struct rte_mempool *pool; /**< Pool from which mbuf was
allocated. */

lib/mbuf/rte_mbuf_core.h +2 -1
 	/* second cache line - fields only used in slow path or on TX */
-	RTE_MARKER cacheline1 __rte_cache_min_aligned;
+	union {
+		void *cacheline1;

The __rte_cache_min_aligned cannot be removed. It provides cache line

alignment for 32 bit platforms, where pointers in the first cache line only use 4 byte.

oh no i forgot i needed to figure this out before submission. now that it's here though i could use some help / suggestions.

the existing __rte_cache_min_aligned (and indeed standard alignas) facilities are not of great utility when applied to anonymous unions, further complicating things is that it also has to work with C++.

Quoted 6 lines

i'll take this away and work on it some more but does anyone here have a
suggestion on how to align this anonymous union data member to the desired alignment *without* the union being padded to min cache line size and as a consequence causing the rte_mbuf struct to be 3 instead of 2 cache lines? (that's essentially the problem i need help solving).

I would suggest to simply remove __rte_cache_min_aligned (and the implicit padding that comes with it), and instead conditionally (#ifdef RTE_ARCH_32) add an explicit uintptr_t padding field after each pointer field in the rte_mbuf struct's first cache line.

But that would break the 32-bit ABI, so instead insert the explicit padding in the rte_mbuf struct at the end of its first cache line (where the implicit padding from __rte_cache_min_aligned is currently added), something like this:

struct rte_mempool *pool; /**< Pool from which mbuf was allocated. */

+#ifdef RTE_ARCH_32
+ /* Padding to ensure correct alignment of cacheline1. */
+ uintptr_t pad_buf_addr;
+#if !RTE_IOVA_IN_MBUF
+ uintptr_t pad_next;
+#endif
+#endif /* RTE_ARCH_32 */

	/* second cache line - fields only used in slow path or on TX */

To be on the safe side, add a static_assert to verify that offsetof(struct rte_mbuf, cacheline1) == RTE_CACHE_LINE_MIN_SIZE. This should be true for all architectures, i.e. both 64 bit and 32 bit.

#5 lore raw

Re: [PATCH] mbuf: replace GCC marker extension with C11 anonymous unions

In reply to Tyler Retzlaff
Quoted 7 lines · Tyler Retzlaff

Replace the use of RTE_MARKER<x> with C11 anonymous unions to improve code portability between toolchains.

Update use of rte_mbuf rearm_data field in net/ionic, net/sfc and net/virtio which were accessing field as a zero-length array.

Quoted 10 lines
---
 drivers/net/ionic/ionic_lif.c               |   8 +-
 drivers/net/ionic/ionic_rxtx_sg.c           |   4 +-
 drivers/net/ionic/ionic_rxtx_simple.c       |   2 +-
 drivers/net/sfc/sfc_ef100_rx.c              |   8 +-
 drivers/net/sfc/sfc_ef10_rx.c               |  12 +--
 drivers/net/virtio/virtio_rxtx_packed_avx.h |   8 +-
 lib/mbuf/rte_mbuf_core.h                    | 135 +++++++++++++++-------------
 7 files changed, 94 insertions(+), 83 deletions(-)

<snip>
@@ -464,9 +464,10 @@ enum {

lib/mbuf/rte_mbuf_core.h enum { · line 470

Quoted 10 lines

* The generic rte_mbuf, containing a packet mbuf. */
struct rte_mbuf {

lib/mbuf/rte_mbuf_core.h +4 -3
-	RTE_MARKER cacheline0;
-
-	void *buf_addr;           /**< Virtual address of segment buffer. */
+	union {
+	    void *cacheline0;
+	    void *buf_addr;           /**< Virtual address of segment buffer. */
+	};

This marker is never used, so we should just look to drop it. I think it was originally added to have an equivalent to the cacheline1 marker.

However, that would be an ABI change, so I'm ok to have this as-is for now.

/Bruce

#6 lore raw

Re: [PATCH] mbuf: replace GCC marker extension with C11 anonymous unions

Quoted 25 lines · Bruce Richardson
Quoted 17 lines · Tyler Retzlaff

Replace the use of RTE_MARKER<x> with C11 anonymous unions to improve code portability between toolchains.

Update use of rte_mbuf rearm_data field in net/ionic, net/sfc and net/virtio which were accessing field as a zero-length array.

---
 drivers/net/ionic/ionic_lif.c               |   8 +-
 drivers/net/ionic/ionic_rxtx_sg.c           |   4 +-
 drivers/net/ionic/ionic_rxtx_simple.c       |   2 +-
 drivers/net/sfc/sfc_ef100_rx.c              |   8 +-
 drivers/net/sfc/sfc_ef10_rx.c               |  12 +--
 drivers/net/virtio/virtio_rxtx_packed_avx.h |   8 +-
 lib/mbuf/rte_mbuf_core.h                    | 135 +++++++++++++++-------------
 7 files changed, 94 insertions(+), 83 deletions(-)

<snip>

(quoted diff) +0 -0
@@ -464,9 +464,10 @@ enum {
Quoted 5 lines

* The generic rte_mbuf, containing a packet mbuf. */
struct rte_mbuf {

lib/mbuf/rte_mbuf_core.h +0 -2
-	RTE_MARKER cacheline0;
-
Quoted 8 lines

lib/mbuf/rte_mbuf_core.h enum { · line 470

Quoted 5 lines
lib/mbuf/rte_mbuf_core.h +4 -1
-	void *buf_addr;           /**< Virtual address of segment buffer. */
+	union {
+	    void *cacheline0;
+	    void *buf_addr;           /**< Virtual address of segment buffer. */
+	};

This marker is never used, so we should just look to drop it. I think it was originally added to have an equivalent to the cacheline1 marker.

it's actually got a use in one location.

rte_mbuf.h:

static inline void
rte_mbuf_prefetch_part1(struct rte_mbuf *m)

{
        rte_prefetch0(&m->cacheline0);
}
Quoted 1 line

However, that would be an ABI change, so I'm ok to have this as-is for now.

do you mean api change? just asking to make sure i understand what i'm doing.

as i understand how this extension (marker) works removing the cacheline0 marker would not alter the layout of the struct. that is the sizeof the struct, sizeof any field nor the offset of any field changes would change by the marker removal.

Quoted 2 lines

/Bruce

#7 lore raw

RE: [PATCH] mbuf: replace GCC marker extension with C11 anonymous unions

Quoted 47 lines

From: Tyler Retzlaff [mailto:[email protected]]
Sent: Wednesday, 31 January 2024 21.46

Quoted 2 lines · Bruce Richardson
Quoted 1 line · Tyler Retzlaff

Replace the use of RTE_MARKER<x> with C11 anonymous unions to

improve

Quoted 5 lines
Quoted 5 lines

code portability between toolchains.

Update use of rte_mbuf rearm_data field in net/ionic, net/sfc and net/virtio which were accessing field as a zero-length array.

Quoted 9 lines
Quoted 9 lines
---
 drivers/net/ionic/ionic_lif.c               |   8 +-
 drivers/net/ionic/ionic_rxtx_sg.c           |   4 +-
 drivers/net/ionic/ionic_rxtx_simple.c       |   2 +-
 drivers/net/sfc/sfc_ef100_rx.c              |   8 +-
 drivers/net/sfc/sfc_ef10_rx.c               |  12 +--
 drivers/net/virtio/virtio_rxtx_packed_avx.h |   8 +-
 lib/mbuf/rte_mbuf_core.h                    | 135 +++++++++++++++-

------------

Quoted 10 lines
Quoted 2 lines
 7 files changed, 94 insertions(+), 83 deletions(-)

<snip>

(quoted diff) +0 -0
@@ -464,9 +464,10 @@ enum {

lib/mbuf/rte_mbuf_core.h enum {

Quoted 6 lines

* The generic rte_mbuf, containing a packet mbuf. */
struct rte_mbuf {

lib/mbuf/rte_mbuf_core.h +0 -3
-	RTE_MARKER cacheline0;
-
-	void *buf_addr;           /**< Virtual address of segment buffer.

*/

Quoted 3 lines

lib/mbuf/rte_mbuf_core.h enum {

Quoted 3 lines
lib/mbuf/rte_mbuf_core.h +3 -0
+	union {
+	    void *cacheline0;
+	    void *buf_addr;           /**< Virtual address of segment

buffer. */

Quoted 3 lines

Review

Quoted 1 line
(quoted diff) +1 -0
+	};

This marker is never used, so we should just look to drop it. I think

it

Quoted 1 line

was originally added to have an equivalent to the cacheline1 marker.

it's actually got a use in one location.

rte_mbuf.h:

Quoted 8 lines

static inline void
rte_mbuf_prefetch_part1(struct rte_mbuf *m)

{	
        rte_prefetch0(&m->cacheline0);
}	
Quoted 1 line

However, that would be an ABI change, so I'm ok to have this as-is

for now.

Typo: API change, not ABI change.

Quoted 8 lines

do you mean api change? just asking to make sure i understand what i'm doing.

as i understand how this extension (marker) works removing the cacheline0 marker would not alter the layout of the struct. that is the sizeof the struct, sizeof any field nor the offset of any field changes would change by the marker removal.

Correctly understood, Tyler.

The struct layout is unmodified, so it's not an ABI change.
However, it's an API change, because applications cannot access the field anymore.

Although DPDK itself doesn't use the field, other applications might use rte_prefetch0(&m->cacheline0) instead of rte_mbuf_prefetch_part1(m). After checking in-house, I can mention at least one company doing that. ;-)

We should keep the cacheline0 field and not break the API. Not for my sake, but for other applications. :-)

#8 lore raw

PATCH v2 1/1 RFC: replace GCC marker extension with C11 anonymous unions

In reply to Tyler Retzlaff

The zero sized RTE_MARKER<n> typedefs are a GCC extension unsupported by MSVC. Replace the use of the RTE_MARKER typedefs with anonymous unions.

Note:

v1 of the series tried to maintain the API after some study it has been discovered that some existing uses of the markers do not produce compilation failure but evaluate to unintended values in the absence of adaptation. For this reason the existing markers cannot be removed because it is too hard to identify what needs to be changed by consumers. While the ABI has been maintained the subtle API change is just too risky.

The question I'm asking now is how to gracefully deprecate the markers while allowing consumption of the struct on Windows.

I propose the following:

* Introduce the unions as per-this series except instead of adding members that match the original RTE_MARKER field names provide *new* names.
* Retain (conditionally compiled away on Windows) the existing RTE_MARKER fields with their original names.
* Convert in-tree code to use the new names in the unions.

The old names & markers would be announced for deprecation and eventually removed and when they are the conditional compilation would also go away.

Thoughts?

v2:
* Introduce additional union/struct to agnostically pad cachline0 to RTE_CACHE_LINE_MIN_SIZE without conditional compilation.
* Adapt ixgbe access of rearm_data field.
* Move ol_flags field out of rearm_data union where it didn't belong.
* Added a couple of static_asserts for offset of cacheline1 and sizeof struct rte_mbuf.

Tyler Retzlaff (1):
mbuf: replace GCC marker extension with C11 anonymous unions

 drivers/net/ionic/ionic_lif.c               |   8 +-
 drivers/net/ionic/ionic_rxtx_sg.c           |   4 +-
 drivers/net/ionic/ionic_rxtx_simple.c       |   2 +-
 drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c      |   8 +-
 drivers/net/sfc/sfc_ef100_rx.c              |   8 +-
 drivers/net/sfc/sfc_ef10_rx.c               |  12 +-
 drivers/net/virtio/virtio_rxtx_packed_avx.h |   8 +-
 lib/mbuf/rte_mbuf_core.h                    | 276 ++++++++++++++++------------
 8 files changed, 179 insertions(+), 147 deletions(-)
Signature · 1 line
1.8.3.1
#9 lore raw

PATCH v2 1/1 mbuf: replace GCC marker extension with C11 anonymous unions

Replace the use of RTE_MARKER<x> with C11 anonymous unions to improve code portability between toolchains.

Update use of rte_mbuf rearm_data field in net/ionic, net/sfc, net/ixgbe and net/virtio which were accessing field as a zero-length array.

---
 drivers/net/ionic/ionic_lif.c               |   8 +-
 drivers/net/ionic/ionic_rxtx_sg.c           |   4 +-
 drivers/net/ionic/ionic_rxtx_simple.c       |   2 +-
 drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c      |   8 +-
 drivers/net/sfc/sfc_ef100_rx.c              |   8 +-
 drivers/net/sfc/sfc_ef10_rx.c               |  12 +-
 drivers/net/virtio/virtio_rxtx_packed_avx.h |   8 +-
 lib/mbuf/rte_mbuf_core.h                    | 276 ++++++++++++++++------------
 8 files changed, 179 insertions(+), 147 deletions(-)
drivers/net/ionic/ionic_lif.c +4 -4
index 25b490d..fd99f39 100644
@@ -725,8 +725,8 @@
 
 	rte_compiler_barrier();
 
-	RTE_BUILD_BUG_ON(sizeof(rxm.rearm_data[0]) != sizeof(uint64_t));
-	return rxm.rearm_data[0];
+	RTE_BUILD_BUG_ON(sizeof(rxm.rearm_data) != sizeof(uint64_t));
+	return rxm.rearm_data;
 }
 
 static uint64_t
@@ -743,8 +743,8 @@
 
 	rte_compiler_barrier();
 
-	RTE_BUILD_BUG_ON(sizeof(rxm.rearm_data[0]) != sizeof(uint64_t));
-	return rxm.rearm_data[0];
+	RTE_BUILD_BUG_ON(sizeof(rxm.rearm_data) != sizeof(uint64_t));
+	return rxm.rearm_data;
 }
 
 int
drivers/net/ionic/ionic_rxtx_sg.c +2 -2
index ab8e56e..a569dd1 100644
@@ -285,7 +285,7 @@
 	info[0] = NULL;
 
 	/* Set the mbuf metadata based on the cq entry */
-	rxm->rearm_data[0] = rxq->rearm_data;
+	rxm->rearm_data = rxq->rearm_data;
 	rxm->pkt_len = cq_desc_len;
 	rxm->data_len = RTE_MIN(rxq->hdr_seg_size, cq_desc_len);
 	left = cq_desc_len - rxm->data_len;
@@ -298,7 +298,7 @@
 		info[i] = NULL;
 
 		/* Set the chained mbuf metadata */
-		rxm_seg->rearm_data[0] = rxq->rearm_seg_data;
+		rxm_seg->rearm_data = rxq->rearm_seg_data;
 		rxm_seg->data_len = RTE_MIN(rxq->seg_size, left);
 		left -= rxm_seg->data_len;
 
drivers/net/ionic/ionic_rxtx_simple.c +1 -1
index 5f81856..1978610 100644
@@ -256,7 +256,7 @@
 	info[0] = NULL;
 
 	/* Set the mbuf metadata based on the cq entry */
-	rxm->rearm_data[0] = rxq->rearm_data;
+	rxm->rearm_data = rxq->rearm_data;
 	rxm->pkt_len = cq_desc_len;
 	rxm->data_len = cq_desc_len;
 
drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c +4 -4
index f60808d..bc0525b 100644
@@ -98,10 +98,10 @@
 desc_to_olflags_v_ipsec(__m128i descs[4], struct rte_mbuf **rx_pkts)
 {
 	__m128i sterr, rearm, tmp_e, tmp_p;
-	uint32_t *rearm0 = (uint32_t *)rx_pkts[0]->rearm_data + 2;
-	uint32_t *rearm1 = (uint32_t *)rx_pkts[1]->rearm_data + 2;
-	uint32_t *rearm2 = (uint32_t *)rx_pkts[2]->rearm_data + 2;
-	uint32_t *rearm3 = (uint32_t *)rx_pkts[3]->rearm_data + 2;
+	uint32_t *rearm0 = (uint32_t *)&rx_pkts[0]->rearm_data + 2;
+	uint32_t *rearm1 = (uint32_t *)&rx_pkts[1]->rearm_data + 2;
+	uint32_t *rearm2 = (uint32_t *)&rx_pkts[2]->rearm_data + 2;
+	uint32_t *rearm3 = (uint32_t *)&rx_pkts[3]->rearm_data + 2;
 	const __m128i ipsec_sterr_msk =
 			_mm_set1_epi32(IXGBE_RXDADV_IPSEC_STATUS_SECP |
 				       IXGBE_RXDADV_IPSEC_ERROR_AUTH_FAILED);
drivers/net/sfc/sfc_ef100_rx.c +4 -4
index 2677003..23918d5 100644
@@ -553,9 +553,9 @@ struct sfc_ef100_rxq {
 		pkt = sfc_ef100_rx_next_mbuf(rxq);
 		__rte_mbuf_raw_sanity_check(pkt);
 
-		RTE_BUILD_BUG_ON(sizeof(pkt->rearm_data[0]) !=
+		RTE_BUILD_BUG_ON(sizeof(pkt->rearm_data) !=
 				 sizeof(rxq->rearm_data));
-		pkt->rearm_data[0] = rxq->rearm_data;
+		pkt->rearm_data = rxq->rearm_data;
 
 		/* data_off already moved past Rx prefix */
 		rx_prefix = (const efx_xword_t *)sfc_ef100_rx_pkt_prefix(pkt);
@@ -759,8 +759,8 @@ struct sfc_ef100_rxq {
 
 	/* rearm_data covers structure members filled in above */
 	rte_compiler_barrier();
-	RTE_BUILD_BUG_ON(sizeof(m.rearm_data[0]) != sizeof(uint64_t));
-	return m.rearm_data[0];
+	RTE_BUILD_BUG_ON(sizeof(m.rearm_data) != sizeof(uint64_t));
+	return m.rearm_data;
 }
 
 static sfc_dp_rx_qcreate_t sfc_ef100_rx_qcreate;
drivers/net/sfc/sfc_ef10_rx.c +6 -6
index 30a320d..60bc098 100644
@@ -322,8 +322,8 @@ struct sfc_ef10_rxq {
 
 	m = rxd->mbuf;
 
-	RTE_BUILD_BUG_ON(sizeof(m->rearm_data[0]) != sizeof(rxq->rearm_data));
-	m->rearm_data[0] = rxq->rearm_data;
+	RTE_BUILD_BUG_ON(sizeof(m->rearm_data) != sizeof(rxq->rearm_data));
+	m->rearm_data = rxq->rearm_data;
 
 	/* Classify packet based on Rx event */
 	/* Mask RSS hash offload flag if RSS is not enabled */
@@ -377,9 +377,9 @@ struct sfc_ef10_rxq {
 			rxq->completed = pending;
 		}
 
-		RTE_BUILD_BUG_ON(sizeof(m->rearm_data[0]) !=
+		RTE_BUILD_BUG_ON(sizeof(m->rearm_data) !=
 				 sizeof(rxq->rearm_data));
-		m->rearm_data[0] = rxq->rearm_data;
+		m->rearm_data = rxq->rearm_data;
 
 		/* Event-dependent information is the same */
 		m->ol_flags = m0->ol_flags;
@@ -633,8 +633,8 @@ struct sfc_ef10_rxq {
 
 	/* rearm_data covers structure members filled in above */
 	rte_compiler_barrier();
-	RTE_BUILD_BUG_ON(sizeof(m.rearm_data[0]) != sizeof(uint64_t));
-	return m.rearm_data[0];
+	RTE_BUILD_BUG_ON(sizeof(m.rearm_data) != sizeof(uint64_t));
+	return m.rearm_data;
 }
 
 static sfc_dp_rx_qcreate_t sfc_ef10_rx_qcreate;
drivers/net/virtio/virtio_rxtx_packed_avx.h +4 -4
index 584ac72..a9ce53f 100644
@@ -36,10 +36,10 @@
 	/* Load four mbufs rearm data */
 	RTE_BUILD_BUG_ON(REFCNT_BITS_OFFSET >= 64);
 	RTE_BUILD_BUG_ON(SEG_NUM_BITS_OFFSET >= 64);
-	__m256i mbufs = _mm256_set_epi64x(*tx_pkts[3]->rearm_data,
-					  *tx_pkts[2]->rearm_data,
-					  *tx_pkts[1]->rearm_data,
-					  *tx_pkts[0]->rearm_data);
+	__m256i mbufs = _mm256_set_epi64x(tx_pkts[3]->rearm_data,
+					  tx_pkts[2]->rearm_data,
+					  tx_pkts[1]->rearm_data,
+					  tx_pkts[0]->rearm_data);
 
 	/* refcnt=1 and nb_segs=1 */
 	__m256i mbuf_ref = _mm256_set1_epi64x(DEFAULT_REARM_DATA);
lib/mbuf/rte_mbuf_core.h +154 -122

312 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#10 lore raw

RE: [PATCH v2] mbuf: replace GCC marker extension with C11 anonymous unions

Quoted 5 lines

From: Tyler Retzlaff [mailto:[email protected]]
Sent: Tuesday, 13 February 2024 07.46

Replace the use of RTE_MARKER<x> with C11 anonymous unions to improve code portability between toolchains.

How about combining the cacheline 0 marker and padding, like this:

struct rte_mbuf {
- RTE_MARKER cacheline0;
+ union {
+ char cacheline0[RTE_CACHE_LINE_MIN_SIZE];

+ struct {
- void *buf_addr; /**< Virtual address of segment buffer. */
+ void *buf_addr; /**< Virtual address of segment buffer. */
#if RTE_IOVA_IN_MBUF

You could do the same with the cacheline1 marker:

	/* second cache line - fields only used in slow path or on TX */

- RTE_MARKER cacheline1 __rte_cache_min_aligned;
+ union {
+ char cacheline1[RTE_CACHE_LINE_MIN_SIZE];

+ struct {
#if RTE_IOVA_IN_MBUF
- /**
- * Next segment of scattered packet. Must be NULL in the last
- * segment or in case of non-segmented packet.
- */
- struct rte_mbuf *next;
+ /**
+ * Next segment of scattered packet. Must be NULL in the last
+ * segment or in case of non-segmented packet.
+ */
+ struct rte_mbuf *next;
#else

It also avoids the weird union between cacheline0 and buf_addr at the beginning of the structure, and between cacheline1 and next/dynfield2 at the beginning of the second cache line.

And then you can omit the pad_cacheline0 array at the end of the first part of the structure.

BTW: char is a weaker type than uint8_t - i.e. it is easier to cast to another type. It might be a personal preference, but I would use char instead of uint8_t for the padding array.

#11 lore raw

Re: [PATCH v2] mbuf: replace GCC marker extension with C11 anonymous unions

Quoted 7 lines · Morten Brørup
Quoted 5 lines

From: Tyler Retzlaff [mailto:[email protected]]
Sent: Tuesday, 13 February 2024 07.46

Replace the use of RTE_MARKER<x> with C11 anonymous unions to improve code portability between toolchains.

How about combining the cacheline 0 marker and padding, like this:

this seems like a good suggestion i will evaluate it. at least it gets rid of all the extra nesting if there are no unforseen problems.

Quoted 12 lines

struct rte_mbuf {

lib/mbuf/rte_mbuf_core.h +4 -2
-	RTE_MARKER cacheline0;
+	union {
+		char cacheline0[RTE_CACHE_LINE_MIN_SIZE];
 
+		struct {
-	void *buf_addr;           /**< Virtual address of segment buffer. */
+			void *buf_addr; /**< Virtual address of segment buffer. */
 #if RTE_IOVA_IN_MBUF
Quoted 1 line

You could do the same with the cacheline1 marker:

yeah, i wondered if i should. i'll do it since it does seem more consistent to just pad out both cachelines explicitly instead of just doing all but the last.

we probably don't need to align struct rte_mbuf type if we do since it will cause it to be naturally aligned to RTE_CACHE_LINE_MIN_SIZE.

Quoted 21 lines
	/* second cache line - fields only used in slow path or on TX */
lib/mbuf/rte_mbuf_core.h +8 -6
-	RTE_MARKER cacheline1 __rte_cache_min_aligned;
+	union {
+		char cacheline1[RTE_CACHE_LINE_MIN_SIZE];
 
+		struct {
 #if RTE_IOVA_IN_MBUF
-	/**
-	 * Next segment of scattered packet. Must be NULL in the last
-	 * segment or in case of non-segmented packet.
-	 */
-	struct rte_mbuf *next;
+			/**
+			 * Next segment of scattered packet. Must be NULL in the last
+			 * segment or in case of non-segmented packet.
+			 */
+			struct rte_mbuf *next;
 #else
Quoted 7 lines

It also avoids the weird union between cacheline0 and buf_addr at the beginning of the structure, and between cacheline1 and next/dynfield2 at the beginning of the second cache line.

And then you can omit the pad_cacheline0 array at the end of the first part of the structure.

BTW: char is a weaker type than uint8_t - i.e. it is easier to cast to another type. It might be a personal preference, but I would use char instead of uint8_t for the padding array.

noted, i'll make the change.

thanks!

#12 lore raw

RE: [PATCH v2] mbuf: replace GCC marker extension with C11 anonymous unions

Quoted 30 lines

From: Tyler Retzlaff [mailto:[email protected]]
Sent: Tuesday, 13 February 2024 19.48

Quoted 4 lines · Morten Brørup
Quoted 4 lines

From: Tyler Retzlaff [mailto:[email protected]]
Sent: Tuesday, 13 February 2024 07.46

Replace the use of RTE_MARKER<x> with C11 anonymous unions to

improve

Quoted 3 lines
Quoted 1 line

code portability between toolchains.

How about combining the cacheline 0 marker and padding, like this:

this seems like a good suggestion i will evaluate it. at least it gets rid of all the extra nesting if there are no unforseen problems.

lib/mbuf/rte_mbuf_core.h enum {

Quoted 8 lines

struct rte_mbuf {

lib/mbuf/rte_mbuf_core.h +3 -2
-	RTE_MARKER cacheline0;
+	union {
+		char cacheline0[RTE_CACHE_LINE_MIN_SIZE];
 
+		struct {
-	void *buf_addr;           /**< Virtual address of segment buffer.

*/

Review

Quoted 1 line
(quoted diff) +1 -0
+			void *buf_addr; /**< Virtual address of segment

buffer. */

Quoted 3 lines

#if RTE_IOVA_IN_MBUF

Quoted 8 lines
Quoted 1 line

You could do the same with the cacheline1 marker:

yeah, i wondered if i should. i'll do it since it does seem more consistent to just pad out both cachelines explicitly instead of just doing all but the last.

we probably don't need to align struct rte_mbuf type if we do since it will cause it to be naturally aligned to RTE_CACHE_LINE_MIN_SIZE.

We still need to align struct rte_mbuf to cache line size. RTE_CACHE_LINE_MIN_SIZE is 64, like the cache line size on Intel arch, but cache line size is 128 byte on POWER architecture and Apple M2.

#13 lore raw

Re: [PATCH v2] mbuf: replace GCC marker extension with C11 anonymous unions

Quoted 36 lines · Morten Brørup
Quoted 36 lines

From: Tyler Retzlaff [mailto:[email protected]]
Sent: Tuesday, 13 February 2024 19.48

Quoted 4 lines · Morten Brørup
Quoted 4 lines

From: Tyler Retzlaff [mailto:[email protected]]
Sent: Tuesday, 13 February 2024 07.46

Replace the use of RTE_MARKER<x> with C11 anonymous unions to

improve

Quoted 3 lines
Quoted 1 line

code portability between toolchains.

How about combining the cacheline 0 marker and padding, like this:

this seems like a good suggestion i will evaluate it. at least it gets rid of all the extra nesting if there are no unforseen problems.

lib/mbuf/rte_mbuf_core.h enum {

Quoted 8 lines

struct rte_mbuf {

lib/mbuf/rte_mbuf_core.h +3 -2
-	RTE_MARKER cacheline0;
+	union {
+		char cacheline0[RTE_CACHE_LINE_MIN_SIZE];
 
+		struct {
-	void *buf_addr;           /**< Virtual address of segment buffer.

*/

Review

Quoted 1 line
(quoted diff) +1 -0
+			void *buf_addr; /**< Virtual address of segment

buffer. */

Quoted 4 lines

#if RTE_IOVA_IN_MBUF

You could do the same with the cacheline1 marker:

yeah, i wondered if i should. i'll do it since it does seem more consistent to just pad out both cachelines explicitly instead of just doing all but the last.

Quoted 6 lines
Quoted 2 lines

we probably don't need to align struct rte_mbuf type if we do since it will cause it to be naturally aligned to RTE_CACHE_LINE_MIN_SIZE.

We still need to align struct rte_mbuf to cache line size. RTE_CACHE_LINE_MIN_SIZE is 64, like the cache line size on Intel arch, but cache line size is 128 byte on POWER architecture and Apple M2.

RTE_CACHE_LINE_SIZE vs RTE_CACHE_LINE_MIN_SIZE forgot about that.

#14 lore raw

Re: [PATCH v2] RFC: replace GCC marker extension with C11 anonymous unions

In reply to Tyler Retzlaff
Quoted 23 lines · Tyler Retzlaff

The zero sized RTE_MARKER<n> typedefs are a GCC extension unsupported by MSVC. Replace the use of the RTE_MARKER typedefs with anonymous unions.

Note:

v1 of the series tried to maintain the API after some study it has been discovered that some existing uses of the markers do not produce compilation failure but evaluate to unintended values in the absence of adaptation. For this reason the existing markers cannot be removed because it is too hard to identify what needs to be changed by consumers. While the ABI has been maintained the subtle API change is just too risky.

The question I'm asking now is how to gracefully deprecate the markers while allowing consumption of the struct on Windows.

I propose the following:

* Introduce the unions as per-this series except instead of adding members that match the original RTE_MARKER field names provide *new* names.
* Retain (conditionally compiled away on Windows) the existing RTE_MARKER fields with their original names.
* Convert in-tree code to use the new names in the unions.

Quoted 5 lines

The old names & markers would be announced for deprecation and eventually removed and when they are the conditional compilation would also go away.

Thoughts?

This seems a good approach. +1 from me for the idea.

/Bruce

#15 lore raw

RE: [PATCH v2] RFC: replace GCC marker extension with C11 anonymous unions

In reply to Tyler Retzlaff
Quoted 33 lines

From: Tyler Retzlaff [mailto:[email protected]]
Sent: Tuesday, 13 February 2024 07.46

The zero sized RTE_MARKER<n> typedefs are a GCC extension unsupported by
MSVC. Replace the use of the RTE_MARKER typedefs with anonymous unions.

Note:

v1 of the series tried to maintain the API after some study it has been discovered that some existing uses of the markers do not produce compilation
failure but evaluate to unintended values in the absence of adaptation. For this reason the existing markers cannot be removed because it is too hard
to identify what needs to be changed by consumers. While the ABI has been
maintained the subtle API change is just too risky.

The question I'm asking now is how to gracefully deprecate the markers while allowing consumption of the struct on Windows.

I propose the following:

* Introduce the unions as per-this series except instead of adding members
that match the original RTE_MARKER field names provide *new* names.
* Retain (conditionally compiled away on Windows) the existing RTE_MARKER
fields with their original names.
* Convert in-tree code to use the new names in the unions.

Quoted 6 lines

The old names & markers would be announced for deprecation and eventually
removed and when they are the conditional compilation would also go away.

Thoughts?

Seems like the right thing to do!

The modified type of rearm_data might not be noticed by out-of-tree PMD developers, so using a new name for the new type reduces the risk.

If some of the markers maintain their type or get a compatible type (from an API perspective), they can keep their names.

#16 lore raw

PATCH v3 1/1 RFC deprecate RTE_MARKER in struct rte_mbuf

In reply to Tyler Retzlaff

Here is the latest iteration of the proposed change to allow struct rte_mbuf to be consumed by MSVC.

* Introduce an internal __rte_marker macro conditionally expanded for MSVC vs existing users of the struct. At some point we can uncomment __rte_deprecated to assist migration away from the current marker fields for applications after appropriate announcement periods etc..

* Introduce anonymous unions to allow aliasing of the previous named offsets by a *new* name. The intention would be to convert the dpdk tree to use the new names along with this change and enable __rte_deprecated for dpdk builds (not applications) to avoid accidental re-introduction.

* The anonymous unions are now also used to pad cacheline0 and cacheline1 instead of __rte_cache_min_aligned.

* Converted the type of the fields for the named markers to char[] instead of uint8_t[].

Tyler Retzlaff (1):
mbuf: deprecate GCC marker in rte mbuf struct

 lib/eal/include/rte_common.h |   6 +
 lib/mbuf/rte_mbuf_core.h     | 365 +++++++++++++++++++++++--------------------
 2 files changed, 201 insertions(+), 170 deletions(-)
Signature · 1 line
1.8.3.1
#17 lore raw

PATCH v3 1/1 mbuf: deprecate GCC marker in rte mbuf struct

Provide a macro that allows conditional expansion of RTE_MARKER fields to empty to allow rte_mbuf to be used with MSVC. It is proposed that we announce the fields to be __rte_deprecated (currently disabled).

Introduce C11 anonymous unions to permit aliasing of well-known offsets by name into the rte_mbuf structure by a *new* name and to provide padding for cache alignment.

---
 lib/eal/include/rte_common.h |   6 +
 lib/mbuf/rte_mbuf_core.h     | 365 +++++++++++++++++++++++--------------------
 2 files changed, 201 insertions(+), 170 deletions(-)
lib/eal/include/rte_common.h +6 -0
index d7d6390..af73f67 100644
@@ -582,6 +582,12 @@ static void __attribute__((destructor(RTE_PRIO(prio)), used)) func(void)
 /** Marker for 8B alignment in a structure. */
 __extension__ typedef uint64_t RTE_MARKER64[0];
 
+#define __rte_marker(type, name) type name /* __rte_deprecated */
+
+#else
+
+#define __rte_marker(type, name)
+
 #endif
 
 /*********** Macros for calculating min and max **********/
lib/mbuf/rte_mbuf_core.h +195 -170

408 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#18 lore raw

RE: [PATCH v3] mbuf: deprecate GCC marker in rte mbuf struct

Quoted 7 lines

From: Tyler Retzlaff [mailto:[email protected]]
Sent: Wednesday, 14 February 2024 00.33

Provide a macro that allows conditional expansion of RTE_MARKER fields to empty to allow rte_mbuf to be used with MSVC. It is proposed that we announce the fields to be __rte_deprecated (currently disabled).

Quoted 6 lines

Introduce C11 anonymous unions to permit aliasing of well-known offsets by name into the rte_mbuf structure by a *new* name and to provide padding for cache alignment.

---

I think you are nearly there now. Beautiful solution. :-)

Only one comment inline below.

Quoted 36 lines
(quoted diff) +0 -1
-	/* remaining bytes are set on RX when pulling packet from

descriptor */

lib/mbuf/rte_mbuf_core.h +1 -3
-	RTE_MARKER rx_descriptor_fields1;
+			uint64_t ol_flags;        /**< Offload features. */
 
-	/*
-	 * The packet type, which is the combination of outer/inner L2,

L3, L4

(quoted diff) +0 -1
-	 * and tunnel types. The packet_type is about data really present

in the

(quoted diff) +0 -1
-	 * mbuf. Example: if vlan stripping is enabled, a received vlan

packet

(quoted diff) +0 -1
-	 * would have RTE_PTYPE_L2_ETHER and not RTE_PTYPE_L2_VLAN

because the

lib/mbuf/rte_mbuf_core.h +0 -4
-	 * vlan is stripped from the data.
-	 */
-	union {
-		uint32_t packet_type; /**< L2/L3/L4 and tunnel information.

*/

lib/mbuf/rte_mbuf_core.h +1 -6
-		__extension__
-		struct {
-			uint8_t l2_type:4;   /**< (Outer) L2 type. */
-			uint8_t l3_type:4;   /**< (Outer) L3 type. */
-			uint8_t l4_type:4;   /**< (Outer) L4 type. */
-			uint8_t tun_type:4;  /**< Tunnel type. */
+			/* remaining bytes are set on RX when pulling packet

from descriptor */

lib/mbuf/rte_mbuf_core.h +2 -6
+			__rte_marker(RTE_MARKER, rx_descriptor_fields1);
 			union {
-				uint8_t inner_esp_next_proto;
-				/**< ESP next protocol type, valid if
-				 * RTE_PTYPE_TUNNEL_ESP tunnel type is set
-				 * on both Tx and Rx.
-				 */
-				__extension__
+				char mbuf_rx_descriptor_fields1[sizeof(void
Quoted 1 line

*)];

The size of the mbuf_rx_descriptor_fields1 array - and the union it belongs to - may not be accurate.

The existing rx_descriptor_fields1 effectively has no type/size, and the associated comment "/* remaining bytes are set on RX" doesn't help; it omits how many bytes it refers to. I'll call it "an already existing bug" for the sake of discussion. I think the struct should go all the way to the pool pointer, to reflect which "remaining bytes" are set on RX.
You might consider taking the opportunity to fix this existing "bug", i.e. update the comment and move more fields into the struct unionized with the mbuf_rx_descriptor_fields1 array. (This suggestion is in the category NICE TO HAVE, and certainly not a requirement!)

Regardless if you fix this existing "bug" or not, the size of the mbuf_rx_descriptor_fields1 array should match the size of the struct it is unionized with, rather than using sizeof(void*) (which is either 4 or 8 bytes, depending on CPU architecture). Instinctively, I think that it is a bad idea to carry over the "sizeless" aspect of the rx_descriptor_fields1 marker into the mbuf_rx_descriptor_fields1 array. However, you have been working more in depth with this patch series, so I'm open for arguments for the way you did it!

Quoted 168 lines
lib/mbuf/rte_mbuf_core.h +2 -4
 				struct {
-					uint8_t inner_l2_type:4;
-					/**< Inner L2 type. */
-					uint8_t inner_l3_type:4;
-					/**< Inner L3 type. */
+					/*
+					 * The packet type, which is the

combination of outer/inner L2, L3, L4

(quoted diff) +1 -0
+					 * and tunnel types. The packet_type is

about data really present in the

(quoted diff) +1 -0
+					 * mbuf. Example: if vlan stripping is

enabled, a received vlan packet

(quoted diff) +1 -0
+					 * would have RTE_PTYPE_L2_ETHER and not

RTE_PTYPE_L2_VLAN because the

lib/mbuf/rte_mbuf_core.h +4 -0
+					 * vlan is stripped from the data.
+					 */
+					union {
+						uint32_t packet_type; /**< L2/L3/L4

and tunnel information. */

lib/mbuf/rte_mbuf_core.h +3 -0
+						__extension__
+						struct {
+							uint8_t l2_type:4;   /**<

(Outer) L2 type. */

(quoted diff) +1 -0
+							uint8_t l3_type:4;   /**<

(Outer) L3 type. */

(quoted diff) +1 -0
+							uint8_t l4_type:4;   /**<

(Outer) L4 type. */

(quoted diff) +1 -0
+							uint8_t tun_type:4;  /**<

Tunnel type. */

(quoted diff) +2 -0
+							union {
+								uint8_t

inner_esp_next_proto;

(quoted diff) +1 -0
+								/**< ESP next protocol

type, valid if

(quoted diff) +1 -0
+								 * RTE_PTYPE_TUNNEL_ESP

tunnel type is set

lib/mbuf/rte_mbuf_core.h +5 -0
+								 * on both Tx and Rx.
+								 */
+								__extension__
+								struct {
+									uint8_t

inner_l2_type:4;

(quoted diff) +1 -0
+									/**< Inner L2

type. */

(quoted diff) +1 -0
+									uint8_t

inner_l3_type:4;

(quoted diff) +1 -0
+									/**< Inner L3

type. */

lib/mbuf/rte_mbuf_core.h +3 -0
+								};
+							};
+							uint8_t inner_l4_type:4; /**<

Inner L4 type. */

lib/mbuf/rte_mbuf_core.h +3 -0
+						};
+					};
+					uint32_t pkt_len;         /**< Total pkt

len: sum of all segments. */

lib/mbuf/rte_mbuf_core.h +0 -4
 				};
 			};
-			uint8_t inner_l4_type:4; /**< Inner L4 type. */
-		};
-	};
 
-	uint32_t pkt_len;         /**< Total pkt len: sum of all

segments. */

(quoted diff) +0 -1
-	uint16_t data_len;        /**< Amount of data in segment buffer.

*/

lib/mbuf/rte_mbuf_core.h +1 -2
-	/** VLAN TCI (CPU order), valid if RTE_MBUF_F_RX_VLAN is set. */
-	uint16_t vlan_tci;
+			uint16_t data_len;        /**< Amount of data in

segment buffer. */

(quoted diff) +1 -0
+			/** VLAN TCI (CPU order), valid if RTE_MBUF_F_RX_VLAN

is set. */

lib/mbuf/rte_mbuf_core.h +1 -3
+			uint16_t vlan_tci;
 
-	union {
-		union {
-			uint32_t rss;     /**< RSS hash result if RSS enabled

*/

lib/mbuf/rte_mbuf_core.h +2 -1
-			struct {
+			union {
 				union {
+					uint32_t rss;     /**< RSS hash result if

RSS enabled */

lib/mbuf/rte_mbuf_core.h +0 -24
 					struct {
-						uint16_t hash;
-						uint16_t id;
-					};
-					uint32_t lo;
-					/**< Second 4 flexible bytes */
-				};
-				uint32_t hi;
-				/**< First 4 flexible bytes or FD ID, dependent
-				 * on RTE_MBUF_F_RX_FDIR_* flag in ol_flags.
-				 */
-			} fdir;	/**< Filter identifier if FDIR enabled */
-			struct rte_mbuf_sched sched;
-			/**< Hierarchical scheduler : 8 bytes */
-			struct {
-				uint32_t reserved1;
-				uint16_t reserved2;
-				uint16_t txq;
-				/**< The event eth Tx adapter uses this field
-				 * to store Tx queue id.
-				 * @see rte_event_eth_tx_adapter_txq_set()
-				 */
-			} txadapter; /**< Eventdev ethdev Tx adapter */
-			uint32_t usr;
-			/**< User defined tags. See rte_distributor_process()

*/

lib/mbuf/rte_mbuf_core.h +7 -2
-		} hash;                   /**< hash information */
-	};
+						union {
+							struct {
+								uint16_t hash;
+								uint16_t id;
+							};
+							uint32_t lo;
+							/**< Second 4 flexible bytes

*/

lib/mbuf/rte_mbuf_core.h +3 -0
+						};
+						uint32_t hi;
+						/**< First 4 flexible bytes or FD

ID, dependent

(quoted diff) +1 -0
+						 * on RTE_MBUF_F_RX_FDIR_* flag in

ol_flags.

(quoted diff) +2 -0
+						 */
+					} fdir;	/**< Filter identifier if

FDIR enabled */

lib/mbuf/rte_mbuf_core.h +7 -0
+					struct rte_mbuf_sched sched;
+					/**< Hierarchical scheduler : 8 bytes */
+					struct {
+						uint32_t reserved1;
+						uint16_t reserved2;
+						uint16_t txq;
+						/**< The event eth Tx adapter uses

this field

(quoted diff) +2 -0
+						 * to store Tx queue id.
+						 * @see

rte_event_eth_tx_adapter_txq_set()

(quoted diff) +2 -0
+						 */
+					} txadapter; /**< Eventdev ethdev Tx

adapter */

(quoted diff) +2 -0
+					uint32_t usr;
+					/**< User defined tags. See

rte_distributor_process() */

(quoted diff) +1 -0
+				} hash;                   /**< hash information

*/

lib/mbuf/rte_mbuf_core.h +1 -1
+			};
 
-	/** Outer VLAN TCI (CPU order), valid if RTE_MBUF_F_RX_QINQ is

set. */

(quoted diff) +1 -1
-	uint16_t vlan_tci_outer;
+			/** Outer VLAN TCI (CPU order), valid if

RTE_MBUF_F_RX_QINQ is set. */

lib/mbuf/rte_mbuf_core.h +2 -1
+			uint16_t vlan_tci_outer;
 
-	uint16_t buf_len;         /**< Length of segment buffer. */
+			uint16_t buf_len;         /**< Length of segment

buffer. */

(quoted diff) +0 -1
-	struct rte_mempool *pool; /**< Pool from which mbuf was

allocated. */

(quoted diff) +1 -0
+			struct rte_mempool *pool; /**< Pool from which mbuf

was allocated. */

lib/mbuf/rte_mbuf_core.h +2 -0
+		};
+	};
 
 	/* second cache line - fields only used in slow path or on TX */
#19 lore raw

Re: [PATCH v3] mbuf: deprecate GCC marker in rte mbuf struct

Quoted 49 lines · Morten Brørup
Quoted 7 lines

From: Tyler Retzlaff [mailto:[email protected]]
Sent: Wednesday, 14 February 2024 00.33

Provide a macro that allows conditional expansion of RTE_MARKER fields to empty to allow rte_mbuf to be used with MSVC. It is proposed that we announce the fields to be __rte_deprecated (currently disabled).

Quoted 6 lines

Introduce C11 anonymous unions to permit aliasing of well-known offsets by name into the rte_mbuf structure by a *new* name and to provide padding for cache alignment.

---

I think you are nearly there now. Beautiful solution. :-)

Only one comment inline below.

Quoted 31 lines
(quoted diff) +0 -1
-	/* remaining bytes are set on RX when pulling packet from

descriptor */

lib/mbuf/rte_mbuf_core.h +1 -3
-	RTE_MARKER rx_descriptor_fields1;
+			uint64_t ol_flags;        /**< Offload features. */
 
-	/*
-	 * The packet type, which is the combination of outer/inner L2,

L3, L4

(quoted diff) +0 -1
-	 * and tunnel types. The packet_type is about data really present

in the

(quoted diff) +0 -1
-	 * mbuf. Example: if vlan stripping is enabled, a received vlan

packet

(quoted diff) +0 -1
-	 * would have RTE_PTYPE_L2_ETHER and not RTE_PTYPE_L2_VLAN

because the

lib/mbuf/rte_mbuf_core.h +0 -4
-	 * vlan is stripped from the data.
-	 */
-	union {
-		uint32_t packet_type; /**< L2/L3/L4 and tunnel information.

*/

lib/mbuf/rte_mbuf_core.h +1 -6
-		__extension__
-		struct {
-			uint8_t l2_type:4;   /**< (Outer) L2 type. */
-			uint8_t l3_type:4;   /**< (Outer) L3 type. */
-			uint8_t l4_type:4;   /**< (Outer) L4 type. */
-			uint8_t tun_type:4;  /**< Tunnel type. */
+			/* remaining bytes are set on RX when pulling packet

from descriptor */

lib/mbuf/rte_mbuf_core.h +1 -2
+			__rte_marker(RTE_MARKER, rx_descriptor_fields1);
 			union {
-				uint8_t inner_esp_next_proto;
-				/**< ESP next protocol type, valid if
Quoted 8 lines
Quoted 6 lines
lib/mbuf/rte_mbuf_core.h +1 -4
-				 * RTE_PTYPE_TUNNEL_ESP tunnel type is set
-				 * on both Tx and Rx.
-				 */
-				__extension__
+				char mbuf_rx_descriptor_fields1[sizeof(void

*)];

The size of the mbuf_rx_descriptor_fields1 array - and the union it belongs to - may not be accurate.

yeah, i just cloned the type out of the marker. but you are right it's garbage. on 32-bit platforms access via that union member probably falls into undefined behavior territory.

i'll replace it with [8] since that's the size of the struct member, at least then it's as big as the other union fields.

i think my greatest concern at this point is making a mistake in adapting the in-tree consumers to the new field that assumed the named thing was void *[]. sometimes the address is taken, sometimes not, might be okay since we're consistently using arrays now but it will likely need some casts where previously didn't. definitely appreciate careful review.

thanks

Quoted 176 lines

The existing rx_descriptor_fields1 effectively has no type/size, and the associated comment "/* remaining bytes are set on RX" doesn't help; it omits how many bytes it refers to. I'll call it "an already existing bug" for the sake of discussion. I think the struct should go all the way to the pool pointer, to reflect which "remaining bytes" are set on RX.
You might consider taking the opportunity to fix this existing "bug", i.e. update the comment and move more fields into the struct unionized with the mbuf_rx_descriptor_fields1 array. (This suggestion is in the category NICE TO HAVE, and certainly not a requirement!)

Regardless if you fix this existing "bug" or not, the size of the mbuf_rx_descriptor_fields1 array should match the size of the struct it is unionized with, rather than using sizeof(void*) (which is either 4 or 8 bytes, depending on CPU architecture). Instinctively, I think that it is a bad idea to carry over the "sizeless" aspect of the rx_descriptor_fields1 marker into the mbuf_rx_descriptor_fields1 array. However, you have been working more in depth with this patch series, so I'm open for arguments for the way you did it!

Quoted 168 lines
lib/mbuf/rte_mbuf_core.h +2 -4
 				struct {
-					uint8_t inner_l2_type:4;
-					/**< Inner L2 type. */
-					uint8_t inner_l3_type:4;
-					/**< Inner L3 type. */
+					/*
+					 * The packet type, which is the

combination of outer/inner L2, L3, L4

(quoted diff) +1 -0
+					 * and tunnel types. The packet_type is

about data really present in the

(quoted diff) +1 -0
+					 * mbuf. Example: if vlan stripping is

enabled, a received vlan packet

(quoted diff) +1 -0
+					 * would have RTE_PTYPE_L2_ETHER and not

RTE_PTYPE_L2_VLAN because the

lib/mbuf/rte_mbuf_core.h +4 -0
+					 * vlan is stripped from the data.
+					 */
+					union {
+						uint32_t packet_type; /**< L2/L3/L4

and tunnel information. */

lib/mbuf/rte_mbuf_core.h +3 -0
+						__extension__
+						struct {
+							uint8_t l2_type:4;   /**<

(Outer) L2 type. */

(quoted diff) +1 -0
+							uint8_t l3_type:4;   /**<

(Outer) L3 type. */

(quoted diff) +1 -0
+							uint8_t l4_type:4;   /**<

(Outer) L4 type. */

(quoted diff) +1 -0
+							uint8_t tun_type:4;  /**<

Tunnel type. */

(quoted diff) +2 -0
+							union {
+								uint8_t

inner_esp_next_proto;

(quoted diff) +1 -0
+								/**< ESP next protocol

type, valid if

(quoted diff) +1 -0
+								 * RTE_PTYPE_TUNNEL_ESP

tunnel type is set

lib/mbuf/rte_mbuf_core.h +5 -0
+								 * on both Tx and Rx.
+								 */
+								__extension__
+								struct {
+									uint8_t

inner_l2_type:4;

(quoted diff) +1 -0
+									/**< Inner L2

type. */

(quoted diff) +1 -0
+									uint8_t

inner_l3_type:4;

(quoted diff) +1 -0
+									/**< Inner L3

type. */

lib/mbuf/rte_mbuf_core.h +3 -0
+								};
+							};
+							uint8_t inner_l4_type:4; /**<

Inner L4 type. */

lib/mbuf/rte_mbuf_core.h +3 -0
+						};
+					};
+					uint32_t pkt_len;         /**< Total pkt

len: sum of all segments. */

lib/mbuf/rte_mbuf_core.h +0 -4
 				};
 			};
-			uint8_t inner_l4_type:4; /**< Inner L4 type. */
-		};
-	};
 
-	uint32_t pkt_len;         /**< Total pkt len: sum of all

segments. */

(quoted diff) +0 -1
-	uint16_t data_len;        /**< Amount of data in segment buffer.

*/

lib/mbuf/rte_mbuf_core.h +1 -2
-	/** VLAN TCI (CPU order), valid if RTE_MBUF_F_RX_VLAN is set. */
-	uint16_t vlan_tci;
+			uint16_t data_len;        /**< Amount of data in

segment buffer. */

(quoted diff) +1 -0
+			/** VLAN TCI (CPU order), valid if RTE_MBUF_F_RX_VLAN

is set. */

lib/mbuf/rte_mbuf_core.h +1 -3
+			uint16_t vlan_tci;
 
-	union {
-		union {
-			uint32_t rss;     /**< RSS hash result if RSS enabled

*/

lib/mbuf/rte_mbuf_core.h +2 -1
-			struct {
+			union {
 				union {
+					uint32_t rss;     /**< RSS hash result if

RSS enabled */

lib/mbuf/rte_mbuf_core.h +0 -24
 					struct {
-						uint16_t hash;
-						uint16_t id;
-					};
-					uint32_t lo;
-					/**< Second 4 flexible bytes */
-				};
-				uint32_t hi;
-				/**< First 4 flexible bytes or FD ID, dependent
-				 * on RTE_MBUF_F_RX_FDIR_* flag in ol_flags.
-				 */
-			} fdir;	/**< Filter identifier if FDIR enabled */
-			struct rte_mbuf_sched sched;
-			/**< Hierarchical scheduler : 8 bytes */
-			struct {
-				uint32_t reserved1;
-				uint16_t reserved2;
-				uint16_t txq;
-				/**< The event eth Tx adapter uses this field
-				 * to store Tx queue id.
-				 * @see rte_event_eth_tx_adapter_txq_set()
-				 */
-			} txadapter; /**< Eventdev ethdev Tx adapter */
-			uint32_t usr;
-			/**< User defined tags. See rte_distributor_process()

*/

lib/mbuf/rte_mbuf_core.h +7 -2
-		} hash;                   /**< hash information */
-	};
+						union {
+							struct {
+								uint16_t hash;
+								uint16_t id;
+							};
+							uint32_t lo;
+							/**< Second 4 flexible bytes

*/

lib/mbuf/rte_mbuf_core.h +3 -0
+						};
+						uint32_t hi;
+						/**< First 4 flexible bytes or FD

ID, dependent

(quoted diff) +1 -0
+						 * on RTE_MBUF_F_RX_FDIR_* flag in

ol_flags.

(quoted diff) +2 -0
+						 */
+					} fdir;	/**< Filter identifier if

FDIR enabled */

lib/mbuf/rte_mbuf_core.h +7 -0
+					struct rte_mbuf_sched sched;
+					/**< Hierarchical scheduler : 8 bytes */
+					struct {
+						uint32_t reserved1;
+						uint16_t reserved2;
+						uint16_t txq;
+						/**< The event eth Tx adapter uses

this field

(quoted diff) +2 -0
+						 * to store Tx queue id.
+						 * @see

rte_event_eth_tx_adapter_txq_set()

(quoted diff) +2 -0
+						 */
+					} txadapter; /**< Eventdev ethdev Tx

adapter */

(quoted diff) +2 -0
+					uint32_t usr;
+					/**< User defined tags. See

rte_distributor_process() */

(quoted diff) +1 -0
+				} hash;                   /**< hash information

*/

lib/mbuf/rte_mbuf_core.h +1 -1
+			};
 
-	/** Outer VLAN TCI (CPU order), valid if RTE_MBUF_F_RX_QINQ is

set. */

(quoted diff) +1 -1
-	uint16_t vlan_tci_outer;
+			/** Outer VLAN TCI (CPU order), valid if

RTE_MBUF_F_RX_QINQ is set. */

lib/mbuf/rte_mbuf_core.h +2 -1
+			uint16_t vlan_tci_outer;
 
-	uint16_t buf_len;         /**< Length of segment buffer. */
+			uint16_t buf_len;         /**< Length of segment

buffer. */

(quoted diff) +0 -1
-	struct rte_mempool *pool; /**< Pool from which mbuf was

allocated. */

(quoted diff) +1 -0
+			struct rte_mempool *pool; /**< Pool from which mbuf

was allocated. */

lib/mbuf/rte_mbuf_core.h +2 -0
+		};
+	};
 
 	/* second cache line - fields only used in slow path or on TX */
#20 lore raw

RE: [PATCH v3] RFC deprecate RTE_MARKER in struct rte_mbuf

In reply to Tyler Retzlaff
Quoted 23 lines

From: Tyler Retzlaff [mailto:[email protected]]
Sent: Wednesday, 14 February 2024 00.33

Here is the latest iteration of the proposed change to allow struct rte_mbuf
to be consumed by MSVC.

* Introduce an internal __rte_marker macro conditionally expanded for MSVC
vs existing users of the struct. At some point we can uncomment
__rte_deprecated
to assist migration away from the current marker fields for
applications
after appropriate announcement periods etc..

* Introduce anonymous unions to allow aliasing of the previous named offsets by a *new* name. The intention would be to convert the dpdk
tree
to use the new names along with this change and enable
__rte_deprecated
for dpdk builds (not applications) to avoid accidental re-
introduction.

Quoted 3 lines

* The anonymous unions are now also used to pad cacheline0 and cacheline1 instead
of __rte_cache_min_aligned.

ACK. This design also seems reusable for similar structures.

#21 lore raw

Re: [PATCH v3] RFC deprecate RTE_MARKER in struct rte_mbuf

In reply to Tyler Retzlaff
Quoted 19 lines · On Tue, 13 Feb 2024 15:33:28 -0800 Tyler Retzlaff…

Here is the latest iteration of the proposed change to allow struct rte_mbuf to be consumed by MSVC.

* Introduce an internal __rte_marker macro conditionally expanded for MSVC vs existing users of the struct. At some point we can uncomment __rte_deprecated to assist migration away from the current marker fields for applications after appropriate announcement periods etc..

* Introduce anonymous unions to allow aliasing of the previous named offsets by a *new* name. The intention would be to convert the dpdk tree to use the new names along with this change and enable __rte_deprecated for dpdk builds (not applications) to avoid accidental re-introduction.

* The anonymous unions are now also used to pad cacheline0 and cacheline1 instead of __rte_cache_min_aligned.

* Converted the type of the fields for the named markers to char[] instead of uint8_t[].

Quoted 7 lines

Tyler Retzlaff (1):
mbuf: deprecate GCC marker in rte mbuf struct

 lib/eal/include/rte_common.h |   6 +
 lib/mbuf/rte_mbuf_core.h     | 365 +++++++++++++++++++++++--------------------
 2 files changed, 201 insertions(+), 170 deletions(-)

I was never convinced that __rte_marker was good idea in the first place.

It seemed to be only useful as annotation or for use by pre-fetch. The problem is that for annotation, it can easily be wrong if using different cache size or structure chagnes.
For prefetch, just using the structure and pointer math based on cacheline seems like a better option. Plus DPDK does excessive and unproved prefetching. For real world cases prefetching doesn't help unless there is enough cycles from when prefetch is issued and when it is used. If too long, the prefetch is useless, if too close the extra overhead of the prefetch slows down the intervening execution units.

#22 lore raw

v4 cover stop using zero sized marker fields

In reply to Tyler Retzlaff

The zero sized RTE_MARKER<n> typedefs are a GCC extension unsupported by MSVC. This series adds new fields and allows deprecation of the old.

Introduce new anonymous union fields with mbuf_ prefix for cacheline0, rearm_data, rx_descriptor_fields1, and cacheline1.

Remove in-tree use of the zero sized marker fields and adapt consuming code to use the new anonymous union fields.

Question: what is the correct mechanism to allow uncommenting of __rte_deprecated in __rte_marker when building DPDK itself but not when building applications?

Tyler Retzlaff (18):
mbuf: deprecate GCC marker in rte mbuf struct
mbuf: stop using zero sized marker fields net/i40e: stop using zero sized marker fields net/iavf: stop using zero sized marker fields net/ice: stop using zero sized marker fields net/ixgbe: stop using zero sized marker fields net/mlx5: stop using zero sized marker fields net/sfc: stop using zero sized marker fields net/bnxt: stop using zero sized marker fields net/enic: stop using zero sized marker fields net/fm10k: stop using zero sized marker fields net/hns3: stop using zero sized marker fields net/ionic: stop using zero sized marker fields net/thunderx: stop using zero sized marker fields net/virtio: stop using zero sized marker fields net/cnxk: stop using zero sized marker fields common/idpf: stop using zero sized marker fields examples/dma: stop using zero sized marker fields

 doc/guides/rel_notes/deprecation.rst            |  20 ++
 drivers/common/idpf/idpf_common_rxtx.c          |   4 +-
 drivers/common/idpf/idpf_common_rxtx_avx512.c   |  60 ++--
 drivers/net/bnxt/bnxt_rxtx_vec_avx2.c           |  18 +-
 drivers/net/bnxt/bnxt_rxtx_vec_common.h         |   4 +-
 drivers/net/bnxt/bnxt_rxtx_vec_neon.c           |  20 +-
 drivers/net/bnxt/bnxt_rxtx_vec_sse.c            |  20 +-
 drivers/net/cnxk/cn10k_rx.h                     |  50 ++--
 drivers/net/cnxk/cn9k_rx.h                      |  34 +--
 drivers/net/cnxk/cnxk_ethdev.c                  |   4 +-
 drivers/net/enic/enic.h                         |   2 +-
 drivers/net/enic/enic_main.c                    |   4 +-
 drivers/net/enic/enic_rxtx_vec_avx2.c           |  22 +-
 drivers/net/fm10k/fm10k_rxtx_vec.c              |  24 +-
 drivers/net/hns3/hns3_rxtx_vec.c                |  22 +-
 drivers/net/hns3/hns3_rxtx_vec_neon.h           |  28 +-
 drivers/net/hns3/hns3_rxtx_vec_sve.c            |   6 +-
 drivers/net/i40e/i40e_rxtx_vec_altivec.c        |  14 +-
 drivers/net/i40e/i40e_rxtx_vec_avx2.c           |  30 +-
 drivers/net/i40e/i40e_rxtx_vec_avx512.c         |  32 +-
 drivers/net/i40e/i40e_rxtx_vec_common.h         |   4 +-
 drivers/net/i40e/i40e_rxtx_vec_neon.c           |  16 +-
 drivers/net/i40e/i40e_rxtx_vec_sse.c            |  34 +--
 drivers/net/iavf/iavf_rxtx_vec_avx2.c           |  60 ++--
 drivers/net/iavf/iavf_rxtx_vec_avx512.c         |  60 ++--
 drivers/net/iavf/iavf_rxtx_vec_common.h         |   4 +-
 drivers/net/iavf/iavf_rxtx_vec_neon.c           |  16 +-
 drivers/net/iavf/iavf_rxtx_vec_sse.c            |  68 ++---
 drivers/net/ice/ice_rxtx_vec_avx2.c             |  30 +-
 drivers/net/ice/ice_rxtx_vec_avx512.c           |  30 +-
 drivers/net/ice/ice_rxtx_vec_common.h           |   4 +-
 drivers/net/ice/ice_rxtx_vec_sse.c              |  34 +--
 drivers/net/ionic/ionic_lif.c                   |   8 +-
 drivers/net/ionic/ionic_rxtx_sg.c               |   4 +-
 drivers/net/ionic/ionic_rxtx_simple.c           |   2 +-
 drivers/net/ixgbe/ixgbe_rxtx_vec_common.h       |   4 +-
 drivers/net/ixgbe/ixgbe_rxtx_vec_neon.c         |  12 +-
 drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c          |  42 +--
 drivers/net/mlx5/mlx5_rxq.c                     |   6 +-
 drivers/net/mlx5/mlx5_rxtx_vec.h                |  16 +-
 drivers/net/mlx5/mlx5_rxtx_vec_altivec.h        |  48 +--
 drivers/net/mlx5/mlx5_rxtx_vec_neon.h           |  42 +--
 drivers/net/mlx5/mlx5_rxtx_vec_sse.h            |  48 +--
 drivers/net/sfc/sfc_ef100_rx.c                  |  10 +-
 drivers/net/sfc/sfc_ef10_rx.c                   |  14 +-
 drivers/net/thunderx/nicvf_ethdev.c             |   4 +-
 drivers/net/thunderx/nicvf_rxtx.h               |   4 +-
 drivers/net/virtio/virtio_rxtx_packed.h         |   4 +-
 drivers/net/virtio/virtio_rxtx_packed_avx.h     |  14 +-
 drivers/net/virtio/virtio_rxtx_packed_neon.h    |  18 +-
 drivers/net/virtio/virtio_rxtx_simple.c         |   4 +-
 drivers/net/virtio/virtio_rxtx_simple.h         |   2 +-
 drivers/net/virtio/virtio_rxtx_simple_altivec.c |  16 +-
 drivers/net/virtio/virtio_rxtx_simple_neon.c    |  16 +-
 drivers/net/virtio/virtio_rxtx_simple_sse.c     |  16 +-
 examples/dma/dmafwd.c                           |   4 +-
 lib/eal/include/rte_common.h                    |   6 +
 lib/mbuf/rte_mbuf.h                             |   4 +-
 lib/mbuf/rte_mbuf_core.h                        | 375 +++++++++++++-----------
 59 files changed, 793 insertions(+), 728 deletions(-)
Signature · 1 line
1.8.3.1
#23 lore raw

PATCH v4 1/18 mbuf: deprecate GCC marker in rte mbuf struct

Provide a macro that allows conditional expansion of RTE_MARKER fields to empty to allow rte_mbuf to be used with MSVC. It is proposed that we announce the fields to be __rte_deprecated (currently disabled).

Introduce C11 anonymous unions to permit aliasing of well-known offsets by name into the rte_mbuf structure by a *new* name and to provide padding for cache alignment.

---
 doc/guides/rel_notes/deprecation.rst |  20 ++
 lib/eal/include/rte_common.h         |   6 +
 lib/mbuf/rte_mbuf_core.h             | 375 +++++++++++++++++++----------------
 3 files changed, 233 insertions(+), 168 deletions(-)
doc/guides/rel_notes/deprecation.rst +20 -0
index 10630ba..8594255 100644
@@ -17,6 +17,26 @@ Other API and ABI deprecation notices are to be posted below.
 Deprecation Notices
 -------------------
 
+* mbuf: Named zero sized fields of type ``RTE_MARKER`` and ``RTE_MARKER64``
+  will be removed from ``struct rte_mbuf`` and replaced with new fields
+  in anonymous unions.
+
+  The names of the fields impacted are:
+
+    old name                  new name
+
+  ``cacheline0``            ``mbuf_cachelin0``
+  ``rearm_data``            ``mbuf_rearm_data``
+  ``rx_descriptor_fields1`` ``mbuf_rx_descriptor_fields1``
+  ``cacheline1``            ``mbuf_cachelin1``
+
+  Contributions to DPDK should immediately start using the new names,
+  applications should adapt to new names as soon as possible as the
+  old names will be removed in a future DPDK release.
+
+  Note: types of the new names are not API compatible with the old and
+  some code conversion is required to maintain correct behavior.
+
 * build: The ``enable_kmods`` option is deprecated and will be removed in a future release.
   Setting/clearing the option has no impact on the build.
   Instead, kernel modules will be always built for OS's where out-of-tree kernel modules
lib/eal/include/rte_common.h +6 -0
index d7d6390..af73f67 100644
@@ -582,6 +582,12 @@ static void __attribute__((destructor(RTE_PRIO(prio)), used)) func(void)
 /** Marker for 8B alignment in a structure. */
 __extension__ typedef uint64_t RTE_MARKER64[0];
 
+#define __rte_marker(type, name) type name /* __rte_deprecated */
+
+#else
+
+#define __rte_marker(type, name)
+
 #endif
 
 /*********** Macros for calculating min and max **********/
lib/mbuf/rte_mbuf_core.h +207 -168

418 lines not on this page · raw message

Signature · 1 line
1.8.3.1
Acked-by on v4 1/18
#24 lore raw

Re: [PATCH v4 01/18] mbuf: deprecate GCC marker in rte mbuf struct

Some minor comments style may need adjust.

With above fixed,

Quoted 10 lines · Tyler Retzlaff

Provide a macro that allows conditional expansion of RTE_MARKER fields to empty to allow rte_mbuf to be used with MSVC. It is proposed that we announce the fields to be __rte_deprecated (currently disabled).

Introduce C11 anonymous unions to permit aliasing of well-known offsets by name into the rte_mbuf structure by a *new* name and to provide padding for cache alignment.

---

...

Quoted 36 lines
lib/mbuf/rte_mbuf_core.h +5 -26
-	/* remaining bytes are set on RX when pulling packet from descriptor */
-	RTE_MARKER rx_descriptor_fields1;
+			uint64_t ol_flags;        /**< Offload features. */
 
-	/*
-	 * The packet type, which is the combination of outer/inner L2, L3, L4
-	 * and tunnel types. The packet_type is about data really present in the
-	 * mbuf. Example: if vlan stripping is enabled, a received vlan packet
-	 * would have RTE_PTYPE_L2_ETHER and not RTE_PTYPE_L2_VLAN because the
-	 * vlan is stripped from the data.
-	 */
-	union {
-		uint32_t packet_type; /**< L2/L3/L4 and tunnel information. */
-		__extension__
-		struct {
-			uint8_t l2_type:4;   /**< (Outer) L2 type. */
-			uint8_t l3_type:4;   /**< (Outer) L3 type. */
-			uint8_t l4_type:4;   /**< (Outer) L4 type. */
-			uint8_t tun_type:4;  /**< Tunnel type. */
+			/* remaining bytes are set on RX when pulling packet from descriptor */
+			__rte_marker(RTE_MARKER, rx_descriptor_fields1);
 			union {
-				uint8_t inner_esp_next_proto;
-				/**< ESP next protocol type, valid if
-				 * RTE_PTYPE_TUNNEL_ESP tunnel type is set
-				 * on both Tx and Rx.
-				 */
+				char mbuf_rx_descriptor_fields1[8];
 				__extension__
 				struct {
-					uint8_t inner_l2_type:4;
-					/**< Inner L2 type. */
-					uint8_t inner_l3_type:4;
-					/**< Inner L3 type. */
+					/*

lib/mbuf/rte_mbuf_core.h enum { · line 549

Quoted 10 lines
lib/mbuf/rte_mbuf_core.h +10 -0
+					 * The packet type, which is the combination of outer/inner
+					 * L2, L3, L4 and tunnel types. The packet_type is about
+					 * data really present in the mbuf. Example: if vlan
+					 * stripping is enabled, a received vlan packet would have
+					 * RTE_PTYPE_L2_ETHER and not RTE_PTYPE_L2_VLAN because the
+					 * vlan is stripped from the data.
+					 */
+					union {
+						uint32_t packet_type;
+						/**< L2/L3/L4 and tunnel information. */

According dpdk doxygen guidelines [1], prefer prefix comment in above case.

[1] https://doc.dpdk.org/guides/contributing/documentation.html#doxygen-guidelines

Quoted 20 lines
lib/mbuf/rte_mbuf_core.h +20 -0
+						__extension__
+						struct {
+							uint8_t l2_type:4;
+							/**< (Outer) L2 type. */
+							uint8_t l3_type:4;
+							/**< (Outer) L3 type. */
+							uint8_t l4_type:4;
+							/**< (Outer) L4 type. */
+							uint8_t tun_type:4;
+							/**< Tunnel type. */
+							union {
+								uint8_t inner_esp_next_proto;
+								/**< ESP next protocol type, valid
+								 * if RTE_PTYPE_TUNNEL_ESP tunnel
+								 * type is set on both Tx and Rx.
+								 */
+								__extension__
+								struct {
+									uint8_t inner_l2_type:4;
+									/**< Inner L2 type. */

lib/mbuf/rte_mbuf_core.h enum { · line 579

Quoted 10 lines
lib/mbuf/rte_mbuf_core.h +10 -0
+									uint8_t inner_l3_type:4;
+									/**< Inner L3 type. */
+								};
+							};
+							uint8_t inner_l4_type:4;
+							/**< Inner L4 type. */
+						};
+					};
+					uint32_t pkt_len;
+					/**< Total pkt len: sum of all segments. */

The above should also use prefix comment type.

Quoted 6 lines
lib/mbuf/rte_mbuf_core.h +0 -3
 				};
 			};
-			uint8_t inner_l4_type:4; /**< Inner L4 type. */
-		};
-	};

...

#25 lore raw

Re: [PATCH v4 01/18] mbuf: deprecate GCC marker in rte mbuf struct

In reply to Tyler Retzlaff

15/02/2024 07:21, Tyler Retzlaff:

Quoted 79 lines

Provide a macro that allows conditional expansion of RTE_MARKER fields to empty to allow rte_mbuf to be used with MSVC. It is proposed that we announce the fields to be __rte_deprecated (currently disabled).

Introduce C11 anonymous unions to permit aliasing of well-known offsets by name into the rte_mbuf structure by a *new* name and to provide padding for cache alignment.

---
 doc/guides/rel_notes/deprecation.rst |  20 ++
 lib/eal/include/rte_common.h         |   6 +
 lib/mbuf/rte_mbuf_core.h             | 375 +++++++++++++++++++----------------
 3 files changed, 233 insertions(+), 168 deletions(-)
doc/guides/rel_notes/deprecation.rst +20 -0
index 10630ba..8594255 100644
@@ -17,6 +17,26 @@ Other API and ABI deprecation notices are to be posted below.
 Deprecation Notices
 -------------------
 
+* mbuf: Named zero sized fields of type ``RTE_MARKER`` and ``RTE_MARKER64``
+  will be removed from ``struct rte_mbuf`` and replaced with new fields
+  in anonymous unions.
+
+  The names of the fields impacted are:
+
+    old name                  new name
+
+  ``cacheline0``            ``mbuf_cachelin0``
+  ``rearm_data``            ``mbuf_rearm_data``
+  ``rx_descriptor_fields1`` ``mbuf_rx_descriptor_fields1``
+  ``cacheline1``            ``mbuf_cachelin1``
+
+  Contributions to DPDK should immediately start using the new names,
+  applications should adapt to new names as soon as possible as the
+  old names will be removed in a future DPDK release.
+
+  Note: types of the new names are not API compatible with the old and
+  some code conversion is required to maintain correct behavior.
+
 * build: The ``enable_kmods`` option is deprecated and will be removed in a future release.
   Setting/clearing the option has no impact on the build.
   Instead, kernel modules will be always built for OS's where out-of-tree kernel modules
lib/eal/include/rte_common.h +6 -0
index d7d6390..af73f67 100644
@@ -582,6 +582,12 @@ static void __attribute__((destructor(RTE_PRIO(prio)), used)) func(void)
 /** Marker for 8B alignment in a structure. */
 __extension__ typedef uint64_t RTE_MARKER64[0];
 
+#define __rte_marker(type, name) type name /* __rte_deprecated */
+
+#else
+
+#define __rte_marker(type, name)
+
 #endif
 
 /*********** Macros for calculating min and max **********/
lib/mbuf/rte_mbuf_core.h +3 -0
index 5688683..9e9590b 100644
@@ -16,7 +16,10 @@
  * New fields and flags should fit in the "dynamic space".
  */
 
+#include <assert.h>
+#include <stdalign.h>
 #include <stdint.h>
+#include <stddef.h>
 
 #include <rte_byteorder.h>
 #include <rte_stdatomic.h>

lib/mbuf/rte_mbuf_core.h enum { · line 470

Quoted 7 lines
lib/mbuf/rte_mbuf_core.h +1 -3
@@ -464,204 +467,240 @@ enum {
  * The generic rte_mbuf, containing a packet mbuf.
  */
 struct rte_mbuf {
-	RTE_MARKER cacheline0;
-
-	void *buf_addr;           /**< Virtual address of segment buffer. */
+	__rte_marker(RTE_MARKER, cacheline0);

You don't need to keep the first argument.
This would be simpler:

	__rte_marker(cacheline0);

You just need to create 2 functions: __rte_marker and __rte_marker64.

You should replace all occurrences of RTE_MARKER in DPDK in one patch, and mark RTE_MARKER as deprecated (use #pragma GCC poison)

lib/mbuf/rte_mbuf_core.h enum {

Quoted 5 lines
lib/mbuf/rte_mbuf_core.h +5 -0
+	union {
+		char mbuf_cacheline0[RTE_CACHE_LINE_MIN_SIZE];
+		__extension__
+		struct {
+			void *buf_addr;           /**< Virtual address of segment buffer. 

I think it is ugly.

Changing mbuf API is a serious issue.

#26 lore raw

RE: [PATCH v4 01/18] mbuf: deprecate GCC marker in rte mbuf struct

Quoted 106 lines

From: Thomas Monjalon [mailto:[email protected]]
Sent: Sunday, 18 February 2024 13.40

15/02/2024 07:21, Tyler Retzlaff:

Quoted 1 line

Provide a macro that allows conditional expansion of RTE_MARKER

fields

Quoted 7 lines

to empty to allow rte_mbuf to be used with MSVC. It is proposed that we announce the fields to be __rte_deprecated (currently disabled).

Introduce C11 anonymous unions to permit aliasing of well-known offsets by name into the rte_mbuf structure by a *new* name and to provide padding for cache alignment.

Quoted 5 lines
---
 doc/guides/rel_notes/deprecation.rst |  20 ++
 lib/eal/include/rte_common.h         |   6 +
 lib/mbuf/rte_mbuf_core.h             | 375 +++++++++++++++++++------

----------

Review

Quoted 3 lines
 3 files changed, 233 insertions(+), 168 deletions(-)
(quoted diff) +0 -0

b/doc/guides/rel_notes/deprecation.rst

doc/guides/rel_notes/deprecation.rst Other API and ABI deprecation notices are to be

Quoted 4 lines

index 10630ba..8594255 100644

doc/guides/rel_notes/deprecation.rst +0 -0
@@ -17,6 +17,26 @@ Other API and ABI deprecation notices are to be

posted below.

doc/guides/rel_notes/deprecation.rst Other API and ABI deprecation notices are to be posted below.

Quoted 4 lines
doc/guides/rel_notes/deprecation.rst +1 -0
 Deprecation Notices
 -------------------
 
+* mbuf: Named zero sized fields of type ``RTE_MARKER`` and

``RTE_MARKER64``

doc/guides/rel_notes/deprecation.rst Other API and ABI deprecation notices are to be · line 21

Quoted 1 line
doc/guides/rel_notes/deprecation.rst +1 -0
+  will be removed from ``struct rte_mbuf`` and replaced with new

fields

doc/guides/rel_notes/deprecation.rst Other API and ABI deprecation notices are to be posted below.

Quoted 12 lines
doc/guides/rel_notes/deprecation.rst +12 -0
+  in anonymous unions.
+
+  The names of the fields impacted are:
+
+    old name                  new name
+
+  ``cacheline0``            ``mbuf_cachelin0``
+  ``rearm_data``            ``mbuf_rearm_data``
+  ``rx_descriptor_fields1`` ``mbuf_rx_descriptor_fields1``
+  ``cacheline1``            ``mbuf_cachelin1``
+
+  Contributions to DPDK should immediately start using the new

names,

doc/guides/rel_notes/deprecation.rst Other API and ABI deprecation notices are to be posted below.

Quoted 4 lines
doc/guides/rel_notes/deprecation.rst +4 -0
+  applications should adapt to new names as soon as possible as the
+  old names will be removed in a future DPDK release.
+
+  Note: types of the new names are not API compatible with the old

and

doc/guides/rel_notes/deprecation.rst Other API and ABI deprecation notices are to be posted below.

Quoted 3 lines
doc/guides/rel_notes/deprecation.rst +2 -0
+  some code conversion is required to maintain correct behavior.
+
 * build: The ``enable_kmods`` option is deprecated and will be

removed in a future release.

doc/guides/rel_notes/deprecation.rst Other API and ABI deprecation notices are to be · line 42

Quoted 2 lines
doc/guides/rel_notes/deprecation.rst +0 -0
   Setting/clearing the option has no impact on the build.
   Instead, kernel modules will be always built for OS's where out-

of-tree kernel modules

Review

Quoted 1 line
(quoted diff) +0 -0

b/lib/eal/include/rte_common.h

lib/eal/include/rte_common.h static void

Quoted 4 lines

index d7d6390..af73f67 100644

lib/eal/include/rte_common.h +0 -0
@@ -582,6 +582,12 @@ static void

__attribute__((destructor(RTE_PRIO(prio)), used)) func(void)

Quoted 28 lines
lib/eal/include/rte_common.h +6 -0
 /** Marker for 8B alignment in a structure. */
 __extension__ typedef uint64_t RTE_MARKER64[0];
 
+#define __rte_marker(type, name) type name /* __rte_deprecated */
+
+#else
+
+#define __rte_marker(type, name)
+
 #endif
 
 /*********** Macros for calculating min and max **********/
lib/mbuf/rte_mbuf_core.h +3 -0
index 5688683..9e9590b 100644
@@ -16,7 +16,10 @@
  * New fields and flags should fit in the "dynamic space".
  */
 
+#include <assert.h>
+#include <stdalign.h>
 #include <stdint.h>
+#include <stddef.h>
 
 #include <rte_byteorder.h>
 #include <rte_stdatomic.h>

lib/mbuf/rte_mbuf_core.h enum { · line 469

Quoted 6 lines
lib/mbuf/rte_mbuf_core.h +0 -3
@@ -464,204 +467,240 @@ enum {
  * The generic rte_mbuf, containing a packet mbuf.
  */
 struct rte_mbuf {
-	RTE_MARKER cacheline0;
-
-	void *buf_addr;           /**< Virtual address of segment buffer.

*/

lib/mbuf/rte_mbuf_core.h enum { · line 470

Quoted 1 line
lib/mbuf/rte_mbuf_core.h +1 -0
+	__rte_marker(RTE_MARKER, cacheline0);

You don't need to keep the first argument.
This would be simpler:

Quoted 5 lines
	__rte_marker(cacheline0);

You just need to create 2 functions: __rte_marker and __rte_marker64.

You should replace all occurrences of RTE_MARKER in DPDK in one patch, and mark RTE_MARKER as deprecated (use #pragma GCC poison)

I like this suggestion.
However, some applications might use RTE_MARKER in their own structures. Wouldn't it be considered API breakage to mark RTE_MARKER as deprecated?

Quoted 11 lines

lib/mbuf/rte_mbuf_core.h enum {

Quoted 6 lines
lib/mbuf/rte_mbuf_core.h +5 -0
+	union {
+		char mbuf_cacheline0[RTE_CACHE_LINE_MIN_SIZE];
+		__extension__
+		struct {
+			void *buf_addr;           /**< Virtual address of

segment buffer.

I think it is ugly.

Changing mbuf API is a serious issue.

#27 lore raw

Re: [PATCH v4 01/18] mbuf: deprecate GCC marker in rte mbuf struct

18/02/2024 14:07, Morten Brørup:

Quoted 48 lines

From: Thomas Monjalon [mailto:[email protected]]

Quoted 47 lines

15/02/2024 07:21, Tyler Retzlaff:

lib/eal/include/rte_common.h static void

Quoted 3 lines
lib/eal/include/rte_common.h +0 -0
@@ -582,6 +582,12 @@ static void

__attribute__((destructor(RTE_PRIO(prio)), used)) func(void)

Quoted 28 lines
lib/eal/include/rte_common.h +6 -0
 /** Marker for 8B alignment in a structure. */
 __extension__ typedef uint64_t RTE_MARKER64[0];
 
+#define __rte_marker(type, name) type name /* __rte_deprecated */
+
+#else
+
+#define __rte_marker(type, name)
+
 #endif
 
 /*********** Macros for calculating min and max **********/
lib/mbuf/rte_mbuf_core.h +3 -0
index 5688683..9e9590b 100644
@@ -16,7 +16,10 @@
  * New fields and flags should fit in the "dynamic space".
  */
 
+#include <assert.h>
+#include <stdalign.h>
 #include <stdint.h>
+#include <stddef.h>
 
 #include <rte_byteorder.h>
 #include <rte_stdatomic.h>

lib/mbuf/rte_mbuf_core.h enum { · line 469

Quoted 6 lines
lib/mbuf/rte_mbuf_core.h +0 -3
@@ -464,204 +467,240 @@ enum {
  * The generic rte_mbuf, containing a packet mbuf.
  */
 struct rte_mbuf {
-	RTE_MARKER cacheline0;
-
-	void *buf_addr;           /**< Virtual address of segment buffer.

*/

lib/mbuf/rte_mbuf_core.h enum { · line 470

Quoted 1 line
lib/mbuf/rte_mbuf_core.h +1 -0
+	__rte_marker(RTE_MARKER, cacheline0);

You don't need to keep the first argument.
This would be simpler:

	__rte_marker(cacheline0);

You just need to create 2 functions: __rte_marker and __rte_marker64.

Quoted 6 lines
Quoted 2 lines

You should replace all occurrences of RTE_MARKER in DPDK in one patch, and mark RTE_MARKER as deprecated (use #pragma GCC poison)

I like this suggestion.
However, some applications might use RTE_MARKER in their own structures. Wouldn't it be considered API breakage to mark RTE_MARKER as deprecated?

Yes it is an API breakage.
Do we prefer waiting 24.11 for poisoning this macro?

#28 lore raw

RE: [PATCH v4 01/18] mbuf: deprecate GCC marker in rte mbuf struct

Quoted 59 lines

From: Thomas Monjalon [mailto:[email protected]]
Sent: Sunday, 18 February 2024 16.22

18/02/2024 14:07, Morten Brørup:

Quoted 10 lines

From: Thomas Monjalon [mailto:[email protected]]

Quoted 9 lines

15/02/2024 07:21, Tyler Retzlaff:

lib/eal/include/rte_common.h static void

Quoted 3 lines
lib/eal/include/rte_common.h +0 -0
@@ -582,6 +582,12 @@ static void

__attribute__((destructor(RTE_PRIO(prio)), used)) func(void)

Quoted 4 lines
lib/eal/include/rte_common.h +1 -0
 /** Marker for 8B alignment in a structure. */
 __extension__ typedef uint64_t RTE_MARKER64[0];
 
+#define __rte_marker(type, name) type name /* __rte_deprecated

*/

Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
lib/eal/include/rte_common.h +5 -0
+
+#else
+
+#define __rte_marker(type, name)
+
 #endif
 
 /*********** Macros for calculating min and max **********/
lib/mbuf/rte_mbuf_core.h +3 -0
index 5688683..9e9590b 100644
@@ -16,7 +16,10 @@
  * New fields and flags should fit in the "dynamic space".
  */
 
+#include <assert.h>
+#include <stdalign.h>
 #include <stdint.h>
+#include <stddef.h>
 
Quoted 9 lines
Quoted 9 lines

lib/mbuf/rte_mbuf_core.h enum { · line 469

Quoted 9 lines
lib/mbuf/rte_mbuf_core.h +0 -3
 #include <rte_byteorder.h>
 #include <rte_stdatomic.h>
@@ -464,204 +467,240 @@ enum {
  * The generic rte_mbuf, containing a packet mbuf.
  */
 struct rte_mbuf {
-	RTE_MARKER cacheline0;
-
-	void *buf_addr;           /**< Virtual address of segment

buffer.

Quoted 7 lines
Quoted 7 lines

*/

lib/mbuf/rte_mbuf_core.h enum { · line 470

Quoted 1 line
lib/mbuf/rte_mbuf_core.h +1 -0
+	__rte_marker(RTE_MARKER, cacheline0);

You don't need to keep the first argument.
This would be simpler:

	__rte_marker(cacheline0);

You just need to create 2 functions: __rte_marker and

__rte_marker64.

Quoted 2 lines
Quoted 2 lines

You should replace all occurrences of RTE_MARKER in DPDK in one

patch,

Quoted 2 lines
Quoted 1 line

and mark RTE_MARKER as deprecated (use #pragma GCC poison)

Quoted 8 lines
Quoted 2 lines

I like this suggestion.
However, some applications might use RTE_MARKER in their own

structures.

Quoted 1 line

Wouldn't it be considered API breakage to mark RTE_MARKER as

deprecated?

Yes it is an API breakage.
Do we prefer waiting 24.11 for poisoning this macro?

Personally, I generally don't mind API breakages, assuming that they are visible and thus don't silently introduce bugs. The distro people might have a different opinion.

#29 lore raw

Re: [PATCH v4 01/18] mbuf: deprecate GCC marker in rte mbuf struct

In reply to Thomas Monjalon
Quoted 52 lines · Thomas Monjalon

18/02/2024 14:07, Morten Brørup:

Quoted 51 lines

From: Thomas Monjalon [mailto:[email protected]]

Quoted 49 lines

15/02/2024 07:21, Tyler Retzlaff:

lib/eal/include/rte_common.h static void

Quoted 3 lines
lib/eal/include/rte_common.h +0 -0
@@ -582,6 +582,12 @@ static void

__attribute__((destructor(RTE_PRIO(prio)), used)) func(void)

Quoted 28 lines
lib/eal/include/rte_common.h +6 -0
 /** Marker for 8B alignment in a structure. */
 __extension__ typedef uint64_t RTE_MARKER64[0];
 
+#define __rte_marker(type, name) type name /* __rte_deprecated */
+
+#else
+
+#define __rte_marker(type, name)
+
 #endif
 
 /*********** Macros for calculating min and max **********/
lib/mbuf/rte_mbuf_core.h +3 -0
index 5688683..9e9590b 100644
@@ -16,7 +16,10 @@
  * New fields and flags should fit in the "dynamic space".
  */
 
+#include <assert.h>
+#include <stdalign.h>
 #include <stdint.h>
+#include <stddef.h>
 
 #include <rte_byteorder.h>
 #include <rte_stdatomic.h>

lib/mbuf/rte_mbuf_core.h enum { · line 469

Quoted 6 lines
lib/mbuf/rte_mbuf_core.h +0 -3
@@ -464,204 +467,240 @@ enum {
  * The generic rte_mbuf, containing a packet mbuf.
  */
 struct rte_mbuf {
-	RTE_MARKER cacheline0;
-
-	void *buf_addr;           /**< Virtual address of segment buffer.

*/

lib/mbuf/rte_mbuf_core.h enum { · line 470

Quoted 1 line
lib/mbuf/rte_mbuf_core.h +1 -0
+	__rte_marker(RTE_MARKER, cacheline0);

You don't need to keep the first argument.
This would be simpler:

	__rte_marker(cacheline0);

You just need to create 2 functions: __rte_marker and __rte_marker64.

You should replace all occurrences of RTE_MARKER in DPDK in one patch, and mark RTE_MARKER as deprecated (use #pragma GCC poison)

Quoted 6 lines
Quoted 3 lines

I like this suggestion.
However, some applications might use RTE_MARKER in their own structures. Wouldn't it be considered API breakage to mark RTE_MARKER as deprecated?

Yes it is an API breakage.
Do we prefer waiting 24.11 for poisoning this macro?

i only intend to announce deprecation now, actual poisoning given mbuf is involved probably should be no earlier than 24.11 and possibly even longer. though in my experience adaptation never really happens until it is forced.

Quoted 1 line
#30 lore raw

Re: [PATCH v4 01/18] mbuf: deprecate GCC marker in rte mbuf struct

In reply to Thomas Monjalon
Quoted 90 lines · Thomas Monjalon

15/02/2024 07:21, Tyler Retzlaff:

Quoted 79 lines

Provide a macro that allows conditional expansion of RTE_MARKER fields to empty to allow rte_mbuf to be used with MSVC. It is proposed that we announce the fields to be __rte_deprecated (currently disabled).

Introduce C11 anonymous unions to permit aliasing of well-known offsets by name into the rte_mbuf structure by a *new* name and to provide padding for cache alignment.

---
 doc/guides/rel_notes/deprecation.rst |  20 ++
 lib/eal/include/rte_common.h         |   6 +
 lib/mbuf/rte_mbuf_core.h             | 375 +++++++++++++++++++----------------
 3 files changed, 233 insertions(+), 168 deletions(-)
doc/guides/rel_notes/deprecation.rst +20 -0
index 10630ba..8594255 100644
@@ -17,6 +17,26 @@ Other API and ABI deprecation notices are to be posted below.
 Deprecation Notices
 -------------------
 
+* mbuf: Named zero sized fields of type ``RTE_MARKER`` and ``RTE_MARKER64``
+  will be removed from ``struct rte_mbuf`` and replaced with new fields
+  in anonymous unions.
+
+  The names of the fields impacted are:
+
+    old name                  new name
+
+  ``cacheline0``            ``mbuf_cachelin0``
+  ``rearm_data``            ``mbuf_rearm_data``
+  ``rx_descriptor_fields1`` ``mbuf_rx_descriptor_fields1``
+  ``cacheline1``            ``mbuf_cachelin1``
+
+  Contributions to DPDK should immediately start using the new names,
+  applications should adapt to new names as soon as possible as the
+  old names will be removed in a future DPDK release.
+
+  Note: types of the new names are not API compatible with the old and
+  some code conversion is required to maintain correct behavior.
+
 * build: The ``enable_kmods`` option is deprecated and will be removed in a future release.
   Setting/clearing the option has no impact on the build.
   Instead, kernel modules will be always built for OS's where out-of-tree kernel modules
lib/eal/include/rte_common.h +6 -0
index d7d6390..af73f67 100644
@@ -582,6 +582,12 @@ static void __attribute__((destructor(RTE_PRIO(prio)), used)) func(void)
 /** Marker for 8B alignment in a structure. */
 __extension__ typedef uint64_t RTE_MARKER64[0];
 
+#define __rte_marker(type, name) type name /* __rte_deprecated */
+
+#else
+
+#define __rte_marker(type, name)
+
 #endif
 
 /*********** Macros for calculating min and max **********/
lib/mbuf/rte_mbuf_core.h +3 -0
index 5688683..9e9590b 100644
@@ -16,7 +16,10 @@
  * New fields and flags should fit in the "dynamic space".
  */
 
+#include <assert.h>
+#include <stdalign.h>
 #include <stdint.h>
+#include <stddef.h>
 
 #include <rte_byteorder.h>
 #include <rte_stdatomic.h>

lib/mbuf/rte_mbuf_core.h enum { · line 470

Quoted 7 lines
lib/mbuf/rte_mbuf_core.h +1 -3
@@ -464,204 +467,240 @@ enum {
  * The generic rte_mbuf, containing a packet mbuf.
  */
 struct rte_mbuf {
-	RTE_MARKER cacheline0;
-
-	void *buf_addr;           /**< Virtual address of segment buffer. */
+	__rte_marker(RTE_MARKER, cacheline0);

You don't need to keep the first argument.
This would be simpler:

Quoted 2 lines
	__rte_marker(cacheline0);

You just need to create 2 functions: __rte_marker and __rte_marker64.

no objection, i'll add 2 macros and drop the first argument.

Quoted 3 lines

You should replace all occurrences of RTE_MARKER in DPDK in one patch, and mark RTE_MARKER as deprecated (use #pragma GCC poison)

will update to use pragma instead of __rte_deprecated

Quoted 10 lines

lib/mbuf/rte_mbuf_core.h enum {

Quoted 6 lines
lib/mbuf/rte_mbuf_core.h +5 -0
+	union {
+		char mbuf_cacheline0[RTE_CACHE_LINE_MIN_SIZE];
+		__extension__
+		struct {
+			void *buf_addr;           /**< Virtual address of segment buffer. 

I think it is ugly.

Changing mbuf API is a serious issue.

agreed, do you have an alternate proposal to solve problem?

Quoted 1 line
#31 lore raw

Re: [PATCH v4 01/18] mbuf: deprecate GCC marker in rte mbuf struct

20/02/2024 18:20, Tyler Retzlaff:

Quoted 9 lines · Thomas Monjalon
Quoted 8 lines

15/02/2024 07:21, Tyler Retzlaff:

Quoted 7 lines

Provide a macro that allows conditional expansion of RTE_MARKER fields to empty to allow rte_mbuf to be used with MSVC. It is proposed that we announce the fields to be __rte_deprecated (currently disabled).

Introduce C11 anonymous unions to permit aliasing of well-known offsets by name into the rte_mbuf structure by a *new* name and to provide padding for cache alignment.

[...]

Quoted 13 lines
Quoted 13 lines

lib/mbuf/rte_mbuf_core.h enum {

Quoted 10 lines

struct rte_mbuf {

lib/mbuf/rte_mbuf_core.h +6 -3
-	RTE_MARKER cacheline0;
-
-	void *buf_addr;           /**< Virtual address of segment buffer. */
+	__rte_marker(RTE_MARKER, cacheline0);
+	union {
+		char mbuf_cacheline0[RTE_CACHE_LINE_MIN_SIZE];
+		__extension__
+		struct {
+			void *buf_addr;           /**< Virtual address of segment buffer. 

I think it is ugly.

Quoted 3 lines
Quoted 1 line

Changing mbuf API is a serious issue.

agreed, do you have an alternate proposal to solve problem?

The best would be that MSVC supports a kind of struct marker.

#32 lore raw

Re: [PATCH v4 01/18] mbuf: deprecate GCC marker in rte mbuf struct

20/02/2024 18:53, Thomas Monjalon:

Quoted 24 lines

20/02/2024 18:20, Tyler Retzlaff:

Quoted 9 lines · Thomas Monjalon
Quoted 8 lines

15/02/2024 07:21, Tyler Retzlaff:

Quoted 7 lines

Provide a macro that allows conditional expansion of RTE_MARKER fields to empty to allow rte_mbuf to be used with MSVC. It is proposed that we announce the fields to be __rte_deprecated (currently disabled).

Introduce C11 anonymous unions to permit aliasing of well-known offsets by name into the rte_mbuf structure by a *new* name and to provide padding for cache alignment.

[...]

Quoted 13 lines
Quoted 13 lines

lib/mbuf/rte_mbuf_core.h enum {

Quoted 10 lines

struct rte_mbuf {

lib/mbuf/rte_mbuf_core.h +6 -3
-	RTE_MARKER cacheline0;
-
-	void *buf_addr;           /**< Virtual address of segment buffer. */
+	__rte_marker(RTE_MARKER, cacheline0);
+	union {
+		char mbuf_cacheline0[RTE_CACHE_LINE_MIN_SIZE];
+		__extension__
+		struct {
+			void *buf_addr;           /**< Virtual address of segment buffer. 

I think it is ugly.

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

Changing mbuf API is a serious issue.

agreed, do you have an alternate proposal to solve problem?

The best would be that MSVC supports a kind of struct marker.

After more thoughts, it's OK to break API for mbuf markers.
There are 2 kind of markers in mbuf:
1/ cacheline markers used only in rte_mbuf_prefetch_part functions 2/ rearm_data and rx_descriptor_fields1 which are offsets used by drivers
The cacheline markers can be removed and offset calculated in prefetch functions. The second type of markers are intended to be used by drivers only, so there is not API compatibility concern.
Instead of complicated unions, I propose to replace them with inline functions which return the offset in the same type as the markers.

As RTE_MARKER macros rely on a non-standard C feature,
I propose to mark them as non-recommended,
and stop using them in DPDK code.
We can keep them for compatibility and drop them when compiling with MSVC.

Some markers are used in crypto structures for cachelines, we can probably drop them easily, they look unused.

The last thing to handle is cacheline padding. It can be done on the first field of the next cacheline, instead of using a zero-sized marker for padding.

Problem solved? Let's get rid of these markers?

#33 lore raw

Re: [PATCH v4 01/18] mbuf: deprecate GCC marker in rte mbuf struct

Quoted 46 lines · Thomas Monjalon

20/02/2024 18:53, Thomas Monjalon:

Quoted 24 lines

20/02/2024 18:20, Tyler Retzlaff:

Quoted 9 lines · Thomas Monjalon
Quoted 8 lines

15/02/2024 07:21, Tyler Retzlaff:

Quoted 7 lines

Provide a macro that allows conditional expansion of RTE_MARKER fields to empty to allow rte_mbuf to be used with MSVC. It is proposed that we announce the fields to be __rte_deprecated (currently disabled).

Introduce C11 anonymous unions to permit aliasing of well-known offsets by name into the rte_mbuf structure by a *new* name and to provide padding for cache alignment.

[...]

Quoted 13 lines
Quoted 13 lines

lib/mbuf/rte_mbuf_core.h enum {

Quoted 10 lines

struct rte_mbuf {

lib/mbuf/rte_mbuf_core.h +6 -3
-	RTE_MARKER cacheline0;
-
-	void *buf_addr;           /**< Virtual address of segment buffer. */
+	__rte_marker(RTE_MARKER, cacheline0);
+	union {
+		char mbuf_cacheline0[RTE_CACHE_LINE_MIN_SIZE];
+		__extension__
+		struct {
+			void *buf_addr;           /**< Virtual address of segment buffer. 

I think it is ugly.

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

Changing mbuf API is a serious issue.

agreed, do you have an alternate proposal to solve problem?

The best would be that MSVC supports a kind of struct marker.

After more thoughts, it's OK to break API for mbuf markers.
There are 2 kind of markers in mbuf:
1/ cacheline markers used only in rte_mbuf_prefetch_part functions 2/ rearm_data and rx_descriptor_fields1 which are offsets used by drivers
The cacheline markers can be removed and offset calculated in prefetch functions. The second type of markers are intended to be used by drivers only, so there is not API compatibility concern.
Instead of complicated unions, I propose to replace them with inline functions which return the offset in the same type as the markers.

As RTE_MARKER macros rely on a non-standard C feature,
I propose to mark them as non-recommended,
and stop using them in DPDK code.
We can keep them for compatibility and drop them when compiling with MSVC.

Quoted 8 lines

Some markers are used in crypto structures for cachelines, we can probably drop them easily, they look unused.

The last thing to handle is cacheline padding. It can be done on the first field of the next cacheline, instead of using a zero-sized marker for padding.

Problem solved? Let's get rid of these markers?

certainly simplifies things, i don't object i'll submit a new revision with the suggestions outlined above.

thanks Thomas

Quoted 1 line
#34 lore raw

PATCH v4 2/18 mbuf: stop using zero sized marker fields

In reply to Tyler Retzlaff

Update to reference newly named anonymous union markers supported by standard C and stop referencing zero sized compiler extension markers.

---
 lib/mbuf/rte_mbuf.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
lib/mbuf/rte_mbuf.h +2 -2
index 286b32b..963f713 100644
@@ -108,7 +108,7 @@
 static inline void
 rte_mbuf_prefetch_part1(struct rte_mbuf *m)
 {
-	rte_prefetch0(&m->cacheline0);
+	rte_prefetch0(&m->mbuf_cacheline0);
 }
 
 /**
@@ -126,7 +126,7 @@
 rte_mbuf_prefetch_part2(struct rte_mbuf *m)
 {
 #if RTE_CACHE_LINE_SIZE == 64
-	rte_prefetch0(&m->cacheline1);
+	rte_prefetch0(&m->mbuf_cacheline1);
 #else
 	RTE_SET_USED(m);
 #endif
Signature · 1 line
1.8.3.1
Acked-by on v4 2/18
#35 lore raw

Re: [PATCH v4 02/18] mbuf: stop using zero sized marker fields

Quoted 31 lines · Tyler Retzlaff

Update to reference newly named anonymous union markers supported by standard C and stop referencing zero sized compiler extension markers.

---
 lib/mbuf/rte_mbuf.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
lib/mbuf/rte_mbuf.h +2 -2
index 286b32b..963f713 100644
@@ -108,7 +108,7 @@
 static inline void
 rte_mbuf_prefetch_part1(struct rte_mbuf *m)
 {
-	rte_prefetch0(&m->cacheline0);
+	rte_prefetch0(&m->mbuf_cacheline0);
 }
 
 /**
@@ -126,7 +126,7 @@
 rte_mbuf_prefetch_part2(struct rte_mbuf *m)
 {
 #if RTE_CACHE_LINE_SIZE == 64
-	rte_prefetch0(&m->cacheline1);
+	rte_prefetch0(&m->mbuf_cacheline1);
 #else
 	RTE_SET_USED(m);
 #endif
#36 lore raw

PATCH v4 3/18 net/i40e: stop using zero sized marker fields

In reply to Tyler Retzlaff

Update to reference newly named anonymous union markers supported by standard C and stop referencing zero sized compiler extension markers.

---
 drivers/net/i40e/i40e_rxtx_vec_altivec.c | 14 ++++++-------
 drivers/net/i40e/i40e_rxtx_vec_avx2.c    | 30 ++++++++++++++--------------
 drivers/net/i40e/i40e_rxtx_vec_avx512.c  | 32 +++++++++++++++---------------
 drivers/net/i40e/i40e_rxtx_vec_common.h  |  4 ++--
 drivers/net/i40e/i40e_rxtx_vec_neon.c    | 16 +++++++--------
 drivers/net/i40e/i40e_rxtx_vec_sse.c     | 34 ++++++++++++++++----------------
 6 files changed, 65 insertions(+), 65 deletions(-)
drivers/net/i40e/i40e_rxtx_vec_altivec.c +7 -7
index b6b0d38..0941335 100644
@@ -64,11 +64,11 @@
 		  * Data to be rearmed is 6 bytes long.
 		  * Though, RX will overwrite ol_flags that are coming next
 		  * anyway. So overwrite whole 8 bytes with one load:
-		  * 6 bytes of rearm_data plus first 2 bytes of ol_flags.
+		  * 6 bytes of mbuf_rearm_data plus first 2 bytes of ol_flags.
 		  */
-		p0 = (uintptr_t)&mb0->rearm_data;
+		p0 = (uintptr_t)&mb0->mbuf_rearm_data;
 		*(uint64_t *)p0 = rxq->mbuf_initializer;
-		p1 = (uintptr_t)&mb1->rearm_data;
+		p1 = (uintptr_t)&mb1->mbuf_rearm_data;
 		*(uint64_t *)p1 = rxq->mbuf_initializer;
 
 		/* load buf_addr(lo 64bit) and buf_iova(hi 64bit) */
@@ -371,11 +371,11 @@
 		/* D.3 copy final 3,4 data to rx_pkts */
 		vec_st(pkt_mb4, 0,
 		 (__vector unsigned char *)&rx_pkts[pos + 3]
-			->rx_descriptor_fields1
+			->mbuf_rx_descriptor_fields1
 		);
 		vec_st(pkt_mb3, 0,
 		 (__vector unsigned char *)&rx_pkts[pos + 2]
-			->rx_descriptor_fields1
+			->mbuf_rx_descriptor_fields1
 		);
 
 		/* D.2 pkt 1,2 set in_port/nb_seg and remove crc */
@@ -423,10 +423,10 @@
 		/* D.3 copy final 1,2 data to rx_pkts */
 		vec_st(pkt_mb2, 0,
 		 (__vector unsigned char *)&rx_pkts[pos + 1]
-			->rx_descriptor_fields1
+			->mbuf_rx_descriptor_fields1
 		);
 		vec_st(pkt_mb1, 0,
-		 (__vector unsigned char *)&rx_pkts[pos]->rx_descriptor_fields1
+		 (__vector unsigned char *)&rx_pkts[pos]->mbuf_rx_descriptor_fields1
 		);
 		desc_to_ptype_v(descs, &rx_pkts[pos], ptype_tbl);
 		desc_to_olflags_v(descs, &rx_pkts[pos]);
drivers/net/i40e/i40e_rxtx_vec_avx2.c +15 -15
index f468c1f..bf2570c 100644
@@ -186,13 +186,13 @@
 	 * calls above.
 	 */
 	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, pkt_len) !=
-			offsetof(struct rte_mbuf, rx_descriptor_fields1) + 4);
+			offsetof(struct rte_mbuf, mbuf_rx_descriptor_fields1) + 4);
 	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, data_len) !=
-			offsetof(struct rte_mbuf, rx_descriptor_fields1) + 8);
+			offsetof(struct rte_mbuf, mbuf_rx_descriptor_fields1) + 8);
 	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, vlan_tci) !=
-			offsetof(struct rte_mbuf, rx_descriptor_fields1) + 10);
+			offsetof(struct rte_mbuf, mbuf_rx_descriptor_fields1) + 10);
 	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, hash) !=
-			offsetof(struct rte_mbuf, rx_descriptor_fields1) + 12);
+			offsetof(struct rte_mbuf, mbuf_rx_descriptor_fields1) + 12);
 
 	/* Status/Error flag masks */
 	/*
@@ -527,9 +527,9 @@
 		 */
 		/* check the structure matches expectations */
 		RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, ol_flags) !=
-				offsetof(struct rte_mbuf, rearm_data) + 8);
-		RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, rearm_data) !=
-				RTE_ALIGN(offsetof(struct rte_mbuf, rearm_data), 16));
+				offsetof(struct rte_mbuf, mbuf_rearm_data) + 8);
+		RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, mbuf_rearm_data) !=
+				RTE_ALIGN(offsetof(struct rte_mbuf, mbuf_rearm_data), 16));
 		/* build up data and do writes */
 		__m256i rearm0, rearm1, rearm2, rearm3, rearm4, rearm5,
 				rearm6, rearm7;
@@ -543,10 +543,10 @@
 		rearm2 = _mm256_permute2f128_si256(rearm2, mb2_3, 0x20);
 		rearm0 = _mm256_permute2f128_si256(rearm0, mb0_1, 0x20);
 		/* write to mbuf */
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 6]->rearm_data, rearm6);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 4]->rearm_data, rearm4);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 2]->rearm_data, rearm2);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 0]->rearm_data, rearm0);
+		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 6]->mbuf_rearm_data, rearm6);
+		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 4]->mbuf_rearm_data, rearm4);
+		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 2]->mbuf_rearm_data, rearm2);
+		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 0]->mbuf_rearm_data, rearm0);
 
 		/* repeat for the odd mbufs */
 		const __m256i odd_flags = _mm256_castsi128_si256(
@@ -561,10 +561,10 @@
 		rearm3 = _mm256_blend_epi32(rearm3, mb2_3, 0xF0);
 		rearm1 = _mm256_blend_epi32(rearm1, mb0_1, 0xF0);
 		/* again write to mbufs */
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 7]->rearm_data, rearm7);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 5]->rearm_data, rearm5);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 3]->rearm_data, rearm3);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 1]->rearm_data, rearm1);
+		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 7]->mbuf_rearm_data, rearm7);
+		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 5]->mbuf_rearm_data, rearm5);
+		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 3]->mbuf_rearm_data, rearm3);
+		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 1]->mbuf_rearm_data, rearm1);
 
 		/* extract and record EOP bit */
 		if (split_packet) {
drivers/net/i40e/i40e_rxtx_vec_avx512.c +16 -16
index f3050cd..d521281 100644
@@ -175,13 +175,13 @@
 	 * calls above.
 	 */
 	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, pkt_len) !=
-			offsetof(struct rte_mbuf, rx_descriptor_fields1) + 4);
+			offsetof(struct rte_mbuf, mbuf_rx_descriptor_fields1) + 4);
 	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, data_len) !=
-			offsetof(struct rte_mbuf, rx_descriptor_fields1) + 8);
+			offsetof(struct rte_mbuf, mbuf_rx_descriptor_fields1) + 8);
 	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, vlan_tci) !=
-			offsetof(struct rte_mbuf, rx_descriptor_fields1) + 10);
+			offsetof(struct rte_mbuf, mbuf_rx_descriptor_fields1) + 10);
 	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, hash) !=
-			offsetof(struct rte_mbuf, rx_descriptor_fields1) + 12);
+			offsetof(struct rte_mbuf, mbuf_rx_descriptor_fields1) + 12);
 
 	/* Status/Error flag masks */
 	/* mask everything except RSS, flow director and VLAN flags
@@ -559,9 +559,9 @@
 		 */
 		/* check the structure matches expectations */
 		RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, ol_flags) !=
-				offsetof(struct rte_mbuf, rearm_data) + 8);
-		RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, rearm_data) !=
-				RTE_ALIGN(offsetof(struct rte_mbuf, rearm_data), 16));
+				offsetof(struct rte_mbuf, mbuf_rearm_data) + 8);
+		RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, mbuf_rearm_data) !=
+				RTE_ALIGN(offsetof(struct rte_mbuf, mbuf_rearm_data), 16));
 		/* build up data and do writes */
 		__m256i rearm0, rearm1, rearm2, rearm3, rearm4, rearm5,
 				rearm6, rearm7;
@@ -580,13 +580,13 @@
 		rearm0 = _mm256_permute2f128_si256(rearm0, mb0_1, 0x20);
 		/* write to mbuf */
 		_mm256_storeu_si256
-			((__m256i *)&rx_pkts[i + 6]->rearm_data, rearm6);
+			((__m256i *)&rx_pkts[i + 6]->mbuf_rearm_data, rearm6);
 		_mm256_storeu_si256
-			((__m256i *)&rx_pkts[i + 4]->rearm_data, rearm4);
+			((__m256i *)&rx_pkts[i + 4]->mbuf_rearm_data, rearm4);
 		_mm256_storeu_si256
-			((__m256i *)&rx_pkts[i + 2]->rearm_data, rearm2);
+			((__m256i *)&rx_pkts[i + 2]->mbuf_rearm_data, rearm2);
 		_mm256_storeu_si256
-			((__m256i *)&rx_pkts[i + 0]->rearm_data, rearm0);
+			((__m256i *)&rx_pkts[i + 0]->mbuf_rearm_data, rearm0);
 
 		/* repeat for the odd mbufs */
 		const __m256i odd_flags = _mm256_castsi128_si256
@@ -606,13 +606,13 @@
 		rearm1 = _mm256_blend_epi32(rearm1, mb0_1, 0xF0);
 		/* again write to mbufs */
 		_mm256_storeu_si256
-			((__m256i *)&rx_pkts[i + 7]->rearm_data, rearm7);
+			((__m256i *)&rx_pkts[i + 7]->mbuf_rearm_data, rearm7);
 		_mm256_storeu_si256
-			((__m256i *)&rx_pkts[i + 5]->rearm_data, rearm5);
+			((__m256i *)&rx_pkts[i + 5]->mbuf_rearm_data, rearm5);
 		_mm256_storeu_si256
-			((__m256i *)&rx_pkts[i + 3]->rearm_data, rearm3);
+			((__m256i *)&rx_pkts[i + 3]->mbuf_rearm_data, rearm3);
 		_mm256_storeu_si256
-			((__m256i *)&rx_pkts[i + 1]->rearm_data, rearm1);
+			((__m256i *)&rx_pkts[i + 1]->mbuf_rearm_data, rearm1);
 
 		/* extract and record EOP bit */
 		if (split_packet) {
@@ -826,7 +826,7 @@
 		free[0] = m;
 		nb_free = 1;
 		for (i = 1; i < n; i++) {
-			rte_prefetch0(&txep[i + 3].mbuf->cacheline1);
+			rte_prefetch0(&txep[i + 3].mbuf->mbuf_cacheline1);
 			m = rte_pktmbuf_prefree_seg(txep[i].mbuf);
 			if (likely(m)) {
 				if (likely(m->pool == free[0]->pool)) {
drivers/net/i40e/i40e_rxtx_vec_common.h +2 -2
index 8b74563..57c2cd6 100644
@@ -197,9 +197,9 @@
 	mb_def.port = rxq->port_id;
 	rte_mbuf_refcnt_set(&mb_def, 1);
 
-	/* prevent compiler reordering: rearm_data covers previous fields */
+	/* prevent compiler reordering: mbuf_rearm_data covers previous fields */
 	rte_compiler_barrier();
-	p = (uintptr_t)&mb_def.rearm_data;
+	p = (uintptr_t)&mb_def.mbuf_rearm_data;
 	rxq->mbuf_initializer = *(uint64_t *)p;
 	rxq->rx_using_sse = 1;
 	return 0;
drivers/net/i40e/i40e_rxtx_vec_neon.c +8 -8
index d873e30..218c2ee 100644
@@ -300,10 +300,10 @@
 	rearm2 = vsetq_lane_u64(vgetq_lane_u32(vlan0, 2), mbuf_init, 1);
 	rearm3 = vsetq_lane_u64(vgetq_lane_u32(vlan0, 3), mbuf_init, 1);
 
-	vst1q_u64((uint64_t *)&rx_pkts[0]->rearm_data, rearm0);
-	vst1q_u64((uint64_t *)&rx_pkts[1]->rearm_data, rearm1);
-	vst1q_u64((uint64_t *)&rx_pkts[2]->rearm_data, rearm2);
-	vst1q_u64((uint64_t *)&rx_pkts[3]->rearm_data, rearm3);
+	vst1q_u64((uint64_t *)&rx_pkts[0]->mbuf_rearm_data, rearm0);
+	vst1q_u64((uint64_t *)&rx_pkts[1]->mbuf_rearm_data, rearm1);
+	vst1q_u64((uint64_t *)&rx_pkts[2]->mbuf_rearm_data, rearm2);
+	vst1q_u64((uint64_t *)&rx_pkts[3]->mbuf_rearm_data, rearm3);
 }
 
 #define PKTLEN_SHIFT     10
@@ -492,13 +492,13 @@
 		pkt_mb1 = vreinterpretq_u8_u16(tmp);
 
 		/* D.3 copy final data to rx_pkts */
-		vst1q_u8((void *)&rx_pkts[pos + 3]->rx_descriptor_fields1,
+		vst1q_u8((void *)&rx_pkts[pos + 3]->mbuf_rx_descriptor_fields1,
 				pkt_mb4);
-		vst1q_u8((void *)&rx_pkts[pos + 2]->rx_descriptor_fields1,
+		vst1q_u8((void *)&rx_pkts[pos + 2]->mbuf_rx_descriptor_fields1,
 				pkt_mb3);
-		vst1q_u8((void *)&rx_pkts[pos + 1]->rx_descriptor_fields1,
+		vst1q_u8((void *)&rx_pkts[pos + 1]->mbuf_rx_descriptor_fields1,
 				pkt_mb2);
-		vst1q_u8((void *)&rx_pkts[pos]->rx_descriptor_fields1,
+		vst1q_u8((void *)&rx_pkts[pos]->mbuf_rx_descriptor_fields1,
 				pkt_mb1);
 
 		desc_to_ptype_v(descs, &rx_pkts[pos], ptype_tbl);
drivers/net/i40e/i40e_rxtx_vec_sse.c +17 -17
index 9200a23..9380e38 100644
@@ -318,13 +318,13 @@
 
 	/* write the rearm data and the olflags in one write */
 	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, ol_flags) !=
-			offsetof(struct rte_mbuf, rearm_data) + 8);
-	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, rearm_data) !=
-			RTE_ALIGN(offsetof(struct rte_mbuf, rearm_data), 16));
-	_mm_store_si128((__m128i *)&rx_pkts[0]->rearm_data, rearm0);
-	_mm_store_si128((__m128i *)&rx_pkts[1]->rearm_data, rearm1);
-	_mm_store_si128((__m128i *)&rx_pkts[2]->rearm_data, rearm2);
-	_mm_store_si128((__m128i *)&rx_pkts[3]->rearm_data, rearm3);
+			offsetof(struct rte_mbuf, mbuf_rearm_data) + 8);
+	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, mbuf_rearm_data) !=
+			RTE_ALIGN(offsetof(struct rte_mbuf, mbuf_rearm_data), 16));
+	_mm_store_si128((__m128i *)&rx_pkts[0]->mbuf_rearm_data, rearm0);
+	_mm_store_si128((__m128i *)&rx_pkts[1]->mbuf_rearm_data, rearm1);
+	_mm_store_si128((__m128i *)&rx_pkts[2]->mbuf_rearm_data, rearm2);
+	_mm_store_si128((__m128i *)&rx_pkts[3]->mbuf_rearm_data, rearm3);
 }
 
 #define PKTLEN_SHIFT     10
@@ -377,9 +377,9 @@
 	 * call above.
 	 */
 	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, pkt_len) !=
-			offsetof(struct rte_mbuf, rx_descriptor_fields1) + 4);
+			offsetof(struct rte_mbuf, mbuf_rx_descriptor_fields1) + 4);
 	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, data_len) !=
-			offsetof(struct rte_mbuf, rx_descriptor_fields1) + 8);
+			offsetof(struct rte_mbuf, mbuf_rx_descriptor_fields1) + 8);
 	__m128i dd_check, eop_check;
 
 	/* nb_pkts has to be floor-aligned to RTE_I40E_DESCS_PER_LOOP */
@@ -427,13 +427,13 @@
 	 * here for completeness in case of future modifications.
 	 */
 	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, pkt_len) !=
-			offsetof(struct rte_mbuf, rx_descriptor_fields1) + 4);
+			offsetof(struct rte_mbuf, mbuf_rx_descriptor_fields1) + 4);
 	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, data_len) !=
-			offsetof(struct rte_mbuf, rx_descriptor_fields1) + 8);
+			offsetof(struct rte_mbuf, mbuf_rx_descriptor_fields1) + 8);
 	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, vlan_tci) !=
-			offsetof(struct rte_mbuf, rx_descriptor_fields1) + 10);
+			offsetof(struct rte_mbuf, mbuf_rx_descriptor_fields1) + 10);
 	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, hash) !=
-			offsetof(struct rte_mbuf, rx_descriptor_fields1) + 12);
+			offsetof(struct rte_mbuf, mbuf_rx_descriptor_fields1) + 12);
 
 	/* Cache is empty -> need to scan the buffer rings, but first move
 	 * the next 'n' mbufs into the cache
@@ -537,9 +537,9 @@
 		staterr = _mm_unpacklo_epi32(sterr_tmp1, sterr_tmp2);
 
 		/* D.3 copy final 3,4 data to rx_pkts */
-		_mm_storeu_si128((void *)&rx_pkts[pos+3]->rx_descriptor_fields1,
+		_mm_storeu_si128((void *)&rx_pkts[pos+3]->mbuf_rx_descriptor_fields1,
 				 pkt_mb4);
-		_mm_storeu_si128((void *)&rx_pkts[pos+2]->rx_descriptor_fields1,
+		_mm_storeu_si128((void *)&rx_pkts[pos+2]->mbuf_rx_descriptor_fields1,
 				 pkt_mb3);
 
 		/* D.2 pkt 1,2 set in_port/nb_seg and remove crc */
@@ -573,9 +573,9 @@
 		staterr = _mm_packs_epi32(staterr, zero);
 
 		/* D.3 copy final 1,2 data to rx_pkts */
-		_mm_storeu_si128((void *)&rx_pkts[pos+1]->rx_descriptor_fields1,
+		_mm_storeu_si128((void *)&rx_pkts[pos+1]->mbuf_rx_descriptor_fields1,
 				 pkt_mb2);
-		_mm_storeu_si128((void *)&rx_pkts[pos]->rx_descriptor_fields1,
+		_mm_storeu_si128((void *)&rx_pkts[pos]->mbuf_rx_descriptor_fields1,
 				 pkt_mb1);
 		desc_to_ptype_v(descs, &rx_pkts[pos], ptype_tbl);
 		/* C.4 calc available number of desc */
Signature · 1 line
1.8.3.1
#37 lore raw

PATCH v4 4/18 net/iavf: stop using zero sized marker fields

In reply to Tyler Retzlaff

Update to reference newly named anonymous union markers supported by standard C and stop referencing zero sized compiler extension markers.

---
 drivers/net/iavf/iavf_rxtx_vec_avx2.c   | 60 ++++++++++++++---------------
 drivers/net/iavf/iavf_rxtx_vec_avx512.c | 60 ++++++++++++++---------------
 drivers/net/iavf/iavf_rxtx_vec_common.h |  4 +-
 drivers/net/iavf/iavf_rxtx_vec_neon.c   | 16 ++++----
 drivers/net/iavf/iavf_rxtx_vec_sse.c    | 68 ++++++++++++++++-----------------
 5 files changed, 104 insertions(+), 104 deletions(-)
drivers/net/iavf/iavf_rxtx_vec_avx2.c +30 -30
index 510b4d8..e763b96 100644
@@ -104,13 +104,13 @@
 	 * calls above.
 	 */
 	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, pkt_len) !=
-			offsetof(struct rte_mbuf, rx_descriptor_fields1) + 4);
+			offsetof(struct rte_mbuf, mbuf_rx_descriptor_fields1) + 4);
 	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, data_len) !=
-			offsetof(struct rte_mbuf, rx_descriptor_fields1) + 8);
+			offsetof(struct rte_mbuf, mbuf_rx_descriptor_fields1) + 8);
 	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, vlan_tci) !=
-			offsetof(struct rte_mbuf, rx_descriptor_fields1) + 10);
+			offsetof(struct rte_mbuf, mbuf_rx_descriptor_fields1) + 10);
 	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, hash) !=
-			offsetof(struct rte_mbuf, rx_descriptor_fields1) + 12);
+			offsetof(struct rte_mbuf, mbuf_rx_descriptor_fields1) + 12);
 
 	/* Status/Error flag masks */
 	/**
@@ -374,10 +374,10 @@
 		 */
 		/* check the structure matches expectations */
 		RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, ol_flags) !=
-				 offsetof(struct rte_mbuf, rearm_data) + 8);
-		RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, rearm_data) !=
+				 offsetof(struct rte_mbuf, mbuf_rearm_data) + 8);
+		RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, mbuf_rearm_data) !=
 				 RTE_ALIGN(offsetof(struct rte_mbuf,
-						    rearm_data),
+						    mbuf_rearm_data),
 					   16));
 		/* build up data and do writes */
 		__m256i rearm0, rearm1, rearm2, rearm3, rearm4, rearm5,
@@ -398,13 +398,13 @@
 		rearm2 = _mm256_permute2f128_si256(rearm2, mb2_3, 0x20);
 		rearm0 = _mm256_permute2f128_si256(rearm0, mb0_1, 0x20);
 		/* write to mbuf */
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 6]->rearm_data,
+		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 6]->mbuf_rearm_data,
 				    rearm6);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 4]->rearm_data,
+		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 4]->mbuf_rearm_data,
 				    rearm4);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 2]->rearm_data,
+		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 2]->mbuf_rearm_data,
 				    rearm2);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 0]->rearm_data,
+		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 0]->mbuf_rearm_data,
 				    rearm0);
 
 		/* repeat for the odd mbufs */
@@ -427,13 +427,13 @@
 		rearm3 = _mm256_blend_epi32(rearm3, mb2_3, 0xF0);
 		rearm1 = _mm256_blend_epi32(rearm1, mb0_1, 0xF0);
 		/* again write to mbufs */
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 7]->rearm_data,
+		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 7]->mbuf_rearm_data,
 				    rearm7);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 5]->rearm_data,
+		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 5]->mbuf_rearm_data,
 				    rearm5);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 3]->rearm_data,
+		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 3]->mbuf_rearm_data,
 				    rearm3);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 1]->rearm_data,
+		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 1]->mbuf_rearm_data,
 				    rearm1);
 
 		/* extract and record EOP bit */
@@ -628,13 +628,13 @@
 	 * calls above.
 	 */
 	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, pkt_len) !=
-			offsetof(struct rte_mbuf, rx_descriptor_fields1) + 4);
+			offsetof(struct rte_mbuf, mbuf_rx_descriptor_fields1) + 4);
 	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, data_len) !=
-			offsetof(struct rte_mbuf, rx_descriptor_fields1) + 8);
+			offsetof(struct rte_mbuf, mbuf_rx_descriptor_fields1) + 8);
 	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, vlan_tci) !=
-			offsetof(struct rte_mbuf, rx_descriptor_fields1) + 10);
+			offsetof(struct rte_mbuf, mbuf_rx_descriptor_fields1) + 10);
 	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, hash) !=
-			offsetof(struct rte_mbuf, rx_descriptor_fields1) + 12);
+			offsetof(struct rte_mbuf, mbuf_rx_descriptor_fields1) + 12);
 
 	/* Status/Error flag masks */
 	/**
@@ -1281,10 +1281,10 @@
 		 */
 		/* check the structure matches expectations */
 		RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, ol_flags) !=
-				 offsetof(struct rte_mbuf, rearm_data) + 8);
-		RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, rearm_data) !=
+				 offsetof(struct rte_mbuf, mbuf_rearm_data) + 8);
+		RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, mbuf_rearm_data) !=
 				 RTE_ALIGN(offsetof(struct rte_mbuf,
-						    rearm_data),
+						    mbuf_rearm_data),
 					   16));
 		/* build up data and do writes */
 		__m256i rearm0, rearm1, rearm2, rearm3, rearm4, rearm5,
@@ -1305,13 +1305,13 @@
 		rearm2 = _mm256_permute2f128_si256(rearm2, mb2_3, 0x20);
 		rearm0 = _mm256_permute2f128_si256(rearm0, mb0_1, 0x20);
 		/* write to mbuf */
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 6]->rearm_data,
+		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 6]->mbuf_rearm_data,
 				    rearm6);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 4]->rearm_data,
+		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 4]->mbuf_rearm_data,
 				    rearm4);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 2]->rearm_data,
+		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 2]->mbuf_rearm_data,
 				    rearm2);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 0]->rearm_data,
+		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 0]->mbuf_rearm_data,
 				    rearm0);
 
 		/* repeat for the odd mbufs */
@@ -1334,13 +1334,13 @@
 		rearm3 = _mm256_blend_epi32(rearm3, mb2_3, 0xF0);
 		rearm1 = _mm256_blend_epi32(rearm1, mb0_1, 0xF0);
 		/* again write to mbufs */
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 7]->rearm_data,
+		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 7]->mbuf_rearm_data,
 				    rearm7);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 5]->rearm_data,
+		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 5]->mbuf_rearm_data,
 				    rearm5);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 3]->rearm_data,
+		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 3]->mbuf_rearm_data,
 				    rearm3);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 1]->rearm_data,
+		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 1]->mbuf_rearm_data,
 				    rearm1);
 
 		/* extract and record EOP bit */
drivers/net/iavf/iavf_rxtx_vec_avx512.c +30 -30

128 lines not on this page · raw message

drivers/net/iavf/iavf_rxtx_vec_common.h +2 -2
index 5c52200..4ce1196 100644
@@ -205,9 +205,9 @@
 	mb_def.port = rxq->port_id;
 	rte_mbuf_refcnt_set(&mb_def, 1);
 
-	/* prevent compiler reordering: rearm_data covers previous fields */
+	/* prevent compiler reordering: mbuf_rearm_data covers previous fields */
 	rte_compiler_barrier();
-	p = (uintptr_t)&mb_def.rearm_data;
+	p = (uintptr_t)&mb_def.mbuf_rearm_data;
 	rxq->mbuf_initializer = *(uint64_t *)p;
 	return 0;
 }
drivers/net/iavf/iavf_rxtx_vec_neon.c +8 -8
index 83825aa..f4f6033 100644
@@ -159,10 +159,10 @@
 	rearm2 = vsetq_lane_u64(vgetq_lane_u32(vlan0, 2), mbuf_init, 1);
 	rearm3 = vsetq_lane_u64(vgetq_lane_u32(vlan0, 3), mbuf_init, 1);
 
-	vst1q_u64((uint64_t *)&rx_pkts[0]->rearm_data, rearm0);
-	vst1q_u64((uint64_t *)&rx_pkts[1]->rearm_data, rearm1);
-	vst1q_u64((uint64_t *)&rx_pkts[2]->rearm_data, rearm2);
-	vst1q_u64((uint64_t *)&rx_pkts[3]->rearm_data, rearm3);
+	vst1q_u64((uint64_t *)&rx_pkts[0]->mbuf_rearm_data, rearm0);
+	vst1q_u64((uint64_t *)&rx_pkts[1]->mbuf_rearm_data, rearm1);
+	vst1q_u64((uint64_t *)&rx_pkts[2]->mbuf_rearm_data, rearm2);
+	vst1q_u64((uint64_t *)&rx_pkts[3]->mbuf_rearm_data, rearm3);
 }
 
 #define PKTLEN_SHIFT     10
@@ -332,13 +332,13 @@
 		pkt_mb1 = vreinterpretq_u8_u16(tmp);
 
 		/* D.3 copy final data to rx_pkts */
-		vst1q_u8((void *)&rx_pkts[pos + 3]->rx_descriptor_fields1,
+		vst1q_u8((void *)&rx_pkts[pos + 3]->mbuf_rx_descriptor_fields1,
 				pkt_mb4);
-		vst1q_u8((void *)&rx_pkts[pos + 2]->rx_descriptor_fields1,
+		vst1q_u8((void *)&rx_pkts[pos + 2]->mbuf_rx_descriptor_fields1,
 				pkt_mb3);
-		vst1q_u8((void *)&rx_pkts[pos + 1]->rx_descriptor_fields1,
+		vst1q_u8((void *)&rx_pkts[pos + 1]->mbuf_rx_descriptor_fields1,
 				pkt_mb2);
-		vst1q_u8((void *)&rx_pkts[pos]->rx_descriptor_fields1,
+		vst1q_u8((void *)&rx_pkts[pos]->mbuf_rx_descriptor_fields1,
 				pkt_mb1);
 
 		desc_to_ptype_v(descs, &rx_pkts[pos], ptype_tbl);
drivers/net/iavf/iavf_rxtx_vec_sse.c +34 -34

142 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#38 lore raw

PATCH v4 5/18 net/ice: stop using zero sized marker fields

In reply to Tyler Retzlaff

Update to reference newly named anonymous union markers supported by standard C and stop referencing zero sized compiler extension markers.

---
 drivers/net/ice/ice_rxtx_vec_avx2.c   | 30 +++++++++++++++---------------
 drivers/net/ice/ice_rxtx_vec_avx512.c | 30 +++++++++++++++---------------
 drivers/net/ice/ice_rxtx_vec_common.h |  4 ++--
 drivers/net/ice/ice_rxtx_vec_sse.c    | 34 +++++++++++++++++-----------------
 4 files changed, 49 insertions(+), 49 deletions(-)
drivers/net/ice/ice_rxtx_vec_avx2.c +15 -15
index 6f6d790..2d27f1c 100644
@@ -120,13 +120,13 @@
 	 * calls above.
 	 */
 	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, pkt_len) !=
-			offsetof(struct rte_mbuf, rx_descriptor_fields1) + 4);
+			offsetof(struct rte_mbuf, mbuf_rx_descriptor_fields1) + 4);
 	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, data_len) !=
-			offsetof(struct rte_mbuf, rx_descriptor_fields1) + 8);
+			offsetof(struct rte_mbuf, mbuf_rx_descriptor_fields1) + 8);
 	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, vlan_tci) !=
-			offsetof(struct rte_mbuf, rx_descriptor_fields1) + 10);
+			offsetof(struct rte_mbuf, mbuf_rx_descriptor_fields1) + 10);
 	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, hash) !=
-			offsetof(struct rte_mbuf, rx_descriptor_fields1) + 12);
+			offsetof(struct rte_mbuf, mbuf_rx_descriptor_fields1) + 12);
 
 	/* Status/Error flag masks */
 	/**
@@ -572,10 +572,10 @@
 		 */
 		/* check the structure matches expectations */
 		RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, ol_flags) !=
-				 offsetof(struct rte_mbuf, rearm_data) + 8);
-		RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, rearm_data) !=
+				 offsetof(struct rte_mbuf, mbuf_rearm_data) + 8);
+		RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, mbuf_rearm_data) !=
 				 RTE_ALIGN(offsetof(struct rte_mbuf,
-						    rearm_data),
+						    mbuf_rearm_data),
 					   16));
 		/* build up data and do writes */
 		__m256i rearm0, rearm1, rearm2, rearm3, rearm4, rearm5,
@@ -596,13 +596,13 @@
 		rearm2 = _mm256_permute2f128_si256(rearm2, mb2_3, 0x20);
 		rearm0 = _mm256_permute2f128_si256(rearm0, mb0_1, 0x20);
 		/* write to mbuf */
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 6]->rearm_data,
+		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 6]->mbuf_rearm_data,
 				    rearm6);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 4]->rearm_data,
+		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 4]->mbuf_rearm_data,
 				    rearm4);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 2]->rearm_data,
+		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 2]->mbuf_rearm_data,
 				    rearm2);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 0]->rearm_data,
+		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 0]->mbuf_rearm_data,
 				    rearm0);
 
 		/* repeat for the odd mbufs */
@@ -625,13 +625,13 @@
 		rearm3 = _mm256_blend_epi32(rearm3, mb2_3, 0xF0);
 		rearm1 = _mm256_blend_epi32(rearm1, mb0_1, 0xF0);
 		/* again write to mbufs */
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 7]->rearm_data,
+		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 7]->mbuf_rearm_data,
 				    rearm7);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 5]->rearm_data,
+		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 5]->mbuf_rearm_data,
 				    rearm5);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 3]->rearm_data,
+		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 3]->mbuf_rearm_data,
 				    rearm3);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 1]->rearm_data,
+		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 1]->mbuf_rearm_data,
 				    rearm1);
 
 		/* extract and record EOP bit */
drivers/net/ice/ice_rxtx_vec_avx512.c +15 -15
index 04148e8..a31f358 100644
@@ -106,13 +106,13 @@
 	 * calls above.
 	 */
 	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, pkt_len) !=
-			offsetof(struct rte_mbuf, rx_descriptor_fields1) + 4);
+			offsetof(struct rte_mbuf, mbuf_rx_descriptor_fields1) + 4);
 	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, data_len) !=
-			offsetof(struct rte_mbuf, rx_descriptor_fields1) + 8);
+			offsetof(struct rte_mbuf, mbuf_rx_descriptor_fields1) + 8);
 	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, vlan_tci) !=
-			offsetof(struct rte_mbuf, rx_descriptor_fields1) + 10);
+			offsetof(struct rte_mbuf, mbuf_rx_descriptor_fields1) + 10);
 	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, hash) !=
-			offsetof(struct rte_mbuf, rx_descriptor_fields1) + 12);
+			offsetof(struct rte_mbuf, mbuf_rx_descriptor_fields1) + 12);
 
 	/* following code block is for Rx Checksum Offload */
 	/* Status/Error flag masks */
@@ -570,10 +570,10 @@
 		 */
 		/* check the structure matches expectations */
 		RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, ol_flags) !=
-				 offsetof(struct rte_mbuf, rearm_data) + 8);
-		RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, rearm_data) !=
+				 offsetof(struct rte_mbuf, mbuf_rearm_data) + 8);
+		RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, mbuf_rearm_data) !=
 				 RTE_ALIGN(offsetof(struct rte_mbuf,
-						    rearm_data),
+						    mbuf_rearm_data),
 					   16));
 		/* build up data and do writes */
 		__m256i rearm0, rearm1, rearm2, rearm3, rearm4, rearm5,
@@ -597,13 +597,13 @@
 		rearm0 = _mm256_permute2f128_si256(rearm0, mb0_1, 0x20);
 
 		/* write to mbuf */
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 6]->rearm_data,
+		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 6]->mbuf_rearm_data,
 				    rearm6);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 4]->rearm_data,
+		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 4]->mbuf_rearm_data,
 				    rearm4);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 2]->rearm_data,
+		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 2]->mbuf_rearm_data,
 				    rearm2);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 0]->rearm_data,
+		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 0]->mbuf_rearm_data,
 				    rearm0);
 
 		/* repeat for the odd mbufs */
@@ -627,13 +627,13 @@
 		rearm3 = _mm256_blend_epi32(rearm3, mb2_3, 0xF0);
 		rearm1 = _mm256_blend_epi32(rearm1, mb0_1, 0xF0);
 		/* again write to mbufs */
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 7]->rearm_data,
+		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 7]->mbuf_rearm_data,
 				    rearm7);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 5]->rearm_data,
+		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 5]->mbuf_rearm_data,
 				    rearm5);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 3]->rearm_data,
+		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 3]->mbuf_rearm_data,
 				    rearm3);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 1]->rearm_data,
+		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 1]->mbuf_rearm_data,
 				    rearm1);
 
 		/* extract and record EOP bit */
drivers/net/ice/ice_rxtx_vec_common.h +2 -2
index 4b73465..9b06206 100644
@@ -240,9 +240,9 @@
 	mb_def.port = rxq->port_id;
 	rte_mbuf_refcnt_set(&mb_def, 1);
 
-	/* prevent compiler reordering: rearm_data covers previous fields */
+	/* prevent compiler reordering: mbuf_rearm_data covers previous fields */
 	rte_compiler_barrier();
-	p = (uintptr_t)&mb_def.rearm_data;
+	p = (uintptr_t)&mb_def.mbuf_rearm_data;
 	rxq->mbuf_initializer = *(uint64_t *)p;
 	return 0;
 }
drivers/net/ice/ice_rxtx_vec_sse.c +17 -17
index 9a1b7e3..9fde848 100644
@@ -268,13 +268,13 @@
 
 	/* write the rearm data and the olflags in one write */
 	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, ol_flags) !=
-			 offsetof(struct rte_mbuf, rearm_data) + 8);
-	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, rearm_data) !=
-			 RTE_ALIGN(offsetof(struct rte_mbuf, rearm_data), 16));
-	_mm_store_si128((__m128i *)&rx_pkts[0]->rearm_data, rearm0);
-	_mm_store_si128((__m128i *)&rx_pkts[1]->rearm_data, rearm1);
-	_mm_store_si128((__m128i *)&rx_pkts[2]->rearm_data, rearm2);
-	_mm_store_si128((__m128i *)&rx_pkts[3]->rearm_data, rearm3);
+			 offsetof(struct rte_mbuf, mbuf_rearm_data) + 8);
+	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, mbuf_rearm_data) !=
+			 RTE_ALIGN(offsetof(struct rte_mbuf, mbuf_rearm_data), 16));
+	_mm_store_si128((__m128i *)&rx_pkts[0]->mbuf_rearm_data, rearm0);
+	_mm_store_si128((__m128i *)&rx_pkts[1]->mbuf_rearm_data, rearm1);
+	_mm_store_si128((__m128i *)&rx_pkts[2]->mbuf_rearm_data, rearm2);
+	_mm_store_si128((__m128i *)&rx_pkts[3]->mbuf_rearm_data, rearm3);
 }
 
 static inline void
@@ -348,9 +348,9 @@
 	 * call above.
 	 */
 	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, pkt_len) !=
-			 offsetof(struct rte_mbuf, rx_descriptor_fields1) + 4);
+			 offsetof(struct rte_mbuf, mbuf_rx_descriptor_fields1) + 4);
 	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, data_len) !=
-			 offsetof(struct rte_mbuf, rx_descriptor_fields1) + 8);
+			 offsetof(struct rte_mbuf, mbuf_rx_descriptor_fields1) + 8);
 
 	/* 4 packets DD mask */
 	const __m128i dd_check = _mm_set_epi64x(0x0000000100000001LL,
@@ -388,13 +388,13 @@
 	 * here for completeness in case of future modifications.
 	 */
 	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, pkt_len) !=
-			 offsetof(struct rte_mbuf, rx_descriptor_fields1) + 4);
+			 offsetof(struct rte_mbuf, mbuf_rx_descriptor_fields1) + 4);
 	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, data_len) !=
-			 offsetof(struct rte_mbuf, rx_descriptor_fields1) + 8);
+			 offsetof(struct rte_mbuf, mbuf_rx_descriptor_fields1) + 8);
 	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, vlan_tci) !=
-			 offsetof(struct rte_mbuf, rx_descriptor_fields1) + 10);
+			 offsetof(struct rte_mbuf, mbuf_rx_descriptor_fields1) + 10);
 	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, hash) !=
-			 offsetof(struct rte_mbuf, rx_descriptor_fields1) + 12);
+			 offsetof(struct rte_mbuf, mbuf_rx_descriptor_fields1) + 12);
 
 	/* Cache is empty -> need to scan the buffer rings, but first move
 	 * the next 'n' mbufs into the cache
@@ -542,10 +542,10 @@
 
 		/* D.3 copy final 3,4 data to rx_pkts */
 		_mm_storeu_si128
-			((void *)&rx_pkts[pos + 3]->rx_descriptor_fields1,
+			((void *)&rx_pkts[pos + 3]->mbuf_rx_descriptor_fields1,
 			 pkt_mb3);
 		_mm_storeu_si128
-			((void *)&rx_pkts[pos + 2]->rx_descriptor_fields1,
+			((void *)&rx_pkts[pos + 2]->mbuf_rx_descriptor_fields1,
 			 pkt_mb2);
 
 		/* C* extract and record EOP bit */
@@ -569,9 +569,9 @@
 
 		/* D.3 copy final 1,2 data to rx_pkts */
 		_mm_storeu_si128
-			((void *)&rx_pkts[pos + 1]->rx_descriptor_fields1,
+			((void *)&rx_pkts[pos + 1]->mbuf_rx_descriptor_fields1,
 			 pkt_mb1);
-		_mm_storeu_si128((void *)&rx_pkts[pos]->rx_descriptor_fields1,
+		_mm_storeu_si128((void *)&rx_pkts[pos]->mbuf_rx_descriptor_fields1,
 				 pkt_mb0);
 		ice_rx_desc_to_ptype_v(descs, &rx_pkts[pos], ptype_tbl);
 		/* C.4 calc available number of desc */
Signature · 1 line
1.8.3.1
#39 lore raw

PATCH v4 6/18 net/ixgbe: stop using zero sized marker fields

In reply to Tyler Retzlaff

Update to reference newly named anonymous union markers supported by standard C and stop referencing zero sized compiler extension markers.

---
 drivers/net/ixgbe/ixgbe_rxtx_vec_common.h |  4 +--
 drivers/net/ixgbe/ixgbe_rxtx_vec_neon.c   | 12 ++++-----
 drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c    | 42 +++++++++++++++----------------
 3 files changed, 29 insertions(+), 29 deletions(-)
drivers/net/ixgbe/ixgbe_rxtx_vec_common.h +2 -2
index a4d9ec9..abb55a1 100644
@@ -252,9 +252,9 @@
 	mb_def.port = rxq->port_id;
 	rte_mbuf_refcnt_set(&mb_def, 1);
 
-	/* prevent compiler reordering: rearm_data covers previous fields */
+	/* prevent compiler reordering: mbuf_rearm_data covers previous fields */
 	rte_compiler_barrier();
-	p = (uintptr_t)&mb_def.rearm_data;
+	p = (uintptr_t)&mb_def.mbuf_rearm_data;
 	rxq->mbuf_initializer = *(uint64_t *)p;
 	return 0;
 }
drivers/net/ixgbe/ixgbe_rxtx_vec_neon.c +6 -6
index 952b032..6ad888f 100644
@@ -56,13 +56,13 @@
 		 * Flush mbuf with pkt template.
 		 * Data to be rearmed is 6 bytes long.
 		 */
-		vst1_u8((uint8_t *)&mb0->rearm_data, p);
+		vst1_u8((uint8_t *)&mb0->mbuf_rearm_data, p);
 		paddr = mb0->buf_iova + RTE_PKTMBUF_HEADROOM;
 		dma_addr0 = vsetq_lane_u64(paddr, zero, 0);
 		/* flush desc with pa dma_addr */
 		vst1q_u64((uint64_t *)&rxdp++->read, dma_addr0);
 
-		vst1_u8((uint8_t *)&mb1->rearm_data, p);
+		vst1_u8((uint8_t *)&mb1->mbuf_rearm_data, p);
 		paddr = mb1->buf_iova + RTE_PKTMBUF_HEADROOM;
 		dma_addr1 = vsetq_lane_u64(paddr, zero, 0);
 		vst1q_u64((uint64_t *)&rxdp++->read, dma_addr1);
@@ -411,9 +411,9 @@
 		pkt_mb3 = vreinterpretq_u8_u16(tmp);
 
 		/* D.3 copy final 3,4 data to rx_pkts */
-		vst1q_u8((void *)&rx_pkts[pos + 3]->rx_descriptor_fields1,
+		vst1q_u8((void *)&rx_pkts[pos + 3]->mbuf_rx_descriptor_fields1,
 			 pkt_mb4);
-		vst1q_u8((void *)&rx_pkts[pos + 2]->rx_descriptor_fields1,
+		vst1q_u8((void *)&rx_pkts[pos + 2]->mbuf_rx_descriptor_fields1,
 			 pkt_mb3);
 
 		/* D.2 pkt 1,2 set in_port/nb_seg and remove crc */
@@ -441,9 +441,9 @@
 		rte_prefetch_non_temporal(rxdp + RTE_IXGBE_DESCS_PER_LOOP);
 
 		/* D.3 copy final 1,2 data to rx_pkts */
-		vst1q_u8((uint8_t *)&rx_pkts[pos + 1]->rx_descriptor_fields1,
+		vst1q_u8((uint8_t *)&rx_pkts[pos + 1]->mbuf_rx_descriptor_fields1,
 			 pkt_mb2);
-		vst1q_u8((uint8_t *)&rx_pkts[pos]->rx_descriptor_fields1,
+		vst1q_u8((uint8_t *)&rx_pkts[pos]->mbuf_rx_descriptor_fields1,
 			 pkt_mb1);
 
 		desc_to_ptype_v(descs, rxq->pkt_type_mask, &rx_pkts[pos]);
drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c +21 -21

84 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#40 lore raw

PATCH v4 7/18 net/mlx5: stop using zero sized marker fields

In reply to Tyler Retzlaff

Update to reference newly named anonymous union markers supported by standard C and stop referencing zero sized compiler extension markers.

---
 drivers/net/mlx5/mlx5_rxq.c              |  6 ++--
 drivers/net/mlx5/mlx5_rxtx_vec.h         | 16 +++++------
 drivers/net/mlx5/mlx5_rxtx_vec_altivec.h | 48 ++++++++++++++++----------------
 drivers/net/mlx5/mlx5_rxtx_vec_neon.h    | 42 ++++++++++++++--------------
 drivers/net/mlx5/mlx5_rxtx_vec_sse.h     | 48 ++++++++++++++++----------------
 5 files changed, 80 insertions(+), 80 deletions(-)
drivers/net/mlx5/mlx5_rxq.c +3 -3
index 1bb036a..b0a4610 100644
@@ -186,7 +186,7 @@
 				rte_mempool_get_priv(rxq_ctrl->rxq.mp);
 		int j;
 
-		/* Initialize default rearm_data for vPMD. */
+		/* Initialize default mbuf_rearm_data for vPMD. */
 		mbuf_init->data_off = RTE_PKTMBUF_HEADROOM;
 		rte_mbuf_refcnt_set(mbuf_init, 1);
 		mbuf_init->nb_segs = 1;
@@ -196,11 +196,11 @@
 			mbuf_init->ol_flags = RTE_MBUF_F_EXTERNAL;
 		/*
 		 * prevent compiler reordering:
-		 * rearm_data covers previous fields.
+		 * mbuf_rearm_data covers previous fields.
 		 */
 		rte_compiler_barrier();
 		rxq->mbuf_initializer =
-			*(rte_xmm_t *)&mbuf_init->rearm_data;
+			*(rte_xmm_t *)&mbuf_init->mbuf_rearm_data;
 		/* Padding with a fake mbuf for vectorized Rx. */
 		for (j = 0; j < MLX5_VPMD_DESCS_PER_LOOP; ++j)
 			(*rxq->elts)[elts_n + j] = &rxq->fake_mbuf;
drivers/net/mlx5/mlx5_rxtx_vec.h +8 -8
index 77c3f4e..ee4e442 100644
@@ -31,23 +31,23 @@
 
 /* rxq_cq_decompress_v() */
 S_ASSERT_RTE_MBUF(offsetof(struct rte_mbuf, pkt_len) ==
-		  offsetof(struct rte_mbuf, rx_descriptor_fields1) + 4);
+		  offsetof(struct rte_mbuf, mbuf_rx_descriptor_fields1) + 4);
 S_ASSERT_RTE_MBUF(offsetof(struct rte_mbuf, data_len) ==
-		  offsetof(struct rte_mbuf, rx_descriptor_fields1) + 8);
+		  offsetof(struct rte_mbuf, mbuf_rx_descriptor_fields1) + 8);
 S_ASSERT_RTE_MBUF(offsetof(struct rte_mbuf, hash) ==
-		  offsetof(struct rte_mbuf, rx_descriptor_fields1) + 12);
+		  offsetof(struct rte_mbuf, mbuf_rx_descriptor_fields1) + 12);
 
 /* rxq_cq_to_ptype_oflags_v() */
 S_ASSERT_RTE_MBUF(offsetof(struct rte_mbuf, ol_flags) ==
-		  offsetof(struct rte_mbuf, rearm_data) + 8);
-S_ASSERT_RTE_MBUF(offsetof(struct rte_mbuf, rearm_data) ==
-		  RTE_ALIGN(offsetof(struct rte_mbuf, rearm_data), 16));
+		  offsetof(struct rte_mbuf, mbuf_rearm_data) + 8);
+S_ASSERT_RTE_MBUF(offsetof(struct rte_mbuf, mbuf_rearm_data) ==
+		  RTE_ALIGN(offsetof(struct rte_mbuf, mbuf_rearm_data), 16));
 
 /* rxq_burst_v() */
 S_ASSERT_RTE_MBUF(offsetof(struct rte_mbuf, pkt_len) ==
-		  offsetof(struct rte_mbuf, rx_descriptor_fields1) + 4);
+		  offsetof(struct rte_mbuf, mbuf_rx_descriptor_fields1) + 4);
 S_ASSERT_RTE_MBUF(offsetof(struct rte_mbuf, data_len) ==
-		  offsetof(struct rte_mbuf, rx_descriptor_fields1) + 8);
+		  offsetof(struct rte_mbuf, mbuf_rx_descriptor_fields1) + 8);
 #if (RTE_CACHE_LINE_SIZE == 128)
 S_ASSERT_MLX5_CQE(offsetof(struct mlx5_cqe, pkt_info) == 64);
 #else
drivers/net/mlx5/mlx5_rxtx_vec_altivec.h +24 -24

119 lines not on this page · raw message

drivers/net/mlx5/mlx5_rxtx_vec_neon.h +21 -21

122 lines not on this page · raw message

drivers/net/mlx5/mlx5_rxtx_vec_sse.h +24 -24

111 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#41 lore raw

PATCH v4 8/18 net/sfc: stop using zero sized marker fields

In reply to Tyler Retzlaff

Update to reference newly named anonymous union markers supported by standard C and stop referencing zero sized compiler extension markers.

---
 drivers/net/sfc/sfc_ef100_rx.c | 10 +++++-----
 drivers/net/sfc/sfc_ef10_rx.c  | 14 +++++++-------
 2 files changed, 12 insertions(+), 12 deletions(-)
drivers/net/sfc/sfc_ef100_rx.c +5 -5
index 2677003..b316a6d 100644
@@ -553,9 +553,9 @@ struct sfc_ef100_rxq {
 		pkt = sfc_ef100_rx_next_mbuf(rxq);
 		__rte_mbuf_raw_sanity_check(pkt);
 
-		RTE_BUILD_BUG_ON(sizeof(pkt->rearm_data[0]) !=
+		RTE_BUILD_BUG_ON(sizeof(pkt->mbuf_rearm_data) !=
 				 sizeof(rxq->rearm_data));
-		pkt->rearm_data[0] = rxq->rearm_data;
+		*(uint64_t *)&pkt->mbuf_rearm_data[0] = rxq->rearm_data;
 
 		/* data_off already moved past Rx prefix */
 		rx_prefix = (const efx_xword_t *)sfc_ef100_rx_pkt_prefix(pkt);
@@ -757,10 +757,10 @@ struct sfc_ef100_rxq {
 	m.nb_segs = 1;
 	m.port = port_id;
 
-	/* rearm_data covers structure members filled in above */
+	/* mbuf_rearm_data covers structure members filled in above */
 	rte_compiler_barrier();
-	RTE_BUILD_BUG_ON(sizeof(m.rearm_data[0]) != sizeof(uint64_t));
-	return m.rearm_data[0];
+	RTE_BUILD_BUG_ON(sizeof(m.mbuf_rearm_data) != sizeof(uint64_t));
+	return *(uint64_t *)&m.mbuf_rearm_data[0];
 }
 
 static sfc_dp_rx_qcreate_t sfc_ef100_rx_qcreate;
drivers/net/sfc/sfc_ef10_rx.c +7 -7
index 30a320d..7b9103c 100644
@@ -322,8 +322,8 @@ struct sfc_ef10_rxq {
 
 	m = rxd->mbuf;
 
-	RTE_BUILD_BUG_ON(sizeof(m->rearm_data[0]) != sizeof(rxq->rearm_data));
-	m->rearm_data[0] = rxq->rearm_data;
+	RTE_BUILD_BUG_ON(sizeof(m->mbuf_rearm_data) != sizeof(rxq->rearm_data));
+	*(uint64_t *)&m->mbuf_rearm_data[0] = rxq->rearm_data;
 
 	/* Classify packet based on Rx event */
 	/* Mask RSS hash offload flag if RSS is not enabled */
@@ -377,9 +377,9 @@ struct sfc_ef10_rxq {
 			rxq->completed = pending;
 		}
 
-		RTE_BUILD_BUG_ON(sizeof(m->rearm_data[0]) !=
+		RTE_BUILD_BUG_ON(sizeof(m->mbuf_rearm_data) !=
 				 sizeof(rxq->rearm_data));
-		m->rearm_data[0] = rxq->rearm_data;
+		*(uint64_t *)&m->mbuf_rearm_data[0] = rxq->rearm_data;
 
 		/* Event-dependent information is the same */
 		m->ol_flags = m0->ol_flags;
@@ -631,10 +631,10 @@ struct sfc_ef10_rxq {
 	m.nb_segs = 1;
 	m.port = port_id;
 
-	/* rearm_data covers structure members filled in above */
+	/* mbuf_rearm_data covers structure members filled in above */
 	rte_compiler_barrier();
-	RTE_BUILD_BUG_ON(sizeof(m.rearm_data[0]) != sizeof(uint64_t));
-	return m.rearm_data[0];
+	RTE_BUILD_BUG_ON(sizeof(m.mbuf_rearm_data) != sizeof(uint64_t));
+	return *(uint64_t *)&m.mbuf_rearm_data[0];
 }
 
 static sfc_dp_rx_qcreate_t sfc_ef10_rx_qcreate;
Signature · 1 line
1.8.3.1
#42 lore raw

PATCH v4 9/18 net/bnxt: stop using zero sized marker fields

In reply to Tyler Retzlaff

Update to reference newly named anonymous union markers supported by standard C and stop referencing zero sized compiler extension markers.

---
 drivers/net/bnxt/bnxt_rxtx_vec_avx2.c   | 18 +++++++++---------
 drivers/net/bnxt/bnxt_rxtx_vec_common.h |  4 ++--
 drivers/net/bnxt/bnxt_rxtx_vec_neon.c   | 20 ++++++++++----------
 drivers/net/bnxt/bnxt_rxtx_vec_sse.c    | 20 ++++++++++----------
 4 files changed, 31 insertions(+), 31 deletions(-)
drivers/net/bnxt/bnxt_rxtx_vec_avx2.c +9 -9
index ea8dbaf..5f92e0f 100644
@@ -266,7 +266,7 @@
 		if (num_valid == 0)
 			break;
 
-		/* Update mbuf rearm_data for eight packets. */
+		/* Update mbuf mbuf_rearm_data for eight packets. */
 		mbuf01 = _mm256_shuffle_epi8(rxcmp0_1, shuf_msk);
 		mbuf23 = _mm256_shuffle_epi8(rxcmp2_3, shuf_msk);
 		mbuf45 = _mm256_shuffle_epi8(rxcmp4_5, shuf_msk);
@@ -310,13 +310,13 @@
 					    0x04);
 
 		/* Store all mbuf fields for first four packets. */
-		_mm256_storeu_si256((void *)&rx_pkts[i + 0]->rearm_data,
+		_mm256_storeu_si256((void *)&rx_pkts[i + 0]->mbuf_rearm_data,
 				    rearm0);
-		_mm256_storeu_si256((void *)&rx_pkts[i + 1]->rearm_data,
+		_mm256_storeu_si256((void *)&rx_pkts[i + 1]->mbuf_rearm_data,
 				    rearm1);
-		_mm256_storeu_si256((void *)&rx_pkts[i + 2]->rearm_data,
+		_mm256_storeu_si256((void *)&rx_pkts[i + 2]->mbuf_rearm_data,
 				    rearm2);
-		_mm256_storeu_si256((void *)&rx_pkts[i + 3]->rearm_data,
+		_mm256_storeu_si256((void *)&rx_pkts[i + 3]->mbuf_rearm_data,
 				    rearm3);
 
 		/* Unpack rearm data, set fixed fields for final four mbufs. */
@@ -336,13 +336,13 @@
 					    0x04);
 
 		/* Store all mbuf fields for final four packets. */
-		_mm256_storeu_si256((void *)&rx_pkts[i + 4]->rearm_data,
+		_mm256_storeu_si256((void *)&rx_pkts[i + 4]->mbuf_rearm_data,
 				    rearm4);
-		_mm256_storeu_si256((void *)&rx_pkts[i + 5]->rearm_data,
+		_mm256_storeu_si256((void *)&rx_pkts[i + 5]->mbuf_rearm_data,
 				    rearm5);
-		_mm256_storeu_si256((void *)&rx_pkts[i + 6]->rearm_data,
+		_mm256_storeu_si256((void *)&rx_pkts[i + 6]->mbuf_rearm_data,
 				    rearm6);
-		_mm256_storeu_si256((void *)&rx_pkts[i + 7]->rearm_data,
+		_mm256_storeu_si256((void *)&rx_pkts[i + 7]->mbuf_rearm_data,
 				    rearm7);
 
 		nb_rx_pkts += num_valid;
drivers/net/bnxt/bnxt_rxtx_vec_common.h +2 -2
index 2294f0a..05a52d2 100644
@@ -44,9 +44,9 @@
 	mb_def.port = rxq->port_id;
 	rte_mbuf_refcnt_set(&mb_def, 1);
 
-	/* prevent compiler reordering: rearm_data covers previous fields */
+	/* prevent compiler reordering: mbuf_rearm_data covers previous fields */
 	rte_compiler_barrier();
-	p = (uintptr_t)&mb_def.rearm_data;
+	p = (uintptr_t)&mb_def.mbuf_rearm_data;
 	rxq->mbuf_initializer = *(uint64_t *)p;
 	rxq->rxrearm_nb = 0;
 	rxq->rxrearm_start = 0;
drivers/net/bnxt/bnxt_rxtx_vec_neon.c +10 -10
index 775400f..7156f05 100644
@@ -133,29 +133,29 @@
 	errors = vorrq_u32(errors, vshrq_n_u32(is_tunnel, 1));
 	index = vorrq_u32(index, is_tunnel);
 
-	/* Update mbuf rearm_data for four packets. */
+	/* Update mbuf mbuf_rearm_data for four packets. */
 	GET_OL_FLAGS(rss_flags, index, errors, 0, ol_flags);
-	vst1q_u32((uint32_t *)&mbuf[0]->rearm_data,
+	vst1q_u32((uint32_t *)&mbuf[0]->mbuf_rearm_data,
 		  vsetq_lane_u32(ol_flags, vreinterpretq_u32_u64(mb_init), 2));
 	GET_OL_FLAGS(rss_flags, index, errors, 1, ol_flags);
-	vst1q_u32((uint32_t *)&mbuf[1]->rearm_data,
+	vst1q_u32((uint32_t *)&mbuf[1]->mbuf_rearm_data,
 		  vsetq_lane_u32(ol_flags, vreinterpretq_u32_u64(mb_init), 2));
 	GET_OL_FLAGS(rss_flags, index, errors, 2, ol_flags);
-	vst1q_u32((uint32_t *)&mbuf[2]->rearm_data,
+	vst1q_u32((uint32_t *)&mbuf[2]->mbuf_rearm_data,
 		  vsetq_lane_u32(ol_flags, vreinterpretq_u32_u64(mb_init), 2));
 	GET_OL_FLAGS(rss_flags, index, errors, 3, ol_flags);
-	vst1q_u32((uint32_t *)&mbuf[3]->rearm_data,
+	vst1q_u32((uint32_t *)&mbuf[3]->mbuf_rearm_data,
 		  vsetq_lane_u32(ol_flags, vreinterpretq_u32_u64(mb_init), 2));
 
-	/* Update mbuf rx_descriptor_fields1 for four packets. */
+	/* Update mbuf mbuf_rx_descriptor_fields1 for four packets. */
 	GET_DESC_FIELDS(mm_rxcmp[0], mm_rxcmp1[0], shuf_msk, ptype_idx, 0, tmp);
-	vst1q_u32((uint32_t *)&mbuf[0]->rx_descriptor_fields1, tmp);
+	vst1q_u32((uint32_t *)&mbuf[0]->mbuf_rx_descriptor_fields1, tmp);
 	GET_DESC_FIELDS(mm_rxcmp[1], mm_rxcmp1[1], shuf_msk, ptype_idx, 1, tmp);
-	vst1q_u32((uint32_t *)&mbuf[1]->rx_descriptor_fields1, tmp);
+	vst1q_u32((uint32_t *)&mbuf[1]->mbuf_rx_descriptor_fields1, tmp);
 	GET_DESC_FIELDS(mm_rxcmp[2], mm_rxcmp1[2], shuf_msk, ptype_idx, 2, tmp);
-	vst1q_u32((uint32_t *)&mbuf[2]->rx_descriptor_fields1, tmp);
+	vst1q_u32((uint32_t *)&mbuf[2]->mbuf_rx_descriptor_fields1, tmp);
 	GET_DESC_FIELDS(mm_rxcmp[3], mm_rxcmp1[3], shuf_msk, ptype_idx, 3, tmp);
-	vst1q_u32((uint32_t *)&mbuf[3]->rx_descriptor_fields1, tmp);
+	vst1q_u32((uint32_t *)&mbuf[3]->mbuf_rx_descriptor_fields1, tmp);
 }
 
 static uint16_t
drivers/net/bnxt/bnxt_rxtx_vec_sse.c +10 -10
index 8ef51ce..b4e6fa6 100644
@@ -118,35 +118,35 @@
 	errors = _mm_or_si128(errors, _mm_srli_epi32(is_tunnel, 1));
 	index = _mm_or_si128(index, is_tunnel);
 
-	/* Update mbuf rearm_data for four packets. */
+	/* Update mbuf mbuf_rearm_data for four packets. */
 	GET_OL_FLAGS(rss_flags, index, errors, 0, ol_flags);
-	_mm_store_si128((void *)&mbuf[0]->rearm_data,
+	_mm_store_si128((void *)&mbuf[0]->mbuf_rearm_data,
 			_mm_or_si128(mbuf_init, _mm_set_epi64x(ol_flags, 0)));
 
 	GET_OL_FLAGS(rss_flags, index, errors, 1, ol_flags);
-	_mm_store_si128((void *)&mbuf[1]->rearm_data,
+	_mm_store_si128((void *)&mbuf[1]->mbuf_rearm_data,
 			_mm_or_si128(mbuf_init, _mm_set_epi64x(ol_flags, 0)));
 
 	GET_OL_FLAGS(rss_flags, index, errors, 2, ol_flags);
-	_mm_store_si128((void *)&mbuf[2]->rearm_data,
+	_mm_store_si128((void *)&mbuf[2]->mbuf_rearm_data,
 			_mm_or_si128(mbuf_init, _mm_set_epi64x(ol_flags, 0)));
 
 	GET_OL_FLAGS(rss_flags, index, errors, 3, ol_flags);
-	_mm_store_si128((void *)&mbuf[3]->rearm_data,
+	_mm_store_si128((void *)&mbuf[3]->mbuf_rearm_data,
 			_mm_or_si128(mbuf_init, _mm_set_epi64x(ol_flags, 0)));
 
-	/* Update mbuf rx_descriptor_fields1 for four packes. */
+	/* Update mbuf mbuf_rx_descriptor_fields1 for four packes. */
 	GET_DESC_FIELDS(mm_rxcmp[0], mm_rxcmp1[0], shuf_msk, ptype_idx, 0, t0);
-	_mm_store_si128((void *)&mbuf[0]->rx_descriptor_fields1, t0);
+	_mm_store_si128((void *)&mbuf[0]->mbuf_rx_descriptor_fields1, t0);
 
 	GET_DESC_FIELDS(mm_rxcmp[1], mm_rxcmp1[1], shuf_msk, ptype_idx, 1, t0);
-	_mm_store_si128((void *)&mbuf[1]->rx_descriptor_fields1, t0);
+	_mm_store_si128((void *)&mbuf[1]->mbuf_rx_descriptor_fields1, t0);
 
 	GET_DESC_FIELDS(mm_rxcmp[2], mm_rxcmp1[2], shuf_msk, ptype_idx, 2, t0);
-	_mm_store_si128((void *)&mbuf[2]->rx_descriptor_fields1, t0);
+	_mm_store_si128((void *)&mbuf[2]->mbuf_rx_descriptor_fields1, t0);
 
 	GET_DESC_FIELDS(mm_rxcmp[3], mm_rxcmp1[3], shuf_msk, ptype_idx, 3, t0);
-	_mm_store_si128((void *)&mbuf[3]->rx_descriptor_fields1, t0);
+	_mm_store_si128((void *)&mbuf[3]->mbuf_rx_descriptor_fields1, t0);
 }
 
 static uint16_t
Signature · 1 line
1.8.3.1
#43 lore raw

PATCH v4 10/18 net/enic: stop using zero sized marker fields

In reply to Tyler Retzlaff

Update to reference newly named anonymous union markers supported by standard C and stop referencing zero sized compiler extension markers.

---
 drivers/net/enic/enic.h               |  2 +-
 drivers/net/enic/enic_main.c          |  4 ++--
 drivers/net/enic/enic_rxtx_vec_avx2.c | 22 +++++++++++-----------
 3 files changed, 14 insertions(+), 14 deletions(-)
drivers/net/enic/enic.h +1 -1
index 7877870..f2064ad 100644
@@ -92,7 +92,7 @@ struct enic {
 	struct vnic_dev *vdev;
 
 	/*
-	 * mbuf_initializer contains 64 bits of mbuf rearm_data, used by
+	 * mbuf_initializer contains 64 bits of mbuf mbuf_rearm_data, used by
 	 * the avx2 handler at this time.
 	 */
 	uint64_t mbuf_initializer;
drivers/net/enic/enic_main.c +2 -2
index a6aaa76..923f92f 100644
@@ -584,7 +584,7 @@ int enic_enable(struct enic *enic)
 
 		/*
 		 * mbuf_initializer contains const-after-init fields of
-		 * receive mbufs (i.e. 64 bits of fields from rearm_data).
+		 * receive mbufs (i.e. 64 bits of fields from mbuf_rearm_data).
 		 * It is currently used by the vectorized handler.
 		 */
 		mb_def.nb_segs = 1;
@@ -592,7 +592,7 @@ int enic_enable(struct enic *enic)
 		mb_def.port = enic->port_id;
 		rte_mbuf_refcnt_set(&mb_def, 1);
 		rte_compiler_barrier();
-		p = (uintptr_t)&mb_def.rearm_data;
+		p = (uintptr_t)&mb_def.mbuf_rearm_data;
 		enic->mbuf_initializer = *(uint64_t *)p;
 	}
 
drivers/net/enic/enic_rxtx_vec_avx2.c +11 -11
index 600efff..bd495d7 100644
@@ -19,7 +19,7 @@
 {
 	bool tnl;
 
-	*(uint64_t *)&mb->rearm_data = enic->mbuf_initializer;
+	*(uint64_t *)&mb->mbuf_rearm_data = enic->mbuf_initializer;
 	mb->data_len = cqd->bytes_written_flags &
 		CQ_ENET_RQ_DESC_BYTES_WRITTEN_MASK;
 	mb->pkt_len = mb->data_len;
@@ -394,13 +394,13 @@
 	 * type_color               - 15  (unused)
 	 *
 	 * --- mbuf fields ---       offset
-	 * rearm_data              ---- 16
+	 * mbuf_rearm_data            ---- 16
 	 * data_off    - 0      (mbuf_init) -+
 	 * refcnt      - 2      (mbuf_init)  |
 	 * nb_segs     - 4      (mbuf_init)  | 16B 128b
 	 * port        - 6      (mbuf_init)  |
 	 * ol_flag     - 8      (from cqd)  -+
-	 * rx_descriptor_fields1   ---- 32
+	 * mbuf_rx_descriptor_fields1 ---- 32
 	 * packet_type - 0      (from cqd)  -+
 	 * pkt_len     - 4      (from cqd)   |
 	 * data_len    - 8      (from cqd)   | 16B 128b
@@ -737,14 +737,14 @@
 		 * vlan_tci    - 26     (from cqd)
 		 * rss         - 28     (from cqd)
 		 */
-		_mm256_storeu_si256((__m256i *)&rxmb[0]->rearm_data, rearm0);
-		_mm256_storeu_si256((__m256i *)&rxmb[1]->rearm_data, rearm1);
-		_mm256_storeu_si256((__m256i *)&rxmb[2]->rearm_data, rearm2);
-		_mm256_storeu_si256((__m256i *)&rxmb[3]->rearm_data, rearm3);
-		_mm256_storeu_si256((__m256i *)&rxmb[4]->rearm_data, rearm4);
-		_mm256_storeu_si256((__m256i *)&rxmb[5]->rearm_data, rearm5);
-		_mm256_storeu_si256((__m256i *)&rxmb[6]->rearm_data, rearm6);
-		_mm256_storeu_si256((__m256i *)&rxmb[7]->rearm_data, rearm7);
+		_mm256_storeu_si256((__m256i *)&rxmb[0]->mbuf_rearm_data, rearm0);
+		_mm256_storeu_si256((__m256i *)&rxmb[1]->mbuf_rearm_data, rearm1);
+		_mm256_storeu_si256((__m256i *)&rxmb[2]->mbuf_rearm_data, rearm2);
+		_mm256_storeu_si256((__m256i *)&rxmb[3]->mbuf_rearm_data, rearm3);
+		_mm256_storeu_si256((__m256i *)&rxmb[4]->mbuf_rearm_data, rearm4);
+		_mm256_storeu_si256((__m256i *)&rxmb[5]->mbuf_rearm_data, rearm5);
+		_mm256_storeu_si256((__m256i *)&rxmb[6]->mbuf_rearm_data, rearm6);
+		_mm256_storeu_si256((__m256i *)&rxmb[7]->mbuf_rearm_data, rearm7);
 
 		max_rx -= 8;
 		cqd += 8;
Signature · 1 line
1.8.3.1
#44 lore raw

PATCH v4 11/18 net/fm10k: stop using zero sized marker fields

In reply to Tyler Retzlaff

Update to reference newly named anonymous union markers supported by standard C and stop referencing zero sized compiler extension markers.

---
 drivers/net/fm10k/fm10k_rxtx_vec.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)
drivers/net/fm10k/fm10k_rxtx_vec.c +12 -12
index 2b6914b..6668420 100644
@@ -237,9 +237,9 @@
 	mb_def.port = rxq->port_id;
 	rte_mbuf_refcnt_set(&mb_def, 1);
 
-	/* prevent compiler reordering: rearm_data covers previous fields */
+	/* prevent compiler reordering: mbuf_rearm_data covers previous fields */
 	rte_compiler_barrier();
-	p = (uintptr_t)&mb_def.rearm_data;
+	p = (uintptr_t)&mb_def.mbuf_rearm_data;
 	rxq->mbuf_initializer = *(uint64_t *)p;
 	return 0;
 }
@@ -290,9 +290,9 @@
 		/* Flush mbuf with pkt template.
 		 * Data to be rearmed is 6 bytes long.
 		 */
-		p0 = (uintptr_t)&mb0->rearm_data;
+		p0 = (uintptr_t)&mb0->mbuf_rearm_data;
 		*(uint64_t *)p0 = rxq->mbuf_initializer;
-		p1 = (uintptr_t)&mb1->rearm_data;
+		p1 = (uintptr_t)&mb1->mbuf_rearm_data;
 		*(uint64_t *)p1 = rxq->mbuf_initializer;
 
 		/* load buf_addr(lo 64bit) and buf_iova(hi 64bit) */
@@ -428,13 +428,13 @@
 	 * here for completeness in case of future modifications.
 	 */
 	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, pkt_len) !=
-			offsetof(struct rte_mbuf, rx_descriptor_fields1) + 4);
+			offsetof(struct rte_mbuf, mbuf_rx_descriptor_fields1) + 4);
 	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, data_len) !=
-			offsetof(struct rte_mbuf, rx_descriptor_fields1) + 8);
+			offsetof(struct rte_mbuf, mbuf_rx_descriptor_fields1) + 8);
 	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, vlan_tci) !=
-			offsetof(struct rte_mbuf, rx_descriptor_fields1) + 10);
+			offsetof(struct rte_mbuf, mbuf_rx_descriptor_fields1) + 10);
 	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, hash) !=
-			offsetof(struct rte_mbuf, rx_descriptor_fields1) + 12);
+			offsetof(struct rte_mbuf, mbuf_rx_descriptor_fields1) + 12);
 
 	/* Cache is empty -> need to scan the buffer rings, but first move
 	 * the next 'n' mbufs into the cache
@@ -519,9 +519,9 @@
 		staterr = _mm_unpacklo_epi32(sterr_tmp1, sterr_tmp2);
 
 		/* D.3 copy final 3,4 data to rx_pkts */
-		_mm_storeu_si128((void *)&rx_pkts[pos+3]->rx_descriptor_fields1,
+		_mm_storeu_si128((void *)&rx_pkts[pos+3]->mbuf_rx_descriptor_fields1,
 				pkt_mb4);
-		_mm_storeu_si128((void *)&rx_pkts[pos+2]->rx_descriptor_fields1,
+		_mm_storeu_si128((void *)&rx_pkts[pos+2]->mbuf_rx_descriptor_fields1,
 				pkt_mb3);
 
 		/* C* extract and record EOP bit */
@@ -557,9 +557,9 @@
 		staterr = _mm_packs_epi32(staterr, zero);
 
 		/* D.3 copy final 1,2 data to rx_pkts */
-		_mm_storeu_si128((void *)&rx_pkts[pos+1]->rx_descriptor_fields1,
+		_mm_storeu_si128((void *)&rx_pkts[pos+1]->mbuf_rx_descriptor_fields1,
 				pkt_mb2);
-		_mm_storeu_si128((void *)&rx_pkts[pos]->rx_descriptor_fields1,
+		_mm_storeu_si128((void *)&rx_pkts[pos]->mbuf_rx_descriptor_fields1,
 				pkt_mb1);
 
 		fm10k_desc_to_pktype_v(descs0, &rx_pkts[pos]);
Signature · 1 line
1.8.3.1
#45 lore raw

PATCH v4 12/18 net/hns3: stop using zero sized marker fields

In reply to Tyler Retzlaff

Update to reference newly named anonymous union markers supported by standard C and stop referencing zero sized compiler extension markers.

---
 drivers/net/hns3/hns3_rxtx_vec.c      | 22 +++++++++++-----------
 drivers/net/hns3/hns3_rxtx_vec_neon.h | 28 ++++++++++++++--------------
 drivers/net/hns3/hns3_rxtx_vec_sve.c  |  6 +++---
 3 files changed, 28 insertions(+), 28 deletions(-)
drivers/net/hns3/hns3_rxtx_vec.c +11 -11
index 9708ec6..4888b3d 100644
@@ -121,27 +121,27 @@
 	mb_def.port = rxq->port_id;
 	rte_mbuf_refcnt_set(&mb_def, 1);
 
-	/* compile-time verifies the rearm_data first 8bytes */
+	/* compile-time verifies the mbuf_rearm_data first 8bytes */
 	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, data_off) <
-			 offsetof(struct rte_mbuf, rearm_data));
+			 offsetof(struct rte_mbuf, mbuf_rearm_data));
 	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, refcnt) <
-			 offsetof(struct rte_mbuf, rearm_data));
+			 offsetof(struct rte_mbuf, mbuf_rearm_data));
 	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, nb_segs) <
-			 offsetof(struct rte_mbuf, rearm_data));
+			 offsetof(struct rte_mbuf, mbuf_rearm_data));
 	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, port) <
-			 offsetof(struct rte_mbuf, rearm_data));
+			 offsetof(struct rte_mbuf, mbuf_rearm_data));
 	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, data_off) -
-			 offsetof(struct rte_mbuf, rearm_data) > 6);
+			 offsetof(struct rte_mbuf, mbuf_rearm_data) > 6);
 	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, refcnt) -
-			 offsetof(struct rte_mbuf, rearm_data) > 6);
+			 offsetof(struct rte_mbuf, mbuf_rearm_data) > 6);
 	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, nb_segs) -
-			 offsetof(struct rte_mbuf, rearm_data) > 6);
+			 offsetof(struct rte_mbuf, mbuf_rearm_data) > 6);
 	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, port) -
-			 offsetof(struct rte_mbuf, rearm_data) > 6);
+			 offsetof(struct rte_mbuf, mbuf_rearm_data) > 6);
 
-	/* prevent compiler reordering: rearm_data covers previous fields */
+	/* prevent compiler reordering: mbuf_rearm_data covers previous fields */
 	rte_compiler_barrier();
-	p = (uintptr_t)&mb_def.rearm_data;
+	p = (uintptr_t)&mb_def.mbuf_rearm_data;
 	rxq->mbuf_initializer = *(uint64_t *)p;
 }
 
drivers/net/hns3/hns3_rxtx_vec_neon.h +14 -14
index 0dc6b9f..b1717ae 100644
@@ -104,7 +104,7 @@
 	for (i = 0; i < bd_vld_num; i++) {
 		pkt = sw_ring[i].mbuf;
 
-		/* init rte_mbuf.rearm_data last 64-bit */
+		/* init rte_mbuf.mbuf_rearm_data last 64-bit */
 		pkt->ol_flags = RTE_MBUF_F_RX_RSS_HASH;
 
 		l234_info = rxdp[i].rx.l234_info;
@@ -139,7 +139,7 @@
 	uint32_t pos;
 	int offset;
 
-	/* mask to shuffle from desc to mbuf's rx_descriptor_fields1 */
+	/* mask to shuffle from desc to mbuf's mbuf_rx_descriptor_fields1 */
 	uint8x16_t shuf_desc_fields_msk = {
 		0xff, 0xff, 0xff, 0xff,  /* packet type init zero */
 		20, 21, 0xff, 0xff,      /* rx.pkt_len to rte_mbuf.pkt_len */
@@ -158,11 +158,11 @@
 
 	/* compile-time verifies the shuffle mask */
 	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, pkt_len) !=
-			 offsetof(struct rte_mbuf, rx_descriptor_fields1) + 4);
+			 offsetof(struct rte_mbuf, mbuf_rx_descriptor_fields1) + 4);
 	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, data_len) !=
-			 offsetof(struct rte_mbuf, rx_descriptor_fields1) + 8);
+			 offsetof(struct rte_mbuf, mbuf_rx_descriptor_fields1) + 8);
 	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, hash.rss) !=
-			 offsetof(struct rte_mbuf, rx_descriptor_fields1) + 12);
+			 offsetof(struct rte_mbuf, mbuf_rx_descriptor_fields1) + 12);
 
 	for (pos = 0; pos < nb_pkts; pos += HNS3_DEFAULT_DESCS_PER_LOOP,
 				     rxdp += HNS3_DEFAULT_DESCS_PER_LOOP) {
@@ -236,23 +236,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((void *)&sw_ring[pos + 0].mbuf->mbuf_rx_descriptor_fields1,
 			 pkt_mb1);
-		vst1q_u8((void *)&sw_ring[pos + 1].mbuf->rx_descriptor_fields1,
+		vst1q_u8((void *)&sw_ring[pos + 1].mbuf->mbuf_rx_descriptor_fields1,
 			 pkt_mb2);
-		vst1q_u8((void *)&sw_ring[pos + 2].mbuf->rx_descriptor_fields1,
+		vst1q_u8((void *)&sw_ring[pos + 2].mbuf->mbuf_rx_descriptor_fields1,
 			 pkt_mb3);
-		vst1q_u8((void *)&sw_ring[pos + 3].mbuf->rx_descriptor_fields1,
+		vst1q_u8((void *)&sw_ring[pos + 3].mbuf->mbuf_rx_descriptor_fields1,
 			 pkt_mb4);
 
-		/* store the first 8 bytes of packets mbuf's rearm_data */
-		*(uint64_t *)&sw_ring[pos + 0].mbuf->rearm_data =
+		/* store the first 8 bytes of packets mbuf's mbuf_rearm_data */
+		*(uint64_t *)&sw_ring[pos + 0].mbuf->mbuf_rearm_data =
 			rxq->mbuf_initializer;
-		*(uint64_t *)&sw_ring[pos + 1].mbuf->rearm_data =
+		*(uint64_t *)&sw_ring[pos + 1].mbuf->mbuf_rearm_data =
 			rxq->mbuf_initializer;
-		*(uint64_t *)&sw_ring[pos + 2].mbuf->rearm_data =
+		*(uint64_t *)&sw_ring[pos + 2].mbuf->mbuf_rearm_data =
 			rxq->mbuf_initializer;
-		*(uint64_t *)&sw_ring[pos + 3].mbuf->rearm_data =
+		*(uint64_t *)&sw_ring[pos + 3].mbuf->mbuf_rearm_data =
 			rxq->mbuf_initializer;
 
 		rte_prefetch_non_temporal(rxdp + HNS3_DEFAULT_DESCS_PER_LOOP);
drivers/net/hns3/hns3_rxtx_vec_sve.c +3 -3
index 8aa4448..57aeca9 100644
@@ -33,7 +33,7 @@
 	int ret, i;
 
 	for (i = 0; i < (int)bd_vld_num; i++) {
-		/* init rte_mbuf.rearm_data last 64-bit */
+		/* init rte_mbuf.mbuf_rearm_data last 64-bit */
 		rx_pkts[i]->ol_flags = RTE_MBUF_F_RX_RSS_HASH;
 		rx_pkts[i]->hash.rss = rxdp[i].rx.rss_hash;
 		rx_pkts[i]->pkt_len = rte_le_to_cpu_16(rxdp[i].rx.pkt_len) -
@@ -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, mbuf_rearm_data), mbuf_init);
 		svst1_scatter_u64base_offset_u64(PG64_256BIT, mbp2st,
-			offsetof(struct rte_mbuf, rearm_data), mbuf_init);
+			offsetof(struct rte_mbuf, mbuf_rearm_data), mbuf_init);
 
 		next_rxdp = rxdp + HNS3_SVE_DEFAULT_DESCS_PER_LOOP;
 		rte_prefetch_non_temporal(next_rxdp);
Signature · 1 line
1.8.3.1
#47 lore raw

PATCH v4 13/18 net/ionic: stop using zero sized marker fields

In reply to Tyler Retzlaff

Update to reference newly named anonymous union markers supported by standard C and stop referencing zero sized compiler extension markers.

---
 drivers/net/ionic/ionic_lif.c         | 8 ++++----
 drivers/net/ionic/ionic_rxtx_sg.c     | 4 ++--
 drivers/net/ionic/ionic_rxtx_simple.c | 2 +-
 3 files changed, 7 insertions(+), 7 deletions(-)
drivers/net/ionic/ionic_lif.c +4 -4
index 25b490d..6497d43 100644
@@ -725,8 +725,8 @@
 
 	rte_compiler_barrier();
 
-	RTE_BUILD_BUG_ON(sizeof(rxm.rearm_data[0]) != sizeof(uint64_t));
-	return rxm.rearm_data[0];
+	RTE_BUILD_BUG_ON(sizeof(rxm.mbuf_rearm_data) != sizeof(uint64_t));
+	return *(uint64_t *)&rxm.mbuf_rearm_data[0];
 }
 
 static uint64_t
@@ -743,8 +743,8 @@
 
 	rte_compiler_barrier();
 
-	RTE_BUILD_BUG_ON(sizeof(rxm.rearm_data[0]) != sizeof(uint64_t));
-	return rxm.rearm_data[0];
+	RTE_BUILD_BUG_ON(sizeof(rxm.mbuf_rearm_data) != sizeof(uint64_t));
+	return *(uint64_t *)&rxm.mbuf_rearm_data[0];
 }
 
 int
drivers/net/ionic/ionic_rxtx_sg.c +2 -2
index ab8e56e..b12a257 100644
@@ -285,7 +285,7 @@
 	info[0] = NULL;
 
 	/* Set the mbuf metadata based on the cq entry */
-	rxm->rearm_data[0] = rxq->rearm_data;
+	*(uint64_t *)&rxm->mbuf_rearm_data[0] = rxq->rearm_data;
 	rxm->pkt_len = cq_desc_len;
 	rxm->data_len = RTE_MIN(rxq->hdr_seg_size, cq_desc_len);
 	left = cq_desc_len - rxm->data_len;
@@ -298,7 +298,7 @@
 		info[i] = NULL;
 
 		/* Set the chained mbuf metadata */
-		rxm_seg->rearm_data[0] = rxq->rearm_seg_data;
+		*(uint64_t *)&rxm_seg->mbuf_rearm_data[0] = rxq->rearm_seg_data;
 		rxm_seg->data_len = RTE_MIN(rxq->seg_size, left);
 		left -= rxm_seg->data_len;
 
drivers/net/ionic/ionic_rxtx_simple.c +1 -1
index 5f81856..37b51a6 100644
@@ -256,7 +256,7 @@
 	info[0] = NULL;
 
 	/* Set the mbuf metadata based on the cq entry */
-	rxm->rearm_data[0] = rxq->rearm_data;
+	*(uint64_t *)&rxm->mbuf_rearm_data[0] = rxq->rearm_data;
 	rxm->pkt_len = cq_desc_len;
 	rxm->data_len = cq_desc_len;
 
Signature · 1 line
1.8.3.1
#48 lore raw

PATCH v4 14/18 net/thunderx: stop using zero sized marker fields

In reply to Tyler Retzlaff

Update to reference newly named anonymous union markers supported by standard C and stop referencing zero sized compiler extension markers.

---
 drivers/net/thunderx/nicvf_ethdev.c | 4 ++--
 drivers/net/thunderx/nicvf_rxtx.h   | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/net/thunderx/nicvf_ethdev.c +2 -2
index a504d41..4dd5577 100644
@@ -1323,9 +1323,9 @@ enum nicvf_link_speed {
 	mb_def.port = rxq->port_id;
 	rte_mbuf_refcnt_set(&mb_def, 1);
 
-	/* Prevent compiler reordering: rearm_data covers previous fields */
+	/* Prevent compiler reordering: mbuf_rearm_data covers previous fields */
 	rte_compiler_barrier();
-	p = (uintptr_t)&mb_def.rearm_data;
+	p = (uintptr_t)&mb_def.mbuf_rearm_data;
 	rxq->mbuf_initializer.value = *(uint64_t *)p;
 }
 
drivers/net/thunderx/nicvf_rxtx.h +2 -2
index 4b83e33..67bc701 100644
@@ -66,7 +66,7 @@ static inline uint16_t __attribute__((const))
 #else
 	init.value += apad;
 #endif
-	*(uint64_t *)(&pkt->rearm_data) = init.value;
+	*(uint64_t *)(&pkt->mbuf_rearm_data) = init.value;
 }
 
 static inline void
@@ -80,7 +80,7 @@ static inline uint16_t __attribute__((const))
 	init.value += apad;
 #endif
 	init.fields.nb_segs = nb_segs;
-	*(uint64_t *)(&pkt->rearm_data) = init.value;
+	*(uint64_t *)(&pkt->mbuf_rearm_data) = init.value;
 }
 
 uint32_t nicvf_dev_rx_queue_count(void *rx_queue);
Signature · 1 line
1.8.3.1
#49 lore raw

PATCH v4 15/18 net/virtio: stop using zero sized marker fields

In reply to Tyler Retzlaff

Update to reference newly named anonymous union markers supported by standard C and stop referencing zero sized compiler extension markers.

---
 drivers/net/virtio/virtio_rxtx_packed.h         |  4 ++--
 drivers/net/virtio/virtio_rxtx_packed_avx.h     | 14 +++++++-------
 drivers/net/virtio/virtio_rxtx_packed_neon.h    | 18 +++++++++---------
 drivers/net/virtio/virtio_rxtx_simple.c         |  4 ++--
 drivers/net/virtio/virtio_rxtx_simple.h         |  2 +-
 drivers/net/virtio/virtio_rxtx_simple_altivec.c | 16 ++++++++--------
 drivers/net/virtio/virtio_rxtx_simple_neon.c    | 16 ++++++++--------
 drivers/net/virtio/virtio_rxtx_simple_sse.c     | 16 ++++++++--------
 8 files changed, 45 insertions(+), 45 deletions(-)
drivers/net/virtio/virtio_rxtx_packed.h +2 -2
index 5361129..5bd6966 100644
@@ -37,12 +37,12 @@
 
 /* reference count offset in mbuf rearm data */
 #define REFCNT_BITS_OFFSET ((offsetof(struct rte_mbuf, refcnt) - \
-	offsetof(struct rte_mbuf, rearm_data)) * BYTE_SIZE)
+	offsetof(struct rte_mbuf, mbuf_rearm_data)) * BYTE_SIZE)
 
 #ifdef CC_AVX512_SUPPORT
 /* segment number offset in mbuf rearm data */
 #define SEG_NUM_BITS_OFFSET ((offsetof(struct rte_mbuf, nb_segs) - \
-	offsetof(struct rte_mbuf, rearm_data)) * BYTE_SIZE)
+	offsetof(struct rte_mbuf, mbuf_rearm_data)) * BYTE_SIZE)
 /* default rearm data */
 #define DEFAULT_REARM_DATA (1ULL << SEG_NUM_BITS_OFFSET | \
 	1ULL << REFCNT_BITS_OFFSET)
drivers/net/virtio/virtio_rxtx_packed_avx.h +7 -7
index 584ac72..8780e8e 100644
@@ -36,10 +36,10 @@
 	/* Load four mbufs rearm data */
 	RTE_BUILD_BUG_ON(REFCNT_BITS_OFFSET >= 64);
 	RTE_BUILD_BUG_ON(SEG_NUM_BITS_OFFSET >= 64);
-	__m256i mbufs = _mm256_set_epi64x(*tx_pkts[3]->rearm_data,
-					  *tx_pkts[2]->rearm_data,
-					  *tx_pkts[1]->rearm_data,
-					  *tx_pkts[0]->rearm_data);
+	__m256i mbufs = _mm256_set_epi64x(*(uint64_t *)tx_pkts[3]->mbuf_rearm_data,
+					  *(uint64_t *)tx_pkts[2]->mbuf_rearm_data,
+					  *(uint64_t *)tx_pkts[1]->mbuf_rearm_data,
+					  *(uint64_t *)tx_pkts[0]->mbuf_rearm_data);
 
 	/* refcnt=1 and nb_segs=1 */
 	__m256i mbuf_ref = _mm256_set1_epi64x(DEFAULT_REARM_DATA);
@@ -54,7 +54,7 @@
 	/* Check headroom is enough */
 	const __mmask16 data_mask = 0x1 | 0x1 << 4 | 0x1 << 8 | 0x1 << 12;
 	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, data_off) !=
-		offsetof(struct rte_mbuf, rearm_data));
+		offsetof(struct rte_mbuf, mbuf_rearm_data));
 	cmp = _mm256_mask_cmplt_epu16_mask(data_mask, mbufs, head_rooms);
 	if (unlikely(cmp))
 		return -1;
@@ -187,7 +187,7 @@
 		rx_pkts[i] = (struct rte_mbuf *)vq->vq_descx[id + i].cookie;
 		rte_packet_prefetch(rte_pktmbuf_mtod(rx_pkts[i], void *));
 
-		addrs[i] = (uintptr_t)rx_pkts[i]->rx_descriptor_fields1;
+		addrs[i] = (uintptr_t)rx_pkts[i]->mbuf_rx_descriptor_fields1;
 	}
 
 	/*
@@ -205,7 +205,7 @@
 
 	/* assert offset of data_len */
 	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, data_len) !=
-		offsetof(struct rte_mbuf, rx_descriptor_fields1) + 8);
+		offsetof(struct rte_mbuf, mbuf_rx_descriptor_fields1) + 8);
 
 	__m512i v_index = _mm512_set_epi64(addrs[3] + 8, addrs[3],
 					   addrs[2] + 8, addrs[2],
drivers/net/virtio/virtio_rxtx_packed_neon.h +9 -9
index c222ebf..2432d0a 100644
@@ -59,10 +59,10 @@
 	uint8x16x2_t mbuf;
 	/* Load four mbufs rearm data. */
 	RTE_BUILD_BUG_ON(REFCNT_BITS_OFFSET >= 64);
-	pkts[0] = vld1_u16((uint16_t *)&tx_pkts[0]->rearm_data);
-	pkts[1] = vld1_u16((uint16_t *)&tx_pkts[1]->rearm_data);
-	pkts[2] = vld1_u16((uint16_t *)&tx_pkts[2]->rearm_data);
-	pkts[3] = vld1_u16((uint16_t *)&tx_pkts[3]->rearm_data);
+	pkts[0] = vld1_u16((uint16_t *)&tx_pkts[0]->mbuf_rearm_data);
+	pkts[1] = vld1_u16((uint16_t *)&tx_pkts[1]->mbuf_rearm_data);
+	pkts[2] = vld1_u16((uint16_t *)&tx_pkts[2]->mbuf_rearm_data);
+	pkts[3] = vld1_u16((uint16_t *)&tx_pkts[3]->mbuf_rearm_data);
 
 	mbuf.val[0] = vreinterpretq_u8_u16(vcombine_u16(pkts[0], pkts[1]));
 	mbuf.val[1] = vreinterpretq_u8_u16(vcombine_u16(pkts[2], pkts[3]));
@@ -78,7 +78,7 @@
 	/* Check headroom is enough. */
 	uint16x4_t head_rooms = vdup_n_u16(head_size);
 	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, data_off) !=
-			 offsetof(struct rte_mbuf, rearm_data));
+			 offsetof(struct rte_mbuf, mbuf_rearm_data));
 	uint16x4_t data_offset = vreinterpret_u16_u8(vqtbl2_u8(mbuf, data_msk));
 	uint64x1_t cmp2 = vreinterpret_u64_u16(vclt_u16(data_offset, head_rooms));
 	if (unlikely(vget_lane_u64(cmp2, 0)))
@@ -263,10 +263,10 @@
 	pkt_mb[3] = vreinterpretq_u64_u16(vsubq_u16(
 			vreinterpretq_u16_u64(pkt_mb[3]), len_adjust));
 
-	vst1q_u64((void *)&rx_pkts[0]->rx_descriptor_fields1, pkt_mb[0]);
-	vst1q_u64((void *)&rx_pkts[1]->rx_descriptor_fields1, pkt_mb[1]);
-	vst1q_u64((void *)&rx_pkts[2]->rx_descriptor_fields1, pkt_mb[2]);
-	vst1q_u64((void *)&rx_pkts[3]->rx_descriptor_fields1, pkt_mb[3]);
+	vst1q_u64((void *)&rx_pkts[0]->mbuf_rx_descriptor_fields1, pkt_mb[0]);
+	vst1q_u64((void *)&rx_pkts[1]->mbuf_rx_descriptor_fields1, pkt_mb[1]);
+	vst1q_u64((void *)&rx_pkts[2]->mbuf_rx_descriptor_fields1, pkt_mb[2]);
+	vst1q_u64((void *)&rx_pkts[3]->mbuf_rx_descriptor_fields1, pkt_mb[3]);
 
 	if (hw->has_rx_offload) {
 		virtio_for_each_try_unroll(i, 0, PACKED_BATCH_SIZE) {
drivers/net/virtio/virtio_rxtx_simple.c +2 -2
index 4382569..26b712b 100644
@@ -39,9 +39,9 @@
 	mb_def.port = vq->hw->port_id;
 	rte_mbuf_refcnt_set(&mb_def, 1);
 
-	/* prevent compiler reordering: rearm_data covers previous fields */
+	/* prevent compiler reordering: mbuf_rearm_data covers previous fields */
 	rte_compiler_barrier();
-	p = (uintptr_t)&mb_def.rearm_data;
+	p = (uintptr_t)&mb_def.mbuf_rearm_data;
 	rxq->mbuf_initializer = *(uint64_t *)p;
 
 	return 0;
drivers/net/virtio/virtio_rxtx_simple.h +1 -1
index 79196ed..d00e51d 100644
@@ -41,7 +41,7 @@
 	for (i = 0; i < RTE_VIRTIO_VPMD_RX_REARM_THRESH; i++) {
 		uintptr_t p;
 
-		p = (uintptr_t)&sw_ring[i]->rearm_data;
+		p = (uintptr_t)&sw_ring[i]->mbuf_rearm_data;
 		*(uint64_t *)p = rxvq->mbuf_initializer;
 
 		start_dp[i].addr = VIRTIO_MBUF_ADDR(sw_ring[i], vq) +
drivers/net/virtio/virtio_rxtx_simple_altivec.c +8 -8
index 542ec3d..70c82d0 100644
@@ -138,9 +138,9 @@
 			((__vector unsigned short)pkt_mb[0] + len_adjust);
 		pkt_mb[1] = (__vector unsigned char)
 			((__vector unsigned short)pkt_mb[1] + len_adjust);
-		*(__vector unsigned char *)&rx_pkts[0]->rx_descriptor_fields1 =
+		*(__vector unsigned char *)&rx_pkts[0]->mbuf_rx_descriptor_fields1 =
 			pkt_mb[0];
-		*(__vector unsigned char *)&rx_pkts[1]->rx_descriptor_fields1 =
+		*(__vector unsigned char *)&rx_pkts[1]->mbuf_rx_descriptor_fields1 =
 			pkt_mb[1];
 
 		pkt_mb[2] = vec_perm(desc[1], zero, shuf_msk1);
@@ -149,9 +149,9 @@
 			((__vector unsigned short)pkt_mb[2] + len_adjust);
 		pkt_mb[3] = (__vector unsigned char)
 			((__vector unsigned short)pkt_mb[3] + len_adjust);
-		*(__vector unsigned char *)&rx_pkts[2]->rx_descriptor_fields1 =
+		*(__vector unsigned char *)&rx_pkts[2]->mbuf_rx_descriptor_fields1 =
 			pkt_mb[2];
-		*(__vector unsigned char *)&rx_pkts[3]->rx_descriptor_fields1 =
+		*(__vector unsigned char *)&rx_pkts[3]->mbuf_rx_descriptor_fields1 =
 			pkt_mb[3];
 
 		pkt_mb[4] = vec_perm(desc[2], zero, shuf_msk1);
@@ -160,9 +160,9 @@
 			((__vector unsigned short)pkt_mb[4] + len_adjust);
 		pkt_mb[5] = (__vector unsigned char)
 			((__vector unsigned short)pkt_mb[5] + len_adjust);
-		*(__vector unsigned char *)&rx_pkts[4]->rx_descriptor_fields1 =
+		*(__vector unsigned char *)&rx_pkts[4]->mbuf_rx_descriptor_fields1 =
 			pkt_mb[4];
-		*(__vector unsigned char *)&rx_pkts[5]->rx_descriptor_fields1 =
+		*(__vector unsigned char *)&rx_pkts[5]->mbuf_rx_descriptor_fields1 =
 			pkt_mb[5];
 
 		pkt_mb[6] = vec_perm(desc[3], zero, shuf_msk1);
@@ -171,9 +171,9 @@
 			((__vector unsigned short)pkt_mb[6] + len_adjust);
 		pkt_mb[7] = (__vector unsigned char)
 			((__vector unsigned short)pkt_mb[7] + len_adjust);
-		*(__vector unsigned char *)&rx_pkts[6]->rx_descriptor_fields1 =
+		*(__vector unsigned char *)&rx_pkts[6]->mbuf_rx_descriptor_fields1 =
 			pkt_mb[6];
-		*(__vector unsigned char *)&rx_pkts[7]->rx_descriptor_fields1 =
+		*(__vector unsigned char *)&rx_pkts[7]->mbuf_rx_descriptor_fields1 =
 			pkt_mb[7];
 
 		if (unlikely(nb_used <= RTE_VIRTIO_DESC_PER_LOOP)) {
drivers/net/virtio/virtio_rxtx_simple_neon.c +8 -8
index 7139b31..5b8bd67 100644
@@ -138,9 +138,9 @@
 				vreinterpretq_u16_u64(pkt_mb[1]), len_adjust));
 		pkt_mb[0] = vreinterpretq_u64_u16(vsubq_u16(
 				vreinterpretq_u16_u64(pkt_mb[0]), len_adjust));
-		vst1q_u64((void *)&rx_pkts[1]->rx_descriptor_fields1,
+		vst1q_u64((void *)&rx_pkts[1]->mbuf_rx_descriptor_fields1,
 			pkt_mb[1]);
-		vst1q_u64((void *)&rx_pkts[0]->rx_descriptor_fields1,
+		vst1q_u64((void *)&rx_pkts[0]->mbuf_rx_descriptor_fields1,
 			pkt_mb[0]);
 
 		pkt_mb[3] = vreinterpretq_u64_u8(vqtbl1q_u8(
@@ -151,9 +151,9 @@
 				vreinterpretq_u16_u64(pkt_mb[3]), len_adjust));
 		pkt_mb[2] = vreinterpretq_u64_u16(vsubq_u16(
 				vreinterpretq_u16_u64(pkt_mb[2]), len_adjust));
-		vst1q_u64((void *)&rx_pkts[3]->rx_descriptor_fields1,
+		vst1q_u64((void *)&rx_pkts[3]->mbuf_rx_descriptor_fields1,
 			pkt_mb[3]);
-		vst1q_u64((void *)&rx_pkts[2]->rx_descriptor_fields1,
+		vst1q_u64((void *)&rx_pkts[2]->mbuf_rx_descriptor_fields1,
 			pkt_mb[2]);
 
 		pkt_mb[5] = vreinterpretq_u64_u8(vqtbl1q_u8(
@@ -164,9 +164,9 @@
 				vreinterpretq_u16_u64(pkt_mb[5]), len_adjust));
 		pkt_mb[4] = vreinterpretq_u64_u16(vsubq_u16(
 				vreinterpretq_u16_u64(pkt_mb[4]), len_adjust));
-		vst1q_u64((void *)&rx_pkts[5]->rx_descriptor_fields1,
+		vst1q_u64((void *)&rx_pkts[5]->mbuf_rx_descriptor_fields1,
 			pkt_mb[5]);
-		vst1q_u64((void *)&rx_pkts[4]->rx_descriptor_fields1,
+		vst1q_u64((void *)&rx_pkts[4]->mbuf_rx_descriptor_fields1,
 			pkt_mb[4]);
 
 		pkt_mb[7] = vreinterpretq_u64_u8(vqtbl1q_u8(
@@ -177,9 +177,9 @@
 				vreinterpretq_u16_u64(pkt_mb[7]), len_adjust));
 		pkt_mb[6] = vreinterpretq_u64_u16(vsubq_u16(
 				vreinterpretq_u16_u64(pkt_mb[6]), len_adjust));
-		vst1q_u64((void *)&rx_pkts[7]->rx_descriptor_fields1,
+		vst1q_u64((void *)&rx_pkts[7]->mbuf_rx_descriptor_fields1,
 			pkt_mb[7]);
-		vst1q_u64((void *)&rx_pkts[6]->rx_descriptor_fields1,
+		vst1q_u64((void *)&rx_pkts[6]->mbuf_rx_descriptor_fields1,
 			pkt_mb[6]);
 
 		if (unlikely(nb_used <= RTE_VIRTIO_DESC_PER_LOOP)) {
drivers/net/virtio/virtio_rxtx_simple_sse.c +8 -8
index 6a18741..009c02d 100644
@@ -134,36 +134,36 @@
 		pkt_mb[0] = _mm_shuffle_epi8(desc[0], shuf_msk1);
 		pkt_mb[1] = _mm_add_epi16(pkt_mb[1], len_adjust);
 		pkt_mb[0] = _mm_add_epi16(pkt_mb[0], len_adjust);
-		_mm_storeu_si128((void *)&rx_pkts[1]->rx_descriptor_fields1,
+		_mm_storeu_si128((void *)&rx_pkts[1]->mbuf_rx_descriptor_fields1,
 			pkt_mb[1]);
-		_mm_storeu_si128((void *)&rx_pkts[0]->rx_descriptor_fields1,
+		_mm_storeu_si128((void *)&rx_pkts[0]->mbuf_rx_descriptor_fields1,
 			pkt_mb[0]);
 
 		pkt_mb[3] = _mm_shuffle_epi8(desc[1], shuf_msk2);
 		pkt_mb[2] = _mm_shuffle_epi8(desc[1], shuf_msk1);
 		pkt_mb[3] = _mm_add_epi16(pkt_mb[3], len_adjust);
 		pkt_mb[2] = _mm_add_epi16(pkt_mb[2], len_adjust);
-		_mm_storeu_si128((void *)&rx_pkts[3]->rx_descriptor_fields1,
+		_mm_storeu_si128((void *)&rx_pkts[3]->mbuf_rx_descriptor_fields1,
 			pkt_mb[3]);
-		_mm_storeu_si128((void *)&rx_pkts[2]->rx_descriptor_fields1,
+		_mm_storeu_si128((void *)&rx_pkts[2]->mbuf_rx_descriptor_fields1,
 			pkt_mb[2]);
 
 		pkt_mb[5] = _mm_shuffle_epi8(desc[2], shuf_msk2);
 		pkt_mb[4] = _mm_shuffle_epi8(desc[2], shuf_msk1);
 		pkt_mb[5] = _mm_add_epi16(pkt_mb[5], len_adjust);
 		pkt_mb[4] = _mm_add_epi16(pkt_mb[4], len_adjust);
-		_mm_storeu_si128((void *)&rx_pkts[5]->rx_descriptor_fields1,
+		_mm_storeu_si128((void *)&rx_pkts[5]->mbuf_rx_descriptor_fields1,
 			pkt_mb[5]);
-		_mm_storeu_si128((void *)&rx_pkts[4]->rx_descriptor_fields1,
+		_mm_storeu_si128((void *)&rx_pkts[4]->mbuf_rx_descriptor_fields1,
 			pkt_mb[4]);
 
 		pkt_mb[7] = _mm_shuffle_epi8(desc[3], shuf_msk2);
 		pkt_mb[6] = _mm_shuffle_epi8(desc[3], shuf_msk1);
 		pkt_mb[7] = _mm_add_epi16(pkt_mb[7], len_adjust);
 		pkt_mb[6] = _mm_add_epi16(pkt_mb[6], len_adjust);
-		_mm_storeu_si128((void *)&rx_pkts[7]->rx_descriptor_fields1,
+		_mm_storeu_si128((void *)&rx_pkts[7]->mbuf_rx_descriptor_fields1,
 			pkt_mb[7]);
-		_mm_storeu_si128((void *)&rx_pkts[6]->rx_descriptor_fields1,
+		_mm_storeu_si128((void *)&rx_pkts[6]->mbuf_rx_descriptor_fields1,
 			pkt_mb[6]);
 
 		if (unlikely(nb_used <= RTE_VIRTIO_DESC_PER_LOOP)) {
Signature · 1 line
1.8.3.1
#50 lore raw

PATCH v4 16/18 net/cnxk: stop using zero sized marker fields

In reply to Tyler Retzlaff

Update to reference newly named anonymous union markers supported by standard C and stop referencing zero sized compiler extension markers.

---
 drivers/net/cnxk/cn10k_rx.h    | 50 +++++++++++++++++++++---------------------
 drivers/net/cnxk/cn9k_rx.h     | 34 ++++++++++++++--------------
 drivers/net/cnxk/cnxk_ethdev.c |  4 ++--
 3 files changed, 44 insertions(+), 44 deletions(-)
drivers/net/cnxk/cn10k_rx.h +25 -25
index 7bb4c86..51333b0 100644
@@ -309,7 +309,7 @@
 		frag_rx = (union nix_rx_parse_u *)(wqe + 1);
 		frag_size = rlen + frag_rx->lcptr - frag_rx->laptr;
 
-		*(uint64_t *)(&mbuf->rearm_data) = mbuf_init;
+		*(uint64_t *)(&mbuf->mbuf_rearm_data) = mbuf_init;
 		mbuf->data_len = frag_size;
 		mbuf->pkt_len = frag_size;
 		mbuf->ol_flags = ol_flags;
@@ -368,7 +368,7 @@
 	fsz_w1 >>= 16;
 
 	data_off = b_off + frag_rx->lcptr + l3_hdr_size;
-	*(uint64_t *)(&mbuf->rearm_data) = mbuf_init | data_off;
+	*(uint64_t *)(&mbuf->mbuf_rearm_data) = mbuf_init | data_off;
 	mbuf->data_len = frag_size;
 
 	/* Mark frag as get */
@@ -384,7 +384,7 @@
 		fsz_w1 >>= 16;
 
 		data_off = b_off + frag_rx->lcptr + l3_hdr_size;
-		*(uint64_t *)(&mbuf->rearm_data) = mbuf_init | data_off;
+		*(uint64_t *)(&mbuf->mbuf_rearm_data) = mbuf_init | data_off;
 		mbuf->data_len = frag_size;
 
 		/* Mark frag as get */
@@ -401,7 +401,7 @@
 		fsz_w1 >>= 16;
 
 		data_off = b_off + frag_rx->lcptr + l3_hdr_size;
-		*(uint64_t *)(&mbuf->rearm_data) = mbuf_init | data_off;
+		*(uint64_t *)(&mbuf->mbuf_rearm_data) = mbuf_init | data_off;
 		mbuf->data_len = frag_size;
 
 		/* Mark frag as get */
@@ -502,7 +502,7 @@
 
 	inner->pkt_len = len;
 	inner->data_len = len;
-	*(uint64_t *)(&inner->rearm_data) = mbuf_init;
+	*(uint64_t *)(&inner->mbuf_rearm_data) = mbuf_init;
 
 	inner->ol_flags = ((CPT_COMP_HWGOOD_MASK & (1U << ucc)) ?
 			   RTE_MBUF_F_RX_SEC_OFFLOAD :
@@ -584,7 +584,7 @@
 			/* First frag len */
 			inner->pkt_len = vgetq_lane_u16(*rx_desc_field1, 2);
 			inner->data_len = vgetq_lane_u16(*rx_desc_field1, 4);
-			p = (uintptr_t)&inner->rearm_data;
+			p = (uintptr_t)&inner->mbuf_rearm_data;
 			*(uint64_t *)p = mbuf_init;
 
 			/* Reassembly success */
@@ -774,7 +774,7 @@
 
 		mbuf->data_len = sg_len;
 		sg = sg >> 16;
-		p = (uintptr_t)&mbuf->rearm_data;
+		p = (uintptr_t)&mbuf->mbuf_rearm_data;
 		*(uint64_t *)p = rearm & ~0xFFFF;
 		nb_segs--;
 		iova_list++;
@@ -825,7 +825,7 @@
 			head->nb_segs = nb_segs;
 		}
 		mbuf = next_frag;
-		p = (uintptr_t)&mbuf->rearm_data;
+		p = (uintptr_t)&mbuf->mbuf_rearm_data;
 		*(uint64_t *)p = rearm + ldptr;
 		mbuf->data_len = (sg & 0xFFFF) - ldptr -
 				 (flags & NIX_RX_OFFLOAD_TSTAMP_F ?
@@ -849,7 +849,7 @@
 
 
 		len = mbuf->pkt_len;
-		p = (uintptr_t)&mbuf->rearm_data;
+		p = (uintptr_t)&mbuf->mbuf_rearm_data;
 		*(uint64_t *)p = rearm;
 		mbuf->data_len = (sg & 0xFFFF) -
 				 (flags & NIX_RX_OFFLOAD_TSTAMP_F ?
@@ -917,7 +917,7 @@
 		mbuf->ol_flags = ol_flags;
 		mbuf->pkt_len = len;
 		mbuf->data_len = len;
-		p = (uintptr_t)&mbuf->rearm_data;
+		p = (uintptr_t)&mbuf->mbuf_rearm_data;
 		*(uint64_t *)p = val;
 	}
 
@@ -1464,7 +1464,7 @@
 				0,    1,    /* octet 1~0, 16 bits data_len */
 				0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
 
-			/* Form the rx_descriptor_fields1 with pkt_len and data_len */
+			/* Form the mbuf_rx_descriptor_fields1 with pkt_len and data_len */
 			f0 = vqtbl1q_u8(cq0_w8, shuf_msk);
 			f1 = vqtbl1q_u8(cq1_w8, shuf_msk);
 			f2 = vqtbl1q_u8(cq2_w8, shuf_msk);
@@ -1512,7 +1512,7 @@
 		}
 
 		if (flags & NIX_RX_OFFLOAD_RSS_F) {
-			/* Fill rss in the rx_descriptor_fields1 */
+			/* Fill rss in the mbuf_rx_descriptor_fields1 */
 			f0 = vsetq_lane_u32(cq0_w0, f0, 3);
 			f1 = vsetq_lane_u32(cq1_w0, f1, 3);
 			f2 = vsetq_lane_u32(cq2_w0, f2, 3);
@@ -1529,7 +1529,7 @@
 		}
 
 		if (flags & NIX_RX_OFFLOAD_PTYPE_F) {
-			/* Fill packet_type in the rx_descriptor_fields1 */
+			/* Fill packet_type in the mbuf_rx_descriptor_fields1 */
 			f0 = vsetq_lane_u32(nix_ptype_get(lookup_mem, cq0_w1),
 					    f0, 0);
 			f1 = vsetq_lane_u32(nix_ptype_get(lookup_mem, cq1_w1),
@@ -1959,23 +1959,23 @@
 			}
 		}
 
-		/* Form rearm_data with ol_flags */
+		/* Form mbuf_rearm_data with ol_flags */
 		rearm0 = vsetq_lane_u64(ol_flags0, rearm0, 1);
 		rearm1 = vsetq_lane_u64(ol_flags1, rearm1, 1);
 		rearm2 = vsetq_lane_u64(ol_flags2, rearm2, 1);
 		rearm3 = vsetq_lane_u64(ol_flags3, rearm3, 1);
 
-		/* Update rx_descriptor_fields1 */
-		vst1q_u64((uint64_t *)mbuf0->rx_descriptor_fields1, f0);
-		vst1q_u64((uint64_t *)mbuf1->rx_descriptor_fields1, f1);
-		vst1q_u64((uint64_t *)mbuf2->rx_descriptor_fields1, f2);
-		vst1q_u64((uint64_t *)mbuf3->rx_descriptor_fields1, f3);
-
-		/* Update rearm_data */
-		vst1q_u64((uint64_t *)mbuf0->rearm_data, rearm0);
-		vst1q_u64((uint64_t *)mbuf1->rearm_data, rearm1);
-		vst1q_u64((uint64_t *)mbuf2->rearm_data, rearm2);
-		vst1q_u64((uint64_t *)mbuf3->rearm_data, rearm3);
+		/* Update mbuf_rx_descriptor_fields1 */
+		vst1q_u64((uint64_t *)mbuf0->mbuf_rx_descriptor_fields1, f0);
+		vst1q_u64((uint64_t *)mbuf1->mbuf_rx_descriptor_fields1, f1);
+		vst1q_u64((uint64_t *)mbuf2->mbuf_rx_descriptor_fields1, f2);
+		vst1q_u64((uint64_t *)mbuf3->mbuf_rx_descriptor_fields1, f3);
+
+		/* Update mbuf_rearm_data */
+		vst1q_u64((uint64_t *)mbuf0->mbuf_rearm_data, rearm0);
+		vst1q_u64((uint64_t *)mbuf1->mbuf_rearm_data, rearm1);
+		vst1q_u64((uint64_t *)mbuf2->mbuf_rearm_data, rearm2);
+		vst1q_u64((uint64_t *)mbuf3->mbuf_rearm_data, rearm3);
 
 		if (flags & NIX_RX_MULTI_SEG_F) {
 			/* Multi segment is enable build mseg list for
drivers/net/cnxk/cn9k_rx.h +17 -17
index d8bb65c..1256640 100644
@@ -155,7 +155,7 @@
 
 		mbuf->data_len = sg & 0xFFFF;
 		sg = sg >> 16;
-		*(uint64_t *)(&mbuf->rearm_data) = rearm;
+		*(uint64_t *)(&mbuf->mbuf_rearm_data) = rearm;
 		nb_segs--;
 		iova_list++;
 
@@ -398,7 +398,7 @@
 			nix_update_match_id(rx->cn9k.match_id, ol_flags, mbuf);
 
 	mbuf->ol_flags = ol_flags;
-	*(uint64_t *)(&mbuf->rearm_data) = val;
+	*(uint64_t *)(&mbuf->mbuf_rearm_data) = val;
 	mbuf->pkt_len = len;
 	mbuf->data_len = len;
 
@@ -615,7 +615,7 @@
 			0,    1,    /* octet 1~0, 16 bits data_len */
 			0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
 
-		/* Form the rx_descriptor_fields1 with pkt_len and data_len */
+		/* Form the mbuf_rx_descriptor_fields1 with pkt_len and data_len */
 		f0 = vqtbl1q_u8(cq0_w8, shuf_msk);
 		f1 = vqtbl1q_u8(cq1_w8, shuf_msk);
 		f2 = vqtbl1q_u8(cq2_w8, shuf_msk);
@@ -632,7 +632,7 @@
 		uint64_t cq3_w1 = ((uint64_t *)(cq0 + CQE_SZ(3)))[1];
 
 		if (flags & NIX_RX_OFFLOAD_RSS_F) {
-			/* Fill rss in the rx_descriptor_fields1 */
+			/* Fill rss in the mbuf_rx_descriptor_fields1 */
 			f0 = vsetq_lane_u32(cq0_w0, f0, 3);
 			f1 = vsetq_lane_u32(cq1_w0, f1, 3);
 			f2 = vsetq_lane_u32(cq2_w0, f2, 3);
@@ -649,7 +649,7 @@
 		}
 
 		if (flags & NIX_RX_OFFLOAD_PTYPE_F) {
-			/* Fill packet_type in the rx_descriptor_fields1 */
+			/* Fill packet_type in the mbuf_rx_descriptor_fields1 */
 			f0 = vsetq_lane_u32(nix_ptype_get(lookup_mem, cq0_w1),
 					    f0, 0);
 			f1 = vsetq_lane_u32(nix_ptype_get(lookup_mem, cq1_w1),
@@ -792,23 +792,23 @@
 			}
 		}
 
-		/* Form rearm_data with ol_flags */
+		/* Form mbuf_rearm_data with ol_flags */
 		rearm0 = vsetq_lane_u64(ol_flags0, rearm0, 1);
 		rearm1 = vsetq_lane_u64(ol_flags1, rearm1, 1);
 		rearm2 = vsetq_lane_u64(ol_flags2, rearm2, 1);
 		rearm3 = vsetq_lane_u64(ol_flags3, rearm3, 1);
 
-		/* Update rx_descriptor_fields1 */
-		vst1q_u64((uint64_t *)mbuf0->rx_descriptor_fields1, f0);
-		vst1q_u64((uint64_t *)mbuf1->rx_descriptor_fields1, f1);
-		vst1q_u64((uint64_t *)mbuf2->rx_descriptor_fields1, f2);
-		vst1q_u64((uint64_t *)mbuf3->rx_descriptor_fields1, f3);
-
-		/* Update rearm_data */
-		vst1q_u64((uint64_t *)mbuf0->rearm_data, rearm0);
-		vst1q_u64((uint64_t *)mbuf1->rearm_data, rearm1);
-		vst1q_u64((uint64_t *)mbuf2->rearm_data, rearm2);
-		vst1q_u64((uint64_t *)mbuf3->rearm_data, rearm3);
+		/* Update mbuf_rx_descriptor_fields1 */
+		vst1q_u64((uint64_t *)mbuf0->mbuf_rx_descriptor_fields1, f0);
+		vst1q_u64((uint64_t *)mbuf1->mbuf_rx_descriptor_fields1, f1);
+		vst1q_u64((uint64_t *)mbuf2->mbuf_rx_descriptor_fields1, f2);
+		vst1q_u64((uint64_t *)mbuf3->mbuf_rx_descriptor_fields1, f3);
+
+		/* Update mbuf_rearm_data */
+		vst1q_u64((uint64_t *)mbuf0->mbuf_rearm_data, rearm0);
+		vst1q_u64((uint64_t *)mbuf1->mbuf_rearm_data, rearm1);
+		vst1q_u64((uint64_t *)mbuf2->mbuf_rearm_data, rearm2);
+		vst1q_u64((uint64_t *)mbuf3->mbuf_rearm_data, rearm3);
 
 		if (flags & NIX_RX_MULTI_SEG_F) {
 			/* Multi segment is enable build mseg list for
drivers/net/cnxk/cnxk_ethdev.c +2 -2
index 5e11bbb..4a02e35 100644
@@ -435,9 +435,9 @@
 	mb_def.port = port_id;
 	rte_mbuf_refcnt_set(&mb_def, 1);
 
-	/* Prevent compiler reordering: rearm_data covers previous fields */
+	/* Prevent compiler reordering: mbuf_rearm_data covers previous fields */
 	rte_compiler_barrier();
-	tmp = (uint64_t *)&mb_def.rearm_data;
+	tmp = (uint64_t *)&mb_def.mbuf_rearm_data;
 
 	return *tmp;
 }
Signature · 1 line
1.8.3.1
#51 lore raw

PATCH v4 17/18 common/idpf: stop using zero sized marker fields

In reply to Tyler Retzlaff

Update to reference newly named anonymous union markers supported by standard C and stop referencing zero sized compiler extension markers.

---
 drivers/common/idpf/idpf_common_rxtx.c        |  4 +-
 drivers/common/idpf/idpf_common_rxtx_avx512.c | 60 +++++++++++++--------------
 2 files changed, 32 insertions(+), 32 deletions(-)
drivers/common/idpf/idpf_common_rxtx.c +2 -2
index 83b131e..06f1e9d 100644
@@ -1603,9 +1603,9 @@
 	mb_def.port = rxq->port_id;
 	rte_mbuf_refcnt_set(&mb_def, 1);
 
-	/* prevent compiler reordering: rearm_data covers previous fields */
+	/* prevent compiler reordering: mbuf_rearm_data covers previous fields */
 	rte_compiler_barrier();
-	p = (uintptr_t)&mb_def.rearm_data;
+	p = (uintptr_t)&mb_def.mbuf_rearm_data;
 	rxq->mbuf_initializer = *(uint64_t *)p;
 	return 0;
 }
drivers/common/idpf/idpf_common_rxtx_avx512.c +30 -30

128 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#52 lore raw

PATCH v4 18/18 examples/dma: stop using zero sized marker fields

In reply to Tyler Retzlaff

Update to reference newly named anonymous union markers supported by standard C and stop referencing zero sized compiler extension markers.

---
 examples/dma/dmafwd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
examples/dma/dmafwd.c +2 -2
index f4a0bff..60313da 100644
@@ -294,9 +294,9 @@ struct dma_bufs {
 pktmbuf_metadata_copy(const struct rte_mbuf *src, struct rte_mbuf *dst)
 {
 	dst->data_off = src->data_off;
-	memcpy(&dst->rx_descriptor_fields1, &src->rx_descriptor_fields1,
+	memcpy(&dst->mbuf_rx_descriptor_fields1, &src->mbuf_rx_descriptor_fields1,
 		offsetof(struct rte_mbuf, buf_len) -
-		offsetof(struct rte_mbuf, rx_descriptor_fields1));
+		offsetof(struct rte_mbuf, mbuf_rx_descriptor_fields1));
 }
 
 /* Copy packet data */
Signature · 1 line
1.8.3.1
#53 lore raw

RE: [PATCH v4 00/18] stop using zero sized marker fields

In reply to Tyler Retzlaff
Quoted 7 lines

From: Tyler Retzlaff [mailto:[email protected]]
Sent: Thursday, 15 February 2024 07.21

The zero sized RTE_MARKER<n> typedefs are a GCC extension unsupported by
MSVC. This series adds new fields and allows deprecation of the old.

Quoted 5 lines

Introduce new anonymous union fields with mbuf_ prefix for cacheline0, rearm_data, rx_descriptor_fields1, and cacheline1.

Remove in-tree use of the zero sized marker fields and adapt consuming code to use the new anonymous union fields.

#54 lore raw

v5 cover stop using RTE_MARKER extensions

In reply to Tyler Retzlaff

RTE_MARKER typedefs are a GCC extension unsupported by MSVC. This series hides the markers when building with MSVC and updates libraries and drivers to access compatibly typed pointers to the rte_mbuf struct offsets.

This series, does the following.

Introduces a new macro __rte_marker(type, name) which is used to conditionally expand RTE_MARKER fields empty when building with GCC.

Updates existing inline functions accessing cacheline{0,1} markers in the rte_mbuf struct to stop using the markers and instead uses the mbuf fields directly.

Introduces 2 new inline functions to allow drivers to access rearm_data and rx_descriptor_fields1 descriptors without using the RTE_MARKER fields.

Updates all drivers to use the new inline rte_mbuf struct accessors for rearm_data and rx_descriptor_fields1.

Any previous Acks on the series are considered to be reset due to amount of change.

v5:
* update existing cacheline{0, 1} inline functions to access actual mbuf fields.
* introduce new inline functions for accessing rearm_data and rx_descriptor_fields1 descriptors.
* adapt drivers to use new inline functions.

prior versions not relevant due to re-work of entire series.

Tyler Retzlaff (22):
eal: provide macro to expand marker extensions
mbuf: expand rte markers empty when building with MSVC
security: expand rte markers empty when building with MSVC
cryptodev: expand rte markers empty when building with MSVC
mbuf: stop using mbuf cacheline marker fields
mbuf: add mbuf descriptor accessors
common/idpf: use mbuf descriptor accessors net/bnxt: use mbuf descriptor accessors
net/cnxk: use mbuf descriptor accessors
net/enic: use mbuf descriptor accessors net/fm10k: use mbuf descriptor accessors net/hns3: use mbuf descriptor accessors
net/i40e: use mbuf descriptor accessors
net/iavf: use mbuf descriptor accessors
net/ice: use mbuf descriptor accessors
net/ionic: use mbuf descriptor accessors net/ixgbe: use mbuf descriptor accessors net/mlx5: use mbuf descriptor accessors net/octeon_ep: use mbuf descriptor accessors net/sfc: use mbuf descriptor accessors net/thunderx: use mbuf descriptor accessors net/virtio: use mbuf descriptor accessors

 drivers/common/idpf/idpf_common_rxtx.c          |  4 +--
 drivers/common/idpf/idpf_common_rxtx_avx512.c   | 33 ++++++++++++-----------
 drivers/net/bnxt/bnxt_rxtx_vec_avx2.c           | 32 +++++++++++-----------
 drivers/net/bnxt/bnxt_rxtx_vec_common.h         |  4 +--
 drivers/net/bnxt/bnxt_rxtx_vec_neon.c           | 16 +++++------
 drivers/net/bnxt/bnxt_rxtx_vec_sse.c            | 16 +++++------
 drivers/net/cnxk/cn10k_rx.h                     | 36 ++++++++++++-------------
 drivers/net/cnxk/cn9k_rx.h                      | 20 +++++++-------
 drivers/net/cnxk/cnxk_ethdev.c                  |  2 +-
 drivers/net/enic/enic_main.c                    |  4 +--
 drivers/net/enic/enic_rxtx_vec_avx2.c           | 18 ++++++-------
 drivers/net/fm10k/fm10k_rxtx_vec.c              | 19 +++++--------
 drivers/net/hns3/hns3_rxtx_vec.c                |  4 +--
 drivers/net/hns3/hns3_rxtx_vec_neon.h           | 16 +++++------
 drivers/net/i40e/i40e_rxtx_vec_altivec.c        | 18 +++++--------
 drivers/net/i40e/i40e_rxtx_vec_avx2.c           | 16 +++++------
 drivers/net/i40e/i40e_rxtx_vec_avx512.c         | 16 +++++------
 drivers/net/i40e/i40e_rxtx_vec_common.h         |  4 +--
 drivers/net/i40e/i40e_rxtx_vec_neon.c           | 16 +++++------
 drivers/net/i40e/i40e_rxtx_vec_sse.c            | 16 +++++------
 drivers/net/iavf/iavf_rxtx_vec_avx2.c           | 32 +++++++++++-----------
 drivers/net/iavf/iavf_rxtx_vec_avx512.c         | 32 +++++++++++-----------
 drivers/net/iavf/iavf_rxtx_vec_common.h         |  4 +--
 drivers/net/iavf/iavf_rxtx_vec_neon.c           | 16 +++++------
 drivers/net/iavf/iavf_rxtx_vec_sse.c            | 32 +++++++++++-----------
 drivers/net/ice/ice_rxtx_vec_avx2.c             | 16 +++++------
 drivers/net/ice/ice_rxtx_vec_avx512.c           | 16 +++++------
 drivers/net/ice/ice_rxtx_vec_common.h           |  4 +--
 drivers/net/ice/ice_rxtx_vec_sse.c              | 16 +++++------
 drivers/net/ionic/ionic_lif.c                   |  4 +--
 drivers/net/ionic/ionic_rxtx_sg.c               |  4 +--
 drivers/net/ionic/ionic_rxtx_simple.c           |  2 +-
 drivers/net/ixgbe/ixgbe_rxtx_vec_common.h       |  4 +--
 drivers/net/ixgbe/ixgbe_rxtx_vec_neon.c         | 12 ++++-----
 drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c          | 24 ++++++++---------
 drivers/net/mlx5/mlx5_rxq.c                     |  2 +-
 drivers/net/mlx5/mlx5_rxtx_vec_altivec.h        | 28 +++++++++----------
 drivers/net/mlx5/mlx5_rxtx_vec_neon.h           | 20 +++++++-------
 drivers/net/mlx5/mlx5_rxtx_vec_sse.h            | 28 +++++++++----------
 drivers/net/octeon_ep/cnxk_ep_rx.h              |  2 +-
 drivers/net/octeon_ep/cnxk_ep_rx_avx.c          |  2 +-
 drivers/net/octeon_ep/cnxk_ep_rx_neon.c         |  8 +++---
 drivers/net/octeon_ep/cnxk_ep_rx_sse.c          |  8 +++---
 drivers/net/octeon_ep/otx_ep_rxtx.c             |  5 +---
 drivers/net/sfc/sfc_ef100_rx.c                  |  4 +--
 drivers/net/sfc/sfc_ef10_rx.c                   |  6 ++---
 drivers/net/thunderx/nicvf_ethdev.c             |  4 +--
 drivers/net/thunderx/nicvf_rxtx.h               |  4 +--
 drivers/net/virtio/virtio_rxtx_packed_avx.h     | 10 +++----
 drivers/net/virtio/virtio_rxtx_packed_neon.h    | 16 +++++------
 drivers/net/virtio/virtio_rxtx_simple.c         |  4 +--
 drivers/net/virtio/virtio_rxtx_simple.h         |  5 +---
 drivers/net/virtio/virtio_rxtx_simple_altivec.c | 16 +++++------
 drivers/net/virtio/virtio_rxtx_simple_neon.c    | 24 ++++++-----------
 drivers/net/virtio/virtio_rxtx_simple_sse.c     | 16 +++++------
 lib/cryptodev/cryptodev_pmd.h                   |  5 ++--
 lib/eal/include/rte_common.h                    |  8 +++++-
 lib/mbuf/rte_mbuf.h                             | 28 +++++++++++++++++--
 lib/mbuf/rte_mbuf_core.h                        | 10 +++----
 lib/security/rte_security_driver.h              |  5 ++--
 60 files changed, 392 insertions(+), 404 deletions(-)
Signature · 1 line
1.8.3.1
#55 lore raw

PATCH v5 1/22 eal: provide macro to expand marker extensions

RTE_MARKER typedefs are a GCC extension unsupported by MSVC. Provide a new macro __rte_marker(type, name) that may be used to expand RTE_MARKER empty in struct definitions when building with MSVC.

---
 lib/eal/include/rte_common.h | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
lib/eal/include/rte_common.h +7 -1
index 1cc1222..60d81a2 100644
@@ -578,7 +578,11 @@ static void __attribute__((destructor(RTE_PRIO(prio)), used)) func(void)
 
 /*********** Structure alignment markers ********/
 
-#ifndef RTE_TOOLCHAIN_MSVC
+#ifdef RTE_TOOLCHAIN_MSVC
+
+#define __rte_marker(type, name)
+
+#else
 
 /** Generic marker for any place in a structure. */
 __extension__ typedef void    *RTE_MARKER[0];
@@ -591,6 +595,8 @@ static void __attribute__((destructor(RTE_PRIO(prio)), used)) func(void)
 /** Marker for 8B alignment in a structure. */
 __extension__ typedef uint64_t RTE_MARKER64[0];
 
+#define __rte_marker(type, name) type name;
+
 #endif
 
 /*********** Macros for calculating min and max **********/
Signature · 1 line
1.8.3.1
#56 lore raw

Re: [PATCH v5 01/22] eal: provide macro to expand marker extensions

24/02/2024 09:21, Tyler Retzlaff:

Quoted 3 lines

RTE_MARKER typedefs are a GCC extension unsupported by MSVC. Provide a new macro __rte_marker(type, name) that may be used to expand RTE_MARKER empty in struct definitions when building with MSVC.

I don't think we need to define a new marker macro.
I propose to simply not define them with MSVC, triggering a compilation error. So we keep the old markers for applications which were not using MSVC anyway. And inside DPDK libraries and drivers, we remove their usages.

#57 lore raw

Re: [PATCH v5 01/22] eal: provide macro to expand marker extensions

24/02/2024 11:51, Thomas Monjalon:

Quoted 9 lines

24/02/2024 09:21, Tyler Retzlaff:

Quoted 3 lines

RTE_MARKER typedefs are a GCC extension unsupported by MSVC. Provide a new macro __rte_marker(type, name) that may be used to expand RTE_MARKER empty in struct definitions when building with MSVC.

I don't think we need to define a new marker macro.
I propose to simply not define them with MSVC, triggering a compilation error. So we keep the old markers for applications which were not using MSVC anyway. And inside DPDK libraries and drivers, we remove their usages.

One more thing to fix:
When padding is done on the marker, example:

	RTE_MARKER cacheline1 __rte_cache_min_aligned;

We need to move alignment on the first real field, while keeping compatibility with the marker. I'm afraid we need to have alignment done only once.

It may be difficult without using #ifdef inside the struct.

It's probably easier to replace alignment with explicit padding.

#58 lore raw

PATCH v5 2/22 mbuf: expand rte markers empty when building with MSVC

In reply to Tyler Retzlaff

RTE_MARKER typedefs are a GCC extension unsupported by MSVC. Use __rte_marker to expand RTE_MARKER fields empty in rte_mbuf struct.

Make slight adjustment to cacheline1 __rte_cache_min_aligned as to continue maintaining correct alignment with or without the marker expanding empty.

---
 lib/mbuf/rte_mbuf_core.h | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
lib/mbuf/rte_mbuf_core.h +5 -5
index 5688683..4bf4587 100644
@@ -464,7 +464,7 @@ enum {
  * The generic rte_mbuf, containing a packet mbuf.
  */
 struct rte_mbuf {
-	RTE_MARKER cacheline0;
+	__rte_marker(RTE_MARKER, cacheline0)
 
 	void *buf_addr;           /**< Virtual address of segment buffer. */
 #if RTE_IOVA_IN_MBUF
@@ -487,7 +487,7 @@ struct rte_mbuf {
 #endif
 
 	/* next 8 bytes are initialised on RX descriptor rearm */
-	RTE_MARKER64 rearm_data;
+	__rte_marker(RTE_MARKER64, rearm_data)
 	uint16_t data_off;
 
 	/**
@@ -514,7 +514,7 @@ struct rte_mbuf {
 	uint64_t ol_flags;        /**< Offload features. */
 
 	/* remaining bytes are set on RX when pulling packet from descriptor */
-	RTE_MARKER rx_descriptor_fields1;
+	__rte_marker(RTE_MARKER, rx_descriptor_fields1)
 
 	/*
 	 * The packet type, which is the combination of outer/inner L2, L3, L4
@@ -595,8 +595,8 @@ struct rte_mbuf {
 	struct rte_mempool *pool; /**< Pool from which mbuf was allocated. */
 
 	/* second cache line - fields only used in slow path or on TX */
-	RTE_MARKER cacheline1 __rte_cache_min_aligned;
-
+	__rte_cache_min_aligned
+	__rte_marker(RTE_MARKER, cacheline1)
 #if RTE_IOVA_IN_MBUF
 	/**
 	 * Next segment of scattered packet. Must be NULL in the last
Signature · 1 line
1.8.3.1
#59 lore raw

PATCH v5 3/22 security: expand rte markers empty when building with MSVC

In reply to Tyler Retzlaff

RTE_MARKER typedefs are a GCC extension unsupported by MSVC. Use __rte_marker to expand RTE_MARKER fields empty in rte_security_session struct.

Make slight adjustment to cacheline1 __rte_cache_min_aligned as to continue maintaining correct alignment with or without the marker expanding empty.

---
 lib/security/rte_security_driver.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
lib/security/rte_security_driver.h +3 -2
index faa4074..a25ccd0 100644
@@ -24,7 +24,7 @@
  * Security session to be used by library for internal usage
  */
 struct rte_security_session {
-	RTE_MARKER cacheline0;
+	__rte_marker(RTE_MARKER, cacheline0)
 	uint64_t opaque_data;
 	/**< Opaque user defined data */
 	uint64_t fast_mdata;
@@ -32,7 +32,8 @@ struct rte_security_session {
 	rte_iova_t driver_priv_data_iova;
 	/**< session private data IOVA address */
 
-	RTE_MARKER cacheline1 __rte_cache_min_aligned;
+	 __rte_cache_min_aligned
+	__rte_marker(RTE_MARKER, cacheline1)
 	uint8_t driver_priv_data[];
 	/**< Private session material, variable size (depends on driver) */
 };
Signature · 1 line
1.8.3.1
#60 lore raw

PATCH v5 4/22 cryptodev: expand rte markers empty when building with MSVC

In reply to Tyler Retzlaff

RTE_MARKER typedefs are a GCC extension unsupported by MSVC. Use __rte_marker to expand RTE_MARKER fields empty in rte_security_session struct.

Make slight adjustment to cacheline1 __rte_cache_min_aligned as to continue maintaining correct alignment with or without the marker expanding empty.

---
 lib/cryptodev/cryptodev_pmd.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
lib/cryptodev/cryptodev_pmd.h +3 -2
index 0732b35..1d4810c 100644
@@ -139,7 +139,7 @@ struct cryptodev_driver {
  * has a fixed algo, key, op-type, digest_len etc.
  */
 struct rte_cryptodev_sym_session {
-	RTE_MARKER cacheline0;
+	__rte_marker(RTE_MARKER, cacheline0)
 	uint64_t opaque_data;
 	/**< Can be used for external metadata */
 	uint32_t sess_data_sz;
@@ -151,7 +151,8 @@ struct rte_cryptodev_sym_session {
 	rte_iova_t driver_priv_data_iova;
 	/**< Session driver data IOVA address */
 
-	RTE_MARKER cacheline1 __rte_cache_min_aligned;
+	__rte_cache_min_aligned
+	__rte_marker(RTE_MARKER, cacheline1)
 	/**< Second cache line - start of the driver session data */
 	uint8_t driver_priv_data[];
 	/**< Driver specific session data, variable size */
Signature · 1 line
1.8.3.1
#61 lore raw

PATCH v5 5/22 mbuf: stop using mbuf cacheline marker fields

In reply to Tyler Retzlaff

Update prefetch inline functions to access rte_mbuf struct fields directly instead of via cacheline{0,1} marker extension fields.

---
 lib/mbuf/rte_mbuf.h | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
lib/mbuf/rte_mbuf.h +6 -2
index 286b32b..04cde0f 100644
@@ -108,7 +108,7 @@
 static inline void
 rte_mbuf_prefetch_part1(struct rte_mbuf *m)
 {
-	rte_prefetch0(&m->cacheline0);
+	rte_prefetch0(&m->buf_addr);
 }
 
 /**
@@ -126,7 +126,11 @@
 rte_mbuf_prefetch_part2(struct rte_mbuf *m)
 {
 #if RTE_CACHE_LINE_SIZE == 64
-	rte_prefetch0(&m->cacheline1);
+#if RTE_IOVA_IN_MBUF
+	rte_prefetch0(&m->next);
+#else
+	rte_prefetch0(&m->dynfield2);
+#endif
 #else
 	RTE_SET_USED(m);
 #endif
Signature · 1 line
1.8.3.1
#62 lore raw

Re: [PATCH v5 05/22] mbuf: stop using mbuf cacheline marker fields

24/02/2024 09:21, Tyler Retzlaff:

Quoted 4 lines

Update prefetch inline functions to access rte_mbuf struct fields directly instead of via cacheline{0,1} marker extension fields.

[...]

lib/mbuf/rte_mbuf.h line 111

Quoted 4 lines

rte_mbuf_prefetch_part1(struct rte_mbuf *m)
{

lib/mbuf/rte_mbuf.h +1 -1
-	rte_prefetch0(&m->cacheline0);
+	rte_prefetch0(&m->buf_addr);

Should be simply "m", no need to point to the first field explicitly.

[...]

lib/mbuf/rte_mbuf.h line 133

Quoted 9 lines

rte_mbuf_prefetch_part2(struct rte_mbuf *m)
{
#if RTE_CACHE_LINE_SIZE == 64

lib/mbuf/rte_mbuf.h +5 -1
-	rte_prefetch0(&m->cacheline1);
+#if RTE_IOVA_IN_MBUF
+	rte_prefetch0(&m->next);
+#else
+	rte_prefetch0(&m->dynfield2);
+#endif

I think it is better to calculate m + min cache line size instead of relying on fields.

#63 lore raw

Re: [PATCH v5 05/22] mbuf: stop using mbuf cacheline marker fields

Quoted 14 lines · On Sat, 24 Feb 2024 11:58:59 +0100 Thomas Monjalon <[email protected]> wrote:

24/02/2024 09:21, Tyler Retzlaff:

Quoted 4 lines

Update prefetch inline functions to access rte_mbuf struct fields directly instead of via cacheline{0,1} marker extension fields.

[...]

lib/mbuf/rte_mbuf.h line 111

Quoted 4 lines

rte_mbuf_prefetch_part1(struct rte_mbuf *m)
{

lib/mbuf/rte_mbuf.h +1 -1
-	rte_prefetch0(&m->cacheline0);
+	rte_prefetch0(&m->buf_addr);  

Should be simply "m", no need to point to the first field explicitly.

[...]

Quoted 14 lines

lib/mbuf/rte_mbuf.h line 133

Quoted 9 lines

rte_mbuf_prefetch_part2(struct rte_mbuf *m)
{
#if RTE_CACHE_LINE_SIZE == 64

lib/mbuf/rte_mbuf.h +5 -1
-	rte_prefetch0(&m->cacheline1);
+#if RTE_IOVA_IN_MBUF
+	rte_prefetch0(&m->next);
+#else
+	rte_prefetch0(&m->dynfield2);
+#endif  

I think it is better to calculate m + min cache line size instead of relying on fields.

Agree with Thomas, the markers and field dependency are bad idea.

#64 lore raw

PATCH v5 6/22 mbuf: add mbuf descriptor accessors

In reply to Tyler Retzlaff

Provide inline functions to access rearm data and rx descriptor fields in rte_mbuf struct.

---
 lib/mbuf/rte_mbuf.h | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
lib/mbuf/rte_mbuf.h +20 -0
index 04cde0f..7993730 100644
@@ -136,6 +136,26 @@
 #endif
 }
 
+static inline
+uint64_t *
+rte_mbuf_rearm_data(struct rte_mbuf *m)
+{
+	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, ol_flags) !=
+			 offsetof(struct rte_mbuf, data_off) + 8);
+	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, rearm_data) !=
+			 RTE_ALIGN(offsetof(struct rte_mbuf,
+					    data_off),
+					    16));
+
+	return (uint64_t *)&m->data_off;
+}
+
+static inline
+void *
+rte_mbuf_rx_descriptor_fields1(struct rte_mbuf *m)
+{
+	return &m->packet_type;
+}
 
 static inline uint16_t rte_pktmbuf_priv_size(struct rte_mempool *mp);
 
Signature · 1 line
1.8.3.1
#65 lore raw

Re: [PATCH v5 06/22] mbuf: add mbuf descriptor accessors

24/02/2024 09:21, Tyler Retzlaff:

Quoted 2 lines

Provide inline functions to access rearm data and rx descriptor fields in rte_mbuf struct.

[...]

Quoted 10 lines
lib/mbuf/rte_mbuf.h +10 -0
+static inline
+uint64_t *
+rte_mbuf_rearm_data(struct rte_mbuf *m)
+{
+	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, ol_flags) !=
+			 offsetof(struct rte_mbuf, data_off) + 8);
+	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, rearm_data) !=
+			 RTE_ALIGN(offsetof(struct rte_mbuf,
+					    data_off),
+					    16));

lib/mbuf/rte_mbuf.h line 158

Quoted 10 lines
lib/mbuf/rte_mbuf.h +10 -0
+
+	return (uint64_t *)&m->data_off;
+}
+
+static inline
+void *
+rte_mbuf_rx_descriptor_fields1(struct rte_mbuf *m)
+{
+	return &m->packet_type;
+}

We need to enforce usage of these accessors.
Please add these 2 things:
1/ comments in the mbuf structure to encourage using these functions 2/ checkpatch warning if using the markers directly in new code

#66 lore raw

PATCH v5 7/22 common/idpf: use mbuf descriptor accessors

In reply to Tyler Retzlaff

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.

---
 drivers/common/idpf/idpf_common_rxtx.c        |  4 +---
 drivers/common/idpf/idpf_common_rxtx_avx512.c | 33 ++++++++++++++-------------
 2 files changed, 18 insertions(+), 19 deletions(-)
drivers/common/idpf/idpf_common_rxtx.c +1 -3
index 83b131e..62ddf2e 100644
@@ -1595,7 +1595,6 @@
 static inline int
 idpf_rxq_vec_setup_default(struct idpf_rx_queue *rxq)
 {
-	uintptr_t p;
 	struct rte_mbuf mb_def = { .buf_addr = 0 }; /* zeroed mbuf */
 
 	mb_def.nb_segs = 1;
@@ -1605,8 +1604,7 @@
 
 	/* 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);
 	return 0;
 }
 
drivers/common/idpf/idpf_common_rxtx_avx512.c +17 -16
index f65e8d5..f978a27 100644
@@ -462,6 +462,7 @@
 				 RTE_ALIGN(offsetof(struct rte_mbuf,
 						    rearm_data),
 						    16));
+
 		/* build up data and do writes */
 		__m256i rearm0, rearm1, rearm2, rearm3, rearm4, rearm5,
 			rearm6, rearm7;
@@ -476,13 +477,13 @@
 		rearm0 = _mm256_permute2f128_si256(mbuf_init, mb0_1, 0x20);
 
 		/* write to mbuf */
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 6]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 6]),
 				    rearm6);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 4]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 4]),
 				    rearm4);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 2]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 2]),
 				    rearm2);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 0]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 0]),
 				    rearm0);
 
 		rearm7 = _mm256_blend_epi32(mbuf_init, mb6_7, 0xF0);
@@ -491,13 +492,13 @@
 		rearm1 = _mm256_blend_epi32(mbuf_init, mb0_1, 0xF0);
 
 		/* again write to mbufs */
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 7]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 7]),
 				    rearm7);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 5]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 5]),
 				    rearm5);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 3]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 3]),
 				    rearm3);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 1]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 1]),
 				    rearm1);
 
 		/* perform dd_check */
@@ -936,13 +937,13 @@
 		rearm0 = _mm256_permute2f128_si256(mbuf_init, mb0_1, 0x20);
 
 		/* write to mbuf */
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 6]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 6]),
 				    rearm6);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 4]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 4]),
 				    rearm4);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 2]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 2]),
 				    rearm2);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 0]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 0]),
 				    rearm0);
 
 		rearm7 = _mm256_blend_epi32(mbuf_init, mb6_7, 0xF0);
@@ -951,13 +952,13 @@
 		rearm1 = _mm256_blend_epi32(mbuf_init, mb0_1, 0xF0);
 
 		/* again write to mbufs */
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 7]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 7]),
 				    rearm7);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 5]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 5]),
 				    rearm5);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 3]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 3]),
 				    rearm3);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 1]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 1]),
 				    rearm1);
 
 		const __mmask8 dd_mask = _mm512_cmpeq_epi64_mask(
Signature · 1 line
1.8.3.1
#67 lore raw

PATCH v5 8/22 net/bnxt: use mbuf descriptor accessors

In reply to Tyler Retzlaff

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.

---
 drivers/net/bnxt/bnxt_rxtx_vec_avx2.c   | 32 ++++++++++++++++----------------
 drivers/net/bnxt/bnxt_rxtx_vec_common.h |  4 +---
 drivers/net/bnxt/bnxt_rxtx_vec_neon.c   | 16 ++++++++--------
 drivers/net/bnxt/bnxt_rxtx_vec_sse.c    | 16 ++++++++--------
 4 files changed, 33 insertions(+), 35 deletions(-)
drivers/net/bnxt/bnxt_rxtx_vec_avx2.c +16 -16
index ce6b597..5982d12 100644
@@ -310,13 +310,13 @@
 					    0x04);
 
 		/* Store all mbuf fields for first four packets. */
-		_mm256_storeu_si256((void *)&rx_pkts[i + 0]->rearm_data,
+		_mm256_storeu_si256((void *)rte_mbuf_rearm_data(rx_pkts[i + 0]),
 				    rearm0);
-		_mm256_storeu_si256((void *)&rx_pkts[i + 1]->rearm_data,
+		_mm256_storeu_si256((void *)rte_mbuf_rearm_data(rx_pkts[i + 1]),
 				    rearm1);
-		_mm256_storeu_si256((void *)&rx_pkts[i + 2]->rearm_data,
+		_mm256_storeu_si256((void *)rte_mbuf_rearm_data(rx_pkts[i + 2]),
 				    rearm2);
-		_mm256_storeu_si256((void *)&rx_pkts[i + 3]->rearm_data,
+		_mm256_storeu_si256((void *)rte_mbuf_rearm_data(rx_pkts[i + 3]),
 				    rearm3);
 
 		/* Unpack rearm data, set fixed fields for final four mbufs. */
@@ -336,13 +336,13 @@
 					    0x04);
 
 		/* Store all mbuf fields for final four packets. */
-		_mm256_storeu_si256((void *)&rx_pkts[i + 4]->rearm_data,
+		_mm256_storeu_si256((void *)rte_mbuf_rearm_data(rx_pkts[i + 4]),
 				    rearm4);
-		_mm256_storeu_si256((void *)&rx_pkts[i + 5]->rearm_data,
+		_mm256_storeu_si256((void *)rte_mbuf_rearm_data(rx_pkts[i + 5]),
 				    rearm5);
-		_mm256_storeu_si256((void *)&rx_pkts[i + 6]->rearm_data,
+		_mm256_storeu_si256((void *)rte_mbuf_rearm_data(rx_pkts[i + 6]),
 				    rearm6);
-		_mm256_storeu_si256((void *)&rx_pkts[i + 7]->rearm_data,
+		_mm256_storeu_si256((void *)rte_mbuf_rearm_data(rx_pkts[i + 7]),
 				    rearm7);
 
 		nb_rx_pkts += num_valid;
@@ -598,13 +598,13 @@
 					    0x04);
 
 		/* Store all mbuf fields for first four packets. */
-		_mm256_storeu_si256((void *)&rx_pkts[i + 0]->rearm_data,
+		_mm256_storeu_si256((void *)rte_mbuf_rearm_data(rx_pkts[i + 0]),
 				    rearm0);
-		_mm256_storeu_si256((void *)&rx_pkts[i + 1]->rearm_data,
+		_mm256_storeu_si256((void *)rte_mbuf_rearm_data(rx_pkts[i + 1]),
 				    rearm1);
-		_mm256_storeu_si256((void *)&rx_pkts[i + 2]->rearm_data,
+		_mm256_storeu_si256((void *)rte_mbuf_rearm_data(rx_pkts[i + 2]),
 				    rearm2);
-		_mm256_storeu_si256((void *)&rx_pkts[i + 3]->rearm_data,
+		_mm256_storeu_si256((void *)rte_mbuf_rearm_data(rx_pkts[i + 3]),
 				    rearm3);
 
 		/* Unpack rearm data, set fixed fields for final four mbufs. */
@@ -624,13 +624,13 @@
 					    0x04);
 
 		/* Store all mbuf fields for final four packets. */
-		_mm256_storeu_si256((void *)&rx_pkts[i + 4]->rearm_data,
+		_mm256_storeu_si256((void *)rte_mbuf_rearm_data(rx_pkts[i + 4]),
 				    rearm4);
-		_mm256_storeu_si256((void *)&rx_pkts[i + 5]->rearm_data,
+		_mm256_storeu_si256((void *)rte_mbuf_rearm_data(rx_pkts[i + 5]),
 				    rearm5);
-		_mm256_storeu_si256((void *)&rx_pkts[i + 6]->rearm_data,
+		_mm256_storeu_si256((void *)rte_mbuf_rearm_data(rx_pkts[i + 6]),
 				    rearm6);
-		_mm256_storeu_si256((void *)&rx_pkts[i + 7]->rearm_data,
+		_mm256_storeu_si256((void *)rte_mbuf_rearm_data(rx_pkts[i + 7]),
 				    rearm7);
 
 		nb_rx_pkts += num_valid;
drivers/net/bnxt/bnxt_rxtx_vec_common.h +1 -3
index 2294f0a..fb0b1c1 100644
@@ -36,7 +36,6 @@
 static inline int
 bnxt_rxq_vec_setup_common(struct bnxt_rx_queue *rxq)
 {
-	uintptr_t p;
 	struct rte_mbuf mb_def = { .buf_addr = 0 }; /* zeroed mbuf */
 
 	mb_def.nb_segs = 1;
@@ -46,8 +45,7 @@
 
 	/* 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);
 	rxq->rxrearm_nb = 0;
 	rxq->rxrearm_start = 0;
 	return 0;
drivers/net/bnxt/bnxt_rxtx_vec_neon.c +8 -8
index 775400f..9ca9903 100644
@@ -135,27 +135,27 @@
 
 	/* Update mbuf rearm_data for four packets. */
 	GET_OL_FLAGS(rss_flags, index, errors, 0, ol_flags);
-	vst1q_u32((uint32_t *)&mbuf[0]->rearm_data,
+	vst1q_u32((uint32_t *)rte_mbuf_rearm_data(mbuf[0]),
 		  vsetq_lane_u32(ol_flags, vreinterpretq_u32_u64(mb_init), 2));
 	GET_OL_FLAGS(rss_flags, index, errors, 1, ol_flags);
-	vst1q_u32((uint32_t *)&mbuf[1]->rearm_data,
+	vst1q_u32((uint32_t *)rte_mbuf_rearm_data(mbuf[1]),
 		  vsetq_lane_u32(ol_flags, vreinterpretq_u32_u64(mb_init), 2));
 	GET_OL_FLAGS(rss_flags, index, errors, 2, ol_flags);
-	vst1q_u32((uint32_t *)&mbuf[2]->rearm_data,
+	vst1q_u32((uint32_t *)rte_mbuf_rearm_data(mbuf[2]),
 		  vsetq_lane_u32(ol_flags, vreinterpretq_u32_u64(mb_init), 2));
 	GET_OL_FLAGS(rss_flags, index, errors, 3, ol_flags);
-	vst1q_u32((uint32_t *)&mbuf[3]->rearm_data,
+	vst1q_u32((uint32_t *)rte_mbuf_rearm_data(mbuf[3]),
 		  vsetq_lane_u32(ol_flags, vreinterpretq_u32_u64(mb_init), 2));
 
 	/* Update mbuf rx_descriptor_fields1 for four packets. */
 	GET_DESC_FIELDS(mm_rxcmp[0], mm_rxcmp1[0], shuf_msk, ptype_idx, 0, tmp);
-	vst1q_u32((uint32_t *)&mbuf[0]->rx_descriptor_fields1, tmp);
+	vst1q_u32((uint32_t *)rte_mbuf_rx_descriptor_fields1(mbuf[0]), tmp);
 	GET_DESC_FIELDS(mm_rxcmp[1], mm_rxcmp1[1], shuf_msk, ptype_idx, 1, tmp);
-	vst1q_u32((uint32_t *)&mbuf[1]->rx_descriptor_fields1, tmp);
+	vst1q_u32((uint32_t *)rte_mbuf_rx_descriptor_fields1(mbuf[1]), tmp);
 	GET_DESC_FIELDS(mm_rxcmp[2], mm_rxcmp1[2], shuf_msk, ptype_idx, 2, tmp);
-	vst1q_u32((uint32_t *)&mbuf[2]->rx_descriptor_fields1, tmp);
+	vst1q_u32((uint32_t *)rte_mbuf_rx_descriptor_fields1(mbuf[2]), tmp);
 	GET_DESC_FIELDS(mm_rxcmp[3], mm_rxcmp1[3], shuf_msk, ptype_idx, 3, tmp);
-	vst1q_u32((uint32_t *)&mbuf[3]->rx_descriptor_fields1, tmp);
+	vst1q_u32((uint32_t *)rte_mbuf_rx_descriptor_fields1(mbuf[3]), tmp);
 }
 
 static uint16_t
drivers/net/bnxt/bnxt_rxtx_vec_sse.c +8 -8
index 6c0e332..080e990 100644
@@ -114,33 +114,33 @@
 
 	/* Update mbuf rearm_data for four packets. */
 	GET_OL_FLAGS(rss_flags, index, errors, 0, ol_flags);
-	_mm_store_si128((void *)&mbuf[0]->rearm_data,
+	_mm_store_si128((void *)rte_mbuf_rearm_data(mbuf[0]),
 			_mm_or_si128(mbuf_init, _mm_set_epi64x(ol_flags, 0)));
 
 	GET_OL_FLAGS(rss_flags, index, errors, 1, ol_flags);
-	_mm_store_si128((void *)&mbuf[1]->rearm_data,
+	_mm_store_si128((void *)rte_mbuf_rearm_data(mbuf[1]),
 			_mm_or_si128(mbuf_init, _mm_set_epi64x(ol_flags, 0)));
 
 	GET_OL_FLAGS(rss_flags, index, errors, 2, ol_flags);
-	_mm_store_si128((void *)&mbuf[2]->rearm_data,
+	_mm_store_si128((void *)rte_mbuf_rearm_data(mbuf[2]),
 			_mm_or_si128(mbuf_init, _mm_set_epi64x(ol_flags, 0)));
 
 	GET_OL_FLAGS(rss_flags, index, errors, 3, ol_flags);
-	_mm_store_si128((void *)&mbuf[3]->rearm_data,
+	_mm_store_si128((void *)rte_mbuf_rearm_data(mbuf[3]),
 			_mm_or_si128(mbuf_init, _mm_set_epi64x(ol_flags, 0)));
 
 	/* Update mbuf rx_descriptor_fields1 for four packes. */
 	GET_DESC_FIELDS(mm_rxcmp[0], mm_rxcmp1[0], shuf_msk, ptype_idx, 0, t0);
-	_mm_store_si128((void *)&mbuf[0]->rx_descriptor_fields1, t0);
+	_mm_store_si128(rte_mbuf_rx_descriptor_fields1(mbuf[0]), t0);
 
 	GET_DESC_FIELDS(mm_rxcmp[1], mm_rxcmp1[1], shuf_msk, ptype_idx, 1, t0);
-	_mm_store_si128((void *)&mbuf[1]->rx_descriptor_fields1, t0);
+	_mm_store_si128(rte_mbuf_rx_descriptor_fields1(mbuf[1]), t0);
 
 	GET_DESC_FIELDS(mm_rxcmp[2], mm_rxcmp1[2], shuf_msk, ptype_idx, 2, t0);
-	_mm_store_si128((void *)&mbuf[2]->rx_descriptor_fields1, t0);
+	_mm_store_si128(rte_mbuf_rx_descriptor_fields1(mbuf[2]), t0);
 
 	GET_DESC_FIELDS(mm_rxcmp[3], mm_rxcmp1[3], shuf_msk, ptype_idx, 3, t0);
-	_mm_store_si128((void *)&mbuf[3]->rx_descriptor_fields1, t0);
+	_mm_store_si128(rte_mbuf_rx_descriptor_fields1(mbuf[3]), t0);
 }
 
 static uint16_t
Signature · 1 line
1.8.3.1
#68 lore raw

PATCH v5 9/22 net/cnxk: use mbuf descriptor accessors

In reply to Tyler Retzlaff

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.

---
 drivers/net/cnxk/cn10k_rx.h    | 36 ++++++++++++++++++------------------
 drivers/net/cnxk/cn9k_rx.h     | 20 ++++++++++----------
 drivers/net/cnxk/cnxk_ethdev.c |  2 +-
 3 files changed, 29 insertions(+), 29 deletions(-)
drivers/net/cnxk/cn10k_rx.h +18 -18
index 7bb4c86..4bfb323 100644
@@ -309,7 +309,7 @@
 		frag_rx = (union nix_rx_parse_u *)(wqe + 1);
 		frag_size = rlen + frag_rx->lcptr - frag_rx->laptr;
 
-		*(uint64_t *)(&mbuf->rearm_data) = mbuf_init;
+		*rte_mbuf_rearm_data(mbuf) = mbuf_init;
 		mbuf->data_len = frag_size;
 		mbuf->pkt_len = frag_size;
 		mbuf->ol_flags = ol_flags;
@@ -368,7 +368,7 @@
 	fsz_w1 >>= 16;
 
 	data_off = b_off + frag_rx->lcptr + l3_hdr_size;
-	*(uint64_t *)(&mbuf->rearm_data) = mbuf_init | data_off;
+	*rte_mbuf_rearm_data(mbuf) = mbuf_init | data_off;
 	mbuf->data_len = frag_size;
 
 	/* Mark frag as get */
@@ -384,7 +384,7 @@
 		fsz_w1 >>= 16;
 
 		data_off = b_off + frag_rx->lcptr + l3_hdr_size;
-		*(uint64_t *)(&mbuf->rearm_data) = mbuf_init | data_off;
+		*rte_mbuf_rearm_data(mbuf) = mbuf_init | data_off;
 		mbuf->data_len = frag_size;
 
 		/* Mark frag as get */
@@ -401,7 +401,7 @@
 		fsz_w1 >>= 16;
 
 		data_off = b_off + frag_rx->lcptr + l3_hdr_size;
-		*(uint64_t *)(&mbuf->rearm_data) = mbuf_init | data_off;
+		*rte_mbuf_rearm_data(mbuf) = mbuf_init | data_off;
 		mbuf->data_len = frag_size;
 
 		/* Mark frag as get */
@@ -502,7 +502,7 @@
 
 	inner->pkt_len = len;
 	inner->data_len = len;
-	*(uint64_t *)(&inner->rearm_data) = mbuf_init;
+	*rte_mbuf_rearm_data(inner) = mbuf_init;
 
 	inner->ol_flags = ((CPT_COMP_HWGOOD_MASK & (1U << ucc)) ?
 			   RTE_MBUF_F_RX_SEC_OFFLOAD :
@@ -584,7 +584,7 @@
 			/* First frag len */
 			inner->pkt_len = vgetq_lane_u16(*rx_desc_field1, 2);
 			inner->data_len = vgetq_lane_u16(*rx_desc_field1, 4);
-			p = (uintptr_t)&inner->rearm_data;
+			p = (uintptr_t)rte_mbuf_rearm_data(inner);
 			*(uint64_t *)p = mbuf_init;
 
 			/* Reassembly success */
@@ -774,7 +774,7 @@
 
 		mbuf->data_len = sg_len;
 		sg = sg >> 16;
-		p = (uintptr_t)&mbuf->rearm_data;
+		p = (uintptr_t)rte_mbuf_rearm_data(mbuf);
 		*(uint64_t *)p = rearm & ~0xFFFF;
 		nb_segs--;
 		iova_list++;
@@ -825,7 +825,7 @@
 			head->nb_segs = nb_segs;
 		}
 		mbuf = next_frag;
-		p = (uintptr_t)&mbuf->rearm_data;
+		p = (uintptr_t)rte_mbuf_rearm_data(mbuf);
 		*(uint64_t *)p = rearm + ldptr;
 		mbuf->data_len = (sg & 0xFFFF) - ldptr -
 				 (flags & NIX_RX_OFFLOAD_TSTAMP_F ?
@@ -849,7 +849,7 @@
 
 
 		len = mbuf->pkt_len;
-		p = (uintptr_t)&mbuf->rearm_data;
+		p = (uintptr_t)rte_mbuf_rearm_data(mbuf);
 		*(uint64_t *)p = rearm;
 		mbuf->data_len = (sg & 0xFFFF) -
 				 (flags & NIX_RX_OFFLOAD_TSTAMP_F ?
@@ -917,7 +917,7 @@
 		mbuf->ol_flags = ol_flags;
 		mbuf->pkt_len = len;
 		mbuf->data_len = len;
-		p = (uintptr_t)&mbuf->rearm_data;
+		p = (uintptr_t)rte_mbuf_rearm_data(mbuf);
 		*(uint64_t *)p = val;
 	}
 
@@ -1966,16 +1966,16 @@
 		rearm3 = vsetq_lane_u64(ol_flags3, rearm3, 1);
 
 		/* Update rx_descriptor_fields1 */
-		vst1q_u64((uint64_t *)mbuf0->rx_descriptor_fields1, f0);
-		vst1q_u64((uint64_t *)mbuf1->rx_descriptor_fields1, f1);
-		vst1q_u64((uint64_t *)mbuf2->rx_descriptor_fields1, f2);
-		vst1q_u64((uint64_t *)mbuf3->rx_descriptor_fields1, f3);
+		vst1q_u64((uint64_t *)rte_mbuf_rx_descriptor_fields1(mbuf0), f0);
+		vst1q_u64((uint64_t *)rte_mbuf_rx_descriptor_fields1(mbuf1), f1);
+		vst1q_u64((uint64_t *)rte_mbuf_rx_descriptor_fields1(mbuf2), f2);
+		vst1q_u64((uint64_t *)rte_mbuf_rx_descriptor_fields1(mbuf3), f3);
 
 		/* Update rearm_data */
-		vst1q_u64((uint64_t *)mbuf0->rearm_data, rearm0);
-		vst1q_u64((uint64_t *)mbuf1->rearm_data, rearm1);
-		vst1q_u64((uint64_t *)mbuf2->rearm_data, rearm2);
-		vst1q_u64((uint64_t *)mbuf3->rearm_data, rearm3);
+		vst1q_u64(rte_mbuf_rearm_data(mbuf0), rearm0);
+		vst1q_u64(rte_mbuf_rearm_data(mbuf1), rearm1);
+		vst1q_u64(rte_mbuf_rearm_data(mbuf2), rearm2);
+		vst1q_u64(rte_mbuf_rearm_data(mbuf3), rearm3);
 
 		if (flags & NIX_RX_MULTI_SEG_F) {
 			/* Multi segment is enable build mseg list for
drivers/net/cnxk/cn9k_rx.h +10 -10
index d8bb65c..f1212f8 100644
@@ -155,7 +155,7 @@
 
 		mbuf->data_len = sg & 0xFFFF;
 		sg = sg >> 16;
-		*(uint64_t *)(&mbuf->rearm_data) = rearm;
+		*rte_mbuf_rearm_data(mbuf) = rearm;
 		nb_segs--;
 		iova_list++;
 
@@ -398,7 +398,7 @@
 			nix_update_match_id(rx->cn9k.match_id, ol_flags, mbuf);
 
 	mbuf->ol_flags = ol_flags;
-	*(uint64_t *)(&mbuf->rearm_data) = val;
+	*rte_mbuf_rearm_data(mbuf) = val;
 	mbuf->pkt_len = len;
 	mbuf->data_len = len;
 
@@ -799,16 +799,16 @@
 		rearm3 = vsetq_lane_u64(ol_flags3, rearm3, 1);
 
 		/* Update rx_descriptor_fields1 */
-		vst1q_u64((uint64_t *)mbuf0->rx_descriptor_fields1, f0);
-		vst1q_u64((uint64_t *)mbuf1->rx_descriptor_fields1, f1);
-		vst1q_u64((uint64_t *)mbuf2->rx_descriptor_fields1, f2);
-		vst1q_u64((uint64_t *)mbuf3->rx_descriptor_fields1, f3);
+		vst1q_u64((uint64_t *)rte_mbuf_rx_descriptor_fields1(mbuf0), f0);
+		vst1q_u64((uint64_t *)rte_mbuf_rx_descriptor_fields1(mbuf1), f1);
+		vst1q_u64((uint64_t *)rte_mbuf_rx_descriptor_fields1(mbuf2), f2);
+		vst1q_u64((uint64_t *)rte_mbuf_rx_descriptor_fields1(mbuf3), f3);
 
 		/* Update rearm_data */
-		vst1q_u64((uint64_t *)mbuf0->rearm_data, rearm0);
-		vst1q_u64((uint64_t *)mbuf1->rearm_data, rearm1);
-		vst1q_u64((uint64_t *)mbuf2->rearm_data, rearm2);
-		vst1q_u64((uint64_t *)mbuf3->rearm_data, rearm3);
+		vst1q_u64(rte_mbuf_rearm_data(mbuf0), rearm0);
+		vst1q_u64(rte_mbuf_rearm_data(mbuf1), rearm1);
+		vst1q_u64(rte_mbuf_rearm_data(mbuf2), rearm2);
+		vst1q_u64(rte_mbuf_rearm_data(mbuf3), rearm3);
 
 		if (flags & NIX_RX_MULTI_SEG_F) {
 			/* Multi segment is enable build mseg list for
drivers/net/cnxk/cnxk_ethdev.c +1 -1
index 2372a4e..14f6b7c 100644
@@ -437,7 +437,7 @@
 
 	/* Prevent compiler reordering: rearm_data covers previous fields */
 	rte_compiler_barrier();
-	tmp = (uint64_t *)&mb_def.rearm_data;
+	tmp = rte_mbuf_rearm_data(&mb_def);
 
 	return *tmp;
 }
Signature · 1 line
1.8.3.1
#69 lore raw

PATCH v5 10/22 net/enic: use mbuf descriptor accessors

In reply to Tyler Retzlaff

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.

---
 drivers/net/enic/enic_main.c          |  4 +---
 drivers/net/enic/enic_rxtx_vec_avx2.c | 18 +++++++++---------
 2 files changed, 10 insertions(+), 12 deletions(-)
drivers/net/enic/enic_main.c +1 -3
index a6aaa76..59e0be4 100644
@@ -577,7 +577,6 @@ int enic_enable(struct enic *enic)
 	int err;
 	struct rte_eth_dev *eth_dev = enic->rte_dev;
 	uint64_t simple_tx_offloads;
-	uintptr_t p;
 
 	if (enic->enable_avx2_rx) {
 		struct rte_mbuf mb_def = { .buf_addr = 0 };
@@ -592,8 +591,7 @@ int enic_enable(struct enic *enic)
 		mb_def.port = enic->port_id;
 		rte_mbuf_refcnt_set(&mb_def, 1);
 		rte_compiler_barrier();
-		p = (uintptr_t)&mb_def.rearm_data;
-		enic->mbuf_initializer = *(uint64_t *)p;
+		enic->mbuf_initializer = *rte_mbuf_rearm_data(&mb_def);
 	}
 
 	eth_dev->data->dev_link.link_speed = vnic_dev_port_speed(enic->vdev);
drivers/net/enic/enic_rxtx_vec_avx2.c +9 -9
index 600efff..f6ab6e1 100644
@@ -19,7 +19,7 @@
 {
 	bool tnl;
 
-	*(uint64_t *)&mb->rearm_data = enic->mbuf_initializer;
+	*rte_mbuf_rearm_data(mb) = enic->mbuf_initializer;
 	mb->data_len = cqd->bytes_written_flags &
 		CQ_ENET_RQ_DESC_BYTES_WRITTEN_MASK;
 	mb->pkt_len = mb->data_len;
@@ -737,14 +737,14 @@
 		 * vlan_tci    - 26     (from cqd)
 		 * rss         - 28     (from cqd)
 		 */
-		_mm256_storeu_si256((__m256i *)&rxmb[0]->rearm_data, rearm0);
-		_mm256_storeu_si256((__m256i *)&rxmb[1]->rearm_data, rearm1);
-		_mm256_storeu_si256((__m256i *)&rxmb[2]->rearm_data, rearm2);
-		_mm256_storeu_si256((__m256i *)&rxmb[3]->rearm_data, rearm3);
-		_mm256_storeu_si256((__m256i *)&rxmb[4]->rearm_data, rearm4);
-		_mm256_storeu_si256((__m256i *)&rxmb[5]->rearm_data, rearm5);
-		_mm256_storeu_si256((__m256i *)&rxmb[6]->rearm_data, rearm6);
-		_mm256_storeu_si256((__m256i *)&rxmb[7]->rearm_data, rearm7);
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rxmb[0]), rearm0);
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rxmb[1]), rearm1);
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rxmb[2]), rearm2);
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rxmb[3]), rearm3);
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rxmb[4]), rearm4);
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rxmb[5]), rearm5);
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rxmb[6]), rearm6);
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rxmb[7]), rearm7);
 
 		max_rx -= 8;
 		cqd += 8;
Signature · 1 line
1.8.3.1
#70 lore raw

PATCH v5 11/22 net/fm10k: use mbuf descriptor accessors

In reply to Tyler Retzlaff

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.

---
 drivers/net/fm10k/fm10k_rxtx_vec.c | 19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)
drivers/net/fm10k/fm10k_rxtx_vec.c +7 -12
index 2b6914b..e7d3810 100644
@@ -226,7 +226,6 @@
 int __rte_cold
 fm10k_rxq_vec_setup(struct fm10k_rx_queue *rxq)
 {
-	uintptr_t p;
 	struct rte_mbuf mb_def = { .buf_addr = 0 }; /* zeroed mbuf */
 
 	mb_def.nb_segs = 1;
@@ -239,8 +238,7 @@
 
 	/* 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);
 	return 0;
 }
 
@@ -282,7 +280,6 @@
 	/* Initialize the mbufs in vector, process 2 mbufs in one loop */
 	for (i = 0; i < RTE_FM10K_RXQ_REARM_THRESH; i += 2, mb_alloc += 2) {
 		__m128i vaddr0, vaddr1;
-		uintptr_t p0, p1;
 
 		mb0 = mb_alloc[0];
 		mb1 = mb_alloc[1];
@@ -290,10 +287,8 @@
 		/* Flush mbuf with pkt template.
 		 * Data to be rearmed is 6 bytes long.
 		 */
-		p0 = (uintptr_t)&mb0->rearm_data;
-		*(uint64_t *)p0 = rxq->mbuf_initializer;
-		p1 = (uintptr_t)&mb1->rearm_data;
-		*(uint64_t *)p1 = rxq->mbuf_initializer;
+		*rte_mbuf_rearm_data(mb0) = rxq->mbuf_initializer;
+		*rte_mbuf_rearm_data(mb1) = rxq->mbuf_initializer;
 
 		/* load buf_addr(lo 64bit) and buf_iova(hi 64bit) */
 		RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, buf_iova) !=
@@ -519,9 +514,9 @@
 		staterr = _mm_unpacklo_epi32(sterr_tmp1, sterr_tmp2);
 
 		/* D.3 copy final 3,4 data to rx_pkts */
-		_mm_storeu_si128((void *)&rx_pkts[pos+3]->rx_descriptor_fields1,
+		_mm_storeu_si128(rte_mbuf_rx_descriptor_fields1(rx_pkts[pos+3]),
 				pkt_mb4);
-		_mm_storeu_si128((void *)&rx_pkts[pos+2]->rx_descriptor_fields1,
+		_mm_storeu_si128(rte_mbuf_rx_descriptor_fields1(rx_pkts[pos+2]),
 				pkt_mb3);
 
 		/* C* extract and record EOP bit */
@@ -557,9 +552,9 @@
 		staterr = _mm_packs_epi32(staterr, zero);
 
 		/* D.3 copy final 1,2 data to rx_pkts */
-		_mm_storeu_si128((void *)&rx_pkts[pos+1]->rx_descriptor_fields1,
+		_mm_storeu_si128(rte_mbuf_rx_descriptor_fields1(rx_pkts[pos+1]),
 				pkt_mb2);
-		_mm_storeu_si128((void *)&rx_pkts[pos]->rx_descriptor_fields1,
+		_mm_storeu_si128(rte_mbuf_rx_descriptor_fields1(rx_pkts[pos]),
 				pkt_mb1);
 
 		fm10k_desc_to_pktype_v(descs0, &rx_pkts[pos]);
Signature · 1 line
1.8.3.1
#71 lore raw

PATCH v5 12/22 net/hns3: use mbuf descriptor accessors

In reply to Tyler Retzlaff

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.

---
 drivers/net/hns3/hns3_rxtx_vec.c      |  4 +---
 drivers/net/hns3/hns3_rxtx_vec_neon.h | 16 ++++++++--------
 2 files changed, 9 insertions(+), 11 deletions(-)
drivers/net/hns3/hns3_rxtx_vec.c +1 -3
index 9708ec6..174be45 100644
@@ -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;
@@ -141,8 +140,7 @@
 
 	/* 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
drivers/net/hns3/hns3_rxtx_vec_neon.h +8 -8
index 0dc6b9f..7b2c3e3 100644
@@ -236,23 +236,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);
Signature · 1 line
1.8.3.1
#72 lore raw

PATCH v5 13/22 net/i40e: use mbuf descriptor accessors

In reply to Tyler Retzlaff

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.

---
 drivers/net/i40e/i40e_rxtx_vec_altivec.c | 18 ++++++------------
 drivers/net/i40e/i40e_rxtx_vec_avx2.c    | 16 ++++++++--------
 drivers/net/i40e/i40e_rxtx_vec_avx512.c  | 16 ++++++++--------
 drivers/net/i40e/i40e_rxtx_vec_common.h  |  4 +---
 drivers/net/i40e/i40e_rxtx_vec_neon.c    | 16 ++++++++--------
 drivers/net/i40e/i40e_rxtx_vec_sse.c     | 16 ++++++++--------
 6 files changed, 39 insertions(+), 47 deletions(-)
drivers/net/i40e/i40e_rxtx_vec_altivec.c +6 -12
index b6b0d38..3e065ee 100644
@@ -55,7 +55,6 @@
 	/* Initialize the mbufs in vector, process 2 mbufs in one loop */
 	for (i = 0; i < RTE_I40E_RXQ_REARM_THRESH; i += 2, rxep += 2) {
 		__vector unsigned long vaddr0, vaddr1;
-		uintptr_t p0, p1;
 
 		mb0 = rxep[0].mbuf;
 		mb1 = rxep[1].mbuf;
@@ -66,10 +65,8 @@
 		  * anyway. So overwrite whole 8 bytes with one load:
 		  * 6 bytes of rearm_data plus first 2 bytes of ol_flags.
 		  */
-		p0 = (uintptr_t)&mb0->rearm_data;
-		*(uint64_t *)p0 = rxq->mbuf_initializer;
-		p1 = (uintptr_t)&mb1->rearm_data;
-		*(uint64_t *)p1 = rxq->mbuf_initializer;
+		*rte_mbuf_rearm_data(mb0) = rxq->mbuf_initializer;
+		*rte_mbuf_rearm_data(mb1) = rxq->mbuf_initializer;
 
 		/* load buf_addr(lo 64bit) and buf_iova(hi 64bit) */
 		vaddr0 = vec_ld(0, (__vector unsigned long *)&mb0->buf_addr);
@@ -370,12 +367,10 @@
 
 		/* D.3 copy final 3,4 data to rx_pkts */
 		vec_st(pkt_mb4, 0,
-		 (__vector unsigned char *)&rx_pkts[pos + 3]
-			->rx_descriptor_fields1
+		 (__vector unsigned char *)rte_mbuf_rx_descriptor_fields1(rx_pkts[pos + 3])
 		);
 		vec_st(pkt_mb3, 0,
-		 (__vector unsigned char *)&rx_pkts[pos + 2]
-			->rx_descriptor_fields1
+		 (__vector unsigned char *)rte_mbuf_rx_descriptor_fields1(rx_pkts[pos + 2])
 		);
 
 		/* D.2 pkt 1,2 set in_port/nb_seg and remove crc */
@@ -422,11 +417,10 @@
 
 		/* D.3 copy final 1,2 data to rx_pkts */
 		vec_st(pkt_mb2, 0,
-		 (__vector unsigned char *)&rx_pkts[pos + 1]
-			->rx_descriptor_fields1
+		 (__vector unsigned char *)rte_mbuf_rx_descriptor_fields1(rx_pkts[pos + 1])
 		);
 		vec_st(pkt_mb1, 0,
-		 (__vector unsigned char *)&rx_pkts[pos]->rx_descriptor_fields1
+		 (__vector unsigned char *)rte_mbuf_rx_descriptor_fields1(rx_pkts[pos])
 		);
 		desc_to_ptype_v(descs, &rx_pkts[pos], ptype_tbl);
 		desc_to_olflags_v(descs, &rx_pkts[pos]);
drivers/net/i40e/i40e_rxtx_vec_avx2.c +8 -8
index f468c1f..027afbe 100644
@@ -543,10 +543,10 @@
 		rearm2 = _mm256_permute2f128_si256(rearm2, mb2_3, 0x20);
 		rearm0 = _mm256_permute2f128_si256(rearm0, mb0_1, 0x20);
 		/* write to mbuf */
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 6]->rearm_data, rearm6);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 4]->rearm_data, rearm4);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 2]->rearm_data, rearm2);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 0]->rearm_data, rearm0);
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 6]), rearm6);
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 4]), rearm4);
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 2]), rearm2);
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 0]), rearm0);
 
 		/* repeat for the odd mbufs */
 		const __m256i odd_flags = _mm256_castsi128_si256(
@@ -561,10 +561,10 @@
 		rearm3 = _mm256_blend_epi32(rearm3, mb2_3, 0xF0);
 		rearm1 = _mm256_blend_epi32(rearm1, mb0_1, 0xF0);
 		/* again write to mbufs */
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 7]->rearm_data, rearm7);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 5]->rearm_data, rearm5);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 3]->rearm_data, rearm3);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 1]->rearm_data, rearm1);
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 7]), rearm7);
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 5]), rearm5);
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 3]), rearm3);
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 1]), rearm1);
 
 		/* extract and record EOP bit */
 		if (split_packet) {
drivers/net/i40e/i40e_rxtx_vec_avx512.c +8 -8
index f3050cd..91dda60 100644
@@ -580,13 +580,13 @@
 		rearm0 = _mm256_permute2f128_si256(rearm0, mb0_1, 0x20);
 		/* write to mbuf */
 		_mm256_storeu_si256
-			((__m256i *)&rx_pkts[i + 6]->rearm_data, rearm6);
+			((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 6]), rearm6);
 		_mm256_storeu_si256
-			((__m256i *)&rx_pkts[i + 4]->rearm_data, rearm4);
+			((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 4]), rearm4);
 		_mm256_storeu_si256
-			((__m256i *)&rx_pkts[i + 2]->rearm_data, rearm2);
+			((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 2]), rearm2);
 		_mm256_storeu_si256
-			((__m256i *)&rx_pkts[i + 0]->rearm_data, rearm0);
+			((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 0]), rearm0);
 
 		/* repeat for the odd mbufs */
 		const __m256i odd_flags = _mm256_castsi128_si256
@@ -606,13 +606,13 @@
 		rearm1 = _mm256_blend_epi32(rearm1, mb0_1, 0xF0);
 		/* again write to mbufs */
 		_mm256_storeu_si256
-			((__m256i *)&rx_pkts[i + 7]->rearm_data, rearm7);
+			((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 7]), rearm7);
 		_mm256_storeu_si256
-			((__m256i *)&rx_pkts[i + 5]->rearm_data, rearm5);
+			((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 5]), rearm5);
 		_mm256_storeu_si256
-			((__m256i *)&rx_pkts[i + 3]->rearm_data, rearm3);
+			((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 3]), rearm3);
 		_mm256_storeu_si256
-			((__m256i *)&rx_pkts[i + 1]->rearm_data, rearm1);
+			((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 1]), rearm1);
 
 		/* extract and record EOP bit */
 		if (split_packet) {
drivers/net/i40e/i40e_rxtx_vec_common.h +1 -3
index 8b74563..5633268 100644
@@ -189,7 +189,6 @@
 static inline int
 i40e_rxq_vec_setup_default(struct i40e_rx_queue *rxq)
 {
-	uintptr_t p;
 	struct rte_mbuf mb_def = { .buf_addr = 0 }; /* zeroed mbuf */
 
 	mb_def.nb_segs = 1;
@@ -199,8 +198,7 @@
 
 	/* 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);
 	rxq->rx_using_sse = 1;
 	return 0;
 }
drivers/net/i40e/i40e_rxtx_vec_neon.c +8 -8
index d873e30..29dfd92 100644
@@ -300,10 +300,10 @@
 	rearm2 = vsetq_lane_u64(vgetq_lane_u32(vlan0, 2), mbuf_init, 1);
 	rearm3 = vsetq_lane_u64(vgetq_lane_u32(vlan0, 3), mbuf_init, 1);
 
-	vst1q_u64((uint64_t *)&rx_pkts[0]->rearm_data, rearm0);
-	vst1q_u64((uint64_t *)&rx_pkts[1]->rearm_data, rearm1);
-	vst1q_u64((uint64_t *)&rx_pkts[2]->rearm_data, rearm2);
-	vst1q_u64((uint64_t *)&rx_pkts[3]->rearm_data, rearm3);
+	vst1q_u64(rte_mbuf_rearm_data(rx_pkts[0]), rearm0);
+	vst1q_u64(rte_mbuf_rearm_data(rx_pkts[1]), rearm1);
+	vst1q_u64(rte_mbuf_rearm_data(rx_pkts[2]), rearm2);
+	vst1q_u64(rte_mbuf_rearm_data(rx_pkts[3]), rearm3);
 }
 
 #define PKTLEN_SHIFT     10
@@ -492,13 +492,13 @@
 		pkt_mb1 = vreinterpretq_u8_u16(tmp);
 
 		/* D.3 copy final data to rx_pkts */
-		vst1q_u8((void *)&rx_pkts[pos + 3]->rx_descriptor_fields1,
+		vst1q_u8(rte_mbuf_rx_descriptor_fields1(rx_pkts[pos + 3]),
 				pkt_mb4);
-		vst1q_u8((void *)&rx_pkts[pos + 2]->rx_descriptor_fields1,
+		vst1q_u8(rte_mbuf_rx_descriptor_fields1(rx_pkts[pos + 2]),
 				pkt_mb3);
-		vst1q_u8((void *)&rx_pkts[pos + 1]->rx_descriptor_fields1,
+		vst1q_u8(rte_mbuf_rx_descriptor_fields1(rx_pkts[pos + 1]),
 				pkt_mb2);
-		vst1q_u8((void *)&rx_pkts[pos]->rx_descriptor_fields1,
+		vst1q_u8(rte_mbuf_rx_descriptor_fields1(rx_pkts[pos]),
 				pkt_mb1);
 
 		desc_to_ptype_v(descs, &rx_pkts[pos], ptype_tbl);
drivers/net/i40e/i40e_rxtx_vec_sse.c +8 -8
index 2d4480a..d87b5ba 100644
@@ -319,10 +319,10 @@
 			offsetof(struct rte_mbuf, rearm_data) + 8);
 	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, rearm_data) !=
 			RTE_ALIGN(offsetof(struct rte_mbuf, rearm_data), 16));
-	_mm_store_si128((__m128i *)&rx_pkts[0]->rearm_data, rearm0);
-	_mm_store_si128((__m128i *)&rx_pkts[1]->rearm_data, rearm1);
-	_mm_store_si128((__m128i *)&rx_pkts[2]->rearm_data, rearm2);
-	_mm_store_si128((__m128i *)&rx_pkts[3]->rearm_data, rearm3);
+	_mm_store_si128((__m128i *)rte_mbuf_rearm_data(rx_pkts[0]), rearm0);
+	_mm_store_si128((__m128i *)rte_mbuf_rearm_data(rx_pkts[1]), rearm1);
+	_mm_store_si128((__m128i *)rte_mbuf_rearm_data(rx_pkts[2]), rearm2);
+	_mm_store_si128((__m128i *)rte_mbuf_rearm_data(rx_pkts[3]), rearm3);
 }
 
 #define PKTLEN_SHIFT     10
@@ -535,9 +535,9 @@
 		staterr = _mm_unpacklo_epi32(sterr_tmp1, sterr_tmp2);
 
 		/* D.3 copy final 3,4 data to rx_pkts */
-		_mm_storeu_si128((void *)&rx_pkts[pos+3]->rx_descriptor_fields1,
+		_mm_storeu_si128(rte_mbuf_rx_descriptor_fields1(rx_pkts[pos+3]),
 				 pkt_mb4);
-		_mm_storeu_si128((void *)&rx_pkts[pos+2]->rx_descriptor_fields1,
+		_mm_storeu_si128(rte_mbuf_rx_descriptor_fields1(rx_pkts[pos+2]),
 				 pkt_mb3);
 
 		/* D.2 pkt 1,2 set in_port/nb_seg and remove crc */
@@ -571,9 +571,9 @@
 		staterr = _mm_packs_epi32(staterr, zero);
 
 		/* D.3 copy final 1,2 data to rx_pkts */
-		_mm_storeu_si128((void *)&rx_pkts[pos+1]->rx_descriptor_fields1,
+		_mm_storeu_si128(rte_mbuf_rx_descriptor_fields1(rx_pkts[pos+1]),
 				 pkt_mb2);
-		_mm_storeu_si128((void *)&rx_pkts[pos]->rx_descriptor_fields1,
+		_mm_storeu_si128(rte_mbuf_rx_descriptor_fields1(rx_pkts[pos]),
 				 pkt_mb1);
 		desc_to_ptype_v(descs, &rx_pkts[pos], ptype_tbl);
 		/* C.4 calc available number of desc */
Signature · 1 line
1.8.3.1
#73 lore raw

PATCH v5 14/22 net/iavf: use mbuf descriptor accessors

In reply to Tyler Retzlaff

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.

---
 drivers/net/iavf/iavf_rxtx_vec_avx2.c   | 32 ++++++++++++++++----------------
 drivers/net/iavf/iavf_rxtx_vec_avx512.c | 32 ++++++++++++++++----------------
 drivers/net/iavf/iavf_rxtx_vec_common.h |  4 +---
 drivers/net/iavf/iavf_rxtx_vec_neon.c   | 16 ++++++++--------
 drivers/net/iavf/iavf_rxtx_vec_sse.c    | 32 ++++++++++++++++----------------
 5 files changed, 57 insertions(+), 59 deletions(-)
drivers/net/iavf/iavf_rxtx_vec_avx2.c +16 -16
index 510b4d8..0211e83 100644
@@ -398,13 +398,13 @@
 		rearm2 = _mm256_permute2f128_si256(rearm2, mb2_3, 0x20);
 		rearm0 = _mm256_permute2f128_si256(rearm0, mb0_1, 0x20);
 		/* write to mbuf */
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 6]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 6]),
 				    rearm6);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 4]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 4]),
 				    rearm4);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 2]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 2]),
 				    rearm2);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 0]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 0]),
 				    rearm0);
 
 		/* repeat for the odd mbufs */
@@ -427,13 +427,13 @@
 		rearm3 = _mm256_blend_epi32(rearm3, mb2_3, 0xF0);
 		rearm1 = _mm256_blend_epi32(rearm1, mb0_1, 0xF0);
 		/* again write to mbufs */
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 7]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 7]),
 				    rearm7);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 5]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 5]),
 				    rearm5);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 3]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 3]),
 				    rearm3);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 1]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 1]),
 				    rearm1);
 
 		/* extract and record EOP bit */
@@ -1305,13 +1305,13 @@
 		rearm2 = _mm256_permute2f128_si256(rearm2, mb2_3, 0x20);
 		rearm0 = _mm256_permute2f128_si256(rearm0, mb0_1, 0x20);
 		/* write to mbuf */
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 6]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 6]),
 				    rearm6);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 4]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 4]),
 				    rearm4);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 2]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 2]),
 				    rearm2);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 0]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 0]),
 				    rearm0);
 
 		/* repeat for the odd mbufs */
@@ -1334,13 +1334,13 @@
 		rearm3 = _mm256_blend_epi32(rearm3, mb2_3, 0xF0);
 		rearm1 = _mm256_blend_epi32(rearm1, mb0_1, 0xF0);
 		/* again write to mbufs */
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 7]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 7]),
 				    rearm7);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 5]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 5]),
 				    rearm5);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 3]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 3]),
 				    rearm3);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 1]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 1]),
 				    rearm1);
 
 		/* extract and record EOP bit */
drivers/net/iavf/iavf_rxtx_vec_avx512.c +16 -16
index 3bb6f30..950ec91 100644
@@ -450,13 +450,13 @@
 			rearm0 = _mm256_permute2f128_si256(mbuf_init, mb0_1, 0x20);
 		}
 		/* write to mbuf */
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 6]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 6]),
 				    rearm6);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 4]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 4]),
 				    rearm4);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 2]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 2]),
 				    rearm2);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 0]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 0]),
 				    rearm0);
 
 		/* repeat for the odd mbufs */
@@ -486,13 +486,13 @@
 			rearm1 = _mm256_blend_epi32(mbuf_init, mb0_1, 0xF0);
 		}
 		/* again write to mbufs */
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 7]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 7]),
 				    rearm7);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 5]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 5]),
 				    rearm5);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 3]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 3]),
 				    rearm3);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 1]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 1]),
 				    rearm1);
 
 		/* extract and record EOP bit */
@@ -1461,13 +1461,13 @@
 		rearm2 = _mm256_permute2f128_si256(rearm2, mb2_3, 0x20);
 		rearm0 = _mm256_permute2f128_si256(rearm0, mb0_1, 0x20);
 		/* write to mbuf */
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 6]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 6]),
 				    rearm6);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 4]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 4]),
 				    rearm4);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 2]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 2]),
 				    rearm2);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 0]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 0]),
 				    rearm0);
 
 		/* repeat for the odd mbufs */
@@ -1490,13 +1490,13 @@
 		rearm3 = _mm256_blend_epi32(rearm3, mb2_3, 0xF0);
 		rearm1 = _mm256_blend_epi32(rearm1, mb0_1, 0xF0);
 		/* again write to mbufs */
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 7]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 7]),
 				    rearm7);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 5]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 5]),
 				    rearm5);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 3]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 3]),
 				    rearm3);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 1]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 1]),
 				    rearm1);
 
 		/* extract and record EOP bit */
drivers/net/iavf/iavf_rxtx_vec_common.h +1 -3
index 5c52200..71e3644 100644
@@ -197,7 +197,6 @@
 static inline int
 iavf_rxq_vec_setup_default(struct iavf_rx_queue *rxq)
 {
-	uintptr_t p;
 	struct rte_mbuf mb_def = { .buf_addr = 0 }; /* zeroed mbuf */
 
 	mb_def.nb_segs = 1;
@@ -207,8 +206,7 @@
 
 	/* 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);
 	return 0;
 }
 
drivers/net/iavf/iavf_rxtx_vec_neon.c +8 -8
index 83825aa..d7ea940 100644
@@ -159,10 +159,10 @@
 	rearm2 = vsetq_lane_u64(vgetq_lane_u32(vlan0, 2), mbuf_init, 1);
 	rearm3 = vsetq_lane_u64(vgetq_lane_u32(vlan0, 3), mbuf_init, 1);
 
-	vst1q_u64((uint64_t *)&rx_pkts[0]->rearm_data, rearm0);
-	vst1q_u64((uint64_t *)&rx_pkts[1]->rearm_data, rearm1);
-	vst1q_u64((uint64_t *)&rx_pkts[2]->rearm_data, rearm2);
-	vst1q_u64((uint64_t *)&rx_pkts[3]->rearm_data, rearm3);
+	vst1q_u64(rte_mbuf_rearm_data(rx_pkts[0]), rearm0);
+	vst1q_u64(rte_mbuf_rearm_data(rx_pkts[1]), rearm1);
+	vst1q_u64(rte_mbuf_rearm_data(rx_pkts[2]), rearm2);
+	vst1q_u64(rte_mbuf_rearm_data(rx_pkts[3]), rearm3);
 }
 
 #define PKTLEN_SHIFT     10
@@ -332,13 +332,13 @@
 		pkt_mb1 = vreinterpretq_u8_u16(tmp);
 
 		/* D.3 copy final data to rx_pkts */
-		vst1q_u8((void *)&rx_pkts[pos + 3]->rx_descriptor_fields1,
+		vst1q_u8(rte_mbuf_rx_descriptor_fields1(rx_pkts[pos + 3]),
 				pkt_mb4);
-		vst1q_u8((void *)&rx_pkts[pos + 2]->rx_descriptor_fields1,
+		vst1q_u8(rte_mbuf_rx_descriptor_fields1(rx_pkts[pos + 2]),
 				pkt_mb3);
-		vst1q_u8((void *)&rx_pkts[pos + 1]->rx_descriptor_fields1,
+		vst1q_u8(rte_mbuf_rx_descriptor_fields1(rx_pkts[pos + 1]),
 				pkt_mb2);
-		vst1q_u8((void *)&rx_pkts[pos]->rx_descriptor_fields1,
+		vst1q_u8(rte_mbuf_rx_descriptor_fields1(rx_pkts[pos]),
 				pkt_mb1);
 
 		desc_to_ptype_v(descs, &rx_pkts[pos], ptype_tbl);
drivers/net/iavf/iavf_rxtx_vec_sse.c +16 -16
index 96f187f..634d9f5 100644
@@ -183,10 +183,10 @@
 			offsetof(struct rte_mbuf, rearm_data) + 8);
 	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, rearm_data) !=
 			RTE_ALIGN(offsetof(struct rte_mbuf, rearm_data), 16));
-	_mm_store_si128((__m128i *)&rx_pkts[0]->rearm_data, rearm0);
-	_mm_store_si128((__m128i *)&rx_pkts[1]->rearm_data, rearm1);
-	_mm_store_si128((__m128i *)&rx_pkts[2]->rearm_data, rearm2);
-	_mm_store_si128((__m128i *)&rx_pkts[3]->rearm_data, rearm3);
+	_mm_store_si128((__m128i *)rte_mbuf_rearm_data(rx_pkts[0]), rearm0);
+	_mm_store_si128((__m128i *)rte_mbuf_rearm_data(rx_pkts[1]), rearm1);
+	_mm_store_si128((__m128i *)rte_mbuf_rearm_data(rx_pkts[2]), rearm2);
+	_mm_store_si128((__m128i *)rte_mbuf_rearm_data(rx_pkts[3]), rearm3);
 }
 
 static inline __m128i
@@ -416,10 +416,10 @@
 			 offsetof(struct rte_mbuf, rearm_data) + 8);
 	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, rearm_data) !=
 			 RTE_ALIGN(offsetof(struct rte_mbuf, rearm_data), 16));
-	_mm_store_si128((__m128i *)&rx_pkts[0]->rearm_data, rearm0);
-	_mm_store_si128((__m128i *)&rx_pkts[1]->rearm_data, rearm1);
-	_mm_store_si128((__m128i *)&rx_pkts[2]->rearm_data, rearm2);
-	_mm_store_si128((__m128i *)&rx_pkts[3]->rearm_data, rearm3);
+	_mm_store_si128((__m128i *)rte_mbuf_rearm_data(rx_pkts[0]), rearm0);
+	_mm_store_si128((__m128i *)rte_mbuf_rearm_data(rx_pkts[1]), rearm1);
+	_mm_store_si128((__m128i *)rte_mbuf_rearm_data(rx_pkts[2]), rearm2);
+	_mm_store_si128((__m128i *)rte_mbuf_rearm_data(rx_pkts[3]), rearm3);
 }
 
 #define PKTLEN_SHIFT     10
@@ -651,10 +651,10 @@
 
 		/* D.3 copy final 3,4 data to rx_pkts */
 		_mm_storeu_si128(
-			(void *)&rx_pkts[pos + 3]->rx_descriptor_fields1,
+			rte_mbuf_rx_descriptor_fields1(rx_pkts[pos + 3]),
 			pkt_mb4);
 		_mm_storeu_si128(
-			(void *)&rx_pkts[pos + 2]->rx_descriptor_fields1,
+			rte_mbuf_rx_descriptor_fields1(rx_pkts[pos + 2]),
 			pkt_mb3);
 
 		/* D.2 pkt 1,2 remove crc */
@@ -689,9 +689,9 @@
 
 		/* D.3 copy final 1,2 data to rx_pkts */
 		_mm_storeu_si128(
-			(void *)&rx_pkts[pos + 1]->rx_descriptor_fields1,
+			rte_mbuf_rx_descriptor_fields1(rx_pkts[pos + 1]),
 			pkt_mb2);
-		_mm_storeu_si128((void *)&rx_pkts[pos]->rx_descriptor_fields1,
+		_mm_storeu_si128(rte_mbuf_rx_descriptor_fields1(rx_pkts[pos]),
 				 pkt_mb1);
 		desc_to_ptype_v(descs, &rx_pkts[pos], ptype_tbl);
 		/* C.4 calc available number of desc */
@@ -1089,10 +1089,10 @@
 
 		/* D.3 copy final 3,4 data to rx_pkts */
 		_mm_storeu_si128
-			((void *)&rx_pkts[pos + 3]->rx_descriptor_fields1,
+			(rte_mbuf_rx_descriptor_fields1(rx_pkts[pos + 3]),
 			 pkt_mb3);
 		_mm_storeu_si128
-			((void *)&rx_pkts[pos + 2]->rx_descriptor_fields1,
+			(rte_mbuf_rx_descriptor_fields1(rx_pkts[pos + 2]),
 			 pkt_mb2);
 
 		/* C* extract and record EOP bit */
@@ -1116,9 +1116,9 @@
 
 		/* D.3 copy final 1,2 data to rx_pkts */
 		_mm_storeu_si128
-			((void *)&rx_pkts[pos + 1]->rx_descriptor_fields1,
+			(rte_mbuf_rx_descriptor_fields1(rx_pkts[pos + 1]),
 			 pkt_mb1);
-		_mm_storeu_si128((void *)&rx_pkts[pos]->rx_descriptor_fields1,
+		_mm_storeu_si128(rte_mbuf_rx_descriptor_fields1(rx_pkts[pos]),
 				 pkt_mb0);
 		flex_desc_to_ptype_v(descs, &rx_pkts[pos], ptype_tbl);
 		/* C.4 calc available number of desc */
Signature · 1 line
1.8.3.1
#74 lore raw

PATCH v5 15/22 net/ice: use mbuf descriptor accessors

In reply to Tyler Retzlaff

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.

---
 drivers/net/ice/ice_rxtx_vec_avx2.c   | 16 ++++++++--------
 drivers/net/ice/ice_rxtx_vec_avx512.c | 16 ++++++++--------
 drivers/net/ice/ice_rxtx_vec_common.h |  4 +---
 drivers/net/ice/ice_rxtx_vec_sse.c    | 16 ++++++++--------
 4 files changed, 25 insertions(+), 27 deletions(-)
drivers/net/ice/ice_rxtx_vec_avx2.c +8 -8
index 6f6d790..fb3811a 100644
@@ -596,13 +596,13 @@
 		rearm2 = _mm256_permute2f128_si256(rearm2, mb2_3, 0x20);
 		rearm0 = _mm256_permute2f128_si256(rearm0, mb0_1, 0x20);
 		/* write to mbuf */
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 6]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 6]),
 				    rearm6);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 4]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 4]),
 				    rearm4);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 2]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 2]),
 				    rearm2);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 0]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 0]),
 				    rearm0);
 
 		/* repeat for the odd mbufs */
@@ -625,13 +625,13 @@
 		rearm3 = _mm256_blend_epi32(rearm3, mb2_3, 0xF0);
 		rearm1 = _mm256_blend_epi32(rearm1, mb0_1, 0xF0);
 		/* again write to mbufs */
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 7]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 7]),
 				    rearm7);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 5]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 5]),
 				    rearm5);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 3]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 3]),
 				    rearm3);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 1]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 1]),
 				    rearm1);
 
 		/* extract and record EOP bit */
drivers/net/ice/ice_rxtx_vec_avx512.c +8 -8
index 04148e8..46d471f 100644
@@ -597,13 +597,13 @@
 		rearm0 = _mm256_permute2f128_si256(rearm0, mb0_1, 0x20);
 
 		/* write to mbuf */
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 6]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 6]),
 				    rearm6);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 4]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 4]),
 				    rearm4);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 2]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 2]),
 				    rearm2);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 0]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 0]),
 				    rearm0);
 
 		/* repeat for the odd mbufs */
@@ -627,13 +627,13 @@
 		rearm3 = _mm256_blend_epi32(rearm3, mb2_3, 0xF0);
 		rearm1 = _mm256_blend_epi32(rearm1, mb0_1, 0xF0);
 		/* again write to mbufs */
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 7]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 7]),
 				    rearm7);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 5]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 5]),
 				    rearm5);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 3]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 3]),
 				    rearm3);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 1]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 1]),
 				    rearm1);
 
 		/* extract and record EOP bit */
drivers/net/ice/ice_rxtx_vec_common.h +1 -3
index 4b73465..c284d2d 100644
@@ -232,7 +232,6 @@
 static inline int
 ice_rxq_vec_setup_default(struct ice_rx_queue *rxq)
 {
-	uintptr_t p;
 	struct rte_mbuf mb_def = { .buf_addr = 0 }; /* zeroed mbuf */
 
 	mb_def.nb_segs = 1;
@@ -242,8 +241,7 @@
 
 	/* 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);
 	return 0;
 }
 
drivers/net/ice/ice_rxtx_vec_sse.c +8 -8
index 9a1b7e3..4a051b7 100644
@@ -271,10 +271,10 @@
 			 offsetof(struct rte_mbuf, rearm_data) + 8);
 	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, rearm_data) !=
 			 RTE_ALIGN(offsetof(struct rte_mbuf, rearm_data), 16));
-	_mm_store_si128((__m128i *)&rx_pkts[0]->rearm_data, rearm0);
-	_mm_store_si128((__m128i *)&rx_pkts[1]->rearm_data, rearm1);
-	_mm_store_si128((__m128i *)&rx_pkts[2]->rearm_data, rearm2);
-	_mm_store_si128((__m128i *)&rx_pkts[3]->rearm_data, rearm3);
+	_mm_store_si128((__m128i *)rte_mbuf_rearm_data(rx_pkts[0]), rearm0);
+	_mm_store_si128((__m128i *)rte_mbuf_rearm_data(rx_pkts[1]), rearm1);
+	_mm_store_si128((__m128i *)rte_mbuf_rearm_data(rx_pkts[2]), rearm2);
+	_mm_store_si128((__m128i *)rte_mbuf_rearm_data(rx_pkts[3]), rearm3);
 }
 
 static inline void
@@ -542,10 +542,10 @@
 
 		/* D.3 copy final 3,4 data to rx_pkts */
 		_mm_storeu_si128
-			((void *)&rx_pkts[pos + 3]->rx_descriptor_fields1,
+			(rte_mbuf_rx_descriptor_fields1(rx_pkts[pos + 3]),
 			 pkt_mb3);
 		_mm_storeu_si128
-			((void *)&rx_pkts[pos + 2]->rx_descriptor_fields1,
+			(rte_mbuf_rx_descriptor_fields1(rx_pkts[pos + 2]),
 			 pkt_mb2);
 
 		/* C* extract and record EOP bit */
@@ -569,9 +569,9 @@
 
 		/* D.3 copy final 1,2 data to rx_pkts */
 		_mm_storeu_si128
-			((void *)&rx_pkts[pos + 1]->rx_descriptor_fields1,
+			(rte_mbuf_rx_descriptor_fields1(rx_pkts[pos + 1]),
 			 pkt_mb1);
-		_mm_storeu_si128((void *)&rx_pkts[pos]->rx_descriptor_fields1,
+		_mm_storeu_si128(rte_mbuf_rx_descriptor_fields1(rx_pkts[pos]),
 				 pkt_mb0);
 		ice_rx_desc_to_ptype_v(descs, &rx_pkts[pos], ptype_tbl);
 		/* C.4 calc available number of desc */
Signature · 1 line
1.8.3.1
#75 lore raw

PATCH v5 16/22 net/ionic: use mbuf descriptor accessors

In reply to Tyler Retzlaff

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.

---
 drivers/net/ionic/ionic_lif.c         | 4 ++--
 drivers/net/ionic/ionic_rxtx_sg.c     | 4 ++--
 drivers/net/ionic/ionic_rxtx_simple.c | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)
drivers/net/ionic/ionic_lif.c +2 -2
index 93a1011..cec9a38 100644
@@ -745,7 +745,7 @@
 	rte_compiler_barrier();
 
 	RTE_BUILD_BUG_ON(sizeof(rxm.rearm_data[0]) != sizeof(uint64_t));
-	return rxm.rearm_data[0];
+	return *rte_mbuf_rearm_data(&rxm);
 }
 
 static uint64_t
@@ -763,7 +763,7 @@
 	rte_compiler_barrier();
 
 	RTE_BUILD_BUG_ON(sizeof(rxm.rearm_data[0]) != sizeof(uint64_t));
-	return rxm.rearm_data[0];
+	return *rte_mbuf_rearm_data(&rxm);
 }
 
 int
drivers/net/ionic/ionic_rxtx_sg.c +2 -2
index 92e1d6e..4a6f3c2 100644
@@ -286,7 +286,7 @@
 	info[0] = NULL;
 
 	/* Set the mbuf metadata based on the cq entry */
-	rxm->rearm_data[0] = rxq->rearm_data;
+	*rte_mbuf_rearm_data(rxm) = rxq->rearm_data;
 	rxm->pkt_len = cq_desc_len;
 	rxm->data_len = RTE_MIN(rxq->hdr_seg_size, cq_desc_len);
 	left = cq_desc_len - rxm->data_len;
@@ -299,7 +299,7 @@
 		info[i] = NULL;
 
 		/* Set the chained mbuf metadata */
-		rxm_seg->rearm_data[0] = rxq->rearm_seg_data;
+		*rte_mbuf_rearm_data(rxm_seg) = rxq->rearm_seg_data;
 		rxm_seg->data_len = RTE_MIN(rxq->seg_size, left);
 		left -= rxm_seg->data_len;
 
drivers/net/ionic/ionic_rxtx_simple.c +1 -1
index f12f66f..02528e8 100644
@@ -257,7 +257,7 @@
 	info[0] = NULL;
 
 	/* Set the mbuf metadata based on the cq entry */
-	rxm->rearm_data[0] = rxq->rearm_data;
+	*rte_mbuf_rearm_data(rxm) = rxq->rearm_data;
 	rxm->pkt_len = cq_desc_len;
 	rxm->data_len = cq_desc_len;
 
Signature · 1 line
1.8.3.1
#76 lore raw

PATCH v5 17/22 net/ixgbe: use mbuf descriptor accessors

In reply to Tyler Retzlaff

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.

---
 drivers/net/ixgbe/ixgbe_rxtx_vec_common.h |  4 +---
 drivers/net/ixgbe/ixgbe_rxtx_vec_neon.c   | 12 ++++++------
 drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c    | 24 ++++++++++++------------
 3 files changed, 19 insertions(+), 21 deletions(-)
drivers/net/ixgbe/ixgbe_rxtx_vec_common.h +1 -3
index a4d9ec9..78ab168 100644
@@ -244,7 +244,6 @@
 static inline int
 ixgbe_rxq_vec_setup_default(struct ixgbe_rx_queue *rxq)
 {
-	uintptr_t p;
 	struct rte_mbuf mb_def = { .buf_addr = 0 }; /* zeroed mbuf */
 
 	mb_def.nb_segs = 1;
@@ -254,8 +253,7 @@
 
 	/* 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);
 	return 0;
 }
 
drivers/net/ixgbe/ixgbe_rxtx_vec_neon.c +6 -6
index 952b032..2e1d903 100644
@@ -56,13 +56,13 @@
 		 * Flush mbuf with pkt template.
 		 * Data to be rearmed is 6 bytes long.
 		 */
-		vst1_u8((uint8_t *)&mb0->rearm_data, p);
+		vst1_u8((uint8_t *)rte_mbuf_rearm_data(mb0), p);
 		paddr = mb0->buf_iova + RTE_PKTMBUF_HEADROOM;
 		dma_addr0 = vsetq_lane_u64(paddr, zero, 0);
 		/* flush desc with pa dma_addr */
 		vst1q_u64((uint64_t *)&rxdp++->read, dma_addr0);
 
-		vst1_u8((uint8_t *)&mb1->rearm_data, p);
+		vst1_u8((uint8_t *)rte_mbuf_rearm_data(mb1), p);
 		paddr = mb1->buf_iova + RTE_PKTMBUF_HEADROOM;
 		dma_addr1 = vsetq_lane_u64(paddr, zero, 0);
 		vst1q_u64((uint64_t *)&rxdp++->read, dma_addr1);
@@ -411,9 +411,9 @@
 		pkt_mb3 = vreinterpretq_u8_u16(tmp);
 
 		/* D.3 copy final 3,4 data to rx_pkts */
-		vst1q_u8((void *)&rx_pkts[pos + 3]->rx_descriptor_fields1,
+		vst1q_u8(rte_mbuf_rx_descriptor_fields1(rx_pkts[pos + 3]),
 			 pkt_mb4);
-		vst1q_u8((void *)&rx_pkts[pos + 2]->rx_descriptor_fields1,
+		vst1q_u8(rte_mbuf_rx_descriptor_fields1(rx_pkts[pos + 2]),
 			 pkt_mb3);
 
 		/* D.2 pkt 1,2 set in_port/nb_seg and remove crc */
@@ -441,9 +441,9 @@
 		rte_prefetch_non_temporal(rxdp + RTE_IXGBE_DESCS_PER_LOOP);
 
 		/* D.3 copy final 1,2 data to rx_pkts */
-		vst1q_u8((uint8_t *)&rx_pkts[pos + 1]->rx_descriptor_fields1,
+		vst1q_u8((uint8_t *)rte_mbuf_rx_descriptor_fields1(rx_pkts[pos + 1]),
 			 pkt_mb2);
-		vst1q_u8((uint8_t *)&rx_pkts[pos]->rx_descriptor_fields1,
+		vst1q_u8((uint8_t *)rte_mbuf_rx_descriptor_fields1(rx_pkts[pos]),
 			 pkt_mb1);
 
 		desc_to_ptype_v(descs, rxq->pkt_type_mask, &rx_pkts[pos]);
drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c +12 -12
index f60808d..d8de64c 100644
@@ -98,10 +98,10 @@
 desc_to_olflags_v_ipsec(__m128i descs[4], struct rte_mbuf **rx_pkts)
 {
 	__m128i sterr, rearm, tmp_e, tmp_p;
-	uint32_t *rearm0 = (uint32_t *)rx_pkts[0]->rearm_data + 2;
-	uint32_t *rearm1 = (uint32_t *)rx_pkts[1]->rearm_data + 2;
-	uint32_t *rearm2 = (uint32_t *)rx_pkts[2]->rearm_data + 2;
-	uint32_t *rearm3 = (uint32_t *)rx_pkts[3]->rearm_data + 2;
+	uint32_t *rearm0 = (uint32_t *)rte_mbuf_rearm_data(rx_pkts[0]) + 2;
+	uint32_t *rearm1 = (uint32_t *)rte_mbuf_rearm_data(rx_pkts[1]) + 2;
+	uint32_t *rearm2 = (uint32_t *)rte_mbuf_rearm_data(rx_pkts[2]) + 2;
+	uint32_t *rearm3 = (uint32_t *)rte_mbuf_rearm_data(rx_pkts[3]) + 2;
 	const __m128i ipsec_sterr_msk =
 			_mm_set1_epi32(IXGBE_RXDADV_IPSEC_STATUS_SECP |
 				       IXGBE_RXDADV_IPSEC_ERROR_AUTH_FAILED);
@@ -255,10 +255,10 @@
 			offsetof(struct rte_mbuf, rearm_data) + 8);
 	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, rearm_data) !=
 			RTE_ALIGN(offsetof(struct rte_mbuf, rearm_data), 16));
-	_mm_store_si128((__m128i *)&rx_pkts[0]->rearm_data, rearm0);
-	_mm_store_si128((__m128i *)&rx_pkts[1]->rearm_data, rearm1);
-	_mm_store_si128((__m128i *)&rx_pkts[2]->rearm_data, rearm2);
-	_mm_store_si128((__m128i *)&rx_pkts[3]->rearm_data, rearm3);
+	_mm_store_si128((__m128i *)rte_mbuf_rearm_data(rx_pkts[0]), rearm0);
+	_mm_store_si128((__m128i *)rte_mbuf_rearm_data(rx_pkts[1]), rearm1);
+	_mm_store_si128((__m128i *)rte_mbuf_rearm_data(rx_pkts[2]), rearm2);
+	_mm_store_si128((__m128i *)rte_mbuf_rearm_data(rx_pkts[3]), rearm3);
 }
 
 static inline uint32_t get_packet_type(int index,
@@ -530,9 +530,9 @@ static inline uint32_t get_packet_type(int index,
 		staterr = _mm_unpacklo_epi32(sterr_tmp1, sterr_tmp2);
 
 		/* D.3 copy final 3,4 data to rx_pkts */
-		_mm_storeu_si128((void *)&rx_pkts[pos+3]->rx_descriptor_fields1,
+		_mm_storeu_si128(rte_mbuf_rx_descriptor_fields1(rx_pkts[pos+3]),
 				pkt_mb4);
-		_mm_storeu_si128((void *)&rx_pkts[pos+2]->rx_descriptor_fields1,
+		_mm_storeu_si128(rte_mbuf_rx_descriptor_fields1(rx_pkts[pos+2]),
 				pkt_mb3);
 
 		/* D.2 pkt 1,2 set in_port/nb_seg and remove crc */
@@ -566,9 +566,9 @@ static inline uint32_t get_packet_type(int index,
 		staterr = _mm_packs_epi32(staterr, zero);
 
 		/* D.3 copy final 1,2 data to rx_pkts */
-		_mm_storeu_si128((void *)&rx_pkts[pos+1]->rx_descriptor_fields1,
+		_mm_storeu_si128(rte_mbuf_rx_descriptor_fields1(rx_pkts[pos+1]),
 				pkt_mb2);
-		_mm_storeu_si128((void *)&rx_pkts[pos]->rx_descriptor_fields1,
+		_mm_storeu_si128(rte_mbuf_rx_descriptor_fields1(rx_pkts[pos]),
 				pkt_mb1);
 
 		desc_to_ptype_v(descs, rxq->pkt_type_mask, &rx_pkts[pos]);
Signature · 1 line
1.8.3.1
#77 lore raw

PATCH v5 18/22 net/mlx5: use mbuf descriptor accessors

In reply to Tyler Retzlaff

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.

---
 drivers/net/mlx5/mlx5_rxq.c              |  2 +-
 drivers/net/mlx5/mlx5_rxtx_vec_altivec.h | 28 ++++++++++++++--------------
 drivers/net/mlx5/mlx5_rxtx_vec_neon.h    | 20 ++++++++++----------
 drivers/net/mlx5/mlx5_rxtx_vec_sse.h     | 28 ++++++++++++++--------------
 4 files changed, 39 insertions(+), 39 deletions(-)
drivers/net/mlx5/mlx5_rxq.c +1 -1
index ca2eeed..b854418 100644
@@ -200,7 +200,7 @@
 		 */
 		rte_compiler_barrier();
 		rxq->mbuf_initializer =
-			*(rte_xmm_t *)&mbuf_init->rearm_data;
+			*(rte_xmm_t *)rte_mbuf_rearm_data(mbuf_init);
 		/* Padding with a fake mbuf for vectorized Rx. */
 		for (j = 0; j < MLX5_VPMD_DESCS_PER_LOOP; ++j)
 			(*rxq->elts)[elts_n + j] = &rxq->fake_mbuf;
drivers/net/mlx5/mlx5_rxtx_vec_altivec.h +14 -14
index cccfa7f..9349c21 100644
@@ -101,10 +101,10 @@
 	uint16_t pkts_n = mcqe_n;
 	const __vector unsigned char rearm =
 		(__vector unsigned char)vec_vsx_ld(0,
-		(signed int const *)&t_pkt->rearm_data);
+		(signed int const *)rte_mbuf_rearm_data(t_pkt));
 	const __vector unsigned char rxdf =
 		(__vector unsigned char)vec_vsx_ld(0,
-		(signed int const *)&t_pkt->rx_descriptor_fields1);
+		(signed int const *)rte_mbuf_rx_descriptor_fields1(t_pkt));
 	const __vector unsigned char crc_adj =
 		(__vector unsigned char)(__vector unsigned short){
 			0, 0, rxq->crc_present * RTE_ETHER_CRC_LEN, 0,
@@ -173,9 +173,9 @@
 
 		/* B.1 store rearm data to mbuf. */
 		*(__vector unsigned char *)
-			&elts[pos]->rearm_data = rearm;
+			rte_mbuf_rearm_data(elts[pos]) = rearm;
 		*(__vector unsigned char *)
-			&elts[pos + 1]->rearm_data = rearm;
+			rte_mbuf_rearm_data(elts[pos + 1]) = rearm;
 
 		/* C.1 combine data from mCQEs with rx_descriptor_fields1. */
 		rxdf1 = vec_perm(mcqe1, zero, shuf_mask1);
@@ -195,15 +195,15 @@
 
 		/* D.1 store rx_descriptor_fields1. */
 		*(__vector unsigned char *)
-			&elts[pos]->rx_descriptor_fields1 = rxdf1;
+			rte_mbuf_rx_descriptor_fields1(elts[pos]) = rxdf1;
 		*(__vector unsigned char *)
-			&elts[pos + 1]->rx_descriptor_fields1 = rxdf2;
+			rte_mbuf_rx_descriptor_fields1(elts[pos + 1]) = rxdf2;
 
 		/* B.1 store rearm data to mbuf. */
 		*(__vector unsigned char *)
-			&elts[pos + 2]->rearm_data = rearm;
+			rte_mbuf_rearm_data(elts[pos + 2]) = rearm;
 		*(__vector unsigned char *)
-			&elts[pos + 3]->rearm_data = rearm;
+			rte_mbuf_rearm_data(elts[pos + 3]) = rearm;
 
 		/* C.1 combine data from mCQEs with rx_descriptor_fields1. */
 		rxdf1 = vec_perm(mcqe2, zero, shuf_mask1);
@@ -223,9 +223,9 @@
 
 		/* D.1 store rx_descriptor_fields1. */
 		*(__vector unsigned char *)
-			&elts[pos + 2]->rx_descriptor_fields1 = rxdf1;
+			rte_mbuf_rx_descriptor_fields1(elts[pos + 2]) = rxdf1;
 		*(__vector unsigned char *)
-			&elts[pos + 3]->rx_descriptor_fields1 = rxdf2;
+			rte_mbuf_rx_descriptor_fields1(elts[pos + 3]) = rxdf2;
 
 #ifdef MLX5_PMD_SOFT_COUNTERS
 		invalid_mask = (__vector unsigned char)(__vector unsigned long){
@@ -769,13 +769,13 @@
 
 	/* Write 8B rearm_data and 8B ol_flags. */
 	vec_vsx_st(rearm0, 0,
-		(__vector unsigned char *)&pkts[0]->rearm_data);
+		(__vector unsigned char *)rte_mbuf_rearm_data(pkts[0]));
 	vec_vsx_st(rearm1, 0,
-		(__vector unsigned char *)&pkts[1]->rearm_data);
+		(__vector unsigned char *)rte_mbuf_rearm_data(pkts[1]));
 	vec_vsx_st(rearm2, 0,
-		(__vector unsigned char *)&pkts[2]->rearm_data);
+		(__vector unsigned char *)rte_mbuf_rearm_data(pkts[2]));
 	vec_vsx_st(rearm3, 0,
-		(__vector unsigned char *)&pkts[3]->rearm_data);
+		(__vector unsigned char *)rte_mbuf_rearm_data(pkts[3]));
 }
 
 /**
drivers/net/mlx5/mlx5_rxtx_vec_neon.h +10 -10
index 3ed6881..97ea620 100644
@@ -99,7 +99,7 @@
 		t_pkt->data_len + (rxq->crc_present * RTE_ETHER_CRC_LEN);
 	uint16_t pkts_n = mcqe_n;
 	const uint64x2_t rearm =
-		vld1q_u64((void *)&t_pkt->rearm_data);
+		vld1q_u64((void *)rte_mbuf_rearm_data(t_pkt));
 	const uint32x4_t rxdf_mask = {
 		0xffffffff, /* packet_type */
 		0,          /* skip pkt_len */
@@ -107,7 +107,7 @@
 		0,          /* skip hash.rss */
 	};
 	const uint8x16_t rxdf =
-		vandq_u8(vld1q_u8((void *)&t_pkt->rx_descriptor_fields1),
+		vandq_u8(vld1q_u8(rte_mbuf_rx_descriptor_fields1(t_pkt)),
 			 vreinterpretq_u8_u32(rxdf_mask));
 	const uint16x8_t crc_adj = {
 		0, 0,
@@ -140,10 +140,10 @@
 		rte_prefetch0((void *)(cq + mcqe_n));
 	for (pos = 0; pos < mcqe_n; ) {
 		uint8_t *p = (void *)&mcq[pos % 8];
-		uint8_t *e0 = (void *)&elts[pos]->rearm_data;
-		uint8_t *e1 = (void *)&elts[pos + 1]->rearm_data;
-		uint8_t *e2 = (void *)&elts[pos + 2]->rearm_data;
-		uint8_t *e3 = (void *)&elts[pos + 3]->rearm_data;
+		uint8_t *e0 = (void *)rte_mbuf_rearm_data(elts[pos]);
+		uint8_t *e1 = (void *)rte_mbuf_rearm_data(elts[pos + 1]);
+		uint8_t *e2 = (void *)rte_mbuf_rearm_data(elts[pos + 2]);
+		uint8_t *e3 = (void *)rte_mbuf_rearm_data(elts[pos + 3]);
 		uint16x4_t byte_cnt;
 #ifdef MLX5_PMD_SOFT_COUNTERS
 		uint16x4_t invalid_mask =
@@ -513,10 +513,10 @@
 					(vgetq_lane_u32(ol_flags, 0),
 					 vreinterpretq_u32_u64(mbuf_init), 2));
 
-	vst1q_u64((void *)&pkts[0]->rearm_data, rearm0);
-	vst1q_u64((void *)&pkts[1]->rearm_data, rearm1);
-	vst1q_u64((void *)&pkts[2]->rearm_data, rearm2);
-	vst1q_u64((void *)&pkts[3]->rearm_data, rearm3);
+	vst1q_u64((void *)rte_mbuf_rearm_data(pkts[0]), rearm0);
+	vst1q_u64((void *)rte_mbuf_rearm_data(pkts[1]), rearm1);
+	vst1q_u64((void *)rte_mbuf_rearm_data(pkts[2]), rearm2);
+	vst1q_u64((void *)rte_mbuf_rearm_data(pkts[3]), rearm3);
 }
 
 /**
drivers/net/mlx5/mlx5_rxtx_vec_sse.h +14 -14
index 2bdd1f6..088ce37 100644
@@ -98,9 +98,9 @@
 		t_pkt->data_len + (rxq->crc_present * RTE_ETHER_CRC_LEN);
 	uint16_t pkts_n = mcqe_n;
 	const __m128i rearm =
-		_mm_loadu_si128((__m128i *)&t_pkt->rearm_data);
+		_mm_loadu_si128((__m128i *)rte_mbuf_rearm_data(t_pkt));
 	const __m128i rxdf =
-		_mm_loadu_si128((__m128i *)&t_pkt->rx_descriptor_fields1);
+		_mm_loadu_si128((__m128i *)rte_mbuf_rx_descriptor_fields1(t_pkt));
 	const __m128i crc_adj =
 		_mm_set_epi16(0, 0, 0,
 			      rxq->crc_present * RTE_ETHER_CRC_LEN,
@@ -145,8 +145,8 @@
 		mcqe1 = _mm_loadu_si128((__m128i *)&mcq[pos % 8]);
 		mcqe2 = _mm_loadu_si128((__m128i *)&mcq[pos % 8 + 2]);
 		/* B.1 store rearm data to mbuf. */
-		_mm_storeu_si128((__m128i *)&elts[pos]->rearm_data, rearm);
-		_mm_storeu_si128((__m128i *)&elts[pos + 1]->rearm_data, rearm);
+		_mm_storeu_si128((__m128i *)rte_mbuf_rearm_data(elts[pos]), rearm);
+		_mm_storeu_si128((__m128i *)rte_mbuf_rearm_data(elts[pos + 1]), rearm);
 		/* C.1 combine data from mCQEs with rx_descriptor_fields1. */
 		rxdf1 = _mm_shuffle_epi8(mcqe1, shuf_mask1);
 		rxdf2 = _mm_shuffle_epi8(mcqe1, shuf_mask2);
@@ -156,14 +156,14 @@
 		rxdf2 = _mm_blend_epi16(rxdf2, rxdf, 0x23);
 		/* D.1 store rx_descriptor_fields1. */
 		_mm_storeu_si128((__m128i *)
-				  &elts[pos]->rx_descriptor_fields1,
+				  rte_mbuf_rx_descriptor_fields1(elts[pos]),
 				 rxdf1);
 		_mm_storeu_si128((__m128i *)
-				  &elts[pos + 1]->rx_descriptor_fields1,
+				  rte_mbuf_rx_descriptor_fields1(elts[pos + 1]),
 				 rxdf2);
 		/* B.1 store rearm data to mbuf. */
-		_mm_storeu_si128((__m128i *)&elts[pos + 2]->rearm_data, rearm);
-		_mm_storeu_si128((__m128i *)&elts[pos + 3]->rearm_data, rearm);
+		_mm_storeu_si128((__m128i *)rte_mbuf_rearm_data(elts[pos + 2]), rearm);
+		_mm_storeu_si128((__m128i *)rte_mbuf_rearm_data(elts[pos + 3]), rearm);
 		/* C.1 combine data from mCQEs with rx_descriptor_fields1. */
 		rxdf1 = _mm_shuffle_epi8(mcqe2, shuf_mask1);
 		rxdf2 = _mm_shuffle_epi8(mcqe2, shuf_mask2);
@@ -173,10 +173,10 @@
 		rxdf2 = _mm_blend_epi16(rxdf2, rxdf, 0x23);
 		/* D.1 store rx_descriptor_fields1. */
 		_mm_storeu_si128((__m128i *)
-				  &elts[pos + 2]->rx_descriptor_fields1,
+				  rte_mbuf_rx_descriptor_fields1(elts[pos + 2]),
 				 rxdf1);
 		_mm_storeu_si128((__m128i *)
-				  &elts[pos + 3]->rx_descriptor_fields1,
+				  rte_mbuf_rx_descriptor_fields1(elts[pos + 3]),
 				 rxdf2);
 #ifdef MLX5_PMD_SOFT_COUNTERS
 		invalid_mask = _mm_set_epi64x(0,
@@ -511,10 +511,10 @@
 	rearm2 = _mm_blend_epi16(mbuf_init, ol_flags, 0x30);
 	rearm3 = _mm_blend_epi16(mbuf_init, _mm_srli_si128(ol_flags, 4), 0x30);
 	/* Write 8B rearm_data and 8B ol_flags. */
-	_mm_store_si128((__m128i *)&pkts[0]->rearm_data, rearm0);
-	_mm_store_si128((__m128i *)&pkts[1]->rearm_data, rearm1);
-	_mm_store_si128((__m128i *)&pkts[2]->rearm_data, rearm2);
-	_mm_store_si128((__m128i *)&pkts[3]->rearm_data, rearm3);
+	_mm_store_si128((__m128i *)rte_mbuf_rearm_data(pkts[0]), rearm0);
+	_mm_store_si128((__m128i *)rte_mbuf_rearm_data(pkts[1]), rearm1);
+	_mm_store_si128((__m128i *)rte_mbuf_rearm_data(pkts[2]), rearm2);
+	_mm_store_si128((__m128i *)rte_mbuf_rearm_data(pkts[3]), rearm3);
 }
 
 /**
Signature · 1 line
1.8.3.1
#78 lore raw

PATCH v5 19/22 net/octeon_ep: use mbuf descriptor accessors

In reply to Tyler Retzlaff

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.

---
 drivers/net/octeon_ep/cnxk_ep_rx.h      | 2 +-
 drivers/net/octeon_ep/cnxk_ep_rx_avx.c  | 2 +-
 drivers/net/octeon_ep/cnxk_ep_rx_neon.c | 8 ++++----
 drivers/net/octeon_ep/cnxk_ep_rx_sse.c  | 8 ++++----
 drivers/net/octeon_ep/otx_ep_rxtx.c     | 5 +----
 5 files changed, 11 insertions(+), 14 deletions(-)
drivers/net/octeon_ep/cnxk_ep_rx.h +1 -1
index 61263e6..1d706e2 100644
@@ -158,7 +158,7 @@
 		mbuf->pkt_len = pkt_len;
 		mbuf->data_len = pkt_len;
 
-		*(uint64_t *)&mbuf->rearm_data = droq->rearm_data;
+		*rte_mbuf_rearm_data(mbuf) = droq->rearm_data;
 		rx_pkts[pkts] = mbuf;
 		bytes_rsvd += pkt_len;
 	}
drivers/net/octeon_ep/cnxk_ep_rx_avx.c +1 -1
index 47eb1d2..3b8241c 100644
@@ -60,7 +60,7 @@
 
 		/* Store the 256bit data to the mbuf. */
 		for (i = 0; i < CNXK_EP_OQ_DESC_PER_LOOP_AVX; i++)
-			_mm256_storeu_si256((__m256i *)&m[i]->rearm_data, data[i]);
+			_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(m[i]), data[i]);
 
 		for (i = 0; i < CNXK_EP_OQ_DESC_PER_LOOP_AVX; i++)
 			rx_pkts[pkts++] = m[i];
drivers/net/octeon_ep/cnxk_ep_rx_neon.c +4 -4
index 4c46a7e..8797252 100644
@@ -72,10 +72,10 @@
 		*(uint64_t *)&m3->pkt_len = vgetq_lane_u64(s23, 1);
 
 		/* Reset rearm data. */
-		*(uint64_t *)&m0->rearm_data = droq->rearm_data;
-		*(uint64_t *)&m1->rearm_data = droq->rearm_data;
-		*(uint64_t *)&m2->rearm_data = droq->rearm_data;
-		*(uint64_t *)&m3->rearm_data = droq->rearm_data;
+		*rte_mbuf_rearm_data(m0) = droq->rearm_data;
+		*rte_mbuf_rearm_data(m1) = droq->rearm_data;
+		*rte_mbuf_rearm_data(m2) = droq->rearm_data;
+		*rte_mbuf_rearm_data(m3) = droq->rearm_data;
 
 		rx_pkts[pkts++] = m0;
 		rx_pkts[pkts++] = m1;
drivers/net/octeon_ep/cnxk_ep_rx_sse.c +4 -4
index 308c8b2..1466217 100644
@@ -64,10 +64,10 @@
 		*(uint64_t *)&m3->pkt_len = ((rte_xmm_t)s23).u64[1];
 
 		/* Reset rearm data. */
-		*(uint64_t *)&m0->rearm_data = droq->rearm_data;
-		*(uint64_t *)&m1->rearm_data = droq->rearm_data;
-		*(uint64_t *)&m2->rearm_data = droq->rearm_data;
-		*(uint64_t *)&m3->rearm_data = droq->rearm_data;
+		*rte_mbuf_rearm_data(m0) = droq->rearm_data;
+		*rte_mbuf_rearm_data(m1) = droq->rearm_data;
+		*rte_mbuf_rearm_data(m2) = droq->rearm_data;
+		*rte_mbuf_rearm_data(m3) = droq->rearm_data;
 
 		rx_pkts[pkts++] = m0;
 		rx_pkts[pkts++] = m1;
drivers/net/octeon_ep/otx_ep_rxtx.c +1 -4
index aea148e..4470599 100644
@@ -289,7 +289,6 @@
 {
 	uint16_t port_id = otx_ep->port_id;
 	struct rte_mbuf mb_def;
-	uint64_t *tmp;
 
 	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, data_off) % 8 != 0);
 	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, refcnt) - offsetof(struct rte_mbuf, data_off) !=
@@ -305,9 +304,7 @@
 
 	/* Prevent compiler reordering: rearm_data covers previous fields */
 	rte_compiler_barrier();
-	tmp = (uint64_t *)&mb_def.rearm_data;
-
-	return *tmp;
+	return *rte_mbuf_rearm_data(&mb_def);
 }
 
 /* OQ initialization */
Signature · 1 line
1.8.3.1
#79 lore raw

PATCH v5 20/22 net/sfc: use mbuf descriptor accessors

In reply to Tyler Retzlaff

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.

---
 drivers/net/sfc/sfc_ef100_rx.c | 4 ++--
 drivers/net/sfc/sfc_ef10_rx.c  | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)
drivers/net/sfc/sfc_ef100_rx.c +2 -2
index e283879..3d93a7c 100644
@@ -555,7 +555,7 @@ struct sfc_ef100_rxq {
 
 		RTE_BUILD_BUG_ON(sizeof(pkt->rearm_data[0]) !=
 				 sizeof(rxq->rearm_data));
-		pkt->rearm_data[0] = rxq->rearm_data;
+		*rte_mbuf_rearm_data(pkt) = rxq->rearm_data;
 
 		/* data_off already moved past Rx prefix */
 		rx_prefix = (const efx_xword_t *)sfc_ef100_rx_pkt_prefix(pkt);
@@ -761,7 +761,7 @@ struct sfc_ef100_rxq {
 	/* rearm_data covers structure members filled in above */
 	rte_compiler_barrier();
 	RTE_BUILD_BUG_ON(sizeof(m.rearm_data[0]) != sizeof(uint64_t));
-	return m.rearm_data[0];
+	return *rte_mbuf_rearm_data(&m);
 }
 
 static sfc_dp_rx_qcreate_t sfc_ef100_rx_qcreate;
drivers/net/sfc/sfc_ef10_rx.c +3 -3
index 6044293..9c993a3 100644
@@ -323,7 +323,7 @@ struct sfc_ef10_rxq {
 	m = rxd->mbuf;
 
 	RTE_BUILD_BUG_ON(sizeof(m->rearm_data[0]) != sizeof(rxq->rearm_data));
-	m->rearm_data[0] = rxq->rearm_data;
+	*rte_mbuf_rearm_data(m) = rxq->rearm_data;
 
 	/* Classify packet based on Rx event */
 	/* Mask RSS hash offload flag if RSS is not enabled */
@@ -379,7 +379,7 @@ struct sfc_ef10_rxq {
 
 		RTE_BUILD_BUG_ON(sizeof(m->rearm_data[0]) !=
 				 sizeof(rxq->rearm_data));
-		m->rearm_data[0] = rxq->rearm_data;
+		*rte_mbuf_rearm_data(m) = rxq->rearm_data;
 
 		/* Event-dependent information is the same */
 		m->ol_flags = m0->ol_flags;
@@ -634,7 +634,7 @@ struct sfc_ef10_rxq {
 	/* rearm_data covers structure members filled in above */
 	rte_compiler_barrier();
 	RTE_BUILD_BUG_ON(sizeof(m.rearm_data[0]) != sizeof(uint64_t));
-	return m.rearm_data[0];
+	return *rte_mbuf_rearm_data(&m);
 }
 
 static sfc_dp_rx_qcreate_t sfc_ef10_rx_qcreate;
Signature · 1 line
1.8.3.1
#80 lore raw

PATCH v5 21/22 net/thunderx: use mbuf descriptor accessors

In reply to Tyler Retzlaff

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.

---
 drivers/net/thunderx/nicvf_ethdev.c | 4 +---
 drivers/net/thunderx/nicvf_rxtx.h   | 4 ++--
 2 files changed, 3 insertions(+), 5 deletions(-)
drivers/net/thunderx/nicvf_ethdev.c +1 -3
index 609d95d..722751c 100644
@@ -1306,7 +1306,6 @@ enum nicvf_link_speed {
 static inline void
 nicvf_rxq_mbuf_setup(struct nicvf_rxq *rxq)
 {
-	uintptr_t p;
 	struct rte_mbuf mb_def;
 	struct nicvf *nic = rxq->nic;
 
@@ -1328,8 +1327,7 @@ enum nicvf_link_speed {
 
 	/* Prevent compiler reordering: rearm_data covers previous fields */
 	rte_compiler_barrier();
-	p = (uintptr_t)&mb_def.rearm_data;
-	rxq->mbuf_initializer.value = *(uint64_t *)p;
+	rxq->mbuf_initializer.value = *rte_mbuf_rearm_data(&mb_def);
 }
 
 static int
drivers/net/thunderx/nicvf_rxtx.h +2 -2
index 4b83e33..7c07cde 100644
@@ -66,7 +66,7 @@ static inline uint16_t __attribute__((const))
 #else
 	init.value += apad;
 #endif
-	*(uint64_t *)(&pkt->rearm_data) = init.value;
+	*rte_mbuf_rearm_data(pkt) = init.value;
 }
 
 static inline void
@@ -80,7 +80,7 @@ static inline uint16_t __attribute__((const))
 	init.value += apad;
 #endif
 	init.fields.nb_segs = nb_segs;
-	*(uint64_t *)(&pkt->rearm_data) = init.value;
+	*rte_mbuf_rearm_data(pkt) = init.value;
 }
 
 uint32_t nicvf_dev_rx_queue_count(void *rx_queue);
Signature · 1 line
1.8.3.1
#81 lore raw

PATCH v5 22/22 net/virtio: use mbuf descriptor accessors

In reply to Tyler Retzlaff

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.

---
 drivers/net/virtio/virtio_rxtx_packed_avx.h     | 10 +++++-----
 drivers/net/virtio/virtio_rxtx_packed_neon.h    | 16 ++++++++--------
 drivers/net/virtio/virtio_rxtx_simple.c         |  4 +---
 drivers/net/virtio/virtio_rxtx_simple.h         |  5 +----
 drivers/net/virtio/virtio_rxtx_simple_altivec.c | 16 ++++++++--------
 drivers/net/virtio/virtio_rxtx_simple_neon.c    | 24 ++++++++----------------
 drivers/net/virtio/virtio_rxtx_simple_sse.c     | 16 ++++++++--------
 7 files changed, 39 insertions(+), 52 deletions(-)
drivers/net/virtio/virtio_rxtx_packed_avx.h +5 -5
index 584ac72..fc60179 100644
@@ -36,10 +36,10 @@
 	/* Load four mbufs rearm data */
 	RTE_BUILD_BUG_ON(REFCNT_BITS_OFFSET >= 64);
 	RTE_BUILD_BUG_ON(SEG_NUM_BITS_OFFSET >= 64);
-	__m256i mbufs = _mm256_set_epi64x(*tx_pkts[3]->rearm_data,
-					  *tx_pkts[2]->rearm_data,
-					  *tx_pkts[1]->rearm_data,
-					  *tx_pkts[0]->rearm_data);
+	__m256i mbufs = _mm256_set_epi64x(*rte_mbuf_rearm_data(tx_pkts[3]),
+					  *rte_mbuf_rearm_data(tx_pkts[2]),
+					  *rte_mbuf_rearm_data(tx_pkts[1]),
+					  *rte_mbuf_rearm_data(tx_pkts[0]));
 
 	/* refcnt=1 and nb_segs=1 */
 	__m256i mbuf_ref = _mm256_set1_epi64x(DEFAULT_REARM_DATA);
@@ -187,7 +187,7 @@
 		rx_pkts[i] = (struct rte_mbuf *)vq->vq_descx[id + i].cookie;
 		rte_packet_prefetch(rte_pktmbuf_mtod(rx_pkts[i], void *));
 
-		addrs[i] = (uintptr_t)rx_pkts[i]->rx_descriptor_fields1;
+		addrs[i] = (uintptr_t)rte_mbuf_rx_descriptor_fields1(rx_pkts[i]);
 	}
 
 	/*
drivers/net/virtio/virtio_rxtx_packed_neon.h +8 -8
index c222ebf..b33f29a 100644
@@ -59,10 +59,10 @@
 	uint8x16x2_t mbuf;
 	/* Load four mbufs rearm data. */
 	RTE_BUILD_BUG_ON(REFCNT_BITS_OFFSET >= 64);
-	pkts[0] = vld1_u16((uint16_t *)&tx_pkts[0]->rearm_data);
-	pkts[1] = vld1_u16((uint16_t *)&tx_pkts[1]->rearm_data);
-	pkts[2] = vld1_u16((uint16_t *)&tx_pkts[2]->rearm_data);
-	pkts[3] = vld1_u16((uint16_t *)&tx_pkts[3]->rearm_data);
+	pkts[0] = vld1_u16((uint16_t *)rte_mbuf_rearm_data(tx_pkts[0]));
+	pkts[1] = vld1_u16((uint16_t *)rte_mbuf_rearm_data(tx_pkts[1]));
+	pkts[2] = vld1_u16((uint16_t *)rte_mbuf_rearm_data(tx_pkts[2]));
+	pkts[3] = vld1_u16((uint16_t *)rte_mbuf_rearm_data(tx_pkts[3]));
 
 	mbuf.val[0] = vreinterpretq_u8_u16(vcombine_u16(pkts[0], pkts[1]));
 	mbuf.val[1] = vreinterpretq_u8_u16(vcombine_u16(pkts[2], pkts[3]));
@@ -263,10 +263,10 @@
 	pkt_mb[3] = vreinterpretq_u64_u16(vsubq_u16(
 			vreinterpretq_u16_u64(pkt_mb[3]), len_adjust));
 
-	vst1q_u64((void *)&rx_pkts[0]->rx_descriptor_fields1, pkt_mb[0]);
-	vst1q_u64((void *)&rx_pkts[1]->rx_descriptor_fields1, pkt_mb[1]);
-	vst1q_u64((void *)&rx_pkts[2]->rx_descriptor_fields1, pkt_mb[2]);
-	vst1q_u64((void *)&rx_pkts[3]->rx_descriptor_fields1, pkt_mb[3]);
+	vst1q_u64(rte_mbuf_rx_descriptor_fields1(rx_pkts[0]), pkt_mb[0]);
+	vst1q_u64(rte_mbuf_rx_descriptor_fields1(rx_pkts[1]), pkt_mb[1]);
+	vst1q_u64(rte_mbuf_rx_descriptor_fields1(rx_pkts[2]), pkt_mb[2]);
+	vst1q_u64(rte_mbuf_rx_descriptor_fields1(rx_pkts[3]), pkt_mb[3]);
 
 	if (hw->has_rx_offload) {
 		virtio_for_each_try_unroll(i, 0, PACKED_BATCH_SIZE) {
drivers/net/virtio/virtio_rxtx_simple.c +1 -3
index 4382569..e6a82e5 100644
@@ -31,7 +31,6 @@
 virtio_rxq_vec_setup(struct virtnet_rx *rxq)
 {
 	struct virtqueue *vq = virtnet_rxq_to_vq(rxq);
-	uintptr_t p;
 	struct rte_mbuf mb_def = { .buf_addr = 0 }; /* zeroed mbuf */
 
 	mb_def.nb_segs = 1;
@@ -41,8 +40,7 @@
 
 	/* 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);
 
 	return 0;
 }
drivers/net/virtio/virtio_rxtx_simple.h +1 -4
index 79196ed..16fef0e 100644
@@ -39,10 +39,7 @@
 	}
 
 	for (i = 0; i < RTE_VIRTIO_VPMD_RX_REARM_THRESH; i++) {
-		uintptr_t p;
-
-		p = (uintptr_t)&sw_ring[i]->rearm_data;
-		*(uint64_t *)p = rxvq->mbuf_initializer;
+		*rte_mbuf_rearm_data(sw_ring[i]) = rxvq->mbuf_initializer;
 
 		start_dp[i].addr = VIRTIO_MBUF_ADDR(sw_ring[i], vq) +
 			RTE_PKTMBUF_HEADROOM - vq->hw->vtnet_hdr_size;
drivers/net/virtio/virtio_rxtx_simple_altivec.c +8 -8
index 542ec3d..39ec1ca 100644
@@ -138,9 +138,9 @@
 			((__vector unsigned short)pkt_mb[0] + len_adjust);
 		pkt_mb[1] = (__vector unsigned char)
 			((__vector unsigned short)pkt_mb[1] + len_adjust);
-		*(__vector unsigned char *)&rx_pkts[0]->rx_descriptor_fields1 =
+		*(__vector unsigned char *)rte_mbuf_rx_descriptor_fields1(rx_pkts[0]) =
 			pkt_mb[0];
-		*(__vector unsigned char *)&rx_pkts[1]->rx_descriptor_fields1 =
+		*(__vector unsigned char *)rte_mbuf_rx_descriptor_fields1(rx_pkts[1]) =
 			pkt_mb[1];
 
 		pkt_mb[2] = vec_perm(desc[1], zero, shuf_msk1);
@@ -149,9 +149,9 @@
 			((__vector unsigned short)pkt_mb[2] + len_adjust);
 		pkt_mb[3] = (__vector unsigned char)
 			((__vector unsigned short)pkt_mb[3] + len_adjust);
-		*(__vector unsigned char *)&rx_pkts[2]->rx_descriptor_fields1 =
+		*(__vector unsigned char *)rte_mbuf_rx_descriptor_fields1(rx_pkts[2]) =
 			pkt_mb[2];
-		*(__vector unsigned char *)&rx_pkts[3]->rx_descriptor_fields1 =
+		*(__vector unsigned char *)rte_mbuf_rx_descriptor_fields1(rx_pkts[3]) =
 			pkt_mb[3];
 
 		pkt_mb[4] = vec_perm(desc[2], zero, shuf_msk1);
@@ -160,9 +160,9 @@
 			((__vector unsigned short)pkt_mb[4] + len_adjust);
 		pkt_mb[5] = (__vector unsigned char)
 			((__vector unsigned short)pkt_mb[5] + len_adjust);
-		*(__vector unsigned char *)&rx_pkts[4]->rx_descriptor_fields1 =
+		*(__vector unsigned char *)rte_mbuf_rx_descriptor_fields1(rx_pkts[4]) =
 			pkt_mb[4];
-		*(__vector unsigned char *)&rx_pkts[5]->rx_descriptor_fields1 =
+		*(__vector unsigned char *)rte_mbuf_rx_descriptor_fields1(rx_pkts[5]) =
 			pkt_mb[5];
 
 		pkt_mb[6] = vec_perm(desc[3], zero, shuf_msk1);
@@ -171,9 +171,9 @@
 			((__vector unsigned short)pkt_mb[6] + len_adjust);
 		pkt_mb[7] = (__vector unsigned char)
 			((__vector unsigned short)pkt_mb[7] + len_adjust);
-		*(__vector unsigned char *)&rx_pkts[6]->rx_descriptor_fields1 =
+		*(__vector unsigned char *)rte_mbuf_rx_descriptor_fields1(rx_pkts[6]) =
 			pkt_mb[6];
-		*(__vector unsigned char *)&rx_pkts[7]->rx_descriptor_fields1 =
+		*(__vector unsigned char *)rte_mbuf_rx_descriptor_fields1(rx_pkts[7]) =
 			pkt_mb[7];
 
 		if (unlikely(nb_used <= RTE_VIRTIO_DESC_PER_LOOP)) {
drivers/net/virtio/virtio_rxtx_simple_neon.c +8 -16
index 7139b31..873b42c 100644
@@ -138,10 +138,8 @@
 				vreinterpretq_u16_u64(pkt_mb[1]), len_adjust));
 		pkt_mb[0] = vreinterpretq_u64_u16(vsubq_u16(
 				vreinterpretq_u16_u64(pkt_mb[0]), len_adjust));
-		vst1q_u64((void *)&rx_pkts[1]->rx_descriptor_fields1,
-			pkt_mb[1]);
-		vst1q_u64((void *)&rx_pkts[0]->rx_descriptor_fields1,
-			pkt_mb[0]);
+		vst1q_u64(rte_mbuf_rx_descriptor_fields1(rx_pkts[1]), pkt_mb[1]);
+		vst1q_u64(rte_mbuf_rx_descriptor_fields1(rx_pkts[0]), pkt_mb[0]);
 
 		pkt_mb[3] = vreinterpretq_u64_u8(vqtbl1q_u8(
 				vreinterpretq_u8_u64(desc[1]), shuf_msk2));
@@ -151,10 +149,8 @@
 				vreinterpretq_u16_u64(pkt_mb[3]), len_adjust));
 		pkt_mb[2] = vreinterpretq_u64_u16(vsubq_u16(
 				vreinterpretq_u16_u64(pkt_mb[2]), len_adjust));
-		vst1q_u64((void *)&rx_pkts[3]->rx_descriptor_fields1,
-			pkt_mb[3]);
-		vst1q_u64((void *)&rx_pkts[2]->rx_descriptor_fields1,
-			pkt_mb[2]);
+		vst1q_u64(rte_mbuf_rx_descriptor_fields1(rx_pkts[3]), pkt_mb[3]);
+		vst1q_u64(rte_mbuf_rx_descriptor_fields1(rx_pkts[2]), pkt_mb[2]);
 
 		pkt_mb[5] = vreinterpretq_u64_u8(vqtbl1q_u8(
 				vreinterpretq_u8_u64(desc[2]), shuf_msk2));
@@ -164,10 +160,8 @@
 				vreinterpretq_u16_u64(pkt_mb[5]), len_adjust));
 		pkt_mb[4] = vreinterpretq_u64_u16(vsubq_u16(
 				vreinterpretq_u16_u64(pkt_mb[4]), len_adjust));
-		vst1q_u64((void *)&rx_pkts[5]->rx_descriptor_fields1,
-			pkt_mb[5]);
-		vst1q_u64((void *)&rx_pkts[4]->rx_descriptor_fields1,
-			pkt_mb[4]);
+		vst1q_u64(rte_mbuf_rx_descriptor_fields1(rx_pkts[5]), pkt_mb[5]);
+		vst1q_u64(rte_mbuf_rx_descriptor_fields1(rx_pkts[4]), pkt_mb[4]);
 
 		pkt_mb[7] = vreinterpretq_u64_u8(vqtbl1q_u8(
 				vreinterpretq_u8_u64(desc[3]), shuf_msk2));
@@ -177,10 +171,8 @@
 				vreinterpretq_u16_u64(pkt_mb[7]), len_adjust));
 		pkt_mb[6] = vreinterpretq_u64_u16(vsubq_u16(
 				vreinterpretq_u16_u64(pkt_mb[6]), len_adjust));
-		vst1q_u64((void *)&rx_pkts[7]->rx_descriptor_fields1,
-			pkt_mb[7]);
-		vst1q_u64((void *)&rx_pkts[6]->rx_descriptor_fields1,
-			pkt_mb[6]);
+		vst1q_u64(rte_mbuf_rx_descriptor_fields1(rx_pkts[7]), pkt_mb[7]);
+		vst1q_u64(rte_mbuf_rx_descriptor_fields1(rx_pkts[6]), pkt_mb[6]);
 
 		if (unlikely(nb_used <= RTE_VIRTIO_DESC_PER_LOOP)) {
 			if (sw_ring + nb_used <= sw_ring_end)
drivers/net/virtio/virtio_rxtx_simple_sse.c +8 -8
index 6a18741..25db486 100644
@@ -134,36 +134,36 @@
 		pkt_mb[0] = _mm_shuffle_epi8(desc[0], shuf_msk1);
 		pkt_mb[1] = _mm_add_epi16(pkt_mb[1], len_adjust);
 		pkt_mb[0] = _mm_add_epi16(pkt_mb[0], len_adjust);
-		_mm_storeu_si128((void *)&rx_pkts[1]->rx_descriptor_fields1,
+		_mm_storeu_si128(rte_mbuf_rx_descriptor_fields1(rx_pkts[1]),
 			pkt_mb[1]);
-		_mm_storeu_si128((void *)&rx_pkts[0]->rx_descriptor_fields1,
+		_mm_storeu_si128(rte_mbuf_rx_descriptor_fields1(rx_pkts[0]),
 			pkt_mb[0]);
 
 		pkt_mb[3] = _mm_shuffle_epi8(desc[1], shuf_msk2);
 		pkt_mb[2] = _mm_shuffle_epi8(desc[1], shuf_msk1);
 		pkt_mb[3] = _mm_add_epi16(pkt_mb[3], len_adjust);
 		pkt_mb[2] = _mm_add_epi16(pkt_mb[2], len_adjust);
-		_mm_storeu_si128((void *)&rx_pkts[3]->rx_descriptor_fields1,
+		_mm_storeu_si128(rte_mbuf_rx_descriptor_fields1(rx_pkts[3]),
 			pkt_mb[3]);
-		_mm_storeu_si128((void *)&rx_pkts[2]->rx_descriptor_fields1,
+		_mm_storeu_si128(rte_mbuf_rx_descriptor_fields1(rx_pkts[2]),
 			pkt_mb[2]);
 
 		pkt_mb[5] = _mm_shuffle_epi8(desc[2], shuf_msk2);
 		pkt_mb[4] = _mm_shuffle_epi8(desc[2], shuf_msk1);
 		pkt_mb[5] = _mm_add_epi16(pkt_mb[5], len_adjust);
 		pkt_mb[4] = _mm_add_epi16(pkt_mb[4], len_adjust);
-		_mm_storeu_si128((void *)&rx_pkts[5]->rx_descriptor_fields1,
+		_mm_storeu_si128(rte_mbuf_rx_descriptor_fields1(rx_pkts[5]),
 			pkt_mb[5]);
-		_mm_storeu_si128((void *)&rx_pkts[4]->rx_descriptor_fields1,
+		_mm_storeu_si128(rte_mbuf_rx_descriptor_fields1(rx_pkts[4]),
 			pkt_mb[4]);
 
 		pkt_mb[7] = _mm_shuffle_epi8(desc[3], shuf_msk2);
 		pkt_mb[6] = _mm_shuffle_epi8(desc[3], shuf_msk1);
 		pkt_mb[7] = _mm_add_epi16(pkt_mb[7], len_adjust);
 		pkt_mb[6] = _mm_add_epi16(pkt_mb[6], len_adjust);
-		_mm_storeu_si128((void *)&rx_pkts[7]->rx_descriptor_fields1,
+		_mm_storeu_si128(rte_mbuf_rx_descriptor_fields1(rx_pkts[7]),
 			pkt_mb[7]);
-		_mm_storeu_si128((void *)&rx_pkts[6]->rx_descriptor_fields1,
+		_mm_storeu_si128(rte_mbuf_rx_descriptor_fields1(rx_pkts[6]),
 			pkt_mb[6]);
 
 		if (unlikely(nb_used <= RTE_VIRTIO_DESC_PER_LOOP)) {
Signature · 1 line
1.8.3.1
#82 lore raw

RE: [PATCH v5 00/22] stop using RTE_MARKER extensions

In reply to Tyler Retzlaff

+to: Thomas

Quoted 8 lines

From: Tyler Retzlaff [mailto:[email protected]]
Sent: Saturday, 24 February 2024 09.22

RTE_MARKER typedefs are a GCC extension unsupported by MSVC. This series hides the markers when building with MSVC and updates libraries and drivers to access compatibly typed pointers to the rte_mbuf struct offsets.

Quoted 4 lines

This series, does the following.

Introduces a new macro __rte_marker(type, name) which is used to conditionally expand RTE_MARKER fields empty when building with GCC.

Important typo: GCC -> MSVC.

Correct me if I'm wrong: When building with MSVC, the RTE_MARKER fields don't exist at all.

Quoted 15 lines

Updates existing inline functions accessing cacheline{0,1} markers in the rte_mbuf struct to stop using the markers and instead uses the mbuf fields directly.

Introduces 2 new inline functions to allow drivers to access rearm_data and rx_descriptor_fields1 descriptors without using the RTE_MARKER fields.

Updates all drivers to use the new inline rte_mbuf struct accessors for rearm_data and rx_descriptor_fields1.

Any previous Acks on the series are considered to be reset due to amount of change.

Quoted 6 lines

v5:
* update existing cacheline{0, 1} inline functions to access actual mbuf fields.
* introduce new inline functions for accessing rearm_data and rx_descriptor_fields1 descriptors.
* adapt drivers to use new inline functions.

Accessor functions like these are BS for structures that are part of the public API.
Nobody will use the accessor functions! When developing an application (or lib or driver), the developer will look at the structure and access the relevant fields directly; why would the developer start looking elsewhere for accessor functions?

Another alternative would be to remove the rearm_data and rx_descriptor_fields1 fields from the structure, and in the drivers address the first field of the group, and preferably add some static_asserts to check the sequence of the fields they cover. I don't like this alternative, but I'm putting it out there for discussion/inspiration. I prefer the union+struct approach to visibly group the fields together.

Overall, I dislike approach taken in this version of the patch series.
On the surface, it has minimal changes to the mbuf structure.
But underneath, some of the fields (the markers) may or may not exist, depending on compiler, and this fact is not obvious when looking at the structure. I think this will degrade future MSVC compatibility for both applications, libraries and PMDs.

As Thomas stressed, we should take special care of the mbuf structure! It has to be modified for MSVC compatibility, so we have to find the best compromise. Personally, I prefer the previous approach over this version.

Maybe we need to compromise on API compatibility to make this a beautiful modification.

@Thomas, looking at the mbuf and eal patches, what do you think about this version of the series?

#83 lore raw

Re: [PATCH v5 00/22] stop using RTE_MARKER extensions

24/02/2024 11:42, Morten Brørup:

Quoted 6 lines

From: Tyler Retzlaff [mailto:[email protected]]

Quoted 5 lines

RTE_MARKER typedefs are a GCC extension unsupported by MSVC. This series hides the markers when building with MSVC and updates libraries and drivers to access compatibly typed pointers to the rte_mbuf struct offsets.

Quoted 8 lines
Quoted 4 lines

This series, does the following.

Introduces a new macro __rte_marker(type, name) which is used to conditionally expand RTE_MARKER fields empty when building with GCC.

Important typo: GCC -> MSVC.

Correct me if I'm wrong: When building with MSVC, the RTE_MARKER fields don't exist at all.

Yes it should trigger a compiler error when using an old marker with MSVC. So no need of this wrapper __rte_marker().

Quoted 4 lines
Quoted 4 lines

Updates existing inline functions accessing cacheline{0,1} markers in the rte_mbuf struct to stop using the markers and instead uses the mbuf fields directly.

Quoted 8 lines
Quoted 6 lines

Introduces 2 new inline functions to allow drivers to access rearm_data and rx_descriptor_fields1 descriptors without using the RTE_MARKER fields.

Updates all drivers to use the new inline rte_mbuf struct accessors for rearm_data and rx_descriptor_fields1.

Accessor functions like these are BS for structures that are part of the public API.

What is BS?

Quoted 1 line

Nobody will use the accessor functions! When developing an application (or lib or driver), the developer will look at the structure and access the relevant fields directly; why would the developer start looking elsewhere for accessor functions?

Yes that's why we need to reference the accessors inside the mbuf structure. Also we should check new code (with checkpatch) for not using markers anymore.

Quoted 2 lines

Another alternative would be to remove the rearm_data and rx_descriptor_fields1 fields from the structure, and in the drivers address the first field of the group, and preferably add some static_asserts to check the sequence of the fields they cover. I don't like this alternative, but I'm putting it out there for discussion/inspiration. I prefer the union+struct approach to visibly group the fields together.

Unions make the mbuf struct more complicate just for compatibility.

Quoted 3 lines

Overall, I dislike approach taken in this version of the patch series.
On the surface, it has minimal changes to the mbuf structure.
But underneath, some of the fields (the markers) may or may not exist, depending on compiler, and this fact is not obvious when looking at the structure. I think this will degrade future MSVC compatibility for both applications, libraries and PMDs.

With appropriate checks, we won't use markers anymore.

Quoted 7 lines

As Thomas stressed, we should take special care of the mbuf structure! It has to be modified for MSVC compatibility, so we have to find the best compromise. Personally, I prefer the previous approach over this version.

Maybe we need to compromise on API compatibility to make this a beautiful modification.

@Thomas, looking at the mbuf and eal patches, what do you think about this version of the series?

I prefer this series with following changes:
- no __rte_marker wrapper
- make sure cache line padding is effective without markers
- no direct access of fields for cache line prefetch
- comments in mbuf
- checkpatch

#84 lore raw

RE: [PATCH v5 00/22] stop using RTE_MARKER extensions

Quoted 84 lines

From: Thomas Monjalon [mailto:[email protected]]
Sent: Saturday, 24 February 2024 12.14

24/02/2024 11:42, Morten Brørup:

Quoted 2 lines

From: Tyler Retzlaff [mailto:[email protected]]

Quoted 1 line

RTE_MARKER typedefs are a GCC extension unsupported by MSVC. This

series

Quoted 4 lines
Quoted 4 lines

hides the markers when building with MSVC and updates libraries and drivers to access compatibly typed pointers to the rte_mbuf struct offsets.

Quoted 8 lines
Quoted 4 lines

This series, does the following.

Introduces a new macro __rte_marker(type, name) which is used to conditionally expand RTE_MARKER fields empty when building with GCC.

Important typo: GCC -> MSVC.

Correct me if I'm wrong: When building with MSVC, the RTE_MARKER

fields don't exist at all.

Yes it should trigger a compiler error when using an old marker with MSVC.
So no need of this wrapper __rte_marker().

Quoted 1 line
Quoted 1 line

Updates existing inline functions accessing cacheline{0,1} markers

in

Quoted 1 line
Quoted 1 line

the rte_mbuf struct to stop using the markers and instead uses the

mbuf

Quoted 3 lines
Quoted 3 lines

fields directly.

Introduces 2 new inline functions to allow drivers to access

rearm_data

Quoted 4 lines
Quoted 4 lines

and rx_descriptor_fields1 descriptors without using the RTE_MARKER fields.

Updates all drivers to use the new inline rte_mbuf struct accessors

for

Quoted 3 lines
Quoted 1 line

rearm_data and rx_descriptor_fields1.

Accessor functions like these are BS for structures that are part of

the public API.

What is BS?

Quoted 1 line

Nobody will use the accessor functions! When developing an application

(or lib or driver), the developer will look at the structure and access the relevant fields directly; why would the developer start looking elsewhere for accessor functions?

Yes that's why we need to reference the accessors inside the mbuf structure.
Also we should check new code (with checkpatch) for not using markers anymore.

Quoted 1 line

Another alternative would be to remove the rearm_data and

rx_descriptor_fields1 fields from the structure, and in the drivers address the first field of the group, and preferably add some static_asserts to check the sequence of the fields they cover. I don't like this alternative, but I'm putting it out there for discussion/inspiration.

Quoted 1 line

I prefer the union+struct approach to visibly group the fields

together.

Unions make the mbuf struct more complicate just for compatibility.

Quoted 3 lines

Overall, I dislike approach taken in this version of the patch series. On the surface, it has minimal changes to the mbuf structure. But underneath, some of the fields (the markers) may or may not exist,

depending on compiler, and this fact is not obvious when looking at the structure. I think this will degrade future MSVC compatibility for both applications, libraries and PMDs.

With appropriate checks, we won't use markers anymore.

Quoted 2 lines

As Thomas stressed, we should take special care of the mbuf structure! It has to be modified for MSVC compatibility, so we have to find the

best compromise.

Quoted 3 lines

Personally, I prefer the previous approach over this version.

Maybe we need to compromise on API compatibility to make this a

beautiful modification.

Quoted 2 lines

@Thomas, looking at the mbuf and eal patches, what do you think about

Quoted 9 lines

this version of the series?

I prefer this series with following changes:
- no __rte_marker wrapper
- make sure cache line padding is effective without markers
- no direct access of fields for cache line prefetch
- comments in mbuf
- checkpatch

Thomas has provided a lot of good feedback for this version of the series, showing that the path is worth exploring further. In other words: I'm likely to be convinced. ;-)

#85 lore raw

v6 cover stop and remove RTE_MARKER typedefs

In reply to Tyler Retzlaff

RTE_MARKER typedefs are a GCC extension unsupported by MSVC. This series stops referencing and removes the markers.

This series, does the following.

* RTE_MARKER{,816,32,64} fields are removed from all structures.
* Moves duplicated assertions referencing marker fields to rte_mbuf_core.h and updates them to be based on static_assert using non marker field names.
* Updates prefetch inline functions to calculate the address to prefetch for cachline0 and cacheline1 without the markers.
* Introduces 2 new inline functions for accessing rearm_data and rx_descriptor_fields1 descriptor to decouple from use of the marker field names so that they can be removed.
* Updates driver access to use new inline descriptors.

v6:
* remove all rte marker fields and note their removal in release notes.
* move duplicated assertions to global scope with struct rte_mbuf.
* calculate cacheline{0,1} addresses without using struct rte_mbuf fields.
* added comments into struct rte_mbuf field directing readers to use inline accessors for rearm_data and rx_descriptor_fields1 descriptors.
* added checkpatches check to block new additions using RTE_MARKER typedefs.
* switch to using alignas to align cacheline1 in modified structs.
* removed __rte_marker macro as it was not desired and is now not needed.

v5:
* update existing cacheline{0, 1} inline functions to access actual mbuf fields.
* introduce new inline functions for accessing rearm_data and rx_descriptor_fields1 descriptors.
* adapt drivers to use new inline functions.

prior versions not relevant due to re-work of entire series.

Tyler Retzlaff (23):
mbuf: add accessors for rearm and Rx descriptor fields
mbuf: consolidate driver asserts for mbuf struct common/idpf: use mbuf descriptor accessors net/bnxt: use mbuf descriptor accessors net/cnxk: use mbuf descriptor accessors net/enic: use mbuf descriptor accessors net/fm10k: use mbuf descriptor accessors net/hns3: use mbuf descriptor accessors net/i40e: use mbuf descriptor accessors net/iavf: use mbuf descriptor accessors net/ice: use mbuf descriptor accessors net/ionic: use mbuf descriptor accessors net/ixgbe: use mbuf descriptor accessors net/mlx5: use mbuf descriptor accessors net/octeon_ep: use mbuf descriptor accessors net/sfc: use mbuf descriptor accessors net/thunderx: use mbuf descriptor accessors net/virtio: use mbuf descriptor accessors examples/dma: use mbuf descriptor accessor
mbuf: remove and stop using rte marker fields
security: remove rte marker fields
cryptodev: remove rte marker fields
devtools: forbid new use of rte marker typedefs

 devtools/checkpatches.sh                        |  8 +++
 doc/guides/rel_notes/release_24_03.rst          | 15 +++++
 drivers/common/idpf/idpf_common_rxtx.c          |  4 +-
 drivers/common/idpf/idpf_common_rxtx_avx512.c   | 73 +++++----------------
 drivers/net/bnxt/bnxt_rxtx_vec_avx2.c           | 32 +++++-----
 drivers/net/bnxt/bnxt_rxtx_vec_common.h         |  4 +-
 drivers/net/bnxt/bnxt_rxtx_vec_neon.c           | 16 ++---
 drivers/net/bnxt/bnxt_rxtx_vec_sse.c            | 16 ++---
 drivers/net/cnxk/cn10k_rx.h                     | 36 +++++------
 drivers/net/cnxk/cn9k_rx.h                      | 20 +++---
 drivers/net/cnxk/cnxk_ethdev.c                  |  2 +-
 drivers/net/enic/enic_main.c                    |  4 +-
 drivers/net/enic/enic_rxtx_vec_avx2.c           | 18 +++---
 drivers/net/fm10k/fm10k_rxtx_vec.c              | 32 ++--------
 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 +-
 drivers/net/i40e/i40e_rxtx_vec_altivec.c        | 18 ++----
 drivers/net/i40e/i40e_rxtx_vec_avx2.c           | 34 +++-------
 drivers/net/i40e/i40e_rxtx_vec_avx512.c         | 35 +++-------
 drivers/net/i40e/i40e_rxtx_vec_common.h         |  4 +-
 drivers/net/i40e/i40e_rxtx_vec_neon.c           | 16 ++---
 drivers/net/i40e/i40e_rxtx_vec_sse.c            | 43 +++----------
 drivers/net/iavf/iavf_rxtx_vec_avx2.c           | 72 +++++----------------
 drivers/net/iavf/iavf_rxtx_vec_avx512.c         | 72 +++++----------------
 drivers/net/iavf/iavf_rxtx_vec_common.h         |  4 +-
 drivers/net/iavf/iavf_rxtx_vec_neon.c           | 16 ++---
 drivers/net/iavf/iavf_rxtx_vec_sse.c            | 85 +++++--------------------
 drivers/net/ice/ice_rxtx_vec_avx2.c             | 36 +++--------
 drivers/net/ice/ice_rxtx_vec_avx512.c           | 37 +++--------
 drivers/net/ice/ice_rxtx_vec_common.h           |  4 +-
 drivers/net/ice/ice_rxtx_vec_sse.c              | 44 +++----------
 drivers/net/ionic/ionic_lif.c                   |  6 +-
 drivers/net/ionic/ionic_rxtx_sg.c               |  4 +-
 drivers/net/ionic/ionic_rxtx_simple.c           |  2 +-
 drivers/net/ixgbe/ixgbe_rxtx_vec_common.h       |  4 +-
 drivers/net/ixgbe/ixgbe_rxtx_vec_neon.c         | 12 ++--
 drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c          | 51 ++++-----------
 drivers/net/mlx5/mlx5_rxq.c                     |  2 +-
 drivers/net/mlx5/mlx5_rxtx_vec.h                | 19 ------
 drivers/net/mlx5/mlx5_rxtx_vec_altivec.h        | 28 ++++----
 drivers/net/mlx5/mlx5_rxtx_vec_neon.h           | 20 +++---
 drivers/net/mlx5/mlx5_rxtx_vec_sse.h            | 28 ++++----
 drivers/net/octeon_ep/cnxk_ep_rx.h              |  2 +-
 drivers/net/octeon_ep/cnxk_ep_rx_avx.c          |  2 +-
 drivers/net/octeon_ep/cnxk_ep_rx_neon.c         |  8 +--
 drivers/net/octeon_ep/cnxk_ep_rx_sse.c          |  8 +--
 drivers/net/octeon_ep/otx_ep_rxtx.c             |  5 +-
 drivers/net/sfc/sfc_ef100_rx.c                  |  7 +-
 drivers/net/sfc/sfc_ef10_rx.c                   | 10 +--
 drivers/net/thunderx/nicvf_ethdev.c             |  4 +-
 drivers/net/thunderx/nicvf_rxtx.h               |  4 +-
 drivers/net/virtio/virtio_rxtx_packed.h         |  4 +-
 drivers/net/virtio/virtio_rxtx_packed_avx.h     | 16 ++---
 drivers/net/virtio/virtio_rxtx_packed_neon.h    | 18 +++---
 drivers/net/virtio/virtio_rxtx_simple.c         |  4 +-
 drivers/net/virtio/virtio_rxtx_simple.h         |  5 +-
 drivers/net/virtio/virtio_rxtx_simple_altivec.c | 16 ++---
 drivers/net/virtio/virtio_rxtx_simple_neon.c    | 24 +++----
 drivers/net/virtio/virtio_rxtx_simple_sse.c     | 16 ++---
 examples/dma/dmafwd.c                           |  5 +-
 lib/cryptodev/cryptodev_pmd.h                   |  5 +-
 lib/mbuf/rte_mbuf.h                             | 17 ++++-
 lib/mbuf/rte_mbuf_core.h                        | 50 ++++++++++++---
 lib/security/rte_security_driver.h              |  5 +-
 65 files changed, 445 insertions(+), 816 deletions(-)
Signature · 1 line
1.8.3.1
#86 lore raw

PATCH v6 1/23 mbuf: add accessors for rearm and Rx descriptor fields

RTE_MARKER typedefs are a GCC extension unsupported by MSVC. Provide inline functions to access compatible type pointer to rearm_data and rx_descriptor_fields1 which will allow direct references on the rte marker fields to be removed.

---
 lib/mbuf/rte_mbuf.h      | 13 +++++++++++++
 lib/mbuf/rte_mbuf_core.h | 11 ++++++++++-
 2 files changed, 23 insertions(+), 1 deletion(-)
lib/mbuf/rte_mbuf.h +13 -0
index 286b32b..aa7495b 100644
@@ -132,6 +132,19 @@
 #endif
 }
 
+static inline
+uint64_t *
+rte_mbuf_rearm_data(struct rte_mbuf *m)
+{
+	return (uint64_t *)&m->data_off;
+}
+
+static inline
+void *
+rte_mbuf_rx_descriptor_fields1(struct rte_mbuf *m)
+{
+	return &m->packet_type;
+}
 
 static inline uint16_t rte_pktmbuf_priv_size(struct rte_mempool *mp);
 
lib/mbuf/rte_mbuf_core.h +10 -1
index 5688683..7000c04 100644
@@ -486,7 +486,12 @@ struct rte_mbuf {
 	struct rte_mbuf *next;
 #endif
 
-	/* next 8 bytes are initialised on RX descriptor rearm */
+	/**
+	 * next 8 bytes are initialised on RX descriptor rearm
+	 *
+	 * To obtain a pointer to rearm_data use the rte_mbuf_rearm_data()
+	 * accessor instead of directly referencing through the data_off field.
+	 */
 	RTE_MARKER64 rearm_data;
 	uint16_t data_off;
 
@@ -522,6 +527,10 @@ struct rte_mbuf {
 	 * mbuf. Example: if vlan stripping is enabled, a received vlan packet
 	 * would have RTE_PTYPE_L2_ETHER and not RTE_PTYPE_L2_VLAN because the
 	 * vlan is stripped from the data.
+	 *
+	 * To obtain a pointer to rx_descriptor_fields1 use the
+	 * rte_mbuf_rx_descriptor_fields1() accessor instead of directly
+	 * referencing through the the anonymous union fields.
 	 */
 	union {
 		uint32_t packet_type; /**< L2/L3/L4 and tunnel information. */
Signature · 1 line
1.8.3.1
#87 lore raw

RE: [PATCH v6 01/23] mbuf: add accessors for rearm and Rx descriptor fields

Quoted 19 lines

From: Tyler Retzlaff [mailto:[email protected]]
Sent: Tuesday, 27 February 2024 06.41

RTE_MARKER typedefs are a GCC extension unsupported by MSVC. Provide inline functions to access compatible type pointer to rearm_data and rx_descriptor_fields1 which will allow direct references on the rte marker fields to be removed.

---
 lib/mbuf/rte_mbuf.h      | 13 +++++++++++++
 lib/mbuf/rte_mbuf_core.h | 11 ++++++++++-
 2 files changed, 23 insertions(+), 1 deletion(-)
lib/mbuf/rte_mbuf.h +0 -0
index 286b32b..aa7495b 100644

lib/mbuf/rte_mbuf.h line 140

Quoted 9 lines
lib/mbuf/rte_mbuf.h +6 -0
@@ -132,6 +132,19 @@
 #endif
 }
 
+static inline
+uint64_t *
+rte_mbuf_rearm_data(struct rte_mbuf *m)
+{
+	return (uint64_t *)&m->data_off;
+}

Consider returning (void *) instead of (uint64_t *). Just a suggestion; I don't know which is better.

lib/mbuf/rte_mbuf.h line 147

Quoted 7 lines
lib/mbuf/rte_mbuf.h +7 -0
+
+static inline
+void *
+rte_mbuf_rx_descriptor_fields1(struct rte_mbuf *m)
+{
+	return &m->packet_type;
+}

The mbuf_rx_descriptor_fields1 field is disappearing in a later patch; consider taking the opportunity to use a better name here.

Quoted 8 lines
lib/mbuf/rte_mbuf.h +0 -0
 static inline uint16_t rte_pktmbuf_priv_size(struct rte_mempool *mp);
 
lib/mbuf/rte_mbuf_core.h +0 -0
index 5688683..7000c04 100644

lib/mbuf/rte_mbuf_core.h struct rte_mbuf { · line 492

Quoted 8 lines
lib/mbuf/rte_mbuf_core.h +4 -1
@@ -486,7 +486,12 @@ struct rte_mbuf {
 	struct rte_mbuf *next;
 #endif
 
-	/* next 8 bytes are initialised on RX descriptor rearm */
+	/**
+	 * next 8 bytes are initialised on RX descriptor rearm
+	 *
+	 * To obtain a pointer to rearm_data use the rte_mbuf_rearm_data()

The "rearm_data" field is disappearing in a later patch; don't refer to it by that name in the comments here.

lib/mbuf/rte_mbuf_core.h struct rte_mbuf { · line 532

Quoted 12 lines
lib/mbuf/rte_mbuf_core.h +5 -0
+	 * accessor instead of directly referencing through the data_off field.
+	 */
 	RTE_MARKER64 rearm_data;
 	uint16_t data_off;
 
@@ -522,6 +527,10 @@ struct rte_mbuf {
 	 * mbuf. Example: if vlan stripping is enabled, a received vlan packet
 	 * would have RTE_PTYPE_L2_ETHER and not RTE_PTYPE_L2_VLAN because the
 	 * vlan is stripped from the data.
+	 *
+	 * To obtain a pointer to rx_descriptor_fields1 use the
+	 * rte_mbuf_rx_descriptor_fields1() accessor instead of directly

The "rx_descriptor_fields1" field is disappearing in a later patch;
don't refer to it by that name in the comments here.
And if you update the access function's name, remember to update it in the comment here too.

Quoted 6 lines
lib/mbuf/rte_mbuf_core.h +1 -1
+	 * referencing through the the anonymous union fields.
 	 */
 	union {
 		uint32_t packet_type; /**< L2/L3/L4 and tunnel information. */
--

1.8.3.1

#88 lore raw

Re: [PATCH v6 01/23] mbuf: add accessors for rearm and Rx descriptor fields

Quoted 22 lines · Morten Brørup
Quoted 22 lines

From: Tyler Retzlaff [mailto:[email protected]]
Sent: Tuesday, 27 February 2024 06.41

RTE_MARKER typedefs are a GCC extension unsupported by MSVC. Provide inline functions to access compatible type pointer to rearm_data and rx_descriptor_fields1 which will allow direct references on the rte marker fields to be removed.

---
 lib/mbuf/rte_mbuf.h      | 13 +++++++++++++
 lib/mbuf/rte_mbuf_core.h | 11 ++++++++++-
 2 files changed, 23 insertions(+), 1 deletion(-)
lib/mbuf/rte_mbuf.h +0 -0
index 286b32b..aa7495b 100644
@@ -132,6 +132,19 @@
 #endif
 }
 
Quoted 9 lines

lib/mbuf/rte_mbuf.h line 140

Quoted 6 lines
lib/mbuf/rte_mbuf.h +6 -0
+static inline
+uint64_t *
+rte_mbuf_rearm_data(struct rte_mbuf *m)
+{
+	return (uint64_t *)&m->data_off;
+}

Consider returning (void *) instead of (uint64_t *). Just a suggestion; I don't know which is better.

if you mean just the cast i don't think it matters. arguably it could go void * first but we're already aliasing through a different type. this is one argument in favor of the union.

Quoted 11 lines

lib/mbuf/rte_mbuf.h line 147

Quoted 8 lines
lib/mbuf/rte_mbuf.h +7 -0
+
+static inline
+void *
+rte_mbuf_rx_descriptor_fields1(struct rte_mbuf *m)
+{
+	return &m->packet_type;
+}

The mbuf_rx_descriptor_fields1 field is disappearing in a later patch; consider taking the opportunity to use a better name here.

oh boy. you're asking for a new name but not suggesting a new name. naming is hard (no one is ever happy). for this and rearm_data if you or anyone suggests a name i'll make the change ~everywhere including comments across all drivers.

Quoted 12 lines
Quoted 12 lines
lib/mbuf/rte_mbuf.h +0 -0
 static inline uint16_t rte_pktmbuf_priv_size(struct rte_mempool *mp);
 
lib/mbuf/rte_mbuf_core.h +0 -0
index 5688683..7000c04 100644
@@ -486,7 +486,12 @@ struct rte_mbuf {
 	struct rte_mbuf *next;
 #endif
 
Quoted 8 lines

lib/mbuf/rte_mbuf_core.h struct rte_mbuf { · line 492

Quoted 5 lines
lib/mbuf/rte_mbuf_core.h +4 -1
-	/* next 8 bytes are initialised on RX descriptor rearm */
+	/**
+	 * next 8 bytes are initialised on RX descriptor rearm
+	 *
+	 * To obtain a pointer to rearm_data use the rte_mbuf_rearm_data()

The "rearm_data" field is disappearing in a later patch; don't refer to it by that name in the comments here.

without having renamed the block of fields cheerfully known as "rearm_data" i kept all documentation/comments here and in drivers using rearm_data for familiarity. (unless someone suggests a new name for the group of fields).

Quoted 6 lines
Quoted 6 lines
lib/mbuf/rte_mbuf_core.h +2 -0
+	 * accessor instead of directly referencing through the data_off field.
+	 */
 	RTE_MARKER64 rearm_data;
 	uint16_t data_off;
 
Quoted 11 lines

lib/mbuf/rte_mbuf_core.h struct rte_mbuf { · line 532

Quoted 7 lines
lib/mbuf/rte_mbuf_core.h +3 -0
@@ -522,6 +527,10 @@ struct rte_mbuf {
 	 * mbuf. Example: if vlan stripping is enabled, a received vlan packet
 	 * would have RTE_PTYPE_L2_ETHER and not RTE_PTYPE_L2_VLAN because the
 	 * vlan is stripped from the data.
+	 *
+	 * To obtain a pointer to rx_descriptor_fields1 use the
+	 * rte_mbuf_rx_descriptor_fields1() accessor instead of directly

The "rx_descriptor_fields1" field is disappearing in a later patch;
don't refer to it by that name in the comments here.
And if you update the access function's name, remember to update it in the comment here too.

same as above.

Quoted 7 lines
Quoted 7 lines
lib/mbuf/rte_mbuf_core.h +1 -1
+	 * referencing through the the anonymous union fields.
 	 */
 	union {
 		uint32_t packet_type; /**< L2/L3/L4 and tunnel information. */
--

1.8.3.1

#89 lore raw

RE: [PATCH v6 01/23] mbuf: add accessors for rearm and Rx descriptor fields

+To: Thomas, previously joined the discussion

Quoted 36 lines

From: Tyler Retzlaff [mailto:[email protected]]
Sent: Tuesday, 27 February 2024 18.17

Quoted 22 lines · Morten Brørup
Quoted 22 lines

From: Tyler Retzlaff [mailto:[email protected]]
Sent: Tuesday, 27 February 2024 06.41

RTE_MARKER typedefs are a GCC extension unsupported by MSVC. Provide inline functions to access compatible type pointer to rearm_data and rx_descriptor_fields1 which will allow direct references on the rte marker fields to be removed.

---
 lib/mbuf/rte_mbuf.h      | 13 +++++++++++++
 lib/mbuf/rte_mbuf_core.h | 11 ++++++++++-
 2 files changed, 23 insertions(+), 1 deletion(-)
lib/mbuf/rte_mbuf.h +0 -0
index 286b32b..aa7495b 100644
@@ -132,6 +132,19 @@
 #endif
 }
 
Quoted 9 lines

lib/mbuf/rte_mbuf.h line 140

Quoted 6 lines
lib/mbuf/rte_mbuf.h +6 -0
+static inline
+uint64_t *
+rte_mbuf_rearm_data(struct rte_mbuf *m)
+{
+	return (uint64_t *)&m->data_off;
+}

Consider returning (void *) instead of (uint64_t *). Just a suggestion; I don't know which is better.

Quoted 1 line

if you mean just the cast i don't think it matters.

No, I meant the return type.
The type is opaque; only its size is fixed at 8 byte. Maybe uint64_t * is the best type, after all.

Quoted 3 lines

arguably it could go
void * first but we're already aliasing through a different type. this is one argument in favor of the union.

The zero-size markers (rearm_data and rx_descriptor_fields1) were intended to be used like unions, which the drivers effectively do.
Previous C standards didn't allow anonymous structures, so using union+struct in pre-C11 DPDK would clutter the code with subfield names. But now that we moved on to C11, we don't have this problem anymore.

IMHO, replacing the zero-size markers - which are directly visible in the structure's source code - with access functions located in some other header file degrades source code readability.

I am in favor of union+struct in the mbuf structure over access functions. I think the explicit grouping of the fields improves the readability of the mbuf structure, also compared to the zero-size markers.

Quoted 13 lines
Quoted 12 lines

lib/mbuf/rte_mbuf.h line 147

Quoted 9 lines
lib/mbuf/rte_mbuf.h +7 -0
+
+static inline
+void *
+rte_mbuf_rx_descriptor_fields1(struct rte_mbuf *m)
+{
+	return &m->packet_type;
+}

The mbuf_rx_descriptor_fields1 field is disappearing in a later patch; consider taking the opportunity to use a better name here.

Quoted 4 lines

oh boy. you're asking for a new name but not suggesting a new name. naming is hard (no one is ever happy). for this and rearm_data if you or anyone suggests a name i'll make the change ~everywhere including comments across all drivers.

As you mention below, keeping the current names is an advantage for familiarity.
Changing the name brings no real benefit, and although the current name is somewhat silly (perhaps anticipating a second group of rx descriptor fields), we should probably just keep it.

Quoted 22 lines
Quoted 13 lines
Quoted 13 lines
lib/mbuf/rte_mbuf.h +0 -0
 static inline uint16_t rte_pktmbuf_priv_size(struct rte_mempool *mp);
 
lib/mbuf/rte_mbuf_core.h +0 -0
index 5688683..7000c04 100644
@@ -486,7 +486,12 @@ struct rte_mbuf {
 	struct rte_mbuf *next;
 #endif
 
Quoted 8 lines

lib/mbuf/rte_mbuf_core.h struct rte_mbuf { · line 492

Quoted 5 lines
lib/mbuf/rte_mbuf_core.h +4 -1
-	/* next 8 bytes are initialised on RX descriptor rearm */
+	/**
+	 * next 8 bytes are initialised on RX descriptor rearm
+	 *
+	 * To obtain a pointer to rearm_data use the rte_mbuf_rearm_data()

The "rearm_data" field is disappearing in a later patch; don't refer to it by that name in the comments here.

Quoted 5 lines

without having renamed the block of fields cheerfully known as "rearm_data" i kept all documentation/comments here and in drivers using rearm_data for familiarity. (unless someone suggests a new name for the group
of fields).

OK, you already thought about the use of the names in the documentation. I don't object to your conclusion.

Quoted 29 lines
Quoted 7 lines
Quoted 7 lines
lib/mbuf/rte_mbuf_core.h +2 -0
+	 * accessor instead of directly referencing through the data_off field.
+	 */
 	RTE_MARKER64 rearm_data;
 	uint16_t data_off;
 
Quoted 11 lines

lib/mbuf/rte_mbuf_core.h struct rte_mbuf { · line 532

Quoted 7 lines
lib/mbuf/rte_mbuf_core.h +3 -0
@@ -522,6 +527,10 @@ struct rte_mbuf {
 	 * mbuf. Example: if vlan stripping is enabled, a received vlan packet
 	 * would have RTE_PTYPE_L2_ETHER and not RTE_PTYPE_L2_VLAN because the
 	 * vlan is stripped from the data.
+	 *
+	 * To obtain a pointer to rx_descriptor_fields1 use the
+	 * rte_mbuf_rx_descriptor_fields1() accessor instead of directly

The "rx_descriptor_fields1" field is disappearing in a later patch; don't refer to it by that name in the comments here.
And if you update the access function's name, remember to update it in the

comment here too.

same as above.

Quoted 7 lines
Quoted 7 lines
lib/mbuf/rte_mbuf_core.h +1 -1
+	 * referencing through the the anonymous union fields.
 	 */
 	union {
 		uint32_t packet_type; /**< L2/L3/L4 and tunnel information. */
--

1.8.3.1

#90 lore raw

Re: [PATCH v6 01/23] mbuf: add accessors for rearm and Rx descriptor fields

Quoted 38 lines · Morten Brørup

+To: Thomas, previously joined the discussion

Quoted 36 lines

From: Tyler Retzlaff [mailto:[email protected]]
Sent: Tuesday, 27 February 2024 18.17

Quoted 31 lines · Morten Brørup
Quoted 19 lines

From: Tyler Retzlaff [mailto:[email protected]]
Sent: Tuesday, 27 February 2024 06.41

RTE_MARKER typedefs are a GCC extension unsupported by MSVC. Provide inline functions to access compatible type pointer to rearm_data and rx_descriptor_fields1 which will allow direct references on the rte marker fields to be removed.

---
 lib/mbuf/rte_mbuf.h      | 13 +++++++++++++
 lib/mbuf/rte_mbuf_core.h | 11 ++++++++++-
 2 files changed, 23 insertions(+), 1 deletion(-)
lib/mbuf/rte_mbuf.h +0 -0
index 286b32b..aa7495b 100644

lib/mbuf/rte_mbuf.h line 140

Quoted 9 lines
lib/mbuf/rte_mbuf.h +6 -0
@@ -132,6 +132,19 @@
 #endif
 }
 
+static inline
+uint64_t *
+rte_mbuf_rearm_data(struct rte_mbuf *m)
+{
+	return (uint64_t *)&m->data_off;
+}

Consider returning (void *) instead of (uint64_t *). Just a suggestion; I don't know which is better.

Quoted 5 lines
Quoted 1 line

if you mean just the cast i don't think it matters.

No, I meant the return type.
The type is opaque; only its size is fixed at 8 byte. Maybe uint64_t * is the best type, after all.

ah, in many places the drivers want the uint64_t * keeping it here allows for some of the casts (and potential for mistakes) to be discarded. if i recall in some places they do math on the returned pointer.

Quoted 11 lines
Quoted 4 lines

arguably it could go
void * first but we're already aliasing through a different type. this is one argument in favor of the union.

The zero-size markers (rearm_data and rx_descriptor_fields1) were intended to be used like unions, which the drivers effectively do.
Previous C standards didn't allow anonymous structures, so using union+struct in pre-C11 DPDK would clutter the code with subfield names. But now that we moved on to C11, we don't have this problem anymore.

IMHO, replacing the zero-size markers - which are directly visible in the structure's source code - with access functions located in some other header file degrades source code readability.

I am in favor of union+struct in the mbuf structure over access functions. I think the explicit grouping of the fields improves the readability of the mbuf structure, also compared to the zero-size markers.

it's unfortunate the zero-size markers could be accessed slightly differently than the anonymous unions necessitating code referencing them to be changed.

Thomas and i discussed rearm_data and rx_descriptor_fields1 at length and it was understood why i had to add new field names if using the union approach there was an expressed preference for accessors.

one possibly important detail that came out of our conversation was that rearm_data rx_descriptor_fields1 are (I think) supposed to be internal and that being the case means updading the dpdk drivers means i updated *all* consumers i.e. i can break the api and adapt in the same commit if they are truly internal because no application should be accessing the fields.

one approach i've enjoyed some success with is to present semi-opaque structures where the internal fields are by convention discouraged in their use but doing this requires duplicating parts of the whole to e.g. give the drivers the view of the struct they need and is an increased burden for maintainers. again this relies on the fields actually being internal only.

both approaches have been put up in this series now, just looking for folks to look at the two and push for one or the other.

thanks!

#91 lore raw

PATCH v6 2/23 mbuf: consolidate driver asserts for mbuf struct

In reply to Tyler Retzlaff

Collect duplicated RTE_BUILD_BUG_ON checks from drivers and place them at global scope with struct rte_mbuf definition using static_assert.

---
 lib/mbuf/rte_mbuf_core.h | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)
lib/mbuf/rte_mbuf_core.h +34 -0
index 7000c04..36551c2 100644
@@ -16,8 +16,11 @@
  * New fields and flags should fit in the "dynamic space".
  */
 
+#include <assert.h>
+#include <stddef.h>
 #include <stdint.h>
 
+#include <rte_common.h>
 #include <rte_byteorder.h>
 #include <rte_stdatomic.h>
 
@@ -673,6 +676,37 @@ struct rte_mbuf {
 	uint32_t dynfield1[9]; /**< Reserved for dynamic fields. */
 } __rte_cache_aligned;
 
+static_assert(!(offsetof(struct rte_mbuf, ol_flags) !=
+	offsetof(struct rte_mbuf, rearm_data) + 8), "ol_flags");
+static_assert(!(offsetof(struct rte_mbuf, rearm_data) !=
+	RTE_ALIGN(offsetof(struct rte_mbuf, rearm_data), 16)), "rearm_data");
+static_assert(!(offsetof(struct rte_mbuf, data_off) !=
+	offsetof(struct rte_mbuf, rearm_data)), "data_off");
+static_assert(!(offsetof(struct rte_mbuf, data_off) <
+	offsetof(struct rte_mbuf, rearm_data)), "data_off");
+static_assert(!(offsetof(struct rte_mbuf, refcnt) <
+	offsetof(struct rte_mbuf, rearm_data)), "refcnt");
+static_assert(!(offsetof(struct rte_mbuf, nb_segs) <
+	offsetof(struct rte_mbuf, rearm_data)), "nb_segs");
+static_assert(!(offsetof(struct rte_mbuf, port) <
+	offsetof(struct rte_mbuf, rearm_data)), "port");
+static_assert(!(offsetof(struct rte_mbuf, data_off) -
+	offsetof(struct rte_mbuf, rearm_data) > 6), "data_off");
+static_assert(!(offsetof(struct rte_mbuf, refcnt) -
+	offsetof(struct rte_mbuf, rearm_data) > 6), "refcnt");
+static_assert(!(offsetof(struct rte_mbuf, nb_segs) -
+	offsetof(struct rte_mbuf, rearm_data) > 6), "nb_segs");
+static_assert(!(offsetof(struct rte_mbuf, port) -
+	offsetof(struct rte_mbuf, rearm_data) > 6), "port");
+static_assert(!(offsetof(struct rte_mbuf, pkt_len) !=
+	offsetof(struct rte_mbuf, rx_descriptor_fields1) + 4), "pkt_len");
+static_assert(!(offsetof(struct rte_mbuf, data_len) !=
+	offsetof(struct rte_mbuf, rx_descriptor_fields1) + 8), "data_len");
+static_assert(!(offsetof(struct rte_mbuf, vlan_tci) !=
+	offsetof(struct rte_mbuf, rx_descriptor_fields1) + 10), "vlan_tci");
+static_assert(!(offsetof(struct rte_mbuf, hash) !=
+	offsetof(struct rte_mbuf, rx_descriptor_fields1) + 12), "hash");
+
 /**
  * Function typedef of callback to free externally attached buffer.
  */
Signature · 1 line
1.8.3.1
Acked-by on v6 2/23
#92 lore raw

RE: [PATCH v6 02/23] mbuf: consolidate driver asserts for mbuf struct

Quoted 57 lines

Subject: [PATCH v6 02/23] mbuf: consolidate driver asserts for mbuf struct

Collect duplicated RTE_BUILD_BUG_ON checks from drivers and place them at global scope with struct rte_mbuf definition using static_assert.

---
 lib/mbuf/rte_mbuf_core.h | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)
lib/mbuf/rte_mbuf_core.h +28 -0
index 7000c04..36551c2 100644
@@ -16,8 +16,11 @@
  * New fields and flags should fit in the "dynamic space".
  */
 
+#include <assert.h>
+#include <stddef.h>
 #include <stdint.h>
 
+#include <rte_common.h>
 #include <rte_byteorder.h>
 #include <rte_stdatomic.h>
 
@@ -673,6 +676,37 @@ struct rte_mbuf {
 	uint32_t dynfield1[9]; /**< Reserved for dynamic fields. */
 } __rte_cache_aligned;
 
+static_assert(!(offsetof(struct rte_mbuf, ol_flags) !=
+	offsetof(struct rte_mbuf, rearm_data) + 8), "ol_flags");
+static_assert(!(offsetof(struct rte_mbuf, rearm_data) !=
+	RTE_ALIGN(offsetof(struct rte_mbuf, rearm_data), 16)), "rearm_data");
+static_assert(!(offsetof(struct rte_mbuf, data_off) !=
+	offsetof(struct rte_mbuf, rearm_data)), "data_off");
+static_assert(!(offsetof(struct rte_mbuf, data_off) <
+	offsetof(struct rte_mbuf, rearm_data)), "data_off");
+static_assert(!(offsetof(struct rte_mbuf, refcnt) <
+	offsetof(struct rte_mbuf, rearm_data)), "refcnt");
+static_assert(!(offsetof(struct rte_mbuf, nb_segs) <
+	offsetof(struct rte_mbuf, rearm_data)), "nb_segs");
+static_assert(!(offsetof(struct rte_mbuf, port) <
+	offsetof(struct rte_mbuf, rearm_data)), "port");
+static_assert(!(offsetof(struct rte_mbuf, data_off) -
+	offsetof(struct rte_mbuf, rearm_data) > 6), "data_off");
+static_assert(!(offsetof(struct rte_mbuf, refcnt) -
+	offsetof(struct rte_mbuf, rearm_data) > 6), "refcnt");
+static_assert(!(offsetof(struct rte_mbuf, nb_segs) -
+	offsetof(struct rte_mbuf, rearm_data) > 6), "nb_segs");
+static_assert(!(offsetof(struct rte_mbuf, port) -
+	offsetof(struct rte_mbuf, rearm_data) > 6), "port");
+static_assert(!(offsetof(struct rte_mbuf, pkt_len) !=
+	offsetof(struct rte_mbuf, rx_descriptor_fields1) + 4), "pkt_len");
+static_assert(!(offsetof(struct rte_mbuf, data_len) !=

lib/mbuf/rte_mbuf_core.h struct rte_mbuf {

Quoted 10 lines
lib/mbuf/rte_mbuf_core.h +6 -1
+	offsetof(struct rte_mbuf, rx_descriptor_fields1) + 8), "data_len");
+static_assert(!(offsetof(struct rte_mbuf, vlan_tci) !=
+	offsetof(struct rte_mbuf, rx_descriptor_fields1) + 10), "vlan_tci");
+static_assert(!(offsetof(struct rte_mbuf, hash) !=
+	offsetof(struct rte_mbuf, rx_descriptor_fields1) + 12), "hash");
+
 /**
  * Function typedef of callback to free externally attached buffer.
  */
--
Quoted 1 line

1.8.3.1

#93 lore raw

Re: [PATCH v6 02/23] mbuf: consolidate driver asserts for mbuf struct

In reply to Tyler Retzlaff

We've gone around in circles a little on this series. Let's discuss it at the next techboard meeting, please put it on the agenda.

Summary

MSVC does not support the typedef of zero-sized typed arrays used in struct rte_mbuf and a handful of other structs built on Windows. Better known as ``RTE_MARKER`` fields.

There are two competing solutions we would like to know which to move forward with.

1. Use C11 anonymous unions and anonymous struct extensions to replace the RTE_MARKER fields which can maintain ABI and API compatibility.

2. Provide inline accessors for struct rte_mbuf for some fields and removing others which maintains ABI but breaks API.

I'm proposing a mix of 1 & 2 to maintain ABI and some API for struct rte_mbuf fields but remove (API breaking) cacheline{0,1} RTE_MARKER fields in favor of existing inline functions for prefetching.

Thanks!

Quoted 64 lines · Tyler Retzlaff

Collect duplicated RTE_BUILD_BUG_ON checks from drivers and place them at global scope with struct rte_mbuf definition using static_assert.

---
 lib/mbuf/rte_mbuf_core.h | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)
lib/mbuf/rte_mbuf_core.h +34 -0
index 7000c04..36551c2 100644
@@ -16,8 +16,11 @@
  * New fields and flags should fit in the "dynamic space".
  */
 
+#include <assert.h>
+#include <stddef.h>
 #include <stdint.h>
 
+#include <rte_common.h>
 #include <rte_byteorder.h>
 #include <rte_stdatomic.h>
 
@@ -673,6 +676,37 @@ struct rte_mbuf {
 	uint32_t dynfield1[9]; /**< Reserved for dynamic fields. */
 } __rte_cache_aligned;
 
+static_assert(!(offsetof(struct rte_mbuf, ol_flags) !=
+	offsetof(struct rte_mbuf, rearm_data) + 8), "ol_flags");
+static_assert(!(offsetof(struct rte_mbuf, rearm_data) !=
+	RTE_ALIGN(offsetof(struct rte_mbuf, rearm_data), 16)), "rearm_data");
+static_assert(!(offsetof(struct rte_mbuf, data_off) !=
+	offsetof(struct rte_mbuf, rearm_data)), "data_off");
+static_assert(!(offsetof(struct rte_mbuf, data_off) <
+	offsetof(struct rte_mbuf, rearm_data)), "data_off");
+static_assert(!(offsetof(struct rte_mbuf, refcnt) <
+	offsetof(struct rte_mbuf, rearm_data)), "refcnt");
+static_assert(!(offsetof(struct rte_mbuf, nb_segs) <
+	offsetof(struct rte_mbuf, rearm_data)), "nb_segs");
+static_assert(!(offsetof(struct rte_mbuf, port) <
+	offsetof(struct rte_mbuf, rearm_data)), "port");
+static_assert(!(offsetof(struct rte_mbuf, data_off) -
+	offsetof(struct rte_mbuf, rearm_data) > 6), "data_off");
+static_assert(!(offsetof(struct rte_mbuf, refcnt) -
+	offsetof(struct rte_mbuf, rearm_data) > 6), "refcnt");
+static_assert(!(offsetof(struct rte_mbuf, nb_segs) -
+	offsetof(struct rte_mbuf, rearm_data) > 6), "nb_segs");
+static_assert(!(offsetof(struct rte_mbuf, port) -
+	offsetof(struct rte_mbuf, rearm_data) > 6), "port");
+static_assert(!(offsetof(struct rte_mbuf, pkt_len) !=
+	offsetof(struct rte_mbuf, rx_descriptor_fields1) + 4), "pkt_len");
+static_assert(!(offsetof(struct rte_mbuf, data_len) !=
+	offsetof(struct rte_mbuf, rx_descriptor_fields1) + 8), "data_len");
+static_assert(!(offsetof(struct rte_mbuf, vlan_tci) !=
+	offsetof(struct rte_mbuf, rx_descriptor_fields1) + 10), "vlan_tci");
+static_assert(!(offsetof(struct rte_mbuf, hash) !=
+	offsetof(struct rte_mbuf, rx_descriptor_fields1) + 12), "hash");
+
 /**
  * Function typedef of callback to free externally attached buffer.
  */
Signature · 1 line
1.8.3.1
#94 lore raw

PATCH v6 3/23 common/idpf: use mbuf descriptor accessors

In reply to Tyler Retzlaff

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.

---
 drivers/common/idpf/idpf_common_rxtx.c        |  4 +-
 drivers/common/idpf/idpf_common_rxtx_avx512.c | 73 +++++++--------------------
 2 files changed, 18 insertions(+), 59 deletions(-)
drivers/common/idpf/idpf_common_rxtx.c +1 -3
index 83b131e..62ddf2e 100644
@@ -1595,7 +1595,6 @@
 static inline int
 idpf_rxq_vec_setup_default(struct idpf_rx_queue *rxq)
 {
-	uintptr_t p;
 	struct rte_mbuf mb_def = { .buf_addr = 0 }; /* zeroed mbuf */
 
 	mb_def.nb_segs = 1;
@@ -1605,8 +1604,7 @@
 
 	/* 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);
 	return 0;
 }
 
drivers/common/idpf/idpf_common_rxtx_avx512.c +17 -56

133 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#95 lore raw

PATCH v6 4/23 net/bnxt: use mbuf descriptor accessors

In reply to Tyler Retzlaff

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.

---
 drivers/net/bnxt/bnxt_rxtx_vec_avx2.c   | 32 ++++++++++++++++----------------
 drivers/net/bnxt/bnxt_rxtx_vec_common.h |  4 +---
 drivers/net/bnxt/bnxt_rxtx_vec_neon.c   | 16 ++++++++--------
 drivers/net/bnxt/bnxt_rxtx_vec_sse.c    | 16 ++++++++--------
 4 files changed, 33 insertions(+), 35 deletions(-)
drivers/net/bnxt/bnxt_rxtx_vec_avx2.c +16 -16
index ce6b597..5982d12 100644
@@ -310,13 +310,13 @@
 					    0x04);
 
 		/* Store all mbuf fields for first four packets. */
-		_mm256_storeu_si256((void *)&rx_pkts[i + 0]->rearm_data,
+		_mm256_storeu_si256((void *)rte_mbuf_rearm_data(rx_pkts[i + 0]),
 				    rearm0);
-		_mm256_storeu_si256((void *)&rx_pkts[i + 1]->rearm_data,
+		_mm256_storeu_si256((void *)rte_mbuf_rearm_data(rx_pkts[i + 1]),
 				    rearm1);
-		_mm256_storeu_si256((void *)&rx_pkts[i + 2]->rearm_data,
+		_mm256_storeu_si256((void *)rte_mbuf_rearm_data(rx_pkts[i + 2]),
 				    rearm2);
-		_mm256_storeu_si256((void *)&rx_pkts[i + 3]->rearm_data,
+		_mm256_storeu_si256((void *)rte_mbuf_rearm_data(rx_pkts[i + 3]),
 				    rearm3);
 
 		/* Unpack rearm data, set fixed fields for final four mbufs. */
@@ -336,13 +336,13 @@
 					    0x04);
 
 		/* Store all mbuf fields for final four packets. */
-		_mm256_storeu_si256((void *)&rx_pkts[i + 4]->rearm_data,
+		_mm256_storeu_si256((void *)rte_mbuf_rearm_data(rx_pkts[i + 4]),
 				    rearm4);
-		_mm256_storeu_si256((void *)&rx_pkts[i + 5]->rearm_data,
+		_mm256_storeu_si256((void *)rte_mbuf_rearm_data(rx_pkts[i + 5]),
 				    rearm5);
-		_mm256_storeu_si256((void *)&rx_pkts[i + 6]->rearm_data,
+		_mm256_storeu_si256((void *)rte_mbuf_rearm_data(rx_pkts[i + 6]),
 				    rearm6);
-		_mm256_storeu_si256((void *)&rx_pkts[i + 7]->rearm_data,
+		_mm256_storeu_si256((void *)rte_mbuf_rearm_data(rx_pkts[i + 7]),
 				    rearm7);
 
 		nb_rx_pkts += num_valid;
@@ -598,13 +598,13 @@
 					    0x04);
 
 		/* Store all mbuf fields for first four packets. */
-		_mm256_storeu_si256((void *)&rx_pkts[i + 0]->rearm_data,
+		_mm256_storeu_si256((void *)rte_mbuf_rearm_data(rx_pkts[i + 0]),
 				    rearm0);
-		_mm256_storeu_si256((void *)&rx_pkts[i + 1]->rearm_data,
+		_mm256_storeu_si256((void *)rte_mbuf_rearm_data(rx_pkts[i + 1]),
 				    rearm1);
-		_mm256_storeu_si256((void *)&rx_pkts[i + 2]->rearm_data,
+		_mm256_storeu_si256((void *)rte_mbuf_rearm_data(rx_pkts[i + 2]),
 				    rearm2);
-		_mm256_storeu_si256((void *)&rx_pkts[i + 3]->rearm_data,
+		_mm256_storeu_si256((void *)rte_mbuf_rearm_data(rx_pkts[i + 3]),
 				    rearm3);
 
 		/* Unpack rearm data, set fixed fields for final four mbufs. */
@@ -624,13 +624,13 @@
 					    0x04);
 
 		/* Store all mbuf fields for final four packets. */
-		_mm256_storeu_si256((void *)&rx_pkts[i + 4]->rearm_data,
+		_mm256_storeu_si256((void *)rte_mbuf_rearm_data(rx_pkts[i + 4]),
 				    rearm4);
-		_mm256_storeu_si256((void *)&rx_pkts[i + 5]->rearm_data,
+		_mm256_storeu_si256((void *)rte_mbuf_rearm_data(rx_pkts[i + 5]),
 				    rearm5);
-		_mm256_storeu_si256((void *)&rx_pkts[i + 6]->rearm_data,
+		_mm256_storeu_si256((void *)rte_mbuf_rearm_data(rx_pkts[i + 6]),
 				    rearm6);
-		_mm256_storeu_si256((void *)&rx_pkts[i + 7]->rearm_data,
+		_mm256_storeu_si256((void *)rte_mbuf_rearm_data(rx_pkts[i + 7]),
 				    rearm7);
 
 		nb_rx_pkts += num_valid;
drivers/net/bnxt/bnxt_rxtx_vec_common.h +1 -3
index 2294f0a..fb0b1c1 100644
@@ -36,7 +36,6 @@
 static inline int
 bnxt_rxq_vec_setup_common(struct bnxt_rx_queue *rxq)
 {
-	uintptr_t p;
 	struct rte_mbuf mb_def = { .buf_addr = 0 }; /* zeroed mbuf */
 
 	mb_def.nb_segs = 1;
@@ -46,8 +45,7 @@
 
 	/* 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);
 	rxq->rxrearm_nb = 0;
 	rxq->rxrearm_start = 0;
 	return 0;
drivers/net/bnxt/bnxt_rxtx_vec_neon.c +8 -8
index 775400f..9ca9903 100644
@@ -135,27 +135,27 @@
 
 	/* Update mbuf rearm_data for four packets. */
 	GET_OL_FLAGS(rss_flags, index, errors, 0, ol_flags);
-	vst1q_u32((uint32_t *)&mbuf[0]->rearm_data,
+	vst1q_u32((uint32_t *)rte_mbuf_rearm_data(mbuf[0]),
 		  vsetq_lane_u32(ol_flags, vreinterpretq_u32_u64(mb_init), 2));
 	GET_OL_FLAGS(rss_flags, index, errors, 1, ol_flags);
-	vst1q_u32((uint32_t *)&mbuf[1]->rearm_data,
+	vst1q_u32((uint32_t *)rte_mbuf_rearm_data(mbuf[1]),
 		  vsetq_lane_u32(ol_flags, vreinterpretq_u32_u64(mb_init), 2));
 	GET_OL_FLAGS(rss_flags, index, errors, 2, ol_flags);
-	vst1q_u32((uint32_t *)&mbuf[2]->rearm_data,
+	vst1q_u32((uint32_t *)rte_mbuf_rearm_data(mbuf[2]),
 		  vsetq_lane_u32(ol_flags, vreinterpretq_u32_u64(mb_init), 2));
 	GET_OL_FLAGS(rss_flags, index, errors, 3, ol_flags);
-	vst1q_u32((uint32_t *)&mbuf[3]->rearm_data,
+	vst1q_u32((uint32_t *)rte_mbuf_rearm_data(mbuf[3]),
 		  vsetq_lane_u32(ol_flags, vreinterpretq_u32_u64(mb_init), 2));
 
 	/* Update mbuf rx_descriptor_fields1 for four packets. */
 	GET_DESC_FIELDS(mm_rxcmp[0], mm_rxcmp1[0], shuf_msk, ptype_idx, 0, tmp);
-	vst1q_u32((uint32_t *)&mbuf[0]->rx_descriptor_fields1, tmp);
+	vst1q_u32((uint32_t *)rte_mbuf_rx_descriptor_fields1(mbuf[0]), tmp);
 	GET_DESC_FIELDS(mm_rxcmp[1], mm_rxcmp1[1], shuf_msk, ptype_idx, 1, tmp);
-	vst1q_u32((uint32_t *)&mbuf[1]->rx_descriptor_fields1, tmp);
+	vst1q_u32((uint32_t *)rte_mbuf_rx_descriptor_fields1(mbuf[1]), tmp);
 	GET_DESC_FIELDS(mm_rxcmp[2], mm_rxcmp1[2], shuf_msk, ptype_idx, 2, tmp);
-	vst1q_u32((uint32_t *)&mbuf[2]->rx_descriptor_fields1, tmp);
+	vst1q_u32((uint32_t *)rte_mbuf_rx_descriptor_fields1(mbuf[2]), tmp);
 	GET_DESC_FIELDS(mm_rxcmp[3], mm_rxcmp1[3], shuf_msk, ptype_idx, 3, tmp);
-	vst1q_u32((uint32_t *)&mbuf[3]->rx_descriptor_fields1, tmp);
+	vst1q_u32((uint32_t *)rte_mbuf_rx_descriptor_fields1(mbuf[3]), tmp);
 }
 
 static uint16_t
drivers/net/bnxt/bnxt_rxtx_vec_sse.c +8 -8
index 6c0e332..080e990 100644
@@ -114,33 +114,33 @@
 
 	/* Update mbuf rearm_data for four packets. */
 	GET_OL_FLAGS(rss_flags, index, errors, 0, ol_flags);
-	_mm_store_si128((void *)&mbuf[0]->rearm_data,
+	_mm_store_si128((void *)rte_mbuf_rearm_data(mbuf[0]),
 			_mm_or_si128(mbuf_init, _mm_set_epi64x(ol_flags, 0)));
 
 	GET_OL_FLAGS(rss_flags, index, errors, 1, ol_flags);
-	_mm_store_si128((void *)&mbuf[1]->rearm_data,
+	_mm_store_si128((void *)rte_mbuf_rearm_data(mbuf[1]),
 			_mm_or_si128(mbuf_init, _mm_set_epi64x(ol_flags, 0)));
 
 	GET_OL_FLAGS(rss_flags, index, errors, 2, ol_flags);
-	_mm_store_si128((void *)&mbuf[2]->rearm_data,
+	_mm_store_si128((void *)rte_mbuf_rearm_data(mbuf[2]),
 			_mm_or_si128(mbuf_init, _mm_set_epi64x(ol_flags, 0)));
 
 	GET_OL_FLAGS(rss_flags, index, errors, 3, ol_flags);
-	_mm_store_si128((void *)&mbuf[3]->rearm_data,
+	_mm_store_si128((void *)rte_mbuf_rearm_data(mbuf[3]),
 			_mm_or_si128(mbuf_init, _mm_set_epi64x(ol_flags, 0)));
 
 	/* Update mbuf rx_descriptor_fields1 for four packes. */
 	GET_DESC_FIELDS(mm_rxcmp[0], mm_rxcmp1[0], shuf_msk, ptype_idx, 0, t0);
-	_mm_store_si128((void *)&mbuf[0]->rx_descriptor_fields1, t0);
+	_mm_store_si128(rte_mbuf_rx_descriptor_fields1(mbuf[0]), t0);
 
 	GET_DESC_FIELDS(mm_rxcmp[1], mm_rxcmp1[1], shuf_msk, ptype_idx, 1, t0);
-	_mm_store_si128((void *)&mbuf[1]->rx_descriptor_fields1, t0);
+	_mm_store_si128(rte_mbuf_rx_descriptor_fields1(mbuf[1]), t0);
 
 	GET_DESC_FIELDS(mm_rxcmp[2], mm_rxcmp1[2], shuf_msk, ptype_idx, 2, t0);
-	_mm_store_si128((void *)&mbuf[2]->rx_descriptor_fields1, t0);
+	_mm_store_si128(rte_mbuf_rx_descriptor_fields1(mbuf[2]), t0);
 
 	GET_DESC_FIELDS(mm_rxcmp[3], mm_rxcmp1[3], shuf_msk, ptype_idx, 3, t0);
-	_mm_store_si128((void *)&mbuf[3]->rx_descriptor_fields1, t0);
+	_mm_store_si128(rte_mbuf_rx_descriptor_fields1(mbuf[3]), t0);
 }
 
 static uint16_t
Signature · 1 line
1.8.3.1
#96 lore raw

PATCH v6 5/23 net/cnxk: use mbuf descriptor accessors

In reply to Tyler Retzlaff

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.

---
 drivers/net/cnxk/cn10k_rx.h    | 36 ++++++++++++++++++------------------
 drivers/net/cnxk/cn9k_rx.h     | 20 ++++++++++----------
 drivers/net/cnxk/cnxk_ethdev.c |  2 +-
 3 files changed, 29 insertions(+), 29 deletions(-)
drivers/net/cnxk/cn10k_rx.h +18 -18
index 7bb4c86..4bfb323 100644
@@ -309,7 +309,7 @@
 		frag_rx = (union nix_rx_parse_u *)(wqe + 1);
 		frag_size = rlen + frag_rx->lcptr - frag_rx->laptr;
 
-		*(uint64_t *)(&mbuf->rearm_data) = mbuf_init;
+		*rte_mbuf_rearm_data(mbuf) = mbuf_init;
 		mbuf->data_len = frag_size;
 		mbuf->pkt_len = frag_size;
 		mbuf->ol_flags = ol_flags;
@@ -368,7 +368,7 @@
 	fsz_w1 >>= 16;
 
 	data_off = b_off + frag_rx->lcptr + l3_hdr_size;
-	*(uint64_t *)(&mbuf->rearm_data) = mbuf_init | data_off;
+	*rte_mbuf_rearm_data(mbuf) = mbuf_init | data_off;
 	mbuf->data_len = frag_size;
 
 	/* Mark frag as get */
@@ -384,7 +384,7 @@
 		fsz_w1 >>= 16;
 
 		data_off = b_off + frag_rx->lcptr + l3_hdr_size;
-		*(uint64_t *)(&mbuf->rearm_data) = mbuf_init | data_off;
+		*rte_mbuf_rearm_data(mbuf) = mbuf_init | data_off;
 		mbuf->data_len = frag_size;
 
 		/* Mark frag as get */
@@ -401,7 +401,7 @@
 		fsz_w1 >>= 16;
 
 		data_off = b_off + frag_rx->lcptr + l3_hdr_size;
-		*(uint64_t *)(&mbuf->rearm_data) = mbuf_init | data_off;
+		*rte_mbuf_rearm_data(mbuf) = mbuf_init | data_off;
 		mbuf->data_len = frag_size;
 
 		/* Mark frag as get */
@@ -502,7 +502,7 @@
 
 	inner->pkt_len = len;
 	inner->data_len = len;
-	*(uint64_t *)(&inner->rearm_data) = mbuf_init;
+	*rte_mbuf_rearm_data(inner) = mbuf_init;
 
 	inner->ol_flags = ((CPT_COMP_HWGOOD_MASK & (1U << ucc)) ?
 			   RTE_MBUF_F_RX_SEC_OFFLOAD :
@@ -584,7 +584,7 @@
 			/* First frag len */
 			inner->pkt_len = vgetq_lane_u16(*rx_desc_field1, 2);
 			inner->data_len = vgetq_lane_u16(*rx_desc_field1, 4);
-			p = (uintptr_t)&inner->rearm_data;
+			p = (uintptr_t)rte_mbuf_rearm_data(inner);
 			*(uint64_t *)p = mbuf_init;
 
 			/* Reassembly success */
@@ -774,7 +774,7 @@
 
 		mbuf->data_len = sg_len;
 		sg = sg >> 16;
-		p = (uintptr_t)&mbuf->rearm_data;
+		p = (uintptr_t)rte_mbuf_rearm_data(mbuf);
 		*(uint64_t *)p = rearm & ~0xFFFF;
 		nb_segs--;
 		iova_list++;
@@ -825,7 +825,7 @@
 			head->nb_segs = nb_segs;
 		}
 		mbuf = next_frag;
-		p = (uintptr_t)&mbuf->rearm_data;
+		p = (uintptr_t)rte_mbuf_rearm_data(mbuf);
 		*(uint64_t *)p = rearm + ldptr;
 		mbuf->data_len = (sg & 0xFFFF) - ldptr -
 				 (flags & NIX_RX_OFFLOAD_TSTAMP_F ?
@@ -849,7 +849,7 @@
 
 
 		len = mbuf->pkt_len;
-		p = (uintptr_t)&mbuf->rearm_data;
+		p = (uintptr_t)rte_mbuf_rearm_data(mbuf);
 		*(uint64_t *)p = rearm;
 		mbuf->data_len = (sg & 0xFFFF) -
 				 (flags & NIX_RX_OFFLOAD_TSTAMP_F ?
@@ -917,7 +917,7 @@
 		mbuf->ol_flags = ol_flags;
 		mbuf->pkt_len = len;
 		mbuf->data_len = len;
-		p = (uintptr_t)&mbuf->rearm_data;
+		p = (uintptr_t)rte_mbuf_rearm_data(mbuf);
 		*(uint64_t *)p = val;
 	}
 
@@ -1966,16 +1966,16 @@
 		rearm3 = vsetq_lane_u64(ol_flags3, rearm3, 1);
 
 		/* Update rx_descriptor_fields1 */
-		vst1q_u64((uint64_t *)mbuf0->rx_descriptor_fields1, f0);
-		vst1q_u64((uint64_t *)mbuf1->rx_descriptor_fields1, f1);
-		vst1q_u64((uint64_t *)mbuf2->rx_descriptor_fields1, f2);
-		vst1q_u64((uint64_t *)mbuf3->rx_descriptor_fields1, f3);
+		vst1q_u64((uint64_t *)rte_mbuf_rx_descriptor_fields1(mbuf0), f0);
+		vst1q_u64((uint64_t *)rte_mbuf_rx_descriptor_fields1(mbuf1), f1);
+		vst1q_u64((uint64_t *)rte_mbuf_rx_descriptor_fields1(mbuf2), f2);
+		vst1q_u64((uint64_t *)rte_mbuf_rx_descriptor_fields1(mbuf3), f3);
 
 		/* Update rearm_data */
-		vst1q_u64((uint64_t *)mbuf0->rearm_data, rearm0);
-		vst1q_u64((uint64_t *)mbuf1->rearm_data, rearm1);
-		vst1q_u64((uint64_t *)mbuf2->rearm_data, rearm2);
-		vst1q_u64((uint64_t *)mbuf3->rearm_data, rearm3);
+		vst1q_u64(rte_mbuf_rearm_data(mbuf0), rearm0);
+		vst1q_u64(rte_mbuf_rearm_data(mbuf1), rearm1);
+		vst1q_u64(rte_mbuf_rearm_data(mbuf2), rearm2);
+		vst1q_u64(rte_mbuf_rearm_data(mbuf3), rearm3);
 
 		if (flags & NIX_RX_MULTI_SEG_F) {
 			/* Multi segment is enable build mseg list for
drivers/net/cnxk/cn9k_rx.h +10 -10
index d8bb65c..f1212f8 100644
@@ -155,7 +155,7 @@
 
 		mbuf->data_len = sg & 0xFFFF;
 		sg = sg >> 16;
-		*(uint64_t *)(&mbuf->rearm_data) = rearm;
+		*rte_mbuf_rearm_data(mbuf) = rearm;
 		nb_segs--;
 		iova_list++;
 
@@ -398,7 +398,7 @@
 			nix_update_match_id(rx->cn9k.match_id, ol_flags, mbuf);
 
 	mbuf->ol_flags = ol_flags;
-	*(uint64_t *)(&mbuf->rearm_data) = val;
+	*rte_mbuf_rearm_data(mbuf) = val;
 	mbuf->pkt_len = len;
 	mbuf->data_len = len;
 
@@ -799,16 +799,16 @@
 		rearm3 = vsetq_lane_u64(ol_flags3, rearm3, 1);
 
 		/* Update rx_descriptor_fields1 */
-		vst1q_u64((uint64_t *)mbuf0->rx_descriptor_fields1, f0);
-		vst1q_u64((uint64_t *)mbuf1->rx_descriptor_fields1, f1);
-		vst1q_u64((uint64_t *)mbuf2->rx_descriptor_fields1, f2);
-		vst1q_u64((uint64_t *)mbuf3->rx_descriptor_fields1, f3);
+		vst1q_u64((uint64_t *)rte_mbuf_rx_descriptor_fields1(mbuf0), f0);
+		vst1q_u64((uint64_t *)rte_mbuf_rx_descriptor_fields1(mbuf1), f1);
+		vst1q_u64((uint64_t *)rte_mbuf_rx_descriptor_fields1(mbuf2), f2);
+		vst1q_u64((uint64_t *)rte_mbuf_rx_descriptor_fields1(mbuf3), f3);
 
 		/* Update rearm_data */
-		vst1q_u64((uint64_t *)mbuf0->rearm_data, rearm0);
-		vst1q_u64((uint64_t *)mbuf1->rearm_data, rearm1);
-		vst1q_u64((uint64_t *)mbuf2->rearm_data, rearm2);
-		vst1q_u64((uint64_t *)mbuf3->rearm_data, rearm3);
+		vst1q_u64(rte_mbuf_rearm_data(mbuf0), rearm0);
+		vst1q_u64(rte_mbuf_rearm_data(mbuf1), rearm1);
+		vst1q_u64(rte_mbuf_rearm_data(mbuf2), rearm2);
+		vst1q_u64(rte_mbuf_rearm_data(mbuf3), rearm3);
 
 		if (flags & NIX_RX_MULTI_SEG_F) {
 			/* Multi segment is enable build mseg list for
drivers/net/cnxk/cnxk_ethdev.c +1 -1
index 2372a4e..14f6b7c 100644
@@ -437,7 +437,7 @@
 
 	/* Prevent compiler reordering: rearm_data covers previous fields */
 	rte_compiler_barrier();
-	tmp = (uint64_t *)&mb_def.rearm_data;
+	tmp = rte_mbuf_rearm_data(&mb_def);
 
 	return *tmp;
 }
Signature · 1 line
1.8.3.1
#97 lore raw

PATCH v6 6/23 net/enic: use mbuf descriptor accessors

In reply to Tyler Retzlaff

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.

---
 drivers/net/enic/enic_main.c          |  4 +---
 drivers/net/enic/enic_rxtx_vec_avx2.c | 18 +++++++++---------
 2 files changed, 10 insertions(+), 12 deletions(-)
drivers/net/enic/enic_main.c +1 -3
index a6aaa76..59e0be4 100644
@@ -577,7 +577,6 @@ int enic_enable(struct enic *enic)
 	int err;
 	struct rte_eth_dev *eth_dev = enic->rte_dev;
 	uint64_t simple_tx_offloads;
-	uintptr_t p;
 
 	if (enic->enable_avx2_rx) {
 		struct rte_mbuf mb_def = { .buf_addr = 0 };
@@ -592,8 +591,7 @@ int enic_enable(struct enic *enic)
 		mb_def.port = enic->port_id;
 		rte_mbuf_refcnt_set(&mb_def, 1);
 		rte_compiler_barrier();
-		p = (uintptr_t)&mb_def.rearm_data;
-		enic->mbuf_initializer = *(uint64_t *)p;
+		enic->mbuf_initializer = *rte_mbuf_rearm_data(&mb_def);
 	}
 
 	eth_dev->data->dev_link.link_speed = vnic_dev_port_speed(enic->vdev);
drivers/net/enic/enic_rxtx_vec_avx2.c +9 -9
index 600efff..f6ab6e1 100644
@@ -19,7 +19,7 @@
 {
 	bool tnl;
 
-	*(uint64_t *)&mb->rearm_data = enic->mbuf_initializer;
+	*rte_mbuf_rearm_data(mb) = enic->mbuf_initializer;
 	mb->data_len = cqd->bytes_written_flags &
 		CQ_ENET_RQ_DESC_BYTES_WRITTEN_MASK;
 	mb->pkt_len = mb->data_len;
@@ -737,14 +737,14 @@
 		 * vlan_tci    - 26     (from cqd)
 		 * rss         - 28     (from cqd)
 		 */
-		_mm256_storeu_si256((__m256i *)&rxmb[0]->rearm_data, rearm0);
-		_mm256_storeu_si256((__m256i *)&rxmb[1]->rearm_data, rearm1);
-		_mm256_storeu_si256((__m256i *)&rxmb[2]->rearm_data, rearm2);
-		_mm256_storeu_si256((__m256i *)&rxmb[3]->rearm_data, rearm3);
-		_mm256_storeu_si256((__m256i *)&rxmb[4]->rearm_data, rearm4);
-		_mm256_storeu_si256((__m256i *)&rxmb[5]->rearm_data, rearm5);
-		_mm256_storeu_si256((__m256i *)&rxmb[6]->rearm_data, rearm6);
-		_mm256_storeu_si256((__m256i *)&rxmb[7]->rearm_data, rearm7);
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rxmb[0]), rearm0);
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rxmb[1]), rearm1);
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rxmb[2]), rearm2);
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rxmb[3]), rearm3);
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rxmb[4]), rearm4);
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rxmb[5]), rearm5);
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rxmb[6]), rearm6);
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rxmb[7]), rearm7);
 
 		max_rx -= 8;
 		cqd += 8;
Signature · 1 line
1.8.3.1
#98 lore raw

PATCH v6 7/23 net/fm10k: use mbuf descriptor accessors

In reply to Tyler Retzlaff

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.

---
 drivers/net/fm10k/fm10k_rxtx_vec.c | 32 +++++++-------------------------
 1 file changed, 7 insertions(+), 25 deletions(-)
drivers/net/fm10k/fm10k_rxtx_vec.c +7 -25
index 2b6914b..795e70a 100644
@@ -226,7 +226,6 @@
 int __rte_cold
 fm10k_rxq_vec_setup(struct fm10k_rx_queue *rxq)
 {
-	uintptr_t p;
 	struct rte_mbuf mb_def = { .buf_addr = 0 }; /* zeroed mbuf */
 
 	mb_def.nb_segs = 1;
@@ -239,8 +238,7 @@
 
 	/* 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);
 	return 0;
 }
 
@@ -282,7 +280,6 @@
 	/* Initialize the mbufs in vector, process 2 mbufs in one loop */
 	for (i = 0; i < RTE_FM10K_RXQ_REARM_THRESH; i += 2, mb_alloc += 2) {
 		__m128i vaddr0, vaddr1;
-		uintptr_t p0, p1;
 
 		mb0 = mb_alloc[0];
 		mb1 = mb_alloc[1];
@@ -290,10 +287,8 @@
 		/* Flush mbuf with pkt template.
 		 * Data to be rearmed is 6 bytes long.
 		 */
-		p0 = (uintptr_t)&mb0->rearm_data;
-		*(uint64_t *)p0 = rxq->mbuf_initializer;
-		p1 = (uintptr_t)&mb1->rearm_data;
-		*(uint64_t *)p1 = rxq->mbuf_initializer;
+		*rte_mbuf_rearm_data(mb0) = rxq->mbuf_initializer;
+		*rte_mbuf_rearm_data(mb1) = rxq->mbuf_initializer;
 
 		/* load buf_addr(lo 64bit) and buf_iova(hi 64bit) */
 		RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, buf_iova) !=
@@ -422,19 +417,6 @@
 		0xFF, 0xFF,  /* skip high 16 bits pkt_type */
 		0xFF, 0xFF   /* Skip pkt_type field in shuffle operation */
 		);
-	/*
-	 * Compile-time verify the shuffle mask
-	 * NOTE: some field positions already verified above, but duplicated
-	 * here for completeness in case of future modifications.
-	 */
-	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, vlan_tci) !=
-			offsetof(struct rte_mbuf, rx_descriptor_fields1) + 10);
-	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, hash) !=
-			offsetof(struct rte_mbuf, rx_descriptor_fields1) + 12);
 
 	/* Cache is empty -> need to scan the buffer rings, but first move
 	 * the next 'n' mbufs into the cache
@@ -519,9 +501,9 @@
 		staterr = _mm_unpacklo_epi32(sterr_tmp1, sterr_tmp2);
 
 		/* D.3 copy final 3,4 data to rx_pkts */
-		_mm_storeu_si128((void *)&rx_pkts[pos+3]->rx_descriptor_fields1,
+		_mm_storeu_si128(rte_mbuf_rx_descriptor_fields1(rx_pkts[pos + 3]),
 				pkt_mb4);
-		_mm_storeu_si128((void *)&rx_pkts[pos+2]->rx_descriptor_fields1,
+		_mm_storeu_si128(rte_mbuf_rx_descriptor_fields1(rx_pkts[pos + 2]),
 				pkt_mb3);
 
 		/* C* extract and record EOP bit */
@@ -557,9 +539,9 @@
 		staterr = _mm_packs_epi32(staterr, zero);
 
 		/* D.3 copy final 1,2 data to rx_pkts */
-		_mm_storeu_si128((void *)&rx_pkts[pos+1]->rx_descriptor_fields1,
+		_mm_storeu_si128(rte_mbuf_rx_descriptor_fields1(rx_pkts[pos + 1]),
 				pkt_mb2);
-		_mm_storeu_si128((void *)&rx_pkts[pos]->rx_descriptor_fields1,
+		_mm_storeu_si128(rte_mbuf_rx_descriptor_fields1(rx_pkts[pos]),
 				pkt_mb1);
 
 		fm10k_desc_to_pktype_v(descs0, &rx_pkts[pos]);
Signature · 1 line
1.8.3.1
#99 lore raw

PATCH v6 8/23 net/hns3: use mbuf descriptor accessors

In reply to Tyler Retzlaff

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.

---
 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(-)
drivers/net/hns3/hns3_rxtx_vec.c +1 -21
index 9708ec6..d6c9e80 100644
@@ -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
drivers/net/hns3/hns3_rxtx_vec_neon.h +8 -16
index 0dc6b9f..6f46131 100644
@@ -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);
drivers/net/hns3/hns3_rxtx_vec_sve.c +2 -2
index 8aa4448..f6259d1 100644
@@ -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);
Signature · 1 line
1.8.3.1
#100 lore raw

PATCH v6 9/23 net/i40e: use mbuf descriptor accessors

In reply to Tyler Retzlaff

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.

Use rte_mbuf_prefetch_part2() to prefetch cacheline1 and remove reference to rte marker field.

---
 drivers/net/i40e/i40e_rxtx_vec_altivec.c | 18 +++++--------
 drivers/net/i40e/i40e_rxtx_vec_avx2.c    | 34 ++++++-------------------
 drivers/net/i40e/i40e_rxtx_vec_avx512.c  | 35 +++++++-------------------
 drivers/net/i40e/i40e_rxtx_vec_common.h  |  4 +--
 drivers/net/i40e/i40e_rxtx_vec_neon.c    | 16 ++++++------
 drivers/net/i40e/i40e_rxtx_vec_sse.c     | 43 +++++++-------------------------
 6 files changed, 41 insertions(+), 109 deletions(-)
drivers/net/i40e/i40e_rxtx_vec_altivec.c +6 -12
index b6b0d38..3e065ee 100644
@@ -55,7 +55,6 @@
 	/* Initialize the mbufs in vector, process 2 mbufs in one loop */
 	for (i = 0; i < RTE_I40E_RXQ_REARM_THRESH; i += 2, rxep += 2) {
 		__vector unsigned long vaddr0, vaddr1;
-		uintptr_t p0, p1;
 
 		mb0 = rxep[0].mbuf;
 		mb1 = rxep[1].mbuf;
@@ -66,10 +65,8 @@
 		  * anyway. So overwrite whole 8 bytes with one load:
 		  * 6 bytes of rearm_data plus first 2 bytes of ol_flags.
 		  */
-		p0 = (uintptr_t)&mb0->rearm_data;
-		*(uint64_t *)p0 = rxq->mbuf_initializer;
-		p1 = (uintptr_t)&mb1->rearm_data;
-		*(uint64_t *)p1 = rxq->mbuf_initializer;
+		*rte_mbuf_rearm_data(mb0) = rxq->mbuf_initializer;
+		*rte_mbuf_rearm_data(mb1) = rxq->mbuf_initializer;
 
 		/* load buf_addr(lo 64bit) and buf_iova(hi 64bit) */
 		vaddr0 = vec_ld(0, (__vector unsigned long *)&mb0->buf_addr);
@@ -370,12 +367,10 @@
 
 		/* D.3 copy final 3,4 data to rx_pkts */
 		vec_st(pkt_mb4, 0,
-		 (__vector unsigned char *)&rx_pkts[pos + 3]
-			->rx_descriptor_fields1
+		 (__vector unsigned char *)rte_mbuf_rx_descriptor_fields1(rx_pkts[pos + 3])
 		);
 		vec_st(pkt_mb3, 0,
-		 (__vector unsigned char *)&rx_pkts[pos + 2]
-			->rx_descriptor_fields1
+		 (__vector unsigned char *)rte_mbuf_rx_descriptor_fields1(rx_pkts[pos + 2])
 		);
 
 		/* D.2 pkt 1,2 set in_port/nb_seg and remove crc */
@@ -422,11 +417,10 @@
 
 		/* D.3 copy final 1,2 data to rx_pkts */
 		vec_st(pkt_mb2, 0,
-		 (__vector unsigned char *)&rx_pkts[pos + 1]
-			->rx_descriptor_fields1
+		 (__vector unsigned char *)rte_mbuf_rx_descriptor_fields1(rx_pkts[pos + 1])
 		);
 		vec_st(pkt_mb1, 0,
-		 (__vector unsigned char *)&rx_pkts[pos]->rx_descriptor_fields1
+		 (__vector unsigned char *)rte_mbuf_rx_descriptor_fields1(rx_pkts[pos])
 		);
 		desc_to_ptype_v(descs, &rx_pkts[pos], ptype_tbl);
 		desc_to_olflags_v(descs, &rx_pkts[pos]);
drivers/net/i40e/i40e_rxtx_vec_avx2.c +8 -26
index f468c1f..360d80f 100644
@@ -180,19 +180,6 @@
 			0xFF, 0xFF,  /* pkt_type set as unknown */
 			0xFF, 0xFF   /*pkt_type set as unknown */
 	);
-	/*
-	 * compile-time check the above crc and shuffle layout is correct.
-	 * NOTE: the first field (lowest address) is given last in set_epi
-	 * calls above.
-	 */
-	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, vlan_tci) !=
-			offsetof(struct rte_mbuf, rx_descriptor_fields1) + 10);
-	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, hash) !=
-			offsetof(struct rte_mbuf, rx_descriptor_fields1) + 12);
 
 	/* Status/Error flag masks */
 	/*
@@ -525,11 +512,6 @@
 		 * add in the previously computed rx_descriptor fields to
 		 * make a single 256-bit write per mbuf
 		 */
-		/* check the structure matches expectations */
-		RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, ol_flags) !=
-				offsetof(struct rte_mbuf, rearm_data) + 8);
-		RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, rearm_data) !=
-				RTE_ALIGN(offsetof(struct rte_mbuf, rearm_data), 16));
 		/* build up data and do writes */
 		__m256i rearm0, rearm1, rearm2, rearm3, rearm4, rearm5,
 				rearm6, rearm7;
@@ -543,10 +525,10 @@
 		rearm2 = _mm256_permute2f128_si256(rearm2, mb2_3, 0x20);
 		rearm0 = _mm256_permute2f128_si256(rearm0, mb0_1, 0x20);
 		/* write to mbuf */
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 6]->rearm_data, rearm6);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 4]->rearm_data, rearm4);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 2]->rearm_data, rearm2);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 0]->rearm_data, rearm0);
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 6]), rearm6);
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 4]), rearm4);
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 2]), rearm2);
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 0]), rearm0);
 
 		/* repeat for the odd mbufs */
 		const __m256i odd_flags = _mm256_castsi128_si256(
@@ -561,10 +543,10 @@
 		rearm3 = _mm256_blend_epi32(rearm3, mb2_3, 0xF0);
 		rearm1 = _mm256_blend_epi32(rearm1, mb0_1, 0xF0);
 		/* again write to mbufs */
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 7]->rearm_data, rearm7);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 5]->rearm_data, rearm5);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 3]->rearm_data, rearm3);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 1]->rearm_data, rearm1);
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 7]), rearm7);
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 5]), rearm5);
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 3]), rearm3);
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 1]), rearm1);
 
 		/* extract and record EOP bit */
 		if (split_packet) {
drivers/net/i40e/i40e_rxtx_vec_avx512.c +9 -26
index f3050cd..e13bd2f 100644
@@ -170,18 +170,6 @@
 			 /* pkt_type set as unknown */
 			 0xFFFFFFFF
 			);
-	/* compile-time check the above crc and shuffle layout is correct.
-	 * NOTE: the first field (lowest address) is given last in set_epi
-	 * calls above.
-	 */
-	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, vlan_tci) !=
-			offsetof(struct rte_mbuf, rx_descriptor_fields1) + 10);
-	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, hash) !=
-			offsetof(struct rte_mbuf, rx_descriptor_fields1) + 12);
 
 	/* Status/Error flag masks */
 	/* mask everything except RSS, flow director and VLAN flags
@@ -557,11 +545,6 @@
 		 * add in the previously computed rx_descriptor fields to
 		 * make a single 256-bit write per mbuf
 		 */
-		/* check the structure matches expectations */
-		RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, ol_flags) !=
-				offsetof(struct rte_mbuf, rearm_data) + 8);
-		RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, rearm_data) !=
-				RTE_ALIGN(offsetof(struct rte_mbuf, rearm_data), 16));
 		/* build up data and do writes */
 		__m256i rearm0, rearm1, rearm2, rearm3, rearm4, rearm5,
 				rearm6, rearm7;
@@ -580,13 +563,13 @@
 		rearm0 = _mm256_permute2f128_si256(rearm0, mb0_1, 0x20);
 		/* write to mbuf */
 		_mm256_storeu_si256
-			((__m256i *)&rx_pkts[i + 6]->rearm_data, rearm6);
+			((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 6]), rearm6);
 		_mm256_storeu_si256
-			((__m256i *)&rx_pkts[i + 4]->rearm_data, rearm4);
+			((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 4]), rearm4);
 		_mm256_storeu_si256
-			((__m256i *)&rx_pkts[i + 2]->rearm_data, rearm2);
+			((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 2]), rearm2);
 		_mm256_storeu_si256
-			((__m256i *)&rx_pkts[i + 0]->rearm_data, rearm0);
+			((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 0]), rearm0);
 
 		/* repeat for the odd mbufs */
 		const __m256i odd_flags = _mm256_castsi128_si256
@@ -606,13 +589,13 @@
 		rearm1 = _mm256_blend_epi32(rearm1, mb0_1, 0xF0);
 		/* again write to mbufs */
 		_mm256_storeu_si256
-			((__m256i *)&rx_pkts[i + 7]->rearm_data, rearm7);
+			((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 7]), rearm7);
 		_mm256_storeu_si256
-			((__m256i *)&rx_pkts[i + 5]->rearm_data, rearm5);
+			((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 5]), rearm5);
 		_mm256_storeu_si256
-			((__m256i *)&rx_pkts[i + 3]->rearm_data, rearm3);
+			((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 3]), rearm3);
 		_mm256_storeu_si256
-			((__m256i *)&rx_pkts[i + 1]->rearm_data, rearm1);
+			((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 1]), rearm1);
 
 		/* extract and record EOP bit */
 		if (split_packet) {
@@ -826,7 +809,7 @@
 		free[0] = m;
 		nb_free = 1;
 		for (i = 1; i < n; i++) {
-			rte_prefetch0(&txep[i + 3].mbuf->cacheline1);
+			rte_mbuf_prefetch_part2(txep[i + 3].mbuf);
 			m = rte_pktmbuf_prefree_seg(txep[i].mbuf);
 			if (likely(m)) {
 				if (likely(m->pool == free[0]->pool)) {
drivers/net/i40e/i40e_rxtx_vec_common.h +1 -3
index 8b74563..5633268 100644
@@ -189,7 +189,6 @@
 static inline int
 i40e_rxq_vec_setup_default(struct i40e_rx_queue *rxq)
 {
-	uintptr_t p;
 	struct rte_mbuf mb_def = { .buf_addr = 0 }; /* zeroed mbuf */
 
 	mb_def.nb_segs = 1;
@@ -199,8 +198,7 @@
 
 	/* 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);
 	rxq->rx_using_sse = 1;
 	return 0;
 }
drivers/net/i40e/i40e_rxtx_vec_neon.c +8 -8
index d873e30..29dfd92 100644
@@ -300,10 +300,10 @@
 	rearm2 = vsetq_lane_u64(vgetq_lane_u32(vlan0, 2), mbuf_init, 1);
 	rearm3 = vsetq_lane_u64(vgetq_lane_u32(vlan0, 3), mbuf_init, 1);
 
-	vst1q_u64((uint64_t *)&rx_pkts[0]->rearm_data, rearm0);
-	vst1q_u64((uint64_t *)&rx_pkts[1]->rearm_data, rearm1);
-	vst1q_u64((uint64_t *)&rx_pkts[2]->rearm_data, rearm2);
-	vst1q_u64((uint64_t *)&rx_pkts[3]->rearm_data, rearm3);
+	vst1q_u64(rte_mbuf_rearm_data(rx_pkts[0]), rearm0);
+	vst1q_u64(rte_mbuf_rearm_data(rx_pkts[1]), rearm1);
+	vst1q_u64(rte_mbuf_rearm_data(rx_pkts[2]), rearm2);
+	vst1q_u64(rte_mbuf_rearm_data(rx_pkts[3]), rearm3);
 }
 
 #define PKTLEN_SHIFT     10
@@ -492,13 +492,13 @@
 		pkt_mb1 = vreinterpretq_u8_u16(tmp);
 
 		/* D.3 copy final data to rx_pkts */
-		vst1q_u8((void *)&rx_pkts[pos + 3]->rx_descriptor_fields1,
+		vst1q_u8(rte_mbuf_rx_descriptor_fields1(rx_pkts[pos + 3]),
 				pkt_mb4);
-		vst1q_u8((void *)&rx_pkts[pos + 2]->rx_descriptor_fields1,
+		vst1q_u8(rte_mbuf_rx_descriptor_fields1(rx_pkts[pos + 2]),
 				pkt_mb3);
-		vst1q_u8((void *)&rx_pkts[pos + 1]->rx_descriptor_fields1,
+		vst1q_u8(rte_mbuf_rx_descriptor_fields1(rx_pkts[pos + 1]),
 				pkt_mb2);
-		vst1q_u8((void *)&rx_pkts[pos]->rx_descriptor_fields1,
+		vst1q_u8(rte_mbuf_rx_descriptor_fields1(rx_pkts[pos]),
 				pkt_mb1);
 
 		desc_to_ptype_v(descs, &rx_pkts[pos], ptype_tbl);
drivers/net/i40e/i40e_rxtx_vec_sse.c +9 -34

75 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#101 lore raw

PATCH v6 10/23 net/iavf: use mbuf descriptor accessors

In reply to Tyler Retzlaff

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.

---
 drivers/net/iavf/iavf_rxtx_vec_avx2.c   | 72 +++++++---------------------
 drivers/net/iavf/iavf_rxtx_vec_avx512.c | 72 +++++++---------------------
 drivers/net/iavf/iavf_rxtx_vec_common.h |  4 +-
 drivers/net/iavf/iavf_rxtx_vec_neon.c   | 16 +++----
 drivers/net/iavf/iavf_rxtx_vec_sse.c    | 85 +++++++--------------------------
 5 files changed, 58 insertions(+), 191 deletions(-)
drivers/net/iavf/iavf_rxtx_vec_avx2.c +16 -56
index 510b4d8..33f2850 100644
@@ -98,19 +98,6 @@
 			 0xFF, 0xFF,  /* pkt_type set as unknown */
 			 0xFF, 0xFF   /*pkt_type set as unknown */
 			);
-	/**
-	 * compile-time check the above crc and shuffle layout is correct.
-	 * NOTE: the first field (lowest address) is given last in set_epi
-	 * calls above.
-	 */
-	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, vlan_tci) !=
-			offsetof(struct rte_mbuf, rx_descriptor_fields1) + 10);
-	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, hash) !=
-			offsetof(struct rte_mbuf, rx_descriptor_fields1) + 12);
 
 	/* Status/Error flag masks */
 	/**
@@ -372,13 +359,6 @@
 		 * add in the previously computed rx_descriptor fields to
 		 * make a single 256-bit write per mbuf
 		 */
-		/* check the structure matches expectations */
-		RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, ol_flags) !=
-				 offsetof(struct rte_mbuf, rearm_data) + 8);
-		RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, rearm_data) !=
-				 RTE_ALIGN(offsetof(struct rte_mbuf,
-						    rearm_data),
-					   16));
 		/* build up data and do writes */
 		__m256i rearm0, rearm1, rearm2, rearm3, rearm4, rearm5,
 			rearm6, rearm7;
@@ -398,13 +378,13 @@
 		rearm2 = _mm256_permute2f128_si256(rearm2, mb2_3, 0x20);
 		rearm0 = _mm256_permute2f128_si256(rearm0, mb0_1, 0x20);
 		/* write to mbuf */
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 6]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 6]),
 				    rearm6);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 4]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 4]),
 				    rearm4);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 2]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 2]),
 				    rearm2);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 0]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 0]),
 				    rearm0);
 
 		/* repeat for the odd mbufs */
@@ -427,13 +407,13 @@
 		rearm3 = _mm256_blend_epi32(rearm3, mb2_3, 0xF0);
 		rearm1 = _mm256_blend_epi32(rearm1, mb0_1, 0xF0);
 		/* again write to mbufs */
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 7]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 7]),
 				    rearm7);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 5]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 5]),
 				    rearm5);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 3]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 3]),
 				    rearm3);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 1]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 1]),
 				    rearm1);
 
 		/* extract and record EOP bit */
@@ -622,19 +602,6 @@
 			 0xFF, 0xFF,	/* pkt_type set as unknown */
 			 0xFF, 0xFF	/*pkt_type set as unknown */
 			);
-	/**
-	 * compile-time check the above crc and shuffle layout is correct.
-	 * NOTE: the first field (lowest address) is given last in set_epi
-	 * calls above.
-	 */
-	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, vlan_tci) !=
-			offsetof(struct rte_mbuf, rx_descriptor_fields1) + 10);
-	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, hash) !=
-			offsetof(struct rte_mbuf, rx_descriptor_fields1) + 12);
 
 	/* Status/Error flag masks */
 	/**
@@ -1279,13 +1246,6 @@
 		 * add in the previously computed rx_descriptor fields to
 		 * make a single 256-bit write per mbuf
 		 */
-		/* check the structure matches expectations */
-		RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, ol_flags) !=
-				 offsetof(struct rte_mbuf, rearm_data) + 8);
-		RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, rearm_data) !=
-				 RTE_ALIGN(offsetof(struct rte_mbuf,
-						    rearm_data),
-					   16));
 		/* build up data and do writes */
 		__m256i rearm0, rearm1, rearm2, rearm3, rearm4, rearm5,
 			rearm6, rearm7;
@@ -1305,13 +1265,13 @@
 		rearm2 = _mm256_permute2f128_si256(rearm2, mb2_3, 0x20);
 		rearm0 = _mm256_permute2f128_si256(rearm0, mb0_1, 0x20);
 		/* write to mbuf */
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 6]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 6]),
 				    rearm6);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 4]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 4]),
 				    rearm4);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 2]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 2]),
 				    rearm2);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 0]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 0]),
 				    rearm0);
 
 		/* repeat for the odd mbufs */
@@ -1334,13 +1294,13 @@
 		rearm3 = _mm256_blend_epi32(rearm3, mb2_3, 0xF0);
 		rearm1 = _mm256_blend_epi32(rearm1, mb0_1, 0xF0);
 		/* again write to mbufs */
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 7]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 7]),
 				    rearm7);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 5]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 5]),
 				    rearm5);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 3]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 3]),
 				    rearm3);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 1]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 1]),
 				    rearm1);
 
 		/* extract and record EOP bit */
drivers/net/iavf/iavf_rxtx_vec_avx512.c +16 -56

132 lines not on this page · raw message

drivers/net/iavf/iavf_rxtx_vec_common.h +1 -3
index 5c52200..71e3644 100644
@@ -197,7 +197,6 @@
 static inline int
 iavf_rxq_vec_setup_default(struct iavf_rx_queue *rxq)
 {
-	uintptr_t p;
 	struct rte_mbuf mb_def = { .buf_addr = 0 }; /* zeroed mbuf */
 
 	mb_def.nb_segs = 1;
@@ -207,8 +206,7 @@
 
 	/* 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);
 	return 0;
 }
 
drivers/net/iavf/iavf_rxtx_vec_neon.c +8 -8
index 83825aa..d7ea940 100644
@@ -159,10 +159,10 @@
 	rearm2 = vsetq_lane_u64(vgetq_lane_u32(vlan0, 2), mbuf_init, 1);
 	rearm3 = vsetq_lane_u64(vgetq_lane_u32(vlan0, 3), mbuf_init, 1);
 
-	vst1q_u64((uint64_t *)&rx_pkts[0]->rearm_data, rearm0);
-	vst1q_u64((uint64_t *)&rx_pkts[1]->rearm_data, rearm1);
-	vst1q_u64((uint64_t *)&rx_pkts[2]->rearm_data, rearm2);
-	vst1q_u64((uint64_t *)&rx_pkts[3]->rearm_data, rearm3);
+	vst1q_u64(rte_mbuf_rearm_data(rx_pkts[0]), rearm0);
+	vst1q_u64(rte_mbuf_rearm_data(rx_pkts[1]), rearm1);
+	vst1q_u64(rte_mbuf_rearm_data(rx_pkts[2]), rearm2);
+	vst1q_u64(rte_mbuf_rearm_data(rx_pkts[3]), rearm3);
 }
 
 #define PKTLEN_SHIFT     10
@@ -332,13 +332,13 @@
 		pkt_mb1 = vreinterpretq_u8_u16(tmp);
 
 		/* D.3 copy final data to rx_pkts */
-		vst1q_u8((void *)&rx_pkts[pos + 3]->rx_descriptor_fields1,
+		vst1q_u8(rte_mbuf_rx_descriptor_fields1(rx_pkts[pos + 3]),
 				pkt_mb4);
-		vst1q_u8((void *)&rx_pkts[pos + 2]->rx_descriptor_fields1,
+		vst1q_u8(rte_mbuf_rx_descriptor_fields1(rx_pkts[pos + 2]),
 				pkt_mb3);
-		vst1q_u8((void *)&rx_pkts[pos + 1]->rx_descriptor_fields1,
+		vst1q_u8(rte_mbuf_rx_descriptor_fields1(rx_pkts[pos + 1]),
 				pkt_mb2);
-		vst1q_u8((void *)&rx_pkts[pos]->rx_descriptor_fields1,
+		vst1q_u8(rte_mbuf_rx_descriptor_fields1(rx_pkts[pos]),
 				pkt_mb1);
 
 		desc_to_ptype_v(descs, &rx_pkts[pos], ptype_tbl);
drivers/net/iavf/iavf_rxtx_vec_sse.c +17 -68

151 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#102 lore raw

PATCH v6 11/23 net/ice: use mbuf descriptor accessors

In reply to Tyler Retzlaff

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.

---
 drivers/net/ice/ice_rxtx_vec_avx2.c   | 36 +++++++---------------------
 drivers/net/ice/ice_rxtx_vec_avx512.c | 37 +++++++----------------------
 drivers/net/ice/ice_rxtx_vec_common.h |  4 +---
 drivers/net/ice/ice_rxtx_vec_sse.c    | 44 +++++++----------------------------
 4 files changed, 25 insertions(+), 96 deletions(-)
drivers/net/ice/ice_rxtx_vec_avx2.c +8 -28
index 6f6d790..853f99b 100644
@@ -114,19 +114,6 @@
 			 0xFF, 0xFF,	/* pkt_type set as unknown */
 			 0xFF, 0xFF	/*pkt_type set as unknown */
 			);
-	/**
-	 * compile-time check the above crc and shuffle layout is correct.
-	 * NOTE: the first field (lowest address) is given last in set_epi
-	 * calls above.
-	 */
-	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, vlan_tci) !=
-			offsetof(struct rte_mbuf, rx_descriptor_fields1) + 10);
-	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, hash) !=
-			offsetof(struct rte_mbuf, rx_descriptor_fields1) + 12);
 
 	/* Status/Error flag masks */
 	/**
@@ -570,13 +557,6 @@
 		 * add in the previously computed rx_descriptor fields to
 		 * make a single 256-bit write per mbuf
 		 */
-		/* check the structure matches expectations */
-		RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, ol_flags) !=
-				 offsetof(struct rte_mbuf, rearm_data) + 8);
-		RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, rearm_data) !=
-				 RTE_ALIGN(offsetof(struct rte_mbuf,
-						    rearm_data),
-					   16));
 		/* build up data and do writes */
 		__m256i rearm0, rearm1, rearm2, rearm3, rearm4, rearm5,
 			rearm6, rearm7;
@@ -596,13 +576,13 @@
 		rearm2 = _mm256_permute2f128_si256(rearm2, mb2_3, 0x20);
 		rearm0 = _mm256_permute2f128_si256(rearm0, mb0_1, 0x20);
 		/* write to mbuf */
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 6]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 6]),
 				    rearm6);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 4]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 4]),
 				    rearm4);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 2]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 2]),
 				    rearm2);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 0]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 0]),
 				    rearm0);
 
 		/* repeat for the odd mbufs */
@@ -625,13 +605,13 @@
 		rearm3 = _mm256_blend_epi32(rearm3, mb2_3, 0xF0);
 		rearm1 = _mm256_blend_epi32(rearm1, mb0_1, 0xF0);
 		/* again write to mbufs */
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 7]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 7]),
 				    rearm7);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 5]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 5]),
 				    rearm5);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 3]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 3]),
 				    rearm3);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 1]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 1]),
 				    rearm1);
 
 		/* extract and record EOP bit */
drivers/net/ice/ice_rxtx_vec_avx512.c +8 -29
index 04148e8..6d04bf7 100644
@@ -100,20 +100,6 @@
 			 0xFFFFFFFF
 			);
 
-	/**
-	 * compile-time check the above crc and shuffle layout is correct.
-	 * NOTE: the first field (lowest address) is given last in set_epi
-	 * calls above.
-	 */
-	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, vlan_tci) !=
-			offsetof(struct rte_mbuf, rx_descriptor_fields1) + 10);
-	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, hash) !=
-			offsetof(struct rte_mbuf, rx_descriptor_fields1) + 12);
-
 	/* following code block is for Rx Checksum Offload */
 	/* Status/Error flag masks */
 	/**
@@ -568,13 +554,6 @@
 		 * add in the previously computed rx_descriptor fields to
 		 * make a single 256-bit write per mbuf
 		 */
-		/* check the structure matches expectations */
-		RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, ol_flags) !=
-				 offsetof(struct rte_mbuf, rearm_data) + 8);
-		RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, rearm_data) !=
-				 RTE_ALIGN(offsetof(struct rte_mbuf,
-						    rearm_data),
-					   16));
 		/* build up data and do writes */
 		__m256i rearm0, rearm1, rearm2, rearm3, rearm4, rearm5,
 			rearm6, rearm7;
@@ -597,13 +576,13 @@
 		rearm0 = _mm256_permute2f128_si256(rearm0, mb0_1, 0x20);
 
 		/* write to mbuf */
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 6]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 6]),
 				    rearm6);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 4]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 4]),
 				    rearm4);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 2]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 2]),
 				    rearm2);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 0]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 0]),
 				    rearm0);
 
 		/* repeat for the odd mbufs */
@@ -627,13 +606,13 @@
 		rearm3 = _mm256_blend_epi32(rearm3, mb2_3, 0xF0);
 		rearm1 = _mm256_blend_epi32(rearm1, mb0_1, 0xF0);
 		/* again write to mbufs */
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 7]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 7]),
 				    rearm7);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 5]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 5]),
 				    rearm5);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 3]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 3]),
 				    rearm3);
-		_mm256_storeu_si256((__m256i *)&rx_pkts[i + 1]->rearm_data,
+		_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(rx_pkts[i + 1]),
 				    rearm1);
 
 		/* extract and record EOP bit */
drivers/net/ice/ice_rxtx_vec_common.h +1 -3
index 4b73465..c284d2d 100644
@@ -232,7 +232,6 @@
 static inline int
 ice_rxq_vec_setup_default(struct ice_rx_queue *rxq)
 {
-	uintptr_t p;
 	struct rte_mbuf mb_def = { .buf_addr = 0 }; /* zeroed mbuf */
 
 	mb_def.nb_segs = 1;
@@ -242,8 +241,7 @@
 
 	/* 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);
 	return 0;
 }
 
drivers/net/ice/ice_rxtx_vec_sse.c +8 -36

77 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#103 lore raw

PATCH v6 12/23 net/ionic: use mbuf descriptor accessors

In reply to Tyler Retzlaff

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.

---
 drivers/net/ionic/ionic_lif.c         | 6 ++----
 drivers/net/ionic/ionic_rxtx_sg.c     | 4 ++--
 drivers/net/ionic/ionic_rxtx_simple.c | 2 +-
 3 files changed, 5 insertions(+), 7 deletions(-)
drivers/net/ionic/ionic_lif.c +2 -4
index 93a1011..4a5aa1e 100644
@@ -744,8 +744,7 @@
 
 	rte_compiler_barrier();
 
-	RTE_BUILD_BUG_ON(sizeof(rxm.rearm_data[0]) != sizeof(uint64_t));
-	return rxm.rearm_data[0];
+	return *rte_mbuf_rearm_data(&rxm);
 }
 
 static uint64_t
@@ -762,8 +761,7 @@
 
 	rte_compiler_barrier();
 
-	RTE_BUILD_BUG_ON(sizeof(rxm.rearm_data[0]) != sizeof(uint64_t));
-	return rxm.rearm_data[0];
+	return *rte_mbuf_rearm_data(&rxm);
 }
 
 int
drivers/net/ionic/ionic_rxtx_sg.c +2 -2
index 92e1d6e..4a6f3c2 100644
@@ -286,7 +286,7 @@
 	info[0] = NULL;
 
 	/* Set the mbuf metadata based on the cq entry */
-	rxm->rearm_data[0] = rxq->rearm_data;
+	*rte_mbuf_rearm_data(rxm) = rxq->rearm_data;
 	rxm->pkt_len = cq_desc_len;
 	rxm->data_len = RTE_MIN(rxq->hdr_seg_size, cq_desc_len);
 	left = cq_desc_len - rxm->data_len;
@@ -299,7 +299,7 @@
 		info[i] = NULL;
 
 		/* Set the chained mbuf metadata */
-		rxm_seg->rearm_data[0] = rxq->rearm_seg_data;
+		*rte_mbuf_rearm_data(rxm_seg) = rxq->rearm_seg_data;
 		rxm_seg->data_len = RTE_MIN(rxq->seg_size, left);
 		left -= rxm_seg->data_len;
 
drivers/net/ionic/ionic_rxtx_simple.c +1 -1
index f12f66f..02528e8 100644
@@ -257,7 +257,7 @@
 	info[0] = NULL;
 
 	/* Set the mbuf metadata based on the cq entry */
-	rxm->rearm_data[0] = rxq->rearm_data;
+	*rte_mbuf_rearm_data(rxm) = rxq->rearm_data;
 	rxm->pkt_len = cq_desc_len;
 	rxm->data_len = cq_desc_len;
 
Signature · 1 line
1.8.3.1
#104 lore raw

PATCH v6 13/23 net/ixgbe: use mbuf descriptor accessors

In reply to Tyler Retzlaff

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.

---
 drivers/net/ixgbe/ixgbe_rxtx_vec_common.h |  4 +--
 drivers/net/ixgbe/ixgbe_rxtx_vec_neon.c   | 12 ++++----
 drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c    | 51 ++++++++-----------------------
 3 files changed, 20 insertions(+), 47 deletions(-)
drivers/net/ixgbe/ixgbe_rxtx_vec_common.h +1 -3
index a4d9ec9..78ab168 100644
@@ -244,7 +244,6 @@
 static inline int
 ixgbe_rxq_vec_setup_default(struct ixgbe_rx_queue *rxq)
 {
-	uintptr_t p;
 	struct rte_mbuf mb_def = { .buf_addr = 0 }; /* zeroed mbuf */
 
 	mb_def.nb_segs = 1;
@@ -254,8 +253,7 @@
 
 	/* 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);
 	return 0;
 }
 
drivers/net/ixgbe/ixgbe_rxtx_vec_neon.c +6 -6
index 952b032..2e1d903 100644
@@ -56,13 +56,13 @@
 		 * Flush mbuf with pkt template.
 		 * Data to be rearmed is 6 bytes long.
 		 */
-		vst1_u8((uint8_t *)&mb0->rearm_data, p);
+		vst1_u8((uint8_t *)rte_mbuf_rearm_data(mb0), p);
 		paddr = mb0->buf_iova + RTE_PKTMBUF_HEADROOM;
 		dma_addr0 = vsetq_lane_u64(paddr, zero, 0);
 		/* flush desc with pa dma_addr */
 		vst1q_u64((uint64_t *)&rxdp++->read, dma_addr0);
 
-		vst1_u8((uint8_t *)&mb1->rearm_data, p);
+		vst1_u8((uint8_t *)rte_mbuf_rearm_data(mb1), p);
 		paddr = mb1->buf_iova + RTE_PKTMBUF_HEADROOM;
 		dma_addr1 = vsetq_lane_u64(paddr, zero, 0);
 		vst1q_u64((uint64_t *)&rxdp++->read, dma_addr1);
@@ -411,9 +411,9 @@
 		pkt_mb3 = vreinterpretq_u8_u16(tmp);
 
 		/* D.3 copy final 3,4 data to rx_pkts */
-		vst1q_u8((void *)&rx_pkts[pos + 3]->rx_descriptor_fields1,
+		vst1q_u8(rte_mbuf_rx_descriptor_fields1(rx_pkts[pos + 3]),
 			 pkt_mb4);
-		vst1q_u8((void *)&rx_pkts[pos + 2]->rx_descriptor_fields1,
+		vst1q_u8(rte_mbuf_rx_descriptor_fields1(rx_pkts[pos + 2]),
 			 pkt_mb3);
 
 		/* D.2 pkt 1,2 set in_port/nb_seg and remove crc */
@@ -441,9 +441,9 @@
 		rte_prefetch_non_temporal(rxdp + RTE_IXGBE_DESCS_PER_LOOP);
 
 		/* D.3 copy final 1,2 data to rx_pkts */
-		vst1q_u8((uint8_t *)&rx_pkts[pos + 1]->rx_descriptor_fields1,
+		vst1q_u8((uint8_t *)rte_mbuf_rx_descriptor_fields1(rx_pkts[pos + 1]),
 			 pkt_mb2);
-		vst1q_u8((uint8_t *)&rx_pkts[pos]->rx_descriptor_fields1,
+		vst1q_u8((uint8_t *)rte_mbuf_rx_descriptor_fields1(rx_pkts[pos]),
 			 pkt_mb1);
 
 		desc_to_ptype_v(descs, rxq->pkt_type_mask, &rx_pkts[pos]);
drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c +13 -38

89 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#105 lore raw

PATCH v6 14/23 net/mlx5: use mbuf descriptor accessors

In reply to Tyler Retzlaff

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.

---
 drivers/net/mlx5/mlx5_rxq.c              |  2 +-
 drivers/net/mlx5/mlx5_rxtx_vec.h         | 19 -------------------
 drivers/net/mlx5/mlx5_rxtx_vec_altivec.h | 28 ++++++++++++++--------------
 drivers/net/mlx5/mlx5_rxtx_vec_neon.h    | 20 ++++++++++----------
 drivers/net/mlx5/mlx5_rxtx_vec_sse.h     | 28 ++++++++++++++--------------
 5 files changed, 39 insertions(+), 58 deletions(-)
drivers/net/mlx5/mlx5_rxq.c +1 -1
index ca2eeed..b854418 100644
@@ -200,7 +200,7 @@
 		 */
 		rte_compiler_barrier();
 		rxq->mbuf_initializer =
-			*(rte_xmm_t *)&mbuf_init->rearm_data;
+			*(rte_xmm_t *)rte_mbuf_rearm_data(mbuf_init);
 		/* Padding with a fake mbuf for vectorized Rx. */
 		for (j = 0; j < MLX5_VPMD_DESCS_PER_LOOP; ++j)
 			(*rxq->elts)[elts_n + j] = &rxq->fake_mbuf;
drivers/net/mlx5/mlx5_rxtx_vec.h +0 -19
index 77c3f4e..43518c4 100644
@@ -29,25 +29,6 @@
 #define S_ASSERT_MLX5_CQE(s) \
 	static_assert(s, "A field of struct mlx5_cqe is changed")
 
-/* rxq_cq_decompress_v() */
-S_ASSERT_RTE_MBUF(offsetof(struct rte_mbuf, pkt_len) ==
-		  offsetof(struct rte_mbuf, rx_descriptor_fields1) + 4);
-S_ASSERT_RTE_MBUF(offsetof(struct rte_mbuf, data_len) ==
-		  offsetof(struct rte_mbuf, rx_descriptor_fields1) + 8);
-S_ASSERT_RTE_MBUF(offsetof(struct rte_mbuf, hash) ==
-		  offsetof(struct rte_mbuf, rx_descriptor_fields1) + 12);
-
-/* rxq_cq_to_ptype_oflags_v() */
-S_ASSERT_RTE_MBUF(offsetof(struct rte_mbuf, ol_flags) ==
-		  offsetof(struct rte_mbuf, rearm_data) + 8);
-S_ASSERT_RTE_MBUF(offsetof(struct rte_mbuf, rearm_data) ==
-		  RTE_ALIGN(offsetof(struct rte_mbuf, rearm_data), 16));
-
-/* rxq_burst_v() */
-S_ASSERT_RTE_MBUF(offsetof(struct rte_mbuf, pkt_len) ==
-		  offsetof(struct rte_mbuf, rx_descriptor_fields1) + 4);
-S_ASSERT_RTE_MBUF(offsetof(struct rte_mbuf, data_len) ==
-		  offsetof(struct rte_mbuf, rx_descriptor_fields1) + 8);
 #if (RTE_CACHE_LINE_SIZE == 128)
 S_ASSERT_MLX5_CQE(offsetof(struct mlx5_cqe, pkt_info) == 64);
 #else
drivers/net/mlx5/mlx5_rxtx_vec_altivec.h +14 -14
index cccfa7f..9349c21 100644
@@ -101,10 +101,10 @@
 	uint16_t pkts_n = mcqe_n;
 	const __vector unsigned char rearm =
 		(__vector unsigned char)vec_vsx_ld(0,
-		(signed int const *)&t_pkt->rearm_data);
+		(signed int const *)rte_mbuf_rearm_data(t_pkt));
 	const __vector unsigned char rxdf =
 		(__vector unsigned char)vec_vsx_ld(0,
-		(signed int const *)&t_pkt->rx_descriptor_fields1);
+		(signed int const *)rte_mbuf_rx_descriptor_fields1(t_pkt));
 	const __vector unsigned char crc_adj =
 		(__vector unsigned char)(__vector unsigned short){
 			0, 0, rxq->crc_present * RTE_ETHER_CRC_LEN, 0,
@@ -173,9 +173,9 @@
 
 		/* B.1 store rearm data to mbuf. */
 		*(__vector unsigned char *)
-			&elts[pos]->rearm_data = rearm;
+			rte_mbuf_rearm_data(elts[pos]) = rearm;
 		*(__vector unsigned char *)
-			&elts[pos + 1]->rearm_data = rearm;
+			rte_mbuf_rearm_data(elts[pos + 1]) = rearm;
 
 		/* C.1 combine data from mCQEs with rx_descriptor_fields1. */
 		rxdf1 = vec_perm(mcqe1, zero, shuf_mask1);
@@ -195,15 +195,15 @@
 
 		/* D.1 store rx_descriptor_fields1. */
 		*(__vector unsigned char *)
-			&elts[pos]->rx_descriptor_fields1 = rxdf1;
+			rte_mbuf_rx_descriptor_fields1(elts[pos]) = rxdf1;
 		*(__vector unsigned char *)
-			&elts[pos + 1]->rx_descriptor_fields1 = rxdf2;
+			rte_mbuf_rx_descriptor_fields1(elts[pos + 1]) = rxdf2;
 
 		/* B.1 store rearm data to mbuf. */
 		*(__vector unsigned char *)
-			&elts[pos + 2]->rearm_data = rearm;
+			rte_mbuf_rearm_data(elts[pos + 2]) = rearm;
 		*(__vector unsigned char *)
-			&elts[pos + 3]->rearm_data = rearm;
+			rte_mbuf_rearm_data(elts[pos + 3]) = rearm;
 
 		/* C.1 combine data from mCQEs with rx_descriptor_fields1. */
 		rxdf1 = vec_perm(mcqe2, zero, shuf_mask1);
@@ -223,9 +223,9 @@
 
 		/* D.1 store rx_descriptor_fields1. */
 		*(__vector unsigned char *)
-			&elts[pos + 2]->rx_descriptor_fields1 = rxdf1;
+			rte_mbuf_rx_descriptor_fields1(elts[pos + 2]) = rxdf1;
 		*(__vector unsigned char *)
-			&elts[pos + 3]->rx_descriptor_fields1 = rxdf2;
+			rte_mbuf_rx_descriptor_fields1(elts[pos + 3]) = rxdf2;
 
 #ifdef MLX5_PMD_SOFT_COUNTERS
 		invalid_mask = (__vector unsigned char)(__vector unsigned long){
@@ -769,13 +769,13 @@
 
 	/* Write 8B rearm_data and 8B ol_flags. */
 	vec_vsx_st(rearm0, 0,
-		(__vector unsigned char *)&pkts[0]->rearm_data);
+		(__vector unsigned char *)rte_mbuf_rearm_data(pkts[0]));
 	vec_vsx_st(rearm1, 0,
-		(__vector unsigned char *)&pkts[1]->rearm_data);
+		(__vector unsigned char *)rte_mbuf_rearm_data(pkts[1]));
 	vec_vsx_st(rearm2, 0,
-		(__vector unsigned char *)&pkts[2]->rearm_data);
+		(__vector unsigned char *)rte_mbuf_rearm_data(pkts[2]));
 	vec_vsx_st(rearm3, 0,
-		(__vector unsigned char *)&pkts[3]->rearm_data);
+		(__vector unsigned char *)rte_mbuf_rearm_data(pkts[3]));
 }
 
 /**
drivers/net/mlx5/mlx5_rxtx_vec_neon.h +10 -10
index 3ed6881..97ea620 100644
@@ -99,7 +99,7 @@
 		t_pkt->data_len + (rxq->crc_present * RTE_ETHER_CRC_LEN);
 	uint16_t pkts_n = mcqe_n;
 	const uint64x2_t rearm =
-		vld1q_u64((void *)&t_pkt->rearm_data);
+		vld1q_u64((void *)rte_mbuf_rearm_data(t_pkt));
 	const uint32x4_t rxdf_mask = {
 		0xffffffff, /* packet_type */
 		0,          /* skip pkt_len */
@@ -107,7 +107,7 @@
 		0,          /* skip hash.rss */
 	};
 	const uint8x16_t rxdf =
-		vandq_u8(vld1q_u8((void *)&t_pkt->rx_descriptor_fields1),
+		vandq_u8(vld1q_u8(rte_mbuf_rx_descriptor_fields1(t_pkt)),
 			 vreinterpretq_u8_u32(rxdf_mask));
 	const uint16x8_t crc_adj = {
 		0, 0,
@@ -140,10 +140,10 @@
 		rte_prefetch0((void *)(cq + mcqe_n));
 	for (pos = 0; pos < mcqe_n; ) {
 		uint8_t *p = (void *)&mcq[pos % 8];
-		uint8_t *e0 = (void *)&elts[pos]->rearm_data;
-		uint8_t *e1 = (void *)&elts[pos + 1]->rearm_data;
-		uint8_t *e2 = (void *)&elts[pos + 2]->rearm_data;
-		uint8_t *e3 = (void *)&elts[pos + 3]->rearm_data;
+		uint8_t *e0 = (void *)rte_mbuf_rearm_data(elts[pos]);
+		uint8_t *e1 = (void *)rte_mbuf_rearm_data(elts[pos + 1]);
+		uint8_t *e2 = (void *)rte_mbuf_rearm_data(elts[pos + 2]);
+		uint8_t *e3 = (void *)rte_mbuf_rearm_data(elts[pos + 3]);
 		uint16x4_t byte_cnt;
 #ifdef MLX5_PMD_SOFT_COUNTERS
 		uint16x4_t invalid_mask =
@@ -513,10 +513,10 @@
 					(vgetq_lane_u32(ol_flags, 0),
 					 vreinterpretq_u32_u64(mbuf_init), 2));
 
-	vst1q_u64((void *)&pkts[0]->rearm_data, rearm0);
-	vst1q_u64((void *)&pkts[1]->rearm_data, rearm1);
-	vst1q_u64((void *)&pkts[2]->rearm_data, rearm2);
-	vst1q_u64((void *)&pkts[3]->rearm_data, rearm3);
+	vst1q_u64((void *)rte_mbuf_rearm_data(pkts[0]), rearm0);
+	vst1q_u64((void *)rte_mbuf_rearm_data(pkts[1]), rearm1);
+	vst1q_u64((void *)rte_mbuf_rearm_data(pkts[2]), rearm2);
+	vst1q_u64((void *)rte_mbuf_rearm_data(pkts[3]), rearm3);
 }
 
 /**
drivers/net/mlx5/mlx5_rxtx_vec_sse.h +14 -14
index 2bdd1f6..088ce37 100644
@@ -98,9 +98,9 @@
 		t_pkt->data_len + (rxq->crc_present * RTE_ETHER_CRC_LEN);
 	uint16_t pkts_n = mcqe_n;
 	const __m128i rearm =
-		_mm_loadu_si128((__m128i *)&t_pkt->rearm_data);
+		_mm_loadu_si128((__m128i *)rte_mbuf_rearm_data(t_pkt));
 	const __m128i rxdf =
-		_mm_loadu_si128((__m128i *)&t_pkt->rx_descriptor_fields1);
+		_mm_loadu_si128((__m128i *)rte_mbuf_rx_descriptor_fields1(t_pkt));
 	const __m128i crc_adj =
 		_mm_set_epi16(0, 0, 0,
 			      rxq->crc_present * RTE_ETHER_CRC_LEN,
@@ -145,8 +145,8 @@
 		mcqe1 = _mm_loadu_si128((__m128i *)&mcq[pos % 8]);
 		mcqe2 = _mm_loadu_si128((__m128i *)&mcq[pos % 8 + 2]);
 		/* B.1 store rearm data to mbuf. */
-		_mm_storeu_si128((__m128i *)&elts[pos]->rearm_data, rearm);
-		_mm_storeu_si128((__m128i *)&elts[pos + 1]->rearm_data, rearm);
+		_mm_storeu_si128((__m128i *)rte_mbuf_rearm_data(elts[pos]), rearm);
+		_mm_storeu_si128((__m128i *)rte_mbuf_rearm_data(elts[pos + 1]), rearm);
 		/* C.1 combine data from mCQEs with rx_descriptor_fields1. */
 		rxdf1 = _mm_shuffle_epi8(mcqe1, shuf_mask1);
 		rxdf2 = _mm_shuffle_epi8(mcqe1, shuf_mask2);
@@ -156,14 +156,14 @@
 		rxdf2 = _mm_blend_epi16(rxdf2, rxdf, 0x23);
 		/* D.1 store rx_descriptor_fields1. */
 		_mm_storeu_si128((__m128i *)
-				  &elts[pos]->rx_descriptor_fields1,
+				  rte_mbuf_rx_descriptor_fields1(elts[pos]),
 				 rxdf1);
 		_mm_storeu_si128((__m128i *)
-				  &elts[pos + 1]->rx_descriptor_fields1,
+				  rte_mbuf_rx_descriptor_fields1(elts[pos + 1]),
 				 rxdf2);
 		/* B.1 store rearm data to mbuf. */
-		_mm_storeu_si128((__m128i *)&elts[pos + 2]->rearm_data, rearm);
-		_mm_storeu_si128((__m128i *)&elts[pos + 3]->rearm_data, rearm);
+		_mm_storeu_si128((__m128i *)rte_mbuf_rearm_data(elts[pos + 2]), rearm);
+		_mm_storeu_si128((__m128i *)rte_mbuf_rearm_data(elts[pos + 3]), rearm);
 		/* C.1 combine data from mCQEs with rx_descriptor_fields1. */
 		rxdf1 = _mm_shuffle_epi8(mcqe2, shuf_mask1);
 		rxdf2 = _mm_shuffle_epi8(mcqe2, shuf_mask2);
@@ -173,10 +173,10 @@
 		rxdf2 = _mm_blend_epi16(rxdf2, rxdf, 0x23);
 		/* D.1 store rx_descriptor_fields1. */
 		_mm_storeu_si128((__m128i *)
-				  &elts[pos + 2]->rx_descriptor_fields1,
+				  rte_mbuf_rx_descriptor_fields1(elts[pos + 2]),
 				 rxdf1);
 		_mm_storeu_si128((__m128i *)
-				  &elts[pos + 3]->rx_descriptor_fields1,
+				  rte_mbuf_rx_descriptor_fields1(elts[pos + 3]),
 				 rxdf2);
 #ifdef MLX5_PMD_SOFT_COUNTERS
 		invalid_mask = _mm_set_epi64x(0,
@@ -511,10 +511,10 @@
 	rearm2 = _mm_blend_epi16(mbuf_init, ol_flags, 0x30);
 	rearm3 = _mm_blend_epi16(mbuf_init, _mm_srli_si128(ol_flags, 4), 0x30);
 	/* Write 8B rearm_data and 8B ol_flags. */
-	_mm_store_si128((__m128i *)&pkts[0]->rearm_data, rearm0);
-	_mm_store_si128((__m128i *)&pkts[1]->rearm_data, rearm1);
-	_mm_store_si128((__m128i *)&pkts[2]->rearm_data, rearm2);
-	_mm_store_si128((__m128i *)&pkts[3]->rearm_data, rearm3);
+	_mm_store_si128((__m128i *)rte_mbuf_rearm_data(pkts[0]), rearm0);
+	_mm_store_si128((__m128i *)rte_mbuf_rearm_data(pkts[1]), rearm1);
+	_mm_store_si128((__m128i *)rte_mbuf_rearm_data(pkts[2]), rearm2);
+	_mm_store_si128((__m128i *)rte_mbuf_rearm_data(pkts[3]), rearm3);
 }
 
 /**
Signature · 1 line
1.8.3.1
#106 lore raw

PATCH v6 15/23 net/octeon_ep: use mbuf descriptor accessors

In reply to Tyler Retzlaff

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.

---
 drivers/net/octeon_ep/cnxk_ep_rx.h      | 2 +-
 drivers/net/octeon_ep/cnxk_ep_rx_avx.c  | 2 +-
 drivers/net/octeon_ep/cnxk_ep_rx_neon.c | 8 ++++----
 drivers/net/octeon_ep/cnxk_ep_rx_sse.c  | 8 ++++----
 drivers/net/octeon_ep/otx_ep_rxtx.c     | 5 +----
 5 files changed, 11 insertions(+), 14 deletions(-)
drivers/net/octeon_ep/cnxk_ep_rx.h +1 -1
index 61263e6..1d706e2 100644
@@ -158,7 +158,7 @@
 		mbuf->pkt_len = pkt_len;
 		mbuf->data_len = pkt_len;
 
-		*(uint64_t *)&mbuf->rearm_data = droq->rearm_data;
+		*rte_mbuf_rearm_data(mbuf) = droq->rearm_data;
 		rx_pkts[pkts] = mbuf;
 		bytes_rsvd += pkt_len;
 	}
drivers/net/octeon_ep/cnxk_ep_rx_avx.c +1 -1
index 47eb1d2..3b8241c 100644
@@ -60,7 +60,7 @@
 
 		/* Store the 256bit data to the mbuf. */
 		for (i = 0; i < CNXK_EP_OQ_DESC_PER_LOOP_AVX; i++)
-			_mm256_storeu_si256((__m256i *)&m[i]->rearm_data, data[i]);
+			_mm256_storeu_si256((__m256i *)rte_mbuf_rearm_data(m[i]), data[i]);
 
 		for (i = 0; i < CNXK_EP_OQ_DESC_PER_LOOP_AVX; i++)
 			rx_pkts[pkts++] = m[i];
drivers/net/octeon_ep/cnxk_ep_rx_neon.c +4 -4
index 4c46a7e..8797252 100644
@@ -72,10 +72,10 @@
 		*(uint64_t *)&m3->pkt_len = vgetq_lane_u64(s23, 1);
 
 		/* Reset rearm data. */
-		*(uint64_t *)&m0->rearm_data = droq->rearm_data;
-		*(uint64_t *)&m1->rearm_data = droq->rearm_data;
-		*(uint64_t *)&m2->rearm_data = droq->rearm_data;
-		*(uint64_t *)&m3->rearm_data = droq->rearm_data;
+		*rte_mbuf_rearm_data(m0) = droq->rearm_data;
+		*rte_mbuf_rearm_data(m1) = droq->rearm_data;
+		*rte_mbuf_rearm_data(m2) = droq->rearm_data;
+		*rte_mbuf_rearm_data(m3) = droq->rearm_data;
 
 		rx_pkts[pkts++] = m0;
 		rx_pkts[pkts++] = m1;
drivers/net/octeon_ep/cnxk_ep_rx_sse.c +4 -4
index 308c8b2..1466217 100644
@@ -64,10 +64,10 @@
 		*(uint64_t *)&m3->pkt_len = ((rte_xmm_t)s23).u64[1];
 
 		/* Reset rearm data. */
-		*(uint64_t *)&m0->rearm_data = droq->rearm_data;
-		*(uint64_t *)&m1->rearm_data = droq->rearm_data;
-		*(uint64_t *)&m2->rearm_data = droq->rearm_data;
-		*(uint64_t *)&m3->rearm_data = droq->rearm_data;
+		*rte_mbuf_rearm_data(m0) = droq->rearm_data;
+		*rte_mbuf_rearm_data(m1) = droq->rearm_data;
+		*rte_mbuf_rearm_data(m2) = droq->rearm_data;
+		*rte_mbuf_rearm_data(m3) = droq->rearm_data;
 
 		rx_pkts[pkts++] = m0;
 		rx_pkts[pkts++] = m1;
drivers/net/octeon_ep/otx_ep_rxtx.c +1 -4
index aea148e..4470599 100644
@@ -289,7 +289,6 @@
 {
 	uint16_t port_id = otx_ep->port_id;
 	struct rte_mbuf mb_def;
-	uint64_t *tmp;
 
 	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, data_off) % 8 != 0);
 	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, refcnt) - offsetof(struct rte_mbuf, data_off) !=
@@ -305,9 +304,7 @@
 
 	/* Prevent compiler reordering: rearm_data covers previous fields */
 	rte_compiler_barrier();
-	tmp = (uint64_t *)&mb_def.rearm_data;
-
-	return *tmp;
+	return *rte_mbuf_rearm_data(&mb_def);
 }
 
 /* OQ initialization */
Signature · 1 line
1.8.3.1
#107 lore raw

PATCH v6 16/23 net/sfc: use mbuf descriptor accessors

In reply to Tyler Retzlaff

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.

---
 drivers/net/sfc/sfc_ef100_rx.c |  7 ++-----
 drivers/net/sfc/sfc_ef10_rx.c  | 10 +++-------
 2 files changed, 5 insertions(+), 12 deletions(-)
drivers/net/sfc/sfc_ef100_rx.c +2 -5
index e283879..51c7da0 100644
@@ -553,9 +553,7 @@ struct sfc_ef100_rxq {
 		pkt = sfc_ef100_rx_next_mbuf(rxq);
 		__rte_mbuf_raw_sanity_check(pkt);
 
-		RTE_BUILD_BUG_ON(sizeof(pkt->rearm_data[0]) !=
-				 sizeof(rxq->rearm_data));
-		pkt->rearm_data[0] = rxq->rearm_data;
+		*rte_mbuf_rearm_data(pkt) = rxq->rearm_data;
 
 		/* data_off already moved past Rx prefix */
 		rx_prefix = (const efx_xword_t *)sfc_ef100_rx_pkt_prefix(pkt);
@@ -760,8 +758,7 @@ struct sfc_ef100_rxq {
 
 	/* rearm_data covers structure members filled in above */
 	rte_compiler_barrier();
-	RTE_BUILD_BUG_ON(sizeof(m.rearm_data[0]) != sizeof(uint64_t));
-	return m.rearm_data[0];
+	return *rte_mbuf_rearm_data(&m);
 }
 
 static sfc_dp_rx_qcreate_t sfc_ef100_rx_qcreate;
drivers/net/sfc/sfc_ef10_rx.c +3 -7
index 6044293..2ac0203 100644
@@ -322,8 +322,7 @@ struct sfc_ef10_rxq {
 
 	m = rxd->mbuf;
 
-	RTE_BUILD_BUG_ON(sizeof(m->rearm_data[0]) != sizeof(rxq->rearm_data));
-	m->rearm_data[0] = rxq->rearm_data;
+	*rte_mbuf_rearm_data(m) = rxq->rearm_data;
 
 	/* Classify packet based on Rx event */
 	/* Mask RSS hash offload flag if RSS is not enabled */
@@ -377,9 +376,7 @@ struct sfc_ef10_rxq {
 			rxq->completed = pending;
 		}
 
-		RTE_BUILD_BUG_ON(sizeof(m->rearm_data[0]) !=
-				 sizeof(rxq->rearm_data));
-		m->rearm_data[0] = rxq->rearm_data;
+		*rte_mbuf_rearm_data(m) = rxq->rearm_data;
 
 		/* Event-dependent information is the same */
 		m->ol_flags = m0->ol_flags;
@@ -633,8 +630,7 @@ struct sfc_ef10_rxq {
 
 	/* rearm_data covers structure members filled in above */
 	rte_compiler_barrier();
-	RTE_BUILD_BUG_ON(sizeof(m.rearm_data[0]) != sizeof(uint64_t));
-	return m.rearm_data[0];
+	return *rte_mbuf_rearm_data(&m);
 }
 
 static sfc_dp_rx_qcreate_t sfc_ef10_rx_qcreate;
Signature · 1 line
1.8.3.1
#108 lore raw

PATCH v6 17/23 net/thunderx: use mbuf descriptor accessors

In reply to Tyler Retzlaff

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.

---
 drivers/net/thunderx/nicvf_ethdev.c | 4 +---
 drivers/net/thunderx/nicvf_rxtx.h   | 4 ++--
 2 files changed, 3 insertions(+), 5 deletions(-)
drivers/net/thunderx/nicvf_ethdev.c +1 -3
index 609d95d..722751c 100644
@@ -1306,7 +1306,6 @@ enum nicvf_link_speed {
 static inline void
 nicvf_rxq_mbuf_setup(struct nicvf_rxq *rxq)
 {
-	uintptr_t p;
 	struct rte_mbuf mb_def;
 	struct nicvf *nic = rxq->nic;
 
@@ -1328,8 +1327,7 @@ enum nicvf_link_speed {
 
 	/* Prevent compiler reordering: rearm_data covers previous fields */
 	rte_compiler_barrier();
-	p = (uintptr_t)&mb_def.rearm_data;
-	rxq->mbuf_initializer.value = *(uint64_t *)p;
+	rxq->mbuf_initializer.value = *rte_mbuf_rearm_data(&mb_def);
 }
 
 static int
drivers/net/thunderx/nicvf_rxtx.h +2 -2
index 4b83e33..7c07cde 100644
@@ -66,7 +66,7 @@ static inline uint16_t __attribute__((const))
 #else
 	init.value += apad;
 #endif
-	*(uint64_t *)(&pkt->rearm_data) = init.value;
+	*rte_mbuf_rearm_data(pkt) = init.value;
 }
 
 static inline void
@@ -80,7 +80,7 @@ static inline uint16_t __attribute__((const))
 	init.value += apad;
 #endif
 	init.fields.nb_segs = nb_segs;
-	*(uint64_t *)(&pkt->rearm_data) = init.value;
+	*rte_mbuf_rearm_data(pkt) = init.value;
 }
 
 uint32_t nicvf_dev_rx_queue_count(void *rx_queue);
Signature · 1 line
1.8.3.1
#109 lore raw

PATCH v6 18/23 net/virtio: use mbuf descriptor accessors

In reply to Tyler Retzlaff

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.

---
 drivers/net/virtio/virtio_rxtx_packed.h         |  4 ++--
 drivers/net/virtio/virtio_rxtx_packed_avx.h     | 16 +++++-----------
 drivers/net/virtio/virtio_rxtx_packed_neon.h    | 18 ++++++++----------
 drivers/net/virtio/virtio_rxtx_simple.c         |  4 +---
 drivers/net/virtio/virtio_rxtx_simple.h         |  5 +----
 drivers/net/virtio/virtio_rxtx_simple_altivec.c | 16 ++++++++--------
 drivers/net/virtio/virtio_rxtx_simple_neon.c    | 24 ++++++++----------------
 drivers/net/virtio/virtio_rxtx_simple_sse.c     | 16 ++++++++--------
 8 files changed, 41 insertions(+), 62 deletions(-)
drivers/net/virtio/virtio_rxtx_packed.h +2 -2
index 5361129..0a8c9f8 100644
@@ -37,12 +37,12 @@
 
 /* reference count offset in mbuf rearm data */
 #define REFCNT_BITS_OFFSET ((offsetof(struct rte_mbuf, refcnt) - \
-	offsetof(struct rte_mbuf, rearm_data)) * BYTE_SIZE)
+	offsetof(struct rte_mbuf, data_off)) * BYTE_SIZE)
 
 #ifdef CC_AVX512_SUPPORT
 /* segment number offset in mbuf rearm data */
 #define SEG_NUM_BITS_OFFSET ((offsetof(struct rte_mbuf, nb_segs) - \
-	offsetof(struct rte_mbuf, rearm_data)) * BYTE_SIZE)
+	offsetof(struct rte_mbuf, data_off)) * BYTE_SIZE)
 /* default rearm data */
 #define DEFAULT_REARM_DATA (1ULL << SEG_NUM_BITS_OFFSET | \
 	1ULL << REFCNT_BITS_OFFSET)
drivers/net/virtio/virtio_rxtx_packed_avx.h +5 -11
index 584ac72..5d30e2a 100644
@@ -36,10 +36,10 @@
 	/* Load four mbufs rearm data */
 	RTE_BUILD_BUG_ON(REFCNT_BITS_OFFSET >= 64);
 	RTE_BUILD_BUG_ON(SEG_NUM_BITS_OFFSET >= 64);
-	__m256i mbufs = _mm256_set_epi64x(*tx_pkts[3]->rearm_data,
-					  *tx_pkts[2]->rearm_data,
-					  *tx_pkts[1]->rearm_data,
-					  *tx_pkts[0]->rearm_data);
+	__m256i mbufs = _mm256_set_epi64x(*rte_mbuf_rearm_data(tx_pkts[3]),
+					  *rte_mbuf_rearm_data(tx_pkts[2]),
+					  *rte_mbuf_rearm_data(tx_pkts[1]),
+					  *rte_mbuf_rearm_data(tx_pkts[0]));
 
 	/* refcnt=1 and nb_segs=1 */
 	__m256i mbuf_ref = _mm256_set1_epi64x(DEFAULT_REARM_DATA);
@@ -53,8 +53,6 @@
 
 	/* Check headroom is enough */
 	const __mmask16 data_mask = 0x1 | 0x1 << 4 | 0x1 << 8 | 0x1 << 12;
-	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, data_off) !=
-		offsetof(struct rte_mbuf, rearm_data));
 	cmp = _mm256_mask_cmplt_epu16_mask(data_mask, mbufs, head_rooms);
 	if (unlikely(cmp))
 		return -1;
@@ -187,7 +185,7 @@
 		rx_pkts[i] = (struct rte_mbuf *)vq->vq_descx[id + i].cookie;
 		rte_packet_prefetch(rte_pktmbuf_mtod(rx_pkts[i], void *));
 
-		addrs[i] = (uintptr_t)rx_pkts[i]->rx_descriptor_fields1;
+		addrs[i] = (uintptr_t)rte_mbuf_rx_descriptor_fields1(rx_pkts[i]);
 	}
 
 	/*
@@ -203,10 +201,6 @@
 
 	__m512i v_value = _mm512_add_epi32(values, mbuf_len_offset);
 
-	/* assert offset of data_len */
-	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, data_len) !=
-		offsetof(struct rte_mbuf, rx_descriptor_fields1) + 8);
-
 	__m512i v_index = _mm512_set_epi64(addrs[3] + 8, addrs[3],
 					   addrs[2] + 8, addrs[2],
 					   addrs[1] + 8, addrs[1],
drivers/net/virtio/virtio_rxtx_packed_neon.h +8 -10
index c222ebf..c172fad 100644
@@ -59,10 +59,10 @@
 	uint8x16x2_t mbuf;
 	/* Load four mbufs rearm data. */
 	RTE_BUILD_BUG_ON(REFCNT_BITS_OFFSET >= 64);
-	pkts[0] = vld1_u16((uint16_t *)&tx_pkts[0]->rearm_data);
-	pkts[1] = vld1_u16((uint16_t *)&tx_pkts[1]->rearm_data);
-	pkts[2] = vld1_u16((uint16_t *)&tx_pkts[2]->rearm_data);
-	pkts[3] = vld1_u16((uint16_t *)&tx_pkts[3]->rearm_data);
+	pkts[0] = vld1_u16((uint16_t *)rte_mbuf_rearm_data(tx_pkts[0]));
+	pkts[1] = vld1_u16((uint16_t *)rte_mbuf_rearm_data(tx_pkts[1]));
+	pkts[2] = vld1_u16((uint16_t *)rte_mbuf_rearm_data(tx_pkts[2]));
+	pkts[3] = vld1_u16((uint16_t *)rte_mbuf_rearm_data(tx_pkts[3]));
 
 	mbuf.val[0] = vreinterpretq_u8_u16(vcombine_u16(pkts[0], pkts[1]));
 	mbuf.val[1] = vreinterpretq_u8_u16(vcombine_u16(pkts[2], pkts[3]));
@@ -77,8 +77,6 @@
 
 	/* Check headroom is enough. */
 	uint16x4_t head_rooms = vdup_n_u16(head_size);
-	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, data_off) !=
-			 offsetof(struct rte_mbuf, rearm_data));
 	uint16x4_t data_offset = vreinterpret_u16_u8(vqtbl2_u8(mbuf, data_msk));
 	uint64x1_t cmp2 = vreinterpret_u64_u16(vclt_u16(data_offset, head_rooms));
 	if (unlikely(vget_lane_u64(cmp2, 0)))
@@ -263,10 +261,10 @@
 	pkt_mb[3] = vreinterpretq_u64_u16(vsubq_u16(
 			vreinterpretq_u16_u64(pkt_mb[3]), len_adjust));
 
-	vst1q_u64((void *)&rx_pkts[0]->rx_descriptor_fields1, pkt_mb[0]);
-	vst1q_u64((void *)&rx_pkts[1]->rx_descriptor_fields1, pkt_mb[1]);
-	vst1q_u64((void *)&rx_pkts[2]->rx_descriptor_fields1, pkt_mb[2]);
-	vst1q_u64((void *)&rx_pkts[3]->rx_descriptor_fields1, pkt_mb[3]);
+	vst1q_u64(rte_mbuf_rx_descriptor_fields1(rx_pkts[0]), pkt_mb[0]);
+	vst1q_u64(rte_mbuf_rx_descriptor_fields1(rx_pkts[1]), pkt_mb[1]);
+	vst1q_u64(rte_mbuf_rx_descriptor_fields1(rx_pkts[2]), pkt_mb[2]);
+	vst1q_u64(rte_mbuf_rx_descriptor_fields1(rx_pkts[3]), pkt_mb[3]);
 
 	if (hw->has_rx_offload) {
 		virtio_for_each_try_unroll(i, 0, PACKED_BATCH_SIZE) {
drivers/net/virtio/virtio_rxtx_simple.c +1 -3
index 4382569..e6a82e5 100644
@@ -31,7 +31,6 @@
 virtio_rxq_vec_setup(struct virtnet_rx *rxq)
 {
 	struct virtqueue *vq = virtnet_rxq_to_vq(rxq);
-	uintptr_t p;
 	struct rte_mbuf mb_def = { .buf_addr = 0 }; /* zeroed mbuf */
 
 	mb_def.nb_segs = 1;
@@ -41,8 +40,7 @@
 
 	/* 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);
 
 	return 0;
 }
drivers/net/virtio/virtio_rxtx_simple.h +1 -4
index 79196ed..16fef0e 100644
@@ -39,10 +39,7 @@
 	}
 
 	for (i = 0; i < RTE_VIRTIO_VPMD_RX_REARM_THRESH; i++) {
-		uintptr_t p;
-
-		p = (uintptr_t)&sw_ring[i]->rearm_data;
-		*(uint64_t *)p = rxvq->mbuf_initializer;
+		*rte_mbuf_rearm_data(sw_ring[i]) = rxvq->mbuf_initializer;
 
 		start_dp[i].addr = VIRTIO_MBUF_ADDR(sw_ring[i], vq) +
 			RTE_PKTMBUF_HEADROOM - vq->hw->vtnet_hdr_size;
drivers/net/virtio/virtio_rxtx_simple_altivec.c +8 -8
index 542ec3d..39ec1ca 100644
@@ -138,9 +138,9 @@
 			((__vector unsigned short)pkt_mb[0] + len_adjust);
 		pkt_mb[1] = (__vector unsigned char)
 			((__vector unsigned short)pkt_mb[1] + len_adjust);
-		*(__vector unsigned char *)&rx_pkts[0]->rx_descriptor_fields1 =
+		*(__vector unsigned char *)rte_mbuf_rx_descriptor_fields1(rx_pkts[0]) =
 			pkt_mb[0];
-		*(__vector unsigned char *)&rx_pkts[1]->rx_descriptor_fields1 =
+		*(__vector unsigned char *)rte_mbuf_rx_descriptor_fields1(rx_pkts[1]) =
 			pkt_mb[1];
 
 		pkt_mb[2] = vec_perm(desc[1], zero, shuf_msk1);
@@ -149,9 +149,9 @@
 			((__vector unsigned short)pkt_mb[2] + len_adjust);
 		pkt_mb[3] = (__vector unsigned char)
 			((__vector unsigned short)pkt_mb[3] + len_adjust);
-		*(__vector unsigned char *)&rx_pkts[2]->rx_descriptor_fields1 =
+		*(__vector unsigned char *)rte_mbuf_rx_descriptor_fields1(rx_pkts[2]) =
 			pkt_mb[2];
-		*(__vector unsigned char *)&rx_pkts[3]->rx_descriptor_fields1 =
+		*(__vector unsigned char *)rte_mbuf_rx_descriptor_fields1(rx_pkts[3]) =
 			pkt_mb[3];
 
 		pkt_mb[4] = vec_perm(desc[2], zero, shuf_msk1);
@@ -160,9 +160,9 @@
 			((__vector unsigned short)pkt_mb[4] + len_adjust);
 		pkt_mb[5] = (__vector unsigned char)
 			((__vector unsigned short)pkt_mb[5] + len_adjust);
-		*(__vector unsigned char *)&rx_pkts[4]->rx_descriptor_fields1 =
+		*(__vector unsigned char *)rte_mbuf_rx_descriptor_fields1(rx_pkts[4]) =
 			pkt_mb[4];
-		*(__vector unsigned char *)&rx_pkts[5]->rx_descriptor_fields1 =
+		*(__vector unsigned char *)rte_mbuf_rx_descriptor_fields1(rx_pkts[5]) =
 			pkt_mb[5];
 
 		pkt_mb[6] = vec_perm(desc[3], zero, shuf_msk1);
@@ -171,9 +171,9 @@
 			((__vector unsigned short)pkt_mb[6] + len_adjust);
 		pkt_mb[7] = (__vector unsigned char)
 			((__vector unsigned short)pkt_mb[7] + len_adjust);
-		*(__vector unsigned char *)&rx_pkts[6]->rx_descriptor_fields1 =
+		*(__vector unsigned char *)rte_mbuf_rx_descriptor_fields1(rx_pkts[6]) =
 			pkt_mb[6];
-		*(__vector unsigned char *)&rx_pkts[7]->rx_descriptor_fields1 =
+		*(__vector unsigned char *)rte_mbuf_rx_descriptor_fields1(rx_pkts[7]) =
 			pkt_mb[7];
 
 		if (unlikely(nb_used <= RTE_VIRTIO_DESC_PER_LOOP)) {
drivers/net/virtio/virtio_rxtx_simple_neon.c +8 -16
index 7139b31..873b42c 100644
@@ -138,10 +138,8 @@
 				vreinterpretq_u16_u64(pkt_mb[1]), len_adjust));
 		pkt_mb[0] = vreinterpretq_u64_u16(vsubq_u16(
 				vreinterpretq_u16_u64(pkt_mb[0]), len_adjust));
-		vst1q_u64((void *)&rx_pkts[1]->rx_descriptor_fields1,
-			pkt_mb[1]);
-		vst1q_u64((void *)&rx_pkts[0]->rx_descriptor_fields1,
-			pkt_mb[0]);
+		vst1q_u64(rte_mbuf_rx_descriptor_fields1(rx_pkts[1]), pkt_mb[1]);
+		vst1q_u64(rte_mbuf_rx_descriptor_fields1(rx_pkts[0]), pkt_mb[0]);
 
 		pkt_mb[3] = vreinterpretq_u64_u8(vqtbl1q_u8(
 				vreinterpretq_u8_u64(desc[1]), shuf_msk2));
@@ -151,10 +149,8 @@
 				vreinterpretq_u16_u64(pkt_mb[3]), len_adjust));
 		pkt_mb[2] = vreinterpretq_u64_u16(vsubq_u16(
 				vreinterpretq_u16_u64(pkt_mb[2]), len_adjust));
-		vst1q_u64((void *)&rx_pkts[3]->rx_descriptor_fields1,
-			pkt_mb[3]);
-		vst1q_u64((void *)&rx_pkts[2]->rx_descriptor_fields1,
-			pkt_mb[2]);
+		vst1q_u64(rte_mbuf_rx_descriptor_fields1(rx_pkts[3]), pkt_mb[3]);
+		vst1q_u64(rte_mbuf_rx_descriptor_fields1(rx_pkts[2]), pkt_mb[2]);
 
 		pkt_mb[5] = vreinterpretq_u64_u8(vqtbl1q_u8(
 				vreinterpretq_u8_u64(desc[2]), shuf_msk2));
@@ -164,10 +160,8 @@
 				vreinterpretq_u16_u64(pkt_mb[5]), len_adjust));
 		pkt_mb[4] = vreinterpretq_u64_u16(vsubq_u16(
 				vreinterpretq_u16_u64(pkt_mb[4]), len_adjust));
-		vst1q_u64((void *)&rx_pkts[5]->rx_descriptor_fields1,
-			pkt_mb[5]);
-		vst1q_u64((void *)&rx_pkts[4]->rx_descriptor_fields1,
-			pkt_mb[4]);
+		vst1q_u64(rte_mbuf_rx_descriptor_fields1(rx_pkts[5]), pkt_mb[5]);
+		vst1q_u64(rte_mbuf_rx_descriptor_fields1(rx_pkts[4]), pkt_mb[4]);
 
 		pkt_mb[7] = vreinterpretq_u64_u8(vqtbl1q_u8(
 				vreinterpretq_u8_u64(desc[3]), shuf_msk2));
@@ -177,10 +171,8 @@
 				vreinterpretq_u16_u64(pkt_mb[7]), len_adjust));
 		pkt_mb[6] = vreinterpretq_u64_u16(vsubq_u16(
 				vreinterpretq_u16_u64(pkt_mb[6]), len_adjust));
-		vst1q_u64((void *)&rx_pkts[7]->rx_descriptor_fields1,
-			pkt_mb[7]);
-		vst1q_u64((void *)&rx_pkts[6]->rx_descriptor_fields1,
-			pkt_mb[6]);
+		vst1q_u64(rte_mbuf_rx_descriptor_fields1(rx_pkts[7]), pkt_mb[7]);
+		vst1q_u64(rte_mbuf_rx_descriptor_fields1(rx_pkts[6]), pkt_mb[6]);
 
 		if (unlikely(nb_used <= RTE_VIRTIO_DESC_PER_LOOP)) {
 			if (sw_ring + nb_used <= sw_ring_end)
drivers/net/virtio/virtio_rxtx_simple_sse.c +8 -8
index 6a18741..25db486 100644
@@ -134,36 +134,36 @@
 		pkt_mb[0] = _mm_shuffle_epi8(desc[0], shuf_msk1);
 		pkt_mb[1] = _mm_add_epi16(pkt_mb[1], len_adjust);
 		pkt_mb[0] = _mm_add_epi16(pkt_mb[0], len_adjust);
-		_mm_storeu_si128((void *)&rx_pkts[1]->rx_descriptor_fields1,
+		_mm_storeu_si128(rte_mbuf_rx_descriptor_fields1(rx_pkts[1]),
 			pkt_mb[1]);
-		_mm_storeu_si128((void *)&rx_pkts[0]->rx_descriptor_fields1,
+		_mm_storeu_si128(rte_mbuf_rx_descriptor_fields1(rx_pkts[0]),
 			pkt_mb[0]);
 
 		pkt_mb[3] = _mm_shuffle_epi8(desc[1], shuf_msk2);
 		pkt_mb[2] = _mm_shuffle_epi8(desc[1], shuf_msk1);
 		pkt_mb[3] = _mm_add_epi16(pkt_mb[3], len_adjust);
 		pkt_mb[2] = _mm_add_epi16(pkt_mb[2], len_adjust);
-		_mm_storeu_si128((void *)&rx_pkts[3]->rx_descriptor_fields1,
+		_mm_storeu_si128(rte_mbuf_rx_descriptor_fields1(rx_pkts[3]),
 			pkt_mb[3]);
-		_mm_storeu_si128((void *)&rx_pkts[2]->rx_descriptor_fields1,
+		_mm_storeu_si128(rte_mbuf_rx_descriptor_fields1(rx_pkts[2]),
 			pkt_mb[2]);
 
 		pkt_mb[5] = _mm_shuffle_epi8(desc[2], shuf_msk2);
 		pkt_mb[4] = _mm_shuffle_epi8(desc[2], shuf_msk1);
 		pkt_mb[5] = _mm_add_epi16(pkt_mb[5], len_adjust);
 		pkt_mb[4] = _mm_add_epi16(pkt_mb[4], len_adjust);
-		_mm_storeu_si128((void *)&rx_pkts[5]->rx_descriptor_fields1,
+		_mm_storeu_si128(rte_mbuf_rx_descriptor_fields1(rx_pkts[5]),
 			pkt_mb[5]);
-		_mm_storeu_si128((void *)&rx_pkts[4]->rx_descriptor_fields1,
+		_mm_storeu_si128(rte_mbuf_rx_descriptor_fields1(rx_pkts[4]),
 			pkt_mb[4]);
 
 		pkt_mb[7] = _mm_shuffle_epi8(desc[3], shuf_msk2);
 		pkt_mb[6] = _mm_shuffle_epi8(desc[3], shuf_msk1);
 		pkt_mb[7] = _mm_add_epi16(pkt_mb[7], len_adjust);
 		pkt_mb[6] = _mm_add_epi16(pkt_mb[6], len_adjust);
-		_mm_storeu_si128((void *)&rx_pkts[7]->rx_descriptor_fields1,
+		_mm_storeu_si128(rte_mbuf_rx_descriptor_fields1(rx_pkts[7]),
 			pkt_mb[7]);
-		_mm_storeu_si128((void *)&rx_pkts[6]->rx_descriptor_fields1,
+		_mm_storeu_si128(rte_mbuf_rx_descriptor_fields1(rx_pkts[6]),
 			pkt_mb[6]);
 
 		if (unlikely(nb_used <= RTE_VIRTIO_DESC_PER_LOOP)) {
Signature · 1 line
1.8.3.1
#110 lore raw

PATCH v6 19/23 examples/dma: use mbuf descriptor accessor

In reply to Tyler Retzlaff

RTE_MARKER typedefs are a GCC extension unsupported by MSVC. Use new rte_mbuf_rx_descriptor_fields1 accessor that provides a compatible type pointer without using the marker field.

---
 examples/dma/dmafwd.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
examples/dma/dmafwd.c +3 -2
index f4a0bff..54991f6 100644
@@ -294,9 +294,10 @@ struct dma_bufs {
 pktmbuf_metadata_copy(const struct rte_mbuf *src, struct rte_mbuf *dst)
 {
 	dst->data_off = src->data_off;
-	memcpy(&dst->rx_descriptor_fields1, &src->rx_descriptor_fields1,
+	memcpy(rte_mbuf_rx_descriptor_fields1(dst),
+		rte_mbuf_rx_descriptor_fields1((struct rte_mbuf *)(uintptr_t)src),
 		offsetof(struct rte_mbuf, buf_len) -
-		offsetof(struct rte_mbuf, rx_descriptor_fields1));
+		offsetof(struct rte_mbuf, data_off));
 }
 
 /* Copy packet data */
Signature · 1 line
1.8.3.1
#111 lore raw

PATCH v6 20/23 mbuf: remove and stop using rte marker fields

In reply to Tyler Retzlaff

RTE_MARKER typedefs are a GCC extension unsupported by MSVC. Remove RTE_MARKER fields from rte_mbuf struct.

Maintain alignment of fields after removed cacheline1 marker by placing C11 alignas(RTE_CACHE_LINE_MIN_SIZE).

Update implementation of rte_mbuf_prefetch_part1() and rte_mbuf_prefetch_part2() inline functions calculate pointer for prefetch of cachline0 and cachline1 without using removed markers.

Update static_assert of rte_mbuf struct fields to reference data_off and packet_type fields that occupy the original offsets of the marker fields.

---
 doc/guides/rel_notes/release_24_03.rst |  9 ++++++++
 lib/mbuf/rte_mbuf.h                    |  4 ++--
 lib/mbuf/rte_mbuf_core.h               | 39 +++++++++++++---------------------
 3 files changed, 26 insertions(+), 26 deletions(-)
doc/guides/rel_notes/release_24_03.rst +9 -0
index 879bb49..67750f2 100644
@@ -156,6 +156,15 @@ Removed Items
   The application reserved statically defined logtypes ``RTE_LOGTYPE_USER1..RTE_LOGTYPE_USER8``
   are still defined.
 
+* mbuf: ``RTE_MARKER`` fields ``cacheline0`` ``cacheline1``
+  ``rx_descriptor_fields1`` and ``RTE_MARKER64`` field ``rearm_data``
+  have been removed from ``struct rte_mbuf``.
+  Prefetch of ``cacheline0`` and ``cacheline1`` may be achieved through
+  ``rte_mbuf_prefetch_part1()`` and ``rte_mbuf_prefetch_part2()`` inline
+  functions respectively.
+  Access to ``rearm_data`` and ``rx_descriptor_fields1`` should be
+  through new inline functions ``rte_mbuf_rearm_data()`` and
+  ``rte_mbuf_rx_descriptor_fields1()`` respectively.
 
 API Changes
 -----------
lib/mbuf/rte_mbuf.h +2 -2
index aa7495b..61cda20 100644
@@ -108,7 +108,7 @@
 static inline void
 rte_mbuf_prefetch_part1(struct rte_mbuf *m)
 {
-	rte_prefetch0(&m->cacheline0);
+	rte_prefetch0(m);
 }
 
 /**
@@ -126,7 +126,7 @@
 rte_mbuf_prefetch_part2(struct rte_mbuf *m)
 {
 #if RTE_CACHE_LINE_SIZE == 64
-	rte_prefetch0(&m->cacheline1);
+	rte_prefetch0(RTE_PTR_ADD(m, RTE_CACHE_LINE_MIN_SIZE));
 #else
 	RTE_SET_USED(m);
 #endif
lib/mbuf/rte_mbuf_core.h +15 -24
index 36551c2..4e06f15 100644
@@ -18,6 +18,7 @@
 
 #include <assert.h>
 #include <stddef.h>
+#include <stdalign.h>
 #include <stdint.h>
 
 #include <rte_common.h>
@@ -467,8 +468,6 @@ enum {
  * The generic rte_mbuf, containing a packet mbuf.
  */
 struct rte_mbuf {
-	RTE_MARKER cacheline0;
-
 	void *buf_addr;           /**< Virtual address of segment buffer. */
 #if RTE_IOVA_IN_MBUF
 	/**
@@ -495,7 +494,6 @@ struct rte_mbuf {
 	 * To obtain a pointer to rearm_data use the rte_mbuf_rearm_data()
 	 * accessor instead of directly referencing through the data_off field.
 	 */
-	RTE_MARKER64 rearm_data;
 	uint16_t data_off;
 
 	/**
@@ -522,8 +520,6 @@ struct rte_mbuf {
 	uint64_t ol_flags;        /**< Offload features. */
 
 	/* remaining bytes are set on RX when pulling packet from descriptor */
-	RTE_MARKER rx_descriptor_fields1;
-
 	/*
 	 * The packet type, which is the combination of outer/inner L2, L3, L4
 	 * and tunnel types. The packet_type is about data really present in the
@@ -607,8 +603,7 @@ struct rte_mbuf {
 	struct rte_mempool *pool; /**< Pool from which mbuf was allocated. */
 
 	/* second cache line - fields only used in slow path or on TX */
-	RTE_MARKER cacheline1 __rte_cache_min_aligned;
-
+	alignas(RTE_CACHE_LINE_MIN_SIZE)
 #if RTE_IOVA_IN_MBUF
 	/**
 	 * Next segment of scattered packet. Must be NULL in the last
@@ -677,35 +672,31 @@ struct rte_mbuf {
 } __rte_cache_aligned;
 
 static_assert(!(offsetof(struct rte_mbuf, ol_flags) !=
-	offsetof(struct rte_mbuf, rearm_data) + 8), "ol_flags");
-static_assert(!(offsetof(struct rte_mbuf, rearm_data) !=
-	RTE_ALIGN(offsetof(struct rte_mbuf, rearm_data), 16)), "rearm_data");
+	offsetof(struct rte_mbuf, data_off) + 8), "ol_flags");
 static_assert(!(offsetof(struct rte_mbuf, data_off) !=
-	offsetof(struct rte_mbuf, rearm_data)), "data_off");
-static_assert(!(offsetof(struct rte_mbuf, data_off) <
-	offsetof(struct rte_mbuf, rearm_data)), "data_off");
+	RTE_ALIGN(offsetof(struct rte_mbuf, data_off), 16)), "data_off");
 static_assert(!(offsetof(struct rte_mbuf, refcnt) <
-	offsetof(struct rte_mbuf, rearm_data)), "refcnt");
+	offsetof(struct rte_mbuf, data_off)), "refcnt");
 static_assert(!(offsetof(struct rte_mbuf, nb_segs) <
-	offsetof(struct rte_mbuf, rearm_data)), "nb_segs");
+	offsetof(struct rte_mbuf, data_off)), "nb_segs");
 static_assert(!(offsetof(struct rte_mbuf, port) <
-	offsetof(struct rte_mbuf, rearm_data)), "port");
+	offsetof(struct rte_mbuf, data_off)), "port");
 static_assert(!(offsetof(struct rte_mbuf, data_off) -
-	offsetof(struct rte_mbuf, rearm_data) > 6), "data_off");
+	offsetof(struct rte_mbuf, data_off) > 6), "data_off");
 static_assert(!(offsetof(struct rte_mbuf, refcnt) -
-	offsetof(struct rte_mbuf, rearm_data) > 6), "refcnt");
+	offsetof(struct rte_mbuf, data_off) > 6), "refcnt");
 static_assert(!(offsetof(struct rte_mbuf, nb_segs) -
-	offsetof(struct rte_mbuf, rearm_data) > 6), "nb_segs");
+	offsetof(struct rte_mbuf, data_off) > 6), "nb_segs");
 static_assert(!(offsetof(struct rte_mbuf, port) -
-	offsetof(struct rte_mbuf, rearm_data) > 6), "port");
+	offsetof(struct rte_mbuf, data_off) > 6), "port");
 static_assert(!(offsetof(struct rte_mbuf, pkt_len) !=
-	offsetof(struct rte_mbuf, rx_descriptor_fields1) + 4), "pkt_len");
+	offsetof(struct rte_mbuf, packet_type) + 4), "pkt_len");
 static_assert(!(offsetof(struct rte_mbuf, data_len) !=
-	offsetof(struct rte_mbuf, rx_descriptor_fields1) + 8), "data_len");
+	offsetof(struct rte_mbuf, packet_type) + 8), "data_len");
 static_assert(!(offsetof(struct rte_mbuf, vlan_tci) !=
-	offsetof(struct rte_mbuf, rx_descriptor_fields1) + 10), "vlan_tci");
+	offsetof(struct rte_mbuf, packet_type) + 10), "vlan_tci");
 static_assert(!(offsetof(struct rte_mbuf, hash) !=
-	offsetof(struct rte_mbuf, rx_descriptor_fields1) + 12), "hash");
+	offsetof(struct rte_mbuf, packet_type) + 12), "hash");
 
 /**
  * Function typedef of callback to free externally attached buffer.
Signature · 1 line
1.8.3.1
#112 lore raw

RE: [PATCH v6 20/23] mbuf: remove and stop using rte marker fields

lib/mbuf/rte_mbuf_core.h struct rte_mbuf { · line 606

Quoted 7 lines
lib/mbuf/rte_mbuf_core.h +1 -2
@@ -607,8 +603,7 @@ struct rte_mbuf {
 	struct rte_mempool *pool; /**< Pool from which mbuf was allocated. */
 
 	/* second cache line - fields only used in slow path or on TX */
-	RTE_MARKER cacheline1 __rte_cache_min_aligned;
-
+	alignas(RTE_CACHE_LINE_MIN_SIZE)

This comment is a matter of taste...

The alignas() is too far away from the field it applies to, and might get overlooked. I would prefer it immediately before "struct rte_mbuf *next;" and "uint64_t dynfield2;".

Quoted 3 lines
lib/mbuf/rte_mbuf_core.h +0 -0
 #if RTE_IOVA_IN_MBUF
 	/**
 	 * Next segment of scattered packet. Must be NULL in the last