Skip to contentSkip to conversation

fix packing of structs when building with MSVC

PATCH Superseded Tyler Retzlaff 9 participants 318 messages Mar 20, 2024 – Jan 15, 2025 Page 1 of 4

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

cover fix packing of structs when building with MSVC

MSVC struct packing is not compatible with GCC provide a macro that can be used to push existing pack value and sets packing to 1-byte. The existing __rte_packed macro is then used to restore the pack value prior to the push.

Instead of providing macros exclusively for MSVC and for GCC the existing macro is deliberately utilized to trigger a warning if no existing packing has been pushed allowing easy identification of locations where the __rte_msvc_pack is missing.

I've decided to only add the macro to packed structs that are built for Windows. It seems there is little value in adding the macro tree wide and if new code arrives that is built on Windows the __rte_packed will flag where the preamble macro is required.

Tyler Retzlaff (15):
eal: provide pack start macro for MSVC
eal: pack structures when building with MSVC
net: pack structures when building with MSVC common/iavf: pack structures when building with MSVC common/idpf: pack structures when building with MSVC common/mlx5: pack structures when building with MSVC dma/ioat: pack structures when building with MSVC net/i40e: pack structures when building with MSVC net/iavf: pack structures when building with MSVC net/ice: pack structures when building with MSVC net/mlx5: pack structures when building with MSVC net/octeon_ep: pack structures when building with MSVC app/testpmd: pack structures when building with MSVC app/test: pack structures when building with MSVC
examples: pack structures when building with MSVC

 app/test-pmd/csumonly.c                     |  1 +
 app/test/test_efd.c                         |  1 +
 app/test/test_hash.c                        |  1 +
 app/test/test_member.c                      |  1 +
 drivers/common/iavf/iavf_osdep.h            |  2 ++
 drivers/common/iavf/virtchnl_inline_ipsec.h | 11 +++++++++++
 drivers/common/idpf/base/idpf_osdep.h       |  2 ++
 drivers/common/mlx5/mlx5_common_mr.h        |  4 ++++
 drivers/common/mlx5/mlx5_common_utils.h     |  1 +
 drivers/common/mlx5/mlx5_prm.h              | 28 ++++++++++++++++++++++++++++
 drivers/dma/ioat/ioat_hw_defs.h             |  1 +
 drivers/net/i40e/base/i40e_osdep.h          |  2 ++
 drivers/net/iavf/iavf_ipsec_crypto.h        |  3 +++
 drivers/net/iavf/iavf_rxtx.c                |  1 +
 drivers/net/ice/base/ice_osdep.h            |  2 ++
 drivers/net/mlx5/hws/mlx5dr.h               |  1 +
 drivers/net/mlx5/mlx5.h                     |  1 +
 drivers/net/mlx5/mlx5_flow.h                |  5 +++++
 drivers/net/mlx5/mlx5_hws_cnt.h             |  1 +
 drivers/net/mlx5/mlx5_utils.h               |  4 ++++
 drivers/net/octeon_ep/otx_ep_mbox.h         |  1 +
 examples/common/neon/port_group.h           |  1 +
 examples/ip_pipeline/cli.c                  |  5 +++++
 examples/ipsec-secgw/ipsec.h                |  1 +
 examples/l3fwd-power/main.c                 |  2 ++
 examples/ptpclient/ptpclient.c              |  8 ++++++++
 lib/eal/common/eal_private.h                |  1 +
 lib/eal/include/rte_common.h                |  4 +++-
 lib/eal/include/rte_memory.h                |  1 +
 lib/eal/include/rte_memzone.h               |  1 +
 lib/eal/include/rte_trace_point.h           |  1 +
 lib/eal/x86/include/rte_memcpy.h            |  3 +++
 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 ++
 52 files changed, 143 insertions(+), 1 deletion(-)
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH 1/15 eal: provide pack start macro for MSVC

MSVC struct packing is not compatible with GCC provide a macro that can be used to push existing pack value and sets packing to 1-byte. The existing __rte_packed macro is then used to restore the pack value prior to the push.

Instead of providing macros exclusively for MSVC and for GCC the existing macro is deliberately utilized to trigger a warning if no existing packing has been pushed allowing easy identification of locations where the __rte_msvc_pack is missing.

---
 lib/eal/include/rte_common.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
lib/eal/include/rte_common.h +3 -1
index 298a5c6..44825ed 100644
@@ -97,8 +97,10 @@
  * Force a structure to be packed
  */
 #ifdef RTE_TOOLCHAIN_MSVC
-#define __rte_packed
+#define __rte_msvc_pack __pragma(pack(push, 1))
+#define __rte_packed __pragma(pack(pop))
 #else
+#define __rte_msvc_pack
 #define __rte_packed __attribute__((__packed__))
 #endif
 
Signature · 1 line
1.8.3.1
#2 lore raw

PATCH 2/15 eal: pack structures when building with MSVC

In reply to Tyler Retzlaff

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

---
 lib/eal/common/eal_private.h      | 1 +
 lib/eal/include/rte_memory.h      | 1 +
 lib/eal/include/rte_memzone.h     | 1 +
 lib/eal/include/rte_trace_point.h | 1 +
 lib/eal/x86/include/rte_memcpy.h  | 3 +++
 5 files changed, 7 insertions(+)
lib/eal/common/eal_private.h +1 -0
index 71523cf..21ace2a 100644
@@ -43,6 +43,7 @@ struct lcore_config {
 /**
  * The global RTE configuration structure.
  */
+__rte_msvc_pack
 struct rte_config {
 	uint32_t main_lcore;         /**< Id of the main lcore */
 	uint32_t lcore_count;        /**< Number of available logical cores. */
lib/eal/include/rte_memory.h +1 -0
index 842362d..73bb00d 100644
@@ -46,6 +46,7 @@
 /**
  * Physical memory segment descriptor.
  */
+__rte_msvc_pack
 struct rte_memseg {
 	rte_iova_t iova;            /**< Start IO address. */
 	union {
lib/eal/include/rte_memzone.h +1 -0
index 931497f..ca312c0 100644
@@ -45,6 +45,7 @@
  * A structure describing a memzone, which is a contiguous portion of
  * physical memory identified by a name.
  */
+__rte_msvc_pack
 struct rte_memzone {
 
 #define RTE_MEMZONE_NAMESIZE 32       /**< Maximum length of memory zone name.*/
lib/eal/include/rte_trace_point.h +1 -0
index 41e2a7f..63f333c 100644
@@ -292,6 +292,7 @@ int __rte_trace_point_register(rte_trace_point_t *trace, const char *name,
 #define __RTE_TRACE_FIELD_ENABLE_MASK (1ULL << 63)
 #define __RTE_TRACE_FIELD_ENABLE_DISCARD (1ULL << 62)
 
+__rte_msvc_pack
 struct __rte_trace_stream_header {
 	uint32_t magic;
 	rte_uuid_t uuid;
lib/eal/x86/include/rte_memcpy.h +3 -0
index 72a9229..fdc5df0 100644
@@ -57,12 +57,15 @@
 	 * Use the following structs to avoid violating C standard
 	 * alignment requirements and to avoid strict aliasing bugs
 	 */
+	__rte_msvc_pack
 	struct rte_uint64_alias {
 		uint64_t val;
 	} __rte_packed __rte_may_alias;
+	__rte_msvc_pack
 	struct rte_uint32_alias {
 		uint32_t val;
 	} __rte_packed __rte_may_alias;
+	__rte_msvc_pack
 	struct rte_uint16_alias {
 		uint16_t val;
 	} __rte_packed __rte_may_alias;
Signature · 1 line
1.8.3.1
#3 lore raw

Re: [PATCH 02/15] eal: pack structures when building with MSVC

Quoted 17 lines · Tyler Retzlaff

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

---
 lib/eal/common/eal_private.h      | 1 +
 lib/eal/include/rte_memory.h      | 1 +
 lib/eal/include/rte_memzone.h     | 1 +
 lib/eal/include/rte_trace_point.h | 1 +
 lib/eal/x86/include/rte_memcpy.h  | 3 +++
 5 files changed, 7 insertions(+)
lib/eal/common/eal_private.h +0 -0
index 71523cf..21ace2a 100644

lib/eal/common/eal_private.h struct lcore_config { · line 49

Quoted 7 lines
lib/eal/common/eal_private.h +1 -0
@@ -43,6 +43,7 @@ struct lcore_config {
 /**
  * The global RTE configuration structure.
  */
+__rte_msvc_pack
 struct rte_config {
 	uint32_t main_lcore;         /**< Id of the main lcore */
 	uint32_t lcore_count;        /**< Number of available logical cores. */

This struct almost certainly doesn't need to be packed - since it's in a private header, I would imagine removing packing wouldn't be an ABI break.
Also, removing rte_packed doesn't change the size for me for a 64-bit x86 build. Looking at the struct, I don't see why it would change on a 32-bit build either.

Quoted 17 lines
lib/eal/include/rte_memory.h +1 -0
index 842362d..73bb00d 100644
@@ -46,6 +46,7 @@
 /**
  * Physical memory segment descriptor.
  */
+__rte_msvc_pack
 struct rte_memseg {
 	rte_iova_t iova;            /**< Start IO address. */
 	union {
lib/eal/include/rte_memzone.h +0 -0
index 931497f..ca312c0 100644

lib/eal/include/rte_memzone.h line 50

Quoted 6 lines
lib/eal/include/rte_memzone.h +1 -0
@@ -45,6 +45,7 @@
  * A structure describing a memzone, which is a contiguous portion of
  * physical memory identified by a name.
  */
+__rte_msvc_pack
 struct rte_memzone {
 

This also doesn't look like it should be packed. It is a public header though so we may need to be more careful. Checking a 64-bit x86 build shows no size change when removing the "packed" attribute, though. For 32-bit, I think the "size_t" field in the middle would be followed by padding on 32-bit if we removed the "packed" attribute, so it may be a no-go for now. :-(

lib/eal/include/rte_trace_point.h int __rte_trace_point_register(rte_trace_point_t *trace, const char *name, · line 298

Quoted 13 lines
lib/eal/include/rte_memzone.h +0 -0
 #define RTE_MEMZONE_NAMESIZE 32       /**< Maximum length of memory zone name.*/
lib/eal/include/rte_trace_point.h +1 -0
index 41e2a7f..63f333c 100644
@@ -292,6 +292,7 @@ int __rte_trace_point_register(rte_trace_point_t *trace, const char *name,
 #define __RTE_TRACE_FIELD_ENABLE_MASK (1ULL << 63)
 #define __RTE_TRACE_FIELD_ENABLE_DISCARD (1ULL << 62)
 
+__rte_msvc_pack
 struct __rte_trace_stream_header {
 	uint32_t magic;
 	rte_uuid_t uuid;

From code review, this doesn't look like "packed" has any impact, since all fields should naturally be aligned on both 32-bit and 64-bit builds.

/Bruce

#4 lore raw

PATCH 3/15 net: pack structures when building with MSVC

In reply to Tyler Retzlaff

Add __rte_msvc_pushpack(1) to all __rte_packed structs to cause packing when building with MSVC.

---
 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(+)
lib/net/rte_arp.h +2 -0
index 668cea1..35d68c1 100644
@@ -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 */
lib/net/rte_dtls.h +1 -0
index 4f541df..0c75b06 100644
@@ -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;
lib/net/rte_esp.h +2 -0
index 464c513..27c9287 100644
@@ -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 */
lib/net/rte_ether.h +1 -0
index 32ed515..354e3a5 100644
@@ -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. */
lib/net/rte_geneve.h +1 -0
index 3bbc561..5c02526 100644
@@ -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. */
lib/net/rte_gre.h +4 -0
index 8da8027..77882e7 100644
@@ -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;
lib/net/rte_gtp.h +5 -0
index 9849872..26fc80a 100644
@@ -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
lib/net/rte_ib.h +1 -0
index 9eab5f9..c4c5d39 100644
@@ -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
lib/net/rte_icmp.h +3 -0
index 4bf64d7..e865db4 100644
@@ -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. */
lib/net/rte_ip.h +4 -0
index 0d103d4..908a25c 100644
@@ -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 */
lib/net/rte_l2tpv2.h +4 -0
index 9cda347..a917013 100644
@@ -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 {
lib/net/rte_macsec.h +2 -0
index d0cd2f6..54de1bd 100644
@@ -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;
lib/net/rte_mpls.h +1 -0
index 51523e7..d5f6026 100644
@@ -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
lib/net/rte_pdcp_hdr.h +4 -0
index 72ae9a6..6a20ad9 100644
@@ -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 */
lib/net/rte_ppp.h +1 -0
index 7b86ac4..fde585f 100644
@@ -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) */
lib/net/rte_sctp.h +1 -0
index 965682d..a6cfe8f 100644
@@ -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. */
lib/net/rte_tcp.h +1 -0
index 506ac4e..d11cb2c 100644
@@ -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. */
lib/net/rte_tls.h +1 -0
index 2eb3c6d..81af4c7 100644
@@ -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;
lib/net/rte_udp.h +1 -0
index 6135494..5416855 100644
@@ -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. */
lib/net/rte_vxlan.h +2 -0
index 997fc78..bcfd579 100644
@@ -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 {
Signature · 1 line
1.8.3.1
#5 lore raw

Re: [PATCH 03/15] net: pack structures when building with MSVC

Quoted 17 lines · On Wed, 20 Mar 2024 14:05:59 -0700 Tyler Retzlaff…

Add __rte_msvc_pushpack(1) to all __rte_packed structs to cause packing when building with MSVC.

---
 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 ++
Quoted 8 lines
 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 ++

This no longer applies, need to rebase this series. Address the comments from Bruce in previous patch as well.

#6 lore raw

PATCH 4/15 common/iavf: pack structures when building with MSVC

In reply to Tyler Retzlaff

Add __rte_msvc_pushpack(1) to all __rte_packed structs to cause packing when building with MSVC.

---
 drivers/common/iavf/iavf_osdep.h            |  2 ++
 drivers/common/iavf/virtchnl_inline_ipsec.h | 11 +++++++++++
 2 files changed, 13 insertions(+)
drivers/common/iavf/iavf_osdep.h +2 -0
index 263d924..1fb057c 100644
@@ -158,6 +158,7 @@
 } while (0)
 
 /* memory allocation tracking */
+__rte_msvc_pack
 struct iavf_dma_mem {
 	void *va;
 	u64 pa;
@@ -165,6 +166,7 @@ struct iavf_dma_mem {
 	const void *zone;
 } __rte_packed;
 
+__rte_msvc_pack
 struct iavf_virt_mem {
 	void *va;
 	u32 size;
drivers/common/iavf/virtchnl_inline_ipsec.h +11 -0
index 2f4bf15..feb0f44 100644
@@ -109,6 +109,7 @@ enum inline_ipsec_ops {
 };
 
 /* Not all valid, if certain field is invalid, set 1 for all bits */
+__rte_msvc_pack
 struct virtchnl_algo_cap  {
 	u32 algo_type;
 
@@ -132,6 +133,7 @@ struct virtchnl_algo_cap  {
 } __rte_packed;
 
 /* vf record the capability of crypto from the virtchnl */
+__rte_msvc_pack
 struct virtchnl_sym_crypto_cap {
 	u8 crypto_type;
 	u8 algo_cap_num;
@@ -142,6 +144,7 @@ struct virtchnl_sym_crypto_cap {
  * VF pass virtchnl_ipsec_cap to PF
  * and PF return capability of ipsec from virtchnl.
  */
+__rte_msvc_pack
 struct virtchnl_ipsec_cap {
 	/* max number of SA per VF */
 	u16 max_sa_num;
@@ -172,6 +175,7 @@ struct virtchnl_ipsec_cap {
 } __rte_packed;
 
 /* configuration of crypto function */
+__rte_msvc_pack
 struct virtchnl_ipsec_crypto_cfg_item {
 	u8 crypto_type;
 
@@ -203,6 +207,7 @@ struct virtchnl_ipsec_sym_crypto_cfg {
  * PF create SA as configuration and PF driver will return
  * an unique index (sa_idx) for the created SA.
  */
+__rte_msvc_pack
 struct virtchnl_ipsec_sa_cfg {
 	/* IPsec SA Protocol - AH/ESP */
 	u8 virtchnl_protocol_type;
@@ -298,6 +303,7 @@ struct virtchnl_ipsec_sa_cfg {
  * VF send configuration of index of SA to PF
  * PF will update SA according to configuration
  */
+__rte_msvc_pack
 struct virtchnl_ipsec_sa_update {
 	u32 sa_index; /* SA to update */
 	u32 esn_hi; /* high 32 bits of esn */
@@ -310,6 +316,7 @@ struct virtchnl_ipsec_sa_update {
  * flag bitmap indicate all SA or just selected SA will
  * be destroyed
  */
+__rte_msvc_pack
 struct virtchnl_ipsec_sa_destroy {
 	/* All zero bitmap indicates all SA will be destroyed.
 	 * Non-zero bitmap indicates the selected SA in
@@ -325,6 +332,7 @@ struct virtchnl_ipsec_sa_destroy {
  * VF send this SA configuration to PF using virtchnl;
  * PF read SA and will return configuration for the created SA.
  */
+__rte_msvc_pack
 struct virtchnl_ipsec_sa_read {
 	/* SA valid - invalid/valid */
 	u8 valid;
@@ -431,6 +439,7 @@ struct virtchnl_ipsec_sa_read {
 #define VIRTCHNL_IPSEC_INBOUND_SPD_TBL_IPV6	(1)
 
 /* Add allowlist entry in IES */
+__rte_msvc_pack
 struct virtchnl_ipsec_sp_cfg {
 	u32 spi;
 	u32 dip[4];
@@ -459,6 +468,7 @@ struct virtchnl_ipsec_sp_cfg {
 
 
 /* Delete allowlist entry in IES */
+__rte_msvc_pack
 struct virtchnl_ipsec_sp_destroy {
 	/* 0 for IPv4 table, 1 for IPv6 table. */
 	u8 table_id;
@@ -494,6 +504,7 @@ struct virtchnl_ipsec_resp {
 };
 
 /* Internal message descriptor for VF <-> IPsec communication */
+__rte_msvc_pack
 struct inline_ipsec_msg {
 	u16 ipsec_opcode;
 	u16 req_id;
Signature · 1 line
1.8.3.1
#7 lore raw

PATCH 5/15 common/idpf: pack structures when building with MSVC

In reply to Tyler Retzlaff

Add __rte_msvc_pushpack(1) to all __rte_packed structs to cause packing when building with MSVC.

---
 drivers/common/idpf/base/idpf_osdep.h | 2 ++
 1 file changed, 2 insertions(+)
drivers/common/idpf/base/idpf_osdep.h +2 -0
index 74a376c..f5fcdc3 100644
@@ -180,6 +180,7 @@ static inline uint64_t idpf_read_addr64(volatile void *addr)
 #define BITS_PER_BYTE       8
 
 /* memory allocation tracking */
+__rte_msvc_pack
 struct idpf_dma_mem {
 	void *va;
 	u64 pa;
@@ -187,6 +188,7 @@ struct idpf_dma_mem {
 	const void *zone;
 } __rte_packed;
 
+__rte_msvc_pack
 struct idpf_virt_mem {
 	void *va;
 	u32 size;
Signature · 1 line
1.8.3.1
#8 lore raw

PATCH 6/15 common/mlx5: pack structures when building with MSVC

In reply to Tyler Retzlaff

Add __rte_msvc_pushpack(1) to all __rte_packed structs to cause packing when building with MSVC.

---
 drivers/common/mlx5/mlx5_common_mr.h    |  4 ++++
 drivers/common/mlx5/mlx5_common_utils.h |  1 +
 drivers/common/mlx5/mlx5_prm.h          | 28 ++++++++++++++++++++++++++++
 3 files changed, 33 insertions(+)
drivers/common/mlx5/mlx5_common_mr.h +4 -0
index 8789d40..4f4bd73 100644
@@ -49,6 +49,7 @@ struct mlx5_mr {
 };
 
 /* Cache entry for Memory Region. */
+__rte_msvc_pack
 struct mr_cache_entry {
 	uintptr_t start; /* Start address of MR. */
 	uintptr_t end; /* End address of MR. */
@@ -56,6 +57,7 @@ struct mr_cache_entry {
 } __rte_packed;
 
 /* MR Cache table for Binary search. */
+__rte_msvc_pack
 struct mlx5_mr_btree {
 	uint32_t len; /* Number of entries. */
 	uint32_t size; /* Total number of entries. */
@@ -65,6 +67,7 @@ struct mlx5_mr_btree {
 struct mlx5_common_device;
 
 /* Per-queue MR control descriptor. */
+__rte_msvc_pack
 struct mlx5_mr_ctrl {
 	uint32_t *dev_gen_ptr; /* Generation number of device to poll. */
 	uint32_t cur_gen; /* Generation number saved to flush caches. */
@@ -78,6 +81,7 @@ struct mlx5_mr_ctrl {
 LIST_HEAD(mlx5_mempool_reg_list, mlx5_mempool_reg);
 
 /* Global per-device MR cache. */
+__rte_msvc_pack
 struct mlx5_mr_share_cache {
 	uint32_t dev_gen; /* Generation number to flush local caches. */
 	rte_rwlock_t rwlock; /* MR cache Lock. */
drivers/common/mlx5/mlx5_common_utils.h +1 -0
index ae15119..a44975c 100644
@@ -27,6 +27,7 @@
  * Structure of the entry in the mlx5 list, user should define its own struct
  * that contains this in order to store the data.
  */
+__rte_msvc_pack
 struct mlx5_list_entry {
 	LIST_ENTRY(mlx5_list_entry) next; /* Entry pointers in the list. */
 	uint32_t ref_cnt __rte_aligned(8); /* 0 means, entry is invalid. */
drivers/common/mlx5/mlx5_prm.h +28 -0
index c671c75..bf9ecd1 100644
@@ -319,6 +319,7 @@ enum mlx5_mpw_mode {
 };
 
 /* WQE Control segment. */
+__rte_msvc_pack
 struct mlx5_wqe_cseg {
 	uint32_t opcode;
 	uint32_t sq_ds;
@@ -336,10 +337,12 @@ struct mlx5_wqe_cseg {
 #define WQE_CSEG_WQE_INDEX_OFFSET	 8
 
 /* Header of data segment. Minimal size Data Segment */
+__rte_msvc_pack
 struct mlx5_wqe_dseg {
 	uint32_t bcount;
 	union {
 		uint8_t inline_data[MLX5_DSEG_MIN_INLINE_SIZE];
+		__rte_msvc_pack
 		struct {
 			uint32_t lkey;
 			uint64_t pbuf;
@@ -348,8 +351,10 @@ struct mlx5_wqe_dseg {
 } __rte_packed;
 
 /* Subset of struct WQE Ethernet Segment. */
+__rte_msvc_pack
 struct mlx5_wqe_eseg {
 	union {
+		__rte_msvc_pack
 		struct {
 			uint32_t swp_offs;
 			uint8_t	cs_flags;
@@ -362,6 +367,7 @@ struct mlx5_wqe_eseg {
 				uint16_t vlan_tag;
 			};
 		} __rte_packed;
+		__rte_msvc_pack
 		struct {
 			uint32_t offsets;
 			uint32_t flags;
@@ -371,6 +377,7 @@ struct mlx5_wqe_eseg {
 	};
 } __rte_packed;
 
+__rte_msvc_pack
 struct mlx5_wqe_qseg {
 	uint32_t reserved0;
 	uint32_t reserved1;
@@ -378,6 +385,7 @@ struct mlx5_wqe_qseg {
 	uint32_t qpn_cqn;
 } __rte_packed;
 
+__rte_msvc_pack
 struct mlx5_wqe_wseg {
 	uint32_t operation;
 	uint32_t lkey;
@@ -388,6 +396,7 @@ struct mlx5_wqe_wseg {
 } __rte_packed;
 
 /* The title WQEBB, header of WQE. */
+__rte_msvc_pack
 struct mlx5_wqe {
 	union {
 		struct mlx5_wqe_cseg cseg;
@@ -437,6 +446,7 @@ struct mlx5_cqe {
 	uint8_t lro_num_seg;
 	union {
 		uint8_t user_index_bytes[3];
+		__rte_msvc_pack
 		struct {
 			uint8_t user_index_hi;
 			uint16_t user_index_low;
@@ -460,6 +470,7 @@ struct mlx5_cqe_ts {
 	uint8_t op_own;
 };
 
+__rte_msvc_pack
 struct mlx5_wqe_rseg {
 	uint64_t raddr;
 	uint32_t rkey;
@@ -479,6 +490,7 @@ struct mlx5_wqe_rseg {
 #define MLX5_UMR_KLM_NUM_ALIGN \
 	(MLX5_UMR_KLM_PTR_ALIGN / sizeof(struct mlx5_klm))
 
+__rte_msvc_pack
 struct mlx5_wqe_umr_cseg {
 	uint32_t if_cf_toe_cq_res;
 	uint32_t ko_to_bs;
@@ -486,6 +498,7 @@ struct mlx5_wqe_umr_cseg {
 	uint32_t rsvd1[8];
 } __rte_packed;
 
+__rte_msvc_pack
 struct mlx5_wqe_mkey_cseg {
 	uint32_t fr_res_af_sf;
 	uint32_t qpn_mkey;
@@ -549,6 +562,7 @@ enum {
 #define MLX5_CRYPTO_MMO_TYPE_OFFSET 24
 #define MLX5_CRYPTO_MMO_OP_OFFSET 20
 
+__rte_msvc_pack
 struct mlx5_wqe_umr_bsf_seg {
 	/*
 	 * bs_bpt_eo_es contains:
@@ -582,6 +596,7 @@ struct mlx5_wqe_umr_bsf_seg {
 #pragma GCC diagnostic ignored "-Wpedantic"
 #endif
 
+__rte_msvc_pack
 struct mlx5_umr_wqe {
 	struct mlx5_wqe_cseg ctr;
 	struct mlx5_wqe_umr_cseg ucseg;
@@ -592,18 +607,21 @@ struct mlx5_umr_wqe {
 	};
 } __rte_packed;
 
+__rte_msvc_pack
 struct mlx5_rdma_write_wqe {
 	struct mlx5_wqe_cseg ctr;
 	struct mlx5_wqe_rseg rseg;
 	struct mlx5_wqe_dseg dseg[];
 } __rte_packed;
 
+__rte_msvc_pack
 struct mlx5_wqe_send_en_seg {
 	uint32_t reserve[2];
 	uint32_t sqnpc;
 	uint32_t qpn;
 } __rte_packed;
 
+__rte_msvc_pack
 struct mlx5_wqe_send_en_wqe {
 	struct mlx5_wqe_cseg ctr;
 	struct mlx5_wqe_send_en_seg sseg;
@@ -650,6 +668,7 @@ struct mlx5_wqe_metadata_seg {
 	uint64_t addr;
 };
 
+__rte_msvc_pack
 struct mlx5_gga_wqe {
 	uint32_t opcode;
 	uint32_t sq_ds;
@@ -663,16 +682,19 @@ struct mlx5_gga_wqe {
 } __rte_packed;
 
 union mlx5_gga_compress_opaque {
+	__rte_msvc_pack
 	struct {
 		uint32_t syndrome;
 		uint32_t reserved0;
 		uint32_t scattered_length;
 		union {
+			__rte_msvc_pack
 			struct {
 				uint32_t reserved1[5];
 				uint32_t crc32;
 				uint32_t adler32;
 			} v1 __rte_packed;
+			__rte_msvc_pack
 			struct {
 				uint32_t crc32;
 				uint32_t adler32;
@@ -685,9 +707,11 @@ struct mlx5_gga_wqe {
 };
 
 union mlx5_gga_crypto_opaque {
+	__rte_msvc_pack
 	struct {
 		uint32_t syndrome;
 		uint32_t reserved0[2];
+		__rte_msvc_pack
 		struct {
 			uint32_t iv[3];
 			uint32_t tag_size;
@@ -4134,6 +4158,7 @@ enum mlx5_aso_op {
 #define MLX5_ASO_CSEG_READ_ENABLE 1
 
 /* ASO WQE CTRL segment. */
+__rte_msvc_pack
 struct mlx5_aso_cseg {
 	uint32_t va_h;
 	uint32_t va_l_r;
@@ -4150,6 +4175,7 @@ struct mlx5_aso_cseg {
 #define MLX5_MTR_MAX_TOKEN_VALUE INT32_MAX
 
 /* A meter data segment - 2 per ASO WQE. */
+__rte_msvc_pack
 struct mlx5_aso_mtr_dseg {
 	uint32_t v_bo_sc_bbog_mm;
 	/*
@@ -4191,6 +4217,7 @@ struct mlx5_aso_mtr_dseg {
 #define MLX5_ASO_MTRS_PER_POOL 128
 
 /* ASO WQE data segment. */
+__rte_msvc_pack
 struct mlx5_aso_dseg {
 	union {
 		uint8_t data[MLX5_ASO_WQE_DSEG_SIZE];
@@ -4199,6 +4226,7 @@ struct mlx5_aso_dseg {
 } __rte_packed;
 
 /* ASO WQE. */
+__rte_msvc_pack
 struct mlx5_aso_wqe {
 	struct mlx5_wqe_cseg general_cseg;
 	struct mlx5_aso_cseg aso_cseg;
Signature · 1 line
1.8.3.1
#9 lore raw

PATCH 7/15 dma/ioat: pack structures when building with MSVC

In reply to Tyler Retzlaff

Add __rte_msvc_pushpack(1) to all __rte_packed structs to cause packing when building with MSVC.

---
 drivers/dma/ioat/ioat_hw_defs.h | 1 +
 1 file changed, 1 insertion(+)
drivers/dma/ioat/ioat_hw_defs.h +1 -0
index dc3493a..6e32807 100644
@@ -52,6 +52,7 @@
 #define	IOAT_DMACAP_PQ		(1 << 9)
 #define	IOAT_DMACAP_DMA_DIF	(1 << 10)
 
+__rte_msvc_pack
 struct ioat_registers {
 	uint8_t		chancnt;
 	uint8_t		xfercap;
Signature · 1 line
1.8.3.1
#10 lore raw

Re: [PATCH 07/15] dma/ioat: pack structures when building with MSVC

Quoted 13 lines · Tyler Retzlaff

Add __rte_msvc_pushpack(1) to all __rte_packed structs to cause packing when building with MSVC.

---
 drivers/dma/ioat/ioat_hw_defs.h | 1 +
 1 file changed, 1 insertion(+)
drivers/dma/ioat/ioat_hw_defs.h +0 -0
index dc3493a..6e32807 100644

drivers/dma/ioat/ioat_hw_defs.h line 58

Quoted 7 lines
drivers/dma/ioat/ioat_hw_defs.h +1 -0
@@ -52,6 +52,7 @@
 #define	IOAT_DMACAP_PQ		(1 << 9)
 #define	IOAT_DMACAP_DMA_DIF	(1 << 10)
 
+__rte_msvc_pack
 struct ioat_registers {
 	uint8_t		chancnt;
 	uint8_t		xfercap;

This struct has all gaps explicitly filled, so packed should not be necessary. Struct has same size with and without the attribute.

/Bruce

#11 lore raw

Re: [PATCH 07/15] dma/ioat: pack structures when building with MSVC

Quoted 17 lines · Bruce Richardson
Quoted 16 lines · Tyler Retzlaff

Add __rte_msvc_pushpack(1) to all __rte_packed structs to cause packing when building with MSVC.

---
 drivers/dma/ioat/ioat_hw_defs.h | 1 +
 1 file changed, 1 insertion(+)
drivers/dma/ioat/ioat_hw_defs.h +0 -0
index dc3493a..6e32807 100644
@@ -52,6 +52,7 @@
 #define	IOAT_DMACAP_PQ		(1 << 9)
 #define	IOAT_DMACAP_DMA_DIF	(1 << 10)
 
Quoted 7 lines

drivers/dma/ioat/ioat_hw_defs.h line 58

Quoted 4 lines
drivers/dma/ioat/ioat_hw_defs.h +1 -0
+__rte_msvc_pack
 struct ioat_registers {
 	uint8_t		chancnt;
 	uint8_t		xfercap;

This struct has all gaps explicitly filled, so packed should not be necessary. Struct has same size with and without the attribute.

just eyeballing it i think

        uint32_t        dmacapability;  /* 0x10 */

with packing will not be aligned on a 4-byte boundary.

maybe i miscounted though.

Quoted 2 lines

/Bruce

#12 lore raw

PATCH 8/15 net/i40e: pack structures when building with MSVC

In reply to Tyler Retzlaff

Add __rte_msvc_pushpack(1) to all __rte_packed structs to cause packing when building with MSVC.

---
 drivers/net/i40e/base/i40e_osdep.h | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/i40e/base/i40e_osdep.h +2 -0
index aa5dc61..28439e3 100644
@@ -177,6 +177,7 @@ static inline uint64_t i40e_read64_addr(volatile void *addr)
 #define ARRAY_SIZE(arr) RTE_DIM(arr)
 
 /* memory allocation tracking */
+__rte_msvc_pack
 struct i40e_dma_mem {
 	void *va;
 	u64 pa;
@@ -188,6 +189,7 @@ struct i40e_dma_mem {
 			i40e_allocate_dma_mem_d(h, m, s, a)
 #define i40e_free_dma_mem(h, m) i40e_free_dma_mem_d(h, m)
 
+__rte_msvc_pack
 struct i40e_virt_mem {
 	void *va;
 	u32 size;
Signature · 1 line
1.8.3.1
#13 lore raw

PATCH 9/15 net/iavf: pack structures when building with MSVC

In reply to Tyler Retzlaff

Add __rte_msvc_pushpack(1) to all __rte_packed structs to cause packing when building with MSVC.

---
 drivers/net/iavf/iavf_ipsec_crypto.h | 3 +++
 drivers/net/iavf/iavf_rxtx.c         | 1 +
 2 files changed, 4 insertions(+)
drivers/net/iavf/iavf_ipsec_crypto.h +3 -0
index 49f9202..36ced50 100644
@@ -11,12 +11,14 @@
 
 
 
+__rte_msvc_pack
 struct iavf_tx_ipsec_desc {
 	union {
 		struct {
 			__le64 qw0;
 			__le64 qw1;
 		};
+		__rte_msvc_pack
 		struct {
 			__le16 l4payload_length;
 			__le32 esn;
@@ -84,6 +86,7 @@ enum iavf_ipsec_iv_len {
  * transmit data path. Parameters set for session by calling
  * rte_security_set_pkt_metadata() API.
  */
+__rte_msvc_pack
 struct iavf_ipsec_crypto_pkt_metadata {
 	uint32_t sa_idx;                /* SA hardware index (20b/4B) */
 
drivers/net/iavf/iavf_rxtx.c +1 -0
index 0a5246d..ba0fa6f 100644
@@ -50,6 +50,7 @@
 static uint16_t vxlan_gpe_udp_port = RTE_VXLAN_GPE_DEFAULT_PORT;
 static uint16_t geneve_udp_port = RTE_GENEVE_DEFAULT_PORT;
 
+__rte_msvc_pack
 struct simple_gre_hdr {
 	uint16_t flags;
 	uint16_t proto;
Signature · 1 line
1.8.3.1
#14 lore raw

Re: [PATCH 09/15] net/iavf: pack structures when building with MSVC

Quoted 18 lines · Tyler Retzlaff

Add __rte_msvc_pushpack(1) to all __rte_packed structs to cause packing when building with MSVC.

---
 drivers/net/iavf/iavf_ipsec_crypto.h | 3 +++
 drivers/net/iavf/iavf_rxtx.c         | 1 +
 2 files changed, 4 insertions(+)
drivers/net/iavf/iavf_ipsec_crypto.h +1 -0
index 49f9202..36ced50 100644
@@ -11,12 +11,14 @@
 
 
 
+__rte_msvc_pack

drivers/net/iavf/iavf_ipsec_crypto.h line 24

Quoted 10 lines
drivers/net/iavf/iavf_ipsec_crypto.h +1 -0
 struct iavf_tx_ipsec_desc {
 	union {
 		struct {
 			__le64 qw0;
 			__le64 qw1;
 		};
+		__rte_msvc_pack
 		struct {
 			__le16 l4payload_length;
 			__le32 esn;

Looking at the structure, I believe only the inner packed attribute is necessary. However, given that we need packed attributes, for safety, let's keep them both.

drivers/net/iavf/iavf_ipsec_crypto.h enum iavf_ipsec_iv_len { · line 92

Quoted 8 lines
drivers/net/iavf/iavf_ipsec_crypto.h +1 -0
@@ -84,6 +86,7 @@ enum iavf_ipsec_iv_len {
  * transmit data path. Parameters set for session by calling
  * rte_security_set_pkt_metadata() API.
  */
+__rte_msvc_pack
 struct iavf_ipsec_crypto_pkt_metadata {
 	uint32_t sa_idx;                /* SA hardware index (20b/4B) */
 

This is exactly 16-bytes in size, with all members explicitly sized and properly aligned. Therefore we can drop the packed atttribute.

drivers/net/iavf/iavf_rxtx.c line 56

Quoted 12 lines
drivers/net/iavf/iavf_rxtx.c +1 -0
index 0a5246d..ba0fa6f 100644
@@ -50,6 +50,7 @@
 static uint16_t vxlan_gpe_udp_port = RTE_VXLAN_GPE_DEFAULT_PORT;
 static uint16_t geneve_udp_port = RTE_GENEVE_DEFAULT_PORT;
 
+__rte_msvc_pack
 struct simple_gre_hdr {
 	uint16_t flags;
 	uint16_t proto;

Two 16-bit fields only, so no need to pack this struct either.

/Bruce

#15 lore raw

PATCH 10/15 net/ice: pack structures when building with MSVC

In reply to Tyler Retzlaff

Add __rte_msvc_pushpack(1) to all __rte_packed structs to cause packing when building with MSVC.

---
 drivers/net/ice/base/ice_osdep.h | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/ice/base/ice_osdep.h +2 -0
index 0e14b93..087dc6a 100644
@@ -187,6 +187,7 @@
 #define BITS_PER_BYTE       8
 
 /* memory allocation tracking */
+__rte_msvc_pack
 struct ice_dma_mem {
 	void *va;
 	u64 pa;
@@ -194,6 +195,7 @@ struct ice_dma_mem {
 	const void *zone;
 } __rte_packed;
 
+__rte_msvc_pack
 struct ice_virt_mem {
 	void *va;
 	u32 size;
Signature · 1 line
1.8.3.1
#16 lore raw

PATCH 11/15 net/mlx5: pack structures when building with MSVC

In reply to Tyler Retzlaff

Add __rte_msvc_pushpack(1) to all __rte_packed structs to cause packing when building with MSVC.

---
 drivers/net/mlx5/hws/mlx5dr.h   | 1 +
 drivers/net/mlx5/mlx5.h         | 1 +
 drivers/net/mlx5/mlx5_flow.h    | 5 +++++
 drivers/net/mlx5/mlx5_hws_cnt.h | 1 +
 drivers/net/mlx5/mlx5_utils.h   | 4 ++++
 5 files changed, 12 insertions(+)
drivers/net/mlx5/hws/mlx5dr.h +1 -0
index 80e118a..cd5bb05 100644
@@ -300,6 +300,7 @@ struct mlx5dr_action_dest_attr {
 	};
 };
 
+__rte_msvc_pack
 struct mlx5dr_crc_encap_entropy_hash_fields {
 	union mlx5dr_crc_encap_entropy_hash_ip_field dst;
 	union mlx5dr_crc_encap_entropy_hash_ip_field src;
drivers/net/mlx5/mlx5.h +1 -0
index 0091a24..6228ee8 100644
@@ -221,6 +221,7 @@ struct mlx5_dev_spawn_data {
 }
 
 /** Data associated with socket messages. */
+__rte_msvc_pack
 struct mlx5_flow_dump_req  {
 	uint32_t port_id; /**< There are plans in DPDK to extend port_id. */
 	uint64_t flow_id;
drivers/net/mlx5/mlx5_flow.h +5 -0
index 34b5e0f..172b023 100644
@@ -658,6 +658,7 @@ struct mlx5_flow_dv_tag_resource {
 };
 
 /* Modify resource structure */
+__rte_msvc_pack
 struct mlx5_flow_dv_modify_hdr_resource {
 	struct mlx5_list_entry entry;
 	void *action; /**< Modify header action object. */
@@ -812,6 +813,7 @@ struct mlx5_flow_dv_dest_array_resource {
 
 
 /** Device flow handle structure for DV mode only. */
+__rte_msvc_pack
 struct mlx5_flow_handle_dv {
 	/* Flow DV api: */
 	struct mlx5_flow_dv_matcher *matcher; /**< Cache to matcher. */
@@ -830,6 +832,7 @@ struct mlx5_flow_handle_dv {
 } __rte_packed;
 
 /** Device flow handle structure: used both for creating & destroying. */
+__rte_msvc_pack
 struct mlx5_flow_handle {
 	SILIST_ENTRY(uint32_t)next;
 	struct mlx5_vf_vlan vf_vlan; /**< Structure for VF VLAN workaround. */
@@ -1231,6 +1234,7 @@ struct mlx5_flow_attr {
 };
 
 /* Flow structure. */
+__rte_msvc_pack
 struct rte_flow {
 	uint32_t dev_handles;
 	/**< Device flow handles that are part of the flow. */
@@ -1304,6 +1308,7 @@ enum {
 #endif
 
 /** HWS flow struct. */
+__rte_msvc_pack
 struct rte_flow_hw {
 	/** The table flow allcated from. */
 	struct rte_flow_template_table *table;
drivers/net/mlx5/mlx5_hws_cnt.h +1 -0
index e005960..1f53a1a 100644
@@ -133,6 +133,7 @@ enum {
 };
 
 /* HWS counter age parameter. */
+__rte_msvc_pack
 struct mlx5_hws_age_param {
 	uint32_t timeout; /* Aging timeout in seconds (atomically accessed). */
 	uint32_t sec_since_last_hit;
drivers/net/mlx5/mlx5_utils.h +4 -0
index f3c0d76..cf80e5e 100644
@@ -118,6 +118,7 @@ struct mlx5_l3t_level_tbl {
 };
 
 /* L3 word entry table data structure. */
+__rte_msvc_pack
 struct mlx5_l3t_entry_word {
 	uint32_t idx; /* Table index. */
 	uint64_t ref_cnt; /* Table ref_cnt. */
@@ -128,6 +129,7 @@ struct mlx5_l3t_entry_word {
 } __rte_packed;
 
 /* L3 double word entry table data structure. */
+__rte_msvc_pack
 struct mlx5_l3t_entry_dword {
 	uint32_t idx; /* Table index. */
 	uint64_t ref_cnt; /* Table ref_cnt. */
@@ -138,6 +140,7 @@ struct mlx5_l3t_entry_dword {
 } __rte_packed;
 
 /* L3 quad word entry table data structure. */
+__rte_msvc_pack
 struct mlx5_l3t_entry_qword {
 	uint32_t idx; /* Table index. */
 	uint64_t ref_cnt; /* Table ref_cnt. */
@@ -148,6 +151,7 @@ struct mlx5_l3t_entry_qword {
 } __rte_packed;
 
 /* L3 pointer entry table data structure. */
+__rte_msvc_pack
 struct mlx5_l3t_entry_ptr {
 	uint32_t idx; /* Table index. */
 	uint64_t ref_cnt; /* Table ref_cnt. */
Signature · 1 line
1.8.3.1
#17 lore raw

PATCH 12/15 net/octeon_ep: pack structures when building with MSVC

In reply to Tyler Retzlaff

Add __rte_msvc_pushpack(1) to all __rte_packed structs to cause packing when building with MSVC.

---
 drivers/net/octeon_ep/otx_ep_mbox.h | 1 +
 1 file changed, 1 insertion(+)
drivers/net/octeon_ep/otx_ep_mbox.h +1 -0
index a3fc15c..005fce3 100644
@@ -70,6 +70,7 @@ enum otx_ep_link_autoneg {
 #define OTX_EP_MBOX_MORE_FRAG_FLAG 1
 #define OTX_EP_MBOX_WRITE_WAIT_TIME msecs_to_jiffies(1)
 
+__rte_msvc_pack
 union otx_ep_mbox_word {
 	uint64_t u64;
 	struct {
Signature · 1 line
1.8.3.1
#18 lore raw

PATCH 13/15 app/testpmd: pack structures when building with MSVC

In reply to Tyler Retzlaff

Add __rte_msvc_pushpack(1) to all __rte_packed structs to cause packing when building with MSVC.

---
 app/test-pmd/csumonly.c | 1 +
 1 file changed, 1 insertion(+)
app/test-pmd/csumonly.c +1 -0
index 6711dda..638e607 100644
@@ -89,6 +89,7 @@ struct testpmd_offload_info {
 };
 
 /* simplified GRE header */
+__rte_msvc_pack
 struct simple_gre_hdr {
 	uint16_t flags;
 	uint16_t proto;
Signature · 1 line
1.8.3.1
#19 lore raw

Re: [PATCH 13/15] app/testpmd: pack structures when building with MSVC

Quoted 13 lines · Tyler Retzlaff

Add __rte_msvc_pushpack(1) to all __rte_packed structs to cause packing when building with MSVC.

---
 app/test-pmd/csumonly.c | 1 +
 1 file changed, 1 insertion(+)
app/test-pmd/csumonly.c +0 -0
index 6711dda..638e607 100644

app/test-pmd/csumonly.c struct testpmd_offload_info { · line 95

Quoted 7 lines
app/test-pmd/csumonly.c +1 -0
@@ -89,6 +89,7 @@ struct testpmd_offload_info {
 };
 
 /* simplified GRE header */
+__rte_msvc_pack
 struct simple_gre_hdr {
 	uint16_t flags;
 	uint16_t proto;

Should not need to be packed, as no padding.

However, if we don't mark this as packed could we hit problems if (for whatever reason) we ever receive a packet where the gre_hdr is not aligned on an even byte boundary? Does packing affect the minimum alignment requirements of the whole struct, as well as removing padding?

/Bruce

#20 lore raw

PATCH 14/15 app/test: pack structures when building with MSVC

In reply to Tyler Retzlaff

Add __rte_msvc_pushpack(1) to all __rte_packed structs to cause packing when building with MSVC.

---
 app/test/test_efd.c    | 1 +
 app/test/test_hash.c   | 1 +
 app/test/test_member.c | 1 +
 3 files changed, 3 insertions(+)
app/test/test_efd.c +1 -0
index 1c0986b..df176a0 100644
@@ -33,6 +33,7 @@
 static unsigned int test_socket_id;
 
 /* 5-tuple key type */
+__rte_msvc_pack
 struct flow_key {
 	uint32_t ip_src;
 	uint32_t ip_dst;
app/test/test_hash.c +1 -0
index d586878..08c1773 100644
@@ -79,6 +79,7 @@
  * Should be packed to avoid holes with potentially
  * undefined content in the middle.
  */
+__rte_msvc_pack
 struct flow_key {
 	uint32_t ip_src;
 	uint32_t ip_dst;
app/test/test_member.c +1 -0
index 5a4d275..ccd481a 100644
@@ -32,6 +32,7 @@
 struct rte_member_setsum *setsum_sketch;
 
 /* 5-tuple key type */
+__rte_msvc_pack
 struct flow_key {
 	uint32_t ip_src;
 	uint32_t ip_dst;
Signature · 1 line
1.8.3.1
#21 lore raw

PATCH 15/15 examples: pack structures when building with MSVC

In reply to Tyler Retzlaff

Add __rte_msvc_pushpack(1) to all __rte_packed structs to cause packing when building with MSVC.

---
 examples/common/neon/port_group.h | 1 +
 examples/ip_pipeline/cli.c        | 5 +++++
 examples/ipsec-secgw/ipsec.h      | 1 +
 examples/l3fwd-power/main.c       | 2 ++
 examples/ptpclient/ptpclient.c    | 8 ++++++++
 5 files changed, 17 insertions(+)
examples/common/neon/port_group.h +1 -0
index 421e2e8..bd40590 100644
@@ -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;
examples/ip_pipeline/cli.c +5 -0
index e8269ea..cae5c1f 100644
@@ -2566,6 +2566,7 @@
  *    | lpm
  *       ipv4 | ipv6 <addr> <depth>
  */
+__rte_msvc_pack
 struct pkt_key_qinq {
 	uint16_t ethertype_svlan;
 	uint16_t svlan;
@@ -2573,6 +2574,7 @@ struct pkt_key_qinq {
 	uint16_t cvlan;
 } __rte_packed;
 
+__rte_msvc_pack
 struct pkt_key_ipv4_5tuple {
 	uint8_t time_to_live;
 	uint8_t proto;
@@ -2583,6 +2585,7 @@ struct pkt_key_ipv4_5tuple {
 	uint16_t dp;
 } __rte_packed;
 
+__rte_msvc_pack
 struct pkt_key_ipv6_5tuple {
 	uint16_t payload_length;
 	uint8_t proto;
@@ -2593,10 +2596,12 @@ struct pkt_key_ipv6_5tuple {
 	uint16_t dp;
 } __rte_packed;
 
+__rte_msvc_pack
 struct pkt_key_ipv4_addr {
 	uint32_t addr;
 } __rte_packed;
 
+__rte_msvc_pack
 struct pkt_key_ipv6_addr {
 	uint8_t addr[16];
 } __rte_packed;
examples/ipsec-secgw/ipsec.h +1 -0
index bdcada1..bdc6045 100644
@@ -277,6 +277,7 @@ struct socket_ctx {
 	struct rte_mempool *session_pool;
 };
 
+__rte_msvc_pack
 struct cnt_blk {
 	uint32_t salt;
 	uint64_t iv;
examples/l3fwd-power/main.c +2 -0
index f4adcf4..a3be37b 100644
@@ -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];
examples/ptpclient/ptpclient.c +8 -0
index afb61bb..cdd73fd 100644
@@ -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;
Signature · 1 line
1.8.3.1
#22 lore raw

Re: [PATCH 15/15] examples: pack structures when building with MSVC

Quoted 55 lines · Tyler Retzlaff

Add __rte_msvc_pushpack(1) to all __rte_packed structs to cause packing when building with MSVC.

---
 examples/common/neon/port_group.h | 1 +
 examples/ip_pipeline/cli.c        | 5 +++++
 examples/ipsec-secgw/ipsec.h      | 1 +
 examples/l3fwd-power/main.c       | 2 ++
 examples/ptpclient/ptpclient.c    | 8 ++++++++
 5 files changed, 17 insertions(+)
examples/common/neon/port_group.h +1 -0
index 421e2e8..bd40590 100644
@@ -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;
examples/ip_pipeline/cli.c +3 -0
index e8269ea..cae5c1f 100644
@@ -2566,6 +2566,7 @@
  *    | lpm
  *       ipv4 | ipv6 <addr> <depth>
  */
+__rte_msvc_pack
 struct pkt_key_qinq {
 	uint16_t ethertype_svlan;
 	uint16_t svlan;
@@ -2573,6 +2574,7 @@ struct pkt_key_qinq {
 	uint16_t cvlan;
 } __rte_packed;
 
+__rte_msvc_pack
 struct pkt_key_ipv4_5tuple {
 	uint8_t time_to_live;
 	uint8_t proto;
@@ -2583,6 +2585,7 @@ struct pkt_key_ipv4_5tuple {
 	uint16_t dp;
 } __rte_packed;
 
+__rte_msvc_pack
 struct pkt_key_ipv6_5tuple {
 	uint16_t payload_length;
 	uint8_t proto;
@@ -2593,10 +2596,12 @@ struct pkt_key_ipv6_5tuple {
 	uint16_t dp;
 } __rte_packed;

examples/ip_pipeline/cli.c struct pkt_key_ipv6_5tuple { · line 2607

Quoted 10 lines
examples/ip_pipeline/cli.c +2 -0
 
+__rte_msvc_pack
 struct pkt_key_ipv4_addr {
 	uint32_t addr;
 } __rte_packed;
 
+__rte_msvc_pack
 struct pkt_key_ipv6_addr {
 	uint8_t addr[16];
 } __rte_packed;

These structs don't look to me like they need packing. No padding should appear between elements of the structs. The last struct definitely doesn't need it, as it's a uint8_t array.

/Bruce

#23 lore raw
In reply to Tyler Retzlaff
Quoted 10 lines · On Wed, 20 Mar 2024 14:05:56 -0700 Tyler Retzlaff…

MSVC struct packing is not compatible with GCC provide a macro that can be used to push existing pack value and sets packing to 1-byte. The existing __rte_packed macro is then used to restore the pack value prior to the push.

Instead of providing macros exclusively for MSVC and for GCC the existing macro is deliberately utilized to trigger a warning if no existing packing has been pushed allowing easy identification of locations where the __rte_msvc_pack is missing.

Quoted 5 lines

I've decided to only add the macro to packed structs that are built for Windows. It seems there is little value in adding the macro tree wide and if new code arrives that is built on Windows the __rte_packed will flag where the preamble macro is required.

Why is packed used so many places in DPDK?
Packed should be reserved for things like network protocols with unaligned fields.

Many of these structure have no holes and are naturally packed. Adding packed attribute unnecessarily can generate poor code on architectures that do not support unaligned access.

#24 lore raw
Quoted 19 lines · Stephen Hemminger
Quoted 10 lines · On Wed, 20 Mar 2024 14:05:56 -0700 Tyler Retzlaff…

MSVC struct packing is not compatible with GCC provide a macro that can be used to push existing pack value and sets packing to 1-byte. The existing __rte_packed macro is then used to restore the pack value prior to the push.

Instead of providing macros exclusively for MSVC and for GCC the existing macro is deliberately utilized to trigger a warning if no existing packing has been pushed allowing easy identification of locations where the __rte_msvc_pack is missing.

Quoted 5 lines

I've decided to only add the macro to packed structs that are built for Windows. It seems there is little value in adding the macro tree wide and if new code arrives that is built on Windows the __rte_packed will flag where the preamble macro is required.

Quoted 3 lines

Why is packed used so many places in DPDK?
Packed should be reserved for things like network protocols with unaligned fields.

I made the same observation. Even network frame formats can be handled without packing so long as you do some extra work to copy small units of data out which is often worth doing manually and once only instead of obfuscated behind codegen and direct field access.

Quoted 3 lines

Many of these structure have no holes and are naturally packed. Adding packed attribute unnecessarily can generate poor code on architectures that do not support unaligned access.

For the specific case where their fields and alignments are naturally packed I'm not entirely certain you get different codegen but I agree it might and we'd like to avoid it if it does.

In a lot of the cases it seems to be drivers and often appears like it is either structs that are used to hardware registers or firmware protocol data units. Both of which may be need packing.

I will commit to removing packing in structs in this series iff individual maintainers identify the specific structs in reply to the series. If there is no request I'll leave it to them to figure out.

Maintainers should review and request removal as appropriate.

Thanks!

#25 lore raw

v2 cover fix packing of structs when building with MSVC

In reply to Tyler Retzlaff

MSVC struct packing is not compatible with GCC provide a macro that can be used to push existing pack value and sets packing to 1-byte. The existing __rte_packed macro is then used to restore the pack value prior to the push.

Instead of providing macros exclusively for MSVC and for GCC the existing macro is deliberately utilized to trigger a warning if no existing packing has been pushed allowing easy identification of locations where the __rte_msvc_pack is missing.

I've decided to only add the macro to packed structs that are built for Windows. It seems there is little value in adding the macro tree wide and if new code arrives that is built on Windows the __rte_packed will flag where the preamble macro is required.

If as a part of review maintainers identify structs they believe don't require packing so long as they are explicitly identified i'll remove the __rte_packed as a part of this series.

v2:
* app/testpmd, remove packing from simple_gre_hdr
* net/iavf, remove packing from iavf_ipsec_crypto_pkt_metadata, simple_gre_hdr
* examples, remove packing from pkt_key_qinq, pkt_key_ipv4_5tuple,

    pkt_key_ipv6_5tuple, pkt_key_ipv4_addr, pkt_key_ipv6_addr

* eal, remove packing from rte_config, __rte_trace_stream_header

Tyler Retzlaff (15):
eal: provide pack start macro for MSVC
eal: pack structures when building with MSVC
net: pack structures when building with MSVC common/iavf: pack structures when building with MSVC common/idpf: pack structures when building with MSVC common/mlx5: pack structures when building with MSVC dma/ioat: pack structures when building with MSVC net/i40e: pack structures when building with MSVC net/iavf: pack structures when building with MSVC net/ice: pack structures when building with MSVC net/mlx5: pack structures when building with MSVC net/octeon_ep: pack structures when building with MSVC app/testpmd: pack structures when building with MSVC app/test: pack structures when building with MSVC
examples: pack structures when building with MSVC

 app/test-pmd/csumonly.c                     |  2 +-
 app/test/test_efd.c                         |  1 +
 app/test/test_hash.c                        |  1 +
 app/test/test_member.c                      |  1 +
 drivers/common/iavf/iavf_osdep.h            |  2 ++
 drivers/common/iavf/virtchnl_inline_ipsec.h | 11 +++++++++++
 drivers/common/idpf/base/idpf_osdep.h       |  2 ++
 drivers/common/mlx5/mlx5_common_mr.h        |  4 ++++
 drivers/common/mlx5/mlx5_common_utils.h     |  1 +
 drivers/common/mlx5/mlx5_prm.h              | 28 ++++++++++++++++++++++++++++
 drivers/dma/ioat/ioat_hw_defs.h             |  1 +
 drivers/net/i40e/base/i40e_osdep.h          |  2 ++
 drivers/net/iavf/iavf_ipsec_crypto.h        |  4 +++-
 drivers/net/iavf/iavf_rxtx.c                |  2 +-
 drivers/net/ice/base/ice_osdep.h            |  2 ++
 drivers/net/mlx5/hws/mlx5dr.h               |  1 +
 drivers/net/mlx5/mlx5.h                     |  1 +
 drivers/net/mlx5/mlx5_flow.h                |  5 +++++
 drivers/net/mlx5/mlx5_hws_cnt.h             |  1 +
 drivers/net/mlx5/mlx5_utils.h               |  4 ++++
 drivers/net/octeon_ep/otx_ep_mbox.h         |  1 +
 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 ++++++++
 lib/eal/common/eal_private.h                |  2 +-
 lib/eal/include/rte_common.h                |  4 +++-
 lib/eal/include/rte_memory.h                |  1 +
 lib/eal/include/rte_memzone.h               |  1 +
 lib/eal/include/rte_trace_point.h           |  2 +-
 lib/eal/x86/include/rte_memcpy.h            |  3 +++
 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 ++
 52 files changed, 143 insertions(+), 11 deletions(-)
Signature · 1 line
1.8.3.1
#26 lore raw

PATCH v2 1/15 eal: provide pack start macro for MSVC

MSVC struct packing is not compatible with GCC provide a macro that can be used to push existing pack value and sets packing to 1-byte. The existing __rte_packed macro is then used to restore the pack value prior to the push.

Instead of providing macros exclusively for MSVC and for GCC the existing macro is deliberately utilized to trigger a warning if no existing packing has been pushed allowing easy identification of locations where the __rte_msvc_pack is missing.

---
 lib/eal/include/rte_common.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
lib/eal/include/rte_common.h +3 -1
index 298a5c6..44825ed 100644
@@ -97,8 +97,10 @@
  * Force a structure to be packed
  */
 #ifdef RTE_TOOLCHAIN_MSVC
-#define __rte_packed
+#define __rte_msvc_pack __pragma(pack(push, 1))
+#define __rte_packed __pragma(pack(pop))
 #else
+#define __rte_msvc_pack
 #define __rte_packed __attribute__((__packed__))
 #endif
 
Signature · 1 line
1.8.3.1
#27 lore raw

PATCH v2 2/15 eal: pack structures when building with MSVC

In reply to 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.

---
 lib/eal/common/eal_private.h      | 2 +-
 lib/eal/include/rte_memory.h      | 1 +
 lib/eal/include/rte_memzone.h     | 1 +
 lib/eal/include/rte_trace_point.h | 2 +-
 lib/eal/x86/include/rte_memcpy.h  | 3 +++
 5 files changed, 7 insertions(+), 2 deletions(-)
lib/eal/common/eal_private.h +1 -1
index 71523cf..4c929fb 100644
@@ -62,7 +62,7 @@ struct rte_config {
 	 * DPDK instances
 	 */
 	struct rte_mem_config *mem_config;
-} __rte_packed;
+};
 
 /**
  * Get the global configuration structure.
lib/eal/include/rte_memory.h +1 -0
index 842362d..73bb00d 100644
@@ -46,6 +46,7 @@
 /**
  * Physical memory segment descriptor.
  */
+__rte_msvc_pack
 struct rte_memseg {
 	rte_iova_t iova;            /**< Start IO address. */
 	union {
lib/eal/include/rte_memzone.h +1 -0
index 931497f..ca312c0 100644
@@ -45,6 +45,7 @@
  * A structure describing a memzone, which is a contiguous portion of
  * physical memory identified by a name.
  */
+__rte_msvc_pack
 struct rte_memzone {
 
 #define RTE_MEMZONE_NAMESIZE 32       /**< Maximum length of memory zone name.*/
lib/eal/include/rte_trace_point.h +1 -1
index 41e2a7f..e786ee3 100644
@@ -297,7 +297,7 @@ struct __rte_trace_stream_header {
 	rte_uuid_t uuid;
 	uint32_t lcore_id;
 	char thread_name[__RTE_TRACE_EMIT_STRING_LEN_MAX];
-} __rte_packed;
+};
 
 struct __rte_trace_header {
 	uint32_t offset;
lib/eal/x86/include/rte_memcpy.h +3 -0
index 72a9229..fdc5df0 100644
@@ -57,12 +57,15 @@
 	 * Use the following structs to avoid violating C standard
 	 * alignment requirements and to avoid strict aliasing bugs
 	 */
+	__rte_msvc_pack
 	struct rte_uint64_alias {
 		uint64_t val;
 	} __rte_packed __rte_may_alias;
+	__rte_msvc_pack
 	struct rte_uint32_alias {
 		uint32_t val;
 	} __rte_packed __rte_may_alias;
+	__rte_msvc_pack
 	struct rte_uint16_alias {
 		uint16_t val;
 	} __rte_packed __rte_may_alias;
Signature · 1 line
1.8.3.1
#28 lore raw

PATCH v2 3/15 net: pack structures when building with MSVC

In reply to Tyler Retzlaff

Add __rte_msvc_pushpack(1) to all __rte_packed structs to cause packing when building with MSVC.

---
 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(+)
lib/net/rte_arp.h +2 -0
index 668cea1..35d68c1 100644
@@ -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 */
lib/net/rte_dtls.h +1 -0
index 4f541df..0c75b06 100644
@@ -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;
lib/net/rte_esp.h +2 -0
index 464c513..27c9287 100644
@@ -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 */
lib/net/rte_ether.h +1 -0
index 32ed515..354e3a5 100644
@@ -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. */
lib/net/rte_geneve.h +1 -0
index 3bbc561..5c02526 100644
@@ -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. */
lib/net/rte_gre.h +4 -0
index 8da8027..77882e7 100644
@@ -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;
lib/net/rte_gtp.h +5 -0
index 9849872..26fc80a 100644
@@ -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
lib/net/rte_ib.h +1 -0
index 9eab5f9..c4c5d39 100644
@@ -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
lib/net/rte_icmp.h +3 -0
index 4bf64d7..e865db4 100644
@@ -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. */
lib/net/rte_ip.h +4 -0
index 0d103d4..908a25c 100644
@@ -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 */
lib/net/rte_l2tpv2.h +4 -0
index 9cda347..a917013 100644
@@ -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 {
lib/net/rte_macsec.h +2 -0
index d0cd2f6..54de1bd 100644
@@ -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;
lib/net/rte_mpls.h +1 -0
index 51523e7..d5f6026 100644
@@ -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
lib/net/rte_pdcp_hdr.h +4 -0
index 72ae9a6..6a20ad9 100644
@@ -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 */
lib/net/rte_ppp.h +1 -0
index 7b86ac4..fde585f 100644
@@ -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) */
lib/net/rte_sctp.h +1 -0
index 965682d..a6cfe8f 100644
@@ -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. */
lib/net/rte_tcp.h +1 -0
index 506ac4e..d11cb2c 100644
@@ -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. */
lib/net/rte_tls.h +1 -0
index 2eb3c6d..81af4c7 100644
@@ -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;
lib/net/rte_udp.h +1 -0
index 6135494..5416855 100644
@@ -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. */
lib/net/rte_vxlan.h +2 -0
index 997fc78..bcfd579 100644
@@ -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 {
Signature · 1 line
1.8.3.1
#29 lore raw

PATCH v2 4/15 common/iavf: pack structures when building with MSVC

In reply to Tyler Retzlaff

Add __rte_msvc_pushpack(1) to all __rte_packed structs to cause packing when building with MSVC.

---
 drivers/common/iavf/iavf_osdep.h            |  2 ++
 drivers/common/iavf/virtchnl_inline_ipsec.h | 11 +++++++++++
 2 files changed, 13 insertions(+)
drivers/common/iavf/iavf_osdep.h +2 -0
index 263d924..1fb057c 100644
@@ -158,6 +158,7 @@
 } while (0)
 
 /* memory allocation tracking */
+__rte_msvc_pack
 struct iavf_dma_mem {
 	void *va;
 	u64 pa;
@@ -165,6 +166,7 @@ struct iavf_dma_mem {
 	const void *zone;
 } __rte_packed;
 
+__rte_msvc_pack
 struct iavf_virt_mem {
 	void *va;
 	u32 size;
drivers/common/iavf/virtchnl_inline_ipsec.h +11 -0
index 2f4bf15..feb0f44 100644
@@ -109,6 +109,7 @@ enum inline_ipsec_ops {
 };
 
 /* Not all valid, if certain field is invalid, set 1 for all bits */
+__rte_msvc_pack
 struct virtchnl_algo_cap  {
 	u32 algo_type;
 
@@ -132,6 +133,7 @@ struct virtchnl_algo_cap  {
 } __rte_packed;
 
 /* vf record the capability of crypto from the virtchnl */
+__rte_msvc_pack
 struct virtchnl_sym_crypto_cap {
 	u8 crypto_type;
 	u8 algo_cap_num;
@@ -142,6 +144,7 @@ struct virtchnl_sym_crypto_cap {
  * VF pass virtchnl_ipsec_cap to PF
  * and PF return capability of ipsec from virtchnl.
  */
+__rte_msvc_pack
 struct virtchnl_ipsec_cap {
 	/* max number of SA per VF */
 	u16 max_sa_num;
@@ -172,6 +175,7 @@ struct virtchnl_ipsec_cap {
 } __rte_packed;
 
 /* configuration of crypto function */
+__rte_msvc_pack
 struct virtchnl_ipsec_crypto_cfg_item {
 	u8 crypto_type;
 
@@ -203,6 +207,7 @@ struct virtchnl_ipsec_sym_crypto_cfg {
  * PF create SA as configuration and PF driver will return
  * an unique index (sa_idx) for the created SA.
  */
+__rte_msvc_pack
 struct virtchnl_ipsec_sa_cfg {
 	/* IPsec SA Protocol - AH/ESP */
 	u8 virtchnl_protocol_type;
@@ -298,6 +303,7 @@ struct virtchnl_ipsec_sa_cfg {
  * VF send configuration of index of SA to PF
  * PF will update SA according to configuration
  */
+__rte_msvc_pack
 struct virtchnl_ipsec_sa_update {
 	u32 sa_index; /* SA to update */
 	u32 esn_hi; /* high 32 bits of esn */
@@ -310,6 +316,7 @@ struct virtchnl_ipsec_sa_update {
  * flag bitmap indicate all SA or just selected SA will
  * be destroyed
  */
+__rte_msvc_pack
 struct virtchnl_ipsec_sa_destroy {
 	/* All zero bitmap indicates all SA will be destroyed.
 	 * Non-zero bitmap indicates the selected SA in
@@ -325,6 +332,7 @@ struct virtchnl_ipsec_sa_destroy {
  * VF send this SA configuration to PF using virtchnl;
  * PF read SA and will return configuration for the created SA.
  */
+__rte_msvc_pack
 struct virtchnl_ipsec_sa_read {
 	/* SA valid - invalid/valid */
 	u8 valid;
@@ -431,6 +439,7 @@ struct virtchnl_ipsec_sa_read {
 #define VIRTCHNL_IPSEC_INBOUND_SPD_TBL_IPV6	(1)
 
 /* Add allowlist entry in IES */
+__rte_msvc_pack
 struct virtchnl_ipsec_sp_cfg {
 	u32 spi;
 	u32 dip[4];
@@ -459,6 +468,7 @@ struct virtchnl_ipsec_sp_cfg {
 
 
 /* Delete allowlist entry in IES */
+__rte_msvc_pack
 struct virtchnl_ipsec_sp_destroy {
 	/* 0 for IPv4 table, 1 for IPv6 table. */
 	u8 table_id;
@@ -494,6 +504,7 @@ struct virtchnl_ipsec_resp {
 };
 
 /* Internal message descriptor for VF <-> IPsec communication */
+__rte_msvc_pack
 struct inline_ipsec_msg {
 	u16 ipsec_opcode;
 	u16 req_id;
Signature · 1 line
1.8.3.1
#30 lore raw

PATCH v2 5/15 common/idpf: pack structures when building with MSVC

In reply to Tyler Retzlaff

Add __rte_msvc_pushpack(1) to all __rte_packed structs to cause packing when building with MSVC.

---
 drivers/common/idpf/base/idpf_osdep.h | 2 ++
 1 file changed, 2 insertions(+)
drivers/common/idpf/base/idpf_osdep.h +2 -0
index 74a376c..f5fcdc3 100644
@@ -180,6 +180,7 @@ static inline uint64_t idpf_read_addr64(volatile void *addr)
 #define BITS_PER_BYTE       8
 
 /* memory allocation tracking */
+__rte_msvc_pack
 struct idpf_dma_mem {
 	void *va;
 	u64 pa;
@@ -187,6 +188,7 @@ struct idpf_dma_mem {
 	const void *zone;
 } __rte_packed;
 
+__rte_msvc_pack
 struct idpf_virt_mem {
 	void *va;
 	u32 size;
Signature · 1 line
1.8.3.1
#31 lore raw

PATCH v2 6/15 common/mlx5: pack structures when building with MSVC

In reply to Tyler Retzlaff

Add __rte_msvc_pushpack(1) to all __rte_packed structs to cause packing when building with MSVC.

---
 drivers/common/mlx5/mlx5_common_mr.h    |  4 ++++
 drivers/common/mlx5/mlx5_common_utils.h |  1 +
 drivers/common/mlx5/mlx5_prm.h          | 28 ++++++++++++++++++++++++++++
 3 files changed, 33 insertions(+)
drivers/common/mlx5/mlx5_common_mr.h +4 -0
index 8789d40..4f4bd73 100644
@@ -49,6 +49,7 @@ struct mlx5_mr {
 };
 
 /* Cache entry for Memory Region. */
+__rte_msvc_pack
 struct mr_cache_entry {
 	uintptr_t start; /* Start address of MR. */
 	uintptr_t end; /* End address of MR. */
@@ -56,6 +57,7 @@ struct mr_cache_entry {
 } __rte_packed;
 
 /* MR Cache table for Binary search. */
+__rte_msvc_pack
 struct mlx5_mr_btree {
 	uint32_t len; /* Number of entries. */
 	uint32_t size; /* Total number of entries. */
@@ -65,6 +67,7 @@ struct mlx5_mr_btree {
 struct mlx5_common_device;
 
 /* Per-queue MR control descriptor. */
+__rte_msvc_pack
 struct mlx5_mr_ctrl {
 	uint32_t *dev_gen_ptr; /* Generation number of device to poll. */
 	uint32_t cur_gen; /* Generation number saved to flush caches. */
@@ -78,6 +81,7 @@ struct mlx5_mr_ctrl {
 LIST_HEAD(mlx5_mempool_reg_list, mlx5_mempool_reg);
 
 /* Global per-device MR cache. */
+__rte_msvc_pack
 struct mlx5_mr_share_cache {
 	uint32_t dev_gen; /* Generation number to flush local caches. */
 	rte_rwlock_t rwlock; /* MR cache Lock. */
drivers/common/mlx5/mlx5_common_utils.h +1 -0
index ae15119..a44975c 100644
@@ -27,6 +27,7 @@
  * Structure of the entry in the mlx5 list, user should define its own struct
  * that contains this in order to store the data.
  */
+__rte_msvc_pack
 struct mlx5_list_entry {
 	LIST_ENTRY(mlx5_list_entry) next; /* Entry pointers in the list. */
 	uint32_t ref_cnt __rte_aligned(8); /* 0 means, entry is invalid. */
drivers/common/mlx5/mlx5_prm.h +28 -0
index c671c75..bf9ecd1 100644
@@ -319,6 +319,7 @@ enum mlx5_mpw_mode {
 };
 
 /* WQE Control segment. */
+__rte_msvc_pack
 struct mlx5_wqe_cseg {
 	uint32_t opcode;
 	uint32_t sq_ds;
@@ -336,10 +337,12 @@ struct mlx5_wqe_cseg {
 #define WQE_CSEG_WQE_INDEX_OFFSET	 8
 
 /* Header of data segment. Minimal size Data Segment */
+__rte_msvc_pack
 struct mlx5_wqe_dseg {
 	uint32_t bcount;
 	union {
 		uint8_t inline_data[MLX5_DSEG_MIN_INLINE_SIZE];
+		__rte_msvc_pack
 		struct {
 			uint32_t lkey;
 			uint64_t pbuf;
@@ -348,8 +351,10 @@ struct mlx5_wqe_dseg {
 } __rte_packed;
 
 /* Subset of struct WQE Ethernet Segment. */
+__rte_msvc_pack
 struct mlx5_wqe_eseg {
 	union {
+		__rte_msvc_pack
 		struct {
 			uint32_t swp_offs;
 			uint8_t	cs_flags;
@@ -362,6 +367,7 @@ struct mlx5_wqe_eseg {
 				uint16_t vlan_tag;
 			};
 		} __rte_packed;
+		__rte_msvc_pack
 		struct {
 			uint32_t offsets;
 			uint32_t flags;
@@ -371,6 +377,7 @@ struct mlx5_wqe_eseg {
 	};
 } __rte_packed;
 
+__rte_msvc_pack
 struct mlx5_wqe_qseg {
 	uint32_t reserved0;
 	uint32_t reserved1;
@@ -378,6 +385,7 @@ struct mlx5_wqe_qseg {
 	uint32_t qpn_cqn;
 } __rte_packed;
 
+__rte_msvc_pack
 struct mlx5_wqe_wseg {
 	uint32_t operation;
 	uint32_t lkey;
@@ -388,6 +396,7 @@ struct mlx5_wqe_wseg {
 } __rte_packed;
 
 /* The title WQEBB, header of WQE. */
+__rte_msvc_pack
 struct mlx5_wqe {
 	union {
 		struct mlx5_wqe_cseg cseg;
@@ -437,6 +446,7 @@ struct mlx5_cqe {
 	uint8_t lro_num_seg;
 	union {
 		uint8_t user_index_bytes[3];
+		__rte_msvc_pack
 		struct {
 			uint8_t user_index_hi;
 			uint16_t user_index_low;
@@ -460,6 +470,7 @@ struct mlx5_cqe_ts {
 	uint8_t op_own;
 };
 
+__rte_msvc_pack
 struct mlx5_wqe_rseg {
 	uint64_t raddr;
 	uint32_t rkey;
@@ -479,6 +490,7 @@ struct mlx5_wqe_rseg {
 #define MLX5_UMR_KLM_NUM_ALIGN \
 	(MLX5_UMR_KLM_PTR_ALIGN / sizeof(struct mlx5_klm))
 
+__rte_msvc_pack
 struct mlx5_wqe_umr_cseg {
 	uint32_t if_cf_toe_cq_res;
 	uint32_t ko_to_bs;
@@ -486,6 +498,7 @@ struct mlx5_wqe_umr_cseg {
 	uint32_t rsvd1[8];
 } __rte_packed;
 
+__rte_msvc_pack
 struct mlx5_wqe_mkey_cseg {
 	uint32_t fr_res_af_sf;
 	uint32_t qpn_mkey;
@@ -549,6 +562,7 @@ enum {
 #define MLX5_CRYPTO_MMO_TYPE_OFFSET 24
 #define MLX5_CRYPTO_MMO_OP_OFFSET 20
 
+__rte_msvc_pack
 struct mlx5_wqe_umr_bsf_seg {
 	/*
 	 * bs_bpt_eo_es contains:
@@ -582,6 +596,7 @@ struct mlx5_wqe_umr_bsf_seg {
 #pragma GCC diagnostic ignored "-Wpedantic"
 #endif
 
+__rte_msvc_pack
 struct mlx5_umr_wqe {
 	struct mlx5_wqe_cseg ctr;
 	struct mlx5_wqe_umr_cseg ucseg;
@@ -592,18 +607,21 @@ struct mlx5_umr_wqe {
 	};
 } __rte_packed;
 
+__rte_msvc_pack
 struct mlx5_rdma_write_wqe {
 	struct mlx5_wqe_cseg ctr;
 	struct mlx5_wqe_rseg rseg;
 	struct mlx5_wqe_dseg dseg[];
 } __rte_packed;
 
+__rte_msvc_pack
 struct mlx5_wqe_send_en_seg {
 	uint32_t reserve[2];
 	uint32_t sqnpc;
 	uint32_t qpn;
 } __rte_packed;
 
+__rte_msvc_pack
 struct mlx5_wqe_send_en_wqe {
 	struct mlx5_wqe_cseg ctr;
 	struct mlx5_wqe_send_en_seg sseg;
@@ -650,6 +668,7 @@ struct mlx5_wqe_metadata_seg {
 	uint64_t addr;
 };
 
+__rte_msvc_pack
 struct mlx5_gga_wqe {
 	uint32_t opcode;
 	uint32_t sq_ds;
@@ -663,16 +682,19 @@ struct mlx5_gga_wqe {
 } __rte_packed;
 
 union mlx5_gga_compress_opaque {
+	__rte_msvc_pack
 	struct {
 		uint32_t syndrome;
 		uint32_t reserved0;
 		uint32_t scattered_length;
 		union {
+			__rte_msvc_pack
 			struct {
 				uint32_t reserved1[5];
 				uint32_t crc32;
 				uint32_t adler32;
 			} v1 __rte_packed;
+			__rte_msvc_pack
 			struct {
 				uint32_t crc32;
 				uint32_t adler32;
@@ -685,9 +707,11 @@ struct mlx5_gga_wqe {
 };
 
 union mlx5_gga_crypto_opaque {
+	__rte_msvc_pack
 	struct {
 		uint32_t syndrome;
 		uint32_t reserved0[2];
+		__rte_msvc_pack
 		struct {
 			uint32_t iv[3];
 			uint32_t tag_size;
@@ -4134,6 +4158,7 @@ enum mlx5_aso_op {
 #define MLX5_ASO_CSEG_READ_ENABLE 1
 
 /* ASO WQE CTRL segment. */
+__rte_msvc_pack
 struct mlx5_aso_cseg {
 	uint32_t va_h;
 	uint32_t va_l_r;
@@ -4150,6 +4175,7 @@ struct mlx5_aso_cseg {
 #define MLX5_MTR_MAX_TOKEN_VALUE INT32_MAX
 
 /* A meter data segment - 2 per ASO WQE. */
+__rte_msvc_pack
 struct mlx5_aso_mtr_dseg {
 	uint32_t v_bo_sc_bbog_mm;
 	/*
@@ -4191,6 +4217,7 @@ struct mlx5_aso_mtr_dseg {
 #define MLX5_ASO_MTRS_PER_POOL 128
 
 /* ASO WQE data segment. */
+__rte_msvc_pack
 struct mlx5_aso_dseg {
 	union {
 		uint8_t data[MLX5_ASO_WQE_DSEG_SIZE];
@@ -4199,6 +4226,7 @@ struct mlx5_aso_dseg {
 } __rte_packed;
 
 /* ASO WQE. */
+__rte_msvc_pack
 struct mlx5_aso_wqe {
 	struct mlx5_wqe_cseg general_cseg;
 	struct mlx5_aso_cseg aso_cseg;
Signature · 1 line
1.8.3.1
#32 lore raw

PATCH v2 7/15 dma/ioat: pack structures when building with MSVC

In reply to Tyler Retzlaff

Add __rte_msvc_pushpack(1) to all __rte_packed structs to cause packing when building with MSVC.

---
 drivers/dma/ioat/ioat_hw_defs.h | 1 +
 1 file changed, 1 insertion(+)
drivers/dma/ioat/ioat_hw_defs.h +1 -0
index dc3493a..6e32807 100644
@@ -52,6 +52,7 @@
 #define	IOAT_DMACAP_PQ		(1 << 9)
 #define	IOAT_DMACAP_DMA_DIF	(1 << 10)
 
+__rte_msvc_pack
 struct ioat_registers {
 	uint8_t		chancnt;
 	uint8_t		xfercap;
Signature · 1 line
1.8.3.1
#33 lore raw

PATCH v2 8/15 net/i40e: pack structures when building with MSVC

In reply to Tyler Retzlaff

Add __rte_msvc_pushpack(1) to all __rte_packed structs to cause packing when building with MSVC.

---
 drivers/net/i40e/base/i40e_osdep.h | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/i40e/base/i40e_osdep.h +2 -0
index aa5dc61..28439e3 100644
@@ -177,6 +177,7 @@ static inline uint64_t i40e_read64_addr(volatile void *addr)
 #define ARRAY_SIZE(arr) RTE_DIM(arr)
 
 /* memory allocation tracking */
+__rte_msvc_pack
 struct i40e_dma_mem {
 	void *va;
 	u64 pa;
@@ -188,6 +189,7 @@ struct i40e_dma_mem {
 			i40e_allocate_dma_mem_d(h, m, s, a)
 #define i40e_free_dma_mem(h, m) i40e_free_dma_mem_d(h, m)
 
+__rte_msvc_pack
 struct i40e_virt_mem {
 	void *va;
 	u32 size;
Signature · 1 line
1.8.3.1
#34 lore raw

PATCH v2 9/15 net/iavf: pack structures when building with MSVC

In reply to Tyler Retzlaff

Add __rte_msvc_pushpack(1) 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.

---
 drivers/net/iavf/iavf_ipsec_crypto.h | 4 +++-
 drivers/net/iavf/iavf_rxtx.c         | 2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)
drivers/net/iavf/iavf_ipsec_crypto.h +3 -1
index 49f9202..0637ce2 100644
@@ -11,12 +11,14 @@
 
 
 
+__rte_msvc_pack
 struct iavf_tx_ipsec_desc {
 	union {
 		struct {
 			__le64 qw0;
 			__le64 qw1;
 		};
+		__rte_msvc_pack
 		struct {
 			__le16 l4payload_length;
 			__le32 esn;
@@ -97,7 +99,7 @@ struct iavf_ipsec_crypto_pkt_metadata {
 	uint8_t next_proto;		/* Next Protocol (8b/1B) */
 
 	uint32_t esn;		        /* Extended Sequence Number (32b/4B) */
-} __rte_packed;
+};
 
 /**
  * Inline IPsec Crypto offload is supported
drivers/net/iavf/iavf_rxtx.c +1 -1
index 0a5246d..61309c3 100644
@@ -53,7 +53,7 @@
 struct simple_gre_hdr {
 	uint16_t flags;
 	uint16_t proto;
-} __rte_packed;
+};
 
 /* structure that caches offload info for the current packet */
 struct offload_info {
Signature · 1 line
1.8.3.1
#35 lore raw

PATCH v2 10/15 net/ice: pack structures when building with MSVC

In reply to Tyler Retzlaff

Add __rte_msvc_pushpack(1) to all __rte_packed structs to cause packing when building with MSVC.

---
 drivers/net/ice/base/ice_osdep.h | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/ice/base/ice_osdep.h +2 -0
index 0e14b93..087dc6a 100644
@@ -187,6 +187,7 @@
 #define BITS_PER_BYTE       8
 
 /* memory allocation tracking */
+__rte_msvc_pack
 struct ice_dma_mem {
 	void *va;
 	u64 pa;
@@ -194,6 +195,7 @@ struct ice_dma_mem {
 	const void *zone;
 } __rte_packed;
 
+__rte_msvc_pack
 struct ice_virt_mem {
 	void *va;
 	u32 size;
Signature · 1 line
1.8.3.1
#36 lore raw

PATCH v2 11/15 net/mlx5: pack structures when building with MSVC

In reply to Tyler Retzlaff

Add __rte_msvc_pushpack(1) to all __rte_packed structs to cause packing when building with MSVC.

---
 drivers/net/mlx5/hws/mlx5dr.h   | 1 +
 drivers/net/mlx5/mlx5.h         | 1 +
 drivers/net/mlx5/mlx5_flow.h    | 5 +++++
 drivers/net/mlx5/mlx5_hws_cnt.h | 1 +
 drivers/net/mlx5/mlx5_utils.h   | 4 ++++
 5 files changed, 12 insertions(+)
drivers/net/mlx5/hws/mlx5dr.h +1 -0
index 80e118a..cd5bb05 100644
@@ -300,6 +300,7 @@ struct mlx5dr_action_dest_attr {
 	};
 };
 
+__rte_msvc_pack
 struct mlx5dr_crc_encap_entropy_hash_fields {
 	union mlx5dr_crc_encap_entropy_hash_ip_field dst;
 	union mlx5dr_crc_encap_entropy_hash_ip_field src;
drivers/net/mlx5/mlx5.h +1 -0
index 0091a24..6228ee8 100644
@@ -221,6 +221,7 @@ struct mlx5_dev_spawn_data {
 }
 
 /** Data associated with socket messages. */
+__rte_msvc_pack
 struct mlx5_flow_dump_req  {
 	uint32_t port_id; /**< There are plans in DPDK to extend port_id. */
 	uint64_t flow_id;
drivers/net/mlx5/mlx5_flow.h +5 -0
index 0065727..da0f8b7 100644
@@ -658,6 +658,7 @@ struct mlx5_flow_dv_tag_resource {
 };
 
 /* Modify resource structure */
+__rte_msvc_pack
 struct mlx5_flow_dv_modify_hdr_resource {
 	struct mlx5_list_entry entry;
 	void *action; /**< Modify header action object. */
@@ -812,6 +813,7 @@ struct mlx5_flow_dv_dest_array_resource {
 
 
 /** Device flow handle structure for DV mode only. */
+__rte_msvc_pack
 struct mlx5_flow_handle_dv {
 	/* Flow DV api: */
 	struct mlx5_flow_dv_matcher *matcher; /**< Cache to matcher. */
@@ -830,6 +832,7 @@ struct mlx5_flow_handle_dv {
 } __rte_packed;
 
 /** Device flow handle structure: used both for creating & destroying. */
+__rte_msvc_pack
 struct mlx5_flow_handle {
 	SILIST_ENTRY(uint32_t)next;
 	struct mlx5_vf_vlan vf_vlan; /**< Structure for VF VLAN workaround. */
@@ -1231,6 +1234,7 @@ struct mlx5_flow_attr {
 };
 
 /* Flow structure. */
+__rte_msvc_pack
 struct rte_flow {
 	uint32_t dev_handles;
 	/**< Device flow handles that are part of the flow. */
@@ -1304,6 +1308,7 @@ enum {
 #endif
 
 /** HWS flow struct. */
+__rte_msvc_pack
 struct rte_flow_hw {
 	/** The table flow allcated from. */
 	struct rte_flow_template_table *table;
drivers/net/mlx5/mlx5_hws_cnt.h +1 -0
index e005960..1f53a1a 100644
@@ -133,6 +133,7 @@ enum {
 };
 
 /* HWS counter age parameter. */
+__rte_msvc_pack
 struct mlx5_hws_age_param {
 	uint32_t timeout; /* Aging timeout in seconds (atomically accessed). */
 	uint32_t sec_since_last_hit;
drivers/net/mlx5/mlx5_utils.h +4 -0
index f3c0d76..cf80e5e 100644
@@ -118,6 +118,7 @@ struct mlx5_l3t_level_tbl {
 };
 
 /* L3 word entry table data structure. */
+__rte_msvc_pack
 struct mlx5_l3t_entry_word {
 	uint32_t idx; /* Table index. */
 	uint64_t ref_cnt; /* Table ref_cnt. */
@@ -128,6 +129,7 @@ struct mlx5_l3t_entry_word {
 } __rte_packed;
 
 /* L3 double word entry table data structure. */
+__rte_msvc_pack
 struct mlx5_l3t_entry_dword {
 	uint32_t idx; /* Table index. */
 	uint64_t ref_cnt; /* Table ref_cnt. */
@@ -138,6 +140,7 @@ struct mlx5_l3t_entry_dword {
 } __rte_packed;
 
 /* L3 quad word entry table data structure. */
+__rte_msvc_pack
 struct mlx5_l3t_entry_qword {
 	uint32_t idx; /* Table index. */
 	uint64_t ref_cnt; /* Table ref_cnt. */
@@ -148,6 +151,7 @@ struct mlx5_l3t_entry_qword {
 } __rte_packed;
 
 /* L3 pointer entry table data structure. */
+__rte_msvc_pack
 struct mlx5_l3t_entry_ptr {
 	uint32_t idx; /* Table index. */
 	uint64_t ref_cnt; /* Table ref_cnt. */
Signature · 1 line
1.8.3.1
#37 lore raw

PATCH v2 12/15 net/octeon_ep: pack structures when building with MSVC

In reply to Tyler Retzlaff

Add __rte_msvc_pushpack(1) to all __rte_packed structs to cause packing when building with MSVC.

---
 drivers/net/octeon_ep/otx_ep_mbox.h | 1 +
 1 file changed, 1 insertion(+)
drivers/net/octeon_ep/otx_ep_mbox.h +1 -0
index a3fc15c..005fce3 100644
@@ -70,6 +70,7 @@ enum otx_ep_link_autoneg {
 #define OTX_EP_MBOX_MORE_FRAG_FLAG 1
 #define OTX_EP_MBOX_WRITE_WAIT_TIME msecs_to_jiffies(1)
 
+__rte_msvc_pack
 union otx_ep_mbox_word {
 	uint64_t u64;
 	struct {
Signature · 1 line
1.8.3.1
#38 lore raw

PATCH v2 13/15 app/testpmd: pack structures when building with MSVC

In reply to Tyler Retzlaff

Add __rte_msvc_pushpack(1) 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.

---
 app/test-pmd/csumonly.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
app/test-pmd/csumonly.c +1 -1
index 6711dda..f24c381 100644
@@ -92,7 +92,7 @@ struct testpmd_offload_info {
 struct simple_gre_hdr {
 	uint16_t flags;
 	uint16_t proto;
-} __rte_packed;
+};
 
 static uint16_t
 get_udptcp_checksum(struct rte_mbuf *m, void *l3_hdr, uint16_t l4_off,
Signature · 1 line
1.8.3.1
#39 lore raw

PATCH v2 14/15 app/test: pack structures when building with MSVC

In reply to Tyler Retzlaff

Add __rte_msvc_pushpack(1) to all __rte_packed structs to cause packing when building with MSVC.

---
 app/test/test_efd.c    | 1 +
 app/test/test_hash.c   | 1 +
 app/test/test_member.c | 1 +
 3 files changed, 3 insertions(+)
app/test/test_efd.c +1 -0
index 1c0986b..df176a0 100644
@@ -33,6 +33,7 @@
 static unsigned int test_socket_id;
 
 /* 5-tuple key type */
+__rte_msvc_pack
 struct flow_key {
 	uint32_t ip_src;
 	uint32_t ip_dst;
app/test/test_hash.c +1 -0
index d586878..08c1773 100644
@@ -79,6 +79,7 @@
  * Should be packed to avoid holes with potentially
  * undefined content in the middle.
  */
+__rte_msvc_pack
 struct flow_key {
 	uint32_t ip_src;
 	uint32_t ip_dst;
app/test/test_member.c +1 -0
index 5a4d275..ccd481a 100644
@@ -32,6 +32,7 @@
 struct rte_member_setsum *setsum_sketch;
 
 /* 5-tuple key type */
+__rte_msvc_pack
 struct flow_key {
 	uint32_t ip_src;
 	uint32_t ip_dst;
Signature · 1 line
1.8.3.1
#40 lore raw

PATCH v2 15/15 examples: pack structures when building with MSVC

In reply to Tyler Retzlaff

Add __rte_msvc_pushpack(1) 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.

---
 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(-)
examples/common/neon/port_group.h +1 -0
index 421e2e8..bd40590 100644
@@ -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;
examples/ip_pipeline/cli.c +5 -5
index e8269ea..aad6c78 100644
@@ -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,
examples/ipsec-secgw/ipsec.h +1 -0
index bdcada1..bdc6045 100644
@@ -277,6 +277,7 @@ struct socket_ctx {
 	struct rte_mempool *session_pool;
 };
 
+__rte_msvc_pack
 struct cnt_blk {
 	uint32_t salt;
 	uint64_t iv;
examples/l3fwd-power/main.c +2 -0
index f4adcf4..a3be37b 100644
@@ -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];
examples/ptpclient/ptpclient.c +8 -0
index afb61bb..cdd73fd 100644
@@ -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;
Signature · 1 line
1.8.3.1
#41 lore raw

v3 cover fix packing of structs when building with MSVC

In reply to Tyler Retzlaff

MSVC struct packing is not compatible with GCC provide a macro that can be used to push existing pack value and sets packing to 1-byte. The existing __rte_packed macro is then used to restore the pack value prior to the push.

Instead of providing macros exclusively for MSVC and for GCC the existing macro is deliberately utilized to trigger a warning if no existing packing has been pushed allowing easy identification of locations where the __rte_msvc_pack is missing.

I've decided to only add the macro to packed structs that are built for Windows. It seems there is little value in adding the macro tree wide and if new code arrives that is built on Windows the __rte_packed will flag where the preamble macro is required.

If as a part of review maintainers identify structs they believe don't require packing so long as they are explicitly identified i'll remove the __rte_packed as a part of this series.

v3:
* add missing __rte_msvc_pack to crypto/mlx5
* fix commit messages to reference __rte_msvc_pack macro instead

    of __rte_msvc_pushpack(1)

v2:
* app/testpmd, remove packing from simple_gre_hdr
* net/iavf, remove packing from iavf_ipsec_crypto_pkt_metadata, simple_gre_hdr
* examples, remove packing from pkt_key_qinq, pkt_key_ipv4_5tuple,

    pkt_key_ipv6_5tuple, pkt_key_ipv4_addr, pkt_key_ipv6_addr

* eal, remove packing from rte_config, __rte_trace_stream_header

Tyler Retzlaff (16):
eal: provide pack start macro for MSVC
eal: pack structures when building with MSVC
net: pack structures when building with MSVC common/iavf: pack structures when building with MSVC common/idpf: pack structures when building with MSVC common/mlx5: pack structures when building with MSVC dma/ioat: pack structures when building with MSVC net/i40e: pack structures when building with MSVC net/iavf: pack structures when building with MSVC net/ice: pack structures when building with MSVC net/mlx5: pack structures when building with MSVC net/octeon_ep: pack structures when building with MSVC app/testpmd: pack structures when building with MSVC app/test: pack structures when building with MSVC
examples: pack structures when building with MSVC crypto/mlx5: pack structures when building with MSVC

 app/test-pmd/csumonly.c                     |  2 +-
 app/test/test_efd.c                         |  1 +
 app/test/test_hash.c                        |  1 +
 app/test/test_member.c                      |  1 +
 drivers/common/iavf/iavf_osdep.h            |  2 ++
 drivers/common/iavf/virtchnl_inline_ipsec.h | 11 +++++++++++
 drivers/common/idpf/base/idpf_osdep.h       |  2 ++
 drivers/common/mlx5/mlx5_common_mr.h        |  4 ++++
 drivers/common/mlx5/mlx5_common_utils.h     |  1 +
 drivers/common/mlx5/mlx5_prm.h              | 28 ++++++++++++++++++++++++++++
 drivers/crypto/mlx5/mlx5_crypto.h           |  1 +
 drivers/dma/ioat/ioat_hw_defs.h             |  1 +
 drivers/net/i40e/base/i40e_osdep.h          |  2 ++
 drivers/net/iavf/iavf_ipsec_crypto.h        |  4 +++-
 drivers/net/iavf/iavf_rxtx.c                |  2 +-
 drivers/net/ice/base/ice_osdep.h            |  2 ++
 drivers/net/mlx5/hws/mlx5dr.h               |  1 +
 drivers/net/mlx5/mlx5.h                     |  1 +
 drivers/net/mlx5/mlx5_flow.h                |  5 +++++
 drivers/net/mlx5/mlx5_hws_cnt.h             |  1 +
 drivers/net/mlx5/mlx5_utils.h               |  4 ++++
 drivers/net/octeon_ep/otx_ep_mbox.h         |  1 +
 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 ++++++++
 lib/eal/common/eal_private.h                |  2 +-
 lib/eal/include/rte_common.h                |  4 +++-
 lib/eal/include/rte_memory.h                |  1 +
 lib/eal/include/rte_memzone.h               |  1 +
 lib/eal/include/rte_trace_point.h           |  2 +-
 lib/eal/x86/include/rte_memcpy.h            |  3 +++
 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 ++
 53 files changed, 144 insertions(+), 11 deletions(-)
Signature · 1 line
1.8.3.1
#42 lore raw

PATCH v3 1/16 eal: provide pack start macro for MSVC

MSVC struct packing is not compatible with GCC provide a macro that can be used to push existing pack value and sets packing to 1-byte. The existing __rte_packed macro is then used to restore the pack value prior to the push.

Instead of providing macros exclusively for MSVC and for GCC the existing macro is deliberately utilized to trigger a warning if no existing packing has been pushed allowing easy identification of locations where the __rte_msvc_pack is missing.

---
 lib/eal/include/rte_common.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
lib/eal/include/rte_common.h +3 -1
index 298a5c6..44825ed 100644
@@ -97,8 +97,10 @@
  * Force a structure to be packed
  */
 #ifdef RTE_TOOLCHAIN_MSVC
-#define __rte_packed
+#define __rte_msvc_pack __pragma(pack(push, 1))
+#define __rte_packed __pragma(pack(pop))
 #else
+#define __rte_msvc_pack
 #define __rte_packed __attribute__((__packed__))
 #endif
 
Signature · 1 line
1.8.3.1
#43 lore raw

PATCH v3 2/16 eal: pack structures when building with MSVC

In reply to 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.

---
 lib/eal/common/eal_private.h      | 2 +-
 lib/eal/include/rte_memory.h      | 1 +
 lib/eal/include/rte_memzone.h     | 1 +
 lib/eal/include/rte_trace_point.h | 2 +-
 lib/eal/x86/include/rte_memcpy.h  | 3 +++
 5 files changed, 7 insertions(+), 2 deletions(-)
lib/eal/common/eal_private.h +1 -1
index 71523cf..4c929fb 100644
@@ -62,7 +62,7 @@ struct rte_config {
 	 * DPDK instances
 	 */
 	struct rte_mem_config *mem_config;
-} __rte_packed;
+};
 
 /**
  * Get the global configuration structure.
lib/eal/include/rte_memory.h +1 -0
index 842362d..73bb00d 100644
@@ -46,6 +46,7 @@
 /**
  * Physical memory segment descriptor.
  */
+__rte_msvc_pack
 struct rte_memseg {
 	rte_iova_t iova;            /**< Start IO address. */
 	union {
lib/eal/include/rte_memzone.h +1 -0
index 931497f..ca312c0 100644
@@ -45,6 +45,7 @@
  * A structure describing a memzone, which is a contiguous portion of
  * physical memory identified by a name.
  */
+__rte_msvc_pack
 struct rte_memzone {
 
 #define RTE_MEMZONE_NAMESIZE 32       /**< Maximum length of memory zone name.*/
lib/eal/include/rte_trace_point.h +1 -1
index 41e2a7f..e786ee3 100644
@@ -297,7 +297,7 @@ struct __rte_trace_stream_header {
 	rte_uuid_t uuid;
 	uint32_t lcore_id;
 	char thread_name[__RTE_TRACE_EMIT_STRING_LEN_MAX];
-} __rte_packed;
+};
 
 struct __rte_trace_header {
 	uint32_t offset;
lib/eal/x86/include/rte_memcpy.h +3 -0
index 72a9229..fdc5df0 100644
@@ -57,12 +57,15 @@
 	 * Use the following structs to avoid violating C standard
 	 * alignment requirements and to avoid strict aliasing bugs
 	 */
+	__rte_msvc_pack
 	struct rte_uint64_alias {
 		uint64_t val;
 	} __rte_packed __rte_may_alias;
+	__rte_msvc_pack
 	struct rte_uint32_alias {
 		uint32_t val;
 	} __rte_packed __rte_may_alias;
+	__rte_msvc_pack
 	struct rte_uint16_alias {
 		uint16_t val;
 	} __rte_packed __rte_may_alias;
Signature · 1 line
1.8.3.1
#44 lore raw

PATCH v3 3/16 net: pack structures when building with MSVC

In reply to Tyler Retzlaff

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

---
 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(+)
lib/net/rte_arp.h +2 -0
index 668cea1..35d68c1 100644
@@ -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 */
lib/net/rte_dtls.h +1 -0
index 4f541df..0c75b06 100644
@@ -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;
lib/net/rte_esp.h +2 -0
index 464c513..27c9287 100644
@@ -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 */
lib/net/rte_ether.h +1 -0
index 32ed515..354e3a5 100644
@@ -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. */
lib/net/rte_geneve.h +1 -0
index 3bbc561..5c02526 100644
@@ -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. */
lib/net/rte_gre.h +4 -0
index 8da8027..77882e7 100644
@@ -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;
lib/net/rte_gtp.h +5 -0
index 9849872..26fc80a 100644
@@ -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
lib/net/rte_ib.h +1 -0
index 9eab5f9..c4c5d39 100644
@@ -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
lib/net/rte_icmp.h +3 -0
index 4bf64d7..e865db4 100644
@@ -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. */
lib/net/rte_ip.h +4 -0
index 0d103d4..908a25c 100644
@@ -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 */
lib/net/rte_l2tpv2.h +4 -0
index 9cda347..a917013 100644
@@ -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 {
lib/net/rte_macsec.h +2 -0
index d0cd2f6..54de1bd 100644
@@ -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;
lib/net/rte_mpls.h +1 -0
index 51523e7..d5f6026 100644
@@ -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
lib/net/rte_pdcp_hdr.h +4 -0
index 72ae9a6..6a20ad9 100644
@@ -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 */
lib/net/rte_ppp.h +1 -0
index 7b86ac4..fde585f 100644
@@ -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) */
lib/net/rte_sctp.h +1 -0
index 965682d..a6cfe8f 100644
@@ -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. */
lib/net/rte_tcp.h +1 -0
index 506ac4e..d11cb2c 100644
@@ -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. */
lib/net/rte_tls.h +1 -0
index 2eb3c6d..81af4c7 100644
@@ -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;
lib/net/rte_udp.h +1 -0
index 6135494..5416855 100644
@@ -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. */
lib/net/rte_vxlan.h +2 -0
index 997fc78..bcfd579 100644
@@ -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 {
Signature · 1 line
1.8.3.1
#45 lore raw

PATCH v3 4/16 common/iavf: pack structures when building with MSVC

In reply to Tyler Retzlaff

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

---
 drivers/common/iavf/iavf_osdep.h            |  2 ++
 drivers/common/iavf/virtchnl_inline_ipsec.h | 11 +++++++++++
 2 files changed, 13 insertions(+)
drivers/common/iavf/iavf_osdep.h +2 -0
index 263d924..1fb057c 100644
@@ -158,6 +158,7 @@
 } while (0)
 
 /* memory allocation tracking */
+__rte_msvc_pack
 struct iavf_dma_mem {
 	void *va;
 	u64 pa;
@@ -165,6 +166,7 @@ struct iavf_dma_mem {
 	const void *zone;
 } __rte_packed;
 
+__rte_msvc_pack
 struct iavf_virt_mem {
 	void *va;
 	u32 size;
drivers/common/iavf/virtchnl_inline_ipsec.h +11 -0
index 2f4bf15..feb0f44 100644
@@ -109,6 +109,7 @@ enum inline_ipsec_ops {
 };
 
 /* Not all valid, if certain field is invalid, set 1 for all bits */
+__rte_msvc_pack
 struct virtchnl_algo_cap  {
 	u32 algo_type;
 
@@ -132,6 +133,7 @@ struct virtchnl_algo_cap  {
 } __rte_packed;
 
 /* vf record the capability of crypto from the virtchnl */
+__rte_msvc_pack
 struct virtchnl_sym_crypto_cap {
 	u8 crypto_type;
 	u8 algo_cap_num;
@@ -142,6 +144,7 @@ struct virtchnl_sym_crypto_cap {
  * VF pass virtchnl_ipsec_cap to PF
  * and PF return capability of ipsec from virtchnl.
  */
+__rte_msvc_pack
 struct virtchnl_ipsec_cap {
 	/* max number of SA per VF */
 	u16 max_sa_num;
@@ -172,6 +175,7 @@ struct virtchnl_ipsec_cap {
 } __rte_packed;
 
 /* configuration of crypto function */
+__rte_msvc_pack
 struct virtchnl_ipsec_crypto_cfg_item {
 	u8 crypto_type;
 
@@ -203,6 +207,7 @@ struct virtchnl_ipsec_sym_crypto_cfg {
  * PF create SA as configuration and PF driver will return
  * an unique index (sa_idx) for the created SA.
  */
+__rte_msvc_pack
 struct virtchnl_ipsec_sa_cfg {
 	/* IPsec SA Protocol - AH/ESP */
 	u8 virtchnl_protocol_type;
@@ -298,6 +303,7 @@ struct virtchnl_ipsec_sa_cfg {
  * VF send configuration of index of SA to PF
  * PF will update SA according to configuration
  */
+__rte_msvc_pack
 struct virtchnl_ipsec_sa_update {
 	u32 sa_index; /* SA to update */
 	u32 esn_hi; /* high 32 bits of esn */
@@ -310,6 +316,7 @@ struct virtchnl_ipsec_sa_update {
  * flag bitmap indicate all SA or just selected SA will
  * be destroyed
  */
+__rte_msvc_pack
 struct virtchnl_ipsec_sa_destroy {
 	/* All zero bitmap indicates all SA will be destroyed.
 	 * Non-zero bitmap indicates the selected SA in
@@ -325,6 +332,7 @@ struct virtchnl_ipsec_sa_destroy {
  * VF send this SA configuration to PF using virtchnl;
  * PF read SA and will return configuration for the created SA.
  */
+__rte_msvc_pack
 struct virtchnl_ipsec_sa_read {
 	/* SA valid - invalid/valid */
 	u8 valid;
@@ -431,6 +439,7 @@ struct virtchnl_ipsec_sa_read {
 #define VIRTCHNL_IPSEC_INBOUND_SPD_TBL_IPV6	(1)
 
 /* Add allowlist entry in IES */
+__rte_msvc_pack
 struct virtchnl_ipsec_sp_cfg {
 	u32 spi;
 	u32 dip[4];
@@ -459,6 +468,7 @@ struct virtchnl_ipsec_sp_cfg {
 
 
 /* Delete allowlist entry in IES */
+__rte_msvc_pack
 struct virtchnl_ipsec_sp_destroy {
 	/* 0 for IPv4 table, 1 for IPv6 table. */
 	u8 table_id;
@@ -494,6 +504,7 @@ struct virtchnl_ipsec_resp {
 };
 
 /* Internal message descriptor for VF <-> IPsec communication */
+__rte_msvc_pack
 struct inline_ipsec_msg {
 	u16 ipsec_opcode;
 	u16 req_id;
Signature · 1 line
1.8.3.1
#46 lore raw

PATCH v3 5/16 common/idpf: pack structures when building with MSVC

In reply to Tyler Retzlaff

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

---
 drivers/common/idpf/base/idpf_osdep.h | 2 ++
 1 file changed, 2 insertions(+)
drivers/common/idpf/base/idpf_osdep.h +2 -0
index 74a376c..f5fcdc3 100644
@@ -180,6 +180,7 @@ static inline uint64_t idpf_read_addr64(volatile void *addr)
 #define BITS_PER_BYTE       8
 
 /* memory allocation tracking */
+__rte_msvc_pack
 struct idpf_dma_mem {
 	void *va;
 	u64 pa;
@@ -187,6 +188,7 @@ struct idpf_dma_mem {
 	const void *zone;
 } __rte_packed;
 
+__rte_msvc_pack
 struct idpf_virt_mem {
 	void *va;
 	u32 size;
Signature · 1 line
1.8.3.1
#47 lore raw

PATCH v3 6/16 common/mlx5: pack structures when building with MSVC

In reply to Tyler Retzlaff

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

---
 drivers/common/mlx5/mlx5_common_mr.h    |  4 ++++
 drivers/common/mlx5/mlx5_common_utils.h |  1 +
 drivers/common/mlx5/mlx5_prm.h          | 28 ++++++++++++++++++++++++++++
 3 files changed, 33 insertions(+)
drivers/common/mlx5/mlx5_common_mr.h +4 -0
index 8789d40..4f4bd73 100644
@@ -49,6 +49,7 @@ struct mlx5_mr {
 };
 
 /* Cache entry for Memory Region. */
+__rte_msvc_pack
 struct mr_cache_entry {
 	uintptr_t start; /* Start address of MR. */
 	uintptr_t end; /* End address of MR. */
@@ -56,6 +57,7 @@ struct mr_cache_entry {
 } __rte_packed;
 
 /* MR Cache table for Binary search. */
+__rte_msvc_pack
 struct mlx5_mr_btree {
 	uint32_t len; /* Number of entries. */
 	uint32_t size; /* Total number of entries. */
@@ -65,6 +67,7 @@ struct mlx5_mr_btree {
 struct mlx5_common_device;
 
 /* Per-queue MR control descriptor. */
+__rte_msvc_pack
 struct mlx5_mr_ctrl {
 	uint32_t *dev_gen_ptr; /* Generation number of device to poll. */
 	uint32_t cur_gen; /* Generation number saved to flush caches. */
@@ -78,6 +81,7 @@ struct mlx5_mr_ctrl {
 LIST_HEAD(mlx5_mempool_reg_list, mlx5_mempool_reg);
 
 /* Global per-device MR cache. */
+__rte_msvc_pack
 struct mlx5_mr_share_cache {
 	uint32_t dev_gen; /* Generation number to flush local caches. */
 	rte_rwlock_t rwlock; /* MR cache Lock. */
drivers/common/mlx5/mlx5_common_utils.h +1 -0
index ae15119..a44975c 100644
@@ -27,6 +27,7 @@
  * Structure of the entry in the mlx5 list, user should define its own struct
  * that contains this in order to store the data.
  */
+__rte_msvc_pack
 struct mlx5_list_entry {
 	LIST_ENTRY(mlx5_list_entry) next; /* Entry pointers in the list. */
 	uint32_t ref_cnt __rte_aligned(8); /* 0 means, entry is invalid. */
drivers/common/mlx5/mlx5_prm.h +28 -0
index c671c75..bf9ecd1 100644
@@ -319,6 +319,7 @@ enum mlx5_mpw_mode {
 };
 
 /* WQE Control segment. */
+__rte_msvc_pack
 struct mlx5_wqe_cseg {
 	uint32_t opcode;
 	uint32_t sq_ds;
@@ -336,10 +337,12 @@ struct mlx5_wqe_cseg {
 #define WQE_CSEG_WQE_INDEX_OFFSET	 8
 
 /* Header of data segment. Minimal size Data Segment */
+__rte_msvc_pack
 struct mlx5_wqe_dseg {
 	uint32_t bcount;
 	union {
 		uint8_t inline_data[MLX5_DSEG_MIN_INLINE_SIZE];
+		__rte_msvc_pack
 		struct {
 			uint32_t lkey;
 			uint64_t pbuf;
@@ -348,8 +351,10 @@ struct mlx5_wqe_dseg {
 } __rte_packed;
 
 /* Subset of struct WQE Ethernet Segment. */
+__rte_msvc_pack
 struct mlx5_wqe_eseg {
 	union {
+		__rte_msvc_pack
 		struct {
 			uint32_t swp_offs;
 			uint8_t	cs_flags;
@@ -362,6 +367,7 @@ struct mlx5_wqe_eseg {
 				uint16_t vlan_tag;
 			};
 		} __rte_packed;
+		__rte_msvc_pack
 		struct {
 			uint32_t offsets;
 			uint32_t flags;
@@ -371,6 +377,7 @@ struct mlx5_wqe_eseg {
 	};
 } __rte_packed;
 
+__rte_msvc_pack
 struct mlx5_wqe_qseg {
 	uint32_t reserved0;
 	uint32_t reserved1;
@@ -378,6 +385,7 @@ struct mlx5_wqe_qseg {
 	uint32_t qpn_cqn;
 } __rte_packed;
 
+__rte_msvc_pack
 struct mlx5_wqe_wseg {
 	uint32_t operation;
 	uint32_t lkey;
@@ -388,6 +396,7 @@ struct mlx5_wqe_wseg {
 } __rte_packed;
 
 /* The title WQEBB, header of WQE. */
+__rte_msvc_pack
 struct mlx5_wqe {
 	union {
 		struct mlx5_wqe_cseg cseg;
@@ -437,6 +446,7 @@ struct mlx5_cqe {
 	uint8_t lro_num_seg;
 	union {
 		uint8_t user_index_bytes[3];
+		__rte_msvc_pack
 		struct {
 			uint8_t user_index_hi;
 			uint16_t user_index_low;
@@ -460,6 +470,7 @@ struct mlx5_cqe_ts {
 	uint8_t op_own;
 };
 
+__rte_msvc_pack
 struct mlx5_wqe_rseg {
 	uint64_t raddr;
 	uint32_t rkey;
@@ -479,6 +490,7 @@ struct mlx5_wqe_rseg {
 #define MLX5_UMR_KLM_NUM_ALIGN \
 	(MLX5_UMR_KLM_PTR_ALIGN / sizeof(struct mlx5_klm))
 
+__rte_msvc_pack
 struct mlx5_wqe_umr_cseg {
 	uint32_t if_cf_toe_cq_res;
 	uint32_t ko_to_bs;
@@ -486,6 +498,7 @@ struct mlx5_wqe_umr_cseg {
 	uint32_t rsvd1[8];
 } __rte_packed;
 
+__rte_msvc_pack
 struct mlx5_wqe_mkey_cseg {
 	uint32_t fr_res_af_sf;
 	uint32_t qpn_mkey;
@@ -549,6 +562,7 @@ enum {
 #define MLX5_CRYPTO_MMO_TYPE_OFFSET 24
 #define MLX5_CRYPTO_MMO_OP_OFFSET 20
 
+__rte_msvc_pack
 struct mlx5_wqe_umr_bsf_seg {
 	/*
 	 * bs_bpt_eo_es contains:
@@ -582,6 +596,7 @@ struct mlx5_wqe_umr_bsf_seg {
 #pragma GCC diagnostic ignored "-Wpedantic"
 #endif
 
+__rte_msvc_pack
 struct mlx5_umr_wqe {
 	struct mlx5_wqe_cseg ctr;
 	struct mlx5_wqe_umr_cseg ucseg;
@@ -592,18 +607,21 @@ struct mlx5_umr_wqe {
 	};
 } __rte_packed;
 
+__rte_msvc_pack
 struct mlx5_rdma_write_wqe {
 	struct mlx5_wqe_cseg ctr;
 	struct mlx5_wqe_rseg rseg;
 	struct mlx5_wqe_dseg dseg[];
 } __rte_packed;
 
+__rte_msvc_pack
 struct mlx5_wqe_send_en_seg {
 	uint32_t reserve[2];
 	uint32_t sqnpc;
 	uint32_t qpn;
 } __rte_packed;
 
+__rte_msvc_pack
 struct mlx5_wqe_send_en_wqe {
 	struct mlx5_wqe_cseg ctr;
 	struct mlx5_wqe_send_en_seg sseg;
@@ -650,6 +668,7 @@ struct mlx5_wqe_metadata_seg {
 	uint64_t addr;
 };
 
+__rte_msvc_pack
 struct mlx5_gga_wqe {
 	uint32_t opcode;
 	uint32_t sq_ds;
@@ -663,16 +682,19 @@ struct mlx5_gga_wqe {
 } __rte_packed;
 
 union mlx5_gga_compress_opaque {
+	__rte_msvc_pack
 	struct {
 		uint32_t syndrome;
 		uint32_t reserved0;
 		uint32_t scattered_length;
 		union {
+			__rte_msvc_pack
 			struct {
 				uint32_t reserved1[5];
 				uint32_t crc32;
 				uint32_t adler32;
 			} v1 __rte_packed;
+			__rte_msvc_pack
 			struct {
 				uint32_t crc32;
 				uint32_t adler32;
@@ -685,9 +707,11 @@ struct mlx5_gga_wqe {
 };
 
 union mlx5_gga_crypto_opaque {
+	__rte_msvc_pack
 	struct {
 		uint32_t syndrome;
 		uint32_t reserved0[2];
+		__rte_msvc_pack
 		struct {
 			uint32_t iv[3];
 			uint32_t tag_size;
@@ -4134,6 +4158,7 @@ enum mlx5_aso_op {
 #define MLX5_ASO_CSEG_READ_ENABLE 1
 
 /* ASO WQE CTRL segment. */
+__rte_msvc_pack
 struct mlx5_aso_cseg {
 	uint32_t va_h;
 	uint32_t va_l_r;
@@ -4150,6 +4175,7 @@ struct mlx5_aso_cseg {
 #define MLX5_MTR_MAX_TOKEN_VALUE INT32_MAX
 
 /* A meter data segment - 2 per ASO WQE. */
+__rte_msvc_pack
 struct mlx5_aso_mtr_dseg {
 	uint32_t v_bo_sc_bbog_mm;
 	/*
@@ -4191,6 +4217,7 @@ struct mlx5_aso_mtr_dseg {
 #define MLX5_ASO_MTRS_PER_POOL 128
 
 /* ASO WQE data segment. */
+__rte_msvc_pack
 struct mlx5_aso_dseg {
 	union {
 		uint8_t data[MLX5_ASO_WQE_DSEG_SIZE];
@@ -4199,6 +4226,7 @@ struct mlx5_aso_dseg {
 } __rte_packed;
 
 /* ASO WQE. */
+__rte_msvc_pack
 struct mlx5_aso_wqe {
 	struct mlx5_wqe_cseg general_cseg;
 	struct mlx5_aso_cseg aso_cseg;
Signature · 1 line
1.8.3.1
#48 lore raw

PATCH v3 7/16 dma/ioat: pack structures when building with MSVC

In reply to Tyler Retzlaff

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

---
 drivers/dma/ioat/ioat_hw_defs.h | 1 +
 1 file changed, 1 insertion(+)
drivers/dma/ioat/ioat_hw_defs.h +1 -0
index dc3493a..6e32807 100644
@@ -52,6 +52,7 @@
 #define	IOAT_DMACAP_PQ		(1 << 9)
 #define	IOAT_DMACAP_DMA_DIF	(1 << 10)
 
+__rte_msvc_pack
 struct ioat_registers {
 	uint8_t		chancnt;
 	uint8_t		xfercap;
Signature · 1 line
1.8.3.1
#49 lore raw

PATCH v3 8/16 net/i40e: pack structures when building with MSVC

In reply to Tyler Retzlaff

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

---
 drivers/net/i40e/base/i40e_osdep.h | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/i40e/base/i40e_osdep.h +2 -0
index aa5dc61..28439e3 100644
@@ -177,6 +177,7 @@ static inline uint64_t i40e_read64_addr(volatile void *addr)
 #define ARRAY_SIZE(arr) RTE_DIM(arr)
 
 /* memory allocation tracking */
+__rte_msvc_pack
 struct i40e_dma_mem {
 	void *va;
 	u64 pa;
@@ -188,6 +189,7 @@ struct i40e_dma_mem {
 			i40e_allocate_dma_mem_d(h, m, s, a)
 #define i40e_free_dma_mem(h, m) i40e_free_dma_mem_d(h, m)
 
+__rte_msvc_pack
 struct i40e_virt_mem {
 	void *va;
 	u32 size;
Signature · 1 line
1.8.3.1
#50 lore raw

PATCH v3 9/16 net/iavf: pack structures when building with MSVC

In reply to 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.

---
 drivers/net/iavf/iavf_ipsec_crypto.h | 4 +++-
 drivers/net/iavf/iavf_rxtx.c         | 2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)
drivers/net/iavf/iavf_ipsec_crypto.h +3 -1
index 49f9202..0637ce2 100644
@@ -11,12 +11,14 @@
 
 
 
+__rte_msvc_pack
 struct iavf_tx_ipsec_desc {
 	union {
 		struct {
 			__le64 qw0;
 			__le64 qw1;
 		};
+		__rte_msvc_pack
 		struct {
 			__le16 l4payload_length;
 			__le32 esn;
@@ -97,7 +99,7 @@ struct iavf_ipsec_crypto_pkt_metadata {
 	uint8_t next_proto;		/* Next Protocol (8b/1B) */
 
 	uint32_t esn;		        /* Extended Sequence Number (32b/4B) */
-} __rte_packed;
+};
 
 /**
  * Inline IPsec Crypto offload is supported
drivers/net/iavf/iavf_rxtx.c +1 -1
index 0a5246d..61309c3 100644
@@ -53,7 +53,7 @@
 struct simple_gre_hdr {
 	uint16_t flags;
 	uint16_t proto;
-} __rte_packed;
+};
 
 /* structure that caches offload info for the current packet */
 struct offload_info {
Signature · 1 line
1.8.3.1
#51 lore raw

PATCH v3 10/16 net/ice: pack structures when building with MSVC

In reply to Tyler Retzlaff

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

---
 drivers/net/ice/base/ice_osdep.h | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/ice/base/ice_osdep.h +2 -0
index 0e14b93..087dc6a 100644
@@ -187,6 +187,7 @@
 #define BITS_PER_BYTE       8
 
 /* memory allocation tracking */
+__rte_msvc_pack
 struct ice_dma_mem {
 	void *va;
 	u64 pa;
@@ -194,6 +195,7 @@ struct ice_dma_mem {
 	const void *zone;
 } __rte_packed;
 
+__rte_msvc_pack
 struct ice_virt_mem {
 	void *va;
 	u32 size;
Signature · 1 line
1.8.3.1
#52 lore raw

PATCH v3 11/16 net/mlx5: pack structures when building with MSVC

In reply to Tyler Retzlaff

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

---
 drivers/net/mlx5/hws/mlx5dr.h   | 1 +
 drivers/net/mlx5/mlx5.h         | 1 +
 drivers/net/mlx5/mlx5_flow.h    | 5 +++++
 drivers/net/mlx5/mlx5_hws_cnt.h | 1 +
 drivers/net/mlx5/mlx5_utils.h   | 4 ++++
 5 files changed, 12 insertions(+)
drivers/net/mlx5/hws/mlx5dr.h +1 -0
index 80e118a..cd5bb05 100644
@@ -300,6 +300,7 @@ struct mlx5dr_action_dest_attr {
 	};
 };
 
+__rte_msvc_pack
 struct mlx5dr_crc_encap_entropy_hash_fields {
 	union mlx5dr_crc_encap_entropy_hash_ip_field dst;
 	union mlx5dr_crc_encap_entropy_hash_ip_field src;
drivers/net/mlx5/mlx5.h +1 -0
index 0091a24..6228ee8 100644
@@ -221,6 +221,7 @@ struct mlx5_dev_spawn_data {
 }
 
 /** Data associated with socket messages. */
+__rte_msvc_pack
 struct mlx5_flow_dump_req  {
 	uint32_t port_id; /**< There are plans in DPDK to extend port_id. */
 	uint64_t flow_id;
drivers/net/mlx5/mlx5_flow.h +5 -0
index 0065727..da0f8b7 100644
@@ -658,6 +658,7 @@ struct mlx5_flow_dv_tag_resource {
 };
 
 /* Modify resource structure */
+__rte_msvc_pack
 struct mlx5_flow_dv_modify_hdr_resource {
 	struct mlx5_list_entry entry;
 	void *action; /**< Modify header action object. */
@@ -812,6 +813,7 @@ struct mlx5_flow_dv_dest_array_resource {
 
 
 /** Device flow handle structure for DV mode only. */
+__rte_msvc_pack
 struct mlx5_flow_handle_dv {
 	/* Flow DV api: */
 	struct mlx5_flow_dv_matcher *matcher; /**< Cache to matcher. */
@@ -830,6 +832,7 @@ struct mlx5_flow_handle_dv {
 } __rte_packed;
 
 /** Device flow handle structure: used both for creating & destroying. */
+__rte_msvc_pack
 struct mlx5_flow_handle {
 	SILIST_ENTRY(uint32_t)next;
 	struct mlx5_vf_vlan vf_vlan; /**< Structure for VF VLAN workaround. */
@@ -1231,6 +1234,7 @@ struct mlx5_flow_attr {
 };
 
 /* Flow structure. */
+__rte_msvc_pack
 struct rte_flow {
 	uint32_t dev_handles;
 	/**< Device flow handles that are part of the flow. */
@@ -1304,6 +1308,7 @@ enum {
 #endif
 
 /** HWS flow struct. */
+__rte_msvc_pack
 struct rte_flow_hw {
 	/** The table flow allcated from. */
 	struct rte_flow_template_table *table;
drivers/net/mlx5/mlx5_hws_cnt.h +1 -0
index e005960..1f53a1a 100644
@@ -133,6 +133,7 @@ enum {
 };
 
 /* HWS counter age parameter. */
+__rte_msvc_pack
 struct mlx5_hws_age_param {
 	uint32_t timeout; /* Aging timeout in seconds (atomically accessed). */
 	uint32_t sec_since_last_hit;
drivers/net/mlx5/mlx5_utils.h +4 -0
index f3c0d76..cf80e5e 100644
@@ -118,6 +118,7 @@ struct mlx5_l3t_level_tbl {
 };
 
 /* L3 word entry table data structure. */
+__rte_msvc_pack
 struct mlx5_l3t_entry_word {
 	uint32_t idx; /* Table index. */
 	uint64_t ref_cnt; /* Table ref_cnt. */
@@ -128,6 +129,7 @@ struct mlx5_l3t_entry_word {
 } __rte_packed;
 
 /* L3 double word entry table data structure. */
+__rte_msvc_pack
 struct mlx5_l3t_entry_dword {
 	uint32_t idx; /* Table index. */
 	uint64_t ref_cnt; /* Table ref_cnt. */
@@ -138,6 +140,7 @@ struct mlx5_l3t_entry_dword {
 } __rte_packed;
 
 /* L3 quad word entry table data structure. */
+__rte_msvc_pack
 struct mlx5_l3t_entry_qword {
 	uint32_t idx; /* Table index. */
 	uint64_t ref_cnt; /* Table ref_cnt. */
@@ -148,6 +151,7 @@ struct mlx5_l3t_entry_qword {
 } __rte_packed;
 
 /* L3 pointer entry table data structure. */
+__rte_msvc_pack
 struct mlx5_l3t_entry_ptr {
 	uint32_t idx; /* Table index. */
 	uint64_t ref_cnt; /* Table ref_cnt. */
Signature · 1 line
1.8.3.1
#53 lore raw

PATCH v3 12/16 net/octeon_ep: pack structures when building with MSVC

In reply to Tyler Retzlaff

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

---
 drivers/net/octeon_ep/otx_ep_mbox.h | 1 +
 1 file changed, 1 insertion(+)
drivers/net/octeon_ep/otx_ep_mbox.h +1 -0
index a3fc15c..005fce3 100644
@@ -70,6 +70,7 @@ enum otx_ep_link_autoneg {
 #define OTX_EP_MBOX_MORE_FRAG_FLAG 1
 #define OTX_EP_MBOX_WRITE_WAIT_TIME msecs_to_jiffies(1)
 
+__rte_msvc_pack
 union otx_ep_mbox_word {
 	uint64_t u64;
 	struct {
Signature · 1 line
1.8.3.1
#54 lore raw

PATCH v3 13/16 app/testpmd: pack structures when building with MSVC

In reply to 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.

---
 app/test-pmd/csumonly.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
app/test-pmd/csumonly.c +1 -1
index 6711dda..f24c381 100644
@@ -92,7 +92,7 @@ struct testpmd_offload_info {
 struct simple_gre_hdr {
 	uint16_t flags;
 	uint16_t proto;
-} __rte_packed;
+};
 
 static uint16_t
 get_udptcp_checksum(struct rte_mbuf *m, void *l3_hdr, uint16_t l4_off,
Signature · 1 line
1.8.3.1
#55 lore raw

PATCH v3 14/16 app/test: pack structures when building with MSVC

In reply to Tyler Retzlaff

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

---
 app/test/test_efd.c    | 1 +
 app/test/test_hash.c   | 1 +
 app/test/test_member.c | 1 +
 3 files changed, 3 insertions(+)
app/test/test_efd.c +1 -0
index 1c0986b..df176a0 100644
@@ -33,6 +33,7 @@
 static unsigned int test_socket_id;
 
 /* 5-tuple key type */
+__rte_msvc_pack
 struct flow_key {
 	uint32_t ip_src;
 	uint32_t ip_dst;
app/test/test_hash.c +1 -0
index d586878..08c1773 100644
@@ -79,6 +79,7 @@
  * Should be packed to avoid holes with potentially
  * undefined content in the middle.
  */
+__rte_msvc_pack
 struct flow_key {
 	uint32_t ip_src;
 	uint32_t ip_dst;
app/test/test_member.c +1 -0
index 5a4d275..ccd481a 100644
@@ -32,6 +32,7 @@
 struct rte_member_setsum *setsum_sketch;
 
 /* 5-tuple key type */
+__rte_msvc_pack
 struct flow_key {
 	uint32_t ip_src;
 	uint32_t ip_dst;
Signature · 1 line
1.8.3.1
#56 lore raw

PATCH v3 15/16 examples: pack structures when building with MSVC

In reply to 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.

---
 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(-)
examples/common/neon/port_group.h +1 -0
index 421e2e8..bd40590 100644
@@ -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;
examples/ip_pipeline/cli.c +5 -5
index e8269ea..aad6c78 100644
@@ -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,
examples/ipsec-secgw/ipsec.h +1 -0
index bdcada1..bdc6045 100644
@@ -277,6 +277,7 @@ struct socket_ctx {
 	struct rte_mempool *session_pool;
 };
 
+__rte_msvc_pack
 struct cnt_blk {
 	uint32_t salt;
 	uint64_t iv;
examples/l3fwd-power/main.c +2 -0
index f4adcf4..a3be37b 100644
@@ -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];
examples/ptpclient/ptpclient.c +8 -0
index afb61bb..cdd73fd 100644
@@ -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;
Signature · 1 line
1.8.3.1
#57 lore raw

PATCH v3 16/16 crypto/mlx5: pack structures when building with MSVC

In reply to Tyler Retzlaff

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

---
 drivers/crypto/mlx5/mlx5_crypto.h | 1 +
 1 file changed, 1 insertion(+)
drivers/crypto/mlx5/mlx5_crypto.h +1 -0
index 36dacdc..3b4916d 100644
@@ -95,6 +95,7 @@ struct mlx5_crypto_devarg_params {
 	uint32_t is_aes_gcm:1;
 };
 
+__rte_msvc_pack
 struct mlx5_crypto_session {
 	union {
 		/**< AES-XTS configuration. */
Signature · 1 line
1.8.3.1
#58 lore raw

v4 cover fix packing of structs when building with MSVC

In reply to Tyler Retzlaff

MSVC struct packing is not compatible with GCC provide a macro that can be used to push existing pack value and sets packing to 1-byte. The existing __rte_packed macro is then used to restore the pack value prior to the push.

Instead of providing macros exclusively for MSVC and for GCC the existing macro is deliberately utilized to trigger a warning if no existing packing has been pushed allowing easy identification of locations where the __rte_msvc_pack is missing.

I've decided to only add the macro to packed structs that are built for Windows. It seems there is little value in adding the macro tree wide and if new code arrives that is built on Windows the __rte_packed will flag where the preamble macro is required.

If as a part of review maintainers identify structs they believe don't require packing so long as they are explicitly identified i'll remove the __rte_packed as a part of this series.

v4:
* add another missing __rte_msvc_pack to crypto/mlx5 patch
* correct commit message for duplicated packing packing in crypto/mlx5 patch

v3:
* add missing __rte_msvc_pack to crypto/mlx5
* fix commit messages to reference __rte_msvc_pack macro instead

    of __rte_msvc_pushpack(1)

v2:
* app/testpmd, remove packing from simple_gre_hdr
* net/iavf, remove packing from iavf_ipsec_crypto_pkt_metadata, simple_gre_hdr
* examples, remove packing from pkt_key_qinq, pkt_key_ipv4_5tuple,

    pkt_key_ipv6_5tuple, pkt_key_ipv4_addr, pkt_key_ipv6_addr

* eal, remove packing from rte_config, __rte_trace_stream_header

Tyler Retzlaff (16):
eal: provide pack start macro for MSVC
eal: pack structures when building with MSVC
net: pack structures when building with MSVC common/iavf: pack structures when building with MSVC common/idpf: pack structures when building with MSVC common/mlx5: pack structures when building with MSVC dma/ioat: pack structures when building with MSVC net/i40e: pack structures when building with MSVC net/iavf: pack structures when building with MSVC net/ice: pack structures when building with MSVC net/mlx5: pack structures when building with MSVC net/octeon_ep: pack structures when building with MSVC app/testpmd: pack structures when building with MSVC app/test: pack structures when building with MSVC
examples: pack structures when building with MSVC crypto/mlx5: pack structures when building with MSVC

 app/test-pmd/csumonly.c                     |  2 +-
 app/test/test_efd.c                         |  1 +
 app/test/test_hash.c                        |  1 +
 app/test/test_member.c                      |  1 +
 drivers/common/iavf/iavf_osdep.h            |  2 ++
 drivers/common/iavf/virtchnl_inline_ipsec.h | 11 +++++++++++
 drivers/common/idpf/base/idpf_osdep.h       |  2 ++
 drivers/common/mlx5/mlx5_common_mr.h        |  4 ++++
 drivers/common/mlx5/mlx5_common_utils.h     |  1 +
 drivers/common/mlx5/mlx5_prm.h              | 28 ++++++++++++++++++++++++++++
 drivers/crypto/mlx5/mlx5_crypto.h           |  1 +
 drivers/crypto/mlx5/mlx5_crypto_gcm.c       |  1 +
 drivers/dma/ioat/ioat_hw_defs.h             |  1 +
 drivers/net/i40e/base/i40e_osdep.h          |  2 ++
 drivers/net/iavf/iavf_ipsec_crypto.h        |  4 +++-
 drivers/net/iavf/iavf_rxtx.c                |  2 +-
 drivers/net/ice/base/ice_osdep.h            |  2 ++
 drivers/net/mlx5/hws/mlx5dr.h               |  1 +
 drivers/net/mlx5/mlx5.h                     |  1 +
 drivers/net/mlx5/mlx5_flow.h                |  5 +++++
 drivers/net/mlx5/mlx5_hws_cnt.h             |  1 +
 drivers/net/mlx5/mlx5_utils.h               |  4 ++++
 drivers/net/octeon_ep/otx_ep_mbox.h         |  1 +
 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 ++++++++
 lib/eal/common/eal_private.h                |  2 +-
 lib/eal/include/rte_common.h                |  4 +++-
 lib/eal/include/rte_memory.h                |  1 +
 lib/eal/include/rte_memzone.h               |  1 +
 lib/eal/include/rte_trace_point.h           |  2 +-
 lib/eal/x86/include/rte_memcpy.h            |  3 +++
 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 ++
 54 files changed, 145 insertions(+), 11 deletions(-)
Signature · 1 line
1.8.3.1
#59 lore raw

PATCH v4 1/16 eal: provide pack start macro for MSVC

MSVC struct packing is not compatible with GCC provide a macro that can be used to push existing pack value and sets packing to 1-byte. The existing __rte_packed macro is then used to restore the pack value prior to the push.

Instead of providing macros exclusively for MSVC and for GCC the existing macro is deliberately utilized to trigger a warning if no existing packing has been pushed allowing easy identification of locations where the __rte_msvc_pack is missing.

---
 lib/eal/include/rte_common.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
lib/eal/include/rte_common.h +3 -1
index 298a5c6..44825ed 100644
@@ -97,8 +97,10 @@
  * Force a structure to be packed
  */
 #ifdef RTE_TOOLCHAIN_MSVC
-#define __rte_packed
+#define __rte_msvc_pack __pragma(pack(push, 1))
+#define __rte_packed __pragma(pack(pop))
 #else
+#define __rte_msvc_pack
 #define __rte_packed __attribute__((__packed__))
 #endif
 
Signature · 1 line
1.8.3.1
#60 lore raw

PATCH v4 2/16 eal: pack structures when building with MSVC

In reply to 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.

---
 lib/eal/common/eal_private.h      | 2 +-
 lib/eal/include/rte_memory.h      | 1 +
 lib/eal/include/rte_memzone.h     | 1 +
 lib/eal/include/rte_trace_point.h | 2 +-
 lib/eal/x86/include/rte_memcpy.h  | 3 +++
 5 files changed, 7 insertions(+), 2 deletions(-)
lib/eal/common/eal_private.h +1 -1
index 71523cf..4c929fb 100644
@@ -62,7 +62,7 @@ struct rte_config {
 	 * DPDK instances
 	 */
 	struct rte_mem_config *mem_config;
-} __rte_packed;
+};
 
 /**
  * Get the global configuration structure.
lib/eal/include/rte_memory.h +1 -0
index 842362d..73bb00d 100644
@@ -46,6 +46,7 @@
 /**
  * Physical memory segment descriptor.
  */
+__rte_msvc_pack
 struct rte_memseg {
 	rte_iova_t iova;            /**< Start IO address. */
 	union {
lib/eal/include/rte_memzone.h +1 -0
index 931497f..ca312c0 100644
@@ -45,6 +45,7 @@
  * A structure describing a memzone, which is a contiguous portion of
  * physical memory identified by a name.
  */
+__rte_msvc_pack
 struct rte_memzone {
 
 #define RTE_MEMZONE_NAMESIZE 32       /**< Maximum length of memory zone name.*/
lib/eal/include/rte_trace_point.h +1 -1
index 41e2a7f..e786ee3 100644
@@ -297,7 +297,7 @@ struct __rte_trace_stream_header {
 	rte_uuid_t uuid;
 	uint32_t lcore_id;
 	char thread_name[__RTE_TRACE_EMIT_STRING_LEN_MAX];
-} __rte_packed;
+};
 
 struct __rte_trace_header {
 	uint32_t offset;
lib/eal/x86/include/rte_memcpy.h +3 -0
index 72a9229..fdc5df0 100644
@@ -57,12 +57,15 @@
 	 * Use the following structs to avoid violating C standard
 	 * alignment requirements and to avoid strict aliasing bugs
 	 */
+	__rte_msvc_pack
 	struct rte_uint64_alias {
 		uint64_t val;
 	} __rte_packed __rte_may_alias;
+	__rte_msvc_pack
 	struct rte_uint32_alias {
 		uint32_t val;
 	} __rte_packed __rte_may_alias;
+	__rte_msvc_pack
 	struct rte_uint16_alias {
 		uint16_t val;
 	} __rte_packed __rte_may_alias;
Signature · 1 line
1.8.3.1
#61 lore raw

PATCH v4 3/16 net: pack structures when building with MSVC

In reply to Tyler Retzlaff

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

---
 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(+)
lib/net/rte_arp.h +2 -0
index 668cea1..35d68c1 100644
@@ -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 */
lib/net/rte_dtls.h +1 -0
index 4f541df..0c75b06 100644
@@ -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;
lib/net/rte_esp.h +2 -0
index 464c513..27c9287 100644
@@ -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 */
lib/net/rte_ether.h +1 -0
index 32ed515..354e3a5 100644
@@ -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. */
lib/net/rte_geneve.h +1 -0
index 3bbc561..5c02526 100644
@@ -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. */
lib/net/rte_gre.h +4 -0
index 8da8027..77882e7 100644
@@ -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;
lib/net/rte_gtp.h +5 -0
index 9849872..26fc80a 100644
@@ -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
lib/net/rte_ib.h +1 -0
index 9eab5f9..c4c5d39 100644
@@ -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
lib/net/rte_icmp.h +3 -0
index 4bf64d7..e865db4 100644
@@ -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. */
lib/net/rte_ip.h +4 -0
index 0d103d4..908a25c 100644
@@ -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 */
lib/net/rte_l2tpv2.h +4 -0
index 9cda347..a917013 100644
@@ -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 {
lib/net/rte_macsec.h +2 -0
index d0cd2f6..54de1bd 100644
@@ -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;
lib/net/rte_mpls.h +1 -0
index 51523e7..d5f6026 100644
@@ -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
lib/net/rte_pdcp_hdr.h +4 -0
index 72ae9a6..6a20ad9 100644
@@ -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 */
lib/net/rte_ppp.h +1 -0
index 7b86ac4..fde585f 100644
@@ -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) */
lib/net/rte_sctp.h +1 -0
index 965682d..a6cfe8f 100644
@@ -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. */
lib/net/rte_tcp.h +1 -0
index 506ac4e..d11cb2c 100644
@@ -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. */
lib/net/rte_tls.h +1 -0
index 2eb3c6d..81af4c7 100644
@@ -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;
lib/net/rte_udp.h +1 -0
index 6135494..5416855 100644
@@ -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. */
lib/net/rte_vxlan.h +2 -0
index 997fc78..bcfd579 100644
@@ -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 {
Signature · 1 line
1.8.3.1
#62 lore raw

PATCH v4 4/16 common/iavf: pack structures when building with MSVC

In reply to Tyler Retzlaff

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

---
 drivers/common/iavf/iavf_osdep.h            |  2 ++
 drivers/common/iavf/virtchnl_inline_ipsec.h | 11 +++++++++++
 2 files changed, 13 insertions(+)
drivers/common/iavf/iavf_osdep.h +2 -0
index 263d924..1fb057c 100644
@@ -158,6 +158,7 @@
 } while (0)
 
 /* memory allocation tracking */
+__rte_msvc_pack
 struct iavf_dma_mem {
 	void *va;
 	u64 pa;
@@ -165,6 +166,7 @@ struct iavf_dma_mem {
 	const void *zone;
 } __rte_packed;
 
+__rte_msvc_pack
 struct iavf_virt_mem {
 	void *va;
 	u32 size;
drivers/common/iavf/virtchnl_inline_ipsec.h +11 -0
index 2f4bf15..feb0f44 100644
@@ -109,6 +109,7 @@ enum inline_ipsec_ops {
 };
 
 /* Not all valid, if certain field is invalid, set 1 for all bits */
+__rte_msvc_pack
 struct virtchnl_algo_cap  {
 	u32 algo_type;
 
@@ -132,6 +133,7 @@ struct virtchnl_algo_cap  {
 } __rte_packed;
 
 /* vf record the capability of crypto from the virtchnl */
+__rte_msvc_pack
 struct virtchnl_sym_crypto_cap {
 	u8 crypto_type;
 	u8 algo_cap_num;
@@ -142,6 +144,7 @@ struct virtchnl_sym_crypto_cap {
  * VF pass virtchnl_ipsec_cap to PF
  * and PF return capability of ipsec from virtchnl.
  */
+__rte_msvc_pack
 struct virtchnl_ipsec_cap {
 	/* max number of SA per VF */
 	u16 max_sa_num;
@@ -172,6 +175,7 @@ struct virtchnl_ipsec_cap {
 } __rte_packed;
 
 /* configuration of crypto function */
+__rte_msvc_pack
 struct virtchnl_ipsec_crypto_cfg_item {
 	u8 crypto_type;
 
@@ -203,6 +207,7 @@ struct virtchnl_ipsec_sym_crypto_cfg {
  * PF create SA as configuration and PF driver will return
  * an unique index (sa_idx) for the created SA.
  */
+__rte_msvc_pack
 struct virtchnl_ipsec_sa_cfg {
 	/* IPsec SA Protocol - AH/ESP */
 	u8 virtchnl_protocol_type;
@@ -298,6 +303,7 @@ struct virtchnl_ipsec_sa_cfg {
  * VF send configuration of index of SA to PF
  * PF will update SA according to configuration
  */
+__rte_msvc_pack
 struct virtchnl_ipsec_sa_update {
 	u32 sa_index; /* SA to update */
 	u32 esn_hi; /* high 32 bits of esn */
@@ -310,6 +316,7 @@ struct virtchnl_ipsec_sa_update {
  * flag bitmap indicate all SA or just selected SA will
  * be destroyed
  */
+__rte_msvc_pack
 struct virtchnl_ipsec_sa_destroy {
 	/* All zero bitmap indicates all SA will be destroyed.
 	 * Non-zero bitmap indicates the selected SA in
@@ -325,6 +332,7 @@ struct virtchnl_ipsec_sa_destroy {
  * VF send this SA configuration to PF using virtchnl;
  * PF read SA and will return configuration for the created SA.
  */
+__rte_msvc_pack
 struct virtchnl_ipsec_sa_read {
 	/* SA valid - invalid/valid */
 	u8 valid;
@@ -431,6 +439,7 @@ struct virtchnl_ipsec_sa_read {
 #define VIRTCHNL_IPSEC_INBOUND_SPD_TBL_IPV6	(1)
 
 /* Add allowlist entry in IES */
+__rte_msvc_pack
 struct virtchnl_ipsec_sp_cfg {
 	u32 spi;
 	u32 dip[4];
@@ -459,6 +468,7 @@ struct virtchnl_ipsec_sp_cfg {
 
 
 /* Delete allowlist entry in IES */
+__rte_msvc_pack
 struct virtchnl_ipsec_sp_destroy {
 	/* 0 for IPv4 table, 1 for IPv6 table. */
 	u8 table_id;
@@ -494,6 +504,7 @@ struct virtchnl_ipsec_resp {
 };
 
 /* Internal message descriptor for VF <-> IPsec communication */
+__rte_msvc_pack
 struct inline_ipsec_msg {
 	u16 ipsec_opcode;
 	u16 req_id;
Signature · 1 line
1.8.3.1
#63 lore raw

PATCH v4 5/16 common/idpf: pack structures when building with MSVC

In reply to Tyler Retzlaff

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

---
 drivers/common/idpf/base/idpf_osdep.h | 2 ++
 1 file changed, 2 insertions(+)
drivers/common/idpf/base/idpf_osdep.h +2 -0
index 74a376c..f5fcdc3 100644
@@ -180,6 +180,7 @@ static inline uint64_t idpf_read_addr64(volatile void *addr)
 #define BITS_PER_BYTE       8
 
 /* memory allocation tracking */
+__rte_msvc_pack
 struct idpf_dma_mem {
 	void *va;
 	u64 pa;
@@ -187,6 +188,7 @@ struct idpf_dma_mem {
 	const void *zone;
 } __rte_packed;
 
+__rte_msvc_pack
 struct idpf_virt_mem {
 	void *va;
 	u32 size;
Signature · 1 line
1.8.3.1
#64 lore raw

PATCH v4 6/16 common/mlx5: pack structures when building with MSVC

In reply to Tyler Retzlaff

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

---
 drivers/common/mlx5/mlx5_common_mr.h    |  4 ++++
 drivers/common/mlx5/mlx5_common_utils.h |  1 +
 drivers/common/mlx5/mlx5_prm.h          | 28 ++++++++++++++++++++++++++++
 3 files changed, 33 insertions(+)
drivers/common/mlx5/mlx5_common_mr.h +4 -0
index 8789d40..4f4bd73 100644
@@ -49,6 +49,7 @@ struct mlx5_mr {
 };
 
 /* Cache entry for Memory Region. */
+__rte_msvc_pack
 struct mr_cache_entry {
 	uintptr_t start; /* Start address of MR. */
 	uintptr_t end; /* End address of MR. */
@@ -56,6 +57,7 @@ struct mr_cache_entry {
 } __rte_packed;
 
 /* MR Cache table for Binary search. */
+__rte_msvc_pack
 struct mlx5_mr_btree {
 	uint32_t len; /* Number of entries. */
 	uint32_t size; /* Total number of entries. */
@@ -65,6 +67,7 @@ struct mlx5_mr_btree {
 struct mlx5_common_device;
 
 /* Per-queue MR control descriptor. */
+__rte_msvc_pack
 struct mlx5_mr_ctrl {
 	uint32_t *dev_gen_ptr; /* Generation number of device to poll. */
 	uint32_t cur_gen; /* Generation number saved to flush caches. */
@@ -78,6 +81,7 @@ struct mlx5_mr_ctrl {
 LIST_HEAD(mlx5_mempool_reg_list, mlx5_mempool_reg);
 
 /* Global per-device MR cache. */
+__rte_msvc_pack
 struct mlx5_mr_share_cache {
 	uint32_t dev_gen; /* Generation number to flush local caches. */
 	rte_rwlock_t rwlock; /* MR cache Lock. */
drivers/common/mlx5/mlx5_common_utils.h +1 -0
index ae15119..a44975c 100644
@@ -27,6 +27,7 @@
  * Structure of the entry in the mlx5 list, user should define its own struct
  * that contains this in order to store the data.
  */
+__rte_msvc_pack
 struct mlx5_list_entry {
 	LIST_ENTRY(mlx5_list_entry) next; /* Entry pointers in the list. */
 	uint32_t ref_cnt __rte_aligned(8); /* 0 means, entry is invalid. */
drivers/common/mlx5/mlx5_prm.h +28 -0
index c671c75..bf9ecd1 100644
@@ -319,6 +319,7 @@ enum mlx5_mpw_mode {
 };
 
 /* WQE Control segment. */
+__rte_msvc_pack
 struct mlx5_wqe_cseg {
 	uint32_t opcode;
 	uint32_t sq_ds;
@@ -336,10 +337,12 @@ struct mlx5_wqe_cseg {
 #define WQE_CSEG_WQE_INDEX_OFFSET	 8
 
 /* Header of data segment. Minimal size Data Segment */
+__rte_msvc_pack
 struct mlx5_wqe_dseg {
 	uint32_t bcount;
 	union {
 		uint8_t inline_data[MLX5_DSEG_MIN_INLINE_SIZE];
+		__rte_msvc_pack
 		struct {
 			uint32_t lkey;
 			uint64_t pbuf;
@@ -348,8 +351,10 @@ struct mlx5_wqe_dseg {
 } __rte_packed;
 
 /* Subset of struct WQE Ethernet Segment. */
+__rte_msvc_pack
 struct mlx5_wqe_eseg {
 	union {
+		__rte_msvc_pack
 		struct {
 			uint32_t swp_offs;
 			uint8_t	cs_flags;
@@ -362,6 +367,7 @@ struct mlx5_wqe_eseg {
 				uint16_t vlan_tag;
 			};
 		} __rte_packed;
+		__rte_msvc_pack
 		struct {
 			uint32_t offsets;
 			uint32_t flags;
@@ -371,6 +377,7 @@ struct mlx5_wqe_eseg {
 	};
 } __rte_packed;
 
+__rte_msvc_pack
 struct mlx5_wqe_qseg {
 	uint32_t reserved0;
 	uint32_t reserved1;
@@ -378,6 +385,7 @@ struct mlx5_wqe_qseg {
 	uint32_t qpn_cqn;
 } __rte_packed;
 
+__rte_msvc_pack
 struct mlx5_wqe_wseg {
 	uint32_t operation;
 	uint32_t lkey;
@@ -388,6 +396,7 @@ struct mlx5_wqe_wseg {
 } __rte_packed;
 
 /* The title WQEBB, header of WQE. */
+__rte_msvc_pack
 struct mlx5_wqe {
 	union {
 		struct mlx5_wqe_cseg cseg;
@@ -437,6 +446,7 @@ struct mlx5_cqe {
 	uint8_t lro_num_seg;
 	union {
 		uint8_t user_index_bytes[3];
+		__rte_msvc_pack
 		struct {
 			uint8_t user_index_hi;
 			uint16_t user_index_low;
@@ -460,6 +470,7 @@ struct mlx5_cqe_ts {
 	uint8_t op_own;
 };
 
+__rte_msvc_pack
 struct mlx5_wqe_rseg {
 	uint64_t raddr;
 	uint32_t rkey;
@@ -479,6 +490,7 @@ struct mlx5_wqe_rseg {
 #define MLX5_UMR_KLM_NUM_ALIGN \
 	(MLX5_UMR_KLM_PTR_ALIGN / sizeof(struct mlx5_klm))
 
+__rte_msvc_pack
 struct mlx5_wqe_umr_cseg {
 	uint32_t if_cf_toe_cq_res;
 	uint32_t ko_to_bs;
@@ -486,6 +498,7 @@ struct mlx5_wqe_umr_cseg {
 	uint32_t rsvd1[8];
 } __rte_packed;
 
+__rte_msvc_pack
 struct mlx5_wqe_mkey_cseg {
 	uint32_t fr_res_af_sf;
 	uint32_t qpn_mkey;
@@ -549,6 +562,7 @@ enum {
 #define MLX5_CRYPTO_MMO_TYPE_OFFSET 24
 #define MLX5_CRYPTO_MMO_OP_OFFSET 20
 
+__rte_msvc_pack
 struct mlx5_wqe_umr_bsf_seg {
 	/*
 	 * bs_bpt_eo_es contains:
@@ -582,6 +596,7 @@ struct mlx5_wqe_umr_bsf_seg {
 #pragma GCC diagnostic ignored "-Wpedantic"
 #endif
 
+__rte_msvc_pack
 struct mlx5_umr_wqe {
 	struct mlx5_wqe_cseg ctr;
 	struct mlx5_wqe_umr_cseg ucseg;
@@ -592,18 +607,21 @@ struct mlx5_umr_wqe {
 	};
 } __rte_packed;
 
+__rte_msvc_pack
 struct mlx5_rdma_write_wqe {
 	struct mlx5_wqe_cseg ctr;
 	struct mlx5_wqe_rseg rseg;
 	struct mlx5_wqe_dseg dseg[];
 } __rte_packed;
 
+__rte_msvc_pack
 struct mlx5_wqe_send_en_seg {
 	uint32_t reserve[2];
 	uint32_t sqnpc;
 	uint32_t qpn;
 } __rte_packed;
 
+__rte_msvc_pack
 struct mlx5_wqe_send_en_wqe {
 	struct mlx5_wqe_cseg ctr;
 	struct mlx5_wqe_send_en_seg sseg;
@@ -650,6 +668,7 @@ struct mlx5_wqe_metadata_seg {
 	uint64_t addr;
 };
 
+__rte_msvc_pack
 struct mlx5_gga_wqe {
 	uint32_t opcode;
 	uint32_t sq_ds;
@@ -663,16 +682,19 @@ struct mlx5_gga_wqe {
 } __rte_packed;
 
 union mlx5_gga_compress_opaque {
+	__rte_msvc_pack
 	struct {
 		uint32_t syndrome;
 		uint32_t reserved0;
 		uint32_t scattered_length;
 		union {
+			__rte_msvc_pack
 			struct {
 				uint32_t reserved1[5];
 				uint32_t crc32;
 				uint32_t adler32;
 			} v1 __rte_packed;
+			__rte_msvc_pack
 			struct {
 				uint32_t crc32;
 				uint32_t adler32;
@@ -685,9 +707,11 @@ struct mlx5_gga_wqe {
 };
 
 union mlx5_gga_crypto_opaque {
+	__rte_msvc_pack
 	struct {
 		uint32_t syndrome;
 		uint32_t reserved0[2];
+		__rte_msvc_pack
 		struct {
 			uint32_t iv[3];
 			uint32_t tag_size;
@@ -4134,6 +4158,7 @@ enum mlx5_aso_op {
 #define MLX5_ASO_CSEG_READ_ENABLE 1
 
 /* ASO WQE CTRL segment. */
+__rte_msvc_pack
 struct mlx5_aso_cseg {
 	uint32_t va_h;
 	uint32_t va_l_r;
@@ -4150,6 +4175,7 @@ struct mlx5_aso_cseg {
 #define MLX5_MTR_MAX_TOKEN_VALUE INT32_MAX
 
 /* A meter data segment - 2 per ASO WQE. */
+__rte_msvc_pack
 struct mlx5_aso_mtr_dseg {
 	uint32_t v_bo_sc_bbog_mm;
 	/*
@@ -4191,6 +4217,7 @@ struct mlx5_aso_mtr_dseg {
 #define MLX5_ASO_MTRS_PER_POOL 128
 
 /* ASO WQE data segment. */
+__rte_msvc_pack
 struct mlx5_aso_dseg {
 	union {
 		uint8_t data[MLX5_ASO_WQE_DSEG_SIZE];
@@ -4199,6 +4226,7 @@ struct mlx5_aso_dseg {
 } __rte_packed;
 
 /* ASO WQE. */
+__rte_msvc_pack
 struct mlx5_aso_wqe {
 	struct mlx5_wqe_cseg general_cseg;
 	struct mlx5_aso_cseg aso_cseg;
Signature · 1 line
1.8.3.1
#65 lore raw

PATCH v4 7/16 dma/ioat: pack structures when building with MSVC

In reply to Tyler Retzlaff

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

---
 drivers/dma/ioat/ioat_hw_defs.h | 1 +
 1 file changed, 1 insertion(+)
drivers/dma/ioat/ioat_hw_defs.h +1 -0
index dc3493a..6e32807 100644
@@ -52,6 +52,7 @@
 #define	IOAT_DMACAP_PQ		(1 << 9)
 #define	IOAT_DMACAP_DMA_DIF	(1 << 10)
 
+__rte_msvc_pack
 struct ioat_registers {
 	uint8_t		chancnt;
 	uint8_t		xfercap;
Signature · 1 line
1.8.3.1
#66 lore raw

PATCH v4 8/16 net/i40e: pack structures when building with MSVC

In reply to Tyler Retzlaff

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

---
 drivers/net/i40e/base/i40e_osdep.h | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/i40e/base/i40e_osdep.h +2 -0
index aa5dc61..28439e3 100644
@@ -177,6 +177,7 @@ static inline uint64_t i40e_read64_addr(volatile void *addr)
 #define ARRAY_SIZE(arr) RTE_DIM(arr)
 
 /* memory allocation tracking */
+__rte_msvc_pack
 struct i40e_dma_mem {
 	void *va;
 	u64 pa;
@@ -188,6 +189,7 @@ struct i40e_dma_mem {
 			i40e_allocate_dma_mem_d(h, m, s, a)
 #define i40e_free_dma_mem(h, m) i40e_free_dma_mem_d(h, m)
 
+__rte_msvc_pack
 struct i40e_virt_mem {
 	void *va;
 	u32 size;
Signature · 1 line
1.8.3.1
#67 lore raw

PATCH v4 9/16 net/iavf: pack structures when building with MSVC

In reply to 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.

---
 drivers/net/iavf/iavf_ipsec_crypto.h | 4 +++-
 drivers/net/iavf/iavf_rxtx.c         | 2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)
drivers/net/iavf/iavf_ipsec_crypto.h +3 -1
index 49f9202..0637ce2 100644
@@ -11,12 +11,14 @@
 
 
 
+__rte_msvc_pack
 struct iavf_tx_ipsec_desc {
 	union {
 		struct {
 			__le64 qw0;
 			__le64 qw1;
 		};
+		__rte_msvc_pack
 		struct {
 			__le16 l4payload_length;
 			__le32 esn;
@@ -97,7 +99,7 @@ struct iavf_ipsec_crypto_pkt_metadata {
 	uint8_t next_proto;		/* Next Protocol (8b/1B) */
 
 	uint32_t esn;		        /* Extended Sequence Number (32b/4B) */
-} __rte_packed;
+};
 
 /**
  * Inline IPsec Crypto offload is supported
drivers/net/iavf/iavf_rxtx.c +1 -1
index 0a5246d..61309c3 100644
@@ -53,7 +53,7 @@
 struct simple_gre_hdr {
 	uint16_t flags;
 	uint16_t proto;
-} __rte_packed;
+};
 
 /* structure that caches offload info for the current packet */
 struct offload_info {
Signature · 1 line
1.8.3.1
#68 lore raw

PATCH v4 10/16 net/ice: pack structures when building with MSVC

In reply to Tyler Retzlaff

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

---
 drivers/net/ice/base/ice_osdep.h | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/ice/base/ice_osdep.h +2 -0
index 0e14b93..087dc6a 100644
@@ -187,6 +187,7 @@
 #define BITS_PER_BYTE       8
 
 /* memory allocation tracking */
+__rte_msvc_pack
 struct ice_dma_mem {
 	void *va;
 	u64 pa;
@@ -194,6 +195,7 @@ struct ice_dma_mem {
 	const void *zone;
 } __rte_packed;
 
+__rte_msvc_pack
 struct ice_virt_mem {
 	void *va;
 	u32 size;
Signature · 1 line
1.8.3.1
#69 lore raw

PATCH v4 11/16 net/mlx5: pack structures when building with MSVC

In reply to Tyler Retzlaff

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

---
 drivers/net/mlx5/hws/mlx5dr.h   | 1 +
 drivers/net/mlx5/mlx5.h         | 1 +
 drivers/net/mlx5/mlx5_flow.h    | 5 +++++
 drivers/net/mlx5/mlx5_hws_cnt.h | 1 +
 drivers/net/mlx5/mlx5_utils.h   | 4 ++++
 5 files changed, 12 insertions(+)
drivers/net/mlx5/hws/mlx5dr.h +1 -0
index 80e118a..cd5bb05 100644
@@ -300,6 +300,7 @@ struct mlx5dr_action_dest_attr {
 	};
 };
 
+__rte_msvc_pack
 struct mlx5dr_crc_encap_entropy_hash_fields {
 	union mlx5dr_crc_encap_entropy_hash_ip_field dst;
 	union mlx5dr_crc_encap_entropy_hash_ip_field src;
drivers/net/mlx5/mlx5.h +1 -0
index 0091a24..6228ee8 100644
@@ -221,6 +221,7 @@ struct mlx5_dev_spawn_data {
 }
 
 /** Data associated with socket messages. */
+__rte_msvc_pack
 struct mlx5_flow_dump_req  {
 	uint32_t port_id; /**< There are plans in DPDK to extend port_id. */
 	uint64_t flow_id;
drivers/net/mlx5/mlx5_flow.h +5 -0
index 0065727..da0f8b7 100644
@@ -658,6 +658,7 @@ struct mlx5_flow_dv_tag_resource {
 };
 
 /* Modify resource structure */
+__rte_msvc_pack
 struct mlx5_flow_dv_modify_hdr_resource {
 	struct mlx5_list_entry entry;
 	void *action; /**< Modify header action object. */
@@ -812,6 +813,7 @@ struct mlx5_flow_dv_dest_array_resource {
 
 
 /** Device flow handle structure for DV mode only. */
+__rte_msvc_pack
 struct mlx5_flow_handle_dv {
 	/* Flow DV api: */
 	struct mlx5_flow_dv_matcher *matcher; /**< Cache to matcher. */
@@ -830,6 +832,7 @@ struct mlx5_flow_handle_dv {
 } __rte_packed;
 
 /** Device flow handle structure: used both for creating & destroying. */
+__rte_msvc_pack
 struct mlx5_flow_handle {
 	SILIST_ENTRY(uint32_t)next;
 	struct mlx5_vf_vlan vf_vlan; /**< Structure for VF VLAN workaround. */
@@ -1231,6 +1234,7 @@ struct mlx5_flow_attr {
 };
 
 /* Flow structure. */
+__rte_msvc_pack
 struct rte_flow {
 	uint32_t dev_handles;
 	/**< Device flow handles that are part of the flow. */
@@ -1304,6 +1308,7 @@ enum {
 #endif
 
 /** HWS flow struct. */
+__rte_msvc_pack
 struct rte_flow_hw {
 	/** The table flow allcated from. */
 	struct rte_flow_template_table *table;
drivers/net/mlx5/mlx5_hws_cnt.h +1 -0
index e005960..1f53a1a 100644
@@ -133,6 +133,7 @@ enum {
 };
 
 /* HWS counter age parameter. */
+__rte_msvc_pack
 struct mlx5_hws_age_param {
 	uint32_t timeout; /* Aging timeout in seconds (atomically accessed). */
 	uint32_t sec_since_last_hit;
drivers/net/mlx5/mlx5_utils.h +4 -0
index f3c0d76..cf80e5e 100644
@@ -118,6 +118,7 @@ struct mlx5_l3t_level_tbl {
 };
 
 /* L3 word entry table data structure. */
+__rte_msvc_pack
 struct mlx5_l3t_entry_word {
 	uint32_t idx; /* Table index. */
 	uint64_t ref_cnt; /* Table ref_cnt. */
@@ -128,6 +129,7 @@ struct mlx5_l3t_entry_word {
 } __rte_packed;
 
 /* L3 double word entry table data structure. */
+__rte_msvc_pack
 struct mlx5_l3t_entry_dword {
 	uint32_t idx; /* Table index. */
 	uint64_t ref_cnt; /* Table ref_cnt. */
@@ -138,6 +140,7 @@ struct mlx5_l3t_entry_dword {
 } __rte_packed;
 
 /* L3 quad word entry table data structure. */
+__rte_msvc_pack
 struct mlx5_l3t_entry_qword {
 	uint32_t idx; /* Table index. */
 	uint64_t ref_cnt; /* Table ref_cnt. */
@@ -148,6 +151,7 @@ struct mlx5_l3t_entry_qword {
 } __rte_packed;
 
 /* L3 pointer entry table data structure. */
+__rte_msvc_pack
 struct mlx5_l3t_entry_ptr {
 	uint32_t idx; /* Table index. */
 	uint64_t ref_cnt; /* Table ref_cnt. */
Signature · 1 line
1.8.3.1
#70 lore raw

PATCH v4 12/16 net/octeon_ep: pack structures when building with MSVC

In reply to Tyler Retzlaff

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

---
 drivers/net/octeon_ep/otx_ep_mbox.h | 1 +
 1 file changed, 1 insertion(+)
drivers/net/octeon_ep/otx_ep_mbox.h +1 -0
index a3fc15c..005fce3 100644
@@ -70,6 +70,7 @@ enum otx_ep_link_autoneg {
 #define OTX_EP_MBOX_MORE_FRAG_FLAG 1
 #define OTX_EP_MBOX_WRITE_WAIT_TIME msecs_to_jiffies(1)
 
+__rte_msvc_pack
 union otx_ep_mbox_word {
 	uint64_t u64;
 	struct {
Signature · 1 line
1.8.3.1
#71 lore raw

PATCH v4 13/16 app/testpmd: pack structures when building with MSVC

In reply to 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.

---
 app/test-pmd/csumonly.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
app/test-pmd/csumonly.c +1 -1
index 6711dda..f24c381 100644
@@ -92,7 +92,7 @@ struct testpmd_offload_info {
 struct simple_gre_hdr {
 	uint16_t flags;
 	uint16_t proto;
-} __rte_packed;
+};
 
 static uint16_t
 get_udptcp_checksum(struct rte_mbuf *m, void *l3_hdr, uint16_t l4_off,
Signature · 1 line
1.8.3.1
#72 lore raw

PATCH v4 14/16 app/test: pack structures when building with MSVC

In reply to Tyler Retzlaff

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

---
 app/test/test_efd.c    | 1 +
 app/test/test_hash.c   | 1 +
 app/test/test_member.c | 1 +
 3 files changed, 3 insertions(+)
app/test/test_efd.c +1 -0
index 1c0986b..df176a0 100644
@@ -33,6 +33,7 @@
 static unsigned int test_socket_id;
 
 /* 5-tuple key type */
+__rte_msvc_pack
 struct flow_key {
 	uint32_t ip_src;
 	uint32_t ip_dst;
app/test/test_hash.c +1 -0
index d586878..08c1773 100644
@@ -79,6 +79,7 @@
  * Should be packed to avoid holes with potentially
  * undefined content in the middle.
  */
+__rte_msvc_pack
 struct flow_key {
 	uint32_t ip_src;
 	uint32_t ip_dst;
app/test/test_member.c +1 -0
index 5a4d275..ccd481a 100644
@@ -32,6 +32,7 @@
 struct rte_member_setsum *setsum_sketch;
 
 /* 5-tuple key type */
+__rte_msvc_pack
 struct flow_key {
 	uint32_t ip_src;
 	uint32_t ip_dst;
Signature · 1 line
1.8.3.1
#73 lore raw

PATCH v4 15/16 examples: pack structures when building with MSVC

In reply to 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.

---
 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(-)
examples/common/neon/port_group.h +1 -0
index 421e2e8..bd40590 100644
@@ -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;
examples/ip_pipeline/cli.c +5 -5
index e8269ea..aad6c78 100644
@@ -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,
examples/ipsec-secgw/ipsec.h +1 -0
index bdcada1..bdc6045 100644
@@ -277,6 +277,7 @@ struct socket_ctx {
 	struct rte_mempool *session_pool;
 };
 
+__rte_msvc_pack
 struct cnt_blk {
 	uint32_t salt;
 	uint64_t iv;
examples/l3fwd-power/main.c +2 -0
index f4adcf4..a3be37b 100644
@@ -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];
examples/ptpclient/ptpclient.c +8 -0
index afb61bb..cdd73fd 100644
@@ -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;
Signature · 1 line
1.8.3.1
#74 lore raw

PATCH v4 16/16 crypto/mlx5: pack structures when building with MSVC

In reply to Tyler Retzlaff

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

---
 drivers/crypto/mlx5/mlx5_crypto.h     | 1 +
 drivers/crypto/mlx5/mlx5_crypto_gcm.c | 1 +
 2 files changed, 2 insertions(+)
drivers/crypto/mlx5/mlx5_crypto.h +1 -0
index 36dacdc..3b4916d 100644
@@ -95,6 +95,7 @@ struct mlx5_crypto_devarg_params {
 	uint32_t is_aes_gcm:1;
 };
 
+__rte_msvc_pack
 struct mlx5_crypto_session {
 	union {
 		/**< AES-XTS configuration. */
drivers/crypto/mlx5/mlx5_crypto_gcm.c +1 -0
index fc6ade6..9a2c438 100644
@@ -62,6 +62,7 @@ struct mlx5_crypto_gcm_data {
 	uint32_t dst_mkey;
 };
 
+__rte_msvc_pack
 struct mlx5_crypto_gcm_tag_cpy_info {
 	void *digest;
 	uint8_t tag_len;
Signature · 1 line
1.8.3.1
#75 lore raw

v5 cover fix packing of structs when building with MSVC

In reply to Tyler Retzlaff

From: Andre Muezerie <[email protected]>

MSVC struct packing is not compatible with GCC provide a macro that can be used to push existing pack value and sets packing to 1-byte. The existing __rte_packed macro is then used to restore the pack value prior to the push.

Instead of providing macros exclusively for MSVC and for GCC the existing macro is deliberately utilized to trigger a warning if no existing packing has been pushed allowing easy identification of locations where the __rte_msvc_pack is missing.

I've decided to only add the macro to packed structs that are built for Windows. It seems there is little value in adding the macro tree wide and if new code arrives that is built on Windows the __rte_packed will flag where the preamble macro is required.

If as a part of review maintainers identify structs they believe don't require packing so long as they are explicitly identified i'll remove the __rte_packed as a part of this series.

v5:
* rebase on top of latest main

v4:
* add another missing __rte_msvc_pack to crypto/mlx5 patch
* correct commit message for duplicated packing packing in crypto/mlx5 patch

v3:
* add missing __rte_msvc_pack to crypto/mlx5
* fix commit messages to reference __rte_msvc_pack macro instead

    of __rte_msvc_pushpack(1)

v2:
* app/testpmd, remove packing from simple_gre_hdr
* net/iavf, remove packing from iavf_ipsec_crypto_pkt_metadata, simple_gre_hdr
* examples, remove packing from pkt_key_qinq, pkt_key_ipv4_5tuple,

    pkt_key_ipv6_5tuple, pkt_key_ipv4_addr, pkt_key_ipv6_addr

* eal, remove packing from rte_config, __rte_trace_stream_header

Tyler Retzlaff (16):
eal: provide pack start macro for MSVC
eal: pack structures when building with MSVC
net: pack structures when building with MSVC common/iavf: pack structures when building with MSVC common/idpf: pack structures when building with MSVC common/mlx5: pack structures when building with MSVC dma/ioat: pack structures when building with MSVC net/i40e: pack structures when building with MSVC net/iavf: pack structures when building with MSVC net/ice: pack structures when building with MSVC net/mlx5: pack structures when building with MSVC net/octeon_ep: pack structures when building with MSVC app/testpmd: pack structures when building with MSVC app/test: pack structures when building with MSVC
examples: pack structures when building with MSVC crypto/mlx5: pack structures when building with MSVC

 app/test-pmd/csumonly.c                     |  2 +-
 app/test/test_efd.c                         |  1 +
 app/test/test_hash.c                        |  1 +
 app/test/test_member.c                      |  1 +
 drivers/common/iavf/iavf_osdep.h            |  2 ++
 drivers/common/iavf/virtchnl_inline_ipsec.h | 11 ++++++++
 drivers/common/idpf/base/idpf_osdep.h       |  2 ++
 drivers/common/mlx5/mlx5_common_mr.h        |  4 +++
 drivers/common/mlx5/mlx5_common_utils.h     |  1 +
 drivers/common/mlx5/mlx5_prm.h              | 30 +++++++++++++++++++++
 drivers/crypto/mlx5/mlx5_crypto.h           |  2 ++
 drivers/crypto/mlx5/mlx5_crypto_gcm.c       |  1 +
 drivers/dma/ioat/ioat_hw_defs.h             |  1 +
 drivers/net/i40e/base/i40e_osdep.h          |  2 ++
 drivers/net/iavf/iavf_ipsec_crypto.h        |  4 ++-
 drivers/net/iavf/iavf_rxtx.c                |  2 +-
 drivers/net/ice/base/ice_osdep.h            |  2 ++
 drivers/net/mlx5/hws/mlx5dr.h               |  1 +
 drivers/net/mlx5/mlx5.h                     |  1 +
 drivers/net/mlx5/mlx5_flow.h                |  4 +++
 drivers/net/mlx5/mlx5_hws_cnt.h             |  1 +
 drivers/net/mlx5/mlx5_utils.h               |  4 +++
 drivers/net/octeon_ep/otx_ep_mbox.h         |  1 +
 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 +
 lib/eal/common/eal_private.h                |  2 +-
 lib/eal/include/rte_common.h                |  4 ++-
 lib/eal/include/rte_memory.h                |  1 +
 lib/eal/include/rte_memzone.h               |  1 +
 lib/eal/include/rte_trace_point.h           |  2 +-
 lib/eal/x86/include/rte_memcpy.h            |  3 +++
 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 +++++
 56 files changed, 156 insertions(+), 12 deletions(-)

--
2.47.0.vfs.0.3

#76 lore raw

PATCH v5 1/16 eal: provide pack start macro for MSVC

From: Tyler Retzlaff <[email protected]>

MSVC struct packing is not compatible with GCC. Provide a macro that can be used to push existing pack value and sets packing to 1-byte. The existing __rte_packed macro is then used to restore the pack value prior to the push.

Instead of providing macros exclusively for MSVC and for GCC the existing macro is deliberately utilized to trigger a warning if no existing packing has been pushed allowing easy identification of locations where the __rte_msvc_pack is missing.

---
 lib/eal/include/rte_common.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
lib/eal/include/rte_common.h +3 -1
index 4d299f2b36..409890863e 100644
@@ -103,8 +103,10 @@ typedef uint16_t unaligned_uint16_t;
  * Force a structure to be packed
  */
 #ifdef RTE_TOOLCHAIN_MSVC
-#define __rte_packed
+#define __rte_msvc_pack __pragma(pack(push, 1))
+#define __rte_packed __pragma(pack(pop))
 #else
+#define __rte_msvc_pack
 #define __rte_packed __attribute__((__packed__))
 #endif
 
Signature · 1 line
2.47.0.vfs.0.3
#77 lore raw

RE: [PATCH v5 01/16] eal: provide pack start macro for MSVC

Quoted 38 lines

From: Andre Muezerie [mailto:[email protected]]
Sent: Tuesday, 19 November 2024 05.35

From: Tyler Retzlaff <[email protected]>

MSVC struct packing is not compatible with GCC. Provide a macro that can be used to push existing pack value and sets packing to 1-byte. The existing __rte_packed macro is then used to restore the pack value prior to the push.

Instead of providing macros exclusively for MSVC and for GCC the existing macro is deliberately utilized to trigger a warning if no existing packing has been pushed allowing easy identification of locations where the __rte_msvc_pack is missing.

---
 lib/eal/include/rte_common.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
lib/eal/include/rte_common.h +3 -2
index 4d299f2b36..409890863e 100644
@@ -103,8 +103,10 @@ typedef uint16_t unaligned_uint16_t;
  * Force a structure to be packed
  */
 #ifdef RTE_TOOLCHAIN_MSVC
-#define __rte_packed
+#define __rte_msvc_pack __pragma(pack(push, 1))
+#define __rte_packed __pragma(pack(pop))
 #else
+#define __rte_msvc_pack
 #define __rte_packed __attribute__((__packed__))
 #endif
 
--
Quoted 1 line

2.47.0.vfs.0.3

Before proceeding with this, can we please discuss the alternative, proposed here:
https://inbox.dpdk.org/dev/CAJFAV8yStgiBbe+Nkt9mC30r0+ZP64_kGuRHOzqd90RD2HXZyw@mail.gmail.com/

The definition of the packing macro in OVS, for reference:
https://github.com/openvswitch/ovs/blob/main/include/openvswitch/compiler.h#L209

The current solution requires __rte_packed to be placed at the end of a structure, although __attribute__((packed)) is normally allowed at the beginning (between the "struct" tag and the name of the structure), which introduces a high risk of contributors placing it "incorrectly", thus causing errors.

I have a strong preference for an __RTE_PACKED(decl) variant.

Here's a third alternative:
#ifdef RTE_TOOLCHAIN_MSVC
#define __rte_msvc_pack_begin __pragma(pack(push, 1))
#define __rte_msvc_pack_end __pragma(pack(pop))
#else
#define __rte_msvc_pack_begin
#define __rte_msvc_pack_end
#endif

The third alternative is also problematic, e.g. if a contributor forgets the _end after the structure declaration, or adds another structure declaration before the _end.

-Morten

#78 lore raw

RE: [PATCH v5 01/16] eal: provide pack start macro for MSVC

Quoted 52 lines

-----Original Message-----
From: Morten Brørup <[email protected]>
Sent: Tuesday, November 19, 2024 8:32 AM
To: Andre Muezerie <[email protected]>; [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: RE: [PATCH v5 01/16] eal: provide pack start macro for MSVC

Quoted 37 lines

From: Andre Muezerie [mailto:[email protected]]
Sent: Tuesday, 19 November 2024 05.35

From: Tyler Retzlaff <[email protected]>

MSVC struct packing is not compatible with GCC. Provide a macro that can be used to push existing pack value and sets packing to 1-byte. The existing __rte_packed macro is then used to restore the pack value prior to the push.

Instead of providing macros exclusively for MSVC and for GCC the existing macro is deliberately utilized to trigger a warning if no existing packing has been pushed allowing easy identification of locations where the __rte_msvc_pack is missing.

---
 lib/eal/include/rte_common.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
lib/eal/include/rte_common.h +3 -1
index 4d299f2b36..409890863e 100644
@@ -103,8 +103,10 @@ typedef uint16_t unaligned_uint16_t;
  * Force a structure to be packed
  */
 #ifdef RTE_TOOLCHAIN_MSVC
-#define __rte_packed
+#define __rte_msvc_pack __pragma(pack(push, 1))
+#define __rte_packed __pragma(pack(pop))
 #else
+#define __rte_msvc_pack
 #define __rte_packed __attribute__((__packed__))
 #endif
 
Quoted 8 lines
Quoted 2 lines

--
2.47.0.vfs.0.3

Before proceeding with this, can we please discuss the alternative, proposed here:
https://inbox.dpdk.org/dev/CAJFAV8yStgiBbe+Nkt9mC30r0+ZP64_kGuRHOzqd90RD2HXZyw@mail.gmail.com/

The definition of the packing macro in OVS, for reference:
https://github.com/openvswitch/ovs/blob/main/include/openvswitch/compiler.h#L209

Yes, that one looks much nicer to me too.
Could I also ask to avoid creeping _msvc_ into DPDK namespace.

Quoted 20 lines

The current solution requires __rte_packed to be placed at the end of a structure, although __attribute__((packed)) is normally allowed at the beginning (between the "struct" tag and the name of the structure), which introduces a high risk of contributors placing it "incorrectly", thus causing errors.

I have a strong preference for an __RTE_PACKED(decl) variant.

Here's a third alternative:
#ifdef RTE_TOOLCHAIN_MSVC
#define __rte_msvc_pack_begin __pragma(pack(push, 1))
#define __rte_msvc_pack_end __pragma(pack(pop))
#else
#define __rte_msvc_pack_begin
#define __rte_msvc_pack_end
#endif

The third alternative is also problematic, e.g. if a contributor forgets the _end after the structure declaration, or adds another structure declaration before the _end.

-Morten

#79 lore raw

Re: [PATCH v5 01/16] eal: provide pack start macro for MSVC

Quoted 58 lines · Konstantin Ananyev
Quoted 58 lines

-----Original Message-----
From: Morten Brørup <[email protected]>
Sent: Tuesday, November 19, 2024 8:32 AM
To: Andre Muezerie <[email protected]>; [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: RE: [PATCH v5 01/16] eal: provide pack start macro for MSVC

Quoted 38 lines

From: Andre Muezerie [mailto:[email protected]]
Sent: Tuesday, 19 November 2024 05.35

From: Tyler Retzlaff <[email protected]>

MSVC struct packing is not compatible with GCC. Provide a macro that can be used to push existing pack value and sets packing to 1-byte. The existing __rte_packed macro is then used to restore the pack value prior to the push.

Instead of providing macros exclusively for MSVC and for GCC the existing macro is deliberately utilized to trigger a warning if no existing packing has been pushed allowing easy identification of locations where the __rte_msvc_pack is missing.

---
 lib/eal/include/rte_common.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
lib/eal/include/rte_common.h +3 -2
index 4d299f2b36..409890863e 100644
@@ -103,8 +103,10 @@ typedef uint16_t unaligned_uint16_t;
  * Force a structure to be packed
  */
 #ifdef RTE_TOOLCHAIN_MSVC
-#define __rte_packed
+#define __rte_msvc_pack __pragma(pack(push, 1))
+#define __rte_packed __pragma(pack(pop))
 #else
+#define __rte_msvc_pack
 #define __rte_packed __attribute__((__packed__))
 #endif
 
--
Quoted 1 line

2.47.0.vfs.0.3

Before proceeding with this, can we please discuss the alternative, proposed here:
https://inbox.dpdk.org/dev/CAJFAV8yStgiBbe+Nkt9mC30r0+ZP64_kGuRHOzqd90RD2HXZyw@mail.gmail.com/

Quoted 6 lines
Quoted 2 lines

The definition of the packing macro in OVS, for reference:
https://github.com/openvswitch/ovs/blob/main/include/openvswitch/compiler.h#L209

Yes, that one looks much nicer to me too.
Could I also ask to avoid creeping _msvc_ into DPDK namespace.

These are all good comments. I'll look more into it.

Quoted 20 lines
Quoted 20 lines

The current solution requires __rte_packed to be placed at the end of a structure, although __attribute__((packed)) is normally allowed at the beginning (between the "struct" tag and the name of the structure), which introduces a high risk of contributors placing it "incorrectly", thus causing errors.

I have a strong preference for an __RTE_PACKED(decl) variant.

Here's a third alternative:
#ifdef RTE_TOOLCHAIN_MSVC
#define __rte_msvc_pack_begin __pragma(pack(push, 1))
#define __rte_msvc_pack_end __pragma(pack(pop))
#else
#define __rte_msvc_pack_begin
#define __rte_msvc_pack_end
#endif

The third alternative is also problematic, e.g. if a contributor forgets the _end after the structure declaration, or adds another structure declaration before the _end.

-Morten

#80 lore raw

Re: [PATCH v5 01/16] eal: provide pack start macro for MSVC

In reply to Morten Brørup
Quoted 59 lines · Morten Brørup
Quoted 38 lines

From: Andre Muezerie [mailto:[email protected]]
Sent: Tuesday, 19 November 2024 05.35

From: Tyler Retzlaff <[email protected]>

MSVC struct packing is not compatible with GCC. Provide a macro that can be used to push existing pack value and sets packing to 1-byte. The existing __rte_packed macro is then used to restore the pack value prior to the push.

Instead of providing macros exclusively for MSVC and for GCC the existing macro is deliberately utilized to trigger a warning if no existing packing has been pushed allowing easy identification of locations where the __rte_msvc_pack is missing.

---
 lib/eal/include/rte_common.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
lib/eal/include/rte_common.h +3 -2
index 4d299f2b36..409890863e 100644
@@ -103,8 +103,10 @@ typedef uint16_t unaligned_uint16_t;
  * Force a structure to be packed
  */
 #ifdef RTE_TOOLCHAIN_MSVC
-#define __rte_packed
+#define __rte_msvc_pack __pragma(pack(push, 1))
+#define __rte_packed __pragma(pack(pop))
 #else
+#define __rte_msvc_pack
 #define __rte_packed __attribute__((__packed__))
 #endif
 
--
Quoted 1 line

2.47.0.vfs.0.3

Before proceeding with this, can we please discuss the alternative, proposed here:
https://inbox.dpdk.org/dev/CAJFAV8yStgiBbe+Nkt9mC30r0+ZP64_kGuRHOzqd90RD2HXZyw@mail.gmail.com/

The definition of the packing macro in OVS, for reference:
https://github.com/openvswitch/ovs/blob/main/include/openvswitch/compiler.h#L209

The current solution requires __rte_packed to be placed at the end of a structure, although __attribute__((packed)) is normally allowed at the beginning (between the "struct" tag and the name of the structure), which introduces a high risk of contributors placing it "incorrectly", thus causing errors.

I have a strong preference for an __RTE_PACKED(decl) variant.

Here's a third alternative:
#ifdef RTE_TOOLCHAIN_MSVC
#define __rte_msvc_pack_begin __pragma(pack(push, 1))
#define __rte_msvc_pack_end __pragma(pack(pop))
#else
#define __rte_msvc_pack_begin
#define __rte_msvc_pack_end
#endif

Quoted 3 lines

The third alternative is also problematic, e.g. if a contributor forgets the _end after the structure declaration, or adds another structure declaration before the _end.

-Morten

I looked at the suggestions made and I liked the one having a __RTE_PACKED macro the most.

Advantages:
- Can be placed in front of the struct, or even in the middle. Good for readability.
- Does not require a different macro to be placed at the end of the structure as was proposed in V5 series.
- Works well in 99% of the cases.

Problems can arise when compiler directives are present in the struct, as they become arguments for __RTE_PACKED macro. This is not portable. I've seen two situations in the DPDK code:

1) #defines mentioned in the struct. In this situation we can just move the #define out of the struct.

2) #if/#ifdef/#elif mentioned in the struct.
This is a somewhat common pattern in structs where fields change based on endianness.
Example:

/**
* IPv4 Header
*/

struct __rte_aligned(2) rte_ipv4_hdr {
	__extension__
	union {
		uint8_t version_ihl;    /**< version and header length */
		struct {
#if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
			uint8_t ihl:4;     /**< header length */
			uint8_t version:4; /**< version */
#elif RTE_BYTE_ORDER == RTE_BIG_ENDIAN
			uint8_t version:4; /**< version */
			uint8_t ihl:4;     /**< header length */
#endif
		};
	};
	uint8_t  type_of_service;	/**< type of service */
	rte_be16_t total_length;	/**< length of packet */

...
} __rte_packed;

One way to solve this is to move the #if to the outside. But that involves defining the struct twice (once for each endianness). It's less than ideal because common parts would be duplicated. I'm not sure how popular this would be.
It's not so common though (about 1% of the structs?). I think it's an acceptable trade-off to get portable code, but I would like to hear your thoughts.

Result after moving #if to the outside of the struct:

#if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
__RTE_PACKED(

struct __rte_aligned(2) rte_ipv4_hdr {
	__extension__
	union {
		uint8_t version_ihl;    /**< version and header length */
		struct {
			uint8_t ihl:4;     /**< header length */
			uint8_t version:4; /**< version */
		};
	};
	uint8_t  type_of_service;	/**< type of service */
	rte_be16_t total_length;	/**< length of packet */

...
});
#elif RTE_BYTE_ORDER == RTE_BIG_ENDIAN
__RTE_PACKED(

struct __rte_aligned(2) rte_ipv4_hdr {
	__extension__
	union {
		uint8_t version_ihl;    /**< version and header length */
		struct {
			uint8_t version:4; /**< version */
			uint8_t ihl:4;     /**< header length */
#endif
		};
	};
	uint8_t  type_of_service;	/**< type of service */
	rte_be16_t total_length;	/**< length of packet */

...
});
#endif

Andre

#81 lore raw

Re: [PATCH v5 01/16] eal: provide pack start macro for MSVC

21/11/2024 20:39, Andre Muezerie:

Quoted 107 lines · Morten Brørup
Quoted 59 lines
Quoted 38 lines

From: Andre Muezerie [mailto:[email protected]]
Sent: Tuesday, 19 November 2024 05.35

From: Tyler Retzlaff <[email protected]>

MSVC struct packing is not compatible with GCC. Provide a macro that can be used to push existing pack value and sets packing to 1-byte. The existing __rte_packed macro is then used to restore the pack value prior to the push.

Instead of providing macros exclusively for MSVC and for GCC the existing macro is deliberately utilized to trigger a warning if no existing packing has been pushed allowing easy identification of locations where the __rte_msvc_pack is missing.

---
 lib/eal/include/rte_common.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
lib/eal/include/rte_common.h +3 -2
index 4d299f2b36..409890863e 100644
@@ -103,8 +103,10 @@ typedef uint16_t unaligned_uint16_t;
  * Force a structure to be packed
  */
 #ifdef RTE_TOOLCHAIN_MSVC
-#define __rte_packed
+#define __rte_msvc_pack __pragma(pack(push, 1))
+#define __rte_packed __pragma(pack(pop))
 #else
+#define __rte_msvc_pack
 #define __rte_packed __attribute__((__packed__))
 #endif
 
--
Quoted 1 line

2.47.0.vfs.0.3

Before proceeding with this, can we please discuss the alternative, proposed here:
https://inbox.dpdk.org/dev/CAJFAV8yStgiBbe+Nkt9mC30r0+ZP64_kGuRHOzqd90RD2HXZyw@mail.gmail.com/

The definition of the packing macro in OVS, for reference:
https://github.com/openvswitch/ovs/blob/main/include/openvswitch/compiler.h#L209

The current solution requires __rte_packed to be placed at the end of a structure, although __attribute__((packed)) is normally allowed at the beginning (between the "struct" tag and the name of the structure), which introduces a high risk of contributors placing it "incorrectly", thus causing errors.

I have a strong preference for an __RTE_PACKED(decl) variant.

Here's a third alternative:
#ifdef RTE_TOOLCHAIN_MSVC
#define __rte_msvc_pack_begin __pragma(pack(push, 1))
#define __rte_msvc_pack_end __pragma(pack(pop))
#else
#define __rte_msvc_pack_begin
#define __rte_msvc_pack_end
#endif

Quoted 3 lines

The third alternative is also problematic, e.g. if a contributor forgets the _end after the structure declaration, or adds another structure declaration before the _end.

-Morten

I looked at the suggestions made and I liked the one having a __RTE_PACKED macro the most.

Advantages:
- Can be placed in front of the struct, or even in the middle. Good for readability.
- Does not require a different macro to be placed at the end of the structure as was proposed in V5 series.
- Works well in 99% of the cases.

Problems can arise when compiler directives are present in the struct, as they become arguments for __RTE_PACKED macro. This is not portable. I've seen two situations in the DPDK code:

1) #defines mentioned in the struct. In this situation we can just move the #define out of the struct.

2) #if/#ifdef/#elif mentioned in the struct.
This is a somewhat common pattern in structs where fields change based on endianness.
Example:

/**
* IPv4 Header
*/

struct __rte_aligned(2) rte_ipv4_hdr {
	__extension__
	union {
		uint8_t version_ihl;    /**< version and header length */
		struct {
#if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
			uint8_t ihl:4;     /**< header length */
			uint8_t version:4; /**< version */
#elif RTE_BYTE_ORDER == RTE_BIG_ENDIAN
			uint8_t version:4; /**< version */
			uint8_t ihl:4;     /**< header length */
#endif
		};
	};
	uint8_t  type_of_service;	/**< type of service */
	rte_be16_t total_length;	/**< length of packet */

...
} __rte_packed;

Quoted 7 lines

One way to solve this is to move the #if to the outside. But that involves defining the struct twice (once for each endianness). It's less than ideal because common parts would be duplicated. I'm not sure how popular this would be.
It's not so common though (about 1% of the structs?). I think it's an acceptable trade-off to get portable code, but I would like to hear your thoughts.

This code would be portable if Microsoft would align with other compilers.

Also I'm not sure we really need __rte_packed for most network protocols.

#82 lore raw

Re: [PATCH v5 01/16] eal: provide pack start macro for MSVC

Quoted 116 lines · Thomas Monjalon

21/11/2024 20:39, Andre Muezerie:

Quoted 107 lines · Morten Brørup
Quoted 59 lines
Quoted 38 lines

From: Andre Muezerie [mailto:[email protected]]
Sent: Tuesday, 19 November 2024 05.35

From: Tyler Retzlaff <[email protected]>

MSVC struct packing is not compatible with GCC. Provide a macro that can be used to push existing pack value and sets packing to 1-byte. The existing __rte_packed macro is then used to restore the pack value prior to the push.

Instead of providing macros exclusively for MSVC and for GCC the existing macro is deliberately utilized to trigger a warning if no existing packing has been pushed allowing easy identification of locations where the __rte_msvc_pack is missing.

---
 lib/eal/include/rte_common.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
lib/eal/include/rte_common.h +3 -2
index 4d299f2b36..409890863e 100644
@@ -103,8 +103,10 @@ typedef uint16_t unaligned_uint16_t;
  * Force a structure to be packed
  */
 #ifdef RTE_TOOLCHAIN_MSVC
-#define __rte_packed
+#define __rte_msvc_pack __pragma(pack(push, 1))
+#define __rte_packed __pragma(pack(pop))
 #else
+#define __rte_msvc_pack
 #define __rte_packed __attribute__((__packed__))
 #endif
 
--
Quoted 1 line

2.47.0.vfs.0.3

Before proceeding with this, can we please discuss the alternative, proposed here:
https://inbox.dpdk.org/dev/CAJFAV8yStgiBbe+Nkt9mC30r0+ZP64_kGuRHOzqd90RD2HXZyw@mail.gmail.com/

The definition of the packing macro in OVS, for reference:
https://github.com/openvswitch/ovs/blob/main/include/openvswitch/compiler.h#L209

The current solution requires __rte_packed to be placed at the end of a structure, although __attribute__((packed)) is normally allowed at the beginning (between the "struct" tag and the name of the structure), which introduces a high risk of contributors placing it "incorrectly", thus causing errors.

I have a strong preference for an __RTE_PACKED(decl) variant.

Here's a third alternative:
#ifdef RTE_TOOLCHAIN_MSVC
#define __rte_msvc_pack_begin __pragma(pack(push, 1))
#define __rte_msvc_pack_end __pragma(pack(pop))
#else
#define __rte_msvc_pack_begin
#define __rte_msvc_pack_end
#endif

Quoted 3 lines

The third alternative is also problematic, e.g. if a contributor forgets the _end after the structure declaration, or adds another structure declaration before the _end.

-Morten

I looked at the suggestions made and I liked the one having a __RTE_PACKED macro the most.

Advantages:
- Can be placed in front of the struct, or even in the middle. Good for readability.
- Does not require a different macro to be placed at the end of the structure as was proposed in V5 series.
- Works well in 99% of the cases.

Problems can arise when compiler directives are present in the struct, as they become arguments for __RTE_PACKED macro. This is not portable. I've seen two situations in the DPDK code:

1) #defines mentioned in the struct. In this situation we can just move the #define out of the struct.

2) #if/#ifdef/#elif mentioned in the struct.
This is a somewhat common pattern in structs where fields change based on endianness.
Example:

/**
* IPv4 Header
*/

struct __rte_aligned(2) rte_ipv4_hdr {
	__extension__
	union {
		uint8_t version_ihl;    /**< version and header length */
		struct {
#if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
			uint8_t ihl:4;     /**< header length */
			uint8_t version:4; /**< version */
#elif RTE_BYTE_ORDER == RTE_BIG_ENDIAN
			uint8_t version:4; /**< version */
			uint8_t ihl:4;     /**< header length */
#endif
		};
	};
	uint8_t  type_of_service;	/**< type of service */
	rte_be16_t total_length;	/**< length of packet */

...
} __rte_packed;

Quoted 7 lines

One way to solve this is to move the #if to the outside. But that involves defining the struct twice (once for each endianness). It's less than ideal because common parts would be duplicated. I'm not sure how popular this would be.
It's not so common though (about 1% of the structs?). I think it's an acceptable trade-off to get portable code, but I would like to hear your thoughts.

Quoted 4 lines

This code would be portable if Microsoft would align with other compilers.

Also I'm not sure we really need __rte_packed for most network protocols.

Indeed, it's is a shame that the way MSVC works differs so much, but unfortunately that won't change.

Considering the implications of the __RTE_PACK macro approach on these special cases, perhaps the initial proposal made in the series that was submitted for review is better after all? At least it does not have these "special" cases, so the approach required on the code would be uniform in the entire code base.

#83 lore raw

RE: [PATCH v5 01/16] eal: provide pack start macro for MSVC

Quoted 98 lines

From: Andre Muezerie [mailto:[email protected]]
Sent: Friday, 22 November 2024 01.12

Quoted 8 lines · Thomas Monjalon

21/11/2024 20:39, Andre Muezerie:

Quoted 7 lines · Morten Brørup
Quoted 6 lines
Quoted 6 lines

From: Andre Muezerie [mailto:[email protected]]
Sent: Tuesday, 19 November 2024 05.35

From: Tyler Retzlaff <[email protected]>

MSVC struct packing is not compatible with GCC. Provide a macro

that

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

can be used to push existing pack value and sets packing to 1-

byte.

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

The existing __rte_packed macro is then used to restore the

pack value

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

prior to the push.

Instead of providing macros exclusively for MSVC and for GCC

the

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

existing macro is deliberately utilized to trigger a warning if

no

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

existing packing has been pushed allowing easy identification

of

Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
Quoted 24 lines

locations where the __rte_msvc_pack is missing.

---
 lib/eal/include/rte_common.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
lib/eal/include/rte_common.h +3 -1
index 4d299f2b36..409890863e 100644
@@ -103,8 +103,10 @@ typedef uint16_t unaligned_uint16_t;
  * Force a structure to be packed
  */
 #ifdef RTE_TOOLCHAIN_MSVC
-#define __rte_packed
+#define __rte_msvc_pack __pragma(pack(push, 1))
+#define __rte_packed __pragma(pack(pop))
 #else
+#define __rte_msvc_pack
 #define __rte_packed __attribute__((__packed__))
 #endif
 
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

--
2.47.0.vfs.0.3

Before proceeding with this, can we please discuss the

alternative, proposed here:

Quoted 1 line
Quoted 1 line
Quoted 1 line

https://inbox.dpdk.org/dev/CAJFAV8yStgiBbe+Nkt9mC30r0+ZP64_kGuRHOzqd90R
[email protected]/

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

The definition of the packing macro in OVS, for reference:

https://github.com/openvswitch/ovs/blob/main/include/openvswitch/compil
er.h#L209

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

The current solution requires __rte_packed to be placed at the

end of a structure, although __attribute__((packed)) is normally allowed at the beginning (between the "struct" tag and the name of the structure), which introduces a high risk of contributors placing it "incorrectly", thus causing errors.

Quoted 12 lines
Quoted 12 lines
Quoted 12 lines

I have a strong preference for an __RTE_PACKED(decl) variant.

Here's a third alternative:
#ifdef RTE_TOOLCHAIN_MSVC
#define __rte_msvc_pack_begin __pragma(pack(push, 1))
#define __rte_msvc_pack_end __pragma(pack(pop))
#else
#define __rte_msvc_pack_begin
#define __rte_msvc_pack_end
#endif

Quoted 1 line
Quoted 1 line
Quoted 1 line

The third alternative is also problematic, e.g. if a contributor

forgets the _end after the structure declaration, or adds another structure declaration before the _end.

Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

-Morten

I looked at the suggestions made and I liked the one having a

__RTE_PACKED macro

Quoted 4 lines
Quoted 4 lines

the most.

Advantages:
- Can be placed in front of the struct, or even in the middle. Good

for readability.

Quoted 1 line
Quoted 1 line

- Does not require a different macro to be placed at the end of the

structure as was

Quoted 3 lines
Quoted 3 lines

proposed in V5 series.
- Works well in 99% of the cases.

Quoted 8 lines
Quoted 1 line
Quoted 1 line

Problems can arise when compiler directives are present in the

struct, as they

Quoted 4 lines
Quoted 4 lines

become arguments for __RTE_PACKED macro. This is not portable. I've seen two situations in the DPDK code:

1) #defines mentioned in the struct. In this situation we can just

move the

Quoted 1 line
Quoted 1 line
   #define out of the struct.

No problem.

Quoted 32 lines
Quoted 3 lines
Quoted 3 lines

2) #if/#ifdef/#elif mentioned in the struct.
This is a somewhat common pattern in structs where fields change

based on

Quoted 25 lines
Quoted 25 lines

endianness.
Example:

/**
* IPv4 Header
*/

struct __rte_aligned(2) rte_ipv4_hdr {
	__extension__
	union {
		uint8_t version_ihl;    /**< version and header length */
		struct {
#if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
			uint8_t ihl:4;     /**< header length */
			uint8_t version:4; /**< version */
#elif RTE_BYTE_ORDER == RTE_BIG_ENDIAN
			uint8_t version:4; /**< version */
			uint8_t ihl:4;     /**< header length */
#endif
		};
	};
	uint8_t  type_of_service;	/**< type of service */
	rte_be16_t total_length;	/**< length of packet */

...
} __rte_packed;

Quoted 1 line
Quoted 1 line

One way to solve this is to move the #if to the outside. But that

involves

Quoted 1 line
Quoted 1 line

defining the struct twice (once for each endianness). It's less

Quoted 9 lines

than

Quoted 1 line
Quoted 1 line

ideal because common parts would be duplicated. I'm not sure how

popular

Quoted 2 lines
Quoted 2 lines

this would be.
It's not so common though (about 1% of the structs?). I think it's

an

Quoted 1 line
Quoted 1 line

acceptable trade-off to get portable code, but I would like to hear

your

Quoted 1 line
Quoted 1 line

thoughts.

Good catch.
Although it is relatively rare, it is a standard design pattern, also in other projects than DPDK. We should either support it, or emit an error on occurrence when compiling.

Quoted 6 lines
Quoted 2 lines

This code would be portable if Microsoft would align with other

compilers.

Quoted 2 lines

Also I'm not sure we really need __rte_packed for most network

protocols.

Many network protocol structures contain uint32_t/rte_be32_t fields, which makes the structures 4-byte aligned; but the preceding 14 byte Ethernet header makes them non-4-byte aligned. So their alignment needs to be reduced from 4-byte to 2-byte.

Quoted 10 lines
Quoted 1 line

Indeed, it's is a shame that the way MSVC works differs so much, but unfortunately that won't change.

Considering the implications of the __RTE_PACK macro approach on these special cases, perhaps the initial proposal made in the series that was submitted for review is better after all? At least it does not have these "special" cases, so the approach required on the code would be uniform in the entire code base.

Agree.
If we don't like "msvc" in the macro name, we could rename __rte_msvc_pack to __rte_packed_begin.
We could also rename __rte_packed to __rte_packed_end, emphasizing that __rte_packed is no longer allowed at the beginning of structures. And for backwards compatibility add #define __rte_packed __rte_packed_end.

Structures would then look like this:

struct __rte_packed_begin __rte_aligned(2) rte_proto_hdr {
	rte_be32_t	proto_field;

...
} __rte_packed_end;

If you prefer keeping __rte_packed instead of renaming it to __rte_packed_end, it would probably be easy for checkpatch to verify its location in the structure declaration, as it must always be directly preceded by whitespace and directly followed by a semicolon. (The same goes for __rte_packed_end.)

Checkpatch could also verify that each __rte_packed_end/__rte_packed is preceded by __rte_packed_begin, for MSVC compatibility.

#84 lore raw

Re: [PATCH v5 01/16] eal: provide pack start macro for MSVC

Quoted 183 lines · Morten Brørup
Quoted 98 lines

From: Andre Muezerie [mailto:[email protected]]
Sent: Friday, 22 November 2024 01.12

Quoted 8 lines · Thomas Monjalon

21/11/2024 20:39, Andre Muezerie:

Quoted 7 lines · Morten Brørup
Quoted 6 lines
Quoted 6 lines

From: Andre Muezerie [mailto:[email protected]]
Sent: Tuesday, 19 November 2024 05.35

From: Tyler Retzlaff <[email protected]>

MSVC struct packing is not compatible with GCC. Provide a macro

that

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

can be used to push existing pack value and sets packing to 1-

byte.

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

The existing __rte_packed macro is then used to restore the

pack value

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

prior to the push.

Instead of providing macros exclusively for MSVC and for GCC

the

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

existing macro is deliberately utilized to trigger a warning if

no

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

existing packing has been pushed allowing easy identification

of

Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
Quoted 24 lines

locations where the __rte_msvc_pack is missing.

---
 lib/eal/include/rte_common.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
lib/eal/include/rte_common.h +3 -1
index 4d299f2b36..409890863e 100644
@@ -103,8 +103,10 @@ typedef uint16_t unaligned_uint16_t;
  * Force a structure to be packed
  */
 #ifdef RTE_TOOLCHAIN_MSVC
-#define __rte_packed
+#define __rte_msvc_pack __pragma(pack(push, 1))
+#define __rte_packed __pragma(pack(pop))
 #else
+#define __rte_msvc_pack
 #define __rte_packed __attribute__((__packed__))
 #endif
 
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

--
2.47.0.vfs.0.3

Before proceeding with this, can we please discuss the

alternative, proposed here:

Quoted 1 line
Quoted 1 line
Quoted 1 line

https://inbox.dpdk.org/dev/CAJFAV8yStgiBbe+Nkt9mC30r0+ZP64_kGuRHOzqd90R
[email protected]/

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

The definition of the packing macro in OVS, for reference:

https://github.com/openvswitch/ovs/blob/main/include/openvswitch/compil
er.h#L209

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

The current solution requires __rte_packed to be placed at the

end of a structure, although __attribute__((packed)) is normally allowed at the beginning (between the "struct" tag and the name of the structure), which introduces a high risk of contributors placing it "incorrectly", thus causing errors.

Quoted 12 lines
Quoted 12 lines
Quoted 12 lines

I have a strong preference for an __RTE_PACKED(decl) variant.

Here's a third alternative:
#ifdef RTE_TOOLCHAIN_MSVC
#define __rte_msvc_pack_begin __pragma(pack(push, 1))
#define __rte_msvc_pack_end __pragma(pack(pop))
#else
#define __rte_msvc_pack_begin
#define __rte_msvc_pack_end
#endif

Quoted 1 line
Quoted 1 line
Quoted 1 line

The third alternative is also problematic, e.g. if a contributor

forgets the _end after the structure declaration, or adds another structure declaration before the _end.

Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

-Morten

I looked at the suggestions made and I liked the one having a

__RTE_PACKED macro

Quoted 4 lines
Quoted 4 lines

the most.

Advantages:
- Can be placed in front of the struct, or even in the middle. Good

for readability.

Quoted 1 line
Quoted 1 line

- Does not require a different macro to be placed at the end of the

structure as was

Quoted 3 lines
Quoted 3 lines

proposed in V5 series.
- Works well in 99% of the cases.

Quoted 8 lines
Quoted 1 line
Quoted 1 line

Problems can arise when compiler directives are present in the

struct, as they

Quoted 4 lines
Quoted 4 lines

become arguments for __RTE_PACKED macro. This is not portable. I've seen two situations in the DPDK code:

1) #defines mentioned in the struct. In this situation we can just

move the

Quoted 1 line
Quoted 1 line
   #define out of the struct.

No problem.

Quoted 32 lines
Quoted 3 lines
Quoted 3 lines

2) #if/#ifdef/#elif mentioned in the struct.
This is a somewhat common pattern in structs where fields change

based on

Quoted 25 lines
Quoted 25 lines

endianness.
Example:

/**
* IPv4 Header
*/

struct __rte_aligned(2) rte_ipv4_hdr {
	__extension__
	union {
		uint8_t version_ihl;    /**< version and header length */
		struct {
#if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
			uint8_t ihl:4;     /**< header length */
			uint8_t version:4; /**< version */
#elif RTE_BYTE_ORDER == RTE_BIG_ENDIAN
			uint8_t version:4; /**< version */
			uint8_t ihl:4;     /**< header length */
#endif
		};
	};
	uint8_t  type_of_service;	/**< type of service */
	rte_be16_t total_length;	/**< length of packet */

...
} __rte_packed;

Quoted 1 line
Quoted 1 line

One way to solve this is to move the #if to the outside. But that

involves

Quoted 1 line
Quoted 1 line

defining the struct twice (once for each endianness). It's less

Quoted 9 lines

than

Quoted 1 line
Quoted 1 line

ideal because common parts would be duplicated. I'm not sure how

popular

Quoted 2 lines
Quoted 2 lines

this would be.
It's not so common though (about 1% of the structs?). I think it's

an

Quoted 1 line
Quoted 1 line

acceptable trade-off to get portable code, but I would like to hear

your

Quoted 1 line
Quoted 1 line

thoughts.

Good catch.
Although it is relatively rare, it is a standard design pattern, also in other projects than DPDK. We should either support it, or emit an error on occurrence when compiling.

Quoted 6 lines
Quoted 2 lines

This code would be portable if Microsoft would align with other

compilers.

Quoted 2 lines

Also I'm not sure we really need __rte_packed for most network

protocols.

Many network protocol structures contain uint32_t/rte_be32_t fields, which makes the structures 4-byte aligned; but the preceding 14 byte Ethernet header makes them non-4-byte aligned. So their alignment needs to be reduced from 4-byte to 2-byte.

Quoted 10 lines
Quoted 1 line

Indeed, it's is a shame that the way MSVC works differs so much, but unfortunately that won't change.

Considering the implications of the __RTE_PACK macro approach on these special cases, perhaps the initial proposal made in the series that was submitted for review is better after all? At least it does not have these "special" cases, so the approach required on the code would be uniform in the entire code base.

Agree.
If we don't like "msvc" in the macro name, we could rename __rte_msvc_pack to __rte_packed_begin.
We could also rename __rte_packed to __rte_packed_end, emphasizing that __rte_packed is no longer allowed at the beginning of structures. And for backwards compatibility add #define __rte_packed __rte_packed_end.

Structures would then look like this:

struct __rte_packed_begin __rte_aligned(2) rte_proto_hdr {
	rte_be32_t	proto_field;
Quoted 7 lines

...
} __rte_packed_end;

If you prefer keeping __rte_packed instead of renaming it to __rte_packed_end, it would probably be easy for checkpatch to verify its location in the structure declaration, as it must always be directly preceded by whitespace and directly followed by a semicolon. (The same goes for __rte_packed_end.)

Checkpatch could also verify that each __rte_packed_end/__rte_packed is preceded by __rte_packed_begin, for MSVC compatibility.

Makes sense. I'll update the series accordingly.

#85 lore raw

Re: [PATCH v5 01/16] eal: provide pack start macro for MSVC

In reply to Morten Brørup
Quoted 59 lines · Morten Brørup
Quoted 38 lines

From: Andre Muezerie [mailto:[email protected]]
Sent: Tuesday, 19 November 2024 05.35

From: Tyler Retzlaff <[email protected]>

MSVC struct packing is not compatible with GCC. Provide a macro that can be used to push existing pack value and sets packing to 1-byte. The existing __rte_packed macro is then used to restore the pack value prior to the push.

Instead of providing macros exclusively for MSVC and for GCC the existing macro is deliberately utilized to trigger a warning if no existing packing has been pushed allowing easy identification of locations where the __rte_msvc_pack is missing.

---
 lib/eal/include/rte_common.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
lib/eal/include/rte_common.h +3 -2
index 4d299f2b36..409890863e 100644
@@ -103,8 +103,10 @@ typedef uint16_t unaligned_uint16_t;
  * Force a structure to be packed
  */
 #ifdef RTE_TOOLCHAIN_MSVC
-#define __rte_packed
+#define __rte_msvc_pack __pragma(pack(push, 1))
+#define __rte_packed __pragma(pack(pop))
 #else
+#define __rte_msvc_pack
 #define __rte_packed __attribute__((__packed__))
 #endif
 
--
Quoted 1 line

2.47.0.vfs.0.3

Before proceeding with this, can we please discuss the alternative, proposed here:
https://inbox.dpdk.org/dev/CAJFAV8yStgiBbe+Nkt9mC30r0+ZP64_kGuRHOzqd90RD2HXZyw@mail.gmail.com/

The definition of the packing macro in OVS, for reference:
https://github.com/openvswitch/ovs/blob/main/include/openvswitch/compiler.h#L209

The current solution requires __rte_packed to be placed at the end of a structure, although __attribute__((packed)) is normally allowed at the beginning (between the "struct" tag and the name of the structure), which introduces a high risk of contributors placing it "incorrectly", thus causing errors.

I have a strong preference for an __RTE_PACKED(decl) variant.

Here's a third alternative:
#ifdef RTE_TOOLCHAIN_MSVC
#define __rte_msvc_pack_begin __pragma(pack(push, 1))
#define __rte_msvc_pack_end __pragma(pack(pop))
#else
#define __rte_msvc_pack_begin
#define __rte_msvc_pack_end
#endif

Quoted 1 line

The third alternative is also problematic, e.g. if a contributor forgets the _end after the structure declaration, or adds another structure declaration before the _end.

so just some additional info here.

for the compiler that cares about the end (i.e. msvc) msvc actually emits a warning (treated as error) if a push pack is not closed with a pop pack within a header or a tu. that's one of the benefits of the macros in original proposal.

Quoted 2 lines

-Morten

#86 lore raw

PATCH v5 2/16 eal: pack structures when building with MSVC

In reply to Andre Muezerie

From: Tyler Retzlaff <[email protected]>

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.

---
 lib/eal/common/eal_private.h      | 2 +-
 lib/eal/include/rte_memory.h      | 1 +
 lib/eal/include/rte_memzone.h     | 1 +
 lib/eal/include/rte_trace_point.h | 2 +-
 lib/eal/x86/include/rte_memcpy.h  | 3 +++
 5 files changed, 7 insertions(+), 2 deletions(-)
lib/eal/common/eal_private.h +1 -1
index bb315dab04..3b94e01b5b 100644
@@ -62,7 +62,7 @@ struct rte_config {
 	 * DPDK instances
 	 */
 	struct rte_mem_config *mem_config;
-} __rte_packed;
+};
 
 /**
  * Get the global configuration structure.
lib/eal/include/rte_memory.h +1 -0
index dbd0a6bedc..fffbd2ed65 100644
@@ -46,6 +46,7 @@ extern "C" {
 /**
  * Physical memory segment descriptor.
  */
+__rte_msvc_pack
 struct rte_memseg {
 	rte_iova_t iova;            /**< Start IO address. */
 	union {
lib/eal/include/rte_memzone.h +1 -0
index e1563994d5..e52bdc91b8 100644
@@ -45,6 +45,7 @@ extern "C" {
  * A structure describing a memzone, which is a contiguous portion of
  * physical memory identified by a name.
  */
+__rte_msvc_pack
 struct rte_memzone {
 
 #define RTE_MEMZONE_NAMESIZE 32       /**< Maximum length of memory zone name.*/
lib/eal/include/rte_trace_point.h +1 -1
index 87b5f43c3c..b24db3b6da 100644
@@ -298,7 +298,7 @@ struct __rte_trace_stream_header {
 	rte_uuid_t uuid;
 	uint32_t lcore_id;
 	char thread_name[__RTE_TRACE_EMIT_STRING_LEN_MAX];
-} __rte_packed;
+};
 
 struct __rte_trace_header {
 	uint32_t offset;
lib/eal/x86/include/rte_memcpy.h +3 -0
index 42058e4a3f..fed715ca33 100644
@@ -67,12 +67,15 @@ rte_mov15_or_less(void *dst, const void *src, size_t n)
 	 * Use the following structs to avoid violating C standard
 	 * alignment requirements and to avoid strict aliasing bugs
 	 */
+	__rte_msvc_pack
 	struct rte_uint64_alias {
 		uint64_t val;
 	} __rte_packed __rte_may_alias;
+	__rte_msvc_pack
 	struct rte_uint32_alias {
 		uint32_t val;
 	} __rte_packed __rte_may_alias;
+	__rte_msvc_pack
 	struct rte_uint16_alias {
 		uint16_t val;
 	} __rte_packed __rte_may_alias;
Signature · 1 line
2.47.0.vfs.0.3
#87 lore raw

PATCH v5 3/16 net: pack structures when building with MSVC

In reply to Andre Muezerie

From: Tyler Retzlaff <[email protected]>

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

---
 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(+)
lib/net/rte_arp.h +2 -0
index 668cea1704..35d68c108d 100644
@@ -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 */
lib/net/rte_dtls.h +1 -0
index 246cd8a72d..a6243a2791 100644
@@ -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;
lib/net/rte_esp.h +2 -0
index 745a9847fe..ff7b5fe585 100644
@@ -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 */
lib/net/rte_geneve.h +1 -0
index eb2c85f1e9..8bea7d288b 100644
@@ -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. */
lib/net/rte_gre.h +4 -0
index 1483e1b42d..48bd5b1621 100644
@@ -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;
lib/net/rte_gtp.h +5 -0
index ab06e23a6e..09d7d8e3a9 100644
@@ -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
lib/net/rte_ib.h +1 -0
index a551f3753f..eaa97dff31 100644
@@ -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
lib/net/rte_icmp.h +3 -0
index e69d68ab6e..63b21c051b 100644
@@ -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. */
lib/net/rte_ip4.h +1 -0
index f9b8333332..f1ec24a8d1 100644
@@ -39,6 +39,7 @@ extern "C" {
 /**
  * IPv4 Header
  */
+__rte_msvc_pack
 struct __rte_aligned(2) rte_ipv4_hdr {
 	__extension__
 	union {
lib/net/rte_ip6.h +4 -0
index 992ab5ee1f..cab8d40f2b 100644
@@ -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 */
lib/net/rte_l2tpv2.h +4 -0
index ac16657856..b34431581a 100644
@@ -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 {
lib/net/rte_macsec.h +2 -0
index beeeb8effe..11c0c2e38c 100644
@@ -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;
lib/net/rte_mpls.h +1 -0
index 35a356efd3..184a569a6b 100644
@@ -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
lib/net/rte_pdcp_hdr.h +4 -0
index c22b66bf93..5a7c11e784 100644
@@ -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 */
lib/net/rte_ppp.h +1 -0
index 63c72a9392..bf91295e92 100644
@@ -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) */
lib/net/rte_sctp.h +1 -0
index e757c57db3..4379836c5c 100644
@@ -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. */
lib/net/rte_tcp.h +1 -0
index 1bcacbf038..3f5a37b9b0 100644
@@ -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. */
lib/net/rte_tls.h +1 -0
index 595567e3e9..094f722c12 100644
@@ -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;
lib/net/rte_udp.h +1 -0
index c01dad9c9b..6de76e0199 100644
@@ -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. */
lib/net/rte_vxlan.h +7 -0
index bd1c89835e..17367f1343 100644
@@ -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 {
Signature · 1 line
2.47.0.vfs.0.3
#88 lore raw

PATCH v5 4/16 common/iavf: pack structures when building with MSVC

In reply to Andre Muezerie

From: Tyler Retzlaff <[email protected]>

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

---
 drivers/common/iavf/iavf_osdep.h            |  2 ++
 drivers/common/iavf/virtchnl_inline_ipsec.h | 11 +++++++++++
 2 files changed, 13 insertions(+)
drivers/common/iavf/iavf_osdep.h +2 -0
index 1f2b7889cb..8e9d93ccaa 100644
@@ -158,6 +158,7 @@ do {                                                            \
 } while (0)
 
 /* memory allocation tracking */
+__rte_msvc_pack
 struct iavf_dma_mem {
 	void *va;
 	u64 pa;
@@ -165,6 +166,7 @@ struct iavf_dma_mem {
 	const void *zone;
 } __rte_packed;
 
+__rte_msvc_pack
 struct iavf_virt_mem {
 	void *va;
 	u32 size;
drivers/common/iavf/virtchnl_inline_ipsec.h +11 -0
index 2f4bf15725..feb0f44381 100644
@@ -109,6 +109,7 @@ enum inline_ipsec_ops {
 };
 
 /* Not all valid, if certain field is invalid, set 1 for all bits */
+__rte_msvc_pack
 struct virtchnl_algo_cap  {
 	u32 algo_type;
 
@@ -132,6 +133,7 @@ struct virtchnl_algo_cap  {
 } __rte_packed;
 
 /* vf record the capability of crypto from the virtchnl */
+__rte_msvc_pack
 struct virtchnl_sym_crypto_cap {
 	u8 crypto_type;
 	u8 algo_cap_num;
@@ -142,6 +144,7 @@ struct virtchnl_sym_crypto_cap {
  * VF pass virtchnl_ipsec_cap to PF
  * and PF return capability of ipsec from virtchnl.
  */
+__rte_msvc_pack
 struct virtchnl_ipsec_cap {
 	/* max number of SA per VF */
 	u16 max_sa_num;
@@ -172,6 +175,7 @@ struct virtchnl_ipsec_cap {
 } __rte_packed;
 
 /* configuration of crypto function */
+__rte_msvc_pack
 struct virtchnl_ipsec_crypto_cfg_item {
 	u8 crypto_type;
 
@@ -203,6 +207,7 @@ struct virtchnl_ipsec_sym_crypto_cfg {
  * PF create SA as configuration and PF driver will return
  * an unique index (sa_idx) for the created SA.
  */
+__rte_msvc_pack
 struct virtchnl_ipsec_sa_cfg {
 	/* IPsec SA Protocol - AH/ESP */
 	u8 virtchnl_protocol_type;
@@ -298,6 +303,7 @@ struct virtchnl_ipsec_sa_cfg {
  * VF send configuration of index of SA to PF
  * PF will update SA according to configuration
  */
+__rte_msvc_pack
 struct virtchnl_ipsec_sa_update {
 	u32 sa_index; /* SA to update */
 	u32 esn_hi; /* high 32 bits of esn */
@@ -310,6 +316,7 @@ struct virtchnl_ipsec_sa_update {
  * flag bitmap indicate all SA or just selected SA will
  * be destroyed
  */
+__rte_msvc_pack
 struct virtchnl_ipsec_sa_destroy {
 	/* All zero bitmap indicates all SA will be destroyed.
 	 * Non-zero bitmap indicates the selected SA in
@@ -325,6 +332,7 @@ struct virtchnl_ipsec_sa_destroy {
  * VF send this SA configuration to PF using virtchnl;
  * PF read SA and will return configuration for the created SA.
  */
+__rte_msvc_pack
 struct virtchnl_ipsec_sa_read {
 	/* SA valid - invalid/valid */
 	u8 valid;
@@ -431,6 +439,7 @@ struct virtchnl_ipsec_sa_read {
 #define VIRTCHNL_IPSEC_INBOUND_SPD_TBL_IPV6	(1)
 
 /* Add allowlist entry in IES */
+__rte_msvc_pack
 struct virtchnl_ipsec_sp_cfg {
 	u32 spi;
 	u32 dip[4];
@@ -459,6 +468,7 @@ struct virtchnl_ipsec_sp_cfg {
 
 
 /* Delete allowlist entry in IES */
+__rte_msvc_pack
 struct virtchnl_ipsec_sp_destroy {
 	/* 0 for IPv4 table, 1 for IPv6 table. */
 	u8 table_id;
@@ -494,6 +504,7 @@ struct virtchnl_ipsec_resp {
 };
 
 /* Internal message descriptor for VF <-> IPsec communication */
+__rte_msvc_pack
 struct inline_ipsec_msg {
 	u16 ipsec_opcode;
 	u16 req_id;
Signature · 1 line
2.47.0.vfs.0.3
#89 lore raw

PATCH v5 5/16 common/idpf: pack structures when building with MSVC

In reply to Andre Muezerie

From: Tyler Retzlaff <[email protected]>

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

---
 drivers/common/idpf/base/idpf_osdep.h | 2 ++
 1 file changed, 2 insertions(+)
drivers/common/idpf/base/idpf_osdep.h +2 -0
index cf9e553906..95449fbf19 100644
@@ -180,6 +180,7 @@ static inline uint64_t idpf_read_addr64(volatile void *addr)
 #define BITS_PER_BYTE       8
 
 /* memory allocation tracking */
+__rte_msvc_pack
 struct idpf_dma_mem {
 	void *va;
 	u64 pa;
@@ -187,6 +188,7 @@ struct idpf_dma_mem {
 	const void *zone;
 } __rte_packed;
 
+__rte_msvc_pack
 struct idpf_virt_mem {
 	void *va;
 	u32 size;
Signature · 1 line
2.47.0.vfs.0.3
#90 lore raw

PATCH v5 6/16 common/mlx5: pack structures when building with MSVC

In reply to Andre Muezerie

From: Tyler Retzlaff <[email protected]>

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

---
 drivers/common/mlx5/mlx5_common_mr.h    |  4 ++++
 drivers/common/mlx5/mlx5_common_utils.h |  1 +
 drivers/common/mlx5/mlx5_prm.h          | 30 +++++++++++++++++++++++++
 3 files changed, 35 insertions(+)
drivers/common/mlx5/mlx5_common_mr.h +4 -0
index a7f1042037..a1ea68504e 100644
@@ -49,6 +49,7 @@ struct mlx5_mr {
 };
 
 /* Cache entry for Memory Region. */
+__rte_msvc_pack
 struct mr_cache_entry {
 	uintptr_t start; /* Start address of MR. */
 	uintptr_t end; /* End address of MR. */
@@ -56,6 +57,7 @@ struct mr_cache_entry {
 } __rte_packed;
 
 /* MR Cache table for Binary search. */
+__rte_msvc_pack
 struct mlx5_mr_btree {
 	uint32_t len; /* Number of entries. */
 	uint32_t size; /* Total number of entries. */
@@ -65,6 +67,7 @@ struct mlx5_mr_btree {
 struct mlx5_common_device;
 
 /* Per-queue MR control descriptor. */
+__rte_msvc_pack
 struct mlx5_mr_ctrl {
 	uint32_t *dev_gen_ptr; /* Generation number of device to poll. */
 	uint32_t cur_gen; /* Generation number saved to flush caches. */
@@ -78,6 +81,7 @@ LIST_HEAD(mlx5_mr_list, mlx5_mr);
 LIST_HEAD(mlx5_mempool_reg_list, mlx5_mempool_reg);
 
 /* Global per-device MR cache. */
+__rte_msvc_pack
 struct mlx5_mr_share_cache {
 	uint32_t dev_gen; /* Generation number to flush local caches. */
 	rte_rwlock_t rwlock; /* MR cache Lock. */
drivers/common/mlx5/mlx5_common_utils.h +1 -0
index 9139bc6829..b93df0b27d 100644
@@ -27,6 +27,7 @@ struct mlx5_list;
  * Structure of the entry in the mlx5 list, user should define its own struct
  * that contains this in order to store the data.
  */
+__rte_msvc_pack
 struct mlx5_list_entry {
 	LIST_ENTRY(mlx5_list_entry) next; /* Entry pointers in the list. */
 	alignas(8) RTE_ATOMIC(uint32_t) ref_cnt; /* 0 means, entry is invalid. */
drivers/common/mlx5/mlx5_prm.h +30 -0
index 2d82807bc2..72f87ad30b 100644
@@ -323,6 +323,7 @@ enum mlx5_mpw_mode {
 };
 
 /* WQE Control segment. */
+__rte_msvc_pack
 struct __rte_aligned(MLX5_WSEG_SIZE) mlx5_wqe_cseg {
 	uint32_t opcode;
 	uint32_t sq_ds;
@@ -340,10 +341,12 @@ struct __rte_aligned(MLX5_WSEG_SIZE) mlx5_wqe_cseg {
 #define WQE_CSEG_WQE_INDEX_OFFSET	 8
 
 /* Header of data segment. Minimal size Data Segment */
+__rte_msvc_pack
 struct mlx5_wqe_dseg {
 	uint32_t bcount;
 	union {
 		uint8_t inline_data[MLX5_DSEG_MIN_INLINE_SIZE];
+		__rte_msvc_pack
 		struct {
 			uint32_t lkey;
 			uint64_t pbuf;
@@ -352,8 +355,10 @@ struct mlx5_wqe_dseg {
 } __rte_packed;
 
 /* Subset of struct WQE Ethernet Segment. */
+__rte_msvc_pack
 struct mlx5_wqe_eseg {
 	union {
+		__rte_msvc_pack
 		struct {
 			uint32_t swp_offs;
 			uint8_t	cs_flags;
@@ -366,6 +371,7 @@ struct mlx5_wqe_eseg {
 				uint16_t vlan_tag;
 			};
 		} __rte_packed;
+		__rte_msvc_pack
 		struct {
 			uint32_t offsets;
 			uint32_t flags;
@@ -375,6 +381,7 @@ struct mlx5_wqe_eseg {
 	};
 } __rte_packed;
 
+__rte_msvc_pack
 struct mlx5_wqe_qseg {
 	uint32_t reserved0;
 	uint32_t reserved1;
@@ -382,6 +389,7 @@ struct mlx5_wqe_qseg {
 	uint32_t qpn_cqn;
 } __rte_packed;
 
+__rte_msvc_pack
 struct mlx5_wqe_wseg {
 	uint32_t operation;
 	uint32_t lkey;
@@ -392,6 +400,7 @@ struct mlx5_wqe_wseg {
 } __rte_packed;
 
 /* The title WQEBB, header of WQE. */
+__rte_msvc_pack
 struct mlx5_wqe {
 	union {
 		struct mlx5_wqe_cseg cseg;
@@ -464,6 +473,7 @@ struct mlx5_cqe {
 	uint8_t lro_num_seg;
 	union {
 		uint8_t user_index_bytes[3];
+		__rte_msvc_pack
 		struct {
 			uint8_t user_index_hi;
 			uint16_t user_index_low;
@@ -487,6 +497,7 @@ struct mlx5_cqe_ts {
 	uint8_t op_own;
 };
 
+__rte_msvc_pack
 struct mlx5_wqe_rseg {
 	uint64_t raddr;
 	uint32_t rkey;
@@ -506,6 +517,7 @@ struct mlx5_wqe_rseg {
 #define MLX5_UMR_KLM_NUM_ALIGN \
 	(MLX5_UMR_KLM_PTR_ALIGN / sizeof(struct mlx5_klm))
 
+__rte_msvc_pack
 struct mlx5_wqe_umr_cseg {
 	uint32_t if_cf_toe_cq_res;
 	uint32_t ko_to_bs;
@@ -513,6 +525,7 @@ struct mlx5_wqe_umr_cseg {
 	uint32_t rsvd1[8];
 } __rte_packed;
 
+__rte_msvc_pack
 struct mlx5_wqe_mkey_cseg {
 	uint32_t fr_res_af_sf;
 	uint32_t qpn_mkey;
@@ -576,6 +589,7 @@ enum {
 #define MLX5_CRYPTO_MMO_TYPE_OFFSET 24
 #define MLX5_CRYPTO_MMO_OP_OFFSET 20
 
+__rte_msvc_pack
 struct mlx5_wqe_umr_bsf_seg {
 	/*
 	 * bs_bpt_eo_es contains:
@@ -609,6 +623,7 @@ struct mlx5_wqe_umr_bsf_seg {
 #pragma GCC diagnostic ignored "-Wpedantic"
 #endif
 
+__rte_msvc_pack
 struct mlx5_umr_wqe {
 	struct mlx5_wqe_cseg ctr;
 	struct mlx5_wqe_umr_cseg ucseg;
@@ -619,18 +634,21 @@ struct mlx5_umr_wqe {
 	};
 } __rte_packed;
 
+__rte_msvc_pack
 struct mlx5_rdma_write_wqe {
 	struct mlx5_wqe_cseg ctr;
 	struct mlx5_wqe_rseg rseg;
 	struct mlx5_wqe_dseg dseg[];
 } __rte_packed;
 
+__rte_msvc_pack
 struct mlx5_wqe_send_en_seg {
 	uint32_t reserve[2];
 	uint32_t sqnpc;
 	uint32_t qpn;
 } __rte_packed;
 
+__rte_msvc_pack
 struct mlx5_wqe_send_en_wqe {
 	struct mlx5_wqe_cseg ctr;
 	struct mlx5_wqe_send_en_seg sseg;
@@ -677,6 +695,7 @@ struct mlx5_wqe_metadata_seg {
 	uint64_t addr;
 };
 
+__rte_msvc_pack
 struct mlx5_gga_wqe {
 	uint32_t opcode;
 	uint32_t sq_ds;
@@ -690,16 +709,19 @@ struct mlx5_gga_wqe {
 } __rte_packed;
 
 union mlx5_gga_compress_opaque {
+	__rte_msvc_pack
 	struct {
 		uint32_t syndrome;
 		uint32_t reserved0;
 		uint32_t scattered_length;
 		union {
+			__rte_msvc_pack
 			struct {
 				uint32_t reserved1[5];
 				uint32_t crc32;
 				uint32_t adler32;
 			} v1 __rte_packed;
+			__rte_msvc_pack
 			struct {
 				uint32_t crc32;
 				uint32_t adler32;
@@ -712,9 +734,11 @@ union mlx5_gga_compress_opaque {
 };
 
 union mlx5_gga_crypto_opaque {
+	__rte_msvc_pack
 	struct {
 		uint32_t syndrome;
 		uint32_t reserved0[2];
+		__rte_msvc_pack
 		struct {
 			uint32_t iv[3];
 			uint32_t tag_size;
@@ -931,6 +955,7 @@ mlx5_regc_value(uint8_t regc_ix)
 
 /* Modification sub command. */
 struct mlx5_modification_cmd {
+	__rte_msvc_pack
 	union {
 		uint32_t data0;
 		struct {
@@ -942,6 +967,7 @@ struct mlx5_modification_cmd {
 			unsigned int action_type:4;
 		};
 	} __rte_packed;
+	__rte_msvc_pack
 	union {
 		uint32_t data1;
 		uint8_t data[4];
@@ -4191,6 +4217,7 @@ enum mlx5_aso_op {
 #define MLX5_ASO_CSEG_READ_ENABLE 1
 
 /* ASO WQE CTRL segment. */
+__rte_msvc_pack
 struct mlx5_aso_cseg {
 	uint32_t va_h;
 	uint32_t va_l_r;
@@ -4207,6 +4234,7 @@ struct mlx5_aso_cseg {
 #define MLX5_MTR_MAX_TOKEN_VALUE INT32_MAX
 
 /* A meter data segment - 2 per ASO WQE. */
+__rte_msvc_pack
 struct mlx5_aso_mtr_dseg {
 	uint32_t v_bo_sc_bbog_mm;
 	/*
@@ -4248,6 +4276,7 @@ struct mlx5_aso_mtr_dseg {
 #define MLX5_ASO_MTRS_PER_POOL 128
 
 /* ASO WQE data segment. */
+__rte_msvc_pack
 struct mlx5_aso_dseg {
 	union {
 		uint8_t data[MLX5_ASO_WQE_DSEG_SIZE];
@@ -4256,6 +4285,7 @@ struct mlx5_aso_dseg {
 } __rte_packed;
 
 /* ASO WQE. */
+__rte_msvc_pack
 struct mlx5_aso_wqe {
 	struct mlx5_wqe_cseg general_cseg;
 	struct mlx5_aso_cseg aso_cseg;
Signature · 1 line
2.47.0.vfs.0.3
#91 lore raw

PATCH v5 7/16 dma/ioat: pack structures when building with MSVC

In reply to Andre Muezerie

From: Tyler Retzlaff <[email protected]>

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

---
 drivers/dma/ioat/ioat_hw_defs.h | 1 +
 1 file changed, 1 insertion(+)
drivers/dma/ioat/ioat_hw_defs.h +1 -0
index 11893951f2..b67e252d6c 100644
@@ -52,6 +52,7 @@ extern "C" {
 #define	IOAT_DMACAP_PQ		(1 << 9)
 #define	IOAT_DMACAP_DMA_DIF	(1 << 10)
 
+__rte_msvc_pack
 struct ioat_registers {
 	uint8_t		chancnt;
 	uint8_t		xfercap;
Signature · 1 line
2.47.0.vfs.0.3
#92 lore raw

PATCH v5 8/16 net/i40e: pack structures when building with MSVC

In reply to Andre Muezerie

From: Tyler Retzlaff <[email protected]>

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

---
 drivers/net/i40e/base/i40e_osdep.h | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/i40e/base/i40e_osdep.h +2 -0
index 8960206d8b..af8756b7d8 100644
@@ -177,6 +177,7 @@ static inline uint64_t i40e_read64_addr(volatile void *addr)
 #define ARRAY_SIZE(arr) RTE_DIM(arr)
 
 /* memory allocation tracking */
+__rte_msvc_pack
 struct i40e_dma_mem {
 	void *va;
 	u64 pa;
@@ -188,6 +189,7 @@ struct i40e_dma_mem {
 			i40e_allocate_dma_mem_d(h, m, s, a)
 #define i40e_free_dma_mem(h, m) i40e_free_dma_mem_d(h, m)
 
+__rte_msvc_pack
 struct i40e_virt_mem {
 	void *va;
 	u32 size;
Signature · 1 line
2.47.0.vfs.0.3
#93 lore raw

PATCH v5 9/16 net/iavf: pack structures when building with MSVC

In reply to Andre Muezerie

From: Tyler Retzlaff <[email protected]>

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.

---
 drivers/net/iavf/iavf_ipsec_crypto.h | 4 +++-
 drivers/net/iavf/iavf_rxtx.c         | 2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)
drivers/net/iavf/iavf_ipsec_crypto.h +3 -1
index 49f9202aca..0637ce21d6 100644
@@ -11,12 +11,14 @@
 
 
 
+__rte_msvc_pack
 struct iavf_tx_ipsec_desc {
 	union {
 		struct {
 			__le64 qw0;
 			__le64 qw1;
 		};
+		__rte_msvc_pack
 		struct {
 			__le16 l4payload_length;
 			__le32 esn;
@@ -97,7 +99,7 @@ struct iavf_ipsec_crypto_pkt_metadata {
 	uint8_t next_proto;		/* Next Protocol (8b/1B) */
 
 	uint32_t esn;		        /* Extended Sequence Number (32b/4B) */
-} __rte_packed;
+};
 
 /**
  * Inline IPsec Crypto offload is supported
drivers/net/iavf/iavf_rxtx.c +1 -1
index 4850b9e381..7efbee7c3e 100644
@@ -53,7 +53,7 @@ static uint16_t geneve_udp_port = RTE_GENEVE_DEFAULT_PORT;
 struct simple_gre_hdr {
 	uint16_t flags;
 	uint16_t proto;
-} __rte_packed;
+};
 
 /* structure that caches offload info for the current packet */
 struct offload_info {
Signature · 1 line
2.47.0.vfs.0.3
#94 lore raw

PATCH v5 10/16 net/ice: pack structures when building with MSVC

In reply to Andre Muezerie

From: Tyler Retzlaff <[email protected]>

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

---
 drivers/net/ice/base/ice_osdep.h | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/ice/base/ice_osdep.h +2 -0
index 5f7347023f..d0280dd2c2 100644
@@ -187,6 +187,7 @@ do {									\
 #define BITS_PER_BYTE       8
 
 /* memory allocation tracking */
+__rte_msvc_pack
 struct ice_dma_mem {
 	void *va;
 	u64 pa;
@@ -194,6 +195,7 @@ struct ice_dma_mem {
 	const void *zone;
 } __rte_packed;
 
+__rte_msvc_pack
 struct ice_virt_mem {
 	void *va;
 	u32 size;
Signature · 1 line
2.47.0.vfs.0.3
#95 lore raw

PATCH v5 11/16 net/mlx5: pack structures when building with MSVC

In reply to Andre Muezerie

From: Tyler Retzlaff <[email protected]>

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

---
 drivers/net/mlx5/hws/mlx5dr.h   | 1 +
 drivers/net/mlx5/mlx5.h         | 1 +
 drivers/net/mlx5/mlx5_flow.h    | 4 ++++
 drivers/net/mlx5/mlx5_hws_cnt.h | 1 +
 drivers/net/mlx5/mlx5_utils.h   | 4 ++++
 5 files changed, 11 insertions(+)
drivers/net/mlx5/hws/mlx5dr.h +1 -0
index 3668ab9fcf..6539af27bb 100644
@@ -328,6 +328,7 @@ union mlx5dr_crc_encap_entropy_hash_ip_field {
 	};
 };
 
+__rte_msvc_pack
 struct mlx5dr_crc_encap_entropy_hash_fields {
 	union mlx5dr_crc_encap_entropy_hash_ip_field dst;
 	union mlx5dr_crc_encap_entropy_hash_ip_field src;
drivers/net/mlx5/mlx5.h +1 -0
index 89d277b523..1ca52bfe69 100644
@@ -235,6 +235,7 @@ mlx5_is_probed_port_on_mpesw_device(struct mlx5_dev_spawn_data *spawn)
 }
 
 /** Data associated with socket messages. */
+__rte_msvc_pack
 struct mlx5_flow_dump_req  {
 	uint32_t port_id; /**< There are plans in DPDK to extend port_id. */
 	uint64_t flow_id;
drivers/net/mlx5/mlx5_flow.h +4 -0
index bcc2782460..4d40866539 100644
@@ -673,6 +673,7 @@ struct mlx5_flow_dv_tag_resource {
 };
 
 /* Modify resource structure */
+__rte_msvc_pack
 struct mlx5_flow_dv_modify_hdr_resource {
 	struct mlx5_list_entry entry;
 	void *action; /**< Modify header action object. */
@@ -831,6 +832,7 @@ struct mlx5_flow_dv_dest_array_resource {
 
 
 /** Device flow handle structure for DV mode only. */
+__rte_msvc_pack
 struct mlx5_flow_handle_dv {
 	/* Flow DV api: */
 	struct mlx5_flow_dv_matcher *matcher; /**< Cache to matcher. */
@@ -849,6 +851,7 @@ struct mlx5_flow_handle_dv {
 } __rte_packed;
 
 /** Device flow handle structure: used both for creating & destroying. */
+__rte_msvc_pack
 struct mlx5_flow_handle {
 	SILIST_ENTRY(uint32_t)next;
 	struct mlx5_vf_vlan vf_vlan; /**< Structure for VF VLAN workaround. */
@@ -1250,6 +1253,7 @@ struct mlx5_flow_attr {
 };
 
 /* Flow structure. */
+__rte_msvc_pack
 struct rte_flow {
 	uint32_t dev_handles;
 	/**< Device flow handles that are part of the flow. */
drivers/net/mlx5/mlx5_hws_cnt.h +1 -0
index d8da9dfcdd..7479da7c5e 100644
@@ -133,6 +133,7 @@ enum {
 };
 
 /* HWS counter age parameter. */
+__rte_msvc_pack
 struct __rte_cache_aligned mlx5_hws_age_param {
 	RTE_ATOMIC(uint32_t) timeout; /* Aging timeout in seconds (atomically accessed). */
 	RTE_ATOMIC(uint32_t) sec_since_last_hit;
drivers/net/mlx5/mlx5_utils.h +4 -0
index f933daf03c..081678fa43 100644
@@ -115,6 +115,7 @@ struct mlx5_l3t_level_tbl {
 };
 
 /* L3 word entry table data structure. */
+__rte_msvc_pack
 struct mlx5_l3t_entry_word {
 	uint32_t idx; /* Table index. */
 	uint64_t ref_cnt; /* Table ref_cnt. */
@@ -125,6 +126,7 @@ struct mlx5_l3t_entry_word {
 } __rte_packed;
 
 /* L3 double word entry table data structure. */
+__rte_msvc_pack
 struct mlx5_l3t_entry_dword {
 	uint32_t idx; /* Table index. */
 	uint64_t ref_cnt; /* Table ref_cnt. */
@@ -135,6 +137,7 @@ struct mlx5_l3t_entry_dword {
 } __rte_packed;
 
 /* L3 quad word entry table data structure. */
+__rte_msvc_pack
 struct mlx5_l3t_entry_qword {
 	uint32_t idx; /* Table index. */
 	uint64_t ref_cnt; /* Table ref_cnt. */
@@ -145,6 +148,7 @@ struct mlx5_l3t_entry_qword {
 } __rte_packed;
 
 /* L3 pointer entry table data structure. */
+__rte_msvc_pack
 struct mlx5_l3t_entry_ptr {
 	uint32_t idx; /* Table index. */
 	uint64_t ref_cnt; /* Table ref_cnt. */
Signature · 1 line
2.47.0.vfs.0.3
#96 lore raw

PATCH v5 12/16 net/octeon_ep: pack structures when building with MSVC

In reply to Andre Muezerie

From: Tyler Retzlaff <[email protected]>

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

---
 drivers/net/octeon_ep/otx_ep_mbox.h | 1 +
 1 file changed, 1 insertion(+)
drivers/net/octeon_ep/otx_ep_mbox.h +1 -0
index ec96e4edc5..44da0fa84f 100644
@@ -76,6 +76,7 @@ enum otx_ep_link_autoneg {
 #define OTX_EP_MBOX_MORE_FRAG_FLAG 1
 #define OTX_EP_MBOX_WRITE_WAIT_TIME msecs_to_jiffies(1)
 
+__rte_msvc_pack
 union otx_ep_mbox_word {
 	uint64_t u64;
 	struct {
Signature · 1 line
2.47.0.vfs.0.3
#97 lore raw

PATCH v5 13/16 app/testpmd: pack structures when building with MSVC

In reply to Andre Muezerie

From: Tyler Retzlaff <[email protected]>

Remove __rte_packed where it appears natural alignment without packing would produce the same layout or the struct is internal.

---
 app/test-pmd/csumonly.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
app/test-pmd/csumonly.c +1 -1
index 2246c22e8e..d77a140641 100644
@@ -92,7 +92,7 @@ struct testpmd_offload_info {
 struct simple_gre_hdr {
 	uint16_t flags;
 	uint16_t proto;
-} __rte_packed;
+};
 
 static uint16_t
 get_udptcp_checksum(struct rte_mbuf *m, void *l3_hdr, uint16_t l4_off,
Signature · 1 line
2.47.0.vfs.0.3
#98 lore raw

PATCH v5 14/16 app/test: pack structures when building with MSVC

In reply to Andre Muezerie

From: Tyler Retzlaff <[email protected]>

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

---
 app/test/test_efd.c    | 1 +
 app/test/test_hash.c   | 1 +
 app/test/test_member.c | 1 +
 3 files changed, 3 insertions(+)
app/test/test_efd.c +1 -0
index 1c0986b9bc..df176a0fbb 100644
@@ -33,6 +33,7 @@ test_efd(void)
 static unsigned int test_socket_id;
 
 /* 5-tuple key type */
+__rte_msvc_pack
 struct flow_key {
 	uint32_t ip_src;
 	uint32_t ip_dst;
app/test/test_hash.c +1 -0
index 65b9cad93c..9b621ec6c3 100644
@@ -79,6 +79,7 @@ static uint32_t hashtest_key_lens[] = {0, 2, 4, 5, 6, 7, 8, 10, 11, 15, 16, 21,
  * Should be packed to avoid holes with potentially
  * undefined content in the middle.
  */
+__rte_msvc_pack
 struct flow_key {
 	uint32_t ip_src;
 	uint32_t ip_dst;
app/test/test_member.c +1 -0
index 5a4d2750db..ccd481a3a1 100644
@@ -32,6 +32,7 @@ struct rte_member_setsum *setsum_vbf;
 struct rte_member_setsum *setsum_sketch;
 
 /* 5-tuple key type */
+__rte_msvc_pack
 struct flow_key {
 	uint32_t ip_src;
 	uint32_t ip_dst;
Signature · 1 line
2.47.0.vfs.0.3
#99 lore raw

PATCH v5 15/16 examples: pack structures when building with MSVC

In reply to Andre Muezerie

From: Tyler Retzlaff <[email protected]>

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.

---
 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(-)
examples/common/neon/port_group.h +1 -0
index 421e2e8613..bd40590418 100644
@@ -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;
examples/ip_pipeline/cli.c +5 -5
index 92dfacdeb0..766fc8e46e 100644
@@ -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,
examples/ipsec-secgw/ipsec.h +1 -0
index f12f57e2d5..dc146bccb8 100644
@@ -274,6 +274,7 @@ struct socket_ctx {
 	struct rte_mempool *session_pool;
 };
 
+__rte_msvc_pack
 struct cnt_blk {
 	uint32_t salt;
 	uint64_t iv;
examples/l3fwd-power/main.c +3 -1
index ae8b55924e..ce3c901b45 100644
@@ -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];
examples/l3fwd/l3fwd_route.h +2 -0
index 62263c3540..8c7be4b9d6 100644
@@ -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];
examples/ptpclient/ptpclient.c +8 -0
index 23fa487081..d7caad41d3 100644
@@ -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;
examples/vhost_blk/blk_spec.h +1 -0
index 3c54f70eaf..3dc0681551 100644
@@ -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;
 
Signature · 1 line
2.47.0.vfs.0.3
#100 lore raw

PATCH v5 16/16 crypto/mlx5: pack structures when building with MSVC

In reply to Andre Muezerie

From: Tyler Retzlaff <[email protected]>

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

---
 drivers/crypto/mlx5/mlx5_crypto.h     | 2 ++
 drivers/crypto/mlx5/mlx5_crypto_gcm.c | 1 +
 2 files changed, 3 insertions(+)
drivers/crypto/mlx5/mlx5_crypto.h +2 -0
index 547bb490e2..80a7a38f17 100644
@@ -32,6 +32,7 @@ enum mlx5_crypto_mode {
 	MLX5_CRYPTO_IPSEC_OPT,
 };
 
+__rte_msvc_pack
 struct mlx5_crypto_ipsec_mem {
 	uint8_t mem[MLX5_CRYPTO_GCM_IPSEC_IV_SIZE];
 } __rte_packed;
@@ -108,6 +109,7 @@ struct mlx5_crypto_devarg_params {
 	enum mlx5_crypto_mode crypto_mode;
 };
 
+__rte_msvc_pack
 struct mlx5_crypto_session {
 	union {
 		/**< AES-XTS configuration. */
drivers/crypto/mlx5/mlx5_crypto_gcm.c +1 -0
index cd21605bd2..005be4d4bf 100644
@@ -62,6 +62,7 @@ struct mlx5_crypto_gcm_data {
 	uint32_t dst_mkey;
 };
 
+__rte_msvc_pack
 struct mlx5_crypto_gcm_tag_cpy_info {
 	void *digest;
 	uint8_t tag_len;
Signature · 1 line
2.47.0.vfs.0.3
#102 lore raw

v6 cover fix packing of structs when building with MSVC

In reply to Tyler Retzlaff

MSVC struct packing is not compatible with GCC. Provide a macro (__rte_packed_begin) that can be used to push existing pack value and sets packing to 1-byte. The existing __rte_packed macro is replaced with __rte_packed_end and restores the pack value prior to the push.

Instead of providing macros exclusively for MSVC and for GCC, 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.

Macro __rte_packed is removed and the two new macros represent the new way to enable packing in the DPDK code.

Script checkpatches.sh was enhanced to ensure __rte_packed_begin and __rte_packed_end show up in pairs when checking patches.

If as a part of review maintainers identify structs they believe don't require packing so long as they are explicitly identified I'll remove the __rte_packed as a part of this series.

v6:
* replace __rte_msvc_pack with __rte_packed_begin
* replace __rte_packed with __rte_packed_end
* update checkpatches.sh to ensure __rte_packed_begin and __rte_packed_end are used in pairs
* remove __rte_packed

v5:
* rebase on top of latest main

v4:
* add another missing __rte_msvc_pack to crypto/mlx5 patch
* correct commit message for duplicated packing packing in crypto/mlx5 patch

v3:
* add missing __rte_msvc_pack to crypto/mlx5
* fix commit messages to reference __rte_msvc_pack macro instead

    of __rte_msvc_pushpack(1)

v2:
* app/testpmd, remove packing from simple_gre_hdr
* net/iavf, remove packing from iavf_ipsec_crypto_pkt_metadata, simple_gre_hdr
* examples, remove packing from pkt_key_qinq, pkt_key_ipv4_5tuple,

    pkt_key_ipv6_5tuple, pkt_key_ipv4_addr, pkt_key_ipv6_addr

* eal, remove packing from rte_config, __rte_trace_stream_header

Andre Muezerie (30):
devtools: check packed attributes eal/include: add new packing macros app/test-pmd: remove unnecessary packed attributes app/test: replace packed attributes doc/guides: replace packed attributes drivers/baseband: replace packed attributes drivers/bus: replace packed attributes drivers/common: replace packed attributes drivers/compress: replace packed attributes drivers/crypto: replace packed attributes drivers/dma: replace packed attributes drivers/event: replace packed attributes drivers/mempool: replace packed attributes drivers/net: replace packed attributes drivers/raw: replace packed attributes drivers/regex: replace packed attributes drivers/vdpa: replace packed attributes examples/common: replace packed attributes examples/ip-pipeline: remove packed attributes examples/ipsec_secgw: replace packed attributes examples/l3fwd-power: replace packed attributes examples/l3fwd: replace packed attributes examples/ptpclient: replace packed attributes examples/vhost_blk: replace packed attributes lib/eal: replace packed attributes lib/ipsec: replace packed attributes lib/net: replace packed attributes lib/pipeline: replace packed attributes lib/vhost: replace packed attributes lib/eal: remove __rte_packed

 app/test-pmd/csumonly.c                       |    2 +-
 app/test/test_efd.c                           |    3 +-
 app/test/test_hash.c                          |    3 +-
 app/test/test_member.c                        |    3 +-
 devtools/checkpatches.sh                      |   23 +
 doc/guides/nics/ark.rst                       |    3 +-
 .../prog_guide/packet_classif_access_ctrl.rst |    3 +-
 drivers/baseband/acc/acc_common.h             |   59 +-
 drivers/baseband/fpga_5gnr_fec/agx100_pmd.h   |   16 +-
 .../baseband/fpga_5gnr_fec/fpga_5gnr_fec.h    |    4 +-
 drivers/baseband/fpga_5gnr_fec/vc_5gnr_pmd.h  |    8 +-
 drivers/baseband/fpga_lte_fec/fpga_lte_fec.c  |   12 +-
 drivers/baseband/la12xx/bbdev_la12xx_ipc.h    |   32 +-
 drivers/bus/dpaa/include/fsl_bman.h           |   15 +-
 drivers/bus/dpaa/include/fsl_fman.h           |    4 +-
 drivers/bus/dpaa/include/fsl_qman.h           |  158 +-
 drivers/bus/ifpga/bus_ifpga_driver.h          |    8 +-
 drivers/bus/vmbus/rte_vmbus_reg.h             |  108 +-
 drivers/common/cnxk/hw/sdp.h                  |    4 +-
 drivers/common/cnxk/roc_npc.h                 |   16 +-
 drivers/common/cnxk/roc_npc_mcam_dump.c       |    4 +-
 drivers/common/cnxk/roc_platform.h            |    3 +-
 drivers/common/dpaax/compat.h                 |    3 -
 drivers/common/iavf/iavf_osdep.h              |    8 +-
 drivers/common/iavf/virtchnl_inline_ipsec.h   |   44 +-
 drivers/common/idpf/base/idpf_osdep.h         |    8 +-
 drivers/common/mlx5/mlx5_common_mr.h          |   12 +-
 drivers/common/mlx5/mlx5_common_utils.h       |    3 +-
 drivers/common/mlx5/mlx5_prm.h                |   90 +-
 drivers/common/qat/qat_adf/icp_qat_fw_la.h    |    8 +-
 drivers/common/qat/qat_common.h               |    8 +-
 drivers/compress/qat/qat_comp.h               |    4 +-
 drivers/crypto/caam_jr/caam_jr.c              |    4 +-
 drivers/crypto/caam_jr/caam_jr_desc.h         |   64 +-
 drivers/crypto/caam_jr/caam_jr_hw_specific.h  |   48 +-
 drivers/crypto/dpaa_sec/dpaa_sec.h            |   12 +-
 drivers/crypto/ionic/ionic_crypto_if.h        |   36 +-
 drivers/crypto/mlx5/mlx5_crypto.h             |    6 +-
 drivers/crypto/mlx5/mlx5_crypto_gcm.c         |    3 +-
 drivers/crypto/qat/qat_sym.h                  |    7 +-
 drivers/crypto/qat/qat_sym_session.h          |    4 +-
 drivers/dma/dpaa/dpaa_qdma.h                  |   20 +-
 drivers/dma/dpaa2/dpaa2_qdma.h                |   16 +-
 drivers/dma/ioat/ioat_hw_defs.h               |    3 +-
 drivers/event/octeontx/timvf_evdev.c          |    4 +-
 drivers/event/octeontx/timvf_evdev.h          |   12 +-
 drivers/mempool/octeontx/octeontx_fpavf.c     |   16 +-
 drivers/net/ark/ark_ddm.h                     |    4 +-
 drivers/net/ark/ark_pktchkr.h                 |    8 +-
 drivers/net/ark/ark_pktdir.h                  |    5 +-
 drivers/net/ark/ark_pktgen.h                  |    4 +-
 drivers/net/ark/ark_udm.h                     |    4 +-
 drivers/net/atlantic/hw_atl/hw_atl_utils.h    |  120 +-
 .../net/atlantic/hw_atl/hw_atl_utils_fw2x.c   |    8 +-
 drivers/net/avp/rte_avp_common.h              |   12 +-
 drivers/net/bnxt/bnxt.h                       |    8 +-
 drivers/net/bnxt/hsi_struct_def_dpdk.h        | 3344 ++++++++---------
 drivers/net/bnxt/tf_core/tf_resources.h       |   32 +-
 drivers/net/bnxt/tf_core/v3/tfc_mpc_table.c   |   20 +-
 drivers/net/bonding/rte_eth_bond_8023ad.h     |   32 +-
 drivers/net/cnxk/cn10k_rxtx.h                 |    4 +-
 drivers/net/cnxk/cn20k_rxtx.h                 |    4 +-
 drivers/net/cnxk/cn9k_ethdev.h                |    4 +-
 drivers/net/cnxk/cnxk_rep_msg.h               |   64 +-
 drivers/net/dpaa/dpaa_rxtx.h                  |   28 +-
 drivers/net/dpaa/fmlib/fm_ext.h               |    4 +-
 drivers/net/dpaa2/base/dpaa2_hw_dpni_annot.h  |    4 +-
 drivers/net/dpaa2/dpaa2_recycle.c             |   16 +-
 drivers/net/enic/base/vnic_devcmd.h           |   40 +-
 drivers/net/enic/base/vnic_flowman.h          |  120 +-
 drivers/net/gve/base/gve_desc.h               |   16 +-
 drivers/net/gve/base/gve_desc_dqo.h           |   32 +-
 drivers/net/gve/base/gve_osdep.h              |    3 -
 drivers/net/hns3/hns3_mbx.h                   |    8 +-
 drivers/net/hns3/hns3_rxtx.h                  |    4 +-
 drivers/net/i40e/base/i40e_osdep.h            |    6 +-
 drivers/net/iavf/iavf_ipsec_crypto.h          |    8 +-
 drivers/net/iavf/iavf_rxtx.c                  |    2 +-
 drivers/net/ice/base/ice_osdep.h              |    9 +-
 drivers/net/ionic/ionic_if.h                  |   72 +-
 drivers/net/memif/memif.h                     |   36 +-
 drivers/net/mlx4/mlx4_mr.h                    |   12 +-
 drivers/net/mlx5/hws/mlx5dr.h                 |    3 +-
 drivers/net/mlx5/mlx5.h                       |    3 +-
 drivers/net/mlx5/mlx5_flow.h                  |   12 +-
 drivers/net/mlx5/mlx5_hws_cnt.h               |    3 +-
 drivers/net/mlx5/mlx5_utils.h                 |   12 +-
 drivers/net/netvsc/hn_nvs.h                   |   72 +-
 drivers/net/netvsc/ndis.h                     |    8 +-
 drivers/net/nfp/flower/nfp_flower_cmsg.h      |    4 +-
 drivers/net/nfp/flower/nfp_flower_flow.h      |    4 +-
 drivers/net/nfp/nfd3/nfp_nfd3.h               |    4 +-
 drivers/net/nfp/nfp_rxtx.h                    |    8 +-
 drivers/net/nfp/nfpcore/nfp_nsp.c             |    4 +-
 drivers/net/ntnic/dbsconfig/ntnic_dbsconfig.c |   12 +-
 drivers/net/octeon_ep/otx_ep_mbox.h           |    3 +-
 drivers/net/octeontx/base/octeontx_pki_var.h  |    4 +-
 drivers/net/pfe/pfe_hif.h                     |    4 +-
 drivers/net/virtio/virtio.h                   |    4 +-
 drivers/net/virtio/virtio_cvq.h               |    8 +-
 drivers/net/virtio/virtio_user/vhost_user.c   |    4 +-
 drivers/net/zxdh/zxdh_common.c                |    8 +-
 drivers/net/zxdh/zxdh_msg.h                   |   16 +-
 drivers/net/zxdh/zxdh_pci.h                   |    4 +-
 drivers/net/zxdh/zxdh_queue.h                 |   64 +-
 drivers/net/zxdh/zxdh_rxtx.h                  |    8 +-
 drivers/raw/ifpga/afu_pmd_n3000.h             |    8 +-
 drivers/raw/ifpga/base/opae_hw_api.h          |    4 +-
 drivers/regex/cn9k/cn9k_regexdev.c            |    4 +-
 drivers/regex/mlx5/mlx5_rxp.h                 |   16 +-
 drivers/vdpa/ifc/base/ifcvf.h                 |    4 +-
 drivers/vdpa/mlx5/mlx5_vdpa.h                 |    4 +-
 examples/common/neon/port_group.h             |    4 +-
 examples/ip_pipeline/cli.c                    |   10 +-
 examples/ipsec-secgw/ipsec.h                  |    3 +-
 examples/l3fwd-power/main.c                   |    6 +-
 examples/l3fwd/l3fwd_route.h                  |    6 +-
 examples/ptpclient/ptpclient.c                |   24 +-
 examples/vhost_blk/blk_spec.h                 |    3 +-
 lib/eal/common/eal_private.h                  |    2 +-
 lib/eal/include/rte_common.h                  |    6 +-
 lib/eal/include/rte_memory.h                  |    3 +-
 lib/eal/include/rte_memzone.h                 |    3 +-
 lib/eal/include/rte_trace_point.h             |    2 +-
 lib/eal/x86/include/rte_memcpy.h              |    9 +-
 lib/ipsec/crypto.h                            |   44 +-
 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 +-
 lib/pipeline/rte_table_action.c               |   64 +-
 lib/vhost/vhost_user.h                        |    8 +-
 148 files changed, 2926 insertions(+), 2759 deletions(-)

--
2.34.1

#103 lore raw

PATCH v6 1/30 devtools: check packed attributes

Ensure __rte_packed_begin and __rte_packed_end show up in pairs when checking patches.

---
 devtools/checkpatches.sh | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
devtools/checkpatches.sh +23 -0
index 4a8591be22..d304a84df3 100755
@@ -362,6 +362,21 @@ check_aligned_attributes() { # <patch>
 	return $res
 }
 
+check_packed_attributes() { # <patch>
+	res=0
+
+	begin_count=$(grep '__rte_packed_begin' "$1" | \
+			wc -l)
+	end_count=$(grep '__rte_packed_end' "$1" | \
+			wc -l)
+	if [ $begin_count != $end_count ]; then
+		echo "__rte_packed_begin and __rte_packed_end mismatch. They should always be used in pairs."
+		res=1
+	fi
+
+	return $res
+}
+
 check_release_notes() { # <patch>
 	rel_notes_prefix=doc/guides/rel_notes/release_
 	IFS=. read year month release < VERSION
@@ -479,6 +494,14 @@ check () { # <patch-file> <commit>
 		ret=1
 	fi
 
+	! $verbose || printf '\nChecking packed attributes:\n'
+	report=$(check_packed_attributes "$tmpinput")
+	if [ $? -ne 0 ] ; then
+		$headline_printed || print_headline "$subject"
+		printf '%s\n' "$report"
+		ret=1
+	fi
+
 	! $verbose || printf '\nChecking release notes updates:\n'
 	report=$(check_release_notes "$tmpinput")
 	if [ $? -ne 0 ] ; then
Signature · 1 line
2.34.1
#105 lore raw

PATCH v6 2/30 eal/include: add new packing macros

In reply to Andre Muezerie

MSVC struct packing is not compatible with GCC. Add macro __rte_packed_begin which can be used to push existing pack value and set packing to 1-byte. Add 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.

Macro __rte_packed will be removed in a subsequent patch.

---
 lib/eal/include/rte_common.h | 11 +++++++++++
 1 file changed, 11 insertions(+)
lib/eal/include/rte_common.h +11 -0
index 4d299f2b36..affdcaf3c1 100644
@@ -108,6 +108,17 @@ typedef uint16_t unaligned_uint16_t;
 #define __rte_packed __attribute__((__packed__))
 #endif
 
+/**
+ * Force a structure to be packed
+ */
+#ifdef RTE_TOOLCHAIN_MSVC
+#define __rte_packed_begin __pragma(pack(push, 1))
+#define __rte_packed_end __pragma(pack(pop))
+#else
+#define __rte_packed_begin
+#define __rte_packed_end __attribute__((__packed__))
+#endif
+
 /**
  * Macro to mark a type that is not subject to type-based aliasing rules
  */
Signature · 1 line
2.34.1
author Acked-by on v6 2/30
#106 lore raw

Re: [PATCH v6 02/30] eal/include: add new packing macros

Quoted 10 lines · Andre Muezerie

MSVC struct packing is not compatible with GCC. Add macro __rte_packed_begin which can be used to push existing pack value and set packing to 1-byte. Add 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.

Quoted 4 lines

Macro __rte_packed will be removed in a subsequent patch.

---

#107 lore raw

PATCH v6 3/30 app/test-pmd: remove unnecessary packed attributes

In reply to Andre Muezerie

Removed __rte_packed attribute from structure that is naturally packed already.

---
 app/test-pmd/csumonly.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
app/test-pmd/csumonly.c +1 -1
index 2246c22e8e..d77a140641 100644
@@ -92,7 +92,7 @@ struct testpmd_offload_info {
 struct simple_gre_hdr {
 	uint16_t flags;
 	uint16_t proto;
-} __rte_packed;
+};
 
 static uint16_t
 get_udptcp_checksum(struct rte_mbuf *m, void *l3_hdr, uint16_t l4_off,
Signature · 1 line
2.34.1
#108 lore raw

PATCH v6 4/30 app/test: replace packed attributes

In reply to Andre Muezerie

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.

---
 app/test/test_efd.c    | 3 ++-
 app/test/test_hash.c   | 3 ++-
 app/test/test_member.c | 3 ++-
 3 files changed, 6 insertions(+), 3 deletions(-)
app/test/test_efd.c +2 -1
index 1c0986b9bc..0c4444c764 100644
@@ -33,13 +33,14 @@ test_efd(void)
 static unsigned int test_socket_id;
 
 /* 5-tuple key type */
+__rte_packed_begin
 struct flow_key {
 	uint32_t ip_src;
 	uint32_t ip_dst;
 	uint16_t port_src;
 	uint16_t port_dst;
 	uint8_t proto;
-} __rte_packed;
+} __rte_packed_end;
 
 RTE_LOG_REGISTER(efd_logtype_test, test.efd, INFO);
 
app/test/test_hash.c +2 -1
index 65b9cad93c..6dbd038efd 100644
@@ -79,13 +79,14 @@ static uint32_t hashtest_key_lens[] = {0, 2, 4, 5, 6, 7, 8, 10, 11, 15, 16, 21,
  * Should be packed to avoid holes with potentially
  * undefined content in the middle.
  */
+__rte_packed_begin
 struct flow_key {
 	uint32_t ip_src;
 	uint32_t ip_dst;
 	uint16_t port_src;
 	uint16_t port_dst;
 	uint32_t proto;
-} __rte_packed;
+} __rte_packed_end;
 
 /*
  * Hash function that always returns the same value, to easily test what
app/test/test_member.c +2 -1
index 5a4d2750db..72ea7c239a 100644
@@ -32,13 +32,14 @@ struct rte_member_setsum *setsum_vbf;
 struct rte_member_setsum *setsum_sketch;
 
 /* 5-tuple key type */
+__rte_packed_begin
 struct flow_key {
 	uint32_t ip_src;
 	uint32_t ip_dst;
 	uint16_t port_src;
 	uint16_t port_dst;
 	uint8_t proto;
-} __rte_packed;
+} __rte_packed_end;
 
 /* Set ID Macros for multimatch test usage */
 #define M_MATCH_S 1	/* Not start with 0 since by default 0 means no match */
Signature · 1 line
2.34.1
author Reviewed-by on v6 4/30
#109 lore raw

Re: [PATCH v6 04/30] app/test: replace packed attributes

Quoted 5 lines · Andre Muezerie

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.

Quoted 7 lines

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.

---

#110 lore raw

PATCH v6 5/30 doc/guides: replace packed attributes

In reply to Andre Muezerie

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.

---
 doc/guides/nics/ark.rst                              | 3 ++-
 doc/guides/prog_guide/packet_classif_access_ctrl.rst | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)
doc/guides/nics/ark.rst +2 -1
index a9f6d4cdb8..0cb5460199 100644
@@ -172,10 +172,11 @@ during RX from user meta data coming from FPGA hardware.
    };
 
    /* RX tuser field based on user's hardware */
+   __rte_packed_begin
    struct user_rx_meta {
       uint64_t timestamp;
       uint32_t rss;
-   } __rte_packed;
+   } __rte_packed_end;
 
    /* Create ark_user_extension object for use in other hook functions */
    void *rte_pmd_ark_dev_init(struct rte_eth_dev * dev,
doc/guides/prog_guide/packet_classif_access_ctrl.rst +2 -1
index c8844d0616..55db983a05 100644
@@ -154,6 +154,7 @@ To define classification for the IPv6 2-tuple: <protocol, IPv6 source address> o
 
 .. code-block:: c
 
+    __rte_packed_begin
     struct rte_ipv6_hdr {
         uint32_t vtc_flow;     /* IP version, traffic class & flow label. */
         uint16_t payload_len;  /* IP packet length - includes sizeof(ip_header). */
@@ -161,7 +162,7 @@ To define classification for the IPv6 2-tuple: <protocol, IPv6 source address> o
         uint8_t hop_limits;    /* Hop limits. */
         uint8_t src_addr[16];  /* IP address of source host. */
         uint8_t dst_addr[16];  /* IP address of destination host(s). */
-    } __rte_packed;
+    } __rte_packed_end;
 
 The following array of field definitions can be used:
 
Signature · 1 line
2.34.1
author Acked-by on v6 5/30
#111 lore raw

Re: [PATCH v6 05/30] doc/guides: replace packed attributes

Quoted 5 lines · Andre Muezerie

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.

Quoted 7 lines

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.

---

#112 lore raw

PATCH v6 6/30 drivers/baseband: replace packed attributes

In reply to Andre Muezerie

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.

---
 drivers/baseband/acc/acc_common.h             | 59 +++++++++++--------
 drivers/baseband/fpga_5gnr_fec/agx100_pmd.h   | 16 ++---
 .../baseband/fpga_5gnr_fec/fpga_5gnr_fec.h    |  4 +-
 drivers/baseband/fpga_5gnr_fec/vc_5gnr_pmd.h  |  8 +--
 drivers/baseband/fpga_lte_fec/fpga_lte_fec.c  | 12 ++--
 drivers/baseband/la12xx/bbdev_la12xx_ipc.h    | 32 +++++-----
 6 files changed, 72 insertions(+), 59 deletions(-)
drivers/baseband/acc/acc_common.h +36 -23
index bf218332be..74c6787e4b 100644
@@ -160,6 +160,7 @@ extern int acc_common_logtype;
 	RTE_LOG_LINE(level, ACC_COMMON, __VA_ARGS__)
 
 /* ACC100 DMA Descriptor triplet */
+__rte_packed_begin
 struct acc_dma_triplet {
 	uint64_t address;
 	uint32_t blen:20,
@@ -168,7 +169,7 @@ struct acc_dma_triplet {
 		dma_ext:1,
 		res1:2,
 		blkid:4;
-} __rte_packed;
+} __rte_packed_end;
 
 
 /* ACC100 Queue Manager Enqueue PCI Register */
@@ -183,7 +184,8 @@ union acc_enqueue_reg_fmt {
 };
 
 /* FEC 4G Uplink Frame Control Word */
-struct __rte_packed acc_fcw_td {
+__rte_packed_begin
+struct acc_fcw_td {
 	uint8_t fcw_ver:4,
 		num_maps:4; /* Unused in ACC100 */
 	uint8_t filler:6, /* Unused in ACC100 */
@@ -220,10 +222,11 @@ struct __rte_packed acc_fcw_td {
 				rsrvd4:10;
 		};
 	};
-};
+} __rte_packed_end;
 
 /* FEC 4G Downlink Frame Control Word */
-struct __rte_packed acc_fcw_te {
+__rte_packed_begin
+struct acc_fcw_te {
 	uint16_t k_neg;
 	uint16_t k_pos;
 	uint8_t c_neg;
@@ -251,10 +254,11 @@ struct __rte_packed acc_fcw_te {
 	uint8_t code_block_mode:1,
 		rsrvd8:7;
 	uint64_t rsrvd9;
-};
+} __rte_packed_end;
 
 /* FEC 5GNR Downlink Frame Control Word */
-struct __rte_packed acc_fcw_le {
+__rte_packed_begin
+struct acc_fcw_le {
 	uint32_t FCWversion:4,
 		qm:4,
 		nfiller:11,
@@ -279,10 +283,11 @@ struct __rte_packed acc_fcw_le {
 	uint32_t res6;
 	uint32_t res7;
 	uint32_t res8;
-};
+} __rte_packed_end;
 
 /* FEC 5GNR Uplink Frame Control Word */
-struct __rte_packed acc_fcw_ld {
+__rte_packed_begin
+struct acc_fcw_ld {
 	uint32_t FCWversion:4,
 		qm:4,
 		nfiller:11,
@@ -326,10 +331,11 @@ struct __rte_packed acc_fcw_ld {
 		tb_crc_select:2, /* Not supported in ACC100 */
 		dec_llrclip:2,  /* Not supported in VRB1 */
 		tb_trailer_size:20; /* Not supported in ACC100 */
-};
+} __rte_packed_end;
 
 /* FFT Frame Control Word */
-struct __rte_packed acc_fcw_fft {
+__rte_packed_begin
+struct acc_fcw_fft {
 	uint32_t in_frame_size:16,
 		leading_pad_size:16;
 	uint32_t out_frame_size:16,
@@ -351,10 +357,11 @@ struct __rte_packed acc_fcw_fft {
 		power_shift:4,
 		power_en:1,
 		res:19;
-};
+} __rte_packed_end;
 
 /* FFT Frame Control Word. */
-struct __rte_packed acc_fcw_fft_3 {
+__rte_packed_begin
+struct acc_fcw_fft_3 {
 	uint32_t in_frame_size:16,
 		leading_pad_size:16;
 	uint32_t out_frame_size:16,
@@ -381,11 +388,12 @@ struct __rte_packed acc_fcw_fft_3 {
 	uint16_t cs_theta_0[ACC_MAX_CS];
 	uint32_t cs_theta_d[ACC_MAX_CS];
 	int8_t cs_time_offset[ACC_MAX_CS];
-};
+} __rte_packed_end;
 
 
 /* MLD-TS Frame Control Word */
-struct __rte_packed acc_fcw_mldts {
+__rte_packed_begin
+struct acc_fcw_mldts {
 	uint32_t fcw_version:4,
 		res0:12,
 		nrb:13, /* 1 to 1925 */
@@ -409,7 +417,7 @@ struct __rte_packed acc_fcw_mldts {
 	uint32_t pad2;
 	uint32_t pad3;
 	uint32_t pad4;
-};
+} __rte_packed_end;
 
 /* DMA Response Descriptor */
 union acc_dma_rsp_desc {
@@ -435,7 +443,8 @@ union acc_dma_rsp_desc {
 };
 
 /* DMA Request Descriptor */
-struct __rte_packed acc_dma_req_desc {
+__rte_packed_begin
+struct acc_dma_req_desc {
 	union {
 		struct{
 			uint32_t type:4,
@@ -496,7 +505,7 @@ struct __rte_packed acc_dma_req_desc {
 		};
 		uint64_t pad3[ACC_DMA_DESC_PADDINGS]; /* pad to 64 bits */
 	};
-};
+} __rte_packed_end;
 
 /* ACC100 DMA Descriptor */
 union acc_dma_desc {
@@ -506,6 +515,7 @@ union acc_dma_desc {
 };
 
 /* Union describing Info Ring entry */
+__rte_packed_begin
 union acc_info_ring_data {
 	uint32_t val;
 	struct {
@@ -534,25 +544,28 @@ union acc_info_ring_data {
 		uint32_t loop_vrb2: 1;
 		uint32_t valid_vrb2: 1;
 	};
-} __rte_packed;
+} __rte_packed_end;
 
-struct __rte_packed acc_pad_ptr {
+__rte_packed_begin
+struct acc_pad_ptr {
 	void *op_addr;
 	uint64_t pad1;  /* pad to 64 bits */
-};
+} __rte_packed_end;
 
-struct __rte_packed acc_ptrs {
+__rte_packed_begin
+struct acc_ptrs {
 	struct acc_pad_ptr ptr[ACC_COMPANION_PTRS];
-};
+} __rte_packed_end;
 
 /* Union describing Info Ring entry */
+__rte_packed_begin
 union acc_harq_layout_data {
 	uint32_t val;
 	struct {
 		uint16_t offset;
 		uint16_t size0;
 	};
-} __rte_packed;
+} __rte_packed_end;
 
 /**
  * Structure with details about RTE_BBDEV_EVENT_DEQUEUE event. It's passed to
drivers/baseband/fpga_5gnr_fec/agx100_pmd.h +8 -8
index 5e562376c9..b6ef1d3f20 100644
@@ -49,7 +49,7 @@ enum {
 };
 
 /* AGX100 TX Slice Descriptor. */
-struct __rte_packed agx100_input_slice_desc {
+__rte_packed_begin struct agx100_input_slice_desc {
 	uint32_t input_start_addr_lo;
 	uint32_t input_start_addr_hi;
 	uint32_t input_slice_length:21,
@@ -58,10 +58,10 @@ struct __rte_packed agx100_input_slice_desc {
 		start_of_pkt:1;
 	uint32_t input_slice_time_stamp:31,
 		input_c:1;
-};
+} __rte_packed_end;
 
 /* AGX100 RX Slice Descriptor. */
-struct __rte_packed agx100_output_slice_desc {
+__rte_packed_begin struct agx100_output_slice_desc {
 	uint32_t output_start_addr_lo;
 	uint32_t output_start_addr_hi;
 	uint32_t output_slice_length:21,
@@ -70,10 +70,10 @@ struct __rte_packed agx100_output_slice_desc {
 		start_of_pkt:1;
 	uint32_t output_slice_time_stamp:31,
 		output_c:1;
-};
+} __rte_packed_end;
 
 /* AGX100 DL DMA Encoding Request Descriptor. */
-struct __rte_packed agx100_dma_enc_desc {
+__rte_packed_begin struct agx100_dma_enc_desc {
 	uint32_t done:1, /**< 0: not completed 1: completed. */
 		rsrvd0:17,
 		error_msg:2,
@@ -161,10 +161,10 @@ struct __rte_packed agx100_dma_enc_desc {
 		uint8_t sw_ctxt[AGX100_RING_DESC_LEN_UNIT_BYTES *
 					(AGX100_RING_DESC_ENTRY_LENGTH - 1)];
 	};
-};
+} __rte_packed_end;
 
 /* AGX100 UL DMA Decoding Request Descriptor. */
-struct __rte_packed agx100_dma_dec_desc {
+__rte_packed_begin struct agx100_dma_dec_desc {
 	uint32_t done:1, /**< 0: not completed 1: completed. */
 		tb_crc_pass:1, /**< 0: doesn't pass 1: pass. */
 		cb_crc_all_pass:1, /**< 0: doesn't pass 1: pass. */
@@ -262,7 +262,7 @@ struct __rte_packed agx100_dma_dec_desc {
 		uint8_t sw_ctxt[AGX100_RING_DESC_LEN_UNIT_BYTES *
 					(AGX100_RING_DESC_ENTRY_LENGTH - 1)];
 	};
-};
+} __rte_packed_end;
 
 /* AGX100 DMA Descriptor. */
 union agx100_dma_desc {
drivers/baseband/fpga_5gnr_fec/fpga_5gnr_fec.h +2 -2
index 10a19e4dec..24797b8ef3 100644
@@ -89,7 +89,7 @@ enum {
 };
 
 /* FPGA 5GNR Ring Control Register. */
-struct __rte_packed fpga_5gnr_ring_ctrl_reg {
+__rte_packed_begin struct fpga_5gnr_ring_ctrl_reg {
 	uint64_t ring_base_addr;
 	uint64_t ring_head_addr;
 	uint16_t ring_size:11;
@@ -107,7 +107,7 @@ struct __rte_packed fpga_5gnr_ring_ctrl_reg {
 	uint16_t rsrvd3;
 	uint16_t head_point;
 	uint16_t rsrvd4;
-};
+} __rte_packed_end;
 
 /* Private data structure for each FPGA 5GNR device. */
 struct fpga_5gnr_fec_device {
drivers/baseband/fpga_5gnr_fec/vc_5gnr_pmd.h +4 -4
index 9a488ae8d6..ca05ddd593 100644
@@ -46,7 +46,7 @@ enum {
 };
 
 /* VC 5GNR FPGA FEC DMA Encoding Request Descriptor. */
-struct __rte_packed vc_5gnr_dma_enc_desc {
+__rte_packed_begin struct vc_5gnr_dma_enc_desc {
 	uint32_t done:1,
 		rsrvd0:7,
 		error:4,
@@ -84,10 +84,10 @@ struct __rte_packed vc_5gnr_dma_enc_desc {
 		uint8_t sw_ctxt[VC_5GNR_RING_DESC_LEN_UNIT_BYTES *
 					(VC_5GNR_RING_DESC_ENTRY_LENGTH - 1)];
 	};
-};
+} __rte_packed_end;
 
 /* VC 5GNR FPGA DPC FEC DMA Decoding Request Descriptor. */
-struct __rte_packed vc_5gnr_dma_dec_desc {
+__rte_packed_begin struct vc_5gnr_dma_dec_desc {
 	uint32_t done:1,
 		iter:5,
 		et_pass:1,
@@ -128,7 +128,7 @@ struct __rte_packed vc_5gnr_dma_dec_desc {
 
 		uint32_t sw_ctxt[8 * (VC_5GNR_RING_DESC_ENTRY_LENGTH - 1)];
 	};
-};
+} __rte_packed_end;
 
 /* Vista Creek 5GNR DMA Descriptor. */
 union vc_5gnr_dma_desc {
drivers/baseband/fpga_lte_fec/fpga_lte_fec.c +6 -6
index ed21a18b62..c67027618c 100644
@@ -114,7 +114,7 @@ enum {
 };
 
 /* FPGA LTE FEC DMA Encoding Request Descriptor */
-struct __rte_packed fpga_dma_enc_desc {
+__rte_packed_begin struct fpga_dma_enc_desc {
 	uint32_t done:1,
 		rsrvd0:11,
 		error:4,
@@ -148,10 +148,10 @@ struct __rte_packed fpga_dma_enc_desc {
 		uint8_t sw_ctxt[FPGA_RING_DESC_LEN_UNIT_BYTES *
 					(FPGA_RING_DESC_ENTRY_LENGTH - 1)];
 	};
-};
+} __rte_packed_end;
 
 /* FPGA LTE FEC DMA Decoding Request Descriptor */
-struct __rte_packed fpga_dma_dec_desc {
+__rte_packed_begin struct fpga_dma_dec_desc {
 	uint32_t done:1,
 		iter:5,
 		rsrvd0:2,
@@ -188,7 +188,7 @@ struct __rte_packed fpga_dma_dec_desc {
 
 		uint32_t sw_ctxt[8 * (FPGA_RING_DESC_ENTRY_LENGTH - 1)];
 	};
-};
+} __rte_packed_end;
 
 /* FPGA LTE DMA Descriptor */
 union fpga_dma_desc {
@@ -197,7 +197,7 @@ union fpga_dma_desc {
 };
 
 /* FPGA LTE FEC Ring Control Register */
-struct __rte_packed fpga_ring_ctrl_reg {
+__rte_packed_begin struct fpga_ring_ctrl_reg {
 	uint64_t ring_base_addr;
 	uint64_t ring_head_addr;
 	uint16_t ring_size:11;
@@ -216,7 +216,7 @@ struct __rte_packed fpga_ring_ctrl_reg {
 	uint16_t head_point;
 	uint16_t rsrvd4;
 
-};
+} __rte_packed_end;
 
 /* Private data structure for each FPGA FEC device */
 struct fpga_lte_fec_device {
drivers/baseband/la12xx/bbdev_la12xx_ipc.h +16 -16
index b6a7f677d0..b915a71cca 100644
@@ -93,7 +93,7 @@ typedef struct {
 #define IPC_GET_CI_INDEX(x)	(x & IPC_PI_CI_INDEX_MASK)
 
 /** buffer ring common metadata */
-typedef struct ipc_bd_ring_md {
+typedef __rte_packed_begin struct ipc_bd_ring_md {
 	volatile uint32_t pi;		/**< Producer index and flag (MSB)
 					  *  which flip for each Ring wrapping
 					  */
@@ -102,10 +102,10 @@ typedef struct ipc_bd_ring_md {
 					  */
 	uint32_t ring_size;	/**< depth (Used to roll-over pi/ci) */
 	uint32_t msg_size;	/**< Size of the each buffer */
-} __rte_packed ipc_br_md_t;
+} __rte_packed_end ipc_br_md_t;
 
 /** IPC buffer descriptor */
-typedef struct ipc_buffer_desc {
+typedef __rte_packed_begin struct ipc_buffer_desc {
 	union {
 		uint64_t host_virt;	/**< msg's host virtual address */
 		struct {
@@ -115,9 +115,9 @@ typedef struct ipc_buffer_desc {
 	};
 	uint32_t modem_ptr;	/**< msg's modem physical address */
 	uint32_t len;		/**< msg len */
-} __rte_packed ipc_bd_t;
+} __rte_packed_end ipc_bd_t;
 
-typedef struct ipc_channel {
+typedef __rte_packed_begin struct ipc_channel {
 	uint32_t ch_id;		/**< Channel id */
 	ipc_br_md_t md;			/**< Metadata for BD ring */
 	ipc_bd_t bd_h[IPC_MAX_DEPTH];	/**< Buffer Descriptor on Host */
@@ -134,22 +134,22 @@ typedef struct ipc_channel {
 					  * circular buffer size
 					  */
 	uint32_t host_ipc_params;	/**< Address for host IPC parameters */
-} __rte_packed ipc_ch_t;
+} __rte_packed_end ipc_ch_t;
 
-typedef struct ipc_instance {
+typedef __rte_packed_begin struct ipc_instance {
 	uint32_t instance_id;		/**< instance id, use to init this
 					  * instance by ipc_init API
 					  */
 	uint32_t initialized;		/**< Set in ipc_init */
 	ipc_ch_t ch_list[IPC_MAX_CHANNEL_COUNT];
 		/**< Channel descriptors in this instance */
-} __rte_packed ipc_instance_t;
+} __rte_packed_end ipc_instance_t;
 
-typedef struct ipc_metadata {
+typedef __rte_packed_begin struct ipc_metadata {
 	uint32_t ipc_host_signature; /**< IPC host signature, Set by host/L2 */
 	uint32_t ipc_geul_signature; /**< IPC geul signature, Set by modem */
 	ipc_instance_t instance_list[IPC_MAX_INSTANCE_COUNT];
-} __rte_packed ipc_metadata_t;
+} __rte_packed_end ipc_metadata_t;
 
 typedef struct ipc_channel_us_priv {
 	int32_t		eventfd;
@@ -221,24 +221,24 @@ struct bbdev_ipc_dequeue_op {
  * of the parameters which are also part of Shared BD ring. Read access
  * of these parameters from the host side would not be over PCI.
  */
-typedef struct host_ipc_params {
+typedef __rte_packed_begin struct host_ipc_params {
 	volatile uint32_t pi;
 	volatile uint32_t ci;
 	volatile uint32_t bd_m_modem_ptr[IPC_MAX_DEPTH];
-} __rte_packed host_ipc_params_t;
+} __rte_packed_end host_ipc_params_t;
 
-struct hif_ipc_regs {
+__rte_packed_begin struct hif_ipc_regs {
 	uint32_t ipc_mdata_offset;
 	uint32_t ipc_mdata_size;
-} __rte_packed;
+} __rte_packed_end;
 
-struct gul_hif {
+__rte_packed_begin struct gul_hif {
 	uint32_t ver;
 	uint32_t hif_ver;
 	uint32_t status;
 	volatile uint32_t host_ready;
 	volatile uint32_t mod_ready;
 	struct hif_ipc_regs ipc_regs;
-} __rte_packed;
+} __rte_packed_end;
 
 #endif
Signature · 1 line
2.34.1
author Reviewed-by on v6 6/30
#113 lore raw

Re: [PATCH v6 06/30] drivers/baseband: replace packed attributes

Quoted 5 lines · Andre Muezerie

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.

Quoted 7 lines

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.

---

#114 lore raw

PATCH v6 7/30 drivers/bus: replace packed attributes

In reply to Andre Muezerie

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.

---
 drivers/bus/dpaa/include/fsl_bman.h  |  15 ++-
 drivers/bus/dpaa/include/fsl_fman.h  |   4 +-
 drivers/bus/dpaa/include/fsl_qman.h  | 155 ++++++++++++++-------------
 drivers/bus/ifpga/bus_ifpga_driver.h |   8 +-
 drivers/bus/vmbus/rte_vmbus_reg.h    | 108 +++++++++----------
 5 files changed, 150 insertions(+), 140 deletions(-)
drivers/bus/dpaa/include/fsl_bman.h +10 -5
index 34d7eb32ce..9d3fc9f395 100644
@@ -86,6 +86,7 @@ static inline dma_addr_t bm_buf_addr(const struct bm_buffer *buf)
 	} while (0)
 
 /* See 1.5.3.5.4: "Release Command" */
+__rte_packed_begin
 struct bm_rcr_entry {
 	union {
 		struct {
@@ -95,7 +96,7 @@ struct bm_rcr_entry {
 		};
 		struct bm_buffer bufs[8];
 	};
-} __packed;
+} __rte_packed_end;
 #define BM_RCR_VERB_VBIT		0x80
 #define BM_RCR_VERB_CMD_MASK		0x70	/* one of two values; */
 #define BM_RCR_VERB_CMD_BPID_SINGLE	0x20
@@ -104,20 +105,23 @@ struct bm_rcr_entry {
 
 /* See 1.5.3.1: "Acquire Command" */
 /* See 1.5.3.2: "Query Command" */
+__rte_packed_begin
 struct bm_mcc_acquire {
 	u8 bpid;
 	u8 __reserved1[62];
-} __packed;
+} __rte_packed_end;
+__rte_packed_begin
 struct bm_mcc_query {
 	u8 __reserved2[63];
-} __packed;
+} __rte_packed_end;
+__rte_packed_begin
 struct bm_mc_command {
 	u8 __dont_write_directly__verb;
 	union {
 		struct bm_mcc_acquire acquire;
 		struct bm_mcc_query query;
 	};
-} __packed;
+} __rte_packed_end;
 #define BM_MCC_VERB_VBIT		0x80
 #define BM_MCC_VERB_CMD_MASK		0x70	/* where the verb contains; */
 #define BM_MCC_VERB_CMD_ACQUIRE		0x10
@@ -136,6 +140,7 @@ struct bm_pool_state {
 	} as, ds;
 };
 
+__rte_packed_begin
 struct bm_mc_result {
 	union {
 		struct {
@@ -152,7 +157,7 @@ struct bm_mc_result {
 		} acquire;
 		struct bm_pool_state query;
 	};
-} __packed;
+} __rte_packed_end;
 #define BM_MCR_VERB_VBIT		0x80
 #define BM_MCR_VERB_CMD_MASK		BM_MCC_VERB_CMD_MASK
 #define BM_MCR_VERB_CMD_ACQUIRE		BM_MCC_VERB_CMD_ACQUIRE
drivers/bus/dpaa/include/fsl_fman.h +2 -2
index 5a9750ad0c..513d14cced 100644
@@ -12,7 +12,7 @@
 /* Status field in FD is updated on Rx side by FMAN with following information.
  * Refer to field description in FM BG.
  */
-struct fm_status_t {
+__rte_packed_begin struct fm_status_t {
 	unsigned int reserved0:3;
 	unsigned int dcl4c:1; /* Don't Check L4 Checksum */
 	unsigned int reserved1:1;
@@ -38,7 +38,7 @@ struct fm_status_t {
 	unsigned int phe:1; /* Header Error during parsing */
 	unsigned int frdr:1; /* Frame Dropped by disabled port */
 	unsigned int reserved5:4;
-} __rte_packed;
+} __rte_packed_end;
 
 /* Set MAC address for a particular interface */
 __rte_internal
drivers/bus/dpaa/include/fsl_qman.h +80 -75

421 lines not on this page · raw message

drivers/bus/ifpga/bus_ifpga_driver.h +4 -4
index af151ffd4b..c292144130 100644
@@ -29,10 +29,10 @@ struct rte_afu_driver;
 
 #define IFPGA_BUS_BITSTREAM_PATH_MAX_LEN 256
 
-struct rte_afu_uuid {
+__rte_packed_begin struct rte_afu_uuid {
 	uint64_t uuid_low;
 	uint64_t uuid_high;
-} __rte_packed;
+} __rte_packed_end;
 
 #define IFPGA_BUS_DEV_PORT_MAX 4
 
@@ -40,10 +40,10 @@ struct rte_afu_uuid {
  * A structure describing an ID for a AFU driver. Each driver provides a
  * table of these IDs for each device that it supports.
  */
-struct rte_afu_id {
+__rte_packed_begin struct rte_afu_id {
 	struct rte_afu_uuid uuid;
 	int      port; /**< port number */
-} __rte_packed;
+} __rte_packed_end;
 
 /**
  * A structure PR (Partial Reconfiguration) configuration AFU driver.
drivers/bus/vmbus/rte_vmbus_reg.h +54 -54

285 lines not on this page · raw message

Signature · 1 line
2.34.1
author Reviewed-by on v6 7/30
#115 lore raw

Re: [PATCH v6 07/30] drivers/bus: replace packed attributes

Quoted 5 lines · Andre Muezerie

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.

Quoted 7 lines

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.

---

#116 lore raw

PATCH v6 8/30 drivers/common: replace packed attributes

In reply to Andre Muezerie

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.

---
 drivers/common/cnxk/hw/sdp.h                |  4 +-
 drivers/common/cnxk/roc_npc.h               | 16 ++--
 drivers/common/cnxk/roc_npc_mcam_dump.c     |  4 +-
 drivers/common/cnxk/roc_platform.h          |  3 +-
 drivers/common/dpaax/compat.h               |  3 -
 drivers/common/iavf/iavf_osdep.h            |  8 +-
 drivers/common/iavf/virtchnl_inline_ipsec.h | 44 +++++-----
 drivers/common/idpf/base/idpf_osdep.h       |  8 +-
 drivers/common/mlx5/mlx5_common_mr.h        | 12 ++-
 drivers/common/mlx5/mlx5_common_utils.h     |  3 +-
 drivers/common/mlx5/mlx5_prm.h              | 90 ++++++++++++++-------
 drivers/common/qat/qat_adf/icp_qat_fw_la.h  |  8 +-
 drivers/common/qat/qat_common.h             |  8 +-
 13 files changed, 122 insertions(+), 89 deletions(-)
drivers/common/cnxk/hw/sdp.h +2 -2
index 686f516097..c5b42c08f6 100644
@@ -156,7 +156,7 @@
 #define SDP_VF_R_OUT_INT_LEVELS_TIMET (32)
 
 /* SDP Instruction Header */
-struct sdp_instr_ih {
+__plt_packed_begin struct sdp_instr_ih {
 	/* Data Len */
 	uint64_t tlen : 16;
 
@@ -177,6 +177,6 @@ struct sdp_instr_ih {
 
 	/* Reserved2 */
 	uint64_t rsvd2 : 1;
-} __plt_packed;
+} __plt_packed_end;
 
 #endif /* __SDP_HW_H_  */
drivers/common/cnxk/roc_npc.h +8 -8
index bf8c65aa9c..4f7247f867 100644
@@ -97,10 +97,10 @@ struct roc_npc_flow_item_eth {
 	uint32_t reserved : 31; /**< Reserved, must be zero. */
 };
 
-struct roc_vlan_hdr {
+__plt_packed_begin struct roc_vlan_hdr {
 	uint16_t vlan_tci; /**< Priority (3) + CFI (1) + Identifier Code (12) */
 	uint16_t eth_proto; /**< Ethernet type of encapsulated frame. */
-} __plt_packed;
+} __plt_packed_end;
 
 struct roc_npc_flow_item_vlan {
 	union {
@@ -115,23 +115,23 @@ struct roc_npc_flow_item_vlan {
 	uint32_t reserved : 31; /**< Reserved, must be zero. */
 };
 
-struct roc_ipv6_hdr {
+__plt_packed_begin struct roc_ipv6_hdr {
 	uint32_t vtc_flow;    /**< IP version, traffic class & flow label. */
 	uint16_t payload_len; /**< IP payload size, including ext. headers */
 	uint8_t proto;	      /**< Protocol, next header. */
 	uint8_t hop_limits;   /**< Hop limits. */
 	uint8_t src_addr[16]; /**< IP address of source host. */
 	uint8_t dst_addr[16]; /**< IP address of destination host(s). */
-} __plt_packed;
+} __plt_packed_end;
 
-struct roc_ipv6_fragment_ext {
+__plt_packed_begin struct roc_ipv6_fragment_ext {
 	uint8_t next_header; /**< Next header type */
 	uint8_t reserved;    /**< Reserved */
 	uint16_t frag_data;  /**< All fragmentation data */
 	uint32_t id;	     /**< Packet ID */
-} __plt_packed;
+} __plt_packed_end;
 
-struct roc_ipv6_routing_ext {
+__plt_packed_begin struct roc_ipv6_routing_ext {
 	uint8_t next_hdr;	/**< Protocol, next header. */
 	uint8_t hdr_len;	/**< Header length. */
 	uint8_t type;		/**< Extension header type. */
@@ -145,7 +145,7 @@ struct roc_ipv6_routing_ext {
 		};
 	};
 	/* Next are 128-bit IPv6 address fields to describe segments. */
-} __plt_packed;
+} __plt_packed_end;
 
 struct roc_flow_item_ipv6_ext {
 	uint8_t next_hdr; /**< Next header. */
drivers/common/cnxk/roc_npc_mcam_dump.c +2 -2
index ebd2dd69c2..ca566d2b44 100644
@@ -35,7 +35,7 @@
 #define NIX_TX_VTAGACT_VTAG1_OP_MASK	 GENMASK(45, 44)
 #define NIX_TX_VTAGACT_VTAG1_DEF_MASK	 GENMASK(57, 48)
 
-struct npc_rx_parse_nibble_s {
+__plt_packed_begin struct npc_rx_parse_nibble_s {
 	uint16_t chan : 3;
 	uint16_t errlev : 1;
 	uint16_t errcode : 2;
@@ -56,7 +56,7 @@ struct npc_rx_parse_nibble_s {
 	uint16_t lgtype : 1;
 	uint16_t lhflags : 2;
 	uint16_t lhtype : 1;
-} __plt_packed;
+} __plt_packed_end;
 
 static const char *const intf_str[] = {
 	"NIX-RX",
drivers/common/cnxk/roc_platform.h +2 -1
index df4f88f288..d6f3ea9acc 100644
@@ -97,7 +97,8 @@
 
 #define __plt_cache_aligned __rte_cache_aligned
 #define __plt_always_inline __rte_always_inline
-#define __plt_packed	    __rte_packed
+#define __plt_packed_begin	__rte_packed_begin
+#define __plt_packed_end	__rte_packed_end
 #define __plt_unused	    __rte_unused
 #define __roc_api	    __rte_internal
 #define plt_iova_t	    rte_iova_t
drivers/common/dpaax/compat.h +0 -3
index 7c8d82c2b2..28bffde2a7 100644
@@ -53,9 +53,6 @@
 #ifndef __always_unused
 #define __always_unused	__rte_unused
 #endif
-#ifndef __packed
-#define __packed	__rte_packed
-#endif
 #ifndef noinline
 #define noinline	__rte_noinline
 #endif
drivers/common/iavf/iavf_osdep.h +4 -4
index 1f2b7889cb..91f77948bb 100644
@@ -158,17 +158,17 @@ do {                                                            \
 } while (0)
 
 /* memory allocation tracking */
-struct iavf_dma_mem {
+__rte_packed_begin struct iavf_dma_mem {
 	void *va;
 	u64 pa;
 	u32 size;
 	const void *zone;
-} __rte_packed;
+} __rte_packed_end;
 
-struct iavf_virt_mem {
+__rte_packed_begin struct iavf_virt_mem {
 	void *va;
 	u32 size;
-} __rte_packed;
+} __rte_packed_end;
 
 #define iavf_allocate_dma_mem(h, m, unused, s, a) \
 			iavf_allocate_dma_mem_d(h, m, s, a)
drivers/common/iavf/virtchnl_inline_ipsec.h +22 -22

153 lines not on this page · raw message

drivers/common/idpf/base/idpf_osdep.h +4 -4
index cf9e553906..a3a232ac7f 100644
@@ -180,17 +180,17 @@ static inline uint64_t idpf_read_addr64(volatile void *addr)
 #define BITS_PER_BYTE       8
 
 /* memory allocation tracking */
-struct idpf_dma_mem {
+__rte_packed_begin struct idpf_dma_mem {
 	void *va;
 	u64 pa;
 	u32 size;
 	const void *zone;
-} __rte_packed;
+} __rte_packed_end;
 
-struct idpf_virt_mem {
+__rte_packed_begin struct idpf_virt_mem {
 	void *va;
 	u32 size;
-} __rte_packed;
+} __rte_packed_end;
 
 #define idpf_malloc(h, s)	rte_zmalloc(NULL, s, 0)
 #define idpf_calloc(h, c, s)	rte_zmalloc(NULL, (c) * (s), 0)
drivers/common/mlx5/mlx5_common_mr.h +8 -4
index a7f1042037..299d38b78b 100644
@@ -49,22 +49,25 @@ struct mlx5_mr {
 };
 
 /* Cache entry for Memory Region. */
+__rte_packed_begin
 struct mr_cache_entry {
 	uintptr_t start; /* Start address of MR. */
 	uintptr_t end; /* End address of MR. */
 	uint32_t lkey; /* rte_cpu_to_be_32(lkey). */
-} __rte_packed;
+} __rte_packed_end;
 
 /* MR Cache table for Binary search. */
+__rte_packed_begin
 struct mlx5_mr_btree {
 	uint32_t len; /* Number of entries. */
 	uint32_t size; /* Total number of entries. */
 	struct mr_cache_entry (*table)[];
-} __rte_packed;
+} __rte_packed_end;
 
 struct mlx5_common_device;
 
 /* Per-queue MR control descriptor. */
+__rte_packed_begin
 struct mlx5_mr_ctrl {
 	uint32_t *dev_gen_ptr; /* Generation number of device to poll. */
 	uint32_t cur_gen; /* Generation number saved to flush caches. */
@@ -72,12 +75,13 @@ struct mlx5_mr_ctrl {
 	uint16_t head; /* Index of the oldest entry in top-half cache. */
 	struct mr_cache_entry cache[MLX5_MR_CACHE_N]; /* Cache for top-half. */
 	struct mlx5_mr_btree cache_bh; /* Cache for bottom-half. */
-} __rte_packed;
+} __rte_packed_end;
 
 LIST_HEAD(mlx5_mr_list, mlx5_mr);
 LIST_HEAD(mlx5_mempool_reg_list, mlx5_mempool_reg);
 
 /* Global per-device MR cache. */
+__rte_packed_begin
 struct mlx5_mr_share_cache {
 	uint32_t dev_gen; /* Generation number to flush local caches. */
 	rte_rwlock_t rwlock; /* MR cache Lock. */
@@ -88,7 +92,7 @@ struct mlx5_mr_share_cache {
 	struct mlx5_mempool_reg_list mempool_reg_list; /* Mempool database. */
 	mlx5_reg_mr_t reg_mr_cb; /* Callback to reg_mr func */
 	mlx5_dereg_mr_t dereg_mr_cb; /* Callback to dereg_mr func */
-} __rte_packed;
+} __rte_packed_end;
 
 /* Multi-Packet RQ buffer header. */
 struct __rte_cache_aligned mlx5_mprq_buf {
drivers/common/mlx5/mlx5_common_utils.h +2 -1
index 9139bc6829..70d9c6d69e 100644
@@ -27,6 +27,7 @@ struct mlx5_list;
  * Structure of the entry in the mlx5 list, user should define its own struct
  * that contains this in order to store the data.
  */
+__rte_packed_begin
 struct mlx5_list_entry {
 	LIST_ENTRY(mlx5_list_entry) next; /* Entry pointers in the list. */
 	alignas(8) RTE_ATOMIC(uint32_t) ref_cnt; /* 0 means, entry is invalid. */
@@ -35,7 +36,7 @@ struct mlx5_list_entry {
 		struct mlx5_list_entry *gentry;
 		uint32_t bucket_idx;
 	};
-} __rte_packed;
+} __rte_packed_end;
 
 struct __rte_cache_aligned mlx5_list_cache {
 	LIST_HEAD(mlx5_list_head, mlx5_list_entry) h;
drivers/common/mlx5/mlx5_prm.h +60 -30

323 lines not on this page · raw message

drivers/common/qat/qat_adf/icp_qat_fw_la.h +4 -4
index fe32b66c50..30a93549cf 100644
@@ -357,7 +357,7 @@ struct icp_qat_fw_cipher_auth_cd_ctrl_hdr {
 #define ICP_QAT_FW_HASH_REQUEST_PARAMETERS_OFFSET 24
 #define ICP_QAT_FW_CIPHER_REQUEST_PARAMETERS_OFFSET (0)
 
-struct icp_qat_fw_la_cipher_req_params {
+__rte_packed_begin struct icp_qat_fw_la_cipher_req_params {
 	uint32_t cipher_offset;
 	uint32_t cipher_length;
 	union {
@@ -372,9 +372,9 @@ struct icp_qat_fw_la_cipher_req_params {
 	uint16_t spc_aad_sz;
 	uint8_t reserved;
 	uint8_t spc_auth_res_sz;
-} __rte_packed;
+} __rte_packed_end;
 
-struct icp_qat_fw_la_auth_req_params {
+__rte_packed_begin struct icp_qat_fw_la_auth_req_params {
 	uint32_t auth_off;
 	uint32_t auth_len;
 	union {
@@ -389,7 +389,7 @@ struct icp_qat_fw_la_auth_req_params {
 	uint8_t resrvd1;
 	uint8_t hash_state_sz;
 	uint8_t auth_res_sz;
-} __rte_packed;
+} __rte_packed_end;
 
 struct icp_qat_fw_la_auth_req_params_resrvd_flds {
 	uint32_t resrvd[ICP_QAT_FW_NUM_LONGWORDS_6];
drivers/common/qat/qat_common.h +4 -4
index 703534dc15..272a799640 100644
@@ -57,11 +57,11 @@ enum qat_svc_list {
 };
 
 /**< Common struct for scatter-gather list operations */
-struct qat_flat_buf {
+__rte_packed_begin struct qat_flat_buf {
 	uint32_t len;
 	uint32_t resrvd;
 	uint64_t addr;
-} __rte_packed;
+} __rte_packed_end;
 
 #define qat_sgl_hdr  struct { \
 	uint64_t resrvd; \
@@ -70,11 +70,11 @@ struct qat_flat_buf {
 }
 
 __extension__
-struct __rte_cache_aligned qat_sgl {
+__rte_packed_begin struct __rte_cache_aligned qat_sgl {
 	qat_sgl_hdr;
 	/* flexible array of flat buffers*/
 	struct qat_flat_buf buffers[0];
-} __rte_packed;
+} __rte_packed_end;
 
 /** Common, i.e. not service-specific, statistics */
 struct qat_common_stats {
Signature · 1 line
2.34.1
author Reviewed-by on v6 8/30
#117 lore raw

Re: [PATCH v6 08/30] drivers/common: replace packed attributes

Quoted 5 lines · Andre Muezerie

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.

Quoted 7 lines

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.

---

#118 lore raw

PATCH v6 9/30 drivers/compress: replace packed attributes

In reply to Andre Muezerie

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.

---
 drivers/compress/qat/qat_comp.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/compress/qat/qat_comp.h +2 -2
index 1da4770b1c..90231ad42a 100644
@@ -50,10 +50,10 @@ struct array_of_ptrs {
 	phys_addr_t pointer[0];
 };
 
-struct __rte_cache_aligned qat_inter_sgl {
+__rte_packed_begin struct __rte_cache_aligned qat_inter_sgl {
 	qat_sgl_hdr;
 	struct qat_flat_buf buffers[QAT_NUM_BUFS_IN_IM_SGL];
-} __rte_packed;
+} __rte_packed_end;
 
 
 struct qat_comp_op_cookie {
Signature · 1 line
2.34.1
author Reviewed-by on v6 9/30
#119 lore raw

Re: [PATCH v6 09/30] drivers/compress: replace packed attributes

Quoted 5 lines · Andre Muezerie

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.

Quoted 7 lines

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.

---

#120 lore raw

PATCH v6 10/30 drivers/crypto: replace packed attributes

In reply to Andre Muezerie

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.

---
 drivers/crypto/caam_jr/caam_jr.c             |  4 +-
 drivers/crypto/caam_jr/caam_jr_desc.h        | 64 ++++++++++----------
 drivers/crypto/caam_jr/caam_jr_hw_specific.h | 48 +++++++--------
 drivers/crypto/dpaa_sec/dpaa_sec.h           | 12 ++--
 drivers/crypto/ionic/ionic_crypto_if.h       | 36 +++++------
 drivers/crypto/mlx5/mlx5_crypto.h            |  6 +-
 drivers/crypto/mlx5/mlx5_crypto_gcm.c        |  3 +-
 drivers/crypto/qat/qat_sym.h                 |  7 ++-
 drivers/crypto/qat/qat_sym_session.h         |  4 +-
 9 files changed, 94 insertions(+), 90 deletions(-)
drivers/crypto/caam_jr/caam_jr.c +2 -2
index 4082b3f422..fedeefdf80 100644
@@ -53,10 +53,10 @@ static enum sec_driver_state_e g_driver_state = SEC_DRIVER_STATE_IDLE;
 static int g_job_rings_no;
 static int g_job_rings_max;
 
-struct sec_outring_entry {
+__rte_packed_begin struct sec_outring_entry {
 	phys_addr_t desc;	/* Pointer to completed descriptor */
 	uint32_t status;	/* Status for completed descriptor */
-} __rte_packed;
+} __rte_packed_end;
 
 /* virtual address conversin when mempool support is available for ctx */
 static inline phys_addr_t
drivers/crypto/caam_jr/caam_jr_desc.h +32 -32

139 lines not on this page · raw message

drivers/crypto/caam_jr/caam_jr_hw_specific.h +24 -24

103 lines not on this page · raw message

drivers/crypto/dpaa_sec/dpaa_sec.h +6 -6
index 64d9e22159..f8b0147845 100644
@@ -62,8 +62,8 @@ enum dpaa_sec_op_type {
 #define DPAA_SEC_MAX_DESC_SIZE  64
 /* code or cmd block to caam */
 struct sec_cdb {
-	struct {
-		union {
+	__rte_packed_begin struct {
+		__rte_packed_begin union {
 			uint32_t word;
 			struct {
 #if RTE_BYTE_ORDER == RTE_BIG_ENDIAN
@@ -76,9 +76,9 @@ struct sec_cdb {
 				uint16_t rsvd63_48;
 #endif
 			} field;
-		} __packed hi;
+		} __rte_packed_end hi;
 
-		union {
+		__rte_packed_begin union {
 			uint32_t word;
 			struct {
 #if RTE_BYTE_ORDER == RTE_BIG_ENDIAN
@@ -101,8 +101,8 @@ struct sec_cdb {
 				unsigned int rsvd31_30:2;
 #endif
 			} field;
-		} __packed lo;
-	} __packed sh_hdr;
+		} __rte_packed_end lo;
+	} __rte_packed_end sh_hdr;
 
 	uint32_t sh_desc[DPAA_SEC_MAX_DESC_SIZE];
 };
drivers/crypto/ionic/ionic_crypto_if.h +18 -18
index ea418f3d4b..eef2b6a6d9 100644
@@ -263,13 +263,13 @@ struct iocpt_lif_setattr_cmd {
 	u8     opcode;
 	u8     attr;
 	__le16 lif_index;
-	union {
+	__rte_packed_begin union {
 		u8	state;
 		char	name[IOCPT_IFNAMSIZ];
 		__le64	features;
 		u8	stats_ctl;
 		u8	rsvd[60];
-	} __rte_packed;
+	} __rte_packed_end;
 };
 
 /**
@@ -283,10 +283,10 @@ struct iocpt_lif_setattr_comp {
 	u8     status;
 	u8     rsvd;
 	__le16 comp_index;
-	union {
+	__rte_packed_begin union {
 		__le64	features;
 		u8	rsvd2[11];
-	} __rte_packed;
+	} __rte_packed_end;
 	u8     color;
 };
 
@@ -316,11 +316,11 @@ struct iocpt_lif_getattr_comp {
 	u8     status;
 	u8     rsvd;
 	__le16 comp_index;
-	union {
+	__rte_packed_begin union {
 		u8	state;
 		__le64	features;
 		u8	rsvd2[11];
-	} __rte_packed;
+	} __rte_packed_end;
 	u8     color;
 };
 
@@ -396,7 +396,7 @@ struct iocpt_q_identify_comp {
  * @cq_ring_base: Completion queue ring base address
  * @sg_ring_base: Scatter/Gather ring base address
  */
-struct iocpt_q_init_cmd {
+__rte_packed_begin struct iocpt_q_init_cmd {
 	u8     opcode;
 	u8     type;
 	__le16 lif_index;
@@ -417,7 +417,7 @@ struct iocpt_q_init_cmd {
 	__le64 cq_ring_base;
 	__le64 sg_ring_base;
 	u8     rsvd2[20];
-} __rte_packed;
+} __rte_packed_end;
 
 /**
  * struct iocpt_q_init_comp - Queue init command completion
@@ -469,7 +469,7 @@ enum iocpt_desc_opcode {
  * @intr_ctx_addr:   Completion interrupt context address
  * @intr_ctx_data:   Completion interrupt context data
  */
-struct iocpt_crypto_desc {
+__rte_packed_begin struct iocpt_crypto_desc {
 	uint8_t  opcode;
 	uint8_t  flags;
 	uint8_t  num_src_dst_sgs;
@@ -481,7 +481,7 @@ struct iocpt_crypto_desc {
 	__le32   session_tag;
 	__le64   intr_ctx_addr;
 	__le64   intr_ctx_data;
-} __rte_packed;
+} __rte_packed_end;
 
 static inline uint8_t iocpt_encode_nsge_src_dst(uint8_t src, uint8_t dst)
 {
@@ -765,14 +765,14 @@ struct iocpt_log_event {
  * @queue_count:    Queue counts per queue-type
  */
 union iocpt_lif_config {
-	struct {
+	__rte_packed_begin struct {
 		u8     state;
 		u8     rsvd[3];
 		char   name[IOCPT_IFNAMSIZ];
 		u8     rsvd2[12];
 		__le64 features;
 		__le32 queue_count[IOCPT_QTYPE_MAX];
-	} __rte_packed;
+	} __rte_packed_end;
 	__le32 words[56];
 };
 
@@ -876,14 +876,14 @@ union iocpt_dev_info_regs {
  * @data:            Opcode-specific side-data
  */
 union iocpt_dev_cmd_regs {
-	struct {
+	__rte_packed_begin struct {
 		u32    doorbell;
 		u32    done;
 		union iocpt_dev_cmd         cmd;
 		union iocpt_dev_cmd_comp    comp;
 		u8     rsvd[48];
 		u32    data[478];
-	} __rte_packed;
+	} __rte_packed_end;
 	u32    words[512];
 };
 
@@ -893,10 +893,10 @@ union iocpt_dev_cmd_regs {
  * @devcmd:          Device command registers
  */
 union iocpt_dev_regs {
-	struct {
+	__rte_packed_begin struct {
 		union iocpt_dev_info_regs info;
 		union iocpt_dev_cmd_regs  devcmd;
-	} __rte_packed;
+	} __rte_packed_end;
 	__le32 words[1024];
 };
 
@@ -971,7 +971,7 @@ union iocpt_dev_identity {
  * @config:             LIF config struct with features, q counts
  */
 union iocpt_lif_identity {
-	struct {
+	__rte_packed_begin struct {
 		__le64 features;
 
 		u8 version;
@@ -980,7 +980,7 @@ union iocpt_lif_identity {
 		__le32 max_nb_sessions;
 		u8 rsvd2[120];
 		union iocpt_lif_config config;
-	} __rte_packed;
+	} __rte_packed_end;
 	__le32 words[90];
 };
 
drivers/crypto/mlx5/mlx5_crypto.h +4 -2
index 547bb490e2..28eef9ef55 100644
@@ -32,9 +32,10 @@ enum mlx5_crypto_mode {
 	MLX5_CRYPTO_IPSEC_OPT,
 };
 
+__rte_packed_begin
 struct mlx5_crypto_ipsec_mem {
 	uint8_t mem[MLX5_CRYPTO_GCM_IPSEC_IV_SIZE];
-} __rte_packed;
+} __rte_packed_end;
 
 struct mlx5_crypto_priv {
 	TAILQ_ENTRY(mlx5_crypto_priv) next;
@@ -108,6 +109,7 @@ struct mlx5_crypto_devarg_params {
 	enum mlx5_crypto_mode crypto_mode;
 };
 
+__rte_packed_begin
 struct mlx5_crypto_session {
 	union {
 		/**< AES-XTS configuration. */
@@ -145,7 +147,7 @@ struct mlx5_crypto_session {
 	/**< Initialisation Vector length. */
 	struct mlx5_crypto_dek *dek; /**< Pointer to dek struct. */
 	uint32_t dek_id; /**< DEK ID */
-} __rte_packed;
+} __rte_packed_end;
 
 struct mlx5_crypto_dek_ctx {
 	struct rte_crypto_sym_xform *xform;
drivers/crypto/mlx5/mlx5_crypto_gcm.c +2 -1
index cd21605bd2..b62e60854a 100644
@@ -62,10 +62,11 @@ struct mlx5_crypto_gcm_data {
 	uint32_t dst_mkey;
 };
 
+__rte_packed_begin
 struct mlx5_crypto_gcm_tag_cpy_info {
 	void *digest;
 	uint8_t tag_len;
-} __rte_packed;
+} __rte_packed_end;
 
 static struct rte_cryptodev_capabilities mlx5_crypto_gcm_caps[] = {
 	{
drivers/crypto/qat/qat_sym.h +4 -3
index eedf5de755..622161ad56 100644
@@ -103,10 +103,10 @@
 
 struct qat_sym_session;
 
-struct __rte_cache_aligned qat_sym_sgl {
+__rte_packed_begin struct __rte_cache_aligned qat_sym_sgl {
 	qat_sgl_hdr;
 	struct qat_flat_buf buffers[QAT_SYM_SGL_MAX_NUMBER];
-} __rte_packed;
+} __rte_packed_end;
 
 struct qat_sym_op_cookie {
 	struct qat_sym_sgl qat_sgl_src;
@@ -116,8 +116,9 @@ struct qat_sym_op_cookie {
 	union {
 		/* Used for Single-Pass AES-GMAC only */
 		struct {
+			__rte_packed_begin
 			alignas(RTE_CACHE_LINE_SIZE) struct icp_qat_hw_cipher_algo_blk cd_cipher
-					__rte_packed;
+					__rte_packed_end;
 			phys_addr_t cd_phys_addr;
 		} spc_gmac;
 	} opt;
drivers/crypto/qat/qat_sym_session.h +2 -2
index f2634774ec..2b85062170 100644
@@ -92,7 +92,7 @@ typedef int (*qat_sym_build_request_t)(void *in_op, struct qat_sym_session *ctx,
 		uint8_t *out_msg, void *op_cookie);
 
 /* Common content descriptor */
-struct __rte_cache_aligned qat_sym_cd {
+__rte_packed_begin struct __rte_cache_aligned qat_sym_cd {
 	struct icp_qat_hw_cipher_algo_blk cipher;
 	union {
 		struct icp_qat_hw_auth_algo_blk hash;
@@ -100,7 +100,7 @@ struct __rte_cache_aligned qat_sym_cd {
 		struct icp_qat_hw_gen3_crc_cd crc_gen3;
 		struct icp_qat_hw_gen4_crc_cd crc_gen4;
 	};
-} __rte_packed;
+} __rte_packed_end;
 
 struct qat_sym_session {
 	enum icp_qat_fw_la_cmd_id qat_cmd;
Signature · 1 line
2.34.1
author Reviewed-by on v6 10/30
#121 lore raw

Re: [PATCH v6 10/30] drivers/crypto: replace packed attributes

Quoted 5 lines · Andre Muezerie

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.

Quoted 7 lines

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.

---

#122 lore raw

PATCH v6 11/30 drivers/dma: replace packed attributes

In reply to Andre Muezerie

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.

---
 drivers/dma/dpaa/dpaa_qdma.h    | 20 ++++++++++----------
 drivers/dma/dpaa2/dpaa2_qdma.h  | 16 ++++++++--------
 drivers/dma/ioat/ioat_hw_defs.h |  3 ++-
 3 files changed, 20 insertions(+), 19 deletions(-)
drivers/dma/dpaa/dpaa_qdma.h +10 -10
index 91eaf1455a..579483ac34 100644
@@ -119,7 +119,7 @@
 	(((fsl_qdma_engine)->block_offset) * (x))
 
 /* qDMA Command Descriptor Formats */
-struct fsl_qdma_comp_cmd_desc {
+__rte_packed_begin struct fsl_qdma_comp_cmd_desc {
 	uint8_t status;
 	uint32_t rsv0:22;
 	uint32_t ser:1;
@@ -132,9 +132,9 @@ struct fsl_qdma_comp_cmd_desc {
 	uint8_t queue:3;
 	uint8_t rsv4:3;
 	uint8_t dd:2;
-} __rte_packed;
+} __rte_packed_end;
 
-struct fsl_qdma_comp_sg_desc {
+__rte_packed_begin struct fsl_qdma_comp_sg_desc {
 	uint32_t offset:13;
 	uint32_t rsv0:19;
 	uint32_t length:30;
@@ -143,9 +143,9 @@ struct fsl_qdma_comp_sg_desc {
 	uint32_t addr_lo;
 	uint8_t addr_hi;
 	uint32_t rsv1:24;
-} __rte_packed;
+} __rte_packed_end;
 
-struct fsl_qdma_sdf {
+__rte_packed_begin struct fsl_qdma_sdf {
 	uint32_t rsv0;
 	uint32_t ssd:12;
 	uint32_t sss:12;
@@ -160,9 +160,9 @@ struct fsl_qdma_sdf {
 	uint32_t sqos:3;
 	uint32_t ns:1;
 	uint32_t srttype:4;
-} __rte_packed;
+} __rte_packed_end;
 
-struct fsl_qdma_ddf {
+__rte_packed_begin struct fsl_qdma_ddf {
 	uint32_t rsv0;
 	uint32_t dsd:12;
 	uint32_t dss:12;
@@ -177,7 +177,7 @@ struct fsl_qdma_ddf {
 	uint32_t dqos:3;
 	uint32_t ns:1;
 	uint32_t dwttype:4;
-} __rte_packed;
+} __rte_packed_end;
 
 struct fsl_qdma_df {
 	struct fsl_qdma_sdf sdf;
@@ -186,7 +186,7 @@ struct fsl_qdma_df {
 
 #define FSL_QDMA_SG_MAX_ENTRY 64
 #define FSL_QDMA_MAX_DESC_NUM (FSL_QDMA_SG_MAX_ENTRY * QDMA_QUEUE_SIZE)
-struct fsl_qdma_cmpd_ft {
+__rte_packed_begin struct fsl_qdma_cmpd_ft {
 	struct fsl_qdma_comp_sg_desc desc_buf;
 	struct fsl_qdma_comp_sg_desc desc_sbuf;
 	struct fsl_qdma_comp_sg_desc desc_dbuf;
@@ -197,7 +197,7 @@ struct fsl_qdma_cmpd_ft {
 	uint64_t phy_ssge;
 	uint64_t phy_dsge;
 	uint64_t phy_df;
-} __rte_packed;
+} __rte_packed_end;
 
 #define FSL_QDMA_ERR_REG_STATUS_OFFSET 0xe00
 
drivers/dma/dpaa2/dpaa2_qdma.h +8 -8
index 0fd1debaf8..664304e1ff 100644
@@ -39,7 +39,7 @@
 #define DPAA2_QDMA_BMT_DISABLE 0x0
 
 /** Source/Destination Descriptor */
-struct qdma_sdd {
+__rte_packed_begin struct qdma_sdd {
 	uint32_t rsv;
 	/** Stride configuration */
 	uint32_t stride;
@@ -85,7 +85,7 @@ struct qdma_sdd {
 			uint32_t wrttype:4;
 		} write_cmd;
 	};
-} __rte_packed;
+} __rte_packed_end;
 
 #define QDMA_SG_FMT_SDB	0x0 /* single data buffer */
 #define QDMA_SG_FMT_FDS	0x1 /* frame data section */
@@ -96,7 +96,7 @@ struct qdma_sdd {
 #define QDMA_SG_BMT_ENABLE DPAA2_QDMA_BMT_ENABLE
 #define QDMA_SG_BMT_DISABLE DPAA2_QDMA_BMT_DISABLE
 
-struct qdma_sg_entry {
+__rte_packed_begin struct qdma_sg_entry {
 	uint32_t addr_lo;		/* address 0:31 */
 	uint32_t addr_hi:17;	/* address 32:48 */
 	uint32_t rsv:15;
@@ -122,7 +122,7 @@ struct qdma_sg_entry {
 			uint32_t f:1;
 		} ctrl;
 	};
-} __rte_packed;
+} __rte_packed_end;
 
 struct dpaa2_qdma_rbp {
 	uint32_t use_ultrashort:1;
@@ -213,19 +213,19 @@ enum {
 	DPAA2_QDMA_MAX_SDD
 };
 
-struct qdma_cntx_fle_sdd {
+__rte_packed_begin struct qdma_cntx_fle_sdd {
 	struct qbman_fle fle[DPAA2_QDMA_MAX_FLE];
 	struct qdma_sdd sdd[DPAA2_QDMA_MAX_SDD];
-} __rte_packed;
+} __rte_packed_end;
 
-struct qdma_cntx_sg {
+__rte_packed_begin struct qdma_cntx_sg {
 	struct qdma_cntx_fle_sdd fle_sdd;
 	struct qdma_sg_entry sg_src_entry[RTE_DPAAX_QDMA_JOB_SUBMIT_MAX];
 	struct qdma_sg_entry sg_dst_entry[RTE_DPAAX_QDMA_JOB_SUBMIT_MAX];
 	uint16_t cntx_idx[RTE_DPAAX_QDMA_JOB_SUBMIT_MAX];
 	uint16_t job_nb;
 	uint16_t rsv[3];
-} __rte_packed;
+} __rte_packed_end;
 
 #define DPAA2_QDMA_IDXADDR_FROM_SG_FLAG(flag) \
 	((void *)(uintptr_t)((flag) - ((flag) & RTE_DPAAX_QDMA_SG_IDX_ADDR_MASK)))
drivers/dma/ioat/ioat_hw_defs.h +2 -1
index 11893951f2..e9c3ae236e 100644
@@ -52,6 +52,7 @@ extern "C" {
 #define	IOAT_DMACAP_PQ		(1 << 9)
 #define	IOAT_DMACAP_DMA_DIF	(1 << 10)
 
+__rte_packed_begin
 struct ioat_registers {
 	uint8_t		chancnt;
 	uint8_t		xfercap;
@@ -75,7 +76,7 @@ struct ioat_registers {
 	uint8_t		reserved2[0x8];	/* 0xA0 */
 	uint32_t	chanerr;	/* 0xA8 */
 	uint32_t	chanerrmask;	/* 0xAC */
-} __rte_packed;
+} __rte_packed_end;
 
 #define IOAT_CHANCMD_RESET	0x20
 #define IOAT_CHANCMD_SUSPEND	0x04
Signature · 1 line
2.34.1
author Reviewed-by on v6 11/30
#123 lore raw

Re: [PATCH v6 11/30] drivers/dma: replace packed attributes

Quoted 5 lines · Andre Muezerie

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.

Quoted 7 lines

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.

---

#124 lore raw

PATCH v6 12/30 drivers/event: replace packed attributes

In reply to Andre Muezerie

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.

---
 drivers/event/octeontx/timvf_evdev.c |  4 ++--
 drivers/event/octeontx/timvf_evdev.h | 12 ++++++------
 2 files changed, 8 insertions(+), 8 deletions(-)
drivers/event/octeontx/timvf_evdev.c +2 -2
index 82f17144a6..9339b13941 100644
@@ -9,10 +9,10 @@ RTE_LOG_REGISTER_SUFFIX(otx_logtype_timvf, timer, NOTICE);
 
 static struct rte_eventdev *event_dev;
 
-struct __rte_packed timvf_mbox_dev_info {
+__rte_packed_begin struct timvf_mbox_dev_info {
 	uint64_t ring_active[4];
 	uint64_t clk_freq;
-};
+} __rte_packed_end;
 
 /* Response messages */
 enum {
drivers/event/octeontx/timvf_evdev.h +6 -6
index 44a4ee41c4..0dd3734773 100644
@@ -123,7 +123,7 @@ enum timvf_clk_src {
 };
 
 /* TIM_MEM_BUCKET */
-struct __rte_aligned(8) tim_mem_bucket {
+__rte_packed_begin struct __rte_aligned(8) tim_mem_bucket {
 	uint64_t first_chunk;
 	union {
 		RTE_ATOMIC(uint64_t) w1;
@@ -139,19 +139,19 @@ struct __rte_aligned(8) tim_mem_bucket {
 	};
 	uint64_t current_chunk;
 	uint64_t pad;
-} __rte_packed;
+} __rte_packed_end;
 
-struct tim_mem_entry {
+__rte_packed_begin struct tim_mem_entry {
 	uint64_t w0;
 	uint64_t wqe;
-} __rte_packed;
+} __rte_packed_end;
 
-struct timvf_ctrl_reg {
+__rte_packed_begin struct timvf_ctrl_reg {
 	uint64_t rctrl0;
 	uint64_t rctrl1;
 	uint64_t rctrl2;
 	uint8_t use_pmu;
-} __rte_packed;
+} __rte_packed_end;
 
 struct timvf_ring;
 
Signature · 1 line
2.34.1
author Reviewed-by on v6 12/30
#125 lore raw

Re: [PATCH v6 12/30] drivers/event: replace packed attributes

Quoted 5 lines · Andre Muezerie

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.

Quoted 7 lines

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.

---

#126 lore raw

PATCH v6 13/30 drivers/mempool: replace packed attributes

In reply to Andre Muezerie

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.

---
 drivers/mempool/octeontx/octeontx_fpavf.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/mempool/octeontx/octeontx_fpavf.c +8 -8
index 966fee8bfe..d2eb837c17 100644
@@ -46,20 +46,20 @@ struct octeontx_mbox_fpa_cfg {
 	uint64_t	aura_cfg;
 };
 
-struct __rte_packed gen_req {
+__rte_packed_begin struct gen_req {
 	uint32_t	value;
-};
+} __rte_packed_end;
 
-struct __rte_packed idn_req {
+__rte_packed_begin struct idn_req {
 	uint8_t	domain_id;
-};
+} __rte_packed_end;
 
-struct __rte_packed gen_resp {
+__rte_packed_begin struct gen_resp {
 	uint16_t	domain_id;
 	uint16_t	vfid;
-};
+} __rte_packed_end;
 
-struct __rte_packed dcfg_resp {
+__rte_packed_begin struct dcfg_resp {
 	uint8_t	sso_count;
 	uint8_t	ssow_count;
 	uint8_t	fpa_count;
@@ -67,7 +67,7 @@ struct __rte_packed dcfg_resp {
 	uint8_t	tim_count;
 	uint8_t	net_port_count;
 	uint8_t	virt_port_count;
-};
+} __rte_packed_end;
 
 #define FPA_MAX_POOL	32
 #define FPA_PF_PAGE_SZ	4096
Signature · 1 line
2.34.1
author Reviewed-by on v6 13/30
#127 lore raw

Re: [PATCH v6 13/30] drivers/mempool: replace packed attributes

Quoted 5 lines · Andre Muezerie

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.

Quoted 7 lines

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.

---