From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id BD33146879; Wed, 4 Jun 2025 16:15:43 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AAB5E42D80; Wed, 4 Jun 2025 16:15:43 +0200 (CEST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 65CB4427DA for ; Wed, 4 Jun 2025 16:15:42 +0200 (CEST) Received: by linux.microsoft.com (Postfix, from userid 1213) id 57C93201FF4D; Wed, 4 Jun 2025 07:15:41 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 57C93201FF4D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1749046541; bh=jLh/8gdh5WiqY+h7P7wNEIRqPIR31ar5f8K1Qgm1AjY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lt7KAFxahQ68cmLbzT7xyMkcR8Wgxoy18oJfKKZeuD8QJ/jRtMS1J4y4i+u6yO0F4 nXdnZRVH0IPzl6VuZBpyE1Gb+ulavH6eonpZ1qwIB1T5tBBnnfLYzpaUc7Y5n5cQKW 6DyMDtru3qm5+wYgixUGsFAh6ydDgOizXPB7H8n0= From: Andre Muezerie To: andremue@linux.microsoft.com Cc: bingz@nvidia.com, dev@dpdk.org, dsosnowski@nvidia.com, matan@nvidia.com, orika@nvidia.com, suanmingm@nvidia.com, viacheslavo@nvidia.com Subject: [PATCH v2] common/mlx5: use intrinsics instead of inline assembly Date: Wed, 4 Jun 2025 07:15:25 -0700 Message-Id: <1749046525-9166-1-git-send-email-andremue@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1746457062-8502-1-git-send-email-andremue@linux.microsoft.com> References: <1746457062-8502-1-git-send-email-andremue@linux.microsoft.com> X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org 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 --- drivers/common/mlx5/mlx5_common.c | 13 +++++++++++-- drivers/net/mlx5/mlx5_txpp.c | 11 +++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/drivers/common/mlx5/mlx5_common.c b/drivers/common/mlx5/mlx5_common.c index ebe327a950..fbe1578a84 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..0e99b58bde 100644 --- a/drivers/net/mlx5/mlx5_txpp.c +++ b/drivers/net/mlx5/mlx5_txpp.c @@ -486,6 +486,16 @@ 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], src->val[0], (int64_t *)exp); +} +#else static inline int mlx5_atomic128_compare_exchange(rte_int128_t *dst, rte_int128_t *exp, @@ -510,6 +520,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.3