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

Message ID 1710968771-16435-14-git-send-email-roretzla@linux.microsoft.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series fix packing of structs when building with MSVC |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

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

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 app/test-pmd/csumonly.c | 1 +
 1 file changed, 1 insertion(+)
  

Comments

Bruce Richardson March 21, 2024, 4:28 p.m. UTC | #1
On Wed, Mar 20, 2024 at 02:06:09PM -0700, Tyler Retzlaff wrote:
> Add __rte_msvc_pushpack(1) to all __rte_packed structs to cause packing
> when building with MSVC.
> 
> Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
> ---
>  app/test-pmd/csumonly.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c
> index 6711dda..638e607 100644
> --- a/app/test-pmd/csumonly.c
> +++ b/app/test-pmd/csumonly.c
> @@ -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
  

Patch

diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c
index 6711dda..638e607 100644
--- a/app/test-pmd/csumonly.c
+++ b/app/test-pmd/csumonly.c
@@ -89,6 +89,7 @@  struct testpmd_offload_info {
 };
 
 /* simplified GRE header */
+__rte_msvc_pack
 struct simple_gre_hdr {
 	uint16_t flags;
 	uint16_t proto;