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

2024-02-24 Thread Tyler Retzlaff
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.

Signed-off-by: Tyler Retzlaff 
---
 lib/eal/include/rte_common.h | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/lib/eal/include/rte_common.h b/lib/eal/include/rte_common.h
index 1cc1222..60d81a2 100644
--- a/lib/eal/include/rte_common.h
+++ b/lib/eal/include/rte_common.h
@@ -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 **/
-- 
1.8.3.1



[PATCH v5 00/22] stop using RTE_MARKER extensions

2024-02-24 Thread 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_s

[PATCH v5 03/22] security: expand rte markers empty when building with MSVC

2024-02-24 Thread 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.

Signed-off-by: Tyler Retzlaff 
---
 lib/security/rte_security_driver.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lib/security/rte_security_driver.h 
b/lib/security/rte_security_driver.h
index faa4074..a25ccd0 100644
--- a/lib/security/rte_security_driver.h
+++ b/lib/security/rte_security_driver.h
@@ -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) */
 };
-- 
1.8.3.1



[PATCH v5 02/22] mbuf: expand rte markers empty when building with MSVC

2024-02-24 Thread 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.

Signed-off-by: Tyler Retzlaff 
---
 lib/mbuf/rte_mbuf_core.h | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/lib/mbuf/rte_mbuf_core.h b/lib/mbuf/rte_mbuf_core.h
index 5688683..4bf4587 100644
--- a/lib/mbuf/rte_mbuf_core.h
+++ b/lib/mbuf/rte_mbuf_core.h
@@ -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
-- 
1.8.3.1



[PATCH v5 04/22] cryptodev: expand rte markers empty when building with MSVC

2024-02-24 Thread 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.

Signed-off-by: Tyler Retzlaff 
---
 lib/cryptodev/cryptodev_pmd.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lib/cryptodev/cryptodev_pmd.h b/lib/cryptodev/cryptodev_pmd.h
index 0732b35..1d4810c 100644
--- a/lib/cryptodev/cryptodev_pmd.h
+++ b/lib/cryptodev/cryptodev_pmd.h
@@ -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 */
-- 
1.8.3.1



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

2024-02-24 Thread Tyler Retzlaff
Update prefetch inline functions to access rte_mbuf struct fields
directly instead of via cacheline{0,1} marker extension fields.

Signed-off-by: Tyler Retzlaff 
---
 lib/mbuf/rte_mbuf.h | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/lib/mbuf/rte_mbuf.h b/lib/mbuf/rte_mbuf.h
index 286b32b..04cde0f 100644
--- a/lib/mbuf/rte_mbuf.h
+++ b/lib/mbuf/rte_mbuf.h
@@ -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
-- 
1.8.3.1



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

2024-02-24 Thread Tyler Retzlaff
Provide inline functions to access rearm data and rx descriptor fields
in rte_mbuf struct.

Signed-off-by: Tyler Retzlaff 
---
 lib/mbuf/rte_mbuf.h | 20 
 1 file changed, 20 insertions(+)

diff --git a/lib/mbuf/rte_mbuf.h b/lib/mbuf/rte_mbuf.h
index 04cde0f..7993730 100644
--- a/lib/mbuf/rte_mbuf.h
+++ b/lib/mbuf/rte_mbuf.h
@@ -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);
 
-- 
1.8.3.1



[PATCH v5 07/22] common/idpf: use mbuf descriptor accessors

2024-02-24 Thread 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.

Signed-off-by: Tyler Retzlaff 
---
 drivers/common/idpf/idpf_common_rxtx.c|  4 +---
 drivers/common/idpf/idpf_common_rxtx_avx512.c | 33 ++-
 2 files changed, 18 insertions(+), 19 deletions(-)

diff --git a/drivers/common/idpf/idpf_common_rxtx.c 
b/drivers/common/idpf/idpf_common_rxtx.c
index 83b131e..62ddf2e 100644
--- a/drivers/common/idpf/idpf_common_rxtx.c
+++ b/drivers/common/idpf/idpf_common_rxtx.c
@@ -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;
 }
 
diff --git a/drivers/common/idpf/idpf_common_rxtx_avx512.c 
b/drivers/common/idpf/idpf_common_rxtx_avx512.c
index f65e8d5..f978a27 100644
--- a/drivers/common/idpf/idpf_common_rxtx_avx512.c
+++ b/drivers/common/idpf/idpf_common_rxtx_avx512.c
@@ -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 */
- 

[PATCH v5 08/22] net/bnxt: use mbuf descriptor accessors

2024-02-24 Thread 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.

Signed-off-by: Tyler Retzlaff 
---
 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(-)

diff --git a/drivers/net/bnxt/bnxt_rxtx_vec_avx2.c 
b/drivers/net/bnxt/bnxt_rxtx_vec_avx2.c
index ce6b597..5982d12 100644
--- a/drivers/net/bnxt/bnxt_rxtx_vec_avx2.c
+++ b/drivers/net/bnxt/bnxt_rxtx_vec_avx2.c
@@ -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;
diff --git a/drivers/net/bnxt/bnxt_rxtx_vec_common.h 
b/drivers/net/bnxt/bnxt_rxtx_vec_common.h
index 2294f0a..fb0b1c1 100644
--- a/drivers/net/bnxt/bnxt_rxtx_vec_common.h
+++ b/drivers/net/bnxt/bnxt_rxtx_vec_common.h
@@ -36,7 +36,6

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

2024-02-24 Thread 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.

Signed-off-by: Tyler Retzlaff 
---
 drivers/net/enic/enic_main.c  |  4 +---
 drivers/net/enic/enic_rxtx_vec_avx2.c | 18 +-
 2 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/drivers/net/enic/enic_main.c b/drivers/net/enic/enic_main.c
index a6aaa76..59e0be4 100644
--- a/drivers/net/enic/enic_main.c
+++ b/drivers/net/enic/enic_main.c
@@ -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);
diff --git a/drivers/net/enic/enic_rxtx_vec_avx2.c 
b/drivers/net/enic/enic_rxtx_vec_avx2.c
index 600efff..f6ab6e1 100644
--- a/drivers/net/enic/enic_rxtx_vec_avx2.c
+++ b/drivers/net/enic/enic_rxtx_vec_avx2.c
@@ -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;
-- 
1.8.3.1



[PATCH v5 09/22] net/cnxk: use mbuf descriptor accessors

2024-02-24 Thread 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.

Signed-off-by: Tyler Retzlaff 
---
 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(-)

diff --git a/drivers/net/cnxk/cn10k_rx.h b/drivers/net/cnxk/cn10k_rx.h
index 7bb4c86..4bfb323 100644
--- a/drivers/net/cnxk/cn10k_rx.h
+++ b/drivers/net/cnxk/cn10k_rx.h
@@ -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 & ~0x;
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 & 0x) - 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 & 0x) -
 (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);
-   vst1

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

2024-02-24 Thread 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.

Signed-off-by: Tyler Retzlaff 
---
 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(-)

diff --git a/drivers/net/iavf/iavf_rxtx_vec_avx2.c 
b/drivers/net/iavf/iavf_rxtx_vec_avx2.c
index 510b4d8..0211e83 100644
--- a/drivers/net/iavf/iavf_rxtx_vec_avx2.c
+++ b/drivers/net/iavf/iavf_rxtx_vec_avx2.c
@@ -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

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

2024-02-24 Thread 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.

Signed-off-by: Tyler Retzlaff 
---
 drivers/net/hns3/hns3_rxtx_vec.c  |  4 +---
 drivers/net/hns3/hns3_rxtx_vec_neon.h | 16 
 2 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/drivers/net/hns3/hns3_rxtx_vec.c b/drivers/net/hns3/hns3_rxtx_vec.c
index 9708ec6..174be45 100644
--- a/drivers/net/hns3/hns3_rxtx_vec.c
+++ b/drivers/net/hns3/hns3_rxtx_vec.c
@@ -113,7 +113,6 @@
 static void
 hns3_rxq_vec_setup_rearm_data(struct hns3_rx_queue *rxq)
 {
-   uintptr_t p;
struct rte_mbuf mb_def = { .buf_addr = 0 }; /* zeroed mbuf */
 
mb_def.nb_segs = 1;
@@ -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
diff --git a/drivers/net/hns3/hns3_rxtx_vec_neon.h 
b/drivers/net/hns3/hns3_rxtx_vec_neon.h
index 0dc6b9f..7b2c3e3 100644
--- a/drivers/net/hns3/hns3_rxtx_vec_neon.h
+++ b/drivers/net/hns3/hns3_rxtx_vec_neon.h
@@ -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);
-- 
1.8.3.1



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

2024-02-24 Thread 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.

Signed-off-by: Tyler Retzlaff 
---
 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(-)

diff --git a/drivers/net/ice/ice_rxtx_vec_avx2.c 
b/drivers/net/ice/ice_rxtx_vec_avx2.c
index 6f6d790..fb3811a 100644
--- a/drivers/net/ice/ice_rxtx_vec_avx2.c
+++ b/drivers/net/ice/ice_rxtx_vec_avx2.c
@@ -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 */
diff --git a/drivers/net/ice/ice_rxtx_vec_avx512.c 
b/drivers/net/ice/ice_rxtx_vec_avx512.c
index 04148e8..46d471f 100644
--- a/drivers/net/ice/ice_rxtx_vec_avx512.c
+++ b/drivers/net/ice/ice_rxtx_vec_avx512.c
@@ -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,
+ 

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

2024-02-24 Thread 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.

Signed-off-by: Tyler Retzlaff 
---
 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(-)

diff --git a/drivers/net/ionic/ionic_lif.c b/drivers/net/ionic/ionic_lif.c
index 93a1011..cec9a38 100644
--- a/drivers/net/ionic/ionic_lif.c
+++ b/drivers/net/ionic/ionic_lif.c
@@ -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
diff --git a/drivers/net/ionic/ionic_rxtx_sg.c 
b/drivers/net/ionic/ionic_rxtx_sg.c
index 92e1d6e..4a6f3c2 100644
--- a/drivers/net/ionic/ionic_rxtx_sg.c
+++ b/drivers/net/ionic/ionic_rxtx_sg.c
@@ -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;
 
diff --git a/drivers/net/ionic/ionic_rxtx_simple.c 
b/drivers/net/ionic/ionic_rxtx_simple.c
index f12f66f..02528e8 100644
--- a/drivers/net/ionic/ionic_rxtx_simple.c
+++ b/drivers/net/ionic/ionic_rxtx_simple.c
@@ -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;
 
-- 
1.8.3.1



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

2024-02-24 Thread 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.

Signed-off-by: Tyler Retzlaff 
---
 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(-)

diff --git a/drivers/net/i40e/i40e_rxtx_vec_altivec.c 
b/drivers/net/i40e/i40e_rxtx_vec_altivec.c
index b6b0d38..3e065ee 100644
--- a/drivers/net/i40e/i40e_rxtx_vec_altivec.c
+++ b/drivers/net/i40e/i40e_rxtx_vec_altivec.c
@@ -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]);
diff --git a/drivers/net/i40e/i40e_rxtx_vec_avx2.c 
b/drivers/net/i40e/i40e_rxtx_vec_avx2.c
index f468c1f..027afbe 100644
--- a/drivers/net/i40e/i40e_rxtx_vec_avx2.c
+++ b/drivers/net/i40e/i40e_rxtx_vec_avx2.c
@@ -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

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

2024-02-24 Thread 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.

Signed-off-by: Tyler Retzlaff 
---
 drivers/net/fm10k/fm10k_rxtx_vec.c | 19 +++
 1 file changed, 7 insertions(+), 12 deletions(-)

diff --git a/drivers/net/fm10k/fm10k_rxtx_vec.c 
b/drivers/net/fm10k/fm10k_rxtx_vec.c
index 2b6914b..e7d3810 100644
--- a/drivers/net/fm10k/fm10k_rxtx_vec.c
+++ b/drivers/net/fm10k/fm10k_rxtx_vec.c
@@ -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]);
-- 
1.8.3.1



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

2024-02-24 Thread 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.

Signed-off-by: Tyler Retzlaff 
---
 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(-)

diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c
index ca2eeed..b854418 100644
--- a/drivers/net/mlx5/mlx5_rxq.c
+++ b/drivers/net/mlx5/mlx5_rxq.c
@@ -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;
diff --git a/drivers/net/mlx5/mlx5_rxtx_vec_altivec.h 
b/drivers/net/mlx5/mlx5_rxtx_vec_altivec.h
index cccfa7f..9349c21 100644
--- a/drivers/net/mlx5/mlx5_rxtx_vec_altivec.h
+++ b/drivers/net/mlx5/mlx5_rxtx_vec_altivec.h
@@ -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]));
 }
 
 /**
diff --gi

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

2024-02-24 Thread 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.

Signed-off-by: Tyler Retzlaff 
---
 drivers/net/sfc/sfc_ef100_rx.c | 4 ++--
 drivers/net/sfc/sfc_ef10_rx.c  | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/net/sfc/sfc_ef100_rx.c b/drivers/net/sfc/sfc_ef100_rx.c
index e283879..3d93a7c 100644
--- a/drivers/net/sfc/sfc_ef100_rx.c
+++ b/drivers/net/sfc/sfc_ef100_rx.c
@@ -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;
diff --git a/drivers/net/sfc/sfc_ef10_rx.c b/drivers/net/sfc/sfc_ef10_rx.c
index 6044293..9c993a3 100644
--- a/drivers/net/sfc/sfc_ef10_rx.c
+++ b/drivers/net/sfc/sfc_ef10_rx.c
@@ -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;
-- 
1.8.3.1



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

2024-02-24 Thread 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.

Signed-off-by: Tyler Retzlaff 
---
 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(-)

diff --git a/drivers/net/ixgbe/ixgbe_rxtx_vec_common.h 
b/drivers/net/ixgbe/ixgbe_rxtx_vec_common.h
index a4d9ec9..78ab168 100644
--- a/drivers/net/ixgbe/ixgbe_rxtx_vec_common.h
+++ b/drivers/net/ixgbe/ixgbe_rxtx_vec_common.h
@@ -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;
 }
 
diff --git a/drivers/net/ixgbe/ixgbe_rxtx_vec_neon.c 
b/drivers/net/ixgbe/ixgbe_rxtx_vec_neon.c
index 952b032..2e1d903 100644
--- a/drivers/net/ixgbe/ixgbe_rxtx_vec_neon.c
+++ b/drivers/net/ixgbe/ixgbe_rxtx_vec_neon.c
@@ -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]);
diff --git a/drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c 
b/drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c
index f60808d..d8de64c 100644
--- a/drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c
+++ b/drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c
@@ -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]->r

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

2024-02-24 Thread 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.

Signed-off-by: Tyler Retzlaff 
---
 drivers/net/thunderx/nicvf_ethdev.c | 4 +---
 drivers/net/thunderx/nicvf_rxtx.h   | 4 ++--
 2 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/net/thunderx/nicvf_ethdev.c 
b/drivers/net/thunderx/nicvf_ethdev.c
index 609d95d..722751c 100644
--- a/drivers/net/thunderx/nicvf_ethdev.c
+++ b/drivers/net/thunderx/nicvf_ethdev.c
@@ -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
diff --git a/drivers/net/thunderx/nicvf_rxtx.h 
b/drivers/net/thunderx/nicvf_rxtx.h
index 4b83e33..7c07cde 100644
--- a/drivers/net/thunderx/nicvf_rxtx.h
+++ b/drivers/net/thunderx/nicvf_rxtx.h
@@ -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);
-- 
1.8.3.1



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

2024-02-24 Thread 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.

Signed-off-by: Tyler Retzlaff 
---
 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(-)

diff --git a/drivers/net/virtio/virtio_rxtx_packed_avx.h 
b/drivers/net/virtio/virtio_rxtx_packed_avx.h
index 584ac72..fc60179 100644
--- a/drivers/net/virtio/virtio_rxtx_packed_avx.h
+++ b/drivers/net/virtio/virtio_rxtx_packed_avx.h
@@ -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]);
}
 
/*
diff --git a/drivers/net/virtio/virtio_rxtx_packed_neon.h 
b/drivers/net/virtio/virtio_rxtx_packed_neon.h
index c222ebf..b33f29a 100644
--- a/drivers/net/virtio/virtio_rxtx_packed_neon.h
+++ b/drivers/net/virtio/virtio_rxtx_packed_neon.h
@@ -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) {
diff --git a/drivers/net/virtio/virtio_rxtx_simple.c 
b/drivers/net/virtio/virtio_rxtx_simple.c
index 4382569..e6a82e5 100644
--- a/drivers/net/virtio/virtio_rxtx_simple.c
+++ b/drivers/net/virtio/virtio_rxtx_simple.c
@@ -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;
 }
diff --git a/drivers/net/virtio/virtio_rxtx_simple.h 
b/drivers/net/virtio/virtio_rxtx_simple.h

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

2024-02-24 Thread 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.

Signed-off-by: Tyler Retzlaff 
---
 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(-)

diff --git a/drivers/net/octeon_ep/cnxk_ep_rx.h 
b/drivers/net/octeon_ep/cnxk_ep_rx.h
index 61263e6..1d706e2 100644
--- a/drivers/net/octeon_ep/cnxk_ep_rx.h
+++ b/drivers/net/octeon_ep/cnxk_ep_rx.h
@@ -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;
}
diff --git a/drivers/net/octeon_ep/cnxk_ep_rx_avx.c 
b/drivers/net/octeon_ep/cnxk_ep_rx_avx.c
index 47eb1d2..3b8241c 100644
--- a/drivers/net/octeon_ep/cnxk_ep_rx_avx.c
+++ b/drivers/net/octeon_ep/cnxk_ep_rx_avx.c
@@ -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];
diff --git a/drivers/net/octeon_ep/cnxk_ep_rx_neon.c 
b/drivers/net/octeon_ep/cnxk_ep_rx_neon.c
index 4c46a7e..8797252 100644
--- a/drivers/net/octeon_ep/cnxk_ep_rx_neon.c
+++ b/drivers/net/octeon_ep/cnxk_ep_rx_neon.c
@@ -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;
diff --git a/drivers/net/octeon_ep/cnxk_ep_rx_sse.c 
b/drivers/net/octeon_ep/cnxk_ep_rx_sse.c
index 308c8b2..1466217 100644
--- a/drivers/net/octeon_ep/cnxk_ep_rx_sse.c
+++ b/drivers/net/octeon_ep/cnxk_ep_rx_sse.c
@@ -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;
diff --git a/drivers/net/octeon_ep/otx_ep_rxtx.c 
b/drivers/net/octeon_ep/otx_ep_rxtx.c
index aea148e..4470599 100644
--- a/drivers/net/octeon_ep/otx_ep_rxtx.c
+++ b/drivers/net/octeon_ep/otx_ep_rxtx.c
@@ -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 */
-- 
1.8.3.1



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

2024-02-24 Thread Morten Brørup
+to: Thomas

> From: Tyler Retzlaff [mailto:roret...@linux.microsoft.com]
> 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.
> 
> 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.

> 
> 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.

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?



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

2024-02-24 Thread Thomas Monjalon
24/02/2024 09:21, Tyler Retzlaff:
> 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.





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

2024-02-24 Thread Thomas Monjalon
24/02/2024 09:21, Tyler Retzlaff:
> Update prefetch inline functions to access rte_mbuf struct fields
> directly instead of via cacheline{0,1} marker extension fields.
> 
> Signed-off-by: Tyler Retzlaff 
[...]
>  rte_mbuf_prefetch_part1(struct rte_mbuf *m)
>  {
> - rte_prefetch0(&m->cacheline0);
> + rte_prefetch0(&m->buf_addr);

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

[...]
>  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

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




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

2024-02-24 Thread Thomas Monjalon
24/02/2024 09:21, Tyler Retzlaff:
> Provide inline functions to access rearm data and rx descriptor fields
> in rte_mbuf struct.
[...]
> +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;
> +}

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




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

2024-02-24 Thread Thomas Monjalon
24/02/2024 11:42, Morten Brørup:
> From: Tyler Retzlaff [mailto:roret...@linux.microsoft.com]
> > 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.
> 
> 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().

> > 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.
> 
> Accessor functions like these are BS for structures that are part of the 
> public API.

What is BS?

> 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.

> 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.

> 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.

> 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




RTE_MARKER with MSVC

2024-02-24 Thread Morten Brørup
Hi Tyler,

Does MSVC permit empty structures, i.e. structures with no fields? Perhaps with 
some additional decoration, a la [[msvc::no_unique_address]].
If so, perhaps that would be a possible workaround for RTE_MARKERs.


Med venlig hilsen / Kind regards,
-Morten Brørup




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

2024-02-24 Thread Thomas Monjalon
24/02/2024 11:51, Thomas Monjalon:
> 24/02/2024 09:21, Tyler Retzlaff:
> > 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.




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

2024-02-24 Thread Morten Brørup
> From: Thomas Monjalon [mailto:tho...@monjalon.net]
> Sent: Saturday, 24 February 2024 12.14
> 
> 24/02/2024 11:42, Morten Brørup:
> > From: Tyler Retzlaff [mailto:roret...@linux.microsoft.com]
> > > 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.
> >
> > 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().
> 
> > > 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.
> >
> > Accessor functions like these are BS for structures that are part of
> the public API.
> 
> What is BS?
> 
> > 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.
> 
> > 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.
> 
> > 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.
> 
> > 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
> 

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. ;-)



A couple of patches for dumpcap

2024-02-24 Thread Isaac Boukris
Hi Stephen,

Please take a look.

Thanks!


dumpcap_fixes.patch
Description: Binary data


[PATCH v1] app/testpmd : return if no packets in GRO heavy weight mode

2024-02-24 Thread Kumara Parameshwaran
If there are no packets flushed in GRO heavy weight mode,
return false as this fall through code would return true
indicating that packets are available

Fixes: 461c287ab553 ("app/testpmd: fix GRO packets flush on timeout")
Cc: sta...@dpdk.org

Signed-off-by: Kumara Parameshwaran 
---
 app/test-pmd/csumonly.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c
index d73f08b2c6..6711dda42e 100644
--- a/app/test-pmd/csumonly.c
+++ b/app/test-pmd/csumonly.c
@@ -1142,6 +1142,8 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
gro_pkts_num);
fs->gro_times = 0;
}
+   if (nb_rx == 0)
+   return false;
}
 
pkts_ip_csum_recalc(pkts_burst, nb_rx, tx_offloads);
-- 
2.25.1