[v9,13/30] drivers/mempool: replace packed attributes

Message ID 1736383715-31703-14-git-send-email-andremue@linux.microsoft.com (mailing list archive)
State Superseded
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

Andre Muezerie Jan. 9, 2025, 12:48 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>
Reviewed-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 drivers/mempool/octeontx/octeontx_fpavf.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
  

Patch

diff --git a/drivers/mempool/octeontx/octeontx_fpavf.c b/drivers/mempool/octeontx/octeontx_fpavf.c
index 966fee8bfe..6cd0fc057f 100644
--- a/drivers/mempool/octeontx/octeontx_fpavf.c
+++ b/drivers/mempool/octeontx/octeontx_fpavf.c
@@ -46,20 +46,20 @@  struct octeontx_mbox_fpa_cfg {
 	uint64_t	aura_cfg;
 };
 
-struct __rte_packed gen_req {
+struct __rte_packed_begin gen_req {
 	uint32_t	value;
-};
+} __rte_packed_end;
 
-struct __rte_packed idn_req {
+struct __rte_packed_begin idn_req {
 	uint8_t	domain_id;
-};
+} __rte_packed_end;
 
-struct __rte_packed gen_resp {
+struct __rte_packed_begin gen_resp {
 	uint16_t	domain_id;
 	uint16_t	vfid;
-};
+} __rte_packed_end;
 
-struct __rte_packed dcfg_resp {
+struct __rte_packed_begin 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