diff mbox series

[v1,RFC] wifi: rtw88: Validate the eFuse structs

Message ID 20230108213114.547135-1-martin.blumenstingl@googlemail.com
State New
Headers show
Series [v1,RFC] wifi: rtw88: Validate the eFuse structs | expand

Commit Message

Martin Blumenstingl Jan. 8, 2023, 9:31 p.m. UTC
Add static assertions for the PCIe/USB offsets inside the eFuse structs
to ensure that the compiler doesn't add padding anywhere (relevant)
inside the structs.

Suggested-by: Ping-Ke Shih <pkshih@realtek.com>
Suggested-by: David Laight <David.Laight@aculab.com>
Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
---
This is the continuation of my patch from [0] where initially I added
__packed attributes to the eFuse structs. David raised concerns that
this is the "sledgehammer" way of doing things and it can impact
performance.

So this implementation is my understanding of David's suggestion from
[1] (and Ping-Ke also suggested a similar approach for debugging a
size difference I've been seeing with / without __packed).


[0] https://lore.kernel.org/linux-wireless/20221228133547.633797-2-martin.blumenstingl@googlemail.com/
[1] https://lore.kernel.org/linux-wireless/4c4551c787ee4fc9ac40b34707d7365a@AcuMS.aculab.com/


 drivers/net/wireless/realtek/rtw88/rtw8723d.h | 5 +++++
 drivers/net/wireless/realtek/rtw88/rtw8821c.h | 5 +++++
 drivers/net/wireless/realtek/rtw88/rtw8822b.h | 5 +++++
 drivers/net/wireless/realtek/rtw88/rtw8822c.h | 5 +++++
 4 files changed, 20 insertions(+)
diff mbox series

Patch

diff --git a/drivers/net/wireless/realtek/rtw88/rtw8723d.h b/drivers/net/wireless/realtek/rtw88/rtw8723d.h
index a356318a5c15..b1747a22135c 100644
--- a/drivers/net/wireless/realtek/rtw88/rtw8723d.h
+++ b/drivers/net/wireless/realtek/rtw88/rtw8723d.h
@@ -83,6 +83,11 @@  struct rtw8723d_efuse {
 	};
 };
 
+static_assert(offsetof(struct rtw8723d_efuse, e) == 0xd0);
+static_assert(sizeof(struct rtw8723de_efuse) == 14);
+static_assert(offsetof(struct rtw8723d_efuse, u) == 0xd0);
+static_assert(sizeof(struct rtw8723du_efuse) == 59);
+
 extern const struct rtw_chip_info rtw8723d_hw_spec;
 
 /* phy status page0 */
diff --git a/drivers/net/wireless/realtek/rtw88/rtw8821c.h b/drivers/net/wireless/realtek/rtw88/rtw8821c.h
index 1c81260f3a54..70fdc7bf2b64 100644
--- a/drivers/net/wireless/realtek/rtw88/rtw8821c.h
+++ b/drivers/net/wireless/realtek/rtw88/rtw8821c.h
@@ -97,6 +97,11 @@  struct rtw8821c_efuse {
 	};
 };
 
+static_assert(offsetof(struct rtw8821c_efuse, e) == 0xd0);
+static_assert(sizeof(struct rtw8821ce_efuse) == 49);
+static_assert(offsetof(struct rtw8821c_efuse, u) == 0xd0);
+static_assert(sizeof(struct rtw8821cu_efuse) == 304);
+
 static inline void
 _rtw_write32s_mask(struct rtw_dev *rtwdev, u32 addr, u32 mask, u32 data)
 {
diff --git a/drivers/net/wireless/realtek/rtw88/rtw8822b.h b/drivers/net/wireless/realtek/rtw88/rtw8822b.h
index 01d3644e0c94..5d24ce7a8943 100644
--- a/drivers/net/wireless/realtek/rtw88/rtw8822b.h
+++ b/drivers/net/wireless/realtek/rtw88/rtw8822b.h
@@ -97,6 +97,11 @@  struct rtw8822b_efuse {
 	};
 };
 
+static_assert(offsetof(struct rtw8822b_efuse, e) == 0xd0);
+static_assert(sizeof(struct rtw8822be_efuse) == 49);
+static_assert(offsetof(struct rtw8822b_efuse, u) == 0xd0);
+static_assert(sizeof(struct rtw8822bu_efuse) == 304);
+
 static inline void
 _rtw_write32s_mask(struct rtw_dev *rtwdev, u32 addr, u32 mask, u32 data)
 {
diff --git a/drivers/net/wireless/realtek/rtw88/rtw8822c.h b/drivers/net/wireless/realtek/rtw88/rtw8822c.h
index 479d5d769c52..4c5402008387 100644
--- a/drivers/net/wireless/realtek/rtw88/rtw8822c.h
+++ b/drivers/net/wireless/realtek/rtw88/rtw8822c.h
@@ -96,6 +96,11 @@  struct rtw8822c_efuse {
 	};
 };
 
+static_assert(offsetof(struct rtw8822c_efuse, e) == 0x120);
+static_assert(sizeof(struct rtw8822ce_efuse) == 47);
+static_assert(offsetof(struct rtw8822c_efuse, u) == 0x120);
+static_assert(sizeof(struct rtw8822cu_efuse) == 122);
+
 enum rtw8822c_dpk_agc_phase {
 	RTW_DPK_GAIN_CHECK,
 	RTW_DPK_GAIN_LARGE,