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