Lines Matching +full:tcm +full:- +full:mode
1 // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
3 * Copyright (C) 2012-2014, 2018-2024 Intel Corporation
4 * Copyright (C) 2013-2015 Intel Mobile Communications GmbH
5 * Copyright (C) 2015-2017 Intel Deutschland GmbH
12 #include "iwl-trans.h"
14 #include "fw-api.h"
15 #include "time-sync.h"
31 /* multicast and non-data only arrives on default queue */
32 if (!ieee80211_is_data(hdr->frame_control) ||
33 is_multicast_ether_addr(hdr->addr1))
37 if (!(stats->flag & RX_FLAG_DECRYPTED))
41 * avoid checking for default queue - we don't want to replicate
48 /* if we are here - this for sure is either CCMP or GCMP */
51 "expected hw-decrypted unicast frame for station\n");
52 return -1;
57 extiv = (u8 *)hdr + ieee80211_hdrlen(hdr->frame_control);
60 ptk_pn = rcu_dereference(mvmsta->ptk_pn[keyidx]);
62 return -1;
64 if (ieee80211_is_data_qos(hdr->frame_control))
71 return -1;
81 res = memcmp(pn, ptk_pn->q[queue].pn[tid], IEEE80211_CCMP_PN_LEN);
83 return -1;
84 if (!res && !(stats->flag & RX_FLAG_ALLOW_SAME_PN))
85 return -1;
87 memcpy(ptk_pn->q[queue].pn[tid], pn, IEEE80211_CCMP_PN_LEN);
88 stats->flag |= RX_FLAG_PN_VALIDATED;
99 struct iwl_rx_mpdu_desc *desc = (void *)pkt->data;
101 unsigned int hdrlen = ieee80211_hdrlen(hdr->frame_control);
102 u8 mic_crc_len = u8_get_bits(desc->mac_flags1,
105 if (desc->mac_flags2 & IWL_RX_MPDU_MFLG2_PAD) {
106 len -= 2;
114 * and sufficient, in monitor mode there's no decryption being done.
116 if (len > mic_crc_len && !ieee80211_hw_check(mvm->hw, RX_INCLUDES_FCS))
117 len -= mic_crc_len;
119 /* If frame is small enough to fit in skb->head, pull it completely.
142 return -EINVAL;
147 skb_set_mac_header(skb, skb->len);
149 skb_put_data(skb, (u8 *)hdr + hdrlen + pad_len, headlen - hdrlen);
154 * this is the case - it's easier to just bail out to CHECKSUM_NONE
162 if (skb->ip_summed == CHECKSUM_COMPLETE) {
168 if (unlikely(headlen - hdrlen < sizeof(*shdr) ||
169 !ether_addr_equal(shdr->hdr, rfc1042_header) ||
170 (shdr->type != htons(ETH_P_IP) &&
171 shdr->type != htons(ETH_P_ARP) &&
172 shdr->type != htons(ETH_P_IPV6) &&
173 shdr->type != htons(ETH_P_8021Q) &&
174 shdr->type != htons(ETH_P_PAE) &&
175 shdr->type != htons(ETH_P_TDLS))))
176 skb->ip_summed = CHECKSUM_NONE;
177 else if (mvm->trans->trans_cfg->device_family < IWL_DEVICE_FAMILY_BZ)
182 fraglen = len - headlen;
185 int offset = (u8 *)hdr + headlen + pad_len -
189 fraglen, rxb->truesize);
205 tlv->type = cpu_to_le16(type);
206 tlv->len = cpu_to_le16(len);
215 const u16 vendor_data_len = sizeof(mvm->cur_aid);
217 if (!mvm->cur_aid)
225 radiotap->oui[0] = 0xf6;
226 radiotap->oui[1] = 0x54;
227 radiotap->oui[2] = 0x25;
228 /* radiotap sniffer config sub-namespace */
229 radiotap->oui_subtype = 1;
230 radiotap->vendor_type = 0;
233 memcpy(radiotap->data, &mvm->cur_aid, sizeof(mvm->cur_aid));
235 rx_status->flag |= RX_FLAG_RADIOTAP_TLV_AT_END;
238 /* iwl_mvm_pass_packet_to_mac80211 - passes the packet for mac80211 */
249 ieee80211_rx_napi(mvm->hw, sta, skb, napi);
260 energy_a = energy_a ? -energy_a : S8_MIN;
261 energy_b = energy_b ? -energy_b : S8_MIN;
267 rx_status->signal = max_energy;
268 rx_status->chains =
270 rx_status->chain_signal[0] = energy_a;
271 rx_status->chain_signal[1] = energy_b;
285 u32 len = le16_to_cpu(desc->mpdu_len);
292 * For non-beacon, we don't really care. But beacons may
296 * it can filter a lot - though usually only if nothing has
299 if (!ieee80211_is_beacon(hdr->frame_control))
303 return -1;
306 mvmvif = iwl_mvm_vif_from_mac80211(mvmsta->vif);
308 /* key mismatch - will also report !MIC_OK but we shouldn't count it */
315 stats->flag |= RX_FLAG_DECRYPTED;
323 key = rcu_dereference(mvmvif->bcn_prot.keys[0]);
325 key = rcu_dereference(mvmvif->bcn_prot.keys[1]);
330 if (len < key->icv_len + IEEE80211_GMAC_PN_LEN + 2)
334 keyid = frame[len - key->icv_len - IEEE80211_GMAC_PN_LEN - 2];
336 if (keyid != key->keyidx) {
342 return -1;
343 key = rcu_dereference(mvmvif->bcn_prot.keys[keyid - 6]);
354 wdev = ieee80211_vif_to_wdev(mvmsta->vif);
355 if (wdev->netdev)
356 cfg80211_rx_unprot_mlme_mgmt(wdev->netdev, (void *)hdr, len);
358 return -1;
367 u32 status = le32_to_cpu(desc->status);
370 * Drop UNKNOWN frames in aggregation, unless in monitor mode
378 IWL_RX_MPDU_STATUS_SEC_UNKNOWN && !mvm->monitor_on) {
380 return -1;
383 if (unlikely(ieee80211_is_mgmt(hdr->frame_control) &&
384 !ieee80211_has_protected(hdr->frame_control)))
387 if (!ieee80211_has_protected(hdr->frame_control) ||
394 /* XXX-BZ do similar to rx.c for now as these are plenty. */
408 return -1;
411 stats->flag |= RX_FLAG_DECRYPTED | RX_FLAG_MIC_STRIPPED;
416 if (!fw_has_api(&mvm->fw->ucode_capa,
421 if (mvm->trans->trans_cfg->gen2 &&
423 stats->flag |= RX_FLAG_MMIC_ERROR;
429 return -1;
431 stats->flag |= RX_FLAG_DECRYPTED;
437 stats->flag |= RX_FLAG_ICV_STRIPPED;
438 if (mvm->trans->trans_cfg->gen2)
439 stats->flag |= RX_FLAG_MMIC_STRIPPED;
445 return -1;
446 stats->flag |= RX_FLAG_DECRYPTED;
457 * Also drop un-decrypted frames in monitor mode.
459 if (!is_multicast_ether_addr(hdr->addr1) &&
460 !mvm->monitor_on && net_ratelimit())
476 struct iwl_rx_mpdu_desc *desc = (void *)pkt->data;
478 if (mvm->trans->trans_cfg->device_family >= IWL_DEVICE_FAMILY_AX210) {
479 if (pkt->len_n_flags & cpu_to_le32(FH_RSCSR_RPA_EN)) {
480 u16 hwsum = be16_to_cpu(desc->v3.raw_xsum);
482 skb->ip_summed = CHECKSUM_COMPLETE;
483 skb->csum = csum_unfold(~(__force __sum16)hwsum);
488 u16 flags = le16_to_cpu(desc->l3l4_flags);
492 mvmvif = iwl_mvm_vif_from_mac80211(mvmsta->vif);
494 if (mvmvif->features & NETIF_F_RXCSUM &&
499 skb->ip_summed = CHECKSUM_UNNECESSARY;
521 if (WARN_ON_ONCE(!mvm_sta->dup_data))
524 dup_data = &mvm_sta->dup_data[queue];
528 * (IEEE 802.11-2012: 9.3.2.10 "Duplicate detection and recovery")
530 if (ieee80211_is_ctl(hdr->frame_control) ||
531 ieee80211_is_any_nullfunc(hdr->frame_control) ||
532 is_multicast_ether_addr(hdr->addr1))
535 if (ieee80211_is_data_qos(hdr->frame_control)) {
544 /* If this wasn't a part of an A-MSDU the sub-frame index will be 0 */
545 sub_frame_idx = desc->amsdu_info &
548 if (unlikely(ieee80211_has_retry(hdr->frame_control) &&
549 dup_data->last_seq[tid] == hdr->seq_ctrl &&
550 dup_data->last_sub_frame[tid] >= sub_frame_idx))
554 if (dup_data->last_seq[tid] == hdr->seq_ctrl &&
555 sub_frame_idx > dup_data->last_sub_frame[tid] &&
556 desc->mac_flags2 & IWL_RX_MPDU_MFLG2_AMSDU)
557 rx_status->flag |= RX_FLAG_ALLOW_SAME_PN;
559 dup_data->last_seq[tid] = hdr->seq_ctrl;
560 dup_data->last_sub_frame[tid] = sub_frame_idx;
562 rx_status->flag |= RX_FLAG_DUP_VALIDATED;
575 &baid_data->entries[reorder_buf->queue *
576 baid_data->entries_per_queue];
577 u16 ssn = reorder_buf->head_sn;
579 lockdep_assert_held(&reorder_buf->lock);
582 int index = ssn % baid_data->buf_size;
589 * Empty the list. Will have more than one frame for A-MSDU.
595 reorder_buf->queue,
597 reorder_buf->num_stored--;
600 reorder_buf->head_sn = nssn;
609 u8 baid = data->baid;
617 ba_data = rcu_dereference(mvm->baid_map[baid]);
622 sta_id = ffs(ba_data->sta_mask) - 1;
623 sta = rcu_dereference(mvm->fw_id_to_mac_id[sta_id]);
627 reorder_buf = &ba_data->reorder_buf[queue];
630 spin_lock_bh(&reorder_buf->lock);
632 ieee80211_sn_add(reorder_buf->head_sn,
633 ba_data->buf_size));
634 spin_unlock_bh(&reorder_buf->lock);
653 baid >= ARRAY_SIZE(mvm->baid_map)))
658 ba_data = rcu_dereference(mvm->baid_map[baid]);
663 sta_id = ffs(ba_data->sta_mask) - 1;
664 sta = rcu_dereference(mvm->fw_id_to_mac_id[sta_id]);
668 reorder_buf = &ba_data->reorder_buf[queue];
670 spin_lock_bh(&reorder_buf->lock);
673 spin_unlock_bh(&reorder_buf->lock);
687 notif = (void *)pkt->data;
688 internal_notif = (void *)notif->payload;
694 len -= sizeof(*notif) + sizeof(*internal_notif);
696 if (WARN_ONCE(internal_notif->sync &&
697 mvm->queue_sync_cookie != internal_notif->cookie,
699 internal_notif->cookie, mvm->queue_sync_cookie, queue))
702 switch (internal_notif->type) {
711 iwl_mvm_del_ba(mvm, queue, (void *)internal_notif->data);
714 WARN_ONCE(1, "Invalid identifier %d", internal_notif->type);
717 if (internal_notif->sync) {
718 WARN_ONCE(!test_and_clear_bit(queue, &mvm->queue_sync_state),
721 if (READ_ONCE(mvm->queue_sync_state) == 0)
722 wake_up(&mvm->rx_sync_waitq);
740 u32 reorder = le32_to_cpu(desc->reorder_data);
741 bool amsdu = desc->mac_flags2 & IWL_RX_MPDU_MFLG2_AMSDU;
743 desc->amsdu_info & IWL_RX_MPDU_AMSDU_LAST_SUBFRAME;
749 u8 sub_frame_idx = desc->amsdu_info &
760 if (mvm->trans->trans_cfg->device_family == IWL_DEVICE_FAMILY_9000)
767 * This also covers pure monitor mode, in which case we won't
779 if (!ieee80211_is_back_req(hdr->frame_control) &&
780 (!ieee80211_is_data_qos(hdr->frame_control) ||
781 is_multicast_ether_addr(hdr->addr1)))
784 if (unlikely(!ieee80211_is_data_present(hdr->frame_control)))
787 baid_data = rcu_dereference(mvm->baid_map[baid]);
790 "Got valid BAID but no baid allocated, bypass the re-ordering buffer. Baid %d reorder 0x%x\n",
799 sta_mask = iwl_mvm_sta_fw_id_mask(mvm, sta, -1);
803 tid != baid_data->tid ||
804 !(sta_mask & baid_data->sta_mask),
806 baid, baid_data->sta_mask, baid_data->tid,
814 buffer = &baid_data->reorder_buf[queue];
815 entries = &baid_data->entries[queue * baid_data->entries_per_queue];
817 spin_lock_bh(&buffer->lock);
819 if (!buffer->valid) {
821 spin_unlock_bh(&buffer->lock);
824 buffer->valid = true;
828 if (desc->status & cpu_to_le32(IWL_RX_MPDU_STATUS_DUPLICATE))
836 if (!buffer->num_stored && ieee80211_sn_less(sn, nssn)) {
838 buffer->head_sn = nssn;
839 /* No need to update AMSDU last SN - we are moving the head */
840 spin_unlock_bh(&buffer->lock);
852 if (!buffer->num_stored && sn == buffer->head_sn) {
854 buffer->head_sn = ieee80211_sn_inc(buffer->head_sn);
856 /* No need to update AMSDU last SN - we are moving the head */
857 spin_unlock_bh(&buffer->lock);
862 index = sn % baid_data->buf_size;
864 buffer->num_stored++;
867 buffer->last_amsdu = sn;
868 buffer->last_sub_index = sub_frame_idx;
872 * We cannot trust NSSN for AMSDU sub-frames that are not the last.
873 * The reason is that NSSN advances on the first sub-frame, and may
874 * cause the reorder buffer to advance before all the sub-frames arrive.
877 * releasing SN 0,1, 2. When sub-frame 1 arrives - reorder buffer is
879 * If the last sub-frame is not on this queue - we will get frame
886 spin_unlock_bh(&buffer->lock);
891 spin_unlock_bh(&buffer->lock);
904 data = rcu_dereference(mvm->baid_map[baid]);
907 "Got valid BAID but no baid allocated, bypass the re-ordering buffer. Baid %d reorder 0x%x\n",
912 if (!data->timeout)
915 timeout = data->timeout;
922 if (time_before(data->last_rx + TU_TO_JIFFIES(timeout), now))
924 data->last_rx = now;
936 mac_addr[i] = addr[ETH_ALEN - i - 1];
959 u32 phy_data2 = le32_to_cpu(phy_data->d2);
960 u32 phy_data3 = le32_to_cpu(phy_data->d3);
961 u16 phy_data4 = le16_to_cpu(phy_data->d4);
962 u32 rate_n_flags = phy_data->rate_n_flags;
965 he_mu->flags1 |=
969 he_mu->flags1 |=
974 he_mu->ru_ch1[0] = FIELD_GET(IWL_RX_PHY_DATA2_HE_MU_EXT_CH1_RU0,
976 he_mu->ru_ch1[1] = FIELD_GET(IWL_RX_PHY_DATA3_HE_MU_EXT_CH1_RU1,
978 he_mu->ru_ch1[2] = FIELD_GET(IWL_RX_PHY_DATA2_HE_MU_EXT_CH1_RU2,
980 he_mu->ru_ch1[3] = FIELD_GET(IWL_RX_PHY_DATA3_HE_MU_EXT_CH1_RU3,
986 he_mu->flags1 |=
990 he_mu->flags2 |=
995 he_mu->ru_ch2[0] = FIELD_GET(IWL_RX_PHY_DATA2_HE_MU_EXT_CH2_RU0,
997 he_mu->ru_ch2[1] = FIELD_GET(IWL_RX_PHY_DATA3_HE_MU_EXT_CH2_RU1,
999 he_mu->ru_ch2[2] = FIELD_GET(IWL_RX_PHY_DATA2_HE_MU_EXT_CH2_RU2,
1001 he_mu->ru_ch2[3] = FIELD_GET(IWL_RX_PHY_DATA3_HE_MU_EXT_CH2_RU3,
1014 * incorrect for the case that we receive an HE-MU
1018 * the TSF/timers are not be transmitted in HE-MU.
1020 u8 ru = le32_get_bits(phy_data->d1, IWL_RX_PHY_DATA1_HE_RU_ALLOC_MASK);
1021 u32 rate_n_flags = phy_data->rate_n_flags;
1025 rx_status->bw = RATE_INFO_BW_HE_RU;
1027 he->data1 |= cpu_to_le16(IEEE80211_RADIOTAP_HE_DATA1_BW_RU_ALLOC_KNOWN);
1031 rx_status->he_ru = NL80211_RATE_INFO_HE_RU_ALLOC_26;
1035 rx_status->he_ru = NL80211_RATE_INFO_HE_RU_ALLOC_52;
1036 offs = ru - 37;
1039 rx_status->he_ru = NL80211_RATE_INFO_HE_RU_ALLOC_106;
1040 offs = ru - 53;
1043 rx_status->he_ru = NL80211_RATE_INFO_HE_RU_ALLOC_242;
1044 offs = ru - 61;
1047 rx_status->he_ru = NL80211_RATE_INFO_HE_RU_ALLOC_484;
1048 offs = ru - 65;
1051 rx_status->he_ru = NL80211_RATE_INFO_HE_RU_ALLOC_996;
1054 rx_status->he_ru = NL80211_RATE_INFO_HE_RU_ALLOC_2x996;
1057 he->data2 |= le16_encode_bits(offs,
1059 he->data2 |= cpu_to_le16(IEEE80211_RADIOTAP_HE_DATA2_PRISEC_80_KNOWN |
1061 if (phy_data->d1 & cpu_to_le32(IWL_RX_PHY_DATA1_HE_RU_ALLOC_SEC80))
1062 he->data2 |=
1076 he_mu->flags2 |=
1081 he->data6 |=
1095 switch (phy_data->info_type) {
1108 he->data1 |= cpu_to_le16(IEEE80211_RADIOTAP_HE_DATA1_SPTL_REUSE_KNOWN |
1112 he->data4 |= le16_encode_bits(le32_get_bits(phy_data->d2,
1115 he->data4 |= le16_encode_bits(le32_get_bits(phy_data->d2,
1118 he->data4 |= le16_encode_bits(le32_get_bits(phy_data->d2,
1121 he->data4 |= le16_encode_bits(le32_get_bits(phy_data->d2,
1130 he->data1 |= cpu_to_le16(IEEE80211_RADIOTAP_HE_DATA1_LDPC_XSYMSEG_KNOWN |
1133 he->data2 |= cpu_to_le16(IEEE80211_RADIOTAP_HE_DATA2_PRE_FEC_PAD_KNOWN |
1137 he->data3 |= le16_encode_bits(le32_get_bits(phy_data->d0,
1140 if (phy_data->info_type != IWL_RX_PHY_INFO_TYPE_HE_TB &&
1141 phy_data->info_type != IWL_RX_PHY_INFO_TYPE_HE_TB_EXT) {
1142 he->data1 |= cpu_to_le16(IEEE80211_RADIOTAP_HE_DATA1_UL_DL_KNOWN);
1143 he->data3 |= le16_encode_bits(le32_get_bits(phy_data->d0,
1147 he->data3 |= le16_encode_bits(le32_get_bits(phy_data->d0,
1150 he->data5 |= le16_encode_bits(le32_get_bits(phy_data->d0,
1153 he->data5 |= le16_encode_bits(le32_get_bits(phy_data->d0,
1156 he->data5 |= le16_encode_bits(le32_get_bits(phy_data->d1,
1159 he->data6 |= le16_encode_bits(le32_get_bits(phy_data->d0,
1162 he->data6 |= le16_encode_bits(le32_get_bits(phy_data->d0,
1168 switch (phy_data->info_type) {
1172 he->data1 |= cpu_to_le16(IEEE80211_RADIOTAP_HE_DATA1_SPTL_REUSE_KNOWN);
1173 he->data4 |= le16_encode_bits(le32_get_bits(phy_data->d0,
1182 switch (phy_data->info_type) {
1184 he_mu->flags1 |=
1185 le16_encode_bits(le16_get_bits(phy_data->d4,
1188 he_mu->flags1 |=
1189 le16_encode_bits(le16_get_bits(phy_data->d4,
1192 he_mu->flags2 |=
1193 le16_encode_bits(le16_get_bits(phy_data->d4,
1199 he_mu->flags2 |=
1200 le16_encode_bits(le32_get_bits(phy_data->d1,
1203 he_mu->flags2 |=
1204 le16_encode_bits(le32_get_bits(phy_data->d1,
1213 he->data1 |= cpu_to_le16(IEEE80211_RADIOTAP_HE_DATA1_BEAM_CHANGE_KNOWN);
1214 he->data3 |= le16_encode_bits(le32_get_bits(phy_data->d0,
1230 (_usig)->mask |= cpu_to_le32(_enc_bits); \
1231 (_usig)->value |= LE32_DEC_ENC(in_value, dec_bits, _enc_bits); \
1235 eht->data[(rt_data)] |= \
1275 if (phy_data->with_data) {
1276 __le32 data1 = phy_data->d1;
1277 __le32 data2 = phy_data->d2;
1278 __le32 data3 = phy_data->d3;
1279 __le32 data4 = phy_data->eht_d4;
1280 __le32 data5 = phy_data->d5;
1281 u32 phy_bw = phy_data->rate_n_flags & RATE_MCS_CHAN_WIDTH_MSK;
1296 eht->user_info[0] |=
1301 eht->known |= cpu_to_le32(IEEE80211_RADIOTAP_EHT_KNOWN_NR_NON_OFDMA_USERS_M);
1302 eht->data[7] |= LE32_DEC_ENC
1316 * However firmware can only give us A1-D2, so the higher
1346 __le32 usig_a1 = phy_data->rx_vec[0];
1347 __le32 usig_a2 = phy_data->rx_vec[1];
1385 if (phy_data->with_data) {
1386 __le32 data5 = phy_data->d5;
1399 __le32 usig_a1 = phy_data->rx_vec[0];
1400 __le32 usig_a2 = phy_data->rx_vec[1];
1430 u32 ru = le32_get_bits(eht->data[8],
1434 /* Using D1.5 Table 9-53a - Encoding of PS160 and RU Allocation subfields
1491 rx_status->bw = RATE_INFO_BW_EHT_RU;
1492 rx_status->eht.ru = nl_ru;
1502 __le32 data0 = phy_data->d0;
1503 __le32 data1 = phy_data->d1;
1504 __le32 usig_a1 = phy_data->rx_vec[0];
1505 u8 info_type = phy_data->info_type;
1512 usig->common |= cpu_to_le32
1515 if (phy_data->with_data) {
1516 usig->common |= LE32_DEC_ENC(data0,
1519 usig->common |= LE32_DEC_ENC(data0,
1523 usig->common |= LE32_DEC_ENC(usig_a1,
1526 usig->common |= LE32_DEC_ENC(usig_a1,
1531 if (fw_has_capa(&mvm->fw->ucode_capa,
1533 usig->common |=
1535 usig->common |=
1540 eht->known |= cpu_to_le32(IEEE80211_RADIOTAP_EHT_KNOWN_SPATIAL_REUSE);
1541 eht->data[0] |= LE32_DEC_ENC(data0,
1546 eht->known |= cpu_to_le32(IEEE80211_RADIOTAP_EHT_KNOWN_RU_ALLOC_TB_FMT);
1547 eht->data[8] |= LE32_DEC_ENC(data0, IWL_RX_PHY_DATA0_EHT_PS160,
1549 eht->data[8] |= LE32_DEC_ENC(data1, IWL_RX_PHY_DATA1_EHT_RU_ALLOC_B0,
1551 eht->data[8] |= LE32_DEC_ENC(data1, IWL_RX_PHY_DATA1_EHT_RU_ALLOC_B1_B7,
1557 * which is on only in case of monitor mode so no need to check monitor
1558 * mode
1560 eht->known |= cpu_to_le32(IEEE80211_RADIOTAP_EHT_KNOWN_PRIMARY_80);
1561 eht->data[1] |=
1562 le32_encode_bits(mvm->monitor_p80,
1565 usig->common |= cpu_to_le32(IEEE80211_RADIOTAP_EHT_USIG_COMMON_TXOP_KNOWN);
1566 if (phy_data->with_data)
1567 usig->common |= LE32_DEC_ENC(data0, IWL_RX_PHY_DATA0_EHT_TXOP_DUR_MASK,
1570 usig->common |= LE32_DEC_ENC(usig_a1, IWL_RX_USIG_A1_TXOP_DURATION,
1573 eht->known |= cpu_to_le32(IEEE80211_RADIOTAP_EHT_KNOWN_LDPC_EXTRA_SYM_OM);
1574 eht->data[0] |= LE32_DEC_ENC(data0, IWL_RX_PHY_DATA0_EHT_LDPC_EXT_SYM,
1577 eht->known |= cpu_to_le32(IEEE80211_RADIOTAP_EHT_KNOWN_PRE_PADD_FACOR_OM);
1578 eht->data[0] |= LE32_DEC_ENC(data0, IWL_RX_PHY_DATA0_EHT_PRE_FEC_PAD_MASK,
1581 eht->known |= cpu_to_le32(IEEE80211_RADIOTAP_EHT_KNOWN_PE_DISAMBIGUITY_OM);
1582 eht->data[0] |= LE32_DEC_ENC(data0, IWL_RX_PHY_DATA0_EHT_PE_DISAMBIG,
1588 usig->common |= cpu_to_le32(IEEE80211_RADIOTAP_EHT_USIG_COMMON_BAD_USIG_CRC);
1590 usig->common |= cpu_to_le32(IEEE80211_RADIOTAP_EHT_USIG_COMMON_PHY_VER_KNOWN);
1591 usig->common |= LE32_DEC_ENC(data0, IWL_RX_PHY_DATA0_EHT_PHY_VER,
1595 * TODO: what about TB - IWL_RX_PHY_DATA1_EHT_TB_PILOT_TYPE,
1599 eht->known |= cpu_to_le32(IEEE80211_RADIOTAP_EHT_KNOWN_EHT_LTF);
1600 eht->data[0] |= LE32_DEC_ENC(data1, IWL_RX_PHY_DATA1_EHT_SIG_LTF_NUM,
1622 u32 rate_n_flags = phy_data->rate_n_flags;
1626 u16 phy_info = phy_data->phy_info;
1630 if (phy_data->with_data)
1637 rx_status->flag |= RX_FLAG_RADIOTAP_TLV_AT_END;
1638 usig->common |=
1645 le32_to_cpu(phy_data->d0));
1647 usig->common |= cpu_to_le32
1650 /* report the AMPDU-EOF bit on single frames */
1652 rx_status->flag |= RX_FLAG_AMPDU_DETAILS;
1653 rx_status->flag |= RX_FLAG_AMPDU_EOF_BIT_KNOWN;
1654 if (phy_data->d0 & cpu_to_le32(IWL_RX_PHY_DATA0_EHT_DELIM_EOF))
1655 rx_status->flag |= RX_FLAG_AMPDU_EOF_BIT;
1660 (phy_info & IWL_RX_MPDU_PHY_AMPDU) && phy_data->first_subframe) {
1661 rx_status->flag |= RX_FLAG_AMPDU_EOF_BIT_KNOWN;
1662 if (phy_data->d0 & cpu_to_le32(IWL_RX_PHY_DATA0_EHT_DELIM_EOF))
1663 rx_status->flag |= RX_FLAG_AMPDU_EOF_BIT;
1681 rx_status->eht.gi = NL80211_RATE_INFO_EHT_GI_1_6;
1684 rx_status->eht.gi = NL80211_RATE_INFO_EHT_GI_0_8;
1689 rx_status->eht.gi = NL80211_RATE_INFO_EHT_GI_1_6;
1695 rx_status->eht.gi = NL80211_RATE_INFO_EHT_GI_3_2;
1697 rx_status->eht.gi = NL80211_RATE_INFO_EHT_GI_0_8;
1702 rx_status->eht.gi = NL80211_RATE_INFO_EHT_GI_3_2;
1711 eht->known |= cpu_to_le32(IEEE80211_RADIOTAP_EHT_KNOWN_GI);
1712 eht->data[0] |= cpu_to_le32
1716 rx_status->eht.gi));
1720 if (!phy_data->with_data) {
1721 eht->known |= cpu_to_le32(IEEE80211_RADIOTAP_EHT_KNOWN_NSS_S |
1723 eht->data[7] |=
1724 le32_encode_bits(le32_get_bits(phy_data->rx_vec[2],
1728 eht->data[7] |=
1731 eht->user_info[0] |=
1739 eht->user_info[0] |=
1743 eht->user_info[0] |=
1746 eht->user_info[0] |= cpu_to_le32
1762 u32 rate_n_flags = phy_data->rate_n_flags;
1781 u16 phy_info = phy_data->phy_info;
1784 rx_status->flag |= RX_FLAG_RADIOTAP_HE;
1786 if (phy_data->info_type == IWL_RX_PHY_INFO_TYPE_HE_MU ||
1787 phy_data->info_type == IWL_RX_PHY_INFO_TYPE_HE_MU_EXT) {
1789 rx_status->flag |= RX_FLAG_RADIOTAP_HE_MU;
1792 /* report the AMPDU-EOF bit on single frames */
1794 rx_status->flag |= RX_FLAG_AMPDU_DETAILS;
1795 rx_status->flag |= RX_FLAG_AMPDU_EOF_BIT_KNOWN;
1796 if (phy_data->d0 & cpu_to_le32(IWL_RX_PHY_DATA0_HE_DELIM_EOF))
1797 rx_status->flag |= RX_FLAG_AMPDU_EOF_BIT;
1806 (phy_info & IWL_RX_MPDU_PHY_AMPDU) && phy_data->first_subframe) {
1807 rx_status->flag |= RX_FLAG_AMPDU_EOF_BIT_KNOWN;
1808 if (phy_data->d0 & cpu_to_le32(IWL_RX_PHY_DATA0_EHT_DELIM_EOF))
1809 rx_status->flag |= RX_FLAG_AMPDU_EOF_BIT;
1814 rx_status->bw = RATE_INFO_BW_HE_RU;
1815 rx_status->he_ru = NL80211_RATE_INFO_HE_RU_ALLOC_106;
1821 he->data1 |=
1833 he->data1 |= cpu_to_le16(he_type >> RATE_MCS_HE_TYPE_POS);
1836 he->data5 |= cpu_to_le16(IEEE80211_RADIOTAP_HE_DATA5_TXBF);
1842 rx_status->he_gi = NL80211_RATE_INFO_HE_GI_1_6;
1844 rx_status->he_gi = NL80211_RATE_INFO_HE_GI_0_8;
1852 rx_status->he_gi = NL80211_RATE_INFO_HE_GI_1_6;
1854 rx_status->he_gi = NL80211_RATE_INFO_HE_GI_0_8;
1859 rx_status->he_gi = NL80211_RATE_INFO_HE_GI_3_2;
1862 rx_status->he_gi = NL80211_RATE_INFO_HE_GI_1_6;
1867 rx_status->he_gi = NL80211_RATE_INFO_HE_GI_3_2;
1871 rx_status->he_gi = NL80211_RATE_INFO_HE_GI_0_8;
1878 he->data5 |= le16_encode_bits(ltf,
1888 switch (phy_data->info_type) {
1902 lsig->data1 = cpu_to_le16(IEEE80211_RADIOTAP_LSIG_DATA1_LENGTH_KNOWN);
1903 lsig->data2 = le16_encode_bits(le32_get_bits(phy_data->d1,
1906 rx_status->flag |= RX_FLAG_RADIOTAP_LSIG;
1923 if (mvmsta->vif != rx_sta_csa->vif)
1926 if (mvmsta->disable_tx)
1927 rx_sta_csa->all_sta_unblocked = false;
1931 * Note: requires also rx_status->band to be prefilled, as well
1932 * as phy_data (apart from phy_data->info_type)
1940 u32 rate_n_flags = phy_data->rate_n_flags;
1945 phy_data->info_type = IWL_RX_PHY_INFO_TYPE_NONE;
1947 if (phy_data->phy_info & IWL_RX_MPDU_PHY_TSF_OVERLOAD)
1948 phy_data->info_type =
1949 le32_get_bits(phy_data->d1,
1957 rx_status->bw = RATE_INFO_BW_40;
1960 rx_status->bw = RATE_INFO_BW_80;
1963 rx_status->bw = RATE_INFO_BW_160;
1966 rx_status->bw = RATE_INFO_BW_320;
1970 /* must be before L-SIG data */
1976 rx_status->device_timestamp = phy_data->gp2_on_air_rise;
1978 if (mvm->rx_ts_ptp && mvm->monitor_on) {
1980 iwl_mvm_ptp_get_adj_time(mvm, phy_data->gp2_on_air_rise * NSEC_PER_USEC);
1982 rx_status->mactime = div64_u64(adj_time, NSEC_PER_USEC);
1983 rx_status->flag |= RX_FLAG_MACTIME_IS_RTAP_TS64;
1984 rx_status->flag &= ~RX_FLAG_MACTIME;
1987 rx_status->freq = ieee80211_channel_to_frequency(phy_data->channel,
1988 rx_status->band);
1990 phy_data->energy_a, phy_data->energy_b);
1996 if (unlikely(mvm->monitor_on))
2004 rx_status->enc_flags |= RX_ENC_FLAG_SHORT_GI;
2007 rx_status->enc_flags |= RX_ENC_FLAG_LDPC;
2011 rx_status->encoding = RX_ENC_VHT;
2014 rx_status->encoding = RX_ENC_HE;
2015 rx_status->he_dcm =
2019 rx_status->encoding = RX_ENC_EHT;
2025 rx_status->encoding = RX_ENC_HT;
2026 rx_status->rate_idx = RATE_HT_MCS_INDEX(rate_n_flags);
2027 rx_status->enc_flags |= stbc << RX_ENC_FLAG_STBC_SHIFT;
2032 rx_status->nss =
2034 rx_status->rate_idx = rate_n_flags & RATE_MCS_CODE_MSK;
2035 rx_status->enc_flags |= stbc << RX_ENC_FLAG_STBC_SHIFT;
2039 rx_status->band);
2041 rx_status->rate_idx = rate;
2044 rx_status->rate_idx = 0;
2047 rate_n_flags, rx_status->band);
2060 struct iwl_rx_mpdu_desc *desc = (void *)pkt->data;
2067 u8 sta_id = le32_get_bits(desc->status, IWL_RX_MPDU_STATUS_STA_ID);
2072 if (unlikely(test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status)))
2075 if (mvm->trans->trans_cfg->device_family >= IWL_DEVICE_FAMILY_AX210)
2085 if (mvm->trans->trans_cfg->device_family >= IWL_DEVICE_FAMILY_AX210) {
2086 phy_data.rate_n_flags = le32_to_cpu(desc->v3.rate_n_flags);
2087 phy_data.channel = desc->v3.channel;
2088 phy_data.gp2_on_air_rise = le32_to_cpu(desc->v3.gp2_on_air_rise);
2089 phy_data.energy_a = desc->v3.energy_a;
2090 phy_data.energy_b = desc->v3.energy_b;
2092 phy_data.d0 = desc->v3.phy_data0;
2093 phy_data.d1 = desc->v3.phy_data1;
2094 phy_data.d2 = desc->v3.phy_data2;
2095 phy_data.d3 = desc->v3.phy_data3;
2096 phy_data.eht_d4 = desc->phy_eht_data4;
2097 phy_data.d5 = desc->v3.phy_data5;
2099 phy_data.rate_n_flags = le32_to_cpu(desc->v1.rate_n_flags);
2100 phy_data.channel = desc->v1.channel;
2101 phy_data.gp2_on_air_rise = le32_to_cpu(desc->v1.gp2_on_air_rise);
2102 phy_data.energy_a = desc->v1.energy_a;
2103 phy_data.energy_b = desc->v1.energy_b;
2105 phy_data.d0 = desc->v1.phy_data0;
2106 phy_data.d1 = desc->v1.phy_data1;
2107 phy_data.d2 = desc->v1.phy_data2;
2108 phy_data.d3 = desc->v1.phy_data3;
2111 if (iwl_fw_lookup_notif_ver(mvm->fw, LEGACY_GROUP,
2120 len = le16_to_cpu(desc->mpdu_len);
2128 phy_data.phy_info = le16_to_cpu(desc->phy_info);
2129 phy_data.d4 = desc->phy_data4;
2131 hdr = (void *)(pkt->data + desc_size);
2141 if (desc->mac_flags2 & IWL_RX_MPDU_MFLG2_PAD) {
2154 * Keep packets with CRC errors (and with overrun) for monitor mode
2157 if (!(desc->status & cpu_to_le32(IWL_RX_MPDU_STATUS_CRC_OK)) ||
2158 !(desc->status & cpu_to_le32(IWL_RX_MPDU_STATUS_OVERRUN_OK))) {
2160 le32_to_cpu(desc->status));
2161 rx_status->flag |= RX_FLAG_FAILED_FCS_CRC;
2167 rx_status->enc_flags |= RX_ENC_FLAG_SHORTPRE;
2172 if (mvm->trans->trans_cfg->device_family >=
2174 tsf_on_air_rise = le64_to_cpu(desc->v3.tsf_on_air_rise);
2176 tsf_on_air_rise = le64_to_cpu(desc->v1.tsf_on_air_rise);
2178 rx_status->mactime = tsf_on_air_rise;
2180 rx_status->flag |= RX_FLAG_MACTIME_PLCP_START;
2184 u8 band = BAND_IN_RX_STATUS(desc->mac_phy_idx);
2186 rx_status->band = iwl_mvm_nl80211_band_from_phy(band);
2188 rx_status->band = phy_data.channel > 14 ? NL80211_BAND_5GHZ :
2197 rx_status->flag |= RX_FLAG_AMPDU_DETAILS;
2201 * see if the frame was really part of an A-MPDU or not.
2203 if (toggle_bit != mvm->ampdu_toggle) {
2204 mvm->ampdu_ref++;
2205 if (mvm->ampdu_ref == 0)
2206 mvm->ampdu_ref++;
2207 mvm->ampdu_toggle = toggle_bit;
2210 rx_status->ampdu_reference = mvm->ampdu_ref;
2215 if (desc->status & cpu_to_le32(IWL_RX_MPDU_STATUS_SRC_STA_FOUND)) {
2216 if (!WARN_ON_ONCE(sta_id >= mvm->fw->ucode_capa.num_stations)) {
2219 sta = rcu_dereference(mvm->fw_id_to_mac_id[sta_id]);
2222 link_sta = rcu_dereference(mvm->fw_id_to_link_sta[sta_id]);
2224 if (sta && sta->valid_links && link_sta) {
2225 rx_status->link_valid = 1;
2226 rx_status->link_id = link_sta->link_id;
2229 } else if (!is_multicast_ether_addr(hdr->addr2)) {
2234 sta = ieee80211_find_sta_by_ifaddr(mvm->hw, hdr->addr2, NULL);
2238 le32_to_cpu(pkt->len_n_flags), queue,
2249 rcu_dereference(mvm->csa_tx_blocked_vif);
2250 u8 baid = (u8)((le32_to_cpu(desc->reorder_data) &
2254 struct ieee80211_vif *vif = mvmsta->vif;
2256 if (!mvm->tcm.paused && len >= sizeof(*hdr) &&
2257 !is_multicast_ether_addr(hdr->addr1) &&
2258 ieee80211_is_data(hdr->frame_control) &&
2259 time_after(jiffies, mvm->tcm.ts + MVM_TCM_PERIOD))
2260 schedule_delayed_work(&mvm->tcm.work, 0);
2275 if (mvmvif->csa_target_freq == rx_status->freq)
2278 ieee80211_iterate_stations_atomic(mvm->hw,
2283 RCU_INIT_POINTER(mvm->csa_tx_blocked_vif, NULL);
2286 cancel_delayed_work(&mvm->cs_tx_unblock_dwork);
2292 trig = iwl_fw_dbg_trigger_on(&mvm->fwrt,
2296 if (trig && ieee80211_is_beacon(hdr->frame_control)) {
2300 rssi_trig = (void *)trig->data;
2301 rssi = le32_to_cpu(rssi_trig->rssi);
2303 if (rx_status->signal < rssi)
2304 iwl_fw_dbg_collect_trig(&mvm->fwrt, trig,
2312 if (ieee80211_is_data(hdr->frame_control))
2317 le16_to_cpu(hdr->seq_ctrl));
2323 * Our hardware de-aggregates AMSDUs but copies the mac header
2324 * as it to the de-aggregated MPDUs. We need to turn off the
2326 * In addition, HW reverses addr3 and addr4 - reverse it back.
2328 if ((desc->mac_flags2 & IWL_RX_MPDU_MFLG2_AMSDU) &&
2329 !WARN_ON(!ieee80211_is_data_qos(hdr->frame_control))) {
2334 if (mvm->trans->trans_cfg->device_family ==
2336 iwl_mvm_flip_address(hdr->addr3);
2338 if (ieee80211_has_a4(hdr->frame_control))
2339 iwl_mvm_flip_address(hdr->addr4);
2343 u32 reorder_data = le32_to_cpu(desc->reorder_data);
2348 if (ieee80211_is_data(hdr->frame_control)) {
2349 u8 sub_frame_idx = desc->amsdu_info &
2352 /* 0 means not an A-MSDU, and 1 means a new A-MSDU */
2361 if (unlikely((ieee80211_is_beacon(hdr->frame_control) ||
2362 ieee80211_is_probe_resp(hdr->frame_control)) &&
2363 mvm->sched_scan_pass_all ==
2365 mvm->sched_scan_pass_all = SCHED_SCAN_PASS_ALL_FOUND;
2367 if (unlikely(ieee80211_is_beacon(hdr->frame_control) ||
2368 ieee80211_is_probe_resp(hdr->frame_control)))
2369 rx_status->boottime_ns = ktime_get_boottime_ns();
2378 likely(!iwl_mvm_time_sync_frame(mvm, skb, hdr->addr2)) &&
2380 if (mvm->trans->trans_cfg->device_family == IWL_DEVICE_FAMILY_9000 &&
2381 (desc->mac_flags2 & IWL_RX_MPDU_MFLG2_AMSDU) &&
2382 !(desc->amsdu_info & IWL_RX_MPDU_AMSDU_LAST_SUBFRAME))
2383 rx_status->flag |= RX_FLAG_AMSDU_MORE;
2396 struct iwl_rx_no_data_ver_3 *desc = (void *)pkt->data;
2403 if (unlikely(test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status)))
2409 rssi = le32_to_cpu(desc->rssi);
2410 phy_data.d0 = desc->phy_info[0];
2411 phy_data.d1 = desc->phy_info[1];
2413 phy_data.gp2_on_air_rise = le32_to_cpu(desc->on_air_rise_time);
2414 phy_data.rate_n_flags = le32_to_cpu(desc->rate);
2419 phy_data.rx_vec[0] = desc->rx_vec[0];
2420 phy_data.rx_vec[1] = desc->rx_vec[1];
2422 if (iwl_fw_lookup_notif_ver(mvm->fw, DATA_PATH_GROUP,
2433 if (iwl_fw_lookup_notif_ver(mvm->fw, DATA_PATH_GROUP,
2439 phy_data.rx_vec[2] = desc->rx_vec[2];
2440 phy_data.rx_vec[3] = desc->rx_vec[3];
2458 /* 0-length PSDU */
2459 rx_status->flag |= RX_FLAG_NO_PSDU;
2462 if (le32_get_bits(desc->info, RX_NO_DATA_INFO_ERR_MSK) !=
2464 rx_status->flag |= RX_FLAG_FAILED_PLCP_CRC;
2466 switch (le32_get_bits(desc->info, RX_NO_DATA_INFO_TYPE_MSK)) {
2468 rx_status->zero_length_psdu_type =
2473 rx_status->zero_length_psdu_type =
2477 rx_status->zero_length_psdu_type =
2482 rx_status->band = phy_data.channel > 14 ? NL80211_BAND_5GHZ :
2495 skb_set_mac_header(skb, skb->len);
2504 rx_status->nss =
2505 le32_get_bits(desc->rx_vec[0],
2509 rx_status->nss =
2510 le32_get_bits(desc->rx_vec[0],
2514 rx_status->nss =
2515 le32_get_bits(desc->rx_vec[2],
2520 ieee80211_rx_napi(mvm->hw, sta, skb, napi);
2528 struct iwl_frame_release *release = (void *)pkt->data;
2533 iwl_mvm_release_frames_from_notif(mvm, napi, release->baid,
2534 le16_to_cpu(release->nssn),
2542 struct iwl_bar_frame_release *release = (void *)pkt->data;
2543 unsigned int baid = le32_get_bits(release->ba_info,
2545 unsigned int nssn = le32_get_bits(release->ba_info,
2547 unsigned int sta_id = le32_get_bits(release->sta_tid,
2549 unsigned int tid = le32_get_bits(release->sta_tid,
2557 baid >= ARRAY_SIZE(mvm->baid_map)))
2561 baid_data = rcu_dereference(mvm->baid_map[baid]);
2569 if (WARN(tid != baid_data->tid || sta_id > IWL_MVM_STATION_COUNT_MAX ||
2570 !(baid_data->sta_mask & BIT(sta_id)),
2572 baid, baid_data->sta_mask, baid_data->tid, sta_id,