From: Tyler Retzlaff <roret...@linux.microsoft.com>

Add __rte_msvc_pack to all __rte_packed structs to cause packing
when building with MSVC.

Signed-off-by: Tyler Retzlaff <roret...@linux.microsoft.com>
---
 lib/net/rte_arp.h      | 2 ++
 lib/net/rte_dtls.h     | 1 +
 lib/net/rte_esp.h      | 2 ++
 lib/net/rte_geneve.h   | 1 +
 lib/net/rte_gre.h      | 4 ++++
 lib/net/rte_gtp.h      | 5 +++++
 lib/net/rte_ib.h       | 1 +
 lib/net/rte_icmp.h     | 3 +++
 lib/net/rte_ip4.h      | 1 +
 lib/net/rte_ip6.h      | 4 ++++
 lib/net/rte_l2tpv2.h   | 4 ++++
 lib/net/rte_macsec.h   | 2 ++
 lib/net/rte_mpls.h     | 1 +
 lib/net/rte_pdcp_hdr.h | 4 ++++
 lib/net/rte_ppp.h      | 1 +
 lib/net/rte_sctp.h     | 1 +
 lib/net/rte_tcp.h      | 1 +
 lib/net/rte_tls.h      | 1 +
 lib/net/rte_udp.h      | 1 +
 lib/net/rte_vxlan.h    | 7 +++++++
 20 files changed, 47 insertions(+)

diff --git a/lib/net/rte_arp.h b/lib/net/rte_arp.h
index 668cea1704..35d68c108d 100644
--- a/lib/net/rte_arp.h
+++ b/lib/net/rte_arp.h
@@ -21,6 +21,7 @@ extern "C" {
 /**
  * ARP header IPv4 payload.
  */
+__rte_msvc_pack
 struct __rte_aligned(2) rte_arp_ipv4 {
        struct rte_ether_addr arp_sha;  /**< sender hardware address */
        rte_be32_t            arp_sip;  /**< sender IP address */
@@ -31,6 +32,7 @@ struct __rte_aligned(2) rte_arp_ipv4 {
 /**
  * ARP header.
  */
+__rte_msvc_pack
 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 */
diff --git a/lib/net/rte_dtls.h b/lib/net/rte_dtls.h
index 246cd8a72d..a6243a2791 100644
--- a/lib/net/rte_dtls.h
+++ b/lib/net/rte_dtls.h
@@ -30,6 +30,7 @@
  * DTLS Header
  */
 __extension__
+__rte_msvc_pack
 struct rte_dtls_hdr {
        /** Content type of DTLS packet. Defined as RTE_DTLS_TYPE_*. */
        uint8_t type;
diff --git a/lib/net/rte_esp.h b/lib/net/rte_esp.h
index 745a9847fe..ff7b5fe585 100644
--- a/lib/net/rte_esp.h
+++ b/lib/net/rte_esp.h
@@ -16,6 +16,7 @@
 /**
  * ESP Header
  */
+__rte_msvc_pack
 struct rte_esp_hdr {
        rte_be32_t spi;  /**< Security Parameters Index */
        rte_be32_t seq;  /**< packet sequence number */
@@ -24,6 +25,7 @@ struct rte_esp_hdr {
 /**
  * ESP Trailer
  */
+__rte_msvc_pack
 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 */
diff --git a/lib/net/rte_geneve.h b/lib/net/rte_geneve.h
index eb2c85f1e9..8bea7d288b 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_msvc_pack
 struct rte_geneve_hdr {
 #if RTE_BYTE_ORDER == RTE_BIG_ENDIAN
        uint8_t ver:2;          /**< Version. */
diff --git a/lib/net/rte_gre.h b/lib/net/rte_gre.h
index 1483e1b42d..48bd5b1621 100644
--- a/lib/net/rte_gre.h
+++ b/lib/net/rte_gre.h
@@ -23,6 +23,7 @@
  * GRE Header
  */
 __extension__
+__rte_msvc_pack
 struct rte_gre_hdr {
 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
        uint16_t res2:4; /**< Reserved */
@@ -47,6 +48,7 @@ struct rte_gre_hdr {
 /**
  * Optional field checksum in GRE header
  */
+__rte_msvc_pack
 struct rte_gre_hdr_opt_checksum_rsvd {
        rte_be16_t checksum;
        rte_be16_t reserved1;
@@ -55,6 +57,7 @@ struct rte_gre_hdr_opt_checksum_rsvd {
 /**
  * Optional field key in GRE header
  */
+__rte_msvc_pack
 struct rte_gre_hdr_opt_key {
        rte_be32_t key;
 } __rte_packed;
@@ -62,6 +65,7 @@ struct rte_gre_hdr_opt_key {
 /**
  * Optional field sequence in GRE header
  */
+__rte_msvc_pack
 struct rte_gre_hdr_opt_sequence {
        rte_be32_t sequence;
 } __rte_packed;
diff --git a/lib/net/rte_gtp.h b/lib/net/rte_gtp.h
index ab06e23a6e..09d7d8e3a9 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_msvc_pack
 struct rte_gtp_hdr {
        union {
                uint8_t gtp_hdr_info; /**< GTP header info */
@@ -51,6 +52,7 @@ struct rte_gtp_hdr {
 } __rte_packed;
 
 /* Optional word of GTP header, present if any of E, S, PN is set. */
+__rte_msvc_pack
 struct rte_gtp_hdr_ext_word {
        rte_be16_t sqn;       /**< Sequence Number. */
        uint8_t npdu;         /**< N-PDU number. */
@@ -62,6 +64,7 @@ struct rte_gtp_hdr_ext_word {
  * defined based on RFC 38415-g30.
  */
 __extension__
+__rte_msvc_pack
 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
@@ -85,6 +88,7 @@ struct rte_gtp_psc_generic_hdr {
  * type0 defined based on RFC 38415-g30
  */
 __extension__
+__rte_msvc_pack
 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
@@ -112,6 +116,7 @@ struct rte_gtp_psc_type0_hdr {
  * type1 defined based on RFC 38415-g30
  */
 __extension__
+__rte_msvc_pack
 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
diff --git a/lib/net/rte_ib.h b/lib/net/rte_ib.h
index a551f3753f..eaa97dff31 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_msvc_pack
 struct rte_ib_bth {
        uint8_t opcode;         /**< Opcode. */
 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
diff --git a/lib/net/rte_icmp.h b/lib/net/rte_icmp.h
index e69d68ab6e..63b21c051b 100644
--- a/lib/net/rte_icmp.h
+++ b/lib/net/rte_icmp.h
@@ -21,6 +21,7 @@
 /**
  * ICMP base header
  */
+__rte_msvc_pack
 struct rte_icmp_base_hdr {
        uint8_t type;
        uint8_t code;
@@ -30,6 +31,7 @@ struct rte_icmp_base_hdr {
 /**
  * ICMP echo header
  */
+__rte_msvc_pack
 struct rte_icmp_echo_hdr {
        struct rte_icmp_base_hdr base;
        rte_be16_t identifier;
@@ -41,6 +43,7 @@ struct rte_icmp_echo_hdr {
  *
  * @see rte_icmp_echo_hdr which is similar.
  */
+__rte_msvc_pack
 struct rte_icmp_hdr {
        uint8_t  icmp_type;     /* ICMP packet type. */
        uint8_t  icmp_code;     /* ICMP packet code. */
diff --git a/lib/net/rte_ip4.h b/lib/net/rte_ip4.h
index f9b8333332..f1ec24a8d1 100644
--- a/lib/net/rte_ip4.h
+++ b/lib/net/rte_ip4.h
@@ -39,6 +39,7 @@ extern "C" {
 /**
  * IPv4 Header
  */
+__rte_msvc_pack
 struct __rte_aligned(2) rte_ipv4_hdr {
        __extension__
        union {
diff --git a/lib/net/rte_ip6.h b/lib/net/rte_ip6.h
index 992ab5ee1f..cab8d40f2b 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_msvc_pack
 enum rte_ipv6_mc_scope {
        /** Invalid multicast scope. */
        RTE_IPV6_MC_SCOPE_NONE = 0x00,
@@ -461,6 +462,7 @@ rte_ether_mcast_from_ipv6(struct rte_ether_addr *mac, const 
struct rte_ipv6_addr
 /**
  * IPv6 Header
  */
+__rte_msvc_pack
 struct __rte_aligned(2) rte_ipv6_hdr {
        union {
                rte_be32_t vtc_flow;        /**< IP version, traffic class & 
flow label. */
@@ -508,6 +510,7 @@ static inline int rte_ipv6_check_version(const struct 
rte_ipv6_hdr *ip)
 /**
  * IPv6 Routing Extension Header
  */
+__rte_msvc_pack
 struct __rte_aligned(2) rte_ipv6_routing_ext {
        uint8_t next_hdr;                       /**< Protocol, next header. */
        uint8_t hdr_len;                        /**< Header length. */
@@ -752,6 +755,7 @@ 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_msvc_pack
 struct __rte_aligned(2) rte_ipv6_fragment_ext {
        uint8_t next_header;    /**< Next header type */
        uint8_t reserved;       /**< Reserved */
diff --git a/lib/net/rte_l2tpv2.h b/lib/net/rte_l2tpv2.h
index ac16657856..b34431581a 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_msvc_pack
 struct rte_l2tpv2_msg_with_all_options {
        rte_be16_t length;              /**< length(16) */
        rte_be16_t tunnel_id;           /**< tunnel ID(16) */
@@ -139,6 +140,7 @@ struct rte_l2tpv2_msg_with_all_options {
  * L2TPv2 message Header contains all options except length(ns, nr,
  * offset size, offset padding).
  */
+__rte_msvc_pack
 struct rte_l2tpv2_msg_without_length {
        rte_be16_t tunnel_id;           /**< tunnel ID(16) */
        rte_be16_t session_id;          /**< session ID(16) */
@@ -176,6 +178,7 @@ struct rte_l2tpv2_msg_without_offset {
 /**
  * L2TPv2 message Header contains options offset size and offset padding.
  */
+__rte_msvc_pack
 struct rte_l2tpv2_msg_with_offset {
        rte_be16_t tunnel_id;           /**< tunnel ID(16) */
        rte_be16_t session_id;          /**< session ID(16) */
@@ -213,6 +216,7 @@ struct rte_l2tpv2_msg_without_all_options {
 /**
  * L2TPv2 Combined Message Header Format: Common Header + Options
  */
+__rte_msvc_pack
 struct rte_l2tpv2_combined_msg_hdr {
        struct rte_l2tpv2_common_hdr common; /**< common header */
        union {
diff --git a/lib/net/rte_macsec.h b/lib/net/rte_macsec.h
index beeeb8effe..11c0c2e38c 100644
--- a/lib/net/rte_macsec.h
+++ b/lib/net/rte_macsec.h
@@ -25,6 +25,7 @@
  * MACsec Header (SecTAG)
  */
 __extension__
+__rte_msvc_pack
 struct rte_macsec_hdr {
        /**
         * Tag control information and Association number of secure channel.
@@ -48,6 +49,7 @@ 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_msvc_pack
 struct rte_macsec_sci_hdr {
        uint8_t sci[RTE_MACSEC_SCI_LEN]; /**< Optional secure channel ID. */
 } __rte_packed;
diff --git a/lib/net/rte_mpls.h b/lib/net/rte_mpls.h
index 35a356efd3..184a569a6b 100644
--- a/lib/net/rte_mpls.h
+++ b/lib/net/rte_mpls.h
@@ -18,6 +18,7 @@
  * MPLS header.
  */
 __extension__
+__rte_msvc_pack
 struct rte_mpls_hdr {
        rte_be16_t tag_msb; /**< Label(msb). */
 #if RTE_BYTE_ORDER == RTE_BIG_ENDIAN
diff --git a/lib/net/rte_pdcp_hdr.h b/lib/net/rte_pdcp_hdr.h
index c22b66bf93..5a7c11e784 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_msvc_pack
 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 */
@@ -71,6 +72,7 @@ struct rte_pdcp_cp_data_pdu_sn_12_hdr {
  * 6.2.2.2 Data PDU for DRBs and MRBs with 12 bits PDCP SN
  */
 __extension__
+__rte_msvc_pack
 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 */
@@ -88,6 +90,7 @@ struct rte_pdcp_up_data_pdu_sn_12_hdr {
  * 6.2.2.3 Data PDU for DRBs and MRBs with 18 bits PDCP SN
  */
 __extension__
+__rte_msvc_pack
 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 */
@@ -106,6 +109,7 @@ struct rte_pdcp_up_data_pdu_sn_18_hdr {
  * 6.2.3.1 Control PDU for PDCP status report
  */
 __extension__
+__rte_msvc_pack
 struct rte_pdcp_up_ctrl_pdu_hdr {
 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
        uint8_t r : 4;          /**< Reserved */
diff --git a/lib/net/rte_ppp.h b/lib/net/rte_ppp.h
index 63c72a9392..bf91295e92 100644
--- a/lib/net/rte_ppp.h
+++ b/lib/net/rte_ppp.h
@@ -17,6 +17,7 @@
 /**
  * PPP Header
  */
+__rte_msvc_pack
 struct rte_ppp_hdr {
        uint8_t addr; /**< PPP address(8) */
        uint8_t ctrl; /**< PPP control(8) */
diff --git a/lib/net/rte_sctp.h b/lib/net/rte_sctp.h
index e757c57db3..4379836c5c 100644
--- a/lib/net/rte_sctp.h
+++ b/lib/net/rte_sctp.h
@@ -21,6 +21,7 @@
 /**
  * SCTP Header
  */
+__rte_msvc_pack
 struct rte_sctp_hdr {
        rte_be16_t src_port; /**< Source port. */
        rte_be16_t dst_port; /**< Destin port. */
diff --git a/lib/net/rte_tcp.h b/lib/net/rte_tcp.h
index 1bcacbf038..3f5a37b9b0 100644
--- a/lib/net/rte_tcp.h
+++ b/lib/net/rte_tcp.h
@@ -21,6 +21,7 @@
 /**
  * TCP Header
  */
+__rte_msvc_pack
 struct rte_tcp_hdr {
        rte_be16_t src_port; /**< TCP source port. */
        rte_be16_t dst_port; /**< TCP destination port. */
diff --git a/lib/net/rte_tls.h b/lib/net/rte_tls.h
index 595567e3e9..094f722c12 100644
--- a/lib/net/rte_tls.h
+++ b/lib/net/rte_tls.h
@@ -28,6 +28,7 @@
  * TLS Header
  */
 __extension__
+__rte_msvc_pack
 struct rte_tls_hdr {
        /** Content type of TLS packet. Defined as RTE_TLS_TYPE_*. */
        uint8_t type;
diff --git a/lib/net/rte_udp.h b/lib/net/rte_udp.h
index c01dad9c9b..6de76e0199 100644
--- a/lib/net/rte_udp.h
+++ b/lib/net/rte_udp.h
@@ -21,6 +21,7 @@
 /**
  * UDP Header
  */
+__rte_msvc_pack
 struct rte_udp_hdr {
        rte_be16_t src_port;    /**< UDP source port. */
        rte_be16_t dst_port;    /**< UDP destination port. */
diff --git a/lib/net/rte_vxlan.h b/lib/net/rte_vxlan.h
index bd1c89835e..17367f1343 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_msvc_pack
 struct rte_vxlan_hdr {
        union {
                rte_be32_t vx_flags; /**< flags (8 bits) + extensions (24 
bits). */
+               __rte_msvc_pack
                struct {
                        union {
                                uint8_t flags; /**< Default is I bit, others 
are extensions. */
+                               __rte_msvc_pack
                                struct {
 #if RTE_BYTE_ORDER == RTE_BIG_ENDIAN
                                        uint8_t flag_g:1,     /**< GBP bit. */
@@ -55,6 +58,7 @@ struct rte_vxlan_hdr {
                        }; /* end of 1st byte */
                        union {
                                uint8_t rsvd0[3]; /* Reserved for extensions. */
+                               __rte_msvc_pack
                                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_msvc_pack
                                                struct {
                                                        uint8_t rsvd0_gpe; /* 
Reserved. */
                                                        uint8_t proto; /**< GPE 
Next protocol. */
@@ -87,6 +92,7 @@ struct rte_vxlan_hdr {
        }; /* end of 1st 32-bit word */
        union {
                rte_be32_t vx_vni; /**< VNI (24 bits) + reserved (8 bits). */
+               __rte_msvc_pack
                struct {
                        uint8_t    vni[3];   /**< VXLAN Identifier. */
                        union {
@@ -111,6 +117,7 @@ struct rte_vxlan_hdr {
  * Identifier and Reserved fields (16 bits and 8 bits).
  */
 __extension__ /* no named member in struct */
+__rte_msvc_pack
 struct rte_vxlan_gpe_hdr {
        union {
                struct {
-- 
2.47.0.vfs.0.3

Reply via email to