From patchwork Mon Mar 4 17:52:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 137924 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 DA74E43B9B; Mon, 4 Mar 2024 18:54:04 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8F81442DF8; Mon, 4 Mar 2024 18:53:05 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 0210940ED0 for ; Mon, 4 Mar 2024 18:52:51 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id A751A20B74CB; Mon, 4 Mar 2024 09:52:50 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com A751A20B74CB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1709574770; bh=Zk+bJLH9MNzqzjXiN9lQpVIC0JIJzH29jqFTwFmqj1U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D1On3FtIOmxAhm4D4kMFfTFEHJwMwsM7A5EZ+N82psxNaLxHuIjKolnT63PIml0hu IpmHaExw3De/NeuRHFdFLwWdmn2T5r6t+OxhkMlbF+sULz9u4keJ7qhIhkziFM1ESK D2dFM/O8gW2pi6O/gysX0EZSnXBbzDnjgzAo8chE= 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 v7 11/39] ethdev: use C11 alignas Date: Mon, 4 Mar 2024 09:52:16 -0800 Message-Id: <1709574764-9041-12-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1709574764-9041-1-git-send-email-roretzla@linux.microsoft.com> References: <1707873986-29352-1-git-send-email-roretzla@linux.microsoft.com> <1709574764-9041-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 The current location used for __rte_aligned(a) for alignment of types and variables is not compatible with MSVC. There is only a single location accepted by both toolchains. For variables standard C11 offers alignas(a) supported by conformant compilers i.e. both MSVC and GCC. For types the standard offers no alignment facility that compatibly interoperates with C and C++ but may be achieved by relocating the placement of __rte_aligned(a) to the aforementioned location accepted by all currently supported toolchains. To allow alignment for both compilers do the following: * 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: Konstantin Ananyev --- lib/ethdev/ethdev_driver.h | 8 ++++---- lib/ethdev/rte_ethdev.h | 16 ++++++++-------- lib/ethdev/rte_ethdev_core.h | 4 ++-- lib/ethdev/rte_flow_driver.h | 4 ++-- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/ethdev/ethdev_driver.h b/lib/ethdev/ethdev_driver.h index 0e4c1f0..bab3a8c 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 */ @@ -93,7 +93,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; @@ -104,7 +104,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 */ @@ -190,7 +190,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 ed27360..2a92953 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. @@ -1836,7 +1836,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. */ @@ -1850,17 +1850,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 @@ -1870,7 +1870,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. */ @@ -1884,7 +1884,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 a18f242..e55fb42 100644 --- a/lib/ethdev/rte_ethdev_core.h +++ b/lib/ethdev/rte_ethdev_core.h @@ -84,7 +84,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 { /**@{*/ /** @@ -124,7 +124,7 @@ struct rte_eth_fp_ops { uintptr_t reserved2[1]; /**@}*/ -} __rte_cache_aligned; +}; extern struct rte_eth_fp_ops rte_eth_fp_ops[RTE_MAX_ETHPORTS]; diff --git a/lib/ethdev/rte_flow_driver.h b/lib/ethdev/rte_flow_driver.h index 3c702e3..506d126 100644 --- a/lib/ethdev/rte_flow_driver.h +++ b/lib/ethdev/rte_flow_driver.h @@ -432,7 +432,7 @@ typedef int (*rte_flow_async_action_list_handle_query_update_t)( * * Fast path async flow functions are held in a flat array, one entry per ethdev. */ -struct rte_flow_fp_ops { +struct __rte_cache_aligned rte_flow_fp_ops { rte_flow_async_create_t async_create; rte_flow_async_create_by_index_t async_create_by_index; rte_flow_async_actions_update_t async_actions_update; @@ -447,7 +447,7 @@ struct rte_flow_fp_ops { rte_flow_async_action_list_handle_create_t async_action_list_handle_create; rte_flow_async_action_list_handle_destroy_t async_action_list_handle_destroy; rte_flow_async_action_list_handle_query_update_t async_action_list_handle_query_update; -} __rte_cache_aligned; +}; /** * @internal