rxmq.c 32 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063
  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 - 2015 Intel Mobile Communications GmbH
  10. * Copyright(c) 2015 - 2017 Intel Deutschland GmbH
  11. *
  12. * This program is free software; you can redistribute it and/or modify
  13. * it under the terms of version 2 of the GNU General Public License as
  14. * published by the Free Software Foundation.
  15. *
  16. * This program is distributed in the hope that it will be useful, but
  17. * WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  19. * General Public License for more details.
  20. *
  21. * The full GNU General Public License is included in this distribution
  22. * in the file called COPYING.
  23. *
  24. * Contact Information:
  25. * Intel Linux Wireless <ilw@linux.intel.com>
  26. * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  27. *
  28. * BSD LICENSE
  29. *
  30. * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
  31. * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
  32. * Copyright(c) 2015 - 2017 Intel Deutschland GmbH
  33. * All rights reserved.
  34. *
  35. * Redistribution and use in source and binary forms, with or without
  36. * modification, are permitted provided that the following conditions
  37. * are met:
  38. *
  39. * * Redistributions of source code must retain the above copyright
  40. * notice, this list of conditions and the following disclaimer.
  41. * * Redistributions in binary form must reproduce the above copyright
  42. * notice, this list of conditions and the following disclaimer in
  43. * the documentation and/or other materials provided with the
  44. * distribution.
  45. * * Neither the name Intel Corporation nor the names of its
  46. * contributors may be used to endorse or promote products derived
  47. * from this software without specific prior written permission.
  48. *
  49. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  50. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  51. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  52. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  53. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  54. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  55. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  56. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  57. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  58. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  59. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  60. *****************************************************************************/
  61. #include <linux/etherdevice.h>
  62. #include <linux/skbuff.h>
  63. #include "iwl-trans.h"
  64. #include "mvm.h"
  65. #include "fw-api.h"
  66. #include "fw-dbg.h"
  67. static inline int iwl_mvm_check_pn(struct iwl_mvm *mvm, struct sk_buff *skb,
  68. int queue, struct ieee80211_sta *sta)
  69. {
  70. struct iwl_mvm_sta *mvmsta;
  71. struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
  72. struct ieee80211_rx_status *stats = IEEE80211_SKB_RXCB(skb);
  73. struct iwl_mvm_key_pn *ptk_pn;
  74. u8 tid, keyidx;
  75. u8 pn[IEEE80211_CCMP_PN_LEN];
  76. u8 *extiv;
  77. /* do PN checking */
  78. /* multicast and non-data only arrives on default queue */
  79. if (!ieee80211_is_data(hdr->frame_control) ||
  80. is_multicast_ether_addr(hdr->addr1))
  81. return 0;
  82. /* do not check PN for open AP */
  83. if (!(stats->flag & RX_FLAG_DECRYPTED))
  84. return 0;
  85. /*
  86. * avoid checking for default queue - we don't want to replicate
  87. * all the logic that's necessary for checking the PN on fragmented
  88. * frames, leave that to mac80211
  89. */
  90. if (queue == 0)
  91. return 0;
  92. /* if we are here - this for sure is either CCMP or GCMP */
  93. if (IS_ERR_OR_NULL(sta)) {
  94. IWL_ERR(mvm,
  95. "expected hw-decrypted unicast frame for station\n");
  96. return -1;
  97. }
  98. mvmsta = iwl_mvm_sta_from_mac80211(sta);
  99. extiv = (u8 *)hdr + ieee80211_hdrlen(hdr->frame_control);
  100. keyidx = extiv[3] >> 6;
  101. ptk_pn = rcu_dereference(mvmsta->ptk_pn[keyidx]);
  102. if (!ptk_pn)
  103. return -1;
  104. if (ieee80211_is_data_qos(hdr->frame_control))
  105. tid = *ieee80211_get_qos_ctl(hdr) & IEEE80211_QOS_CTL_TID_MASK;
  106. else
  107. tid = 0;
  108. /* we don't use HCCA/802.11 QoS TSPECs, so drop such frames */
  109. if (tid >= IWL_MAX_TID_COUNT)
  110. return -1;
  111. /* load pn */
  112. pn[0] = extiv[7];
  113. pn[1] = extiv[6];
  114. pn[2] = extiv[5];
  115. pn[3] = extiv[4];
  116. pn[4] = extiv[1];
  117. pn[5] = extiv[0];
  118. if (memcmp(pn, ptk_pn->q[queue].pn[tid],
  119. IEEE80211_CCMP_PN_LEN) <= 0)
  120. return -1;
  121. if (!(stats->flag & RX_FLAG_AMSDU_MORE))
  122. memcpy(ptk_pn->q[queue].pn[tid], pn, IEEE80211_CCMP_PN_LEN);
  123. stats->flag |= RX_FLAG_PN_VALIDATED;
  124. return 0;
  125. }
  126. /* iwl_mvm_create_skb Adds the rxb to a new skb */
  127. static void iwl_mvm_create_skb(struct sk_buff *skb, struct ieee80211_hdr *hdr,
  128. u16 len, u8 crypt_len,
  129. struct iwl_rx_cmd_buffer *rxb)
  130. {
  131. struct iwl_rx_packet *pkt = rxb_addr(rxb);
  132. struct iwl_rx_mpdu_desc *desc = (void *)pkt->data;
  133. unsigned int headlen, fraglen, pad_len = 0;
  134. unsigned int hdrlen = ieee80211_hdrlen(hdr->frame_control);
  135. if (desc->mac_flags2 & IWL_RX_MPDU_MFLG2_PAD) {
  136. pad_len = 2;
  137. /*
  138. * If the device inserted padding it means that (it thought)
  139. * the 802.11 header wasn't a multiple of 4 bytes long. In
  140. * this case, reserve two bytes at the start of the SKB to
  141. * align the payload properly in case we end up copying it.
  142. */
  143. skb_reserve(skb, pad_len);
  144. }
  145. len -= pad_len;
  146. /* If frame is small enough to fit in skb->head, pull it completely.
  147. * If not, only pull ieee80211_hdr (including crypto if present, and
  148. * an additional 8 bytes for SNAP/ethertype, see below) so that
  149. * splice() or TCP coalesce are more efficient.
  150. *
  151. * Since, in addition, ieee80211_data_to_8023() always pull in at
  152. * least 8 bytes (possibly more for mesh) we can do the same here
  153. * to save the cost of doing it later. That still doesn't pull in
  154. * the actual IP header since the typical case has a SNAP header.
  155. * If the latter changes (there are efforts in the standards group
  156. * to do so) we should revisit this and ieee80211_data_to_8023().
  157. */
  158. headlen = (len <= skb_tailroom(skb)) ? len :
  159. hdrlen + crypt_len + 8;
  160. /* The firmware may align the packet to DWORD.
  161. * The padding is inserted after the IV.
  162. * After copying the header + IV skip the padding if
  163. * present before copying packet data.
  164. */
  165. hdrlen += crypt_len;
  166. memcpy(skb_put(skb, hdrlen), hdr, hdrlen);
  167. memcpy(skb_put(skb, headlen - hdrlen), (u8 *)hdr + hdrlen + pad_len,
  168. headlen - hdrlen);
  169. fraglen = len - headlen;
  170. if (fraglen) {
  171. int offset = (void *)hdr + headlen + pad_len -
  172. rxb_addr(rxb) + rxb_offset(rxb);
  173. skb_add_rx_frag(skb, 0, rxb_steal_page(rxb), offset,
  174. fraglen, rxb->truesize);
  175. }
  176. }
  177. /* iwl_mvm_pass_packet_to_mac80211 - passes the packet for mac80211 */
  178. static void iwl_mvm_pass_packet_to_mac80211(struct iwl_mvm *mvm,
  179. struct napi_struct *napi,
  180. struct sk_buff *skb, int queue,
  181. struct ieee80211_sta *sta)
  182. {
  183. if (iwl_mvm_check_pn(mvm, skb, queue, sta))
  184. kfree_skb(skb);
  185. else
  186. ieee80211_rx_napi(mvm->hw, sta, skb, napi);
  187. }
  188. static void iwl_mvm_get_signal_strength(struct iwl_mvm *mvm,
  189. struct iwl_rx_mpdu_desc *desc,
  190. struct ieee80211_rx_status *rx_status)
  191. {
  192. int energy_a, energy_b, max_energy;
  193. energy_a = desc->energy_a;
  194. energy_a = energy_a ? -energy_a : S8_MIN;
  195. energy_b = desc->energy_b;
  196. energy_b = energy_b ? -energy_b : S8_MIN;
  197. max_energy = max(energy_a, energy_b);
  198. IWL_DEBUG_STATS(mvm, "energy In A %d B %d, and max %d\n",
  199. energy_a, energy_b, max_energy);
  200. rx_status->signal = max_energy;
  201. rx_status->chains = 0; /* TODO: phy info */
  202. rx_status->chain_signal[0] = energy_a;
  203. rx_status->chain_signal[1] = energy_b;
  204. rx_status->chain_signal[2] = S8_MIN;
  205. }
  206. static int iwl_mvm_rx_crypto(struct iwl_mvm *mvm, struct ieee80211_hdr *hdr,
  207. struct ieee80211_rx_status *stats,
  208. struct iwl_rx_mpdu_desc *desc, int queue,
  209. u8 *crypt_len)
  210. {
  211. u16 status = le16_to_cpu(desc->status);
  212. if (!ieee80211_has_protected(hdr->frame_control) ||
  213. (status & IWL_RX_MPDU_STATUS_SEC_MASK) ==
  214. IWL_RX_MPDU_STATUS_SEC_NONE)
  215. return 0;
  216. /* TODO: handle packets encrypted with unknown alg */
  217. switch (status & IWL_RX_MPDU_STATUS_SEC_MASK) {
  218. case IWL_RX_MPDU_STATUS_SEC_CCM:
  219. case IWL_RX_MPDU_STATUS_SEC_GCM:
  220. BUILD_BUG_ON(IEEE80211_CCMP_PN_LEN != IEEE80211_GCMP_PN_LEN);
  221. /* alg is CCM: check MIC only */
  222. if (!(status & IWL_RX_MPDU_STATUS_MIC_OK))
  223. return -1;
  224. stats->flag |= RX_FLAG_DECRYPTED;
  225. *crypt_len = IEEE80211_CCMP_HDR_LEN;
  226. return 0;
  227. case IWL_RX_MPDU_STATUS_SEC_TKIP:
  228. /* Don't drop the frame and decrypt it in SW */
  229. if (!(status & IWL_RX_MPDU_RES_STATUS_TTAK_OK))
  230. return 0;
  231. *crypt_len = IEEE80211_TKIP_IV_LEN;
  232. /* fall through if TTAK OK */
  233. case IWL_RX_MPDU_STATUS_SEC_WEP:
  234. if (!(status & IWL_RX_MPDU_STATUS_ICV_OK))
  235. return -1;
  236. stats->flag |= RX_FLAG_DECRYPTED;
  237. if ((status & IWL_RX_MPDU_STATUS_SEC_MASK) ==
  238. IWL_RX_MPDU_STATUS_SEC_WEP)
  239. *crypt_len = IEEE80211_WEP_IV_LEN;
  240. return 0;
  241. case IWL_RX_MPDU_STATUS_SEC_EXT_ENC:
  242. if (!(status & IWL_RX_MPDU_STATUS_MIC_OK))
  243. return -1;
  244. stats->flag |= RX_FLAG_DECRYPTED;
  245. return 0;
  246. default:
  247. IWL_ERR(mvm, "Unhandled alg: 0x%x\n", status);
  248. }
  249. return 0;
  250. }
  251. static void iwl_mvm_rx_csum(struct ieee80211_sta *sta,
  252. struct sk_buff *skb,
  253. struct iwl_rx_mpdu_desc *desc)
  254. {
  255. struct iwl_mvm_sta *mvmsta = iwl_mvm_sta_from_mac80211(sta);
  256. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(mvmsta->vif);
  257. u16 flags = le16_to_cpu(desc->l3l4_flags);
  258. u8 l3_prot = (u8)((flags & IWL_RX_L3L4_L3_PROTO_MASK) >>
  259. IWL_RX_L3_PROTO_POS);
  260. if (mvmvif->features & NETIF_F_RXCSUM &&
  261. flags & IWL_RX_L3L4_TCP_UDP_CSUM_OK &&
  262. (flags & IWL_RX_L3L4_IP_HDR_CSUM_OK ||
  263. l3_prot == IWL_RX_L3_TYPE_IPV6 ||
  264. l3_prot == IWL_RX_L3_TYPE_IPV6_FRAG))
  265. skb->ip_summed = CHECKSUM_UNNECESSARY;
  266. }
  267. /*
  268. * returns true if a packet outside BA session is a duplicate and
  269. * should be dropped
  270. */
  271. static bool iwl_mvm_is_nonagg_dup(struct ieee80211_sta *sta, int queue,
  272. struct ieee80211_rx_status *rx_status,
  273. struct ieee80211_hdr *hdr,
  274. struct iwl_rx_mpdu_desc *desc)
  275. {
  276. struct iwl_mvm_sta *mvm_sta;
  277. struct iwl_mvm_rxq_dup_data *dup_data;
  278. u8 baid, tid, sub_frame_idx;
  279. if (WARN_ON(IS_ERR_OR_NULL(sta)))
  280. return false;
  281. baid = (le32_to_cpu(desc->reorder_data) &
  282. IWL_RX_MPDU_REORDER_BAID_MASK) >>
  283. IWL_RX_MPDU_REORDER_BAID_SHIFT;
  284. if (baid != IWL_RX_REORDER_DATA_INVALID_BAID)
  285. return false;
  286. mvm_sta = iwl_mvm_sta_from_mac80211(sta);
  287. dup_data = &mvm_sta->dup_data[queue];
  288. /*
  289. * Drop duplicate 802.11 retransmissions
  290. * (IEEE 802.11-2012: 9.3.2.10 "Duplicate detection and recovery")
  291. */
  292. if (ieee80211_is_ctl(hdr->frame_control) ||
  293. ieee80211_is_qos_nullfunc(hdr->frame_control) ||
  294. is_multicast_ether_addr(hdr->addr1)) {
  295. rx_status->flag |= RX_FLAG_DUP_VALIDATED;
  296. return false;
  297. }
  298. if (ieee80211_is_data_qos(hdr->frame_control))
  299. /* frame has qos control */
  300. tid = *ieee80211_get_qos_ctl(hdr) &
  301. IEEE80211_QOS_CTL_TID_MASK;
  302. else
  303. tid = IWL_MAX_TID_COUNT;
  304. /* If this wasn't a part of an A-MSDU the sub-frame index will be 0 */
  305. sub_frame_idx = desc->amsdu_info & IWL_RX_MPDU_AMSDU_SUBFRAME_IDX_MASK;
  306. if (unlikely(ieee80211_has_retry(hdr->frame_control) &&
  307. dup_data->last_seq[tid] == hdr->seq_ctrl &&
  308. dup_data->last_sub_frame[tid] >= sub_frame_idx))
  309. return true;
  310. dup_data->last_seq[tid] = hdr->seq_ctrl;
  311. dup_data->last_sub_frame[tid] = sub_frame_idx;
  312. rx_status->flag |= RX_FLAG_DUP_VALIDATED;
  313. return false;
  314. }
  315. int iwl_mvm_notify_rx_queue(struct iwl_mvm *mvm, u32 rxq_mask,
  316. const u8 *data, u32 count)
  317. {
  318. struct iwl_rxq_sync_cmd *cmd;
  319. u32 data_size = sizeof(*cmd) + count;
  320. int ret;
  321. /* should be DWORD aligned */
  322. if (WARN_ON(count & 3 || count > IWL_MULTI_QUEUE_SYNC_MSG_MAX_SIZE))
  323. return -EINVAL;
  324. cmd = kzalloc(data_size, GFP_KERNEL);
  325. if (!cmd)
  326. return -ENOMEM;
  327. cmd->rxq_mask = cpu_to_le32(rxq_mask);
  328. cmd->count = cpu_to_le32(count);
  329. cmd->flags = 0;
  330. memcpy(cmd->payload, data, count);
  331. ret = iwl_mvm_send_cmd_pdu(mvm,
  332. WIDE_ID(DATA_PATH_GROUP,
  333. TRIGGER_RX_QUEUES_NOTIF_CMD),
  334. 0, data_size, cmd);
  335. kfree(cmd);
  336. return ret;
  337. }
  338. /*
  339. * Returns true if sn2 - buffer_size < sn1 < sn2.
  340. * To be used only in order to compare reorder buffer head with NSSN.
  341. * We fully trust NSSN unless it is behind us due to reorder timeout.
  342. * Reorder timeout can only bring us up to buffer_size SNs ahead of NSSN.
  343. */
  344. static bool iwl_mvm_is_sn_less(u16 sn1, u16 sn2, u16 buffer_size)
  345. {
  346. return ieee80211_sn_less(sn1, sn2) &&
  347. !ieee80211_sn_less(sn1, sn2 - buffer_size);
  348. }
  349. #define RX_REORDER_BUF_TIMEOUT_MQ (HZ / 10)
  350. static void iwl_mvm_release_frames(struct iwl_mvm *mvm,
  351. struct ieee80211_sta *sta,
  352. struct napi_struct *napi,
  353. struct iwl_mvm_reorder_buffer *reorder_buf,
  354. u16 nssn)
  355. {
  356. u16 ssn = reorder_buf->head_sn;
  357. lockdep_assert_held(&reorder_buf->lock);
  358. /* ignore nssn smaller than head sn - this can happen due to timeout */
  359. if (iwl_mvm_is_sn_less(nssn, ssn, reorder_buf->buf_size))
  360. goto set_timer;
  361. while (iwl_mvm_is_sn_less(ssn, nssn, reorder_buf->buf_size)) {
  362. int index = ssn % reorder_buf->buf_size;
  363. struct sk_buff_head *skb_list = &reorder_buf->entries[index];
  364. struct sk_buff *skb;
  365. ssn = ieee80211_sn_inc(ssn);
  366. /*
  367. * Empty the list. Will have more than one frame for A-MSDU.
  368. * Empty list is valid as well since nssn indicates frames were
  369. * received.
  370. */
  371. while ((skb = __skb_dequeue(skb_list))) {
  372. iwl_mvm_pass_packet_to_mac80211(mvm, napi, skb,
  373. reorder_buf->queue,
  374. sta);
  375. reorder_buf->num_stored--;
  376. }
  377. }
  378. reorder_buf->head_sn = nssn;
  379. set_timer:
  380. if (reorder_buf->num_stored && !reorder_buf->removed) {
  381. u16 index = reorder_buf->head_sn % reorder_buf->buf_size;
  382. while (skb_queue_empty(&reorder_buf->entries[index]))
  383. index = (index + 1) % reorder_buf->buf_size;
  384. /* modify timer to match next frame's expiration time */
  385. mod_timer(&reorder_buf->reorder_timer,
  386. reorder_buf->reorder_time[index] + 1 +
  387. RX_REORDER_BUF_TIMEOUT_MQ);
  388. } else {
  389. del_timer(&reorder_buf->reorder_timer);
  390. }
  391. }
  392. void iwl_mvm_reorder_timer_expired(unsigned long data)
  393. {
  394. struct iwl_mvm_reorder_buffer *buf = (void *)data;
  395. int i;
  396. u16 sn = 0, index = 0;
  397. bool expired = false;
  398. bool cont = false;
  399. spin_lock(&buf->lock);
  400. if (!buf->num_stored || buf->removed) {
  401. spin_unlock(&buf->lock);
  402. return;
  403. }
  404. for (i = 0; i < buf->buf_size ; i++) {
  405. index = (buf->head_sn + i) % buf->buf_size;
  406. if (skb_queue_empty(&buf->entries[index])) {
  407. /*
  408. * If there is a hole and the next frame didn't expire
  409. * we want to break and not advance SN
  410. */
  411. cont = false;
  412. continue;
  413. }
  414. if (!cont && !time_after(jiffies, buf->reorder_time[index] +
  415. RX_REORDER_BUF_TIMEOUT_MQ))
  416. break;
  417. expired = true;
  418. /* continue until next hole after this expired frames */
  419. cont = true;
  420. sn = ieee80211_sn_add(buf->head_sn, i + 1);
  421. }
  422. if (expired) {
  423. struct ieee80211_sta *sta;
  424. rcu_read_lock();
  425. sta = rcu_dereference(buf->mvm->fw_id_to_mac_id[buf->sta_id]);
  426. /* SN is set to the last expired frame + 1 */
  427. IWL_DEBUG_HT(buf->mvm,
  428. "Releasing expired frames for sta %u, sn %d\n",
  429. buf->sta_id, sn);
  430. iwl_mvm_release_frames(buf->mvm, sta, NULL, buf, sn);
  431. rcu_read_unlock();
  432. } else if (buf->num_stored) {
  433. /*
  434. * If no frame expired and there are stored frames, index is now
  435. * pointing to the first unexpired frame - modify timer
  436. * accordingly to this frame.
  437. */
  438. mod_timer(&buf->reorder_timer,
  439. buf->reorder_time[index] +
  440. 1 + RX_REORDER_BUF_TIMEOUT_MQ);
  441. }
  442. spin_unlock(&buf->lock);
  443. }
  444. static void iwl_mvm_del_ba(struct iwl_mvm *mvm, int queue,
  445. struct iwl_mvm_delba_data *data)
  446. {
  447. struct iwl_mvm_baid_data *ba_data;
  448. struct ieee80211_sta *sta;
  449. struct iwl_mvm_reorder_buffer *reorder_buf;
  450. u8 baid = data->baid;
  451. if (WARN_ONCE(baid >= IWL_MAX_BAID, "invalid BAID: %x\n", baid))
  452. return;
  453. rcu_read_lock();
  454. ba_data = rcu_dereference(mvm->baid_map[baid]);
  455. if (WARN_ON_ONCE(!ba_data))
  456. goto out;
  457. sta = rcu_dereference(mvm->fw_id_to_mac_id[ba_data->sta_id]);
  458. if (WARN_ON_ONCE(IS_ERR_OR_NULL(sta)))
  459. goto out;
  460. reorder_buf = &ba_data->reorder_buf[queue];
  461. /* release all frames that are in the reorder buffer to the stack */
  462. spin_lock_bh(&reorder_buf->lock);
  463. iwl_mvm_release_frames(mvm, sta, NULL, reorder_buf,
  464. ieee80211_sn_add(reorder_buf->head_sn,
  465. reorder_buf->buf_size));
  466. spin_unlock_bh(&reorder_buf->lock);
  467. del_timer_sync(&reorder_buf->reorder_timer);
  468. out:
  469. rcu_read_unlock();
  470. }
  471. void iwl_mvm_rx_queue_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb,
  472. int queue)
  473. {
  474. struct iwl_rx_packet *pkt = rxb_addr(rxb);
  475. struct iwl_rxq_sync_notification *notif;
  476. struct iwl_mvm_internal_rxq_notif *internal_notif;
  477. notif = (void *)pkt->data;
  478. internal_notif = (void *)notif->payload;
  479. if (internal_notif->sync) {
  480. if (mvm->queue_sync_cookie != internal_notif->cookie) {
  481. WARN_ONCE(1,
  482. "Received expired RX queue sync message\n");
  483. return;
  484. }
  485. if (!atomic_dec_return(&mvm->queue_sync_counter))
  486. wake_up(&mvm->rx_sync_waitq);
  487. }
  488. switch (internal_notif->type) {
  489. case IWL_MVM_RXQ_EMPTY:
  490. break;
  491. case IWL_MVM_RXQ_NOTIF_DEL_BA:
  492. iwl_mvm_del_ba(mvm, queue, (void *)internal_notif->data);
  493. break;
  494. default:
  495. WARN_ONCE(1, "Invalid identifier %d", internal_notif->type);
  496. }
  497. }
  498. /*
  499. * Returns true if the MPDU was buffered\dropped, false if it should be passed
  500. * to upper layer.
  501. */
  502. static bool iwl_mvm_reorder(struct iwl_mvm *mvm,
  503. struct napi_struct *napi,
  504. int queue,
  505. struct ieee80211_sta *sta,
  506. struct sk_buff *skb,
  507. struct iwl_rx_mpdu_desc *desc)
  508. {
  509. struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
  510. struct iwl_mvm_sta *mvm_sta;
  511. struct iwl_mvm_baid_data *baid_data;
  512. struct iwl_mvm_reorder_buffer *buffer;
  513. struct sk_buff *tail;
  514. u32 reorder = le32_to_cpu(desc->reorder_data);
  515. bool amsdu = desc->mac_flags2 & IWL_RX_MPDU_MFLG2_AMSDU;
  516. bool last_subframe =
  517. desc->amsdu_info & IWL_RX_MPDU_AMSDU_LAST_SUBFRAME;
  518. u8 tid = *ieee80211_get_qos_ctl(hdr) & IEEE80211_QOS_CTL_TID_MASK;
  519. u8 sub_frame_idx = desc->amsdu_info &
  520. IWL_RX_MPDU_AMSDU_SUBFRAME_IDX_MASK;
  521. int index;
  522. u16 nssn, sn;
  523. u8 baid;
  524. baid = (reorder & IWL_RX_MPDU_REORDER_BAID_MASK) >>
  525. IWL_RX_MPDU_REORDER_BAID_SHIFT;
  526. /*
  527. * This also covers the case of receiving a Block Ack Request
  528. * outside a BA session; we'll pass it to mac80211 and that
  529. * then sends a delBA action frame.
  530. */
  531. if (baid == IWL_RX_REORDER_DATA_INVALID_BAID)
  532. return false;
  533. /* no sta yet */
  534. if (WARN_ON(IS_ERR_OR_NULL(sta)))
  535. return false;
  536. mvm_sta = iwl_mvm_sta_from_mac80211(sta);
  537. /* not a data packet or a bar */
  538. if (!ieee80211_is_back_req(hdr->frame_control) &&
  539. (!ieee80211_is_data_qos(hdr->frame_control) ||
  540. is_multicast_ether_addr(hdr->addr1)))
  541. return false;
  542. if (unlikely(!ieee80211_is_data_present(hdr->frame_control)))
  543. return false;
  544. baid_data = rcu_dereference(mvm->baid_map[baid]);
  545. if (!baid_data) {
  546. WARN(!(reorder & IWL_RX_MPDU_REORDER_BA_OLD_SN),
  547. "Received baid %d, but no data exists for this BAID\n",
  548. baid);
  549. return false;
  550. }
  551. if (WARN(tid != baid_data->tid || mvm_sta->sta_id != baid_data->sta_id,
  552. "baid 0x%x is mapped to sta:%d tid:%d, but was received for sta:%d tid:%d\n",
  553. baid, baid_data->sta_id, baid_data->tid, mvm_sta->sta_id,
  554. tid))
  555. return false;
  556. nssn = reorder & IWL_RX_MPDU_REORDER_NSSN_MASK;
  557. sn = (reorder & IWL_RX_MPDU_REORDER_SN_MASK) >>
  558. IWL_RX_MPDU_REORDER_SN_SHIFT;
  559. buffer = &baid_data->reorder_buf[queue];
  560. spin_lock_bh(&buffer->lock);
  561. if (!buffer->valid) {
  562. if (reorder & IWL_RX_MPDU_REORDER_BA_OLD_SN) {
  563. spin_unlock_bh(&buffer->lock);
  564. return false;
  565. }
  566. buffer->valid = true;
  567. }
  568. if (ieee80211_is_back_req(hdr->frame_control)) {
  569. iwl_mvm_release_frames(mvm, sta, napi, buffer, nssn);
  570. goto drop;
  571. }
  572. /*
  573. * If there was a significant jump in the nssn - adjust.
  574. * If the SN is smaller than the NSSN it might need to first go into
  575. * the reorder buffer, in which case we just release up to it and the
  576. * rest of the function will take of storing it and releasing up to the
  577. * nssn
  578. */
  579. if (!iwl_mvm_is_sn_less(nssn, buffer->head_sn + buffer->buf_size,
  580. buffer->buf_size)) {
  581. u16 min_sn = ieee80211_sn_less(sn, nssn) ? sn : nssn;
  582. iwl_mvm_release_frames(mvm, sta, napi, buffer, min_sn);
  583. }
  584. /* drop any oudated packets */
  585. if (ieee80211_sn_less(sn, buffer->head_sn))
  586. goto drop;
  587. /* release immediately if allowed by nssn and no stored frames */
  588. if (!buffer->num_stored && ieee80211_sn_less(sn, nssn)) {
  589. if (iwl_mvm_is_sn_less(buffer->head_sn, nssn,
  590. buffer->buf_size) &&
  591. (!amsdu || last_subframe))
  592. buffer->head_sn = nssn;
  593. /* No need to update AMSDU last SN - we are moving the head */
  594. spin_unlock_bh(&buffer->lock);
  595. return false;
  596. }
  597. index = sn % buffer->buf_size;
  598. /*
  599. * Check if we already stored this frame
  600. * As AMSDU is either received or not as whole, logic is simple:
  601. * If we have frames in that position in the buffer and the last frame
  602. * originated from AMSDU had a different SN then it is a retransmission.
  603. * If it is the same SN then if the subframe index is incrementing it
  604. * is the same AMSDU - otherwise it is a retransmission.
  605. */
  606. tail = skb_peek_tail(&buffer->entries[index]);
  607. if (tail && !amsdu)
  608. goto drop;
  609. else if (tail && (sn != buffer->last_amsdu ||
  610. buffer->last_sub_index >= sub_frame_idx))
  611. goto drop;
  612. /* put in reorder buffer */
  613. __skb_queue_tail(&buffer->entries[index], skb);
  614. buffer->num_stored++;
  615. buffer->reorder_time[index] = jiffies;
  616. if (amsdu) {
  617. buffer->last_amsdu = sn;
  618. buffer->last_sub_index = sub_frame_idx;
  619. }
  620. /*
  621. * We cannot trust NSSN for AMSDU sub-frames that are not the last.
  622. * The reason is that NSSN advances on the first sub-frame, and may
  623. * cause the reorder buffer to advance before all the sub-frames arrive.
  624. * Example: reorder buffer contains SN 0 & 2, and we receive AMSDU with
  625. * SN 1. NSSN for first sub frame will be 3 with the result of driver
  626. * releasing SN 0,1, 2. When sub-frame 1 arrives - reorder buffer is
  627. * already ahead and it will be dropped.
  628. * If the last sub-frame is not on this queue - we will get frame
  629. * release notification with up to date NSSN.
  630. */
  631. if (!amsdu || last_subframe)
  632. iwl_mvm_release_frames(mvm, sta, napi, buffer, nssn);
  633. spin_unlock_bh(&buffer->lock);
  634. return true;
  635. drop:
  636. kfree_skb(skb);
  637. spin_unlock_bh(&buffer->lock);
  638. return true;
  639. }
  640. static void iwl_mvm_agg_rx_received(struct iwl_mvm *mvm,
  641. u32 reorder_data, u8 baid)
  642. {
  643. unsigned long now = jiffies;
  644. unsigned long timeout;
  645. struct iwl_mvm_baid_data *data;
  646. rcu_read_lock();
  647. data = rcu_dereference(mvm->baid_map[baid]);
  648. if (!data) {
  649. WARN_ON(!(reorder_data & IWL_RX_MPDU_REORDER_BA_OLD_SN));
  650. goto out;
  651. }
  652. if (!data->timeout)
  653. goto out;
  654. timeout = data->timeout;
  655. /*
  656. * Do not update last rx all the time to avoid cache bouncing
  657. * between the rx queues.
  658. * Update it every timeout. Worst case is the session will
  659. * expire after ~ 2 * timeout, which doesn't matter that much.
  660. */
  661. if (time_before(data->last_rx + TU_TO_JIFFIES(timeout), now))
  662. /* Update is atomic */
  663. data->last_rx = now;
  664. out:
  665. rcu_read_unlock();
  666. }
  667. void iwl_mvm_rx_mpdu_mq(struct iwl_mvm *mvm, struct napi_struct *napi,
  668. struct iwl_rx_cmd_buffer *rxb, int queue)
  669. {
  670. struct ieee80211_rx_status *rx_status;
  671. struct iwl_rx_packet *pkt = rxb_addr(rxb);
  672. struct iwl_rx_mpdu_desc *desc = (void *)pkt->data;
  673. struct ieee80211_hdr *hdr = (void *)(pkt->data + sizeof(*desc));
  674. u32 len = le16_to_cpu(desc->mpdu_len);
  675. u32 rate_n_flags = le32_to_cpu(desc->rate_n_flags);
  676. u16 phy_info = le16_to_cpu(desc->phy_info);
  677. struct ieee80211_sta *sta = NULL;
  678. struct sk_buff *skb;
  679. u8 crypt_len = 0;
  680. /* Dont use dev_alloc_skb(), we'll have enough headroom once
  681. * ieee80211_hdr pulled.
  682. */
  683. skb = alloc_skb(128, GFP_ATOMIC);
  684. if (!skb) {
  685. IWL_ERR(mvm, "alloc_skb failed\n");
  686. return;
  687. }
  688. rx_status = IEEE80211_SKB_RXCB(skb);
  689. if (iwl_mvm_rx_crypto(mvm, hdr, rx_status, desc, queue, &crypt_len)) {
  690. kfree_skb(skb);
  691. return;
  692. }
  693. /*
  694. * Keep packets with CRC errors (and with overrun) for monitor mode
  695. * (otherwise the firmware discards them) but mark them as bad.
  696. */
  697. if (!(desc->status & cpu_to_le16(IWL_RX_MPDU_STATUS_CRC_OK)) ||
  698. !(desc->status & cpu_to_le16(IWL_RX_MPDU_STATUS_OVERRUN_OK))) {
  699. IWL_DEBUG_RX(mvm, "Bad CRC or FIFO: 0x%08X.\n",
  700. le16_to_cpu(desc->status));
  701. rx_status->flag |= RX_FLAG_FAILED_FCS_CRC;
  702. }
  703. /* set the preamble flag if appropriate */
  704. if (phy_info & IWL_RX_MPDU_PHY_SHORT_PREAMBLE)
  705. rx_status->enc_flags |= RX_ENC_FLAG_SHORTPRE;
  706. if (likely(!(phy_info & IWL_RX_MPDU_PHY_TSF_OVERLOAD))) {
  707. rx_status->mactime = le64_to_cpu(desc->tsf_on_air_rise);
  708. /* TSF as indicated by the firmware is at INA time */
  709. rx_status->flag |= RX_FLAG_MACTIME_PLCP_START;
  710. }
  711. rx_status->device_timestamp = le32_to_cpu(desc->gp2_on_air_rise);
  712. rx_status->band = desc->channel > 14 ? NL80211_BAND_5GHZ :
  713. NL80211_BAND_2GHZ;
  714. rx_status->freq = ieee80211_channel_to_frequency(desc->channel,
  715. rx_status->band);
  716. iwl_mvm_get_signal_strength(mvm, desc, rx_status);
  717. /* update aggregation data for monitor sake on default queue */
  718. if (!queue && (phy_info & IWL_RX_MPDU_PHY_AMPDU)) {
  719. bool toggle_bit = phy_info & IWL_RX_MPDU_PHY_AMPDU_TOGGLE;
  720. rx_status->flag |= RX_FLAG_AMPDU_DETAILS;
  721. rx_status->ampdu_reference = mvm->ampdu_ref;
  722. /* toggle is switched whenever new aggregation starts */
  723. if (toggle_bit != mvm->ampdu_toggle) {
  724. mvm->ampdu_ref++;
  725. mvm->ampdu_toggle = toggle_bit;
  726. }
  727. }
  728. rcu_read_lock();
  729. if (le16_to_cpu(desc->status) & IWL_RX_MPDU_STATUS_SRC_STA_FOUND) {
  730. u8 id = desc->sta_id_flags & IWL_RX_MPDU_SIF_STA_ID_MASK;
  731. if (!WARN_ON_ONCE(id >= ARRAY_SIZE(mvm->fw_id_to_mac_id))) {
  732. sta = rcu_dereference(mvm->fw_id_to_mac_id[id]);
  733. if (IS_ERR(sta))
  734. sta = NULL;
  735. }
  736. } else if (!is_multicast_ether_addr(hdr->addr2)) {
  737. /*
  738. * This is fine since we prevent two stations with the same
  739. * address from being added.
  740. */
  741. sta = ieee80211_find_sta_by_ifaddr(mvm->hw, hdr->addr2, NULL);
  742. }
  743. if (sta) {
  744. struct iwl_mvm_sta *mvmsta = iwl_mvm_sta_from_mac80211(sta);
  745. struct ieee80211_vif *tx_blocked_vif =
  746. rcu_dereference(mvm->csa_tx_blocked_vif);
  747. u8 baid = (u8)((le32_to_cpu(desc->reorder_data) &
  748. IWL_RX_MPDU_REORDER_BAID_MASK) >>
  749. IWL_RX_MPDU_REORDER_BAID_SHIFT);
  750. /*
  751. * We have tx blocked stations (with CS bit). If we heard
  752. * frames from a blocked station on a new channel we can
  753. * TX to it again.
  754. */
  755. if (unlikely(tx_blocked_vif) &&
  756. tx_blocked_vif == mvmsta->vif) {
  757. struct iwl_mvm_vif *mvmvif =
  758. iwl_mvm_vif_from_mac80211(tx_blocked_vif);
  759. if (mvmvif->csa_target_freq == rx_status->freq)
  760. iwl_mvm_sta_modify_disable_tx_ap(mvm, sta,
  761. false);
  762. }
  763. rs_update_last_rssi(mvm, &mvmsta->lq_sta, rx_status);
  764. if (iwl_fw_dbg_trigger_enabled(mvm->fw, FW_DBG_TRIGGER_RSSI) &&
  765. ieee80211_is_beacon(hdr->frame_control)) {
  766. struct iwl_fw_dbg_trigger_tlv *trig;
  767. struct iwl_fw_dbg_trigger_low_rssi *rssi_trig;
  768. bool trig_check;
  769. s32 rssi;
  770. trig = iwl_fw_dbg_get_trigger(mvm->fw,
  771. FW_DBG_TRIGGER_RSSI);
  772. rssi_trig = (void *)trig->data;
  773. rssi = le32_to_cpu(rssi_trig->rssi);
  774. trig_check =
  775. iwl_fw_dbg_trigger_check_stop(mvm, mvmsta->vif,
  776. trig);
  777. if (trig_check && rx_status->signal < rssi)
  778. iwl_mvm_fw_dbg_collect_trig(mvm, trig, NULL);
  779. }
  780. if (ieee80211_is_data(hdr->frame_control))
  781. iwl_mvm_rx_csum(sta, skb, desc);
  782. if (iwl_mvm_is_nonagg_dup(sta, queue, rx_status, hdr, desc)) {
  783. kfree_skb(skb);
  784. goto out;
  785. }
  786. /*
  787. * Our hardware de-aggregates AMSDUs but copies the mac header
  788. * as it to the de-aggregated MPDUs. We need to turn off the
  789. * AMSDU bit in the QoS control ourselves.
  790. * In addition, HW reverses addr3 and addr4 - reverse it back.
  791. */
  792. if ((desc->mac_flags2 & IWL_RX_MPDU_MFLG2_AMSDU) &&
  793. !WARN_ON(!ieee80211_is_data_qos(hdr->frame_control))) {
  794. int i;
  795. u8 *qc = ieee80211_get_qos_ctl(hdr);
  796. u8 mac_addr[ETH_ALEN];
  797. *qc &= ~IEEE80211_QOS_CTL_A_MSDU_PRESENT;
  798. for (i = 0; i < ETH_ALEN; i++)
  799. mac_addr[i] = hdr->addr3[ETH_ALEN - i - 1];
  800. ether_addr_copy(hdr->addr3, mac_addr);
  801. if (ieee80211_has_a4(hdr->frame_control)) {
  802. for (i = 0; i < ETH_ALEN; i++)
  803. mac_addr[i] =
  804. hdr->addr4[ETH_ALEN - i - 1];
  805. ether_addr_copy(hdr->addr4, mac_addr);
  806. }
  807. }
  808. if (baid != IWL_RX_REORDER_DATA_INVALID_BAID) {
  809. u32 reorder_data = le32_to_cpu(desc->reorder_data);
  810. iwl_mvm_agg_rx_received(mvm, reorder_data, baid);
  811. }
  812. }
  813. /* Set up the HT phy flags */
  814. switch (rate_n_flags & RATE_MCS_CHAN_WIDTH_MSK) {
  815. case RATE_MCS_CHAN_WIDTH_20:
  816. break;
  817. case RATE_MCS_CHAN_WIDTH_40:
  818. rx_status->bw = RATE_INFO_BW_40;
  819. break;
  820. case RATE_MCS_CHAN_WIDTH_80:
  821. rx_status->bw = RATE_INFO_BW_80;
  822. break;
  823. case RATE_MCS_CHAN_WIDTH_160:
  824. rx_status->bw = RATE_INFO_BW_160;
  825. break;
  826. }
  827. if (rate_n_flags & RATE_MCS_SGI_MSK)
  828. rx_status->enc_flags |= RX_ENC_FLAG_SHORT_GI;
  829. if (rate_n_flags & RATE_HT_MCS_GF_MSK)
  830. rx_status->enc_flags |= RX_ENC_FLAG_HT_GF;
  831. if (rate_n_flags & RATE_MCS_LDPC_MSK)
  832. rx_status->enc_flags |= RX_ENC_FLAG_LDPC;
  833. if (rate_n_flags & RATE_MCS_HT_MSK) {
  834. u8 stbc = (rate_n_flags & RATE_MCS_STBC_MSK) >>
  835. RATE_MCS_STBC_POS;
  836. rx_status->encoding = RX_ENC_HT;
  837. rx_status->rate_idx = rate_n_flags & RATE_HT_MCS_INDEX_MSK;
  838. rx_status->enc_flags |= stbc << RX_ENC_FLAG_STBC_SHIFT;
  839. } else if (rate_n_flags & RATE_MCS_VHT_MSK) {
  840. u8 stbc = (rate_n_flags & RATE_MCS_STBC_MSK) >>
  841. RATE_MCS_STBC_POS;
  842. rx_status->nss =
  843. ((rate_n_flags & RATE_VHT_MCS_NSS_MSK) >>
  844. RATE_VHT_MCS_NSS_POS) + 1;
  845. rx_status->rate_idx = rate_n_flags & RATE_VHT_MCS_RATE_CODE_MSK;
  846. rx_status->encoding = RX_ENC_VHT;
  847. rx_status->enc_flags |= stbc << RX_ENC_FLAG_STBC_SHIFT;
  848. if (rate_n_flags & RATE_MCS_BF_MSK)
  849. rx_status->enc_flags |= RX_ENC_FLAG_BF;
  850. } else {
  851. int rate = iwl_mvm_legacy_rate_to_mac80211_idx(rate_n_flags,
  852. rx_status->band);
  853. if (WARN(rate < 0 || rate > 0xFF,
  854. "Invalid rate flags 0x%x, band %d,\n",
  855. rate_n_flags, rx_status->band)) {
  856. kfree_skb(skb);
  857. goto out;
  858. }
  859. rx_status->rate_idx = rate;
  860. }
  861. /* management stuff on default queue */
  862. if (!queue) {
  863. if (unlikely((ieee80211_is_beacon(hdr->frame_control) ||
  864. ieee80211_is_probe_resp(hdr->frame_control)) &&
  865. mvm->sched_scan_pass_all ==
  866. SCHED_SCAN_PASS_ALL_ENABLED))
  867. mvm->sched_scan_pass_all = SCHED_SCAN_PASS_ALL_FOUND;
  868. if (unlikely(ieee80211_is_beacon(hdr->frame_control) ||
  869. ieee80211_is_probe_resp(hdr->frame_control)))
  870. rx_status->boottime_ns = ktime_get_boot_ns();
  871. }
  872. iwl_mvm_create_skb(skb, hdr, len, crypt_len, rxb);
  873. if (!iwl_mvm_reorder(mvm, napi, queue, sta, skb, desc))
  874. iwl_mvm_pass_packet_to_mac80211(mvm, napi, skb, queue, sta);
  875. out:
  876. rcu_read_unlock();
  877. }
  878. void iwl_mvm_rx_frame_release(struct iwl_mvm *mvm, struct napi_struct *napi,
  879. struct iwl_rx_cmd_buffer *rxb, int queue)
  880. {
  881. struct iwl_rx_packet *pkt = rxb_addr(rxb);
  882. struct iwl_frame_release *release = (void *)pkt->data;
  883. struct ieee80211_sta *sta;
  884. struct iwl_mvm_reorder_buffer *reorder_buf;
  885. struct iwl_mvm_baid_data *ba_data;
  886. int baid = release->baid;
  887. IWL_DEBUG_HT(mvm, "Frame release notification for BAID %u, NSSN %d\n",
  888. release->baid, le16_to_cpu(release->nssn));
  889. if (WARN_ON_ONCE(baid == IWL_RX_REORDER_DATA_INVALID_BAID))
  890. return;
  891. rcu_read_lock();
  892. ba_data = rcu_dereference(mvm->baid_map[baid]);
  893. if (WARN_ON_ONCE(!ba_data))
  894. goto out;
  895. sta = rcu_dereference(mvm->fw_id_to_mac_id[ba_data->sta_id]);
  896. if (WARN_ON_ONCE(IS_ERR_OR_NULL(sta)))
  897. goto out;
  898. reorder_buf = &ba_data->reorder_buf[queue];
  899. spin_lock_bh(&reorder_buf->lock);
  900. iwl_mvm_release_frames(mvm, sta, napi, reorder_buf,
  901. le16_to_cpu(release->nssn));
  902. spin_unlock_bh(&reorder_buf->lock);
  903. out:
  904. rcu_read_unlock();
  905. }