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

Message ID 1710968771-16435-8-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>
---
 drivers/dma/ioat/ioat_hw_defs.h | 1 +
 1 file changed, 1 insertion(+)
  

Comments

Bruce Richardson March 21, 2024, 4:13 p.m. UTC | #1
On Wed, Mar 20, 2024 at 02:06:03PM -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>
> ---
>  drivers/dma/ioat/ioat_hw_defs.h | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/dma/ioat/ioat_hw_defs.h b/drivers/dma/ioat/ioat_hw_defs.h
> index dc3493a..6e32807 100644
> --- a/drivers/dma/ioat/ioat_hw_defs.h
> +++ b/drivers/dma/ioat/ioat_hw_defs.h
> @@ -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
  
Tyler Retzlaff March 27, 2024, 10:51 p.m. UTC | #2
On Thu, Mar 21, 2024 at 04:13:32PM +0000, Bruce Richardson wrote:
> On Wed, Mar 20, 2024 at 02:06:03PM -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>
> > ---
> >  drivers/dma/ioat/ioat_hw_defs.h | 1 +
> >  1 file changed, 1 insertion(+)
> > 
> > diff --git a/drivers/dma/ioat/ioat_hw_defs.h b/drivers/dma/ioat/ioat_hw_defs.h
> > index dc3493a..6e32807 100644
> > --- a/drivers/dma/ioat/ioat_hw_defs.h
> > +++ b/drivers/dma/ioat/ioat_hw_defs.h
> > @@ -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.

just eyeballing it i think

        uint32_t        dmacapability;  /* 0x10 */

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

maybe i miscounted though.

> 
> /Bruce
  

Patch

diff --git a/drivers/dma/ioat/ioat_hw_defs.h b/drivers/dma/ioat/ioat_hw_defs.h
index dc3493a..6e32807 100644
--- a/drivers/dma/ioat/ioat_hw_defs.h
+++ b/drivers/dma/ioat/ioat_hw_defs.h
@@ -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;