File Index
Files and directories
Sign in
FILE

ieee80211_i.h

File preview with syntax highlighting.

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