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