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