agg-rx.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * HT handling
  4. *
  5. * Copyright 2003, Jouni Malinen <[email protected]>
  6. * Copyright 2002-2005, Instant802 Networks, Inc.
  7. * Copyright 2005-2006, Devicescape Software, Inc.
  8. * Copyright 2006-2007 Jiri Benc <[email protected]>
  9. * Copyright 2007, Michael Wu <[email protected]>
  10. * Copyright 2007-2010, Intel Corporation
  11. * Copyright(c) 2015-2017 Intel Deutschland GmbH
  12. * Copyright (C) 2018-2022 Intel Corporation
  13. */
  14. /**
  15. * DOC: RX A-MPDU aggregation
  16. *
  17. * Aggregation on the RX side requires only implementing the
  18. * @ampdu_action callback that is invoked to start/stop any
  19. * block-ack sessions for RX aggregation.
  20. *
  21. * When RX aggregation is started by the peer, the driver is
  22. * notified via @ampdu_action function, with the
  23. * %IEEE80211_AMPDU_RX_START action, and may reject the request
  24. * in which case a negative response is sent to the peer, if it
  25. * accepts it a positive response is sent.
  26. *
  27. * While the session is active, the device/driver are required
  28. * to de-aggregate frames and pass them up one by one to mac80211,
  29. * which will handle the reorder buffer.
  30. *
  31. * When the aggregation session is stopped again by the peer or
  32. * ourselves, the driver's @ampdu_action function will be called
  33. * with the action %IEEE80211_AMPDU_RX_STOP. In this case, the
  34. * call must not fail.
  35. */
  36. #include <linux/ieee80211.h>
  37. #include <linux/slab.h>
  38. #include <linux/export.h>
  39. #include <net/mac80211.h>
  40. #include "ieee80211_i.h"
  41. #include "driver-ops.h"
  42. static void ieee80211_free_tid_rx(struct rcu_head *h)
  43. {
  44. struct tid_ampdu_rx *tid_rx =
  45. container_of(h, struct tid_ampdu_rx, rcu_head);
  46. int i;
  47. for (i = 0; i < tid_rx->buf_size; i++)
  48. __skb_queue_purge(&tid_rx->reorder_buf[i]);
  49. kfree(tid_rx->reorder_buf);
  50. kfree(tid_rx->reorder_time);
  51. kfree(tid_rx);
  52. }
  53. void ___ieee80211_stop_rx_ba_session(struct sta_info *sta, u16 tid,
  54. u16 initiator, u16 reason, bool tx)
  55. {
  56. struct ieee80211_local *local = sta->local;
  57. struct tid_ampdu_rx *tid_rx;
  58. struct ieee80211_ampdu_params params = {
  59. .sta = &sta->sta,
  60. .action = IEEE80211_AMPDU_RX_STOP,
  61. .tid = tid,
  62. .amsdu = false,
  63. .timeout = 0,
  64. .ssn = 0,
  65. };
  66. lockdep_assert_held(&sta->ampdu_mlme.mtx);
  67. tid_rx = rcu_dereference_protected(sta->ampdu_mlme.tid_rx[tid],
  68. lockdep_is_held(&sta->ampdu_mlme.mtx));
  69. if (!test_bit(tid, sta->ampdu_mlme.agg_session_valid))
  70. return;
  71. RCU_INIT_POINTER(sta->ampdu_mlme.tid_rx[tid], NULL);
  72. __clear_bit(tid, sta->ampdu_mlme.agg_session_valid);
  73. ht_dbg(sta->sdata,
  74. "Rx BA session stop requested for %pM tid %u %s reason: %d\n",
  75. sta->sta.addr, tid,
  76. initiator == WLAN_BACK_RECIPIENT ? "recipient" : "initiator",
  77. (int)reason);
  78. if (drv_ampdu_action(local, sta->sdata, &params))
  79. sdata_info(sta->sdata,
  80. "HW problem - can not stop rx aggregation for %pM tid %d\n",
  81. sta->sta.addr, tid);
  82. /* check if this is a self generated aggregation halt */
  83. if (initiator == WLAN_BACK_RECIPIENT && tx)
  84. ieee80211_send_delba(sta->sdata, sta->sta.addr,
  85. tid, WLAN_BACK_RECIPIENT, reason);
  86. /*
  87. * return here in case tid_rx is not assigned - which will happen if
  88. * IEEE80211_HW_SUPPORTS_REORDERING_BUFFER is set.
  89. */
  90. if (!tid_rx)
  91. return;
  92. del_timer_sync(&tid_rx->session_timer);
  93. /* make sure ieee80211_sta_reorder_release() doesn't re-arm the timer */
  94. spin_lock_bh(&tid_rx->reorder_lock);
  95. tid_rx->removed = true;
  96. spin_unlock_bh(&tid_rx->reorder_lock);
  97. del_timer_sync(&tid_rx->reorder_timer);
  98. call_rcu(&tid_rx->rcu_head, ieee80211_free_tid_rx);
  99. }
  100. void __ieee80211_stop_rx_ba_session(struct sta_info *sta, u16 tid,
  101. u16 initiator, u16 reason, bool tx)
  102. {
  103. mutex_lock(&sta->ampdu_mlme.mtx);
  104. ___ieee80211_stop_rx_ba_session(sta, tid, initiator, reason, tx);
  105. mutex_unlock(&sta->ampdu_mlme.mtx);
  106. }
  107. void ieee80211_stop_rx_ba_session(struct ieee80211_vif *vif, u16 ba_rx_bitmap,
  108. const u8 *addr)
  109. {
  110. struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
  111. struct sta_info *sta;
  112. int i;
  113. rcu_read_lock();
  114. sta = sta_info_get_bss(sdata, addr);
  115. if (!sta) {
  116. rcu_read_unlock();
  117. return;
  118. }
  119. for (i = 0; i < IEEE80211_NUM_TIDS; i++)
  120. if (ba_rx_bitmap & BIT(i))
  121. set_bit(i, sta->ampdu_mlme.tid_rx_stop_requested);
  122. ieee80211_queue_work(&sta->local->hw, &sta->ampdu_mlme.work);
  123. rcu_read_unlock();
  124. }
  125. EXPORT_SYMBOL(ieee80211_stop_rx_ba_session);
  126. /*
  127. * After accepting the AddBA Request we activated a timer,
  128. * resetting it after each frame that arrives from the originator.
  129. */
  130. static void sta_rx_agg_session_timer_expired(struct timer_list *t)
  131. {
  132. struct tid_ampdu_rx *tid_rx = from_timer(tid_rx, t, session_timer);
  133. struct sta_info *sta = tid_rx->sta;
  134. u8 tid = tid_rx->tid;
  135. unsigned long timeout;
  136. timeout = tid_rx->last_rx + TU_TO_JIFFIES(tid_rx->timeout);
  137. if (time_is_after_jiffies(timeout)) {
  138. mod_timer(&tid_rx->session_timer, timeout);
  139. return;
  140. }
  141. ht_dbg(sta->sdata, "RX session timer expired on %pM tid %d\n",
  142. sta->sta.addr, tid);
  143. set_bit(tid, sta->ampdu_mlme.tid_rx_timer_expired);
  144. ieee80211_queue_work(&sta->local->hw, &sta->ampdu_mlme.work);
  145. }
  146. static void sta_rx_agg_reorder_timer_expired(struct timer_list *t)
  147. {
  148. struct tid_ampdu_rx *tid_rx = from_timer(tid_rx, t, reorder_timer);
  149. rcu_read_lock();
  150. ieee80211_release_reorder_timeout(tid_rx->sta, tid_rx->tid);
  151. rcu_read_unlock();
  152. }
  153. static void ieee80211_add_addbaext(struct ieee80211_sub_if_data *sdata,
  154. struct sk_buff *skb,
  155. const struct ieee80211_addba_ext_ie *req,
  156. u16 buf_size)
  157. {
  158. struct ieee80211_supported_band *sband;
  159. struct ieee80211_addba_ext_ie *resp;
  160. const struct ieee80211_sta_he_cap *he_cap;
  161. u8 frag_level, cap_frag_level;
  162. u8 *pos;
  163. sband = ieee80211_get_sband(sdata);
  164. if (!sband)
  165. return;
  166. he_cap = ieee80211_get_he_iftype_cap(sband,
  167. ieee80211_vif_type_p2p(&sdata->vif));
  168. if (!he_cap)
  169. return;
  170. pos = skb_put_zero(skb, 2 + sizeof(struct ieee80211_addba_ext_ie));
  171. *pos++ = WLAN_EID_ADDBA_EXT;
  172. *pos++ = sizeof(struct ieee80211_addba_ext_ie);
  173. resp = (struct ieee80211_addba_ext_ie *)pos;
  174. resp->data = req->data & IEEE80211_ADDBA_EXT_NO_FRAG;
  175. frag_level = u32_get_bits(req->data,
  176. IEEE80211_ADDBA_EXT_FRAG_LEVEL_MASK);
  177. cap_frag_level = u32_get_bits(he_cap->he_cap_elem.mac_cap_info[0],
  178. IEEE80211_HE_MAC_CAP0_DYNAMIC_FRAG_MASK);
  179. if (frag_level > cap_frag_level)
  180. frag_level = cap_frag_level;
  181. resp->data |= u8_encode_bits(frag_level,
  182. IEEE80211_ADDBA_EXT_FRAG_LEVEL_MASK);
  183. resp->data |= u8_encode_bits(buf_size >> IEEE80211_ADDBA_EXT_BUF_SIZE_SHIFT,
  184. IEEE80211_ADDBA_EXT_BUF_SIZE_MASK);
  185. }
  186. static void ieee80211_send_addba_resp(struct sta_info *sta, u8 *da, u16 tid,
  187. u8 dialog_token, u16 status, u16 policy,
  188. u16 buf_size, u16 timeout,
  189. const struct ieee80211_addba_ext_ie *addbaext)
  190. {
  191. struct ieee80211_sub_if_data *sdata = sta->sdata;
  192. struct ieee80211_local *local = sdata->local;
  193. struct sk_buff *skb;
  194. struct ieee80211_mgmt *mgmt;
  195. bool amsdu = ieee80211_hw_check(&local->hw, SUPPORTS_AMSDU_IN_AMPDU);
  196. u16 capab;
  197. skb = dev_alloc_skb(sizeof(*mgmt) +
  198. 2 + sizeof(struct ieee80211_addba_ext_ie) +
  199. local->hw.extra_tx_headroom);
  200. if (!skb)
  201. return;
  202. skb_reserve(skb, local->hw.extra_tx_headroom);
  203. mgmt = skb_put_zero(skb, 24);
  204. memcpy(mgmt->da, da, ETH_ALEN);
  205. memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN);
  206. if (sdata->vif.type == NL80211_IFTYPE_AP ||
  207. sdata->vif.type == NL80211_IFTYPE_AP_VLAN ||
  208. sdata->vif.type == NL80211_IFTYPE_MESH_POINT)
  209. memcpy(mgmt->bssid, sdata->vif.addr, ETH_ALEN);
  210. else if (sdata->vif.type == NL80211_IFTYPE_STATION)
  211. memcpy(mgmt->bssid, sdata->deflink.u.mgd.bssid, ETH_ALEN);
  212. else if (sdata->vif.type == NL80211_IFTYPE_ADHOC)
  213. memcpy(mgmt->bssid, sdata->u.ibss.bssid, ETH_ALEN);
  214. mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
  215. IEEE80211_STYPE_ACTION);
  216. skb_put(skb, 1 + sizeof(mgmt->u.action.u.addba_resp));
  217. mgmt->u.action.category = WLAN_CATEGORY_BACK;
  218. mgmt->u.action.u.addba_resp.action_code = WLAN_ACTION_ADDBA_RESP;
  219. mgmt->u.action.u.addba_resp.dialog_token = dialog_token;
  220. capab = u16_encode_bits(amsdu, IEEE80211_ADDBA_PARAM_AMSDU_MASK);
  221. capab |= u16_encode_bits(policy, IEEE80211_ADDBA_PARAM_POLICY_MASK);
  222. capab |= u16_encode_bits(tid, IEEE80211_ADDBA_PARAM_TID_MASK);
  223. capab |= u16_encode_bits(buf_size, IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK);
  224. mgmt->u.action.u.addba_resp.capab = cpu_to_le16(capab);
  225. mgmt->u.action.u.addba_resp.timeout = cpu_to_le16(timeout);
  226. mgmt->u.action.u.addba_resp.status = cpu_to_le16(status);
  227. if (sta->sta.deflink.he_cap.has_he && addbaext)
  228. ieee80211_add_addbaext(sdata, skb, addbaext, buf_size);
  229. ieee80211_tx_skb(sdata, skb);
  230. }
  231. void ___ieee80211_start_rx_ba_session(struct sta_info *sta,
  232. u8 dialog_token, u16 timeout,
  233. u16 start_seq_num, u16 ba_policy, u16 tid,
  234. u16 buf_size, bool tx, bool auto_seq,
  235. const struct ieee80211_addba_ext_ie *addbaext)
  236. {
  237. struct ieee80211_local *local = sta->sdata->local;
  238. struct tid_ampdu_rx *tid_agg_rx;
  239. struct ieee80211_ampdu_params params = {
  240. .sta = &sta->sta,
  241. .action = IEEE80211_AMPDU_RX_START,
  242. .tid = tid,
  243. .amsdu = false,
  244. .timeout = timeout,
  245. .ssn = start_seq_num,
  246. };
  247. int i, ret = -EOPNOTSUPP;
  248. u16 status = WLAN_STATUS_REQUEST_DECLINED;
  249. u16 max_buf_size;
  250. if (tid >= IEEE80211_FIRST_TSPEC_TSID) {
  251. ht_dbg(sta->sdata,
  252. "STA %pM requests BA session on unsupported tid %d\n",
  253. sta->sta.addr, tid);
  254. goto end;
  255. }
  256. if (!sta->sta.deflink.ht_cap.ht_supported &&
  257. sta->sdata->vif.bss_conf.chandef.chan->band != NL80211_BAND_6GHZ) {
  258. ht_dbg(sta->sdata,
  259. "STA %pM erroneously requests BA session on tid %d w/o QoS\n",
  260. sta->sta.addr, tid);
  261. /* send a response anyway, it's an error case if we get here */
  262. goto end;
  263. }
  264. if (test_sta_flag(sta, WLAN_STA_BLOCK_BA)) {
  265. ht_dbg(sta->sdata,
  266. "Suspend in progress - Denying ADDBA request (%pM tid %d)\n",
  267. sta->sta.addr, tid);
  268. goto end;
  269. }
  270. if (sta->sta.deflink.eht_cap.has_eht)
  271. max_buf_size = IEEE80211_MAX_AMPDU_BUF_EHT;
  272. else if (sta->sta.deflink.he_cap.has_he)
  273. max_buf_size = IEEE80211_MAX_AMPDU_BUF_HE;
  274. else
  275. max_buf_size = IEEE80211_MAX_AMPDU_BUF_HT;
  276. /* sanity check for incoming parameters:
  277. * check if configuration can support the BA policy
  278. * and if buffer size does not exceeds max value */
  279. /* XXX: check own ht delayed BA capability?? */
  280. if (((ba_policy != 1) &&
  281. (!(sta->sta.deflink.ht_cap.cap & IEEE80211_HT_CAP_DELAY_BA))) ||
  282. (buf_size > max_buf_size)) {
  283. status = WLAN_STATUS_INVALID_QOS_PARAM;
  284. ht_dbg_ratelimited(sta->sdata,
  285. "AddBA Req with bad params from %pM on tid %u. policy %d, buffer size %d\n",
  286. sta->sta.addr, tid, ba_policy, buf_size);
  287. goto end;
  288. }
  289. /* determine default buffer size */
  290. if (buf_size == 0)
  291. buf_size = max_buf_size;
  292. /* make sure the size doesn't exceed the maximum supported by the hw */
  293. if (buf_size > sta->sta.max_rx_aggregation_subframes)
  294. buf_size = sta->sta.max_rx_aggregation_subframes;
  295. params.buf_size = buf_size;
  296. ht_dbg(sta->sdata, "AddBA Req buf_size=%d for %pM\n",
  297. buf_size, sta->sta.addr);
  298. /* examine state machine */
  299. lockdep_assert_held(&sta->ampdu_mlme.mtx);
  300. if (test_bit(tid, sta->ampdu_mlme.agg_session_valid)) {
  301. if (sta->ampdu_mlme.tid_rx_token[tid] == dialog_token) {
  302. struct tid_ampdu_rx *tid_rx;
  303. ht_dbg_ratelimited(sta->sdata,
  304. "updated AddBA Req from %pM on tid %u\n",
  305. sta->sta.addr, tid);
  306. /* We have no API to update the timeout value in the
  307. * driver so reject the timeout update if the timeout
  308. * changed. If it did not change, i.e., no real update,
  309. * just reply with success.
  310. */
  311. rcu_read_lock();
  312. tid_rx = rcu_dereference(sta->ampdu_mlme.tid_rx[tid]);
  313. if (tid_rx && tid_rx->timeout == timeout)
  314. status = WLAN_STATUS_SUCCESS;
  315. else
  316. status = WLAN_STATUS_REQUEST_DECLINED;
  317. rcu_read_unlock();
  318. goto end;
  319. }
  320. ht_dbg_ratelimited(sta->sdata,
  321. "unexpected AddBA Req from %pM on tid %u\n",
  322. sta->sta.addr, tid);
  323. /* delete existing Rx BA session on the same tid */
  324. ___ieee80211_stop_rx_ba_session(sta, tid, WLAN_BACK_RECIPIENT,
  325. WLAN_STATUS_UNSPECIFIED_QOS,
  326. false);
  327. }
  328. if (ieee80211_hw_check(&local->hw, SUPPORTS_REORDERING_BUFFER)) {
  329. ret = drv_ampdu_action(local, sta->sdata, &params);
  330. ht_dbg(sta->sdata,
  331. "Rx A-MPDU request on %pM tid %d result %d\n",
  332. sta->sta.addr, tid, ret);
  333. if (!ret)
  334. status = WLAN_STATUS_SUCCESS;
  335. goto end;
  336. }
  337. /* prepare A-MPDU MLME for Rx aggregation */
  338. tid_agg_rx = kzalloc(sizeof(*tid_agg_rx), GFP_KERNEL);
  339. if (!tid_agg_rx)
  340. goto end;
  341. spin_lock_init(&tid_agg_rx->reorder_lock);
  342. /* rx timer */
  343. timer_setup(&tid_agg_rx->session_timer,
  344. sta_rx_agg_session_timer_expired, TIMER_DEFERRABLE);
  345. /* rx reorder timer */
  346. timer_setup(&tid_agg_rx->reorder_timer,
  347. sta_rx_agg_reorder_timer_expired, 0);
  348. /* prepare reordering buffer */
  349. tid_agg_rx->reorder_buf =
  350. kcalloc(buf_size, sizeof(struct sk_buff_head), GFP_KERNEL);
  351. tid_agg_rx->reorder_time =
  352. kcalloc(buf_size, sizeof(unsigned long), GFP_KERNEL);
  353. if (!tid_agg_rx->reorder_buf || !tid_agg_rx->reorder_time) {
  354. kfree(tid_agg_rx->reorder_buf);
  355. kfree(tid_agg_rx->reorder_time);
  356. kfree(tid_agg_rx);
  357. goto end;
  358. }
  359. for (i = 0; i < buf_size; i++)
  360. __skb_queue_head_init(&tid_agg_rx->reorder_buf[i]);
  361. ret = drv_ampdu_action(local, sta->sdata, &params);
  362. ht_dbg(sta->sdata, "Rx A-MPDU request on %pM tid %d result %d\n",
  363. sta->sta.addr, tid, ret);
  364. if (ret) {
  365. kfree(tid_agg_rx->reorder_buf);
  366. kfree(tid_agg_rx->reorder_time);
  367. kfree(tid_agg_rx);
  368. goto end;
  369. }
  370. /* update data */
  371. tid_agg_rx->ssn = start_seq_num;
  372. tid_agg_rx->head_seq_num = start_seq_num;
  373. tid_agg_rx->buf_size = buf_size;
  374. tid_agg_rx->timeout = timeout;
  375. tid_agg_rx->stored_mpdu_num = 0;
  376. tid_agg_rx->auto_seq = auto_seq;
  377. tid_agg_rx->started = false;
  378. tid_agg_rx->reorder_buf_filtered = 0;
  379. tid_agg_rx->tid = tid;
  380. tid_agg_rx->sta = sta;
  381. status = WLAN_STATUS_SUCCESS;
  382. /* activate it for RX */
  383. rcu_assign_pointer(sta->ampdu_mlme.tid_rx[tid], tid_agg_rx);
  384. if (timeout) {
  385. mod_timer(&tid_agg_rx->session_timer, TU_TO_EXP_TIME(timeout));
  386. tid_agg_rx->last_rx = jiffies;
  387. }
  388. end:
  389. if (status == WLAN_STATUS_SUCCESS) {
  390. __set_bit(tid, sta->ampdu_mlme.agg_session_valid);
  391. __clear_bit(tid, sta->ampdu_mlme.unexpected_agg);
  392. sta->ampdu_mlme.tid_rx_token[tid] = dialog_token;
  393. }
  394. if (tx)
  395. ieee80211_send_addba_resp(sta, sta->sta.addr, tid,
  396. dialog_token, status, 1, buf_size,
  397. timeout, addbaext);
  398. }
  399. static void __ieee80211_start_rx_ba_session(struct sta_info *sta,
  400. u8 dialog_token, u16 timeout,
  401. u16 start_seq_num, u16 ba_policy,
  402. u16 tid, u16 buf_size, bool tx,
  403. bool auto_seq,
  404. const struct ieee80211_addba_ext_ie *addbaext)
  405. {
  406. mutex_lock(&sta->ampdu_mlme.mtx);
  407. ___ieee80211_start_rx_ba_session(sta, dialog_token, timeout,
  408. start_seq_num, ba_policy, tid,
  409. buf_size, tx, auto_seq, addbaext);
  410. mutex_unlock(&sta->ampdu_mlme.mtx);
  411. }
  412. void ieee80211_process_addba_request(struct ieee80211_local *local,
  413. struct sta_info *sta,
  414. struct ieee80211_mgmt *mgmt,
  415. size_t len)
  416. {
  417. u16 capab, tid, timeout, ba_policy, buf_size, start_seq_num;
  418. struct ieee802_11_elems *elems = NULL;
  419. u8 dialog_token;
  420. int ies_len;
  421. /* extract session parameters from addba request frame */
  422. dialog_token = mgmt->u.action.u.addba_req.dialog_token;
  423. timeout = le16_to_cpu(mgmt->u.action.u.addba_req.timeout);
  424. start_seq_num =
  425. le16_to_cpu(mgmt->u.action.u.addba_req.start_seq_num) >> 4;
  426. capab = le16_to_cpu(mgmt->u.action.u.addba_req.capab);
  427. ba_policy = (capab & IEEE80211_ADDBA_PARAM_POLICY_MASK) >> 1;
  428. tid = (capab & IEEE80211_ADDBA_PARAM_TID_MASK) >> 2;
  429. buf_size = (capab & IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK) >> 6;
  430. ies_len = len - offsetof(struct ieee80211_mgmt,
  431. u.action.u.addba_req.variable);
  432. if (ies_len) {
  433. elems = ieee802_11_parse_elems(mgmt->u.action.u.addba_req.variable,
  434. ies_len, true, NULL);
  435. if (!elems || elems->parse_error)
  436. goto free;
  437. }
  438. if (sta->sta.deflink.eht_cap.has_eht && elems && elems->addba_ext_ie) {
  439. u8 buf_size_1k = u8_get_bits(elems->addba_ext_ie->data,
  440. IEEE80211_ADDBA_EXT_BUF_SIZE_MASK);
  441. buf_size |= buf_size_1k << IEEE80211_ADDBA_EXT_BUF_SIZE_SHIFT;
  442. }
  443. __ieee80211_start_rx_ba_session(sta, dialog_token, timeout,
  444. start_seq_num, ba_policy, tid,
  445. buf_size, true, false,
  446. elems ? elems->addba_ext_ie : NULL);
  447. free:
  448. kfree(elems);
  449. }
  450. void ieee80211_manage_rx_ba_offl(struct ieee80211_vif *vif,
  451. const u8 *addr, unsigned int tid)
  452. {
  453. struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
  454. struct ieee80211_local *local = sdata->local;
  455. struct sta_info *sta;
  456. rcu_read_lock();
  457. sta = sta_info_get_bss(sdata, addr);
  458. if (!sta)
  459. goto unlock;
  460. set_bit(tid, sta->ampdu_mlme.tid_rx_manage_offl);
  461. ieee80211_queue_work(&local->hw, &sta->ampdu_mlme.work);
  462. unlock:
  463. rcu_read_unlock();
  464. }
  465. EXPORT_SYMBOL(ieee80211_manage_rx_ba_offl);
  466. void ieee80211_rx_ba_timer_expired(struct ieee80211_vif *vif,
  467. const u8 *addr, unsigned int tid)
  468. {
  469. struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
  470. struct ieee80211_local *local = sdata->local;
  471. struct sta_info *sta;
  472. rcu_read_lock();
  473. sta = sta_info_get_bss(sdata, addr);
  474. if (!sta)
  475. goto unlock;
  476. set_bit(tid, sta->ampdu_mlme.tid_rx_timer_expired);
  477. ieee80211_queue_work(&local->hw, &sta->ampdu_mlme.work);
  478. unlock:
  479. rcu_read_unlock();
  480. }
  481. EXPORT_SYMBOL(ieee80211_rx_ba_timer_expired);