Skip to contentSkip to conversation

add diagnostics macros to make code portable

PATCH Superseded Andre Muezerie 6 participants 97 messages Dec 27, 2024 – Jan 30, 2025 Network drivers Page 1 of 3

lore
Share & tools
lore
#0 lore raw

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

Andre Muezerie (3):
lib/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 |  4 +--
 drivers/net/axgbe/axgbe_rxtx.h                | 12 +++----
 drivers/net/cpfl/cpfl_rxtx_vec_common.h       |  4 +--
 drivers/net/dpaa2/dpaa2_rxtx.c                | 15 ++------
 drivers/net/fm10k/fm10k_rxtx_vec.c            |  4 +--
 drivers/net/hns3/hns3_rxtx_vec_neon.h         |  2 +-
 .../net/i40e/i40e_recycle_mbufs_vec_common.c  |  2 +-
 drivers/net/i40e/i40e_rxtx_common_avx.h       |  4 +--
 drivers/net/i40e/i40e_rxtx_vec_altivec.c      |  2 +-
 drivers/net/i40e/i40e_rxtx_vec_avx2.c         |  4 +--
 drivers/net/i40e/i40e_rxtx_vec_avx512.c       |  4 +--
 drivers/net/i40e/i40e_rxtx_vec_common.h       |  4 +--
 drivers/net/i40e/i40e_rxtx_vec_neon.c         |  3 +-
 drivers/net/i40e/i40e_rxtx_vec_sse.c          |  4 +--
 drivers/net/iavf/iavf_rxtx_vec_avx2.c         |  4 +--
 drivers/net/iavf/iavf_rxtx_vec_avx512.c       |  4 +--
 drivers/net/iavf/iavf_rxtx_vec_common.h       |  4 +--
 drivers/net/iavf/iavf_rxtx_vec_sse.c          |  4 +--
 drivers/net/ice/ice_rxtx_common_avx.h         |  4 +--
 drivers/net/ice/ice_rxtx_vec_avx2.c           |  4 +--
 drivers/net/ice/ice_rxtx_vec_avx512.c         |  4 +--
 drivers/net/ice/ice_rxtx_vec_common.h         |  4 +--
 drivers/net/ice/ice_rxtx_vec_sse.c            |  4 +--
 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       |  2 +-
 drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c        |  4 +--
 drivers/net/mlx5/mlx5_flow.c                  |  6 ++--
 drivers/net/mlx5/mlx5_rxtx_vec_altivec.h      |  6 ++--
 drivers/net/mlx5/mlx5_rxtx_vec_neon.h         |  2 +-
 drivers/net/mlx5/mlx5_rxtx_vec_sse.h          |  4 +--
 drivers/net/tap/tap_flow.c                    |  6 ++--
 drivers/net/virtio/virtio_rxtx_simple.c       |  4 +--
 lib/eal/include/rte_common.h                  | 34 +++++++++++++++++++
 34 files changed, 77 insertions(+), 101 deletions(-)

--
2.47.0.vfs.0.3

#1 lore raw

PATCH 1/3 lib/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 | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)
lib/eal/include/rte_common.h +34 -0
index 4d299f2b36..c5f91730ef 100644
@@ -137,6 +137,40 @@ typedef uint16_t unaligned_uint16_t;
 #define RTE_DEPRECATED(x)
 #endif
 
+/*
+ * Macro to ignore whenever a pointer is cast so as to remove 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
+
+/*
+ * Macro to ignore code that might break the strict aliasing rules that
+ * the compiler is using for optimization.
+ */
+#if !defined __INTEL_COMPILER && !defined RTE_TOOLCHAIN_MSVC
+#define __rte_diagnostic_ignored_wstrict_aliasing \
+		_Pragma("GCC diagnostic ignored \"-Wstrict-aliasing\"")
+#else
+#define __rte_diagnostic_ignored_wstrict_aliasing
+#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
+
 /**
  * Mark a function or variable to a weak reference.
  */
Signature · 1 line
2.47.0.vfs.0.3
#2 lore raw

PATCH 2/3 drivers/common: add diagnostics macros to make code portable

In reply to Andre Muezerie

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.

---
 drivers/common/idpf/idpf_common_rxtx_avx512.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/common/idpf/idpf_common_rxtx_avx512.c +1 -3
index b8450b03ae..d298a5ca36 100644
@@ -6,9 +6,7 @@
 #include "idpf_common_device.h"
 #include "idpf_common_rxtx.h"
 
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
+__rte_diagnostic_ignored_wcast_qual
 
 #define IDPF_DESCS_PER_LOOP_AVX 8
 #define PKTLEN_SHIFT 10
Signature · 1 line
2.47.0.vfs.0.3
#3 lore raw

Re: [PATCH 2/3] drivers/common: add diagnostics macros to make code portable

Quoted 7 lines · On Thu, 26 Dec 2024 17:33:15 -0800 Andre Muezerie…

From: Andre Muezerie <[email protected]>
To: Bruce Richardson <[email protected]>, Konstantin Ananyev <[email protected]>, Jingjing Wu <[email protected]>, Praveen Shetty <[email protected]>
Cc: [email protected], Andre Muezerie <[email protected]>
Subject: [PATCH 2/3] drivers/common: add diagnostics macros to make code portable
Date: Thu, 26 Dec 2024 17:33:15 -0800
X-Mailer: git-send-email 1.8.3.1

Quoted 6 lines

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

As much as possible, these should be fixed. Disabling warnings hides too many pre-existing bugs.

#4 lore raw

Re: [PATCH 2/3] drivers/common: add diagnostics macros to make code portable

Quoted 17 lines · Stephen Hemminger
Quoted 7 lines · On Thu, 26 Dec 2024 17:33:15 -0800 Andre Muezerie…

From: Andre Muezerie <[email protected]>
To: Bruce Richardson <[email protected]>, Konstantin Ananyev <[email protected]>, Jingjing Wu <[email protected]>, Praveen Shetty <[email protected]>
Cc: [email protected], Andre Muezerie <[email protected]>
Subject: [PATCH 2/3] drivers/common: add diagnostics macros to make code portable
Date: Thu, 26 Dec 2024 17:33:15 -0800
X-Mailer: git-send-email 1.8.3.1

Quoted 6 lines

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

Quoted 2 lines

As much as possible, these should be fixed. Disabling warnings hides too many pre-existing bugs.

I'll take a closer look at these warnings and see what I can get fixed.

My main goal here was to get the code to compile with MSVC (without disabling additional warnings), but I agree that it's not great to see these warnings getting disabled in so many places.

#5 lore raw

PATCH 3/3 drivers/net: add diagnostics macros to make code portable

In reply to Andre Muezerie

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.

---
 drivers/net/axgbe/axgbe_rxtx.h                    | 12 ++++--------
 drivers/net/cpfl/cpfl_rxtx_vec_common.h           |  4 +---
 drivers/net/dpaa2/dpaa2_rxtx.c                    | 15 +++------------
 drivers/net/fm10k/fm10k_rxtx_vec.c                |  4 +---
 drivers/net/hns3/hns3_rxtx_vec_neon.h             |  2 +-
 drivers/net/i40e/i40e_recycle_mbufs_vec_common.c  |  2 +-
 drivers/net/i40e/i40e_rxtx_common_avx.h           |  4 +---
 drivers/net/i40e/i40e_rxtx_vec_altivec.c          |  2 +-
 drivers/net/i40e/i40e_rxtx_vec_avx2.c             |  4 +---
 drivers/net/i40e/i40e_rxtx_vec_avx512.c           |  4 +---
 drivers/net/i40e/i40e_rxtx_vec_common.h           |  4 +---
 drivers/net/i40e/i40e_rxtx_vec_neon.c             |  3 +--
 drivers/net/i40e/i40e_rxtx_vec_sse.c              |  4 +---
 drivers/net/iavf/iavf_rxtx_vec_avx2.c             |  4 +---
 drivers/net/iavf/iavf_rxtx_vec_avx512.c           |  4 +---
 drivers/net/iavf/iavf_rxtx_vec_common.h           |  4 +---
 drivers/net/iavf/iavf_rxtx_vec_sse.c              |  4 +---
 drivers/net/ice/ice_rxtx_common_avx.h             |  4 +---
 drivers/net/ice/ice_rxtx_vec_avx2.c               |  4 +---
 drivers/net/ice/ice_rxtx_vec_avx512.c             |  4 +---
 drivers/net/ice/ice_rxtx_vec_common.h             |  4 +---
 drivers/net/ice/ice_rxtx_vec_sse.c                |  4 +---
 drivers/net/idpf/idpf_rxtx_vec_common.h           |  4 +---
 .../net/ixgbe/ixgbe_recycle_mbufs_vec_common.c    |  2 +-
 drivers/net/ixgbe/ixgbe_rxtx_vec_neon.c           |  2 +-
 drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c            |  4 +---
 drivers/net/mlx5/mlx5_flow.c                      |  6 +++---
 drivers/net/mlx5/mlx5_rxtx_vec_altivec.h          |  6 ++----
 drivers/net/mlx5/mlx5_rxtx_vec_neon.h             |  2 +-
 drivers/net/mlx5/mlx5_rxtx_vec_sse.h              |  4 +---
 drivers/net/tap/tap_flow.c                        |  6 +++---
 drivers/net/virtio/virtio_rxtx_simple.c           |  4 +---
 32 files changed, 42 insertions(+), 98 deletions(-)
drivers/net/axgbe/axgbe_rxtx.h +4 -8
index a326ba9ac8..59583477ac 100644
@@ -6,14 +6,10 @@
 #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
+#include <rte_common.h>
+
+/* to suppress compiler warnings related to descriptor casting */
+__rte_diagnostic_ignored_wcast_qual
 
 /* Descriptor related defines */
 #define AXGBE_MAX_RING_DESC		4096 /*should be power of 2*/
drivers/net/cpfl/cpfl_rxtx_vec_common.h +1 -3
index 479e1ddcb9..5cc841022c 100644
@@ -11,9 +11,7 @@
 #include "cpfl_ethdev.h"
 #include "cpfl_rxtx.h"
 
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
+__rte_diagnostic_ignored_wcast_qual
 
 #define CPFL_SCALAR_PATH		0
 #define CPFL_VECTOR_PATH		1
drivers/net/dpaa2/dpaa2_rxtx.c +3 -12
index e3b6c7e460..f2aba62588 100644
@@ -1962,13 +1962,8 @@ 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
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 
 /* This function loopbacks all the received packets.*/
 uint16_t
@@ -2118,8 +2113,4 @@ 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
+__rte_diagnostic_pop
drivers/net/fm10k/fm10k_rxtx_vec.c +1 -3
index 68acaca75b..d8c8eba9b5 100644
@@ -11,9 +11,7 @@
 
 #include <rte_vect.h>
 
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
+__rte_diagnostic_ignored_wcast_qual
 
 static void
 fm10k_reset_tx_queue(struct fm10k_tx_queue *txq);
drivers/net/hns3/hns3_rxtx_vec_neon.h +1 -1
index bbb5478015..429f37b8f7 100644
@@ -9,7 +9,7 @@
 
 #include <arm_neon.h>
 
-#pragma GCC diagnostic ignored "-Wcast-qual"
+__rte_diagnostic_ignored_wcast_qual
 
 static inline void
 hns3_vec_tx(volatile struct hns3_desc *desc, struct rte_mbuf *pkt)
drivers/net/i40e/i40e_recycle_mbufs_vec_common.c +1 -1
index 14424c9921..c399bfd95d 100644
@@ -10,7 +10,7 @@
 #include "i40e_ethdev.h"
 #include "i40e_rxtx.h"
 
-#pragma GCC diagnostic ignored "-Wcast-qual"
+__rte_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 +1 -3
index 85958d6c81..2a2635ce43 100644
@@ -11,9 +11,7 @@
 #include "i40e_ethdev.h"
 #include "i40e_rxtx.h"
 
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
+__rte_diagnostic_ignored_wcast_qual
 
 #ifdef __AVX2__
 static __rte_always_inline void
drivers/net/i40e/i40e_rxtx_vec_altivec.c +1 -1
index b6b0d38ec1..e3d4ec0459 100644
@@ -15,7 +15,7 @@
 
 #include <rte_altivec.h>
 
-#pragma GCC diagnostic ignored "-Wcast-qual"
+__rte_diagnostic_ignored_wcast_qual
 
 static inline void
 i40e_rxq_rearm(struct i40e_rx_queue *rxq)
drivers/net/i40e/i40e_rxtx_vec_avx2.c +1 -3
index 19cf0ac718..49a9866ea9 100644
@@ -15,9 +15,7 @@
 
 #include <rte_vect.h>
 
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
+__rte_diagnostic_ignored_wcast_qual
 
 static __rte_always_inline void
 i40e_rxq_rearm(struct i40e_rx_queue *rxq)
drivers/net/i40e/i40e_rxtx_vec_avx512.c +1 -3
index 3b2750221b..c2148b65e4 100644
@@ -15,9 +15,7 @@
 
 #include <rte_vect.h>
 
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
+__rte_diagnostic_ignored_wcast_qual
 
 #define RTE_I40E_DESCS_PER_LOOP_AVX 8
 
drivers/net/i40e/i40e_rxtx_vec_common.h +1 -3
index 8b745630e4..94eaf6109d 100644
@@ -11,9 +11,7 @@
 #include "i40e_ethdev.h"
 #include "i40e_rxtx.h"
 
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
+__rte_diagnostic_ignored_wcast_qual
 
 static inline uint16_t
 reassemble_packets(struct i40e_rx_queue *rxq, struct rte_mbuf **rx_bufs,
drivers/net/i40e/i40e_rxtx_vec_neon.c +1 -2
index e1c5c7041b..fc82189e84 100644
@@ -16,8 +16,7 @@
 #include "i40e_rxtx.h"
 #include "i40e_rxtx_vec_common.h"
 
-
-#pragma GCC diagnostic ignored "-Wcast-qual"
+__rte_diagnostic_ignored_wcast_qual
 
 static inline void
 i40e_rxq_rearm(struct i40e_rx_queue *rxq)
drivers/net/i40e/i40e_rxtx_vec_sse.c +1 -3
index ad560d2b6b..89a07f74f5 100644
@@ -14,9 +14,7 @@
 
 #include <rte_vect.h>
 
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
+__rte_diagnostic_ignored_wcast_qual
 
 static inline void
 i40e_rxq_rearm(struct i40e_rx_queue *rxq)
drivers/net/iavf/iavf_rxtx_vec_avx2.c +1 -3
index 49d41af953..d80b06c4a6 100644
@@ -6,9 +6,7 @@
 
 #include <rte_vect.h>
 
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
+__rte_diagnostic_ignored_wcast_qual
 
 static __rte_always_inline void
 iavf_rxq_rearm(struct iavf_rx_queue *rxq)
drivers/net/iavf/iavf_rxtx_vec_avx512.c +1 -3
index d6a861bf80..876935d199 100644
@@ -6,9 +6,7 @@
 
 #include <rte_vect.h>
 
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
+__rte_diagnostic_ignored_wcast_qual
 
 #define IAVF_DESCS_PER_LOOP_AVX 8
 #define PKTLEN_SHIFT 10
drivers/net/iavf/iavf_rxtx_vec_common.h +1 -3
index 5c5220048d..fc886b0ab6 100644
@@ -11,9 +11,7 @@
 #include "iavf.h"
 #include "iavf_rxtx.h"
 
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
+__rte_diagnostic_ignored_wcast_qual
 
 static __rte_always_inline uint16_t
 reassemble_packets(struct iavf_rx_queue *rxq, struct rte_mbuf **rx_bufs,
drivers/net/iavf/iavf_rxtx_vec_sse.c +1 -3
index 0db6fa8bd4..88556e1bf3 100644
@@ -12,9 +12,7 @@
 
 #include <rte_vect.h>
 
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
+__rte_diagnostic_ignored_wcast_qual
 
 static inline void
 iavf_rxq_rearm(struct iavf_rx_queue *rxq)
drivers/net/ice/ice_rxtx_common_avx.h +1 -3
index dacb87dcb0..7d2acc622f 100644
@@ -7,9 +7,7 @@
 
 #include "ice_rxtx.h"
 
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
+__rte_diagnostic_ignored_wcast_qual
 
 #ifdef __AVX2__
 static __rte_always_inline void
drivers/net/ice/ice_rxtx_vec_avx2.c +1 -3
index d6e88dbb29..1d53404af8 100644
@@ -7,9 +7,7 @@
 
 #include <rte_vect.h>
 
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
+__rte_diagnostic_ignored_wcast_qual
 
 static __rte_always_inline void
 ice_rxq_rearm(struct ice_rx_queue *rxq)
drivers/net/ice/ice_rxtx_vec_avx512.c +1 -3
index add095ef06..e1f41312b5 100644
@@ -7,9 +7,7 @@
 
 #include <rte_vect.h>
 
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
+__rte_diagnostic_ignored_wcast_qual
 
 #define ICE_DESCS_PER_LOOP_AVX 8
 
drivers/net/ice/ice_rxtx_vec_common.h +1 -3
index 4b73465af5..537d1d086a 100644
@@ -7,9 +7,7 @@
 
 #include "ice_rxtx.h"
 
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
+__rte_diagnostic_ignored_wcast_qual
 
 static inline uint16_t
 ice_rx_reassemble_packets(struct ice_rx_queue *rxq, struct rte_mbuf **rx_bufs,
drivers/net/ice/ice_rxtx_vec_sse.c +1 -3
index c01d8ede29..77ede76632 100644
@@ -6,9 +6,7 @@
 
 #include <rte_vect.h>
 
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
+__rte_diagnostic_ignored_wcast_qual
 
 static inline __m128i
 ice_flex_rxd_to_fdir_flags_vec(const __m128i fdir_id0_3)
drivers/net/idpf/idpf_rxtx_vec_common.h +1 -3
index 2787d27616..ba29901e67 100644
@@ -11,9 +11,7 @@
 #include "idpf_ethdev.h"
 #include "idpf_rxtx.h"
 
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
+__rte_diagnostic_ignored_wcast_qual
 
 #define IDPF_SCALAR_PATH		0
 #define IDPF_VECTOR_PATH		1
drivers/net/ixgbe/ixgbe_recycle_mbufs_vec_common.c +1 -1
index d451562269..b39661b3e3 100644
@@ -8,7 +8,7 @@
 #include "ixgbe_ethdev.h"
 #include "ixgbe_rxtx.h"
 
-#pragma GCC diagnostic ignored "-Wcast-qual"
+__rte_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 +1 -1
index 952b032eb6..25e820bef8 100644
@@ -11,7 +11,7 @@
 #include "ixgbe_rxtx.h"
 #include "ixgbe_rxtx_vec_common.h"
 
-#pragma GCC diagnostic ignored "-Wcast-qual"
+__rte_diagnostic_ignored_wcast_qual
 
 static inline void
 ixgbe_rxq_rearm(struct ixgbe_rx_queue *rxq)
drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c +1 -3
index a77370cdb7..5a5e8242ef 100644
@@ -12,9 +12,7 @@
 
 #include <rte_vect.h>
 
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
+__rte_diagnostic_ignored_wcast_qual
 
 static inline void
 ixgbe_rxq_rearm(struct ixgbe_rx_queue *rxq)
drivers/net/mlx5/mlx5_flow.c +3 -3
index 16ddd05448..0a89d2c414 100644
@@ -7287,10 +7287,10 @@ flow_tunnel_from_rule(const struct mlx5_flow *flow)
 {
 	struct mlx5_flow_tunnel *tunnel;
 
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wcast-qual"
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	tunnel = (typeof(tunnel))flow->tunnel;
-#pragma GCC diagnostic pop
+__rte_diagnostic_pop
 
 	return tunnel;
 }
drivers/net/mlx5/mlx5_rxtx_vec_altivec.h +2 -4
index 240987d03d..8fa91d1269 100644
@@ -25,10 +25,8 @@
 #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
+__rte_diagnostic_ignored_wcast_qual
+__rte_diagnostic_ignored_wstrict_aliasing
 
 /**
  * Store free buffers to RX SW ring.
drivers/net/mlx5/mlx5_rxtx_vec_neon.h +1 -1
index dc1d30753d..d097bb443b 100644
@@ -25,7 +25,7 @@
 #include "mlx5_rxtx_vec.h"
 #include "mlx5_autoconf.h"
 
-#pragma GCC diagnostic ignored "-Wcast-qual"
+__rte_diagnostic_ignored_wcast_qual
 
 /**
  * Store free buffers to RX SW ring.
drivers/net/mlx5/mlx5_rxtx_vec_sse.h +1 -3
index 81a177fce7..f786a91032 100644
@@ -24,9 +24,7 @@
 #include "mlx5_rxtx_vec.h"
 #include "mlx5_autoconf.h"
 
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
+__rte_diagnostic_ignored_wcast_qual
 
 /**
  * Store free buffers to RX SW ring.
drivers/net/tap/tap_flow.c +3 -3
index c0e44bb1a7..373b773e2d 100644
@@ -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/virtio/virtio_rxtx_simple.c +1 -3
index 438256970d..4037c212c2 100644
@@ -23,9 +23,7 @@
 
 #include "virtio_rxtx_simple.h"
 
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
+__rte_diagnostic_ignored_wcast_qual
 
 int __rte_cold
 virtio_rxq_vec_setup(struct virtnet_rx *rxq)
Signature · 1 line
2.47.0.vfs.0.3
#6 lore raw

v2 cover add diagnostics macros to make code portable

In reply to Andre Muezerie

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.

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):
lib/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 | 46 +++++++++++++++++--
 drivers/net/axgbe/axgbe_rxtx.h                |  9 ----
 drivers/net/cpfl/cpfl_rxtx_vec_common.h       |  4 --
 drivers/net/dpaa2/dpaa2_rxtx.c                | 16 ++-----
 drivers/net/fm10k/fm10k_rxtx_vec.c            | 19 ++++++--
 drivers/net/hns3/hns3_rxtx_vec_neon.h         |  2 -
 .../net/i40e/i40e_recycle_mbufs_vec_common.c  |  2 -
 drivers/net/i40e/i40e_rxtx_common_avx.h       | 10 ++--
 drivers/net/i40e/i40e_rxtx_vec_altivec.c      |  2 -
 drivers/net/i40e/i40e_rxtx_vec_avx2.c         | 16 +++++--
 drivers/net/i40e/i40e_rxtx_vec_avx512.c       | 16 +++++--
 drivers/net/i40e/i40e_rxtx_vec_common.h       |  4 --
 drivers/net/i40e/i40e_rxtx_vec_neon.c         |  3 --
 drivers/net/i40e/i40e_rxtx_vec_sse.c          | 22 +++++++--
 drivers/net/iavf/iavf_rxtx_vec_avx2.c         | 21 +++++++--
 drivers/net/iavf/iavf_rxtx_vec_avx512.c       | 27 +++++++++--
 drivers/net/iavf/iavf_rxtx_vec_common.h       | 10 ++--
 drivers/net/iavf/iavf_rxtx_vec_sse.c          | 30 ++++++++++--
 drivers/net/ice/ice_rxtx_common_avx.h         | 10 ++--
 drivers/net/ice/ice_rxtx_vec_avx2.c           | 16 +++++--
 drivers/net/ice/ice_rxtx_vec_avx512.c         | 16 +++++--
 drivers/net/ice/ice_rxtx_vec_common.h         |  4 --
 drivers/net/ice/ice_rxtx_vec_sse.c            | 22 +++++++--
 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       |  2 -
 drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c        | 19 ++++++--
 drivers/net/mlx5/mlx5_flow.c                  |  6 +--
 drivers/net/mlx5/mlx5_rxtx_vec_altivec.h      |  5 --
 drivers/net/mlx5/mlx5_rxtx_vec_neon.h         |  2 -
 drivers/net/mlx5/mlx5_rxtx_vec_sse.h          |  4 --
 drivers/net/tap/tap_flow.c                    |  6 +--
 drivers/net/virtio/virtio_rxtx_simple.c       |  4 --
 lib/eal/include/rte_common.h                  | 23 ++++++++++
 34 files changed, 269 insertions(+), 135 deletions(-)

--
2.47.0.vfs.0.3

#7 lore raw

PATCH v2 1/3 lib/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 | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
lib/eal/include/rte_common.h +23 -0
index 4d299f2b36..13b7b92f46 100644
@@ -137,6 +137,29 @@ typedef uint16_t unaligned_uint16_t;
 #define RTE_DEPRECATED(x)
 #endif
 
+/*
+ * Macro to ignore whenever a pointer is cast so as to remove 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
+
+/*
+ * 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
+
 /**
  * Mark a function or variable to a weak reference.
  */
Signature · 1 line
2.47.0.vfs.0.3
#8 lore raw

PATCH v2 2/3 drivers/common: add diagnostics macros to make code portable

In reply to Andre Muezerie

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.

---
 drivers/common/idpf/idpf_common_rxtx_avx512.c | 46 +++++++++++++++++--
 1 file changed, 42 insertions(+), 4 deletions(-)
drivers/common/idpf/idpf_common_rxtx_avx512.c +42 -4
index b8450b03ae..37cd0a43e2 100644
@@ -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,8 +30,11 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				_mm_store_si128((__m128i *)&rxdp[i].read,
 						dma_addr0);
+__rte_diagnostic_pop
 			}
 		}
 		rte_atomic_fetch_add_explicit(&rxq->rx_stats.mbuf_alloc_failed,
@@ -108,8 +107,11 @@ 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 */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm512_store_si512((__m512i *)&rxdp->read, dma_addr0_3);
 		_mm512_store_si512((__m512i *)&(rxdp + 4)->read, dma_addr4_7);
+__rte_diagnostic_pop
 	}
 
 	rxq->rxrearm_start += IDPF_RXQ_REARM_THRESH;
@@ -164,8 +166,11 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 					_mm_storeu_si128((__m128i *)&rxdp[i].read,
 							 dma_addr0);
+__rte_diagnostic_pop
 				}
 			}
 			rte_atomic_fetch_add_explicit(&rxq->rx_stats.mbuf_alloc_failed,
@@ -216,10 +221,13 @@ idpf_singleq_rearm(struct idpf_rx_queue *rxq)
 				 iovas1);
 		const __m512i desc6_7 = _mm512_bsrli_epi128(desc4_5, 8);
 
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_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);
+__rte_diagnostic_pop
 
 		rxp += IDPF_DESCS_PER_LOOP_AVX;
 		rxdp += IDPF_DESCS_PER_LOOP_AVX;
@@ -336,6 +344,8 @@ _idpf_singleq_recv_raw_pkts_avx512(struct idpf_rx_queue *rxq,
 #endif
 
 		__m512i raw_desc0_3, raw_desc4_7;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		const __m128i raw_desc7 =
 			_mm_load_si128((void *)(rxdp + 7));
 		rte_compiler_barrier();
@@ -359,6 +369,7 @@ _idpf_singleq_recv_raw_pkts_avx512(struct idpf_rx_queue *rxq,
 		rte_compiler_barrier();
 		const __m128i raw_desc0 =
 			_mm_load_si128((void *)(rxdp + 0));
+__rte_diagnostic_pop
 
 		raw_desc4_7 = _mm512_broadcast_i32x4(raw_desc4);
 		raw_desc4_7 = _mm512_inserti32x4(raw_desc4_7, raw_desc5, 1);
@@ -560,8 +571,11 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				_mm_store_si128((__m128i *)&rxdp[i],
 						dma_addr0);
+__rte_diagnostic_pop
 			}
 		}
 	rte_atomic_fetch_add_explicit(&rx_bufq->rx_stats.mbuf_alloc_failed,
@@ -634,8 +648,11 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 					_mm_storeu_si128((__m128i *)&rxdp[i],
 							 dma_addr0);
+__rte_diagnostic_pop
 				}
 			}
 		rte_atomic_fetch_add_explicit(&rx_bufq->rx_stats.mbuf_alloc_failed,
@@ -797,6 +814,8 @@ _idpf_splitq_recv_raw_pkts_avx512(struct idpf_rx_queue *rxq,
 #endif
 
 		__m512i raw_desc0_3, raw_desc4_7;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		const __m128i raw_desc7 =
 			_mm_load_si128((void *)(rxdp + 7));
 		rte_compiler_barrier();
@@ -820,6 +839,7 @@ _idpf_splitq_recv_raw_pkts_avx512(struct idpf_rx_queue *rxq,
 		rte_compiler_barrier();
 		const __m128i raw_desc0 =
 			_mm_load_si128((void *)(rxdp + 0));
+__rte_diagnostic_pop
 
 		raw_desc4_7 = _mm512_broadcast_i32x4(raw_desc4);
 		raw_desc4_7 = _mm512_inserti32x4(raw_desc4_7, raw_desc5, 1);
@@ -1131,7 +1151,10 @@ idpf_singleq_vtx1(volatile struct idpf_base_tx_desc *txdp,
 
 	__m128i descriptor = _mm_set_epi64x(high_qw,
 					    pkt->buf_iova + pkt->data_off);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm_storeu_si128((__m128i *)txdp, descriptor);
+__rte_diagnostic_pop
 }
 
 #define IDPF_TX_LEN_MASK 0xAA
@@ -1178,7 +1201,10 @@ 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);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm512_storeu_si512((void *)txdp, desc0_3);
+__rte_diagnostic_pop
 	}
 
 	/* do any last ones */
@@ -1435,7 +1461,10 @@ idpf_splitq_vtx1(volatile struct idpf_flex_tx_sched_desc *txdp,
 
 	__m128i descriptor = _mm_set_epi64x(high_qw,
 					    pkt->buf_iova + pkt->data_off);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm_storeu_si128((__m128i *)txdp, descriptor);
+__rte_diagnostic_pop
 }
 
 static __rte_always_inline void
@@ -1480,7 +1509,10 @@ 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);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm512_storeu_si512((void *)txdp, desc0_3);
+__rte_diagnostic_pop
 	}
 
 	/* do any last ones */
@@ -1521,11 +1553,14 @@ idpf_splitq_xmit_fixed_burst_vec_avx512(void *tx_queue, struct rte_mbuf **tx_pkt
 	if (nb_commit >= n) {
 		tx_backlog_entry_avx512(txep, tx_pkts, n);
 
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		idpf_splitq_vtx((void *)txdp, tx_pkts, n - 1, cmd_dtype);
 		tx_pkts += (n - 1);
 		txdp += (n - 1);
 
 		idpf_splitq_vtx1((void *)txdp, *tx_pkts++, cmd_dtype);
+__rte_diagnostic_pop
 
 		nb_commit = (uint16_t)(nb_commit - n);
 
@@ -1540,7 +1575,10 @@ idpf_splitq_xmit_fixed_burst_vec_avx512(void *tx_queue, struct rte_mbuf **tx_pkt
 
 	tx_backlog_entry_avx512(txep, tx_pkts, nb_commit);
 
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	idpf_splitq_vtx((void *)txdp, tx_pkts, nb_commit, cmd_dtype);
+__rte_diagnostic_pop
 
 	tx_id = (uint16_t)(tx_id + nb_commit);
 	if (tx_id > txq->next_rs)
Signature · 1 line
2.47.0.vfs.0.3
#9 lore raw

PATCH v2 3/3 drivers/net: add diagnostics macros to make code portable

In reply to Andre Muezerie

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.

---
 drivers/net/axgbe/axgbe_rxtx.h                |  9 ------
 drivers/net/cpfl/cpfl_rxtx_vec_common.h       |  4 ---
 drivers/net/dpaa2/dpaa2_rxtx.c                | 16 ++--------
 drivers/net/fm10k/fm10k_rxtx_vec.c            | 19 +++++++++---
 drivers/net/hns3/hns3_rxtx_vec_neon.h         |  2 --
 .../net/i40e/i40e_recycle_mbufs_vec_common.c  |  2 --
 drivers/net/i40e/i40e_rxtx_common_avx.h       | 10 ++++---
 drivers/net/i40e/i40e_rxtx_vec_altivec.c      |  2 --
 drivers/net/i40e/i40e_rxtx_vec_avx2.c         | 16 +++++++---
 drivers/net/i40e/i40e_rxtx_vec_avx512.c       | 16 +++++++---
 drivers/net/i40e/i40e_rxtx_vec_common.h       |  4 ---
 drivers/net/i40e/i40e_rxtx_vec_neon.c         |  3 --
 drivers/net/i40e/i40e_rxtx_vec_sse.c          | 22 +++++++++++---
 drivers/net/iavf/iavf_rxtx_vec_avx2.c         | 21 +++++++++----
 drivers/net/iavf/iavf_rxtx_vec_avx512.c       | 27 +++++++++++++----
 drivers/net/iavf/iavf_rxtx_vec_common.h       | 10 ++++---
 drivers/net/iavf/iavf_rxtx_vec_sse.c          | 30 +++++++++++++++----
 drivers/net/ice/ice_rxtx_common_avx.h         | 10 ++++---
 drivers/net/ice/ice_rxtx_vec_avx2.c           | 16 +++++++---
 drivers/net/ice/ice_rxtx_vec_avx512.c         | 16 +++++++---
 drivers/net/ice/ice_rxtx_vec_common.h         |  4 ---
 drivers/net/ice/ice_rxtx_vec_sse.c            | 22 +++++++++++---
 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       |  2 --
 drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c        | 19 +++++++++---
 drivers/net/mlx5/mlx5_flow.c                  |  6 ++--
 drivers/net/mlx5/mlx5_rxtx_vec_altivec.h      |  5 ----
 drivers/net/mlx5/mlx5_rxtx_vec_neon.h         |  2 --
 drivers/net/mlx5/mlx5_rxtx_vec_sse.h          |  4 ---
 drivers/net/tap/tap_flow.c                    |  6 ++--
 drivers/net/virtio/virtio_rxtx_simple.c       |  4 ---
 32 files changed, 204 insertions(+), 131 deletions(-)
drivers/net/axgbe/axgbe_rxtx.h +0 -9
index a326ba9ac8..f5f74a0a39 100644
@@ -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
index 479e1ddcb9..5b98f86932 100644
@@ -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 +3 -13
index e3b6c7e460..21c306fd94 100644
@@ -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,10 @@ dpaa2_dev_loopback_rx(void *queue,
 			if (unlikely((status & QBMAN_DQ_STAT_VALIDFRAME) == 0))
 				continue;
 		}
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		fd[num_rx] = (struct qbman_fd *)qbman_result_DQ_fd(dq_storage);
+__rte_diagnostic_pop
 
 		dq_storage++;
 		num_rx++;
@@ -2118,8 +2113,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 +15 -4
index 68acaca75b..3d534a91ac 100644
@@ -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,11 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 			_mm_store_si128((__m128i *)&rxdp[i].q,
 						dma_addr0);
+__rte_diagnostic_pop
 		}
 
 		rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
@@ -316,8 +315,11 @@ fm10k_rxq_rearm(struct fm10k_rx_queue *rxq)
 		dma_addr1 = _mm_and_si128(dma_addr1, hba_msk);
 
 		/* flush desc with pa dma_addr */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm_store_si128((__m128i *)&rxdp++->q, dma_addr0);
 		_mm_store_si128((__m128i *)&rxdp++->q, dma_addr1);
+__rte_diagnostic_pop
 
 		/* enforce 512B alignment on default Rx virtual addresses */
 		mb0->data_off = (uint16_t)(RTE_PTR_ALIGN((char *)mb0->buf_addr
@@ -465,7 +467,10 @@ 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] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs0[3] = _mm_loadu_si128((__m128i *)(rxdp + 3));
+__rte_diagnostic_pop
 		rte_compiler_barrier();
 
 		/* B.2 copy 2 64 bit or 4 32 bit mbuf point into rx_pkts */
@@ -477,11 +482,14 @@ fm10k_recv_raw_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
 #endif
 
 		/* A.1 load desc[2-0] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs0[2] = _mm_loadu_si128((__m128i *)(rxdp + 2));
 		rte_compiler_barrier();
 		descs0[1] = _mm_loadu_si128((__m128i *)(rxdp + 1));
 		rte_compiler_barrier();
 		descs0[0] = _mm_loadu_si128((__m128i *)(rxdp));
+__rte_diagnostic_pop
 
 #if defined(RTE_ARCH_X86_64)
 		/* B.2 copy 2 mbuf point into rx_pkts  */
@@ -736,7 +744,10 @@ 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));
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm_store_si128((__m128i *)txdp, descriptor);
+__rte_diagnostic_pop
 }
 
 static inline void
drivers/net/hns3/hns3_rxtx_vec_neon.h +0 -2
index bbb5478015..5297087085 100644
@@ -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)
 {
drivers/net/i40e/i40e_recycle_mbufs_vec_common.c +0 -2
index 14424c9921..6eafe51e3d 100644
@@ -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 +6 -4
index 85958d6c81..97e3ab6845 100644
@@ -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,8 +32,11 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				_mm_store_si128((__m128i *)&rxdp[i].read,
 						dma_addr0);
+__rte_diagnostic_pop
 			}
 		}
 		rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
@@ -72,8 +71,11 @@ 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 */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr0);
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr1);
+__rte_diagnostic_pop
 	}
 #else
 #ifdef __AVX512VL__
drivers/net/i40e/i40e_rxtx_vec_altivec.c +0 -2
index b6b0d38ec1..02d930a7f2 100644
@@ -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)
 {
drivers/net/i40e/i40e_rxtx_vec_avx2.c +12 -4
index 19cf0ac718..90a1d4661a 100644
@@ -15,10 +15,6 @@
 
 #include <rte_vect.h>
 
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
-
 static __rte_always_inline void
 i40e_rxq_rearm(struct i40e_rx_queue *rxq)
 {
@@ -39,8 +35,11 @@ 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 */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	__m128i *rxdp_desc_0 = (void *)(&rxdp[desc_idx + 0].wb.qword2);
 	__m128i *rxdp_desc_1 = (void *)(&rxdp[desc_idx + 1].wb.qword2);
+__rte_diagnostic_pop
 	const __m128i desc_qw2_0 = _mm_load_si128(rxdp_desc_0);
 	const __m128i desc_qw2_1 = _mm_load_si128(rxdp_desc_1);
 
@@ -276,6 +275,8 @@ _recv_raw_pkts_vec_avx2(struct i40e_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 				_mm256_loadu_si256((void *)&sw_ring[i + 4]));
 #endif
 
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		const __m128i raw_desc7 = _mm_load_si128((void *)(rxdp + 7));
 		rte_compiler_barrier();
 		const __m128i raw_desc6 = _mm_load_si128((void *)(rxdp + 6));
@@ -291,6 +292,7 @@ _recv_raw_pkts_vec_avx2(struct i40e_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 		const __m128i raw_desc1 = _mm_load_si128((void *)(rxdp + 1));
 		rte_compiler_barrier();
 		const __m128i raw_desc0 = _mm_load_si128((void *)(rxdp + 0));
+__rte_diagnostic_pop
 
 		const __m256i raw_desc6_7 = _mm256_inserti128_si256(
 				_mm256_castsi128_si256(raw_desc6), raw_desc7, 1);
@@ -695,7 +697,10 @@ vtx1(volatile struct i40e_tx_desc *txdp,
 
 	__m128i descriptor = _mm_set_epi64x(high_qw,
 				pkt->buf_iova + pkt->data_off);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm_store_si128((__m128i *)txdp, descriptor);
+__rte_diagnostic_pop
 }
 
 static inline void
@@ -728,8 +733,11 @@ 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);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm256_store_si256((void *)(txdp + 2), desc2_3);
 		_mm256_store_si256((void *)txdp, desc0_1);
+__rte_diagnostic_pop
 	}
 
 	/* do any last ones */
drivers/net/i40e/i40e_rxtx_vec_avx512.c +12 -4
index 3b2750221b..b77989074f 100644
@@ -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 8
 
 static __rte_always_inline void
@@ -41,8 +37,11 @@ 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 */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	__m128i *rxdp_desc_0 = (void *)(&rxdp[desc_idx + 0].wb.qword2);
 	__m128i *rxdp_desc_1 = (void *)(&rxdp[desc_idx + 1].wb.qword2);
+__rte_diagnostic_pop
 	const __m128i desc_qw2_0 = _mm_load_si128(rxdp_desc_0);
 	const __m128i desc_qw2_1 = _mm_load_si128(rxdp_desc_1);
 
@@ -263,6 +262,8 @@ _recv_raw_pkts_vec_avx512(struct i40e_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 		__m256i raw_desc0_1, raw_desc2_3, raw_desc4_5, raw_desc6_7;
 
 		/* load in descriptors, in reverse order */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		const __m128i raw_desc7 =
 			_mm_load_si128((void *)(rxdp + 7));
 		rte_compiler_barrier();
@@ -286,6 +287,7 @@ _recv_raw_pkts_vec_avx512(struct i40e_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 		rte_compiler_barrier();
 		const __m128i raw_desc0 =
 			_mm_load_si128((void *)(rxdp + 0));
+__rte_diagnostic_pop
 
 		raw_desc6_7 =
 			_mm256_inserti128_si256
@@ -875,7 +877,10 @@ 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);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm_store_si128((__m128i *)txdp, descriptor);
+__rte_diagnostic_pop
 }
 
 static inline void
@@ -909,7 +914,10 @@ 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);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm512_storeu_si512((void *)txdp, desc0_3);
+__rte_diagnostic_pop
 	}
 
 	/* do any last ones */
drivers/net/i40e/i40e_rxtx_vec_common.h +0 -4
index 8b745630e4..ec59a68f9d 100644
@@ -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 +0 -3
index e1c5c7041b..f056f40dee 100644
@@ -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)
 {
drivers/net/i40e/i40e_rxtx_vec_sse.c +18 -4
index ad560d2b6b..8a5537bcf2 100644
@@ -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,8 +37,11 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				_mm_store_si128((__m128i *)&rxdp[i].read,
 						dma_addr0);
+__rte_diagnostic_pop
 			}
 		}
 		rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
@@ -72,8 +71,11 @@ i40e_rxq_rearm(struct i40e_rx_queue *rxq)
 		dma_addr1 = _mm_add_epi64(dma_addr1, hdr_room);
 
 		/* flush desc with pa dma_addr */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr0);
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr1);
+__rte_diagnostic_pop
 	}
 
 	rxq->rxrearm_start += RTE_I40E_RXQ_REARM_THRESH;
@@ -97,10 +99,13 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	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);
+__rte_diagnostic_pop
 
 	/* FDIR ID data: move last u32 of each desc to 4 u32 lanes */
 	__m128i v_unpack_01, v_unpack_23;
@@ -462,7 +467,10 @@ _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] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs[3] = _mm_loadu_si128((__m128i *)(rxdp + 3));
+__rte_diagnostic_pop
 		rte_compiler_barrier();
 
 		/* B.2 copy 2 64 bit or 4 32 bit mbuf point into rx_pkts */
@@ -474,11 +482,14 @@ _recv_raw_pkts_vec(struct i40e_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 #endif
 
 		/* A.1 load desc[2-0] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs[2] = _mm_loadu_si128((__m128i *)(rxdp + 2));
 		rte_compiler_barrier();
 		descs[1] = _mm_loadu_si128((__m128i *)(rxdp + 1));
 		rte_compiler_barrier();
 		descs[0] = _mm_loadu_si128((__m128i *)(rxdp));
+__rte_diagnostic_pop
 
 #if defined(RTE_ARCH_X86_64)
 		/* B.2 copy 2 mbuf point into rx_pkts  */
@@ -681,7 +692,10 @@ vtx1(volatile struct i40e_tx_desc *txdp,
 
 	__m128i descriptor = _mm_set_epi64x(high_qw,
 				pkt->buf_iova + pkt->data_off);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm_store_si128((__m128i *)txdp, descriptor);
+__rte_diagnostic_pop
 }
 
 static inline void
drivers/net/iavf/iavf_rxtx_vec_avx2.c +16 -5
index 49d41af953..f5503d9dae 100644
@@ -6,10 +6,6 @@
 
 #include <rte_vect.h>
 
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
-
 static __rte_always_inline void
 iavf_rxq_rearm(struct iavf_rx_queue *rxq)
 {
@@ -193,6 +189,8 @@ _iavf_recv_raw_pkts_vec_avx2(struct iavf_rx_queue *rxq,
 			 _mm256_loadu_si256((void *)&sw_ring[i + 4]));
 #endif
 
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		const __m128i raw_desc7 = _mm_load_si128((void *)(rxdp + 7));
 		rte_compiler_barrier();
 		const __m128i raw_desc6 = _mm_load_si128((void *)(rxdp + 6));
@@ -208,6 +206,7 @@ _iavf_recv_raw_pkts_vec_avx2(struct iavf_rx_queue *rxq,
 		const __m128i raw_desc1 = _mm_load_si128((void *)(rxdp + 1));
 		rte_compiler_barrier();
 		const __m128i raw_desc0 = _mm_load_si128((void *)(rxdp + 0));
+__rte_diagnostic_pop
 
 		const __m256i raw_desc6_7 =
 			_mm256_inserti128_si256(_mm256_castsi128_si256(raw_desc6), raw_desc7, 1);
@@ -509,7 +508,7 @@ _iavf_recv_raw_pkts_vec_avx2_flex_rxd(struct iavf_rx_queue *rxq,
 			0, rxq->mbuf_initializer);
 	struct rte_mbuf **sw_ring = &rxq->sw_ring[rxq->rx_tail];
 	volatile union iavf_rx_flex_desc *rxdp =
-		(union iavf_rx_flex_desc *)rxq->rx_ring + rxq->rx_tail;
+		(volatile union iavf_rx_flex_desc *)rxq->rx_ring + rxq->rx_tail;
 
 	rte_prefetch0(rxdp);
 
@@ -742,6 +741,8 @@ _iavf_recv_raw_pkts_vec_avx2_flex_rxd(struct iavf_rx_queue *rxq,
 
 		__m256i raw_desc0_1, raw_desc2_3, raw_desc4_5, raw_desc6_7;
 
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		const __m128i raw_desc7 =
 			_mm_load_si128((void *)(rxdp + 7));
 		rte_compiler_barrier();
@@ -765,6 +766,7 @@ _iavf_recv_raw_pkts_vec_avx2_flex_rxd(struct iavf_rx_queue *rxq,
 		rte_compiler_barrier();
 		const __m128i raw_desc0 =
 			_mm_load_si128((void *)(rxdp + 0));
+__rte_diagnostic_pop
 
 		raw_desc6_7 =
 			_mm256_inserti128_si256
@@ -959,6 +961,8 @@ _iavf_recv_raw_pkts_vec_avx2_flex_rxd(struct iavf_rx_queue *rxq,
 				offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP ||
 			    rxq->rx_flags & IAVF_RX_FLAGS_VLAN_TAG_LOC_L2TAG2_2) {
 				/* load bottom half of every 32B desc */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				const __m128i raw_desc_bh7 =
 					_mm_load_si128
 						((void *)(&rxdp[7].wb.status_error1));
@@ -990,6 +994,7 @@ _iavf_recv_raw_pkts_vec_avx2_flex_rxd(struct iavf_rx_queue *rxq,
 				const __m128i raw_desc_bh0 =
 					_mm_load_si128
 						((void *)(&rxdp[0].wb.status_error1));
+__rte_diagnostic_pop
 
 				__m256i raw_desc_bh6_7 =
 					_mm256_inserti128_si256
@@ -1664,7 +1669,10 @@ iavf_vtx1(volatile struct iavf_tx_desc *txdp,
 
 	__m128i descriptor = _mm_set_epi64x(high_qw,
 				pkt->buf_iova + pkt->data_off);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm_store_si128((__m128i *)txdp, descriptor);
+__rte_diagnostic_pop
 }
 
 static __rte_always_inline void
@@ -1719,8 +1727,11 @@ iavf_vtx(volatile struct iavf_tx_desc *txdp,
 				 pkt[1]->buf_iova + pkt[1]->data_off,
 				 hi_qw0,
 				 pkt[0]->buf_iova + pkt[0]->data_off);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm256_store_si256((void *)(txdp + 2), desc2_3);
 		_mm256_store_si256((void *)txdp, desc0_1);
+__rte_diagnostic_pop
 	}
 
 	/* do any last ones */
drivers/net/iavf/iavf_rxtx_vec_avx512.c +22 -5
index d6a861bf80..04894debc8 100644
@@ -6,10 +6,6 @@
 
 #include <rte_vect.h>
 
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
-
 #define IAVF_DESCS_PER_LOOP_AVX 8
 #define PKTLEN_SHIFT 10
 
@@ -164,6 +160,8 @@ _iavf_recv_raw_pkts_vec_avx512(struct iavf_rx_queue *rxq,
 #endif
 
 		__m512i raw_desc0_3, raw_desc4_7;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		const __m128i raw_desc7 =
 			_mm_load_si128((void *)(rxdp + 7));
 		rte_compiler_barrier();
@@ -187,6 +185,7 @@ _iavf_recv_raw_pkts_vec_avx512(struct iavf_rx_queue *rxq,
 		rte_compiler_barrier();
 		const __m128i raw_desc0 =
 			_mm_load_si128((void *)(rxdp + 0));
+__rte_diagnostic_pop
 
 		raw_desc4_7 = _mm512_broadcast_i32x4(raw_desc4);
 		raw_desc4_7 = _mm512_inserti32x4(raw_desc4_7, raw_desc5, 1);
@@ -600,7 +599,7 @@ _iavf_recv_raw_pkts_vec_avx512_flex_rxd(struct iavf_rx_queue *rxq,
 						    rxq->mbuf_initializer);
 	struct rte_mbuf **sw_ring = &rxq->sw_ring[rxq->rx_tail];
 	volatile union iavf_rx_flex_desc *rxdp =
-		(union iavf_rx_flex_desc *)rxq->rx_ring + rxq->rx_tail;
+		(volatile union iavf_rx_flex_desc *)rxq->rx_ring + rxq->rx_tail;
 
 	rte_prefetch0(rxdp);
 
@@ -733,6 +732,8 @@ _iavf_recv_raw_pkts_vec_avx512_flex_rxd(struct iavf_rx_queue *rxq,
 
 		__m512i raw_desc0_3, raw_desc4_7;
 
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		const __m128i raw_desc7 =
 			_mm_load_si128((void *)(rxdp + 7));
 		rte_compiler_barrier();
@@ -756,6 +757,7 @@ _iavf_recv_raw_pkts_vec_avx512_flex_rxd(struct iavf_rx_queue *rxq,
 		rte_compiler_barrier();
 		const __m128i raw_desc0 =
 			_mm_load_si128((void *)(rxdp + 0));
+__rte_diagnostic_pop
 
 		raw_desc4_7 = _mm512_broadcast_i32x4(raw_desc4);
 		raw_desc4_7 = _mm512_inserti32x4(raw_desc4_7, raw_desc5, 1);
@@ -1111,6 +1113,8 @@ _iavf_recv_raw_pkts_vec_avx512_flex_rxd(struct iavf_rx_queue *rxq,
 				offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP ||
 			    rxq->rx_flags & IAVF_RX_FLAGS_VLAN_TAG_LOC_L2TAG2_2) {
 				/* load bottom half of every 32B desc */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				const __m128i raw_desc_bh7 =
 					_mm_load_si128
 						((void *)(&rxdp[7].wb.status_error1));
@@ -1142,6 +1146,7 @@ _iavf_recv_raw_pkts_vec_avx512_flex_rxd(struct iavf_rx_queue *rxq,
 				const __m128i raw_desc_bh0 =
 					_mm_load_si128
 						((void *)(&rxdp[0].wb.status_error1));
+__rte_diagnostic_pop
 
 				__m256i raw_desc_bh6_7 =
 					_mm256_inserti128_si256
@@ -1983,7 +1988,10 @@ iavf_vtx1(volatile struct iavf_tx_desc *txdp,
 
 	__m128i descriptor = _mm_set_epi64x(high_qw,
 					    pkt->buf_iova + pkt->data_off);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm_storeu_si128((__m128i *)txdp, descriptor);
+__rte_diagnostic_pop
 }
 
 #define IAVF_TX_LEN_MASK 0xAA
@@ -2037,7 +2045,10 @@ iavf_vtx(volatile struct iavf_tx_desc *txdp,
 				 pkt[1]->buf_iova + pkt[1]->data_off,
 				 hi_qw0,
 				 pkt[0]->buf_iova + pkt[0]->data_off);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm512_storeu_si512((void *)txdp, desc0_3);
+__rte_diagnostic_pop
 	}
 
 	/* do any last ones */
@@ -2225,7 +2236,10 @@ ctx_vtx1(volatile struct iavf_tx_desc *txdp, struct rte_mbuf *pkt,
 	__m256i ctx_data_desc = _mm256_set_epi64x(high_data_qw, pkt->buf_iova + pkt->data_off,
 							high_ctx_qw, low_ctx_qw);
 
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm256_storeu_si256((__m256i *)txdp, ctx_data_desc);
+__rte_diagnostic_pop
 }
 
 static __rte_always_inline void
@@ -2300,7 +2314,10 @@ ctx_vtx(volatile struct iavf_tx_desc *txdp,
 						hi_ctx_qw1, low_ctx_qw1,
 						hi_data_qw0, pkt[0]->buf_iova + pkt[0]->data_off,
 						hi_ctx_qw0, low_ctx_qw0);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm512_storeu_si512((void *)txdp, desc0_3);
+__rte_diagnostic_pop
 	}
 
 	if (nb_pkts)
drivers/net/iavf/iavf_rxtx_vec_common.h +6 -4
index 5c5220048d..690e0749e4 100644
@@ -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_t
 reassemble_packets(struct iavf_rx_queue *rxq, struct rte_mbuf **rx_bufs,
 		   uint16_t nb_bufs, uint8_t *split_flags)
@@ -422,8 +418,11 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				_mm_store_si128((__m128i *)&rxdp[i].read,
 						dma_addr0);
+__rte_diagnostic_pop
 			}
 		}
 		rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
@@ -458,8 +457,11 @@ 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 */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr0);
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr1);
+__rte_diagnostic_pop
 	}
 #else
 #ifdef CC_AVX512_SUPPORT
drivers/net/iavf/iavf_rxtx_vec_sse.c +25 -5
index 0db6fa8bd4..373df0c935 100644
@@ -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,8 +34,11 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				_mm_store_si128((__m128i *)&rxdp[i].read,
 						dma_addr0);
+__rte_diagnostic_pop
 			}
 		}
 		rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
@@ -69,8 +68,11 @@ iavf_rxq_rearm(struct iavf_rx_queue *rxq)
 		dma_addr1 = _mm_add_epi64(dma_addr1, hdr_room);
 
 		/* flush desc with pa dma_addr */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr0);
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr1);
+__rte_diagnostic_pop
 	}
 
 	rxq->rxrearm_start += rxq->rx_free_thresh;
@@ -578,7 +580,10 @@ _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] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs[3] = _mm_loadu_si128((__m128i *)(rxdp + 3));
+__rte_diagnostic_pop
 		rte_compiler_barrier();
 
 		/* B.2 copy 2 64 bit or 4 32 bit mbuf point into rx_pkts */
@@ -590,11 +595,14 @@ _recv_raw_pkts_vec(struct iavf_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 #endif
 
 		/* A.1 load desc[2-0] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs[2] = _mm_loadu_si128((__m128i *)(rxdp + 2));
 		rte_compiler_barrier();
 		descs[1] = _mm_loadu_si128((__m128i *)(rxdp + 1));
 		rte_compiler_barrier();
 		descs[0] = _mm_loadu_si128((__m128i *)(rxdp));
+__rte_diagnostic_pop
 
 #if defined(RTE_ARCH_X86_64)
 		/* B.2 copy 2 mbuf point into rx_pkts  */
@@ -783,7 +791,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 +872,10 @@ _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] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs[3] = _mm_loadu_si128((__m128i *)(rxdp + 3));
+__rte_diagnostic_pop
 		rte_compiler_barrier();
 
 		/* B.2 copy 2 64 bit or 4 32 bit mbuf point into rx_pkts */
@@ -876,11 +887,14 @@ _recv_raw_pkts_vec_flex_rxd(struct iavf_rx_queue *rxq,
 #endif
 
 		/* A.1 load desc[2-0] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs[2] = _mm_loadu_si128((__m128i *)(rxdp + 2));
 		rte_compiler_barrier();
 		descs[1] = _mm_loadu_si128((__m128i *)(rxdp + 1));
 		rte_compiler_barrier();
 		descs[0] = _mm_loadu_si128((__m128i *)(rxdp));
+__rte_diagnostic_pop
 
 #if defined(RTE_ARCH_X86_64)
 		/* B.2 copy 2 mbuf point into rx_pkts  */
@@ -927,6 +941,8 @@ _recv_raw_pkts_vec_flex_rxd(struct iavf_rx_queue *rxq,
 			offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP ||
 			rxq->rx_flags & IAVF_RX_FLAGS_VLAN_TAG_LOC_L2TAG2_2) {
 			/* load bottom half of every 32B desc */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 			descs_bh[3] = _mm_load_si128
 					((void *)(&rxdp[3].wb.status_error1));
 			rte_compiler_barrier();
@@ -938,6 +954,7 @@ _recv_raw_pkts_vec_flex_rxd(struct iavf_rx_queue *rxq,
 			rte_compiler_barrier();
 			descs_bh[0] = _mm_load_si128
 					((void *)(&rxdp[0].wb.status_error1));
+__rte_diagnostic_pop
 		}
 
 		if (offloads & RTE_ETH_RX_OFFLOAD_RSS_HASH) {
@@ -1349,7 +1366,10 @@ 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);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm_store_si128((__m128i *)txdp, descriptor);
+__rte_diagnostic_pop
 }
 
 static inline void
drivers/net/ice/ice_rxtx_common_avx.h +6 -4
index dacb87dcb0..b9cb1f5279 100644
@@ -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,8 +29,11 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				_mm_store_si128((__m128i *)&rxdp[i].read,
 						dma_addr0);
+__rte_diagnostic_pop
 			}
 		}
 		rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
@@ -77,8 +76,11 @@ 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 */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr0);
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr1);
+__rte_diagnostic_pop
 	}
 #else
 #ifdef __AVX512VL__
drivers/net/ice/ice_rxtx_vec_avx2.c +12 -4
index d6e88dbb29..6c6a810a15 100644
@@ -7,10 +7,6 @@
 
 #include <rte_vect.h>
 
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
-
 static __rte_always_inline void
 ice_rxq_rearm(struct ice_rx_queue *rxq)
 {
@@ -254,6 +250,8 @@ _ice_recv_raw_pkts_vec_avx2(struct ice_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 			 _mm256_loadu_si256((void *)&sw_ring[i + 4]));
 #endif
 
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		const __m128i raw_desc7 = _mm_load_si128((void *)(rxdp + 7));
 		rte_compiler_barrier();
 		const __m128i raw_desc6 = _mm_load_si128((void *)(rxdp + 6));
@@ -269,6 +267,7 @@ _ice_recv_raw_pkts_vec_avx2(struct ice_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 		const __m128i raw_desc1 = _mm_load_si128((void *)(rxdp + 1));
 		rte_compiler_barrier();
 		const __m128i raw_desc0 = _mm_load_si128((void *)(rxdp + 0));
+__rte_diagnostic_pop
 
 		const __m256i raw_desc6_7 =
 			_mm256_inserti128_si256(_mm256_castsi128_si256(raw_desc6), raw_desc7, 1);
@@ -444,6 +443,8 @@ _ice_recv_raw_pkts_vec_avx2(struct ice_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 			if (rxq->vsi->adapter->pf.dev_data->dev_conf.rxmode.offloads &
 					RTE_ETH_RX_OFFLOAD_RSS_HASH) {
 				/* load bottom half of every 32B desc */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				const __m128i raw_desc_bh7 =
 					_mm_load_si128
 						((void *)(&rxdp[7].wb.status_error1));
@@ -475,6 +476,7 @@ _ice_recv_raw_pkts_vec_avx2(struct ice_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 				const __m128i raw_desc_bh0 =
 					_mm_load_si128
 						((void *)(&rxdp[0].wb.status_error1));
+__rte_diagnostic_pop
 
 				__m256i raw_desc_bh6_7 =
 					_mm256_inserti128_si256
@@ -790,7 +792,10 @@ ice_vtx1(volatile struct ice_tx_desc *txdp,
 		ice_txd_enable_offload(pkt, &high_qw);
 
 	__m128i descriptor = _mm_set_epi64x(high_qw, rte_pktmbuf_iova(pkt));
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm_store_si128((__m128i *)txdp, descriptor);
+__rte_diagnostic_pop
 }
 
 static __rte_always_inline void
@@ -841,8 +846,11 @@ ice_vtx(volatile struct ice_tx_desc *txdp,
 			_mm256_set_epi64x
 				(hi_qw1, rte_pktmbuf_iova(pkt[1]),
 				 hi_qw0, rte_pktmbuf_iova(pkt[0]));
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm256_store_si256((void *)(txdp + 2), desc2_3);
 		_mm256_store_si256((void *)txdp, desc0_1);
+__rte_diagnostic_pop
 	}
 
 	/* do any last ones */
drivers/net/ice/ice_rxtx_vec_avx512.c +12 -4
index add095ef06..5a774550dc 100644
@@ -7,10 +7,6 @@
 
 #include <rte_vect.h>
 
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
-
 #define ICE_DESCS_PER_LOOP_AVX 8
 
 static __rte_always_inline void
@@ -243,6 +239,8 @@ _ice_recv_raw_pkts_vec_avx512(struct ice_rx_queue *rxq,
 		__m256i raw_desc0_1, raw_desc2_3, raw_desc4_5, raw_desc6_7;
 
 		/* load in descriptors, in reverse order */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		const __m128i raw_desc7 =
 			_mm_load_si128((void *)(rxdp + 7));
 		rte_compiler_barrier();
@@ -266,6 +264,7 @@ _ice_recv_raw_pkts_vec_avx512(struct ice_rx_queue *rxq,
 		rte_compiler_barrier();
 		const __m128i raw_desc0 =
 			_mm_load_si128((void *)(rxdp + 0));
+__rte_diagnostic_pop
 
 		raw_desc6_7 =
 			_mm256_inserti128_si256
@@ -474,6 +473,8 @@ _ice_recv_raw_pkts_vec_avx512(struct ice_rx_queue *rxq,
 			if (rxq->vsi->adapter->pf.dev_data->dev_conf.rxmode.offloads &
 					RTE_ETH_RX_OFFLOAD_RSS_HASH) {
 				/* load bottom half of every 32B desc */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				const __m128i raw_desc_bh7 =
 					_mm_load_si128
 						((void *)(&rxdp[7].wb.status_error1));
@@ -505,6 +506,7 @@ _ice_recv_raw_pkts_vec_avx512(struct ice_rx_queue *rxq,
 				const __m128i raw_desc_bh0 =
 					_mm_load_si128
 						((void *)(&rxdp[0].wb.status_error1));
+__rte_diagnostic_pop
 
 				__m256i raw_desc_bh6_7 =
 					_mm256_inserti128_si256
@@ -987,7 +989,10 @@ ice_vtx1(volatile struct ice_tx_desc *txdp,
 		ice_txd_enable_offload(pkt, &high_qw);
 
 	__m128i descriptor = _mm_set_epi64x(high_qw, rte_pktmbuf_iova(pkt));
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm_store_si128((__m128i *)txdp, descriptor);
+__rte_diagnostic_pop
 }
 
 static __rte_always_inline void
@@ -1029,7 +1034,10 @@ ice_vtx(volatile struct ice_tx_desc *txdp, struct rte_mbuf **pkt,
 				 hi_qw2, rte_pktmbuf_iova(pkt[2]),
 				 hi_qw1, rte_pktmbuf_iova(pkt[1]),
 				 hi_qw0, rte_pktmbuf_iova(pkt[0]));
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm512_storeu_si512((void *)txdp, desc0_3);
+__rte_diagnostic_pop
 	}
 
 	/* do any last ones */
drivers/net/ice/ice_rxtx_vec_common.h +0 -4
index 4b73465af5..45147decff 100644
@@ -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 +18 -4
index c01d8ede29..f2991cee1a 100644
@@ -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,8 +48,11 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				_mm_store_si128((__m128i *)&rxdp[i].read,
 						dma_addr0);
+__rte_diagnostic_pop
 			}
 		}
 		rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
@@ -91,8 +90,11 @@ ice_rxq_rearm(struct ice_rx_queue *rxq)
 		dma_addr1 = _mm_add_epi64(dma_addr1, hdr_room);
 
 		/* flush desc with pa dma_addr */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr0);
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr1);
+__rte_diagnostic_pop
 	}
 
 	rxq->rxrearm_start += ICE_RXQ_REARM_THRESH;
@@ -425,7 +427,10 @@ _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] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs[3] = _mm_loadu_si128((__m128i *)(rxdp + 3));
+__rte_diagnostic_pop
 		rte_compiler_barrier();
 
 		/* B.2 copy 2 64 bit or 4 32 bit mbuf point into rx_pkts */
@@ -437,11 +442,14 @@ _ice_recv_raw_pkts_vec(struct ice_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 #endif
 
 		/* A.1 load desc[2-0] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs[2] = _mm_loadu_si128((__m128i *)(rxdp + 2));
 		rte_compiler_barrier();
 		descs[1] = _mm_loadu_si128((__m128i *)(rxdp + 1));
 		rte_compiler_barrier();
 		descs[0] = _mm_loadu_si128((__m128i *)(rxdp));
+__rte_diagnostic_pop
 
 #if defined(RTE_ARCH_X86_64)
 		/* B.2 copy 2 mbuf point into rx_pkts  */
@@ -489,6 +497,8 @@ _ice_recv_raw_pkts_vec(struct ice_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 		if (rxq->vsi->adapter->pf.dev_data->dev_conf.rxmode.offloads &
 				RTE_ETH_RX_OFFLOAD_RSS_HASH) {
 			/* load bottom half of every 32B desc */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 			const __m128i raw_desc_bh3 =
 				_mm_load_si128
 					((void *)(&rxdp[3].wb.status_error1));
@@ -504,6 +514,7 @@ _ice_recv_raw_pkts_vec(struct ice_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 			const __m128i raw_desc_bh0 =
 				_mm_load_si128
 					((void *)(&rxdp[0].wb.status_error1));
+__rte_diagnostic_pop
 
 			/**
 			 * to shift the 32b RSS hash value to the
@@ -680,7 +691,10 @@ 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));
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm_store_si128((__m128i *)txdp, descriptor);
+__rte_diagnostic_pop
 }
 
 static inline void
drivers/net/idpf/idpf_rxtx_vec_common.h +0 -4
index 2787d27616..002c1e6948 100644
@@ -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
index d451562269..92a89f8def 100644
@@ -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 +0 -2
index 952b032eb6..4e7a64b39f 100644
@@ -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)
 {
drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c +15 -4
index a77370cdb7..8e4048a32f 100644
@@ -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,8 +37,11 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				_mm_store_si128((__m128i *)&rxdp[i].read,
 						dma_addr0);
+__rte_diagnostic_pop
 			}
 		}
 		rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
@@ -76,8 +75,11 @@ ixgbe_rxq_rearm(struct ixgbe_rx_queue *rxq)
 		dma_addr1 =  _mm_and_si128(dma_addr1, hba_msk);
 
 		/* flush desc with pa dma_addr */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr0);
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr1);
+__rte_diagnostic_pop
 	}
 
 	rxq->rxrearm_start += RTE_IXGBE_RXQ_REARM_THRESH;
@@ -466,7 +468,10 @@ _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] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs[3] = _mm_loadu_si128((__m128i *)(rxdp + 3));
+__rte_diagnostic_pop
 		rte_compiler_barrier();
 
 		/* B.2 copy 2 64 bit or 4 32 bit mbuf point into rx_pkts */
@@ -478,11 +483,14 @@ _recv_raw_pkts_vec(struct ixgbe_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 #endif
 
 		/* A.1 load desc[2-0] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs[2] = _mm_loadu_si128((__m128i *)(rxdp + 2));
 		rte_compiler_barrier();
 		descs[1] = _mm_loadu_si128((__m128i *)(rxdp + 1));
 		rte_compiler_barrier();
 		descs[0] = _mm_loadu_si128((__m128i *)(rxdp));
+__rte_diagnostic_pop
 
 #if defined(RTE_ARCH_X86_64)
 		/* B.2 copy 2 mbuf point into rx_pkts  */
@@ -676,7 +684,10 @@ 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);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm_store_si128((__m128i *)&txdp->read, descriptor);
+__rte_diagnostic_pop
 }
 
 static inline void
drivers/net/mlx5/mlx5_flow.c +3 -3
index 16ddd05448..0a89d2c414 100644
@@ -7287,10 +7287,10 @@ flow_tunnel_from_rule(const struct mlx5_flow *flow)
 {
 	struct mlx5_flow_tunnel *tunnel;
 
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wcast-qual"
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	tunnel = (typeof(tunnel))flow->tunnel;
-#pragma GCC diagnostic pop
+__rte_diagnostic_pop
 
 	return tunnel;
 }
drivers/net/mlx5/mlx5_rxtx_vec_altivec.h +0 -5
index 240987d03d..b37483bcca 100644
@@ -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 +0 -2
index dc1d30753d..e7deacc1fb 100644
@@ -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.
  *
drivers/net/mlx5/mlx5_rxtx_vec_sse.h +0 -4
index 81a177fce7..55c23dac80 100644
@@ -24,10 +24,6 @@
 #include "mlx5_rxtx_vec.h"
 #include "mlx5_autoconf.h"
 
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
-
 /**
  * Store free buffers to RX SW ring.
  *
drivers/net/tap/tap_flow.c +3 -3
index c0e44bb1a7..373b773e2d 100644
@@ -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/virtio/virtio_rxtx_simple.c +0 -4
index 438256970d..439e00a7e1 100644
@@ -23,10 +23,6 @@
 
 #include "virtio_rxtx_simple.h"
 
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
-
 int __rte_cold
 virtio_rxq_vec_setup(struct virtnet_rx *rxq)
 {
Signature · 1 line
2.47.0.vfs.0.3
#10 lore raw

v3 cover add diagnostics macros to make code portable

In reply to Andre Muezerie

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.

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):
lib/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 | 46 +++++++++++++++++--
 drivers/net/axgbe/axgbe_rxtx.h                |  9 ----
 drivers/net/cpfl/cpfl_rxtx_vec_common.h       |  4 --
 drivers/net/dpaa2/dpaa2_rxtx.c                | 16 ++-----
 drivers/net/fm10k/fm10k_rxtx_vec.c            | 19 ++++++--
 drivers/net/hns3/hns3_rxtx_vec_neon.h         |  5 +-
 .../net/i40e/i40e_recycle_mbufs_vec_common.c  |  2 -
 drivers/net/i40e/i40e_rxtx_common_avx.h       | 16 +++++--
 drivers/net/i40e/i40e_rxtx_vec_altivec.c      | 11 ++++-
 drivers/net/i40e/i40e_rxtx_vec_avx2.c         | 16 +++++--
 drivers/net/i40e/i40e_rxtx_vec_avx512.c       | 16 +++++--
 drivers/net/i40e/i40e_rxtx_vec_common.h       |  4 --
 drivers/net/i40e/i40e_rxtx_vec_neon.c         |  9 ++--
 drivers/net/i40e/i40e_rxtx_vec_sse.c          | 22 +++++++--
 drivers/net/iavf/iavf_rxtx_vec_avx2.c         | 21 +++++++--
 drivers/net/iavf/iavf_rxtx_vec_avx512.c       | 27 +++++++++--
 drivers/net/iavf/iavf_rxtx_vec_common.h       | 10 ++--
 drivers/net/iavf/iavf_rxtx_vec_sse.c          | 30 ++++++++++--
 drivers/net/ice/ice_rxtx_common_avx.h         | 10 ++--
 drivers/net/ice/ice_rxtx_vec_avx2.c           | 16 +++++--
 drivers/net/ice/ice_rxtx_vec_avx512.c         | 16 +++++--
 drivers/net/ice/ice_rxtx_vec_common.h         |  4 --
 drivers/net/ice/ice_rxtx_vec_sse.c            | 22 +++++++--
 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       |  2 -
 drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c        | 19 ++++++--
 drivers/net/mlx5/mlx5_flow.c                  |  6 +--
 drivers/net/mlx5/mlx5_rxtx_vec_altivec.h      |  5 --
 drivers/net/mlx5/mlx5_rxtx_vec_neon.h         |  2 -
 drivers/net/mlx5/mlx5_rxtx_vec_sse.h          | 26 ++++++++---
 drivers/net/tap/tap_flow.c                    |  6 +--
 drivers/net/virtio/virtio_rxtx_simple.c       |  4 --
 lib/eal/include/rte_common.h                  | 23 ++++++++++
 34 files changed, 312 insertions(+), 138 deletions(-)

--
2.47.0.vfs.0.3

#11 lore raw

PATCH v3 1/3 lib/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 | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
lib/eal/include/rte_common.h +23 -0
index 4d299f2b36..13b7b92f46 100644
@@ -137,6 +137,29 @@ typedef uint16_t unaligned_uint16_t;
 #define RTE_DEPRECATED(x)
 #endif
 
+/*
+ * Macro to ignore whenever a pointer is cast so as to remove 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
+
+/*
+ * 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
+
 /**
  * Mark a function or variable to a weak reference.
  */
Signature · 1 line
2.47.0.vfs.0.3
#12 lore raw

PATCH v3 2/3 drivers/common: add diagnostics macros to make code portable

In reply to Andre Muezerie

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.

---
 drivers/common/idpf/idpf_common_rxtx_avx512.c | 46 +++++++++++++++++--
 1 file changed, 42 insertions(+), 4 deletions(-)
drivers/common/idpf/idpf_common_rxtx_avx512.c +42 -4
index b8450b03ae..37cd0a43e2 100644
@@ -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,8 +30,11 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				_mm_store_si128((__m128i *)&rxdp[i].read,
 						dma_addr0);
+__rte_diagnostic_pop
 			}
 		}
 		rte_atomic_fetch_add_explicit(&rxq->rx_stats.mbuf_alloc_failed,
@@ -108,8 +107,11 @@ 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 */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm512_store_si512((__m512i *)&rxdp->read, dma_addr0_3);
 		_mm512_store_si512((__m512i *)&(rxdp + 4)->read, dma_addr4_7);
+__rte_diagnostic_pop
 	}
 
 	rxq->rxrearm_start += IDPF_RXQ_REARM_THRESH;
@@ -164,8 +166,11 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 					_mm_storeu_si128((__m128i *)&rxdp[i].read,
 							 dma_addr0);
+__rte_diagnostic_pop
 				}
 			}
 			rte_atomic_fetch_add_explicit(&rxq->rx_stats.mbuf_alloc_failed,
@@ -216,10 +221,13 @@ idpf_singleq_rearm(struct idpf_rx_queue *rxq)
 				 iovas1);
 		const __m512i desc6_7 = _mm512_bsrli_epi128(desc4_5, 8);
 
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_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);
+__rte_diagnostic_pop
 
 		rxp += IDPF_DESCS_PER_LOOP_AVX;
 		rxdp += IDPF_DESCS_PER_LOOP_AVX;
@@ -336,6 +344,8 @@ _idpf_singleq_recv_raw_pkts_avx512(struct idpf_rx_queue *rxq,
 #endif
 
 		__m512i raw_desc0_3, raw_desc4_7;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		const __m128i raw_desc7 =
 			_mm_load_si128((void *)(rxdp + 7));
 		rte_compiler_barrier();
@@ -359,6 +369,7 @@ _idpf_singleq_recv_raw_pkts_avx512(struct idpf_rx_queue *rxq,
 		rte_compiler_barrier();
 		const __m128i raw_desc0 =
 			_mm_load_si128((void *)(rxdp + 0));
+__rte_diagnostic_pop
 
 		raw_desc4_7 = _mm512_broadcast_i32x4(raw_desc4);
 		raw_desc4_7 = _mm512_inserti32x4(raw_desc4_7, raw_desc5, 1);
@@ -560,8 +571,11 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				_mm_store_si128((__m128i *)&rxdp[i],
 						dma_addr0);
+__rte_diagnostic_pop
 			}
 		}
 	rte_atomic_fetch_add_explicit(&rx_bufq->rx_stats.mbuf_alloc_failed,
@@ -634,8 +648,11 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 					_mm_storeu_si128((__m128i *)&rxdp[i],
 							 dma_addr0);
+__rte_diagnostic_pop
 				}
 			}
 		rte_atomic_fetch_add_explicit(&rx_bufq->rx_stats.mbuf_alloc_failed,
@@ -797,6 +814,8 @@ _idpf_splitq_recv_raw_pkts_avx512(struct idpf_rx_queue *rxq,
 #endif
 
 		__m512i raw_desc0_3, raw_desc4_7;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		const __m128i raw_desc7 =
 			_mm_load_si128((void *)(rxdp + 7));
 		rte_compiler_barrier();
@@ -820,6 +839,7 @@ _idpf_splitq_recv_raw_pkts_avx512(struct idpf_rx_queue *rxq,
 		rte_compiler_barrier();
 		const __m128i raw_desc0 =
 			_mm_load_si128((void *)(rxdp + 0));
+__rte_diagnostic_pop
 
 		raw_desc4_7 = _mm512_broadcast_i32x4(raw_desc4);
 		raw_desc4_7 = _mm512_inserti32x4(raw_desc4_7, raw_desc5, 1);
@@ -1131,7 +1151,10 @@ idpf_singleq_vtx1(volatile struct idpf_base_tx_desc *txdp,
 
 	__m128i descriptor = _mm_set_epi64x(high_qw,
 					    pkt->buf_iova + pkt->data_off);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm_storeu_si128((__m128i *)txdp, descriptor);
+__rte_diagnostic_pop
 }
 
 #define IDPF_TX_LEN_MASK 0xAA
@@ -1178,7 +1201,10 @@ 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);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm512_storeu_si512((void *)txdp, desc0_3);
+__rte_diagnostic_pop
 	}
 
 	/* do any last ones */
@@ -1435,7 +1461,10 @@ idpf_splitq_vtx1(volatile struct idpf_flex_tx_sched_desc *txdp,
 
 	__m128i descriptor = _mm_set_epi64x(high_qw,
 					    pkt->buf_iova + pkt->data_off);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm_storeu_si128((__m128i *)txdp, descriptor);
+__rte_diagnostic_pop
 }
 
 static __rte_always_inline void
@@ -1480,7 +1509,10 @@ 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);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm512_storeu_si512((void *)txdp, desc0_3);
+__rte_diagnostic_pop
 	}
 
 	/* do any last ones */
@@ -1521,11 +1553,14 @@ idpf_splitq_xmit_fixed_burst_vec_avx512(void *tx_queue, struct rte_mbuf **tx_pkt
 	if (nb_commit >= n) {
 		tx_backlog_entry_avx512(txep, tx_pkts, n);
 
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		idpf_splitq_vtx((void *)txdp, tx_pkts, n - 1, cmd_dtype);
 		tx_pkts += (n - 1);
 		txdp += (n - 1);
 
 		idpf_splitq_vtx1((void *)txdp, *tx_pkts++, cmd_dtype);
+__rte_diagnostic_pop
 
 		nb_commit = (uint16_t)(nb_commit - n);
 
@@ -1540,7 +1575,10 @@ idpf_splitq_xmit_fixed_burst_vec_avx512(void *tx_queue, struct rte_mbuf **tx_pkt
 
 	tx_backlog_entry_avx512(txep, tx_pkts, nb_commit);
 
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	idpf_splitq_vtx((void *)txdp, tx_pkts, nb_commit, cmd_dtype);
+__rte_diagnostic_pop
 
 	tx_id = (uint16_t)(tx_id + nb_commit);
 	if (tx_id > txq->next_rs)
Signature · 1 line
2.47.0.vfs.0.3
#13 lore raw

PATCH v3 3/3 drivers/net: add diagnostics macros to make code portable

In reply to Andre Muezerie

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.

---
 drivers/net/axgbe/axgbe_rxtx.h                |  9 ------
 drivers/net/cpfl/cpfl_rxtx_vec_common.h       |  4 ---
 drivers/net/dpaa2/dpaa2_rxtx.c                | 16 ++--------
 drivers/net/fm10k/fm10k_rxtx_vec.c            | 19 +++++++++---
 drivers/net/hns3/hns3_rxtx_vec_neon.h         |  5 ++--
 .../net/i40e/i40e_recycle_mbufs_vec_common.c  |  2 --
 drivers/net/i40e/i40e_rxtx_common_avx.h       | 16 +++++++---
 drivers/net/i40e/i40e_rxtx_vec_altivec.c      | 11 +++++--
 drivers/net/i40e/i40e_rxtx_vec_avx2.c         | 16 +++++++---
 drivers/net/i40e/i40e_rxtx_vec_avx512.c       | 16 +++++++---
 drivers/net/i40e/i40e_rxtx_vec_common.h       |  4 ---
 drivers/net/i40e/i40e_rxtx_vec_neon.c         |  9 ++++--
 drivers/net/i40e/i40e_rxtx_vec_sse.c          | 22 +++++++++++---
 drivers/net/iavf/iavf_rxtx_vec_avx2.c         | 21 +++++++++----
 drivers/net/iavf/iavf_rxtx_vec_avx512.c       | 27 +++++++++++++----
 drivers/net/iavf/iavf_rxtx_vec_common.h       | 10 ++++---
 drivers/net/iavf/iavf_rxtx_vec_sse.c          | 30 +++++++++++++++----
 drivers/net/ice/ice_rxtx_common_avx.h         | 10 ++++---
 drivers/net/ice/ice_rxtx_vec_avx2.c           | 16 +++++++---
 drivers/net/ice/ice_rxtx_vec_avx512.c         | 16 +++++++---
 drivers/net/ice/ice_rxtx_vec_common.h         |  4 ---
 drivers/net/ice/ice_rxtx_vec_sse.c            | 22 +++++++++++---
 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       |  2 --
 drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c        | 19 +++++++++---
 drivers/net/mlx5/mlx5_flow.c                  |  6 ++--
 drivers/net/mlx5/mlx5_rxtx_vec_altivec.h      |  5 ----
 drivers/net/mlx5/mlx5_rxtx_vec_neon.h         |  2 --
 drivers/net/mlx5/mlx5_rxtx_vec_sse.h          | 26 +++++++++++-----
 drivers/net/tap/tap_flow.c                    |  6 ++--
 drivers/net/virtio/virtio_rxtx_simple.c       |  4 ---
 32 files changed, 247 insertions(+), 134 deletions(-)
drivers/net/axgbe/axgbe_rxtx.h +0 -9
index a326ba9ac8..f5f74a0a39 100644
@@ -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
index 479e1ddcb9..5b98f86932 100644
@@ -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 +3 -13
index e3b6c7e460..21c306fd94 100644
@@ -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,10 @@ dpaa2_dev_loopback_rx(void *queue,
 			if (unlikely((status & QBMAN_DQ_STAT_VALIDFRAME) == 0))
 				continue;
 		}
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		fd[num_rx] = (struct qbman_fd *)qbman_result_DQ_fd(dq_storage);
+__rte_diagnostic_pop
 
 		dq_storage++;
 		num_rx++;
@@ -2118,8 +2113,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 +15 -4
index 68acaca75b..3d534a91ac 100644
@@ -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,11 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 			_mm_store_si128((__m128i *)&rxdp[i].q,
 						dma_addr0);
+__rte_diagnostic_pop
 		}
 
 		rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
@@ -316,8 +315,11 @@ fm10k_rxq_rearm(struct fm10k_rx_queue *rxq)
 		dma_addr1 = _mm_and_si128(dma_addr1, hba_msk);
 
 		/* flush desc with pa dma_addr */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm_store_si128((__m128i *)&rxdp++->q, dma_addr0);
 		_mm_store_si128((__m128i *)&rxdp++->q, dma_addr1);
+__rte_diagnostic_pop
 
 		/* enforce 512B alignment on default Rx virtual addresses */
 		mb0->data_off = (uint16_t)(RTE_PTR_ALIGN((char *)mb0->buf_addr
@@ -465,7 +467,10 @@ 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] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs0[3] = _mm_loadu_si128((__m128i *)(rxdp + 3));
+__rte_diagnostic_pop
 		rte_compiler_barrier();
 
 		/* B.2 copy 2 64 bit or 4 32 bit mbuf point into rx_pkts */
@@ -477,11 +482,14 @@ fm10k_recv_raw_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
 #endif
 
 		/* A.1 load desc[2-0] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs0[2] = _mm_loadu_si128((__m128i *)(rxdp + 2));
 		rte_compiler_barrier();
 		descs0[1] = _mm_loadu_si128((__m128i *)(rxdp + 1));
 		rte_compiler_barrier();
 		descs0[0] = _mm_loadu_si128((__m128i *)(rxdp));
+__rte_diagnostic_pop
 
 #if defined(RTE_ARCH_X86_64)
 		/* B.2 copy 2 mbuf point into rx_pkts  */
@@ -736,7 +744,10 @@ 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));
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm_store_si128((__m128i *)txdp, descriptor);
+__rte_diagnostic_pop
 }
 
 static inline void
drivers/net/hns3/hns3_rxtx_vec_neon.h +3 -2
index bbb5478015..99f080f3e8 100644
@@ -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,11 @@ hns3_vec_tx(volatile struct hns3_desc *desc, struct rte_mbuf *pkt)
 		0,
 		((uint64_t)HNS3_TXD_DEFAULT_VLD_FE_BDTYPE) << HNS3_UINT32_BIT
 	};
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	vst1q_u64((uint64_t *)&desc->addr, val1);
 	vst1q_u64((uint64_t *)&desc->tx.outer_vlan_tag, val2);
+__rte_diagnostic_pop
 }
 
 static uint16_t
drivers/net/i40e/i40e_recycle_mbufs_vec_common.c +0 -2
index 14424c9921..6eafe51e3d 100644
@@ -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 +12 -4
index 85958d6c81..bcabacf689 100644
@@ -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,8 +32,11 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				_mm_store_si128((__m128i *)&rxdp[i].read,
 						dma_addr0);
+__rte_diagnostic_pop
 			}
 		}
 		rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
@@ -72,8 +71,11 @@ 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 */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr0);
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr1);
+__rte_diagnostic_pop
 	}
 #else
 #ifdef __AVX512VL__
@@ -144,8 +146,11 @@ 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 */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 			_mm512_store_si512((__m512i *)&rxdp->read, dma_addr0_3);
 			_mm512_store_si512((__m512i *)&(rxdp + 4)->read, dma_addr4_7);
+__rte_diagnostic_pop
 		}
 	} else
 #endif /* __AVX512VL__*/
@@ -190,8 +195,11 @@ 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 */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 			_mm256_store_si256((__m256i *)&rxdp->read, dma_addr0_1);
 			_mm256_store_si256((__m256i *)&(rxdp + 2)->read, dma_addr2_3);
+__rte_diagnostic_pop
 		}
 	}
 
drivers/net/i40e/i40e_rxtx_vec_altivec.c +9 -2
index b6b0d38ec1..6771cc7928 100644
@@ -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)
 {
@@ -286,7 +284,10 @@ _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] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs[3] = *(__vector unsigned long *)(rxdp + 3);
+__rte_diagnostic_pop
 		rte_compiler_barrier();
 
 		/* B.2 copy 2 mbuf point into rx_pkts  */
@@ -296,11 +297,14 @@ _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] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs[2] = *(__vector unsigned long *)(rxdp + 2);
 		rte_compiler_barrier();
 		descs[1] = *(__vector unsigned long *)(rxdp + 1);
 		rte_compiler_barrier();
 		descs[0] = *(__vector unsigned long *)(rxdp);
+__rte_diagnostic_pop
 
 		/* B.2 copy 2 mbuf point into rx_pkts  */
 		*(__vector unsigned long *)&rx_pkts[pos + 2] =  mbp2;
@@ -534,7 +538,10 @@ vtx1(volatile struct i40e_tx_desc *txdp,
 
 	__vector unsigned long descriptor = (__vector unsigned long){
 		pkt->buf_iova + pkt->data_off, high_qw};
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	*(__vector unsigned long *)txdp = descriptor;
+__rte_diagnostic_pop
 }
 
 static inline void
drivers/net/i40e/i40e_rxtx_vec_avx2.c +12 -4
index 19cf0ac718..90a1d4661a 100644
@@ -15,10 +15,6 @@
 
 #include <rte_vect.h>
 
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
-
 static __rte_always_inline void
 i40e_rxq_rearm(struct i40e_rx_queue *rxq)
 {
@@ -39,8 +35,11 @@ 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 */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	__m128i *rxdp_desc_0 = (void *)(&rxdp[desc_idx + 0].wb.qword2);
 	__m128i *rxdp_desc_1 = (void *)(&rxdp[desc_idx + 1].wb.qword2);
+__rte_diagnostic_pop
 	const __m128i desc_qw2_0 = _mm_load_si128(rxdp_desc_0);
 	const __m128i desc_qw2_1 = _mm_load_si128(rxdp_desc_1);
 
@@ -276,6 +275,8 @@ _recv_raw_pkts_vec_avx2(struct i40e_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 				_mm256_loadu_si256((void *)&sw_ring[i + 4]));
 #endif
 
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		const __m128i raw_desc7 = _mm_load_si128((void *)(rxdp + 7));
 		rte_compiler_barrier();
 		const __m128i raw_desc6 = _mm_load_si128((void *)(rxdp + 6));
@@ -291,6 +292,7 @@ _recv_raw_pkts_vec_avx2(struct i40e_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 		const __m128i raw_desc1 = _mm_load_si128((void *)(rxdp + 1));
 		rte_compiler_barrier();
 		const __m128i raw_desc0 = _mm_load_si128((void *)(rxdp + 0));
+__rte_diagnostic_pop
 
 		const __m256i raw_desc6_7 = _mm256_inserti128_si256(
 				_mm256_castsi128_si256(raw_desc6), raw_desc7, 1);
@@ -695,7 +697,10 @@ vtx1(volatile struct i40e_tx_desc *txdp,
 
 	__m128i descriptor = _mm_set_epi64x(high_qw,
 				pkt->buf_iova + pkt->data_off);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm_store_si128((__m128i *)txdp, descriptor);
+__rte_diagnostic_pop
 }
 
 static inline void
@@ -728,8 +733,11 @@ 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);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm256_store_si256((void *)(txdp + 2), desc2_3);
 		_mm256_store_si256((void *)txdp, desc0_1);
+__rte_diagnostic_pop
 	}
 
 	/* do any last ones */
drivers/net/i40e/i40e_rxtx_vec_avx512.c +12 -4
index 3b2750221b..b77989074f 100644
@@ -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 8
 
 static __rte_always_inline void
@@ -41,8 +37,11 @@ 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 */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	__m128i *rxdp_desc_0 = (void *)(&rxdp[desc_idx + 0].wb.qword2);
 	__m128i *rxdp_desc_1 = (void *)(&rxdp[desc_idx + 1].wb.qword2);
+__rte_diagnostic_pop
 	const __m128i desc_qw2_0 = _mm_load_si128(rxdp_desc_0);
 	const __m128i desc_qw2_1 = _mm_load_si128(rxdp_desc_1);
 
@@ -263,6 +262,8 @@ _recv_raw_pkts_vec_avx512(struct i40e_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 		__m256i raw_desc0_1, raw_desc2_3, raw_desc4_5, raw_desc6_7;
 
 		/* load in descriptors, in reverse order */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		const __m128i raw_desc7 =
 			_mm_load_si128((void *)(rxdp + 7));
 		rte_compiler_barrier();
@@ -286,6 +287,7 @@ _recv_raw_pkts_vec_avx512(struct i40e_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 		rte_compiler_barrier();
 		const __m128i raw_desc0 =
 			_mm_load_si128((void *)(rxdp + 0));
+__rte_diagnostic_pop
 
 		raw_desc6_7 =
 			_mm256_inserti128_si256
@@ -875,7 +877,10 @@ 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);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm_store_si128((__m128i *)txdp, descriptor);
+__rte_diagnostic_pop
 }
 
 static inline void
@@ -909,7 +914,10 @@ 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);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm512_storeu_si512((void *)txdp, desc0_3);
+__rte_diagnostic_pop
 	}
 
 	/* do any last ones */
drivers/net/i40e/i40e_rxtx_vec_common.h +0 -4
index 8b745630e4..ec59a68f9d 100644
@@ -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 +6 -3
index e1c5c7041b..f35f3e1e20 100644
@@ -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)
 {
@@ -421,6 +418,8 @@ _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] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs[3] =  vld1q_u64((uint64_t *)(rxdp + 3));
 		descs[2] =  vld1q_u64((uint64_t *)(rxdp + 2));
 		descs[1] =  vld1q_u64((uint64_t *)(rxdp + 1));
@@ -433,6 +432,7 @@ _recv_raw_pkts_vec(struct i40e_rx_queue *__rte_restrict rxq,
 		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);
+__rte_diagnostic_pop
 
 		/* B.1 load 4 mbuf point */
 		mbp1 = vld1q_u64((uint64_t *)&sw_ring[pos]);
@@ -662,7 +662,10 @@ 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};
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	vst1q_u64((uint64_t *)txdp, descriptor);
+__rte_diagnostic_pop
 }
 
 static inline void
drivers/net/i40e/i40e_rxtx_vec_sse.c +18 -4
index ad560d2b6b..8a5537bcf2 100644
@@ -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,8 +37,11 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				_mm_store_si128((__m128i *)&rxdp[i].read,
 						dma_addr0);
+__rte_diagnostic_pop
 			}
 		}
 		rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
@@ -72,8 +71,11 @@ i40e_rxq_rearm(struct i40e_rx_queue *rxq)
 		dma_addr1 = _mm_add_epi64(dma_addr1, hdr_room);
 
 		/* flush desc with pa dma_addr */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr0);
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr1);
+__rte_diagnostic_pop
 	}
 
 	rxq->rxrearm_start += RTE_I40E_RXQ_REARM_THRESH;
@@ -97,10 +99,13 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	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);
+__rte_diagnostic_pop
 
 	/* FDIR ID data: move last u32 of each desc to 4 u32 lanes */
 	__m128i v_unpack_01, v_unpack_23;
@@ -462,7 +467,10 @@ _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] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs[3] = _mm_loadu_si128((__m128i *)(rxdp + 3));
+__rte_diagnostic_pop
 		rte_compiler_barrier();
 
 		/* B.2 copy 2 64 bit or 4 32 bit mbuf point into rx_pkts */
@@ -474,11 +482,14 @@ _recv_raw_pkts_vec(struct i40e_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 #endif
 
 		/* A.1 load desc[2-0] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs[2] = _mm_loadu_si128((__m128i *)(rxdp + 2));
 		rte_compiler_barrier();
 		descs[1] = _mm_loadu_si128((__m128i *)(rxdp + 1));
 		rte_compiler_barrier();
 		descs[0] = _mm_loadu_si128((__m128i *)(rxdp));
+__rte_diagnostic_pop
 
 #if defined(RTE_ARCH_X86_64)
 		/* B.2 copy 2 mbuf point into rx_pkts  */
@@ -681,7 +692,10 @@ vtx1(volatile struct i40e_tx_desc *txdp,
 
 	__m128i descriptor = _mm_set_epi64x(high_qw,
 				pkt->buf_iova + pkt->data_off);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm_store_si128((__m128i *)txdp, descriptor);
+__rte_diagnostic_pop
 }
 
 static inline void
drivers/net/iavf/iavf_rxtx_vec_avx2.c +16 -5
index 49d41af953..f5503d9dae 100644
@@ -6,10 +6,6 @@
 
 #include <rte_vect.h>
 
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
-
 static __rte_always_inline void
 iavf_rxq_rearm(struct iavf_rx_queue *rxq)
 {
@@ -193,6 +189,8 @@ _iavf_recv_raw_pkts_vec_avx2(struct iavf_rx_queue *rxq,
 			 _mm256_loadu_si256((void *)&sw_ring[i + 4]));
 #endif
 
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		const __m128i raw_desc7 = _mm_load_si128((void *)(rxdp + 7));
 		rte_compiler_barrier();
 		const __m128i raw_desc6 = _mm_load_si128((void *)(rxdp + 6));
@@ -208,6 +206,7 @@ _iavf_recv_raw_pkts_vec_avx2(struct iavf_rx_queue *rxq,
 		const __m128i raw_desc1 = _mm_load_si128((void *)(rxdp + 1));
 		rte_compiler_barrier();
 		const __m128i raw_desc0 = _mm_load_si128((void *)(rxdp + 0));
+__rte_diagnostic_pop
 
 		const __m256i raw_desc6_7 =
 			_mm256_inserti128_si256(_mm256_castsi128_si256(raw_desc6), raw_desc7, 1);
@@ -509,7 +508,7 @@ _iavf_recv_raw_pkts_vec_avx2_flex_rxd(struct iavf_rx_queue *rxq,
 			0, rxq->mbuf_initializer);
 	struct rte_mbuf **sw_ring = &rxq->sw_ring[rxq->rx_tail];
 	volatile union iavf_rx_flex_desc *rxdp =
-		(union iavf_rx_flex_desc *)rxq->rx_ring + rxq->rx_tail;
+		(volatile union iavf_rx_flex_desc *)rxq->rx_ring + rxq->rx_tail;
 
 	rte_prefetch0(rxdp);
 
@@ -742,6 +741,8 @@ _iavf_recv_raw_pkts_vec_avx2_flex_rxd(struct iavf_rx_queue *rxq,
 
 		__m256i raw_desc0_1, raw_desc2_3, raw_desc4_5, raw_desc6_7;
 
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		const __m128i raw_desc7 =
 			_mm_load_si128((void *)(rxdp + 7));
 		rte_compiler_barrier();
@@ -765,6 +766,7 @@ _iavf_recv_raw_pkts_vec_avx2_flex_rxd(struct iavf_rx_queue *rxq,
 		rte_compiler_barrier();
 		const __m128i raw_desc0 =
 			_mm_load_si128((void *)(rxdp + 0));
+__rte_diagnostic_pop
 
 		raw_desc6_7 =
 			_mm256_inserti128_si256
@@ -959,6 +961,8 @@ _iavf_recv_raw_pkts_vec_avx2_flex_rxd(struct iavf_rx_queue *rxq,
 				offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP ||
 			    rxq->rx_flags & IAVF_RX_FLAGS_VLAN_TAG_LOC_L2TAG2_2) {
 				/* load bottom half of every 32B desc */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				const __m128i raw_desc_bh7 =
 					_mm_load_si128
 						((void *)(&rxdp[7].wb.status_error1));
@@ -990,6 +994,7 @@ _iavf_recv_raw_pkts_vec_avx2_flex_rxd(struct iavf_rx_queue *rxq,
 				const __m128i raw_desc_bh0 =
 					_mm_load_si128
 						((void *)(&rxdp[0].wb.status_error1));
+__rte_diagnostic_pop
 
 				__m256i raw_desc_bh6_7 =
 					_mm256_inserti128_si256
@@ -1664,7 +1669,10 @@ iavf_vtx1(volatile struct iavf_tx_desc *txdp,
 
 	__m128i descriptor = _mm_set_epi64x(high_qw,
 				pkt->buf_iova + pkt->data_off);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm_store_si128((__m128i *)txdp, descriptor);
+__rte_diagnostic_pop
 }
 
 static __rte_always_inline void
@@ -1719,8 +1727,11 @@ iavf_vtx(volatile struct iavf_tx_desc *txdp,
 				 pkt[1]->buf_iova + pkt[1]->data_off,
 				 hi_qw0,
 				 pkt[0]->buf_iova + pkt[0]->data_off);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm256_store_si256((void *)(txdp + 2), desc2_3);
 		_mm256_store_si256((void *)txdp, desc0_1);
+__rte_diagnostic_pop
 	}
 
 	/* do any last ones */
drivers/net/iavf/iavf_rxtx_vec_avx512.c +22 -5
index d6a861bf80..04894debc8 100644
@@ -6,10 +6,6 @@
 
 #include <rte_vect.h>
 
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
-
 #define IAVF_DESCS_PER_LOOP_AVX 8
 #define PKTLEN_SHIFT 10
 
@@ -164,6 +160,8 @@ _iavf_recv_raw_pkts_vec_avx512(struct iavf_rx_queue *rxq,
 #endif
 
 		__m512i raw_desc0_3, raw_desc4_7;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		const __m128i raw_desc7 =
 			_mm_load_si128((void *)(rxdp + 7));
 		rte_compiler_barrier();
@@ -187,6 +185,7 @@ _iavf_recv_raw_pkts_vec_avx512(struct iavf_rx_queue *rxq,
 		rte_compiler_barrier();
 		const __m128i raw_desc0 =
 			_mm_load_si128((void *)(rxdp + 0));
+__rte_diagnostic_pop
 
 		raw_desc4_7 = _mm512_broadcast_i32x4(raw_desc4);
 		raw_desc4_7 = _mm512_inserti32x4(raw_desc4_7, raw_desc5, 1);
@@ -600,7 +599,7 @@ _iavf_recv_raw_pkts_vec_avx512_flex_rxd(struct iavf_rx_queue *rxq,
 						    rxq->mbuf_initializer);
 	struct rte_mbuf **sw_ring = &rxq->sw_ring[rxq->rx_tail];
 	volatile union iavf_rx_flex_desc *rxdp =
-		(union iavf_rx_flex_desc *)rxq->rx_ring + rxq->rx_tail;
+		(volatile union iavf_rx_flex_desc *)rxq->rx_ring + rxq->rx_tail;
 
 	rte_prefetch0(rxdp);
 
@@ -733,6 +732,8 @@ _iavf_recv_raw_pkts_vec_avx512_flex_rxd(struct iavf_rx_queue *rxq,
 
 		__m512i raw_desc0_3, raw_desc4_7;
 
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		const __m128i raw_desc7 =
 			_mm_load_si128((void *)(rxdp + 7));
 		rte_compiler_barrier();
@@ -756,6 +757,7 @@ _iavf_recv_raw_pkts_vec_avx512_flex_rxd(struct iavf_rx_queue *rxq,
 		rte_compiler_barrier();
 		const __m128i raw_desc0 =
 			_mm_load_si128((void *)(rxdp + 0));
+__rte_diagnostic_pop
 
 		raw_desc4_7 = _mm512_broadcast_i32x4(raw_desc4);
 		raw_desc4_7 = _mm512_inserti32x4(raw_desc4_7, raw_desc5, 1);
@@ -1111,6 +1113,8 @@ _iavf_recv_raw_pkts_vec_avx512_flex_rxd(struct iavf_rx_queue *rxq,
 				offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP ||
 			    rxq->rx_flags & IAVF_RX_FLAGS_VLAN_TAG_LOC_L2TAG2_2) {
 				/* load bottom half of every 32B desc */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				const __m128i raw_desc_bh7 =
 					_mm_load_si128
 						((void *)(&rxdp[7].wb.status_error1));
@@ -1142,6 +1146,7 @@ _iavf_recv_raw_pkts_vec_avx512_flex_rxd(struct iavf_rx_queue *rxq,
 				const __m128i raw_desc_bh0 =
 					_mm_load_si128
 						((void *)(&rxdp[0].wb.status_error1));
+__rte_diagnostic_pop
 
 				__m256i raw_desc_bh6_7 =
 					_mm256_inserti128_si256
@@ -1983,7 +1988,10 @@ iavf_vtx1(volatile struct iavf_tx_desc *txdp,
 
 	__m128i descriptor = _mm_set_epi64x(high_qw,
 					    pkt->buf_iova + pkt->data_off);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm_storeu_si128((__m128i *)txdp, descriptor);
+__rte_diagnostic_pop
 }
 
 #define IAVF_TX_LEN_MASK 0xAA
@@ -2037,7 +2045,10 @@ iavf_vtx(volatile struct iavf_tx_desc *txdp,
 				 pkt[1]->buf_iova + pkt[1]->data_off,
 				 hi_qw0,
 				 pkt[0]->buf_iova + pkt[0]->data_off);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm512_storeu_si512((void *)txdp, desc0_3);
+__rte_diagnostic_pop
 	}
 
 	/* do any last ones */
@@ -2225,7 +2236,10 @@ ctx_vtx1(volatile struct iavf_tx_desc *txdp, struct rte_mbuf *pkt,
 	__m256i ctx_data_desc = _mm256_set_epi64x(high_data_qw, pkt->buf_iova + pkt->data_off,
 							high_ctx_qw, low_ctx_qw);
 
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm256_storeu_si256((__m256i *)txdp, ctx_data_desc);
+__rte_diagnostic_pop
 }
 
 static __rte_always_inline void
@@ -2300,7 +2314,10 @@ ctx_vtx(volatile struct iavf_tx_desc *txdp,
 						hi_ctx_qw1, low_ctx_qw1,
 						hi_data_qw0, pkt[0]->buf_iova + pkt[0]->data_off,
 						hi_ctx_qw0, low_ctx_qw0);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm512_storeu_si512((void *)txdp, desc0_3);
+__rte_diagnostic_pop
 	}
 
 	if (nb_pkts)
drivers/net/iavf/iavf_rxtx_vec_common.h +6 -4
index 5c5220048d..690e0749e4 100644
@@ -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_t
 reassemble_packets(struct iavf_rx_queue *rxq, struct rte_mbuf **rx_bufs,
 		   uint16_t nb_bufs, uint8_t *split_flags)
@@ -422,8 +418,11 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				_mm_store_si128((__m128i *)&rxdp[i].read,
 						dma_addr0);
+__rte_diagnostic_pop
 			}
 		}
 		rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
@@ -458,8 +457,11 @@ 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 */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr0);
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr1);
+__rte_diagnostic_pop
 	}
 #else
 #ifdef CC_AVX512_SUPPORT
drivers/net/iavf/iavf_rxtx_vec_sse.c +25 -5
index 0db6fa8bd4..373df0c935 100644
@@ -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,8 +34,11 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				_mm_store_si128((__m128i *)&rxdp[i].read,
 						dma_addr0);
+__rte_diagnostic_pop
 			}
 		}
 		rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
@@ -69,8 +68,11 @@ iavf_rxq_rearm(struct iavf_rx_queue *rxq)
 		dma_addr1 = _mm_add_epi64(dma_addr1, hdr_room);
 
 		/* flush desc with pa dma_addr */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr0);
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr1);
+__rte_diagnostic_pop
 	}
 
 	rxq->rxrearm_start += rxq->rx_free_thresh;
@@ -578,7 +580,10 @@ _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] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs[3] = _mm_loadu_si128((__m128i *)(rxdp + 3));
+__rte_diagnostic_pop
 		rte_compiler_barrier();
 
 		/* B.2 copy 2 64 bit or 4 32 bit mbuf point into rx_pkts */
@@ -590,11 +595,14 @@ _recv_raw_pkts_vec(struct iavf_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 #endif
 
 		/* A.1 load desc[2-0] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs[2] = _mm_loadu_si128((__m128i *)(rxdp + 2));
 		rte_compiler_barrier();
 		descs[1] = _mm_loadu_si128((__m128i *)(rxdp + 1));
 		rte_compiler_barrier();
 		descs[0] = _mm_loadu_si128((__m128i *)(rxdp));
+__rte_diagnostic_pop
 
 #if defined(RTE_ARCH_X86_64)
 		/* B.2 copy 2 mbuf point into rx_pkts  */
@@ -783,7 +791,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 +872,10 @@ _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] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs[3] = _mm_loadu_si128((__m128i *)(rxdp + 3));
+__rte_diagnostic_pop
 		rte_compiler_barrier();
 
 		/* B.2 copy 2 64 bit or 4 32 bit mbuf point into rx_pkts */
@@ -876,11 +887,14 @@ _recv_raw_pkts_vec_flex_rxd(struct iavf_rx_queue *rxq,
 #endif
 
 		/* A.1 load desc[2-0] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs[2] = _mm_loadu_si128((__m128i *)(rxdp + 2));
 		rte_compiler_barrier();
 		descs[1] = _mm_loadu_si128((__m128i *)(rxdp + 1));
 		rte_compiler_barrier();
 		descs[0] = _mm_loadu_si128((__m128i *)(rxdp));
+__rte_diagnostic_pop
 
 #if defined(RTE_ARCH_X86_64)
 		/* B.2 copy 2 mbuf point into rx_pkts  */
@@ -927,6 +941,8 @@ _recv_raw_pkts_vec_flex_rxd(struct iavf_rx_queue *rxq,
 			offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP ||
 			rxq->rx_flags & IAVF_RX_FLAGS_VLAN_TAG_LOC_L2TAG2_2) {
 			/* load bottom half of every 32B desc */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 			descs_bh[3] = _mm_load_si128
 					((void *)(&rxdp[3].wb.status_error1));
 			rte_compiler_barrier();
@@ -938,6 +954,7 @@ _recv_raw_pkts_vec_flex_rxd(struct iavf_rx_queue *rxq,
 			rte_compiler_barrier();
 			descs_bh[0] = _mm_load_si128
 					((void *)(&rxdp[0].wb.status_error1));
+__rte_diagnostic_pop
 		}
 
 		if (offloads & RTE_ETH_RX_OFFLOAD_RSS_HASH) {
@@ -1349,7 +1366,10 @@ 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);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm_store_si128((__m128i *)txdp, descriptor);
+__rte_diagnostic_pop
 }
 
 static inline void
drivers/net/ice/ice_rxtx_common_avx.h +6 -4
index dacb87dcb0..b9cb1f5279 100644
@@ -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,8 +29,11 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				_mm_store_si128((__m128i *)&rxdp[i].read,
 						dma_addr0);
+__rte_diagnostic_pop
 			}
 		}
 		rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
@@ -77,8 +76,11 @@ 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 */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr0);
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr1);
+__rte_diagnostic_pop
 	}
 #else
 #ifdef __AVX512VL__
drivers/net/ice/ice_rxtx_vec_avx2.c +12 -4
index d6e88dbb29..6c6a810a15 100644
@@ -7,10 +7,6 @@
 
 #include <rte_vect.h>
 
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
-
 static __rte_always_inline void
 ice_rxq_rearm(struct ice_rx_queue *rxq)
 {
@@ -254,6 +250,8 @@ _ice_recv_raw_pkts_vec_avx2(struct ice_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 			 _mm256_loadu_si256((void *)&sw_ring[i + 4]));
 #endif
 
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		const __m128i raw_desc7 = _mm_load_si128((void *)(rxdp + 7));
 		rte_compiler_barrier();
 		const __m128i raw_desc6 = _mm_load_si128((void *)(rxdp + 6));
@@ -269,6 +267,7 @@ _ice_recv_raw_pkts_vec_avx2(struct ice_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 		const __m128i raw_desc1 = _mm_load_si128((void *)(rxdp + 1));
 		rte_compiler_barrier();
 		const __m128i raw_desc0 = _mm_load_si128((void *)(rxdp + 0));
+__rte_diagnostic_pop
 
 		const __m256i raw_desc6_7 =
 			_mm256_inserti128_si256(_mm256_castsi128_si256(raw_desc6), raw_desc7, 1);
@@ -444,6 +443,8 @@ _ice_recv_raw_pkts_vec_avx2(struct ice_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 			if (rxq->vsi->adapter->pf.dev_data->dev_conf.rxmode.offloads &
 					RTE_ETH_RX_OFFLOAD_RSS_HASH) {
 				/* load bottom half of every 32B desc */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				const __m128i raw_desc_bh7 =
 					_mm_load_si128
 						((void *)(&rxdp[7].wb.status_error1));
@@ -475,6 +476,7 @@ _ice_recv_raw_pkts_vec_avx2(struct ice_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 				const __m128i raw_desc_bh0 =
 					_mm_load_si128
 						((void *)(&rxdp[0].wb.status_error1));
+__rte_diagnostic_pop
 
 				__m256i raw_desc_bh6_7 =
 					_mm256_inserti128_si256
@@ -790,7 +792,10 @@ ice_vtx1(volatile struct ice_tx_desc *txdp,
 		ice_txd_enable_offload(pkt, &high_qw);
 
 	__m128i descriptor = _mm_set_epi64x(high_qw, rte_pktmbuf_iova(pkt));
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm_store_si128((__m128i *)txdp, descriptor);
+__rte_diagnostic_pop
 }
 
 static __rte_always_inline void
@@ -841,8 +846,11 @@ ice_vtx(volatile struct ice_tx_desc *txdp,
 			_mm256_set_epi64x
 				(hi_qw1, rte_pktmbuf_iova(pkt[1]),
 				 hi_qw0, rte_pktmbuf_iova(pkt[0]));
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm256_store_si256((void *)(txdp + 2), desc2_3);
 		_mm256_store_si256((void *)txdp, desc0_1);
+__rte_diagnostic_pop
 	}
 
 	/* do any last ones */
drivers/net/ice/ice_rxtx_vec_avx512.c +12 -4
index add095ef06..5a774550dc 100644
@@ -7,10 +7,6 @@
 
 #include <rte_vect.h>
 
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
-
 #define ICE_DESCS_PER_LOOP_AVX 8
 
 static __rte_always_inline void
@@ -243,6 +239,8 @@ _ice_recv_raw_pkts_vec_avx512(struct ice_rx_queue *rxq,
 		__m256i raw_desc0_1, raw_desc2_3, raw_desc4_5, raw_desc6_7;
 
 		/* load in descriptors, in reverse order */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		const __m128i raw_desc7 =
 			_mm_load_si128((void *)(rxdp + 7));
 		rte_compiler_barrier();
@@ -266,6 +264,7 @@ _ice_recv_raw_pkts_vec_avx512(struct ice_rx_queue *rxq,
 		rte_compiler_barrier();
 		const __m128i raw_desc0 =
 			_mm_load_si128((void *)(rxdp + 0));
+__rte_diagnostic_pop
 
 		raw_desc6_7 =
 			_mm256_inserti128_si256
@@ -474,6 +473,8 @@ _ice_recv_raw_pkts_vec_avx512(struct ice_rx_queue *rxq,
 			if (rxq->vsi->adapter->pf.dev_data->dev_conf.rxmode.offloads &
 					RTE_ETH_RX_OFFLOAD_RSS_HASH) {
 				/* load bottom half of every 32B desc */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				const __m128i raw_desc_bh7 =
 					_mm_load_si128
 						((void *)(&rxdp[7].wb.status_error1));
@@ -505,6 +506,7 @@ _ice_recv_raw_pkts_vec_avx512(struct ice_rx_queue *rxq,
 				const __m128i raw_desc_bh0 =
 					_mm_load_si128
 						((void *)(&rxdp[0].wb.status_error1));
+__rte_diagnostic_pop
 
 				__m256i raw_desc_bh6_7 =
 					_mm256_inserti128_si256
@@ -987,7 +989,10 @@ ice_vtx1(volatile struct ice_tx_desc *txdp,
 		ice_txd_enable_offload(pkt, &high_qw);
 
 	__m128i descriptor = _mm_set_epi64x(high_qw, rte_pktmbuf_iova(pkt));
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm_store_si128((__m128i *)txdp, descriptor);
+__rte_diagnostic_pop
 }
 
 static __rte_always_inline void
@@ -1029,7 +1034,10 @@ ice_vtx(volatile struct ice_tx_desc *txdp, struct rte_mbuf **pkt,
 				 hi_qw2, rte_pktmbuf_iova(pkt[2]),
 				 hi_qw1, rte_pktmbuf_iova(pkt[1]),
 				 hi_qw0, rte_pktmbuf_iova(pkt[0]));
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm512_storeu_si512((void *)txdp, desc0_3);
+__rte_diagnostic_pop
 	}
 
 	/* do any last ones */
drivers/net/ice/ice_rxtx_vec_common.h +0 -4
index 4b73465af5..45147decff 100644
@@ -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 +18 -4
index c01d8ede29..f2991cee1a 100644
@@ -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,8 +48,11 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				_mm_store_si128((__m128i *)&rxdp[i].read,
 						dma_addr0);
+__rte_diagnostic_pop
 			}
 		}
 		rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
@@ -91,8 +90,11 @@ ice_rxq_rearm(struct ice_rx_queue *rxq)
 		dma_addr1 = _mm_add_epi64(dma_addr1, hdr_room);
 
 		/* flush desc with pa dma_addr */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr0);
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr1);
+__rte_diagnostic_pop
 	}
 
 	rxq->rxrearm_start += ICE_RXQ_REARM_THRESH;
@@ -425,7 +427,10 @@ _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] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs[3] = _mm_loadu_si128((__m128i *)(rxdp + 3));
+__rte_diagnostic_pop
 		rte_compiler_barrier();
 
 		/* B.2 copy 2 64 bit or 4 32 bit mbuf point into rx_pkts */
@@ -437,11 +442,14 @@ _ice_recv_raw_pkts_vec(struct ice_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 #endif
 
 		/* A.1 load desc[2-0] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs[2] = _mm_loadu_si128((__m128i *)(rxdp + 2));
 		rte_compiler_barrier();
 		descs[1] = _mm_loadu_si128((__m128i *)(rxdp + 1));
 		rte_compiler_barrier();
 		descs[0] = _mm_loadu_si128((__m128i *)(rxdp));
+__rte_diagnostic_pop
 
 #if defined(RTE_ARCH_X86_64)
 		/* B.2 copy 2 mbuf point into rx_pkts  */
@@ -489,6 +497,8 @@ _ice_recv_raw_pkts_vec(struct ice_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 		if (rxq->vsi->adapter->pf.dev_data->dev_conf.rxmode.offloads &
 				RTE_ETH_RX_OFFLOAD_RSS_HASH) {
 			/* load bottom half of every 32B desc */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 			const __m128i raw_desc_bh3 =
 				_mm_load_si128
 					((void *)(&rxdp[3].wb.status_error1));
@@ -504,6 +514,7 @@ _ice_recv_raw_pkts_vec(struct ice_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 			const __m128i raw_desc_bh0 =
 				_mm_load_si128
 					((void *)(&rxdp[0].wb.status_error1));
+__rte_diagnostic_pop
 
 			/**
 			 * to shift the 32b RSS hash value to the
@@ -680,7 +691,10 @@ 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));
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm_store_si128((__m128i *)txdp, descriptor);
+__rte_diagnostic_pop
 }
 
 static inline void
drivers/net/idpf/idpf_rxtx_vec_common.h +0 -4
index 2787d27616..002c1e6948 100644
@@ -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
index d451562269..92a89f8def 100644
@@ -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 +0 -2
index 952b032eb6..4e7a64b39f 100644
@@ -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)
 {
drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c +15 -4
index a77370cdb7..8e4048a32f 100644
@@ -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,8 +37,11 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				_mm_store_si128((__m128i *)&rxdp[i].read,
 						dma_addr0);
+__rte_diagnostic_pop
 			}
 		}
 		rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
@@ -76,8 +75,11 @@ ixgbe_rxq_rearm(struct ixgbe_rx_queue *rxq)
 		dma_addr1 =  _mm_and_si128(dma_addr1, hba_msk);
 
 		/* flush desc with pa dma_addr */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr0);
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr1);
+__rte_diagnostic_pop
 	}
 
 	rxq->rxrearm_start += RTE_IXGBE_RXQ_REARM_THRESH;
@@ -466,7 +468,10 @@ _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] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs[3] = _mm_loadu_si128((__m128i *)(rxdp + 3));
+__rte_diagnostic_pop
 		rte_compiler_barrier();
 
 		/* B.2 copy 2 64 bit or 4 32 bit mbuf point into rx_pkts */
@@ -478,11 +483,14 @@ _recv_raw_pkts_vec(struct ixgbe_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 #endif
 
 		/* A.1 load desc[2-0] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs[2] = _mm_loadu_si128((__m128i *)(rxdp + 2));
 		rte_compiler_barrier();
 		descs[1] = _mm_loadu_si128((__m128i *)(rxdp + 1));
 		rte_compiler_barrier();
 		descs[0] = _mm_loadu_si128((__m128i *)(rxdp));
+__rte_diagnostic_pop
 
 #if defined(RTE_ARCH_X86_64)
 		/* B.2 copy 2 mbuf point into rx_pkts  */
@@ -676,7 +684,10 @@ 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);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm_store_si128((__m128i *)&txdp->read, descriptor);
+__rte_diagnostic_pop
 }
 
 static inline void
drivers/net/mlx5/mlx5_flow.c +3 -3
index 16ddd05448..0a89d2c414 100644
@@ -7287,10 +7287,10 @@ flow_tunnel_from_rule(const struct mlx5_flow *flow)
 {
 	struct mlx5_flow_tunnel *tunnel;
 
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wcast-qual"
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	tunnel = (typeof(tunnel))flow->tunnel;
-#pragma GCC diagnostic pop
+__rte_diagnostic_pop
 
 	return tunnel;
 }
drivers/net/mlx5/mlx5_rxtx_vec_altivec.h +0 -5
index 240987d03d..b37483bcca 100644
@@ -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 +0 -2
index dc1d30753d..e7deacc1fb 100644
@@ -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.
  *
drivers/net/mlx5/mlx5_rxtx_vec_sse.h +19 -7
index 81a177fce7..f4d08d5b30 100644
@@ -24,10 +24,6 @@
 #include "mlx5_rxtx_vec.h"
 #include "mlx5_autoconf.h"
 
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
-
 /**
  * Store free buffers to RX SW ring.
  *
@@ -75,7 +71,8 @@ static inline uint16_t
 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);
+	volatile struct mlx5_mini_cqe8 *mcq =
+		(volatile void *)(cq + !rxq->cqe_comp_layout);
 	/* Title packet is pre-built. */
 	struct rte_mbuf *t_pkt = rxq->cqe_comp_layout ? &rxq->title_pkt : elts[0];
 	unsigned int pos;
@@ -129,8 +126,11 @@ rxq_cq_decompress_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq,
 	 * E. store flow tag (rte_flow mark).
 	 */
 cycle:
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	if (rxq->cqe_comp_layout)
 		rte_prefetch0((void *)(cq + mcqe_n));
+__rte_diagnostic_pop
 	for (pos = 0; pos < mcqe_n; ) {
 		__m128i mcqe1, mcqe2;
 		__m128i rxdf1, rxdf2;
@@ -138,6 +138,8 @@ rxq_cq_decompress_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq,
 		__m128i byte_cnt, invalid_mask;
 #endif
 
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		if (!rxq->cqe_comp_layout)
 			for (i = 0; i < MLX5_VPMD_DESCS_PER_LOOP; ++i)
 				if (likely(pos + i < mcqe_n))
@@ -145,6 +147,7 @@ rxq_cq_decompress_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq,
 		/* A.1 load mCQEs into a 128bit register. */
 		mcqe1 = _mm_loadu_si128((__m128i *)&mcq[pos % 8]);
 		mcqe2 = _mm_loadu_si128((__m128i *)&mcq[pos % 8 + 2]);
+__rte_diagnostic_pop
 		/* B.1 store rearm data to mbuf. */
 		_mm_storeu_si128((__m128i *)&elts[pos]->rearm_data, rearm);
 		_mm_storeu_si128((__m128i *)&elts[pos + 1]->rearm_data, rearm);
@@ -354,9 +357,12 @@ rxq_cq_decompress_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq,
 		/* Move to next CQE and invalidate consumed CQEs. */
 		if (!rxq->cqe_comp_layout) {
 			if (!(pos & 0x7) && pos < mcqe_n) {
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				if (pos + 8 < mcqe_n)
 					rte_prefetch0((void *)(cq + pos + 8));
-				mcq = (void *)(cq + pos);
+__rte_diagnostic_pop
+				mcq = (volatile void *)(cq + pos);
 				for (i = 0; i < 8; ++i)
 					cq[inv++].op_own = MLX5_CQE_INVALIDATE;
 			}
@@ -371,7 +377,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 void *)cq;
 			mcqe_n = MLX5_CQE_NUM_MINIS(cq->op_own) + 1;
 			pkts_n += mcqe_n;
 			goto cycle;
@@ -651,6 +657,8 @@ rxq_cq_process_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq,
 		p = _mm_andnot_si128(mask, p);
 		/* A.1 load cqes. */
 		p3 = _mm_extract_epi16(p, 3);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		cqes[3] = _mm_loadl_epi64((__m128i *)
 					   &cq[pos + p3].sop_drop_qpn);
 		rte_compiler_barrier();
@@ -683,6 +691,7 @@ rxq_cq_process_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq,
 		cqes[2] = _mm_blend_epi16(cqes[2], cqe_tmp1, 0x30);
 		cqe_tmp2 = _mm_loadl_epi64((__m128i *)&cq[pos + p3].rsvd4[2]);
 		cqe_tmp1 = _mm_loadl_epi64((__m128i *)&cq[pos + p2].rsvd4[2]);
+__rte_diagnostic_pop
 		cqes[3] = _mm_blend_epi16(cqes[3], cqe_tmp2, 0x04);
 		cqes[2] = _mm_blend_epi16(cqes[2], cqe_tmp1, 0x04);
 		/* C.2 generate final structure for mbuf with swapping bytes. */
@@ -700,6 +709,8 @@ rxq_cq_process_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq,
 		/* E.1 extract op_own field. */
 		op_own_tmp2 = _mm_unpacklo_epi32(cqes[2], cqes[3]);
 		/* C.1 load remained CQE data and extract necessary fields. */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		cqe_tmp2 = _mm_load_si128((__m128i *)&cq[pos + p1]);
 		cqe_tmp1 = _mm_load_si128((__m128i *)&cq[pos]);
 		cqes[1] = _mm_blendv_epi8(cqes[1], cqe_tmp2, blend_mask);
@@ -710,6 +721,7 @@ rxq_cq_process_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq,
 		cqes[0] = _mm_blend_epi16(cqes[0], cqe_tmp1, 0x30);
 		cqe_tmp2 = _mm_loadl_epi64((__m128i *)&cq[pos + p1].rsvd4[2]);
 		cqe_tmp1 = _mm_loadl_epi64((__m128i *)&cq[pos].rsvd4[2]);
+__rte_diagnostic_pop
 		cqes[1] = _mm_blend_epi16(cqes[1], cqe_tmp2, 0x04);
 		cqes[0] = _mm_blend_epi16(cqes[0], cqe_tmp1, 0x04);
 		/* C.2 generate final structure for mbuf with swapping bytes. */
drivers/net/tap/tap_flow.c +3 -3
index c0e44bb1a7..373b773e2d 100644
@@ -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/virtio/virtio_rxtx_simple.c +0 -4
index 438256970d..439e00a7e1 100644
@@ -23,10 +23,6 @@
 
 #include "virtio_rxtx_simple.h"
 
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
-
 int __rte_cold
 virtio_rxq_vec_setup(struct virtnet_rx *rxq)
 {
Signature · 1 line
2.47.0.vfs.0.3
#14 lore raw

v4 cover add diagnostics macros to make code portable

In reply to Andre Muezerie

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.

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):
lib/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 | 46 +++++++++++++++++--
 drivers/net/axgbe/axgbe_rxtx.h                |  9 ----
 drivers/net/cpfl/cpfl_rxtx_vec_common.h       |  4 --
 drivers/net/dpaa2/dpaa2_rxtx.c                | 16 ++-----
 drivers/net/fm10k/fm10k_rxtx_vec.c            | 19 ++++++--
 drivers/net/hns3/hns3_rxtx_vec_neon.h         |  5 +-
 .../net/i40e/i40e_recycle_mbufs_vec_common.c  |  2 -
 drivers/net/i40e/i40e_rxtx_common_avx.h       | 16 +++++--
 drivers/net/i40e/i40e_rxtx_vec_altivec.c      | 17 ++++++-
 drivers/net/i40e/i40e_rxtx_vec_avx2.c         | 16 +++++--
 drivers/net/i40e/i40e_rxtx_vec_avx512.c       | 16 +++++--
 drivers/net/i40e/i40e_rxtx_vec_common.h       |  4 --
 drivers/net/i40e/i40e_rxtx_vec_neon.c         | 15 ++++--
 drivers/net/i40e/i40e_rxtx_vec_sse.c          | 22 +++++++--
 drivers/net/iavf/iavf_rxtx_vec_avx2.c         | 21 +++++++--
 drivers/net/iavf/iavf_rxtx_vec_avx512.c       | 27 +++++++++--
 drivers/net/iavf/iavf_rxtx_vec_common.h       | 10 ++--
 drivers/net/iavf/iavf_rxtx_vec_sse.c          | 30 ++++++++++--
 drivers/net/ice/ice_rxtx_common_avx.h         | 16 +++++--
 drivers/net/ice/ice_rxtx_vec_avx2.c           | 16 +++++--
 drivers/net/ice/ice_rxtx_vec_avx512.c         | 16 +++++--
 drivers/net/ice/ice_rxtx_vec_common.h         |  4 --
 drivers/net/ice/ice_rxtx_vec_sse.c            | 22 +++++++--
 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       |  2 -
 drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c        | 19 ++++++--
 drivers/net/mlx5/mlx5_flow.c                  |  6 +--
 drivers/net/mlx5/mlx5_rxtx_vec_altivec.h      |  5 --
 drivers/net/mlx5/mlx5_rxtx_vec_neon.h         |  2 -
 drivers/net/mlx5/mlx5_rxtx_vec_sse.h          | 26 ++++++++---
 drivers/net/tap/tap_flow.c                    |  6 +--
 drivers/net/virtio/virtio_rxtx_simple.c       |  4 --
 lib/eal/include/rte_common.h                  | 23 ++++++++++
 34 files changed, 330 insertions(+), 138 deletions(-)

--
2.47.0.vfs.0.3

#15 lore raw

PATCH v4 1/3 lib/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 | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
lib/eal/include/rte_common.h +23 -0
index 4d299f2b36..13b7b92f46 100644
@@ -137,6 +137,29 @@ typedef uint16_t unaligned_uint16_t;
 #define RTE_DEPRECATED(x)
 #endif
 
+/*
+ * Macro to ignore whenever a pointer is cast so as to remove 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
+
+/*
+ * 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
+
 /**
  * Mark a function or variable to a weak reference.
  */
Signature · 1 line
2.47.0.vfs.0.3
#16 lore raw

PATCH v4 2/3 drivers/common: add diagnostics macros to make code portable

In reply to Andre Muezerie

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.

---
 drivers/common/idpf/idpf_common_rxtx_avx512.c | 46 +++++++++++++++++--
 1 file changed, 42 insertions(+), 4 deletions(-)
drivers/common/idpf/idpf_common_rxtx_avx512.c +42 -4
index b8450b03ae..37cd0a43e2 100644
@@ -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,8 +30,11 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				_mm_store_si128((__m128i *)&rxdp[i].read,
 						dma_addr0);
+__rte_diagnostic_pop
 			}
 		}
 		rte_atomic_fetch_add_explicit(&rxq->rx_stats.mbuf_alloc_failed,
@@ -108,8 +107,11 @@ 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 */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm512_store_si512((__m512i *)&rxdp->read, dma_addr0_3);
 		_mm512_store_si512((__m512i *)&(rxdp + 4)->read, dma_addr4_7);
+__rte_diagnostic_pop
 	}
 
 	rxq->rxrearm_start += IDPF_RXQ_REARM_THRESH;
@@ -164,8 +166,11 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 					_mm_storeu_si128((__m128i *)&rxdp[i].read,
 							 dma_addr0);
+__rte_diagnostic_pop
 				}
 			}
 			rte_atomic_fetch_add_explicit(&rxq->rx_stats.mbuf_alloc_failed,
@@ -216,10 +221,13 @@ idpf_singleq_rearm(struct idpf_rx_queue *rxq)
 				 iovas1);
 		const __m512i desc6_7 = _mm512_bsrli_epi128(desc4_5, 8);
 
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_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);
+__rte_diagnostic_pop
 
 		rxp += IDPF_DESCS_PER_LOOP_AVX;
 		rxdp += IDPF_DESCS_PER_LOOP_AVX;
@@ -336,6 +344,8 @@ _idpf_singleq_recv_raw_pkts_avx512(struct idpf_rx_queue *rxq,
 #endif
 
 		__m512i raw_desc0_3, raw_desc4_7;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		const __m128i raw_desc7 =
 			_mm_load_si128((void *)(rxdp + 7));
 		rte_compiler_barrier();
@@ -359,6 +369,7 @@ _idpf_singleq_recv_raw_pkts_avx512(struct idpf_rx_queue *rxq,
 		rte_compiler_barrier();
 		const __m128i raw_desc0 =
 			_mm_load_si128((void *)(rxdp + 0));
+__rte_diagnostic_pop
 
 		raw_desc4_7 = _mm512_broadcast_i32x4(raw_desc4);
 		raw_desc4_7 = _mm512_inserti32x4(raw_desc4_7, raw_desc5, 1);
@@ -560,8 +571,11 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				_mm_store_si128((__m128i *)&rxdp[i],
 						dma_addr0);
+__rte_diagnostic_pop
 			}
 		}
 	rte_atomic_fetch_add_explicit(&rx_bufq->rx_stats.mbuf_alloc_failed,
@@ -634,8 +648,11 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 					_mm_storeu_si128((__m128i *)&rxdp[i],
 							 dma_addr0);
+__rte_diagnostic_pop
 				}
 			}
 		rte_atomic_fetch_add_explicit(&rx_bufq->rx_stats.mbuf_alloc_failed,
@@ -797,6 +814,8 @@ _idpf_splitq_recv_raw_pkts_avx512(struct idpf_rx_queue *rxq,
 #endif
 
 		__m512i raw_desc0_3, raw_desc4_7;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		const __m128i raw_desc7 =
 			_mm_load_si128((void *)(rxdp + 7));
 		rte_compiler_barrier();
@@ -820,6 +839,7 @@ _idpf_splitq_recv_raw_pkts_avx512(struct idpf_rx_queue *rxq,
 		rte_compiler_barrier();
 		const __m128i raw_desc0 =
 			_mm_load_si128((void *)(rxdp + 0));
+__rte_diagnostic_pop
 
 		raw_desc4_7 = _mm512_broadcast_i32x4(raw_desc4);
 		raw_desc4_7 = _mm512_inserti32x4(raw_desc4_7, raw_desc5, 1);
@@ -1131,7 +1151,10 @@ idpf_singleq_vtx1(volatile struct idpf_base_tx_desc *txdp,
 
 	__m128i descriptor = _mm_set_epi64x(high_qw,
 					    pkt->buf_iova + pkt->data_off);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm_storeu_si128((__m128i *)txdp, descriptor);
+__rte_diagnostic_pop
 }
 
 #define IDPF_TX_LEN_MASK 0xAA
@@ -1178,7 +1201,10 @@ 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);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm512_storeu_si512((void *)txdp, desc0_3);
+__rte_diagnostic_pop
 	}
 
 	/* do any last ones */
@@ -1435,7 +1461,10 @@ idpf_splitq_vtx1(volatile struct idpf_flex_tx_sched_desc *txdp,
 
 	__m128i descriptor = _mm_set_epi64x(high_qw,
 					    pkt->buf_iova + pkt->data_off);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm_storeu_si128((__m128i *)txdp, descriptor);
+__rte_diagnostic_pop
 }
 
 static __rte_always_inline void
@@ -1480,7 +1509,10 @@ 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);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm512_storeu_si512((void *)txdp, desc0_3);
+__rte_diagnostic_pop
 	}
 
 	/* do any last ones */
@@ -1521,11 +1553,14 @@ idpf_splitq_xmit_fixed_burst_vec_avx512(void *tx_queue, struct rte_mbuf **tx_pkt
 	if (nb_commit >= n) {
 		tx_backlog_entry_avx512(txep, tx_pkts, n);
 
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		idpf_splitq_vtx((void *)txdp, tx_pkts, n - 1, cmd_dtype);
 		tx_pkts += (n - 1);
 		txdp += (n - 1);
 
 		idpf_splitq_vtx1((void *)txdp, *tx_pkts++, cmd_dtype);
+__rte_diagnostic_pop
 
 		nb_commit = (uint16_t)(nb_commit - n);
 
@@ -1540,7 +1575,10 @@ idpf_splitq_xmit_fixed_burst_vec_avx512(void *tx_queue, struct rte_mbuf **tx_pkt
 
 	tx_backlog_entry_avx512(txep, tx_pkts, nb_commit);
 
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	idpf_splitq_vtx((void *)txdp, tx_pkts, nb_commit, cmd_dtype);
+__rte_diagnostic_pop
 
 	tx_id = (uint16_t)(tx_id + nb_commit);
 	if (tx_id > txq->next_rs)
Signature · 1 line
2.47.0.vfs.0.3
#17 lore raw

PATCH v4 3/3 drivers/net: add diagnostics macros to make code portable

In reply to Andre Muezerie

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.

---
 drivers/net/axgbe/axgbe_rxtx.h                |  9 ------
 drivers/net/cpfl/cpfl_rxtx_vec_common.h       |  4 ---
 drivers/net/dpaa2/dpaa2_rxtx.c                | 16 ++--------
 drivers/net/fm10k/fm10k_rxtx_vec.c            | 19 +++++++++---
 drivers/net/hns3/hns3_rxtx_vec_neon.h         |  5 ++--
 .../net/i40e/i40e_recycle_mbufs_vec_common.c  |  2 --
 drivers/net/i40e/i40e_rxtx_common_avx.h       | 16 +++++++---
 drivers/net/i40e/i40e_rxtx_vec_altivec.c      | 17 +++++++++--
 drivers/net/i40e/i40e_rxtx_vec_avx2.c         | 16 +++++++---
 drivers/net/i40e/i40e_rxtx_vec_avx512.c       | 16 +++++++---
 drivers/net/i40e/i40e_rxtx_vec_common.h       |  4 ---
 drivers/net/i40e/i40e_rxtx_vec_neon.c         | 15 ++++++++--
 drivers/net/i40e/i40e_rxtx_vec_sse.c          | 22 +++++++++++---
 drivers/net/iavf/iavf_rxtx_vec_avx2.c         | 21 +++++++++----
 drivers/net/iavf/iavf_rxtx_vec_avx512.c       | 27 +++++++++++++----
 drivers/net/iavf/iavf_rxtx_vec_common.h       | 10 ++++---
 drivers/net/iavf/iavf_rxtx_vec_sse.c          | 30 +++++++++++++++----
 drivers/net/ice/ice_rxtx_common_avx.h         | 16 +++++++---
 drivers/net/ice/ice_rxtx_vec_avx2.c           | 16 +++++++---
 drivers/net/ice/ice_rxtx_vec_avx512.c         | 16 +++++++---
 drivers/net/ice/ice_rxtx_vec_common.h         |  4 ---
 drivers/net/ice/ice_rxtx_vec_sse.c            | 22 +++++++++++---
 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       |  2 --
 drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c        | 19 +++++++++---
 drivers/net/mlx5/mlx5_flow.c                  |  6 ++--
 drivers/net/mlx5/mlx5_rxtx_vec_altivec.h      |  5 ----
 drivers/net/mlx5/mlx5_rxtx_vec_neon.h         |  2 --
 drivers/net/mlx5/mlx5_rxtx_vec_sse.h          | 26 +++++++++++-----
 drivers/net/tap/tap_flow.c                    |  6 ++--
 drivers/net/virtio/virtio_rxtx_simple.c       |  4 ---
 32 files changed, 265 insertions(+), 134 deletions(-)
drivers/net/axgbe/axgbe_rxtx.h +0 -9
index a326ba9ac8..f5f74a0a39 100644
@@ -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
index 479e1ddcb9..5b98f86932 100644
@@ -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 +3 -13
index e3b6c7e460..21c306fd94 100644
@@ -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,10 @@ dpaa2_dev_loopback_rx(void *queue,
 			if (unlikely((status & QBMAN_DQ_STAT_VALIDFRAME) == 0))
 				continue;
 		}
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		fd[num_rx] = (struct qbman_fd *)qbman_result_DQ_fd(dq_storage);
+__rte_diagnostic_pop
 
 		dq_storage++;
 		num_rx++;
@@ -2118,8 +2113,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 +15 -4
index 68acaca75b..3d534a91ac 100644
@@ -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,11 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 			_mm_store_si128((__m128i *)&rxdp[i].q,
 						dma_addr0);
+__rte_diagnostic_pop
 		}
 
 		rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
@@ -316,8 +315,11 @@ fm10k_rxq_rearm(struct fm10k_rx_queue *rxq)
 		dma_addr1 = _mm_and_si128(dma_addr1, hba_msk);
 
 		/* flush desc with pa dma_addr */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm_store_si128((__m128i *)&rxdp++->q, dma_addr0);
 		_mm_store_si128((__m128i *)&rxdp++->q, dma_addr1);
+__rte_diagnostic_pop
 
 		/* enforce 512B alignment on default Rx virtual addresses */
 		mb0->data_off = (uint16_t)(RTE_PTR_ALIGN((char *)mb0->buf_addr
@@ -465,7 +467,10 @@ 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] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs0[3] = _mm_loadu_si128((__m128i *)(rxdp + 3));
+__rte_diagnostic_pop
 		rte_compiler_barrier();
 
 		/* B.2 copy 2 64 bit or 4 32 bit mbuf point into rx_pkts */
@@ -477,11 +482,14 @@ fm10k_recv_raw_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
 #endif
 
 		/* A.1 load desc[2-0] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs0[2] = _mm_loadu_si128((__m128i *)(rxdp + 2));
 		rte_compiler_barrier();
 		descs0[1] = _mm_loadu_si128((__m128i *)(rxdp + 1));
 		rte_compiler_barrier();
 		descs0[0] = _mm_loadu_si128((__m128i *)(rxdp));
+__rte_diagnostic_pop
 
 #if defined(RTE_ARCH_X86_64)
 		/* B.2 copy 2 mbuf point into rx_pkts  */
@@ -736,7 +744,10 @@ 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));
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm_store_si128((__m128i *)txdp, descriptor);
+__rte_diagnostic_pop
 }
 
 static inline void
drivers/net/hns3/hns3_rxtx_vec_neon.h +3 -2
index bbb5478015..99f080f3e8 100644
@@ -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,11 @@ hns3_vec_tx(volatile struct hns3_desc *desc, struct rte_mbuf *pkt)
 		0,
 		((uint64_t)HNS3_TXD_DEFAULT_VLD_FE_BDTYPE) << HNS3_UINT32_BIT
 	};
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	vst1q_u64((uint64_t *)&desc->addr, val1);
 	vst1q_u64((uint64_t *)&desc->tx.outer_vlan_tag, val2);
+__rte_diagnostic_pop
 }
 
 static uint16_t
drivers/net/i40e/i40e_recycle_mbufs_vec_common.c +0 -2
index 14424c9921..6eafe51e3d 100644
@@ -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 +12 -4
index 85958d6c81..bcabacf689 100644
@@ -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,8 +32,11 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				_mm_store_si128((__m128i *)&rxdp[i].read,
 						dma_addr0);
+__rte_diagnostic_pop
 			}
 		}
 		rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
@@ -72,8 +71,11 @@ 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 */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr0);
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr1);
+__rte_diagnostic_pop
 	}
 #else
 #ifdef __AVX512VL__
@@ -144,8 +146,11 @@ 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 */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 			_mm512_store_si512((__m512i *)&rxdp->read, dma_addr0_3);
 			_mm512_store_si512((__m512i *)&(rxdp + 4)->read, dma_addr4_7);
+__rte_diagnostic_pop
 		}
 	} else
 #endif /* __AVX512VL__*/
@@ -190,8 +195,11 @@ 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 */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 			_mm256_store_si256((__m256i *)&rxdp->read, dma_addr0_1);
 			_mm256_store_si256((__m256i *)&(rxdp + 2)->read, dma_addr2_3);
+__rte_diagnostic_pop
 		}
 	}
 
drivers/net/i40e/i40e_rxtx_vec_altivec.c +15 -2
index b6b0d38ec1..c5546132e9 100644
@@ -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)
 {
@@ -43,8 +41,11 @@ i40e_rxq_rearm(struct i40e_rx_queue *rxq)
 			dma_addr0 = (__vector unsigned long){};
 			for (i = 0; i < RTE_I40E_DESCS_PER_LOOP; i++) {
 				rxep[i].mbuf = &rxq->fake_mbuf;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				vec_st(dma_addr0, 0,
 				       (__vector unsigned long *)&rxdp[i].read);
+__rte_diagnostic_pop
 			}
 		}
 		rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
@@ -84,8 +85,11 @@ i40e_rxq_rearm(struct i40e_rx_queue *rxq)
 		dma_addr1 = vec_add(dma_addr1, hdr_room);
 
 		/* flush desc with pa dma_addr */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		vec_st(dma_addr0, 0, (__vector unsigned long *)&rxdp++->read);
 		vec_st(dma_addr1, 0, (__vector unsigned long *)&rxdp++->read);
+__rte_diagnostic_pop
 	}
 
 	rxq->rxrearm_start += RTE_I40E_RXQ_REARM_THRESH;
@@ -286,7 +290,10 @@ _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] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs[3] = *(__vector unsigned long *)(rxdp + 3);
+__rte_diagnostic_pop
 		rte_compiler_barrier();
 
 		/* B.2 copy 2 mbuf point into rx_pkts  */
@@ -296,11 +303,14 @@ _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] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs[2] = *(__vector unsigned long *)(rxdp + 2);
 		rte_compiler_barrier();
 		descs[1] = *(__vector unsigned long *)(rxdp + 1);
 		rte_compiler_barrier();
 		descs[0] = *(__vector unsigned long *)(rxdp);
+__rte_diagnostic_pop
 
 		/* B.2 copy 2 mbuf point into rx_pkts  */
 		*(__vector unsigned long *)&rx_pkts[pos + 2] =  mbp2;
@@ -534,7 +544,10 @@ vtx1(volatile struct i40e_tx_desc *txdp,
 
 	__vector unsigned long descriptor = (__vector unsigned long){
 		pkt->buf_iova + pkt->data_off, high_qw};
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	*(__vector unsigned long *)txdp = descriptor;
+__rte_diagnostic_pop
 }
 
 static inline void
drivers/net/i40e/i40e_rxtx_vec_avx2.c +12 -4
index 19cf0ac718..90a1d4661a 100644
@@ -15,10 +15,6 @@
 
 #include <rte_vect.h>
 
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
-
 static __rte_always_inline void
 i40e_rxq_rearm(struct i40e_rx_queue *rxq)
 {
@@ -39,8 +35,11 @@ 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 */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	__m128i *rxdp_desc_0 = (void *)(&rxdp[desc_idx + 0].wb.qword2);
 	__m128i *rxdp_desc_1 = (void *)(&rxdp[desc_idx + 1].wb.qword2);
+__rte_diagnostic_pop
 	const __m128i desc_qw2_0 = _mm_load_si128(rxdp_desc_0);
 	const __m128i desc_qw2_1 = _mm_load_si128(rxdp_desc_1);
 
@@ -276,6 +275,8 @@ _recv_raw_pkts_vec_avx2(struct i40e_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 				_mm256_loadu_si256((void *)&sw_ring[i + 4]));
 #endif
 
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		const __m128i raw_desc7 = _mm_load_si128((void *)(rxdp + 7));
 		rte_compiler_barrier();
 		const __m128i raw_desc6 = _mm_load_si128((void *)(rxdp + 6));
@@ -291,6 +292,7 @@ _recv_raw_pkts_vec_avx2(struct i40e_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 		const __m128i raw_desc1 = _mm_load_si128((void *)(rxdp + 1));
 		rte_compiler_barrier();
 		const __m128i raw_desc0 = _mm_load_si128((void *)(rxdp + 0));
+__rte_diagnostic_pop
 
 		const __m256i raw_desc6_7 = _mm256_inserti128_si256(
 				_mm256_castsi128_si256(raw_desc6), raw_desc7, 1);
@@ -695,7 +697,10 @@ vtx1(volatile struct i40e_tx_desc *txdp,
 
 	__m128i descriptor = _mm_set_epi64x(high_qw,
 				pkt->buf_iova + pkt->data_off);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm_store_si128((__m128i *)txdp, descriptor);
+__rte_diagnostic_pop
 }
 
 static inline void
@@ -728,8 +733,11 @@ 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);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm256_store_si256((void *)(txdp + 2), desc2_3);
 		_mm256_store_si256((void *)txdp, desc0_1);
+__rte_diagnostic_pop
 	}
 
 	/* do any last ones */
drivers/net/i40e/i40e_rxtx_vec_avx512.c +12 -4
index 3b2750221b..b77989074f 100644
@@ -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 8
 
 static __rte_always_inline void
@@ -41,8 +37,11 @@ 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 */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	__m128i *rxdp_desc_0 = (void *)(&rxdp[desc_idx + 0].wb.qword2);
 	__m128i *rxdp_desc_1 = (void *)(&rxdp[desc_idx + 1].wb.qword2);
+__rte_diagnostic_pop
 	const __m128i desc_qw2_0 = _mm_load_si128(rxdp_desc_0);
 	const __m128i desc_qw2_1 = _mm_load_si128(rxdp_desc_1);
 
@@ -263,6 +262,8 @@ _recv_raw_pkts_vec_avx512(struct i40e_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 		__m256i raw_desc0_1, raw_desc2_3, raw_desc4_5, raw_desc6_7;
 
 		/* load in descriptors, in reverse order */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		const __m128i raw_desc7 =
 			_mm_load_si128((void *)(rxdp + 7));
 		rte_compiler_barrier();
@@ -286,6 +287,7 @@ _recv_raw_pkts_vec_avx512(struct i40e_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 		rte_compiler_barrier();
 		const __m128i raw_desc0 =
 			_mm_load_si128((void *)(rxdp + 0));
+__rte_diagnostic_pop
 
 		raw_desc6_7 =
 			_mm256_inserti128_si256
@@ -875,7 +877,10 @@ 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);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm_store_si128((__m128i *)txdp, descriptor);
+__rte_diagnostic_pop
 }
 
 static inline void
@@ -909,7 +914,10 @@ 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);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm512_storeu_si512((void *)txdp, desc0_3);
+__rte_diagnostic_pop
 	}
 
 	/* do any last ones */
drivers/net/i40e/i40e_rxtx_vec_common.h +0 -4
index 8b745630e4..ec59a68f9d 100644
@@ -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 +12 -3
index e1c5c7041b..9928ab7ba8 100644
@@ -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)
 {
@@ -58,11 +55,14 @@ i40e_rxq_rearm(struct i40e_rx_queue *rxq)
 		dma_addr0 = vdupq_n_u64(paddr);
 
 		/* flush desc with pa dma_addr */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		vst1q_u64((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);
+__rte_diagnostic_pop
 	}
 
 	rxq->rxrearm_start += RTE_I40E_RXQ_REARM_THRESH;
@@ -87,10 +87,13 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	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);
+__rte_diagnostic_pop
 
 	/* FDIR ID data: move last u32 of each desc to 4 u32 lanes */
 	uint32x4_t v_unpack_02, v_unpack_13;
@@ -421,6 +424,8 @@ _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] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs[3] =  vld1q_u64((uint64_t *)(rxdp + 3));
 		descs[2] =  vld1q_u64((uint64_t *)(rxdp + 2));
 		descs[1] =  vld1q_u64((uint64_t *)(rxdp + 1));
@@ -433,6 +438,7 @@ _recv_raw_pkts_vec(struct i40e_rx_queue *__rte_restrict rxq,
 		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);
+__rte_diagnostic_pop
 
 		/* B.1 load 4 mbuf point */
 		mbp1 = vld1q_u64((uint64_t *)&sw_ring[pos]);
@@ -662,7 +668,10 @@ 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};
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	vst1q_u64((uint64_t *)txdp, descriptor);
+__rte_diagnostic_pop
 }
 
 static inline void
drivers/net/i40e/i40e_rxtx_vec_sse.c +18 -4
index ad560d2b6b..8a5537bcf2 100644
@@ -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,8 +37,11 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				_mm_store_si128((__m128i *)&rxdp[i].read,
 						dma_addr0);
+__rte_diagnostic_pop
 			}
 		}
 		rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
@@ -72,8 +71,11 @@ i40e_rxq_rearm(struct i40e_rx_queue *rxq)
 		dma_addr1 = _mm_add_epi64(dma_addr1, hdr_room);
 
 		/* flush desc with pa dma_addr */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr0);
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr1);
+__rte_diagnostic_pop
 	}
 
 	rxq->rxrearm_start += RTE_I40E_RXQ_REARM_THRESH;
@@ -97,10 +99,13 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	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);
+__rte_diagnostic_pop
 
 	/* FDIR ID data: move last u32 of each desc to 4 u32 lanes */
 	__m128i v_unpack_01, v_unpack_23;
@@ -462,7 +467,10 @@ _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] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs[3] = _mm_loadu_si128((__m128i *)(rxdp + 3));
+__rte_diagnostic_pop
 		rte_compiler_barrier();
 
 		/* B.2 copy 2 64 bit or 4 32 bit mbuf point into rx_pkts */
@@ -474,11 +482,14 @@ _recv_raw_pkts_vec(struct i40e_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 #endif
 
 		/* A.1 load desc[2-0] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs[2] = _mm_loadu_si128((__m128i *)(rxdp + 2));
 		rte_compiler_barrier();
 		descs[1] = _mm_loadu_si128((__m128i *)(rxdp + 1));
 		rte_compiler_barrier();
 		descs[0] = _mm_loadu_si128((__m128i *)(rxdp));
+__rte_diagnostic_pop
 
 #if defined(RTE_ARCH_X86_64)
 		/* B.2 copy 2 mbuf point into rx_pkts  */
@@ -681,7 +692,10 @@ vtx1(volatile struct i40e_tx_desc *txdp,
 
 	__m128i descriptor = _mm_set_epi64x(high_qw,
 				pkt->buf_iova + pkt->data_off);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm_store_si128((__m128i *)txdp, descriptor);
+__rte_diagnostic_pop
 }
 
 static inline void
drivers/net/iavf/iavf_rxtx_vec_avx2.c +16 -5
index 49d41af953..f5503d9dae 100644
@@ -6,10 +6,6 @@
 
 #include <rte_vect.h>
 
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
-
 static __rte_always_inline void
 iavf_rxq_rearm(struct iavf_rx_queue *rxq)
 {
@@ -193,6 +189,8 @@ _iavf_recv_raw_pkts_vec_avx2(struct iavf_rx_queue *rxq,
 			 _mm256_loadu_si256((void *)&sw_ring[i + 4]));
 #endif
 
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		const __m128i raw_desc7 = _mm_load_si128((void *)(rxdp + 7));
 		rte_compiler_barrier();
 		const __m128i raw_desc6 = _mm_load_si128((void *)(rxdp + 6));
@@ -208,6 +206,7 @@ _iavf_recv_raw_pkts_vec_avx2(struct iavf_rx_queue *rxq,
 		const __m128i raw_desc1 = _mm_load_si128((void *)(rxdp + 1));
 		rte_compiler_barrier();
 		const __m128i raw_desc0 = _mm_load_si128((void *)(rxdp + 0));
+__rte_diagnostic_pop
 
 		const __m256i raw_desc6_7 =
 			_mm256_inserti128_si256(_mm256_castsi128_si256(raw_desc6), raw_desc7, 1);
@@ -509,7 +508,7 @@ _iavf_recv_raw_pkts_vec_avx2_flex_rxd(struct iavf_rx_queue *rxq,
 			0, rxq->mbuf_initializer);
 	struct rte_mbuf **sw_ring = &rxq->sw_ring[rxq->rx_tail];
 	volatile union iavf_rx_flex_desc *rxdp =
-		(union iavf_rx_flex_desc *)rxq->rx_ring + rxq->rx_tail;
+		(volatile union iavf_rx_flex_desc *)rxq->rx_ring + rxq->rx_tail;
 
 	rte_prefetch0(rxdp);
 
@@ -742,6 +741,8 @@ _iavf_recv_raw_pkts_vec_avx2_flex_rxd(struct iavf_rx_queue *rxq,
 
 		__m256i raw_desc0_1, raw_desc2_3, raw_desc4_5, raw_desc6_7;
 
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		const __m128i raw_desc7 =
 			_mm_load_si128((void *)(rxdp + 7));
 		rte_compiler_barrier();
@@ -765,6 +766,7 @@ _iavf_recv_raw_pkts_vec_avx2_flex_rxd(struct iavf_rx_queue *rxq,
 		rte_compiler_barrier();
 		const __m128i raw_desc0 =
 			_mm_load_si128((void *)(rxdp + 0));
+__rte_diagnostic_pop
 
 		raw_desc6_7 =
 			_mm256_inserti128_si256
@@ -959,6 +961,8 @@ _iavf_recv_raw_pkts_vec_avx2_flex_rxd(struct iavf_rx_queue *rxq,
 				offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP ||
 			    rxq->rx_flags & IAVF_RX_FLAGS_VLAN_TAG_LOC_L2TAG2_2) {
 				/* load bottom half of every 32B desc */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				const __m128i raw_desc_bh7 =
 					_mm_load_si128
 						((void *)(&rxdp[7].wb.status_error1));
@@ -990,6 +994,7 @@ _iavf_recv_raw_pkts_vec_avx2_flex_rxd(struct iavf_rx_queue *rxq,
 				const __m128i raw_desc_bh0 =
 					_mm_load_si128
 						((void *)(&rxdp[0].wb.status_error1));
+__rte_diagnostic_pop
 
 				__m256i raw_desc_bh6_7 =
 					_mm256_inserti128_si256
@@ -1664,7 +1669,10 @@ iavf_vtx1(volatile struct iavf_tx_desc *txdp,
 
 	__m128i descriptor = _mm_set_epi64x(high_qw,
 				pkt->buf_iova + pkt->data_off);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm_store_si128((__m128i *)txdp, descriptor);
+__rte_diagnostic_pop
 }
 
 static __rte_always_inline void
@@ -1719,8 +1727,11 @@ iavf_vtx(volatile struct iavf_tx_desc *txdp,
 				 pkt[1]->buf_iova + pkt[1]->data_off,
 				 hi_qw0,
 				 pkt[0]->buf_iova + pkt[0]->data_off);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm256_store_si256((void *)(txdp + 2), desc2_3);
 		_mm256_store_si256((void *)txdp, desc0_1);
+__rte_diagnostic_pop
 	}
 
 	/* do any last ones */
drivers/net/iavf/iavf_rxtx_vec_avx512.c +22 -5
index d6a861bf80..04894debc8 100644
@@ -6,10 +6,6 @@
 
 #include <rte_vect.h>
 
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
-
 #define IAVF_DESCS_PER_LOOP_AVX 8
 #define PKTLEN_SHIFT 10
 
@@ -164,6 +160,8 @@ _iavf_recv_raw_pkts_vec_avx512(struct iavf_rx_queue *rxq,
 #endif
 
 		__m512i raw_desc0_3, raw_desc4_7;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		const __m128i raw_desc7 =
 			_mm_load_si128((void *)(rxdp + 7));
 		rte_compiler_barrier();
@@ -187,6 +185,7 @@ _iavf_recv_raw_pkts_vec_avx512(struct iavf_rx_queue *rxq,
 		rte_compiler_barrier();
 		const __m128i raw_desc0 =
 			_mm_load_si128((void *)(rxdp + 0));
+__rte_diagnostic_pop
 
 		raw_desc4_7 = _mm512_broadcast_i32x4(raw_desc4);
 		raw_desc4_7 = _mm512_inserti32x4(raw_desc4_7, raw_desc5, 1);
@@ -600,7 +599,7 @@ _iavf_recv_raw_pkts_vec_avx512_flex_rxd(struct iavf_rx_queue *rxq,
 						    rxq->mbuf_initializer);
 	struct rte_mbuf **sw_ring = &rxq->sw_ring[rxq->rx_tail];
 	volatile union iavf_rx_flex_desc *rxdp =
-		(union iavf_rx_flex_desc *)rxq->rx_ring + rxq->rx_tail;
+		(volatile union iavf_rx_flex_desc *)rxq->rx_ring + rxq->rx_tail;
 
 	rte_prefetch0(rxdp);
 
@@ -733,6 +732,8 @@ _iavf_recv_raw_pkts_vec_avx512_flex_rxd(struct iavf_rx_queue *rxq,
 
 		__m512i raw_desc0_3, raw_desc4_7;
 
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		const __m128i raw_desc7 =
 			_mm_load_si128((void *)(rxdp + 7));
 		rte_compiler_barrier();
@@ -756,6 +757,7 @@ _iavf_recv_raw_pkts_vec_avx512_flex_rxd(struct iavf_rx_queue *rxq,
 		rte_compiler_barrier();
 		const __m128i raw_desc0 =
 			_mm_load_si128((void *)(rxdp + 0));
+__rte_diagnostic_pop
 
 		raw_desc4_7 = _mm512_broadcast_i32x4(raw_desc4);
 		raw_desc4_7 = _mm512_inserti32x4(raw_desc4_7, raw_desc5, 1);
@@ -1111,6 +1113,8 @@ _iavf_recv_raw_pkts_vec_avx512_flex_rxd(struct iavf_rx_queue *rxq,
 				offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP ||
 			    rxq->rx_flags & IAVF_RX_FLAGS_VLAN_TAG_LOC_L2TAG2_2) {
 				/* load bottom half of every 32B desc */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				const __m128i raw_desc_bh7 =
 					_mm_load_si128
 						((void *)(&rxdp[7].wb.status_error1));
@@ -1142,6 +1146,7 @@ _iavf_recv_raw_pkts_vec_avx512_flex_rxd(struct iavf_rx_queue *rxq,
 				const __m128i raw_desc_bh0 =
 					_mm_load_si128
 						((void *)(&rxdp[0].wb.status_error1));
+__rte_diagnostic_pop
 
 				__m256i raw_desc_bh6_7 =
 					_mm256_inserti128_si256
@@ -1983,7 +1988,10 @@ iavf_vtx1(volatile struct iavf_tx_desc *txdp,
 
 	__m128i descriptor = _mm_set_epi64x(high_qw,
 					    pkt->buf_iova + pkt->data_off);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm_storeu_si128((__m128i *)txdp, descriptor);
+__rte_diagnostic_pop
 }
 
 #define IAVF_TX_LEN_MASK 0xAA
@@ -2037,7 +2045,10 @@ iavf_vtx(volatile struct iavf_tx_desc *txdp,
 				 pkt[1]->buf_iova + pkt[1]->data_off,
 				 hi_qw0,
 				 pkt[0]->buf_iova + pkt[0]->data_off);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm512_storeu_si512((void *)txdp, desc0_3);
+__rte_diagnostic_pop
 	}
 
 	/* do any last ones */
@@ -2225,7 +2236,10 @@ ctx_vtx1(volatile struct iavf_tx_desc *txdp, struct rte_mbuf *pkt,
 	__m256i ctx_data_desc = _mm256_set_epi64x(high_data_qw, pkt->buf_iova + pkt->data_off,
 							high_ctx_qw, low_ctx_qw);
 
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm256_storeu_si256((__m256i *)txdp, ctx_data_desc);
+__rte_diagnostic_pop
 }
 
 static __rte_always_inline void
@@ -2300,7 +2314,10 @@ ctx_vtx(volatile struct iavf_tx_desc *txdp,
 						hi_ctx_qw1, low_ctx_qw1,
 						hi_data_qw0, pkt[0]->buf_iova + pkt[0]->data_off,
 						hi_ctx_qw0, low_ctx_qw0);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm512_storeu_si512((void *)txdp, desc0_3);
+__rte_diagnostic_pop
 	}
 
 	if (nb_pkts)
drivers/net/iavf/iavf_rxtx_vec_common.h +6 -4
index 5c5220048d..690e0749e4 100644
@@ -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_t
 reassemble_packets(struct iavf_rx_queue *rxq, struct rte_mbuf **rx_bufs,
 		   uint16_t nb_bufs, uint8_t *split_flags)
@@ -422,8 +418,11 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				_mm_store_si128((__m128i *)&rxdp[i].read,
 						dma_addr0);
+__rte_diagnostic_pop
 			}
 		}
 		rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
@@ -458,8 +457,11 @@ 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 */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr0);
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr1);
+__rte_diagnostic_pop
 	}
 #else
 #ifdef CC_AVX512_SUPPORT
drivers/net/iavf/iavf_rxtx_vec_sse.c +25 -5
index 0db6fa8bd4..373df0c935 100644
@@ -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,8 +34,11 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				_mm_store_si128((__m128i *)&rxdp[i].read,
 						dma_addr0);
+__rte_diagnostic_pop
 			}
 		}
 		rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
@@ -69,8 +68,11 @@ iavf_rxq_rearm(struct iavf_rx_queue *rxq)
 		dma_addr1 = _mm_add_epi64(dma_addr1, hdr_room);
 
 		/* flush desc with pa dma_addr */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr0);
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr1);
+__rte_diagnostic_pop
 	}
 
 	rxq->rxrearm_start += rxq->rx_free_thresh;
@@ -578,7 +580,10 @@ _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] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs[3] = _mm_loadu_si128((__m128i *)(rxdp + 3));
+__rte_diagnostic_pop
 		rte_compiler_barrier();
 
 		/* B.2 copy 2 64 bit or 4 32 bit mbuf point into rx_pkts */
@@ -590,11 +595,14 @@ _recv_raw_pkts_vec(struct iavf_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 #endif
 
 		/* A.1 load desc[2-0] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs[2] = _mm_loadu_si128((__m128i *)(rxdp + 2));
 		rte_compiler_barrier();
 		descs[1] = _mm_loadu_si128((__m128i *)(rxdp + 1));
 		rte_compiler_barrier();
 		descs[0] = _mm_loadu_si128((__m128i *)(rxdp));
+__rte_diagnostic_pop
 
 #if defined(RTE_ARCH_X86_64)
 		/* B.2 copy 2 mbuf point into rx_pkts  */
@@ -783,7 +791,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 +872,10 @@ _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] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs[3] = _mm_loadu_si128((__m128i *)(rxdp + 3));
+__rte_diagnostic_pop
 		rte_compiler_barrier();
 
 		/* B.2 copy 2 64 bit or 4 32 bit mbuf point into rx_pkts */
@@ -876,11 +887,14 @@ _recv_raw_pkts_vec_flex_rxd(struct iavf_rx_queue *rxq,
 #endif
 
 		/* A.1 load desc[2-0] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs[2] = _mm_loadu_si128((__m128i *)(rxdp + 2));
 		rte_compiler_barrier();
 		descs[1] = _mm_loadu_si128((__m128i *)(rxdp + 1));
 		rte_compiler_barrier();
 		descs[0] = _mm_loadu_si128((__m128i *)(rxdp));
+__rte_diagnostic_pop
 
 #if defined(RTE_ARCH_X86_64)
 		/* B.2 copy 2 mbuf point into rx_pkts  */
@@ -927,6 +941,8 @@ _recv_raw_pkts_vec_flex_rxd(struct iavf_rx_queue *rxq,
 			offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP ||
 			rxq->rx_flags & IAVF_RX_FLAGS_VLAN_TAG_LOC_L2TAG2_2) {
 			/* load bottom half of every 32B desc */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 			descs_bh[3] = _mm_load_si128
 					((void *)(&rxdp[3].wb.status_error1));
 			rte_compiler_barrier();
@@ -938,6 +954,7 @@ _recv_raw_pkts_vec_flex_rxd(struct iavf_rx_queue *rxq,
 			rte_compiler_barrier();
 			descs_bh[0] = _mm_load_si128
 					((void *)(&rxdp[0].wb.status_error1));
+__rte_diagnostic_pop
 		}
 
 		if (offloads & RTE_ETH_RX_OFFLOAD_RSS_HASH) {
@@ -1349,7 +1366,10 @@ 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);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm_store_si128((__m128i *)txdp, descriptor);
+__rte_diagnostic_pop
 }
 
 static inline void
drivers/net/ice/ice_rxtx_common_avx.h +12 -4
index dacb87dcb0..b0d5232510 100644
@@ -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,8 +29,11 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				_mm_store_si128((__m128i *)&rxdp[i].read,
 						dma_addr0);
+__rte_diagnostic_pop
 			}
 		}
 		rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
@@ -77,8 +76,11 @@ 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 */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr0);
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr1);
+__rte_diagnostic_pop
 	}
 #else
 #ifdef __AVX512VL__
@@ -157,8 +159,11 @@ 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 */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 			_mm512_store_si512((__m512i *)&rxdp->read, dma_addr0_3);
 			_mm512_store_si512((__m512i *)&(rxdp + 4)->read, dma_addr4_7);
+__rte_diagnostic_pop
 		}
 	} else
 #endif /* __AVX512VL__ */
@@ -213,8 +218,11 @@ 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 */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 			_mm256_store_si256((__m256i *)&rxdp->read, dma_addr0_1);
 			_mm256_store_si256((__m256i *)&(rxdp + 2)->read, dma_addr2_3);
+__rte_diagnostic_pop
 		}
 	}
 
drivers/net/ice/ice_rxtx_vec_avx2.c +12 -4
index d6e88dbb29..6c6a810a15 100644
@@ -7,10 +7,6 @@
 
 #include <rte_vect.h>
 
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
-
 static __rte_always_inline void
 ice_rxq_rearm(struct ice_rx_queue *rxq)
 {
@@ -254,6 +250,8 @@ _ice_recv_raw_pkts_vec_avx2(struct ice_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 			 _mm256_loadu_si256((void *)&sw_ring[i + 4]));
 #endif
 
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		const __m128i raw_desc7 = _mm_load_si128((void *)(rxdp + 7));
 		rte_compiler_barrier();
 		const __m128i raw_desc6 = _mm_load_si128((void *)(rxdp + 6));
@@ -269,6 +267,7 @@ _ice_recv_raw_pkts_vec_avx2(struct ice_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 		const __m128i raw_desc1 = _mm_load_si128((void *)(rxdp + 1));
 		rte_compiler_barrier();
 		const __m128i raw_desc0 = _mm_load_si128((void *)(rxdp + 0));
+__rte_diagnostic_pop
 
 		const __m256i raw_desc6_7 =
 			_mm256_inserti128_si256(_mm256_castsi128_si256(raw_desc6), raw_desc7, 1);
@@ -444,6 +443,8 @@ _ice_recv_raw_pkts_vec_avx2(struct ice_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 			if (rxq->vsi->adapter->pf.dev_data->dev_conf.rxmode.offloads &
 					RTE_ETH_RX_OFFLOAD_RSS_HASH) {
 				/* load bottom half of every 32B desc */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				const __m128i raw_desc_bh7 =
 					_mm_load_si128
 						((void *)(&rxdp[7].wb.status_error1));
@@ -475,6 +476,7 @@ _ice_recv_raw_pkts_vec_avx2(struct ice_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 				const __m128i raw_desc_bh0 =
 					_mm_load_si128
 						((void *)(&rxdp[0].wb.status_error1));
+__rte_diagnostic_pop
 
 				__m256i raw_desc_bh6_7 =
 					_mm256_inserti128_si256
@@ -790,7 +792,10 @@ ice_vtx1(volatile struct ice_tx_desc *txdp,
 		ice_txd_enable_offload(pkt, &high_qw);
 
 	__m128i descriptor = _mm_set_epi64x(high_qw, rte_pktmbuf_iova(pkt));
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm_store_si128((__m128i *)txdp, descriptor);
+__rte_diagnostic_pop
 }
 
 static __rte_always_inline void
@@ -841,8 +846,11 @@ ice_vtx(volatile struct ice_tx_desc *txdp,
 			_mm256_set_epi64x
 				(hi_qw1, rte_pktmbuf_iova(pkt[1]),
 				 hi_qw0, rte_pktmbuf_iova(pkt[0]));
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm256_store_si256((void *)(txdp + 2), desc2_3);
 		_mm256_store_si256((void *)txdp, desc0_1);
+__rte_diagnostic_pop
 	}
 
 	/* do any last ones */
drivers/net/ice/ice_rxtx_vec_avx512.c +12 -4
index add095ef06..5a774550dc 100644
@@ -7,10 +7,6 @@
 
 #include <rte_vect.h>
 
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
-
 #define ICE_DESCS_PER_LOOP_AVX 8
 
 static __rte_always_inline void
@@ -243,6 +239,8 @@ _ice_recv_raw_pkts_vec_avx512(struct ice_rx_queue *rxq,
 		__m256i raw_desc0_1, raw_desc2_3, raw_desc4_5, raw_desc6_7;
 
 		/* load in descriptors, in reverse order */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		const __m128i raw_desc7 =
 			_mm_load_si128((void *)(rxdp + 7));
 		rte_compiler_barrier();
@@ -266,6 +264,7 @@ _ice_recv_raw_pkts_vec_avx512(struct ice_rx_queue *rxq,
 		rte_compiler_barrier();
 		const __m128i raw_desc0 =
 			_mm_load_si128((void *)(rxdp + 0));
+__rte_diagnostic_pop
 
 		raw_desc6_7 =
 			_mm256_inserti128_si256
@@ -474,6 +473,8 @@ _ice_recv_raw_pkts_vec_avx512(struct ice_rx_queue *rxq,
 			if (rxq->vsi->adapter->pf.dev_data->dev_conf.rxmode.offloads &
 					RTE_ETH_RX_OFFLOAD_RSS_HASH) {
 				/* load bottom half of every 32B desc */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				const __m128i raw_desc_bh7 =
 					_mm_load_si128
 						((void *)(&rxdp[7].wb.status_error1));
@@ -505,6 +506,7 @@ _ice_recv_raw_pkts_vec_avx512(struct ice_rx_queue *rxq,
 				const __m128i raw_desc_bh0 =
 					_mm_load_si128
 						((void *)(&rxdp[0].wb.status_error1));
+__rte_diagnostic_pop
 
 				__m256i raw_desc_bh6_7 =
 					_mm256_inserti128_si256
@@ -987,7 +989,10 @@ ice_vtx1(volatile struct ice_tx_desc *txdp,
 		ice_txd_enable_offload(pkt, &high_qw);
 
 	__m128i descriptor = _mm_set_epi64x(high_qw, rte_pktmbuf_iova(pkt));
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm_store_si128((__m128i *)txdp, descriptor);
+__rte_diagnostic_pop
 }
 
 static __rte_always_inline void
@@ -1029,7 +1034,10 @@ ice_vtx(volatile struct ice_tx_desc *txdp, struct rte_mbuf **pkt,
 				 hi_qw2, rte_pktmbuf_iova(pkt[2]),
 				 hi_qw1, rte_pktmbuf_iova(pkt[1]),
 				 hi_qw0, rte_pktmbuf_iova(pkt[0]));
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm512_storeu_si512((void *)txdp, desc0_3);
+__rte_diagnostic_pop
 	}
 
 	/* do any last ones */
drivers/net/ice/ice_rxtx_vec_common.h +0 -4
index 4b73465af5..45147decff 100644
@@ -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 +18 -4
index c01d8ede29..f2991cee1a 100644
@@ -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,8 +48,11 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				_mm_store_si128((__m128i *)&rxdp[i].read,
 						dma_addr0);
+__rte_diagnostic_pop
 			}
 		}
 		rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
@@ -91,8 +90,11 @@ ice_rxq_rearm(struct ice_rx_queue *rxq)
 		dma_addr1 = _mm_add_epi64(dma_addr1, hdr_room);
 
 		/* flush desc with pa dma_addr */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr0);
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr1);
+__rte_diagnostic_pop
 	}
 
 	rxq->rxrearm_start += ICE_RXQ_REARM_THRESH;
@@ -425,7 +427,10 @@ _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] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs[3] = _mm_loadu_si128((__m128i *)(rxdp + 3));
+__rte_diagnostic_pop
 		rte_compiler_barrier();
 
 		/* B.2 copy 2 64 bit or 4 32 bit mbuf point into rx_pkts */
@@ -437,11 +442,14 @@ _ice_recv_raw_pkts_vec(struct ice_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 #endif
 
 		/* A.1 load desc[2-0] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs[2] = _mm_loadu_si128((__m128i *)(rxdp + 2));
 		rte_compiler_barrier();
 		descs[1] = _mm_loadu_si128((__m128i *)(rxdp + 1));
 		rte_compiler_barrier();
 		descs[0] = _mm_loadu_si128((__m128i *)(rxdp));
+__rte_diagnostic_pop
 
 #if defined(RTE_ARCH_X86_64)
 		/* B.2 copy 2 mbuf point into rx_pkts  */
@@ -489,6 +497,8 @@ _ice_recv_raw_pkts_vec(struct ice_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 		if (rxq->vsi->adapter->pf.dev_data->dev_conf.rxmode.offloads &
 				RTE_ETH_RX_OFFLOAD_RSS_HASH) {
 			/* load bottom half of every 32B desc */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 			const __m128i raw_desc_bh3 =
 				_mm_load_si128
 					((void *)(&rxdp[3].wb.status_error1));
@@ -504,6 +514,7 @@ _ice_recv_raw_pkts_vec(struct ice_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 			const __m128i raw_desc_bh0 =
 				_mm_load_si128
 					((void *)(&rxdp[0].wb.status_error1));
+__rte_diagnostic_pop
 
 			/**
 			 * to shift the 32b RSS hash value to the
@@ -680,7 +691,10 @@ 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));
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm_store_si128((__m128i *)txdp, descriptor);
+__rte_diagnostic_pop
 }
 
 static inline void
drivers/net/idpf/idpf_rxtx_vec_common.h +0 -4
index 2787d27616..002c1e6948 100644
@@ -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
index d451562269..92a89f8def 100644
@@ -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 +0 -2
index 952b032eb6..4e7a64b39f 100644
@@ -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)
 {
drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c +15 -4
index a77370cdb7..8e4048a32f 100644
@@ -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,8 +37,11 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				_mm_store_si128((__m128i *)&rxdp[i].read,
 						dma_addr0);
+__rte_diagnostic_pop
 			}
 		}
 		rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
@@ -76,8 +75,11 @@ ixgbe_rxq_rearm(struct ixgbe_rx_queue *rxq)
 		dma_addr1 =  _mm_and_si128(dma_addr1, hba_msk);
 
 		/* flush desc with pa dma_addr */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr0);
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr1);
+__rte_diagnostic_pop
 	}
 
 	rxq->rxrearm_start += RTE_IXGBE_RXQ_REARM_THRESH;
@@ -466,7 +468,10 @@ _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] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs[3] = _mm_loadu_si128((__m128i *)(rxdp + 3));
+__rte_diagnostic_pop
 		rte_compiler_barrier();
 
 		/* B.2 copy 2 64 bit or 4 32 bit mbuf point into rx_pkts */
@@ -478,11 +483,14 @@ _recv_raw_pkts_vec(struct ixgbe_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 #endif
 
 		/* A.1 load desc[2-0] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs[2] = _mm_loadu_si128((__m128i *)(rxdp + 2));
 		rte_compiler_barrier();
 		descs[1] = _mm_loadu_si128((__m128i *)(rxdp + 1));
 		rte_compiler_barrier();
 		descs[0] = _mm_loadu_si128((__m128i *)(rxdp));
+__rte_diagnostic_pop
 
 #if defined(RTE_ARCH_X86_64)
 		/* B.2 copy 2 mbuf point into rx_pkts  */
@@ -676,7 +684,10 @@ 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);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm_store_si128((__m128i *)&txdp->read, descriptor);
+__rte_diagnostic_pop
 }
 
 static inline void
drivers/net/mlx5/mlx5_flow.c +3 -3
index 16ddd05448..0a89d2c414 100644
@@ -7287,10 +7287,10 @@ flow_tunnel_from_rule(const struct mlx5_flow *flow)
 {
 	struct mlx5_flow_tunnel *tunnel;
 
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wcast-qual"
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	tunnel = (typeof(tunnel))flow->tunnel;
-#pragma GCC diagnostic pop
+__rte_diagnostic_pop
 
 	return tunnel;
 }
drivers/net/mlx5/mlx5_rxtx_vec_altivec.h +0 -5
index 240987d03d..b37483bcca 100644
@@ -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 +0 -2
index dc1d30753d..e7deacc1fb 100644
@@ -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.
  *
drivers/net/mlx5/mlx5_rxtx_vec_sse.h +19 -7
index 81a177fce7..f4d08d5b30 100644
@@ -24,10 +24,6 @@
 #include "mlx5_rxtx_vec.h"
 #include "mlx5_autoconf.h"
 
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
-
 /**
  * Store free buffers to RX SW ring.
  *
@@ -75,7 +71,8 @@ static inline uint16_t
 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);
+	volatile struct mlx5_mini_cqe8 *mcq =
+		(volatile void *)(cq + !rxq->cqe_comp_layout);
 	/* Title packet is pre-built. */
 	struct rte_mbuf *t_pkt = rxq->cqe_comp_layout ? &rxq->title_pkt : elts[0];
 	unsigned int pos;
@@ -129,8 +126,11 @@ rxq_cq_decompress_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq,
 	 * E. store flow tag (rte_flow mark).
 	 */
 cycle:
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	if (rxq->cqe_comp_layout)
 		rte_prefetch0((void *)(cq + mcqe_n));
+__rte_diagnostic_pop
 	for (pos = 0; pos < mcqe_n; ) {
 		__m128i mcqe1, mcqe2;
 		__m128i rxdf1, rxdf2;
@@ -138,6 +138,8 @@ rxq_cq_decompress_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq,
 		__m128i byte_cnt, invalid_mask;
 #endif
 
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		if (!rxq->cqe_comp_layout)
 			for (i = 0; i < MLX5_VPMD_DESCS_PER_LOOP; ++i)
 				if (likely(pos + i < mcqe_n))
@@ -145,6 +147,7 @@ rxq_cq_decompress_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq,
 		/* A.1 load mCQEs into a 128bit register. */
 		mcqe1 = _mm_loadu_si128((__m128i *)&mcq[pos % 8]);
 		mcqe2 = _mm_loadu_si128((__m128i *)&mcq[pos % 8 + 2]);
+__rte_diagnostic_pop
 		/* B.1 store rearm data to mbuf. */
 		_mm_storeu_si128((__m128i *)&elts[pos]->rearm_data, rearm);
 		_mm_storeu_si128((__m128i *)&elts[pos + 1]->rearm_data, rearm);
@@ -354,9 +357,12 @@ rxq_cq_decompress_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq,
 		/* Move to next CQE and invalidate consumed CQEs. */
 		if (!rxq->cqe_comp_layout) {
 			if (!(pos & 0x7) && pos < mcqe_n) {
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				if (pos + 8 < mcqe_n)
 					rte_prefetch0((void *)(cq + pos + 8));
-				mcq = (void *)(cq + pos);
+__rte_diagnostic_pop
+				mcq = (volatile void *)(cq + pos);
 				for (i = 0; i < 8; ++i)
 					cq[inv++].op_own = MLX5_CQE_INVALIDATE;
 			}
@@ -371,7 +377,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 void *)cq;
 			mcqe_n = MLX5_CQE_NUM_MINIS(cq->op_own) + 1;
 			pkts_n += mcqe_n;
 			goto cycle;
@@ -651,6 +657,8 @@ rxq_cq_process_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq,
 		p = _mm_andnot_si128(mask, p);
 		/* A.1 load cqes. */
 		p3 = _mm_extract_epi16(p, 3);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		cqes[3] = _mm_loadl_epi64((__m128i *)
 					   &cq[pos + p3].sop_drop_qpn);
 		rte_compiler_barrier();
@@ -683,6 +691,7 @@ rxq_cq_process_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq,
 		cqes[2] = _mm_blend_epi16(cqes[2], cqe_tmp1, 0x30);
 		cqe_tmp2 = _mm_loadl_epi64((__m128i *)&cq[pos + p3].rsvd4[2]);
 		cqe_tmp1 = _mm_loadl_epi64((__m128i *)&cq[pos + p2].rsvd4[2]);
+__rte_diagnostic_pop
 		cqes[3] = _mm_blend_epi16(cqes[3], cqe_tmp2, 0x04);
 		cqes[2] = _mm_blend_epi16(cqes[2], cqe_tmp1, 0x04);
 		/* C.2 generate final structure for mbuf with swapping bytes. */
@@ -700,6 +709,8 @@ rxq_cq_process_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq,
 		/* E.1 extract op_own field. */
 		op_own_tmp2 = _mm_unpacklo_epi32(cqes[2], cqes[3]);
 		/* C.1 load remained CQE data and extract necessary fields. */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		cqe_tmp2 = _mm_load_si128((__m128i *)&cq[pos + p1]);
 		cqe_tmp1 = _mm_load_si128((__m128i *)&cq[pos]);
 		cqes[1] = _mm_blendv_epi8(cqes[1], cqe_tmp2, blend_mask);
@@ -710,6 +721,7 @@ rxq_cq_process_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq,
 		cqes[0] = _mm_blend_epi16(cqes[0], cqe_tmp1, 0x30);
 		cqe_tmp2 = _mm_loadl_epi64((__m128i *)&cq[pos + p1].rsvd4[2]);
 		cqe_tmp1 = _mm_loadl_epi64((__m128i *)&cq[pos].rsvd4[2]);
+__rte_diagnostic_pop
 		cqes[1] = _mm_blend_epi16(cqes[1], cqe_tmp2, 0x04);
 		cqes[0] = _mm_blend_epi16(cqes[0], cqe_tmp1, 0x04);
 		/* C.2 generate final structure for mbuf with swapping bytes. */
drivers/net/tap/tap_flow.c +3 -3
index c0e44bb1a7..373b773e2d 100644
@@ -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/virtio/virtio_rxtx_simple.c +0 -4
index 438256970d..439e00a7e1 100644
@@ -23,10 +23,6 @@
 
 #include "virtio_rxtx_simple.h"
 
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
-
 int __rte_cold
 virtio_rxq_vec_setup(struct virtnet_rx *rxq)
 {
Signature · 1 line
2.47.0.vfs.0.3
#18 lore raw
In reply to Andre Muezerie
Quoted 14 lines · On Mon, 30 Dec 2024 07:59:27 -0800 Andre Muezerie…

From: Andre Muezerie <[email protected]>
To: [email protected]
Cc: [email protected], [email protected]
Subject: [PATCH v4 0/3] add diagnostics macros to make code portable
Date: Mon, 30 Dec 2024 07:59:27 -0800
X-Mailer: git-send-email 1.8.3.1

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

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

Does anyone still use the Intel C compiler with DPDK?
I really wonder if it is only maintained for legacy/sponsorship reasons.

#19 lore raw

v5 cover add diagnostics macros to make code portable

In reply to Andre Muezerie

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.

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):
lib/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 | 46 +++++++++++++++++--
 drivers/net/axgbe/axgbe_rxtx.h                |  9 ----
 drivers/net/cpfl/cpfl_rxtx_vec_common.h       |  4 --
 drivers/net/dpaa2/dpaa2_rxtx.c                | 16 ++-----
 drivers/net/fm10k/fm10k_rxtx_vec.c            | 19 ++++++--
 drivers/net/hns3/hns3_rxtx_vec_neon.h         |  5 +-
 .../net/i40e/i40e_recycle_mbufs_vec_common.c  |  2 -
 drivers/net/i40e/i40e_rxtx_common_avx.h       | 16 +++++--
 drivers/net/i40e/i40e_rxtx_vec_altivec.c      | 17 ++++++-
 drivers/net/i40e/i40e_rxtx_vec_avx2.c         | 16 +++++--
 drivers/net/i40e/i40e_rxtx_vec_avx512.c       | 16 +++++--
 drivers/net/i40e/i40e_rxtx_vec_common.h       |  4 --
 drivers/net/i40e/i40e_rxtx_vec_neon.c         | 18 ++++++--
 drivers/net/i40e/i40e_rxtx_vec_sse.c          | 22 +++++++--
 drivers/net/iavf/iavf_rxtx_vec_avx2.c         | 21 +++++++--
 drivers/net/iavf/iavf_rxtx_vec_avx512.c       | 27 +++++++++--
 drivers/net/iavf/iavf_rxtx_vec_common.h       | 10 ++--
 drivers/net/iavf/iavf_rxtx_vec_sse.c          | 30 ++++++++++--
 drivers/net/ice/ice_rxtx_common_avx.h         | 16 +++++--
 drivers/net/ice/ice_rxtx_vec_avx2.c           | 16 +++++--
 drivers/net/ice/ice_rxtx_vec_avx512.c         | 16 +++++--
 drivers/net/ice/ice_rxtx_vec_common.h         |  4 --
 drivers/net/ice/ice_rxtx_vec_sse.c            | 22 +++++++--
 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       |  2 -
 drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c        | 19 ++++++--
 drivers/net/mlx5/mlx5_flow.c                  |  6 +--
 drivers/net/mlx5/mlx5_rxtx_vec_altivec.h      |  5 --
 drivers/net/mlx5/mlx5_rxtx_vec_neon.h         |  2 -
 drivers/net/mlx5/mlx5_rxtx_vec_sse.h          | 26 ++++++++---
 drivers/net/tap/tap_flow.c                    |  6 +--
 drivers/net/virtio/virtio_rxtx_simple.c       |  4 --
 lib/eal/include/rte_common.h                  | 23 ++++++++++
 34 files changed, 333 insertions(+), 138 deletions(-)

--
2.47.0.vfs.0.3

#20 lore raw

PATCH v5 1/3 lib/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 | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
lib/eal/include/rte_common.h +23 -0
index 4d299f2b36..13b7b92f46 100644
@@ -137,6 +137,29 @@ typedef uint16_t unaligned_uint16_t;
 #define RTE_DEPRECATED(x)
 #endif
 
+/*
+ * Macro to ignore whenever a pointer is cast so as to remove 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
+
+/*
+ * 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
+
 /**
  * Mark a function or variable to a weak reference.
  */
Signature · 1 line
2.47.0.vfs.0.3
#21 lore raw

PATCH v5 2/3 drivers/common: add diagnostics macros to make code portable

In reply to Andre Muezerie

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.

---
 drivers/common/idpf/idpf_common_rxtx_avx512.c | 46 +++++++++++++++++--
 1 file changed, 42 insertions(+), 4 deletions(-)
drivers/common/idpf/idpf_common_rxtx_avx512.c +42 -4
index b8450b03ae..37cd0a43e2 100644
@@ -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,8 +30,11 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				_mm_store_si128((__m128i *)&rxdp[i].read,
 						dma_addr0);
+__rte_diagnostic_pop
 			}
 		}
 		rte_atomic_fetch_add_explicit(&rxq->rx_stats.mbuf_alloc_failed,
@@ -108,8 +107,11 @@ 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 */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm512_store_si512((__m512i *)&rxdp->read, dma_addr0_3);
 		_mm512_store_si512((__m512i *)&(rxdp + 4)->read, dma_addr4_7);
+__rte_diagnostic_pop
 	}
 
 	rxq->rxrearm_start += IDPF_RXQ_REARM_THRESH;
@@ -164,8 +166,11 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 					_mm_storeu_si128((__m128i *)&rxdp[i].read,
 							 dma_addr0);
+__rte_diagnostic_pop
 				}
 			}
 			rte_atomic_fetch_add_explicit(&rxq->rx_stats.mbuf_alloc_failed,
@@ -216,10 +221,13 @@ idpf_singleq_rearm(struct idpf_rx_queue *rxq)
 				 iovas1);
 		const __m512i desc6_7 = _mm512_bsrli_epi128(desc4_5, 8);
 
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_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);
+__rte_diagnostic_pop
 
 		rxp += IDPF_DESCS_PER_LOOP_AVX;
 		rxdp += IDPF_DESCS_PER_LOOP_AVX;
@@ -336,6 +344,8 @@ _idpf_singleq_recv_raw_pkts_avx512(struct idpf_rx_queue *rxq,
 #endif
 
 		__m512i raw_desc0_3, raw_desc4_7;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		const __m128i raw_desc7 =
 			_mm_load_si128((void *)(rxdp + 7));
 		rte_compiler_barrier();
@@ -359,6 +369,7 @@ _idpf_singleq_recv_raw_pkts_avx512(struct idpf_rx_queue *rxq,
 		rte_compiler_barrier();
 		const __m128i raw_desc0 =
 			_mm_load_si128((void *)(rxdp + 0));
+__rte_diagnostic_pop
 
 		raw_desc4_7 = _mm512_broadcast_i32x4(raw_desc4);
 		raw_desc4_7 = _mm512_inserti32x4(raw_desc4_7, raw_desc5, 1);
@@ -560,8 +571,11 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				_mm_store_si128((__m128i *)&rxdp[i],
 						dma_addr0);
+__rte_diagnostic_pop
 			}
 		}
 	rte_atomic_fetch_add_explicit(&rx_bufq->rx_stats.mbuf_alloc_failed,
@@ -634,8 +648,11 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 					_mm_storeu_si128((__m128i *)&rxdp[i],
 							 dma_addr0);
+__rte_diagnostic_pop
 				}
 			}
 		rte_atomic_fetch_add_explicit(&rx_bufq->rx_stats.mbuf_alloc_failed,
@@ -797,6 +814,8 @@ _idpf_splitq_recv_raw_pkts_avx512(struct idpf_rx_queue *rxq,
 #endif
 
 		__m512i raw_desc0_3, raw_desc4_7;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		const __m128i raw_desc7 =
 			_mm_load_si128((void *)(rxdp + 7));
 		rte_compiler_barrier();
@@ -820,6 +839,7 @@ _idpf_splitq_recv_raw_pkts_avx512(struct idpf_rx_queue *rxq,
 		rte_compiler_barrier();
 		const __m128i raw_desc0 =
 			_mm_load_si128((void *)(rxdp + 0));
+__rte_diagnostic_pop
 
 		raw_desc4_7 = _mm512_broadcast_i32x4(raw_desc4);
 		raw_desc4_7 = _mm512_inserti32x4(raw_desc4_7, raw_desc5, 1);
@@ -1131,7 +1151,10 @@ idpf_singleq_vtx1(volatile struct idpf_base_tx_desc *txdp,
 
 	__m128i descriptor = _mm_set_epi64x(high_qw,
 					    pkt->buf_iova + pkt->data_off);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm_storeu_si128((__m128i *)txdp, descriptor);
+__rte_diagnostic_pop
 }
 
 #define IDPF_TX_LEN_MASK 0xAA
@@ -1178,7 +1201,10 @@ 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);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm512_storeu_si512((void *)txdp, desc0_3);
+__rte_diagnostic_pop
 	}
 
 	/* do any last ones */
@@ -1435,7 +1461,10 @@ idpf_splitq_vtx1(volatile struct idpf_flex_tx_sched_desc *txdp,
 
 	__m128i descriptor = _mm_set_epi64x(high_qw,
 					    pkt->buf_iova + pkt->data_off);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm_storeu_si128((__m128i *)txdp, descriptor);
+__rte_diagnostic_pop
 }
 
 static __rte_always_inline void
@@ -1480,7 +1509,10 @@ 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);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm512_storeu_si512((void *)txdp, desc0_3);
+__rte_diagnostic_pop
 	}
 
 	/* do any last ones */
@@ -1521,11 +1553,14 @@ idpf_splitq_xmit_fixed_burst_vec_avx512(void *tx_queue, struct rte_mbuf **tx_pkt
 	if (nb_commit >= n) {
 		tx_backlog_entry_avx512(txep, tx_pkts, n);
 
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		idpf_splitq_vtx((void *)txdp, tx_pkts, n - 1, cmd_dtype);
 		tx_pkts += (n - 1);
 		txdp += (n - 1);
 
 		idpf_splitq_vtx1((void *)txdp, *tx_pkts++, cmd_dtype);
+__rte_diagnostic_pop
 
 		nb_commit = (uint16_t)(nb_commit - n);
 
@@ -1540,7 +1575,10 @@ idpf_splitq_xmit_fixed_burst_vec_avx512(void *tx_queue, struct rte_mbuf **tx_pkt
 
 	tx_backlog_entry_avx512(txep, tx_pkts, nb_commit);
 
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	idpf_splitq_vtx((void *)txdp, tx_pkts, nb_commit, cmd_dtype);
+__rte_diagnostic_pop
 
 	tx_id = (uint16_t)(tx_id + nb_commit);
 	if (tx_id > txq->next_rs)
Signature · 1 line
2.47.0.vfs.0.3
#22 lore raw

PATCH v5 3/3 drivers/net: add diagnostics macros to make code portable

In reply to Andre Muezerie

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.

---
 drivers/net/axgbe/axgbe_rxtx.h                |  9 ------
 drivers/net/cpfl/cpfl_rxtx_vec_common.h       |  4 ---
 drivers/net/dpaa2/dpaa2_rxtx.c                | 16 ++--------
 drivers/net/fm10k/fm10k_rxtx_vec.c            | 19 +++++++++---
 drivers/net/hns3/hns3_rxtx_vec_neon.h         |  5 ++--
 .../net/i40e/i40e_recycle_mbufs_vec_common.c  |  2 --
 drivers/net/i40e/i40e_rxtx_common_avx.h       | 16 +++++++---
 drivers/net/i40e/i40e_rxtx_vec_altivec.c      | 17 +++++++++--
 drivers/net/i40e/i40e_rxtx_vec_avx2.c         | 16 +++++++---
 drivers/net/i40e/i40e_rxtx_vec_avx512.c       | 16 +++++++---
 drivers/net/i40e/i40e_rxtx_vec_common.h       |  4 ---
 drivers/net/i40e/i40e_rxtx_vec_neon.c         | 18 +++++++++--
 drivers/net/i40e/i40e_rxtx_vec_sse.c          | 22 +++++++++++---
 drivers/net/iavf/iavf_rxtx_vec_avx2.c         | 21 +++++++++----
 drivers/net/iavf/iavf_rxtx_vec_avx512.c       | 27 +++++++++++++----
 drivers/net/iavf/iavf_rxtx_vec_common.h       | 10 ++++---
 drivers/net/iavf/iavf_rxtx_vec_sse.c          | 30 +++++++++++++++----
 drivers/net/ice/ice_rxtx_common_avx.h         | 16 +++++++---
 drivers/net/ice/ice_rxtx_vec_avx2.c           | 16 +++++++---
 drivers/net/ice/ice_rxtx_vec_avx512.c         | 16 +++++++---
 drivers/net/ice/ice_rxtx_vec_common.h         |  4 ---
 drivers/net/ice/ice_rxtx_vec_sse.c            | 22 +++++++++++---
 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       |  2 --
 drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c        | 19 +++++++++---
 drivers/net/mlx5/mlx5_flow.c                  |  6 ++--
 drivers/net/mlx5/mlx5_rxtx_vec_altivec.h      |  5 ----
 drivers/net/mlx5/mlx5_rxtx_vec_neon.h         |  2 --
 drivers/net/mlx5/mlx5_rxtx_vec_sse.h          | 26 +++++++++++-----
 drivers/net/tap/tap_flow.c                    |  6 ++--
 drivers/net/virtio/virtio_rxtx_simple.c       |  4 ---
 32 files changed, 268 insertions(+), 134 deletions(-)
drivers/net/axgbe/axgbe_rxtx.h +0 -9
index a326ba9ac8..f5f74a0a39 100644
@@ -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
index 479e1ddcb9..5b98f86932 100644
@@ -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 +3 -13
index e3b6c7e460..21c306fd94 100644
@@ -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,10 @@ dpaa2_dev_loopback_rx(void *queue,
 			if (unlikely((status & QBMAN_DQ_STAT_VALIDFRAME) == 0))
 				continue;
 		}
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		fd[num_rx] = (struct qbman_fd *)qbman_result_DQ_fd(dq_storage);
+__rte_diagnostic_pop
 
 		dq_storage++;
 		num_rx++;
@@ -2118,8 +2113,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 +15 -4
index 68acaca75b..3d534a91ac 100644
@@ -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,11 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 			_mm_store_si128((__m128i *)&rxdp[i].q,
 						dma_addr0);
+__rte_diagnostic_pop
 		}
 
 		rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
@@ -316,8 +315,11 @@ fm10k_rxq_rearm(struct fm10k_rx_queue *rxq)
 		dma_addr1 = _mm_and_si128(dma_addr1, hba_msk);
 
 		/* flush desc with pa dma_addr */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm_store_si128((__m128i *)&rxdp++->q, dma_addr0);
 		_mm_store_si128((__m128i *)&rxdp++->q, dma_addr1);
+__rte_diagnostic_pop
 
 		/* enforce 512B alignment on default Rx virtual addresses */
 		mb0->data_off = (uint16_t)(RTE_PTR_ALIGN((char *)mb0->buf_addr
@@ -465,7 +467,10 @@ 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] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs0[3] = _mm_loadu_si128((__m128i *)(rxdp + 3));
+__rte_diagnostic_pop
 		rte_compiler_barrier();
 
 		/* B.2 copy 2 64 bit or 4 32 bit mbuf point into rx_pkts */
@@ -477,11 +482,14 @@ fm10k_recv_raw_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
 #endif
 
 		/* A.1 load desc[2-0] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs0[2] = _mm_loadu_si128((__m128i *)(rxdp + 2));
 		rte_compiler_barrier();
 		descs0[1] = _mm_loadu_si128((__m128i *)(rxdp + 1));
 		rte_compiler_barrier();
 		descs0[0] = _mm_loadu_si128((__m128i *)(rxdp));
+__rte_diagnostic_pop
 
 #if defined(RTE_ARCH_X86_64)
 		/* B.2 copy 2 mbuf point into rx_pkts  */
@@ -736,7 +744,10 @@ 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));
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm_store_si128((__m128i *)txdp, descriptor);
+__rte_diagnostic_pop
 }
 
 static inline void
drivers/net/hns3/hns3_rxtx_vec_neon.h +3 -2
index bbb5478015..99f080f3e8 100644
@@ -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,11 @@ hns3_vec_tx(volatile struct hns3_desc *desc, struct rte_mbuf *pkt)
 		0,
 		((uint64_t)HNS3_TXD_DEFAULT_VLD_FE_BDTYPE) << HNS3_UINT32_BIT
 	};
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	vst1q_u64((uint64_t *)&desc->addr, val1);
 	vst1q_u64((uint64_t *)&desc->tx.outer_vlan_tag, val2);
+__rte_diagnostic_pop
 }
 
 static uint16_t
drivers/net/i40e/i40e_recycle_mbufs_vec_common.c +0 -2
index 14424c9921..6eafe51e3d 100644
@@ -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 +12 -4
index 85958d6c81..bcabacf689 100644
@@ -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,8 +32,11 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				_mm_store_si128((__m128i *)&rxdp[i].read,
 						dma_addr0);
+__rte_diagnostic_pop
 			}
 		}
 		rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
@@ -72,8 +71,11 @@ 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 */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr0);
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr1);
+__rte_diagnostic_pop
 	}
 #else
 #ifdef __AVX512VL__
@@ -144,8 +146,11 @@ 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 */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 			_mm512_store_si512((__m512i *)&rxdp->read, dma_addr0_3);
 			_mm512_store_si512((__m512i *)&(rxdp + 4)->read, dma_addr4_7);
+__rte_diagnostic_pop
 		}
 	} else
 #endif /* __AVX512VL__*/
@@ -190,8 +195,11 @@ 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 */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 			_mm256_store_si256((__m256i *)&rxdp->read, dma_addr0_1);
 			_mm256_store_si256((__m256i *)&(rxdp + 2)->read, dma_addr2_3);
+__rte_diagnostic_pop
 		}
 	}
 
drivers/net/i40e/i40e_rxtx_vec_altivec.c +15 -2
index b6b0d38ec1..c5546132e9 100644
@@ -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)
 {
@@ -43,8 +41,11 @@ i40e_rxq_rearm(struct i40e_rx_queue *rxq)
 			dma_addr0 = (__vector unsigned long){};
 			for (i = 0; i < RTE_I40E_DESCS_PER_LOOP; i++) {
 				rxep[i].mbuf = &rxq->fake_mbuf;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				vec_st(dma_addr0, 0,
 				       (__vector unsigned long *)&rxdp[i].read);
+__rte_diagnostic_pop
 			}
 		}
 		rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
@@ -84,8 +85,11 @@ i40e_rxq_rearm(struct i40e_rx_queue *rxq)
 		dma_addr1 = vec_add(dma_addr1, hdr_room);
 
 		/* flush desc with pa dma_addr */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		vec_st(dma_addr0, 0, (__vector unsigned long *)&rxdp++->read);
 		vec_st(dma_addr1, 0, (__vector unsigned long *)&rxdp++->read);
+__rte_diagnostic_pop
 	}
 
 	rxq->rxrearm_start += RTE_I40E_RXQ_REARM_THRESH;
@@ -286,7 +290,10 @@ _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] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs[3] = *(__vector unsigned long *)(rxdp + 3);
+__rte_diagnostic_pop
 		rte_compiler_barrier();
 
 		/* B.2 copy 2 mbuf point into rx_pkts  */
@@ -296,11 +303,14 @@ _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] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs[2] = *(__vector unsigned long *)(rxdp + 2);
 		rte_compiler_barrier();
 		descs[1] = *(__vector unsigned long *)(rxdp + 1);
 		rte_compiler_barrier();
 		descs[0] = *(__vector unsigned long *)(rxdp);
+__rte_diagnostic_pop
 
 		/* B.2 copy 2 mbuf point into rx_pkts  */
 		*(__vector unsigned long *)&rx_pkts[pos + 2] =  mbp2;
@@ -534,7 +544,10 @@ vtx1(volatile struct i40e_tx_desc *txdp,
 
 	__vector unsigned long descriptor = (__vector unsigned long){
 		pkt->buf_iova + pkt->data_off, high_qw};
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	*(__vector unsigned long *)txdp = descriptor;
+__rte_diagnostic_pop
 }
 
 static inline void
drivers/net/i40e/i40e_rxtx_vec_avx2.c +12 -4
index 19cf0ac718..90a1d4661a 100644
@@ -15,10 +15,6 @@
 
 #include <rte_vect.h>
 
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
-
 static __rte_always_inline void
 i40e_rxq_rearm(struct i40e_rx_queue *rxq)
 {
@@ -39,8 +35,11 @@ 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 */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	__m128i *rxdp_desc_0 = (void *)(&rxdp[desc_idx + 0].wb.qword2);
 	__m128i *rxdp_desc_1 = (void *)(&rxdp[desc_idx + 1].wb.qword2);
+__rte_diagnostic_pop
 	const __m128i desc_qw2_0 = _mm_load_si128(rxdp_desc_0);
 	const __m128i desc_qw2_1 = _mm_load_si128(rxdp_desc_1);
 
@@ -276,6 +275,8 @@ _recv_raw_pkts_vec_avx2(struct i40e_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 				_mm256_loadu_si256((void *)&sw_ring[i + 4]));
 #endif
 
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		const __m128i raw_desc7 = _mm_load_si128((void *)(rxdp + 7));
 		rte_compiler_barrier();
 		const __m128i raw_desc6 = _mm_load_si128((void *)(rxdp + 6));
@@ -291,6 +292,7 @@ _recv_raw_pkts_vec_avx2(struct i40e_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 		const __m128i raw_desc1 = _mm_load_si128((void *)(rxdp + 1));
 		rte_compiler_barrier();
 		const __m128i raw_desc0 = _mm_load_si128((void *)(rxdp + 0));
+__rte_diagnostic_pop
 
 		const __m256i raw_desc6_7 = _mm256_inserti128_si256(
 				_mm256_castsi128_si256(raw_desc6), raw_desc7, 1);
@@ -695,7 +697,10 @@ vtx1(volatile struct i40e_tx_desc *txdp,
 
 	__m128i descriptor = _mm_set_epi64x(high_qw,
 				pkt->buf_iova + pkt->data_off);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm_store_si128((__m128i *)txdp, descriptor);
+__rte_diagnostic_pop
 }
 
 static inline void
@@ -728,8 +733,11 @@ 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);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm256_store_si256((void *)(txdp + 2), desc2_3);
 		_mm256_store_si256((void *)txdp, desc0_1);
+__rte_diagnostic_pop
 	}
 
 	/* do any last ones */
drivers/net/i40e/i40e_rxtx_vec_avx512.c +12 -4
index 3b2750221b..b77989074f 100644
@@ -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 8
 
 static __rte_always_inline void
@@ -41,8 +37,11 @@ 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 */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	__m128i *rxdp_desc_0 = (void *)(&rxdp[desc_idx + 0].wb.qword2);
 	__m128i *rxdp_desc_1 = (void *)(&rxdp[desc_idx + 1].wb.qword2);
+__rte_diagnostic_pop
 	const __m128i desc_qw2_0 = _mm_load_si128(rxdp_desc_0);
 	const __m128i desc_qw2_1 = _mm_load_si128(rxdp_desc_1);
 
@@ -263,6 +262,8 @@ _recv_raw_pkts_vec_avx512(struct i40e_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 		__m256i raw_desc0_1, raw_desc2_3, raw_desc4_5, raw_desc6_7;
 
 		/* load in descriptors, in reverse order */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		const __m128i raw_desc7 =
 			_mm_load_si128((void *)(rxdp + 7));
 		rte_compiler_barrier();
@@ -286,6 +287,7 @@ _recv_raw_pkts_vec_avx512(struct i40e_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 		rte_compiler_barrier();
 		const __m128i raw_desc0 =
 			_mm_load_si128((void *)(rxdp + 0));
+__rte_diagnostic_pop
 
 		raw_desc6_7 =
 			_mm256_inserti128_si256
@@ -875,7 +877,10 @@ 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);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm_store_si128((__m128i *)txdp, descriptor);
+__rte_diagnostic_pop
 }
 
 static inline void
@@ -909,7 +914,10 @@ 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);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm512_storeu_si512((void *)txdp, desc0_3);
+__rte_diagnostic_pop
 	}
 
 	/* do any last ones */
drivers/net/i40e/i40e_rxtx_vec_common.h +0 -4
index 8b745630e4..ec59a68f9d 100644
@@ -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 +15 -3
index e1c5c7041b..cfc6d9ead3 100644
@@ -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,10 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				vst1q_u64((uint64_t *)&rxdp[i].read, zero);
+__rte_diagnostic_pop
 			}
 		}
 		rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
@@ -58,11 +58,14 @@ i40e_rxq_rearm(struct i40e_rx_queue *rxq)
 		dma_addr0 = vdupq_n_u64(paddr);
 
 		/* flush desc with pa dma_addr */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		vst1q_u64((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);
+__rte_diagnostic_pop
 	}
 
 	rxq->rxrearm_start += RTE_I40E_RXQ_REARM_THRESH;
@@ -87,10 +90,13 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	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);
+__rte_diagnostic_pop
 
 	/* FDIR ID data: move last u32 of each desc to 4 u32 lanes */
 	uint32x4_t v_unpack_02, v_unpack_13;
@@ -421,6 +427,8 @@ _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] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs[3] =  vld1q_u64((uint64_t *)(rxdp + 3));
 		descs[2] =  vld1q_u64((uint64_t *)(rxdp + 2));
 		descs[1] =  vld1q_u64((uint64_t *)(rxdp + 1));
@@ -433,6 +441,7 @@ _recv_raw_pkts_vec(struct i40e_rx_queue *__rte_restrict rxq,
 		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);
+__rte_diagnostic_pop
 
 		/* B.1 load 4 mbuf point */
 		mbp1 = vld1q_u64((uint64_t *)&sw_ring[pos]);
@@ -662,7 +671,10 @@ 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};
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	vst1q_u64((uint64_t *)txdp, descriptor);
+__rte_diagnostic_pop
 }
 
 static inline void
drivers/net/i40e/i40e_rxtx_vec_sse.c +18 -4
index ad560d2b6b..8a5537bcf2 100644
@@ -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,8 +37,11 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				_mm_store_si128((__m128i *)&rxdp[i].read,
 						dma_addr0);
+__rte_diagnostic_pop
 			}
 		}
 		rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
@@ -72,8 +71,11 @@ i40e_rxq_rearm(struct i40e_rx_queue *rxq)
 		dma_addr1 = _mm_add_epi64(dma_addr1, hdr_room);
 
 		/* flush desc with pa dma_addr */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr0);
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr1);
+__rte_diagnostic_pop
 	}
 
 	rxq->rxrearm_start += RTE_I40E_RXQ_REARM_THRESH;
@@ -97,10 +99,13 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	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);
+__rte_diagnostic_pop
 
 	/* FDIR ID data: move last u32 of each desc to 4 u32 lanes */
 	__m128i v_unpack_01, v_unpack_23;
@@ -462,7 +467,10 @@ _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] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs[3] = _mm_loadu_si128((__m128i *)(rxdp + 3));
+__rte_diagnostic_pop
 		rte_compiler_barrier();
 
 		/* B.2 copy 2 64 bit or 4 32 bit mbuf point into rx_pkts */
@@ -474,11 +482,14 @@ _recv_raw_pkts_vec(struct i40e_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 #endif
 
 		/* A.1 load desc[2-0] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs[2] = _mm_loadu_si128((__m128i *)(rxdp + 2));
 		rte_compiler_barrier();
 		descs[1] = _mm_loadu_si128((__m128i *)(rxdp + 1));
 		rte_compiler_barrier();
 		descs[0] = _mm_loadu_si128((__m128i *)(rxdp));
+__rte_diagnostic_pop
 
 #if defined(RTE_ARCH_X86_64)
 		/* B.2 copy 2 mbuf point into rx_pkts  */
@@ -681,7 +692,10 @@ vtx1(volatile struct i40e_tx_desc *txdp,
 
 	__m128i descriptor = _mm_set_epi64x(high_qw,
 				pkt->buf_iova + pkt->data_off);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm_store_si128((__m128i *)txdp, descriptor);
+__rte_diagnostic_pop
 }
 
 static inline void
drivers/net/iavf/iavf_rxtx_vec_avx2.c +16 -5
index 49d41af953..f5503d9dae 100644
@@ -6,10 +6,6 @@
 
 #include <rte_vect.h>
 
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
-
 static __rte_always_inline void
 iavf_rxq_rearm(struct iavf_rx_queue *rxq)
 {
@@ -193,6 +189,8 @@ _iavf_recv_raw_pkts_vec_avx2(struct iavf_rx_queue *rxq,
 			 _mm256_loadu_si256((void *)&sw_ring[i + 4]));
 #endif
 
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		const __m128i raw_desc7 = _mm_load_si128((void *)(rxdp + 7));
 		rte_compiler_barrier();
 		const __m128i raw_desc6 = _mm_load_si128((void *)(rxdp + 6));
@@ -208,6 +206,7 @@ _iavf_recv_raw_pkts_vec_avx2(struct iavf_rx_queue *rxq,
 		const __m128i raw_desc1 = _mm_load_si128((void *)(rxdp + 1));
 		rte_compiler_barrier();
 		const __m128i raw_desc0 = _mm_load_si128((void *)(rxdp + 0));
+__rte_diagnostic_pop
 
 		const __m256i raw_desc6_7 =
 			_mm256_inserti128_si256(_mm256_castsi128_si256(raw_desc6), raw_desc7, 1);
@@ -509,7 +508,7 @@ _iavf_recv_raw_pkts_vec_avx2_flex_rxd(struct iavf_rx_queue *rxq,
 			0, rxq->mbuf_initializer);
 	struct rte_mbuf **sw_ring = &rxq->sw_ring[rxq->rx_tail];
 	volatile union iavf_rx_flex_desc *rxdp =
-		(union iavf_rx_flex_desc *)rxq->rx_ring + rxq->rx_tail;
+		(volatile union iavf_rx_flex_desc *)rxq->rx_ring + rxq->rx_tail;
 
 	rte_prefetch0(rxdp);
 
@@ -742,6 +741,8 @@ _iavf_recv_raw_pkts_vec_avx2_flex_rxd(struct iavf_rx_queue *rxq,
 
 		__m256i raw_desc0_1, raw_desc2_3, raw_desc4_5, raw_desc6_7;
 
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		const __m128i raw_desc7 =
 			_mm_load_si128((void *)(rxdp + 7));
 		rte_compiler_barrier();
@@ -765,6 +766,7 @@ _iavf_recv_raw_pkts_vec_avx2_flex_rxd(struct iavf_rx_queue *rxq,
 		rte_compiler_barrier();
 		const __m128i raw_desc0 =
 			_mm_load_si128((void *)(rxdp + 0));
+__rte_diagnostic_pop
 
 		raw_desc6_7 =
 			_mm256_inserti128_si256
@@ -959,6 +961,8 @@ _iavf_recv_raw_pkts_vec_avx2_flex_rxd(struct iavf_rx_queue *rxq,
 				offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP ||
 			    rxq->rx_flags & IAVF_RX_FLAGS_VLAN_TAG_LOC_L2TAG2_2) {
 				/* load bottom half of every 32B desc */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				const __m128i raw_desc_bh7 =
 					_mm_load_si128
 						((void *)(&rxdp[7].wb.status_error1));
@@ -990,6 +994,7 @@ _iavf_recv_raw_pkts_vec_avx2_flex_rxd(struct iavf_rx_queue *rxq,
 				const __m128i raw_desc_bh0 =
 					_mm_load_si128
 						((void *)(&rxdp[0].wb.status_error1));
+__rte_diagnostic_pop
 
 				__m256i raw_desc_bh6_7 =
 					_mm256_inserti128_si256
@@ -1664,7 +1669,10 @@ iavf_vtx1(volatile struct iavf_tx_desc *txdp,
 
 	__m128i descriptor = _mm_set_epi64x(high_qw,
 				pkt->buf_iova + pkt->data_off);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm_store_si128((__m128i *)txdp, descriptor);
+__rte_diagnostic_pop
 }
 
 static __rte_always_inline void
@@ -1719,8 +1727,11 @@ iavf_vtx(volatile struct iavf_tx_desc *txdp,
 				 pkt[1]->buf_iova + pkt[1]->data_off,
 				 hi_qw0,
 				 pkt[0]->buf_iova + pkt[0]->data_off);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm256_store_si256((void *)(txdp + 2), desc2_3);
 		_mm256_store_si256((void *)txdp, desc0_1);
+__rte_diagnostic_pop
 	}
 
 	/* do any last ones */
drivers/net/iavf/iavf_rxtx_vec_avx512.c +22 -5
index d6a861bf80..04894debc8 100644
@@ -6,10 +6,6 @@
 
 #include <rte_vect.h>
 
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
-
 #define IAVF_DESCS_PER_LOOP_AVX 8
 #define PKTLEN_SHIFT 10
 
@@ -164,6 +160,8 @@ _iavf_recv_raw_pkts_vec_avx512(struct iavf_rx_queue *rxq,
 #endif
 
 		__m512i raw_desc0_3, raw_desc4_7;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		const __m128i raw_desc7 =
 			_mm_load_si128((void *)(rxdp + 7));
 		rte_compiler_barrier();
@@ -187,6 +185,7 @@ _iavf_recv_raw_pkts_vec_avx512(struct iavf_rx_queue *rxq,
 		rte_compiler_barrier();
 		const __m128i raw_desc0 =
 			_mm_load_si128((void *)(rxdp + 0));
+__rte_diagnostic_pop
 
 		raw_desc4_7 = _mm512_broadcast_i32x4(raw_desc4);
 		raw_desc4_7 = _mm512_inserti32x4(raw_desc4_7, raw_desc5, 1);
@@ -600,7 +599,7 @@ _iavf_recv_raw_pkts_vec_avx512_flex_rxd(struct iavf_rx_queue *rxq,
 						    rxq->mbuf_initializer);
 	struct rte_mbuf **sw_ring = &rxq->sw_ring[rxq->rx_tail];
 	volatile union iavf_rx_flex_desc *rxdp =
-		(union iavf_rx_flex_desc *)rxq->rx_ring + rxq->rx_tail;
+		(volatile union iavf_rx_flex_desc *)rxq->rx_ring + rxq->rx_tail;
 
 	rte_prefetch0(rxdp);
 
@@ -733,6 +732,8 @@ _iavf_recv_raw_pkts_vec_avx512_flex_rxd(struct iavf_rx_queue *rxq,
 
 		__m512i raw_desc0_3, raw_desc4_7;
 
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		const __m128i raw_desc7 =
 			_mm_load_si128((void *)(rxdp + 7));
 		rte_compiler_barrier();
@@ -756,6 +757,7 @@ _iavf_recv_raw_pkts_vec_avx512_flex_rxd(struct iavf_rx_queue *rxq,
 		rte_compiler_barrier();
 		const __m128i raw_desc0 =
 			_mm_load_si128((void *)(rxdp + 0));
+__rte_diagnostic_pop
 
 		raw_desc4_7 = _mm512_broadcast_i32x4(raw_desc4);
 		raw_desc4_7 = _mm512_inserti32x4(raw_desc4_7, raw_desc5, 1);
@@ -1111,6 +1113,8 @@ _iavf_recv_raw_pkts_vec_avx512_flex_rxd(struct iavf_rx_queue *rxq,
 				offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP ||
 			    rxq->rx_flags & IAVF_RX_FLAGS_VLAN_TAG_LOC_L2TAG2_2) {
 				/* load bottom half of every 32B desc */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				const __m128i raw_desc_bh7 =
 					_mm_load_si128
 						((void *)(&rxdp[7].wb.status_error1));
@@ -1142,6 +1146,7 @@ _iavf_recv_raw_pkts_vec_avx512_flex_rxd(struct iavf_rx_queue *rxq,
 				const __m128i raw_desc_bh0 =
 					_mm_load_si128
 						((void *)(&rxdp[0].wb.status_error1));
+__rte_diagnostic_pop
 
 				__m256i raw_desc_bh6_7 =
 					_mm256_inserti128_si256
@@ -1983,7 +1988,10 @@ iavf_vtx1(volatile struct iavf_tx_desc *txdp,
 
 	__m128i descriptor = _mm_set_epi64x(high_qw,
 					    pkt->buf_iova + pkt->data_off);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm_storeu_si128((__m128i *)txdp, descriptor);
+__rte_diagnostic_pop
 }
 
 #define IAVF_TX_LEN_MASK 0xAA
@@ -2037,7 +2045,10 @@ iavf_vtx(volatile struct iavf_tx_desc *txdp,
 				 pkt[1]->buf_iova + pkt[1]->data_off,
 				 hi_qw0,
 				 pkt[0]->buf_iova + pkt[0]->data_off);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm512_storeu_si512((void *)txdp, desc0_3);
+__rte_diagnostic_pop
 	}
 
 	/* do any last ones */
@@ -2225,7 +2236,10 @@ ctx_vtx1(volatile struct iavf_tx_desc *txdp, struct rte_mbuf *pkt,
 	__m256i ctx_data_desc = _mm256_set_epi64x(high_data_qw, pkt->buf_iova + pkt->data_off,
 							high_ctx_qw, low_ctx_qw);
 
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm256_storeu_si256((__m256i *)txdp, ctx_data_desc);
+__rte_diagnostic_pop
 }
 
 static __rte_always_inline void
@@ -2300,7 +2314,10 @@ ctx_vtx(volatile struct iavf_tx_desc *txdp,
 						hi_ctx_qw1, low_ctx_qw1,
 						hi_data_qw0, pkt[0]->buf_iova + pkt[0]->data_off,
 						hi_ctx_qw0, low_ctx_qw0);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm512_storeu_si512((void *)txdp, desc0_3);
+__rte_diagnostic_pop
 	}
 
 	if (nb_pkts)
drivers/net/iavf/iavf_rxtx_vec_common.h +6 -4
index 5c5220048d..690e0749e4 100644
@@ -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_t
 reassemble_packets(struct iavf_rx_queue *rxq, struct rte_mbuf **rx_bufs,
 		   uint16_t nb_bufs, uint8_t *split_flags)
@@ -422,8 +418,11 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				_mm_store_si128((__m128i *)&rxdp[i].read,
 						dma_addr0);
+__rte_diagnostic_pop
 			}
 		}
 		rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
@@ -458,8 +457,11 @@ 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 */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr0);
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr1);
+__rte_diagnostic_pop
 	}
 #else
 #ifdef CC_AVX512_SUPPORT
drivers/net/iavf/iavf_rxtx_vec_sse.c +25 -5
index 0db6fa8bd4..373df0c935 100644
@@ -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,8 +34,11 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				_mm_store_si128((__m128i *)&rxdp[i].read,
 						dma_addr0);
+__rte_diagnostic_pop
 			}
 		}
 		rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
@@ -69,8 +68,11 @@ iavf_rxq_rearm(struct iavf_rx_queue *rxq)
 		dma_addr1 = _mm_add_epi64(dma_addr1, hdr_room);
 
 		/* flush desc with pa dma_addr */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr0);
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr1);
+__rte_diagnostic_pop
 	}
 
 	rxq->rxrearm_start += rxq->rx_free_thresh;
@@ -578,7 +580,10 @@ _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] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs[3] = _mm_loadu_si128((__m128i *)(rxdp + 3));
+__rte_diagnostic_pop
 		rte_compiler_barrier();
 
 		/* B.2 copy 2 64 bit or 4 32 bit mbuf point into rx_pkts */
@@ -590,11 +595,14 @@ _recv_raw_pkts_vec(struct iavf_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 #endif
 
 		/* A.1 load desc[2-0] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs[2] = _mm_loadu_si128((__m128i *)(rxdp + 2));
 		rte_compiler_barrier();
 		descs[1] = _mm_loadu_si128((__m128i *)(rxdp + 1));
 		rte_compiler_barrier();
 		descs[0] = _mm_loadu_si128((__m128i *)(rxdp));
+__rte_diagnostic_pop
 
 #if defined(RTE_ARCH_X86_64)
 		/* B.2 copy 2 mbuf point into rx_pkts  */
@@ -783,7 +791,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 +872,10 @@ _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] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs[3] = _mm_loadu_si128((__m128i *)(rxdp + 3));
+__rte_diagnostic_pop
 		rte_compiler_barrier();
 
 		/* B.2 copy 2 64 bit or 4 32 bit mbuf point into rx_pkts */
@@ -876,11 +887,14 @@ _recv_raw_pkts_vec_flex_rxd(struct iavf_rx_queue *rxq,
 #endif
 
 		/* A.1 load desc[2-0] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs[2] = _mm_loadu_si128((__m128i *)(rxdp + 2));
 		rte_compiler_barrier();
 		descs[1] = _mm_loadu_si128((__m128i *)(rxdp + 1));
 		rte_compiler_barrier();
 		descs[0] = _mm_loadu_si128((__m128i *)(rxdp));
+__rte_diagnostic_pop
 
 #if defined(RTE_ARCH_X86_64)
 		/* B.2 copy 2 mbuf point into rx_pkts  */
@@ -927,6 +941,8 @@ _recv_raw_pkts_vec_flex_rxd(struct iavf_rx_queue *rxq,
 			offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP ||
 			rxq->rx_flags & IAVF_RX_FLAGS_VLAN_TAG_LOC_L2TAG2_2) {
 			/* load bottom half of every 32B desc */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 			descs_bh[3] = _mm_load_si128
 					((void *)(&rxdp[3].wb.status_error1));
 			rte_compiler_barrier();
@@ -938,6 +954,7 @@ _recv_raw_pkts_vec_flex_rxd(struct iavf_rx_queue *rxq,
 			rte_compiler_barrier();
 			descs_bh[0] = _mm_load_si128
 					((void *)(&rxdp[0].wb.status_error1));
+__rte_diagnostic_pop
 		}
 
 		if (offloads & RTE_ETH_RX_OFFLOAD_RSS_HASH) {
@@ -1349,7 +1366,10 @@ 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);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm_store_si128((__m128i *)txdp, descriptor);
+__rte_diagnostic_pop
 }
 
 static inline void
drivers/net/ice/ice_rxtx_common_avx.h +12 -4
index dacb87dcb0..b0d5232510 100644
@@ -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,8 +29,11 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				_mm_store_si128((__m128i *)&rxdp[i].read,
 						dma_addr0);
+__rte_diagnostic_pop
 			}
 		}
 		rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
@@ -77,8 +76,11 @@ 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 */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr0);
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr1);
+__rte_diagnostic_pop
 	}
 #else
 #ifdef __AVX512VL__
@@ -157,8 +159,11 @@ 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 */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 			_mm512_store_si512((__m512i *)&rxdp->read, dma_addr0_3);
 			_mm512_store_si512((__m512i *)&(rxdp + 4)->read, dma_addr4_7);
+__rte_diagnostic_pop
 		}
 	} else
 #endif /* __AVX512VL__ */
@@ -213,8 +218,11 @@ 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 */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 			_mm256_store_si256((__m256i *)&rxdp->read, dma_addr0_1);
 			_mm256_store_si256((__m256i *)&(rxdp + 2)->read, dma_addr2_3);
+__rte_diagnostic_pop
 		}
 	}
 
drivers/net/ice/ice_rxtx_vec_avx2.c +12 -4
index d6e88dbb29..6c6a810a15 100644
@@ -7,10 +7,6 @@
 
 #include <rte_vect.h>
 
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
-
 static __rte_always_inline void
 ice_rxq_rearm(struct ice_rx_queue *rxq)
 {
@@ -254,6 +250,8 @@ _ice_recv_raw_pkts_vec_avx2(struct ice_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 			 _mm256_loadu_si256((void *)&sw_ring[i + 4]));
 #endif
 
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		const __m128i raw_desc7 = _mm_load_si128((void *)(rxdp + 7));
 		rte_compiler_barrier();
 		const __m128i raw_desc6 = _mm_load_si128((void *)(rxdp + 6));
@@ -269,6 +267,7 @@ _ice_recv_raw_pkts_vec_avx2(struct ice_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 		const __m128i raw_desc1 = _mm_load_si128((void *)(rxdp + 1));
 		rte_compiler_barrier();
 		const __m128i raw_desc0 = _mm_load_si128((void *)(rxdp + 0));
+__rte_diagnostic_pop
 
 		const __m256i raw_desc6_7 =
 			_mm256_inserti128_si256(_mm256_castsi128_si256(raw_desc6), raw_desc7, 1);
@@ -444,6 +443,8 @@ _ice_recv_raw_pkts_vec_avx2(struct ice_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 			if (rxq->vsi->adapter->pf.dev_data->dev_conf.rxmode.offloads &
 					RTE_ETH_RX_OFFLOAD_RSS_HASH) {
 				/* load bottom half of every 32B desc */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				const __m128i raw_desc_bh7 =
 					_mm_load_si128
 						((void *)(&rxdp[7].wb.status_error1));
@@ -475,6 +476,7 @@ _ice_recv_raw_pkts_vec_avx2(struct ice_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 				const __m128i raw_desc_bh0 =
 					_mm_load_si128
 						((void *)(&rxdp[0].wb.status_error1));
+__rte_diagnostic_pop
 
 				__m256i raw_desc_bh6_7 =
 					_mm256_inserti128_si256
@@ -790,7 +792,10 @@ ice_vtx1(volatile struct ice_tx_desc *txdp,
 		ice_txd_enable_offload(pkt, &high_qw);
 
 	__m128i descriptor = _mm_set_epi64x(high_qw, rte_pktmbuf_iova(pkt));
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm_store_si128((__m128i *)txdp, descriptor);
+__rte_diagnostic_pop
 }
 
 static __rte_always_inline void
@@ -841,8 +846,11 @@ ice_vtx(volatile struct ice_tx_desc *txdp,
 			_mm256_set_epi64x
 				(hi_qw1, rte_pktmbuf_iova(pkt[1]),
 				 hi_qw0, rte_pktmbuf_iova(pkt[0]));
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm256_store_si256((void *)(txdp + 2), desc2_3);
 		_mm256_store_si256((void *)txdp, desc0_1);
+__rte_diagnostic_pop
 	}
 
 	/* do any last ones */
drivers/net/ice/ice_rxtx_vec_avx512.c +12 -4
index add095ef06..5a774550dc 100644
@@ -7,10 +7,6 @@
 
 #include <rte_vect.h>
 
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
-
 #define ICE_DESCS_PER_LOOP_AVX 8
 
 static __rte_always_inline void
@@ -243,6 +239,8 @@ _ice_recv_raw_pkts_vec_avx512(struct ice_rx_queue *rxq,
 		__m256i raw_desc0_1, raw_desc2_3, raw_desc4_5, raw_desc6_7;
 
 		/* load in descriptors, in reverse order */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		const __m128i raw_desc7 =
 			_mm_load_si128((void *)(rxdp + 7));
 		rte_compiler_barrier();
@@ -266,6 +264,7 @@ _ice_recv_raw_pkts_vec_avx512(struct ice_rx_queue *rxq,
 		rte_compiler_barrier();
 		const __m128i raw_desc0 =
 			_mm_load_si128((void *)(rxdp + 0));
+__rte_diagnostic_pop
 
 		raw_desc6_7 =
 			_mm256_inserti128_si256
@@ -474,6 +473,8 @@ _ice_recv_raw_pkts_vec_avx512(struct ice_rx_queue *rxq,
 			if (rxq->vsi->adapter->pf.dev_data->dev_conf.rxmode.offloads &
 					RTE_ETH_RX_OFFLOAD_RSS_HASH) {
 				/* load bottom half of every 32B desc */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				const __m128i raw_desc_bh7 =
 					_mm_load_si128
 						((void *)(&rxdp[7].wb.status_error1));
@@ -505,6 +506,7 @@ _ice_recv_raw_pkts_vec_avx512(struct ice_rx_queue *rxq,
 				const __m128i raw_desc_bh0 =
 					_mm_load_si128
 						((void *)(&rxdp[0].wb.status_error1));
+__rte_diagnostic_pop
 
 				__m256i raw_desc_bh6_7 =
 					_mm256_inserti128_si256
@@ -987,7 +989,10 @@ ice_vtx1(volatile struct ice_tx_desc *txdp,
 		ice_txd_enable_offload(pkt, &high_qw);
 
 	__m128i descriptor = _mm_set_epi64x(high_qw, rte_pktmbuf_iova(pkt));
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm_store_si128((__m128i *)txdp, descriptor);
+__rte_diagnostic_pop
 }
 
 static __rte_always_inline void
@@ -1029,7 +1034,10 @@ ice_vtx(volatile struct ice_tx_desc *txdp, struct rte_mbuf **pkt,
 				 hi_qw2, rte_pktmbuf_iova(pkt[2]),
 				 hi_qw1, rte_pktmbuf_iova(pkt[1]),
 				 hi_qw0, rte_pktmbuf_iova(pkt[0]));
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm512_storeu_si512((void *)txdp, desc0_3);
+__rte_diagnostic_pop
 	}
 
 	/* do any last ones */
drivers/net/ice/ice_rxtx_vec_common.h +0 -4
index 4b73465af5..45147decff 100644
@@ -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 +18 -4
index c01d8ede29..f2991cee1a 100644
@@ -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,8 +48,11 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				_mm_store_si128((__m128i *)&rxdp[i].read,
 						dma_addr0);
+__rte_diagnostic_pop
 			}
 		}
 		rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
@@ -91,8 +90,11 @@ ice_rxq_rearm(struct ice_rx_queue *rxq)
 		dma_addr1 = _mm_add_epi64(dma_addr1, hdr_room);
 
 		/* flush desc with pa dma_addr */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr0);
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr1);
+__rte_diagnostic_pop
 	}
 
 	rxq->rxrearm_start += ICE_RXQ_REARM_THRESH;
@@ -425,7 +427,10 @@ _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] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs[3] = _mm_loadu_si128((__m128i *)(rxdp + 3));
+__rte_diagnostic_pop
 		rte_compiler_barrier();
 
 		/* B.2 copy 2 64 bit or 4 32 bit mbuf point into rx_pkts */
@@ -437,11 +442,14 @@ _ice_recv_raw_pkts_vec(struct ice_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 #endif
 
 		/* A.1 load desc[2-0] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs[2] = _mm_loadu_si128((__m128i *)(rxdp + 2));
 		rte_compiler_barrier();
 		descs[1] = _mm_loadu_si128((__m128i *)(rxdp + 1));
 		rte_compiler_barrier();
 		descs[0] = _mm_loadu_si128((__m128i *)(rxdp));
+__rte_diagnostic_pop
 
 #if defined(RTE_ARCH_X86_64)
 		/* B.2 copy 2 mbuf point into rx_pkts  */
@@ -489,6 +497,8 @@ _ice_recv_raw_pkts_vec(struct ice_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 		if (rxq->vsi->adapter->pf.dev_data->dev_conf.rxmode.offloads &
 				RTE_ETH_RX_OFFLOAD_RSS_HASH) {
 			/* load bottom half of every 32B desc */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 			const __m128i raw_desc_bh3 =
 				_mm_load_si128
 					((void *)(&rxdp[3].wb.status_error1));
@@ -504,6 +514,7 @@ _ice_recv_raw_pkts_vec(struct ice_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 			const __m128i raw_desc_bh0 =
 				_mm_load_si128
 					((void *)(&rxdp[0].wb.status_error1));
+__rte_diagnostic_pop
 
 			/**
 			 * to shift the 32b RSS hash value to the
@@ -680,7 +691,10 @@ 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));
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm_store_si128((__m128i *)txdp, descriptor);
+__rte_diagnostic_pop
 }
 
 static inline void
drivers/net/idpf/idpf_rxtx_vec_common.h +0 -4
index 2787d27616..002c1e6948 100644
@@ -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
index d451562269..92a89f8def 100644
@@ -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 +0 -2
index 952b032eb6..4e7a64b39f 100644
@@ -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)
 {
drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c +15 -4
index a77370cdb7..8e4048a32f 100644
@@ -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,8 +37,11 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				_mm_store_si128((__m128i *)&rxdp[i].read,
 						dma_addr0);
+__rte_diagnostic_pop
 			}
 		}
 		rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
@@ -76,8 +75,11 @@ ixgbe_rxq_rearm(struct ixgbe_rx_queue *rxq)
 		dma_addr1 =  _mm_and_si128(dma_addr1, hba_msk);
 
 		/* flush desc with pa dma_addr */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr0);
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr1);
+__rte_diagnostic_pop
 	}
 
 	rxq->rxrearm_start += RTE_IXGBE_RXQ_REARM_THRESH;
@@ -466,7 +468,10 @@ _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] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs[3] = _mm_loadu_si128((__m128i *)(rxdp + 3));
+__rte_diagnostic_pop
 		rte_compiler_barrier();
 
 		/* B.2 copy 2 64 bit or 4 32 bit mbuf point into rx_pkts */
@@ -478,11 +483,14 @@ _recv_raw_pkts_vec(struct ixgbe_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 #endif
 
 		/* A.1 load desc[2-0] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs[2] = _mm_loadu_si128((__m128i *)(rxdp + 2));
 		rte_compiler_barrier();
 		descs[1] = _mm_loadu_si128((__m128i *)(rxdp + 1));
 		rte_compiler_barrier();
 		descs[0] = _mm_loadu_si128((__m128i *)(rxdp));
+__rte_diagnostic_pop
 
 #if defined(RTE_ARCH_X86_64)
 		/* B.2 copy 2 mbuf point into rx_pkts  */
@@ -676,7 +684,10 @@ 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);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm_store_si128((__m128i *)&txdp->read, descriptor);
+__rte_diagnostic_pop
 }
 
 static inline void
drivers/net/mlx5/mlx5_flow.c +3 -3
index 16ddd05448..0a89d2c414 100644
@@ -7287,10 +7287,10 @@ flow_tunnel_from_rule(const struct mlx5_flow *flow)
 {
 	struct mlx5_flow_tunnel *tunnel;
 
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wcast-qual"
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	tunnel = (typeof(tunnel))flow->tunnel;
-#pragma GCC diagnostic pop
+__rte_diagnostic_pop
 
 	return tunnel;
 }
drivers/net/mlx5/mlx5_rxtx_vec_altivec.h +0 -5
index 240987d03d..b37483bcca 100644
@@ -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 +0 -2
index dc1d30753d..e7deacc1fb 100644
@@ -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.
  *
drivers/net/mlx5/mlx5_rxtx_vec_sse.h +19 -7
index 81a177fce7..f4d08d5b30 100644
@@ -24,10 +24,6 @@
 #include "mlx5_rxtx_vec.h"
 #include "mlx5_autoconf.h"
 
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
-
 /**
  * Store free buffers to RX SW ring.
  *
@@ -75,7 +71,8 @@ static inline uint16_t
 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);
+	volatile struct mlx5_mini_cqe8 *mcq =
+		(volatile void *)(cq + !rxq->cqe_comp_layout);
 	/* Title packet is pre-built. */
 	struct rte_mbuf *t_pkt = rxq->cqe_comp_layout ? &rxq->title_pkt : elts[0];
 	unsigned int pos;
@@ -129,8 +126,11 @@ rxq_cq_decompress_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq,
 	 * E. store flow tag (rte_flow mark).
 	 */
 cycle:
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	if (rxq->cqe_comp_layout)
 		rte_prefetch0((void *)(cq + mcqe_n));
+__rte_diagnostic_pop
 	for (pos = 0; pos < mcqe_n; ) {
 		__m128i mcqe1, mcqe2;
 		__m128i rxdf1, rxdf2;
@@ -138,6 +138,8 @@ rxq_cq_decompress_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq,
 		__m128i byte_cnt, invalid_mask;
 #endif
 
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		if (!rxq->cqe_comp_layout)
 			for (i = 0; i < MLX5_VPMD_DESCS_PER_LOOP; ++i)
 				if (likely(pos + i < mcqe_n))
@@ -145,6 +147,7 @@ rxq_cq_decompress_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq,
 		/* A.1 load mCQEs into a 128bit register. */
 		mcqe1 = _mm_loadu_si128((__m128i *)&mcq[pos % 8]);
 		mcqe2 = _mm_loadu_si128((__m128i *)&mcq[pos % 8 + 2]);
+__rte_diagnostic_pop
 		/* B.1 store rearm data to mbuf. */
 		_mm_storeu_si128((__m128i *)&elts[pos]->rearm_data, rearm);
 		_mm_storeu_si128((__m128i *)&elts[pos + 1]->rearm_data, rearm);
@@ -354,9 +357,12 @@ rxq_cq_decompress_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq,
 		/* Move to next CQE and invalidate consumed CQEs. */
 		if (!rxq->cqe_comp_layout) {
 			if (!(pos & 0x7) && pos < mcqe_n) {
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				if (pos + 8 < mcqe_n)
 					rte_prefetch0((void *)(cq + pos + 8));
-				mcq = (void *)(cq + pos);
+__rte_diagnostic_pop
+				mcq = (volatile void *)(cq + pos);
 				for (i = 0; i < 8; ++i)
 					cq[inv++].op_own = MLX5_CQE_INVALIDATE;
 			}
@@ -371,7 +377,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 void *)cq;
 			mcqe_n = MLX5_CQE_NUM_MINIS(cq->op_own) + 1;
 			pkts_n += mcqe_n;
 			goto cycle;
@@ -651,6 +657,8 @@ rxq_cq_process_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq,
 		p = _mm_andnot_si128(mask, p);
 		/* A.1 load cqes. */
 		p3 = _mm_extract_epi16(p, 3);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		cqes[3] = _mm_loadl_epi64((__m128i *)
 					   &cq[pos + p3].sop_drop_qpn);
 		rte_compiler_barrier();
@@ -683,6 +691,7 @@ rxq_cq_process_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq,
 		cqes[2] = _mm_blend_epi16(cqes[2], cqe_tmp1, 0x30);
 		cqe_tmp2 = _mm_loadl_epi64((__m128i *)&cq[pos + p3].rsvd4[2]);
 		cqe_tmp1 = _mm_loadl_epi64((__m128i *)&cq[pos + p2].rsvd4[2]);
+__rte_diagnostic_pop
 		cqes[3] = _mm_blend_epi16(cqes[3], cqe_tmp2, 0x04);
 		cqes[2] = _mm_blend_epi16(cqes[2], cqe_tmp1, 0x04);
 		/* C.2 generate final structure for mbuf with swapping bytes. */
@@ -700,6 +709,8 @@ rxq_cq_process_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq,
 		/* E.1 extract op_own field. */
 		op_own_tmp2 = _mm_unpacklo_epi32(cqes[2], cqes[3]);
 		/* C.1 load remained CQE data and extract necessary fields. */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		cqe_tmp2 = _mm_load_si128((__m128i *)&cq[pos + p1]);
 		cqe_tmp1 = _mm_load_si128((__m128i *)&cq[pos]);
 		cqes[1] = _mm_blendv_epi8(cqes[1], cqe_tmp2, blend_mask);
@@ -710,6 +721,7 @@ rxq_cq_process_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq,
 		cqes[0] = _mm_blend_epi16(cqes[0], cqe_tmp1, 0x30);
 		cqe_tmp2 = _mm_loadl_epi64((__m128i *)&cq[pos + p1].rsvd4[2]);
 		cqe_tmp1 = _mm_loadl_epi64((__m128i *)&cq[pos].rsvd4[2]);
+__rte_diagnostic_pop
 		cqes[1] = _mm_blend_epi16(cqes[1], cqe_tmp2, 0x04);
 		cqes[0] = _mm_blend_epi16(cqes[0], cqe_tmp1, 0x04);
 		/* C.2 generate final structure for mbuf with swapping bytes. */
drivers/net/tap/tap_flow.c +3 -3
index c0e44bb1a7..373b773e2d 100644
@@ -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/virtio/virtio_rxtx_simple.c +0 -4
index 438256970d..439e00a7e1 100644
@@ -23,10 +23,6 @@
 
 #include "virtio_rxtx_simple.h"
 
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
-
 int __rte_cold
 virtio_rxq_vec_setup(struct virtnet_rx *rxq)
 {
Signature · 1 line
2.47.0.vfs.0.3
#23 lore raw

v6 cover add diagnostics macros to make code portable

In reply to Andre Muezerie

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.

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):
lib/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 | 46 +++++++++++++++++--
 drivers/net/axgbe/axgbe_rxtx.h                |  9 ----
 drivers/net/cpfl/cpfl_rxtx_vec_common.h       |  4 --
 drivers/net/dpaa2/dpaa2_rxtx.c                | 16 ++-----
 drivers/net/fm10k/fm10k_rxtx_vec.c            | 19 ++++++--
 drivers/net/hns3/hns3_rxtx_vec_neon.h         |  5 +-
 .../net/i40e/i40e_recycle_mbufs_vec_common.c  |  2 -
 drivers/net/i40e/i40e_rxtx_common_avx.h       | 16 +++++--
 drivers/net/i40e/i40e_rxtx_vec_altivec.c      | 17 ++++++-
 drivers/net/i40e/i40e_rxtx_vec_avx2.c         | 16 +++++--
 drivers/net/i40e/i40e_rxtx_vec_avx512.c       | 16 +++++--
 drivers/net/i40e/i40e_rxtx_vec_common.h       |  4 --
 drivers/net/i40e/i40e_rxtx_vec_neon.c         | 18 ++++++--
 drivers/net/i40e/i40e_rxtx_vec_sse.c          | 22 +++++++--
 drivers/net/iavf/iavf_rxtx_vec_avx2.c         | 21 +++++++--
 drivers/net/iavf/iavf_rxtx_vec_avx512.c       | 27 +++++++++--
 drivers/net/iavf/iavf_rxtx_vec_common.h       | 10 ++--
 drivers/net/iavf/iavf_rxtx_vec_neon.c         |  3 ++
 drivers/net/iavf/iavf_rxtx_vec_sse.c          | 30 ++++++++++--
 drivers/net/ice/ice_rxtx_common_avx.h         | 16 +++++--
 drivers/net/ice/ice_rxtx_vec_avx2.c           | 16 +++++--
 drivers/net/ice/ice_rxtx_vec_avx512.c         | 16 +++++--
 drivers/net/ice/ice_rxtx_vec_common.h         |  4 --
 drivers/net/ice/ice_rxtx_vec_sse.c            | 22 +++++++--
 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       |  2 -
 drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c        | 19 ++++++--
 drivers/net/mlx5/mlx5_flow.c                  |  6 +--
 drivers/net/mlx5/mlx5_rxtx_vec_altivec.h      |  5 --
 drivers/net/mlx5/mlx5_rxtx_vec_neon.h         |  2 -
 drivers/net/mlx5/mlx5_rxtx_vec_sse.h          | 26 ++++++++---
 drivers/net/tap/tap_flow.c                    |  6 +--
 drivers/net/virtio/virtio_rxtx_simple.c       |  4 --
 lib/eal/include/rte_common.h                  | 23 ++++++++++
 35 files changed, 336 insertions(+), 138 deletions(-)

--
2.47.0.vfs.0.3

#24 lore raw

PATCH v6 1/3 lib/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 | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
lib/eal/include/rte_common.h +23 -0
index 4d299f2b36..13b7b92f46 100644
@@ -137,6 +137,29 @@ typedef uint16_t unaligned_uint16_t;
 #define RTE_DEPRECATED(x)
 #endif
 
+/*
+ * Macro to ignore whenever a pointer is cast so as to remove 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
+
+/*
+ * 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
+
 /**
  * Mark a function or variable to a weak reference.
  */
Signature · 1 line
2.47.0.vfs.0.3
#25 lore raw

PATCH v6 2/3 drivers/common: add diagnostics macros to make code portable

In reply to Andre Muezerie

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.

---
 drivers/common/idpf/idpf_common_rxtx_avx512.c | 46 +++++++++++++++++--
 1 file changed, 42 insertions(+), 4 deletions(-)
drivers/common/idpf/idpf_common_rxtx_avx512.c +42 -4
index b8450b03ae..37cd0a43e2 100644
@@ -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,8 +30,11 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				_mm_store_si128((__m128i *)&rxdp[i].read,
 						dma_addr0);
+__rte_diagnostic_pop
 			}
 		}
 		rte_atomic_fetch_add_explicit(&rxq->rx_stats.mbuf_alloc_failed,
@@ -108,8 +107,11 @@ 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 */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm512_store_si512((__m512i *)&rxdp->read, dma_addr0_3);
 		_mm512_store_si512((__m512i *)&(rxdp + 4)->read, dma_addr4_7);
+__rte_diagnostic_pop
 	}
 
 	rxq->rxrearm_start += IDPF_RXQ_REARM_THRESH;
@@ -164,8 +166,11 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 					_mm_storeu_si128((__m128i *)&rxdp[i].read,
 							 dma_addr0);
+__rte_diagnostic_pop
 				}
 			}
 			rte_atomic_fetch_add_explicit(&rxq->rx_stats.mbuf_alloc_failed,
@@ -216,10 +221,13 @@ idpf_singleq_rearm(struct idpf_rx_queue *rxq)
 				 iovas1);
 		const __m512i desc6_7 = _mm512_bsrli_epi128(desc4_5, 8);
 
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_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);
+__rte_diagnostic_pop
 
 		rxp += IDPF_DESCS_PER_LOOP_AVX;
 		rxdp += IDPF_DESCS_PER_LOOP_AVX;
@@ -336,6 +344,8 @@ _idpf_singleq_recv_raw_pkts_avx512(struct idpf_rx_queue *rxq,
 #endif
 
 		__m512i raw_desc0_3, raw_desc4_7;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		const __m128i raw_desc7 =
 			_mm_load_si128((void *)(rxdp + 7));
 		rte_compiler_barrier();
@@ -359,6 +369,7 @@ _idpf_singleq_recv_raw_pkts_avx512(struct idpf_rx_queue *rxq,
 		rte_compiler_barrier();
 		const __m128i raw_desc0 =
 			_mm_load_si128((void *)(rxdp + 0));
+__rte_diagnostic_pop
 
 		raw_desc4_7 = _mm512_broadcast_i32x4(raw_desc4);
 		raw_desc4_7 = _mm512_inserti32x4(raw_desc4_7, raw_desc5, 1);
@@ -560,8 +571,11 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				_mm_store_si128((__m128i *)&rxdp[i],
 						dma_addr0);
+__rte_diagnostic_pop
 			}
 		}
 	rte_atomic_fetch_add_explicit(&rx_bufq->rx_stats.mbuf_alloc_failed,
@@ -634,8 +648,11 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 					_mm_storeu_si128((__m128i *)&rxdp[i],
 							 dma_addr0);
+__rte_diagnostic_pop
 				}
 			}
 		rte_atomic_fetch_add_explicit(&rx_bufq->rx_stats.mbuf_alloc_failed,
@@ -797,6 +814,8 @@ _idpf_splitq_recv_raw_pkts_avx512(struct idpf_rx_queue *rxq,
 #endif
 
 		__m512i raw_desc0_3, raw_desc4_7;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		const __m128i raw_desc7 =
 			_mm_load_si128((void *)(rxdp + 7));
 		rte_compiler_barrier();
@@ -820,6 +839,7 @@ _idpf_splitq_recv_raw_pkts_avx512(struct idpf_rx_queue *rxq,
 		rte_compiler_barrier();
 		const __m128i raw_desc0 =
 			_mm_load_si128((void *)(rxdp + 0));
+__rte_diagnostic_pop
 
 		raw_desc4_7 = _mm512_broadcast_i32x4(raw_desc4);
 		raw_desc4_7 = _mm512_inserti32x4(raw_desc4_7, raw_desc5, 1);
@@ -1131,7 +1151,10 @@ idpf_singleq_vtx1(volatile struct idpf_base_tx_desc *txdp,
 
 	__m128i descriptor = _mm_set_epi64x(high_qw,
 					    pkt->buf_iova + pkt->data_off);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm_storeu_si128((__m128i *)txdp, descriptor);
+__rte_diagnostic_pop
 }
 
 #define IDPF_TX_LEN_MASK 0xAA
@@ -1178,7 +1201,10 @@ 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);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm512_storeu_si512((void *)txdp, desc0_3);
+__rte_diagnostic_pop
 	}
 
 	/* do any last ones */
@@ -1435,7 +1461,10 @@ idpf_splitq_vtx1(volatile struct idpf_flex_tx_sched_desc *txdp,
 
 	__m128i descriptor = _mm_set_epi64x(high_qw,
 					    pkt->buf_iova + pkt->data_off);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm_storeu_si128((__m128i *)txdp, descriptor);
+__rte_diagnostic_pop
 }
 
 static __rte_always_inline void
@@ -1480,7 +1509,10 @@ 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);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm512_storeu_si512((void *)txdp, desc0_3);
+__rte_diagnostic_pop
 	}
 
 	/* do any last ones */
@@ -1521,11 +1553,14 @@ idpf_splitq_xmit_fixed_burst_vec_avx512(void *tx_queue, struct rte_mbuf **tx_pkt
 	if (nb_commit >= n) {
 		tx_backlog_entry_avx512(txep, tx_pkts, n);
 
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		idpf_splitq_vtx((void *)txdp, tx_pkts, n - 1, cmd_dtype);
 		tx_pkts += (n - 1);
 		txdp += (n - 1);
 
 		idpf_splitq_vtx1((void *)txdp, *tx_pkts++, cmd_dtype);
+__rte_diagnostic_pop
 
 		nb_commit = (uint16_t)(nb_commit - n);
 
@@ -1540,7 +1575,10 @@ idpf_splitq_xmit_fixed_burst_vec_avx512(void *tx_queue, struct rte_mbuf **tx_pkt
 
 	tx_backlog_entry_avx512(txep, tx_pkts, nb_commit);
 
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	idpf_splitq_vtx((void *)txdp, tx_pkts, nb_commit, cmd_dtype);
+__rte_diagnostic_pop
 
 	tx_id = (uint16_t)(tx_id + nb_commit);
 	if (tx_id > txq->next_rs)
Signature · 1 line
2.47.0.vfs.0.3
#26 lore raw

PATCH v6 3/3 drivers/net: add diagnostics macros to make code portable

In reply to Andre Muezerie

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.

---
 drivers/net/axgbe/axgbe_rxtx.h                |  9 ------
 drivers/net/cpfl/cpfl_rxtx_vec_common.h       |  4 ---
 drivers/net/dpaa2/dpaa2_rxtx.c                | 16 ++--------
 drivers/net/fm10k/fm10k_rxtx_vec.c            | 19 +++++++++---
 drivers/net/hns3/hns3_rxtx_vec_neon.h         |  5 ++--
 .../net/i40e/i40e_recycle_mbufs_vec_common.c  |  2 --
 drivers/net/i40e/i40e_rxtx_common_avx.h       | 16 +++++++---
 drivers/net/i40e/i40e_rxtx_vec_altivec.c      | 17 +++++++++--
 drivers/net/i40e/i40e_rxtx_vec_avx2.c         | 16 +++++++---
 drivers/net/i40e/i40e_rxtx_vec_avx512.c       | 16 +++++++---
 drivers/net/i40e/i40e_rxtx_vec_common.h       |  4 ---
 drivers/net/i40e/i40e_rxtx_vec_neon.c         | 18 +++++++++--
 drivers/net/i40e/i40e_rxtx_vec_sse.c          | 22 +++++++++++---
 drivers/net/iavf/iavf_rxtx_vec_avx2.c         | 21 +++++++++----
 drivers/net/iavf/iavf_rxtx_vec_avx512.c       | 27 +++++++++++++----
 drivers/net/iavf/iavf_rxtx_vec_common.h       | 10 ++++---
 drivers/net/iavf/iavf_rxtx_vec_neon.c         |  3 ++
 drivers/net/iavf/iavf_rxtx_vec_sse.c          | 30 +++++++++++++++----
 drivers/net/ice/ice_rxtx_common_avx.h         | 16 +++++++---
 drivers/net/ice/ice_rxtx_vec_avx2.c           | 16 +++++++---
 drivers/net/ice/ice_rxtx_vec_avx512.c         | 16 +++++++---
 drivers/net/ice/ice_rxtx_vec_common.h         |  4 ---
 drivers/net/ice/ice_rxtx_vec_sse.c            | 22 +++++++++++---
 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       |  2 --
 drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c        | 19 +++++++++---
 drivers/net/mlx5/mlx5_flow.c                  |  6 ++--
 drivers/net/mlx5/mlx5_rxtx_vec_altivec.h      |  5 ----
 drivers/net/mlx5/mlx5_rxtx_vec_neon.h         |  2 --
 drivers/net/mlx5/mlx5_rxtx_vec_sse.h          | 26 +++++++++++-----
 drivers/net/tap/tap_flow.c                    |  6 ++--
 drivers/net/virtio/virtio_rxtx_simple.c       |  4 ---
 33 files changed, 271 insertions(+), 134 deletions(-)
drivers/net/axgbe/axgbe_rxtx.h +0 -9
index a326ba9ac8..f5f74a0a39 100644
@@ -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
index 479e1ddcb9..5b98f86932 100644
@@ -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 +3 -13
index e3b6c7e460..21c306fd94 100644
@@ -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,10 @@ dpaa2_dev_loopback_rx(void *queue,
 			if (unlikely((status & QBMAN_DQ_STAT_VALIDFRAME) == 0))
 				continue;
 		}
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		fd[num_rx] = (struct qbman_fd *)qbman_result_DQ_fd(dq_storage);
+__rte_diagnostic_pop
 
 		dq_storage++;
 		num_rx++;
@@ -2118,8 +2113,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 +15 -4
index 68acaca75b..3d534a91ac 100644
@@ -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,11 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 			_mm_store_si128((__m128i *)&rxdp[i].q,
 						dma_addr0);
+__rte_diagnostic_pop
 		}
 
 		rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
@@ -316,8 +315,11 @@ fm10k_rxq_rearm(struct fm10k_rx_queue *rxq)
 		dma_addr1 = _mm_and_si128(dma_addr1, hba_msk);
 
 		/* flush desc with pa dma_addr */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm_store_si128((__m128i *)&rxdp++->q, dma_addr0);
 		_mm_store_si128((__m128i *)&rxdp++->q, dma_addr1);
+__rte_diagnostic_pop
 
 		/* enforce 512B alignment on default Rx virtual addresses */
 		mb0->data_off = (uint16_t)(RTE_PTR_ALIGN((char *)mb0->buf_addr
@@ -465,7 +467,10 @@ 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] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs0[3] = _mm_loadu_si128((__m128i *)(rxdp + 3));
+__rte_diagnostic_pop
 		rte_compiler_barrier();
 
 		/* B.2 copy 2 64 bit or 4 32 bit mbuf point into rx_pkts */
@@ -477,11 +482,14 @@ fm10k_recv_raw_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
 #endif
 
 		/* A.1 load desc[2-0] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs0[2] = _mm_loadu_si128((__m128i *)(rxdp + 2));
 		rte_compiler_barrier();
 		descs0[1] = _mm_loadu_si128((__m128i *)(rxdp + 1));
 		rte_compiler_barrier();
 		descs0[0] = _mm_loadu_si128((__m128i *)(rxdp));
+__rte_diagnostic_pop
 
 #if defined(RTE_ARCH_X86_64)
 		/* B.2 copy 2 mbuf point into rx_pkts  */
@@ -736,7 +744,10 @@ 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));
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm_store_si128((__m128i *)txdp, descriptor);
+__rte_diagnostic_pop
 }
 
 static inline void
drivers/net/hns3/hns3_rxtx_vec_neon.h +3 -2
index bbb5478015..99f080f3e8 100644
@@ -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,11 @@ hns3_vec_tx(volatile struct hns3_desc *desc, struct rte_mbuf *pkt)
 		0,
 		((uint64_t)HNS3_TXD_DEFAULT_VLD_FE_BDTYPE) << HNS3_UINT32_BIT
 	};
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	vst1q_u64((uint64_t *)&desc->addr, val1);
 	vst1q_u64((uint64_t *)&desc->tx.outer_vlan_tag, val2);
+__rte_diagnostic_pop
 }
 
 static uint16_t
drivers/net/i40e/i40e_recycle_mbufs_vec_common.c +0 -2
index 14424c9921..6eafe51e3d 100644
@@ -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 +12 -4
index 85958d6c81..bcabacf689 100644
@@ -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,8 +32,11 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				_mm_store_si128((__m128i *)&rxdp[i].read,
 						dma_addr0);
+__rte_diagnostic_pop
 			}
 		}
 		rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
@@ -72,8 +71,11 @@ 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 */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr0);
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr1);
+__rte_diagnostic_pop
 	}
 #else
 #ifdef __AVX512VL__
@@ -144,8 +146,11 @@ 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 */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 			_mm512_store_si512((__m512i *)&rxdp->read, dma_addr0_3);
 			_mm512_store_si512((__m512i *)&(rxdp + 4)->read, dma_addr4_7);
+__rte_diagnostic_pop
 		}
 	} else
 #endif /* __AVX512VL__*/
@@ -190,8 +195,11 @@ 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 */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 			_mm256_store_si256((__m256i *)&rxdp->read, dma_addr0_1);
 			_mm256_store_si256((__m256i *)&(rxdp + 2)->read, dma_addr2_3);
+__rte_diagnostic_pop
 		}
 	}
 
drivers/net/i40e/i40e_rxtx_vec_altivec.c +15 -2
index b6b0d38ec1..c5546132e9 100644
@@ -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)
 {
@@ -43,8 +41,11 @@ i40e_rxq_rearm(struct i40e_rx_queue *rxq)
 			dma_addr0 = (__vector unsigned long){};
 			for (i = 0; i < RTE_I40E_DESCS_PER_LOOP; i++) {
 				rxep[i].mbuf = &rxq->fake_mbuf;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				vec_st(dma_addr0, 0,
 				       (__vector unsigned long *)&rxdp[i].read);
+__rte_diagnostic_pop
 			}
 		}
 		rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
@@ -84,8 +85,11 @@ i40e_rxq_rearm(struct i40e_rx_queue *rxq)
 		dma_addr1 = vec_add(dma_addr1, hdr_room);
 
 		/* flush desc with pa dma_addr */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		vec_st(dma_addr0, 0, (__vector unsigned long *)&rxdp++->read);
 		vec_st(dma_addr1, 0, (__vector unsigned long *)&rxdp++->read);
+__rte_diagnostic_pop
 	}
 
 	rxq->rxrearm_start += RTE_I40E_RXQ_REARM_THRESH;
@@ -286,7 +290,10 @@ _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] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs[3] = *(__vector unsigned long *)(rxdp + 3);
+__rte_diagnostic_pop
 		rte_compiler_barrier();
 
 		/* B.2 copy 2 mbuf point into rx_pkts  */
@@ -296,11 +303,14 @@ _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] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs[2] = *(__vector unsigned long *)(rxdp + 2);
 		rte_compiler_barrier();
 		descs[1] = *(__vector unsigned long *)(rxdp + 1);
 		rte_compiler_barrier();
 		descs[0] = *(__vector unsigned long *)(rxdp);
+__rte_diagnostic_pop
 
 		/* B.2 copy 2 mbuf point into rx_pkts  */
 		*(__vector unsigned long *)&rx_pkts[pos + 2] =  mbp2;
@@ -534,7 +544,10 @@ vtx1(volatile struct i40e_tx_desc *txdp,
 
 	__vector unsigned long descriptor = (__vector unsigned long){
 		pkt->buf_iova + pkt->data_off, high_qw};
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	*(__vector unsigned long *)txdp = descriptor;
+__rte_diagnostic_pop
 }
 
 static inline void
drivers/net/i40e/i40e_rxtx_vec_avx2.c +12 -4
index 19cf0ac718..90a1d4661a 100644
@@ -15,10 +15,6 @@
 
 #include <rte_vect.h>
 
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
-
 static __rte_always_inline void
 i40e_rxq_rearm(struct i40e_rx_queue *rxq)
 {
@@ -39,8 +35,11 @@ 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 */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	__m128i *rxdp_desc_0 = (void *)(&rxdp[desc_idx + 0].wb.qword2);
 	__m128i *rxdp_desc_1 = (void *)(&rxdp[desc_idx + 1].wb.qword2);
+__rte_diagnostic_pop
 	const __m128i desc_qw2_0 = _mm_load_si128(rxdp_desc_0);
 	const __m128i desc_qw2_1 = _mm_load_si128(rxdp_desc_1);
 
@@ -276,6 +275,8 @@ _recv_raw_pkts_vec_avx2(struct i40e_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 				_mm256_loadu_si256((void *)&sw_ring[i + 4]));
 #endif
 
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		const __m128i raw_desc7 = _mm_load_si128((void *)(rxdp + 7));
 		rte_compiler_barrier();
 		const __m128i raw_desc6 = _mm_load_si128((void *)(rxdp + 6));
@@ -291,6 +292,7 @@ _recv_raw_pkts_vec_avx2(struct i40e_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 		const __m128i raw_desc1 = _mm_load_si128((void *)(rxdp + 1));
 		rte_compiler_barrier();
 		const __m128i raw_desc0 = _mm_load_si128((void *)(rxdp + 0));
+__rte_diagnostic_pop
 
 		const __m256i raw_desc6_7 = _mm256_inserti128_si256(
 				_mm256_castsi128_si256(raw_desc6), raw_desc7, 1);
@@ -695,7 +697,10 @@ vtx1(volatile struct i40e_tx_desc *txdp,
 
 	__m128i descriptor = _mm_set_epi64x(high_qw,
 				pkt->buf_iova + pkt->data_off);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm_store_si128((__m128i *)txdp, descriptor);
+__rte_diagnostic_pop
 }
 
 static inline void
@@ -728,8 +733,11 @@ 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);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm256_store_si256((void *)(txdp + 2), desc2_3);
 		_mm256_store_si256((void *)txdp, desc0_1);
+__rte_diagnostic_pop
 	}
 
 	/* do any last ones */
drivers/net/i40e/i40e_rxtx_vec_avx512.c +12 -4
index 3b2750221b..b77989074f 100644
@@ -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 8
 
 static __rte_always_inline void
@@ -41,8 +37,11 @@ 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 */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	__m128i *rxdp_desc_0 = (void *)(&rxdp[desc_idx + 0].wb.qword2);
 	__m128i *rxdp_desc_1 = (void *)(&rxdp[desc_idx + 1].wb.qword2);
+__rte_diagnostic_pop
 	const __m128i desc_qw2_0 = _mm_load_si128(rxdp_desc_0);
 	const __m128i desc_qw2_1 = _mm_load_si128(rxdp_desc_1);
 
@@ -263,6 +262,8 @@ _recv_raw_pkts_vec_avx512(struct i40e_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 		__m256i raw_desc0_1, raw_desc2_3, raw_desc4_5, raw_desc6_7;
 
 		/* load in descriptors, in reverse order */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		const __m128i raw_desc7 =
 			_mm_load_si128((void *)(rxdp + 7));
 		rte_compiler_barrier();
@@ -286,6 +287,7 @@ _recv_raw_pkts_vec_avx512(struct i40e_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 		rte_compiler_barrier();
 		const __m128i raw_desc0 =
 			_mm_load_si128((void *)(rxdp + 0));
+__rte_diagnostic_pop
 
 		raw_desc6_7 =
 			_mm256_inserti128_si256
@@ -875,7 +877,10 @@ 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);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm_store_si128((__m128i *)txdp, descriptor);
+__rte_diagnostic_pop
 }
 
 static inline void
@@ -909,7 +914,10 @@ 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);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm512_storeu_si512((void *)txdp, desc0_3);
+__rte_diagnostic_pop
 	}
 
 	/* do any last ones */
drivers/net/i40e/i40e_rxtx_vec_common.h +0 -4
index 8b745630e4..ec59a68f9d 100644
@@ -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 +15 -3
index e1c5c7041b..cfc6d9ead3 100644
@@ -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,10 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				vst1q_u64((uint64_t *)&rxdp[i].read, zero);
+__rte_diagnostic_pop
 			}
 		}
 		rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
@@ -58,11 +58,14 @@ i40e_rxq_rearm(struct i40e_rx_queue *rxq)
 		dma_addr0 = vdupq_n_u64(paddr);
 
 		/* flush desc with pa dma_addr */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		vst1q_u64((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);
+__rte_diagnostic_pop
 	}
 
 	rxq->rxrearm_start += RTE_I40E_RXQ_REARM_THRESH;
@@ -87,10 +90,13 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	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);
+__rte_diagnostic_pop
 
 	/* FDIR ID data: move last u32 of each desc to 4 u32 lanes */
 	uint32x4_t v_unpack_02, v_unpack_13;
@@ -421,6 +427,8 @@ _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] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs[3] =  vld1q_u64((uint64_t *)(rxdp + 3));
 		descs[2] =  vld1q_u64((uint64_t *)(rxdp + 2));
 		descs[1] =  vld1q_u64((uint64_t *)(rxdp + 1));
@@ -433,6 +441,7 @@ _recv_raw_pkts_vec(struct i40e_rx_queue *__rte_restrict rxq,
 		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);
+__rte_diagnostic_pop
 
 		/* B.1 load 4 mbuf point */
 		mbp1 = vld1q_u64((uint64_t *)&sw_ring[pos]);
@@ -662,7 +671,10 @@ 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};
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	vst1q_u64((uint64_t *)txdp, descriptor);
+__rte_diagnostic_pop
 }
 
 static inline void
drivers/net/i40e/i40e_rxtx_vec_sse.c +18 -4
index ad560d2b6b..8a5537bcf2 100644
@@ -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,8 +37,11 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				_mm_store_si128((__m128i *)&rxdp[i].read,
 						dma_addr0);
+__rte_diagnostic_pop
 			}
 		}
 		rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
@@ -72,8 +71,11 @@ i40e_rxq_rearm(struct i40e_rx_queue *rxq)
 		dma_addr1 = _mm_add_epi64(dma_addr1, hdr_room);
 
 		/* flush desc with pa dma_addr */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr0);
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr1);
+__rte_diagnostic_pop
 	}
 
 	rxq->rxrearm_start += RTE_I40E_RXQ_REARM_THRESH;
@@ -97,10 +99,13 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	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);
+__rte_diagnostic_pop
 
 	/* FDIR ID data: move last u32 of each desc to 4 u32 lanes */
 	__m128i v_unpack_01, v_unpack_23;
@@ -462,7 +467,10 @@ _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] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs[3] = _mm_loadu_si128((__m128i *)(rxdp + 3));
+__rte_diagnostic_pop
 		rte_compiler_barrier();
 
 		/* B.2 copy 2 64 bit or 4 32 bit mbuf point into rx_pkts */
@@ -474,11 +482,14 @@ _recv_raw_pkts_vec(struct i40e_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 #endif
 
 		/* A.1 load desc[2-0] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs[2] = _mm_loadu_si128((__m128i *)(rxdp + 2));
 		rte_compiler_barrier();
 		descs[1] = _mm_loadu_si128((__m128i *)(rxdp + 1));
 		rte_compiler_barrier();
 		descs[0] = _mm_loadu_si128((__m128i *)(rxdp));
+__rte_diagnostic_pop
 
 #if defined(RTE_ARCH_X86_64)
 		/* B.2 copy 2 mbuf point into rx_pkts  */
@@ -681,7 +692,10 @@ vtx1(volatile struct i40e_tx_desc *txdp,
 
 	__m128i descriptor = _mm_set_epi64x(high_qw,
 				pkt->buf_iova + pkt->data_off);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm_store_si128((__m128i *)txdp, descriptor);
+__rte_diagnostic_pop
 }
 
 static inline void
drivers/net/iavf/iavf_rxtx_vec_avx2.c +16 -5
index 49d41af953..f5503d9dae 100644
@@ -6,10 +6,6 @@
 
 #include <rte_vect.h>
 
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
-
 static __rte_always_inline void
 iavf_rxq_rearm(struct iavf_rx_queue *rxq)
 {
@@ -193,6 +189,8 @@ _iavf_recv_raw_pkts_vec_avx2(struct iavf_rx_queue *rxq,
 			 _mm256_loadu_si256((void *)&sw_ring[i + 4]));
 #endif
 
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		const __m128i raw_desc7 = _mm_load_si128((void *)(rxdp + 7));
 		rte_compiler_barrier();
 		const __m128i raw_desc6 = _mm_load_si128((void *)(rxdp + 6));
@@ -208,6 +206,7 @@ _iavf_recv_raw_pkts_vec_avx2(struct iavf_rx_queue *rxq,
 		const __m128i raw_desc1 = _mm_load_si128((void *)(rxdp + 1));
 		rte_compiler_barrier();
 		const __m128i raw_desc0 = _mm_load_si128((void *)(rxdp + 0));
+__rte_diagnostic_pop
 
 		const __m256i raw_desc6_7 =
 			_mm256_inserti128_si256(_mm256_castsi128_si256(raw_desc6), raw_desc7, 1);
@@ -509,7 +508,7 @@ _iavf_recv_raw_pkts_vec_avx2_flex_rxd(struct iavf_rx_queue *rxq,
 			0, rxq->mbuf_initializer);
 	struct rte_mbuf **sw_ring = &rxq->sw_ring[rxq->rx_tail];
 	volatile union iavf_rx_flex_desc *rxdp =
-		(union iavf_rx_flex_desc *)rxq->rx_ring + rxq->rx_tail;
+		(volatile union iavf_rx_flex_desc *)rxq->rx_ring + rxq->rx_tail;
 
 	rte_prefetch0(rxdp);
 
@@ -742,6 +741,8 @@ _iavf_recv_raw_pkts_vec_avx2_flex_rxd(struct iavf_rx_queue *rxq,
 
 		__m256i raw_desc0_1, raw_desc2_3, raw_desc4_5, raw_desc6_7;
 
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		const __m128i raw_desc7 =
 			_mm_load_si128((void *)(rxdp + 7));
 		rte_compiler_barrier();
@@ -765,6 +766,7 @@ _iavf_recv_raw_pkts_vec_avx2_flex_rxd(struct iavf_rx_queue *rxq,
 		rte_compiler_barrier();
 		const __m128i raw_desc0 =
 			_mm_load_si128((void *)(rxdp + 0));
+__rte_diagnostic_pop
 
 		raw_desc6_7 =
 			_mm256_inserti128_si256
@@ -959,6 +961,8 @@ _iavf_recv_raw_pkts_vec_avx2_flex_rxd(struct iavf_rx_queue *rxq,
 				offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP ||
 			    rxq->rx_flags & IAVF_RX_FLAGS_VLAN_TAG_LOC_L2TAG2_2) {
 				/* load bottom half of every 32B desc */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				const __m128i raw_desc_bh7 =
 					_mm_load_si128
 						((void *)(&rxdp[7].wb.status_error1));
@@ -990,6 +994,7 @@ _iavf_recv_raw_pkts_vec_avx2_flex_rxd(struct iavf_rx_queue *rxq,
 				const __m128i raw_desc_bh0 =
 					_mm_load_si128
 						((void *)(&rxdp[0].wb.status_error1));
+__rte_diagnostic_pop
 
 				__m256i raw_desc_bh6_7 =
 					_mm256_inserti128_si256
@@ -1664,7 +1669,10 @@ iavf_vtx1(volatile struct iavf_tx_desc *txdp,
 
 	__m128i descriptor = _mm_set_epi64x(high_qw,
 				pkt->buf_iova + pkt->data_off);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm_store_si128((__m128i *)txdp, descriptor);
+__rte_diagnostic_pop
 }
 
 static __rte_always_inline void
@@ -1719,8 +1727,11 @@ iavf_vtx(volatile struct iavf_tx_desc *txdp,
 				 pkt[1]->buf_iova + pkt[1]->data_off,
 				 hi_qw0,
 				 pkt[0]->buf_iova + pkt[0]->data_off);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm256_store_si256((void *)(txdp + 2), desc2_3);
 		_mm256_store_si256((void *)txdp, desc0_1);
+__rte_diagnostic_pop
 	}
 
 	/* do any last ones */
drivers/net/iavf/iavf_rxtx_vec_avx512.c +22 -5
index d6a861bf80..04894debc8 100644
@@ -6,10 +6,6 @@
 
 #include <rte_vect.h>
 
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
-
 #define IAVF_DESCS_PER_LOOP_AVX 8
 #define PKTLEN_SHIFT 10
 
@@ -164,6 +160,8 @@ _iavf_recv_raw_pkts_vec_avx512(struct iavf_rx_queue *rxq,
 #endif
 
 		__m512i raw_desc0_3, raw_desc4_7;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		const __m128i raw_desc7 =
 			_mm_load_si128((void *)(rxdp + 7));
 		rte_compiler_barrier();
@@ -187,6 +185,7 @@ _iavf_recv_raw_pkts_vec_avx512(struct iavf_rx_queue *rxq,
 		rte_compiler_barrier();
 		const __m128i raw_desc0 =
 			_mm_load_si128((void *)(rxdp + 0));
+__rte_diagnostic_pop
 
 		raw_desc4_7 = _mm512_broadcast_i32x4(raw_desc4);
 		raw_desc4_7 = _mm512_inserti32x4(raw_desc4_7, raw_desc5, 1);
@@ -600,7 +599,7 @@ _iavf_recv_raw_pkts_vec_avx512_flex_rxd(struct iavf_rx_queue *rxq,
 						    rxq->mbuf_initializer);
 	struct rte_mbuf **sw_ring = &rxq->sw_ring[rxq->rx_tail];
 	volatile union iavf_rx_flex_desc *rxdp =
-		(union iavf_rx_flex_desc *)rxq->rx_ring + rxq->rx_tail;
+		(volatile union iavf_rx_flex_desc *)rxq->rx_ring + rxq->rx_tail;
 
 	rte_prefetch0(rxdp);
 
@@ -733,6 +732,8 @@ _iavf_recv_raw_pkts_vec_avx512_flex_rxd(struct iavf_rx_queue *rxq,
 
 		__m512i raw_desc0_3, raw_desc4_7;
 
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		const __m128i raw_desc7 =
 			_mm_load_si128((void *)(rxdp + 7));
 		rte_compiler_barrier();
@@ -756,6 +757,7 @@ _iavf_recv_raw_pkts_vec_avx512_flex_rxd(struct iavf_rx_queue *rxq,
 		rte_compiler_barrier();
 		const __m128i raw_desc0 =
 			_mm_load_si128((void *)(rxdp + 0));
+__rte_diagnostic_pop
 
 		raw_desc4_7 = _mm512_broadcast_i32x4(raw_desc4);
 		raw_desc4_7 = _mm512_inserti32x4(raw_desc4_7, raw_desc5, 1);
@@ -1111,6 +1113,8 @@ _iavf_recv_raw_pkts_vec_avx512_flex_rxd(struct iavf_rx_queue *rxq,
 				offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP ||
 			    rxq->rx_flags & IAVF_RX_FLAGS_VLAN_TAG_LOC_L2TAG2_2) {
 				/* load bottom half of every 32B desc */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				const __m128i raw_desc_bh7 =
 					_mm_load_si128
 						((void *)(&rxdp[7].wb.status_error1));
@@ -1142,6 +1146,7 @@ _iavf_recv_raw_pkts_vec_avx512_flex_rxd(struct iavf_rx_queue *rxq,
 				const __m128i raw_desc_bh0 =
 					_mm_load_si128
 						((void *)(&rxdp[0].wb.status_error1));
+__rte_diagnostic_pop
 
 				__m256i raw_desc_bh6_7 =
 					_mm256_inserti128_si256
@@ -1983,7 +1988,10 @@ iavf_vtx1(volatile struct iavf_tx_desc *txdp,
 
 	__m128i descriptor = _mm_set_epi64x(high_qw,
 					    pkt->buf_iova + pkt->data_off);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm_storeu_si128((__m128i *)txdp, descriptor);
+__rte_diagnostic_pop
 }
 
 #define IAVF_TX_LEN_MASK 0xAA
@@ -2037,7 +2045,10 @@ iavf_vtx(volatile struct iavf_tx_desc *txdp,
 				 pkt[1]->buf_iova + pkt[1]->data_off,
 				 hi_qw0,
 				 pkt[0]->buf_iova + pkt[0]->data_off);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm512_storeu_si512((void *)txdp, desc0_3);
+__rte_diagnostic_pop
 	}
 
 	/* do any last ones */
@@ -2225,7 +2236,10 @@ ctx_vtx1(volatile struct iavf_tx_desc *txdp, struct rte_mbuf *pkt,
 	__m256i ctx_data_desc = _mm256_set_epi64x(high_data_qw, pkt->buf_iova + pkt->data_off,
 							high_ctx_qw, low_ctx_qw);
 
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm256_storeu_si256((__m256i *)txdp, ctx_data_desc);
+__rte_diagnostic_pop
 }
 
 static __rte_always_inline void
@@ -2300,7 +2314,10 @@ ctx_vtx(volatile struct iavf_tx_desc *txdp,
 						hi_ctx_qw1, low_ctx_qw1,
 						hi_data_qw0, pkt[0]->buf_iova + pkt[0]->data_off,
 						hi_ctx_qw0, low_ctx_qw0);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm512_storeu_si512((void *)txdp, desc0_3);
+__rte_diagnostic_pop
 	}
 
 	if (nb_pkts)
drivers/net/iavf/iavf_rxtx_vec_common.h +6 -4
index 5c5220048d..690e0749e4 100644
@@ -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_t
 reassemble_packets(struct iavf_rx_queue *rxq, struct rte_mbuf **rx_bufs,
 		   uint16_t nb_bufs, uint8_t *split_flags)
@@ -422,8 +418,11 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				_mm_store_si128((__m128i *)&rxdp[i].read,
 						dma_addr0);
+__rte_diagnostic_pop
 			}
 		}
 		rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
@@ -458,8 +457,11 @@ 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 */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr0);
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr1);
+__rte_diagnostic_pop
 	}
 #else
 #ifdef CC_AVX512_SUPPORT
drivers/net/iavf/iavf_rxtx_vec_neon.c +3 -0
index 04be574683..ab347938d2 100644
@@ -269,6 +269,8 @@ _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] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs[3] =  vld1q_u64((uint64_t *)(rxdp + 3));
 		descs[2] =  vld1q_u64((uint64_t *)(rxdp + 2));
 		descs[1] =  vld1q_u64((uint64_t *)(rxdp + 1));
@@ -281,6 +283,7 @@ _recv_raw_pkts_vec(struct iavf_rx_queue *__rte_restrict rxq,
 		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);
+__rte_diagnostic_pop
 
 		/* B.1 load 4 mbuf point */
 		mbp1 = vld1q_u64((uint64_t *)&sw_ring[pos]);
drivers/net/iavf/iavf_rxtx_vec_sse.c +25 -5
index 0db6fa8bd4..373df0c935 100644
@@ -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,8 +34,11 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				_mm_store_si128((__m128i *)&rxdp[i].read,
 						dma_addr0);
+__rte_diagnostic_pop
 			}
 		}
 		rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
@@ -69,8 +68,11 @@ iavf_rxq_rearm(struct iavf_rx_queue *rxq)
 		dma_addr1 = _mm_add_epi64(dma_addr1, hdr_room);
 
 		/* flush desc with pa dma_addr */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr0);
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr1);
+__rte_diagnostic_pop
 	}
 
 	rxq->rxrearm_start += rxq->rx_free_thresh;
@@ -578,7 +580,10 @@ _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] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs[3] = _mm_loadu_si128((__m128i *)(rxdp + 3));
+__rte_diagnostic_pop
 		rte_compiler_barrier();
 
 		/* B.2 copy 2 64 bit or 4 32 bit mbuf point into rx_pkts */
@@ -590,11 +595,14 @@ _recv_raw_pkts_vec(struct iavf_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 #endif
 
 		/* A.1 load desc[2-0] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs[2] = _mm_loadu_si128((__m128i *)(rxdp + 2));
 		rte_compiler_barrier();
 		descs[1] = _mm_loadu_si128((__m128i *)(rxdp + 1));
 		rte_compiler_barrier();
 		descs[0] = _mm_loadu_si128((__m128i *)(rxdp));
+__rte_diagnostic_pop
 
 #if defined(RTE_ARCH_X86_64)
 		/* B.2 copy 2 mbuf point into rx_pkts  */
@@ -783,7 +791,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 +872,10 @@ _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] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs[3] = _mm_loadu_si128((__m128i *)(rxdp + 3));
+__rte_diagnostic_pop
 		rte_compiler_barrier();
 
 		/* B.2 copy 2 64 bit or 4 32 bit mbuf point into rx_pkts */
@@ -876,11 +887,14 @@ _recv_raw_pkts_vec_flex_rxd(struct iavf_rx_queue *rxq,
 #endif
 
 		/* A.1 load desc[2-0] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs[2] = _mm_loadu_si128((__m128i *)(rxdp + 2));
 		rte_compiler_barrier();
 		descs[1] = _mm_loadu_si128((__m128i *)(rxdp + 1));
 		rte_compiler_barrier();
 		descs[0] = _mm_loadu_si128((__m128i *)(rxdp));
+__rte_diagnostic_pop
 
 #if defined(RTE_ARCH_X86_64)
 		/* B.2 copy 2 mbuf point into rx_pkts  */
@@ -927,6 +941,8 @@ _recv_raw_pkts_vec_flex_rxd(struct iavf_rx_queue *rxq,
 			offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP ||
 			rxq->rx_flags & IAVF_RX_FLAGS_VLAN_TAG_LOC_L2TAG2_2) {
 			/* load bottom half of every 32B desc */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 			descs_bh[3] = _mm_load_si128
 					((void *)(&rxdp[3].wb.status_error1));
 			rte_compiler_barrier();
@@ -938,6 +954,7 @@ _recv_raw_pkts_vec_flex_rxd(struct iavf_rx_queue *rxq,
 			rte_compiler_barrier();
 			descs_bh[0] = _mm_load_si128
 					((void *)(&rxdp[0].wb.status_error1));
+__rte_diagnostic_pop
 		}
 
 		if (offloads & RTE_ETH_RX_OFFLOAD_RSS_HASH) {
@@ -1349,7 +1366,10 @@ 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);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm_store_si128((__m128i *)txdp, descriptor);
+__rte_diagnostic_pop
 }
 
 static inline void
drivers/net/ice/ice_rxtx_common_avx.h +12 -4
index dacb87dcb0..b0d5232510 100644
@@ -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,8 +29,11 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				_mm_store_si128((__m128i *)&rxdp[i].read,
 						dma_addr0);
+__rte_diagnostic_pop
 			}
 		}
 		rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
@@ -77,8 +76,11 @@ 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 */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr0);
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr1);
+__rte_diagnostic_pop
 	}
 #else
 #ifdef __AVX512VL__
@@ -157,8 +159,11 @@ 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 */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 			_mm512_store_si512((__m512i *)&rxdp->read, dma_addr0_3);
 			_mm512_store_si512((__m512i *)&(rxdp + 4)->read, dma_addr4_7);
+__rte_diagnostic_pop
 		}
 	} else
 #endif /* __AVX512VL__ */
@@ -213,8 +218,11 @@ 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 */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 			_mm256_store_si256((__m256i *)&rxdp->read, dma_addr0_1);
 			_mm256_store_si256((__m256i *)&(rxdp + 2)->read, dma_addr2_3);
+__rte_diagnostic_pop
 		}
 	}
 
drivers/net/ice/ice_rxtx_vec_avx2.c +12 -4
index d6e88dbb29..6c6a810a15 100644
@@ -7,10 +7,6 @@
 
 #include <rte_vect.h>
 
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
-
 static __rte_always_inline void
 ice_rxq_rearm(struct ice_rx_queue *rxq)
 {
@@ -254,6 +250,8 @@ _ice_recv_raw_pkts_vec_avx2(struct ice_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 			 _mm256_loadu_si256((void *)&sw_ring[i + 4]));
 #endif
 
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		const __m128i raw_desc7 = _mm_load_si128((void *)(rxdp + 7));
 		rte_compiler_barrier();
 		const __m128i raw_desc6 = _mm_load_si128((void *)(rxdp + 6));
@@ -269,6 +267,7 @@ _ice_recv_raw_pkts_vec_avx2(struct ice_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 		const __m128i raw_desc1 = _mm_load_si128((void *)(rxdp + 1));
 		rte_compiler_barrier();
 		const __m128i raw_desc0 = _mm_load_si128((void *)(rxdp + 0));
+__rte_diagnostic_pop
 
 		const __m256i raw_desc6_7 =
 			_mm256_inserti128_si256(_mm256_castsi128_si256(raw_desc6), raw_desc7, 1);
@@ -444,6 +443,8 @@ _ice_recv_raw_pkts_vec_avx2(struct ice_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 			if (rxq->vsi->adapter->pf.dev_data->dev_conf.rxmode.offloads &
 					RTE_ETH_RX_OFFLOAD_RSS_HASH) {
 				/* load bottom half of every 32B desc */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				const __m128i raw_desc_bh7 =
 					_mm_load_si128
 						((void *)(&rxdp[7].wb.status_error1));
@@ -475,6 +476,7 @@ _ice_recv_raw_pkts_vec_avx2(struct ice_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 				const __m128i raw_desc_bh0 =
 					_mm_load_si128
 						((void *)(&rxdp[0].wb.status_error1));
+__rte_diagnostic_pop
 
 				__m256i raw_desc_bh6_7 =
 					_mm256_inserti128_si256
@@ -790,7 +792,10 @@ ice_vtx1(volatile struct ice_tx_desc *txdp,
 		ice_txd_enable_offload(pkt, &high_qw);
 
 	__m128i descriptor = _mm_set_epi64x(high_qw, rte_pktmbuf_iova(pkt));
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm_store_si128((__m128i *)txdp, descriptor);
+__rte_diagnostic_pop
 }
 
 static __rte_always_inline void
@@ -841,8 +846,11 @@ ice_vtx(volatile struct ice_tx_desc *txdp,
 			_mm256_set_epi64x
 				(hi_qw1, rte_pktmbuf_iova(pkt[1]),
 				 hi_qw0, rte_pktmbuf_iova(pkt[0]));
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm256_store_si256((void *)(txdp + 2), desc2_3);
 		_mm256_store_si256((void *)txdp, desc0_1);
+__rte_diagnostic_pop
 	}
 
 	/* do any last ones */
drivers/net/ice/ice_rxtx_vec_avx512.c +12 -4
index add095ef06..5a774550dc 100644
@@ -7,10 +7,6 @@
 
 #include <rte_vect.h>
 
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
-
 #define ICE_DESCS_PER_LOOP_AVX 8
 
 static __rte_always_inline void
@@ -243,6 +239,8 @@ _ice_recv_raw_pkts_vec_avx512(struct ice_rx_queue *rxq,
 		__m256i raw_desc0_1, raw_desc2_3, raw_desc4_5, raw_desc6_7;
 
 		/* load in descriptors, in reverse order */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		const __m128i raw_desc7 =
 			_mm_load_si128((void *)(rxdp + 7));
 		rte_compiler_barrier();
@@ -266,6 +264,7 @@ _ice_recv_raw_pkts_vec_avx512(struct ice_rx_queue *rxq,
 		rte_compiler_barrier();
 		const __m128i raw_desc0 =
 			_mm_load_si128((void *)(rxdp + 0));
+__rte_diagnostic_pop
 
 		raw_desc6_7 =
 			_mm256_inserti128_si256
@@ -474,6 +473,8 @@ _ice_recv_raw_pkts_vec_avx512(struct ice_rx_queue *rxq,
 			if (rxq->vsi->adapter->pf.dev_data->dev_conf.rxmode.offloads &
 					RTE_ETH_RX_OFFLOAD_RSS_HASH) {
 				/* load bottom half of every 32B desc */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				const __m128i raw_desc_bh7 =
 					_mm_load_si128
 						((void *)(&rxdp[7].wb.status_error1));
@@ -505,6 +506,7 @@ _ice_recv_raw_pkts_vec_avx512(struct ice_rx_queue *rxq,
 				const __m128i raw_desc_bh0 =
 					_mm_load_si128
 						((void *)(&rxdp[0].wb.status_error1));
+__rte_diagnostic_pop
 
 				__m256i raw_desc_bh6_7 =
 					_mm256_inserti128_si256
@@ -987,7 +989,10 @@ ice_vtx1(volatile struct ice_tx_desc *txdp,
 		ice_txd_enable_offload(pkt, &high_qw);
 
 	__m128i descriptor = _mm_set_epi64x(high_qw, rte_pktmbuf_iova(pkt));
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm_store_si128((__m128i *)txdp, descriptor);
+__rte_diagnostic_pop
 }
 
 static __rte_always_inline void
@@ -1029,7 +1034,10 @@ ice_vtx(volatile struct ice_tx_desc *txdp, struct rte_mbuf **pkt,
 				 hi_qw2, rte_pktmbuf_iova(pkt[2]),
 				 hi_qw1, rte_pktmbuf_iova(pkt[1]),
 				 hi_qw0, rte_pktmbuf_iova(pkt[0]));
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm512_storeu_si512((void *)txdp, desc0_3);
+__rte_diagnostic_pop
 	}
 
 	/* do any last ones */
drivers/net/ice/ice_rxtx_vec_common.h +0 -4
index 4b73465af5..45147decff 100644
@@ -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 +18 -4
index c01d8ede29..f2991cee1a 100644
@@ -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,8 +48,11 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				_mm_store_si128((__m128i *)&rxdp[i].read,
 						dma_addr0);
+__rte_diagnostic_pop
 			}
 		}
 		rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
@@ -91,8 +90,11 @@ ice_rxq_rearm(struct ice_rx_queue *rxq)
 		dma_addr1 = _mm_add_epi64(dma_addr1, hdr_room);
 
 		/* flush desc with pa dma_addr */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr0);
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr1);
+__rte_diagnostic_pop
 	}
 
 	rxq->rxrearm_start += ICE_RXQ_REARM_THRESH;
@@ -425,7 +427,10 @@ _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] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs[3] = _mm_loadu_si128((__m128i *)(rxdp + 3));
+__rte_diagnostic_pop
 		rte_compiler_barrier();
 
 		/* B.2 copy 2 64 bit or 4 32 bit mbuf point into rx_pkts */
@@ -437,11 +442,14 @@ _ice_recv_raw_pkts_vec(struct ice_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 #endif
 
 		/* A.1 load desc[2-0] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs[2] = _mm_loadu_si128((__m128i *)(rxdp + 2));
 		rte_compiler_barrier();
 		descs[1] = _mm_loadu_si128((__m128i *)(rxdp + 1));
 		rte_compiler_barrier();
 		descs[0] = _mm_loadu_si128((__m128i *)(rxdp));
+__rte_diagnostic_pop
 
 #if defined(RTE_ARCH_X86_64)
 		/* B.2 copy 2 mbuf point into rx_pkts  */
@@ -489,6 +497,8 @@ _ice_recv_raw_pkts_vec(struct ice_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 		if (rxq->vsi->adapter->pf.dev_data->dev_conf.rxmode.offloads &
 				RTE_ETH_RX_OFFLOAD_RSS_HASH) {
 			/* load bottom half of every 32B desc */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 			const __m128i raw_desc_bh3 =
 				_mm_load_si128
 					((void *)(&rxdp[3].wb.status_error1));
@@ -504,6 +514,7 @@ _ice_recv_raw_pkts_vec(struct ice_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 			const __m128i raw_desc_bh0 =
 				_mm_load_si128
 					((void *)(&rxdp[0].wb.status_error1));
+__rte_diagnostic_pop
 
 			/**
 			 * to shift the 32b RSS hash value to the
@@ -680,7 +691,10 @@ 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));
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm_store_si128((__m128i *)txdp, descriptor);
+__rte_diagnostic_pop
 }
 
 static inline void
drivers/net/idpf/idpf_rxtx_vec_common.h +0 -4
index 2787d27616..002c1e6948 100644
@@ -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
index d451562269..92a89f8def 100644
@@ -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 +0 -2
index 952b032eb6..4e7a64b39f 100644
@@ -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)
 {
drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c +15 -4
index a77370cdb7..8e4048a32f 100644
@@ -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,8 +37,11 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				_mm_store_si128((__m128i *)&rxdp[i].read,
 						dma_addr0);
+__rte_diagnostic_pop
 			}
 		}
 		rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
@@ -76,8 +75,11 @@ ixgbe_rxq_rearm(struct ixgbe_rx_queue *rxq)
 		dma_addr1 =  _mm_and_si128(dma_addr1, hba_msk);
 
 		/* flush desc with pa dma_addr */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr0);
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr1);
+__rte_diagnostic_pop
 	}
 
 	rxq->rxrearm_start += RTE_IXGBE_RXQ_REARM_THRESH;
@@ -466,7 +468,10 @@ _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] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs[3] = _mm_loadu_si128((__m128i *)(rxdp + 3));
+__rte_diagnostic_pop
 		rte_compiler_barrier();
 
 		/* B.2 copy 2 64 bit or 4 32 bit mbuf point into rx_pkts */
@@ -478,11 +483,14 @@ _recv_raw_pkts_vec(struct ixgbe_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 #endif
 
 		/* A.1 load desc[2-0] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs[2] = _mm_loadu_si128((__m128i *)(rxdp + 2));
 		rte_compiler_barrier();
 		descs[1] = _mm_loadu_si128((__m128i *)(rxdp + 1));
 		rte_compiler_barrier();
 		descs[0] = _mm_loadu_si128((__m128i *)(rxdp));
+__rte_diagnostic_pop
 
 #if defined(RTE_ARCH_X86_64)
 		/* B.2 copy 2 mbuf point into rx_pkts  */
@@ -676,7 +684,10 @@ 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);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm_store_si128((__m128i *)&txdp->read, descriptor);
+__rte_diagnostic_pop
 }
 
 static inline void
drivers/net/mlx5/mlx5_flow.c +3 -3
index 16ddd05448..0a89d2c414 100644
@@ -7287,10 +7287,10 @@ flow_tunnel_from_rule(const struct mlx5_flow *flow)
 {
 	struct mlx5_flow_tunnel *tunnel;
 
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wcast-qual"
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	tunnel = (typeof(tunnel))flow->tunnel;
-#pragma GCC diagnostic pop
+__rte_diagnostic_pop
 
 	return tunnel;
 }
drivers/net/mlx5/mlx5_rxtx_vec_altivec.h +0 -5
index 240987d03d..b37483bcca 100644
@@ -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 +0 -2
index dc1d30753d..e7deacc1fb 100644
@@ -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.
  *
drivers/net/mlx5/mlx5_rxtx_vec_sse.h +19 -7
index 81a177fce7..f4d08d5b30 100644
@@ -24,10 +24,6 @@
 #include "mlx5_rxtx_vec.h"
 #include "mlx5_autoconf.h"
 
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
-
 /**
  * Store free buffers to RX SW ring.
  *
@@ -75,7 +71,8 @@ static inline uint16_t
 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);
+	volatile struct mlx5_mini_cqe8 *mcq =
+		(volatile void *)(cq + !rxq->cqe_comp_layout);
 	/* Title packet is pre-built. */
 	struct rte_mbuf *t_pkt = rxq->cqe_comp_layout ? &rxq->title_pkt : elts[0];
 	unsigned int pos;
@@ -129,8 +126,11 @@ rxq_cq_decompress_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq,
 	 * E. store flow tag (rte_flow mark).
 	 */
 cycle:
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	if (rxq->cqe_comp_layout)
 		rte_prefetch0((void *)(cq + mcqe_n));
+__rte_diagnostic_pop
 	for (pos = 0; pos < mcqe_n; ) {
 		__m128i mcqe1, mcqe2;
 		__m128i rxdf1, rxdf2;
@@ -138,6 +138,8 @@ rxq_cq_decompress_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq,
 		__m128i byte_cnt, invalid_mask;
 #endif
 
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		if (!rxq->cqe_comp_layout)
 			for (i = 0; i < MLX5_VPMD_DESCS_PER_LOOP; ++i)
 				if (likely(pos + i < mcqe_n))
@@ -145,6 +147,7 @@ rxq_cq_decompress_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq,
 		/* A.1 load mCQEs into a 128bit register. */
 		mcqe1 = _mm_loadu_si128((__m128i *)&mcq[pos % 8]);
 		mcqe2 = _mm_loadu_si128((__m128i *)&mcq[pos % 8 + 2]);
+__rte_diagnostic_pop
 		/* B.1 store rearm data to mbuf. */
 		_mm_storeu_si128((__m128i *)&elts[pos]->rearm_data, rearm);
 		_mm_storeu_si128((__m128i *)&elts[pos + 1]->rearm_data, rearm);
@@ -354,9 +357,12 @@ rxq_cq_decompress_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq,
 		/* Move to next CQE and invalidate consumed CQEs. */
 		if (!rxq->cqe_comp_layout) {
 			if (!(pos & 0x7) && pos < mcqe_n) {
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				if (pos + 8 < mcqe_n)
 					rte_prefetch0((void *)(cq + pos + 8));
-				mcq = (void *)(cq + pos);
+__rte_diagnostic_pop
+				mcq = (volatile void *)(cq + pos);
 				for (i = 0; i < 8; ++i)
 					cq[inv++].op_own = MLX5_CQE_INVALIDATE;
 			}
@@ -371,7 +377,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 void *)cq;
 			mcqe_n = MLX5_CQE_NUM_MINIS(cq->op_own) + 1;
 			pkts_n += mcqe_n;
 			goto cycle;
@@ -651,6 +657,8 @@ rxq_cq_process_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq,
 		p = _mm_andnot_si128(mask, p);
 		/* A.1 load cqes. */
 		p3 = _mm_extract_epi16(p, 3);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		cqes[3] = _mm_loadl_epi64((__m128i *)
 					   &cq[pos + p3].sop_drop_qpn);
 		rte_compiler_barrier();
@@ -683,6 +691,7 @@ rxq_cq_process_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq,
 		cqes[2] = _mm_blend_epi16(cqes[2], cqe_tmp1, 0x30);
 		cqe_tmp2 = _mm_loadl_epi64((__m128i *)&cq[pos + p3].rsvd4[2]);
 		cqe_tmp1 = _mm_loadl_epi64((__m128i *)&cq[pos + p2].rsvd4[2]);
+__rte_diagnostic_pop
 		cqes[3] = _mm_blend_epi16(cqes[3], cqe_tmp2, 0x04);
 		cqes[2] = _mm_blend_epi16(cqes[2], cqe_tmp1, 0x04);
 		/* C.2 generate final structure for mbuf with swapping bytes. */
@@ -700,6 +709,8 @@ rxq_cq_process_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq,
 		/* E.1 extract op_own field. */
 		op_own_tmp2 = _mm_unpacklo_epi32(cqes[2], cqes[3]);
 		/* C.1 load remained CQE data and extract necessary fields. */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		cqe_tmp2 = _mm_load_si128((__m128i *)&cq[pos + p1]);
 		cqe_tmp1 = _mm_load_si128((__m128i *)&cq[pos]);
 		cqes[1] = _mm_blendv_epi8(cqes[1], cqe_tmp2, blend_mask);
@@ -710,6 +721,7 @@ rxq_cq_process_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq,
 		cqes[0] = _mm_blend_epi16(cqes[0], cqe_tmp1, 0x30);
 		cqe_tmp2 = _mm_loadl_epi64((__m128i *)&cq[pos + p1].rsvd4[2]);
 		cqe_tmp1 = _mm_loadl_epi64((__m128i *)&cq[pos].rsvd4[2]);
+__rte_diagnostic_pop
 		cqes[1] = _mm_blend_epi16(cqes[1], cqe_tmp2, 0x04);
 		cqes[0] = _mm_blend_epi16(cqes[0], cqe_tmp1, 0x04);
 		/* C.2 generate final structure for mbuf with swapping bytes. */
drivers/net/tap/tap_flow.c +3 -3
index c0e44bb1a7..373b773e2d 100644
@@ -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/virtio/virtio_rxtx_simple.c +0 -4
index 438256970d..439e00a7e1 100644
@@ -23,10 +23,6 @@
 
 #include "virtio_rxtx_simple.h"
 
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
-
 int __rte_cold
 virtio_rxq_vec_setup(struct virtnet_rx *rxq)
 {
Signature · 1 line
2.47.0.vfs.0.3
#27 lore raw

v7 cover add diagnostics macros to make code portable

In reply to Andre Muezerie

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.

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):
lib/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 | 46 +++++++++++++++++--
 drivers/net/axgbe/axgbe_rxtx.h                |  9 ----
 drivers/net/cpfl/cpfl_rxtx_vec_common.h       |  4 --
 drivers/net/dpaa2/dpaa2_rxtx.c                | 16 ++-----
 drivers/net/fm10k/fm10k_rxtx_vec.c            | 19 ++++++--
 drivers/net/hns3/hns3_rxtx_vec_neon.h         |  5 +-
 .../net/i40e/i40e_recycle_mbufs_vec_common.c  |  2 -
 drivers/net/i40e/i40e_rxtx_common_avx.h       | 16 +++++--
 drivers/net/i40e/i40e_rxtx_vec_altivec.c      | 17 ++++++-
 drivers/net/i40e/i40e_rxtx_vec_avx2.c         | 16 +++++--
 drivers/net/i40e/i40e_rxtx_vec_avx512.c       | 16 +++++--
 drivers/net/i40e/i40e_rxtx_vec_common.h       |  4 --
 drivers/net/i40e/i40e_rxtx_vec_neon.c         | 18 ++++++--
 drivers/net/i40e/i40e_rxtx_vec_sse.c          | 22 +++++++--
 drivers/net/iavf/iavf_rxtx_vec_avx2.c         | 21 +++++++--
 drivers/net/iavf/iavf_rxtx_vec_avx512.c       | 27 +++++++++--
 drivers/net/iavf/iavf_rxtx_vec_common.h       | 10 ++--
 drivers/net/iavf/iavf_rxtx_vec_neon.c         |  9 ++++
 drivers/net/iavf/iavf_rxtx_vec_sse.c          | 30 ++++++++++--
 drivers/net/ice/ice_rxtx_common_avx.h         | 16 +++++--
 drivers/net/ice/ice_rxtx_vec_avx2.c           | 16 +++++--
 drivers/net/ice/ice_rxtx_vec_avx512.c         | 16 +++++--
 drivers/net/ice/ice_rxtx_vec_common.h         |  4 --
 drivers/net/ice/ice_rxtx_vec_sse.c            | 22 +++++++--
 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       |  2 -
 drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c        | 19 ++++++--
 drivers/net/mlx5/mlx5_flow.c                  |  6 +--
 drivers/net/mlx5/mlx5_rxtx_vec_altivec.h      |  5 --
 drivers/net/mlx5/mlx5_rxtx_vec_neon.h         |  2 -
 drivers/net/mlx5/mlx5_rxtx_vec_sse.h          | 26 ++++++++---
 drivers/net/tap/tap_flow.c                    |  6 +--
 drivers/net/virtio/virtio_rxtx_simple.c       |  4 --
 lib/eal/include/rte_common.h                  | 23 ++++++++++
 35 files changed, 342 insertions(+), 138 deletions(-)

--
2.47.0.vfs.0.3

#28 lore raw

PATCH v7 1/3 lib/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 | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
lib/eal/include/rte_common.h +23 -0
index 4d299f2b36..13b7b92f46 100644
@@ -137,6 +137,29 @@ typedef uint16_t unaligned_uint16_t;
 #define RTE_DEPRECATED(x)
 #endif
 
+/*
+ * Macro to ignore whenever a pointer is cast so as to remove 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
+
+/*
+ * 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
+
 /**
  * Mark a function or variable to a weak reference.
  */
Signature · 1 line
2.47.0.vfs.0.3
#29 lore raw

PATCH v7 2/3 drivers/common: add diagnostics macros to make code portable

In reply to Andre Muezerie

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.

---
 drivers/common/idpf/idpf_common_rxtx_avx512.c | 46 +++++++++++++++++--
 1 file changed, 42 insertions(+), 4 deletions(-)
drivers/common/idpf/idpf_common_rxtx_avx512.c +42 -4
index b8450b03ae..37cd0a43e2 100644
@@ -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,8 +30,11 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				_mm_store_si128((__m128i *)&rxdp[i].read,
 						dma_addr0);
+__rte_diagnostic_pop
 			}
 		}
 		rte_atomic_fetch_add_explicit(&rxq->rx_stats.mbuf_alloc_failed,
@@ -108,8 +107,11 @@ 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 */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm512_store_si512((__m512i *)&rxdp->read, dma_addr0_3);
 		_mm512_store_si512((__m512i *)&(rxdp + 4)->read, dma_addr4_7);
+__rte_diagnostic_pop
 	}
 
 	rxq->rxrearm_start += IDPF_RXQ_REARM_THRESH;
@@ -164,8 +166,11 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 					_mm_storeu_si128((__m128i *)&rxdp[i].read,
 							 dma_addr0);
+__rte_diagnostic_pop
 				}
 			}
 			rte_atomic_fetch_add_explicit(&rxq->rx_stats.mbuf_alloc_failed,
@@ -216,10 +221,13 @@ idpf_singleq_rearm(struct idpf_rx_queue *rxq)
 				 iovas1);
 		const __m512i desc6_7 = _mm512_bsrli_epi128(desc4_5, 8);
 
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_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);
+__rte_diagnostic_pop
 
 		rxp += IDPF_DESCS_PER_LOOP_AVX;
 		rxdp += IDPF_DESCS_PER_LOOP_AVX;
@@ -336,6 +344,8 @@ _idpf_singleq_recv_raw_pkts_avx512(struct idpf_rx_queue *rxq,
 #endif
 
 		__m512i raw_desc0_3, raw_desc4_7;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		const __m128i raw_desc7 =
 			_mm_load_si128((void *)(rxdp + 7));
 		rte_compiler_barrier();
@@ -359,6 +369,7 @@ _idpf_singleq_recv_raw_pkts_avx512(struct idpf_rx_queue *rxq,
 		rte_compiler_barrier();
 		const __m128i raw_desc0 =
 			_mm_load_si128((void *)(rxdp + 0));
+__rte_diagnostic_pop
 
 		raw_desc4_7 = _mm512_broadcast_i32x4(raw_desc4);
 		raw_desc4_7 = _mm512_inserti32x4(raw_desc4_7, raw_desc5, 1);
@@ -560,8 +571,11 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				_mm_store_si128((__m128i *)&rxdp[i],
 						dma_addr0);
+__rte_diagnostic_pop
 			}
 		}
 	rte_atomic_fetch_add_explicit(&rx_bufq->rx_stats.mbuf_alloc_failed,
@@ -634,8 +648,11 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 					_mm_storeu_si128((__m128i *)&rxdp[i],
 							 dma_addr0);
+__rte_diagnostic_pop
 				}
 			}
 		rte_atomic_fetch_add_explicit(&rx_bufq->rx_stats.mbuf_alloc_failed,
@@ -797,6 +814,8 @@ _idpf_splitq_recv_raw_pkts_avx512(struct idpf_rx_queue *rxq,
 #endif
 
 		__m512i raw_desc0_3, raw_desc4_7;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		const __m128i raw_desc7 =
 			_mm_load_si128((void *)(rxdp + 7));
 		rte_compiler_barrier();
@@ -820,6 +839,7 @@ _idpf_splitq_recv_raw_pkts_avx512(struct idpf_rx_queue *rxq,
 		rte_compiler_barrier();
 		const __m128i raw_desc0 =
 			_mm_load_si128((void *)(rxdp + 0));
+__rte_diagnostic_pop
 
 		raw_desc4_7 = _mm512_broadcast_i32x4(raw_desc4);
 		raw_desc4_7 = _mm512_inserti32x4(raw_desc4_7, raw_desc5, 1);
@@ -1131,7 +1151,10 @@ idpf_singleq_vtx1(volatile struct idpf_base_tx_desc *txdp,
 
 	__m128i descriptor = _mm_set_epi64x(high_qw,
 					    pkt->buf_iova + pkt->data_off);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm_storeu_si128((__m128i *)txdp, descriptor);
+__rte_diagnostic_pop
 }
 
 #define IDPF_TX_LEN_MASK 0xAA
@@ -1178,7 +1201,10 @@ 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);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm512_storeu_si512((void *)txdp, desc0_3);
+__rte_diagnostic_pop
 	}
 
 	/* do any last ones */
@@ -1435,7 +1461,10 @@ idpf_splitq_vtx1(volatile struct idpf_flex_tx_sched_desc *txdp,
 
 	__m128i descriptor = _mm_set_epi64x(high_qw,
 					    pkt->buf_iova + pkt->data_off);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm_storeu_si128((__m128i *)txdp, descriptor);
+__rte_diagnostic_pop
 }
 
 static __rte_always_inline void
@@ -1480,7 +1509,10 @@ 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);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm512_storeu_si512((void *)txdp, desc0_3);
+__rte_diagnostic_pop
 	}
 
 	/* do any last ones */
@@ -1521,11 +1553,14 @@ idpf_splitq_xmit_fixed_burst_vec_avx512(void *tx_queue, struct rte_mbuf **tx_pkt
 	if (nb_commit >= n) {
 		tx_backlog_entry_avx512(txep, tx_pkts, n);
 
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		idpf_splitq_vtx((void *)txdp, tx_pkts, n - 1, cmd_dtype);
 		tx_pkts += (n - 1);
 		txdp += (n - 1);
 
 		idpf_splitq_vtx1((void *)txdp, *tx_pkts++, cmd_dtype);
+__rte_diagnostic_pop
 
 		nb_commit = (uint16_t)(nb_commit - n);
 
@@ -1540,7 +1575,10 @@ idpf_splitq_xmit_fixed_burst_vec_avx512(void *tx_queue, struct rte_mbuf **tx_pkt
 
 	tx_backlog_entry_avx512(txep, tx_pkts, nb_commit);
 
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	idpf_splitq_vtx((void *)txdp, tx_pkts, nb_commit, cmd_dtype);
+__rte_diagnostic_pop
 
 	tx_id = (uint16_t)(tx_id + nb_commit);
 	if (tx_id > txq->next_rs)
Signature · 1 line
2.47.0.vfs.0.3
#30 lore raw

PATCH v7 3/3 drivers/net: add diagnostics macros to make code portable

In reply to Andre Muezerie

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.

---
 drivers/net/axgbe/axgbe_rxtx.h                |  9 ------
 drivers/net/cpfl/cpfl_rxtx_vec_common.h       |  4 ---
 drivers/net/dpaa2/dpaa2_rxtx.c                | 16 ++--------
 drivers/net/fm10k/fm10k_rxtx_vec.c            | 19 +++++++++---
 drivers/net/hns3/hns3_rxtx_vec_neon.h         |  5 ++--
 .../net/i40e/i40e_recycle_mbufs_vec_common.c  |  2 --
 drivers/net/i40e/i40e_rxtx_common_avx.h       | 16 +++++++---
 drivers/net/i40e/i40e_rxtx_vec_altivec.c      | 17 +++++++++--
 drivers/net/i40e/i40e_rxtx_vec_avx2.c         | 16 +++++++---
 drivers/net/i40e/i40e_rxtx_vec_avx512.c       | 16 +++++++---
 drivers/net/i40e/i40e_rxtx_vec_common.h       |  4 ---
 drivers/net/i40e/i40e_rxtx_vec_neon.c         | 18 +++++++++--
 drivers/net/i40e/i40e_rxtx_vec_sse.c          | 22 +++++++++++---
 drivers/net/iavf/iavf_rxtx_vec_avx2.c         | 21 +++++++++----
 drivers/net/iavf/iavf_rxtx_vec_avx512.c       | 27 +++++++++++++----
 drivers/net/iavf/iavf_rxtx_vec_common.h       | 10 ++++---
 drivers/net/iavf/iavf_rxtx_vec_neon.c         |  9 ++++++
 drivers/net/iavf/iavf_rxtx_vec_sse.c          | 30 +++++++++++++++----
 drivers/net/ice/ice_rxtx_common_avx.h         | 16 +++++++---
 drivers/net/ice/ice_rxtx_vec_avx2.c           | 16 +++++++---
 drivers/net/ice/ice_rxtx_vec_avx512.c         | 16 +++++++---
 drivers/net/ice/ice_rxtx_vec_common.h         |  4 ---
 drivers/net/ice/ice_rxtx_vec_sse.c            | 22 +++++++++++---
 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       |  2 --
 drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c        | 19 +++++++++---
 drivers/net/mlx5/mlx5_flow.c                  |  6 ++--
 drivers/net/mlx5/mlx5_rxtx_vec_altivec.h      |  5 ----
 drivers/net/mlx5/mlx5_rxtx_vec_neon.h         |  2 --
 drivers/net/mlx5/mlx5_rxtx_vec_sse.h          | 26 +++++++++++-----
 drivers/net/tap/tap_flow.c                    |  6 ++--
 drivers/net/virtio/virtio_rxtx_simple.c       |  4 ---
 33 files changed, 277 insertions(+), 134 deletions(-)
drivers/net/axgbe/axgbe_rxtx.h +0 -9
index a326ba9ac8..f5f74a0a39 100644
@@ -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
index 479e1ddcb9..5b98f86932 100644
@@ -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 +3 -13
index e3b6c7e460..21c306fd94 100644
@@ -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,10 @@ dpaa2_dev_loopback_rx(void *queue,
 			if (unlikely((status & QBMAN_DQ_STAT_VALIDFRAME) == 0))
 				continue;
 		}
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		fd[num_rx] = (struct qbman_fd *)qbman_result_DQ_fd(dq_storage);
+__rte_diagnostic_pop
 
 		dq_storage++;
 		num_rx++;
@@ -2118,8 +2113,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 +15 -4
index 68acaca75b..3d534a91ac 100644
@@ -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,11 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 			_mm_store_si128((__m128i *)&rxdp[i].q,
 						dma_addr0);
+__rte_diagnostic_pop
 		}
 
 		rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
@@ -316,8 +315,11 @@ fm10k_rxq_rearm(struct fm10k_rx_queue *rxq)
 		dma_addr1 = _mm_and_si128(dma_addr1, hba_msk);
 
 		/* flush desc with pa dma_addr */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm_store_si128((__m128i *)&rxdp++->q, dma_addr0);
 		_mm_store_si128((__m128i *)&rxdp++->q, dma_addr1);
+__rte_diagnostic_pop
 
 		/* enforce 512B alignment on default Rx virtual addresses */
 		mb0->data_off = (uint16_t)(RTE_PTR_ALIGN((char *)mb0->buf_addr
@@ -465,7 +467,10 @@ 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] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs0[3] = _mm_loadu_si128((__m128i *)(rxdp + 3));
+__rte_diagnostic_pop
 		rte_compiler_barrier();
 
 		/* B.2 copy 2 64 bit or 4 32 bit mbuf point into rx_pkts */
@@ -477,11 +482,14 @@ fm10k_recv_raw_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
 #endif
 
 		/* A.1 load desc[2-0] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs0[2] = _mm_loadu_si128((__m128i *)(rxdp + 2));
 		rte_compiler_barrier();
 		descs0[1] = _mm_loadu_si128((__m128i *)(rxdp + 1));
 		rte_compiler_barrier();
 		descs0[0] = _mm_loadu_si128((__m128i *)(rxdp));
+__rte_diagnostic_pop
 
 #if defined(RTE_ARCH_X86_64)
 		/* B.2 copy 2 mbuf point into rx_pkts  */
@@ -736,7 +744,10 @@ 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));
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm_store_si128((__m128i *)txdp, descriptor);
+__rte_diagnostic_pop
 }
 
 static inline void
drivers/net/hns3/hns3_rxtx_vec_neon.h +3 -2
index bbb5478015..99f080f3e8 100644
@@ -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,11 @@ hns3_vec_tx(volatile struct hns3_desc *desc, struct rte_mbuf *pkt)
 		0,
 		((uint64_t)HNS3_TXD_DEFAULT_VLD_FE_BDTYPE) << HNS3_UINT32_BIT
 	};
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	vst1q_u64((uint64_t *)&desc->addr, val1);
 	vst1q_u64((uint64_t *)&desc->tx.outer_vlan_tag, val2);
+__rte_diagnostic_pop
 }
 
 static uint16_t
drivers/net/i40e/i40e_recycle_mbufs_vec_common.c +0 -2
index 14424c9921..6eafe51e3d 100644
@@ -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 +12 -4
index 85958d6c81..bcabacf689 100644
@@ -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,8 +32,11 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				_mm_store_si128((__m128i *)&rxdp[i].read,
 						dma_addr0);
+__rte_diagnostic_pop
 			}
 		}
 		rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
@@ -72,8 +71,11 @@ 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 */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr0);
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr1);
+__rte_diagnostic_pop
 	}
 #else
 #ifdef __AVX512VL__
@@ -144,8 +146,11 @@ 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 */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 			_mm512_store_si512((__m512i *)&rxdp->read, dma_addr0_3);
 			_mm512_store_si512((__m512i *)&(rxdp + 4)->read, dma_addr4_7);
+__rte_diagnostic_pop
 		}
 	} else
 #endif /* __AVX512VL__*/
@@ -190,8 +195,11 @@ 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 */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 			_mm256_store_si256((__m256i *)&rxdp->read, dma_addr0_1);
 			_mm256_store_si256((__m256i *)&(rxdp + 2)->read, dma_addr2_3);
+__rte_diagnostic_pop
 		}
 	}
 
drivers/net/i40e/i40e_rxtx_vec_altivec.c +15 -2
index b6b0d38ec1..c5546132e9 100644
@@ -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)
 {
@@ -43,8 +41,11 @@ i40e_rxq_rearm(struct i40e_rx_queue *rxq)
 			dma_addr0 = (__vector unsigned long){};
 			for (i = 0; i < RTE_I40E_DESCS_PER_LOOP; i++) {
 				rxep[i].mbuf = &rxq->fake_mbuf;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				vec_st(dma_addr0, 0,
 				       (__vector unsigned long *)&rxdp[i].read);
+__rte_diagnostic_pop
 			}
 		}
 		rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
@@ -84,8 +85,11 @@ i40e_rxq_rearm(struct i40e_rx_queue *rxq)
 		dma_addr1 = vec_add(dma_addr1, hdr_room);
 
 		/* flush desc with pa dma_addr */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		vec_st(dma_addr0, 0, (__vector unsigned long *)&rxdp++->read);
 		vec_st(dma_addr1, 0, (__vector unsigned long *)&rxdp++->read);
+__rte_diagnostic_pop
 	}
 
 	rxq->rxrearm_start += RTE_I40E_RXQ_REARM_THRESH;
@@ -286,7 +290,10 @@ _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] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs[3] = *(__vector unsigned long *)(rxdp + 3);
+__rte_diagnostic_pop
 		rte_compiler_barrier();
 
 		/* B.2 copy 2 mbuf point into rx_pkts  */
@@ -296,11 +303,14 @@ _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] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs[2] = *(__vector unsigned long *)(rxdp + 2);
 		rte_compiler_barrier();
 		descs[1] = *(__vector unsigned long *)(rxdp + 1);
 		rte_compiler_barrier();
 		descs[0] = *(__vector unsigned long *)(rxdp);
+__rte_diagnostic_pop
 
 		/* B.2 copy 2 mbuf point into rx_pkts  */
 		*(__vector unsigned long *)&rx_pkts[pos + 2] =  mbp2;
@@ -534,7 +544,10 @@ vtx1(volatile struct i40e_tx_desc *txdp,
 
 	__vector unsigned long descriptor = (__vector unsigned long){
 		pkt->buf_iova + pkt->data_off, high_qw};
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	*(__vector unsigned long *)txdp = descriptor;
+__rte_diagnostic_pop
 }
 
 static inline void
drivers/net/i40e/i40e_rxtx_vec_avx2.c +12 -4
index 19cf0ac718..90a1d4661a 100644
@@ -15,10 +15,6 @@
 
 #include <rte_vect.h>
 
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
-
 static __rte_always_inline void
 i40e_rxq_rearm(struct i40e_rx_queue *rxq)
 {
@@ -39,8 +35,11 @@ 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 */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	__m128i *rxdp_desc_0 = (void *)(&rxdp[desc_idx + 0].wb.qword2);
 	__m128i *rxdp_desc_1 = (void *)(&rxdp[desc_idx + 1].wb.qword2);
+__rte_diagnostic_pop
 	const __m128i desc_qw2_0 = _mm_load_si128(rxdp_desc_0);
 	const __m128i desc_qw2_1 = _mm_load_si128(rxdp_desc_1);
 
@@ -276,6 +275,8 @@ _recv_raw_pkts_vec_avx2(struct i40e_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 				_mm256_loadu_si256((void *)&sw_ring[i + 4]));
 #endif
 
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		const __m128i raw_desc7 = _mm_load_si128((void *)(rxdp + 7));
 		rte_compiler_barrier();
 		const __m128i raw_desc6 = _mm_load_si128((void *)(rxdp + 6));
@@ -291,6 +292,7 @@ _recv_raw_pkts_vec_avx2(struct i40e_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 		const __m128i raw_desc1 = _mm_load_si128((void *)(rxdp + 1));
 		rte_compiler_barrier();
 		const __m128i raw_desc0 = _mm_load_si128((void *)(rxdp + 0));
+__rte_diagnostic_pop
 
 		const __m256i raw_desc6_7 = _mm256_inserti128_si256(
 				_mm256_castsi128_si256(raw_desc6), raw_desc7, 1);
@@ -695,7 +697,10 @@ vtx1(volatile struct i40e_tx_desc *txdp,
 
 	__m128i descriptor = _mm_set_epi64x(high_qw,
 				pkt->buf_iova + pkt->data_off);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm_store_si128((__m128i *)txdp, descriptor);
+__rte_diagnostic_pop
 }
 
 static inline void
@@ -728,8 +733,11 @@ 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);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm256_store_si256((void *)(txdp + 2), desc2_3);
 		_mm256_store_si256((void *)txdp, desc0_1);
+__rte_diagnostic_pop
 	}
 
 	/* do any last ones */
drivers/net/i40e/i40e_rxtx_vec_avx512.c +12 -4
index 3b2750221b..b77989074f 100644
@@ -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 8
 
 static __rte_always_inline void
@@ -41,8 +37,11 @@ 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 */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	__m128i *rxdp_desc_0 = (void *)(&rxdp[desc_idx + 0].wb.qword2);
 	__m128i *rxdp_desc_1 = (void *)(&rxdp[desc_idx + 1].wb.qword2);
+__rte_diagnostic_pop
 	const __m128i desc_qw2_0 = _mm_load_si128(rxdp_desc_0);
 	const __m128i desc_qw2_1 = _mm_load_si128(rxdp_desc_1);
 
@@ -263,6 +262,8 @@ _recv_raw_pkts_vec_avx512(struct i40e_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 		__m256i raw_desc0_1, raw_desc2_3, raw_desc4_5, raw_desc6_7;
 
 		/* load in descriptors, in reverse order */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		const __m128i raw_desc7 =
 			_mm_load_si128((void *)(rxdp + 7));
 		rte_compiler_barrier();
@@ -286,6 +287,7 @@ _recv_raw_pkts_vec_avx512(struct i40e_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 		rte_compiler_barrier();
 		const __m128i raw_desc0 =
 			_mm_load_si128((void *)(rxdp + 0));
+__rte_diagnostic_pop
 
 		raw_desc6_7 =
 			_mm256_inserti128_si256
@@ -875,7 +877,10 @@ 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);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm_store_si128((__m128i *)txdp, descriptor);
+__rte_diagnostic_pop
 }
 
 static inline void
@@ -909,7 +914,10 @@ 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);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm512_storeu_si512((void *)txdp, desc0_3);
+__rte_diagnostic_pop
 	}
 
 	/* do any last ones */
drivers/net/i40e/i40e_rxtx_vec_common.h +0 -4
index 8b745630e4..ec59a68f9d 100644
@@ -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 +15 -3
index e1c5c7041b..cfc6d9ead3 100644
@@ -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,10 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				vst1q_u64((uint64_t *)&rxdp[i].read, zero);
+__rte_diagnostic_pop
 			}
 		}
 		rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
@@ -58,11 +58,14 @@ i40e_rxq_rearm(struct i40e_rx_queue *rxq)
 		dma_addr0 = vdupq_n_u64(paddr);
 
 		/* flush desc with pa dma_addr */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		vst1q_u64((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);
+__rte_diagnostic_pop
 	}
 
 	rxq->rxrearm_start += RTE_I40E_RXQ_REARM_THRESH;
@@ -87,10 +90,13 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	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);
+__rte_diagnostic_pop
 
 	/* FDIR ID data: move last u32 of each desc to 4 u32 lanes */
 	uint32x4_t v_unpack_02, v_unpack_13;
@@ -421,6 +427,8 @@ _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] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs[3] =  vld1q_u64((uint64_t *)(rxdp + 3));
 		descs[2] =  vld1q_u64((uint64_t *)(rxdp + 2));
 		descs[1] =  vld1q_u64((uint64_t *)(rxdp + 1));
@@ -433,6 +441,7 @@ _recv_raw_pkts_vec(struct i40e_rx_queue *__rte_restrict rxq,
 		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);
+__rte_diagnostic_pop
 
 		/* B.1 load 4 mbuf point */
 		mbp1 = vld1q_u64((uint64_t *)&sw_ring[pos]);
@@ -662,7 +671,10 @@ 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};
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	vst1q_u64((uint64_t *)txdp, descriptor);
+__rte_diagnostic_pop
 }
 
 static inline void
drivers/net/i40e/i40e_rxtx_vec_sse.c +18 -4
index ad560d2b6b..8a5537bcf2 100644
@@ -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,8 +37,11 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				_mm_store_si128((__m128i *)&rxdp[i].read,
 						dma_addr0);
+__rte_diagnostic_pop
 			}
 		}
 		rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
@@ -72,8 +71,11 @@ i40e_rxq_rearm(struct i40e_rx_queue *rxq)
 		dma_addr1 = _mm_add_epi64(dma_addr1, hdr_room);
 
 		/* flush desc with pa dma_addr */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr0);
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr1);
+__rte_diagnostic_pop
 	}
 
 	rxq->rxrearm_start += RTE_I40E_RXQ_REARM_THRESH;
@@ -97,10 +99,13 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	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);
+__rte_diagnostic_pop
 
 	/* FDIR ID data: move last u32 of each desc to 4 u32 lanes */
 	__m128i v_unpack_01, v_unpack_23;
@@ -462,7 +467,10 @@ _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] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs[3] = _mm_loadu_si128((__m128i *)(rxdp + 3));
+__rte_diagnostic_pop
 		rte_compiler_barrier();
 
 		/* B.2 copy 2 64 bit or 4 32 bit mbuf point into rx_pkts */
@@ -474,11 +482,14 @@ _recv_raw_pkts_vec(struct i40e_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 #endif
 
 		/* A.1 load desc[2-0] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs[2] = _mm_loadu_si128((__m128i *)(rxdp + 2));
 		rte_compiler_barrier();
 		descs[1] = _mm_loadu_si128((__m128i *)(rxdp + 1));
 		rte_compiler_barrier();
 		descs[0] = _mm_loadu_si128((__m128i *)(rxdp));
+__rte_diagnostic_pop
 
 #if defined(RTE_ARCH_X86_64)
 		/* B.2 copy 2 mbuf point into rx_pkts  */
@@ -681,7 +692,10 @@ vtx1(volatile struct i40e_tx_desc *txdp,
 
 	__m128i descriptor = _mm_set_epi64x(high_qw,
 				pkt->buf_iova + pkt->data_off);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm_store_si128((__m128i *)txdp, descriptor);
+__rte_diagnostic_pop
 }
 
 static inline void
drivers/net/iavf/iavf_rxtx_vec_avx2.c +16 -5
index 49d41af953..f5503d9dae 100644
@@ -6,10 +6,6 @@
 
 #include <rte_vect.h>
 
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
-
 static __rte_always_inline void
 iavf_rxq_rearm(struct iavf_rx_queue *rxq)
 {
@@ -193,6 +189,8 @@ _iavf_recv_raw_pkts_vec_avx2(struct iavf_rx_queue *rxq,
 			 _mm256_loadu_si256((void *)&sw_ring[i + 4]));
 #endif
 
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		const __m128i raw_desc7 = _mm_load_si128((void *)(rxdp + 7));
 		rte_compiler_barrier();
 		const __m128i raw_desc6 = _mm_load_si128((void *)(rxdp + 6));
@@ -208,6 +206,7 @@ _iavf_recv_raw_pkts_vec_avx2(struct iavf_rx_queue *rxq,
 		const __m128i raw_desc1 = _mm_load_si128((void *)(rxdp + 1));
 		rte_compiler_barrier();
 		const __m128i raw_desc0 = _mm_load_si128((void *)(rxdp + 0));
+__rte_diagnostic_pop
 
 		const __m256i raw_desc6_7 =
 			_mm256_inserti128_si256(_mm256_castsi128_si256(raw_desc6), raw_desc7, 1);
@@ -509,7 +508,7 @@ _iavf_recv_raw_pkts_vec_avx2_flex_rxd(struct iavf_rx_queue *rxq,
 			0, rxq->mbuf_initializer);
 	struct rte_mbuf **sw_ring = &rxq->sw_ring[rxq->rx_tail];
 	volatile union iavf_rx_flex_desc *rxdp =
-		(union iavf_rx_flex_desc *)rxq->rx_ring + rxq->rx_tail;
+		(volatile union iavf_rx_flex_desc *)rxq->rx_ring + rxq->rx_tail;
 
 	rte_prefetch0(rxdp);
 
@@ -742,6 +741,8 @@ _iavf_recv_raw_pkts_vec_avx2_flex_rxd(struct iavf_rx_queue *rxq,
 
 		__m256i raw_desc0_1, raw_desc2_3, raw_desc4_5, raw_desc6_7;
 
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		const __m128i raw_desc7 =
 			_mm_load_si128((void *)(rxdp + 7));
 		rte_compiler_barrier();
@@ -765,6 +766,7 @@ _iavf_recv_raw_pkts_vec_avx2_flex_rxd(struct iavf_rx_queue *rxq,
 		rte_compiler_barrier();
 		const __m128i raw_desc0 =
 			_mm_load_si128((void *)(rxdp + 0));
+__rte_diagnostic_pop
 
 		raw_desc6_7 =
 			_mm256_inserti128_si256
@@ -959,6 +961,8 @@ _iavf_recv_raw_pkts_vec_avx2_flex_rxd(struct iavf_rx_queue *rxq,
 				offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP ||
 			    rxq->rx_flags & IAVF_RX_FLAGS_VLAN_TAG_LOC_L2TAG2_2) {
 				/* load bottom half of every 32B desc */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				const __m128i raw_desc_bh7 =
 					_mm_load_si128
 						((void *)(&rxdp[7].wb.status_error1));
@@ -990,6 +994,7 @@ _iavf_recv_raw_pkts_vec_avx2_flex_rxd(struct iavf_rx_queue *rxq,
 				const __m128i raw_desc_bh0 =
 					_mm_load_si128
 						((void *)(&rxdp[0].wb.status_error1));
+__rte_diagnostic_pop
 
 				__m256i raw_desc_bh6_7 =
 					_mm256_inserti128_si256
@@ -1664,7 +1669,10 @@ iavf_vtx1(volatile struct iavf_tx_desc *txdp,
 
 	__m128i descriptor = _mm_set_epi64x(high_qw,
 				pkt->buf_iova + pkt->data_off);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm_store_si128((__m128i *)txdp, descriptor);
+__rte_diagnostic_pop
 }
 
 static __rte_always_inline void
@@ -1719,8 +1727,11 @@ iavf_vtx(volatile struct iavf_tx_desc *txdp,
 				 pkt[1]->buf_iova + pkt[1]->data_off,
 				 hi_qw0,
 				 pkt[0]->buf_iova + pkt[0]->data_off);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm256_store_si256((void *)(txdp + 2), desc2_3);
 		_mm256_store_si256((void *)txdp, desc0_1);
+__rte_diagnostic_pop
 	}
 
 	/* do any last ones */
drivers/net/iavf/iavf_rxtx_vec_avx512.c +22 -5
index d6a861bf80..04894debc8 100644
@@ -6,10 +6,6 @@
 
 #include <rte_vect.h>
 
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
-
 #define IAVF_DESCS_PER_LOOP_AVX 8
 #define PKTLEN_SHIFT 10
 
@@ -164,6 +160,8 @@ _iavf_recv_raw_pkts_vec_avx512(struct iavf_rx_queue *rxq,
 #endif
 
 		__m512i raw_desc0_3, raw_desc4_7;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		const __m128i raw_desc7 =
 			_mm_load_si128((void *)(rxdp + 7));
 		rte_compiler_barrier();
@@ -187,6 +185,7 @@ _iavf_recv_raw_pkts_vec_avx512(struct iavf_rx_queue *rxq,
 		rte_compiler_barrier();
 		const __m128i raw_desc0 =
 			_mm_load_si128((void *)(rxdp + 0));
+__rte_diagnostic_pop
 
 		raw_desc4_7 = _mm512_broadcast_i32x4(raw_desc4);
 		raw_desc4_7 = _mm512_inserti32x4(raw_desc4_7, raw_desc5, 1);
@@ -600,7 +599,7 @@ _iavf_recv_raw_pkts_vec_avx512_flex_rxd(struct iavf_rx_queue *rxq,
 						    rxq->mbuf_initializer);
 	struct rte_mbuf **sw_ring = &rxq->sw_ring[rxq->rx_tail];
 	volatile union iavf_rx_flex_desc *rxdp =
-		(union iavf_rx_flex_desc *)rxq->rx_ring + rxq->rx_tail;
+		(volatile union iavf_rx_flex_desc *)rxq->rx_ring + rxq->rx_tail;
 
 	rte_prefetch0(rxdp);
 
@@ -733,6 +732,8 @@ _iavf_recv_raw_pkts_vec_avx512_flex_rxd(struct iavf_rx_queue *rxq,
 
 		__m512i raw_desc0_3, raw_desc4_7;
 
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		const __m128i raw_desc7 =
 			_mm_load_si128((void *)(rxdp + 7));
 		rte_compiler_barrier();
@@ -756,6 +757,7 @@ _iavf_recv_raw_pkts_vec_avx512_flex_rxd(struct iavf_rx_queue *rxq,
 		rte_compiler_barrier();
 		const __m128i raw_desc0 =
 			_mm_load_si128((void *)(rxdp + 0));
+__rte_diagnostic_pop
 
 		raw_desc4_7 = _mm512_broadcast_i32x4(raw_desc4);
 		raw_desc4_7 = _mm512_inserti32x4(raw_desc4_7, raw_desc5, 1);
@@ -1111,6 +1113,8 @@ _iavf_recv_raw_pkts_vec_avx512_flex_rxd(struct iavf_rx_queue *rxq,
 				offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP ||
 			    rxq->rx_flags & IAVF_RX_FLAGS_VLAN_TAG_LOC_L2TAG2_2) {
 				/* load bottom half of every 32B desc */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				const __m128i raw_desc_bh7 =
 					_mm_load_si128
 						((void *)(&rxdp[7].wb.status_error1));
@@ -1142,6 +1146,7 @@ _iavf_recv_raw_pkts_vec_avx512_flex_rxd(struct iavf_rx_queue *rxq,
 				const __m128i raw_desc_bh0 =
 					_mm_load_si128
 						((void *)(&rxdp[0].wb.status_error1));
+__rte_diagnostic_pop
 
 				__m256i raw_desc_bh6_7 =
 					_mm256_inserti128_si256
@@ -1983,7 +1988,10 @@ iavf_vtx1(volatile struct iavf_tx_desc *txdp,
 
 	__m128i descriptor = _mm_set_epi64x(high_qw,
 					    pkt->buf_iova + pkt->data_off);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm_storeu_si128((__m128i *)txdp, descriptor);
+__rte_diagnostic_pop
 }
 
 #define IAVF_TX_LEN_MASK 0xAA
@@ -2037,7 +2045,10 @@ iavf_vtx(volatile struct iavf_tx_desc *txdp,
 				 pkt[1]->buf_iova + pkt[1]->data_off,
 				 hi_qw0,
 				 pkt[0]->buf_iova + pkt[0]->data_off);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm512_storeu_si512((void *)txdp, desc0_3);
+__rte_diagnostic_pop
 	}
 
 	/* do any last ones */
@@ -2225,7 +2236,10 @@ ctx_vtx1(volatile struct iavf_tx_desc *txdp, struct rte_mbuf *pkt,
 	__m256i ctx_data_desc = _mm256_set_epi64x(high_data_qw, pkt->buf_iova + pkt->data_off,
 							high_ctx_qw, low_ctx_qw);
 
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm256_storeu_si256((__m256i *)txdp, ctx_data_desc);
+__rte_diagnostic_pop
 }
 
 static __rte_always_inline void
@@ -2300,7 +2314,10 @@ ctx_vtx(volatile struct iavf_tx_desc *txdp,
 						hi_ctx_qw1, low_ctx_qw1,
 						hi_data_qw0, pkt[0]->buf_iova + pkt[0]->data_off,
 						hi_ctx_qw0, low_ctx_qw0);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm512_storeu_si512((void *)txdp, desc0_3);
+__rte_diagnostic_pop
 	}
 
 	if (nb_pkts)
drivers/net/iavf/iavf_rxtx_vec_common.h +6 -4
index 5c5220048d..690e0749e4 100644
@@ -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_t
 reassemble_packets(struct iavf_rx_queue *rxq, struct rte_mbuf **rx_bufs,
 		   uint16_t nb_bufs, uint8_t *split_flags)
@@ -422,8 +418,11 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				_mm_store_si128((__m128i *)&rxdp[i].read,
 						dma_addr0);
+__rte_diagnostic_pop
 			}
 		}
 		rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
@@ -458,8 +457,11 @@ 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 */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr0);
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr1);
+__rte_diagnostic_pop
 	}
 #else
 #ifdef CC_AVX512_SUPPORT
drivers/net/iavf/iavf_rxtx_vec_neon.c +9 -0
index 04be574683..5e723e1193 100644
@@ -36,7 +36,10 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				vst1q_u64((uint64_t *)&rxdp[i].read, zero);
+__rte_diagnostic_pop
 			}
 		}
 		rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
@@ -53,11 +56,14 @@ iavf_rxq_rearm(struct iavf_rx_queue *rxq)
 		dma_addr0 = vdupq_n_u64(paddr);
 
 		/* flush desc with pa dma_addr */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		vst1q_u64((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);
+__rte_diagnostic_pop
 	}
 
 	rxq->rxrearm_start += IAVF_RXQ_REARM_THRESH;
@@ -269,6 +275,8 @@ _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] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs[3] =  vld1q_u64((uint64_t *)(rxdp + 3));
 		descs[2] =  vld1q_u64((uint64_t *)(rxdp + 2));
 		descs[1] =  vld1q_u64((uint64_t *)(rxdp + 1));
@@ -281,6 +289,7 @@ _recv_raw_pkts_vec(struct iavf_rx_queue *__rte_restrict rxq,
 		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);
+__rte_diagnostic_pop
 
 		/* B.1 load 4 mbuf point */
 		mbp1 = vld1q_u64((uint64_t *)&sw_ring[pos]);
drivers/net/iavf/iavf_rxtx_vec_sse.c +25 -5
index 0db6fa8bd4..373df0c935 100644
@@ -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,8 +34,11 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				_mm_store_si128((__m128i *)&rxdp[i].read,
 						dma_addr0);
+__rte_diagnostic_pop
 			}
 		}
 		rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
@@ -69,8 +68,11 @@ iavf_rxq_rearm(struct iavf_rx_queue *rxq)
 		dma_addr1 = _mm_add_epi64(dma_addr1, hdr_room);
 
 		/* flush desc with pa dma_addr */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr0);
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr1);
+__rte_diagnostic_pop
 	}
 
 	rxq->rxrearm_start += rxq->rx_free_thresh;
@@ -578,7 +580,10 @@ _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] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs[3] = _mm_loadu_si128((__m128i *)(rxdp + 3));
+__rte_diagnostic_pop
 		rte_compiler_barrier();
 
 		/* B.2 copy 2 64 bit or 4 32 bit mbuf point into rx_pkts */
@@ -590,11 +595,14 @@ _recv_raw_pkts_vec(struct iavf_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 #endif
 
 		/* A.1 load desc[2-0] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs[2] = _mm_loadu_si128((__m128i *)(rxdp + 2));
 		rte_compiler_barrier();
 		descs[1] = _mm_loadu_si128((__m128i *)(rxdp + 1));
 		rte_compiler_barrier();
 		descs[0] = _mm_loadu_si128((__m128i *)(rxdp));
+__rte_diagnostic_pop
 
 #if defined(RTE_ARCH_X86_64)
 		/* B.2 copy 2 mbuf point into rx_pkts  */
@@ -783,7 +791,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 +872,10 @@ _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] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs[3] = _mm_loadu_si128((__m128i *)(rxdp + 3));
+__rte_diagnostic_pop
 		rte_compiler_barrier();
 
 		/* B.2 copy 2 64 bit or 4 32 bit mbuf point into rx_pkts */
@@ -876,11 +887,14 @@ _recv_raw_pkts_vec_flex_rxd(struct iavf_rx_queue *rxq,
 #endif
 
 		/* A.1 load desc[2-0] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs[2] = _mm_loadu_si128((__m128i *)(rxdp + 2));
 		rte_compiler_barrier();
 		descs[1] = _mm_loadu_si128((__m128i *)(rxdp + 1));
 		rte_compiler_barrier();
 		descs[0] = _mm_loadu_si128((__m128i *)(rxdp));
+__rte_diagnostic_pop
 
 #if defined(RTE_ARCH_X86_64)
 		/* B.2 copy 2 mbuf point into rx_pkts  */
@@ -927,6 +941,8 @@ _recv_raw_pkts_vec_flex_rxd(struct iavf_rx_queue *rxq,
 			offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP ||
 			rxq->rx_flags & IAVF_RX_FLAGS_VLAN_TAG_LOC_L2TAG2_2) {
 			/* load bottom half of every 32B desc */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 			descs_bh[3] = _mm_load_si128
 					((void *)(&rxdp[3].wb.status_error1));
 			rte_compiler_barrier();
@@ -938,6 +954,7 @@ _recv_raw_pkts_vec_flex_rxd(struct iavf_rx_queue *rxq,
 			rte_compiler_barrier();
 			descs_bh[0] = _mm_load_si128
 					((void *)(&rxdp[0].wb.status_error1));
+__rte_diagnostic_pop
 		}
 
 		if (offloads & RTE_ETH_RX_OFFLOAD_RSS_HASH) {
@@ -1349,7 +1366,10 @@ 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);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm_store_si128((__m128i *)txdp, descriptor);
+__rte_diagnostic_pop
 }
 
 static inline void
drivers/net/ice/ice_rxtx_common_avx.h +12 -4
index dacb87dcb0..b0d5232510 100644
@@ -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,8 +29,11 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				_mm_store_si128((__m128i *)&rxdp[i].read,
 						dma_addr0);
+__rte_diagnostic_pop
 			}
 		}
 		rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
@@ -77,8 +76,11 @@ 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 */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr0);
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr1);
+__rte_diagnostic_pop
 	}
 #else
 #ifdef __AVX512VL__
@@ -157,8 +159,11 @@ 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 */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 			_mm512_store_si512((__m512i *)&rxdp->read, dma_addr0_3);
 			_mm512_store_si512((__m512i *)&(rxdp + 4)->read, dma_addr4_7);
+__rte_diagnostic_pop
 		}
 	} else
 #endif /* __AVX512VL__ */
@@ -213,8 +218,11 @@ 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 */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 			_mm256_store_si256((__m256i *)&rxdp->read, dma_addr0_1);
 			_mm256_store_si256((__m256i *)&(rxdp + 2)->read, dma_addr2_3);
+__rte_diagnostic_pop
 		}
 	}
 
drivers/net/ice/ice_rxtx_vec_avx2.c +12 -4
index d6e88dbb29..6c6a810a15 100644
@@ -7,10 +7,6 @@
 
 #include <rte_vect.h>
 
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
-
 static __rte_always_inline void
 ice_rxq_rearm(struct ice_rx_queue *rxq)
 {
@@ -254,6 +250,8 @@ _ice_recv_raw_pkts_vec_avx2(struct ice_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 			 _mm256_loadu_si256((void *)&sw_ring[i + 4]));
 #endif
 
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		const __m128i raw_desc7 = _mm_load_si128((void *)(rxdp + 7));
 		rte_compiler_barrier();
 		const __m128i raw_desc6 = _mm_load_si128((void *)(rxdp + 6));
@@ -269,6 +267,7 @@ _ice_recv_raw_pkts_vec_avx2(struct ice_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 		const __m128i raw_desc1 = _mm_load_si128((void *)(rxdp + 1));
 		rte_compiler_barrier();
 		const __m128i raw_desc0 = _mm_load_si128((void *)(rxdp + 0));
+__rte_diagnostic_pop
 
 		const __m256i raw_desc6_7 =
 			_mm256_inserti128_si256(_mm256_castsi128_si256(raw_desc6), raw_desc7, 1);
@@ -444,6 +443,8 @@ _ice_recv_raw_pkts_vec_avx2(struct ice_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 			if (rxq->vsi->adapter->pf.dev_data->dev_conf.rxmode.offloads &
 					RTE_ETH_RX_OFFLOAD_RSS_HASH) {
 				/* load bottom half of every 32B desc */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				const __m128i raw_desc_bh7 =
 					_mm_load_si128
 						((void *)(&rxdp[7].wb.status_error1));
@@ -475,6 +476,7 @@ _ice_recv_raw_pkts_vec_avx2(struct ice_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 				const __m128i raw_desc_bh0 =
 					_mm_load_si128
 						((void *)(&rxdp[0].wb.status_error1));
+__rte_diagnostic_pop
 
 				__m256i raw_desc_bh6_7 =
 					_mm256_inserti128_si256
@@ -790,7 +792,10 @@ ice_vtx1(volatile struct ice_tx_desc *txdp,
 		ice_txd_enable_offload(pkt, &high_qw);
 
 	__m128i descriptor = _mm_set_epi64x(high_qw, rte_pktmbuf_iova(pkt));
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm_store_si128((__m128i *)txdp, descriptor);
+__rte_diagnostic_pop
 }
 
 static __rte_always_inline void
@@ -841,8 +846,11 @@ ice_vtx(volatile struct ice_tx_desc *txdp,
 			_mm256_set_epi64x
 				(hi_qw1, rte_pktmbuf_iova(pkt[1]),
 				 hi_qw0, rte_pktmbuf_iova(pkt[0]));
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm256_store_si256((void *)(txdp + 2), desc2_3);
 		_mm256_store_si256((void *)txdp, desc0_1);
+__rte_diagnostic_pop
 	}
 
 	/* do any last ones */
drivers/net/ice/ice_rxtx_vec_avx512.c +12 -4
index add095ef06..5a774550dc 100644
@@ -7,10 +7,6 @@
 
 #include <rte_vect.h>
 
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
-
 #define ICE_DESCS_PER_LOOP_AVX 8
 
 static __rte_always_inline void
@@ -243,6 +239,8 @@ _ice_recv_raw_pkts_vec_avx512(struct ice_rx_queue *rxq,
 		__m256i raw_desc0_1, raw_desc2_3, raw_desc4_5, raw_desc6_7;
 
 		/* load in descriptors, in reverse order */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		const __m128i raw_desc7 =
 			_mm_load_si128((void *)(rxdp + 7));
 		rte_compiler_barrier();
@@ -266,6 +264,7 @@ _ice_recv_raw_pkts_vec_avx512(struct ice_rx_queue *rxq,
 		rte_compiler_barrier();
 		const __m128i raw_desc0 =
 			_mm_load_si128((void *)(rxdp + 0));
+__rte_diagnostic_pop
 
 		raw_desc6_7 =
 			_mm256_inserti128_si256
@@ -474,6 +473,8 @@ _ice_recv_raw_pkts_vec_avx512(struct ice_rx_queue *rxq,
 			if (rxq->vsi->adapter->pf.dev_data->dev_conf.rxmode.offloads &
 					RTE_ETH_RX_OFFLOAD_RSS_HASH) {
 				/* load bottom half of every 32B desc */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				const __m128i raw_desc_bh7 =
 					_mm_load_si128
 						((void *)(&rxdp[7].wb.status_error1));
@@ -505,6 +506,7 @@ _ice_recv_raw_pkts_vec_avx512(struct ice_rx_queue *rxq,
 				const __m128i raw_desc_bh0 =
 					_mm_load_si128
 						((void *)(&rxdp[0].wb.status_error1));
+__rte_diagnostic_pop
 
 				__m256i raw_desc_bh6_7 =
 					_mm256_inserti128_si256
@@ -987,7 +989,10 @@ ice_vtx1(volatile struct ice_tx_desc *txdp,
 		ice_txd_enable_offload(pkt, &high_qw);
 
 	__m128i descriptor = _mm_set_epi64x(high_qw, rte_pktmbuf_iova(pkt));
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm_store_si128((__m128i *)txdp, descriptor);
+__rte_diagnostic_pop
 }
 
 static __rte_always_inline void
@@ -1029,7 +1034,10 @@ ice_vtx(volatile struct ice_tx_desc *txdp, struct rte_mbuf **pkt,
 				 hi_qw2, rte_pktmbuf_iova(pkt[2]),
 				 hi_qw1, rte_pktmbuf_iova(pkt[1]),
 				 hi_qw0, rte_pktmbuf_iova(pkt[0]));
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm512_storeu_si512((void *)txdp, desc0_3);
+__rte_diagnostic_pop
 	}
 
 	/* do any last ones */
drivers/net/ice/ice_rxtx_vec_common.h +0 -4
index 4b73465af5..45147decff 100644
@@ -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 +18 -4
index c01d8ede29..f2991cee1a 100644
@@ -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,8 +48,11 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				_mm_store_si128((__m128i *)&rxdp[i].read,
 						dma_addr0);
+__rte_diagnostic_pop
 			}
 		}
 		rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
@@ -91,8 +90,11 @@ ice_rxq_rearm(struct ice_rx_queue *rxq)
 		dma_addr1 = _mm_add_epi64(dma_addr1, hdr_room);
 
 		/* flush desc with pa dma_addr */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr0);
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr1);
+__rte_diagnostic_pop
 	}
 
 	rxq->rxrearm_start += ICE_RXQ_REARM_THRESH;
@@ -425,7 +427,10 @@ _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] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs[3] = _mm_loadu_si128((__m128i *)(rxdp + 3));
+__rte_diagnostic_pop
 		rte_compiler_barrier();
 
 		/* B.2 copy 2 64 bit or 4 32 bit mbuf point into rx_pkts */
@@ -437,11 +442,14 @@ _ice_recv_raw_pkts_vec(struct ice_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 #endif
 
 		/* A.1 load desc[2-0] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs[2] = _mm_loadu_si128((__m128i *)(rxdp + 2));
 		rte_compiler_barrier();
 		descs[1] = _mm_loadu_si128((__m128i *)(rxdp + 1));
 		rte_compiler_barrier();
 		descs[0] = _mm_loadu_si128((__m128i *)(rxdp));
+__rte_diagnostic_pop
 
 #if defined(RTE_ARCH_X86_64)
 		/* B.2 copy 2 mbuf point into rx_pkts  */
@@ -489,6 +497,8 @@ _ice_recv_raw_pkts_vec(struct ice_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 		if (rxq->vsi->adapter->pf.dev_data->dev_conf.rxmode.offloads &
 				RTE_ETH_RX_OFFLOAD_RSS_HASH) {
 			/* load bottom half of every 32B desc */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 			const __m128i raw_desc_bh3 =
 				_mm_load_si128
 					((void *)(&rxdp[3].wb.status_error1));
@@ -504,6 +514,7 @@ _ice_recv_raw_pkts_vec(struct ice_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 			const __m128i raw_desc_bh0 =
 				_mm_load_si128
 					((void *)(&rxdp[0].wb.status_error1));
+__rte_diagnostic_pop
 
 			/**
 			 * to shift the 32b RSS hash value to the
@@ -680,7 +691,10 @@ 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));
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm_store_si128((__m128i *)txdp, descriptor);
+__rte_diagnostic_pop
 }
 
 static inline void
drivers/net/idpf/idpf_rxtx_vec_common.h +0 -4
index 2787d27616..002c1e6948 100644
@@ -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
index d451562269..92a89f8def 100644
@@ -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 +0 -2
index 952b032eb6..4e7a64b39f 100644
@@ -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)
 {
drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c +15 -4
index a77370cdb7..8e4048a32f 100644
@@ -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,8 +37,11 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				_mm_store_si128((__m128i *)&rxdp[i].read,
 						dma_addr0);
+__rte_diagnostic_pop
 			}
 		}
 		rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
@@ -76,8 +75,11 @@ ixgbe_rxq_rearm(struct ixgbe_rx_queue *rxq)
 		dma_addr1 =  _mm_and_si128(dma_addr1, hba_msk);
 
 		/* flush desc with pa dma_addr */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr0);
 		_mm_store_si128((__m128i *)&rxdp++->read, dma_addr1);
+__rte_diagnostic_pop
 	}
 
 	rxq->rxrearm_start += RTE_IXGBE_RXQ_REARM_THRESH;
@@ -466,7 +468,10 @@ _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] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs[3] = _mm_loadu_si128((__m128i *)(rxdp + 3));
+__rte_diagnostic_pop
 		rte_compiler_barrier();
 
 		/* B.2 copy 2 64 bit or 4 32 bit mbuf point into rx_pkts */
@@ -478,11 +483,14 @@ _recv_raw_pkts_vec(struct ixgbe_rx_queue *rxq, struct rte_mbuf **rx_pkts,
 #endif
 
 		/* A.1 load desc[2-0] */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		descs[2] = _mm_loadu_si128((__m128i *)(rxdp + 2));
 		rte_compiler_barrier();
 		descs[1] = _mm_loadu_si128((__m128i *)(rxdp + 1));
 		rte_compiler_barrier();
 		descs[0] = _mm_loadu_si128((__m128i *)(rxdp));
+__rte_diagnostic_pop
 
 #if defined(RTE_ARCH_X86_64)
 		/* B.2 copy 2 mbuf point into rx_pkts  */
@@ -676,7 +684,10 @@ 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);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm_store_si128((__m128i *)&txdp->read, descriptor);
+__rte_diagnostic_pop
 }
 
 static inline void
drivers/net/mlx5/mlx5_flow.c +3 -3
index 16ddd05448..0a89d2c414 100644
@@ -7287,10 +7287,10 @@ flow_tunnel_from_rule(const struct mlx5_flow *flow)
 {
 	struct mlx5_flow_tunnel *tunnel;
 
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wcast-qual"
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	tunnel = (typeof(tunnel))flow->tunnel;
-#pragma GCC diagnostic pop
+__rte_diagnostic_pop
 
 	return tunnel;
 }
drivers/net/mlx5/mlx5_rxtx_vec_altivec.h +0 -5
index 240987d03d..b37483bcca 100644
@@ -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 +0 -2
index dc1d30753d..e7deacc1fb 100644
@@ -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.
  *
drivers/net/mlx5/mlx5_rxtx_vec_sse.h +19 -7
index 81a177fce7..f4d08d5b30 100644
@@ -24,10 +24,6 @@
 #include "mlx5_rxtx_vec.h"
 #include "mlx5_autoconf.h"
 
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
-
 /**
  * Store free buffers to RX SW ring.
  *
@@ -75,7 +71,8 @@ static inline uint16_t
 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);
+	volatile struct mlx5_mini_cqe8 *mcq =
+		(volatile void *)(cq + !rxq->cqe_comp_layout);
 	/* Title packet is pre-built. */
 	struct rte_mbuf *t_pkt = rxq->cqe_comp_layout ? &rxq->title_pkt : elts[0];
 	unsigned int pos;
@@ -129,8 +126,11 @@ rxq_cq_decompress_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq,
 	 * E. store flow tag (rte_flow mark).
 	 */
 cycle:
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	if (rxq->cqe_comp_layout)
 		rte_prefetch0((void *)(cq + mcqe_n));
+__rte_diagnostic_pop
 	for (pos = 0; pos < mcqe_n; ) {
 		__m128i mcqe1, mcqe2;
 		__m128i rxdf1, rxdf2;
@@ -138,6 +138,8 @@ rxq_cq_decompress_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq,
 		__m128i byte_cnt, invalid_mask;
 #endif
 
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		if (!rxq->cqe_comp_layout)
 			for (i = 0; i < MLX5_VPMD_DESCS_PER_LOOP; ++i)
 				if (likely(pos + i < mcqe_n))
@@ -145,6 +147,7 @@ rxq_cq_decompress_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq,
 		/* A.1 load mCQEs into a 128bit register. */
 		mcqe1 = _mm_loadu_si128((__m128i *)&mcq[pos % 8]);
 		mcqe2 = _mm_loadu_si128((__m128i *)&mcq[pos % 8 + 2]);
+__rte_diagnostic_pop
 		/* B.1 store rearm data to mbuf. */
 		_mm_storeu_si128((__m128i *)&elts[pos]->rearm_data, rearm);
 		_mm_storeu_si128((__m128i *)&elts[pos + 1]->rearm_data, rearm);
@@ -354,9 +357,12 @@ rxq_cq_decompress_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq,
 		/* Move to next CQE and invalidate consumed CQEs. */
 		if (!rxq->cqe_comp_layout) {
 			if (!(pos & 0x7) && pos < mcqe_n) {
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				if (pos + 8 < mcqe_n)
 					rte_prefetch0((void *)(cq + pos + 8));
-				mcq = (void *)(cq + pos);
+__rte_diagnostic_pop
+				mcq = (volatile void *)(cq + pos);
 				for (i = 0; i < 8; ++i)
 					cq[inv++].op_own = MLX5_CQE_INVALIDATE;
 			}
@@ -371,7 +377,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 void *)cq;
 			mcqe_n = MLX5_CQE_NUM_MINIS(cq->op_own) + 1;
 			pkts_n += mcqe_n;
 			goto cycle;
@@ -651,6 +657,8 @@ rxq_cq_process_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq,
 		p = _mm_andnot_si128(mask, p);
 		/* A.1 load cqes. */
 		p3 = _mm_extract_epi16(p, 3);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		cqes[3] = _mm_loadl_epi64((__m128i *)
 					   &cq[pos + p3].sop_drop_qpn);
 		rte_compiler_barrier();
@@ -683,6 +691,7 @@ rxq_cq_process_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq,
 		cqes[2] = _mm_blend_epi16(cqes[2], cqe_tmp1, 0x30);
 		cqe_tmp2 = _mm_loadl_epi64((__m128i *)&cq[pos + p3].rsvd4[2]);
 		cqe_tmp1 = _mm_loadl_epi64((__m128i *)&cq[pos + p2].rsvd4[2]);
+__rte_diagnostic_pop
 		cqes[3] = _mm_blend_epi16(cqes[3], cqe_tmp2, 0x04);
 		cqes[2] = _mm_blend_epi16(cqes[2], cqe_tmp1, 0x04);
 		/* C.2 generate final structure for mbuf with swapping bytes. */
@@ -700,6 +709,8 @@ rxq_cq_process_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq,
 		/* E.1 extract op_own field. */
 		op_own_tmp2 = _mm_unpacklo_epi32(cqes[2], cqes[3]);
 		/* C.1 load remained CQE data and extract necessary fields. */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		cqe_tmp2 = _mm_load_si128((__m128i *)&cq[pos + p1]);
 		cqe_tmp1 = _mm_load_si128((__m128i *)&cq[pos]);
 		cqes[1] = _mm_blendv_epi8(cqes[1], cqe_tmp2, blend_mask);
@@ -710,6 +721,7 @@ rxq_cq_process_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq,
 		cqes[0] = _mm_blend_epi16(cqes[0], cqe_tmp1, 0x30);
 		cqe_tmp2 = _mm_loadl_epi64((__m128i *)&cq[pos + p1].rsvd4[2]);
 		cqe_tmp1 = _mm_loadl_epi64((__m128i *)&cq[pos].rsvd4[2]);
+__rte_diagnostic_pop
 		cqes[1] = _mm_blend_epi16(cqes[1], cqe_tmp2, 0x04);
 		cqes[0] = _mm_blend_epi16(cqes[0], cqe_tmp1, 0x04);
 		/* C.2 generate final structure for mbuf with swapping bytes. */
drivers/net/tap/tap_flow.c +3 -3
index c0e44bb1a7..373b773e2d 100644
@@ -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/virtio/virtio_rxtx_simple.c +0 -4
index 438256970d..439e00a7e1 100644
@@ -23,10 +23,6 @@
 
 #include "virtio_rxtx_simple.h"
 
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
-
 int __rte_cold
 virtio_rxq_vec_setup(struct virtnet_rx *rxq)
 {
Signature · 1 line
2.47.0.vfs.0.3
#31 lore raw

v8 cover add diagnostics macros to make code portable

In reply to Andre Muezerie

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.

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):
lib/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 | 46 +++++++++++++++++--
 drivers/net/axgbe/axgbe_rxtx.h                |  9 ----
 drivers/net/cpfl/cpfl_rxtx_vec_common.h       |  4 --
 drivers/net/dpaa2/dpaa2_rxtx.c                | 16 ++-----
 drivers/net/fm10k/fm10k_rxtx_vec.c            | 19 ++++++--
 drivers/net/hns3/hns3_rxtx_vec_neon.h         |  5 +-
 .../net/i40e/i40e_recycle_mbufs_vec_common.c  |  2 -
 drivers/net/i40e/i40e_rxtx_common_avx.h       | 16 +++++--
 drivers/net/i40e/i40e_rxtx_vec_altivec.c      | 17 ++++++-
 drivers/net/i40e/i40e_rxtx_vec_avx2.c         | 16 +++++--
 drivers/net/i40e/i40e_rxtx_vec_avx512.c       | 16 +++++--
 drivers/net/i40e/i40e_rxtx_vec_common.h       |  4 --
 drivers/net/i40e/i40e_rxtx_vec_neon.c         | 18 ++++++--
 drivers/net/i40e/i40e_rxtx_vec_sse.c          | 22 +++++++--
 drivers/net/iavf/iavf_rxtx_vec_avx2.c         | 21 +++++++--
 drivers/net/iavf/iavf_rxtx_vec_avx512.c       | 27 +++++++++--
 drivers/net/iavf/iavf_rxtx_vec_common.h       | 10 ++--
 drivers/net/iavf/iavf_rxtx_vec_neon.c         |  9 ++++
 drivers/net/iavf/iavf_rxtx_vec_sse.c          | 30 ++++++++++--
 drivers/net/ice/ice_rxtx_common_avx.h         | 16 +++++--
 drivers/net/ice/ice_rxtx_vec_avx2.c           | 16 +++++--
 drivers/net/ice/ice_rxtx_vec_avx512.c         | 16 +++++--
 drivers/net/ice/ice_rxtx_vec_common.h         |  4 --
 drivers/net/ice/ice_rxtx_vec_sse.c            | 22 +++++++--
 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       |  8 +++-
 drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c        | 19 ++++++--
 drivers/net/mlx5/mlx5_flow.c                  |  6 +--
 drivers/net/mlx5/mlx5_rxtx_vec_altivec.h      |  5 --
 drivers/net/mlx5/mlx5_rxtx_vec_neon.h         |  2 -
 drivers/net/mlx5/mlx5_rxtx_vec_sse.h          | 26 ++++++++---
 drivers/net/tap/tap_flow.c                    |  6 +--
 drivers/net/virtio/virtio_rxtx_simple.c       |  4 --
 lib/eal/include/rte_common.h                  | 23 ++++++++++
 35 files changed, 348 insertions(+), 138 deletions(-)

--
2.47.0.vfs.0.3

#32 lore raw

PATCH v8 1/3 lib/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 | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
lib/eal/include/rte_common.h +23 -0
index 4d299f2b36..13b7b92f46 100644
@@ -137,6 +137,29 @@ typedef uint16_t unaligned_uint16_t;
 #define RTE_DEPRECATED(x)
 #endif
 
+/*
+ * Macro to ignore whenever a pointer is cast so as to remove 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
+
+/*
+ * 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
+
 /**
  * Mark a function or variable to a weak reference.
  */
Signature · 1 line
2.47.0.vfs.0.3
#33 lore raw

PATCH v8 2/3 drivers/common: add diagnostics macros to make code portable

In reply to Andre Muezerie

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.

---
 drivers/common/idpf/idpf_common_rxtx_avx512.c | 46 +++++++++++++++++--
 1 file changed, 42 insertions(+), 4 deletions(-)
drivers/common/idpf/idpf_common_rxtx_avx512.c +42 -4
index b8450b03ae..37cd0a43e2 100644
@@ -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,8 +30,11 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				_mm_store_si128((__m128i *)&rxdp[i].read,
 						dma_addr0);
+__rte_diagnostic_pop
 			}
 		}
 		rte_atomic_fetch_add_explicit(&rxq->rx_stats.mbuf_alloc_failed,
@@ -108,8 +107,11 @@ 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 */
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm512_store_si512((__m512i *)&rxdp->read, dma_addr0_3);
 		_mm512_store_si512((__m512i *)&(rxdp + 4)->read, dma_addr4_7);
+__rte_diagnostic_pop
 	}
 
 	rxq->rxrearm_start += IDPF_RXQ_REARM_THRESH;
@@ -164,8 +166,11 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 					_mm_storeu_si128((__m128i *)&rxdp[i].read,
 							 dma_addr0);
+__rte_diagnostic_pop
 				}
 			}
 			rte_atomic_fetch_add_explicit(&rxq->rx_stats.mbuf_alloc_failed,
@@ -216,10 +221,13 @@ idpf_singleq_rearm(struct idpf_rx_queue *rxq)
 				 iovas1);
 		const __m512i desc6_7 = _mm512_bsrli_epi128(desc4_5, 8);
 
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_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);
+__rte_diagnostic_pop
 
 		rxp += IDPF_DESCS_PER_LOOP_AVX;
 		rxdp += IDPF_DESCS_PER_LOOP_AVX;
@@ -336,6 +344,8 @@ _idpf_singleq_recv_raw_pkts_avx512(struct idpf_rx_queue *rxq,
 #endif
 
 		__m512i raw_desc0_3, raw_desc4_7;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		const __m128i raw_desc7 =
 			_mm_load_si128((void *)(rxdp + 7));
 		rte_compiler_barrier();
@@ -359,6 +369,7 @@ _idpf_singleq_recv_raw_pkts_avx512(struct idpf_rx_queue *rxq,
 		rte_compiler_barrier();
 		const __m128i raw_desc0 =
 			_mm_load_si128((void *)(rxdp + 0));
+__rte_diagnostic_pop
 
 		raw_desc4_7 = _mm512_broadcast_i32x4(raw_desc4);
 		raw_desc4_7 = _mm512_inserti32x4(raw_desc4_7, raw_desc5, 1);
@@ -560,8 +571,11 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 				_mm_store_si128((__m128i *)&rxdp[i],
 						dma_addr0);
+__rte_diagnostic_pop
 			}
 		}
 	rte_atomic_fetch_add_explicit(&rx_bufq->rx_stats.mbuf_alloc_failed,
@@ -634,8 +648,11 @@ 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;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 					_mm_storeu_si128((__m128i *)&rxdp[i],
 							 dma_addr0);
+__rte_diagnostic_pop
 				}
 			}
 		rte_atomic_fetch_add_explicit(&rx_bufq->rx_stats.mbuf_alloc_failed,
@@ -797,6 +814,8 @@ _idpf_splitq_recv_raw_pkts_avx512(struct idpf_rx_queue *rxq,
 #endif
 
 		__m512i raw_desc0_3, raw_desc4_7;
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		const __m128i raw_desc7 =
 			_mm_load_si128((void *)(rxdp + 7));
 		rte_compiler_barrier();
@@ -820,6 +839,7 @@ _idpf_splitq_recv_raw_pkts_avx512(struct idpf_rx_queue *rxq,
 		rte_compiler_barrier();
 		const __m128i raw_desc0 =
 			_mm_load_si128((void *)(rxdp + 0));
+__rte_diagnostic_pop
 
 		raw_desc4_7 = _mm512_broadcast_i32x4(raw_desc4);
 		raw_desc4_7 = _mm512_inserti32x4(raw_desc4_7, raw_desc5, 1);
@@ -1131,7 +1151,10 @@ idpf_singleq_vtx1(volatile struct idpf_base_tx_desc *txdp,
 
 	__m128i descriptor = _mm_set_epi64x(high_qw,
 					    pkt->buf_iova + pkt->data_off);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm_storeu_si128((__m128i *)txdp, descriptor);
+__rte_diagnostic_pop
 }
 
 #define IDPF_TX_LEN_MASK 0xAA
@@ -1178,7 +1201,10 @@ 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);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm512_storeu_si512((void *)txdp, desc0_3);
+__rte_diagnostic_pop
 	}
 
 	/* do any last ones */
@@ -1435,7 +1461,10 @@ idpf_splitq_vtx1(volatile struct idpf_flex_tx_sched_desc *txdp,
 
 	__m128i descriptor = _mm_set_epi64x(high_qw,
 					    pkt->buf_iova + pkt->data_off);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	_mm_storeu_si128((__m128i *)txdp, descriptor);
+__rte_diagnostic_pop
 }
 
 static __rte_always_inline void
@@ -1480,7 +1509,10 @@ 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);
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		_mm512_storeu_si512((void *)txdp, desc0_3);
+__rte_diagnostic_pop
 	}
 
 	/* do any last ones */
@@ -1521,11 +1553,14 @@ idpf_splitq_xmit_fixed_burst_vec_avx512(void *tx_queue, struct rte_mbuf **tx_pkt
 	if (nb_commit >= n) {
 		tx_backlog_entry_avx512(txep, tx_pkts, n);
 
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 		idpf_splitq_vtx((void *)txdp, tx_pkts, n - 1, cmd_dtype);
 		tx_pkts += (n - 1);
 		txdp += (n - 1);
 
 		idpf_splitq_vtx1((void *)txdp, *tx_pkts++, cmd_dtype);
+__rte_diagnostic_pop
 
 		nb_commit = (uint16_t)(nb_commit - n);
 
@@ -1540,7 +1575,10 @@ idpf_splitq_xmit_fixed_burst_vec_avx512(void *tx_queue, struct rte_mbuf **tx_pkt
 
 	tx_backlog_entry_avx512(txep, tx_pkts, nb_commit);
 
+__rte_diagnostic_push
+__rte_diagnostic_ignored_wcast_qual
 	idpf_splitq_vtx((void *)txdp, tx_pkts, nb_commit, cmd_dtype);
+__rte_diagnostic_pop
 
 	tx_id = (uint16_t)(tx_id + nb_commit);
 	if (tx_id > txq->next_rs)
Signature · 1 line
2.47.0.vfs.0.3