xref: /openbmc/linux/net/mac80211/ieee80211_i.h (revision 4dc792b8)
1f0706e82SJiri Benc /*
2f0706e82SJiri Benc  * Copyright 2002-2005, Instant802 Networks, Inc.
3f0706e82SJiri Benc  * Copyright 2005, Devicescape Software, Inc.
4f0706e82SJiri Benc  * Copyright 2006-2007	Jiri Benc <jbenc@suse.cz>
5026331c4SJouni Malinen  * Copyright 2007-2010	Johannes Berg <johannes@sipsolutions.net>
6d98ad83eSJohannes Berg  * Copyright 2013-2014  Intel Mobile Communications GmbH
7f0706e82SJiri Benc  *
8f0706e82SJiri Benc  * This program is free software; you can redistribute it and/or modify
9f0706e82SJiri Benc  * it under the terms of the GNU General Public License version 2 as
10f0706e82SJiri Benc  * published by the Free Software Foundation.
11f0706e82SJiri Benc  */
12f0706e82SJiri Benc 
13f0706e82SJiri Benc #ifndef IEEE80211_I_H
14f0706e82SJiri Benc #define IEEE80211_I_H
15f0706e82SJiri Benc 
16f0706e82SJiri Benc #include <linux/kernel.h>
17f0706e82SJiri Benc #include <linux/device.h>
18f0706e82SJiri Benc #include <linux/if_ether.h>
19f0706e82SJiri Benc #include <linux/interrupt.h>
20f0706e82SJiri Benc #include <linux/list.h>
21f0706e82SJiri Benc #include <linux/netdevice.h>
22f0706e82SJiri Benc #include <linux/skbuff.h>
23f0706e82SJiri Benc #include <linux/workqueue.h>
24f0706e82SJiri Benc #include <linux/types.h>
25f0706e82SJiri Benc #include <linux/spinlock.h>
26571ecf67SJohannes Berg #include <linux/etherdevice.h>
27e1e54068SJohannes Berg #include <linux/leds.h>
28a729cff8SJohannes Berg #include <linux/idr.h>
297bedd0cfSJohannes Berg #include <linux/rhashtable.h>
30fe7a5d5cSJohannes Berg #include <net/ieee80211_radiotap.h>
3193da9cc1Scolin@cozybit.com #include <net/cfg80211.h>
3251cb6db0SDavid S. Miller #include <net/mac80211.h>
332c8dccc7SJohannes Berg #include "key.h"
34f0706e82SJiri Benc #include "sta_info.h"
35bdcbd8e0SJohannes Berg #include "debug.h"
36f0706e82SJiri Benc 
379cfb0009SJohannes Berg struct ieee80211_local;
38f0706e82SJiri Benc 
39f0706e82SJiri Benc /* Maximum number of broadcast/multicast frames to buffer when some of the
40f0706e82SJiri Benc  * associated stations are using power saving. */
41f0706e82SJiri Benc #define AP_MAX_BC_BUFFER 128
42f0706e82SJiri Benc 
43f0706e82SJiri Benc /* Maximum number of frames buffered to all STAs, including multicast frames.
44f0706e82SJiri Benc  * Note: increasing this limit increases the potential memory requirement. Each
45f0706e82SJiri Benc  * frame can be up to about 2 kB long. */
46f0706e82SJiri Benc #define TOTAL_MAX_TX_BUFFER 512
47f0706e82SJiri Benc 
48f0706e82SJiri Benc /* Required encryption head and tailroom */
49f0706e82SJiri Benc #define IEEE80211_ENCRYPT_HEADROOM 8
50765cb46aSJouni Malinen #define IEEE80211_ENCRYPT_TAILROOM 18
51f0706e82SJiri Benc 
52f0706e82SJiri Benc /* IEEE 802.11 (Ch. 9.5 Defragmentation) requires support for concurrent
53f0706e82SJiri Benc  * reception of at least three fragmented frames. This limit can be increased
54f0706e82SJiri Benc  * by changing this define, at the cost of slower frame reassembly and
55f0706e82SJiri Benc  * increased memory use (about 2 kB of RAM per entry). */
56f0706e82SJiri Benc #define IEEE80211_FRAGMENT_MAX 4
57f0706e82SJiri Benc 
581ea6f9c0SJohannes Berg /* power level hasn't been configured (or set to automatic) */
591ea6f9c0SJohannes Berg #define IEEE80211_UNSET_POWER_LEVEL	INT_MIN
601ea6f9c0SJohannes Berg 
61d6a4ed6fSArik Nemtsov /*
62aa75ebc2SMichal Kazior  * Some APs experience problems when working with U-APSD. Decreasing the
63aa75ebc2SMichal Kazior  * probability of that happening by using legacy mode for all ACs but VO isn't
64aa75ebc2SMichal Kazior  * enough.
65aa75ebc2SMichal Kazior  *
66aa75ebc2SMichal Kazior  * Cisco 4410N originally forced us to enable VO by default only because it
67aa75ebc2SMichal Kazior  * treated non-VO ACs as legacy.
68aa75ebc2SMichal Kazior  *
69aa75ebc2SMichal Kazior  * However some APs (notably Netgear R7000) silently reclassify packets to
70aa75ebc2SMichal Kazior  * different ACs. Since u-APSD ACs require trigger frames for frame retrieval
71aa75ebc2SMichal Kazior  * clients would never see some frames (e.g. ARP responses) or would fetch them
72aa75ebc2SMichal Kazior  * accidentally after a long time.
73aa75ebc2SMichal Kazior  *
74aa75ebc2SMichal Kazior  * It makes little sense to enable u-APSD queues by default because it needs
75aa75ebc2SMichal Kazior  * userspace applications to be aware of it to actually take advantage of the
76aa75ebc2SMichal Kazior  * possible additional powersavings. Implicitly depending on driver autotrigger
77aa75ebc2SMichal Kazior  * frame support doesn't make much sense.
78d6a4ed6fSArik Nemtsov  */
79aa75ebc2SMichal Kazior #define IEEE80211_DEFAULT_UAPSD_QUEUES 0
80ab13315aSKalle Valo 
81ab13315aSKalle Valo #define IEEE80211_DEFAULT_MAX_SP_LEN		\
82ab13315aSKalle Valo 	IEEE80211_WMM_IE_STA_QOSINFO_SP_ALL
83ab13315aSKalle Valo 
846ae16775SAntonio Quartulli #define IEEE80211_DEAUTH_FRAME_LEN	(24 /* hdr */ + 2 /* reason */)
856ae16775SAntonio Quartulli 
86f0706e82SJiri Benc struct ieee80211_fragment_entry {
87f0706e82SJiri Benc 	struct sk_buff_head skb_list;
8869f13223SJohannes Berg 	unsigned long first_frag_time;
8969f13223SJohannes Berg 	u16 seq;
9069f13223SJohannes Berg 	u16 extra_len;
9169f13223SJohannes Berg 	u16 last_frag;
9269f13223SJohannes Berg 	u8 rx_queue;
9369f13223SJohannes Berg 	bool ccmp; /* Whether fragments were encrypted with CCMP */
94f0706e82SJiri Benc 	u8 last_pn[6]; /* PN of the last fragment if CCMP was used */
95f0706e82SJiri Benc };
96f0706e82SJiri Benc 
97f0706e82SJiri Benc 
98c2b13452SJohannes Berg struct ieee80211_bss {
99ef429dadSJohannes Berg 	u32 device_ts_beacon, device_ts_presp;
1008c358bcdSJohannes Berg 
10143ac2ca3SJouni Malinen 	bool wmm_used;
102ab13315aSKalle Valo 	bool uapsd_supported;
10300d3f14cSJohannes Berg 
104f0706e82SJiri Benc #define IEEE80211_MAX_SUPP_RATES 32
105f0706e82SJiri Benc 	u8 supp_rates[IEEE80211_MAX_SUPP_RATES];
106f0706e82SJiri Benc 	size_t supp_rates_len;
107817cee76SAlexander Bondar 	struct ieee80211_rate *beacon_rate;
108f0706e82SJiri Benc 
10900d3f14cSJohannes Berg 	/*
11025985edcSLucas De Marchi 	 * During association, we save an ERP value from a probe response so
1115628221cSDaniel Drake 	 * that we can feed ERP info to the driver when handling the
1125628221cSDaniel Drake 	 * association completes. these fields probably won't be up-to-date
11300d3f14cSJohannes Berg 	 * otherwise, you probably don't want to use them.
11400d3f14cSJohannes Berg 	 */
11500d3f14cSJohannes Berg 	bool has_erp_value;
1165628221cSDaniel Drake 	u8 erp_value;
117fcff4f10SPaul Stewart 
118fcff4f10SPaul Stewart 	/* Keep track of the corruption of the last beacon/probe response. */
119fcff4f10SPaul Stewart 	u8 corrupt_data;
120fcff4f10SPaul Stewart 
121fcff4f10SPaul Stewart 	/* Keep track of what bits of information we have valid info for. */
122fcff4f10SPaul Stewart 	u8 valid_data;
123fcff4f10SPaul Stewart };
124fcff4f10SPaul Stewart 
125fcff4f10SPaul Stewart /**
126fcff4f10SPaul Stewart  * enum ieee80211_corrupt_data_flags - BSS data corruption flags
127fcff4f10SPaul Stewart  * @IEEE80211_BSS_CORRUPT_BEACON: last beacon frame received was corrupted
128fcff4f10SPaul Stewart  * @IEEE80211_BSS_CORRUPT_PROBE_RESP: last probe response received was corrupted
129fcff4f10SPaul Stewart  *
130fcff4f10SPaul Stewart  * These are bss flags that are attached to a bss in the
131fcff4f10SPaul Stewart  * @corrupt_data field of &struct ieee80211_bss.
132fcff4f10SPaul Stewart  */
133fcff4f10SPaul Stewart enum ieee80211_bss_corrupt_data_flags {
134fcff4f10SPaul Stewart 	IEEE80211_BSS_CORRUPT_BEACON		= BIT(0),
135fcff4f10SPaul Stewart 	IEEE80211_BSS_CORRUPT_PROBE_RESP	= BIT(1)
136fcff4f10SPaul Stewart };
137fcff4f10SPaul Stewart 
138fcff4f10SPaul Stewart /**
139fcff4f10SPaul Stewart  * enum ieee80211_valid_data_flags - BSS valid data flags
140fcff4f10SPaul Stewart  * @IEEE80211_BSS_VALID_WMM: WMM/UAPSD data was gathered from non-corrupt IE
141fcff4f10SPaul Stewart  * @IEEE80211_BSS_VALID_RATES: Supported rates were gathered from non-corrupt IE
142fcff4f10SPaul Stewart  * @IEEE80211_BSS_VALID_ERP: ERP flag was gathered from non-corrupt IE
143fcff4f10SPaul Stewart  *
144fcff4f10SPaul Stewart  * These are bss flags that are attached to a bss in the
145fcff4f10SPaul Stewart  * @valid_data field of &struct ieee80211_bss.  They show which parts
146d070f913SStephen Hemminger  * of the data structure were received as a result of an un-corrupted
147fcff4f10SPaul Stewart  * beacon/probe response.
148fcff4f10SPaul Stewart  */
149fcff4f10SPaul Stewart enum ieee80211_bss_valid_data_flags {
150fcff4f10SPaul Stewart 	IEEE80211_BSS_VALID_WMM			= BIT(1),
151fcff4f10SPaul Stewart 	IEEE80211_BSS_VALID_RATES		= BIT(2),
152fcff4f10SPaul Stewart 	IEEE80211_BSS_VALID_ERP			= BIT(3)
153f0706e82SJiri Benc };
154f0706e82SJiri Benc 
1559ae54c84SJohannes Berg typedef unsigned __bitwise__ ieee80211_tx_result;
1569ae54c84SJohannes Berg #define TX_CONTINUE	((__force ieee80211_tx_result) 0u)
1579ae54c84SJohannes Berg #define TX_DROP		((__force ieee80211_tx_result) 1u)
1589ae54c84SJohannes Berg #define TX_QUEUED	((__force ieee80211_tx_result) 2u)
1599ae54c84SJohannes Berg 
1605cf121c3SJohannes Berg #define IEEE80211_TX_UNICAST		BIT(1)
1615cf121c3SJohannes Berg #define IEEE80211_TX_PS_BUFFERED	BIT(2)
1629ae54c84SJohannes Berg 
1635cf121c3SJohannes Berg struct ieee80211_tx_data {
164f0706e82SJiri Benc 	struct sk_buff *skb;
165252b86c4SJohannes Berg 	struct sk_buff_head skbs;
166f0706e82SJiri Benc 	struct ieee80211_local *local;
167f0706e82SJiri Benc 	struct ieee80211_sub_if_data *sdata;
168f0706e82SJiri Benc 	struct sta_info *sta;
169f0706e82SJiri Benc 	struct ieee80211_key *key;
1700d528d85SFelix Fietkau 	struct ieee80211_tx_rate rate;
1715cf121c3SJohannes Berg 
172056cdd59SJohannes Berg 	unsigned int flags;
1735cf121c3SJohannes Berg };
1745cf121c3SJohannes Berg 
1755cf121c3SJohannes Berg 
1765cf121c3SJohannes Berg typedef unsigned __bitwise__ ieee80211_rx_result;
1775cf121c3SJohannes Berg #define RX_CONTINUE		((__force ieee80211_rx_result) 0u)
1785cf121c3SJohannes Berg #define RX_DROP_UNUSABLE	((__force ieee80211_rx_result) 1u)
1795cf121c3SJohannes Berg #define RX_DROP_MONITOR		((__force ieee80211_rx_result) 2u)
1805cf121c3SJohannes Berg #define RX_QUEUED		((__force ieee80211_rx_result) 3u)
1815cf121c3SJohannes Berg 
182554891e6SJohannes Berg /**
183554891e6SJohannes Berg  * enum ieee80211_packet_rx_flags - packet RX flags
184554891e6SJohannes Berg  * @IEEE80211_RX_AMSDU: a-MSDU packet
185554891e6SJohannes Berg  * @IEEE80211_RX_MALFORMED_ACTION_FRM: action frame is malformed
1864cfda47bSChristian Lamparter  * @IEEE80211_RX_DEFERRED_RELEASE: frame was subjected to receive reordering
187554891e6SJohannes Berg  *
188554891e6SJohannes Berg  * These are per-frame flags that are attached to a frame in the
189554891e6SJohannes Berg  * @rx_flags field of &struct ieee80211_rx_status.
190554891e6SJohannes Berg  */
191554891e6SJohannes Berg enum ieee80211_packet_rx_flags {
192554891e6SJohannes Berg 	IEEE80211_RX_AMSDU			= BIT(3),
193554891e6SJohannes Berg 	IEEE80211_RX_MALFORMED_ACTION_FRM	= BIT(4),
1944cfda47bSChristian Lamparter 	IEEE80211_RX_DEFERRED_RELEASE		= BIT(5),
195554891e6SJohannes Berg };
196554891e6SJohannes Berg 
197554891e6SJohannes Berg /**
198554891e6SJohannes Berg  * enum ieee80211_rx_flags - RX data flags
199554891e6SJohannes Berg  *
200554891e6SJohannes Berg  * @IEEE80211_RX_CMNTR: received on cooked monitor already
201ee971924SJohannes Berg  * @IEEE80211_RX_BEACON_REPORTED: This frame was already reported
202ee971924SJohannes Berg  *	to cfg80211_report_obss_beacon().
203554891e6SJohannes Berg  *
204554891e6SJohannes Berg  * These flags are used across handling multiple interfaces
205554891e6SJohannes Berg  * for a single frame.
206554891e6SJohannes Berg  */
207554891e6SJohannes Berg enum ieee80211_rx_flags {
208554891e6SJohannes Berg 	IEEE80211_RX_CMNTR		= BIT(0),
209ee971924SJohannes Berg 	IEEE80211_RX_BEACON_REPORTED	= BIT(1),
210554891e6SJohannes Berg };
2115cf121c3SJohannes Berg 
2125cf121c3SJohannes Berg struct ieee80211_rx_data {
213af9f9b22SJohannes Berg 	struct napi_struct *napi;
2145cf121c3SJohannes Berg 	struct sk_buff *skb;
2155cf121c3SJohannes Berg 	struct ieee80211_local *local;
2165cf121c3SJohannes Berg 	struct ieee80211_sub_if_data *sdata;
2175cf121c3SJohannes Berg 	struct sta_info *sta;
2185cf121c3SJohannes Berg 	struct ieee80211_key *key;
219056cdd59SJohannes Berg 
220056cdd59SJohannes Berg 	unsigned int flags;
2219e26297aSJohannes Berg 
2229e26297aSJohannes Berg 	/*
2239e26297aSJohannes Berg 	 * Index into sequence numbers array, 0..16
2249e26297aSJohannes Berg 	 * since the last (16) is used for non-QoS,
2259e26297aSJohannes Berg 	 * will be 16 on non-QoS frames.
2269e26297aSJohannes Berg 	 */
2279e26297aSJohannes Berg 	int seqno_idx;
2289e26297aSJohannes Berg 
2299e26297aSJohannes Berg 	/*
2309e26297aSJohannes Berg 	 * Index into the security IV/PN arrays, 0..16
2319e26297aSJohannes Berg 	 * since the last (16) is used for CCMP-encrypted
2329e26297aSJohannes Berg 	 * management frames, will be set to 16 on mgmt
2339e26297aSJohannes Berg 	 * frames and 0 on non-QoS frames.
2349e26297aSJohannes Berg 	 */
2359e26297aSJohannes Berg 	int security_idx;
2369e26297aSJohannes Berg 
23750741ae0SJohannes Berg 	u32 tkip_iv32;
23850741ae0SJohannes Berg 	u16 tkip_iv16;
239f0706e82SJiri Benc };
240f0706e82SJiri Benc 
241af296bdbSMichal Kazior struct ieee80211_csa_settings {
242af296bdbSMichal Kazior 	const u16 *counter_offsets_beacon;
243af296bdbSMichal Kazior 	const u16 *counter_offsets_presp;
244af296bdbSMichal Kazior 
245af296bdbSMichal Kazior 	int n_counter_offsets_beacon;
246af296bdbSMichal Kazior 	int n_counter_offsets_presp;
247af296bdbSMichal Kazior 
248af296bdbSMichal Kazior 	u8 count;
249af296bdbSMichal Kazior };
250af296bdbSMichal Kazior 
2515dfdaf58SJohannes Berg struct beacon_data {
2525dfdaf58SJohannes Berg 	u8 *head, *tail;
2535dfdaf58SJohannes Berg 	int head_len, tail_len;
25443552be1SThomas Pedersen 	struct ieee80211_meshconf_ie *meshconf;
255af296bdbSMichal Kazior 	u16 csa_counter_offsets[IEEE80211_MAX_CSA_COUNTERS_NUM];
256af296bdbSMichal Kazior 	u8 csa_current_counter;
2578860020eSJohannes Berg 	struct rcu_head rcu_head;
2585dfdaf58SJohannes Berg };
2595dfdaf58SJohannes Berg 
260aa7a0080SEyal Shapira struct probe_resp {
261aa7a0080SEyal Shapira 	struct rcu_head rcu_head;
262aa7a0080SEyal Shapira 	int len;
263af296bdbSMichal Kazior 	u16 csa_counter_offsets[IEEE80211_MAX_CSA_COUNTERS_NUM];
264aa7a0080SEyal Shapira 	u8 data[0];
265aa7a0080SEyal Shapira };
266aa7a0080SEyal Shapira 
267d012a605SMarco Porsch struct ps_data {
268d012a605SMarco Porsch 	/* yes, this looks ugly, but guarantees that we can later use
269d012a605SMarco Porsch 	 * bitmap_empty :)
270d012a605SMarco Porsch 	 * NB: don't touch this bitmap, use sta_info_{set,clear}_tim_bit */
2715fe2bb86SJoe Perches 	u8 tim[sizeof(unsigned long) * BITS_TO_LONGS(IEEE80211_MAX_AID + 1)]
2725fe2bb86SJoe Perches 			__aligned(__alignof__(unsigned long));
273d012a605SMarco Porsch 	struct sk_buff_head bc_buf;
274d012a605SMarco Porsch 	atomic_t num_sta_ps; /* number of stations in PS mode */
275d012a605SMarco Porsch 	int dtim_count;
276d012a605SMarco Porsch 	bool dtim_bc_mc;
277d012a605SMarco Porsch };
278d012a605SMarco Porsch 
279f0706e82SJiri Benc struct ieee80211_if_ap {
28040b275b6SJohannes Berg 	struct beacon_data __rcu *beacon;
281aa7a0080SEyal Shapira 	struct probe_resp __rcu *probe_resp;
282f0706e82SJiri Benc 
28373da7d5bSSimon Wunderlich 	/* to be used after channel switch. */
28473da7d5bSSimon Wunderlich 	struct cfg80211_beacon_data *next_beacon;
2854e141dadSMichal Kazior 	struct list_head vlans; /* write-protected with RTNL and local->mtx */
2860ec3ca44SJohannes Berg 
287d012a605SMarco Porsch 	struct ps_data ps;
288030ef8f8SFelix Fietkau 	atomic_t num_mcast_sta; /* number of stations receiving multicast */
289687da132SEmmanuel Grumbach 	enum ieee80211_smps_mode req_smps, /* requested smps mode */
290687da132SEmmanuel Grumbach 			 driver_smps_mode; /* smps mode request */
291687da132SEmmanuel Grumbach 
292687da132SEmmanuel Grumbach 	struct work_struct request_smps_work;
293f0706e82SJiri Benc };
294f0706e82SJiri Benc 
295f0706e82SJiri Benc struct ieee80211_if_wds {
296f0706e82SJiri Benc 	struct sta_info *sta;
297056cdd59SJohannes Berg 	u8 remote_addr[ETH_ALEN];
298f0706e82SJiri Benc };
299f0706e82SJiri Benc 
300f0706e82SJiri Benc struct ieee80211_if_vlan {
3014e141dadSMichal Kazior 	struct list_head list; /* write-protected with RTNL and local->mtx */
302f14543eeSFelix Fietkau 
303f14543eeSFelix Fietkau 	/* used for all tx if the VLAN is configured to 4-addr mode */
30440b275b6SJohannes Berg 	struct sta_info __rcu *sta;
305f0706e82SJiri Benc };
306f0706e82SJiri Benc 
307ee385855SLuis Carlos Cobo struct mesh_stats {
308c8a61a7dSDaniel Walker 	__u32 fwded_mcast;		/* Mesh forwarded multicast frames */
309c8a61a7dSDaniel Walker 	__u32 fwded_unicast;		/* Mesh forwarded unicast frames */
310c8a61a7dSDaniel Walker 	__u32 fwded_frames;		/* Mesh total forwarded frames */
311ee385855SLuis Carlos Cobo 	__u32 dropped_frames_ttl;	/* Not transmitted since mesh_ttl == 0*/
312ee385855SLuis Carlos Cobo 	__u32 dropped_frames_no_route;	/* Not transmitted, no route found */
313cfee66b0SJavier Cardona 	__u32 dropped_frames_congestion;/* Not forwarded due to congestion */
314ee385855SLuis Carlos Cobo };
315ee385855SLuis Carlos Cobo 
316ee385855SLuis Carlos Cobo #define PREQ_Q_F_START		0x1
317ee385855SLuis Carlos Cobo #define PREQ_Q_F_REFRESH	0x2
318ee385855SLuis Carlos Cobo struct mesh_preq_queue {
319ee385855SLuis Carlos Cobo 	struct list_head list;
320ee385855SLuis Carlos Cobo 	u8 dst[ETH_ALEN];
321ee385855SLuis Carlos Cobo 	u8 flags;
322ee385855SLuis Carlos Cobo };
323ee385855SLuis Carlos Cobo 
3242eb278e0SJohannes Berg struct ieee80211_roc_work {
32577fdaa12SJohannes Berg 	struct list_head list;
3262eb278e0SJohannes Berg 	struct list_head dependents;
327f679f65dSJohannes Berg 
3282eb278e0SJohannes Berg 	struct delayed_work work;
329af6b6374SJohannes Berg 
330af6b6374SJohannes Berg 	struct ieee80211_sub_if_data *sdata;
331af6b6374SJohannes Berg 
332f679f65dSJohannes Berg 	struct ieee80211_channel *chan;
333af6b6374SJohannes Berg 
3342eb278e0SJohannes Berg 	bool started, abort, hw_begun, notified;
3353fbd45caSJohannes Berg 	bool to_be_freed;
336b4b177a5SJohannes Berg 	bool on_channel;
337f679f65dSJohannes Berg 
3382eb278e0SJohannes Berg 	unsigned long hw_start_time;
339e4da8c37SJohannes Berg 
3402eb278e0SJohannes Berg 	u32 duration, req_duration;
341f30221e4SJohannes Berg 	struct sk_buff *frame;
34250febf6aSJohannes Berg 	u64 cookie, mgmt_tx_cookie;
343d339d5caSIlan Peer 	enum ieee80211_roc_type type;
34477fdaa12SJohannes Berg };
34577fdaa12SJohannes Berg 
34646900298SJohannes Berg /* flags used in struct ieee80211_if_managed.flags */
347ab1faeadSJohannes Berg enum ieee80211_sta_flags {
348b291ba11SJohannes Berg 	IEEE80211_STA_CONNECTION_POLL	= BIT(1),
349b291ba11SJohannes Berg 	IEEE80211_STA_CONTROL_PORT	= BIT(2),
350a8243b72SJohannes Berg 	IEEE80211_STA_DISABLE_HT	= BIT(4),
351b291ba11SJohannes Berg 	IEEE80211_STA_MFP_ENABLED	= BIT(6),
352ab13315aSKalle Valo 	IEEE80211_STA_UAPSD_ENABLED	= BIT(7),
353375177bfSVivek Natarajan 	IEEE80211_STA_NULLFUNC_ACKED	= BIT(8),
35417e4ec14SJouni Malinen 	IEEE80211_STA_RESET_SIGNAL_AVE	= BIT(9),
35524398e39SJohannes Berg 	IEEE80211_STA_DISABLE_40MHZ	= BIT(10),
356d545dabaSMahesh Palivela 	IEEE80211_STA_DISABLE_VHT	= BIT(11),
357f2d9d270SJohannes Berg 	IEEE80211_STA_DISABLE_80P80MHZ	= BIT(12),
358f2d9d270SJohannes Berg 	IEEE80211_STA_DISABLE_160MHZ	= BIT(13),
359095d81ceSJohannes Berg 	IEEE80211_STA_DISABLE_WMM	= BIT(14),
360cd2f5dd7SAssaf Krauss 	IEEE80211_STA_ENABLE_RRM	= BIT(15),
361ab1faeadSJohannes Berg };
362ab1faeadSJohannes Berg 
36366e67e41SJohannes Berg struct ieee80211_mgd_auth_data {
36466e67e41SJohannes Berg 	struct cfg80211_bss *bss;
36566e67e41SJohannes Berg 	unsigned long timeout;
36666e67e41SJohannes Berg 	int tries;
36766e67e41SJohannes Berg 	u16 algorithm, expected_transaction;
36866e67e41SJohannes Berg 
36966e67e41SJohannes Berg 	u8 key[WLAN_KEY_LEN_WEP104];
37066e67e41SJohannes Berg 	u8 key_len, key_idx;
37166e67e41SJohannes Berg 	bool done;
37289afe614SJohannes Berg 	bool timeout_started;
37366e67e41SJohannes Berg 
3746b8ece3aSJouni Malinen 	u16 sae_trans, sae_status;
3756b8ece3aSJouni Malinen 	size_t data_len;
3766b8ece3aSJouni Malinen 	u8 data[];
37766e67e41SJohannes Berg };
37866e67e41SJohannes Berg 
37966e67e41SJohannes Berg struct ieee80211_mgd_assoc_data {
38066e67e41SJohannes Berg 	struct cfg80211_bss *bss;
38166e67e41SJohannes Berg 	const u8 *supp_rates;
38266e67e41SJohannes Berg 
38366e67e41SJohannes Berg 	unsigned long timeout;
38466e67e41SJohannes Berg 	int tries;
38566e67e41SJohannes Berg 
38666e67e41SJohannes Berg 	u16 capability;
38766e67e41SJohannes Berg 	u8 prev_bssid[ETH_ALEN];
38866e67e41SJohannes Berg 	u8 ssid[IEEE80211_MAX_SSID_LEN];
38966e67e41SJohannes Berg 	u8 ssid_len;
39066e67e41SJohannes Berg 	u8 supp_rates_len;
39176f0303dSJohannes Berg 	bool wmm, uapsd;
392989c6505SAlexander Bondar 	bool need_beacon;
39366e67e41SJohannes Berg 	bool synced;
39489afe614SJohannes Berg 	bool timeout_started;
39566e67e41SJohannes Berg 
3969dde6423SJohannes Berg 	u8 ap_ht_param;
3979dde6423SJohannes Berg 
398b08fbbd8SJohannes Berg 	struct ieee80211_vht_cap ap_vht_cap;
399b08fbbd8SJohannes Berg 
40066e67e41SJohannes Berg 	size_t ie_len;
40166e67e41SJohannes Berg 	u8 ie[];
40266e67e41SJohannes Berg };
40366e67e41SJohannes Berg 
40402219b3aSJohannes Berg struct ieee80211_sta_tx_tspec {
40502219b3aSJohannes Berg 	/* timestamp of the first packet in the time slice */
40602219b3aSJohannes Berg 	unsigned long time_slice_start;
40702219b3aSJohannes Berg 
40802219b3aSJohannes Berg 	u32 admitted_time; /* in usecs, unlike over the air */
40902219b3aSJohannes Berg 	u8 tsid;
41002219b3aSJohannes Berg 	s8 up; /* signed to be able to invalidate with -1 during teardown */
41102219b3aSJohannes Berg 
41202219b3aSJohannes Berg 	/* consumed TX time in microseconds in the time slice */
41302219b3aSJohannes Berg 	u32 consumed_tx_time;
41402219b3aSJohannes Berg 	enum {
41502219b3aSJohannes Berg 		TX_TSPEC_ACTION_NONE = 0,
41602219b3aSJohannes Berg 		TX_TSPEC_ACTION_DOWNGRADE,
41702219b3aSJohannes Berg 		TX_TSPEC_ACTION_STOP_DOWNGRADE,
41802219b3aSJohannes Berg 	} action;
41902219b3aSJohannes Berg 	bool downgraded;
42002219b3aSJohannes Berg };
42102219b3aSJohannes Berg 
422338c17aeSJohannes Berg DECLARE_EWMA(beacon_signal, 16, 4)
423338c17aeSJohannes Berg 
42446900298SJohannes Berg struct ieee80211_if_managed {
425056cdd59SJohannes Berg 	struct timer_list timer;
426b291ba11SJohannes Berg 	struct timer_list conn_mon_timer;
427b291ba11SJohannes Berg 	struct timer_list bcn_mon_timer;
428c481ec97SSujith 	struct timer_list chswitch_timer;
429b291ba11SJohannes Berg 	struct work_struct monitor_work;
430c481ec97SSujith 	struct work_struct chswitch_work;
4311e4dcd01SJuuso Oikarinen 	struct work_struct beacon_connection_loss_work;
432882a7c69SJohannes Berg 	struct work_struct csa_connection_drop_work;
43346900298SJohannes Berg 
4347ccc8bd7SFelix Fietkau 	unsigned long beacon_timeout;
435b291ba11SJohannes Berg 	unsigned long probe_timeout;
436a43abf29SMaxim Levitsky 	int probe_send_count;
43704ac3c0eSFelix Fietkau 	bool nullfunc_failed;
438682bd38bSJohannes Berg 	bool connection_loss;
439b291ba11SJohannes Berg 
4400c1ad2caSJohannes Berg 	struct cfg80211_bss *associated;
44166e67e41SJohannes Berg 	struct ieee80211_mgd_auth_data *auth_data;
44266e67e41SJohannes Berg 	struct ieee80211_mgd_assoc_data *assoc_data;
44346900298SJohannes Berg 
44477fdaa12SJohannes Berg 	u8 bssid[ETH_ALEN];
44546900298SJohannes Berg 
446f0706e82SJiri Benc 	u16 aid;
447f0706e82SJiri Benc 
448965bedadSJohannes Berg 	bool powersave; /* powersave requested for this iface */
44905cb9108SJohannes Berg 	bool broken_ap; /* AP is broken -- turn off powersave */
450989c6505SAlexander Bondar 	bool have_beacon;
451826262c3SJohannes Berg 	u8 dtim_period;
4520f78231bSJohannes Berg 	enum ieee80211_smps_mode req_smps, /* requested smps mode */
453d1f5b7a3SJohannes Berg 				 driver_smps_mode; /* smps mode request */
454d1f5b7a3SJohannes Berg 
455d1f5b7a3SJohannes Berg 	struct work_struct request_smps_work;
456965bedadSJohannes Berg 
457d6f2da5bSJiri Slaby 	unsigned int flags;
458f0706e82SJiri Benc 
4590c21e632SLuciano Coelho 	bool csa_waiting_bcn;
460f84eaa10SJohannes Berg 	bool csa_ignored_same_chan;
4610c21e632SLuciano Coelho 
462d8ec4433SJuuso Oikarinen 	bool beacon_crc_valid;
463d91f36dbSJohannes Berg 	u32 beacon_crc;
464d91f36dbSJohannes Berg 
4651672c0e3SJohannes Berg 	bool status_acked;
4661672c0e3SJohannes Berg 	bool status_received;
4671672c0e3SJohannes Berg 	__le16 status_fc;
4681672c0e3SJohannes Berg 
469fdfacf0aSJouni Malinen 	enum {
470fdfacf0aSJouni Malinen 		IEEE80211_MFP_DISABLED,
471fdfacf0aSJouni Malinen 		IEEE80211_MFP_OPTIONAL,
472fdfacf0aSJouni Malinen 		IEEE80211_MFP_REQUIRED
473fdfacf0aSJouni Malinen 	} mfp; /* management frame protection */
474fdfacf0aSJouni Malinen 
475dc41e4d4SEliad Peller 	/*
476dc41e4d4SEliad Peller 	 * Bitmask of enabled u-apsd queues,
477dc41e4d4SEliad Peller 	 * IEEE80211_WMM_IE_STA_QOSINFO_AC_BE & co. Needs a new association
478dc41e4d4SEliad Peller 	 * to take effect.
479dc41e4d4SEliad Peller 	 */
480dc41e4d4SEliad Peller 	unsigned int uapsd_queues;
481dc41e4d4SEliad Peller 
482dc41e4d4SEliad Peller 	/*
483dc41e4d4SEliad Peller 	 * Maximum number of buffered frames AP can deliver during a
484dc41e4d4SEliad Peller 	 * service period, IEEE80211_WMM_IE_STA_QOSINFO_SP_ALL or similar.
485dc41e4d4SEliad Peller 	 * Needs a new association to take effect.
486dc41e4d4SEliad Peller 	 */
487dc41e4d4SEliad Peller 	unsigned int uapsd_max_sp_len;
488dc41e4d4SEliad Peller 
489f0706e82SJiri Benc 	int wmm_last_param_set;
4909bc383deSJohannes Berg 
4919bc383deSJohannes Berg 	u8 use_4addr;
49217e4ec14SJouni Malinen 
49367baf663SJanusz Dziedzic 	s16 p2p_noa_index;
494488dd7b5SJohannes Berg 
495338c17aeSJohannes Berg 	struct ewma_beacon_signal ave_beacon_signal;
49617e4ec14SJouni Malinen 
49717e4ec14SJouni Malinen 	/*
498391a200aSJouni Malinen 	 * Number of Beacon frames used in ave_beacon_signal. This can be used
499391a200aSJouni Malinen 	 * to avoid generating less reliable cqm events that would be based
500391a200aSJouni Malinen 	 * only on couple of received frames.
501391a200aSJouni Malinen 	 */
502391a200aSJouni Malinen 	unsigned int count_beacon_signal;
503391a200aSJouni Malinen 
504391a200aSJouni Malinen 	/*
50517e4ec14SJouni Malinen 	 * Last Beacon frame signal strength average (ave_beacon_signal / 16)
50617e4ec14SJouni Malinen 	 * that triggered a cqm event. 0 indicates that no event has been
50717e4ec14SJouni Malinen 	 * generated for the current association.
50817e4ec14SJouni Malinen 	 */
50917e4ec14SJouni Malinen 	int last_cqm_event_signal;
510615f7b9bSMeenakshi Venkataraman 
511615f7b9bSMeenakshi Venkataraman 	/*
512615f7b9bSMeenakshi Venkataraman 	 * State variables for keeping track of RSSI of the AP currently
513615f7b9bSMeenakshi Venkataraman 	 * connected to and informing driver when RSSI has gone
514615f7b9bSMeenakshi Venkataraman 	 * below/above a certain threshold.
515615f7b9bSMeenakshi Venkataraman 	 */
516615f7b9bSMeenakshi Venkataraman 	int rssi_min_thold, rssi_max_thold;
517615f7b9bSMeenakshi Venkataraman 	int last_ave_beacon_signal;
518ef96a842SBen Greear 
519ef96a842SBen Greear 	struct ieee80211_ht_cap ht_capa; /* configured ht-cap over-rides */
520ef96a842SBen Greear 	struct ieee80211_ht_cap ht_capa_mask; /* Valid parts of ht_capa */
521dd5ecfeaSJohannes Berg 	struct ieee80211_vht_cap vht_capa; /* configured VHT overrides */
522dd5ecfeaSJohannes Berg 	struct ieee80211_vht_cap vht_capa_mask; /* Valid parts of vht_capa */
52381dd2b88SArik Nemtsov 
5241277b4a9SLiad Kaufman 	/* TDLS support */
52581dd2b88SArik Nemtsov 	u8 tdls_peer[ETH_ALEN] __aligned(2);
52681dd2b88SArik Nemtsov 	struct delayed_work tdls_peer_del_work;
5271277b4a9SLiad Kaufman 	struct sk_buff *orig_teardown_skb; /* The original teardown skb */
5281277b4a9SLiad Kaufman 	struct sk_buff *teardown_skb; /* A copy to send through the AP */
5291277b4a9SLiad Kaufman 	spinlock_t teardown_lock; /* To lock changing teardown_skb */
5309041c1faSArik Nemtsov 	bool tdls_chan_switch_prohibited;
53182c0cc90SArik Nemtsov 	bool tdls_wider_bw_prohibited;
53202219b3aSJohannes Berg 
53302219b3aSJohannes Berg 	/* WMM-AC TSPEC support */
53402219b3aSJohannes Berg 	struct ieee80211_sta_tx_tspec tx_tspec[IEEE80211_NUM_ACS];
53502219b3aSJohannes Berg 	/* Use a separate work struct so that we can do something here
53602219b3aSJohannes Berg 	 * while the sdata->work is flushing the queues, for example.
53702219b3aSJohannes Berg 	 * otherwise, in scenarios where we hardly get any traffic out
53802219b3aSJohannes Berg 	 * on the BE queue, but there's a lot of VO traffic, we might
53902219b3aSJohannes Berg 	 * get stuck in a downgraded situation and flush takes forever.
54002219b3aSJohannes Berg 	 */
54102219b3aSJohannes Berg 	struct delayed_work tx_tspec_wk;
542f0706e82SJiri Benc };
543f0706e82SJiri Benc 
54446900298SJohannes Berg struct ieee80211_if_ibss {
54546900298SJohannes Berg 	struct timer_list timer;
546cd7760e6SSimon Wunderlich 	struct work_struct csa_connection_drop_work;
54746900298SJohannes Berg 
548af8cdcd8SJohannes Berg 	unsigned long last_scan_completed;
5495bb644a0SJohannes Berg 
550fbd2c8dcSTeemu Paasikivi 	u32 basic_rates;
551fbd2c8dcSTeemu Paasikivi 
552af8cdcd8SJohannes Berg 	bool fixed_bssid;
553af8cdcd8SJohannes Berg 	bool fixed_channel;
554fffd0934SJohannes Berg 	bool privacy;
55546900298SJohannes Berg 
556267335d6SAntonio Quartulli 	bool control_port;
5578e8d347dSSimon Wunderlich 	bool userspace_handles_dfs;
558267335d6SAntonio Quartulli 
5594d196e4bSFelix Fietkau 	u8 bssid[ETH_ALEN] __aligned(2);
560af8cdcd8SJohannes Berg 	u8 ssid[IEEE80211_MAX_SSID_LEN];
561af8cdcd8SJohannes Berg 	u8 ssid_len, ie_len;
562af8cdcd8SJohannes Berg 	u8 *ie;
5633aede78aSSimon Wunderlich 	struct cfg80211_chan_def chandef;
56446900298SJohannes Berg 
56546900298SJohannes Berg 	unsigned long ibss_join_req;
566af8cdcd8SJohannes Berg 	/* probe response/beacon for IBSS */
567c3ffeab4SJohannes Berg 	struct beacon_data __rcu *presp;
56846900298SJohannes Berg 
569822854b0SSimon Wunderlich 	struct ieee80211_ht_cap ht_capa; /* configured ht-cap over-rides */
570822854b0SSimon Wunderlich 	struct ieee80211_ht_cap ht_capa_mask; /* Valid parts of ht_capa */
571822854b0SSimon Wunderlich 
5728bf11d8dSJohannes Berg 	spinlock_t incomplete_lock;
5738bf11d8dSJohannes Berg 	struct list_head incomplete_stations;
5748bf11d8dSJohannes Berg 
57546900298SJohannes Berg 	enum {
57646900298SJohannes Berg 		IEEE80211_IBSS_MLME_SEARCH,
57746900298SJohannes Berg 		IEEE80211_IBSS_MLME_JOINED,
57846900298SJohannes Berg 	} state;
57946900298SJohannes Berg };
58046900298SJohannes Berg 
581dbf498fbSJavier Cardona /**
582239281f8SRostislav Lisovy  * struct ieee80211_if_ocb - OCB mode state
583239281f8SRostislav Lisovy  *
584239281f8SRostislav Lisovy  * @housekeeping_timer: timer for periodic invocation of a housekeeping task
585239281f8SRostislav Lisovy  * @wrkq_flags: OCB deferred task action
586239281f8SRostislav Lisovy  * @incomplete_lock: delayed STA insertion lock
587239281f8SRostislav Lisovy  * @incomplete_stations: list of STAs waiting for delayed insertion
588239281f8SRostislav Lisovy  * @joined: indication if the interface is connected to an OCB network
589239281f8SRostislav Lisovy  */
590239281f8SRostislav Lisovy struct ieee80211_if_ocb {
591239281f8SRostislav Lisovy 	struct timer_list housekeeping_timer;
592239281f8SRostislav Lisovy 	unsigned long wrkq_flags;
593239281f8SRostislav Lisovy 
594239281f8SRostislav Lisovy 	spinlock_t incomplete_lock;
595239281f8SRostislav Lisovy 	struct list_head incomplete_stations;
596239281f8SRostislav Lisovy 
597239281f8SRostislav Lisovy 	bool joined;
598239281f8SRostislav Lisovy };
599239281f8SRostislav Lisovy 
600239281f8SRostislav Lisovy /**
601dbf498fbSJavier Cardona  * struct ieee80211_mesh_sync_ops - Extensible synchronization framework interface
602dbf498fbSJavier Cardona  *
603dbf498fbSJavier Cardona  * these declarations define the interface, which enables
604dbf498fbSJavier Cardona  * vendor-specific mesh synchronization
605dbf498fbSJavier Cardona  *
606dbf498fbSJavier Cardona  */
607dbf498fbSJavier Cardona struct ieee802_11_elems;
608dbf498fbSJavier Cardona struct ieee80211_mesh_sync_ops {
609dbf498fbSJavier Cardona 	void (*rx_bcn_presp)(struct ieee80211_sub_if_data *sdata,
610dbf498fbSJavier Cardona 			     u16 stype,
611dbf498fbSJavier Cardona 			     struct ieee80211_mgmt *mgmt,
612dbf498fbSJavier Cardona 			     struct ieee802_11_elems *elems,
613dbf498fbSJavier Cardona 			     struct ieee80211_rx_status *rx_status);
61443552be1SThomas Pedersen 
61543552be1SThomas Pedersen 	/* should be called with beacon_data under RCU read lock */
61643552be1SThomas Pedersen 	void (*adjust_tbtt)(struct ieee80211_sub_if_data *sdata,
61743552be1SThomas Pedersen 			    struct beacon_data *beacon);
618dbf498fbSJavier Cardona 	/* add other framework functions here */
619dbf498fbSJavier Cardona };
620dbf498fbSJavier Cardona 
621b8456a14SChun-Yeow Yeoh struct mesh_csa_settings {
622b8456a14SChun-Yeow Yeoh 	struct rcu_head rcu_head;
623b8456a14SChun-Yeow Yeoh 	struct cfg80211_csa_settings settings;
624b8456a14SChun-Yeow Yeoh };
625b8456a14SChun-Yeow Yeoh 
626472dbc45SJohannes Berg struct ieee80211_if_mesh {
627472dbc45SJohannes Berg 	struct timer_list housekeeping_timer;
628472dbc45SJohannes Berg 	struct timer_list mesh_path_timer;
629e304bfd3SRui Paulo 	struct timer_list mesh_path_root_timer;
630472dbc45SJohannes Berg 
63118889231SJavier Cardona 	unsigned long wrkq_flags;
632f81a9dedSThomas Pedersen 	unsigned long mbss_changed;
633472dbc45SJohannes Berg 
634472dbc45SJohannes Berg 	u8 mesh_id[IEEE80211_MAX_MESH_ID_LEN];
635472dbc45SJohannes Berg 	size_t mesh_id_len;
636472dbc45SJohannes Berg 	/* Active Path Selection Protocol Identifier */
6373491707aSRui Paulo 	u8 mesh_pp_id;
638472dbc45SJohannes Berg 	/* Active Path Selection Metric Identifier */
6393491707aSRui Paulo 	u8 mesh_pm_id;
640472dbc45SJohannes Berg 	/* Congestion Control Mode Identifier */
6413491707aSRui Paulo 	u8 mesh_cc_id;
6429e03fdfdSJavier Cardona 	/* Synchronization Protocol Identifier */
6433491707aSRui Paulo 	u8 mesh_sp_id;
6449e03fdfdSJavier Cardona 	/* Authentication Protocol Identifier */
6453491707aSRui Paulo 	u8 mesh_auth_id;
646d19b3bf6SRui Paulo 	/* Local mesh Sequence Number */
647d19b3bf6SRui Paulo 	u32 sn;
648472dbc45SJohannes Berg 	/* Last used PREQ ID */
649472dbc45SJohannes Berg 	u32 preq_id;
650472dbc45SJohannes Berg 	atomic_t mpaths;
651d19b3bf6SRui Paulo 	/* Timestamp of last SN update */
652d19b3bf6SRui Paulo 	unsigned long last_sn_update;
653dca7e943SThomas Pedersen 	/* Time when it's ok to send next PERR */
654dca7e943SThomas Pedersen 	unsigned long next_perr;
655dca7e943SThomas Pedersen 	/* Timestamp of last PREQ sent */
656472dbc45SJohannes Berg 	unsigned long last_preq;
657472dbc45SJohannes Berg 	struct mesh_rmc *rmc;
658472dbc45SJohannes Berg 	spinlock_t mesh_preq_queue_lock;
659472dbc45SJohannes Berg 	struct mesh_preq_queue preq_queue;
660472dbc45SJohannes Berg 	int preq_queue_len;
661472dbc45SJohannes Berg 	struct mesh_stats mshstats;
662472dbc45SJohannes Berg 	struct mesh_config mshcfg;
6631258d976SAshok Nagarajan 	atomic_t estab_plinks;
664472dbc45SJohannes Berg 	u32 mesh_seqnum;
665472dbc45SJohannes Berg 	bool accepting_plinks;
6665ee68e5bSJavier Cardona 	int num_gates;
6672b5e1967SThomas Pedersen 	struct beacon_data __rcu *beacon;
668581a8b0fSJavier Cardona 	const u8 *ie;
669581a8b0fSJavier Cardona 	u8 ie_len;
670b130e5ceSJavier Cardona 	enum {
671b130e5ceSJavier Cardona 		IEEE80211_MESH_SEC_NONE = 0x0,
672b130e5ceSJavier Cardona 		IEEE80211_MESH_SEC_AUTHED = 0x1,
673b130e5ceSJavier Cardona 		IEEE80211_MESH_SEC_SECURED = 0x2,
674b130e5ceSJavier Cardona 	} security;
675a6dad6a2SThomas Pedersen 	bool user_mpm;
676dbf498fbSJavier Cardona 	/* Extensible Synchronization Framework */
6778ba7acf3SJohannes Berg 	const struct ieee80211_mesh_sync_ops *sync_ops;
678dbf498fbSJavier Cardona 	s64 sync_offset_clockdrift_max;
679dbf498fbSJavier Cardona 	spinlock_t sync_offset_lock;
680dbf498fbSJavier Cardona 	bool adjusting_tbtt;
6813f52b7e3SMarco Porsch 	/* mesh power save */
6823f52b7e3SMarco Porsch 	enum nl80211_mesh_power_mode nonpeer_pm;
6833f52b7e3SMarco Porsch 	int ps_peers_light_sleep;
6843f52b7e3SMarco Porsch 	int ps_peers_deep_sleep;
6853f52b7e3SMarco Porsch 	struct ps_data ps;
6868f2535b9SChun-Yeow Yeoh 	/* Channel Switching Support */
687b8456a14SChun-Yeow Yeoh 	struct mesh_csa_settings __rcu *csa;
6880cb4d4dcSLuciano Coelho 	enum {
6890cb4d4dcSLuciano Coelho 		IEEE80211_MESH_CSA_ROLE_NONE,
6900cb4d4dcSLuciano Coelho 		IEEE80211_MESH_CSA_ROLE_INIT,
6910cb4d4dcSLuciano Coelho 		IEEE80211_MESH_CSA_ROLE_REPEATER,
6920cb4d4dcSLuciano Coelho 	} csa_role;
693b8456a14SChun-Yeow Yeoh 	u8 chsw_ttl;
6948f2535b9SChun-Yeow Yeoh 	u16 pre_value;
69543552be1SThomas Pedersen 
69643552be1SThomas Pedersen 	/* offset from skb->data while building IE */
69743552be1SThomas Pedersen 	int meshconf_offset;
698472dbc45SJohannes Berg };
699902acc78SJohannes Berg 
700902acc78SJohannes Berg #ifdef CONFIG_MAC80211_MESH
701472dbc45SJohannes Berg #define IEEE80211_IFSTA_MESH_CTR_INC(msh, name)	\
702472dbc45SJohannes Berg 	do { (msh)->mshstats.name++; } while (0)
703902acc78SJohannes Berg #else
704472dbc45SJohannes Berg #define IEEE80211_IFSTA_MESH_CTR_INC(msh, name) \
705902acc78SJohannes Berg 	do { } while (0)
706902acc78SJohannes Berg #endif
707f0706e82SJiri Benc 
708213cd118SJohannes Berg /**
709213cd118SJohannes Berg  * enum ieee80211_sub_if_data_flags - virtual interface flags
710213cd118SJohannes Berg  *
711213cd118SJohannes Berg  * @IEEE80211_SDATA_ALLMULTI: interface wants all multicast packets
712213cd118SJohannes Berg  * @IEEE80211_SDATA_OPERATING_GMODE: operating in G-only mode
713213cd118SJohannes Berg  * @IEEE80211_SDATA_DONT_BRIDGE_PACKETS: bridge packets between
714213cd118SJohannes Berg  *	associated stations and deliver multicast frames both
715213cd118SJohannes Berg  *	back to wireless media and to the local net stack.
71695acac61SJohannes Berg  * @IEEE80211_SDATA_DISCONNECT_RESUME: Disconnect after resume.
7177b7eab6fSJohannes Berg  * @IEEE80211_SDATA_IN_DRIVER: indicates interface was added to driver
718322cd406SSara Sharon  * @IEEE80211_SDATA_MU_MIMO_OWNER: indicates interface owns MU-MIMO capability
719213cd118SJohannes Berg  */
720213cd118SJohannes Berg enum ieee80211_sub_if_data_flags {
721213cd118SJohannes Berg 	IEEE80211_SDATA_ALLMULTI		= BIT(0),
7227986cf95SJohannes Berg 	IEEE80211_SDATA_OPERATING_GMODE		= BIT(2),
7237986cf95SJohannes Berg 	IEEE80211_SDATA_DONT_BRIDGE_PACKETS	= BIT(3),
72495acac61SJohannes Berg 	IEEE80211_SDATA_DISCONNECT_RESUME	= BIT(4),
7257b7eab6fSJohannes Berg 	IEEE80211_SDATA_IN_DRIVER		= BIT(5),
726322cd406SSara Sharon 	IEEE80211_SDATA_MU_MIMO_OWNER		= BIT(6),
727213cd118SJohannes Berg };
728213cd118SJohannes Berg 
72934d4bc4dSJohannes Berg /**
73034d4bc4dSJohannes Berg  * enum ieee80211_sdata_state_bits - virtual interface state bits
73134d4bc4dSJohannes Berg  * @SDATA_STATE_RUNNING: virtual interface is up & running; this
73234d4bc4dSJohannes Berg  *	mirrors netif_running() but is separate for interface type
73334d4bc4dSJohannes Berg  *	change handling while the interface is up
7345b714c6aSJohannes Berg  * @SDATA_STATE_OFFCHANNEL: This interface is currently in offchannel
7355b714c6aSJohannes Berg  *	mode, so queues are stopped
736d6a83228SJohannes Berg  * @SDATA_STATE_OFFCHANNEL_BEACON_STOPPED: Beaconing was stopped due
737d6a83228SJohannes Berg  *	to offchannel, reset when offchannel returns
73834d4bc4dSJohannes Berg  */
73934d4bc4dSJohannes Berg enum ieee80211_sdata_state_bits {
74034d4bc4dSJohannes Berg 	SDATA_STATE_RUNNING,
7415b714c6aSJohannes Berg 	SDATA_STATE_OFFCHANNEL,
742d6a83228SJohannes Berg 	SDATA_STATE_OFFCHANNEL_BEACON_STOPPED,
74334d4bc4dSJohannes Berg };
74434d4bc4dSJohannes Berg 
745d01a1e65SMichal Kazior /**
746d01a1e65SMichal Kazior  * enum ieee80211_chanctx_mode - channel context configuration mode
747d01a1e65SMichal Kazior  *
748d01a1e65SMichal Kazior  * @IEEE80211_CHANCTX_SHARED: channel context may be used by
749d01a1e65SMichal Kazior  *	multiple interfaces
750d01a1e65SMichal Kazior  * @IEEE80211_CHANCTX_EXCLUSIVE: channel context can be used
751d01a1e65SMichal Kazior  *	only by a single interface. This can be used for example for
752d01a1e65SMichal Kazior  *	non-fixed channel IBSS.
753d01a1e65SMichal Kazior  */
754d01a1e65SMichal Kazior enum ieee80211_chanctx_mode {
755d01a1e65SMichal Kazior 	IEEE80211_CHANCTX_SHARED,
756d01a1e65SMichal Kazior 	IEEE80211_CHANCTX_EXCLUSIVE
757d01a1e65SMichal Kazior };
758d01a1e65SMichal Kazior 
7595bcae31dSMichal Kazior /**
7605bcae31dSMichal Kazior  * enum ieee80211_chanctx_replace_state - channel context replacement state
7615bcae31dSMichal Kazior  *
7625bcae31dSMichal Kazior  * This is used for channel context in-place reservations that require channel
7635bcae31dSMichal Kazior  * context switch/swap.
7645bcae31dSMichal Kazior  *
7655bcae31dSMichal Kazior  * @IEEE80211_CHANCTX_REPLACE_NONE: no replacement is taking place
7665bcae31dSMichal Kazior  * @IEEE80211_CHANCTX_WILL_BE_REPLACED: this channel context will be replaced
7675bcae31dSMichal Kazior  *	by a (not yet registered) channel context pointed by %replace_ctx.
7685bcae31dSMichal Kazior  * @IEEE80211_CHANCTX_REPLACES_OTHER: this (not yet registered) channel context
7695bcae31dSMichal Kazior  *	replaces an existing channel context pointed to by %replace_ctx.
7705bcae31dSMichal Kazior  */
7715bcae31dSMichal Kazior enum ieee80211_chanctx_replace_state {
7725bcae31dSMichal Kazior 	IEEE80211_CHANCTX_REPLACE_NONE,
7735bcae31dSMichal Kazior 	IEEE80211_CHANCTX_WILL_BE_REPLACED,
7745bcae31dSMichal Kazior 	IEEE80211_CHANCTX_REPLACES_OTHER,
7755bcae31dSMichal Kazior };
7765bcae31dSMichal Kazior 
777d01a1e65SMichal Kazior struct ieee80211_chanctx {
778d01a1e65SMichal Kazior 	struct list_head list;
779d01a1e65SMichal Kazior 	struct rcu_head rcu_head;
780d01a1e65SMichal Kazior 
781484298adSMichal Kazior 	struct list_head assigned_vifs;
782e3afb920SMichal Kazior 	struct list_head reserved_vifs;
783484298adSMichal Kazior 
7845bcae31dSMichal Kazior 	enum ieee80211_chanctx_replace_state replace_state;
7855bcae31dSMichal Kazior 	struct ieee80211_chanctx *replace_ctx;
7865bcae31dSMichal Kazior 
787d01a1e65SMichal Kazior 	enum ieee80211_chanctx_mode mode;
7888a61af65SJohannes Berg 	bool driver_present;
789d01a1e65SMichal Kazior 
790d01a1e65SMichal Kazior 	struct ieee80211_chanctx_conf conf;
791d01a1e65SMichal Kazior };
792d01a1e65SMichal Kazior 
79332db6b54SKyeyoon Park struct mac80211_qos_map {
79432db6b54SKyeyoon Park 	struct cfg80211_qos_map qos_map;
79532db6b54SKyeyoon Park 	struct rcu_head rcu_head;
79632db6b54SKyeyoon Park };
79732db6b54SKyeyoon Park 
798ba8c3d6fSFelix Fietkau enum txq_info_flags {
799ba8c3d6fSFelix Fietkau 	IEEE80211_TXQ_STOP,
800ba8c3d6fSFelix Fietkau 	IEEE80211_TXQ_AMPDU,
801ba8c3d6fSFelix Fietkau };
802ba8c3d6fSFelix Fietkau 
803ba8c3d6fSFelix Fietkau struct txq_info {
804ba8c3d6fSFelix Fietkau 	struct sk_buff_head queue;
805ba8c3d6fSFelix Fietkau 	unsigned long flags;
806ba8c3d6fSFelix Fietkau 
807ba8c3d6fSFelix Fietkau 	/* keep last! */
808ba8c3d6fSFelix Fietkau 	struct ieee80211_txq txq;
809ba8c3d6fSFelix Fietkau };
810ba8c3d6fSFelix Fietkau 
811f0706e82SJiri Benc struct ieee80211_sub_if_data {
812f0706e82SJiri Benc 	struct list_head list;
813f0706e82SJiri Benc 
814f0706e82SJiri Benc 	struct wireless_dev wdev;
815f0706e82SJiri Benc 
81611a843b7SJohannes Berg 	/* keys */
81711a843b7SJohannes Berg 	struct list_head key_list;
81811a843b7SJohannes Berg 
8193bff1865SYogesh Ashok Powar 	/* count for keys needing tailroom space allocation */
8203bff1865SYogesh Ashok Powar 	int crypto_tx_tailroom_needed_cnt;
8218d1f7ecdSJohannes Berg 	int crypto_tx_tailroom_pending_dec;
8228d1f7ecdSJohannes Berg 	struct delayed_work dec_tailroom_needed_wk;
8233bff1865SYogesh Ashok Powar 
824f0706e82SJiri Benc 	struct net_device *dev;
825f0706e82SJiri Benc 	struct ieee80211_local *local;
826f0706e82SJiri Benc 
82713262ffdSJiri Slaby 	unsigned int flags;
8287e9ed188SDaniel Drake 
82934d4bc4dSJohannes Berg 	unsigned long state;
83034d4bc4dSJohannes Berg 
83147846c9bSJohannes Berg 	char name[IFNAMSIZ];
83247846c9bSJohannes Berg 
833f0706e82SJiri Benc 	/* Fragment table for host-based reassembly */
834f0706e82SJiri Benc 	struct ieee80211_fragment_entry	fragments[IEEE80211_FRAGMENT_MAX];
835f0706e82SJiri Benc 	unsigned int fragment_next;
836f0706e82SJiri Benc 
837b53be792SSimon Wunderlich 	/* TID bitmap for NoAck policy */
838b53be792SSimon Wunderlich 	u16 noack_map;
839b53be792SSimon Wunderlich 
84000e96decSYoni Divinsky 	/* bit field of ACM bits (BIT(802.1D tag)) */
84100e96decSYoni Divinsky 	u8 wmm_acm;
84200e96decSYoni Divinsky 
84340b275b6SJohannes Berg 	struct ieee80211_key __rcu *keys[NUM_DEFAULT_KEYS + NUM_DEFAULT_MGMT_KEYS];
84440b275b6SJohannes Berg 	struct ieee80211_key __rcu *default_unicast_key;
84540b275b6SJohannes Berg 	struct ieee80211_key __rcu *default_multicast_key;
84640b275b6SJohannes Berg 	struct ieee80211_key __rcu *default_mgmt_key;
847f0706e82SJiri Benc 
84894778280SJohannes Berg 	u16 sequence_number;
849a621fa4dSJohannes Berg 	__be16 control_port_protocol;
850a621fa4dSJohannes Berg 	bool control_port_no_encrypt;
8512475b1ccSMax Stepanov 	int encrypt_headroom;
85294778280SJohannes Berg 
853ba8c3d6fSFelix Fietkau 	atomic_t txqs_len[IEEE80211_NUM_ACS];
85454bcbc69SJohannes Berg 	struct ieee80211_tx_queue_params tx_conf[IEEE80211_NUM_ACS];
85532db6b54SKyeyoon Park 	struct mac80211_qos_map __rcu *qos_map;
856f6f3def3SEliad Peller 
85773da7d5bSSimon Wunderlich 	struct work_struct csa_finalize_work;
85859af6928SMichal Kazior 	bool csa_block_tx; /* write-protected by sdata_lock and local->mtx */
85933787fc4SLuciano Coelho 	struct cfg80211_chan_def csa_chandef;
86073da7d5bSSimon Wunderlich 
861484298adSMichal Kazior 	struct list_head assigned_chanctx_list; /* protected by chanctx_mtx */
862e3afb920SMichal Kazior 	struct list_head reserved_chanctx_list; /* protected by chanctx_mtx */
863484298adSMichal Kazior 
86411335a55SLuciano Coelho 	/* context reservation -- protected with chanctx_mtx */
86511335a55SLuciano Coelho 	struct ieee80211_chanctx *reserved_chanctx;
86611335a55SLuciano Coelho 	struct cfg80211_chan_def reserved_chandef;
86709332481SMichal Kazior 	bool reserved_radar_required;
8685bcae31dSMichal Kazior 	bool reserved_ready;
86911335a55SLuciano Coelho 
87004ecd257SJohannes Berg 	/* used to reconfigure hardware SM PS */
87104ecd257SJohannes Berg 	struct work_struct recalc_smps;
87204ecd257SJohannes Berg 
87364592c8fSJohannes Berg 	struct work_struct work;
87435f20c14SJohannes Berg 	struct sk_buff_head skb_queue;
87535f20c14SJohannes Berg 
87604ecd257SJohannes Berg 	u8 needed_rx_chains;
87704ecd257SJohannes Berg 	enum ieee80211_smps_mode smps_mode;
87804ecd257SJohannes Berg 
8791ea6f9c0SJohannes Berg 	int user_power_level; /* in dBm */
8801ea6f9c0SJohannes Berg 	int ap_power_level; /* in dBm */
8811ea6f9c0SJohannes Berg 
882164eb02dSSimon Wunderlich 	bool radar_required;
883164eb02dSSimon Wunderlich 	struct delayed_work dfs_cac_timer_work;
884164eb02dSSimon Wunderlich 
8853e122be0SJohannes Berg 	/*
8863e122be0SJohannes Berg 	 * AP this belongs to: self in AP mode and
8873e122be0SJohannes Berg 	 * corresponding AP in VLAN mode, NULL for
8883e122be0SJohannes Berg 	 * all others (might be needed later in IBSS)
8893e122be0SJohannes Berg 	 */
8903e122be0SJohannes Berg 	struct ieee80211_if_ap *bss;
8913e122be0SJohannes Berg 
89237eb0b16SJouni Malinen 	/* bitmap of allowed (non-MCS) rate indexes for rate control */
89337eb0b16SJouni Malinen 	u32 rc_rateidx_mask[IEEE80211_NUM_BANDS];
8942ffbe6d3SFelix Fietkau 
8952ffbe6d3SFelix Fietkau 	bool rc_has_mcs_mask[IEEE80211_NUM_BANDS];
89619468413SSimon Wunderlich 	u8  rc_rateidx_mcs_mask[IEEE80211_NUM_BANDS][IEEE80211_HT_MCS_MASK_LEN];
897f0706e82SJiri Benc 
898b119ad6eSLorenzo Bianconi 	bool rc_has_vht_mcs_mask[IEEE80211_NUM_BANDS];
899b119ad6eSLorenzo Bianconi 	u16 rc_rateidx_vht_mcs_mask[IEEE80211_NUM_BANDS][NL80211_VHT_NSS_MAX];
900b119ad6eSLorenzo Bianconi 
901f0706e82SJiri Benc 	union {
902f0706e82SJiri Benc 		struct ieee80211_if_ap ap;
903f0706e82SJiri Benc 		struct ieee80211_if_wds wds;
904f0706e82SJiri Benc 		struct ieee80211_if_vlan vlan;
90546900298SJohannes Berg 		struct ieee80211_if_managed mgd;
90646900298SJohannes Berg 		struct ieee80211_if_ibss ibss;
907472dbc45SJohannes Berg 		struct ieee80211_if_mesh mesh;
908239281f8SRostislav Lisovy 		struct ieee80211_if_ocb ocb;
9098cc9a739SMichael Wu 		u32 mntr_flags;
910f0706e82SJiri Benc 	} u;
911e9f207f0SJiri Benc 
912e9f207f0SJiri Benc #ifdef CONFIG_MAC80211_DEBUGFS
913e9f207f0SJiri Benc 	struct {
914295bafb4SBen Greear 		struct dentry *subdir_stations;
915f7e0104cSJohannes Berg 		struct dentry *default_unicast_key;
916f7e0104cSJohannes Berg 		struct dentry *default_multicast_key;
9173cfcf6acSJouni Malinen 		struct dentry *default_mgmt_key;
9187bcfaf2fSJohannes Berg 	} debugfs;
919e9f207f0SJiri Benc #endif
920529ba6e9SJohannes Berg 
92132bfd35dSJohannes Berg 	/* must be last, dynamically sized area in this! */
92232bfd35dSJohannes Berg 	struct ieee80211_vif vif;
923f0706e82SJiri Benc };
924f0706e82SJiri Benc 
92532bfd35dSJohannes Berg static inline
92632bfd35dSJohannes Berg struct ieee80211_sub_if_data *vif_to_sdata(struct ieee80211_vif *p)
92732bfd35dSJohannes Berg {
92832bfd35dSJohannes Berg 	return container_of(p, struct ieee80211_sub_if_data, vif);
92932bfd35dSJohannes Berg }
93032bfd35dSJohannes Berg 
9318d61ffa5SJohannes Berg static inline void sdata_lock(struct ieee80211_sub_if_data *sdata)
9328d61ffa5SJohannes Berg 	__acquires(&sdata->wdev.mtx)
9338d61ffa5SJohannes Berg {
9348d61ffa5SJohannes Berg 	mutex_lock(&sdata->wdev.mtx);
9358d61ffa5SJohannes Berg 	__acquire(&sdata->wdev.mtx);
9368d61ffa5SJohannes Berg }
9378d61ffa5SJohannes Berg 
9388d61ffa5SJohannes Berg static inline void sdata_unlock(struct ieee80211_sub_if_data *sdata)
9398d61ffa5SJohannes Berg 	__releases(&sdata->wdev.mtx)
9408d61ffa5SJohannes Berg {
9418d61ffa5SJohannes Berg 	mutex_unlock(&sdata->wdev.mtx);
9428d61ffa5SJohannes Berg 	__release(&sdata->wdev.mtx);
9438d61ffa5SJohannes Berg }
9448d61ffa5SJohannes Berg 
9457ca133bcSSimon Wunderlich #define sdata_dereference(p, sdata) \
9467ca133bcSSimon Wunderlich 	rcu_dereference_protected(p, lockdep_is_held(&sdata->wdev.mtx))
9477ca133bcSSimon Wunderlich 
9488d61ffa5SJohannes Berg static inline void
9498d61ffa5SJohannes Berg sdata_assert_lock(struct ieee80211_sub_if_data *sdata)
9508d61ffa5SJohannes Berg {
9518d61ffa5SJohannes Berg 	lockdep_assert_held(&sdata->wdev.mtx);
9528d61ffa5SJohannes Berg }
9538d61ffa5SJohannes Berg 
95455de908aSJohannes Berg static inline enum ieee80211_band
95555de908aSJohannes Berg ieee80211_get_sdata_band(struct ieee80211_sub_if_data *sdata)
95655de908aSJohannes Berg {
95755de908aSJohannes Berg 	enum ieee80211_band band = IEEE80211_BAND_2GHZ;
95855de908aSJohannes Berg 	struct ieee80211_chanctx_conf *chanctx_conf;
95955de908aSJohannes Berg 
96055de908aSJohannes Berg 	rcu_read_lock();
96155de908aSJohannes Berg 	chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
96255de908aSJohannes Berg 	if (!WARN_ON(!chanctx_conf))
9634bf88530SJohannes Berg 		band = chanctx_conf->def.chan->band;
96455de908aSJohannes Berg 	rcu_read_unlock();
96555de908aSJohannes Berg 
96655de908aSJohannes Berg 	return band;
96755de908aSJohannes Berg }
96855de908aSJohannes Berg 
969438b61b7SSimon Wunderlich static inline int
970438b61b7SSimon Wunderlich ieee80211_chandef_get_shift(struct cfg80211_chan_def *chandef)
971438b61b7SSimon Wunderlich {
972438b61b7SSimon Wunderlich 	switch (chandef->width) {
973438b61b7SSimon Wunderlich 	case NL80211_CHAN_WIDTH_5:
974438b61b7SSimon Wunderlich 		return 2;
975438b61b7SSimon Wunderlich 	case NL80211_CHAN_WIDTH_10:
976438b61b7SSimon Wunderlich 		return 1;
977438b61b7SSimon Wunderlich 	default:
978438b61b7SSimon Wunderlich 		return 0;
979438b61b7SSimon Wunderlich 	}
980438b61b7SSimon Wunderlich }
981438b61b7SSimon Wunderlich 
982438b61b7SSimon Wunderlich static inline int
983438b61b7SSimon Wunderlich ieee80211_vif_get_shift(struct ieee80211_vif *vif)
984438b61b7SSimon Wunderlich {
985438b61b7SSimon Wunderlich 	struct ieee80211_chanctx_conf *chanctx_conf;
986438b61b7SSimon Wunderlich 	int shift = 0;
987438b61b7SSimon Wunderlich 
988438b61b7SSimon Wunderlich 	rcu_read_lock();
989438b61b7SSimon Wunderlich 	chanctx_conf = rcu_dereference(vif->chanctx_conf);
990438b61b7SSimon Wunderlich 	if (chanctx_conf)
991438b61b7SSimon Wunderlich 		shift = ieee80211_chandef_get_shift(&chanctx_conf->def);
992438b61b7SSimon Wunderlich 	rcu_read_unlock();
993438b61b7SSimon Wunderlich 
994438b61b7SSimon Wunderlich 	return shift;
995438b61b7SSimon Wunderlich }
996438b61b7SSimon Wunderlich 
99708cf42e8SMichal Kazior struct ieee80211_rx_agg {
99808cf42e8SMichal Kazior 	u8 addr[ETH_ALEN];
99908cf42e8SMichal Kazior 	u16 tid;
100008cf42e8SMichal Kazior };
100108cf42e8SMichal Kazior 
1002c1475ca9SJohannes Berg enum sdata_queue_type {
1003c1475ca9SJohannes Berg 	IEEE80211_SDATA_QUEUE_TYPE_FRAME	= 0,
1004c1475ca9SJohannes Berg 	IEEE80211_SDATA_QUEUE_AGG_START		= 1,
1005c1475ca9SJohannes Berg 	IEEE80211_SDATA_QUEUE_AGG_STOP		= 2,
100608cf42e8SMichal Kazior 	IEEE80211_SDATA_QUEUE_RX_AGG_START	= 3,
100708cf42e8SMichal Kazior 	IEEE80211_SDATA_QUEUE_RX_AGG_STOP	= 4,
1008c1475ca9SJohannes Berg };
1009c1475ca9SJohannes Berg 
1010f0706e82SJiri Benc enum {
1011f0706e82SJiri Benc 	IEEE80211_RX_MSG	= 1,
1012f0706e82SJiri Benc 	IEEE80211_TX_STATUS_MSG	= 2,
1013f0706e82SJiri Benc };
1014f0706e82SJiri Benc 
1015ce7c9111SKalle Valo enum queue_stop_reason {
1016ce7c9111SKalle Valo 	IEEE80211_QUEUE_STOP_REASON_DRIVER,
1017520eb820SKalle Valo 	IEEE80211_QUEUE_STOP_REASON_PS,
101896f5e66eSJohannes Berg 	IEEE80211_QUEUE_STOP_REASON_CSA,
101996f5e66eSJohannes Berg 	IEEE80211_QUEUE_STOP_REASON_AGGREGATION,
102025420604SJohannes Berg 	IEEE80211_QUEUE_STOP_REASON_SUSPEND,
10218f77f384SJohannes Berg 	IEEE80211_QUEUE_STOP_REASON_SKB_ADD,
10226c17b77bSSeth Forshee 	IEEE80211_QUEUE_STOP_REASON_OFFCHANNEL,
1023445ea4e8SJohannes Berg 	IEEE80211_QUEUE_STOP_REASON_FLUSH,
1024db67d661SArik Nemtsov 	IEEE80211_QUEUE_STOP_REASON_TDLS_TEARDOWN,
1025b6da911bSLiad Kaufman 	IEEE80211_QUEUE_STOP_REASON_RESERVE_TID,
1026cca07b00SLuciano Coelho 
1027cca07b00SLuciano Coelho 	IEEE80211_QUEUE_STOP_REASONS,
1028ce7c9111SKalle Valo };
1029ce7c9111SKalle Valo 
103065a6538aSLuciano Coelho #ifdef CONFIG_MAC80211_LEDS
1031e1e54068SJohannes Berg struct tpt_led_trigger {
1032e1e54068SJohannes Berg 	char name[32];
1033e1e54068SJohannes Berg 	const struct ieee80211_tpt_blink *blink_table;
1034e1e54068SJohannes Berg 	unsigned int blink_table_len;
1035e1e54068SJohannes Berg 	struct timer_list timer;
1036e1e54068SJohannes Berg 	unsigned long prev_traffic;
1037e1e54068SJohannes Berg 	unsigned long tx_bytes, rx_bytes;
103867408c8cSJohannes Berg 	unsigned int active, want;
103967408c8cSJohannes Berg 	bool running;
1040e1e54068SJohannes Berg };
104165a6538aSLuciano Coelho #endif
1042e1e54068SJohannes Berg 
1043142b9f50SHelmut Schaa /**
1044142b9f50SHelmut Schaa  * mac80211 scan flags - currently active scan mode
1045142b9f50SHelmut Schaa  *
1046142b9f50SHelmut Schaa  * @SCAN_SW_SCANNING: We're currently in the process of scanning but may as
1047142b9f50SHelmut Schaa  *	well be on the operating channel
1048142b9f50SHelmut Schaa  * @SCAN_HW_SCANNING: The hardware is scanning for us, we have no way to
1049142b9f50SHelmut Schaa  *	determine if we are on the operating channel or not
10508a690674SBen Greear  * @SCAN_ONCHANNEL_SCANNING:  Do a software scan on only the current operating
10518a690674SBen Greear  *	channel. This should not interrupt normal traffic.
10528789d459SJohannes Berg  * @SCAN_COMPLETED: Set for our scan work function when the driver reported
10538789d459SJohannes Berg  *	that the scan completed.
10548789d459SJohannes Berg  * @SCAN_ABORTED: Set for our scan work function when the driver reported
10558789d459SJohannes Berg  *	a scan complete for an aborted scan.
1056a754055aSEmmanuel Grumbach  * @SCAN_HW_CANCELLED: Set for our scan work function when the scan is being
1057a754055aSEmmanuel Grumbach  *	cancelled.
1058142b9f50SHelmut Schaa  */
1059fbe9c429SHelmut Schaa enum {
1060fbe9c429SHelmut Schaa 	SCAN_SW_SCANNING,
1061142b9f50SHelmut Schaa 	SCAN_HW_SCANNING,
10628a690674SBen Greear 	SCAN_ONCHANNEL_SCANNING,
10638789d459SJohannes Berg 	SCAN_COMPLETED,
10648789d459SJohannes Berg 	SCAN_ABORTED,
1065a754055aSEmmanuel Grumbach 	SCAN_HW_CANCELLED,
1066142b9f50SHelmut Schaa };
1067142b9f50SHelmut Schaa 
1068142b9f50SHelmut Schaa /**
1069142b9f50SHelmut Schaa  * enum mac80211_scan_state - scan state machine states
1070142b9f50SHelmut Schaa  *
1071142b9f50SHelmut Schaa  * @SCAN_DECISION: Main entry point to the scan state machine, this state
1072142b9f50SHelmut Schaa  *	determines if we should keep on scanning or switch back to the
1073142b9f50SHelmut Schaa  *	operating channel
1074142b9f50SHelmut Schaa  * @SCAN_SET_CHANNEL: Set the next channel to be scanned
1075142b9f50SHelmut Schaa  * @SCAN_SEND_PROBE: Send probe requests and wait for probe responses
107607ef03eeSJohannes Berg  * @SCAN_SUSPEND: Suspend the scan and go back to operating channel to
107707ef03eeSJohannes Berg  *	send out data
107807ef03eeSJohannes Berg  * @SCAN_RESUME: Resume the scan and scan the next channel
1079cd2bb512SSam Leffler  * @SCAN_ABORT: Abort the scan and go back to operating channel
1080142b9f50SHelmut Schaa  */
1081142b9f50SHelmut Schaa enum mac80211_scan_state {
1082142b9f50SHelmut Schaa 	SCAN_DECISION,
1083142b9f50SHelmut Schaa 	SCAN_SET_CHANNEL,
1084142b9f50SHelmut Schaa 	SCAN_SEND_PROBE,
108507ef03eeSJohannes Berg 	SCAN_SUSPEND,
108607ef03eeSJohannes Berg 	SCAN_RESUME,
1087cd2bb512SSam Leffler 	SCAN_ABORT,
1088fbe9c429SHelmut Schaa };
1089fbe9c429SHelmut Schaa 
1090f0706e82SJiri Benc struct ieee80211_local {
1091f0706e82SJiri Benc 	/* embed the driver visible part.
1092f0706e82SJiri Benc 	 * don't cast (use the static inlines below), but we keep
1093f0706e82SJiri Benc 	 * it first anyway so they become a no-op */
1094f0706e82SJiri Benc 	struct ieee80211_hw hw;
1095f0706e82SJiri Benc 
1096f0706e82SJiri Benc 	const struct ieee80211_ops *ops;
1097f0706e82SJiri Benc 
109842935ecaSLuis R. Rodriguez 	/*
109942935ecaSLuis R. Rodriguez 	 * private workqueue to mac80211. mac80211 makes this accessible
110042935ecaSLuis R. Rodriguez 	 * via ieee80211_queue_work()
110142935ecaSLuis R. Rodriguez 	 */
110242935ecaSLuis R. Rodriguez 	struct workqueue_struct *workqueue;
110342935ecaSLuis R. Rodriguez 
1104e4e72fb4SJohannes Berg 	unsigned long queue_stop_reasons[IEEE80211_MAX_QUEUES];
1105cca07b00SLuciano Coelho 	int q_stop_reasons[IEEE80211_MAX_QUEUES][IEEE80211_QUEUE_STOP_REASONS];
110696f5e66eSJohannes Berg 	/* also used to protect ampdu_ac_queue and amdpu_ac_stop_refcnt */
1107ce7c9111SKalle Valo 	spinlock_t queue_stop_reason_lock;
110896f5e66eSJohannes Berg 
1109f0706e82SJiri Benc 	int open_count;
11103d30d949SMichael Wu 	int monitors, cooked_mntrs;
11118cc9a739SMichael Wu 	/* number of interfaces with corresponding FIF_ flags */
11127be5086dSJohannes Berg 	int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss, fif_pspoll,
11137be5086dSJohannes Berg 	    fif_probe_req;
11147be5086dSJohannes Berg 	int probe_req_reg;
11154150c572SJohannes Berg 	unsigned int filter_flags; /* FIF_* */
11163b8d81e0SJohannes Berg 
11173ffc2a90SJohannes Berg 	bool wiphy_ciphers_allocated;
11183ffc2a90SJohannes Berg 
1119fe57d9f5SJohannes Berg 	bool use_chanctx;
1120fe57d9f5SJohannes Berg 
11213b8d81e0SJohannes Berg 	/* protects the aggregated multicast list and filter calls */
11223b8d81e0SJohannes Berg 	spinlock_t filter_lock;
11233b8d81e0SJohannes Berg 
11243ac64beeSJohannes Berg 	/* used for uploading changed mc list */
11253ac64beeSJohannes Berg 	struct work_struct reconfig_filter;
11263ac64beeSJohannes Berg 
11273b8d81e0SJohannes Berg 	/* aggregated multicast list */
112822bedad3SJiri Pirko 	struct netdev_hw_addr_list mc_list;
11293b8d81e0SJohannes Berg 
1130d0709a65SJohannes Berg 	bool tim_in_locked_section; /* see ieee80211_beacon_get() */
11315bb644a0SJohannes Berg 
11325bb644a0SJohannes Berg 	/*
11335bb644a0SJohannes Berg 	 * suspended is true if we finished all the suspend _and_ we have
11345bb644a0SJohannes Berg 	 * not yet come up from resume. This is to be used by mac80211
11355bb644a0SJohannes Berg 	 * to ensure driver sanity during suspend and mac80211's own
11365bb644a0SJohannes Berg 	 * sanity. It can eventually be used for WoW as well.
11375bb644a0SJohannes Berg 	 */
11385bb644a0SJohannes Berg 	bool suspended;
11395bb644a0SJohannes Berg 
11405bb644a0SJohannes Berg 	/*
1141ceb99fe0SJohannes Berg 	 * Resuming is true while suspended, but when we're reprogramming the
1142ceb99fe0SJohannes Berg 	 * hardware -- at that time it's allowed to use ieee80211_queue_work()
1143ceb99fe0SJohannes Berg 	 * again even though some other parts of the stack are still suspended
1144ceb99fe0SJohannes Berg 	 * and we still drop received frames to avoid waking the stack.
1145ceb99fe0SJohannes Berg 	 */
1146ceb99fe0SJohannes Berg 	bool resuming;
1147ceb99fe0SJohannes Berg 
1148ceb99fe0SJohannes Berg 	/*
11495bb644a0SJohannes Berg 	 * quiescing is true during the suspend process _only_ to
11505bb644a0SJohannes Berg 	 * ease timer cancelling etc.
11515bb644a0SJohannes Berg 	 */
11525bb644a0SJohannes Berg 	bool quiescing;
11535bb644a0SJohannes Berg 
1154ea77f12fSJohannes Berg 	/* device is started */
1155ea77f12fSJohannes Berg 	bool started;
1156ea77f12fSJohannes Berg 
115704800adaSArik Nemtsov 	/* device is during a HW reconfig */
115804800adaSArik Nemtsov 	bool in_reconfig;
115904800adaSArik Nemtsov 
1160eecc4800SJohannes Berg 	/* wowlan is enabled -- don't reconfig on resume */
1161eecc4800SJohannes Berg 	bool wowlan;
1162eecc4800SJohannes Berg 
1163164eb02dSSimon Wunderlich 	struct work_struct radar_detected_work;
1164164eb02dSSimon Wunderlich 
116504ecd257SJohannes Berg 	/* number of RX chains the hardware has */
116604ecd257SJohannes Berg 	u8 rx_chains;
116704ecd257SJohannes Berg 
1168b306f453SJohannes Berg 	int tx_headroom; /* required headroom for hardware/radiotap */
1169f0706e82SJiri Benc 
1170f0706e82SJiri Benc 	/* Tasklet and skb queue to process calls from IRQ mode. All frames
1171f0706e82SJiri Benc 	 * added to skb_queue will be processed, but frames in
1172f0706e82SJiri Benc 	 * skb_queue_unreliable may be dropped if the total length of these
1173f0706e82SJiri Benc 	 * queues increases over the limit. */
1174f0706e82SJiri Benc #define IEEE80211_IRQSAFE_QUEUE_LIMIT 128
1175f0706e82SJiri Benc 	struct tasklet_struct tasklet;
1176f0706e82SJiri Benc 	struct sk_buff_head skb_queue;
1177f0706e82SJiri Benc 	struct sk_buff_head skb_queue_unreliable;
1178f0706e82SJiri Benc 
1179f9e124fbSChristian Lamparter 	spinlock_t rx_path_lock;
118024a8fdadSChristian Lamparter 
1181d0709a65SJohannes Berg 	/* Station data */
1182d0709a65SJohannes Berg 	/*
11834d33960bSJohannes Berg 	 * The mutex only protects the list, hash table and
11844d33960bSJohannes Berg 	 * counter, reads are done with RCU.
1185d0709a65SJohannes Berg 	 */
118634e89507SJohannes Berg 	struct mutex sta_mtx;
11874d33960bSJohannes Berg 	spinlock_t tim_lock;
1188d0709a65SJohannes Berg 	unsigned long num_sta;
11894d33960bSJohannes Berg 	struct list_head sta_list;
11907bedd0cfSJohannes Berg 	struct rhashtable sta_hash;
1191f0706e82SJiri Benc 	struct timer_list sta_cleanup;
1192f5ea9120SJohannes Berg 	int sta_generation;
1193f0706e82SJiri Benc 
11942a577d98SJohannes Berg 	struct sk_buff_head pending[IEEE80211_MAX_QUEUES];
1195f0706e82SJiri Benc 	struct tasklet_struct tx_pending_tasklet;
1196f0706e82SJiri Benc 
1197a6a67db2SJohannes Berg 	atomic_t agg_queue_stop[IEEE80211_MAX_QUEUES];
1198cd8ffc80SJohannes Berg 
1199df140465SJohannes Berg 	/* number of interfaces with allmulti RX */
1200df140465SJohannes Berg 	atomic_t iff_allmultis;
1201f0706e82SJiri Benc 
1202f0706e82SJiri Benc 	struct rate_control_ref *rate_ctrl;
1203f0706e82SJiri Benc 
12045f9f1812SFelix Fietkau 	struct crypto_cipher *wep_tx_tfm;
12055f9f1812SFelix Fietkau 	struct crypto_cipher *wep_rx_tfm;
1206f0706e82SJiri Benc 	u32 wep_iv;
1207f0706e82SJiri Benc 
1208c771c9d8SJohannes Berg 	/* see iface.c */
120979010420SJohannes Berg 	struct list_head interfaces;
1210c771c9d8SJohannes Berg 	struct mutex iflist_mtx;
121179010420SJohannes Berg 
1212b16bd15cSJohannes Berg 	/*
1213ad0e2b5aSJohannes Berg 	 * Key mutex, protects sdata's key_list and sta_info's
1214b16bd15cSJohannes Berg 	 * key pointers (write access, they're RCU.)
1215b16bd15cSJohannes Berg 	 */
1216ad0e2b5aSJohannes Berg 	struct mutex key_mtx;
1217b16bd15cSJohannes Berg 
1218a1699b75SJohannes Berg 	/* mutex for scan and work locking */
1219a1699b75SJohannes Berg 	struct mutex mtx;
1220b16bd15cSJohannes Berg 
1221c2b13452SJohannes Berg 	/* Scanning and BSS list */
1222fbe9c429SHelmut Schaa 	unsigned long scanning;
12232a519311SJohannes Berg 	struct cfg80211_ssid scan_ssid;
12245ba63533SJohannes Berg 	struct cfg80211_scan_request *int_scan_req;
12256ea0a69cSJohannes Berg 	struct cfg80211_scan_request __rcu *scan_req;
1226c56ef672SDavid Spinadel 	struct ieee80211_scan_request *hw_scan_req;
12277ca15a0aSSimon Wunderlich 	struct cfg80211_chan_def scan_chandef;
12284d36ec58SJohannes Berg 	enum ieee80211_band hw_scan_band;
1229f0706e82SJiri Benc 	int scan_channel_idx;
1230de95a54bSJohannes Berg 	int scan_ies_len;
1231c604b9f2SJohannes Berg 	int hw_scan_ies_bufsize;
12328318d78aSJohannes Berg 
123385a9994aSLuciano Coelho 	struct work_struct sched_scan_stopped_work;
12345260a5b2SJohannes Berg 	struct ieee80211_sub_if_data __rcu *sched_scan_sdata;
12356ea0a69cSJohannes Berg 	struct cfg80211_sched_scan_request __rcu *sched_scan_req;
1236a344d677SJohannes Berg 	u8 scan_addr[ETH_ALEN];
123779f460caSLuciano Coelho 
1238df13cce5SHelmut Schaa 	unsigned long leave_oper_channel_time;
1239977923b0SHelmut Schaa 	enum mac80211_scan_state next_scan_state;
1240f0706e82SJiri Benc 	struct delayed_work scan_work;
1241e2fd5dbcSJohannes Berg 	struct ieee80211_sub_if_data __rcu *scan_sdata;
124255de908aSJohannes Berg 	/* For backward compatibility only -- do not use */
1243675a0b04SKarl Beldan 	struct cfg80211_chan_def _oper_chandef;
1244f0706e82SJiri Benc 
1245b8bc4b0aSJohannes Berg 	/* Temporary remain-on-channel for off-channel operations */
1246b8bc4b0aSJohannes Berg 	struct ieee80211_channel *tmp_channel;
1247b8bc4b0aSJohannes Berg 
1248d01a1e65SMichal Kazior 	/* channel contexts */
1249d01a1e65SMichal Kazior 	struct list_head chanctx_list;
1250d01a1e65SMichal Kazior 	struct mutex chanctx_mtx;
1251d01a1e65SMichal Kazior 
1252c206ca67SJohannes Berg #ifdef CONFIG_MAC80211_LEDS
12538d5c2585SJohannes Berg 	struct led_trigger tx_led, rx_led, assoc_led, radio_led;
12548d5c2585SJohannes Berg 	struct led_trigger tpt_led;
12558d5c2585SJohannes Berg 	atomic_t tx_led_active, rx_led_active, assoc_led_active;
12568d5c2585SJohannes Berg 	atomic_t radio_led_active, tpt_led_active;
1257c206ca67SJohannes Berg 	struct tpt_led_trigger *tpt_led_trigger;
1258c206ca67SJohannes Berg #endif
1259c206ca67SJohannes Berg 
1260c206ca67SJohannes Berg #ifdef CONFIG_MAC80211_DEBUG_COUNTERS
1261f0706e82SJiri Benc 	/* SNMP counters */
1262f0706e82SJiri Benc 	/* dot11CountersTable */
1263f0706e82SJiri Benc 	u32 dot11TransmittedFragmentCount;
1264f0706e82SJiri Benc 	u32 dot11MulticastTransmittedFrameCount;
1265f0706e82SJiri Benc 	u32 dot11FailedCount;
1266f0706e82SJiri Benc 	u32 dot11RetryCount;
1267f0706e82SJiri Benc 	u32 dot11MultipleRetryCount;
1268f0706e82SJiri Benc 	u32 dot11FrameDuplicateCount;
1269f0706e82SJiri Benc 	u32 dot11ReceivedFragmentCount;
1270f0706e82SJiri Benc 	u32 dot11MulticastReceivedFrameCount;
1271f0706e82SJiri Benc 	u32 dot11TransmittedFrameCount;
1272f0706e82SJiri Benc 
1273f0706e82SJiri Benc 	/* TX/RX handler statistics */
1274f0706e82SJiri Benc 	unsigned int tx_handlers_drop;
1275f0706e82SJiri Benc 	unsigned int tx_handlers_queued;
1276f0706e82SJiri Benc 	unsigned int tx_handlers_drop_wep;
1277f0706e82SJiri Benc 	unsigned int tx_handlers_drop_not_assoc;
1278f0706e82SJiri Benc 	unsigned int tx_handlers_drop_unauth_port;
1279f0706e82SJiri Benc 	unsigned int rx_handlers_drop;
1280f0706e82SJiri Benc 	unsigned int rx_handlers_queued;
1281f0706e82SJiri Benc 	unsigned int rx_handlers_drop_nullfunc;
1282f0706e82SJiri Benc 	unsigned int rx_handlers_drop_defrag;
1283f0706e82SJiri Benc 	unsigned int tx_expand_skb_head;
1284f0706e82SJiri Benc 	unsigned int tx_expand_skb_head_cloned;
1285f1160434SJohannes Berg 	unsigned int rx_expand_skb_head_defrag;
1286f0706e82SJiri Benc 	unsigned int rx_handlers_fragments;
1287f0706e82SJiri Benc 	unsigned int tx_status_drop;
1288f0706e82SJiri Benc #define I802_DEBUG_INC(c) (c)++
1289f0706e82SJiri Benc #else /* CONFIG_MAC80211_DEBUG_COUNTERS */
1290f0706e82SJiri Benc #define I802_DEBUG_INC(c) do { } while (0)
1291f0706e82SJiri Benc #endif /* CONFIG_MAC80211_DEBUG_COUNTERS */
1292f0706e82SJiri Benc 
1293f0706e82SJiri Benc 
1294f0706e82SJiri Benc 	int total_ps_buffered; /* total number of all buffered unicast and
1295f0706e82SJiri Benc 				* multicast packets for power saving stations
1296f0706e82SJiri Benc 				*/
1297520eb820SKalle Valo 
1298572e0012SKalle Valo 	bool pspolling;
1299b203ffc3SJouni Malinen 	bool offchannel_ps_enabled;
1300965bedadSJohannes Berg 	/*
1301965bedadSJohannes Berg 	 * PS can only be enabled when we have exactly one managed
1302965bedadSJohannes Berg 	 * interface (and monitors) in PS, this then points there.
1303965bedadSJohannes Berg 	 */
1304965bedadSJohannes Berg 	struct ieee80211_sub_if_data *ps_sdata;
1305520eb820SKalle Valo 	struct work_struct dynamic_ps_enable_work;
1306520eb820SKalle Valo 	struct work_struct dynamic_ps_disable_work;
1307520eb820SKalle Valo 	struct timer_list dynamic_ps_timer;
130810f644a4SJohannes Berg 	struct notifier_block network_latency_notifier;
13092b2c009eSJuuso Oikarinen 	struct notifier_block ifa_notifier;
1310a65240c1SJohannes Berg 	struct notifier_block ifa6_notifier;
1311f0706e82SJiri Benc 
1312ff616381SJuuso Oikarinen 	/*
1313ff616381SJuuso Oikarinen 	 * The dynamic ps timeout configured from user space via WEXT -
1314ff616381SJuuso Oikarinen 	 * this will override whatever chosen by mac80211 internally.
1315ff616381SJuuso Oikarinen 	 */
1316ff616381SJuuso Oikarinen 	int dynamic_ps_forced_timeout;
1317ff616381SJuuso Oikarinen 
13181ea6f9c0SJohannes Berg 	int user_power_level; /* in dBm, for all interfaces */
13192bf30fabSJohannes Berg 
13200f78231bSJohannes Berg 	enum ieee80211_smps_mode smps_mode;
13210f78231bSJohannes Berg 
1322f2753ddbSJohannes Berg 	struct work_struct restart_work;
1323f2753ddbSJohannes Berg 
1324e9f207f0SJiri Benc #ifdef CONFIG_MAC80211_DEBUGFS
1325e9f207f0SJiri Benc 	struct local_debugfsdentries {
13264b7679a5SJohannes Berg 		struct dentry *rcdir;
1327e9f207f0SJiri Benc 		struct dentry *keys;
1328e9f207f0SJiri Benc 	} debugfs;
1329e9f207f0SJiri Benc #endif
13304e6cbfd0SJohn W. Linville 
13312eb278e0SJohannes Berg 	/*
13322eb278e0SJohannes Berg 	 * Remain-on-channel support
13332eb278e0SJohannes Berg 	 */
13342eb278e0SJohannes Berg 	struct list_head roc_list;
133521f83589SJohannes Berg 	struct work_struct hw_roc_start, hw_roc_done;
13362eb278e0SJohannes Berg 	unsigned long hw_roc_start_time;
133750febf6aSJohannes Berg 	u64 roc_cookie_counter;
133821f83589SJohannes Berg 
1339a729cff8SJohannes Berg 	struct idr ack_status_frames;
1340a729cff8SJohannes Berg 	spinlock_t ack_status_lock;
1341a729cff8SJohannes Berg 
1342f142c6b9SJohannes Berg 	struct ieee80211_sub_if_data __rcu *p2p_sdata;
1343f142c6b9SJohannes Berg 
13444b6f1dd6SJohannes Berg 	/* virtual monitor interface */
13454b6f1dd6SJohannes Berg 	struct ieee80211_sub_if_data __rcu *monitor_sdata;
13464bf88530SJohannes Berg 	struct cfg80211_chan_def monitor_chandef;
1347e9a21949SLuciano Coelho 
1348e9a21949SLuciano Coelho 	/* extended capabilities provided by mac80211 */
1349e9a21949SLuciano Coelho 	u8 ext_capa[8];
1350c8ff71e6SArik Nemtsov 
1351c8ff71e6SArik Nemtsov 	/* TDLS channel switch */
1352c8ff71e6SArik Nemtsov 	struct work_struct tdls_chsw_work;
1353c8ff71e6SArik Nemtsov 	struct sk_buff_head skb_queue_tdls_chsw;
1354f0706e82SJiri Benc };
1355f0706e82SJiri Benc 
13563e122be0SJohannes Berg static inline struct ieee80211_sub_if_data *
13573e122be0SJohannes Berg IEEE80211_DEV_TO_SUB_IF(struct net_device *dev)
13583e122be0SJohannes Berg {
13593e122be0SJohannes Berg 	return netdev_priv(dev);
13603e122be0SJohannes Berg }
13613e122be0SJohannes Berg 
136271bbc994SJohannes Berg static inline struct ieee80211_sub_if_data *
136371bbc994SJohannes Berg IEEE80211_WDEV_TO_SUB_IF(struct wireless_dev *wdev)
136471bbc994SJohannes Berg {
136571bbc994SJohannes Berg 	return container_of(wdev, struct ieee80211_sub_if_data, wdev);
136671bbc994SJohannes Berg }
136771bbc994SJohannes Berg 
1368c1475ca9SJohannes Berg /* this struct represents 802.11n's RA/TID combination */
1369eadc8d9eSRon Rindjunsky struct ieee80211_ra_tid {
1370eadc8d9eSRon Rindjunsky 	u8 ra[ETH_ALEN];
1371eadc8d9eSRon Rindjunsky 	u16 tid;
1372eadc8d9eSRon Rindjunsky };
1373eadc8d9eSRon Rindjunsky 
1374c0f17eb9SChun-Yeow Yeoh /* this struct holds the value parsing from channel switch IE  */
1375c0f17eb9SChun-Yeow Yeoh struct ieee80211_csa_ie {
1376c0f17eb9SChun-Yeow Yeoh 	struct cfg80211_chan_def chandef;
1377c0f17eb9SChun-Yeow Yeoh 	u8 mode;
1378c0f17eb9SChun-Yeow Yeoh 	u8 count;
1379c0f17eb9SChun-Yeow Yeoh 	u8 ttl;
13803f718fd8SChun-Yeow Yeoh 	u16 pre_value;
1381c0f17eb9SChun-Yeow Yeoh };
1382c0f17eb9SChun-Yeow Yeoh 
1383dd76986bSJohannes Berg /* Parsed Information Elements */
1384dd76986bSJohannes Berg struct ieee802_11_elems {
13854a3cb702SJohannes Berg 	const u8 *ie_start;
1386dd76986bSJohannes Berg 	size_t total_len;
1387dd76986bSJohannes Berg 
1388dd76986bSJohannes Berg 	/* pointers to IEs */
138953837584SArik Nemtsov 	const struct ieee80211_tdls_lnkie *lnk_id;
139053837584SArik Nemtsov 	const struct ieee80211_ch_switch_timing *ch_sw_timing;
13919041c1faSArik Nemtsov 	const u8 *ext_capab;
13924a3cb702SJohannes Berg 	const u8 *ssid;
13934a3cb702SJohannes Berg 	const u8 *supp_rates;
13944a3cb702SJohannes Berg 	const u8 *ds_params;
13954a3cb702SJohannes Berg 	const struct ieee80211_tim_ie *tim;
13964a3cb702SJohannes Berg 	const u8 *challenge;
13974a3cb702SJohannes Berg 	const u8 *rsn;
13984a3cb702SJohannes Berg 	const u8 *erp_info;
13994a3cb702SJohannes Berg 	const u8 *ext_supp_rates;
14004a3cb702SJohannes Berg 	const u8 *wmm_info;
14014a3cb702SJohannes Berg 	const u8 *wmm_param;
14024a3cb702SJohannes Berg 	const struct ieee80211_ht_cap *ht_cap_elem;
14034a3cb702SJohannes Berg 	const struct ieee80211_ht_operation *ht_operation;
14044a3cb702SJohannes Berg 	const struct ieee80211_vht_cap *vht_cap_elem;
14054a3cb702SJohannes Berg 	const struct ieee80211_vht_operation *vht_operation;
14064a3cb702SJohannes Berg 	const struct ieee80211_meshconf_ie *mesh_config;
14074a3cb702SJohannes Berg 	const u8 *mesh_id;
14084a3cb702SJohannes Berg 	const u8 *peering;
14094a3cb702SJohannes Berg 	const __le16 *awake_window;
14104a3cb702SJohannes Berg 	const u8 *preq;
14114a3cb702SJohannes Berg 	const u8 *prep;
14124a3cb702SJohannes Berg 	const u8 *perr;
14134a3cb702SJohannes Berg 	const struct ieee80211_rann_ie *rann;
14144a3cb702SJohannes Berg 	const struct ieee80211_channel_sw_ie *ch_switch_ie;
1415b4f286a1SJohannes Berg 	const struct ieee80211_ext_chansw_ie *ext_chansw_ie;
1416b2e506bfSJohannes Berg 	const struct ieee80211_wide_bw_chansw_ie *wide_bw_chansw_ie;
14174a3cb702SJohannes Berg 	const u8 *country_elem;
14184a3cb702SJohannes Berg 	const u8 *pwr_constr_elem;
1419c8d65917SSteinar H. Gunderson 	const u8 *cisco_dtpc_elem;
142079ba1d89SJohannes Berg 	const struct ieee80211_timeout_interval_ie *timeout_int;
14214a3cb702SJohannes Berg 	const u8 *opmode_notif;
142285220d71SJohannes Berg 	const struct ieee80211_sec_chan_offs_ie *sec_chan_offs;
14238f2535b9SChun-Yeow Yeoh 	const struct ieee80211_mesh_chansw_params_ie *mesh_chansw_params_ie;
1424dd76986bSJohannes Berg 
1425dd76986bSJohannes Berg 	/* length of them, respectively */
14269041c1faSArik Nemtsov 	u8 ext_capab_len;
1427dd76986bSJohannes Berg 	u8 ssid_len;
1428dd76986bSJohannes Berg 	u8 supp_rates_len;
1429dd76986bSJohannes Berg 	u8 tim_len;
1430dd76986bSJohannes Berg 	u8 challenge_len;
1431dd76986bSJohannes Berg 	u8 rsn_len;
1432dd76986bSJohannes Berg 	u8 ext_supp_rates_len;
1433dd76986bSJohannes Berg 	u8 wmm_info_len;
1434dd76986bSJohannes Berg 	u8 wmm_param_len;
1435dd76986bSJohannes Berg 	u8 mesh_id_len;
1436dd76986bSJohannes Berg 	u8 peering_len;
1437dd76986bSJohannes Berg 	u8 preq_len;
1438dd76986bSJohannes Berg 	u8 prep_len;
1439dd76986bSJohannes Berg 	u8 perr_len;
1440dd76986bSJohannes Berg 	u8 country_elem_len;
1441fcff4f10SPaul Stewart 
1442fcff4f10SPaul Stewart 	/* whether a parse error occurred while retrieving these elements */
1443fcff4f10SPaul Stewart 	bool parse_error;
1444dd76986bSJohannes Berg };
1445dd76986bSJohannes Berg 
1446f0706e82SJiri Benc static inline struct ieee80211_local *hw_to_local(
1447f0706e82SJiri Benc 	struct ieee80211_hw *hw)
1448f0706e82SJiri Benc {
1449f0706e82SJiri Benc 	return container_of(hw, struct ieee80211_local, hw);
1450f0706e82SJiri Benc }
1451f0706e82SJiri Benc 
1452ba8c3d6fSFelix Fietkau static inline struct txq_info *to_txq_info(struct ieee80211_txq *txq)
1453ba8c3d6fSFelix Fietkau {
1454ba8c3d6fSFelix Fietkau 	return container_of(txq, struct txq_info, txq);
1455ba8c3d6fSFelix Fietkau }
1456f0706e82SJiri Benc 
1457571ecf67SJohannes Berg static inline int ieee80211_bssid_match(const u8 *raddr, const u8 *addr)
1458571ecf67SJohannes Berg {
1459b203ca39SJoe Perches 	return ether_addr_equal(raddr, addr) ||
1460571ecf67SJohannes Berg 	       is_broadcast_ether_addr(raddr);
1461571ecf67SJohannes Berg }
1462571ecf67SJohannes Berg 
1463f4bda337SThomas Pedersen static inline bool
1464f4bda337SThomas Pedersen ieee80211_have_rx_timestamp(struct ieee80211_rx_status *status)
1465f4bda337SThomas Pedersen {
1466f4bda337SThomas Pedersen 	WARN_ON_ONCE(status->flag & RX_FLAG_MACTIME_START &&
1467f4bda337SThomas Pedersen 		     status->flag & RX_FLAG_MACTIME_END);
1468f4bda337SThomas Pedersen 	return status->flag & (RX_FLAG_MACTIME_START | RX_FLAG_MACTIME_END);
1469f4bda337SThomas Pedersen }
1470571ecf67SJohannes Berg 
1471f4bda337SThomas Pedersen u64 ieee80211_calculate_rx_timestamp(struct ieee80211_local *local,
1472f4bda337SThomas Pedersen 				     struct ieee80211_rx_status *status,
1473f4bda337SThomas Pedersen 				     unsigned int mpdu_len,
1474f4bda337SThomas Pedersen 				     unsigned int mpdu_offset);
1475e8975581SJohannes Berg int ieee80211_hw_config(struct ieee80211_local *local, u32 changed);
14765cf121c3SJohannes Berg void ieee80211_tx_set_protected(struct ieee80211_tx_data *tx);
14779c6bd790SJohannes Berg void ieee80211_bss_info_change_notify(struct ieee80211_sub_if_data *sdata,
14789c6bd790SJohannes Berg 				      u32 changed);
14790d143fe1SJohannes Berg void ieee80211_configure_filter(struct ieee80211_local *local);
148046900298SJohannes Berg u32 ieee80211_reset_erp_info(struct ieee80211_sub_if_data *sdata);
1481f0706e82SJiri Benc 
148246900298SJohannes Berg /* STA code */
14839c6bd790SJohannes Berg void ieee80211_sta_setup_sdata(struct ieee80211_sub_if_data *sdata);
148477fdaa12SJohannes Berg int ieee80211_mgd_auth(struct ieee80211_sub_if_data *sdata,
148577fdaa12SJohannes Berg 		       struct cfg80211_auth_request *req);
148677fdaa12SJohannes Berg int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata,
148777fdaa12SJohannes Berg 			struct cfg80211_assoc_request *req);
148877fdaa12SJohannes Berg int ieee80211_mgd_deauth(struct ieee80211_sub_if_data *sdata,
148963c9c5e7SJohannes Berg 			 struct cfg80211_deauth_request *req);
149077fdaa12SJohannes Berg int ieee80211_mgd_disassoc(struct ieee80211_sub_if_data *sdata,
149163c9c5e7SJohannes Berg 			   struct cfg80211_disassoc_request *req);
1492572e0012SKalle Valo void ieee80211_send_pspoll(struct ieee80211_local *local,
1493572e0012SKalle Valo 			   struct ieee80211_sub_if_data *sdata);
149410f644a4SJohannes Berg void ieee80211_recalc_ps(struct ieee80211_local *local, s32 latency);
1495ab095877SEliad Peller void ieee80211_recalc_ps_vif(struct ieee80211_sub_if_data *sdata);
149610f644a4SJohannes Berg int ieee80211_max_network_latency(struct notifier_block *nb,
149710f644a4SJohannes Berg 				  unsigned long data, void *dummy);
14982b2c009eSJuuso Oikarinen int ieee80211_set_arp_filter(struct ieee80211_sub_if_data *sdata);
14991fa57d01SJohannes Berg void ieee80211_sta_work(struct ieee80211_sub_if_data *sdata);
15001fa57d01SJohannes Berg void ieee80211_sta_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
15011fa57d01SJohannes Berg 				  struct sk_buff *skb);
1502d3a910a8SLuis R. Rodriguez void ieee80211_sta_reset_beacon_monitor(struct ieee80211_sub_if_data *sdata);
1503be099e82SLuis R. Rodriguez void ieee80211_sta_reset_conn_monitor(struct ieee80211_sub_if_data *sdata);
1504afa762f6SEliad Peller void ieee80211_mgd_stop(struct ieee80211_sub_if_data *sdata);
15051672c0e3SJohannes Berg void ieee80211_mgd_conn_tx_status(struct ieee80211_sub_if_data *sdata,
15061672c0e3SJohannes Berg 				  __le16 fc, bool acked);
15071a1cb744SJohannes Berg void ieee80211_mgd_quiesce(struct ieee80211_sub_if_data *sdata);
1508b8360ab8SJohannes Berg void ieee80211_sta_restart(struct ieee80211_sub_if_data *sdata);
150902219b3aSJohannes Berg void ieee80211_sta_handle_tspec_ac_params(struct ieee80211_sub_if_data *sdata);
15109c6bd790SJohannes Berg 
151146900298SJohannes Berg /* IBSS code */
151246900298SJohannes Berg void ieee80211_ibss_notify_scan_completed(struct ieee80211_local *local);
151346900298SJohannes Berg void ieee80211_ibss_setup_sdata(struct ieee80211_sub_if_data *sdata);
15148bf11d8dSJohannes Berg void ieee80211_ibss_rx_no_sta(struct ieee80211_sub_if_data *sdata,
15158bf11d8dSJohannes Berg 			      const u8 *bssid, const u8 *addr, u32 supp_rates);
1516af8cdcd8SJohannes Berg int ieee80211_ibss_join(struct ieee80211_sub_if_data *sdata,
1517af8cdcd8SJohannes Berg 			struct cfg80211_ibss_params *params);
1518af8cdcd8SJohannes Berg int ieee80211_ibss_leave(struct ieee80211_sub_if_data *sdata);
15191fa57d01SJohannes Berg void ieee80211_ibss_work(struct ieee80211_sub_if_data *sdata);
15201fa57d01SJohannes Berg void ieee80211_ibss_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
15211fa57d01SJohannes Berg 				   struct sk_buff *skb);
1522cd7760e6SSimon Wunderlich int ieee80211_ibss_csa_beacon(struct ieee80211_sub_if_data *sdata,
1523cd7760e6SSimon Wunderlich 			      struct cfg80211_csa_settings *csa_settings);
1524cd7760e6SSimon Wunderlich int ieee80211_ibss_finish_csa(struct ieee80211_sub_if_data *sdata);
1525cd7760e6SSimon Wunderlich void ieee80211_ibss_stop(struct ieee80211_sub_if_data *sdata);
15261fa57d01SJohannes Berg 
1527239281f8SRostislav Lisovy /* OCB code */
1528239281f8SRostislav Lisovy void ieee80211_ocb_work(struct ieee80211_sub_if_data *sdata);
1529239281f8SRostislav Lisovy void ieee80211_ocb_rx_no_sta(struct ieee80211_sub_if_data *sdata,
1530239281f8SRostislav Lisovy 			     const u8 *bssid, const u8 *addr, u32 supp_rates);
1531239281f8SRostislav Lisovy void ieee80211_ocb_setup_sdata(struct ieee80211_sub_if_data *sdata);
1532239281f8SRostislav Lisovy int ieee80211_ocb_join(struct ieee80211_sub_if_data *sdata,
1533239281f8SRostislav Lisovy 		       struct ocb_setup *setup);
1534239281f8SRostislav Lisovy int ieee80211_ocb_leave(struct ieee80211_sub_if_data *sdata);
1535239281f8SRostislav Lisovy 
15361fa57d01SJohannes Berg /* mesh code */
15371fa57d01SJohannes Berg void ieee80211_mesh_work(struct ieee80211_sub_if_data *sdata);
15381fa57d01SJohannes Berg void ieee80211_mesh_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
15391fa57d01SJohannes Berg 				   struct sk_buff *skb);
1540b8456a14SChun-Yeow Yeoh int ieee80211_mesh_csa_beacon(struct ieee80211_sub_if_data *sdata,
154166e01cf9SLuciano Coelho 			      struct cfg80211_csa_settings *csa_settings);
1542b8456a14SChun-Yeow Yeoh int ieee80211_mesh_finish_csa(struct ieee80211_sub_if_data *sdata);
154346900298SJohannes Berg 
15449c6bd790SJohannes Berg /* scan/BSS handling */
154546900298SJohannes Berg void ieee80211_scan_work(struct work_struct *work);
154634bcf715SStanislaw Gruszka int ieee80211_request_ibss_scan(struct ieee80211_sub_if_data *sdata,
1547be4a4b6aSJohannes Berg 				const u8 *ssid, u8 ssid_len,
154876bed0f4SJanusz.Dziedzic@tieto.com 				struct ieee80211_channel **channels,
154976bed0f4SJanusz.Dziedzic@tieto.com 				unsigned int n_channels,
15507ca15a0aSSimon Wunderlich 				enum nl80211_bss_scan_width scan_width);
1551c2b13452SJohannes Berg int ieee80211_request_scan(struct ieee80211_sub_if_data *sdata,
15522a519311SJohannes Berg 			   struct cfg80211_scan_request *req);
15535bb644a0SJohannes Berg void ieee80211_scan_cancel(struct ieee80211_local *local);
1554133d40f9SStanislaw Gruszka void ieee80211_run_deferred_scan(struct ieee80211_local *local);
1555d48b2968SJohannes Berg void ieee80211_scan_rx(struct ieee80211_local *local, struct sk_buff *skb);
15569c6bd790SJohannes Berg 
15570a51b27eSJohannes Berg void ieee80211_mlme_notify_scan_completed(struct ieee80211_local *local);
1558c2b13452SJohannes Berg struct ieee80211_bss *
155998c8fccfSJohannes Berg ieee80211_bss_info_update(struct ieee80211_local *local,
156098c8fccfSJohannes Berg 			  struct ieee80211_rx_status *rx_status,
156198c8fccfSJohannes Berg 			  struct ieee80211_mgmt *mgmt,
156298c8fccfSJohannes Berg 			  size_t len,
156398c8fccfSJohannes Berg 			  struct ieee802_11_elems *elems,
1564d45c4172SEmmanuel Grumbach 			  struct ieee80211_channel *channel);
156598c8fccfSJohannes Berg void ieee80211_rx_bss_put(struct ieee80211_local *local,
1566c2b13452SJohannes Berg 			  struct ieee80211_bss *bss);
1567ee385855SLuis Carlos Cobo 
156879f460caSLuciano Coelho /* scheduled scan handling */
1569d43c6b6eSDavid Spinadel int
1570d43c6b6eSDavid Spinadel __ieee80211_request_sched_scan_start(struct ieee80211_sub_if_data *sdata,
1571d43c6b6eSDavid Spinadel 				     struct cfg80211_sched_scan_request *req);
157279f460caSLuciano Coelho int ieee80211_request_sched_scan_start(struct ieee80211_sub_if_data *sdata,
157379f460caSLuciano Coelho 				       struct cfg80211_sched_scan_request *req);
157485a9994aSLuciano Coelho int ieee80211_request_sched_scan_stop(struct ieee80211_sub_if_data *sdata);
1575f6837ba8SJohannes Berg void ieee80211_sched_scan_end(struct ieee80211_local *local);
157685a9994aSLuciano Coelho void ieee80211_sched_scan_stopped_work(struct work_struct *work);
157779f460caSLuciano Coelho 
1578b203ffc3SJouni Malinen /* off-channel helpers */
1579aacde9eeSStanislaw Gruszka void ieee80211_offchannel_stop_vifs(struct ieee80211_local *local);
1580aacde9eeSStanislaw Gruszka void ieee80211_offchannel_return(struct ieee80211_local *local);
15812eb278e0SJohannes Berg void ieee80211_roc_setup(struct ieee80211_local *local);
15822eb278e0SJohannes Berg void ieee80211_start_next_roc(struct ieee80211_local *local);
1583c8f994eeSJohannes Berg void ieee80211_roc_purge(struct ieee80211_local *local,
1584c8f994eeSJohannes Berg 			 struct ieee80211_sub_if_data *sdata);
15853fbd45caSJohannes Berg void ieee80211_roc_notify_destroy(struct ieee80211_roc_work *roc, bool free);
15862eb278e0SJohannes Berg void ieee80211_sw_roc_work(struct work_struct *work);
15872eb278e0SJohannes Berg void ieee80211_handle_roc_started(struct ieee80211_roc_work *roc);
1588b203ffc3SJouni Malinen 
158973da7d5bSSimon Wunderlich /* channel switch handling */
159073da7d5bSSimon Wunderlich void ieee80211_csa_finalize_work(struct work_struct *work);
159182a8e17dSLuciano Coelho int ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev,
159282a8e17dSLuciano Coelho 			     struct cfg80211_csa_settings *params);
159373da7d5bSSimon Wunderlich 
15943e122be0SJohannes Berg /* interface handling */
159547846c9bSJohannes Berg int ieee80211_iface_init(void);
159647846c9bSJohannes Berg void ieee80211_iface_exit(void);
15973e122be0SJohannes Berg int ieee80211_if_add(struct ieee80211_local *local, const char *name,
15986bab2e19STom Gundersen 		     unsigned char name_assign_type,
159984efbb84SJohannes Berg 		     struct wireless_dev **new_wdev, enum nl80211_iftype type,
1600ee385855SLuis Carlos Cobo 		     struct vif_params *params);
1601f3947e2dSJohannes Berg int ieee80211_if_change_type(struct ieee80211_sub_if_data *sdata,
160205c914feSJohannes Berg 			     enum nl80211_iftype type);
1603f698d856SJasper Bryant-Greene void ieee80211_if_remove(struct ieee80211_sub_if_data *sdata);
160475636525SJohannes Berg void ieee80211_remove_interfaces(struct ieee80211_local *local);
1605382a103bSJohannes Berg u32 ieee80211_idle_off(struct ieee80211_local *local);
16065cff20e6SJohannes Berg void ieee80211_recalc_idle(struct ieee80211_local *local);
160785416a4fSChristian Lamparter void ieee80211_adjust_monitor_flags(struct ieee80211_sub_if_data *sdata,
160885416a4fSChristian Lamparter 				    const int offset);
1609f142c6b9SJohannes Berg int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up);
1610f142c6b9SJohannes Berg void ieee80211_sdata_stop(struct ieee80211_sub_if_data *sdata);
16113c3e21e7SJohannes Berg int ieee80211_add_virtual_monitor(struct ieee80211_local *local);
16123c3e21e7SJohannes Berg void ieee80211_del_virtual_monitor(struct ieee80211_local *local);
1613f0706e82SJiri Benc 
16141ea6f9c0SJohannes Berg bool __ieee80211_recalc_txpower(struct ieee80211_sub_if_data *sdata);
1615db82d8a9SLorenzo Bianconi void ieee80211_recalc_txpower(struct ieee80211_sub_if_data *sdata,
1616db82d8a9SLorenzo Bianconi 			      bool update_bss);
16171ea6f9c0SJohannes Berg 
16189607e6b6SJohannes Berg static inline bool ieee80211_sdata_running(struct ieee80211_sub_if_data *sdata)
16199607e6b6SJohannes Berg {
162034d4bc4dSJohannes Berg 	return test_bit(SDATA_STATE_RUNNING, &sdata->state);
16219607e6b6SJohannes Berg }
16229607e6b6SJohannes Berg 
1623e2ebc74dSJohannes Berg /* tx handling */
1624e2ebc74dSJohannes Berg void ieee80211_clear_tx_pending(struct ieee80211_local *local);
1625e2ebc74dSJohannes Berg void ieee80211_tx_pending(unsigned long data);
1626d0cf9c0dSStephen Hemminger netdev_tx_t ieee80211_monitor_start_xmit(struct sk_buff *skb,
1627d0cf9c0dSStephen Hemminger 					 struct net_device *dev);
1628d0cf9c0dSStephen Hemminger netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb,
1629d0cf9c0dSStephen Hemminger 				       struct net_device *dev);
163024d342c5SLiad Kaufman void __ieee80211_subif_start_xmit(struct sk_buff *skb,
163124d342c5SLiad Kaufman 				  struct net_device *dev,
163224d342c5SLiad Kaufman 				  u32 info_flags);
16331f98ab7fSFelix Fietkau void ieee80211_purge_tx_queue(struct ieee80211_hw *hw,
16341f98ab7fSFelix Fietkau 			      struct sk_buff_head *skbs);
16357528ec57SJohannes Berg struct sk_buff *
16367528ec57SJohannes Berg ieee80211_build_data_template(struct ieee80211_sub_if_data *sdata,
16377528ec57SJohannes Berg 			      struct sk_buff *skb, u32 info_flags);
16384dc792b8SHelmut Schaa void ieee80211_tx_monitor(struct ieee80211_local *local, struct sk_buff *skb,
16394dc792b8SHelmut Schaa 			  struct ieee80211_supported_band *sband,
16404dc792b8SHelmut Schaa 			  int retry_count, int shift, bool send_to_cooked);
1641e2ebc74dSJohannes Berg 
164217c18bf8SJohannes Berg void ieee80211_check_fast_xmit(struct sta_info *sta);
164317c18bf8SJohannes Berg void ieee80211_check_fast_xmit_all(struct ieee80211_local *local);
164417c18bf8SJohannes Berg void ieee80211_check_fast_xmit_iface(struct ieee80211_sub_if_data *sdata);
164517c18bf8SJohannes Berg void ieee80211_clear_fast_xmit(struct sta_info *sta);
164617c18bf8SJohannes Berg 
1647de1ede7aSJohannes Berg /* HT */
1648ef96a842SBen Greear void ieee80211_apply_htcap_overrides(struct ieee80211_sub_if_data *sdata,
1649ef96a842SBen Greear 				     struct ieee80211_sta_ht_cap *ht_cap);
1650e1a0c6b3SJohannes Berg bool ieee80211_ht_cap_ie_to_sta_ht_cap(struct ieee80211_sub_if_data *sdata,
1651ef96a842SBen Greear 				       struct ieee80211_supported_band *sband,
16524a3cb702SJohannes Berg 				       const struct ieee80211_ht_cap *ht_cap_ie,
1653e1a0c6b3SJohannes Berg 				       struct sta_info *sta);
1654b8695a8fSJohannes Berg void ieee80211_send_delba(struct ieee80211_sub_if_data *sdata,
1655b8695a8fSJohannes Berg 			  const u8 *da, u16 tid,
1656b8695a8fSJohannes Berg 			  u16 initiator, u16 reason_code);
16570f78231bSJohannes Berg int ieee80211_send_smps_action(struct ieee80211_sub_if_data *sdata,
16580f78231bSJohannes Berg 			       enum ieee80211_smps_mode smps, const u8 *da,
16590f78231bSJohannes Berg 			       const u8 *bssid);
1660687da132SEmmanuel Grumbach void ieee80211_request_smps_ap_work(struct work_struct *work);
1661687da132SEmmanuel Grumbach void ieee80211_request_smps_mgd_work(struct work_struct *work);
1662687da132SEmmanuel Grumbach bool ieee80211_smps_is_restrictive(enum ieee80211_smps_mode smps_mode_old,
1663687da132SEmmanuel Grumbach 				   enum ieee80211_smps_mode smps_mode_new);
1664de1ede7aSJohannes Berg 
16657c3b1dd8SJohannes Berg void ___ieee80211_stop_rx_ba_session(struct sta_info *sta, u16 tid,
166653f73c09SJohannes Berg 				     u16 initiator, u16 reason, bool stop);
1667849b7967SJohannes Berg void __ieee80211_stop_rx_ba_session(struct sta_info *sta, u16 tid,
166853f73c09SJohannes Berg 				    u16 initiator, u16 reason, bool stop);
166908cf42e8SMichal Kazior void __ieee80211_start_rx_ba_session(struct sta_info *sta,
167008cf42e8SMichal Kazior 				     u8 dialog_token, u16 timeout,
167108cf42e8SMichal Kazior 				     u16 start_seq_num, u16 ba_policy, u16 tid,
16724549cf2bSMichal Kazior 				     u16 buf_size, bool tx, bool auto_seq);
1673c82c4a80SJohannes Berg void ieee80211_sta_tear_down_BA_sessions(struct sta_info *sta,
1674c82c4a80SJohannes Berg 					 enum ieee80211_agg_stop_reason reason);
1675de1ede7aSJohannes Berg void ieee80211_process_delba(struct ieee80211_sub_if_data *sdata,
1676de1ede7aSJohannes Berg 			     struct sta_info *sta,
1677de1ede7aSJohannes Berg 			     struct ieee80211_mgmt *mgmt, size_t len);
1678de1ede7aSJohannes Berg void ieee80211_process_addba_resp(struct ieee80211_local *local,
1679de1ede7aSJohannes Berg 				  struct sta_info *sta,
1680de1ede7aSJohannes Berg 				  struct ieee80211_mgmt *mgmt,
1681de1ede7aSJohannes Berg 				  size_t len);
1682de1ede7aSJohannes Berg void ieee80211_process_addba_request(struct ieee80211_local *local,
1683de1ede7aSJohannes Berg 				     struct sta_info *sta,
1684de1ede7aSJohannes Berg 				     struct ieee80211_mgmt *mgmt,
1685de1ede7aSJohannes Berg 				     size_t len);
1686de1ede7aSJohannes Berg 
1687849b7967SJohannes Berg int __ieee80211_stop_tx_ba_session(struct sta_info *sta, u16 tid,
1688c82c4a80SJohannes Berg 				   enum ieee80211_agg_stop_reason reason);
168967c282c0SJohannes Berg int ___ieee80211_stop_tx_ba_session(struct sta_info *sta, u16 tid,
1690c82c4a80SJohannes Berg 				    enum ieee80211_agg_stop_reason reason);
16915d22c89bSJohannes Berg void ieee80211_start_tx_ba_cb(struct ieee80211_vif *vif, u8 *ra, u16 tid);
16925d22c89bSJohannes Berg void ieee80211_stop_tx_ba_cb(struct ieee80211_vif *vif, u8 *ra, u8 tid);
169367c282c0SJohannes Berg void ieee80211_ba_session_work(struct work_struct *work);
169467c282c0SJohannes Berg void ieee80211_tx_ba_session_handle_start(struct sta_info *sta, int tid);
16952bff8ebfSChristian Lamparter void ieee80211_release_reorder_timeout(struct sta_info *sta, int tid);
1696849b7967SJohannes Berg 
169704ecd257SJohannes Berg u8 ieee80211_mcs_to_chains(const struct ieee80211_mcs_info *mcs);
169804ecd257SJohannes Berg 
1699818255eaSMahesh Palivela /* VHT */
17004a3cb702SJohannes Berg void
17014a3cb702SJohannes Berg ieee80211_vht_cap_ie_to_sta_vht_cap(struct ieee80211_sub_if_data *sdata,
1702818255eaSMahesh Palivela 				    struct ieee80211_supported_band *sband,
17034a3cb702SJohannes Berg 				    const struct ieee80211_vht_cap *vht_cap_ie,
17044a34215eSJohannes Berg 				    struct sta_info *sta);
17051c45c5ceSEliad Peller enum ieee80211_sta_rx_bandwidth ieee80211_sta_cap_rx_bw(struct sta_info *sta);
1706e1a0c6b3SJohannes Berg enum ieee80211_sta_rx_bandwidth ieee80211_sta_cur_vht_bw(struct sta_info *sta);
17078921d04eSJohannes Berg void ieee80211_sta_set_rx_nss(struct sta_info *sta);
1708b1bce14aSMarek Kwaczynski u32 __ieee80211_vht_handle_opmode(struct ieee80211_sub_if_data *sdata,
1709b1bce14aSMarek Kwaczynski                                   struct sta_info *sta, u8 opmode,
1710b1bce14aSMarek Kwaczynski                                   enum ieee80211_band band, bool nss_only);
17110af83d3dSJohannes Berg void ieee80211_vht_handle_opmode(struct ieee80211_sub_if_data *sdata,
17120af83d3dSJohannes Berg 				 struct sta_info *sta, u8 opmode,
1713bee7f586SJohannes Berg 				 enum ieee80211_band band, bool nss_only);
1714dd5ecfeaSJohannes Berg void ieee80211_apply_vhtcap_overrides(struct ieee80211_sub_if_data *sdata,
1715dd5ecfeaSJohannes Berg 				      struct ieee80211_sta_vht_cap *vht_cap);
1716b119ad6eSLorenzo Bianconi void ieee80211_get_vht_mask_from_cap(__le16 vht_cap,
1717b119ad6eSLorenzo Bianconi 				     u16 vht_mask[NL80211_VHT_NSS_MAX]);
17184a34215eSJohannes Berg 
171939192c0bSJohannes Berg /* Spectrum management */
172039192c0bSJohannes Berg void ieee80211_process_measurement_req(struct ieee80211_sub_if_data *sdata,
172139192c0bSJohannes Berg 				       struct ieee80211_mgmt *mgmt,
172239192c0bSJohannes Berg 				       size_t len);
1723e6b7cde4SSimon Wunderlich /**
1724e6b7cde4SSimon Wunderlich  * ieee80211_parse_ch_switch_ie - parses channel switch IEs
1725e6b7cde4SSimon Wunderlich  * @sdata: the sdata of the interface which has received the frame
1726e6b7cde4SSimon Wunderlich  * @elems: parsed 802.11 elements received with the frame
1727e6b7cde4SSimon Wunderlich  * @current_band: indicates the current band
1728e6b7cde4SSimon Wunderlich  * @sta_flags: contains information about own capabilities and restrictions
1729e6b7cde4SSimon Wunderlich  *	to decide which channel switch announcements can be accepted. Only the
1730e6b7cde4SSimon Wunderlich  *	following subset of &enum ieee80211_sta_flags are evaluated:
1731e6b7cde4SSimon Wunderlich  *	%IEEE80211_STA_DISABLE_HT, %IEEE80211_STA_DISABLE_VHT,
1732e6b7cde4SSimon Wunderlich  *	%IEEE80211_STA_DISABLE_40MHZ, %IEEE80211_STA_DISABLE_80P80MHZ,
1733e6b7cde4SSimon Wunderlich  *	%IEEE80211_STA_DISABLE_160MHZ.
1734e6b7cde4SSimon Wunderlich  * @bssid: the currently connected bssid (for reporting)
1735c0f17eb9SChun-Yeow Yeoh  * @csa_ie: parsed 802.11 csa elements on count, mode, chandef and mesh ttl.
1736c0f17eb9SChun-Yeow Yeoh 	All of them will be filled with if success only.
1737e6b7cde4SSimon Wunderlich  * Return: 0 on success, <0 on error and >0 if there is nothing to parse.
1738e6b7cde4SSimon Wunderlich  */
1739e6b7cde4SSimon Wunderlich int ieee80211_parse_ch_switch_ie(struct ieee80211_sub_if_data *sdata,
174084469a45SLuciano Coelho 				 struct ieee802_11_elems *elems,
1741e6b7cde4SSimon Wunderlich 				 enum ieee80211_band current_band,
1742c0f17eb9SChun-Yeow Yeoh 				 u32 sta_flags, u8 *bssid,
1743c0f17eb9SChun-Yeow Yeoh 				 struct ieee80211_csa_ie *csa_ie);
174439192c0bSJohannes Berg 
1745f2753ddbSJohannes Berg /* Suspend/resume and hw reconfiguration */
1746f2753ddbSJohannes Berg int ieee80211_reconfig(struct ieee80211_local *local);
174784f6a01cSJohannes Berg void ieee80211_stop_device(struct ieee80211_local *local);
1748f2753ddbSJohannes Berg 
1749eecc4800SJohannes Berg int __ieee80211_suspend(struct ieee80211_hw *hw,
1750eecc4800SJohannes Berg 			struct cfg80211_wowlan *wowlan);
1751f2753ddbSJohannes Berg 
1752f2753ddbSJohannes Berg static inline int __ieee80211_resume(struct ieee80211_hw *hw)
1753f2753ddbSJohannes Berg {
175485f72bc8SJohn W. Linville 	struct ieee80211_local *local = hw_to_local(hw);
175585f72bc8SJohn W. Linville 
17569120d94eSLuciano Coelho 	WARN(test_bit(SCAN_HW_SCANNING, &local->scanning) &&
17579120d94eSLuciano Coelho 	     !test_bit(SCAN_COMPLETED, &local->scanning),
175885f72bc8SJohn W. Linville 		"%s: resume with hardware scan still in progress\n",
175985f72bc8SJohn W. Linville 		wiphy_name(hw->wiphy));
176085f72bc8SJohn W. Linville 
1761f2753ddbSJohannes Berg 	return ieee80211_reconfig(hw_to_local(hw));
1762f2753ddbSJohannes Berg }
1763665af4fcSBob Copeland 
1764c2d1560aSJohannes Berg /* utility functions/constants */
17658a47cea7SJohannes Berg extern const void *const mac80211_wiphy_privid; /* for wiphy privid */
17664ee73f33SMichal Kazior int ieee80211_frame_duration(enum ieee80211_band band, size_t len,
1767438b61b7SSimon Wunderlich 			     int rate, int erp, int short_preamble,
1768438b61b7SSimon Wunderlich 			     int shift);
1769f698d856SJasper Bryant-Greene void mac80211_ev_michael_mic_failure(struct ieee80211_sub_if_data *sdata, int keyidx,
1770e6d6e342SJohannes Berg 				     struct ieee80211_hdr *hdr, const u8 *tsc,
1771e6d6e342SJohannes Berg 				     gfp_t gfp);
17723abead59SJohannes Berg void ieee80211_set_wmm_default(struct ieee80211_sub_if_data *sdata,
17733abead59SJohannes Berg 			       bool bss_notify);
17747c10770fSJohannes Berg void ieee80211_xmit(struct ieee80211_sub_if_data *sdata,
17757c10770fSJohannes Berg 		    struct sta_info *sta, struct sk_buff *skb);
1776cf6bb79aSHelmut Schaa 
177755de908aSJohannes Berg void __ieee80211_tx_skb_tid_band(struct ieee80211_sub_if_data *sdata,
177855de908aSJohannes Berg 				 struct sk_buff *skb, int tid,
177955de908aSJohannes Berg 				 enum ieee80211_band band);
178055de908aSJohannes Berg 
178155de908aSJohannes Berg static inline void
178255de908aSJohannes Berg ieee80211_tx_skb_tid_band(struct ieee80211_sub_if_data *sdata,
178355de908aSJohannes Berg 			  struct sk_buff *skb, int tid,
178455de908aSJohannes Berg 			  enum ieee80211_band band)
178555de908aSJohannes Berg {
178655de908aSJohannes Berg 	rcu_read_lock();
178755de908aSJohannes Berg 	__ieee80211_tx_skb_tid_band(sdata, skb, tid, band);
178855de908aSJohannes Berg 	rcu_read_unlock();
178955de908aSJohannes Berg }
179055de908aSJohannes Berg 
179155de908aSJohannes Berg static inline void ieee80211_tx_skb_tid(struct ieee80211_sub_if_data *sdata,
179255de908aSJohannes Berg 					struct sk_buff *skb, int tid)
179355de908aSJohannes Berg {
179455de908aSJohannes Berg 	struct ieee80211_chanctx_conf *chanctx_conf;
179555de908aSJohannes Berg 
179655de908aSJohannes Berg 	rcu_read_lock();
179755de908aSJohannes Berg 	chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
179855de908aSJohannes Berg 	if (WARN_ON(!chanctx_conf)) {
179955de908aSJohannes Berg 		rcu_read_unlock();
180055de908aSJohannes Berg 		kfree_skb(skb);
180155de908aSJohannes Berg 		return;
180255de908aSJohannes Berg 	}
180355de908aSJohannes Berg 
180455de908aSJohannes Berg 	__ieee80211_tx_skb_tid_band(sdata, skb, tid,
18054bf88530SJohannes Berg 				    chanctx_conf->def.chan->band);
180655de908aSJohannes Berg 	rcu_read_unlock();
180755de908aSJohannes Berg }
180855de908aSJohannes Berg 
180955de908aSJohannes Berg static inline void ieee80211_tx_skb(struct ieee80211_sub_if_data *sdata,
1810cf6bb79aSHelmut Schaa 				    struct sk_buff *skb)
1811cf6bb79aSHelmut Schaa {
1812cf6bb79aSHelmut Schaa 	/* Send all internal mgmt frames on VO. Accordingly set TID to 7. */
1813cf6bb79aSHelmut Schaa 	ieee80211_tx_skb_tid(sdata, skb, 7);
1814cf6bb79aSHelmut Schaa }
1815cf6bb79aSHelmut Schaa 
181635d865afSJohannes Berg u32 ieee802_11_parse_elems_crc(const u8 *start, size_t len, bool action,
1817d91f36dbSJohannes Berg 			       struct ieee802_11_elems *elems,
1818d91f36dbSJohannes Berg 			       u64 filter, u32 crc);
181935d865afSJohannes Berg static inline void ieee802_11_parse_elems(const u8 *start, size_t len,
182035d865afSJohannes Berg 					  bool action,
1821ddc4db2eSJohannes Berg 					  struct ieee802_11_elems *elems)
1822ddc4db2eSJohannes Berg {
1823b2e506bfSJohannes Berg 	ieee802_11_parse_elems_crc(start, len, action, elems, 0, 0);
1824ddc4db2eSJohannes Berg }
1825ddc4db2eSJohannes Berg 
182683eb935eSMichal Kazior static inline bool ieee80211_rx_reorder_ready(struct sk_buff_head *frames)
182783eb935eSMichal Kazior {
182883eb935eSMichal Kazior 	struct sk_buff *tail = skb_peek_tail(frames);
182983eb935eSMichal Kazior 	struct ieee80211_rx_status *status;
183083eb935eSMichal Kazior 
183183eb935eSMichal Kazior 	if (!tail)
183283eb935eSMichal Kazior 		return false;
183383eb935eSMichal Kazior 
183483eb935eSMichal Kazior 	status = IEEE80211_SKB_RXCB(tail);
183583eb935eSMichal Kazior 	if (status->flag & RX_FLAG_AMSDU_MORE)
183683eb935eSMichal Kazior 		return false;
183783eb935eSMichal Kazior 
183883eb935eSMichal Kazior 	return true;
183983eb935eSMichal Kazior }
184083eb935eSMichal Kazior 
184102219b3aSJohannes Berg extern const int ieee802_1d_to_ac[8];
184202219b3aSJohannes Berg 
184302219b3aSJohannes Berg static inline int ieee80211_ac_from_tid(int tid)
184402219b3aSJohannes Berg {
184502219b3aSJohannes Berg 	return ieee802_1d_to_ac[tid & 7];
184602219b3aSJohannes Berg }
184702219b3aSJohannes Berg 
1848520eb820SKalle Valo void ieee80211_dynamic_ps_enable_work(struct work_struct *work);
1849520eb820SKalle Valo void ieee80211_dynamic_ps_disable_work(struct work_struct *work);
1850520eb820SKalle Valo void ieee80211_dynamic_ps_timer(unsigned long data);
1851a97b77b9SVivek Natarajan void ieee80211_send_nullfunc(struct ieee80211_local *local,
1852a97b77b9SVivek Natarajan 			     struct ieee80211_sub_if_data *sdata,
1853a97b77b9SVivek Natarajan 			     int powersave);
18543cf335d5SKalle Valo void ieee80211_sta_rx_notify(struct ieee80211_sub_if_data *sdata,
18553cf335d5SKalle Valo 			     struct ieee80211_hdr *hdr);
18564e5ff376SFelix Fietkau void ieee80211_sta_tx_notify(struct ieee80211_sub_if_data *sdata,
185702219b3aSJohannes Berg 			     struct ieee80211_hdr *hdr, bool ack, u16 tx_time);
1858520eb820SKalle Valo 
1859ce7c9111SKalle Valo void ieee80211_wake_queues_by_reason(struct ieee80211_hw *hw,
1860445ea4e8SJohannes Berg 				     unsigned long queues,
1861cca07b00SLuciano Coelho 				     enum queue_stop_reason reason,
1862cca07b00SLuciano Coelho 				     bool refcounted);
186326da23b6SLuciano Coelho void ieee80211_stop_vif_queues(struct ieee80211_local *local,
186426da23b6SLuciano Coelho 			       struct ieee80211_sub_if_data *sdata,
186526da23b6SLuciano Coelho 			       enum queue_stop_reason reason);
186626da23b6SLuciano Coelho void ieee80211_wake_vif_queues(struct ieee80211_local *local,
186726da23b6SLuciano Coelho 			       struct ieee80211_sub_if_data *sdata,
186826da23b6SLuciano Coelho 			       enum queue_stop_reason reason);
1869ce7c9111SKalle Valo void ieee80211_stop_queues_by_reason(struct ieee80211_hw *hw,
1870445ea4e8SJohannes Berg 				     unsigned long queues,
1871cca07b00SLuciano Coelho 				     enum queue_stop_reason reason,
1872cca07b00SLuciano Coelho 				     bool refcounted);
187396f5e66eSJohannes Berg void ieee80211_wake_queue_by_reason(struct ieee80211_hw *hw, int queue,
1874cca07b00SLuciano Coelho 				    enum queue_stop_reason reason,
1875cca07b00SLuciano Coelho 				    bool refcounted);
187696f5e66eSJohannes Berg void ieee80211_stop_queue_by_reason(struct ieee80211_hw *hw, int queue,
1877cca07b00SLuciano Coelho 				    enum queue_stop_reason reason,
1878cca07b00SLuciano Coelho 				    bool refcounted);
18793a25a8c8SJohannes Berg void ieee80211_propagate_queue_wake(struct ieee80211_local *local, int queue);
18808f77f384SJohannes Berg void ieee80211_add_pending_skb(struct ieee80211_local *local,
18818f77f384SJohannes Berg 			       struct sk_buff *skb);
1882e3685e03SJohannes Berg void ieee80211_add_pending_skbs(struct ieee80211_local *local,
1883e3685e03SJohannes Berg 				struct sk_buff_head *skbs);
188439ecc01dSJohannes Berg void ieee80211_flush_queues(struct ieee80211_local *local,
18853b24f4c6SEmmanuel Grumbach 			    struct ieee80211_sub_if_data *sdata, bool drop);
18864f9610d5SLiad Kaufman void __ieee80211_flush_queues(struct ieee80211_local *local,
18874f9610d5SLiad Kaufman 			      struct ieee80211_sub_if_data *sdata,
18883b24f4c6SEmmanuel Grumbach 			      unsigned int queues, bool drop);
1889ce7c9111SKalle Valo 
18904afaff17SEmmanuel Grumbach static inline bool ieee80211_can_run_worker(struct ieee80211_local *local)
18914afaff17SEmmanuel Grumbach {
18924afaff17SEmmanuel Grumbach 	/*
18934afaff17SEmmanuel Grumbach 	 * If quiescing is set, we are racing with __ieee80211_suspend.
18944afaff17SEmmanuel Grumbach 	 * __ieee80211_suspend flushes the workers after setting quiescing,
18954afaff17SEmmanuel Grumbach 	 * and we check quiescing / suspended before enqueing new workers.
18964afaff17SEmmanuel Grumbach 	 * We should abort the worker to avoid the races below.
18974afaff17SEmmanuel Grumbach 	 */
18984afaff17SEmmanuel Grumbach 	if (local->quiescing)
18994afaff17SEmmanuel Grumbach 		return false;
19004afaff17SEmmanuel Grumbach 
19014afaff17SEmmanuel Grumbach 	/*
19024afaff17SEmmanuel Grumbach 	 * We might already be suspended if the following scenario occurs:
19034afaff17SEmmanuel Grumbach 	 * __ieee80211_suspend		Control path
19044afaff17SEmmanuel Grumbach 	 *
19054afaff17SEmmanuel Grumbach 	 *				if (local->quiescing)
19064afaff17SEmmanuel Grumbach 	 *					return;
19074afaff17SEmmanuel Grumbach 	 * local->quiescing = true;
19084afaff17SEmmanuel Grumbach 	 * flush_workqueue();
19094afaff17SEmmanuel Grumbach 	 *				queue_work(...);
19104afaff17SEmmanuel Grumbach 	 * local->suspended = true;
19114afaff17SEmmanuel Grumbach 	 * local->quiescing = false;
19124afaff17SEmmanuel Grumbach 	 *				worker starts running...
19134afaff17SEmmanuel Grumbach 	 */
19144afaff17SEmmanuel Grumbach 	if (local->suspended)
19154afaff17SEmmanuel Grumbach 		return false;
19164afaff17SEmmanuel Grumbach 
19174afaff17SEmmanuel Grumbach 	return true;
19184afaff17SEmmanuel Grumbach }
19194afaff17SEmmanuel Grumbach 
1920ba8c3d6fSFelix Fietkau void ieee80211_init_tx_queue(struct ieee80211_sub_if_data *sdata,
1921ba8c3d6fSFelix Fietkau 			     struct sta_info *sta,
1922ba8c3d6fSFelix Fietkau 			     struct txq_info *txq, int tid);
192346900298SJohannes Berg void ieee80211_send_auth(struct ieee80211_sub_if_data *sdata,
1924700e8ea6SJouni Malinen 			 u16 transaction, u16 auth_alg, u16 status,
19254a3cb702SJohannes Berg 			 const u8 *extra, size_t extra_len, const u8 *bssid,
19261672c0e3SJohannes Berg 			 const u8 *da, const u8 *key, u8 key_len, u8 key_idx,
19271672c0e3SJohannes Berg 			 u32 tx_flags);
19286ae16775SAntonio Quartulli void ieee80211_send_deauth_disassoc(struct ieee80211_sub_if_data *sdata,
19296ae16775SAntonio Quartulli 				    const u8 *bssid, u16 stype, u16 reason,
19306ae16775SAntonio Quartulli 				    bool send_frame, u8 *frame_buf);
1931de95a54bSJohannes Berg int ieee80211_build_preq_ies(struct ieee80211_local *local, u8 *buffer,
1932c56ef672SDavid Spinadel 			     size_t buffer_len,
1933c56ef672SDavid Spinadel 			     struct ieee80211_scan_ies *ie_desc,
1934c56ef672SDavid Spinadel 			     const u8 *ie, size_t ie_len,
1935c56ef672SDavid Spinadel 			     u8 bands_used, u32 *rate_masks,
19362103dec1SSimon Wunderlich 			     struct cfg80211_chan_def *chandef);
1937a619a4c0SJuuso Oikarinen struct sk_buff *ieee80211_build_probe_req(struct ieee80211_sub_if_data *sdata,
1938a344d677SJohannes Berg 					  const u8 *src, const u8 *dst,
1939a344d677SJohannes Berg 					  u32 ratemask,
19406b77863bSJohannes Berg 					  struct ieee80211_channel *chan,
1941a619a4c0SJuuso Oikarinen 					  const u8 *ssid, size_t ssid_len,
1942a806c558SPaul Stewart 					  const u8 *ie, size_t ie_len,
1943a806c558SPaul Stewart 					  bool directed);
1944a344d677SJohannes Berg void ieee80211_send_probe_req(struct ieee80211_sub_if_data *sdata,
1945a344d677SJohannes Berg 			      const u8 *src, const u8 *dst,
1946de95a54bSJohannes Berg 			      const u8 *ssid, size_t ssid_len,
1947a806c558SPaul Stewart 			      const u8 *ie, size_t ie_len,
19481672c0e3SJohannes Berg 			      u32 ratemask, bool directed, u32 tx_flags,
194955de908aSJohannes Berg 			      struct ieee80211_channel *channel, bool scan);
195046900298SJohannes Berg 
19512103dec1SSimon Wunderlich u32 ieee80211_sta_get_rates(struct ieee80211_sub_if_data *sdata,
195246900298SJohannes Berg 			    struct ieee802_11_elems *elems,
19539ebb61a2SAshok Nagarajan 			    enum ieee80211_band band, u32 *basic_rates);
1954687da132SEmmanuel Grumbach int __ieee80211_request_smps_mgd(struct ieee80211_sub_if_data *sdata,
1955687da132SEmmanuel Grumbach 				 enum ieee80211_smps_mode smps_mode);
1956687da132SEmmanuel Grumbach int __ieee80211_request_smps_ap(struct ieee80211_sub_if_data *sdata,
19570f78231bSJohannes Berg 				enum ieee80211_smps_mode smps_mode);
195804ecd257SJohannes Berg void ieee80211_recalc_smps(struct ieee80211_sub_if_data *sdata);
195921f659bfSEliad Peller void ieee80211_recalc_min_chandef(struct ieee80211_sub_if_data *sdata);
196046900298SJohannes Berg 
19618e664fb3SJohannes Berg size_t ieee80211_ie_split_vendor(const u8 *ies, size_t ielen, size_t offset);
1962ef96a842SBen Greear u8 *ieee80211_ie_build_ht_cap(u8 *pos, struct ieee80211_sta_ht_cap *ht_cap,
196342e7aa77SAlexander Simon 			      u16 cap);
1964074d46d1SJohannes Berg u8 *ieee80211_ie_build_ht_oper(u8 *pos, struct ieee80211_sta_ht_cap *ht_cap,
19654bf88530SJohannes Berg 			       const struct cfg80211_chan_def *chandef,
1966431e3154SAshok Nagarajan 			       u16 prot_mode);
1967ba0afa2fSMahesh Palivela u8 *ieee80211_ie_build_vht_cap(u8 *pos, struct ieee80211_sta_vht_cap *vht_cap,
1968ba0afa2fSMahesh Palivela 			       u32 cap);
1969fb28ec0cSArik Nemtsov u8 *ieee80211_ie_build_vht_oper(u8 *pos, struct ieee80211_sta_vht_cap *vht_cap,
1970fb28ec0cSArik Nemtsov 				const struct cfg80211_chan_def *chandef);
19712103dec1SSimon Wunderlich int ieee80211_parse_bitrates(struct cfg80211_chan_def *chandef,
19722103dec1SSimon Wunderlich 			     const struct ieee80211_supported_band *sband,
19732103dec1SSimon Wunderlich 			     const u8 *srates, int srates_len, u32 *rates);
1974fc8a7321SJohannes Berg int ieee80211_add_srates_ie(struct ieee80211_sub_if_data *sdata,
19756b77863bSJohannes Berg 			    struct sk_buff *skb, bool need_basic,
19766b77863bSJohannes Berg 			    enum ieee80211_band band);
1977fc8a7321SJohannes Berg int ieee80211_add_ext_srates_ie(struct ieee80211_sub_if_data *sdata,
19786b77863bSJohannes Berg 				struct sk_buff *skb, bool need_basic,
19796b77863bSJohannes Berg 				enum ieee80211_band band);
198040b861a0SArik Nemtsov u8 *ieee80211_add_wmm_info_ie(u8 *buf, u8 qosinfo);
19818e664fb3SJohannes Berg 
1982f444de05SJohannes Berg /* channel management */
19834bf88530SJohannes Berg void ieee80211_ht_oper_to_chandef(struct ieee80211_channel *control_chan,
19844a3cb702SJohannes Berg 				  const struct ieee80211_ht_operation *ht_oper,
19854bf88530SJohannes Berg 				  struct cfg80211_chan_def *chandef);
1986abcff6efSJanusz.Dziedzic@tieto.com void ieee80211_vht_oper_to_chandef(struct ieee80211_channel *control_chan,
1987abcff6efSJanusz.Dziedzic@tieto.com 				   const struct ieee80211_vht_operation *oper,
1988abcff6efSJanusz.Dziedzic@tieto.com 				   struct cfg80211_chan_def *chandef);
1989e6b7cde4SSimon Wunderlich u32 ieee80211_chandef_downgrade(struct cfg80211_chan_def *c);
1990f444de05SJohannes Berg 
1991d01a1e65SMichal Kazior int __must_check
1992d01a1e65SMichal Kazior ieee80211_vif_use_channel(struct ieee80211_sub_if_data *sdata,
19934bf88530SJohannes Berg 			  const struct cfg80211_chan_def *chandef,
1994d01a1e65SMichal Kazior 			  enum ieee80211_chanctx_mode mode);
19952c9b7359SJohannes Berg int __must_check
199611335a55SLuciano Coelho ieee80211_vif_reserve_chanctx(struct ieee80211_sub_if_data *sdata,
199711335a55SLuciano Coelho 			      const struct cfg80211_chan_def *chandef,
199809332481SMichal Kazior 			      enum ieee80211_chanctx_mode mode,
199909332481SMichal Kazior 			      bool radar_required);
200011335a55SLuciano Coelho int __must_check
20015bcae31dSMichal Kazior ieee80211_vif_use_reserved_context(struct ieee80211_sub_if_data *sdata);
200211335a55SLuciano Coelho int ieee80211_vif_unreserve_chanctx(struct ieee80211_sub_if_data *sdata);
200311335a55SLuciano Coelho 
200411335a55SLuciano Coelho int __must_check
20052c9b7359SJohannes Berg ieee80211_vif_change_bandwidth(struct ieee80211_sub_if_data *sdata,
20062c9b7359SJohannes Berg 			       const struct cfg80211_chan_def *chandef,
20072c9b7359SJohannes Berg 			       u32 *changed);
2008d01a1e65SMichal Kazior void ieee80211_vif_release_channel(struct ieee80211_sub_if_data *sdata);
20094d76d21bSJohannes Berg void ieee80211_vif_vlan_copy_chanctx(struct ieee80211_sub_if_data *sdata);
20101f4ac5a6SJohannes Berg void ieee80211_vif_copy_chanctx_to_vlans(struct ieee80211_sub_if_data *sdata,
20111f4ac5a6SJohannes Berg 					 bool clear);
2012c0166da9SMichal Kazior int ieee80211_chanctx_refcount(struct ieee80211_local *local,
2013c0166da9SMichal Kazior 			       struct ieee80211_chanctx *ctx);
2014d01a1e65SMichal Kazior 
201504ecd257SJohannes Berg void ieee80211_recalc_smps_chanctx(struct ieee80211_local *local,
201604ecd257SJohannes Berg 				   struct ieee80211_chanctx *chanctx);
201721f659bfSEliad Peller void ieee80211_recalc_chanctx_min_def(struct ieee80211_local *local,
201821f659bfSEliad Peller 				      struct ieee80211_chanctx *ctx);
20195cbc95a7SEliad Peller bool ieee80211_is_radar_required(struct ieee80211_local *local);
2020164eb02dSSimon Wunderlich 
2021164eb02dSSimon Wunderlich void ieee80211_dfs_cac_timer(unsigned long data);
2022164eb02dSSimon Wunderlich void ieee80211_dfs_cac_timer_work(struct work_struct *work);
2023164eb02dSSimon Wunderlich void ieee80211_dfs_cac_cancel(struct ieee80211_local *local);
2024164eb02dSSimon Wunderlich void ieee80211_dfs_radar_detected_work(struct work_struct *work);
2025c6da674aSChun-Yeow Yeoh int ieee80211_send_action_csa(struct ieee80211_sub_if_data *sdata,
2026c6da674aSChun-Yeow Yeoh 			      struct cfg80211_csa_settings *csa_settings);
202704ecd257SJohannes Berg 
20282475b1ccSMax Stepanov bool ieee80211_cs_valid(const struct ieee80211_cipher_scheme *cs);
20292475b1ccSMax Stepanov bool ieee80211_cs_list_valid(const struct ieee80211_cipher_scheme *cs, int n);
20302475b1ccSMax Stepanov const struct ieee80211_cipher_scheme *
20312475b1ccSMax Stepanov ieee80211_cs_get(struct ieee80211_local *local, u32 cipher,
20322475b1ccSMax Stepanov 		 enum nl80211_iftype iftype);
20332475b1ccSMax Stepanov int ieee80211_cs_headroom(struct ieee80211_local *local,
20342475b1ccSMax Stepanov 			  struct cfg80211_crypto_settings *crypto,
20352475b1ccSMax Stepanov 			  enum nl80211_iftype iftype);
2036057d5f4bSThomas Pedersen void ieee80211_recalc_dtim(struct ieee80211_local *local,
2037057d5f4bSThomas Pedersen 			   struct ieee80211_sub_if_data *sdata);
203873de86a3SLuciano Coelho int ieee80211_check_combinations(struct ieee80211_sub_if_data *sdata,
203973de86a3SLuciano Coelho 				 const struct cfg80211_chan_def *chandef,
204073de86a3SLuciano Coelho 				 enum ieee80211_chanctx_mode chanmode,
204173de86a3SLuciano Coelho 				 u8 radar_detect);
20426fa001bcSMichal Kazior int ieee80211_max_num_channels(struct ieee80211_local *local);
20430fabfaafSArik Nemtsov enum nl80211_chan_width ieee80211_get_sta_bw(struct ieee80211_sta *sta);
20440fabfaafSArik Nemtsov void ieee80211_recalc_chanctx_chantype(struct ieee80211_local *local,
20450fabfaafSArik Nemtsov 				       struct ieee80211_chanctx *ctx);
20462475b1ccSMax Stepanov 
204795224fe8SArik Nemtsov /* TDLS */
204895224fe8SArik Nemtsov int ieee80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
20493b3a0162SJohannes Berg 			const u8 *peer, u8 action_code, u8 dialog_token,
205095224fe8SArik Nemtsov 			u16 status_code, u32 peer_capability,
205131fa97c5SArik Nemtsov 			bool initiator, const u8 *extra_ies,
205231fa97c5SArik Nemtsov 			size_t extra_ies_len);
205395224fe8SArik Nemtsov int ieee80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
20543b3a0162SJohannes Berg 			const u8 *peer, enum nl80211_tdls_operation oper);
2055c10a1993SJohannes Berg void ieee80211_tdls_peer_del_work(struct work_struct *wk);
2056a7a6bdd0SArik Nemtsov int ieee80211_tdls_channel_switch(struct wiphy *wiphy, struct net_device *dev,
2057a7a6bdd0SArik Nemtsov 				  const u8 *addr, u8 oper_class,
2058a7a6bdd0SArik Nemtsov 				  struct cfg80211_chan_def *chandef);
2059a7a6bdd0SArik Nemtsov void ieee80211_tdls_cancel_channel_switch(struct wiphy *wiphy,
2060a7a6bdd0SArik Nemtsov 					  struct net_device *dev,
2061a7a6bdd0SArik Nemtsov 					  const u8 *addr);
2062d51c2ea3SArik Nemtsov void ieee80211_teardown_tdls_peers(struct ieee80211_sub_if_data *sdata);
2063c8ff71e6SArik Nemtsov void ieee80211_tdls_chsw_work(struct work_struct *wk);
206495224fe8SArik Nemtsov 
2065b7ffbd7eSJohannes Berg extern const struct ethtool_ops ieee80211_ethtool_ops;
2066b7ffbd7eSJohannes Berg 
2067f4ea83ddSJohannes Berg #ifdef CONFIG_MAC80211_NOINLINE
2068d9e8a70fSJohannes Berg #define debug_noinline noinline
2069d9e8a70fSJohannes Berg #else
2070d9e8a70fSJohannes Berg #define debug_noinline
2071d9e8a70fSJohannes Berg #endif
2072d9e8a70fSJohannes Berg 
2073f0706e82SJiri Benc #endif /* IEEE80211_I_H */
2074