tx.c 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029
  1. /******************************************************************************
  2. *
  3. * This file is provided under a dual BSD/GPLv2 license. When using or
  4. * redistributing this file, you may do so under either license.
  5. *
  6. * GPL LICENSE SUMMARY
  7. *
  8. * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
  9. * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of version 2 of the GNU General Public License as
  13. * published by the Free Software Foundation.
  14. *
  15. * This program is distributed in the hope that it will be useful, but
  16. * WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18. * General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
  23. * USA
  24. *
  25. * The full GNU General Public License is included in this distribution
  26. * in the file called COPYING.
  27. *
  28. * Contact Information:
  29. * Intel Linux Wireless <ilw@linux.intel.com>
  30. * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  31. *
  32. * BSD LICENSE
  33. *
  34. * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
  35. * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH
  36. * All rights reserved.
  37. *
  38. * Redistribution and use in source and binary forms, with or without
  39. * modification, are permitted provided that the following conditions
  40. * are met:
  41. *
  42. * * Redistributions of source code must retain the above copyright
  43. * notice, this list of conditions and the following disclaimer.
  44. * * Redistributions in binary form must reproduce the above copyright
  45. * notice, this list of conditions and the following disclaimer in
  46. * the documentation and/or other materials provided with the
  47. * distribution.
  48. * * Neither the name Intel Corporation nor the names of its
  49. * contributors may be used to endorse or promote products derived
  50. * from this software without specific prior written permission.
  51. *
  52. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  53. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  54. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  55. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  56. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  57. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  58. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  59. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  60. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  61. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  62. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  63. *
  64. *****************************************************************************/
  65. #include <linux/ieee80211.h>
  66. #include <linux/etherdevice.h>
  67. #include "iwl-trans.h"
  68. #include "iwl-eeprom-parse.h"
  69. #include "mvm.h"
  70. #include "sta.h"
  71. /*
  72. * Sets most of the Tx cmd's fields
  73. */
  74. static void iwl_mvm_set_tx_cmd(struct iwl_mvm *mvm, struct sk_buff *skb,
  75. struct iwl_tx_cmd *tx_cmd,
  76. struct ieee80211_tx_info *info, u8 sta_id)
  77. {
  78. struct ieee80211_hdr *hdr = (void *)skb->data;
  79. __le16 fc = hdr->frame_control;
  80. u32 tx_flags = le32_to_cpu(tx_cmd->tx_flags);
  81. u32 len = skb->len + FCS_LEN;
  82. u8 ac;
  83. if (!(info->flags & IEEE80211_TX_CTL_NO_ACK))
  84. tx_flags |= TX_CMD_FLG_ACK;
  85. else
  86. tx_flags &= ~TX_CMD_FLG_ACK;
  87. if (ieee80211_is_probe_resp(fc))
  88. tx_flags |= TX_CMD_FLG_TSF;
  89. else if (ieee80211_is_back_req(fc))
  90. tx_flags |= TX_CMD_FLG_ACK | TX_CMD_FLG_BAR;
  91. if (ieee80211_has_morefrags(fc))
  92. tx_flags |= TX_CMD_FLG_MORE_FRAG;
  93. if (ieee80211_is_data_qos(fc)) {
  94. u8 *qc = ieee80211_get_qos_ctl(hdr);
  95. tx_cmd->tid_tspec = qc[0] & 0xf;
  96. tx_flags &= ~TX_CMD_FLG_SEQ_CTL;
  97. } else {
  98. tx_cmd->tid_tspec = IWL_TID_NON_QOS;
  99. if (info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ)
  100. tx_flags |= TX_CMD_FLG_SEQ_CTL;
  101. else
  102. tx_flags &= ~TX_CMD_FLG_SEQ_CTL;
  103. }
  104. /* tid_tspec will default to 0 = BE when QOS isn't enabled */
  105. ac = tid_to_mac80211_ac[tx_cmd->tid_tspec];
  106. tx_flags |= iwl_mvm_bt_coex_tx_prio(mvm, hdr, info, ac) <<
  107. TX_CMD_FLG_BT_PRIO_POS;
  108. if (ieee80211_is_mgmt(fc)) {
  109. if (ieee80211_is_assoc_req(fc) || ieee80211_is_reassoc_req(fc))
  110. tx_cmd->pm_frame_timeout = cpu_to_le16(3);
  111. else
  112. tx_cmd->pm_frame_timeout = cpu_to_le16(2);
  113. /* The spec allows Action frames in A-MPDU, we don't support
  114. * it
  115. */
  116. WARN_ON_ONCE(info->flags & IEEE80211_TX_CTL_AMPDU);
  117. } else if (info->control.flags & IEEE80211_TX_CTRL_PORT_CTRL_PROTO) {
  118. tx_cmd->pm_frame_timeout = cpu_to_le16(2);
  119. } else {
  120. tx_cmd->pm_frame_timeout = 0;
  121. }
  122. if (ieee80211_is_data(fc) && len > mvm->rts_threshold &&
  123. !is_multicast_ether_addr(ieee80211_get_DA(hdr)))
  124. tx_flags |= TX_CMD_FLG_PROT_REQUIRE;
  125. if ((mvm->fw->ucode_capa.capa[0] &
  126. IWL_UCODE_TLV_CAPA_TXPOWER_INSERTION_SUPPORT) &&
  127. ieee80211_action_contains_tpc(skb))
  128. tx_flags |= TX_CMD_FLG_WRITE_TX_POWER;
  129. tx_cmd->tx_flags = cpu_to_le32(tx_flags);
  130. /* Total # bytes to be transmitted */
  131. tx_cmd->len = cpu_to_le16((u16)skb->len);
  132. tx_cmd->next_frame_len = 0;
  133. tx_cmd->life_time = cpu_to_le32(TX_CMD_LIFE_TIME_INFINITE);
  134. tx_cmd->sta_id = sta_id;
  135. }
  136. /*
  137. * Sets the fields in the Tx cmd that are rate related
  138. */
  139. static void iwl_mvm_set_tx_cmd_rate(struct iwl_mvm *mvm,
  140. struct iwl_tx_cmd *tx_cmd,
  141. struct ieee80211_tx_info *info,
  142. struct ieee80211_sta *sta,
  143. __le16 fc)
  144. {
  145. u32 rate_flags;
  146. int rate_idx;
  147. u8 rate_plcp;
  148. /* Set retry limit on RTS packets */
  149. tx_cmd->rts_retry_limit = IWL_RTS_DFAULT_RETRY_LIMIT;
  150. /* Set retry limit on DATA packets and Probe Responses*/
  151. if (ieee80211_is_probe_resp(fc)) {
  152. tx_cmd->data_retry_limit = IWL_MGMT_DFAULT_RETRY_LIMIT;
  153. tx_cmd->rts_retry_limit =
  154. min(tx_cmd->data_retry_limit, tx_cmd->rts_retry_limit);
  155. } else if (ieee80211_is_back_req(fc)) {
  156. tx_cmd->data_retry_limit = IWL_BAR_DFAULT_RETRY_LIMIT;
  157. } else {
  158. tx_cmd->data_retry_limit = IWL_DEFAULT_TX_RETRY;
  159. }
  160. /*
  161. * for data packets, rate info comes from the table inside the fw. This
  162. * table is controlled by LINK_QUALITY commands
  163. */
  164. if (ieee80211_is_data(fc) && sta) {
  165. tx_cmd->initial_rate_index = 0;
  166. tx_cmd->tx_flags |= cpu_to_le32(TX_CMD_FLG_STA_RATE);
  167. return;
  168. } else if (ieee80211_is_back_req(fc)) {
  169. tx_cmd->tx_flags |=
  170. cpu_to_le32(TX_CMD_FLG_ACK | TX_CMD_FLG_BAR);
  171. }
  172. /* HT rate doesn't make sense for a non data frame */
  173. WARN_ONCE(info->control.rates[0].flags & IEEE80211_TX_RC_MCS,
  174. "Got an HT rate (flags:0x%x/mcs:%d) for a non data frame (fc:0x%x)\n",
  175. info->control.rates[0].flags,
  176. info->control.rates[0].idx,
  177. le16_to_cpu(fc));
  178. rate_idx = info->control.rates[0].idx;
  179. /* if the rate isn't a well known legacy rate, take the lowest one */
  180. if (rate_idx < 0 || rate_idx > IWL_RATE_COUNT_LEGACY)
  181. rate_idx = rate_lowest_index(
  182. &mvm->nvm_data->bands[info->band], sta);
  183. /* For 5 GHZ band, remap mac80211 rate indices into driver indices */
  184. if (info->band == IEEE80211_BAND_5GHZ)
  185. rate_idx += IWL_FIRST_OFDM_RATE;
  186. /* For 2.4 GHZ band, check that there is no need to remap */
  187. BUILD_BUG_ON(IWL_FIRST_CCK_RATE != 0);
  188. /* Get PLCP rate for tx_cmd->rate_n_flags */
  189. rate_plcp = iwl_mvm_mac80211_idx_to_hwrate(rate_idx);
  190. mvm->mgmt_last_antenna_idx =
  191. iwl_mvm_next_antenna(mvm, mvm->fw->valid_tx_ant,
  192. mvm->mgmt_last_antenna_idx);
  193. if (info->band == IEEE80211_BAND_2GHZ &&
  194. !iwl_mvm_bt_coex_is_shared_ant_avail(mvm))
  195. rate_flags = BIT(mvm->cfg->non_shared_ant) << RATE_MCS_ANT_POS;
  196. else
  197. rate_flags =
  198. BIT(mvm->mgmt_last_antenna_idx) << RATE_MCS_ANT_POS;
  199. /* Set CCK flag as needed */
  200. if ((rate_idx >= IWL_FIRST_CCK_RATE) && (rate_idx <= IWL_LAST_CCK_RATE))
  201. rate_flags |= RATE_MCS_CCK_MSK;
  202. /* Set the rate in the TX cmd */
  203. tx_cmd->rate_n_flags = cpu_to_le32((u32)rate_plcp | rate_flags);
  204. }
  205. /*
  206. * Sets the fields in the Tx cmd that are crypto related
  207. */
  208. static void iwl_mvm_set_tx_cmd_crypto(struct iwl_mvm *mvm,
  209. struct ieee80211_tx_info *info,
  210. struct iwl_tx_cmd *tx_cmd,
  211. struct sk_buff *skb_frag)
  212. {
  213. struct ieee80211_key_conf *keyconf = info->control.hw_key;
  214. switch (keyconf->cipher) {
  215. case WLAN_CIPHER_SUITE_CCMP:
  216. tx_cmd->sec_ctl = TX_CMD_SEC_CCM;
  217. memcpy(tx_cmd->key, keyconf->key, keyconf->keylen);
  218. if (info->flags & IEEE80211_TX_CTL_AMPDU)
  219. tx_cmd->tx_flags |= cpu_to_le32(TX_CMD_FLG_CCMP_AGG);
  220. break;
  221. case WLAN_CIPHER_SUITE_TKIP:
  222. tx_cmd->sec_ctl = TX_CMD_SEC_TKIP;
  223. ieee80211_get_tkip_p2k(keyconf, skb_frag, tx_cmd->key);
  224. break;
  225. case WLAN_CIPHER_SUITE_WEP104:
  226. tx_cmd->sec_ctl |= TX_CMD_SEC_KEY128;
  227. /* fall through */
  228. case WLAN_CIPHER_SUITE_WEP40:
  229. tx_cmd->sec_ctl |= TX_CMD_SEC_WEP |
  230. ((keyconf->keyidx << TX_CMD_SEC_WEP_KEY_IDX_POS) &
  231. TX_CMD_SEC_WEP_KEY_IDX_MSK);
  232. memcpy(&tx_cmd->key[3], keyconf->key, keyconf->keylen);
  233. break;
  234. default:
  235. tx_cmd->sec_ctl |= TX_CMD_SEC_EXT;
  236. }
  237. }
  238. /*
  239. * Allocates and sets the Tx cmd the driver data pointers in the skb
  240. */
  241. static struct iwl_device_cmd *
  242. iwl_mvm_set_tx_params(struct iwl_mvm *mvm, struct sk_buff *skb,
  243. struct ieee80211_sta *sta, u8 sta_id)
  244. {
  245. struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
  246. struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
  247. struct iwl_device_cmd *dev_cmd;
  248. struct iwl_tx_cmd *tx_cmd;
  249. dev_cmd = iwl_trans_alloc_tx_cmd(mvm->trans);
  250. if (unlikely(!dev_cmd))
  251. return NULL;
  252. memset(dev_cmd, 0, sizeof(*dev_cmd));
  253. dev_cmd->hdr.cmd = TX_CMD;
  254. tx_cmd = (struct iwl_tx_cmd *)dev_cmd->payload;
  255. if (info->control.hw_key)
  256. iwl_mvm_set_tx_cmd_crypto(mvm, info, tx_cmd, skb);
  257. iwl_mvm_set_tx_cmd(mvm, skb, tx_cmd, info, sta_id);
  258. iwl_mvm_set_tx_cmd_rate(mvm, tx_cmd, info, sta, hdr->frame_control);
  259. memset(&info->status, 0, sizeof(info->status));
  260. info->driver_data[0] = NULL;
  261. info->driver_data[1] = dev_cmd;
  262. return dev_cmd;
  263. }
  264. int iwl_mvm_tx_skb_non_sta(struct iwl_mvm *mvm, struct sk_buff *skb)
  265. {
  266. struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
  267. struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
  268. struct iwl_device_cmd *dev_cmd;
  269. struct iwl_tx_cmd *tx_cmd;
  270. u8 sta_id;
  271. if (WARN_ON_ONCE(info->flags & IEEE80211_TX_CTL_AMPDU))
  272. return -1;
  273. if (WARN_ON_ONCE(info->flags & IEEE80211_TX_CTL_SEND_AFTER_DTIM &&
  274. (!info->control.vif ||
  275. info->hw_queue != info->control.vif->cab_queue)))
  276. return -1;
  277. /*
  278. * IWL_MVM_OFFCHANNEL_QUEUE is used for ROC packets that can be used
  279. * in 2 different types of vifs, P2P & STATION. P2P uses the offchannel
  280. * queue. STATION (HS2.0) uses the auxiliary context of the FW,
  281. * and hence needs to be sent on the aux queue
  282. */
  283. if (IEEE80211_SKB_CB(skb)->hw_queue == IWL_MVM_OFFCHANNEL_QUEUE &&
  284. info->control.vif->type == NL80211_IFTYPE_STATION)
  285. IEEE80211_SKB_CB(skb)->hw_queue = mvm->aux_queue;
  286. /*
  287. * If the interface on which frame is sent is the P2P_DEVICE
  288. * or an AP/GO interface use the broadcast station associated
  289. * with it; otherwise use the AUX station.
  290. */
  291. if (info->control.vif &&
  292. (info->control.vif->type == NL80211_IFTYPE_P2P_DEVICE ||
  293. info->control.vif->type == NL80211_IFTYPE_AP)) {
  294. struct iwl_mvm_vif *mvmvif =
  295. iwl_mvm_vif_from_mac80211(info->control.vif);
  296. sta_id = mvmvif->bcast_sta.sta_id;
  297. } else {
  298. sta_id = mvm->aux_sta.sta_id;
  299. }
  300. IWL_DEBUG_TX(mvm, "station Id %d, queue=%d\n", sta_id, info->hw_queue);
  301. dev_cmd = iwl_mvm_set_tx_params(mvm, skb, NULL, sta_id);
  302. if (!dev_cmd)
  303. return -1;
  304. /* From now on, we cannot access info->control */
  305. tx_cmd = (struct iwl_tx_cmd *)dev_cmd->payload;
  306. /* Copy MAC header from skb into command buffer */
  307. memcpy(tx_cmd->hdr, hdr, ieee80211_hdrlen(hdr->frame_control));
  308. if (iwl_trans_tx(mvm->trans, skb, dev_cmd, info->hw_queue)) {
  309. iwl_trans_free_tx_cmd(mvm->trans, dev_cmd);
  310. return -1;
  311. }
  312. return 0;
  313. }
  314. /*
  315. * Sets the fields in the Tx cmd that are crypto related
  316. */
  317. int iwl_mvm_tx_skb(struct iwl_mvm *mvm, struct sk_buff *skb,
  318. struct ieee80211_sta *sta)
  319. {
  320. struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
  321. struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
  322. struct iwl_mvm_sta *mvmsta;
  323. struct iwl_device_cmd *dev_cmd;
  324. struct iwl_tx_cmd *tx_cmd;
  325. __le16 fc;
  326. u16 seq_number = 0;
  327. u8 tid = IWL_MAX_TID_COUNT;
  328. u8 txq_id = info->hw_queue;
  329. bool is_data_qos = false, is_ampdu = false;
  330. mvmsta = iwl_mvm_sta_from_mac80211(sta);
  331. fc = hdr->frame_control;
  332. if (WARN_ON_ONCE(!mvmsta))
  333. return -1;
  334. if (WARN_ON_ONCE(mvmsta->sta_id == IWL_MVM_STATION_COUNT))
  335. return -1;
  336. dev_cmd = iwl_mvm_set_tx_params(mvm, skb, sta, mvmsta->sta_id);
  337. if (!dev_cmd)
  338. goto drop;
  339. tx_cmd = (struct iwl_tx_cmd *)dev_cmd->payload;
  340. /* From now on, we cannot access info->control */
  341. /*
  342. * we handle that entirely ourselves -- for uAPSD the firmware
  343. * will always send a notification, and for PS-Poll responses
  344. * we'll notify mac80211 when getting frame status
  345. */
  346. info->flags &= ~IEEE80211_TX_STATUS_EOSP;
  347. spin_lock(&mvmsta->lock);
  348. if (ieee80211_is_data_qos(fc) && !ieee80211_is_qos_nullfunc(fc)) {
  349. u8 *qc = NULL;
  350. qc = ieee80211_get_qos_ctl(hdr);
  351. tid = qc[0] & IEEE80211_QOS_CTL_TID_MASK;
  352. if (WARN_ON_ONCE(tid >= IWL_MAX_TID_COUNT))
  353. goto drop_unlock_sta;
  354. seq_number = mvmsta->tid_data[tid].seq_number;
  355. seq_number &= IEEE80211_SCTL_SEQ;
  356. hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG);
  357. hdr->seq_ctrl |= cpu_to_le16(seq_number);
  358. is_data_qos = true;
  359. is_ampdu = info->flags & IEEE80211_TX_CTL_AMPDU;
  360. }
  361. /* Copy MAC header from skb into command buffer */
  362. memcpy(tx_cmd->hdr, hdr, ieee80211_hdrlen(fc));
  363. WARN_ON_ONCE(info->flags & IEEE80211_TX_CTL_SEND_AFTER_DTIM);
  364. if (is_ampdu) {
  365. if (WARN_ON_ONCE(mvmsta->tid_data[tid].state != IWL_AGG_ON))
  366. goto drop_unlock_sta;
  367. txq_id = mvmsta->tid_data[tid].txq_id;
  368. }
  369. IWL_DEBUG_TX(mvm, "TX to [%d|%d] Q:%d - seq: 0x%x\n", mvmsta->sta_id,
  370. tid, txq_id, IEEE80211_SEQ_TO_SN(seq_number));
  371. if (iwl_trans_tx(mvm->trans, skb, dev_cmd, txq_id))
  372. goto drop_unlock_sta;
  373. if (is_data_qos && !ieee80211_has_morefrags(fc))
  374. mvmsta->tid_data[tid].seq_number = seq_number + 0x10;
  375. spin_unlock(&mvmsta->lock);
  376. if (txq_id < mvm->first_agg_queue)
  377. atomic_inc(&mvm->pending_frames[mvmsta->sta_id]);
  378. return 0;
  379. drop_unlock_sta:
  380. iwl_trans_free_tx_cmd(mvm->trans, dev_cmd);
  381. spin_unlock(&mvmsta->lock);
  382. drop:
  383. return -1;
  384. }
  385. static void iwl_mvm_check_ratid_empty(struct iwl_mvm *mvm,
  386. struct ieee80211_sta *sta, u8 tid)
  387. {
  388. struct iwl_mvm_sta *mvmsta = iwl_mvm_sta_from_mac80211(sta);
  389. struct iwl_mvm_tid_data *tid_data = &mvmsta->tid_data[tid];
  390. struct ieee80211_vif *vif = mvmsta->vif;
  391. lockdep_assert_held(&mvmsta->lock);
  392. if ((tid_data->state == IWL_AGG_ON ||
  393. tid_data->state == IWL_EMPTYING_HW_QUEUE_DELBA) &&
  394. iwl_mvm_tid_queued(tid_data) == 0) {
  395. /*
  396. * Now that this aggregation queue is empty tell mac80211 so it
  397. * knows we no longer have frames buffered for the station on
  398. * this TID (for the TIM bitmap calculation.)
  399. */
  400. ieee80211_sta_set_buffered(sta, tid, false);
  401. }
  402. if (tid_data->ssn != tid_data->next_reclaimed)
  403. return;
  404. switch (tid_data->state) {
  405. case IWL_EMPTYING_HW_QUEUE_ADDBA:
  406. IWL_DEBUG_TX_QUEUES(mvm,
  407. "Can continue addBA flow ssn = next_recl = %d\n",
  408. tid_data->next_reclaimed);
  409. tid_data->state = IWL_AGG_STARTING;
  410. ieee80211_start_tx_ba_cb_irqsafe(vif, sta->addr, tid);
  411. break;
  412. case IWL_EMPTYING_HW_QUEUE_DELBA:
  413. IWL_DEBUG_TX_QUEUES(mvm,
  414. "Can continue DELBA flow ssn = next_recl = %d\n",
  415. tid_data->next_reclaimed);
  416. iwl_mvm_disable_txq(mvm, tid_data->txq_id);
  417. tid_data->state = IWL_AGG_OFF;
  418. /*
  419. * we can't hold the mutex - but since we are after a sequence
  420. * point (call to iwl_mvm_disable_txq(), so we don't even need
  421. * a memory barrier.
  422. */
  423. mvm->queue_to_mac80211[tid_data->txq_id] =
  424. IWL_INVALID_MAC80211_QUEUE;
  425. ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid);
  426. break;
  427. default:
  428. break;
  429. }
  430. }
  431. #ifdef CONFIG_IWLWIFI_DEBUG
  432. const char *iwl_mvm_get_tx_fail_reason(u32 status)
  433. {
  434. #define TX_STATUS_FAIL(x) case TX_STATUS_FAIL_ ## x: return #x
  435. #define TX_STATUS_POSTPONE(x) case TX_STATUS_POSTPONE_ ## x: return #x
  436. switch (status & TX_STATUS_MSK) {
  437. case TX_STATUS_SUCCESS:
  438. return "SUCCESS";
  439. TX_STATUS_POSTPONE(DELAY);
  440. TX_STATUS_POSTPONE(FEW_BYTES);
  441. TX_STATUS_POSTPONE(BT_PRIO);
  442. TX_STATUS_POSTPONE(QUIET_PERIOD);
  443. TX_STATUS_POSTPONE(CALC_TTAK);
  444. TX_STATUS_FAIL(INTERNAL_CROSSED_RETRY);
  445. TX_STATUS_FAIL(SHORT_LIMIT);
  446. TX_STATUS_FAIL(LONG_LIMIT);
  447. TX_STATUS_FAIL(UNDERRUN);
  448. TX_STATUS_FAIL(DRAIN_FLOW);
  449. TX_STATUS_FAIL(RFKILL_FLUSH);
  450. TX_STATUS_FAIL(LIFE_EXPIRE);
  451. TX_STATUS_FAIL(DEST_PS);
  452. TX_STATUS_FAIL(HOST_ABORTED);
  453. TX_STATUS_FAIL(BT_RETRY);
  454. TX_STATUS_FAIL(STA_INVALID);
  455. TX_STATUS_FAIL(FRAG_DROPPED);
  456. TX_STATUS_FAIL(TID_DISABLE);
  457. TX_STATUS_FAIL(FIFO_FLUSHED);
  458. TX_STATUS_FAIL(SMALL_CF_POLL);
  459. TX_STATUS_FAIL(FW_DROP);
  460. TX_STATUS_FAIL(STA_COLOR_MISMATCH);
  461. }
  462. return "UNKNOWN";
  463. #undef TX_STATUS_FAIL
  464. #undef TX_STATUS_POSTPONE
  465. }
  466. #endif /* CONFIG_IWLWIFI_DEBUG */
  467. void iwl_mvm_hwrate_to_tx_rate(u32 rate_n_flags,
  468. enum ieee80211_band band,
  469. struct ieee80211_tx_rate *r)
  470. {
  471. if (rate_n_flags & RATE_HT_MCS_GF_MSK)
  472. r->flags |= IEEE80211_TX_RC_GREEN_FIELD;
  473. switch (rate_n_flags & RATE_MCS_CHAN_WIDTH_MSK) {
  474. case RATE_MCS_CHAN_WIDTH_20:
  475. break;
  476. case RATE_MCS_CHAN_WIDTH_40:
  477. r->flags |= IEEE80211_TX_RC_40_MHZ_WIDTH;
  478. break;
  479. case RATE_MCS_CHAN_WIDTH_80:
  480. r->flags |= IEEE80211_TX_RC_80_MHZ_WIDTH;
  481. break;
  482. case RATE_MCS_CHAN_WIDTH_160:
  483. r->flags |= IEEE80211_TX_RC_160_MHZ_WIDTH;
  484. break;
  485. }
  486. if (rate_n_flags & RATE_MCS_SGI_MSK)
  487. r->flags |= IEEE80211_TX_RC_SHORT_GI;
  488. if (rate_n_flags & RATE_MCS_HT_MSK) {
  489. r->flags |= IEEE80211_TX_RC_MCS;
  490. r->idx = rate_n_flags & RATE_HT_MCS_INDEX_MSK;
  491. } else if (rate_n_flags & RATE_MCS_VHT_MSK) {
  492. ieee80211_rate_set_vht(
  493. r, rate_n_flags & RATE_VHT_MCS_RATE_CODE_MSK,
  494. ((rate_n_flags & RATE_VHT_MCS_NSS_MSK) >>
  495. RATE_VHT_MCS_NSS_POS) + 1);
  496. r->flags |= IEEE80211_TX_RC_VHT_MCS;
  497. } else {
  498. r->idx = iwl_mvm_legacy_rate_to_mac80211_idx(rate_n_flags,
  499. band);
  500. }
  501. }
  502. /**
  503. * translate ucode response to mac80211 tx status control values
  504. */
  505. static void iwl_mvm_hwrate_to_tx_status(u32 rate_n_flags,
  506. struct ieee80211_tx_info *info)
  507. {
  508. struct ieee80211_tx_rate *r = &info->status.rates[0];
  509. info->status.antenna =
  510. ((rate_n_flags & RATE_MCS_ANT_ABC_MSK) >> RATE_MCS_ANT_POS);
  511. iwl_mvm_hwrate_to_tx_rate(rate_n_flags, info->band, r);
  512. }
  513. static void iwl_mvm_rx_tx_cmd_single(struct iwl_mvm *mvm,
  514. struct iwl_rx_packet *pkt)
  515. {
  516. struct ieee80211_sta *sta;
  517. u16 sequence = le16_to_cpu(pkt->hdr.sequence);
  518. int txq_id = SEQ_TO_QUEUE(sequence);
  519. struct iwl_mvm_tx_resp *tx_resp = (void *)pkt->data;
  520. int sta_id = IWL_MVM_TX_RES_GET_RA(tx_resp->ra_tid);
  521. int tid = IWL_MVM_TX_RES_GET_TID(tx_resp->ra_tid);
  522. u32 status = le16_to_cpu(tx_resp->status.status);
  523. u16 ssn = iwl_mvm_get_scd_ssn(tx_resp);
  524. struct iwl_mvm_sta *mvmsta;
  525. struct sk_buff_head skbs;
  526. u8 skb_freed = 0;
  527. u16 next_reclaimed, seq_ctl;
  528. __skb_queue_head_init(&skbs);
  529. seq_ctl = le16_to_cpu(tx_resp->seq_ctl);
  530. /* we can free until ssn % q.n_bd not inclusive */
  531. iwl_trans_reclaim(mvm->trans, txq_id, ssn, &skbs);
  532. while (!skb_queue_empty(&skbs)) {
  533. struct sk_buff *skb = __skb_dequeue(&skbs);
  534. struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
  535. skb_freed++;
  536. iwl_trans_free_tx_cmd(mvm->trans, info->driver_data[1]);
  537. memset(&info->status, 0, sizeof(info->status));
  538. info->flags &= ~IEEE80211_TX_CTL_AMPDU;
  539. /* inform mac80211 about what happened with the frame */
  540. switch (status & TX_STATUS_MSK) {
  541. case TX_STATUS_SUCCESS:
  542. case TX_STATUS_DIRECT_DONE:
  543. info->flags |= IEEE80211_TX_STAT_ACK;
  544. break;
  545. case TX_STATUS_FAIL_DEST_PS:
  546. info->flags |= IEEE80211_TX_STAT_TX_FILTERED;
  547. break;
  548. default:
  549. break;
  550. }
  551. info->status.rates[0].count = tx_resp->failure_frame + 1;
  552. iwl_mvm_hwrate_to_tx_status(le32_to_cpu(tx_resp->initial_rate),
  553. info);
  554. /* Single frame failure in an AMPDU queue => send BAR */
  555. if (txq_id >= mvm->first_agg_queue &&
  556. !(info->flags & IEEE80211_TX_STAT_ACK))
  557. info->flags |= IEEE80211_TX_STAT_AMPDU_NO_BACK;
  558. /* W/A FW bug: seq_ctl is wrong when the status isn't success */
  559. if (status != TX_STATUS_SUCCESS) {
  560. struct ieee80211_hdr *hdr = (void *)skb->data;
  561. seq_ctl = le16_to_cpu(hdr->seq_ctrl);
  562. }
  563. BUILD_BUG_ON(ARRAY_SIZE(info->status.status_driver_data) < 1);
  564. info->status.status_driver_data[0] =
  565. (void *)(uintptr_t)tx_resp->reduced_tpc;
  566. ieee80211_tx_status(mvm->hw, skb);
  567. }
  568. if (txq_id >= mvm->first_agg_queue) {
  569. /* If this is an aggregation queue, we use the ssn since:
  570. * ssn = wifi seq_num % 256.
  571. * The seq_ctl is the sequence control of the packet to which
  572. * this Tx response relates. But if there is a hole in the
  573. * bitmap of the BA we received, this Tx response may allow to
  574. * reclaim the hole and all the subsequent packets that were
  575. * already acked. In that case, seq_ctl != ssn, and the next
  576. * packet to be reclaimed will be ssn and not seq_ctl. In that
  577. * case, several packets will be reclaimed even if
  578. * frame_count = 1.
  579. *
  580. * The ssn is the index (% 256) of the latest packet that has
  581. * treated (acked / dropped) + 1.
  582. */
  583. next_reclaimed = ssn;
  584. } else {
  585. /* The next packet to be reclaimed is the one after this one */
  586. next_reclaimed = IEEE80211_SEQ_TO_SN(seq_ctl + 0x10);
  587. }
  588. IWL_DEBUG_TX_REPLY(mvm,
  589. "TXQ %d status %s (0x%08x)\n",
  590. txq_id, iwl_mvm_get_tx_fail_reason(status), status);
  591. IWL_DEBUG_TX_REPLY(mvm,
  592. "\t\t\t\tinitial_rate 0x%x retries %d, idx=%d ssn=%d next_reclaimed=0x%x seq_ctl=0x%x\n",
  593. le32_to_cpu(tx_resp->initial_rate),
  594. tx_resp->failure_frame, SEQ_TO_INDEX(sequence),
  595. ssn, next_reclaimed, seq_ctl);
  596. rcu_read_lock();
  597. sta = rcu_dereference(mvm->fw_id_to_mac_id[sta_id]);
  598. /*
  599. * sta can't be NULL otherwise it'd mean that the sta has been freed in
  600. * the firmware while we still have packets for it in the Tx queues.
  601. */
  602. if (WARN_ON_ONCE(!sta))
  603. goto out;
  604. if (!IS_ERR(sta)) {
  605. mvmsta = iwl_mvm_sta_from_mac80211(sta);
  606. if (tid != IWL_TID_NON_QOS) {
  607. struct iwl_mvm_tid_data *tid_data =
  608. &mvmsta->tid_data[tid];
  609. spin_lock_bh(&mvmsta->lock);
  610. tid_data->next_reclaimed = next_reclaimed;
  611. IWL_DEBUG_TX_REPLY(mvm, "Next reclaimed packet:%d\n",
  612. next_reclaimed);
  613. iwl_mvm_check_ratid_empty(mvm, sta, tid);
  614. spin_unlock_bh(&mvmsta->lock);
  615. }
  616. if (mvmsta->next_status_eosp) {
  617. mvmsta->next_status_eosp = false;
  618. ieee80211_sta_eosp(sta);
  619. }
  620. } else {
  621. mvmsta = NULL;
  622. }
  623. /*
  624. * If the txq is not an AMPDU queue, there is no chance we freed
  625. * several skbs. Check that out...
  626. */
  627. if (txq_id >= mvm->first_agg_queue)
  628. goto out;
  629. /* We can't free more than one frame at once on a shared queue */
  630. WARN_ON(skb_freed > 1);
  631. /* If we have still frames for this STA nothing to do here */
  632. if (!atomic_sub_and_test(skb_freed, &mvm->pending_frames[sta_id]))
  633. goto out;
  634. if (mvmsta && mvmsta->vif->type == NL80211_IFTYPE_AP) {
  635. /*
  636. * If there are no pending frames for this STA and
  637. * the tx to this station is not disabled, notify
  638. * mac80211 that this station can now wake up in its
  639. * STA table.
  640. * If mvmsta is not NULL, sta is valid.
  641. */
  642. spin_lock_bh(&mvmsta->lock);
  643. if (!mvmsta->disable_tx)
  644. ieee80211_sta_block_awake(mvm->hw, sta, false);
  645. spin_unlock_bh(&mvmsta->lock);
  646. }
  647. if (PTR_ERR(sta) == -EBUSY || PTR_ERR(sta) == -ENOENT) {
  648. /*
  649. * We are draining and this was the last packet - pre_rcu_remove
  650. * has been called already. We might be after the
  651. * synchronize_net already.
  652. * Don't rely on iwl_mvm_rm_sta to see the empty Tx queues.
  653. */
  654. set_bit(sta_id, mvm->sta_drained);
  655. schedule_work(&mvm->sta_drained_wk);
  656. }
  657. out:
  658. rcu_read_unlock();
  659. }
  660. #ifdef CONFIG_IWLWIFI_DEBUG
  661. #define AGG_TX_STATE_(x) case AGG_TX_STATE_ ## x: return #x
  662. static const char *iwl_get_agg_tx_status(u16 status)
  663. {
  664. switch (status & AGG_TX_STATE_STATUS_MSK) {
  665. AGG_TX_STATE_(TRANSMITTED);
  666. AGG_TX_STATE_(UNDERRUN);
  667. AGG_TX_STATE_(BT_PRIO);
  668. AGG_TX_STATE_(FEW_BYTES);
  669. AGG_TX_STATE_(ABORT);
  670. AGG_TX_STATE_(LAST_SENT_TTL);
  671. AGG_TX_STATE_(LAST_SENT_TRY_CNT);
  672. AGG_TX_STATE_(LAST_SENT_BT_KILL);
  673. AGG_TX_STATE_(SCD_QUERY);
  674. AGG_TX_STATE_(TEST_BAD_CRC32);
  675. AGG_TX_STATE_(RESPONSE);
  676. AGG_TX_STATE_(DUMP_TX);
  677. AGG_TX_STATE_(DELAY_TX);
  678. }
  679. return "UNKNOWN";
  680. }
  681. static void iwl_mvm_rx_tx_cmd_agg_dbg(struct iwl_mvm *mvm,
  682. struct iwl_rx_packet *pkt)
  683. {
  684. struct iwl_mvm_tx_resp *tx_resp = (void *)pkt->data;
  685. struct agg_tx_status *frame_status = &tx_resp->status;
  686. int i;
  687. for (i = 0; i < tx_resp->frame_count; i++) {
  688. u16 fstatus = le16_to_cpu(frame_status[i].status);
  689. IWL_DEBUG_TX_REPLY(mvm,
  690. "status %s (0x%04x), try-count (%d) seq (0x%x)\n",
  691. iwl_get_agg_tx_status(fstatus),
  692. fstatus & AGG_TX_STATE_STATUS_MSK,
  693. (fstatus & AGG_TX_STATE_TRY_CNT_MSK) >>
  694. AGG_TX_STATE_TRY_CNT_POS,
  695. le16_to_cpu(frame_status[i].sequence));
  696. }
  697. }
  698. #else
  699. static void iwl_mvm_rx_tx_cmd_agg_dbg(struct iwl_mvm *mvm,
  700. struct iwl_rx_packet *pkt)
  701. {}
  702. #endif /* CONFIG_IWLWIFI_DEBUG */
  703. static void iwl_mvm_rx_tx_cmd_agg(struct iwl_mvm *mvm,
  704. struct iwl_rx_packet *pkt)
  705. {
  706. struct iwl_mvm_tx_resp *tx_resp = (void *)pkt->data;
  707. int sta_id = IWL_MVM_TX_RES_GET_RA(tx_resp->ra_tid);
  708. int tid = IWL_MVM_TX_RES_GET_TID(tx_resp->ra_tid);
  709. u16 sequence = le16_to_cpu(pkt->hdr.sequence);
  710. struct ieee80211_sta *sta;
  711. if (WARN_ON_ONCE(SEQ_TO_QUEUE(sequence) < mvm->first_agg_queue))
  712. return;
  713. if (WARN_ON_ONCE(tid == IWL_TID_NON_QOS))
  714. return;
  715. iwl_mvm_rx_tx_cmd_agg_dbg(mvm, pkt);
  716. rcu_read_lock();
  717. sta = rcu_dereference(mvm->fw_id_to_mac_id[sta_id]);
  718. if (!WARN_ON_ONCE(IS_ERR_OR_NULL(sta))) {
  719. struct iwl_mvm_sta *mvmsta = iwl_mvm_sta_from_mac80211(sta);
  720. mvmsta->tid_data[tid].rate_n_flags =
  721. le32_to_cpu(tx_resp->initial_rate);
  722. mvmsta->tid_data[tid].reduced_tpc = tx_resp->reduced_tpc;
  723. }
  724. rcu_read_unlock();
  725. }
  726. int iwl_mvm_rx_tx_cmd(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb,
  727. struct iwl_device_cmd *cmd)
  728. {
  729. struct iwl_rx_packet *pkt = rxb_addr(rxb);
  730. struct iwl_mvm_tx_resp *tx_resp = (void *)pkt->data;
  731. if (tx_resp->frame_count == 1)
  732. iwl_mvm_rx_tx_cmd_single(mvm, pkt);
  733. else
  734. iwl_mvm_rx_tx_cmd_agg(mvm, pkt);
  735. return 0;
  736. }
  737. static void iwl_mvm_tx_info_from_ba_notif(struct ieee80211_tx_info *info,
  738. struct iwl_mvm_ba_notif *ba_notif,
  739. struct iwl_mvm_tid_data *tid_data)
  740. {
  741. info->flags |= IEEE80211_TX_STAT_AMPDU;
  742. info->status.ampdu_ack_len = ba_notif->txed_2_done;
  743. info->status.ampdu_len = ba_notif->txed;
  744. iwl_mvm_hwrate_to_tx_status(tid_data->rate_n_flags,
  745. info);
  746. info->status.status_driver_data[0] =
  747. (void *)(uintptr_t)tid_data->reduced_tpc;
  748. }
  749. int iwl_mvm_rx_ba_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb,
  750. struct iwl_device_cmd *cmd)
  751. {
  752. struct iwl_rx_packet *pkt = rxb_addr(rxb);
  753. struct iwl_mvm_ba_notif *ba_notif = (void *)pkt->data;
  754. struct sk_buff_head reclaimed_skbs;
  755. struct iwl_mvm_tid_data *tid_data;
  756. struct ieee80211_sta *sta;
  757. struct iwl_mvm_sta *mvmsta;
  758. struct sk_buff *skb;
  759. int sta_id, tid, freed;
  760. /* "flow" corresponds to Tx queue */
  761. u16 scd_flow = le16_to_cpu(ba_notif->scd_flow);
  762. /* "ssn" is start of block-ack Tx window, corresponds to index
  763. * (in Tx queue's circular buffer) of first TFD/frame in window */
  764. u16 ba_resp_scd_ssn = le16_to_cpu(ba_notif->scd_ssn);
  765. sta_id = ba_notif->sta_id;
  766. tid = ba_notif->tid;
  767. rcu_read_lock();
  768. sta = rcu_dereference(mvm->fw_id_to_mac_id[sta_id]);
  769. /* Reclaiming frames for a station that has been deleted ? */
  770. if (WARN_ON_ONCE(IS_ERR_OR_NULL(sta))) {
  771. rcu_read_unlock();
  772. return 0;
  773. }
  774. mvmsta = iwl_mvm_sta_from_mac80211(sta);
  775. tid_data = &mvmsta->tid_data[tid];
  776. if (WARN_ONCE(tid_data->txq_id != scd_flow, "Q %d, tid %d, flow %d",
  777. tid_data->txq_id, tid, scd_flow)) {
  778. rcu_read_unlock();
  779. return 0;
  780. }
  781. spin_lock_bh(&mvmsta->lock);
  782. __skb_queue_head_init(&reclaimed_skbs);
  783. /*
  784. * Release all TFDs before the SSN, i.e. all TFDs in front of
  785. * block-ack window (we assume that they've been successfully
  786. * transmitted ... if not, it's too late anyway).
  787. */
  788. iwl_trans_reclaim(mvm->trans, scd_flow, ba_resp_scd_ssn,
  789. &reclaimed_skbs);
  790. IWL_DEBUG_TX_REPLY(mvm,
  791. "BA_NOTIFICATION Received from %pM, sta_id = %d\n",
  792. (u8 *)&ba_notif->sta_addr_lo32,
  793. ba_notif->sta_id);
  794. IWL_DEBUG_TX_REPLY(mvm,
  795. "TID = %d, SeqCtl = %d, bitmap = 0x%llx, scd_flow = %d, scd_ssn = %d sent:%d, acked:%d\n",
  796. ba_notif->tid, le16_to_cpu(ba_notif->seq_ctl),
  797. (unsigned long long)le64_to_cpu(ba_notif->bitmap),
  798. scd_flow, ba_resp_scd_ssn, ba_notif->txed,
  799. ba_notif->txed_2_done);
  800. tid_data->next_reclaimed = ba_resp_scd_ssn;
  801. iwl_mvm_check_ratid_empty(mvm, sta, tid);
  802. freed = 0;
  803. skb_queue_walk(&reclaimed_skbs, skb) {
  804. struct ieee80211_hdr *hdr = (void *)skb->data;
  805. struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
  806. if (ieee80211_is_data_qos(hdr->frame_control))
  807. freed++;
  808. else
  809. WARN_ON_ONCE(1);
  810. iwl_trans_free_tx_cmd(mvm->trans, info->driver_data[1]);
  811. memset(&info->status, 0, sizeof(info->status));
  812. /* Packet was transmitted successfully, failures come as single
  813. * frames because before failing a frame the firmware transmits
  814. * it without aggregation at least once.
  815. */
  816. info->flags |= IEEE80211_TX_STAT_ACK;
  817. /* this is the first skb we deliver in this batch */
  818. /* put the rate scaling data there */
  819. if (freed == 1)
  820. iwl_mvm_tx_info_from_ba_notif(info, ba_notif, tid_data);
  821. }
  822. spin_unlock_bh(&mvmsta->lock);
  823. /* We got a BA notif with 0 acked or scd_ssn didn't progress which is
  824. * possible (i.e. first MPDU in the aggregation wasn't acked)
  825. * Still it's important to update RS about sent vs. acked.
  826. */
  827. if (skb_queue_empty(&reclaimed_skbs)) {
  828. struct ieee80211_tx_info ba_info = {};
  829. struct ieee80211_chanctx_conf *chanctx_conf = NULL;
  830. if (mvmsta->vif)
  831. chanctx_conf =
  832. rcu_dereference(mvmsta->vif->chanctx_conf);
  833. if (WARN_ON_ONCE(!chanctx_conf))
  834. goto out;
  835. ba_info.band = chanctx_conf->def.chan->band;
  836. iwl_mvm_tx_info_from_ba_notif(&ba_info, ba_notif, tid_data);
  837. IWL_DEBUG_TX_REPLY(mvm, "No reclaim. Update rs directly\n");
  838. iwl_mvm_rs_tx_status(mvm, sta, tid, &ba_info);
  839. }
  840. out:
  841. rcu_read_unlock();
  842. while (!skb_queue_empty(&reclaimed_skbs)) {
  843. skb = __skb_dequeue(&reclaimed_skbs);
  844. ieee80211_tx_status(mvm->hw, skb);
  845. }
  846. return 0;
  847. }
  848. int iwl_mvm_flush_tx_path(struct iwl_mvm *mvm, u32 tfd_msk, bool sync)
  849. {
  850. int ret;
  851. struct iwl_tx_path_flush_cmd flush_cmd = {
  852. .queues_ctl = cpu_to_le32(tfd_msk),
  853. .flush_ctl = cpu_to_le16(DUMP_TX_FIFO_FLUSH),
  854. };
  855. u32 flags = sync ? 0 : CMD_ASYNC;
  856. ret = iwl_mvm_send_cmd_pdu(mvm, TXPATH_FLUSH, flags,
  857. sizeof(flush_cmd), &flush_cmd);
  858. if (ret)
  859. IWL_ERR(mvm, "Failed to send flush command (%d)\n", ret);
  860. return ret;
  861. }