From patchwork Mon Apr 3 21:52:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 125732 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3EE83428C3; Mon, 3 Apr 2023 23:52:43 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 82E6041143; Mon, 3 Apr 2023 23:52:39 +0200 (CEST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 161304067E for ; Mon, 3 Apr 2023 23:52:37 +0200 (CEST) Received: by linux.microsoft.com (Postfix, from userid 1086) id 5F8C4210DC5D; Mon, 3 Apr 2023 14:52:36 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 5F8C4210DC5D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1680558756; bh=5ltsvVaUMbKkOdztLnohPoEDJyNO4qKJ6XNaAjGfoFU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SZZjl9yoOfEn7Ix4/ef5G9ZYkbcfv2LHFjiDe28qfIos+oyC44nPh3dWI6eTENSLk cIwt1ZByarg1BjtG0Z40+wOGcF6F6znHeWD8xvrkWhCfkr7MFUIjr+vFkrAxOc4VpT zyJEmhLeH99yC6qBCsAe4BXUZbNM3q2WGL2HPsew= From: Tyler Retzlaff To: dev@dpdk.org Cc: bruce.richardson@intel.com, david.marchand@redhat.com, thomas@monjalon.net, mb@smartsharesystems.com, Tyler Retzlaff Subject: [PATCH 1/9] eal: use rdtsc intrinsic when compiling with msvc Date: Mon, 3 Apr 2023 14:52:23 -0700 Message-Id: <1680558751-17931-2-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1680558751-17931-1-git-send-email-roretzla@linux.microsoft.com> References: <1680558751-17931-1-git-send-email-roretzla@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 Inline assembly is not supported for msvc x64 instead use __rdtsc intrinsic. Signed-off-by: Tyler Retzlaff --- lib/eal/x86/include/rte_cycles.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/eal/x86/include/rte_cycles.h b/lib/eal/x86/include/rte_cycles.h index a461a4d..0c142ce 100644 --- a/lib/eal/x86/include/rte_cycles.h +++ b/lib/eal/x86/include/rte_cycles.h @@ -6,6 +6,10 @@ #ifndef _RTE_CYCLES_X86_64_H_ #define _RTE_CYCLES_X86_64_H_ +#ifdef RTE_TOOLCHAIN_MSVC +#include +#endif + #ifdef __cplusplus extern "C" { #endif @@ -23,6 +27,7 @@ static inline uint64_t rte_rdtsc(void) { +#ifndef RTE_TOOLCHAIN_MSVC union { uint64_t tsc_64; RTE_STD_C11 @@ -47,6 +52,9 @@ "=a" (tsc.lo_32), "=d" (tsc.hi_32)); return tsc.tsc_64; +#else + return __rdtsc(); +#endif } static inline uint64_t From patchwork Mon Apr 3 21:52:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 125734 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A0B19428C3; Mon, 3 Apr 2023 23:52:54 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B82A242BB1; Mon, 3 Apr 2023 23:52:41 +0200 (CEST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 4382F40EDE for ; Mon, 3 Apr 2023 23:52:37 +0200 (CEST) Received: by linux.microsoft.com (Postfix, from userid 1086) id 6BA56210DC68; Mon, 3 Apr 2023 14:52:36 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 6BA56210DC68 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1680558756; bh=aVNgvOGAqJXcMymeeUabNQLNbDPaZZ1fFdt0Ib9Ah9I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hUmHz4qghhx2E3LI54Wr8UCWEhCDvQTdCDpElepoc016qYWFO8j/+5GvP2pX3UASC 7bUI6jJPW7Zi3EjL3CvPylDq36r3FgDylmYqJaphf6FwyKjPZJx8Ng9+OwiRiGejmq lYk42oDnlX3s/i2+x+dSq7Gau7iAyPfh9KfDdJhs= From: Tyler Retzlaff To: dev@dpdk.org Cc: bruce.richardson@intel.com, david.marchand@redhat.com, thomas@monjalon.net, mb@smartsharesystems.com, Tyler Retzlaff Subject: [PATCH 2/9] eal: use rtm and xtest intrinsics when compiling with msvc Date: Mon, 3 Apr 2023 14:52:24 -0700 Message-Id: <1680558751-17931-3-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1680558751-17931-1-git-send-email-roretzla@linux.microsoft.com> References: <1680558751-17931-1-git-send-email-roretzla@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 Inline assembly is not supported for msvc x64 instead use _xbegin, _xend, _xabort and _xtest intrinsics. Signed-off-by: Tyler Retzlaff --- lib/eal/x86/include/rte_rtm.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/lib/eal/x86/include/rte_rtm.h b/lib/eal/x86/include/rte_rtm.h index 36bf498..26672cb 100644 --- a/lib/eal/x86/include/rte_rtm.h +++ b/lib/eal/x86/include/rte_rtm.h @@ -5,6 +5,9 @@ #ifndef _RTE_RTM_H_ #define _RTE_RTM_H_ 1 +#ifdef RTE_TOOLCHAIN_MSVC +#include +#endif /* Official RTM intrinsics interface matching gcc/icc, but works on older gcc compatible compilers and binutils. */ @@ -28,31 +31,47 @@ static __rte_always_inline unsigned int rte_xbegin(void) { +#ifndef RTE_TOOLCHAIN_MSVC unsigned int ret = RTE_XBEGIN_STARTED; asm volatile(".byte 0xc7,0xf8 ; .long 0" : "+a" (ret) :: "memory"); return ret; +#else + return _xbegin(); +#endif } static __rte_always_inline void rte_xend(void) { +#ifndef RTE_TOOLCHAIN_MSVC asm volatile(".byte 0x0f,0x01,0xd5" ::: "memory"); +#else + _xend(); +#endif } /* not an inline function to workaround a clang bug with -O0 */ +#ifndef RTE_TOOLCHAIN_MSVC #define rte_xabort(status) do { \ asm volatile(".byte 0xc6,0xf8,%P0" :: "i" (status) : "memory"); \ } while (0) +#else +#define rte_xabort(status) _xabort(status) +#endif static __rte_always_inline int rte_xtest(void) { +#ifndef RTE_TOOLCHAIN_MSVC unsigned char out; asm volatile(".byte 0x0f,0x01,0xd6 ; setnz %0" : "=r" (out) :: "memory"); return out; +#else + return _xtest(); +#endif } #ifdef __cplusplus From patchwork Mon Apr 3 21:52:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 125733 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A30D8428C3; Mon, 3 Apr 2023 23:52:48 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A12EC427F2; Mon, 3 Apr 2023 23:52:40 +0200 (CEST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 32C2940ED7 for ; Mon, 3 Apr 2023 23:52:37 +0200 (CEST) Received: by linux.microsoft.com (Postfix, from userid 1086) id 77E81210DC6B; Mon, 3 Apr 2023 14:52:36 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 77E81210DC6B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1680558756; bh=NkYdfoiTJaLrhHz7KcRNOGzqWAXr+CfWASjfC2PM8fo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZqnRF2KnIJk80FF7eBjw5qAeyZNOGiho8KQVJh/nMBzui4fFX6lOvVt+gh6sJ/dfn 0dRy0wrKM3hWqKlIXGCMxu8YNA7Q5SFqMTIBmNzHqAz8ylkbU6A5KTzx8LXanDtKcg iGCckbkQjpuCGLulpbxTN5OOR0teWlL54kWEnjB8= From: Tyler Retzlaff To: dev@dpdk.org Cc: bruce.richardson@intel.com, david.marchand@redhat.com, thomas@monjalon.net, mb@smartsharesystems.com, Tyler Retzlaff Subject: [PATCH 3/9] eal: use barrier intrinsics when compiling with msvc Date: Mon, 3 Apr 2023 14:52:25 -0700 Message-Id: <1680558751-17931-4-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1680558751-17931-1-git-send-email-roretzla@linux.microsoft.com> References: <1680558751-17931-1-git-send-email-roretzla@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 Inline assembly is not supported for msvc x64 instead use _{Read,Write,ReadWrite}Barrier() intrinsics. Signed-off-by: Tyler Retzlaff --- lib/eal/include/generic/rte_atomic.h | 4 ++++ lib/eal/x86/include/rte_atomic.h | 10 +++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/eal/include/generic/rte_atomic.h b/lib/eal/include/generic/rte_atomic.h index 234b268..e973184 100644 --- a/lib/eal/include/generic/rte_atomic.h +++ b/lib/eal/include/generic/rte_atomic.h @@ -116,9 +116,13 @@ * Guarantees that operation reordering does not occur at compile time * for operations directly before and after the barrier. */ +#ifndef RTE_TOOLCHAIN_MSVC #define rte_compiler_barrier() do { \ asm volatile ("" : : : "memory"); \ } while(0) +#else +#define rte_compiler_barrier() _ReadWriteBarrier() +#endif /** * Synchronization fence between threads based on the specified memory order. diff --git a/lib/eal/x86/include/rte_atomic.h b/lib/eal/x86/include/rte_atomic.h index f2ee1a9..5cce9ba 100644 --- a/lib/eal/x86/include/rte_atomic.h +++ b/lib/eal/x86/include/rte_atomic.h @@ -27,9 +27,13 @@ #define rte_rmb() _mm_lfence() +#ifndef RTE_TOOLCHAIN_MSVC #define rte_smp_wmb() rte_compiler_barrier() - #define rte_smp_rmb() rte_compiler_barrier() +#else +#define rte_smp_wmb() _WriteBarrier() +#define rte_smp_rmb() _ReadBarrier() +#endif /* * From Intel Software Development Manual; Vol 3; @@ -66,11 +70,15 @@ static __rte_always_inline void rte_smp_mb(void) { +#ifndef RTE_TOOLCHAIN_MSVC #ifdef RTE_ARCH_I686 asm volatile("lock addl $0, -128(%%esp); " ::: "memory"); #else asm volatile("lock addl $0, -128(%%rsp); " ::: "memory"); #endif +#else + rte_compiler_barrier(); +#endif } #define rte_io_mb() rte_mb() From patchwork Mon Apr 3 21:52:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 125735 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 5EEB9428C3; Mon, 3 Apr 2023 23:53:00 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3BFDC427E9; Mon, 3 Apr 2023 23:52:43 +0200 (CEST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 4CB2D410D1 for ; Mon, 3 Apr 2023 23:52:37 +0200 (CEST) Received: by linux.microsoft.com (Postfix, from userid 1086) id 84337210DC6D; Mon, 3 Apr 2023 14:52:36 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 84337210DC6D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1680558756; bh=WfIZcnRYKGDh1nXpqtqJc/Dfdhg/l+26IcDfS6neT/8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Jo3sAegOdKhhBPMiodv9gQ2t0XUSodlzAPxXITUCebstckc5zrpYzAtXiSlBercqg 8A+W111BnGqQ+NbS3XVME50lKBNrkjX8agrldcpODXMVhok/nWwwMDjThyCPKXy9LM gNtkZHa2ovywG59WjOTcxiZZYhu+zwE+iVKuL8QI= From: Tyler Retzlaff To: dev@dpdk.org Cc: bruce.richardson@intel.com, david.marchand@redhat.com, thomas@monjalon.net, mb@smartsharesystems.com, Tyler Retzlaff Subject: [PATCH 4/9] eal: typedef cpu flag enum as int for msvc Date: Mon, 3 Apr 2023 14:52:26 -0700 Message-Id: <1680558751-17931-5-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1680558751-17931-1-git-send-email-roretzla@linux.microsoft.com> References: <1680558751-17931-1-git-send-email-roretzla@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 Forward declaration of a typedef is a non-standard extension and is not supported by msvc. Use an int instead. Abstract the use of the int/enum rte_cpu_flag_t in function parameter lists by re-typdefing the enum rte_cpu_flag_t to the rte_cpu_flag_t identifier. Remove the use of __extension__ on function prototypes where rte_cpu_flag_t appared in parameter lists, it is sufficient to have the conditionally compiled __extension__ at the non-standard forward declaration site. Signed-off-by: Tyler Retzlaff --- lib/eal/include/generic/rte_cpuflags.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/eal/include/generic/rte_cpuflags.h b/lib/eal/include/generic/rte_cpuflags.h index d35551e..87ab03c 100644 --- a/lib/eal/include/generic/rte_cpuflags.h +++ b/lib/eal/include/generic/rte_cpuflags.h @@ -44,8 +44,12 @@ struct rte_cpu_intrinsics { /** * Enumeration of all CPU features supported */ +#ifndef RTE_TOOLCHAIN_MSVC __extension__ -enum rte_cpu_flag_t; +typedef enum rte_cpu_flag_t rte_cpu_flag_t; +#else +typedef int rte_cpu_flag_t; +#endif /** * Get name of CPU flag @@ -56,9 +60,8 @@ struct rte_cpu_intrinsics { * flag name * NULL if flag ID is invalid */ -__extension__ const char * -rte_cpu_get_flag_name(enum rte_cpu_flag_t feature); +rte_cpu_get_flag_name(rte_cpu_flag_t feature); /** * Function for checking a CPU flag availability @@ -70,9 +73,8 @@ struct rte_cpu_intrinsics { * 0 if flag is not available * -ENOENT if flag is invalid */ -__extension__ int -rte_cpu_get_flag_enabled(enum rte_cpu_flag_t feature); +rte_cpu_get_flag_enabled(rte_cpu_flag_t feature); /** * This function checks that the currently used CPU supports the CPU features From patchwork Mon Apr 3 21:52:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 125740 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 695B0428C3; Mon, 3 Apr 2023 23:53:32 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 627B042D3E; Mon, 3 Apr 2023 23:52:49 +0200 (CEST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 0A6D6410D1 for ; Mon, 3 Apr 2023 23:52:38 +0200 (CEST) Received: by linux.microsoft.com (Postfix, from userid 1086) id 90406210DC70; Mon, 3 Apr 2023 14:52:36 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 90406210DC70 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1680558756; bh=RGOshNuMPn+0padrIfYfv4CpESAP5aLLZV7po6DDosE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MDk1+0tv8aVil2bGzn43bfkWo0GUtyjYsRA/mD9tq7vUG41Z2anZV436fPS0K0o2h UZy2LTkznS/hfPcnJKYpIS/rd9pBgNZwy5eKE5dZewL53mjxHJiZA69D4pragZcDLe 9VvKQgr7HStDHPJLPrLO4E4NM0AR6/ejr5xyvYak= From: Tyler Retzlaff To: dev@dpdk.org Cc: bruce.richardson@intel.com, david.marchand@redhat.com, thomas@monjalon.net, mb@smartsharesystems.com, Tyler Retzlaff Subject: [PATCH 5/9] eal: hide GCC extension based alignment markers Date: Mon, 3 Apr 2023 14:52:27 -0700 Message-Id: <1680558751-17931-6-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1680558751-17931-1-git-send-email-roretzla@linux.microsoft.com> References: <1680558751-17931-1-git-send-email-roretzla@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 don't expose typedefs used as alignment markers. Signed-off-by: Tyler Retzlaff --- lib/eal/include/rte_common.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/eal/include/rte_common.h b/lib/eal/include/rte_common.h index 15765b4..2f464e3 100644 --- a/lib/eal/include/rte_common.h +++ b/lib/eal/include/rte_common.h @@ -460,6 +460,8 @@ static void __attribute__((destructor(RTE_PRIO(prio)), used)) func(void) /*********** Structure alignment markers ********/ +#ifndef RTE_TOOLCHAIN_MSVC + /** Generic marker for any place in a structure. */ __extension__ typedef void *RTE_MARKER[0]; /** Marker for 1B alignment in a structure. */ @@ -471,6 +473,8 @@ static void __attribute__((destructor(RTE_PRIO(prio)), used)) func(void) /** Marker for 8B alignment in a structure. */ __extension__ typedef uint64_t RTE_MARKER64[0]; +#endif + /** * Combines 32b inputs most significant set bits into the least * significant bits to construct a value with the same MSBs as x From patchwork Mon Apr 3 21:52:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 125739 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2A58F428C3; Mon, 3 Apr 2023 23:53:27 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 456E742D37; Mon, 3 Apr 2023 23:52:48 +0200 (CEST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id D911C4067E for ; Mon, 3 Apr 2023 23:52:37 +0200 (CEST) Received: by linux.microsoft.com (Postfix, from userid 1086) id 9C45D210DC73; Mon, 3 Apr 2023 14:52:36 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 9C45D210DC73 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1680558756; bh=DnaZ14ATtMFkJVRoRlrZQMfdkaZJ+/vXFYhJkmlWy/k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F1U4KJDRD89Ra7cbyGWymRYU5aL88NmBraqy04Q81MY3FhGTy2eVxNXJggSrFg6KX kLMC9B96FIK/pCDvjr+9MamCOKe5ntX2FPM2SRF2Pd0zUfmpRpXAgYH8EFXCY6+Qp+ SDVr33O+FoZtjE35SXZAq3bMcMaxVXXqwMomd3E8= From: Tyler Retzlaff To: dev@dpdk.org Cc: bruce.richardson@intel.com, david.marchand@redhat.com, thomas@monjalon.net, mb@smartsharesystems.com, Tyler Retzlaff Subject: [PATCH 6/9] eal: expand most macros to empty when using msvc Date: Mon, 3 Apr 2023 14:52:28 -0700 Message-Id: <1680558751-17931-7-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1680558751-17931-1-git-send-email-roretzla@linux.microsoft.com> References: <1680558751-17931-1-git-send-email-roretzla@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 For now expand a lot of common rte macros empty. The catch here is we need to test that most of the macros do what they should but at the same time they are blocking work needed to bootstrap of the unit tests. Later we will return and provide (where possible) expansions that work correctly for msvc and where not possible provide some alternate macros to achieve the same outcome. Signed-off-by: Tyler Retzlaff --- lib/eal/include/rte_branch_prediction.h | 8 ++++++++ lib/eal/include/rte_common.h | 33 +++++++++++++++++++++++++++++++++ lib/eal/include/rte_compat.h | 20 ++++++++++++++++++++ 3 files changed, 61 insertions(+) diff --git a/lib/eal/include/rte_branch_prediction.h b/lib/eal/include/rte_branch_prediction.h index 0256a9d..3589c97 100644 --- a/lib/eal/include/rte_branch_prediction.h +++ b/lib/eal/include/rte_branch_prediction.h @@ -25,7 +25,11 @@ * */ #ifndef likely +#ifndef RTE_TOOLCHAIN_MSVC #define likely(x) __builtin_expect(!!(x), 1) +#else +#define likely(x) (!!(x) == 1) +#endif #endif /* likely */ /** @@ -39,7 +43,11 @@ * */ #ifndef unlikely +#ifndef RTE_TOOLCHAIN_MSVC #define unlikely(x) __builtin_expect(!!(x), 0) +#else +#define unlikely(x) (!!(x) == 0) +#endif #endif /* unlikely */ #ifdef __cplusplus diff --git a/lib/eal/include/rte_common.h b/lib/eal/include/rte_common.h index 2f464e3..a724e22 100644 --- a/lib/eal/include/rte_common.h +++ b/lib/eal/include/rte_common.h @@ -65,7 +65,11 @@ /** * Force alignment */ +#ifndef RTE_TOOLCHAIN_MSVC #define __rte_aligned(a) __attribute__((__aligned__(a))) +#else +#define __rte_aligned(a) +#endif #ifdef RTE_ARCH_STRICT_ALIGN typedef uint64_t unaligned_uint64_t __rte_aligned(1); @@ -88,8 +92,13 @@ #define __rte_may_alias __attribute__((__may_alias__)) /******* Macro to mark functions and fields scheduled for removal *****/ +#ifndef RTE_TOOLCHAIN_MSVC #define __rte_deprecated __attribute__((__deprecated__)) #define __rte_deprecated_msg(msg) __attribute__((__deprecated__(msg))) +#else +#define __rte_deprecated +#define __rte_deprecated_msg(msg) +#endif /** * Macro to mark macros and defines scheduled for removal @@ -117,7 +126,11 @@ /** * short definition to mark a function parameter unused */ +#ifndef RTE_TOOLCHAIN_MSVC #define __rte_unused __attribute__((__unused__)) +#else +#define __rte_unused +#endif /** * Mark pointer as restricted with regard to pointer aliasing. @@ -141,6 +154,7 @@ * even if the underlying stdio implementation is ANSI-compliant, * so this must be overridden. */ +#ifndef RTE_TOOLCHAIN_MSVC #if RTE_CC_IS_GNU #define __rte_format_printf(format_index, first_arg) \ __attribute__((format(gnu_printf, format_index, first_arg))) @@ -148,6 +162,9 @@ #define __rte_format_printf(format_index, first_arg) \ __attribute__((format(printf, format_index, first_arg))) #endif +#else +#define __rte_format_printf(format_index, first_arg) +#endif /** * Tells compiler that the function returns a value that points to @@ -222,7 +239,11 @@ static void __attribute__((destructor(RTE_PRIO(prio)), used)) func(void) /** * Hint never returning function */ +#ifndef RTE_TOOLCHAIN_MSVC #define __rte_noreturn __attribute__((noreturn)) +#else +#define __rte_noreturn +#endif /** * Issue a warning in case the function's return value is ignored. @@ -247,12 +268,20 @@ static void __attribute__((destructor(RTE_PRIO(prio)), used)) func(void) * } * @endcode */ +#ifndef RTE_TOOLCHAIN_MSVC #define __rte_warn_unused_result __attribute__((warn_unused_result)) +#else +#define __rte_warn_unused_result +#endif /** * Force a function to be inlined */ +#ifndef RTE_TOOLCHAIN_MSVC #define __rte_always_inline inline __attribute__((always_inline)) +#else +#define __rte_always_inline +#endif /** * Force a function to be noinlined @@ -437,7 +466,11 @@ static void __attribute__((destructor(RTE_PRIO(prio)), used)) func(void) #define RTE_CACHE_LINE_MIN_SIZE 64 /** Force alignment to cache line. */ +#ifndef RTE_TOOLCHAIN_MSVC #define __rte_cache_aligned __rte_aligned(RTE_CACHE_LINE_SIZE) +#else +#define __rte_cache_aligned +#endif /** Force minimum cache line alignment. */ #define __rte_cache_min_aligned __rte_aligned(RTE_CACHE_LINE_MIN_SIZE) diff --git a/lib/eal/include/rte_compat.h b/lib/eal/include/rte_compat.h index fc9fbaa..6a4b5ee 100644 --- a/lib/eal/include/rte_compat.h +++ b/lib/eal/include/rte_compat.h @@ -12,14 +12,22 @@ #ifndef ALLOW_EXPERIMENTAL_API +#ifndef RTE_TOOLCHAIN_MSVC #define __rte_experimental \ __attribute__((deprecated("Symbol is not yet part of stable ABI"), \ section(".text.experimental"))) +#else +#define __rte_experimental +#endif #else +#ifndef RTE_TOOLCHAIN_MSVC #define __rte_experimental \ __attribute__((section(".text.experimental"))) +#else +#define __rte_experimental +#endif #endif @@ -30,23 +38,35 @@ #if !defined ALLOW_INTERNAL_API && __has_attribute(error) /* For GCC */ +#ifndef RTE_TOOLCHAIN_MSVC #define __rte_internal \ __attribute__((error("Symbol is not public ABI"), \ section(".text.internal"))) +#else +#define __rte_internal +#endif #elif !defined ALLOW_INTERNAL_API && __has_attribute(diagnose_if) /* For clang */ +#ifndef RTE_TOOLCHAIN_MSVC #define __rte_internal \ _Pragma("GCC diagnostic push") \ _Pragma("GCC diagnostic ignored \"-Wgcc-compat\"") \ __attribute__((diagnose_if(1, "Symbol is not public ABI", "error"), \ section(".text.internal"))) \ _Pragma("GCC diagnostic pop") +#else +#define __rte_internal +#endif #else +#ifndef RTE_TOOLCHAIN_MSVC #define __rte_internal \ __attribute__((section(".text.internal"))) +#else +#define __rte_internal +#endif #endif From patchwork Mon Apr 3 21:52:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 125736 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 915C0428C3; Mon, 3 Apr 2023 23:53:09 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id ED2B842C54; Mon, 3 Apr 2023 23:52:44 +0200 (CEST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id D7ABB40156 for ; Mon, 3 Apr 2023 23:52:37 +0200 (CEST) Received: by linux.microsoft.com (Postfix, from userid 1086) id A8865210DC76; Mon, 3 Apr 2023 14:52:36 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com A8865210DC76 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1680558756; bh=uH50+MFvPHR3vD/Mq60lPgkZKJADsnrYD4/ri9Wn6kk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z4zHOu1cD+N0QzoCv/edQI/zaZCvx1ElIqyxT4ONELGWK76xmR+PZBX+xRiBCEmF3 a5XlrFodF2nBVqE1955XtmSJSoBITcLVV977g5zt94/Y0TR4iWy+uDD4ImkvpdoZoZ qSRPQW4M9BE79CAlKfwgzn0IiM5IZtw+69NOsezI= From: Tyler Retzlaff To: dev@dpdk.org Cc: bruce.richardson@intel.com, david.marchand@redhat.com, thomas@monjalon.net, mb@smartsharesystems.com, Tyler Retzlaff Subject: [PATCH 7/9] eal: exclude exposure of rte atomic APIs for MSVC builds Date: Mon, 3 Apr 2023 14:52:29 -0700 Message-Id: <1680558751-17931-8-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1680558751-17931-1-git-send-email-roretzla@linux.microsoft.com> References: <1680558751-17931-1-git-send-email-roretzla@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 It's discouraged to use rte_atomics APIs instead standard APIs should be used from C11. Since MSVC is a new toolchain/platform combination block visibility of the rte_atomic APIs from day 1. Signed-off-by: Tyler Retzlaff --- lib/eal/include/generic/rte_atomic.h | 7 +++++++ lib/eal/x86/include/rte_atomic.h | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/lib/eal/include/generic/rte_atomic.h b/lib/eal/include/generic/rte_atomic.h index e973184..1964697 100644 --- a/lib/eal/include/generic/rte_atomic.h +++ b/lib/eal/include/generic/rte_atomic.h @@ -131,6 +131,8 @@ /*------------------------- 16 bit atomic operations -------------------------*/ +#ifndef RTE_TOOLCHAIN_MSVC + /** * Atomic compare and set. * @@ -1038,8 +1040,11 @@ static inline void rte_atomic64_clear(rte_atomic64_t *v) } #endif +#endif + /*------------------------ 128 bit atomic operations -------------------------*/ + /** * 128-bit integer structure. */ @@ -1049,8 +1054,10 @@ static inline void rte_atomic64_clear(rte_atomic64_t *v) union { uint64_t val[2]; #ifdef RTE_ARCH_64 +#ifndef RTE_TOOLCHAIN_MSVC __extension__ __int128 int128; #endif +#endif }; } __rte_aligned(16) rte_int128_t; diff --git a/lib/eal/x86/include/rte_atomic.h b/lib/eal/x86/include/rte_atomic.h index 5cce9ba..20f3380 100644 --- a/lib/eal/x86/include/rte_atomic.h +++ b/lib/eal/x86/include/rte_atomic.h @@ -87,6 +87,8 @@ #define rte_io_rmb() rte_compiler_barrier() +#ifndef RTE_TOOLCHAIN_MSVC + /** * Synchronization fence between threads based on the specified memory order. * @@ -283,6 +285,8 @@ static inline int rte_atomic32_dec_and_test(rte_atomic32_t *v) #include "rte_atomic_64.h" #endif +#endif + #ifdef __cplusplus } #endif From patchwork Mon Apr 3 21:52:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 125737 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 83D85428C3; Mon, 3 Apr 2023 23:53:15 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1718D42D29; Mon, 3 Apr 2023 23:52:46 +0200 (CEST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id D928D40ED7 for ; Mon, 3 Apr 2023 23:52:37 +0200 (CEST) Received: by linux.microsoft.com (Postfix, from userid 1086) id B4D96210DC7A; Mon, 3 Apr 2023 14:52:36 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com B4D96210DC7A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1680558756; bh=UdRl6E4dhDfTdvJ/Ndp/1r/2c9CLJI/CsNAgZ1wnSmA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lpghkKMsL456Qmz6BB9X9JZJQcDGrcNDVLJR/PFzJT8rcpyIC2BUBzxU7Ha/30ftc gBSgOJqnXNF1ZiAuC2xMM4mcx+b7SmIBuiMpbgghBvxrZ26qUYrB7+LJHVP4qBeqc3 dtHmY86lZKxxSXgLHpfKWep1wg10QBNg/RCblS+0= From: Tyler Retzlaff To: dev@dpdk.org Cc: bruce.richardson@intel.com, david.marchand@redhat.com, thomas@monjalon.net, mb@smartsharesystems.com, Tyler Retzlaff Subject: [PATCH 8/9] telemetry: disable json print formatting with msvc Date: Mon, 3 Apr 2023 14:52:30 -0700 Message-Id: <1680558751-17931-9-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1680558751-17931-1-git-send-email-roretzla@linux.microsoft.com> References: <1680558751-17931-1-git-send-email-roretzla@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 VLAs are unsafe and will never be implemented in MSVC. When compiling with MSVC just return immediately indicating 0 output characters formatted. For now telemetry doesn't work on Windows, we will revisit support for the telemetry library sometime after we establish the DPDK unit tests. Signed-off-by: Tyler Retzlaff --- lib/telemetry/telemetry_json.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/telemetry/telemetry_json.h b/lib/telemetry/telemetry_json.h index 744bbfe..d847003 100644 --- a/lib/telemetry/telemetry_json.h +++ b/lib/telemetry/telemetry_json.h @@ -30,6 +30,7 @@ static inline int __json_snprintf(char *buf, const int len, const char *format, ...) { +#ifndef RTE_TOOLCHAIN_MSVC char tmp[len]; va_list ap; int ret; @@ -41,6 +42,7 @@ strcpy(buf, tmp); return ret; } +#endif return 0; /* nothing written or modified */ } @@ -60,6 +62,7 @@ static inline int __json_format_str(char *buf, const int len, const char *prefix, const char *str, const char *suffix) { +#ifndef RTE_TOOLCHAIN_MSVC char tmp[len]; int tmpidx = 0; @@ -98,6 +101,9 @@ strcpy(buf, tmp); return tmpidx; +#else + return 0; +#endif } /* Copies an empty array into the provided buffer. */ From patchwork Mon Apr 3 21:52:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 125738 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3B4F0428C3; Mon, 3 Apr 2023 23:53:21 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2DB8742D31; Mon, 3 Apr 2023 23:52:47 +0200 (CEST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 02FB240EDE for ; Mon, 3 Apr 2023 23:52:37 +0200 (CEST) Received: by linux.microsoft.com (Postfix, from userid 1086) id C0C5D210DC7C; Mon, 3 Apr 2023 14:52:36 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com C0C5D210DC7C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1680558756; bh=8s73UQQAtEQ2WczFyopp6uPfPk17PNcxGsk9aCTBFsw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gCgDeLvgBHigQzDvCDhGBOianlYVS41ar+X7Y0DCnYMpplxWld8dkIgocm91C7VTu VSRY6WZ1cno57Gp4n4XCCZSufSR8Jsm43ioHE8fyTWYCxurD9rAo1ZASuzaXPBaSOY W9dqbH0D4UFiL2bWKnvXYfrOHiuun3ByFznAQN3c= From: Tyler Retzlaff To: dev@dpdk.org Cc: bruce.richardson@intel.com, david.marchand@redhat.com, thomas@monjalon.net, mb@smartsharesystems.com, Tyler Retzlaff Subject: [PATCH 9/9] telemetry: avoid expanding versioned symbol macros on msvc Date: Mon, 3 Apr 2023 14:52:31 -0700 Message-Id: <1680558751-17931-10-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1680558751-17931-1-git-send-email-roretzla@linux.microsoft.com> References: <1680558751-17931-1-git-send-email-roretzla@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 Windows does not support versioned symbols. Fortunately Windows also doesn't have an exported stable ABI. Export rte_tel_data_add_array_int -> rte_tel_data_add_array_int_24 and rte_tel_data_add_dict_int -> rte_tel_data_add_dict_int_v24 functions. Windows does have a way to achieve similar versioning for symbols but it is not a simple #define so it will be done as a work package later. Signed-off-by: Tyler Retzlaff --- lib/telemetry/telemetry_data.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/telemetry/telemetry_data.c b/lib/telemetry/telemetry_data.c index 2bac2de..284c16e 100644 --- a/lib/telemetry/telemetry_data.c +++ b/lib/telemetry/telemetry_data.c @@ -82,8 +82,16 @@ /* mark the v23 function as the older version, and v24 as the default version */ VERSION_SYMBOL(rte_tel_data_add_array_int, _v23, 23); BIND_DEFAULT_SYMBOL(rte_tel_data_add_array_int, _v24, 24); +#ifndef RTE_TOOLCHAIN_MSVC MAP_STATIC_SYMBOL(int rte_tel_data_add_array_int(struct rte_tel_data *d, int64_t x), rte_tel_data_add_array_int_v24); +#else +int +rte_tel_data_add_array_int(struct rte_tel_data *d, int64_t x) +{ + return rte_tel_data_add_array_int_v24(d, x); +} +#endif int rte_tel_data_add_array_uint(struct rte_tel_data *d, uint64_t x) @@ -220,8 +228,16 @@ /* mark the v23 function as the older version, and v24 as the default version */ VERSION_SYMBOL(rte_tel_data_add_dict_int, _v23, 23); BIND_DEFAULT_SYMBOL(rte_tel_data_add_dict_int, _v24, 24); +#ifndef RTE_TOOLCHAIN_MSVC MAP_STATIC_SYMBOL(int rte_tel_data_add_dict_int(struct rte_tel_data *d, const char *name, int64_t val), rte_tel_data_add_dict_int_v24); +#else +int +rte_tel_data_add_dict_int(struct rte_tel_data *d, const char *name, int64_t val) +{ + return rte_tel_data_add_dict_int_v24(d, name, val); +} +#endif int rte_tel_data_add_dict_uint(struct rte_tel_data *d,