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
7 #include <linux/etherdevice.h>
8 #include <linux/skbuff.h>
12 #include "time-sync.h"
14 static inline int iwl_mvm_check_pn(struct iwl_mvm
*mvm
, struct sk_buff
*skb
,
15 int queue
, struct ieee80211_sta
*sta
)
17 struct iwl_mvm_sta
*mvmsta
;
18 struct ieee80211_hdr
*hdr
= (void *)skb_mac_header(skb
);
19 struct ieee80211_rx_status
*stats
= IEEE80211_SKB_RXCB(skb
);
20 struct iwl_mvm_key_pn
*ptk_pn
;
23 u8 pn
[IEEE80211_CCMP_PN_LEN
];
28 /* multicast and non-data only arrives on default queue */
29 if (!ieee80211_is_data(hdr
->frame_control
) ||
30 is_multicast_ether_addr(hdr
->addr1
))
33 /* do not check PN for open AP */
34 if (!(stats
->flag
& RX_FLAG_DECRYPTED
))
38 * avoid checking for default queue - we don't want to replicate
39 * all the logic that's necessary for checking the PN on fragmented
40 * frames, leave that to mac80211
45 /* if we are here - this for sure is either CCMP or GCMP */
46 if (IS_ERR_OR_NULL(sta
)) {
48 "expected hw-decrypted unicast frame for station\n");
52 mvmsta
= iwl_mvm_sta_from_mac80211(sta
);
54 extiv
= (u8
*)hdr
+ ieee80211_hdrlen(hdr
->frame_control
);
55 keyidx
= extiv
[3] >> 6;
57 ptk_pn
= rcu_dereference(mvmsta
->ptk_pn
[keyidx
]);
61 if (ieee80211_is_data_qos(hdr
->frame_control
))
62 tid
= ieee80211_get_tid(hdr
);
66 /* we don't use HCCA/802.11 QoS TSPECs, so drop such frames */
67 if (tid
>= IWL_MAX_TID_COUNT
)
78 res
= memcmp(pn
, ptk_pn
->q
[queue
].pn
[tid
], IEEE80211_CCMP_PN_LEN
);
81 if (!res
&& !(stats
->flag
& RX_FLAG_ALLOW_SAME_PN
))
84 memcpy(ptk_pn
->q
[queue
].pn
[tid
], pn
, IEEE80211_CCMP_PN_LEN
);
85 stats
->flag
|= RX_FLAG_PN_VALIDATED
;
90 /* iwl_mvm_create_skb Adds the rxb to a new skb */
91 static int iwl_mvm_create_skb(struct iwl_mvm
*mvm
, struct sk_buff
*skb
,
92 struct ieee80211_hdr
*hdr
, u16 len
, u8 crypt_len
,
93 struct iwl_rx_cmd_buffer
*rxb
)
95 struct iwl_rx_packet
*pkt
= rxb_addr(rxb
);
96 struct iwl_rx_mpdu_desc
*desc
= (void *)pkt
->data
;
97 unsigned int headlen
, fraglen
, pad_len
= 0;
98 unsigned int hdrlen
= ieee80211_hdrlen(hdr
->frame_control
);
99 u8 mic_crc_len
= u8_get_bits(desc
->mac_flags1
,
100 IWL_RX_MPDU_MFLG1_MIC_CRC_LEN_MASK
) << 1;
102 if (desc
->mac_flags2
& IWL_RX_MPDU_MFLG2_PAD
) {
108 * For non monitor interface strip the bytes the RADA might not have
109 * removed (it might be disabled, e.g. for mgmt frames). As a monitor
110 * interface cannot exist with other interfaces, this removal is safe
111 * and sufficient, in monitor mode there's no decryption being done.
113 if (len
> mic_crc_len
&& !ieee80211_hw_check(mvm
->hw
, RX_INCLUDES_FCS
))
116 /* If frame is small enough to fit in skb->head, pull it completely.
117 * If not, only pull ieee80211_hdr (including crypto if present, and
118 * an additional 8 bytes for SNAP/ethertype, see below) so that
119 * splice() or TCP coalesce are more efficient.
121 * Since, in addition, ieee80211_data_to_8023() always pull in at
122 * least 8 bytes (possibly more for mesh) we can do the same here
123 * to save the cost of doing it later. That still doesn't pull in
124 * the actual IP header since the typical case has a SNAP header.
125 * If the latter changes (there are efforts in the standards group
126 * to do so) we should revisit this and ieee80211_data_to_8023().
128 headlen
= (len
<= skb_tailroom(skb
)) ? len
:
129 hdrlen
+ crypt_len
+ 8;
131 /* The firmware may align the packet to DWORD.
132 * The padding is inserted after the IV.
133 * After copying the header + IV skip the padding if
134 * present before copying packet data.
138 if (unlikely(headlen
< hdrlen
))
141 /* Since data doesn't move data while putting data on skb and that is
142 * the only way we use, data + len is the next place that hdr would be put
144 skb_set_mac_header(skb
, skb
->len
);
145 skb_put_data(skb
, hdr
, hdrlen
);
146 skb_put_data(skb
, (u8
*)hdr
+ hdrlen
+ pad_len
, headlen
- hdrlen
);
149 * If we did CHECKSUM_COMPLETE, the hardware only does it right for
150 * certain cases and starts the checksum after the SNAP. Check if
151 * this is the case - it's easier to just bail out to CHECKSUM_NONE
152 * in the cases the hardware didn't handle, since it's rare to see
153 * such packets, even though the hardware did calculate the checksum
154 * in this case, just starting after the MAC header instead.
156 * Starting from Bz hardware, it calculates starting directly after
157 * the MAC header, so that matches mac80211's expectation.
159 if (skb
->ip_summed
== CHECKSUM_COMPLETE
) {
163 } __packed
*shdr
= (void *)((u8
*)hdr
+ hdrlen
+ pad_len
);
165 if (unlikely(headlen
- hdrlen
< sizeof(*shdr
) ||
166 !ether_addr_equal(shdr
->hdr
, rfc1042_header
) ||
167 (shdr
->type
!= htons(ETH_P_IP
) &&
168 shdr
->type
!= htons(ETH_P_ARP
) &&
169 shdr
->type
!= htons(ETH_P_IPV6
) &&
170 shdr
->type
!= htons(ETH_P_8021Q
) &&
171 shdr
->type
!= htons(ETH_P_PAE
) &&
172 shdr
->type
!= htons(ETH_P_TDLS
))))
173 skb
->ip_summed
= CHECKSUM_NONE
;
174 else if (mvm
->trans
->trans_cfg
->device_family
< IWL_DEVICE_FAMILY_BZ
)
175 /* mac80211 assumes full CSUM including SNAP header */
176 skb_postpush_rcsum(skb
, shdr
, sizeof(*shdr
));
179 fraglen
= len
- headlen
;
182 int offset
= (u8
*)hdr
+ headlen
+ pad_len
-
183 (u8
*)rxb_addr(rxb
) + rxb_offset(rxb
);
185 skb_add_rx_frag(skb
, 0, rxb_steal_page(rxb
), offset
,
186 fraglen
, rxb
->truesize
);
192 /* put a TLV on the skb and return data pointer
194 * Also pad to 4 the len and zero out all data part
197 iwl_mvm_radiotap_put_tlv(struct sk_buff
*skb
, u16 type
, u16 len
)
199 struct ieee80211_radiotap_tlv
*tlv
;
201 tlv
= skb_put(skb
, sizeof(*tlv
));
202 tlv
->type
= cpu_to_le16(type
);
203 tlv
->len
= cpu_to_le16(len
);
204 return skb_put_zero(skb
, ALIGN(len
, 4));
207 static void iwl_mvm_add_rtap_sniffer_config(struct iwl_mvm
*mvm
,
210 struct ieee80211_rx_status
*rx_status
= IEEE80211_SKB_RXCB(skb
);
211 struct ieee80211_radiotap_vendor_content
*radiotap
;
212 const u16 vendor_data_len
= sizeof(mvm
->cur_aid
);
217 radiotap
= iwl_mvm_radiotap_put_tlv(skb
,
218 IEEE80211_RADIOTAP_VENDOR_NAMESPACE
,
219 sizeof(*radiotap
) + vendor_data_len
);
222 radiotap
->oui
[0] = 0xf6;
223 radiotap
->oui
[1] = 0x54;
224 radiotap
->oui
[2] = 0x25;
225 /* radiotap sniffer config sub-namespace */
226 radiotap
->oui_subtype
= 1;
227 radiotap
->vendor_type
= 0;
229 /* fill the data now */
230 memcpy(radiotap
->data
, &mvm
->cur_aid
, sizeof(mvm
->cur_aid
));
232 rx_status
->flag
|= RX_FLAG_RADIOTAP_TLV_AT_END
;
235 /* iwl_mvm_pass_packet_to_mac80211 - passes the packet for mac80211 */
236 static void iwl_mvm_pass_packet_to_mac80211(struct iwl_mvm
*mvm
,
237 struct napi_struct
*napi
,
238 struct sk_buff
*skb
, int queue
,
239 struct ieee80211_sta
*sta
)
241 if (unlikely(iwl_mvm_check_pn(mvm
, skb
, queue
, sta
))) {
246 ieee80211_rx_napi(mvm
->hw
, sta
, skb
, napi
);
249 static void iwl_mvm_get_signal_strength(struct iwl_mvm
*mvm
,
250 struct ieee80211_rx_status
*rx_status
,
251 u32 rate_n_flags
, int energy_a
,
255 u32 rate_flags
= rate_n_flags
;
257 energy_a
= energy_a
? -energy_a
: S8_MIN
;
258 energy_b
= energy_b
? -energy_b
: S8_MIN
;
259 max_energy
= max(energy_a
, energy_b
);
261 IWL_DEBUG_STATS(mvm
, "energy In A %d B %d, and max %d\n",
262 energy_a
, energy_b
, max_energy
);
264 rx_status
->signal
= max_energy
;
266 (rate_flags
& RATE_MCS_ANT_AB_MSK
) >> RATE_MCS_ANT_POS
;
267 rx_status
->chain_signal
[0] = energy_a
;
268 rx_status
->chain_signal
[1] = energy_b
;
271 static int iwl_mvm_rx_mgmt_prot(struct ieee80211_sta
*sta
,
272 struct ieee80211_hdr
*hdr
,
273 struct iwl_rx_mpdu_desc
*desc
,
275 struct ieee80211_rx_status
*stats
)
277 struct wireless_dev
*wdev
;
278 struct iwl_mvm_sta
*mvmsta
;
279 struct iwl_mvm_vif
*mvmvif
;
281 struct ieee80211_key_conf
*key
;
282 u32 len
= le16_to_cpu(desc
->mpdu_len
);
283 const u8
*frame
= (void *)hdr
;
285 if ((status
& IWL_RX_MPDU_STATUS_SEC_MASK
) == IWL_RX_MPDU_STATUS_SEC_NONE
)
289 * For non-beacon, we don't really care. But beacons may
290 * be filtered out, and we thus need the firmware's replay
291 * detection, otherwise beacons the firmware previously
292 * filtered could be replayed, or something like that, and
293 * it can filter a lot - though usually only if nothing has
296 if (!ieee80211_is_beacon(hdr
->frame_control
))
302 mvmsta
= iwl_mvm_sta_from_mac80211(sta
);
303 mvmvif
= iwl_mvm_vif_from_mac80211(mvmsta
->vif
);
305 /* key mismatch - will also report !MIC_OK but we shouldn't count it */
306 if (!(status
& IWL_RX_MPDU_STATUS_KEY_VALID
))
310 if (likely(status
& IWL_RX_MPDU_STATUS_MIC_OK
&&
311 !(status
& IWL_RX_MPDU_STATUS_REPLAY_ERROR
))) {
312 stats
->flag
|= RX_FLAG_DECRYPTED
;
317 * both keys will have the same cipher and MIC length, use
318 * whichever one is available
320 key
= rcu_dereference(mvmvif
->bcn_prot
.keys
[0]);
322 key
= rcu_dereference(mvmvif
->bcn_prot
.keys
[1]);
327 if (len
< key
->icv_len
+ IEEE80211_GMAC_PN_LEN
+ 2)
330 /* get the real key ID */
331 keyid
= frame
[len
- key
->icv_len
- IEEE80211_GMAC_PN_LEN
- 2];
332 /* and if that's the other key, look it up */
333 if (keyid
!= key
->keyidx
) {
335 * shouldn't happen since firmware checked, but be safe
336 * in case the MIC length is wrong too, for example
338 if (keyid
!= 6 && keyid
!= 7)
340 key
= rcu_dereference(mvmvif
->bcn_prot
.keys
[keyid
- 6]);
345 /* Report status to mac80211 */
346 if (!(status
& IWL_RX_MPDU_STATUS_MIC_OK
))
347 ieee80211_key_mic_failure(key
);
348 else if (status
& IWL_RX_MPDU_STATUS_REPLAY_ERROR
)
349 ieee80211_key_replay(key
);
351 wdev
= ieee80211_vif_to_wdev(mvmsta
->vif
);
353 cfg80211_rx_unprot_mlme_mgmt(wdev
->netdev
, (void *)hdr
, len
);
358 static int iwl_mvm_rx_crypto(struct iwl_mvm
*mvm
, struct ieee80211_sta
*sta
,
359 struct ieee80211_hdr
*hdr
,
360 struct ieee80211_rx_status
*stats
, u16 phy_info
,
361 struct iwl_rx_mpdu_desc
*desc
,
362 u32 pkt_flags
, int queue
, u8
*crypt_len
)
364 u32 status
= le32_to_cpu(desc
->status
);
367 * Drop UNKNOWN frames in aggregation, unless in monitor mode
368 * (where we don't have the keys).
369 * We limit this to aggregation because in TKIP this is a valid
370 * scenario, since we may not have the (correct) TTAK (phase 1
371 * key) in the firmware.
373 if (phy_info
& IWL_RX_MPDU_PHY_AMPDU
&&
374 (status
& IWL_RX_MPDU_STATUS_SEC_MASK
) ==
375 IWL_RX_MPDU_STATUS_SEC_UNKNOWN
&& !mvm
->monitor_on
) {
376 IWL_DEBUG_DROP(mvm
, "Dropping packets, bad enc status\n");
380 if (unlikely(ieee80211_is_mgmt(hdr
->frame_control
) &&
381 !ieee80211_has_protected(hdr
->frame_control
)))
382 return iwl_mvm_rx_mgmt_prot(sta
, hdr
, desc
, status
, stats
);
384 if (!ieee80211_has_protected(hdr
->frame_control
) ||
385 (status
& IWL_RX_MPDU_STATUS_SEC_MASK
) ==
386 IWL_RX_MPDU_STATUS_SEC_NONE
)
389 /* TODO: handle packets encrypted with unknown alg */
391 switch (status
& IWL_RX_MPDU_STATUS_SEC_MASK
) {
392 case IWL_RX_MPDU_STATUS_SEC_CCM
:
393 case IWL_RX_MPDU_STATUS_SEC_GCM
:
394 BUILD_BUG_ON(IEEE80211_CCMP_PN_LEN
!= IEEE80211_GCMP_PN_LEN
);
395 /* alg is CCM: check MIC only */
396 if (!(status
& IWL_RX_MPDU_STATUS_MIC_OK
)) {
398 "Dropping packet, bad MIC (CCM/GCM)\n");
402 stats
->flag
|= RX_FLAG_DECRYPTED
| RX_FLAG_MIC_STRIPPED
;
403 *crypt_len
= IEEE80211_CCMP_HDR_LEN
;
405 case IWL_RX_MPDU_STATUS_SEC_TKIP
:
406 /* Don't drop the frame and decrypt it in SW */
407 if (!fw_has_api(&mvm
->fw
->ucode_capa
,
408 IWL_UCODE_TLV_API_DEPRECATE_TTAK
) &&
409 !(status
& IWL_RX_MPDU_RES_STATUS_TTAK_OK
))
412 if (mvm
->trans
->trans_cfg
->gen2
&&
413 !(status
& RX_MPDU_RES_STATUS_MIC_OK
))
414 stats
->flag
|= RX_FLAG_MMIC_ERROR
;
416 *crypt_len
= IEEE80211_TKIP_IV_LEN
;
418 case IWL_RX_MPDU_STATUS_SEC_WEP
:
419 if (!(status
& IWL_RX_MPDU_STATUS_ICV_OK
))
422 stats
->flag
|= RX_FLAG_DECRYPTED
;
423 if ((status
& IWL_RX_MPDU_STATUS_SEC_MASK
) ==
424 IWL_RX_MPDU_STATUS_SEC_WEP
)
425 *crypt_len
= IEEE80211_WEP_IV_LEN
;
427 if (pkt_flags
& FH_RSCSR_RADA_EN
) {
428 stats
->flag
|= RX_FLAG_ICV_STRIPPED
;
429 if (mvm
->trans
->trans_cfg
->gen2
)
430 stats
->flag
|= RX_FLAG_MMIC_STRIPPED
;
434 case IWL_RX_MPDU_STATUS_SEC_EXT_ENC
:
435 if (!(status
& IWL_RX_MPDU_STATUS_MIC_OK
))
437 stats
->flag
|= RX_FLAG_DECRYPTED
;
439 case RX_MPDU_RES_STATUS_SEC_CMAC_GMAC_ENC
:
443 * Sometimes we can get frames that were not decrypted
444 * because the firmware didn't have the keys yet. This can
445 * happen after connection where we can get multicast frames
446 * before the GTK is installed.
447 * Silently drop those frames.
448 * Also drop un-decrypted frames in monitor mode.
450 if (!is_multicast_ether_addr(hdr
->addr1
) &&
451 !mvm
->monitor_on
&& net_ratelimit())
452 IWL_WARN(mvm
, "Unhandled alg: 0x%x\n", status
);
458 static void iwl_mvm_rx_csum(struct iwl_mvm
*mvm
,
459 struct ieee80211_sta
*sta
,
461 struct iwl_rx_packet
*pkt
)
463 struct iwl_rx_mpdu_desc
*desc
= (void *)pkt
->data
;
465 if (mvm
->trans
->trans_cfg
->device_family
>= IWL_DEVICE_FAMILY_AX210
) {
466 if (pkt
->len_n_flags
& cpu_to_le32(FH_RSCSR_RPA_EN
)) {
467 u16 hwsum
= be16_to_cpu(desc
->v3
.raw_xsum
);
469 skb
->ip_summed
= CHECKSUM_COMPLETE
;
470 skb
->csum
= csum_unfold(~(__force __sum16
)hwsum
);
473 struct iwl_mvm_sta
*mvmsta
= iwl_mvm_sta_from_mac80211(sta
);
474 struct iwl_mvm_vif
*mvmvif
;
475 u16 flags
= le16_to_cpu(desc
->l3l4_flags
);
476 u8 l3_prot
= (u8
)((flags
& IWL_RX_L3L4_L3_PROTO_MASK
) >>
477 IWL_RX_L3_PROTO_POS
);
479 mvmvif
= iwl_mvm_vif_from_mac80211(mvmsta
->vif
);
481 if (mvmvif
->features
& NETIF_F_RXCSUM
&&
482 flags
& IWL_RX_L3L4_TCP_UDP_CSUM_OK
&&
483 (flags
& IWL_RX_L3L4_IP_HDR_CSUM_OK
||
484 l3_prot
== IWL_RX_L3_TYPE_IPV6
||
485 l3_prot
== IWL_RX_L3_TYPE_IPV6_FRAG
))
486 skb
->ip_summed
= CHECKSUM_UNNECESSARY
;
491 * returns true if a packet is a duplicate or invalid tid and should be dropped.
492 * Updates AMSDU PN tracking info
494 static bool iwl_mvm_is_dup(struct ieee80211_sta
*sta
, int queue
,
495 struct ieee80211_rx_status
*rx_status
,
496 struct ieee80211_hdr
*hdr
,
497 struct iwl_rx_mpdu_desc
*desc
)
499 struct iwl_mvm_sta
*mvm_sta
;
500 struct iwl_mvm_rxq_dup_data
*dup_data
;
501 u8 tid
, sub_frame_idx
;
503 if (WARN_ON(IS_ERR_OR_NULL(sta
)))
506 mvm_sta
= iwl_mvm_sta_from_mac80211(sta
);
508 if (WARN_ON_ONCE(!mvm_sta
->dup_data
))
511 dup_data
= &mvm_sta
->dup_data
[queue
];
514 * Drop duplicate 802.11 retransmissions
515 * (IEEE 802.11-2012: 9.3.2.10 "Duplicate detection and recovery")
517 if (ieee80211_is_ctl(hdr
->frame_control
) ||
518 ieee80211_is_any_nullfunc(hdr
->frame_control
) ||
519 is_multicast_ether_addr(hdr
->addr1
))
522 if (ieee80211_is_data_qos(hdr
->frame_control
)) {
523 /* frame has qos control */
524 tid
= ieee80211_get_tid(hdr
);
525 if (tid
>= IWL_MAX_TID_COUNT
)
528 tid
= IWL_MAX_TID_COUNT
;
531 /* If this wasn't a part of an A-MSDU the sub-frame index will be 0 */
532 sub_frame_idx
= desc
->amsdu_info
&
533 IWL_RX_MPDU_AMSDU_SUBFRAME_IDX_MASK
;
535 if (unlikely(ieee80211_has_retry(hdr
->frame_control
) &&
536 dup_data
->last_seq
[tid
] == hdr
->seq_ctrl
&&
537 dup_data
->last_sub_frame
[tid
] >= sub_frame_idx
))
540 /* Allow same PN as the first subframe for following sub frames */
541 if (dup_data
->last_seq
[tid
] == hdr
->seq_ctrl
&&
542 sub_frame_idx
> dup_data
->last_sub_frame
[tid
] &&
543 desc
->mac_flags2
& IWL_RX_MPDU_MFLG2_AMSDU
)
544 rx_status
->flag
|= RX_FLAG_ALLOW_SAME_PN
;
546 dup_data
->last_seq
[tid
] = hdr
->seq_ctrl
;
547 dup_data
->last_sub_frame
[tid
] = sub_frame_idx
;
549 rx_status
->flag
|= RX_FLAG_DUP_VALIDATED
;
554 static void iwl_mvm_release_frames(struct iwl_mvm
*mvm
,
555 struct ieee80211_sta
*sta
,
556 struct napi_struct
*napi
,
557 struct iwl_mvm_baid_data
*baid_data
,
558 struct iwl_mvm_reorder_buffer
*reorder_buf
,
561 struct iwl_mvm_reorder_buf_entry
*entries
=
562 &baid_data
->entries
[reorder_buf
->queue
*
563 baid_data
->entries_per_queue
];
564 u16 ssn
= reorder_buf
->head_sn
;
566 lockdep_assert_held(&reorder_buf
->lock
);
568 while (ieee80211_sn_less(ssn
, nssn
)) {
569 int index
= ssn
% baid_data
->buf_size
;
570 struct sk_buff_head
*skb_list
= &entries
[index
].frames
;
573 ssn
= ieee80211_sn_inc(ssn
);
576 * Empty the list. Will have more than one frame for A-MSDU.
577 * Empty list is valid as well since nssn indicates frames were
580 while ((skb
= __skb_dequeue(skb_list
))) {
581 iwl_mvm_pass_packet_to_mac80211(mvm
, napi
, skb
,
584 reorder_buf
->num_stored
--;
587 reorder_buf
->head_sn
= nssn
;
590 static void iwl_mvm_del_ba(struct iwl_mvm
*mvm
, int queue
,
591 struct iwl_mvm_delba_data
*data
)
593 struct iwl_mvm_baid_data
*ba_data
;
594 struct ieee80211_sta
*sta
;
595 struct iwl_mvm_reorder_buffer
*reorder_buf
;
596 u8 baid
= data
->baid
;
599 if (WARN_ONCE(baid
>= IWL_MAX_BAID
, "invalid BAID: %x\n", baid
))
604 ba_data
= rcu_dereference(mvm
->baid_map
[baid
]);
605 if (WARN_ON_ONCE(!ba_data
))
608 /* pick any STA ID to find the pointer */
609 sta_id
= ffs(ba_data
->sta_mask
) - 1;
610 sta
= rcu_dereference(mvm
->fw_id_to_mac_id
[sta_id
]);
611 if (WARN_ON_ONCE(IS_ERR_OR_NULL(sta
)))
614 reorder_buf
= &ba_data
->reorder_buf
[queue
];
616 /* release all frames that are in the reorder buffer to the stack */
617 spin_lock_bh(&reorder_buf
->lock
);
618 iwl_mvm_release_frames(mvm
, sta
, NULL
, ba_data
, reorder_buf
,
619 ieee80211_sn_add(reorder_buf
->head_sn
,
621 spin_unlock_bh(&reorder_buf
->lock
);
627 static void iwl_mvm_release_frames_from_notif(struct iwl_mvm
*mvm
,
628 struct napi_struct
*napi
,
629 u8 baid
, u16 nssn
, int queue
)
631 struct ieee80211_sta
*sta
;
632 struct iwl_mvm_reorder_buffer
*reorder_buf
;
633 struct iwl_mvm_baid_data
*ba_data
;
636 IWL_DEBUG_HT(mvm
, "Frame release notification for BAID %u, NSSN %d\n",
639 if (WARN_ON_ONCE(baid
== IWL_RX_REORDER_DATA_INVALID_BAID
||
640 baid
>= ARRAY_SIZE(mvm
->baid_map
)))
645 ba_data
= rcu_dereference(mvm
->baid_map
[baid
]);
646 if (WARN(!ba_data
, "BAID %d not found in map\n", baid
))
649 /* pick any STA ID to find the pointer */
650 sta_id
= ffs(ba_data
->sta_mask
) - 1;
651 sta
= rcu_dereference(mvm
->fw_id_to_mac_id
[sta_id
]);
652 if (WARN_ON_ONCE(IS_ERR_OR_NULL(sta
)))
655 reorder_buf
= &ba_data
->reorder_buf
[queue
];
657 spin_lock_bh(&reorder_buf
->lock
);
658 iwl_mvm_release_frames(mvm
, sta
, napi
, ba_data
,
660 spin_unlock_bh(&reorder_buf
->lock
);
666 void iwl_mvm_rx_queue_notif(struct iwl_mvm
*mvm
, struct napi_struct
*napi
,
667 struct iwl_rx_cmd_buffer
*rxb
, int queue
)
669 struct iwl_rx_packet
*pkt
= rxb_addr(rxb
);
670 struct iwl_rxq_sync_notification
*notif
;
671 struct iwl_mvm_internal_rxq_notif
*internal_notif
;
672 u32 len
= iwl_rx_packet_payload_len(pkt
);
674 notif
= (void *)pkt
->data
;
675 internal_notif
= (void *)notif
->payload
;
677 if (WARN_ONCE(len
< sizeof(*notif
) + sizeof(*internal_notif
),
678 "invalid notification size %d (%d)",
679 len
, (int)(sizeof(*notif
) + sizeof(*internal_notif
))))
681 len
-= sizeof(*notif
) + sizeof(*internal_notif
);
683 if (WARN_ONCE(internal_notif
->sync
&&
684 mvm
->queue_sync_cookie
!= internal_notif
->cookie
,
685 "Received expired RX queue sync message (cookie %d but wanted %d, queue %d)\n",
686 internal_notif
->cookie
, mvm
->queue_sync_cookie
, queue
))
689 switch (internal_notif
->type
) {
690 case IWL_MVM_RXQ_EMPTY
:
691 WARN_ONCE(len
, "invalid empty notification size %d", len
);
693 case IWL_MVM_RXQ_NOTIF_DEL_BA
:
694 if (WARN_ONCE(len
!= sizeof(struct iwl_mvm_delba_data
),
695 "invalid delba notification size %d (%d)",
696 len
, (int)sizeof(struct iwl_mvm_delba_data
)))
698 iwl_mvm_del_ba(mvm
, queue
, (void *)internal_notif
->data
);
701 WARN_ONCE(1, "Invalid identifier %d", internal_notif
->type
);
704 if (internal_notif
->sync
) {
705 WARN_ONCE(!test_and_clear_bit(queue
, &mvm
->queue_sync_state
),
706 "queue sync: queue %d responded a second time!\n",
708 if (READ_ONCE(mvm
->queue_sync_state
) == 0)
709 wake_up(&mvm
->rx_sync_waitq
);
714 * Returns true if the MPDU was buffered\dropped, false if it should be passed
717 static bool iwl_mvm_reorder(struct iwl_mvm
*mvm
,
718 struct napi_struct
*napi
,
720 struct ieee80211_sta
*sta
,
722 struct iwl_rx_mpdu_desc
*desc
)
724 struct ieee80211_hdr
*hdr
= (void *)skb_mac_header(skb
);
725 struct iwl_mvm_baid_data
*baid_data
;
726 struct iwl_mvm_reorder_buffer
*buffer
;
727 u32 reorder
= le32_to_cpu(desc
->reorder_data
);
728 bool amsdu
= desc
->mac_flags2
& IWL_RX_MPDU_MFLG2_AMSDU
;
730 desc
->amsdu_info
& IWL_RX_MPDU_AMSDU_LAST_SUBFRAME
;
731 u8 tid
= ieee80211_get_tid(hdr
);
732 struct iwl_mvm_reorder_buf_entry
*entries
;
738 baid
= (reorder
& IWL_RX_MPDU_REORDER_BAID_MASK
) >>
739 IWL_RX_MPDU_REORDER_BAID_SHIFT
;
741 if (mvm
->trans
->trans_cfg
->device_family
== IWL_DEVICE_FAMILY_9000
)
745 * This also covers the case of receiving a Block Ack Request
746 * outside a BA session; we'll pass it to mac80211 and that
747 * then sends a delBA action frame.
748 * This also covers pure monitor mode, in which case we won't
749 * have any BA sessions.
751 if (baid
== IWL_RX_REORDER_DATA_INVALID_BAID
)
755 if (WARN_ONCE(IS_ERR_OR_NULL(sta
),
756 "Got valid BAID without a valid station assigned\n"))
759 /* not a data packet or a bar */
760 if (!ieee80211_is_back_req(hdr
->frame_control
) &&
761 (!ieee80211_is_data_qos(hdr
->frame_control
) ||
762 is_multicast_ether_addr(hdr
->addr1
)))
765 if (unlikely(!ieee80211_is_data_present(hdr
->frame_control
)))
768 baid_data
= rcu_dereference(mvm
->baid_map
[baid
]);
771 "Got valid BAID but no baid allocated, bypass the re-ordering buffer. Baid %d reorder 0x%x\n",
776 sta_mask
= iwl_mvm_sta_fw_id_mask(mvm
, sta
, -1);
778 if (IWL_FW_CHECK(mvm
,
779 tid
!= baid_data
->tid
||
780 !(sta_mask
& baid_data
->sta_mask
),
781 "baid 0x%x is mapped to sta_mask:0x%x tid:%d, but was received for sta_mask:0x%x tid:%d\n",
782 baid
, baid_data
->sta_mask
, baid_data
->tid
,
786 nssn
= reorder
& IWL_RX_MPDU_REORDER_NSSN_MASK
;
787 sn
= (reorder
& IWL_RX_MPDU_REORDER_SN_MASK
) >>
788 IWL_RX_MPDU_REORDER_SN_SHIFT
;
790 buffer
= &baid_data
->reorder_buf
[queue
];
791 entries
= &baid_data
->entries
[queue
* baid_data
->entries_per_queue
];
793 spin_lock_bh(&buffer
->lock
);
795 if (!buffer
->valid
) {
796 if (reorder
& IWL_RX_MPDU_REORDER_BA_OLD_SN
) {
797 spin_unlock_bh(&buffer
->lock
);
800 buffer
->valid
= true;
803 /* drop any duplicated packets */
804 if (desc
->status
& cpu_to_le32(IWL_RX_MPDU_STATUS_DUPLICATE
))
807 /* drop any oudated packets */
808 if (reorder
& IWL_RX_MPDU_REORDER_BA_OLD_SN
)
811 /* release immediately if allowed by nssn and no stored frames */
812 if (!buffer
->num_stored
&& ieee80211_sn_less(sn
, nssn
)) {
813 if (!amsdu
|| last_subframe
)
814 buffer
->head_sn
= nssn
;
816 spin_unlock_bh(&buffer
->lock
);
821 * release immediately if there are no stored frames, and the sn is
823 * This can happen due to reorder timer, where NSSN is behind head_sn.
824 * When we released everything, and we got the next frame in the
825 * sequence, according to the NSSN we can't release immediately,
826 * while technically there is no hole and we can move forward.
828 if (!buffer
->num_stored
&& sn
== buffer
->head_sn
) {
829 if (!amsdu
|| last_subframe
)
830 buffer
->head_sn
= ieee80211_sn_inc(buffer
->head_sn
);
832 spin_unlock_bh(&buffer
->lock
);
836 /* put in reorder buffer */
837 index
= sn
% baid_data
->buf_size
;
838 __skb_queue_tail(&entries
[index
].frames
, skb
);
839 buffer
->num_stored
++;
842 * We cannot trust NSSN for AMSDU sub-frames that are not the last.
843 * The reason is that NSSN advances on the first sub-frame, and may
844 * cause the reorder buffer to advance before all the sub-frames arrive.
845 * Example: reorder buffer contains SN 0 & 2, and we receive AMSDU with
846 * SN 1. NSSN for first sub frame will be 3 with the result of driver
847 * releasing SN 0,1, 2. When sub-frame 1 arrives - reorder buffer is
848 * already ahead and it will be dropped.
849 * If the last sub-frame is not on this queue - we will get frame
850 * release notification with up to date NSSN.
852 if (!amsdu
|| last_subframe
)
853 iwl_mvm_release_frames(mvm
, sta
, napi
, baid_data
,
856 spin_unlock_bh(&buffer
->lock
);
861 spin_unlock_bh(&buffer
->lock
);
865 static void iwl_mvm_agg_rx_received(struct iwl_mvm
*mvm
,
866 u32 reorder_data
, u8 baid
)
868 unsigned long now
= jiffies
;
869 unsigned long timeout
;
870 struct iwl_mvm_baid_data
*data
;
874 data
= rcu_dereference(mvm
->baid_map
[baid
]);
877 "Got valid BAID but no baid allocated, bypass the re-ordering buffer. Baid %d reorder 0x%x\n",
885 timeout
= data
->timeout
;
887 * Do not update last rx all the time to avoid cache bouncing
888 * between the rx queues.
889 * Update it every timeout. Worst case is the session will
890 * expire after ~ 2 * timeout, which doesn't matter that much.
892 if (time_before(data
->last_rx
+ TU_TO_JIFFIES(timeout
), now
))
893 /* Update is atomic */
900 static void iwl_mvm_flip_address(u8
*addr
)
903 u8 mac_addr
[ETH_ALEN
];
905 for (i
= 0; i
< ETH_ALEN
; i
++)
906 mac_addr
[i
] = addr
[ETH_ALEN
- i
- 1];
907 ether_addr_copy(addr
, mac_addr
);
910 struct iwl_mvm_rx_phy_data
{
911 enum iwl_rx_phy_info_type info_type
;
912 __le32 d0
, d1
, d2
, d3
, eht_d4
, d5
;
921 u8 energy_a
, energy_b
;
925 static void iwl_mvm_decode_he_mu_ext(struct iwl_mvm
*mvm
,
926 struct iwl_mvm_rx_phy_data
*phy_data
,
927 struct ieee80211_radiotap_he_mu
*he_mu
)
929 u32 phy_data2
= le32_to_cpu(phy_data
->d2
);
930 u32 phy_data3
= le32_to_cpu(phy_data
->d3
);
931 u16 phy_data4
= le16_to_cpu(phy_data
->d4
);
932 u32 rate_n_flags
= phy_data
->rate_n_flags
;
934 if (FIELD_GET(IWL_RX_PHY_DATA4_HE_MU_EXT_CH1_CRC_OK
, phy_data4
)) {
936 cpu_to_le16(IEEE80211_RADIOTAP_HE_MU_FLAGS1_CH1_RU_KNOWN
|
937 IEEE80211_RADIOTAP_HE_MU_FLAGS1_CH1_CTR_26T_RU_KNOWN
);
940 le16_encode_bits(FIELD_GET(IWL_RX_PHY_DATA4_HE_MU_EXT_CH1_CTR_RU
,
942 IEEE80211_RADIOTAP_HE_MU_FLAGS1_CH1_CTR_26T_RU
);
944 he_mu
->ru_ch1
[0] = FIELD_GET(IWL_RX_PHY_DATA2_HE_MU_EXT_CH1_RU0
,
946 he_mu
->ru_ch1
[1] = FIELD_GET(IWL_RX_PHY_DATA3_HE_MU_EXT_CH1_RU1
,
948 he_mu
->ru_ch1
[2] = FIELD_GET(IWL_RX_PHY_DATA2_HE_MU_EXT_CH1_RU2
,
950 he_mu
->ru_ch1
[3] = FIELD_GET(IWL_RX_PHY_DATA3_HE_MU_EXT_CH1_RU3
,
954 if (FIELD_GET(IWL_RX_PHY_DATA4_HE_MU_EXT_CH2_CRC_OK
, phy_data4
) &&
955 (rate_n_flags
& RATE_MCS_CHAN_WIDTH_MSK_V1
) != RATE_MCS_CHAN_WIDTH_20
) {
957 cpu_to_le16(IEEE80211_RADIOTAP_HE_MU_FLAGS1_CH2_RU_KNOWN
|
958 IEEE80211_RADIOTAP_HE_MU_FLAGS1_CH2_CTR_26T_RU_KNOWN
);
961 le16_encode_bits(FIELD_GET(IWL_RX_PHY_DATA4_HE_MU_EXT_CH2_CTR_RU
,
963 IEEE80211_RADIOTAP_HE_MU_FLAGS2_CH2_CTR_26T_RU
);
965 he_mu
->ru_ch2
[0] = FIELD_GET(IWL_RX_PHY_DATA2_HE_MU_EXT_CH2_RU0
,
967 he_mu
->ru_ch2
[1] = FIELD_GET(IWL_RX_PHY_DATA3_HE_MU_EXT_CH2_RU1
,
969 he_mu
->ru_ch2
[2] = FIELD_GET(IWL_RX_PHY_DATA2_HE_MU_EXT_CH2_RU2
,
971 he_mu
->ru_ch2
[3] = FIELD_GET(IWL_RX_PHY_DATA3_HE_MU_EXT_CH2_RU3
,
977 iwl_mvm_decode_he_phy_ru_alloc(struct iwl_mvm_rx_phy_data
*phy_data
,
978 struct ieee80211_radiotap_he
*he
,
979 struct ieee80211_radiotap_he_mu
*he_mu
,
980 struct ieee80211_rx_status
*rx_status
)
983 * Unfortunately, we have to leave the mac80211 data
984 * incorrect for the case that we receive an HE-MU
985 * transmission and *don't* have the HE phy data (due
986 * to the bits being used for TSF). This shouldn't
987 * happen though as management frames where we need
988 * the TSF/timers are not be transmitted in HE-MU.
990 u8 ru
= le32_get_bits(phy_data
->d1
, IWL_RX_PHY_DATA1_HE_RU_ALLOC_MASK
);
991 u32 rate_n_flags
= phy_data
->rate_n_flags
;
992 u32 he_type
= rate_n_flags
& RATE_MCS_HE_TYPE_MSK_V1
;
995 rx_status
->bw
= RATE_INFO_BW_HE_RU
;
997 he
->data1
|= cpu_to_le16(IEEE80211_RADIOTAP_HE_DATA1_BW_RU_ALLOC_KNOWN
);
1001 rx_status
->he_ru
= NL80211_RATE_INFO_HE_RU_ALLOC_26
;
1005 rx_status
->he_ru
= NL80211_RATE_INFO_HE_RU_ALLOC_52
;
1009 rx_status
->he_ru
= NL80211_RATE_INFO_HE_RU_ALLOC_106
;
1013 rx_status
->he_ru
= NL80211_RATE_INFO_HE_RU_ALLOC_242
;
1017 rx_status
->he_ru
= NL80211_RATE_INFO_HE_RU_ALLOC_484
;
1021 rx_status
->he_ru
= NL80211_RATE_INFO_HE_RU_ALLOC_996
;
1024 rx_status
->he_ru
= NL80211_RATE_INFO_HE_RU_ALLOC_2x996
;
1027 he
->data2
|= le16_encode_bits(offs
,
1028 IEEE80211_RADIOTAP_HE_DATA2_RU_OFFSET
);
1029 he
->data2
|= cpu_to_le16(IEEE80211_RADIOTAP_HE_DATA2_PRISEC_80_KNOWN
|
1030 IEEE80211_RADIOTAP_HE_DATA2_RU_OFFSET_KNOWN
);
1031 if (phy_data
->d1
& cpu_to_le32(IWL_RX_PHY_DATA1_HE_RU_ALLOC_SEC80
))
1033 cpu_to_le16(IEEE80211_RADIOTAP_HE_DATA2_PRISEC_80_SEC
);
1035 #define CHECK_BW(bw) \
1036 BUILD_BUG_ON(IEEE80211_RADIOTAP_HE_MU_FLAGS2_BW_FROM_SIG_A_BW_ ## bw ## MHZ != \
1037 RATE_MCS_CHAN_WIDTH_##bw >> RATE_MCS_CHAN_WIDTH_POS); \
1038 BUILD_BUG_ON(IEEE80211_RADIOTAP_HE_DATA6_TB_PPDU_BW_ ## bw ## MHZ != \
1039 RATE_MCS_CHAN_WIDTH_##bw >> RATE_MCS_CHAN_WIDTH_POS)
1047 le16_encode_bits(FIELD_GET(RATE_MCS_CHAN_WIDTH_MSK_V1
,
1049 IEEE80211_RADIOTAP_HE_MU_FLAGS2_BW_FROM_SIG_A_BW
);
1050 else if (he_type
== RATE_MCS_HE_TYPE_TRIG_V1
)
1052 cpu_to_le16(IEEE80211_RADIOTAP_HE_DATA6_TB_PPDU_BW_KNOWN
) |
1053 le16_encode_bits(FIELD_GET(RATE_MCS_CHAN_WIDTH_MSK_V1
,
1055 IEEE80211_RADIOTAP_HE_DATA6_TB_PPDU_BW
);
1058 static void iwl_mvm_decode_he_phy_data(struct iwl_mvm
*mvm
,
1059 struct iwl_mvm_rx_phy_data
*phy_data
,
1060 struct ieee80211_radiotap_he
*he
,
1061 struct ieee80211_radiotap_he_mu
*he_mu
,
1062 struct ieee80211_rx_status
*rx_status
,
1065 switch (phy_data
->info_type
) {
1066 case IWL_RX_PHY_INFO_TYPE_NONE
:
1067 case IWL_RX_PHY_INFO_TYPE_CCK
:
1068 case IWL_RX_PHY_INFO_TYPE_OFDM_LGCY
:
1069 case IWL_RX_PHY_INFO_TYPE_HT
:
1070 case IWL_RX_PHY_INFO_TYPE_VHT_SU
:
1071 case IWL_RX_PHY_INFO_TYPE_VHT_MU
:
1072 case IWL_RX_PHY_INFO_TYPE_EHT_MU
:
1073 case IWL_RX_PHY_INFO_TYPE_EHT_TB
:
1074 case IWL_RX_PHY_INFO_TYPE_EHT_MU_EXT
:
1075 case IWL_RX_PHY_INFO_TYPE_EHT_TB_EXT
:
1077 case IWL_RX_PHY_INFO_TYPE_HE_TB_EXT
:
1078 he
->data1
|= cpu_to_le16(IEEE80211_RADIOTAP_HE_DATA1_SPTL_REUSE_KNOWN
|
1079 IEEE80211_RADIOTAP_HE_DATA1_SPTL_REUSE2_KNOWN
|
1080 IEEE80211_RADIOTAP_HE_DATA1_SPTL_REUSE3_KNOWN
|
1081 IEEE80211_RADIOTAP_HE_DATA1_SPTL_REUSE4_KNOWN
);
1082 he
->data4
|= le16_encode_bits(le32_get_bits(phy_data
->d2
,
1083 IWL_RX_PHY_DATA2_HE_TB_EXT_SPTL_REUSE1
),
1084 IEEE80211_RADIOTAP_HE_DATA4_TB_SPTL_REUSE1
);
1085 he
->data4
|= le16_encode_bits(le32_get_bits(phy_data
->d2
,
1086 IWL_RX_PHY_DATA2_HE_TB_EXT_SPTL_REUSE2
),
1087 IEEE80211_RADIOTAP_HE_DATA4_TB_SPTL_REUSE2
);
1088 he
->data4
|= le16_encode_bits(le32_get_bits(phy_data
->d2
,
1089 IWL_RX_PHY_DATA2_HE_TB_EXT_SPTL_REUSE3
),
1090 IEEE80211_RADIOTAP_HE_DATA4_TB_SPTL_REUSE3
);
1091 he
->data4
|= le16_encode_bits(le32_get_bits(phy_data
->d2
,
1092 IWL_RX_PHY_DATA2_HE_TB_EXT_SPTL_REUSE4
),
1093 IEEE80211_RADIOTAP_HE_DATA4_TB_SPTL_REUSE4
);
1095 case IWL_RX_PHY_INFO_TYPE_HE_SU
:
1096 case IWL_RX_PHY_INFO_TYPE_HE_MU
:
1097 case IWL_RX_PHY_INFO_TYPE_HE_MU_EXT
:
1098 case IWL_RX_PHY_INFO_TYPE_HE_TB
:
1100 he
->data1
|= cpu_to_le16(IEEE80211_RADIOTAP_HE_DATA1_LDPC_XSYMSEG_KNOWN
|
1101 IEEE80211_RADIOTAP_HE_DATA1_DOPPLER_KNOWN
|
1102 IEEE80211_RADIOTAP_HE_DATA1_BSS_COLOR_KNOWN
);
1103 he
->data2
|= cpu_to_le16(IEEE80211_RADIOTAP_HE_DATA2_PRE_FEC_PAD_KNOWN
|
1104 IEEE80211_RADIOTAP_HE_DATA2_PE_DISAMBIG_KNOWN
|
1105 IEEE80211_RADIOTAP_HE_DATA2_TXOP_KNOWN
|
1106 IEEE80211_RADIOTAP_HE_DATA2_NUM_LTF_SYMS_KNOWN
);
1107 he
->data3
|= le16_encode_bits(le32_get_bits(phy_data
->d0
,
1108 IWL_RX_PHY_DATA0_HE_BSS_COLOR_MASK
),
1109 IEEE80211_RADIOTAP_HE_DATA3_BSS_COLOR
);
1110 if (phy_data
->info_type
!= IWL_RX_PHY_INFO_TYPE_HE_TB
&&
1111 phy_data
->info_type
!= IWL_RX_PHY_INFO_TYPE_HE_TB_EXT
) {
1112 he
->data1
|= cpu_to_le16(IEEE80211_RADIOTAP_HE_DATA1_UL_DL_KNOWN
);
1113 he
->data3
|= le16_encode_bits(le32_get_bits(phy_data
->d0
,
1114 IWL_RX_PHY_DATA0_HE_UPLINK
),
1115 IEEE80211_RADIOTAP_HE_DATA3_UL_DL
);
1117 he
->data3
|= le16_encode_bits(le32_get_bits(phy_data
->d0
,
1118 IWL_RX_PHY_DATA0_HE_LDPC_EXT_SYM
),
1119 IEEE80211_RADIOTAP_HE_DATA3_LDPC_XSYMSEG
);
1120 he
->data5
|= le16_encode_bits(le32_get_bits(phy_data
->d0
,
1121 IWL_RX_PHY_DATA0_HE_PRE_FEC_PAD_MASK
),
1122 IEEE80211_RADIOTAP_HE_DATA5_PRE_FEC_PAD
);
1123 he
->data5
|= le16_encode_bits(le32_get_bits(phy_data
->d0
,
1124 IWL_RX_PHY_DATA0_HE_PE_DISAMBIG
),
1125 IEEE80211_RADIOTAP_HE_DATA5_PE_DISAMBIG
);
1126 he
->data5
|= le16_encode_bits(le32_get_bits(phy_data
->d1
,
1127 IWL_RX_PHY_DATA1_HE_LTF_NUM_MASK
),
1128 IEEE80211_RADIOTAP_HE_DATA5_NUM_LTF_SYMS
);
1129 he
->data6
|= le16_encode_bits(le32_get_bits(phy_data
->d0
,
1130 IWL_RX_PHY_DATA0_HE_TXOP_DUR_MASK
),
1131 IEEE80211_RADIOTAP_HE_DATA6_TXOP
);
1132 he
->data6
|= le16_encode_bits(le32_get_bits(phy_data
->d0
,
1133 IWL_RX_PHY_DATA0_HE_DOPPLER
),
1134 IEEE80211_RADIOTAP_HE_DATA6_DOPPLER
);
1138 switch (phy_data
->info_type
) {
1139 case IWL_RX_PHY_INFO_TYPE_HE_MU_EXT
:
1140 case IWL_RX_PHY_INFO_TYPE_HE_MU
:
1141 case IWL_RX_PHY_INFO_TYPE_HE_SU
:
1142 he
->data1
|= cpu_to_le16(IEEE80211_RADIOTAP_HE_DATA1_SPTL_REUSE_KNOWN
);
1143 he
->data4
|= le16_encode_bits(le32_get_bits(phy_data
->d0
,
1144 IWL_RX_PHY_DATA0_HE_SPATIAL_REUSE_MASK
),
1145 IEEE80211_RADIOTAP_HE_DATA4_SU_MU_SPTL_REUSE
);
1152 switch (phy_data
->info_type
) {
1153 case IWL_RX_PHY_INFO_TYPE_HE_MU_EXT
:
1155 le16_encode_bits(le16_get_bits(phy_data
->d4
,
1156 IWL_RX_PHY_DATA4_HE_MU_EXT_SIGB_DCM
),
1157 IEEE80211_RADIOTAP_HE_MU_FLAGS1_SIG_B_DCM
);
1159 le16_encode_bits(le16_get_bits(phy_data
->d4
,
1160 IWL_RX_PHY_DATA4_HE_MU_EXT_SIGB_MCS_MASK
),
1161 IEEE80211_RADIOTAP_HE_MU_FLAGS1_SIG_B_MCS
);
1163 le16_encode_bits(le16_get_bits(phy_data
->d4
,
1164 IWL_RX_PHY_DATA4_HE_MU_EXT_PREAMBLE_PUNC_TYPE_MASK
),
1165 IEEE80211_RADIOTAP_HE_MU_FLAGS2_PUNC_FROM_SIG_A_BW
);
1166 iwl_mvm_decode_he_mu_ext(mvm
, phy_data
, he_mu
);
1168 case IWL_RX_PHY_INFO_TYPE_HE_MU
:
1170 le16_encode_bits(le32_get_bits(phy_data
->d1
,
1171 IWL_RX_PHY_DATA1_HE_MU_SIBG_SYM_OR_USER_NUM_MASK
),
1172 IEEE80211_RADIOTAP_HE_MU_FLAGS2_SIG_B_SYMS_USERS
);
1174 le16_encode_bits(le32_get_bits(phy_data
->d1
,
1175 IWL_RX_PHY_DATA1_HE_MU_SIGB_COMPRESSION
),
1176 IEEE80211_RADIOTAP_HE_MU_FLAGS2_SIG_B_COMP
);
1178 case IWL_RX_PHY_INFO_TYPE_HE_TB
:
1179 case IWL_RX_PHY_INFO_TYPE_HE_TB_EXT
:
1180 iwl_mvm_decode_he_phy_ru_alloc(phy_data
, he
, he_mu
, rx_status
);
1182 case IWL_RX_PHY_INFO_TYPE_HE_SU
:
1183 he
->data1
|= cpu_to_le16(IEEE80211_RADIOTAP_HE_DATA1_BEAM_CHANGE_KNOWN
);
1184 he
->data3
|= le16_encode_bits(le32_get_bits(phy_data
->d0
,
1185 IWL_RX_PHY_DATA0_HE_BEAM_CHNG
),
1186 IEEE80211_RADIOTAP_HE_DATA3_BEAM_CHANGE
);
1194 #define LE32_DEC_ENC(value, dec_bits, enc_bits) \
1195 le32_encode_bits(le32_get_bits(value, dec_bits), enc_bits)
1197 #define IWL_MVM_ENC_USIG_VALUE_MASK(usig, in_value, dec_bits, enc_bits) do { \
1198 typeof(enc_bits) _enc_bits = enc_bits; \
1199 typeof(usig) _usig = usig; \
1200 (_usig)->mask |= cpu_to_le32(_enc_bits); \
1201 (_usig)->value |= LE32_DEC_ENC(in_value, dec_bits, _enc_bits); \
1204 #define __IWL_MVM_ENC_EHT_RU(rt_data, rt_ru, fw_data, fw_ru) \
1205 eht->data[(rt_data)] |= \
1207 (IEEE80211_RADIOTAP_EHT_DATA ## rt_data ## _RU_ALLOC_CC_ ## rt_ru ## _KNOWN) | \
1208 LE32_DEC_ENC(data ## fw_data, \
1209 IWL_RX_PHY_DATA ## fw_data ## _EHT_MU_EXT_RU_ALLOC_ ## fw_ru, \
1210 IEEE80211_RADIOTAP_EHT_DATA ## rt_data ## _RU_ALLOC_CC_ ## rt_ru))
1212 #define _IWL_MVM_ENC_EHT_RU(rt_data, rt_ru, fw_data, fw_ru) \
1213 __IWL_MVM_ENC_EHT_RU(rt_data, rt_ru, fw_data, fw_ru)
1215 #define IEEE80211_RADIOTAP_RU_DATA_1_1_1 1
1216 #define IEEE80211_RADIOTAP_RU_DATA_2_1_1 2
1217 #define IEEE80211_RADIOTAP_RU_DATA_1_1_2 2
1218 #define IEEE80211_RADIOTAP_RU_DATA_2_1_2 2
1219 #define IEEE80211_RADIOTAP_RU_DATA_1_2_1 3
1220 #define IEEE80211_RADIOTAP_RU_DATA_2_2_1 3
1221 #define IEEE80211_RADIOTAP_RU_DATA_1_2_2 3
1222 #define IEEE80211_RADIOTAP_RU_DATA_2_2_2 4
1224 #define IWL_RX_RU_DATA_A1 2
1225 #define IWL_RX_RU_DATA_A2 2
1226 #define IWL_RX_RU_DATA_B1 2
1227 #define IWL_RX_RU_DATA_B2 4
1228 #define IWL_RX_RU_DATA_C1 3
1229 #define IWL_RX_RU_DATA_C2 3
1230 #define IWL_RX_RU_DATA_D1 4
1231 #define IWL_RX_RU_DATA_D2 4
1233 #define IWL_MVM_ENC_EHT_RU(rt_ru, fw_ru) \
1234 _IWL_MVM_ENC_EHT_RU(IEEE80211_RADIOTAP_RU_DATA_ ## rt_ru, \
1236 IWL_RX_RU_DATA_ ## fw_ru, \
1239 static void iwl_mvm_decode_eht_ext_mu(struct iwl_mvm
*mvm
,
1240 struct iwl_mvm_rx_phy_data
*phy_data
,
1241 struct ieee80211_rx_status
*rx_status
,
1242 struct ieee80211_radiotap_eht
*eht
,
1243 struct ieee80211_radiotap_eht_usig
*usig
)
1245 if (phy_data
->with_data
) {
1246 __le32 data1
= phy_data
->d1
;
1247 __le32 data2
= phy_data
->d2
;
1248 __le32 data3
= phy_data
->d3
;
1249 __le32 data4
= phy_data
->eht_d4
;
1250 __le32 data5
= phy_data
->d5
;
1251 u32 phy_bw
= phy_data
->rate_n_flags
& RATE_MCS_CHAN_WIDTH_MSK
;
1253 IWL_MVM_ENC_USIG_VALUE_MASK(usig
, data5
,
1254 IWL_RX_PHY_DATA5_EHT_TYPE_AND_COMP
,
1255 IEEE80211_RADIOTAP_EHT_USIG2_MU_B0_B1_PPDU_TYPE
);
1256 IWL_MVM_ENC_USIG_VALUE_MASK(usig
, data5
,
1257 IWL_RX_PHY_DATA5_EHT_MU_PUNC_CH_CODE
,
1258 IEEE80211_RADIOTAP_EHT_USIG2_MU_B3_B7_PUNCTURED_INFO
);
1259 IWL_MVM_ENC_USIG_VALUE_MASK(usig
, data4
,
1260 IWL_RX_PHY_DATA4_EHT_MU_EXT_SIGB_MCS
,
1261 IEEE80211_RADIOTAP_EHT_USIG2_MU_B9_B10_SIG_MCS
);
1262 IWL_MVM_ENC_USIG_VALUE_MASK
1263 (usig
, data1
, IWL_RX_PHY_DATA1_EHT_MU_NUM_SIG_SYM_USIGA2
,
1264 IEEE80211_RADIOTAP_EHT_USIG2_MU_B11_B15_EHT_SIG_SYMBOLS
);
1266 eht
->user_info
[0] |=
1267 cpu_to_le32(IEEE80211_RADIOTAP_EHT_USER_INFO_STA_ID_KNOWN
) |
1268 LE32_DEC_ENC(data5
, IWL_RX_PHY_DATA5_EHT_MU_STA_ID_USR
,
1269 IEEE80211_RADIOTAP_EHT_USER_INFO_STA_ID
);
1271 eht
->known
|= cpu_to_le32(IEEE80211_RADIOTAP_EHT_KNOWN_NR_NON_OFDMA_USERS_M
);
1272 eht
->data
[7] |= LE32_DEC_ENC
1273 (data5
, IWL_RX_PHY_DATA5_EHT_MU_NUM_USR_NON_OFDMA
,
1274 IEEE80211_RADIOTAP_EHT_DATA7_NUM_OF_NON_OFDMA_USERS
);
1277 * Hardware labels the content channels/RU allocation values
1279 * Content Channel 1 Content Channel 2
1282 * 80 MHz: A1 C1 B1 D1
1283 * 160 MHz: A1 C1 A2 C2 B1 D1 B2 D2
1284 * 320 MHz: A1 C1 A2 C2 A3 C3 A4 C4 B1 D1 B2 D2 B3 D3 B4 D4
1286 * However firmware can only give us A1-D2, so the higher
1287 * frequencies are missing.
1291 case RATE_MCS_CHAN_WIDTH_320
:
1292 /* additional values are missing in RX metadata */
1293 case RATE_MCS_CHAN_WIDTH_160
:
1294 /* content channel 1 */
1295 IWL_MVM_ENC_EHT_RU(1_2_1
, A2
);
1296 IWL_MVM_ENC_EHT_RU(1_2_2
, C2
);
1297 /* content channel 2 */
1298 IWL_MVM_ENC_EHT_RU(2_2_1
, B2
);
1299 IWL_MVM_ENC_EHT_RU(2_2_2
, D2
);
1301 case RATE_MCS_CHAN_WIDTH_80
:
1302 /* content channel 1 */
1303 IWL_MVM_ENC_EHT_RU(1_1_2
, C1
);
1304 /* content channel 2 */
1305 IWL_MVM_ENC_EHT_RU(2_1_2
, D1
);
1307 case RATE_MCS_CHAN_WIDTH_40
:
1308 /* content channel 2 */
1309 IWL_MVM_ENC_EHT_RU(2_1_1
, B1
);
1311 case RATE_MCS_CHAN_WIDTH_20
:
1312 IWL_MVM_ENC_EHT_RU(1_1_1
, A1
);
1316 __le32 usig_a1
= phy_data
->rx_vec
[0];
1317 __le32 usig_a2
= phy_data
->rx_vec
[1];
1319 IWL_MVM_ENC_USIG_VALUE_MASK(usig
, usig_a1
,
1320 IWL_RX_USIG_A1_DISREGARD
,
1321 IEEE80211_RADIOTAP_EHT_USIG1_MU_B20_B24_DISREGARD
);
1322 IWL_MVM_ENC_USIG_VALUE_MASK(usig
, usig_a1
,
1323 IWL_RX_USIG_A1_VALIDATE
,
1324 IEEE80211_RADIOTAP_EHT_USIG1_MU_B25_VALIDATE
);
1325 IWL_MVM_ENC_USIG_VALUE_MASK(usig
, usig_a2
,
1326 IWL_RX_USIG_A2_EHT_PPDU_TYPE
,
1327 IEEE80211_RADIOTAP_EHT_USIG2_MU_B0_B1_PPDU_TYPE
);
1328 IWL_MVM_ENC_USIG_VALUE_MASK(usig
, usig_a2
,
1329 IWL_RX_USIG_A2_EHT_USIG2_VALIDATE_B2
,
1330 IEEE80211_RADIOTAP_EHT_USIG2_MU_B2_VALIDATE
);
1331 IWL_MVM_ENC_USIG_VALUE_MASK(usig
, usig_a2
,
1332 IWL_RX_USIG_A2_EHT_PUNC_CHANNEL
,
1333 IEEE80211_RADIOTAP_EHT_USIG2_MU_B3_B7_PUNCTURED_INFO
);
1334 IWL_MVM_ENC_USIG_VALUE_MASK(usig
, usig_a2
,
1335 IWL_RX_USIG_A2_EHT_USIG2_VALIDATE_B8
,
1336 IEEE80211_RADIOTAP_EHT_USIG2_MU_B8_VALIDATE
);
1337 IWL_MVM_ENC_USIG_VALUE_MASK(usig
, usig_a2
,
1338 IWL_RX_USIG_A2_EHT_SIG_MCS
,
1339 IEEE80211_RADIOTAP_EHT_USIG2_MU_B9_B10_SIG_MCS
);
1340 IWL_MVM_ENC_USIG_VALUE_MASK
1341 (usig
, usig_a2
, IWL_RX_USIG_A2_EHT_SIG_SYM_NUM
,
1342 IEEE80211_RADIOTAP_EHT_USIG2_MU_B11_B15_EHT_SIG_SYMBOLS
);
1343 IWL_MVM_ENC_USIG_VALUE_MASK(usig
, usig_a2
,
1344 IWL_RX_USIG_A2_EHT_CRC_OK
,
1345 IEEE80211_RADIOTAP_EHT_USIG2_MU_B16_B19_CRC
);
1349 static void iwl_mvm_decode_eht_ext_tb(struct iwl_mvm
*mvm
,
1350 struct iwl_mvm_rx_phy_data
*phy_data
,
1351 struct ieee80211_rx_status
*rx_status
,
1352 struct ieee80211_radiotap_eht
*eht
,
1353 struct ieee80211_radiotap_eht_usig
*usig
)
1355 if (phy_data
->with_data
) {
1356 __le32 data5
= phy_data
->d5
;
1358 IWL_MVM_ENC_USIG_VALUE_MASK(usig
, data5
,
1359 IWL_RX_PHY_DATA5_EHT_TYPE_AND_COMP
,
1360 IEEE80211_RADIOTAP_EHT_USIG2_TB_B0_B1_PPDU_TYPE
);
1361 IWL_MVM_ENC_USIG_VALUE_MASK(usig
, data5
,
1362 IWL_RX_PHY_DATA5_EHT_TB_SPATIAL_REUSE1
,
1363 IEEE80211_RADIOTAP_EHT_USIG2_TB_B3_B6_SPATIAL_REUSE_1
);
1365 IWL_MVM_ENC_USIG_VALUE_MASK(usig
, data5
,
1366 IWL_RX_PHY_DATA5_EHT_TB_SPATIAL_REUSE2
,
1367 IEEE80211_RADIOTAP_EHT_USIG2_TB_B7_B10_SPATIAL_REUSE_2
);
1369 __le32 usig_a1
= phy_data
->rx_vec
[0];
1370 __le32 usig_a2
= phy_data
->rx_vec
[1];
1372 IWL_MVM_ENC_USIG_VALUE_MASK(usig
, usig_a1
,
1373 IWL_RX_USIG_A1_DISREGARD
,
1374 IEEE80211_RADIOTAP_EHT_USIG1_TB_B20_B25_DISREGARD
);
1375 IWL_MVM_ENC_USIG_VALUE_MASK(usig
, usig_a2
,
1376 IWL_RX_USIG_A2_EHT_PPDU_TYPE
,
1377 IEEE80211_RADIOTAP_EHT_USIG2_TB_B0_B1_PPDU_TYPE
);
1378 IWL_MVM_ENC_USIG_VALUE_MASK(usig
, usig_a2
,
1379 IWL_RX_USIG_A2_EHT_USIG2_VALIDATE_B2
,
1380 IEEE80211_RADIOTAP_EHT_USIG2_TB_B2_VALIDATE
);
1381 IWL_MVM_ENC_USIG_VALUE_MASK(usig
, usig_a2
,
1382 IWL_RX_USIG_A2_EHT_TRIG_SPATIAL_REUSE_1
,
1383 IEEE80211_RADIOTAP_EHT_USIG2_TB_B3_B6_SPATIAL_REUSE_1
);
1384 IWL_MVM_ENC_USIG_VALUE_MASK(usig
, usig_a2
,
1385 IWL_RX_USIG_A2_EHT_TRIG_SPATIAL_REUSE_2
,
1386 IEEE80211_RADIOTAP_EHT_USIG2_TB_B7_B10_SPATIAL_REUSE_2
);
1387 IWL_MVM_ENC_USIG_VALUE_MASK(usig
, usig_a2
,
1388 IWL_RX_USIG_A2_EHT_TRIG_USIG2_DISREGARD
,
1389 IEEE80211_RADIOTAP_EHT_USIG2_TB_B11_B15_DISREGARD
);
1390 IWL_MVM_ENC_USIG_VALUE_MASK(usig
, usig_a2
,
1391 IWL_RX_USIG_A2_EHT_CRC_OK
,
1392 IEEE80211_RADIOTAP_EHT_USIG2_TB_B16_B19_CRC
);
1396 static void iwl_mvm_decode_eht_ru(struct iwl_mvm
*mvm
,
1397 struct ieee80211_rx_status
*rx_status
,
1398 struct ieee80211_radiotap_eht
*eht
)
1400 u32 ru
= le32_get_bits(eht
->data
[8],
1401 IEEE80211_RADIOTAP_EHT_DATA8_RU_ALLOC_TB_FMT_B7_B1
);
1402 enum nl80211_eht_ru_alloc nl_ru
;
1404 /* Using D1.5 Table 9-53a - Encoding of PS160 and RU Allocation subfields
1405 * in an EHT variant User Info field
1410 nl_ru
= NL80211_RATE_INFO_EHT_RU_ALLOC_26
;
1413 nl_ru
= NL80211_RATE_INFO_EHT_RU_ALLOC_52
;
1416 nl_ru
= NL80211_RATE_INFO_EHT_RU_ALLOC_106
;
1419 nl_ru
= NL80211_RATE_INFO_EHT_RU_ALLOC_242
;
1422 nl_ru
= NL80211_RATE_INFO_EHT_RU_ALLOC_484
;
1425 nl_ru
= NL80211_RATE_INFO_EHT_RU_ALLOC_996
;
1428 nl_ru
= NL80211_RATE_INFO_EHT_RU_ALLOC_2x996
;
1431 nl_ru
= NL80211_RATE_INFO_EHT_RU_ALLOC_4x996
;
1434 nl_ru
= NL80211_RATE_INFO_EHT_RU_ALLOC_52P26
;
1437 nl_ru
= NL80211_RATE_INFO_EHT_RU_ALLOC_106P26
;
1440 nl_ru
= NL80211_RATE_INFO_EHT_RU_ALLOC_484P242
;
1443 nl_ru
= NL80211_RATE_INFO_EHT_RU_ALLOC_996P484
;
1446 nl_ru
= NL80211_RATE_INFO_EHT_RU_ALLOC_996P484P242
;
1449 nl_ru
= NL80211_RATE_INFO_EHT_RU_ALLOC_2x996P484
;
1452 nl_ru
= NL80211_RATE_INFO_EHT_RU_ALLOC_3x996
;
1455 nl_ru
= NL80211_RATE_INFO_EHT_RU_ALLOC_3x996P484
;
1461 rx_status
->bw
= RATE_INFO_BW_EHT_RU
;
1462 rx_status
->eht
.ru
= nl_ru
;
1465 static void iwl_mvm_decode_eht_phy_data(struct iwl_mvm
*mvm
,
1466 struct iwl_mvm_rx_phy_data
*phy_data
,
1467 struct ieee80211_rx_status
*rx_status
,
1468 struct ieee80211_radiotap_eht
*eht
,
1469 struct ieee80211_radiotap_eht_usig
*usig
)
1472 __le32 data0
= phy_data
->d0
;
1473 __le32 data1
= phy_data
->d1
;
1474 __le32 usig_a1
= phy_data
->rx_vec
[0];
1475 u8 info_type
= phy_data
->info_type
;
1477 /* Not in EHT range */
1478 if (info_type
< IWL_RX_PHY_INFO_TYPE_EHT_MU
||
1479 info_type
> IWL_RX_PHY_INFO_TYPE_EHT_TB_EXT
)
1482 usig
->common
|= cpu_to_le32
1483 (IEEE80211_RADIOTAP_EHT_USIG_COMMON_UL_DL_KNOWN
|
1484 IEEE80211_RADIOTAP_EHT_USIG_COMMON_BSS_COLOR_KNOWN
);
1485 if (phy_data
->with_data
) {
1486 usig
->common
|= LE32_DEC_ENC(data0
,
1487 IWL_RX_PHY_DATA0_EHT_UPLINK
,
1488 IEEE80211_RADIOTAP_EHT_USIG_COMMON_UL_DL
);
1489 usig
->common
|= LE32_DEC_ENC(data0
,
1490 IWL_RX_PHY_DATA0_EHT_BSS_COLOR_MASK
,
1491 IEEE80211_RADIOTAP_EHT_USIG_COMMON_BSS_COLOR
);
1493 usig
->common
|= LE32_DEC_ENC(usig_a1
,
1494 IWL_RX_USIG_A1_UL_FLAG
,
1495 IEEE80211_RADIOTAP_EHT_USIG_COMMON_UL_DL
);
1496 usig
->common
|= LE32_DEC_ENC(usig_a1
,
1497 IWL_RX_USIG_A1_BSS_COLOR
,
1498 IEEE80211_RADIOTAP_EHT_USIG_COMMON_BSS_COLOR
);
1501 if (fw_has_capa(&mvm
->fw
->ucode_capa
,
1502 IWL_UCODE_TLV_CAPA_SNIFF_VALIDATE_SUPPORT
)) {
1504 cpu_to_le32(IEEE80211_RADIOTAP_EHT_USIG_COMMON_VALIDATE_BITS_CHECKED
);
1506 LE32_DEC_ENC(data0
, IWL_RX_PHY_DATA0_EHT_VALIDATE
,
1507 IEEE80211_RADIOTAP_EHT_USIG_COMMON_VALIDATE_BITS_OK
);
1510 eht
->known
|= cpu_to_le32(IEEE80211_RADIOTAP_EHT_KNOWN_SPATIAL_REUSE
);
1511 eht
->data
[0] |= LE32_DEC_ENC(data0
,
1512 IWL_RX_PHY_DATA0_ETH_SPATIAL_REUSE_MASK
,
1513 IEEE80211_RADIOTAP_EHT_DATA0_SPATIAL_REUSE
);
1515 /* All RU allocating size/index is in TB format */
1516 eht
->known
|= cpu_to_le32(IEEE80211_RADIOTAP_EHT_KNOWN_RU_ALLOC_TB_FMT
);
1517 eht
->data
[8] |= LE32_DEC_ENC(data0
, IWL_RX_PHY_DATA0_EHT_PS160
,
1518 IEEE80211_RADIOTAP_EHT_DATA8_RU_ALLOC_TB_FMT_PS_160
);
1519 eht
->data
[8] |= LE32_DEC_ENC(data1
, IWL_RX_PHY_DATA1_EHT_RU_ALLOC_B0
,
1520 IEEE80211_RADIOTAP_EHT_DATA8_RU_ALLOC_TB_FMT_B0
);
1521 eht
->data
[8] |= LE32_DEC_ENC(data1
, IWL_RX_PHY_DATA1_EHT_RU_ALLOC_B1_B7
,
1522 IEEE80211_RADIOTAP_EHT_DATA8_RU_ALLOC_TB_FMT_B7_B1
);
1524 iwl_mvm_decode_eht_ru(mvm
, rx_status
, eht
);
1526 /* We only get here in case of IWL_RX_MPDU_PHY_TSF_OVERLOAD is set
1527 * which is on only in case of monitor mode so no need to check monitor
1530 eht
->known
|= cpu_to_le32(IEEE80211_RADIOTAP_EHT_KNOWN_PRIMARY_80
);
1532 le32_encode_bits(mvm
->monitor_p80
,
1533 IEEE80211_RADIOTAP_EHT_DATA1_PRIMARY_80
);
1535 usig
->common
|= cpu_to_le32(IEEE80211_RADIOTAP_EHT_USIG_COMMON_TXOP_KNOWN
);
1536 if (phy_data
->with_data
)
1537 usig
->common
|= LE32_DEC_ENC(data0
, IWL_RX_PHY_DATA0_EHT_TXOP_DUR_MASK
,
1538 IEEE80211_RADIOTAP_EHT_USIG_COMMON_TXOP
);
1540 usig
->common
|= LE32_DEC_ENC(usig_a1
, IWL_RX_USIG_A1_TXOP_DURATION
,
1541 IEEE80211_RADIOTAP_EHT_USIG_COMMON_TXOP
);
1543 eht
->known
|= cpu_to_le32(IEEE80211_RADIOTAP_EHT_KNOWN_LDPC_EXTRA_SYM_OM
);
1544 eht
->data
[0] |= LE32_DEC_ENC(data0
, IWL_RX_PHY_DATA0_EHT_LDPC_EXT_SYM
,
1545 IEEE80211_RADIOTAP_EHT_DATA0_LDPC_EXTRA_SYM_OM
);
1547 eht
->known
|= cpu_to_le32(IEEE80211_RADIOTAP_EHT_KNOWN_PRE_PADD_FACOR_OM
);
1548 eht
->data
[0] |= LE32_DEC_ENC(data0
, IWL_RX_PHY_DATA0_EHT_PRE_FEC_PAD_MASK
,
1549 IEEE80211_RADIOTAP_EHT_DATA0_PRE_PADD_FACOR_OM
);
1551 eht
->known
|= cpu_to_le32(IEEE80211_RADIOTAP_EHT_KNOWN_PE_DISAMBIGUITY_OM
);
1552 eht
->data
[0] |= LE32_DEC_ENC(data0
, IWL_RX_PHY_DATA0_EHT_PE_DISAMBIG
,
1553 IEEE80211_RADIOTAP_EHT_DATA0_PE_DISAMBIGUITY_OM
);
1555 /* TODO: what about IWL_RX_PHY_DATA0_EHT_BW320_SLOT */
1557 if (!le32_get_bits(data0
, IWL_RX_PHY_DATA0_EHT_SIGA_CRC_OK
))
1558 usig
->common
|= cpu_to_le32(IEEE80211_RADIOTAP_EHT_USIG_COMMON_BAD_USIG_CRC
);
1560 usig
->common
|= cpu_to_le32(IEEE80211_RADIOTAP_EHT_USIG_COMMON_PHY_VER_KNOWN
);
1561 usig
->common
|= LE32_DEC_ENC(data0
, IWL_RX_PHY_DATA0_EHT_PHY_VER
,
1562 IEEE80211_RADIOTAP_EHT_USIG_COMMON_PHY_VER
);
1565 * TODO: what about TB - IWL_RX_PHY_DATA1_EHT_TB_PILOT_TYPE,
1566 * IWL_RX_PHY_DATA1_EHT_TB_LOW_SS
1569 eht
->known
|= cpu_to_le32(IEEE80211_RADIOTAP_EHT_KNOWN_EHT_LTF
);
1570 eht
->data
[0] |= LE32_DEC_ENC(data1
, IWL_RX_PHY_DATA1_EHT_SIG_LTF_NUM
,
1571 IEEE80211_RADIOTAP_EHT_DATA0_EHT_LTF
);
1573 if (info_type
== IWL_RX_PHY_INFO_TYPE_EHT_TB_EXT
||
1574 info_type
== IWL_RX_PHY_INFO_TYPE_EHT_TB
)
1575 iwl_mvm_decode_eht_ext_tb(mvm
, phy_data
, rx_status
, eht
, usig
);
1577 if (info_type
== IWL_RX_PHY_INFO_TYPE_EHT_MU_EXT
||
1578 info_type
== IWL_RX_PHY_INFO_TYPE_EHT_MU
)
1579 iwl_mvm_decode_eht_ext_mu(mvm
, phy_data
, rx_status
, eht
, usig
);
1582 static void iwl_mvm_rx_eht(struct iwl_mvm
*mvm
, struct sk_buff
*skb
,
1583 struct iwl_mvm_rx_phy_data
*phy_data
,
1586 struct ieee80211_rx_status
*rx_status
= IEEE80211_SKB_RXCB(skb
);
1588 struct ieee80211_radiotap_eht
*eht
;
1589 struct ieee80211_radiotap_eht_usig
*usig
;
1590 size_t eht_len
= sizeof(*eht
);
1592 u32 rate_n_flags
= phy_data
->rate_n_flags
;
1593 u32 he_type
= rate_n_flags
& RATE_MCS_HE_TYPE_MSK
;
1594 /* EHT and HE have the same valus for LTF */
1595 u8 ltf
= IEEE80211_RADIOTAP_HE_DATA5_LTF_SIZE_UNKNOWN
;
1596 u16 phy_info
= phy_data
->phy_info
;
1599 /* u32 for 1 user_info */
1600 if (phy_data
->with_data
)
1601 eht_len
+= sizeof(u32
);
1603 eht
= iwl_mvm_radiotap_put_tlv(skb
, IEEE80211_RADIOTAP_EHT
, eht_len
);
1605 usig
= iwl_mvm_radiotap_put_tlv(skb
, IEEE80211_RADIOTAP_EHT_USIG
,
1607 rx_status
->flag
|= RX_FLAG_RADIOTAP_TLV_AT_END
;
1609 cpu_to_le32(IEEE80211_RADIOTAP_EHT_USIG_COMMON_BW_KNOWN
);
1611 /* specific handling for 320MHz */
1612 bw
= FIELD_GET(RATE_MCS_CHAN_WIDTH_MSK
, rate_n_flags
);
1613 if (bw
== RATE_MCS_CHAN_WIDTH_320_VAL
)
1614 bw
+= FIELD_GET(IWL_RX_PHY_DATA0_EHT_BW320_SLOT
,
1615 le32_to_cpu(phy_data
->d0
));
1617 usig
->common
|= cpu_to_le32
1618 (FIELD_PREP(IEEE80211_RADIOTAP_EHT_USIG_COMMON_BW
, bw
));
1620 /* report the AMPDU-EOF bit on single frames */
1621 if (!queue
&& !(phy_info
& IWL_RX_MPDU_PHY_AMPDU
)) {
1622 rx_status
->flag
|= RX_FLAG_AMPDU_DETAILS
;
1623 rx_status
->flag
|= RX_FLAG_AMPDU_EOF_BIT_KNOWN
;
1624 if (phy_data
->d0
& cpu_to_le32(IWL_RX_PHY_DATA0_EHT_DELIM_EOF
))
1625 rx_status
->flag
|= RX_FLAG_AMPDU_EOF_BIT
;
1628 /* update aggregation data for monitor sake on default queue */
1629 if (!queue
&& (phy_info
& IWL_RX_MPDU_PHY_TSF_OVERLOAD
) &&
1630 (phy_info
& IWL_RX_MPDU_PHY_AMPDU
) && phy_data
->first_subframe
) {
1631 rx_status
->flag
|= RX_FLAG_AMPDU_EOF_BIT_KNOWN
;
1632 if (phy_data
->d0
& cpu_to_le32(IWL_RX_PHY_DATA0_EHT_DELIM_EOF
))
1633 rx_status
->flag
|= RX_FLAG_AMPDU_EOF_BIT
;
1636 if (phy_info
& IWL_RX_MPDU_PHY_TSF_OVERLOAD
)
1637 iwl_mvm_decode_eht_phy_data(mvm
, phy_data
, rx_status
, eht
, usig
);
1639 #define CHECK_TYPE(F) \
1640 BUILD_BUG_ON(IEEE80211_RADIOTAP_HE_DATA1_FORMAT_ ## F != \
1641 (RATE_MCS_HE_TYPE_ ## F >> RATE_MCS_HE_TYPE_POS))
1648 switch (FIELD_GET(RATE_MCS_HE_GI_LTF_MSK
, rate_n_flags
)) {
1650 if (he_type
== RATE_MCS_HE_TYPE_TRIG
) {
1651 rx_status
->eht
.gi
= NL80211_RATE_INFO_EHT_GI_1_6
;
1652 ltf
= IEEE80211_RADIOTAP_HE_DATA5_LTF_SIZE_1X
;
1654 rx_status
->eht
.gi
= NL80211_RATE_INFO_EHT_GI_0_8
;
1655 ltf
= IEEE80211_RADIOTAP_HE_DATA5_LTF_SIZE_2X
;
1659 rx_status
->eht
.gi
= NL80211_RATE_INFO_EHT_GI_1_6
;
1660 ltf
= IEEE80211_RADIOTAP_HE_DATA5_LTF_SIZE_2X
;
1663 ltf
= IEEE80211_RADIOTAP_HE_DATA5_LTF_SIZE_4X
;
1664 if (he_type
== RATE_MCS_HE_TYPE_TRIG
)
1665 rx_status
->eht
.gi
= NL80211_RATE_INFO_EHT_GI_3_2
;
1667 rx_status
->eht
.gi
= NL80211_RATE_INFO_EHT_GI_0_8
;
1670 if (he_type
!= RATE_MCS_HE_TYPE_TRIG
) {
1671 ltf
= IEEE80211_RADIOTAP_HE_DATA5_LTF_SIZE_4X
;
1672 rx_status
->eht
.gi
= NL80211_RATE_INFO_EHT_GI_3_2
;
1680 if (ltf
!= IEEE80211_RADIOTAP_HE_DATA5_LTF_SIZE_UNKNOWN
) {
1681 eht
->known
|= cpu_to_le32(IEEE80211_RADIOTAP_EHT_KNOWN_GI
);
1682 eht
->data
[0] |= cpu_to_le32
1683 (FIELD_PREP(IEEE80211_RADIOTAP_EHT_DATA0_LTF
,
1685 FIELD_PREP(IEEE80211_RADIOTAP_EHT_DATA0_GI
,
1686 rx_status
->eht
.gi
));
1690 if (!phy_data
->with_data
) {
1691 eht
->known
|= cpu_to_le32(IEEE80211_RADIOTAP_EHT_KNOWN_NSS_S
|
1692 IEEE80211_RADIOTAP_EHT_KNOWN_BEAMFORMED_S
);
1694 le32_encode_bits(le32_get_bits(phy_data
->rx_vec
[2],
1695 RX_NO_DATA_RX_VEC2_EHT_NSTS_MSK
),
1696 IEEE80211_RADIOTAP_EHT_DATA7_NSS_S
);
1697 if (rate_n_flags
& RATE_MCS_BF_MSK
)
1699 cpu_to_le32(IEEE80211_RADIOTAP_EHT_DATA7_BEAMFORMED_S
);
1701 eht
->user_info
[0] |=
1702 cpu_to_le32(IEEE80211_RADIOTAP_EHT_USER_INFO_MCS_KNOWN
|
1703 IEEE80211_RADIOTAP_EHT_USER_INFO_CODING_KNOWN
|
1704 IEEE80211_RADIOTAP_EHT_USER_INFO_NSS_KNOWN_O
|
1705 IEEE80211_RADIOTAP_EHT_USER_INFO_BEAMFORMING_KNOWN_O
|
1706 IEEE80211_RADIOTAP_EHT_USER_INFO_DATA_FOR_USER
);
1708 if (rate_n_flags
& RATE_MCS_BF_MSK
)
1709 eht
->user_info
[0] |=
1710 cpu_to_le32(IEEE80211_RADIOTAP_EHT_USER_INFO_BEAMFORMING_O
);
1712 if (rate_n_flags
& RATE_MCS_LDPC_MSK
)
1713 eht
->user_info
[0] |=
1714 cpu_to_le32(IEEE80211_RADIOTAP_EHT_USER_INFO_CODING
);
1716 eht
->user_info
[0] |= cpu_to_le32
1717 (FIELD_PREP(IEEE80211_RADIOTAP_EHT_USER_INFO_MCS
,
1718 FIELD_GET(RATE_VHT_MCS_RATE_CODE_MSK
,
1720 FIELD_PREP(IEEE80211_RADIOTAP_EHT_USER_INFO_NSS_O
,
1721 FIELD_GET(RATE_MCS_NSS_MSK
, rate_n_flags
)));
1725 static void iwl_mvm_rx_he(struct iwl_mvm
*mvm
, struct sk_buff
*skb
,
1726 struct iwl_mvm_rx_phy_data
*phy_data
,
1729 struct ieee80211_rx_status
*rx_status
= IEEE80211_SKB_RXCB(skb
);
1730 struct ieee80211_radiotap_he
*he
= NULL
;
1731 struct ieee80211_radiotap_he_mu
*he_mu
= NULL
;
1732 u32 rate_n_flags
= phy_data
->rate_n_flags
;
1733 u32 he_type
= rate_n_flags
& RATE_MCS_HE_TYPE_MSK
;
1735 static const struct ieee80211_radiotap_he known
= {
1736 .data1
= cpu_to_le16(IEEE80211_RADIOTAP_HE_DATA1_DATA_MCS_KNOWN
|
1737 IEEE80211_RADIOTAP_HE_DATA1_DATA_DCM_KNOWN
|
1738 IEEE80211_RADIOTAP_HE_DATA1_STBC_KNOWN
|
1739 IEEE80211_RADIOTAP_HE_DATA1_CODING_KNOWN
),
1740 .data2
= cpu_to_le16(IEEE80211_RADIOTAP_HE_DATA2_GI_KNOWN
|
1741 IEEE80211_RADIOTAP_HE_DATA2_TXBF_KNOWN
),
1743 static const struct ieee80211_radiotap_he_mu mu_known
= {
1744 .flags1
= cpu_to_le16(IEEE80211_RADIOTAP_HE_MU_FLAGS1_SIG_B_MCS_KNOWN
|
1745 IEEE80211_RADIOTAP_HE_MU_FLAGS1_SIG_B_DCM_KNOWN
|
1746 IEEE80211_RADIOTAP_HE_MU_FLAGS1_SIG_B_SYMS_USERS_KNOWN
|
1747 IEEE80211_RADIOTAP_HE_MU_FLAGS1_SIG_B_COMP_KNOWN
),
1748 .flags2
= cpu_to_le16(IEEE80211_RADIOTAP_HE_MU_FLAGS2_PUNC_FROM_SIG_A_BW_KNOWN
|
1749 IEEE80211_RADIOTAP_HE_MU_FLAGS2_BW_FROM_SIG_A_BW_KNOWN
),
1751 u16 phy_info
= phy_data
->phy_info
;
1753 he
= skb_put_data(skb
, &known
, sizeof(known
));
1754 rx_status
->flag
|= RX_FLAG_RADIOTAP_HE
;
1756 if (phy_data
->info_type
== IWL_RX_PHY_INFO_TYPE_HE_MU
||
1757 phy_data
->info_type
== IWL_RX_PHY_INFO_TYPE_HE_MU_EXT
) {
1758 he_mu
= skb_put_data(skb
, &mu_known
, sizeof(mu_known
));
1759 rx_status
->flag
|= RX_FLAG_RADIOTAP_HE_MU
;
1762 /* report the AMPDU-EOF bit on single frames */
1763 if (!queue
&& !(phy_info
& IWL_RX_MPDU_PHY_AMPDU
)) {
1764 rx_status
->flag
|= RX_FLAG_AMPDU_DETAILS
;
1765 rx_status
->flag
|= RX_FLAG_AMPDU_EOF_BIT_KNOWN
;
1766 if (phy_data
->d0
& cpu_to_le32(IWL_RX_PHY_DATA0_HE_DELIM_EOF
))
1767 rx_status
->flag
|= RX_FLAG_AMPDU_EOF_BIT
;
1770 if (phy_info
& IWL_RX_MPDU_PHY_TSF_OVERLOAD
)
1771 iwl_mvm_decode_he_phy_data(mvm
, phy_data
, he
, he_mu
, rx_status
,
1774 /* update aggregation data for monitor sake on default queue */
1775 if (!queue
&& (phy_info
& IWL_RX_MPDU_PHY_TSF_OVERLOAD
) &&
1776 (phy_info
& IWL_RX_MPDU_PHY_AMPDU
) && phy_data
->first_subframe
) {
1777 rx_status
->flag
|= RX_FLAG_AMPDU_EOF_BIT_KNOWN
;
1778 if (phy_data
->d0
& cpu_to_le32(IWL_RX_PHY_DATA0_EHT_DELIM_EOF
))
1779 rx_status
->flag
|= RX_FLAG_AMPDU_EOF_BIT
;
1782 if (he_type
== RATE_MCS_HE_TYPE_EXT_SU
&&
1783 rate_n_flags
& RATE_MCS_HE_106T_MSK
) {
1784 rx_status
->bw
= RATE_INFO_BW_HE_RU
;
1785 rx_status
->he_ru
= NL80211_RATE_INFO_HE_RU_ALLOC_106
;
1788 /* actually data is filled in mac80211 */
1789 if (he_type
== RATE_MCS_HE_TYPE_SU
||
1790 he_type
== RATE_MCS_HE_TYPE_EXT_SU
)
1792 cpu_to_le16(IEEE80211_RADIOTAP_HE_DATA1_BW_RU_ALLOC_KNOWN
);
1794 #define CHECK_TYPE(F) \
1795 BUILD_BUG_ON(IEEE80211_RADIOTAP_HE_DATA1_FORMAT_ ## F != \
1796 (RATE_MCS_HE_TYPE_ ## F >> RATE_MCS_HE_TYPE_POS))
1803 he
->data1
|= cpu_to_le16(he_type
>> RATE_MCS_HE_TYPE_POS
);
1805 if (rate_n_flags
& RATE_MCS_BF_MSK
)
1806 he
->data5
|= cpu_to_le16(IEEE80211_RADIOTAP_HE_DATA5_TXBF
);
1808 switch ((rate_n_flags
& RATE_MCS_HE_GI_LTF_MSK
) >>
1809 RATE_MCS_HE_GI_LTF_POS
) {
1811 if (he_type
== RATE_MCS_HE_TYPE_TRIG
)
1812 rx_status
->he_gi
= NL80211_RATE_INFO_HE_GI_1_6
;
1814 rx_status
->he_gi
= NL80211_RATE_INFO_HE_GI_0_8
;
1815 if (he_type
== RATE_MCS_HE_TYPE_MU
)
1816 ltf
= IEEE80211_RADIOTAP_HE_DATA5_LTF_SIZE_4X
;
1818 ltf
= IEEE80211_RADIOTAP_HE_DATA5_LTF_SIZE_1X
;
1821 if (he_type
== RATE_MCS_HE_TYPE_TRIG
)
1822 rx_status
->he_gi
= NL80211_RATE_INFO_HE_GI_1_6
;
1824 rx_status
->he_gi
= NL80211_RATE_INFO_HE_GI_0_8
;
1825 ltf
= IEEE80211_RADIOTAP_HE_DATA5_LTF_SIZE_2X
;
1828 if (he_type
== RATE_MCS_HE_TYPE_TRIG
) {
1829 rx_status
->he_gi
= NL80211_RATE_INFO_HE_GI_3_2
;
1830 ltf
= IEEE80211_RADIOTAP_HE_DATA5_LTF_SIZE_4X
;
1832 rx_status
->he_gi
= NL80211_RATE_INFO_HE_GI_1_6
;
1833 ltf
= IEEE80211_RADIOTAP_HE_DATA5_LTF_SIZE_2X
;
1837 rx_status
->he_gi
= NL80211_RATE_INFO_HE_GI_3_2
;
1838 ltf
= IEEE80211_RADIOTAP_HE_DATA5_LTF_SIZE_4X
;
1841 rx_status
->he_gi
= NL80211_RATE_INFO_HE_GI_0_8
;
1842 ltf
= IEEE80211_RADIOTAP_HE_DATA5_LTF_SIZE_4X
;
1845 ltf
= IEEE80211_RADIOTAP_HE_DATA5_LTF_SIZE_UNKNOWN
;
1848 he
->data5
|= le16_encode_bits(ltf
,
1849 IEEE80211_RADIOTAP_HE_DATA5_LTF_SIZE
);
1852 static void iwl_mvm_decode_lsig(struct sk_buff
*skb
,
1853 struct iwl_mvm_rx_phy_data
*phy_data
)
1855 struct ieee80211_rx_status
*rx_status
= IEEE80211_SKB_RXCB(skb
);
1856 struct ieee80211_radiotap_lsig
*lsig
;
1858 switch (phy_data
->info_type
) {
1859 case IWL_RX_PHY_INFO_TYPE_HT
:
1860 case IWL_RX_PHY_INFO_TYPE_VHT_SU
:
1861 case IWL_RX_PHY_INFO_TYPE_VHT_MU
:
1862 case IWL_RX_PHY_INFO_TYPE_HE_TB_EXT
:
1863 case IWL_RX_PHY_INFO_TYPE_HE_SU
:
1864 case IWL_RX_PHY_INFO_TYPE_HE_MU
:
1865 case IWL_RX_PHY_INFO_TYPE_HE_MU_EXT
:
1866 case IWL_RX_PHY_INFO_TYPE_HE_TB
:
1867 case IWL_RX_PHY_INFO_TYPE_EHT_MU
:
1868 case IWL_RX_PHY_INFO_TYPE_EHT_TB
:
1869 case IWL_RX_PHY_INFO_TYPE_EHT_MU_EXT
:
1870 case IWL_RX_PHY_INFO_TYPE_EHT_TB_EXT
:
1871 lsig
= skb_put(skb
, sizeof(*lsig
));
1872 lsig
->data1
= cpu_to_le16(IEEE80211_RADIOTAP_LSIG_DATA1_LENGTH_KNOWN
);
1873 lsig
->data2
= le16_encode_bits(le32_get_bits(phy_data
->d1
,
1874 IWL_RX_PHY_DATA1_LSIG_LEN_MASK
),
1875 IEEE80211_RADIOTAP_LSIG_DATA2_LENGTH
);
1876 rx_status
->flag
|= RX_FLAG_RADIOTAP_LSIG
;
1883 struct iwl_rx_sta_csa
{
1884 bool all_sta_unblocked
;
1885 struct ieee80211_vif
*vif
;
1888 static void iwl_mvm_rx_get_sta_block_tx(void *data
, struct ieee80211_sta
*sta
)
1890 struct iwl_mvm_sta
*mvmsta
= iwl_mvm_sta_from_mac80211(sta
);
1891 struct iwl_rx_sta_csa
*rx_sta_csa
= data
;
1893 if (mvmsta
->vif
!= rx_sta_csa
->vif
)
1896 if (mvmsta
->disable_tx
)
1897 rx_sta_csa
->all_sta_unblocked
= false;
1901 * Note: requires also rx_status->band to be prefilled, as well
1902 * as phy_data (apart from phy_data->info_type)
1904 static void iwl_mvm_rx_fill_status(struct iwl_mvm
*mvm
,
1905 struct sk_buff
*skb
,
1906 struct iwl_mvm_rx_phy_data
*phy_data
,
1909 struct ieee80211_rx_status
*rx_status
= IEEE80211_SKB_RXCB(skb
);
1910 u32 rate_n_flags
= phy_data
->rate_n_flags
;
1911 u8 stbc
= u32_get_bits(rate_n_flags
, RATE_MCS_STBC_MSK
);
1912 u32 format
= rate_n_flags
& RATE_MCS_MOD_TYPE_MSK
;
1915 phy_data
->info_type
= IWL_RX_PHY_INFO_TYPE_NONE
;
1917 if (phy_data
->phy_info
& IWL_RX_MPDU_PHY_TSF_OVERLOAD
)
1918 phy_data
->info_type
=
1919 le32_get_bits(phy_data
->d1
,
1920 IWL_RX_PHY_DATA1_INFO_TYPE_MASK
);
1922 /* This may be overridden by iwl_mvm_rx_he() to HE_RU */
1923 switch (rate_n_flags
& RATE_MCS_CHAN_WIDTH_MSK
) {
1924 case RATE_MCS_CHAN_WIDTH_20
:
1926 case RATE_MCS_CHAN_WIDTH_40
:
1927 rx_status
->bw
= RATE_INFO_BW_40
;
1929 case RATE_MCS_CHAN_WIDTH_80
:
1930 rx_status
->bw
= RATE_INFO_BW_80
;
1932 case RATE_MCS_CHAN_WIDTH_160
:
1933 rx_status
->bw
= RATE_INFO_BW_160
;
1935 case RATE_MCS_CHAN_WIDTH_320
:
1936 rx_status
->bw
= RATE_INFO_BW_320
;
1940 /* must be before L-SIG data */
1941 if (format
== RATE_MCS_HE_MSK
)
1942 iwl_mvm_rx_he(mvm
, skb
, phy_data
, queue
);
1944 iwl_mvm_decode_lsig(skb
, phy_data
);
1946 rx_status
->device_timestamp
= phy_data
->gp2_on_air_rise
;
1948 if (mvm
->rx_ts_ptp
&& mvm
->monitor_on
) {
1950 iwl_mvm_ptp_get_adj_time(mvm
, phy_data
->gp2_on_air_rise
* NSEC_PER_USEC
);
1952 rx_status
->mactime
= div64_u64(adj_time
, NSEC_PER_USEC
);
1953 rx_status
->flag
|= RX_FLAG_MACTIME_IS_RTAP_TS64
;
1954 rx_status
->flag
&= ~RX_FLAG_MACTIME
;
1957 rx_status
->freq
= ieee80211_channel_to_frequency(phy_data
->channel
,
1959 iwl_mvm_get_signal_strength(mvm
, rx_status
, rate_n_flags
,
1960 phy_data
->energy_a
, phy_data
->energy_b
);
1962 /* using TLV format and must be after all fixed len fields */
1963 if (format
== RATE_MCS_EHT_MSK
)
1964 iwl_mvm_rx_eht(mvm
, skb
, phy_data
, queue
);
1966 if (unlikely(mvm
->monitor_on
))
1967 iwl_mvm_add_rtap_sniffer_config(mvm
, skb
);
1969 is_sgi
= format
== RATE_MCS_HE_MSK
?
1970 iwl_he_is_sgi(rate_n_flags
) :
1971 rate_n_flags
& RATE_MCS_SGI_MSK
;
1973 if (!(format
== RATE_MCS_CCK_MSK
) && is_sgi
)
1974 rx_status
->enc_flags
|= RX_ENC_FLAG_SHORT_GI
;
1976 if (rate_n_flags
& RATE_MCS_LDPC_MSK
)
1977 rx_status
->enc_flags
|= RX_ENC_FLAG_LDPC
;
1980 case RATE_MCS_VHT_MSK
:
1981 rx_status
->encoding
= RX_ENC_VHT
;
1983 case RATE_MCS_HE_MSK
:
1984 rx_status
->encoding
= RX_ENC_HE
;
1986 !!(rate_n_flags
& RATE_HE_DUAL_CARRIER_MODE_MSK
);
1988 case RATE_MCS_EHT_MSK
:
1989 rx_status
->encoding
= RX_ENC_EHT
;
1994 case RATE_MCS_HT_MSK
:
1995 rx_status
->encoding
= RX_ENC_HT
;
1996 rx_status
->rate_idx
= RATE_HT_MCS_INDEX(rate_n_flags
);
1997 rx_status
->enc_flags
|= stbc
<< RX_ENC_FLAG_STBC_SHIFT
;
1999 case RATE_MCS_VHT_MSK
:
2000 case RATE_MCS_HE_MSK
:
2001 case RATE_MCS_EHT_MSK
:
2003 u32_get_bits(rate_n_flags
, RATE_MCS_NSS_MSK
) + 1;
2004 rx_status
->rate_idx
= rate_n_flags
& RATE_MCS_CODE_MSK
;
2005 rx_status
->enc_flags
|= stbc
<< RX_ENC_FLAG_STBC_SHIFT
;
2008 int rate
= iwl_mvm_legacy_hw_idx_to_mac80211_idx(rate_n_flags
,
2011 rx_status
->rate_idx
= rate
;
2013 if ((rate
< 0 || rate
> 0xFF)) {
2014 rx_status
->rate_idx
= 0;
2015 if (net_ratelimit())
2016 IWL_ERR(mvm
, "Invalid rate flags 0x%x, band %d,\n",
2017 rate_n_flags
, rx_status
->band
);
2025 void iwl_mvm_rx_mpdu_mq(struct iwl_mvm
*mvm
, struct napi_struct
*napi
,
2026 struct iwl_rx_cmd_buffer
*rxb
, int queue
)
2028 struct ieee80211_rx_status
*rx_status
;
2029 struct iwl_rx_packet
*pkt
= rxb_addr(rxb
);
2030 struct iwl_rx_mpdu_desc
*desc
= (void *)pkt
->data
;
2031 struct ieee80211_hdr
*hdr
;
2033 u32 pkt_len
= iwl_rx_packet_payload_len(pkt
);
2034 struct ieee80211_sta
*sta
= NULL
;
2035 struct sk_buff
*skb
;
2037 u8 sta_id
= le32_get_bits(desc
->status
, IWL_RX_MPDU_STATUS_STA_ID
);
2039 struct iwl_mvm_rx_phy_data phy_data
= {};
2042 if (unlikely(test_bit(IWL_MVM_STATUS_IN_HW_RESTART
, &mvm
->status
)))
2045 if (mvm
->trans
->trans_cfg
->device_family
>= IWL_DEVICE_FAMILY_AX210
)
2046 desc_size
= sizeof(*desc
);
2048 desc_size
= IWL_RX_DESC_SIZE_V1
;
2050 if (unlikely(pkt_len
< desc_size
)) {
2051 IWL_DEBUG_DROP(mvm
, "Bad REPLY_RX_MPDU_CMD size\n");
2055 if (mvm
->trans
->trans_cfg
->device_family
>= IWL_DEVICE_FAMILY_AX210
) {
2056 phy_data
.rate_n_flags
= le32_to_cpu(desc
->v3
.rate_n_flags
);
2057 phy_data
.channel
= desc
->v3
.channel
;
2058 phy_data
.gp2_on_air_rise
= le32_to_cpu(desc
->v3
.gp2_on_air_rise
);
2059 phy_data
.energy_a
= desc
->v3
.energy_a
;
2060 phy_data
.energy_b
= desc
->v3
.energy_b
;
2062 phy_data
.d0
= desc
->v3
.phy_data0
;
2063 phy_data
.d1
= desc
->v3
.phy_data1
;
2064 phy_data
.d2
= desc
->v3
.phy_data2
;
2065 phy_data
.d3
= desc
->v3
.phy_data3
;
2066 phy_data
.eht_d4
= desc
->phy_eht_data4
;
2067 phy_data
.d5
= desc
->v3
.phy_data5
;
2069 phy_data
.rate_n_flags
= le32_to_cpu(desc
->v1
.rate_n_flags
);
2070 phy_data
.channel
= desc
->v1
.channel
;
2071 phy_data
.gp2_on_air_rise
= le32_to_cpu(desc
->v1
.gp2_on_air_rise
);
2072 phy_data
.energy_a
= desc
->v1
.energy_a
;
2073 phy_data
.energy_b
= desc
->v1
.energy_b
;
2075 phy_data
.d0
= desc
->v1
.phy_data0
;
2076 phy_data
.d1
= desc
->v1
.phy_data1
;
2077 phy_data
.d2
= desc
->v1
.phy_data2
;
2078 phy_data
.d3
= desc
->v1
.phy_data3
;
2081 if (iwl_fw_lookup_notif_ver(mvm
->fw
, LEGACY_GROUP
,
2082 REPLY_RX_MPDU_CMD
, 0) < 4) {
2083 phy_data
.rate_n_flags
= iwl_new_rate_from_v1(phy_data
.rate_n_flags
);
2084 IWL_DEBUG_DROP(mvm
, "Got old format rate, converting. New rate: 0x%x\n",
2085 phy_data
.rate_n_flags
);
2088 format
= phy_data
.rate_n_flags
& RATE_MCS_MOD_TYPE_MSK
;
2090 len
= le16_to_cpu(desc
->mpdu_len
);
2092 if (unlikely(len
+ desc_size
> pkt_len
)) {
2093 IWL_DEBUG_DROP(mvm
, "FW lied about packet len\n");
2097 phy_data
.with_data
= true;
2098 phy_data
.phy_info
= le16_to_cpu(desc
->phy_info
);
2099 phy_data
.d4
= desc
->phy_data4
;
2101 hdr
= (void *)(pkt
->data
+ desc_size
);
2102 /* Dont use dev_alloc_skb(), we'll have enough headroom once
2103 * ieee80211_hdr pulled.
2105 skb
= alloc_skb(128, GFP_ATOMIC
);
2107 IWL_ERR(mvm
, "alloc_skb failed\n");
2111 if (desc
->mac_flags2
& IWL_RX_MPDU_MFLG2_PAD
) {
2113 * If the device inserted padding it means that (it thought)
2114 * the 802.11 header wasn't a multiple of 4 bytes long. In
2115 * this case, reserve two bytes at the start of the SKB to
2116 * align the payload properly in case we end up copying it.
2118 skb_reserve(skb
, 2);
2121 rx_status
= IEEE80211_SKB_RXCB(skb
);
2124 * Keep packets with CRC errors (and with overrun) for monitor mode
2125 * (otherwise the firmware discards them) but mark them as bad.
2127 if (!(desc
->status
& cpu_to_le32(IWL_RX_MPDU_STATUS_CRC_OK
)) ||
2128 !(desc
->status
& cpu_to_le32(IWL_RX_MPDU_STATUS_OVERRUN_OK
))) {
2129 IWL_DEBUG_RX(mvm
, "Bad CRC or FIFO: 0x%08X.\n",
2130 le32_to_cpu(desc
->status
));
2131 rx_status
->flag
|= RX_FLAG_FAILED_FCS_CRC
;
2134 /* set the preamble flag if appropriate */
2135 if (format
== RATE_MCS_CCK_MSK
&&
2136 phy_data
.phy_info
& IWL_RX_MPDU_PHY_SHORT_PREAMBLE
)
2137 rx_status
->enc_flags
|= RX_ENC_FLAG_SHORTPRE
;
2139 if (likely(!(phy_data
.phy_info
& IWL_RX_MPDU_PHY_TSF_OVERLOAD
))) {
2140 u64 tsf_on_air_rise
;
2142 if (mvm
->trans
->trans_cfg
->device_family
>=
2143 IWL_DEVICE_FAMILY_AX210
)
2144 tsf_on_air_rise
= le64_to_cpu(desc
->v3
.tsf_on_air_rise
);
2146 tsf_on_air_rise
= le64_to_cpu(desc
->v1
.tsf_on_air_rise
);
2148 rx_status
->mactime
= tsf_on_air_rise
;
2149 /* TSF as indicated by the firmware is at INA time */
2150 rx_status
->flag
|= RX_FLAG_MACTIME_PLCP_START
;
2153 if (iwl_mvm_is_band_in_rx_supported(mvm
)) {
2154 u8 band
= BAND_IN_RX_STATUS(desc
->mac_phy_idx
);
2156 rx_status
->band
= iwl_mvm_nl80211_band_from_phy(band
);
2158 rx_status
->band
= phy_data
.channel
> 14 ? NL80211_BAND_5GHZ
:
2162 /* update aggregation data for monitor sake on default queue */
2163 if (!queue
&& (phy_data
.phy_info
& IWL_RX_MPDU_PHY_AMPDU
)) {
2166 toggle_bit
= phy_data
.phy_info
& IWL_RX_MPDU_PHY_AMPDU_TOGGLE
;
2167 rx_status
->flag
|= RX_FLAG_AMPDU_DETAILS
;
2169 * Toggle is switched whenever new aggregation starts. Make
2170 * sure ampdu_reference is never 0 so we can later use it to
2171 * see if the frame was really part of an A-MPDU or not.
2173 if (toggle_bit
!= mvm
->ampdu_toggle
) {
2175 if (mvm
->ampdu_ref
== 0)
2177 mvm
->ampdu_toggle
= toggle_bit
;
2178 phy_data
.first_subframe
= true;
2180 rx_status
->ampdu_reference
= mvm
->ampdu_ref
;
2185 if (desc
->status
& cpu_to_le32(IWL_RX_MPDU_STATUS_SRC_STA_FOUND
)) {
2186 if (!WARN_ON_ONCE(sta_id
>= mvm
->fw
->ucode_capa
.num_stations
)) {
2187 struct ieee80211_link_sta
*link_sta
;
2189 sta
= rcu_dereference(mvm
->fw_id_to_mac_id
[sta_id
]);
2192 link_sta
= rcu_dereference(mvm
->fw_id_to_link_sta
[sta_id
]);
2194 if (sta
&& sta
->valid_links
&& link_sta
) {
2195 rx_status
->link_valid
= 1;
2196 rx_status
->link_id
= link_sta
->link_id
;
2199 } else if (!is_multicast_ether_addr(hdr
->addr2
)) {
2201 * This is fine since we prevent two stations with the same
2202 * address from being added.
2204 sta
= ieee80211_find_sta_by_ifaddr(mvm
->hw
, hdr
->addr2
, NULL
);
2207 if (iwl_mvm_rx_crypto(mvm
, sta
, hdr
, rx_status
, phy_data
.phy_info
, desc
,
2208 le32_to_cpu(pkt
->len_n_flags
), queue
,
2214 iwl_mvm_rx_fill_status(mvm
, skb
, &phy_data
, queue
);
2217 struct iwl_mvm_sta
*mvmsta
= iwl_mvm_sta_from_mac80211(sta
);
2218 struct ieee80211_vif
*tx_blocked_vif
=
2219 rcu_dereference(mvm
->csa_tx_blocked_vif
);
2220 u8 baid
= (u8
)((le32_to_cpu(desc
->reorder_data
) &
2221 IWL_RX_MPDU_REORDER_BAID_MASK
) >>
2222 IWL_RX_MPDU_REORDER_BAID_SHIFT
);
2223 struct iwl_fw_dbg_trigger_tlv
*trig
;
2224 struct ieee80211_vif
*vif
= mvmsta
->vif
;
2226 if (!mvm
->tcm
.paused
&& len
>= sizeof(*hdr
) &&
2227 !is_multicast_ether_addr(hdr
->addr1
) &&
2228 ieee80211_is_data(hdr
->frame_control
) &&
2229 time_after(jiffies
, mvm
->tcm
.ts
+ MVM_TCM_PERIOD
))
2230 schedule_delayed_work(&mvm
->tcm
.work
, 0);
2233 * We have tx blocked stations (with CS bit). If we heard
2234 * frames from a blocked station on a new channel we can
2237 if (unlikely(tx_blocked_vif
) && tx_blocked_vif
== vif
) {
2238 struct iwl_mvm_vif
*mvmvif
=
2239 iwl_mvm_vif_from_mac80211(tx_blocked_vif
);
2240 struct iwl_rx_sta_csa rx_sta_csa
= {
2241 .all_sta_unblocked
= true,
2242 .vif
= tx_blocked_vif
,
2245 if (mvmvif
->csa_target_freq
== rx_status
->freq
)
2246 iwl_mvm_sta_modify_disable_tx_ap(mvm
, sta
,
2248 ieee80211_iterate_stations_atomic(mvm
->hw
,
2249 iwl_mvm_rx_get_sta_block_tx
,
2252 if (rx_sta_csa
.all_sta_unblocked
) {
2253 RCU_INIT_POINTER(mvm
->csa_tx_blocked_vif
, NULL
);
2254 /* Unblock BCAST / MCAST station */
2255 iwl_mvm_modify_all_sta_disable_tx(mvm
, mvmvif
, false);
2256 cancel_delayed_work(&mvm
->cs_tx_unblock_dwork
);
2260 rs_update_last_rssi(mvm
, mvmsta
, rx_status
);
2262 trig
= iwl_fw_dbg_trigger_on(&mvm
->fwrt
,
2263 ieee80211_vif_to_wdev(vif
),
2264 FW_DBG_TRIGGER_RSSI
);
2266 if (trig
&& ieee80211_is_beacon(hdr
->frame_control
)) {
2267 struct iwl_fw_dbg_trigger_low_rssi
*rssi_trig
;
2270 rssi_trig
= (void *)trig
->data
;
2271 rssi
= le32_to_cpu(rssi_trig
->rssi
);
2273 if (rx_status
->signal
< rssi
)
2274 iwl_fw_dbg_collect_trig(&mvm
->fwrt
, trig
,
2278 if (ieee80211_is_data(hdr
->frame_control
))
2279 iwl_mvm_rx_csum(mvm
, sta
, skb
, pkt
);
2281 if (iwl_mvm_is_dup(sta
, queue
, rx_status
, hdr
, desc
)) {
2282 IWL_DEBUG_DROP(mvm
, "Dropping duplicate packet 0x%x\n",
2283 le16_to_cpu(hdr
->seq_ctrl
));
2289 * Our hardware de-aggregates AMSDUs but copies the mac header
2290 * as it to the de-aggregated MPDUs. We need to turn off the
2291 * AMSDU bit in the QoS control ourselves.
2292 * In addition, HW reverses addr3 and addr4 - reverse it back.
2294 if ((desc
->mac_flags2
& IWL_RX_MPDU_MFLG2_AMSDU
) &&
2295 !WARN_ON(!ieee80211_is_data_qos(hdr
->frame_control
))) {
2296 u8
*qc
= ieee80211_get_qos_ctl(hdr
);
2298 *qc
&= ~IEEE80211_QOS_CTL_A_MSDU_PRESENT
;
2300 if (mvm
->trans
->trans_cfg
->device_family
==
2301 IWL_DEVICE_FAMILY_9000
) {
2302 iwl_mvm_flip_address(hdr
->addr3
);
2304 if (ieee80211_has_a4(hdr
->frame_control
))
2305 iwl_mvm_flip_address(hdr
->addr4
);
2308 if (baid
!= IWL_RX_REORDER_DATA_INVALID_BAID
) {
2309 u32 reorder_data
= le32_to_cpu(desc
->reorder_data
);
2311 iwl_mvm_agg_rx_received(mvm
, reorder_data
, baid
);
2314 if (ieee80211_is_data(hdr
->frame_control
)) {
2315 u8 sub_frame_idx
= desc
->amsdu_info
&
2316 IWL_RX_MPDU_AMSDU_SUBFRAME_IDX_MASK
;
2318 /* 0 means not an A-MSDU, and 1 means a new A-MSDU */
2319 if (!sub_frame_idx
|| sub_frame_idx
== 1)
2320 iwl_mvm_count_mpdu(mvmsta
, sta_id
, 1, false,
2325 /* management stuff on default queue */
2327 if (unlikely((ieee80211_is_beacon(hdr
->frame_control
) ||
2328 ieee80211_is_probe_resp(hdr
->frame_control
)) &&
2329 mvm
->sched_scan_pass_all
==
2330 SCHED_SCAN_PASS_ALL_ENABLED
))
2331 mvm
->sched_scan_pass_all
= SCHED_SCAN_PASS_ALL_FOUND
;
2333 if (unlikely(ieee80211_is_beacon(hdr
->frame_control
) ||
2334 ieee80211_is_probe_resp(hdr
->frame_control
)))
2335 rx_status
->boottime_ns
= ktime_get_boottime_ns();
2338 if (iwl_mvm_create_skb(mvm
, skb
, hdr
, len
, crypt_len
, rxb
)) {
2343 if (!iwl_mvm_reorder(mvm
, napi
, queue
, sta
, skb
, desc
) &&
2344 likely(!iwl_mvm_time_sync_frame(mvm
, skb
, hdr
->addr2
)) &&
2345 likely(!iwl_mvm_mei_filter_scan(mvm
, skb
))) {
2346 if (mvm
->trans
->trans_cfg
->device_family
== IWL_DEVICE_FAMILY_9000
&&
2347 (desc
->mac_flags2
& IWL_RX_MPDU_MFLG2_AMSDU
) &&
2348 !(desc
->amsdu_info
& IWL_RX_MPDU_AMSDU_LAST_SUBFRAME
))
2349 rx_status
->flag
|= RX_FLAG_AMSDU_MORE
;
2351 iwl_mvm_pass_packet_to_mac80211(mvm
, napi
, skb
, queue
, sta
);
2357 void iwl_mvm_rx_monitor_no_data(struct iwl_mvm
*mvm
, struct napi_struct
*napi
,
2358 struct iwl_rx_cmd_buffer
*rxb
, int queue
)
2360 struct ieee80211_rx_status
*rx_status
;
2361 struct iwl_rx_packet
*pkt
= rxb_addr(rxb
);
2362 struct iwl_rx_no_data_ver_3
*desc
= (void *)pkt
->data
;
2364 struct ieee80211_sta
*sta
= NULL
;
2365 struct sk_buff
*skb
;
2366 struct iwl_mvm_rx_phy_data phy_data
;
2369 if (unlikely(test_bit(IWL_MVM_STATUS_IN_HW_RESTART
, &mvm
->status
)))
2372 if (unlikely(iwl_rx_packet_payload_len(pkt
) < sizeof(struct iwl_rx_no_data
)))
2375 rssi
= le32_to_cpu(desc
->rssi
);
2376 phy_data
.d0
= desc
->phy_info
[0];
2377 phy_data
.d1
= desc
->phy_info
[1];
2378 phy_data
.phy_info
= IWL_RX_MPDU_PHY_TSF_OVERLOAD
;
2379 phy_data
.gp2_on_air_rise
= le32_to_cpu(desc
->on_air_rise_time
);
2380 phy_data
.rate_n_flags
= le32_to_cpu(desc
->rate
);
2381 phy_data
.energy_a
= u32_get_bits(rssi
, RX_NO_DATA_CHAIN_A_MSK
);
2382 phy_data
.energy_b
= u32_get_bits(rssi
, RX_NO_DATA_CHAIN_B_MSK
);
2383 phy_data
.channel
= u32_get_bits(rssi
, RX_NO_DATA_CHANNEL_MSK
);
2384 phy_data
.with_data
= false;
2385 phy_data
.rx_vec
[0] = desc
->rx_vec
[0];
2386 phy_data
.rx_vec
[1] = desc
->rx_vec
[1];
2388 if (iwl_fw_lookup_notif_ver(mvm
->fw
, DATA_PATH_GROUP
,
2389 RX_NO_DATA_NOTIF
, 0) < 2) {
2390 IWL_DEBUG_DROP(mvm
, "Got an old rate format. Old rate: 0x%x\n",
2391 phy_data
.rate_n_flags
);
2392 phy_data
.rate_n_flags
= iwl_new_rate_from_v1(phy_data
.rate_n_flags
);
2393 IWL_DEBUG_DROP(mvm
, " Rate after conversion to the new format: 0x%x\n",
2394 phy_data
.rate_n_flags
);
2397 format
= phy_data
.rate_n_flags
& RATE_MCS_MOD_TYPE_MSK
;
2399 if (iwl_fw_lookup_notif_ver(mvm
->fw
, DATA_PATH_GROUP
,
2400 RX_NO_DATA_NOTIF
, 0) >= 3) {
2401 if (unlikely(iwl_rx_packet_payload_len(pkt
) <
2402 sizeof(struct iwl_rx_no_data_ver_3
)))
2403 /* invalid len for ver 3 */
2405 phy_data
.rx_vec
[2] = desc
->rx_vec
[2];
2406 phy_data
.rx_vec
[3] = desc
->rx_vec
[3];
2408 if (format
== RATE_MCS_EHT_MSK
)
2409 /* no support for EHT before version 3 API */
2413 /* Dont use dev_alloc_skb(), we'll have enough headroom once
2414 * ieee80211_hdr pulled.
2416 skb
= alloc_skb(128, GFP_ATOMIC
);
2418 IWL_ERR(mvm
, "alloc_skb failed\n");
2422 rx_status
= IEEE80211_SKB_RXCB(skb
);
2425 rx_status
->flag
|= RX_FLAG_NO_PSDU
;
2427 /* mark as failed PLCP on any errors to skip checks in mac80211 */
2428 if (le32_get_bits(desc
->info
, RX_NO_DATA_INFO_ERR_MSK
) !=
2429 RX_NO_DATA_INFO_ERR_NONE
)
2430 rx_status
->flag
|= RX_FLAG_FAILED_PLCP_CRC
;
2432 switch (le32_get_bits(desc
->info
, RX_NO_DATA_INFO_TYPE_MSK
)) {
2433 case RX_NO_DATA_INFO_TYPE_NDP
:
2434 rx_status
->zero_length_psdu_type
=
2435 IEEE80211_RADIOTAP_ZERO_LEN_PSDU_SOUNDING
;
2437 case RX_NO_DATA_INFO_TYPE_MU_UNMATCHED
:
2438 case RX_NO_DATA_INFO_TYPE_TB_UNMATCHED
:
2439 rx_status
->zero_length_psdu_type
=
2440 IEEE80211_RADIOTAP_ZERO_LEN_PSDU_NOT_CAPTURED
;
2443 rx_status
->zero_length_psdu_type
=
2444 IEEE80211_RADIOTAP_ZERO_LEN_PSDU_VENDOR
;
2448 rx_status
->band
= phy_data
.channel
> 14 ? NL80211_BAND_5GHZ
:
2451 iwl_mvm_rx_fill_status(mvm
, skb
, &phy_data
, queue
);
2453 /* no more radio tap info should be put after this point.
2455 * We mark it as mac header, for upper layers to know where
2456 * all radio tap header ends.
2458 * Since data doesn't move data while putting data on skb and that is
2459 * the only way we use, data + len is the next place that hdr would be put
2461 skb_set_mac_header(skb
, skb
->len
);
2464 * Override the nss from the rx_vec since the rate_n_flags has
2465 * only 2 bits for the nss which gives a max of 4 ss but there
2466 * may be up to 8 spatial streams.
2469 case RATE_MCS_VHT_MSK
:
2471 le32_get_bits(desc
->rx_vec
[0],
2472 RX_NO_DATA_RX_VEC0_VHT_NSTS_MSK
) + 1;
2474 case RATE_MCS_HE_MSK
:
2476 le32_get_bits(desc
->rx_vec
[0],
2477 RX_NO_DATA_RX_VEC0_HE_NSTS_MSK
) + 1;
2479 case RATE_MCS_EHT_MSK
:
2481 le32_get_bits(desc
->rx_vec
[2],
2482 RX_NO_DATA_RX_VEC2_EHT_NSTS_MSK
) + 1;
2486 ieee80211_rx_napi(mvm
->hw
, sta
, skb
, napi
);
2490 void iwl_mvm_rx_frame_release(struct iwl_mvm
*mvm
, struct napi_struct
*napi
,
2491 struct iwl_rx_cmd_buffer
*rxb
, int queue
)
2493 struct iwl_rx_packet
*pkt
= rxb_addr(rxb
);
2494 struct iwl_frame_release
*release
= (void *)pkt
->data
;
2496 if (unlikely(iwl_rx_packet_payload_len(pkt
) < sizeof(*release
)))
2499 iwl_mvm_release_frames_from_notif(mvm
, napi
, release
->baid
,
2500 le16_to_cpu(release
->nssn
),
2504 void iwl_mvm_rx_bar_frame_release(struct iwl_mvm
*mvm
, struct napi_struct
*napi
,
2505 struct iwl_rx_cmd_buffer
*rxb
, int queue
)
2507 struct iwl_rx_packet
*pkt
= rxb_addr(rxb
);
2508 struct iwl_bar_frame_release
*release
= (void *)pkt
->data
;
2509 unsigned int baid
= le32_get_bits(release
->ba_info
,
2510 IWL_BAR_FRAME_RELEASE_BAID_MASK
);
2511 unsigned int nssn
= le32_get_bits(release
->ba_info
,
2512 IWL_BAR_FRAME_RELEASE_NSSN_MASK
);
2513 unsigned int sta_id
= le32_get_bits(release
->sta_tid
,
2514 IWL_BAR_FRAME_RELEASE_STA_MASK
);
2515 unsigned int tid
= le32_get_bits(release
->sta_tid
,
2516 IWL_BAR_FRAME_RELEASE_TID_MASK
);
2517 struct iwl_mvm_baid_data
*baid_data
;
2519 if (unlikely(iwl_rx_packet_payload_len(pkt
) < sizeof(*release
)))
2522 if (WARN_ON_ONCE(baid
== IWL_RX_REORDER_DATA_INVALID_BAID
||
2523 baid
>= ARRAY_SIZE(mvm
->baid_map
)))
2527 baid_data
= rcu_dereference(mvm
->baid_map
[baid
]);
2530 "Got valid BAID %d but not allocated, invalid BAR release!\n",
2535 if (WARN(tid
!= baid_data
->tid
|| sta_id
> IWL_STATION_COUNT_MAX
||
2536 !(baid_data
->sta_mask
& BIT(sta_id
)),
2537 "baid 0x%x is mapped to sta_mask:0x%x tid:%d, but BAR release received for sta:%d tid:%d\n",
2538 baid
, baid_data
->sta_mask
, baid_data
->tid
, sta_id
,
2542 IWL_DEBUG_DROP(mvm
, "Received a BAR, expect packet loss: nssn %d\n",
2545 iwl_mvm_release_frames_from_notif(mvm
, napi
, baid
, nssn
, queue
);