aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211/tx.c
diff options
context:
space:
mode:
authorWojciech Dubowik <Wojciech.Dubowik@neratec.com>2015-06-10 07:06:53 -0400
committerJohannes Berg <johannes.berg@intel.com>2015-07-17 09:38:08 -0400
commite996ec2a4ddb53164262990d33304c429709f687 (patch)
treed3999b77cf0021862ddfe67233f847cb7e74793b /net/mac80211/tx.c
parent1365770248c122dd155351e714b44fe77036292c (diff)
mac80211: avoid unnecessary beacon deref on CSA counter update
The beacon struct is already available in many contexts that are also already in an RCU read-locked section. Avoid that by using the existing beacon struct pointer directly. Signed-off-by: Wojciech Dubowik <Wojciech.Dubowik@neratec.com> [rewrite subject/add commit message] Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'net/mac80211/tx.c')
-rw-r--r--net/mac80211/tx.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index 87b9b4e27d22..7c6832f91dc3 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -3210,6 +3210,16 @@ static void ieee80211_set_csa(struct ieee80211_sub_if_data *sdata,
3210 rcu_read_unlock(); 3210 rcu_read_unlock();
3211} 3211}
3212 3212
3213static u8 __ieee80211_csa_update_counter(struct beacon_data *beacon)
3214{
3215 beacon->csa_current_counter--;
3216
3217 /* the counter should never reach 0 */
3218 WARN_ON_ONCE(!beacon->csa_current_counter);
3219
3220 return beacon->csa_current_counter;
3221}
3222
3213u8 ieee80211_csa_update_counter(struct ieee80211_vif *vif) 3223u8 ieee80211_csa_update_counter(struct ieee80211_vif *vif)
3214{ 3224{
3215 struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif); 3225 struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
@@ -3228,11 +3238,7 @@ u8 ieee80211_csa_update_counter(struct ieee80211_vif *vif)
3228 if (!beacon) 3238 if (!beacon)
3229 goto unlock; 3239 goto unlock;
3230 3240
3231 beacon->csa_current_counter--; 3241 count = __ieee80211_csa_update_counter(beacon);
3232
3233 /* the counter should never reach 0 */
3234 WARN_ON_ONCE(!beacon->csa_current_counter);
3235 count = beacon->csa_current_counter;
3236 3242
3237unlock: 3243unlock:
3238 rcu_read_unlock(); 3244 rcu_read_unlock();
@@ -3332,7 +3338,7 @@ __ieee80211_beacon_get(struct ieee80211_hw *hw,
3332 if (beacon) { 3338 if (beacon) {
3333 if (beacon->csa_counter_offsets[0]) { 3339 if (beacon->csa_counter_offsets[0]) {
3334 if (!is_template) 3340 if (!is_template)
3335 ieee80211_csa_update_counter(vif); 3341 __ieee80211_csa_update_counter(beacon);
3336 3342
3337 ieee80211_set_csa(sdata, beacon); 3343 ieee80211_set_csa(sdata, beacon);
3338 } 3344 }
@@ -3378,7 +3384,7 @@ __ieee80211_beacon_get(struct ieee80211_hw *hw,
3378 3384
3379 if (beacon->csa_counter_offsets[0]) { 3385 if (beacon->csa_counter_offsets[0]) {
3380 if (!is_template) 3386 if (!is_template)
3381 ieee80211_csa_update_counter(vif); 3387 __ieee80211_csa_update_counter(beacon);
3382 3388
3383 ieee80211_set_csa(sdata, beacon); 3389 ieee80211_set_csa(sdata, beacon);
3384 } 3390 }
@@ -3408,7 +3414,7 @@ __ieee80211_beacon_get(struct ieee80211_hw *hw,
3408 * for now we leave it consistent with overall 3414 * for now we leave it consistent with overall
3409 * mac80211's behavior. 3415 * mac80211's behavior.
3410 */ 3416 */
3411 ieee80211_csa_update_counter(vif); 3417 __ieee80211_csa_update_counter(beacon);
3412 3418
3413 ieee80211_set_csa(sdata, beacon); 3419 ieee80211_set_csa(sdata, beacon);
3414 } 3420 }