rxmq.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599
  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 - 2016 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 - 2016 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. void iwl_mvm_rx_phy_cmd_mq(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb)
  68. {
  69. mvm->ampdu_ref++;
  70. #ifdef CONFIG_IWLWIFI_DEBUGFS
  71. if (mvm->last_phy_info.phy_flags & cpu_to_le16(RX_RES_PHY_FLAGS_AGG)) {
  72. spin_lock(&mvm->drv_stats_lock);
  73. mvm->drv_rx_stats.ampdu_count++;
  74. spin_unlock(&mvm->drv_stats_lock);
  75. }
  76. #endif
  77. }
  78. static inline int iwl_mvm_check_pn(struct iwl_mvm *mvm, struct sk_buff *skb,
  79. int queue, struct ieee80211_sta *sta)
  80. {
  81. struct iwl_mvm_sta *mvmsta;
  82. struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
  83. struct ieee80211_rx_status *stats = IEEE80211_SKB_RXCB(skb);
  84. struct iwl_mvm_key_pn *ptk_pn;
  85. u8 tid, keyidx;
  86. u8 pn[IEEE80211_CCMP_PN_LEN];
  87. u8 *extiv;
  88. /* do PN checking */
  89. /* multicast and non-data only arrives on default queue */
  90. if (!ieee80211_is_data(hdr->frame_control) ||
  91. is_multicast_ether_addr(hdr->addr1))
  92. return 0;
  93. /* do not check PN for open AP */
  94. if (!(stats->flag & RX_FLAG_DECRYPTED))
  95. return 0;
  96. /*
  97. * avoid checking for default queue - we don't want to replicate
  98. * all the logic that's necessary for checking the PN on fragmented
  99. * frames, leave that to mac80211
  100. */
  101. if (queue == 0)
  102. return 0;
  103. /* if we are here - this for sure is either CCMP or GCMP */
  104. if (IS_ERR_OR_NULL(sta)) {
  105. IWL_ERR(mvm,
  106. "expected hw-decrypted unicast frame for station\n");
  107. return -1;
  108. }
  109. mvmsta = iwl_mvm_sta_from_mac80211(sta);
  110. extiv = (u8 *)hdr + ieee80211_hdrlen(hdr->frame_control);
  111. keyidx = extiv[3] >> 6;
  112. ptk_pn = rcu_dereference(mvmsta->ptk_pn[keyidx]);
  113. if (!ptk_pn)
  114. return -1;
  115. if (ieee80211_is_data_qos(hdr->frame_control))
  116. tid = *ieee80211_get_qos_ctl(hdr) & IEEE80211_QOS_CTL_TID_MASK;
  117. else
  118. tid = 0;
  119. /* we don't use HCCA/802.11 QoS TSPECs, so drop such frames */
  120. if (tid >= IWL_MAX_TID_COUNT)
  121. return -1;
  122. /* load pn */
  123. pn[0] = extiv[7];
  124. pn[1] = extiv[6];
  125. pn[2] = extiv[5];
  126. pn[3] = extiv[4];
  127. pn[4] = extiv[1];
  128. pn[5] = extiv[0];
  129. if (memcmp(pn, ptk_pn->q[queue].pn[tid],
  130. IEEE80211_CCMP_PN_LEN) <= 0)
  131. return -1;
  132. memcpy(ptk_pn->q[queue].pn[tid], pn, IEEE80211_CCMP_PN_LEN);
  133. stats->flag |= RX_FLAG_PN_VALIDATED;
  134. return 0;
  135. }
  136. /* iwl_mvm_create_skb Adds the rxb to a new skb */
  137. static void iwl_mvm_create_skb(struct sk_buff *skb, struct ieee80211_hdr *hdr,
  138. u16 len, u8 crypt_len,
  139. struct iwl_rx_cmd_buffer *rxb)
  140. {
  141. struct iwl_rx_packet *pkt = rxb_addr(rxb);
  142. struct iwl_rx_mpdu_desc *desc = (void *)pkt->data;
  143. unsigned int headlen, fraglen, pad_len = 0;
  144. unsigned int hdrlen = ieee80211_hdrlen(hdr->frame_control);
  145. if (desc->mac_flags2 & IWL_RX_MPDU_MFLG2_PAD)
  146. pad_len = 2;
  147. len -= pad_len;
  148. /* If frame is small enough to fit in skb->head, pull it completely.
  149. * If not, only pull ieee80211_hdr (including crypto if present, and
  150. * an additional 8 bytes for SNAP/ethertype, see below) so that
  151. * splice() or TCP coalesce are more efficient.
  152. *
  153. * Since, in addition, ieee80211_data_to_8023() always pull in at
  154. * least 8 bytes (possibly more for mesh) we can do the same here
  155. * to save the cost of doing it later. That still doesn't pull in
  156. * the actual IP header since the typical case has a SNAP header.
  157. * If the latter changes (there are efforts in the standards group
  158. * to do so) we should revisit this and ieee80211_data_to_8023().
  159. */
  160. headlen = (len <= skb_tailroom(skb)) ? len :
  161. hdrlen + crypt_len + 8;
  162. /* The firmware may align the packet to DWORD.
  163. * The padding is inserted after the IV.
  164. * After copying the header + IV skip the padding if
  165. * present before copying packet data.
  166. */
  167. hdrlen += crypt_len;
  168. memcpy(skb_put(skb, hdrlen), hdr, hdrlen);
  169. memcpy(skb_put(skb, headlen - hdrlen), (u8 *)hdr + hdrlen + pad_len,
  170. headlen - hdrlen);
  171. fraglen = len - headlen;
  172. if (fraglen) {
  173. int offset = (void *)hdr + headlen + pad_len -
  174. rxb_addr(rxb) + rxb_offset(rxb);
  175. skb_add_rx_frag(skb, 0, rxb_steal_page(rxb), offset,
  176. fraglen, rxb->truesize);
  177. }
  178. }
  179. /* iwl_mvm_pass_packet_to_mac80211 - passes the packet for mac80211 */
  180. static void iwl_mvm_pass_packet_to_mac80211(struct iwl_mvm *mvm,
  181. struct napi_struct *napi,
  182. struct sk_buff *skb, int queue,
  183. struct ieee80211_sta *sta)
  184. {
  185. if (iwl_mvm_check_pn(mvm, skb, queue, sta))
  186. kfree_skb(skb);
  187. else
  188. ieee80211_rx_napi(mvm->hw, skb, napi);
  189. }
  190. static void iwl_mvm_get_signal_strength(struct iwl_mvm *mvm,
  191. struct iwl_rx_mpdu_desc *desc,
  192. struct ieee80211_rx_status *rx_status)
  193. {
  194. int energy_a, energy_b, max_energy;
  195. energy_a = desc->energy_a;
  196. energy_a = energy_a ? -energy_a : S8_MIN;
  197. energy_b = desc->energy_b;
  198. energy_b = energy_b ? -energy_b : S8_MIN;
  199. max_energy = max(energy_a, energy_b);
  200. IWL_DEBUG_STATS(mvm, "energy In A %d B %d, and max %d\n",
  201. energy_a, energy_b, max_energy);
  202. rx_status->signal = max_energy;
  203. rx_status->chains = 0; /* TODO: phy info */
  204. rx_status->chain_signal[0] = energy_a;
  205. rx_status->chain_signal[1] = energy_b;
  206. rx_status->chain_signal[2] = S8_MIN;
  207. }
  208. static int iwl_mvm_rx_crypto(struct iwl_mvm *mvm, struct ieee80211_hdr *hdr,
  209. struct ieee80211_rx_status *stats,
  210. struct iwl_rx_mpdu_desc *desc, int queue,
  211. u8 *crypt_len)
  212. {
  213. u16 status = le16_to_cpu(desc->status);
  214. if (!ieee80211_has_protected(hdr->frame_control) ||
  215. (status & IWL_RX_MPDU_STATUS_SEC_MASK) ==
  216. IWL_RX_MPDU_STATUS_SEC_NONE)
  217. return 0;
  218. /* TODO: handle packets encrypted with unknown alg */
  219. switch (status & IWL_RX_MPDU_STATUS_SEC_MASK) {
  220. case IWL_RX_MPDU_STATUS_SEC_CCM:
  221. case IWL_RX_MPDU_STATUS_SEC_GCM:
  222. BUILD_BUG_ON(IEEE80211_CCMP_PN_LEN != IEEE80211_GCMP_PN_LEN);
  223. /* alg is CCM: check MIC only */
  224. if (!(status & IWL_RX_MPDU_STATUS_MIC_OK))
  225. return -1;
  226. stats->flag |= RX_FLAG_DECRYPTED;
  227. *crypt_len = IEEE80211_CCMP_HDR_LEN;
  228. return 0;
  229. case IWL_RX_MPDU_STATUS_SEC_TKIP:
  230. /* Don't drop the frame and decrypt it in SW */
  231. if (!(status & IWL_RX_MPDU_RES_STATUS_TTAK_OK))
  232. return 0;
  233. *crypt_len = IEEE80211_TKIP_IV_LEN;
  234. /* fall through if TTAK OK */
  235. case IWL_RX_MPDU_STATUS_SEC_WEP:
  236. if (!(status & IWL_RX_MPDU_STATUS_ICV_OK))
  237. return -1;
  238. stats->flag |= RX_FLAG_DECRYPTED;
  239. if ((status & IWL_RX_MPDU_STATUS_SEC_MASK) ==
  240. IWL_RX_MPDU_STATUS_SEC_WEP)
  241. *crypt_len = IEEE80211_WEP_IV_LEN;
  242. return 0;
  243. case IWL_RX_MPDU_STATUS_SEC_EXT_ENC:
  244. if (!(status & IWL_RX_MPDU_STATUS_MIC_OK))
  245. return -1;
  246. stats->flag |= RX_FLAG_DECRYPTED;
  247. return 0;
  248. default:
  249. IWL_ERR(mvm, "Unhandled alg: 0x%x\n", status);
  250. }
  251. return 0;
  252. }
  253. static void iwl_mvm_rx_csum(struct ieee80211_sta *sta,
  254. struct sk_buff *skb,
  255. struct iwl_rx_mpdu_desc *desc)
  256. {
  257. struct iwl_mvm_sta *mvmsta = iwl_mvm_sta_from_mac80211(sta);
  258. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(mvmsta->vif);
  259. if (mvmvif->features & NETIF_F_RXCSUM &&
  260. desc->l3l4_flags & cpu_to_le16(IWL_RX_L3L4_IP_HDR_CSUM_OK) &&
  261. desc->l3l4_flags & cpu_to_le16(IWL_RX_L3L4_TCP_UDP_CSUM_OK))
  262. skb->ip_summed = CHECKSUM_UNNECESSARY;
  263. }
  264. /*
  265. * returns true if a packet outside BA session is a duplicate and
  266. * should be dropped
  267. */
  268. static bool iwl_mvm_is_nonagg_dup(struct ieee80211_sta *sta, int queue,
  269. struct ieee80211_rx_status *rx_status,
  270. struct ieee80211_hdr *hdr,
  271. struct iwl_rx_mpdu_desc *desc)
  272. {
  273. struct iwl_mvm_sta *mvm_sta;
  274. struct iwl_mvm_rxq_dup_data *dup_data;
  275. u8 baid, tid, sub_frame_idx;
  276. if (WARN_ON(IS_ERR_OR_NULL(sta)))
  277. return false;
  278. baid = (le32_to_cpu(desc->reorder_data) &
  279. IWL_RX_MPDU_REORDER_BAID_MASK) >>
  280. IWL_RX_MPDU_REORDER_BAID_SHIFT;
  281. if (baid != IWL_RX_REORDER_DATA_INVALID_BAID)
  282. return false;
  283. mvm_sta = iwl_mvm_sta_from_mac80211(sta);
  284. dup_data = &mvm_sta->dup_data[queue];
  285. /*
  286. * Drop duplicate 802.11 retransmissions
  287. * (IEEE 802.11-2012: 9.3.2.10 "Duplicate detection and recovery")
  288. */
  289. if (ieee80211_is_ctl(hdr->frame_control) ||
  290. ieee80211_is_qos_nullfunc(hdr->frame_control) ||
  291. is_multicast_ether_addr(hdr->addr1)) {
  292. rx_status->flag |= RX_FLAG_DUP_VALIDATED;
  293. return false;
  294. }
  295. if (ieee80211_is_data_qos(hdr->frame_control))
  296. /* frame has qos control */
  297. tid = *ieee80211_get_qos_ctl(hdr) &
  298. IEEE80211_QOS_CTL_TID_MASK;
  299. else
  300. tid = IWL_MAX_TID_COUNT;
  301. /* If this wasn't a part of an A-MSDU the sub-frame index will be 0 */
  302. sub_frame_idx = desc->amsdu_info & IWL_RX_MPDU_AMSDU_SUBFRAME_IDX_MASK;
  303. if (unlikely(ieee80211_has_retry(hdr->frame_control) &&
  304. dup_data->last_seq[tid] == hdr->seq_ctrl &&
  305. dup_data->last_sub_frame[tid] >= sub_frame_idx))
  306. return true;
  307. dup_data->last_seq[tid] = hdr->seq_ctrl;
  308. dup_data->last_sub_frame[tid] = sub_frame_idx;
  309. rx_status->flag |= RX_FLAG_DUP_VALIDATED;
  310. return false;
  311. }
  312. int iwl_mvm_notify_rx_queue(struct iwl_mvm *mvm, u32 rxq_mask,
  313. const u8 *data, u32 count)
  314. {
  315. struct iwl_rxq_sync_cmd *cmd;
  316. u32 data_size = sizeof(*cmd) + count;
  317. int ret;
  318. /* should be DWORD aligned */
  319. if (WARN_ON(count & 3 || count > IWL_MULTI_QUEUE_SYNC_MSG_MAX_SIZE))
  320. return -EINVAL;
  321. cmd = kzalloc(data_size, GFP_KERNEL);
  322. if (!cmd)
  323. return -ENOMEM;
  324. cmd->rxq_mask = cpu_to_le32(rxq_mask);
  325. cmd->count = cpu_to_le32(count);
  326. cmd->flags = 0;
  327. memcpy(cmd->payload, data, count);
  328. ret = iwl_mvm_send_cmd_pdu(mvm,
  329. WIDE_ID(DATA_PATH_GROUP,
  330. TRIGGER_RX_QUEUES_NOTIF_CMD),
  331. 0, data_size, cmd);
  332. kfree(cmd);
  333. return ret;
  334. }
  335. void iwl_mvm_rx_queue_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb,
  336. int queue)
  337. {
  338. struct iwl_rx_packet *pkt = rxb_addr(rxb);
  339. struct iwl_rxq_sync_notification *notif;
  340. struct iwl_mvm_internal_rxq_notif *internal_notif;
  341. notif = (void *)pkt->data;
  342. internal_notif = (void *)notif->payload;
  343. switch (internal_notif->type) {
  344. case IWL_MVM_RXQ_NOTIF_DEL_BA:
  345. /* TODO */
  346. break;
  347. default:
  348. WARN_ONCE(1, "Invalid identifier %d", internal_notif->type);
  349. }
  350. }
  351. void iwl_mvm_rx_mpdu_mq(struct iwl_mvm *mvm, struct napi_struct *napi,
  352. struct iwl_rx_cmd_buffer *rxb, int queue)
  353. {
  354. struct ieee80211_rx_status *rx_status;
  355. struct iwl_rx_packet *pkt = rxb_addr(rxb);
  356. struct iwl_rx_mpdu_desc *desc = (void *)pkt->data;
  357. struct ieee80211_hdr *hdr = (void *)(pkt->data + sizeof(*desc));
  358. u32 len = le16_to_cpu(desc->mpdu_len);
  359. u32 rate_n_flags = le32_to_cpu(desc->rate_n_flags);
  360. struct ieee80211_sta *sta = NULL;
  361. struct sk_buff *skb;
  362. u8 crypt_len = 0;
  363. /* Dont use dev_alloc_skb(), we'll have enough headroom once
  364. * ieee80211_hdr pulled.
  365. */
  366. skb = alloc_skb(128, GFP_ATOMIC);
  367. if (!skb) {
  368. IWL_ERR(mvm, "alloc_skb failed\n");
  369. return;
  370. }
  371. rx_status = IEEE80211_SKB_RXCB(skb);
  372. if (iwl_mvm_rx_crypto(mvm, hdr, rx_status, desc, queue, &crypt_len)) {
  373. kfree_skb(skb);
  374. return;
  375. }
  376. /*
  377. * Keep packets with CRC errors (and with overrun) for monitor mode
  378. * (otherwise the firmware discards them) but mark them as bad.
  379. */
  380. if (!(desc->status & cpu_to_le16(IWL_RX_MPDU_STATUS_CRC_OK)) ||
  381. !(desc->status & cpu_to_le16(IWL_RX_MPDU_STATUS_OVERRUN_OK))) {
  382. IWL_DEBUG_RX(mvm, "Bad CRC or FIFO: 0x%08X.\n",
  383. le16_to_cpu(desc->status));
  384. rx_status->flag |= RX_FLAG_FAILED_FCS_CRC;
  385. }
  386. rx_status->mactime = le64_to_cpu(desc->tsf_on_air_rise);
  387. rx_status->device_timestamp = le32_to_cpu(desc->gp2_on_air_rise);
  388. rx_status->band = desc->channel > 14 ? IEEE80211_BAND_5GHZ :
  389. IEEE80211_BAND_2GHZ;
  390. rx_status->freq = ieee80211_channel_to_frequency(desc->channel,
  391. rx_status->band);
  392. iwl_mvm_get_signal_strength(mvm, desc, rx_status);
  393. /* TSF as indicated by the firmware is at INA time */
  394. rx_status->flag |= RX_FLAG_MACTIME_PLCP_START;
  395. rcu_read_lock();
  396. if (le16_to_cpu(desc->status) & IWL_RX_MPDU_STATUS_SRC_STA_FOUND) {
  397. u8 id = desc->sta_id_flags & IWL_RX_MPDU_SIF_STA_ID_MASK;
  398. if (!WARN_ON_ONCE(id >= IWL_MVM_STATION_COUNT)) {
  399. sta = rcu_dereference(mvm->fw_id_to_mac_id[id]);
  400. if (IS_ERR(sta))
  401. sta = NULL;
  402. }
  403. } else if (!is_multicast_ether_addr(hdr->addr2)) {
  404. /*
  405. * This is fine since we prevent two stations with the same
  406. * address from being added.
  407. */
  408. sta = ieee80211_find_sta_by_ifaddr(mvm->hw, hdr->addr2, NULL);
  409. }
  410. if (sta) {
  411. struct iwl_mvm_sta *mvmsta = iwl_mvm_sta_from_mac80211(sta);
  412. /*
  413. * We have tx blocked stations (with CS bit). If we heard
  414. * frames from a blocked station on a new channel we can
  415. * TX to it again.
  416. */
  417. if (unlikely(mvm->csa_tx_block_bcn_timeout))
  418. iwl_mvm_sta_modify_disable_tx_ap(mvm, sta, false);
  419. rs_update_last_rssi(mvm, &mvmsta->lq_sta, rx_status);
  420. if (iwl_fw_dbg_trigger_enabled(mvm->fw, FW_DBG_TRIGGER_RSSI) &&
  421. ieee80211_is_beacon(hdr->frame_control)) {
  422. struct iwl_fw_dbg_trigger_tlv *trig;
  423. struct iwl_fw_dbg_trigger_low_rssi *rssi_trig;
  424. bool trig_check;
  425. s32 rssi;
  426. trig = iwl_fw_dbg_get_trigger(mvm->fw,
  427. FW_DBG_TRIGGER_RSSI);
  428. rssi_trig = (void *)trig->data;
  429. rssi = le32_to_cpu(rssi_trig->rssi);
  430. trig_check =
  431. iwl_fw_dbg_trigger_check_stop(mvm, mvmsta->vif,
  432. trig);
  433. if (trig_check && rx_status->signal < rssi)
  434. iwl_mvm_fw_dbg_collect_trig(mvm, trig, NULL);
  435. }
  436. /* TODO: multi queue TCM */
  437. if (ieee80211_is_data(hdr->frame_control))
  438. iwl_mvm_rx_csum(sta, skb, desc);
  439. if (iwl_mvm_is_nonagg_dup(sta, queue, rx_status, hdr, desc)) {
  440. kfree_skb(skb);
  441. rcu_read_unlock();
  442. return;
  443. }
  444. /*
  445. * Our hardware de-aggregates AMSDUs but copies the mac header
  446. * as it to the de-aggregated MPDUs. We need to turn off the
  447. * AMSDU bit in the QoS control ourselves.
  448. */
  449. if ((desc->mac_flags2 & IWL_RX_MPDU_MFLG2_AMSDU) &&
  450. !WARN_ON(!ieee80211_is_data_qos(hdr->frame_control))) {
  451. u8 *qc = ieee80211_get_qos_ctl(hdr);
  452. *qc &= ~IEEE80211_QOS_CTL_A_MSDU_PRESENT;
  453. }
  454. }
  455. /*
  456. * TODO: PHY info.
  457. * Verify we don't have the information in the MPDU descriptor and
  458. * that it is not needed.
  459. * Make sure for monitor mode that we are on default queue, update
  460. * ampdu_ref and the rest of phy info then
  461. */
  462. /* Set up the HT phy flags */
  463. switch (rate_n_flags & RATE_MCS_CHAN_WIDTH_MSK) {
  464. case RATE_MCS_CHAN_WIDTH_20:
  465. break;
  466. case RATE_MCS_CHAN_WIDTH_40:
  467. rx_status->flag |= RX_FLAG_40MHZ;
  468. break;
  469. case RATE_MCS_CHAN_WIDTH_80:
  470. rx_status->vht_flag |= RX_VHT_FLAG_80MHZ;
  471. break;
  472. case RATE_MCS_CHAN_WIDTH_160:
  473. rx_status->vht_flag |= RX_VHT_FLAG_160MHZ;
  474. break;
  475. }
  476. if (rate_n_flags & RATE_MCS_SGI_MSK)
  477. rx_status->flag |= RX_FLAG_SHORT_GI;
  478. if (rate_n_flags & RATE_HT_MCS_GF_MSK)
  479. rx_status->flag |= RX_FLAG_HT_GF;
  480. if (rate_n_flags & RATE_MCS_LDPC_MSK)
  481. rx_status->flag |= RX_FLAG_LDPC;
  482. if (rate_n_flags & RATE_MCS_HT_MSK) {
  483. u8 stbc = (rate_n_flags & RATE_MCS_HT_STBC_MSK) >>
  484. RATE_MCS_STBC_POS;
  485. rx_status->flag |= RX_FLAG_HT;
  486. rx_status->rate_idx = rate_n_flags & RATE_HT_MCS_INDEX_MSK;
  487. rx_status->flag |= stbc << RX_FLAG_STBC_SHIFT;
  488. } else if (rate_n_flags & RATE_MCS_VHT_MSK) {
  489. u8 stbc = (rate_n_flags & RATE_MCS_VHT_STBC_MSK) >>
  490. RATE_MCS_STBC_POS;
  491. rx_status->vht_nss =
  492. ((rate_n_flags & RATE_VHT_MCS_NSS_MSK) >>
  493. RATE_VHT_MCS_NSS_POS) + 1;
  494. rx_status->rate_idx = rate_n_flags & RATE_VHT_MCS_RATE_CODE_MSK;
  495. rx_status->flag |= RX_FLAG_VHT;
  496. rx_status->flag |= stbc << RX_FLAG_STBC_SHIFT;
  497. if (rate_n_flags & RATE_MCS_BF_MSK)
  498. rx_status->vht_flag |= RX_VHT_FLAG_BF;
  499. } else {
  500. rx_status->rate_idx =
  501. iwl_mvm_legacy_rate_to_mac80211_idx(rate_n_flags,
  502. rx_status->band);
  503. }
  504. /* TODO: PHY info - update ampdu queue statistics (for debugfs) */
  505. /* TODO: PHY info - gscan */
  506. iwl_mvm_create_skb(skb, hdr, len, crypt_len, rxb);
  507. iwl_mvm_pass_packet_to_mac80211(mvm, napi, skb, queue, sta);
  508. rcu_read_unlock();
  509. }
  510. void iwl_mvm_rx_frame_release(struct iwl_mvm *mvm,
  511. struct iwl_rx_cmd_buffer *rxb, int queue)
  512. {
  513. /* TODO */
  514. }