From 925c862cbc21bd6c40c40f8f8acfda3fc0fcda9b Mon Sep 17 00:00:00 2001 From: Wang Xiao W Date: Thu, 10 Sep 2015 12:38:21 +0800 Subject: [PATCH] fm10k/base: pack TLV overlay structures This patch adds #pragma pack(push, 1) around some structures which are passed via TLV messages. These structures must not be left unpacked as GCC and other compilers are wont to do. Otherwise, we get invalid message responses from the Switch Manager software since it sends 20 bytes and we expect 24. Solaris (and other OS's) are not C99 compliant, so they are not able to use the C99 style #pragma pack() code. Wrap with C99 tag for easy stripping. Signed-off-by: Wang Xiao W --- drivers/net/fm10k/base/fm10k_pf.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/net/fm10k/base/fm10k_pf.h b/drivers/net/fm10k/base/fm10k_pf.h index 1df0a23ca6..44bd193fcb 100644 --- a/drivers/net/fm10k/base/fm10k_pf.h +++ b/drivers/net/fm10k/base/fm10k_pf.h @@ -91,6 +91,16 @@ enum fm10k_pf_tlv_attr_id_v1 { #define FM10K_MSG_UPDATE_PVID_PVID_SHIFT 16 #define FM10K_MSG_UPDATE_PVID_PVID_SIZE 16 +/* The following data structures are overlayed specifically to TLV mailbox + * messages, and must not have gaps between their values. They must line up + * correctly to the TLV definition. + */ +#ifdef C99 +#pragma pack(push, 1) +#else +#pragma pack(1) +#endif /* C99 */ + struct fm10k_mac_update { __le32 mac_lower; __le16 mac_upper; @@ -124,6 +134,12 @@ struct fm10k_swapi_1588_clock_owner { __le16 enabled; }; +#ifdef C99 +#pragma pack(pop) +#else +#pragma pack() +#endif /* C99 */ + #define FM10K_PF_MSG_LPORT_CREATE_HANDLER(func) \ FM10K_MSG_HANDLER(FM10K_PF_MSG_ID_LPORT_CREATE, NULL, func) #define FM10K_PF_MSG_LPORT_DELETE_HANDLER(func) \ -- 2.20.1