Skip to content

Commit b8a31c9

Browse files
Felix Fietkaujmberg-intel
authored andcommitted
ieee80211: mark 802.11 related structs as being 2-byte aligned
Regardless of what header features they use, or if they align the IP header or not, 802.11 packets from all drivers guarantee a 2-byte alignment (and there's a debug WARN_ON in case they don't). Annotate packet structs with __aligned(2) to allow the compiler to use 16-bit load/store operations on platforms with extremely inefficient unaligned access (e.g. MIPS). This reduces code size and improves performance on affected platforms and causes no binary code change on others. Signed-off-by: Felix Fietkau <nbd@openwrt.org> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
1 parent 9a88658 commit b8a31c9

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

‎include/linux/ieee80211.h‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ struct ieee80211_hdr {
213213
u8 addr3[6];
214214
__le16 seq_ctrl;
215215
u8 addr4[6];
216-
} __packed;
216+
} __packed __aligned(2);
217217

218218
struct ieee80211_hdr_3addr {
219219
__le16 frame_control;
@@ -222,7 +222,7 @@ struct ieee80211_hdr_3addr {
222222
u8 addr2[6];
223223
u8 addr3[6];
224224
__le16 seq_ctrl;
225-
} __packed;
225+
} __packed __aligned(2);
226226

227227
struct ieee80211_qos_hdr {
228228
__le16 frame_control;
@@ -232,7 +232,7 @@ struct ieee80211_qos_hdr {
232232
u8 addr3[6];
233233
__le16 seq_ctrl;
234234
__le16 qos_ctrl;
235-
} __packed;
235+
} __packed __aligned(2);
236236

237237
/**
238238
* ieee80211_has_tods - check if IEEE80211_FCTL_TODS is set
@@ -609,7 +609,7 @@ struct ieee80211s_hdr {
609609
__le32 seqnum;
610610
u8 eaddr1[6];
611611
u8 eaddr2[6];
612-
} __packed;
612+
} __packed __aligned(2);
613613

614614
/* Mesh flags */
615615
#define MESH_FLAGS_AE_A4 0x1
@@ -903,7 +903,7 @@ struct ieee80211_mgmt {
903903
} u;
904904
} __packed action;
905905
} u;
906-
} __packed;
906+
} __packed __aligned(2);
907907

908908
/* Supported Rates value encodings in 802.11n-2009 7.3.2.2 */
909909
#define BSS_MEMBERSHIP_SELECTOR_HT_PHY 127
@@ -934,20 +934,20 @@ struct ieee80211_rts {
934934
__le16 duration;
935935
u8 ra[6];
936936
u8 ta[6];
937-
} __packed;
937+
} __packed __aligned(2);
938938

939939
struct ieee80211_cts {
940940
__le16 frame_control;
941941
__le16 duration;
942942
u8 ra[6];
943-
} __packed;
943+
} __packed __aligned(2);
944944

945945
struct ieee80211_pspoll {
946946
__le16 frame_control;
947947
__le16 aid;
948948
u8 bssid[6];
949949
u8 ta[6];
950-
} __packed;
950+
} __packed __aligned(2);
951951

952952
/* TDLS */
953953

0 commit comments

Comments
 (0)