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

Message ID 1732668761-5556-6-git-send-email-andremue@linux.microsoft.com (mailing list archive)
State Superseded
Delegated to: David Marchand
Headers
Series fix packing of structs when building with MSVC |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Andre Muezerie Nov. 27, 2024, 12:52 a.m. UTC
MSVC struct packing is not compatible with GCC. Replace macro
__rte_packed with __rte_packed_begin to push existing pack value
and set packing to 1-byte and macro __rte_packed_end to restore
the pack value prior to the push.

Macro __rte_packed_end is deliberately utilized to trigger a
MSVC compiler warning if no existing packing has been pushed allowing
easy identification of locations where the __rte_packed_begin is
missing.

Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
---
 doc/guides/nics/ark.rst                              | 3 ++-
 doc/guides/prog_guide/packet_classif_access_ctrl.rst | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)
  

Comments

Tyler Retzlaff Dec. 5, 2024, 12:12 a.m. UTC | #1
On Tue, Nov 26, 2024 at 04:52:16PM -0800, Andre Muezerie wrote:
> MSVC struct packing is not compatible with GCC. Replace macro
> __rte_packed with __rte_packed_begin to push existing pack value
> and set packing to 1-byte and macro __rte_packed_end to restore
> the pack value prior to the push.
> 
> Macro __rte_packed_end is deliberately utilized to trigger a
> MSVC compiler warning if no existing packing has been pushed allowing
> easy identification of locations where the __rte_packed_begin is
> missing.
> 
> Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
> ---

Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
  

Patch

diff --git a/doc/guides/nics/ark.rst b/doc/guides/nics/ark.rst
index a9f6d4cdb8..0cb5460199 100644
--- a/doc/guides/nics/ark.rst
+++ b/doc/guides/nics/ark.rst
@@ -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,
diff --git a/doc/guides/prog_guide/packet_classif_access_ctrl.rst b/doc/guides/prog_guide/packet_classif_access_ctrl.rst
index c8844d0616..55db983a05 100644
--- a/doc/guides/prog_guide/packet_classif_access_ctrl.rst
+++ b/doc/guides/prog_guide/packet_classif_access_ctrl.rst
@@ -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: