* [PATCH 1/5] lib/eal: add portable macro for weak linking
2024-12-24 3:05 [PATCH 0/5] use portable macro for weak linking Andre Muezerie
@ 2024-12-24 3:05 ` Andre Muezerie
2024-12-24 3:05 ` [PATCH 2/5] app/test-compress-perf: use " Andre Muezerie
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Andre Muezerie @ 2024-12-24 3:05 UTC (permalink / raw)
To: Tyler Retzlaff; +Cc: dev, Andre Muezerie
MSVC uses pragmas to indicate weak linking, so the old __rte_weak
attribute needs to made into a macro so that the same syntax can
be used for MSVC and other compilers like gcc.
This patch adds macro RTE_WEAK and deprecates __rte_weak.
Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
---
lib/eal/include/rte_common.h | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/lib/eal/include/rte_common.h b/lib/eal/include/rte_common.h
index 4d299f2b36..904b3ba5ec 100644
--- a/lib/eal/include/rte_common.h
+++ b/lib/eal/include/rte_common.h
@@ -137,10 +137,22 @@ typedef uint16_t unaligned_uint16_t;
#define RTE_DEPRECATED(x)
#endif
+/**
+ * @deprecated
+ * @see RTE_WEAK
+ */
+#define __rte_weak (RTE_DEPRECATED(__rte_weak) __attribute__((__weak__)))
+
/**
* Mark a function or variable to a weak reference.
*/
-#define __rte_weak __attribute__((__weak__))
+#ifdef RTE_TOOLCHAIN_MSVC
+#define RTE_WEAK(FUNC_NAME) \
+ (__pragma(comment(linker, "/alternatename:" #FUNC_NAME "=rte_weak_" \
+ #FUNC_NAME)) rte_weak_ ## FUNC_NAME)
+#else
+#define RTE_WEAK(FUNC_NAME) (__attribute__((__weak__)) FUNC_NAME)
+#endif
/**
* Mark a function to be pure.
--
2.47.0.vfs.0.3
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/5] app/test-compress-perf: use portable macro for weak linking
2024-12-24 3:05 [PATCH 0/5] use portable macro for weak linking Andre Muezerie
2024-12-24 3:05 ` [PATCH 1/5] lib/eal: add " Andre Muezerie
@ 2024-12-24 3:05 ` Andre Muezerie
2024-12-24 3:05 ` [PATCH 3/5] drivers/bus: " Andre Muezerie
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Andre Muezerie @ 2024-12-24 3:05 UTC (permalink / raw)
Cc: dev, Andre Muezerie
MSVC uses pragmas to indicate weak linking, so the old __rte_weak
attribute needs to made into a macro so that the same syntax can
be used for MSVC and other compilers like gcc.
This patch replaces __rte_weak with macro RTE_WEAK.
Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
---
app/test-compress-perf/main.c | 36 +++++++++++++++++------------------
1 file changed, 18 insertions(+), 18 deletions(-)
diff --git a/app/test-compress-perf/main.c b/app/test-compress-perf/main.c
index fa366123ed..01742a39ee 100644
--- a/app/test-compress-perf/main.c
+++ b/app/test-compress-perf/main.c
@@ -522,8 +522,8 @@ main(int argc, char **argv)
return ret;
}
-__rte_weak void *
-cperf_cyclecount_test_constructor(uint8_t dev_id __rte_unused,
+void *
+RTE_WEAK(cperf_cyclecount_test_constructor)(uint8_t dev_id __rte_unused,
uint16_t qp_id __rte_unused,
struct comp_test_data *options __rte_unused)
{
@@ -531,20 +531,20 @@ cperf_cyclecount_test_constructor(uint8_t dev_id __rte_unused,
return NULL;
}
-__rte_weak void
-cperf_cyclecount_test_destructor(void *arg __rte_unused)
+void
+RTE_WEAK(cperf_cyclecount_test_destructor)(void *arg __rte_unused)
{
RTE_LOG(INFO, USER1, "Something wrong happened!!!\n");
}
-__rte_weak int
-cperf_cyclecount_test_runner(void *test_ctx __rte_unused)
+int
+RTE_WEAK(cperf_cyclecount_test_runner)(void *test_ctx __rte_unused)
{
return 0;
}
-__rte_weak void *
-cperf_throughput_test_constructor(uint8_t dev_id __rte_unused,
+void *
+RTE_WEAK(cperf_throughput_test_constructor)(uint8_t dev_id __rte_unused,
uint16_t qp_id __rte_unused,
struct comp_test_data *options __rte_unused)
{
@@ -552,19 +552,19 @@ cperf_throughput_test_constructor(uint8_t dev_id __rte_unused,
return NULL;
}
-__rte_weak void
-cperf_throughput_test_destructor(void *arg __rte_unused)
+void
+RTE_WEAK(cperf_throughput_test_destructor)(void *arg __rte_unused)
{
}
-__rte_weak int
-cperf_throughput_test_runner(void *test_ctx __rte_unused)
+int
+RTE_WEAK(cperf_throughput_test_runner)(void *test_ctx __rte_unused)
{
return 0;
}
-__rte_weak void *
-cperf_verify_test_constructor(uint8_t dev_id __rte_unused,
+void *
+RTE_WEAK(cperf_verify_test_constructor)(uint8_t dev_id __rte_unused,
uint16_t qp_id __rte_unused,
struct comp_test_data *options __rte_unused)
{
@@ -572,14 +572,14 @@ cperf_verify_test_constructor(uint8_t dev_id __rte_unused,
return NULL;
}
-__rte_weak void
-cperf_verify_test_destructor(void *arg __rte_unused)
+void
+RTE_WEAK(cperf_verify_test_destructor)(void *arg __rte_unused)
{
}
-__rte_weak int
-cperf_verify_test_runner(void *test_ctx __rte_unused)
+int
+RTE_WEAK(cperf_verify_test_runner)(void *test_ctx __rte_unused)
{
return 0;
}
--
2.47.0.vfs.0.3
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 3/5] drivers/bus: use portable macro for weak linking
2024-12-24 3:05 [PATCH 0/5] use portable macro for weak linking Andre Muezerie
2024-12-24 3:05 ` [PATCH 1/5] lib/eal: add " Andre Muezerie
2024-12-24 3:05 ` [PATCH 2/5] app/test-compress-perf: use " Andre Muezerie
@ 2024-12-24 3:05 ` Andre Muezerie
2024-12-24 3:05 ` [PATCH 4/5] drivers/common: " Andre Muezerie
2024-12-24 3:05 ` [PATCH 5/5] drivers/net: " Andre Muezerie
4 siblings, 0 replies; 6+ messages in thread
From: Andre Muezerie @ 2024-12-24 3:05 UTC (permalink / raw)
To: Parav Pandit, Xueming Li; +Cc: dev, Andre Muezerie
MSVC uses pragmas to indicate weak linking, so the old __rte_weak
attribute needs to made into a macro so that the same syntax can
be used for MSVC and other compilers like gcc.
This patch replaces __rte_weak with macro RTE_WEAK.
Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
---
drivers/bus/auxiliary/auxiliary_common.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/bus/auxiliary/auxiliary_common.c b/drivers/bus/auxiliary/auxiliary_common.c
index e6cbc4d356..147009ddab 100644
--- a/drivers/bus/auxiliary/auxiliary_common.c
+++ b/drivers/bus/auxiliary/auxiliary_common.c
@@ -41,8 +41,8 @@ auxiliary_devargs_lookup(const char *name)
*
* Stub for OS not supporting auxiliary bus.
*/
-__rte_weak bool
-auxiliary_dev_exists(const char *name)
+bool
+RTE_WEAK(auxiliary_dev_exists)(const char *name)
{
RTE_SET_USED(name);
return false;
@@ -53,8 +53,8 @@ auxiliary_dev_exists(const char *name)
*
* Stub for OS not supporting auxiliary bus.
*/
-__rte_weak int
-auxiliary_scan(void)
+int
+RTE_WEAK(auxiliary_scan)(void)
{
return 0;
}
--
2.47.0.vfs.0.3
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 4/5] drivers/common: use portable macro for weak linking
2024-12-24 3:05 [PATCH 0/5] use portable macro for weak linking Andre Muezerie
` (2 preceding siblings ...)
2024-12-24 3:05 ` [PATCH 3/5] drivers/bus: " Andre Muezerie
@ 2024-12-24 3:05 ` Andre Muezerie
2024-12-24 3:05 ` [PATCH 5/5] drivers/net: " Andre Muezerie
4 siblings, 0 replies; 6+ messages in thread
From: Andre Muezerie @ 2024-12-24 3:05 UTC (permalink / raw)
To: Nagadheeraj Rottela, Srikanth Jampala, Kai Ji; +Cc: dev, Andre Muezerie
MSVC uses pragmas to indicate weak linking, so the old __rte_weak
attribute needs to made into a macro so that the same syntax can
be used for MSVC and other compilers like gcc.
This patch replaces __rte_weak with macro RTE_WEAK.
Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
---
drivers/common/nitrox/nitrox_device.c | 16 ++++++++--------
drivers/common/qat/qat_qp.c | 4 ++--
2 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/drivers/common/nitrox/nitrox_device.c b/drivers/common/nitrox/nitrox_device.c
index 39edc440a7..6d82b49c46 100644
--- a/drivers/common/nitrox/nitrox_device.c
+++ b/drivers/common/nitrox/nitrox_device.c
@@ -133,29 +133,29 @@ static struct rte_pci_driver nitrox_pmd = {
.remove = nitrox_pci_remove,
};
-__rte_weak int
-nitrox_sym_pmd_create(struct nitrox_device *ndev)
+int
+RTE_WEAK(nitrox_sym_pmd_create)(struct nitrox_device *ndev)
{
RTE_SET_USED(ndev);
return 0;
}
-__rte_weak int
-nitrox_sym_pmd_destroy(struct nitrox_device *ndev)
+int
+RTE_WEAK(nitrox_sym_pmd_destroy)(struct nitrox_device *ndev)
{
RTE_SET_USED(ndev);
return 0;
}
-__rte_weak int
-nitrox_comp_pmd_create(struct nitrox_device *ndev)
+int
+RTE_WEAK(nitrox_comp_pmd_create)(struct nitrox_device *ndev)
{
RTE_SET_USED(ndev);
return 0;
}
-__rte_weak int
-nitrox_comp_pmd_destroy(struct nitrox_device *ndev)
+int
+RTE_WEAK(nitrox_comp_pmd_destroy)(struct nitrox_device *ndev)
{
RTE_SET_USED(ndev);
return 0;
diff --git a/drivers/common/qat/qat_qp.c b/drivers/common/qat/qat_qp.c
index 4bf9bac23e..1a6faa2e18 100644
--- a/drivers/common/qat/qat_qp.c
+++ b/drivers/common/qat/qat_qp.c
@@ -945,8 +945,8 @@ qat_cq_get_fw_cipher_crc_cap(struct qat_qp *qp)
}
#endif
-__rte_weak int
-qat_comp_process_response(void **op __rte_unused, uint8_t *resp __rte_unused,
+int
+RTE_WEAK(qat_comp_process_response)(void **op __rte_unused, uint8_t *resp __rte_unused,
void *op_cookie __rte_unused,
uint64_t *dequeue_err_count __rte_unused)
{
--
2.47.0.vfs.0.3
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 5/5] drivers/net: use portable macro for weak linking
2024-12-24 3:05 [PATCH 0/5] use portable macro for weak linking Andre Muezerie
` (3 preceding siblings ...)
2024-12-24 3:05 ` [PATCH 4/5] drivers/common: " Andre Muezerie
@ 2024-12-24 3:05 ` Andre Muezerie
4 siblings, 0 replies; 6+ messages in thread
From: Andre Muezerie @ 2024-12-24 3:05 UTC (permalink / raw)
To: John Daley, Hyong Youb Kim, Jie Hai, Chaoyong He,
Maxime Coquelin, Chenbo Xia
Cc: dev, Andre Muezerie
MSVC uses pragmas to indicate weak linking, so the old __rte_weak
attribute needs to made into a macro so that the same syntax can
be used for MSVC and other compilers like gcc.
This patch replaces __rte_weak with macro RTE_WEAK.
Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
---
drivers/net/enic/enic_main.c | 4 +--
drivers/net/fm10k/fm10k_ethdev.c | 32 ++++++++++++------------
drivers/net/hns3/hns3_rxtx.c | 28 ++++++++++-----------
drivers/net/nfp/nfdk/nfp_nfdk_vec_stub.c | 4 +--
drivers/net/nfp/nfp_rxtx_vec_stub.c | 8 +++---
drivers/net/virtio/virtio_rxtx.c | 8 +++---
drivers/net/virtio/virtio_rxtx_simple.c | 4 +--
7 files changed, 44 insertions(+), 44 deletions(-)
diff --git a/drivers/net/enic/enic_main.c b/drivers/net/enic/enic_main.c
index b755b15d92..8bcd620bb8 100644
--- a/drivers/net/enic/enic_main.c
+++ b/drivers/net/enic/enic_main.c
@@ -513,8 +513,8 @@ static void enic_prep_wq_for_simple_tx(struct enic *enic, uint16_t queue_idx)
* The 'strong' version is in enic_rxtx_vec_avx2.c. This weak version is used
* used when that file is not compiled.
*/
-__rte_weak bool
-enic_use_vector_rx_handler(__rte_unused struct rte_eth_dev *eth_dev)
+bool
+RTE_WEAK(enic_use_vector_rx_handler)(__rte_unused struct rte_eth_dev *eth_dev)
{
return false;
}
diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c
index 7b490bea17..26385c6bd4 100644
--- a/drivers/net/fm10k/fm10k_ethdev.c
+++ b/drivers/net/fm10k/fm10k_ethdev.c
@@ -130,14 +130,14 @@ fm10k_mbx_unlock(struct fm10k_hw *hw)
}
/* Stubs needed for linkage when vPMD is disabled */
-__rte_weak int
-fm10k_rx_vec_condition_check(__rte_unused struct rte_eth_dev *dev)
+int
+RTE_WEAK(fm10k_rx_vec_condition_check)(__rte_unused struct rte_eth_dev *dev)
{
return -1;
}
-__rte_weak uint16_t
-fm10k_recv_pkts_vec(
+uint16_t
+RTE_WEAK(fm10k_recv_pkts_vec)(
__rte_unused void *rx_queue,
__rte_unused struct rte_mbuf **rx_pkts,
__rte_unused uint16_t nb_pkts)
@@ -145,8 +145,8 @@ fm10k_recv_pkts_vec(
return 0;
}
-__rte_weak uint16_t
-fm10k_recv_scattered_pkts_vec(
+uint16_t
+RTE_WEAK(fm10k_recv_scattered_pkts_vec)(
__rte_unused void *rx_queue,
__rte_unused struct rte_mbuf **rx_pkts,
__rte_unused uint16_t nb_pkts)
@@ -154,34 +154,34 @@ fm10k_recv_scattered_pkts_vec(
return 0;
}
-__rte_weak int
-fm10k_rxq_vec_setup(__rte_unused struct fm10k_rx_queue *rxq)
+int
+RTE_WEAK(fm10k_rxq_vec_setup)(__rte_unused struct fm10k_rx_queue *rxq)
{
return -1;
}
-__rte_weak void
-fm10k_rx_queue_release_mbufs_vec(
+void
+RTE_WEAK(fm10k_rx_queue_release_mbufs_vec)(
__rte_unused struct fm10k_rx_queue *rxq)
{
return;
}
-__rte_weak void
-fm10k_txq_vec_setup(__rte_unused struct fm10k_tx_queue *txq)
+void
+RTE_WEAK(fm10k_txq_vec_setup)(__rte_unused struct fm10k_tx_queue *txq)
{
return;
}
-__rte_weak int
-fm10k_tx_vec_condition_check(__rte_unused struct fm10k_tx_queue *txq)
+int
+RTE_WEAK(fm10k_tx_vec_condition_check)(__rte_unused struct fm10k_tx_queue *txq)
{
return -1;
}
-__rte_weak uint16_t
-fm10k_xmit_fixed_burst_vec(__rte_unused void *tx_queue,
+uint16_t
+RTE_WEAK(fm10k_xmit_fixed_burst_vec)(__rte_unused void *tx_queue,
__rte_unused struct rte_mbuf **tx_pkts,
__rte_unused uint16_t nb_pkts)
{
diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c
index 03bbbc435f..392e19a6bc 100644
--- a/drivers/net/hns3/hns3_rxtx.c
+++ b/drivers/net/hns3/hns3_rxtx.c
@@ -2787,27 +2787,27 @@ hns3_recv_scattered_pkts(void *rx_queue,
return nb_rx;
}
-void __rte_weak
-hns3_rxq_vec_setup(__rte_unused struct hns3_rx_queue *rxq)
+void
+RTE_WEAK(hns3_rxq_vec_setup)(__rte_unused struct hns3_rx_queue *rxq)
{
}
-int __rte_weak
-hns3_rx_check_vec_support(__rte_unused struct rte_eth_dev *dev)
+int
+RTE_WEAK(hns3_rx_check_vec_support)(__rte_unused struct rte_eth_dev *dev)
{
return -ENOTSUP;
}
-uint16_t __rte_weak
-hns3_recv_pkts_vec(__rte_unused void *rx_queue,
+uint16_t
+RTE_WEAK(hns3_recv_pkts_vec)(__rte_unused void *rx_queue,
__rte_unused struct rte_mbuf **rx_pkts,
__rte_unused uint16_t nb_pkts)
{
return 0;
}
-uint16_t __rte_weak
-hns3_recv_pkts_vec_sve(__rte_unused void *rx_queue,
+uint16_t
+RTE_WEAK(hns3_recv_pkts_vec_sve)(__rte_unused void *rx_queue,
__rte_unused struct rte_mbuf **rx_pkts,
__rte_unused uint16_t nb_pkts)
{
@@ -4256,22 +4256,22 @@ hns3_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
return nb_tx;
}
-int __rte_weak
-hns3_tx_check_vec_support(__rte_unused struct rte_eth_dev *dev)
+int
+RTE_WEAK(hns3_tx_check_vec_support)(__rte_unused struct rte_eth_dev *dev)
{
return -ENOTSUP;
}
-uint16_t __rte_weak
-hns3_xmit_pkts_vec(__rte_unused void *tx_queue,
+uint16_t
+RTE_WEAK(hns3_xmit_pkts_vec)(__rte_unused void *tx_queue,
__rte_unused struct rte_mbuf **tx_pkts,
__rte_unused uint16_t nb_pkts)
{
return 0;
}
-uint16_t __rte_weak
-hns3_xmit_pkts_vec_sve(void __rte_unused * tx_queue,
+uint16_t
+RTE_WEAK(hns3_xmit_pkts_vec_sve)(void __rte_unused * tx_queue,
struct rte_mbuf __rte_unused **tx_pkts,
uint16_t __rte_unused nb_pkts)
{
diff --git a/drivers/net/nfp/nfdk/nfp_nfdk_vec_stub.c b/drivers/net/nfp/nfdk/nfp_nfdk_vec_stub.c
index 146ec21d51..d9959d7549 100644
--- a/drivers/net/nfp/nfdk/nfp_nfdk_vec_stub.c
+++ b/drivers/net/nfp/nfdk/nfp_nfdk_vec_stub.c
@@ -5,8 +5,8 @@
#include "nfp_nfdk_vec.h"
-uint16_t __rte_weak
-nfp_net_nfdk_vec_avx2_xmit_pkts(__rte_unused void *tx_queue,
+uint16_t
+RTE_WEAK(nfp_net_nfdk_vec_avx2_xmit_pkts)(__rte_unused void *tx_queue,
__rte_unused struct rte_mbuf **tx_pkts,
__rte_unused uint16_t nb_pkts)
{
diff --git a/drivers/net/nfp/nfp_rxtx_vec_stub.c b/drivers/net/nfp/nfp_rxtx_vec_stub.c
index c480f61ef0..66924212ad 100644
--- a/drivers/net/nfp/nfp_rxtx_vec_stub.c
+++ b/drivers/net/nfp/nfp_rxtx_vec_stub.c
@@ -10,14 +10,14 @@
#include "nfp_rxtx_vec.h"
-bool __rte_weak
-nfp_net_get_avx2_supported(void)
+bool
+RTE_WEAK(nfp_net_get_avx2_supported)(void)
{
return false;
}
-uint16_t __rte_weak
-nfp_net_vec_avx2_recv_pkts(__rte_unused void *rx_queue,
+uint16_t
+RTE_WEAK(nfp_net_vec_avx2_recv_pkts)(__rte_unused void *rx_queue,
__rte_unused struct rte_mbuf **rx_pkts,
__rte_unused uint16_t nb_pkts)
{
diff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virtio_rxtx.c
index b67f063b31..170bae35c5 100644
--- a/drivers/net/virtio/virtio_rxtx.c
+++ b/drivers/net/virtio/virtio_rxtx.c
@@ -2045,16 +2045,16 @@ virtio_xmit_pkts_inorder(void *tx_queue,
return nb_tx;
}
-__rte_weak uint16_t
-virtio_recv_pkts_packed_vec(void *rx_queue __rte_unused,
+uint16_t
+RTE_WEAK(virtio_recv_pkts_packed_vec)(void *rx_queue __rte_unused,
struct rte_mbuf **rx_pkts __rte_unused,
uint16_t nb_pkts __rte_unused)
{
return 0;
}
-__rte_weak uint16_t
-virtio_xmit_pkts_packed_vec(void *tx_queue __rte_unused,
+uint16_t
+RTE_WEAK(virtio_xmit_pkts_packed_vec)(void *tx_queue __rte_unused,
struct rte_mbuf **tx_pkts __rte_unused,
uint16_t nb_pkts __rte_unused)
{
diff --git a/drivers/net/virtio/virtio_rxtx_simple.c b/drivers/net/virtio/virtio_rxtx_simple.c
index 438256970d..9c0a2c77ce 100644
--- a/drivers/net/virtio/virtio_rxtx_simple.c
+++ b/drivers/net/virtio/virtio_rxtx_simple.c
@@ -48,8 +48,8 @@ virtio_rxq_vec_setup(struct virtnet_rx *rxq)
}
/* Stub for linkage when arch specific implementation is not available */
-__rte_weak uint16_t
-virtio_recv_pkts_vec(void *rx_queue __rte_unused,
+uint16_t
+RTE_WEAK(virtio_recv_pkts_vec)(void *rx_queue __rte_unused,
struct rte_mbuf **rx_pkts __rte_unused,
uint16_t nb_pkts __rte_unused)
{
--
2.47.0.vfs.0.3
^ permalink raw reply [flat|nested] 6+ messages in thread