1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 /* 3 * Copyright 2002-2005, Instant802 Networks, Inc. 4 * Copyright 2005, Devicescape Software, Inc. 5 * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz> 6 * Copyright 2007-2010 Johannes Berg <johannes@sipsolutions.net> 7 * Copyright 2013-2015 Intel Mobile Communications GmbH 8 * Copyright (C) 2018-2026 Intel Corporation 9 */ 10 11 #ifndef IEEE80211_I_H 12 #define IEEE80211_I_H 13 14 #include <linux/kernel.h> 15 #include <linux/device.h> 16 #include <linux/if_ether.h> 17 #include <linux/interrupt.h> 18 #include <linux/list.h> 19 #include <linux/netdevice.h> 20 #include <linux/skbuff.h> 21 #include <linux/workqueue.h> 22 #include <linux/types.h> 23 #include <linux/spinlock.h> 24 #include <linux/etherdevice.h> 25 #include <linux/leds.h> 26 #include <linux/idr.h> 27 #include <linux/rhashtable.h> 28 #include <linux/rbtree.h> 29 #include <kunit/visibility.h> 30 #include <net/ieee80211_radiotap.h> 31 #include <net/cfg80211.h> 32 #include <net/mac80211.h> 33 #include <net/fq.h> 34 #include "key.h" 35 #include "sta_info.h" 36 #include "debug.h" 37 #include "drop.h" 38 39 extern const struct cfg80211_ops mac80211_config_ops; 40 41 struct ieee80211_local; 42 struct ieee80211_mesh_fast_tx; 43 44 /* Maximum number of broadcast/multicast frames to buffer when some of the 45 * associated stations are using power saving. */ 46 #define AP_MAX_BC_BUFFER 128 47 48 /* Maximum number of frames buffered to all STAs, including multicast frames. 49 * Note: increasing this limit increases the potential memory requirement. Each 50 * frame can be up to about 2 kB long. */ 51 #define TOTAL_MAX_TX_BUFFER 512 52 53 /* Required encryption head and tailroom */ 54 #define IEEE80211_ENCRYPT_HEADROOM 8 55 #define IEEE80211_ENCRYPT_TAILROOM 18 56 57 /* power level hasn't been configured (or set to automatic) */ 58 #define IEEE80211_UNSET_POWER_LEVEL INT_MIN 59 60 /* 61 * Some APs experience problems when working with U-APSD. Decreasing the 62 * probability of that happening by using legacy mode for all ACs but VO isn't 63 * enough. 64 * 65 * Cisco 4410N originally forced us to enable VO by default only because it 66 * treated non-VO ACs as legacy. 67 * 68 * However some APs (notably Netgear R7000) silently reclassify packets to 69 * different ACs. Since u-APSD ACs require trigger frames for frame retrieval 70 * clients would never see some frames (e.g. ARP responses) or would fetch them 71 * accidentally after a long time. 72 * 73 * It makes little sense to enable u-APSD queues by default because it needs 74 * userspace applications to be aware of it to actually take advantage of the 75 * possible additional powersavings. Implicitly depending on driver autotrigger 76 * frame support doesn't make much sense. 77 */ 78 #define IEEE80211_DEFAULT_UAPSD_QUEUES 0 79 80 #define IEEE80211_DEFAULT_MAX_SP_LEN \ 81 IEEE80211_WMM_IE_STA_QOSINFO_SP_ALL 82 83 extern const u8 ieee80211_ac_to_qos_mask[IEEE80211_NUM_ACS]; 84 85 #define IEEE80211_DEAUTH_FRAME_LEN (24 /* hdr */ + 2 /* reason */) 86 87 #define IEEE80211_MAX_NAN_INSTANCE_ID 255 88 89 /* 90 * Current mac80211 implementation supports a maximum of 1600 AIDS 91 * for S1G interfaces. With regards to an S1G TIM, this covers 25 blocks 92 * as each block is 64 AIDs. 93 */ 94 #define IEEE80211_MAX_SUPPORTED_S1G_AID 1600 95 #define IEEE80211_MAX_SUPPORTED_S1G_TIM_BLOCKS 25 96 97 enum ieee80211_status_data { 98 IEEE80211_STATUS_TYPE_MASK = 0x00f, 99 IEEE80211_STATUS_TYPE_INVALID = 0, 100 IEEE80211_STATUS_TYPE_SMPS = 1, 101 IEEE80211_STATUS_TYPE_NEG_TTLM = 2, 102 IEEE80211_STATUS_TYPE_UHR_OMP = 3, 103 IEEE80211_STATUS_SUBDATA_MASK = 0x1ff0, 104 }; 105 106 static inline bool 107 ieee80211_sta_keep_active(struct sta_info *sta, u8 ac) 108 { 109 /* Keep a station's queues on the active list for deficit accounting 110 * purposes if it was active or queued during the last 100ms. 111 */ 112 return time_before_eq(jiffies, sta->airtime[ac].last_active + HZ / 10); 113 } 114 115 struct ieee80211_bss { 116 u32 device_ts_beacon, device_ts_presp; 117 118 bool wmm_used; 119 bool uapsd_supported; 120 121 #define IEEE80211_MAX_SUPP_RATES 32 122 u8 supp_rates[IEEE80211_MAX_SUPP_RATES]; 123 size_t supp_rates_len; 124 struct ieee80211_rate *beacon_rate; 125 126 u32 vht_cap_info; 127 128 /* 129 * During association, we save an ERP value from a probe response so 130 * that we can feed ERP info to the driver when handling the 131 * association completes. these fields probably won't be up-to-date 132 * otherwise, you probably don't want to use them. 133 */ 134 bool has_erp_value; 135 u8 erp_value; 136 137 /* Keep track of the corruption of the last beacon/probe response. */ 138 u8 corrupt_data; 139 140 /* Keep track of what bits of information we have valid info for. */ 141 u8 valid_data; 142 }; 143 144 /** 145 * enum ieee80211_bss_corrupt_data_flags - BSS data corruption flags 146 * @IEEE80211_BSS_CORRUPT_BEACON: last beacon frame received was corrupted 147 * @IEEE80211_BSS_CORRUPT_PROBE_RESP: last probe response received was corrupted 148 * 149 * These are bss flags that are attached to a bss in the 150 * @corrupt_data field of &struct ieee80211_bss. 151 */ 152 enum ieee80211_bss_corrupt_data_flags { 153 IEEE80211_BSS_CORRUPT_BEACON = BIT(0), 154 IEEE80211_BSS_CORRUPT_PROBE_RESP = BIT(1) 155 }; 156 157 /** 158 * enum ieee80211_bss_valid_data_flags - BSS valid data flags 159 * @IEEE80211_BSS_VALID_WMM: WMM/UAPSD data was gathered from non-corrupt IE 160 * @IEEE80211_BSS_VALID_RATES: Supported rates were gathered from non-corrupt IE 161 * @IEEE80211_BSS_VALID_ERP: ERP flag was gathered from non-corrupt IE 162 * 163 * These are bss flags that are attached to a bss in the 164 * @valid_data field of &struct ieee80211_bss. They show which parts 165 * of the data structure were received as a result of an un-corrupted 166 * beacon/probe response. 167 */ 168 enum ieee80211_bss_valid_data_flags { 169 IEEE80211_BSS_VALID_WMM = BIT(1), 170 IEEE80211_BSS_VALID_RATES = BIT(2), 171 IEEE80211_BSS_VALID_ERP = BIT(3) 172 }; 173 174 typedef unsigned __bitwise ieee80211_tx_result; 175 #define TX_CONTINUE ((__force ieee80211_tx_result) 0u) 176 #define TX_DROP ((__force ieee80211_tx_result) 1u) 177 #define TX_QUEUED ((__force ieee80211_tx_result) 2u) 178 179 #define IEEE80211_TX_UNICAST BIT(1) 180 #define IEEE80211_TX_PS_BUFFERED BIT(2) 181 182 struct ieee80211_tx_data { 183 struct sk_buff *skb; 184 struct sk_buff_head skbs; 185 struct ieee80211_local *local; 186 struct ieee80211_sub_if_data *sdata; 187 struct sta_info *sta; 188 struct ieee80211_key *key; 189 struct ieee80211_tx_rate rate; 190 191 unsigned int flags; 192 }; 193 194 /** 195 * enum ieee80211_packet_rx_flags - packet RX flags 196 * @IEEE80211_RX_AMSDU: a-MSDU packet 197 * @IEEE80211_RX_MALFORMED_ACTION_FRM: action frame is malformed 198 * @IEEE80211_RX_DEFERRED_RELEASE: frame was subjected to receive reordering 199 * 200 * These are per-frame flags that are attached to a frame in the 201 * @rx_flags field of &struct ieee80211_rx_status. 202 */ 203 enum ieee80211_packet_rx_flags { 204 IEEE80211_RX_AMSDU = BIT(3), 205 IEEE80211_RX_MALFORMED_ACTION_FRM = BIT(4), 206 IEEE80211_RX_DEFERRED_RELEASE = BIT(5), 207 }; 208 209 /** 210 * enum ieee80211_rx_flags - RX data flags 211 * 212 * @IEEE80211_RX_BEACON_REPORTED: This frame was already reported 213 * to cfg80211_report_obss_beacon(). 214 * 215 * These flags are used across handling multiple interfaces 216 * for a single frame. 217 */ 218 enum ieee80211_rx_flags { 219 IEEE80211_RX_BEACON_REPORTED = BIT(0), 220 }; 221 222 struct ieee80211_rx_data { 223 struct list_head *list; 224 struct sk_buff *skb; 225 struct ieee80211_local *local; 226 struct ieee80211_sub_if_data *sdata; 227 struct ieee80211_link_data *link; 228 struct sta_info *sta; 229 struct link_sta_info *link_sta; 230 struct ieee80211_key *key; 231 232 unsigned int flags; 233 234 /* 235 * Index into sequence numbers array, 0..16 236 * since the last (16) is used for non-QoS, 237 * will be 16 on non-QoS frames. 238 */ 239 int seqno_idx; 240 241 /* 242 * Index into the security IV/PN arrays, 0..16 243 * since the last (16) is used for CCMP-encrypted 244 * management frames, will be set to 16 on mgmt 245 * frames and 0 on non-QoS frames. 246 */ 247 int security_idx; 248 249 int link_id; 250 251 union { 252 struct { 253 u32 iv32; 254 u16 iv16; 255 } tkip; 256 struct { 257 u8 pn[IEEE80211_CCMP_PN_LEN]; 258 } ccm_gcm; 259 }; 260 261 u8 link_addrs[3 * ETH_ALEN]; 262 }; 263 264 struct ieee80211_csa_settings { 265 const u16 *counter_offsets_beacon; 266 const u16 *counter_offsets_presp; 267 268 int n_counter_offsets_beacon; 269 int n_counter_offsets_presp; 270 271 u8 count; 272 }; 273 274 struct ieee80211_color_change_settings { 275 u16 counter_offset_beacon; 276 u16 counter_offset_presp; 277 u8 count; 278 }; 279 280 struct beacon_data { 281 u8 *head, *tail; 282 int head_len, tail_len; 283 struct ieee80211_meshconf_ie *meshconf; 284 u16 cntdwn_counter_offsets[IEEE80211_MAX_CNTDWN_COUNTERS_NUM]; 285 u8 cntdwn_current_counter; 286 struct cfg80211_mbssid_elems *mbssid_ies; 287 struct cfg80211_rnr_elems *rnr_ies; 288 struct rcu_head rcu_head; 289 }; 290 291 struct probe_resp { 292 struct rcu_head rcu_head; 293 int len; 294 u16 cntdwn_counter_offsets[IEEE80211_MAX_CNTDWN_COUNTERS_NUM]; 295 u8 data[]; 296 }; 297 298 struct fils_discovery_data { 299 struct rcu_head rcu_head; 300 int len; 301 u8 data[]; 302 }; 303 304 struct unsol_bcast_probe_resp_data { 305 struct rcu_head rcu_head; 306 int len; 307 u8 data[]; 308 }; 309 310 struct s1g_short_beacon_data { 311 struct rcu_head rcu_head; 312 u8 *short_head; 313 u8 *short_tail; 314 int short_head_len; 315 int short_tail_len; 316 }; 317 318 struct ps_data { 319 /* yes, this looks ugly, but guarantees that we can later use 320 * bitmap_empty :) 321 * NB: don't touch this bitmap, use sta_info_{set,clear}_tim_bit */ 322 u8 tim[sizeof(unsigned long) * BITS_TO_LONGS(IEEE80211_MAX_AID + 1)] 323 __aligned(__alignof__(unsigned long)); 324 struct sk_buff_head bc_buf; 325 atomic_t num_sta_ps; /* number of stations in PS mode */ 326 int dtim_count; 327 bool dtim_bc_mc; 328 int sb_count; /* num short beacons til next long beacon */ 329 }; 330 331 struct ieee80211_if_ap { 332 struct list_head vlans; /* write-protected with RTNL and local->mtx */ 333 334 struct ps_data ps; 335 atomic_t num_mcast_sta; /* number of stations receiving multicast */ 336 337 bool multicast_to_unicast; 338 bool active; 339 }; 340 341 struct ieee80211_if_vlan { 342 struct list_head list; /* write-protected with RTNL and local->mtx */ 343 344 /* used for all tx if the VLAN is configured to 4-addr mode */ 345 struct sta_info __rcu *sta; 346 atomic_t num_mcast_sta; /* number of stations receiving multicast */ 347 }; 348 349 struct mesh_stats { 350 __u32 fwded_mcast; /* Mesh forwarded multicast frames */ 351 __u32 fwded_unicast; /* Mesh forwarded unicast frames */ 352 __u32 fwded_frames; /* Mesh total forwarded frames */ 353 __u32 dropped_frames_ttl; /* Not transmitted since mesh_ttl == 0*/ 354 __u32 dropped_frames_no_route; /* Not transmitted, no route found */ 355 }; 356 357 #define PREQ_Q_F_START 0x1 358 #define PREQ_Q_F_REFRESH 0x2 359 struct mesh_preq_queue { 360 struct list_head list; 361 u8 dst[ETH_ALEN]; 362 u8 flags; 363 }; 364 365 struct ieee80211_roc_work { 366 struct list_head list; 367 368 struct ieee80211_sub_if_data *sdata; 369 370 struct ieee80211_channel *chan; 371 372 bool started, abort, hw_begun, notified; 373 bool on_channel; 374 375 unsigned long start_time; 376 377 u32 duration, req_duration; 378 struct sk_buff *frame; 379 u64 cookie, mgmt_tx_cookie; 380 enum ieee80211_roc_type type; 381 }; 382 383 /* flags used in struct ieee80211_if_managed.flags */ 384 enum ieee80211_sta_flags { 385 IEEE80211_STA_CONNECTION_POLL = BIT(1), 386 IEEE80211_STA_CONTROL_PORT = BIT(2), 387 IEEE80211_STA_MFP_ENABLED = BIT(6), 388 IEEE80211_STA_UAPSD_ENABLED = BIT(7), 389 IEEE80211_STA_NULLFUNC_ACKED = BIT(8), 390 IEEE80211_STA_ENABLE_RRM = BIT(15), 391 }; 392 393 enum ieee80211_conn_mode { 394 IEEE80211_CONN_MODE_S1G, 395 IEEE80211_CONN_MODE_LEGACY, 396 IEEE80211_CONN_MODE_HT, 397 IEEE80211_CONN_MODE_VHT, 398 IEEE80211_CONN_MODE_HE, 399 IEEE80211_CONN_MODE_EHT, 400 IEEE80211_CONN_MODE_UHR, 401 }; 402 403 #define IEEE80211_CONN_MODE_HIGHEST IEEE80211_CONN_MODE_UHR 404 405 enum ieee80211_conn_bw_limit { 406 IEEE80211_CONN_BW_LIMIT_20, 407 IEEE80211_CONN_BW_LIMIT_40, 408 IEEE80211_CONN_BW_LIMIT_80, 409 IEEE80211_CONN_BW_LIMIT_160, /* also 80+80 */ 410 IEEE80211_CONN_BW_LIMIT_320, 411 }; 412 413 struct ieee80211_conn_settings { 414 enum ieee80211_conn_mode mode; 415 enum ieee80211_conn_bw_limit bw_limit; 416 bool dbe_enabled; 417 }; 418 419 extern const struct ieee80211_conn_settings ieee80211_conn_settings_unlimited; 420 421 struct ieee80211_mgd_auth_data { 422 struct cfg80211_bss *bss; 423 unsigned long timeout; 424 int tries; 425 u16 algorithm, expected_transaction; 426 427 unsigned long userspace_selectors[BITS_TO_LONGS(128)]; 428 429 u8 key[WLAN_KEY_LEN_WEP104]; 430 u8 key_len, key_idx; 431 bool done, waiting; 432 bool peer_confirmed; 433 bool timeout_started; 434 int link_id; 435 436 u8 ap_addr[ETH_ALEN] __aligned(2); 437 438 u16 trans, status; 439 size_t data_len; 440 u8 data[]; 441 }; 442 443 struct ieee80211_mgd_assoc_data { 444 struct { 445 struct cfg80211_bss *bss; 446 447 u8 addr[ETH_ALEN] __aligned(2); 448 449 u8 ap_ht_param; 450 451 struct ieee80211_vht_cap ap_vht_cap; 452 453 size_t elems_len; 454 u8 *elems; /* pointing to inside ie[] below */ 455 456 struct ieee80211_conn_settings conn; 457 458 u16 status; 459 } link[IEEE80211_MLD_MAX_NUM_LINKS]; 460 461 u8 ap_addr[ETH_ALEN] __aligned(2); 462 463 /* this is for a workaround, so we use it only for non-MLO */ 464 const u8 *supp_rates; 465 u8 supp_rates_len; 466 467 unsigned long timeout; 468 int tries; 469 470 u8 prev_ap_addr[ETH_ALEN]; 471 u8 ssid[IEEE80211_MAX_SSID_LEN]; 472 u8 ssid_len; 473 bool wmm, uapsd; 474 bool need_beacon; 475 bool synced; 476 bool timeout_started; 477 bool comeback; /* whether the AP has requested association comeback */ 478 bool s1g; 479 bool spp_amsdu; 480 481 s8 assoc_link_id; 482 483 __le16 ext_mld_capa_ops; 484 485 u8 fils_nonces[2 * FILS_NONCE_LEN]; 486 u8 fils_kek[FILS_MAX_KEK_LEN]; 487 size_t fils_kek_len; 488 489 size_t ie_len; 490 u8 *ie_pos; /* used to fill ie[] with link[].elems */ 491 u8 ie[]; 492 }; 493 494 struct ieee80211_sta_tx_tspec { 495 /* timestamp of the first packet in the time slice */ 496 unsigned long time_slice_start; 497 498 u32 admitted_time; /* in usecs, unlike over the air */ 499 u8 tsid; 500 s8 up; /* signed to be able to invalidate with -1 during teardown */ 501 502 /* consumed TX time in microseconds in the time slice */ 503 u32 consumed_tx_time; 504 enum { 505 TX_TSPEC_ACTION_NONE = 0, 506 TX_TSPEC_ACTION_DOWNGRADE, 507 TX_TSPEC_ACTION_STOP_DOWNGRADE, 508 } action; 509 bool downgraded; 510 }; 511 512 /* Advertised TID-to-link mapping info */ 513 struct ieee80211_adv_ttlm_info { 514 /* time in TUs at which the new mapping is established, or 0 if there is 515 * no planned advertised TID-to-link mapping 516 */ 517 u16 switch_time; 518 u32 duration; /* duration of the planned T2L map in TUs */ 519 u16 map; /* map of usable links for all TIDs */ 520 bool active; /* whether the advertised mapping is active or not */ 521 }; 522 523 DECLARE_EWMA(beacon_signal, 4, 4) 524 525 struct ieee80211_if_managed { 526 struct timer_list timer; 527 struct timer_list conn_mon_timer; 528 struct timer_list bcn_mon_timer; 529 struct wiphy_work monitor_work; 530 struct wiphy_work beacon_connection_loss_work; 531 struct wiphy_work csa_connection_drop_work; 532 533 unsigned long beacon_timeout; 534 unsigned long probe_timeout; 535 int probe_send_count; 536 bool nullfunc_failed; 537 u8 connection_loss:1, 538 driver_disconnect:1, 539 reconnect:1, 540 associated:1; 541 542 struct ieee80211_mgd_auth_data *auth_data; 543 struct ieee80211_mgd_assoc_data *assoc_data; 544 545 unsigned long userspace_selectors[BITS_TO_LONGS(128)]; 546 547 bool powersave; /* powersave requested for this iface */ 548 bool broken_ap; /* AP is broken -- turn off powersave */ 549 550 unsigned int flags; 551 552 u16 mcast_seq_last; 553 554 bool status_acked; 555 bool status_received; 556 __le16 status_fc; 557 558 enum { 559 IEEE80211_MFP_DISABLED, 560 IEEE80211_MFP_OPTIONAL, 561 IEEE80211_MFP_REQUIRED 562 } mfp; /* management frame protection */ 563 564 /* 565 * Bitmask of enabled u-apsd queues, 566 * IEEE80211_WMM_IE_STA_QOSINFO_AC_BE & co. Needs a new association 567 * to take effect. 568 */ 569 unsigned int uapsd_queues; 570 571 /* 572 * Maximum number of buffered frames AP can deliver during a 573 * service period, IEEE80211_WMM_IE_STA_QOSINFO_SP_ALL or similar. 574 * Needs a new association to take effect. 575 */ 576 unsigned int uapsd_max_sp_len; 577 578 u8 use_4addr; 579 580 /* 581 * State variables for keeping track of RSSI of the AP currently 582 * connected to and informing driver when RSSI has gone 583 * below/above a certain threshold. 584 */ 585 int rssi_min_thold, rssi_max_thold; 586 587 struct ieee80211_ht_cap ht_capa; /* configured ht-cap over-rides */ 588 struct ieee80211_ht_cap ht_capa_mask; /* Valid parts of ht_capa */ 589 struct ieee80211_vht_cap vht_capa; /* configured VHT overrides */ 590 struct ieee80211_vht_cap vht_capa_mask; /* Valid parts of vht_capa */ 591 struct ieee80211_s1g_cap s1g_capa; /* configured S1G overrides */ 592 struct ieee80211_s1g_cap s1g_capa_mask; /* valid s1g_capa bits */ 593 594 /* TDLS support */ 595 u8 tdls_peer[ETH_ALEN] __aligned(2); 596 struct wiphy_delayed_work tdls_peer_del_work; 597 struct sk_buff *orig_teardown_skb; /* The original teardown skb */ 598 struct sk_buff *teardown_skb; /* A copy to send through the AP */ 599 spinlock_t teardown_lock; /* To lock changing teardown_skb */ 600 bool tdls_wider_bw_prohibited; 601 602 /* WMM-AC TSPEC support */ 603 struct ieee80211_sta_tx_tspec tx_tspec[IEEE80211_NUM_ACS]; 604 /* Use a separate work struct so that we can do something here 605 * while the sdata->work is flushing the queues, for example. 606 * otherwise, in scenarios where we hardly get any traffic out 607 * on the BE queue, but there's a lot of VO traffic, we might 608 * get stuck in a downgraded situation and flush takes forever. 609 */ 610 struct wiphy_delayed_work tx_tspec_wk; 611 612 /* Information elements from the last transmitted (Re)Association 613 * Request frame. 614 */ 615 u8 *assoc_req_ies; 616 size_t assoc_req_ies_len; 617 618 struct wiphy_hrtimer_work ml_reconf_work; 619 u16 removed_links; 620 621 /* TID-to-link mapping support */ 622 struct wiphy_hrtimer_work ttlm_work; 623 struct ieee80211_adv_ttlm_info ttlm_info; 624 struct wiphy_work teardown_ttlm_work; 625 626 /* dialog token enumerator for neg TTLM request */ 627 u8 dialog_token_alloc; 628 struct wiphy_delayed_work neg_ttlm_timeout_work; 629 630 /* Locally initiated multi-link reconfiguration */ 631 struct { 632 struct ieee80211_mgd_assoc_data *add_links_data; 633 struct wiphy_delayed_work wk; 634 u16 removed_links; 635 u16 added_links; 636 u8 dialog_token; 637 } reconf; 638 639 /* Support for epcs */ 640 struct { 641 bool enabled; 642 u8 dialog_token; 643 } epcs; 644 645 struct { 646 struct wiphy_hrtimer_work status_work; 647 u32 timeout_us; 648 u16 links; 649 u16 pending, pending_init; 650 u8 dialog_token; 651 bool acked; 652 } uhr_omp; 653 }; 654 655 struct ieee80211_if_ibss { 656 struct timer_list timer; 657 struct wiphy_work csa_connection_drop_work; 658 659 unsigned long last_scan_completed; 660 661 u32 basic_rates; 662 663 bool fixed_bssid; 664 bool fixed_channel; 665 bool privacy; 666 667 bool control_port; 668 bool userspace_handles_dfs; 669 670 u8 bssid[ETH_ALEN] __aligned(2); 671 u8 ssid[IEEE80211_MAX_SSID_LEN]; 672 u8 ssid_len, ie_len; 673 u8 *ie; 674 struct cfg80211_chan_def chandef; 675 676 unsigned long ibss_join_req; 677 /* probe response/beacon for IBSS */ 678 struct beacon_data __rcu *presp; 679 680 struct ieee80211_ht_cap ht_capa; /* configured ht-cap over-rides */ 681 struct ieee80211_ht_cap ht_capa_mask; /* Valid parts of ht_capa */ 682 683 spinlock_t incomplete_lock; 684 struct list_head incomplete_stations; 685 686 enum { 687 IEEE80211_IBSS_MLME_SEARCH, 688 IEEE80211_IBSS_MLME_JOINED, 689 } state; 690 }; 691 692 /** 693 * struct ieee80211_if_ocb - OCB mode state 694 * 695 * @housekeeping_timer: timer for periodic invocation of a housekeeping task 696 * @wrkq_flags: OCB deferred task action 697 * @incomplete_lock: delayed STA insertion lock 698 * @incomplete_stations: list of STAs waiting for delayed insertion 699 * @joined: indication if the interface is connected to an OCB network 700 */ 701 struct ieee80211_if_ocb { 702 struct timer_list housekeeping_timer; 703 unsigned long wrkq_flags; 704 705 spinlock_t incomplete_lock; 706 struct list_head incomplete_stations; 707 708 bool joined; 709 }; 710 711 /** 712 * struct ieee80211_mesh_sync_ops - Extensible synchronization framework interface 713 * 714 * these declarations define the interface, which enables 715 * vendor-specific mesh synchronization 716 * 717 * @rx_bcn_presp: beacon/probe response was received 718 * @adjust_tsf: TSF adjustment method 719 */ 720 struct ieee80211_mesh_sync_ops { 721 void (*rx_bcn_presp)(struct ieee80211_sub_if_data *sdata, u16 stype, 722 struct ieee80211_mgmt *mgmt, unsigned int len, 723 const struct ieee80211_meshconf_ie *mesh_cfg, 724 struct ieee80211_rx_status *rx_status); 725 726 /* should be called with beacon_data under RCU read lock */ 727 void (*adjust_tsf)(struct ieee80211_sub_if_data *sdata, 728 struct beacon_data *beacon); 729 /* add other framework functions here */ 730 }; 731 732 struct mesh_csa_settings { 733 struct rcu_head rcu_head; 734 struct cfg80211_csa_settings settings; 735 }; 736 737 /** 738 * struct mesh_table - mesh hash table 739 * 740 * @known_gates: list of known mesh gates and their mpaths by the station. The 741 * gate's mpath may or may not be resolved and active. 742 * @gates_lock: protects updates to known_gates 743 * @rhead: the rhashtable containing struct mesh_paths, keyed by dest addr 744 * @walk_head: linked list containing all mesh_path objects 745 * @walk_lock: lock protecting walk_head 746 * @entries: number of entries in the table 747 */ 748 struct mesh_table { 749 struct hlist_head known_gates; 750 spinlock_t gates_lock; 751 struct rhashtable rhead; 752 struct hlist_head walk_head; 753 spinlock_t walk_lock; 754 atomic_t entries; /* Up to MAX_MESH_NEIGHBOURS */ 755 }; 756 757 /** 758 * struct mesh_tx_cache - mesh fast xmit header cache 759 * 760 * @rht: hash table containing struct ieee80211_mesh_fast_tx, using skb DA as key 761 * @walk_head: linked list containing all ieee80211_mesh_fast_tx objects 762 * @walk_lock: lock protecting walk_head and rht 763 */ 764 struct mesh_tx_cache { 765 struct rhashtable rht; 766 struct hlist_head walk_head; 767 spinlock_t walk_lock; 768 }; 769 770 struct ieee80211_if_mesh { 771 struct timer_list housekeeping_timer; 772 struct timer_list mesh_path_timer; 773 struct timer_list mesh_path_root_timer; 774 775 unsigned long wrkq_flags; 776 unsigned long mbss_changed[64 / BITS_PER_LONG]; 777 778 bool userspace_handles_dfs; 779 780 u8 mesh_id[IEEE80211_MAX_MESH_ID_LEN]; 781 size_t mesh_id_len; 782 /* Active Path Selection Protocol Identifier */ 783 u8 mesh_pp_id; 784 /* Active Path Selection Metric Identifier */ 785 u8 mesh_pm_id; 786 /* Congestion Control Mode Identifier */ 787 u8 mesh_cc_id; 788 /* Synchronization Protocol Identifier */ 789 u8 mesh_sp_id; 790 /* Authentication Protocol Identifier */ 791 u8 mesh_auth_id; 792 /* Local mesh Sequence Number */ 793 u32 sn; 794 /* Last used PREQ ID */ 795 u32 preq_id; 796 atomic_t mpaths; 797 /* Timestamp of last SN update */ 798 unsigned long last_sn_update; 799 /* Time when it's ok to send next PERR */ 800 unsigned long next_perr; 801 /* Timestamp of last PREQ sent */ 802 unsigned long last_preq; 803 struct mesh_rmc *rmc; 804 spinlock_t mesh_preq_queue_lock; 805 struct mesh_preq_queue preq_queue; 806 int preq_queue_len; 807 struct mesh_stats mshstats; 808 struct mesh_config mshcfg; 809 atomic_t estab_plinks; 810 atomic_t mesh_seqnum; 811 bool accepting_plinks; 812 int num_gates; 813 struct beacon_data __rcu *beacon; 814 const u8 *ie; 815 u8 ie_len; 816 enum { 817 IEEE80211_MESH_SEC_NONE = 0x0, 818 IEEE80211_MESH_SEC_AUTHED = 0x1, 819 IEEE80211_MESH_SEC_SECURED = 0x2, 820 } security; 821 bool user_mpm; 822 /* Extensible Synchronization Framework */ 823 const struct ieee80211_mesh_sync_ops *sync_ops; 824 s64 sync_offset_clockdrift_max; 825 spinlock_t sync_offset_lock; 826 /* mesh power save */ 827 enum nl80211_mesh_power_mode nonpeer_pm; 828 int ps_peers_light_sleep; 829 int ps_peers_deep_sleep; 830 struct ps_data ps; 831 /* Channel Switching Support */ 832 struct mesh_csa_settings __rcu *csa; 833 enum { 834 IEEE80211_MESH_CSA_ROLE_NONE, 835 IEEE80211_MESH_CSA_ROLE_INIT, 836 IEEE80211_MESH_CSA_ROLE_REPEATER, 837 } csa_role; 838 u8 chsw_ttl; 839 u16 pre_value; 840 841 /* offset from skb->data while building IE */ 842 int meshconf_offset; 843 844 struct mesh_table mesh_paths; 845 struct mesh_table mpp_paths; /* Store paths for MPP&MAP */ 846 int mesh_paths_generation; 847 int mpp_paths_generation; 848 struct mesh_tx_cache tx_cache; 849 }; 850 851 #ifdef CONFIG_MAC80211_MESH 852 #define IEEE80211_IFSTA_MESH_CTR_INC(msh, name) \ 853 do { (msh)->mshstats.name++; } while (0) 854 #else 855 #define IEEE80211_IFSTA_MESH_CTR_INC(msh, name) \ 856 do { } while (0) 857 #endif 858 859 /** 860 * enum ieee80211_sub_if_data_flags - virtual interface flags 861 * 862 * @IEEE80211_SDATA_ALLMULTI: interface wants all multicast packets 863 * @IEEE80211_SDATA_DONT_BRIDGE_PACKETS: bridge packets between 864 * associated stations and deliver multicast frames both 865 * back to wireless media and to the local net stack. 866 * @IEEE80211_SDATA_DISCONNECT_RESUME: Disconnect after resume. 867 * @IEEE80211_SDATA_IN_DRIVER: indicates interface was added to driver 868 * @IEEE80211_SDATA_DISCONNECT_HW_RESTART: Disconnect after hardware restart 869 * recovery 870 */ 871 enum ieee80211_sub_if_data_flags { 872 IEEE80211_SDATA_ALLMULTI = BIT(0), 873 IEEE80211_SDATA_DONT_BRIDGE_PACKETS = BIT(3), 874 IEEE80211_SDATA_DISCONNECT_RESUME = BIT(4), 875 IEEE80211_SDATA_IN_DRIVER = BIT(5), 876 IEEE80211_SDATA_DISCONNECT_HW_RESTART = BIT(6), 877 }; 878 879 /** 880 * enum ieee80211_sdata_state_bits - virtual interface state bits 881 * @SDATA_STATE_RUNNING: virtual interface is up & running; this 882 * mirrors netif_running() but is separate for interface type 883 * change handling while the interface is up 884 * @SDATA_STATE_OFFCHANNEL: This interface is currently in offchannel 885 * mode, so queues are stopped 886 * @SDATA_STATE_OFFCHANNEL_BEACON_STOPPED: Beaconing was stopped due 887 * to offchannel, reset when offchannel returns 888 */ 889 enum ieee80211_sdata_state_bits { 890 SDATA_STATE_RUNNING, 891 SDATA_STATE_OFFCHANNEL, 892 SDATA_STATE_OFFCHANNEL_BEACON_STOPPED, 893 }; 894 895 /** 896 * enum ieee80211_chanctx_mode - channel context configuration mode 897 * 898 * @IEEE80211_CHANCTX_SHARED: channel context may be used by 899 * multiple interfaces 900 * @IEEE80211_CHANCTX_EXCLUSIVE: channel context can be used 901 * only by a single interface. This can be used for example for 902 * non-fixed channel IBSS. 903 */ 904 enum ieee80211_chanctx_mode { 905 IEEE80211_CHANCTX_SHARED, 906 IEEE80211_CHANCTX_EXCLUSIVE 907 }; 908 909 /** 910 * enum ieee80211_chanctx_replace_state - channel context replacement state 911 * 912 * This is used for channel context in-place reservations that require channel 913 * context switch/swap. 914 * 915 * @IEEE80211_CHANCTX_REPLACE_NONE: no replacement is taking place 916 * @IEEE80211_CHANCTX_WILL_BE_REPLACED: this channel context will be replaced 917 * by a (not yet registered) channel context pointed by %replace_ctx. 918 * @IEEE80211_CHANCTX_REPLACES_OTHER: this (not yet registered) channel context 919 * replaces an existing channel context pointed to by %replace_ctx. 920 */ 921 enum ieee80211_chanctx_replace_state { 922 IEEE80211_CHANCTX_REPLACE_NONE, 923 IEEE80211_CHANCTX_WILL_BE_REPLACED, 924 IEEE80211_CHANCTX_REPLACES_OTHER, 925 }; 926 927 struct ieee80211_chanctx { 928 struct list_head list; 929 struct rcu_head rcu_head; 930 931 enum ieee80211_chanctx_replace_state replace_state; 932 struct ieee80211_chanctx *replace_ctx; 933 934 enum ieee80211_chanctx_mode mode; 935 bool driver_present; 936 937 /* temporary data for search algorithm etc. */ 938 struct ieee80211_chan_req req; 939 940 bool radar_detected; 941 942 /* This chanctx is in process of getting used */ 943 bool will_be_used; 944 945 /* MUST be last - ends in a flexible-array member. */ 946 struct ieee80211_chanctx_conf conf; 947 }; 948 949 struct mac80211_qos_map { 950 struct cfg80211_qos_map qos_map; 951 struct rcu_head rcu_head; 952 }; 953 954 enum txq_info_flags { 955 IEEE80211_TXQ_STOP, 956 IEEE80211_TXQ_AMPDU, 957 IEEE80211_TXQ_NO_AMSDU, 958 IEEE80211_TXQ_DIRTY, 959 }; 960 961 /** 962 * struct txq_info - per tid queue 963 * 964 * @tin: contains packets split into multiple flows 965 * @def_cvars: codel vars for the @tin's default_flow 966 * @cstats: code statistics for this queue 967 * @frags: used to keep fragments created after dequeue 968 * @schedule_order: used with ieee80211_local->active_txqs 969 * @schedule_round: counter to prevent infinite loops on TXQ scheduling 970 * @flags: TXQ flags from &enum txq_info_flags 971 * @txq: the driver visible part 972 */ 973 struct txq_info { 974 struct fq_tin tin; 975 struct codel_vars def_cvars; 976 struct codel_stats cstats; 977 978 u16 schedule_round; 979 struct list_head schedule_order; 980 981 struct sk_buff_head frags; 982 983 unsigned long flags; 984 985 /* keep last! */ 986 struct ieee80211_txq txq; 987 }; 988 989 struct ieee80211_if_mntr { 990 u32 flags; 991 u8 mu_follow_addr[ETH_ALEN] __aligned(2); 992 993 struct list_head list; 994 }; 995 996 /** 997 * struct ieee80211_if_nan - NAN state 998 * 999 * @conf: current NAN configuration 1000 * @started: true iff NAN is started 1001 * @de: Discovery Engine state (only valid if !WIPHY_NAN_FLAGS_USERSPACE_DE) 1002 * @de.func_lock: lock for @de.function_inst_ids 1003 * @de.function_inst_ids: a bitmap of available instance_id's 1004 * @removed_channels: bitmap of channels that should be removed from the NAN 1005 * schedule once the deferred schedule update is completed. 1006 */ 1007 struct ieee80211_if_nan { 1008 struct cfg80211_nan_conf conf; 1009 bool started; 1010 1011 struct { 1012 /* protects function_inst_ids */ 1013 spinlock_t func_lock; 1014 struct idr function_inst_ids; 1015 } de; 1016 1017 DECLARE_BITMAP(removed_channels, IEEE80211_NAN_MAX_CHANNELS); 1018 }; 1019 1020 /** 1021 * struct ieee80211_if_nan_data - NAN data path state 1022 * 1023 * @nmi: pointer to the NAN management interface sdata. Used for data path, 1024 * hence RCU. 1025 */ 1026 struct ieee80211_if_nan_data { 1027 struct ieee80211_sub_if_data __rcu *nmi; 1028 }; 1029 1030 struct ieee80211_link_data_managed { 1031 u8 bssid[ETH_ALEN] __aligned(2); 1032 1033 u8 dtim_period; 1034 enum ieee80211_smps_mode req_smps, /* requested smps mode */ 1035 driver_smps_mode; /* smps mode request */ 1036 1037 struct ieee80211_conn_settings conn; 1038 1039 s16 p2p_noa_index; 1040 1041 bool tdls_chan_switch_prohibited; 1042 1043 bool have_beacon; 1044 bool tracking_signal_avg; 1045 bool disable_wmm_tracking; 1046 bool operating_11g_mode; 1047 1048 struct { 1049 struct wiphy_hrtimer_work switch_work; 1050 struct cfg80211_chan_def ap_chandef; 1051 struct ieee80211_parsed_tpe tpe; 1052 ktime_t time; 1053 bool waiting_bcn; 1054 bool ignored_same_chan; 1055 bool blocked_tx; 1056 } csa; 1057 1058 struct wiphy_work request_smps_work; 1059 /* used to reconfigure hardware SM PS */ 1060 struct wiphy_work recalc_smps; 1061 1062 bool beacon_crc_valid; 1063 u32 beacon_crc; 1064 struct ewma_beacon_signal ave_beacon_signal; 1065 int last_ave_beacon_signal; 1066 1067 /* 1068 * Number of Beacon frames used in ave_beacon_signal. This can be used 1069 * to avoid generating less reliable cqm events that would be based 1070 * only on couple of received frames. 1071 */ 1072 unsigned int count_beacon_signal; 1073 1074 /* Number of times beacon loss was invoked. */ 1075 unsigned int beacon_loss_count; 1076 1077 /* 1078 * Last Beacon frame signal strength average (ave_beacon_signal / 16) 1079 * that triggered a cqm event. 0 indicates that no event has been 1080 * generated for the current association. 1081 */ 1082 int last_cqm_event_signal; 1083 1084 int wmm_last_param_set; 1085 int mu_edca_last_param_set; 1086 }; 1087 1088 struct ieee80211_link_data_ap { 1089 struct beacon_data __rcu *beacon; 1090 struct probe_resp __rcu *probe_resp; 1091 struct fils_discovery_data __rcu *fils_discovery; 1092 struct unsol_bcast_probe_resp_data __rcu *unsol_bcast_probe_resp; 1093 struct s1g_short_beacon_data __rcu *s1g_short_beacon; 1094 1095 /* to be used after channel switch. */ 1096 struct cfg80211_beacon_data *next_beacon; 1097 }; 1098 1099 struct ieee80211_link_data { 1100 struct ieee80211_sub_if_data *sdata; 1101 unsigned int link_id; 1102 1103 /* multicast keys only */ 1104 struct ieee80211_key __rcu *gtk[NUM_DEFAULT_KEYS + 1105 NUM_DEFAULT_MGMT_KEYS + 1106 NUM_DEFAULT_BEACON_KEYS]; 1107 struct ieee80211_key __rcu *default_multicast_key; 1108 struct ieee80211_key __rcu *default_mgmt_key; 1109 struct ieee80211_key __rcu *default_beacon_key; 1110 1111 1112 bool operating_11g_mode; 1113 1114 struct { 1115 struct wiphy_work finalize_work; 1116 struct ieee80211_chan_req chanreq; 1117 } csa; 1118 1119 struct wiphy_work color_change_finalize_work; 1120 struct wiphy_delayed_work color_collision_detect_work; 1121 u64 color_bitmap; 1122 1123 /* context reservation -- protected with wiphy mutex */ 1124 struct ieee80211_chanctx *reserved_chanctx; 1125 struct ieee80211_chan_req reserved; 1126 bool reserved_radar_required; 1127 bool reserved_ready; 1128 1129 u8 needed_rx_chains; 1130 enum ieee80211_smps_mode smps_mode; 1131 1132 int user_power_level; /* in dBm */ 1133 int ap_power_level; /* in dBm */ 1134 1135 bool radar_required; 1136 struct wiphy_hrtimer_work dfs_cac_timer_work; 1137 1138 union { 1139 struct ieee80211_link_data_managed mgd; 1140 struct ieee80211_link_data_ap ap; 1141 } u; 1142 1143 struct ieee80211_tx_queue_params tx_conf[IEEE80211_NUM_ACS]; 1144 1145 struct ieee80211_bss_conf *conf; 1146 1147 struct { 1148 enum ieee80211_sta_rx_bandwidth he_and_lower; 1149 enum ieee80211_sta_rx_bandwidth eht; /* and UHR non-DBE */ 1150 } bss_bw; 1151 1152 #ifdef CONFIG_MAC80211_DEBUGFS 1153 struct dentry *debugfs_dir; 1154 #endif 1155 }; 1156 1157 struct ieee80211_sub_if_data { 1158 struct list_head list; 1159 1160 struct wireless_dev wdev; 1161 1162 /* keys */ 1163 struct list_head key_list; 1164 1165 /* count for keys needing tailroom space allocation */ 1166 int crypto_tx_tailroom_needed_cnt; 1167 int crypto_tx_tailroom_pending_dec; 1168 struct wiphy_delayed_work dec_tailroom_needed_wk; 1169 1170 struct net_device *dev; 1171 struct ieee80211_local *local; 1172 1173 unsigned int flags; 1174 1175 unsigned long state; 1176 1177 char name[IFNAMSIZ]; 1178 1179 struct ieee80211_fragment_cache frags; 1180 1181 /* TID bitmap for NoAck policy */ 1182 u16 noack_map; 1183 1184 /* bit field of ACM bits (BIT(802.1D tag)) */ 1185 u8 wmm_acm; 1186 1187 struct ieee80211_key __rcu *keys[NUM_DEFAULT_KEYS]; 1188 struct ieee80211_key __rcu *default_unicast_key; 1189 1190 u16 sequence_number; 1191 u16 mld_mcast_seq; 1192 __be16 control_port_protocol; 1193 bool control_port_no_encrypt; 1194 bool control_port_no_preauth; 1195 bool control_port_over_nl80211; 1196 1197 atomic_t num_tx_queued; 1198 struct mac80211_qos_map __rcu *qos_map; 1199 1200 struct wiphy_work work; 1201 struct sk_buff_head skb_queue; 1202 struct sk_buff_head status_queue; 1203 1204 /* 1205 * AP this belongs to: self in AP mode and 1206 * corresponding AP in VLAN mode, NULL for 1207 * all others (might be needed later in IBSS) 1208 */ 1209 struct ieee80211_if_ap *bss; 1210 1211 /* bitmap of allowed (non-MCS) rate indexes for rate control */ 1212 u32 rc_rateidx_mask[NUM_NL80211_BANDS]; 1213 1214 bool rc_has_mcs_mask[NUM_NL80211_BANDS]; 1215 u8 rc_rateidx_mcs_mask[NUM_NL80211_BANDS][IEEE80211_HT_MCS_MASK_LEN]; 1216 1217 bool rc_has_vht_mcs_mask[NUM_NL80211_BANDS]; 1218 u16 rc_rateidx_vht_mcs_mask[NUM_NL80211_BANDS][NL80211_VHT_NSS_MAX]; 1219 1220 /* Beacon frame (non-MCS) rate (as a bitmap) */ 1221 u32 beacon_rateidx_mask[NUM_NL80211_BANDS]; 1222 bool beacon_rate_set; 1223 1224 union { 1225 struct ieee80211_if_ap ap; 1226 struct ieee80211_if_vlan vlan; 1227 struct ieee80211_if_managed mgd; 1228 struct ieee80211_if_ibss ibss; 1229 struct ieee80211_if_mesh mesh; 1230 struct ieee80211_if_ocb ocb; 1231 struct ieee80211_if_mntr mntr; 1232 struct ieee80211_if_nan nan; 1233 struct ieee80211_if_nan_data nan_data; 1234 } u; 1235 1236 struct ieee80211_link_data deflink; 1237 struct ieee80211_link_data __rcu *link[IEEE80211_MLD_MAX_NUM_LINKS]; 1238 1239 /* for ieee80211_set_active_links_async() */ 1240 struct wiphy_work activate_links_work; 1241 u16 desired_active_links; 1242 1243 u16 restart_active_links; 1244 1245 #ifdef CONFIG_MAC80211_DEBUGFS 1246 struct { 1247 struct dentry *subdir_stations; 1248 struct dentry *default_unicast_key; 1249 struct dentry *default_multicast_key; 1250 struct dentry *default_mgmt_key; 1251 struct dentry *default_beacon_key; 1252 } debugfs; 1253 #endif 1254 1255 u32 tx_handlers_drop; 1256 /* must be last, dynamically sized area in this! */ 1257 struct ieee80211_vif vif; 1258 }; 1259 1260 static inline 1261 struct ieee80211_sub_if_data *vif_to_sdata(struct ieee80211_vif *p) 1262 { 1263 return container_of(p, struct ieee80211_sub_if_data, vif); 1264 } 1265 1266 #define sdata_dereference(p, sdata) \ 1267 wiphy_dereference(sdata->local->hw.wiphy, p) 1268 1269 #define for_each_sdata_link(_local, _link) \ 1270 /* outer loop just to define the variables ... */ \ 1271 for (struct ieee80211_sub_if_data *___sdata = NULL; \ 1272 !___sdata; \ 1273 ___sdata = (void *)~0 /* always stop */) \ 1274 for (int ___link_id = ARRAY_SIZE(___sdata->link); \ 1275 ___link_id; ___link_id = 0 /* always stop */) \ 1276 list_for_each_entry(___sdata, &(_local)->interfaces, list) \ 1277 if (___link_id == ARRAY_SIZE(___sdata->link) && \ 1278 ieee80211_sdata_running(___sdata)) \ 1279 for (___link_id = 0; \ 1280 ___link_id < ARRAY_SIZE(___sdata->link); \ 1281 ___link_id++) \ 1282 if ((_link = wiphy_dereference((_local)->hw.wiphy, \ 1283 ___sdata->link[___link_id]))) 1284 1285 /* 1286 * for_each_sdata_link_rcu() must be used under RCU read lock. 1287 */ 1288 #define for_each_sdata_link_rcu(_local, _link) \ 1289 /* outer loop just to define the variables ... */ \ 1290 for (struct ieee80211_sub_if_data *___sdata = NULL; \ 1291 !___sdata; \ 1292 ___sdata = (void *)~0 /* always stop */) \ 1293 for (int ___link_id = ARRAY_SIZE(___sdata->link); \ 1294 ___link_id; ___link_id = 0 /* always stop */) \ 1295 list_for_each_entry(___sdata, &(_local)->interfaces, list) \ 1296 if (___link_id == ARRAY_SIZE(___sdata->link) && \ 1297 ieee80211_sdata_running(___sdata)) \ 1298 for (___link_id = 0; \ 1299 ___link_id < ARRAY_SIZE((___sdata)->link); \ 1300 ___link_id++) \ 1301 if ((_link = rcu_dereference((___sdata)->link[___link_id]))) 1302 1303 #define for_each_link_data(sdata, __link) \ 1304 /* outer loop just to define the variable ... */ \ 1305 for (struct ieee80211_sub_if_data *__sdata = (sdata); __sdata; \ 1306 __sdata = NULL /* always stop */) \ 1307 for (int __link_id = 0; \ 1308 __link_id < ARRAY_SIZE((__sdata)->link); __link_id++) \ 1309 if ((!(__sdata)->vif.valid_links || \ 1310 (__sdata)->vif.valid_links & BIT(__link_id)) && \ 1311 ((__link) = sdata_dereference((__sdata)->link[__link_id], \ 1312 (__sdata)))) 1313 1314 /* 1315 * for_each_link_data_rcu should be used under RCU read lock. 1316 */ 1317 #define for_each_link_data_rcu(sdata, __link) \ 1318 /* outer loop just to define the variable ... */ \ 1319 for (struct ieee80211_sub_if_data *__sdata = (sdata); __sdata; \ 1320 __sdata = NULL /* always stop */) \ 1321 for (int __link_id = 0; \ 1322 __link_id < ARRAY_SIZE((__sdata)->link); __link_id++) \ 1323 if ((!(__sdata)->vif.valid_links || \ 1324 (__sdata)->vif.valid_links & BIT(__link_id)) && \ 1325 ((__link) = rcu_dereference((__sdata)->link[__link_id]))) \ 1326 1327 static inline int 1328 ieee80211_get_mbssid_beacon_len(struct cfg80211_mbssid_elems *elems, 1329 struct cfg80211_rnr_elems *rnr_elems, 1330 u8 i) 1331 { 1332 int len = 0; 1333 1334 if (!elems || !elems->cnt || i > elems->cnt) 1335 return 0; 1336 1337 if (i < elems->cnt) { 1338 len = elems->elem[i].len; 1339 if (rnr_elems) { 1340 len += rnr_elems->elem[i].len; 1341 for (i = elems->cnt; i < rnr_elems->cnt; i++) 1342 len += rnr_elems->elem[i].len; 1343 } 1344 return len; 1345 } 1346 1347 /* i == elems->cnt, calculate total length of all MBSSID elements */ 1348 for (i = 0; i < elems->cnt; i++) 1349 len += elems->elem[i].len; 1350 1351 if (rnr_elems) { 1352 for (i = 0; i < rnr_elems->cnt; i++) 1353 len += rnr_elems->elem[i].len; 1354 } 1355 1356 return len; 1357 } 1358 1359 enum { 1360 IEEE80211_RX_MSG = 1, 1361 IEEE80211_TX_STATUS_MSG = 2, 1362 }; 1363 1364 enum queue_stop_reason { 1365 IEEE80211_QUEUE_STOP_REASON_DRIVER, 1366 IEEE80211_QUEUE_STOP_REASON_PS, 1367 IEEE80211_QUEUE_STOP_REASON_CSA, 1368 IEEE80211_QUEUE_STOP_REASON_AGGREGATION, 1369 IEEE80211_QUEUE_STOP_REASON_SUSPEND, 1370 IEEE80211_QUEUE_STOP_REASON_SKB_ADD, 1371 IEEE80211_QUEUE_STOP_REASON_OFFCHANNEL, 1372 IEEE80211_QUEUE_STOP_REASON_FLUSH, 1373 IEEE80211_QUEUE_STOP_REASON_TDLS_TEARDOWN, 1374 IEEE80211_QUEUE_STOP_REASON_RESERVE_TID, 1375 IEEE80211_QUEUE_STOP_REASON_IFTYPE_CHANGE, 1376 1377 IEEE80211_QUEUE_STOP_REASONS, 1378 }; 1379 1380 #ifdef CONFIG_MAC80211_LEDS 1381 struct tpt_led_trigger { 1382 char name[32]; 1383 const struct ieee80211_tpt_blink *blink_table; 1384 unsigned int blink_table_len; 1385 struct timer_list timer; 1386 struct ieee80211_local *local; 1387 unsigned long prev_traffic; 1388 unsigned long tx_bytes, rx_bytes; 1389 unsigned int active, want; 1390 bool running; 1391 }; 1392 #endif 1393 1394 /** 1395 * enum mac80211_scan_flags - currently active scan mode 1396 * 1397 * @SCAN_SW_SCANNING: We're currently in the process of scanning but may as 1398 * well be on the operating channel 1399 * @SCAN_HW_SCANNING: The hardware is scanning for us, we have no way to 1400 * determine if we are on the operating channel or not 1401 * @SCAN_ONCHANNEL_SCANNING: Do a software scan on only the current operating 1402 * channel. This should not interrupt normal traffic. 1403 * @SCAN_COMPLETED: Set for our scan work function when the driver reported 1404 * that the scan completed. 1405 * @SCAN_ABORTED: Set for our scan work function when the driver reported 1406 * a scan complete for an aborted scan. 1407 * @SCAN_HW_CANCELLED: Set for our scan work function when the scan is being 1408 * cancelled. 1409 * @SCAN_BEACON_WAIT: Set whenever we're passive scanning because of radar/no-IR 1410 * and could send a probe request after receiving a beacon. 1411 * @SCAN_BEACON_DONE: Beacon received, we can now send a probe request 1412 */ 1413 enum mac80211_scan_flags { 1414 SCAN_SW_SCANNING, 1415 SCAN_HW_SCANNING, 1416 SCAN_ONCHANNEL_SCANNING, 1417 SCAN_COMPLETED, 1418 SCAN_ABORTED, 1419 SCAN_HW_CANCELLED, 1420 SCAN_BEACON_WAIT, 1421 SCAN_BEACON_DONE, 1422 }; 1423 1424 /** 1425 * enum mac80211_scan_state - scan state machine states 1426 * 1427 * @SCAN_DECISION: Main entry point to the scan state machine, this state 1428 * determines if we should keep on scanning or switch back to the 1429 * operating channel 1430 * @SCAN_SET_CHANNEL: Set the next channel to be scanned 1431 * @SCAN_SEND_PROBE: Send probe requests and wait for probe responses 1432 * @SCAN_SUSPEND: Suspend the scan and go back to operating channel to 1433 * send out data 1434 * @SCAN_RESUME: Resume the scan and scan the next channel 1435 * @SCAN_ABORT: Abort the scan and go back to operating channel 1436 */ 1437 enum mac80211_scan_state { 1438 SCAN_DECISION, 1439 SCAN_SET_CHANNEL, 1440 SCAN_SEND_PROBE, 1441 SCAN_SUSPEND, 1442 SCAN_RESUME, 1443 SCAN_ABORT, 1444 }; 1445 1446 DECLARE_STATIC_KEY_FALSE(aql_disable); 1447 1448 struct ieee80211_local { 1449 /* embed the driver visible part. 1450 * don't cast (use the static inlines below), but we keep 1451 * it first anyway so they become a no-op */ 1452 struct ieee80211_hw hw; 1453 1454 struct fq fq; 1455 struct codel_vars *cvars; 1456 struct codel_params cparams; 1457 1458 /* protects active_txqs and txqi->schedule_order */ 1459 spinlock_t active_txq_lock[IEEE80211_NUM_ACS]; 1460 struct list_head active_txqs[IEEE80211_NUM_ACS]; 1461 u16 schedule_round[IEEE80211_NUM_ACS]; 1462 1463 /* serializes ieee80211_handle_wake_tx_queue */ 1464 spinlock_t handle_wake_tx_queue_lock; 1465 1466 u16 airtime_flags; 1467 u32 aql_txq_limit_mc; 1468 u32 aql_txq_limit_low[IEEE80211_NUM_ACS]; 1469 u32 aql_txq_limit_high[IEEE80211_NUM_ACS]; 1470 u32 aql_threshold; 1471 atomic_t aql_total_pending_airtime; 1472 atomic_t aql_mc_pending_airtime; 1473 atomic_t aql_ac_pending_airtime[IEEE80211_NUM_ACS]; 1474 1475 const struct ieee80211_ops *ops; 1476 1477 /* 1478 * private workqueue to mac80211. mac80211 makes this accessible 1479 * via ieee80211_queue_work() 1480 */ 1481 struct workqueue_struct *workqueue; 1482 1483 unsigned long queue_stop_reasons[IEEE80211_MAX_QUEUES]; 1484 int q_stop_reasons[IEEE80211_MAX_QUEUES][IEEE80211_QUEUE_STOP_REASONS]; 1485 /* also used to protect ampdu_ac_queue and amdpu_ac_stop_refcnt */ 1486 spinlock_t queue_stop_reason_lock; 1487 1488 int open_count; 1489 int monitors, virt_monitors, tx_mntrs; 1490 /* number of interfaces with corresponding FIF_ flags */ 1491 int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss, fif_pspoll, 1492 fif_probe_req; 1493 bool probe_req_reg; 1494 bool rx_mcast_action_reg; 1495 unsigned int filter_flags; /* FIF_* */ 1496 1497 struct cfg80211_chan_def dflt_chandef; 1498 bool emulate_chanctx; 1499 1500 /* protects the aggregated multicast list and filter calls */ 1501 spinlock_t filter_lock; 1502 1503 /* used for uploading changed mc list */ 1504 struct wiphy_work reconfig_filter; 1505 1506 /* aggregated multicast list */ 1507 struct netdev_hw_addr_list mc_list; 1508 1509 bool tim_in_locked_section; /* see ieee80211_beacon_get() */ 1510 1511 /* 1512 * suspended is true if we finished all the suspend _and_ we have 1513 * not yet come up from resume. This is to be used by mac80211 1514 * to ensure driver sanity during suspend and mac80211's own 1515 * sanity. It can eventually be used for WoW as well. 1516 */ 1517 bool suspended; 1518 1519 /* suspending is true during the whole suspend process */ 1520 bool suspending; 1521 1522 /* 1523 * Resuming is true while suspended, but when we're reprogramming the 1524 * hardware -- at that time it's allowed to use ieee80211_queue_work() 1525 * again even though some other parts of the stack are still suspended 1526 * and we still drop received frames to avoid waking the stack. 1527 */ 1528 bool resuming; 1529 1530 /* 1531 * quiescing is true during the suspend process _only_ to 1532 * ease timer cancelling etc. 1533 */ 1534 bool quiescing; 1535 1536 /* device is started */ 1537 bool started; 1538 1539 /* device is during a HW reconfig */ 1540 bool in_reconfig; 1541 1542 /* reconfiguration failed ... suppress some warnings etc. */ 1543 bool reconfig_failure; 1544 1545 /* wowlan is enabled -- don't reconfig on resume */ 1546 bool wowlan; 1547 1548 struct wiphy_work radar_detected_work; 1549 1550 /* number of RX chains the hardware has */ 1551 u8 rx_chains; 1552 1553 /* bitmap of which sbands were copied */ 1554 u8 sband_allocated; 1555 1556 int tx_headroom; /* required headroom for hardware/radiotap */ 1557 1558 /* Tasklet and skb queue to process calls from IRQ mode. All frames 1559 * added to skb_queue will be processed, but frames in 1560 * skb_queue_unreliable may be dropped if the total length of these 1561 * queues increases over the limit. */ 1562 #define IEEE80211_IRQSAFE_QUEUE_LIMIT 128 1563 struct tasklet_struct tasklet; 1564 struct sk_buff_head skb_queue; 1565 struct sk_buff_head skb_queue_unreliable; 1566 1567 spinlock_t rx_path_lock; 1568 1569 /* Station data */ 1570 /* 1571 * The list, hash table and counter are protected 1572 * by the wiphy mutex, reads are done with RCU. 1573 */ 1574 spinlock_t tim_lock; 1575 unsigned long num_sta; 1576 struct list_head sta_list; 1577 struct rhltable sta_hash; 1578 struct rhltable link_sta_hash; 1579 struct timer_list sta_cleanup; 1580 int sta_generation; 1581 1582 struct sk_buff_head pending[IEEE80211_MAX_QUEUES]; 1583 struct tasklet_struct tx_pending_tasklet; 1584 struct tasklet_struct wake_txqs_tasklet; 1585 1586 atomic_t agg_queue_stop[IEEE80211_MAX_QUEUES]; 1587 1588 /* number of interfaces with allmulti RX */ 1589 atomic_t iff_allmultis; 1590 1591 struct rate_control_ref *rate_ctrl; 1592 1593 struct arc4_ctx wep_tx_ctx; 1594 struct arc4_ctx wep_rx_ctx; 1595 u32 wep_iv; 1596 1597 /* see iface.c */ 1598 struct list_head interfaces; 1599 struct list_head mon_list; /* only that are IFF_UP */ 1600 struct mutex iflist_mtx; 1601 1602 /* Scanning and BSS list */ 1603 unsigned long scanning; 1604 struct cfg80211_ssid scan_ssid; 1605 struct cfg80211_scan_request *int_scan_req; 1606 struct cfg80211_scan_request __rcu *scan_req; 1607 struct ieee80211_scan_request *hw_scan_req; 1608 struct cfg80211_chan_def scan_chandef; 1609 enum nl80211_band hw_scan_band; 1610 int scan_channel_idx; 1611 int scan_ies_len; 1612 int hw_scan_ies_bufsize; 1613 struct cfg80211_scan_info scan_info; 1614 1615 struct wiphy_work sched_scan_stopped_work; 1616 struct ieee80211_sub_if_data __rcu *sched_scan_sdata; 1617 struct cfg80211_sched_scan_request __rcu *sched_scan_req; 1618 u8 scan_addr[ETH_ALEN]; 1619 1620 unsigned long leave_oper_channel_time; 1621 enum mac80211_scan_state next_scan_state; 1622 struct wiphy_delayed_work scan_work; 1623 struct ieee80211_sub_if_data __rcu *scan_sdata; 1624 1625 /* Temporary remain-on-channel for off-channel operations */ 1626 struct ieee80211_channel *tmp_channel; 1627 1628 /* channel contexts */ 1629 struct list_head chanctx_list; 1630 1631 #ifdef CONFIG_MAC80211_LEDS 1632 struct led_trigger tx_led, rx_led, assoc_led, radio_led; 1633 struct led_trigger tpt_led; 1634 atomic_t tx_led_active, rx_led_active, assoc_led_active; 1635 atomic_t radio_led_active, tpt_led_active; 1636 struct tpt_led_trigger *tpt_led_trigger; 1637 #endif 1638 1639 #ifdef CONFIG_MAC80211_DEBUG_COUNTERS 1640 /* SNMP counters */ 1641 /* dot11CountersTable */ 1642 u32 dot11TransmittedFragmentCount; 1643 u32 dot11MulticastTransmittedFrameCount; 1644 u32 dot11FailedCount; 1645 u32 dot11RetryCount; 1646 u32 dot11MultipleRetryCount; 1647 u32 dot11FrameDuplicateCount; 1648 u32 dot11ReceivedFragmentCount; 1649 u32 dot11MulticastReceivedFrameCount; 1650 u32 dot11TransmittedFrameCount; 1651 1652 /* TX/RX handler statistics */ 1653 unsigned int tx_handlers_queued; 1654 unsigned int tx_handlers_drop_wep; 1655 unsigned int tx_handlers_drop_not_assoc; 1656 unsigned int tx_handlers_drop_unauth_port; 1657 unsigned int rx_handlers_drop; 1658 unsigned int rx_handlers_queued; 1659 unsigned int rx_handlers_drop_nullfunc; 1660 unsigned int rx_handlers_drop_defrag; 1661 unsigned int tx_expand_skb_head; 1662 unsigned int tx_expand_skb_head_cloned; 1663 unsigned int rx_expand_skb_head_defrag; 1664 unsigned int rx_handlers_fragments; 1665 unsigned int tx_status_drop; 1666 #define I802_DEBUG_INC(c) (c)++ 1667 #else /* CONFIG_MAC80211_DEBUG_COUNTERS */ 1668 #define I802_DEBUG_INC(c) do { } while (0) 1669 #endif /* CONFIG_MAC80211_DEBUG_COUNTERS */ 1670 1671 1672 int total_ps_buffered; /* total number of all buffered unicast and 1673 * multicast packets for power saving stations 1674 */ 1675 1676 bool pspolling; 1677 /* 1678 * PS can only be enabled when we have exactly one managed 1679 * interface (and monitors) in PS, this then points there. 1680 */ 1681 struct ieee80211_sub_if_data *ps_sdata; 1682 struct wiphy_work dynamic_ps_enable_work; 1683 struct wiphy_work dynamic_ps_disable_work; 1684 struct timer_list dynamic_ps_timer; 1685 struct notifier_block ifa_notifier; 1686 struct notifier_block ifa6_notifier; 1687 1688 /* 1689 * The dynamic ps timeout configured from user space via WEXT - 1690 * this will override whatever chosen by mac80211 internally. 1691 */ 1692 int dynamic_ps_forced_timeout; 1693 1694 int user_power_level; /* in dBm, for all interfaces */ 1695 1696 struct work_struct restart_work; 1697 1698 #ifdef CONFIG_MAC80211_DEBUGFS 1699 struct local_debugfsdentries { 1700 struct dentry *rcdir; 1701 struct dentry *keys; 1702 } debugfs; 1703 bool force_tx_status; 1704 #endif 1705 1706 /* 1707 * Remain-on-channel support 1708 */ 1709 struct wiphy_delayed_work roc_work; 1710 struct list_head roc_list; 1711 struct wiphy_work hw_roc_start, hw_roc_done; 1712 unsigned long hw_roc_start_time; 1713 struct idr ack_status_frames; 1714 spinlock_t ack_status_lock; 1715 1716 /* virtual monitor interface */ 1717 struct ieee80211_sub_if_data __rcu *monitor_sdata; 1718 struct ieee80211_chan_req monitor_chanreq; 1719 1720 /* extended capabilities provided by mac80211 */ 1721 u8 ext_capa[8]; 1722 1723 bool wbrf_supported; 1724 }; 1725 1726 static inline struct ieee80211_sub_if_data * 1727 IEEE80211_DEV_TO_SUB_IF(const struct net_device *dev) 1728 { 1729 return netdev_priv(dev); 1730 } 1731 1732 static inline struct ieee80211_sub_if_data * 1733 IEEE80211_WDEV_TO_SUB_IF(struct wireless_dev *wdev) 1734 { 1735 return container_of(wdev, struct ieee80211_sub_if_data, wdev); 1736 } 1737 1738 static inline struct ieee80211_supported_band * 1739 ieee80211_get_sband(struct ieee80211_sub_if_data *sdata) 1740 { 1741 struct ieee80211_local *local = sdata->local; 1742 struct ieee80211_chanctx_conf *chanctx_conf; 1743 enum nl80211_band band; 1744 1745 WARN_ON(ieee80211_vif_is_mld(&sdata->vif)); 1746 1747 rcu_read_lock(); 1748 chanctx_conf = rcu_dereference(sdata->vif.bss_conf.chanctx_conf); 1749 1750 if (!chanctx_conf) { 1751 rcu_read_unlock(); 1752 return NULL; 1753 } 1754 1755 band = chanctx_conf->def.chan->band; 1756 rcu_read_unlock(); 1757 1758 return local->hw.wiphy->bands[band]; 1759 } 1760 1761 static inline struct ieee80211_supported_band * 1762 ieee80211_get_link_sband(struct ieee80211_link_data *link) 1763 { 1764 struct ieee80211_local *local = link->sdata->local; 1765 struct ieee80211_chanctx_conf *chanctx_conf; 1766 enum nl80211_band band; 1767 1768 rcu_read_lock(); 1769 chanctx_conf = rcu_dereference(link->conf->chanctx_conf); 1770 if (!chanctx_conf) { 1771 rcu_read_unlock(); 1772 return NULL; 1773 } 1774 1775 band = chanctx_conf->def.chan->band; 1776 rcu_read_unlock(); 1777 1778 return local->hw.wiphy->bands[band]; 1779 } 1780 1781 /* this struct holds the value parsing from channel switch IE */ 1782 struct ieee80211_csa_ie { 1783 struct ieee80211_chan_req chanreq; 1784 u8 mode; 1785 u8 count; 1786 u8 ttl; 1787 u16 pre_value; 1788 u16 reason_code; 1789 u32 max_switch_time; 1790 }; 1791 1792 enum ieee80211_elems_parse_error { 1793 IEEE80211_PARSE_ERR_INVALID_END = BIT(0), 1794 IEEE80211_PARSE_ERR_DUP_ELEM = BIT(1), 1795 IEEE80211_PARSE_ERR_BAD_ELEM_SIZE = BIT(2), 1796 IEEE80211_PARSE_ERR_UNEXPECTED_ELEM = BIT(3), 1797 IEEE80211_PARSE_ERR_DUP_NEST_ML_BASIC = BIT(4), 1798 }; 1799 1800 /* Parsed Information Elements */ 1801 struct ieee802_11_elems { 1802 const u8 *ie_start; 1803 size_t total_len; 1804 u32 crc; 1805 u8 frame_type; 1806 bool from_ap; 1807 1808 /* pointers to IEs */ 1809 const struct ieee80211_tdls_lnkie *lnk_id; 1810 const struct ieee80211_ch_switch_timing *ch_sw_timing; 1811 const u8 *ext_capab; 1812 const u8 *ssid; 1813 const u8 *supp_rates; 1814 const u8 *ds_params; 1815 const struct ieee80211_tim_ie *tim; 1816 const u8 *rsn; 1817 const u8 *rsnx; 1818 const u8 *erp_info; 1819 const u8 *ext_supp_rates; 1820 const u8 *wmm_info; 1821 const u8 *wmm_param; 1822 const struct ieee80211_ht_cap *ht_cap_elem; 1823 const struct ieee80211_ht_operation *ht_operation; 1824 const struct ieee80211_vht_cap *vht_cap_elem; 1825 const struct ieee80211_vht_operation *vht_operation; 1826 const struct ieee80211_meshconf_ie *mesh_config; 1827 const u8 *he_cap; 1828 const struct ieee80211_he_operation *he_operation; 1829 const struct ieee80211_he_spr *he_spr; 1830 const struct ieee80211_mu_edca_param_set *mu_edca_param_set; 1831 const struct ieee80211_he_6ghz_capa *he_6ghz_capa; 1832 const u8 *uora_element; 1833 const u8 *mesh_id; 1834 const u8 *peering; 1835 const __le16 *awake_window; 1836 const u8 *preq; 1837 const u8 *prep; 1838 const u8 *perr; 1839 const struct ieee80211_rann_ie *rann; 1840 const struct ieee80211_channel_sw_ie *ch_switch_ie; 1841 const struct ieee80211_ext_chansw_ie *ext_chansw_ie; 1842 const struct ieee80211_wide_bw_chansw_ie *wide_bw_chansw_ie; 1843 const u8 *max_channel_switch_time; 1844 const u8 *country_elem; 1845 const u8 *pwr_constr_elem; 1846 const u8 *cisco_dtpc_elem; 1847 const struct ieee80211_timeout_interval_ie *timeout_int; 1848 const u8 *opmode_notif; 1849 const struct ieee80211_sec_chan_offs_ie *sec_chan_offs; 1850 struct ieee80211_mesh_chansw_params_ie *mesh_chansw_params_ie; 1851 const struct ieee80211_bss_max_idle_period_ie *max_idle_period_ie; 1852 const struct ieee80211_multiple_bssid_configuration *mbssid_config_ie; 1853 const struct ieee80211_bssid_index *bssid_index; 1854 u8 max_bssid_indicator; 1855 u8 dtim_count; 1856 u8 dtim_period; 1857 const struct ieee80211_addba_ext_ie *addba_ext_ie; 1858 const struct ieee80211_s1g_cap *s1g_capab; 1859 const struct ieee80211_s1g_oper_ie *s1g_oper; 1860 const struct ieee80211_s1g_bcn_compat_ie *s1g_bcn_compat; 1861 const struct ieee80211_aid_response_ie *aid_resp; 1862 const struct ieee80211_eht_cap_elem *eht_cap; 1863 const struct ieee80211_eht_operation *eht_operation; 1864 const struct ieee80211_multi_link_elem *ml_basic; 1865 const struct ieee80211_multi_link_elem *ml_reconf; 1866 const struct ieee80211_multi_link_elem *ml_epcs; 1867 const struct ieee80211_bandwidth_indication *bandwidth_indication; 1868 const struct ieee80211_ttlm_elem *ttlm[IEEE80211_TTLM_MAX_CNT]; 1869 const struct ieee80211_uhr_cap *uhr_cap; 1870 const struct ieee80211_uhr_operation *uhr_operation; 1871 1872 /* not the order in the psd values is per element, not per chandef */ 1873 struct ieee80211_parsed_tpe tpe; 1874 struct ieee80211_parsed_tpe csa_tpe; 1875 1876 /* length of them, respectively */ 1877 u8 ext_capab_len; 1878 u8 ssid_len; 1879 u8 supp_rates_len; 1880 u8 tim_len; 1881 u8 rsn_len; 1882 u8 rsnx_len; 1883 u8 ext_supp_rates_len; 1884 u8 wmm_info_len; 1885 u8 wmm_param_len; 1886 u8 he_cap_len; 1887 u8 mesh_id_len; 1888 u8 peering_len; 1889 u8 preq_len; 1890 u8 prep_len; 1891 u8 perr_len; 1892 u8 country_elem_len; 1893 u8 bssid_index_len; 1894 u8 eht_cap_len; 1895 u8 uhr_cap_len; 1896 u8 uhr_operation_len; 1897 1898 /* mult-link element can be de-fragmented and thus u8 is not sufficient */ 1899 size_t ml_basic_len; 1900 size_t ml_reconf_len; 1901 size_t ml_epcs_len; 1902 1903 u8 ttlm_num; 1904 1905 /* 1906 * store the per station profile pointer and length in case that the 1907 * parsing also handled Multi-Link element parsing for a specific link 1908 * ID. 1909 */ 1910 struct ieee80211_mle_per_sta_profile *prof; 1911 size_t sta_prof_len; 1912 1913 /* 1914 * When parsing the beacon with MBSSID (from a transmitted BSS), this 1915 * indicates that the profile the parser was instructed to look for 1916 * (via the bss value in &struct ieee80211_elems_parse_params) couldn't 1917 * be found (due to EMA, or perhaps broken AP) and the result cannot be 1918 * considered complete. 1919 */ 1920 bool mbssid_nontx_profile_missing; 1921 1922 /* whether/which parse error occurred while retrieving these elements */ 1923 u8 parse_error; 1924 }; 1925 1926 static inline struct ieee80211_local *hw_to_local( 1927 struct ieee80211_hw *hw) 1928 { 1929 return container_of(hw, struct ieee80211_local, hw); 1930 } 1931 1932 static inline struct txq_info *to_txq_info(struct ieee80211_txq *txq) 1933 { 1934 return container_of(txq, struct txq_info, txq); 1935 } 1936 1937 static inline bool txq_has_queue(struct ieee80211_txq *txq) 1938 { 1939 struct txq_info *txqi = to_txq_info(txq); 1940 1941 return !(skb_queue_empty(&txqi->frags) && !txqi->tin.backlog_packets); 1942 } 1943 1944 static inline bool 1945 ieee80211_have_rx_timestamp(struct ieee80211_rx_status *status) 1946 { 1947 return status->flag & RX_FLAG_MACTIME; 1948 } 1949 1950 void ieee80211_vif_inc_num_mcast(struct ieee80211_sub_if_data *sdata); 1951 void ieee80211_vif_dec_num_mcast(struct ieee80211_sub_if_data *sdata); 1952 1953 void ieee80211_vif_block_queues_csa(struct ieee80211_sub_if_data *sdata); 1954 void ieee80211_vif_unblock_queues_csa(struct ieee80211_sub_if_data *sdata); 1955 1956 /* This function returns the number of multicast stations connected to this 1957 * interface. It returns -1 if that number is not tracked, that is for netdevs 1958 * not in AP or AP_VLAN mode or when using 4addr. 1959 */ 1960 static inline int 1961 ieee80211_vif_get_num_mcast_if(struct ieee80211_sub_if_data *sdata) 1962 { 1963 if (sdata->vif.type == NL80211_IFTYPE_AP) 1964 return atomic_read(&sdata->u.ap.num_mcast_sta); 1965 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN && !sdata->u.vlan.sta) 1966 return atomic_read(&sdata->u.vlan.num_mcast_sta); 1967 return -1; 1968 } 1969 1970 static inline bool ieee80211_sdata_running(struct ieee80211_sub_if_data *sdata) 1971 { 1972 return test_bit(SDATA_STATE_RUNNING, &sdata->state); 1973 } 1974 1975 int ieee80211_hw_config(struct ieee80211_local *local, int radio_idx, 1976 u32 changed); 1977 int ieee80211_hw_conf_chan(struct ieee80211_local *local); 1978 void ieee80211_hw_conf_init(struct ieee80211_local *local); 1979 void ieee80211_tx_set_protected(struct ieee80211_tx_data *tx); 1980 void ieee80211_bss_info_change_notify(struct ieee80211_sub_if_data *sdata, 1981 u64 changed); 1982 void ieee80211_vif_cfg_change_notify(struct ieee80211_sub_if_data *sdata, 1983 u64 changed); 1984 void ieee80211_link_info_change_notify(struct ieee80211_sub_if_data *sdata, 1985 struct ieee80211_link_data *link, 1986 u64 changed); 1987 void ieee80211_configure_filter(struct ieee80211_local *local); 1988 u64 ieee80211_reset_erp_info(struct ieee80211_sub_if_data *sdata); 1989 1990 void ieee80211_handle_queued_frames(struct ieee80211_local *local); 1991 1992 int ieee80211_attach_ack_skb(struct ieee80211_local *local, struct sk_buff *skb, 1993 u64 *cookie, gfp_t gfp); 1994 1995 void ieee80211_check_fast_rx(struct sta_info *sta); 1996 void __ieee80211_check_fast_rx_iface(struct ieee80211_sub_if_data *sdata); 1997 void ieee80211_check_fast_rx_iface(struct ieee80211_sub_if_data *sdata); 1998 void ieee80211_clear_fast_rx(struct sta_info *sta); 1999 2000 bool ieee80211_is_our_addr(struct ieee80211_sub_if_data *sdata, 2001 const u8 *addr, int *out_link_id); 2002 2003 /* AP code */ 2004 void ieee80211_ap_rx_queued_frame(struct ieee80211_sub_if_data *sdata, 2005 struct sk_buff *skb); 2006 void ieee80211_uhr_disable_dbe_all_stas(struct ieee80211_link_data *link); 2007 2008 /* STA code */ 2009 void ieee80211_sta_setup_sdata(struct ieee80211_sub_if_data *sdata); 2010 int ieee80211_mgd_auth(struct ieee80211_sub_if_data *sdata, 2011 struct cfg80211_auth_request *req); 2012 int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata, 2013 struct cfg80211_assoc_request *req); 2014 int ieee80211_mgd_deauth(struct ieee80211_sub_if_data *sdata, 2015 struct cfg80211_deauth_request *req); 2016 int ieee80211_mgd_disassoc(struct ieee80211_sub_if_data *sdata, 2017 struct cfg80211_disassoc_request *req); 2018 void ieee80211_send_pspoll(struct ieee80211_local *local, 2019 struct ieee80211_sub_if_data *sdata); 2020 void ieee80211_recalc_ps(struct ieee80211_local *local); 2021 void ieee80211_recalc_ps_vif(struct ieee80211_sub_if_data *sdata); 2022 void ieee80211_sta_work(struct ieee80211_sub_if_data *sdata); 2023 void ieee80211_sta_rx_queued_frame(struct ieee80211_sub_if_data *sdata, 2024 struct sk_buff *skb); 2025 void ieee80211_sta_reset_beacon_monitor(struct ieee80211_sub_if_data *sdata); 2026 void ieee80211_sta_reset_conn_monitor(struct ieee80211_sub_if_data *sdata); 2027 void ieee80211_mgd_stop(struct ieee80211_sub_if_data *sdata); 2028 void ieee80211_mgd_conn_tx_status(struct ieee80211_sub_if_data *sdata, 2029 __le16 fc, bool acked); 2030 void ieee80211_mgd_quiesce(struct ieee80211_sub_if_data *sdata); 2031 void ieee80211_sta_restart(struct ieee80211_sub_if_data *sdata); 2032 void ieee80211_sta_handle_tspec_ac_params(struct ieee80211_sub_if_data *sdata); 2033 void ieee80211_sta_connection_lost(struct ieee80211_sub_if_data *sdata, 2034 u8 reason, bool tx); 2035 void ieee80211_mgd_setup_link(struct ieee80211_link_data *link); 2036 void ieee80211_mgd_stop_link(struct ieee80211_link_data *link); 2037 void ieee80211_mgd_set_link_qos_params(struct ieee80211_link_data *link); 2038 2039 /* IBSS code */ 2040 void ieee80211_ibss_notify_scan_completed(struct ieee80211_local *local); 2041 void ieee80211_ibss_setup_sdata(struct ieee80211_sub_if_data *sdata); 2042 void ieee80211_ibss_rx_no_sta(struct ieee80211_sub_if_data *sdata, 2043 const u8 *bssid, const u8 *addr, u32 supp_rates); 2044 int ieee80211_ibss_join(struct ieee80211_sub_if_data *sdata, 2045 struct cfg80211_ibss_params *params); 2046 int ieee80211_ibss_leave(struct ieee80211_sub_if_data *sdata); 2047 void ieee80211_ibss_work(struct ieee80211_sub_if_data *sdata); 2048 void ieee80211_ibss_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata, 2049 struct sk_buff *skb); 2050 int ieee80211_ibss_csa_beacon(struct ieee80211_sub_if_data *sdata, 2051 struct cfg80211_csa_settings *csa_settings, 2052 u64 *changed); 2053 int ieee80211_ibss_finish_csa(struct ieee80211_sub_if_data *sdata, 2054 u64 *changed); 2055 void ieee80211_ibss_stop(struct ieee80211_sub_if_data *sdata); 2056 2057 /* OCB code */ 2058 void ieee80211_ocb_work(struct ieee80211_sub_if_data *sdata); 2059 void ieee80211_ocb_rx_no_sta(struct ieee80211_sub_if_data *sdata, 2060 const u8 *bssid, const u8 *addr, u32 supp_rates); 2061 void ieee80211_ocb_setup_sdata(struct ieee80211_sub_if_data *sdata); 2062 int ieee80211_ocb_join(struct ieee80211_sub_if_data *sdata, 2063 struct ocb_setup *setup); 2064 int ieee80211_ocb_leave(struct ieee80211_sub_if_data *sdata); 2065 2066 /* mesh code */ 2067 void ieee80211_mesh_work(struct ieee80211_sub_if_data *sdata); 2068 void ieee80211_mesh_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata, 2069 struct sk_buff *skb); 2070 int ieee80211_mesh_csa_beacon(struct ieee80211_sub_if_data *sdata, 2071 struct cfg80211_csa_settings *csa_settings, 2072 u64 *changed); 2073 int ieee80211_mesh_finish_csa(struct ieee80211_sub_if_data *sdata, 2074 u64 *changed); 2075 2076 /* NAN code */ 2077 int ieee80211_nan_set_local_sched(struct ieee80211_sub_if_data *sdata, 2078 struct cfg80211_nan_local_sched *sched); 2079 int ieee80211_nan_set_peer_sched(struct ieee80211_sub_if_data *sdata, 2080 struct cfg80211_nan_peer_sched *sched); 2081 void ieee80211_nan_free_peer_sched(struct ieee80211_nan_peer_sched *sched); 2082 void ieee80211_nan_update_ndi_carrier(struct ieee80211_sub_if_data *ndi_sdata); 2083 struct ieee80211_nan_channel * 2084 ieee80211_nan_find_evac_chan(struct ieee80211_local *local, 2085 struct ieee80211_sub_if_data *sdata, 2086 struct ieee80211_chanctx *ctx); 2087 void ieee80211_nan_evacuate_channel(struct ieee80211_sub_if_data *sdata, 2088 struct ieee80211_nan_channel *nan_channel); 2089 2090 static inline struct ieee80211_sub_if_data * 2091 ieee80211_find_nan_sdata(struct ieee80211_local *local) 2092 { 2093 struct ieee80211_sub_if_data *sdata; 2094 2095 lockdep_assert_wiphy(local->hw.wiphy); 2096 2097 /* Find the NAN interface - there can only be one */ 2098 list_for_each_entry(sdata, &local->interfaces, list) { 2099 if (ieee80211_sdata_running(sdata) && 2100 sdata->vif.type == NL80211_IFTYPE_NAN) 2101 return sdata; 2102 } 2103 2104 return NULL; 2105 } 2106 2107 /* scan/BSS handling */ 2108 void ieee80211_scan_work(struct wiphy *wiphy, struct wiphy_work *work); 2109 int ieee80211_request_ibss_scan(struct ieee80211_sub_if_data *sdata, 2110 const u8 *ssid, u8 ssid_len, 2111 struct ieee80211_channel **channels, 2112 unsigned int n_channels); 2113 int ieee80211_request_scan(struct ieee80211_sub_if_data *sdata, 2114 struct cfg80211_scan_request *req); 2115 void ieee80211_scan_cancel(struct ieee80211_local *local); 2116 void ieee80211_run_deferred_scan(struct ieee80211_local *local); 2117 void ieee80211_scan_rx(struct ieee80211_local *local, struct sk_buff *skb); 2118 2119 void ieee80211_inform_bss(struct wiphy *wiphy, struct cfg80211_bss *bss, 2120 const struct cfg80211_bss_ies *ies, void *data); 2121 2122 void ieee80211_mlme_notify_scan_completed(struct ieee80211_local *local); 2123 struct ieee80211_bss * 2124 ieee80211_bss_info_update(struct ieee80211_local *local, 2125 struct ieee80211_rx_status *rx_status, 2126 struct ieee80211_mgmt *mgmt, 2127 size_t len, 2128 struct ieee80211_channel *channel); 2129 void ieee80211_rx_bss_put(struct ieee80211_local *local, 2130 struct ieee80211_bss *bss); 2131 2132 /* scheduled scan handling */ 2133 int 2134 __ieee80211_request_sched_scan_start(struct ieee80211_sub_if_data *sdata, 2135 struct cfg80211_sched_scan_request *req); 2136 int ieee80211_request_sched_scan_start(struct ieee80211_sub_if_data *sdata, 2137 struct cfg80211_sched_scan_request *req); 2138 int ieee80211_request_sched_scan_stop(struct ieee80211_local *local); 2139 void ieee80211_sched_scan_end(struct ieee80211_local *local); 2140 void ieee80211_sched_scan_stopped_work(struct wiphy *wiphy, 2141 struct wiphy_work *work); 2142 2143 /* off-channel/mgmt-tx */ 2144 void ieee80211_offchannel_stop_vifs(struct ieee80211_local *local); 2145 void ieee80211_offchannel_return(struct ieee80211_local *local); 2146 void ieee80211_roc_setup(struct ieee80211_local *local); 2147 void ieee80211_start_next_roc(struct ieee80211_local *local); 2148 void ieee80211_reconfig_roc(struct ieee80211_local *local); 2149 void ieee80211_roc_purge(struct ieee80211_local *local, 2150 struct ieee80211_sub_if_data *sdata); 2151 int ieee80211_remain_on_channel(struct wiphy *wiphy, struct wireless_dev *wdev, 2152 struct ieee80211_channel *chan, 2153 unsigned int duration, u64 cookie, 2154 const u8 *rx_addr); 2155 int ieee80211_cancel_remain_on_channel(struct wiphy *wiphy, 2156 struct wireless_dev *wdev, u64 cookie); 2157 int ieee80211_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev, 2158 struct cfg80211_mgmt_tx_params *params, u64 cookie); 2159 int ieee80211_mgmt_tx_cancel_wait(struct wiphy *wiphy, 2160 struct wireless_dev *wdev, u64 cookie); 2161 2162 /* channel switch handling */ 2163 void ieee80211_csa_finalize_work(struct wiphy *wiphy, struct wiphy_work *work); 2164 int ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev, 2165 struct cfg80211_csa_settings *params); 2166 2167 /* color change handling */ 2168 void ieee80211_color_change_finalize_work(struct wiphy *wiphy, 2169 struct wiphy_work *work); 2170 void ieee80211_color_collision_detection_work(struct wiphy *wiphy, 2171 struct wiphy_work *work); 2172 2173 /* interface handling */ 2174 #define MAC80211_SUPPORTED_FEATURES_TX (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | \ 2175 NETIF_F_HW_CSUM | NETIF_F_SG | \ 2176 NETIF_F_HIGHDMA | NETIF_F_GSO_SOFTWARE | \ 2177 NETIF_F_HW_TC) 2178 #define MAC80211_SUPPORTED_FEATURES_RX (NETIF_F_RXCSUM) 2179 #define MAC80211_SUPPORTED_FEATURES (MAC80211_SUPPORTED_FEATURES_TX | \ 2180 MAC80211_SUPPORTED_FEATURES_RX) 2181 2182 int ieee80211_iface_init(void); 2183 void ieee80211_iface_exit(void); 2184 int ieee80211_if_add(struct ieee80211_local *local, const char *name, 2185 unsigned char name_assign_type, 2186 struct wireless_dev **new_wdev, enum nl80211_iftype type, 2187 struct vif_params *params); 2188 int ieee80211_if_change_type(struct ieee80211_sub_if_data *sdata, 2189 enum nl80211_iftype type); 2190 void ieee80211_if_remove(struct ieee80211_sub_if_data *sdata); 2191 void ieee80211_remove_interfaces(struct ieee80211_local *local); 2192 u32 ieee80211_idle_off(struct ieee80211_local *local); 2193 void ieee80211_recalc_idle(struct ieee80211_local *local); 2194 void ieee80211_adjust_monitor_flags(struct ieee80211_sub_if_data *sdata, 2195 const int offset); 2196 int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up); 2197 void ieee80211_sdata_stop(struct ieee80211_sub_if_data *sdata); 2198 int ieee80211_add_virtual_monitor(struct ieee80211_local *local, 2199 struct ieee80211_sub_if_data *creator_sdata); 2200 void ieee80211_del_virtual_monitor(struct ieee80211_local *local); 2201 2202 bool __ieee80211_recalc_txpower(struct ieee80211_link_data *link); 2203 void ieee80211_recalc_txpower(struct ieee80211_link_data *link, 2204 bool update_bss); 2205 void ieee80211_recalc_offload(struct ieee80211_local *local); 2206 2207 /* link handling */ 2208 void ieee80211_link_setup(struct ieee80211_link_data *link); 2209 void ieee80211_link_init(struct ieee80211_sub_if_data *sdata, 2210 int link_id, 2211 struct ieee80211_link_data *link, 2212 struct ieee80211_bss_conf *link_conf); 2213 void ieee80211_link_stop(struct ieee80211_link_data *link); 2214 int ieee80211_vif_set_links(struct ieee80211_sub_if_data *sdata, 2215 u16 new_links, u16 dormant_links); 2216 static inline void ieee80211_vif_clear_links(struct ieee80211_sub_if_data *sdata) 2217 { 2218 ieee80211_vif_set_links(sdata, 0, 0); 2219 } 2220 2221 void ieee80211_apvlan_link_setup(struct ieee80211_sub_if_data *sdata); 2222 void ieee80211_apvlan_link_clear(struct ieee80211_sub_if_data *sdata); 2223 2224 /* tx handling */ 2225 void ieee80211_clear_tx_pending(struct ieee80211_local *local); 2226 void ieee80211_tx_pending(struct tasklet_struct *t); 2227 netdev_tx_t ieee80211_monitor_start_xmit(struct sk_buff *skb, 2228 struct net_device *dev); 2229 netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb, 2230 struct net_device *dev); 2231 netdev_tx_t ieee80211_subif_start_xmit_8023(struct sk_buff *skb, 2232 struct net_device *dev); 2233 void __ieee80211_subif_start_xmit(struct sk_buff *skb, 2234 struct net_device *dev, 2235 u32 info_flags, 2236 u32 ctrl_flags, 2237 u64 cookie); 2238 struct sk_buff * 2239 ieee80211_build_data_template(struct ieee80211_sub_if_data *sdata, 2240 struct sk_buff *skb, u32 info_flags); 2241 void ieee80211_tx_monitor(struct ieee80211_local *local, struct sk_buff *skb, 2242 int retry_count, struct ieee80211_tx_status *status); 2243 2244 void ieee80211_check_fast_xmit(struct sta_info *sta); 2245 void ieee80211_check_fast_xmit_all(struct ieee80211_local *local); 2246 void ieee80211_check_fast_xmit_iface(struct ieee80211_sub_if_data *sdata); 2247 void ieee80211_clear_fast_xmit(struct sta_info *sta); 2248 int ieee80211_tx_control_port(struct wiphy *wiphy, struct net_device *dev, 2249 const u8 *buf, size_t len, 2250 const u8 *dest, __be16 proto, bool unencrypted, 2251 int link_id, u64 cookie); 2252 int ieee80211_probe_mesh_link(struct wiphy *wiphy, struct net_device *dev, 2253 const u8 *buf, size_t len); 2254 void __ieee80211_xmit_fast(struct ieee80211_sub_if_data *sdata, 2255 struct sta_info *sta, 2256 struct ieee80211_fast_tx *fast_tx, 2257 struct sk_buff *skb, bool ampdu, 2258 const u8 *da, const u8 *sa); 2259 void ieee80211_aggr_check(struct ieee80211_sub_if_data *sdata, 2260 struct sta_info *sta, struct sk_buff *skb); 2261 2262 /* HT */ 2263 void ieee80211_apply_htcap_overrides(struct ieee80211_sub_if_data *sdata, 2264 struct ieee80211_sta_ht_cap *ht_cap); 2265 bool ieee80211_ht_cap_ie_to_sta_ht_cap(struct ieee80211_sub_if_data *sdata, 2266 const struct ieee80211_sta_ht_cap *own_cap, 2267 const struct ieee80211_ht_cap *ht_cap_ie, 2268 struct link_sta_info *link_sta); 2269 void ieee80211_send_delba(struct ieee80211_sub_if_data *sdata, 2270 const u8 *da, u16 tid, 2271 u16 initiator, u16 reason_code, 2272 bool use_ndp); 2273 int ieee80211_send_smps_action(struct ieee80211_sub_if_data *sdata, 2274 enum ieee80211_smps_mode smps, const u8 *da, 2275 const u8 *bssid, int link_id); 2276 void ieee80211_add_addbaext(struct sk_buff *skb, 2277 const u8 req_addba_ext_data, 2278 u16 buf_size); 2279 u8 ieee80211_retrieve_addba_ext_data(struct sta_info *sta, 2280 const void *elem_data, ssize_t elem_len, 2281 u16 *buf_size); 2282 void __ieee80211_stop_rx_ba_session(struct sta_info *sta, u16 tid, 2283 u16 initiator, u16 reason, bool stop); 2284 void __ieee80211_start_rx_ba_session(struct sta_info *sta, 2285 u8 dialog_token, u16 timeout, 2286 u16 start_seq_num, u16 ba_policy, u16 tid, 2287 u16 buf_size, bool tx, bool auto_seq, 2288 bool req_ndp, 2289 const u8 addba_ext_data); 2290 void ieee80211_sta_tear_down_BA_sessions(struct sta_info *sta, 2291 enum ieee80211_agg_stop_reason reason); 2292 void ieee80211_process_delba(struct ieee80211_sub_if_data *sdata, 2293 struct sta_info *sta, 2294 struct ieee80211_mgmt *mgmt, size_t len); 2295 void ieee80211_process_addba_resp(struct ieee80211_local *local, 2296 struct sta_info *sta, 2297 struct ieee80211_mgmt *mgmt, 2298 size_t len); 2299 void ieee80211_process_addba_request(struct ieee80211_local *local, 2300 struct sta_info *sta, 2301 struct ieee80211_mgmt *mgmt, 2302 size_t len); 2303 2304 static inline struct ieee80211_mgmt * 2305 ieee80211_mgmt_ba(struct sk_buff *skb, const u8 *da, 2306 struct ieee80211_sub_if_data *sdata) 2307 { 2308 struct ieee80211_mgmt *mgmt = skb_put_zero(skb, 24); 2309 2310 ether_addr_copy(mgmt->da, da); 2311 ether_addr_copy(mgmt->sa, sdata->vif.addr); 2312 2313 if (sdata->vif.type == NL80211_IFTYPE_AP || 2314 sdata->vif.type == NL80211_IFTYPE_AP_VLAN || 2315 sdata->vif.type == NL80211_IFTYPE_MESH_POINT) 2316 ether_addr_copy(mgmt->bssid, sdata->vif.addr); 2317 else if (sdata->vif.type == NL80211_IFTYPE_STATION) 2318 ether_addr_copy(mgmt->bssid, sdata->vif.cfg.ap_addr); 2319 else if (sdata->vif.type == NL80211_IFTYPE_ADHOC) 2320 ether_addr_copy(mgmt->bssid, sdata->u.ibss.bssid); 2321 2322 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | 2323 IEEE80211_STYPE_ACTION); 2324 return mgmt; 2325 } 2326 2327 int __ieee80211_stop_tx_ba_session(struct sta_info *sta, u16 tid, 2328 enum ieee80211_agg_stop_reason reason); 2329 void ieee80211_start_tx_ba_cb(struct sta_info *sta, int tid, 2330 struct tid_ampdu_tx *tid_tx); 2331 void ieee80211_stop_tx_ba_cb(struct sta_info *sta, int tid, 2332 struct tid_ampdu_tx *tid_tx); 2333 void ieee80211_ba_session_work(struct wiphy *wiphy, struct wiphy_work *work); 2334 void ieee80211_tx_ba_session_handle_start(struct sta_info *sta, int tid); 2335 void ieee80211_release_reorder_timeout(struct sta_info *sta, int tid); 2336 2337 u8 ieee80211_mcs_to_chains(const struct ieee80211_mcs_info *mcs); 2338 enum nl80211_smps_mode 2339 ieee80211_smps_mode_to_smps_mode(enum ieee80211_smps_mode smps); 2340 2341 void ieee80211_ht_handle_chanwidth_notif(struct ieee80211_local *local, 2342 struct ieee80211_sub_if_data *sdata, 2343 struct sta_info *sta, 2344 struct link_sta_info *link_sta, 2345 u8 chanwidth, enum nl80211_band band); 2346 2347 /* VHT */ 2348 void 2349 ieee80211_vht_cap_ie_to_sta_vht_cap(struct ieee80211_sub_if_data *sdata, 2350 struct ieee80211_supported_band *sband, 2351 const struct ieee80211_sta_vht_cap *own_vht_cap, 2352 const struct ieee80211_vht_cap *vht_cap_ie, 2353 const struct ieee80211_vht_cap *vht_cap_ie2, 2354 struct link_sta_info *link_sta); 2355 void ieee80211_process_mu_groups(struct ieee80211_sub_if_data *sdata, 2356 struct ieee80211_link_data *link, 2357 struct ieee80211_mgmt *mgmt); 2358 u32 __ieee80211_vht_handle_opmode(struct ieee80211_sub_if_data *sdata, 2359 struct link_sta_info *sta, 2360 u8 opmode, enum nl80211_band band); 2361 void ieee80211_vht_handle_opmode(struct ieee80211_sub_if_data *sdata, 2362 struct link_sta_info *sta, 2363 u8 opmode, enum nl80211_band band); 2364 void ieee80211_apply_vhtcap_overrides(struct ieee80211_sub_if_data *sdata, 2365 struct ieee80211_sta_vht_cap *vht_cap); 2366 void ieee80211_get_vht_mask_from_cap(__le16 vht_cap, 2367 u16 vht_mask[NL80211_VHT_NSS_MAX]); 2368 2369 /* HE */ 2370 void 2371 _ieee80211_he_cap_ie_to_sta_he_cap(struct ieee80211_sub_if_data *sdata, 2372 const struct ieee80211_sta_he_cap *own_he_cap, 2373 const u8 *he_cap_ie, u8 he_cap_len, 2374 const struct ieee80211_he_6ghz_capa *he_6ghz_capa, 2375 struct link_sta_info *link_sta); 2376 void 2377 ieee80211_he_cap_ie_to_sta_he_cap(struct ieee80211_sub_if_data *sdata, 2378 struct ieee80211_supported_band *sband, 2379 const u8 *he_cap_ie, u8 he_cap_len, 2380 const struct ieee80211_he_6ghz_capa *he_6ghz_capa, 2381 struct link_sta_info *link_sta); 2382 void 2383 ieee80211_he_spr_ie_to_bss_conf(struct ieee80211_vif *vif, 2384 const struct ieee80211_he_spr *he_spr_ie_elem); 2385 2386 void 2387 ieee80211_he_op_ie_to_bss_conf(struct ieee80211_vif *vif, 2388 const struct ieee80211_he_operation *he_op_ie_elem); 2389 2390 /* S1G */ 2391 void ieee80211_s1g_sta_rate_init(struct sta_info *sta); 2392 bool ieee80211_s1g_is_twt_setup(struct sk_buff *skb); 2393 void ieee80211_s1g_rx_twt_action(struct ieee80211_sub_if_data *sdata, 2394 struct sk_buff *skb); 2395 void ieee80211_s1g_status_twt_action(struct ieee80211_sub_if_data *sdata, 2396 struct sk_buff *skb); 2397 void ieee80211_s1g_cap_to_sta_s1g_cap(struct ieee80211_sub_if_data *sdata, 2398 const struct ieee80211_s1g_cap *s1g_cap_ie, 2399 struct link_sta_info *link_sta); 2400 bool ieee80211_s1g_use_ndp_ba(const struct ieee80211_sub_if_data *sdata, 2401 const struct sta_info *sta); 2402 2403 /* Spectrum management */ 2404 void ieee80211_process_measurement_req(struct ieee80211_sub_if_data *sdata, 2405 struct ieee80211_mgmt *mgmt, 2406 size_t len); 2407 /** 2408 * ieee80211_parse_ch_switch_ie - parses channel switch IEs 2409 * @sdata: the sdata of the interface which has received the frame 2410 * @elems: parsed 802.11 elements received with the frame 2411 * @current_band: indicates the current band 2412 * @vht_cap_info: VHT capabilities of the transmitter 2413 * @conn: contains information about own capabilities and restrictions 2414 * to decide which channel switch announcements can be accepted 2415 * @bssid: the currently connected bssid (for reporting) 2416 * @unprot_action: whether the frame was an unprotected frame or not, 2417 * used for reporting 2418 * @csa_ie: parsed 802.11 csa elements on count, mode, chandef and mesh ttl. 2419 * All of them will be filled with if success only. 2420 * Return: 0 on success, <0 on error and >0 if there is nothing to parse. 2421 */ 2422 int ieee80211_parse_ch_switch_ie(struct ieee80211_sub_if_data *sdata, 2423 struct ieee802_11_elems *elems, 2424 enum nl80211_band current_band, 2425 u32 vht_cap_info, 2426 struct ieee80211_conn_settings *conn, 2427 u8 *bssid, bool unprot_action, 2428 struct ieee80211_csa_ie *csa_ie); 2429 2430 /* Suspend/resume and hw reconfiguration */ 2431 int ieee80211_reconfig(struct ieee80211_local *local); 2432 void ieee80211_stop_device(struct ieee80211_local *local, bool suspend); 2433 2434 int __ieee80211_suspend(struct ieee80211_hw *hw, 2435 struct cfg80211_wowlan *wowlan, bool reset); 2436 2437 static inline int __ieee80211_resume(struct ieee80211_hw *hw) 2438 { 2439 struct ieee80211_local *local = hw_to_local(hw); 2440 2441 WARN(test_bit(SCAN_HW_SCANNING, &local->scanning) && 2442 !test_bit(SCAN_COMPLETED, &local->scanning), 2443 "%s: resume with hardware scan still in progress\n", 2444 wiphy_name(hw->wiphy)); 2445 2446 return ieee80211_reconfig(hw_to_local(hw)); 2447 } 2448 2449 /* utility functions/constants */ 2450 extern const void *const mac80211_wiphy_privid; /* for wiphy privid */ 2451 const char *ieee80211_conn_mode_str(enum ieee80211_conn_mode mode); 2452 enum ieee80211_conn_bw_limit 2453 ieee80211_min_bw_limit_from_chandef(struct cfg80211_chan_def *chandef); 2454 int ieee80211_frame_duration(enum nl80211_band band, size_t len, 2455 int rate, int erp, int short_preamble); 2456 void ieee80211_regulatory_limit_wmm_params(struct ieee80211_sub_if_data *sdata, 2457 struct ieee80211_tx_queue_params *qparam, 2458 int ac); 2459 void ieee80211_clear_tpe(struct ieee80211_parsed_tpe *tpe); 2460 void ieee80211_set_wmm_default(struct ieee80211_link_data *link, 2461 bool bss_notify, bool enable_qos); 2462 void ieee80211_xmit(struct ieee80211_sub_if_data *sdata, 2463 struct sta_info *sta, struct sk_buff *skb); 2464 2465 void __ieee80211_tx_skb_tid_band(struct ieee80211_sub_if_data *sdata, 2466 struct sk_buff *skb, int tid, int link_id, 2467 enum nl80211_band band); 2468 2469 static inline bool ieee80211_require_encrypted_assoc(__le16 fc, 2470 struct sta_info *sta) 2471 { 2472 return sta && sta->sta.epp_peer && ieee80211_is_assoc(fc); 2473 } 2474 2475 /* sta_out needs to be checked for ERR_PTR() before using */ 2476 int ieee80211_lookup_ra_sta(struct ieee80211_sub_if_data *sdata, 2477 struct sk_buff *skb, 2478 struct sta_info **sta_out); 2479 2480 static inline void 2481 ieee80211_tx_skb_tid_band(struct ieee80211_sub_if_data *sdata, 2482 struct sk_buff *skb, int tid, 2483 enum nl80211_band band) 2484 { 2485 rcu_read_lock(); 2486 __ieee80211_tx_skb_tid_band(sdata, skb, tid, -1, band); 2487 rcu_read_unlock(); 2488 } 2489 2490 void ieee80211_tx_skb_tid(struct ieee80211_sub_if_data *sdata, 2491 struct sk_buff *skb, int tid, int link_id); 2492 2493 static inline void ieee80211_tx_skb(struct ieee80211_sub_if_data *sdata, 2494 struct sk_buff *skb) 2495 { 2496 /* Send all internal mgmt frames on VO. Accordingly set TID to 7. */ 2497 ieee80211_tx_skb_tid(sdata, skb, 7, -1); 2498 } 2499 2500 /** 2501 * struct ieee80211_elems_parse_params - element parsing parameters 2502 * @mode: connection mode for parsing 2503 * @start: pointer to the elements 2504 * @len: length of the elements 2505 * @type: type of the frame the elements came from 2506 * (action, probe response, beacon, etc.) 2507 * @filter: bitmap of element IDs to filter out while calculating 2508 * the element CRC 2509 * @crc: CRC starting value 2510 * @bss: the BSS to parse this as, for multi-BSSID cases this can 2511 * represent a non-transmitting BSS in which case the data 2512 * for that non-transmitting BSS is returned 2513 * @link_id: the link ID to parse elements for, if a STA profile 2514 * is present in the multi-link element, or -1 to ignore; 2515 * note that the code currently assumes parsing an association 2516 * (or re-association) response frame if this is given 2517 * @from_ap: frame is received from an AP (currently used only 2518 * for EHT capabilities parsing) 2519 */ 2520 struct ieee80211_elems_parse_params { 2521 enum ieee80211_conn_mode mode; 2522 const u8 *start; 2523 size_t len; 2524 u8 type; 2525 u64 filter; 2526 u32 crc; 2527 struct cfg80211_bss *bss; 2528 int link_id; 2529 bool from_ap; 2530 }; 2531 2532 struct ieee802_11_elems * 2533 ieee802_11_parse_elems_full(struct ieee80211_elems_parse_params *params); 2534 2535 static inline struct ieee802_11_elems * 2536 ieee802_11_parse_elems(const u8 *start, size_t len, u8 type, 2537 struct cfg80211_bss *bss) 2538 { 2539 struct ieee80211_elems_parse_params params = { 2540 .mode = IEEE80211_CONN_MODE_HIGHEST, 2541 .start = start, 2542 .len = len, 2543 .type = type, 2544 .bss = bss, 2545 .link_id = -1, 2546 }; 2547 2548 return ieee802_11_parse_elems_full(¶ms); 2549 } 2550 2551 extern const int ieee802_1d_to_ac[8]; 2552 2553 static inline int ieee80211_ac_from_tid(int tid) 2554 { 2555 return ieee802_1d_to_ac[tid & 7]; 2556 } 2557 2558 void ieee80211_dynamic_ps_enable_work(struct wiphy *wiphy, 2559 struct wiphy_work *work); 2560 void ieee80211_dynamic_ps_disable_work(struct wiphy *wiphy, 2561 struct wiphy_work *work); 2562 void ieee80211_dynamic_ps_timer(struct timer_list *t); 2563 void ieee80211_send_nullfunc(struct ieee80211_local *local, 2564 struct ieee80211_sub_if_data *sdata, 2565 bool powersave); 2566 void ieee80211_send_4addr_nullfunc(struct ieee80211_local *local, 2567 struct ieee80211_sub_if_data *sdata); 2568 void ieee80211_sta_tx_notify(struct ieee80211_sub_if_data *sdata, 2569 struct ieee80211_hdr *hdr, bool ack, u16 tx_time); 2570 unsigned int 2571 ieee80211_get_vif_queues(struct ieee80211_local *local, 2572 struct ieee80211_sub_if_data *sdata); 2573 void ieee80211_wake_queues_by_reason(struct ieee80211_hw *hw, 2574 unsigned long queues, 2575 enum queue_stop_reason reason, 2576 bool refcounted); 2577 void ieee80211_stop_queues_by_reason(struct ieee80211_hw *hw, 2578 unsigned long queues, 2579 enum queue_stop_reason reason, 2580 bool refcounted); 2581 void ieee80211_wake_queue_by_reason(struct ieee80211_hw *hw, int queue, 2582 enum queue_stop_reason reason, 2583 bool refcounted); 2584 void ieee80211_stop_queue_by_reason(struct ieee80211_hw *hw, int queue, 2585 enum queue_stop_reason reason, 2586 bool refcounted); 2587 static inline void 2588 ieee80211_stop_vif_queues(struct ieee80211_local *local, 2589 struct ieee80211_sub_if_data *sdata, 2590 enum queue_stop_reason reason) 2591 { 2592 ieee80211_stop_queues_by_reason(&local->hw, 2593 ieee80211_get_vif_queues(local, sdata), 2594 reason, true); 2595 } 2596 2597 static inline void 2598 ieee80211_wake_vif_queues(struct ieee80211_local *local, 2599 struct ieee80211_sub_if_data *sdata, 2600 enum queue_stop_reason reason) 2601 { 2602 ieee80211_wake_queues_by_reason(&local->hw, 2603 ieee80211_get_vif_queues(local, sdata), 2604 reason, true); 2605 } 2606 static inline void 2607 ieee80211_stop_vif_queues_norefcount(struct ieee80211_local *local, 2608 struct ieee80211_sub_if_data *sdata, 2609 enum queue_stop_reason reason) 2610 { 2611 ieee80211_stop_queues_by_reason(&local->hw, 2612 ieee80211_get_vif_queues(local, sdata), 2613 reason, false); 2614 } 2615 static inline void 2616 ieee80211_wake_vif_queues_norefcount(struct ieee80211_local *local, 2617 struct ieee80211_sub_if_data *sdata, 2618 enum queue_stop_reason reason) 2619 { 2620 ieee80211_wake_queues_by_reason(&local->hw, 2621 ieee80211_get_vif_queues(local, sdata), 2622 reason, false); 2623 } 2624 void ieee80211_add_pending_skb(struct ieee80211_local *local, 2625 struct sk_buff *skb); 2626 void ieee80211_add_pending_skbs(struct ieee80211_local *local, 2627 struct sk_buff_head *skbs); 2628 void ieee80211_flush_queues(struct ieee80211_local *local, 2629 struct ieee80211_sub_if_data *sdata, bool drop); 2630 void __ieee80211_flush_queues(struct ieee80211_local *local, 2631 struct ieee80211_sub_if_data *sdata, 2632 unsigned int queues, bool drop); 2633 2634 static inline bool ieee80211_can_run_worker(struct ieee80211_local *local) 2635 { 2636 /* 2637 * It's unsafe to try to do any work during reconfigure flow. 2638 * When the flow ends the work will be requeued. 2639 */ 2640 if (local->in_reconfig) 2641 return false; 2642 2643 /* 2644 * If quiescing is set, we are racing with __ieee80211_suspend. 2645 * __ieee80211_suspend flushes the workers after setting quiescing, 2646 * and we check quiescing / suspended before enqueuing new workers. 2647 * We should abort the worker to avoid the races below. 2648 */ 2649 if (local->quiescing) 2650 return false; 2651 2652 /* 2653 * We might already be suspended if the following scenario occurs: 2654 * __ieee80211_suspend Control path 2655 * 2656 * if (local->quiescing) 2657 * return; 2658 * local->quiescing = true; 2659 * flush_workqueue(); 2660 * queue_work(...); 2661 * local->suspended = true; 2662 * local->quiescing = false; 2663 * worker starts running... 2664 */ 2665 if (local->suspended) 2666 return false; 2667 2668 return true; 2669 } 2670 2671 int ieee80211_txq_setup_flows(struct ieee80211_local *local); 2672 void ieee80211_txq_set_params(struct ieee80211_local *local, int radio_idx); 2673 void ieee80211_txq_teardown_flows(struct ieee80211_local *local); 2674 void ieee80211_txq_init(struct ieee80211_sub_if_data *sdata, 2675 struct sta_info *sta, 2676 struct txq_info *txq, int tid); 2677 void ieee80211_txq_purge(struct ieee80211_local *local, 2678 struct txq_info *txqi); 2679 void ieee80211_purge_sta_txqs(struct sta_info *sta); 2680 void ieee80211_txq_remove_vlan(struct ieee80211_local *local, 2681 struct ieee80211_sub_if_data *sdata); 2682 void ieee80211_fill_txq_stats(struct cfg80211_txq_stats *txqstats, 2683 struct txq_info *txqi); 2684 void ieee80211_wake_txqs(struct tasklet_struct *t); 2685 void ieee80211_send_auth(struct ieee80211_sub_if_data *sdata, 2686 u16 transaction, u16 auth_alg, u16 status, 2687 const u8 *extra, size_t extra_len, const u8 *bssid, 2688 const u8 *da, const u8 *key, u8 key_len, u8 key_idx, 2689 u32 tx_flags); 2690 void ieee80211_send_deauth_disassoc(struct ieee80211_sub_if_data *sdata, 2691 const u8 *da, const u8 *bssid, 2692 u16 stype, u16 reason, 2693 bool send_frame, u8 *frame_buf); 2694 2695 enum { 2696 IEEE80211_PROBE_FLAG_DIRECTED = BIT(0), 2697 IEEE80211_PROBE_FLAG_MIN_CONTENT = BIT(1), 2698 IEEE80211_PROBE_FLAG_RANDOM_SN = BIT(2), 2699 }; 2700 2701 int ieee80211_build_preq_ies(struct ieee80211_sub_if_data *sdata, u8 *buffer, 2702 size_t buffer_len, 2703 struct ieee80211_scan_ies *ie_desc, 2704 const u8 *ie, size_t ie_len, 2705 u8 bands_used, u32 *rate_masks, 2706 struct cfg80211_chan_def *chandef, 2707 u32 flags); 2708 struct sk_buff *ieee80211_build_probe_req(struct ieee80211_sub_if_data *sdata, 2709 const u8 *src, const u8 *dst, 2710 u32 ratemask, 2711 struct ieee80211_channel *chan, 2712 const u8 *ssid, size_t ssid_len, 2713 const u8 *ie, size_t ie_len, 2714 u32 flags); 2715 u32 ieee80211_sta_get_rates(struct ieee80211_sub_if_data *sdata, 2716 struct ieee802_11_elems *elems, 2717 enum nl80211_band band, u32 *basic_rates); 2718 int __ieee80211_request_smps_mgd(struct ieee80211_sub_if_data *sdata, 2719 struct ieee80211_link_data *link, 2720 enum ieee80211_smps_mode smps_mode); 2721 void ieee80211_recalc_smps(struct ieee80211_sub_if_data *sdata, 2722 struct ieee80211_link_data *link); 2723 void ieee80211_recalc_min_chandef(struct ieee80211_sub_if_data *sdata, 2724 int link_id); 2725 2726 size_t ieee80211_ie_split_vendor(const u8 *ies, size_t ielen, size_t offset); 2727 u8 *ieee80211_ie_build_ht_cap(u8 *pos, struct ieee80211_sta_ht_cap *ht_cap, 2728 u16 cap); 2729 u8 *ieee80211_ie_build_ht_oper(u8 *pos, struct ieee80211_sta_ht_cap *ht_cap, 2730 const struct cfg80211_chan_def *chandef, 2731 u16 prot_mode, bool rifs_mode); 2732 void ieee80211_ie_build_wide_bw_cs(u8 *pos, 2733 const struct cfg80211_chan_def *chandef); 2734 u8 *ieee80211_ie_build_vht_cap(u8 *pos, struct ieee80211_sta_vht_cap *vht_cap, 2735 u32 cap); 2736 u8 *ieee80211_ie_build_vht_oper(u8 *pos, struct ieee80211_sta_vht_cap *vht_cap, 2737 const struct cfg80211_chan_def *chandef); 2738 u8 ieee80211_ie_len_he_cap(struct ieee80211_sub_if_data *sdata); 2739 u8 *ieee80211_ie_build_he_oper(u8 *pos, const struct cfg80211_chan_def *chandef); 2740 u8 *ieee80211_ie_build_eht_oper(u8 *pos, const struct cfg80211_chan_def *chandef, 2741 const struct ieee80211_sta_eht_cap *eht_cap); 2742 int ieee80211_parse_bitrates(const struct ieee80211_supported_band *sband, 2743 const u8 *srates, int srates_len, u32 *rates); 2744 u8 *ieee80211_add_wmm_info_ie(u8 *buf, u8 qosinfo); 2745 void ieee80211_add_s1g_capab_ie(struct ieee80211_sub_if_data *sdata, 2746 struct ieee80211_sta_s1g_cap *caps, 2747 struct sk_buff *skb); 2748 void ieee80211_add_aid_request_ie(struct ieee80211_sub_if_data *sdata, 2749 struct sk_buff *skb); 2750 2751 enum nl80211_chan_width 2752 ieee80211_sta_rx_bw_to_chan_width(enum ieee80211_sta_rx_bandwidth bw); 2753 2754 /* element building in SKBs */ 2755 int ieee80211_put_srates_elem(struct sk_buff *skb, 2756 const struct ieee80211_supported_band *sband, 2757 u32 basic_rates, u32 masked_rates, 2758 u8 element_id); 2759 int ieee80211_put_he_cap(struct sk_buff *skb, 2760 struct ieee80211_sub_if_data *sdata, 2761 const struct ieee80211_supported_band *sband, 2762 const struct ieee80211_conn_settings *conn); 2763 int ieee80211_put_he_6ghz_cap(struct sk_buff *skb, 2764 struct ieee80211_sub_if_data *sdata, 2765 enum ieee80211_smps_mode smps_mode); 2766 int ieee80211_put_eht_cap(struct sk_buff *skb, 2767 struct ieee80211_sub_if_data *sdata, 2768 const struct ieee80211_supported_band *sband, 2769 const struct ieee80211_conn_settings *conn); 2770 int ieee80211_put_uhr_cap(struct sk_buff *skb, 2771 struct ieee80211_sub_if_data *sdata, 2772 const struct ieee80211_supported_band *sband); 2773 void ieee80211_put_reg_conn(struct ieee80211_sub_if_data *sdata, 2774 struct sk_buff *skb); 2775 2776 /* channel management */ 2777 bool ieee80211_chandef_ht_oper(const struct ieee80211_ht_operation *ht_oper, 2778 struct cfg80211_chan_def *chandef); 2779 bool ieee80211_chandef_vht_oper(struct ieee80211_hw *hw, u32 vht_cap_info, 2780 const struct ieee80211_vht_operation *oper, 2781 const struct ieee80211_ht_operation *htop, 2782 struct cfg80211_chan_def *chandef); 2783 void ieee80211_chandef_eht_oper(const struct ieee80211_eht_operation_info *info, 2784 struct cfg80211_chan_def *chandef); 2785 bool ieee80211_chandef_he_6ghz_oper(struct ieee80211_local *local, 2786 const struct ieee80211_he_operation *he_oper, 2787 const struct ieee80211_eht_operation *eht_oper, 2788 struct cfg80211_chan_def *chandef); 2789 bool ieee80211_chandef_s1g_oper(struct ieee80211_local *local, 2790 const struct ieee80211_s1g_oper_ie *oper, 2791 struct cfg80211_chan_def *chandef); 2792 void ieee80211_chandef_downgrade(struct cfg80211_chan_def *chandef, 2793 struct ieee80211_conn_settings *conn); 2794 static inline void 2795 ieee80211_chanreq_downgrade(struct ieee80211_chan_req *chanreq, 2796 struct ieee80211_conn_settings *conn) 2797 { 2798 ieee80211_chandef_downgrade(&chanreq->oper, conn); 2799 if (WARN_ON(!conn)) 2800 return; 2801 if (conn->mode < IEEE80211_CONN_MODE_EHT) 2802 chanreq->ap.chan = NULL; 2803 conn->dbe_enabled = false; 2804 } 2805 2806 bool ieee80211_chanreq_identical(const struct ieee80211_chan_req *a, 2807 const struct ieee80211_chan_req *b); 2808 2809 int __must_check 2810 _ieee80211_link_use_channel(struct ieee80211_link_data *link, 2811 const struct ieee80211_chan_req *req, 2812 enum ieee80211_chanctx_mode mode, 2813 bool assign_on_failure); 2814 2815 static inline int __must_check 2816 ieee80211_link_use_channel(struct ieee80211_link_data *link, 2817 const struct ieee80211_chan_req *req, 2818 enum ieee80211_chanctx_mode mode) 2819 { 2820 return _ieee80211_link_use_channel(link, req, mode, false); 2821 } 2822 2823 int __must_check 2824 ieee80211_link_reserve_chanctx(struct ieee80211_link_data *link, 2825 const struct ieee80211_chan_req *req, 2826 enum ieee80211_chanctx_mode mode, 2827 bool radar_required); 2828 int __must_check 2829 ieee80211_link_use_reserved_context(struct ieee80211_link_data *link); 2830 void ieee80211_link_unreserve_chanctx(struct ieee80211_link_data *link); 2831 2832 int __must_check 2833 ieee80211_link_change_chanreq(struct ieee80211_link_data *link, 2834 const struct ieee80211_chan_req *req, 2835 u64 *changed); 2836 void __ieee80211_link_release_channel(struct ieee80211_link_data *link, 2837 bool skip_idle_recalc); 2838 void ieee80211_link_release_channel(struct ieee80211_link_data *link); 2839 void ieee80211_link_vlan_copy_chanctx(struct ieee80211_link_data *link); 2840 void ieee80211_link_copy_chanctx_to_vlans(struct ieee80211_link_data *link, 2841 bool clear); 2842 int ieee80211_chanctx_refcount(struct ieee80211_local *local, 2843 struct ieee80211_chanctx *ctx); 2844 2845 void ieee80211_recalc_smps_chanctx(struct ieee80211_local *local, 2846 struct ieee80211_chanctx *chanctx); 2847 void ieee80211_recalc_chanctx_min_def(struct ieee80211_local *local, 2848 struct ieee80211_chanctx *ctx); 2849 bool ieee80211_is_radar_required(struct ieee80211_local *local, 2850 struct cfg80211_scan_request *req); 2851 bool ieee80211_is_radio_idx_in_scan_req(struct wiphy *wiphy, 2852 struct cfg80211_scan_request *scan_req, 2853 int radio_idx); 2854 2855 void ieee80211_dfs_cac_timer_work(struct wiphy *wiphy, struct wiphy_work *work); 2856 void ieee80211_dfs_cac_cancel(struct ieee80211_local *local, 2857 struct ieee80211_chanctx *chanctx); 2858 void ieee80211_dfs_radar_detected_work(struct wiphy *wiphy, 2859 struct wiphy_work *work); 2860 int ieee80211_send_action_csa(struct ieee80211_sub_if_data *sdata, 2861 struct cfg80211_csa_settings *csa_settings); 2862 void ieee80211_recalc_sb_count(struct ieee80211_sub_if_data *sdata, u64 tsf); 2863 void ieee80211_recalc_dtim(struct ieee80211_sub_if_data *sdata, u64 tsf); 2864 2865 struct ieee80211_check_combinations_data { 2866 const struct cfg80211_chan_def *chandef; 2867 enum ieee80211_chanctx_mode chanmode; 2868 u8 radar_detect; 2869 int radio_idx; 2870 bool (*chanctx_filter)(struct ieee80211_chanctx *ctx, 2871 void *filter_data); 2872 void *filter_data; 2873 }; 2874 2875 int ieee80211_check_combinations_ext(struct ieee80211_sub_if_data *sdata, 2876 struct ieee80211_check_combinations_data *data); 2877 2878 static inline int 2879 ieee80211_check_combinations(struct ieee80211_sub_if_data *sdata, 2880 const struct cfg80211_chan_def *chandef, 2881 enum ieee80211_chanctx_mode chanmode, 2882 u8 radar_detect, int radio_idx) 2883 { 2884 struct ieee80211_check_combinations_data data = { 2885 .chandef = chandef, 2886 .chanmode = chanmode, 2887 .radar_detect = radar_detect, 2888 .radio_idx = radio_idx, 2889 }; 2890 2891 return ieee80211_check_combinations_ext(sdata, &data); 2892 } 2893 2894 int ieee80211_max_num_channels(struct ieee80211_local *local, int radio_idx); 2895 u32 ieee80211_get_radio_mask(struct wiphy *wiphy, struct net_device *dev); 2896 void ieee80211_recalc_chanctx_chantype(struct ieee80211_local *local, 2897 struct ieee80211_chanctx *ctx); 2898 struct ieee80211_chanctx * 2899 ieee80211_find_or_create_chanctx(struct ieee80211_sub_if_data *sdata, 2900 const struct ieee80211_chan_req *chanreq, 2901 enum ieee80211_chanctx_mode mode, 2902 bool assign_on_failure, 2903 bool *reused_ctx); 2904 void ieee80211_free_chanctx(struct ieee80211_local *local, 2905 struct ieee80211_chanctx *ctx, 2906 bool skip_idle_recalc); 2907 int ieee80211_chanctx_num_assigned(struct ieee80211_local *local, 2908 struct ieee80211_chanctx *ctx); 2909 /* TDLS */ 2910 int ieee80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev, 2911 const u8 *peer, int link_id, 2912 u8 action_code, u8 dialog_token, u16 status_code, 2913 u32 peer_capability, bool initiator, 2914 const u8 *extra_ies, size_t extra_ies_len); 2915 int ieee80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev, 2916 const u8 *peer, enum nl80211_tdls_operation oper); 2917 void ieee80211_tdls_peer_del_work(struct wiphy *wiphy, struct wiphy_work *wk); 2918 int ieee80211_tdls_channel_switch(struct wiphy *wiphy, struct net_device *dev, 2919 const u8 *addr, u8 oper_class, 2920 struct cfg80211_chan_def *chandef); 2921 void ieee80211_tdls_cancel_channel_switch(struct wiphy *wiphy, 2922 struct net_device *dev, 2923 const u8 *addr); 2924 void ieee80211_teardown_tdls_peers(struct ieee80211_link_data *link); 2925 void ieee80211_tdls_handle_disconnect(struct ieee80211_sub_if_data *sdata, 2926 const u8 *peer, u16 reason); 2927 void 2928 ieee80211_process_tdls_channel_switch(struct ieee80211_sub_if_data *sdata, 2929 struct sk_buff *skb); 2930 2931 2932 const char *ieee80211_get_reason_code_string(u16 reason_code); 2933 u16 ieee80211_encode_usf(int val); 2934 u8 *ieee80211_get_bssid(struct ieee80211_hdr *hdr, size_t len, 2935 enum nl80211_iftype type); 2936 2937 extern const struct ethtool_ops ieee80211_ethtool_ops; 2938 2939 u32 ieee80211_rate_expected_tx_airtime(struct ieee80211_hw *hw, 2940 struct ieee80211_tx_rate *tx_rate, 2941 struct rate_info *ri, 2942 enum nl80211_band band, 2943 bool ampdu, int len); 2944 u32 ieee80211_calc_expected_tx_airtime(struct ieee80211_hw *hw, 2945 struct ieee80211_vif *vif, 2946 struct ieee80211_sta *pubsta, 2947 int len, bool ampdu); 2948 #ifdef CONFIG_MAC80211_NOINLINE 2949 #define debug_noinline noinline 2950 #else 2951 #define debug_noinline 2952 #endif 2953 2954 void ieee80211_init_frag_cache(struct ieee80211_fragment_cache *cache); 2955 void ieee80211_destroy_frag_cache(struct ieee80211_fragment_cache *cache); 2956 2957 u8 ieee80211_ie_len_eht_cap(struct ieee80211_sub_if_data *sdata); 2958 2959 void 2960 ieee80211_eht_cap_ie_to_sta_eht_cap(struct ieee80211_sub_if_data *sdata, 2961 struct ieee80211_supported_band *sband, 2962 const u8 *he_cap_ie, u8 he_cap_len, 2963 const struct ieee80211_eht_cap_elem *eht_cap_ie_elem, 2964 u8 eht_cap_len, 2965 struct link_sta_info *link_sta); 2966 int ieee80211_req_neg_ttlm(struct ieee80211_sub_if_data *sdata, 2967 struct cfg80211_ttlm_params *params); 2968 2969 void ieee80211_check_wbrf_support(struct ieee80211_local *local); 2970 void ieee80211_add_wbrf(struct ieee80211_local *local, struct cfg80211_chan_def *chandef); 2971 void ieee80211_remove_wbrf(struct ieee80211_local *local, struct cfg80211_chan_def *chandef); 2972 int ieee80211_mgd_set_epcs(struct ieee80211_sub_if_data *sdata, bool enable); 2973 2974 int ieee80211_mgd_assoc_ml_reconf(struct ieee80211_sub_if_data *sdata, 2975 struct cfg80211_ml_reconf_req *req); 2976 2977 void ieee80211_stop_mbssid(struct ieee80211_sub_if_data *sdata); 2978 2979 void 2980 ieee80211_uhr_cap_ie_to_sta_uhr_cap(struct ieee80211_sub_if_data *sdata, 2981 struct ieee80211_supported_band *sband, 2982 const struct ieee80211_uhr_cap *uhr_cap, 2983 u8 uhr_cap_len, 2984 struct link_sta_info *link_sta); 2985 2986 #if IS_ENABLED(CONFIG_MAC80211_KUNIT_TEST) 2987 #define EXPORT_SYMBOL_IF_MAC80211_KUNIT(sym) EXPORT_SYMBOL_IF_KUNIT(sym) 2988 #define VISIBLE_IF_MAC80211_KUNIT 2989 ieee80211_rx_result 2990 ieee80211_drop_unencrypted_mgmt(struct ieee80211_rx_data *rx); 2991 int ieee80211_calc_chandef_subchan_offset(const struct cfg80211_chan_def *ap, 2992 u8 n_partial_subchans); 2993 void ieee80211_rearrange_tpe_psd(struct ieee80211_parsed_tpe_psd *psd, 2994 const struct cfg80211_chan_def *ap, 2995 const struct cfg80211_chan_def *used); 2996 struct ieee802_11_elems * 2997 ieee80211_determine_chan_mode(struct ieee80211_sub_if_data *sdata, 2998 struct ieee80211_conn_settings *conn, 2999 struct cfg80211_bss *cbss, 3000 struct link_sta_info *link_sta, int link_id, 3001 struct ieee80211_chan_req *chanreq, 3002 struct cfg80211_chan_def *ap_chandef, 3003 unsigned long *userspace_selectors); 3004 int ieee80211_parse_neg_ttlm(struct ieee80211_sub_if_data *sdata, 3005 const struct ieee80211_ttlm_elem *ttlm, 3006 struct ieee80211_neg_ttlm *neg_ttlm, 3007 u8 *direction); 3008 #else 3009 #define EXPORT_SYMBOL_IF_MAC80211_KUNIT(sym) 3010 #define VISIBLE_IF_MAC80211_KUNIT static 3011 #endif 3012 3013 #endif /* IEEE80211_I_H */ 3014