rxmq.c 32 KB

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