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 6610B45F25; Mon, 23 Dec 2024 20:14:17 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id ACEDC40A6E; Mon, 23 Dec 2024 20:12:45 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 8E93B402D7 for ; Mon, 23 Dec 2024 20:12:16 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1213) id EBC29206ADE9; Mon, 23 Dec 2024 11:12:14 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com EBC29206ADE9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1734981135; bh=IOW4IZfejbX15f0ldn+kapJ8HCGHXyXvKjdIhweStzU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XX9q6rs3RNwi9T0h90UgCrisIhY9iTog6gD+VvOoyul21yINgOpM3lcvESU55gDtb cBdbqv6crv6onxw0HEETFWknXEVWAmGQ5Eh+WRsgf3EwpwcoKu/ZwXVhcckLqnyvZy GaL1t/ff5Wb9yQxxgDnLQKVgdF/Pt2dLguO9zRYo= From: Andre Muezerie To: roretzla@linux.microsoft.com Cc: 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, Andre Muezerie Subject: [PATCH v7 27/29] lib/net: replace packed attributes Date: Mon, 23 Dec 2024 11:12:00 -0800 Message-Id: <1734981122-4729-28-git-send-email-andremue@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1734981122-4729-1-git-send-email-andremue@linux.microsoft.com> References: <1710968771-16435-1-git-send-email-roretzla@linux.microsoft.com> <1734981122-4729-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 MSVC struct packing is not compatible with GCC. Replace macro __rte_packed with __rte_packed_begin to push existing pack value and set packing to 1-byte and macro __rte_packed_end to restore the pack value prior to the push. Macro __rte_packed_end is deliberately utilized to trigger a MSVC compiler warning if no existing packing has been pushed allowing easy identification of locations where the __rte_packed_begin is missing. Signed-off-by: Andre Muezerie --- lib/net/rte_arp.h | 6 ++++-- lib/net/rte_dtls.h | 3 ++- lib/net/rte_esp.h | 6 ++++-- lib/net/rte_geneve.h | 3 ++- lib/net/rte_gre.h | 12 ++++++++---- lib/net/rte_gtp.h | 15 ++++++++++----- lib/net/rte_ib.h | 3 ++- lib/net/rte_icmp.h | 9 ++++++--- lib/net/rte_ip4.h | 3 ++- lib/net/rte_ip6.h | 12 ++++++++---- lib/net/rte_l2tpv2.h | 12 ++++++++---- lib/net/rte_macsec.h | 6 ++++-- lib/net/rte_mpls.h | 3 ++- lib/net/rte_pdcp_hdr.h | 12 ++++++++---- lib/net/rte_ppp.h | 3 ++- lib/net/rte_sctp.h | 3 ++- lib/net/rte_tcp.h | 3 ++- lib/net/rte_tls.h | 3 ++- lib/net/rte_udp.h | 3 ++- lib/net/rte_vxlan.h | 21 ++++++++++++++------- 20 files changed, 94 insertions(+), 47 deletions(-) diff --git a/lib/net/rte_arp.h b/lib/net/rte_arp.h index 668cea1704..4032dd72a5 100644 --- a/lib/net/rte_arp.h +++ b/lib/net/rte_arp.h @@ -21,16 +21,18 @@ extern "C" { /** * ARP header IPv4 payload. */ +__rte_packed_begin 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_packed_end; /** * ARP header. */ +__rte_packed_begin 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 +49,7 @@ struct __rte_aligned(2) rte_arp_hdr { #define RTE_ARP_OP_INVREPLY 9 /**< response identifying peer */ struct rte_arp_ipv4 arp_data; -} __rte_packed; +} __rte_packed_end; /** * Make a RARP packet based on MAC addr. diff --git a/lib/net/rte_dtls.h b/lib/net/rte_dtls.h index 246cd8a72d..a341b2155e 100644 --- a/lib/net/rte_dtls.h +++ b/lib/net/rte_dtls.h @@ -30,6 +30,7 @@ * DTLS Header */ __extension__ +__rte_packed_begin struct rte_dtls_hdr { /** Content type of DTLS packet. Defined as RTE_DTLS_TYPE_*. */ uint8_t type; @@ -48,6 +49,6 @@ struct rte_dtls_hdr { #endif /** The length (in bytes) of the following DTLS packet. */ rte_be16_t length; -} __rte_packed; +} __rte_packed_end; #endif /* RTE_DTLS_H */ diff --git a/lib/net/rte_esp.h b/lib/net/rte_esp.h index 745a9847fe..156e26ec0a 100644 --- a/lib/net/rte_esp.h +++ b/lib/net/rte_esp.h @@ -16,17 +16,19 @@ /** * ESP Header */ +__rte_packed_begin struct rte_esp_hdr { rte_be32_t spi; /**< Security Parameters Index */ rte_be32_t seq; /**< packet sequence number */ -} __rte_packed; +} __rte_packed_end; /** * ESP Trailer */ +__rte_packed_begin struct rte_esp_tail { uint8_t pad_len; /**< number of pad bytes (0-255) */ uint8_t next_proto; /**< IPv4 or IPv6 or next layer header */ -} __rte_packed; +} __rte_packed_end; #endif /* RTE_ESP_H_ */ diff --git a/lib/net/rte_geneve.h b/lib/net/rte_geneve.h index eb2c85f1e9..66489c524e 100644 --- a/lib/net/rte_geneve.h +++ b/lib/net/rte_geneve.h @@ -34,6 +34,7 @@ * More-bits (optional) variable length options. */ __extension__ +__rte_packed_begin struct rte_geneve_hdr { #if RTE_BYTE_ORDER == RTE_BIG_ENDIAN uint8_t ver:2; /**< Version. */ @@ -52,7 +53,7 @@ struct rte_geneve_hdr { uint8_t vni[3]; /**< Virtual network identifier. */ uint8_t reserved2; /**< Reserved. */ uint32_t opts[]; /**< Variable length options. */ -} __rte_packed; +} __rte_packed_end; /* GENEVE ETH next protocol types */ #define RTE_GENEVE_TYPE_ETH 0x6558 /**< Ethernet Protocol. */ diff --git a/lib/net/rte_gre.h b/lib/net/rte_gre.h index 1483e1b42d..d9e70c43c6 100644 --- a/lib/net/rte_gre.h +++ b/lib/net/rte_gre.h @@ -23,6 +23,7 @@ * GRE Header */ __extension__ +__rte_packed_begin struct rte_gre_hdr { #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN uint16_t res2:4; /**< Reserved */ @@ -42,28 +43,31 @@ struct rte_gre_hdr { uint16_t ver:3; /**< Version Number */ #endif rte_be16_t proto; /**< Protocol Type */ -} __rte_packed; +} __rte_packed_end; /** * Optional field checksum in GRE header */ +__rte_packed_begin struct rte_gre_hdr_opt_checksum_rsvd { rte_be16_t checksum; rte_be16_t reserved1; -} __rte_packed; +} __rte_packed_end; /** * Optional field key in GRE header */ +__rte_packed_begin struct rte_gre_hdr_opt_key { rte_be32_t key; -} __rte_packed; +} __rte_packed_end; /** * Optional field sequence in GRE header */ +__rte_packed_begin struct rte_gre_hdr_opt_sequence { rte_be32_t sequence; -} __rte_packed; +} __rte_packed_end; #endif /* RTE_GRE_H_ */ diff --git a/lib/net/rte_gtp.h b/lib/net/rte_gtp.h index ab06e23a6e..e2d3711304 100644 --- a/lib/net/rte_gtp.h +++ b/lib/net/rte_gtp.h @@ -24,6 +24,7 @@ * No optional fields and next extension header. */ __extension__ +__rte_packed_begin struct rte_gtp_hdr { union { uint8_t gtp_hdr_info; /**< GTP header info */ @@ -48,20 +49,22 @@ struct rte_gtp_hdr { uint8_t msg_type; /**< GTP message type */ rte_be16_t plen; /**< Total payload length */ rte_be32_t teid; /**< Tunnel endpoint ID */ -} __rte_packed; +} __rte_packed_end; /* Optional word of GTP header, present if any of E, S, PN is set. */ +__rte_packed_begin struct rte_gtp_hdr_ext_word { rte_be16_t sqn; /**< Sequence Number. */ uint8_t npdu; /**< N-PDU number. */ uint8_t next_ext; /**< Next Extension Header Type. */ -} __rte_packed; +} __rte_packed_end; /** * Optional extension for GTP with next_ext set to 0x85 * defined based on RFC 38415-g30. */ __extension__ +__rte_packed_begin struct rte_gtp_psc_generic_hdr { uint8_t ext_hdr_len; /**< PDU ext hdr len in multiples of 4 bytes */ #if RTE_BYTE_ORDER == RTE_BIG_ENDIAN @@ -78,13 +81,14 @@ struct rte_gtp_psc_generic_hdr { uint8_t spare:2; /**< type specific spare bits */ #endif uint8_t data[0]; /**< variable length data fields */ -} __rte_packed; +} __rte_packed_end; /** * Optional extension for GTP with next_ext set to 0x85 * type0 defined based on RFC 38415-g30 */ __extension__ +__rte_packed_begin struct rte_gtp_psc_type0_hdr { uint8_t ext_hdr_len; /**< PDU ext hdr len in multiples of 4 bytes */ #if RTE_BYTE_ORDER == RTE_BIG_ENDIAN @@ -105,13 +109,14 @@ struct rte_gtp_psc_type0_hdr { uint8_t ppp:1; /**< Paging policy presence */ #endif uint8_t data[0]; /**< variable length data fields */ -} __rte_packed; +} __rte_packed_end; /** * Optional extension for GTP with next_ext set to 0x85 * type1 defined based on RFC 38415-g30 */ __extension__ +__rte_packed_begin struct rte_gtp_psc_type1_hdr { uint8_t ext_hdr_len; /**< PDU ext hdr len in multiples of 4 bytes */ #if RTE_BYTE_ORDER == RTE_BIG_ENDIAN @@ -134,7 +139,7 @@ struct rte_gtp_psc_type1_hdr { uint8_t n_delay_ind:1; /**< N3/N9 delay result presence */ #endif uint8_t data[0]; /**< variable length data fields */ -} __rte_packed; +} __rte_packed_end; /** GTP header length */ #define RTE_ETHER_GTP_HLEN \ diff --git a/lib/net/rte_ib.h b/lib/net/rte_ib.h index a551f3753f..989d9d53b3 100644 --- a/lib/net/rte_ib.h +++ b/lib/net/rte_ib.h @@ -22,6 +22,7 @@ * IB Specification Vol 1-Release-1.4. */ __extension__ +__rte_packed_begin struct rte_ib_bth { uint8_t opcode; /**< Opcode. */ #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN @@ -54,7 +55,7 @@ struct rte_ib_bth { uint8_t rsvd1:7; /**< Reserved. */ #endif uint8_t psn[3]; /**< Packet Sequence Number */ -} __rte_packed; +} __rte_packed_end; /** RoCEv2 default port. */ #define RTE_ROCEV2_DEFAULT_PORT 4791 diff --git a/lib/net/rte_icmp.h b/lib/net/rte_icmp.h index e69d68ab6e..912d79a1cf 100644 --- a/lib/net/rte_icmp.h +++ b/lib/net/rte_icmp.h @@ -21,33 +21,36 @@ /** * ICMP base header */ +__rte_packed_begin struct rte_icmp_base_hdr { uint8_t type; uint8_t code; rte_be16_t checksum; -} __rte_packed; +} __rte_packed_end; /** * ICMP echo header */ +__rte_packed_begin struct rte_icmp_echo_hdr { struct rte_icmp_base_hdr base; rte_be16_t identifier; rte_be16_t sequence; -} __rte_packed; +} __rte_packed_end; /** * ICMP Header * * @see rte_icmp_echo_hdr which is similar. */ +__rte_packed_begin struct rte_icmp_hdr { uint8_t icmp_type; /* ICMP packet type. */ uint8_t icmp_code; /* ICMP packet code. */ rte_be16_t icmp_cksum; /* ICMP packet checksum. */ rte_be16_t icmp_ident; /* ICMP packet identifier. */ rte_be16_t icmp_seq_nb; /* ICMP packet sequence number. */ -} __rte_packed; +} __rte_packed_end; /* ICMP packet types */ #define RTE_ICMP_TYPE_ECHO_REPLY 0 diff --git a/lib/net/rte_ip4.h b/lib/net/rte_ip4.h index f9b8333332..30bbe1541d 100644 --- a/lib/net/rte_ip4.h +++ b/lib/net/rte_ip4.h @@ -39,6 +39,7 @@ extern "C" { /** * IPv4 Header */ +__rte_packed_begin struct __rte_aligned(2) rte_ipv4_hdr { __extension__ union { @@ -62,7 +63,7 @@ struct __rte_aligned(2) rte_ipv4_hdr { rte_be16_t hdr_checksum; /**< header checksum */ rte_be32_t src_addr; /**< source address */ rte_be32_t dst_addr; /**< destination address */ -} __rte_packed; +} __rte_packed_end; /** Create IPv4 address */ #define RTE_IPV4(a, b, c, d) ((uint32_t)(((a) & 0xff) << 24) | \ diff --git a/lib/net/rte_ip6.h b/lib/net/rte_ip6.h index 992ab5ee1f..c92753b3f2 100644 --- a/lib/net/rte_ip6.h +++ b/lib/net/rte_ip6.h @@ -345,6 +345,7 @@ rte_ipv6_addr_is_mcast(const struct rte_ipv6_addr *ip) /** * IPv6 multicast scope values as defined in RFC 4291, section 2.7. */ +__rte_packed_begin enum rte_ipv6_mc_scope { /** Invalid multicast scope. */ RTE_IPV6_MC_SCOPE_NONE = 0x00, @@ -358,7 +359,7 @@ enum rte_ipv6_mc_scope { RTE_IPV6_MC_SCOPE_ORGLOCAL = 0x08, /** Global multicast scope. */ RTE_IPV6_MC_SCOPE_GLOBAL = 0x0e, -} __rte_packed; +} __rte_packed_end; /** * Extract the IPv6 multicast scope value as defined in RFC 4291, section 2.7. @@ -461,6 +462,7 @@ rte_ether_mcast_from_ipv6(struct rte_ether_addr *mac, const struct rte_ipv6_addr /** * IPv6 Header */ +__rte_packed_begin struct __rte_aligned(2) rte_ipv6_hdr { union { rte_be32_t vtc_flow; /**< IP version, traffic class & flow label. */ @@ -484,7 +486,7 @@ struct __rte_aligned(2) rte_ipv6_hdr { uint8_t hop_limits; /**< Hop limits. */ struct rte_ipv6_addr src_addr; /**< IP address of source host. */ struct rte_ipv6_addr dst_addr; /**< IP address of destination host(s). */ -} __rte_packed; +} __rte_packed_end; /** * Check that the IPv6 header version field is valid according to RFC 8200 section 3. @@ -508,6 +510,7 @@ static inline int rte_ipv6_check_version(const struct rte_ipv6_hdr *ip) /** * IPv6 Routing Extension Header */ +__rte_packed_begin struct __rte_aligned(2) rte_ipv6_routing_ext { uint8_t next_hdr; /**< Protocol, next header. */ uint8_t hdr_len; /**< Header length. */ @@ -523,7 +526,7 @@ struct __rte_aligned(2) rte_ipv6_routing_ext { }; }; /* Next are 128-bit IPv6 address fields to describe segments. */ -} __rte_packed; +} __rte_packed_end; /* IPv6 vtc_flow: IPv / TC / flow_label */ #define RTE_IPV6_HDR_FL_SHIFT 0 @@ -752,12 +755,13 @@ rte_ipv6_udptcp_cksum_mbuf_verify(const struct rte_mbuf *m, #define RTE_IPV6_SET_FRAG_DATA(fo, mf) \ (((fo) & RTE_IPV6_EHDR_FO_MASK) | ((mf) & RTE_IPV6_EHDR_MF_MASK)) +__rte_packed_begin struct __rte_aligned(2) rte_ipv6_fragment_ext { uint8_t next_header; /**< Next header type */ uint8_t reserved; /**< Reserved */ rte_be16_t frag_data; /**< All fragmentation data */ rte_be32_t id; /**< Packet ID */ -} __rte_packed; +} __rte_packed_end; /* IPv6 fragment extension header size */ #define RTE_IPV6_FRAG_HDR_SIZE sizeof(struct rte_ipv6_fragment_ext) diff --git a/lib/net/rte_l2tpv2.h b/lib/net/rte_l2tpv2.h index ac16657856..f035a0d5b3 100644 --- a/lib/net/rte_l2tpv2.h +++ b/lib/net/rte_l2tpv2.h @@ -125,6 +125,7 @@ struct rte_l2tpv2_common_hdr { * L2TPv2 message Header contains all options(length, ns, nr, * offset size, offset padding). */ +__rte_packed_begin struct rte_l2tpv2_msg_with_all_options { rte_be16_t length; /**< length(16) */ rte_be16_t tunnel_id; /**< tunnel ID(16) */ @@ -133,12 +134,13 @@ struct rte_l2tpv2_msg_with_all_options { rte_be16_t nr; /**< Nr(16) */ rte_be16_t offset_size; /**< offset size(16) */ uint8_t *offset_padding; /**< offset padding(variable length) */ -} __rte_packed; +} __rte_packed_end; /** * L2TPv2 message Header contains all options except length(ns, nr, * offset size, offset padding). */ +__rte_packed_begin struct rte_l2tpv2_msg_without_length { rte_be16_t tunnel_id; /**< tunnel ID(16) */ rte_be16_t session_id; /**< session ID(16) */ @@ -146,7 +148,7 @@ struct rte_l2tpv2_msg_without_length { rte_be16_t nr; /**< Nr(16) */ rte_be16_t offset_size; /**< offset size(16) */ uint8_t *offset_padding; /**< offset padding(variable length) */ -} __rte_packed; +} __rte_packed_end; /** * L2TPv2 message Header contains all options except ns_nr(length, @@ -176,12 +178,13 @@ struct rte_l2tpv2_msg_without_offset { /** * L2TPv2 message Header contains options offset size and offset padding. */ +__rte_packed_begin struct rte_l2tpv2_msg_with_offset { rte_be16_t tunnel_id; /**< tunnel ID(16) */ rte_be16_t session_id; /**< session ID(16) */ rte_be16_t offset_size; /**< offset size(16) */ uint8_t *offset_padding; /**< offset padding(variable length) */ -} __rte_packed; +} __rte_packed_end; /** * L2TPv2 message Header contains options ns and nr. @@ -213,6 +216,7 @@ struct rte_l2tpv2_msg_without_all_options { /** * L2TPv2 Combined Message Header Format: Common Header + Options */ +__rte_packed_begin struct rte_l2tpv2_combined_msg_hdr { struct rte_l2tpv2_common_hdr common; /**< common header */ union { @@ -233,6 +237,6 @@ struct rte_l2tpv2_combined_msg_hdr { /** header without all options */ struct rte_l2tpv2_msg_without_all_options type7; }; -} __rte_packed; +} __rte_packed_end; #endif /* _RTE_L2TPV2_H_ */ diff --git a/lib/net/rte_macsec.h b/lib/net/rte_macsec.h index beeeb8effe..088f60417e 100644 --- a/lib/net/rte_macsec.h +++ b/lib/net/rte_macsec.h @@ -25,6 +25,7 @@ * MACsec Header (SecTAG) */ __extension__ +__rte_packed_begin struct rte_macsec_hdr { /** * Tag control information and Association number of secure channel. @@ -39,7 +40,7 @@ struct rte_macsec_hdr { uint8_t short_length:6; /**< Short Length. */ #endif rte_be32_t packet_number; /**< Packet number to support replay protection. */ -} __rte_packed; +} __rte_packed_end; /** SCI length in MACsec header if present. */ #define RTE_MACSEC_SCI_LEN 8 @@ -48,8 +49,9 @@ struct rte_macsec_hdr { * MACsec SCI header (8 bytes) after the MACsec header * which is present if SC bit is set in tci_an. */ +__rte_packed_begin struct rte_macsec_sci_hdr { uint8_t sci[RTE_MACSEC_SCI_LEN]; /**< Optional secure channel ID. */ -} __rte_packed; +} __rte_packed_end; #endif /* RTE_MACSEC_H */ diff --git a/lib/net/rte_mpls.h b/lib/net/rte_mpls.h index 35a356efd3..a5dda16db7 100644 --- a/lib/net/rte_mpls.h +++ b/lib/net/rte_mpls.h @@ -18,6 +18,7 @@ * MPLS header. */ __extension__ +__rte_packed_begin struct rte_mpls_hdr { rte_be16_t tag_msb; /**< Label(msb). */ #if RTE_BYTE_ORDER == RTE_BIG_ENDIAN @@ -30,6 +31,6 @@ struct rte_mpls_hdr { uint8_t tag_lsb:4; /**< label(lsb) */ #endif uint8_t ttl; /**< Time to live. */ -} __rte_packed; +} __rte_packed_end; #endif /* RTE_MPLS_H_ */ diff --git a/lib/net/rte_pdcp_hdr.h b/lib/net/rte_pdcp_hdr.h index c22b66bf93..e05fcf83f2 100644 --- a/lib/net/rte_pdcp_hdr.h +++ b/lib/net/rte_pdcp_hdr.h @@ -56,6 +56,7 @@ enum rte_pdcp_pdu_type { * 6.2.2.1 Data PDU for SRBs */ __extension__ +__rte_packed_begin struct rte_pdcp_cp_data_pdu_sn_12_hdr { #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN uint8_t sn_11_8 : 4; /**< Sequence number bits 8-11 */ @@ -65,12 +66,13 @@ struct rte_pdcp_cp_data_pdu_sn_12_hdr { uint8_t sn_11_8 : 4; /**< Sequence number bits 8-11 */ #endif uint8_t sn_7_0; /**< Sequence number bits 0-7 */ -} __rte_packed; +} __rte_packed_end; /** * 6.2.2.2 Data PDU for DRBs and MRBs with 12 bits PDCP SN */ __extension__ +__rte_packed_begin struct rte_pdcp_up_data_pdu_sn_12_hdr { #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN uint8_t sn_11_8 : 4; /**< Sequence number bits 8-11 */ @@ -82,12 +84,13 @@ struct rte_pdcp_up_data_pdu_sn_12_hdr { uint8_t sn_11_8 : 4; /**< Sequence number bits 8-11 */ #endif uint8_t sn_7_0; /**< Sequence number bits 0-7 */ -} __rte_packed; +} __rte_packed_end; /** * 6.2.2.3 Data PDU for DRBs and MRBs with 18 bits PDCP SN */ __extension__ +__rte_packed_begin struct rte_pdcp_up_data_pdu_sn_18_hdr { #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN uint8_t sn_17_16 : 2; /**< Sequence number bits 16-17 */ @@ -100,12 +103,13 @@ struct rte_pdcp_up_data_pdu_sn_18_hdr { #endif uint8_t sn_15_8; /**< Sequence number bits 8-15 */ uint8_t sn_7_0; /**< Sequence number bits 0-7 */ -} __rte_packed; +} __rte_packed_end; /** * 6.2.3.1 Control PDU for PDCP status report */ __extension__ +__rte_packed_begin struct rte_pdcp_up_ctrl_pdu_hdr { #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN uint8_t r : 4; /**< Reserved */ @@ -134,6 +138,6 @@ struct rte_pdcp_up_ctrl_pdu_hdr { * in the Bitmap is 1. */ uint8_t bitmap[]; -} __rte_packed; +} __rte_packed_end; #endif /* RTE_PDCP_HDR_H */ diff --git a/lib/net/rte_ppp.h b/lib/net/rte_ppp.h index 63c72a9392..bda693a1e7 100644 --- a/lib/net/rte_ppp.h +++ b/lib/net/rte_ppp.h @@ -17,10 +17,11 @@ /** * PPP Header */ +__rte_packed_begin struct rte_ppp_hdr { uint8_t addr; /**< PPP address(8) */ uint8_t ctrl; /**< PPP control(8) */ rte_be16_t proto_id; /**< PPP protocol identifier(16) */ -} __rte_packed; +} __rte_packed_end; #endif /* _RTE_PPP_H_ */ diff --git a/lib/net/rte_sctp.h b/lib/net/rte_sctp.h index e757c57db3..f9dfac2ba7 100644 --- a/lib/net/rte_sctp.h +++ b/lib/net/rte_sctp.h @@ -21,11 +21,12 @@ /** * SCTP Header */ +__rte_packed_begin struct rte_sctp_hdr { rte_be16_t src_port; /**< Source port. */ rte_be16_t dst_port; /**< Destin port. */ rte_be32_t tag; /**< Validation tag. */ rte_be32_t cksum; /**< Checksum. */ -} __rte_packed; +} __rte_packed_end; #endif /* RTE_SCTP_H_ */ diff --git a/lib/net/rte_tcp.h b/lib/net/rte_tcp.h index 1bcacbf038..218599f790 100644 --- a/lib/net/rte_tcp.h +++ b/lib/net/rte_tcp.h @@ -21,6 +21,7 @@ /** * TCP Header */ +__rte_packed_begin struct rte_tcp_hdr { rte_be16_t src_port; /**< TCP source port. */ rte_be16_t dst_port; /**< TCP destination port. */ @@ -31,7 +32,7 @@ struct rte_tcp_hdr { rte_be16_t rx_win; /**< RX flow control window. */ rte_be16_t cksum; /**< TCP checksum. */ rte_be16_t tcp_urp; /**< TCP urgent pointer, if any. */ -} __rte_packed; +} __rte_packed_end; /** * TCP Flags diff --git a/lib/net/rte_tls.h b/lib/net/rte_tls.h index 595567e3e9..33411f83f2 100644 --- a/lib/net/rte_tls.h +++ b/lib/net/rte_tls.h @@ -28,6 +28,7 @@ * TLS Header */ __extension__ +__rte_packed_begin struct rte_tls_hdr { /** Content type of TLS packet. Defined as RTE_TLS_TYPE_*. */ uint8_t type; @@ -35,6 +36,6 @@ struct rte_tls_hdr { rte_be16_t version; /** The length (in bytes) of the following TLS packet. */ rte_be16_t length; -} __rte_packed; +} __rte_packed_end; #endif /* RTE_TLS_H */ diff --git a/lib/net/rte_udp.h b/lib/net/rte_udp.h index c01dad9c9b..548a063dab 100644 --- a/lib/net/rte_udp.h +++ b/lib/net/rte_udp.h @@ -21,11 +21,12 @@ /** * UDP Header */ +__rte_packed_begin struct rte_udp_hdr { rte_be16_t src_port; /**< UDP source port. */ rte_be16_t dst_port; /**< UDP destination port. */ rte_be16_t dgram_len; /**< UDP datagram length */ rte_be16_t dgram_cksum; /**< UDP datagram checksum */ -} __rte_packed; +} __rte_packed_end; #endif /* RTE_UDP_H_ */ diff --git a/lib/net/rte_vxlan.h b/lib/net/rte_vxlan.h index bd1c89835e..f54e4206b6 100644 --- a/lib/net/rte_vxlan.h +++ b/lib/net/rte_vxlan.h @@ -27,12 +27,15 @@ * Reserved fields (24 bits and 8 bits) */ __extension__ /* no named member in struct */ +__rte_packed_begin struct rte_vxlan_hdr { union { rte_be32_t vx_flags; /**< flags (8 bits) + extensions (24 bits). */ + __rte_packed_begin struct { union { uint8_t flags; /**< Default is I bit, others are extensions. */ + __rte_packed_begin struct { #if RTE_BYTE_ORDER == RTE_BIG_ENDIAN uint8_t flag_g:1, /**< GBP bit. */ @@ -51,10 +54,11 @@ struct rte_vxlan_hdr { flag_rsvd:1, flag_g:1; #endif - } __rte_packed; + } __rte_packed_end; }; /* end of 1st byte */ union { uint8_t rsvd0[3]; /* Reserved for extensions. */ + __rte_packed_begin struct { #if RTE_BYTE_ORDER == RTE_BIG_ENDIAN uint8_t rsvd0_gbp1:1, /* Reserved. */ @@ -71,6 +75,7 @@ struct rte_vxlan_hdr { #endif union { uint16_t policy_id; /**< GBP Identifier. */ + __rte_packed_begin struct { uint8_t rsvd0_gpe; /* Reserved. */ uint8_t proto; /**< GPE Next protocol. */ @@ -79,23 +84,24 @@ struct rte_vxlan_hdr { * 0x03 : Ethernet * 0x04 : Network Service Header */ - } __rte_packed; + } __rte_packed_end; }; - } __rte_packed; + } __rte_packed_end; }; - } __rte_packed; + } __rte_packed_end; }; /* end of 1st 32-bit word */ union { rte_be32_t vx_vni; /**< VNI (24 bits) + reserved (8 bits). */ + __rte_packed_begin struct { uint8_t vni[3]; /**< VXLAN Identifier. */ union { uint8_t rsvd1; /**< Reserved. */ uint8_t last_rsvd; /**< Reserved. */ }; - } __rte_packed; + } __rte_packed_end; }; /* end of 2nd 32-bit word */ -} __rte_packed; +} __rte_packed_end; /** VXLAN tunnel header length. */ #define RTE_ETHER_VXLAN_HLEN \ @@ -111,6 +117,7 @@ struct rte_vxlan_hdr { * Identifier and Reserved fields (16 bits and 8 bits). */ __extension__ /* no named member in struct */ +__rte_packed_begin struct rte_vxlan_gpe_hdr { union { struct { @@ -127,7 +134,7 @@ struct rte_vxlan_gpe_hdr { uint8_t rsvd1; /**< Reserved. */ }; }; -} __rte_packed; +} __rte_packed_end; /** * @deprecated -- 2.47.0.vfs.0.3