tx.c 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032
  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 for a non data frame 0x%x\n",
  175. info->control.rates[0].flags);
  176. rate_idx = info->control.rates[0].idx;
  177. /* if the rate isn't a well known legacy rate, take the lowest one */
  178. if (rate_idx < 0 || rate_idx > IWL_RATE_COUNT_LEGACY)
  179. rate_idx = rate_lowest_index(
  180. &mvm->nvm_data->bands[info->band], sta);
  181. /* For 5 GHZ band, remap mac80211 rate indices into driver indices */
  182. if (info->band == IEEE80211_BAND_5GHZ)
  183. rate_idx += IWL_FIRST_OFDM_RATE;
  184. /* For 2.4 GHZ band, check that there is no need to remap */
  185. BUILD_BUG_ON(IWL_FIRST_CCK_RATE != 0);
  186. /* Get PLCP rate for tx_cmd->rate_n_flags */
  187. rate_plcp = iwl_mvm_mac80211_idx_to_hwrate(rate_idx);
  188. mvm->mgmt_last_antenna_idx =
  189. iwl_mvm_next_antenna(mvm, mvm->fw->valid_tx_ant,
  190. mvm->mgmt_last_antenna_idx);
  191. if (info->band == IEEE80211_BAND_2GHZ &&
  192. !iwl_mvm_bt_coex_is_shared_ant_avail(mvm))
  193. rate_flags = BIT(mvm->cfg->non_shared_ant) << RATE_MCS_ANT_POS;
  194. else
  195. rate_flags =
  196. BIT(mvm->mgmt_last_antenna_idx) << RATE_MCS_ANT_POS;
  197. /* Set CCK flag as needed */
  198. if ((rate_idx >= IWL_FIRST_CCK_RATE) && (rate_idx <= IWL_LAST_CCK_RATE))
  199. rate_flags |= RATE_MCS_CCK_MSK;
  200. /* Set the rate in the TX cmd */
  201. tx_cmd->rate_n_flags = cpu_to_le32((u32)rate_plcp | rate_flags);
  202. }
  203. /*
  204. * Sets the fields in the Tx cmd that are crypto related
  205. */
  206. static void iwl_mvm_set_tx_cmd_crypto(struct iwl_mvm *mvm,
  207. struct ieee80211_tx_info *info,
  208. struct iwl_tx_cmd *tx_cmd,
  209. struct sk_buff *skb_frag)
  210. {
  211. struct ieee80211_key_conf *keyconf = info->control.hw_key;
  212. switch (keyconf->cipher) {
  213. case WLAN_CIPHER_SUITE_CCMP:
  214. tx_cmd->sec_ctl = TX_CMD_SEC_CCM;
  215. memcpy(tx_cmd->key, keyconf->key, keyconf->keylen);
  216. if (info->flags & IEEE80211_TX_CTL_AMPDU)
  217. tx_cmd->tx_flags |= cpu_to_le32(TX_CMD_FLG_CCMP_AGG);
  218. break;
  219. case WLAN_CIPHER_SUITE_TKIP:
  220. tx_cmd->sec_ctl = TX_CMD_SEC_TKIP;
  221. ieee80211_get_tkip_p2k(keyconf, skb_frag, tx_cmd->key);
  222. break;
  223. case WLAN_CIPHER_SUITE_WEP104:
  224. tx_cmd->sec_ctl |= TX_CMD_SEC_KEY128;
  225. /* fall through */
  226. case WLAN_CIPHER_SUITE_WEP40:
  227. tx_cmd->sec_ctl |= TX_CMD_SEC_WEP |
  228. ((keyconf->keyidx << TX_CMD_SEC_WEP_KEY_IDX_POS) &
  229. TX_CMD_SEC_WEP_KEY_IDX_MSK);
  230. memcpy(&tx_cmd->key[3], keyconf->key, keyconf->keylen);
  231. break;
  232. default:
  233. tx_cmd->sec_ctl |= TX_CMD_SEC_EXT;
  234. }
  235. }
  236. /*
  237. * Allocates and sets the Tx cmd the driver data pointers in the skb
  238. */
  239. static struct iwl_device_cmd *
  240. iwl_mvm_set_tx_params(struct iwl_mvm *mvm, struct sk_buff *skb,
  241. struct ieee80211_sta *sta, u8 sta_id)
  242. {
  243. struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
  244. struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
  245. struct iwl_device_cmd *dev_cmd;
  246. struct iwl_tx_cmd *tx_cmd;
  247. dev_cmd = iwl_trans_alloc_tx_cmd(mvm->trans);
  248. if (unlikely(!dev_cmd))
  249. return NULL;
  250. memset(dev_cmd, 0, sizeof(*dev_cmd));
  251. dev_cmd->hdr.cmd = TX_CMD;
  252. tx_cmd = (struct iwl_tx_cmd *)dev_cmd->payload;
  253. if (info->control.hw_key)
  254. iwl_mvm_set_tx_cmd_crypto(mvm, info, tx_cmd, skb);
  255. iwl_mvm_set_tx_cmd(mvm, skb, tx_cmd, info, sta_id);
  256. iwl_mvm_set_tx_cmd_rate(mvm, tx_cmd, info, sta, hdr->frame_control);
  257. memset(&info->status, 0, sizeof(info->status));
  258. info->driver_data[0] = NULL;
  259. info->driver_data[1] = dev_cmd;
  260. return dev_cmd;
  261. }
  262. int iwl_mvm_tx_skb_non_sta(struct iwl_mvm *mvm, struct sk_buff *skb)
  263. {
  264. struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
  265. struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
  266. struct iwl_device_cmd *dev_cmd;
  267. struct iwl_tx_cmd *tx_cmd;
  268. u8 sta_id;
  269. if (WARN_ON_ONCE(info->flags & IEEE80211_TX_CTL_AMPDU))
  270. return -1;
  271. if (WARN_ON_ONCE(info->flags & IEEE80211_TX_CTL_SEND_AFTER_DTIM &&
  272. (!info->control.vif ||
  273. info->hw_queue != info->control.vif->cab_queue)))
  274. return -1;
  275. /*
  276. * IWL_MVM_OFFCHANNEL_QUEUE is used for ROC packets that can be used
  277. * in 2 different types of vifs, P2P & STATION. P2P uses the offchannel
  278. * queue. STATION (HS2.0) uses the auxiliary context of the FW,
  279. * and hence needs to be sent on the aux queue
  280. */
  281. if (IEEE80211_SKB_CB(skb)->hw_queue == IWL_MVM_OFFCHANNEL_QUEUE &&
  282. info->control.vif->type == NL80211_IFTYPE_STATION)
  283. IEEE80211_SKB_CB(skb)->hw_queue = mvm->aux_queue;
  284. /*
  285. * If the interface on which frame is sent is the P2P_DEVICE
  286. * or an AP/GO interface use the broadcast station associated
  287. * with it; otherwise use the AUX station.
  288. */
  289. if (info->control.vif &&
  290. (info->control.vif->type == NL80211_IFTYPE_P2P_DEVICE ||
  291. info->control.vif->type == NL80211_IFTYPE_AP)) {
  292. struct iwl_mvm_vif *mvmvif =
  293. iwl_mvm_vif_from_mac80211(info->control.vif);
  294. sta_id = mvmvif->bcast_sta.sta_id;
  295. } else {
  296. sta_id = mvm->aux_sta.sta_id;
  297. }
  298. IWL_DEBUG_TX(mvm, "station Id %d, queue=%d\n", sta_id, info->hw_queue);
  299. dev_cmd = iwl_mvm_set_tx_params(mvm, skb, NULL, sta_id);
  300. if (!dev_cmd)
  301. return -1;
  302. /* From now on, we cannot access info->control */
  303. tx_cmd = (struct iwl_tx_cmd *)dev_cmd->payload;
  304. /* Copy MAC header from skb into command buffer */
  305. memcpy(tx_cmd->hdr, hdr, ieee80211_hdrlen(hdr->frame_control));
  306. if (iwl_trans_tx(mvm->trans, skb, dev_cmd, info->hw_queue)) {
  307. iwl_trans_free_tx_cmd(mvm->trans, dev_cmd);
  308. return -1;
  309. }
  310. return 0;
  311. }
  312. /*
  313. * Sets the fields in the Tx cmd that are crypto related
  314. */
  315. int iwl_mvm_tx_skb(struct iwl_mvm *mvm, struct sk_buff *skb,
  316. struct ieee80211_sta *sta)
  317. {
  318. struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
  319. struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
  320. struct iwl_mvm_sta *mvmsta;
  321. struct iwl_device_cmd *dev_cmd;
  322. struct iwl_tx_cmd *tx_cmd;
  323. __le16 fc;
  324. u16 seq_number = 0;
  325. u8 tid = IWL_MAX_TID_COUNT;
  326. u8 txq_id = info->hw_queue;
  327. bool is_data_qos = false, is_ampdu = false;
  328. mvmsta = iwl_mvm_sta_from_mac80211(sta);
  329. fc = hdr->frame_control;
  330. if (WARN_ON_ONCE(!mvmsta))
  331. return -1;
  332. if (WARN_ON_ONCE(mvmsta->sta_id == IWL_MVM_STATION_COUNT))
  333. return -1;
  334. dev_cmd = iwl_mvm_set_tx_params(mvm, skb, sta, mvmsta->sta_id);
  335. if (!dev_cmd)
  336. goto drop;
  337. tx_cmd = (struct iwl_tx_cmd *)dev_cmd->payload;
  338. /* From now on, we cannot access info->control */
  339. /*
  340. * we handle that entirely ourselves -- for uAPSD the firmware
  341. * will always send a notification, and for PS-Poll responses
  342. * we'll notify mac80211 when getting frame status
  343. */
  344. info->flags &= ~IEEE80211_TX_STATUS_EOSP;
  345. spin_lock(&mvmsta->lock);
  346. if (ieee80211_is_data_qos(fc) && !ieee80211_is_qos_nullfunc(fc)) {
  347. u8 *qc = NULL;
  348. qc = ieee80211_get_qos_ctl(hdr);
  349. tid = qc[0] & IEEE80211_QOS_CTL_TID_MASK;
  350. if (WARN_ON_ONCE(tid >= IWL_MAX_TID_COUNT))
  351. goto drop_unlock_sta;
  352. seq_number = mvmsta->tid_data[tid].seq_number;
  353. seq_number &= IEEE80211_SCTL_SEQ;
  354. hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG);
  355. hdr->seq_ctrl |= cpu_to_le16(seq_number);
  356. is_data_qos = true;
  357. is_ampdu = info->flags & IEEE80211_TX_CTL_AMPDU;
  358. }
  359. /* Copy MAC header from skb into command buffer */
  360. memcpy(tx_cmd->hdr, hdr, ieee80211_hdrlen(fc));
  361. WARN_ON_ONCE(info->flags & IEEE80211_TX_CTL_SEND_AFTER_DTIM);
  362. if (is_ampdu) {
  363. if (WARN_ON_ONCE(mvmsta->tid_data[tid].state != IWL_AGG_ON))
  364. goto drop_unlock_sta;
  365. txq_id = mvmsta->tid_data[tid].txq_id;
  366. }
  367. IWL_DEBUG_TX(mvm, "TX to [%d|%d] Q:%d - seq: 0x%x\n", mvmsta->sta_id,
  368. tid, txq_id, IEEE80211_SEQ_TO_SN(seq_number));
  369. if (iwl_trans_tx(mvm->trans, skb, dev_cmd, txq_id))
  370. goto drop_unlock_sta;
  371. if (is_data_qos && !ieee80211_has_morefrags(fc))
  372. mvmsta->tid_data[tid].seq_number = seq_number + 0x10;
  373. spin_unlock(&mvmsta->lock);
  374. if (txq_id < mvm->first_agg_queue)
  375. atomic_inc(&mvm->pending_frames[mvmsta->sta_id]);
  376. return 0;
  377. drop_unlock_sta:
  378. iwl_trans_free_tx_cmd(mvm->trans, dev_cmd);
  379. spin_unlock(&mvmsta->lock);
  380. drop:
  381. return -1;
  382. }
  383. static void iwl_mvm_check_ratid_empty(struct iwl_mvm *mvm,
  384. struct ieee80211_sta *sta, u8 tid)
  385. {
  386. struct iwl_mvm_sta *mvmsta = iwl_mvm_sta_from_mac80211(sta);
  387. struct iwl_mvm_tid_data *tid_data = &mvmsta->tid_data[tid];
  388. struct ieee80211_vif *vif = mvmsta->vif;
  389. lockdep_assert_held(&mvmsta->lock);
  390. if ((tid_data->state == IWL_AGG_ON ||
  391. tid_data->state == IWL_EMPTYING_HW_QUEUE_DELBA) &&
  392. iwl_mvm_tid_queued(tid_data) == 0) {
  393. /*
  394. * Now that this aggregation queue is empty tell mac80211 so it
  395. * knows we no longer have frames buffered for the station on
  396. * this TID (for the TIM bitmap calculation.)
  397. */
  398. ieee80211_sta_set_buffered(sta, tid, false);
  399. }
  400. if (tid_data->ssn != tid_data->next_reclaimed)
  401. return;
  402. switch (tid_data->state) {
  403. case IWL_EMPTYING_HW_QUEUE_ADDBA:
  404. IWL_DEBUG_TX_QUEUES(mvm,
  405. "Can continue addBA flow ssn = next_recl = %d\n",
  406. tid_data->next_reclaimed);
  407. tid_data->state = IWL_AGG_STARTING;
  408. ieee80211_start_tx_ba_cb_irqsafe(vif, sta->addr, tid);
  409. break;
  410. case IWL_EMPTYING_HW_QUEUE_DELBA:
  411. IWL_DEBUG_TX_QUEUES(mvm,
  412. "Can continue DELBA flow ssn = next_recl = %d\n",
  413. tid_data->next_reclaimed);
  414. iwl_mvm_disable_txq(mvm, tid_data->txq_id);
  415. tid_data->state = IWL_AGG_OFF;
  416. /*
  417. * we can't hold the mutex - but since we are after a sequence
  418. * point (call to iwl_mvm_disable_txq(), so we don't even need
  419. * a memory barrier.
  420. */
  421. mvm->queue_to_mac80211[tid_data->txq_id] =
  422. IWL_INVALID_MAC80211_QUEUE;
  423. ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid);
  424. break;
  425. default:
  426. break;
  427. }
  428. }
  429. #ifdef CONFIG_IWLWIFI_DEBUG
  430. const char *iwl_mvm_get_tx_fail_reason(u32 status)
  431. {
  432. #define TX_STATUS_FAIL(x) case TX_STATUS_FAIL_ ## x: return #x
  433. #define TX_STATUS_POSTPONE(x) case TX_STATUS_POSTPONE_ ## x: return #x
  434. switch (status & TX_STATUS_MSK) {
  435. case TX_STATUS_SUCCESS:
  436. return "SUCCESS";
  437. TX_STATUS_POSTPONE(DELAY);
  438. TX_STATUS_POSTPONE(FEW_BYTES);
  439. TX_STATUS_POSTPONE(BT_PRIO);
  440. TX_STATUS_POSTPONE(QUIET_PERIOD);
  441. TX_STATUS_POSTPONE(CALC_TTAK);
  442. TX_STATUS_FAIL(INTERNAL_CROSSED_RETRY);
  443. TX_STATUS_FAIL(SHORT_LIMIT);
  444. TX_STATUS_FAIL(LONG_LIMIT);
  445. TX_STATUS_FAIL(UNDERRUN);
  446. TX_STATUS_FAIL(DRAIN_FLOW);
  447. TX_STATUS_FAIL(RFKILL_FLUSH);
  448. TX_STATUS_FAIL(LIFE_EXPIRE);
  449. TX_STATUS_FAIL(DEST_PS);
  450. TX_STATUS_FAIL(HOST_ABORTED);
  451. TX_STATUS_FAIL(BT_RETRY);
  452. TX_STATUS_FAIL(STA_INVALID);
  453. TX_STATUS_FAIL(FRAG_DROPPED);
  454. TX_STATUS_FAIL(TID_DISABLE);
  455. TX_STATUS_FAIL(FIFO_FLUSHED);
  456. TX_STATUS_FAIL(SMALL_CF_POLL);
  457. TX_STATUS_FAIL(FW_DROP);
  458. TX_STATUS_FAIL(STA_COLOR_MISMATCH);
  459. }
  460. return "UNKNOWN";
  461. #undef TX_STATUS_FAIL
  462. #undef TX_STATUS_POSTPONE
  463. }
  464. #endif /* CONFIG_IWLWIFI_DEBUG */
  465. void iwl_mvm_hwrate_to_tx_rate(u32 rate_n_flags,
  466. enum ieee80211_band band,
  467. struct ieee80211_tx_rate *r)
  468. {
  469. if (rate_n_flags & RATE_HT_MCS_GF_MSK)
  470. r->flags |= IEEE80211_TX_RC_GREEN_FIELD;
  471. switch (rate_n_flags & RATE_MCS_CHAN_WIDTH_MSK) {
  472. case RATE_MCS_CHAN_WIDTH_20:
  473. break;
  474. case RATE_MCS_CHAN_WIDTH_40:
  475. r->flags |= IEEE80211_TX_RC_40_MHZ_WIDTH;
  476. break;
  477. case RATE_MCS_CHAN_WIDTH_80:
  478. r->flags |= IEEE80211_TX_RC_80_MHZ_WIDTH;
  479. break;
  480. case RATE_MCS_CHAN_WIDTH_160:
  481. r->flags |= IEEE80211_TX_RC_160_MHZ_WIDTH;
  482. break;
  483. }
  484. if (rate_n_flags & RATE_MCS_SGI_MSK)
  485. r->flags |= IEEE80211_TX_RC_SHORT_GI;
  486. if (rate_n_flags & RATE_MCS_HT_MSK) {
  487. r->flags |= IEEE80211_TX_RC_MCS;
  488. r->idx = rate_n_flags & RATE_HT_MCS_INDEX_MSK;
  489. } else if (rate_n_flags & RATE_MCS_VHT_MSK) {
  490. ieee80211_rate_set_vht(
  491. r, rate_n_flags & RATE_VHT_MCS_RATE_CODE_MSK,
  492. ((rate_n_flags & RATE_VHT_MCS_NSS_MSK) >>
  493. RATE_VHT_MCS_NSS_POS) + 1);
  494. r->flags |= IEEE80211_TX_RC_VHT_MCS;
  495. } else {
  496. r->idx = iwl_mvm_legacy_rate_to_mac80211_idx(rate_n_flags,
  497. band);
  498. }
  499. }
  500. /**
  501. * translate ucode response to mac80211 tx status control values
  502. */
  503. static void iwl_mvm_hwrate_to_tx_status(u32 rate_n_flags,
  504. struct ieee80211_tx_info *info)
  505. {
  506. struct ieee80211_tx_rate *r = &info->status.rates[0];
  507. info->status.antenna =
  508. ((rate_n_flags & RATE_MCS_ANT_ABC_MSK) >> RATE_MCS_ANT_POS);
  509. iwl_mvm_hwrate_to_tx_rate(rate_n_flags, info->band, r);
  510. }
  511. static void iwl_mvm_rx_tx_cmd_single(struct iwl_mvm *mvm,
  512. struct iwl_rx_packet *pkt)
  513. {
  514. struct ieee80211_sta *sta;
  515. u16 sequence = le16_to_cpu(pkt->hdr.sequence);
  516. int txq_id = SEQ_TO_QUEUE(sequence);
  517. struct iwl_mvm_tx_resp *tx_resp = (void *)pkt->data;
  518. int sta_id = IWL_MVM_TX_RES_GET_RA(tx_resp->ra_tid);
  519. int tid = IWL_MVM_TX_RES_GET_TID(tx_resp->ra_tid);
  520. u32 status = le16_to_cpu(tx_resp->status.status);
  521. u16 ssn = iwl_mvm_get_scd_ssn(tx_resp);
  522. struct iwl_mvm_sta *mvmsta;
  523. struct sk_buff_head skbs;
  524. u8 skb_freed = 0;
  525. u16 next_reclaimed, seq_ctl;
  526. __skb_queue_head_init(&skbs);
  527. seq_ctl = le16_to_cpu(tx_resp->seq_ctl);
  528. /* we can free until ssn % q.n_bd not inclusive */
  529. iwl_trans_reclaim(mvm->trans, txq_id, ssn, &skbs);
  530. while (!skb_queue_empty(&skbs)) {
  531. struct sk_buff *skb = __skb_dequeue(&skbs);
  532. struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
  533. skb_freed++;
  534. iwl_trans_free_tx_cmd(mvm->trans, info->driver_data[1]);
  535. memset(&info->status, 0, sizeof(info->status));
  536. info->flags &= ~IEEE80211_TX_CTL_AMPDU;
  537. /* inform mac80211 about what happened with the frame */
  538. switch (status & TX_STATUS_MSK) {
  539. case TX_STATUS_SUCCESS:
  540. case TX_STATUS_DIRECT_DONE:
  541. info->flags |= IEEE80211_TX_STAT_ACK;
  542. break;
  543. case TX_STATUS_FAIL_DEST_PS:
  544. info->flags |= IEEE80211_TX_STAT_TX_FILTERED;
  545. break;
  546. default:
  547. break;
  548. }
  549. info->status.rates[0].count = tx_resp->failure_frame + 1;
  550. iwl_mvm_hwrate_to_tx_status(le32_to_cpu(tx_resp->initial_rate),
  551. info);
  552. /* Single frame failure in an AMPDU queue => send BAR */
  553. if (txq_id >= mvm->first_agg_queue &&
  554. !(info->flags & IEEE80211_TX_STAT_ACK))
  555. info->flags |= IEEE80211_TX_STAT_AMPDU_NO_BACK;
  556. /* W/A FW bug: seq_ctl is wrong when the status isn't success */
  557. if (status != TX_STATUS_SUCCESS) {
  558. struct ieee80211_hdr *hdr = (void *)skb->data;
  559. seq_ctl = le16_to_cpu(hdr->seq_ctrl);
  560. }
  561. BUILD_BUG_ON(ARRAY_SIZE(info->status.status_driver_data) < 1);
  562. info->status.status_driver_data[0] =
  563. (void *)(uintptr_t)tx_resp->reduced_tpc;
  564. ieee80211_tx_status(mvm->hw, skb);
  565. }
  566. if (txq_id >= mvm->first_agg_queue) {
  567. /* If this is an aggregation queue, we use the ssn since:
  568. * ssn = wifi seq_num % 256.
  569. * The seq_ctl is the sequence control of the packet to which
  570. * this Tx response relates. But if there is a hole in the
  571. * bitmap of the BA we received, this Tx response may allow to
  572. * reclaim the hole and all the subsequent packets that were
  573. * already acked. In that case, seq_ctl != ssn, and the next
  574. * packet to be reclaimed will be ssn and not seq_ctl. In that
  575. * case, several packets will be reclaimed even if
  576. * frame_count = 1.
  577. *
  578. * The ssn is the index (% 256) of the latest packet that has
  579. * treated (acked / dropped) + 1.
  580. */
  581. next_reclaimed = ssn;
  582. } else {
  583. /* The next packet to be reclaimed is the one after this one */
  584. next_reclaimed = IEEE80211_SEQ_TO_SN(seq_ctl + 0x10);
  585. }
  586. IWL_DEBUG_TX_REPLY(mvm,
  587. "TXQ %d status %s (0x%08x)\n",
  588. txq_id, iwl_mvm_get_tx_fail_reason(status), status);
  589. IWL_DEBUG_TX_REPLY(mvm,
  590. "\t\t\t\tinitial_rate 0x%x retries %d, idx=%d ssn=%d next_reclaimed=0x%x seq_ctl=0x%x\n",
  591. le32_to_cpu(tx_resp->initial_rate),
  592. tx_resp->failure_frame, SEQ_TO_INDEX(sequence),
  593. ssn, next_reclaimed, seq_ctl);
  594. rcu_read_lock();
  595. sta = rcu_dereference(mvm->fw_id_to_mac_id[sta_id]);
  596. /*
  597. * sta can't be NULL otherwise it'd mean that the sta has been freed in
  598. * the firmware while we still have packets for it in the Tx queues.
  599. */
  600. if (WARN_ON_ONCE(!sta))
  601. goto out;
  602. if (!IS_ERR(sta)) {
  603. mvmsta = iwl_mvm_sta_from_mac80211(sta);
  604. if (tid != IWL_TID_NON_QOS) {
  605. struct iwl_mvm_tid_data *tid_data =
  606. &mvmsta->tid_data[tid];
  607. spin_lock_bh(&mvmsta->lock);
  608. tid_data->next_reclaimed = next_reclaimed;
  609. IWL_DEBUG_TX_REPLY(mvm, "Next reclaimed packet:%d\n",
  610. next_reclaimed);
  611. iwl_mvm_check_ratid_empty(mvm, sta, tid);
  612. spin_unlock_bh(&mvmsta->lock);
  613. }
  614. if (mvmsta->next_status_eosp) {
  615. mvmsta->next_status_eosp = false;
  616. ieee80211_sta_eosp(sta);
  617. }
  618. } else {
  619. mvmsta = NULL;
  620. }
  621. /*
  622. * If the txq is not an AMPDU queue, there is no chance we freed
  623. * several skbs. Check that out...
  624. */
  625. if (txq_id >= mvm->first_agg_queue)
  626. goto out;
  627. /* We can't free more than one frame at once on a shared queue */
  628. WARN_ON(skb_freed > 1);
  629. /* If we have still frames for this STA nothing to do here */
  630. if (!atomic_sub_and_test(skb_freed, &mvm->pending_frames[sta_id]))
  631. goto out;
  632. if (mvmsta && mvmsta->vif->type == NL80211_IFTYPE_AP) {
  633. /*
  634. * If there are no pending frames for this STA and
  635. * the tx to this station is not disabled, notify
  636. * mac80211 that this station can now wake up in its
  637. * STA table.
  638. * If mvmsta is not NULL, sta is valid.
  639. */
  640. spin_lock_bh(&mvmsta->lock);
  641. if (!mvmsta->disable_tx)
  642. ieee80211_sta_block_awake(mvm->hw, sta, false);
  643. spin_unlock_bh(&mvmsta->lock);
  644. }
  645. if (PTR_ERR(sta) == -EBUSY || PTR_ERR(sta) == -ENOENT) {
  646. /*
  647. * We are draining and this was the last packet - pre_rcu_remove
  648. * has been called already. We might be after the
  649. * synchronize_net already.
  650. * Don't rely on iwl_mvm_rm_sta to see the empty Tx queues.
  651. */
  652. set_bit(sta_id, mvm->sta_drained);
  653. schedule_work(&mvm->sta_drained_wk);
  654. }
  655. out:
  656. rcu_read_unlock();
  657. }
  658. #ifdef CONFIG_IWLWIFI_DEBUG
  659. #define AGG_TX_STATE_(x) case AGG_TX_STATE_ ## x: return #x
  660. static const char *iwl_get_agg_tx_status(u16 status)
  661. {
  662. switch (status & AGG_TX_STATE_STATUS_MSK) {
  663. AGG_TX_STATE_(TRANSMITTED);
  664. AGG_TX_STATE_(UNDERRUN);
  665. AGG_TX_STATE_(BT_PRIO);
  666. AGG_TX_STATE_(FEW_BYTES);
  667. AGG_TX_STATE_(ABORT);
  668. AGG_TX_STATE_(LAST_SENT_TTL);
  669. AGG_TX_STATE_(LAST_SENT_TRY_CNT);
  670. AGG_TX_STATE_(LAST_SENT_BT_KILL);
  671. AGG_TX_STATE_(SCD_QUERY);
  672. AGG_TX_STATE_(TEST_BAD_CRC32);
  673. AGG_TX_STATE_(RESPONSE);
  674. AGG_TX_STATE_(DUMP_TX);
  675. AGG_TX_STATE_(DELAY_TX);
  676. }
  677. return "UNKNOWN";
  678. }
  679. static void iwl_mvm_rx_tx_cmd_agg_dbg(struct iwl_mvm *mvm,
  680. struct iwl_rx_packet *pkt)
  681. {
  682. struct iwl_mvm_tx_resp *tx_resp = (void *)pkt->data;
  683. struct agg_tx_status *frame_status = &tx_resp->status;
  684. int i;
  685. for (i = 0; i < tx_resp->frame_count; i++) {
  686. u16 fstatus = le16_to_cpu(frame_status[i].status);
  687. IWL_DEBUG_TX_REPLY(mvm,
  688. "status %s (0x%04x), try-count (%d) seq (0x%x)\n",
  689. iwl_get_agg_tx_status(fstatus),
  690. fstatus & AGG_TX_STATE_STATUS_MSK,
  691. (fstatus & AGG_TX_STATE_TRY_CNT_MSK) >>
  692. AGG_TX_STATE_TRY_CNT_POS,
  693. le16_to_cpu(frame_status[i].sequence));
  694. }
  695. }
  696. #else
  697. static void iwl_mvm_rx_tx_cmd_agg_dbg(struct iwl_mvm *mvm,
  698. struct iwl_rx_packet *pkt)
  699. {}
  700. #endif /* CONFIG_IWLWIFI_DEBUG */
  701. static void iwl_mvm_rx_tx_cmd_agg(struct iwl_mvm *mvm,
  702. struct iwl_rx_packet *pkt)
  703. {
  704. struct iwl_mvm_tx_resp *tx_resp = (void *)pkt->data;
  705. int sta_id = IWL_MVM_TX_RES_GET_RA(tx_resp->ra_tid);
  706. int tid = IWL_MVM_TX_RES_GET_TID(tx_resp->ra_tid);
  707. u16 sequence = le16_to_cpu(pkt->hdr.sequence);
  708. struct ieee80211_sta *sta;
  709. if (WARN_ON_ONCE(SEQ_TO_QUEUE(sequence) < mvm->first_agg_queue))
  710. return;
  711. if (WARN_ON_ONCE(tid == IWL_TID_NON_QOS))
  712. return;
  713. iwl_mvm_rx_tx_cmd_agg_dbg(mvm, pkt);
  714. rcu_read_lock();
  715. sta = rcu_dereference(mvm->fw_id_to_mac_id[sta_id]);
  716. if (!WARN_ON_ONCE(IS_ERR_OR_NULL(sta))) {
  717. struct iwl_mvm_sta *mvmsta = iwl_mvm_sta_from_mac80211(sta);
  718. mvmsta->tid_data[tid].rate_n_flags =
  719. le32_to_cpu(tx_resp->initial_rate);
  720. mvmsta->tid_data[tid].reduced_tpc = tx_resp->reduced_tpc;
  721. }
  722. rcu_read_unlock();
  723. }
  724. int iwl_mvm_rx_tx_cmd(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb,
  725. struct iwl_device_cmd *cmd)
  726. {
  727. struct iwl_rx_packet *pkt = rxb_addr(rxb);
  728. struct iwl_mvm_tx_resp *tx_resp = (void *)pkt->data;
  729. if (tx_resp->frame_count == 1)
  730. iwl_mvm_rx_tx_cmd_single(mvm, pkt);
  731. else
  732. iwl_mvm_rx_tx_cmd_agg(mvm, pkt);
  733. return 0;
  734. }
  735. static void iwl_mvm_tx_info_from_ba_notif(struct ieee80211_tx_info *info,
  736. struct iwl_mvm_ba_notif *ba_notif,
  737. struct iwl_mvm_tid_data *tid_data)
  738. {
  739. info->flags |= IEEE80211_TX_STAT_AMPDU;
  740. info->status.ampdu_ack_len = ba_notif->txed_2_done;
  741. info->status.ampdu_len = ba_notif->txed;
  742. iwl_mvm_hwrate_to_tx_status(tid_data->rate_n_flags,
  743. info);
  744. info->status.status_driver_data[0] =
  745. (void *)(uintptr_t)tid_data->reduced_tpc;
  746. }
  747. int iwl_mvm_rx_ba_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb,
  748. struct iwl_device_cmd *cmd)
  749. {
  750. struct iwl_rx_packet *pkt = rxb_addr(rxb);
  751. struct iwl_mvm_ba_notif *ba_notif = (void *)pkt->data;
  752. struct sk_buff_head reclaimed_skbs;
  753. struct iwl_mvm_tid_data *tid_data;
  754. struct ieee80211_sta *sta;
  755. struct iwl_mvm_sta *mvmsta;
  756. struct sk_buff *skb;
  757. int sta_id, tid, freed;
  758. /* "flow" corresponds to Tx queue */
  759. u16 scd_flow = le16_to_cpu(ba_notif->scd_flow);
  760. /* "ssn" is start of block-ack Tx window, corresponds to index
  761. * (in Tx queue's circular buffer) of first TFD/frame in window */
  762. u16 ba_resp_scd_ssn = le16_to_cpu(ba_notif->scd_ssn);
  763. sta_id = ba_notif->sta_id;
  764. tid = ba_notif->tid;
  765. if (WARN_ONCE(sta_id >= IWL_MVM_STATION_COUNT ||
  766. tid >= IWL_MAX_TID_COUNT,
  767. "sta_id %d tid %d", sta_id, tid))
  768. return 0;
  769. rcu_read_lock();
  770. sta = rcu_dereference(mvm->fw_id_to_mac_id[sta_id]);
  771. /* Reclaiming frames for a station that has been deleted ? */
  772. if (WARN_ON_ONCE(IS_ERR_OR_NULL(sta))) {
  773. rcu_read_unlock();
  774. return 0;
  775. }
  776. mvmsta = iwl_mvm_sta_from_mac80211(sta);
  777. tid_data = &mvmsta->tid_data[tid];
  778. if (WARN_ONCE(tid_data->txq_id != scd_flow, "Q %d, tid %d, flow %d",
  779. tid_data->txq_id, tid, scd_flow)) {
  780. rcu_read_unlock();
  781. return 0;
  782. }
  783. spin_lock_bh(&mvmsta->lock);
  784. __skb_queue_head_init(&reclaimed_skbs);
  785. /*
  786. * Release all TFDs before the SSN, i.e. all TFDs in front of
  787. * block-ack window (we assume that they've been successfully
  788. * transmitted ... if not, it's too late anyway).
  789. */
  790. iwl_trans_reclaim(mvm->trans, scd_flow, ba_resp_scd_ssn,
  791. &reclaimed_skbs);
  792. IWL_DEBUG_TX_REPLY(mvm,
  793. "BA_NOTIFICATION Received from %pM, sta_id = %d\n",
  794. (u8 *)&ba_notif->sta_addr_lo32,
  795. ba_notif->sta_id);
  796. IWL_DEBUG_TX_REPLY(mvm,
  797. "TID = %d, SeqCtl = %d, bitmap = 0x%llx, scd_flow = %d, scd_ssn = %d sent:%d, acked:%d\n",
  798. ba_notif->tid, le16_to_cpu(ba_notif->seq_ctl),
  799. (unsigned long long)le64_to_cpu(ba_notif->bitmap),
  800. scd_flow, ba_resp_scd_ssn, ba_notif->txed,
  801. ba_notif->txed_2_done);
  802. tid_data->next_reclaimed = ba_resp_scd_ssn;
  803. iwl_mvm_check_ratid_empty(mvm, sta, tid);
  804. freed = 0;
  805. skb_queue_walk(&reclaimed_skbs, skb) {
  806. struct ieee80211_hdr *hdr = (void *)skb->data;
  807. struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
  808. if (ieee80211_is_data_qos(hdr->frame_control))
  809. freed++;
  810. else
  811. WARN_ON_ONCE(1);
  812. iwl_trans_free_tx_cmd(mvm->trans, info->driver_data[1]);
  813. memset(&info->status, 0, sizeof(info->status));
  814. /* Packet was transmitted successfully, failures come as single
  815. * frames because before failing a frame the firmware transmits
  816. * it without aggregation at least once.
  817. */
  818. info->flags |= IEEE80211_TX_STAT_ACK;
  819. /* this is the first skb we deliver in this batch */
  820. /* put the rate scaling data there */
  821. if (freed == 1)
  822. iwl_mvm_tx_info_from_ba_notif(info, ba_notif, tid_data);
  823. }
  824. spin_unlock_bh(&mvmsta->lock);
  825. /* We got a BA notif with 0 acked or scd_ssn didn't progress which is
  826. * possible (i.e. first MPDU in the aggregation wasn't acked)
  827. * Still it's important to update RS about sent vs. acked.
  828. */
  829. if (skb_queue_empty(&reclaimed_skbs)) {
  830. struct ieee80211_tx_info ba_info = {};
  831. struct ieee80211_chanctx_conf *chanctx_conf = NULL;
  832. if (mvmsta->vif)
  833. chanctx_conf =
  834. rcu_dereference(mvmsta->vif->chanctx_conf);
  835. if (WARN_ON_ONCE(!chanctx_conf))
  836. goto out;
  837. ba_info.band = chanctx_conf->def.chan->band;
  838. iwl_mvm_tx_info_from_ba_notif(&ba_info, ba_notif, tid_data);
  839. IWL_DEBUG_TX_REPLY(mvm, "No reclaim. Update rs directly\n");
  840. iwl_mvm_rs_tx_status(mvm, sta, tid, &ba_info);
  841. }
  842. out:
  843. rcu_read_unlock();
  844. while (!skb_queue_empty(&reclaimed_skbs)) {
  845. skb = __skb_dequeue(&reclaimed_skbs);
  846. ieee80211_tx_status(mvm->hw, skb);
  847. }
  848. return 0;
  849. }
  850. int iwl_mvm_flush_tx_path(struct iwl_mvm *mvm, u32 tfd_msk, bool sync)
  851. {
  852. int ret;
  853. struct iwl_tx_path_flush_cmd flush_cmd = {
  854. .queues_ctl = cpu_to_le32(tfd_msk),
  855. .flush_ctl = cpu_to_le16(DUMP_TX_FIFO_FLUSH),
  856. };
  857. u32 flags = sync ? 0 : CMD_ASYNC;
  858. ret = iwl_mvm_send_cmd_pdu(mvm, TXPATH_FLUSH, flags,
  859. sizeof(flush_cmd), &flush_cmd);
  860. if (ret)
  861. IWL_ERR(mvm, "Failed to send flush command (%d)\n", ret);
  862. return ret;
  863. }