Skip to content

Commit cca07b0

Browse files
lucacoelhojmberg-intel
authored andcommitted
mac80211: introduce refcount for queue_stop_reasons
Sometimes different vifs may be stopping the queues for the same reason (e.g. when several interfaces are performing a channel switch). Instead of using a bitmask for the reasons, use an integer that holds a refcount instead. In order to keep it backwards compatible, introduce a boolean in some functions that tell us whether the queue stopping should be refcounted or not. For now, use not refcounted for all calls to keep it functionally the same as before. Signed-off-by: Luciano Coelho <luciano.coelho@intel.com> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
1 parent 59f48fe commit cca07b0

10 files changed

Lines changed: 98 additions & 46 deletions

File tree

‎net/mac80211/agg-tx.c‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,13 @@ ieee80211_stop_queue_agg(struct ieee80211_sub_if_data *sdata, int tid)
170170
{
171171
int queue = sdata->vif.hw_queue[ieee80211_ac_from_tid(tid)];
172172

173+
/* we do refcounting here, so don't use the queue reason refcounting */
174+
173175
if (atomic_inc_return(&sdata->local->agg_queue_stop[queue]) == 1)
174176
ieee80211_stop_queue_by_reason(
175177
&sdata->local->hw, queue,
176-
IEEE80211_QUEUE_STOP_REASON_AGGREGATION);
178+
IEEE80211_QUEUE_STOP_REASON_AGGREGATION,
179+
false);
177180
__acquire(agg_queue);
178181
}
179182

@@ -185,7 +188,8 @@ ieee80211_wake_queue_agg(struct ieee80211_sub_if_data *sdata, int tid)
185188
if (atomic_dec_return(&sdata->local->agg_queue_stop[queue]) == 0)
186189
ieee80211_wake_queue_by_reason(
187190
&sdata->local->hw, queue,
188-
IEEE80211_QUEUE_STOP_REASON_AGGREGATION);
191+
IEEE80211_QUEUE_STOP_REASON_AGGREGATION,
192+
false);
189193
__release(agg_queue);
190194
}
191195

‎net/mac80211/cfg.c‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -837,7 +837,8 @@ static int ieee80211_stop_ap(struct wiphy *wiphy, struct net_device *dev)
837837
if (!ieee80211_csa_needs_block_tx(local))
838838
ieee80211_wake_queues_by_reason(&local->hw,
839839
IEEE80211_MAX_QUEUE_MAP,
840-
IEEE80211_QUEUE_STOP_REASON_CSA);
840+
IEEE80211_QUEUE_STOP_REASON_CSA,
841+
false);
841842
mutex_unlock(&local->mtx);
842843

843844
kfree(sdata->u.ap.next_beacon);
@@ -2828,7 +2829,8 @@ static int __ieee80211_csa_finalize(struct ieee80211_sub_if_data *sdata)
28282829
if (!ieee80211_csa_needs_block_tx(local))
28292830
ieee80211_wake_queues_by_reason(&local->hw,
28302831
IEEE80211_MAX_QUEUE_MAP,
2831-
IEEE80211_QUEUE_STOP_REASON_CSA);
2832+
IEEE80211_QUEUE_STOP_REASON_CSA,
2833+
false);
28322834

28332835
return 0;
28342836
}
@@ -3060,7 +3062,8 @@ __ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev,
30603062
if (sdata->csa_block_tx)
30613063
ieee80211_stop_queues_by_reason(&local->hw,
30623064
IEEE80211_MAX_QUEUE_MAP,
3063-
IEEE80211_QUEUE_STOP_REASON_CSA);
3065+
IEEE80211_QUEUE_STOP_REASON_CSA,
3066+
false);
30643067

30653068
if (changed) {
30663069
ieee80211_bss_info_change_notify(sdata, changed);

‎net/mac80211/ieee80211_i.h‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -922,6 +922,8 @@ enum queue_stop_reason {
922922
IEEE80211_QUEUE_STOP_REASON_SKB_ADD,
923923
IEEE80211_QUEUE_STOP_REASON_OFFCHANNEL,
924924
IEEE80211_QUEUE_STOP_REASON_FLUSH,
925+
926+
IEEE80211_QUEUE_STOP_REASONS,
925927
};
926928

927929
#ifdef CONFIG_MAC80211_LEDS
@@ -1018,6 +1020,7 @@ struct ieee80211_local {
10181020
struct workqueue_struct *workqueue;
10191021

10201022
unsigned long queue_stop_reasons[IEEE80211_MAX_QUEUES];
1023+
int q_stop_reasons[IEEE80211_MAX_QUEUES][IEEE80211_QUEUE_STOP_REASONS];
10211024
/* also used to protect ampdu_ac_queue and amdpu_ac_stop_refcnt */
10221025
spinlock_t queue_stop_reason_lock;
10231026

@@ -1715,14 +1718,18 @@ void ieee80211_sta_tx_notify(struct ieee80211_sub_if_data *sdata,
17151718

17161719
void ieee80211_wake_queues_by_reason(struct ieee80211_hw *hw,
17171720
unsigned long queues,
1718-
enum queue_stop_reason reason);
1721+
enum queue_stop_reason reason,
1722+
bool refcounted);
17191723
void ieee80211_stop_queues_by_reason(struct ieee80211_hw *hw,
17201724
unsigned long queues,
1721-
enum queue_stop_reason reason);
1725+
enum queue_stop_reason reason,
1726+
bool refcounted);
17221727
void ieee80211_wake_queue_by_reason(struct ieee80211_hw *hw, int queue,
1723-
enum queue_stop_reason reason);
1728+
enum queue_stop_reason reason,
1729+
bool refcounted);
17241730
void ieee80211_stop_queue_by_reason(struct ieee80211_hw *hw, int queue,
1725-
enum queue_stop_reason reason);
1731+
enum queue_stop_reason reason,
1732+
bool refcounted);
17261733
void ieee80211_propagate_queue_wake(struct ieee80211_local *local, int queue);
17271734
void ieee80211_add_pending_skb(struct ieee80211_local *local,
17281735
struct sk_buff *skb);

‎net/mac80211/iface.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -844,7 +844,8 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
844844
if (!ieee80211_csa_needs_block_tx(local))
845845
ieee80211_wake_queues_by_reason(&local->hw,
846846
IEEE80211_MAX_QUEUE_MAP,
847-
IEEE80211_QUEUE_STOP_REASON_CSA);
847+
IEEE80211_QUEUE_STOP_REASON_CSA,
848+
false);
848849
mutex_unlock(&local->mtx);
849850
sdata_unlock(sdata);
850851

‎net/mac80211/main.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,8 @@ void ieee80211_restart_hw(struct ieee80211_hw *hw)
272272

273273
/* use this reason, ieee80211_reconfig will unblock it */
274274
ieee80211_stop_queues_by_reason(hw, IEEE80211_MAX_QUEUE_MAP,
275-
IEEE80211_QUEUE_STOP_REASON_SUSPEND);
275+
IEEE80211_QUEUE_STOP_REASON_SUSPEND,
276+
false);
276277

277278
/*
278279
* Stop all Rx during the reconfig. We don't want state changes

‎net/mac80211/mlme.c‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -983,7 +983,8 @@ static void ieee80211_chswitch_work(struct work_struct *work)
983983
if (!ieee80211_csa_needs_block_tx(local))
984984
ieee80211_wake_queues_by_reason(&local->hw,
985985
IEEE80211_MAX_QUEUE_MAP,
986-
IEEE80211_QUEUE_STOP_REASON_CSA);
986+
IEEE80211_QUEUE_STOP_REASON_CSA,
987+
false);
987988
mutex_unlock(&local->mtx);
988989

989990
ifmgd->flags &= ~IEEE80211_STA_CSA_RECEIVED;
@@ -1115,7 +1116,8 @@ ieee80211_sta_process_chanswitch(struct ieee80211_sub_if_data *sdata,
11151116
if (sdata->csa_block_tx)
11161117
ieee80211_stop_queues_by_reason(&local->hw,
11171118
IEEE80211_MAX_QUEUE_MAP,
1118-
IEEE80211_QUEUE_STOP_REASON_CSA);
1119+
IEEE80211_QUEUE_STOP_REASON_CSA,
1120+
false);
11191121
mutex_unlock(&local->mtx);
11201122

11211123
if (local->ops->channel_switch) {
@@ -1385,7 +1387,8 @@ void ieee80211_dynamic_ps_disable_work(struct work_struct *work)
13851387

13861388
ieee80211_wake_queues_by_reason(&local->hw,
13871389
IEEE80211_MAX_QUEUE_MAP,
1388-
IEEE80211_QUEUE_STOP_REASON_PS);
1390+
IEEE80211_QUEUE_STOP_REASON_PS,
1391+
false);
13891392
}
13901393

13911394
void ieee80211_dynamic_ps_enable_work(struct work_struct *work)
@@ -1833,7 +1836,8 @@ static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata,
18331836
if (!ieee80211_csa_needs_block_tx(local))
18341837
ieee80211_wake_queues_by_reason(&local->hw,
18351838
IEEE80211_MAX_QUEUE_MAP,
1836-
IEEE80211_QUEUE_STOP_REASON_CSA);
1839+
IEEE80211_QUEUE_STOP_REASON_CSA,
1840+
false);
18371841
mutex_unlock(&local->mtx);
18381842

18391843
sdata->encrypt_headroom = IEEE80211_ENCRYPT_HEADROOM;
@@ -2082,7 +2086,8 @@ static void __ieee80211_disconnect(struct ieee80211_sub_if_data *sdata)
20822086
if (!ieee80211_csa_needs_block_tx(local))
20832087
ieee80211_wake_queues_by_reason(&local->hw,
20842088
IEEE80211_MAX_QUEUE_MAP,
2085-
IEEE80211_QUEUE_STOP_REASON_CSA);
2089+
IEEE80211_QUEUE_STOP_REASON_CSA,
2090+
false);
20862091
mutex_unlock(&local->mtx);
20872092

20882093
cfg80211_tx_mlme_mgmt(sdata->dev, frame_buf,

‎net/mac80211/offchannel.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ void ieee80211_offchannel_stop_vifs(struct ieee80211_local *local)
119119
* before sending nullfunc to enable powersave at the AP.
120120
*/
121121
ieee80211_stop_queues_by_reason(&local->hw, IEEE80211_MAX_QUEUE_MAP,
122-
IEEE80211_QUEUE_STOP_REASON_OFFCHANNEL);
122+
IEEE80211_QUEUE_STOP_REASON_OFFCHANNEL,
123+
false);
123124
ieee80211_flush_queues(local, NULL);
124125

125126
mutex_lock(&local->iflist_mtx);
@@ -182,7 +183,8 @@ void ieee80211_offchannel_return(struct ieee80211_local *local)
182183
mutex_unlock(&local->iflist_mtx);
183184

184185
ieee80211_wake_queues_by_reason(&local->hw, IEEE80211_MAX_QUEUE_MAP,
185-
IEEE80211_QUEUE_STOP_REASON_OFFCHANNEL);
186+
IEEE80211_QUEUE_STOP_REASON_OFFCHANNEL,
187+
false);
186188
}
187189

188190
void ieee80211_handle_roc_started(struct ieee80211_roc_work *roc)

‎net/mac80211/pm.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
3535

3636
ieee80211_stop_queues_by_reason(hw,
3737
IEEE80211_MAX_QUEUE_MAP,
38-
IEEE80211_QUEUE_STOP_REASON_SUSPEND);
38+
IEEE80211_QUEUE_STOP_REASON_SUSPEND,
39+
false);
3940

4041
/* flush out all packets */
4142
synchronize_net();
@@ -74,7 +75,8 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
7475
}
7576
ieee80211_wake_queues_by_reason(hw,
7677
IEEE80211_MAX_QUEUE_MAP,
77-
IEEE80211_QUEUE_STOP_REASON_SUSPEND);
78+
IEEE80211_QUEUE_STOP_REASON_SUSPEND,
79+
false);
7880
return err;
7981
} else if (err > 0) {
8082
WARN_ON(err != 1);

‎net/mac80211/tx.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,8 @@ ieee80211_tx_h_dynamic_ps(struct ieee80211_tx_data *tx)
250250
if (local->hw.conf.flags & IEEE80211_CONF_PS) {
251251
ieee80211_stop_queues_by_reason(&local->hw,
252252
IEEE80211_MAX_QUEUE_MAP,
253-
IEEE80211_QUEUE_STOP_REASON_PS);
253+
IEEE80211_QUEUE_STOP_REASON_PS,
254+
false);
254255
ifmgd->flags &= ~IEEE80211_STA_NULLFUNC_ACKED;
255256
ieee80211_queue_work(&local->hw,
256257
&local->dynamic_ps_disable_work);

0 commit comments

Comments
 (0)