From patchwork Tue Apr 16 00:05:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 139412 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 23AFE43E80; Tue, 16 Apr 2024 02:06:42 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C3B1C40E96; Tue, 16 Apr 2024 02:05:43 +0200 (CEST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id DF5A04027F for ; Tue, 16 Apr 2024 02:05:16 +0200 (CEST) Received: by linux.microsoft.com (Postfix, from userid 1086) id B71C320FD463; Mon, 15 Apr 2024 17:05:15 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com B71C320FD463 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1713225915; bh=1L1f/WbzBRlO5juzTnvoc0NadRn8LVJ/ugRGM7ikz9o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NKepIjAk+ywFz0w5EH7fp9FwTJH+T5rJ8/rH6U2kEzT9aTW3uaNeE2ynZEp361vIM ri0E+iRiI9q1Ez6BhBN47c7rZ8Q5Ru5tVhRuNNKLK6NVbv1FEJORivdJy5P05p3AN5 zd1QGInJ/OMnODyDuhlvf5P4Hisnz6Od52/nBvAA= From: Tyler Retzlaff To: dev@dpdk.org Cc: Akhil Goyal , Aman Singh , Anatoly Burakov , Bruce Richardson , Byron Marohn , Conor Walsh , Cristian Dumitrescu , Dariusz Sosnowski , David Hunt , Jerin Jacob , Jingjing Wu , Kirill Rybalchenko , Konstantin Ananyev , Matan Azrad , Ori Kam , Radu Nicolau , Ruifeng Wang , Sameh Gobriel , Sivaprasad Tummala , Suanming Mou , Sunil Kumar Kori , Vamsi Attunuru , Viacheslav Ovsiienko , Vladimir Medvedkin , Yipeng Wang , Yuying Zhang , Yuying Zhang , Tyler Retzlaff Subject: [PATCH v4 15/16] examples: pack structures when building with MSVC Date: Mon, 15 Apr 2024 17:05:12 -0700 Message-Id: <1713225913-20792-16-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1713225913-20792-1-git-send-email-roretzla@linux.microsoft.com> References: <1710968771-16435-1-git-send-email-roretzla@linux.microsoft.com> <1713225913-20792-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 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 | 2 ++ examples/ptpclient/ptpclient.c | 8 ++++++++ 5 files changed, 17 insertions(+), 5 deletions(-) diff --git a/examples/common/neon/port_group.h b/examples/common/neon/port_group.h index 421e2e8..bd40590 100644 --- a/examples/common/neon/port_group.h +++ b/examples/common/neon/port_group.h @@ -21,6 +21,7 @@ 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 e8269ea..aad6c78 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 { uint8_t da[16]; uint16_t sp; uint16_t dp; -} __rte_packed; +}; struct pkt_key_ipv4_addr { uint32_t addr; -} __rte_packed; +}; struct pkt_key_ipv6_addr { uint8_t addr[16]; -} __rte_packed; +}; static uint32_t parse_match(char **tokens, diff --git a/examples/ipsec-secgw/ipsec.h b/examples/ipsec-secgw/ipsec.h index bdcada1..bdc6045 100644 --- a/examples/ipsec-secgw/ipsec.h +++ b/examples/ipsec-secgw/ipsec.h @@ -277,6 +277,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 f4adcf4..a3be37b 100644 --- a/examples/l3fwd-power/main.c +++ b/examples/l3fwd-power/main.c @@ -278,6 +278,7 @@ struct lcore_rx_queue { #define DEFAULT_HASH_FUNC rte_jhash #endif +__rte_msvc_pack struct ipv4_5tuple { uint32_t ip_dst; uint32_t ip_src; @@ -286,6 +287,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 afb61bb..cdd73fd 100644 --- a/examples/ptpclient/ptpclient.c +++ b/examples/ptpclient/ptpclient.c @@ -56,6 +56,7 @@ }; /* Structs used for PTP handling. */ +__rte_msvc_pack struct tstamp { uint16_t sec_msb; uint32_t sec_lsb; @@ -66,11 +67,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; @@ -86,22 +89,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; @@ -110,6 +117,7 @@ struct delay_resp_msg { } __rte_packed; struct ptp_message { + __rte_msvc_pack union { struct ptp_header header; struct sync_msg sync;