DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] drivers: remove __rte_used from functions for compatibility with MSVC
@ 2025-04-04  1:47 Andre Muezerie
  2025-05-27  5:02 ` [EXTERNAL] " Jerin Jacob
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Andre Muezerie @ 2025-04-04  1:47 UTC (permalink / raw)
  To: Nithin Dabilpuram, Kiran Kumar K, Sunil Kumar Kori, Satha Rao,
	Harman Kalra
  Cc: dev, Andre Muezerie

With gcc, the macro __rte_used translates to __attribute__((used)).
MSVC has something to the same effect, but harder to use and with some
limitations (one being that it cannot be used with "static"). Therefore,
it makes sense to avoid __rte_used in some cases.

The functions modified in this patch don't really need to use __rte_used.
Instead, these functions can be involved in same ifdefs used in the
callers. That way, they are only defined when needed (when
someone is actually calling the function). Doing so makes the code
compatible with MSVC and avoids compiler warnings about functions being
defined but not used.

Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
---
 drivers/net/cnxk/cn10k_rx_select.c | 6 +++++-
 drivers/net/cnxk/cn10k_tx_select.c | 6 ++++--
 drivers/net/cnxk/cn20k_rx_select.c | 6 +++++-
 drivers/net/cnxk/cn20k_tx_select.c | 6 ++++--
 drivers/net/cnxk/cn9k_rx_select.c  | 6 ++++--
 drivers/net/cnxk/cn9k_tx_select.c  | 6 ++++--
 6 files changed, 26 insertions(+), 10 deletions(-)

diff --git a/drivers/net/cnxk/cn10k_rx_select.c b/drivers/net/cnxk/cn10k_rx_select.c
index fe1f0dda73..658a434d75 100644
--- a/drivers/net/cnxk/cn10k_rx_select.c
+++ b/drivers/net/cnxk/cn10k_rx_select.c
@@ -5,7 +5,9 @@
 #include "cn10k_ethdev.h"
 #include "cn10k_rx.h"
 
-static __rte_used void
+#if defined(RTE_ARCH_ARM64)
+#if !defined(CNXK_DIS_TMPLT_FUNC)
+static void
 pick_rx_func(struct rte_eth_dev *eth_dev,
 	     const eth_rx_burst_t rx_burst[NIX_RX_OFFLOAD_MAX])
 {
@@ -21,6 +23,8 @@ pick_rx_func(struct rte_eth_dev *eth_dev,
 
 	rte_atomic_thread_fence(rte_memory_order_release);
 }
+#endif
+#endif
 
 static uint16_t __rte_noinline __rte_hot __rte_unused
 cn10k_nix_flush_rx(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t pkts)
diff --git a/drivers/net/cnxk/cn10k_tx_select.c b/drivers/net/cnxk/cn10k_tx_select.c
index 56fddac5a0..b9a17b8bc2 100644
--- a/drivers/net/cnxk/cn10k_tx_select.c
+++ b/drivers/net/cnxk/cn10k_tx_select.c
@@ -5,7 +5,9 @@
 #include "cn10k_ethdev.h"
 #include "cn10k_tx.h"
 
-static __rte_used inline void
+#if defined(RTE_ARCH_ARM64)
+#if !defined(CNXK_DIS_TMPLT_FUNC)
+static inline void
 pick_tx_func(struct rte_eth_dev *eth_dev,
 	     const eth_tx_burst_t tx_burst[NIX_TX_OFFLOAD_MAX])
 {
@@ -19,8 +21,8 @@ pick_tx_func(struct rte_eth_dev *eth_dev,
 		rte_eth_fp_ops[eth_dev->data->port_id].tx_pkt_burst =
 			eth_dev->tx_pkt_burst;
 }
+#endif
 
-#if defined(RTE_ARCH_ARM64)
 static int
 cn10k_nix_tx_queue_count(void *tx_queue)
 {
diff --git a/drivers/net/cnxk/cn20k_rx_select.c b/drivers/net/cnxk/cn20k_rx_select.c
index 25c79434cd..df12befc20 100644
--- a/drivers/net/cnxk/cn20k_rx_select.c
+++ b/drivers/net/cnxk/cn20k_rx_select.c
@@ -5,7 +5,9 @@
 #include "cn20k_ethdev.h"
 #include "cn20k_rx.h"
 
-static __rte_used void
+#if defined(RTE_ARCH_ARM64)
+#if !defined(CNXK_DIS_TMPLT_FUNC)
+static void
 pick_rx_func(struct rte_eth_dev *eth_dev, const eth_rx_burst_t rx_burst[NIX_RX_OFFLOAD_MAX])
 {
 	struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);
@@ -18,6 +20,8 @@ pick_rx_func(struct rte_eth_dev *eth_dev, const eth_rx_burst_t rx_burst[NIX_RX_O
 
 	rte_atomic_thread_fence(rte_memory_order_release);
 }
+#endif
+#endif
 
 static uint16_t __rte_noinline __rte_hot __rte_unused
 cn20k_nix_flush_rx(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t pkts)
diff --git a/drivers/net/cnxk/cn20k_tx_select.c b/drivers/net/cnxk/cn20k_tx_select.c
index fb62b54a5f..d0c97a6c19 100644
--- a/drivers/net/cnxk/cn20k_tx_select.c
+++ b/drivers/net/cnxk/cn20k_tx_select.c
@@ -5,7 +5,9 @@
 #include "cn20k_ethdev.h"
 #include "cn20k_tx.h"
 
-static __rte_used inline void
+#if defined(RTE_ARCH_ARM64)
+#if !defined(CNXK_DIS_TMPLT_FUNC)
+static inline void
 pick_tx_func(struct rte_eth_dev *eth_dev, const eth_tx_burst_t tx_burst[NIX_TX_OFFLOAD_MAX])
 {
 	struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);
@@ -16,8 +18,8 @@ pick_tx_func(struct rte_eth_dev *eth_dev, const eth_tx_burst_t tx_burst[NIX_TX_O
 	if (eth_dev->data->dev_started)
 		rte_eth_fp_ops[eth_dev->data->port_id].tx_pkt_burst = eth_dev->tx_pkt_burst;
 }
+#endif
 
-#if defined(RTE_ARCH_ARM64)
 static int
 cn20k_nix_tx_queue_count(void *tx_queue)
 {
diff --git a/drivers/net/cnxk/cn9k_rx_select.c b/drivers/net/cnxk/cn9k_rx_select.c
index 0d4031ddeb..8cddc88e5d 100644
--- a/drivers/net/cnxk/cn9k_rx_select.c
+++ b/drivers/net/cnxk/cn9k_rx_select.c
@@ -5,7 +5,9 @@
 #include "cn9k_ethdev.h"
 #include "cn9k_rx.h"
 
-static __rte_used void
+#if defined(RTE_ARCH_ARM64)
+#if !defined(CNXK_DIS_TMPLT_FUNC)
+static void
 pick_rx_func(struct rte_eth_dev *eth_dev,
 	     const eth_rx_burst_t rx_burst[NIX_RX_OFFLOAD_MAX])
 {
@@ -19,8 +21,8 @@ pick_rx_func(struct rte_eth_dev *eth_dev,
 		rte_eth_fp_ops[eth_dev->data->port_id].rx_pkt_burst =
 			eth_dev->rx_pkt_burst;
 }
+#endif
 
-#if defined(RTE_ARCH_ARM64)
 static void
 cn9k_eth_set_rx_tmplt_func(struct rte_eth_dev *eth_dev)
 {
diff --git a/drivers/net/cnxk/cn9k_tx_select.c b/drivers/net/cnxk/cn9k_tx_select.c
index 497449b1c4..8eaf6ad1d1 100644
--- a/drivers/net/cnxk/cn9k_tx_select.c
+++ b/drivers/net/cnxk/cn9k_tx_select.c
@@ -5,7 +5,9 @@
 #include "cn9k_ethdev.h"
 #include "cn9k_tx.h"
 
-static __rte_used void
+#if defined(RTE_ARCH_ARM64)
+#if !defined(CNXK_DIS_TMPLT_FUNC)
+static void
 pick_tx_func(struct rte_eth_dev *eth_dev,
 	     const eth_tx_burst_t tx_burst[NIX_TX_OFFLOAD_MAX])
 {
@@ -19,8 +21,8 @@ pick_tx_func(struct rte_eth_dev *eth_dev,
 		rte_eth_fp_ops[eth_dev->data->port_id].tx_pkt_burst =
 			eth_dev->tx_pkt_burst;
 }
+#endif
 
-#if defined(RTE_ARCH_ARM64)
 static int
 cn9k_nix_tx_queue_count(void *tx_queue)
 {
-- 
2.49.0.vfs.0.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: [EXTERNAL] [PATCH] drivers: remove __rte_used from functions for compatibility with MSVC
  2025-04-04  1:47 [PATCH] drivers: remove __rte_used from functions for compatibility with MSVC Andre Muezerie
@ 2025-05-27  5:02 ` Jerin Jacob
  2025-05-27  7:02   ` Pavan Nikhilesh Bhagavatula
  2025-05-27 19:49 ` [PATCH v2] " Andre Muezerie
  2025-05-28 13:22 ` [PATCH v3] " Andre Muezerie
  2 siblings, 1 reply; 7+ messages in thread
From: Jerin Jacob @ 2025-05-27  5:02 UTC (permalink / raw)
  To: Andre Muezerie, Nithin Kumar Dabilpuram,
	Kiran Kumar Kokkilagadda, Sunil Kumar Kori,
	Satha Koteswara Rao Kottidi, Harman Kalra
  Cc: dev

[-- Attachment #1: Type: text/html, Size: 9463 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: [EXTERNAL] [PATCH] drivers: remove __rte_used from functions for compatibility with MSVC
  2025-05-27  5:02 ` [EXTERNAL] " Jerin Jacob
@ 2025-05-27  7:02   ` Pavan Nikhilesh Bhagavatula
  0 siblings, 0 replies; 7+ messages in thread
From: Pavan Nikhilesh Bhagavatula @ 2025-05-27  7:02 UTC (permalink / raw)
  To: Jerin Jacob, Andre Muezerie, Nithin Kumar Dabilpuram,
	Kiran Kumar Kokkilagadda, Sunil Kumar Kori,
	Satha Koteswara Rao Kottidi, Harman Kalra
  Cc: dev

[-- Attachment #1: Type: text/html, Size: 10247 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2] drivers: remove __rte_used from functions for compatibility with MSVC
  2025-04-04  1:47 [PATCH] drivers: remove __rte_used from functions for compatibility with MSVC Andre Muezerie
  2025-05-27  5:02 ` [EXTERNAL] " Jerin Jacob
@ 2025-05-27 19:49 ` Andre Muezerie
  2025-05-28  6:27   ` Jerin Jacob
  2025-05-28 13:22 ` [PATCH v3] " Andre Muezerie
  2 siblings, 1 reply; 7+ messages in thread
From: Andre Muezerie @ 2025-05-27 19:49 UTC (permalink / raw)
  To: andremue; +Cc: dev, hkalra, kirankumark, ndabilpuram, skori, skoteshwar

With gcc, the macro __rte_used translates to __attribute__((used)).
MSVC has something to the same effect, but harder to use and with some
limitations (one being that it cannot be used with "static"). Therefore,
it makes sense to avoid __rte_used in some cases.

The functions modified in this patch don't really need to use __rte_used.
Instead, these functions can be involved in same ifdefs used in the
callers. That way, they are only defined when needed (when
someone is actually calling the function). Doing so makes the code
compatible with MSVC and avoids compiler warnings about functions being
defined but not used.

Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
Acked-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
---
 drivers/net/cnxk/cn10k_rx_select.c | 4 +++-
 drivers/net/cnxk/cn10k_tx_select.c | 6 ++++--
 drivers/net/cnxk/cn20k_rx_select.c | 4 +++-
 drivers/net/cnxk/cn20k_tx_select.c | 6 ++++--
 drivers/net/cnxk/cn9k_rx_select.c  | 6 ++++--
 drivers/net/cnxk/cn9k_tx_select.c  | 6 ++++--
 6 files changed, 22 insertions(+), 10 deletions(-)

diff --git a/drivers/net/cnxk/cn10k_rx_select.c b/drivers/net/cnxk/cn10k_rx_select.c
index fe1f0dda73..5258d7f745 100644
--- a/drivers/net/cnxk/cn10k_rx_select.c
+++ b/drivers/net/cnxk/cn10k_rx_select.c
@@ -5,7 +5,8 @@
 #include "cn10k_ethdev.h"
 #include "cn10k_rx.h"
 
-static __rte_used void
+#if defined(RTE_ARCH_ARM64) && !defined(CNXK_DIS_TMPLT_FUNC)
+static void
 pick_rx_func(struct rte_eth_dev *eth_dev,
 	     const eth_rx_burst_t rx_burst[NIX_RX_OFFLOAD_MAX])
 {
@@ -21,6 +22,7 @@ pick_rx_func(struct rte_eth_dev *eth_dev,
 
 	rte_atomic_thread_fence(rte_memory_order_release);
 }
+#endif
 
 static uint16_t __rte_noinline __rte_hot __rte_unused
 cn10k_nix_flush_rx(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t pkts)
diff --git a/drivers/net/cnxk/cn10k_tx_select.c b/drivers/net/cnxk/cn10k_tx_select.c
index 56fddac5a0..b9a17b8bc2 100644
--- a/drivers/net/cnxk/cn10k_tx_select.c
+++ b/drivers/net/cnxk/cn10k_tx_select.c
@@ -5,7 +5,9 @@
 #include "cn10k_ethdev.h"
 #include "cn10k_tx.h"
 
-static __rte_used inline void
+#if defined(RTE_ARCH_ARM64)
+#if !defined(CNXK_DIS_TMPLT_FUNC)
+static inline void
 pick_tx_func(struct rte_eth_dev *eth_dev,
 	     const eth_tx_burst_t tx_burst[NIX_TX_OFFLOAD_MAX])
 {
@@ -19,8 +21,8 @@ pick_tx_func(struct rte_eth_dev *eth_dev,
 		rte_eth_fp_ops[eth_dev->data->port_id].tx_pkt_burst =
 			eth_dev->tx_pkt_burst;
 }
+#endif
 
-#if defined(RTE_ARCH_ARM64)
 static int
 cn10k_nix_tx_queue_count(void *tx_queue)
 {
diff --git a/drivers/net/cnxk/cn20k_rx_select.c b/drivers/net/cnxk/cn20k_rx_select.c
index 25c79434cd..d60f4e62f7 100644
--- a/drivers/net/cnxk/cn20k_rx_select.c
+++ b/drivers/net/cnxk/cn20k_rx_select.c
@@ -5,7 +5,8 @@
 #include "cn20k_ethdev.h"
 #include "cn20k_rx.h"
 
-static __rte_used void
+#if defined(RTE_ARCH_ARM64) && !defined(CNXK_DIS_TMPLT_FUNC)
+static void
 pick_rx_func(struct rte_eth_dev *eth_dev, const eth_rx_burst_t rx_burst[NIX_RX_OFFLOAD_MAX])
 {
 	struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);
@@ -18,6 +19,7 @@ pick_rx_func(struct rte_eth_dev *eth_dev, const eth_rx_burst_t rx_burst[NIX_RX_O
 
 	rte_atomic_thread_fence(rte_memory_order_release);
 }
+#endif
 
 static uint16_t __rte_noinline __rte_hot __rte_unused
 cn20k_nix_flush_rx(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t pkts)
diff --git a/drivers/net/cnxk/cn20k_tx_select.c b/drivers/net/cnxk/cn20k_tx_select.c
index fb62b54a5f..d0c97a6c19 100644
--- a/drivers/net/cnxk/cn20k_tx_select.c
+++ b/drivers/net/cnxk/cn20k_tx_select.c
@@ -5,7 +5,9 @@
 #include "cn20k_ethdev.h"
 #include "cn20k_tx.h"
 
-static __rte_used inline void
+#if defined(RTE_ARCH_ARM64)
+#if !defined(CNXK_DIS_TMPLT_FUNC)
+static inline void
 pick_tx_func(struct rte_eth_dev *eth_dev, const eth_tx_burst_t tx_burst[NIX_TX_OFFLOAD_MAX])
 {
 	struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);
@@ -16,8 +18,8 @@ pick_tx_func(struct rte_eth_dev *eth_dev, const eth_tx_burst_t tx_burst[NIX_TX_O
 	if (eth_dev->data->dev_started)
 		rte_eth_fp_ops[eth_dev->data->port_id].tx_pkt_burst = eth_dev->tx_pkt_burst;
 }
+#endif
 
-#if defined(RTE_ARCH_ARM64)
 static int
 cn20k_nix_tx_queue_count(void *tx_queue)
 {
diff --git a/drivers/net/cnxk/cn9k_rx_select.c b/drivers/net/cnxk/cn9k_rx_select.c
index 0d4031ddeb..8cddc88e5d 100644
--- a/drivers/net/cnxk/cn9k_rx_select.c
+++ b/drivers/net/cnxk/cn9k_rx_select.c
@@ -5,7 +5,9 @@
 #include "cn9k_ethdev.h"
 #include "cn9k_rx.h"
 
-static __rte_used void
+#if defined(RTE_ARCH_ARM64)
+#if !defined(CNXK_DIS_TMPLT_FUNC)
+static void
 pick_rx_func(struct rte_eth_dev *eth_dev,
 	     const eth_rx_burst_t rx_burst[NIX_RX_OFFLOAD_MAX])
 {
@@ -19,8 +21,8 @@ pick_rx_func(struct rte_eth_dev *eth_dev,
 		rte_eth_fp_ops[eth_dev->data->port_id].rx_pkt_burst =
 			eth_dev->rx_pkt_burst;
 }
+#endif
 
-#if defined(RTE_ARCH_ARM64)
 static void
 cn9k_eth_set_rx_tmplt_func(struct rte_eth_dev *eth_dev)
 {
diff --git a/drivers/net/cnxk/cn9k_tx_select.c b/drivers/net/cnxk/cn9k_tx_select.c
index 497449b1c4..8eaf6ad1d1 100644
--- a/drivers/net/cnxk/cn9k_tx_select.c
+++ b/drivers/net/cnxk/cn9k_tx_select.c
@@ -5,7 +5,9 @@
 #include "cn9k_ethdev.h"
 #include "cn9k_tx.h"
 
-static __rte_used void
+#if defined(RTE_ARCH_ARM64)
+#if !defined(CNXK_DIS_TMPLT_FUNC)
+static void
 pick_tx_func(struct rte_eth_dev *eth_dev,
 	     const eth_tx_burst_t tx_burst[NIX_TX_OFFLOAD_MAX])
 {
@@ -19,8 +21,8 @@ pick_tx_func(struct rte_eth_dev *eth_dev,
 		rte_eth_fp_ops[eth_dev->data->port_id].tx_pkt_burst =
 			eth_dev->tx_pkt_burst;
 }
+#endif
 
-#if defined(RTE_ARCH_ARM64)
 static int
 cn9k_nix_tx_queue_count(void *tx_queue)
 {
-- 
2.49.0.vfs.0.3


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] drivers: remove __rte_used from functions for compatibility with MSVC
  2025-05-27 19:49 ` [PATCH v2] " Andre Muezerie
@ 2025-05-28  6:27   ` Jerin Jacob
  0 siblings, 0 replies; 7+ messages in thread
From: Jerin Jacob @ 2025-05-28  6:27 UTC (permalink / raw)
  To: Andre Muezerie; +Cc: dev, hkalra, kirankumark, ndabilpuram, skori, skoteshwar

On Wed, May 28, 2025 at 1:27 AM Andre Muezerie
<andremue@linux.microsoft.com> wrote:
>
> With gcc, the macro __rte_used translates to __attribute__((used)).
> MSVC has something to the same effect, but harder to use and with some
> limitations (one being that it cannot be used with "static"). Therefore,
> it makes sense to avoid __rte_used in some cases.
>
> The functions modified in this patch don't really need to use __rte_used.
> Instead, these functions can be involved in same ifdefs used in the
> callers. That way, they are only defined when needed (when
> someone is actually calling the function). Doing so makes the code
> compatible with MSVC and avoids compiler warnings about functions being
> defined but not used.
>
> Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
> Acked-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
> ---

>
> -static __rte_used inline void
> +#if defined(RTE_ARCH_ARM64)
> +#if !defined(CNXK_DIS_TMPLT_FUNC)

Please change to #if defined(RTE_ARCH_ARM64) &&
!defined(CNXK_DIS_TMPLT_FUNC) in all instances.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v3] drivers: remove __rte_used from functions for compatibility with MSVC
  2025-04-04  1:47 [PATCH] drivers: remove __rte_used from functions for compatibility with MSVC Andre Muezerie
  2025-05-27  5:02 ` [EXTERNAL] " Jerin Jacob
  2025-05-27 19:49 ` [PATCH v2] " Andre Muezerie
@ 2025-05-28 13:22 ` Andre Muezerie
  2025-05-29  5:53   ` Jerin Jacob
  2 siblings, 1 reply; 7+ messages in thread
From: Andre Muezerie @ 2025-05-28 13:22 UTC (permalink / raw)
  To: andremue; +Cc: dev, hkalra, kirankumark, ndabilpuram, skori, skoteshwar

With gcc, the macro __rte_used translates to __attribute__((used)).
MSVC has something to the same effect, but harder to use and with some
limitations (one being that it cannot be used with "static"). Therefore,
it makes sense to avoid __rte_used in some cases.

The functions modified in this patch don't really need to use __rte_used.
Instead, these functions can be involved in same ifdefs used in the
callers. That way, they are only defined when needed (when
someone is actually calling the function). Doing so makes the code
compatible with MSVC and avoids compiler warnings about functions being
defined but not used.

Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
Acked-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
---
 drivers/net/cnxk/cn10k_rx_select.c | 4 +++-
 drivers/net/cnxk/cn10k_tx_select.c | 4 +++-
 drivers/net/cnxk/cn20k_rx_select.c | 4 +++-
 drivers/net/cnxk/cn20k_tx_select.c | 4 +++-
 drivers/net/cnxk/cn9k_rx_select.c  | 4 +++-
 drivers/net/cnxk/cn9k_tx_select.c  | 4 +++-
 6 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/drivers/net/cnxk/cn10k_rx_select.c b/drivers/net/cnxk/cn10k_rx_select.c
index fe1f0dda73..5258d7f745 100644
--- a/drivers/net/cnxk/cn10k_rx_select.c
+++ b/drivers/net/cnxk/cn10k_rx_select.c
@@ -5,7 +5,8 @@
 #include "cn10k_ethdev.h"
 #include "cn10k_rx.h"
 
-static __rte_used void
+#if defined(RTE_ARCH_ARM64) && !defined(CNXK_DIS_TMPLT_FUNC)
+static void
 pick_rx_func(struct rte_eth_dev *eth_dev,
 	     const eth_rx_burst_t rx_burst[NIX_RX_OFFLOAD_MAX])
 {
@@ -21,6 +22,7 @@ pick_rx_func(struct rte_eth_dev *eth_dev,
 
 	rte_atomic_thread_fence(rte_memory_order_release);
 }
+#endif
 
 static uint16_t __rte_noinline __rte_hot __rte_unused
 cn10k_nix_flush_rx(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t pkts)
diff --git a/drivers/net/cnxk/cn10k_tx_select.c b/drivers/net/cnxk/cn10k_tx_select.c
index 56fddac5a0..066c65c9b9 100644
--- a/drivers/net/cnxk/cn10k_tx_select.c
+++ b/drivers/net/cnxk/cn10k_tx_select.c
@@ -5,7 +5,8 @@
 #include "cn10k_ethdev.h"
 #include "cn10k_tx.h"
 
-static __rte_used inline void
+#if defined(RTE_ARCH_ARM64) && !defined(CNXK_DIS_TMPLT_FUNC)
+static inline void
 pick_tx_func(struct rte_eth_dev *eth_dev,
 	     const eth_tx_burst_t tx_burst[NIX_TX_OFFLOAD_MAX])
 {
@@ -19,6 +20,7 @@ pick_tx_func(struct rte_eth_dev *eth_dev,
 		rte_eth_fp_ops[eth_dev->data->port_id].tx_pkt_burst =
 			eth_dev->tx_pkt_burst;
 }
+#endif
 
 #if defined(RTE_ARCH_ARM64)
 static int
diff --git a/drivers/net/cnxk/cn20k_rx_select.c b/drivers/net/cnxk/cn20k_rx_select.c
index 25c79434cd..d60f4e62f7 100644
--- a/drivers/net/cnxk/cn20k_rx_select.c
+++ b/drivers/net/cnxk/cn20k_rx_select.c
@@ -5,7 +5,8 @@
 #include "cn20k_ethdev.h"
 #include "cn20k_rx.h"
 
-static __rte_used void
+#if defined(RTE_ARCH_ARM64) && !defined(CNXK_DIS_TMPLT_FUNC)
+static void
 pick_rx_func(struct rte_eth_dev *eth_dev, const eth_rx_burst_t rx_burst[NIX_RX_OFFLOAD_MAX])
 {
 	struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);
@@ -18,6 +19,7 @@ pick_rx_func(struct rte_eth_dev *eth_dev, const eth_rx_burst_t rx_burst[NIX_RX_O
 
 	rte_atomic_thread_fence(rte_memory_order_release);
 }
+#endif
 
 static uint16_t __rte_noinline __rte_hot __rte_unused
 cn20k_nix_flush_rx(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t pkts)
diff --git a/drivers/net/cnxk/cn20k_tx_select.c b/drivers/net/cnxk/cn20k_tx_select.c
index fb62b54a5f..95cd1148a1 100644
--- a/drivers/net/cnxk/cn20k_tx_select.c
+++ b/drivers/net/cnxk/cn20k_tx_select.c
@@ -5,7 +5,8 @@
 #include "cn20k_ethdev.h"
 #include "cn20k_tx.h"
 
-static __rte_used inline void
+#if defined(RTE_ARCH_ARM64) && !defined(CNXK_DIS_TMPLT_FUNC)
+static inline void
 pick_tx_func(struct rte_eth_dev *eth_dev, const eth_tx_burst_t tx_burst[NIX_TX_OFFLOAD_MAX])
 {
 	struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);
@@ -16,6 +17,7 @@ pick_tx_func(struct rte_eth_dev *eth_dev, const eth_tx_burst_t tx_burst[NIX_TX_O
 	if (eth_dev->data->dev_started)
 		rte_eth_fp_ops[eth_dev->data->port_id].tx_pkt_burst = eth_dev->tx_pkt_burst;
 }
+#endif
 
 #if defined(RTE_ARCH_ARM64)
 static int
diff --git a/drivers/net/cnxk/cn9k_rx_select.c b/drivers/net/cnxk/cn9k_rx_select.c
index 0d4031ddeb..bb943e694d 100644
--- a/drivers/net/cnxk/cn9k_rx_select.c
+++ b/drivers/net/cnxk/cn9k_rx_select.c
@@ -5,7 +5,8 @@
 #include "cn9k_ethdev.h"
 #include "cn9k_rx.h"
 
-static __rte_used void
+#if defined(RTE_ARCH_ARM64) && !defined(CNXK_DIS_TMPLT_FUNC)
+static void
 pick_rx_func(struct rte_eth_dev *eth_dev,
 	     const eth_rx_burst_t rx_burst[NIX_RX_OFFLOAD_MAX])
 {
@@ -19,6 +20,7 @@ pick_rx_func(struct rte_eth_dev *eth_dev,
 		rte_eth_fp_ops[eth_dev->data->port_id].rx_pkt_burst =
 			eth_dev->rx_pkt_burst;
 }
+#endif
 
 #if defined(RTE_ARCH_ARM64)
 static void
diff --git a/drivers/net/cnxk/cn9k_tx_select.c b/drivers/net/cnxk/cn9k_tx_select.c
index 497449b1c4..784faa3b8b 100644
--- a/drivers/net/cnxk/cn9k_tx_select.c
+++ b/drivers/net/cnxk/cn9k_tx_select.c
@@ -5,7 +5,8 @@
 #include "cn9k_ethdev.h"
 #include "cn9k_tx.h"
 
-static __rte_used void
+#if defined(RTE_ARCH_ARM64) && !defined(CNXK_DIS_TMPLT_FUNC)
+static void
 pick_tx_func(struct rte_eth_dev *eth_dev,
 	     const eth_tx_burst_t tx_burst[NIX_TX_OFFLOAD_MAX])
 {
@@ -19,6 +20,7 @@ pick_tx_func(struct rte_eth_dev *eth_dev,
 		rte_eth_fp_ops[eth_dev->data->port_id].tx_pkt_burst =
 			eth_dev->tx_pkt_burst;
 }
+#endif
 
 #if defined(RTE_ARCH_ARM64)
 static int
-- 
2.49.0.vfs.0.3


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v3] drivers: remove __rte_used from functions for compatibility with MSVC
  2025-05-28 13:22 ` [PATCH v3] " Andre Muezerie
@ 2025-05-29  5:53   ` Jerin Jacob
  0 siblings, 0 replies; 7+ messages in thread
From: Jerin Jacob @ 2025-05-29  5:53 UTC (permalink / raw)
  To: Andre Muezerie; +Cc: dev, hkalra, kirankumark, ndabilpuram, skori, skoteshwar

On Thu, May 29, 2025 at 5:42 AM Andre Muezerie
<andremue@linux.microsoft.com> wrote:
>
> With gcc, the macro __rte_used translates to __attribute__((used)).
> MSVC has something to the same effect, but harder to use and with some
> limitations (one being that it cannot be used with "static"). Therefore,
> it makes sense to avoid __rte_used in some cases.
>
> The functions modified in this patch don't really need to use __rte_used.
> Instead, these functions can be involved in same ifdefs used in the
> callers. That way, they are only defined when needed (when
> someone is actually calling the function). Doing so makes the code
> compatible with MSVC and avoids compiler warnings about functions being
> defined but not used.
>
> Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
> Acked-by: Pavan Nikhilesh <pbhagavatula@marvell.com>

Updated the git commit as follows and applied to
dpdk-next-net-mrvl/for-main. Thanks


    net/cnxk: improve MSVC compatibility

    With gcc, the macro __rte_used translates to __attribute__((used)).
    MSVC has something to the same effect, but harder to use and with some
    limitations (one being that it cannot be used with "static"). Therefore,
    it makes sense to avoid __rte_used in some cases.

    The functions modified in this patch don't really need to use __rte_used.
    Instead, these functions can be involved in same ifdefs used in the
    callers. That way, they are only defined when needed (when
    someone is actually calling the function). Doing so makes the code
    compatible with MSVC and avoids compiler warnings about functions being
    defined but not used.

    Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
    Acked-by: Pavan Nikhilesh <pbhagavatula@marvell.com>

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-05-29  5:54 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-04-04  1:47 [PATCH] drivers: remove __rte_used from functions for compatibility with MSVC Andre Muezerie
2025-05-27  5:02 ` [EXTERNAL] " Jerin Jacob
2025-05-27  7:02   ` Pavan Nikhilesh Bhagavatula
2025-05-27 19:49 ` [PATCH v2] " Andre Muezerie
2025-05-28  6:27   ` Jerin Jacob
2025-05-28 13:22 ` [PATCH v3] " Andre Muezerie
2025-05-29  5:53   ` Jerin Jacob

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).