* [PATCH] common/mlx5: use intrinsics instead of inline assembly
@ 2025-05-05 14:57 Andre Muezerie
0 siblings, 0 replies; only message in thread
From: Andre Muezerie @ 2025-05-05 14:57 UTC (permalink / raw)
To: Dariusz Sosnowski, Viacheslav Ovsiienko, Bing Zhao, Ori Kam,
Suanming Mou, Matan Azrad
Cc: dev, Andre Muezerie
When compiling with MSVC the errors below are hit because msvc does not
support inline assembly:
1)
../drivers/common/mlx5/mlx5_common.c(86): warning C4013: '__asm__'
undefined; assuming extern returning int
../drivers/common/mlx5/mlx5_common.c(87): error C2143: syntax error:
missing ')' before ':'
2)
../drivers/net/mlx5/mlx5_txpp.c(510): error C2065: '__asm__':
undeclared identifier
../drivers/net/mlx5/mlx5_txpp.c(510): error C2143: syntax error:
missing ';' before 'volatile'
The fix for (1) is to use compiler intrinsic __cpuid and for (2)
intrinsic _InterlockedCompareExchange128 can be used.
Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
---
drivers/common/mlx5/mlx5_common.c | 13 +++++++++++--
drivers/net/mlx5/mlx5_txpp.c | 15 +++++++++++++++
2 files changed, 26 insertions(+), 2 deletions(-)
diff --git a/drivers/common/mlx5/mlx5_common.c b/drivers/common/mlx5/mlx5_common.c
index 4f25127582..e1ce17559d 100644
--- a/drivers/common/mlx5/mlx5_common.c
+++ b/drivers/common/mlx5/mlx5_common.c
@@ -75,9 +75,18 @@ static inline void mlx5_cpu_id(unsigned int level,
unsigned int *eax, unsigned int *ebx,
unsigned int *ecx, unsigned int *edx)
{
+#ifdef RTE_TOOLCHAIN_MSVC
+ int data[4];
+ __cpuid(data, level);
+ *eax = data[0];
+ *ebx = data[1];
+ *ecx = data[2];
+ *edx = data[3];
+#else
__asm__("cpuid\n\t"
- : "=a" (*eax), "=b" (*ebx), "=c" (*ecx), "=d" (*edx)
- : "0" (level));
+ : "=a" (*eax), "=b" (*ebx), "=c" (*ecx), "=d" (*edx)
+ : "0" (level));
+#endif
}
#endif
diff --git a/drivers/net/mlx5/mlx5_txpp.c b/drivers/net/mlx5/mlx5_txpp.c
index e6d3ad83e9..5bbaf668e6 100644
--- a/drivers/net/mlx5/mlx5_txpp.c
+++ b/drivers/net/mlx5/mlx5_txpp.c
@@ -486,6 +486,20 @@ mlx5_txpp_cq_arm(struct mlx5_dev_ctx_shared *sh)
}
#if defined(RTE_ARCH_X86_64)
+#ifdef RTE_TOOLCHAIN_MSVC
+static inline int
+mlx5_atomic128_compare_exchange(rte_int128_t *dst,
+ rte_int128_t *exp,
+ const rte_int128_t *src)
+{
+ return (int)_InterlockedCompareExchange128(
+ (int64_t volatile *)dst,
+ src->val[1], /* exchange high */
+ src->val[0], /* exchange low */
+ (int64_t *)exp /* comparand result */
+ );
+}
+#else
static inline int
mlx5_atomic128_compare_exchange(rte_int128_t *dst,
rte_int128_t *exp,
@@ -510,6 +524,7 @@ mlx5_atomic128_compare_exchange(rte_int128_t *dst,
return res;
}
#endif
+#endif
static inline void
mlx5_atomic_read_cqe(rte_int128_t *from, rte_int128_t *ts)
--
2.49.0.vfs.0.2
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2025-05-05 14:57 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-05-05 14:57 [PATCH] common/mlx5: use intrinsics instead of inline assembly Andre Muezerie
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).