Skip to content

Commit 7cca2ac

Browse files
keesjmberg-intel
authored andcommitted
mac80211: aggregation: Convert timers to use timer_setup()
In preparation for unconditionally passing the struct timer_list pointer to all timer callbacks, switch to using the new timer_setup() and from_timer() to pass the timer pointer explicitly. This removes the tid mapping array and expands the tid structures to add a pointer back to the station, along with the tid index itself. Cc: Johannes Berg <[email protected]> Cc: "David S. Miller" <[email protected]> Cc: [email protected] Cc: [email protected] Signed-off-by: Kees Cook <[email protected]> [switch tid variables to u8, the valid range is 0-15 at most, initialize tid_tx->sta/tid properly] Signed-off-by: Johannes Berg <[email protected]>
1 parent 4490526 commit 7cca2ac

File tree

4 files changed

+45
-60
lines changed

4 files changed

+45
-60
lines changed

net/mac80211/agg-rx.c

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -151,21 +151,17 @@ EXPORT_SYMBOL(ieee80211_stop_rx_ba_session);
151151
* After accepting the AddBA Request we activated a timer,
152152
* resetting it after each frame that arrives from the originator.
153153
*/
154-
static void sta_rx_agg_session_timer_expired(unsigned long data)
154+
static void sta_rx_agg_session_timer_expired(struct timer_list *t)
155155
{
156-
/* not an elegant detour, but there is no choice as the timer passes
157-
* only one argument, and various sta_info are needed here, so init
158-
* flow in sta_info_create gives the TID as data, while the timer_to_id
159-
* array gives the sta through container_of */
160-
u8 *ptid = (u8 *)data;
161-
u8 *timer_to_id = ptid - *ptid;
162-
struct sta_info *sta = container_of(timer_to_id, struct sta_info,
163-
timer_to_tid[0]);
156+
struct tid_ampdu_rx *tid_rx_timer =
157+
from_timer(tid_rx_timer, t, session_timer);
158+
struct sta_info *sta = tid_rx_timer->sta;
159+
u8 tid = tid_rx_timer->tid;
164160
struct tid_ampdu_rx *tid_rx;
165161
unsigned long timeout;
166162

167163
rcu_read_lock();
168-
tid_rx = rcu_dereference(sta->ampdu_mlme.tid_rx[*ptid]);
164+
tid_rx = rcu_dereference(sta->ampdu_mlme.tid_rx[tid]);
169165
if (!tid_rx) {
170166
rcu_read_unlock();
171167
return;
@@ -180,21 +176,18 @@ static void sta_rx_agg_session_timer_expired(unsigned long data)
180176
rcu_read_unlock();
181177

182178
ht_dbg(sta->sdata, "RX session timer expired on %pM tid %d\n",
183-
sta->sta.addr, (u16)*ptid);
179+
sta->sta.addr, tid);
184180

185-
set_bit(*ptid, sta->ampdu_mlme.tid_rx_timer_expired);
181+
set_bit(tid, sta->ampdu_mlme.tid_rx_timer_expired);
186182
ieee80211_queue_work(&sta->local->hw, &sta->ampdu_mlme.work);
187183
}
188184

189-
static void sta_rx_agg_reorder_timer_expired(unsigned long data)
185+
static void sta_rx_agg_reorder_timer_expired(struct timer_list *t)
190186
{
191-
u8 *ptid = (u8 *)data;
192-
u8 *timer_to_id = ptid - *ptid;
193-
struct sta_info *sta = container_of(timer_to_id, struct sta_info,
194-
timer_to_tid[0]);
187+
struct tid_ampdu_rx *tid_rx = from_timer(tid_rx, t, reorder_timer);
195188

196189
rcu_read_lock();
197-
ieee80211_release_reorder_timeout(sta, *ptid);
190+
ieee80211_release_reorder_timeout(tid_rx->sta, tid_rx->tid);
198191
rcu_read_unlock();
199192
}
200193

@@ -356,14 +349,12 @@ void ___ieee80211_start_rx_ba_session(struct sta_info *sta,
356349
spin_lock_init(&tid_agg_rx->reorder_lock);
357350

358351
/* rx timer */
359-
setup_deferrable_timer(&tid_agg_rx->session_timer,
360-
sta_rx_agg_session_timer_expired,
361-
(unsigned long)&sta->timer_to_tid[tid]);
352+
timer_setup(&tid_agg_rx->session_timer,
353+
sta_rx_agg_session_timer_expired, TIMER_DEFERRABLE);
362354

363355
/* rx reorder timer */
364-
setup_timer(&tid_agg_rx->reorder_timer,
365-
sta_rx_agg_reorder_timer_expired,
366-
(unsigned long)&sta->timer_to_tid[tid]);
356+
timer_setup(&tid_agg_rx->reorder_timer,
357+
sta_rx_agg_reorder_timer_expired, 0);
367358

368359
/* prepare reordering buffer */
369360
tid_agg_rx->reorder_buf =
@@ -399,6 +390,8 @@ void ___ieee80211_start_rx_ba_session(struct sta_info *sta,
399390
tid_agg_rx->auto_seq = auto_seq;
400391
tid_agg_rx->started = false;
401392
tid_agg_rx->reorder_buf_filtered = 0;
393+
tid_agg_rx->tid = tid;
394+
tid_agg_rx->sta = sta;
402395
status = WLAN_STATUS_SUCCESS;
403396

404397
/* activate it for RX */

net/mac80211/agg-tx.c

Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -422,15 +422,12 @@ int ___ieee80211_stop_tx_ba_session(struct sta_info *sta, u16 tid,
422422
* add Block Ack response will arrive from the recipient.
423423
* If this timer expires sta_addba_resp_timer_expired will be executed.
424424
*/
425-
static void sta_addba_resp_timer_expired(unsigned long data)
425+
static void sta_addba_resp_timer_expired(struct timer_list *t)
426426
{
427-
/* not an elegant detour, but there is no choice as the timer passes
428-
* only one argument, and both sta_info and TID are needed, so init
429-
* flow in sta_info_create gives the TID as data, while the timer_to_id
430-
* array gives the sta through container_of */
431-
u16 tid = *(u8 *)data;
432-
struct sta_info *sta = container_of((void *)data,
433-
struct sta_info, timer_to_tid[tid]);
427+
struct tid_ampdu_tx *tid_tx_timer =
428+
from_timer(tid_tx_timer, t, addba_resp_timer);
429+
struct sta_info *sta = tid_tx_timer->sta;
430+
u8 tid = tid_tx_timer->tid;
434431
struct tid_ampdu_tx *tid_tx;
435432

436433
/* check if the TID waits for addBA response */
@@ -525,21 +522,17 @@ void ieee80211_tx_ba_session_handle_start(struct sta_info *sta, int tid)
525522
* After accepting the AddBA Response we activated a timer,
526523
* resetting it after each frame that we send.
527524
*/
528-
static void sta_tx_agg_session_timer_expired(unsigned long data)
525+
static void sta_tx_agg_session_timer_expired(struct timer_list *t)
529526
{
530-
/* not an elegant detour, but there is no choice as the timer passes
531-
* only one argument, and various sta_info are needed here, so init
532-
* flow in sta_info_create gives the TID as data, while the timer_to_id
533-
* array gives the sta through container_of */
534-
u8 *ptid = (u8 *)data;
535-
u8 *timer_to_id = ptid - *ptid;
536-
struct sta_info *sta = container_of(timer_to_id, struct sta_info,
537-
timer_to_tid[0]);
527+
struct tid_ampdu_tx *tid_tx_timer =
528+
from_timer(tid_tx_timer, t, session_timer);
529+
struct sta_info *sta = tid_tx_timer->sta;
530+
u8 tid = tid_tx_timer->tid;
538531
struct tid_ampdu_tx *tid_tx;
539532
unsigned long timeout;
540533

541534
rcu_read_lock();
542-
tid_tx = rcu_dereference(sta->ampdu_mlme.tid_tx[*ptid]);
535+
tid_tx = rcu_dereference(sta->ampdu_mlme.tid_tx[tid]);
543536
if (!tid_tx || test_bit(HT_AGG_STATE_STOPPING, &tid_tx->state)) {
544537
rcu_read_unlock();
545538
return;
@@ -555,9 +548,9 @@ static void sta_tx_agg_session_timer_expired(unsigned long data)
555548
rcu_read_unlock();
556549

557550
ht_dbg(sta->sdata, "tx session timer expired on %pM tid %d\n",
558-
sta->sta.addr, (u16)*ptid);
551+
sta->sta.addr, tid);
559552

560-
ieee80211_stop_tx_ba_session(&sta->sta, *ptid);
553+
ieee80211_stop_tx_ba_session(&sta->sta, tid);
561554
}
562555

563556
int ieee80211_start_tx_ba_session(struct ieee80211_sta *pubsta, u16 tid,
@@ -670,16 +663,15 @@ int ieee80211_start_tx_ba_session(struct ieee80211_sta *pubsta, u16 tid,
670663
__set_bit(HT_AGG_STATE_WANT_START, &tid_tx->state);
671664

672665
tid_tx->timeout = timeout;
666+
tid_tx->sta = sta;
667+
tid_tx->tid = tid;
673668

674669
/* response timer */
675-
setup_timer(&tid_tx->addba_resp_timer,
676-
sta_addba_resp_timer_expired,
677-
(unsigned long)&sta->timer_to_tid[tid]);
670+
timer_setup(&tid_tx->addba_resp_timer, sta_addba_resp_timer_expired, 0);
678671

679672
/* tx timer */
680-
setup_deferrable_timer(&tid_tx->session_timer,
681-
sta_tx_agg_session_timer_expired,
682-
(unsigned long)&sta->timer_to_tid[tid]);
673+
timer_setup(&tid_tx->session_timer,
674+
sta_tx_agg_session_timer_expired, TIMER_DEFERRABLE);
683675

684676
/* assign a dialog token */
685677
sta->ampdu_mlme.dialog_token_allocator++;

net/mac80211/sta_info.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -379,14 +379,6 @@ struct sta_info *sta_info_alloc(struct ieee80211_sub_if_data *sdata,
379379
if (sta_prepare_rate_control(local, sta, gfp))
380380
goto free_txq;
381381

382-
for (i = 0; i < IEEE80211_NUM_TIDS; i++) {
383-
/*
384-
* timer_to_tid must be initialized with identity mapping
385-
* to enable session_timer's data differentiation. See
386-
* sta_rx_agg_session_timer_expired for usage.
387-
*/
388-
sta->timer_to_tid[i] = i;
389-
}
390382
for (i = 0; i < IEEE80211_NUM_ACS; i++) {
391383
skb_queue_head_init(&sta->ps_tx_buf[i]);
392384
skb_queue_head_init(&sta->tx_filtered[i]);

net/mac80211/sta_info.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,15 +126,19 @@ enum ieee80211_agg_stop_reason {
126126
AGG_STOP_DESTROY_STA,
127127
};
128128

129+
struct sta_info;
130+
129131
/**
130132
* struct tid_ampdu_tx - TID aggregation information (Tx).
131133
*
132134
* @rcu_head: rcu head for freeing structure
133135
* @session_timer: check if we keep Tx-ing on the TID (by timeout value)
134136
* @addba_resp_timer: timer for peer's response to addba request
135137
* @pending: pending frames queue -- use sta's spinlock to protect
138+
* @sta: station we are attached to
136139
* @dialog_token: dialog token for aggregation session
137140
* @timeout: session timeout value to be filled in ADDBA requests
141+
* @tid: TID number
138142
* @state: session state (see above)
139143
* @last_tx: jiffies of last tx activity
140144
* @stop_initiator: initiator of a session stop
@@ -158,6 +162,7 @@ struct tid_ampdu_tx {
158162
struct timer_list session_timer;
159163
struct timer_list addba_resp_timer;
160164
struct sk_buff_head pending;
165+
struct sta_info *sta;
161166
unsigned long state;
162167
unsigned long last_tx;
163168
u16 timeout;
@@ -169,6 +174,7 @@ struct tid_ampdu_tx {
169174
u16 failed_bar_ssn;
170175
bool bar_pending;
171176
bool amsdu;
177+
u8 tid;
172178
};
173179

174180
/**
@@ -181,12 +187,14 @@ struct tid_ampdu_tx {
181187
* @reorder_time: jiffies when skb was added
182188
* @session_timer: check if peer keeps Tx-ing on the TID (by timeout value)
183189
* @reorder_timer: releases expired frames from the reorder buffer.
190+
* @sta: station we are attached to
184191
* @last_rx: jiffies of last rx activity
185192
* @head_seq_num: head sequence number in reordering buffer.
186193
* @stored_mpdu_num: number of MPDUs in reordering buffer
187194
* @ssn: Starting Sequence Number expected to be aggregated.
188195
* @buf_size: buffer size for incoming A-MPDUs
189196
* @timeout: reset timer value (in TUs).
197+
* @tid: TID number
190198
* @rcu_head: RCU head used for freeing this struct
191199
* @reorder_lock: serializes access to reorder buffer, see below.
192200
* @auto_seq: used for offloaded BA sessions to automatically pick head_seq_and
@@ -208,6 +216,7 @@ struct tid_ampdu_rx {
208216
u64 reorder_buf_filtered;
209217
struct sk_buff_head *reorder_buf;
210218
unsigned long *reorder_time;
219+
struct sta_info *sta;
211220
struct timer_list session_timer;
212221
struct timer_list reorder_timer;
213222
unsigned long last_rx;
@@ -216,6 +225,7 @@ struct tid_ampdu_rx {
216225
u16 ssn;
217226
u16 buf_size;
218227
u16 timeout;
228+
u8 tid;
219229
u8 auto_seq:1,
220230
removed:1,
221231
started:1;
@@ -447,7 +457,6 @@ struct ieee80211_sta_rx_stats {
447457
* plus one for non-QoS frames)
448458
* @tid_seq: per-TID sequence numbers for sending to this STA
449459
* @ampdu_mlme: A-MPDU state machine state
450-
* @timer_to_tid: identity mapping to ID timers
451460
* @mesh: mesh STA information
452461
* @debugfs_dir: debug filesystem directory dentry
453462
* @dead: set to true when sta is unlinked
@@ -554,7 +563,6 @@ struct sta_info {
554563
* Aggregation information, locked with lock.
555564
*/
556565
struct sta_ampdu_mlme ampdu_mlme;
557-
u8 timer_to_tid[IEEE80211_NUM_TIDS];
558566

559567
#ifdef CONFIG_MAC80211_DEBUGFS
560568
struct dentry *debugfs_dir;

0 commit comments

Comments
 (0)