diff options
author | Johannes Berg <johannes.berg@intel.com> | 2011-09-29 10:04:36 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2011-09-30 15:57:19 -0400 |
commit | c2c98fdeb5c897499644eb247285c8e3dacc6450 (patch) | |
tree | aaa9c0f8dd16ab896308470e21a0813041094670 /net/mac80211/sta_info.h | |
parent | deeaee197b0fa694ba6c8f02cdb57b3be7115b4f (diff) |
mac80211: optimise station flags
The flaglock in struct sta_info has long been
something that I wanted to get rid of, this
finally does the conversion to atomic bitops.
The conversion itself is straight-forward in
most places, a few things needed to change a
bit since we can no longer use multiple bits
at the same time.
On x86-64, this is a fairly significant code
size reduction:
text data bss dec hex
427861 23648 1008 452517 6e7a5 before
425383 23648 976 450007 6ddd7 after
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/mac80211/sta_info.h')
-rw-r--r-- | net/mac80211/sta_info.h | 104 |
1 files changed, 34 insertions, 70 deletions
diff --git a/net/mac80211/sta_info.h b/net/mac80211/sta_info.h index 348847a32630..8c8ce05ad26f 100644 --- a/net/mac80211/sta_info.h +++ b/net/mac80211/sta_info.h | |||
@@ -19,7 +19,8 @@ | |||
19 | /** | 19 | /** |
20 | * enum ieee80211_sta_info_flags - Stations flags | 20 | * enum ieee80211_sta_info_flags - Stations flags |
21 | * | 21 | * |
22 | * These flags are used with &struct sta_info's @flags member. | 22 | * These flags are used with &struct sta_info's @flags member, but |
23 | * only indirectly with set_sta_flag() and friends. | ||
23 | * | 24 | * |
24 | * @WLAN_STA_AUTH: Station is authenticated. | 25 | * @WLAN_STA_AUTH: Station is authenticated. |
25 | * @WLAN_STA_ASSOC: Station is associated. | 26 | * @WLAN_STA_ASSOC: Station is associated. |
@@ -53,23 +54,23 @@ | |||
53 | * reply to other uAPSD trigger frames or PS-Poll. | 54 | * reply to other uAPSD trigger frames or PS-Poll. |
54 | */ | 55 | */ |
55 | enum ieee80211_sta_info_flags { | 56 | enum ieee80211_sta_info_flags { |
56 | WLAN_STA_AUTH = 1<<0, | 57 | WLAN_STA_AUTH, |
57 | WLAN_STA_ASSOC = 1<<1, | 58 | WLAN_STA_ASSOC, |
58 | WLAN_STA_PS_STA = 1<<2, | 59 | WLAN_STA_PS_STA, |
59 | WLAN_STA_AUTHORIZED = 1<<3, | 60 | WLAN_STA_AUTHORIZED, |
60 | WLAN_STA_SHORT_PREAMBLE = 1<<4, | 61 | WLAN_STA_SHORT_PREAMBLE, |
61 | WLAN_STA_ASSOC_AP = 1<<5, | 62 | WLAN_STA_ASSOC_AP, |
62 | WLAN_STA_WME = 1<<6, | 63 | WLAN_STA_WME, |
63 | WLAN_STA_WDS = 1<<7, | 64 | WLAN_STA_WDS, |
64 | WLAN_STA_CLEAR_PS_FILT = 1<<9, | 65 | WLAN_STA_CLEAR_PS_FILT, |
65 | WLAN_STA_MFP = 1<<10, | 66 | WLAN_STA_MFP, |
66 | WLAN_STA_BLOCK_BA = 1<<11, | 67 | WLAN_STA_BLOCK_BA, |
67 | WLAN_STA_PS_DRIVER = 1<<12, | 68 | WLAN_STA_PS_DRIVER, |
68 | WLAN_STA_PSPOLL = 1<<13, | 69 | WLAN_STA_PSPOLL, |
69 | WLAN_STA_TDLS_PEER = 1<<15, | 70 | WLAN_STA_TDLS_PEER, |
70 | WLAN_STA_TDLS_PEER_AUTH = 1<<16, | 71 | WLAN_STA_TDLS_PEER_AUTH, |
71 | WLAN_STA_UAPSD = 1<<17, | 72 | WLAN_STA_UAPSD, |
72 | WLAN_STA_SP = 1<<18, | 73 | WLAN_STA_SP, |
73 | }; | 74 | }; |
74 | 75 | ||
75 | #define STA_TID_NUM 16 | 76 | #define STA_TID_NUM 16 |
@@ -212,10 +213,9 @@ struct sta_ampdu_mlme { | |||
212 | * @last_rx_rate_flag: rx status flag of the last data packet | 213 | * @last_rx_rate_flag: rx status flag of the last data packet |
213 | * @lock: used for locking all fields that require locking, see comments | 214 | * @lock: used for locking all fields that require locking, see comments |
214 | * in the header file. | 215 | * in the header file. |
215 | * @flaglock: spinlock for flags accesses | ||
216 | * @drv_unblock_wk: used for driver PS unblocking | 216 | * @drv_unblock_wk: used for driver PS unblocking |
217 | * @listen_interval: listen interval of this station, when we're acting as AP | 217 | * @listen_interval: listen interval of this station, when we're acting as AP |
218 | * @flags: STA flags, see &enum ieee80211_sta_info_flags | 218 | * @_flags: STA flags, see &enum ieee80211_sta_info_flags, do not use directly |
219 | * @ps_tx_buf: buffers (per AC) of frames to transmit to this station | 219 | * @ps_tx_buf: buffers (per AC) of frames to transmit to this station |
220 | * when it leaves power saving state or polls | 220 | * when it leaves power saving state or polls |
221 | * @tx_filtered: buffers (per AC) of frames we already tried to | 221 | * @tx_filtered: buffers (per AC) of frames we already tried to |
@@ -272,7 +272,6 @@ struct sta_info { | |||
272 | struct rate_control_ref *rate_ctrl; | 272 | struct rate_control_ref *rate_ctrl; |
273 | void *rate_ctrl_priv; | 273 | void *rate_ctrl_priv; |
274 | spinlock_t lock; | 274 | spinlock_t lock; |
275 | spinlock_t flaglock; | ||
276 | 275 | ||
277 | struct work_struct drv_unblock_wk; | 276 | struct work_struct drv_unblock_wk; |
278 | 277 | ||
@@ -282,11 +281,8 @@ struct sta_info { | |||
282 | 281 | ||
283 | bool uploaded; | 282 | bool uploaded; |
284 | 283 | ||
285 | /* | 284 | /* use the accessors defined below */ |
286 | * frequently updated, locked with own spinlock (flaglock), | 285 | unsigned long _flags; |
287 | * use the accessors defined below | ||
288 | */ | ||
289 | u32 flags; | ||
290 | 286 | ||
291 | /* | 287 | /* |
292 | * STA powersave frame queues, no more than the internal | 288 | * STA powersave frame queues, no more than the internal |
@@ -370,60 +366,28 @@ static inline enum nl80211_plink_state sta_plink_state(struct sta_info *sta) | |||
370 | return NL80211_PLINK_LISTEN; | 366 | return NL80211_PLINK_LISTEN; |
371 | } | 367 | } |
372 | 368 | ||
373 | static inline void set_sta_flags(struct sta_info *sta, const u32 flags) | 369 | static inline void set_sta_flag(struct sta_info *sta, |
370 | enum ieee80211_sta_info_flags flag) | ||
374 | { | 371 | { |
375 | unsigned long irqfl; | 372 | set_bit(flag, &sta->_flags); |
376 | |||
377 | spin_lock_irqsave(&sta->flaglock, irqfl); | ||
378 | sta->flags |= flags; | ||
379 | spin_unlock_irqrestore(&sta->flaglock, irqfl); | ||
380 | } | 373 | } |
381 | 374 | ||
382 | static inline void clear_sta_flags(struct sta_info *sta, const u32 flags) | 375 | static inline void clear_sta_flag(struct sta_info *sta, |
376 | enum ieee80211_sta_info_flags flag) | ||
383 | { | 377 | { |
384 | unsigned long irqfl; | 378 | clear_bit(flag, &sta->_flags); |
385 | |||
386 | spin_lock_irqsave(&sta->flaglock, irqfl); | ||
387 | sta->flags &= ~flags; | ||
388 | spin_unlock_irqrestore(&sta->flaglock, irqfl); | ||
389 | } | 379 | } |
390 | 380 | ||
391 | static inline u32 test_sta_flags(struct sta_info *sta, const u32 flags) | 381 | static inline int test_sta_flag(struct sta_info *sta, |
382 | enum ieee80211_sta_info_flags flag) | ||
392 | { | 383 | { |
393 | u32 ret; | 384 | return test_bit(flag, &sta->_flags); |
394 | unsigned long irqfl; | ||
395 | |||
396 | spin_lock_irqsave(&sta->flaglock, irqfl); | ||
397 | ret = sta->flags & flags; | ||
398 | spin_unlock_irqrestore(&sta->flaglock, irqfl); | ||
399 | |||
400 | return ret; | ||
401 | } | 385 | } |
402 | 386 | ||
403 | static inline u32 test_and_clear_sta_flags(struct sta_info *sta, | 387 | static inline int test_and_clear_sta_flag(struct sta_info *sta, |
404 | const u32 flags) | 388 | enum ieee80211_sta_info_flags flag) |
405 | { | 389 | { |
406 | u32 ret; | 390 | return test_and_clear_bit(flag, &sta->_flags); |
407 | unsigned long irqfl; | ||
408 | |||
409 | spin_lock_irqsave(&sta->flaglock, irqfl); | ||
410 | ret = sta->flags & flags; | ||
411 | sta->flags &= ~flags; | ||
412 | spin_unlock_irqrestore(&sta->flaglock, irqfl); | ||
413 | |||
414 | return ret; | ||
415 | } | ||
416 | |||
417 | static inline u32 get_sta_flags(struct sta_info *sta) | ||
418 | { | ||
419 | u32 ret; | ||
420 | unsigned long irqfl; | ||
421 | |||
422 | spin_lock_irqsave(&sta->flaglock, irqfl); | ||
423 | ret = sta->flags; | ||
424 | spin_unlock_irqrestore(&sta->flaglock, irqfl); | ||
425 | |||
426 | return ret; | ||
427 | } | 391 | } |
428 | 392 | ||
429 | void ieee80211_assign_tid_tx(struct sta_info *sta, int tid, | 393 | void ieee80211_assign_tid_tx(struct sta_info *sta, int tid, |