From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2C8DB45D3C; Tue, 19 Nov 2024 05:37:54 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EC9EB427DC; Tue, 19 Nov 2024 05:36:35 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id EF9C34067E for ; Tue, 19 Nov 2024 05:36:16 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1213) id 3AAC923717FF; Mon, 18 Nov 2024 20:36:14 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 3AAC923717FF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1731990975; bh=uggjLS8/ozZrgV+e412FKi0SqwEiAR2EZurwyr4uDpo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HMD9nU5hyYBYnGx6OqpSDABOE9Op9Ce0KNUILGcarFMOXXOLjkJi63kNlofKdeY0I 5FRwAwxQ64zJ5IB1ZFQ+limkKAywEyrjkAr77GIdH7rY+8Gpe+lLgttQKjxyiw8EDY ySxaYQEfPYY+gf8cnMYIACFYovl0VqIrxCFGw6LY= From: Andre Muezerie To: roretzla@linux.microsoft.com Cc: Yuying.Zhang@intel.com, aman.deep.singh@intel.com, anatoly.burakov@intel.com, bruce.richardson@intel.com, byron.marohn@intel.com, conor.walsh@intel.com, cristian.dumitrescu@intel.com, david.hunt@intel.com, dev@dpdk.org, dsosnowski@nvidia.com, gakhil@marvell.com, jerinj@marvell.com, jingjing.wu@intel.com, kirill.rybalchenko@intel.com, konstantin.v.ananyev@yandex.ru, matan@nvidia.com, orika@nvidia.com, radu.nicolau@intel.com, ruifeng.wang@arm.com, sameh.gobriel@intel.com, sivaprasad.tummala@amd.com, skori@marvell.com, stephen@networkplumber.org, suanmingm@nvidia.com, vattunuru@marvell.com, viacheslavo@nvidia.com, vladimir.medvedkin@intel.com, yipeng1.wang@intel.com Subject: [PATCH v5 15/16] examples: pack structures when building with MSVC Date: Mon, 18 Nov 2024 20:35:40 -0800 Message-Id: <1731990941-10001-16-git-send-email-andremue@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1731990941-10001-1-git-send-email-andremue@linux.microsoft.com> References: <1710968771-16435-1-git-send-email-roretzla@linux.microsoft.com> <1731990941-10001-1-git-send-email-andremue@linux.microsoft.com> X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Tyler Retzlaff Add __rte_msvc_pack to all __rte_packed structs to cause packing when building with MSVC. Remove __rte_packed where it appears natural alignment without packing would produce the same layout or the struct is internal. Signed-off-by: Tyler Retzlaff --- examples/common/neon/port_group.h | 1 + examples/ip_pipeline/cli.c | 10 +++++----- examples/ipsec-secgw/ipsec.h | 1 + examples/l3fwd-power/main.c | 4 +++- examples/l3fwd/l3fwd_route.h | 2 ++ examples/ptpclient/ptpclient.c | 8 ++++++++ examples/vhost_blk/blk_spec.h | 1 + 7 files changed, 21 insertions(+), 6 deletions(-) diff --git a/examples/common/neon/port_group.h b/examples/common/neon/port_group.h index 421e2e8613..bd40590418 100644 --- a/examples/common/neon/port_group.h +++ b/examples/common/neon/port_group.h @@ -21,6 +21,7 @@ static inline uint16_t * port_groupx4(uint16_t pn[FWDSTEP + 1], uint16_t *lp, uint16x8_t dp1, uint16x8_t dp2) { + __rte_msvc_pack union { uint16_t u16[FWDSTEP + 1]; uint64_t u64; diff --git a/examples/ip_pipeline/cli.c b/examples/ip_pipeline/cli.c index 92dfacdeb0..766fc8e46e 100644 --- a/examples/ip_pipeline/cli.c +++ b/examples/ip_pipeline/cli.c @@ -2571,7 +2571,7 @@ struct pkt_key_qinq { uint16_t svlan; uint16_t ethertype_cvlan; uint16_t cvlan; -} __rte_packed; +}; struct pkt_key_ipv4_5tuple { uint8_t time_to_live; @@ -2581,7 +2581,7 @@ struct pkt_key_ipv4_5tuple { uint32_t da; uint16_t sp; uint16_t dp; -} __rte_packed; +}; struct pkt_key_ipv6_5tuple { uint16_t payload_length; @@ -2591,15 +2591,15 @@ struct pkt_key_ipv6_5tuple { struct rte_ipv6_addr da; uint16_t sp; uint16_t dp; -} __rte_packed; +}; struct pkt_key_ipv4_addr { uint32_t addr; -} __rte_packed; +}; struct pkt_key_ipv6_addr { struct rte_ipv6_addr addr; -} __rte_packed; +}; static uint32_t parse_match(char **tokens, diff --git a/examples/ipsec-secgw/ipsec.h b/examples/ipsec-secgw/ipsec.h index f12f57e2d5..dc146bccb8 100644 --- a/examples/ipsec-secgw/ipsec.h +++ b/examples/ipsec-secgw/ipsec.h @@ -274,6 +274,7 @@ struct socket_ctx { struct rte_mempool *session_pool; }; +__rte_msvc_pack struct cnt_blk { uint32_t salt; uint64_t iv; diff --git a/examples/l3fwd-power/main.c b/examples/l3fwd-power/main.c index ae8b55924e..ce3c901b45 100644 --- a/examples/l3fwd-power/main.c +++ b/examples/l3fwd-power/main.c @@ -282,7 +282,8 @@ static struct rte_mempool * pktmbuf_pool[NB_SOCKETS]; #define DEFAULT_HASH_FUNC rte_jhash #endif -struct ipv4_5tuple { +__rte_msvc_pack +__rte_msvc_packstruct ipv4_5tuple { uint32_t ip_dst; uint32_t ip_src; uint16_t port_dst; @@ -290,6 +291,7 @@ struct ipv4_5tuple { uint8_t proto; } __rte_packed; +__rte_msvc_pack struct ipv6_5tuple { uint8_t ip_dst[IPV6_ADDR_LEN]; uint8_t ip_src[IPV6_ADDR_LEN]; diff --git a/examples/l3fwd/l3fwd_route.h b/examples/l3fwd/l3fwd_route.h index 62263c3540..8c7be4b9d6 100644 --- a/examples/l3fwd/l3fwd_route.h +++ b/examples/l3fwd/l3fwd_route.h @@ -36,6 +36,7 @@ struct ipv6_l3fwd_route { uint8_t if_out; }; +__rte_msvc_pack struct ipv4_5tuple { uint32_t ip_dst; uint32_t ip_src; @@ -44,6 +45,7 @@ struct ipv4_5tuple { uint8_t proto; } __rte_packed; +__rte_msvc_pack struct ipv6_5tuple { uint8_t ip_dst[IPV6_ADDR_LEN]; uint8_t ip_src[IPV6_ADDR_LEN]; diff --git a/examples/ptpclient/ptpclient.c b/examples/ptpclient/ptpclient.c index 23fa487081..d7caad41d3 100644 --- a/examples/ptpclient/ptpclient.c +++ b/examples/ptpclient/ptpclient.c @@ -85,6 +85,7 @@ static const struct rte_ether_addr ether_multicast = { }; /* Structs used for PTP handling. */ +__rte_msvc_pack struct tstamp { uint16_t sec_msb; uint32_t sec_lsb; @@ -95,11 +96,13 @@ struct clock_id { uint8_t id[8]; }; +__rte_msvc_pack struct port_id { struct clock_id clock_id; uint16_t port_number; } __rte_packed; +__rte_msvc_pack struct ptp_header { uint8_t msg_type; uint8_t ver; @@ -115,22 +118,26 @@ struct ptp_header { int8_t log_message_interval; } __rte_packed; +__rte_msvc_pack struct sync_msg { struct ptp_header hdr; struct tstamp origin_tstamp; } __rte_packed; +__rte_msvc_pack struct follow_up_msg { struct ptp_header hdr; struct tstamp precise_origin_tstamp; uint8_t suffix[]; } __rte_packed; +__rte_msvc_pack struct delay_req_msg { struct ptp_header hdr; struct tstamp origin_tstamp; } __rte_packed; +__rte_msvc_pack struct delay_resp_msg { struct ptp_header hdr; struct tstamp rx_tstamp; @@ -139,6 +146,7 @@ struct delay_resp_msg { } __rte_packed; struct ptp_message { + __rte_msvc_pack union { struct ptp_header header; struct sync_msg sync; diff --git a/examples/vhost_blk/blk_spec.h b/examples/vhost_blk/blk_spec.h index 3c54f70eaf..3dc0681551 100644 --- a/examples/vhost_blk/blk_spec.h +++ b/examples/vhost_blk/blk_spec.h @@ -73,6 +73,7 @@ struct vhost_memory_padded { struct vhost_memory_region regions[VHOST_USER_MEMORY_MAX_NREGIONS]; }; +__rte_msvc_pack struct vhost_user_msg { enum vhost_user_request request; -- 2.47.0.vfs.0.3