Merge tag 'probes-fixes-v6.16-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git...
[linux-2.6-block.git] / net / mac80211 / agg-rx.c
CommitLineData
d2912cb1 1// SPDX-License-Identifier: GPL-2.0-only
b8695a8f
JB
2/*
3 * HT handling
4 *
5 * Copyright 2003, Jouni Malinen <jkmaline@cc.hut.fi>
6 * Copyright 2002-2005, Instant802 Networks, Inc.
7 * Copyright 2005-2006, Devicescape Software, Inc.
8 * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz>
9 * Copyright 2007, Michael Wu <flamingice@sourmilk.net>
a93e3644 10 * Copyright 2007-2010, Intel Corporation
04c2cf34 11 * Copyright(c) 2015-2017 Intel Deutschland GmbH
3979c8e6 12 * Copyright (C) 2018-2024 Intel Corporation
b8695a8f
JB
13 */
14
73a72a81
JB
15/**
16 * DOC: RX A-MPDU aggregation
17 *
18 * Aggregation on the RX side requires only implementing the
19 * @ampdu_action callback that is invoked to start/stop any
20 * block-ack sessions for RX aggregation.
21 *
22 * When RX aggregation is started by the peer, the driver is
23 * notified via @ampdu_action function, with the
24 * %IEEE80211_AMPDU_RX_START action, and may reject the request
25 * in which case a negative response is sent to the peer, if it
26 * accepts it a positive response is sent.
27 *
28 * While the session is active, the device/driver are required
29 * to de-aggregate frames and pass them up one by one to mac80211,
30 * which will handle the reorder buffer.
31 *
32 * When the aggregation session is stopped again by the peer or
33 * ourselves, the driver's @ampdu_action function will be called
34 * with the action %IEEE80211_AMPDU_RX_STOP. In this case, the
35 * call must not fail.
36 */
37
b8695a8f 38#include <linux/ieee80211.h>
5a0e3ad6 39#include <linux/slab.h>
bc3b2d7f 40#include <linux/export.h>
b8695a8f
JB
41#include <net/mac80211.h>
42#include "ieee80211_i.h"
24487981 43#include "driver-ops.h"
b8695a8f 44
a87f736d
JB
45static void ieee80211_free_tid_rx(struct rcu_head *h)
46{
47 struct tid_ampdu_rx *tid_rx =
48 container_of(h, struct tid_ampdu_rx, rcu_head);
49 int i;
50
51 for (i = 0; i < tid_rx->buf_size; i++)
83eb935e 52 __skb_queue_purge(&tid_rx->reorder_buf[i]);
a87f736d
JB
53 kfree(tid_rx->reorder_buf);
54 kfree(tid_rx->reorder_time);
55 kfree(tid_rx);
56}
57
463559b7
JB
58void __ieee80211_stop_rx_ba_session(struct sta_info *sta, u16 tid,
59 u16 initiator, u16 reason, bool tx)
b8695a8f 60{
d75636ef 61 struct ieee80211_local *local = sta->local;
098a6070 62 struct tid_ampdu_rx *tid_rx;
50ea05ef
SS
63 struct ieee80211_ampdu_params params = {
64 .sta = &sta->sta,
65 .action = IEEE80211_AMPDU_RX_STOP,
66 .tid = tid,
67 .amsdu = false,
68 .timeout = 0,
69 .ssn = 0,
70 };
b8695a8f 71
463559b7 72 lockdep_assert_wiphy(sta->local->hw.wiphy);
098a6070 73
40b275b6 74 tid_rx = rcu_dereference_protected(sta->ampdu_mlme.tid_rx[tid],
463559b7 75 lockdep_is_held(&sta->local->hw.wiphy->mtx));
a87f736d 76
412a6d80 77 if (!test_bit(tid, sta->ampdu_mlme.agg_session_valid))
b8695a8f 78 return;
d75636ef 79
a9b3cd7f 80 RCU_INIT_POINTER(sta->ampdu_mlme.tid_rx[tid], NULL);
412a6d80 81 __clear_bit(tid, sta->ampdu_mlme.agg_session_valid);
b8695a8f 82
bdcbd8e0
JB
83 ht_dbg(sta->sdata,
84 "Rx BA session stop requested for %pM tid %u %s reason: %d\n",
85 sta->sta.addr, tid,
09e0a2fe 86 initiator == WLAN_BACK_RECIPIENT ? "recipient" : "initiator",
bdcbd8e0 87 (int)reason);
b8695a8f 88
50ea05ef 89 if (drv_ampdu_action(local, sta->sdata, &params))
bdcbd8e0 90 sdata_info(sta->sdata,
0a214d3f
JB
91 "HW problem - can not stop rx aggregation for %pM tid %d\n",
92 sta->sta.addr, tid);
b8695a8f 93
b8695a8f 94 /* check if this is a self generated aggregation halt */
53f73c09 95 if (initiator == WLAN_BACK_RECIPIENT && tx)
d75636ef 96 ieee80211_send_delba(sta->sdata, sta->sta.addr,
a7f39f60 97 tid, WLAN_BACK_RECIPIENT, reason);
b8695a8f 98
412a6d80
SS
99 /*
100 * return here in case tid_rx is not assigned - which will happen if
101 * IEEE80211_HW_SUPPORTS_REORDERING_BUFFER is set.
102 */
103 if (!tid_rx)
104 return;
105
8fa7292f 106 timer_delete_sync(&tid_rx->session_timer);
a87f736d 107
788211d8
JB
108 /* make sure ieee80211_sta_reorder_release() doesn't re-arm the timer */
109 spin_lock_bh(&tid_rx->reorder_lock);
110 tid_rx->removed = true;
111 spin_unlock_bh(&tid_rx->reorder_lock);
8fa7292f 112 timer_delete_sync(&tid_rx->reorder_timer);
788211d8 113
a87f736d 114 call_rcu(&tid_rx->rcu_head, ieee80211_free_tid_rx);
b8695a8f
JB
115}
116
f41ccd71
SL
117void ieee80211_stop_rx_ba_session(struct ieee80211_vif *vif, u16 ba_rx_bitmap,
118 const u8 *addr)
119{
120 struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
0a557ed3 121 struct sta_info *sta;
f41ccd71
SL
122 int i;
123
0a557ed3 124 rcu_read_lock();
bc192f89 125 sta = sta_info_get_bss(sdata, addr);
0a557ed3
EP
126 if (!sta) {
127 rcu_read_unlock();
128 return;
129 }
130
5a306f58 131 for (i = 0; i < IEEE80211_NUM_TIDS; i++)
f41ccd71
SL
132 if (ba_rx_bitmap & BIT(i))
133 set_bit(i, sta->ampdu_mlme.tid_rx_stop_requested);
134
1b672118 135 wiphy_work_queue(sta->local->hw.wiphy, &sta->ampdu_mlme.work);
0a557ed3 136 rcu_read_unlock();
f41ccd71
SL
137}
138EXPORT_SYMBOL(ieee80211_stop_rx_ba_session);
139
b8695a8f
JB
140/*
141 * After accepting the AddBA Request we activated a timer,
142 * resetting it after each frame that arrives from the originator.
b8695a8f 143 */
7cca2acd 144static void sta_rx_agg_session_timer_expired(struct timer_list *t)
b8695a8f 145{
41cb0855
IM
146 struct tid_ampdu_rx *tid_rx = timer_container_of(tid_rx, t,
147 session_timer);
d559e303
JB
148 struct sta_info *sta = tid_rx->sta;
149 u8 tid = tid_rx->tid;
12d3952f
FF
150 unsigned long timeout;
151
12d3952f
FF
152 timeout = tid_rx->last_rx + TU_TO_JIFFIES(tid_rx->timeout);
153 if (time_is_after_jiffies(timeout)) {
154 mod_timer(&tid_rx->session_timer, timeout);
155 return;
156 }
b8695a8f 157
0a214d3f 158 ht_dbg(sta->sdata, "RX session timer expired on %pM tid %d\n",
7cca2acd 159 sta->sta.addr, tid);
d63e9ae3 160
7cca2acd 161 set_bit(tid, sta->ampdu_mlme.tid_rx_timer_expired);
1b672118 162 wiphy_work_queue(sta->local->hw.wiphy, &sta->ampdu_mlme.work);
b8695a8f
JB
163}
164
7cca2acd 165static void sta_rx_agg_reorder_timer_expired(struct timer_list *t)
2bff8ebf 166{
41cb0855
IM
167 struct tid_ampdu_rx *tid_rx = timer_container_of(tid_rx, t,
168 reorder_timer);
2bff8ebf
CL
169
170 rcu_read_lock();
7cca2acd 171 ieee80211_release_reorder_timeout(tid_rx->sta, tid_rx->tid);
2bff8ebf
CL
172 rcu_read_unlock();
173}
174
406c5548
MC
175void ieee80211_add_addbaext(struct sk_buff *skb,
176 const u8 req_addba_ext_data,
177 u16 buf_size)
2ab45876 178{
406c5548 179 struct ieee80211_addba_ext_ie *addba_ext;
2ab45876
JC
180 u8 *pos;
181
2ab45876
JC
182 pos = skb_put_zero(skb, 2 + sizeof(struct ieee80211_addba_ext_ie));
183 *pos++ = WLAN_EID_ADDBA_EXT;
184 *pos++ = sizeof(struct ieee80211_addba_ext_ie);
406c5548 185 addba_ext = (struct ieee80211_addba_ext_ie *)pos;
2ab45876 186
406c5548
MC
187 addba_ext->data = IEEE80211_ADDBA_EXT_NO_FRAG;
188 if (req_addba_ext_data)
189 addba_ext->data &= req_addba_ext_data;
190
191 addba_ext->data |=
192 u8_encode_bits(buf_size >> IEEE80211_ADDBA_EXT_BUF_SIZE_SHIFT,
193 IEEE80211_ADDBA_EXT_BUF_SIZE_MASK);
194}
195
196u8 ieee80211_retrieve_addba_ext_data(struct sta_info *sta,
197 const void *elem_data, ssize_t elem_len,
198 u16 *buf_size)
199{
200 struct ieee802_11_elems *elems;
201 u8 buf_size_1k, data = 0;
202
203 if (!sta->sta.deflink.he_cap.has_he)
204 return 0;
205
206 if (elem_len <= 0)
207 return 0;
208
209 elems = ieee802_11_parse_elems(elem_data, elem_len, true, NULL);
210
3979c8e6
JB
211 if (!elems || elems->parse_error || !elems->addba_ext_ie)
212 goto free;
406c5548 213
3979c8e6 214 data = elems->addba_ext_ie->data;
406c5548 215
3979c8e6
JB
216 if (buf_size &&
217 (sta->sta.valid_links || sta->sta.deflink.eht_cap.has_eht)) {
406c5548
MC
218 buf_size_1k = u8_get_bits(elems->addba_ext_ie->data,
219 IEEE80211_ADDBA_EXT_BUF_SIZE_MASK);
220 *buf_size |= (u16)buf_size_1k <<
221 IEEE80211_ADDBA_EXT_BUF_SIZE_SHIFT;
222 }
3979c8e6 223
406c5548
MC
224free:
225 kfree(elems);
226
227 return data;
2ab45876
JC
228}
229
230static void ieee80211_send_addba_resp(struct sta_info *sta, u8 *da, u16 tid,
b8695a8f 231 u8 dialog_token, u16 status, u16 policy,
2ab45876 232 u16 buf_size, u16 timeout,
406c5548 233 const u8 req_addba_ext_data)
b8695a8f 234{
2ab45876 235 struct ieee80211_sub_if_data *sdata = sta->sdata;
b8695a8f
JB
236 struct ieee80211_local *local = sdata->local;
237 struct sk_buff *skb;
238 struct ieee80211_mgmt *mgmt;
99e7ca44 239 bool amsdu = ieee80211_hw_check(&local->hw, SUPPORTS_AMSDU_IN_AMPDU);
b8695a8f
JB
240 u16 capab;
241
2ab45876
JC
242 skb = dev_alloc_skb(sizeof(*mgmt) +
243 2 + sizeof(struct ieee80211_addba_ext_ie) +
244 local->hw.extra_tx_headroom);
d15b8459 245 if (!skb)
b8695a8f 246 return;
b8695a8f
JB
247
248 skb_reserve(skb, local->hw.extra_tx_headroom);
ea63fb71 249 mgmt = ieee80211_mgmt_ba(skb, da, sdata);
b8695a8f
JB
250
251 skb_put(skb, 1 + sizeof(mgmt->u.action.u.addba_resp));
252 mgmt->u.action.category = WLAN_CATEGORY_BACK;
253 mgmt->u.action.u.addba_resp.action_code = WLAN_ACTION_ADDBA_RESP;
254 mgmt->u.action.u.addba_resp.dialog_token = dialog_token;
255
db8ebd06
JB
256 capab = u16_encode_bits(amsdu, IEEE80211_ADDBA_PARAM_AMSDU_MASK);
257 capab |= u16_encode_bits(policy, IEEE80211_ADDBA_PARAM_POLICY_MASK);
258 capab |= u16_encode_bits(tid, IEEE80211_ADDBA_PARAM_TID_MASK);
259 capab |= u16_encode_bits(buf_size, IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK);
b8695a8f
JB
260
261 mgmt->u.action.u.addba_resp.capab = cpu_to_le16(capab);
262 mgmt->u.action.u.addba_resp.timeout = cpu_to_le16(timeout);
263 mgmt->u.action.u.addba_resp.status = cpu_to_le16(status);
264
3979c8e6 265 if (sta->sta.valid_links || sta->sta.deflink.he_cap.has_he)
406c5548 266 ieee80211_add_addbaext(skb, req_addba_ext_data, buf_size);
2ab45876 267
62ae67be 268 ieee80211_tx_skb(sdata, skb);
b8695a8f
JB
269}
270
463559b7
JB
271void __ieee80211_start_rx_ba_session(struct sta_info *sta,
272 u8 dialog_token, u16 timeout,
273 u16 start_seq_num, u16 ba_policy, u16 tid,
274 u16 buf_size, bool tx, bool auto_seq,
406c5548 275 const u8 addba_ext_data)
b8695a8f 276{
08cf42e8 277 struct ieee80211_local *local = sta->sdata->local;
b8695a8f 278 struct tid_ampdu_rx *tid_agg_rx;
50ea05ef
SS
279 struct ieee80211_ampdu_params params = {
280 .sta = &sta->sta,
281 .action = IEEE80211_AMPDU_RX_START,
282 .tid = tid,
283 .amsdu = false,
284 .timeout = timeout,
285 .ssn = start_seq_num,
286 };
83eb935e 287 int i, ret = -EOPNOTSUPP;
08cf42e8 288 u16 status = WLAN_STATUS_REQUEST_DECLINED;
41cbb0f5 289 u16 max_buf_size;
b8695a8f 290
463559b7
JB
291 lockdep_assert_wiphy(sta->local->hw.wiphy);
292
85d5313e
JB
293 if (tid >= IEEE80211_FIRST_TSPEC_TSID) {
294 ht_dbg(sta->sdata,
295 "STA %pM requests BA session on unsupported tid %d\n",
296 sta->sta.addr, tid);
bde59c47 297 goto end;
85d5313e
JB
298 }
299
3979c8e6
JB
300 if (!sta->sta.valid_links &&
301 !sta->sta.deflink.ht_cap.ht_supported &&
2e82be13 302 !sta->sta.deflink.he_cap.has_he) {
8f9c77fc 303 ht_dbg(sta->sdata,
e406121e 304 "STA %pM erroneously requests BA session on tid %d w/o HT\n",
8f9c77fc
JB
305 sta->sta.addr, tid);
306 /* send a response anyway, it's an error case if we get here */
bde59c47 307 goto end;
8f9c77fc
JB
308 }
309
c2c98fde 310 if (test_sta_flag(sta, WLAN_STA_BLOCK_BA)) {
0a214d3f
JB
311 ht_dbg(sta->sdata,
312 "Suspend in progress - Denying ADDBA request (%pM tid %d)\n",
313 sta->sta.addr, tid);
bde59c47 314 goto end;
722f069a
S
315 }
316
3979c8e6 317 if (sta->sta.valid_links || sta->sta.deflink.eht_cap.has_eht)
c1c5c8a2 318 max_buf_size = IEEE80211_MAX_AMPDU_BUF_EHT;
046d2e7c 319 else if (sta->sta.deflink.he_cap.has_he)
2a2c86f1 320 max_buf_size = IEEE80211_MAX_AMPDU_BUF_HE;
41cbb0f5
LC
321 else
322 max_buf_size = IEEE80211_MAX_AMPDU_BUF_HT;
323
b8695a8f
JB
324 /* sanity check for incoming parameters:
325 * check if configuration can support the BA policy
326 * and if buffer size does not exceeds max value */
327 /* XXX: check own ht delayed BA capability?? */
f64f9e71 328 if (((ba_policy != 1) &&
3979c8e6
JB
329 (sta->sta.valid_links ||
330 !(sta->sta.deflink.ht_cap.cap & IEEE80211_HT_CAP_DELAY_BA))) ||
41cbb0f5 331 (buf_size > max_buf_size)) {
b8695a8f 332 status = WLAN_STATUS_INVALID_QOS_PARAM;
bdcbd8e0
JB
333 ht_dbg_ratelimited(sta->sdata,
334 "AddBA Req with bad params from %pM on tid %u. policy %d, buffer size %d\n",
08cf42e8 335 sta->sta.addr, tid, ba_policy, buf_size);
bde59c47 336 goto end;
b8695a8f
JB
337 }
338 /* determine default buffer size */
82694f76 339 if (buf_size == 0)
41cbb0f5 340 buf_size = max_buf_size;
b8695a8f 341
df6ba5d8 342 /* make sure the size doesn't exceed the maximum supported by the hw */
480dd46b
MA
343 if (buf_size > sta->sta.max_rx_aggregation_subframes)
344 buf_size = sta->sta.max_rx_aggregation_subframes;
50ea05ef 345 params.buf_size = buf_size;
b8695a8f 346
480dd46b
MA
347 ht_dbg(sta->sdata, "AddBA Req buf_size=%d for %pM\n",
348 buf_size, sta->sta.addr);
349
412a6d80 350 if (test_bit(tid, sta->ampdu_mlme.agg_session_valid)) {
1c3d185a 351 if (sta->ampdu_mlme.tid_rx_token[tid] == dialog_token) {
21b7022f
IP
352 struct tid_ampdu_rx *tid_rx;
353
f89e07d4
JB
354 ht_dbg_ratelimited(sta->sdata,
355 "updated AddBA Req from %pM on tid %u\n",
356 sta->sta.addr, tid);
357 /* We have no API to update the timeout value in the
21b7022f 358 * driver so reject the timeout update if the timeout
39f774e7 359 * changed. If it did not change, i.e., no real update,
21b7022f 360 * just reply with success.
f89e07d4 361 */
21b7022f
IP
362 rcu_read_lock();
363 tid_rx = rcu_dereference(sta->ampdu_mlme.tid_rx[tid]);
364 if (tid_rx && tid_rx->timeout == timeout)
365 status = WLAN_STATUS_SUCCESS;
366 else
367 status = WLAN_STATUS_REQUEST_DECLINED;
368 rcu_read_unlock();
f89e07d4
JB
369 goto end;
370 }
371
bdcbd8e0
JB
372 ht_dbg_ratelimited(sta->sdata,
373 "unexpected AddBA Req from %pM on tid %u\n",
08cf42e8 374 sta->sta.addr, tid);
15b4d843
AN
375
376 /* delete existing Rx BA session on the same tid */
463559b7
JB
377 __ieee80211_stop_rx_ba_session(sta, tid, WLAN_BACK_RECIPIENT,
378 WLAN_STATUS_UNSPECIFIED_QOS,
379 false);
b8695a8f
JB
380 }
381
412a6d80
SS
382 if (ieee80211_hw_check(&local->hw, SUPPORTS_REORDERING_BUFFER)) {
383 ret = drv_ampdu_action(local, sta->sdata, &params);
384 ht_dbg(sta->sdata,
385 "Rx A-MPDU request on %pM tid %d result %d\n",
386 sta->sta.addr, tid, ret);
387 if (!ret)
388 status = WLAN_STATUS_SUCCESS;
389 goto end;
390 }
391
b8695a8f 392 /* prepare A-MPDU MLME for Rx aggregation */
f39ea269 393 tid_agg_rx = kzalloc(sizeof(*tid_agg_rx), GFP_KERNEL);
d15b8459 394 if (!tid_agg_rx)
b8695a8f 395 goto end;
b8695a8f 396
2bff8ebf
CL
397 spin_lock_init(&tid_agg_rx->reorder_lock);
398
a87f736d 399 /* rx timer */
7cca2acd
KC
400 timer_setup(&tid_agg_rx->session_timer,
401 sta_rx_agg_session_timer_expired, TIMER_DEFERRABLE);
b8695a8f 402
2bff8ebf 403 /* rx reorder timer */
7cca2acd
KC
404 timer_setup(&tid_agg_rx->reorder_timer,
405 sta_rx_agg_reorder_timer_expired, 0);
2bff8ebf 406
b8695a8f
JB
407 /* prepare reordering buffer */
408 tid_agg_rx->reorder_buf =
83eb935e 409 kcalloc(buf_size, sizeof(struct sk_buff_head), GFP_KERNEL);
4d050f1d 410 tid_agg_rx->reorder_time =
dd318575 411 kcalloc(buf_size, sizeof(unsigned long), GFP_KERNEL);
4d050f1d 412 if (!tid_agg_rx->reorder_buf || !tid_agg_rx->reorder_time) {
4d050f1d
JM
413 kfree(tid_agg_rx->reorder_buf);
414 kfree(tid_agg_rx->reorder_time);
a87f736d 415 kfree(tid_agg_rx);
b8695a8f
JB
416 goto end;
417 }
418
83eb935e
MK
419 for (i = 0; i < buf_size; i++)
420 __skb_queue_head_init(&tid_agg_rx->reorder_buf[i]);
421
50ea05ef 422 ret = drv_ampdu_action(local, sta->sdata, &params);
0a214d3f
JB
423 ht_dbg(sta->sdata, "Rx A-MPDU request on %pM tid %d result %d\n",
424 sta->sta.addr, tid, ret);
b8695a8f
JB
425 if (ret) {
426 kfree(tid_agg_rx->reorder_buf);
a87f736d 427 kfree(tid_agg_rx->reorder_time);
b8695a8f 428 kfree(tid_agg_rx);
b8695a8f
JB
429 goto end;
430 }
431
a87f736d 432 /* update data */
b8695a8f
JB
433 tid_agg_rx->ssn = start_seq_num;
434 tid_agg_rx->head_seq_num = start_seq_num;
435 tid_agg_rx->buf_size = buf_size;
436 tid_agg_rx->timeout = timeout;
437 tid_agg_rx->stored_mpdu_num = 0;
4549cf2b 438 tid_agg_rx->auto_seq = auto_seq;
b7540d8f 439 tid_agg_rx->started = false;
06470f74 440 tid_agg_rx->reorder_buf_filtered = 0;
7cca2acd
KC
441 tid_agg_rx->tid = tid;
442 tid_agg_rx->sta = sta;
b8695a8f 443 status = WLAN_STATUS_SUCCESS;
a87f736d
JB
444
445 /* activate it for RX */
cf778b00 446 rcu_assign_pointer(sta->ampdu_mlme.tid_rx[tid], tid_agg_rx);
f955ebb4 447
12d3952f 448 if (timeout) {
f955ebb4 449 mod_timer(&tid_agg_rx->session_timer, TU_TO_EXP_TIME(timeout));
12d3952f
FF
450 tid_agg_rx->last_rx = jiffies;
451 }
f955ebb4 452
b8695a8f 453end:
bfe40fa3 454 if (status == WLAN_STATUS_SUCCESS) {
412a6d80 455 __set_bit(tid, sta->ampdu_mlme.agg_session_valid);
bfe40fa3 456 __clear_bit(tid, sta->ampdu_mlme.unexpected_agg);
1c3d185a 457 sta->ampdu_mlme.tid_rx_token[tid] = dialog_token;
bfe40fa3 458 }
b8695a8f 459
08cf42e8 460 if (tx)
2ab45876 461 ieee80211_send_addba_resp(sta, sta->sta.addr, tid,
08cf42e8 462 dialog_token, status, 1, buf_size,
406c5548 463 timeout, addba_ext_data);
08cf42e8
MK
464}
465
466void ieee80211_process_addba_request(struct ieee80211_local *local,
467 struct sta_info *sta,
468 struct ieee80211_mgmt *mgmt,
469 size_t len)
470{
471 u16 capab, tid, timeout, ba_policy, buf_size, start_seq_num;
406c5548 472 u8 dialog_token, addba_ext_data;
08cf42e8
MK
473
474 /* extract session parameters from addba request frame */
475 dialog_token = mgmt->u.action.u.addba_req.dialog_token;
476 timeout = le16_to_cpu(mgmt->u.action.u.addba_req.timeout);
477 start_seq_num =
478 le16_to_cpu(mgmt->u.action.u.addba_req.start_seq_num) >> 4;
479
480 capab = le16_to_cpu(mgmt->u.action.u.addba_req.capab);
481 ba_policy = (capab & IEEE80211_ADDBA_PARAM_POLICY_MASK) >> 1;
482 tid = (capab & IEEE80211_ADDBA_PARAM_TID_MASK) >> 2;
483 buf_size = (capab & IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK) >> 6;
484
406c5548
MC
485 addba_ext_data =
486 ieee80211_retrieve_addba_ext_data(sta,
487 mgmt->u.action.u.addba_req.variable,
488 len -
489 offsetof(typeof(*mgmt),
490 u.action.u.addba_req.variable),
491 &buf_size);
c1c5c8a2 492
08cf42e8
MK
493 __ieee80211_start_rx_ba_session(sta, dialog_token, timeout,
494 start_seq_num, ba_policy, tid,
406c5548 495 buf_size, true, false, addba_ext_data);
08cf42e8
MK
496}
497
699cb58c 498void ieee80211_manage_rx_ba_offl(struct ieee80211_vif *vif,
1272c5d8 499 const u8 *addr, unsigned int tid)
08cf42e8
MK
500{
501 struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
699cb58c 502 struct sta_info *sta;
08cf42e8 503
699cb58c
JB
504 rcu_read_lock();
505 sta = sta_info_get_bss(sdata, addr);
506 if (!sta)
507 goto unlock;
08cf42e8 508
1272c5d8 509 set_bit(tid, sta->ampdu_mlme.tid_rx_manage_offl);
1b672118 510 wiphy_work_queue(sta->local->hw.wiphy, &sta->ampdu_mlme.work);
699cb58c
JB
511 unlock:
512 rcu_read_unlock();
b8695a8f 513}
699cb58c 514EXPORT_SYMBOL(ieee80211_manage_rx_ba_offl);
04c2cf34
NG
515
516void ieee80211_rx_ba_timer_expired(struct ieee80211_vif *vif,
517 const u8 *addr, unsigned int tid)
518{
519 struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
04c2cf34
NG
520 struct sta_info *sta;
521
522 rcu_read_lock();
523 sta = sta_info_get_bss(sdata, addr);
524 if (!sta)
525 goto unlock;
526
527 set_bit(tid, sta->ampdu_mlme.tid_rx_timer_expired);
1b672118 528 wiphy_work_queue(sta->local->hw.wiphy, &sta->ampdu_mlme.work);
04c2cf34
NG
529
530 unlock:
531 rcu_read_unlock();
532}
533EXPORT_SYMBOL(ieee80211_rx_ba_timer_expired);