Lines Matching +full:mic +full:- +full:pos
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright 2002-2005, Instant802 Networks, Inc.
4 * Copyright 2005-2006, Devicescape Software, Inc.
5 * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz>
6 * Copyright 2007-2010 Johannes Berg <johannes@sipsolutions.net>
7 * Copyright 2013-2014 Intel Mobile Communications GmbH
8 * Copyright(c) 2015 - 2017 Intel Deutschland GmbH
9 * Copyright (C) 2018-2024 Intel Corporation
28 #include "driver-ops.h"
53 __pskb_trim(skb, skb->len - present_fcs_len); in ieee80211_clean_skb()
57 * info in skb->data. in ieee80211_clean_skb()
59 status->flag &= ~(RX_FLAG_RADIOTAP_TLV_AT_END | in ieee80211_clean_skb()
64 hdr = (void *)skb->data; in ieee80211_clean_skb()
65 fc = hdr->frame_control; in ieee80211_clean_skb()
68 * Remove the HT-Control field (if present) on management in ieee80211_clean_skb()
78 hdr->frame_control &= ~cpu_to_le16(IEEE80211_FCTL_ORDER); in ieee80211_clean_skb()
85 memmove(skb->data + IEEE80211_HT_CTL_LEN, skb->data, in ieee80211_clean_skb()
86 hdrlen - IEEE80211_HT_CTL_LEN); in ieee80211_clean_skb()
98 hdr = (void *)(skb->data + rtap_space); in should_drop_frame()
100 if (status->flag & (RX_FLAG_FAILED_FCS_CRC | in should_drop_frame()
106 if (unlikely(skb->len < 16 + present_fcs_len + rtap_space)) in should_drop_frame()
109 if (ieee80211_is_ctl(hdr->frame_control) && in should_drop_frame()
110 !ieee80211_is_pspoll(hdr->frame_control) && in should_drop_frame()
111 !ieee80211_is_back_req(hdr->frame_control)) in should_drop_frame()
128 if (status->chains) in ieee80211_rx_radiotap_hdrlen()
129 len += 4 * hweight8(status->chains); in ieee80211_rx_radiotap_hdrlen()
135 if (ieee80211_hw_check(&local->hw, SIGNAL_DBM)) in ieee80211_rx_radiotap_hdrlen()
138 /* antenna field, if we don't have per-chain info */ in ieee80211_rx_radiotap_hdrlen()
139 if (!status->chains) in ieee80211_rx_radiotap_hdrlen()
145 if (status->encoding == RX_ENC_HT) /* HT info */ in ieee80211_rx_radiotap_hdrlen()
148 if (status->flag & RX_FLAG_AMPDU_DETAILS) { in ieee80211_rx_radiotap_hdrlen()
153 if (status->encoding == RX_ENC_VHT) { in ieee80211_rx_radiotap_hdrlen()
158 if (local->hw.radiotap_timestamp.units_pos >= 0) { in ieee80211_rx_radiotap_hdrlen()
163 if (status->encoding == RX_ENC_HE && in ieee80211_rx_radiotap_hdrlen()
164 status->flag & RX_FLAG_RADIOTAP_HE) { in ieee80211_rx_radiotap_hdrlen()
170 if (status->encoding == RX_ENC_HE && in ieee80211_rx_radiotap_hdrlen()
171 status->flag & RX_FLAG_RADIOTAP_HE_MU) { in ieee80211_rx_radiotap_hdrlen()
177 if (status->flag & RX_FLAG_NO_PSDU) in ieee80211_rx_radiotap_hdrlen()
180 if (status->flag & RX_FLAG_RADIOTAP_LSIG) { in ieee80211_rx_radiotap_hdrlen()
186 if (status->chains) { in ieee80211_rx_radiotap_hdrlen()
188 len += 2 * hweight8(status->chains); in ieee80211_rx_radiotap_hdrlen()
191 if (status->flag & RX_FLAG_RADIOTAP_TLV_AT_END) { in ieee80211_rx_radiotap_hdrlen()
195 * The position to look at depends on the existence (or non- in ieee80211_rx_radiotap_hdrlen()
198 if (status->flag & RX_FLAG_RADIOTAP_HE) in ieee80211_rx_radiotap_hdrlen()
201 if (status->flag & RX_FLAG_RADIOTAP_HE_MU) in ieee80211_rx_radiotap_hdrlen()
204 if (status->flag & RX_FLAG_RADIOTAP_LSIG) in ieee80211_rx_radiotap_hdrlen()
212 len += skb_mac_header(skb) - &skb->data[tlv_offset]; in ieee80211_rx_radiotap_hdrlen()
226 status->link_valid = 1; in __ieee80211_queue_skb_to_iface()
227 status->link_id = link_id; in __ieee80211_queue_skb_to_iface()
229 status->link_valid = 0; in __ieee80211_queue_skb_to_iface()
232 skb_queue_tail(&sdata->skb_queue, skb); in __ieee80211_queue_skb_to_iface()
233 wiphy_work_queue(sdata->local->hw.wiphy, &sdata->work); in __ieee80211_queue_skb_to_iface()
235 sta->deflink.rx_stats.packets++; in __ieee80211_queue_skb_to_iface()
243 skb->protocol = 0; in ieee80211_queue_skb_to_iface()
262 if (skb->len < rtap_space + sizeof(action) + in ieee80211_handle_mu_mimo_mon()
266 if (!is_valid_ether_addr(sdata->u.mntr.mu_follow_addr)) in ieee80211_handle_mu_mimo_mon()
280 if (!ether_addr_equal(action.hdr.addr1, sdata->u.mntr.mu_follow_addr)) in ieee80211_handle_mu_mimo_mon()
287 ieee80211_queue_skb_to_iface(sdata, -1, NULL, skb); in ieee80211_handle_mu_mimo_mon()
291 * ieee80211_add_rx_radiotap_header - add radiotap header
303 unsigned char *pos; in ieee80211_add_rx_radiotap_header() local
310 unsigned long chains = status->chains; in ieee80211_add_rx_radiotap_header()
315 if (status->flag & RX_FLAG_RADIOTAP_HE) { in ieee80211_add_rx_radiotap_header()
316 he = *(struct ieee80211_radiotap_he *)skb->data; in ieee80211_add_rx_radiotap_header()
318 WARN_ON_ONCE(status->encoding != RX_ENC_HE); in ieee80211_add_rx_radiotap_header()
321 if (status->flag & RX_FLAG_RADIOTAP_HE_MU) { in ieee80211_add_rx_radiotap_header()
322 he_mu = *(struct ieee80211_radiotap_he_mu *)skb->data; in ieee80211_add_rx_radiotap_header()
326 if (status->flag & RX_FLAG_RADIOTAP_LSIG) { in ieee80211_add_rx_radiotap_header()
327 lsig = *(struct ieee80211_radiotap_lsig *)skb->data; in ieee80211_add_rx_radiotap_header()
331 if (status->flag & RX_FLAG_RADIOTAP_TLV_AT_END) { in ieee80211_add_rx_radiotap_header()
333 tlvs_len = skb_mac_header(skb) - skb->data; in ieee80211_add_rx_radiotap_header()
336 mpdulen = skb->len; in ieee80211_add_rx_radiotap_header()
337 if (!(has_fcs && ieee80211_hw_check(&local->hw, RX_INCLUDES_FCS))) in ieee80211_add_rx_radiotap_header()
340 rthdr = skb_push(skb, rtap_len - tlvs_len); in ieee80211_add_rx_radiotap_header()
341 memset(rthdr, 0, rtap_len - tlvs_len); in ieee80211_add_rx_radiotap_header()
342 it_present = &rthdr->it_present; in ieee80211_add_rx_radiotap_header()
345 rthdr->it_len = cpu_to_le16(rtap_len); in ieee80211_add_rx_radiotap_header()
350 if (!status->chains) in ieee80211_add_rx_radiotap_header()
363 if (status->flag & RX_FLAG_RADIOTAP_TLV_AT_END) in ieee80211_add_rx_radiotap_header()
369 * than via it_present otherwise later uses of pos will cause in ieee80211_add_rx_radiotap_header()
373 pos = (void *)&rthdr->it_optional[it_present + 1 - rthdr->it_optional]; in ieee80211_add_rx_radiotap_header()
380 while ((pos - (u8 *)rthdr) & 7) in ieee80211_add_rx_radiotap_header()
381 *pos++ = 0; in ieee80211_add_rx_radiotap_header()
385 pos); in ieee80211_add_rx_radiotap_header()
386 rthdr->it_present |= cpu_to_le32(BIT(IEEE80211_RADIOTAP_TSFT)); in ieee80211_add_rx_radiotap_header()
387 pos += 8; in ieee80211_add_rx_radiotap_header()
391 if (has_fcs && ieee80211_hw_check(&local->hw, RX_INCLUDES_FCS)) in ieee80211_add_rx_radiotap_header()
392 *pos |= IEEE80211_RADIOTAP_F_FCS; in ieee80211_add_rx_radiotap_header()
393 if (status->flag & (RX_FLAG_FAILED_FCS_CRC | RX_FLAG_FAILED_PLCP_CRC)) in ieee80211_add_rx_radiotap_header()
394 *pos |= IEEE80211_RADIOTAP_F_BADFCS; in ieee80211_add_rx_radiotap_header()
395 if (status->enc_flags & RX_ENC_FLAG_SHORTPRE) in ieee80211_add_rx_radiotap_header()
396 *pos |= IEEE80211_RADIOTAP_F_SHORTPRE; in ieee80211_add_rx_radiotap_header()
397 pos++; in ieee80211_add_rx_radiotap_header()
400 if (!rate || status->encoding != RX_ENC_LEGACY) { in ieee80211_add_rx_radiotap_header()
407 *pos = 0; in ieee80211_add_rx_radiotap_header()
410 rthdr->it_present |= cpu_to_le32(BIT(IEEE80211_RADIOTAP_RATE)); in ieee80211_add_rx_radiotap_header()
411 if (status->bw == RATE_INFO_BW_10) in ieee80211_add_rx_radiotap_header()
413 else if (status->bw == RATE_INFO_BW_5) in ieee80211_add_rx_radiotap_header()
415 *pos = DIV_ROUND_UP(rate->bitrate, 5 * (1 << shift)); in ieee80211_add_rx_radiotap_header()
417 pos++; in ieee80211_add_rx_radiotap_header()
421 put_unaligned_le16(status->freq, pos); in ieee80211_add_rx_radiotap_header()
422 pos += 2; in ieee80211_add_rx_radiotap_header()
423 if (status->bw == RATE_INFO_BW_10) in ieee80211_add_rx_radiotap_header()
425 else if (status->bw == RATE_INFO_BW_5) in ieee80211_add_rx_radiotap_header()
428 if (status->band == NL80211_BAND_5GHZ || in ieee80211_add_rx_radiotap_header()
429 status->band == NL80211_BAND_6GHZ) in ieee80211_add_rx_radiotap_header()
431 else if (status->encoding != RX_ENC_LEGACY) in ieee80211_add_rx_radiotap_header()
433 else if (rate && rate->flags & IEEE80211_RATE_ERP_G) in ieee80211_add_rx_radiotap_header()
439 put_unaligned_le16(channel_flags, pos); in ieee80211_add_rx_radiotap_header()
440 pos += 2; in ieee80211_add_rx_radiotap_header()
443 if (ieee80211_hw_check(&local->hw, SIGNAL_DBM) && in ieee80211_add_rx_radiotap_header()
444 !(status->flag & RX_FLAG_NO_SIGNAL_VAL)) { in ieee80211_add_rx_radiotap_header()
445 *pos = status->signal; in ieee80211_add_rx_radiotap_header()
446 rthdr->it_present |= in ieee80211_add_rx_radiotap_header()
448 pos++; in ieee80211_add_rx_radiotap_header()
453 if (!status->chains) { in ieee80211_add_rx_radiotap_header()
455 *pos = status->antenna; in ieee80211_add_rx_radiotap_header()
456 pos++; in ieee80211_add_rx_radiotap_header()
463 if ((pos - (u8 *)rthdr) & 1) in ieee80211_add_rx_radiotap_header()
464 *pos++ = 0; in ieee80211_add_rx_radiotap_header()
465 if (status->flag & RX_FLAG_FAILED_PLCP_CRC) in ieee80211_add_rx_radiotap_header()
467 put_unaligned_le16(rx_flags, pos); in ieee80211_add_rx_radiotap_header()
468 pos += 2; in ieee80211_add_rx_radiotap_header()
470 if (status->encoding == RX_ENC_HT) { in ieee80211_add_rx_radiotap_header()
473 rthdr->it_present |= cpu_to_le32(BIT(IEEE80211_RADIOTAP_MCS)); in ieee80211_add_rx_radiotap_header()
474 *pos = local->hw.radiotap_mcs_details; in ieee80211_add_rx_radiotap_header()
475 if (status->enc_flags & RX_ENC_FLAG_HT_GF) in ieee80211_add_rx_radiotap_header()
476 *pos |= IEEE80211_RADIOTAP_MCS_HAVE_FMT; in ieee80211_add_rx_radiotap_header()
477 if (status->enc_flags & RX_ENC_FLAG_LDPC) in ieee80211_add_rx_radiotap_header()
478 *pos |= IEEE80211_RADIOTAP_MCS_HAVE_FEC; in ieee80211_add_rx_radiotap_header()
479 pos++; in ieee80211_add_rx_radiotap_header()
480 *pos = 0; in ieee80211_add_rx_radiotap_header()
481 if (status->enc_flags & RX_ENC_FLAG_SHORT_GI) in ieee80211_add_rx_radiotap_header()
482 *pos |= IEEE80211_RADIOTAP_MCS_SGI; in ieee80211_add_rx_radiotap_header()
483 if (status->bw == RATE_INFO_BW_40) in ieee80211_add_rx_radiotap_header()
484 *pos |= IEEE80211_RADIOTAP_MCS_BW_40; in ieee80211_add_rx_radiotap_header()
485 if (status->enc_flags & RX_ENC_FLAG_HT_GF) in ieee80211_add_rx_radiotap_header()
486 *pos |= IEEE80211_RADIOTAP_MCS_FMT_GF; in ieee80211_add_rx_radiotap_header()
487 if (status->enc_flags & RX_ENC_FLAG_LDPC) in ieee80211_add_rx_radiotap_header()
488 *pos |= IEEE80211_RADIOTAP_MCS_FEC_LDPC; in ieee80211_add_rx_radiotap_header()
489 stbc = (status->enc_flags & RX_ENC_FLAG_STBC_MASK) >> RX_ENC_FLAG_STBC_SHIFT; in ieee80211_add_rx_radiotap_header()
490 *pos |= stbc << IEEE80211_RADIOTAP_MCS_STBC_SHIFT; in ieee80211_add_rx_radiotap_header()
491 pos++; in ieee80211_add_rx_radiotap_header()
492 *pos++ = status->rate_idx; in ieee80211_add_rx_radiotap_header()
495 if (status->flag & RX_FLAG_AMPDU_DETAILS) { in ieee80211_add_rx_radiotap_header()
499 while ((pos - (u8 *)rthdr) & 3) in ieee80211_add_rx_radiotap_header()
500 pos++; in ieee80211_add_rx_radiotap_header()
501 rthdr->it_present |= in ieee80211_add_rx_radiotap_header()
503 put_unaligned_le32(status->ampdu_reference, pos); in ieee80211_add_rx_radiotap_header()
504 pos += 4; in ieee80211_add_rx_radiotap_header()
505 if (status->flag & RX_FLAG_AMPDU_LAST_KNOWN) in ieee80211_add_rx_radiotap_header()
507 if (status->flag & RX_FLAG_AMPDU_IS_LAST) in ieee80211_add_rx_radiotap_header()
509 if (status->flag & RX_FLAG_AMPDU_DELIM_CRC_ERROR) in ieee80211_add_rx_radiotap_header()
511 if (status->flag & RX_FLAG_AMPDU_DELIM_CRC_KNOWN) in ieee80211_add_rx_radiotap_header()
513 if (status->flag & RX_FLAG_AMPDU_EOF_BIT_KNOWN) in ieee80211_add_rx_radiotap_header()
515 if (status->flag & RX_FLAG_AMPDU_EOF_BIT) in ieee80211_add_rx_radiotap_header()
517 put_unaligned_le16(flags, pos); in ieee80211_add_rx_radiotap_header()
518 pos += 2; in ieee80211_add_rx_radiotap_header()
519 if (status->flag & RX_FLAG_AMPDU_DELIM_CRC_KNOWN) in ieee80211_add_rx_radiotap_header()
520 *pos++ = status->ampdu_delimiter_crc; in ieee80211_add_rx_radiotap_header()
522 *pos++ = 0; in ieee80211_add_rx_radiotap_header()
523 *pos++ = 0; in ieee80211_add_rx_radiotap_header()
526 if (status->encoding == RX_ENC_VHT) { in ieee80211_add_rx_radiotap_header()
527 u16 known = local->hw.radiotap_vht_details; in ieee80211_add_rx_radiotap_header()
529 rthdr->it_present |= cpu_to_le32(BIT(IEEE80211_RADIOTAP_VHT)); in ieee80211_add_rx_radiotap_header()
530 put_unaligned_le16(known, pos); in ieee80211_add_rx_radiotap_header()
531 pos += 2; in ieee80211_add_rx_radiotap_header()
533 if (status->enc_flags & RX_ENC_FLAG_SHORT_GI) in ieee80211_add_rx_radiotap_header()
534 *pos |= IEEE80211_RADIOTAP_VHT_FLAG_SGI; in ieee80211_add_rx_radiotap_header()
536 if (status->enc_flags & RX_ENC_FLAG_STBC_MASK) in ieee80211_add_rx_radiotap_header()
537 *pos |= IEEE80211_RADIOTAP_VHT_FLAG_STBC; in ieee80211_add_rx_radiotap_header()
538 if (status->enc_flags & RX_ENC_FLAG_BF) in ieee80211_add_rx_radiotap_header()
539 *pos |= IEEE80211_RADIOTAP_VHT_FLAG_BEAMFORMED; in ieee80211_add_rx_radiotap_header()
540 pos++; in ieee80211_add_rx_radiotap_header()
542 switch (status->bw) { in ieee80211_add_rx_radiotap_header()
544 *pos++ = 4; in ieee80211_add_rx_radiotap_header()
547 *pos++ = 11; in ieee80211_add_rx_radiotap_header()
550 *pos++ = 1; in ieee80211_add_rx_radiotap_header()
553 *pos++ = 0; in ieee80211_add_rx_radiotap_header()
556 *pos = (status->rate_idx << 4) | status->nss; in ieee80211_add_rx_radiotap_header()
557 pos += 4; in ieee80211_add_rx_radiotap_header()
559 if (status->enc_flags & RX_ENC_FLAG_LDPC) in ieee80211_add_rx_radiotap_header()
560 *pos |= IEEE80211_RADIOTAP_CODING_LDPC_USER0; in ieee80211_add_rx_radiotap_header()
561 pos++; in ieee80211_add_rx_radiotap_header()
563 pos++; in ieee80211_add_rx_radiotap_header()
565 pos += 2; in ieee80211_add_rx_radiotap_header()
568 if (local->hw.radiotap_timestamp.units_pos >= 0) { in ieee80211_add_rx_radiotap_header()
573 rthdr->it_present |= in ieee80211_add_rx_radiotap_header()
577 while ((pos - (u8 *)rthdr) & 7) in ieee80211_add_rx_radiotap_header()
578 pos++; in ieee80211_add_rx_radiotap_header()
580 if (status->flag & RX_FLAG_MACTIME_IS_RTAP_TS64) { in ieee80211_add_rx_radiotap_header()
582 ts = status->mactime; in ieee80211_add_rx_radiotap_header()
585 ts = status->device_timestamp; in ieee80211_add_rx_radiotap_header()
588 put_unaligned_le64(ts, pos); in ieee80211_add_rx_radiotap_header()
589 pos += sizeof(u64); in ieee80211_add_rx_radiotap_header()
591 if (local->hw.radiotap_timestamp.accuracy >= 0) { in ieee80211_add_rx_radiotap_header()
592 accuracy = local->hw.radiotap_timestamp.accuracy; in ieee80211_add_rx_radiotap_header()
595 put_unaligned_le16(accuracy, pos); in ieee80211_add_rx_radiotap_header()
596 pos += sizeof(u16); in ieee80211_add_rx_radiotap_header()
598 *pos++ = local->hw.radiotap_timestamp.units_pos; in ieee80211_add_rx_radiotap_header()
599 *pos++ = flags; in ieee80211_add_rx_radiotap_header()
602 if (status->encoding == RX_ENC_HE && in ieee80211_add_rx_radiotap_header()
603 status->flag & RX_FLAG_RADIOTAP_HE) { in ieee80211_add_rx_radiotap_header()
606 if (status->enc_flags & RX_ENC_FLAG_STBC_MASK) { in ieee80211_add_rx_radiotap_header()
609 status->enc_flags)); in ieee80211_add_rx_radiotap_header()
612 he.data6 |= HE_PREP(DATA6_NSTS, status->nss); in ieee80211_add_rx_radiotap_header()
623 he.data3 |= HE_PREP(DATA3_DATA_MCS, status->rate_idx); in ieee80211_add_rx_radiotap_header()
624 he.data3 |= HE_PREP(DATA3_DATA_DCM, status->he_dcm); in ieee80211_add_rx_radiotap_header()
626 !!(status->enc_flags & RX_ENC_FLAG_LDPC)); in ieee80211_add_rx_radiotap_header()
628 he.data5 |= HE_PREP(DATA5_GI, status->he_gi); in ieee80211_add_rx_radiotap_header()
630 switch (status->bw) { in ieee80211_add_rx_radiotap_header()
661 status->he_ru + 4); in ieee80211_add_rx_radiotap_header()
664 WARN_ONCE(1, "Invalid SU BW %d\n", status->bw); in ieee80211_add_rx_radiotap_header()
668 while ((pos - (u8 *)rthdr) & 1) in ieee80211_add_rx_radiotap_header()
669 pos++; in ieee80211_add_rx_radiotap_header()
670 rthdr->it_present |= cpu_to_le32(BIT(IEEE80211_RADIOTAP_HE)); in ieee80211_add_rx_radiotap_header()
671 memcpy(pos, &he, sizeof(he)); in ieee80211_add_rx_radiotap_header()
672 pos += sizeof(he); in ieee80211_add_rx_radiotap_header()
675 if (status->encoding == RX_ENC_HE && in ieee80211_add_rx_radiotap_header()
676 status->flag & RX_FLAG_RADIOTAP_HE_MU) { in ieee80211_add_rx_radiotap_header()
678 while ((pos - (u8 *)rthdr) & 1) in ieee80211_add_rx_radiotap_header()
679 pos++; in ieee80211_add_rx_radiotap_header()
680 rthdr->it_present |= cpu_to_le32(BIT(IEEE80211_RADIOTAP_HE_MU)); in ieee80211_add_rx_radiotap_header()
681 memcpy(pos, &he_mu, sizeof(he_mu)); in ieee80211_add_rx_radiotap_header()
682 pos += sizeof(he_mu); in ieee80211_add_rx_radiotap_header()
685 if (status->flag & RX_FLAG_NO_PSDU) { in ieee80211_add_rx_radiotap_header()
686 rthdr->it_present |= in ieee80211_add_rx_radiotap_header()
688 *pos++ = status->zero_length_psdu_type; in ieee80211_add_rx_radiotap_header()
691 if (status->flag & RX_FLAG_RADIOTAP_LSIG) { in ieee80211_add_rx_radiotap_header()
693 while ((pos - (u8 *)rthdr) & 1) in ieee80211_add_rx_radiotap_header()
694 pos++; in ieee80211_add_rx_radiotap_header()
695 rthdr->it_present |= cpu_to_le32(BIT(IEEE80211_RADIOTAP_LSIG)); in ieee80211_add_rx_radiotap_header()
696 memcpy(pos, &lsig, sizeof(lsig)); in ieee80211_add_rx_radiotap_header()
697 pos += sizeof(lsig); in ieee80211_add_rx_radiotap_header()
701 *pos++ = status->chain_signal[chain]; in ieee80211_add_rx_radiotap_header()
702 *pos++ = chain; in ieee80211_add_rx_radiotap_header()
718 needed_headroom = rt_hdrlen - rtap_space; in ieee80211_make_monitor_skb()
753 skb->ip_summed = CHECKSUM_UNNECESSARY; in ieee80211_make_monitor_skb()
754 skb->pkt_type = PACKET_OTHERHOST; in ieee80211_make_monitor_skb()
755 skb->protocol = htons(ETH_P_802_2); in ieee80211_make_monitor_skb()
762 * returns a cleaned-up SKB that no longer includes the FCS nor the
775 rcu_dereference(local->monitor_sdata); in ieee80211_rx_monitor()
779 if (WARN_ON_ONCE(status->flag & RX_FLAG_RADIOTAP_TLV_AT_END && in ieee80211_rx_monitor()
786 if (status->flag & RX_FLAG_RADIOTAP_HE) in ieee80211_rx_monitor()
789 if (status->flag & RX_FLAG_RADIOTAP_HE_MU) in ieee80211_rx_monitor()
792 if (status->flag & RX_FLAG_RADIOTAP_LSIG) in ieee80211_rx_monitor()
795 if (status->flag & RX_FLAG_RADIOTAP_TLV_AT_END) in ieee80211_rx_monitor()
796 rtap_space += skb_mac_header(origskb) - &origskb->data[rtap_space]; in ieee80211_rx_monitor()
809 if (!(status->flag & RX_FLAG_NO_PSDU)) { in ieee80211_rx_monitor()
810 if (ieee80211_hw_check(&local->hw, RX_INCLUDES_FCS)) { in ieee80211_rx_monitor()
811 if (unlikely(origskb->len <= FCS_LEN + rtap_space)) { in ieee80211_rx_monitor()
820 /* also consider the hdr->frame_control */ in ieee80211_rx_monitor()
832 if (!local->monitors || (status->flag & RX_FLAG_SKIP_MONITOR)) { in ieee80211_rx_monitor()
844 list_for_each_entry_rcu(sdata, &local->mon_list, u.mntr.list) { in ieee80211_rx_monitor()
845 bool last_monitor = list_is_last(&sdata->u.mntr.list, in ieee80211_rx_monitor()
846 &local->mon_list); in ieee80211_rx_monitor()
865 skb->dev = sdata->dev; in ieee80211_rx_monitor()
866 dev_sw_netstats_rx_add(skb->dev, skb->len); in ieee80211_rx_monitor()
887 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data; in ieee80211_parse_qos()
888 struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(rx->skb); in ieee80211_parse_qos()
892 if (ieee80211_is_data_qos(hdr->frame_control)) { in ieee80211_parse_qos()
897 status->rx_flags |= IEEE80211_RX_AMSDU; in ieee80211_parse_qos()
903 * IEEE 802.11-2007, 7.1.3.4.1 ("Sequence Number field"): in ieee80211_parse_qos()
907 * Address 1 field, and all non-QoS data frames sent in ieee80211_parse_qos()
909 * modulo-4096 counter, [...] in ieee80211_parse_qos()
911 * We also use that counter for non-QoS STAs. in ieee80211_parse_qos()
915 if (ieee80211_is_mgmt(hdr->frame_control)) in ieee80211_parse_qos()
920 rx->seqno_idx = seqno_idx; in ieee80211_parse_qos()
921 rx->security_idx = security_idx; in ieee80211_parse_qos()
922 /* Set skb->priority to 1d tag if highest order bit of TID is not set. in ieee80211_parse_qos()
923 * For now, set skb->priority to 0 for other cases. */ in ieee80211_parse_qos()
924 rx->skb->priority = (tid > 7) ? 0 : tid; in ieee80211_parse_qos()
930 * Drivers always need to pass packets that are aligned to two-byte boundaries
934 * guarantees that the contained IP header is aligned to a four-byte
936 * payload to a four-byte boundary (because either the IP header is directly
942 * With A-MSDU frames, however, the payload data address must yield two modulo
943 * four because there are 14-byte 802.3 headers within the A-MSDU frames that
945 * specs were sane enough this time around to require padding each A-MSDU
955 WARN_ON_ONCE((unsigned long)rx->skb->data & 1); in ieee80211_verify_alignment()
964 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; in ieee80211_is_unicast_robust_mgmt_frame()
966 if (is_multicast_ether_addr(hdr->addr1)) in ieee80211_is_unicast_robust_mgmt_frame()
975 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; in ieee80211_is_multicast_robust_mgmt_frame()
977 if (!is_multicast_ether_addr(hdr->addr1)) in ieee80211_is_multicast_robust_mgmt_frame()
984 /* Get the BIP key index from MMIE; return -1 if this is not a BIP frame */
987 struct ieee80211_mgmt *hdr = (struct ieee80211_mgmt *) skb->data; in ieee80211_get_mmie_keyidx()
991 if (skb->len < 24 + sizeof(*mmie) || !is_multicast_ether_addr(hdr->da)) in ieee80211_get_mmie_keyidx()
992 return -1; in ieee80211_get_mmie_keyidx()
995 !ieee80211_is_beacon(hdr->frame_control)) in ieee80211_get_mmie_keyidx()
996 return -1; /* not a robust management frame */ in ieee80211_get_mmie_keyidx()
999 (skb->data + skb->len - sizeof(*mmie)); in ieee80211_get_mmie_keyidx()
1000 if (mmie->element_id == WLAN_EID_MMIE && in ieee80211_get_mmie_keyidx()
1001 mmie->length == sizeof(*mmie) - 2) in ieee80211_get_mmie_keyidx()
1002 return le16_to_cpu(mmie->key_id); in ieee80211_get_mmie_keyidx()
1005 (skb->data + skb->len - sizeof(*mmie16)); in ieee80211_get_mmie_keyidx()
1006 if (skb->len >= 24 + sizeof(*mmie16) && in ieee80211_get_mmie_keyidx()
1007 mmie16->element_id == WLAN_EID_MMIE && in ieee80211_get_mmie_keyidx()
1008 mmie16->length == sizeof(*mmie16) - 2) in ieee80211_get_mmie_keyidx()
1009 return le16_to_cpu(mmie16->key_id); in ieee80211_get_mmie_keyidx()
1011 return -1; in ieee80211_get_mmie_keyidx()
1016 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; in ieee80211_get_keyid()
1017 __le16 fc = hdr->frame_control; in ieee80211_get_keyid()
1022 if (unlikely(skb->len < hdrlen + IEEE80211_WEP_IV_LEN)) in ieee80211_get_keyid()
1023 return -EINVAL; in ieee80211_get_keyid()
1034 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data; in ieee80211_rx_mesh_check()
1035 char *dev_addr = rx->sdata->vif.addr; in ieee80211_rx_mesh_check()
1037 if (ieee80211_is_data(hdr->frame_control)) { in ieee80211_rx_mesh_check()
1038 if (is_multicast_ether_addr(hdr->addr1)) { in ieee80211_rx_mesh_check()
1039 if (ieee80211_has_tods(hdr->frame_control) || in ieee80211_rx_mesh_check()
1040 !ieee80211_has_fromds(hdr->frame_control)) in ieee80211_rx_mesh_check()
1042 if (ether_addr_equal(hdr->addr3, dev_addr)) in ieee80211_rx_mesh_check()
1045 if (!ieee80211_has_a4(hdr->frame_control)) in ieee80211_rx_mesh_check()
1047 if (ether_addr_equal(hdr->addr4, dev_addr)) in ieee80211_rx_mesh_check()
1056 if (!rx->sta || sta_plink_state(rx->sta) != NL80211_PLINK_ESTAB) { in ieee80211_rx_mesh_check()
1059 if (!ieee80211_is_mgmt(hdr->frame_control)) in ieee80211_rx_mesh_check()
1062 if (ieee80211_is_action(hdr->frame_control)) { in ieee80211_rx_mesh_check()
1066 if (rx->skb->len < IEEE80211_MIN_ACTION_SIZE) in ieee80211_rx_mesh_check()
1070 category = mgmt->u.action.category; in ieee80211_rx_mesh_check()
1077 if (ieee80211_is_probe_req(hdr->frame_control) || in ieee80211_rx_mesh_check()
1078 ieee80211_is_probe_resp(hdr->frame_control) || in ieee80211_rx_mesh_check()
1079 ieee80211_is_beacon(hdr->frame_control) || in ieee80211_rx_mesh_check()
1080 ieee80211_is_auth(hdr->frame_control)) in ieee80211_rx_mesh_check()
1092 struct sk_buff_head *frames = &tid_agg_rx->reorder_buf[index]; in ieee80211_rx_reorder_ready()
1096 if (tid_agg_rx->reorder_buf_filtered && in ieee80211_rx_reorder_ready()
1097 tid_agg_rx->reorder_buf_filtered & BIT_ULL(index)) in ieee80211_rx_reorder_ready()
1104 if (status->flag & RX_FLAG_AMSDU_MORE) in ieee80211_rx_reorder_ready()
1115 struct sk_buff_head *skb_list = &tid_agg_rx->reorder_buf[index]; in ieee80211_release_reorder_frame()
1119 lockdep_assert_held(&tid_agg_rx->reorder_lock); in ieee80211_release_reorder_frame()
1130 tid_agg_rx->stored_mpdu_num--; in ieee80211_release_reorder_frame()
1133 status->rx_flags |= IEEE80211_RX_DEFERRED_RELEASE; in ieee80211_release_reorder_frame()
1138 if (tid_agg_rx->reorder_buf_filtered) in ieee80211_release_reorder_frame()
1139 tid_agg_rx->reorder_buf_filtered &= ~BIT_ULL(index); in ieee80211_release_reorder_frame()
1140 tid_agg_rx->head_seq_num = ieee80211_sn_inc(tid_agg_rx->head_seq_num); in ieee80211_release_reorder_frame()
1150 lockdep_assert_held(&tid_agg_rx->reorder_lock); in ieee80211_release_reorder_frames()
1152 while (ieee80211_sn_less(tid_agg_rx->head_seq_num, head_seq_num)) { in ieee80211_release_reorder_frames()
1153 index = tid_agg_rx->head_seq_num % tid_agg_rx->buf_size; in ieee80211_release_reorder_frames()
1166 * Callers must hold tid_agg_rx->reorder_lock.
1176 lockdep_assert_held(&tid_agg_rx->reorder_lock); in ieee80211_sta_reorder_release()
1179 index = tid_agg_rx->head_seq_num % tid_agg_rx->buf_size; in ieee80211_sta_reorder_release()
1181 tid_agg_rx->stored_mpdu_num) { in ieee80211_sta_reorder_release()
1187 for (j = (index + 1) % tid_agg_rx->buf_size; j != index; in ieee80211_sta_reorder_release()
1188 j = (j + 1) % tid_agg_rx->buf_size) { in ieee80211_sta_reorder_release()
1194 !time_after(jiffies, tid_agg_rx->reorder_time[j] + in ieee80211_sta_reorder_release()
1198 /* don't leave incomplete A-MSDUs around */ in ieee80211_sta_reorder_release()
1199 for (i = (index + 1) % tid_agg_rx->buf_size; i != j; in ieee80211_sta_reorder_release()
1200 i = (i + 1) % tid_agg_rx->buf_size) in ieee80211_sta_reorder_release()
1201 __skb_queue_purge(&tid_agg_rx->reorder_buf[i]); in ieee80211_sta_reorder_release()
1211 tid_agg_rx->head_seq_num = in ieee80211_sta_reorder_release()
1212 (tid_agg_rx->head_seq_num + in ieee80211_sta_reorder_release()
1219 index = tid_agg_rx->head_seq_num % tid_agg_rx->buf_size; in ieee80211_sta_reorder_release()
1222 if (tid_agg_rx->stored_mpdu_num) { in ieee80211_sta_reorder_release()
1223 j = index = tid_agg_rx->head_seq_num % tid_agg_rx->buf_size; in ieee80211_sta_reorder_release()
1225 for (; j != (index - 1) % tid_agg_rx->buf_size; in ieee80211_sta_reorder_release()
1226 j = (j + 1) % tid_agg_rx->buf_size) { in ieee80211_sta_reorder_release()
1233 if (!tid_agg_rx->removed) in ieee80211_sta_reorder_release()
1234 mod_timer(&tid_agg_rx->reorder_timer, in ieee80211_sta_reorder_release()
1235 tid_agg_rx->reorder_time[j] + 1 + in ieee80211_sta_reorder_release()
1238 del_timer(&tid_agg_rx->reorder_timer); in ieee80211_sta_reorder_release()
1252 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; in ieee80211_sta_manage_reorder_buf()
1259 spin_lock(&tid_agg_rx->reorder_lock); in ieee80211_sta_manage_reorder_buf()
1265 if (unlikely(tid_agg_rx->auto_seq)) { in ieee80211_sta_manage_reorder_buf()
1266 tid_agg_rx->auto_seq = false; in ieee80211_sta_manage_reorder_buf()
1267 tid_agg_rx->ssn = mpdu_seq_num; in ieee80211_sta_manage_reorder_buf()
1268 tid_agg_rx->head_seq_num = mpdu_seq_num; in ieee80211_sta_manage_reorder_buf()
1271 buf_size = tid_agg_rx->buf_size; in ieee80211_sta_manage_reorder_buf()
1272 head_seq_num = tid_agg_rx->head_seq_num; in ieee80211_sta_manage_reorder_buf()
1278 if (unlikely(!tid_agg_rx->started)) { in ieee80211_sta_manage_reorder_buf()
1283 tid_agg_rx->started = true; in ieee80211_sta_manage_reorder_buf()
1306 index = mpdu_seq_num % tid_agg_rx->buf_size; in ieee80211_sta_manage_reorder_buf()
1320 if (mpdu_seq_num == tid_agg_rx->head_seq_num && in ieee80211_sta_manage_reorder_buf()
1321 tid_agg_rx->stored_mpdu_num == 0) { in ieee80211_sta_manage_reorder_buf()
1322 if (!(status->flag & RX_FLAG_AMSDU_MORE)) in ieee80211_sta_manage_reorder_buf()
1323 tid_agg_rx->head_seq_num = in ieee80211_sta_manage_reorder_buf()
1324 ieee80211_sn_inc(tid_agg_rx->head_seq_num); in ieee80211_sta_manage_reorder_buf()
1330 __skb_queue_tail(&tid_agg_rx->reorder_buf[index], skb); in ieee80211_sta_manage_reorder_buf()
1331 if (!(status->flag & RX_FLAG_AMSDU_MORE)) { in ieee80211_sta_manage_reorder_buf()
1332 tid_agg_rx->reorder_time[index] = jiffies; in ieee80211_sta_manage_reorder_buf()
1333 tid_agg_rx->stored_mpdu_num++; in ieee80211_sta_manage_reorder_buf()
1338 spin_unlock(&tid_agg_rx->reorder_lock); in ieee80211_sta_manage_reorder_buf()
1343 * Reorder MPDUs from A-MPDUs, keeping them on a buffer. Returns
1349 struct sk_buff *skb = rx->skb; in ieee80211_rx_reorder_ampdu()
1350 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; in ieee80211_rx_reorder_ampdu()
1351 struct sta_info *sta = rx->sta; in ieee80211_rx_reorder_ampdu()
1356 if (!ieee80211_is_data_qos(hdr->frame_control) || in ieee80211_rx_reorder_ampdu()
1357 is_multicast_ether_addr(hdr->addr1)) in ieee80211_rx_reorder_ampdu()
1372 tid_agg_rx = rcu_dereference(sta->ampdu_mlme.tid_rx[tid]); in ieee80211_rx_reorder_ampdu()
1375 !test_bit(tid, rx->sta->ampdu_mlme.agg_session_valid) && in ieee80211_rx_reorder_ampdu()
1376 !test_and_set_bit(tid, rx->sta->ampdu_mlme.unexpected_agg)) in ieee80211_rx_reorder_ampdu()
1377 ieee80211_send_delba(rx->sdata, rx->sta->sta.addr, tid, in ieee80211_rx_reorder_ampdu()
1384 if (unlikely(hdr->frame_control & cpu_to_le16(IEEE80211_STYPE_NULLFUNC))) in ieee80211_rx_reorder_ampdu()
1391 /* new, potentially un-ordered, ampdu frame - process it */ in ieee80211_rx_reorder_ampdu()
1394 if (tid_agg_rx->timeout) in ieee80211_rx_reorder_ampdu()
1395 tid_agg_rx->last_rx = jiffies; in ieee80211_rx_reorder_ampdu()
1397 /* if this mpdu is fragmented - terminate rx aggregation session */ in ieee80211_rx_reorder_ampdu()
1398 sc = le16_to_cpu(hdr->seq_ctrl); in ieee80211_rx_reorder_ampdu()
1400 ieee80211_queue_skb_to_iface(rx->sdata, rx->link_id, NULL, skb); in ieee80211_rx_reorder_ampdu()
1405 * No locking needed -- we will only ever process one in ieee80211_rx_reorder_ampdu()
1411 if (ieee80211_sta_manage_reorder_buf(rx->sdata, tid_agg_rx, skb, in ieee80211_rx_reorder_ampdu()
1422 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data; in ieee80211_rx_h_check_dup()
1423 struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(rx->skb); in ieee80211_rx_h_check_dup()
1425 if (status->flag & RX_FLAG_DUP_VALIDATED) in ieee80211_rx_h_check_dup()
1430 * (IEEE 802.11-2012: 9.3.2.10 "Duplicate detection and recovery") in ieee80211_rx_h_check_dup()
1433 if (rx->skb->len < 24) in ieee80211_rx_h_check_dup()
1436 if (ieee80211_is_ctl(hdr->frame_control) || in ieee80211_rx_h_check_dup()
1437 ieee80211_is_any_nullfunc(hdr->frame_control)) in ieee80211_rx_h_check_dup()
1440 if (!rx->sta) in ieee80211_rx_h_check_dup()
1443 if (unlikely(is_multicast_ether_addr(hdr->addr1))) { in ieee80211_rx_h_check_dup()
1444 struct ieee80211_sub_if_data *sdata = rx->sdata; in ieee80211_rx_h_check_dup()
1447 if (!ieee80211_is_data_present(hdr->frame_control)) in ieee80211_rx_h_check_dup()
1450 if (!ieee80211_vif_is_mld(&sdata->vif) || in ieee80211_rx_h_check_dup()
1451 sdata->vif.type != NL80211_IFTYPE_STATION) in ieee80211_rx_h_check_dup()
1454 if (sdata->u.mgd.mcast_seq_last != IEEE80211_SN_MODULO && in ieee80211_rx_h_check_dup()
1455 ieee80211_sn_less_eq(sn, sdata->u.mgd.mcast_seq_last)) in ieee80211_rx_h_check_dup()
1458 sdata->u.mgd.mcast_seq_last = sn; in ieee80211_rx_h_check_dup()
1462 if (unlikely(ieee80211_has_retry(hdr->frame_control) && in ieee80211_rx_h_check_dup()
1463 rx->sta->last_seq_ctrl[rx->seqno_idx] == hdr->seq_ctrl)) { in ieee80211_rx_h_check_dup()
1464 I802_DEBUG_INC(rx->local->dot11FrameDuplicateCount); in ieee80211_rx_h_check_dup()
1465 rx->link_sta->rx_stats.num_duplicates++; in ieee80211_rx_h_check_dup()
1467 } else if (!(status->flag & RX_FLAG_AMSDU_MORE)) { in ieee80211_rx_h_check_dup()
1468 rx->sta->last_seq_ctrl[rx->seqno_idx] = hdr->seq_ctrl; in ieee80211_rx_h_check_dup()
1477 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data; in ieee80211_rx_h_check()
1488 if (ieee80211_vif_is_mesh(&rx->sdata->vif)) in ieee80211_rx_h_check()
1491 if (unlikely((ieee80211_is_data(hdr->frame_control) || in ieee80211_rx_h_check()
1492 ieee80211_is_pspoll(hdr->frame_control)) && in ieee80211_rx_h_check()
1493 rx->sdata->vif.type != NL80211_IFTYPE_ADHOC && in ieee80211_rx_h_check()
1494 rx->sdata->vif.type != NL80211_IFTYPE_OCB && in ieee80211_rx_h_check()
1495 (!rx->sta || !test_sta_flag(rx->sta, WLAN_STA_ASSOC)))) { in ieee80211_rx_h_check()
1501 if (rx->sta && rx->sdata->vif.type == NL80211_IFTYPE_STATION && in ieee80211_rx_h_check()
1502 ieee80211_is_data_present(hdr->frame_control)) { in ieee80211_rx_h_check()
1506 hdrlen = ieee80211_hdrlen(hdr->frame_control); in ieee80211_rx_h_check()
1508 if (rx->skb->len < hdrlen + 8) in ieee80211_rx_h_check()
1511 skb_copy_bits(rx->skb, hdrlen + 6, ðertype, 2); in ieee80211_rx_h_check()
1512 if (ethertype == rx->sdata->control_port_protocol) in ieee80211_rx_h_check()
1516 if (rx->sdata->vif.type == NL80211_IFTYPE_AP && in ieee80211_rx_h_check()
1517 cfg80211_rx_spurious_frame(rx->sdata->dev, in ieee80211_rx_h_check()
1518 hdr->addr2, in ieee80211_rx_h_check()
1536 local = rx->local; in ieee80211_rx_h_check_more_data()
1537 skb = rx->skb; in ieee80211_rx_h_check_more_data()
1538 hdr = (struct ieee80211_hdr *) skb->data; in ieee80211_rx_h_check_more_data()
1540 if (!local->pspolling) in ieee80211_rx_h_check_more_data()
1543 if (!ieee80211_has_fromds(hdr->frame_control)) in ieee80211_rx_h_check_more_data()
1547 if (!ieee80211_is_data(hdr->frame_control)) in ieee80211_rx_h_check_more_data()
1550 if (!ieee80211_has_moredata(hdr->frame_control)) { in ieee80211_rx_h_check_more_data()
1552 local->pspolling = false; in ieee80211_rx_h_check_more_data()
1557 ieee80211_send_pspoll(local, rx->sdata); in ieee80211_rx_h_check_more_data()
1564 struct ieee80211_sub_if_data *sdata = sta->sdata; in sta_ps_start()
1565 struct ieee80211_local *local = sdata->local; in sta_ps_start()
1569 if (sta->sdata->vif.type == NL80211_IFTYPE_AP || in sta_ps_start()
1570 sta->sdata->vif.type == NL80211_IFTYPE_AP_VLAN) in sta_ps_start()
1571 ps = &sdata->bss->ps; in sta_ps_start()
1575 atomic_inc(&ps->num_sta_ps); in sta_ps_start()
1577 if (!ieee80211_hw_check(&local->hw, AP_LINK_PS)) in sta_ps_start()
1578 drv_sta_notify(local, sdata, STA_NOTIFY_SLEEP, &sta->sta); in sta_ps_start()
1580 sta->sta.addr, sta->sta.aid); in sta_ps_start()
1585 struct ieee80211_txq *txq = sta->sta.txq[tid]; in sta_ps_start()
1588 spin_lock(&local->active_txq_lock[txq->ac]); in sta_ps_start()
1589 if (!list_empty(&txqi->schedule_order)) in sta_ps_start()
1590 list_del_init(&txqi->schedule_order); in sta_ps_start()
1591 spin_unlock(&local->active_txq_lock[txq->ac]); in sta_ps_start()
1594 set_bit(tid, &sta->txq_buffered_tids); in sta_ps_start()
1596 clear_bit(tid, &sta->txq_buffered_tids); in sta_ps_start()
1602 ps_dbg(sta->sdata, "STA %pM aid %d exits power save mode\n", in sta_ps_end()
1603 sta->sta.addr, sta->sta.aid); in sta_ps_end()
1613 ps_dbg(sta->sdata, "STA %pM aid %d driver-ps-blocked\n", in sta_ps_end()
1614 sta->sta.addr, sta->sta.aid); in sta_ps_end()
1628 WARN_ON(!ieee80211_hw_check(&sta->local->hw, AP_LINK_PS)); in ieee80211_sta_ps_transition()
1633 return -EINVAL; in ieee80211_sta_ps_transition()
1664 * If this AC is not trigger-enabled do nothing unless the in ieee80211_sta_uapsd_trigger()
1667 * NB: This could/should check a separate bitmap of trigger- in ieee80211_sta_uapsd_trigger()
1671 if (!(sta->sta.uapsd_queues & ieee80211_ac_to_qos_mask[ac]) && in ieee80211_sta_uapsd_trigger()
1689 struct ieee80211_sub_if_data *sdata = rx->sdata; in ieee80211_rx_h_uapsd_and_pspoll()
1690 struct ieee80211_hdr *hdr = (void *)rx->skb->data; in ieee80211_rx_h_uapsd_and_pspoll()
1691 struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(rx->skb); in ieee80211_rx_h_uapsd_and_pspoll()
1693 if (!rx->sta) in ieee80211_rx_h_uapsd_and_pspoll()
1696 if (sdata->vif.type != NL80211_IFTYPE_AP && in ieee80211_rx_h_uapsd_and_pspoll()
1697 sdata->vif.type != NL80211_IFTYPE_AP_VLAN) in ieee80211_rx_h_uapsd_and_pspoll()
1702 * uAPSD and PS-Poll frames (the latter shouldn't even come up from in ieee80211_rx_h_uapsd_and_pspoll()
1705 if (ieee80211_hw_check(&sdata->local->hw, AP_LINK_PS)) in ieee80211_rx_h_uapsd_and_pspoll()
1711 * in the PS-Poll case the station must be confused ... in ieee80211_rx_h_uapsd_and_pspoll()
1713 if (!test_sta_flag(rx->sta, WLAN_STA_PS_STA)) in ieee80211_rx_h_uapsd_and_pspoll()
1716 if (unlikely(ieee80211_is_pspoll(hdr->frame_control))) { in ieee80211_rx_h_uapsd_and_pspoll()
1717 ieee80211_sta_pspoll(&rx->sta->sta); in ieee80211_rx_h_uapsd_and_pspoll()
1721 dev_kfree_skb(rx->skb); in ieee80211_rx_h_uapsd_and_pspoll()
1724 } else if (!ieee80211_has_morefrags(hdr->frame_control) && in ieee80211_rx_h_uapsd_and_pspoll()
1725 !(status->rx_flags & IEEE80211_RX_DEFERRED_RELEASE) && in ieee80211_rx_h_uapsd_and_pspoll()
1726 ieee80211_has_pm(hdr->frame_control) && in ieee80211_rx_h_uapsd_and_pspoll()
1727 (ieee80211_is_data_qos(hdr->frame_control) || in ieee80211_rx_h_uapsd_and_pspoll()
1728 ieee80211_is_qos_nullfunc(hdr->frame_control))) { in ieee80211_rx_h_uapsd_and_pspoll()
1731 ieee80211_sta_uapsd_trigger(&rx->sta->sta, tid); in ieee80211_rx_h_uapsd_and_pspoll()
1740 struct sta_info *sta = rx->sta; in ieee80211_rx_h_sta_process()
1741 struct link_sta_info *link_sta = rx->link_sta; in ieee80211_rx_h_sta_process()
1742 struct sk_buff *skb = rx->skb; in ieee80211_rx_h_sta_process()
1744 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; in ieee80211_rx_h_sta_process()
1758 if (rx->sdata->vif.type == NL80211_IFTYPE_ADHOC) { in ieee80211_rx_h_sta_process()
1759 u8 *bssid = ieee80211_get_bssid(hdr, rx->skb->len, in ieee80211_rx_h_sta_process()
1761 if (ether_addr_equal(bssid, rx->sdata->u.ibss.bssid) && in ieee80211_rx_h_sta_process()
1763 link_sta->rx_stats.last_rx = jiffies; in ieee80211_rx_h_sta_process()
1764 if (ieee80211_is_data_present(hdr->frame_control) && in ieee80211_rx_h_sta_process()
1765 !is_multicast_ether_addr(hdr->addr1)) in ieee80211_rx_h_sta_process()
1766 link_sta->rx_stats.last_rate = in ieee80211_rx_h_sta_process()
1769 } else if (rx->sdata->vif.type == NL80211_IFTYPE_OCB) { in ieee80211_rx_h_sta_process()
1770 link_sta->rx_stats.last_rx = jiffies; in ieee80211_rx_h_sta_process()
1771 } else if (!ieee80211_is_s1g_beacon(hdr->frame_control) && in ieee80211_rx_h_sta_process()
1772 !is_multicast_ether_addr(hdr->addr1)) { in ieee80211_rx_h_sta_process()
1777 link_sta->rx_stats.last_rx = jiffies; in ieee80211_rx_h_sta_process()
1778 if (ieee80211_is_data_present(hdr->frame_control)) in ieee80211_rx_h_sta_process()
1779 link_sta->rx_stats.last_rate = sta_stats_encode_rate(status); in ieee80211_rx_h_sta_process()
1782 link_sta->rx_stats.fragments++; in ieee80211_rx_h_sta_process()
1784 u64_stats_update_begin(&link_sta->rx_stats.syncp); in ieee80211_rx_h_sta_process()
1785 link_sta->rx_stats.bytes += rx->skb->len; in ieee80211_rx_h_sta_process()
1786 u64_stats_update_end(&link_sta->rx_stats.syncp); in ieee80211_rx_h_sta_process()
1788 if (!(status->flag & RX_FLAG_NO_SIGNAL_VAL)) { in ieee80211_rx_h_sta_process()
1789 link_sta->rx_stats.last_signal = status->signal; in ieee80211_rx_h_sta_process()
1790 ewma_signal_add(&link_sta->rx_stats_avg.signal, in ieee80211_rx_h_sta_process()
1791 -status->signal); in ieee80211_rx_h_sta_process()
1794 if (status->chains) { in ieee80211_rx_h_sta_process()
1795 link_sta->rx_stats.chains = status->chains; in ieee80211_rx_h_sta_process()
1796 for (i = 0; i < ARRAY_SIZE(status->chain_signal); i++) { in ieee80211_rx_h_sta_process()
1797 int signal = status->chain_signal[i]; in ieee80211_rx_h_sta_process()
1799 if (!(status->chains & BIT(i))) in ieee80211_rx_h_sta_process()
1802 link_sta->rx_stats.chain_signal_last[i] = signal; in ieee80211_rx_h_sta_process()
1803 ewma_signal_add(&link_sta->rx_stats_avg.chain_signal[i], in ieee80211_rx_h_sta_process()
1804 -signal); in ieee80211_rx_h_sta_process()
1808 if (ieee80211_is_s1g_beacon(hdr->frame_control)) in ieee80211_rx_h_sta_process()
1814 * frame as specified in IEEE 802.11-2016 11.2.3.2 in ieee80211_rx_h_sta_process()
1816 if (!ieee80211_hw_check(&sta->local->hw, AP_LINK_PS) && in ieee80211_rx_h_sta_process()
1817 !ieee80211_has_morefrags(hdr->frame_control) && in ieee80211_rx_h_sta_process()
1818 !is_multicast_ether_addr(hdr->addr1) && in ieee80211_rx_h_sta_process()
1819 (ieee80211_is_mgmt(hdr->frame_control) || in ieee80211_rx_h_sta_process()
1820 ieee80211_is_data(hdr->frame_control)) && in ieee80211_rx_h_sta_process()
1821 !(status->rx_flags & IEEE80211_RX_DEFERRED_RELEASE) && in ieee80211_rx_h_sta_process()
1822 (rx->sdata->vif.type == NL80211_IFTYPE_AP || in ieee80211_rx_h_sta_process()
1823 rx->sdata->vif.type == NL80211_IFTYPE_AP_VLAN)) { in ieee80211_rx_h_sta_process()
1825 if (!ieee80211_has_pm(hdr->frame_control)) in ieee80211_rx_h_sta_process()
1828 if (ieee80211_has_pm(hdr->frame_control)) in ieee80211_rx_h_sta_process()
1834 if (ieee80211_vif_is_mesh(&rx->sdata->vif)) in ieee80211_rx_h_sta_process()
1838 * Drop (qos-)data::nullfunc frames silently, since they in ieee80211_rx_h_sta_process()
1841 if (ieee80211_is_any_nullfunc(hdr->frame_control)) { in ieee80211_rx_h_sta_process()
1842 I802_DEBUG_INC(rx->local->rx_handlers_drop_nullfunc); in ieee80211_rx_h_sta_process()
1845 * If we receive a 4-addr nullfunc frame from a STA in ieee80211_rx_h_sta_process()
1846 * that was not moved to a 4-addr STA vlan yet send in ieee80211_rx_h_sta_process()
1850 if (ieee80211_has_a4(hdr->frame_control) && in ieee80211_rx_h_sta_process()
1851 (rx->sdata->vif.type == NL80211_IFTYPE_AP || in ieee80211_rx_h_sta_process()
1852 (rx->sdata->vif.type == NL80211_IFTYPE_AP_VLAN && in ieee80211_rx_h_sta_process()
1853 !rx->sdata->u.vlan.sta))) { in ieee80211_rx_h_sta_process()
1856 rx->sdata->dev, sta->sta.addr, in ieee80211_rx_h_sta_process()
1864 link_sta->rx_stats.packets++; in ieee80211_rx_h_sta_process()
1865 dev_kfree_skb(rx->skb); in ieee80211_rx_h_sta_process()
1891 idx2 = idx - 1; in ieee80211_rx_get_bigtk()
1894 if (rx->link_sta) in ieee80211_rx_get_bigtk()
1895 key = rcu_dereference(rx->link_sta->gtk[idx]); in ieee80211_rx_get_bigtk()
1897 key = rcu_dereference(rx->link->gtk[idx]); in ieee80211_rx_get_bigtk()
1898 if (!key && rx->link_sta) in ieee80211_rx_get_bigtk()
1899 key = rcu_dereference(rx->link_sta->gtk[idx2]); in ieee80211_rx_get_bigtk()
1901 key = rcu_dereference(rx->link->gtk[idx2]); in ieee80211_rx_get_bigtk()
1909 struct sk_buff *skb = rx->skb; in ieee80211_rx_h_decrypt()
1911 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; in ieee80211_rx_h_decrypt()
1916 int mmie_keyidx = -1; in ieee80211_rx_h_decrypt()
1919 if (ieee80211_is_ext(hdr->frame_control)) in ieee80211_rx_h_decrypt()
1926 * - GTK (group keys) in ieee80211_rx_h_decrypt()
1927 * - IGTK (group keys for management frames) in ieee80211_rx_h_decrypt()
1928 * - BIGTK (group keys for Beacon frames) in ieee80211_rx_h_decrypt()
1929 * - PTK (pairwise keys) in ieee80211_rx_h_decrypt()
1930 * - STK (station-to-station pairwise keys) in ieee80211_rx_h_decrypt()
1935 * BIGTKs. Unless, of course, actual WEP keys ("pre-RSNA") are used, in ieee80211_rx_h_decrypt()
1951 rx->key = NULL; in ieee80211_rx_h_decrypt()
1952 fc = hdr->frame_control; in ieee80211_rx_h_decrypt()
1954 if (rx->sta) { in ieee80211_rx_h_decrypt()
1955 int keyid = rx->sta->ptk_idx; in ieee80211_rx_h_decrypt()
1956 sta_ptk = rcu_dereference(rx->sta->ptk[keyid]); in ieee80211_rx_h_decrypt()
1959 !(status->flag & RX_FLAG_IV_STRIPPED)) { in ieee80211_rx_h_decrypt()
1960 keyid = ieee80211_get_keyid(rx->skb); in ieee80211_rx_h_decrypt()
1965 ptk_idx = rcu_dereference(rx->sta->ptk[keyid]); in ieee80211_rx_h_decrypt()
1970 mmie_keyidx = ieee80211_get_mmie_keyidx(rx->skb); in ieee80211_rx_h_decrypt()
1972 if (!is_multicast_ether_addr(hdr->addr1) && sta_ptk) { in ieee80211_rx_h_decrypt()
1973 rx->key = ptk_idx ? ptk_idx : sta_ptk; in ieee80211_rx_h_decrypt()
1974 if ((status->flag & RX_FLAG_DECRYPTED) && in ieee80211_rx_h_decrypt()
1975 (status->flag & RX_FLAG_IV_STRIPPED)) in ieee80211_rx_h_decrypt()
1982 if ((status->flag & RX_FLAG_DECRYPTED) && in ieee80211_rx_h_decrypt()
1983 (status->flag & RX_FLAG_IV_STRIPPED)) in ieee80211_rx_h_decrypt()
1989 if (rx->sdata->dev) in ieee80211_rx_h_decrypt()
1990 cfg80211_rx_unprot_mlme_mgmt(rx->sdata->dev, in ieee80211_rx_h_decrypt()
1991 skb->data, in ieee80211_rx_h_decrypt()
1992 skb->len); in ieee80211_rx_h_decrypt()
1996 rx->key = ieee80211_rx_get_bigtk(rx, mmie_keyidx); in ieee80211_rx_h_decrypt()
1997 if (!rx->key) in ieee80211_rx_h_decrypt()
2001 if ((status->flag & RX_FLAG_DECRYPTED) && in ieee80211_rx_h_decrypt()
2002 (status->flag & RX_FLAG_IV_STRIPPED)) in ieee80211_rx_h_decrypt()
2008 if (rx->link_sta) { in ieee80211_rx_h_decrypt()
2010 test_sta_flag(rx->sta, WLAN_STA_MFP)) in ieee80211_rx_h_decrypt()
2013 rx->key = rcu_dereference(rx->link_sta->gtk[mmie_keyidx]); in ieee80211_rx_h_decrypt()
2015 if (!rx->key) in ieee80211_rx_h_decrypt()
2016 rx->key = rcu_dereference(rx->link->gtk[mmie_keyidx]); in ieee80211_rx_h_decrypt()
2020 * need to set rx->key if there is a key that could have been in ieee80211_rx_h_decrypt()
2028 key = ieee80211_rx_get_bigtk(rx, -1); in ieee80211_rx_h_decrypt()
2030 is_multicast_ether_addr(hdr->addr1)) { in ieee80211_rx_h_decrypt()
2031 key = rcu_dereference(rx->link->default_mgmt_key); in ieee80211_rx_h_decrypt()
2033 if (rx->link_sta) { in ieee80211_rx_h_decrypt()
2035 key = rcu_dereference(rx->link_sta->gtk[i]); in ieee80211_rx_h_decrypt()
2042 key = rcu_dereference(rx->link->gtk[i]); in ieee80211_rx_h_decrypt()
2049 rx->key = key; in ieee80211_rx_h_decrypt()
2061 if ((status->flag & RX_FLAG_DECRYPTED) && in ieee80211_rx_h_decrypt()
2062 (status->flag & RX_FLAG_IV_STRIPPED)) in ieee80211_rx_h_decrypt()
2065 keyidx = ieee80211_get_keyid(rx->skb); in ieee80211_rx_h_decrypt()
2070 /* check per-station GTK first, if multicast packet */ in ieee80211_rx_h_decrypt()
2071 if (is_multicast_ether_addr(hdr->addr1) && rx->link_sta) in ieee80211_rx_h_decrypt()
2072 rx->key = rcu_dereference(rx->link_sta->gtk[keyidx]); in ieee80211_rx_h_decrypt()
2075 if (!rx->key) { in ieee80211_rx_h_decrypt()
2076 if (is_multicast_ether_addr(hdr->addr1)) in ieee80211_rx_h_decrypt()
2077 rx->key = rcu_dereference(rx->link->gtk[keyidx]); in ieee80211_rx_h_decrypt()
2078 if (!rx->key) in ieee80211_rx_h_decrypt()
2079 rx->key = rcu_dereference(rx->sdata->keys[keyidx]); in ieee80211_rx_h_decrypt()
2082 * RSNA-protected unicast frames should always be in ieee80211_rx_h_decrypt()
2083 * sent with pairwise or station-to-station keys, in ieee80211_rx_h_decrypt()
2086 if (rx->key && in ieee80211_rx_h_decrypt()
2087 rx->key->conf.cipher != WLAN_CIPHER_SUITE_WEP40 && in ieee80211_rx_h_decrypt()
2088 rx->key->conf.cipher != WLAN_CIPHER_SUITE_WEP104 && in ieee80211_rx_h_decrypt()
2089 !is_multicast_ether_addr(hdr->addr1)) in ieee80211_rx_h_decrypt()
2090 rx->key = NULL; in ieee80211_rx_h_decrypt()
2094 if (rx->key) { in ieee80211_rx_h_decrypt()
2095 if (unlikely(rx->key->flags & KEY_FLAG_TAINTED)) in ieee80211_rx_h_decrypt()
2103 switch (rx->key->conf.cipher) { in ieee80211_rx_h_decrypt()
2140 status->flag |= RX_FLAG_DECRYPTED; in ieee80211_rx_h_decrypt()
2143 rx->sdata->dev)) in ieee80211_rx_h_decrypt()
2144 cfg80211_rx_unprot_mlme_mgmt(rx->sdata->dev, in ieee80211_rx_h_decrypt()
2145 skb->data, skb->len); in ieee80211_rx_h_decrypt()
2154 for (i = 0; i < ARRAY_SIZE(cache->entries); i++) in ieee80211_init_frag_cache()
2155 skb_queue_head_init(&cache->entries[i].skb_list); in ieee80211_init_frag_cache()
2162 for (i = 0; i < ARRAY_SIZE(cache->entries); i++) in ieee80211_destroy_frag_cache()
2163 __skb_queue_purge(&cache->entries[i].skb_list); in ieee80211_destroy_frag_cache()
2173 entry = &cache->entries[cache->next++]; in ieee80211_reassemble_add()
2174 if (cache->next >= IEEE80211_FRAGMENT_MAX) in ieee80211_reassemble_add()
2175 cache->next = 0; in ieee80211_reassemble_add()
2177 __skb_queue_purge(&entry->skb_list); in ieee80211_reassemble_add()
2179 __skb_queue_tail(&entry->skb_list, *skb); /* no need for locking */ in ieee80211_reassemble_add()
2181 entry->first_frag_time = jiffies; in ieee80211_reassemble_add()
2182 entry->seq = seq; in ieee80211_reassemble_add()
2183 entry->rx_queue = rx_queue; in ieee80211_reassemble_add()
2184 entry->last_frag = frag; in ieee80211_reassemble_add()
2185 entry->check_sequential_pn = false; in ieee80211_reassemble_add()
2186 entry->extra_len = 0; in ieee80211_reassemble_add()
2199 idx = cache->next; in ieee80211_reassemble_find()
2204 idx--; in ieee80211_reassemble_find()
2206 idx = IEEE80211_FRAGMENT_MAX - 1; in ieee80211_reassemble_find()
2208 entry = &cache->entries[idx]; in ieee80211_reassemble_find()
2209 if (skb_queue_empty(&entry->skb_list) || entry->seq != seq || in ieee80211_reassemble_find()
2210 entry->rx_queue != rx_queue || in ieee80211_reassemble_find()
2211 entry->last_frag + 1 != frag) in ieee80211_reassemble_find()
2214 f_skb = __skb_peek(&entry->skb_list); in ieee80211_reassemble_find()
2215 f_hdr = (struct ieee80211_hdr *) f_skb->data; in ieee80211_reassemble_find()
2220 if (((hdr->frame_control ^ f_hdr->frame_control) & in ieee80211_reassemble_find()
2222 !ether_addr_equal(hdr->addr1, f_hdr->addr1) || in ieee80211_reassemble_find()
2223 !ether_addr_equal(hdr->addr2, f_hdr->addr2)) in ieee80211_reassemble_find()
2226 if (time_after(jiffies, entry->first_frag_time + 2 * HZ)) { in ieee80211_reassemble_find()
2227 __skb_queue_purge(&entry->skb_list); in ieee80211_reassemble_find()
2238 return rx->key && in requires_sequential_pn()
2239 (rx->key->conf.cipher == WLAN_CIPHER_SUITE_CCMP || in requires_sequential_pn()
2240 rx->key->conf.cipher == WLAN_CIPHER_SUITE_CCMP_256 || in requires_sequential_pn()
2241 rx->key->conf.cipher == WLAN_CIPHER_SUITE_GCMP || in requires_sequential_pn()
2242 rx->key->conf.cipher == WLAN_CIPHER_SUITE_GCMP_256) && in requires_sequential_pn()
2249 struct ieee80211_fragment_cache *cache = &rx->sdata->frags; in ieee80211_rx_h_defragment()
2256 struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(rx->skb); in ieee80211_rx_h_defragment()
2258 hdr = (struct ieee80211_hdr *)rx->skb->data; in ieee80211_rx_h_defragment()
2259 fc = hdr->frame_control; in ieee80211_rx_h_defragment()
2264 sc = le16_to_cpu(hdr->seq_ctrl); in ieee80211_rx_h_defragment()
2267 if (rx->sta) in ieee80211_rx_h_defragment()
2268 cache = &rx->sta->frags; in ieee80211_rx_h_defragment()
2273 if (is_multicast_ether_addr(hdr->addr1)) in ieee80211_rx_h_defragment()
2276 I802_DEBUG_INC(rx->local->rx_handlers_fragments); in ieee80211_rx_h_defragment()
2278 if (skb_linearize(rx->skb)) in ieee80211_rx_h_defragment()
2282 * skb_linearize() might change the skb->data and in ieee80211_rx_h_defragment()
2286 hdr = (struct ieee80211_hdr *)rx->skb->data; in ieee80211_rx_h_defragment()
2292 rx->seqno_idx, &(rx->skb)); in ieee80211_rx_h_defragment()
2294 int queue = rx->security_idx; in ieee80211_rx_h_defragment()
2299 entry->check_sequential_pn = true; in ieee80211_rx_h_defragment()
2300 entry->is_protected = true; in ieee80211_rx_h_defragment()
2301 entry->key_color = rx->key->color; in ieee80211_rx_h_defragment()
2302 memcpy(entry->last_pn, in ieee80211_rx_h_defragment()
2303 rx->key->u.ccmp.rx_pn[queue], in ieee80211_rx_h_defragment()
2309 BUILD_BUG_ON(sizeof(rx->key->u.ccmp.rx_pn[queue]) != in ieee80211_rx_h_defragment()
2310 sizeof(rx->key->u.gcmp.rx_pn[queue])); in ieee80211_rx_h_defragment()
2313 } else if (rx->key && in ieee80211_rx_h_defragment()
2315 (status->flag & RX_FLAG_DECRYPTED))) { in ieee80211_rx_h_defragment()
2316 entry->is_protected = true; in ieee80211_rx_h_defragment()
2317 entry->key_color = rx->key->color; in ieee80211_rx_h_defragment()
2326 rx->seqno_idx, hdr); in ieee80211_rx_h_defragment()
2328 I802_DEBUG_INC(rx->local->rx_handlers_drop_defrag); in ieee80211_rx_h_defragment()
2334 * see IEEE P802.11-REVmc/D5.0, 12.5.3.4.4, item d (for CCMP) in ieee80211_rx_h_defragment()
2335 * and IEEE P802.11-REVmc/D5.0, 12.5.5.4.4, item d (for GCMP) in ieee80211_rx_h_defragment()
2337 if (entry->check_sequential_pn) { in ieee80211_rx_h_defragment()
2345 if (entry->key_color != rx->key->color) in ieee80211_rx_h_defragment()
2348 memcpy(pn, entry->last_pn, IEEE80211_CCMP_PN_LEN); in ieee80211_rx_h_defragment()
2349 for (i = IEEE80211_CCMP_PN_LEN - 1; i >= 0; i--) { in ieee80211_rx_h_defragment()
2355 rpn = rx->ccm_gcm.pn; in ieee80211_rx_h_defragment()
2358 memcpy(entry->last_pn, pn, IEEE80211_CCMP_PN_LEN); in ieee80211_rx_h_defragment()
2359 } else if (entry->is_protected && in ieee80211_rx_h_defragment()
2360 (!rx->key || in ieee80211_rx_h_defragment()
2362 !(status->flag & RX_FLAG_DECRYPTED)) || in ieee80211_rx_h_defragment()
2363 rx->key->color != entry->key_color)) { in ieee80211_rx_h_defragment()
2365 * if for TKIP Michael MIC should protect us, and WEP is a in ieee80211_rx_h_defragment()
2369 } else if (entry->is_protected && rx->key && in ieee80211_rx_h_defragment()
2370 entry->key_color != rx->key->color && in ieee80211_rx_h_defragment()
2371 (status->flag & RX_FLAG_DECRYPTED)) { in ieee80211_rx_h_defragment()
2375 skb_pull(rx->skb, ieee80211_hdrlen(fc)); in ieee80211_rx_h_defragment()
2376 __skb_queue_tail(&entry->skb_list, rx->skb); in ieee80211_rx_h_defragment()
2377 entry->last_frag = frag; in ieee80211_rx_h_defragment()
2378 entry->extra_len += rx->skb->len; in ieee80211_rx_h_defragment()
2380 rx->skb = NULL; in ieee80211_rx_h_defragment()
2384 rx->skb = __skb_dequeue(&entry->skb_list); in ieee80211_rx_h_defragment()
2385 if (skb_tailroom(rx->skb) < entry->extra_len) { in ieee80211_rx_h_defragment()
2386 I802_DEBUG_INC(rx->local->rx_expand_skb_head_defrag); in ieee80211_rx_h_defragment()
2387 if (unlikely(pskb_expand_head(rx->skb, 0, entry->extra_len, in ieee80211_rx_h_defragment()
2389 I802_DEBUG_INC(rx->local->rx_handlers_drop_defrag); in ieee80211_rx_h_defragment()
2390 __skb_queue_purge(&entry->skb_list); in ieee80211_rx_h_defragment()
2394 while ((skb = __skb_dequeue(&entry->skb_list))) { in ieee80211_rx_h_defragment()
2395 skb_put_data(rx->skb, skb->data, skb->len); in ieee80211_rx_h_defragment()
2400 ieee80211_led_rx(rx->local); in ieee80211_rx_h_defragment()
2401 if (rx->sta) in ieee80211_rx_h_defragment()
2402 rx->link_sta->rx_stats.packets++; in ieee80211_rx_h_defragment()
2408 if (unlikely(!rx->sta || !test_sta_flag(rx->sta, WLAN_STA_AUTHORIZED))) in ieee80211_802_1x_port_control()
2409 return -EACCES; in ieee80211_802_1x_port_control()
2416 struct sk_buff *skb = rx->skb; in ieee80211_drop_unencrypted()
2423 if (status->flag & RX_FLAG_DECRYPTED) in ieee80211_drop_unencrypted()
2429 ieee80211_is_data(fc) && rx->key)) in ieee80211_drop_unencrypted()
2430 return -EACCES; in ieee80211_drop_unencrypted()
2438 struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(rx->skb); in ieee80211_drop_unencrypted_mgmt()
2439 struct ieee80211_mgmt *mgmt = (void *)rx->skb->data; in ieee80211_drop_unencrypted_mgmt()
2440 __le16 fc = mgmt->frame_control; in ieee80211_drop_unencrypted_mgmt()
2446 if (status->flag & RX_FLAG_DECRYPTED) in ieee80211_drop_unencrypted_mgmt()
2451 mgmt->u.action.category == WLAN_CATEGORY_PROTECTED_DUAL_OF_ACTION) in ieee80211_drop_unencrypted_mgmt()
2454 if (rx->sta && test_sta_flag(rx->sta, WLAN_STA_MFP)) { in ieee80211_drop_unencrypted_mgmt()
2456 ieee80211_is_unicast_robust_mgmt_frame(rx->skb))) { in ieee80211_drop_unencrypted_mgmt()
2461 * during 4-way-HS (key is installed after HS). in ieee80211_drop_unencrypted_mgmt()
2463 if (!rx->key) in ieee80211_drop_unencrypted_mgmt()
2466 cfg80211_rx_unprot_mlme_mgmt(rx->sdata->dev, in ieee80211_drop_unencrypted_mgmt()
2467 rx->skb->data, in ieee80211_drop_unencrypted_mgmt()
2468 rx->skb->len); in ieee80211_drop_unencrypted_mgmt()
2473 if (unlikely(ieee80211_is_multicast_robust_mgmt_frame(rx->skb) && in ieee80211_drop_unencrypted_mgmt()
2474 ieee80211_get_mmie_keyidx(rx->skb) < 0)) { in ieee80211_drop_unencrypted_mgmt()
2477 cfg80211_rx_unprot_mlme_mgmt(rx->sdata->dev, in ieee80211_drop_unencrypted_mgmt()
2478 rx->skb->data, in ieee80211_drop_unencrypted_mgmt()
2479 rx->skb->len); in ieee80211_drop_unencrypted_mgmt()
2482 if (unlikely(ieee80211_is_beacon(fc) && rx->key && in ieee80211_drop_unencrypted_mgmt()
2483 ieee80211_get_mmie_keyidx(rx->skb) < 0)) { in ieee80211_drop_unencrypted_mgmt()
2484 cfg80211_rx_unprot_mlme_mgmt(rx->sdata->dev, in ieee80211_drop_unencrypted_mgmt()
2485 rx->skb->data, in ieee80211_drop_unencrypted_mgmt()
2486 rx->skb->len); in ieee80211_drop_unencrypted_mgmt()
2493 if (unlikely(ieee80211_is_action(fc) && !rx->key && in ieee80211_drop_unencrypted_mgmt()
2494 ieee80211_is_robust_mgmt_frame(rx->skb))) in ieee80211_drop_unencrypted_mgmt()
2498 if (is_unicast_ether_addr(mgmt->da) && in ieee80211_drop_unencrypted_mgmt()
2499 ieee80211_is_protected_dual_of_public_action(rx->skb)) in ieee80211_drop_unencrypted_mgmt()
2508 ieee80211_is_robust_mgmt_frame(rx->skb) && in ieee80211_drop_unencrypted_mgmt()
2509 (!rx->sta || !test_sta_flag(rx->sta, WLAN_STA_ASSOC))) in ieee80211_drop_unencrypted_mgmt()
2519 struct ieee80211_sub_if_data *sdata = rx->sdata; in __ieee80211_data_to_8023()
2520 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data; in __ieee80211_data_to_8023()
2526 if (ieee80211_has_a4(hdr->frame_control) && in __ieee80211_data_to_8023()
2527 sdata->vif.type == NL80211_IFTYPE_AP_VLAN && !sdata->u.vlan.sta) in __ieee80211_data_to_8023()
2530 if (sdata->vif.type == NL80211_IFTYPE_STATION && in __ieee80211_data_to_8023()
2531 !!sdata->u.mgd.use_4addr != !!ieee80211_has_a4(hdr->frame_control)) { in __ieee80211_data_to_8023()
2532 if (!sdata->u.mgd.use_4addr) in __ieee80211_data_to_8023()
2534 else if (!ether_addr_equal(hdr->addr1, sdata->vif.addr)) in __ieee80211_data_to_8023()
2538 if (is_multicast_ether_addr(hdr->addr1) && in __ieee80211_data_to_8023()
2539 sdata->vif.type == NL80211_IFTYPE_AP_VLAN && sdata->u.vlan.sta) in __ieee80211_data_to_8023()
2542 ret = ieee80211_data_to_8023(rx->skb, sdata->vif.addr, sdata->vif.type); in __ieee80211_data_to_8023()
2546 ehdr = (struct ethhdr *) rx->skb->data; in __ieee80211_data_to_8023()
2547 if (ehdr->h_proto == rx->sdata->control_port_protocol) in __ieee80211_data_to_8023()
2560 /* non-MLO, or MLD address replaced by hardware */ in ieee80211_is_our_addr()
2561 if (ether_addr_equal(sdata->vif.addr, addr)) in ieee80211_is_our_addr()
2564 if (!ieee80211_vif_is_mld(&sdata->vif)) in ieee80211_is_our_addr()
2567 for (link_id = 0; link_id < ARRAY_SIZE(sdata->vif.link_conf); link_id++) { in ieee80211_is_our_addr()
2570 conf = rcu_dereference(sdata->vif.link_conf[link_id]); in ieee80211_is_our_addr()
2574 if (ether_addr_equal(conf->addr, addr)) { in ieee80211_is_our_addr()
2585 * requires that rx->skb is a frame with ethernet header
2591 struct ethhdr *ehdr = (struct ethhdr *) rx->skb->data; in ieee80211_frame_allowed()
2598 if (unlikely(ehdr->h_proto == rx->sdata->control_port_protocol)) in ieee80211_frame_allowed()
2599 return ieee80211_is_our_addr(rx->sdata, ehdr->h_dest, NULL) || in ieee80211_frame_allowed()
2600 ether_addr_equal(ehdr->h_dest, pae_group_addr); in ieee80211_frame_allowed()
2612 struct ieee80211_sub_if_data *sdata = rx->sdata; in ieee80211_deliver_skb_to_local_stack()
2613 struct net_device *dev = sdata->dev; in ieee80211_deliver_skb_to_local_stack()
2615 if (unlikely((skb->protocol == sdata->control_port_protocol || in ieee80211_deliver_skb_to_local_stack()
2616 (skb->protocol == cpu_to_be16(ETH_P_PREAUTH) && in ieee80211_deliver_skb_to_local_stack()
2617 !sdata->control_port_no_preauth)) && in ieee80211_deliver_skb_to_local_stack()
2618 sdata->control_port_over_nl80211)) { in ieee80211_deliver_skb_to_local_stack()
2620 bool noencrypt = !(status->flag & RX_FLAG_DECRYPTED); in ieee80211_deliver_skb_to_local_stack()
2622 cfg80211_rx_control_port(dev, skb, noencrypt, rx->link_id); in ieee80211_deliver_skb_to_local_stack()
2627 memset(skb->cb, 0, sizeof(skb->cb)); in ieee80211_deliver_skb_to_local_stack()
2644 if (unlikely(skb->protocol == sdata->control_port_protocol && in ieee80211_deliver_skb_to_local_stack()
2645 !ether_addr_equal(ehdr->h_dest, sdata->vif.addr))) in ieee80211_deliver_skb_to_local_stack()
2646 ether_addr_copy(ehdr->h_dest, sdata->vif.addr); in ieee80211_deliver_skb_to_local_stack()
2649 if (rx->list) in ieee80211_deliver_skb_to_local_stack()
2650 list_add_tail(&skb->list, rx->list); in ieee80211_deliver_skb_to_local_stack()
2657 * requires that rx->skb is a frame with ethernet header
2662 struct ieee80211_sub_if_data *sdata = rx->sdata; in ieee80211_deliver_skb()
2663 struct net_device *dev = sdata->dev; in ieee80211_deliver_skb()
2665 struct ethhdr *ehdr = (struct ethhdr *) rx->skb->data; in ieee80211_deliver_skb()
2668 skb = rx->skb; in ieee80211_deliver_skb()
2671 dev_sw_netstats_rx_add(dev, skb->len); in ieee80211_deliver_skb()
2673 if (rx->sta) { in ieee80211_deliver_skb()
2676 * for non-QoS-data frames. Here we know it's a data in ieee80211_deliver_skb()
2679 u64_stats_update_begin(&rx->link_sta->rx_stats.syncp); in ieee80211_deliver_skb()
2680 rx->link_sta->rx_stats.msdu[rx->seqno_idx]++; in ieee80211_deliver_skb()
2681 u64_stats_update_end(&rx->link_sta->rx_stats.syncp); in ieee80211_deliver_skb()
2684 if ((sdata->vif.type == NL80211_IFTYPE_AP || in ieee80211_deliver_skb()
2685 sdata->vif.type == NL80211_IFTYPE_AP_VLAN) && in ieee80211_deliver_skb()
2686 !(sdata->flags & IEEE80211_SDATA_DONT_BRIDGE_PACKETS) && in ieee80211_deliver_skb()
2687 ehdr->h_proto != rx->sdata->control_port_protocol && in ieee80211_deliver_skb()
2688 (sdata->vif.type != NL80211_IFTYPE_AP_VLAN || !sdata->u.vlan.sta)) { in ieee80211_deliver_skb()
2689 if (is_multicast_ether_addr(ehdr->h_dest) && in ieee80211_deliver_skb()
2698 dev->name); in ieee80211_deliver_skb()
2699 } else if (!is_multicast_ether_addr(ehdr->h_dest) && in ieee80211_deliver_skb()
2700 !ether_addr_equal(ehdr->h_dest, ehdr->h_source)) { in ieee80211_deliver_skb()
2701 dsta = sta_info_get(sdata, ehdr->h_dest); in ieee80211_deliver_skb()
2718 * frames are required to be aligned to 2-byte boundaries in ieee80211_deliver_skb()
2721 * access fields as 2-byte aligned (e.g. for ether_addr_equal) in ieee80211_deliver_skb()
2725 align = (unsigned long)(skb->data + sizeof(struct ethhdr)) & 3; in ieee80211_deliver_skb()
2731 u8 *data = skb->data; in ieee80211_deliver_skb()
2733 skb->data -= align; in ieee80211_deliver_skb()
2734 memmove(skb->data, data, len); in ieee80211_deliver_skb()
2742 skb->protocol = eth_type_trans(skb, dev); in ieee80211_deliver_skb()
2752 xmit_skb->priority += 256; in ieee80211_deliver_skb()
2753 xmit_skb->protocol = htons(ETH_P_802_3); in ieee80211_deliver_skb()
2765 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; in ieee80211_rx_mesh_fast_forward()
2776 mesh_hdr = (struct ieee80211s_hdr *)(skb->data + sizeof(eth)); in ieee80211_rx_mesh_fast_forward()
2777 if ((mesh_hdr->flags & MESH_FLAGS_AE) == MESH_FLAGS_AE_A5_A6) in ieee80211_rx_mesh_fast_forward()
2778 ether_addr_copy(key.addr, mesh_hdr->eaddr1); in ieee80211_rx_mesh_fast_forward()
2779 else if (!(mesh_hdr->flags & MESH_FLAGS_AE)) in ieee80211_rx_mesh_fast_forward()
2780 ether_addr_copy(key.addr, skb->data); in ieee80211_rx_mesh_fast_forward()
2788 sta = rcu_dereference(entry->mpath->next_hop); in ieee80211_rx_mesh_fast_forward()
2795 tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK; in ieee80211_rx_mesh_fast_forward()
2796 tid_tx = rcu_dereference(sta->ampdu_mlme.tid_tx[tid]); in ieee80211_rx_mesh_fast_forward()
2798 if (!test_bit(HT_AGG_STATE_OPERATIONAL, &tid_tx->state)) in ieee80211_rx_mesh_fast_forward()
2801 if (tid_tx->timeout) in ieee80211_rx_mesh_fast_forward()
2802 tid_tx->last_tx = jiffies; in ieee80211_rx_mesh_fast_forward()
2807 if (ieee80211_get_8023_tunnel_proto(skb->data + hdrlen, in ieee80211_rx_mesh_fast_forward()
2808 &skb->protocol)) in ieee80211_rx_mesh_fast_forward()
2811 skb->protocol = htons(skb->len - hdrlen); in ieee80211_rx_mesh_fast_forward()
2814 skb->dev = sdata->dev; in ieee80211_rx_mesh_fast_forward()
2815 memcpy(ð, skb->data, ETH_HLEN - 2); in ieee80211_rx_mesh_fast_forward()
2817 __ieee80211_xmit_fast(sdata, sta, &entry->fast_tx, skb, tid_tx, in ieee80211_rx_mesh_fast_forward()
2831 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; in ieee80211_rx_mesh_data()
2832 struct ieee80211_local *local = sdata->local; in ieee80211_rx_mesh_data()
2847 if (!ieee80211_vif_is_mesh(&sdata->vif)) in ieee80211_rx_mesh_data()
2853 mesh_hdr = (struct ieee80211s_hdr *)(skb->data + sizeof(*eth)); in ieee80211_rx_mesh_data()
2859 eth = (struct ethhdr *)skb->data; in ieee80211_rx_mesh_data()
2860 multicast = is_multicast_ether_addr(eth->h_dest); in ieee80211_rx_mesh_data()
2863 if (!mesh_hdr->ttl) in ieee80211_rx_mesh_data()
2867 if (is_multicast_ether_addr(eth->h_dest) && in ieee80211_rx_mesh_data()
2868 mesh_rmc_check(sdata, eth->h_source, mesh_hdr)) in ieee80211_rx_mesh_data()
2872 if (sdata->crypto_tx_tailroom_needed_cnt) in ieee80211_rx_mesh_data()
2875 if (mesh_hdr->flags & MESH_FLAGS_AE) { in ieee80211_rx_mesh_data()
2881 proxied_addr = mesh_hdr->eaddr1; in ieee80211_rx_mesh_data()
2882 else if ((mesh_hdr->flags & MESH_FLAGS_AE) == MESH_FLAGS_AE_A5_A6) in ieee80211_rx_mesh_data()
2884 proxied_addr = mesh_hdr->eaddr2; in ieee80211_rx_mesh_data()
2891 mpp_path_add(sdata, proxied_addr, eth->h_source); in ieee80211_rx_mesh_data()
2893 spin_lock_bh(&mppath->state_lock); in ieee80211_rx_mesh_data()
2894 if (!ether_addr_equal(mppath->mpp, eth->h_source)) { in ieee80211_rx_mesh_data()
2895 memcpy(mppath->mpp, eth->h_source, ETH_ALEN); in ieee80211_rx_mesh_data()
2898 mppath->exp_time = jiffies; in ieee80211_rx_mesh_data()
2899 spin_unlock_bh(&mppath->state_lock); in ieee80211_rx_mesh_data()
2910 if (ether_addr_equal(sdata->vif.addr, eth->h_dest)) in ieee80211_rx_mesh_data()
2913 if (!--mesh_hdr->ttl) { in ieee80211_rx_mesh_data()
2921 if (!ifmsh->mshcfg.dot11MeshForwarding) { in ieee80211_rx_mesh_data()
2922 if (is_multicast_ether_addr(eth->h_dest)) in ieee80211_rx_mesh_data()
2928 skb_set_queue_mapping(skb, ieee802_1d_to_ac[skb->priority]); in ieee80211_rx_mesh_data()
2935 eth->h_dest, eth->h_source); in ieee80211_rx_mesh_data()
2938 int extra_head = sizeof(struct ieee80211_hdr) - sizeof(*eth); in ieee80211_rx_mesh_data()
2940 fwd_skb = skb_copy_expand(skb, local->tx_headroom + extra_head + in ieee80211_rx_mesh_data()
2949 if (skb_cow_head(fwd_skb, hdrlen - sizeof(struct ethhdr))) in ieee80211_rx_mesh_data()
2956 fwd_hdr = skb_push(fwd_skb, hdrlen - sizeof(struct ethhdr)); in ieee80211_rx_mesh_data()
2957 memcpy(fwd_hdr, &hdr, hdrlen - 2); in ieee80211_rx_mesh_data()
2963 if (ieee80211_get_8023_tunnel_proto(fwd_skb->data + hdrlen, in ieee80211_rx_mesh_data()
2964 &fwd_skb->protocol)) in ieee80211_rx_mesh_data()
2967 fwd_skb->protocol = htons(fwd_skb->len - hdrlen); in ieee80211_rx_mesh_data()
2972 info->control.flags |= IEEE80211_TX_INTCFL_NEED_TXPROCESSING; in ieee80211_rx_mesh_data()
2973 info->control.vif = &sdata->vif; in ieee80211_rx_mesh_data()
2974 info->control.jiffies = jiffies; in ieee80211_rx_mesh_data()
2975 fwd_skb->dev = sdata->dev; in ieee80211_rx_mesh_data()
2978 memcpy(fwd_hdr->addr2, sdata->vif.addr, ETH_ALEN); in ieee80211_rx_mesh_data()
2987 mesh_path_error_tx(sdata, ifmsh->mshcfg.element_ttl, in ieee80211_rx_mesh_data()
2990 sta->sta.addr); in ieee80211_rx_mesh_data()
3012 struct net_device *dev = rx->sdata->dev; in __ieee80211_rx_h_amsdu()
3013 struct sk_buff *skb = rx->skb; in __ieee80211_rx_h_amsdu()
3014 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; in __ieee80211_rx_h_amsdu()
3015 __le16 fc = hdr->frame_control; in __ieee80211_rx_h_amsdu()
3021 if (unlikely(ieee80211_has_a4(hdr->frame_control))) { in __ieee80211_rx_h_amsdu()
3024 } else switch (rx->sdata->vif.type) { in __ieee80211_rx_h_amsdu()
3030 if (!rx->sta || in __ieee80211_rx_h_amsdu()
3031 !test_sta_flag(rx->sta, WLAN_STA_TDLS_PEER)) in __ieee80211_rx_h_amsdu()
3042 skb->dev = dev; in __ieee80211_rx_h_amsdu()
3046 rx->sdata->vif.addr, in __ieee80211_rx_h_amsdu()
3047 rx->sdata->vif.type, in __ieee80211_rx_h_amsdu()
3051 if (rx->sta->amsdu_mesh_control < 0) { in __ieee80211_rx_h_amsdu()
3052 s8 valid = -1; in __ieee80211_rx_h_amsdu()
3061 valid = -1; in __ieee80211_rx_h_amsdu()
3068 rx->sta->amsdu_mesh_control = valid; in __ieee80211_rx_h_amsdu()
3071 ieee80211_amsdu_to_8023s(skb, &frame_list, dev->dev_addr, in __ieee80211_rx_h_amsdu()
3072 rx->sdata->vif.type, in __ieee80211_rx_h_amsdu()
3073 rx->local->hw.extra_tx_headroom, in __ieee80211_rx_h_amsdu()
3075 rx->sta->amsdu_mesh_control); in __ieee80211_rx_h_amsdu()
3078 rx->skb = __skb_dequeue(&frame_list); in __ieee80211_rx_h_amsdu()
3080 res = ieee80211_rx_mesh_data(rx->sdata, rx->sta, rx->skb); in __ieee80211_rx_h_amsdu()
3097 dev_kfree_skb(rx->skb); in __ieee80211_rx_h_amsdu()
3106 struct sk_buff *skb = rx->skb; in ieee80211_rx_h_amsdu()
3108 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; in ieee80211_rx_h_amsdu()
3109 __le16 fc = hdr->frame_control; in ieee80211_rx_h_amsdu()
3111 if (!(status->rx_flags & IEEE80211_RX_AMSDU)) in ieee80211_rx_h_amsdu()
3120 if (unlikely(ieee80211_has_a4(hdr->frame_control))) { in ieee80211_rx_h_amsdu()
3121 switch (rx->sdata->vif.type) { in ieee80211_rx_h_amsdu()
3123 if (!rx->sdata->u.vlan.sta) in ieee80211_rx_h_amsdu()
3127 if (!rx->sdata->u.mgd.use_4addr) in ieee80211_rx_h_amsdu()
3137 if (is_multicast_ether_addr(hdr->addr1) || !rx->sta) in ieee80211_rx_h_amsdu()
3140 if (rx->key) { in ieee80211_rx_h_amsdu()
3142 * We should not receive A-MSDUs on pre-HT connections, in ieee80211_rx_h_amsdu()
3145 * A-MSDUs or such. in ieee80211_rx_h_amsdu()
3147 switch (rx->key->conf.cipher) { in ieee80211_rx_h_amsdu()
3163 struct ieee80211_sub_if_data *sdata = rx->sdata; in ieee80211_rx_h_data()
3164 struct ieee80211_local *local = rx->local; in ieee80211_rx_h_data()
3165 struct net_device *dev = sdata->dev; in ieee80211_rx_h_data()
3166 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data; in ieee80211_rx_h_data()
3167 __le16 fc = hdr->frame_control; in ieee80211_rx_h_data()
3171 if (unlikely(!ieee80211_is_data(hdr->frame_control))) in ieee80211_rx_h_data()
3174 if (unlikely(!ieee80211_is_data_present(hdr->frame_control))) in ieee80211_rx_h_data()
3178 * Send unexpected-4addr-frame event to hostapd. For older versions, in ieee80211_rx_h_data()
3181 if (ieee80211_has_a4(hdr->frame_control) && in ieee80211_rx_h_data()
3182 sdata->vif.type == NL80211_IFTYPE_AP) { in ieee80211_rx_h_data()
3183 if (rx->sta && in ieee80211_rx_h_data()
3184 !test_and_set_sta_flag(rx->sta, WLAN_STA_4ADDR_EVENT)) in ieee80211_rx_h_data()
3186 rx->sdata->dev, rx->sta->sta.addr, GFP_ATOMIC); in ieee80211_rx_h_data()
3194 res = ieee80211_rx_mesh_data(rx->sdata, rx->sta, rx->skb); in ieee80211_rx_h_data()
3202 if (unlikely(((struct ethhdr *)rx->skb->data)->h_proto == in ieee80211_rx_h_data()
3204 struct ieee80211_tdls_data *tf = (void *)rx->skb->data; in ieee80211_rx_h_data()
3206 if (pskb_may_pull(rx->skb, in ieee80211_rx_h_data()
3208 tf->payload_type == WLAN_TDLS_SNAP_RFTYPE && in ieee80211_rx_h_data()
3209 tf->category == WLAN_CATEGORY_TDLS && in ieee80211_rx_h_data()
3210 (tf->action_code == WLAN_TDLS_CHANNEL_SWITCH_REQUEST || in ieee80211_rx_h_data()
3211 tf->action_code == WLAN_TDLS_CHANNEL_SWITCH_RESPONSE)) { in ieee80211_rx_h_data()
3212 rx->skb->protocol = cpu_to_be16(ETH_P_TDLS); in ieee80211_rx_h_data()
3213 __ieee80211_queue_skb_to_iface(sdata, rx->link_id, in ieee80211_rx_h_data()
3214 rx->sta, rx->skb); in ieee80211_rx_h_data()
3219 if (rx->sdata->vif.type == NL80211_IFTYPE_AP_VLAN && in ieee80211_rx_h_data()
3220 unlikely(port_control) && sdata->bss) { in ieee80211_rx_h_data()
3221 sdata = container_of(sdata->bss, struct ieee80211_sub_if_data, in ieee80211_rx_h_data()
3223 dev = sdata->dev; in ieee80211_rx_h_data()
3224 rx->sdata = sdata; in ieee80211_rx_h_data()
3227 rx->skb->dev = dev; in ieee80211_rx_h_data()
3229 if (!ieee80211_hw_check(&local->hw, SUPPORTS_DYNAMIC_PS) && in ieee80211_rx_h_data()
3230 local->ps_sdata && local->hw.conf.dynamic_ps_timeout > 0 && in ieee80211_rx_h_data()
3232 ((struct ethhdr *)rx->skb->data)->h_dest) && in ieee80211_rx_h_data()
3233 (!local->scanning && in ieee80211_rx_h_data()
3234 !test_bit(SDATA_STATE_OFFCHANNEL, &sdata->state))) in ieee80211_rx_h_data()
3235 mod_timer(&local->dynamic_ps_timer, jiffies + in ieee80211_rx_h_data()
3236 msecs_to_jiffies(local->hw.conf.dynamic_ps_timeout)); in ieee80211_rx_h_data()
3246 struct sk_buff *skb = rx->skb; in ieee80211_rx_h_ctrl()
3247 struct ieee80211_bar *bar = (struct ieee80211_bar *)skb->data; in ieee80211_rx_h_ctrl()
3252 if (likely(!ieee80211_is_ctl(bar->frame_control))) in ieee80211_rx_h_ctrl()
3255 if (ieee80211_is_back_req(bar->frame_control)) { in ieee80211_rx_h_ctrl()
3263 if (!rx->sta) in ieee80211_rx_h_ctrl()
3272 if (!test_bit(tid, rx->sta->ampdu_mlme.agg_session_valid) && in ieee80211_rx_h_ctrl()
3273 !test_and_set_bit(tid, rx->sta->ampdu_mlme.unexpected_agg)) in ieee80211_rx_h_ctrl()
3274 ieee80211_send_delba(rx->sdata, rx->sta->sta.addr, tid, in ieee80211_rx_h_ctrl()
3278 tid_agg_rx = rcu_dereference(rx->sta->ampdu_mlme.tid_rx[tid]); in ieee80211_rx_h_ctrl()
3285 event.u.ba.sta = &rx->sta->sta; in ieee80211_rx_h_ctrl()
3288 if (tid_agg_rx->timeout) in ieee80211_rx_h_ctrl()
3289 mod_timer(&tid_agg_rx->session_timer, in ieee80211_rx_h_ctrl()
3290 TU_TO_EXP_TIME(tid_agg_rx->timeout)); in ieee80211_rx_h_ctrl()
3292 spin_lock(&tid_agg_rx->reorder_lock); in ieee80211_rx_h_ctrl()
3294 ieee80211_release_reorder_frames(rx->sdata, tid_agg_rx, in ieee80211_rx_h_ctrl()
3296 spin_unlock(&tid_agg_rx->reorder_lock); in ieee80211_rx_h_ctrl()
3298 drv_event_callback(rx->local, rx->sdata, &event); in ieee80211_rx_h_ctrl()
3316 struct ieee80211_local *local = sdata->local; in ieee80211_process_sa_query_req()
3320 if (!ether_addr_equal(mgmt->da, sdata->vif.addr)) { in ieee80211_process_sa_query_req()
3325 if (!ether_addr_equal(mgmt->sa, sdata->deflink.u.mgd.bssid) || in ieee80211_process_sa_query_req()
3326 !ether_addr_equal(mgmt->bssid, sdata->deflink.u.mgd.bssid)) { in ieee80211_process_sa_query_req()
3331 if (len < 24 + 1 + sizeof(resp->u.action.u.sa_query)) { in ieee80211_process_sa_query_req()
3336 skb = dev_alloc_skb(sizeof(*resp) + local->hw.extra_tx_headroom); in ieee80211_process_sa_query_req()
3340 skb_reserve(skb, local->hw.extra_tx_headroom); in ieee80211_process_sa_query_req()
3342 memcpy(resp->da, mgmt->sa, ETH_ALEN); in ieee80211_process_sa_query_req()
3343 memcpy(resp->sa, sdata->vif.addr, ETH_ALEN); in ieee80211_process_sa_query_req()
3344 memcpy(resp->bssid, sdata->deflink.u.mgd.bssid, ETH_ALEN); in ieee80211_process_sa_query_req()
3345 resp->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | in ieee80211_process_sa_query_req()
3347 skb_put(skb, 1 + sizeof(resp->u.action.u.sa_query)); in ieee80211_process_sa_query_req()
3348 resp->u.action.category = WLAN_CATEGORY_SA_QUERY; in ieee80211_process_sa_query_req()
3349 resp->u.action.u.sa_query.action = WLAN_ACTION_SA_QUERY_RESPONSE; in ieee80211_process_sa_query_req()
3350 memcpy(resp->u.action.u.sa_query.trans_id, in ieee80211_process_sa_query_req()
3351 mgmt->u.action.u.sa_query.trans_id, in ieee80211_process_sa_query_req()
3360 struct ieee80211_mgmt *mgmt = (void *)rx->skb->data; in ieee80211_rx_check_bss_color_collision()
3365 if (!wiphy_ext_feature_isset(rx->local->hw.wiphy, in ieee80211_rx_check_bss_color_collision()
3369 if (ieee80211_hw_check(&rx->local->hw, DETECTS_COLOR_COLLISION)) in ieee80211_rx_check_bss_color_collision()
3372 bss_conf = rx->link->conf; in ieee80211_rx_check_bss_color_collision()
3373 if (bss_conf->csa_active || bss_conf->color_change_active || in ieee80211_rx_check_bss_color_collision()
3374 !bss_conf->he_bss_color.enabled) in ieee80211_rx_check_bss_color_collision()
3377 baselen = mgmt->u.beacon.variable - rx->skb->data; in ieee80211_rx_check_bss_color_collision()
3378 if (baselen > rx->skb->len) in ieee80211_rx_check_bss_color_collision()
3382 mgmt->u.beacon.variable, in ieee80211_rx_check_bss_color_collision()
3383 rx->skb->len - baselen); in ieee80211_rx_check_bss_color_collision()
3384 if (ie && ie->datalen >= sizeof(struct ieee80211_he_operation) && in ieee80211_rx_check_bss_color_collision()
3385 ie->datalen >= ieee80211_he_oper_size(ie->data + 1)) { in ieee80211_rx_check_bss_color_collision()
3389 he_oper = (void *)(ie->data + 1); in ieee80211_rx_check_bss_color_collision()
3390 if (le32_get_bits(he_oper->he_oper_params, in ieee80211_rx_check_bss_color_collision()
3394 color = le32_get_bits(he_oper->he_oper_params, in ieee80211_rx_check_bss_color_collision()
3396 if (color == bss_conf->he_bss_color.color) in ieee80211_rx_check_bss_color_collision()
3397 ieee80211_obss_color_collision_notify(&rx->sdata->vif, in ieee80211_rx_check_bss_color_collision()
3399 bss_conf->link_id); in ieee80211_rx_check_bss_color_collision()
3406 struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) rx->skb->data; in ieee80211_rx_h_mgmt_check()
3407 struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(rx->skb); in ieee80211_rx_h_mgmt_check()
3409 if (ieee80211_is_s1g_beacon(mgmt->frame_control)) in ieee80211_rx_h_mgmt_check()
3417 if (rx->skb->len < 24) in ieee80211_rx_h_mgmt_check()
3420 if (!ieee80211_is_mgmt(mgmt->frame_control)) in ieee80211_rx_h_mgmt_check()
3424 if (ieee80211_is_action(mgmt->frame_control) && in ieee80211_rx_h_mgmt_check()
3425 rx->skb->len < IEEE80211_MIN_ACTION_SIZE) in ieee80211_rx_h_mgmt_check()
3428 if (rx->sdata->vif.type == NL80211_IFTYPE_AP && in ieee80211_rx_h_mgmt_check()
3429 ieee80211_is_beacon(mgmt->frame_control) && in ieee80211_rx_h_mgmt_check()
3430 !(rx->flags & IEEE80211_RX_BEACON_REPORTED)) { in ieee80211_rx_h_mgmt_check()
3436 if (ieee80211_hw_check(&rx->local->hw, SIGNAL_DBM) && in ieee80211_rx_h_mgmt_check()
3437 !(status->flag & RX_FLAG_NO_SIGNAL_VAL)) in ieee80211_rx_h_mgmt_check()
3438 sig = status->signal; in ieee80211_rx_h_mgmt_check()
3440 cfg80211_report_obss_beacon_khz(rx->local->hw.wiphy, in ieee80211_rx_h_mgmt_check()
3441 rx->skb->data, rx->skb->len, in ieee80211_rx_h_mgmt_check()
3444 rx->flags |= IEEE80211_RX_BEACON_REPORTED; in ieee80211_rx_h_mgmt_check()
3453 struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)rx->skb->data; in ieee80211_process_rx_twt_action()
3454 struct ieee80211_sub_if_data *sdata = rx->sdata; in ieee80211_process_rx_twt_action()
3457 if (sdata->vif.type != NL80211_IFTYPE_AP) in ieee80211_process_rx_twt_action()
3460 if (!rx->local->ops->add_twt_setup) in ieee80211_process_rx_twt_action()
3463 if (!sdata->vif.bss_conf.twt_responder) in ieee80211_process_rx_twt_action()
3466 if (!rx->sta) in ieee80211_process_rx_twt_action()
3469 switch (mgmt->u.action.u.s1g.action_code) { in ieee80211_process_rx_twt_action()
3473 if (rx->skb->len < IEEE80211_MIN_ACTION_SIZE + in ieee80211_process_rx_twt_action()
3479 twt = (void *)mgmt->u.action.u.s1g.variable; in ieee80211_process_rx_twt_action()
3480 if (twt->element_id != WLAN_EID_S1G_TWT) in ieee80211_process_rx_twt_action()
3483 if (rx->skb->len < IEEE80211_MIN_ACTION_SIZE + in ieee80211_process_rx_twt_action()
3485 twt->length) in ieee80211_process_rx_twt_action()
3491 if (rx->skb->len < IEEE80211_MIN_ACTION_SIZE + 2) in ieee80211_process_rx_twt_action()
3505 struct ieee80211_local *local = rx->local; in ieee80211_rx_h_action()
3506 struct ieee80211_sub_if_data *sdata = rx->sdata; in ieee80211_rx_h_action()
3507 struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) rx->skb->data; in ieee80211_rx_h_action()
3508 struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(rx->skb); in ieee80211_rx_h_action()
3509 int len = rx->skb->len; in ieee80211_rx_h_action()
3511 if (!ieee80211_is_action(mgmt->frame_control)) in ieee80211_rx_h_action()
3514 if (!rx->sta && mgmt->u.action.category != WLAN_CATEGORY_PUBLIC && in ieee80211_rx_h_action()
3515 mgmt->u.action.category != WLAN_CATEGORY_SELF_PROTECTED && in ieee80211_rx_h_action()
3516 mgmt->u.action.category != WLAN_CATEGORY_SPECTRUM_MGMT) in ieee80211_rx_h_action()
3519 switch (mgmt->u.action.category) { in ieee80211_rx_h_action()
3522 if (!rx->link_sta->pub->ht_cap.ht_supported) in ieee80211_rx_h_action()
3525 if (sdata->vif.type != NL80211_IFTYPE_STATION && in ieee80211_rx_h_action()
3526 sdata->vif.type != NL80211_IFTYPE_MESH_POINT && in ieee80211_rx_h_action()
3527 sdata->vif.type != NL80211_IFTYPE_AP_VLAN && in ieee80211_rx_h_action()
3528 sdata->vif.type != NL80211_IFTYPE_AP && in ieee80211_rx_h_action()
3529 sdata->vif.type != NL80211_IFTYPE_ADHOC) in ieee80211_rx_h_action()
3536 switch (mgmt->u.action.u.ht_smps.action) { in ieee80211_rx_h_action()
3542 if (sdata->vif.type != NL80211_IFTYPE_AP && in ieee80211_rx_h_action()
3543 sdata->vif.type != NL80211_IFTYPE_AP_VLAN) in ieee80211_rx_h_action()
3547 switch (mgmt->u.action.u.ht_smps.smps_control) { in ieee80211_rx_h_action()
3562 if (rx->link_sta->pub->smps_mode == smps_mode) in ieee80211_rx_h_action()
3564 rx->link_sta->pub->smps_mode = smps_mode; in ieee80211_rx_h_action()
3569 sband = rx->local->hw.wiphy->bands[status->band]; in ieee80211_rx_h_action()
3571 rate_control_rate_update(local, sband, rx->sta, 0, in ieee80211_rx_h_action()
3573 cfg80211_sta_opmode_change_notify(sdata->dev, in ieee80211_rx_h_action()
3574 rx->sta->addr, in ieee80211_rx_h_action()
3581 u8 chanwidth = mgmt->u.action.u.ht_notify_cw.chanwidth; in ieee80211_rx_h_action()
3586 if (!(rx->link_sta->pub->ht_cap.cap & in ieee80211_rx_h_action()
3593 max_bw = ieee80211_sta_cap_rx_bw(rx->link_sta); in ieee80211_rx_h_action()
3596 rx->link_sta->cur_max_bandwidth = max_bw; in ieee80211_rx_h_action()
3597 new_bw = ieee80211_sta_cur_vht_bw(rx->link_sta); in ieee80211_rx_h_action()
3599 if (rx->link_sta->pub->bandwidth == new_bw) in ieee80211_rx_h_action()
3602 rx->link_sta->pub->bandwidth = new_bw; in ieee80211_rx_h_action()
3603 sband = rx->local->hw.wiphy->bands[status->band]; in ieee80211_rx_h_action()
3605 ieee80211_sta_rx_bw_to_chan_width(rx->link_sta); in ieee80211_rx_h_action()
3608 rate_control_rate_update(local, sband, rx->sta, 0, in ieee80211_rx_h_action()
3610 cfg80211_sta_opmode_change_notify(sdata->dev, in ieee80211_rx_h_action()
3611 rx->sta->addr, in ieee80211_rx_h_action()
3625 if (sdata->vif.type != NL80211_IFTYPE_STATION) in ieee80211_rx_h_action()
3627 if (!rx->sta) in ieee80211_rx_h_action()
3629 if (!ether_addr_equal(mgmt->bssid, sdata->deflink.u.mgd.bssid)) in ieee80211_rx_h_action()
3631 if (mgmt->u.action.u.ext_chan_switch.action_code != in ieee80211_rx_h_action()
3639 if (sdata->vif.type != NL80211_IFTYPE_STATION && in ieee80211_rx_h_action()
3640 sdata->vif.type != NL80211_IFTYPE_MESH_POINT && in ieee80211_rx_h_action()
3641 sdata->vif.type != NL80211_IFTYPE_AP_VLAN && in ieee80211_rx_h_action()
3642 sdata->vif.type != NL80211_IFTYPE_AP && in ieee80211_rx_h_action()
3643 sdata->vif.type != NL80211_IFTYPE_ADHOC) in ieee80211_rx_h_action()
3650 switch (mgmt->u.action.u.vht_opmode_notif.action_code) { in ieee80211_rx_h_action()
3667 if (sdata->vif.type != NL80211_IFTYPE_STATION && in ieee80211_rx_h_action()
3668 sdata->vif.type != NL80211_IFTYPE_MESH_POINT && in ieee80211_rx_h_action()
3669 sdata->vif.type != NL80211_IFTYPE_AP_VLAN && in ieee80211_rx_h_action()
3670 sdata->vif.type != NL80211_IFTYPE_AP && in ieee80211_rx_h_action()
3671 sdata->vif.type != NL80211_IFTYPE_ADHOC) in ieee80211_rx_h_action()
3678 switch (mgmt->u.action.u.addba_req.action_code) { in ieee80211_rx_h_action()
3681 sizeof(mgmt->u.action.u.addba_req))) in ieee80211_rx_h_action()
3686 sizeof(mgmt->u.action.u.addba_resp))) in ieee80211_rx_h_action()
3691 sizeof(mgmt->u.action.u.delba))) in ieee80211_rx_h_action()
3704 switch (mgmt->u.action.u.measurement.action_code) { in ieee80211_rx_h_action()
3706 if (status->band != NL80211_BAND_5GHZ) in ieee80211_rx_h_action()
3710 sizeof(mgmt->u.action.u.measurement))) in ieee80211_rx_h_action()
3713 if (sdata->vif.type != NL80211_IFTYPE_STATION) in ieee80211_rx_h_action()
3721 sizeof(mgmt->u.action.u.chan_switch))) in ieee80211_rx_h_action()
3724 if (sdata->vif.type != NL80211_IFTYPE_STATION && in ieee80211_rx_h_action()
3725 sdata->vif.type != NL80211_IFTYPE_ADHOC && in ieee80211_rx_h_action()
3726 sdata->vif.type != NL80211_IFTYPE_MESH_POINT) in ieee80211_rx_h_action()
3729 if (sdata->vif.type == NL80211_IFTYPE_STATION) in ieee80211_rx_h_action()
3730 bssid = sdata->deflink.u.mgd.bssid; in ieee80211_rx_h_action()
3731 else if (sdata->vif.type == NL80211_IFTYPE_ADHOC) in ieee80211_rx_h_action()
3732 bssid = sdata->u.ibss.bssid; in ieee80211_rx_h_action()
3733 else if (sdata->vif.type == NL80211_IFTYPE_MESH_POINT) in ieee80211_rx_h_action()
3734 bssid = mgmt->sa; in ieee80211_rx_h_action()
3738 if (!ether_addr_equal(mgmt->bssid, bssid)) in ieee80211_rx_h_action()
3747 sizeof(mgmt->u.action.u.self_prot.action_code))) in ieee80211_rx_h_action()
3750 switch (mgmt->u.action.u.self_prot.action_code) { in ieee80211_rx_h_action()
3754 if (!ieee80211_vif_is_mesh(&sdata->vif)) in ieee80211_rx_h_action()
3756 if (sdata->u.mesh.user_mpm) in ieee80211_rx_h_action()
3762 if (!ieee80211_vif_is_mesh(&sdata->vif)) in ieee80211_rx_h_action()
3769 sizeof(mgmt->u.action.u.mesh_action.action_code))) in ieee80211_rx_h_action()
3772 if (!ieee80211_vif_is_mesh(&sdata->vif)) in ieee80211_rx_h_action()
3783 switch (mgmt->u.action.u.s1g.action_code) { in ieee80211_rx_h_action()
3798 switch (mgmt->u.action.u.ttlm_req.action_code) { in ieee80211_rx_h_action()
3800 if (sdata->vif.type != NL80211_IFTYPE_STATION) in ieee80211_rx_h_action()
3808 if (sdata->vif.type != NL80211_IFTYPE_STATION) in ieee80211_rx_h_action()
3824 status->rx_flags |= IEEE80211_RX_MALFORMED_ACTION_FRM; in ieee80211_rx_h_action()
3829 if (rx->sta) in ieee80211_rx_h_action()
3830 rx->link_sta->rx_stats.packets++; in ieee80211_rx_h_action()
3831 dev_kfree_skb(rx->skb); in ieee80211_rx_h_action()
3835 ieee80211_queue_skb_to_iface(sdata, rx->link_id, rx->sta, rx->skb); in ieee80211_rx_h_action()
3842 struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(rx->skb); in ieee80211_rx_h_userspace_mgmt()
3845 .buf = rx->skb->data, in ieee80211_rx_h_userspace_mgmt()
3846 .len = rx->skb->len, in ieee80211_rx_h_userspace_mgmt()
3847 .link_id = rx->link_id, in ieee80211_rx_h_userspace_mgmt()
3848 .have_link_id = rx->link_id >= 0, in ieee80211_rx_h_userspace_mgmt()
3851 /* skip known-bad action frames and return them in the next handler */ in ieee80211_rx_h_userspace_mgmt()
3852 if (status->rx_flags & IEEE80211_RX_MALFORMED_ACTION_FRM) in ieee80211_rx_h_userspace_mgmt()
3862 if (ieee80211_hw_check(&rx->local->hw, SIGNAL_DBM) && in ieee80211_rx_h_userspace_mgmt()
3863 !(status->flag & RX_FLAG_NO_SIGNAL_VAL)) in ieee80211_rx_h_userspace_mgmt()
3864 info.sig_dbm = status->signal; in ieee80211_rx_h_userspace_mgmt()
3866 if (ieee80211_is_timing_measurement(rx->skb) || in ieee80211_rx_h_userspace_mgmt()
3867 ieee80211_is_ftm(rx->skb)) { in ieee80211_rx_h_userspace_mgmt()
3868 info.rx_tstamp = ktime_to_ns(skb_hwtstamps(rx->skb)->hwtstamp); in ieee80211_rx_h_userspace_mgmt()
3869 info.ack_tstamp = ktime_to_ns(status->ack_tx_hwtstamp); in ieee80211_rx_h_userspace_mgmt()
3872 if (cfg80211_rx_mgmt_ext(&rx->sdata->wdev, &info)) { in ieee80211_rx_h_userspace_mgmt()
3873 if (rx->sta) in ieee80211_rx_h_userspace_mgmt()
3874 rx->link_sta->rx_stats.packets++; in ieee80211_rx_h_userspace_mgmt()
3875 dev_kfree_skb(rx->skb); in ieee80211_rx_h_userspace_mgmt()
3885 struct ieee80211_sub_if_data *sdata = rx->sdata; in ieee80211_rx_h_action_post_userspace()
3886 struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) rx->skb->data; in ieee80211_rx_h_action_post_userspace()
3887 int len = rx->skb->len; in ieee80211_rx_h_action_post_userspace()
3889 if (!ieee80211_is_action(mgmt->frame_control)) in ieee80211_rx_h_action_post_userspace()
3892 switch (mgmt->u.action.category) { in ieee80211_rx_h_action_post_userspace()
3895 sizeof(mgmt->u.action.u.sa_query))) in ieee80211_rx_h_action_post_userspace()
3898 switch (mgmt->u.action.u.sa_query.action) { in ieee80211_rx_h_action_post_userspace()
3900 if (sdata->vif.type != NL80211_IFTYPE_STATION) in ieee80211_rx_h_action_post_userspace()
3911 if (rx->sta) in ieee80211_rx_h_action_post_userspace()
3912 rx->link_sta->rx_stats.packets++; in ieee80211_rx_h_action_post_userspace()
3913 dev_kfree_skb(rx->skb); in ieee80211_rx_h_action_post_userspace()
3920 struct ieee80211_local *local = rx->local; in ieee80211_rx_h_action_return()
3921 struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) rx->skb->data; in ieee80211_rx_h_action_return()
3923 struct ieee80211_sub_if_data *sdata = rx->sdata; in ieee80211_rx_h_action_return()
3924 struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(rx->skb); in ieee80211_rx_h_action_return()
3926 if (!ieee80211_is_action(mgmt->frame_control)) in ieee80211_rx_h_action_return()
3934 * 802.11-2012 9.24.4. in ieee80211_rx_h_action_return()
3939 if (!(status->rx_flags & IEEE80211_RX_MALFORMED_ACTION_FRM) && in ieee80211_rx_h_action_return()
3940 (sdata->vif.type == NL80211_IFTYPE_AP || in ieee80211_rx_h_action_return()
3941 sdata->vif.type == NL80211_IFTYPE_AP_VLAN)) in ieee80211_rx_h_action_return()
3944 if (is_multicast_ether_addr(mgmt->da)) in ieee80211_rx_h_action_return()
3948 if (mgmt->u.action.category & 0x80) in ieee80211_rx_h_action_return()
3951 nskb = skb_copy_expand(rx->skb, local->hw.extra_tx_headroom, 0, in ieee80211_rx_h_action_return()
3954 struct ieee80211_mgmt *nmgmt = (void *)nskb->data; in ieee80211_rx_h_action_return()
3956 nmgmt->u.action.category |= 0x80; in ieee80211_rx_h_action_return()
3957 memcpy(nmgmt->da, nmgmt->sa, ETH_ALEN); in ieee80211_rx_h_action_return()
3958 memcpy(nmgmt->sa, rx->sdata->vif.addr, ETH_ALEN); in ieee80211_rx_h_action_return()
3960 memset(nskb->cb, 0, sizeof(nskb->cb)); in ieee80211_rx_h_action_return()
3962 if (rx->sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE) { in ieee80211_rx_h_action_return()
3965 info->flags = IEEE80211_TX_CTL_TX_OFFCHAN | in ieee80211_rx_h_action_return()
3968 if (ieee80211_hw_check(&local->hw, QUEUE_CONTROL)) in ieee80211_rx_h_action_return()
3969 info->hw_queue = in ieee80211_rx_h_action_return()
3970 local->hw.offchannel_tx_hw_queue; in ieee80211_rx_h_action_return()
3973 __ieee80211_tx_skb_tid_band(rx->sdata, nskb, 7, -1, in ieee80211_rx_h_action_return()
3974 status->band); in ieee80211_rx_h_action_return()
3983 struct ieee80211_sub_if_data *sdata = rx->sdata; in ieee80211_rx_h_ext()
3984 struct ieee80211_hdr *hdr = (void *)rx->skb->data; in ieee80211_rx_h_ext()
3986 if (!ieee80211_is_ext(hdr->frame_control)) in ieee80211_rx_h_ext()
3989 if (sdata->vif.type != NL80211_IFTYPE_STATION) in ieee80211_rx_h_ext()
3993 ieee80211_queue_skb_to_iface(sdata, rx->link_id, rx->sta, rx->skb); in ieee80211_rx_h_ext()
4001 struct ieee80211_sub_if_data *sdata = rx->sdata; in ieee80211_rx_h_mgmt()
4002 struct ieee80211_mgmt *mgmt = (void *)rx->skb->data; in ieee80211_rx_h_mgmt()
4005 stype = mgmt->frame_control & cpu_to_le16(IEEE80211_FCTL_STYPE); in ieee80211_rx_h_mgmt()
4007 if (!ieee80211_vif_is_mesh(&sdata->vif) && in ieee80211_rx_h_mgmt()
4008 sdata->vif.type != NL80211_IFTYPE_ADHOC && in ieee80211_rx_h_mgmt()
4009 sdata->vif.type != NL80211_IFTYPE_OCB && in ieee80211_rx_h_mgmt()
4010 sdata->vif.type != NL80211_IFTYPE_STATION) in ieee80211_rx_h_mgmt()
4020 if (is_multicast_ether_addr(mgmt->da) && in ieee80211_rx_h_mgmt()
4021 !is_broadcast_ether_addr(mgmt->da)) in ieee80211_rx_h_mgmt()
4025 if (sdata->vif.type != NL80211_IFTYPE_STATION && in ieee80211_rx_h_mgmt()
4026 sdata->vif.type != NL80211_IFTYPE_ADHOC) in ieee80211_rx_h_mgmt()
4032 if (is_multicast_ether_addr(mgmt->da) && in ieee80211_rx_h_mgmt()
4033 !is_broadcast_ether_addr(mgmt->da)) in ieee80211_rx_h_mgmt()
4037 if (sdata->vif.type != NL80211_IFTYPE_STATION) in ieee80211_rx_h_mgmt()
4042 if (sdata->vif.type != NL80211_IFTYPE_ADHOC && in ieee80211_rx_h_mgmt()
4043 sdata->vif.type != NL80211_IFTYPE_MESH_POINT) in ieee80211_rx_h_mgmt()
4050 ieee80211_queue_skb_to_iface(sdata, rx->link_id, rx->sta, rx->skb); in ieee80211_rx_h_mgmt()
4060 struct ieee80211_local *local = rx->local; in ieee80211_rx_cooked_monitor()
4061 struct sk_buff *skb = rx->skb, *skb2; in ieee80211_rx_cooked_monitor()
4070 if (rx->flags & IEEE80211_RX_CMNTR) in ieee80211_rx_cooked_monitor()
4072 rx->flags |= IEEE80211_RX_CMNTR; in ieee80211_rx_cooked_monitor()
4075 if (!local->cooked_mntrs) in ieee80211_rx_cooked_monitor()
4090 skb->ip_summed = CHECKSUM_UNNECESSARY; in ieee80211_rx_cooked_monitor()
4091 skb->pkt_type = PACKET_OTHERHOST; in ieee80211_rx_cooked_monitor()
4092 skb->protocol = htons(ETH_P_802_2); in ieee80211_rx_cooked_monitor()
4094 list_for_each_entry_rcu(sdata, &local->interfaces, list) { in ieee80211_rx_cooked_monitor()
4098 if (sdata->vif.type != NL80211_IFTYPE_MONITOR || in ieee80211_rx_cooked_monitor()
4099 !(sdata->u.mntr.flags & MONITOR_FLAG_COOK_FRAMES)) in ieee80211_rx_cooked_monitor()
4105 skb2->dev = prev_dev; in ieee80211_rx_cooked_monitor()
4110 prev_dev = sdata->dev; in ieee80211_rx_cooked_monitor()
4111 dev_sw_netstats_rx_add(sdata->dev, skb->len); in ieee80211_rx_cooked_monitor()
4115 skb->dev = prev_dev; in ieee80211_rx_cooked_monitor()
4127 struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(rx->skb); in ieee80211_rx_handlers_result()
4132 I802_DEBUG_INC(rx->sdata->local->rx_handlers_queued); in ieee80211_rx_handlers_result()
4137 I802_DEBUG_INC(rx->sdata->local->rx_handlers_drop); in ieee80211_rx_handlers_result()
4138 if (rx->sta) in ieee80211_rx_handlers_result()
4139 rx->link_sta->rx_stats.dropped++; in ieee80211_rx_handlers_result()
4144 kfree_skb_reason(rx->skb, (__force u32)res); in ieee80211_rx_handlers_result()
4148 sband = rx->local->hw.wiphy->bands[status->band]; in ieee80211_rx_handlers_result()
4149 if (status->encoding == RX_ENC_LEGACY) in ieee80211_rx_handlers_result()
4150 rate = &sband->bitrates[status->rate_idx]; in ieee80211_rx_handlers_result()
4174 spin_lock_bh(&rx->local->rx_path_lock); in ieee80211_rx_handlers()
4182 rx->skb = skb; in ieee80211_rx_handlers()
4184 if (WARN_ON_ONCE(!rx->link)) in ieee80211_rx_handlers()
4193 /* must be after MMIC verify so header is counted in MPDU mic */ in ieee80211_rx_handlers()
4197 /* special treatment -- needs the queue */ in ieee80211_rx_handlers()
4216 spin_unlock_bh(&rx->local->rx_path_lock); in ieee80211_rx_handlers()
4250 return !!(sta->valid_links & BIT(link_id)); in ieee80211_rx_is_valid_sta_link_id()
4256 rx->link_id = link_id; in ieee80211_rx_data_set_link()
4257 rx->link = rcu_dereference(rx->sdata->link[link_id]); in ieee80211_rx_data_set_link()
4259 if (!rx->sta) in ieee80211_rx_data_set_link()
4260 return rx->link; in ieee80211_rx_data_set_link()
4262 if (!ieee80211_rx_is_valid_sta_link_id(&rx->sta->sta, link_id)) in ieee80211_rx_data_set_link()
4265 rx->link_sta = rcu_dereference(rx->sta->link[link_id]); in ieee80211_rx_data_set_link()
4267 return rx->link && rx->link_sta; in ieee80211_rx_data_set_link()
4273 rx->link_id = link_id; in ieee80211_rx_data_set_sta()
4274 rx->sta = sta; in ieee80211_rx_data_set_sta()
4277 rx->local = sta->sdata->local; in ieee80211_rx_data_set_sta()
4278 if (!rx->sdata) in ieee80211_rx_data_set_sta()
4279 rx->sdata = sta->sdata; in ieee80211_rx_data_set_sta()
4280 rx->link_sta = &sta->deflink; in ieee80211_rx_data_set_sta()
4282 rx->link_sta = NULL; in ieee80211_rx_data_set_sta()
4286 rx->link = &rx->sdata->deflink; in ieee80211_rx_data_set_sta()
4301 /* This is OK -- must be QoS data frame */ in ieee80211_release_reorder_timeout()
4306 int link_id = -1; in ieee80211_release_reorder_timeout()
4309 if (sta->sta.valid_links) in ieee80211_release_reorder_timeout()
4310 link_id = ffs(sta->sta.valid_links) - 1; in ieee80211_release_reorder_timeout()
4315 tid_agg_rx = rcu_dereference(sta->ampdu_mlme.tid_rx[tid]); in ieee80211_release_reorder_timeout()
4321 spin_lock(&tid_agg_rx->reorder_lock); in ieee80211_release_reorder_timeout()
4322 ieee80211_sta_reorder_release(sta->sdata, tid_agg_rx, &frames); in ieee80211_release_reorder_timeout()
4323 spin_unlock(&tid_agg_rx->reorder_lock); in ieee80211_release_reorder_timeout()
4329 .u.ba.sta = &sta->sta, in ieee80211_release_reorder_timeout()
4346 /* This is OK -- must be QoS data frame */ in ieee80211_mark_rx_ba_filtered_frames()
4359 local = sta->sdata->local; in ieee80211_mark_rx_ba_filtered_frames()
4360 WARN_ONCE(local->hw.max_rx_aggregation_subframes > 64, in ieee80211_mark_rx_ba_filtered_frames()
4362 local->hw.max_rx_aggregation_subframes); in ieee80211_mark_rx_ba_filtered_frames()
4364 if (!ieee80211_rx_data_set_sta(&rx, sta, -1)) in ieee80211_mark_rx_ba_filtered_frames()
4368 tid_agg_rx = rcu_dereference(sta->ampdu_mlme.tid_rx[tid]); in ieee80211_mark_rx_ba_filtered_frames()
4372 spin_lock_bh(&tid_agg_rx->reorder_lock); in ieee80211_mark_rx_ba_filtered_frames()
4378 release = (tid_agg_rx->head_seq_num + tid_agg_rx->buf_size) % in ieee80211_mark_rx_ba_filtered_frames()
4380 ieee80211_release_reorder_frames(sta->sdata, tid_agg_rx, in ieee80211_mark_rx_ba_filtered_frames()
4383 tid_agg_rx->head_seq_num = ssn; in ieee80211_mark_rx_ba_filtered_frames()
4385 ieee80211_release_reorder_frames(sta->sdata, tid_agg_rx, ssn, in ieee80211_mark_rx_ba_filtered_frames()
4390 * it can be tid_agg_rx->buf_size behind and still be valid */ in ieee80211_mark_rx_ba_filtered_frames()
4391 diff = (tid_agg_rx->head_seq_num - ssn) & IEEE80211_SN_MASK; in ieee80211_mark_rx_ba_filtered_frames()
4392 if (diff >= tid_agg_rx->buf_size) { in ieee80211_mark_rx_ba_filtered_frames()
4393 tid_agg_rx->reorder_buf_filtered = 0; in ieee80211_mark_rx_ba_filtered_frames()
4400 for (i = 0; i < tid_agg_rx->buf_size; i++) { in ieee80211_mark_rx_ba_filtered_frames()
4401 int index = (ssn + i) % tid_agg_rx->buf_size; in ieee80211_mark_rx_ba_filtered_frames()
4403 tid_agg_rx->reorder_buf_filtered &= ~BIT_ULL(index); in ieee80211_mark_rx_ba_filtered_frames()
4405 tid_agg_rx->reorder_buf_filtered |= BIT_ULL(index); in ieee80211_mark_rx_ba_filtered_frames()
4409 ieee80211_sta_reorder_release(sta->sdata, tid_agg_rx, &frames); in ieee80211_mark_rx_ba_filtered_frames()
4412 spin_unlock_bh(&tid_agg_rx->reorder_lock); in ieee80211_mark_rx_ba_filtered_frames()
4431 struct ieee80211_sub_if_data *sdata = rx->sdata; in ieee80211_accept_frame()
4432 struct sk_buff *skb = rx->skb; in ieee80211_accept_frame()
4433 struct ieee80211_hdr *hdr = (void *)skb->data; in ieee80211_accept_frame()
4435 u8 *bssid = ieee80211_get_bssid(hdr, skb->len, sdata->vif.type); in ieee80211_accept_frame()
4436 bool multicast = is_multicast_ether_addr(hdr->addr1) || in ieee80211_accept_frame()
4437 ieee80211_is_s1g_beacon(hdr->frame_control); in ieee80211_accept_frame()
4439 switch (sdata->vif.type) { in ieee80211_accept_frame()
4441 if (!bssid && !sdata->u.mgd.use_4addr) in ieee80211_accept_frame()
4443 if (ieee80211_is_first_frag(hdr->seq_ctrl) && in ieee80211_accept_frame()
4444 ieee80211_is_robust_mgmt_frame(skb) && !rx->sta) in ieee80211_accept_frame()
4448 return ieee80211_is_our_addr(sdata, hdr->addr1, &rx->link_id); in ieee80211_accept_frame()
4452 if (ether_addr_equal(sdata->vif.addr, hdr->addr2) || in ieee80211_accept_frame()
4453 ether_addr_equal(sdata->u.ibss.bssid, hdr->addr2) || in ieee80211_accept_frame()
4454 !is_valid_ether_addr(hdr->addr2)) in ieee80211_accept_frame()
4456 if (ieee80211_is_beacon(hdr->frame_control)) in ieee80211_accept_frame()
4458 if (!ieee80211_bssid_match(bssid, sdata->u.ibss.bssid)) in ieee80211_accept_frame()
4461 !ether_addr_equal(sdata->vif.addr, hdr->addr1)) in ieee80211_accept_frame()
4463 if (!rx->sta) { in ieee80211_accept_frame()
4465 if (status->encoding != RX_ENC_LEGACY) in ieee80211_accept_frame()
4468 rate_idx = status->rate_idx; in ieee80211_accept_frame()
4469 ieee80211_ibss_rx_no_sta(sdata, bssid, hdr->addr2, in ieee80211_accept_frame()
4476 if (!ieee80211_is_data_present(hdr->frame_control)) in ieee80211_accept_frame()
4481 !ether_addr_equal(sdata->dev->dev_addr, hdr->addr1)) in ieee80211_accept_frame()
4483 if (!rx->sta) { in ieee80211_accept_frame()
4485 if (status->encoding != RX_ENC_LEGACY) in ieee80211_accept_frame()
4488 rate_idx = status->rate_idx; in ieee80211_accept_frame()
4489 ieee80211_ocb_rx_no_sta(sdata, bssid, hdr->addr2, in ieee80211_accept_frame()
4494 if (ether_addr_equal(sdata->vif.addr, hdr->addr2)) in ieee80211_accept_frame()
4498 return ether_addr_equal(sdata->vif.addr, hdr->addr1); in ieee80211_accept_frame()
4502 return ieee80211_is_our_addr(sdata, hdr->addr1, in ieee80211_accept_frame()
4503 &rx->link_id); in ieee80211_accept_frame()
4514 !ieee80211_is_our_addr(sdata, hdr->addr1, in ieee80211_accept_frame()
4515 &rx->link_id)) in ieee80211_accept_frame()
4517 if (ieee80211_is_public_action(hdr, skb->len)) in ieee80211_accept_frame()
4519 return ieee80211_is_beacon(hdr->frame_control); in ieee80211_accept_frame()
4522 if (!ieee80211_has_tods(hdr->frame_control)) { in ieee80211_accept_frame()
4523 /* ignore data frames to TDLS-peers */ in ieee80211_accept_frame()
4524 if (ieee80211_is_data(hdr->frame_control)) in ieee80211_accept_frame()
4526 /* ignore action frames to TDLS-peers */ in ieee80211_accept_frame()
4527 if (ieee80211_is_action(hdr->frame_control) && in ieee80211_accept_frame()
4529 !ether_addr_equal(bssid, hdr->addr1)) in ieee80211_accept_frame()
4534 * 802.11-2016 Table 9-26 says that for data frames, A1 must be in ieee80211_accept_frame()
4535 * the BSSID - we've checked that already but may have accepted in ieee80211_accept_frame()
4550 if (ieee80211_is_data(hdr->frame_control) && multicast) in ieee80211_accept_frame()
4555 return ieee80211_is_public_action(hdr, skb->len) || in ieee80211_accept_frame()
4556 ieee80211_is_probe_req(hdr->frame_control) || in ieee80211_accept_frame()
4557 ieee80211_is_probe_resp(hdr->frame_control) || in ieee80211_accept_frame()
4558 ieee80211_is_beacon(hdr->frame_control); in ieee80211_accept_frame()
4572 struct ieee80211_sub_if_data *sdata = sta->sdata; in ieee80211_check_fast_rx()
4573 struct ieee80211_local *local = sdata->local; in ieee80211_check_fast_rx()
4576 .dev = sdata->dev, in ieee80211_check_fast_rx()
4577 .vif_type = sdata->vif.type, in ieee80211_check_fast_rx()
4578 .control_port_protocol = sdata->control_port_protocol, in ieee80211_check_fast_rx()
4591 ether_addr_copy(fastrx.vif_addr, sdata->vif.addr); in ieee80211_check_fast_rx()
4593 fastrx.uses_rss = ieee80211_hw_check(&local->hw, USES_RSS); in ieee80211_check_fast_rx()
4595 /* fast-rx doesn't do reordering */ in ieee80211_check_fast_rx()
4596 if (ieee80211_hw_check(&local->hw, AMPDU_AGGREGATION) && in ieee80211_check_fast_rx()
4597 !ieee80211_hw_check(&local->hw, SUPPORTS_REORDERING_BUFFER)) in ieee80211_check_fast_rx()
4600 switch (sdata->vif.type) { in ieee80211_check_fast_rx()
4602 if (sta->sta.tdls) { in ieee80211_check_fast_rx()
4613 if (sdata->u.mgd.use_4addr && !sta->sta.tdls) { in ieee80211_check_fast_rx()
4620 if (!sdata->u.mgd.powersave) in ieee80211_check_fast_rx()
4624 if (ieee80211_hw_check(&local->hw, PS_NULLFUNC_STACK)) in ieee80211_check_fast_rx()
4626 if (ieee80211_hw_check(&local->hw, SUPPORTS_PS) && in ieee80211_check_fast_rx()
4627 !ieee80211_hw_check(&local->hw, SUPPORTS_DYNAMIC_PS)) in ieee80211_check_fast_rx()
4632 /* parallel-rx requires this, at least with calls to in ieee80211_check_fast_rx()
4635 if (!ieee80211_hw_check(&local->hw, AP_LINK_PS)) in ieee80211_check_fast_rx()
4642 !(sdata->flags & IEEE80211_SDATA_DONT_BRIDGE_PACKETS) && in ieee80211_check_fast_rx()
4643 (sdata->vif.type != NL80211_IFTYPE_AP_VLAN || in ieee80211_check_fast_rx()
4644 !sdata->u.vlan.sta); in ieee80211_check_fast_rx()
4646 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN && in ieee80211_check_fast_rx()
4647 sdata->u.vlan.sta) { in ieee80211_check_fast_rx()
4669 key = rcu_dereference(sta->ptk[sta->ptk_idx]); in ieee80211_check_fast_rx()
4671 key = rcu_dereference(sdata->default_unicast_key); in ieee80211_check_fast_rx()
4673 switch (key->conf.cipher) { in ieee80211_check_fast_rx()
4675 /* we don't want to deal with MMIC in fast-rx */ in ieee80211_check_fast_rx()
4690 fastrx.icv_len = key->conf.icv_len; in ieee80211_check_fast_rx()
4702 offload_flags = get_bss_sdata(sdata)->vif.offload_flags; in ieee80211_check_fast_rx()
4711 drv_sta_set_decap_offload(local, sdata, &sta->sta, assign); in ieee80211_check_fast_rx()
4713 spin_lock_bh(&sta->lock); in ieee80211_check_fast_rx()
4714 old = rcu_dereference_protected(sta->fast_rx, true); in ieee80211_check_fast_rx()
4715 rcu_assign_pointer(sta->fast_rx, new); in ieee80211_check_fast_rx()
4716 spin_unlock_bh(&sta->lock); in ieee80211_check_fast_rx()
4726 spin_lock_bh(&sta->lock); in ieee80211_clear_fast_rx()
4727 old = rcu_dereference_protected(sta->fast_rx, true); in ieee80211_clear_fast_rx()
4728 RCU_INIT_POINTER(sta->fast_rx, NULL); in ieee80211_clear_fast_rx()
4729 spin_unlock_bh(&sta->lock); in ieee80211_clear_fast_rx()
4737 struct ieee80211_local *local = sdata->local; in __ieee80211_check_fast_rx_iface()
4740 lockdep_assert_wiphy(local->hw.wiphy); in __ieee80211_check_fast_rx_iface()
4742 list_for_each_entry(sta, &local->sta_list, list) { in __ieee80211_check_fast_rx_iface()
4743 if (sdata != sta->sdata && in __ieee80211_check_fast_rx_iface()
4744 (!sta->sdata->bss || sta->sdata->bss != sdata->bss)) in __ieee80211_check_fast_rx_iface()
4752 struct ieee80211_local *local = sdata->local; in ieee80211_check_fast_rx_iface()
4754 lockdep_assert_wiphy(local->hw.wiphy); in ieee80211_check_fast_rx_iface()
4764 struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(rx->skb); in ieee80211_rx_8023()
4765 struct sta_info *sta = rx->sta; in ieee80211_rx_8023()
4767 struct sk_buff *skb = rx->skb; in ieee80211_rx_8023()
4768 void *sa = skb->data + ETH_ALEN; in ieee80211_rx_8023()
4769 void *da = skb->data; in ieee80211_rx_8023()
4771 if (rx->link_id >= 0) { in ieee80211_rx_8023()
4772 link_sta = rcu_dereference(sta->link[rx->link_id]); in ieee80211_rx_8023()
4774 dev_kfree_skb(rx->skb); in ieee80211_rx_8023()
4778 link_sta = &sta->deflink; in ieee80211_rx_8023()
4781 stats = &link_sta->rx_stats; in ieee80211_rx_8023()
4782 if (fast_rx->uses_rss) in ieee80211_rx_8023()
4783 stats = this_cpu_ptr(link_sta->pcpu_rx_stats); in ieee80211_rx_8023()
4786 if (!(status->flag & RX_FLAG_NO_SIGNAL_VAL)) { in ieee80211_rx_8023()
4787 stats->last_signal = status->signal; in ieee80211_rx_8023()
4788 if (!fast_rx->uses_rss) in ieee80211_rx_8023()
4789 ewma_signal_add(&link_sta->rx_stats_avg.signal, in ieee80211_rx_8023()
4790 -status->signal); in ieee80211_rx_8023()
4793 if (status->chains) { in ieee80211_rx_8023()
4796 stats->chains = status->chains; in ieee80211_rx_8023()
4797 for (i = 0; i < ARRAY_SIZE(status->chain_signal); i++) { in ieee80211_rx_8023()
4798 int signal = status->chain_signal[i]; in ieee80211_rx_8023()
4800 if (!(status->chains & BIT(i))) in ieee80211_rx_8023()
4803 stats->chain_signal_last[i] = signal; in ieee80211_rx_8023()
4804 if (!fast_rx->uses_rss) in ieee80211_rx_8023()
4805 ewma_signal_add(&link_sta->rx_stats_avg.chain_signal[i], in ieee80211_rx_8023()
4806 -signal); in ieee80211_rx_8023()
4811 stats->last_rx = jiffies; in ieee80211_rx_8023()
4812 stats->last_rate = sta_stats_encode_rate(status); in ieee80211_rx_8023()
4814 stats->fragments++; in ieee80211_rx_8023()
4815 stats->packets++; in ieee80211_rx_8023()
4817 skb->dev = fast_rx->dev; in ieee80211_rx_8023()
4819 dev_sw_netstats_rx_add(fast_rx->dev, skb->len); in ieee80211_rx_8023()
4823 * for non-QoS-data frames. Here we know it's a data in ieee80211_rx_8023()
4826 u64_stats_update_begin(&stats->syncp); in ieee80211_rx_8023()
4827 stats->msdu[rx->seqno_idx]++; in ieee80211_rx_8023()
4828 stats->bytes += orig_len; in ieee80211_rx_8023()
4829 u64_stats_update_end(&stats->syncp); in ieee80211_rx_8023()
4831 if (fast_rx->internal_forward) { in ieee80211_rx_8023()
4836 sta_info_get(rx->sdata, da)) { in ieee80211_rx_8023()
4847 xmit_skb->priority += 256; in ieee80211_rx_8023()
4848 xmit_skb->protocol = htons(ETH_P_802_3); in ieee80211_rx_8023()
4859 skb->protocol = eth_type_trans(skb, fast_rx->dev); in ieee80211_rx_8023()
4866 struct sk_buff *skb = rx->skb; in ieee80211_invoke_fast_rx()
4867 struct ieee80211_hdr *hdr = (void *)skb->data; in ieee80211_invoke_fast_rx()
4870 int orig_len = skb->len; in ieee80211_invoke_fast_rx()
4871 int hdrlen = ieee80211_hdrlen(hdr->frame_control); in ieee80211_invoke_fast_rx()
4883 /* for parallel-rx, we need to have DUP_VALIDATED, otherwise we write in ieee80211_invoke_fast_rx()
4887 if (!(status->flag & RX_FLAG_DUP_VALIDATED)) in ieee80211_invoke_fast_rx()
4893 * - PN_VALIDATED: similar, but the implementation is tricky in ieee80211_invoke_fast_rx()
4894 * - DECRYPTED: necessary for PN_VALIDATED in ieee80211_invoke_fast_rx()
4896 if (fast_rx->key && in ieee80211_invoke_fast_rx()
4897 (status->flag & FAST_RX_CRYPT_FLAGS) != FAST_RX_CRYPT_FLAGS) in ieee80211_invoke_fast_rx()
4900 if (unlikely(!ieee80211_is_data_present(hdr->frame_control))) in ieee80211_invoke_fast_rx()
4915 if (!ether_addr_equal(fast_rx->vif_addr, hdr->addr1)) in ieee80211_invoke_fast_rx()
4918 if ((hdr->frame_control & cpu_to_le16(IEEE80211_FCTL_FROMDS | in ieee80211_invoke_fast_rx()
4920 fast_rx->expected_ds_bits) in ieee80211_invoke_fast_rx()
4924 * and strip the IV/MIC if necessary in ieee80211_invoke_fast_rx()
4926 if (fast_rx->key && !(status->flag & RX_FLAG_IV_STRIPPED)) { in ieee80211_invoke_fast_rx()
4931 if (!ieee80211_vif_is_mesh(&rx->sdata->vif) && in ieee80211_invoke_fast_rx()
4932 !(status->rx_flags & IEEE80211_RX_AMSDU)) { in ieee80211_invoke_fast_rx()
4936 payload = (void *)(skb->data + snap_offs); in ieee80211_invoke_fast_rx()
4938 if (!ether_addr_equal(payload->snap, fast_rx->rfc1042_hdr)) in ieee80211_invoke_fast_rx()
4943 * bridge-tunnel header - but if we get them this way then in ieee80211_invoke_fast_rx()
4946 if (unlikely(payload->proto == cpu_to_be16(ETH_P_TDLS) || in ieee80211_invoke_fast_rx()
4947 payload->proto == fast_rx->control_port_protocol)) in ieee80211_invoke_fast_rx()
4953 if (rx->key && !(status->flag & RX_FLAG_MIC_STRIPPED) && in ieee80211_invoke_fast_rx()
4954 pskb_trim(skb, skb->len - fast_rx->icv_len)) in ieee80211_invoke_fast_rx()
4957 if (rx->key && !ieee80211_has_protected(hdr->frame_control)) in ieee80211_invoke_fast_rx()
4960 if (status->rx_flags & IEEE80211_RX_AMSDU) { in ieee80211_invoke_fast_rx()
4961 if (__ieee80211_rx_h_amsdu(rx, snap_offs - hdrlen) != in ieee80211_invoke_fast_rx()
4968 /* do the header conversion - first grab the addresses */ in ieee80211_invoke_fast_rx()
4969 ether_addr_copy(addrs.da, skb->data + fast_rx->da_offs); in ieee80211_invoke_fast_rx()
4970 ether_addr_copy(addrs.sa, skb->data + fast_rx->sa_offs); in ieee80211_invoke_fast_rx()
4971 if (ieee80211_vif_is_mesh(&rx->sdata->vif)) { in ieee80211_invoke_fast_rx()
4972 skb_pull(skb, snap_offs - 2); in ieee80211_invoke_fast_rx()
4973 put_unaligned_be16(skb->len - 2, skb->data); in ieee80211_invoke_fast_rx()
4975 skb_postpull_rcsum(skb, skb->data + snap_offs, in ieee80211_invoke_fast_rx()
4984 res = ieee80211_rx_mesh_data(rx->sdata, rx->sta, rx->skb); in ieee80211_invoke_fast_rx()
5000 if (fast_rx->uses_rss) in ieee80211_invoke_fast_rx()
5001 stats = this_cpu_ptr(rx->link_sta->pcpu_rx_stats); in ieee80211_invoke_fast_rx()
5003 stats = &rx->link_sta->rx_stats; in ieee80211_invoke_fast_rx()
5005 stats->dropped++; in ieee80211_invoke_fast_rx()
5018 struct ieee80211_local *local = rx->local; in ieee80211_prepare_and_rx_handle()
5019 struct ieee80211_sub_if_data *sdata = rx->sdata; in ieee80211_prepare_and_rx_handle()
5020 struct ieee80211_hdr *hdr = (void *)skb->data; in ieee80211_prepare_and_rx_handle()
5021 struct link_sta_info *link_sta = rx->link_sta; in ieee80211_prepare_and_rx_handle()
5022 struct ieee80211_link_data *link = rx->link; in ieee80211_prepare_and_rx_handle()
5024 rx->skb = skb; in ieee80211_prepare_and_rx_handle()
5026 /* See if we can do fast-rx; if we have to copy we already lost, in ieee80211_prepare_and_rx_handle()
5033 if (consume && rx->sta) { in ieee80211_prepare_and_rx_handle()
5036 fast_rx = rcu_dereference(rx->sta->fast_rx); in ieee80211_prepare_and_rx_handle()
5047 rx->skb = skb_copy(skb, GFP_ATOMIC); in ieee80211_prepare_and_rx_handle()
5048 if (!rx->skb) { in ieee80211_prepare_and_rx_handle()
5050 wiphy_debug(local->hw.wiphy, in ieee80211_prepare_and_rx_handle()
5052 sdata->name); in ieee80211_prepare_and_rx_handle()
5059 shwt = skb_hwtstamps(rx->skb); in ieee80211_prepare_and_rx_handle()
5060 shwt->hwtstamp = skb_hwtstamps(skb)->hwtstamp; in ieee80211_prepare_and_rx_handle()
5063 hdr = (struct ieee80211_hdr *)rx->skb->data; in ieee80211_prepare_and_rx_handle()
5066 if (unlikely(rx->sta && rx->sta->sta.mlo) && in ieee80211_prepare_and_rx_handle()
5067 is_unicast_ether_addr(hdr->addr1) && in ieee80211_prepare_and_rx_handle()
5068 !ieee80211_is_probe_resp(hdr->frame_control) && in ieee80211_prepare_and_rx_handle()
5069 !ieee80211_is_beacon(hdr->frame_control)) { in ieee80211_prepare_and_rx_handle()
5071 if (ether_addr_equal(link->conf->addr, hdr->addr1)) in ieee80211_prepare_and_rx_handle()
5072 ether_addr_copy(hdr->addr1, rx->sdata->vif.addr); in ieee80211_prepare_and_rx_handle()
5073 if (ether_addr_equal(link_sta->addr, hdr->addr2)) in ieee80211_prepare_and_rx_handle()
5074 ether_addr_copy(hdr->addr2, rx->sta->addr); in ieee80211_prepare_and_rx_handle()
5076 if (!ieee80211_has_tods(hdr->frame_control) && in ieee80211_prepare_and_rx_handle()
5077 !ieee80211_has_fromds(hdr->frame_control)) { in ieee80211_prepare_and_rx_handle()
5078 if (ether_addr_equal(link_sta->addr, hdr->addr3)) in ieee80211_prepare_and_rx_handle()
5079 ether_addr_copy(hdr->addr3, rx->sta->addr); in ieee80211_prepare_and_rx_handle()
5080 else if (ether_addr_equal(link->conf->addr, hdr->addr3)) in ieee80211_prepare_and_rx_handle()
5081 ether_addr_copy(hdr->addr3, rx->sdata->vif.addr); in ieee80211_prepare_and_rx_handle()
5100 int link_id = -1; in __ieee80211_rx_handle_8023()
5106 rx.link_id = -1; in __ieee80211_rx_handle_8023()
5108 I802_DEBUG_INC(local->dot11ReceivedFragmentCount); in __ieee80211_rx_handle_8023()
5111 if (skb->len < sizeof(struct ethhdr)) in __ieee80211_rx_handle_8023()
5117 if (status->link_valid) in __ieee80211_rx_handle_8023()
5118 link_id = status->link_id; in __ieee80211_rx_handle_8023()
5131 fast_rx = rcu_dereference(rx.sta->fast_rx); in __ieee80211_rx_handle_8023()
5135 ieee80211_rx_8023(&rx, fast_rx, skb->len); in __ieee80211_rx_handle_8023()
5146 struct ieee80211_hdr *hdr = (void *)skb->data; in ieee80211_rx_for_interface()
5148 int link_id = -1; in ieee80211_rx_for_interface()
5156 link_sta = link_sta_info_get_bss(rx->sdata, hdr->addr2); in ieee80211_rx_for_interface()
5158 sta = link_sta->sta; in ieee80211_rx_for_interface()
5159 link_id = link_sta->link_id; in ieee80211_rx_for_interface()
5163 sta = sta_info_get_bss(rx->sdata, hdr->addr2); in ieee80211_rx_for_interface()
5164 if (status->link_valid) in ieee80211_rx_for_interface()
5165 link_id = status->link_id; in ieee80211_rx_for_interface()
5193 fc = ((struct ieee80211_hdr *)skb->data)->frame_control; in __ieee80211_rx_handle_packet()
5198 rx.link_id = -1; in __ieee80211_rx_handle_packet()
5201 I802_DEBUG_INC(local->dot11ReceivedFragmentCount); in __ieee80211_rx_handle_packet()
5205 if (skb->len < ieee80211_hdrlen(fc)) in __ieee80211_rx_handle_packet()
5206 err = -ENOBUFS; in __ieee80211_rx_handle_packet()
5218 hdr = (struct ieee80211_hdr *)skb->data; in __ieee80211_rx_handle_packet()
5222 if (unlikely(ieee80211_is_probe_resp(hdr->frame_control) || in __ieee80211_rx_handle_packet()
5223 ieee80211_is_beacon(hdr->frame_control) || in __ieee80211_rx_handle_packet()
5224 ieee80211_is_s1g_beacon(hdr->frame_control))) in __ieee80211_rx_handle_packet()
5229 int link_id = -1; in __ieee80211_rx_handle_packet()
5231 if (status->link_valid) in __ieee80211_rx_handle_packet()
5232 link_id = status->link_id; in __ieee80211_rx_handle_packet()
5247 if (!status->link_valid && pubsta->mlo) { in __ieee80211_rx_handle_packet()
5251 hdr->addr2); in __ieee80211_rx_handle_packet()
5255 ieee80211_rx_data_set_link(&rx, link_sta->link_id); in __ieee80211_rx_handle_packet()
5265 for_each_sta_info(local, hdr->addr2, sta, tmp) { in __ieee80211_rx_handle_packet()
5271 rx.sdata = prev_sta->sdata; in __ieee80211_rx_handle_packet()
5275 if (!status->link_valid && prev_sta->sta.mlo) in __ieee80211_rx_handle_packet()
5284 rx.sdata = prev_sta->sdata; in __ieee80211_rx_handle_packet()
5288 if (!status->link_valid && prev_sta->sta.mlo) in __ieee80211_rx_handle_packet()
5299 list_for_each_entry_rcu(sdata, &local->interfaces, list) { in __ieee80211_rx_handle_packet()
5303 if (sdata->vif.type == NL80211_IFTYPE_MONITOR || in __ieee80211_rx_handle_packet()
5304 sdata->vif.type == NL80211_IFTYPE_AP_VLAN) in __ieee80211_rx_handle_packet()
5346 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; in ieee80211_rx_list()
5350 if (WARN_ON(status->band >= NUM_NL80211_BANDS)) in ieee80211_rx_list()
5353 sband = local->hw.wiphy->bands[status->band]; in ieee80211_rx_list()
5364 if (unlikely(local->quiescing || local->suspended)) in ieee80211_rx_list()
5368 if (unlikely(local->in_reconfig)) in ieee80211_rx_list()
5375 if (WARN_ON(!local->started)) in ieee80211_rx_list()
5378 if (likely(!(status->flag & RX_FLAG_FAILED_PLCP_CRC))) { in ieee80211_rx_list()
5384 switch (status->encoding) { in ieee80211_rx_list()
5387 * rate_idx is MCS index, which can be [0-76] in ieee80211_rx_list()
5396 if (WARN(status->rate_idx > 76, in ieee80211_rx_list()
5398 "status->rate_idx is not " in ieee80211_rx_list()
5399 "an MCS index [0-76]: %d (0x%02x)\n", in ieee80211_rx_list()
5400 status->rate_idx, in ieee80211_rx_list()
5401 status->rate_idx)) in ieee80211_rx_list()
5405 if (WARN_ONCE(status->rate_idx > 11 || in ieee80211_rx_list()
5406 !status->nss || in ieee80211_rx_list()
5407 status->nss > 8, in ieee80211_rx_list()
5409 status->rate_idx, status->nss)) in ieee80211_rx_list()
5413 if (WARN_ONCE(status->rate_idx > 11 || in ieee80211_rx_list()
5414 !status->nss || in ieee80211_rx_list()
5415 status->nss > 8, in ieee80211_rx_list()
5417 status->rate_idx, status->nss)) in ieee80211_rx_list()
5421 if (WARN_ONCE(status->rate_idx > 15 || in ieee80211_rx_list()
5422 !status->nss || in ieee80211_rx_list()
5423 status->nss > 8 || in ieee80211_rx_list()
5424 status->eht.gi > NL80211_RATE_INFO_EHT_GI_3_2, in ieee80211_rx_list()
5426 status->rate_idx, status->nss, status->eht.gi)) in ieee80211_rx_list()
5433 if (WARN_ON(status->rate_idx >= sband->n_bitrates)) in ieee80211_rx_list()
5435 rate = &sband->bitrates[status->rate_idx]; in ieee80211_rx_list()
5439 if (WARN_ON_ONCE(status->link_id >= IEEE80211_LINK_UNSPECIFIED)) in ieee80211_rx_list()
5442 status->rx_flags = 0; in ieee80211_rx_list()
5452 if (!(status->flag & RX_FLAG_8023)) in ieee80211_rx_list()
5455 if ((status->flag & RX_FLAG_8023) || in ieee80211_rx_list()
5456 ieee80211_is_data_present(hdr->frame_control)) in ieee80211_rx_list()
5457 ieee80211_tpt_led_trig_rx(local, skb->len); in ieee80211_rx_list()
5459 if (status->flag & RX_FLAG_8023) in ieee80211_rx_list()
5481 * and this requires that we are in a read-side RCU section during in ieee80211_rx_napi()
5506 BUILD_BUG_ON(sizeof(struct ieee80211_rx_status) > sizeof(skb->cb)); in ieee80211_rx_irqsafe()
5508 skb->pkt_type = IEEE80211_RX_MSG; in ieee80211_rx_irqsafe()
5509 skb_queue_tail(&local->skb_queue, skb); in ieee80211_rx_irqsafe()
5510 tasklet_schedule(&local->tasklet); in ieee80211_rx_irqsafe()