[v2,03/15] net: pack structures when building with MSVC

Message ID 1711580958-20808-4-git-send-email-roretzla@linux.microsoft.com (mailing list archive)
State New
Delegated to: Thomas Monjalon
Headers
Series fix packing of structs when building with MSVC |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Tyler Retzlaff March 27, 2024, 11:09 p.m. UTC
  Add __rte_msvc_pushpack(1) to all __rte_packed structs to cause packing
when building with MSVC.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 lib/net/rte_arp.h      | 2 ++
 lib/net/rte_dtls.h     | 1 +
 lib/net/rte_esp.h      | 2 ++
 lib/net/rte_ether.h    | 1 +
 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_ip.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    | 2 ++
 20 files changed, 42 insertions(+)
  

Patch

diff --git a/lib/net/rte_arp.h b/lib/net/rte_arp.h
index 668cea1..35d68c1 100644
--- a/lib/net/rte_arp.h
+++ b/lib/net/rte_arp.h
@@ -21,6 +21,7 @@ 
 /**
  * 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 4f541df..0c75b06 100644
--- a/lib/net/rte_dtls.h
+++ b/lib/net/rte_dtls.h
@@ -34,6 +34,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 464c513..27c9287 100644
--- a/lib/net/rte_esp.h
+++ b/lib/net/rte_esp.h
@@ -20,6 +20,7 @@ 
 /**
  * ESP Header
  */
+__rte_msvc_pack
 struct rte_esp_hdr {
 	rte_be32_t spi;  /**< Security Parameters Index */
 	rte_be32_t seq;  /**< packet sequence number */
@@ -28,6 +29,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_ether.h b/lib/net/rte_ether.h
index 32ed515..354e3a5 100644
--- a/lib/net/rte_ether.h
+++ b/lib/net/rte_ether.h
@@ -301,6 +301,7 @@  struct __rte_aligned(2) rte_ether_hdr {
  * Contains the 16-bit VLAN Tag Control Identifier and the Ethernet type
  * of the encapsulated frame.
  */
+__rte_msvc_pack
 struct rte_vlan_hdr {
 	rte_be16_t vlan_tci;  /**< Priority (3) + CFI (1) + Identifier Code (12) */
 	rte_be16_t eth_proto; /**< Ethernet type of encapsulated frame. */
diff --git a/lib/net/rte_geneve.h b/lib/net/rte_geneve.h
index 3bbc561..5c02526 100644
--- a/lib/net/rte_geneve.h
+++ b/lib/net/rte_geneve.h
@@ -38,6 +38,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 8da8027..77882e7 100644
--- a/lib/net/rte_gre.h
+++ b/lib/net/rte_gre.h
@@ -27,6 +27,7 @@ 
  * GRE Header
  */
 __extension__
+__rte_msvc_pack
 struct rte_gre_hdr {
 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
 	uint16_t res2:4; /**< Reserved */
@@ -51,6 +52,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;
@@ -59,6 +61,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;
@@ -66,6 +69,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 9849872..26fc80a 100644
--- a/lib/net/rte_gtp.h
+++ b/lib/net/rte_gtp.h
@@ -28,6 +28,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 */
@@ -55,6 +56,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. */
@@ -66,6 +68,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
@@ -89,6 +92,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
@@ -116,6 +120,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 9eab5f9..c4c5d39 100644
--- a/lib/net/rte_ib.h
+++ b/lib/net/rte_ib.h
@@ -26,6 +26,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 4bf64d7..e865db4 100644
--- a/lib/net/rte_icmp.h
+++ b/lib/net/rte_icmp.h
@@ -25,6 +25,7 @@ 
 /**
  * ICMP base header
  */
+__rte_msvc_pack
 struct rte_icmp_base_hdr {
 	uint8_t type;
 	uint8_t code;
@@ -34,6 +35,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;
@@ -45,6 +47,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_ip.h b/lib/net/rte_ip.h
index 0d103d4..908a25c 100644
--- a/lib/net/rte_ip.h
+++ b/lib/net/rte_ip.h
@@ -38,6 +38,7 @@ 
 /**
  * IPv4 Header
  */
+__rte_msvc_pack
 struct rte_ipv4_hdr {
 	__extension__
 	union {
@@ -523,6 +524,7 @@  struct rte_ipv4_hdr {
 /**
  * IPv6 Header
  */
+__rte_msvc_pack
 struct rte_ipv6_hdr {
 	rte_be32_t vtc_flow;	/**< IP version, traffic class & flow label. */
 	rte_be16_t payload_len;	/**< IP payload size, including ext. headers */
@@ -538,6 +540,7 @@  struct rte_ipv6_hdr {
 /**
  * IPv6 Routing Extension Header
  */
+__rte_msvc_pack
 struct rte_ipv6_routing_ext {
 	uint8_t next_hdr;			/**< Protocol, next header. */
 	uint8_t hdr_len;			/**< Header length. */
@@ -783,6 +786,7 @@  struct rte_ipv6_routing_ext {
 #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_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 9cda347..a917013 100644
--- a/lib/net/rte_l2tpv2.h
+++ b/lib/net/rte_l2tpv2.h
@@ -129,6 +129,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) */
@@ -143,6 +144,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) */
@@ -180,6 +182,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) */
@@ -217,6 +220,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 d0cd2f6..54de1bd 100644
--- a/lib/net/rte_macsec.h
+++ b/lib/net/rte_macsec.h
@@ -29,6 +29,7 @@ 
  * MACsec Header (SecTAG)
  */
 __extension__
+__rte_msvc_pack
 struct rte_macsec_hdr {
 	/**
 	 * Tag control information and Association number of secure channel.
@@ -52,6 +53,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 51523e7..d5f6026 100644
--- a/lib/net/rte_mpls.h
+++ b/lib/net/rte_mpls.h
@@ -22,6 +22,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 72ae9a6..6a20ad9 100644
--- a/lib/net/rte_pdcp_hdr.h
+++ b/lib/net/rte_pdcp_hdr.h
@@ -60,6 +60,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 */
@@ -75,6 +76,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 */
@@ -92,6 +94,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 */
@@ -110,6 +113,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 7b86ac4..fde585f 100644
--- a/lib/net/rte_ppp.h
+++ b/lib/net/rte_ppp.h
@@ -21,6 +21,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 965682d..a6cfe8f 100644
--- a/lib/net/rte_sctp.h
+++ b/lib/net/rte_sctp.h
@@ -25,6 +25,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 506ac4e..d11cb2c 100644
--- a/lib/net/rte_tcp.h
+++ b/lib/net/rte_tcp.h
@@ -25,6 +25,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 2eb3c6d..81af4c7 100644
--- a/lib/net/rte_tls.h
+++ b/lib/net/rte_tls.h
@@ -32,6 +32,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 6135494..5416855 100644
--- a/lib/net/rte_udp.h
+++ b/lib/net/rte_udp.h
@@ -25,6 +25,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 997fc78..bcfd579 100644
--- a/lib/net/rte_vxlan.h
+++ b/lib/net/rte_vxlan.h
@@ -31,6 +31,7 @@ 
  * Reserved fields (24 bits and 8 bits)
  */
 __extension__ /* no named member in struct */
+__rte_msvc_pack
 struct rte_vxlan_hdr {
 	union {
 		struct {
@@ -57,6 +58,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 {