From patchwork Wed Feb 14 07:05:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 136712 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 391FA43B27; Wed, 14 Feb 2024 08:07:12 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0FCD442F33; Wed, 14 Feb 2024 08:06:35 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id D5461406B4 for ; Wed, 14 Feb 2024 08:06:25 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 75B7D20B2006; Tue, 13 Feb 2024 23:06:24 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 75B7D20B2006 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1707894384; bh=LERLlTdmESOTaXD3Yfe4cirTnlsTl7iyJ/2nbvkVelI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Uuh3TXip3SkqRtssse4E4qVcKnFff31ZXr+HMgwSXONSQ6WEBXvTMhnS6H6/2NJRD 8KwI4InZtNaDjg6axYNZrSNPTCqYfQ7ZmgTMgDuN48DMTJ8bjqA4gqtFzWG7eyely5 Z4Tka1D703q+krYTh5FE/Tglzxgwk3jnMqiZS7f0= 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 v3 06/39] pipeline: use C11 alignas Date: Tue, 13 Feb 2024 23:05:49 -0800 Message-Id: <1707894382-307-7-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1707894382-307-1-git-send-email-roretzla@linux.microsoft.com> References: <1707873986-29352-1-git-send-email-roretzla@linux.microsoft.com> <1707894382-307-1-git-send-email-roretzla@linux.microsoft.com> X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org * 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 --- 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)