From patchwork Wed Feb 14 16:35:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 136754 X-Patchwork-Delegate: david.marchand@redhat.com 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 D928D43B38; Wed, 14 Feb 2024 17:36:13 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8BCA442D9D; Wed, 14 Feb 2024 17:36:09 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id AA01E41104 for ; Wed, 14 Feb 2024 17:36:06 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id D57D620B2001; Wed, 14 Feb 2024 08:36:05 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com D57D620B2001 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1707928565; bh=dJGbf9qcmY0fMNHfIgPo6Sdc7fqELNb8ANkDy5a6Ke8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cPboqyOMt/gEPlw+9RdnRnEJsdyJ85iraU8W4/s81siqzII9wMuIQSanQM7S3Ecoz C1dCxAeA8evt+V1NSN4hlwPIzFVokvobROqJM4n8x6qZ0abUNgdK+UQ0pL5Pofz4bT v9ivEybXtXOx9x1j9IV+JvHpyWi+nWZJoxdorvlY= From: Tyler Retzlaff To: dev@dpdk.org Cc: Andrew Rybchenko , Bruce Richardson , Chengwen Feng , Cristian Dumitrescu , David Christensen , David Hunt , Ferruh Yigit , Honnappa Nagarahalli , Jasvinder Singh , Jerin Jacob , Kevin Laatz , Konstantin Ananyev , Min Zhou , Ruifeng Wang , Sameh Gobriel , Stanislaw Kardach , Thomas Monjalon , Vladimir Medvedkin , Yipeng Wang , Tyler Retzlaff Subject: [PATCH v4 01/39] eal: use C11 alignas Date: Wed, 14 Feb 2024 08:35:26 -0800 Message-Id: <1707928564-28796-2-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1707928564-28796-1-git-send-email-roretzla@linux.microsoft.com> References: <1707873986-29352-1-git-send-email-roretzla@linux.microsoft.com> <1707928564-28796-1-git-send-email-roretzla@linux.microsoft.com> MIME-Version: 1.0 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 * Expand __rte_aligned(a) to __declspec(align(a)) when building with MSVC. * Move __rte_aligned from the end of {struct,union} definitions to be between {struct,union} and tag. The placement between {struct,union} and the tag allows the desired alignment to be imparted on the type regardless of the toolchain being used for all of GCC, LLVM, MSVC compilers building both C and C++. * Replace use of __rte_aligned(a) on variables/fields with alignas(a). Signed-off-by: Tyler Retzlaff Acked-by: Morten Brørup --- lib/eal/arm/include/rte_vect.h | 4 ++-- lib/eal/common/malloc_elem.h | 4 ++-- lib/eal/common/malloc_heap.h | 4 ++-- lib/eal/common/rte_keepalive.c | 3 ++- lib/eal/common/rte_random.c | 4 ++-- lib/eal/common/rte_service.c | 8 ++++---- lib/eal/include/generic/rte_atomic.h | 4 ++-- lib/eal/include/rte_common.h | 12 +++++------- lib/eal/loongarch/include/rte_vect.h | 8 ++++---- lib/eal/ppc/include/rte_vect.h | 4 ++-- lib/eal/riscv/include/rte_vect.h | 4 ++-- lib/eal/x86/include/rte_vect.h | 4 ++-- lib/eal/x86/rte_power_intrinsics.c | 10 ++++++---- 13 files changed, 37 insertions(+), 36 deletions(-) diff --git a/lib/eal/arm/include/rte_vect.h b/lib/eal/arm/include/rte_vect.h index 8cfe4bd..c97d299 100644 --- a/lib/eal/arm/include/rte_vect.h +++ b/lib/eal/arm/include/rte_vect.h @@ -24,14 +24,14 @@ #define XMM_SIZE (sizeof(xmm_t)) #define XMM_MASK (XMM_SIZE - 1) -typedef union rte_xmm { +typedef union __rte_aligned(16) rte_xmm { xmm_t x; uint8_t u8[XMM_SIZE / sizeof(uint8_t)]; uint16_t u16[XMM_SIZE / sizeof(uint16_t)]; uint32_t u32[XMM_SIZE / sizeof(uint32_t)]; uint64_t u64[XMM_SIZE / sizeof(uint64_t)]; double pd[XMM_SIZE / sizeof(double)]; -} __rte_aligned(16) rte_xmm_t; +} rte_xmm_t; #if defined(RTE_ARCH_ARM) && defined(RTE_ARCH_32) /* NEON intrinsic vqtbl1q_u8() is not supported in ARMv7-A(AArch32) */ diff --git a/lib/eal/common/malloc_elem.h b/lib/eal/common/malloc_elem.h index 952ce73..c7ff671 100644 --- a/lib/eal/common/malloc_elem.h +++ b/lib/eal/common/malloc_elem.h @@ -20,7 +20,7 @@ enum elem_state { ELEM_PAD /* element is a padding-only header */ }; -struct malloc_elem { +struct __rte_cache_aligned malloc_elem { struct malloc_heap *heap; struct malloc_elem *volatile prev; /**< points to prev elem in memseg */ @@ -48,7 +48,7 @@ struct malloc_elem { size_t user_size; uint64_t asan_cookie[2]; /* must be next to header_cookie */ #endif -} __rte_cache_aligned; +}; static const unsigned int MALLOC_ELEM_HEADER_LEN = sizeof(struct malloc_elem); diff --git a/lib/eal/common/malloc_heap.h b/lib/eal/common/malloc_heap.h index 8f3ab57..0c49588 100644 --- a/lib/eal/common/malloc_heap.h +++ b/lib/eal/common/malloc_heap.h @@ -21,7 +21,7 @@ /** * Structure to hold malloc heap */ -struct malloc_heap { +struct __rte_cache_aligned malloc_heap { rte_spinlock_t lock; LIST_HEAD(, malloc_elem) free_head[RTE_HEAP_NUM_FREELISTS]; struct malloc_elem *volatile first; @@ -31,7 +31,7 @@ struct malloc_heap { unsigned int socket_id; size_t total_size; char name[RTE_HEAP_NAME_MAX_LEN]; -} __rte_cache_aligned; +}; void * malloc_heap_alloc(const char *type, size_t size, int socket, unsigned int flags, diff --git a/lib/eal/common/rte_keepalive.c b/lib/eal/common/rte_keepalive.c index f6db973..391c1be 100644 --- a/lib/eal/common/rte_keepalive.c +++ b/lib/eal/common/rte_keepalive.c @@ -2,6 +2,7 @@ * Copyright(c) 2015-2016 Intel Corporation */ +#include #include #include @@ -19,7 +20,7 @@ struct rte_keepalive { /* * Each element must be cache aligned to prevent false sharing. */ - enum rte_keepalive_state core_state __rte_cache_aligned; + alignas(RTE_CACHE_LINE_SIZE) enum rte_keepalive_state core_state; } live_data[RTE_KEEPALIVE_MAXCORES]; /** Last-seen-alive timestamps */ diff --git a/lib/eal/common/rte_random.c b/lib/eal/common/rte_random.c index 7709b8f..90e91b3 100644 --- a/lib/eal/common/rte_random.c +++ b/lib/eal/common/rte_random.c @@ -13,14 +13,14 @@ #include #include -struct rte_rand_state { +struct __rte_cache_aligned rte_rand_state { uint64_t z1; uint64_t z2; uint64_t z3; uint64_t z4; uint64_t z5; RTE_CACHE_GUARD; -} __rte_cache_aligned; +}; /* One instance each for every lcore id-equipped thread, and one * additional instance to be shared by all others threads (i.e., all diff --git a/lib/eal/common/rte_service.c b/lib/eal/common/rte_service.c index d959c91..5637993 100644 --- a/lib/eal/common/rte_service.c +++ b/lib/eal/common/rte_service.c @@ -32,7 +32,7 @@ #define RUNSTATE_RUNNING 1 /* internal representation of a service */ -struct rte_service_spec_impl { +struct __rte_cache_aligned rte_service_spec_impl { /* public part of the struct */ struct rte_service_spec spec; @@ -53,7 +53,7 @@ struct rte_service_spec_impl { * on currently. */ RTE_ATOMIC(uint32_t) num_mapped_cores; -} __rte_cache_aligned; +}; struct service_stats { RTE_ATOMIC(uint64_t) calls; @@ -61,7 +61,7 @@ struct service_stats { }; /* the internal values of a service core */ -struct core_state { +struct __rte_cache_aligned core_state { /* map of services IDs are run on this core */ uint64_t service_mask; RTE_ATOMIC(uint8_t) runstate; /* running or stopped */ @@ -71,7 +71,7 @@ struct core_state { RTE_ATOMIC(uint64_t) loops; RTE_ATOMIC(uint64_t) cycles; struct service_stats service_stats[RTE_SERVICE_NUM_MAX]; -} __rte_cache_aligned; +}; static uint32_t rte_service_count; static struct rte_service_spec_impl *rte_services; diff --git a/lib/eal/include/generic/rte_atomic.h b/lib/eal/include/generic/rte_atomic.h index 0e639da..f859707 100644 --- a/lib/eal/include/generic/rte_atomic.h +++ b/lib/eal/include/generic/rte_atomic.h @@ -1094,7 +1094,7 @@ static inline void rte_atomic64_clear(rte_atomic64_t *v) /** * 128-bit integer structure. */ -typedef struct { +typedef struct __rte_aligned(16) { union { uint64_t val[2]; #ifdef RTE_ARCH_64 @@ -1103,7 +1103,7 @@ static inline void rte_atomic64_clear(rte_atomic64_t *v) #endif #endif }; -} __rte_aligned(16) rte_int128_t; +} rte_int128_t; #ifdef __DOXYGEN__ diff --git a/lib/eal/include/rte_common.h b/lib/eal/include/rte_common.h index d7d6390..ac90951 100644 --- a/lib/eal/include/rte_common.h +++ b/lib/eal/include/rte_common.h @@ -12,6 +12,8 @@ * for DPDK. */ +#include + #ifdef __cplusplus extern "C" { #endif @@ -65,7 +67,7 @@ * Force alignment */ #ifdef RTE_TOOLCHAIN_MSVC -#define __rte_aligned(a) +#define __rte_aligned(a) __declspec(align(a)) #else #define __rte_aligned(a) __attribute__((__aligned__(a))) #endif @@ -529,18 +531,14 @@ static void __attribute__((destructor(RTE_PRIO(prio)), used)) func(void) #define RTE_CACHE_LINE_MIN_SIZE 64 /** Force alignment to cache line. */ -#ifdef RTE_TOOLCHAIN_MSVC -#define __rte_cache_aligned -#else #define __rte_cache_aligned __rte_aligned(RTE_CACHE_LINE_SIZE) -#endif /** Force minimum cache line alignment. */ #define __rte_cache_min_aligned __rte_aligned(RTE_CACHE_LINE_MIN_SIZE) #define _RTE_CACHE_GUARD_HELPER2(unique) \ - char cache_guard_ ## unique[RTE_CACHE_LINE_SIZE * RTE_CACHE_GUARD_LINES] \ - __rte_cache_aligned + alignas(RTE_CACHE_LINE_SIZE) \ + char cache_guard_ ## unique[RTE_CACHE_LINE_SIZE * RTE_CACHE_GUARD_LINES] #define _RTE_CACHE_GUARD_HELPER1(unique) _RTE_CACHE_GUARD_HELPER2(unique) /** * Empty cache lines, to guard against false sharing-like effects diff --git a/lib/eal/loongarch/include/rte_vect.h b/lib/eal/loongarch/include/rte_vect.h index 1546515..aa334e8 100644 --- a/lib/eal/loongarch/include/rte_vect.h +++ b/lib/eal/loongarch/include/rte_vect.h @@ -15,7 +15,7 @@ #define RTE_VECT_DEFAULT_SIMD_BITWIDTH RTE_VECT_SIMD_DISABLED -typedef union xmm { +typedef union __rte_aligned(16) xmm { int8_t i8[16]; int16_t i16[8]; int32_t i32[4]; @@ -25,19 +25,19 @@ uint32_t u32[4]; uint64_t u64[2]; double pd[2]; -} __rte_aligned(16) xmm_t; +} xmm_t; #define XMM_SIZE (sizeof(xmm_t)) #define XMM_MASK (XMM_SIZE - 1) -typedef union rte_xmm { +typedef union __rte_aligned(16) rte_xmm { xmm_t x; uint8_t u8[XMM_SIZE / sizeof(uint8_t)]; uint16_t u16[XMM_SIZE / sizeof(uint16_t)]; uint32_t u32[XMM_SIZE / sizeof(uint32_t)]; uint64_t u64[XMM_SIZE / sizeof(uint64_t)]; double pd[XMM_SIZE / sizeof(double)]; -} __rte_aligned(16) rte_xmm_t; +} rte_xmm_t; static inline xmm_t vect_load_128(void *p) diff --git a/lib/eal/ppc/include/rte_vect.h b/lib/eal/ppc/include/rte_vect.h index a5f009b..c8bace2 100644 --- a/lib/eal/ppc/include/rte_vect.h +++ b/lib/eal/ppc/include/rte_vect.h @@ -22,14 +22,14 @@ #define XMM_SIZE (sizeof(xmm_t)) #define XMM_MASK (XMM_SIZE - 1) -typedef union rte_xmm { +typedef union __rte_aligned(16) rte_xmm { xmm_t x; uint8_t u8[XMM_SIZE / sizeof(uint8_t)]; uint16_t u16[XMM_SIZE / sizeof(uint16_t)]; uint32_t u32[XMM_SIZE / sizeof(uint32_t)]; uint64_t u64[XMM_SIZE / sizeof(uint64_t)]; double pd[XMM_SIZE / sizeof(double)]; -} __rte_aligned(16) rte_xmm_t; +} rte_xmm_t; #ifdef __cplusplus } diff --git a/lib/eal/riscv/include/rte_vect.h b/lib/eal/riscv/include/rte_vect.h index da9092a..6df10fa 100644 --- a/lib/eal/riscv/include/rte_vect.h +++ b/lib/eal/riscv/include/rte_vect.h @@ -22,14 +22,14 @@ #define XMM_SIZE (sizeof(xmm_t)) #define XMM_MASK (XMM_SIZE - 1) -typedef union rte_xmm { +typedef union __rte_aligned(16) rte_xmm { xmm_t x; uint8_t u8[XMM_SIZE / sizeof(uint8_t)]; uint16_t u16[XMM_SIZE / sizeof(uint16_t)]; uint32_t u32[XMM_SIZE / sizeof(uint32_t)]; uint64_t u64[XMM_SIZE / sizeof(uint64_t)]; double pd[XMM_SIZE / sizeof(double)]; -} __rte_aligned(16) rte_xmm_t; +} rte_xmm_t; static inline xmm_t vect_load_128(void *p) diff --git a/lib/eal/x86/include/rte_vect.h b/lib/eal/x86/include/rte_vect.h index 560f9e4..a1a537e 100644 --- a/lib/eal/x86/include/rte_vect.h +++ b/lib/eal/x86/include/rte_vect.h @@ -91,7 +91,7 @@ #define RTE_X86_ZMM_SIZE (sizeof(__m512i)) #define RTE_X86_ZMM_MASK (RTE_X86_ZMM_SIZE - 1) -typedef union __rte_x86_zmm { +typedef union __rte_aligned(RTE_X86_ZMM_SIZE) __rte_x86_zmm { __m512i z; ymm_t y[RTE_X86_ZMM_SIZE / sizeof(ymm_t)]; xmm_t x[RTE_X86_ZMM_SIZE / sizeof(xmm_t)]; @@ -100,7 +100,7 @@ uint32_t u32[RTE_X86_ZMM_SIZE / sizeof(uint32_t)]; uint64_t u64[RTE_X86_ZMM_SIZE / sizeof(uint64_t)]; double pd[RTE_X86_ZMM_SIZE / sizeof(double)]; -} __rte_aligned(RTE_X86_ZMM_SIZE) __rte_x86_zmm_t; +} __rte_x86_zmm_t; #endif /* __AVX512F__ */ diff --git a/lib/eal/x86/rte_power_intrinsics.c b/lib/eal/x86/rte_power_intrinsics.c index 532a2e6..6d9b642 100644 --- a/lib/eal/x86/rte_power_intrinsics.c +++ b/lib/eal/x86/rte_power_intrinsics.c @@ -2,6 +2,8 @@ * Copyright(c) 2020 Intel Corporation */ +#include + #include #include #include @@ -12,10 +14,10 @@ /* * Per-lcore structure holding current status of C0.2 sleeps. */ -static struct power_wait_status { +static alignas(RTE_CACHE_LINE_SIZE) struct power_wait_status { rte_spinlock_t lock; volatile void *monitor_addr; /**< NULL if not currently sleeping */ -} __rte_cache_aligned wait_status[RTE_MAX_LCORE]; +} wait_status[RTE_MAX_LCORE]; /* * This function uses UMONITOR/UMWAIT instructions and will enter C0.2 state. @@ -85,10 +87,10 @@ static void amd_mwaitx(const uint64_t timeout) #endif } -static struct { +static alignas(RTE_CACHE_LINE_SIZE) struct { void (*mmonitor)(volatile void *addr); void (*mwait)(const uint64_t timeout); -} __rte_cache_aligned power_monitor_ops; +} power_monitor_ops; static inline void __umwait_wakeup(volatile void *addr) From patchwork Wed Feb 14 16:35:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 136755 X-Patchwork-Delegate: david.marchand@redhat.com 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 5FE4143B38; Wed, 14 Feb 2024 17:36:20 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2AB6142E1F; Wed, 14 Feb 2024 17:36:11 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id DCA41427DF for ; Wed, 14 Feb 2024 17:36:06 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id E3C7F20B2002; Wed, 14 Feb 2024 08:36:05 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com E3C7F20B2002 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1707928565; bh=yppqelNC91FrKm6G+rdPOwVN8GbGAyVifIiD4wgww4E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KxEY2GPTtDaKXZfR70gPfjt3OrBoNF86xjaR753OnRTtxBAHf2kMiub6oplXaB9qQ /srwExdnlryHvRhowPiM/uTPUEUQQeCvV5T4HkUaXnSavA6EX7PDjCfF42j826s1wc 3eb38OpbJqvM0t58vqXUjxUTsQaS1JNuxwgDHxSY= From: Tyler Retzlaff To: dev@dpdk.org Cc: Andrew Rybchenko , Bruce Richardson , Chengwen Feng , Cristian Dumitrescu , David Christensen , David Hunt , Ferruh Yigit , Honnappa Nagarahalli , Jasvinder Singh , Jerin Jacob , Kevin Laatz , Konstantin Ananyev , Min Zhou , Ruifeng Wang , Sameh Gobriel , Stanislaw Kardach , Thomas Monjalon , Vladimir Medvedkin , Yipeng Wang , Tyler Retzlaff Subject: [PATCH v4 02/39] eal: redefine macro to be integer literal for MSVC Date: Wed, 14 Feb 2024 08:35:27 -0800 Message-Id: <1707928564-28796-3-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1707928564-28796-1-git-send-email-roretzla@linux.microsoft.com> References: <1707873986-29352-1-git-send-email-roretzla@linux.microsoft.com> <1707928564-28796-1-git-send-email-roretzla@linux.microsoft.com> MIME-Version: 1.0 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 MSVC __declspec(align(#)) is limited and accepts only integer literals as opposed to constant expressions. define XMM_SIZE to be 16 instead of sizeof(xmm_t) and static_assert that sizeof(xmm_t) == 16 for compatibility. Signed-off-by: Tyler Retzlaff Acked-by: Morten Brørup --- lib/eal/x86/include/rte_vect.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/eal/x86/include/rte_vect.h b/lib/eal/x86/include/rte_vect.h index a1a537e..441f1a0 100644 --- a/lib/eal/x86/include/rte_vect.h +++ b/lib/eal/x86/include/rte_vect.h @@ -11,6 +11,7 @@ * RTE SSE/AVX related header. */ +#include #include #include #include @@ -33,9 +34,11 @@ typedef __m128i xmm_t; -#define XMM_SIZE (sizeof(xmm_t)) +#define XMM_SIZE 16 #define XMM_MASK (XMM_SIZE - 1) +static_assert(sizeof(xmm_t) == 16, ""); + typedef union rte_xmm { xmm_t x; uint8_t u8[XMM_SIZE / sizeof(uint8_t)]; From patchwork Wed Feb 14 16:35:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 136756 X-Patchwork-Delegate: david.marchand@redhat.com 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 9635343B38; Wed, 14 Feb 2024 17:36:26 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id ADF7642E54; Wed, 14 Feb 2024 17:36:12 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id C8F8D427D7 for ; Wed, 14 Feb 2024 17:36:06 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id F3DE220B2003; Wed, 14 Feb 2024 08:36:05 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com F3DE220B2003 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1707928566; bh=LhiAcFL8IpVzmmAPJgAv0jg/+iGj/fmqJp/gNSqIbVI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ipPssHTCv0b9AV3VCDNmQLHye0LSckLmQtZ/DBOSDXPVqUXU/Gg7ll9VXMhmkE1hI HZHNDf5y7eu3+nQN/y8NJXlB5puYtxnGRZwvZpC+X2NjDYIadchyycHcZS1vc2AeBm 149zAd9ardv8n/BRFOcVmYpDpJuubfHjp6a957Vo= From: Tyler Retzlaff To: dev@dpdk.org Cc: Andrew Rybchenko , Bruce Richardson , Chengwen Feng , Cristian Dumitrescu , David Christensen , David Hunt , Ferruh Yigit , Honnappa Nagarahalli , Jasvinder Singh , Jerin Jacob , Kevin Laatz , Konstantin Ananyev , Min Zhou , Ruifeng Wang , Sameh Gobriel , Stanislaw Kardach , Thomas Monjalon , Vladimir Medvedkin , Yipeng Wang , Tyler Retzlaff Subject: [PATCH v4 03/39] stack: use C11 alignas Date: Wed, 14 Feb 2024 08:35:28 -0800 Message-Id: <1707928564-28796-4-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1707928564-28796-1-git-send-email-roretzla@linux.microsoft.com> References: <1707873986-29352-1-git-send-email-roretzla@linux.microsoft.com> <1707928564-28796-1-git-send-email-roretzla@linux.microsoft.com> MIME-Version: 1.0 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 * Move __rte_aligned from the end of {struct,union} definitions to be between {struct,union} and tag. The placement between {struct,union} and the tag allows the desired alignment to be imparted on the type regardless of the toolchain being used for all of GCC, LLVM, MSVC compilers building both C and C++. * Replace use of __rte_aligned(a) on variables/fields with alignas(a). Signed-off-by: Tyler Retzlaff Acked-by: Morten Brørup --- lib/stack/rte_stack.h | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/stack/rte_stack.h b/lib/stack/rte_stack.h index a379300..8ff0659 100644 --- a/lib/stack/rte_stack.h +++ b/lib/stack/rte_stack.h @@ -15,6 +15,8 @@ #ifndef _RTE_STACK_H_ #define _RTE_STACK_H_ +#include + #ifdef __cplusplus extern "C" { #endif @@ -42,7 +44,7 @@ struct rte_stack_lf_head { struct rte_stack_lf_list { /** List head */ - struct rte_stack_lf_head head __rte_aligned(16); + alignas(16) struct rte_stack_lf_head head; /** List len */ RTE_ATOMIC(uint64_t) len; }; @@ -52,11 +54,11 @@ struct rte_stack_lf_list { */ struct rte_stack_lf { /** LIFO list of elements */ - struct rte_stack_lf_list used __rte_cache_aligned; + alignas(RTE_CACHE_LINE_SIZE) struct rte_stack_lf_list used; /** LIFO list of free elements */ - struct rte_stack_lf_list free __rte_cache_aligned; + alignas(RTE_CACHE_LINE_SIZE) struct rte_stack_lf_list free; /** LIFO elements */ - struct rte_stack_lf_elem elems[] __rte_cache_aligned; + alignas(RTE_CACHE_LINE_SIZE) struct rte_stack_lf_elem elems[]; }; /* Structure containing the LIFO, its current length, and a lock for mutual @@ -71,9 +73,9 @@ struct rte_stack_std { /* The RTE stack structure contains the LIFO structure itself, plus metadata * such as its name and memzone pointer. */ -struct rte_stack { +struct __rte_cache_aligned rte_stack { /** Name of the stack. */ - char name[RTE_STACK_NAMESIZE] __rte_cache_aligned; + alignas(RTE_CACHE_LINE_SIZE) char name[RTE_STACK_NAMESIZE]; /** Memzone containing the rte_stack structure. */ const struct rte_memzone *memzone; uint32_t capacity; /**< Usable size of the stack. */ @@ -82,7 +84,7 @@ struct rte_stack { struct rte_stack_lf stack_lf; /**< Lock-free LIFO structure. */ struct rte_stack_std stack_std; /**< LIFO structure. */ }; -} __rte_cache_aligned; +}; /** * The stack uses lock-free push and pop functions. This flag is only From patchwork Wed Feb 14 16:35:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 136757 X-Patchwork-Delegate: david.marchand@redhat.com 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 32CC443B38; Wed, 14 Feb 2024 17:36:33 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D2BCD42E68; Wed, 14 Feb 2024 17:36:13 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id D7EDD427DB for ; Wed, 14 Feb 2024 17:36:06 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 0E97320B2004; Wed, 14 Feb 2024 08:36:05 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 0E97320B2004 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1707928566; bh=9uM3O7ghLeRbrirSzn7XBQw2gO4GyigUy9Pa6EwlHqQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=H0yAtvi4e7DDegdEhwJo5gukxiaKTGjczIlSDoqPap4tsL5Ah2ujasQ40pxwzevnx ieiKJhbAQNUWBcRCOXLLK/b7aVpTwWRiLzFoeuqK8id641Ww3+/eNctkXBKW17pBn3 2rhBbkDCmWOV9J5YD/iPxM3yHICfAZI5f5w/iUkM= From: Tyler Retzlaff To: dev@dpdk.org Cc: Andrew Rybchenko , Bruce Richardson , Chengwen Feng , Cristian Dumitrescu , David Christensen , David Hunt , Ferruh Yigit , Honnappa Nagarahalli , Jasvinder Singh , Jerin Jacob , Kevin Laatz , Konstantin Ananyev , Min Zhou , Ruifeng Wang , Sameh Gobriel , Stanislaw Kardach , Thomas Monjalon , Vladimir Medvedkin , Yipeng Wang , Tyler Retzlaff Subject: [PATCH v4 04/39] sched: use C11 alignas Date: Wed, 14 Feb 2024 08:35:29 -0800 Message-Id: <1707928564-28796-5-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1707928564-28796-1-git-send-email-roretzla@linux.microsoft.com> References: <1707873986-29352-1-git-send-email-roretzla@linux.microsoft.com> <1707928564-28796-1-git-send-email-roretzla@linux.microsoft.com> MIME-Version: 1.0 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 Replace use of __rte_aligned_16 with C11 alignas(16) and garbage collect the __rte_aligned_16 macro which was only used once. Signed-off-by: Tyler Retzlaff Acked-by: Morten Brørup --- lib/sched/rte_sched.c | 21 +++++++++++---------- lib/sched/rte_sched_common.h | 2 -- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/lib/sched/rte_sched.c b/lib/sched/rte_sched.c index d90aa53..bbdb5d1 100644 --- a/lib/sched/rte_sched.c +++ b/lib/sched/rte_sched.c @@ -2,6 +2,7 @@ * Copyright(c) 2010-2014 Intel Corporation */ +#include #include #include @@ -57,7 +58,7 @@ struct rte_sched_pipe_profile { uint8_t wrr_cost[RTE_SCHED_BE_QUEUES_PER_PIPE]; }; -struct rte_sched_pipe { +struct __rte_cache_aligned rte_sched_pipe { /* Token bucket (TB) */ uint64_t tb_time; /* time of last update */ uint64_t tb_credits; @@ -75,7 +76,7 @@ struct rte_sched_pipe { /* TC oversubscription */ uint64_t tc_ov_credits; uint8_t tc_ov_period_id; -} __rte_cache_aligned; +}; struct rte_sched_queue { uint16_t qw; @@ -145,7 +146,7 @@ struct rte_sched_grinder { uint8_t wrr_cost[RTE_SCHED_BE_QUEUES_PER_PIPE]; }; -struct rte_sched_subport { +struct __rte_cache_aligned rte_sched_subport { /* Token bucket (TB) */ uint64_t tb_time; /* time of last update */ uint64_t tb_credits; @@ -164,7 +165,7 @@ struct rte_sched_subport { double tc_ov_rate; /* Statistics */ - struct rte_sched_subport_stats stats __rte_cache_aligned; + alignas(RTE_CACHE_LINE_SIZE) struct rte_sched_subport_stats stats; /* subport profile */ uint32_t profile; @@ -193,7 +194,7 @@ struct rte_sched_subport { /* Bitmap */ struct rte_bitmap *bmp; - uint32_t grinder_base_bmp_pos[RTE_SCHED_PORT_N_GRINDERS] __rte_aligned_16; + alignas(16) uint32_t grinder_base_bmp_pos[RTE_SCHED_PORT_N_GRINDERS]; /* Grinders */ struct rte_sched_grinder grinder[RTE_SCHED_PORT_N_GRINDERS]; @@ -212,10 +213,10 @@ struct rte_sched_subport { struct rte_sched_pipe_profile *pipe_profiles; uint8_t *bmp_array; struct rte_mbuf **queue_array; - uint8_t memory[0] __rte_cache_aligned; -} __rte_cache_aligned; + alignas(RTE_CACHE_LINE_SIZE) uint8_t memory[0]; +}; -struct rte_sched_port { +struct __rte_cache_aligned rte_sched_port { /* User parameters */ uint32_t n_subports_per_port; uint32_t n_pipes_per_subport; @@ -244,8 +245,8 @@ struct rte_sched_port { /* Large data structures */ struct rte_sched_subport_profile *subport_profiles; - struct rte_sched_subport *subports[0] __rte_cache_aligned; -} __rte_cache_aligned; + alignas(RTE_CACHE_LINE_SIZE) struct rte_sched_subport *subports[0]; +}; enum rte_sched_subport_array { e_RTE_SCHED_SUBPORT_ARRAY_PIPE = 0, diff --git a/lib/sched/rte_sched_common.h b/lib/sched/rte_sched_common.h index 419700b..573d164 100644 --- a/lib/sched/rte_sched_common.h +++ b/lib/sched/rte_sched_common.h @@ -12,8 +12,6 @@ #include #include -#define __rte_aligned_16 __rte_aligned(16) - #if 0 static inline uint32_t rte_min_pos_4_u16(uint16_t *x) From patchwork Wed Feb 14 16:35:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 136760 X-Patchwork-Delegate: david.marchand@redhat.com 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 E764443B38; Wed, 14 Feb 2024 17:36:55 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B133042E50; Wed, 14 Feb 2024 17:36:17 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 8EB274026A for ; Wed, 14 Feb 2024 17:36:07 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 1E22920B2005; Wed, 14 Feb 2024 08:36:05 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 1E22920B2005 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1707928566; bh=qYemn5fm0RadB0Z5+Q1YuGIm/M15oe9bFyQW02No2Zg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PxxxRbphmDToR2u1txuXUX/8kQW6+yFJsBZ5mLiwKG5xpJwXr1BrFP6Wq7j+rVleF fU9PBUDZVi9tYqGcTsAIDRbaXenZYNAuHOd8uq/0NQjpvcPx9HUlyQA/kXpUk5kpZJ pm0xBZlYD9ytJh3g9RKc8Ad9RdnRbZ7Er3NeVjYY= From: Tyler Retzlaff To: dev@dpdk.org Cc: Andrew Rybchenko , Bruce Richardson , Chengwen Feng , Cristian Dumitrescu , David Christensen , David Hunt , Ferruh Yigit , Honnappa Nagarahalli , Jasvinder Singh , Jerin Jacob , Kevin Laatz , Konstantin Ananyev , Min Zhou , Ruifeng Wang , Sameh Gobriel , Stanislaw Kardach , Thomas Monjalon , Vladimir Medvedkin , Yipeng Wang , Tyler Retzlaff Subject: [PATCH v4 05/39] ring: use C11 alignas Date: Wed, 14 Feb 2024 08:35:30 -0800 Message-Id: <1707928564-28796-6-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1707928564-28796-1-git-send-email-roretzla@linux.microsoft.com> References: <1707873986-29352-1-git-send-email-roretzla@linux.microsoft.com> <1707928564-28796-1-git-send-email-roretzla@linux.microsoft.com> MIME-Version: 1.0 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 * Move __rte_aligned from the end of {struct,union} definitions to be between {struct,union} and tag. The placement between {struct,union} and the tag allows the desired alignment to be imparted on the type regardless of the toolchain being used for all of GCC, LLVM, MSVC compilers building both C and C++. * Replace use of __rte_aligned(a) on variables/fields with alignas(a). Signed-off-by: Tyler Retzlaff Acked-by: Morten Brørup --- lib/ring/rte_ring_core.h | 16 +++++++++------- lib/ring/rte_ring_peek_zc.h | 4 ++-- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/lib/ring/rte_ring_core.h b/lib/ring/rte_ring_core.h index b770873..497d535 100644 --- a/lib/ring/rte_ring_core.h +++ b/lib/ring/rte_ring_core.h @@ -19,6 +19,8 @@ * instead. */ +#include + #ifdef __cplusplus extern "C" { #endif @@ -78,7 +80,7 @@ struct rte_ring_headtail { union __rte_ring_rts_poscnt { /** raw 8B value to read/write *cnt* and *pos* as one atomic op */ - RTE_ATOMIC(uint64_t) raw __rte_aligned(8); + alignas(8) RTE_ATOMIC(uint64_t) raw; struct { uint32_t cnt; /**< head/tail reference counter */ uint32_t pos; /**< head/tail position */ @@ -94,7 +96,7 @@ struct rte_ring_rts_headtail { union __rte_ring_hts_pos { /** raw 8B value to read/write *head* and *tail* as one atomic op */ - RTE_ATOMIC(uint64_t) raw __rte_aligned(8); + alignas(8) RTE_ATOMIC(uint64_t) raw; struct { RTE_ATOMIC(uint32_t) head; /**< head position */ RTE_ATOMIC(uint32_t) tail; /**< tail position */ @@ -117,7 +119,7 @@ struct rte_ring_hts_headtail { * a problem. */ struct rte_ring { - char name[RTE_RING_NAMESIZE] __rte_cache_aligned; + alignas(RTE_CACHE_LINE_SIZE) char name[RTE_RING_NAMESIZE]; /**< Name of the ring. */ int flags; /**< Flags supplied at creation. */ const struct rte_memzone *memzone; @@ -129,20 +131,20 @@ struct rte_ring { RTE_CACHE_GUARD; /** Ring producer status. */ - union { + union __rte_cache_aligned { struct rte_ring_headtail prod; struct rte_ring_hts_headtail hts_prod; struct rte_ring_rts_headtail rts_prod; - } __rte_cache_aligned; + }; RTE_CACHE_GUARD; /** Ring consumer status. */ - union { + union __rte_cache_aligned { struct rte_ring_headtail cons; struct rte_ring_hts_headtail hts_cons; struct rte_ring_rts_headtail rts_cons; - } __rte_cache_aligned; + }; RTE_CACHE_GUARD; }; diff --git a/lib/ring/rte_ring_peek_zc.h b/lib/ring/rte_ring_peek_zc.h index 8fb279c..0b5e34b 100644 --- a/lib/ring/rte_ring_peek_zc.h +++ b/lib/ring/rte_ring_peek_zc.h @@ -79,7 +79,7 @@ * This structure contains the pointers and length of the space * reserved on the ring storage. */ -struct rte_ring_zc_data { +struct __rte_cache_aligned rte_ring_zc_data { /* Pointer to the first space in the ring */ void *ptr1; /* Pointer to the second space in the ring if there is wrap-around. @@ -92,7 +92,7 @@ struct rte_ring_zc_data { * will give the number of elements available at ptr2. */ unsigned int n1; -} __rte_cache_aligned; +}; static __rte_always_inline void __rte_ring_get_elem_addr(struct rte_ring *r, uint32_t head, From patchwork Wed Feb 14 16:35:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 136759 X-Patchwork-Delegate: david.marchand@redhat.com 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 8753E43B38; Wed, 14 Feb 2024 17:36:49 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 73CFF42E9B; Wed, 14 Feb 2024 17:36:16 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 905E141104 for ; Wed, 14 Feb 2024 17:36:07 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 2CCD320B2006; Wed, 14 Feb 2024 08:36:05 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 2CCD320B2006 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1707928566; bh=pZgLn5hUUy/9VjN0c67S8EV2SYTMU3qWdsUU2qV1GLU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RG/4Nh7LsGKCdrZaNehf/C4aanzmKDVGPxyflzkvumQAKJgIsqQthgfPXgbdF7hHO vSECZhfDsYlZFpxzMxPU3tjl3r2WC8Ti5514WNfLJgYufAhMdo9LHrgEZMo9ASIsgr ZckDGEVasS/v/YgZgwRBzfSb+XXr/RWS3hzsjqmY= From: Tyler Retzlaff To: dev@dpdk.org Cc: Andrew Rybchenko , Bruce Richardson , Chengwen Feng , Cristian Dumitrescu , David Christensen , David Hunt , Ferruh Yigit , Honnappa Nagarahalli , Jasvinder Singh , Jerin Jacob , Kevin Laatz , Konstantin Ananyev , Min Zhou , Ruifeng Wang , Sameh Gobriel , Stanislaw Kardach , Thomas Monjalon , Vladimir Medvedkin , Yipeng Wang , Tyler Retzlaff Subject: [PATCH v4 06/39] pipeline: use C11 alignas Date: Wed, 14 Feb 2024 08:35:31 -0800 Message-Id: <1707928564-28796-7-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1707928564-28796-1-git-send-email-roretzla@linux.microsoft.com> References: <1707873986-29352-1-git-send-email-roretzla@linux.microsoft.com> <1707928564-28796-1-git-send-email-roretzla@linux.microsoft.com> MIME-Version: 1.0 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 * Move __rte_aligned from the end of {struct,union} definitions to be between {struct,union} and tag. The placement between {struct,union} and the tag allows the desired alignment to be imparted on the type regardless of the toolchain being used for all of GCC, LLVM, MSVC compilers building both C and C++. * Replace use of __rte_aligned(a) on variables/fields with alignas(a). Signed-off-by: Tyler Retzlaff Acked-by: Morten Brørup --- lib/pipeline/rte_pipeline.c | 4 ++-- lib/pipeline/rte_port_in_action.c | 3 ++- lib/pipeline/rte_swx_ipsec.c | 4 +++- lib/pipeline/rte_table_action.c | 24 ++++++++++++------------ 4 files changed, 19 insertions(+), 16 deletions(-) diff --git a/lib/pipeline/rte_pipeline.c b/lib/pipeline/rte_pipeline.c index c9ed903..62a3005 100644 --- a/lib/pipeline/rte_pipeline.c +++ b/lib/pipeline/rte_pipeline.c @@ -104,7 +104,7 @@ struct rte_table { #define RTE_PIPELINE_MAX_NAME_SZ 124 -struct rte_pipeline { +struct __rte_cache_aligned rte_pipeline { /* Input parameters */ char name[RTE_PIPELINE_MAX_NAME_SZ]; int socket_id; @@ -132,7 +132,7 @@ struct rte_pipeline { uint64_t pkts_mask; uint64_t n_pkts_ah_drop; uint64_t pkts_drop_mask; -} __rte_cache_aligned; +}; static inline uint32_t rte_mask_get_next(uint64_t mask, uint32_t pos) diff --git a/lib/pipeline/rte_port_in_action.c b/lib/pipeline/rte_port_in_action.c index 5818973..bbacaff 100644 --- a/lib/pipeline/rte_port_in_action.c +++ b/lib/pipeline/rte_port_in_action.c @@ -2,6 +2,7 @@ * Copyright(c) 2010-2018 Intel Corporation */ +#include #include #include @@ -282,7 +283,7 @@ struct rte_port_in_action_profile * struct rte_port_in_action { struct ap_config cfg; struct ap_data data; - uint8_t memory[0] __rte_cache_aligned; + alignas(RTE_CACHE_LINE_SIZE) uint8_t memory[0]; }; static __rte_always_inline void * diff --git a/lib/pipeline/rte_swx_ipsec.c b/lib/pipeline/rte_swx_ipsec.c index 28576c2..76b853f 100644 --- a/lib/pipeline/rte_swx_ipsec.c +++ b/lib/pipeline/rte_swx_ipsec.c @@ -1,6 +1,8 @@ /* SPDX-License-Identifier: BSD-3-Clause * Copyright(c) 2022 Intel Corporation */ + +#include #include #include #include @@ -154,7 +156,7 @@ struct rte_swx_ipsec { /* * Table memory. */ - uint8_t memory[] __rte_cache_aligned; + alignas(RTE_CACHE_LINE_SIZE) uint8_t memory[]; }; static inline struct ipsec_sa * diff --git a/lib/pipeline/rte_table_action.c b/lib/pipeline/rte_table_action.c index dfdbc66..87c3e0e 100644 --- a/lib/pipeline/rte_table_action.c +++ b/lib/pipeline/rte_table_action.c @@ -465,11 +465,11 @@ struct encap_qinq_data { ((((uint64_t)(s)) & 0x1LLU) << 8) | \ (((uint64_t)(ttl)) & 0xFFLLU))) -struct encap_mpls_data { +struct __rte_aligned(2) encap_mpls_data { struct rte_ether_hdr ether; uint32_t mpls[RTE_TABLE_ACTION_MPLS_LABELS_MAX]; uint32_t mpls_count; -} __rte_packed __rte_aligned(2); +} __rte_packed; #define PPP_PROTOCOL_IP 0x0021 @@ -487,42 +487,42 @@ struct encap_pppoe_data { #define IP_PROTO_UDP 17 -struct encap_vxlan_ipv4_data { +struct __rte_aligned(2) encap_vxlan_ipv4_data { struct rte_ether_hdr ether; struct rte_ipv4_hdr ipv4; struct rte_udp_hdr udp; struct rte_vxlan_hdr vxlan; -} __rte_packed __rte_aligned(2); +} __rte_packed; -struct encap_vxlan_ipv4_vlan_data { +struct __rte_aligned(2) encap_vxlan_ipv4_vlan_data { struct rte_ether_hdr ether; struct rte_vlan_hdr vlan; struct rte_ipv4_hdr ipv4; struct rte_udp_hdr udp; struct rte_vxlan_hdr vxlan; -} __rte_packed __rte_aligned(2); +} __rte_packed; -struct encap_vxlan_ipv6_data { +struct __rte_aligned(2) encap_vxlan_ipv6_data { struct rte_ether_hdr ether; struct rte_ipv6_hdr ipv6; struct rte_udp_hdr udp; struct rte_vxlan_hdr vxlan; -} __rte_packed __rte_aligned(2); +} __rte_packed; -struct encap_vxlan_ipv6_vlan_data { +struct __rte_aligned(2) encap_vxlan_ipv6_vlan_data { struct rte_ether_hdr ether; struct rte_vlan_hdr vlan; struct rte_ipv6_hdr ipv6; struct rte_udp_hdr udp; struct rte_vxlan_hdr vxlan; -} __rte_packed __rte_aligned(2); +} __rte_packed; -struct encap_qinq_pppoe_data { +struct __rte_aligned(2) encap_qinq_pppoe_data { struct rte_ether_hdr ether; struct rte_vlan_hdr svlan; struct rte_vlan_hdr cvlan; struct pppoe_ppp_hdr pppoe_ppp; -} __rte_packed __rte_aligned(2); +} __rte_packed; static size_t encap_data_size(struct rte_table_action_encap_config *encap) From patchwork Wed Feb 14 16:35:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 136761 X-Patchwork-Delegate: david.marchand@redhat.com 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 A93C743B38; Wed, 14 Feb 2024 17:37:02 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D3FB742EC2; Wed, 14 Feb 2024 17:36:18 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 9344E427D7 for ; Wed, 14 Feb 2024 17:36:07 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 3B2DF20B2007; Wed, 14 Feb 2024 08:36:05 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 3B2DF20B2007 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1707928566; bh=UVC5g4s3GCJpjAt0YmC8pAjCzoqDbqnObzgfXUwXmXk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EA2X/CGKKr1cvYp3QwykrN2tYQwefyAwsmx+sn3Gkd4tnuIioUOyxTZcOv1+JZ70h Ahwjh8sXFZKNU2zvTDtk1gZAYQqVu7y/AQbsPnrxkpDESSQJCH/YhvfJOQ9ZBb0Eax JiAYsE6LUAOG/qtpSo6l/icbOCujle/xSniW9s3I= From: Tyler Retzlaff To: dev@dpdk.org Cc: Andrew Rybchenko , Bruce Richardson , Chengwen Feng , Cristian Dumitrescu , David Christensen , David Hunt , Ferruh Yigit , Honnappa Nagarahalli , Jasvinder Singh , Jerin Jacob , Kevin Laatz , Konstantin Ananyev , Min Zhou , Ruifeng Wang , Sameh Gobriel , Stanislaw Kardach , Thomas Monjalon , Vladimir Medvedkin , Yipeng Wang , Tyler Retzlaff Subject: [PATCH v4 07/39] net: use C11 alignas Date: Wed, 14 Feb 2024 08:35:32 -0800 Message-Id: <1707928564-28796-8-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1707928564-28796-1-git-send-email-roretzla@linux.microsoft.com> References: <1707873986-29352-1-git-send-email-roretzla@linux.microsoft.com> <1707928564-28796-1-git-send-email-roretzla@linux.microsoft.com> MIME-Version: 1.0 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 * Move __rte_aligned from the end of {struct,union} definitions to be between {struct,union} and tag. The placement between {struct,union} and the tag allows the desired alignment to be imparted on the type regardless of the toolchain being used for all of GCC, LLVM, MSVC compilers building both C and C++. * Replace use of __rte_aligned(a) on variables/fields with alignas(a). Signed-off-by: Tyler Retzlaff Acked-by: Morten Brørup --- lib/net/net_crc_avx512.c | 14 ++++++++------ lib/net/net_crc_neon.c | 11 ++++++----- lib/net/net_crc_sse.c | 17 +++++++++-------- lib/net/rte_arp.h | 8 ++++---- lib/net/rte_ether.h | 8 ++++---- 5 files changed, 31 insertions(+), 27 deletions(-) diff --git a/lib/net/net_crc_avx512.c b/lib/net/net_crc_avx512.c index f6a3ce9..0f48ca0 100644 --- a/lib/net/net_crc_avx512.c +++ b/lib/net/net_crc_avx512.c @@ -3,6 +3,8 @@ */ +#include + #include #include "net_crc.h" @@ -20,8 +22,8 @@ struct crc_vpclmulqdq_ctx { __m128i fold_1x128b; }; -static struct crc_vpclmulqdq_ctx crc32_eth __rte_aligned(64); -static struct crc_vpclmulqdq_ctx crc16_ccitt __rte_aligned(64); +static alignas(64) struct crc_vpclmulqdq_ctx crc32_eth; +static alignas(64) struct crc_vpclmulqdq_ctx crc16_ccitt; static uint16_t byte_len_to_mask_table[] = { 0x0000, 0x0001, 0x0003, 0x0007, @@ -30,18 +32,18 @@ struct crc_vpclmulqdq_ctx { 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff}; -static const uint8_t shf_table[32] __rte_aligned(16) = { +static const alignas(16) uint8_t shf_table[32] = { 0x00, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f }; -static const uint32_t mask[4] __rte_aligned(16) = { +static const alignas(16) uint32_t mask[4] = { 0xffffffff, 0xffffffff, 0x00000000, 0x00000000 }; -static const uint32_t mask2[4] __rte_aligned(16) = { +static const alignas(16) uint32_t mask2[4] = { 0x00000000, 0xffffffff, 0xffffffff, 0xffffffff }; @@ -93,7 +95,7 @@ struct crc_vpclmulqdq_ctx { uint32_t offset; __m128i res2, res3, res4, pshufb_shf; - const uint32_t mask3[4] __rte_aligned(16) = { + const alignas(16) uint32_t mask3[4] = { 0x80808080, 0x80808080, 0x80808080, 0x80808080 }; diff --git a/lib/net/net_crc_neon.c b/lib/net/net_crc_neon.c index f61d75a..cee75dd 100644 --- a/lib/net/net_crc_neon.c +++ b/lib/net/net_crc_neon.c @@ -2,6 +2,7 @@ * Copyright(c) 2017 Cavium, Inc */ +#include #include #include @@ -19,8 +20,8 @@ struct crc_pmull_ctx { uint64x2_t rk7_rk8; }; -struct crc_pmull_ctx crc32_eth_pmull __rte_aligned(16); -struct crc_pmull_ctx crc16_ccitt_pmull __rte_aligned(16); +alignas(16) struct crc_pmull_ctx crc32_eth_pmull; +alignas(16) struct crc_pmull_ctx crc16_ccitt_pmull; /** * @brief Performs one folding round @@ -96,10 +97,10 @@ struct crc_pmull_ctx { crcr32_reduce_64_to_32(uint64x2_t data64, uint64x2_t precomp) { - static uint32_t mask1[4] __rte_aligned(16) = { + static alignas(16) uint32_t mask1[4] = { 0xffffffff, 0xffffffff, 0x00000000, 0x00000000 }; - static uint32_t mask2[4] __rte_aligned(16) = { + static alignas(16) uint32_t mask2[4] = { 0x00000000, 0xffffffff, 0xffffffff, 0xffffffff }; uint64x2_t tmp0, tmp1, tmp2; @@ -148,7 +149,7 @@ struct crc_pmull_ctx { if (unlikely(data_len < 16)) { /* 0 to 15 bytes */ - uint8_t buffer[16] __rte_aligned(16); + alignas(16) uint8_t buffer[16]; memset(buffer, 0, sizeof(buffer)); memcpy(buffer, data, data_len); diff --git a/lib/net/net_crc_sse.c b/lib/net/net_crc_sse.c index dd75845..d673ae3 100644 --- a/lib/net/net_crc_sse.c +++ b/lib/net/net_crc_sse.c @@ -2,6 +2,7 @@ * Copyright(c) 2017-2020 Intel Corporation */ +#include #include #include @@ -18,8 +19,8 @@ struct crc_pclmulqdq_ctx { __m128i rk7_rk8; }; -static struct crc_pclmulqdq_ctx crc32_eth_pclmulqdq __rte_aligned(16); -static struct crc_pclmulqdq_ctx crc16_ccitt_pclmulqdq __rte_aligned(16); +static alignas(16) struct crc_pclmulqdq_ctx crc32_eth_pclmulqdq; +static alignas(16) struct crc_pclmulqdq_ctx crc16_ccitt_pclmulqdq; /** * @brief Performs one folding round * @@ -96,11 +97,11 @@ struct crc_pclmulqdq_ctx { static __rte_always_inline uint32_t crcr32_reduce_64_to_32(__m128i data64, __m128i precomp) { - static const uint32_t mask1[4] __rte_aligned(16) = { + static const alignas(16) uint32_t mask1[4] = { 0xffffffff, 0xffffffff, 0x00000000, 0x00000000 }; - static const uint32_t mask2[4] __rte_aligned(16) = { + static const alignas(16) uint32_t mask2[4] = { 0x00000000, 0xffffffff, 0xffffffff, 0xffffffff }; __m128i tmp0, tmp1, tmp2; @@ -118,7 +119,7 @@ struct crc_pclmulqdq_ctx { return _mm_extract_epi32(tmp2, 2); } -static const uint8_t crc_xmm_shift_tab[48] __rte_aligned(16) = { +static const alignas(16) uint8_t crc_xmm_shift_tab[48] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, @@ -175,7 +176,7 @@ struct crc_pclmulqdq_ctx { if (unlikely(data_len < 16)) { /* 0 to 15 bytes */ - uint8_t buffer[16] __rte_aligned(16); + alignas(16) uint8_t buffer[16]; memset(buffer, 0, sizeof(buffer)); memcpy(buffer, data, data_len); @@ -212,11 +213,11 @@ struct crc_pclmulqdq_ctx { partial_bytes: if (likely(n < data_len)) { - const uint32_t mask3[4] __rte_aligned(16) = { + const alignas(16) uint32_t mask3[4] = { 0x80808080, 0x80808080, 0x80808080, 0x80808080 }; - const uint8_t shf_table[32] __rte_aligned(16) = { + const alignas(16) uint8_t shf_table[32] = { 0x00, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, diff --git a/lib/net/rte_arp.h b/lib/net/rte_arp.h index c3cd0af..668cea1 100644 --- a/lib/net/rte_arp.h +++ b/lib/net/rte_arp.h @@ -21,17 +21,17 @@ /** * ARP header IPv4 payload. */ -struct rte_arp_ipv4 { +struct __rte_aligned(2) rte_arp_ipv4 { struct rte_ether_addr arp_sha; /**< sender hardware address */ rte_be32_t arp_sip; /**< sender IP address */ struct rte_ether_addr arp_tha; /**< target hardware address */ rte_be32_t arp_tip; /**< target IP address */ -} __rte_packed __rte_aligned(2); +} __rte_packed; /** * ARP header. */ -struct rte_arp_hdr { +struct __rte_aligned(2) rte_arp_hdr { rte_be16_t arp_hardware; /**< format of hardware address */ #define RTE_ARP_HRD_ETHER 1 /**< ARP Ethernet address format */ @@ -47,7 +47,7 @@ struct rte_arp_hdr { #define RTE_ARP_OP_INVREPLY 9 /**< response identifying peer */ struct rte_arp_ipv4 arp_data; -} __rte_packed __rte_aligned(2); +} __rte_packed; /** * Make a RARP packet based on MAC addr. diff --git a/lib/net/rte_ether.h b/lib/net/rte_ether.h index ce073ea..f4c5af4 100644 --- a/lib/net/rte_ether.h +++ b/lib/net/rte_ether.h @@ -57,9 +57,9 @@ * administrator and does not contain OUIs. * See http://standards.ieee.org/regauth/groupmac/tutorial.html */ -struct rte_ether_addr { +struct __rte_aligned(2) rte_ether_addr { uint8_t addr_bytes[RTE_ETHER_ADDR_LEN]; /**< Addr bytes in tx order */ -} __rte_aligned(2); +}; #define RTE_ETHER_LOCAL_ADMIN_ADDR 0x02 /**< Locally assigned Eth. address. */ #define RTE_ETHER_GROUP_ADDR 0x01 /**< Multicast or broadcast Eth. address. */ @@ -276,11 +276,11 @@ static inline int rte_is_valid_assigned_ether_addr(const struct rte_ether_addr * * Ethernet header: Contains the destination address, source address * and frame type. */ -struct rte_ether_hdr { +struct __rte_aligned(2) rte_ether_hdr { struct rte_ether_addr dst_addr; /**< Destination address. */ struct rte_ether_addr src_addr; /**< Source address. */ rte_be16_t ether_type; /**< Frame type. */ -} __rte_aligned(2); +}; /** * Ethernet VLAN Header. From patchwork Wed Feb 14 16:35:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 136758 X-Patchwork-Delegate: david.marchand@redhat.com 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 D64A643B38; Wed, 14 Feb 2024 17:36:42 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5DC7442E93; Wed, 14 Feb 2024 17:36:15 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id A0A82427DB for ; Wed, 14 Feb 2024 17:36:07 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 4BAEB20B2008; Wed, 14 Feb 2024 08:36:06 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 4BAEB20B2008 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1707928566; bh=VwyGmxOwemqg4ZGIaIruP9FtBAF3jj/dHxES9GFQOKI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YewLbUlqzRa9+aNUYQ8NElLuZLRAYybXRSYk8LwRN9d1fjAC/rBprJdMg70qDApD5 o2TTB7FhX7mPXPf+Lj34pmIuK+9qfWRqYVM43N82b3h4JD7vfE/7bPxSrprPWSf8up X+qhhfJhnYWLoSTKioySTZylJjx6jyHqq1QsN4S8= From: Tyler Retzlaff To: dev@dpdk.org Cc: Andrew Rybchenko , Bruce Richardson , Chengwen Feng , Cristian Dumitrescu , David Christensen , David Hunt , Ferruh Yigit , Honnappa Nagarahalli , Jasvinder Singh , Jerin Jacob , Kevin Laatz , Konstantin Ananyev , Min Zhou , Ruifeng Wang , Sameh Gobriel , Stanislaw Kardach , Thomas Monjalon , Vladimir Medvedkin , Yipeng Wang , Tyler Retzlaff Subject: [PATCH v4 08/39] mbuf: use C11 alignas Date: Wed, 14 Feb 2024 08:35:33 -0800 Message-Id: <1707928564-28796-9-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1707928564-28796-1-git-send-email-roretzla@linux.microsoft.com> References: <1707873986-29352-1-git-send-email-roretzla@linux.microsoft.com> <1707928564-28796-1-git-send-email-roretzla@linux.microsoft.com> MIME-Version: 1.0 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 * Move __rte_aligned from the end of {struct,union} definitions to be between {struct,union} and tag. The placement between {struct,union} and the tag allows the desired alignment to be imparted on the type regardless of the toolchain being used for all of GCC, LLVM, MSVC compilers building both C and C++. * Replace use of __rte_aligned(a) on variables/fields with alignas(a). Signed-off-by: Tyler Retzlaff Acked-by: Morten Brørup --- lib/mbuf/rte_mbuf_core.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/mbuf/rte_mbuf_core.h b/lib/mbuf/rte_mbuf_core.h index 5688683..917a811 100644 --- a/lib/mbuf/rte_mbuf_core.h +++ b/lib/mbuf/rte_mbuf_core.h @@ -463,7 +463,7 @@ enum { /** * The generic rte_mbuf, containing a packet mbuf. */ -struct rte_mbuf { +struct __rte_cache_aligned rte_mbuf { RTE_MARKER cacheline0; void *buf_addr; /**< Virtual address of segment buffer. */ @@ -476,7 +476,7 @@ struct rte_mbuf { * same mbuf cacheline0 layout for 32-bit and 64-bit. This makes * working on vector drivers easier. */ - rte_iova_t buf_iova __rte_aligned(sizeof(rte_iova_t)); + alignas(sizeof(rte_iova_t)) rte_iova_t buf_iova; #else /** * Next segment of scattered packet. @@ -662,7 +662,7 @@ struct rte_mbuf { uint16_t timesync; uint32_t dynfield1[9]; /**< Reserved for dynamic fields. */ -} __rte_cache_aligned; +}; /** * Function typedef of callback to free externally attached buffer. From patchwork Wed Feb 14 16:35:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 136762 X-Patchwork-Delegate: david.marchand@redhat.com 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 94F7A43B38; Wed, 14 Feb 2024 17:37:09 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 07F9042F55; Wed, 14 Feb 2024 17:36:20 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id ABBAE427DF for ; Wed, 14 Feb 2024 17:36:07 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 59B2320B2009; Wed, 14 Feb 2024 08:36:06 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 59B2320B2009 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1707928566; bh=0l1yOClIFa7717GBCevE8biiCCdRwf6lR5UfvfZyo18=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GoaZ5gp/KPrKXCHgFI+fpJl1h0YMhW5jBIj3wioFrt6rQU2yi+BfF2oe7WnJDL6By V6uLh2KcuHVmGK0W6RndiP1FcwGyUyvzwKXJ29JUkgB96kGkAmvbzHOH4rgBPJjR0r VQKCB9fLyYRQyH8Y3/9GRbUXWZuy1Nm95JJu1bQU= From: Tyler Retzlaff To: dev@dpdk.org Cc: Andrew Rybchenko , Bruce Richardson , Chengwen Feng , Cristian Dumitrescu , David Christensen , David Hunt , Ferruh Yigit , Honnappa Nagarahalli , Jasvinder Singh , Jerin Jacob , Kevin Laatz , Konstantin Ananyev , Min Zhou , Ruifeng Wang , Sameh Gobriel , Stanislaw Kardach , Thomas Monjalon , Vladimir Medvedkin , Yipeng Wang , Tyler Retzlaff Subject: [PATCH v4 09/39] hash: use C11 alignas Date: Wed, 14 Feb 2024 08:35:34 -0800 Message-Id: <1707928564-28796-10-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1707928564-28796-1-git-send-email-roretzla@linux.microsoft.com> References: <1707873986-29352-1-git-send-email-roretzla@linux.microsoft.com> <1707928564-28796-1-git-send-email-roretzla@linux.microsoft.com> MIME-Version: 1.0 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 * Move __rte_aligned from the end of {struct,union} definitions to be between {struct,union} and tag. The placement between {struct,union} and the tag allows the desired alignment to be imparted on the type regardless of the toolchain being used for all of GCC, LLVM, MSVC compilers building both C and C++. * Replace use of __rte_aligned(a) on variables/fields with alignas(a). Signed-off-by: Tyler Retzlaff Acked-by: Morten Brørup --- lib/hash/rte_cuckoo_hash.h | 16 +++++++++------- lib/hash/rte_thash.c | 4 +++- lib/hash/rte_thash.h | 8 ++++---- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/lib/hash/rte_cuckoo_hash.h b/lib/hash/rte_cuckoo_hash.h index 8ea793c..a528f1d 100644 --- a/lib/hash/rte_cuckoo_hash.h +++ b/lib/hash/rte_cuckoo_hash.h @@ -11,6 +11,8 @@ #ifndef _RTE_CUCKOO_HASH_H_ #define _RTE_CUCKOO_HASH_H_ +#include + #if defined(RTE_ARCH_X86) #include "rte_cmp_x86.h" #endif @@ -117,10 +119,10 @@ enum cmp_jump_table_case { #define RTE_HASH_TSX_MAX_RETRY 10 -struct lcore_cache { +struct __rte_cache_aligned lcore_cache { unsigned len; /**< Cache len */ uint32_t objs[LCORE_CACHE_SIZE]; /**< Cache objects */ -} __rte_cache_aligned; +}; /* Structure that stores key-value pair */ struct rte_hash_key { @@ -141,7 +143,7 @@ enum rte_hash_sig_compare_function { }; /** Bucket structure */ -struct rte_hash_bucket { +struct __rte_cache_aligned rte_hash_bucket { uint16_t sig_current[RTE_HASH_BUCKET_ENTRIES]; RTE_ATOMIC(uint32_t) key_idx[RTE_HASH_BUCKET_ENTRIES]; @@ -149,10 +151,10 @@ struct rte_hash_bucket { uint8_t flag[RTE_HASH_BUCKET_ENTRIES]; void *next; -} __rte_cache_aligned; +}; /** A hash table structure. */ -struct rte_hash { +struct __rte_cache_aligned rte_hash { char name[RTE_HASH_NAMESIZE]; /**< Name of the hash. */ uint32_t entries; /**< Total table entries. */ uint32_t num_buckets; /**< Number of buckets in table. */ @@ -170,7 +172,7 @@ struct rte_hash { /* Fields used in lookup */ - uint32_t key_len __rte_cache_aligned; + alignas(RTE_CACHE_LINE_SIZE) uint32_t key_len; /**< Length of hash key. */ uint8_t hw_trans_mem_support; /**< If hardware transactional memory is used. */ @@ -220,7 +222,7 @@ struct rte_hash { uint32_t *ext_bkt_to_free; RTE_ATOMIC(uint32_t) *tbl_chng_cnt; /**< Indicates if the hash table changed from last read. */ -} __rte_cache_aligned; +}; struct queue_node { struct rte_hash_bucket *bkt; /* Current bucket on the bfs search */ diff --git a/lib/hash/rte_thash.c b/lib/hash/rte_thash.c index e8de071..6464fd3 100644 --- a/lib/hash/rte_thash.c +++ b/lib/hash/rte_thash.c @@ -2,6 +2,8 @@ * Copyright(c) 2021 Intel Corporation */ +#include + #include #include @@ -80,7 +82,7 @@ struct rte_thash_subtuple_helper { uint32_t tuple_offset; /** < Offset in bits of the subtuple */ uint32_t tuple_len; /** < Length in bits of the subtuple */ uint32_t lsb_msk; /** < (1 << reta_sz_log) - 1 */ - __extension__ uint32_t compl_table[0] __rte_cache_aligned; + __extension__ alignas(RTE_CACHE_LINE_SIZE) uint32_t compl_table[0]; /** < Complementary table */ }; diff --git a/lib/hash/rte_thash.h b/lib/hash/rte_thash.h index 2681b1b..30b657e 100644 --- a/lib/hash/rte_thash.h +++ b/lib/hash/rte_thash.h @@ -99,14 +99,14 @@ struct rte_ipv6_tuple { }; }; +#ifdef RTE_ARCH_X86 +union __rte_aligned(XMM_SIZE) rte_thash_tuple { +#else union rte_thash_tuple { +#endif struct rte_ipv4_tuple v4; struct rte_ipv6_tuple v6; -#ifdef RTE_ARCH_X86 -} __rte_aligned(XMM_SIZE); -#else }; -#endif /** * Prepare special converted key to use with rte_softrss_be() From patchwork Wed Feb 14 16:35:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 136769 X-Patchwork-Delegate: david.marchand@redhat.com 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 6853143B38; Wed, 14 Feb 2024 17:37:53 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EFB7643276; Wed, 14 Feb 2024 17:36:27 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id E401E42E1F for ; Wed, 14 Feb 2024 17:36:07 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 6874420B200A; Wed, 14 Feb 2024 08:36:06 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 6874420B200A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1707928566; bh=EUULW1R3VxZYklPYv9ygVN/t9s2kdM/QkEZndOfrNMU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AWAklsMF3oTVdfw56b/kaPmq8g/NltC3XMWJEBiyaw45iI7esfyFNBHYJJriH4uGG lwrkZZGaKfeKVkOyo4L76m9yxU0kaJA9iLQb0fIMTaClKR5+HSUtLS67KckmCiGlJm c/pxAgT/gU8Qm8e/aHaU1KKWAJY169vFIrk50CCI= From: Tyler Retzlaff To: dev@dpdk.org Cc: Andrew Rybchenko , Bruce Richardson , Chengwen Feng , Cristian Dumitrescu , David Christensen , David Hunt , Ferruh Yigit , Honnappa Nagarahalli , Jasvinder Singh , Jerin Jacob , Kevin Laatz , Konstantin Ananyev , Min Zhou , Ruifeng Wang , Sameh Gobriel , Stanislaw Kardach , Thomas Monjalon , Vladimir Medvedkin , Yipeng Wang , Tyler Retzlaff Subject: [PATCH v4 10/39] eventdev: use C11 alignas Date: Wed, 14 Feb 2024 08:35:35 -0800 Message-Id: <1707928564-28796-11-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1707928564-28796-1-git-send-email-roretzla@linux.microsoft.com> References: <1707873986-29352-1-git-send-email-roretzla@linux.microsoft.com> <1707928564-28796-1-git-send-email-roretzla@linux.microsoft.com> MIME-Version: 1.0 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 * Move __rte_aligned from the end of {struct,union} definitions to be between {struct,union} and tag. The placement between {struct,union} and the tag allows the desired alignment to be imparted on the type regardless of the toolchain being used for all of GCC, LLVM, MSVC compilers building both C and C++. * Replace use of __rte_aligned(a) on variables/fields with alignas(a). Signed-off-by: Tyler Retzlaff Acked-by: Morten Brørup --- lib/eventdev/event_timer_adapter_pmd.h | 4 ++-- lib/eventdev/eventdev_pmd.h | 8 ++++---- lib/eventdev/rte_event_crypto_adapter.c | 16 ++++++++-------- lib/eventdev/rte_event_dma_adapter.c | 16 ++++++++-------- lib/eventdev/rte_event_eth_rx_adapter.c | 8 ++++---- lib/eventdev/rte_event_eth_tx_adapter.c | 4 ++-- lib/eventdev/rte_event_timer_adapter.c | 9 +++++---- lib/eventdev/rte_event_timer_adapter.h | 8 ++++---- lib/eventdev/rte_eventdev.h | 8 ++++---- lib/eventdev/rte_eventdev_core.h | 4 ++-- 10 files changed, 43 insertions(+), 42 deletions(-) diff --git a/lib/eventdev/event_timer_adapter_pmd.h b/lib/eventdev/event_timer_adapter_pmd.h index 65b421b..cd5127f 100644 --- a/lib/eventdev/event_timer_adapter_pmd.h +++ b/lib/eventdev/event_timer_adapter_pmd.h @@ -86,7 +86,7 @@ struct event_timer_adapter_ops { * @internal Adapter data; structure to be placed in shared memory to be * accessible by various processes in a multi-process configuration. */ -struct rte_event_timer_adapter_data { +struct __rte_cache_aligned rte_event_timer_adapter_data { uint8_t id; /**< Event timer adapter ID */ uint8_t event_dev_id; @@ -110,7 +110,7 @@ struct rte_event_timer_adapter_data { uint8_t started : 1; /**< Flag to indicate adapter started. */ -} __rte_cache_aligned; +}; #ifdef __cplusplus } diff --git a/lib/eventdev/eventdev_pmd.h b/lib/eventdev/eventdev_pmd.h index c415624..3934d8e 100644 --- a/lib/eventdev/eventdev_pmd.h +++ b/lib/eventdev/eventdev_pmd.h @@ -107,7 +107,7 @@ struct rte_eventdev_global { * This structure is safe to place in shared memory to be common among * different processes in a multi-process configuration. */ -struct rte_eventdev_data { +struct __rte_cache_aligned rte_eventdev_data { int socket_id; /**< Socket ID where memory is allocated */ uint8_t dev_id; @@ -146,10 +146,10 @@ struct rte_eventdev_data { uint64_t reserved_64s[4]; /**< Reserved for future fields */ void *reserved_ptrs[4]; /**< Reserved for future fields */ -} __rte_cache_aligned; +}; /** @internal The data structure associated with each event device. */ -struct rte_eventdev { +struct __rte_cache_aligned rte_eventdev { struct rte_eventdev_data *data; /**< Pointer to device data */ struct eventdev_ops *dev_ops; @@ -189,7 +189,7 @@ struct rte_eventdev { uint64_t reserved_64s[3]; /**< Reserved for future fields */ void *reserved_ptrs[3]; /**< Reserved for future fields */ -} __rte_cache_aligned; +}; extern struct rte_eventdev *rte_eventdevs; /** @internal The pool of rte_eventdev structures. */ diff --git a/lib/eventdev/rte_event_crypto_adapter.c b/lib/eventdev/rte_event_crypto_adapter.c index d46595d..6bc2769 100644 --- a/lib/eventdev/rte_event_crypto_adapter.c +++ b/lib/eventdev/rte_event_crypto_adapter.c @@ -42,7 +42,7 @@ #define ECA_ADAPTER_ARRAY "crypto_adapter_array" -struct crypto_ops_circular_buffer { +struct __rte_cache_aligned crypto_ops_circular_buffer { /* index of head element in circular buffer */ uint16_t head; /* index of tail element in circular buffer */ @@ -53,9 +53,9 @@ struct crypto_ops_circular_buffer { uint16_t size; /* Pointer to hold rte_crypto_ops for batching */ struct rte_crypto_op **op_buffer; -} __rte_cache_aligned; +}; -struct event_crypto_adapter { +struct __rte_cache_aligned event_crypto_adapter { /* Event device identifier */ uint8_t eventdev_id; /* Event port identifier */ @@ -98,10 +98,10 @@ struct event_crypto_adapter { uint16_t nb_qps; /* Adapter mode */ enum rte_event_crypto_adapter_mode mode; -} __rte_cache_aligned; +}; /* Per crypto device information */ -struct crypto_device_info { +struct __rte_cache_aligned crypto_device_info { /* Pointer to cryptodev */ struct rte_cryptodev *dev; /* Pointer to queue pair info */ @@ -118,15 +118,15 @@ struct crypto_device_info { * be invoked if not already invoked */ uint16_t num_qpairs; -} __rte_cache_aligned; +}; /* Per queue pair information */ -struct crypto_queue_pair_info { +struct __rte_cache_aligned crypto_queue_pair_info { /* Set to indicate queue pair is enabled */ bool qp_enabled; /* Circular buffer for batching crypto ops to cdev */ struct crypto_ops_circular_buffer cbuf; -} __rte_cache_aligned; +}; static struct event_crypto_adapter **event_crypto_adapter; diff --git a/lib/eventdev/rte_event_dma_adapter.c b/lib/eventdev/rte_event_dma_adapter.c index 4196164..24dff55 100644 --- a/lib/eventdev/rte_event_dma_adapter.c +++ b/lib/eventdev/rte_event_dma_adapter.c @@ -26,7 +26,7 @@ } while (0) /* DMA ops circular buffer */ -struct dma_ops_circular_buffer { +struct __rte_cache_aligned dma_ops_circular_buffer { /* Index of head element */ uint16_t head; @@ -41,19 +41,19 @@ struct dma_ops_circular_buffer { /* Pointer to hold rte_event_dma_adapter_op for processing */ struct rte_event_dma_adapter_op **op_buffer; -} __rte_cache_aligned; +}; /* Vchan information */ -struct dma_vchan_info { +struct __rte_cache_aligned dma_vchan_info { /* Set to indicate vchan queue is enabled */ bool vq_enabled; /* Circular buffer for batching DMA ops to dma_dev */ struct dma_ops_circular_buffer dma_buf; -} __rte_cache_aligned; +}; /* DMA device information */ -struct dma_device_info { +struct __rte_cache_aligned dma_device_info { /* Pointer to vchan queue info */ struct dma_vchan_info *vchanq; @@ -81,9 +81,9 @@ struct dma_device_info { * transfer uses a hardware mechanism */ uint8_t internal_event_port; -} __rte_cache_aligned; +}; -struct event_dma_adapter { +struct __rte_cache_aligned event_dma_adapter { /* Event device identifier */ uint8_t eventdev_id; @@ -145,7 +145,7 @@ struct event_dma_adapter { /* Per instance stats structure */ struct rte_event_dma_adapter_stats dma_stats; -} __rte_cache_aligned; +}; static struct event_dma_adapter **event_dma_adapter; diff --git a/lib/eventdev/rte_event_eth_rx_adapter.c b/lib/eventdev/rte_event_eth_rx_adapter.c index 1b83a55..3ee20d9 100644 --- a/lib/eventdev/rte_event_eth_rx_adapter.c +++ b/lib/eventdev/rte_event_eth_rx_adapter.c @@ -72,7 +72,7 @@ struct eth_rx_poll_entry { uint16_t eth_rx_qid; }; -struct eth_rx_vector_data { +struct __rte_cache_aligned eth_rx_vector_data { TAILQ_ENTRY(eth_rx_vector_data) next; uint16_t port; uint16_t queue; @@ -82,7 +82,7 @@ struct eth_rx_vector_data { uint64_t vector_timeout_ticks; struct rte_mempool *vector_pool; struct rte_event_vector *vector_ev; -} __rte_cache_aligned; +}; TAILQ_HEAD(eth_rx_vector_data_list, eth_rx_vector_data); @@ -103,7 +103,7 @@ struct eth_event_enqueue_buffer { uint16_t last_mask; }; -struct event_eth_rx_adapter { +struct __rte_cache_aligned event_eth_rx_adapter { /* RSS key */ uint8_t rss_key_be[RSS_KEY_SIZE]; /* Event device identifier */ @@ -188,7 +188,7 @@ struct event_eth_rx_adapter { uint8_t rxa_started; /* Adapter ID */ uint8_t id; -} __rte_cache_aligned; +}; /* Per eth device */ struct eth_device_info { diff --git a/lib/eventdev/rte_event_eth_tx_adapter.c b/lib/eventdev/rte_event_eth_tx_adapter.c index 56435be..67fff8b 100644 --- a/lib/eventdev/rte_event_eth_tx_adapter.c +++ b/lib/eventdev/rte_event_eth_tx_adapter.c @@ -109,7 +109,7 @@ struct txa_service_queue_info { }; /* PMD private structure */ -struct txa_service_data { +struct __rte_cache_aligned txa_service_data { /* Max mbufs processed in any service function invocation */ uint32_t max_nb_tx; /* Number of Tx queues in adapter */ @@ -144,7 +144,7 @@ struct txa_service_data { int64_t service_id; /* Memory allocation name */ char mem_name[TXA_MEM_NAME_LEN]; -} __rte_cache_aligned; +}; /* Per eth device structure */ struct txa_service_ethdev { diff --git a/lib/eventdev/rte_event_timer_adapter.c b/lib/eventdev/rte_event_timer_adapter.c index e6d3492..5d3e37f 100644 --- a/lib/eventdev/rte_event_timer_adapter.c +++ b/lib/eventdev/rte_event_timer_adapter.c @@ -4,6 +4,7 @@ */ #include +#include #include #include #include @@ -512,11 +513,11 @@ struct rte_event_timer_adapter * #define EXP_TIM_BUF_SZ 128 -struct event_buffer { +struct __rte_cache_aligned event_buffer { size_t head; size_t tail; struct rte_event events[EVENT_BUFFER_SZ]; -} __rte_cache_aligned; +}; static inline bool event_buffer_full(struct event_buffer *bufp) @@ -632,9 +633,9 @@ struct swtim { /* Identifier of timer data instance */ uint32_t timer_data_id; /* Track which cores have actually armed a timer */ - struct { + alignas(RTE_CACHE_LINE_SIZE) struct { RTE_ATOMIC(uint16_t) v; - } __rte_cache_aligned in_use[RTE_MAX_LCORE]; + } in_use[RTE_MAX_LCORE]; /* Track which cores' timer lists should be polled */ RTE_ATOMIC(unsigned int) poll_lcores[RTE_MAX_LCORE]; /* The number of lists that should be polled */ diff --git a/lib/eventdev/rte_event_timer_adapter.h b/lib/eventdev/rte_event_timer_adapter.h index c133dec..0bd1b30 100644 --- a/lib/eventdev/rte_event_timer_adapter.h +++ b/lib/eventdev/rte_event_timer_adapter.h @@ -473,7 +473,7 @@ enum rte_event_timer_state { * The generic *rte_event_timer* structure to hold the event timer attributes * for arm and cancel operations. */ -struct rte_event_timer { +struct __rte_cache_aligned rte_event_timer { struct rte_event ev; /**< * Expiry event attributes. On successful event timer timeout, @@ -504,7 +504,7 @@ struct rte_event_timer { /**< Memory to store user specific metadata. * The event timer adapter implementation should not modify this area. */ -} __rte_cache_aligned; +}; typedef uint16_t (*rte_event_timer_arm_burst_t)( const struct rte_event_timer_adapter *adapter, @@ -526,7 +526,7 @@ typedef uint16_t (*rte_event_timer_cancel_burst_t)( /** * @internal Data structure associated with each event timer adapter. */ -struct rte_event_timer_adapter { +struct __rte_cache_aligned rte_event_timer_adapter { rte_event_timer_arm_burst_t arm_burst; /**< Pointer to driver arm_burst function. */ rte_event_timer_arm_tmo_tick_burst_t arm_tmo_tick_burst; @@ -540,7 +540,7 @@ struct rte_event_timer_adapter { uint8_t allocated : 1; /**< Flag to indicate that this adapter has been allocated */ -} __rte_cache_aligned; +}; #define ADAPTER_VALID_OR_ERR_RET(adapter, retval) do { \ if (adapter == NULL || !adapter->allocated) \ diff --git a/lib/eventdev/rte_eventdev.h b/lib/eventdev/rte_eventdev.h index ec9b024..ff143c7 100644 --- a/lib/eventdev/rte_eventdev.h +++ b/lib/eventdev/rte_eventdev.h @@ -1078,7 +1078,7 @@ int rte_event_dev_stop_flush_callback_register(uint8_t dev_id, /** * Event vector structure. */ -struct rte_event_vector { +struct __rte_aligned(16) rte_event_vector { uint16_t nb_elem; /**< Number of elements valid in this event vector. */ uint16_t elem_offset : 12; @@ -1118,19 +1118,19 @@ struct rte_event_vector { * value to share between dequeue and enqueue operation. * The application should not modify this field. */ - union { + union __rte_aligned(16) { #endif struct rte_mbuf *mbufs[0]; void *ptrs[0]; uint64_t u64s[0]; #ifndef __cplusplus - } __rte_aligned(16); + }; #endif /**< Start of the vector array union. Depending upon the event type the * vector array can be an array of mbufs or pointers or opaque u64 * values. */ -} __rte_aligned(16); +}; /* Scheduler type definitions */ #define RTE_SCHED_TYPE_ORDERED 0 diff --git a/lib/eventdev/rte_eventdev_core.h b/lib/eventdev/rte_eventdev_core.h index 5b40551..fc8e155 100644 --- a/lib/eventdev/rte_eventdev_core.h +++ b/lib/eventdev/rte_eventdev_core.h @@ -49,7 +49,7 @@ typedef uint16_t (*event_dma_adapter_enqueue_t)(void *port, struct rte_event ev[ typedef int (*event_profile_switch_t)(void *port, uint8_t profile); /**< @internal Switch active link profile on the event port. */ -struct rte_event_fp_ops { +struct __rte_cache_aligned rte_event_fp_ops { void **data; /**< points to array of internal port data pointers */ event_enqueue_t enqueue; @@ -77,7 +77,7 @@ struct rte_event_fp_ops { event_profile_switch_t profile_switch; /**< PMD Event switch profile function. */ uintptr_t reserved[4]; -} __rte_cache_aligned; +}; extern struct rte_event_fp_ops rte_event_fp_ops[RTE_EVENT_MAX_DEVS]; From patchwork Wed Feb 14 16:35:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 136763 X-Patchwork-Delegate: david.marchand@redhat.com 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 8226343B38; Wed, 14 Feb 2024 17:37:16 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3198442F7D; Wed, 14 Feb 2024 17:36:21 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id CA15842B71 for ; Wed, 14 Feb 2024 17:36:07 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 779E020B200B; Wed, 14 Feb 2024 08:36:06 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 779E020B200B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1707928566; bh=ZpomPayVC9Q0RdLnom0uLzofLMVwSTsxNCVqzblWH0U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FDcY+bvxufMWh0E410uwCzCCCSRgzWk9eV85nV0viFMwbVBea1TG6qI9Kf0kXFjJN rAvX5eSdmFxs1hCa1T4u1JRUdCmAvC2xeImqsldmT+sJenc0BQALnDdcHd3cFvnpd9 OsOiC6cQX1nfHs8OKp7gEiPOmWU3KwHl/1MEtKIU= From: Tyler Retzlaff To: dev@dpdk.org Cc: Andrew Rybchenko , Bruce Richardson , Chengwen Feng , Cristian Dumitrescu , David Christensen , David Hunt , Ferruh Yigit , Honnappa Nagarahalli , Jasvinder Singh , Jerin Jacob , Kevin Laatz , Konstantin Ananyev , Min Zhou , Ruifeng Wang , Sameh Gobriel , Stanislaw Kardach , Thomas Monjalon , Vladimir Medvedkin , Yipeng Wang , Tyler Retzlaff Subject: [PATCH v4 11/39] ethdev: use C11 alignas Date: Wed, 14 Feb 2024 08:35:36 -0800 Message-Id: <1707928564-28796-12-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1707928564-28796-1-git-send-email-roretzla@linux.microsoft.com> References: <1707873986-29352-1-git-send-email-roretzla@linux.microsoft.com> <1707928564-28796-1-git-send-email-roretzla@linux.microsoft.com> MIME-Version: 1.0 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 * Move __rte_aligned from the end of {struct,union} definitions to be between {struct,union} and tag. The placement between {struct,union} and the tag allows the desired alignment to be imparted on the type regardless of the toolchain being used for all of GCC, LLVM, MSVC compilers building both C and C++. * Replace use of __rte_aligned(a) on variables/fields with alignas(a). Signed-off-by: Tyler Retzlaff Acked-by: Morten Brørup --- lib/ethdev/ethdev_driver.h | 8 ++++---- lib/ethdev/rte_ethdev.h | 16 ++++++++-------- lib/ethdev/rte_ethdev_core.h | 4 ++-- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/ethdev/ethdev_driver.h b/lib/ethdev/ethdev_driver.h index b482cd1..2edad71 100644 --- a/lib/ethdev/ethdev_driver.h +++ b/lib/ethdev/ethdev_driver.h @@ -48,7 +48,7 @@ struct rte_eth_rxtx_callback { * memory. This split allows the function pointer and driver data to be per- * process, while the actual configuration data for the device is shared. */ -struct rte_eth_dev { +struct __rte_cache_aligned rte_eth_dev { eth_rx_burst_t rx_pkt_burst; /**< Pointer to PMD receive function */ eth_tx_burst_t tx_pkt_burst; /**< Pointer to PMD transmit function */ @@ -89,7 +89,7 @@ struct rte_eth_dev { enum rte_eth_dev_state state; /**< Flag indicating the port state */ void *security_ctx; /**< Context for security ops */ -} __rte_cache_aligned; +}; struct rte_eth_dev_sriov; struct rte_eth_dev_owner; @@ -100,7 +100,7 @@ struct rte_eth_dev { * device. This structure is safe to place in shared memory to be common * among different processes in a multi-process configuration. */ -struct rte_eth_dev_data { +struct __rte_cache_aligned rte_eth_dev_data { char name[RTE_ETH_NAME_MAX_LEN]; /**< Unique identifier name */ void **rx_queues; /**< Array of pointers to Rx queues */ @@ -186,7 +186,7 @@ struct rte_eth_dev_data { uint16_t backer_port_id; pthread_mutex_t flow_ops_mutex; /**< rte_flow ops mutex */ -} __rte_cache_aligned; +}; /** * @internal diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h index 21e3a21..b7eca2f 100644 --- a/lib/ethdev/rte_ethdev.h +++ b/lib/ethdev/rte_ethdev.h @@ -333,12 +333,12 @@ struct rte_eth_stats { * A structure used to retrieve link-level information of an Ethernet port. */ __extension__ -struct rte_eth_link { +struct __rte_aligned(8) rte_eth_link { uint32_t link_speed; /**< RTE_ETH_SPEED_NUM_ */ uint16_t link_duplex : 1; /**< RTE_ETH_LINK_[HALF/FULL]_DUPLEX */ uint16_t link_autoneg : 1; /**< RTE_ETH_LINK_[AUTONEG/FIXED] */ uint16_t link_status : 1; /**< RTE_ETH_LINK_[DOWN/UP] */ -} __rte_aligned(8); /**< aligned for atomic64 read/write */ +}; /**< aligned for atomic64 read/write */ /**@{@name Link negotiation * Constants used in link management. @@ -1835,7 +1835,7 @@ struct rte_eth_dev_info { * Ethernet device Rx queue information structure. * Used to retrieve information about configured queue. */ -struct rte_eth_rxq_info { +struct __rte_cache_min_aligned rte_eth_rxq_info { struct rte_mempool *mp; /**< mempool used by that queue. */ struct rte_eth_rxconf conf; /**< queue config parameters. */ uint8_t scattered_rx; /**< scattered packets Rx supported. */ @@ -1849,17 +1849,17 @@ struct rte_eth_rxq_info { * Value 0 means that the threshold monitoring is disabled. */ uint8_t avail_thresh; -} __rte_cache_min_aligned; +}; /** * Ethernet device Tx queue information structure. * Used to retrieve information about configured queue. */ -struct rte_eth_txq_info { +struct __rte_cache_min_aligned rte_eth_txq_info { struct rte_eth_txconf conf; /**< queue config parameters. */ uint16_t nb_desc; /**< configured number of TXDs. */ uint8_t queue_state; /**< one of RTE_ETH_QUEUE_STATE_*. */ -} __rte_cache_min_aligned; +}; /** * @warning @@ -1869,7 +1869,7 @@ struct rte_eth_txq_info { * Used to retrieve Rx queue information when Tx queue reusing mbufs and moving * them into Rx mbuf ring. */ -struct rte_eth_recycle_rxq_info { +struct __rte_cache_min_aligned rte_eth_recycle_rxq_info { struct rte_mbuf **mbuf_ring; /**< mbuf ring of Rx queue. */ struct rte_mempool *mp; /**< mempool of Rx queue. */ uint16_t *refill_head; /**< head of Rx queue refilling mbufs. */ @@ -1883,7 +1883,7 @@ struct rte_eth_recycle_rxq_info { * Value 0 means that PMD drivers have no requirement for this. */ uint16_t refill_requirement; -} __rte_cache_min_aligned; +}; /* Generic Burst mode flag definition, values can be ORed. */ diff --git a/lib/ethdev/rte_ethdev_core.h b/lib/ethdev/rte_ethdev_core.h index 4bfaf79..fdfc68f 100644 --- a/lib/ethdev/rte_ethdev_core.h +++ b/lib/ethdev/rte_ethdev_core.h @@ -81,7 +81,7 @@ struct rte_ethdev_qdata { * On 64-bit systems contents of this structure occupy exactly two 64B lines. * On 32-bit systems contents of this structure fits into one 64B line. */ -struct rte_eth_fp_ops { +struct __rte_cache_aligned rte_eth_fp_ops { /**@{*/ /** @@ -119,7 +119,7 @@ struct rte_eth_fp_ops { uintptr_t reserved2[2]; /**@}*/ -} __rte_cache_aligned; +}; extern struct rte_eth_fp_ops rte_eth_fp_ops[RTE_MAX_ETHPORTS]; From patchwork Wed Feb 14 16:35:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 136764 X-Patchwork-Delegate: david.marchand@redhat.com 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 CCA0943B38; Wed, 14 Feb 2024 17:37:22 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4FCE942FAB; Wed, 14 Feb 2024 17:36:22 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id D689942D0B for ; Wed, 14 Feb 2024 17:36:07 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 8638F20B200C; Wed, 14 Feb 2024 08:36:06 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 8638F20B200C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1707928566; bh=fv+sbHey/dTQSgZpiVeEbJy4B07HKwkASiye7sqrgrA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mc74J1alrupisz8+LK9Hmd1++Fm86zBg6cUmSJ/N9v0vEy5R616oy87pnlnl7dhYA qxfTmakFOUxwSz7se9TCPGj+rwyFp7/rOWpNdsBFwEVRO6+9TkxgTyma9tY6NVLdC3 kblYWSuMZK/FJNQC3+75gmCxZHYqEaV3CeKngOX8= From: Tyler Retzlaff To: dev@dpdk.org Cc: Andrew Rybchenko , Bruce Richardson , Chengwen Feng , Cristian Dumitrescu , David Christensen , David Hunt , Ferruh Yigit , Honnappa Nagarahalli , Jasvinder Singh , Jerin Jacob , Kevin Laatz , Konstantin Ananyev , Min Zhou , Ruifeng Wang , Sameh Gobriel , Stanislaw Kardach , Thomas Monjalon , Vladimir Medvedkin , Yipeng Wang , Tyler Retzlaff Subject: [PATCH v4 12/39] dmadev: use C11 alignas Date: Wed, 14 Feb 2024 08:35:37 -0800 Message-Id: <1707928564-28796-13-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1707928564-28796-1-git-send-email-roretzla@linux.microsoft.com> References: <1707873986-29352-1-git-send-email-roretzla@linux.microsoft.com> <1707928564-28796-1-git-send-email-roretzla@linux.microsoft.com> MIME-Version: 1.0 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 * Move __rte_aligned from the end of {struct,union} definitions to be between {struct,union} and tag. The placement between {struct,union} and the tag allows the desired alignment to be imparted on the type regardless of the toolchain being used for all of GCC, LLVM, MSVC compilers building both C and C++. * Replace use of __rte_aligned(a) on variables/fields with alignas(a). Signed-off-by: Tyler Retzlaff Acked-by: Morten Brørup Acked-by: Chengwen Feng --- lib/dmadev/rte_dmadev_core.h | 4 ++-- lib/dmadev/rte_dmadev_pmd.h | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/dmadev/rte_dmadev_core.h b/lib/dmadev/rte_dmadev_core.h index 0647856..1ba2c1f 100644 --- a/lib/dmadev/rte_dmadev_core.h +++ b/lib/dmadev/rte_dmadev_core.h @@ -61,7 +61,7 @@ typedef uint16_t (*rte_dma_completed_status_t)(void *dev_private, * The 'dev_private' field was placed in the first cache line to optimize * performance because the PMD mainly depends on this field. */ -struct rte_dma_fp_object { +struct __rte_aligned(128) rte_dma_fp_object { /** PMD-specific private data. The driver should copy * rte_dma_dev.data->dev_private to this field during initialization. */ @@ -73,7 +73,7 @@ struct rte_dma_fp_object { rte_dma_completed_t completed; rte_dma_completed_status_t completed_status; rte_dma_burst_capacity_t burst_capacity; -} __rte_aligned(128); +}; extern struct rte_dma_fp_object *rte_dma_fp_objs; diff --git a/lib/dmadev/rte_dmadev_pmd.h b/lib/dmadev/rte_dmadev_pmd.h index 7f354f6..5872908 100644 --- a/lib/dmadev/rte_dmadev_pmd.h +++ b/lib/dmadev/rte_dmadev_pmd.h @@ -94,7 +94,7 @@ struct rte_dma_dev_ops { * * @see struct rte_dma_dev::data */ -struct rte_dma_dev_data { +struct __rte_cache_aligned rte_dma_dev_data { char dev_name[RTE_DEV_NAME_MAX_LEN]; /**< Unique identifier name */ int16_t dev_id; /**< Device [external] identifier. */ int16_t numa_node; /**< Local NUMA memory ID. -1 if unknown. */ @@ -103,7 +103,7 @@ struct rte_dma_dev_data { __extension__ uint8_t dev_started : 1; /**< Device state: STARTED(1)/STOPPED(0). */ uint64_t reserved[2]; /**< Reserved for future fields */ -} __rte_cache_aligned; +}; /** * Possible states of a DMA device. @@ -122,7 +122,7 @@ enum rte_dma_dev_state { * @internal * The generic data structure associated with each DMA device. */ -struct rte_dma_dev { +struct __rte_cache_aligned rte_dma_dev { /** Device info which supplied during device initialization. */ struct rte_device *device; struct rte_dma_dev_data *data; /**< Pointer to shared device data. */ @@ -132,7 +132,7 @@ struct rte_dma_dev { const struct rte_dma_dev_ops *dev_ops; enum rte_dma_dev_state state; /**< Flag indicating the device state. */ uint64_t reserved[2]; /**< Reserved for future fields. */ -} __rte_cache_aligned; +}; /** * @internal From patchwork Wed Feb 14 16:35:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 136766 X-Patchwork-Delegate: david.marchand@redhat.com 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 E7EB143B38; Wed, 14 Feb 2024 17:37:34 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8143E42FF5; Wed, 14 Feb 2024 17:36:24 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id D7ACA42D9D for ; Wed, 14 Feb 2024 17:36:07 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 94CAA20B200D; Wed, 14 Feb 2024 08:36:06 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 94CAA20B200D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1707928566; bh=o4S3ALA1kOodLv97PW+baZ6fu3Afhd5kqhb6CscOeLA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QHxK15nAu2fRg2OV/pwrtmbw2YPk8we0aAhT/O1uHBLT7lw5z0nPWcDEpLy8KBSeN cx4BCqQYNm2PAA6gEshCoYW8ifEdlktivdDYByV2Ao6jt2XNGoPnMV7creeT5yKs3r IBMCcIsLndhOM+qkJzQC/WW67PUG4XzDgfHoXxgE= From: Tyler Retzlaff To: dev@dpdk.org Cc: Andrew Rybchenko , Bruce Richardson , Chengwen Feng , Cristian Dumitrescu , David Christensen , David Hunt , Ferruh Yigit , Honnappa Nagarahalli , Jasvinder Singh , Jerin Jacob , Kevin Laatz , Konstantin Ananyev , Min Zhou , Ruifeng Wang , Sameh Gobriel , Stanislaw Kardach , Thomas Monjalon , Vladimir Medvedkin , Yipeng Wang , Tyler Retzlaff Subject: [PATCH v4 13/39] distributor: use C11 alignas Date: Wed, 14 Feb 2024 08:35:38 -0800 Message-Id: <1707928564-28796-14-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1707928564-28796-1-git-send-email-roretzla@linux.microsoft.com> References: <1707873986-29352-1-git-send-email-roretzla@linux.microsoft.com> <1707928564-28796-1-git-send-email-roretzla@linux.microsoft.com> MIME-Version: 1.0 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 * Move __rte_aligned from the end of {struct,union} definitions to be between {struct,union} and tag. The placement between {struct,union} and the tag allows the desired alignment to be imparted on the type regardless of the toolchain being used for all of GCC, LLVM, MSVC compilers building both C and C++. * Replace use of __rte_aligned(a) on variables/fields with alignas(a). Signed-off-by: Tyler Retzlaff Acked-by: Morten Brørup --- lib/distributor/distributor_private.h | 34 ++++++++++++++++++---------------- lib/distributor/rte_distributor.c | 5 +++-- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/lib/distributor/distributor_private.h b/lib/distributor/distributor_private.h index dfeb9b5..07c2c05 100644 --- a/lib/distributor/distributor_private.h +++ b/lib/distributor/distributor_private.h @@ -5,6 +5,8 @@ #ifndef _DIST_PRIV_H_ #define _DIST_PRIV_H_ +#include + /** * @file * RTE distributor @@ -51,10 +53,10 @@ * the next cache line to worker 0, we pad this out to three cache lines. * Only 64-bits of the memory is actually used though. */ -union rte_distributor_buffer_single { +union __rte_cache_aligned rte_distributor_buffer_single { volatile RTE_ATOMIC(int64_t) bufptr64; char pad[RTE_CACHE_LINE_SIZE*3]; -} __rte_cache_aligned; +}; /* * Transfer up to 8 mbufs at a time to/from workers, and @@ -62,12 +64,12 @@ */ #define RTE_DIST_BURST_SIZE 8 -struct rte_distributor_backlog { +struct __rte_cache_aligned rte_distributor_backlog { unsigned int start; unsigned int count; - int64_t pkts[RTE_DIST_BURST_SIZE] __rte_cache_aligned; + alignas(RTE_CACHE_LINE_SIZE) int64_t pkts[RTE_DIST_BURST_SIZE]; uint16_t *tags; /* will point to second cacheline of inflights */ -} __rte_cache_aligned; +}; struct rte_distributor_returned_pkts { @@ -113,17 +115,17 @@ enum rte_distributor_match_function { * There is a separate cacheline for returns in the burst API. */ struct rte_distributor_buffer { - volatile RTE_ATOMIC(int64_t) bufptr64[RTE_DIST_BURST_SIZE] - __rte_cache_aligned; /* <= outgoing to worker */ + volatile alignas(RTE_CACHE_LINE_SIZE) RTE_ATOMIC(int64_t) bufptr64[RTE_DIST_BURST_SIZE]; + /* <= outgoing to worker */ - int64_t pad1 __rte_cache_aligned; /* <= one cache line */ + alignas(RTE_CACHE_LINE_SIZE) int64_t pad1; /* <= one cache line */ - volatile RTE_ATOMIC(int64_t) retptr64[RTE_DIST_BURST_SIZE] - __rte_cache_aligned; /* <= incoming from worker */ + volatile alignas(RTE_CACHE_LINE_SIZE) RTE_ATOMIC(int64_t) retptr64[RTE_DIST_BURST_SIZE]; + /* <= incoming from worker */ - int64_t pad2 __rte_cache_aligned; /* <= one cache line */ + alignas(RTE_CACHE_LINE_SIZE) int64_t pad2; /* <= one cache line */ - int count __rte_cache_aligned; /* <= number of current mbufs */ + alignas(RTE_CACHE_LINE_SIZE) int count; /* <= number of current mbufs */ }; struct rte_distributor { @@ -138,11 +140,11 @@ struct rte_distributor { * on the worker core. Second cache line are the backlog * that are going to go to the worker core. */ - uint16_t in_flight_tags[RTE_DISTRIB_MAX_WORKERS][RTE_DIST_BURST_SIZE*2] - __rte_cache_aligned; + alignas(RTE_CACHE_LINE_SIZE) uint16_t + in_flight_tags[RTE_DISTRIB_MAX_WORKERS][RTE_DIST_BURST_SIZE*2]; - struct rte_distributor_backlog backlog[RTE_DISTRIB_MAX_WORKERS] - __rte_cache_aligned; + alignas(RTE_CACHE_LINE_SIZE) struct rte_distributor_backlog + backlog[RTE_DISTRIB_MAX_WORKERS]; struct rte_distributor_buffer bufs[RTE_DISTRIB_MAX_WORKERS]; diff --git a/lib/distributor/rte_distributor.c b/lib/distributor/rte_distributor.c index 2ecb95c..b901a4e 100644 --- a/lib/distributor/rte_distributor.c +++ b/lib/distributor/rte_distributor.c @@ -2,6 +2,7 @@ * Copyright(c) 2017 Intel Corporation */ +#include #include #include #include @@ -447,7 +448,7 @@ struct rte_mbuf *next_mb = NULL; int64_t next_value = 0; uint16_t new_tag = 0; - uint16_t flows[RTE_DIST_BURST_SIZE] __rte_cache_aligned; + alignas(RTE_CACHE_LINE_SIZE) uint16_t flows[RTE_DIST_BURST_SIZE]; unsigned int i, j, w, wid, matching_required; if (d->alg_type == RTE_DIST_ALG_SINGLE) { @@ -477,7 +478,7 @@ return 0; while (next_idx < num_mbufs) { - uint16_t matches[RTE_DIST_BURST_SIZE] __rte_aligned(128); + alignas(128) uint16_t matches[RTE_DIST_BURST_SIZE]; unsigned int pkts; if ((num_mbufs - next_idx) < RTE_DIST_BURST_SIZE) From patchwork Wed Feb 14 16:35:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 136767 X-Patchwork-Delegate: david.marchand@redhat.com 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 632DF43B38; Wed, 14 Feb 2024 17:37:41 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A5A4E4325E; Wed, 14 Feb 2024 17:36:25 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id DCB3A42DFD for ; Wed, 14 Feb 2024 17:36:07 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id A3A9720B200E; Wed, 14 Feb 2024 08:36:06 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com A3A9720B200E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1707928566; bh=TRxpbGRPjR3QtahLQOV6fLGFKVnO/NtBduafNfDZnAM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RabrZOrDswTG1SDjC2FpLACIEKzxmu14o5q9SN9g1CnIJhG8aj39D02xeYzioplhl vm3HfwIr2xLFXpQ9nwzc0D3HW3hm66//xN4BIgOKFgWn/fBSe5WSeBB+zdLQljWC43 IhYA0cZwapW8CvoZduO5JK5VBuqKwpIsSTy+pSvo= From: Tyler Retzlaff To: dev@dpdk.org Cc: Andrew Rybchenko , Bruce Richardson , Chengwen Feng , Cristian Dumitrescu , David Christensen , David Hunt , Ferruh Yigit , Honnappa Nagarahalli , Jasvinder Singh , Jerin Jacob , Kevin Laatz , Konstantin Ananyev , Min Zhou , Ruifeng Wang , Sameh Gobriel , Stanislaw Kardach , Thomas Monjalon , Vladimir Medvedkin , Yipeng Wang , Tyler Retzlaff Subject: [PATCH v4 14/39] acl: use C11 alignas Date: Wed, 14 Feb 2024 08:35:39 -0800 Message-Id: <1707928564-28796-15-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1707928564-28796-1-git-send-email-roretzla@linux.microsoft.com> References: <1707873986-29352-1-git-send-email-roretzla@linux.microsoft.com> <1707928564-28796-1-git-send-email-roretzla@linux.microsoft.com> MIME-Version: 1.0 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 * Move __rte_aligned from the end of {struct,union} definitions to be between {struct,union} and tag. The placement between {struct,union} and the tag allows the desired alignment to be imparted on the type regardless of the toolchain being used for all of GCC, LLVM, MSVC compilers building both C and C++. * Replace use of __rte_aligned(a) on variables/fields with alignas(a). Signed-off-by: Tyler Retzlaff Acked-by: Morten Brørup --- lib/acl/acl_run.h | 4 ++-- lib/acl/acl_run_altivec.h | 6 ++++-- lib/acl/acl_run_neon.h | 6 ++++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/acl/acl_run.h b/lib/acl/acl_run.h index 7d215de..7f09241 100644 --- a/lib/acl/acl_run.h +++ b/lib/acl/acl_run.h @@ -55,12 +55,12 @@ struct acl_flow_data { * Structure to maintain running results for * a single packet (up to 4 tries). */ -struct completion { +struct __rte_aligned(XMM_SIZE) completion { uint32_t *results; /* running results. */ int32_t priority[RTE_ACL_MAX_CATEGORIES]; /* running priorities. */ uint32_t count; /* num of remaining tries */ /* true for allocated struct */ -} __rte_aligned(XMM_SIZE); +}; /* * One parms structure for each slot in the search engine. diff --git a/lib/acl/acl_run_altivec.h b/lib/acl/acl_run_altivec.h index 3c30466..2d398ff 100644 --- a/lib/acl/acl_run_altivec.h +++ b/lib/acl/acl_run_altivec.h @@ -3,15 +3,17 @@ * Copyright (C) IBM Corporation 2016. */ +#include + #include "acl_run.h" #include "acl_vect.h" -struct _altivec_acl_const { +alignas(RTE_CACHE_LINE_SIZE) struct _altivec_acl_const { rte_xmm_t xmm_shuffle_input; rte_xmm_t xmm_index_mask; rte_xmm_t xmm_ones_16; rte_xmm_t range_base; -} altivec_acl_const __rte_cache_aligned = { +} altivec_acl_const = { { .u32 = {0x00000000, 0x04040404, 0x08080808, 0x0c0c0c0c} }, diff --git a/lib/acl/acl_run_neon.h b/lib/acl/acl_run_neon.h index 69d1b6d..63074f8 100644 --- a/lib/acl/acl_run_neon.h +++ b/lib/acl/acl_run_neon.h @@ -2,14 +2,16 @@ * Copyright(c) 2015 Cavium, Inc */ +#include + #include "acl_run.h" #include "acl_vect.h" -struct _neon_acl_const { +alignas(RTE_CACHE_LINE_SIZE) struct _neon_acl_const { rte_xmm_t xmm_shuffle_input; rte_xmm_t xmm_index_mask; rte_xmm_t range_base; -} neon_acl_const __rte_cache_aligned = { +} neon_acl_const = { { .u32 = {0x00000000, 0x04040404, 0x08080808, 0x0c0c0c0c} }, From patchwork Wed Feb 14 16:35:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 136771 X-Patchwork-Delegate: david.marchand@redhat.com 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 94E6243B38; Wed, 14 Feb 2024 17:38:05 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4361C432C8; Wed, 14 Feb 2024 17:36:30 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 19F44427DB for ; Wed, 14 Feb 2024 17:36:08 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id B2ED920B200F; Wed, 14 Feb 2024 08:36:06 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com B2ED920B200F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1707928566; bh=f2+7LaddPrlEKgP1XbpXgSCD3znULx7iwMKvg7y2HTc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=romeDvXbGw9JA0PUfpLHiLfb1QCofMao35Y/e2qbUuulsKOVv5zUKFRp5GDtUjIgF pYihQgjRqn64wkBSkoBJMgUSbzh96JBhZbnGZGzu3gLp4wvJ88rD+RrmMX9FjybwoU v3mmmvTbjbXA5+hsMvhbUL8tYTBXtQAvKvPUKzac= From: Tyler Retzlaff To: dev@dpdk.org Cc: Andrew Rybchenko , Bruce Richardson , Chengwen Feng , Cristian Dumitrescu , David Christensen , David Hunt , Ferruh Yigit , Honnappa Nagarahalli , Jasvinder Singh , Jerin Jacob , Kevin Laatz , Konstantin Ananyev , Min Zhou , Ruifeng Wang , Sameh Gobriel , Stanislaw Kardach , Thomas Monjalon , Vladimir Medvedkin , Yipeng Wang , Tyler Retzlaff Subject: [PATCH v4 15/39] vhost: use C11 alignas Date: Wed, 14 Feb 2024 08:35:40 -0800 Message-Id: <1707928564-28796-16-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1707928564-28796-1-git-send-email-roretzla@linux.microsoft.com> References: <1707873986-29352-1-git-send-email-roretzla@linux.microsoft.com> <1707928564-28796-1-git-send-email-roretzla@linux.microsoft.com> MIME-Version: 1.0 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 * Move __rte_aligned from the end of {struct,union} definitions to be between {struct,union} and tag. The placement between {struct,union} and the tag allows the desired alignment to be imparted on the type regardless of the toolchain being used for all of GCC, LLVM, MSVC compilers building both C and C++. * Replace use of __rte_aligned(a) on variables/fields with alignas(a). Signed-off-by: Tyler Retzlaff Acked-by: Morten Brørup Reviewed-by: Maxime Coquelin --- lib/vhost/vhost.h | 8 ++++---- lib/vhost/vhost_crypto.c | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/vhost/vhost.h b/lib/vhost/vhost.h index 0b13374..4d11f56 100644 --- a/lib/vhost/vhost.h +++ b/lib/vhost/vhost.h @@ -271,7 +271,7 @@ struct vhost_async { /** * Structure contains variables relevant to RX/TX virtqueues. */ -struct vhost_virtqueue { +struct __rte_cache_aligned vhost_virtqueue { union { struct vring_desc *desc; struct vring_packed_desc *desc_packed; @@ -349,7 +349,7 @@ struct vhost_virtqueue { struct virtqueue_stats stats; RTE_ATOMIC(bool) irq_pending; -} __rte_cache_aligned; +}; /* Virtio device status as per Virtio specification */ #define VIRTIO_DEVICE_STATUS_RESET 0x00 @@ -477,7 +477,7 @@ struct inflight_mem_info { * Device structure contains all configuration information relating * to the device. */ -struct virtio_net { +struct __rte_cache_aligned virtio_net { /* Frontend (QEMU) memory and memory region information */ struct rte_vhost_memory *mem; uint64_t features; @@ -536,7 +536,7 @@ struct virtio_net { struct rte_vhost_user_extern_ops extern_ops; struct vhost_backend_ops *backend_ops; -} __rte_cache_aligned; +}; static inline void vq_assert_lock__(struct virtio_net *dev, struct vhost_virtqueue *vq, const char *func) diff --git a/lib/vhost/vhost_crypto.c b/lib/vhost/vhost_crypto.c index 3704fbb..eb4a158 100644 --- a/lib/vhost/vhost_crypto.c +++ b/lib/vhost/vhost_crypto.c @@ -190,7 +190,7 @@ static int get_iv_len(enum rte_crypto_cipher_algorithm algo) * one DPDK crypto device that deals with all crypto workloads. It is declared * here and defined in vhost_crypto.c */ -struct vhost_crypto { +struct __rte_cache_aligned vhost_crypto { /** Used to lookup DPDK Cryptodev Session based on VIRTIO crypto * session ID. */ @@ -213,7 +213,7 @@ struct vhost_crypto { struct virtio_net *dev; uint8_t option; -} __rte_cache_aligned; +}; struct vhost_crypto_writeback_data { uint8_t *src; From patchwork Wed Feb 14 16:35:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 136775 X-Patchwork-Delegate: david.marchand@redhat.com 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 D16E043B38; Wed, 14 Feb 2024 17:38:29 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C7E464331E; Wed, 14 Feb 2024 17:36:34 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 6DAE142E68 for ; Wed, 14 Feb 2024 17:36:08 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id C192620B2010; Wed, 14 Feb 2024 08:36:06 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com C192620B2010 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1707928566; bh=Cfhj6S1VEiD53ik/xb+8mfqqZiH6tyxgOz3U9P4+QtI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P1OlIFUQ2s3ECfHdWrnHeov1pUH523EVak7sURh2MWJR6helWif2R897VfS6hYYUQ MWfh9bfXjWGinR6/Wu8mF0EQwXbkUrr+7cje1FIXLH6jHeYIgWeRPrnUMRn9Qm4ym0 WHudToH/GUMdDSPl65wCIlMh1ansU/L0W9IrNaUw= From: Tyler Retzlaff To: dev@dpdk.org Cc: Andrew Rybchenko , Bruce Richardson , Chengwen Feng , Cristian Dumitrescu , David Christensen , David Hunt , Ferruh Yigit , Honnappa Nagarahalli , Jasvinder Singh , Jerin Jacob , Kevin Laatz , Konstantin Ananyev , Min Zhou , Ruifeng Wang , Sameh Gobriel , Stanislaw Kardach , Thomas Monjalon , Vladimir Medvedkin , Yipeng Wang , Tyler Retzlaff Subject: [PATCH v4 16/39] timer: use C11 alignas Date: Wed, 14 Feb 2024 08:35:41 -0800 Message-Id: <1707928564-28796-17-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1707928564-28796-1-git-send-email-roretzla@linux.microsoft.com> References: <1707873986-29352-1-git-send-email-roretzla@linux.microsoft.com> <1707928564-28796-1-git-send-email-roretzla@linux.microsoft.com> MIME-Version: 1.0 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 * Move __rte_aligned from the end of {struct,union} definitions to be between {struct,union} and tag. The placement between {struct,union} and the tag allows the desired alignment to be imparted on the type regardless of the toolchain being used for all of GCC, LLVM, MSVC compilers building both C and C++. * Replace use of __rte_aligned(a) on variables/fields with alignas(a). Signed-off-by: Tyler Retzlaff Acked-by: Morten Brørup --- lib/timer/rte_timer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/timer/rte_timer.c b/lib/timer/rte_timer.c index 53ed221..bb8b6a6 100644 --- a/lib/timer/rte_timer.c +++ b/lib/timer/rte_timer.c @@ -24,7 +24,7 @@ /** * Per-lcore info for timers. */ -struct priv_timer { +struct __rte_cache_aligned priv_timer { struct rte_timer pending_head; /**< dummy timer instance to head up list */ rte_spinlock_t list_lock; /**< lock to protect list access */ @@ -44,7 +44,7 @@ struct priv_timer { /** per-lcore statistics */ struct rte_timer_debug_stats stats; #endif -} __rte_cache_aligned; +}; #define FL_ALLOCATED (1 << 0) struct rte_timer_data { From patchwork Wed Feb 14 16:35:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 136768 X-Patchwork-Delegate: david.marchand@redhat.com 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 997B143B38; Wed, 14 Feb 2024 17:37:47 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D5C4043267; Wed, 14 Feb 2024 17:36:26 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 2ADB842E50 for ; Wed, 14 Feb 2024 17:36:08 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id D055820B2011; Wed, 14 Feb 2024 08:36:06 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com D055820B2011 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1707928566; bh=TzxpFKwK74YUZWNtfCzW15WK1AvAimcUTlulpr91gys=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WI/ems6pxb5AMjlqBZuOfHrY/dYOlhWrTzNONlK9mNGJseL/dAjWMlRDB+I5fBgim jHkRzzSiyfM3WCH7p53JSPskxQ4Wts42netl+3ptjQIfiDx/W09uuAlkb0C9zWCpYx iDj4cj6Sntt4iIFGpxKP6DFf6bYmUSLTFsYMjDM4= From: Tyler Retzlaff To: dev@dpdk.org Cc: Andrew Rybchenko , Bruce Richardson , Chengwen Feng , Cristian Dumitrescu , David Christensen , David Hunt , Ferruh Yigit , Honnappa Nagarahalli , Jasvinder Singh , Jerin Jacob , Kevin Laatz , Konstantin Ananyev , Min Zhou , Ruifeng Wang , Sameh Gobriel , Stanislaw Kardach , Thomas Monjalon , Vladimir Medvedkin , Yipeng Wang , Tyler Retzlaff Subject: [PATCH v4 17/39] table: use C11 alignas Date: Wed, 14 Feb 2024 08:35:42 -0800 Message-Id: <1707928564-28796-18-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1707928564-28796-1-git-send-email-roretzla@linux.microsoft.com> References: <1707873986-29352-1-git-send-email-roretzla@linux.microsoft.com> <1707928564-28796-1-git-send-email-roretzla@linux.microsoft.com> MIME-Version: 1.0 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 * Move __rte_aligned from the end of {struct,union} definitions to be between {struct,union} and tag. The placement between {struct,union} and the tag allows the desired alignment to be imparted on the type regardless of the toolchain being used for all of GCC, LLVM, MSVC compilers building both C and C++. * Replace use of __rte_aligned(a) on variables/fields with alignas(a). Signed-off-by: Tyler Retzlaff Acked-by: Morten Brørup --- lib/table/rte_swx_table_learner.c | 4 ++-- lib/table/rte_table_acl.c | 3 ++- lib/table/rte_table_array.c | 7 ++++--- lib/table/rte_table_hash_cuckoo.c | 4 +++- lib/table/rte_table_hash_ext.c | 3 ++- lib/table/rte_table_hash_key16.c | 4 +++- lib/table/rte_table_hash_key32.c | 4 +++- lib/table/rte_table_hash_key8.c | 4 +++- lib/table/rte_table_hash_lru.c | 3 ++- lib/table/rte_table_lpm.c | 3 ++- lib/table/rte_table_lpm_ipv6.c | 3 ++- 11 files changed, 28 insertions(+), 14 deletions(-) diff --git a/lib/table/rte_swx_table_learner.c b/lib/table/rte_swx_table_learner.c index 2b5e6bd..55a3645 100644 --- a/lib/table/rte_swx_table_learner.c +++ b/lib/table/rte_swx_table_learner.c @@ -145,13 +145,13 @@ struct table_params { size_t total_size; }; -struct table { +struct __rte_cache_aligned table { /* Table parameters. */ struct table_params params; /* Table buckets. */ uint8_t buckets[]; -} __rte_cache_aligned; +}; /* The timeout (in cycles) is stored in the table as a 32-bit value by truncating its least * significant 32 bits. Therefore, to make sure the time is always advancing when adding the timeout diff --git a/lib/table/rte_table_acl.c b/lib/table/rte_table_acl.c index 83411d2..2764cda 100644 --- a/lib/table/rte_table_acl.c +++ b/lib/table/rte_table_acl.c @@ -2,6 +2,7 @@ * Copyright(c) 2010-2014 Intel Corporation */ +#include #include #include @@ -47,7 +48,7 @@ struct rte_table_acl { uint8_t *acl_rule_memory; /* Memory to store the rules */ /* Memory to store the action table and stack of free entries */ - uint8_t memory[0] __rte_cache_aligned; + alignas(RTE_CACHE_LINE_SIZE) uint8_t memory[0]; }; diff --git a/lib/table/rte_table_array.c b/lib/table/rte_table_array.c index 80bc2a7..31a17d5 100644 --- a/lib/table/rte_table_array.c +++ b/lib/table/rte_table_array.c @@ -2,6 +2,7 @@ * Copyright(c) 2010-2014 Intel Corporation */ +#include #include #include @@ -27,7 +28,7 @@ #endif -struct rte_table_array { +struct __rte_cache_aligned rte_table_array { struct rte_table_stats stats; /* Input parameters */ @@ -39,8 +40,8 @@ struct rte_table_array { uint32_t entry_pos_mask; /* Internal table */ - uint8_t array[0] __rte_cache_aligned; -} __rte_cache_aligned; + alignas(RTE_CACHE_LINE_SIZE) uint8_t array[0]; +}; static void * rte_table_array_create(void *params, int socket_id, uint32_t entry_size) diff --git a/lib/table/rte_table_hash_cuckoo.c b/lib/table/rte_table_hash_cuckoo.c index 0f4900c..d3b60f3 100644 --- a/lib/table/rte_table_hash_cuckoo.c +++ b/lib/table/rte_table_hash_cuckoo.c @@ -1,6 +1,8 @@ /* SPDX-License-Identifier: BSD-3-Clause * Copyright(c) 2010-2017 Intel Corporation */ + +#include #include #include @@ -42,7 +44,7 @@ struct rte_table_hash { struct rte_hash *h_table; /* Lookup table */ - uint8_t memory[0] __rte_cache_aligned; + alignas(RTE_CACHE_LINE_SIZE) uint8_t memory[0]; }; static int diff --git a/lib/table/rte_table_hash_ext.c b/lib/table/rte_table_hash_ext.c index 2148d83..61e3c79 100644 --- a/lib/table/rte_table_hash_ext.c +++ b/lib/table/rte_table_hash_ext.c @@ -2,6 +2,7 @@ * Copyright(c) 2010-2017 Intel Corporation */ +#include #include #include @@ -99,7 +100,7 @@ struct rte_table_hash { uint32_t *bkt_ext_stack; /* Table memory */ - uint8_t memory[0] __rte_cache_aligned; + alignas(RTE_CACHE_LINE_SIZE) uint8_t memory[0]; }; static int diff --git a/lib/table/rte_table_hash_key16.c b/lib/table/rte_table_hash_key16.c index 7734aef..2af34a5 100644 --- a/lib/table/rte_table_hash_key16.c +++ b/lib/table/rte_table_hash_key16.c @@ -1,6 +1,8 @@ /* SPDX-License-Identifier: BSD-3-Clause * Copyright(c) 2010-2017 Intel Corporation */ + +#include #include #include @@ -83,7 +85,7 @@ struct rte_table_hash { uint32_t *stack; /* Lookup table */ - uint8_t memory[0] __rte_cache_aligned; + alignas(RTE_CACHE_LINE_SIZE) uint8_t memory[0]; }; static int diff --git a/lib/table/rte_table_hash_key32.c b/lib/table/rte_table_hash_key32.c index fcb4348..06e5cf4 100644 --- a/lib/table/rte_table_hash_key32.c +++ b/lib/table/rte_table_hash_key32.c @@ -1,6 +1,8 @@ /* SPDX-License-Identifier: BSD-3-Clause * Copyright(c) 2010-2017 Intel Corporation */ + +#include #include #include @@ -83,7 +85,7 @@ struct rte_table_hash { uint32_t *stack; /* Lookup table */ - uint8_t memory[0] __rte_cache_aligned; + alignas(RTE_CACHE_LINE_SIZE) uint8_t memory[0]; }; static int diff --git a/lib/table/rte_table_hash_key8.c b/lib/table/rte_table_hash_key8.c index bbe6562..2ab8e1b 100644 --- a/lib/table/rte_table_hash_key8.c +++ b/lib/table/rte_table_hash_key8.c @@ -1,6 +1,8 @@ /* SPDX-License-Identifier: BSD-3-Clause * Copyright(c) 2010-2017 Intel Corporation */ + +#include #include #include @@ -79,7 +81,7 @@ struct rte_table_hash { uint32_t *stack; /* Lookup table */ - uint8_t memory[0] __rte_cache_aligned; + alignas(RTE_CACHE_LINE_SIZE) uint8_t memory[0]; }; static int diff --git a/lib/table/rte_table_hash_lru.c b/lib/table/rte_table_hash_lru.c index cb4f329..8604a64 100644 --- a/lib/table/rte_table_hash_lru.c +++ b/lib/table/rte_table_hash_lru.c @@ -2,6 +2,7 @@ * Copyright(c) 2010-2017 Intel Corporation */ +#include #include #include @@ -76,7 +77,7 @@ struct rte_table_hash { uint32_t *key_stack; /* Table memory */ - uint8_t memory[0] __rte_cache_aligned; + alignas(RTE_CACHE_LINE_SIZE) uint8_t memory[0]; }; static int diff --git a/lib/table/rte_table_lpm.c b/lib/table/rte_table_lpm.c index b9cff25..978d7e5 100644 --- a/lib/table/rte_table_lpm.c +++ b/lib/table/rte_table_lpm.c @@ -2,6 +2,7 @@ * Copyright(c) 2010-2014 Intel Corporation */ +#include #include #include @@ -47,7 +48,7 @@ struct rte_table_lpm { /* Next Hop Table (NHT) */ uint32_t nht_users[RTE_TABLE_LPM_MAX_NEXT_HOPS]; - uint8_t nht[0] __rte_cache_aligned; + alignas(RTE_CACHE_LINE_SIZE) uint8_t nht[0]; }; static void * diff --git a/lib/table/rte_table_lpm_ipv6.c b/lib/table/rte_table_lpm_ipv6.c index e4e823a..1d54f83 100644 --- a/lib/table/rte_table_lpm_ipv6.c +++ b/lib/table/rte_table_lpm_ipv6.c @@ -2,6 +2,7 @@ * Copyright(c) 2010-2014 Intel Corporation */ +#include #include #include @@ -44,7 +45,7 @@ struct rte_table_lpm_ipv6 { /* Next Hop Table (NHT) */ uint32_t nht_users[RTE_TABLE_LPM_MAX_NEXT_HOPS]; - uint8_t nht[0] __rte_cache_aligned; + alignas(RTE_CACHE_LINE_SIZE) uint8_t nht[0]; }; static void * From patchwork Wed Feb 14 16:35:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 136765 X-Patchwork-Delegate: david.marchand@redhat.com 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 5AD4343B38; Wed, 14 Feb 2024 17:37:29 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5C9AC42FDB; Wed, 14 Feb 2024 17:36:23 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 2CD7C42E5A for ; Wed, 14 Feb 2024 17:36:08 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id DECC320B2012; Wed, 14 Feb 2024 08:36:06 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com DECC320B2012 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1707928566; bh=yWxccxg4FMSt0MaMFPA1mKi9pOWYGTEjjYom17+9jfw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NcEM/rofHPf4FWE3l+Mz/nhfbVVL98mL8pRCPCH8dmmm1wx4Xv6MqgvX5J36UxGnq kWEgXkdzfA+L+k38/b2I/5zTfolwO6E6M9n6K4fYg0/jbiUmvBoCB8Q5gokA+aBEFG 3EmPFcpQPN66UhJkAWMmloXtasQkcfUFEPR5Nvak= From: Tyler Retzlaff To: dev@dpdk.org Cc: Andrew Rybchenko , Bruce Richardson , Chengwen Feng , Cristian Dumitrescu , David Christensen , David Hunt , Ferruh Yigit , Honnappa Nagarahalli , Jasvinder Singh , Jerin Jacob , Kevin Laatz , Konstantin Ananyev , Min Zhou , Ruifeng Wang , Sameh Gobriel , Stanislaw Kardach , Thomas Monjalon , Vladimir Medvedkin , Yipeng Wang , Tyler Retzlaff Subject: [PATCH v4 18/39] reorder: use C11 alignas Date: Wed, 14 Feb 2024 08:35:43 -0800 Message-Id: <1707928564-28796-19-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1707928564-28796-1-git-send-email-roretzla@linux.microsoft.com> References: <1707873986-29352-1-git-send-email-roretzla@linux.microsoft.com> <1707928564-28796-1-git-send-email-roretzla@linux.microsoft.com> MIME-Version: 1.0 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 * Move __rte_aligned from the end of {struct,union} definitions to be between {struct,union} and tag. The placement between {struct,union} and the tag allows the desired alignment to be imparted on the type regardless of the toolchain being used for all of GCC, LLVM, MSVC compilers building both C and C++. * Replace use of __rte_aligned(a) on variables/fields with alignas(a). Signed-off-by: Tyler Retzlaff Acked-by: Morten Brørup --- lib/reorder/rte_reorder.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/reorder/rte_reorder.c b/lib/reorder/rte_reorder.c index c080b2c..ae97e1a 100644 --- a/lib/reorder/rte_reorder.c +++ b/lib/reorder/rte_reorder.c @@ -37,16 +37,16 @@ int rte_reorder_seqn_dynfield_offset = -1; /* A generic circular buffer */ -struct cir_buffer { +struct __rte_cache_aligned cir_buffer { unsigned int size; /**< Number of entries that can be stored */ unsigned int mask; /**< [buffer_size - 1]: used for wrap-around */ unsigned int head; /**< insertion point in buffer */ unsigned int tail; /**< extraction point in buffer */ struct rte_mbuf **entries; -} __rte_cache_aligned; +}; /* The reorder buffer data structure itself */ -struct rte_reorder_buffer { +struct __rte_cache_aligned rte_reorder_buffer { char name[RTE_REORDER_NAMESIZE]; uint32_t min_seqn; /**< Lowest seq. number that can be in the buffer */ unsigned int memsize; /**< memory area size of reorder buffer */ @@ -54,7 +54,7 @@ struct rte_reorder_buffer { struct cir_buffer ready_buf; /**< temp buffer for dequeued entries */ struct cir_buffer order_buf; /**< buffer used to reorder entries */ -} __rte_cache_aligned; +}; static void rte_reorder_free_mbufs(struct rte_reorder_buffer *b); From patchwork Wed Feb 14 16:35:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 136773 X-Patchwork-Delegate: david.marchand@redhat.com 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 3D3E043B38; Wed, 14 Feb 2024 17:38:18 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 95E1D432EE; Wed, 14 Feb 2024 17:36:32 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 2C04B42E54 for ; Wed, 14 Feb 2024 17:36:08 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id ED0B720B2013; Wed, 14 Feb 2024 08:36:06 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com ED0B720B2013 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1707928566; bh=9wR3tPM1AiZwaytKRffZNJuBBhs2Aqk+b1xvFyF2H/c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p9ciAp+l+eTc57/JeS2Et++HKBkZffMtZo9HICC2ZRIcJSBzEsOIRn7KF7m62/0Nn Q5iSudDBJgm64rgpS9sOX2mm+THH+PUtTuiD+z535RcwDsh9krcisOtFtmEB9sDBMJ tnuTw0v6zJUj8me3Kf7+c4MfWuJ1YaoYV99Mz8S0= From: Tyler Retzlaff To: dev@dpdk.org Cc: Andrew Rybchenko , Bruce Richardson , Chengwen Feng , Cristian Dumitrescu , David Christensen , David Hunt , Ferruh Yigit , Honnappa Nagarahalli , Jasvinder Singh , Jerin Jacob , Kevin Laatz , Konstantin Ananyev , Min Zhou , Ruifeng Wang , Sameh Gobriel , Stanislaw Kardach , Thomas Monjalon , Vladimir Medvedkin , Yipeng Wang , Tyler Retzlaff Subject: [PATCH v4 19/39] regexdev: use C11 alignas Date: Wed, 14 Feb 2024 08:35:44 -0800 Message-Id: <1707928564-28796-20-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1707928564-28796-1-git-send-email-roretzla@linux.microsoft.com> References: <1707873986-29352-1-git-send-email-roretzla@linux.microsoft.com> <1707928564-28796-1-git-send-email-roretzla@linux.microsoft.com> MIME-Version: 1.0 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 * Move __rte_aligned from the end of {struct,union} definitions to be between {struct,union} and tag. The placement between {struct,union} and the tag allows the desired alignment to be imparted on the type regardless of the toolchain being used for all of GCC, LLVM, MSVC compilers building both C and C++. * Replace use of __rte_aligned(a) on variables/fields with alignas(a). Signed-off-by: Tyler Retzlaff Acked-by: Morten Brørup --- lib/regexdev/rte_regexdev_core.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/regexdev/rte_regexdev_core.h b/lib/regexdev/rte_regexdev_core.h index 15ba712..32eef6e 100644 --- a/lib/regexdev/rte_regexdev_core.h +++ b/lib/regexdev/rte_regexdev_core.h @@ -144,13 +144,13 @@ enum rte_regexdev_state { * This structure is safe to place in shared memory to be common among different * processes in a multi-process configuration. */ -struct rte_regexdev_data { +struct __rte_cache_aligned rte_regexdev_data { void *dev_private; /**< PMD-specific private data. */ char dev_name[RTE_REGEXDEV_NAME_MAX_LEN]; /**< Unique identifier name */ uint16_t dev_id; /**< Device [external] identifier. */ struct rte_regexdev_config dev_conf; /**< RegEx configuration. */ uint8_t dev_started : 1; /**< Device started to work. */ -} __rte_cache_aligned; +}; /** * @internal @@ -162,7 +162,7 @@ struct rte_regexdev_data { * memory. This split allows the function pointer and driver data to be per- * process, while the actual configuration data for the device is shared. */ -struct rte_regexdev { +struct __rte_cache_aligned rte_regexdev { regexdev_enqueue_t enqueue; regexdev_dequeue_t dequeue; const struct rte_regexdev_ops *dev_ops; @@ -170,7 +170,7 @@ struct rte_regexdev { struct rte_device *device; /**< Backing device */ enum rte_regexdev_state state; /**< The device state. */ struct rte_regexdev_data *data; /**< Pointer to device data. */ -} __rte_cache_aligned; +}; /** * @internal From patchwork Wed Feb 14 16:35:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 136790 X-Patchwork-Delegate: david.marchand@redhat.com 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 6F08643B38; Wed, 14 Feb 2024 17:39:54 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F0A0243388; Wed, 14 Feb 2024 17:36:51 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 81D4942E71 for ; Wed, 14 Feb 2024 17:36:08 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 0769020B2014; Wed, 14 Feb 2024 08:36:06 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 0769020B2014 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1707928567; bh=191Ffqdb04/ggn7kRQZUau8YP39u0GUjH6uGVmR3S7s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=q+S6QymGougUOEhyJKvLW01gHeoAs7lQTt8C9vkgSQuWZ9pCRMGemYMYQbgjOgZJj qE6LmjPHc3Qo52LU7kibgqB+/3JMmQzivpbjcG+5Ca4qyJgPOj3mtK2xE6dhI+3qq/ r2UiBi/9fJXnwR46Bu9snVgDhYkFQd/tevWXW/bg= From: Tyler Retzlaff To: dev@dpdk.org Cc: Andrew Rybchenko , Bruce Richardson , Chengwen Feng , Cristian Dumitrescu , David Christensen , David Hunt , Ferruh Yigit , Honnappa Nagarahalli , Jasvinder Singh , Jerin Jacob , Kevin Laatz , Konstantin Ananyev , Min Zhou , Ruifeng Wang , Sameh Gobriel , Stanislaw Kardach , Thomas Monjalon , Vladimir Medvedkin , Yipeng Wang , Tyler Retzlaff Subject: [PATCH v4 20/39] rcu: use C11 alignas Date: Wed, 14 Feb 2024 08:35:45 -0800 Message-Id: <1707928564-28796-21-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1707928564-28796-1-git-send-email-roretzla@linux.microsoft.com> References: <1707873986-29352-1-git-send-email-roretzla@linux.microsoft.com> <1707928564-28796-1-git-send-email-roretzla@linux.microsoft.com> MIME-Version: 1.0 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 * Move __rte_aligned from the end of {struct,union} definitions to be between {struct,union} and tag. The placement between {struct,union} and the tag allows the desired alignment to be imparted on the type regardless of the toolchain being used for all of GCC, LLVM, MSVC compilers building both C and C++. * Replace use of __rte_aligned(a) on variables/fields with alignas(a). Signed-off-by: Tyler Retzlaff Acked-by: Morten Brørup --- lib/rcu/rte_rcu_qsbr.h | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/rcu/rte_rcu_qsbr.h b/lib/rcu/rte_rcu_qsbr.h index 23c9f89..f6e6ab3 100644 --- a/lib/rcu/rte_rcu_qsbr.h +++ b/lib/rcu/rte_rcu_qsbr.h @@ -21,6 +21,8 @@ * entered quiescent state. */ +#include + #ifdef __cplusplus extern "C" { #endif @@ -69,7 +71,7 @@ #define RTE_QSBR_THRID_INVALID 0xffffffff /* Worker thread counter */ -struct rte_rcu_qsbr_cnt { +struct __rte_cache_aligned rte_rcu_qsbr_cnt { RTE_ATOMIC(uint64_t) cnt; /**< Quiescent state counter. Value 0 indicates the thread is offline * 64b counter is used to avoid adding more code to address @@ -78,7 +80,7 @@ struct rte_rcu_qsbr_cnt { */ RTE_ATOMIC(uint32_t) lock_cnt; /**< Lock counter. Used when RTE_LIBRTE_RCU_DEBUG is enabled */ -} __rte_cache_aligned; +}; #define __RTE_QSBR_CNT_THR_OFFLINE 0 #define __RTE_QSBR_CNT_INIT 1 @@ -91,28 +93,28 @@ struct rte_rcu_qsbr_cnt { * 1) Quiescent state counter array * 2) Register thread ID array */ -struct rte_rcu_qsbr { - RTE_ATOMIC(uint64_t) token __rte_cache_aligned; +struct __rte_cache_aligned rte_rcu_qsbr { + alignas(RTE_CACHE_LINE_SIZE) RTE_ATOMIC(uint64_t) token; /**< Counter to allow for multiple concurrent quiescent state queries */ RTE_ATOMIC(uint64_t) acked_token; /**< Least token acked by all the threads in the last call to * rte_rcu_qsbr_check API. */ - uint32_t num_elems __rte_cache_aligned; + alignas(RTE_CACHE_LINE_SIZE) uint32_t num_elems; /**< Number of elements in the thread ID array */ RTE_ATOMIC(uint32_t) num_threads; /**< Number of threads currently using this QS variable */ uint32_t max_threads; /**< Maximum number of threads using this QS variable */ - struct rte_rcu_qsbr_cnt qsbr_cnt[0] __rte_cache_aligned; + alignas(RTE_CACHE_LINE_SIZE) struct rte_rcu_qsbr_cnt qsbr_cnt[0]; /**< Quiescent state counter array of 'max_threads' elements */ /**< Registered thread IDs are stored in a bitmap array, * after the quiescent state counter array. */ -} __rte_cache_aligned; +}; /** * Call back function called to free the resources. From patchwork Wed Feb 14 16:35:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 136787 X-Patchwork-Delegate: david.marchand@redhat.com 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 D195143B38; Wed, 14 Feb 2024 17:39:37 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AF56343378; Wed, 14 Feb 2024 17:36:48 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 8F1B042E84 for ; Wed, 14 Feb 2024 17:36:08 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 15CFA20B2015; Wed, 14 Feb 2024 08:36:06 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 15CFA20B2015 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1707928567; bh=D/mOOINdGm91vOc7HdiruNwFF5oebOqFShut9olXjM0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mwALF9GN8+vHiXE1kqrJsFP5zHSqTautX2OcjxEKVgp/KyRyK4H53bIw29/xHUvWG UN008gHljvkInMV3VVHyAnCL9hIGW5RXSbupcKIAQSs9JR4X/UTxOKgAW8A9+cIyG6 pdVuyVl8Z9w97/OCRE97bGpLpSBqm2RTb3Iyit9w= From: Tyler Retzlaff To: dev@dpdk.org Cc: Andrew Rybchenko , Bruce Richardson , Chengwen Feng , Cristian Dumitrescu , David Christensen , David Hunt , Ferruh Yigit , Honnappa Nagarahalli , Jasvinder Singh , Jerin Jacob , Kevin Laatz , Konstantin Ananyev , Min Zhou , Ruifeng Wang , Sameh Gobriel , Stanislaw Kardach , Thomas Monjalon , Vladimir Medvedkin , Yipeng Wang , Tyler Retzlaff Subject: [PATCH v4 21/39] power: use C11 alignas Date: Wed, 14 Feb 2024 08:35:46 -0800 Message-Id: <1707928564-28796-22-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1707928564-28796-1-git-send-email-roretzla@linux.microsoft.com> References: <1707873986-29352-1-git-send-email-roretzla@linux.microsoft.com> <1707928564-28796-1-git-send-email-roretzla@linux.microsoft.com> MIME-Version: 1.0 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 * Move __rte_aligned from the end of {struct,union} definitions to be between {struct,union} and tag. The placement between {struct,union} and the tag allows the desired alignment to be imparted on the type regardless of the toolchain being used for all of GCC, LLVM, MSVC compilers building both C and C++. * Replace use of __rte_aligned(a) on variables/fields with alignas(a). Signed-off-by: Tyler Retzlaff Acked-by: Morten Brørup --- lib/power/power_acpi_cpufreq.c | 4 ++-- lib/power/power_amd_pstate_cpufreq.c | 4 ++-- lib/power/power_cppc_cpufreq.c | 4 ++-- lib/power/power_intel_uncore.c | 4 ++-- lib/power/power_pstate_cpufreq.c | 4 ++-- lib/power/rte_power_pmd_mgmt.c | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/power/power_acpi_cpufreq.c b/lib/power/power_acpi_cpufreq.c index f8d978d..81996e1 100644 --- a/lib/power/power_acpi_cpufreq.c +++ b/lib/power/power_acpi_cpufreq.c @@ -41,7 +41,7 @@ enum power_state { /** * Power info per lcore. */ -struct acpi_power_info { +struct __rte_cache_aligned acpi_power_info { unsigned int lcore_id; /**< Logical core id */ uint32_t freqs[RTE_MAX_LCORE_FREQS]; /**< Frequency array */ uint32_t nb_freqs; /**< number of available freqs */ @@ -51,7 +51,7 @@ struct acpi_power_info { RTE_ATOMIC(uint32_t) state; /**< Power in use state */ uint16_t turbo_available; /**< Turbo Boost available */ uint16_t turbo_enable; /**< Turbo Boost enable/disable */ -} __rte_cache_aligned; +}; static struct acpi_power_info lcore_power_info[RTE_MAX_LCORE]; diff --git a/lib/power/power_amd_pstate_cpufreq.c b/lib/power/power_amd_pstate_cpufreq.c index 028f844..090a0d9 100644 --- a/lib/power/power_amd_pstate_cpufreq.c +++ b/lib/power/power_amd_pstate_cpufreq.c @@ -45,7 +45,7 @@ enum power_state { /** * Power info per lcore. */ -struct amd_pstate_power_info { +struct __rte_cache_aligned amd_pstate_power_info { uint32_t lcore_id; /**< Logical core id */ RTE_ATOMIC(uint32_t) state; /**< Power in use state */ FILE *f; /**< FD of scaling_setspeed */ @@ -58,7 +58,7 @@ struct amd_pstate_power_info { uint16_t turbo_enable; /**< Turbo Boost enable/disable */ uint32_t nb_freqs; /**< number of available freqs */ uint32_t freqs[RTE_MAX_LCORE_FREQS]; /**< Frequency array */ -} __rte_cache_aligned; +}; static struct amd_pstate_power_info lcore_power_info[RTE_MAX_LCORE]; diff --git a/lib/power/power_cppc_cpufreq.c b/lib/power/power_cppc_cpufreq.c index 3ddf39b..32aaacb 100644 --- a/lib/power/power_cppc_cpufreq.c +++ b/lib/power/power_cppc_cpufreq.c @@ -49,7 +49,7 @@ enum power_state { /** * Power info per lcore. */ -struct cppc_power_info { +struct __rte_cache_aligned cppc_power_info { unsigned int lcore_id; /**< Logical core id */ RTE_ATOMIC(uint32_t) state; /**< Power in use state */ FILE *f; /**< FD of scaling_setspeed */ @@ -61,7 +61,7 @@ struct cppc_power_info { uint16_t turbo_enable; /**< Turbo Boost enable/disable */ uint32_t nb_freqs; /**< number of available freqs */ uint32_t freqs[RTE_MAX_LCORE_FREQS]; /**< Frequency array */ -} __rte_cache_aligned; +}; static struct cppc_power_info lcore_power_info[RTE_MAX_LCORE]; diff --git a/lib/power/power_intel_uncore.c b/lib/power/power_intel_uncore.c index 3ce8fcc..9c152e4 100644 --- a/lib/power/power_intel_uncore.c +++ b/lib/power/power_intel_uncore.c @@ -29,7 +29,7 @@ "/sys/devices/system/cpu/intel_uncore_frequency/package_%02u_die_%02u/initial_min_freq_khz" -struct uncore_power_info { +struct __rte_cache_aligned uncore_power_info { unsigned int die; /* Core die id */ unsigned int pkg; /* Package id */ uint32_t freqs[MAX_UNCORE_FREQS]; /* Frequency array */ @@ -41,7 +41,7 @@ struct uncore_power_info { uint32_t org_max_freq; /* Original max freq of uncore */ uint32_t init_max_freq; /* System max uncore freq */ uint32_t init_min_freq; /* System min uncore freq */ -} __rte_cache_aligned; +}; static struct uncore_power_info uncore_info[RTE_MAX_NUMA_NODES][MAX_NUMA_DIE]; diff --git a/lib/power/power_pstate_cpufreq.c b/lib/power/power_pstate_cpufreq.c index 73138dc..2343121 100644 --- a/lib/power/power_pstate_cpufreq.c +++ b/lib/power/power_pstate_cpufreq.c @@ -49,7 +49,7 @@ enum power_state { POWER_UNKNOWN }; -struct pstate_power_info { +struct __rte_cache_aligned pstate_power_info { unsigned int lcore_id; /**< Logical core id */ uint32_t freqs[RTE_MAX_LCORE_FREQS]; /**< Frequency array */ uint32_t nb_freqs; /**< number of available freqs */ @@ -64,7 +64,7 @@ struct pstate_power_info { uint16_t turbo_available; /**< Turbo Boost available */ uint16_t turbo_enable; /**< Turbo Boost enable/disable */ uint16_t priority_core; /**< High Performance core */ -} __rte_cache_aligned; +}; static struct pstate_power_info lcore_power_info[RTE_MAX_LCORE]; diff --git a/lib/power/rte_power_pmd_mgmt.c b/lib/power/rte_power_pmd_mgmt.c index 591fc69..b1c18a5 100644 --- a/lib/power/rte_power_pmd_mgmt.c +++ b/lib/power/rte_power_pmd_mgmt.c @@ -55,7 +55,7 @@ struct queue_list_entry { const struct rte_eth_rxtx_callback *cb; }; -struct pmd_core_cfg { +struct __rte_cache_aligned pmd_core_cfg { TAILQ_HEAD(queue_list_head, queue_list_entry) head; /**< List of queues associated with this lcore */ size_t n_queues; @@ -68,7 +68,7 @@ struct pmd_core_cfg { /**< Number of queues ready to enter power optimized state */ uint64_t sleep_target; /**< Prevent a queue from triggering sleep multiple times */ -} __rte_cache_aligned; +}; static struct pmd_core_cfg lcore_cfgs[RTE_MAX_LCORE]; static inline bool From patchwork Wed Feb 14 16:35:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 136783 X-Patchwork-Delegate: david.marchand@redhat.com 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 28C6243B38; Wed, 14 Feb 2024 17:39:15 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3C04843365; Wed, 14 Feb 2024 17:36:44 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 9762842E8B for ; Wed, 14 Feb 2024 17:36:08 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 25B3520B2016; Wed, 14 Feb 2024 08:36:06 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 25B3520B2016 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1707928567; bh=rlaOixKbHe+iWZXEyL9i2f8Nj3+Yx/r+AuCTg7TLph0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ICMlmJSbtX/Jq5g1+VPV+MRfbsphvG8/63P/SH4bPcwN0j4CAKmrzzDMzimClkrjT G6SITp0XY4q/lZ2LsS4YUEbBwR34qcpj2VRrmr3zdBi+vITM+vCbmzFJW5iyRR2lAR 23/Zj7xvs79eudVGP5TRDmWXesexCLjsydWwRiG8= From: Tyler Retzlaff To: dev@dpdk.org Cc: Andrew Rybchenko , Bruce Richardson , Chengwen Feng , Cristian Dumitrescu , David Christensen , David Hunt , Ferruh Yigit , Honnappa Nagarahalli , Jasvinder Singh , Jerin Jacob , Kevin Laatz , Konstantin Ananyev , Min Zhou , Ruifeng Wang , Sameh Gobriel , Stanislaw Kardach , Thomas Monjalon , Vladimir Medvedkin , Yipeng Wang , Tyler Retzlaff Subject: [PATCH v4 22/39] rawdev: use C11 alignas Date: Wed, 14 Feb 2024 08:35:47 -0800 Message-Id: <1707928564-28796-23-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1707928564-28796-1-git-send-email-roretzla@linux.microsoft.com> References: <1707873986-29352-1-git-send-email-roretzla@linux.microsoft.com> <1707928564-28796-1-git-send-email-roretzla@linux.microsoft.com> MIME-Version: 1.0 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 * Move __rte_aligned from the end of {struct,union} definitions to be between {struct,union} and tag. The placement between {struct,union} and the tag allows the desired alignment to be imparted on the type regardless of the toolchain being used for all of GCC, LLVM, MSVC compilers building both C and C++. * Replace use of __rte_aligned(a) on variables/fields with alignas(a). Signed-off-by: Tyler Retzlaff Acked-by: Morten Brørup --- lib/rawdev/rte_rawdev.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/rawdev/rte_rawdev.h b/lib/rawdev/rte_rawdev.h index 7d5764d..640037b 100644 --- a/lib/rawdev/rte_rawdev.h +++ b/lib/rawdev/rte_rawdev.h @@ -279,7 +279,7 @@ * It is a placeholder for PMD specific data, encapsulating only information * related to framework. */ -struct rte_rawdev { +struct __rte_cache_aligned rte_rawdev { /**< Socket ID where memory is allocated */ int socket_id; /**< Device ID for this instance */ @@ -300,7 +300,7 @@ struct rte_rawdev { rte_rawdev_obj_t dev_private; /**< Device name */ char name[RTE_RAWDEV_NAME_MAX_LEN]; -} __rte_cache_aligned; +}; /** @internal The pool of rte_rawdev structures. */ extern struct rte_rawdev *rte_rawdevs; From patchwork Wed Feb 14 16:35:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 136782 X-Patchwork-Delegate: david.marchand@redhat.com 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 16C4643B38; Wed, 14 Feb 2024 17:39:09 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0D3A443360; Wed, 14 Feb 2024 17:36:43 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id A7DAB42E8D for ; Wed, 14 Feb 2024 17:36:08 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 33E8520B2017; Wed, 14 Feb 2024 08:36:06 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 33E8520B2017 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1707928567; bh=vLBxqVPHruh0R1dUr1069vOYb6zQkMnLkD6RWijhJ2U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZSBZozL7KfJxykOfCSGWCEz02rydvF6i3sDn6XaoilsrmpP20KbEDI5zi4T+On553 rSXI2piOIKAa4HGAioYAhlnSXHRWnIzugbAS3uYTUaZuEhlCzwtRvbxg2CApPsSW1P sIlNvsQQyDADPj5FiUXDQU6f5L3z7gceeH8rATMQ= From: Tyler Retzlaff To: dev@dpdk.org Cc: Andrew Rybchenko , Bruce Richardson , Chengwen Feng , Cristian Dumitrescu , David Christensen , David Hunt , Ferruh Yigit , Honnappa Nagarahalli , Jasvinder Singh , Jerin Jacob , Kevin Laatz , Konstantin Ananyev , Min Zhou , Ruifeng Wang , Sameh Gobriel , Stanislaw Kardach , Thomas Monjalon , Vladimir Medvedkin , Yipeng Wang , Tyler Retzlaff Subject: [PATCH v4 23/39] port: use C11 alignas Date: Wed, 14 Feb 2024 08:35:48 -0800 Message-Id: <1707928564-28796-24-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1707928564-28796-1-git-send-email-roretzla@linux.microsoft.com> References: <1707873986-29352-1-git-send-email-roretzla@linux.microsoft.com> <1707928564-28796-1-git-send-email-roretzla@linux.microsoft.com> MIME-Version: 1.0 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 * Move __rte_aligned from the end of {struct,union} definitions to be between {struct,union} and tag. The placement between {struct,union} and the tag allows the desired alignment to be imparted on the type regardless of the toolchain being used for all of GCC, LLVM, MSVC compilers building both C and C++. * Replace use of __rte_aligned(a) on variables/fields with alignas(a). Signed-off-by: Tyler Retzlaff Acked-by: Morten Brørup --- lib/port/rte_port_frag.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/port/rte_port_frag.c b/lib/port/rte_port_frag.c index 883601a..0940f94 100644 --- a/lib/port/rte_port_frag.c +++ b/lib/port/rte_port_frag.c @@ -34,7 +34,7 @@ struct rte_mempool *pool_direct, struct rte_mempool *pool_indirect); -struct rte_port_ring_reader_frag { +struct __rte_cache_aligned rte_port_ring_reader_frag { struct rte_port_in_stats stats; /* Input parameters */ @@ -53,7 +53,7 @@ struct rte_port_ring_reader_frag { uint32_t pos_frags; frag_op f_frag; -} __rte_cache_aligned; +}; static void * rte_port_ring_reader_frag_create(void *params, int socket_id, int is_ipv4) From patchwork Wed Feb 14 16:35:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 136772 X-Patchwork-Delegate: david.marchand@redhat.com 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 13D0343B38; Wed, 14 Feb 2024 17:38:12 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7F235432DC; Wed, 14 Feb 2024 17:36:31 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 5042642E5B for ; Wed, 14 Feb 2024 17:36:08 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 42A2720B2018; Wed, 14 Feb 2024 08:36:06 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 42A2720B2018 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1707928567; bh=NQWahJsjE9Eke4l4igljTJsx+RkIeyWHYnt3GrI31dE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=so4ByTpq/qV0L0zDQl7J/9r0PTesKNznyDDoiJcnENEH8lJ3JYwyTdv8kmPQEZctY PRvJMF7LdNceNaw9xs8f9LeXrLc7Bwaz+rCVlfROVbp4GwQhWF8J/znT83nsSNM7Rv at9MuXRxs6SudYqcFBtMmFEqImaI+kqjtDYTbQ20= From: Tyler Retzlaff To: dev@dpdk.org Cc: Andrew Rybchenko , Bruce Richardson , Chengwen Feng , Cristian Dumitrescu , David Christensen , David Hunt , Ferruh Yigit , Honnappa Nagarahalli , Jasvinder Singh , Jerin Jacob , Kevin Laatz , Konstantin Ananyev , Min Zhou , Ruifeng Wang , Sameh Gobriel , Stanislaw Kardach , Thomas Monjalon , Vladimir Medvedkin , Yipeng Wang , Tyler Retzlaff Subject: [PATCH v4 24/39] pdcp: use C11 alignas Date: Wed, 14 Feb 2024 08:35:49 -0800 Message-Id: <1707928564-28796-25-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1707928564-28796-1-git-send-email-roretzla@linux.microsoft.com> References: <1707873986-29352-1-git-send-email-roretzla@linux.microsoft.com> <1707928564-28796-1-git-send-email-roretzla@linux.microsoft.com> MIME-Version: 1.0 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 * Move __rte_aligned from the end of {struct,union} definitions to be between {struct,union} and tag. The placement between {struct,union} and the tag allows the desired alignment to be imparted on the type regardless of the toolchain being used for all of GCC, LLVM, MSVC compilers building both C and C++. * Replace use of __rte_aligned(a) on variables/fields with alignas(a). Signed-off-by: Tyler Retzlaff Acked-by: Morten Brørup --- lib/pdcp/rte_pdcp.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pdcp/rte_pdcp.h b/lib/pdcp/rte_pdcp.h index dd8b6e4..f74524f 100644 --- a/lib/pdcp/rte_pdcp.h +++ b/lib/pdcp/rte_pdcp.h @@ -49,7 +49,7 @@ typedef uint16_t (*rte_pdcp_post_p_t)(const struct rte_pdcp_entity *entity, * A PDCP entity is associated either to the control plane or the user plane * depending on which radio bearer it is carrying data for. */ -struct rte_pdcp_entity { +struct __rte_cache_aligned rte_pdcp_entity { /** Entity specific pre-process handle. */ rte_pdcp_pre_p_t pre_process; /** Entity specific post-process handle. */ @@ -66,7 +66,7 @@ struct rte_pdcp_entity { * hold additionally 'max_pkt_cache' number of packets. */ uint32_t max_pkt_cache; -} __rte_cache_aligned; +}; /** * Callback function type for t-Reordering timer start, set during PDCP entity establish. From patchwork Wed Feb 14 16:35:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 136770 X-Patchwork-Delegate: david.marchand@redhat.com 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 A215D43B38; Wed, 14 Feb 2024 17:37:59 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 06E8F432AC; Wed, 14 Feb 2024 17:36:29 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 65E1542E5D for ; Wed, 14 Feb 2024 17:36:08 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 5110820B2019; Wed, 14 Feb 2024 08:36:06 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 5110820B2019 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1707928567; bh=JUZfq/Znm06hsKGW/wkLYxRnT5OgIBpIBhb7rQYzwF0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TIe39b8DwNbQJhtyAbxic+wpGAgpjVjyH4ph0Y75sd95D065tw1i/Z5zuBSUfyGv8 HpMl822Mpi5x77N0v//JCdSyRiJUsvyIwI3qq/HZv78h96E8xPUTVseU+V9KXXPcMU t+tsIVdquHMIGW+/0vG9punngTIo8McUmIwnxNjo= From: Tyler Retzlaff To: dev@dpdk.org Cc: Andrew Rybchenko , Bruce Richardson , Chengwen Feng , Cristian Dumitrescu , David Christensen , David Hunt , Ferruh Yigit , Honnappa Nagarahalli , Jasvinder Singh , Jerin Jacob , Kevin Laatz , Konstantin Ananyev , Min Zhou , Ruifeng Wang , Sameh Gobriel , Stanislaw Kardach , Thomas Monjalon , Vladimir Medvedkin , Yipeng Wang , Tyler Retzlaff Subject: [PATCH v4 25/39] node: use C11 alignas Date: Wed, 14 Feb 2024 08:35:50 -0800 Message-Id: <1707928564-28796-26-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1707928564-28796-1-git-send-email-roretzla@linux.microsoft.com> References: <1707873986-29352-1-git-send-email-roretzla@linux.microsoft.com> <1707928564-28796-1-git-send-email-roretzla@linux.microsoft.com> MIME-Version: 1.0 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 * Move __rte_aligned from the end of {struct,union} definitions to be between {struct,union} and tag. The placement between {struct,union} and the tag allows the desired alignment to be imparted on the type regardless of the toolchain being used for all of GCC, LLVM, MSVC compilers building both C and C++. * Replace use of __rte_aligned(a) on variables/fields with alignas(a). Signed-off-by: Tyler Retzlaff Acked-by: Morten Brørup --- lib/node/node_private.h | 4 ++-- lib/node/pkt_cls.c | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/node/node_private.h b/lib/node/node_private.h index 2b9bad1..ff04659 100644 --- a/lib/node/node_private.h +++ b/lib/node/node_private.h @@ -51,9 +51,9 @@ struct node_mbuf_priv1 { /** * Node mbuf private area 2. */ -struct node_mbuf_priv2 { +struct __rte_cache_aligned node_mbuf_priv2 { uint64_t priv_data; -} __rte_cache_aligned; +}; #define NODE_MBUF_PRIV2_SIZE sizeof(struct node_mbuf_priv2) diff --git a/lib/node/pkt_cls.c b/lib/node/pkt_cls.c index a8302b8..9d21b7f 100644 --- a/lib/node/pkt_cls.c +++ b/lib/node/pkt_cls.c @@ -2,6 +2,8 @@ * Copyright (C) 2020 Marvell. */ +#include + #include #include @@ -9,7 +11,7 @@ #include "node_private.h" /* Next node for each ptype, default is '0' is "pkt_drop" */ -static const uint8_t p_nxt[256] __rte_cache_aligned = { +static const alignas(RTE_CACHE_LINE_SIZE) uint8_t p_nxt[256] = { [RTE_PTYPE_L3_IPV4] = PKT_CLS_NEXT_IP4_LOOKUP, [RTE_PTYPE_L3_IPV4_EXT] = PKT_CLS_NEXT_IP4_LOOKUP, From patchwork Wed Feb 14 16:35:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 136785 X-Patchwork-Delegate: david.marchand@redhat.com 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 D324143B38; Wed, 14 Feb 2024 17:39:26 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 68F4F4336E; Wed, 14 Feb 2024 17:36:46 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id CB43842E90 for ; Wed, 14 Feb 2024 17:36:08 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 5F30120B201A; Wed, 14 Feb 2024 08:36:06 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 5F30120B201A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1707928567; bh=3i0w9uRRxcB5BWpmaAYu0b9KWHbkRd8zyjKyCp0IZcM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=q6U9h9UYqEHFPy85EPUvz43e08p6DNJZBHS9RALDEgp4oTLCsmeUtPIRGPFe44Ies x+T1rPmvUtp32OS1zzEnQRdTg6gcZPl73S1YO68Aqt0csTtxvRWXdTqvnUpPp5cwpg P6O4zQDPRyTafOm9EVSSX6zvehch5Q9X6UKd/z/E= From: Tyler Retzlaff To: dev@dpdk.org Cc: Andrew Rybchenko , Bruce Richardson , Chengwen Feng , Cristian Dumitrescu , David Christensen , David Hunt , Ferruh Yigit , Honnappa Nagarahalli , Jasvinder Singh , Jerin Jacob , Kevin Laatz , Konstantin Ananyev , Min Zhou , Ruifeng Wang , Sameh Gobriel , Stanislaw Kardach , Thomas Monjalon , Vladimir Medvedkin , Yipeng Wang , Tyler Retzlaff Subject: [PATCH v4 26/39] mldev: use C11 alignas Date: Wed, 14 Feb 2024 08:35:51 -0800 Message-Id: <1707928564-28796-27-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1707928564-28796-1-git-send-email-roretzla@linux.microsoft.com> References: <1707873986-29352-1-git-send-email-roretzla@linux.microsoft.com> <1707928564-28796-1-git-send-email-roretzla@linux.microsoft.com> MIME-Version: 1.0 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 * Move __rte_aligned from the end of {struct,union} definitions to be between {struct,union} and tag. The placement between {struct,union} and the tag allows the desired alignment to be imparted on the type regardless of the toolchain being used for all of GCC, LLVM, MSVC compilers building both C and C++. * Replace use of __rte_aligned(a) on variables/fields with alignas(a). Signed-off-by: Tyler Retzlaff Acked-by: Morten Brørup --- lib/mldev/rte_mldev.h | 4 ++-- lib/mldev/rte_mldev_core.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/mldev/rte_mldev.h b/lib/mldev/rte_mldev.h index 5cf6f05..457dc01 100644 --- a/lib/mldev/rte_mldev.h +++ b/lib/mldev/rte_mldev.h @@ -421,7 +421,7 @@ struct rte_ml_buff_seg { * This structure contains data related to performing an ML operation on the buffers using * the model specified through model_id. */ -struct rte_ml_op { +struct __rte_cache_aligned rte_ml_op { uint16_t model_id; /**< Model ID to be used for the operation. */ uint16_t nb_batches; @@ -469,7 +469,7 @@ struct rte_ml_op { * dequeue and enqueue operation. * The application should not modify this field. */ -} __rte_cache_aligned; +}; /* Enqueue/Dequeue operations */ diff --git a/lib/mldev/rte_mldev_core.h b/lib/mldev/rte_mldev_core.h index 2279b1d..b3bd281 100644 --- a/lib/mldev/rte_mldev_core.h +++ b/lib/mldev/rte_mldev_core.h @@ -626,7 +626,7 @@ struct rte_ml_dev_data { * * The data structure associated with each ML device. */ -struct rte_ml_dev { +struct __rte_cache_aligned rte_ml_dev { /** Pointer to PMD enqueue function. */ mldev_enqueue_t enqueue_burst; @@ -647,7 +647,7 @@ struct rte_ml_dev { /** Flag indicating the device is attached. */ __extension__ uint8_t attached : 1; -} __rte_cache_aligned; +}; /** * @internal From patchwork Wed Feb 14 16:35:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 136774 X-Patchwork-Delegate: david.marchand@redhat.com 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 E993643B38; Wed, 14 Feb 2024 17:38:23 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AB94A43306; Wed, 14 Feb 2024 17:36:33 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 7368541104 for ; Wed, 14 Feb 2024 17:36:08 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 6DF2F20B201B; Wed, 14 Feb 2024 08:36:06 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 6DF2F20B201B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1707928567; bh=leKBBcJArKi6x1l6gDQ29h7VJukO8VUh3n1ahF9EzmE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UVeAOiWhljnonly1t4+Xmd31CKHLAVQA7yhLjNCx72LKQF+ms4v/c/ZQsgKoKG2TA cl3WIJSLNXjtZE7JRRHlFgEVekl09llfFs1OOF+yQRdBqTRsuR+uJcAWqCb/wQu94i 0cTzsUT2uQF4O0HsXLwqd8MXTKuZV0fcjjnX/8L0= From: Tyler Retzlaff To: dev@dpdk.org Cc: Andrew Rybchenko , Bruce Richardson , Chengwen Feng , Cristian Dumitrescu , David Christensen , David Hunt , Ferruh Yigit , Honnappa Nagarahalli , Jasvinder Singh , Jerin Jacob , Kevin Laatz , Konstantin Ananyev , Min Zhou , Ruifeng Wang , Sameh Gobriel , Stanislaw Kardach , Thomas Monjalon , Vladimir Medvedkin , Yipeng Wang , Tyler Retzlaff Subject: [PATCH v4 27/39] mempool: use C11 alignas Date: Wed, 14 Feb 2024 08:35:52 -0800 Message-Id: <1707928564-28796-28-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1707928564-28796-1-git-send-email-roretzla@linux.microsoft.com> References: <1707873986-29352-1-git-send-email-roretzla@linux.microsoft.com> <1707928564-28796-1-git-send-email-roretzla@linux.microsoft.com> MIME-Version: 1.0 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 * Move __rte_aligned from the end of {struct,union} definitions to be between {struct,union} and tag. The placement between {struct,union} and the tag allows the desired alignment to be imparted on the type regardless of the toolchain being used for all of GCC, LLVM, MSVC compilers building both C and C++. * Replace use of __rte_aligned(a) on variables/fields with alignas(a). Signed-off-by: Tyler Retzlaff Acked-by: Morten Brørup --- lib/mempool/rte_mempool.h | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/lib/mempool/rte_mempool.h b/lib/mempool/rte_mempool.h index 6fa4d48..23fd5c8 100644 --- a/lib/mempool/rte_mempool.h +++ b/lib/mempool/rte_mempool.h @@ -34,6 +34,7 @@ * user cache created with rte_mempool_cache_create(). */ +#include #include #include #include @@ -66,7 +67,7 @@ * captured since they can be calculated from other stats. * For example: put_cache_objs = put_objs - put_common_pool_objs. */ -struct rte_mempool_debug_stats { +struct __rte_cache_aligned rte_mempool_debug_stats { uint64_t put_bulk; /**< Number of puts. */ uint64_t put_objs; /**< Number of objects successfully put. */ uint64_t put_common_pool_bulk; /**< Number of bulks enqueued in common pool. */ @@ -80,13 +81,13 @@ struct rte_mempool_debug_stats { uint64_t get_success_blks; /**< Successful allocation number of contiguous blocks. */ uint64_t get_fail_blks; /**< Failed allocation number of contiguous blocks. */ RTE_CACHE_GUARD; -} __rte_cache_aligned; +}; #endif /** * A structure that stores a per-core object cache. */ -struct rte_mempool_cache { +struct __rte_cache_aligned rte_mempool_cache { uint32_t size; /**< Size of the cache */ uint32_t flushthresh; /**< Threshold before we flush excess elements */ uint32_t len; /**< Current cache count */ @@ -109,8 +110,8 @@ struct rte_mempool_cache { * Cache is allocated to this size to allow it to overflow in certain * cases to avoid needless emptying of cache. */ - void *objs[RTE_MEMPOOL_CACHE_MAX_SIZE * 2] __rte_cache_aligned; -} __rte_cache_aligned; + alignas(RTE_CACHE_LINE_SIZE) void *objs[RTE_MEMPOOL_CACHE_MAX_SIZE * 2]; +}; /** * A structure that stores the size of mempool elements. @@ -218,15 +219,15 @@ struct rte_mempool_memhdr { * The structure is cache-line aligned to avoid ABI breakages in * a number of cases when something small is added. */ -struct rte_mempool_info { +struct __rte_cache_aligned rte_mempool_info { /** Number of objects in the contiguous block */ unsigned int contig_block_size; -} __rte_cache_aligned; +}; /** * The RTE mempool structure. */ -struct rte_mempool { +struct __rte_cache_aligned rte_mempool { char name[RTE_MEMPOOL_NAMESIZE]; /**< Name of mempool. */ union { void *pool_data; /**< Ring or pool to store objects. */ @@ -268,7 +269,7 @@ struct rte_mempool { */ struct rte_mempool_debug_stats stats[RTE_MAX_LCORE + 1]; #endif -} __rte_cache_aligned; +}; /** Spreading among memory channels not required. */ #define RTE_MEMPOOL_F_NO_SPREAD 0x0001 @@ -688,7 +689,7 @@ typedef int (*rte_mempool_get_info_t)(const struct rte_mempool *mp, /** Structure defining mempool operations structure */ -struct rte_mempool_ops { +struct __rte_cache_aligned rte_mempool_ops { char name[RTE_MEMPOOL_OPS_NAMESIZE]; /**< Name of mempool ops struct. */ rte_mempool_alloc_t alloc; /**< Allocate private data. */ rte_mempool_free_t free; /**< Free the external pool. */ @@ -713,7 +714,7 @@ struct rte_mempool_ops { * Dequeue a number of contiguous object blocks. */ rte_mempool_dequeue_contig_blocks_t dequeue_contig_blocks; -} __rte_cache_aligned; +}; #define RTE_MEMPOOL_MAX_OPS_IDX 16 /**< Max registered ops structs */ @@ -726,14 +727,14 @@ struct rte_mempool_ops { * any function pointers stored directly in the mempool struct would not be. * This results in us simply having "ops_index" in the mempool struct. */ -struct rte_mempool_ops_table { +struct __rte_cache_aligned rte_mempool_ops_table { rte_spinlock_t sl; /**< Spinlock for add/delete. */ uint32_t num_ops; /**< Number of used ops structs in the table. */ /** * Storage for all possible ops structs. */ struct rte_mempool_ops ops[RTE_MEMPOOL_MAX_OPS_IDX]; -} __rte_cache_aligned; +}; /** Array of registered ops structs. */ extern struct rte_mempool_ops_table rte_mempool_ops_table; From patchwork Wed Feb 14 16:35:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 136779 X-Patchwork-Delegate: david.marchand@redhat.com 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 32B0443B38; Wed, 14 Feb 2024 17:38:52 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8F2CF43352; Wed, 14 Feb 2024 17:36:39 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 777D84026A for ; Wed, 14 Feb 2024 17:36:08 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 7CD7620B201C; Wed, 14 Feb 2024 08:36:06 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 7CD7620B201C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1707928567; bh=1Azz5Tkwlpf18VY0hMrVxK2zzYrPYoKwWQZzQOBNvOU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SvFqTXZsjEG8ly9VTt4s2h8AFa0CuTq9Wnr+SMVGaMVLYgp3PyaiMM51iV86Oss+d I0I10msfpaX/4uqtFpA48R4PaHS6Di1A/Akm6G3JAQ6XC6qjRdSUWxHoEQvsGrqTBY Oiio3TTOqeQ6+FkigjqGjcXJisWfxZHrGlLNDlnM= From: Tyler Retzlaff To: dev@dpdk.org Cc: Andrew Rybchenko , Bruce Richardson , Chengwen Feng , Cristian Dumitrescu , David Christensen , David Hunt , Ferruh Yigit , Honnappa Nagarahalli , Jasvinder Singh , Jerin Jacob , Kevin Laatz , Konstantin Ananyev , Min Zhou , Ruifeng Wang , Sameh Gobriel , Stanislaw Kardach , Thomas Monjalon , Vladimir Medvedkin , Yipeng Wang , Tyler Retzlaff Subject: [PATCH v4 28/39] member: use C11 alignas Date: Wed, 14 Feb 2024 08:35:53 -0800 Message-Id: <1707928564-28796-29-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1707928564-28796-1-git-send-email-roretzla@linux.microsoft.com> References: <1707873986-29352-1-git-send-email-roretzla@linux.microsoft.com> <1707928564-28796-1-git-send-email-roretzla@linux.microsoft.com> MIME-Version: 1.0 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 * Move __rte_aligned from the end of {struct,union} definitions to be between {struct,union} and tag. The placement between {struct,union} and the tag allows the desired alignment to be imparted on the type regardless of the toolchain being used for all of GCC, LLVM, MSVC compilers building both C and C++. * Replace use of __rte_aligned(a) on variables/fields with alignas(a). Signed-off-by: Tyler Retzlaff Acked-by: Morten Brørup --- lib/member/rte_member.h | 8 ++++---- lib/member/rte_member_ht.h | 4 ++-- lib/member/rte_member_sketch.c | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/member/rte_member.h b/lib/member/rte_member.h index 3278bbb..aec192e 100644 --- a/lib/member/rte_member.h +++ b/lib/member/rte_member.h @@ -139,7 +139,7 @@ typedef void (*sketch_delete_fn_t)(const struct rte_member_setsum *ss, const void *key); /** @internal setsummary structure. */ -struct rte_member_setsum { +struct __rte_cache_aligned rte_member_setsum { enum rte_member_setsum_type type; /* Type of the set summary. */ uint32_t key_len; /* Length of key. */ uint32_t prim_hash_seed; /* Primary hash function seed. */ @@ -185,14 +185,14 @@ struct rte_member_setsum { #ifdef RTE_ARCH_X86 bool use_avx512; #endif -} __rte_cache_aligned; +}; /** * Parameters used when create the set summary table. Currently user can * specify two types of setsummary: HT based and vBF. For HT based, user can * specify cache or non-cache mode. Here is a table to describe some differences */ -struct rte_member_parameters { +struct __rte_cache_aligned rte_member_parameters { const char *name; /**< Name of the hash. */ /** @@ -326,7 +326,7 @@ struct rte_member_parameters { uint32_t extra_flag; int socket_id; /**< NUMA Socket ID for memory. */ -} __rte_cache_aligned; +}; /** * Find an existing set-summary and return a pointer to it. diff --git a/lib/member/rte_member_ht.h b/lib/member/rte_member_ht.h index 9e24ccd..c9673e3 100644 --- a/lib/member/rte_member_ht.h +++ b/lib/member/rte_member_ht.h @@ -15,10 +15,10 @@ typedef uint16_t member_sig_t; /* signature size is 16 bit */ /* The bucket struct for ht setsum */ -struct member_ht_bucket { +struct __rte_cache_aligned member_ht_bucket { member_sig_t sigs[RTE_MEMBER_BUCKET_ENTRIES]; /* 2-byte signature */ member_set_t sets[RTE_MEMBER_BUCKET_ENTRIES]; /* 2-byte set */ -} __rte_cache_aligned; +}; int rte_member_create_ht(struct rte_member_setsum *ss, diff --git a/lib/member/rte_member_sketch.c b/lib/member/rte_member_sketch.c index e006e83..15af678 100644 --- a/lib/member/rte_member_sketch.c +++ b/lib/member/rte_member_sketch.c @@ -23,7 +23,7 @@ #include "rte_member_sketch_avx512.h" #endif /* CC_AVX512_SUPPORT */ -struct sketch_runtime { +struct __rte_cache_aligned sketch_runtime { uint64_t pkt_cnt; uint32_t until_next; int converged; @@ -31,7 +31,7 @@ struct sketch_runtime { struct node *report_array; void *key_slots; struct rte_ring *free_key_slots; -} __rte_cache_aligned; +}; /* * Geometric sampling to calculate how many packets needs to be From patchwork Wed Feb 14 16:35:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 136777 X-Patchwork-Delegate: david.marchand@redhat.com 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 E8D3143B38; Wed, 14 Feb 2024 17:38:40 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 37DAD43342; Wed, 14 Feb 2024 17:36:37 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 79C4A42E6D for ; Wed, 14 Feb 2024 17:36:08 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 8BC2020B201D; Wed, 14 Feb 2024 08:36:06 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 8BC2020B201D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1707928567; bh=BQP3CCKHZN6cDLqLXwrp3CtgmfzWQW1GzpV7niIq2rM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=flRAZAlGtyxx72/eugyjfFZr2vrC9hII2ORslOOqKOBh2GJ89orIPfifjjDCQ8vKl hexyqb4qS/RVAzygVOwyNHT/hoFWpXbZuq82NoaAzwwetTETneZONLK5CmcJPpfPY1 bU8dAADeYBXNnslsqg+3XYkvvIZsiZeT6+GnwmvI= From: Tyler Retzlaff To: dev@dpdk.org Cc: Andrew Rybchenko , Bruce Richardson , Chengwen Feng , Cristian Dumitrescu , David Christensen , David Hunt , Ferruh Yigit , Honnappa Nagarahalli , Jasvinder Singh , Jerin Jacob , Kevin Laatz , Konstantin Ananyev , Min Zhou , Ruifeng Wang , Sameh Gobriel , Stanislaw Kardach , Thomas Monjalon , Vladimir Medvedkin , Yipeng Wang , Tyler Retzlaff Subject: [PATCH v4 29/39] lpm: use C11 alignas Date: Wed, 14 Feb 2024 08:35:54 -0800 Message-Id: <1707928564-28796-30-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1707928564-28796-1-git-send-email-roretzla@linux.microsoft.com> References: <1707873986-29352-1-git-send-email-roretzla@linux.microsoft.com> <1707928564-28796-1-git-send-email-roretzla@linux.microsoft.com> MIME-Version: 1.0 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 * Move __rte_aligned from the end of {struct,union} definitions to be between {struct,union} and tag. The placement between {struct,union} and the tag allows the desired alignment to be imparted on the type regardless of the toolchain being used for all of GCC, LLVM, MSVC compilers building both C and C++. * Replace use of __rte_aligned(a) on variables/fields with alignas(a). Signed-off-by: Tyler Retzlaff Acked-by: Morten Brørup --- lib/lpm/rte_lpm.h | 5 +++-- lib/lpm/rte_lpm6.c | 8 ++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/lpm/rte_lpm.h b/lib/lpm/rte_lpm.h index f57977b..f311fd9 100644 --- a/lib/lpm/rte_lpm.h +++ b/lib/lpm/rte_lpm.h @@ -11,6 +11,7 @@ * RTE Longest Prefix Match (LPM) */ +#include #include #include @@ -118,8 +119,8 @@ struct rte_lpm_config { /** @internal LPM structure. */ struct rte_lpm { /* LPM Tables. */ - struct rte_lpm_tbl_entry tbl24[RTE_LPM_TBL24_NUM_ENTRIES] - __rte_cache_aligned; /**< LPM tbl24 table. */ + alignas(RTE_CACHE_LINE_SIZE) struct rte_lpm_tbl_entry tbl24[RTE_LPM_TBL24_NUM_ENTRIES]; + /**< LPM tbl24 table. */ struct rte_lpm_tbl_entry *tbl8; /**< LPM tbl8 table. */ }; diff --git a/lib/lpm/rte_lpm6.c b/lib/lpm/rte_lpm6.c index 271bc48..ed5970c 100644 --- a/lib/lpm/rte_lpm6.c +++ b/lib/lpm/rte_lpm6.c @@ -98,16 +98,16 @@ struct rte_lpm6 { /* LPM Tables. */ struct rte_hash *rules_tbl; /**< LPM rules. */ - struct rte_lpm6_tbl_entry tbl24[RTE_LPM6_TBL24_NUM_ENTRIES] - __rte_cache_aligned; /**< LPM tbl24 table. */ + alignas(RTE_CACHE_LINE_SIZE) struct rte_lpm6_tbl_entry tbl24[RTE_LPM6_TBL24_NUM_ENTRIES]; + /**< LPM tbl24 table. */ uint32_t *tbl8_pool; /**< pool of indexes of free tbl8s */ uint32_t tbl8_pool_pos; /**< current position in the tbl8 pool */ struct rte_lpm_tbl8_hdr *tbl8_hdrs; /* array of tbl8 headers */ - struct rte_lpm6_tbl_entry tbl8[0] - __rte_cache_aligned; /**< LPM tbl8 table. */ + alignas(RTE_CACHE_LINE_SIZE) struct rte_lpm6_tbl_entry tbl8[0]; + /**< LPM tbl8 table. */ }; /* From patchwork Wed Feb 14 16:35:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 136784 X-Patchwork-Delegate: david.marchand@redhat.com 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 9D06043B38; Wed, 14 Feb 2024 17:39:20 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 52BD34336A; Wed, 14 Feb 2024 17:36:45 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id D7EDA42E93 for ; Wed, 14 Feb 2024 17:36:08 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 9AE1A20B201E; Wed, 14 Feb 2024 08:36:06 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 9AE1A20B201E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1707928567; bh=04FBikm89XV2zw65pfpk6bJdcdew2sHIVJxnTTU59pU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cG8qUYHCt1sUJD/DRJxhxB052O97GfHWWInDtbbRphdxgPThi9FEWqynehpIIqtum FCG7QWeh0/kB8W+61RJTOIpN01AwoSjmFJnUtNcDhRLoXYFIexbfhHgLFY/QeiAYi5 wL5425kuo6RZ4iGBRDAw6cx6jKU5sPgmkUwDWzsw= From: Tyler Retzlaff To: dev@dpdk.org Cc: Andrew Rybchenko , Bruce Richardson , Chengwen Feng , Cristian Dumitrescu , David Christensen , David Hunt , Ferruh Yigit , Honnappa Nagarahalli , Jasvinder Singh , Jerin Jacob , Kevin Laatz , Konstantin Ananyev , Min Zhou , Ruifeng Wang , Sameh Gobriel , Stanislaw Kardach , Thomas Monjalon , Vladimir Medvedkin , Yipeng Wang , Tyler Retzlaff Subject: [PATCH v4 30/39] ipsec: use C11 alignas Date: Wed, 14 Feb 2024 08:35:55 -0800 Message-Id: <1707928564-28796-31-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1707928564-28796-1-git-send-email-roretzla@linux.microsoft.com> References: <1707873986-29352-1-git-send-email-roretzla@linux.microsoft.com> <1707928564-28796-1-git-send-email-roretzla@linux.microsoft.com> MIME-Version: 1.0 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 * Move __rte_aligned from the end of {struct,union} definitions to be between {struct,union} and tag. The placement between {struct,union} and the tag allows the desired alignment to be imparted on the type regardless of the toolchain being used for all of GCC, LLVM, MSVC compilers building both C and C++. * Replace use of __rte_aligned(a) on variables/fields with alignas(a). Signed-off-by: Tyler Retzlaff Acked-by: Morten Brørup --- lib/ipsec/rte_ipsec.h | 4 ++-- lib/ipsec/sa.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/ipsec/rte_ipsec.h b/lib/ipsec/rte_ipsec.h index 44cecab..f15f6f2 100644 --- a/lib/ipsec/rte_ipsec.h +++ b/lib/ipsec/rte_ipsec.h @@ -55,7 +55,7 @@ struct rte_ipsec_sa_pkt_func { * - pointer to security/crypto session, plus other related data * - session/device specific functions to prepare/process IPsec packets. */ -struct rte_ipsec_session { +struct __rte_cache_aligned rte_ipsec_session { /** * SA that session belongs to. * Note that multiple sessions can belong to the same SA. @@ -77,7 +77,7 @@ struct rte_ipsec_session { }; /** functions to prepare/process IPsec packets */ struct rte_ipsec_sa_pkt_func pkt_func; -} __rte_cache_aligned; +}; /** * Checks that inside given rte_ipsec_session crypto/security fields diff --git a/lib/ipsec/sa.h b/lib/ipsec/sa.h index 4b30bea..2560d33 100644 --- a/lib/ipsec/sa.h +++ b/lib/ipsec/sa.h @@ -75,7 +75,7 @@ enum sa_algo_type { ALGO_TYPE_MAX }; -struct rte_ipsec_sa { +struct __rte_cache_aligned rte_ipsec_sa { uint64_t type; /* type of given SA */ uint64_t udata; /* user defined */ @@ -141,7 +141,7 @@ struct rte_ipsec_sa { } errors; } statistics; -} __rte_cache_aligned; +}; int ipsec_sa_pkt_func_select(const struct rte_ipsec_session *ss, From patchwork Wed Feb 14 16:35:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 136778 X-Patchwork-Delegate: david.marchand@redhat.com 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 A9F1443B38; Wed, 14 Feb 2024 17:38:46 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 636F44334C; Wed, 14 Feb 2024 17:36:38 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 830B142E75 for ; Wed, 14 Feb 2024 17:36:08 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id A9DC020B201F; Wed, 14 Feb 2024 08:36:06 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com A9DC020B201F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1707928567; bh=QNtU9+9FwdXP9BqKNIKdS4Ftcpwa+ayN9EkFQwAk8JA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=R+SOw84EBf6lCl26UIGNBfUbKfFmHz/agCfcWlwnVyYlt4JxJdy/WYwothL1fOMXp wdxEQX/7e6yAwNIgF8ipZcT/rvFnYCFgehic9l8gIQKAZJnh4otzEn0khv8lqYOtjm 1TrYDk6X2xyF7BbnVjLkBWggzUQZaDZmcndyc4kc= From: Tyler Retzlaff To: dev@dpdk.org Cc: Andrew Rybchenko , Bruce Richardson , Chengwen Feng , Cristian Dumitrescu , David Christensen , David Hunt , Ferruh Yigit , Honnappa Nagarahalli , Jasvinder Singh , Jerin Jacob , Kevin Laatz , Konstantin Ananyev , Min Zhou , Ruifeng Wang , Sameh Gobriel , Stanislaw Kardach , Thomas Monjalon , Vladimir Medvedkin , Yipeng Wang , Tyler Retzlaff Subject: [PATCH v4 31/39] jobstats: use C11 alignas Date: Wed, 14 Feb 2024 08:35:56 -0800 Message-Id: <1707928564-28796-32-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1707928564-28796-1-git-send-email-roretzla@linux.microsoft.com> References: <1707873986-29352-1-git-send-email-roretzla@linux.microsoft.com> <1707928564-28796-1-git-send-email-roretzla@linux.microsoft.com> MIME-Version: 1.0 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 * Move __rte_aligned from the end of {struct,union} definitions to be between {struct,union} and tag. The placement between {struct,union} and the tag allows the desired alignment to be imparted on the type regardless of the toolchain being used for all of GCC, LLVM, MSVC compilers building both C and C++. * Replace use of __rte_aligned(a) on variables/fields with alignas(a). Signed-off-by: Tyler Retzlaff Acked-by: Morten Brørup --- lib/jobstats/rte_jobstats.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/jobstats/rte_jobstats.h b/lib/jobstats/rte_jobstats.h index 45b460e..bdd85fe 100644 --- a/lib/jobstats/rte_jobstats.h +++ b/lib/jobstats/rte_jobstats.h @@ -32,7 +32,7 @@ typedef void (*rte_job_update_period_cb_t)(struct rte_jobstats *job, int64_t job_result); -struct rte_jobstats { +struct __rte_cache_aligned rte_jobstats { uint64_t period; /**< Estimated period of execution. */ @@ -65,9 +65,9 @@ struct rte_jobstats { struct rte_jobstats_context *context; /**< Job stats context object that is executing this job. */ -} __rte_cache_aligned; +}; -struct rte_jobstats_context { +struct __rte_cache_aligned rte_jobstats_context { /** Variable holding time at different points: * -# loop start time if loop was started but no job executed yet. * -# job start time if job is currently executing. @@ -111,7 +111,7 @@ struct rte_jobstats_context { uint64_t loop_cnt; /**< Total count of executed loops with at least one executed job. */ -} __rte_cache_aligned; +}; /** * Initialize given context object with default values. From patchwork Wed Feb 14 16:35:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 136780 X-Patchwork-Delegate: david.marchand@redhat.com 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 84FFA43B38; Wed, 14 Feb 2024 17:38:57 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D8D2D43357; Wed, 14 Feb 2024 17:36:40 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id F384C42E94 for ; Wed, 14 Feb 2024 17:36:08 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id B88CD20B2020; Wed, 14 Feb 2024 08:36:06 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com B88CD20B2020 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1707928567; bh=k/TsLJrwxM4H1HwM39p6Fxq+77qY10/bd1weEaD4MQ4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FrnnM16LIXD2hLDW5J3YkHLN3b4FWDh0UEySodSVP1pliuortW/ij2U2w/TChgZQx ZAbs9eY7HBJ2/YgevWP0AS4t73fNvyRb8T9qdqPDag7vSlqa28zZB+81HdD9LzeKvE FtG29ZkQCF6+oJxQlrbGpAW1exr1VaM0k7GGXsKs= From: Tyler Retzlaff To: dev@dpdk.org Cc: Andrew Rybchenko , Bruce Richardson , Chengwen Feng , Cristian Dumitrescu , David Christensen , David Hunt , Ferruh Yigit , Honnappa Nagarahalli , Jasvinder Singh , Jerin Jacob , Kevin Laatz , Konstantin Ananyev , Min Zhou , Ruifeng Wang , Sameh Gobriel , Stanislaw Kardach , Thomas Monjalon , Vladimir Medvedkin , Yipeng Wang , Tyler Retzlaff Subject: [PATCH v4 32/39] bpf: use C11 alignas Date: Wed, 14 Feb 2024 08:35:57 -0800 Message-Id: <1707928564-28796-33-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1707928564-28796-1-git-send-email-roretzla@linux.microsoft.com> References: <1707873986-29352-1-git-send-email-roretzla@linux.microsoft.com> <1707928564-28796-1-git-send-email-roretzla@linux.microsoft.com> MIME-Version: 1.0 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 * Move __rte_aligned from the end of {struct,union} definitions to be between {struct,union} and tag. The placement between {struct,union} and the tag allows the desired alignment to be imparted on the type regardless of the toolchain being used for all of GCC, LLVM, MSVC compilers building both C and C++. * Replace use of __rte_aligned(a) on variables/fields with alignas(a). Signed-off-by: Tyler Retzlaff Acked-by: Morten Brørup --- lib/bpf/bpf_pkt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/bpf/bpf_pkt.c b/lib/bpf/bpf_pkt.c index 793a75d..aaca935 100644 --- a/lib/bpf/bpf_pkt.c +++ b/lib/bpf/bpf_pkt.c @@ -23,7 +23,7 @@ * information about installed BPF rx/tx callback */ -struct bpf_eth_cbi { +struct __rte_cache_aligned bpf_eth_cbi { /* used by both data & control path */ RTE_ATOMIC(uint32_t) use; /*usage counter */ const struct rte_eth_rxtx_callback *cb; /* callback handle */ @@ -33,7 +33,7 @@ struct bpf_eth_cbi { LIST_ENTRY(bpf_eth_cbi) link; uint16_t port; uint16_t queue; -} __rte_cache_aligned; +}; /* * Odd number means that callback is used by datapath. From patchwork Wed Feb 14 16:35:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 136786 X-Patchwork-Delegate: david.marchand@redhat.com 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 DD71243B38; Wed, 14 Feb 2024 17:39:31 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8DD1843375; Wed, 14 Feb 2024 17:36:47 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 9D14442E8C for ; Wed, 14 Feb 2024 17:36:08 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id C6B9D20B2021; Wed, 14 Feb 2024 08:36:06 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com C6B9D20B2021 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1707928567; bh=93qJoPus/30klmf0/s5wbT84HOxlRkpeti3/IiDT1Fw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nuGccqmFGvPsEN6LxRnwws0bY7RmUkXjG4z8JQaq9XNYHny4cbGods/WRSXUjIp1w CH8/iR3kwqp+1kZpwOToHJ+7UtFxNUL7d9mhAPAAvsRWcvDlAje2P8KyU1l2okeH8+ ayr1+I5/f6AHCQH2a6HDUTWetvQhl4OL5kVzHvyI= From: Tyler Retzlaff To: dev@dpdk.org Cc: Andrew Rybchenko , Bruce Richardson , Chengwen Feng , Cristian Dumitrescu , David Christensen , David Hunt , Ferruh Yigit , Honnappa Nagarahalli , Jasvinder Singh , Jerin Jacob , Kevin Laatz , Konstantin Ananyev , Min Zhou , Ruifeng Wang , Sameh Gobriel , Stanislaw Kardach , Thomas Monjalon , Vladimir Medvedkin , Yipeng Wang , Tyler Retzlaff Subject: [PATCH v4 33/39] compressdev: use C11 alignas Date: Wed, 14 Feb 2024 08:35:58 -0800 Message-Id: <1707928564-28796-34-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1707928564-28796-1-git-send-email-roretzla@linux.microsoft.com> References: <1707873986-29352-1-git-send-email-roretzla@linux.microsoft.com> <1707928564-28796-1-git-send-email-roretzla@linux.microsoft.com> MIME-Version: 1.0 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 * Move __rte_aligned from the end of {struct,union} definitions to be between {struct,union} and tag. The placement between {struct,union} and the tag allows the desired alignment to be imparted on the type regardless of the toolchain being used for all of GCC, LLVM, MSVC compilers building both C and C++. * Replace use of __rte_aligned(a) on variables/fields with alignas(a). Signed-off-by: Tyler Retzlaff Acked-by: Morten Brørup --- lib/compressdev/rte_comp.h | 4 ++-- lib/compressdev/rte_compressdev_internal.h | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/compressdev/rte_comp.h b/lib/compressdev/rte_comp.h index 3606ebf..830a240 100644 --- a/lib/compressdev/rte_comp.h +++ b/lib/compressdev/rte_comp.h @@ -356,7 +356,7 @@ struct rte_comp_xform { * Comp operations are enqueued and dequeued in comp PMDs using the * rte_compressdev_enqueue_burst() / rte_compressdev_dequeue_burst() APIs */ -struct rte_comp_op { +struct __rte_cache_aligned rte_comp_op { enum rte_comp_op_type op_type; union { void *private_xform; @@ -478,7 +478,7 @@ struct rte_comp_op { * will be set to RTE_COMP_OP_STATUS_SUCCESS after operation * is successfully processed by a PMD */ -} __rte_cache_aligned; +}; /** * Creates an operation pool diff --git a/lib/compressdev/rte_compressdev_internal.h b/lib/compressdev/rte_compressdev_internal.h index 01b7764..8a626d3 100644 --- a/lib/compressdev/rte_compressdev_internal.h +++ b/lib/compressdev/rte_compressdev_internal.h @@ -69,7 +69,7 @@ typedef uint16_t (*compressdev_enqueue_pkt_burst_t)(void *qp, struct rte_comp_op **ops, uint16_t nb_ops); /** The data structure associated with each comp device. */ -struct rte_compressdev { +struct __rte_cache_aligned rte_compressdev { compressdev_dequeue_pkt_burst_t dequeue_burst; /**< Pointer to PMD receive function */ compressdev_enqueue_pkt_burst_t enqueue_burst; @@ -87,7 +87,7 @@ struct rte_compressdev { __extension__ uint8_t attached : 1; /**< Flag indicating the device is attached */ -} __rte_cache_aligned; +}; /** * @@ -96,7 +96,7 @@ struct rte_compressdev { * This structure is safe to place in shared memory to be common among * different processes in a multi-process configuration. */ -struct rte_compressdev_data { +struct __rte_cache_aligned rte_compressdev_data { uint8_t dev_id; /**< Compress device identifier */ int socket_id; @@ -115,7 +115,7 @@ struct rte_compressdev_data { void *dev_private; /**< PMD-specific private data */ -} __rte_cache_aligned; +}; #ifdef __cplusplus } From patchwork Wed Feb 14 16:35:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 136789 X-Patchwork-Delegate: david.marchand@redhat.com 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 1D3EF43B38; Wed, 14 Feb 2024 17:39:49 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CE01043381; Wed, 14 Feb 2024 17:36:50 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id B08C342E8E for ; Wed, 14 Feb 2024 17:36:08 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id D5D8D20B2023; Wed, 14 Feb 2024 08:36:06 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com D5D8D20B2023 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1707928567; bh=es2FAKw+TZILr6t5+zTCFA5AZOaQTd2xrNZmhDbEuYA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qYghz/MXUJduRM4Lebp73470KknJCJ7mon5rb+JWDSQMpzifz78wAUCFUmhX2vRW0 U1xt/XvAqv4jxabhSvitYWPPEW8CBKueuWeM8Wjgsv5B1sAl7OZ6i2uJZFIgaoq2Yg D6Bspf/IgvBy69tDcLXp46NpRA2071lx9iwvTC7E= From: Tyler Retzlaff To: dev@dpdk.org Cc: Andrew Rybchenko , Bruce Richardson , Chengwen Feng , Cristian Dumitrescu , David Christensen , David Hunt , Ferruh Yigit , Honnappa Nagarahalli , Jasvinder Singh , Jerin Jacob , Kevin Laatz , Konstantin Ananyev , Min Zhou , Ruifeng Wang , Sameh Gobriel , Stanislaw Kardach , Thomas Monjalon , Vladimir Medvedkin , Yipeng Wang , Tyler Retzlaff Subject: [PATCH v4 34/39] cryptodev: use C11 alignas Date: Wed, 14 Feb 2024 08:35:59 -0800 Message-Id: <1707928564-28796-35-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1707928564-28796-1-git-send-email-roretzla@linux.microsoft.com> References: <1707873986-29352-1-git-send-email-roretzla@linux.microsoft.com> <1707928564-28796-1-git-send-email-roretzla@linux.microsoft.com> MIME-Version: 1.0 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 * Move __rte_aligned from the end of {struct,union} definitions to be between {struct,union} and tag. The placement between {struct,union} and the tag allows the desired alignment to be imparted on the type regardless of the toolchain being used for all of GCC, LLVM, MSVC compilers building both C and C++. * Replace use of __rte_aligned(a) on variables/fields with alignas(a). Signed-off-by: Tyler Retzlaff Acked-by: Morten Brørup --- lib/cryptodev/cryptodev_pmd.h | 8 ++++---- lib/cryptodev/rte_cryptodev_core.h | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/cryptodev/cryptodev_pmd.h b/lib/cryptodev/cryptodev_pmd.h index 0732b35..6229ad4 100644 --- a/lib/cryptodev/cryptodev_pmd.h +++ b/lib/cryptodev/cryptodev_pmd.h @@ -61,7 +61,7 @@ struct rte_cryptodev_pmd_init_params { * This structure is safe to place in shared memory to be common among * different processes in a multi-process configuration. */ -struct rte_cryptodev_data { +struct __rte_cache_aligned rte_cryptodev_data { /** Device ID for this instance */ uint8_t dev_id; /** Socket ID where memory is allocated */ @@ -82,10 +82,10 @@ struct rte_cryptodev_data { /** PMD-specific private data */ void *dev_private; -} __rte_cache_aligned; +}; /** @internal The data structure associated with each crypto device. */ -struct rte_cryptodev { +struct __rte_cache_aligned rte_cryptodev { /** Pointer to PMD dequeue function. */ dequeue_pkt_burst_t dequeue_burst; /** Pointer to PMD enqueue function. */ @@ -117,7 +117,7 @@ struct rte_cryptodev { struct rte_cryptodev_cb_rcu *enq_cbs; /** User application callback for post dequeue processing */ struct rte_cryptodev_cb_rcu *deq_cbs; -} __rte_cache_aligned; +}; /** Global structure used for maintaining state of allocated crypto devices */ struct rte_cryptodev_global { diff --git a/lib/cryptodev/rte_cryptodev_core.h b/lib/cryptodev/rte_cryptodev_core.h index 5de89d0..8d7e58d 100644 --- a/lib/cryptodev/rte_cryptodev_core.h +++ b/lib/cryptodev/rte_cryptodev_core.h @@ -40,7 +40,7 @@ struct rte_cryptodev_qpdata { struct rte_cryptodev_cb_rcu *deq_cb; }; -struct rte_crypto_fp_ops { +struct __rte_cache_aligned rte_crypto_fp_ops { /** PMD enqueue burst function. */ enqueue_pkt_burst_t enqueue_burst; /** PMD dequeue burst function. */ @@ -49,7 +49,7 @@ struct rte_crypto_fp_ops { struct rte_cryptodev_qpdata qp; /** Reserved for future ops. */ uintptr_t reserved[3]; -} __rte_cache_aligned; +}; extern struct rte_crypto_fp_ops rte_crypto_fp_ops[RTE_CRYPTO_MAX_DEVS]; From patchwork Wed Feb 14 16:36:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 136776 X-Patchwork-Delegate: david.marchand@redhat.com 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 34AD643B38; Wed, 14 Feb 2024 17:38:35 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id ECBD94332C; Wed, 14 Feb 2024 17:36:35 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id C86AC427D7 for ; Wed, 14 Feb 2024 17:36:08 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id E54A120B2024; Wed, 14 Feb 2024 08:36:06 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com E54A120B2024 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1707928567; bh=uaZSjdRmfR6EN5X6/DZpa0boIOUEw73ieP3sA/cEAso=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Bw3qEwp/1XSuaTd0yU/AdaMEKsLqSU+/4NTwGV/hr62tHiex70KsWRFTU/9bH38nF wWeo++ojaixZPLsRpVWHXGg318laq2mekVjJzWOcQ6pFpFWkeOEZ3jTGq1Z7hKFcHA NxW9Uo12FB/9iQH8bE6MINvh1Eyu6llt+aZFvIc0= From: Tyler Retzlaff To: dev@dpdk.org Cc: Andrew Rybchenko , Bruce Richardson , Chengwen Feng , Cristian Dumitrescu , David Christensen , David Hunt , Ferruh Yigit , Honnappa Nagarahalli , Jasvinder Singh , Jerin Jacob , Kevin Laatz , Konstantin Ananyev , Min Zhou , Ruifeng Wang , Sameh Gobriel , Stanislaw Kardach , Thomas Monjalon , Vladimir Medvedkin , Yipeng Wang , Tyler Retzlaff Subject: [PATCH v4 35/39] dispatcher: use C11 alignas Date: Wed, 14 Feb 2024 08:36:00 -0800 Message-Id: <1707928564-28796-36-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1707928564-28796-1-git-send-email-roretzla@linux.microsoft.com> References: <1707873986-29352-1-git-send-email-roretzla@linux.microsoft.com> <1707928564-28796-1-git-send-email-roretzla@linux.microsoft.com> MIME-Version: 1.0 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 * Move __rte_aligned from the end of {struct,union} definitions to be between {struct,union} and tag. The placement between {struct,union} and the tag allows the desired alignment to be imparted on the type regardless of the toolchain being used for all of GCC, LLVM, MSVC compilers building both C and C++. * Replace use of __rte_aligned(a) on variables/fields with alignas(a). Signed-off-by: Tyler Retzlaff Acked-by: Morten Brørup --- lib/dispatcher/rte_dispatcher.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/dispatcher/rte_dispatcher.c b/lib/dispatcher/rte_dispatcher.c index 95dd41b..4061a73 100644 --- a/lib/dispatcher/rte_dispatcher.c +++ b/lib/dispatcher/rte_dispatcher.c @@ -41,14 +41,14 @@ struct rte_dispatcher_finalizer { void *finalize_data; }; -struct rte_dispatcher_lcore { +struct __rte_cache_aligned rte_dispatcher_lcore { uint8_t num_ports; uint16_t num_handlers; int32_t prio_count; struct rte_dispatcher_lcore_port ports[EVD_MAX_PORTS_PER_LCORE]; struct rte_dispatcher_handler handlers[EVD_MAX_HANDLERS]; struct rte_dispatcher_stats stats; -} __rte_cache_aligned; +}; struct rte_dispatcher { uint8_t event_dev_id; From patchwork Wed Feb 14 16:36:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 136781 X-Patchwork-Delegate: david.marchand@redhat.com 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 ACABF43B38; Wed, 14 Feb 2024 17:39:03 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E18CD4335D; Wed, 14 Feb 2024 17:36:41 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id CFF3F42E92 for ; Wed, 14 Feb 2024 17:36:08 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id F38F420B2025; Wed, 14 Feb 2024 08:36:06 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com F38F420B2025 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1707928568; bh=daTBRXCPqyzb5gCT2nvtA2tAKxsnm6RIbE55O2rI1Zo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nejvVNwWW/jCYRg41zg/byoIOzzMmFdvEz5psiYflRKVKr+WhaeEDEbNN8gjs6vM6 JPKjGIGats1UpX+8cgphneaQt9TN29C3F/fARnPk3r3P3Fg1/Q+95/9ko9DHnyTLBP dW1O2uLyJdZR24IUSHpAGNUpGaxQMqjlboyIpTn4= From: Tyler Retzlaff To: dev@dpdk.org Cc: Andrew Rybchenko , Bruce Richardson , Chengwen Feng , Cristian Dumitrescu , David Christensen , David Hunt , Ferruh Yigit , Honnappa Nagarahalli , Jasvinder Singh , Jerin Jacob , Kevin Laatz , Konstantin Ananyev , Min Zhou , Ruifeng Wang , Sameh Gobriel , Stanislaw Kardach , Thomas Monjalon , Vladimir Medvedkin , Yipeng Wang , Tyler Retzlaff Subject: [PATCH v4 36/39] fib: use C11 alignas Date: Wed, 14 Feb 2024 08:36:01 -0800 Message-Id: <1707928564-28796-37-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1707928564-28796-1-git-send-email-roretzla@linux.microsoft.com> References: <1707873986-29352-1-git-send-email-roretzla@linux.microsoft.com> <1707928564-28796-1-git-send-email-roretzla@linux.microsoft.com> MIME-Version: 1.0 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 * Move __rte_aligned from the end of {struct,union} definitions to be between {struct,union} and tag. The placement between {struct,union} and the tag allows the desired alignment to be imparted on the type regardless of the toolchain being used for all of GCC, LLVM, MSVC compilers building both C and C++. * Replace use of __rte_aligned(a) on variables/fields with alignas(a). Signed-off-by: Tyler Retzlaff Acked-by: Morten Brørup --- lib/fib/dir24_8.h | 4 +++- lib/fib/trie.h | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/fib/dir24_8.h b/lib/fib/dir24_8.h index b0d1a40..6d350f7 100644 --- a/lib/fib/dir24_8.h +++ b/lib/fib/dir24_8.h @@ -6,6 +6,8 @@ #ifndef _DIR24_8_H_ #define _DIR24_8_H_ +#include + #include #include @@ -32,7 +34,7 @@ struct dir24_8_tbl { uint64_t *tbl8; /**< tbl8 table. */ uint64_t *tbl8_idxes; /**< bitmap containing free tbl8 idxes*/ /* tbl24 table. */ - __extension__ uint64_t tbl24[0] __rte_cache_aligned; + __extension__ alignas(RTE_CACHE_LINE_SIZE) uint64_t tbl24[0]; }; static inline void * diff --git a/lib/fib/trie.h b/lib/fib/trie.h index 3cf161a..36ce1fd 100644 --- a/lib/fib/trie.h +++ b/lib/fib/trie.h @@ -6,6 +6,8 @@ #ifndef _TRIE_H_ #define _TRIE_H_ +#include + /** * @file * RTE IPv6 Longest Prefix Match (LPM) @@ -36,7 +38,7 @@ struct rte_trie_tbl { uint32_t *tbl8_pool; /**< bitmap containing free tbl8 idxes*/ uint32_t tbl8_pool_pos; /* tbl24 table. */ - __extension__ uint64_t tbl24[0] __rte_cache_aligned; + __extension__ alignas(RTE_CACHE_LINE_SIZE) uint64_t tbl24[0]; }; static inline uint32_t From patchwork Wed Feb 14 16:36:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 136788 X-Patchwork-Delegate: david.marchand@redhat.com 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 5BFF943B38; Wed, 14 Feb 2024 17:39:43 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C42DE4337D; Wed, 14 Feb 2024 17:36:49 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id DE1F2427DF for ; Wed, 14 Feb 2024 17:36:08 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 0E1D620B2026; Wed, 14 Feb 2024 08:36:06 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 0E1D620B2026 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1707928568; bh=6qgzre6ZdwK5cMXrPNM3aaGtJ/Ngzsn5MY2LvqSZ0T8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=h92YJHKsyTprYa5Hm03Now96hT6qF4GnqFU0y/jxvEXJwa7Kmv8vBw6fqL8zXZFDe 3k8ajw3kmBLETYTlH+0pdvSvusfALyrg+uEr4g+jqqH2ALMA5KLPIjyKXeEK1BTGcM 4CKUyRBu5kvL7OZVUbQWmVreJ3EJvl3KpgTMmOAQ= From: Tyler Retzlaff To: dev@dpdk.org Cc: Andrew Rybchenko , Bruce Richardson , Chengwen Feng , Cristian Dumitrescu , David Christensen , David Hunt , Ferruh Yigit , Honnappa Nagarahalli , Jasvinder Singh , Jerin Jacob , Kevin Laatz , Konstantin Ananyev , Min Zhou , Ruifeng Wang , Sameh Gobriel , Stanislaw Kardach , Thomas Monjalon , Vladimir Medvedkin , Yipeng Wang , Tyler Retzlaff Subject: [PATCH v4 37/39] gpudev: use C11 alignas Date: Wed, 14 Feb 2024 08:36:02 -0800 Message-Id: <1707928564-28796-38-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1707928564-28796-1-git-send-email-roretzla@linux.microsoft.com> References: <1707873986-29352-1-git-send-email-roretzla@linux.microsoft.com> <1707928564-28796-1-git-send-email-roretzla@linux.microsoft.com> MIME-Version: 1.0 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 * Move __rte_aligned from the end of {struct,union} definitions to be between {struct,union} and tag. The placement between {struct,union} and the tag allows the desired alignment to be imparted on the type regardless of the toolchain being used for all of GCC, LLVM, MSVC compilers building both C and C++. * Replace use of __rte_aligned(a) on variables/fields with alignas(a). Signed-off-by: Tyler Retzlaff Acked-by: Morten Brørup --- lib/gpudev/gpudev_driver.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/gpudev/gpudev_driver.h b/lib/gpudev/gpudev_driver.h index 0b1e7f2..37b6ae3 100644 --- a/lib/gpudev/gpudev_driver.h +++ b/lib/gpudev/gpudev_driver.h @@ -72,7 +72,7 @@ struct rte_gpu_mpshared { RTE_ATOMIC(uint16_t) process_refcnt; /* Updated by this library. */ }; -struct rte_gpu { +struct __rte_cache_aligned rte_gpu { /* Backing device. */ struct rte_device *device; /* Data shared between processes. */ @@ -85,7 +85,7 @@ struct rte_gpu { enum rte_gpu_state process_state; /* Updated by this library. */ /* Driver-specific private data for the running process. */ void *process_private; -} __rte_cache_aligned; +}; __rte_internal struct rte_gpu *rte_gpu_get_by_name(const char *name); From patchwork Wed Feb 14 16:36:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 136792 X-Patchwork-Delegate: david.marchand@redhat.com 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 5543843B38; Wed, 14 Feb 2024 17:40:05 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 573B94338E; Wed, 14 Feb 2024 17:36:54 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 26EC742E95 for ; Wed, 14 Feb 2024 17:36:09 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 1C2F320B2027; Wed, 14 Feb 2024 08:36:06 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 1C2F320B2027 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1707928568; bh=5c9/vuZQZ+h9YQQEwX5Iv0l18LCKqwfr1HKPBBUBccA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=owFdvvxBDPXs9Y8LYvtMeMRhyV6LckFUa3uTy/QKQkvpvhWbIT5xv3/iu9HPwUmG1 GFVAQ/wwu9SElQG42065Efecrf5paHcrDxY+a8vr2HhNO62GBI/UJjwuWwjVB/JQqf 1b0HUACT0HLdCigu7FNsSG7b/YFjbV3dTNQmtZZI= From: Tyler Retzlaff To: dev@dpdk.org Cc: Andrew Rybchenko , Bruce Richardson , Chengwen Feng , Cristian Dumitrescu , David Christensen , David Hunt , Ferruh Yigit , Honnappa Nagarahalli , Jasvinder Singh , Jerin Jacob , Kevin Laatz , Konstantin Ananyev , Min Zhou , Ruifeng Wang , Sameh Gobriel , Stanislaw Kardach , Thomas Monjalon , Vladimir Medvedkin , Yipeng Wang , Tyler Retzlaff Subject: [PATCH v4 38/39] graph: use C11 alignas Date: Wed, 14 Feb 2024 08:36:03 -0800 Message-Id: <1707928564-28796-39-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1707928564-28796-1-git-send-email-roretzla@linux.microsoft.com> References: <1707873986-29352-1-git-send-email-roretzla@linux.microsoft.com> <1707928564-28796-1-git-send-email-roretzla@linux.microsoft.com> MIME-Version: 1.0 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 * Move __rte_aligned from the end of {struct,union} definitions to be between {struct,union} and tag. The placement between {struct,union} and the tag allows the desired alignment to be imparted on the type regardless of the toolchain being used for all of GCC, LLVM, MSVC compilers building both C and C++. * Replace use of __rte_aligned(a) on variables/fields with alignas(a). Signed-off-by: Tyler Retzlaff Acked-by: Morten Brørup --- lib/graph/graph_private.h | 4 ++-- lib/graph/graph_stats.c | 4 ++-- lib/graph/rte_graph.h | 4 ++-- lib/graph/rte_graph_worker_common.h | 17 ++++++++++------- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/lib/graph/graph_private.h b/lib/graph/graph_private.h index fb88d4b..7e4d9f8 100644 --- a/lib/graph/graph_private.h +++ b/lib/graph/graph_private.h @@ -71,11 +71,11 @@ struct node { * Structure that holds the graph scheduling workqueue node stream. * Used for mcore dispatch model. */ -struct graph_mcore_dispatch_wq_node { +struct __rte_cache_aligned graph_mcore_dispatch_wq_node { rte_graph_off_t node_off; uint16_t nb_objs; void *objs[RTE_GRAPH_BURST_SIZE]; -} __rte_cache_aligned; +}; /** * @internal diff --git a/lib/graph/graph_stats.c b/lib/graph/graph_stats.c index cc32245..2fb808b 100644 --- a/lib/graph/graph_stats.c +++ b/lib/graph/graph_stats.c @@ -28,7 +28,7 @@ struct cluster_node { struct rte_node *nodes[]; }; -struct rte_graph_cluster_stats { +struct __rte_cache_aligned rte_graph_cluster_stats { /* Header */ rte_graph_cluster_stats_cb_t fn; uint32_t cluster_node_size; /* Size of struct cluster_node */ @@ -38,7 +38,7 @@ struct rte_graph_cluster_stats { size_t sz; struct cluster_node clusters[]; -} __rte_cache_aligned; +}; #define boarder_model_dispatch() \ fprintf(f, "+-------------------------------+---------------+--------" \ diff --git a/lib/graph/rte_graph.h b/lib/graph/rte_graph.h index 2d37d5e..ecfec20 100644 --- a/lib/graph/rte_graph.h +++ b/lib/graph/rte_graph.h @@ -200,7 +200,7 @@ struct rte_graph_cluster_stats_param { * * @see struct rte_graph_cluster_stats_param::fn */ -struct rte_graph_cluster_node_stats { +struct __rte_cache_aligned rte_graph_cluster_node_stats { uint64_t ts; /**< Current timestamp. */ uint64_t calls; /**< Current number of calls made. */ uint64_t objs; /**< Current number of objs processed. */ @@ -225,7 +225,7 @@ struct rte_graph_cluster_node_stats { rte_node_t id; /**< Node identifier of stats. */ uint64_t hz; /**< Cycles per seconds. */ char name[RTE_NODE_NAMESIZE]; /**< Name of the node. */ -} __rte_cache_aligned; +}; /** * Create Graph. diff --git a/lib/graph/rte_graph_worker_common.h b/lib/graph/rte_graph_worker_common.h index 4045a7a..36d864e 100644 --- a/lib/graph/rte_graph_worker_common.h +++ b/lib/graph/rte_graph_worker_common.h @@ -12,6 +12,8 @@ * process, enqueue and move streams of objects to the next nodes. */ +#include + #include #include #include @@ -43,7 +45,7 @@ * * Data structure to hold graph data. */ -struct rte_graph { +struct __rte_cache_aligned rte_graph { /* Fast path area. */ uint32_t tail; /**< Tail of circular buffer. */ uint32_t head; /**< Head of circular buffer. */ @@ -57,7 +59,8 @@ struct rte_graph { union { /* Fast schedule area for mcore dispatch model */ struct { - struct rte_graph_rq_head *rq __rte_cache_aligned; /* The run-queue */ + alignas(RTE_CACHE_LINE_SIZE) struct rte_graph_rq_head *rq; + /* The run-queue */ struct rte_graph_rq_head rq_head; /* The head for run-queue list */ unsigned int lcore_id; /**< The graph running Lcore. */ @@ -77,14 +80,14 @@ struct rte_graph { uint64_t nb_pkt_to_capture; char pcap_filename[RTE_GRAPH_PCAP_FILE_SZ]; /**< Pcap filename. */ uint64_t fence; /**< Fence. */ -} __rte_cache_aligned; +}; /** * @internal * * Data structure to hold node data. */ -struct rte_node { +struct __rte_cache_aligned rte_node { /* Slow path area */ uint64_t fence; /**< Fence. */ rte_graph_off_t next; /**< Index to next node. */ @@ -109,7 +112,7 @@ struct rte_node { }; /* Fast path area */ #define RTE_NODE_CTX_SZ 16 - uint8_t ctx[RTE_NODE_CTX_SZ] __rte_cache_aligned; /**< Node Context. */ + alignas(RTE_CACHE_LINE_SIZE) uint8_t ctx[RTE_NODE_CTX_SZ]; /**< Node Context. */ uint16_t size; /**< Total number of objects available. */ uint16_t idx; /**< Number of objects used. */ rte_graph_off_t off; /**< Offset of node in the graph reel. */ @@ -124,8 +127,8 @@ struct rte_node { rte_node_process_t process; /**< Process function. */ uint64_t process_u64; }; - struct rte_node *nodes[] __rte_cache_min_aligned; /**< Next nodes. */ -} __rte_cache_aligned; + alignas(RTE_CACHE_LINE_MIN_SIZE) struct rte_node *nodes[]; /**< Next nodes. */ +}; /** * @internal From patchwork Wed Feb 14 16:36:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 136791 X-Patchwork-Delegate: david.marchand@redhat.com 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 2AEF143B38; Wed, 14 Feb 2024 17:40:00 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 31E2C4338A; Wed, 14 Feb 2024 17:36:53 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 2791042E96 for ; Wed, 14 Feb 2024 17:36:09 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 2AA8720B2028; Wed, 14 Feb 2024 08:36:06 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 2AA8720B2028 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1707928568; bh=IenjYl+j+G49e7Pu/5cpadzcDiBNWi6As6jilqEec2w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MKapVgA9yVs8VYYCE84QWxbUeyZU2S0adq+KCAbVBMPoEifbSqWB9bQ/mA+gX4g8I Z+8UMyO4IeZ1sEHzpZoqlEiyYAu4MBYC4ez7n6G6W01sON7QCI2uc+qsMcR9js2PHQ Cq2VYAsk42TG8WOp0tqilaAtDgBTrFTtsXxsjlTo= From: Tyler Retzlaff To: dev@dpdk.org Cc: Andrew Rybchenko , Bruce Richardson , Chengwen Feng , Cristian Dumitrescu , David Christensen , David Hunt , Ferruh Yigit , Honnappa Nagarahalli , Jasvinder Singh , Jerin Jacob , Kevin Laatz , Konstantin Ananyev , Min Zhou , Ruifeng Wang , Sameh Gobriel , Stanislaw Kardach , Thomas Monjalon , Vladimir Medvedkin , Yipeng Wang , Tyler Retzlaff Subject: [PATCH v4 39/39] ip_frag: use C11 alignas Date: Wed, 14 Feb 2024 08:36:04 -0800 Message-Id: <1707928564-28796-40-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1707928564-28796-1-git-send-email-roretzla@linux.microsoft.com> References: <1707873986-29352-1-git-send-email-roretzla@linux.microsoft.com> <1707928564-28796-1-git-send-email-roretzla@linux.microsoft.com> MIME-Version: 1.0 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 * Move __rte_aligned from the end of {struct,union} definitions to be between {struct,union} and tag. The placement between {struct,union} and the tag allows the desired alignment to be imparted on the type regardless of the toolchain being used for all of GCC, LLVM, MSVC compilers building both C and C++. * Replace use of __rte_aligned(a) on variables/fields with alignas(a). Signed-off-by: Tyler Retzlaff Acked-by: Morten Brørup --- lib/ip_frag/ip_reassembly.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/ip_frag/ip_reassembly.h b/lib/ip_frag/ip_reassembly.h index a9f97ae..5443c73 100644 --- a/lib/ip_frag/ip_reassembly.h +++ b/lib/ip_frag/ip_reassembly.h @@ -47,7 +47,7 @@ struct ip_frag_key { * Fragmented packet to reassemble. * First two entries in the frags[] array are for the last and first fragments. */ -struct ip_frag_pkt { +struct __rte_cache_aligned ip_frag_pkt { RTE_TAILQ_ENTRY(ip_frag_pkt) lru; /* LRU list */ struct ip_frag_key key; /* fragmentation key */ uint64_t start; /* creation timestamp */ @@ -55,20 +55,20 @@ struct ip_frag_pkt { uint32_t frag_size; /* size of fragments received */ uint32_t last_idx; /* index of next entry to fill */ struct ip_frag frags[IP_MAX_FRAG_NUM]; /* fragments */ -} __rte_cache_aligned; +}; /* fragments tailq */ RTE_TAILQ_HEAD(ip_pkt_list, ip_frag_pkt); /* fragmentation table statistics */ -struct ip_frag_tbl_stat { +struct __rte_cache_aligned ip_frag_tbl_stat { uint64_t find_num; /* total # of find/insert attempts. */ uint64_t add_num; /* # of add ops. */ uint64_t del_num; /* # of del ops. */ uint64_t reuse_num; /* # of reuse (del/add) ops. */ uint64_t fail_total; /* total # of add failures. */ uint64_t fail_nospace; /* # of 'no space' add failures. */ -} __rte_cache_aligned; +}; /* fragmentation table */ struct rte_ip_frag_tbl {