agg-tx.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633
  1. /*
  2. * HT handling
  3. *
  4. * Copyright 2003, Jouni Malinen <jkmaline@cc.hut.fi>
  5. * Copyright 2002-2005, Instant802 Networks, Inc.
  6. * Copyright 2005-2006, Devicescape Software, Inc.
  7. * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz>
  8. * Copyright 2007, Michael Wu <flamingice@sourmilk.net>
  9. * Copyright 2007-2009, Intel Corporation
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License version 2 as
  13. * published by the Free Software Foundation.
  14. */
  15. #include <linux/ieee80211.h>
  16. #include <net/mac80211.h>
  17. #include "ieee80211_i.h"
  18. #include "wme.h"
  19. /**
  20. * DOC: TX aggregation
  21. *
  22. * Aggregation on the TX side requires setting the hardware flag
  23. * %IEEE80211_HW_AMPDU_AGGREGATION as well as, if present, the @ampdu_queues
  24. * hardware parameter to the number of hardware AMPDU queues. If there are no
  25. * hardware queues then the driver will (currently) have to do all frame
  26. * buffering.
  27. *
  28. * When TX aggregation is started by some subsystem (usually the rate control
  29. * algorithm would be appropriate) by calling the
  30. * ieee80211_start_tx_ba_session() function, the driver will be notified via
  31. * its @ampdu_action function, with the %IEEE80211_AMPDU_TX_START action.
  32. *
  33. * In response to that, the driver is later required to call the
  34. * ieee80211_start_tx_ba_cb() (or ieee80211_start_tx_ba_cb_irqsafe())
  35. * function, which will start the aggregation session.
  36. *
  37. * Similarly, when the aggregation session is stopped by
  38. * ieee80211_stop_tx_ba_session(), the driver's @ampdu_action function will
  39. * be called with the action %IEEE80211_AMPDU_TX_STOP. In this case, the
  40. * call must not fail, and the driver must later call ieee80211_stop_tx_ba_cb()
  41. * (or ieee80211_stop_tx_ba_cb_irqsafe()).
  42. */
  43. static void ieee80211_send_addba_request(struct ieee80211_sub_if_data *sdata,
  44. const u8 *da, u16 tid,
  45. u8 dialog_token, u16 start_seq_num,
  46. u16 agg_size, u16 timeout)
  47. {
  48. struct ieee80211_local *local = sdata->local;
  49. struct ieee80211_if_sta *ifsta = &sdata->u.sta;
  50. struct sk_buff *skb;
  51. struct ieee80211_mgmt *mgmt;
  52. u16 capab;
  53. skb = dev_alloc_skb(sizeof(*mgmt) + local->hw.extra_tx_headroom);
  54. if (!skb) {
  55. printk(KERN_ERR "%s: failed to allocate buffer "
  56. "for addba request frame\n", sdata->dev->name);
  57. return;
  58. }
  59. skb_reserve(skb, local->hw.extra_tx_headroom);
  60. mgmt = (struct ieee80211_mgmt *) skb_put(skb, 24);
  61. memset(mgmt, 0, 24);
  62. memcpy(mgmt->da, da, ETH_ALEN);
  63. memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN);
  64. if (sdata->vif.type == NL80211_IFTYPE_AP ||
  65. sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
  66. memcpy(mgmt->bssid, sdata->dev->dev_addr, ETH_ALEN);
  67. else
  68. memcpy(mgmt->bssid, ifsta->bssid, ETH_ALEN);
  69. mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
  70. IEEE80211_STYPE_ACTION);
  71. skb_put(skb, 1 + sizeof(mgmt->u.action.u.addba_req));
  72. mgmt->u.action.category = WLAN_CATEGORY_BACK;
  73. mgmt->u.action.u.addba_req.action_code = WLAN_ACTION_ADDBA_REQ;
  74. mgmt->u.action.u.addba_req.dialog_token = dialog_token;
  75. capab = (u16)(1 << 1); /* bit 1 aggregation policy */
  76. capab |= (u16)(tid << 2); /* bit 5:2 TID number */
  77. capab |= (u16)(agg_size << 6); /* bit 15:6 max size of aggergation */
  78. mgmt->u.action.u.addba_req.capab = cpu_to_le16(capab);
  79. mgmt->u.action.u.addba_req.timeout = cpu_to_le16(timeout);
  80. mgmt->u.action.u.addba_req.start_seq_num =
  81. cpu_to_le16(start_seq_num << 4);
  82. ieee80211_tx_skb(sdata, skb, 1);
  83. }
  84. void ieee80211_send_bar(struct ieee80211_sub_if_data *sdata, u8 *ra, u16 tid, u16 ssn)
  85. {
  86. struct ieee80211_local *local = sdata->local;
  87. struct sk_buff *skb;
  88. struct ieee80211_bar *bar;
  89. u16 bar_control = 0;
  90. skb = dev_alloc_skb(sizeof(*bar) + local->hw.extra_tx_headroom);
  91. if (!skb) {
  92. printk(KERN_ERR "%s: failed to allocate buffer for "
  93. "bar frame\n", sdata->dev->name);
  94. return;
  95. }
  96. skb_reserve(skb, local->hw.extra_tx_headroom);
  97. bar = (struct ieee80211_bar *)skb_put(skb, sizeof(*bar));
  98. memset(bar, 0, sizeof(*bar));
  99. bar->frame_control = cpu_to_le16(IEEE80211_FTYPE_CTL |
  100. IEEE80211_STYPE_BACK_REQ);
  101. memcpy(bar->ra, ra, ETH_ALEN);
  102. memcpy(bar->ta, sdata->dev->dev_addr, ETH_ALEN);
  103. bar_control |= (u16)IEEE80211_BAR_CTRL_ACK_POLICY_NORMAL;
  104. bar_control |= (u16)IEEE80211_BAR_CTRL_CBMTID_COMPRESSED_BA;
  105. bar_control |= (u16)(tid << 12);
  106. bar->control = cpu_to_le16(bar_control);
  107. bar->start_seq_num = cpu_to_le16(ssn);
  108. ieee80211_tx_skb(sdata, skb, 0);
  109. }
  110. static int __ieee80211_stop_tx_ba_session(struct ieee80211_local *local,
  111. struct sta_info *sta, u16 tid,
  112. enum ieee80211_back_parties initiator)
  113. {
  114. int ret;
  115. u8 *state;
  116. state = &sta->ampdu_mlme.tid_state_tx[tid];
  117. if (local->hw.ampdu_queues)
  118. ieee80211_stop_queue(&local->hw, sta->tid_to_tx_q[tid]);
  119. *state = HT_AGG_STATE_REQ_STOP_BA_MSK |
  120. (initiator << HT_AGG_STATE_INITIATOR_SHIFT);
  121. ret = local->ops->ampdu_action(&local->hw, IEEE80211_AMPDU_TX_STOP,
  122. &sta->sta, tid, NULL);
  123. /* HW shall not deny going back to legacy */
  124. if (WARN_ON(ret)) {
  125. *state = HT_AGG_STATE_OPERATIONAL;
  126. if (local->hw.ampdu_queues)
  127. ieee80211_wake_queue(&local->hw, sta->tid_to_tx_q[tid]);
  128. }
  129. return ret;
  130. }
  131. /*
  132. * After sending add Block Ack request we activated a timer until
  133. * add Block Ack response will arrive from the recipient.
  134. * If this timer expires sta_addba_resp_timer_expired will be executed.
  135. */
  136. static void sta_addba_resp_timer_expired(unsigned long data)
  137. {
  138. /* not an elegant detour, but there is no choice as the timer passes
  139. * only one argument, and both sta_info and TID are needed, so init
  140. * flow in sta_info_create gives the TID as data, while the timer_to_id
  141. * array gives the sta through container_of */
  142. u16 tid = *(u8 *)data;
  143. struct sta_info *sta = container_of((void *)data,
  144. struct sta_info, timer_to_tid[tid]);
  145. struct ieee80211_local *local = sta->local;
  146. u8 *state;
  147. state = &sta->ampdu_mlme.tid_state_tx[tid];
  148. /* check if the TID waits for addBA response */
  149. spin_lock_bh(&sta->lock);
  150. if (!(*state & HT_ADDBA_REQUESTED_MSK)) {
  151. spin_unlock_bh(&sta->lock);
  152. *state = HT_AGG_STATE_IDLE;
  153. #ifdef CONFIG_MAC80211_HT_DEBUG
  154. printk(KERN_DEBUG "timer expired on tid %d but we are not "
  155. "expecting addBA response there", tid);
  156. #endif
  157. return;
  158. }
  159. #ifdef CONFIG_MAC80211_HT_DEBUG
  160. printk(KERN_DEBUG "addBA response timer expired on tid %d\n", tid);
  161. #endif
  162. __ieee80211_stop_tx_ba_session(local, sta, tid, WLAN_BACK_INITIATOR);
  163. spin_unlock_bh(&sta->lock);
  164. }
  165. int ieee80211_start_tx_ba_session(struct ieee80211_hw *hw, u8 *ra, u16 tid)
  166. {
  167. struct ieee80211_local *local = hw_to_local(hw);
  168. struct sta_info *sta;
  169. struct ieee80211_sub_if_data *sdata;
  170. u16 start_seq_num;
  171. u8 *state;
  172. int ret = 0;
  173. if (WARN_ON(!local->ops->ampdu_action))
  174. return -EINVAL;
  175. if ((tid >= STA_TID_NUM) || !(hw->flags & IEEE80211_HW_AMPDU_AGGREGATION))
  176. return -EINVAL;
  177. #ifdef CONFIG_MAC80211_HT_DEBUG
  178. printk(KERN_DEBUG "Open BA session requested for %pM tid %u\n",
  179. ra, tid);
  180. #endif /* CONFIG_MAC80211_HT_DEBUG */
  181. rcu_read_lock();
  182. sta = sta_info_get(local, ra);
  183. if (!sta) {
  184. #ifdef CONFIG_MAC80211_HT_DEBUG
  185. printk(KERN_DEBUG "Could not find the station\n");
  186. #endif
  187. ret = -ENOENT;
  188. goto exit;
  189. }
  190. /*
  191. * The aggregation code is not prepared to handle
  192. * anything but STA/AP due to the BSSID handling.
  193. * IBSS could work in the code but isn't supported
  194. * by drivers or the standard.
  195. */
  196. if (sta->sdata->vif.type != NL80211_IFTYPE_STATION &&
  197. sta->sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
  198. sta->sdata->vif.type != NL80211_IFTYPE_AP) {
  199. ret = -EINVAL;
  200. goto exit;
  201. }
  202. spin_lock_bh(&sta->lock);
  203. /* we have tried too many times, receiver does not want A-MPDU */
  204. if (sta->ampdu_mlme.addba_req_num[tid] > HT_AGG_MAX_RETRIES) {
  205. ret = -EBUSY;
  206. goto err_unlock_sta;
  207. }
  208. state = &sta->ampdu_mlme.tid_state_tx[tid];
  209. /* check if the TID is not in aggregation flow already */
  210. if (*state != HT_AGG_STATE_IDLE) {
  211. #ifdef CONFIG_MAC80211_HT_DEBUG
  212. printk(KERN_DEBUG "BA request denied - session is not "
  213. "idle on tid %u\n", tid);
  214. #endif /* CONFIG_MAC80211_HT_DEBUG */
  215. ret = -EAGAIN;
  216. goto err_unlock_sta;
  217. }
  218. /* prepare A-MPDU MLME for Tx aggregation */
  219. sta->ampdu_mlme.tid_tx[tid] =
  220. kmalloc(sizeof(struct tid_ampdu_tx), GFP_ATOMIC);
  221. if (!sta->ampdu_mlme.tid_tx[tid]) {
  222. #ifdef CONFIG_MAC80211_HT_DEBUG
  223. if (net_ratelimit())
  224. printk(KERN_ERR "allocate tx mlme to tid %d failed\n",
  225. tid);
  226. #endif
  227. ret = -ENOMEM;
  228. goto err_unlock_sta;
  229. }
  230. /* Tx timer */
  231. sta->ampdu_mlme.tid_tx[tid]->addba_resp_timer.function =
  232. sta_addba_resp_timer_expired;
  233. sta->ampdu_mlme.tid_tx[tid]->addba_resp_timer.data =
  234. (unsigned long)&sta->timer_to_tid[tid];
  235. init_timer(&sta->ampdu_mlme.tid_tx[tid]->addba_resp_timer);
  236. if (hw->ampdu_queues) {
  237. /* create a new queue for this aggregation */
  238. ret = ieee80211_ht_agg_queue_add(local, sta, tid);
  239. /* case no queue is available to aggregation
  240. * don't switch to aggregation */
  241. if (ret) {
  242. #ifdef CONFIG_MAC80211_HT_DEBUG
  243. printk(KERN_DEBUG "BA request denied - "
  244. "queue unavailable for tid %d\n", tid);
  245. #endif /* CONFIG_MAC80211_HT_DEBUG */
  246. goto err_unlock_queue;
  247. }
  248. }
  249. sdata = sta->sdata;
  250. /* Ok, the Addba frame hasn't been sent yet, but if the driver calls the
  251. * call back right away, it must see that the flow has begun */
  252. *state |= HT_ADDBA_REQUESTED_MSK;
  253. /* This is slightly racy because the queue isn't stopped */
  254. start_seq_num = sta->tid_seq[tid];
  255. ret = local->ops->ampdu_action(hw, IEEE80211_AMPDU_TX_START,
  256. &sta->sta, tid, &start_seq_num);
  257. if (ret) {
  258. /* No need to requeue the packets in the agg queue, since we
  259. * held the tx lock: no packet could be enqueued to the newly
  260. * allocated queue */
  261. if (hw->ampdu_queues)
  262. ieee80211_ht_agg_queue_remove(local, sta, tid, 0);
  263. #ifdef CONFIG_MAC80211_HT_DEBUG
  264. printk(KERN_DEBUG "BA request denied - HW unavailable for"
  265. " tid %d\n", tid);
  266. #endif /* CONFIG_MAC80211_HT_DEBUG */
  267. *state = HT_AGG_STATE_IDLE;
  268. goto err_unlock_queue;
  269. }
  270. /* Will put all the packets in the new SW queue */
  271. if (hw->ampdu_queues)
  272. ieee80211_requeue(local, ieee802_1d_to_ac[tid]);
  273. spin_unlock_bh(&sta->lock);
  274. /* send an addBA request */
  275. sta->ampdu_mlme.dialog_token_allocator++;
  276. sta->ampdu_mlme.tid_tx[tid]->dialog_token =
  277. sta->ampdu_mlme.dialog_token_allocator;
  278. sta->ampdu_mlme.tid_tx[tid]->ssn = start_seq_num;
  279. ieee80211_send_addba_request(sta->sdata, ra, tid,
  280. sta->ampdu_mlme.tid_tx[tid]->dialog_token,
  281. sta->ampdu_mlme.tid_tx[tid]->ssn,
  282. 0x40, 5000);
  283. /* activate the timer for the recipient's addBA response */
  284. sta->ampdu_mlme.tid_tx[tid]->addba_resp_timer.expires =
  285. jiffies + ADDBA_RESP_INTERVAL;
  286. add_timer(&sta->ampdu_mlme.tid_tx[tid]->addba_resp_timer);
  287. #ifdef CONFIG_MAC80211_HT_DEBUG
  288. printk(KERN_DEBUG "activated addBA response timer on tid %d\n", tid);
  289. #endif
  290. goto exit;
  291. err_unlock_queue:
  292. kfree(sta->ampdu_mlme.tid_tx[tid]);
  293. sta->ampdu_mlme.tid_tx[tid] = NULL;
  294. ret = -EBUSY;
  295. err_unlock_sta:
  296. spin_unlock_bh(&sta->lock);
  297. exit:
  298. rcu_read_unlock();
  299. return ret;
  300. }
  301. EXPORT_SYMBOL(ieee80211_start_tx_ba_session);
  302. void ieee80211_start_tx_ba_cb(struct ieee80211_hw *hw, u8 *ra, u16 tid)
  303. {
  304. struct ieee80211_local *local = hw_to_local(hw);
  305. struct sta_info *sta;
  306. u8 *state;
  307. if (tid >= STA_TID_NUM) {
  308. #ifdef CONFIG_MAC80211_HT_DEBUG
  309. printk(KERN_DEBUG "Bad TID value: tid = %d (>= %d)\n",
  310. tid, STA_TID_NUM);
  311. #endif
  312. return;
  313. }
  314. rcu_read_lock();
  315. sta = sta_info_get(local, ra);
  316. if (!sta) {
  317. rcu_read_unlock();
  318. #ifdef CONFIG_MAC80211_HT_DEBUG
  319. printk(KERN_DEBUG "Could not find station: %pM\n", ra);
  320. #endif
  321. return;
  322. }
  323. state = &sta->ampdu_mlme.tid_state_tx[tid];
  324. spin_lock_bh(&sta->lock);
  325. if (!(*state & HT_ADDBA_REQUESTED_MSK)) {
  326. #ifdef CONFIG_MAC80211_HT_DEBUG
  327. printk(KERN_DEBUG "addBA was not requested yet, state is %d\n",
  328. *state);
  329. #endif
  330. spin_unlock_bh(&sta->lock);
  331. rcu_read_unlock();
  332. return;
  333. }
  334. WARN_ON_ONCE(*state & HT_ADDBA_DRV_READY_MSK);
  335. *state |= HT_ADDBA_DRV_READY_MSK;
  336. if (*state == HT_AGG_STATE_OPERATIONAL) {
  337. #ifdef CONFIG_MAC80211_HT_DEBUG
  338. printk(KERN_DEBUG "Aggregation is on for tid %d \n", tid);
  339. #endif
  340. if (hw->ampdu_queues)
  341. ieee80211_wake_queue(hw, sta->tid_to_tx_q[tid]);
  342. }
  343. spin_unlock_bh(&sta->lock);
  344. rcu_read_unlock();
  345. }
  346. EXPORT_SYMBOL(ieee80211_start_tx_ba_cb);
  347. void ieee80211_start_tx_ba_cb_irqsafe(struct ieee80211_hw *hw,
  348. const u8 *ra, u16 tid)
  349. {
  350. struct ieee80211_local *local = hw_to_local(hw);
  351. struct ieee80211_ra_tid *ra_tid;
  352. struct sk_buff *skb = dev_alloc_skb(0);
  353. if (unlikely(!skb)) {
  354. #ifdef CONFIG_MAC80211_HT_DEBUG
  355. if (net_ratelimit())
  356. printk(KERN_WARNING "%s: Not enough memory, "
  357. "dropping start BA session", skb->dev->name);
  358. #endif
  359. return;
  360. }
  361. ra_tid = (struct ieee80211_ra_tid *) &skb->cb;
  362. memcpy(&ra_tid->ra, ra, ETH_ALEN);
  363. ra_tid->tid = tid;
  364. skb->pkt_type = IEEE80211_ADDBA_MSG;
  365. skb_queue_tail(&local->skb_queue, skb);
  366. tasklet_schedule(&local->tasklet);
  367. }
  368. EXPORT_SYMBOL(ieee80211_start_tx_ba_cb_irqsafe);
  369. int ieee80211_stop_tx_ba_session(struct ieee80211_hw *hw,
  370. u8 *ra, u16 tid,
  371. enum ieee80211_back_parties initiator)
  372. {
  373. struct ieee80211_local *local = hw_to_local(hw);
  374. struct sta_info *sta;
  375. u8 *state;
  376. int ret = 0;
  377. if (WARN_ON(!local->ops->ampdu_action))
  378. return -EINVAL;
  379. if (tid >= STA_TID_NUM)
  380. return -EINVAL;
  381. rcu_read_lock();
  382. sta = sta_info_get(local, ra);
  383. if (!sta) {
  384. rcu_read_unlock();
  385. return -ENOENT;
  386. }
  387. /* check if the TID is in aggregation */
  388. state = &sta->ampdu_mlme.tid_state_tx[tid];
  389. spin_lock_bh(&sta->lock);
  390. if (*state != HT_AGG_STATE_OPERATIONAL) {
  391. ret = -ENOENT;
  392. goto unlock;
  393. }
  394. #ifdef CONFIG_MAC80211_HT_DEBUG
  395. printk(KERN_DEBUG "Tx BA session stop requested for %pM tid %u\n",
  396. ra, tid);
  397. #endif /* CONFIG_MAC80211_HT_DEBUG */
  398. ret = __ieee80211_stop_tx_ba_session(local, sta, tid, initiator);
  399. unlock:
  400. spin_unlock_bh(&sta->lock);
  401. rcu_read_unlock();
  402. return ret;
  403. }
  404. EXPORT_SYMBOL(ieee80211_stop_tx_ba_session);
  405. void ieee80211_stop_tx_ba_cb(struct ieee80211_hw *hw, u8 *ra, u8 tid)
  406. {
  407. struct ieee80211_local *local = hw_to_local(hw);
  408. struct sta_info *sta;
  409. u8 *state;
  410. int agg_queue;
  411. if (tid >= STA_TID_NUM) {
  412. #ifdef CONFIG_MAC80211_HT_DEBUG
  413. printk(KERN_DEBUG "Bad TID value: tid = %d (>= %d)\n",
  414. tid, STA_TID_NUM);
  415. #endif
  416. return;
  417. }
  418. #ifdef CONFIG_MAC80211_HT_DEBUG
  419. printk(KERN_DEBUG "Stopping Tx BA session for %pM tid %d\n",
  420. ra, tid);
  421. #endif /* CONFIG_MAC80211_HT_DEBUG */
  422. rcu_read_lock();
  423. sta = sta_info_get(local, ra);
  424. if (!sta) {
  425. #ifdef CONFIG_MAC80211_HT_DEBUG
  426. printk(KERN_DEBUG "Could not find station: %pM\n", ra);
  427. #endif
  428. rcu_read_unlock();
  429. return;
  430. }
  431. state = &sta->ampdu_mlme.tid_state_tx[tid];
  432. /* NOTE: no need to use sta->lock in this state check, as
  433. * ieee80211_stop_tx_ba_session will let only one stop call to
  434. * pass through per sta/tid
  435. */
  436. if ((*state & HT_AGG_STATE_REQ_STOP_BA_MSK) == 0) {
  437. #ifdef CONFIG_MAC80211_HT_DEBUG
  438. printk(KERN_DEBUG "unexpected callback to A-MPDU stop\n");
  439. #endif
  440. rcu_read_unlock();
  441. return;
  442. }
  443. if (*state & HT_AGG_STATE_INITIATOR_MSK)
  444. ieee80211_send_delba(sta->sdata, ra, tid,
  445. WLAN_BACK_INITIATOR, WLAN_REASON_QSTA_NOT_USE);
  446. if (hw->ampdu_queues) {
  447. agg_queue = sta->tid_to_tx_q[tid];
  448. ieee80211_ht_agg_queue_remove(local, sta, tid, 1);
  449. /* We just requeued the all the frames that were in the
  450. * removed queue, and since we might miss a softirq we do
  451. * netif_schedule_queue. ieee80211_wake_queue is not used
  452. * here as this queue is not necessarily stopped
  453. */
  454. netif_schedule_queue(netdev_get_tx_queue(local->mdev,
  455. agg_queue));
  456. }
  457. spin_lock_bh(&sta->lock);
  458. *state = HT_AGG_STATE_IDLE;
  459. sta->ampdu_mlme.addba_req_num[tid] = 0;
  460. kfree(sta->ampdu_mlme.tid_tx[tid]);
  461. sta->ampdu_mlme.tid_tx[tid] = NULL;
  462. spin_unlock_bh(&sta->lock);
  463. rcu_read_unlock();
  464. }
  465. EXPORT_SYMBOL(ieee80211_stop_tx_ba_cb);
  466. void ieee80211_stop_tx_ba_cb_irqsafe(struct ieee80211_hw *hw,
  467. const u8 *ra, u16 tid)
  468. {
  469. struct ieee80211_local *local = hw_to_local(hw);
  470. struct ieee80211_ra_tid *ra_tid;
  471. struct sk_buff *skb = dev_alloc_skb(0);
  472. if (unlikely(!skb)) {
  473. #ifdef CONFIG_MAC80211_HT_DEBUG
  474. if (net_ratelimit())
  475. printk(KERN_WARNING "%s: Not enough memory, "
  476. "dropping stop BA session", skb->dev->name);
  477. #endif
  478. return;
  479. }
  480. ra_tid = (struct ieee80211_ra_tid *) &skb->cb;
  481. memcpy(&ra_tid->ra, ra, ETH_ALEN);
  482. ra_tid->tid = tid;
  483. skb->pkt_type = IEEE80211_DELBA_MSG;
  484. skb_queue_tail(&local->skb_queue, skb);
  485. tasklet_schedule(&local->tasklet);
  486. }
  487. EXPORT_SYMBOL(ieee80211_stop_tx_ba_cb_irqsafe);
  488. void ieee80211_process_addba_resp(struct ieee80211_local *local,
  489. struct sta_info *sta,
  490. struct ieee80211_mgmt *mgmt,
  491. size_t len)
  492. {
  493. struct ieee80211_hw *hw = &local->hw;
  494. u16 capab;
  495. u16 tid, start_seq_num;
  496. u8 *state;
  497. capab = le16_to_cpu(mgmt->u.action.u.addba_resp.capab);
  498. tid = (capab & IEEE80211_ADDBA_PARAM_TID_MASK) >> 2;
  499. state = &sta->ampdu_mlme.tid_state_tx[tid];
  500. spin_lock_bh(&sta->lock);
  501. if (!(*state & HT_ADDBA_REQUESTED_MSK)) {
  502. spin_unlock_bh(&sta->lock);
  503. return;
  504. }
  505. if (mgmt->u.action.u.addba_resp.dialog_token !=
  506. sta->ampdu_mlme.tid_tx[tid]->dialog_token) {
  507. spin_unlock_bh(&sta->lock);
  508. #ifdef CONFIG_MAC80211_HT_DEBUG
  509. printk(KERN_DEBUG "wrong addBA response token, tid %d\n", tid);
  510. #endif /* CONFIG_MAC80211_HT_DEBUG */
  511. return;
  512. }
  513. del_timer_sync(&sta->ampdu_mlme.tid_tx[tid]->addba_resp_timer);
  514. #ifdef CONFIG_MAC80211_HT_DEBUG
  515. printk(KERN_DEBUG "switched off addBA timer for tid %d \n", tid);
  516. #endif /* CONFIG_MAC80211_HT_DEBUG */
  517. if (le16_to_cpu(mgmt->u.action.u.addba_resp.status)
  518. == WLAN_STATUS_SUCCESS) {
  519. *state |= HT_ADDBA_RECEIVED_MSK;
  520. sta->ampdu_mlme.addba_req_num[tid] = 0;
  521. if (*state == HT_AGG_STATE_OPERATIONAL &&
  522. local->hw.ampdu_queues)
  523. ieee80211_wake_queue(hw, sta->tid_to_tx_q[tid]);
  524. if (local->ops->ampdu_action) {
  525. (void)local->ops->ampdu_action(hw,
  526. IEEE80211_AMPDU_TX_RESUME,
  527. &sta->sta, tid, &start_seq_num);
  528. }
  529. #ifdef CONFIG_MAC80211_HT_DEBUG
  530. printk(KERN_DEBUG "Resuming TX aggregation for tid %d\n", tid);
  531. #endif /* CONFIG_MAC80211_HT_DEBUG */
  532. spin_unlock_bh(&sta->lock);
  533. } else {
  534. sta->ampdu_mlme.addba_req_num[tid]++;
  535. __ieee80211_stop_tx_ba_session(local, sta, tid,
  536. WLAN_BACK_INITIATOR);
  537. spin_unlock_bh(&sta->lock);
  538. }
  539. }