xref: /openbmc/linux/net/mac80211/ieee80211_i.h (revision 94d9864c)
1d2912cb1SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */
2f0706e82SJiri Benc /*
3f0706e82SJiri Benc  * Copyright 2002-2005, Instant802 Networks, Inc.
4f0706e82SJiri Benc  * Copyright 2005, Devicescape Software, Inc.
5f0706e82SJiri Benc  * Copyright 2006-2007	Jiri Benc <jbenc@suse.cz>
6026331c4SJouni Malinen  * Copyright 2007-2010	Johannes Berg <johannes@sipsolutions.net>
742bd20d9SAviya Erenfeld  * Copyright 2013-2015  Intel Mobile Communications GmbH
8c74025f4SJohannes Berg  * Copyright (C) 2018-2021 Intel Corporation
9f0706e82SJiri Benc  */
10f0706e82SJiri Benc 
11f0706e82SJiri Benc #ifndef IEEE80211_I_H
12f0706e82SJiri Benc #define IEEE80211_I_H
13f0706e82SJiri Benc 
14f0706e82SJiri Benc #include <linux/kernel.h>
15f0706e82SJiri Benc #include <linux/device.h>
16f0706e82SJiri Benc #include <linux/if_ether.h>
17f0706e82SJiri Benc #include <linux/interrupt.h>
18f0706e82SJiri Benc #include <linux/list.h>
19f0706e82SJiri Benc #include <linux/netdevice.h>
20f0706e82SJiri Benc #include <linux/skbuff.h>
21f0706e82SJiri Benc #include <linux/workqueue.h>
22f0706e82SJiri Benc #include <linux/types.h>
23f0706e82SJiri Benc #include <linux/spinlock.h>
24571ecf67SJohannes Berg #include <linux/etherdevice.h>
25e1e54068SJohannes Berg #include <linux/leds.h>
26a729cff8SJohannes Berg #include <linux/idr.h>
277bedd0cfSJohannes Berg #include <linux/rhashtable.h>
28779969e3SJohannes Berg #include <linux/rbtree.h>
29fe7a5d5cSJohannes Berg #include <net/ieee80211_radiotap.h>
3093da9cc1Scolin@cozybit.com #include <net/cfg80211.h>
3151cb6db0SDavid S. Miller #include <net/mac80211.h>
32fa962b92SMichal Kazior #include <net/fq.h>
332c8dccc7SJohannes Berg #include "key.h"
34f0706e82SJiri Benc #include "sta_info.h"
35bdcbd8e0SJohannes Berg #include "debug.h"
36f0706e82SJiri Benc 
373beea351SJohannes Berg extern const struct cfg80211_ops mac80211_config_ops;
383beea351SJohannes Berg 
399cfb0009SJohannes Berg struct ieee80211_local;
40f0706e82SJiri Benc 
41f0706e82SJiri Benc /* Maximum number of broadcast/multicast frames to buffer when some of the
42f0706e82SJiri Benc  * associated stations are using power saving. */
43f0706e82SJiri Benc #define AP_MAX_BC_BUFFER 128
44f0706e82SJiri Benc 
45f0706e82SJiri Benc /* Maximum number of frames buffered to all STAs, including multicast frames.
46f0706e82SJiri Benc  * Note: increasing this limit increases the potential memory requirement. Each
47f0706e82SJiri Benc  * frame can be up to about 2 kB long. */
48f0706e82SJiri Benc #define TOTAL_MAX_TX_BUFFER 512
49f0706e82SJiri Benc 
50f0706e82SJiri Benc /* Required encryption head and tailroom */
51f0706e82SJiri Benc #define IEEE80211_ENCRYPT_HEADROOM 8
52765cb46aSJouni Malinen #define IEEE80211_ENCRYPT_TAILROOM 18
53f0706e82SJiri Benc 
541ea6f9c0SJohannes Berg /* power level hasn't been configured (or set to automatic) */
551ea6f9c0SJohannes Berg #define IEEE80211_UNSET_POWER_LEVEL	INT_MIN
561ea6f9c0SJohannes Berg 
57d6a4ed6fSArik Nemtsov /*
58aa75ebc2SMichal Kazior  * Some APs experience problems when working with U-APSD. Decreasing the
59aa75ebc2SMichal Kazior  * probability of that happening by using legacy mode for all ACs but VO isn't
60aa75ebc2SMichal Kazior  * enough.
61aa75ebc2SMichal Kazior  *
62aa75ebc2SMichal Kazior  * Cisco 4410N originally forced us to enable VO by default only because it
63aa75ebc2SMichal Kazior  * treated non-VO ACs as legacy.
64aa75ebc2SMichal Kazior  *
65aa75ebc2SMichal Kazior  * However some APs (notably Netgear R7000) silently reclassify packets to
66aa75ebc2SMichal Kazior  * different ACs. Since u-APSD ACs require trigger frames for frame retrieval
67aa75ebc2SMichal Kazior  * clients would never see some frames (e.g. ARP responses) or would fetch them
68aa75ebc2SMichal Kazior  * accidentally after a long time.
69aa75ebc2SMichal Kazior  *
70aa75ebc2SMichal Kazior  * It makes little sense to enable u-APSD queues by default because it needs
71aa75ebc2SMichal Kazior  * userspace applications to be aware of it to actually take advantage of the
72aa75ebc2SMichal Kazior  * possible additional powersavings. Implicitly depending on driver autotrigger
73aa75ebc2SMichal Kazior  * frame support doesn't make much sense.
74d6a4ed6fSArik Nemtsov  */
75aa75ebc2SMichal Kazior #define IEEE80211_DEFAULT_UAPSD_QUEUES 0
76ab13315aSKalle Valo 
77ab13315aSKalle Valo #define IEEE80211_DEFAULT_MAX_SP_LEN		\
78ab13315aSKalle Valo 	IEEE80211_WMM_IE_STA_QOSINFO_SP_ALL
79ab13315aSKalle Valo 
80f438ceb8SEmmanuel Grumbach extern const u8 ieee80211_ac_to_qos_mask[IEEE80211_NUM_ACS];
81f438ceb8SEmmanuel Grumbach 
826ae16775SAntonio Quartulli #define IEEE80211_DEAUTH_FRAME_LEN	(24 /* hdr */ + 2 /* reason */)
836ae16775SAntonio Quartulli 
84167e33f4SAyala Beker #define IEEE80211_MAX_NAN_INSTANCE_ID 255
85167e33f4SAyala Beker 
86c2b13452SJohannes Berg struct ieee80211_bss {
87ef429dadSJohannes Berg 	u32 device_ts_beacon, device_ts_presp;
888c358bcdSJohannes Berg 
8943ac2ca3SJouni Malinen 	bool wmm_used;
90ab13315aSKalle Valo 	bool uapsd_supported;
9100d3f14cSJohannes Berg 
92f0706e82SJiri Benc #define IEEE80211_MAX_SUPP_RATES 32
93f0706e82SJiri Benc 	u8 supp_rates[IEEE80211_MAX_SUPP_RATES];
94f0706e82SJiri Benc 	size_t supp_rates_len;
95817cee76SAlexander Bondar 	struct ieee80211_rate *beacon_rate;
96f0706e82SJiri Benc 
972a333a0dSJohannes Berg 	u32 vht_cap_info;
982a333a0dSJohannes Berg 
9900d3f14cSJohannes Berg 	/*
10025985edcSLucas De Marchi 	 * During association, we save an ERP value from a probe response so
1015628221cSDaniel Drake 	 * that we can feed ERP info to the driver when handling the
1025628221cSDaniel Drake 	 * association completes. these fields probably won't be up-to-date
10300d3f14cSJohannes Berg 	 * otherwise, you probably don't want to use them.
10400d3f14cSJohannes Berg 	 */
10500d3f14cSJohannes Berg 	bool has_erp_value;
1065628221cSDaniel Drake 	u8 erp_value;
107fcff4f10SPaul Stewart 
108fcff4f10SPaul Stewart 	/* Keep track of the corruption of the last beacon/probe response. */
109fcff4f10SPaul Stewart 	u8 corrupt_data;
110fcff4f10SPaul Stewart 
111fcff4f10SPaul Stewart 	/* Keep track of what bits of information we have valid info for. */
112fcff4f10SPaul Stewart 	u8 valid_data;
113fcff4f10SPaul Stewart };
114fcff4f10SPaul Stewart 
115fcff4f10SPaul Stewart /**
116fcff4f10SPaul Stewart  * enum ieee80211_corrupt_data_flags - BSS data corruption flags
117fcff4f10SPaul Stewart  * @IEEE80211_BSS_CORRUPT_BEACON: last beacon frame received was corrupted
118fcff4f10SPaul Stewart  * @IEEE80211_BSS_CORRUPT_PROBE_RESP: last probe response received was corrupted
119fcff4f10SPaul Stewart  *
120fcff4f10SPaul Stewart  * These are bss flags that are attached to a bss in the
121fcff4f10SPaul Stewart  * @corrupt_data field of &struct ieee80211_bss.
122fcff4f10SPaul Stewart  */
123fcff4f10SPaul Stewart enum ieee80211_bss_corrupt_data_flags {
124fcff4f10SPaul Stewart 	IEEE80211_BSS_CORRUPT_BEACON		= BIT(0),
125fcff4f10SPaul Stewart 	IEEE80211_BSS_CORRUPT_PROBE_RESP	= BIT(1)
126fcff4f10SPaul Stewart };
127fcff4f10SPaul Stewart 
128fcff4f10SPaul Stewart /**
129fcff4f10SPaul Stewart  * enum ieee80211_valid_data_flags - BSS valid data flags
130fcff4f10SPaul Stewart  * @IEEE80211_BSS_VALID_WMM: WMM/UAPSD data was gathered from non-corrupt IE
131fcff4f10SPaul Stewart  * @IEEE80211_BSS_VALID_RATES: Supported rates were gathered from non-corrupt IE
132fcff4f10SPaul Stewart  * @IEEE80211_BSS_VALID_ERP: ERP flag was gathered from non-corrupt IE
133fcff4f10SPaul Stewart  *
134fcff4f10SPaul Stewart  * These are bss flags that are attached to a bss in the
135fcff4f10SPaul Stewart  * @valid_data field of &struct ieee80211_bss.  They show which parts
136d070f913SStephen Hemminger  * of the data structure were received as a result of an un-corrupted
137fcff4f10SPaul Stewart  * beacon/probe response.
138fcff4f10SPaul Stewart  */
139fcff4f10SPaul Stewart enum ieee80211_bss_valid_data_flags {
140fcff4f10SPaul Stewart 	IEEE80211_BSS_VALID_WMM			= BIT(1),
141fcff4f10SPaul Stewart 	IEEE80211_BSS_VALID_RATES		= BIT(2),
142fcff4f10SPaul Stewart 	IEEE80211_BSS_VALID_ERP			= BIT(3)
143f0706e82SJiri Benc };
144f0706e82SJiri Benc 
1459efeccacSMichael S. Tsirkin typedef unsigned __bitwise ieee80211_tx_result;
1469ae54c84SJohannes Berg #define TX_CONTINUE	((__force ieee80211_tx_result) 0u)
1479ae54c84SJohannes Berg #define TX_DROP		((__force ieee80211_tx_result) 1u)
1489ae54c84SJohannes Berg #define TX_QUEUED	((__force ieee80211_tx_result) 2u)
1499ae54c84SJohannes Berg 
1505cf121c3SJohannes Berg #define IEEE80211_TX_UNICAST		BIT(1)
1515cf121c3SJohannes Berg #define IEEE80211_TX_PS_BUFFERED	BIT(2)
1529ae54c84SJohannes Berg 
1535cf121c3SJohannes Berg struct ieee80211_tx_data {
154f0706e82SJiri Benc 	struct sk_buff *skb;
155252b86c4SJohannes Berg 	struct sk_buff_head skbs;
156f0706e82SJiri Benc 	struct ieee80211_local *local;
157f0706e82SJiri Benc 	struct ieee80211_sub_if_data *sdata;
158f0706e82SJiri Benc 	struct sta_info *sta;
159f0706e82SJiri Benc 	struct ieee80211_key *key;
1600d528d85SFelix Fietkau 	struct ieee80211_tx_rate rate;
1615cf121c3SJohannes Berg 
162056cdd59SJohannes Berg 	unsigned int flags;
1635cf121c3SJohannes Berg };
1645cf121c3SJohannes Berg 
1655cf121c3SJohannes Berg 
1669efeccacSMichael S. Tsirkin typedef unsigned __bitwise ieee80211_rx_result;
1675cf121c3SJohannes Berg #define RX_CONTINUE		((__force ieee80211_rx_result) 0u)
1685cf121c3SJohannes Berg #define RX_DROP_UNUSABLE	((__force ieee80211_rx_result) 1u)
1695cf121c3SJohannes Berg #define RX_DROP_MONITOR		((__force ieee80211_rx_result) 2u)
1705cf121c3SJohannes Berg #define RX_QUEUED		((__force ieee80211_rx_result) 3u)
1715cf121c3SJohannes Berg 
172554891e6SJohannes Berg /**
173554891e6SJohannes Berg  * enum ieee80211_packet_rx_flags - packet RX flags
174554891e6SJohannes Berg  * @IEEE80211_RX_AMSDU: a-MSDU packet
175554891e6SJohannes Berg  * @IEEE80211_RX_MALFORMED_ACTION_FRM: action frame is malformed
1764cfda47bSChristian Lamparter  * @IEEE80211_RX_DEFERRED_RELEASE: frame was subjected to receive reordering
177554891e6SJohannes Berg  *
178554891e6SJohannes Berg  * These are per-frame flags that are attached to a frame in the
179554891e6SJohannes Berg  * @rx_flags field of &struct ieee80211_rx_status.
180554891e6SJohannes Berg  */
181554891e6SJohannes Berg enum ieee80211_packet_rx_flags {
182554891e6SJohannes Berg 	IEEE80211_RX_AMSDU			= BIT(3),
183554891e6SJohannes Berg 	IEEE80211_RX_MALFORMED_ACTION_FRM	= BIT(4),
1844cfda47bSChristian Lamparter 	IEEE80211_RX_DEFERRED_RELEASE		= BIT(5),
185554891e6SJohannes Berg };
186554891e6SJohannes Berg 
187554891e6SJohannes Berg /**
188554891e6SJohannes Berg  * enum ieee80211_rx_flags - RX data flags
189554891e6SJohannes Berg  *
190554891e6SJohannes Berg  * @IEEE80211_RX_CMNTR: received on cooked monitor already
191ee971924SJohannes Berg  * @IEEE80211_RX_BEACON_REPORTED: This frame was already reported
192ee971924SJohannes Berg  *	to cfg80211_report_obss_beacon().
193554891e6SJohannes Berg  *
194554891e6SJohannes Berg  * These flags are used across handling multiple interfaces
195554891e6SJohannes Berg  * for a single frame.
196554891e6SJohannes Berg  */
197554891e6SJohannes Berg enum ieee80211_rx_flags {
198554891e6SJohannes Berg 	IEEE80211_RX_CMNTR		= BIT(0),
199ee971924SJohannes Berg 	IEEE80211_RX_BEACON_REPORTED	= BIT(1),
200554891e6SJohannes Berg };
2015cf121c3SJohannes Berg 
2025cf121c3SJohannes Berg struct ieee80211_rx_data {
203c5d1686bSFelix Fietkau 	struct list_head *list;
2045cf121c3SJohannes Berg 	struct sk_buff *skb;
2055cf121c3SJohannes Berg 	struct ieee80211_local *local;
2065cf121c3SJohannes Berg 	struct ieee80211_sub_if_data *sdata;
2075cf121c3SJohannes Berg 	struct sta_info *sta;
2085cf121c3SJohannes Berg 	struct ieee80211_key *key;
209056cdd59SJohannes Berg 
210056cdd59SJohannes Berg 	unsigned int flags;
2119e26297aSJohannes Berg 
2129e26297aSJohannes Berg 	/*
2139e26297aSJohannes Berg 	 * Index into sequence numbers array, 0..16
2149e26297aSJohannes Berg 	 * since the last (16) is used for non-QoS,
2159e26297aSJohannes Berg 	 * will be 16 on non-QoS frames.
2169e26297aSJohannes Berg 	 */
2179e26297aSJohannes Berg 	int seqno_idx;
2189e26297aSJohannes Berg 
2199e26297aSJohannes Berg 	/*
2209e26297aSJohannes Berg 	 * Index into the security IV/PN arrays, 0..16
2219e26297aSJohannes Berg 	 * since the last (16) is used for CCMP-encrypted
2229e26297aSJohannes Berg 	 * management frames, will be set to 16 on mgmt
2239e26297aSJohannes Berg 	 * frames and 0 on non-QoS frames.
2249e26297aSJohannes Berg 	 */
2259e26297aSJohannes Berg 	int security_idx;
2269e26297aSJohannes Berg 
227bf30ca92SJohannes Berg 	union {
228bf30ca92SJohannes Berg 		struct {
229bf30ca92SJohannes Berg 			u32 iv32;
230bf30ca92SJohannes Berg 			u16 iv16;
231bf30ca92SJohannes Berg 		} tkip;
232bf30ca92SJohannes Berg 		struct {
233bf30ca92SJohannes Berg 			u8 pn[IEEE80211_CCMP_PN_LEN];
234bf30ca92SJohannes Berg 		} ccm_gcm;
235bf30ca92SJohannes Berg 	};
236f0706e82SJiri Benc };
237f0706e82SJiri Benc 
238af296bdbSMichal Kazior struct ieee80211_csa_settings {
239af296bdbSMichal Kazior 	const u16 *counter_offsets_beacon;
240af296bdbSMichal Kazior 	const u16 *counter_offsets_presp;
241af296bdbSMichal Kazior 
242af296bdbSMichal Kazior 	int n_counter_offsets_beacon;
243af296bdbSMichal Kazior 	int n_counter_offsets_presp;
244af296bdbSMichal Kazior 
245af296bdbSMichal Kazior 	u8 count;
246af296bdbSMichal Kazior };
247af296bdbSMichal Kazior 
2485f9404abSJohn Crispin struct ieee80211_color_change_settings {
2495f9404abSJohn Crispin 	u16 counter_offset_beacon;
2505f9404abSJohn Crispin 	u16 counter_offset_presp;
2515f9404abSJohn Crispin 	u8 count;
2525f9404abSJohn Crispin };
2535f9404abSJohn Crispin 
2545dfdaf58SJohannes Berg struct beacon_data {
2555dfdaf58SJohannes Berg 	u8 *head, *tail;
2565dfdaf58SJohannes Berg 	int head_len, tail_len;
25743552be1SThomas Pedersen 	struct ieee80211_meshconf_ie *meshconf;
2588552a434SJohn Crispin 	u16 cntdwn_counter_offsets[IEEE80211_MAX_CNTDWN_COUNTERS_NUM];
2598552a434SJohn Crispin 	u8 cntdwn_current_counter;
2608860020eSJohannes Berg 	struct rcu_head rcu_head;
2615dfdaf58SJohannes Berg };
2625dfdaf58SJohannes Berg 
263aa7a0080SEyal Shapira struct probe_resp {
264aa7a0080SEyal Shapira 	struct rcu_head rcu_head;
265aa7a0080SEyal Shapira 	int len;
2668552a434SJohn Crispin 	u16 cntdwn_counter_offsets[IEEE80211_MAX_CNTDWN_COUNTERS_NUM];
2673c23215bSGustavo A. R. Silva 	u8 data[];
268aa7a0080SEyal Shapira };
269aa7a0080SEyal Shapira 
270295b02c4SAloka Dixit struct fils_discovery_data {
271295b02c4SAloka Dixit 	struct rcu_head rcu_head;
272295b02c4SAloka Dixit 	int len;
273295b02c4SAloka Dixit 	u8 data[];
274295b02c4SAloka Dixit };
275295b02c4SAloka Dixit 
276632189a0SAloka Dixit struct unsol_bcast_probe_resp_data {
277632189a0SAloka Dixit 	struct rcu_head rcu_head;
278632189a0SAloka Dixit 	int len;
279632189a0SAloka Dixit 	u8 data[];
280632189a0SAloka Dixit };
281632189a0SAloka Dixit 
282d012a605SMarco Porsch struct ps_data {
283d012a605SMarco Porsch 	/* yes, this looks ugly, but guarantees that we can later use
284d012a605SMarco Porsch 	 * bitmap_empty :)
285d012a605SMarco Porsch 	 * NB: don't touch this bitmap, use sta_info_{set,clear}_tim_bit */
2865fe2bb86SJoe Perches 	u8 tim[sizeof(unsigned long) * BITS_TO_LONGS(IEEE80211_MAX_AID + 1)]
2875fe2bb86SJoe Perches 			__aligned(__alignof__(unsigned long));
288d012a605SMarco Porsch 	struct sk_buff_head bc_buf;
289d012a605SMarco Porsch 	atomic_t num_sta_ps; /* number of stations in PS mode */
290d012a605SMarco Porsch 	int dtim_count;
291d012a605SMarco Porsch 	bool dtim_bc_mc;
292d012a605SMarco Porsch };
293d012a605SMarco Porsch 
294f0706e82SJiri Benc struct ieee80211_if_ap {
29540b275b6SJohannes Berg 	struct beacon_data __rcu *beacon;
296aa7a0080SEyal Shapira 	struct probe_resp __rcu *probe_resp;
297295b02c4SAloka Dixit 	struct fils_discovery_data __rcu *fils_discovery;
298632189a0SAloka Dixit 	struct unsol_bcast_probe_resp_data __rcu *unsol_bcast_probe_resp;
299f0706e82SJiri Benc 
30073da7d5bSSimon Wunderlich 	/* to be used after channel switch. */
30173da7d5bSSimon Wunderlich 	struct cfg80211_beacon_data *next_beacon;
3024e141dadSMichal Kazior 	struct list_head vlans; /* write-protected with RTNL and local->mtx */
3030ec3ca44SJohannes Berg 
304d012a605SMarco Porsch 	struct ps_data ps;
305030ef8f8SFelix Fietkau 	atomic_t num_mcast_sta; /* number of stations receiving multicast */
306687da132SEmmanuel Grumbach 
307ebceec86SMichael Braun 	bool multicast_to_unicast;
308f0706e82SJiri Benc };
309f0706e82SJiri Benc 
310f0706e82SJiri Benc struct ieee80211_if_vlan {
3114e141dadSMichal Kazior 	struct list_head list; /* write-protected with RTNL and local->mtx */
312f14543eeSFelix Fietkau 
313f14543eeSFelix Fietkau 	/* used for all tx if the VLAN is configured to 4-addr mode */
31440b275b6SJohannes Berg 	struct sta_info __rcu *sta;
31572f15d53SMichael Braun 	atomic_t num_mcast_sta; /* number of stations receiving multicast */
316f0706e82SJiri Benc };
317f0706e82SJiri Benc 
318ee385855SLuis Carlos Cobo struct mesh_stats {
319c8a61a7dSDaniel Walker 	__u32 fwded_mcast;		/* Mesh forwarded multicast frames */
320c8a61a7dSDaniel Walker 	__u32 fwded_unicast;		/* Mesh forwarded unicast frames */
321c8a61a7dSDaniel Walker 	__u32 fwded_frames;		/* Mesh total forwarded frames */
322ee385855SLuis Carlos Cobo 	__u32 dropped_frames_ttl;	/* Not transmitted since mesh_ttl == 0*/
323ee385855SLuis Carlos Cobo 	__u32 dropped_frames_no_route;	/* Not transmitted, no route found */
324cfee66b0SJavier Cardona 	__u32 dropped_frames_congestion;/* Not forwarded due to congestion */
325ee385855SLuis Carlos Cobo };
326ee385855SLuis Carlos Cobo 
327ee385855SLuis Carlos Cobo #define PREQ_Q_F_START		0x1
328ee385855SLuis Carlos Cobo #define PREQ_Q_F_REFRESH	0x2
329ee385855SLuis Carlos Cobo struct mesh_preq_queue {
330ee385855SLuis Carlos Cobo 	struct list_head list;
331ee385855SLuis Carlos Cobo 	u8 dst[ETH_ALEN];
332ee385855SLuis Carlos Cobo 	u8 flags;
333ee385855SLuis Carlos Cobo };
334ee385855SLuis Carlos Cobo 
3352eb278e0SJohannes Berg struct ieee80211_roc_work {
33677fdaa12SJohannes Berg 	struct list_head list;
337af6b6374SJohannes Berg 
338af6b6374SJohannes Berg 	struct ieee80211_sub_if_data *sdata;
339af6b6374SJohannes Berg 
340f679f65dSJohannes Berg 	struct ieee80211_channel *chan;
341af6b6374SJohannes Berg 
3422eb278e0SJohannes Berg 	bool started, abort, hw_begun, notified;
343b4b177a5SJohannes Berg 	bool on_channel;
344f679f65dSJohannes Berg 
345aaa016ccSJohannes Berg 	unsigned long start_time;
346e4da8c37SJohannes Berg 
3472eb278e0SJohannes Berg 	u32 duration, req_duration;
348f30221e4SJohannes Berg 	struct sk_buff *frame;
34950febf6aSJohannes Berg 	u64 cookie, mgmt_tx_cookie;
350d339d5caSIlan Peer 	enum ieee80211_roc_type type;
35177fdaa12SJohannes Berg };
35277fdaa12SJohannes Berg 
35346900298SJohannes Berg /* flags used in struct ieee80211_if_managed.flags */
354ab1faeadSJohannes Berg enum ieee80211_sta_flags {
355b291ba11SJohannes Berg 	IEEE80211_STA_CONNECTION_POLL	= BIT(1),
356b291ba11SJohannes Berg 	IEEE80211_STA_CONTROL_PORT	= BIT(2),
357a8243b72SJohannes Berg 	IEEE80211_STA_DISABLE_HT	= BIT(4),
358b291ba11SJohannes Berg 	IEEE80211_STA_MFP_ENABLED	= BIT(6),
359ab13315aSKalle Valo 	IEEE80211_STA_UAPSD_ENABLED	= BIT(7),
360375177bfSVivek Natarajan 	IEEE80211_STA_NULLFUNC_ACKED	= BIT(8),
36117e4ec14SJouni Malinen 	IEEE80211_STA_RESET_SIGNAL_AVE	= BIT(9),
36224398e39SJohannes Berg 	IEEE80211_STA_DISABLE_40MHZ	= BIT(10),
363d545dabaSMahesh Palivela 	IEEE80211_STA_DISABLE_VHT	= BIT(11),
364f2d9d270SJohannes Berg 	IEEE80211_STA_DISABLE_80P80MHZ	= BIT(12),
365f2d9d270SJohannes Berg 	IEEE80211_STA_DISABLE_160MHZ	= BIT(13),
366095d81ceSJohannes Berg 	IEEE80211_STA_DISABLE_WMM	= BIT(14),
367cd2f5dd7SAssaf Krauss 	IEEE80211_STA_ENABLE_RRM	= BIT(15),
36841cbb0f5SLuca Coelho 	IEEE80211_STA_DISABLE_HE	= BIT(16),
369ab1faeadSJohannes Berg };
370ab1faeadSJohannes Berg 
37166e67e41SJohannes Berg struct ieee80211_mgd_auth_data {
37266e67e41SJohannes Berg 	struct cfg80211_bss *bss;
37366e67e41SJohannes Berg 	unsigned long timeout;
37466e67e41SJohannes Berg 	int tries;
37566e67e41SJohannes Berg 	u16 algorithm, expected_transaction;
37666e67e41SJohannes Berg 
37766e67e41SJohannes Berg 	u8 key[WLAN_KEY_LEN_WEP104];
37866e67e41SJohannes Berg 	u8 key_len, key_idx;
379*94d9864cSJohannes Berg 	bool done, waiting;
380efb543e6SJouni Malinen 	bool peer_confirmed;
38189afe614SJohannes Berg 	bool timeout_started;
38266e67e41SJohannes Berg 
3836b8ece3aSJouni Malinen 	u16 sae_trans, sae_status;
3846b8ece3aSJouni Malinen 	size_t data_len;
3856b8ece3aSJouni Malinen 	u8 data[];
38666e67e41SJohannes Berg };
38766e67e41SJohannes Berg 
38866e67e41SJohannes Berg struct ieee80211_mgd_assoc_data {
38966e67e41SJohannes Berg 	struct cfg80211_bss *bss;
39066e67e41SJohannes Berg 	const u8 *supp_rates;
39166e67e41SJohannes Berg 
39266e67e41SJohannes Berg 	unsigned long timeout;
39366e67e41SJohannes Berg 	int tries;
39466e67e41SJohannes Berg 
39566e67e41SJohannes Berg 	u16 capability;
39666e67e41SJohannes Berg 	u8 prev_bssid[ETH_ALEN];
39766e67e41SJohannes Berg 	u8 ssid[IEEE80211_MAX_SSID_LEN];
39866e67e41SJohannes Berg 	u8 ssid_len;
39966e67e41SJohannes Berg 	u8 supp_rates_len;
40076f0303dSJohannes Berg 	bool wmm, uapsd;
401989c6505SAlexander Bondar 	bool need_beacon;
40266e67e41SJohannes Berg 	bool synced;
40389afe614SJohannes Berg 	bool timeout_started;
40466e67e41SJohannes Berg 
4059dde6423SJohannes Berg 	u8 ap_ht_param;
4069dde6423SJohannes Berg 
407b08fbbd8SJohannes Berg 	struct ieee80211_vht_cap ap_vht_cap;
408b08fbbd8SJohannes Berg 
40939404feeSJouni Malinen 	u8 fils_nonces[2 * FILS_NONCE_LEN];
41039404feeSJouni Malinen 	u8 fils_kek[FILS_MAX_KEK_LEN];
41139404feeSJouni Malinen 	size_t fils_kek_len;
41239404feeSJouni Malinen 
41366e67e41SJohannes Berg 	size_t ie_len;
41466e67e41SJohannes Berg 	u8 ie[];
41566e67e41SJohannes Berg };
41666e67e41SJohannes Berg 
41702219b3aSJohannes Berg struct ieee80211_sta_tx_tspec {
41802219b3aSJohannes Berg 	/* timestamp of the first packet in the time slice */
41902219b3aSJohannes Berg 	unsigned long time_slice_start;
42002219b3aSJohannes Berg 
42102219b3aSJohannes Berg 	u32 admitted_time; /* in usecs, unlike over the air */
42202219b3aSJohannes Berg 	u8 tsid;
42302219b3aSJohannes Berg 	s8 up; /* signed to be able to invalidate with -1 during teardown */
42402219b3aSJohannes Berg 
42502219b3aSJohannes Berg 	/* consumed TX time in microseconds in the time slice */
42602219b3aSJohannes Berg 	u32 consumed_tx_time;
42702219b3aSJohannes Berg 	enum {
42802219b3aSJohannes Berg 		TX_TSPEC_ACTION_NONE = 0,
42902219b3aSJohannes Berg 		TX_TSPEC_ACTION_DOWNGRADE,
43002219b3aSJohannes Berg 		TX_TSPEC_ACTION_STOP_DOWNGRADE,
43102219b3aSJohannes Berg 	} action;
43202219b3aSJohannes Berg 	bool downgraded;
43302219b3aSJohannes Berg };
43402219b3aSJohannes Berg 
435eb1e011aSJohannes Berg DECLARE_EWMA(beacon_signal, 4, 4)
436338c17aeSJohannes Berg 
43746900298SJohannes Berg struct ieee80211_if_managed {
438056cdd59SJohannes Berg 	struct timer_list timer;
439b291ba11SJohannes Berg 	struct timer_list conn_mon_timer;
440b291ba11SJohannes Berg 	struct timer_list bcn_mon_timer;
441c481ec97SSujith 	struct timer_list chswitch_timer;
442b291ba11SJohannes Berg 	struct work_struct monitor_work;
443c481ec97SSujith 	struct work_struct chswitch_work;
4441e4dcd01SJuuso Oikarinen 	struct work_struct beacon_connection_loss_work;
445882a7c69SJohannes Berg 	struct work_struct csa_connection_drop_work;
44646900298SJohannes Berg 
4477ccc8bd7SFelix Fietkau 	unsigned long beacon_timeout;
448b291ba11SJohannes Berg 	unsigned long probe_timeout;
449a43abf29SMaxim Levitsky 	int probe_send_count;
45004ac3c0eSFelix Fietkau 	bool nullfunc_failed;
4513f8a39ffSJohannes Berg 	u8 connection_loss:1,
4523f8a39ffSJohannes Berg 	   driver_disconnect:1,
4533f8a39ffSJohannes Berg 	   reconnect:1;
454b291ba11SJohannes Berg 
4550c1ad2caSJohannes Berg 	struct cfg80211_bss *associated;
45666e67e41SJohannes Berg 	struct ieee80211_mgd_auth_data *auth_data;
45766e67e41SJohannes Berg 	struct ieee80211_mgd_assoc_data *assoc_data;
45846900298SJohannes Berg 
459a3e2f4b6SMichael Braun 	u8 bssid[ETH_ALEN] __aligned(2);
46046900298SJohannes Berg 
461965bedadSJohannes Berg 	bool powersave; /* powersave requested for this iface */
46205cb9108SJohannes Berg 	bool broken_ap; /* AP is broken -- turn off powersave */
463989c6505SAlexander Bondar 	bool have_beacon;
464826262c3SJohannes Berg 	u8 dtim_period;
4650f78231bSJohannes Berg 	enum ieee80211_smps_mode req_smps, /* requested smps mode */
466d1f5b7a3SJohannes Berg 				 driver_smps_mode; /* smps mode request */
467d1f5b7a3SJohannes Berg 
468d1f5b7a3SJohannes Berg 	struct work_struct request_smps_work;
469965bedadSJohannes Berg 
470d6f2da5bSJiri Slaby 	unsigned int flags;
471f0706e82SJiri Benc 
4720c21e632SLuciano Coelho 	bool csa_waiting_bcn;
473f84eaa10SJohannes Berg 	bool csa_ignored_same_chan;
4740c21e632SLuciano Coelho 
475d8ec4433SJuuso Oikarinen 	bool beacon_crc_valid;
476d91f36dbSJohannes Berg 	u32 beacon_crc;
477d91f36dbSJohannes Berg 
4781672c0e3SJohannes Berg 	bool status_acked;
4791672c0e3SJohannes Berg 	bool status_received;
4801672c0e3SJohannes Berg 	__le16 status_fc;
4811672c0e3SJohannes Berg 
482fdfacf0aSJouni Malinen 	enum {
483fdfacf0aSJouni Malinen 		IEEE80211_MFP_DISABLED,
484fdfacf0aSJouni Malinen 		IEEE80211_MFP_OPTIONAL,
485fdfacf0aSJouni Malinen 		IEEE80211_MFP_REQUIRED
486fdfacf0aSJouni Malinen 	} mfp; /* management frame protection */
487fdfacf0aSJouni Malinen 
488dc41e4d4SEliad Peller 	/*
489dc41e4d4SEliad Peller 	 * Bitmask of enabled u-apsd queues,
490dc41e4d4SEliad Peller 	 * IEEE80211_WMM_IE_STA_QOSINFO_AC_BE & co. Needs a new association
491dc41e4d4SEliad Peller 	 * to take effect.
492dc41e4d4SEliad Peller 	 */
493dc41e4d4SEliad Peller 	unsigned int uapsd_queues;
494dc41e4d4SEliad Peller 
495dc41e4d4SEliad Peller 	/*
496dc41e4d4SEliad Peller 	 * Maximum number of buffered frames AP can deliver during a
497dc41e4d4SEliad Peller 	 * service period, IEEE80211_WMM_IE_STA_QOSINFO_SP_ALL or similar.
498dc41e4d4SEliad Peller 	 * Needs a new association to take effect.
499dc41e4d4SEliad Peller 	 */
500dc41e4d4SEliad Peller 	unsigned int uapsd_max_sp_len;
501dc41e4d4SEliad Peller 
502f0706e82SJiri Benc 	int wmm_last_param_set;
5032e249fc3SShaul Triebitz 	int mu_edca_last_param_set;
5049bc383deSJohannes Berg 
5059bc383deSJohannes Berg 	u8 use_4addr;
50617e4ec14SJouni Malinen 
50767baf663SJanusz Dziedzic 	s16 p2p_noa_index;
508488dd7b5SJohannes Berg 
509338c17aeSJohannes Berg 	struct ewma_beacon_signal ave_beacon_signal;
51017e4ec14SJouni Malinen 
51117e4ec14SJouni Malinen 	/*
512391a200aSJouni Malinen 	 * Number of Beacon frames used in ave_beacon_signal. This can be used
513391a200aSJouni Malinen 	 * to avoid generating less reliable cqm events that would be based
514391a200aSJouni Malinen 	 * only on couple of received frames.
515391a200aSJouni Malinen 	 */
516391a200aSJouni Malinen 	unsigned int count_beacon_signal;
517391a200aSJouni Malinen 
518976bd9efSJohannes Berg 	/* Number of times beacon loss was invoked. */
519976bd9efSJohannes Berg 	unsigned int beacon_loss_count;
520976bd9efSJohannes Berg 
521391a200aSJouni Malinen 	/*
52217e4ec14SJouni Malinen 	 * Last Beacon frame signal strength average (ave_beacon_signal / 16)
52317e4ec14SJouni Malinen 	 * that triggered a cqm event. 0 indicates that no event has been
52417e4ec14SJouni Malinen 	 * generated for the current association.
52517e4ec14SJouni Malinen 	 */
52617e4ec14SJouni Malinen 	int last_cqm_event_signal;
527615f7b9bSMeenakshi Venkataraman 
528615f7b9bSMeenakshi Venkataraman 	/*
529615f7b9bSMeenakshi Venkataraman 	 * State variables for keeping track of RSSI of the AP currently
530615f7b9bSMeenakshi Venkataraman 	 * connected to and informing driver when RSSI has gone
531615f7b9bSMeenakshi Venkataraman 	 * below/above a certain threshold.
532615f7b9bSMeenakshi Venkataraman 	 */
533615f7b9bSMeenakshi Venkataraman 	int rssi_min_thold, rssi_max_thold;
534615f7b9bSMeenakshi Venkataraman 	int last_ave_beacon_signal;
535ef96a842SBen Greear 
536ef96a842SBen Greear 	struct ieee80211_ht_cap ht_capa; /* configured ht-cap over-rides */
537ef96a842SBen Greear 	struct ieee80211_ht_cap ht_capa_mask; /* Valid parts of ht_capa */
538dd5ecfeaSJohannes Berg 	struct ieee80211_vht_cap vht_capa; /* configured VHT overrides */
539dd5ecfeaSJohannes Berg 	struct ieee80211_vht_cap vht_capa_mask; /* Valid parts of vht_capa */
5407957c6c8SThomas Pedersen 	struct ieee80211_s1g_cap s1g_capa; /* configured S1G overrides */
5417957c6c8SThomas Pedersen 	struct ieee80211_s1g_cap s1g_capa_mask; /* valid s1g_capa bits */
54281dd2b88SArik Nemtsov 
5431277b4a9SLiad Kaufman 	/* TDLS support */
54481dd2b88SArik Nemtsov 	u8 tdls_peer[ETH_ALEN] __aligned(2);
54581dd2b88SArik Nemtsov 	struct delayed_work tdls_peer_del_work;
5461277b4a9SLiad Kaufman 	struct sk_buff *orig_teardown_skb; /* The original teardown skb */
5471277b4a9SLiad Kaufman 	struct sk_buff *teardown_skb; /* A copy to send through the AP */
5481277b4a9SLiad Kaufman 	spinlock_t teardown_lock; /* To lock changing teardown_skb */
5499041c1faSArik Nemtsov 	bool tdls_chan_switch_prohibited;
55082c0cc90SArik Nemtsov 	bool tdls_wider_bw_prohibited;
55102219b3aSJohannes Berg 
55202219b3aSJohannes Berg 	/* WMM-AC TSPEC support */
55302219b3aSJohannes Berg 	struct ieee80211_sta_tx_tspec tx_tspec[IEEE80211_NUM_ACS];
55402219b3aSJohannes Berg 	/* Use a separate work struct so that we can do something here
55502219b3aSJohannes Berg 	 * while the sdata->work is flushing the queues, for example.
55602219b3aSJohannes Berg 	 * otherwise, in scenarios where we hardly get any traffic out
55702219b3aSJohannes Berg 	 * on the BE queue, but there's a lot of VO traffic, we might
55802219b3aSJohannes Berg 	 * get stuck in a downgraded situation and flush takes forever.
55902219b3aSJohannes Berg 	 */
56002219b3aSJohannes Berg 	struct delayed_work tx_tspec_wk;
5614d9ec73dSJouni Malinen 
5624d9ec73dSJouni Malinen 	/* Information elements from the last transmitted (Re)Association
5634d9ec73dSJouni Malinen 	 * Request frame.
5644d9ec73dSJouni Malinen 	 */
5654d9ec73dSJouni Malinen 	u8 *assoc_req_ies;
5664d9ec73dSJouni Malinen 	size_t assoc_req_ies_len;
567f0706e82SJiri Benc };
568f0706e82SJiri Benc 
56946900298SJohannes Berg struct ieee80211_if_ibss {
57046900298SJohannes Berg 	struct timer_list timer;
571cd7760e6SSimon Wunderlich 	struct work_struct csa_connection_drop_work;
57246900298SJohannes Berg 
573af8cdcd8SJohannes Berg 	unsigned long last_scan_completed;
5745bb644a0SJohannes Berg 
575fbd2c8dcSTeemu Paasikivi 	u32 basic_rates;
576fbd2c8dcSTeemu Paasikivi 
577af8cdcd8SJohannes Berg 	bool fixed_bssid;
578af8cdcd8SJohannes Berg 	bool fixed_channel;
579fffd0934SJohannes Berg 	bool privacy;
58046900298SJohannes Berg 
581267335d6SAntonio Quartulli 	bool control_port;
5828e8d347dSSimon Wunderlich 	bool userspace_handles_dfs;
583267335d6SAntonio Quartulli 
5844d196e4bSFelix Fietkau 	u8 bssid[ETH_ALEN] __aligned(2);
585af8cdcd8SJohannes Berg 	u8 ssid[IEEE80211_MAX_SSID_LEN];
586af8cdcd8SJohannes Berg 	u8 ssid_len, ie_len;
587af8cdcd8SJohannes Berg 	u8 *ie;
5883aede78aSSimon Wunderlich 	struct cfg80211_chan_def chandef;
58946900298SJohannes Berg 
59046900298SJohannes Berg 	unsigned long ibss_join_req;
591af8cdcd8SJohannes Berg 	/* probe response/beacon for IBSS */
592c3ffeab4SJohannes Berg 	struct beacon_data __rcu *presp;
59346900298SJohannes Berg 
594822854b0SSimon Wunderlich 	struct ieee80211_ht_cap ht_capa; /* configured ht-cap over-rides */
595822854b0SSimon Wunderlich 	struct ieee80211_ht_cap ht_capa_mask; /* Valid parts of ht_capa */
596822854b0SSimon Wunderlich 
5978bf11d8dSJohannes Berg 	spinlock_t incomplete_lock;
5988bf11d8dSJohannes Berg 	struct list_head incomplete_stations;
5998bf11d8dSJohannes Berg 
60046900298SJohannes Berg 	enum {
60146900298SJohannes Berg 		IEEE80211_IBSS_MLME_SEARCH,
60246900298SJohannes Berg 		IEEE80211_IBSS_MLME_JOINED,
60346900298SJohannes Berg 	} state;
60446900298SJohannes Berg };
60546900298SJohannes Berg 
606dbf498fbSJavier Cardona /**
607239281f8SRostislav Lisovy  * struct ieee80211_if_ocb - OCB mode state
608239281f8SRostislav Lisovy  *
609239281f8SRostislav Lisovy  * @housekeeping_timer: timer for periodic invocation of a housekeeping task
610239281f8SRostislav Lisovy  * @wrkq_flags: OCB deferred task action
611239281f8SRostislav Lisovy  * @incomplete_lock: delayed STA insertion lock
612239281f8SRostislav Lisovy  * @incomplete_stations: list of STAs waiting for delayed insertion
613239281f8SRostislav Lisovy  * @joined: indication if the interface is connected to an OCB network
614239281f8SRostislav Lisovy  */
615239281f8SRostislav Lisovy struct ieee80211_if_ocb {
616239281f8SRostislav Lisovy 	struct timer_list housekeeping_timer;
617239281f8SRostislav Lisovy 	unsigned long wrkq_flags;
618239281f8SRostislav Lisovy 
619239281f8SRostislav Lisovy 	spinlock_t incomplete_lock;
620239281f8SRostislav Lisovy 	struct list_head incomplete_stations;
621239281f8SRostislav Lisovy 
622239281f8SRostislav Lisovy 	bool joined;
623239281f8SRostislav Lisovy };
624239281f8SRostislav Lisovy 
625239281f8SRostislav Lisovy /**
626dbf498fbSJavier Cardona  * struct ieee80211_mesh_sync_ops - Extensible synchronization framework interface
627dbf498fbSJavier Cardona  *
628dbf498fbSJavier Cardona  * these declarations define the interface, which enables
629dbf498fbSJavier Cardona  * vendor-specific mesh synchronization
630dbf498fbSJavier Cardona  *
631dbf498fbSJavier Cardona  */
632dbf498fbSJavier Cardona struct ieee802_11_elems;
633dbf498fbSJavier Cardona struct ieee80211_mesh_sync_ops {
634a5b983c6SJohannes Berg 	void (*rx_bcn_presp)(struct ieee80211_sub_if_data *sdata, u16 stype,
635a5b983c6SJohannes Berg 			     struct ieee80211_mgmt *mgmt, unsigned int len,
636a5b983c6SJohannes Berg 			     const struct ieee80211_meshconf_ie *mesh_cfg,
637dbf498fbSJavier Cardona 			     struct ieee80211_rx_status *rx_status);
63843552be1SThomas Pedersen 
63943552be1SThomas Pedersen 	/* should be called with beacon_data under RCU read lock */
640445cd452SMasashi Honma 	void (*adjust_tsf)(struct ieee80211_sub_if_data *sdata,
64143552be1SThomas Pedersen 			   struct beacon_data *beacon);
642dbf498fbSJavier Cardona 	/* add other framework functions here */
643dbf498fbSJavier Cardona };
644dbf498fbSJavier Cardona 
645b8456a14SChun-Yeow Yeoh struct mesh_csa_settings {
646b8456a14SChun-Yeow Yeoh 	struct rcu_head rcu_head;
647b8456a14SChun-Yeow Yeoh 	struct cfg80211_csa_settings settings;
648b8456a14SChun-Yeow Yeoh };
649b8456a14SChun-Yeow Yeoh 
6508b5cb7e4SPavel Skripkin /**
6518b5cb7e4SPavel Skripkin  * struct mesh_table
6528b5cb7e4SPavel Skripkin  *
6538b5cb7e4SPavel Skripkin  * @known_gates: list of known mesh gates and their mpaths by the station. The
6548b5cb7e4SPavel Skripkin  * gate's mpath may or may not be resolved and active.
6558b5cb7e4SPavel Skripkin  * @gates_lock: protects updates to known_gates
6568b5cb7e4SPavel Skripkin  * @rhead: the rhashtable containing struct mesh_paths, keyed by dest addr
6578b5cb7e4SPavel Skripkin  * @walk_head: linked list containing all mesh_path objects
6588b5cb7e4SPavel Skripkin  * @walk_lock: lock protecting walk_head
6598b5cb7e4SPavel Skripkin  * @entries: number of entries in the table
6608b5cb7e4SPavel Skripkin  */
6618b5cb7e4SPavel Skripkin struct mesh_table {
6628b5cb7e4SPavel Skripkin 	struct hlist_head known_gates;
6638b5cb7e4SPavel Skripkin 	spinlock_t gates_lock;
6648b5cb7e4SPavel Skripkin 	struct rhashtable rhead;
6658b5cb7e4SPavel Skripkin 	struct hlist_head walk_head;
6668b5cb7e4SPavel Skripkin 	spinlock_t walk_lock;
6678b5cb7e4SPavel Skripkin 	atomic_t entries;		/* Up to MAX_MESH_NEIGHBOURS */
6688b5cb7e4SPavel Skripkin };
6698b5cb7e4SPavel Skripkin 
670472dbc45SJohannes Berg struct ieee80211_if_mesh {
671472dbc45SJohannes Berg 	struct timer_list housekeeping_timer;
672472dbc45SJohannes Berg 	struct timer_list mesh_path_timer;
673e304bfd3SRui Paulo 	struct timer_list mesh_path_root_timer;
674472dbc45SJohannes Berg 
67518889231SJavier Cardona 	unsigned long wrkq_flags;
676f81a9dedSThomas Pedersen 	unsigned long mbss_changed;
677472dbc45SJohannes Berg 
6780ab2e55dSBenjamin Berg 	bool userspace_handles_dfs;
6790ab2e55dSBenjamin Berg 
680472dbc45SJohannes Berg 	u8 mesh_id[IEEE80211_MAX_MESH_ID_LEN];
681472dbc45SJohannes Berg 	size_t mesh_id_len;
682472dbc45SJohannes Berg 	/* Active Path Selection Protocol Identifier */
6833491707aSRui Paulo 	u8 mesh_pp_id;
684472dbc45SJohannes Berg 	/* Active Path Selection Metric Identifier */
6853491707aSRui Paulo 	u8 mesh_pm_id;
686472dbc45SJohannes Berg 	/* Congestion Control Mode Identifier */
6873491707aSRui Paulo 	u8 mesh_cc_id;
6889e03fdfdSJavier Cardona 	/* Synchronization Protocol Identifier */
6893491707aSRui Paulo 	u8 mesh_sp_id;
6909e03fdfdSJavier Cardona 	/* Authentication Protocol Identifier */
6913491707aSRui Paulo 	u8 mesh_auth_id;
692d19b3bf6SRui Paulo 	/* Local mesh Sequence Number */
693d19b3bf6SRui Paulo 	u32 sn;
694472dbc45SJohannes Berg 	/* Last used PREQ ID */
695472dbc45SJohannes Berg 	u32 preq_id;
696472dbc45SJohannes Berg 	atomic_t mpaths;
697d19b3bf6SRui Paulo 	/* Timestamp of last SN update */
698d19b3bf6SRui Paulo 	unsigned long last_sn_update;
699dca7e943SThomas Pedersen 	/* Time when it's ok to send next PERR */
700dca7e943SThomas Pedersen 	unsigned long next_perr;
701dca7e943SThomas Pedersen 	/* Timestamp of last PREQ sent */
702472dbc45SJohannes Berg 	unsigned long last_preq;
703472dbc45SJohannes Berg 	struct mesh_rmc *rmc;
704472dbc45SJohannes Berg 	spinlock_t mesh_preq_queue_lock;
705472dbc45SJohannes Berg 	struct mesh_preq_queue preq_queue;
706472dbc45SJohannes Berg 	int preq_queue_len;
707472dbc45SJohannes Berg 	struct mesh_stats mshstats;
708472dbc45SJohannes Berg 	struct mesh_config mshcfg;
7091258d976SAshok Nagarajan 	atomic_t estab_plinks;
710472dbc45SJohannes Berg 	u32 mesh_seqnum;
711472dbc45SJohannes Berg 	bool accepting_plinks;
7125ee68e5bSJavier Cardona 	int num_gates;
7132b5e1967SThomas Pedersen 	struct beacon_data __rcu *beacon;
714581a8b0fSJavier Cardona 	const u8 *ie;
715581a8b0fSJavier Cardona 	u8 ie_len;
716b130e5ceSJavier Cardona 	enum {
717b130e5ceSJavier Cardona 		IEEE80211_MESH_SEC_NONE = 0x0,
718b130e5ceSJavier Cardona 		IEEE80211_MESH_SEC_AUTHED = 0x1,
719b130e5ceSJavier Cardona 		IEEE80211_MESH_SEC_SECURED = 0x2,
720b130e5ceSJavier Cardona 	} security;
721a6dad6a2SThomas Pedersen 	bool user_mpm;
722dbf498fbSJavier Cardona 	/* Extensible Synchronization Framework */
7238ba7acf3SJohannes Berg 	const struct ieee80211_mesh_sync_ops *sync_ops;
724dbf498fbSJavier Cardona 	s64 sync_offset_clockdrift_max;
725dbf498fbSJavier Cardona 	spinlock_t sync_offset_lock;
7263f52b7e3SMarco Porsch 	/* mesh power save */
7273f52b7e3SMarco Porsch 	enum nl80211_mesh_power_mode nonpeer_pm;
7283f52b7e3SMarco Porsch 	int ps_peers_light_sleep;
7293f52b7e3SMarco Porsch 	int ps_peers_deep_sleep;
7303f52b7e3SMarco Porsch 	struct ps_data ps;
7318f2535b9SChun-Yeow Yeoh 	/* Channel Switching Support */
732b8456a14SChun-Yeow Yeoh 	struct mesh_csa_settings __rcu *csa;
7330cb4d4dcSLuciano Coelho 	enum {
7340cb4d4dcSLuciano Coelho 		IEEE80211_MESH_CSA_ROLE_NONE,
7350cb4d4dcSLuciano Coelho 		IEEE80211_MESH_CSA_ROLE_INIT,
7360cb4d4dcSLuciano Coelho 		IEEE80211_MESH_CSA_ROLE_REPEATER,
7370cb4d4dcSLuciano Coelho 	} csa_role;
738b8456a14SChun-Yeow Yeoh 	u8 chsw_ttl;
7398f2535b9SChun-Yeow Yeoh 	u16 pre_value;
74043552be1SThomas Pedersen 
74143552be1SThomas Pedersen 	/* offset from skb->data while building IE */
74243552be1SThomas Pedersen 	int meshconf_offset;
7432bdaf386SBob Copeland 
7448b5cb7e4SPavel Skripkin 	struct mesh_table mesh_paths;
7458b5cb7e4SPavel Skripkin 	struct mesh_table mpp_paths; /* Store paths for MPP&MAP */
7462bdaf386SBob Copeland 	int mesh_paths_generation;
7472bdaf386SBob Copeland 	int mpp_paths_generation;
748472dbc45SJohannes Berg };
749902acc78SJohannes Berg 
750902acc78SJohannes Berg #ifdef CONFIG_MAC80211_MESH
751472dbc45SJohannes Berg #define IEEE80211_IFSTA_MESH_CTR_INC(msh, name)	\
752472dbc45SJohannes Berg 	do { (msh)->mshstats.name++; } while (0)
753902acc78SJohannes Berg #else
754472dbc45SJohannes Berg #define IEEE80211_IFSTA_MESH_CTR_INC(msh, name) \
755902acc78SJohannes Berg 	do { } while (0)
756902acc78SJohannes Berg #endif
757f0706e82SJiri Benc 
758213cd118SJohannes Berg /**
759213cd118SJohannes Berg  * enum ieee80211_sub_if_data_flags - virtual interface flags
760213cd118SJohannes Berg  *
761213cd118SJohannes Berg  * @IEEE80211_SDATA_ALLMULTI: interface wants all multicast packets
762213cd118SJohannes Berg  * @IEEE80211_SDATA_OPERATING_GMODE: operating in G-only mode
763213cd118SJohannes Berg  * @IEEE80211_SDATA_DONT_BRIDGE_PACKETS: bridge packets between
764213cd118SJohannes Berg  *	associated stations and deliver multicast frames both
765213cd118SJohannes Berg  *	back to wireless media and to the local net stack.
76695acac61SJohannes Berg  * @IEEE80211_SDATA_DISCONNECT_RESUME: Disconnect after resume.
7677b7eab6fSJohannes Berg  * @IEEE80211_SDATA_IN_DRIVER: indicates interface was added to driver
768213cd118SJohannes Berg  */
769213cd118SJohannes Berg enum ieee80211_sub_if_data_flags {
770213cd118SJohannes Berg 	IEEE80211_SDATA_ALLMULTI		= BIT(0),
7717986cf95SJohannes Berg 	IEEE80211_SDATA_OPERATING_GMODE		= BIT(2),
7727986cf95SJohannes Berg 	IEEE80211_SDATA_DONT_BRIDGE_PACKETS	= BIT(3),
77395acac61SJohannes Berg 	IEEE80211_SDATA_DISCONNECT_RESUME	= BIT(4),
7747b7eab6fSJohannes Berg 	IEEE80211_SDATA_IN_DRIVER		= BIT(5),
775213cd118SJohannes Berg };
776213cd118SJohannes Berg 
77734d4bc4dSJohannes Berg /**
77834d4bc4dSJohannes Berg  * enum ieee80211_sdata_state_bits - virtual interface state bits
77934d4bc4dSJohannes Berg  * @SDATA_STATE_RUNNING: virtual interface is up & running; this
78034d4bc4dSJohannes Berg  *	mirrors netif_running() but is separate for interface type
78134d4bc4dSJohannes Berg  *	change handling while the interface is up
7825b714c6aSJohannes Berg  * @SDATA_STATE_OFFCHANNEL: This interface is currently in offchannel
7835b714c6aSJohannes Berg  *	mode, so queues are stopped
784d6a83228SJohannes Berg  * @SDATA_STATE_OFFCHANNEL_BEACON_STOPPED: Beaconing was stopped due
785d6a83228SJohannes Berg  *	to offchannel, reset when offchannel returns
78634d4bc4dSJohannes Berg  */
78734d4bc4dSJohannes Berg enum ieee80211_sdata_state_bits {
78834d4bc4dSJohannes Berg 	SDATA_STATE_RUNNING,
7895b714c6aSJohannes Berg 	SDATA_STATE_OFFCHANNEL,
790d6a83228SJohannes Berg 	SDATA_STATE_OFFCHANNEL_BEACON_STOPPED,
79134d4bc4dSJohannes Berg };
79234d4bc4dSJohannes Berg 
793d01a1e65SMichal Kazior /**
794d01a1e65SMichal Kazior  * enum ieee80211_chanctx_mode - channel context configuration mode
795d01a1e65SMichal Kazior  *
796d01a1e65SMichal Kazior  * @IEEE80211_CHANCTX_SHARED: channel context may be used by
797d01a1e65SMichal Kazior  *	multiple interfaces
798d01a1e65SMichal Kazior  * @IEEE80211_CHANCTX_EXCLUSIVE: channel context can be used
799d01a1e65SMichal Kazior  *	only by a single interface. This can be used for example for
800d01a1e65SMichal Kazior  *	non-fixed channel IBSS.
801d01a1e65SMichal Kazior  */
802d01a1e65SMichal Kazior enum ieee80211_chanctx_mode {
803d01a1e65SMichal Kazior 	IEEE80211_CHANCTX_SHARED,
804d01a1e65SMichal Kazior 	IEEE80211_CHANCTX_EXCLUSIVE
805d01a1e65SMichal Kazior };
806d01a1e65SMichal Kazior 
8075bcae31dSMichal Kazior /**
8085bcae31dSMichal Kazior  * enum ieee80211_chanctx_replace_state - channel context replacement state
8095bcae31dSMichal Kazior  *
8105bcae31dSMichal Kazior  * This is used for channel context in-place reservations that require channel
8115bcae31dSMichal Kazior  * context switch/swap.
8125bcae31dSMichal Kazior  *
8135bcae31dSMichal Kazior  * @IEEE80211_CHANCTX_REPLACE_NONE: no replacement is taking place
8145bcae31dSMichal Kazior  * @IEEE80211_CHANCTX_WILL_BE_REPLACED: this channel context will be replaced
8155bcae31dSMichal Kazior  *	by a (not yet registered) channel context pointed by %replace_ctx.
8165bcae31dSMichal Kazior  * @IEEE80211_CHANCTX_REPLACES_OTHER: this (not yet registered) channel context
8175bcae31dSMichal Kazior  *	replaces an existing channel context pointed to by %replace_ctx.
8185bcae31dSMichal Kazior  */
8195bcae31dSMichal Kazior enum ieee80211_chanctx_replace_state {
8205bcae31dSMichal Kazior 	IEEE80211_CHANCTX_REPLACE_NONE,
8215bcae31dSMichal Kazior 	IEEE80211_CHANCTX_WILL_BE_REPLACED,
8225bcae31dSMichal Kazior 	IEEE80211_CHANCTX_REPLACES_OTHER,
8235bcae31dSMichal Kazior };
8245bcae31dSMichal Kazior 
825d01a1e65SMichal Kazior struct ieee80211_chanctx {
826d01a1e65SMichal Kazior 	struct list_head list;
827d01a1e65SMichal Kazior 	struct rcu_head rcu_head;
828d01a1e65SMichal Kazior 
829484298adSMichal Kazior 	struct list_head assigned_vifs;
830e3afb920SMichal Kazior 	struct list_head reserved_vifs;
831484298adSMichal Kazior 
8325bcae31dSMichal Kazior 	enum ieee80211_chanctx_replace_state replace_state;
8335bcae31dSMichal Kazior 	struct ieee80211_chanctx *replace_ctx;
8345bcae31dSMichal Kazior 
835d01a1e65SMichal Kazior 	enum ieee80211_chanctx_mode mode;
8368a61af65SJohannes Berg 	bool driver_present;
837d01a1e65SMichal Kazior 
838d01a1e65SMichal Kazior 	struct ieee80211_chanctx_conf conf;
839d01a1e65SMichal Kazior };
840d01a1e65SMichal Kazior 
84132db6b54SKyeyoon Park struct mac80211_qos_map {
84232db6b54SKyeyoon Park 	struct cfg80211_qos_map qos_map;
84332db6b54SKyeyoon Park 	struct rcu_head rcu_head;
84432db6b54SKyeyoon Park };
84532db6b54SKyeyoon Park 
846ba8c3d6fSFelix Fietkau enum txq_info_flags {
847ba8c3d6fSFelix Fietkau 	IEEE80211_TXQ_STOP,
848ba8c3d6fSFelix Fietkau 	IEEE80211_TXQ_AMPDU,
8496e0456b5SFelix Fietkau 	IEEE80211_TXQ_NO_AMSDU,
85021a5d4c3SManikanta Pubbisetty 	IEEE80211_TXQ_STOP_NETIF_TX,
851ba8c3d6fSFelix Fietkau };
852ba8c3d6fSFelix Fietkau 
853fa962b92SMichal Kazior /**
854fa962b92SMichal Kazior  * struct txq_info - per tid queue
855fa962b92SMichal Kazior  *
856fa962b92SMichal Kazior  * @tin: contains packets split into multiple flows
857fa962b92SMichal Kazior  * @def_flow: used as a fallback flow when a packet destined to @tin hashes to
858fa962b92SMichal Kazior  *	a fq_flow which is already owned by a different tin
8595caa328eSMichal Kazior  * @def_cvars: codel vars for @def_flow
86018667600SToke Høiland-Jørgensen  * @schedule_order: used with ieee80211_local->active_txqs
8612433647bSToke Høiland-Jørgensen  * @frags: used to keep fragments created after dequeue
862fa962b92SMichal Kazior  */
863ba8c3d6fSFelix Fietkau struct txq_info {
864fa962b92SMichal Kazior 	struct fq_tin tin;
8655caa328eSMichal Kazior 	struct codel_vars def_cvars;
8668d51dbb8SToke Høiland-Jørgensen 	struct codel_stats cstats;
8672433647bSToke Høiland-Jørgensen 	struct rb_node schedule_order;
868c74025f4SJohannes Berg 
869c74025f4SJohannes Berg 	struct sk_buff_head frags;
870ba8c3d6fSFelix Fietkau 	unsigned long flags;
871ba8c3d6fSFelix Fietkau 
872ba8c3d6fSFelix Fietkau 	/* keep last! */
873ba8c3d6fSFelix Fietkau 	struct ieee80211_txq txq;
874ba8c3d6fSFelix Fietkau };
875ba8c3d6fSFelix Fietkau 
876d8212184SAviya Erenfeld struct ieee80211_if_mntr {
877d8212184SAviya Erenfeld 	u32 flags;
87842bd20d9SAviya Erenfeld 	u8 mu_follow_addr[ETH_ALEN] __aligned(2);
879f64331d5SJohannes Berg 
880f64331d5SJohannes Berg 	struct list_head list;
881d8212184SAviya Erenfeld };
882d8212184SAviya Erenfeld 
8835953ff6dSAyala Beker /**
8845953ff6dSAyala Beker  * struct ieee80211_if_nan - NAN state
8855953ff6dSAyala Beker  *
8865953ff6dSAyala Beker  * @conf: current NAN configuration
887167e33f4SAyala Beker  * @func_ids: a bitmap of available instance_id's
8885953ff6dSAyala Beker  */
8895953ff6dSAyala Beker struct ieee80211_if_nan {
8905953ff6dSAyala Beker 	struct cfg80211_nan_conf conf;
891167e33f4SAyala Beker 
892167e33f4SAyala Beker 	/* protects function_inst_ids */
893167e33f4SAyala Beker 	spinlock_t func_lock;
894167e33f4SAyala Beker 	struct idr function_inst_ids;
8955953ff6dSAyala Beker };
8965953ff6dSAyala Beker 
897f0706e82SJiri Benc struct ieee80211_sub_if_data {
898f0706e82SJiri Benc 	struct list_head list;
899f0706e82SJiri Benc 
900f0706e82SJiri Benc 	struct wireless_dev wdev;
901f0706e82SJiri Benc 
90211a843b7SJohannes Berg 	/* keys */
90311a843b7SJohannes Berg 	struct list_head key_list;
90411a843b7SJohannes Berg 
9053bff1865SYogesh Ashok Powar 	/* count for keys needing tailroom space allocation */
9063bff1865SYogesh Ashok Powar 	int crypto_tx_tailroom_needed_cnt;
9078d1f7ecdSJohannes Berg 	int crypto_tx_tailroom_pending_dec;
9088d1f7ecdSJohannes Berg 	struct delayed_work dec_tailroom_needed_wk;
9093bff1865SYogesh Ashok Powar 
910f0706e82SJiri Benc 	struct net_device *dev;
911f0706e82SJiri Benc 	struct ieee80211_local *local;
912f0706e82SJiri Benc 
91313262ffdSJiri Slaby 	unsigned int flags;
9147e9ed188SDaniel Drake 
91534d4bc4dSJohannes Berg 	unsigned long state;
91634d4bc4dSJohannes Berg 
91747846c9bSJohannes Berg 	char name[IFNAMSIZ];
91847846c9bSJohannes Berg 
9193a11ce08SJohannes Berg 	struct ieee80211_fragment_cache frags;
920f0706e82SJiri Benc 
921b53be792SSimon Wunderlich 	/* TID bitmap for NoAck policy */
922b53be792SSimon Wunderlich 	u16 noack_map;
923b53be792SSimon Wunderlich 
92400e96decSYoni Divinsky 	/* bit field of ACM bits (BIT(802.1D tag)) */
92500e96decSYoni Divinsky 	u8 wmm_acm;
92600e96decSYoni Divinsky 
927e5473e80SJouni Malinen 	struct ieee80211_key __rcu *keys[NUM_DEFAULT_KEYS +
928e5473e80SJouni Malinen 					 NUM_DEFAULT_MGMT_KEYS +
929e5473e80SJouni Malinen 					 NUM_DEFAULT_BEACON_KEYS];
93040b275b6SJohannes Berg 	struct ieee80211_key __rcu *default_unicast_key;
93140b275b6SJohannes Berg 	struct ieee80211_key __rcu *default_multicast_key;
93240b275b6SJohannes Berg 	struct ieee80211_key __rcu *default_mgmt_key;
933e5473e80SJouni Malinen 	struct ieee80211_key __rcu *default_beacon_key;
934f0706e82SJiri Benc 
93594778280SJohannes Berg 	u16 sequence_number;
936a621fa4dSJohannes Berg 	__be16 control_port_protocol;
937a621fa4dSJohannes Berg 	bool control_port_no_encrypt;
9387f3f96ceSMarkus Theil 	bool control_port_no_preauth;
939018f6fbfSDenis Kenzior 	bool control_port_over_nl80211;
9402475b1ccSMax Stepanov 	int encrypt_headroom;
94194778280SJohannes Berg 
94280a83cfcSMichal Kazior 	atomic_t num_tx_queued;
94354bcbc69SJohannes Berg 	struct ieee80211_tx_queue_params tx_conf[IEEE80211_NUM_ACS];
94432db6b54SKyeyoon Park 	struct mac80211_qos_map __rcu *qos_map;
945f6f3def3SEliad Peller 
9462433647bSToke Høiland-Jørgensen 	struct airtime_info airtime[IEEE80211_NUM_ACS];
9472433647bSToke Høiland-Jørgensen 
94873da7d5bSSimon Wunderlich 	struct work_struct csa_finalize_work;
94959af6928SMichal Kazior 	bool csa_block_tx; /* write-protected by sdata_lock and local->mtx */
95033787fc4SLuciano Coelho 	struct cfg80211_chan_def csa_chandef;
95173da7d5bSSimon Wunderlich 
9525f9404abSJohn Crispin 	struct work_struct color_change_finalize_work;
9535f9404abSJohn Crispin 
954484298adSMichal Kazior 	struct list_head assigned_chanctx_list; /* protected by chanctx_mtx */
955e3afb920SMichal Kazior 	struct list_head reserved_chanctx_list; /* protected by chanctx_mtx */
956484298adSMichal Kazior 
95711335a55SLuciano Coelho 	/* context reservation -- protected with chanctx_mtx */
95811335a55SLuciano Coelho 	struct ieee80211_chanctx *reserved_chanctx;
95911335a55SLuciano Coelho 	struct cfg80211_chan_def reserved_chandef;
96009332481SMichal Kazior 	bool reserved_radar_required;
9615bcae31dSMichal Kazior 	bool reserved_ready;
96211335a55SLuciano Coelho 
96304ecd257SJohannes Berg 	/* used to reconfigure hardware SM PS */
96404ecd257SJohannes Berg 	struct work_struct recalc_smps;
96504ecd257SJohannes Berg 
96664592c8fSJohannes Berg 	struct work_struct work;
96735f20c14SJohannes Berg 	struct sk_buff_head skb_queue;
968f5a4c24eSLorenzo Bianconi 	struct sk_buff_head status_queue;
96935f20c14SJohannes Berg 
97004ecd257SJohannes Berg 	u8 needed_rx_chains;
97104ecd257SJohannes Berg 	enum ieee80211_smps_mode smps_mode;
97204ecd257SJohannes Berg 
9731ea6f9c0SJohannes Berg 	int user_power_level; /* in dBm */
9741ea6f9c0SJohannes Berg 	int ap_power_level; /* in dBm */
9751ea6f9c0SJohannes Berg 
976164eb02dSSimon Wunderlich 	bool radar_required;
977164eb02dSSimon Wunderlich 	struct delayed_work dfs_cac_timer_work;
978164eb02dSSimon Wunderlich 
9793e122be0SJohannes Berg 	/*
9803e122be0SJohannes Berg 	 * AP this belongs to: self in AP mode and
9813e122be0SJohannes Berg 	 * corresponding AP in VLAN mode, NULL for
9823e122be0SJohannes Berg 	 * all others (might be needed later in IBSS)
9833e122be0SJohannes Berg 	 */
9843e122be0SJohannes Berg 	struct ieee80211_if_ap *bss;
9853e122be0SJohannes Berg 
98637eb0b16SJouni Malinen 	/* bitmap of allowed (non-MCS) rate indexes for rate control */
98757fbcce3SJohannes Berg 	u32 rc_rateidx_mask[NUM_NL80211_BANDS];
9882ffbe6d3SFelix Fietkau 
98957fbcce3SJohannes Berg 	bool rc_has_mcs_mask[NUM_NL80211_BANDS];
99057fbcce3SJohannes Berg 	u8  rc_rateidx_mcs_mask[NUM_NL80211_BANDS][IEEE80211_HT_MCS_MASK_LEN];
991f0706e82SJiri Benc 
99257fbcce3SJohannes Berg 	bool rc_has_vht_mcs_mask[NUM_NL80211_BANDS];
99357fbcce3SJohannes Berg 	u16 rc_rateidx_vht_mcs_mask[NUM_NL80211_BANDS][NL80211_VHT_NSS_MAX];
994b119ad6eSLorenzo Bianconi 
99508fad438SJouni Malinen 	/* Beacon frame (non-MCS) rate (as a bitmap) */
99608fad438SJouni Malinen 	u32 beacon_rateidx_mask[NUM_NL80211_BANDS];
99708fad438SJouni Malinen 	bool beacon_rate_set;
99808fad438SJouni Malinen 
999f0706e82SJiri Benc 	union {
1000f0706e82SJiri Benc 		struct ieee80211_if_ap ap;
1001f0706e82SJiri Benc 		struct ieee80211_if_vlan vlan;
100246900298SJohannes Berg 		struct ieee80211_if_managed mgd;
100346900298SJohannes Berg 		struct ieee80211_if_ibss ibss;
1004472dbc45SJohannes Berg 		struct ieee80211_if_mesh mesh;
1005239281f8SRostislav Lisovy 		struct ieee80211_if_ocb ocb;
1006d8212184SAviya Erenfeld 		struct ieee80211_if_mntr mntr;
10075953ff6dSAyala Beker 		struct ieee80211_if_nan nan;
1008f0706e82SJiri Benc 	} u;
1009e9f207f0SJiri Benc 
1010e9f207f0SJiri Benc #ifdef CONFIG_MAC80211_DEBUGFS
1011e9f207f0SJiri Benc 	struct {
1012295bafb4SBen Greear 		struct dentry *subdir_stations;
1013f7e0104cSJohannes Berg 		struct dentry *default_unicast_key;
1014f7e0104cSJohannes Berg 		struct dentry *default_multicast_key;
10153cfcf6acSJouni Malinen 		struct dentry *default_mgmt_key;
1016e5473e80SJouni Malinen 		struct dentry *default_beacon_key;
10177bcfaf2fSJohannes Berg 	} debugfs;
1018e9f207f0SJiri Benc #endif
1019529ba6e9SJohannes Berg 
102032bfd35dSJohannes Berg 	/* must be last, dynamically sized area in this! */
102132bfd35dSJohannes Berg 	struct ieee80211_vif vif;
1022f0706e82SJiri Benc };
1023f0706e82SJiri Benc 
102432bfd35dSJohannes Berg static inline
102532bfd35dSJohannes Berg struct ieee80211_sub_if_data *vif_to_sdata(struct ieee80211_vif *p)
102632bfd35dSJohannes Berg {
102732bfd35dSJohannes Berg 	return container_of(p, struct ieee80211_sub_if_data, vif);
102832bfd35dSJohannes Berg }
102932bfd35dSJohannes Berg 
10308d61ffa5SJohannes Berg static inline void sdata_lock(struct ieee80211_sub_if_data *sdata)
10318d61ffa5SJohannes Berg 	__acquires(&sdata->wdev.mtx)
10328d61ffa5SJohannes Berg {
10338d61ffa5SJohannes Berg 	mutex_lock(&sdata->wdev.mtx);
10348d61ffa5SJohannes Berg 	__acquire(&sdata->wdev.mtx);
10358d61ffa5SJohannes Berg }
10368d61ffa5SJohannes Berg 
10378d61ffa5SJohannes Berg static inline void sdata_unlock(struct ieee80211_sub_if_data *sdata)
10388d61ffa5SJohannes Berg 	__releases(&sdata->wdev.mtx)
10398d61ffa5SJohannes Berg {
10408d61ffa5SJohannes Berg 	mutex_unlock(&sdata->wdev.mtx);
10418d61ffa5SJohannes Berg 	__release(&sdata->wdev.mtx);
10428d61ffa5SJohannes Berg }
10438d61ffa5SJohannes Berg 
10447ca133bcSSimon Wunderlich #define sdata_dereference(p, sdata) \
10457ca133bcSSimon Wunderlich 	rcu_dereference_protected(p, lockdep_is_held(&sdata->wdev.mtx))
10467ca133bcSSimon Wunderlich 
10478d61ffa5SJohannes Berg static inline void
10488d61ffa5SJohannes Berg sdata_assert_lock(struct ieee80211_sub_if_data *sdata)
10498d61ffa5SJohannes Berg {
10508d61ffa5SJohannes Berg 	lockdep_assert_held(&sdata->wdev.mtx);
10518d61ffa5SJohannes Berg }
10528d61ffa5SJohannes Berg 
1053438b61b7SSimon Wunderlich static inline int
1054438b61b7SSimon Wunderlich ieee80211_chandef_get_shift(struct cfg80211_chan_def *chandef)
1055438b61b7SSimon Wunderlich {
1056438b61b7SSimon Wunderlich 	switch (chandef->width) {
1057438b61b7SSimon Wunderlich 	case NL80211_CHAN_WIDTH_5:
1058438b61b7SSimon Wunderlich 		return 2;
1059438b61b7SSimon Wunderlich 	case NL80211_CHAN_WIDTH_10:
1060438b61b7SSimon Wunderlich 		return 1;
1061438b61b7SSimon Wunderlich 	default:
1062438b61b7SSimon Wunderlich 		return 0;
1063438b61b7SSimon Wunderlich 	}
1064438b61b7SSimon Wunderlich }
1065438b61b7SSimon Wunderlich 
1066438b61b7SSimon Wunderlich static inline int
1067438b61b7SSimon Wunderlich ieee80211_vif_get_shift(struct ieee80211_vif *vif)
1068438b61b7SSimon Wunderlich {
1069438b61b7SSimon Wunderlich 	struct ieee80211_chanctx_conf *chanctx_conf;
1070438b61b7SSimon Wunderlich 	int shift = 0;
1071438b61b7SSimon Wunderlich 
1072438b61b7SSimon Wunderlich 	rcu_read_lock();
1073438b61b7SSimon Wunderlich 	chanctx_conf = rcu_dereference(vif->chanctx_conf);
1074438b61b7SSimon Wunderlich 	if (chanctx_conf)
1075438b61b7SSimon Wunderlich 		shift = ieee80211_chandef_get_shift(&chanctx_conf->def);
1076438b61b7SSimon Wunderlich 	rcu_read_unlock();
1077438b61b7SSimon Wunderlich 
1078438b61b7SSimon Wunderlich 	return shift;
1079438b61b7SSimon Wunderlich }
1080438b61b7SSimon Wunderlich 
1081f0706e82SJiri Benc enum {
1082f0706e82SJiri Benc 	IEEE80211_RX_MSG	= 1,
1083f0706e82SJiri Benc 	IEEE80211_TX_STATUS_MSG	= 2,
1084f0706e82SJiri Benc };
1085f0706e82SJiri Benc 
1086ce7c9111SKalle Valo enum queue_stop_reason {
1087ce7c9111SKalle Valo 	IEEE80211_QUEUE_STOP_REASON_DRIVER,
1088520eb820SKalle Valo 	IEEE80211_QUEUE_STOP_REASON_PS,
108996f5e66eSJohannes Berg 	IEEE80211_QUEUE_STOP_REASON_CSA,
109096f5e66eSJohannes Berg 	IEEE80211_QUEUE_STOP_REASON_AGGREGATION,
109125420604SJohannes Berg 	IEEE80211_QUEUE_STOP_REASON_SUSPEND,
10928f77f384SJohannes Berg 	IEEE80211_QUEUE_STOP_REASON_SKB_ADD,
10936c17b77bSSeth Forshee 	IEEE80211_QUEUE_STOP_REASON_OFFCHANNEL,
1094445ea4e8SJohannes Berg 	IEEE80211_QUEUE_STOP_REASON_FLUSH,
1095db67d661SArik Nemtsov 	IEEE80211_QUEUE_STOP_REASON_TDLS_TEARDOWN,
1096b6da911bSLiad Kaufman 	IEEE80211_QUEUE_STOP_REASON_RESERVE_TID,
1097054c9939SJohannes Berg 	IEEE80211_QUEUE_STOP_REASON_IFTYPE_CHANGE,
1098cca07b00SLuciano Coelho 
1099cca07b00SLuciano Coelho 	IEEE80211_QUEUE_STOP_REASONS,
1100ce7c9111SKalle Valo };
1101ce7c9111SKalle Valo 
110265a6538aSLuciano Coelho #ifdef CONFIG_MAC80211_LEDS
1103e1e54068SJohannes Berg struct tpt_led_trigger {
1104e1e54068SJohannes Berg 	char name[32];
1105e1e54068SJohannes Berg 	const struct ieee80211_tpt_blink *blink_table;
1106e1e54068SJohannes Berg 	unsigned int blink_table_len;
1107e1e54068SJohannes Berg 	struct timer_list timer;
110834f11cd3SKees Cook 	struct ieee80211_local *local;
1109e1e54068SJohannes Berg 	unsigned long prev_traffic;
1110e1e54068SJohannes Berg 	unsigned long tx_bytes, rx_bytes;
111167408c8cSJohannes Berg 	unsigned int active, want;
111267408c8cSJohannes Berg 	bool running;
1113e1e54068SJohannes Berg };
111465a6538aSLuciano Coelho #endif
1115e1e54068SJohannes Berg 
1116142b9f50SHelmut Schaa /**
1117142b9f50SHelmut Schaa  * mac80211 scan flags - currently active scan mode
1118142b9f50SHelmut Schaa  *
1119142b9f50SHelmut Schaa  * @SCAN_SW_SCANNING: We're currently in the process of scanning but may as
1120142b9f50SHelmut Schaa  *	well be on the operating channel
1121142b9f50SHelmut Schaa  * @SCAN_HW_SCANNING: The hardware is scanning for us, we have no way to
1122142b9f50SHelmut Schaa  *	determine if we are on the operating channel or not
11238a690674SBen Greear  * @SCAN_ONCHANNEL_SCANNING:  Do a software scan on only the current operating
11248a690674SBen Greear  *	channel. This should not interrupt normal traffic.
11258789d459SJohannes Berg  * @SCAN_COMPLETED: Set for our scan work function when the driver reported
11268789d459SJohannes Berg  *	that the scan completed.
11278789d459SJohannes Berg  * @SCAN_ABORTED: Set for our scan work function when the driver reported
11288789d459SJohannes Berg  *	a scan complete for an aborted scan.
1129a754055aSEmmanuel Grumbach  * @SCAN_HW_CANCELLED: Set for our scan work function when the scan is being
1130a754055aSEmmanuel Grumbach  *	cancelled.
1131142b9f50SHelmut Schaa  */
1132fbe9c429SHelmut Schaa enum {
1133fbe9c429SHelmut Schaa 	SCAN_SW_SCANNING,
1134142b9f50SHelmut Schaa 	SCAN_HW_SCANNING,
11358a690674SBen Greear 	SCAN_ONCHANNEL_SCANNING,
11368789d459SJohannes Berg 	SCAN_COMPLETED,
11378789d459SJohannes Berg 	SCAN_ABORTED,
1138a754055aSEmmanuel Grumbach 	SCAN_HW_CANCELLED,
1139142b9f50SHelmut Schaa };
1140142b9f50SHelmut Schaa 
1141142b9f50SHelmut Schaa /**
1142142b9f50SHelmut Schaa  * enum mac80211_scan_state - scan state machine states
1143142b9f50SHelmut Schaa  *
1144142b9f50SHelmut Schaa  * @SCAN_DECISION: Main entry point to the scan state machine, this state
1145142b9f50SHelmut Schaa  *	determines if we should keep on scanning or switch back to the
1146142b9f50SHelmut Schaa  *	operating channel
1147142b9f50SHelmut Schaa  * @SCAN_SET_CHANNEL: Set the next channel to be scanned
1148142b9f50SHelmut Schaa  * @SCAN_SEND_PROBE: Send probe requests and wait for probe responses
114907ef03eeSJohannes Berg  * @SCAN_SUSPEND: Suspend the scan and go back to operating channel to
115007ef03eeSJohannes Berg  *	send out data
115107ef03eeSJohannes Berg  * @SCAN_RESUME: Resume the scan and scan the next channel
1152cd2bb512SSam Leffler  * @SCAN_ABORT: Abort the scan and go back to operating channel
1153142b9f50SHelmut Schaa  */
1154142b9f50SHelmut Schaa enum mac80211_scan_state {
1155142b9f50SHelmut Schaa 	SCAN_DECISION,
1156142b9f50SHelmut Schaa 	SCAN_SET_CHANNEL,
1157142b9f50SHelmut Schaa 	SCAN_SEND_PROBE,
115807ef03eeSJohannes Berg 	SCAN_SUSPEND,
115907ef03eeSJohannes Berg 	SCAN_RESUME,
1160cd2bb512SSam Leffler 	SCAN_ABORT,
1161fbe9c429SHelmut Schaa };
1162fbe9c429SHelmut Schaa 
11632433647bSToke Høiland-Jørgensen /**
11642433647bSToke Høiland-Jørgensen  * struct airtime_sched_info - state used for airtime scheduling and AQL
11652433647bSToke Høiland-Jørgensen  *
11662433647bSToke Høiland-Jørgensen  * @lock: spinlock that protects all the fields in this struct
11672433647bSToke Høiland-Jørgensen  * @active_txqs: rbtree of currently backlogged queues, sorted by virtual time
11682433647bSToke Høiland-Jørgensen  * @schedule_pos: the current position maintained while a driver walks the tree
11692433647bSToke Høiland-Jørgensen  *                with ieee80211_next_txq()
11702433647bSToke Høiland-Jørgensen  * @active_list: list of struct airtime_info structs that were active within
11712433647bSToke Høiland-Jørgensen  *               the last AIRTIME_ACTIVE_DURATION (100 ms), used to compute
11722433647bSToke Høiland-Jørgensen  *               weight_sum
11732433647bSToke Høiland-Jørgensen  * @last_weight_update: used for rate limiting walking active_list
11742433647bSToke Høiland-Jørgensen  * @last_schedule_time: tracks the last time a transmission was scheduled; used
11752433647bSToke Høiland-Jørgensen  *                      for catching up v_t if no stations are eligible for
11762433647bSToke Høiland-Jørgensen  *                      transmission.
11772433647bSToke Høiland-Jørgensen  * @v_t: global virtual time; queues with v_t < this are eligible for
11782433647bSToke Høiland-Jørgensen  *       transmission
11792433647bSToke Høiland-Jørgensen  * @weight_sum: total sum of all active stations used for dividing airtime
11802433647bSToke Høiland-Jørgensen  * @weight_sum_reciprocal: reciprocal of weight_sum (to avoid divisions in fast
11812433647bSToke Høiland-Jørgensen  *                         path - see comment above
11822433647bSToke Høiland-Jørgensen  *                         IEEE80211_RECIPROCAL_DIVISOR_64)
11832433647bSToke Høiland-Jørgensen  * @aql_txq_limit_low: AQL limit when total outstanding airtime
11842433647bSToke Høiland-Jørgensen  *                     is < IEEE80211_AQL_THRESHOLD
11852433647bSToke Høiland-Jørgensen  * @aql_txq_limit_high: AQL limit when total outstanding airtime
11862433647bSToke Høiland-Jørgensen  *                      is > IEEE80211_AQL_THRESHOLD
11872433647bSToke Høiland-Jørgensen  */
11882433647bSToke Høiland-Jørgensen struct airtime_sched_info {
11892433647bSToke Høiland-Jørgensen 	spinlock_t lock;
11902433647bSToke Høiland-Jørgensen 	struct rb_root_cached active_txqs;
11912433647bSToke Høiland-Jørgensen 	struct rb_node *schedule_pos;
11922433647bSToke Høiland-Jørgensen 	struct list_head active_list;
11932433647bSToke Høiland-Jørgensen 	u64 last_weight_update;
11942433647bSToke Høiland-Jørgensen 	u64 last_schedule_activity;
11952433647bSToke Høiland-Jørgensen 	u64 v_t;
11962433647bSToke Høiland-Jørgensen 	u64 weight_sum;
11972433647bSToke Høiland-Jørgensen 	u64 weight_sum_reciprocal;
11982433647bSToke Høiland-Jørgensen 	u32 aql_txq_limit_low;
11992433647bSToke Høiland-Jørgensen 	u32 aql_txq_limit_high;
12002433647bSToke Høiland-Jørgensen };
1201e908435eSLorenzo Bianconi DECLARE_STATIC_KEY_FALSE(aql_disable);
1202e908435eSLorenzo Bianconi 
1203f0706e82SJiri Benc struct ieee80211_local {
1204f0706e82SJiri Benc 	/* embed the driver visible part.
1205f0706e82SJiri Benc 	 * don't cast (use the static inlines below), but we keep
1206f0706e82SJiri Benc 	 * it first anyway so they become a no-op */
1207f0706e82SJiri Benc 	struct ieee80211_hw hw;
1208f0706e82SJiri Benc 
1209fa962b92SMichal Kazior 	struct fq fq;
12105caa328eSMichal Kazior 	struct codel_vars *cvars;
12115caa328eSMichal Kazior 	struct codel_params cparams;
1212fa962b92SMichal Kazior 
121318667600SToke Høiland-Jørgensen 	/* protects active_txqs and txqi->schedule_order */
12142433647bSToke Høiland-Jørgensen 	struct airtime_sched_info airtime[IEEE80211_NUM_ACS];
1215b4809e94SToke Høiland-Jørgensen 	u16 airtime_flags;
12163ace10f5SKan Yan 	u32 aql_threshold;
12173ace10f5SKan Yan 	atomic_t aql_total_pending_airtime;
1218b4809e94SToke Høiland-Jørgensen 
1219f0706e82SJiri Benc 	const struct ieee80211_ops *ops;
1220f0706e82SJiri Benc 
122142935ecaSLuis R. Rodriguez 	/*
122242935ecaSLuis R. Rodriguez 	 * private workqueue to mac80211. mac80211 makes this accessible
122342935ecaSLuis R. Rodriguez 	 * via ieee80211_queue_work()
122442935ecaSLuis R. Rodriguez 	 */
122542935ecaSLuis R. Rodriguez 	struct workqueue_struct *workqueue;
122642935ecaSLuis R. Rodriguez 
1227e4e72fb4SJohannes Berg 	unsigned long queue_stop_reasons[IEEE80211_MAX_QUEUES];
1228cca07b00SLuciano Coelho 	int q_stop_reasons[IEEE80211_MAX_QUEUES][IEEE80211_QUEUE_STOP_REASONS];
122996f5e66eSJohannes Berg 	/* also used to protect ampdu_ac_queue and amdpu_ac_stop_refcnt */
1230ce7c9111SKalle Valo 	spinlock_t queue_stop_reason_lock;
123196f5e66eSJohannes Berg 
1232f0706e82SJiri Benc 	int open_count;
12333d30d949SMichael Wu 	int monitors, cooked_mntrs;
12348cc9a739SMichael Wu 	/* number of interfaces with corresponding FIF_ flags */
12357be5086dSJohannes Berg 	int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss, fif_pspoll,
12367be5086dSJohannes Berg 	    fif_probe_req;
12376cd536feSJohannes Berg 	bool probe_req_reg;
1238873b1cf6SJouni Malinen 	bool rx_mcast_action_reg;
12394150c572SJohannes Berg 	unsigned int filter_flags; /* FIF_* */
12403b8d81e0SJohannes Berg 
12413ffc2a90SJohannes Berg 	bool wiphy_ciphers_allocated;
12423ffc2a90SJohannes Berg 
1243fe57d9f5SJohannes Berg 	bool use_chanctx;
1244fe57d9f5SJohannes Berg 
12453b8d81e0SJohannes Berg 	/* protects the aggregated multicast list and filter calls */
12463b8d81e0SJohannes Berg 	spinlock_t filter_lock;
12473b8d81e0SJohannes Berg 
12483ac64beeSJohannes Berg 	/* used for uploading changed mc list */
12493ac64beeSJohannes Berg 	struct work_struct reconfig_filter;
12503ac64beeSJohannes Berg 
12513b8d81e0SJohannes Berg 	/* aggregated multicast list */
125222bedad3SJiri Pirko 	struct netdev_hw_addr_list mc_list;
12533b8d81e0SJohannes Berg 
1254d0709a65SJohannes Berg 	bool tim_in_locked_section; /* see ieee80211_beacon_get() */
12555bb644a0SJohannes Berg 
12565bb644a0SJohannes Berg 	/*
12575bb644a0SJohannes Berg 	 * suspended is true if we finished all the suspend _and_ we have
12585bb644a0SJohannes Berg 	 * not yet come up from resume. This is to be used by mac80211
12595bb644a0SJohannes Berg 	 * to ensure driver sanity during suspend and mac80211's own
12605bb644a0SJohannes Berg 	 * sanity. It can eventually be used for WoW as well.
12615bb644a0SJohannes Berg 	 */
12625bb644a0SJohannes Berg 	bool suspended;
12635bb644a0SJohannes Berg 
1264b33fb28cSLoic Poulain 	/* suspending is true during the whole suspend process */
1265b33fb28cSLoic Poulain 	bool suspending;
1266b33fb28cSLoic Poulain 
12675bb644a0SJohannes Berg 	/*
1268ceb99fe0SJohannes Berg 	 * Resuming is true while suspended, but when we're reprogramming the
1269ceb99fe0SJohannes Berg 	 * hardware -- at that time it's allowed to use ieee80211_queue_work()
1270ceb99fe0SJohannes Berg 	 * again even though some other parts of the stack are still suspended
1271ceb99fe0SJohannes Berg 	 * and we still drop received frames to avoid waking the stack.
1272ceb99fe0SJohannes Berg 	 */
1273ceb99fe0SJohannes Berg 	bool resuming;
1274ceb99fe0SJohannes Berg 
1275ceb99fe0SJohannes Berg 	/*
12765bb644a0SJohannes Berg 	 * quiescing is true during the suspend process _only_ to
12775bb644a0SJohannes Berg 	 * ease timer cancelling etc.
12785bb644a0SJohannes Berg 	 */
12795bb644a0SJohannes Berg 	bool quiescing;
12805bb644a0SJohannes Berg 
1281ea77f12fSJohannes Berg 	/* device is started */
1282ea77f12fSJohannes Berg 	bool started;
1283ea77f12fSJohannes Berg 
128404800adaSArik Nemtsov 	/* device is during a HW reconfig */
128504800adaSArik Nemtsov 	bool in_reconfig;
128604800adaSArik Nemtsov 
1287eecc4800SJohannes Berg 	/* wowlan is enabled -- don't reconfig on resume */
1288eecc4800SJohannes Berg 	bool wowlan;
1289eecc4800SJohannes Berg 
1290164eb02dSSimon Wunderlich 	struct work_struct radar_detected_work;
1291164eb02dSSimon Wunderlich 
129204ecd257SJohannes Berg 	/* number of RX chains the hardware has */
129304ecd257SJohannes Berg 	u8 rx_chains;
129404ecd257SJohannes Berg 
129509b4a4faSJohannes Berg 	/* bitmap of which sbands were copied */
129609b4a4faSJohannes Berg 	u8 sband_allocated;
129709b4a4faSJohannes Berg 
1298b306f453SJohannes Berg 	int tx_headroom; /* required headroom for hardware/radiotap */
1299f0706e82SJiri Benc 
1300f0706e82SJiri Benc 	/* Tasklet and skb queue to process calls from IRQ mode. All frames
1301f0706e82SJiri Benc 	 * added to skb_queue will be processed, but frames in
1302f0706e82SJiri Benc 	 * skb_queue_unreliable may be dropped if the total length of these
1303f0706e82SJiri Benc 	 * queues increases over the limit. */
1304f0706e82SJiri Benc #define IEEE80211_IRQSAFE_QUEUE_LIMIT 128
1305f0706e82SJiri Benc 	struct tasklet_struct tasklet;
1306f0706e82SJiri Benc 	struct sk_buff_head skb_queue;
1307f0706e82SJiri Benc 	struct sk_buff_head skb_queue_unreliable;
1308f0706e82SJiri Benc 
1309f9e124fbSChristian Lamparter 	spinlock_t rx_path_lock;
131024a8fdadSChristian Lamparter 
1311d0709a65SJohannes Berg 	/* Station data */
1312d0709a65SJohannes Berg 	/*
13134d33960bSJohannes Berg 	 * The mutex only protects the list, hash table and
13144d33960bSJohannes Berg 	 * counter, reads are done with RCU.
1315d0709a65SJohannes Berg 	 */
131634e89507SJohannes Berg 	struct mutex sta_mtx;
13174d33960bSJohannes Berg 	spinlock_t tim_lock;
1318d0709a65SJohannes Berg 	unsigned long num_sta;
13194d33960bSJohannes Berg 	struct list_head sta_list;
132083e7e4ceSHerbert Xu 	struct rhltable sta_hash;
1321f0706e82SJiri Benc 	struct timer_list sta_cleanup;
1322f5ea9120SJohannes Berg 	int sta_generation;
1323f0706e82SJiri Benc 
13242a577d98SJohannes Berg 	struct sk_buff_head pending[IEEE80211_MAX_QUEUES];
1325f0706e82SJiri Benc 	struct tasklet_struct tx_pending_tasklet;
132621a5d4c3SManikanta Pubbisetty 	struct tasklet_struct wake_txqs_tasklet;
1327f0706e82SJiri Benc 
1328a6a67db2SJohannes Berg 	atomic_t agg_queue_stop[IEEE80211_MAX_QUEUES];
1329cd8ffc80SJohannes Berg 
1330df140465SJohannes Berg 	/* number of interfaces with allmulti RX */
1331df140465SJohannes Berg 	atomic_t iff_allmultis;
1332f0706e82SJiri Benc 
1333f0706e82SJiri Benc 	struct rate_control_ref *rate_ctrl;
1334f0706e82SJiri Benc 
13355fdb3735SArd Biesheuvel 	struct arc4_ctx wep_tx_ctx;
13365fdb3735SArd Biesheuvel 	struct arc4_ctx wep_rx_ctx;
1337f0706e82SJiri Benc 	u32 wep_iv;
1338f0706e82SJiri Benc 
1339c771c9d8SJohannes Berg 	/* see iface.c */
134079010420SJohannes Berg 	struct list_head interfaces;
1341f64331d5SJohannes Berg 	struct list_head mon_list; /* only that are IFF_UP && !cooked */
1342c771c9d8SJohannes Berg 	struct mutex iflist_mtx;
134379010420SJohannes Berg 
1344b16bd15cSJohannes Berg 	/*
1345ad0e2b5aSJohannes Berg 	 * Key mutex, protects sdata's key_list and sta_info's
134696fc6efbSAlexander Wetzel 	 * key pointers and ptk_idx (write access, they're RCU.)
1347b16bd15cSJohannes Berg 	 */
1348ad0e2b5aSJohannes Berg 	struct mutex key_mtx;
1349b16bd15cSJohannes Berg 
1350a1699b75SJohannes Berg 	/* mutex for scan and work locking */
1351a1699b75SJohannes Berg 	struct mutex mtx;
1352b16bd15cSJohannes Berg 
1353c2b13452SJohannes Berg 	/* Scanning and BSS list */
1354fbe9c429SHelmut Schaa 	unsigned long scanning;
13552a519311SJohannes Berg 	struct cfg80211_ssid scan_ssid;
13565ba63533SJohannes Berg 	struct cfg80211_scan_request *int_scan_req;
13576ea0a69cSJohannes Berg 	struct cfg80211_scan_request __rcu *scan_req;
1358c56ef672SDavid Spinadel 	struct ieee80211_scan_request *hw_scan_req;
13597ca15a0aSSimon Wunderlich 	struct cfg80211_chan_def scan_chandef;
136057fbcce3SJohannes Berg 	enum nl80211_band hw_scan_band;
1361f0706e82SJiri Benc 	int scan_channel_idx;
1362de95a54bSJohannes Berg 	int scan_ies_len;
1363c604b9f2SJohannes Berg 	int hw_scan_ies_bufsize;
13647947d3e0SAvraham Stern 	struct cfg80211_scan_info scan_info;
13658318d78aSJohannes Berg 
136685a9994aSLuciano Coelho 	struct work_struct sched_scan_stopped_work;
13675260a5b2SJohannes Berg 	struct ieee80211_sub_if_data __rcu *sched_scan_sdata;
13686ea0a69cSJohannes Berg 	struct cfg80211_sched_scan_request __rcu *sched_scan_req;
1369a344d677SJohannes Berg 	u8 scan_addr[ETH_ALEN];
137079f460caSLuciano Coelho 
1371df13cce5SHelmut Schaa 	unsigned long leave_oper_channel_time;
1372977923b0SHelmut Schaa 	enum mac80211_scan_state next_scan_state;
1373f0706e82SJiri Benc 	struct delayed_work scan_work;
1374e2fd5dbcSJohannes Berg 	struct ieee80211_sub_if_data __rcu *scan_sdata;
137555de908aSJohannes Berg 	/* For backward compatibility only -- do not use */
1376675a0b04SKarl Beldan 	struct cfg80211_chan_def _oper_chandef;
1377f0706e82SJiri Benc 
1378b8bc4b0aSJohannes Berg 	/* Temporary remain-on-channel for off-channel operations */
1379b8bc4b0aSJohannes Berg 	struct ieee80211_channel *tmp_channel;
1380b8bc4b0aSJohannes Berg 
1381d01a1e65SMichal Kazior 	/* channel contexts */
1382d01a1e65SMichal Kazior 	struct list_head chanctx_list;
1383d01a1e65SMichal Kazior 	struct mutex chanctx_mtx;
1384d01a1e65SMichal Kazior 
1385c206ca67SJohannes Berg #ifdef CONFIG_MAC80211_LEDS
13868d5c2585SJohannes Berg 	struct led_trigger tx_led, rx_led, assoc_led, radio_led;
13878d5c2585SJohannes Berg 	struct led_trigger tpt_led;
13888d5c2585SJohannes Berg 	atomic_t tx_led_active, rx_led_active, assoc_led_active;
13898d5c2585SJohannes Berg 	atomic_t radio_led_active, tpt_led_active;
1390c206ca67SJohannes Berg 	struct tpt_led_trigger *tpt_led_trigger;
1391c206ca67SJohannes Berg #endif
1392c206ca67SJohannes Berg 
1393c206ca67SJohannes Berg #ifdef CONFIG_MAC80211_DEBUG_COUNTERS
1394f0706e82SJiri Benc 	/* SNMP counters */
1395f0706e82SJiri Benc 	/* dot11CountersTable */
1396f0706e82SJiri Benc 	u32 dot11TransmittedFragmentCount;
1397f0706e82SJiri Benc 	u32 dot11MulticastTransmittedFrameCount;
1398f0706e82SJiri Benc 	u32 dot11FailedCount;
1399f0706e82SJiri Benc 	u32 dot11RetryCount;
1400f0706e82SJiri Benc 	u32 dot11MultipleRetryCount;
1401f0706e82SJiri Benc 	u32 dot11FrameDuplicateCount;
1402f0706e82SJiri Benc 	u32 dot11ReceivedFragmentCount;
1403f0706e82SJiri Benc 	u32 dot11MulticastReceivedFrameCount;
1404f0706e82SJiri Benc 	u32 dot11TransmittedFrameCount;
1405f0706e82SJiri Benc 
1406f0706e82SJiri Benc 	/* TX/RX handler statistics */
1407f0706e82SJiri Benc 	unsigned int tx_handlers_drop;
1408f0706e82SJiri Benc 	unsigned int tx_handlers_queued;
1409f0706e82SJiri Benc 	unsigned int tx_handlers_drop_wep;
1410f0706e82SJiri Benc 	unsigned int tx_handlers_drop_not_assoc;
1411f0706e82SJiri Benc 	unsigned int tx_handlers_drop_unauth_port;
1412f0706e82SJiri Benc 	unsigned int rx_handlers_drop;
1413f0706e82SJiri Benc 	unsigned int rx_handlers_queued;
1414f0706e82SJiri Benc 	unsigned int rx_handlers_drop_nullfunc;
1415f0706e82SJiri Benc 	unsigned int rx_handlers_drop_defrag;
1416f0706e82SJiri Benc 	unsigned int tx_expand_skb_head;
1417f0706e82SJiri Benc 	unsigned int tx_expand_skb_head_cloned;
1418f1160434SJohannes Berg 	unsigned int rx_expand_skb_head_defrag;
1419f0706e82SJiri Benc 	unsigned int rx_handlers_fragments;
1420f0706e82SJiri Benc 	unsigned int tx_status_drop;
1421f0706e82SJiri Benc #define I802_DEBUG_INC(c) (c)++
1422f0706e82SJiri Benc #else /* CONFIG_MAC80211_DEBUG_COUNTERS */
1423f0706e82SJiri Benc #define I802_DEBUG_INC(c) do { } while (0)
1424f0706e82SJiri Benc #endif /* CONFIG_MAC80211_DEBUG_COUNTERS */
1425f0706e82SJiri Benc 
1426f0706e82SJiri Benc 
1427f0706e82SJiri Benc 	int total_ps_buffered; /* total number of all buffered unicast and
1428f0706e82SJiri Benc 				* multicast packets for power saving stations
1429f0706e82SJiri Benc 				*/
1430520eb820SKalle Valo 
1431572e0012SKalle Valo 	bool pspolling;
1432965bedadSJohannes Berg 	/*
1433965bedadSJohannes Berg 	 * PS can only be enabled when we have exactly one managed
1434965bedadSJohannes Berg 	 * interface (and monitors) in PS, this then points there.
1435965bedadSJohannes Berg 	 */
1436965bedadSJohannes Berg 	struct ieee80211_sub_if_data *ps_sdata;
1437520eb820SKalle Valo 	struct work_struct dynamic_ps_enable_work;
1438520eb820SKalle Valo 	struct work_struct dynamic_ps_disable_work;
1439520eb820SKalle Valo 	struct timer_list dynamic_ps_timer;
14402b2c009eSJuuso Oikarinen 	struct notifier_block ifa_notifier;
1441a65240c1SJohannes Berg 	struct notifier_block ifa6_notifier;
1442f0706e82SJiri Benc 
1443ff616381SJuuso Oikarinen 	/*
1444ff616381SJuuso Oikarinen 	 * The dynamic ps timeout configured from user space via WEXT -
1445ff616381SJuuso Oikarinen 	 * this will override whatever chosen by mac80211 internally.
1446ff616381SJuuso Oikarinen 	 */
1447ff616381SJuuso Oikarinen 	int dynamic_ps_forced_timeout;
1448ff616381SJuuso Oikarinen 
14491ea6f9c0SJohannes Berg 	int user_power_level; /* in dBm, for all interfaces */
14502bf30fabSJohannes Berg 
14510f78231bSJohannes Berg 	enum ieee80211_smps_mode smps_mode;
14520f78231bSJohannes Berg 
1453f2753ddbSJohannes Berg 	struct work_struct restart_work;
1454f2753ddbSJohannes Berg 
1455e9f207f0SJiri Benc #ifdef CONFIG_MAC80211_DEBUGFS
1456e9f207f0SJiri Benc 	struct local_debugfsdentries {
14574b7679a5SJohannes Berg 		struct dentry *rcdir;
1458e9f207f0SJiri Benc 		struct dentry *keys;
1459e9f207f0SJiri Benc 	} debugfs;
1460276d9e82SJulius Niedworok 	bool force_tx_status;
1461e9f207f0SJiri Benc #endif
14624e6cbfd0SJohn W. Linville 
14632eb278e0SJohannes Berg 	/*
14642eb278e0SJohannes Berg 	 * Remain-on-channel support
14652eb278e0SJohannes Berg 	 */
1466aaa016ccSJohannes Berg 	struct delayed_work roc_work;
14672eb278e0SJohannes Berg 	struct list_head roc_list;
146821f83589SJohannes Berg 	struct work_struct hw_roc_start, hw_roc_done;
14692eb278e0SJohannes Berg 	unsigned long hw_roc_start_time;
147050febf6aSJohannes Berg 	u64 roc_cookie_counter;
147121f83589SJohannes Berg 
1472a729cff8SJohannes Berg 	struct idr ack_status_frames;
1473a729cff8SJohannes Berg 	spinlock_t ack_status_lock;
1474a729cff8SJohannes Berg 
1475f142c6b9SJohannes Berg 	struct ieee80211_sub_if_data __rcu *p2p_sdata;
1476f142c6b9SJohannes Berg 
14774b6f1dd6SJohannes Berg 	/* virtual monitor interface */
14784b6f1dd6SJohannes Berg 	struct ieee80211_sub_if_data __rcu *monitor_sdata;
14794bf88530SJohannes Berg 	struct cfg80211_chan_def monitor_chandef;
1480e9a21949SLuciano Coelho 
1481e9a21949SLuciano Coelho 	/* extended capabilities provided by mac80211 */
1482e9a21949SLuciano Coelho 	u8 ext_capa[8];
1483f0706e82SJiri Benc };
1484f0706e82SJiri Benc 
14853e122be0SJohannes Berg static inline struct ieee80211_sub_if_data *
1486d787a3e3SFelix Fietkau IEEE80211_DEV_TO_SUB_IF(const struct net_device *dev)
14873e122be0SJohannes Berg {
14883e122be0SJohannes Berg 	return netdev_priv(dev);
14893e122be0SJohannes Berg }
14903e122be0SJohannes Berg 
149171bbc994SJohannes Berg static inline struct ieee80211_sub_if_data *
149271bbc994SJohannes Berg IEEE80211_WDEV_TO_SUB_IF(struct wireless_dev *wdev)
149371bbc994SJohannes Berg {
149471bbc994SJohannes Berg 	return container_of(wdev, struct ieee80211_sub_if_data, wdev);
149571bbc994SJohannes Berg }
149671bbc994SJohannes Berg 
149721a8e9ddSMohammed Shafi Shajakhan static inline struct ieee80211_supported_band *
149821a8e9ddSMohammed Shafi Shajakhan ieee80211_get_sband(struct ieee80211_sub_if_data *sdata)
149921a8e9ddSMohammed Shafi Shajakhan {
150021a8e9ddSMohammed Shafi Shajakhan 	struct ieee80211_local *local = sdata->local;
150121a8e9ddSMohammed Shafi Shajakhan 	struct ieee80211_chanctx_conf *chanctx_conf;
150221a8e9ddSMohammed Shafi Shajakhan 	enum nl80211_band band;
150321a8e9ddSMohammed Shafi Shajakhan 
150421a8e9ddSMohammed Shafi Shajakhan 	rcu_read_lock();
150521a8e9ddSMohammed Shafi Shajakhan 	chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
150621a8e9ddSMohammed Shafi Shajakhan 
15070ee4d555SJohannes Berg 	if (!chanctx_conf) {
150821a8e9ddSMohammed Shafi Shajakhan 		rcu_read_unlock();
150921a8e9ddSMohammed Shafi Shajakhan 		return NULL;
151021a8e9ddSMohammed Shafi Shajakhan 	}
151121a8e9ddSMohammed Shafi Shajakhan 
151221a8e9ddSMohammed Shafi Shajakhan 	band = chanctx_conf->def.chan->band;
151321a8e9ddSMohammed Shafi Shajakhan 	rcu_read_unlock();
151421a8e9ddSMohammed Shafi Shajakhan 
151521a8e9ddSMohammed Shafi Shajakhan 	return local->hw.wiphy->bands[band];
151621a8e9ddSMohammed Shafi Shajakhan }
151721a8e9ddSMohammed Shafi Shajakhan 
1518c0f17eb9SChun-Yeow Yeoh /* this struct holds the value parsing from channel switch IE  */
1519c0f17eb9SChun-Yeow Yeoh struct ieee80211_csa_ie {
1520c0f17eb9SChun-Yeow Yeoh 	struct cfg80211_chan_def chandef;
1521c0f17eb9SChun-Yeow Yeoh 	u8 mode;
1522c0f17eb9SChun-Yeow Yeoh 	u8 count;
1523c0f17eb9SChun-Yeow Yeoh 	u8 ttl;
15243f718fd8SChun-Yeow Yeoh 	u16 pre_value;
15255d55371bSBenjamin Berg 	u16 reason_code;
1526ee145775SSara Sharon 	u32 max_switch_time;
1527c0f17eb9SChun-Yeow Yeoh };
1528c0f17eb9SChun-Yeow Yeoh 
1529dd76986bSJohannes Berg /* Parsed Information Elements */
1530dd76986bSJohannes Berg struct ieee802_11_elems {
15314a3cb702SJohannes Berg 	const u8 *ie_start;
1532dd76986bSJohannes Berg 	size_t total_len;
1533c6e37ed4SJohannes Berg 	u32 crc;
1534dd76986bSJohannes Berg 
1535dd76986bSJohannes Berg 	/* pointers to IEs */
153653837584SArik Nemtsov 	const struct ieee80211_tdls_lnkie *lnk_id;
153753837584SArik Nemtsov 	const struct ieee80211_ch_switch_timing *ch_sw_timing;
15389041c1faSArik Nemtsov 	const u8 *ext_capab;
15394a3cb702SJohannes Berg 	const u8 *ssid;
15404a3cb702SJohannes Berg 	const u8 *supp_rates;
15414a3cb702SJohannes Berg 	const u8 *ds_params;
15424a3cb702SJohannes Berg 	const struct ieee80211_tim_ie *tim;
15434a3cb702SJohannes Berg 	const u8 *rsn;
1544c0058df7SShaul Triebitz 	const u8 *rsnx;
15454a3cb702SJohannes Berg 	const u8 *erp_info;
15464a3cb702SJohannes Berg 	const u8 *ext_supp_rates;
15474a3cb702SJohannes Berg 	const u8 *wmm_info;
15484a3cb702SJohannes Berg 	const u8 *wmm_param;
15494a3cb702SJohannes Berg 	const struct ieee80211_ht_cap *ht_cap_elem;
15504a3cb702SJohannes Berg 	const struct ieee80211_ht_operation *ht_operation;
15514a3cb702SJohannes Berg 	const struct ieee80211_vht_cap *vht_cap_elem;
15524a3cb702SJohannes Berg 	const struct ieee80211_vht_operation *vht_operation;
15534a3cb702SJohannes Berg 	const struct ieee80211_meshconf_ie *mesh_config;
155441cbb0f5SLuca Coelho 	const u8 *he_cap;
155541cbb0f5SLuca Coelho 	const struct ieee80211_he_operation *he_operation;
1556ef11a931SJohn Crispin 	const struct ieee80211_he_spr *he_spr;
155741cbb0f5SLuca Coelho 	const struct ieee80211_mu_edca_param_set *mu_edca_param_set;
1558a6cf28e0SRajkumar Manoharan 	const struct ieee80211_he_6ghz_capa *he_6ghz_capa;
1559b0345850SWen Gong 	const struct ieee80211_tx_pwr_env *tx_pwr_env[IEEE80211_TPE_MAX_IE_COUNT];
156041cbb0f5SLuca Coelho 	const u8 *uora_element;
15614a3cb702SJohannes Berg 	const u8 *mesh_id;
15624a3cb702SJohannes Berg 	const u8 *peering;
15634a3cb702SJohannes Berg 	const __le16 *awake_window;
15644a3cb702SJohannes Berg 	const u8 *preq;
15654a3cb702SJohannes Berg 	const u8 *prep;
15664a3cb702SJohannes Berg 	const u8 *perr;
15674a3cb702SJohannes Berg 	const struct ieee80211_rann_ie *rann;
15684a3cb702SJohannes Berg 	const struct ieee80211_channel_sw_ie *ch_switch_ie;
1569b4f286a1SJohannes Berg 	const struct ieee80211_ext_chansw_ie *ext_chansw_ie;
1570b2e506bfSJohannes Berg 	const struct ieee80211_wide_bw_chansw_ie *wide_bw_chansw_ie;
1571ee145775SSara Sharon 	const u8 *max_channel_switch_time;
15724a3cb702SJohannes Berg 	const u8 *country_elem;
15734a3cb702SJohannes Berg 	const u8 *pwr_constr_elem;
1574c8d65917SSteinar H. Gunderson 	const u8 *cisco_dtpc_elem;
157579ba1d89SJohannes Berg 	const struct ieee80211_timeout_interval_ie *timeout_int;
15764a3cb702SJohannes Berg 	const u8 *opmode_notif;
157785220d71SJohannes Berg 	const struct ieee80211_sec_chan_offs_ie *sec_chan_offs;
1578c4de37eeSPeter Oh 	struct ieee80211_mesh_chansw_params_ie *mesh_chansw_params_ie;
1579e38a017bSAvraham Stern 	const struct ieee80211_bss_max_idle_period_ie *max_idle_period_ie;
158078ac51f8SSara Sharon 	const struct ieee80211_multiple_bssid_configuration *mbssid_config_ie;
158178ac51f8SSara Sharon 	const struct ieee80211_bssid_index *bssid_index;
158278ac51f8SSara Sharon 	u8 max_bssid_indicator;
158378ac51f8SSara Sharon 	u8 dtim_count;
158478ac51f8SSara Sharon 	u8 dtim_period;
15852aa485e1SJohn Crispin 	const struct ieee80211_addba_ext_ie *addba_ext_ie;
1586cd418ba6SThomas Pedersen 	const struct ieee80211_s1g_cap *s1g_capab;
1587cd418ba6SThomas Pedersen 	const struct ieee80211_s1g_oper_ie *s1g_oper;
1588cd418ba6SThomas Pedersen 	const struct ieee80211_s1g_bcn_compat_ie *s1g_bcn_compat;
15891d00ce80SThomas Pedersen 	const struct ieee80211_aid_response_ie *aid_resp;
1590dd76986bSJohannes Berg 
1591dd76986bSJohannes Berg 	/* length of them, respectively */
15929041c1faSArik Nemtsov 	u8 ext_capab_len;
1593dd76986bSJohannes Berg 	u8 ssid_len;
1594dd76986bSJohannes Berg 	u8 supp_rates_len;
1595dd76986bSJohannes Berg 	u8 tim_len;
1596dd76986bSJohannes Berg 	u8 rsn_len;
1597c0058df7SShaul Triebitz 	u8 rsnx_len;
1598dd76986bSJohannes Berg 	u8 ext_supp_rates_len;
1599dd76986bSJohannes Berg 	u8 wmm_info_len;
1600dd76986bSJohannes Berg 	u8 wmm_param_len;
160141cbb0f5SLuca Coelho 	u8 he_cap_len;
1602dd76986bSJohannes Berg 	u8 mesh_id_len;
1603dd76986bSJohannes Berg 	u8 peering_len;
1604dd76986bSJohannes Berg 	u8 preq_len;
1605dd76986bSJohannes Berg 	u8 prep_len;
1606dd76986bSJohannes Berg 	u8 perr_len;
1607dd76986bSJohannes Berg 	u8 country_elem_len;
160878ac51f8SSara Sharon 	u8 bssid_index_len;
1609b0345850SWen Gong 	u8 tx_pwr_env_len[IEEE80211_TPE_MAX_IE_COUNT];
1610b0345850SWen Gong 	u8 tx_pwr_env_num;
1611fcff4f10SPaul Stewart 
1612fcff4f10SPaul Stewart 	/* whether a parse error occurred while retrieving these elements */
1613fcff4f10SPaul Stewart 	bool parse_error;
1614dd76986bSJohannes Berg };
1615dd76986bSJohannes Berg 
1616f0706e82SJiri Benc static inline struct ieee80211_local *hw_to_local(
1617f0706e82SJiri Benc 	struct ieee80211_hw *hw)
1618f0706e82SJiri Benc {
1619f0706e82SJiri Benc 	return container_of(hw, struct ieee80211_local, hw);
1620f0706e82SJiri Benc }
1621f0706e82SJiri Benc 
1622ba8c3d6fSFelix Fietkau static inline struct txq_info *to_txq_info(struct ieee80211_txq *txq)
1623ba8c3d6fSFelix Fietkau {
1624ba8c3d6fSFelix Fietkau 	return container_of(txq, struct txq_info, txq);
1625ba8c3d6fSFelix Fietkau }
1626f0706e82SJiri Benc 
1627bb42f2d1SToke Høiland-Jørgensen static inline bool txq_has_queue(struct ieee80211_txq *txq)
1628bb42f2d1SToke Høiland-Jørgensen {
1629bb42f2d1SToke Høiland-Jørgensen 	struct txq_info *txqi = to_txq_info(txq);
1630bb42f2d1SToke Høiland-Jørgensen 
1631bb42f2d1SToke Høiland-Jørgensen 	return !(skb_queue_empty(&txqi->frags) && !txqi->tin.backlog_packets);
1632bb42f2d1SToke Høiland-Jørgensen }
1633bb42f2d1SToke Høiland-Jørgensen 
16342433647bSToke Høiland-Jørgensen static inline struct airtime_info *to_airtime_info(struct ieee80211_txq *txq)
16352433647bSToke Høiland-Jørgensen {
16362433647bSToke Høiland-Jørgensen 	struct ieee80211_sub_if_data *sdata;
16372433647bSToke Høiland-Jørgensen 	struct sta_info *sta;
16382433647bSToke Høiland-Jørgensen 
16392433647bSToke Høiland-Jørgensen 	if (txq->sta) {
16402433647bSToke Høiland-Jørgensen 		sta = container_of(txq->sta, struct sta_info, sta);
16412433647bSToke Høiland-Jørgensen 		return &sta->airtime[txq->ac];
16422433647bSToke Høiland-Jørgensen 	}
16432433647bSToke Høiland-Jørgensen 
16442433647bSToke Høiland-Jørgensen 	sdata = vif_to_sdata(txq->vif);
16452433647bSToke Høiland-Jørgensen 	return &sdata->airtime[txq->ac];
16462433647bSToke Høiland-Jørgensen }
16472433647bSToke Høiland-Jørgensen 
16482433647bSToke Høiland-Jørgensen /* To avoid divisions in the fast path, we keep pre-computed reciprocals for
16492433647bSToke Høiland-Jørgensen  * airtime weight calculations. There are two different weights to keep track
16502433647bSToke Høiland-Jørgensen  * of: The per-station weight and the sum of weights per phy.
16512433647bSToke Høiland-Jørgensen  *
16522433647bSToke Høiland-Jørgensen  * For the per-station weights (kept in airtime_info below), we use 32-bit
16532433647bSToke Høiland-Jørgensen  * reciprocals with a devisor of 2^19. This lets us keep the multiplications and
16542433647bSToke Høiland-Jørgensen  * divisions for the station weights as 32-bit operations at the cost of a bit
16552433647bSToke Høiland-Jørgensen  * of rounding error for high weights; but the choice of divisor keeps rounding
16562433647bSToke Høiland-Jørgensen  * errors <10% for weights <2^15, assuming no more than 8ms of airtime is
16572433647bSToke Høiland-Jørgensen  * reported at a time.
16582433647bSToke Høiland-Jørgensen  *
16592433647bSToke Høiland-Jørgensen  * For the per-phy sum of weights the values can get higher, so we use 64-bit
16602433647bSToke Høiland-Jørgensen  * operations for those with a 32-bit divisor, which should avoid any
16612433647bSToke Høiland-Jørgensen  * significant rounding errors.
16622433647bSToke Høiland-Jørgensen  */
16632433647bSToke Høiland-Jørgensen #define IEEE80211_RECIPROCAL_DIVISOR_64 0x100000000ULL
16642433647bSToke Høiland-Jørgensen #define IEEE80211_RECIPROCAL_SHIFT_64 32
16652433647bSToke Høiland-Jørgensen #define IEEE80211_RECIPROCAL_DIVISOR_32 0x80000U
16662433647bSToke Høiland-Jørgensen #define IEEE80211_RECIPROCAL_SHIFT_32 19
16672433647bSToke Høiland-Jørgensen 
16682433647bSToke Høiland-Jørgensen static inline void airtime_weight_set(struct airtime_info *air_info, u16 weight)
16692433647bSToke Høiland-Jørgensen {
16702433647bSToke Høiland-Jørgensen 	if (air_info->weight == weight)
16712433647bSToke Høiland-Jørgensen 		return;
16722433647bSToke Høiland-Jørgensen 
16732433647bSToke Høiland-Jørgensen 	air_info->weight = weight;
16742433647bSToke Høiland-Jørgensen 	if (weight) {
16752433647bSToke Høiland-Jørgensen 		air_info->weight_reciprocal =
16762433647bSToke Høiland-Jørgensen 			IEEE80211_RECIPROCAL_DIVISOR_32 / weight;
16772433647bSToke Høiland-Jørgensen 	} else {
16782433647bSToke Høiland-Jørgensen 		air_info->weight_reciprocal = 0;
16792433647bSToke Høiland-Jørgensen 	}
16802433647bSToke Høiland-Jørgensen }
16812433647bSToke Høiland-Jørgensen 
16822433647bSToke Høiland-Jørgensen static inline void airtime_weight_sum_set(struct airtime_sched_info *air_sched,
16832433647bSToke Høiland-Jørgensen 					  int weight_sum)
16842433647bSToke Høiland-Jørgensen {
16852433647bSToke Høiland-Jørgensen 	if (air_sched->weight_sum == weight_sum)
16862433647bSToke Høiland-Jørgensen 		return;
16872433647bSToke Høiland-Jørgensen 
16882433647bSToke Høiland-Jørgensen 	air_sched->weight_sum = weight_sum;
16892433647bSToke Høiland-Jørgensen 	if (air_sched->weight_sum) {
16902433647bSToke Høiland-Jørgensen 		air_sched->weight_sum_reciprocal = IEEE80211_RECIPROCAL_DIVISOR_64;
16912433647bSToke Høiland-Jørgensen 		do_div(air_sched->weight_sum_reciprocal, air_sched->weight_sum);
16922433647bSToke Høiland-Jørgensen 	} else {
16932433647bSToke Høiland-Jørgensen 		air_sched->weight_sum_reciprocal = 0;
16942433647bSToke Høiland-Jørgensen 	}
16952433647bSToke Høiland-Jørgensen }
16962433647bSToke Høiland-Jørgensen 
16972433647bSToke Høiland-Jørgensen /* A problem when trying to enforce airtime fairness is that we want to divide
16982433647bSToke Høiland-Jørgensen  * the airtime between the currently *active* stations. However, basing this on
16992433647bSToke Høiland-Jørgensen  * the instantaneous queue state of stations doesn't work, as queues tend to
17002433647bSToke Høiland-Jørgensen  * oscillate very quickly between empty and occupied, leading to the scheduler
17012433647bSToke Høiland-Jørgensen  * thinking only a single station is active when deciding whether to allow
17022433647bSToke Høiland-Jørgensen  * transmission (and thus not throttling correctly).
17032433647bSToke Høiland-Jørgensen  *
17042433647bSToke Høiland-Jørgensen  * To fix this we use a timer-based notion of activity: a station is considered
17052433647bSToke Høiland-Jørgensen  * active if it has been scheduled within the last 100 ms; we keep a separate
17062433647bSToke Høiland-Jørgensen  * list of all the stations considered active in this manner, and lazily update
17072433647bSToke Høiland-Jørgensen  * the total weight of active stations from this list (filtering the stations in
17082433647bSToke Høiland-Jørgensen  * the list by their 'last active' time).
17092433647bSToke Høiland-Jørgensen  *
17102433647bSToke Høiland-Jørgensen  * We add one additional safeguard to guard against stations that manage to get
17112433647bSToke Høiland-Jørgensen  * scheduled every 100 ms but don't transmit a lot of data, and thus don't use
17122433647bSToke Høiland-Jørgensen  * up any airtime. Such stations would be able to get priority for an extended
17132433647bSToke Høiland-Jørgensen  * period of time if they do start transmitting at full capacity again, and so
17142433647bSToke Høiland-Jørgensen  * we add an explicit maximum for how far behind a station is allowed to fall in
17152433647bSToke Høiland-Jørgensen  * the virtual airtime domain. This limit is set to a relatively high value of
17162433647bSToke Høiland-Jørgensen  * 20 ms because the main mechanism for catching up idle stations is the active
17172433647bSToke Høiland-Jørgensen  * state as described above; i.e., the hard limit should only be hit in
17182433647bSToke Høiland-Jørgensen  * pathological cases.
17192433647bSToke Høiland-Jørgensen  */
17202433647bSToke Høiland-Jørgensen #define AIRTIME_ACTIVE_DURATION (100 * NSEC_PER_MSEC)
17212433647bSToke Høiland-Jørgensen #define AIRTIME_MAX_BEHIND 20000 /* 20 ms */
17222433647bSToke Høiland-Jørgensen 
17232433647bSToke Høiland-Jørgensen static inline bool airtime_is_active(struct airtime_info *air_info, u64 now)
17242433647bSToke Høiland-Jørgensen {
17252433647bSToke Høiland-Jørgensen 	return air_info->last_scheduled >= now - AIRTIME_ACTIVE_DURATION;
17262433647bSToke Høiland-Jørgensen }
17272433647bSToke Høiland-Jørgensen 
17282433647bSToke Høiland-Jørgensen static inline void airtime_set_active(struct airtime_sched_info *air_sched,
17292433647bSToke Høiland-Jørgensen 				      struct airtime_info *air_info, u64 now)
17302433647bSToke Høiland-Jørgensen {
17312433647bSToke Høiland-Jørgensen 	air_info->last_scheduled = now;
17322433647bSToke Høiland-Jørgensen 	air_sched->last_schedule_activity = now;
17332433647bSToke Høiland-Jørgensen 	list_move_tail(&air_info->list, &air_sched->active_list);
17342433647bSToke Høiland-Jørgensen }
17352433647bSToke Høiland-Jørgensen 
17362433647bSToke Høiland-Jørgensen static inline bool airtime_catchup_v_t(struct airtime_sched_info *air_sched,
17372433647bSToke Høiland-Jørgensen 				       u64 v_t, u64 now)
17382433647bSToke Høiland-Jørgensen {
17392433647bSToke Høiland-Jørgensen 	air_sched->v_t = v_t;
17402433647bSToke Høiland-Jørgensen 	return true;
17412433647bSToke Høiland-Jørgensen }
17422433647bSToke Høiland-Jørgensen 
17432433647bSToke Høiland-Jørgensen static inline void init_airtime_info(struct airtime_info *air_info,
17442433647bSToke Høiland-Jørgensen 				     struct airtime_sched_info *air_sched)
17452433647bSToke Høiland-Jørgensen {
17462433647bSToke Høiland-Jørgensen 	atomic_set(&air_info->aql_tx_pending, 0);
17472433647bSToke Høiland-Jørgensen 	air_info->aql_limit_low = air_sched->aql_txq_limit_low;
17482433647bSToke Høiland-Jørgensen 	air_info->aql_limit_high = air_sched->aql_txq_limit_high;
17492433647bSToke Høiland-Jørgensen 	airtime_weight_set(air_info, IEEE80211_DEFAULT_AIRTIME_WEIGHT);
17502433647bSToke Høiland-Jørgensen 	INIT_LIST_HEAD(&air_info->list);
17512433647bSToke Høiland-Jørgensen }
17522433647bSToke Høiland-Jørgensen 
1753571ecf67SJohannes Berg static inline int ieee80211_bssid_match(const u8 *raddr, const u8 *addr)
1754571ecf67SJohannes Berg {
1755b203ca39SJoe Perches 	return ether_addr_equal(raddr, addr) ||
1756571ecf67SJohannes Berg 	       is_broadcast_ether_addr(raddr);
1757571ecf67SJohannes Berg }
1758571ecf67SJohannes Berg 
1759f4bda337SThomas Pedersen static inline bool
1760f4bda337SThomas Pedersen ieee80211_have_rx_timestamp(struct ieee80211_rx_status *status)
1761f4bda337SThomas Pedersen {
1762f4bda337SThomas Pedersen 	WARN_ON_ONCE(status->flag & RX_FLAG_MACTIME_START &&
1763f4bda337SThomas Pedersen 		     status->flag & RX_FLAG_MACTIME_END);
1764da388233SAvraham Stern 	return !!(status->flag & (RX_FLAG_MACTIME_START | RX_FLAG_MACTIME_END |
1765da388233SAvraham Stern 				  RX_FLAG_MACTIME_PLCP_START));
1766f4bda337SThomas Pedersen }
1767571ecf67SJohannes Berg 
176872f15d53SMichael Braun void ieee80211_vif_inc_num_mcast(struct ieee80211_sub_if_data *sdata);
176972f15d53SMichael Braun void ieee80211_vif_dec_num_mcast(struct ieee80211_sub_if_data *sdata);
177072f15d53SMichael Braun 
177172f15d53SMichael Braun /* This function returns the number of multicast stations connected to this
177272f15d53SMichael Braun  * interface. It returns -1 if that number is not tracked, that is for netdevs
177372f15d53SMichael Braun  * not in AP or AP_VLAN mode or when using 4addr.
177472f15d53SMichael Braun  */
177572f15d53SMichael Braun static inline int
177672f15d53SMichael Braun ieee80211_vif_get_num_mcast_if(struct ieee80211_sub_if_data *sdata)
177772f15d53SMichael Braun {
177872f15d53SMichael Braun 	if (sdata->vif.type == NL80211_IFTYPE_AP)
177972f15d53SMichael Braun 		return atomic_read(&sdata->u.ap.num_mcast_sta);
178072f15d53SMichael Braun 	if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN && !sdata->u.vlan.sta)
178172f15d53SMichael Braun 		return atomic_read(&sdata->u.vlan.num_mcast_sta);
178272f15d53SMichael Braun 	return -1;
178372f15d53SMichael Braun }
178472f15d53SMichael Braun 
1785f4bda337SThomas Pedersen u64 ieee80211_calculate_rx_timestamp(struct ieee80211_local *local,
1786f4bda337SThomas Pedersen 				     struct ieee80211_rx_status *status,
1787f4bda337SThomas Pedersen 				     unsigned int mpdu_len,
1788f4bda337SThomas Pedersen 				     unsigned int mpdu_offset);
1789e8975581SJohannes Berg int ieee80211_hw_config(struct ieee80211_local *local, u32 changed);
17905cf121c3SJohannes Berg void ieee80211_tx_set_protected(struct ieee80211_tx_data *tx);
17919c6bd790SJohannes Berg void ieee80211_bss_info_change_notify(struct ieee80211_sub_if_data *sdata,
17929c6bd790SJohannes Berg 				      u32 changed);
17930d143fe1SJohannes Berg void ieee80211_configure_filter(struct ieee80211_local *local);
179446900298SJohannes Berg u32 ieee80211_reset_erp_info(struct ieee80211_sub_if_data *sdata);
1795f0706e82SJiri Benc 
1796a2fcfccbSJohannes Berg u64 ieee80211_mgmt_tx_cookie(struct ieee80211_local *local);
17975ee00dbdSJohannes Berg int ieee80211_attach_ack_skb(struct ieee80211_local *local, struct sk_buff *skb,
17985ee00dbdSJohannes Berg 			     u64 *cookie, gfp_t gfp);
1799a2fcfccbSJohannes Berg 
180049ddf8e6SJohannes Berg void ieee80211_check_fast_rx(struct sta_info *sta);
180149ddf8e6SJohannes Berg void __ieee80211_check_fast_rx_iface(struct ieee80211_sub_if_data *sdata);
180249ddf8e6SJohannes Berg void ieee80211_check_fast_rx_iface(struct ieee80211_sub_if_data *sdata);
180349ddf8e6SJohannes Berg void ieee80211_clear_fast_rx(struct sta_info *sta);
180449ddf8e6SJohannes Berg 
180546900298SJohannes Berg /* STA code */
18069c6bd790SJohannes Berg void ieee80211_sta_setup_sdata(struct ieee80211_sub_if_data *sdata);
180777fdaa12SJohannes Berg int ieee80211_mgd_auth(struct ieee80211_sub_if_data *sdata,
180877fdaa12SJohannes Berg 		       struct cfg80211_auth_request *req);
180977fdaa12SJohannes Berg int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata,
181077fdaa12SJohannes Berg 			struct cfg80211_assoc_request *req);
181177fdaa12SJohannes Berg int ieee80211_mgd_deauth(struct ieee80211_sub_if_data *sdata,
181263c9c5e7SJohannes Berg 			 struct cfg80211_deauth_request *req);
181377fdaa12SJohannes Berg int ieee80211_mgd_disassoc(struct ieee80211_sub_if_data *sdata,
181463c9c5e7SJohannes Berg 			   struct cfg80211_disassoc_request *req);
1815572e0012SKalle Valo void ieee80211_send_pspoll(struct ieee80211_local *local,
1816572e0012SKalle Valo 			   struct ieee80211_sub_if_data *sdata);
18174a733ef1SJohannes Berg void ieee80211_recalc_ps(struct ieee80211_local *local);
1818ab095877SEliad Peller void ieee80211_recalc_ps_vif(struct ieee80211_sub_if_data *sdata);
18192b2c009eSJuuso Oikarinen int ieee80211_set_arp_filter(struct ieee80211_sub_if_data *sdata);
18201fa57d01SJohannes Berg void ieee80211_sta_work(struct ieee80211_sub_if_data *sdata);
18211fa57d01SJohannes Berg void ieee80211_sta_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
18221fa57d01SJohannes Berg 				  struct sk_buff *skb);
182309a740ceSThomas Pedersen void ieee80211_sta_rx_queued_ext(struct ieee80211_sub_if_data *sdata,
182409a740ceSThomas Pedersen 				 struct sk_buff *skb);
1825d3a910a8SLuis R. Rodriguez void ieee80211_sta_reset_beacon_monitor(struct ieee80211_sub_if_data *sdata);
1826be099e82SLuis R. Rodriguez void ieee80211_sta_reset_conn_monitor(struct ieee80211_sub_if_data *sdata);
1827afa762f6SEliad Peller void ieee80211_mgd_stop(struct ieee80211_sub_if_data *sdata);
18281672c0e3SJohannes Berg void ieee80211_mgd_conn_tx_status(struct ieee80211_sub_if_data *sdata,
18291672c0e3SJohannes Berg 				  __le16 fc, bool acked);
18301a1cb744SJohannes Berg void ieee80211_mgd_quiesce(struct ieee80211_sub_if_data *sdata);
1831b8360ab8SJohannes Berg void ieee80211_sta_restart(struct ieee80211_sub_if_data *sdata);
183202219b3aSJohannes Berg void ieee80211_sta_handle_tspec_ac_params(struct ieee80211_sub_if_data *sdata);
18337dd231ebSNaftali Goldstein void ieee80211_sta_connection_lost(struct ieee80211_sub_if_data *sdata,
18347dd231ebSNaftali Goldstein 				   u8 *bssid, u8 reason, bool tx);
18359c6bd790SJohannes Berg 
183646900298SJohannes Berg /* IBSS code */
183746900298SJohannes Berg void ieee80211_ibss_notify_scan_completed(struct ieee80211_local *local);
183846900298SJohannes Berg void ieee80211_ibss_setup_sdata(struct ieee80211_sub_if_data *sdata);
18398bf11d8dSJohannes Berg void ieee80211_ibss_rx_no_sta(struct ieee80211_sub_if_data *sdata,
18408bf11d8dSJohannes Berg 			      const u8 *bssid, const u8 *addr, u32 supp_rates);
1841af8cdcd8SJohannes Berg int ieee80211_ibss_join(struct ieee80211_sub_if_data *sdata,
1842af8cdcd8SJohannes Berg 			struct cfg80211_ibss_params *params);
1843af8cdcd8SJohannes Berg int ieee80211_ibss_leave(struct ieee80211_sub_if_data *sdata);
18441fa57d01SJohannes Berg void ieee80211_ibss_work(struct ieee80211_sub_if_data *sdata);
18451fa57d01SJohannes Berg void ieee80211_ibss_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
18461fa57d01SJohannes Berg 				   struct sk_buff *skb);
1847cd7760e6SSimon Wunderlich int ieee80211_ibss_csa_beacon(struct ieee80211_sub_if_data *sdata,
1848cd7760e6SSimon Wunderlich 			      struct cfg80211_csa_settings *csa_settings);
1849cd7760e6SSimon Wunderlich int ieee80211_ibss_finish_csa(struct ieee80211_sub_if_data *sdata);
1850cd7760e6SSimon Wunderlich void ieee80211_ibss_stop(struct ieee80211_sub_if_data *sdata);
18511fa57d01SJohannes Berg 
1852239281f8SRostislav Lisovy /* OCB code */
1853239281f8SRostislav Lisovy void ieee80211_ocb_work(struct ieee80211_sub_if_data *sdata);
1854239281f8SRostislav Lisovy void ieee80211_ocb_rx_no_sta(struct ieee80211_sub_if_data *sdata,
1855239281f8SRostislav Lisovy 			     const u8 *bssid, const u8 *addr, u32 supp_rates);
1856239281f8SRostislav Lisovy void ieee80211_ocb_setup_sdata(struct ieee80211_sub_if_data *sdata);
1857239281f8SRostislav Lisovy int ieee80211_ocb_join(struct ieee80211_sub_if_data *sdata,
1858239281f8SRostislav Lisovy 		       struct ocb_setup *setup);
1859239281f8SRostislav Lisovy int ieee80211_ocb_leave(struct ieee80211_sub_if_data *sdata);
1860239281f8SRostislav Lisovy 
18611fa57d01SJohannes Berg /* mesh code */
18621fa57d01SJohannes Berg void ieee80211_mesh_work(struct ieee80211_sub_if_data *sdata);
18631fa57d01SJohannes Berg void ieee80211_mesh_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
18641fa57d01SJohannes Berg 				   struct sk_buff *skb);
1865b8456a14SChun-Yeow Yeoh int ieee80211_mesh_csa_beacon(struct ieee80211_sub_if_data *sdata,
186666e01cf9SLuciano Coelho 			      struct cfg80211_csa_settings *csa_settings);
1867b8456a14SChun-Yeow Yeoh int ieee80211_mesh_finish_csa(struct ieee80211_sub_if_data *sdata);
186846900298SJohannes Berg 
18699c6bd790SJohannes Berg /* scan/BSS handling */
187046900298SJohannes Berg void ieee80211_scan_work(struct work_struct *work);
187134bcf715SStanislaw Gruszka int ieee80211_request_ibss_scan(struct ieee80211_sub_if_data *sdata,
1872be4a4b6aSJohannes Berg 				const u8 *ssid, u8 ssid_len,
187376bed0f4SJanusz.Dziedzic@tieto.com 				struct ieee80211_channel **channels,
187476bed0f4SJanusz.Dziedzic@tieto.com 				unsigned int n_channels,
18757ca15a0aSSimon Wunderlich 				enum nl80211_bss_scan_width scan_width);
1876c2b13452SJohannes Berg int ieee80211_request_scan(struct ieee80211_sub_if_data *sdata,
18772a519311SJohannes Berg 			   struct cfg80211_scan_request *req);
18785bb644a0SJohannes Berg void ieee80211_scan_cancel(struct ieee80211_local *local);
1879133d40f9SStanislaw Gruszka void ieee80211_run_deferred_scan(struct ieee80211_local *local);
1880d48b2968SJohannes Berg void ieee80211_scan_rx(struct ieee80211_local *local, struct sk_buff *skb);
18819c6bd790SJohannes Berg 
18820a51b27eSJohannes Berg void ieee80211_mlme_notify_scan_completed(struct ieee80211_local *local);
1883c2b13452SJohannes Berg struct ieee80211_bss *
188498c8fccfSJohannes Berg ieee80211_bss_info_update(struct ieee80211_local *local,
188598c8fccfSJohannes Berg 			  struct ieee80211_rx_status *rx_status,
188698c8fccfSJohannes Berg 			  struct ieee80211_mgmt *mgmt,
188798c8fccfSJohannes Berg 			  size_t len,
1888d45c4172SEmmanuel Grumbach 			  struct ieee80211_channel *channel);
188998c8fccfSJohannes Berg void ieee80211_rx_bss_put(struct ieee80211_local *local,
1890c2b13452SJohannes Berg 			  struct ieee80211_bss *bss);
1891ee385855SLuis Carlos Cobo 
189279f460caSLuciano Coelho /* scheduled scan handling */
1893d43c6b6eSDavid Spinadel int
1894d43c6b6eSDavid Spinadel __ieee80211_request_sched_scan_start(struct ieee80211_sub_if_data *sdata,
1895d43c6b6eSDavid Spinadel 				     struct cfg80211_sched_scan_request *req);
189679f460caSLuciano Coelho int ieee80211_request_sched_scan_start(struct ieee80211_sub_if_data *sdata,
189779f460caSLuciano Coelho 				       struct cfg80211_sched_scan_request *req);
18980d440ea2SEliad Peller int ieee80211_request_sched_scan_stop(struct ieee80211_local *local);
1899f6837ba8SJohannes Berg void ieee80211_sched_scan_end(struct ieee80211_local *local);
190085a9994aSLuciano Coelho void ieee80211_sched_scan_stopped_work(struct work_struct *work);
190179f460caSLuciano Coelho 
1902a2fcfccbSJohannes Berg /* off-channel/mgmt-tx */
1903aacde9eeSStanislaw Gruszka void ieee80211_offchannel_stop_vifs(struct ieee80211_local *local);
1904aacde9eeSStanislaw Gruszka void ieee80211_offchannel_return(struct ieee80211_local *local);
19052eb278e0SJohannes Berg void ieee80211_roc_setup(struct ieee80211_local *local);
19062eb278e0SJohannes Berg void ieee80211_start_next_roc(struct ieee80211_local *local);
1907c8f994eeSJohannes Berg void ieee80211_roc_purge(struct ieee80211_local *local,
1908c8f994eeSJohannes Berg 			 struct ieee80211_sub_if_data *sdata);
1909a2fcfccbSJohannes Berg int ieee80211_remain_on_channel(struct wiphy *wiphy, struct wireless_dev *wdev,
1910a2fcfccbSJohannes Berg 				struct ieee80211_channel *chan,
1911a2fcfccbSJohannes Berg 				unsigned int duration, u64 *cookie);
1912a2fcfccbSJohannes Berg int ieee80211_cancel_remain_on_channel(struct wiphy *wiphy,
1913a2fcfccbSJohannes Berg 				       struct wireless_dev *wdev, u64 cookie);
1914a2fcfccbSJohannes Berg int ieee80211_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev,
1915a2fcfccbSJohannes Berg 		      struct cfg80211_mgmt_tx_params *params, u64 *cookie);
1916a2fcfccbSJohannes Berg int ieee80211_mgmt_tx_cancel_wait(struct wiphy *wiphy,
1917a2fcfccbSJohannes Berg 				  struct wireless_dev *wdev, u64 cookie);
1918b203ffc3SJouni Malinen 
191973da7d5bSSimon Wunderlich /* channel switch handling */
192073da7d5bSSimon Wunderlich void ieee80211_csa_finalize_work(struct work_struct *work);
192182a8e17dSLuciano Coelho int ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev,
192282a8e17dSLuciano Coelho 			     struct cfg80211_csa_settings *params);
192373da7d5bSSimon Wunderlich 
19245f9404abSJohn Crispin /* color change handling */
19255f9404abSJohn Crispin void ieee80211_color_change_finalize_work(struct work_struct *work);
19265f9404abSJohn Crispin 
19273e122be0SJohannes Berg /* interface handling */
192807b83d2eSJohannes Berg #define MAC80211_SUPPORTED_FEATURES_TX	(NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | \
192907b83d2eSJohannes Berg 					 NETIF_F_HW_CSUM | NETIF_F_SG | \
193007b83d2eSJohannes Berg 					 NETIF_F_HIGHDMA | NETIF_F_GSO_SOFTWARE)
193107b83d2eSJohannes Berg #define MAC80211_SUPPORTED_FEATURES_RX	(NETIF_F_RXCSUM)
193207b83d2eSJohannes Berg #define MAC80211_SUPPORTED_FEATURES	(MAC80211_SUPPORTED_FEATURES_TX | \
193307b83d2eSJohannes Berg 					 MAC80211_SUPPORTED_FEATURES_RX)
193407b83d2eSJohannes Berg 
193547846c9bSJohannes Berg int ieee80211_iface_init(void);
193647846c9bSJohannes Berg void ieee80211_iface_exit(void);
19373e122be0SJohannes Berg int ieee80211_if_add(struct ieee80211_local *local, const char *name,
19386bab2e19STom Gundersen 		     unsigned char name_assign_type,
193984efbb84SJohannes Berg 		     struct wireless_dev **new_wdev, enum nl80211_iftype type,
1940ee385855SLuis Carlos Cobo 		     struct vif_params *params);
1941f3947e2dSJohannes Berg int ieee80211_if_change_type(struct ieee80211_sub_if_data *sdata,
194205c914feSJohannes Berg 			     enum nl80211_iftype type);
1943f698d856SJasper Bryant-Greene void ieee80211_if_remove(struct ieee80211_sub_if_data *sdata);
194475636525SJohannes Berg void ieee80211_remove_interfaces(struct ieee80211_local *local);
1945382a103bSJohannes Berg u32 ieee80211_idle_off(struct ieee80211_local *local);
19465cff20e6SJohannes Berg void ieee80211_recalc_idle(struct ieee80211_local *local);
194785416a4fSChristian Lamparter void ieee80211_adjust_monitor_flags(struct ieee80211_sub_if_data *sdata,
194885416a4fSChristian Lamparter 				    const int offset);
1949f142c6b9SJohannes Berg int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up);
1950f142c6b9SJohannes Berg void ieee80211_sdata_stop(struct ieee80211_sub_if_data *sdata);
19513c3e21e7SJohannes Berg int ieee80211_add_virtual_monitor(struct ieee80211_local *local);
19523c3e21e7SJohannes Berg void ieee80211_del_virtual_monitor(struct ieee80211_local *local);
1953f0706e82SJiri Benc 
19541ea6f9c0SJohannes Berg bool __ieee80211_recalc_txpower(struct ieee80211_sub_if_data *sdata);
1955db82d8a9SLorenzo Bianconi void ieee80211_recalc_txpower(struct ieee80211_sub_if_data *sdata,
1956db82d8a9SLorenzo Bianconi 			      bool update_bss);
19576aea26ceSFelix Fietkau void ieee80211_recalc_offload(struct ieee80211_local *local);
19581ea6f9c0SJohannes Berg 
19599607e6b6SJohannes Berg static inline bool ieee80211_sdata_running(struct ieee80211_sub_if_data *sdata)
19609607e6b6SJohannes Berg {
196134d4bc4dSJohannes Berg 	return test_bit(SDATA_STATE_RUNNING, &sdata->state);
19629607e6b6SJohannes Berg }
19639607e6b6SJohannes Berg 
1964e2ebc74dSJohannes Berg /* tx handling */
1965e2ebc74dSJohannes Berg void ieee80211_clear_tx_pending(struct ieee80211_local *local);
1966da1cad73SAllen Pais void ieee80211_tx_pending(struct tasklet_struct *t);
1967d0cf9c0dSStephen Hemminger netdev_tx_t ieee80211_monitor_start_xmit(struct sk_buff *skb,
1968d0cf9c0dSStephen Hemminger 					 struct net_device *dev);
1969d0cf9c0dSStephen Hemminger netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb,
1970d0cf9c0dSStephen Hemminger 				       struct net_device *dev);
197150ff477aSJohn Crispin netdev_tx_t ieee80211_subif_start_xmit_8023(struct sk_buff *skb,
197250ff477aSJohn Crispin 					    struct net_device *dev);
197324d342c5SLiad Kaufman void __ieee80211_subif_start_xmit(struct sk_buff *skb,
197424d342c5SLiad Kaufman 				  struct net_device *dev,
197506016772SRajkumar Manoharan 				  u32 info_flags,
1976a7528198SMarkus Theil 				  u32 ctrl_flags,
1977a7528198SMarkus Theil 				  u64 *cookie);
19781f98ab7fSFelix Fietkau void ieee80211_purge_tx_queue(struct ieee80211_hw *hw,
19791f98ab7fSFelix Fietkau 			      struct sk_buff_head *skbs);
19807528ec57SJohannes Berg struct sk_buff *
19817528ec57SJohannes Berg ieee80211_build_data_template(struct ieee80211_sub_if_data *sdata,
19827528ec57SJohannes Berg 			      struct sk_buff *skb, u32 info_flags);
19834dc792b8SHelmut Schaa void ieee80211_tx_monitor(struct ieee80211_local *local, struct sk_buff *skb,
19844dc792b8SHelmut Schaa 			  struct ieee80211_supported_band *sband,
1985b7b2e8caSJohn Crispin 			  int retry_count, int shift, bool send_to_cooked,
1986b7b2e8caSJohn Crispin 			  struct ieee80211_tx_status *status);
1987e2ebc74dSJohannes Berg 
198817c18bf8SJohannes Berg void ieee80211_check_fast_xmit(struct sta_info *sta);
198917c18bf8SJohannes Berg void ieee80211_check_fast_xmit_all(struct ieee80211_local *local);
199017c18bf8SJohannes Berg void ieee80211_check_fast_xmit_iface(struct ieee80211_sub_if_data *sdata);
199117c18bf8SJohannes Berg void ieee80211_clear_fast_xmit(struct sta_info *sta);
199291180649SDenis Kenzior int ieee80211_tx_control_port(struct wiphy *wiphy, struct net_device *dev,
199391180649SDenis Kenzior 			      const u8 *buf, size_t len,
1994dca9ca2dSMarkus Theil 			      const u8 *dest, __be16 proto, bool unencrypted,
1995dca9ca2dSMarkus Theil 			      u64 *cookie);
19968828f81aSRajkumar Manoharan int ieee80211_probe_mesh_link(struct wiphy *wiphy, struct net_device *dev,
19978828f81aSRajkumar Manoharan 			      const u8 *buf, size_t len);
19982433647bSToke Høiland-Jørgensen void ieee80211_resort_txq(struct ieee80211_hw *hw,
19992433647bSToke Høiland-Jørgensen 			  struct ieee80211_txq *txq);
20002433647bSToke Høiland-Jørgensen void ieee80211_unschedule_txq(struct ieee80211_hw *hw,
20012433647bSToke Høiland-Jørgensen 			      struct ieee80211_txq *txq,
20022433647bSToke Høiland-Jørgensen 			      bool purge);
20032433647bSToke Høiland-Jørgensen void ieee80211_update_airtime_weight(struct ieee80211_local *local,
20042433647bSToke Høiland-Jørgensen 				     struct airtime_sched_info *air_sched,
20052433647bSToke Høiland-Jørgensen 				     u64 now, bool force);
200617c18bf8SJohannes Berg 
2007de1ede7aSJohannes Berg /* HT */
2008ef96a842SBen Greear void ieee80211_apply_htcap_overrides(struct ieee80211_sub_if_data *sdata,
2009ef96a842SBen Greear 				     struct ieee80211_sta_ht_cap *ht_cap);
2010e1a0c6b3SJohannes Berg bool ieee80211_ht_cap_ie_to_sta_ht_cap(struct ieee80211_sub_if_data *sdata,
2011ef96a842SBen Greear 				       struct ieee80211_supported_band *sband,
20124a3cb702SJohannes Berg 				       const struct ieee80211_ht_cap *ht_cap_ie,
2013e1a0c6b3SJohannes Berg 				       struct sta_info *sta);
2014b8695a8fSJohannes Berg void ieee80211_send_delba(struct ieee80211_sub_if_data *sdata,
2015b8695a8fSJohannes Berg 			  const u8 *da, u16 tid,
2016b8695a8fSJohannes Berg 			  u16 initiator, u16 reason_code);
20170f78231bSJohannes Berg int ieee80211_send_smps_action(struct ieee80211_sub_if_data *sdata,
20180f78231bSJohannes Berg 			       enum ieee80211_smps_mode smps, const u8 *da,
20190f78231bSJohannes Berg 			       const u8 *bssid);
2020687da132SEmmanuel Grumbach void ieee80211_request_smps_ap_work(struct work_struct *work);
2021687da132SEmmanuel Grumbach void ieee80211_request_smps_mgd_work(struct work_struct *work);
2022687da132SEmmanuel Grumbach bool ieee80211_smps_is_restrictive(enum ieee80211_smps_mode smps_mode_old,
2023687da132SEmmanuel Grumbach 				   enum ieee80211_smps_mode smps_mode_new);
2024de1ede7aSJohannes Berg 
20257c3b1dd8SJohannes Berg void ___ieee80211_stop_rx_ba_session(struct sta_info *sta, u16 tid,
202653f73c09SJohannes Berg 				     u16 initiator, u16 reason, bool stop);
2027849b7967SJohannes Berg void __ieee80211_stop_rx_ba_session(struct sta_info *sta, u16 tid,
202853f73c09SJohannes Berg 				    u16 initiator, u16 reason, bool stop);
2029bde59c47SJohannes Berg void ___ieee80211_start_rx_ba_session(struct sta_info *sta,
2030bde59c47SJohannes Berg 				      u8 dialog_token, u16 timeout,
2031bde59c47SJohannes Berg 				      u16 start_seq_num, u16 ba_policy, u16 tid,
20322ab45876SJohn Crispin 				      u16 buf_size, bool tx, bool auto_seq,
20332ab45876SJohn Crispin 				      const struct ieee80211_addba_ext_ie *addbaext);
2034c82c4a80SJohannes Berg void ieee80211_sta_tear_down_BA_sessions(struct sta_info *sta,
2035c82c4a80SJohannes Berg 					 enum ieee80211_agg_stop_reason reason);
2036de1ede7aSJohannes Berg void ieee80211_process_delba(struct ieee80211_sub_if_data *sdata,
2037de1ede7aSJohannes Berg 			     struct sta_info *sta,
2038de1ede7aSJohannes Berg 			     struct ieee80211_mgmt *mgmt, size_t len);
2039de1ede7aSJohannes Berg void ieee80211_process_addba_resp(struct ieee80211_local *local,
2040de1ede7aSJohannes Berg 				  struct sta_info *sta,
2041de1ede7aSJohannes Berg 				  struct ieee80211_mgmt *mgmt,
2042de1ede7aSJohannes Berg 				  size_t len);
2043de1ede7aSJohannes Berg void ieee80211_process_addba_request(struct ieee80211_local *local,
2044de1ede7aSJohannes Berg 				     struct sta_info *sta,
2045de1ede7aSJohannes Berg 				     struct ieee80211_mgmt *mgmt,
2046de1ede7aSJohannes Berg 				     size_t len);
2047de1ede7aSJohannes Berg 
2048849b7967SJohannes Berg int __ieee80211_stop_tx_ba_session(struct sta_info *sta, u16 tid,
2049c82c4a80SJohannes Berg 				   enum ieee80211_agg_stop_reason reason);
205067c282c0SJohannes Berg int ___ieee80211_stop_tx_ba_session(struct sta_info *sta, u16 tid,
2051c82c4a80SJohannes Berg 				    enum ieee80211_agg_stop_reason reason);
20527a7c0a64SJohannes Berg void ieee80211_start_tx_ba_cb(struct sta_info *sta, int tid,
20537a7c0a64SJohannes Berg 			      struct tid_ampdu_tx *tid_tx);
20547a7c0a64SJohannes Berg void ieee80211_stop_tx_ba_cb(struct sta_info *sta, int tid,
20557a7c0a64SJohannes Berg 			     struct tid_ampdu_tx *tid_tx);
205667c282c0SJohannes Berg void ieee80211_ba_session_work(struct work_struct *work);
205767c282c0SJohannes Berg void ieee80211_tx_ba_session_handle_start(struct sta_info *sta, int tid);
20582bff8ebfSChristian Lamparter void ieee80211_release_reorder_timeout(struct sta_info *sta, int tid);
2059849b7967SJohannes Berg 
206004ecd257SJohannes Berg u8 ieee80211_mcs_to_chains(const struct ieee80211_mcs_info *mcs);
206157566b20Stamizhr@codeaurora.org enum nl80211_smps_mode
206257566b20Stamizhr@codeaurora.org ieee80211_smps_mode_to_smps_mode(enum ieee80211_smps_mode smps);
206304ecd257SJohannes Berg 
2064818255eaSMahesh Palivela /* VHT */
20654a3cb702SJohannes Berg void
20664a3cb702SJohannes Berg ieee80211_vht_cap_ie_to_sta_vht_cap(struct ieee80211_sub_if_data *sdata,
2067818255eaSMahesh Palivela 				    struct ieee80211_supported_band *sband,
20684a3cb702SJohannes Berg 				    const struct ieee80211_vht_cap *vht_cap_ie,
20694a34215eSJohannes Berg 				    struct sta_info *sta);
20701c45c5ceSEliad Peller enum ieee80211_sta_rx_bandwidth ieee80211_sta_cap_rx_bw(struct sta_info *sta);
2071e1a0c6b3SJohannes Berg enum ieee80211_sta_rx_bandwidth ieee80211_sta_cur_vht_bw(struct sta_info *sta);
20728921d04eSJohannes Berg void ieee80211_sta_set_rx_nss(struct sta_info *sta);
207359021c67SArik Nemtsov enum ieee80211_sta_rx_bandwidth
207459021c67SArik Nemtsov ieee80211_chan_width_to_rx_bw(enum nl80211_chan_width width);
207559021c67SArik Nemtsov enum nl80211_chan_width ieee80211_sta_cap_chan_bw(struct sta_info *sta);
207623a1f8d4SSara Sharon void ieee80211_process_mu_groups(struct ieee80211_sub_if_data *sdata,
207723a1f8d4SSara Sharon 				 struct ieee80211_mgmt *mgmt);
2078b1bce14aSMarek Kwaczynski u32 __ieee80211_vht_handle_opmode(struct ieee80211_sub_if_data *sdata,
2079b1bce14aSMarek Kwaczynski                                   struct sta_info *sta, u8 opmode,
208057fbcce3SJohannes Berg 				  enum nl80211_band band);
20810af83d3dSJohannes Berg void ieee80211_vht_handle_opmode(struct ieee80211_sub_if_data *sdata,
20820af83d3dSJohannes Berg 				 struct sta_info *sta, u8 opmode,
208357fbcce3SJohannes Berg 				 enum nl80211_band band);
2084dd5ecfeaSJohannes Berg void ieee80211_apply_vhtcap_overrides(struct ieee80211_sub_if_data *sdata,
2085dd5ecfeaSJohannes Berg 				      struct ieee80211_sta_vht_cap *vht_cap);
2086b119ad6eSLorenzo Bianconi void ieee80211_get_vht_mask_from_cap(__le16 vht_cap,
2087b119ad6eSLorenzo Bianconi 				     u16 vht_mask[NL80211_VHT_NSS_MAX]);
208897f5f425Stamizhr@codeaurora.org enum nl80211_chan_width
208997f5f425Stamizhr@codeaurora.org ieee80211_sta_rx_bw_to_chan_width(struct sta_info *sta);
20904a34215eSJohannes Berg 
209141cbb0f5SLuca Coelho /* HE */
209241cbb0f5SLuca Coelho void
209341cbb0f5SLuca Coelho ieee80211_he_cap_ie_to_sta_he_cap(struct ieee80211_sub_if_data *sdata,
209441cbb0f5SLuca Coelho 				  struct ieee80211_supported_band *sband,
209541cbb0f5SLuca Coelho 				  const u8 *he_cap_ie, u8 he_cap_len,
20961bb9a8a4SJohannes Berg 				  const struct ieee80211_he_6ghz_capa *he_6ghz_capa,
209741cbb0f5SLuca Coelho 				  struct sta_info *sta);
20981ced169cSJohn Crispin void
20991ced169cSJohn Crispin ieee80211_he_spr_ie_to_bss_conf(struct ieee80211_vif *vif,
21001ced169cSJohn Crispin 				const struct ieee80211_he_spr *he_spr_ie_elem);
210141cbb0f5SLuca Coelho 
2102697f6c50SJohn Crispin void
2103697f6c50SJohn Crispin ieee80211_he_op_ie_to_bss_conf(struct ieee80211_vif *vif,
2104697f6c50SJohn Crispin 			const struct ieee80211_he_operation *he_op_ie_elem);
2105697f6c50SJohn Crispin 
210612bf8fadSThomas Pedersen /* S1G */
210712bf8fadSThomas Pedersen void ieee80211_s1g_sta_rate_init(struct sta_info *sta);
2108f5a4c24eSLorenzo Bianconi bool ieee80211_s1g_is_twt_setup(struct sk_buff *skb);
2109f5a4c24eSLorenzo Bianconi void ieee80211_s1g_rx_twt_action(struct ieee80211_sub_if_data *sdata,
2110f5a4c24eSLorenzo Bianconi 				 struct sk_buff *skb);
2111f5a4c24eSLorenzo Bianconi void ieee80211_s1g_status_twt_action(struct ieee80211_sub_if_data *sdata,
2112f5a4c24eSLorenzo Bianconi 				     struct sk_buff *skb);
211312bf8fadSThomas Pedersen 
211439192c0bSJohannes Berg /* Spectrum management */
211539192c0bSJohannes Berg void ieee80211_process_measurement_req(struct ieee80211_sub_if_data *sdata,
211639192c0bSJohannes Berg 				       struct ieee80211_mgmt *mgmt,
211739192c0bSJohannes Berg 				       size_t len);
2118e6b7cde4SSimon Wunderlich /**
2119e6b7cde4SSimon Wunderlich  * ieee80211_parse_ch_switch_ie - parses channel switch IEs
2120e6b7cde4SSimon Wunderlich  * @sdata: the sdata of the interface which has received the frame
2121e6b7cde4SSimon Wunderlich  * @elems: parsed 802.11 elements received with the frame
2122e6b7cde4SSimon Wunderlich  * @current_band: indicates the current band
21232a333a0dSJohannes Berg  * @vht_cap_info: VHT capabilities of the transmitter
2124e6b7cde4SSimon Wunderlich  * @sta_flags: contains information about own capabilities and restrictions
2125e6b7cde4SSimon Wunderlich  *	to decide which channel switch announcements can be accepted. Only the
2126e6b7cde4SSimon Wunderlich  *	following subset of &enum ieee80211_sta_flags are evaluated:
2127e6b7cde4SSimon Wunderlich  *	%IEEE80211_STA_DISABLE_HT, %IEEE80211_STA_DISABLE_VHT,
2128e6b7cde4SSimon Wunderlich  *	%IEEE80211_STA_DISABLE_40MHZ, %IEEE80211_STA_DISABLE_80P80MHZ,
2129e6b7cde4SSimon Wunderlich  *	%IEEE80211_STA_DISABLE_160MHZ.
2130e6b7cde4SSimon Wunderlich  * @bssid: the currently connected bssid (for reporting)
2131c0f17eb9SChun-Yeow Yeoh  * @csa_ie: parsed 802.11 csa elements on count, mode, chandef and mesh ttl.
2132c0f17eb9SChun-Yeow Yeoh 	All of them will be filled with if success only.
2133e6b7cde4SSimon Wunderlich  * Return: 0 on success, <0 on error and >0 if there is nothing to parse.
2134e6b7cde4SSimon Wunderlich  */
2135e6b7cde4SSimon Wunderlich int ieee80211_parse_ch_switch_ie(struct ieee80211_sub_if_data *sdata,
213684469a45SLuciano Coelho 				 struct ieee802_11_elems *elems,
213757fbcce3SJohannes Berg 				 enum nl80211_band current_band,
21382a333a0dSJohannes Berg 				 u32 vht_cap_info,
2139c0f17eb9SChun-Yeow Yeoh 				 u32 sta_flags, u8 *bssid,
2140c0f17eb9SChun-Yeow Yeoh 				 struct ieee80211_csa_ie *csa_ie);
214139192c0bSJohannes Berg 
2142f2753ddbSJohannes Berg /* Suspend/resume and hw reconfiguration */
2143f2753ddbSJohannes Berg int ieee80211_reconfig(struct ieee80211_local *local);
214484f6a01cSJohannes Berg void ieee80211_stop_device(struct ieee80211_local *local);
2145f2753ddbSJohannes Berg 
2146eecc4800SJohannes Berg int __ieee80211_suspend(struct ieee80211_hw *hw,
2147eecc4800SJohannes Berg 			struct cfg80211_wowlan *wowlan);
2148f2753ddbSJohannes Berg 
2149f2753ddbSJohannes Berg static inline int __ieee80211_resume(struct ieee80211_hw *hw)
2150f2753ddbSJohannes Berg {
215185f72bc8SJohn W. Linville 	struct ieee80211_local *local = hw_to_local(hw);
215285f72bc8SJohn W. Linville 
21539120d94eSLuciano Coelho 	WARN(test_bit(SCAN_HW_SCANNING, &local->scanning) &&
21549120d94eSLuciano Coelho 	     !test_bit(SCAN_COMPLETED, &local->scanning),
215585f72bc8SJohn W. Linville 		"%s: resume with hardware scan still in progress\n",
215685f72bc8SJohn W. Linville 		wiphy_name(hw->wiphy));
215785f72bc8SJohn W. Linville 
2158f2753ddbSJohannes Berg 	return ieee80211_reconfig(hw_to_local(hw));
2159f2753ddbSJohannes Berg }
2160665af4fcSBob Copeland 
2161c2d1560aSJohannes Berg /* utility functions/constants */
21628a47cea7SJohannes Berg extern const void *const mac80211_wiphy_privid; /* for wiphy privid */
216357fbcce3SJohannes Berg int ieee80211_frame_duration(enum nl80211_band band, size_t len,
2164438b61b7SSimon Wunderlich 			     int rate, int erp, int short_preamble,
2165438b61b7SSimon Wunderlich 			     int shift);
2166e552af05SHaim Dreyfuss void ieee80211_regulatory_limit_wmm_params(struct ieee80211_sub_if_data *sdata,
2167e552af05SHaim Dreyfuss 					   struct ieee80211_tx_queue_params *qparam,
2168e552af05SHaim Dreyfuss 					   int ac);
21693abead59SJohannes Berg void ieee80211_set_wmm_default(struct ieee80211_sub_if_data *sdata,
2170cec66283SJohannes Berg 			       bool bss_notify, bool enable_qos);
21717c10770fSJohannes Berg void ieee80211_xmit(struct ieee80211_sub_if_data *sdata,
217208aca29aSMathy Vanhoef 		    struct sta_info *sta, struct sk_buff *skb);
2173cf6bb79aSHelmut Schaa 
217455de908aSJohannes Berg void __ieee80211_tx_skb_tid_band(struct ieee80211_sub_if_data *sdata,
217555de908aSJohannes Berg 				 struct sk_buff *skb, int tid,
217608aca29aSMathy Vanhoef 				 enum nl80211_band band);
217755de908aSJohannes Berg 
217850ff477aSJohn Crispin /* sta_out needs to be checked for ERR_PTR() before using */
217950ff477aSJohn Crispin int ieee80211_lookup_ra_sta(struct ieee80211_sub_if_data *sdata,
218050ff477aSJohn Crispin 			    struct sk_buff *skb,
218150ff477aSJohn Crispin 			    struct sta_info **sta_out);
218250ff477aSJohn Crispin 
218355de908aSJohannes Berg static inline void
218455de908aSJohannes Berg ieee80211_tx_skb_tid_band(struct ieee80211_sub_if_data *sdata,
218555de908aSJohannes Berg 			  struct sk_buff *skb, int tid,
218608aca29aSMathy Vanhoef 			  enum nl80211_band band)
218755de908aSJohannes Berg {
218855de908aSJohannes Berg 	rcu_read_lock();
218908aca29aSMathy Vanhoef 	__ieee80211_tx_skb_tid_band(sdata, skb, tid, band);
219055de908aSJohannes Berg 	rcu_read_unlock();
219155de908aSJohannes Berg }
219255de908aSJohannes Berg 
219355de908aSJohannes Berg static inline void ieee80211_tx_skb_tid(struct ieee80211_sub_if_data *sdata,
219455de908aSJohannes Berg 					struct sk_buff *skb, int tid)
219555de908aSJohannes Berg {
219655de908aSJohannes Berg 	struct ieee80211_chanctx_conf *chanctx_conf;
219755de908aSJohannes Berg 
219855de908aSJohannes Berg 	rcu_read_lock();
219955de908aSJohannes Berg 	chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
220055de908aSJohannes Berg 	if (WARN_ON(!chanctx_conf)) {
220155de908aSJohannes Berg 		rcu_read_unlock();
220255de908aSJohannes Berg 		kfree_skb(skb);
220355de908aSJohannes Berg 		return;
220455de908aSJohannes Berg 	}
220555de908aSJohannes Berg 
220655de908aSJohannes Berg 	__ieee80211_tx_skb_tid_band(sdata, skb, tid,
220708aca29aSMathy Vanhoef 				    chanctx_conf->def.chan->band);
220855de908aSJohannes Berg 	rcu_read_unlock();
220955de908aSJohannes Berg }
221055de908aSJohannes Berg 
221155de908aSJohannes Berg static inline void ieee80211_tx_skb(struct ieee80211_sub_if_data *sdata,
2212cf6bb79aSHelmut Schaa 				    struct sk_buff *skb)
2213cf6bb79aSHelmut Schaa {
2214cf6bb79aSHelmut Schaa 	/* Send all internal mgmt frames on VO. Accordingly set TID to 7. */
2215cf6bb79aSHelmut Schaa 	ieee80211_tx_skb_tid(sdata, skb, 7);
2216cf6bb79aSHelmut Schaa }
2217cf6bb79aSHelmut Schaa 
22185d24828dSJohannes Berg struct ieee802_11_elems *ieee802_11_parse_elems_crc(const u8 *start, size_t len,
221935d865afSJohannes Berg 						    bool action,
22205d24828dSJohannes Berg 						    u64 filter, u32 crc,
22215d24828dSJohannes Berg 						    const u8 *transmitter_bssid,
22225d24828dSJohannes Berg 						    const u8 *bss_bssid);
22235d24828dSJohannes Berg static inline struct ieee802_11_elems *
22245d24828dSJohannes Berg ieee802_11_parse_elems(const u8 *start, size_t len, bool action,
22255d24828dSJohannes Berg 		       const u8 *transmitter_bssid,
22265d24828dSJohannes Berg 		       const u8 *bss_bssid)
2227ddc4db2eSJohannes Berg {
22285d24828dSJohannes Berg 	return ieee802_11_parse_elems_crc(start, len, action, 0, 0,
22294abb52a4SSara Sharon 					  transmitter_bssid, bss_bssid);
2230ddc4db2eSJohannes Berg }
2231ddc4db2eSJohannes Berg 
223283eb935eSMichal Kazior 
223302219b3aSJohannes Berg extern const int ieee802_1d_to_ac[8];
223402219b3aSJohannes Berg 
223502219b3aSJohannes Berg static inline int ieee80211_ac_from_tid(int tid)
223602219b3aSJohannes Berg {
223702219b3aSJohannes Berg 	return ieee802_1d_to_ac[tid & 7];
223802219b3aSJohannes Berg }
223902219b3aSJohannes Berg 
2240520eb820SKalle Valo void ieee80211_dynamic_ps_enable_work(struct work_struct *work);
2241520eb820SKalle Valo void ieee80211_dynamic_ps_disable_work(struct work_struct *work);
224234f11cd3SKees Cook void ieee80211_dynamic_ps_timer(struct timer_list *t);
2243a97b77b9SVivek Natarajan void ieee80211_send_nullfunc(struct ieee80211_local *local,
2244a97b77b9SVivek Natarajan 			     struct ieee80211_sub_if_data *sdata,
2245076cdcb1SJohannes Berg 			     bool powersave);
2246a5d3cbdbSFelix Fietkau void ieee80211_send_4addr_nullfunc(struct ieee80211_local *local,
2247a5d3cbdbSFelix Fietkau 				   struct ieee80211_sub_if_data *sdata);
22484e5ff376SFelix Fietkau void ieee80211_sta_tx_notify(struct ieee80211_sub_if_data *sdata,
224902219b3aSJohannes Berg 			     struct ieee80211_hdr *hdr, bool ack, u16 tx_time);
2250520eb820SKalle Valo 
2251ce7c9111SKalle Valo void ieee80211_wake_queues_by_reason(struct ieee80211_hw *hw,
2252445ea4e8SJohannes Berg 				     unsigned long queues,
2253cca07b00SLuciano Coelho 				     enum queue_stop_reason reason,
2254cca07b00SLuciano Coelho 				     bool refcounted);
225526da23b6SLuciano Coelho void ieee80211_stop_vif_queues(struct ieee80211_local *local,
225626da23b6SLuciano Coelho 			       struct ieee80211_sub_if_data *sdata,
225726da23b6SLuciano Coelho 			       enum queue_stop_reason reason);
225826da23b6SLuciano Coelho void ieee80211_wake_vif_queues(struct ieee80211_local *local,
225926da23b6SLuciano Coelho 			       struct ieee80211_sub_if_data *sdata,
226026da23b6SLuciano Coelho 			       enum queue_stop_reason reason);
2261ce7c9111SKalle Valo void ieee80211_stop_queues_by_reason(struct ieee80211_hw *hw,
2262445ea4e8SJohannes Berg 				     unsigned long queues,
2263cca07b00SLuciano Coelho 				     enum queue_stop_reason reason,
2264cca07b00SLuciano Coelho 				     bool refcounted);
226596f5e66eSJohannes Berg void ieee80211_wake_queue_by_reason(struct ieee80211_hw *hw, int queue,
2266cca07b00SLuciano Coelho 				    enum queue_stop_reason reason,
2267cca07b00SLuciano Coelho 				    bool refcounted);
226896f5e66eSJohannes Berg void ieee80211_stop_queue_by_reason(struct ieee80211_hw *hw, int queue,
2269cca07b00SLuciano Coelho 				    enum queue_stop_reason reason,
2270cca07b00SLuciano Coelho 				    bool refcounted);
22713a25a8c8SJohannes Berg void ieee80211_propagate_queue_wake(struct ieee80211_local *local, int queue);
22728f77f384SJohannes Berg void ieee80211_add_pending_skb(struct ieee80211_local *local,
22738f77f384SJohannes Berg 			       struct sk_buff *skb);
2274e3685e03SJohannes Berg void ieee80211_add_pending_skbs(struct ieee80211_local *local,
2275e3685e03SJohannes Berg 				struct sk_buff_head *skbs);
227639ecc01dSJohannes Berg void ieee80211_flush_queues(struct ieee80211_local *local,
22773b24f4c6SEmmanuel Grumbach 			    struct ieee80211_sub_if_data *sdata, bool drop);
22784f9610d5SLiad Kaufman void __ieee80211_flush_queues(struct ieee80211_local *local,
22794f9610d5SLiad Kaufman 			      struct ieee80211_sub_if_data *sdata,
22803b24f4c6SEmmanuel Grumbach 			      unsigned int queues, bool drop);
2281ce7c9111SKalle Valo 
22824afaff17SEmmanuel Grumbach static inline bool ieee80211_can_run_worker(struct ieee80211_local *local)
22834afaff17SEmmanuel Grumbach {
22844afaff17SEmmanuel Grumbach 	/*
2285f8891461SNaftali Goldstein 	 * It's unsafe to try to do any work during reconfigure flow.
2286f8891461SNaftali Goldstein 	 * When the flow ends the work will be requeued.
2287f8891461SNaftali Goldstein 	 */
2288f8891461SNaftali Goldstein 	if (local->in_reconfig)
2289f8891461SNaftali Goldstein 		return false;
2290f8891461SNaftali Goldstein 
2291f8891461SNaftali Goldstein 	/*
22924afaff17SEmmanuel Grumbach 	 * If quiescing is set, we are racing with __ieee80211_suspend.
22934afaff17SEmmanuel Grumbach 	 * __ieee80211_suspend flushes the workers after setting quiescing,
22944afaff17SEmmanuel Grumbach 	 * and we check quiescing / suspended before enqueing new workers.
22954afaff17SEmmanuel Grumbach 	 * We should abort the worker to avoid the races below.
22964afaff17SEmmanuel Grumbach 	 */
22974afaff17SEmmanuel Grumbach 	if (local->quiescing)
22984afaff17SEmmanuel Grumbach 		return false;
22994afaff17SEmmanuel Grumbach 
23004afaff17SEmmanuel Grumbach 	/*
23014afaff17SEmmanuel Grumbach 	 * We might already be suspended if the following scenario occurs:
23024afaff17SEmmanuel Grumbach 	 * __ieee80211_suspend		Control path
23034afaff17SEmmanuel Grumbach 	 *
23044afaff17SEmmanuel Grumbach 	 *				if (local->quiescing)
23054afaff17SEmmanuel Grumbach 	 *					return;
23064afaff17SEmmanuel Grumbach 	 * local->quiescing = true;
23074afaff17SEmmanuel Grumbach 	 * flush_workqueue();
23084afaff17SEmmanuel Grumbach 	 *				queue_work(...);
23094afaff17SEmmanuel Grumbach 	 * local->suspended = true;
23104afaff17SEmmanuel Grumbach 	 * local->quiescing = false;
23114afaff17SEmmanuel Grumbach 	 *				worker starts running...
23124afaff17SEmmanuel Grumbach 	 */
23134afaff17SEmmanuel Grumbach 	if (local->suspended)
23144afaff17SEmmanuel Grumbach 		return false;
23154afaff17SEmmanuel Grumbach 
23164afaff17SEmmanuel Grumbach 	return true;
23174afaff17SEmmanuel Grumbach }
23184afaff17SEmmanuel Grumbach 
2319fa962b92SMichal Kazior int ieee80211_txq_setup_flows(struct ieee80211_local *local);
23202fe4a29aSToke Høiland-Jørgensen void ieee80211_txq_set_params(struct ieee80211_local *local);
2321fa962b92SMichal Kazior void ieee80211_txq_teardown_flows(struct ieee80211_local *local);
2322fa962b92SMichal Kazior void ieee80211_txq_init(struct ieee80211_sub_if_data *sdata,
2323ba8c3d6fSFelix Fietkau 			struct sta_info *sta,
2324ba8c3d6fSFelix Fietkau 			struct txq_info *txq, int tid);
2325fa962b92SMichal Kazior void ieee80211_txq_purge(struct ieee80211_local *local,
2326fa962b92SMichal Kazior 			 struct txq_info *txqi);
23272a9e2579SJohannes Berg void ieee80211_txq_remove_vlan(struct ieee80211_local *local,
23282a9e2579SJohannes Berg 			       struct ieee80211_sub_if_data *sdata);
23292fe4a29aSToke Høiland-Jørgensen void ieee80211_fill_txq_stats(struct cfg80211_txq_stats *txqstats,
23302fe4a29aSToke Høiland-Jørgensen 			      struct txq_info *txqi);
2331da1cad73SAllen Pais void ieee80211_wake_txqs(struct tasklet_struct *t);
233246900298SJohannes Berg void ieee80211_send_auth(struct ieee80211_sub_if_data *sdata,
2333700e8ea6SJouni Malinen 			 u16 transaction, u16 auth_alg, u16 status,
23344a3cb702SJohannes Berg 			 const u8 *extra, size_t extra_len, const u8 *bssid,
23351672c0e3SJohannes Berg 			 const u8 *da, const u8 *key, u8 key_len, u8 key_idx,
23361672c0e3SJohannes Berg 			 u32 tx_flags);
23376ae16775SAntonio Quartulli void ieee80211_send_deauth_disassoc(struct ieee80211_sub_if_data *sdata,
23384b08d1b6SJohannes Berg 				    const u8 *da, const u8 *bssid,
23394b08d1b6SJohannes Berg 				    u16 stype, u16 reason,
23406ae16775SAntonio Quartulli 				    bool send_frame, u8 *frame_buf);
234100387f32SJohannes Berg 
234200387f32SJohannes Berg enum {
234300387f32SJohannes Berg 	IEEE80211_PROBE_FLAG_DIRECTED		= BIT(0),
2344b9771d41SJohannes Berg 	IEEE80211_PROBE_FLAG_MIN_CONTENT	= BIT(1),
2345b9771d41SJohannes Berg 	IEEE80211_PROBE_FLAG_RANDOM_SN		= BIT(2),
234600387f32SJohannes Berg };
234700387f32SJohannes Berg 
23482ad2274cSIlan Peer int ieee80211_build_preq_ies(struct ieee80211_sub_if_data *sdata, u8 *buffer,
2349c56ef672SDavid Spinadel 			     size_t buffer_len,
2350c56ef672SDavid Spinadel 			     struct ieee80211_scan_ies *ie_desc,
2351c56ef672SDavid Spinadel 			     const u8 *ie, size_t ie_len,
2352c56ef672SDavid Spinadel 			     u8 bands_used, u32 *rate_masks,
235300387f32SJohannes Berg 			     struct cfg80211_chan_def *chandef,
235400387f32SJohannes Berg 			     u32 flags);
2355a619a4c0SJuuso Oikarinen struct sk_buff *ieee80211_build_probe_req(struct ieee80211_sub_if_data *sdata,
2356a344d677SJohannes Berg 					  const u8 *src, const u8 *dst,
2357a344d677SJohannes Berg 					  u32 ratemask,
23586b77863bSJohannes Berg 					  struct ieee80211_channel *chan,
2359a619a4c0SJuuso Oikarinen 					  const u8 *ssid, size_t ssid_len,
2360a806c558SPaul Stewart 					  const u8 *ie, size_t ie_len,
236100387f32SJohannes Berg 					  u32 flags);
23622103dec1SSimon Wunderlich u32 ieee80211_sta_get_rates(struct ieee80211_sub_if_data *sdata,
236346900298SJohannes Berg 			    struct ieee802_11_elems *elems,
236457fbcce3SJohannes Berg 			    enum nl80211_band band, u32 *basic_rates);
2365687da132SEmmanuel Grumbach int __ieee80211_request_smps_mgd(struct ieee80211_sub_if_data *sdata,
2366687da132SEmmanuel Grumbach 				 enum ieee80211_smps_mode smps_mode);
236704ecd257SJohannes Berg void ieee80211_recalc_smps(struct ieee80211_sub_if_data *sdata);
236821f659bfSEliad Peller void ieee80211_recalc_min_chandef(struct ieee80211_sub_if_data *sdata);
236946900298SJohannes Berg 
23708e664fb3SJohannes Berg size_t ieee80211_ie_split_vendor(const u8 *ies, size_t ielen, size_t offset);
2371ef96a842SBen Greear u8 *ieee80211_ie_build_ht_cap(u8 *pos, struct ieee80211_sta_ht_cap *ht_cap,
237242e7aa77SAlexander Simon 			      u16 cap);
2373074d46d1SJohannes Berg u8 *ieee80211_ie_build_ht_oper(u8 *pos, struct ieee80211_sta_ht_cap *ht_cap,
23744bf88530SJohannes Berg 			       const struct cfg80211_chan_def *chandef,
237557f255f5SArik Nemtsov 			       u16 prot_mode, bool rifs_mode);
237675d627d5SSimon Wunderlich void ieee80211_ie_build_wide_bw_cs(u8 *pos,
237775d627d5SSimon Wunderlich 				   const struct cfg80211_chan_def *chandef);
2378ba0afa2fSMahesh Palivela u8 *ieee80211_ie_build_vht_cap(u8 *pos, struct ieee80211_sta_vht_cap *vht_cap,
2379ba0afa2fSMahesh Palivela 			       u32 cap);
2380fb28ec0cSArik Nemtsov u8 *ieee80211_ie_build_vht_oper(u8 *pos, struct ieee80211_sta_vht_cap *vht_cap,
2381fb28ec0cSArik Nemtsov 				const struct cfg80211_chan_def *chandef);
238260ad72daSSven Eckelmann u8 ieee80211_ie_len_he_cap(struct ieee80211_sub_if_data *sdata, u8 iftype);
238341cbb0f5SLuca Coelho u8 *ieee80211_ie_build_he_cap(u8 *pos,
238441cbb0f5SLuca Coelho 			      const struct ieee80211_sta_he_cap *he_cap,
238541cbb0f5SLuca Coelho 			      u8 *end);
238624a2042cSRajkumar Manoharan void ieee80211_ie_build_he_6ghz_cap(struct ieee80211_sub_if_data *sdata,
238724a2042cSRajkumar Manoharan 				    struct sk_buff *skb);
2388d1b7524bSRajkumar Manoharan u8 *ieee80211_ie_build_he_oper(u8 *pos, struct cfg80211_chan_def *chandef);
23892103dec1SSimon Wunderlich int ieee80211_parse_bitrates(struct cfg80211_chan_def *chandef,
23902103dec1SSimon Wunderlich 			     const struct ieee80211_supported_band *sband,
23912103dec1SSimon Wunderlich 			     const u8 *srates, int srates_len, u32 *rates);
2392fc8a7321SJohannes Berg int ieee80211_add_srates_ie(struct ieee80211_sub_if_data *sdata,
23936b77863bSJohannes Berg 			    struct sk_buff *skb, bool need_basic,
239457fbcce3SJohannes Berg 			    enum nl80211_band band);
2395fc8a7321SJohannes Berg int ieee80211_add_ext_srates_ie(struct ieee80211_sub_if_data *sdata,
23966b77863bSJohannes Berg 				struct sk_buff *skb, bool need_basic,
239757fbcce3SJohannes Berg 				enum nl80211_band band);
239840b861a0SArik Nemtsov u8 *ieee80211_add_wmm_info_ie(u8 *buf, u8 qosinfo);
23997957c6c8SThomas Pedersen void ieee80211_add_s1g_capab_ie(struct ieee80211_sub_if_data *sdata,
24007957c6c8SThomas Pedersen 				struct ieee80211_sta_s1g_cap *caps,
24017957c6c8SThomas Pedersen 				struct sk_buff *skb);
24021d00ce80SThomas Pedersen void ieee80211_add_aid_request_ie(struct ieee80211_sub_if_data *sdata,
24031d00ce80SThomas Pedersen 				  struct sk_buff *skb);
24048e664fb3SJohannes Berg 
2405f444de05SJohannes Berg /* channel management */
24068ac3c704SJohannes Berg bool ieee80211_chandef_ht_oper(const struct ieee80211_ht_operation *ht_oper,
24074bf88530SJohannes Berg 			       struct cfg80211_chan_def *chandef);
24082a333a0dSJohannes Berg bool ieee80211_chandef_vht_oper(struct ieee80211_hw *hw, u32 vht_cap_info,
24097eb26df2SJohannes Berg 				const struct ieee80211_vht_operation *oper,
24107eb26df2SJohannes Berg 				const struct ieee80211_ht_operation *htop,
2411abcff6efSJanusz.Dziedzic@tieto.com 				struct cfg80211_chan_def *chandef);
241257fa5e85SJohannes Berg bool ieee80211_chandef_he_6ghz_oper(struct ieee80211_sub_if_data *sdata,
241357fa5e85SJohannes Berg 				    const struct ieee80211_he_operation *he_oper,
241457fa5e85SJohannes Berg 				    struct cfg80211_chan_def *chandef);
24151d00ce80SThomas Pedersen bool ieee80211_chandef_s1g_oper(const struct ieee80211_s1g_oper_ie *oper,
24161d00ce80SThomas Pedersen 				struct cfg80211_chan_def *chandef);
2417e6b7cde4SSimon Wunderlich u32 ieee80211_chandef_downgrade(struct cfg80211_chan_def *c);
2418f444de05SJohannes Berg 
2419d01a1e65SMichal Kazior int __must_check
2420d01a1e65SMichal Kazior ieee80211_vif_use_channel(struct ieee80211_sub_if_data *sdata,
24214bf88530SJohannes Berg 			  const struct cfg80211_chan_def *chandef,
2422d01a1e65SMichal Kazior 			  enum ieee80211_chanctx_mode mode);
24232c9b7359SJohannes Berg int __must_check
242411335a55SLuciano Coelho ieee80211_vif_reserve_chanctx(struct ieee80211_sub_if_data *sdata,
242511335a55SLuciano Coelho 			      const struct cfg80211_chan_def *chandef,
242609332481SMichal Kazior 			      enum ieee80211_chanctx_mode mode,
242709332481SMichal Kazior 			      bool radar_required);
242811335a55SLuciano Coelho int __must_check
24295bcae31dSMichal Kazior ieee80211_vif_use_reserved_context(struct ieee80211_sub_if_data *sdata);
243011335a55SLuciano Coelho int ieee80211_vif_unreserve_chanctx(struct ieee80211_sub_if_data *sdata);
243111335a55SLuciano Coelho 
243211335a55SLuciano Coelho int __must_check
24332c9b7359SJohannes Berg ieee80211_vif_change_bandwidth(struct ieee80211_sub_if_data *sdata,
24342c9b7359SJohannes Berg 			       const struct cfg80211_chan_def *chandef,
24352c9b7359SJohannes Berg 			       u32 *changed);
2436d01a1e65SMichal Kazior void ieee80211_vif_release_channel(struct ieee80211_sub_if_data *sdata);
24374d76d21bSJohannes Berg void ieee80211_vif_vlan_copy_chanctx(struct ieee80211_sub_if_data *sdata);
24381f4ac5a6SJohannes Berg void ieee80211_vif_copy_chanctx_to_vlans(struct ieee80211_sub_if_data *sdata,
24391f4ac5a6SJohannes Berg 					 bool clear);
2440c0166da9SMichal Kazior int ieee80211_chanctx_refcount(struct ieee80211_local *local,
2441c0166da9SMichal Kazior 			       struct ieee80211_chanctx *ctx);
2442d01a1e65SMichal Kazior 
244304ecd257SJohannes Berg void ieee80211_recalc_smps_chanctx(struct ieee80211_local *local,
244404ecd257SJohannes Berg 				   struct ieee80211_chanctx *chanctx);
244521f659bfSEliad Peller void ieee80211_recalc_chanctx_min_def(struct ieee80211_local *local,
244621f659bfSEliad Peller 				      struct ieee80211_chanctx *ctx);
24475cbc95a7SEliad Peller bool ieee80211_is_radar_required(struct ieee80211_local *local);
2448164eb02dSSimon Wunderlich 
2449164eb02dSSimon Wunderlich void ieee80211_dfs_cac_timer(unsigned long data);
2450164eb02dSSimon Wunderlich void ieee80211_dfs_cac_timer_work(struct work_struct *work);
2451164eb02dSSimon Wunderlich void ieee80211_dfs_cac_cancel(struct ieee80211_local *local);
2452164eb02dSSimon Wunderlich void ieee80211_dfs_radar_detected_work(struct work_struct *work);
2453c6da674aSChun-Yeow Yeoh int ieee80211_send_action_csa(struct ieee80211_sub_if_data *sdata,
2454c6da674aSChun-Yeow Yeoh 			      struct cfg80211_csa_settings *csa_settings);
245504ecd257SJohannes Berg 
24562475b1ccSMax Stepanov bool ieee80211_cs_valid(const struct ieee80211_cipher_scheme *cs);
24572475b1ccSMax Stepanov bool ieee80211_cs_list_valid(const struct ieee80211_cipher_scheme *cs, int n);
24582475b1ccSMax Stepanov const struct ieee80211_cipher_scheme *
24592475b1ccSMax Stepanov ieee80211_cs_get(struct ieee80211_local *local, u32 cipher,
24602475b1ccSMax Stepanov 		 enum nl80211_iftype iftype);
24612475b1ccSMax Stepanov int ieee80211_cs_headroom(struct ieee80211_local *local,
24622475b1ccSMax Stepanov 			  struct cfg80211_crypto_settings *crypto,
24632475b1ccSMax Stepanov 			  enum nl80211_iftype iftype);
2464057d5f4bSThomas Pedersen void ieee80211_recalc_dtim(struct ieee80211_local *local,
2465057d5f4bSThomas Pedersen 			   struct ieee80211_sub_if_data *sdata);
246673de86a3SLuciano Coelho int ieee80211_check_combinations(struct ieee80211_sub_if_data *sdata,
246773de86a3SLuciano Coelho 				 const struct cfg80211_chan_def *chandef,
246873de86a3SLuciano Coelho 				 enum ieee80211_chanctx_mode chanmode,
246973de86a3SLuciano Coelho 				 u8 radar_detect);
24706fa001bcSMichal Kazior int ieee80211_max_num_channels(struct ieee80211_local *local);
24710fabfaafSArik Nemtsov void ieee80211_recalc_chanctx_chantype(struct ieee80211_local *local,
24720fabfaafSArik Nemtsov 				       struct ieee80211_chanctx *ctx);
24732475b1ccSMax Stepanov 
247495224fe8SArik Nemtsov /* TDLS */
247595224fe8SArik Nemtsov int ieee80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
24763b3a0162SJohannes Berg 			const u8 *peer, u8 action_code, u8 dialog_token,
247795224fe8SArik Nemtsov 			u16 status_code, u32 peer_capability,
247831fa97c5SArik Nemtsov 			bool initiator, const u8 *extra_ies,
247931fa97c5SArik Nemtsov 			size_t extra_ies_len);
248095224fe8SArik Nemtsov int ieee80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
24813b3a0162SJohannes Berg 			const u8 *peer, enum nl80211_tdls_operation oper);
2482c10a1993SJohannes Berg void ieee80211_tdls_peer_del_work(struct work_struct *wk);
2483a7a6bdd0SArik Nemtsov int ieee80211_tdls_channel_switch(struct wiphy *wiphy, struct net_device *dev,
2484a7a6bdd0SArik Nemtsov 				  const u8 *addr, u8 oper_class,
2485a7a6bdd0SArik Nemtsov 				  struct cfg80211_chan_def *chandef);
2486a7a6bdd0SArik Nemtsov void ieee80211_tdls_cancel_channel_switch(struct wiphy *wiphy,
2487a7a6bdd0SArik Nemtsov 					  struct net_device *dev,
2488a7a6bdd0SArik Nemtsov 					  const u8 *addr);
2489d51c2ea3SArik Nemtsov void ieee80211_teardown_tdls_peers(struct ieee80211_sub_if_data *sdata);
249079c92ca4SYu Wang void ieee80211_tdls_handle_disconnect(struct ieee80211_sub_if_data *sdata,
249179c92ca4SYu Wang 				      const u8 *peer, u16 reason);
2492f057d140SJohannes Berg void
2493f057d140SJohannes Berg ieee80211_process_tdls_channel_switch(struct ieee80211_sub_if_data *sdata,
2494f057d140SJohannes Berg 				      struct sk_buff *skb);
2495f057d140SJohannes Berg 
2496f057d140SJohannes Berg 
249779c92ca4SYu Wang const char *ieee80211_get_reason_code_string(u16 reason_code);
249805d10957SThomas Pedersen u16 ieee80211_encode_usf(int val);
249909a740ceSThomas Pedersen u8 *ieee80211_get_bssid(struct ieee80211_hdr *hdr, size_t len,
250009a740ceSThomas Pedersen 			enum nl80211_iftype type);
250195224fe8SArik Nemtsov 
2502b7ffbd7eSJohannes Berg extern const struct ethtool_ops ieee80211_ethtool_ops;
2503b7ffbd7eSJohannes Berg 
2504db3e1c40SToke Høiland-Jørgensen u32 ieee80211_calc_expected_tx_airtime(struct ieee80211_hw *hw,
2505db3e1c40SToke Høiland-Jørgensen 				       struct ieee80211_vif *vif,
2506db3e1c40SToke Høiland-Jørgensen 				       struct ieee80211_sta *pubsta,
25073ff901cbSFelix Fietkau 				       int len, bool ampdu);
2508f4ea83ddSJohannes Berg #ifdef CONFIG_MAC80211_NOINLINE
2509d9e8a70fSJohannes Berg #define debug_noinline noinline
2510d9e8a70fSJohannes Berg #else
2511d9e8a70fSJohannes Berg #define debug_noinline
2512d9e8a70fSJohannes Berg #endif
2513d9e8a70fSJohannes Berg 
25143a11ce08SJohannes Berg void ieee80211_init_frag_cache(struct ieee80211_fragment_cache *cache);
25153a11ce08SJohannes Berg void ieee80211_destroy_frag_cache(struct ieee80211_fragment_cache *cache);
25163a11ce08SJohannes Berg 
2517f0706e82SJiri Benc #endif /* IEEE80211_I_H */
2518