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