add diagnostics macros to make code portable
PATCH v14 3/3 drivers/net: add diagnostics macros to make code portable
In reply to Andre MuezerieIt was a common pattern to have "GCC diagnostic ignored" pragmas sprinkled over the code and only activate these pragmas for certain compilers (gcc and clang). Clang supports GCC's pragma for compatibility with existing source code, so #pragma GCC diagnostic and #pragma clang diagnostic are synonyms for Clang
(https://clang.llvm.org/docs/UsersManual.html).
Now that effort is being made to make the code compatible with MSVC these expressions would become more complex. It makes sense to hide this complexity behind macros. This makes maintenance easier as these macros are defined in a single place. As a plus the code becomes more readable as well.
--- drivers/net/axgbe/axgbe_rxtx.h | 9 --- drivers/net/cpfl/cpfl_rxtx_vec_common.h | 4 - drivers/net/dpaa2/dpaa2_rxtx.c | 15 +--- drivers/net/fm10k/fm10k_rxtx_vec.c | 21 ++---- drivers/net/hns3/hns3_rxtx_vec_neon.h | 6 +- .../net/i40e/i40e_recycle_mbufs_vec_common.c | 2 - drivers/net/i40e/i40e_rxtx_common_avx.h | 22 +++--- drivers/net/i40e/i40e_rxtx_vec_altivec.c | 18 ++--- drivers/net/i40e/i40e_rxtx_vec_avx2.c | 30 ++++---- drivers/net/i40e/i40e_rxtx_vec_avx512.c | 28 +++---- drivers/net/i40e/i40e_rxtx_vec_common.h | 4 - drivers/net/i40e/i40e_rxtx_vec_neon.c | 35 ++++----- drivers/net/i40e/i40e_rxtx_vec_sse.c | 28 +++---- drivers/net/iavf/iavf_rxtx_vec_avx2.c | 60 +++++++-------- drivers/net/iavf/iavf_rxtx_vec_avx512.c | 62 ++++++++-------- drivers/net/iavf/iavf_rxtx_vec_common.h | 10 +-- drivers/net/iavf/iavf_rxtx_vec_neon.c | 22 +++--- drivers/net/iavf/iavf_rxtx_vec_sse.c | 38 +++++----- drivers/net/ice/ice_rxtx_common_avx.h | 18 ++--- drivers/net/ice/ice_rxtx_vec_avx2.c | 74 +++++++++---------- drivers/net/ice/ice_rxtx_vec_avx512.c | 64 +++++++--------- drivers/net/ice/ice_rxtx_vec_common.h | 4 - drivers/net/ice/ice_rxtx_vec_sse.c | 28 +++---- drivers/net/idpf/idpf_rxtx_vec_common.h | 4 - .../ixgbe/ixgbe_recycle_mbufs_vec_common.c | 2 - drivers/net/ixgbe/ixgbe_rxtx_vec_neon.c | 18 ++--- drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c | 20 ++--- drivers/net/mlx5/mlx5_flow.c | 5 +- drivers/net/mlx5/mlx5_rxtx_vec_altivec.h | 5 -- drivers/net/mlx5/mlx5_rxtx_vec_neon.h | 18 ++--- drivers/net/mlx5/mlx5_rxtx_vec_sse.h | 61 ++++++++------- drivers/net/ngbe/ngbe_rxtx_vec_neon.c | 8 +- drivers/net/tap/tap_flow.c | 6 +- drivers/net/txgbe/txgbe_rxtx_vec_neon.c | 8 +- drivers/net/virtio/virtio_rxtx_simple.c | 4 - 35 files changed, 316 insertions(+), 445 deletions(-)
drivers/net/axgbe/axgbe_rxtx.h +0 -9
@@ -6,15 +6,6 @@#ifndef _AXGBE_RXTX_H_#define _AXGBE_RXTX_H_ -/* to suppress gcc warnings related to descriptor casting*/ -#ifdef RTE_TOOLCHAIN_GCC -#pragma GCC diagnostic ignored "-Wcast-qual" -#endif - -#ifdef RTE_TOOLCHAIN_CLANG -#pragma GCC diagnostic ignored "-Wcast-qual" -#endif -/* Descriptor related defines */ #define AXGBE_MAX_RING_DESC 4096/*should be power of 2*/ #define AXGBE_TX_DESC_MIN_FREE (AXGBE_MAX_RING_DESC >> 3)
drivers/net/cpfl/cpfl_rxtx_vec_common.h +0 -4
@@ -11,10 +11,6 @@#include "cpfl_ethdev.h" #include "cpfl_rxtx.h" -#ifndef __INTEL_COMPILER -#pragma GCC diagnostic ignored "-Wcast-qual" -#endif -#define CPFL_SCALAR_PATH 0#define CPFL_VECTOR_PATH 1#define CPFL_RX_NO_VECTOR_FLAGS ( \
drivers/net/dpaa2/dpaa2_rxtx.c +1 -14
@@ -1962,14 +1962,6 @@ dpaa2_dev_tx_ordered(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)return num_tx; } -#if defined(RTE_TOOLCHAIN_GCC ) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wcast-qual" -#elif defined(RTE_TOOLCHAIN_CLANG ) -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wcast-qual" -#endif -/* This function loopbacks all the received packets.*/ uint16_t dpaa2_dev_loopback_rx(void *queue,
@@ -2083,7 +2075,7 @@ dpaa2_dev_loopback_rx(void *queue,if (unlikely ((status &QBMAN_DQ_STAT_VALIDFRAME ) ==0 ))continue ; } - fd[num_rx] = (struct qbman_fd *)qbman_result_DQ_fd (dq_storage); + fd[num_rx] =RTE_PTR_UNQUAL (qbman_result_DQ_fd (dq_storage)); dq_storage++; num_rx++;
@@ -2118,8 +2110,3 @@ dpaa2_dev_loopback_rx(void *queue,return 0 ; } -#if defined(RTE_TOOLCHAIN_GCC ) -#pragma GCC diagnostic pop -#elif defined(RTE_TOOLCHAIN_CLANG ) -#pragma clang diagnostic pop -#endif
drivers/net/fm10k/fm10k_rxtx_vec.c +8 -13
@@ -11,10 +11,6 @@#include <rte_vect.h> -#ifndef __INTEL_COMPILER -#pragma GCC diagnostic ignored "-Wcast-qual" -#endif -static void fm10k_reset_tx_queue (struct fm10k_tx_queue *txq);
@@ -270,8 +266,7 @@ fm10k_rxq_rearm(struct fm10k_rx_queue *rxq)/* Clean up all the HW/SW ring content */ for (i =0 ; i <RTE_FM10K_RXQ_REARM_THRESH ; i++) { mb_alloc[i] = &rxq->fake_mbuf; -_mm_store_si128 ((__m128i *)&rxdp[i].q, - dma_addr0); + _mm_store_si128(RTE_CAST_PTR(__m128i *, &rxdp[i].q), dma_addr0); } rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
@@ -316,8 +311,8 @@ fm10k_rxq_rearm(struct fm10k_rx_queue *rxq) dma_addr1 =_mm_and_si128 (dma_addr1, hba_msk);/* flush desc with pa dma_addr */ -_mm_store_si128 ((__m128i *)&rxdp++->q, dma_addr0); -_mm_store_si128 ((__m128i *)&rxdp++->q, dma_addr1); + _mm_store_si128(RTE_CAST_PTR(__m128i *, &rxdp++->q), dma_addr0); + _mm_store_si128(RTE_CAST_PTR(__m128i *, &rxdp++->q), dma_addr1);/* enforce 512B alignment on default Rx virtual addresses */ mb0->data_off = (uint16_t)(RTE_PTR_ALIGN((char *)mb0->buf_addr
@@ -465,7 +460,7 @@ fm10k_recv_raw_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,/* Read desc statuses backwards to avoid race condition */ /* A.1 load desc[3] */ - descs0[3 ] =_mm_loadu_si128 ((__m128i *)(rxdp +3 )); + descs0[3] = _mm_loadu_si128(RTE_CAST_PTR(__m128i *, rxdp + 3));rte_compiler_barrier ();/* B.2 copy 2 64 bit or 4 32 bit mbuf point into rx_pkts */
@@ -477,11 +472,11 @@ fm10k_recv_raw_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,#endif /* A.1 load desc[2-0] */ - descs0[2 ] =_mm_loadu_si128 ((__m128i *)(rxdp +2 )); + descs0[2] = _mm_loadu_si128(RTE_CAST_PTR(__m128i *, rxdp + 2));rte_compiler_barrier (); - descs0[1 ] =_mm_loadu_si128 ((__m128i *)(rxdp +1 )); + descs0[1] = _mm_loadu_si128(RTE_CAST_PTR(__m128i *, rxdp + 1));rte_compiler_barrier (); - descs0[0 ] =_mm_loadu_si128 ((__m128i *)(rxdp)); + descs0[0] = _mm_loadu_si128(RTE_CAST_PTR(__m128i *, rxdp));#if defined(RTE_ARCH_X86_64 )/* B.2 copy 2 mbuf point into rx_pkts */
@@ -736,7 +731,7 @@ vtx1(volatile struct fm10k_tx_desc *txdp,__m128i descriptor =_mm_set_epi64x (flags <<56 | (uint64_t )pkt->vlan_tci <<16 | (uint64_t )pkt->data_len,MBUF_DMA_ADDR (pkt)); -_mm_store_si128 ((__m128i *)txdp, descriptor); + _mm_store_si128(RTE_CAST_PTR(__m128i *, txdp), descriptor); } static inline void
drivers/net/hns3/hns3_rxtx_vec_neon.h +2 -4
@@ -9,8 +9,6 @@#include <arm_neon.h> -#pragma GCC diagnostic ignored "-Wcast-qual" -static inline void hns3_vec_tx (volatile struct hns3_desc *desc,struct rte_mbuf *pkt) {
@@ -22,8 +20,8 @@ hns3_vec_tx(volatile struct hns3_desc *desc, struct rte_mbuf *pkt)0 , ((uint64_t )HNS3_TXD_DEFAULT_VLD_FE_BDTYPE ) <<HNS3_UINT32_BIT }; -vst1q_u64 ((uint64_t *)&desc->addr, val1); -vst1q_u64 ((uint64_t *)&desc->tx.outer_vlan_tag, val2); + vst1q_u64(RTE_CAST_PTR(uint64_t *, &desc->addr), val1); + vst1q_u64(RTE_CAST_PTR(uint64_t *, &desc->tx.outer_vlan_tag), val2); } static uint16_t
drivers/net/i40e/i40e_recycle_mbufs_vec_common.c +0 -2
@@ -10,8 +10,6 @@#include "i40e_ethdev.h" #include "i40e_rxtx.h" -#pragma GCC diagnostic ignored "-Wcast-qual" -void i40e_recycle_rx_descriptors_refill_vec (void *rx_queue,uint16_t nb_mbufs) {
drivers/net/i40e/i40e_rxtx_common_avx.h +11 -11
@@ -11,10 +11,6 @@#include "i40e_ethdev.h" #include "i40e_rxtx.h" -#ifndef __INTEL_COMPILER -#pragma GCC diagnostic ignored "-Wcast-qual" -#endif -#ifdef __AVX2__ static __rte_always_inline void i40e_rxq_rearm_common(struct i40e_rx_queue *rxq, __rte_unused bool avx512)
@@ -36,7 +32,7 @@ i40e_rxq_rearm_common(struct i40e_rx_queue *rxq, __rte_unused bool avx512) dma_addr0 =_mm_setzero_si128 ();for (i =0 ; i <RTE_I40E_DESCS_PER_LOOP ; i++) { rxep[i].mbuf = &rxq->fake_mbuf; -_mm_store_si128 ((__m128i *)&rxdp[i].read, + _mm_store_si128(RTE_CAST_PTR(__m128i *, &rxdp[i].read), dma_addr0); } }
@@ -72,8 +68,8 @@ i40e_rxq_rearm_common(struct i40e_rx_queue *rxq, __rte_unused bool avx512) dma_addr1 =_mm_add_epi64 (dma_addr1, hdr_room);/* flush desc with pa dma_addr */ -_mm_store_si128 ((__m128i *)&rxdp++->read, dma_addr0); - _mm_store_si128((__m128i *)&rxdp++->read, dma_addr1); + _mm_store_si128(RTE_CAST_PTR(__m128i *, &rxdp++->read), dma_addr0); + _mm_store_si128(RTE_CAST_PTR(__m128i *, &rxdp++->read), dma_addr1); }#else #ifdef __AVX512VL__
@@ -144,8 +140,10 @@ i40e_rxq_rearm_common(struct i40e_rx_queue *rxq, __rte_unused bool avx512) dma_addr4_7 =_mm512_add_epi64 (dma_addr4_7, hdr_room);/* flush desc with pa dma_addr */ -_mm512_store_si512 ((__m512i *)&rxdp->read, dma_addr0_3); - _mm512_store_si512((__m512i *)&(rxdp + 4)->read, dma_addr4_7); + _mm512_store_si512(RTE_CAST_PTR(__m512i *, + &rxdp->read), dma_addr0_3); + _mm512_store_si512(RTE_CAST_PTR(__m512i *, + &(rxdp + 4)->read), dma_addr4_7); } } else#endif /* __AVX512VL__*/
@@ -190,8 +188,10 @@ i40e_rxq_rearm_common(struct i40e_rx_queue *rxq, __rte_unused bool avx512) dma_addr2_3 =_mm256_add_epi64 (dma_addr2_3, hdr_room);/* flush desc with pa dma_addr */ -_mm256_store_si256 ((__m256i *)&rxdp->read, dma_addr0_1); -_mm256_store_si256 ((__m256i *)&(rxdp +2 )->read, dma_addr2_3); + _mm256_store_si256(RTE_CAST_PTR(__m256i *, + &rxdp->read), dma_addr0_1); + _mm256_store_si256(RTE_CAST_PTR(__m256i *, + &(rxdp + 2)->read), dma_addr2_3); } }
drivers/net/i40e/i40e_rxtx_vec_altivec.c +8 -10
@@ -15,8 +15,6 @@#include <rte_altivec.h> -#pragma GCC diagnostic ignored "-Wcast-qual" -static inline void i40e_rxq_rearm (struct i40e_rx_queue *rxq) {
@@ -44,7 +42,7 @@ i40e_rxq_rearm(struct i40e_rx_queue *rxq)for (i =0 ; i <RTE_I40E_DESCS_PER_LOOP ; i++) { rxep[i].mbuf = &rxq->fake_mbuf;vec_st (dma_addr0,0 , - (__vector unsigned long *)&rxdp[i].read); + RTE_CAST_PTR(__vector unsigned long *, &rxdp[i].read)); } } rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
@@ -84,8 +82,8 @@ i40e_rxq_rearm(struct i40e_rx_queue *rxq) dma_addr1 =vec_add (dma_addr1, hdr_room);/* flush desc with pa dma_addr */ -vec_st (dma_addr0,0 , (__vector unsigned long *)&rxdp++->read); -vec_st (dma_addr1,0 , (__vector unsigned long *)&rxdp++->read); + vec_st(dma_addr0, 0, RTE_CAST_PTR(__vector unsigned long *, &rxdp++->read)); + vec_st(dma_addr1, 0, RTE_CAST_PTR(__vector unsigned long *, &rxdp++->read)); } rxq->rxrearm_start +=RTE_I40E_RXQ_REARM_THRESH ;
@@ -286,7 +284,7 @@ _recv_raw_pkts_vec(struct i40e_rx_queue *rxq, struct rte_mbuf **rx_pkts, mbp1 = *(__vector unsigned long *)&sw_ring[pos];/* Read desc statuses backwards to avoid race condition */ /* A.1 load desc[3] */ - descs[3 ] = *(__vector unsigned long *)(rxdp +3 ); + descs[3] = *RTE_CAST_PTR(__vector unsigned long *, rxdp + 3);rte_compiler_barrier ();/* B.2 copy 2 mbuf point into rx_pkts */
@@ -296,11 +294,11 @@ _recv_raw_pkts_vec(struct i40e_rx_queue *rxq, struct rte_mbuf **rx_pkts, mbp2 = *(__vector unsigned long *)&sw_ring[pos +2 ];/* A.1 load desc[2-0] */ - descs[2 ] = *(__vector unsigned long *)(rxdp +2 ); + descs[2] = *RTE_CAST_PTR(__vector unsigned long *, rxdp + 2);rte_compiler_barrier (); - descs[1 ] = *(__vector unsigned long *)(rxdp +1 ); + descs[1] = *RTE_CAST_PTR(__vector unsigned long *, rxdp + 1);rte_compiler_barrier (); - descs[0 ] = *(__vector unsigned long *)(rxdp); + descs[0] = *RTE_CAST_PTR(__vector unsigned long *, rxdp);/* B.2 copy 2 mbuf point into rx_pkts */ *(__vector unsigned long *)&rx_pkts[pos +2 ] = mbp2;
@@ -534,7 +532,7 @@ vtx1(volatile struct i40e_tx_desc *txdp,__vector unsigned long descriptor = (__vector unsigned long ){ pkt->buf_iova + pkt->data_off, high_qw}; - *(__vector unsigned long *)txdp = descriptor; + *RTE_CAST_PTR(__vector unsigned long *, txdp) = descriptor; } static inline void
drivers/net/i40e/i40e_rxtx_vec_avx2.c +13 -17
@@ -15,10 +15,6 @@#include <rte_vect.h> -#ifndef __INTEL_COMPILER -#pragma GCC diagnostic ignored "-Wcast-qual" -#endif - static __rte_always_inline voidi40e_rxq_rearm (struct i40e_rx_queue *rxq) {
@@ -39,8 +35,8 @@ desc_fdir_processing_32b(volatile union i40e_rx_desc *rxdp, const uint32_t desc_idx) {/* 32B desc path: load rxdp.wb.qword2 for EXT_STATUS and FLEXBH_STAT */ -__m128i *rxdp_desc_0 = (void *)(&rxdp[desc_idx +0 ].wb.qword2); -__m128i *rxdp_desc_1 = (void *)(&rxdp[desc_idx +1 ].wb.qword2); + __m128i *rxdp_desc_0 = RTE_CAST_PTR(__m128i *, &rxdp[desc_idx + 0].wb.qword2); + __m128i *rxdp_desc_1 = RTE_CAST_PTR(__m128i *, &rxdp[desc_idx + 1].wb.qword2);const __m128i desc_qw2_0 =_mm_load_si128 (rxdp_desc_0);const __m128i desc_qw2_1 =_mm_load_si128 (rxdp_desc_1);
@@ -276,21 +272,21 @@ _recv_raw_pkts_vec_avx2(struct i40e_rx_queue *rxq, struct rte_mbuf **rx_pkts, _mm256_loadu_si256((void *)&sw_ring[i + 4]));#endif -const __m128i raw_desc7 =_mm_load_si128 ((void *)(rxdp +7 )); + const __m128i raw_desc7 = _mm_load_si128(RTE_CAST_PTR(const __m128i *, rxdp + 7));rte_compiler_barrier (); -const __m128i raw_desc6 =_mm_load_si128 ((void *)(rxdp +6 )); + const __m128i raw_desc6 = _mm_load_si128(RTE_CAST_PTR(const __m128i *, rxdp + 6));rte_compiler_barrier (); -const __m128i raw_desc5 =_mm_load_si128 ((void *)(rxdp +5 )); + const __m128i raw_desc5 = _mm_load_si128(RTE_CAST_PTR(const __m128i *, rxdp + 5));rte_compiler_barrier (); -const __m128i raw_desc4 =_mm_load_si128 ((void *)(rxdp +4 )); + const __m128i raw_desc4 = _mm_load_si128(RTE_CAST_PTR(const __m128i *, rxdp + 4));rte_compiler_barrier (); -const __m128i raw_desc3 =_mm_load_si128 ((void *)(rxdp +3 )); + const __m128i raw_desc3 = _mm_load_si128(RTE_CAST_PTR(const __m128i *, rxdp + 3));rte_compiler_barrier (); -const __m128i raw_desc2 =_mm_load_si128 ((void *)(rxdp +2 )); + const __m128i raw_desc2 = _mm_load_si128(RTE_CAST_PTR(const __m128i *, rxdp + 2));rte_compiler_barrier (); -const __m128i raw_desc1 =_mm_load_si128 ((void *)(rxdp +1 )); + const __m128i raw_desc1 = _mm_load_si128(RTE_CAST_PTR(const __m128i *, rxdp + 1));rte_compiler_barrier (); -const __m128i raw_desc0 =_mm_load_si128 ((void *)(rxdp +0 )); + const __m128i raw_desc0 = _mm_load_si128(RTE_CAST_PTR(const __m128i *, rxdp + 0));const __m256i raw_desc6_7 =_mm256_inserti128_si256 (_mm256_castsi128_si256 (raw_desc6), raw_desc7,1 );
@@ -695,7 +691,7 @@ vtx1(volatile struct i40e_tx_desc *txdp,__m128i descriptor =_mm_set_epi64x (high_qw, pkt->buf_iova + pkt->data_off); -_mm_store_si128 ((__m128i *)txdp, descriptor); + _mm_store_si128(RTE_CAST_PTR(__m128i *, txdp), descriptor); } static inline void
@@ -728,8 +724,8 @@ vtx(volatile struct i40e_tx_desc *txdp,__m256i desc0_1 =_mm256_set_epi64x ( hi_qw1, pkt[1 ]->buf_iova + pkt[1 ]->data_off, hi_qw0, pkt[0 ]->buf_iova + pkt[0 ]->data_off); -_mm256_store_si256 ((void *)(txdp +2 ), desc2_3); -_mm256_store_si256 ((void *)txdp, desc0_1); + _mm256_store_si256(RTE_CAST_PTR(__m256i *, txdp + 2), desc2_3); + _mm256_store_si256(RTE_CAST_PTR(__m256i *, txdp), desc0_1); }/* do any last ones */
drivers/net/i40e/i40e_rxtx_vec_avx512.c +12 -16
@@ -15,10 +15,6 @@#include <rte_vect.h> -#ifndef __INTEL_COMPILER -#pragma GCC diagnostic ignored "-Wcast-qual" -#endif -#define RTE_I40E_DESCS_PER_LOOP_AVX 8static __rte_always_inline void
@@ -41,8 +37,8 @@ desc_fdir_processing_32b(volatile union i40e_rx_desc *rxdp, const uint32_t desc_idx) {/* 32B desc path: load rxdp.wb.qword2 for EXT_STATUS and FLEXBH_STAT */ -__m128i *rxdp_desc_0 = (void *)(&rxdp[desc_idx +0 ].wb.qword2); -__m128i *rxdp_desc_1 = (void *)(&rxdp[desc_idx +1 ].wb.qword2); + __m128i *rxdp_desc_0 = RTE_CAST_PTR(__m128i *, &rxdp[desc_idx + 0].wb.qword2); + __m128i *rxdp_desc_1 = RTE_CAST_PTR(__m128i *, &rxdp[desc_idx + 1].wb.qword2);const __m128i desc_qw2_0 =_mm_load_si128 (rxdp_desc_0);const __m128i desc_qw2_1 =_mm_load_si128 (rxdp_desc_1);
@@ -264,28 +260,28 @@ _recv_raw_pkts_vec_avx512(struct i40e_rx_queue *rxq, struct rte_mbuf **rx_pkts,/* load in descriptors, in reverse order */ const __m128i raw_desc7 = -_mm_load_si128 ((void *)(rxdp +7 )); + _mm_load_si128(RTE_CAST_PTR(const __m128i *, rxdp + 7));rte_compiler_barrier ();const __m128i raw_desc6 = -_mm_load_si128 ((void *)(rxdp +6 )); + _mm_load_si128(RTE_CAST_PTR(const __m128i *, rxdp + 6));rte_compiler_barrier ();const __m128i raw_desc5 = -_mm_load_si128 ((void *)(rxdp +5 )); + _mm_load_si128(RTE_CAST_PTR(const __m128i *, rxdp + 5));rte_compiler_barrier ();const __m128i raw_desc4 = -_mm_load_si128 ((void *)(rxdp +4 )); + _mm_load_si128(RTE_CAST_PTR(const __m128i *, rxdp + 4));rte_compiler_barrier ();const __m128i raw_desc3 = -_mm_load_si128 ((void *)(rxdp +3 )); + _mm_load_si128(RTE_CAST_PTR(const __m128i *, rxdp + 3));rte_compiler_barrier ();const __m128i raw_desc2 = -_mm_load_si128 ((void *)(rxdp +2 )); + _mm_load_si128(RTE_CAST_PTR(const __m128i *, rxdp + 2));rte_compiler_barrier ();const __m128i raw_desc1 = -_mm_load_si128 ((void *)(rxdp +1 )); + _mm_load_si128(RTE_CAST_PTR(const __m128i *, rxdp + 1));rte_compiler_barrier ();const __m128i raw_desc0 = -_mm_load_si128 ((void *)(rxdp +0 )); + _mm_load_si128(RTE_CAST_PTR(const __m128i *, rxdp + 0)); raw_desc6_7 = _mm256_inserti128_si256
@@ -875,7 +871,7 @@ vtx1(volatile struct i40e_tx_desc *txdp, struct rte_mbuf *pkt, uint64_t flags)__m128i descriptor =_mm_set_epi64x (high_qw, pkt->buf_iova + pkt->data_off); -_mm_store_si128 ((__m128i *)txdp, descriptor); + _mm_store_si128(RTE_CAST_PTR(__m128i *, txdp), descriptor); } static inline void
@@ -909,7 +905,7 @@ vtx(volatile struct i40e_tx_desc *txdp, hi_qw2, pkt[2 ]->buf_iova + pkt[2 ]->data_off, hi_qw1, pkt[1 ]->buf_iova + pkt[1 ]->data_off, hi_qw0, pkt[0]->buf_iova + pkt[0]->data_off); -_mm512_storeu_si512 ((void *)txdp, desc0_3); + _mm512_storeu_si512(RTE_CAST_PTR(void *, txdp), desc0_3); }/* do any last ones */
drivers/net/i40e/i40e_rxtx_vec_common.h +0 -4
@@ -11,10 +11,6 @@#include "i40e_ethdev.h" #include "i40e_rxtx.h" -#ifndef __INTEL_COMPILER -#pragma GCC diagnostic ignored "-Wcast-qual" -#endif -static inline uint16_t reassemble_packets (struct i40e_rx_queue *rxq,struct rte_mbuf **rx_bufs,uint16_t nb_bufs,uint8_t *split_flags)
drivers/net/i40e/i40e_rxtx_vec_neon.c +16 -19
@@ -16,9 +16,6 @@#include "i40e_rxtx.h" #include "i40e_rxtx_vec_common.h" - -#pragma GCC diagnostic ignored "-Wcast-qual" -static inline void i40e_rxq_rearm (struct i40e_rx_queue *rxq) {
@@ -41,7 +38,7 @@ i40e_rxq_rearm(struct i40e_rx_queue *rxq) rxq->nb_rx_desc) {for (i =0 ; i <RTE_I40E_DESCS_PER_LOOP ; i++) { rxep[i].mbuf = &rxq->fake_mbuf; -vst1q_u64 ((uint64_t *)&rxdp[i].read, zero); + vst1q_u64(RTE_CAST_PTR(uint64_t *, &rxdp[i].read), zero); } } rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
@@ -58,11 +55,11 @@ i40e_rxq_rearm(struct i40e_rx_queue *rxq) dma_addr0 =vdupq_n_u64 (paddr);/* flush desc with pa dma_addr */ -vst1q_u64 ((uint64_t *)&rxdp++->read, dma_addr0); + vst1q_u64(RTE_CAST_PTR(uint64_t *, &rxdp++->read), dma_addr0); paddr = mb1->buf_iova +RTE_PKTMBUF_HEADROOM ; dma_addr1 =vdupq_n_u64 (paddr); -vst1q_u64 ((uint64_t *)&rxdp++->read, dma_addr1); + vst1q_u64(RTE_CAST_PTR(uint64_t *, &rxdp++->read), dma_addr1); } rxq->rxrearm_start +=RTE_I40E_RXQ_REARM_THRESH ;
@@ -87,10 +84,10 @@ descs_to_fdir_32b(volatile union i40e_rx_desc *rxdp, struct rte_mbuf **rx_pkt) {/* 32B descriptors: Load 2nd half of descriptors for FDIR ID data */ uint64x2_t desc0_qw23, desc1_qw23, desc2_qw23, desc3_qw23; - desc0_qw23 =vld1q_u64 ((uint64_t *)&(rxdp +0 )->wb.qword2); - desc1_qw23 =vld1q_u64 ((uint64_t *)&(rxdp +1 )->wb.qword2); - desc2_qw23 =vld1q_u64 ((uint64_t *)&(rxdp +2 )->wb.qword2); - desc3_qw23 =vld1q_u64 ((uint64_t *)&(rxdp +3 )->wb.qword2); + desc0_qw23 = vld1q_u64(RTE_CAST_PTR(uint64_t *, &(rxdp + 0)->wb.qword2)); + desc1_qw23 = vld1q_u64(RTE_CAST_PTR(uint64_t *, &(rxdp + 1)->wb.qword2)); + desc2_qw23 = vld1q_u64(RTE_CAST_PTR(uint64_t *, &(rxdp + 2)->wb.qword2)); + desc3_qw23 = vld1q_u64(RTE_CAST_PTR(uint64_t *, &(rxdp + 3)->wb.qword2));/* FDIR ID data: move last u32 of each desc to 4 u32 lanes */ uint32x4_t v_unpack_02, v_unpack_13;
@@ -421,18 +418,18 @@ _recv_raw_pkts_vec(struct i40e_rx_queue *__rte_restrict rxq,int32x4_t len_shl = {0 ,0 ,0 ,PKTLEN_SHIFT };/* A.1 load desc[3-0] */ - descs[3 ] =vld1q_u64 ((uint64_t *)(rxdp +3 )); - descs[2 ] =vld1q_u64 ((uint64_t *)(rxdp +2 )); - descs[1 ] =vld1q_u64 ((uint64_t *)(rxdp +1 )); - descs[0 ] =vld1q_u64 ((uint64_t *)(rxdp)); + descs[3] = vld1q_u64(RTE_CAST_PTR(uint64_t *, rxdp + 3)); + descs[2] = vld1q_u64(RTE_CAST_PTR(uint64_t *, rxdp + 2)); + descs[1] = vld1q_u64(RTE_CAST_PTR(uint64_t *, rxdp + 1)); + descs[0] = vld1q_u64(RTE_CAST_PTR(uint64_t *, rxdp));/* Use acquire fence to order loads of descriptor qwords */ rte_atomic_thread_fence (rte_memory_order_acquire);/* A.2 reload qword0 to make it ordered after qword1 load */ - descs[3 ] =vld1q_lane_u64 ((uint64_t *)(rxdp +3 ), descs[3 ],0 ); - descs[2 ] =vld1q_lane_u64 ((uint64_t *)(rxdp +2 ), descs[2 ],0 ); - descs[1 ] =vld1q_lane_u64 ((uint64_t *)(rxdp +1 ), descs[1 ],0 ); - descs[0 ] =vld1q_lane_u64 ((uint64_t *)(rxdp), descs[0 ],0 ); + descs[3] = vld1q_lane_u64(RTE_CAST_PTR(uint64_t *, rxdp + 3), descs[3], 0); + descs[2] = vld1q_lane_u64(RTE_CAST_PTR(uint64_t *, rxdp + 2), descs[2], 0); + descs[1] = vld1q_lane_u64(RTE_CAST_PTR(uint64_t *, rxdp + 1), descs[1], 0); + descs[0] = vld1q_lane_u64(RTE_CAST_PTR(uint64_t *, rxdp), descs[0], 0);/* B.1 load 4 mbuf point */ mbp1 =vld1q_u64 ((uint64_t *)&sw_ring[pos]);
@@ -662,7 +659,7 @@ vtx1(volatile struct i40e_tx_desc *txdp, ((uint64_t)pkt->data_len << I40E_TXD_QW1_TX_BUF_SZ_SHIFT));uint64x2_t descriptor = {pkt->buf_iova + pkt->data_off, high_qw}; -vst1q_u64 ((uint64_t *)txdp, descriptor); + vst1q_u64(RTE_CAST_PTR(uint64_t *, txdp), descriptor); } static inline void
drivers/net/i40e/i40e_rxtx_vec_sse.c +12 -16
@@ -14,10 +14,6 @@#include <rte_vect.h> -#ifndef __INTEL_COMPILER -#pragma GCC diagnostic ignored "-Wcast-qual" -#endif -static inline void i40e_rxq_rearm (struct i40e_rx_queue *rxq) {
@@ -41,7 +37,7 @@ i40e_rxq_rearm(struct i40e_rx_queue *rxq) dma_addr0 =_mm_setzero_si128 ();for (i =0 ; i <RTE_I40E_DESCS_PER_LOOP ; i++) { rxep[i].mbuf = &rxq->fake_mbuf; -_mm_store_si128 ((__m128i *)&rxdp[i].read, + _mm_store_si128(RTE_CAST_PTR(__m128i *, &rxdp[i].read), dma_addr0); } }
@@ -72,8 +68,8 @@ i40e_rxq_rearm(struct i40e_rx_queue *rxq) dma_addr1 =_mm_add_epi64 (dma_addr1, hdr_room);/* flush desc with pa dma_addr */ -_mm_store_si128 ((__m128i *)&rxdp++->read, dma_addr0); -_mm_store_si128 ((__m128i *)&rxdp++->read, dma_addr1); + _mm_store_si128(RTE_CAST_PTR(__m128i *, &rxdp++->read), dma_addr0); + _mm_store_si128(RTE_CAST_PTR(__m128i *, &rxdp++->read), dma_addr1); } rxq->rxrearm_start +=RTE_I40E_RXQ_REARM_THRESH ;
@@ -97,10 +93,10 @@ descs_to_fdir_32b(volatile union i40e_rx_desc *rxdp, struct rte_mbuf **rx_pkt) {/* 32B descriptors: Load 2nd half of descriptors for FDIR ID data */ __m128i desc0_qw23, desc1_qw23, desc2_qw23, desc3_qw23; - desc0_qw23 =_mm_loadu_si128 ((__m128i *)&(rxdp +0 )->wb.qword2); - desc1_qw23 =_mm_loadu_si128 ((__m128i *)&(rxdp +1 )->wb.qword2); - desc2_qw23 =_mm_loadu_si128 ((__m128i *)&(rxdp +2 )->wb.qword2); - desc3_qw23 =_mm_loadu_si128 ((__m128i *)&(rxdp +3 )->wb.qword2); + desc0_qw23 = _mm_loadu_si128(RTE_CAST_PTR(const __m128i *, &(rxdp + 0)->wb.qword2)); + desc1_qw23 = _mm_loadu_si128(RTE_CAST_PTR(const __m128i *, &(rxdp + 1)->wb.qword2)); + desc2_qw23 = _mm_loadu_si128(RTE_CAST_PTR(const __m128i *, &(rxdp + 2)->wb.qword2)); + desc3_qw23 = _mm_loadu_si128(RTE_CAST_PTR(const __m128i *, &(rxdp + 3)->wb.qword2));/* FDIR ID data: move last u32 of each desc to 4 u32 lanes */ __m128i v_unpack_01, v_unpack_23;
@@ -462,7 +458,7 @@ _recv_raw_pkts_vec(struct i40e_rx_queue *rxq, struct rte_mbuf **rx_pkts, mbp1 =_mm_loadu_si128 ((__m128i *)&sw_ring[pos]);/* Read desc statuses backwards to avoid race condition */ /* A.1 load desc[3] */ - descs[3 ] =_mm_loadu_si128 ((__m128i *)(rxdp +3 )); + descs[3] = _mm_loadu_si128(RTE_CAST_PTR(const __m128i *, rxdp + 3));rte_compiler_barrier ();/* B.2 copy 2 64 bit or 4 32 bit mbuf point into rx_pkts */
@@ -474,11 +470,11 @@ _recv_raw_pkts_vec(struct i40e_rx_queue *rxq, struct rte_mbuf **rx_pkts,#endif /* A.1 load desc[2-0] */ - descs[2 ] =_mm_loadu_si128 ((__m128i *)(rxdp +2 )); + descs[2] = _mm_loadu_si128(RTE_CAST_PTR(const __m128i *, rxdp + 2));rte_compiler_barrier (); - descs[1 ] =_mm_loadu_si128 ((__m128i *)(rxdp +1 )); + descs[1] = _mm_loadu_si128(RTE_CAST_PTR(const __m128i *, rxdp + 1));rte_compiler_barrier (); - descs[0 ] =_mm_loadu_si128 ((__m128i *)(rxdp)); + descs[0] = _mm_loadu_si128(RTE_CAST_PTR(const __m128i *, rxdp));#if defined(RTE_ARCH_X86_64 )/* B.2 copy 2 mbuf point into rx_pkts */
@@ -681,7 +677,7 @@ vtx1(volatile struct i40e_tx_desc *txdp,__m128i descriptor =_mm_set_epi64x (high_qw, pkt->buf_iova + pkt->data_off); -_mm_store_si128 ((__m128i *)txdp, descriptor); + _mm_store_si128(RTE_CAST_PTR(__m128i *, txdp), descriptor); } static inline void
drivers/net/iavf/iavf_rxtx_vec_avx2.c +28 -32
144 lines not on this page · raw message
drivers/net/iavf/iavf_rxtx_vec_avx512.c +29 -33
165 lines not on this page · raw message
drivers/net/iavf/iavf_rxtx_vec_common.h +3 -7
@@ -11,10 +11,6 @@#include "iavf.h" #include "iavf_rxtx.h" -#ifndef __INTEL_COMPILER -#pragma GCC diagnostic ignored "-Wcast-qual" -#endif - static __rte_always_inline uint16_treassemble_packets (struct iavf_rx_queue *rxq,struct rte_mbuf **rx_bufs,uint16_t nb_bufs,uint8_t *split_flags)
@@ -422,7 +418,7 @@ iavf_rxq_rearm_common(struct iavf_rx_queue *rxq, __rte_unused bool avx512) dma_addr0 =_mm_setzero_si128 ();for (i =0 ; i <IAVF_VPMD_DESCS_PER_LOOP ; i++) { rxp[i] = &rxq->fake_mbuf; -_mm_store_si128 ((__m128i *)&rxdp[i].read, + _mm_store_si128(RTE_CAST_PTR(__m128i *, &rxdp[i].read), dma_addr0); } }
@@ -458,8 +454,8 @@ iavf_rxq_rearm_common(struct iavf_rx_queue *rxq, __rte_unused bool avx512) dma_addr1 =_mm_add_epi64 (dma_addr1, hdr_room);/* flush desc with pa dma_addr */ -_mm_store_si128 ((__m128i *)&rxdp++->read, dma_addr0); - _mm_store_si128((__m128i *)&rxdp++->read, dma_addr1); + _mm_store_si128(RTE_CAST_PTR(__m128i *, &rxdp++->read), dma_addr0); + _mm_store_si128(RTE_CAST_PTR(__m128i *, &rxdp++->read), dma_addr1); }#else #ifdef CC_AVX512_SUPPORT
drivers/net/iavf/iavf_rxtx_vec_neon.c +11 -11
@@ -36,7 +36,7 @@ iavf_rxq_rearm(struct iavf_rx_queue *rxq) rxq->nb_rx_desc) {for (i =0 ; i <IAVF_VPMD_DESCS_PER_LOOP ; i++) { rxep[i] = &rxq->fake_mbuf; -vst1q_u64 ((uint64_t *)&rxdp[i].read, zero); + vst1q_u64(RTE_CAST_PTR(uint64_t *, &rxdp[i].read), zero); } } rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
@@ -53,11 +53,11 @@ iavf_rxq_rearm(struct iavf_rx_queue *rxq) dma_addr0 =vdupq_n_u64 (paddr);/* flush desc with pa dma_addr */ -vst1q_u64 ((uint64_t *)&rxdp++->read, dma_addr0); + vst1q_u64(RTE_CAST_PTR(uint64_t *, &rxdp++->read), dma_addr0); paddr = mb1->buf_iova +RTE_PKTMBUF_HEADROOM ; dma_addr1 =vdupq_n_u64 (paddr); -vst1q_u64 ((uint64_t *)&rxdp++->read, dma_addr1); + vst1q_u64(RTE_CAST_PTR(uint64_t *, &rxdp++->read), dma_addr1); } rxq->rxrearm_start +=IAVF_RXQ_REARM_THRESH ;
@@ -269,18 +269,18 @@ _recv_raw_pkts_vec(struct iavf_rx_queue *__rte_restrict rxq,int32x4_t len_shl = {0 ,0 ,0 ,PKTLEN_SHIFT };/* A.1 load desc[3-0] */ - descs[3 ] =vld1q_u64 ((uint64_t *)(rxdp +3 )); - descs[2 ] =vld1q_u64 ((uint64_t *)(rxdp +2 )); - descs[1 ] =vld1q_u64 ((uint64_t *)(rxdp +1 )); - descs[0 ] =vld1q_u64 ((uint64_t *)(rxdp)); + descs[3] = vld1q_u64(RTE_CAST_PTR(uint64_t *, rxdp + 3)); + descs[2] = vld1q_u64(RTE_CAST_PTR(uint64_t *, rxdp + 2)); + descs[1] = vld1q_u64(RTE_CAST_PTR(uint64_t *, rxdp + 1)); + descs[0] = vld1q_u64(RTE_CAST_PTR(uint64_t *, rxdp));/* Use acquire fence to order loads of descriptor qwords */ rte_atomic_thread_fence (rte_memory_order_acquire);/* A.2 reload qword0 to make it ordered after qword1 load */ - descs[3 ] =vld1q_lane_u64 ((uint64_t *)(rxdp +3 ), descs[3 ],0 ); - descs[2 ] =vld1q_lane_u64 ((uint64_t *)(rxdp +2 ), descs[2 ],0 ); - descs[1 ] =vld1q_lane_u64 ((uint64_t *)(rxdp +1 ), descs[1 ],0 ); - descs[0 ] =vld1q_lane_u64 ((uint64_t *)(rxdp), descs[0 ],0 ); + descs[3] = vld1q_lane_u64(RTE_CAST_PTR(uint64_t *, rxdp + 3), descs[3], 0); + descs[2] = vld1q_lane_u64(RTE_CAST_PTR(uint64_t *, rxdp + 2), descs[2], 0); + descs[1] = vld1q_lane_u64(RTE_CAST_PTR(uint64_t *, rxdp + 1), descs[1], 0); + descs[0] = vld1q_lane_u64(RTE_CAST_PTR(uint64_t *, rxdp), descs[0], 0);/* B.1 load 4 mbuf point */ mbp1 =vld1q_u64 ((uint64_t *)&sw_ring[pos]);
drivers/net/iavf/iavf_rxtx_vec_sse.c +17 -21
@@ -12,10 +12,6 @@#include <rte_vect.h> -#ifndef __INTEL_COMPILER -#pragma GCC diagnostic ignored "-Wcast-qual" -#endif -static inline void iavf_rxq_rearm (struct iavf_rx_queue *rxq) {
@@ -38,7 +34,7 @@ iavf_rxq_rearm(struct iavf_rx_queue *rxq) dma_addr0 =_mm_setzero_si128 ();for (i =0 ; i <IAVF_VPMD_DESCS_PER_LOOP ; i++) { rxp[i] = &rxq->fake_mbuf; -_mm_store_si128 ((__m128i *)&rxdp[i].read, + _mm_store_si128(RTE_CAST_PTR(__m128i *, &rxdp[i].read), dma_addr0); } }
@@ -69,8 +65,8 @@ iavf_rxq_rearm(struct iavf_rx_queue *rxq) dma_addr1 =_mm_add_epi64 (dma_addr1, hdr_room);/* flush desc with pa dma_addr */ -_mm_store_si128 ((__m128i *)&rxdp++->read, dma_addr0); -_mm_store_si128 ((__m128i *)&rxdp++->read, dma_addr1); + _mm_store_si128(RTE_CAST_PTR(__m128i *, &rxdp++->read), dma_addr0); + _mm_store_si128(RTE_CAST_PTR(__m128i *, &rxdp++->read), dma_addr1); } rxq->rxrearm_start += rxq->rx_free_thresh;
@@ -578,7 +574,7 @@ _recv_raw_pkts_vec(struct iavf_rx_queue *rxq, struct rte_mbuf **rx_pkts, mbp1 =_mm_loadu_si128 ((__m128i *)&sw_ring[pos]);/* Read desc statuses backwards to avoid race condition */ /* A.1 load desc[3] */ - descs[3 ] =_mm_loadu_si128 ((__m128i *)(rxdp +3 )); + descs[3] = _mm_loadu_si128(RTE_CAST_PTR(const __m128i *, rxdp + 3));rte_compiler_barrier ();/* B.2 copy 2 64 bit or 4 32 bit mbuf point into rx_pkts */
@@ -590,11 +586,11 @@ _recv_raw_pkts_vec(struct iavf_rx_queue *rxq, struct rte_mbuf **rx_pkts,#endif /* A.1 load desc[2-0] */ - descs[2 ] =_mm_loadu_si128 ((__m128i *)(rxdp +2 )); + descs[2] = _mm_loadu_si128(RTE_CAST_PTR(const __m128i *, rxdp + 2));rte_compiler_barrier (); - descs[1 ] =_mm_loadu_si128 ((__m128i *)(rxdp +1 )); + descs[1] = _mm_loadu_si128(RTE_CAST_PTR(const __m128i *, rxdp + 1));rte_compiler_barrier (); - descs[0 ] =_mm_loadu_si128 ((__m128i *)(rxdp)); + descs[0] = _mm_loadu_si128(RTE_CAST_PTR(const __m128i *, rxdp));#if defined(RTE_ARCH_X86_64 )/* B.2 copy 2 mbuf point into rx_pkts */
@@ -783,7 +779,7 @@ _recv_raw_pkts_vec_flex_rxd(struct iavf_rx_queue *rxq,/* Just the act of getting into the function from the application is * going to cost about 7 cycles */ - rxdp = (union iavf_rx_flex_desc *)rxq->rx_ring + rxq->rx_tail; + rxdp = (volatile union iavf_rx_flex_desc *)rxq->rx_ring + rxq->rx_tail;rte_prefetch0 (rxdp);
@@ -864,7 +860,7 @@ _recv_raw_pkts_vec_flex_rxd(struct iavf_rx_queue *rxq, mbp1 =_mm_loadu_si128 ((__m128i *)&sw_ring[pos]);/* Read desc statuses backwards to avoid race condition */ /* A.1 load desc[3] */ - descs[3 ] =_mm_loadu_si128 ((__m128i *)(rxdp +3 )); + descs[3] = _mm_loadu_si128(RTE_CAST_PTR(const __m128i *, rxdp + 3));rte_compiler_barrier ();/* B.2 copy 2 64 bit or 4 32 bit mbuf point into rx_pkts */
@@ -876,11 +872,11 @@ _recv_raw_pkts_vec_flex_rxd(struct iavf_rx_queue *rxq,#endif /* A.1 load desc[2-0] */ - descs[2 ] =_mm_loadu_si128 ((__m128i *)(rxdp +2 )); + descs[2] = _mm_loadu_si128(RTE_CAST_PTR(const __m128i *, rxdp + 2));rte_compiler_barrier (); - descs[1 ] =_mm_loadu_si128 ((__m128i *)(rxdp +1 )); + descs[1] = _mm_loadu_si128(RTE_CAST_PTR(const __m128i *, rxdp + 1));rte_compiler_barrier (); - descs[0 ] =_mm_loadu_si128 ((__m128i *)(rxdp)); + descs[0] = _mm_loadu_si128(RTE_CAST_PTR(const __m128i *, rxdp));#if defined(RTE_ARCH_X86_64 )/* B.2 copy 2 mbuf point into rx_pkts */
@@ -928,16 +924,16 @@ _recv_raw_pkts_vec_flex_rxd(struct iavf_rx_queue *rxq, rxq->rx_flags & IAVF_RX_FLAGS_VLAN_TAG_LOC_L2TAG2_2) {/* load bottom half of every 32B desc */ descs_bh[3 ] =_mm_load_si128 - ((void *)(&rxdp[3 ].wb.status_error1)); + (RTE_CAST_PTR(const __m128i *, &rxdp[3].wb.status_error1));rte_compiler_barrier (); descs_bh[2 ] =_mm_load_si128 - ((void *)(&rxdp[2 ].wb.status_error1)); + (RTE_CAST_PTR(const __m128i *, &rxdp[2].wb.status_error1));rte_compiler_barrier (); descs_bh[1 ] =_mm_load_si128 - ((void *)(&rxdp[1 ].wb.status_error1)); + (RTE_CAST_PTR(const __m128i *, &rxdp[1].wb.status_error1));rte_compiler_barrier (); descs_bh[0 ] =_mm_load_si128 - ((void *)(&rxdp[0 ].wb.status_error1)); + (RTE_CAST_PTR(const __m128i *, &rxdp[0].wb.status_error1)); }if (offloads &RTE_ETH_RX_OFFLOAD_RSS_HASH ) {
@@ -1349,7 +1345,7 @@ vtx1(volatile struct iavf_tx_desc *txdp, struct rte_mbuf *pkt, uint64_t flags)__m128i descriptor =_mm_set_epi64x (high_qw, pkt->buf_iova + pkt->data_off); -_mm_store_si128 ((__m128i *)txdp, descriptor); + _mm_store_si128(RTE_CAST_PTR(__m128i *, txdp), descriptor); } static inline void
drivers/net/ice/ice_rxtx_common_avx.h +7 -11
@@ -7,10 +7,6 @@#include "ice_rxtx.h" -#ifndef __INTEL_COMPILER -#pragma GCC diagnostic ignored "-Wcast-qual" -#endif -#ifdef __AVX2__ static __rte_always_inline void ice_rxq_rearm_common(struct ice_rx_queue *rxq, __rte_unused bool avx512)
@@ -33,7 +29,7 @@ ice_rxq_rearm_common(struct ice_rx_queue *rxq, __rte_unused bool avx512) dma_addr0 =_mm_setzero_si128 ();for (i =0 ; i <ICE_DESCS_PER_LOOP ; i++) { rxep[i].mbuf = &rxq->fake_mbuf; -_mm_store_si128 ((__m128i *)&rxdp[i].read, + _mm_store_si128(RTE_CAST_PTR(__m128i *, &rxdp[i].read), dma_addr0); } }
@@ -77,8 +73,8 @@ ice_rxq_rearm_common(struct ice_rx_queue *rxq, __rte_unused bool avx512) dma_addr1 =_mm_add_epi64 (dma_addr1, hdr_room);/* flush desc with pa dma_addr */ -_mm_store_si128 ((__m128i *)&rxdp++->read, dma_addr0); - _mm_store_si128((__m128i *)&rxdp++->read, dma_addr1); + _mm_store_si128(RTE_CAST_PTR(__m128i *, &rxdp++->read), dma_addr0); + _mm_store_si128(RTE_CAST_PTR(__m128i *, &rxdp++->read), dma_addr1); }#else #ifdef __AVX512VL__
@@ -157,8 +153,8 @@ ice_rxq_rearm_common(struct ice_rx_queue *rxq, __rte_unused bool avx512) dma_addr4_7 =_mm512_add_epi64 (dma_addr4_7, hdr_room);/* flush desc with pa dma_addr */ -_mm512_store_si512 ((__m512i *)&rxdp->read, dma_addr0_3); - _mm512_store_si512((__m512i *)&(rxdp + 4)->read, dma_addr4_7); + _mm512_store_si512(RTE_CAST_PTR(__m512i *, &rxdp->read), dma_addr0_3); + _mm512_store_si512(RTE_CAST_PTR(__m512i *, &(rxdp + 4)->read), dma_addr4_7); } } else#endif /* __AVX512VL__ */
@@ -213,8 +209,8 @@ ice_rxq_rearm_common(struct ice_rx_queue *rxq, __rte_unused bool avx512) dma_addr2_3 =_mm256_add_epi64 (dma_addr2_3, hdr_room);/* flush desc with pa dma_addr */ -_mm256_store_si256 ((__m256i *)&rxdp->read, dma_addr0_1); -_mm256_store_si256 ((__m256i *)&(rxdp +2 )->read, dma_addr2_3); + _mm256_store_si256(RTE_CAST_PTR(__m256i *, &rxdp->read), dma_addr0_1); + _mm256_store_si256(RTE_CAST_PTR(__m256i *, &(rxdp + 2)->read), dma_addr2_3); } }
drivers/net/ice/ice_rxtx_vec_avx2.c +35 -39
118 lines not on this page · raw message
drivers/net/ice/ice_rxtx_vec_avx512.c +26 -38
115 lines not on this page · raw message
drivers/net/ice/ice_rxtx_vec_common.h +0 -4
@@ -7,10 +7,6 @@#include "ice_rxtx.h" -#ifndef __INTEL_COMPILER -#pragma GCC diagnostic ignored "-Wcast-qual" -#endif -static inline uint16_t ice_rx_reassemble_packets (struct ice_rx_queue *rxq,struct rte_mbuf **rx_bufs,uint16_t nb_bufs,uint8_t *split_flags)
drivers/net/ice/ice_rxtx_vec_sse.c +12 -16
@@ -6,10 +6,6 @@#include <rte_vect.h> -#ifndef __INTEL_COMPILER -#pragma GCC diagnostic ignored "-Wcast-qual" -#endif -static inline __m128i ice_flex_rxd_to_fdir_flags_vec (const __m128i fdir_id0_3) {
@@ -52,7 +48,7 @@ ice_rxq_rearm(struct ice_rx_queue *rxq) dma_addr0 =_mm_setzero_si128 ();for (i =0 ; i <ICE_DESCS_PER_LOOP ; i++) { rxep[i].mbuf = &rxq->fake_mbuf; -_mm_store_si128 ((__m128i *)&rxdp[i].read, + _mm_store_si128(RTE_CAST_PTR(__m128i *, &rxdp[i].read), dma_addr0); } }
@@ -91,8 +87,8 @@ ice_rxq_rearm(struct ice_rx_queue *rxq) dma_addr1 =_mm_add_epi64 (dma_addr1, hdr_room);/* flush desc with pa dma_addr */ -_mm_store_si128 ((__m128i *)&rxdp++->read, dma_addr0); -_mm_store_si128 ((__m128i *)&rxdp++->read, dma_addr1); + _mm_store_si128(RTE_CAST_PTR(__m128i *, &rxdp++->read), dma_addr0); + _mm_store_si128(RTE_CAST_PTR(__m128i *, &rxdp++->read), dma_addr1); } rxq->rxrearm_start +=ICE_RXQ_REARM_THRESH ;
@@ -425,7 +421,7 @@ _ice_recv_raw_pkts_vec(struct ice_rx_queue *rxq, struct rte_mbuf **rx_pkts, mbp1 =_mm_loadu_si128 ((__m128i *)&sw_ring[pos]);/* Read desc statuses backwards to avoid race condition */ /* A.1 load desc[3] */ - descs[3 ] =_mm_loadu_si128 ((__m128i *)(rxdp +3 )); + descs[3] = _mm_loadu_si128(RTE_CAST_PTR(const __m128i *, rxdp + 3));rte_compiler_barrier ();/* B.2 copy 2 64 bit or 4 32 bit mbuf point into rx_pkts */
@@ -437,11 +433,11 @@ _ice_recv_raw_pkts_vec(struct ice_rx_queue *rxq, struct rte_mbuf **rx_pkts,#endif /* A.1 load desc[2-0] */ - descs[2 ] =_mm_loadu_si128 ((__m128i *)(rxdp +2 )); + descs[2] = _mm_loadu_si128(RTE_CAST_PTR(const __m128i *, rxdp + 2));rte_compiler_barrier (); - descs[1 ] =_mm_loadu_si128 ((__m128i *)(rxdp +1 )); + descs[1] = _mm_loadu_si128(RTE_CAST_PTR(const __m128i *, rxdp + 1));rte_compiler_barrier (); - descs[0 ] =_mm_loadu_si128 ((__m128i *)(rxdp)); + descs[0] = _mm_loadu_si128(RTE_CAST_PTR(const __m128i *, rxdp));#if defined(RTE_ARCH_X86_64 )/* B.2 copy 2 mbuf point into rx_pkts */
@@ -491,19 +487,19 @@ _ice_recv_raw_pkts_vec(struct ice_rx_queue *rxq, struct rte_mbuf **rx_pkts,/* load bottom half of every 32B desc */ const __m128i raw_desc_bh3 =_mm_load_si128 - ((void *)(&rxdp[3 ].wb.status_error1)); + (RTE_CAST_PTR(const __m128i *, &rxdp[3].wb.status_error1));rte_compiler_barrier ();const __m128i raw_desc_bh2 =_mm_load_si128 - ((void *)(&rxdp[2 ].wb.status_error1)); + (RTE_CAST_PTR(const __m128i *, &rxdp[2].wb.status_error1));rte_compiler_barrier ();const __m128i raw_desc_bh1 =_mm_load_si128 - ((void *)(&rxdp[1 ].wb.status_error1)); + (RTE_CAST_PTR(const __m128i *, &rxdp[1].wb.status_error1));rte_compiler_barrier ();const __m128i raw_desc_bh0 =_mm_load_si128 - ((void *)(&rxdp[0 ].wb.status_error1)); + (RTE_CAST_PTR(const __m128i *, &rxdp[0].wb.status_error1));/** * to shift the 32b RSS hash value to the
@@ -680,7 +676,7 @@ ice_vtx1(volatile struct ice_tx_desc *txdp, struct rte_mbuf *pkt, ((uint64_t)pkt->data_len << ICE_TXD_QW1_TX_BUF_SZ_S));__m128i descriptor =_mm_set_epi64x (high_qw,rte_pktmbuf_iova (pkt)); -_mm_store_si128 ((__m128i *)txdp, descriptor); + _mm_store_si128(RTE_CAST_PTR(__m128i *, txdp), descriptor); } static inline void
drivers/net/idpf/idpf_rxtx_vec_common.h +0 -4
@@ -11,10 +11,6 @@#include "idpf_ethdev.h" #include "idpf_rxtx.h" -#ifndef __INTEL_COMPILER -#pragma GCC diagnostic ignored "-Wcast-qual" -#endif -#define IDPF_SCALAR_PATH 0#define IDPF_VECTOR_PATH 1#define IDPF_RX_NO_VECTOR_FLAGS ( \
drivers/net/ixgbe/ixgbe_recycle_mbufs_vec_common.c +0 -2
@@ -8,8 +8,6 @@#include "ixgbe_ethdev.h" #include "ixgbe_rxtx.h" -#pragma GCC diagnostic ignored "-Wcast-qual" -void ixgbe_recycle_rx_descriptors_refill_vec (void *rx_queue,uint16_t nb_mbufs) {
drivers/net/ixgbe/ixgbe_rxtx_vec_neon.c +8 -10
@@ -11,8 +11,6 @@#include "ixgbe_rxtx.h" #include "ixgbe_rxtx_vec_common.h" -#pragma GCC diagnostic ignored "-Wcast-qual" -static inline void ixgbe_rxq_rearm (struct ixgbe_rx_queue *rxq) {
@@ -36,7 +34,7 @@ ixgbe_rxq_rearm(struct ixgbe_rx_queue *rxq) rxq->nb_rx_desc) {for (i =0 ; i <RTE_IXGBE_DESCS_PER_LOOP ; i++) { rxep[i].mbuf = &rxq->fake_mbuf; -vst1q_u64 ((uint64_t *)&rxdp[i].read, + vst1q_u64(RTE_CAST_PTR(uint64_t *, &rxdp[i].read), zero); } }
@@ -60,12 +58,12 @@ ixgbe_rxq_rearm(struct ixgbe_rx_queue *rxq) 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); + vst1q_u64(RTE_CAST_PTR(uint64_t *, &rxdp++->read), dma_addr0);vst1_u8 ((uint8_t *)&mb1->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); + vst1q_u64(RTE_CAST_PTR(uint64_t *, &rxdp++->read), dma_addr1); } rxq->rxrearm_start +=RTE_IXGBE_RXQ_REARM_THRESH ;
@@ -367,10 +365,10 @@ _recv_raw_pkts_vec(struct ixgbe_rx_queue *rxq, struct rte_mbuf **rx_pkts, mbp2 =vld1q_u64 ((uint64_t *)&sw_ring[pos +2 ]);/* A. load 4 pkts descs */ - descs[0 ] =vld1q_u64 ((uint64_t *)(rxdp)); - descs[1 ] =vld1q_u64 ((uint64_t *)(rxdp +1 )); - descs[2 ] =vld1q_u64 ((uint64_t *)(rxdp +2 )); - descs[3 ] =vld1q_u64 ((uint64_t *)(rxdp +3 )); + descs[0] = vld1q_u64(RTE_CAST_PTR(uint64_t *, rxdp)); + descs[1] = vld1q_u64(RTE_CAST_PTR(uint64_t *, rxdp + 1)); + descs[2] = vld1q_u64(RTE_CAST_PTR(uint64_t *, rxdp + 2)); + descs[3] = vld1q_u64(RTE_CAST_PTR(uint64_t *, rxdp + 3));/* B.2 copy 2 mbuf point into rx_pkts */ vst1q_u64 ((uint64_t *)&rx_pkts[pos +2 ], mbp2);
@@ -554,7 +552,7 @@ vtx1(volatile union ixgbe_adv_tx_desc *txdp, pkt->buf_iova + pkt->data_off, (uint64_t)pkt->pkt_len << 46 | flags | pkt->data_len}; -vst1q_u64 ((uint64_t *)&txdp->read, descriptor); + vst1q_u64(RTE_CAST_PTR(uint64_t *, &txdp->read), descriptor); } static inline void
drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c +8 -12
@@ -12,10 +12,6 @@#include <rte_vect.h> -#ifndef __INTEL_COMPILER -#pragma GCC diagnostic ignored "-Wcast-qual" -#endif -static inline void ixgbe_rxq_rearm (struct ixgbe_rx_queue *rxq) {
@@ -41,7 +37,7 @@ ixgbe_rxq_rearm(struct ixgbe_rx_queue *rxq) dma_addr0 =_mm_setzero_si128 ();for (i =0 ; i <RTE_IXGBE_DESCS_PER_LOOP ; i++) { rxep[i].mbuf = &rxq->fake_mbuf; -_mm_store_si128 ((__m128i *)&rxdp[i].read, + _mm_store_si128(RTE_CAST_PTR(__m128i *, &rxdp[i].read), dma_addr0); } }
@@ -76,8 +72,8 @@ ixgbe_rxq_rearm(struct ixgbe_rx_queue *rxq) dma_addr1 =_mm_and_si128 (dma_addr1, hba_msk);/* flush desc with pa dma_addr */ -_mm_store_si128 ((__m128i *)&rxdp++->read, dma_addr0); -_mm_store_si128 ((__m128i *)&rxdp++->read, dma_addr1); + _mm_store_si128(RTE_CAST_PTR(__m128i *, &rxdp++->read), dma_addr0); + _mm_store_si128(RTE_CAST_PTR(__m128i *, &rxdp++->read), dma_addr1); } rxq->rxrearm_start +=RTE_IXGBE_RXQ_REARM_THRESH ;
@@ -466,7 +462,7 @@ _recv_raw_pkts_vec(struct ixgbe_rx_queue *rxq, struct rte_mbuf **rx_pkts,/* Read desc statuses backwards to avoid race condition */ /* A.1 load desc[3] */ - descs[3 ] =_mm_loadu_si128 ((__m128i *)(rxdp +3 )); + descs[3] = _mm_loadu_si128(RTE_CAST_PTR(const __m128i *, rxdp + 3));rte_compiler_barrier ();/* B.2 copy 2 64 bit or 4 32 bit mbuf point into rx_pkts */
@@ -478,11 +474,11 @@ _recv_raw_pkts_vec(struct ixgbe_rx_queue *rxq, struct rte_mbuf **rx_pkts,#endif /* A.1 load desc[2-0] */ - descs[2 ] =_mm_loadu_si128 ((__m128i *)(rxdp +2 )); + descs[2] = _mm_loadu_si128(RTE_CAST_PTR(const __m128i *, rxdp + 2));rte_compiler_barrier (); - descs[1 ] =_mm_loadu_si128 ((__m128i *)(rxdp +1 )); + descs[1] = _mm_loadu_si128(RTE_CAST_PTR(const __m128i *, rxdp + 1));rte_compiler_barrier (); - descs[0 ] =_mm_loadu_si128 ((__m128i *)(rxdp)); + descs[0] = _mm_loadu_si128(RTE_CAST_PTR(const __m128i *, rxdp));#if defined(RTE_ARCH_X86_64 )/* B.2 copy 2 mbuf point into rx_pkts */
@@ -676,7 +672,7 @@ vtx1(volatile union ixgbe_adv_tx_desc *txdp,__m128i descriptor =_mm_set_epi64x ((uint64_t )pkt->pkt_len <<46 | flags | pkt->data_len, pkt->buf_iova + pkt->data_off); -_mm_store_si128 ((__m128i *)&txdp->read, descriptor); + _mm_store_si128(RTE_CAST_PTR(__m128i *, &txdp->read), descriptor); } static inline void
drivers/net/mlx5/mlx5_flow.c +1 -4
@@ -7287,10 +7287,7 @@ flow_tunnel_from_rule(const struct mlx5_flow *flow) {struct mlx5_flow_tunnel *tunnel; -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wcast-qual" - tunnel = (typeof (tunnel ))flow->tunnel; -#pragma GCC diagnostic pop + tunnel =RTE_PTR_UNQUAL (flow->tunnel);return tunnel; }
drivers/net/mlx5/mlx5_rxtx_vec_altivec.h +0 -5
@@ -25,11 +25,6 @@#include "mlx5_rxtx_vec.h" #include "mlx5_autoconf.h" -#ifndef __INTEL_COMPILER -#pragma GCC diagnostic ignored "-Wcast-qual" -#pragma GCC diagnostic ignored "-Wstrict-aliasing" -#endif -/** * Store free buffers to RX SW ring. *
drivers/net/mlx5/mlx5_rxtx_vec_neon.h +8 -10
@@ -25,8 +25,6 @@#include "mlx5_rxtx_vec.h" #include "mlx5_autoconf.h" -#pragma GCC diagnostic ignored "-Wcast-qual" -/** * Store free buffers to RX SW ring. *
@@ -75,7 +73,7 @@ rxq_cq_decompress_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq, struct rte_mbuf **elts, bool keep) {volatile struct mlx5_mini_cqe8 *mcq = - (void *)&(cq + !rxq->cqe_comp_layout)->pkt_info; + (volatile struct mlx5_mini_cqe8 *)&(cq + !rxq->cqe_comp_layout)->pkt_info;/* Title packet is pre-built. */ struct rte_mbuf *t_pkt = rxq->cqe_comp_layout ? &rxq->title_pkt : elts[0 ];unsigned int pos;
@@ -139,9 +137,9 @@ rxq_cq_decompress_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq,*/ cycle:if (rxq->cqe_comp_layout) -rte_prefetch0 ((void *)(cq + mcqe_n)); + rte_prefetch0((volatile void *), cq + mcqe_n);for (pos =0 ; pos < mcqe_n; ) { -uint8_t *p = (void *)&mcq[pos %8 ]; + uint8_t *p = RTE_CAST_PTR(uint8_t *, &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;
@@ -157,7 +155,7 @@ rxq_cq_decompress_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq,if (!rxq->cqe_comp_layout)for (i =0 ; i <MLX5_VPMD_DESCS_PER_LOOP ; ++i)if (likely (pos + i < mcqe_n)) -rte_prefetch0 ((void *)(cq + pos + i)); +rte_prefetch0 ((volatile void *)(cq + pos + i)); __asm__volatile (/* A.1 load mCQEs into a 128bit register. */ "ld1 {v16.16b - v17.16b}, [%[mcq]] \n\t"
@@ -367,8 +365,8 @@ rxq_cq_decompress_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq,if (!rxq->cqe_comp_layout) {if (!(pos &0x7 ) && pos < mcqe_n) {if (pos +8 < mcqe_n) -rte_prefetch0 ((void *)(cq + pos +8 )); - mcq = (void *)&(cq + pos)->pkt_info; +rte_prefetch0 ((volatile void *)(cq + pos +8 )); + mcq = (volatile struct mlx5_mini_cqe8 *)&(cq + pos)->pkt_info;for (i =0 ; i <8 ; ++i) cq[inv++].op_own =MLX5_CQE_INVALIDATE ; }
@@ -383,7 +381,7 @@ rxq_cq_decompress_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq, MLX5_CQE_FORMAT(cq->op_own) == MLX5_COMPRESSED) { pos =0 ; elts = &elts[mcqe_n]; - mcq = (void *)cq; + mcq = (volatile struct mlx5_mini_cqe8 *)cq; mcqe_n =MLX5_CQE_NUM_MINIS (cq->op_own) +1 ; pkts_n += mcqe_n; goto cycle;
@@ -663,7 +661,7 @@ rxq_cq_process_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq, mask =vcreate_u16 (pkts_n - pos <MLX5_VPMD_DESCS_PER_LOOP ?-1UL >> ((pkts_n - pos) *sizeof (uint16_t ) *8 ) :0 ); - p0 = (void *)&cq[pos].pkt_info; + p0 = &cq[pos].pkt_info; p1 = p0 + (pkts_n - pos >1 ) *sizeof (struct mlx5_cqe ); p2 = p1 + (pkts_n - pos >2 ) *sizeof (struct mlx5_cqe ); p3 = p2 + (pkts_n - pos >3 ) *sizeof (struct mlx5_cqe );
drivers/net/mlx5/mlx5_rxtx_vec_sse.h +29 -32
132 lines not on this page · raw message
drivers/net/ngbe/ngbe_rxtx_vec_neon.c +4 -4
@@ -35,7 +35,7 @@ ngbe_rxq_rearm(struct ngbe_rx_queue *rxq) rxq->nb_rx_desc) {for (i =0 ; i <RTE_NGBE_DESCS_PER_LOOP ; i++) { rxep[i].mbuf = &rxq->fake_mbuf; -vst1q_u64 ((uint64_t *)(uintptr_t )&rxdp[i], zero); + vst1q_u64(RTE_CAST_PTR(uint64_t *, &rxdp[i]), zero); } } rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
@@ -58,12 +58,12 @@ ngbe_rxq_rearm(struct ngbe_rx_queue *rxq) 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 *)(uintptr_t )rxdp++, dma_addr0); + vst1q_u64(RTE_CAST_PTR(uint64_t *, rxdp++), dma_addr0);vst1_u8 ((uint8_t *)&mb1->rearm_data, p); paddr = mb1->buf_iova +RTE_PKTMBUF_HEADROOM ; dma_addr1 =vsetq_lane_u64 (paddr, zero,0 ); -vst1q_u64 ((uint64_t *)(uintptr_t )rxdp++, dma_addr1); + vst1q_u64(RTE_CAST_PTR(uint64_t *, rxdp++), dma_addr1); } rxq->rxrearm_start +=RTE_NGBE_RXQ_REARM_THRESH ;
@@ -484,7 +484,7 @@ vtx1(volatile struct ngbe_tx_desc *txdp,uint64x2_t descriptor = {pkt->buf_iova + pkt->data_off, (uint64_t )pkt_len <<45 | flags | pkt_len}; -vst1q_u64 ((uint64_t *)(uintptr_t )txdp, descriptor); + vst1q_u64(RTE_CAST_PTR(uint64_t *, txdp), descriptor); } static inline void
drivers/net/tap/tap_flow.c +3 -3
@@ -23,10 +23,10 @@#ifdef HAVE_BPF_RSS /* Workaround for warning in bpftool generated skeleton code */ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wcast-qual" +__rte_diagnostic_push +__rte_diagnostic_ignored_wcast_qual#include "tap_rss.skel.h" -#pragma GCC diagnostic pop +__rte_diagnostic_pop#endif #define ISOLATE_HANDLE 1
drivers/net/txgbe/txgbe_rxtx_vec_neon.c +4 -4
@@ -34,7 +34,7 @@ txgbe_rxq_rearm(struct txgbe_rx_queue *rxq) rxq->nb_rx_desc) {for (i =0 ; i <RTE_TXGBE_DESCS_PER_LOOP ; i++) { rxep[i].mbuf = &rxq->fake_mbuf; -vst1q_u64 ((uint64_t *)(uintptr_t )&rxdp[i], zero); + vst1q_u64(RTE_CAST_PTR(uint64_t *, &rxdp[i]), zero); } } rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
@@ -57,12 +57,12 @@ txgbe_rxq_rearm(struct txgbe_rx_queue *rxq) 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 *)(uintptr_t )rxdp++, dma_addr0); + vst1q_u64(RTE_CAST_PTR(uint64_t *, rxdp++), dma_addr0);vst1_u8 ((uint8_t *)&mb1->rearm_data, p); paddr = mb1->buf_iova +RTE_PKTMBUF_HEADROOM ; dma_addr1 =vsetq_lane_u64 (paddr, zero,0 ); -vst1q_u64 ((uint64_t *)(uintptr_t )rxdp++, dma_addr1); + vst1q_u64(RTE_CAST_PTR(uint64_t *, rxdp++), dma_addr1); } rxq->rxrearm_start +=RTE_TXGBE_RXQ_REARM_THRESH ;
@@ -484,7 +484,7 @@ vtx1(volatile struct txgbe_tx_desc *txdp,uint64x2_t descriptor = {pkt->buf_iova + pkt->data_off, (uint64_t )pkt_len <<45 | flags | pkt_len}; -vst1q_u64 ((uint64_t *)(uintptr_t )txdp, descriptor); + vst1q_u64(RTE_CAST_PTR(uint64_t *, txdp), descriptor); } static inline void
drivers/net/virtio/virtio_rxtx_simple.c +0 -4
@@ -23,10 +23,6 @@#include "virtio_rxtx_simple.h" -#ifndef __INTEL_COMPILER -#pragma GCC diagnostic ignored "-Wcast-qual" -#endif - int __rte_coldvirtio_rxq_vec_setup (struct virtnet_rx *rxq) {
Signature · 1 line
2.47.2.vfs.0.1
v15 cover add diagnostics macros to make code portable
In reply to Andre Muezeriev15:
* Fixed a comment in rte_common.h to make Doxygen happy.
* Fixed a typo (extra comma).
* Added missing RTE_PTR_UNQUAL needed for ARM64.
v14:
* Renamed RTE_PTR_DROP_QUALIFIERS into RTE_PTR_UNQUAL to more resemble C23 typeof_unqual.
* Added macro RTE_CAST_PTR to make the cast more readable when removing a type qualifier from a pointer.
v13:
* Renamed RTE_IGNORE_CAST_QUAL into RTE_PTR_DROP_QUALIFIERS.
* Added (void *) cast to RTE_PTR_DROP_QUALIFIERS to avoid the need for casting the result in most places where the macro is used.
v12:
* Added macro RTE_IGNORE_CAST_QUAL and used it as a more compact and readable form to suppress warnings where a cast is used to remove a type qualifier.
v11:
* Added __rte_diagnostic_ignored_wcast_qual to a few more places where it was needed.
v10:
* Added __rte_diagnostic_ignored_wcast_qual to a few more places where it was needed.
v9:
* Added __rte_diagnostic_ignored_wcast_qual to a few more places where it was needed.
v8:
* Added __rte_diagnostic_ignored_wcast_qual to a few more places where it was needed.
v7:
* Added __rte_diagnostic_ignored_wcast_qual to a few more places where it was needed.
v6:
* Added __rte_diagnostic_ignored_wcast_qual to a few more places where it was needed.
v5:
* Added __rte_diagnostic_ignored_wcast_qual to a few more places where it was needed.
v4:
* Added __rte_diagnostic_ignored_wcast_qual to a few more places where it was needed.
v3:
* Added __rte_diagnostic_ignored_wcast_qual to a few more places where it was needed.
v2:
* Removed __rte_diagnostic_ignored_wstrict_aliasing (introduced in v1).
* Removed the pragmas from many files where they were not needed.
* In the files where the pragmas were indeed needed, reduced the scope during which they are active, reducing the chance that unforeseen issues are hidden due to warning suppression.
Andre Muezerie (3):
eal: add diagnostics macros to make code portable drivers/common: add diagnostics macros to make code portable drivers/net: add diagnostics macros to make code portable
drivers/common/idpf/idpf_common_rxtx_avx512.c | 72 +++++++++--------- drivers/net/axgbe/axgbe_rxtx.h | 9 --- drivers/net/cpfl/cpfl_rxtx_vec_common.h | 4 - drivers/net/dpaa2/dpaa2_rxtx.c | 15 +--- drivers/net/fm10k/fm10k_rxtx_vec.c | 21 ++---- drivers/net/hns3/hns3_rxtx_vec_neon.h | 6 +- .../net/i40e/i40e_recycle_mbufs_vec_common.c | 2 - drivers/net/i40e/i40e_rxtx_common_avx.h | 22 +++--- drivers/net/i40e/i40e_rxtx_vec_altivec.c | 18 ++--- drivers/net/i40e/i40e_rxtx_vec_avx2.c | 30 ++++---- drivers/net/i40e/i40e_rxtx_vec_avx512.c | 28 +++---- drivers/net/i40e/i40e_rxtx_vec_common.h | 4 - drivers/net/i40e/i40e_rxtx_vec_neon.c | 35 ++++----- drivers/net/i40e/i40e_rxtx_vec_sse.c | 28 +++---- drivers/net/iavf/iavf_rxtx_vec_avx2.c | 60 +++++++-------- drivers/net/iavf/iavf_rxtx_vec_avx512.c | 62 ++++++++-------- drivers/net/iavf/iavf_rxtx_vec_common.h | 10 +-- drivers/net/iavf/iavf_rxtx_vec_neon.c | 22 +++--- drivers/net/iavf/iavf_rxtx_vec_sse.c | 38 +++++----- drivers/net/ice/ice_rxtx_common_avx.h | 18 ++--- drivers/net/ice/ice_rxtx_vec_avx2.c | 74 +++++++++---------- drivers/net/ice/ice_rxtx_vec_avx512.c | 64 +++++++--------- drivers/net/ice/ice_rxtx_vec_common.h | 4 - drivers/net/ice/ice_rxtx_vec_sse.c | 28 +++---- drivers/net/idpf/idpf_rxtx_vec_common.h | 4 - .../ixgbe/ixgbe_recycle_mbufs_vec_common.c | 2 - drivers/net/ixgbe/ixgbe_rxtx_vec_neon.c | 18 ++--- drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c | 20 ++--- drivers/net/mlx5/mlx5_flow.c | 5 +- drivers/net/mlx5/mlx5_rxtx_vec_altivec.h | 5 -- drivers/net/mlx5/mlx5_rxtx_vec_neon.h | 18 ++--- drivers/net/mlx5/mlx5_rxtx_vec_sse.h | 61 ++++++++------- drivers/net/ngbe/ngbe_rxtx_vec_neon.c | 8 +- drivers/net/tap/tap_flow.c | 6 +- drivers/net/txgbe/txgbe_rxtx_vec_neon.c | 8 +- drivers/net/virtio/virtio_rxtx_simple.c | 4 - lib/eal/include/rte_common.h | 46 ++++++++++++ 37 files changed, 396 insertions(+), 483 deletions(-)
--
2.47.2.vfs.0.1
PATCH v15 1/3 eal: add diagnostics macros to make code portable
It was a common pattern to have "GCC diagnostic ignored" pragmas sprinkled over the code and only activate these pragmas for certain compilers (gcc and clang). Clang supports GCC's pragma for compatibility with existing source code, so #pragma GCC diagnostic and #pragma clang diagnostic are synonyms for Clang
(https://clang.llvm.org/docs/UsersManual.html).
Now that effort is being made to make the code compatible with MSVC these expressions would become more complex. It makes sense to hide this complexity behind macros. This makes maintenance easier as these macros are defined in a single place. As a plus the code becomes more readable as well.
--- lib/eal/include/rte_common.h | 46 ++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+)
lib/eal/include/rte_common.h +46 -0
@@ -156,6 +156,52 @@ typedef uint16_t unaligned_uint16_t;#define RTE_DEPRECATED (x)#endif +/** +* Macros to cause the compiler to remember the state of the diagnostics as of +* each push, and restore to that point at each pop. +*/ +#if !defined(__INTEL_COMPILER) && !defined(RTE_TOOLCHAIN_MSVC ) +#define __rte_diagnostic_push _Pragma("GCC diagnostic push") +#define __rte_diagnostic_pop _Pragma("GCC diagnostic pop") +#else +#define __rte_diagnostic_push +#define __rte_diagnostic_pop +#endif + +/** +* Macro to disable compiler warnings about removing a type +* qualifier from the target type. +*/ +#if !defined(__INTEL_COMPILER) && !defined(RTE_TOOLCHAIN_MSVC ) +#define __rte_diagnostic_ignored_wcast_qual \ + _Pragma("GCC diagnostic ignored \"-Wcast-qual\"") +#else +#define __rte_diagnostic_ignored_wcast_qual +#endif + +/** +* Workaround to discard qualifiers (such as const, volatile, restrict) from a pointer, +* without the compiler emitting a warning. +*/ +#define RTE_PTR_UNQUAL (X ) ((void *)(uintptr_t)(X)) + +/** +* Workaround to discard qualifiers (such as const, volatile, restrict) from a pointer +* and cast it to a specific type, without the compiler emitting a warning. +* +* @warning +* Although this macro can be abused for casting a pointer to point to a different type, +* alignment may be incorrect when casting to point to a larger type. E.g.: +* struct s { +* uint16_t a; +* uint8_t b; +* uint8_t c; +* uint8_t d; +* } v; +* uint16_t * p = RTE_CAST_PTR(uint16_t *, &v.c); // "p" is not 16 bit aligned! +*/ +#define RTE_CAST_PTR (type, ptr) ((type)(uintptr_t)(ptr)) +/** * Mark a function or variable to a weak reference. */
Signature · 1 line
2.47.2.vfs.0.1
RE: [PATCH v15 1/3] eal: add diagnostics macros to make code portable
Quoted 48 lines
From: Andre Muezerie [mailto:[email protected]]
Sent: Saturday, 18 January 2025 22.55It was a common pattern to have "GCC diagnostic ignored" pragmas sprinkled over the code and only activate these pragmas for certain compilers (gcc and clang). Clang supports GCC's pragma for compatibility with existing source code, so #pragma GCC diagnostic and #pragma clang diagnostic are synonyms for Clang
(https://clang.llvm.org/docs/UsersManual.html).Now that effort is being made to make the code compatible with MSVC these expressions would become more complex. It makes sense to hide this complexity behind macros. This makes maintenance easier as these macros are defined in a single place. As a plus the code becomes more readable as well.
Signed-off-by Andre Muezerie <[email protected]>--- lib/eal/include/rte_common.h | 46 ++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+)lib/eal/include/rte_common.h +18
-0@@ -156,6 +156,52 @@ typedef uint16_t unaligned_uint16_t;#define RTE_DEPRECATED (x)#endif +/** +* Macros to cause the compiler to remember the state of the diagnostics as of +* each push, and restore to that point at each pop. +*/ +#if !defined(__INTEL_COMPILER) && !defined(RTE_TOOLCHAIN_MSVC ) +#define __rte_diagnostic_push _Pragma("GCC diagnostic push") +#define __rte_diagnostic_pop _Pragma("GCC diagnostic pop") +#else +#define __rte_diagnostic_push +#define __rte_diagnostic_pop +#endif + +/** +* Macro to disable compiler warnings about removing a type +* qualifier from the target type. +*/ +#if !defined(__INTEL_COMPILER) && !defined(RTE_TOOLCHAIN_MSVC ) +#define __rte_diagnostic_ignored_wcast_qual \
lib/eal/include/rte_common.h typedef uint16_t unaligned_uint16_t; · line 186
Quoted 10 lines
lib/eal/include/rte_common.h +10
-0+ _Pragma("GCC diagnostic ignored \"-Wcast-qual\"") +#else +#define __rte_diagnostic_ignored_wcast_qual +#endif + +/** +* Workaround to discard qualifiers (such as const, volatile, restrict) from a pointer, +* without the compiler emitting a warning. +*/ +#define RTE_PTR_UNQUAL (X ) ((void *)(uintptr_t)(X))
It seems the C23 typeof_unqual and the built-in pre-C23 __typeof_unqual__ couldn't be used. Was it a generic issue, or only when operating on (the return value of) functions?
lib/eal/include/rte_common.h typedef uint16_t unaligned_uint16_t; · line 190
Quoted 4 lines
lib/eal/include/rte_common.h +4
-0+ +/** +* Workaround to discard qualifiers (such as const, volatile, restrict) from a pointer +* and cast it to a specific type, without the compiler emitting a warning.
Propose new description with emphasis on casting rather than discarding qualifiers:
Workaround to cast a pointer to a specific type,
without the compiler emitting a warning about discarding qualifiers.
lib/eal/include/rte_common.h typedef uint16_t unaligned_uint16_t; · line 194
Quoted 4 lines
lib/eal/include/rte_common.h +4
-0+* +* @warning +* Although this macro can be abused for casting a pointer to point to a different type, +* alignment may be incorrect when casting to point to a larger type. E.g.:
This macro is now meant for abuse, so propose softening the warning:
When casting a pointer to point to a larger type,
the resulting pointer may be misaligned,
which causes undefined behavior.
E.g.:
lib/eal/include/rte_common.h typedef uint16_t unaligned_uint16_t; · line 203
Quoted 9 lines
lib/eal/include/rte_common.h +9
-0+* struct s { +* uint16_t a; +* uint8_t b; +* uint8_t c; +* uint8_t d; +* } v; +* uint16_t * p = RTE_CAST_PTR(uint16_t *, &v.c); // "p" is not 16 bit aligned! +*/ +#define RTE_CAST_PTR (type, ptr) ((type)(uintptr_t)(ptr))
I am somewhat concerned about these macros...
There's a good reason why MSVC doesn't allow casting to discard qualifiers or changing the type like this.
If in doubt, read this:
https://www.trust-in-soft.com/resources/blogs/2020-04-06-gcc-always-assumes-aligned-pointer-accesses
We need these workarounds because DPDK currently contains code with formally "undefined behavior". And instead of fixing the root causes, we choose the pragmatic solution and introduce workarounds to allow it.
Would it be possible for the RTE_CAST_PTR macro to check if the casted-to pointer changes from a smaller type to a larger type, and warn/fail if it does?
Should the use of these workaround macros be disallowed in new code? I.e. should checkpatches check for them?
Re: [PATCH v15 1/3] eal: add diagnostics macros to make code portable
Quoted 53 lines · Morten Brørup
Quoted 53 lines
From: Andre Muezerie [mailto:[email protected]]
Sent: Saturday, 18 January 2025 22.55It was a common pattern to have "GCC diagnostic ignored" pragmas sprinkled over the code and only activate these pragmas for certain compilers (gcc and clang). Clang supports GCC's pragma for compatibility with existing source code, so #pragma GCC diagnostic and #pragma clang diagnostic are synonyms for Clang
(https://clang.llvm.org/docs/UsersManual.html).Now that effort is being made to make the code compatible with MSVC these expressions would become more complex. It makes sense to hide this complexity behind macros. This makes maintenance easier as these macros are defined in a single place. As a plus the code becomes more readable as well.
Signed-off-by Andre Muezerie <[email protected]>--- lib/eal/include/rte_common.h | 46 ++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+)lib/eal/include/rte_common.h +23
-0@@ -156,6 +156,52 @@ typedef uint16_t unaligned_uint16_t;#define RTE_DEPRECATED (x)#endif +/** +* Macros to cause the compiler to remember the state of the diagnostics as of +* each push, and restore to that point at each pop. +*/ +#if !defined(__INTEL_COMPILER) && !defined(RTE_TOOLCHAIN_MSVC ) +#define __rte_diagnostic_push _Pragma("GCC diagnostic push") +#define __rte_diagnostic_pop _Pragma("GCC diagnostic pop") +#else +#define __rte_diagnostic_push +#define __rte_diagnostic_pop +#endif + +/** +* Macro to disable compiler warnings about removing a type +* qualifier from the target type. +*/ +#if !defined(__INTEL_COMPILER) && !defined(RTE_TOOLCHAIN_MSVC ) +#define __rte_diagnostic_ignored_wcast_qual \ + _Pragma("GCC diagnostic ignored \"-Wcast-qual\"") +#else +#define __rte_diagnostic_ignored_wcast_qual +#endif +
Quoted 8 lines
lib/eal/include/rte_common.h typedef uint16_t unaligned_uint16_t; · line 186
Quoted 5 lines
lib/eal/include/rte_common.h +5
-0+/** +* Workaround to discard qualifiers (such as const, volatile, restrict) from a pointer, +* without the compiler emitting a warning. +*/ +#define RTE_PTR_UNQUAL (X ) ((void *)(uintptr_t)(X))It seems the C23
typeof_unqualand the built-in pre-C23__typeof_unqual__couldn't be used. Was it a generic issue, or only when operating on (the return value of) functions?
I experimented with C23 typeof_unqual. It indeed works on gcc, clang and MSVC, but there are some details:
a) With gcc the project needs to be compiled with -std=c2x. Many other warnings show up, unrelated to the scope of this patchset. Some look suspicious and should be looked at. An error also showed up, for which I sent out a small patch.
b) When using typeof_unqual and passing "-Wcast-qual" to the compiler, a warning about the qualifier being dropped is emitted. The project currently uses "-Wcast-qual". Perhaps it shouldn't?
Due to (a) I decided to not use typeof_unqual for now, but it would be trivial to change the macro to do so in the future.
Quoted 11 lines
lib/eal/include/rte_common.h typedef uint16_t unaligned_uint16_t; · line 190
Quoted 5 lines
lib/eal/include/rte_common.h +4
-0+ +/** +* Workaround to discard qualifiers (such as const, volatile, restrict) from a pointer +* and cast it to a specific type, without the compiler emitting a warning. Propose new description with emphasis on casting rather than discarding qualifiers:
Workaround to cast a pointer to a specific type,
without the compiler emitting a warning about discarding qualifiers.
I'll update this.
Quoted 10 lines
lib/eal/include/rte_common.h typedef uint16_t unaligned_uint16_t; · line 194
Quoted 4 lines
lib/eal/include/rte_common.h +4
-0+* +* @warning +* Although this macro can be abused for casting a pointer to point to a different type, +* alignment may be incorrect when casting to point to a larger type. E.g.: This macro is now meant for abuse, so propose softening the warning:
When casting a pointer to point to a larger type,
the resulting pointer may be misaligned,
which causes undefined behavior.
I'll update this.
Quoted 16 lines
E.g.:
lib/eal/include/rte_common.h typedef uint16_t unaligned_uint16_t; · line 203
Quoted 9 lines
lib/eal/include/rte_common.h +9
-0+* struct s { +* uint16_t a; +* uint8_t b; +* uint8_t c; +* uint8_t d; +* } v; +* uint16_t * p = RTE_CAST_PTR(uint16_t *, &v.c); // "p" is not 16 bit aligned! +*/ +#define RTE_CAST_PTR (type, ptr) ((type)(uintptr_t)(ptr))I am somewhat concerned about these macros...
There's a good reason why MSVC doesn't allow casting to discard qualifiers or changing the type like this.
Quoted 7 lines
If in doubt, read this:
https://www.trust-in-soft.com/resources/blogs/2020-04-06-gcc-always-assumes-aligned-pointer-accessesWe need these workarounds because DPDK currently contains code with formally "undefined behavior". And instead of fixing the root causes, we choose the pragmatic solution and introduce workarounds to allow it.
Would it be possible for the
RTE_CAST_PTRmacro to check if the casted-to pointer changes from a smaller type to a larger type, and warn/fail if it does?
I'll think about it.
Quoted 3 lines
Should the use of these workaround macros be disallowed in new code? I.e. should checkpatches check for them?
We can certainly add a check to checkpatches.
RE: [PATCH v15 1/3] eal: add diagnostics macros to make code portable
Quoted 75 lines
From: Andre Muezerie [mailto:[email protected]]
Sent: Tuesday, 21 January 2025 15.28Quoted 10 lines · Morten Brørup
Quoted 10 lines
From: Andre Muezerie [mailto:[email protected]]
Sent: Saturday, 18 January 2025 22.55It was a common pattern to have "GCC diagnostic ignored" pragmas sprinkled over the code and only activate these pragmas for certain compilers (gcc and clang). Clang supports GCC's pragma for compatibility with existing source code, so #pragma GCC diagnostic and #pragma clang diagnostic are synonyms for Clang
(https://clang.llvm.org/docs/UsersManual.html).Quoted 3 lines
Quoted 3 lines
Now that effort is being made to make the code compatible with MSVC these expressions would become more complex. It makes sense to hide this complexity behind macros. This makes maintenance easier as
these
Quoted 6 lines
Quoted 6 lines
macros are defined in a single place. As a plus the code becomes more readable as well.
Signed-off-by Andre Muezerie <[email protected]>--- lib/eal/include/rte_common.h | 46++++++++++++++++++++++++++++++++++++
Quoted 11 lines
Quoted 11 lines
1 file changed, 46 insertions(+)lib/eal/include/rte_common.h +0
-0@@ -156,6 +156,52 @@ typedef uint16_t unaligned_uint16_t;#define RTE_DEPRECATED (x)#endif Quoted 2 lines
lib/eal/include/rte_common.h typedef uint16_t unaligned_uint16_t; · line 160
Quoted 2 lines
lib/eal/include/rte_common.h +2
-0+/** +* Macros to cause the compiler to remember the state of the diagnostics as of
Quoted 15 lines
Quoted 15 lines
lib/eal/include/rte_common.h +15
-0+* each push, and restore to that point at each pop. +*/ +#if !defined(__INTEL_COMPILER) && !defined(RTE_TOOLCHAIN_MSVC ) +#define __rte_diagnostic_push _Pragma("GCC diagnostic push") +#define __rte_diagnostic_pop _Pragma("GCC diagnostic pop") +#else +#define __rte_diagnostic_push +#define __rte_diagnostic_pop +#endif + +/** +* Macro to disable compiler warnings about removing a type +* qualifier from the target type. +*/ +#if !defined(__INTEL_COMPILER) && !defined(RTE_TOOLCHAIN_MSVC )Quoted 8 lines
lib/eal/include/rte_common.h typedef uint16_t unaligned_uint16_t;
Quoted 8 lines
lib/eal/include/rte_common.h +8
-0+#define __rte_diagnostic_ignored_wcast_qual \ + _Pragma("GCC diagnostic ignored \"-Wcast-qual\"") +#else +#define __rte_diagnostic_ignored_wcast_qual +#endif + +/** +* Workaround to discard qualifiers (such as const, volatile, restrict) from a pointer,
Quoted 5 lines
lib/eal/include/rte_common.h typedef uint16_t unaligned_uint16_t; · line 186
Quoted 3 lines
lib/eal/include/rte_common.h +3
-0+* without the compiler emitting a warning. +*/ +#define RTE_PTR_UNQUAL (X ) ((void *)(uintptr_t)(X))It seems the C23
typeof_unqualand the built-in pre-C23
__typeof_unqual__couldn't be used.Quoted 1 line
Was it a generic issue, or only when operating on (the return value
of) functions?
I experimented with C23
typeof_unqual. It indeed works on gcc, clang and MSVC, but there are some details:
Quoted 8 lines
a) With gcc the project needs to be compiled with -std=c2x. Many other warnings show up, unrelated to the scope of this patchset. Some look suspicious and should be looked at. An error also showed up, for which I sent out a small patch.
b) When using
typeof_unqualand passing "-Wcast-qual" to the compiler, a warning about the qualifier being dropped is emitted. The project currently uses "-Wcast-qual". Perhaps it shouldn't?
The compiler is our friend; when more warnings enabled, the code quality requirements are higher. Although this statement may not be universally true, I think it is for "-Wcast-qual".
Quoted 3 lines
Due to (a) I decided to not use
typeof_unqualfor now, but it would be trivial to change the macro to do so in the future.
How about __typeof_unqual__ (with double underscores prefix and postfix)? It seems to be available in both GCC [1] and MSVC [2] without requiring C23.
[1]: https://gcc.gnu.org/onlinedocs/gcc/Typeof.html
[2]: https://learn.microsoft.com/en-us/cpp/c-language/typeof-unqual-c?view=msvc-170
Quoted 70 lines
Quoted 5 lines
lib/eal/include/rte_common.h typedef uint16_t unaligned_uint16_t;
Quoted 5 lines
lib/eal/include/rte_common.h +3
-0+ +/** +* Workaround to discard qualifiers (such as const, volatile, restrict) from a pointer
Quoted 1 line
lib/eal/include/rte_common.h typedef uint16_t unaligned_uint16_t; · line 190
Quoted 1 line
lib/eal/include/rte_common.h +1
-0+* and cast it to a specific type, without the compiler emitting a warning.
Quoted 2 lines
Propose new description with emphasis on casting rather than
discarding qualifiers:
Quoted 4 lines
Workaround to cast a pointer to a specific type,
without the compiler emitting a warning about discarding qualifiers.I'll update this.
Quoted 3 lines
lib/eal/include/rte_common.h typedef uint16_t unaligned_uint16_t;
Quoted 3 lines
lib/eal/include/rte_common.h +3
-0+* +* @warning +* Although this macro can be abused for casting a pointer to point to a different type,
Quoted 1 line
lib/eal/include/rte_common.h typedef uint16_t unaligned_uint16_t; · line 194
Quoted 1 line
lib/eal/include/rte_common.h +1
-0+* alignment may be incorrect when casting to point to a larger type. E.g.:
Quoted 6 lines
This macro is now meant for abuse, so propose softening the warning:
When casting a pointer to point to a larger type,
the resulting pointer may be misaligned,
which causes undefined behavior.I'll update this.
Quoted 9 lines
E.g.:
Quoted 7 lines
lib/eal/include/rte_common.h +7
-0+* struct s { +* uint16_t a; +* uint8_t b; +* uint8_t c; +* uint8_t d; +* } v; +* uint16_t * p = RTE_CAST_PTR(uint16_t *, &v.c); // "p" is not 16 bit aligned!
Quoted 6 lines
lib/eal/include/rte_common.h typedef uint16_t unaligned_uint16_t; · line 203
Quoted 2 lines
lib/eal/include/rte_common.h +2
-0+*/ +#define RTE_CAST_PTR (type, ptr) ((type)(uintptr_t)(ptr))I am somewhat concerned about these macros...
There's a good reason why MSVC doesn't allow casting to discard
qualifiers or changing the type like this.
Quoted 3 lines
If in doubt, read this:
https://www.trust-in-soft.com/resources/blogs/2020-04-06-gcc-always-assumes-aligned-pointer-accesses
Quoted 2 lines
We need these workarounds because DPDK currently contains code with
formally "undefined behavior".
Quoted 1 line
And instead of fixing the root causes, we choose the pragmatic
solution and introduce workarounds to allow it.
Quoted 2 lines
Would it be possible for the
RTE_CAST_PTRmacro to check if thecasted-to pointer changes from a smaller type to a larger type, and warn/fail if it does?
I'll think about it.
Quoted 3 lines
Should the use of these workaround macros be disallowed in new code? I.e. should checkpatches check for them?
We can certainly add a check to checkpatches.
Re: [PATCH v15 1/3] eal: add diagnostics macros to make code portable
Quoted 80 lines · Morten Brørup
Quoted 80 lines
From: Andre Muezerie [mailto:[email protected]]
Sent: Tuesday, 21 January 2025 15.28Quoted 10 lines · Morten Brørup
Quoted 10 lines
From: Andre Muezerie [mailto:[email protected]]
Sent: Saturday, 18 January 2025 22.55It was a common pattern to have "GCC diagnostic ignored" pragmas sprinkled over the code and only activate these pragmas for certain compilers (gcc and clang). Clang supports GCC's pragma for compatibility with existing source code, so #pragma GCC diagnostic and #pragma clang diagnostic are synonyms for Clang
(https://clang.llvm.org/docs/UsersManual.html).Quoted 3 lines
Quoted 3 lines
Now that effort is being made to make the code compatible with MSVC these expressions would become more complex. It makes sense to hide this complexity behind macros. This makes maintenance easier as
these
Quoted 6 lines
Quoted 6 lines
macros are defined in a single place. As a plus the code becomes more readable as well.
Signed-off-by Andre Muezerie <[email protected]>--- lib/eal/include/rte_common.h | 46++++++++++++++++++++++++++++++++++++
Quoted 11 lines
Quoted 11 lines
1 file changed, 46 insertions(+)lib/eal/include/rte_common.h +0
-0@@ -156,6 +156,52 @@ typedef uint16_t unaligned_uint16_t;#define RTE_DEPRECATED (x)#endif Quoted 2 lines
lib/eal/include/rte_common.h typedef uint16_t unaligned_uint16_t; · line 160
Quoted 2 lines
lib/eal/include/rte_common.h +2
-0+/** +* Macros to cause the compiler to remember the state of the diagnostics as of
Quoted 15 lines
Quoted 15 lines
lib/eal/include/rte_common.h +15
-0+* each push, and restore to that point at each pop. +*/ +#if !defined(__INTEL_COMPILER) && !defined(RTE_TOOLCHAIN_MSVC ) +#define __rte_diagnostic_push _Pragma("GCC diagnostic push") +#define __rte_diagnostic_pop _Pragma("GCC diagnostic pop") +#else +#define __rte_diagnostic_push +#define __rte_diagnostic_pop +#endif + +/** +* Macro to disable compiler warnings about removing a type +* qualifier from the target type. +*/ +#if !defined(__INTEL_COMPILER) && !defined(RTE_TOOLCHAIN_MSVC )Quoted 8 lines
lib/eal/include/rte_common.h typedef uint16_t unaligned_uint16_t;
Quoted 8 lines
lib/eal/include/rte_common.h +8
-0+#define __rte_diagnostic_ignored_wcast_qual \ + _Pragma("GCC diagnostic ignored \"-Wcast-qual\"") +#else +#define __rte_diagnostic_ignored_wcast_qual +#endif + +/** +* Workaround to discard qualifiers (such as const, volatile, restrict) from a pointer,
Quoted 5 lines
lib/eal/include/rte_common.h typedef uint16_t unaligned_uint16_t; · line 186
Quoted 3 lines
lib/eal/include/rte_common.h +3
-0+* without the compiler emitting a warning. +*/ +#define RTE_PTR_UNQUAL (X ) ((void *)(uintptr_t)(X))It seems the C23
typeof_unqualand the built-in pre-C23
__typeof_unqual__couldn't be used.Quoted 1 line
Was it a generic issue, or only when operating on (the return value
of) functions?
I experimented with C23
typeof_unqual. It indeed works on gcc, clang and MSVC, but there are some details:a) With gcc the project needs to be compiled with -std=c2x. Many other warnings show up, unrelated to the scope of this patchset. Some look suspicious and should be looked at. An error also showed up, for which I sent out a small patch.
Quoted 5 lines
Quoted 3 lines
b) When using
typeof_unqualand passing "-Wcast-qual" to the compiler, a warning about the qualifier being dropped is emitted. The project currently uses "-Wcast-qual". Perhaps it shouldn't?The compiler is our friend; when more warnings enabled, the code quality requirements are higher.
I agree 100% with this.
Quoted 11 lines
Although this statement may not be universally true, I think it is for "-Wcast-qual".
Quoted 3 lines
Due to (a) I decided to not use
typeof_unqualfor now, but it would be trivial to change the macro to do so in the future.How about
__typeof_unqual__(with double underscores prefix and postfix)? It seems to be available in both GCC [1] and MSVC [2] without requiring C23.[1]: https://gcc.gnu.org/onlinedocs/gcc/Typeof.html
[2]: https://learn.microsoft.com/en-us/cpp/c-language/typeof-unqual-c?view=msvc-170
__typeof_unqual__ (with double underscores prefix and postfix) requires gcc-14. On gcc-13 this keyword is not defined.
It works exactly like C23 typeof_unqual: When -Wcast-qual is passed to the compiler a warning is emitted when discarding a qualifier from the pointer target type, which is treated as error in the DPDK build. Without -Wcast-qual it compiles cleanly.
Quoted 71 lines
Quoted 71 lines
Quoted 6 lines
lib/eal/include/rte_common.h typedef uint16_t unaligned_uint16_t;
Quoted 6 lines
lib/eal/include/rte_common.h +3
-0+ +/** +* Workaround to discard qualifiers (such as const, volatile, restrict) from a pointer
Quoted 1 line
lib/eal/include/rte_common.h typedef uint16_t unaligned_uint16_t; · line 190
Quoted 1 line
lib/eal/include/rte_common.h +1
-0+* and cast it to a specific type, without the compiler emitting a warning.
Quoted 2 lines
Propose new description with emphasis on casting rather than
discarding qualifiers:
Quoted 4 lines
Workaround to cast a pointer to a specific type,
without the compiler emitting a warning about discarding qualifiers.I'll update this.
Quoted 3 lines
lib/eal/include/rte_common.h typedef uint16_t unaligned_uint16_t;
Quoted 3 lines
lib/eal/include/rte_common.h +3
-0+* +* @warning +* Although this macro can be abused for casting a pointer to point to a different type,
Quoted 1 line
lib/eal/include/rte_common.h typedef uint16_t unaligned_uint16_t; · line 194
Quoted 1 line
lib/eal/include/rte_common.h +1
-0+* alignment may be incorrect when casting to point to a larger type. E.g.:
Quoted 6 lines
This macro is now meant for abuse, so propose softening the warning:
When casting a pointer to point to a larger type,
the resulting pointer may be misaligned,
which causes undefined behavior.I'll update this.
Quoted 9 lines
E.g.:
Quoted 7 lines
lib/eal/include/rte_common.h +7
-0+* struct s { +* uint16_t a; +* uint8_t b; +* uint8_t c; +* uint8_t d; +* } v; +* uint16_t * p = RTE_CAST_PTR(uint16_t *, &v.c); // "p" is not 16 bit aligned!
Quoted 6 lines
lib/eal/include/rte_common.h typedef uint16_t unaligned_uint16_t; · line 203
Quoted 2 lines
lib/eal/include/rte_common.h +2
-0+*/ +#define RTE_CAST_PTR (type, ptr) ((type)(uintptr_t)(ptr))I am somewhat concerned about these macros...
There's a good reason why MSVC doesn't allow casting to discard
qualifiers or changing the type like this.
Quoted 3 lines
If in doubt, read this:
https://www.trust-in-soft.com/resources/blogs/2020-04-06-gcc-always-assumes-aligned-pointer-accesses
Quoted 2 lines
We need these workarounds because DPDK currently contains code with
formally "undefined behavior".
Quoted 1 line
And instead of fixing the root causes, we choose the pragmatic
solution and introduce workarounds to allow it.
Quoted 2 lines
Would it be possible for the
RTE_CAST_PTRmacro to check if thecasted-to pointer changes from a smaller type to a larger type, and warn/fail if it does?
I'll think about it.
Quoted 3 lines
Should the use of these workaround macros be disallowed in new code? I.e. should checkpatches check for them?
We can certainly add a check to checkpatches.
Re: [PATCH v15 1/3] eal: add diagnostics macros to make code portable
In reply to Andre MuezerieQuoted 63 lines · On Tue, 21 Jan 2025 06:28:16 -0800 Andre Muezerie…
Quoted 53 lines · Morten Brørup
Quoted 53 lines
From: Andre Muezerie [mailto:[email protected]]
Sent: Saturday, 18 January 2025 22.55It was a common pattern to have "GCC diagnostic ignored" pragmas sprinkled over the code and only activate these pragmas for certain compilers (gcc and clang). Clang supports GCC's pragma for compatibility with existing source code, so #pragma GCC diagnostic and #pragma clang diagnostic are synonyms for Clang
(https://clang.llvm.org/docs/UsersManual.html).Now that effort is being made to make the code compatible with MSVC these expressions would become more complex. It makes sense to hide this complexity behind macros. This makes maintenance easier as these macros are defined in a single place. As a plus the code becomes more readable as well.
Signed-off-by Andre Muezerie <[email protected]>--- lib/eal/include/rte_common.h | 46 ++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+)lib/eal/include/rte_common.h +23
-0@@ -156,6 +156,52 @@ typedef uint16_t unaligned_uint16_t;#define RTE_DEPRECATED (x)#endif +/** +* Macros to cause the compiler to remember the state of the diagnostics as of +* each push, and restore to that point at each pop. +*/ +#if !defined(__INTEL_COMPILER) && !defined(RTE_TOOLCHAIN_MSVC ) +#define __rte_diagnostic_push _Pragma("GCC diagnostic push") +#define __rte_diagnostic_pop _Pragma("GCC diagnostic pop") +#else +#define __rte_diagnostic_push +#define __rte_diagnostic_pop +#endif + +/** +* Macro to disable compiler warnings about removing a type +* qualifier from the target type. +*/ +#if !defined(__INTEL_COMPILER) && !defined(RTE_TOOLCHAIN_MSVC ) +#define __rte_diagnostic_ignored_wcast_qual \ + _Pragma("GCC diagnostic ignored \"-Wcast-qual\"") +#else +#define __rte_diagnostic_ignored_wcast_qual +#endif +Quoted 8 lines
lib/eal/include/rte_common.h typedef uint16_t unaligned_uint16_t; · line 186
Quoted 5 lines
lib/eal/include/rte_common.h +5
-0+/** +* Workaround to discard qualifiers (such as const, volatile, restrict) from a pointer, +* without the compiler emitting a warning. +*/ +#define RTE_PTR_UNQUAL (X ) ((void *)(uintptr_t)(X))It seems the C23
typeof_unqualand the built-in pre-C23__typeof_unqual__couldn't be used. Was it a generic issue, or only when operating on (the return value of) functions?
Quoted 7 lines
I experimented with C23
typeof_unqual. It indeed works on gcc, clang and MSVC, but there are some details:a) With gcc the project needs to be compiled with -std=c2x. Many other warnings show up, unrelated to the scope of this patchset. Some look suspicious and should be looked at. An error also showed up, for which I sent out a small patch.
b) When using
typeof_unqualand passing "-Wcast-qual" to the compiler, a warning about the qualifier being dropped is emitted. The project currently uses "-Wcast-qual". Perhaps it shouldn't?Due to (a) I decided to not use
typeof_unqualfor now, but it would be trivial to change the macro to do so in the future.
Be careful, C23 changes some things like default initialization of padding bits. Might break other stuff.
PATCH v15 2/3 drivers/common: add diagnostics macros to make code portable
In reply to Andre MuezerieIt was a common pattern to have "GCC diagnostic ignored" pragmas sprinkled over the code and only activate these pragmas for certain compilers (gcc and clang). Clang supports GCC's pragma for compatibility with existing source code, so #pragma GCC diagnostic and #pragma clang diagnostic are synonyms for Clang
(https://clang.llvm.org/docs/UsersManual.html).
Now that effort is being made to make the code compatible with MSVC these expressions would become more complex. It makes sense to hide this complexity behind macros. This makes maintenance easier as these macros are defined in a single place. As a plus the code becomes more readable as well.
--- drivers/common/idpf/idpf_common_rxtx_avx512.c | 72 +++++++++---------- 1 file changed, 34 insertions(+), 38 deletions(-)
drivers/common/idpf/idpf_common_rxtx_avx512.c +34 -38
@@ -6,10 +6,6 @@#include "idpf_common_device.h" #include "idpf_common_rxtx.h" -#ifndef __INTEL_COMPILER -#pragma GCC diagnostic ignored "-Wcast-qual" -#endif -#define IDPF_DESCS_PER_LOOP_AVX 8#define PKTLEN_SHIFT 10
@@ -34,7 +30,7 @@ idpf_singleq_rearm_common(struct idpf_rx_queue *rxq) dma_addr0 =_mm_setzero_si128 ();for (i =0 ; i <IDPF_VPMD_DESCS_PER_LOOP ; i++) { rxp[i] = &rxq->fake_mbuf; -_mm_store_si128 ((__m128i *)&rxdp[i].read, + _mm_store_si128(RTE_CAST_PTR(__m128i *, &rxdp[i].read), dma_addr0); } }
@@ -108,8 +104,8 @@ idpf_singleq_rearm_common(struct idpf_rx_queue *rxq) dma_addr4_7 =_mm512_add_epi64 (dma_addr4_7, hdr_room);/* flush desc with pa dma_addr */ -_mm512_store_si512 ((__m512i *)&rxdp->read, dma_addr0_3); -_mm512_store_si512 ((__m512i *)&(rxdp +4 )->read, dma_addr4_7); + _mm512_store_si512(RTE_CAST_PTR(__m512i *, &rxdp->read), dma_addr0_3); + _mm512_store_si512(RTE_CAST_PTR(__m512i *, &(rxdp + 4)->read), dma_addr4_7); } rxq->rxrearm_start +=IDPF_RXQ_REARM_THRESH ;
@@ -164,8 +160,8 @@ idpf_singleq_rearm(struct idpf_rx_queue *rxq) dma_addr0 =_mm_setzero_si128 ();for (i =0 ; i <IDPF_VPMD_DESCS_PER_LOOP ; i++) { rxp[i] = &rxq->fake_mbuf; -_mm_storeu_si128 ((__m128i *)&rxdp[i].read, - dma_addr0); + _mm_storeu_si128(RTE_CAST_PTR + (__m128i *, &rxdp[i].read), dma_addr0); } } rte_atomic_fetch_add_explicit(&rxq->rx_stats.mbuf_alloc_failed,
@@ -216,10 +212,10 @@ idpf_singleq_rearm(struct idpf_rx_queue *rxq) iovas1);const __m512i desc6_7 =_mm512_bsrli_epi128 (desc4_5,8 ); -_mm512_storeu_si512 ((void *)rxdp, desc0_1); -_mm512_storeu_si512 ((void *)(rxdp +2 ), desc2_3); -_mm512_storeu_si512 ((void *)(rxdp +4 ), desc4_5); -_mm512_storeu_si512 ((void *)(rxdp +6 ), desc6_7); + _mm512_storeu_si512(RTE_CAST_PTR(void *, rxdp), desc0_1); + _mm512_storeu_si512(RTE_CAST_PTR(void *, (rxdp + 2)), desc2_3); + _mm512_storeu_si512(RTE_CAST_PTR(void *, (rxdp + 4)), desc4_5); + _mm512_storeu_si512(RTE_CAST_PTR(void *, (rxdp + 6)), desc6_7); rxp +=IDPF_DESCS_PER_LOOP_AVX ; rxdp +=IDPF_DESCS_PER_LOOP_AVX ;
@@ -337,28 +333,28 @@ _idpf_singleq_recv_raw_pkts_avx512(struct idpf_rx_queue *rxq,__m512i raw_desc0_3, raw_desc4_7;const __m128i raw_desc7 = -_mm_load_si128 ((void *)(rxdp +7 )); + _mm_load_si128(RTE_CAST_PTR(const __m128i *, rxdp + 7));rte_compiler_barrier ();const __m128i raw_desc6 = -_mm_load_si128 ((void *)(rxdp +6 )); + _mm_load_si128(RTE_CAST_PTR(const __m128i *, rxdp + 6));rte_compiler_barrier ();const __m128i raw_desc5 = -_mm_load_si128 ((void *)(rxdp +5 )); + _mm_load_si128(RTE_CAST_PTR(const __m128i *, rxdp + 5));rte_compiler_barrier ();const __m128i raw_desc4 = -_mm_load_si128 ((void *)(rxdp +4 )); + _mm_load_si128(RTE_CAST_PTR(const __m128i *, rxdp + 4));rte_compiler_barrier ();const __m128i raw_desc3 = -_mm_load_si128 ((void *)(rxdp +3 )); + _mm_load_si128(RTE_CAST_PTR(const __m128i *, rxdp + 3));rte_compiler_barrier ();const __m128i raw_desc2 = -_mm_load_si128 ((void *)(rxdp +2 )); + _mm_load_si128(RTE_CAST_PTR(const __m128i *, rxdp + 2));rte_compiler_barrier ();const __m128i raw_desc1 = -_mm_load_si128 ((void *)(rxdp +1 )); + _mm_load_si128(RTE_CAST_PTR(const __m128i *, rxdp + 1));rte_compiler_barrier ();const __m128i raw_desc0 = -_mm_load_si128 ((void *)(rxdp +0 )); + _mm_load_si128(RTE_CAST_PTR(const __m128i *, rxdp + 0)); raw_desc4_7 =_mm512_broadcast_i32x4 (raw_desc4); raw_desc4_7 =_mm512_inserti32x4 (raw_desc4_7, raw_desc5,1 );
@@ -560,7 +556,7 @@ idpf_splitq_rearm_common(struct idpf_rx_queue *rx_bufq) dma_addr0 =_mm_setzero_si128 ();for (i =0 ; i <IDPF_VPMD_DESCS_PER_LOOP ; i++) { rxp[i] = &rx_bufq->fake_mbuf; -_mm_store_si128 ((__m128i *)&rxdp[i], + _mm_store_si128(RTE_CAST_PTR(__m128i *, &rxdp[i]), dma_addr0); } }
@@ -634,7 +630,7 @@ idpf_splitq_rearm(struct idpf_rx_queue *rx_bufq) dma_addr0 =_mm_setzero_si128 ();for (i =0 ; i <IDPF_VPMD_DESCS_PER_LOOP ; i++) { rxp[i] = &rx_bufq->fake_mbuf; -_mm_storeu_si128 ((__m128i *)&rxdp[i], + _mm_storeu_si128(RTE_CAST_PTR(__m128i *, &rxdp[i]), dma_addr0); } }
@@ -798,28 +794,28 @@ _idpf_splitq_recv_raw_pkts_avx512(struct idpf_rx_queue *rxq,__m512i raw_desc0_3, raw_desc4_7;const __m128i raw_desc7 = -_mm_load_si128 ((void *)(rxdp +7 )); + _mm_load_si128(RTE_CAST_PTR(const __m128i *, rxdp + 7));rte_compiler_barrier ();const __m128i raw_desc6 = -_mm_load_si128 ((void *)(rxdp +6 )); + _mm_load_si128(RTE_CAST_PTR(const __m128i *, rxdp + 6));rte_compiler_barrier ();const __m128i raw_desc5 = -_mm_load_si128 ((void *)(rxdp +5 )); + _mm_load_si128(RTE_CAST_PTR(const __m128i *, rxdp + 5));rte_compiler_barrier ();const __m128i raw_desc4 = -_mm_load_si128 ((void *)(rxdp +4 )); + _mm_load_si128(RTE_CAST_PTR(const __m128i *, rxdp + 4));rte_compiler_barrier ();const __m128i raw_desc3 = -_mm_load_si128 ((void *)(rxdp +3 )); + _mm_load_si128(RTE_CAST_PTR(const __m128i *, rxdp + 3));rte_compiler_barrier ();const __m128i raw_desc2 = -_mm_load_si128 ((void *)(rxdp +2 )); + _mm_load_si128(RTE_CAST_PTR(const __m128i *, rxdp + 2));rte_compiler_barrier ();const __m128i raw_desc1 = -_mm_load_si128 ((void *)(rxdp +1 )); + _mm_load_si128(RTE_CAST_PTR(const __m128i *, rxdp + 1));rte_compiler_barrier ();const __m128i raw_desc0 = -_mm_load_si128 ((void *)(rxdp +0 )); + _mm_load_si128(RTE_CAST_PTR(const __m128i *, rxdp + 0)); raw_desc4_7 =_mm512_broadcast_i32x4 (raw_desc4); raw_desc4_7 =_mm512_inserti32x4 (raw_desc4_7, raw_desc5,1 );
@@ -1131,7 +1127,7 @@ idpf_singleq_vtx1(volatile struct idpf_base_tx_desc *txdp,__m128i descriptor =_mm_set_epi64x (high_qw, pkt->buf_iova + pkt->data_off); -_mm_storeu_si128 ((__m128i *)txdp, descriptor); + _mm_storeu_si128(RTE_CAST_PTR(__m128i *, txdp), descriptor); }#define IDPF_TX_LEN_MASK 0xAA
@@ -1178,7 +1174,7 @@ idpf_singleq_vtx(volatile struct idpf_base_tx_desc *txdp, pkt[1 ]->buf_iova + pkt[1 ]->data_off, hi_qw0, pkt[0]->buf_iova + pkt[0]->data_off); -_mm512_storeu_si512 ((void *)txdp, desc0_3); + _mm512_storeu_si512(RTE_CAST_PTR(void *, txdp), desc0_3); }/* do any last ones */
@@ -1435,7 +1431,7 @@ idpf_splitq_vtx1(volatile struct idpf_flex_tx_sched_desc *txdp,__m128i descriptor =_mm_set_epi64x (high_qw, pkt->buf_iova + pkt->data_off); -_mm_storeu_si128 ((__m128i *)txdp, descriptor); + _mm_storeu_si128(RTE_CAST_PTR(__m128i *, txdp), descriptor); }static __rte_always_inline void
@@ -1480,7 +1476,7 @@ idpf_splitq_vtx(volatile struct idpf_flex_tx_sched_desc *txdp, pkt[1 ]->buf_iova + pkt[1 ]->data_off, hi_qw0, pkt[0]->buf_iova + pkt[0]->data_off); -_mm512_storeu_si512 ((void *)txdp, desc0_3); + _mm512_storeu_si512(RTE_CAST_PTR(void *, txdp), desc0_3); }/* do any last ones */
@@ -1521,11 +1517,11 @@ idpf_splitq_xmit_fixed_burst_vec_avx512(void *tx_queue, struct rte_mbuf **tx_pktif (nb_commit >= n) {tx_backlog_entry_avx512 (txep, tx_pkts, n); -idpf_splitq_vtx ((void *)txdp, tx_pkts, n -1 , cmd_dtype); +idpf_splitq_vtx (txdp, tx_pkts, n -1 , cmd_dtype); tx_pkts += (n -1 ); txdp += (n -1 ); -idpf_splitq_vtx1 ((void *)txdp, *tx_pkts++, cmd_dtype); +idpf_splitq_vtx1 (txdp, *tx_pkts++, cmd_dtype); nb_commit = (uint16_t )(nb_commit - n);
@@ -1540,7 +1536,7 @@ idpf_splitq_xmit_fixed_burst_vec_avx512(void *tx_queue, struct rte_mbuf **tx_pkttx_backlog_entry_avx512 (txep, tx_pkts, nb_commit); -idpf_splitq_vtx ((void *)txdp, tx_pkts, nb_commit, cmd_dtype); +idpf_splitq_vtx (txdp, tx_pkts, nb_commit, cmd_dtype); tx_id = (uint16_t )(tx_id + nb_commit);if (tx_id > txq->next_rs)
Signature · 1 line
2.47.2.vfs.0.1
PATCH v15 3/3 drivers/net: add diagnostics macros to make code portable
In reply to Andre MuezerieIt was a common pattern to have "GCC diagnostic ignored" pragmas sprinkled over the code and only activate these pragmas for certain compilers (gcc and clang). Clang supports GCC's pragma for compatibility with existing source code, so #pragma GCC diagnostic and #pragma clang diagnostic are synonyms for Clang
(https://clang.llvm.org/docs/UsersManual.html).
Now that effort is being made to make the code compatible with MSVC these expressions would become more complex. It makes sense to hide this complexity behind macros. This makes maintenance easier as these macros are defined in a single place. As a plus the code becomes more readable as well.
--- drivers/net/axgbe/axgbe_rxtx.h | 9 --- drivers/net/cpfl/cpfl_rxtx_vec_common.h | 4 - drivers/net/dpaa2/dpaa2_rxtx.c | 15 +--- drivers/net/fm10k/fm10k_rxtx_vec.c | 21 ++---- drivers/net/hns3/hns3_rxtx_vec_neon.h | 6 +- .../net/i40e/i40e_recycle_mbufs_vec_common.c | 2 - drivers/net/i40e/i40e_rxtx_common_avx.h | 22 +++--- drivers/net/i40e/i40e_rxtx_vec_altivec.c | 18 ++--- drivers/net/i40e/i40e_rxtx_vec_avx2.c | 30 ++++---- drivers/net/i40e/i40e_rxtx_vec_avx512.c | 28 +++---- drivers/net/i40e/i40e_rxtx_vec_common.h | 4 - drivers/net/i40e/i40e_rxtx_vec_neon.c | 35 ++++----- drivers/net/i40e/i40e_rxtx_vec_sse.c | 28 +++---- drivers/net/iavf/iavf_rxtx_vec_avx2.c | 60 +++++++-------- drivers/net/iavf/iavf_rxtx_vec_avx512.c | 62 ++++++++-------- drivers/net/iavf/iavf_rxtx_vec_common.h | 10 +-- drivers/net/iavf/iavf_rxtx_vec_neon.c | 22 +++--- drivers/net/iavf/iavf_rxtx_vec_sse.c | 38 +++++----- drivers/net/ice/ice_rxtx_common_avx.h | 18 ++--- drivers/net/ice/ice_rxtx_vec_avx2.c | 74 +++++++++---------- drivers/net/ice/ice_rxtx_vec_avx512.c | 64 +++++++--------- drivers/net/ice/ice_rxtx_vec_common.h | 4 - drivers/net/ice/ice_rxtx_vec_sse.c | 28 +++---- drivers/net/idpf/idpf_rxtx_vec_common.h | 4 - .../ixgbe/ixgbe_recycle_mbufs_vec_common.c | 2 - drivers/net/ixgbe/ixgbe_rxtx_vec_neon.c | 18 ++--- drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c | 20 ++--- drivers/net/mlx5/mlx5_flow.c | 5 +- drivers/net/mlx5/mlx5_rxtx_vec_altivec.h | 5 -- drivers/net/mlx5/mlx5_rxtx_vec_neon.h | 18 ++--- drivers/net/mlx5/mlx5_rxtx_vec_sse.h | 61 ++++++++------- drivers/net/ngbe/ngbe_rxtx_vec_neon.c | 8 +- drivers/net/tap/tap_flow.c | 6 +- drivers/net/txgbe/txgbe_rxtx_vec_neon.c | 8 +- drivers/net/virtio/virtio_rxtx_simple.c | 4 - 35 files changed, 316 insertions(+), 445 deletions(-)
drivers/net/axgbe/axgbe_rxtx.h +0 -9
@@ -6,15 +6,6 @@#ifndef _AXGBE_RXTX_H_#define _AXGBE_RXTX_H_ -/* to suppress gcc warnings related to descriptor casting*/ -#ifdef RTE_TOOLCHAIN_GCC -#pragma GCC diagnostic ignored "-Wcast-qual" -#endif - -#ifdef RTE_TOOLCHAIN_CLANG -#pragma GCC diagnostic ignored "-Wcast-qual" -#endif -/* Descriptor related defines */ #define AXGBE_MAX_RING_DESC 4096/*should be power of 2*/ #define AXGBE_TX_DESC_MIN_FREE (AXGBE_MAX_RING_DESC >> 3)
drivers/net/cpfl/cpfl_rxtx_vec_common.h +0 -4
@@ -11,10 +11,6 @@#include "cpfl_ethdev.h" #include "cpfl_rxtx.h" -#ifndef __INTEL_COMPILER -#pragma GCC diagnostic ignored "-Wcast-qual" -#endif -#define CPFL_SCALAR_PATH 0#define CPFL_VECTOR_PATH 1#define CPFL_RX_NO_VECTOR_FLAGS ( \
drivers/net/dpaa2/dpaa2_rxtx.c +1 -14
@@ -1962,14 +1962,6 @@ dpaa2_dev_tx_ordered(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)return num_tx; } -#if defined(RTE_TOOLCHAIN_GCC ) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wcast-qual" -#elif defined(RTE_TOOLCHAIN_CLANG ) -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wcast-qual" -#endif -/* This function loopbacks all the received packets.*/ uint16_t dpaa2_dev_loopback_rx(void *queue,
@@ -2083,7 +2075,7 @@ dpaa2_dev_loopback_rx(void *queue,if (unlikely ((status &QBMAN_DQ_STAT_VALIDFRAME ) ==0 ))continue ; } - fd[num_rx] = (struct qbman_fd *)qbman_result_DQ_fd (dq_storage); + fd[num_rx] =RTE_PTR_UNQUAL (qbman_result_DQ_fd (dq_storage)); dq_storage++; num_rx++;
@@ -2118,8 +2110,3 @@ dpaa2_dev_loopback_rx(void *queue,return 0 ; } -#if defined(RTE_TOOLCHAIN_GCC ) -#pragma GCC diagnostic pop -#elif defined(RTE_TOOLCHAIN_CLANG ) -#pragma clang diagnostic pop -#endif
drivers/net/fm10k/fm10k_rxtx_vec.c +8 -13
@@ -11,10 +11,6 @@#include <rte_vect.h> -#ifndef __INTEL_COMPILER -#pragma GCC diagnostic ignored "-Wcast-qual" -#endif -static void fm10k_reset_tx_queue (struct fm10k_tx_queue *txq);
@@ -270,8 +266,7 @@ fm10k_rxq_rearm(struct fm10k_rx_queue *rxq)/* Clean up all the HW/SW ring content */ for (i =0 ; i <RTE_FM10K_RXQ_REARM_THRESH ; i++) { mb_alloc[i] = &rxq->fake_mbuf; -_mm_store_si128 ((__m128i *)&rxdp[i].q, - dma_addr0); + _mm_store_si128(RTE_CAST_PTR(__m128i *, &rxdp[i].q), dma_addr0); } rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
@@ -316,8 +311,8 @@ fm10k_rxq_rearm(struct fm10k_rx_queue *rxq) dma_addr1 =_mm_and_si128 (dma_addr1, hba_msk);/* flush desc with pa dma_addr */ -_mm_store_si128 ((__m128i *)&rxdp++->q, dma_addr0); -_mm_store_si128 ((__m128i *)&rxdp++->q, dma_addr1); + _mm_store_si128(RTE_CAST_PTR(__m128i *, &rxdp++->q), dma_addr0); + _mm_store_si128(RTE_CAST_PTR(__m128i *, &rxdp++->q), dma_addr1);/* enforce 512B alignment on default Rx virtual addresses */ mb0->data_off = (uint16_t)(RTE_PTR_ALIGN((char *)mb0->buf_addr
@@ -465,7 +460,7 @@ fm10k_recv_raw_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,/* Read desc statuses backwards to avoid race condition */ /* A.1 load desc[3] */ - descs0[3 ] =_mm_loadu_si128 ((__m128i *)(rxdp +3 )); + descs0[3] = _mm_loadu_si128(RTE_CAST_PTR(__m128i *, rxdp + 3));rte_compiler_barrier ();/* B.2 copy 2 64 bit or 4 32 bit mbuf point into rx_pkts */
@@ -477,11 +472,11 @@ fm10k_recv_raw_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,#endif /* A.1 load desc[2-0] */ - descs0[2 ] =_mm_loadu_si128 ((__m128i *)(rxdp +2 )); + descs0[2] = _mm_loadu_si128(RTE_CAST_PTR(__m128i *, rxdp + 2));rte_compiler_barrier (); - descs0[1 ] =_mm_loadu_si128 ((__m128i *)(rxdp +1 )); + descs0[1] = _mm_loadu_si128(RTE_CAST_PTR(__m128i *, rxdp + 1));rte_compiler_barrier (); - descs0[0 ] =_mm_loadu_si128 ((__m128i *)(rxdp)); + descs0[0] = _mm_loadu_si128(RTE_CAST_PTR(__m128i *, rxdp));#if defined(RTE_ARCH_X86_64 )/* B.2 copy 2 mbuf point into rx_pkts */
@@ -736,7 +731,7 @@ vtx1(volatile struct fm10k_tx_desc *txdp,__m128i descriptor =_mm_set_epi64x (flags <<56 | (uint64_t )pkt->vlan_tci <<16 | (uint64_t )pkt->data_len,MBUF_DMA_ADDR (pkt)); -_mm_store_si128 ((__m128i *)txdp, descriptor); + _mm_store_si128(RTE_CAST_PTR(__m128i *, txdp), descriptor); } static inline void
drivers/net/hns3/hns3_rxtx_vec_neon.h +2 -4
@@ -9,8 +9,6 @@#include <arm_neon.h> -#pragma GCC diagnostic ignored "-Wcast-qual" -static inline void hns3_vec_tx (volatile struct hns3_desc *desc,struct rte_mbuf *pkt) {
@@ -22,8 +20,8 @@ hns3_vec_tx(volatile struct hns3_desc *desc, struct rte_mbuf *pkt)0 , ((uint64_t )HNS3_TXD_DEFAULT_VLD_FE_BDTYPE ) <<HNS3_UINT32_BIT }; -vst1q_u64 ((uint64_t *)&desc->addr, val1); -vst1q_u64 ((uint64_t *)&desc->tx.outer_vlan_tag, val2); + vst1q_u64(RTE_CAST_PTR(uint64_t *, &desc->addr), val1); + vst1q_u64(RTE_CAST_PTR(uint64_t *, &desc->tx.outer_vlan_tag), val2); } static uint16_t
drivers/net/i40e/i40e_recycle_mbufs_vec_common.c +0 -2
@@ -10,8 +10,6 @@#include "i40e_ethdev.h" #include "i40e_rxtx.h" -#pragma GCC diagnostic ignored "-Wcast-qual" -void i40e_recycle_rx_descriptors_refill_vec (void *rx_queue,uint16_t nb_mbufs) {
drivers/net/i40e/i40e_rxtx_common_avx.h +11 -11
@@ -11,10 +11,6 @@#include "i40e_ethdev.h" #include "i40e_rxtx.h" -#ifndef __INTEL_COMPILER -#pragma GCC diagnostic ignored "-Wcast-qual" -#endif -#ifdef __AVX2__ static __rte_always_inline void i40e_rxq_rearm_common(struct i40e_rx_queue *rxq, __rte_unused bool avx512)
@@ -36,7 +32,7 @@ i40e_rxq_rearm_common(struct i40e_rx_queue *rxq, __rte_unused bool avx512) dma_addr0 =_mm_setzero_si128 ();for (i =0 ; i <RTE_I40E_DESCS_PER_LOOP ; i++) { rxep[i].mbuf = &rxq->fake_mbuf; -_mm_store_si128 ((__m128i *)&rxdp[i].read, + _mm_store_si128(RTE_CAST_PTR(__m128i *, &rxdp[i].read), dma_addr0); } }
@@ -72,8 +68,8 @@ i40e_rxq_rearm_common(struct i40e_rx_queue *rxq, __rte_unused bool avx512) dma_addr1 =_mm_add_epi64 (dma_addr1, hdr_room);/* flush desc with pa dma_addr */ -_mm_store_si128 ((__m128i *)&rxdp++->read, dma_addr0); - _mm_store_si128((__m128i *)&rxdp++->read, dma_addr1); + _mm_store_si128(RTE_CAST_PTR(__m128i *, &rxdp++->read), dma_addr0); + _mm_store_si128(RTE_CAST_PTR(__m128i *, &rxdp++->read), dma_addr1); }#else #ifdef __AVX512VL__
@@ -144,8 +140,10 @@ i40e_rxq_rearm_common(struct i40e_rx_queue *rxq, __rte_unused bool avx512) dma_addr4_7 =_mm512_add_epi64 (dma_addr4_7, hdr_room);/* flush desc with pa dma_addr */ -_mm512_store_si512 ((__m512i *)&rxdp->read, dma_addr0_3); - _mm512_store_si512((__m512i *)&(rxdp + 4)->read, dma_addr4_7); + _mm512_store_si512(RTE_CAST_PTR(__m512i *, + &rxdp->read), dma_addr0_3); + _mm512_store_si512(RTE_CAST_PTR(__m512i *, + &(rxdp + 4)->read), dma_addr4_7); } } else#endif /* __AVX512VL__*/
@@ -190,8 +188,10 @@ i40e_rxq_rearm_common(struct i40e_rx_queue *rxq, __rte_unused bool avx512) dma_addr2_3 =_mm256_add_epi64 (dma_addr2_3, hdr_room);/* flush desc with pa dma_addr */ -_mm256_store_si256 ((__m256i *)&rxdp->read, dma_addr0_1); -_mm256_store_si256 ((__m256i *)&(rxdp +2 )->read, dma_addr2_3); + _mm256_store_si256(RTE_CAST_PTR(__m256i *, + &rxdp->read), dma_addr0_1); + _mm256_store_si256(RTE_CAST_PTR(__m256i *, + &(rxdp + 2)->read), dma_addr2_3); } }
drivers/net/i40e/i40e_rxtx_vec_altivec.c +8 -10
@@ -15,8 +15,6 @@#include <rte_altivec.h> -#pragma GCC diagnostic ignored "-Wcast-qual" -static inline void i40e_rxq_rearm (struct i40e_rx_queue *rxq) {
@@ -44,7 +42,7 @@ i40e_rxq_rearm(struct i40e_rx_queue *rxq)for (i =0 ; i <RTE_I40E_DESCS_PER_LOOP ; i++) { rxep[i].mbuf = &rxq->fake_mbuf;vec_st (dma_addr0,0 , - (__vector unsigned long *)&rxdp[i].read); + RTE_CAST_PTR(__vector unsigned long *, &rxdp[i].read)); } } rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
@@ -84,8 +82,8 @@ i40e_rxq_rearm(struct i40e_rx_queue *rxq) dma_addr1 =vec_add (dma_addr1, hdr_room);/* flush desc with pa dma_addr */ -vec_st (dma_addr0,0 , (__vector unsigned long *)&rxdp++->read); -vec_st (dma_addr1,0 , (__vector unsigned long *)&rxdp++->read); + vec_st(dma_addr0, 0, RTE_CAST_PTR(__vector unsigned long *, &rxdp++->read)); + vec_st(dma_addr1, 0, RTE_CAST_PTR(__vector unsigned long *, &rxdp++->read)); } rxq->rxrearm_start +=RTE_I40E_RXQ_REARM_THRESH ;
@@ -286,7 +284,7 @@ _recv_raw_pkts_vec(struct i40e_rx_queue *rxq, struct rte_mbuf **rx_pkts, mbp1 = *(__vector unsigned long *)&sw_ring[pos];/* Read desc statuses backwards to avoid race condition */ /* A.1 load desc[3] */ - descs[3 ] = *(__vector unsigned long *)(rxdp +3 ); + descs[3] = *RTE_CAST_PTR(__vector unsigned long *, rxdp + 3);rte_compiler_barrier ();/* B.2 copy 2 mbuf point into rx_pkts */
@@ -296,11 +294,11 @@ _recv_raw_pkts_vec(struct i40e_rx_queue *rxq, struct rte_mbuf **rx_pkts, mbp2 = *(__vector unsigned long *)&sw_ring[pos +2 ];/* A.1 load desc[2-0] */ - descs[2 ] = *(__vector unsigned long *)(rxdp +2 ); + descs[2] = *RTE_CAST_PTR(__vector unsigned long *, rxdp + 2);rte_compiler_barrier (); - descs[1 ] = *(__vector unsigned long *)(rxdp +1 ); + descs[1] = *RTE_CAST_PTR(__vector unsigned long *, rxdp + 1);rte_compiler_barrier (); - descs[0 ] = *(__vector unsigned long *)(rxdp); + descs[0] = *RTE_CAST_PTR(__vector unsigned long *, rxdp);/* B.2 copy 2 mbuf point into rx_pkts */ *(__vector unsigned long *)&rx_pkts[pos +2 ] = mbp2;
@@ -534,7 +532,7 @@ vtx1(volatile struct i40e_tx_desc *txdp,__vector unsigned long descriptor = (__vector unsigned long ){ pkt->buf_iova + pkt->data_off, high_qw}; - *(__vector unsigned long *)txdp = descriptor; + *RTE_CAST_PTR(__vector unsigned long *, txdp) = descriptor; } static inline void
drivers/net/i40e/i40e_rxtx_vec_avx2.c +13 -17
@@ -15,10 +15,6 @@#include <rte_vect.h> -#ifndef __INTEL_COMPILER -#pragma GCC diagnostic ignored "-Wcast-qual" -#endif - static __rte_always_inline voidi40e_rxq_rearm (struct i40e_rx_queue *rxq) {
@@ -39,8 +35,8 @@ desc_fdir_processing_32b(volatile union i40e_rx_desc *rxdp, const uint32_t desc_idx) {/* 32B desc path: load rxdp.wb.qword2 for EXT_STATUS and FLEXBH_STAT */ -__m128i *rxdp_desc_0 = (void *)(&rxdp[desc_idx +0 ].wb.qword2); -__m128i *rxdp_desc_1 = (void *)(&rxdp[desc_idx +1 ].wb.qword2); + __m128i *rxdp_desc_0 = RTE_CAST_PTR(__m128i *, &rxdp[desc_idx + 0].wb.qword2); + __m128i *rxdp_desc_1 = RTE_CAST_PTR(__m128i *, &rxdp[desc_idx + 1].wb.qword2);const __m128i desc_qw2_0 =_mm_load_si128 (rxdp_desc_0);const __m128i desc_qw2_1 =_mm_load_si128 (rxdp_desc_1);
@@ -276,21 +272,21 @@ _recv_raw_pkts_vec_avx2(struct i40e_rx_queue *rxq, struct rte_mbuf **rx_pkts, _mm256_loadu_si256((void *)&sw_ring[i + 4]));#endif -const __m128i raw_desc7 =_mm_load_si128 ((void *)(rxdp +7 )); + const __m128i raw_desc7 = _mm_load_si128(RTE_CAST_PTR(const __m128i *, rxdp + 7));rte_compiler_barrier (); -const __m128i raw_desc6 =_mm_load_si128 ((void *)(rxdp +6 )); + const __m128i raw_desc6 = _mm_load_si128(RTE_CAST_PTR(const __m128i *, rxdp + 6));rte_compiler_barrier (); -const __m128i raw_desc5 =_mm_load_si128 ((void *)(rxdp +5 )); + const __m128i raw_desc5 = _mm_load_si128(RTE_CAST_PTR(const __m128i *, rxdp + 5));rte_compiler_barrier (); -const __m128i raw_desc4 =_mm_load_si128 ((void *)(rxdp +4 )); + const __m128i raw_desc4 = _mm_load_si128(RTE_CAST_PTR(const __m128i *, rxdp + 4));rte_compiler_barrier (); -const __m128i raw_desc3 =_mm_load_si128 ((void *)(rxdp +3 )); + const __m128i raw_desc3 = _mm_load_si128(RTE_CAST_PTR(const __m128i *, rxdp + 3));rte_compiler_barrier (); -const __m128i raw_desc2 =_mm_load_si128 ((void *)(rxdp +2 )); + const __m128i raw_desc2 = _mm_load_si128(RTE_CAST_PTR(const __m128i *, rxdp + 2));rte_compiler_barrier (); -const __m128i raw_desc1 =_mm_load_si128 ((void *)(rxdp +1 )); + const __m128i raw_desc1 = _mm_load_si128(RTE_CAST_PTR(const __m128i *, rxdp + 1));rte_compiler_barrier (); -const __m128i raw_desc0 =_mm_load_si128 ((void *)(rxdp +0 )); + const __m128i raw_desc0 = _mm_load_si128(RTE_CAST_PTR(const __m128i *, rxdp + 0));const __m256i raw_desc6_7 =_mm256_inserti128_si256 (_mm256_castsi128_si256 (raw_desc6), raw_desc7,1 );
@@ -695,7 +691,7 @@ vtx1(volatile struct i40e_tx_desc *txdp,__m128i descriptor =_mm_set_epi64x (high_qw, pkt->buf_iova + pkt->data_off); -_mm_store_si128 ((__m128i *)txdp, descriptor); + _mm_store_si128(RTE_CAST_PTR(__m128i *, txdp), descriptor); } static inline void
@@ -728,8 +724,8 @@ vtx(volatile struct i40e_tx_desc *txdp,__m256i desc0_1 =_mm256_set_epi64x ( hi_qw1, pkt[1 ]->buf_iova + pkt[1 ]->data_off, hi_qw0, pkt[0 ]->buf_iova + pkt[0 ]->data_off); -_mm256_store_si256 ((void *)(txdp +2 ), desc2_3); -_mm256_store_si256 ((void *)txdp, desc0_1); + _mm256_store_si256(RTE_CAST_PTR(__m256i *, txdp + 2), desc2_3); + _mm256_store_si256(RTE_CAST_PTR(__m256i *, txdp), desc0_1); }/* do any last ones */
drivers/net/i40e/i40e_rxtx_vec_avx512.c +12 -16
@@ -15,10 +15,6 @@#include <rte_vect.h> -#ifndef __INTEL_COMPILER -#pragma GCC diagnostic ignored "-Wcast-qual" -#endif -#define RTE_I40E_DESCS_PER_LOOP_AVX 8static __rte_always_inline void
@@ -41,8 +37,8 @@ desc_fdir_processing_32b(volatile union i40e_rx_desc *rxdp, const uint32_t desc_idx) {/* 32B desc path: load rxdp.wb.qword2 for EXT_STATUS and FLEXBH_STAT */ -__m128i *rxdp_desc_0 = (void *)(&rxdp[desc_idx +0 ].wb.qword2); -__m128i *rxdp_desc_1 = (void *)(&rxdp[desc_idx +1 ].wb.qword2); + __m128i *rxdp_desc_0 = RTE_CAST_PTR(__m128i *, &rxdp[desc_idx + 0].wb.qword2); + __m128i *rxdp_desc_1 = RTE_CAST_PTR(__m128i *, &rxdp[desc_idx + 1].wb.qword2);const __m128i desc_qw2_0 =_mm_load_si128 (rxdp_desc_0);const __m128i desc_qw2_1 =_mm_load_si128 (rxdp_desc_1);
@@ -264,28 +260,28 @@ _recv_raw_pkts_vec_avx512(struct i40e_rx_queue *rxq, struct rte_mbuf **rx_pkts,/* load in descriptors, in reverse order */ const __m128i raw_desc7 = -_mm_load_si128 ((void *)(rxdp +7 )); + _mm_load_si128(RTE_CAST_PTR(const __m128i *, rxdp + 7));rte_compiler_barrier ();const __m128i raw_desc6 = -_mm_load_si128 ((void *)(rxdp +6 )); + _mm_load_si128(RTE_CAST_PTR(const __m128i *, rxdp + 6));rte_compiler_barrier ();const __m128i raw_desc5 = -_mm_load_si128 ((void *)(rxdp +5 )); + _mm_load_si128(RTE_CAST_PTR(const __m128i *, rxdp + 5));rte_compiler_barrier ();const __m128i raw_desc4 = -_mm_load_si128 ((void *)(rxdp +4 )); + _mm_load_si128(RTE_CAST_PTR(const __m128i *, rxdp + 4));rte_compiler_barrier ();const __m128i raw_desc3 = -_mm_load_si128 ((void *)(rxdp +3 )); + _mm_load_si128(RTE_CAST_PTR(const __m128i *, rxdp + 3));rte_compiler_barrier ();const __m128i raw_desc2 = -_mm_load_si128 ((void *)(rxdp +2 )); + _mm_load_si128(RTE_CAST_PTR(const __m128i *, rxdp + 2));rte_compiler_barrier ();const __m128i raw_desc1 = -_mm_load_si128 ((void *)(rxdp +1 )); + _mm_load_si128(RTE_CAST_PTR(const __m128i *, rxdp + 1));rte_compiler_barrier ();const __m128i raw_desc0 = -_mm_load_si128 ((void *)(rxdp +0 )); + _mm_load_si128(RTE_CAST_PTR(const __m128i *, rxdp + 0)); raw_desc6_7 = _mm256_inserti128_si256
@@ -875,7 +871,7 @@ vtx1(volatile struct i40e_tx_desc *txdp, struct rte_mbuf *pkt, uint64_t flags)__m128i descriptor =_mm_set_epi64x (high_qw, pkt->buf_iova + pkt->data_off); -_mm_store_si128 ((__m128i *)txdp, descriptor); + _mm_store_si128(RTE_CAST_PTR(__m128i *, txdp), descriptor); } static inline void
@@ -909,7 +905,7 @@ vtx(volatile struct i40e_tx_desc *txdp, hi_qw2, pkt[2 ]->buf_iova + pkt[2 ]->data_off, hi_qw1, pkt[1 ]->buf_iova + pkt[1 ]->data_off, hi_qw0, pkt[0]->buf_iova + pkt[0]->data_off); -_mm512_storeu_si512 ((void *)txdp, desc0_3); + _mm512_storeu_si512(RTE_CAST_PTR(void *, txdp), desc0_3); }/* do any last ones */
drivers/net/i40e/i40e_rxtx_vec_common.h +0 -4
@@ -11,10 +11,6 @@#include "i40e_ethdev.h" #include "i40e_rxtx.h" -#ifndef __INTEL_COMPILER -#pragma GCC diagnostic ignored "-Wcast-qual" -#endif -static inline uint16_t reassemble_packets (struct i40e_rx_queue *rxq,struct rte_mbuf **rx_bufs,uint16_t nb_bufs,uint8_t *split_flags)
drivers/net/i40e/i40e_rxtx_vec_neon.c +16 -19
@@ -16,9 +16,6 @@#include "i40e_rxtx.h" #include "i40e_rxtx_vec_common.h" - -#pragma GCC diagnostic ignored "-Wcast-qual" -static inline void i40e_rxq_rearm (struct i40e_rx_queue *rxq) {
@@ -41,7 +38,7 @@ i40e_rxq_rearm(struct i40e_rx_queue *rxq) rxq->nb_rx_desc) {for (i =0 ; i <RTE_I40E_DESCS_PER_LOOP ; i++) { rxep[i].mbuf = &rxq->fake_mbuf; -vst1q_u64 ((uint64_t *)&rxdp[i].read, zero); + vst1q_u64(RTE_CAST_PTR(uint64_t *, &rxdp[i].read), zero); } } rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
@@ -58,11 +55,11 @@ i40e_rxq_rearm(struct i40e_rx_queue *rxq) dma_addr0 =vdupq_n_u64 (paddr);/* flush desc with pa dma_addr */ -vst1q_u64 ((uint64_t *)&rxdp++->read, dma_addr0); + vst1q_u64(RTE_CAST_PTR(uint64_t *, &rxdp++->read), dma_addr0); paddr = mb1->buf_iova +RTE_PKTMBUF_HEADROOM ; dma_addr1 =vdupq_n_u64 (paddr); -vst1q_u64 ((uint64_t *)&rxdp++->read, dma_addr1); + vst1q_u64(RTE_CAST_PTR(uint64_t *, &rxdp++->read), dma_addr1); } rxq->rxrearm_start +=RTE_I40E_RXQ_REARM_THRESH ;
@@ -87,10 +84,10 @@ descs_to_fdir_32b(volatile union i40e_rx_desc *rxdp, struct rte_mbuf **rx_pkt) {/* 32B descriptors: Load 2nd half of descriptors for FDIR ID data */ uint64x2_t desc0_qw23, desc1_qw23, desc2_qw23, desc3_qw23; - desc0_qw23 =vld1q_u64 ((uint64_t *)&(rxdp +0 )->wb.qword2); - desc1_qw23 =vld1q_u64 ((uint64_t *)&(rxdp +1 )->wb.qword2); - desc2_qw23 =vld1q_u64 ((uint64_t *)&(rxdp +2 )->wb.qword2); - desc3_qw23 =vld1q_u64 ((uint64_t *)&(rxdp +3 )->wb.qword2); + desc0_qw23 = vld1q_u64(RTE_CAST_PTR(uint64_t *, &(rxdp + 0)->wb.qword2)); + desc1_qw23 = vld1q_u64(RTE_CAST_PTR(uint64_t *, &(rxdp + 1)->wb.qword2)); + desc2_qw23 = vld1q_u64(RTE_CAST_PTR(uint64_t *, &(rxdp + 2)->wb.qword2)); + desc3_qw23 = vld1q_u64(RTE_CAST_PTR(uint64_t *, &(rxdp + 3)->wb.qword2));/* FDIR ID data: move last u32 of each desc to 4 u32 lanes */ uint32x4_t v_unpack_02, v_unpack_13;
@@ -421,18 +418,18 @@ _recv_raw_pkts_vec(struct i40e_rx_queue *__rte_restrict rxq,int32x4_t len_shl = {0 ,0 ,0 ,PKTLEN_SHIFT };/* A.1 load desc[3-0] */ - descs[3 ] =vld1q_u64 ((uint64_t *)(rxdp +3 )); - descs[2 ] =vld1q_u64 ((uint64_t *)(rxdp +2 )); - descs[1 ] =vld1q_u64 ((uint64_t *)(rxdp +1 )); - descs[0 ] =vld1q_u64 ((uint64_t *)(rxdp)); + descs[3] = vld1q_u64(RTE_CAST_PTR(uint64_t *, rxdp + 3)); + descs[2] = vld1q_u64(RTE_CAST_PTR(uint64_t *, rxdp + 2)); + descs[1] = vld1q_u64(RTE_CAST_PTR(uint64_t *, rxdp + 1)); + descs[0] = vld1q_u64(RTE_CAST_PTR(uint64_t *, rxdp));/* Use acquire fence to order loads of descriptor qwords */ rte_atomic_thread_fence (rte_memory_order_acquire);/* A.2 reload qword0 to make it ordered after qword1 load */ - descs[3 ] =vld1q_lane_u64 ((uint64_t *)(rxdp +3 ), descs[3 ],0 ); - descs[2 ] =vld1q_lane_u64 ((uint64_t *)(rxdp +2 ), descs[2 ],0 ); - descs[1 ] =vld1q_lane_u64 ((uint64_t *)(rxdp +1 ), descs[1 ],0 ); - descs[0 ] =vld1q_lane_u64 ((uint64_t *)(rxdp), descs[0 ],0 ); + descs[3] = vld1q_lane_u64(RTE_CAST_PTR(uint64_t *, rxdp + 3), descs[3], 0); + descs[2] = vld1q_lane_u64(RTE_CAST_PTR(uint64_t *, rxdp + 2), descs[2], 0); + descs[1] = vld1q_lane_u64(RTE_CAST_PTR(uint64_t *, rxdp + 1), descs[1], 0); + descs[0] = vld1q_lane_u64(RTE_CAST_PTR(uint64_t *, rxdp), descs[0], 0);/* B.1 load 4 mbuf point */ mbp1 =vld1q_u64 ((uint64_t *)&sw_ring[pos]);
@@ -662,7 +659,7 @@ vtx1(volatile struct i40e_tx_desc *txdp, ((uint64_t)pkt->data_len << I40E_TXD_QW1_TX_BUF_SZ_SHIFT));uint64x2_t descriptor = {pkt->buf_iova + pkt->data_off, high_qw}; -vst1q_u64 ((uint64_t *)txdp, descriptor); + vst1q_u64(RTE_CAST_PTR(uint64_t *, txdp), descriptor); } static inline void
drivers/net/i40e/i40e_rxtx_vec_sse.c +12 -16
@@ -14,10 +14,6 @@#include <rte_vect.h> -#ifndef __INTEL_COMPILER -#pragma GCC diagnostic ignored "-Wcast-qual" -#endif -static inline void i40e_rxq_rearm (struct i40e_rx_queue *rxq) {
@@ -41,7 +37,7 @@ i40e_rxq_rearm(struct i40e_rx_queue *rxq) dma_addr0 =_mm_setzero_si128 ();for (i =0 ; i <RTE_I40E_DESCS_PER_LOOP ; i++) { rxep[i].mbuf = &rxq->fake_mbuf; -_mm_store_si128 ((__m128i *)&rxdp[i].read, + _mm_store_si128(RTE_CAST_PTR(__m128i *, &rxdp[i].read), dma_addr0); } }
@@ -72,8 +68,8 @@ i40e_rxq_rearm(struct i40e_rx_queue *rxq) dma_addr1 =_mm_add_epi64 (dma_addr1, hdr_room);/* flush desc with pa dma_addr */ -_mm_store_si128 ((__m128i *)&rxdp++->read, dma_addr0); -_mm_store_si128 ((__m128i *)&rxdp++->read, dma_addr1); + _mm_store_si128(RTE_CAST_PTR(__m128i *, &rxdp++->read), dma_addr0); + _mm_store_si128(RTE_CAST_PTR(__m128i *, &rxdp++->read), dma_addr1); } rxq->rxrearm_start +=RTE_I40E_RXQ_REARM_THRESH ;
@@ -97,10 +93,10 @@ descs_to_fdir_32b(volatile union i40e_rx_desc *rxdp, struct rte_mbuf **rx_pkt) {/* 32B descriptors: Load 2nd half of descriptors for FDIR ID data */ __m128i desc0_qw23, desc1_qw23, desc2_qw23, desc3_qw23; - desc0_qw23 =_mm_loadu_si128 ((__m128i *)&(rxdp +0 )->wb.qword2); - desc1_qw23 =_mm_loadu_si128 ((__m128i *)&(rxdp +1 )->wb.qword2); - desc2_qw23 =_mm_loadu_si128 ((__m128i *)&(rxdp +2 )->wb.qword2); - desc3_qw23 =_mm_loadu_si128 ((__m128i *)&(rxdp +3 )->wb.qword2); + desc0_qw23 = _mm_loadu_si128(RTE_CAST_PTR(const __m128i *, &(rxdp + 0)->wb.qword2)); + desc1_qw23 = _mm_loadu_si128(RTE_CAST_PTR(const __m128i *, &(rxdp + 1)->wb.qword2)); + desc2_qw23 = _mm_loadu_si128(RTE_CAST_PTR(const __m128i *, &(rxdp + 2)->wb.qword2)); + desc3_qw23 = _mm_loadu_si128(RTE_CAST_PTR(const __m128i *, &(rxdp + 3)->wb.qword2));/* FDIR ID data: move last u32 of each desc to 4 u32 lanes */ __m128i v_unpack_01, v_unpack_23;
@@ -462,7 +458,7 @@ _recv_raw_pkts_vec(struct i40e_rx_queue *rxq, struct rte_mbuf **rx_pkts, mbp1 =_mm_loadu_si128 ((__m128i *)&sw_ring[pos]);/* Read desc statuses backwards to avoid race condition */ /* A.1 load desc[3] */ - descs[3 ] =_mm_loadu_si128 ((__m128i *)(rxdp +3 )); + descs[3] = _mm_loadu_si128(RTE_CAST_PTR(const __m128i *, rxdp + 3));rte_compiler_barrier ();/* B.2 copy 2 64 bit or 4 32 bit mbuf point into rx_pkts */
@@ -474,11 +470,11 @@ _recv_raw_pkts_vec(struct i40e_rx_queue *rxq, struct rte_mbuf **rx_pkts,#endif /* A.1 load desc[2-0] */ - descs[2 ] =_mm_loadu_si128 ((__m128i *)(rxdp +2 )); + descs[2] = _mm_loadu_si128(RTE_CAST_PTR(const __m128i *, rxdp + 2));rte_compiler_barrier (); - descs[1 ] =_mm_loadu_si128 ((__m128i *)(rxdp +1 )); + descs[1] = _mm_loadu_si128(RTE_CAST_PTR(const __m128i *, rxdp + 1));rte_compiler_barrier (); - descs[0 ] =_mm_loadu_si128 ((__m128i *)(rxdp)); + descs[0] = _mm_loadu_si128(RTE_CAST_PTR(const __m128i *, rxdp));#if defined(RTE_ARCH_X86_64 )/* B.2 copy 2 mbuf point into rx_pkts */
@@ -681,7 +677,7 @@ vtx1(volatile struct i40e_tx_desc *txdp,__m128i descriptor =_mm_set_epi64x (high_qw, pkt->buf_iova + pkt->data_off); -_mm_store_si128 ((__m128i *)txdp, descriptor); + _mm_store_si128(RTE_CAST_PTR(__m128i *, txdp), descriptor); } static inline void
drivers/net/iavf/iavf_rxtx_vec_avx2.c +28 -32
144 lines not on this page · raw message
drivers/net/iavf/iavf_rxtx_vec_avx512.c +29 -33
165 lines not on this page · raw message
drivers/net/iavf/iavf_rxtx_vec_common.h +3 -7
@@ -11,10 +11,6 @@#include "iavf.h" #include "iavf_rxtx.h" -#ifndef __INTEL_COMPILER -#pragma GCC diagnostic ignored "-Wcast-qual" -#endif - static __rte_always_inline uint16_treassemble_packets (struct iavf_rx_queue *rxq,struct rte_mbuf **rx_bufs,uint16_t nb_bufs,uint8_t *split_flags)
@@ -422,7 +418,7 @@ iavf_rxq_rearm_common(struct iavf_rx_queue *rxq, __rte_unused bool avx512) dma_addr0 =_mm_setzero_si128 ();for (i =0 ; i <IAVF_VPMD_DESCS_PER_LOOP ; i++) { rxp[i] = &rxq->fake_mbuf; -_mm_store_si128 ((__m128i *)&rxdp[i].read, + _mm_store_si128(RTE_CAST_PTR(__m128i *, &rxdp[i].read), dma_addr0); } }
@@ -458,8 +454,8 @@ iavf_rxq_rearm_common(struct iavf_rx_queue *rxq, __rte_unused bool avx512) dma_addr1 =_mm_add_epi64 (dma_addr1, hdr_room);/* flush desc with pa dma_addr */ -_mm_store_si128 ((__m128i *)&rxdp++->read, dma_addr0); - _mm_store_si128((__m128i *)&rxdp++->read, dma_addr1); + _mm_store_si128(RTE_CAST_PTR(__m128i *, &rxdp++->read), dma_addr0); + _mm_store_si128(RTE_CAST_PTR(__m128i *, &rxdp++->read), dma_addr1); }#else #ifdef CC_AVX512_SUPPORT
drivers/net/iavf/iavf_rxtx_vec_neon.c +11 -11
@@ -36,7 +36,7 @@ iavf_rxq_rearm(struct iavf_rx_queue *rxq) rxq->nb_rx_desc) {for (i =0 ; i <IAVF_VPMD_DESCS_PER_LOOP ; i++) { rxep[i] = &rxq->fake_mbuf; -vst1q_u64 ((uint64_t *)&rxdp[i].read, zero); + vst1q_u64(RTE_CAST_PTR(uint64_t *, &rxdp[i].read), zero); } } rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
@@ -53,11 +53,11 @@ iavf_rxq_rearm(struct iavf_rx_queue *rxq) dma_addr0 =vdupq_n_u64 (paddr);/* flush desc with pa dma_addr */ -vst1q_u64 ((uint64_t *)&rxdp++->read, dma_addr0); + vst1q_u64(RTE_CAST_PTR(uint64_t *, &rxdp++->read), dma_addr0); paddr = mb1->buf_iova +RTE_PKTMBUF_HEADROOM ; dma_addr1 =vdupq_n_u64 (paddr); -vst1q_u64 ((uint64_t *)&rxdp++->read, dma_addr1); + vst1q_u64(RTE_CAST_PTR(uint64_t *, &rxdp++->read), dma_addr1); } rxq->rxrearm_start +=IAVF_RXQ_REARM_THRESH ;
@@ -269,18 +269,18 @@ _recv_raw_pkts_vec(struct iavf_rx_queue *__rte_restrict rxq,int32x4_t len_shl = {0 ,0 ,0 ,PKTLEN_SHIFT };/* A.1 load desc[3-0] */ - descs[3 ] =vld1q_u64 ((uint64_t *)(rxdp +3 )); - descs[2 ] =vld1q_u64 ((uint64_t *)(rxdp +2 )); - descs[1 ] =vld1q_u64 ((uint64_t *)(rxdp +1 )); - descs[0 ] =vld1q_u64 ((uint64_t *)(rxdp)); + descs[3] = vld1q_u64(RTE_CAST_PTR(uint64_t *, rxdp + 3)); + descs[2] = vld1q_u64(RTE_CAST_PTR(uint64_t *, rxdp + 2)); + descs[1] = vld1q_u64(RTE_CAST_PTR(uint64_t *, rxdp + 1)); + descs[0] = vld1q_u64(RTE_CAST_PTR(uint64_t *, rxdp));/* Use acquire fence to order loads of descriptor qwords */ rte_atomic_thread_fence (rte_memory_order_acquire);/* A.2 reload qword0 to make it ordered after qword1 load */ - descs[3 ] =vld1q_lane_u64 ((uint64_t *)(rxdp +3 ), descs[3 ],0 ); - descs[2 ] =vld1q_lane_u64 ((uint64_t *)(rxdp +2 ), descs[2 ],0 ); - descs[1 ] =vld1q_lane_u64 ((uint64_t *)(rxdp +1 ), descs[1 ],0 ); - descs[0 ] =vld1q_lane_u64 ((uint64_t *)(rxdp), descs[0 ],0 ); + descs[3] = vld1q_lane_u64(RTE_CAST_PTR(uint64_t *, rxdp + 3), descs[3], 0); + descs[2] = vld1q_lane_u64(RTE_CAST_PTR(uint64_t *, rxdp + 2), descs[2], 0); + descs[1] = vld1q_lane_u64(RTE_CAST_PTR(uint64_t *, rxdp + 1), descs[1], 0); + descs[0] = vld1q_lane_u64(RTE_CAST_PTR(uint64_t *, rxdp), descs[0], 0);/* B.1 load 4 mbuf point */ mbp1 =vld1q_u64 ((uint64_t *)&sw_ring[pos]);
drivers/net/iavf/iavf_rxtx_vec_sse.c +17 -21
@@ -12,10 +12,6 @@#include <rte_vect.h> -#ifndef __INTEL_COMPILER -#pragma GCC diagnostic ignored "-Wcast-qual" -#endif -static inline void iavf_rxq_rearm (struct iavf_rx_queue *rxq) {
@@ -38,7 +34,7 @@ iavf_rxq_rearm(struct iavf_rx_queue *rxq) dma_addr0 =_mm_setzero_si128 ();for (i =0 ; i <IAVF_VPMD_DESCS_PER_LOOP ; i++) { rxp[i] = &rxq->fake_mbuf; -_mm_store_si128 ((__m128i *)&rxdp[i].read, + _mm_store_si128(RTE_CAST_PTR(__m128i *, &rxdp[i].read), dma_addr0); } }
@@ -69,8 +65,8 @@ iavf_rxq_rearm(struct iavf_rx_queue *rxq) dma_addr1 =_mm_add_epi64 (dma_addr1, hdr_room);/* flush desc with pa dma_addr */ -_mm_store_si128 ((__m128i *)&rxdp++->read, dma_addr0); -_mm_store_si128 ((__m128i *)&rxdp++->read, dma_addr1); + _mm_store_si128(RTE_CAST_PTR(__m128i *, &rxdp++->read), dma_addr0); + _mm_store_si128(RTE_CAST_PTR(__m128i *, &rxdp++->read), dma_addr1); } rxq->rxrearm_start += rxq->rx_free_thresh;
@@ -578,7 +574,7 @@ _recv_raw_pkts_vec(struct iavf_rx_queue *rxq, struct rte_mbuf **rx_pkts, mbp1 =_mm_loadu_si128 ((__m128i *)&sw_ring[pos]);/* Read desc statuses backwards to avoid race condition */ /* A.1 load desc[3] */ - descs[3 ] =_mm_loadu_si128 ((__m128i *)(rxdp +3 )); + descs[3] = _mm_loadu_si128(RTE_CAST_PTR(const __m128i *, rxdp + 3));rte_compiler_barrier ();/* B.2 copy 2 64 bit or 4 32 bit mbuf point into rx_pkts */
@@ -590,11 +586,11 @@ _recv_raw_pkts_vec(struct iavf_rx_queue *rxq, struct rte_mbuf **rx_pkts,#endif /* A.1 load desc[2-0] */ - descs[2 ] =_mm_loadu_si128 ((__m128i *)(rxdp +2 )); + descs[2] = _mm_loadu_si128(RTE_CAST_PTR(const __m128i *, rxdp + 2));rte_compiler_barrier (); - descs[1 ] =_mm_loadu_si128 ((__m128i *)(rxdp +1 )); + descs[1] = _mm_loadu_si128(RTE_CAST_PTR(const __m128i *, rxdp + 1));rte_compiler_barrier (); - descs[0 ] =_mm_loadu_si128 ((__m128i *)(rxdp)); + descs[0] = _mm_loadu_si128(RTE_CAST_PTR(const __m128i *, rxdp));#if defined(RTE_ARCH_X86_64 )/* B.2 copy 2 mbuf point into rx_pkts */
@@ -783,7 +779,7 @@ _recv_raw_pkts_vec_flex_rxd(struct iavf_rx_queue *rxq,/* Just the act of getting into the function from the application is * going to cost about 7 cycles */ - rxdp = (union iavf_rx_flex_desc *)rxq->rx_ring + rxq->rx_tail; + rxdp = (volatile union iavf_rx_flex_desc *)rxq->rx_ring + rxq->rx_tail;rte_prefetch0 (rxdp);
@@ -864,7 +860,7 @@ _recv_raw_pkts_vec_flex_rxd(struct iavf_rx_queue *rxq, mbp1 =_mm_loadu_si128 ((__m128i *)&sw_ring[pos]);/* Read desc statuses backwards to avoid race condition */ /* A.1 load desc[3] */ - descs[3 ] =_mm_loadu_si128 ((__m128i *)(rxdp +3 )); + descs[3] = _mm_loadu_si128(RTE_CAST_PTR(const __m128i *, rxdp + 3));rte_compiler_barrier ();/* B.2 copy 2 64 bit or 4 32 bit mbuf point into rx_pkts */
@@ -876,11 +872,11 @@ _recv_raw_pkts_vec_flex_rxd(struct iavf_rx_queue *rxq,#endif /* A.1 load desc[2-0] */ - descs[2 ] =_mm_loadu_si128 ((__m128i *)(rxdp +2 )); + descs[2] = _mm_loadu_si128(RTE_CAST_PTR(const __m128i *, rxdp + 2));rte_compiler_barrier (); - descs[1 ] =_mm_loadu_si128 ((__m128i *)(rxdp +1 )); + descs[1] = _mm_loadu_si128(RTE_CAST_PTR(const __m128i *, rxdp + 1));rte_compiler_barrier (); - descs[0 ] =_mm_loadu_si128 ((__m128i *)(rxdp)); + descs[0] = _mm_loadu_si128(RTE_CAST_PTR(const __m128i *, rxdp));#if defined(RTE_ARCH_X86_64 )/* B.2 copy 2 mbuf point into rx_pkts */
@@ -928,16 +924,16 @@ _recv_raw_pkts_vec_flex_rxd(struct iavf_rx_queue *rxq, rxq->rx_flags & IAVF_RX_FLAGS_VLAN_TAG_LOC_L2TAG2_2) {/* load bottom half of every 32B desc */ descs_bh[3 ] =_mm_load_si128 - ((void *)(&rxdp[3 ].wb.status_error1)); + (RTE_CAST_PTR(const __m128i *, &rxdp[3].wb.status_error1));rte_compiler_barrier (); descs_bh[2 ] =_mm_load_si128 - ((void *)(&rxdp[2 ].wb.status_error1)); + (RTE_CAST_PTR(const __m128i *, &rxdp[2].wb.status_error1));rte_compiler_barrier (); descs_bh[1 ] =_mm_load_si128 - ((void *)(&rxdp[1 ].wb.status_error1)); + (RTE_CAST_PTR(const __m128i *, &rxdp[1].wb.status_error1));rte_compiler_barrier (); descs_bh[0 ] =_mm_load_si128 - ((void *)(&rxdp[0 ].wb.status_error1)); + (RTE_CAST_PTR(const __m128i *, &rxdp[0].wb.status_error1)); }if (offloads &RTE_ETH_RX_OFFLOAD_RSS_HASH ) {
@@ -1349,7 +1345,7 @@ vtx1(volatile struct iavf_tx_desc *txdp, struct rte_mbuf *pkt, uint64_t flags)__m128i descriptor =_mm_set_epi64x (high_qw, pkt->buf_iova + pkt->data_off); -_mm_store_si128 ((__m128i *)txdp, descriptor); + _mm_store_si128(RTE_CAST_PTR(__m128i *, txdp), descriptor); } static inline void
drivers/net/ice/ice_rxtx_common_avx.h +7 -11
@@ -7,10 +7,6 @@#include "ice_rxtx.h" -#ifndef __INTEL_COMPILER -#pragma GCC diagnostic ignored "-Wcast-qual" -#endif -#ifdef __AVX2__ static __rte_always_inline void ice_rxq_rearm_common(struct ice_rx_queue *rxq, __rte_unused bool avx512)
@@ -33,7 +29,7 @@ ice_rxq_rearm_common(struct ice_rx_queue *rxq, __rte_unused bool avx512) dma_addr0 =_mm_setzero_si128 ();for (i =0 ; i <ICE_DESCS_PER_LOOP ; i++) { rxep[i].mbuf = &rxq->fake_mbuf; -_mm_store_si128 ((__m128i *)&rxdp[i].read, + _mm_store_si128(RTE_CAST_PTR(__m128i *, &rxdp[i].read), dma_addr0); } }
@@ -77,8 +73,8 @@ ice_rxq_rearm_common(struct ice_rx_queue *rxq, __rte_unused bool avx512) dma_addr1 =_mm_add_epi64 (dma_addr1, hdr_room);/* flush desc with pa dma_addr */ -_mm_store_si128 ((__m128i *)&rxdp++->read, dma_addr0); - _mm_store_si128((__m128i *)&rxdp++->read, dma_addr1); + _mm_store_si128(RTE_CAST_PTR(__m128i *, &rxdp++->read), dma_addr0); + _mm_store_si128(RTE_CAST_PTR(__m128i *, &rxdp++->read), dma_addr1); }#else #ifdef __AVX512VL__
@@ -157,8 +153,8 @@ ice_rxq_rearm_common(struct ice_rx_queue *rxq, __rte_unused bool avx512) dma_addr4_7 =_mm512_add_epi64 (dma_addr4_7, hdr_room);/* flush desc with pa dma_addr */ -_mm512_store_si512 ((__m512i *)&rxdp->read, dma_addr0_3); - _mm512_store_si512((__m512i *)&(rxdp + 4)->read, dma_addr4_7); + _mm512_store_si512(RTE_CAST_PTR(__m512i *, &rxdp->read), dma_addr0_3); + _mm512_store_si512(RTE_CAST_PTR(__m512i *, &(rxdp + 4)->read), dma_addr4_7); } } else#endif /* __AVX512VL__ */
@@ -213,8 +209,8 @@ ice_rxq_rearm_common(struct ice_rx_queue *rxq, __rte_unused bool avx512) dma_addr2_3 =_mm256_add_epi64 (dma_addr2_3, hdr_room);/* flush desc with pa dma_addr */ -_mm256_store_si256 ((__m256i *)&rxdp->read, dma_addr0_1); -_mm256_store_si256 ((__m256i *)&(rxdp +2 )->read, dma_addr2_3); + _mm256_store_si256(RTE_CAST_PTR(__m256i *, &rxdp->read), dma_addr0_1); + _mm256_store_si256(RTE_CAST_PTR(__m256i *, &(rxdp + 2)->read), dma_addr2_3); } }
drivers/net/ice/ice_rxtx_vec_avx2.c +35 -39
118 lines not on this page · raw message
drivers/net/ice/ice_rxtx_vec_avx512.c +26 -38
115 lines not on this page · raw message
drivers/net/ice/ice_rxtx_vec_common.h +0 -4
@@ -7,10 +7,6 @@#include "ice_rxtx.h" -#ifndef __INTEL_COMPILER -#pragma GCC diagnostic ignored "-Wcast-qual" -#endif -static inline uint16_t ice_rx_reassemble_packets (struct ice_rx_queue *rxq,struct rte_mbuf **rx_bufs,uint16_t nb_bufs,uint8_t *split_flags)
drivers/net/ice/ice_rxtx_vec_sse.c +12 -16
@@ -6,10 +6,6 @@#include <rte_vect.h> -#ifndef __INTEL_COMPILER -#pragma GCC diagnostic ignored "-Wcast-qual" -#endif -static inline __m128i ice_flex_rxd_to_fdir_flags_vec (const __m128i fdir_id0_3) {
@@ -52,7 +48,7 @@ ice_rxq_rearm(struct ice_rx_queue *rxq) dma_addr0 =_mm_setzero_si128 ();for (i =0 ; i <ICE_DESCS_PER_LOOP ; i++) { rxep[i].mbuf = &rxq->fake_mbuf; -_mm_store_si128 ((__m128i *)&rxdp[i].read, + _mm_store_si128(RTE_CAST_PTR(__m128i *, &rxdp[i].read), dma_addr0); } }
@@ -91,8 +87,8 @@ ice_rxq_rearm(struct ice_rx_queue *rxq) dma_addr1 =_mm_add_epi64 (dma_addr1, hdr_room);/* flush desc with pa dma_addr */ -_mm_store_si128 ((__m128i *)&rxdp++->read, dma_addr0); -_mm_store_si128 ((__m128i *)&rxdp++->read, dma_addr1); + _mm_store_si128(RTE_CAST_PTR(__m128i *, &rxdp++->read), dma_addr0); + _mm_store_si128(RTE_CAST_PTR(__m128i *, &rxdp++->read), dma_addr1); } rxq->rxrearm_start +=ICE_RXQ_REARM_THRESH ;
@@ -425,7 +421,7 @@ _ice_recv_raw_pkts_vec(struct ice_rx_queue *rxq, struct rte_mbuf **rx_pkts, mbp1 =_mm_loadu_si128 ((__m128i *)&sw_ring[pos]);/* Read desc statuses backwards to avoid race condition */ /* A.1 load desc[3] */ - descs[3 ] =_mm_loadu_si128 ((__m128i *)(rxdp +3 )); + descs[3] = _mm_loadu_si128(RTE_CAST_PTR(const __m128i *, rxdp + 3));rte_compiler_barrier ();/* B.2 copy 2 64 bit or 4 32 bit mbuf point into rx_pkts */
@@ -437,11 +433,11 @@ _ice_recv_raw_pkts_vec(struct ice_rx_queue *rxq, struct rte_mbuf **rx_pkts,#endif /* A.1 load desc[2-0] */ - descs[2 ] =_mm_loadu_si128 ((__m128i *)(rxdp +2 )); + descs[2] = _mm_loadu_si128(RTE_CAST_PTR(const __m128i *, rxdp + 2));rte_compiler_barrier (); - descs[1 ] =_mm_loadu_si128 ((__m128i *)(rxdp +1 )); + descs[1] = _mm_loadu_si128(RTE_CAST_PTR(const __m128i *, rxdp + 1));rte_compiler_barrier (); - descs[0 ] =_mm_loadu_si128 ((__m128i *)(rxdp)); + descs[0] = _mm_loadu_si128(RTE_CAST_PTR(const __m128i *, rxdp));#if defined(RTE_ARCH_X86_64 )/* B.2 copy 2 mbuf point into rx_pkts */
@@ -491,19 +487,19 @@ _ice_recv_raw_pkts_vec(struct ice_rx_queue *rxq, struct rte_mbuf **rx_pkts,/* load bottom half of every 32B desc */ const __m128i raw_desc_bh3 =_mm_load_si128 - ((void *)(&rxdp[3 ].wb.status_error1)); + (RTE_CAST_PTR(const __m128i *, &rxdp[3].wb.status_error1));rte_compiler_barrier ();const __m128i raw_desc_bh2 =_mm_load_si128 - ((void *)(&rxdp[2 ].wb.status_error1)); + (RTE_CAST_PTR(const __m128i *, &rxdp[2].wb.status_error1));rte_compiler_barrier ();const __m128i raw_desc_bh1 =_mm_load_si128 - ((void *)(&rxdp[1 ].wb.status_error1)); + (RTE_CAST_PTR(const __m128i *, &rxdp[1].wb.status_error1));rte_compiler_barrier ();const __m128i raw_desc_bh0 =_mm_load_si128 - ((void *)(&rxdp[0 ].wb.status_error1)); + (RTE_CAST_PTR(const __m128i *, &rxdp[0].wb.status_error1));/** * to shift the 32b RSS hash value to the
@@ -680,7 +676,7 @@ ice_vtx1(volatile struct ice_tx_desc *txdp, struct rte_mbuf *pkt, ((uint64_t)pkt->data_len << ICE_TXD_QW1_TX_BUF_SZ_S));__m128i descriptor =_mm_set_epi64x (high_qw,rte_pktmbuf_iova (pkt)); -_mm_store_si128 ((__m128i *)txdp, descriptor); + _mm_store_si128(RTE_CAST_PTR(__m128i *, txdp), descriptor); } static inline void
drivers/net/idpf/idpf_rxtx_vec_common.h +0 -4
@@ -11,10 +11,6 @@#include "idpf_ethdev.h" #include "idpf_rxtx.h" -#ifndef __INTEL_COMPILER -#pragma GCC diagnostic ignored "-Wcast-qual" -#endif -#define IDPF_SCALAR_PATH 0#define IDPF_VECTOR_PATH 1#define IDPF_RX_NO_VECTOR_FLAGS ( \
drivers/net/ixgbe/ixgbe_recycle_mbufs_vec_common.c +0 -2
@@ -8,8 +8,6 @@#include "ixgbe_ethdev.h" #include "ixgbe_rxtx.h" -#pragma GCC diagnostic ignored "-Wcast-qual" -void ixgbe_recycle_rx_descriptors_refill_vec (void *rx_queue,uint16_t nb_mbufs) {
drivers/net/ixgbe/ixgbe_rxtx_vec_neon.c +8 -10
@@ -11,8 +11,6 @@#include "ixgbe_rxtx.h" #include "ixgbe_rxtx_vec_common.h" -#pragma GCC diagnostic ignored "-Wcast-qual" -static inline void ixgbe_rxq_rearm (struct ixgbe_rx_queue *rxq) {
@@ -36,7 +34,7 @@ ixgbe_rxq_rearm(struct ixgbe_rx_queue *rxq) rxq->nb_rx_desc) {for (i =0 ; i <RTE_IXGBE_DESCS_PER_LOOP ; i++) { rxep[i].mbuf = &rxq->fake_mbuf; -vst1q_u64 ((uint64_t *)&rxdp[i].read, + vst1q_u64(RTE_CAST_PTR(uint64_t *, &rxdp[i].read), zero); } }
@@ -60,12 +58,12 @@ ixgbe_rxq_rearm(struct ixgbe_rx_queue *rxq) 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); + vst1q_u64(RTE_CAST_PTR(uint64_t *, &rxdp++->read), dma_addr0);vst1_u8 ((uint8_t *)&mb1->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); + vst1q_u64(RTE_CAST_PTR(uint64_t *, &rxdp++->read), dma_addr1); } rxq->rxrearm_start +=RTE_IXGBE_RXQ_REARM_THRESH ;
@@ -367,10 +365,10 @@ _recv_raw_pkts_vec(struct ixgbe_rx_queue *rxq, struct rte_mbuf **rx_pkts, mbp2 =vld1q_u64 ((uint64_t *)&sw_ring[pos +2 ]);/* A. load 4 pkts descs */ - descs[0 ] =vld1q_u64 ((uint64_t *)(rxdp)); - descs[1 ] =vld1q_u64 ((uint64_t *)(rxdp +1 )); - descs[2 ] =vld1q_u64 ((uint64_t *)(rxdp +2 )); - descs[3 ] =vld1q_u64 ((uint64_t *)(rxdp +3 )); + descs[0] = vld1q_u64(RTE_CAST_PTR(uint64_t *, rxdp)); + descs[1] = vld1q_u64(RTE_CAST_PTR(uint64_t *, rxdp + 1)); + descs[2] = vld1q_u64(RTE_CAST_PTR(uint64_t *, rxdp + 2)); + descs[3] = vld1q_u64(RTE_CAST_PTR(uint64_t *, rxdp + 3));/* B.2 copy 2 mbuf point into rx_pkts */ vst1q_u64 ((uint64_t *)&rx_pkts[pos +2 ], mbp2);
@@ -554,7 +552,7 @@ vtx1(volatile union ixgbe_adv_tx_desc *txdp, pkt->buf_iova + pkt->data_off, (uint64_t)pkt->pkt_len << 46 | flags | pkt->data_len}; -vst1q_u64 ((uint64_t *)&txdp->read, descriptor); + vst1q_u64(RTE_CAST_PTR(uint64_t *, &txdp->read), descriptor); } static inline void
drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c +8 -12
@@ -12,10 +12,6 @@#include <rte_vect.h> -#ifndef __INTEL_COMPILER -#pragma GCC diagnostic ignored "-Wcast-qual" -#endif -static inline void ixgbe_rxq_rearm (struct ixgbe_rx_queue *rxq) {
@@ -41,7 +37,7 @@ ixgbe_rxq_rearm(struct ixgbe_rx_queue *rxq) dma_addr0 =_mm_setzero_si128 ();for (i =0 ; i <RTE_IXGBE_DESCS_PER_LOOP ; i++) { rxep[i].mbuf = &rxq->fake_mbuf; -_mm_store_si128 ((__m128i *)&rxdp[i].read, + _mm_store_si128(RTE_CAST_PTR(__m128i *, &rxdp[i].read), dma_addr0); } }
@@ -76,8 +72,8 @@ ixgbe_rxq_rearm(struct ixgbe_rx_queue *rxq) dma_addr1 =_mm_and_si128 (dma_addr1, hba_msk);/* flush desc with pa dma_addr */ -_mm_store_si128 ((__m128i *)&rxdp++->read, dma_addr0); -_mm_store_si128 ((__m128i *)&rxdp++->read, dma_addr1); + _mm_store_si128(RTE_CAST_PTR(__m128i *, &rxdp++->read), dma_addr0); + _mm_store_si128(RTE_CAST_PTR(__m128i *, &rxdp++->read), dma_addr1); } rxq->rxrearm_start +=RTE_IXGBE_RXQ_REARM_THRESH ;
@@ -466,7 +462,7 @@ _recv_raw_pkts_vec(struct ixgbe_rx_queue *rxq, struct rte_mbuf **rx_pkts,/* Read desc statuses backwards to avoid race condition */ /* A.1 load desc[3] */ - descs[3 ] =_mm_loadu_si128 ((__m128i *)(rxdp +3 )); + descs[3] = _mm_loadu_si128(RTE_CAST_PTR(const __m128i *, rxdp + 3));rte_compiler_barrier ();/* B.2 copy 2 64 bit or 4 32 bit mbuf point into rx_pkts */
@@ -478,11 +474,11 @@ _recv_raw_pkts_vec(struct ixgbe_rx_queue *rxq, struct rte_mbuf **rx_pkts,#endif /* A.1 load desc[2-0] */ - descs[2 ] =_mm_loadu_si128 ((__m128i *)(rxdp +2 )); + descs[2] = _mm_loadu_si128(RTE_CAST_PTR(const __m128i *, rxdp + 2));rte_compiler_barrier (); - descs[1 ] =_mm_loadu_si128 ((__m128i *)(rxdp +1 )); + descs[1] = _mm_loadu_si128(RTE_CAST_PTR(const __m128i *, rxdp + 1));rte_compiler_barrier (); - descs[0 ] =_mm_loadu_si128 ((__m128i *)(rxdp)); + descs[0] = _mm_loadu_si128(RTE_CAST_PTR(const __m128i *, rxdp));#if defined(RTE_ARCH_X86_64 )/* B.2 copy 2 mbuf point into rx_pkts */
@@ -676,7 +672,7 @@ vtx1(volatile union ixgbe_adv_tx_desc *txdp,__m128i descriptor =_mm_set_epi64x ((uint64_t )pkt->pkt_len <<46 | flags | pkt->data_len, pkt->buf_iova + pkt->data_off); -_mm_store_si128 ((__m128i *)&txdp->read, descriptor); + _mm_store_si128(RTE_CAST_PTR(__m128i *, &txdp->read), descriptor); } static inline void
drivers/net/mlx5/mlx5_flow.c +1 -4
@@ -7287,10 +7287,7 @@ flow_tunnel_from_rule(const struct mlx5_flow *flow) {struct mlx5_flow_tunnel *tunnel; -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wcast-qual" - tunnel = (typeof (tunnel ))flow->tunnel; -#pragma GCC diagnostic pop + tunnel =RTE_PTR_UNQUAL (flow->tunnel);return tunnel; }
drivers/net/mlx5/mlx5_rxtx_vec_altivec.h +0 -5
@@ -25,11 +25,6 @@#include "mlx5_rxtx_vec.h" #include "mlx5_autoconf.h" -#ifndef __INTEL_COMPILER -#pragma GCC diagnostic ignored "-Wcast-qual" -#pragma GCC diagnostic ignored "-Wstrict-aliasing" -#endif -/** * Store free buffers to RX SW ring. *
drivers/net/mlx5/mlx5_rxtx_vec_neon.h +8 -10
@@ -25,8 +25,6 @@#include "mlx5_rxtx_vec.h" #include "mlx5_autoconf.h" -#pragma GCC diagnostic ignored "-Wcast-qual" -/** * Store free buffers to RX SW ring. *
@@ -75,7 +73,7 @@ rxq_cq_decompress_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq, struct rte_mbuf **elts, bool keep) {volatile struct mlx5_mini_cqe8 *mcq = - (void *)&(cq + !rxq->cqe_comp_layout)->pkt_info; + (volatile struct mlx5_mini_cqe8 *)&(cq + !rxq->cqe_comp_layout)->pkt_info;/* Title packet is pre-built. */ struct rte_mbuf *t_pkt = rxq->cqe_comp_layout ? &rxq->title_pkt : elts[0 ];unsigned int pos;
@@ -139,9 +137,9 @@ rxq_cq_decompress_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq,*/ cycle:if (rxq->cqe_comp_layout) -rte_prefetch0 ((void *)(cq + mcqe_n)); +rte_prefetch0 ((volatile void *)(cq + mcqe_n));for (pos =0 ; pos < mcqe_n; ) { -uint8_t *p = (void *)&mcq[pos %8 ]; + uint8_t *p = RTE_CAST_PTR(uint8_t *, &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;
@@ -157,7 +155,7 @@ rxq_cq_decompress_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq,if (!rxq->cqe_comp_layout)for (i =0 ; i <MLX5_VPMD_DESCS_PER_LOOP ; ++i)if (likely (pos + i < mcqe_n)) -rte_prefetch0 ((void *)(cq + pos + i)); +rte_prefetch0 ((volatile void *)(cq + pos + i)); __asm__volatile (/* A.1 load mCQEs into a 128bit register. */ "ld1 {v16.16b - v17.16b}, [%[mcq]] \n\t"
@@ -367,8 +365,8 @@ rxq_cq_decompress_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq,if (!rxq->cqe_comp_layout) {if (!(pos &0x7 ) && pos < mcqe_n) {if (pos +8 < mcqe_n) -rte_prefetch0 ((void *)(cq + pos +8 )); - mcq = (void *)&(cq + pos)->pkt_info; +rte_prefetch0 ((volatile void *)(cq + pos +8 )); + mcq = (volatile struct mlx5_mini_cqe8 *)&(cq + pos)->pkt_info;for (i =0 ; i <8 ; ++i) cq[inv++].op_own =MLX5_CQE_INVALIDATE ; }
@@ -383,7 +381,7 @@ rxq_cq_decompress_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq, MLX5_CQE_FORMAT(cq->op_own) == MLX5_COMPRESSED) { pos =0 ; elts = &elts[mcqe_n]; - mcq = (void *)cq; + mcq = (volatile struct mlx5_mini_cqe8 *)cq; mcqe_n =MLX5_CQE_NUM_MINIS (cq->op_own) +1 ; pkts_n += mcqe_n; goto cycle;
@@ -663,7 +661,7 @@ rxq_cq_process_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq, mask =vcreate_u16 (pkts_n - pos <MLX5_VPMD_DESCS_PER_LOOP ?-1UL >> ((pkts_n - pos) *sizeof (uint16_t ) *8 ) :0 ); - p0 = (void *)&cq[pos].pkt_info; + p0 =RTE_PTR_UNQUAL (&cq[pos].pkt_info); p1 = p0 + (pkts_n - pos >1 ) *sizeof (struct mlx5_cqe ); p2 = p1 + (pkts_n - pos >2 ) *sizeof (struct mlx5_cqe ); p3 = p2 + (pkts_n - pos >3 ) *sizeof (struct mlx5_cqe );
drivers/net/mlx5/mlx5_rxtx_vec_sse.h +29 -32
132 lines not on this page · raw message
drivers/net/ngbe/ngbe_rxtx_vec_neon.c +4 -4
@@ -35,7 +35,7 @@ ngbe_rxq_rearm(struct ngbe_rx_queue *rxq) rxq->nb_rx_desc) {for (i =0 ; i <RTE_NGBE_DESCS_PER_LOOP ; i++) { rxep[i].mbuf = &rxq->fake_mbuf; -vst1q_u64 ((uint64_t *)(uintptr_t )&rxdp[i], zero); + vst1q_u64(RTE_CAST_PTR(uint64_t *, &rxdp[i]), zero); } } rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
@@ -58,12 +58,12 @@ ngbe_rxq_rearm(struct ngbe_rx_queue *rxq) 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 *)(uintptr_t )rxdp++, dma_addr0); + vst1q_u64(RTE_CAST_PTR(uint64_t *, rxdp++), dma_addr0);vst1_u8 ((uint8_t *)&mb1->rearm_data, p); paddr = mb1->buf_iova +RTE_PKTMBUF_HEADROOM ; dma_addr1 =vsetq_lane_u64 (paddr, zero,0 ); -vst1q_u64 ((uint64_t *)(uintptr_t )rxdp++, dma_addr1); + vst1q_u64(RTE_CAST_PTR(uint64_t *, rxdp++), dma_addr1); } rxq->rxrearm_start +=RTE_NGBE_RXQ_REARM_THRESH ;
@@ -484,7 +484,7 @@ vtx1(volatile struct ngbe_tx_desc *txdp,uint64x2_t descriptor = {pkt->buf_iova + pkt->data_off, (uint64_t )pkt_len <<45 | flags | pkt_len}; -vst1q_u64 ((uint64_t *)(uintptr_t )txdp, descriptor); + vst1q_u64(RTE_CAST_PTR(uint64_t *, txdp), descriptor); } static inline void
drivers/net/tap/tap_flow.c +3 -3
@@ -23,10 +23,10 @@#ifdef HAVE_BPF_RSS /* Workaround for warning in bpftool generated skeleton code */ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wcast-qual" +__rte_diagnostic_push +__rte_diagnostic_ignored_wcast_qual#include "tap_rss.skel.h" -#pragma GCC diagnostic pop +__rte_diagnostic_pop#endif #define ISOLATE_HANDLE 1
drivers/net/txgbe/txgbe_rxtx_vec_neon.c +4 -4
@@ -34,7 +34,7 @@ txgbe_rxq_rearm(struct txgbe_rx_queue *rxq) rxq->nb_rx_desc) {for (i =0 ; i <RTE_TXGBE_DESCS_PER_LOOP ; i++) { rxep[i].mbuf = &rxq->fake_mbuf; -vst1q_u64 ((uint64_t *)(uintptr_t )&rxdp[i], zero); + vst1q_u64(RTE_CAST_PTR(uint64_t *, &rxdp[i]), zero); } } rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
@@ -57,12 +57,12 @@ txgbe_rxq_rearm(struct txgbe_rx_queue *rxq) 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 *)(uintptr_t )rxdp++, dma_addr0); + vst1q_u64(RTE_CAST_PTR(uint64_t *, rxdp++), dma_addr0);vst1_u8 ((uint8_t *)&mb1->rearm_data, p); paddr = mb1->buf_iova +RTE_PKTMBUF_HEADROOM ; dma_addr1 =vsetq_lane_u64 (paddr, zero,0 ); -vst1q_u64 ((uint64_t *)(uintptr_t )rxdp++, dma_addr1); + vst1q_u64(RTE_CAST_PTR(uint64_t *, rxdp++), dma_addr1); } rxq->rxrearm_start +=RTE_TXGBE_RXQ_REARM_THRESH ;
@@ -484,7 +484,7 @@ vtx1(volatile struct txgbe_tx_desc *txdp,uint64x2_t descriptor = {pkt->buf_iova + pkt->data_off, (uint64_t )pkt_len <<45 | flags | pkt_len}; -vst1q_u64 ((uint64_t *)(uintptr_t )txdp, descriptor); + vst1q_u64(RTE_CAST_PTR(uint64_t *, txdp), descriptor); } static inline void
drivers/net/virtio/virtio_rxtx_simple.c +0 -4
@@ -23,10 +23,6 @@#include "virtio_rxtx_simple.h" -#ifndef __INTEL_COMPILER -#pragma GCC diagnostic ignored "-Wcast-qual" -#endif - int __rte_coldvirtio_rxq_vec_setup (struct virtnet_rx *rxq) {
Signature · 1 line
2.47.2.vfs.0.1
v16 cover add diagnostics macros to make code portable
In reply to Andre Muezeriev16:
* Updated comment for RTE_CAST_PTR.
v15:
* Fixed a comment in rte_common.h to make Doxygen happy.
* Fixed a typo (extra comma).
* Added missing RTE_PTR_UNQUAL needed for ARM64.
v14:
* Renamed RTE_PTR_DROP_QUALIFIERS into RTE_PTR_UNQUAL to more resemble C23 typeof_unqual.
* Added macro RTE_CAST_PTR to make the cast more readable when removing a type qualifier from a pointer.
v13:
* Renamed RTE_IGNORE_CAST_QUAL into RTE_PTR_DROP_QUALIFIERS.
* Added (void *) cast to RTE_PTR_DROP_QUALIFIERS to avoid the need for casting the result in most places where the macro is used.
v12:
* Added macro RTE_IGNORE_CAST_QUAL and used it as a more compact and readable form to suppress warnings where a cast is used to remove a type qualifier.
v11:
* Added __rte_diagnostic_ignored_wcast_qual to a few more places where it was needed.
v10:
* Added __rte_diagnostic_ignored_wcast_qual to a few more places where it was needed.
v9:
* Added __rte_diagnostic_ignored_wcast_qual to a few more places where it was needed.
v8:
* Added __rte_diagnostic_ignored_wcast_qual to a few more places where it was needed.
v7:
* Added __rte_diagnostic_ignored_wcast_qual to a few more places where it was needed.
v6:
* Added __rte_diagnostic_ignored_wcast_qual to a few more places where it was needed.
v5:
* Added __rte_diagnostic_ignored_wcast_qual to a few more places where it was needed.
v4:
* Added __rte_diagnostic_ignored_wcast_qual to a few more places where it was needed.
v3:
* Added __rte_diagnostic_ignored_wcast_qual to a few more places where it was needed.
v2:
* Removed __rte_diagnostic_ignored_wstrict_aliasing (introduced in v1).
* Removed the pragmas from many files where they were not needed.
* In the files where the pragmas were indeed needed, reduced the scope during which they are active, reducing the chance that unforeseen issues are hidden due to warning suppression.
Andre Muezerie (3):
eal: add diagnostics macros to make code portable drivers/common: add diagnostics macros to make code portable drivers/net: add diagnostics macros to make code portable
drivers/common/idpf/idpf_common_rxtx_avx512.c | 72 +++++++++--------- drivers/net/axgbe/axgbe_rxtx.h | 9 --- drivers/net/cpfl/cpfl_rxtx_vec_common.h | 4 - drivers/net/dpaa2/dpaa2_rxtx.c | 15 +--- drivers/net/fm10k/fm10k_rxtx_vec.c | 21 ++---- drivers/net/hns3/hns3_rxtx_vec_neon.h | 6 +- .../net/i40e/i40e_recycle_mbufs_vec_common.c | 2 - drivers/net/i40e/i40e_rxtx_common_avx.h | 22 +++--- drivers/net/i40e/i40e_rxtx_vec_altivec.c | 18 ++--- drivers/net/i40e/i40e_rxtx_vec_avx2.c | 30 ++++---- drivers/net/i40e/i40e_rxtx_vec_avx512.c | 28 +++---- drivers/net/i40e/i40e_rxtx_vec_common.h | 4 - drivers/net/i40e/i40e_rxtx_vec_neon.c | 35 ++++----- drivers/net/i40e/i40e_rxtx_vec_sse.c | 28 +++---- drivers/net/iavf/iavf_rxtx_vec_avx2.c | 60 +++++++-------- drivers/net/iavf/iavf_rxtx_vec_avx512.c | 62 ++++++++-------- drivers/net/iavf/iavf_rxtx_vec_common.h | 10 +-- drivers/net/iavf/iavf_rxtx_vec_neon.c | 22 +++--- drivers/net/iavf/iavf_rxtx_vec_sse.c | 38 +++++----- drivers/net/ice/ice_rxtx_common_avx.h | 18 ++--- drivers/net/ice/ice_rxtx_vec_avx2.c | 74 +++++++++---------- drivers/net/ice/ice_rxtx_vec_avx512.c | 64 +++++++--------- drivers/net/ice/ice_rxtx_vec_common.h | 4 - drivers/net/ice/ice_rxtx_vec_sse.c | 28 +++---- drivers/net/idpf/idpf_rxtx_vec_common.h | 4 - .../ixgbe/ixgbe_recycle_mbufs_vec_common.c | 2 - drivers/net/ixgbe/ixgbe_rxtx_vec_neon.c | 18 ++--- drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c | 20 ++--- drivers/net/mlx5/mlx5_flow.c | 5 +- drivers/net/mlx5/mlx5_rxtx_vec_altivec.h | 5 -- drivers/net/mlx5/mlx5_rxtx_vec_neon.h | 18 ++--- drivers/net/mlx5/mlx5_rxtx_vec_sse.h | 61 ++++++++------- drivers/net/ngbe/ngbe_rxtx_vec_neon.c | 8 +- drivers/net/tap/tap_flow.c | 6 +- drivers/net/txgbe/txgbe_rxtx_vec_neon.c | 8 +- drivers/net/virtio/virtio_rxtx_simple.c | 4 - lib/eal/include/rte_common.h | 48 ++++++++++++ 37 files changed, 398 insertions(+), 483 deletions(-)
--
2.47.2.vfs.0.1
PATCH v16 1/3 eal: add diagnostics macros to make code portable
It was a common pattern to have "GCC diagnostic ignored" pragmas sprinkled over the code and only activate these pragmas for certain compilers (gcc and clang). Clang supports GCC's pragma for compatibility with existing source code, so #pragma GCC diagnostic and #pragma clang diagnostic are synonyms for Clang
(https://clang.llvm.org/docs/UsersManual.html).
Now that effort is being made to make the code compatible with MSVC these expressions would become more complex. It makes sense to hide this complexity behind macros. This makes maintenance easier as these macros are defined in a single place. As a plus the code becomes more readable as well.
--- lib/eal/include/rte_common.h | 48 ++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+)
lib/eal/include/rte_common.h +48 -0
@@ -156,6 +156,54 @@ typedef uint16_t unaligned_uint16_t;#define RTE_DEPRECATED (x)#endif +/** +* Macros to cause the compiler to remember the state of the diagnostics as of +* each push, and restore to that point at each pop. +*/ +#if !defined(__INTEL_COMPILER) && !defined(RTE_TOOLCHAIN_MSVC ) +#define __rte_diagnostic_push _Pragma("GCC diagnostic push") +#define __rte_diagnostic_pop _Pragma("GCC diagnostic pop") +#else +#define __rte_diagnostic_push +#define __rte_diagnostic_pop +#endif + +/** +* Macro to disable compiler warnings about removing a type +* qualifier from the target type. +*/ +#if !defined(__INTEL_COMPILER) && !defined(RTE_TOOLCHAIN_MSVC ) +#define __rte_diagnostic_ignored_wcast_qual \ + _Pragma("GCC diagnostic ignored \"-Wcast-qual\"") +#else +#define __rte_diagnostic_ignored_wcast_qual +#endif + +/** +* Workaround to discard qualifiers (such as const, volatile, restrict) from a pointer, +* without the compiler emitting a warning. +*/ +#define RTE_PTR_UNQUAL (X ) ((void *)(uintptr_t)(X)) + +/** +* Workaround to cast a pointer to a specific type, +* without the compiler emitting a warning about discarding qualifiers. +* +* @warning +* When casting a pointer to point to a larger type, the resulting pointer may +* be misaligned, which results in undefined behavior. +* E.g.: +* +* struct s { +* uint16_t a; +* uint8_t b; +* uint8_t c; +* uint8_t d; +* } v; +* uint16_t * p = RTE_CAST_PTR(uint16_t *, &v.c); // "p" is not 16 bit aligned! +*/ +#define RTE_CAST_PTR (type, ptr) ((type)(uintptr_t)(ptr)) +/** * Mark a function or variable to a weak reference. */
Signature · 1 line
2.47.2.vfs.0.1
RE: [PATCH v16 1/3] eal: add diagnostics macros to make code portable
Quoted 10 lines
From: Andre Muezerie [mailto:[email protected]]
Sent: Tuesday, 21 January 2025 23.36It was a common pattern to have "GCC diagnostic ignored" pragmas sprinkled over the code and only activate these pragmas for certain compilers (gcc and clang). Clang supports GCC's pragma for compatibility with existing source code, so #pragma GCC diagnostic and #pragma clang diagnostic are synonyms for Clang
(https://clang.llvm.org/docs/UsersManual.html).
Quoted 8 lines
Now that effort is being made to make the code compatible with MSVC these expressions would become more complex. It makes sense to hide this complexity behind macros. This makes maintenance easier as these macros are defined in a single place. As a plus the code becomes more readable as well.
Signed-off-by Andre Muezerie <[email protected]>---
Thank you for your extra effort on making this as clean as practically possible, Andre.
PATCH v16 2/3 drivers/common: add diagnostics macros to make code portable
In reply to Andre MuezerieIt was a common pattern to have "GCC diagnostic ignored" pragmas sprinkled over the code and only activate these pragmas for certain compilers (gcc and clang). Clang supports GCC's pragma for compatibility with existing source code, so #pragma GCC diagnostic and #pragma clang diagnostic are synonyms for Clang
(https://clang.llvm.org/docs/UsersManual.html).
Now that effort is being made to make the code compatible with MSVC these expressions would become more complex. It makes sense to hide this complexity behind macros. This makes maintenance easier as these macros are defined in a single place. As a plus the code becomes more readable as well.
--- drivers/common/idpf/idpf_common_rxtx_avx512.c | 72 +++++++++---------- 1 file changed, 34 insertions(+), 38 deletions(-)
drivers/common/idpf/idpf_common_rxtx_avx512.c +34 -38
@@ -6,10 +6,6 @@#include "idpf_common_device.h" #include "idpf_common_rxtx.h" -#ifndef __INTEL_COMPILER -#pragma GCC diagnostic ignored "-Wcast-qual" -#endif -#define IDPF_DESCS_PER_LOOP_AVX 8#define PKTLEN_SHIFT 10
@@ -34,7 +30,7 @@ idpf_singleq_rearm_common(struct idpf_rx_queue *rxq) dma_addr0 =_mm_setzero_si128 ();for (i =0 ; i <IDPF_VPMD_DESCS_PER_LOOP ; i++) { rxp[i] = &rxq->fake_mbuf; -_mm_store_si128 ((__m128i *)&rxdp[i].read, + _mm_store_si128(RTE_CAST_PTR(__m128i *, &rxdp[i].read), dma_addr0); } }
@@ -108,8 +104,8 @@ idpf_singleq_rearm_common(struct idpf_rx_queue *rxq) dma_addr4_7 =_mm512_add_epi64 (dma_addr4_7, hdr_room);/* flush desc with pa dma_addr */ -_mm512_store_si512 ((__m512i *)&rxdp->read, dma_addr0_3); -_mm512_store_si512 ((__m512i *)&(rxdp +4 )->read, dma_addr4_7); + _mm512_store_si512(RTE_CAST_PTR(__m512i *, &rxdp->read), dma_addr0_3); + _mm512_store_si512(RTE_CAST_PTR(__m512i *, &(rxdp + 4)->read), dma_addr4_7); } rxq->rxrearm_start +=IDPF_RXQ_REARM_THRESH ;
@@ -164,8 +160,8 @@ idpf_singleq_rearm(struct idpf_rx_queue *rxq) dma_addr0 =_mm_setzero_si128 ();for (i =0 ; i <IDPF_VPMD_DESCS_PER_LOOP ; i++) { rxp[i] = &rxq->fake_mbuf; -_mm_storeu_si128 ((__m128i *)&rxdp[i].read, - dma_addr0); + _mm_storeu_si128(RTE_CAST_PTR + (__m128i *, &rxdp[i].read), dma_addr0); } } rte_atomic_fetch_add_explicit(&rxq->rx_stats.mbuf_alloc_failed,
@@ -216,10 +212,10 @@ idpf_singleq_rearm(struct idpf_rx_queue *rxq) iovas1);const __m512i desc6_7 =_mm512_bsrli_epi128 (desc4_5,8 ); -_mm512_storeu_si512 ((void *)rxdp, desc0_1); -_mm512_storeu_si512 ((void *)(rxdp +2 ), desc2_3); -_mm512_storeu_si512 ((void *)(rxdp +4 ), desc4_5); -_mm512_storeu_si512 ((void *)(rxdp +6 ), desc6_7); + _mm512_storeu_si512(RTE_CAST_PTR(void *, rxdp), desc0_1); + _mm512_storeu_si512(RTE_CAST_PTR(void *, (rxdp + 2)), desc2_3); + _mm512_storeu_si512(RTE_CAST_PTR(void *, (rxdp + 4)), desc4_5); + _mm512_storeu_si512(RTE_CAST_PTR(void *, (rxdp + 6)), desc6_7); rxp +=IDPF_DESCS_PER_LOOP_AVX ; rxdp +=IDPF_DESCS_PER_LOOP_AVX ;
@@ -337,28 +333,28 @@ _idpf_singleq_recv_raw_pkts_avx512(struct idpf_rx_queue *rxq,__m512i raw_desc0_3, raw_desc4_7;const __m128i raw_desc7 = -_mm_load_si128 ((void *)(rxdp +7 )); + _mm_load_si128(RTE_CAST_PTR(const __m128i *, rxdp + 7));rte_compiler_barrier ();const __m128i raw_desc6 = -_mm_load_si128 ((void *)(rxdp +6 )); + _mm_load_si128(RTE_CAST_PTR(const __m128i *, rxdp + 6));rte_compiler_barrier ();const __m128i raw_desc5 = -_mm_load_si128 ((void *)(rxdp +5 )); + _mm_load_si128(RTE_CAST_PTR(const __m128i *, rxdp + 5));rte_compiler_barrier ();const __m128i raw_desc4 = -_mm_load_si128 ((void *)(rxdp +4 )); + _mm_load_si128(RTE_CAST_PTR(const __m128i *, rxdp + 4));rte_compiler_barrier ();const __m128i raw_desc3 = -_mm_load_si128 ((void *)(rxdp +3 )); + _mm_load_si128(RTE_CAST_PTR(const __m128i *, rxdp + 3));rte_compiler_barrier ();const __m128i raw_desc2 = -_mm_load_si128 ((void *)(rxdp +2 )); + _mm_load_si128(RTE_CAST_PTR(const __m128i *, rxdp + 2));rte_compiler_barrier ();const __m128i raw_desc1 = -_mm_load_si128 ((void *)(rxdp +1 )); + _mm_load_si128(RTE_CAST_PTR(const __m128i *, rxdp + 1));rte_compiler_barrier ();const __m128i raw_desc0 = -_mm_load_si128 ((void *)(rxdp +0 )); + _mm_load_si128(RTE_CAST_PTR(const __m128i *, rxdp + 0)); raw_desc4_7 =_mm512_broadcast_i32x4 (raw_desc4); raw_desc4_7 =_mm512_inserti32x4 (raw_desc4_7, raw_desc5,1 );
@@ -560,7 +556,7 @@ idpf_splitq_rearm_common(struct idpf_rx_queue *rx_bufq) dma_addr0 =_mm_setzero_si128 ();for (i =0 ; i <IDPF_VPMD_DESCS_PER_LOOP ; i++) { rxp[i] = &rx_bufq->fake_mbuf; -_mm_store_si128 ((__m128i *)&rxdp[i], + _mm_store_si128(RTE_CAST_PTR(__m128i *, &rxdp[i]), dma_addr0); } }
@@ -634,7 +630,7 @@ idpf_splitq_rearm(struct idpf_rx_queue *rx_bufq) dma_addr0 =_mm_setzero_si128 ();for (i =0 ; i <IDPF_VPMD_DESCS_PER_LOOP ; i++) { rxp[i] = &rx_bufq->fake_mbuf; -_mm_storeu_si128 ((__m128i *)&rxdp[i], + _mm_storeu_si128(RTE_CAST_PTR(__m128i *, &rxdp[i]), dma_addr0); } }
@@ -798,28 +794,28 @@ _idpf_splitq_recv_raw_pkts_avx512(struct idpf_rx_queue *rxq,__m512i raw_desc0_3, raw_desc4_7;const __m128i raw_desc7 = -_mm_load_si128 ((void *)(rxdp +7 )); + _mm_load_si128(RTE_CAST_PTR(const __m128i *, rxdp + 7));rte_compiler_barrier ();const __m128i raw_desc6 = -_mm_load_si128 ((void *)(rxdp +6 )); + _mm_load_si128(RTE_CAST_PTR(const __m128i *, rxdp + 6));rte_compiler_barrier ();const __m128i raw_desc5 = -_mm_load_si128 ((void *)(rxdp +5 )); + _mm_load_si128(RTE_CAST_PTR(const __m128i *, rxdp + 5));rte_compiler_barrier ();const __m128i raw_desc4 = -_mm_load_si128 ((void *)(rxdp +4 )); + _mm_load_si128(RTE_CAST_PTR(const __m128i *, rxdp + 4));rte_compiler_barrier ();const __m128i raw_desc3 = -_mm_load_si128 ((void *)(rxdp +3 )); + _mm_load_si128(RTE_CAST_PTR(const __m128i *, rxdp + 3));rte_compiler_barrier ();const __m128i raw_desc2 = -_mm_load_si128 ((void *)(rxdp +2 )); + _mm_load_si128(RTE_CAST_PTR(const __m128i *, rxdp + 2));rte_compiler_barrier ();const __m128i raw_desc1 = -_mm_load_si128 ((void *)(rxdp +1 )); + _mm_load_si128(RTE_CAST_PTR(const __m128i *, rxdp + 1));rte_compiler_barrier ();const __m128i raw_desc0 = -_mm_load_si128 ((void *)(rxdp +0 )); + _mm_load_si128(RTE_CAST_PTR(const __m128i *, rxdp + 0)); raw_desc4_7 =_mm512_broadcast_i32x4 (raw_desc4); raw_desc4_7 =_mm512_inserti32x4 (raw_desc4_7, raw_desc5,1 );
@@ -1131,7 +1127,7 @@ idpf_singleq_vtx1(volatile struct idpf_base_tx_desc *txdp,__m128i descriptor =_mm_set_epi64x (high_qw, pkt->buf_iova + pkt->data_off); -_mm_storeu_si128 ((__m128i *)txdp, descriptor); + _mm_storeu_si128(RTE_CAST_PTR(__m128i *, txdp), descriptor); }#define IDPF_TX_LEN_MASK 0xAA
@@ -1178,7 +1174,7 @@ idpf_singleq_vtx(volatile struct idpf_base_tx_desc *txdp, pkt[1 ]->buf_iova + pkt[1 ]->data_off, hi_qw0, pkt[0]->buf_iova + pkt[0]->data_off); -_mm512_storeu_si512 ((void *)txdp, desc0_3); + _mm512_storeu_si512(RTE_CAST_PTR(void *, txdp), desc0_3); }/* do any last ones */
@@ -1435,7 +1431,7 @@ idpf_splitq_vtx1(volatile struct idpf_flex_tx_sched_desc *txdp,__m128i descriptor =_mm_set_epi64x (high_qw, pkt->buf_iova + pkt->data_off); -_mm_storeu_si128 ((__m128i *)txdp, descriptor); + _mm_storeu_si128(RTE_CAST_PTR(__m128i *, txdp), descriptor); }static __rte_always_inline void
@@ -1480,7 +1476,7 @@ idpf_splitq_vtx(volatile struct idpf_flex_tx_sched_desc *txdp, pkt[1 ]->buf_iova + pkt[1 ]->data_off, hi_qw0, pkt[0]->buf_iova + pkt[0]->data_off); -_mm512_storeu_si512 ((void *)txdp, desc0_3); + _mm512_storeu_si512(RTE_CAST_PTR(void *, txdp), desc0_3); }/* do any last ones */
@@ -1521,11 +1517,11 @@ idpf_splitq_xmit_fixed_burst_vec_avx512(void *tx_queue, struct rte_mbuf **tx_pktif (nb_commit >= n) {tx_backlog_entry_avx512 (txep, tx_pkts, n); -idpf_splitq_vtx ((void *)txdp, tx_pkts, n -1 , cmd_dtype); +idpf_splitq_vtx (txdp, tx_pkts, n -1 , cmd_dtype); tx_pkts += (n -1 ); txdp += (n -1 ); -idpf_splitq_vtx1 ((void *)txdp, *tx_pkts++, cmd_dtype); +idpf_splitq_vtx1 (txdp, *tx_pkts++, cmd_dtype); nb_commit = (uint16_t )(nb_commit - n);
@@ -1540,7 +1536,7 @@ idpf_splitq_xmit_fixed_burst_vec_avx512(void *tx_queue, struct rte_mbuf **tx_pkttx_backlog_entry_avx512 (txep, tx_pkts, nb_commit); -idpf_splitq_vtx ((void *)txdp, tx_pkts, nb_commit, cmd_dtype); +idpf_splitq_vtx (txdp, tx_pkts, nb_commit, cmd_dtype); tx_id = (uint16_t )(tx_id + nb_commit);if (tx_id > txq->next_rs)
Signature · 1 line
2.47.2.vfs.0.1
RE: [PATCH v16 2/3] drivers/common: add diagnostics macros to make code portable
Quoted 10 lines
From: Andre Muezerie [mailto:[email protected]]
Sent: Tuesday, 21 January 2025 23.36It was a common pattern to have "GCC diagnostic ignored" pragmas sprinkled over the code and only activate these pragmas for certain compilers (gcc and clang). Clang supports GCC's pragma for compatibility with existing source code, so #pragma GCC diagnostic and #pragma clang diagnostic are synonyms for Clang
(https://clang.llvm.org/docs/UsersManual.html).
Quoted 8 lines
Now that effort is being made to make the code compatible with MSVC these expressions would become more complex. It makes sense to hide this complexity behind macros. This makes maintenance easier as these macros are defined in a single place. As a plus the code becomes more readable as well.
Signed-off-by Andre Muezerie <[email protected]>---
PATCH v16 3/3 drivers/net: add diagnostics macros to make code portable
In reply to Andre MuezerieIt was a common pattern to have "GCC diagnostic ignored" pragmas sprinkled over the code and only activate these pragmas for certain compilers (gcc and clang). Clang supports GCC's pragma for compatibility with existing source code, so #pragma GCC diagnostic and #pragma clang diagnostic are synonyms for Clang
(https://clang.llvm.org/docs/UsersManual.html).
Now that effort is being made to make the code compatible with MSVC these expressions would become more complex. It makes sense to hide this complexity behind macros. This makes maintenance easier as these macros are defined in a single place. As a plus the code becomes more readable as well.
--- drivers/net/axgbe/axgbe_rxtx.h | 9 --- drivers/net/cpfl/cpfl_rxtx_vec_common.h | 4 - drivers/net/dpaa2/dpaa2_rxtx.c | 15 +--- drivers/net/fm10k/fm10k_rxtx_vec.c | 21 ++---- drivers/net/hns3/hns3_rxtx_vec_neon.h | 6 +- .../net/i40e/i40e_recycle_mbufs_vec_common.c | 2 - drivers/net/i40e/i40e_rxtx_common_avx.h | 22 +++--- drivers/net/i40e/i40e_rxtx_vec_altivec.c | 18 ++--- drivers/net/i40e/i40e_rxtx_vec_avx2.c | 30 ++++---- drivers/net/i40e/i40e_rxtx_vec_avx512.c | 28 +++---- drivers/net/i40e/i40e_rxtx_vec_common.h | 4 - drivers/net/i40e/i40e_rxtx_vec_neon.c | 35 ++++----- drivers/net/i40e/i40e_rxtx_vec_sse.c | 28 +++---- drivers/net/iavf/iavf_rxtx_vec_avx2.c | 60 +++++++-------- drivers/net/iavf/iavf_rxtx_vec_avx512.c | 62 ++++++++-------- drivers/net/iavf/iavf_rxtx_vec_common.h | 10 +-- drivers/net/iavf/iavf_rxtx_vec_neon.c | 22 +++--- drivers/net/iavf/iavf_rxtx_vec_sse.c | 38 +++++----- drivers/net/ice/ice_rxtx_common_avx.h | 18 ++--- drivers/net/ice/ice_rxtx_vec_avx2.c | 74 +++++++++---------- drivers/net/ice/ice_rxtx_vec_avx512.c | 64 +++++++--------- drivers/net/ice/ice_rxtx_vec_common.h | 4 - drivers/net/ice/ice_rxtx_vec_sse.c | 28 +++---- drivers/net/idpf/idpf_rxtx_vec_common.h | 4 - .../ixgbe/ixgbe_recycle_mbufs_vec_common.c | 2 - drivers/net/ixgbe/ixgbe_rxtx_vec_neon.c | 18 ++--- drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c | 20 ++--- drivers/net/mlx5/mlx5_flow.c | 5 +- drivers/net/mlx5/mlx5_rxtx_vec_altivec.h | 5 -- drivers/net/mlx5/mlx5_rxtx_vec_neon.h | 18 ++--- drivers/net/mlx5/mlx5_rxtx_vec_sse.h | 61 ++++++++------- drivers/net/ngbe/ngbe_rxtx_vec_neon.c | 8 +- drivers/net/tap/tap_flow.c | 6 +- drivers/net/txgbe/txgbe_rxtx_vec_neon.c | 8 +- drivers/net/virtio/virtio_rxtx_simple.c | 4 - 35 files changed, 316 insertions(+), 445 deletions(-)
drivers/net/axgbe/axgbe_rxtx.h +0 -9
@@ -6,15 +6,6 @@#ifndef _AXGBE_RXTX_H_#define _AXGBE_RXTX_H_ -/* to suppress gcc warnings related to descriptor casting*/ -#ifdef RTE_TOOLCHAIN_GCC -#pragma GCC diagnostic ignored "-Wcast-qual" -#endif - -#ifdef RTE_TOOLCHAIN_CLANG -#pragma GCC diagnostic ignored "-Wcast-qual" -#endif -/* Descriptor related defines */ #define AXGBE_MAX_RING_DESC 4096/*should be power of 2*/ #define AXGBE_TX_DESC_MIN_FREE (AXGBE_MAX_RING_DESC >> 3)
drivers/net/cpfl/cpfl_rxtx_vec_common.h +0 -4
@@ -11,10 +11,6 @@#include "cpfl_ethdev.h" #include "cpfl_rxtx.h" -#ifndef __INTEL_COMPILER -#pragma GCC diagnostic ignored "-Wcast-qual" -#endif -#define CPFL_SCALAR_PATH 0#define CPFL_VECTOR_PATH 1#define CPFL_RX_NO_VECTOR_FLAGS ( \
drivers/net/dpaa2/dpaa2_rxtx.c +1 -14
@@ -1962,14 +1962,6 @@ dpaa2_dev_tx_ordered(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)return num_tx; } -#if defined(RTE_TOOLCHAIN_GCC ) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wcast-qual" -#elif defined(RTE_TOOLCHAIN_CLANG ) -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wcast-qual" -#endif -/* This function loopbacks all the received packets.*/ uint16_t dpaa2_dev_loopback_rx(void *queue,
@@ -2083,7 +2075,7 @@ dpaa2_dev_loopback_rx(void *queue,if (unlikely ((status &QBMAN_DQ_STAT_VALIDFRAME ) ==0 ))continue ; } - fd[num_rx] = (struct qbman_fd *)qbman_result_DQ_fd (dq_storage); + fd[num_rx] =RTE_PTR_UNQUAL (qbman_result_DQ_fd (dq_storage)); dq_storage++; num_rx++;
@@ -2118,8 +2110,3 @@ dpaa2_dev_loopback_rx(void *queue,return 0 ; } -#if defined(RTE_TOOLCHAIN_GCC ) -#pragma GCC diagnostic pop -#elif defined(RTE_TOOLCHAIN_CLANG ) -#pragma clang diagnostic pop -#endif
drivers/net/fm10k/fm10k_rxtx_vec.c +8 -13
@@ -11,10 +11,6 @@#include <rte_vect.h> -#ifndef __INTEL_COMPILER -#pragma GCC diagnostic ignored "-Wcast-qual" -#endif -static void fm10k_reset_tx_queue (struct fm10k_tx_queue *txq);
@@ -270,8 +266,7 @@ fm10k_rxq_rearm(struct fm10k_rx_queue *rxq)/* Clean up all the HW/SW ring content */ for (i =0 ; i <RTE_FM10K_RXQ_REARM_THRESH ; i++) { mb_alloc[i] = &rxq->fake_mbuf; -_mm_store_si128 ((__m128i *)&rxdp[i].q, - dma_addr0); + _mm_store_si128(RTE_CAST_PTR(__m128i *, &rxdp[i].q), dma_addr0); } rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
@@ -316,8 +311,8 @@ fm10k_rxq_rearm(struct fm10k_rx_queue *rxq) dma_addr1 =_mm_and_si128 (dma_addr1, hba_msk);/* flush desc with pa dma_addr */ -_mm_store_si128 ((__m128i *)&rxdp++->q, dma_addr0); -_mm_store_si128 ((__m128i *)&rxdp++->q, dma_addr1); + _mm_store_si128(RTE_CAST_PTR(__m128i *, &rxdp++->q), dma_addr0); + _mm_store_si128(RTE_CAST_PTR(__m128i *, &rxdp++->q), dma_addr1);/* enforce 512B alignment on default Rx virtual addresses */ mb0->data_off = (uint16_t)(RTE_PTR_ALIGN((char *)mb0->buf_addr
@@ -465,7 +460,7 @@ fm10k_recv_raw_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,/* Read desc statuses backwards to avoid race condition */ /* A.1 load desc[3] */ - descs0[3 ] =_mm_loadu_si128 ((__m128i *)(rxdp +3 )); + descs0[3] = _mm_loadu_si128(RTE_CAST_PTR(__m128i *, rxdp + 3));rte_compiler_barrier ();/* B.2 copy 2 64 bit or 4 32 bit mbuf point into rx_pkts */
@@ -477,11 +472,11 @@ fm10k_recv_raw_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,#endif /* A.1 load desc[2-0] */ - descs0[2 ] =_mm_loadu_si128 ((__m128i *)(rxdp +2 )); + descs0[2] = _mm_loadu_si128(RTE_CAST_PTR(__m128i *, rxdp + 2));rte_compiler_barrier (); - descs0[1 ] =_mm_loadu_si128 ((__m128i *)(rxdp +1 )); + descs0[1] = _mm_loadu_si128(RTE_CAST_PTR(__m128i *, rxdp + 1));rte_compiler_barrier (); - descs0[0 ] =_mm_loadu_si128 ((__m128i *)(rxdp)); + descs0[0] = _mm_loadu_si128(RTE_CAST_PTR(__m128i *, rxdp));#if defined(RTE_ARCH_X86_64 )/* B.2 copy 2 mbuf point into rx_pkts */
@@ -736,7 +731,7 @@ vtx1(volatile struct fm10k_tx_desc *txdp,__m128i descriptor =_mm_set_epi64x (flags <<56 | (uint64_t )pkt->vlan_tci <<16 | (uint64_t )pkt->data_len,MBUF_DMA_ADDR (pkt)); -_mm_store_si128 ((__m128i *)txdp, descriptor); + _mm_store_si128(RTE_CAST_PTR(__m128i *, txdp), descriptor); } static inline void
drivers/net/hns3/hns3_rxtx_vec_neon.h +2 -4
@@ -9,8 +9,6 @@#include <arm_neon.h> -#pragma GCC diagnostic ignored "-Wcast-qual" -static inline void hns3_vec_tx (volatile struct hns3_desc *desc,struct rte_mbuf *pkt) {
@@ -22,8 +20,8 @@ hns3_vec_tx(volatile struct hns3_desc *desc, struct rte_mbuf *pkt)0 , ((uint64_t )HNS3_TXD_DEFAULT_VLD_FE_BDTYPE ) <<HNS3_UINT32_BIT }; -vst1q_u64 ((uint64_t *)&desc->addr, val1); -vst1q_u64 ((uint64_t *)&desc->tx.outer_vlan_tag, val2); + vst1q_u64(RTE_CAST_PTR(uint64_t *, &desc->addr), val1); + vst1q_u64(RTE_CAST_PTR(uint64_t *, &desc->tx.outer_vlan_tag), val2); } static uint16_t
drivers/net/i40e/i40e_recycle_mbufs_vec_common.c +0 -2
@@ -10,8 +10,6 @@#include "i40e_ethdev.h" #include "i40e_rxtx.h" -#pragma GCC diagnostic ignored "-Wcast-qual" -void i40e_recycle_rx_descriptors_refill_vec (void *rx_queue,uint16_t nb_mbufs) {
drivers/net/i40e/i40e_rxtx_common_avx.h +11 -11
@@ -11,10 +11,6 @@#include "i40e_ethdev.h" #include "i40e_rxtx.h" -#ifndef __INTEL_COMPILER -#pragma GCC diagnostic ignored "-Wcast-qual" -#endif -#ifdef __AVX2__ static __rte_always_inline void i40e_rxq_rearm_common(struct i40e_rx_queue *rxq, __rte_unused bool avx512)
@@ -36,7 +32,7 @@ i40e_rxq_rearm_common(struct i40e_rx_queue *rxq, __rte_unused bool avx512) dma_addr0 =_mm_setzero_si128 ();for (i =0 ; i <RTE_I40E_DESCS_PER_LOOP ; i++) { rxep[i].mbuf = &rxq->fake_mbuf; -_mm_store_si128 ((__m128i *)&rxdp[i].read, + _mm_store_si128(RTE_CAST_PTR(__m128i *, &rxdp[i].read), dma_addr0); } }
@@ -72,8 +68,8 @@ i40e_rxq_rearm_common(struct i40e_rx_queue *rxq, __rte_unused bool avx512) dma_addr1 =_mm_add_epi64 (dma_addr1, hdr_room);/* flush desc with pa dma_addr */ -_mm_store_si128 ((__m128i *)&rxdp++->read, dma_addr0); - _mm_store_si128((__m128i *)&rxdp++->read, dma_addr1); + _mm_store_si128(RTE_CAST_PTR(__m128i *, &rxdp++->read), dma_addr0); + _mm_store_si128(RTE_CAST_PTR(__m128i *, &rxdp++->read), dma_addr1); }#else #ifdef __AVX512VL__
@@ -144,8 +140,10 @@ i40e_rxq_rearm_common(struct i40e_rx_queue *rxq, __rte_unused bool avx512) dma_addr4_7 =_mm512_add_epi64 (dma_addr4_7, hdr_room);/* flush desc with pa dma_addr */ -_mm512_store_si512 ((__m512i *)&rxdp->read, dma_addr0_3); - _mm512_store_si512((__m512i *)&(rxdp + 4)->read, dma_addr4_7); + _mm512_store_si512(RTE_CAST_PTR(__m512i *, + &rxdp->read), dma_addr0_3); + _mm512_store_si512(RTE_CAST_PTR(__m512i *, + &(rxdp + 4)->read), dma_addr4_7); } } else#endif /* __AVX512VL__*/
@@ -190,8 +188,10 @@ i40e_rxq_rearm_common(struct i40e_rx_queue *rxq, __rte_unused bool avx512) dma_addr2_3 =_mm256_add_epi64 (dma_addr2_3, hdr_room);/* flush desc with pa dma_addr */ -_mm256_store_si256 ((__m256i *)&rxdp->read, dma_addr0_1); -_mm256_store_si256 ((__m256i *)&(rxdp +2 )->read, dma_addr2_3); + _mm256_store_si256(RTE_CAST_PTR(__m256i *, + &rxdp->read), dma_addr0_1); + _mm256_store_si256(RTE_CAST_PTR(__m256i *, + &(rxdp + 2)->read), dma_addr2_3); } }
drivers/net/i40e/i40e_rxtx_vec_altivec.c +8 -10
@@ -15,8 +15,6 @@#include <rte_altivec.h> -#pragma GCC diagnostic ignored "-Wcast-qual" -static inline void i40e_rxq_rearm (struct i40e_rx_queue *rxq) {
@@ -44,7 +42,7 @@ i40e_rxq_rearm(struct i40e_rx_queue *rxq)for (i =0 ; i <RTE_I40E_DESCS_PER_LOOP ; i++) { rxep[i].mbuf = &rxq->fake_mbuf;vec_st (dma_addr0,0 , - (__vector unsigned long *)&rxdp[i].read); + RTE_CAST_PTR(__vector unsigned long *, &rxdp[i].read)); } } rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
@@ -84,8 +82,8 @@ i40e_rxq_rearm(struct i40e_rx_queue *rxq) dma_addr1 =vec_add (dma_addr1, hdr_room);/* flush desc with pa dma_addr */ -vec_st (dma_addr0,0 , (__vector unsigned long *)&rxdp++->read); -vec_st (dma_addr1,0 , (__vector unsigned long *)&rxdp++->read); + vec_st(dma_addr0, 0, RTE_CAST_PTR(__vector unsigned long *, &rxdp++->read)); + vec_st(dma_addr1, 0, RTE_CAST_PTR(__vector unsigned long *, &rxdp++->read)); } rxq->rxrearm_start +=RTE_I40E_RXQ_REARM_THRESH ;
@@ -286,7 +284,7 @@ _recv_raw_pkts_vec(struct i40e_rx_queue *rxq, struct rte_mbuf **rx_pkts, mbp1 = *(__vector unsigned long *)&sw_ring[pos];/* Read desc statuses backwards to avoid race condition */ /* A.1 load desc[3] */ - descs[3 ] = *(__vector unsigned long *)(rxdp +3 ); + descs[3] = *RTE_CAST_PTR(__vector unsigned long *, rxdp + 3);rte_compiler_barrier ();/* B.2 copy 2 mbuf point into rx_pkts */
@@ -296,11 +294,11 @@ _recv_raw_pkts_vec(struct i40e_rx_queue *rxq, struct rte_mbuf **rx_pkts, mbp2 = *(__vector unsigned long *)&sw_ring[pos +2 ];/* A.1 load desc[2-0] */ - descs[2 ] = *(__vector unsigned long *)(rxdp +2 ); + descs[2] = *RTE_CAST_PTR(__vector unsigned long *, rxdp + 2);rte_compiler_barrier (); - descs[1 ] = *(__vector unsigned long *)(rxdp +1 ); + descs[1] = *RTE_CAST_PTR(__vector unsigned long *, rxdp + 1);rte_compiler_barrier (); - descs[0 ] = *(__vector unsigned long *)(rxdp); + descs[0] = *RTE_CAST_PTR(__vector unsigned long *, rxdp);/* B.2 copy 2 mbuf point into rx_pkts */ *(__vector unsigned long *)&rx_pkts[pos +2 ] = mbp2;
@@ -534,7 +532,7 @@ vtx1(volatile struct i40e_tx_desc *txdp,__vector unsigned long descriptor = (__vector unsigned long ){ pkt->buf_iova + pkt->data_off, high_qw}; - *(__vector unsigned long *)txdp = descriptor; + *RTE_CAST_PTR(__vector unsigned long *, txdp) = descriptor; } static inline void
drivers/net/i40e/i40e_rxtx_vec_avx2.c +13 -17
@@ -15,10 +15,6 @@#include <rte_vect.h> -#ifndef __INTEL_COMPILER -#pragma GCC diagnostic ignored "-Wcast-qual" -#endif - static __rte_always_inline voidi40e_rxq_rearm (struct i40e_rx_queue *rxq) {
@@ -39,8 +35,8 @@ desc_fdir_processing_32b(volatile union i40e_rx_desc *rxdp, const uint32_t desc_idx) {/* 32B desc path: load rxdp.wb.qword2 for EXT_STATUS and FLEXBH_STAT */ -__m128i *rxdp_desc_0 = (void *)(&rxdp[desc_idx +0 ].wb.qword2); -__m128i *rxdp_desc_1 = (void *)(&rxdp[desc_idx +1 ].wb.qword2); + __m128i *rxdp_desc_0 = RTE_CAST_PTR(__m128i *, &rxdp[desc_idx + 0].wb.qword2); + __m128i *rxdp_desc_1 = RTE_CAST_PTR(__m128i *, &rxdp[desc_idx + 1].wb.qword2);const __m128i desc_qw2_0 =_mm_load_si128 (rxdp_desc_0);const __m128i desc_qw2_1 =_mm_load_si128 (rxdp_desc_1);
@@ -276,21 +272,21 @@ _recv_raw_pkts_vec_avx2(struct i40e_rx_queue *rxq, struct rte_mbuf **rx_pkts, _mm256_loadu_si256((void *)&sw_ring[i + 4]));#endif -const __m128i raw_desc7 =_mm_load_si128 ((void *)(rxdp +7 )); + const __m128i raw_desc7 = _mm_load_si128(RTE_CAST_PTR(const __m128i *, rxdp + 7));rte_compiler_barrier (); -const __m128i raw_desc6 =_mm_load_si128 ((void *)(rxdp +6 )); + const __m128i raw_desc6 = _mm_load_si128(RTE_CAST_PTR(const __m128i *, rxdp + 6));rte_compiler_barrier (); -const __m128i raw_desc5 =_mm_load_si128 ((void *)(rxdp +5 )); + const __m128i raw_desc5 = _mm_load_si128(RTE_CAST_PTR(const __m128i *, rxdp + 5));rte_compiler_barrier (); -const __m128i raw_desc4 =_mm_load_si128 ((void *)(rxdp +4 )); + const __m128i raw_desc4 = _mm_load_si128(RTE_CAST_PTR(const __m128i *, rxdp + 4));rte_compiler_barrier (); -const __m128i raw_desc3 =_mm_load_si128 ((void *)(rxdp +3 )); + const __m128i raw_desc3 = _mm_load_si128(RTE_CAST_PTR(const __m128i *, rxdp + 3));rte_compiler_barrier (); -const __m128i raw_desc2 =_mm_load_si128 ((void *)(rxdp +2 )); + const __m128i raw_desc2 = _mm_load_si128(RTE_CAST_PTR(const __m128i *, rxdp + 2));rte_compiler_barrier (); -const __m128i raw_desc1 =_mm_load_si128 ((void *)(rxdp +1 )); + const __m128i raw_desc1 = _mm_load_si128(RTE_CAST_PTR(const __m128i *, rxdp + 1));rte_compiler_barrier (); -const __m128i raw_desc0 =_mm_load_si128 ((void *)(rxdp +0 )); + const __m128i raw_desc0 = _mm_load_si128(RTE_CAST_PTR(const __m128i *, rxdp + 0));const __m256i raw_desc6_7 =_mm256_inserti128_si256 (_mm256_castsi128_si256 (raw_desc6), raw_desc7,1 );
@@ -695,7 +691,7 @@ vtx1(volatile struct i40e_tx_desc *txdp,__m128i descriptor =_mm_set_epi64x (high_qw, pkt->buf_iova + pkt->data_off); -_mm_store_si128 ((__m128i *)txdp, descriptor); + _mm_store_si128(RTE_CAST_PTR(__m128i *, txdp), descriptor); } static inline void
@@ -728,8 +724,8 @@ vtx(volatile struct i40e_tx_desc *txdp,__m256i desc0_1 =_mm256_set_epi64x ( hi_qw1, pkt[1 ]->buf_iova + pkt[1 ]->data_off, hi_qw0, pkt[0 ]->buf_iova + pkt[0 ]->data_off); -_mm256_store_si256 ((void *)(txdp +2 ), desc2_3); -_mm256_store_si256 ((void *)txdp, desc0_1); + _mm256_store_si256(RTE_CAST_PTR(__m256i *, txdp + 2), desc2_3); + _mm256_store_si256(RTE_CAST_PTR(__m256i *, txdp), desc0_1); }/* do any last ones */
drivers/net/i40e/i40e_rxtx_vec_avx512.c +12 -16
@@ -15,10 +15,6 @@#include <rte_vect.h> -#ifndef __INTEL_COMPILER -#pragma GCC diagnostic ignored "-Wcast-qual" -#endif -#define RTE_I40E_DESCS_PER_LOOP_AVX 8static __rte_always_inline void
@@ -41,8 +37,8 @@ desc_fdir_processing_32b(volatile union i40e_rx_desc *rxdp, const uint32_t desc_idx) {/* 32B desc path: load rxdp.wb.qword2 for EXT_STATUS and FLEXBH_STAT */ -__m128i *rxdp_desc_0 = (void *)(&rxdp[desc_idx +0 ].wb.qword2); -__m128i *rxdp_desc_1 = (void *)(&rxdp[desc_idx +1 ].wb.qword2); + __m128i *rxdp_desc_0 = RTE_CAST_PTR(__m128i *, &rxdp[desc_idx + 0].wb.qword2); + __m128i *rxdp_desc_1 = RTE_CAST_PTR(__m128i *, &rxdp[desc_idx + 1].wb.qword2);const __m128i desc_qw2_0 =_mm_load_si128 (rxdp_desc_0);const __m128i desc_qw2_1 =_mm_load_si128 (rxdp_desc_1);
@@ -264,28 +260,28 @@ _recv_raw_pkts_vec_avx512(struct i40e_rx_queue *rxq, struct rte_mbuf **rx_pkts,/* load in descriptors, in reverse order */ const __m128i raw_desc7 = -_mm_load_si128 ((void *)(rxdp +7 )); + _mm_load_si128(RTE_CAST_PTR(const __m128i *, rxdp + 7));rte_compiler_barrier ();const __m128i raw_desc6 = -_mm_load_si128 ((void *)(rxdp +6 )); + _mm_load_si128(RTE_CAST_PTR(const __m128i *, rxdp + 6));rte_compiler_barrier ();const __m128i raw_desc5 = -_mm_load_si128 ((void *)(rxdp +5 )); + _mm_load_si128(RTE_CAST_PTR(const __m128i *, rxdp + 5));rte_compiler_barrier ();const __m128i raw_desc4 = -_mm_load_si128 ((void *)(rxdp +4 )); + _mm_load_si128(RTE_CAST_PTR(const __m128i *, rxdp + 4));rte_compiler_barrier ();const __m128i raw_desc3 = -_mm_load_si128 ((void *)(rxdp +3 )); + _mm_load_si128(RTE_CAST_PTR(const __m128i *, rxdp + 3));rte_compiler_barrier ();const __m128i raw_desc2 = -_mm_load_si128 ((void *)(rxdp +2 )); + _mm_load_si128(RTE_CAST_PTR(const __m128i *, rxdp + 2));rte_compiler_barrier ();const __m128i raw_desc1 = -_mm_load_si128 ((void *)(rxdp +1 )); + _mm_load_si128(RTE_CAST_PTR(const __m128i *, rxdp + 1));rte_compiler_barrier ();const __m128i raw_desc0 = -_mm_load_si128 ((void *)(rxdp +0 )); + _mm_load_si128(RTE_CAST_PTR(const __m128i *, rxdp + 0)); raw_desc6_7 = _mm256_inserti128_si256
@@ -875,7 +871,7 @@ vtx1(volatile struct i40e_tx_desc *txdp, struct rte_mbuf *pkt, uint64_t flags)__m128i descriptor =_mm_set_epi64x (high_qw, pkt->buf_iova + pkt->data_off); -_mm_store_si128 ((__m128i *)txdp, descriptor); + _mm_store_si128(RTE_CAST_PTR(__m128i *, txdp), descriptor); } static inline void
@@ -909,7 +905,7 @@ vtx(volatile struct i40e_tx_desc *txdp, hi_qw2, pkt[2 ]->buf_iova + pkt[2 ]->data_off, hi_qw1, pkt[1 ]->buf_iova + pkt[1 ]->data_off, hi_qw0, pkt[0]->buf_iova + pkt[0]->data_off); -_mm512_storeu_si512 ((void *)txdp, desc0_3); + _mm512_storeu_si512(RTE_CAST_PTR(void *, txdp), desc0_3); }/* do any last ones */
drivers/net/i40e/i40e_rxtx_vec_common.h +0 -4
@@ -11,10 +11,6 @@#include "i40e_ethdev.h" #include "i40e_rxtx.h" -#ifndef __INTEL_COMPILER -#pragma GCC diagnostic ignored "-Wcast-qual" -#endif -static inline uint16_t reassemble_packets (struct i40e_rx_queue *rxq,struct rte_mbuf **rx_bufs,uint16_t nb_bufs,uint8_t *split_flags)
drivers/net/i40e/i40e_rxtx_vec_neon.c +16 -19
@@ -16,9 +16,6 @@#include "i40e_rxtx.h" #include "i40e_rxtx_vec_common.h" - -#pragma GCC diagnostic ignored "-Wcast-qual" -static inline void i40e_rxq_rearm (struct i40e_rx_queue *rxq) {
@@ -41,7 +38,7 @@ i40e_rxq_rearm(struct i40e_rx_queue *rxq) rxq->nb_rx_desc) {for (i =0 ; i <RTE_I40E_DESCS_PER_LOOP ; i++) { rxep[i].mbuf = &rxq->fake_mbuf; -vst1q_u64 ((uint64_t *)&rxdp[i].read, zero); + vst1q_u64(RTE_CAST_PTR(uint64_t *, &rxdp[i].read), zero); } } rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
@@ -58,11 +55,11 @@ i40e_rxq_rearm(struct i40e_rx_queue *rxq) dma_addr0 =vdupq_n_u64 (paddr);/* flush desc with pa dma_addr */ -vst1q_u64 ((uint64_t *)&rxdp++->read, dma_addr0); + vst1q_u64(RTE_CAST_PTR(uint64_t *, &rxdp++->read), dma_addr0); paddr = mb1->buf_iova +RTE_PKTMBUF_HEADROOM ; dma_addr1 =vdupq_n_u64 (paddr); -vst1q_u64 ((uint64_t *)&rxdp++->read, dma_addr1); + vst1q_u64(RTE_CAST_PTR(uint64_t *, &rxdp++->read), dma_addr1); } rxq->rxrearm_start +=RTE_I40E_RXQ_REARM_THRESH ;
@@ -87,10 +84,10 @@ descs_to_fdir_32b(volatile union i40e_rx_desc *rxdp, struct rte_mbuf **rx_pkt) {/* 32B descriptors: Load 2nd half of descriptors for FDIR ID data */ uint64x2_t desc0_qw23, desc1_qw23, desc2_qw23, desc3_qw23; - desc0_qw23 =vld1q_u64 ((uint64_t *)&(rxdp +0 )->wb.qword2); - desc1_qw23 =vld1q_u64 ((uint64_t *)&(rxdp +1 )->wb.qword2); - desc2_qw23 =vld1q_u64 ((uint64_t *)&(rxdp +2 )->wb.qword2); - desc3_qw23 =vld1q_u64 ((uint64_t *)&(rxdp +3 )->wb.qword2); + desc0_qw23 = vld1q_u64(RTE_CAST_PTR(uint64_t *, &(rxdp + 0)->wb.qword2)); + desc1_qw23 = vld1q_u64(RTE_CAST_PTR(uint64_t *, &(rxdp + 1)->wb.qword2)); + desc2_qw23 = vld1q_u64(RTE_CAST_PTR(uint64_t *, &(rxdp + 2)->wb.qword2)); + desc3_qw23 = vld1q_u64(RTE_CAST_PTR(uint64_t *, &(rxdp + 3)->wb.qword2));/* FDIR ID data: move last u32 of each desc to 4 u32 lanes */ uint32x4_t v_unpack_02, v_unpack_13;
@@ -421,18 +418,18 @@ _recv_raw_pkts_vec(struct i40e_rx_queue *__rte_restrict rxq,int32x4_t len_shl = {0 ,0 ,0 ,PKTLEN_SHIFT };/* A.1 load desc[3-0] */ - descs[3 ] =vld1q_u64 ((uint64_t *)(rxdp +3 )); - descs[2 ] =vld1q_u64 ((uint64_t *)(rxdp +2 )); - descs[1 ] =vld1q_u64 ((uint64_t *)(rxdp +1 )); - descs[0 ] =vld1q_u64 ((uint64_t *)(rxdp)); + descs[3] = vld1q_u64(RTE_CAST_PTR(uint64_t *, rxdp + 3)); + descs[2] = vld1q_u64(RTE_CAST_PTR(uint64_t *, rxdp + 2)); + descs[1] = vld1q_u64(RTE_CAST_PTR(uint64_t *, rxdp + 1)); + descs[0] = vld1q_u64(RTE_CAST_PTR(uint64_t *, rxdp));/* Use acquire fence to order loads of descriptor qwords */ rte_atomic_thread_fence (rte_memory_order_acquire);/* A.2 reload qword0 to make it ordered after qword1 load */ - descs[3 ] =vld1q_lane_u64 ((uint64_t *)(rxdp +3 ), descs[3 ],0 ); - descs[2 ] =vld1q_lane_u64 ((uint64_t *)(rxdp +2 ), descs[2 ],0 ); - descs[1 ] =vld1q_lane_u64 ((uint64_t *)(rxdp +1 ), descs[1 ],0 ); - descs[0 ] =vld1q_lane_u64 ((uint64_t *)(rxdp), descs[0 ],0 ); + descs[3] = vld1q_lane_u64(RTE_CAST_PTR(uint64_t *, rxdp + 3), descs[3], 0); + descs[2] = vld1q_lane_u64(RTE_CAST_PTR(uint64_t *, rxdp + 2), descs[2], 0); + descs[1] = vld1q_lane_u64(RTE_CAST_PTR(uint64_t *, rxdp + 1), descs[1], 0); + descs[0] = vld1q_lane_u64(RTE_CAST_PTR(uint64_t *, rxdp), descs[0], 0);/* B.1 load 4 mbuf point */ mbp1 =vld1q_u64 ((uint64_t *)&sw_ring[pos]);
@@ -662,7 +659,7 @@ vtx1(volatile struct i40e_tx_desc *txdp, ((uint64_t)pkt->data_len << I40E_TXD_QW1_TX_BUF_SZ_SHIFT));uint64x2_t descriptor = {pkt->buf_iova + pkt->data_off, high_qw}; -vst1q_u64 ((uint64_t *)txdp, descriptor); + vst1q_u64(RTE_CAST_PTR(uint64_t *, txdp), descriptor); } static inline void
drivers/net/i40e/i40e_rxtx_vec_sse.c +12 -16
@@ -14,10 +14,6 @@#include <rte_vect.h> -#ifndef __INTEL_COMPILER -#pragma GCC diagnostic ignored "-Wcast-qual" -#endif -static inline void i40e_rxq_rearm (struct i40e_rx_queue *rxq) {
@@ -41,7 +37,7 @@ i40e_rxq_rearm(struct i40e_rx_queue *rxq) dma_addr0 =_mm_setzero_si128 ();for (i =0 ; i <RTE_I40E_DESCS_PER_LOOP ; i++) { rxep[i].mbuf = &rxq->fake_mbuf; -_mm_store_si128 ((__m128i *)&rxdp[i].read, + _mm_store_si128(RTE_CAST_PTR(__m128i *, &rxdp[i].read), dma_addr0); } }
@@ -72,8 +68,8 @@ i40e_rxq_rearm(struct i40e_rx_queue *rxq) dma_addr1 =_mm_add_epi64 (dma_addr1, hdr_room);/* flush desc with pa dma_addr */ -_mm_store_si128 ((__m128i *)&rxdp++->read, dma_addr0); -_mm_store_si128 ((__m128i *)&rxdp++->read, dma_addr1); + _mm_store_si128(RTE_CAST_PTR(__m128i *, &rxdp++->read), dma_addr0); + _mm_store_si128(RTE_CAST_PTR(__m128i *, &rxdp++->read), dma_addr1); } rxq->rxrearm_start +=RTE_I40E_RXQ_REARM_THRESH ;
@@ -97,10 +93,10 @@ descs_to_fdir_32b(volatile union i40e_rx_desc *rxdp, struct rte_mbuf **rx_pkt) {/* 32B descriptors: Load 2nd half of descriptors for FDIR ID data */ __m128i desc0_qw23, desc1_qw23, desc2_qw23, desc3_qw23; - desc0_qw23 =_mm_loadu_si128 ((__m128i *)&(rxdp +0 )->wb.qword2); - desc1_qw23 =_mm_loadu_si128 ((__m128i *)&(rxdp +1 )->wb.qword2); - desc2_qw23 =_mm_loadu_si128 ((__m128i *)&(rxdp +2 )->wb.qword2); - desc3_qw23 =_mm_loadu_si128 ((__m128i *)&(rxdp +3 )->wb.qword2); + desc0_qw23 = _mm_loadu_si128(RTE_CAST_PTR(const __m128i *, &(rxdp + 0)->wb.qword2)); + desc1_qw23 = _mm_loadu_si128(RTE_CAST_PTR(const __m128i *, &(rxdp + 1)->wb.qword2)); + desc2_qw23 = _mm_loadu_si128(RTE_CAST_PTR(const __m128i *, &(rxdp + 2)->wb.qword2)); + desc3_qw23 = _mm_loadu_si128(RTE_CAST_PTR(const __m128i *, &(rxdp + 3)->wb.qword2));/* FDIR ID data: move last u32 of each desc to 4 u32 lanes */ __m128i v_unpack_01, v_unpack_23;
@@ -462,7 +458,7 @@ _recv_raw_pkts_vec(struct i40e_rx_queue *rxq, struct rte_mbuf **rx_pkts, mbp1 =_mm_loadu_si128 ((__m128i *)&sw_ring[pos]);/* Read desc statuses backwards to avoid race condition */ /* A.1 load desc[3] */ - descs[3 ] =_mm_loadu_si128 ((__m128i *)(rxdp +3 )); + descs[3] = _mm_loadu_si128(RTE_CAST_PTR(const __m128i *, rxdp + 3));rte_compiler_barrier ();/* B.2 copy 2 64 bit or 4 32 bit mbuf point into rx_pkts */
@@ -474,11 +470,11 @@ _recv_raw_pkts_vec(struct i40e_rx_queue *rxq, struct rte_mbuf **rx_pkts,#endif /* A.1 load desc[2-0] */ - descs[2 ] =_mm_loadu_si128 ((__m128i *)(rxdp +2 )); + descs[2] = _mm_loadu_si128(RTE_CAST_PTR(const __m128i *, rxdp + 2));rte_compiler_barrier (); - descs[1 ] =_mm_loadu_si128 ((__m128i *)(rxdp +1 )); + descs[1] = _mm_loadu_si128(RTE_CAST_PTR(const __m128i *, rxdp + 1));rte_compiler_barrier (); - descs[0 ] =_mm_loadu_si128 ((__m128i *)(rxdp)); + descs[0] = _mm_loadu_si128(RTE_CAST_PTR(const __m128i *, rxdp));#if defined(RTE_ARCH_X86_64 )/* B.2 copy 2 mbuf point into rx_pkts */
@@ -681,7 +677,7 @@ vtx1(volatile struct i40e_tx_desc *txdp,__m128i descriptor =_mm_set_epi64x (high_qw, pkt->buf_iova + pkt->data_off); -_mm_store_si128 ((__m128i *)txdp, descriptor); + _mm_store_si128(RTE_CAST_PTR(__m128i *, txdp), descriptor); } static inline void
drivers/net/iavf/iavf_rxtx_vec_avx2.c +28 -32
144 lines not on this page · raw message
drivers/net/iavf/iavf_rxtx_vec_avx512.c +29 -33
165 lines not on this page · raw message
drivers/net/iavf/iavf_rxtx_vec_common.h +3 -7
@@ -11,10 +11,6 @@#include "iavf.h" #include "iavf_rxtx.h" -#ifndef __INTEL_COMPILER -#pragma GCC diagnostic ignored "-Wcast-qual" -#endif - static __rte_always_inline uint16_treassemble_packets (struct iavf_rx_queue *rxq,struct rte_mbuf **rx_bufs,uint16_t nb_bufs,uint8_t *split_flags)
@@ -422,7 +418,7 @@ iavf_rxq_rearm_common(struct iavf_rx_queue *rxq, __rte_unused bool avx512) dma_addr0 =_mm_setzero_si128 ();for (i =0 ; i <IAVF_VPMD_DESCS_PER_LOOP ; i++) { rxp[i] = &rxq->fake_mbuf; -_mm_store_si128 ((__m128i *)&rxdp[i].read, + _mm_store_si128(RTE_CAST_PTR(__m128i *, &rxdp[i].read), dma_addr0); } }
@@ -458,8 +454,8 @@ iavf_rxq_rearm_common(struct iavf_rx_queue *rxq, __rte_unused bool avx512) dma_addr1 =_mm_add_epi64 (dma_addr1, hdr_room);/* flush desc with pa dma_addr */ -_mm_store_si128 ((__m128i *)&rxdp++->read, dma_addr0); - _mm_store_si128((__m128i *)&rxdp++->read, dma_addr1); + _mm_store_si128(RTE_CAST_PTR(__m128i *, &rxdp++->read), dma_addr0); + _mm_store_si128(RTE_CAST_PTR(__m128i *, &rxdp++->read), dma_addr1); }#else #ifdef CC_AVX512_SUPPORT
drivers/net/iavf/iavf_rxtx_vec_neon.c +11 -11
@@ -36,7 +36,7 @@ iavf_rxq_rearm(struct iavf_rx_queue *rxq) rxq->nb_rx_desc) {for (i =0 ; i <IAVF_VPMD_DESCS_PER_LOOP ; i++) { rxep[i] = &rxq->fake_mbuf; -vst1q_u64 ((uint64_t *)&rxdp[i].read, zero); + vst1q_u64(RTE_CAST_PTR(uint64_t *, &rxdp[i].read), zero); } } rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
@@ -53,11 +53,11 @@ iavf_rxq_rearm(struct iavf_rx_queue *rxq) dma_addr0 =vdupq_n_u64 (paddr);/* flush desc with pa dma_addr */ -vst1q_u64 ((uint64_t *)&rxdp++->read, dma_addr0); + vst1q_u64(RTE_CAST_PTR(uint64_t *, &rxdp++->read), dma_addr0); paddr = mb1->buf_iova +RTE_PKTMBUF_HEADROOM ; dma_addr1 =vdupq_n_u64 (paddr); -vst1q_u64 ((uint64_t *)&rxdp++->read, dma_addr1); + vst1q_u64(RTE_CAST_PTR(uint64_t *, &rxdp++->read), dma_addr1); } rxq->rxrearm_start +=IAVF_RXQ_REARM_THRESH ;
@@ -269,18 +269,18 @@ _recv_raw_pkts_vec(struct iavf_rx_queue *__rte_restrict rxq,int32x4_t len_shl = {0 ,0 ,0 ,PKTLEN_SHIFT };/* A.1 load desc[3-0] */ - descs[3 ] =vld1q_u64 ((uint64_t *)(rxdp +3 )); - descs[2 ] =vld1q_u64 ((uint64_t *)(rxdp +2 )); - descs[1 ] =vld1q_u64 ((uint64_t *)(rxdp +1 )); - descs[0 ] =vld1q_u64 ((uint64_t *)(rxdp)); + descs[3] = vld1q_u64(RTE_CAST_PTR(uint64_t *, rxdp + 3)); + descs[2] = vld1q_u64(RTE_CAST_PTR(uint64_t *, rxdp + 2)); + descs[1] = vld1q_u64(RTE_CAST_PTR(uint64_t *, rxdp + 1)); + descs[0] = vld1q_u64(RTE_CAST_PTR(uint64_t *, rxdp));/* Use acquire fence to order loads of descriptor qwords */ rte_atomic_thread_fence (rte_memory_order_acquire);/* A.2 reload qword0 to make it ordered after qword1 load */ - descs[3 ] =vld1q_lane_u64 ((uint64_t *)(rxdp +3 ), descs[3 ],0 ); - descs[2 ] =vld1q_lane_u64 ((uint64_t *)(rxdp +2 ), descs[2 ],0 ); - descs[1 ] =vld1q_lane_u64 ((uint64_t *)(rxdp +1 ), descs[1 ],0 ); - descs[0 ] =vld1q_lane_u64 ((uint64_t *)(rxdp), descs[0 ],0 ); + descs[3] = vld1q_lane_u64(RTE_CAST_PTR(uint64_t *, rxdp + 3), descs[3], 0); + descs[2] = vld1q_lane_u64(RTE_CAST_PTR(uint64_t *, rxdp + 2), descs[2], 0); + descs[1] = vld1q_lane_u64(RTE_CAST_PTR(uint64_t *, rxdp + 1), descs[1], 0); + descs[0] = vld1q_lane_u64(RTE_CAST_PTR(uint64_t *, rxdp), descs[0], 0);/* B.1 load 4 mbuf point */ mbp1 =vld1q_u64 ((uint64_t *)&sw_ring[pos]);
drivers/net/iavf/iavf_rxtx_vec_sse.c +17 -21
@@ -12,10 +12,6 @@#include <rte_vect.h> -#ifndef __INTEL_COMPILER -#pragma GCC diagnostic ignored "-Wcast-qual" -#endif -static inline void iavf_rxq_rearm (struct iavf_rx_queue *rxq) {
@@ -38,7 +34,7 @@ iavf_rxq_rearm(struct iavf_rx_queue *rxq) dma_addr0 =_mm_setzero_si128 ();for (i =0 ; i <IAVF_VPMD_DESCS_PER_LOOP ; i++) { rxp[i] = &rxq->fake_mbuf; -_mm_store_si128 ((__m128i *)&rxdp[i].read, + _mm_store_si128(RTE_CAST_PTR(__m128i *, &rxdp[i].read), dma_addr0); } }
@@ -69,8 +65,8 @@ iavf_rxq_rearm(struct iavf_rx_queue *rxq) dma_addr1 =_mm_add_epi64 (dma_addr1, hdr_room);/* flush desc with pa dma_addr */ -_mm_store_si128 ((__m128i *)&rxdp++->read, dma_addr0); -_mm_store_si128 ((__m128i *)&rxdp++->read, dma_addr1); + _mm_store_si128(RTE_CAST_PTR(__m128i *, &rxdp++->read), dma_addr0); + _mm_store_si128(RTE_CAST_PTR(__m128i *, &rxdp++->read), dma_addr1); } rxq->rxrearm_start += rxq->rx_free_thresh;
@@ -578,7 +574,7 @@ _recv_raw_pkts_vec(struct iavf_rx_queue *rxq, struct rte_mbuf **rx_pkts, mbp1 =_mm_loadu_si128 ((__m128i *)&sw_ring[pos]);/* Read desc statuses backwards to avoid race condition */ /* A.1 load desc[3] */ - descs[3 ] =_mm_loadu_si128 ((__m128i *)(rxdp +3 )); + descs[3] = _mm_loadu_si128(RTE_CAST_PTR(const __m128i *, rxdp + 3));rte_compiler_barrier ();/* B.2 copy 2 64 bit or 4 32 bit mbuf point into rx_pkts */
@@ -590,11 +586,11 @@ _recv_raw_pkts_vec(struct iavf_rx_queue *rxq, struct rte_mbuf **rx_pkts,#endif /* A.1 load desc[2-0] */ - descs[2 ] =_mm_loadu_si128 ((__m128i *)(rxdp +2 )); + descs[2] = _mm_loadu_si128(RTE_CAST_PTR(const __m128i *, rxdp + 2));rte_compiler_barrier (); - descs[1 ] =_mm_loadu_si128 ((__m128i *)(rxdp +1 )); + descs[1] = _mm_loadu_si128(RTE_CAST_PTR(const __m128i *, rxdp + 1));rte_compiler_barrier (); - descs[0 ] =_mm_loadu_si128 ((__m128i *)(rxdp)); + descs[0] = _mm_loadu_si128(RTE_CAST_PTR(const __m128i *, rxdp));#if defined(RTE_ARCH_X86_64 )/* B.2 copy 2 mbuf point into rx_pkts */
@@ -783,7 +779,7 @@ _recv_raw_pkts_vec_flex_rxd(struct iavf_rx_queue *rxq,/* Just the act of getting into the function from the application is * going to cost about 7 cycles */ - rxdp = (union iavf_rx_flex_desc *)rxq->rx_ring + rxq->rx_tail; + rxdp = (volatile union iavf_rx_flex_desc *)rxq->rx_ring + rxq->rx_tail;rte_prefetch0 (rxdp);
@@ -864,7 +860,7 @@ _recv_raw_pkts_vec_flex_rxd(struct iavf_rx_queue *rxq, mbp1 =_mm_loadu_si128 ((__m128i *)&sw_ring[pos]);/* Read desc statuses backwards to avoid race condition */ /* A.1 load desc[3] */ - descs[3 ] =_mm_loadu_si128 ((__m128i *)(rxdp +3 )); + descs[3] = _mm_loadu_si128(RTE_CAST_PTR(const __m128i *, rxdp + 3));rte_compiler_barrier ();/* B.2 copy 2 64 bit or 4 32 bit mbuf point into rx_pkts */
@@ -876,11 +872,11 @@ _recv_raw_pkts_vec_flex_rxd(struct iavf_rx_queue *rxq,#endif /* A.1 load desc[2-0] */ - descs[2 ] =_mm_loadu_si128 ((__m128i *)(rxdp +2 )); + descs[2] = _mm_loadu_si128(RTE_CAST_PTR(const __m128i *, rxdp + 2));rte_compiler_barrier (); - descs[1 ] =_mm_loadu_si128 ((__m128i *)(rxdp +1 )); + descs[1] = _mm_loadu_si128(RTE_CAST_PTR(const __m128i *, rxdp + 1));rte_compiler_barrier (); - descs[0 ] =_mm_loadu_si128 ((__m128i *)(rxdp)); + descs[0] = _mm_loadu_si128(RTE_CAST_PTR(const __m128i *, rxdp));#if defined(RTE_ARCH_X86_64 )/* B.2 copy 2 mbuf point into rx_pkts */
@@ -928,16 +924,16 @@ _recv_raw_pkts_vec_flex_rxd(struct iavf_rx_queue *rxq, rxq->rx_flags & IAVF_RX_FLAGS_VLAN_TAG_LOC_L2TAG2_2) {/* load bottom half of every 32B desc */ descs_bh[3 ] =_mm_load_si128 - ((void *)(&rxdp[3 ].wb.status_error1)); + (RTE_CAST_PTR(const __m128i *, &rxdp[3].wb.status_error1));rte_compiler_barrier (); descs_bh[2 ] =_mm_load_si128 - ((void *)(&rxdp[2 ].wb.status_error1)); + (RTE_CAST_PTR(const __m128i *, &rxdp[2].wb.status_error1));rte_compiler_barrier (); descs_bh[1 ] =_mm_load_si128 - ((void *)(&rxdp[1 ].wb.status_error1)); + (RTE_CAST_PTR(const __m128i *, &rxdp[1].wb.status_error1));rte_compiler_barrier (); descs_bh[0 ] =_mm_load_si128 - ((void *)(&rxdp[0 ].wb.status_error1)); + (RTE_CAST_PTR(const __m128i *, &rxdp[0].wb.status_error1)); }if (offloads &RTE_ETH_RX_OFFLOAD_RSS_HASH ) {
@@ -1349,7 +1345,7 @@ vtx1(volatile struct iavf_tx_desc *txdp, struct rte_mbuf *pkt, uint64_t flags)__m128i descriptor =_mm_set_epi64x (high_qw, pkt->buf_iova + pkt->data_off); -_mm_store_si128 ((__m128i *)txdp, descriptor); + _mm_store_si128(RTE_CAST_PTR(__m128i *, txdp), descriptor); } static inline void
drivers/net/ice/ice_rxtx_common_avx.h +7 -11
@@ -7,10 +7,6 @@#include "ice_rxtx.h" -#ifndef __INTEL_COMPILER -#pragma GCC diagnostic ignored "-Wcast-qual" -#endif -#ifdef __AVX2__ static __rte_always_inline void ice_rxq_rearm_common(struct ice_rx_queue *rxq, __rte_unused bool avx512)
@@ -33,7 +29,7 @@ ice_rxq_rearm_common(struct ice_rx_queue *rxq, __rte_unused bool avx512) dma_addr0 =_mm_setzero_si128 ();for (i =0 ; i <ICE_DESCS_PER_LOOP ; i++) { rxep[i].mbuf = &rxq->fake_mbuf; -_mm_store_si128 ((__m128i *)&rxdp[i].read, + _mm_store_si128(RTE_CAST_PTR(__m128i *, &rxdp[i].read), dma_addr0); } }
@@ -77,8 +73,8 @@ ice_rxq_rearm_common(struct ice_rx_queue *rxq, __rte_unused bool avx512) dma_addr1 =_mm_add_epi64 (dma_addr1, hdr_room);/* flush desc with pa dma_addr */ -_mm_store_si128 ((__m128i *)&rxdp++->read, dma_addr0); - _mm_store_si128((__m128i *)&rxdp++->read, dma_addr1); + _mm_store_si128(RTE_CAST_PTR(__m128i *, &rxdp++->read), dma_addr0); + _mm_store_si128(RTE_CAST_PTR(__m128i *, &rxdp++->read), dma_addr1); }#else #ifdef __AVX512VL__
@@ -157,8 +153,8 @@ ice_rxq_rearm_common(struct ice_rx_queue *rxq, __rte_unused bool avx512) dma_addr4_7 =_mm512_add_epi64 (dma_addr4_7, hdr_room);/* flush desc with pa dma_addr */ -_mm512_store_si512 ((__m512i *)&rxdp->read, dma_addr0_3); - _mm512_store_si512((__m512i *)&(rxdp + 4)->read, dma_addr4_7); + _mm512_store_si512(RTE_CAST_PTR(__m512i *, &rxdp->read), dma_addr0_3); + _mm512_store_si512(RTE_CAST_PTR(__m512i *, &(rxdp + 4)->read), dma_addr4_7); } } else#endif /* __AVX512VL__ */
@@ -213,8 +209,8 @@ ice_rxq_rearm_common(struct ice_rx_queue *rxq, __rte_unused bool avx512) dma_addr2_3 =_mm256_add_epi64 (dma_addr2_3, hdr_room);/* flush desc with pa dma_addr */ -_mm256_store_si256 ((__m256i *)&rxdp->read, dma_addr0_1); -_mm256_store_si256 ((__m256i *)&(rxdp +2 )->read, dma_addr2_3); + _mm256_store_si256(RTE_CAST_PTR(__m256i *, &rxdp->read), dma_addr0_1); + _mm256_store_si256(RTE_CAST_PTR(__m256i *, &(rxdp + 2)->read), dma_addr2_3); } }
drivers/net/ice/ice_rxtx_vec_avx2.c +35 -39
118 lines not on this page · raw message
drivers/net/ice/ice_rxtx_vec_avx512.c +26 -38
115 lines not on this page · raw message
drivers/net/ice/ice_rxtx_vec_common.h +0 -4
@@ -7,10 +7,6 @@#include "ice_rxtx.h" -#ifndef __INTEL_COMPILER -#pragma GCC diagnostic ignored "-Wcast-qual" -#endif -static inline uint16_t ice_rx_reassemble_packets (struct ice_rx_queue *rxq,struct rte_mbuf **rx_bufs,uint16_t nb_bufs,uint8_t *split_flags)
drivers/net/ice/ice_rxtx_vec_sse.c +12 -16
@@ -6,10 +6,6 @@#include <rte_vect.h> -#ifndef __INTEL_COMPILER -#pragma GCC diagnostic ignored "-Wcast-qual" -#endif -static inline __m128i ice_flex_rxd_to_fdir_flags_vec (const __m128i fdir_id0_3) {
@@ -52,7 +48,7 @@ ice_rxq_rearm(struct ice_rx_queue *rxq) dma_addr0 =_mm_setzero_si128 ();for (i =0 ; i <ICE_DESCS_PER_LOOP ; i++) { rxep[i].mbuf = &rxq->fake_mbuf; -_mm_store_si128 ((__m128i *)&rxdp[i].read, + _mm_store_si128(RTE_CAST_PTR(__m128i *, &rxdp[i].read), dma_addr0); } }
@@ -91,8 +87,8 @@ ice_rxq_rearm(struct ice_rx_queue *rxq) dma_addr1 =_mm_add_epi64 (dma_addr1, hdr_room);/* flush desc with pa dma_addr */ -_mm_store_si128 ((__m128i *)&rxdp++->read, dma_addr0); -_mm_store_si128 ((__m128i *)&rxdp++->read, dma_addr1); + _mm_store_si128(RTE_CAST_PTR(__m128i *, &rxdp++->read), dma_addr0); + _mm_store_si128(RTE_CAST_PTR(__m128i *, &rxdp++->read), dma_addr1); } rxq->rxrearm_start +=ICE_RXQ_REARM_THRESH ;
@@ -425,7 +421,7 @@ _ice_recv_raw_pkts_vec(struct ice_rx_queue *rxq, struct rte_mbuf **rx_pkts, mbp1 =_mm_loadu_si128 ((__m128i *)&sw_ring[pos]);/* Read desc statuses backwards to avoid race condition */ /* A.1 load desc[3] */ - descs[3 ] =_mm_loadu_si128 ((__m128i *)(rxdp +3 )); + descs[3] = _mm_loadu_si128(RTE_CAST_PTR(const __m128i *, rxdp + 3));rte_compiler_barrier ();/* B.2 copy 2 64 bit or 4 32 bit mbuf point into rx_pkts */
@@ -437,11 +433,11 @@ _ice_recv_raw_pkts_vec(struct ice_rx_queue *rxq, struct rte_mbuf **rx_pkts,#endif /* A.1 load desc[2-0] */ - descs[2 ] =_mm_loadu_si128 ((__m128i *)(rxdp +2 )); + descs[2] = _mm_loadu_si128(RTE_CAST_PTR(const __m128i *, rxdp + 2));rte_compiler_barrier (); - descs[1 ] =_mm_loadu_si128 ((__m128i *)(rxdp +1 )); + descs[1] = _mm_loadu_si128(RTE_CAST_PTR(const __m128i *, rxdp + 1));rte_compiler_barrier (); - descs[0 ] =_mm_loadu_si128 ((__m128i *)(rxdp)); + descs[0] = _mm_loadu_si128(RTE_CAST_PTR(const __m128i *, rxdp));#if defined(RTE_ARCH_X86_64 )/* B.2 copy 2 mbuf point into rx_pkts */
@@ -491,19 +487,19 @@ _ice_recv_raw_pkts_vec(struct ice_rx_queue *rxq, struct rte_mbuf **rx_pkts,/* load bottom half of every 32B desc */ const __m128i raw_desc_bh3 =_mm_load_si128 - ((void *)(&rxdp[3 ].wb.status_error1)); + (RTE_CAST_PTR(const __m128i *, &rxdp[3].wb.status_error1));rte_compiler_barrier ();const __m128i raw_desc_bh2 =_mm_load_si128 - ((void *)(&rxdp[2 ].wb.status_error1)); + (RTE_CAST_PTR(const __m128i *, &rxdp[2].wb.status_error1));rte_compiler_barrier ();const __m128i raw_desc_bh1 =_mm_load_si128 - ((void *)(&rxdp[1 ].wb.status_error1)); + (RTE_CAST_PTR(const __m128i *, &rxdp[1].wb.status_error1));rte_compiler_barrier ();const __m128i raw_desc_bh0 =_mm_load_si128 - ((void *)(&rxdp[0 ].wb.status_error1)); + (RTE_CAST_PTR(const __m128i *, &rxdp[0].wb.status_error1));/** * to shift the 32b RSS hash value to the
@@ -680,7 +676,7 @@ ice_vtx1(volatile struct ice_tx_desc *txdp, struct rte_mbuf *pkt, ((uint64_t)pkt->data_len << ICE_TXD_QW1_TX_BUF_SZ_S));__m128i descriptor =_mm_set_epi64x (high_qw,rte_pktmbuf_iova (pkt)); -_mm_store_si128 ((__m128i *)txdp, descriptor); + _mm_store_si128(RTE_CAST_PTR(__m128i *, txdp), descriptor); } static inline void
drivers/net/idpf/idpf_rxtx_vec_common.h +0 -4
@@ -11,10 +11,6 @@#include "idpf_ethdev.h" #include "idpf_rxtx.h" -#ifndef __INTEL_COMPILER -#pragma GCC diagnostic ignored "-Wcast-qual" -#endif -#define IDPF_SCALAR_PATH 0#define IDPF_VECTOR_PATH 1#define IDPF_RX_NO_VECTOR_FLAGS ( \
drivers/net/ixgbe/ixgbe_recycle_mbufs_vec_common.c +0 -2
@@ -8,8 +8,6 @@#include "ixgbe_ethdev.h" #include "ixgbe_rxtx.h" -#pragma GCC diagnostic ignored "-Wcast-qual" -void ixgbe_recycle_rx_descriptors_refill_vec (void *rx_queue,uint16_t nb_mbufs) {
drivers/net/ixgbe/ixgbe_rxtx_vec_neon.c +8 -10
@@ -11,8 +11,6 @@#include "ixgbe_rxtx.h" #include "ixgbe_rxtx_vec_common.h" -#pragma GCC diagnostic ignored "-Wcast-qual" -static inline void ixgbe_rxq_rearm (struct ixgbe_rx_queue *rxq) {
@@ -36,7 +34,7 @@ ixgbe_rxq_rearm(struct ixgbe_rx_queue *rxq) rxq->nb_rx_desc) {for (i =0 ; i <RTE_IXGBE_DESCS_PER_LOOP ; i++) { rxep[i].mbuf = &rxq->fake_mbuf; -vst1q_u64 ((uint64_t *)&rxdp[i].read, + vst1q_u64(RTE_CAST_PTR(uint64_t *, &rxdp[i].read), zero); } }
@@ -60,12 +58,12 @@ ixgbe_rxq_rearm(struct ixgbe_rx_queue *rxq) 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); + vst1q_u64(RTE_CAST_PTR(uint64_t *, &rxdp++->read), dma_addr0);vst1_u8 ((uint8_t *)&mb1->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); + vst1q_u64(RTE_CAST_PTR(uint64_t *, &rxdp++->read), dma_addr1); } rxq->rxrearm_start +=RTE_IXGBE_RXQ_REARM_THRESH ;
@@ -367,10 +365,10 @@ _recv_raw_pkts_vec(struct ixgbe_rx_queue *rxq, struct rte_mbuf **rx_pkts, mbp2 =vld1q_u64 ((uint64_t *)&sw_ring[pos +2 ]);/* A. load 4 pkts descs */ - descs[0 ] =vld1q_u64 ((uint64_t *)(rxdp)); - descs[1 ] =vld1q_u64 ((uint64_t *)(rxdp +1 )); - descs[2 ] =vld1q_u64 ((uint64_t *)(rxdp +2 )); - descs[3 ] =vld1q_u64 ((uint64_t *)(rxdp +3 )); + descs[0] = vld1q_u64(RTE_CAST_PTR(uint64_t *, rxdp)); + descs[1] = vld1q_u64(RTE_CAST_PTR(uint64_t *, rxdp + 1)); + descs[2] = vld1q_u64(RTE_CAST_PTR(uint64_t *, rxdp + 2)); + descs[3] = vld1q_u64(RTE_CAST_PTR(uint64_t *, rxdp + 3));/* B.2 copy 2 mbuf point into rx_pkts */ vst1q_u64 ((uint64_t *)&rx_pkts[pos +2 ], mbp2);
@@ -554,7 +552,7 @@ vtx1(volatile union ixgbe_adv_tx_desc *txdp, pkt->buf_iova + pkt->data_off, (uint64_t)pkt->pkt_len << 46 | flags | pkt->data_len}; -vst1q_u64 ((uint64_t *)&txdp->read, descriptor); + vst1q_u64(RTE_CAST_PTR(uint64_t *, &txdp->read), descriptor); } static inline void
drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c +8 -12
@@ -12,10 +12,6 @@#include <rte_vect.h> -#ifndef __INTEL_COMPILER -#pragma GCC diagnostic ignored "-Wcast-qual" -#endif -static inline void ixgbe_rxq_rearm (struct ixgbe_rx_queue *rxq) {
@@ -41,7 +37,7 @@ ixgbe_rxq_rearm(struct ixgbe_rx_queue *rxq) dma_addr0 =_mm_setzero_si128 ();for (i =0 ; i <RTE_IXGBE_DESCS_PER_LOOP ; i++) { rxep[i].mbuf = &rxq->fake_mbuf; -_mm_store_si128 ((__m128i *)&rxdp[i].read, + _mm_store_si128(RTE_CAST_PTR(__m128i *, &rxdp[i].read), dma_addr0); } }
@@ -76,8 +72,8 @@ ixgbe_rxq_rearm(struct ixgbe_rx_queue *rxq) dma_addr1 =_mm_and_si128 (dma_addr1, hba_msk);/* flush desc with pa dma_addr */ -_mm_store_si128 ((__m128i *)&rxdp++->read, dma_addr0); -_mm_store_si128 ((__m128i *)&rxdp++->read, dma_addr1); + _mm_store_si128(RTE_CAST_PTR(__m128i *, &rxdp++->read), dma_addr0); + _mm_store_si128(RTE_CAST_PTR(__m128i *, &rxdp++->read), dma_addr1); } rxq->rxrearm_start +=RTE_IXGBE_RXQ_REARM_THRESH ;
@@ -466,7 +462,7 @@ _recv_raw_pkts_vec(struct ixgbe_rx_queue *rxq, struct rte_mbuf **rx_pkts,/* Read desc statuses backwards to avoid race condition */ /* A.1 load desc[3] */ - descs[3 ] =_mm_loadu_si128 ((__m128i *)(rxdp +3 )); + descs[3] = _mm_loadu_si128(RTE_CAST_PTR(const __m128i *, rxdp + 3));rte_compiler_barrier ();/* B.2 copy 2 64 bit or 4 32 bit mbuf point into rx_pkts */
@@ -478,11 +474,11 @@ _recv_raw_pkts_vec(struct ixgbe_rx_queue *rxq, struct rte_mbuf **rx_pkts,#endif /* A.1 load desc[2-0] */ - descs[2 ] =_mm_loadu_si128 ((__m128i *)(rxdp +2 )); + descs[2] = _mm_loadu_si128(RTE_CAST_PTR(const __m128i *, rxdp + 2));rte_compiler_barrier (); - descs[1 ] =_mm_loadu_si128 ((__m128i *)(rxdp +1 )); + descs[1] = _mm_loadu_si128(RTE_CAST_PTR(const __m128i *, rxdp + 1));rte_compiler_barrier (); - descs[0 ] =_mm_loadu_si128 ((__m128i *)(rxdp)); + descs[0] = _mm_loadu_si128(RTE_CAST_PTR(const __m128i *, rxdp));#if defined(RTE_ARCH_X86_64 )/* B.2 copy 2 mbuf point into rx_pkts */
@@ -676,7 +672,7 @@ vtx1(volatile union ixgbe_adv_tx_desc *txdp,__m128i descriptor =_mm_set_epi64x ((uint64_t )pkt->pkt_len <<46 | flags | pkt->data_len, pkt->buf_iova + pkt->data_off); -_mm_store_si128 ((__m128i *)&txdp->read, descriptor); + _mm_store_si128(RTE_CAST_PTR(__m128i *, &txdp->read), descriptor); } static inline void
drivers/net/mlx5/mlx5_flow.c +1 -4
@@ -7287,10 +7287,7 @@ flow_tunnel_from_rule(const struct mlx5_flow *flow) {struct mlx5_flow_tunnel *tunnel; -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wcast-qual" - tunnel = (typeof (tunnel ))flow->tunnel; -#pragma GCC diagnostic pop + tunnel =RTE_PTR_UNQUAL (flow->tunnel);return tunnel; }
drivers/net/mlx5/mlx5_rxtx_vec_altivec.h +0 -5
@@ -25,11 +25,6 @@#include "mlx5_rxtx_vec.h" #include "mlx5_autoconf.h" -#ifndef __INTEL_COMPILER -#pragma GCC diagnostic ignored "-Wcast-qual" -#pragma GCC diagnostic ignored "-Wstrict-aliasing" -#endif -/** * Store free buffers to RX SW ring. *
drivers/net/mlx5/mlx5_rxtx_vec_neon.h +8 -10
@@ -25,8 +25,6 @@#include "mlx5_rxtx_vec.h" #include "mlx5_autoconf.h" -#pragma GCC diagnostic ignored "-Wcast-qual" -/** * Store free buffers to RX SW ring. *
@@ -75,7 +73,7 @@ rxq_cq_decompress_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq, struct rte_mbuf **elts, bool keep) {volatile struct mlx5_mini_cqe8 *mcq = - (void *)&(cq + !rxq->cqe_comp_layout)->pkt_info; + (volatile struct mlx5_mini_cqe8 *)&(cq + !rxq->cqe_comp_layout)->pkt_info;/* Title packet is pre-built. */ struct rte_mbuf *t_pkt = rxq->cqe_comp_layout ? &rxq->title_pkt : elts[0 ];unsigned int pos;
@@ -139,9 +137,9 @@ rxq_cq_decompress_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq,*/ cycle:if (rxq->cqe_comp_layout) -rte_prefetch0 ((void *)(cq + mcqe_n)); +rte_prefetch0 ((volatile void *)(cq + mcqe_n));for (pos =0 ; pos < mcqe_n; ) { -uint8_t *p = (void *)&mcq[pos %8 ]; + uint8_t *p = RTE_CAST_PTR(uint8_t *, &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;
@@ -157,7 +155,7 @@ rxq_cq_decompress_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq,if (!rxq->cqe_comp_layout)for (i =0 ; i <MLX5_VPMD_DESCS_PER_LOOP ; ++i)if (likely (pos + i < mcqe_n)) -rte_prefetch0 ((void *)(cq + pos + i)); +rte_prefetch0 ((volatile void *)(cq + pos + i)); __asm__volatile (/* A.1 load mCQEs into a 128bit register. */ "ld1 {v16.16b - v17.16b}, [%[mcq]] \n\t"
@@ -367,8 +365,8 @@ rxq_cq_decompress_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq,if (!rxq->cqe_comp_layout) {if (!(pos &0x7 ) && pos < mcqe_n) {if (pos +8 < mcqe_n) -rte_prefetch0 ((void *)(cq + pos +8 )); - mcq = (void *)&(cq + pos)->pkt_info; +rte_prefetch0 ((volatile void *)(cq + pos +8 )); + mcq = (volatile struct mlx5_mini_cqe8 *)&(cq + pos)->pkt_info;for (i =0 ; i <8 ; ++i) cq[inv++].op_own =MLX5_CQE_INVALIDATE ; }
@@ -383,7 +381,7 @@ rxq_cq_decompress_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq, MLX5_CQE_FORMAT(cq->op_own) == MLX5_COMPRESSED) { pos =0 ; elts = &elts[mcqe_n]; - mcq = (void *)cq; + mcq = (volatile struct mlx5_mini_cqe8 *)cq; mcqe_n =MLX5_CQE_NUM_MINIS (cq->op_own) +1 ; pkts_n += mcqe_n; goto cycle;
@@ -663,7 +661,7 @@ rxq_cq_process_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq, mask =vcreate_u16 (pkts_n - pos <MLX5_VPMD_DESCS_PER_LOOP ?-1UL >> ((pkts_n - pos) *sizeof (uint16_t ) *8 ) :0 ); - p0 = (void *)&cq[pos].pkt_info; + p0 =RTE_PTR_UNQUAL (&cq[pos].pkt_info); p1 = p0 + (pkts_n - pos >1 ) *sizeof (struct mlx5_cqe ); p2 = p1 + (pkts_n - pos >2 ) *sizeof (struct mlx5_cqe ); p3 = p2 + (pkts_n - pos >3 ) *sizeof (struct mlx5_cqe );
drivers/net/mlx5/mlx5_rxtx_vec_sse.h +29 -32
132 lines not on this page · raw message
drivers/net/ngbe/ngbe_rxtx_vec_neon.c +4 -4
@@ -35,7 +35,7 @@ ngbe_rxq_rearm(struct ngbe_rx_queue *rxq) rxq->nb_rx_desc) {for (i =0 ; i <RTE_NGBE_DESCS_PER_LOOP ; i++) { rxep[i].mbuf = &rxq->fake_mbuf; -vst1q_u64 ((uint64_t *)(uintptr_t )&rxdp[i], zero); + vst1q_u64(RTE_CAST_PTR(uint64_t *, &rxdp[i]), zero); } } rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
@@ -58,12 +58,12 @@ ngbe_rxq_rearm(struct ngbe_rx_queue *rxq) 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 *)(uintptr_t )rxdp++, dma_addr0); + vst1q_u64(RTE_CAST_PTR(uint64_t *, rxdp++), dma_addr0);vst1_u8 ((uint8_t *)&mb1->rearm_data, p); paddr = mb1->buf_iova +RTE_PKTMBUF_HEADROOM ; dma_addr1 =vsetq_lane_u64 (paddr, zero,0 ); -vst1q_u64 ((uint64_t *)(uintptr_t )rxdp++, dma_addr1); + vst1q_u64(RTE_CAST_PTR(uint64_t *, rxdp++), dma_addr1); } rxq->rxrearm_start +=RTE_NGBE_RXQ_REARM_THRESH ;
@@ -484,7 +484,7 @@ vtx1(volatile struct ngbe_tx_desc *txdp,uint64x2_t descriptor = {pkt->buf_iova + pkt->data_off, (uint64_t )pkt_len <<45 | flags | pkt_len}; -vst1q_u64 ((uint64_t *)(uintptr_t )txdp, descriptor); + vst1q_u64(RTE_CAST_PTR(uint64_t *, txdp), descriptor); } static inline void
drivers/net/tap/tap_flow.c +3 -3
@@ -23,10 +23,10 @@#ifdef HAVE_BPF_RSS /* Workaround for warning in bpftool generated skeleton code */ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wcast-qual" +__rte_diagnostic_push +__rte_diagnostic_ignored_wcast_qual#include "tap_rss.skel.h" -#pragma GCC diagnostic pop +__rte_diagnostic_pop#endif #define ISOLATE_HANDLE 1
drivers/net/txgbe/txgbe_rxtx_vec_neon.c +4 -4
@@ -34,7 +34,7 @@ txgbe_rxq_rearm(struct txgbe_rx_queue *rxq) rxq->nb_rx_desc) {for (i =0 ; i <RTE_TXGBE_DESCS_PER_LOOP ; i++) { rxep[i].mbuf = &rxq->fake_mbuf; -vst1q_u64 ((uint64_t *)(uintptr_t )&rxdp[i], zero); + vst1q_u64(RTE_CAST_PTR(uint64_t *, &rxdp[i]), zero); } } rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
@@ -57,12 +57,12 @@ txgbe_rxq_rearm(struct txgbe_rx_queue *rxq) 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 *)(uintptr_t )rxdp++, dma_addr0); + vst1q_u64(RTE_CAST_PTR(uint64_t *, rxdp++), dma_addr0);vst1_u8 ((uint8_t *)&mb1->rearm_data, p); paddr = mb1->buf_iova +RTE_PKTMBUF_HEADROOM ; dma_addr1 =vsetq_lane_u64 (paddr, zero,0 ); -vst1q_u64 ((uint64_t *)(uintptr_t )rxdp++, dma_addr1); + vst1q_u64(RTE_CAST_PTR(uint64_t *, rxdp++), dma_addr1); } rxq->rxrearm_start +=RTE_TXGBE_RXQ_REARM_THRESH ;
@@ -484,7 +484,7 @@ vtx1(volatile struct txgbe_tx_desc *txdp,uint64x2_t descriptor = {pkt->buf_iova + pkt->data_off, (uint64_t )pkt_len <<45 | flags | pkt_len}; -vst1q_u64 ((uint64_t *)(uintptr_t )txdp, descriptor); + vst1q_u64(RTE_CAST_PTR(uint64_t *, txdp), descriptor); } static inline void
drivers/net/virtio/virtio_rxtx_simple.c +0 -4
@@ -23,10 +23,6 @@#include "virtio_rxtx_simple.h" -#ifndef __INTEL_COMPILER -#pragma GCC diagnostic ignored "-Wcast-qual" -#endif - int __rte_coldvirtio_rxq_vec_setup (struct virtnet_rx *rxq) {
Signature · 1 line
2.47.2.vfs.0.1
RE: [PATCH v16 3/3] drivers/net: add diagnostics macros to make code portable
Quoted 10 lines
From: Andre Muezerie [mailto:[email protected]]
Sent: Tuesday, 21 January 2025 23.36It was a common pattern to have "GCC diagnostic ignored" pragmas sprinkled over the code and only activate these pragmas for certain compilers (gcc and clang). Clang supports GCC's pragma for compatibility with existing source code, so #pragma GCC diagnostic and #pragma clang diagnostic are synonyms for Clang
(https://clang.llvm.org/docs/UsersManual.html).
Quoted 8 lines
Now that effort is being made to make the code compatible with MSVC these expressions would become more complex. It makes sense to hide this complexity behind macros. This makes maintenance easier as these macros are defined in a single place. As a plus the code becomes more readable as well.
Signed-off-by Andre Muezerie <[email protected]>---
RE: [PATCH v16 3/3] drivers/net: add diagnostics macros to make code portable
In reply to Andre MuezerieQuoted 15 lines
-----Original Message-----
From: Andre Muezerie <[email protected]>
Sent: Wednesday, January 22, 2025 12:36 AM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]
Subject: [PATCH v16 3/3]drivers/net: add diagnostics macros to make code portableIt was a common pattern to have "GCC diagnostic ignored" pragmas sprinkled over the code and only activate these pragmas for certain compilers (gcc and clang). Clang supports GCC's pragma for compatibility with existing source code, so #pragma GCC diagnostic and #pragma clang diagnostic are synonyms for Clang
(https://clang.llvm.org/docs/UsersManual.html).
Quoted 8 lines
Now that effort is being made to make the code compatible with MSVC these expressions would become more complex. It makes sense to hide this complexity behind macros. This makes maintenance easier as these macros are defined in a single place. As a plus the code becomes more readable as well.
Signed-off-by Andre Muezerie <[email protected]>---
Hello,
This patch is causing a build failure on PowerPC64, affecting both cross-compilation on x86_64 and native builds on PowerPC64 systems:
drivers/net/mlx5/mlx5_rxtx_vec_altivec.h:77:3: error: cast discards 'volatile' qualifier from pointer target type [-Werror=cast-qual]
Regards,
Ali
RE: [PATCH v16 3/3] drivers/net: add diagnostics macros to make code portable
Quoted 32 lines
-----Original Message-----
From: Ali Alnubani
Sent: Wednesday, January 29, 2025 11:08 PM
To: Andre Muezerie <[email protected]>
Cc: [email protected]; [email protected]; [email protected]
Subject: RE: [PATCH v16 3/3]drivers/net: add diagnostics macros to make code portableQuoted 15 lines
-----Original Message-----
From: Andre Muezerie <[email protected]>
Sent: Wednesday, January 22, 2025 12:36 AM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]
Subject: [PATCH v16 3/3]drivers/net: add diagnostics macros to make code portableIt was a common pattern to have "GCC diagnostic ignored" pragmas sprinkled over the code and only activate these pragmas for certain compilers (gcc and clang). Clang supports GCC's pragma for compatibility with existing source code, so #pragma GCC diagnostic and #pragma clang diagnostic are synonyms for Clang
(https://clang.llvm.org/docs/UsersManual.html).Quoted 8 lines
Now that effort is being made to make the code compatible with MSVC these expressions would become more complex. It makes sense to hide this complexity behind macros. This makes maintenance easier as these macros are defined in a single place. As a plus the code becomes more readable as well.
Signed-off-by Andre Muezerie <[email protected]>---
Quoted 7 lines
Hello,
This patch is causing a build failure on PowerPC64, affecting both cross- compilation on
x86_64and native builds on PowerPC64 systems:
drivers/net/mlx5/mlx5_rxtx_vec_altivec.h:77:3: error: cast discards 'volatile' qualifier from pointer target type [-Werror=cast-qual]
Compiler: powerpc64le-linux-gnu-gcc 9.4.0
Quoted 3 lines
Regards,
Ali
Re: [PATCH v16 3/3] drivers/net: add diagnostics macros to make code portable
Quoted 34 lines · Ali Alnubani
Quoted 34 lines
-----Original Message-----
From: Ali Alnubani
Sent: Wednesday, January 29, 2025 11:08 PM
To: Andre Muezerie <[email protected]>
Cc: [email protected]; [email protected]; [email protected]
Subject: RE: [PATCH v16 3/3]drivers/net: add diagnostics macros to make code portableQuoted 15 lines
-----Original Message-----
From: Andre Muezerie <[email protected]>
Sent: Wednesday, January 22, 2025 12:36 AM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]
Subject: [PATCH v16 3/3]drivers/net: add diagnostics macros to make code portableIt was a common pattern to have "GCC diagnostic ignored" pragmas sprinkled over the code and only activate these pragmas for certain compilers (gcc and clang). Clang supports GCC's pragma for compatibility with existing source code, so #pragma GCC diagnostic and #pragma clang diagnostic are synonyms for Clang
(https://clang.llvm.org/docs/UsersManual.html).Quoted 8 lines
Now that effort is being made to make the code compatible with MSVC these expressions would become more complex. It makes sense to hide this complexity behind macros. This makes maintenance easier as these macros are defined in a single place. As a plus the code becomes more readable as well.
Signed-off-by Andre Muezerie <[email protected]>---
Hello,
Quoted 11 lines
Quoted 5 lines
This patch is causing a build failure on PowerPC64, affecting both cross- compilation on
x86_64and native builds on PowerPC64 systems:
drivers/net/mlx5/mlx5_rxtx_vec_altivec.h:77:3: error: cast discards 'volatile' qualifier from pointer target type [-Werror=cast-qual]Compiler: powerpc64le-linux-gnu-gcc 9.4.0
Quoted 3 lines
Regards,
Ali
Hi Ali. Sorry for the trouble caused. Unfortunately the CI pipeline did not catch this.
A patch fixing this issue was submitted earlier today:
https://patches.dpdk.org/project/dpdk/patch/[email protected]/
Regards,
Andre Muezerie
RE: [PATCH v16 3/3] drivers/net: add diagnostics macros to make code portable
Quoted 58 lines
-----Original Message-----
From: Andre Muezerie <[email protected]>
Sent: Thursday, January 30, 2025 5:38 AM
To: Ali Alnubani <[email protected]>
Cc: [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v16 3/3]drivers/net: add diagnostics macros to make code portableQuoted 5 lines · Ali Alnubani
Quoted 5 lines
-----Original Message-----
From: Ali Alnubani
Sent: Wednesday, January 29, 2025 11:08 PM
To: Andre Muezerie <[email protected]>
Cc: [email protected]; [email protected];Quoted 1 line
Quoted 1 line
Subject: RE: [PATCH v16 3/3]
drivers/net: add diagnostics macros to makecode
Quoted 7 lines
Quoted 7 lines
portable
Quoted 5 lines
-----Original Message-----
From: Andre Muezerie <[email protected]>
Sent: Wednesday, January 22, 2025 12:36 AM
To: [email protected]
Cc: [email protected]; [email protected];Quoted 21 lines
Quoted 21 lines
Quoted 10 lines
Subject: [PATCH v16 3/3]
drivers/net: add diagnostics macros to make code portableIt was a common pattern to have "GCC diagnostic ignored" pragmas sprinkled over the code and only activate these pragmas for certain compilers (gcc and clang). Clang supports GCC's pragma for compatibility with existing source code, so #pragma GCC diagnostic and #pragma clang diagnostic are synonyms for Clang
(https://clang.llvm.org/docs/UsersManual.html).Quoted 8 lines
Now that effort is being made to make the code compatible with MSVC these expressions would become more complex. It makes sense to hide this complexity behind macros. This makes maintenance easier as these macros are defined in a single place. As a plus the code becomes more readable as well.
Signed-off-by Andre Muezerie <[email protected]>---
Hello,
Quoted 11 lines
Quoted 5 lines
This patch is causing a build failure on PowerPC64, affecting both cross- compilation on
x86_64and native builds on PowerPC64 systems:
drivers/net/mlx5/mlx5_rxtx_vec_altivec.h:77:3: error: cast discards 'volatile' qualifier from pointer target type [-Werror=cast-qual]Compiler: powerpc64le-linux-gnu-gcc 9.4.0
Quoted 3 lines
Regards,
Ali
Quoted 6 lines
Hi Ali. Sorry for the trouble caused. Unfortunately the CI pipeline did not catch this.
A patch fixing this issue was submitted earlier today:
https://patches.dpdk.org/project/dpdk/patch/1738172139-31201-1-git-send-
[email protected]/
I missed it, will test it and update.
Thanks!
Quoted 4 lines
Regards,
Andre Muezerie
Quoted 69 lines · Andre Muezerie
v16:
* Updated comment forRTE_CAST_PTR.v15:
* Fixed a comment inrte_common.hto make Doxygen happy.
* Fixed a typo (extra comma).
* Added missingRTE_PTR_UNQUALneeded for ARM64.v14:
* RenamedRTE_PTR_DROP_QUALIFIERSintoRTE_PTR_UNQUALto more resemble C23typeof_unqual.
* Added macroRTE_CAST_PTRto make the cast more readable when removing a type qualifier from a pointer.v13:
* RenamedRTE_IGNORE_CAST_QUALintoRTE_PTR_DROP_QUALIFIERS.
* Added (void *) cast toRTE_PTR_DROP_QUALIFIERSto avoid the need for casting the result in most places where the macro is used.v12:
* Added macroRTE_IGNORE_CAST_QUALand used it as a more compact and readable form to suppress warnings where a cast is used to remove a type qualifier.v11:
* Added__rte_diagnostic_ignored_wcast_qualto a few more places where it was needed.v10:
* Added__rte_diagnostic_ignored_wcast_qualto a few more places where it was needed.v9:
* Added__rte_diagnostic_ignored_wcast_qualto a few more places where it was needed.v8:
* Added__rte_diagnostic_ignored_wcast_qualto a few more places where it was needed.v7:
* Added__rte_diagnostic_ignored_wcast_qualto a few more places where it was needed.v6:
* Added__rte_diagnostic_ignored_wcast_qualto a few more places where it was needed.v5:
* Added__rte_diagnostic_ignored_wcast_qualto a few more places where it was needed.v4:
* Added__rte_diagnostic_ignored_wcast_qualto a few more places where it was needed.v3:
* Added__rte_diagnostic_ignored_wcast_qualto a few more places where it was needed.v2:
* Removed__rte_diagnostic_ignored_wstrict_aliasing(introduced in v1).
* Removed the pragmas from many files where they were not needed.
* In the files where the pragmas were indeed needed, reduced the scope during which they are active, reducing the chance that unforeseen issues are hidden due to warning suppression.
Quoted 4 lines
Andre Muezerie (3):
eal: add diagnostics macros to make code portabledrivers/common: add diagnostics macros to make code portabledrivers/net: add diagnostics macros to make code portable
I moved a bit the casting macros in rte_common.h (and put them next to RTE_CAST_FIELD).
Thanks for this work André, series applied.
Note: there is probably some cleaning to do in the rest of the tree:
$ git grep -l '(void \*)(uintptr_t)' | wc -l 92
Signature · 1 line
David Marchand
Quoted 72 lines · David Marchand
Quoted 69 lines · Andre Muezerie
v16:
* Updated comment forRTE_CAST_PTR.v15:
* Fixed a comment inrte_common.hto make Doxygen happy.
* Fixed a typo (extra comma).
* Added missingRTE_PTR_UNQUALneeded for ARM64.v14:
* RenamedRTE_PTR_DROP_QUALIFIERSintoRTE_PTR_UNQUALto more resemble C23typeof_unqual.
* Added macroRTE_CAST_PTRto make the cast more readable when removing a type qualifier from a pointer.v13:
* RenamedRTE_IGNORE_CAST_QUALintoRTE_PTR_DROP_QUALIFIERS.
* Added (void *) cast toRTE_PTR_DROP_QUALIFIERSto avoid the need for casting the result in most places where the macro is used.v12:
* Added macroRTE_IGNORE_CAST_QUALand used it as a more compact and readable form to suppress warnings where a cast is used to remove a type qualifier.v11:
* Added__rte_diagnostic_ignored_wcast_qualto a few more places where it was needed.v10:
* Added__rte_diagnostic_ignored_wcast_qualto a few more places where it was needed.v9:
* Added__rte_diagnostic_ignored_wcast_qualto a few more places where it was needed.v8:
* Added__rte_diagnostic_ignored_wcast_qualto a few more places where it was needed.v7:
* Added__rte_diagnostic_ignored_wcast_qualto a few more places where it was needed.v6:
* Added__rte_diagnostic_ignored_wcast_qualto a few more places where it was needed.v5:
* Added__rte_diagnostic_ignored_wcast_qualto a few more places where it was needed.v4:
* Added__rte_diagnostic_ignored_wcast_qualto a few more places where it was needed.v3:
* Added__rte_diagnostic_ignored_wcast_qualto a few more places where it was needed.v2:
* Removed__rte_diagnostic_ignored_wstrict_aliasing(introduced in v1).
* Removed the pragmas from many files where they were not needed.
* In the files where the pragmas were indeed needed, reduced the scope during which they are active, reducing the chance that unforeseen issues are hidden due to warning suppression.
Quoted 8 lines
Quoted 4 lines
Andre Muezerie (3):
eal: add diagnostics macros to make code portabledrivers/common: add diagnostics macros to make code portabledrivers/net: add diagnostics macros to make code portableI moved a bit the casting macros in
rte_common.h(and put them next toRTE_CAST_FIELD).
Thanks for this work André, series applied.
CI is not happy with those changes on ppc64le (this was caught by OBS after pushing).
See, for example,
https://build.opensuse.org/package/live_build_log/home:bluca:dpdk/dpdk/Fedora_Rawhide/ppc64le
Please send a fix.
Signature · 1 line
David Marchand
Quoted 83 lines · David Marchand
Quoted 72 lines · David Marchand
Quoted 69 lines · Andre Muezerie
v16:
* Updated comment forRTE_CAST_PTR.v15:
* Fixed a comment inrte_common.hto make Doxygen happy.
* Fixed a typo (extra comma).
* Added missingRTE_PTR_UNQUALneeded for ARM64.v14:
* RenamedRTE_PTR_DROP_QUALIFIERSintoRTE_PTR_UNQUALto more resemble C23typeof_unqual.
* Added macroRTE_CAST_PTRto make the cast more readable when removing a type qualifier from a pointer.v13:
* RenamedRTE_IGNORE_CAST_QUALintoRTE_PTR_DROP_QUALIFIERS.
* Added (void *) cast toRTE_PTR_DROP_QUALIFIERSto avoid the need for casting the result in most places where the macro is used.v12:
* Added macroRTE_IGNORE_CAST_QUALand used it as a more compact and readable form to suppress warnings where a cast is used to remove a type qualifier.v11:
* Added__rte_diagnostic_ignored_wcast_qualto a few more places where it was needed.v10:
* Added__rte_diagnostic_ignored_wcast_qualto a few more places where it was needed.v9:
* Added__rte_diagnostic_ignored_wcast_qualto a few more places where it was needed.v8:
* Added__rte_diagnostic_ignored_wcast_qualto a few more places where it was needed.v7:
* Added__rte_diagnostic_ignored_wcast_qualto a few more places where it was needed.v6:
* Added__rte_diagnostic_ignored_wcast_qualto a few more places where it was needed.v5:
* Added__rte_diagnostic_ignored_wcast_qualto a few more places where it was needed.v4:
* Added__rte_diagnostic_ignored_wcast_qualto a few more places where it was needed.v3:
* Added__rte_diagnostic_ignored_wcast_qualto a few more places where it was needed.v2:
* Removed__rte_diagnostic_ignored_wstrict_aliasing(introduced in v1).
* Removed the pragmas from many files where they were not needed.
* In the files where the pragmas were indeed needed, reduced the scope during which they are active, reducing the chance that unforeseen issues are hidden due to warning suppression.Quoted 8 lines
Quoted 4 lines
Andre Muezerie (3):
eal: add diagnostics macros to make code portabledrivers/common: add diagnostics macros to make code portabledrivers/net: add diagnostics macros to make code portableI moved a bit the casting macros in
rte_common.h(and put them next toRTE_CAST_FIELD).
Thanks for this work André, series applied.
Quoted 10 lines
CI is not happy with those changes on ppc64le (this was caught by OBS after pushing).
See, for example,
https://build.opensuse.org/package/live_build_log/home:bluca:dpdk/dpdk/Fedora_Rawhide/ppc64lePlease send a fix.
Signature · 1 line
David Marchand
Thanks for letting me know David, and also for so quickly smoke-testing my new fix in a container. The fix can be found here: https://patches.dpdk.org/project/dpdk/list/?series=34479
Andre Muezerie