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