xref: /openbmc/linux/net/mac80211/ieee80211_i.h (revision 204a7dbc)
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>
642bd20d9SAviya Erenfeld  * Copyright 2013-2015  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>
33fa962b92SMichal Kazior #include <net/fq.h>
342c8dccc7SJohannes Berg #include "key.h"
35f0706e82SJiri Benc #include "sta_info.h"
36bdcbd8e0SJohannes Berg #include "debug.h"
37f0706e82SJiri Benc 
383beea351SJohannes Berg extern const struct cfg80211_ops mac80211_config_ops;
393beea351SJohannes Berg 
409cfb0009SJohannes Berg struct ieee80211_local;
41f0706e82SJiri Benc 
42f0706e82SJiri Benc /* Maximum number of broadcast/multicast frames to buffer when some of the
43f0706e82SJiri Benc  * associated stations are using power saving. */
44f0706e82SJiri Benc #define AP_MAX_BC_BUFFER 128
45f0706e82SJiri Benc 
46f0706e82SJiri Benc /* Maximum number of frames buffered to all STAs, including multicast frames.
47f0706e82SJiri Benc  * Note: increasing this limit increases the potential memory requirement. Each
48f0706e82SJiri Benc  * frame can be up to about 2 kB long. */
49f0706e82SJiri Benc #define TOTAL_MAX_TX_BUFFER 512
50f0706e82SJiri Benc 
51f0706e82SJiri Benc /* Required encryption head and tailroom */
52f0706e82SJiri Benc #define IEEE80211_ENCRYPT_HEADROOM 8
53765cb46aSJouni Malinen #define IEEE80211_ENCRYPT_TAILROOM 18
54f0706e82SJiri Benc 
55f0706e82SJiri Benc /* IEEE 802.11 (Ch. 9.5 Defragmentation) requires support for concurrent
56f0706e82SJiri Benc  * reception of at least three fragmented frames. This limit can be increased
57f0706e82SJiri Benc  * by changing this define, at the cost of slower frame reassembly and
58f0706e82SJiri Benc  * increased memory use (about 2 kB of RAM per entry). */
59f0706e82SJiri Benc #define IEEE80211_FRAGMENT_MAX 4
60f0706e82SJiri Benc 
611ea6f9c0SJohannes Berg /* power level hasn't been configured (or set to automatic) */
621ea6f9c0SJohannes Berg #define IEEE80211_UNSET_POWER_LEVEL	INT_MIN
631ea6f9c0SJohannes Berg 
64d6a4ed6fSArik Nemtsov /*
65aa75ebc2SMichal Kazior  * Some APs experience problems when working with U-APSD. Decreasing the
66aa75ebc2SMichal Kazior  * probability of that happening by using legacy mode for all ACs but VO isn't
67aa75ebc2SMichal Kazior  * enough.
68aa75ebc2SMichal Kazior  *
69aa75ebc2SMichal Kazior  * Cisco 4410N originally forced us to enable VO by default only because it
70aa75ebc2SMichal Kazior  * treated non-VO ACs as legacy.
71aa75ebc2SMichal Kazior  *
72aa75ebc2SMichal Kazior  * However some APs (notably Netgear R7000) silently reclassify packets to
73aa75ebc2SMichal Kazior  * different ACs. Since u-APSD ACs require trigger frames for frame retrieval
74aa75ebc2SMichal Kazior  * clients would never see some frames (e.g. ARP responses) or would fetch them
75aa75ebc2SMichal Kazior  * accidentally after a long time.
76aa75ebc2SMichal Kazior  *
77aa75ebc2SMichal Kazior  * It makes little sense to enable u-APSD queues by default because it needs
78aa75ebc2SMichal Kazior  * userspace applications to be aware of it to actually take advantage of the
79aa75ebc2SMichal Kazior  * possible additional powersavings. Implicitly depending on driver autotrigger
80aa75ebc2SMichal Kazior  * frame support doesn't make much sense.
81d6a4ed6fSArik Nemtsov  */
82aa75ebc2SMichal Kazior #define IEEE80211_DEFAULT_UAPSD_QUEUES 0
83ab13315aSKalle Valo 
84ab13315aSKalle Valo #define IEEE80211_DEFAULT_MAX_SP_LEN		\
85ab13315aSKalle Valo 	IEEE80211_WMM_IE_STA_QOSINFO_SP_ALL
86ab13315aSKalle Valo 
87f438ceb8SEmmanuel Grumbach extern const u8 ieee80211_ac_to_qos_mask[IEEE80211_NUM_ACS];
88f438ceb8SEmmanuel Grumbach 
896ae16775SAntonio Quartulli #define IEEE80211_DEAUTH_FRAME_LEN	(24 /* hdr */ + 2 /* reason */)
906ae16775SAntonio Quartulli 
91167e33f4SAyala Beker #define IEEE80211_MAX_NAN_INSTANCE_ID 255
92167e33f4SAyala Beker 
93f0706e82SJiri Benc struct ieee80211_fragment_entry {
94f0706e82SJiri Benc 	struct sk_buff_head skb_list;
9569f13223SJohannes Berg 	unsigned long first_frag_time;
9669f13223SJohannes Berg 	u16 seq;
9769f13223SJohannes Berg 	u16 extra_len;
9869f13223SJohannes Berg 	u16 last_frag;
9969f13223SJohannes Berg 	u8 rx_queue;
1009acc54beSJohannes Berg 	bool check_sequential_pn; /* needed for CCMP/GCMP */
101f0706e82SJiri Benc 	u8 last_pn[6]; /* PN of the last fragment if CCMP was used */
102f0706e82SJiri Benc };
103f0706e82SJiri Benc 
104f0706e82SJiri Benc 
105c2b13452SJohannes Berg struct ieee80211_bss {
106ef429dadSJohannes Berg 	u32 device_ts_beacon, device_ts_presp;
1078c358bcdSJohannes Berg 
10843ac2ca3SJouni Malinen 	bool wmm_used;
109ab13315aSKalle Valo 	bool uapsd_supported;
11000d3f14cSJohannes Berg 
111f0706e82SJiri Benc #define IEEE80211_MAX_SUPP_RATES 32
112f0706e82SJiri Benc 	u8 supp_rates[IEEE80211_MAX_SUPP_RATES];
113f0706e82SJiri Benc 	size_t supp_rates_len;
114817cee76SAlexander Bondar 	struct ieee80211_rate *beacon_rate;
115f0706e82SJiri Benc 
11600d3f14cSJohannes Berg 	/*
11725985edcSLucas De Marchi 	 * During association, we save an ERP value from a probe response so
1185628221cSDaniel Drake 	 * that we can feed ERP info to the driver when handling the
1195628221cSDaniel Drake 	 * association completes. these fields probably won't be up-to-date
12000d3f14cSJohannes Berg 	 * otherwise, you probably don't want to use them.
12100d3f14cSJohannes Berg 	 */
12200d3f14cSJohannes Berg 	bool has_erp_value;
1235628221cSDaniel Drake 	u8 erp_value;
124fcff4f10SPaul Stewart 
125fcff4f10SPaul Stewart 	/* Keep track of the corruption of the last beacon/probe response. */
126fcff4f10SPaul Stewart 	u8 corrupt_data;
127fcff4f10SPaul Stewart 
128fcff4f10SPaul Stewart 	/* Keep track of what bits of information we have valid info for. */
129fcff4f10SPaul Stewart 	u8 valid_data;
130fcff4f10SPaul Stewart };
131fcff4f10SPaul Stewart 
132fcff4f10SPaul Stewart /**
133fcff4f10SPaul Stewart  * enum ieee80211_corrupt_data_flags - BSS data corruption flags
134fcff4f10SPaul Stewart  * @IEEE80211_BSS_CORRUPT_BEACON: last beacon frame received was corrupted
135fcff4f10SPaul Stewart  * @IEEE80211_BSS_CORRUPT_PROBE_RESP: last probe response received was corrupted
136fcff4f10SPaul Stewart  *
137fcff4f10SPaul Stewart  * These are bss flags that are attached to a bss in the
138fcff4f10SPaul Stewart  * @corrupt_data field of &struct ieee80211_bss.
139fcff4f10SPaul Stewart  */
140fcff4f10SPaul Stewart enum ieee80211_bss_corrupt_data_flags {
141fcff4f10SPaul Stewart 	IEEE80211_BSS_CORRUPT_BEACON		= BIT(0),
142fcff4f10SPaul Stewart 	IEEE80211_BSS_CORRUPT_PROBE_RESP	= BIT(1)
143fcff4f10SPaul Stewart };
144fcff4f10SPaul Stewart 
145fcff4f10SPaul Stewart /**
146fcff4f10SPaul Stewart  * enum ieee80211_valid_data_flags - BSS valid data flags
147fcff4f10SPaul Stewart  * @IEEE80211_BSS_VALID_WMM: WMM/UAPSD data was gathered from non-corrupt IE
148fcff4f10SPaul Stewart  * @IEEE80211_BSS_VALID_RATES: Supported rates were gathered from non-corrupt IE
149fcff4f10SPaul Stewart  * @IEEE80211_BSS_VALID_ERP: ERP flag was gathered from non-corrupt IE
150fcff4f10SPaul Stewart  *
151fcff4f10SPaul Stewart  * These are bss flags that are attached to a bss in the
152fcff4f10SPaul Stewart  * @valid_data field of &struct ieee80211_bss.  They show which parts
153d070f913SStephen Hemminger  * of the data structure were received as a result of an un-corrupted
154fcff4f10SPaul Stewart  * beacon/probe response.
155fcff4f10SPaul Stewart  */
156fcff4f10SPaul Stewart enum ieee80211_bss_valid_data_flags {
157fcff4f10SPaul Stewart 	IEEE80211_BSS_VALID_WMM			= BIT(1),
158fcff4f10SPaul Stewart 	IEEE80211_BSS_VALID_RATES		= BIT(2),
159fcff4f10SPaul Stewart 	IEEE80211_BSS_VALID_ERP			= BIT(3)
160f0706e82SJiri Benc };
161f0706e82SJiri Benc 
1629efeccacSMichael S. Tsirkin typedef unsigned __bitwise ieee80211_tx_result;
1639ae54c84SJohannes Berg #define TX_CONTINUE	((__force ieee80211_tx_result) 0u)
1649ae54c84SJohannes Berg #define TX_DROP		((__force ieee80211_tx_result) 1u)
1659ae54c84SJohannes Berg #define TX_QUEUED	((__force ieee80211_tx_result) 2u)
1669ae54c84SJohannes Berg 
1675cf121c3SJohannes Berg #define IEEE80211_TX_UNICAST		BIT(1)
1685cf121c3SJohannes Berg #define IEEE80211_TX_PS_BUFFERED	BIT(2)
1699ae54c84SJohannes Berg 
1705cf121c3SJohannes Berg struct ieee80211_tx_data {
171f0706e82SJiri Benc 	struct sk_buff *skb;
172252b86c4SJohannes Berg 	struct sk_buff_head skbs;
173f0706e82SJiri Benc 	struct ieee80211_local *local;
174f0706e82SJiri Benc 	struct ieee80211_sub_if_data *sdata;
175f0706e82SJiri Benc 	struct sta_info *sta;
176f0706e82SJiri Benc 	struct ieee80211_key *key;
1770d528d85SFelix Fietkau 	struct ieee80211_tx_rate rate;
1785cf121c3SJohannes Berg 
179056cdd59SJohannes Berg 	unsigned int flags;
1805cf121c3SJohannes Berg };
1815cf121c3SJohannes Berg 
1825cf121c3SJohannes Berg 
1839efeccacSMichael S. Tsirkin typedef unsigned __bitwise ieee80211_rx_result;
1845cf121c3SJohannes Berg #define RX_CONTINUE		((__force ieee80211_rx_result) 0u)
1855cf121c3SJohannes Berg #define RX_DROP_UNUSABLE	((__force ieee80211_rx_result) 1u)
1865cf121c3SJohannes Berg #define RX_DROP_MONITOR		((__force ieee80211_rx_result) 2u)
1875cf121c3SJohannes Berg #define RX_QUEUED		((__force ieee80211_rx_result) 3u)
1885cf121c3SJohannes Berg 
189554891e6SJohannes Berg /**
190554891e6SJohannes Berg  * enum ieee80211_packet_rx_flags - packet RX flags
191554891e6SJohannes Berg  * @IEEE80211_RX_AMSDU: a-MSDU packet
192554891e6SJohannes Berg  * @IEEE80211_RX_MALFORMED_ACTION_FRM: action frame is malformed
1934cfda47bSChristian Lamparter  * @IEEE80211_RX_DEFERRED_RELEASE: frame was subjected to receive reordering
194554891e6SJohannes Berg  *
195554891e6SJohannes Berg  * These are per-frame flags that are attached to a frame in the
196554891e6SJohannes Berg  * @rx_flags field of &struct ieee80211_rx_status.
197554891e6SJohannes Berg  */
198554891e6SJohannes Berg enum ieee80211_packet_rx_flags {
199554891e6SJohannes Berg 	IEEE80211_RX_AMSDU			= BIT(3),
200554891e6SJohannes Berg 	IEEE80211_RX_MALFORMED_ACTION_FRM	= BIT(4),
2014cfda47bSChristian Lamparter 	IEEE80211_RX_DEFERRED_RELEASE		= BIT(5),
202554891e6SJohannes Berg };
203554891e6SJohannes Berg 
204554891e6SJohannes Berg /**
205554891e6SJohannes Berg  * enum ieee80211_rx_flags - RX data flags
206554891e6SJohannes Berg  *
207554891e6SJohannes Berg  * @IEEE80211_RX_CMNTR: received on cooked monitor already
208ee971924SJohannes Berg  * @IEEE80211_RX_BEACON_REPORTED: This frame was already reported
209ee971924SJohannes Berg  *	to cfg80211_report_obss_beacon().
210554891e6SJohannes Berg  *
211554891e6SJohannes Berg  * These flags are used across handling multiple interfaces
212554891e6SJohannes Berg  * for a single frame.
213554891e6SJohannes Berg  */
214554891e6SJohannes Berg enum ieee80211_rx_flags {
215554891e6SJohannes Berg 	IEEE80211_RX_CMNTR		= BIT(0),
216ee971924SJohannes Berg 	IEEE80211_RX_BEACON_REPORTED	= BIT(1),
217554891e6SJohannes Berg };
2185cf121c3SJohannes Berg 
2195cf121c3SJohannes Berg struct ieee80211_rx_data {
220af9f9b22SJohannes Berg 	struct napi_struct *napi;
2215cf121c3SJohannes Berg 	struct sk_buff *skb;
2225cf121c3SJohannes Berg 	struct ieee80211_local *local;
2235cf121c3SJohannes Berg 	struct ieee80211_sub_if_data *sdata;
2245cf121c3SJohannes Berg 	struct sta_info *sta;
2255cf121c3SJohannes Berg 	struct ieee80211_key *key;
226056cdd59SJohannes Berg 
227056cdd59SJohannes Berg 	unsigned int flags;
2289e26297aSJohannes Berg 
2299e26297aSJohannes Berg 	/*
2309e26297aSJohannes Berg 	 * Index into sequence numbers array, 0..16
2319e26297aSJohannes Berg 	 * since the last (16) is used for non-QoS,
2329e26297aSJohannes Berg 	 * will be 16 on non-QoS frames.
2339e26297aSJohannes Berg 	 */
2349e26297aSJohannes Berg 	int seqno_idx;
2359e26297aSJohannes Berg 
2369e26297aSJohannes Berg 	/*
2379e26297aSJohannes Berg 	 * Index into the security IV/PN arrays, 0..16
2389e26297aSJohannes Berg 	 * since the last (16) is used for CCMP-encrypted
2399e26297aSJohannes Berg 	 * management frames, will be set to 16 on mgmt
2409e26297aSJohannes Berg 	 * frames and 0 on non-QoS frames.
2419e26297aSJohannes Berg 	 */
2429e26297aSJohannes Berg 	int security_idx;
2439e26297aSJohannes Berg 
24450741ae0SJohannes Berg 	u32 tkip_iv32;
24550741ae0SJohannes Berg 	u16 tkip_iv16;
246f0706e82SJiri Benc };
247f0706e82SJiri Benc 
248af296bdbSMichal Kazior struct ieee80211_csa_settings {
249af296bdbSMichal Kazior 	const u16 *counter_offsets_beacon;
250af296bdbSMichal Kazior 	const u16 *counter_offsets_presp;
251af296bdbSMichal Kazior 
252af296bdbSMichal Kazior 	int n_counter_offsets_beacon;
253af296bdbSMichal Kazior 	int n_counter_offsets_presp;
254af296bdbSMichal Kazior 
255af296bdbSMichal Kazior 	u8 count;
256af296bdbSMichal Kazior };
257af296bdbSMichal Kazior 
2585dfdaf58SJohannes Berg struct beacon_data {
2595dfdaf58SJohannes Berg 	u8 *head, *tail;
2605dfdaf58SJohannes Berg 	int head_len, tail_len;
26143552be1SThomas Pedersen 	struct ieee80211_meshconf_ie *meshconf;
262af296bdbSMichal Kazior 	u16 csa_counter_offsets[IEEE80211_MAX_CSA_COUNTERS_NUM];
263af296bdbSMichal Kazior 	u8 csa_current_counter;
2648860020eSJohannes Berg 	struct rcu_head rcu_head;
2655dfdaf58SJohannes Berg };
2665dfdaf58SJohannes Berg 
267aa7a0080SEyal Shapira struct probe_resp {
268aa7a0080SEyal Shapira 	struct rcu_head rcu_head;
269aa7a0080SEyal Shapira 	int len;
270af296bdbSMichal Kazior 	u16 csa_counter_offsets[IEEE80211_MAX_CSA_COUNTERS_NUM];
271aa7a0080SEyal Shapira 	u8 data[0];
272aa7a0080SEyal Shapira };
273aa7a0080SEyal Shapira 
274d012a605SMarco Porsch struct ps_data {
275d012a605SMarco Porsch 	/* yes, this looks ugly, but guarantees that we can later use
276d012a605SMarco Porsch 	 * bitmap_empty :)
277d012a605SMarco Porsch 	 * NB: don't touch this bitmap, use sta_info_{set,clear}_tim_bit */
2785fe2bb86SJoe Perches 	u8 tim[sizeof(unsigned long) * BITS_TO_LONGS(IEEE80211_MAX_AID + 1)]
2795fe2bb86SJoe Perches 			__aligned(__alignof__(unsigned long));
280d012a605SMarco Porsch 	struct sk_buff_head bc_buf;
281d012a605SMarco Porsch 	atomic_t num_sta_ps; /* number of stations in PS mode */
282d012a605SMarco Porsch 	int dtim_count;
283d012a605SMarco Porsch 	bool dtim_bc_mc;
284d012a605SMarco Porsch };
285d012a605SMarco Porsch 
286f0706e82SJiri Benc struct ieee80211_if_ap {
28740b275b6SJohannes Berg 	struct beacon_data __rcu *beacon;
288aa7a0080SEyal Shapira 	struct probe_resp __rcu *probe_resp;
289f0706e82SJiri Benc 
29073da7d5bSSimon Wunderlich 	/* to be used after channel switch. */
29173da7d5bSSimon Wunderlich 	struct cfg80211_beacon_data *next_beacon;
2924e141dadSMichal Kazior 	struct list_head vlans; /* write-protected with RTNL and local->mtx */
2930ec3ca44SJohannes Berg 
294d012a605SMarco Porsch 	struct ps_data ps;
295030ef8f8SFelix Fietkau 	atomic_t num_mcast_sta; /* number of stations receiving multicast */
296687da132SEmmanuel Grumbach 	enum ieee80211_smps_mode req_smps, /* requested smps mode */
297687da132SEmmanuel Grumbach 			 driver_smps_mode; /* smps mode request */
298687da132SEmmanuel Grumbach 
299687da132SEmmanuel Grumbach 	struct work_struct request_smps_work;
300ebceec86SMichael Braun 	bool multicast_to_unicast;
301f0706e82SJiri Benc };
302f0706e82SJiri Benc 
303f0706e82SJiri Benc struct ieee80211_if_wds {
304f0706e82SJiri Benc 	struct sta_info *sta;
305056cdd59SJohannes Berg 	u8 remote_addr[ETH_ALEN];
306f0706e82SJiri Benc };
307f0706e82SJiri Benc 
308f0706e82SJiri Benc struct ieee80211_if_vlan {
3094e141dadSMichal Kazior 	struct list_head list; /* write-protected with RTNL and local->mtx */
310f14543eeSFelix Fietkau 
311f14543eeSFelix Fietkau 	/* used for all tx if the VLAN is configured to 4-addr mode */
31240b275b6SJohannes Berg 	struct sta_info __rcu *sta;
31372f15d53SMichael Braun 	atomic_t num_mcast_sta; /* number of stations receiving multicast */
314f0706e82SJiri Benc };
315f0706e82SJiri Benc 
316ee385855SLuis Carlos Cobo struct mesh_stats {
317c8a61a7dSDaniel Walker 	__u32 fwded_mcast;		/* Mesh forwarded multicast frames */
318c8a61a7dSDaniel Walker 	__u32 fwded_unicast;		/* Mesh forwarded unicast frames */
319c8a61a7dSDaniel Walker 	__u32 fwded_frames;		/* Mesh total forwarded frames */
320ee385855SLuis Carlos Cobo 	__u32 dropped_frames_ttl;	/* Not transmitted since mesh_ttl == 0*/
321ee385855SLuis Carlos Cobo 	__u32 dropped_frames_no_route;	/* Not transmitted, no route found */
322cfee66b0SJavier Cardona 	__u32 dropped_frames_congestion;/* Not forwarded due to congestion */
323ee385855SLuis Carlos Cobo };
324ee385855SLuis Carlos Cobo 
325ee385855SLuis Carlos Cobo #define PREQ_Q_F_START		0x1
326ee385855SLuis Carlos Cobo #define PREQ_Q_F_REFRESH	0x2
327ee385855SLuis Carlos Cobo struct mesh_preq_queue {
328ee385855SLuis Carlos Cobo 	struct list_head list;
329ee385855SLuis Carlos Cobo 	u8 dst[ETH_ALEN];
330ee385855SLuis Carlos Cobo 	u8 flags;
331ee385855SLuis Carlos Cobo };
332ee385855SLuis Carlos Cobo 
3332eb278e0SJohannes Berg struct ieee80211_roc_work {
33477fdaa12SJohannes Berg 	struct list_head list;
335af6b6374SJohannes Berg 
336af6b6374SJohannes Berg 	struct ieee80211_sub_if_data *sdata;
337af6b6374SJohannes Berg 
338f679f65dSJohannes Berg 	struct ieee80211_channel *chan;
339af6b6374SJohannes Berg 
3402eb278e0SJohannes Berg 	bool started, abort, hw_begun, notified;
341b4b177a5SJohannes Berg 	bool on_channel;
342f679f65dSJohannes Berg 
343aaa016ccSJohannes Berg 	unsigned long start_time;
344e4da8c37SJohannes Berg 
3452eb278e0SJohannes Berg 	u32 duration, req_duration;
346f30221e4SJohannes Berg 	struct sk_buff *frame;
34750febf6aSJohannes Berg 	u64 cookie, mgmt_tx_cookie;
348d339d5caSIlan Peer 	enum ieee80211_roc_type type;
34977fdaa12SJohannes Berg };
35077fdaa12SJohannes Berg 
35146900298SJohannes Berg /* flags used in struct ieee80211_if_managed.flags */
352ab1faeadSJohannes Berg enum ieee80211_sta_flags {
353b291ba11SJohannes Berg 	IEEE80211_STA_CONNECTION_POLL	= BIT(1),
354b291ba11SJohannes Berg 	IEEE80211_STA_CONTROL_PORT	= BIT(2),
355a8243b72SJohannes Berg 	IEEE80211_STA_DISABLE_HT	= BIT(4),
356b291ba11SJohannes Berg 	IEEE80211_STA_MFP_ENABLED	= BIT(6),
357ab13315aSKalle Valo 	IEEE80211_STA_UAPSD_ENABLED	= BIT(7),
358375177bfSVivek Natarajan 	IEEE80211_STA_NULLFUNC_ACKED	= BIT(8),
35917e4ec14SJouni Malinen 	IEEE80211_STA_RESET_SIGNAL_AVE	= BIT(9),
36024398e39SJohannes Berg 	IEEE80211_STA_DISABLE_40MHZ	= BIT(10),
361d545dabaSMahesh Palivela 	IEEE80211_STA_DISABLE_VHT	= BIT(11),
362f2d9d270SJohannes Berg 	IEEE80211_STA_DISABLE_80P80MHZ	= BIT(12),
363f2d9d270SJohannes Berg 	IEEE80211_STA_DISABLE_160MHZ	= BIT(13),
364095d81ceSJohannes Berg 	IEEE80211_STA_DISABLE_WMM	= BIT(14),
365cd2f5dd7SAssaf Krauss 	IEEE80211_STA_ENABLE_RRM	= BIT(15),
366ab1faeadSJohannes Berg };
367ab1faeadSJohannes Berg 
36866e67e41SJohannes Berg struct ieee80211_mgd_auth_data {
36966e67e41SJohannes Berg 	struct cfg80211_bss *bss;
37066e67e41SJohannes Berg 	unsigned long timeout;
37166e67e41SJohannes Berg 	int tries;
37266e67e41SJohannes Berg 	u16 algorithm, expected_transaction;
37366e67e41SJohannes Berg 
37466e67e41SJohannes Berg 	u8 key[WLAN_KEY_LEN_WEP104];
37566e67e41SJohannes Berg 	u8 key_len, key_idx;
37666e67e41SJohannes Berg 	bool done;
37789afe614SJohannes Berg 	bool timeout_started;
37866e67e41SJohannes Berg 
3796b8ece3aSJouni Malinen 	u16 sae_trans, sae_status;
3806b8ece3aSJouni Malinen 	size_t data_len;
3816b8ece3aSJouni Malinen 	u8 data[];
38266e67e41SJohannes Berg };
38366e67e41SJohannes Berg 
38466e67e41SJohannes Berg struct ieee80211_mgd_assoc_data {
38566e67e41SJohannes Berg 	struct cfg80211_bss *bss;
38666e67e41SJohannes Berg 	const u8 *supp_rates;
38766e67e41SJohannes Berg 
38866e67e41SJohannes Berg 	unsigned long timeout;
38966e67e41SJohannes Berg 	int tries;
39066e67e41SJohannes Berg 
39166e67e41SJohannes Berg 	u16 capability;
39266e67e41SJohannes Berg 	u8 prev_bssid[ETH_ALEN];
39366e67e41SJohannes Berg 	u8 ssid[IEEE80211_MAX_SSID_LEN];
39466e67e41SJohannes Berg 	u8 ssid_len;
39566e67e41SJohannes Berg 	u8 supp_rates_len;
39676f0303dSJohannes Berg 	bool wmm, uapsd;
397989c6505SAlexander Bondar 	bool need_beacon;
39866e67e41SJohannes Berg 	bool synced;
39989afe614SJohannes Berg 	bool timeout_started;
40066e67e41SJohannes Berg 
4019dde6423SJohannes Berg 	u8 ap_ht_param;
4029dde6423SJohannes Berg 
403b08fbbd8SJohannes Berg 	struct ieee80211_vht_cap ap_vht_cap;
404b08fbbd8SJohannes Berg 
40539404feeSJouni Malinen 	u8 fils_nonces[2 * FILS_NONCE_LEN];
40639404feeSJouni Malinen 	u8 fils_kek[FILS_MAX_KEK_LEN];
40739404feeSJouni Malinen 	size_t fils_kek_len;
40839404feeSJouni Malinen 
40966e67e41SJohannes Berg 	size_t ie_len;
41066e67e41SJohannes Berg 	u8 ie[];
41166e67e41SJohannes Berg };
41266e67e41SJohannes Berg 
41302219b3aSJohannes Berg struct ieee80211_sta_tx_tspec {
41402219b3aSJohannes Berg 	/* timestamp of the first packet in the time slice */
41502219b3aSJohannes Berg 	unsigned long time_slice_start;
41602219b3aSJohannes Berg 
41702219b3aSJohannes Berg 	u32 admitted_time; /* in usecs, unlike over the air */
41802219b3aSJohannes Berg 	u8 tsid;
41902219b3aSJohannes Berg 	s8 up; /* signed to be able to invalidate with -1 during teardown */
42002219b3aSJohannes Berg 
42102219b3aSJohannes Berg 	/* consumed TX time in microseconds in the time slice */
42202219b3aSJohannes Berg 	u32 consumed_tx_time;
42302219b3aSJohannes Berg 	enum {
42402219b3aSJohannes Berg 		TX_TSPEC_ACTION_NONE = 0,
42502219b3aSJohannes Berg 		TX_TSPEC_ACTION_DOWNGRADE,
42602219b3aSJohannes Berg 		TX_TSPEC_ACTION_STOP_DOWNGRADE,
42702219b3aSJohannes Berg 	} action;
42802219b3aSJohannes Berg 	bool downgraded;
42902219b3aSJohannes Berg };
43002219b3aSJohannes Berg 
431eb1e011aSJohannes Berg DECLARE_EWMA(beacon_signal, 4, 4)
432338c17aeSJohannes Berg 
43346900298SJohannes Berg struct ieee80211_if_managed {
434056cdd59SJohannes Berg 	struct timer_list timer;
435b291ba11SJohannes Berg 	struct timer_list conn_mon_timer;
436b291ba11SJohannes Berg 	struct timer_list bcn_mon_timer;
437c481ec97SSujith 	struct timer_list chswitch_timer;
438b291ba11SJohannes Berg 	struct work_struct monitor_work;
439c481ec97SSujith 	struct work_struct chswitch_work;
4401e4dcd01SJuuso Oikarinen 	struct work_struct beacon_connection_loss_work;
441882a7c69SJohannes Berg 	struct work_struct csa_connection_drop_work;
44246900298SJohannes Berg 
4437ccc8bd7SFelix Fietkau 	unsigned long beacon_timeout;
444b291ba11SJohannes Berg 	unsigned long probe_timeout;
445a43abf29SMaxim Levitsky 	int probe_send_count;
44604ac3c0eSFelix Fietkau 	bool nullfunc_failed;
447682bd38bSJohannes Berg 	bool connection_loss;
448b291ba11SJohannes Berg 
4490c1ad2caSJohannes Berg 	struct cfg80211_bss *associated;
45066e67e41SJohannes Berg 	struct ieee80211_mgd_auth_data *auth_data;
45166e67e41SJohannes Berg 	struct ieee80211_mgd_assoc_data *assoc_data;
45246900298SJohannes Berg 
453a3e2f4b6SMichael Braun 	u8 bssid[ETH_ALEN] __aligned(2);
45446900298SJohannes Berg 
455f0706e82SJiri Benc 	u16 aid;
456f0706e82SJiri Benc 
457965bedadSJohannes Berg 	bool powersave; /* powersave requested for this iface */
45805cb9108SJohannes Berg 	bool broken_ap; /* AP is broken -- turn off powersave */
459989c6505SAlexander Bondar 	bool have_beacon;
460826262c3SJohannes Berg 	u8 dtim_period;
4610f78231bSJohannes Berg 	enum ieee80211_smps_mode req_smps, /* requested smps mode */
462d1f5b7a3SJohannes Berg 				 driver_smps_mode; /* smps mode request */
463d1f5b7a3SJohannes Berg 
464d1f5b7a3SJohannes Berg 	struct work_struct request_smps_work;
465965bedadSJohannes Berg 
466d6f2da5bSJiri Slaby 	unsigned int flags;
467f0706e82SJiri Benc 
4680c21e632SLuciano Coelho 	bool csa_waiting_bcn;
469f84eaa10SJohannes Berg 	bool csa_ignored_same_chan;
4700c21e632SLuciano Coelho 
471d8ec4433SJuuso Oikarinen 	bool beacon_crc_valid;
472d91f36dbSJohannes Berg 	u32 beacon_crc;
473d91f36dbSJohannes Berg 
4741672c0e3SJohannes Berg 	bool status_acked;
4751672c0e3SJohannes Berg 	bool status_received;
4761672c0e3SJohannes Berg 	__le16 status_fc;
4771672c0e3SJohannes Berg 
478fdfacf0aSJouni Malinen 	enum {
479fdfacf0aSJouni Malinen 		IEEE80211_MFP_DISABLED,
480fdfacf0aSJouni Malinen 		IEEE80211_MFP_OPTIONAL,
481fdfacf0aSJouni Malinen 		IEEE80211_MFP_REQUIRED
482fdfacf0aSJouni Malinen 	} mfp; /* management frame protection */
483fdfacf0aSJouni Malinen 
484dc41e4d4SEliad Peller 	/*
485dc41e4d4SEliad Peller 	 * Bitmask of enabled u-apsd queues,
486dc41e4d4SEliad Peller 	 * IEEE80211_WMM_IE_STA_QOSINFO_AC_BE & co. Needs a new association
487dc41e4d4SEliad Peller 	 * to take effect.
488dc41e4d4SEliad Peller 	 */
489dc41e4d4SEliad Peller 	unsigned int uapsd_queues;
490dc41e4d4SEliad Peller 
491dc41e4d4SEliad Peller 	/*
492dc41e4d4SEliad Peller 	 * Maximum number of buffered frames AP can deliver during a
493dc41e4d4SEliad Peller 	 * service period, IEEE80211_WMM_IE_STA_QOSINFO_SP_ALL or similar.
494dc41e4d4SEliad Peller 	 * Needs a new association to take effect.
495dc41e4d4SEliad Peller 	 */
496dc41e4d4SEliad Peller 	unsigned int uapsd_max_sp_len;
497dc41e4d4SEliad Peller 
498f0706e82SJiri Benc 	int wmm_last_param_set;
4999bc383deSJohannes Berg 
5009bc383deSJohannes Berg 	u8 use_4addr;
50117e4ec14SJouni Malinen 
50267baf663SJanusz Dziedzic 	s16 p2p_noa_index;
503488dd7b5SJohannes Berg 
504338c17aeSJohannes Berg 	struct ewma_beacon_signal ave_beacon_signal;
50517e4ec14SJouni Malinen 
50617e4ec14SJouni Malinen 	/*
507391a200aSJouni Malinen 	 * Number of Beacon frames used in ave_beacon_signal. This can be used
508391a200aSJouni Malinen 	 * to avoid generating less reliable cqm events that would be based
509391a200aSJouni Malinen 	 * only on couple of received frames.
510391a200aSJouni Malinen 	 */
511391a200aSJouni Malinen 	unsigned int count_beacon_signal;
512391a200aSJouni Malinen 
513976bd9efSJohannes Berg 	/* Number of times beacon loss was invoked. */
514976bd9efSJohannes Berg 	unsigned int beacon_loss_count;
515976bd9efSJohannes Berg 
516391a200aSJouni Malinen 	/*
51717e4ec14SJouni Malinen 	 * Last Beacon frame signal strength average (ave_beacon_signal / 16)
51817e4ec14SJouni Malinen 	 * that triggered a cqm event. 0 indicates that no event has been
51917e4ec14SJouni Malinen 	 * generated for the current association.
52017e4ec14SJouni Malinen 	 */
52117e4ec14SJouni Malinen 	int last_cqm_event_signal;
522615f7b9bSMeenakshi Venkataraman 
523615f7b9bSMeenakshi Venkataraman 	/*
524615f7b9bSMeenakshi Venkataraman 	 * State variables for keeping track of RSSI of the AP currently
525615f7b9bSMeenakshi Venkataraman 	 * connected to and informing driver when RSSI has gone
526615f7b9bSMeenakshi Venkataraman 	 * below/above a certain threshold.
527615f7b9bSMeenakshi Venkataraman 	 */
528615f7b9bSMeenakshi Venkataraman 	int rssi_min_thold, rssi_max_thold;
529615f7b9bSMeenakshi Venkataraman 	int last_ave_beacon_signal;
530ef96a842SBen Greear 
531ef96a842SBen Greear 	struct ieee80211_ht_cap ht_capa; /* configured ht-cap over-rides */
532ef96a842SBen Greear 	struct ieee80211_ht_cap ht_capa_mask; /* Valid parts of ht_capa */
533dd5ecfeaSJohannes Berg 	struct ieee80211_vht_cap vht_capa; /* configured VHT overrides */
534dd5ecfeaSJohannes Berg 	struct ieee80211_vht_cap vht_capa_mask; /* Valid parts of vht_capa */
53581dd2b88SArik Nemtsov 
5361277b4a9SLiad Kaufman 	/* TDLS support */
53781dd2b88SArik Nemtsov 	u8 tdls_peer[ETH_ALEN] __aligned(2);
53881dd2b88SArik Nemtsov 	struct delayed_work tdls_peer_del_work;
5391277b4a9SLiad Kaufman 	struct sk_buff *orig_teardown_skb; /* The original teardown skb */
5401277b4a9SLiad Kaufman 	struct sk_buff *teardown_skb; /* A copy to send through the AP */
5411277b4a9SLiad Kaufman 	spinlock_t teardown_lock; /* To lock changing teardown_skb */
5429041c1faSArik Nemtsov 	bool tdls_chan_switch_prohibited;
54382c0cc90SArik Nemtsov 	bool tdls_wider_bw_prohibited;
54402219b3aSJohannes Berg 
54502219b3aSJohannes Berg 	/* WMM-AC TSPEC support */
54602219b3aSJohannes Berg 	struct ieee80211_sta_tx_tspec tx_tspec[IEEE80211_NUM_ACS];
54702219b3aSJohannes Berg 	/* Use a separate work struct so that we can do something here
54802219b3aSJohannes Berg 	 * while the sdata->work is flushing the queues, for example.
54902219b3aSJohannes Berg 	 * otherwise, in scenarios where we hardly get any traffic out
55002219b3aSJohannes Berg 	 * on the BE queue, but there's a lot of VO traffic, we might
55102219b3aSJohannes Berg 	 * get stuck in a downgraded situation and flush takes forever.
55202219b3aSJohannes Berg 	 */
55302219b3aSJohannes Berg 	struct delayed_work tx_tspec_wk;
554f0706e82SJiri Benc };
555f0706e82SJiri Benc 
55646900298SJohannes Berg struct ieee80211_if_ibss {
55746900298SJohannes Berg 	struct timer_list timer;
558cd7760e6SSimon Wunderlich 	struct work_struct csa_connection_drop_work;
55946900298SJohannes Berg 
560af8cdcd8SJohannes Berg 	unsigned long last_scan_completed;
5615bb644a0SJohannes Berg 
562fbd2c8dcSTeemu Paasikivi 	u32 basic_rates;
563fbd2c8dcSTeemu Paasikivi 
564af8cdcd8SJohannes Berg 	bool fixed_bssid;
565af8cdcd8SJohannes Berg 	bool fixed_channel;
566fffd0934SJohannes Berg 	bool privacy;
56746900298SJohannes Berg 
568267335d6SAntonio Quartulli 	bool control_port;
5698e8d347dSSimon Wunderlich 	bool userspace_handles_dfs;
570267335d6SAntonio Quartulli 
5714d196e4bSFelix Fietkau 	u8 bssid[ETH_ALEN] __aligned(2);
572af8cdcd8SJohannes Berg 	u8 ssid[IEEE80211_MAX_SSID_LEN];
573af8cdcd8SJohannes Berg 	u8 ssid_len, ie_len;
574af8cdcd8SJohannes Berg 	u8 *ie;
5753aede78aSSimon Wunderlich 	struct cfg80211_chan_def chandef;
57646900298SJohannes Berg 
57746900298SJohannes Berg 	unsigned long ibss_join_req;
578af8cdcd8SJohannes Berg 	/* probe response/beacon for IBSS */
579c3ffeab4SJohannes Berg 	struct beacon_data __rcu *presp;
58046900298SJohannes Berg 
581822854b0SSimon Wunderlich 	struct ieee80211_ht_cap ht_capa; /* configured ht-cap over-rides */
582822854b0SSimon Wunderlich 	struct ieee80211_ht_cap ht_capa_mask; /* Valid parts of ht_capa */
583822854b0SSimon Wunderlich 
5848bf11d8dSJohannes Berg 	spinlock_t incomplete_lock;
5858bf11d8dSJohannes Berg 	struct list_head incomplete_stations;
5868bf11d8dSJohannes Berg 
58746900298SJohannes Berg 	enum {
58846900298SJohannes Berg 		IEEE80211_IBSS_MLME_SEARCH,
58946900298SJohannes Berg 		IEEE80211_IBSS_MLME_JOINED,
59046900298SJohannes Berg 	} state;
59146900298SJohannes Berg };
59246900298SJohannes Berg 
593dbf498fbSJavier Cardona /**
594239281f8SRostislav Lisovy  * struct ieee80211_if_ocb - OCB mode state
595239281f8SRostislav Lisovy  *
596239281f8SRostislav Lisovy  * @housekeeping_timer: timer for periodic invocation of a housekeeping task
597239281f8SRostislav Lisovy  * @wrkq_flags: OCB deferred task action
598239281f8SRostislav Lisovy  * @incomplete_lock: delayed STA insertion lock
599239281f8SRostislav Lisovy  * @incomplete_stations: list of STAs waiting for delayed insertion
600239281f8SRostislav Lisovy  * @joined: indication if the interface is connected to an OCB network
601239281f8SRostislav Lisovy  */
602239281f8SRostislav Lisovy struct ieee80211_if_ocb {
603239281f8SRostislav Lisovy 	struct timer_list housekeeping_timer;
604239281f8SRostislav Lisovy 	unsigned long wrkq_flags;
605239281f8SRostislav Lisovy 
606239281f8SRostislav Lisovy 	spinlock_t incomplete_lock;
607239281f8SRostislav Lisovy 	struct list_head incomplete_stations;
608239281f8SRostislav Lisovy 
609239281f8SRostislav Lisovy 	bool joined;
610239281f8SRostislav Lisovy };
611239281f8SRostislav Lisovy 
612239281f8SRostislav Lisovy /**
613dbf498fbSJavier Cardona  * struct ieee80211_mesh_sync_ops - Extensible synchronization framework interface
614dbf498fbSJavier Cardona  *
615dbf498fbSJavier Cardona  * these declarations define the interface, which enables
616dbf498fbSJavier Cardona  * vendor-specific mesh synchronization
617dbf498fbSJavier Cardona  *
618dbf498fbSJavier Cardona  */
619dbf498fbSJavier Cardona struct ieee802_11_elems;
620dbf498fbSJavier Cardona struct ieee80211_mesh_sync_ops {
621dbf498fbSJavier Cardona 	void (*rx_bcn_presp)(struct ieee80211_sub_if_data *sdata,
622dbf498fbSJavier Cardona 			     u16 stype,
623dbf498fbSJavier Cardona 			     struct ieee80211_mgmt *mgmt,
624dbf498fbSJavier Cardona 			     struct ieee802_11_elems *elems,
625dbf498fbSJavier Cardona 			     struct ieee80211_rx_status *rx_status);
62643552be1SThomas Pedersen 
62743552be1SThomas Pedersen 	/* should be called with beacon_data under RCU read lock */
628445cd452SMasashi Honma 	void (*adjust_tsf)(struct ieee80211_sub_if_data *sdata,
62943552be1SThomas Pedersen 			   struct beacon_data *beacon);
630dbf498fbSJavier Cardona 	/* add other framework functions here */
631dbf498fbSJavier Cardona };
632dbf498fbSJavier Cardona 
633b8456a14SChun-Yeow Yeoh struct mesh_csa_settings {
634b8456a14SChun-Yeow Yeoh 	struct rcu_head rcu_head;
635b8456a14SChun-Yeow Yeoh 	struct cfg80211_csa_settings settings;
636b8456a14SChun-Yeow Yeoh };
637b8456a14SChun-Yeow Yeoh 
638472dbc45SJohannes Berg struct ieee80211_if_mesh {
639472dbc45SJohannes Berg 	struct timer_list housekeeping_timer;
640472dbc45SJohannes Berg 	struct timer_list mesh_path_timer;
641e304bfd3SRui Paulo 	struct timer_list mesh_path_root_timer;
642472dbc45SJohannes Berg 
64318889231SJavier Cardona 	unsigned long wrkq_flags;
644f81a9dedSThomas Pedersen 	unsigned long mbss_changed;
645472dbc45SJohannes Berg 
646472dbc45SJohannes Berg 	u8 mesh_id[IEEE80211_MAX_MESH_ID_LEN];
647472dbc45SJohannes Berg 	size_t mesh_id_len;
648472dbc45SJohannes Berg 	/* Active Path Selection Protocol Identifier */
6493491707aSRui Paulo 	u8 mesh_pp_id;
650472dbc45SJohannes Berg 	/* Active Path Selection Metric Identifier */
6513491707aSRui Paulo 	u8 mesh_pm_id;
652472dbc45SJohannes Berg 	/* Congestion Control Mode Identifier */
6533491707aSRui Paulo 	u8 mesh_cc_id;
6549e03fdfdSJavier Cardona 	/* Synchronization Protocol Identifier */
6553491707aSRui Paulo 	u8 mesh_sp_id;
6569e03fdfdSJavier Cardona 	/* Authentication Protocol Identifier */
6573491707aSRui Paulo 	u8 mesh_auth_id;
658d19b3bf6SRui Paulo 	/* Local mesh Sequence Number */
659d19b3bf6SRui Paulo 	u32 sn;
660472dbc45SJohannes Berg 	/* Last used PREQ ID */
661472dbc45SJohannes Berg 	u32 preq_id;
662472dbc45SJohannes Berg 	atomic_t mpaths;
663d19b3bf6SRui Paulo 	/* Timestamp of last SN update */
664d19b3bf6SRui Paulo 	unsigned long last_sn_update;
665dca7e943SThomas Pedersen 	/* Time when it's ok to send next PERR */
666dca7e943SThomas Pedersen 	unsigned long next_perr;
667dca7e943SThomas Pedersen 	/* Timestamp of last PREQ sent */
668472dbc45SJohannes Berg 	unsigned long last_preq;
669472dbc45SJohannes Berg 	struct mesh_rmc *rmc;
670472dbc45SJohannes Berg 	spinlock_t mesh_preq_queue_lock;
671472dbc45SJohannes Berg 	struct mesh_preq_queue preq_queue;
672472dbc45SJohannes Berg 	int preq_queue_len;
673472dbc45SJohannes Berg 	struct mesh_stats mshstats;
674472dbc45SJohannes Berg 	struct mesh_config mshcfg;
6751258d976SAshok Nagarajan 	atomic_t estab_plinks;
676472dbc45SJohannes Berg 	u32 mesh_seqnum;
677472dbc45SJohannes Berg 	bool accepting_plinks;
6785ee68e5bSJavier Cardona 	int num_gates;
6792b5e1967SThomas Pedersen 	struct beacon_data __rcu *beacon;
680581a8b0fSJavier Cardona 	const u8 *ie;
681581a8b0fSJavier Cardona 	u8 ie_len;
682b130e5ceSJavier Cardona 	enum {
683b130e5ceSJavier Cardona 		IEEE80211_MESH_SEC_NONE = 0x0,
684b130e5ceSJavier Cardona 		IEEE80211_MESH_SEC_AUTHED = 0x1,
685b130e5ceSJavier Cardona 		IEEE80211_MESH_SEC_SECURED = 0x2,
686b130e5ceSJavier Cardona 	} security;
687a6dad6a2SThomas Pedersen 	bool user_mpm;
688dbf498fbSJavier Cardona 	/* Extensible Synchronization Framework */
6898ba7acf3SJohannes Berg 	const struct ieee80211_mesh_sync_ops *sync_ops;
690dbf498fbSJavier Cardona 	s64 sync_offset_clockdrift_max;
691dbf498fbSJavier Cardona 	spinlock_t sync_offset_lock;
6923f52b7e3SMarco Porsch 	/* mesh power save */
6933f52b7e3SMarco Porsch 	enum nl80211_mesh_power_mode nonpeer_pm;
6943f52b7e3SMarco Porsch 	int ps_peers_light_sleep;
6953f52b7e3SMarco Porsch 	int ps_peers_deep_sleep;
6963f52b7e3SMarco Porsch 	struct ps_data ps;
6978f2535b9SChun-Yeow Yeoh 	/* Channel Switching Support */
698b8456a14SChun-Yeow Yeoh 	struct mesh_csa_settings __rcu *csa;
6990cb4d4dcSLuciano Coelho 	enum {
7000cb4d4dcSLuciano Coelho 		IEEE80211_MESH_CSA_ROLE_NONE,
7010cb4d4dcSLuciano Coelho 		IEEE80211_MESH_CSA_ROLE_INIT,
7020cb4d4dcSLuciano Coelho 		IEEE80211_MESH_CSA_ROLE_REPEATER,
7030cb4d4dcSLuciano Coelho 	} csa_role;
704b8456a14SChun-Yeow Yeoh 	u8 chsw_ttl;
7058f2535b9SChun-Yeow Yeoh 	u16 pre_value;
70643552be1SThomas Pedersen 
70743552be1SThomas Pedersen 	/* offset from skb->data while building IE */
70843552be1SThomas Pedersen 	int meshconf_offset;
7092bdaf386SBob Copeland 
71060854fd9SBob Copeland 	struct mesh_table *mesh_paths;
71160854fd9SBob Copeland 	struct mesh_table *mpp_paths; /* Store paths for MPP&MAP */
7122bdaf386SBob Copeland 	int mesh_paths_generation;
7132bdaf386SBob Copeland 	int mpp_paths_generation;
714472dbc45SJohannes Berg };
715902acc78SJohannes Berg 
716902acc78SJohannes Berg #ifdef CONFIG_MAC80211_MESH
717472dbc45SJohannes Berg #define IEEE80211_IFSTA_MESH_CTR_INC(msh, name)	\
718472dbc45SJohannes Berg 	do { (msh)->mshstats.name++; } while (0)
719902acc78SJohannes Berg #else
720472dbc45SJohannes Berg #define IEEE80211_IFSTA_MESH_CTR_INC(msh, name) \
721902acc78SJohannes Berg 	do { } while (0)
722902acc78SJohannes Berg #endif
723f0706e82SJiri Benc 
724213cd118SJohannes Berg /**
725213cd118SJohannes Berg  * enum ieee80211_sub_if_data_flags - virtual interface flags
726213cd118SJohannes Berg  *
727213cd118SJohannes Berg  * @IEEE80211_SDATA_ALLMULTI: interface wants all multicast packets
728213cd118SJohannes Berg  * @IEEE80211_SDATA_OPERATING_GMODE: operating in G-only mode
729213cd118SJohannes Berg  * @IEEE80211_SDATA_DONT_BRIDGE_PACKETS: bridge packets between
730213cd118SJohannes Berg  *	associated stations and deliver multicast frames both
731213cd118SJohannes Berg  *	back to wireless media and to the local net stack.
73295acac61SJohannes Berg  * @IEEE80211_SDATA_DISCONNECT_RESUME: Disconnect after resume.
7337b7eab6fSJohannes Berg  * @IEEE80211_SDATA_IN_DRIVER: indicates interface was added to driver
734213cd118SJohannes Berg  */
735213cd118SJohannes Berg enum ieee80211_sub_if_data_flags {
736213cd118SJohannes Berg 	IEEE80211_SDATA_ALLMULTI		= BIT(0),
7377986cf95SJohannes Berg 	IEEE80211_SDATA_OPERATING_GMODE		= BIT(2),
7387986cf95SJohannes Berg 	IEEE80211_SDATA_DONT_BRIDGE_PACKETS	= BIT(3),
73995acac61SJohannes Berg 	IEEE80211_SDATA_DISCONNECT_RESUME	= BIT(4),
7407b7eab6fSJohannes Berg 	IEEE80211_SDATA_IN_DRIVER		= BIT(5),
741213cd118SJohannes Berg };
742213cd118SJohannes Berg 
74334d4bc4dSJohannes Berg /**
74434d4bc4dSJohannes Berg  * enum ieee80211_sdata_state_bits - virtual interface state bits
74534d4bc4dSJohannes Berg  * @SDATA_STATE_RUNNING: virtual interface is up & running; this
74634d4bc4dSJohannes Berg  *	mirrors netif_running() but is separate for interface type
74734d4bc4dSJohannes Berg  *	change handling while the interface is up
7485b714c6aSJohannes Berg  * @SDATA_STATE_OFFCHANNEL: This interface is currently in offchannel
7495b714c6aSJohannes Berg  *	mode, so queues are stopped
750d6a83228SJohannes Berg  * @SDATA_STATE_OFFCHANNEL_BEACON_STOPPED: Beaconing was stopped due
751d6a83228SJohannes Berg  *	to offchannel, reset when offchannel returns
75234d4bc4dSJohannes Berg  */
75334d4bc4dSJohannes Berg enum ieee80211_sdata_state_bits {
75434d4bc4dSJohannes Berg 	SDATA_STATE_RUNNING,
7555b714c6aSJohannes Berg 	SDATA_STATE_OFFCHANNEL,
756d6a83228SJohannes Berg 	SDATA_STATE_OFFCHANNEL_BEACON_STOPPED,
75734d4bc4dSJohannes Berg };
75834d4bc4dSJohannes Berg 
759d01a1e65SMichal Kazior /**
760d01a1e65SMichal Kazior  * enum ieee80211_chanctx_mode - channel context configuration mode
761d01a1e65SMichal Kazior  *
762d01a1e65SMichal Kazior  * @IEEE80211_CHANCTX_SHARED: channel context may be used by
763d01a1e65SMichal Kazior  *	multiple interfaces
764d01a1e65SMichal Kazior  * @IEEE80211_CHANCTX_EXCLUSIVE: channel context can be used
765d01a1e65SMichal Kazior  *	only by a single interface. This can be used for example for
766d01a1e65SMichal Kazior  *	non-fixed channel IBSS.
767d01a1e65SMichal Kazior  */
768d01a1e65SMichal Kazior enum ieee80211_chanctx_mode {
769d01a1e65SMichal Kazior 	IEEE80211_CHANCTX_SHARED,
770d01a1e65SMichal Kazior 	IEEE80211_CHANCTX_EXCLUSIVE
771d01a1e65SMichal Kazior };
772d01a1e65SMichal Kazior 
7735bcae31dSMichal Kazior /**
7745bcae31dSMichal Kazior  * enum ieee80211_chanctx_replace_state - channel context replacement state
7755bcae31dSMichal Kazior  *
7765bcae31dSMichal Kazior  * This is used for channel context in-place reservations that require channel
7775bcae31dSMichal Kazior  * context switch/swap.
7785bcae31dSMichal Kazior  *
7795bcae31dSMichal Kazior  * @IEEE80211_CHANCTX_REPLACE_NONE: no replacement is taking place
7805bcae31dSMichal Kazior  * @IEEE80211_CHANCTX_WILL_BE_REPLACED: this channel context will be replaced
7815bcae31dSMichal Kazior  *	by a (not yet registered) channel context pointed by %replace_ctx.
7825bcae31dSMichal Kazior  * @IEEE80211_CHANCTX_REPLACES_OTHER: this (not yet registered) channel context
7835bcae31dSMichal Kazior  *	replaces an existing channel context pointed to by %replace_ctx.
7845bcae31dSMichal Kazior  */
7855bcae31dSMichal Kazior enum ieee80211_chanctx_replace_state {
7865bcae31dSMichal Kazior 	IEEE80211_CHANCTX_REPLACE_NONE,
7875bcae31dSMichal Kazior 	IEEE80211_CHANCTX_WILL_BE_REPLACED,
7885bcae31dSMichal Kazior 	IEEE80211_CHANCTX_REPLACES_OTHER,
7895bcae31dSMichal Kazior };
7905bcae31dSMichal Kazior 
791d01a1e65SMichal Kazior struct ieee80211_chanctx {
792d01a1e65SMichal Kazior 	struct list_head list;
793d01a1e65SMichal Kazior 	struct rcu_head rcu_head;
794d01a1e65SMichal Kazior 
795484298adSMichal Kazior 	struct list_head assigned_vifs;
796e3afb920SMichal Kazior 	struct list_head reserved_vifs;
797484298adSMichal Kazior 
7985bcae31dSMichal Kazior 	enum ieee80211_chanctx_replace_state replace_state;
7995bcae31dSMichal Kazior 	struct ieee80211_chanctx *replace_ctx;
8005bcae31dSMichal Kazior 
801d01a1e65SMichal Kazior 	enum ieee80211_chanctx_mode mode;
8028a61af65SJohannes Berg 	bool driver_present;
803d01a1e65SMichal Kazior 
804d01a1e65SMichal Kazior 	struct ieee80211_chanctx_conf conf;
805d01a1e65SMichal Kazior };
806d01a1e65SMichal Kazior 
80732db6b54SKyeyoon Park struct mac80211_qos_map {
80832db6b54SKyeyoon Park 	struct cfg80211_qos_map qos_map;
80932db6b54SKyeyoon Park 	struct rcu_head rcu_head;
81032db6b54SKyeyoon Park };
81132db6b54SKyeyoon Park 
812ba8c3d6fSFelix Fietkau enum txq_info_flags {
813ba8c3d6fSFelix Fietkau 	IEEE80211_TXQ_STOP,
814ba8c3d6fSFelix Fietkau 	IEEE80211_TXQ_AMPDU,
8156e0456b5SFelix Fietkau 	IEEE80211_TXQ_NO_AMSDU,
816ba8c3d6fSFelix Fietkau };
817ba8c3d6fSFelix Fietkau 
818fa962b92SMichal Kazior /**
819fa962b92SMichal Kazior  * struct txq_info - per tid queue
820fa962b92SMichal Kazior  *
821fa962b92SMichal Kazior  * @tin: contains packets split into multiple flows
822fa962b92SMichal Kazior  * @def_flow: used as a fallback flow when a packet destined to @tin hashes to
823fa962b92SMichal Kazior  *	a fq_flow which is already owned by a different tin
8245caa328eSMichal Kazior  * @def_cvars: codel vars for @def_flow
825bb42f2d1SToke Høiland-Jørgensen  * @frags: used to keep fragments created after dequeue
826fa962b92SMichal Kazior  */
827ba8c3d6fSFelix Fietkau struct txq_info {
828fa962b92SMichal Kazior 	struct fq_tin tin;
829fa962b92SMichal Kazior 	struct fq_flow def_flow;
8305caa328eSMichal Kazior 	struct codel_vars def_cvars;
8318d51dbb8SToke Høiland-Jørgensen 	struct codel_stats cstats;
832bb42f2d1SToke Høiland-Jørgensen 	struct sk_buff_head frags;
833ba8c3d6fSFelix Fietkau 	unsigned long flags;
834ba8c3d6fSFelix Fietkau 
835ba8c3d6fSFelix Fietkau 	/* keep last! */
836ba8c3d6fSFelix Fietkau 	struct ieee80211_txq txq;
837ba8c3d6fSFelix Fietkau };
838ba8c3d6fSFelix Fietkau 
839d8212184SAviya Erenfeld struct ieee80211_if_mntr {
840d8212184SAviya Erenfeld 	u32 flags;
84142bd20d9SAviya Erenfeld 	u8 mu_follow_addr[ETH_ALEN] __aligned(2);
842f64331d5SJohannes Berg 
843f64331d5SJohannes Berg 	struct list_head list;
844d8212184SAviya Erenfeld };
845d8212184SAviya Erenfeld 
8465953ff6dSAyala Beker /**
8475953ff6dSAyala Beker  * struct ieee80211_if_nan - NAN state
8485953ff6dSAyala Beker  *
8495953ff6dSAyala Beker  * @conf: current NAN configuration
850167e33f4SAyala Beker  * @func_ids: a bitmap of available instance_id's
8515953ff6dSAyala Beker  */
8525953ff6dSAyala Beker struct ieee80211_if_nan {
8535953ff6dSAyala Beker 	struct cfg80211_nan_conf conf;
854167e33f4SAyala Beker 
855167e33f4SAyala Beker 	/* protects function_inst_ids */
856167e33f4SAyala Beker 	spinlock_t func_lock;
857167e33f4SAyala Beker 	struct idr function_inst_ids;
8585953ff6dSAyala Beker };
8595953ff6dSAyala Beker 
860f0706e82SJiri Benc struct ieee80211_sub_if_data {
861f0706e82SJiri Benc 	struct list_head list;
862f0706e82SJiri Benc 
863f0706e82SJiri Benc 	struct wireless_dev wdev;
864f0706e82SJiri Benc 
86511a843b7SJohannes Berg 	/* keys */
86611a843b7SJohannes Berg 	struct list_head key_list;
86711a843b7SJohannes Berg 
8683bff1865SYogesh Ashok Powar 	/* count for keys needing tailroom space allocation */
8693bff1865SYogesh Ashok Powar 	int crypto_tx_tailroom_needed_cnt;
8708d1f7ecdSJohannes Berg 	int crypto_tx_tailroom_pending_dec;
8718d1f7ecdSJohannes Berg 	struct delayed_work dec_tailroom_needed_wk;
8723bff1865SYogesh Ashok Powar 
873f0706e82SJiri Benc 	struct net_device *dev;
874f0706e82SJiri Benc 	struct ieee80211_local *local;
875f0706e82SJiri Benc 
87613262ffdSJiri Slaby 	unsigned int flags;
8777e9ed188SDaniel Drake 
87834d4bc4dSJohannes Berg 	unsigned long state;
87934d4bc4dSJohannes Berg 
88047846c9bSJohannes Berg 	char name[IFNAMSIZ];
88147846c9bSJohannes Berg 
882f0706e82SJiri Benc 	/* Fragment table for host-based reassembly */
883f0706e82SJiri Benc 	struct ieee80211_fragment_entry	fragments[IEEE80211_FRAGMENT_MAX];
884f0706e82SJiri Benc 	unsigned int fragment_next;
885f0706e82SJiri Benc 
886b53be792SSimon Wunderlich 	/* TID bitmap for NoAck policy */
887b53be792SSimon Wunderlich 	u16 noack_map;
888b53be792SSimon Wunderlich 
88900e96decSYoni Divinsky 	/* bit field of ACM bits (BIT(802.1D tag)) */
89000e96decSYoni Divinsky 	u8 wmm_acm;
89100e96decSYoni Divinsky 
89240b275b6SJohannes Berg 	struct ieee80211_key __rcu *keys[NUM_DEFAULT_KEYS + NUM_DEFAULT_MGMT_KEYS];
89340b275b6SJohannes Berg 	struct ieee80211_key __rcu *default_unicast_key;
89440b275b6SJohannes Berg 	struct ieee80211_key __rcu *default_multicast_key;
89540b275b6SJohannes Berg 	struct ieee80211_key __rcu *default_mgmt_key;
896f0706e82SJiri Benc 
89794778280SJohannes Berg 	u16 sequence_number;
898a621fa4dSJohannes Berg 	__be16 control_port_protocol;
899a621fa4dSJohannes Berg 	bool control_port_no_encrypt;
9002475b1ccSMax Stepanov 	int encrypt_headroom;
90194778280SJohannes Berg 
90280a83cfcSMichal Kazior 	atomic_t num_tx_queued;
90354bcbc69SJohannes Berg 	struct ieee80211_tx_queue_params tx_conf[IEEE80211_NUM_ACS];
90432db6b54SKyeyoon Park 	struct mac80211_qos_map __rcu *qos_map;
905f6f3def3SEliad Peller 
90673da7d5bSSimon Wunderlich 	struct work_struct csa_finalize_work;
90759af6928SMichal Kazior 	bool csa_block_tx; /* write-protected by sdata_lock and local->mtx */
90833787fc4SLuciano Coelho 	struct cfg80211_chan_def csa_chandef;
90973da7d5bSSimon Wunderlich 
910484298adSMichal Kazior 	struct list_head assigned_chanctx_list; /* protected by chanctx_mtx */
911e3afb920SMichal Kazior 	struct list_head reserved_chanctx_list; /* protected by chanctx_mtx */
912484298adSMichal Kazior 
91311335a55SLuciano Coelho 	/* context reservation -- protected with chanctx_mtx */
91411335a55SLuciano Coelho 	struct ieee80211_chanctx *reserved_chanctx;
91511335a55SLuciano Coelho 	struct cfg80211_chan_def reserved_chandef;
91609332481SMichal Kazior 	bool reserved_radar_required;
9175bcae31dSMichal Kazior 	bool reserved_ready;
91811335a55SLuciano Coelho 
91904ecd257SJohannes Berg 	/* used to reconfigure hardware SM PS */
92004ecd257SJohannes Berg 	struct work_struct recalc_smps;
92104ecd257SJohannes Berg 
92264592c8fSJohannes Berg 	struct work_struct work;
92335f20c14SJohannes Berg 	struct sk_buff_head skb_queue;
92435f20c14SJohannes Berg 
92504ecd257SJohannes Berg 	u8 needed_rx_chains;
92604ecd257SJohannes Berg 	enum ieee80211_smps_mode smps_mode;
92704ecd257SJohannes Berg 
9281ea6f9c0SJohannes Berg 	int user_power_level; /* in dBm */
9291ea6f9c0SJohannes Berg 	int ap_power_level; /* in dBm */
9301ea6f9c0SJohannes Berg 
931164eb02dSSimon Wunderlich 	bool radar_required;
932164eb02dSSimon Wunderlich 	struct delayed_work dfs_cac_timer_work;
933164eb02dSSimon Wunderlich 
9343e122be0SJohannes Berg 	/*
9353e122be0SJohannes Berg 	 * AP this belongs to: self in AP mode and
9363e122be0SJohannes Berg 	 * corresponding AP in VLAN mode, NULL for
9373e122be0SJohannes Berg 	 * all others (might be needed later in IBSS)
9383e122be0SJohannes Berg 	 */
9393e122be0SJohannes Berg 	struct ieee80211_if_ap *bss;
9403e122be0SJohannes Berg 
94137eb0b16SJouni Malinen 	/* bitmap of allowed (non-MCS) rate indexes for rate control */
94257fbcce3SJohannes Berg 	u32 rc_rateidx_mask[NUM_NL80211_BANDS];
9432ffbe6d3SFelix Fietkau 
94457fbcce3SJohannes Berg 	bool rc_has_mcs_mask[NUM_NL80211_BANDS];
94557fbcce3SJohannes Berg 	u8  rc_rateidx_mcs_mask[NUM_NL80211_BANDS][IEEE80211_HT_MCS_MASK_LEN];
946f0706e82SJiri Benc 
94757fbcce3SJohannes Berg 	bool rc_has_vht_mcs_mask[NUM_NL80211_BANDS];
94857fbcce3SJohannes Berg 	u16 rc_rateidx_vht_mcs_mask[NUM_NL80211_BANDS][NL80211_VHT_NSS_MAX];
949b119ad6eSLorenzo Bianconi 
950f0706e82SJiri Benc 	union {
951f0706e82SJiri Benc 		struct ieee80211_if_ap ap;
952f0706e82SJiri Benc 		struct ieee80211_if_wds wds;
953f0706e82SJiri Benc 		struct ieee80211_if_vlan vlan;
95446900298SJohannes Berg 		struct ieee80211_if_managed mgd;
95546900298SJohannes Berg 		struct ieee80211_if_ibss ibss;
956472dbc45SJohannes Berg 		struct ieee80211_if_mesh mesh;
957239281f8SRostislav Lisovy 		struct ieee80211_if_ocb ocb;
958d8212184SAviya Erenfeld 		struct ieee80211_if_mntr mntr;
9595953ff6dSAyala Beker 		struct ieee80211_if_nan nan;
960f0706e82SJiri Benc 	} u;
961e9f207f0SJiri Benc 
962e9f207f0SJiri Benc #ifdef CONFIG_MAC80211_DEBUGFS
963e9f207f0SJiri Benc 	struct {
964295bafb4SBen Greear 		struct dentry *subdir_stations;
965f7e0104cSJohannes Berg 		struct dentry *default_unicast_key;
966f7e0104cSJohannes Berg 		struct dentry *default_multicast_key;
9673cfcf6acSJouni Malinen 		struct dentry *default_mgmt_key;
9687bcfaf2fSJohannes Berg 	} debugfs;
969e9f207f0SJiri Benc #endif
970529ba6e9SJohannes Berg 
97132bfd35dSJohannes Berg 	/* must be last, dynamically sized area in this! */
97232bfd35dSJohannes Berg 	struct ieee80211_vif vif;
973f0706e82SJiri Benc };
974f0706e82SJiri Benc 
97532bfd35dSJohannes Berg static inline
97632bfd35dSJohannes Berg struct ieee80211_sub_if_data *vif_to_sdata(struct ieee80211_vif *p)
97732bfd35dSJohannes Berg {
97832bfd35dSJohannes Berg 	return container_of(p, struct ieee80211_sub_if_data, vif);
97932bfd35dSJohannes Berg }
98032bfd35dSJohannes Berg 
9818d61ffa5SJohannes Berg static inline void sdata_lock(struct ieee80211_sub_if_data *sdata)
9828d61ffa5SJohannes Berg 	__acquires(&sdata->wdev.mtx)
9838d61ffa5SJohannes Berg {
9848d61ffa5SJohannes Berg 	mutex_lock(&sdata->wdev.mtx);
9858d61ffa5SJohannes Berg 	__acquire(&sdata->wdev.mtx);
9868d61ffa5SJohannes Berg }
9878d61ffa5SJohannes Berg 
9888d61ffa5SJohannes Berg static inline void sdata_unlock(struct ieee80211_sub_if_data *sdata)
9898d61ffa5SJohannes Berg 	__releases(&sdata->wdev.mtx)
9908d61ffa5SJohannes Berg {
9918d61ffa5SJohannes Berg 	mutex_unlock(&sdata->wdev.mtx);
9928d61ffa5SJohannes Berg 	__release(&sdata->wdev.mtx);
9938d61ffa5SJohannes Berg }
9948d61ffa5SJohannes Berg 
9957ca133bcSSimon Wunderlich #define sdata_dereference(p, sdata) \
9967ca133bcSSimon Wunderlich 	rcu_dereference_protected(p, lockdep_is_held(&sdata->wdev.mtx))
9977ca133bcSSimon Wunderlich 
9988d61ffa5SJohannes Berg static inline void
9998d61ffa5SJohannes Berg sdata_assert_lock(struct ieee80211_sub_if_data *sdata)
10008d61ffa5SJohannes Berg {
10018d61ffa5SJohannes Berg 	lockdep_assert_held(&sdata->wdev.mtx);
10028d61ffa5SJohannes Berg }
10038d61ffa5SJohannes Berg 
1004438b61b7SSimon Wunderlich static inline int
1005438b61b7SSimon Wunderlich ieee80211_chandef_get_shift(struct cfg80211_chan_def *chandef)
1006438b61b7SSimon Wunderlich {
1007438b61b7SSimon Wunderlich 	switch (chandef->width) {
1008438b61b7SSimon Wunderlich 	case NL80211_CHAN_WIDTH_5:
1009438b61b7SSimon Wunderlich 		return 2;
1010438b61b7SSimon Wunderlich 	case NL80211_CHAN_WIDTH_10:
1011438b61b7SSimon Wunderlich 		return 1;
1012438b61b7SSimon Wunderlich 	default:
1013438b61b7SSimon Wunderlich 		return 0;
1014438b61b7SSimon Wunderlich 	}
1015438b61b7SSimon Wunderlich }
1016438b61b7SSimon Wunderlich 
1017438b61b7SSimon Wunderlich static inline int
1018438b61b7SSimon Wunderlich ieee80211_vif_get_shift(struct ieee80211_vif *vif)
1019438b61b7SSimon Wunderlich {
1020438b61b7SSimon Wunderlich 	struct ieee80211_chanctx_conf *chanctx_conf;
1021438b61b7SSimon Wunderlich 	int shift = 0;
1022438b61b7SSimon Wunderlich 
1023438b61b7SSimon Wunderlich 	rcu_read_lock();
1024438b61b7SSimon Wunderlich 	chanctx_conf = rcu_dereference(vif->chanctx_conf);
1025438b61b7SSimon Wunderlich 	if (chanctx_conf)
1026438b61b7SSimon Wunderlich 		shift = ieee80211_chandef_get_shift(&chanctx_conf->def);
1027438b61b7SSimon Wunderlich 	rcu_read_unlock();
1028438b61b7SSimon Wunderlich 
1029438b61b7SSimon Wunderlich 	return shift;
1030438b61b7SSimon Wunderlich }
1031438b61b7SSimon Wunderlich 
103208cf42e8SMichal Kazior struct ieee80211_rx_agg {
103308cf42e8SMichal Kazior 	u8 addr[ETH_ALEN];
103408cf42e8SMichal Kazior 	u16 tid;
103508cf42e8SMichal Kazior };
103608cf42e8SMichal Kazior 
1037c1475ca9SJohannes Berg enum sdata_queue_type {
1038c1475ca9SJohannes Berg 	IEEE80211_SDATA_QUEUE_TYPE_FRAME	= 0,
103908cf42e8SMichal Kazior 	IEEE80211_SDATA_QUEUE_RX_AGG_START	= 3,
104008cf42e8SMichal Kazior 	IEEE80211_SDATA_QUEUE_RX_AGG_STOP	= 4,
1041c1475ca9SJohannes Berg };
1042c1475ca9SJohannes Berg 
1043f0706e82SJiri Benc enum {
1044f0706e82SJiri Benc 	IEEE80211_RX_MSG	= 1,
1045f0706e82SJiri Benc 	IEEE80211_TX_STATUS_MSG	= 2,
1046f0706e82SJiri Benc };
1047f0706e82SJiri Benc 
1048ce7c9111SKalle Valo enum queue_stop_reason {
1049ce7c9111SKalle Valo 	IEEE80211_QUEUE_STOP_REASON_DRIVER,
1050520eb820SKalle Valo 	IEEE80211_QUEUE_STOP_REASON_PS,
105196f5e66eSJohannes Berg 	IEEE80211_QUEUE_STOP_REASON_CSA,
105296f5e66eSJohannes Berg 	IEEE80211_QUEUE_STOP_REASON_AGGREGATION,
105325420604SJohannes Berg 	IEEE80211_QUEUE_STOP_REASON_SUSPEND,
10548f77f384SJohannes Berg 	IEEE80211_QUEUE_STOP_REASON_SKB_ADD,
10556c17b77bSSeth Forshee 	IEEE80211_QUEUE_STOP_REASON_OFFCHANNEL,
1056445ea4e8SJohannes Berg 	IEEE80211_QUEUE_STOP_REASON_FLUSH,
1057db67d661SArik Nemtsov 	IEEE80211_QUEUE_STOP_REASON_TDLS_TEARDOWN,
1058b6da911bSLiad Kaufman 	IEEE80211_QUEUE_STOP_REASON_RESERVE_TID,
1059cca07b00SLuciano Coelho 
1060cca07b00SLuciano Coelho 	IEEE80211_QUEUE_STOP_REASONS,
1061ce7c9111SKalle Valo };
1062ce7c9111SKalle Valo 
106365a6538aSLuciano Coelho #ifdef CONFIG_MAC80211_LEDS
1064e1e54068SJohannes Berg struct tpt_led_trigger {
1065e1e54068SJohannes Berg 	char name[32];
1066e1e54068SJohannes Berg 	const struct ieee80211_tpt_blink *blink_table;
1067e1e54068SJohannes Berg 	unsigned int blink_table_len;
1068e1e54068SJohannes Berg 	struct timer_list timer;
1069e1e54068SJohannes Berg 	unsigned long prev_traffic;
1070e1e54068SJohannes Berg 	unsigned long tx_bytes, rx_bytes;
107167408c8cSJohannes Berg 	unsigned int active, want;
107267408c8cSJohannes Berg 	bool running;
1073e1e54068SJohannes Berg };
107465a6538aSLuciano Coelho #endif
1075e1e54068SJohannes Berg 
1076142b9f50SHelmut Schaa /**
1077142b9f50SHelmut Schaa  * mac80211 scan flags - currently active scan mode
1078142b9f50SHelmut Schaa  *
1079142b9f50SHelmut Schaa  * @SCAN_SW_SCANNING: We're currently in the process of scanning but may as
1080142b9f50SHelmut Schaa  *	well be on the operating channel
1081142b9f50SHelmut Schaa  * @SCAN_HW_SCANNING: The hardware is scanning for us, we have no way to
1082142b9f50SHelmut Schaa  *	determine if we are on the operating channel or not
10838a690674SBen Greear  * @SCAN_ONCHANNEL_SCANNING:  Do a software scan on only the current operating
10848a690674SBen Greear  *	channel. This should not interrupt normal traffic.
10858789d459SJohannes Berg  * @SCAN_COMPLETED: Set for our scan work function when the driver reported
10868789d459SJohannes Berg  *	that the scan completed.
10878789d459SJohannes Berg  * @SCAN_ABORTED: Set for our scan work function when the driver reported
10888789d459SJohannes Berg  *	a scan complete for an aborted scan.
1089a754055aSEmmanuel Grumbach  * @SCAN_HW_CANCELLED: Set for our scan work function when the scan is being
1090a754055aSEmmanuel Grumbach  *	cancelled.
1091142b9f50SHelmut Schaa  */
1092fbe9c429SHelmut Schaa enum {
1093fbe9c429SHelmut Schaa 	SCAN_SW_SCANNING,
1094142b9f50SHelmut Schaa 	SCAN_HW_SCANNING,
10958a690674SBen Greear 	SCAN_ONCHANNEL_SCANNING,
10968789d459SJohannes Berg 	SCAN_COMPLETED,
10978789d459SJohannes Berg 	SCAN_ABORTED,
1098a754055aSEmmanuel Grumbach 	SCAN_HW_CANCELLED,
1099142b9f50SHelmut Schaa };
1100142b9f50SHelmut Schaa 
1101142b9f50SHelmut Schaa /**
1102142b9f50SHelmut Schaa  * enum mac80211_scan_state - scan state machine states
1103142b9f50SHelmut Schaa  *
1104142b9f50SHelmut Schaa  * @SCAN_DECISION: Main entry point to the scan state machine, this state
1105142b9f50SHelmut Schaa  *	determines if we should keep on scanning or switch back to the
1106142b9f50SHelmut Schaa  *	operating channel
1107142b9f50SHelmut Schaa  * @SCAN_SET_CHANNEL: Set the next channel to be scanned
1108142b9f50SHelmut Schaa  * @SCAN_SEND_PROBE: Send probe requests and wait for probe responses
110907ef03eeSJohannes Berg  * @SCAN_SUSPEND: Suspend the scan and go back to operating channel to
111007ef03eeSJohannes Berg  *	send out data
111107ef03eeSJohannes Berg  * @SCAN_RESUME: Resume the scan and scan the next channel
1112cd2bb512SSam Leffler  * @SCAN_ABORT: Abort the scan and go back to operating channel
1113142b9f50SHelmut Schaa  */
1114142b9f50SHelmut Schaa enum mac80211_scan_state {
1115142b9f50SHelmut Schaa 	SCAN_DECISION,
1116142b9f50SHelmut Schaa 	SCAN_SET_CHANNEL,
1117142b9f50SHelmut Schaa 	SCAN_SEND_PROBE,
111807ef03eeSJohannes Berg 	SCAN_SUSPEND,
111907ef03eeSJohannes Berg 	SCAN_RESUME,
1120cd2bb512SSam Leffler 	SCAN_ABORT,
1121fbe9c429SHelmut Schaa };
1122fbe9c429SHelmut Schaa 
1123f0706e82SJiri Benc struct ieee80211_local {
1124f0706e82SJiri Benc 	/* embed the driver visible part.
1125f0706e82SJiri Benc 	 * don't cast (use the static inlines below), but we keep
1126f0706e82SJiri Benc 	 * it first anyway so they become a no-op */
1127f0706e82SJiri Benc 	struct ieee80211_hw hw;
1128f0706e82SJiri Benc 
1129fa962b92SMichal Kazior 	struct fq fq;
11305caa328eSMichal Kazior 	struct codel_vars *cvars;
11315caa328eSMichal Kazior 	struct codel_params cparams;
1132fa962b92SMichal Kazior 
1133f0706e82SJiri Benc 	const struct ieee80211_ops *ops;
1134f0706e82SJiri Benc 
113542935ecaSLuis R. Rodriguez 	/*
113642935ecaSLuis R. Rodriguez 	 * private workqueue to mac80211. mac80211 makes this accessible
113742935ecaSLuis R. Rodriguez 	 * via ieee80211_queue_work()
113842935ecaSLuis R. Rodriguez 	 */
113942935ecaSLuis R. Rodriguez 	struct workqueue_struct *workqueue;
114042935ecaSLuis R. Rodriguez 
1141e4e72fb4SJohannes Berg 	unsigned long queue_stop_reasons[IEEE80211_MAX_QUEUES];
1142cca07b00SLuciano Coelho 	int q_stop_reasons[IEEE80211_MAX_QUEUES][IEEE80211_QUEUE_STOP_REASONS];
114396f5e66eSJohannes Berg 	/* also used to protect ampdu_ac_queue and amdpu_ac_stop_refcnt */
1144ce7c9111SKalle Valo 	spinlock_t queue_stop_reason_lock;
114596f5e66eSJohannes Berg 
1146f0706e82SJiri Benc 	int open_count;
11473d30d949SMichael Wu 	int monitors, cooked_mntrs;
11488cc9a739SMichael Wu 	/* number of interfaces with corresponding FIF_ flags */
11497be5086dSJohannes Berg 	int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss, fif_pspoll,
11507be5086dSJohannes Berg 	    fif_probe_req;
11517be5086dSJohannes Berg 	int probe_req_reg;
11524150c572SJohannes Berg 	unsigned int filter_flags; /* FIF_* */
11533b8d81e0SJohannes Berg 
11543ffc2a90SJohannes Berg 	bool wiphy_ciphers_allocated;
11553ffc2a90SJohannes Berg 
1156fe57d9f5SJohannes Berg 	bool use_chanctx;
1157fe57d9f5SJohannes Berg 
11583b8d81e0SJohannes Berg 	/* protects the aggregated multicast list and filter calls */
11593b8d81e0SJohannes Berg 	spinlock_t filter_lock;
11603b8d81e0SJohannes Berg 
11613ac64beeSJohannes Berg 	/* used for uploading changed mc list */
11623ac64beeSJohannes Berg 	struct work_struct reconfig_filter;
11633ac64beeSJohannes Berg 
11643b8d81e0SJohannes Berg 	/* aggregated multicast list */
116522bedad3SJiri Pirko 	struct netdev_hw_addr_list mc_list;
11663b8d81e0SJohannes Berg 
1167d0709a65SJohannes Berg 	bool tim_in_locked_section; /* see ieee80211_beacon_get() */
11685bb644a0SJohannes Berg 
11695bb644a0SJohannes Berg 	/*
11705bb644a0SJohannes Berg 	 * suspended is true if we finished all the suspend _and_ we have
11715bb644a0SJohannes Berg 	 * not yet come up from resume. This is to be used by mac80211
11725bb644a0SJohannes Berg 	 * to ensure driver sanity during suspend and mac80211's own
11735bb644a0SJohannes Berg 	 * sanity. It can eventually be used for WoW as well.
11745bb644a0SJohannes Berg 	 */
11755bb644a0SJohannes Berg 	bool suspended;
11765bb644a0SJohannes Berg 
11775bb644a0SJohannes Berg 	/*
1178ceb99fe0SJohannes Berg 	 * Resuming is true while suspended, but when we're reprogramming the
1179ceb99fe0SJohannes Berg 	 * hardware -- at that time it's allowed to use ieee80211_queue_work()
1180ceb99fe0SJohannes Berg 	 * again even though some other parts of the stack are still suspended
1181ceb99fe0SJohannes Berg 	 * and we still drop received frames to avoid waking the stack.
1182ceb99fe0SJohannes Berg 	 */
1183ceb99fe0SJohannes Berg 	bool resuming;
1184ceb99fe0SJohannes Berg 
1185ceb99fe0SJohannes Berg 	/*
11865bb644a0SJohannes Berg 	 * quiescing is true during the suspend process _only_ to
11875bb644a0SJohannes Berg 	 * ease timer cancelling etc.
11885bb644a0SJohannes Berg 	 */
11895bb644a0SJohannes Berg 	bool quiescing;
11905bb644a0SJohannes Berg 
1191ea77f12fSJohannes Berg 	/* device is started */
1192ea77f12fSJohannes Berg 	bool started;
1193ea77f12fSJohannes Berg 
119404800adaSArik Nemtsov 	/* device is during a HW reconfig */
119504800adaSArik Nemtsov 	bool in_reconfig;
119604800adaSArik Nemtsov 
1197eecc4800SJohannes Berg 	/* wowlan is enabled -- don't reconfig on resume */
1198eecc4800SJohannes Berg 	bool wowlan;
1199eecc4800SJohannes Berg 
1200164eb02dSSimon Wunderlich 	struct work_struct radar_detected_work;
1201164eb02dSSimon Wunderlich 
120204ecd257SJohannes Berg 	/* number of RX chains the hardware has */
120304ecd257SJohannes Berg 	u8 rx_chains;
120404ecd257SJohannes Berg 
1205b306f453SJohannes Berg 	int tx_headroom; /* required headroom for hardware/radiotap */
1206f0706e82SJiri Benc 
1207f0706e82SJiri Benc 	/* Tasklet and skb queue to process calls from IRQ mode. All frames
1208f0706e82SJiri Benc 	 * added to skb_queue will be processed, but frames in
1209f0706e82SJiri Benc 	 * skb_queue_unreliable may be dropped if the total length of these
1210f0706e82SJiri Benc 	 * queues increases over the limit. */
1211f0706e82SJiri Benc #define IEEE80211_IRQSAFE_QUEUE_LIMIT 128
1212f0706e82SJiri Benc 	struct tasklet_struct tasklet;
1213f0706e82SJiri Benc 	struct sk_buff_head skb_queue;
1214f0706e82SJiri Benc 	struct sk_buff_head skb_queue_unreliable;
1215f0706e82SJiri Benc 
1216f9e124fbSChristian Lamparter 	spinlock_t rx_path_lock;
121724a8fdadSChristian Lamparter 
1218d0709a65SJohannes Berg 	/* Station data */
1219d0709a65SJohannes Berg 	/*
12204d33960bSJohannes Berg 	 * The mutex only protects the list, hash table and
12214d33960bSJohannes Berg 	 * counter, reads are done with RCU.
1222d0709a65SJohannes Berg 	 */
122334e89507SJohannes Berg 	struct mutex sta_mtx;
12244d33960bSJohannes Berg 	spinlock_t tim_lock;
1225d0709a65SJohannes Berg 	unsigned long num_sta;
12264d33960bSJohannes Berg 	struct list_head sta_list;
122783e7e4ceSHerbert Xu 	struct rhltable sta_hash;
1228f0706e82SJiri Benc 	struct timer_list sta_cleanup;
1229f5ea9120SJohannes Berg 	int sta_generation;
1230f0706e82SJiri Benc 
12312a577d98SJohannes Berg 	struct sk_buff_head pending[IEEE80211_MAX_QUEUES];
1232f0706e82SJiri Benc 	struct tasklet_struct tx_pending_tasklet;
1233f0706e82SJiri Benc 
1234a6a67db2SJohannes Berg 	atomic_t agg_queue_stop[IEEE80211_MAX_QUEUES];
1235cd8ffc80SJohannes Berg 
1236df140465SJohannes Berg 	/* number of interfaces with allmulti RX */
1237df140465SJohannes Berg 	atomic_t iff_allmultis;
1238f0706e82SJiri Benc 
1239f0706e82SJiri Benc 	struct rate_control_ref *rate_ctrl;
1240f0706e82SJiri Benc 
12415f9f1812SFelix Fietkau 	struct crypto_cipher *wep_tx_tfm;
12425f9f1812SFelix Fietkau 	struct crypto_cipher *wep_rx_tfm;
1243f0706e82SJiri Benc 	u32 wep_iv;
1244f0706e82SJiri Benc 
1245c771c9d8SJohannes Berg 	/* see iface.c */
124679010420SJohannes Berg 	struct list_head interfaces;
1247f64331d5SJohannes Berg 	struct list_head mon_list; /* only that are IFF_UP && !cooked */
1248c771c9d8SJohannes Berg 	struct mutex iflist_mtx;
124979010420SJohannes Berg 
1250b16bd15cSJohannes Berg 	/*
1251ad0e2b5aSJohannes Berg 	 * Key mutex, protects sdata's key_list and sta_info's
1252b16bd15cSJohannes Berg 	 * key pointers (write access, they're RCU.)
1253b16bd15cSJohannes Berg 	 */
1254ad0e2b5aSJohannes Berg 	struct mutex key_mtx;
1255b16bd15cSJohannes Berg 
1256a1699b75SJohannes Berg 	/* mutex for scan and work locking */
1257a1699b75SJohannes Berg 	struct mutex mtx;
1258b16bd15cSJohannes Berg 
1259c2b13452SJohannes Berg 	/* Scanning and BSS list */
1260fbe9c429SHelmut Schaa 	unsigned long scanning;
12612a519311SJohannes Berg 	struct cfg80211_ssid scan_ssid;
12625ba63533SJohannes Berg 	struct cfg80211_scan_request *int_scan_req;
12636ea0a69cSJohannes Berg 	struct cfg80211_scan_request __rcu *scan_req;
1264c56ef672SDavid Spinadel 	struct ieee80211_scan_request *hw_scan_req;
12657ca15a0aSSimon Wunderlich 	struct cfg80211_chan_def scan_chandef;
126657fbcce3SJohannes Berg 	enum nl80211_band hw_scan_band;
1267f0706e82SJiri Benc 	int scan_channel_idx;
1268de95a54bSJohannes Berg 	int scan_ies_len;
1269c604b9f2SJohannes Berg 	int hw_scan_ies_bufsize;
12707947d3e0SAvraham Stern 	struct cfg80211_scan_info scan_info;
12718318d78aSJohannes Berg 
127285a9994aSLuciano Coelho 	struct work_struct sched_scan_stopped_work;
12735260a5b2SJohannes Berg 	struct ieee80211_sub_if_data __rcu *sched_scan_sdata;
12746ea0a69cSJohannes Berg 	struct cfg80211_sched_scan_request __rcu *sched_scan_req;
1275a344d677SJohannes Berg 	u8 scan_addr[ETH_ALEN];
127679f460caSLuciano Coelho 
1277df13cce5SHelmut Schaa 	unsigned long leave_oper_channel_time;
1278977923b0SHelmut Schaa 	enum mac80211_scan_state next_scan_state;
1279f0706e82SJiri Benc 	struct delayed_work scan_work;
1280e2fd5dbcSJohannes Berg 	struct ieee80211_sub_if_data __rcu *scan_sdata;
128155de908aSJohannes Berg 	/* For backward compatibility only -- do not use */
1282675a0b04SKarl Beldan 	struct cfg80211_chan_def _oper_chandef;
1283f0706e82SJiri Benc 
1284b8bc4b0aSJohannes Berg 	/* Temporary remain-on-channel for off-channel operations */
1285b8bc4b0aSJohannes Berg 	struct ieee80211_channel *tmp_channel;
1286b8bc4b0aSJohannes Berg 
1287d01a1e65SMichal Kazior 	/* channel contexts */
1288d01a1e65SMichal Kazior 	struct list_head chanctx_list;
1289d01a1e65SMichal Kazior 	struct mutex chanctx_mtx;
1290d01a1e65SMichal Kazior 
1291c206ca67SJohannes Berg #ifdef CONFIG_MAC80211_LEDS
12928d5c2585SJohannes Berg 	struct led_trigger tx_led, rx_led, assoc_led, radio_led;
12938d5c2585SJohannes Berg 	struct led_trigger tpt_led;
12948d5c2585SJohannes Berg 	atomic_t tx_led_active, rx_led_active, assoc_led_active;
12958d5c2585SJohannes Berg 	atomic_t radio_led_active, tpt_led_active;
1296c206ca67SJohannes Berg 	struct tpt_led_trigger *tpt_led_trigger;
1297c206ca67SJohannes Berg #endif
1298c206ca67SJohannes Berg 
1299c206ca67SJohannes Berg #ifdef CONFIG_MAC80211_DEBUG_COUNTERS
1300f0706e82SJiri Benc 	/* SNMP counters */
1301f0706e82SJiri Benc 	/* dot11CountersTable */
1302f0706e82SJiri Benc 	u32 dot11TransmittedFragmentCount;
1303f0706e82SJiri Benc 	u32 dot11MulticastTransmittedFrameCount;
1304f0706e82SJiri Benc 	u32 dot11FailedCount;
1305f0706e82SJiri Benc 	u32 dot11RetryCount;
1306f0706e82SJiri Benc 	u32 dot11MultipleRetryCount;
1307f0706e82SJiri Benc 	u32 dot11FrameDuplicateCount;
1308f0706e82SJiri Benc 	u32 dot11ReceivedFragmentCount;
1309f0706e82SJiri Benc 	u32 dot11MulticastReceivedFrameCount;
1310f0706e82SJiri Benc 	u32 dot11TransmittedFrameCount;
1311f0706e82SJiri Benc 
1312f0706e82SJiri Benc 	/* TX/RX handler statistics */
1313f0706e82SJiri Benc 	unsigned int tx_handlers_drop;
1314f0706e82SJiri Benc 	unsigned int tx_handlers_queued;
1315f0706e82SJiri Benc 	unsigned int tx_handlers_drop_wep;
1316f0706e82SJiri Benc 	unsigned int tx_handlers_drop_not_assoc;
1317f0706e82SJiri Benc 	unsigned int tx_handlers_drop_unauth_port;
1318f0706e82SJiri Benc 	unsigned int rx_handlers_drop;
1319f0706e82SJiri Benc 	unsigned int rx_handlers_queued;
1320f0706e82SJiri Benc 	unsigned int rx_handlers_drop_nullfunc;
1321f0706e82SJiri Benc 	unsigned int rx_handlers_drop_defrag;
1322f0706e82SJiri Benc 	unsigned int tx_expand_skb_head;
1323f0706e82SJiri Benc 	unsigned int tx_expand_skb_head_cloned;
1324f1160434SJohannes Berg 	unsigned int rx_expand_skb_head_defrag;
1325f0706e82SJiri Benc 	unsigned int rx_handlers_fragments;
1326f0706e82SJiri Benc 	unsigned int tx_status_drop;
1327f0706e82SJiri Benc #define I802_DEBUG_INC(c) (c)++
1328f0706e82SJiri Benc #else /* CONFIG_MAC80211_DEBUG_COUNTERS */
1329f0706e82SJiri Benc #define I802_DEBUG_INC(c) do { } while (0)
1330f0706e82SJiri Benc #endif /* CONFIG_MAC80211_DEBUG_COUNTERS */
1331f0706e82SJiri Benc 
1332f0706e82SJiri Benc 
1333f0706e82SJiri Benc 	int total_ps_buffered; /* total number of all buffered unicast and
1334f0706e82SJiri Benc 				* multicast packets for power saving stations
1335f0706e82SJiri Benc 				*/
1336520eb820SKalle Valo 
1337572e0012SKalle Valo 	bool pspolling;
1338b203ffc3SJouni Malinen 	bool offchannel_ps_enabled;
1339965bedadSJohannes Berg 	/*
1340965bedadSJohannes Berg 	 * PS can only be enabled when we have exactly one managed
1341965bedadSJohannes Berg 	 * interface (and monitors) in PS, this then points there.
1342965bedadSJohannes Berg 	 */
1343965bedadSJohannes Berg 	struct ieee80211_sub_if_data *ps_sdata;
1344520eb820SKalle Valo 	struct work_struct dynamic_ps_enable_work;
1345520eb820SKalle Valo 	struct work_struct dynamic_ps_disable_work;
1346520eb820SKalle Valo 	struct timer_list dynamic_ps_timer;
13472b2c009eSJuuso Oikarinen 	struct notifier_block ifa_notifier;
1348a65240c1SJohannes Berg 	struct notifier_block ifa6_notifier;
1349f0706e82SJiri Benc 
1350ff616381SJuuso Oikarinen 	/*
1351ff616381SJuuso Oikarinen 	 * The dynamic ps timeout configured from user space via WEXT -
1352ff616381SJuuso Oikarinen 	 * this will override whatever chosen by mac80211 internally.
1353ff616381SJuuso Oikarinen 	 */
1354ff616381SJuuso Oikarinen 	int dynamic_ps_forced_timeout;
1355ff616381SJuuso Oikarinen 
13561ea6f9c0SJohannes Berg 	int user_power_level; /* in dBm, for all interfaces */
13572bf30fabSJohannes Berg 
13580f78231bSJohannes Berg 	enum ieee80211_smps_mode smps_mode;
13590f78231bSJohannes Berg 
1360f2753ddbSJohannes Berg 	struct work_struct restart_work;
1361f2753ddbSJohannes Berg 
1362e9f207f0SJiri Benc #ifdef CONFIG_MAC80211_DEBUGFS
1363e9f207f0SJiri Benc 	struct local_debugfsdentries {
13644b7679a5SJohannes Berg 		struct dentry *rcdir;
1365e9f207f0SJiri Benc 		struct dentry *keys;
1366e9f207f0SJiri Benc 	} debugfs;
1367e9f207f0SJiri Benc #endif
13684e6cbfd0SJohn W. Linville 
13692eb278e0SJohannes Berg 	/*
13702eb278e0SJohannes Berg 	 * Remain-on-channel support
13712eb278e0SJohannes Berg 	 */
1372aaa016ccSJohannes Berg 	struct delayed_work roc_work;
13732eb278e0SJohannes Berg 	struct list_head roc_list;
137421f83589SJohannes Berg 	struct work_struct hw_roc_start, hw_roc_done;
13752eb278e0SJohannes Berg 	unsigned long hw_roc_start_time;
137650febf6aSJohannes Berg 	u64 roc_cookie_counter;
137721f83589SJohannes Berg 
1378a729cff8SJohannes Berg 	struct idr ack_status_frames;
1379a729cff8SJohannes Berg 	spinlock_t ack_status_lock;
1380a729cff8SJohannes Berg 
1381f142c6b9SJohannes Berg 	struct ieee80211_sub_if_data __rcu *p2p_sdata;
1382f142c6b9SJohannes Berg 
13834b6f1dd6SJohannes Berg 	/* virtual monitor interface */
13844b6f1dd6SJohannes Berg 	struct ieee80211_sub_if_data __rcu *monitor_sdata;
13854bf88530SJohannes Berg 	struct cfg80211_chan_def monitor_chandef;
1386e9a21949SLuciano Coelho 
1387e9a21949SLuciano Coelho 	/* extended capabilities provided by mac80211 */
1388e9a21949SLuciano Coelho 	u8 ext_capa[8];
1389c8ff71e6SArik Nemtsov 
1390c8ff71e6SArik Nemtsov 	/* TDLS channel switch */
1391c8ff71e6SArik Nemtsov 	struct work_struct tdls_chsw_work;
1392c8ff71e6SArik Nemtsov 	struct sk_buff_head skb_queue_tdls_chsw;
1393f0706e82SJiri Benc };
1394f0706e82SJiri Benc 
13953e122be0SJohannes Berg static inline struct ieee80211_sub_if_data *
13963e122be0SJohannes Berg IEEE80211_DEV_TO_SUB_IF(struct net_device *dev)
13973e122be0SJohannes Berg {
13983e122be0SJohannes Berg 	return netdev_priv(dev);
13993e122be0SJohannes Berg }
14003e122be0SJohannes Berg 
140171bbc994SJohannes Berg static inline struct ieee80211_sub_if_data *
140271bbc994SJohannes Berg IEEE80211_WDEV_TO_SUB_IF(struct wireless_dev *wdev)
140371bbc994SJohannes Berg {
140471bbc994SJohannes Berg 	return container_of(wdev, struct ieee80211_sub_if_data, wdev);
140571bbc994SJohannes Berg }
140671bbc994SJohannes Berg 
140721a8e9ddSMohammed Shafi Shajakhan static inline struct ieee80211_supported_band *
140821a8e9ddSMohammed Shafi Shajakhan ieee80211_get_sband(struct ieee80211_sub_if_data *sdata)
140921a8e9ddSMohammed Shafi Shajakhan {
141021a8e9ddSMohammed Shafi Shajakhan 	struct ieee80211_local *local = sdata->local;
141121a8e9ddSMohammed Shafi Shajakhan 	struct ieee80211_chanctx_conf *chanctx_conf;
141221a8e9ddSMohammed Shafi Shajakhan 	enum nl80211_band band;
141321a8e9ddSMohammed Shafi Shajakhan 
141421a8e9ddSMohammed Shafi Shajakhan 	rcu_read_lock();
141521a8e9ddSMohammed Shafi Shajakhan 	chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
141621a8e9ddSMohammed Shafi Shajakhan 
141721a8e9ddSMohammed Shafi Shajakhan 	if (WARN_ON(!chanctx_conf)) {
141821a8e9ddSMohammed Shafi Shajakhan 		rcu_read_unlock();
141921a8e9ddSMohammed Shafi Shajakhan 		return NULL;
142021a8e9ddSMohammed Shafi Shajakhan 	}
142121a8e9ddSMohammed Shafi Shajakhan 
142221a8e9ddSMohammed Shafi Shajakhan 	band = chanctx_conf->def.chan->band;
142321a8e9ddSMohammed Shafi Shajakhan 	rcu_read_unlock();
142421a8e9ddSMohammed Shafi Shajakhan 
142521a8e9ddSMohammed Shafi Shajakhan 	return local->hw.wiphy->bands[band];
142621a8e9ddSMohammed Shafi Shajakhan }
142721a8e9ddSMohammed Shafi Shajakhan 
1428c0f17eb9SChun-Yeow Yeoh /* this struct holds the value parsing from channel switch IE  */
1429c0f17eb9SChun-Yeow Yeoh struct ieee80211_csa_ie {
1430c0f17eb9SChun-Yeow Yeoh 	struct cfg80211_chan_def chandef;
1431c0f17eb9SChun-Yeow Yeoh 	u8 mode;
1432c0f17eb9SChun-Yeow Yeoh 	u8 count;
1433c0f17eb9SChun-Yeow Yeoh 	u8 ttl;
14343f718fd8SChun-Yeow Yeoh 	u16 pre_value;
1435c0f17eb9SChun-Yeow Yeoh };
1436c0f17eb9SChun-Yeow Yeoh 
1437dd76986bSJohannes Berg /* Parsed Information Elements */
1438dd76986bSJohannes Berg struct ieee802_11_elems {
14394a3cb702SJohannes Berg 	const u8 *ie_start;
1440dd76986bSJohannes Berg 	size_t total_len;
1441dd76986bSJohannes Berg 
1442dd76986bSJohannes Berg 	/* pointers to IEs */
144353837584SArik Nemtsov 	const struct ieee80211_tdls_lnkie *lnk_id;
144453837584SArik Nemtsov 	const struct ieee80211_ch_switch_timing *ch_sw_timing;
14459041c1faSArik Nemtsov 	const u8 *ext_capab;
14464a3cb702SJohannes Berg 	const u8 *ssid;
14474a3cb702SJohannes Berg 	const u8 *supp_rates;
14484a3cb702SJohannes Berg 	const u8 *ds_params;
14494a3cb702SJohannes Berg 	const struct ieee80211_tim_ie *tim;
14504a3cb702SJohannes Berg 	const u8 *challenge;
14514a3cb702SJohannes Berg 	const u8 *rsn;
14524a3cb702SJohannes Berg 	const u8 *erp_info;
14534a3cb702SJohannes Berg 	const u8 *ext_supp_rates;
14544a3cb702SJohannes Berg 	const u8 *wmm_info;
14554a3cb702SJohannes Berg 	const u8 *wmm_param;
14564a3cb702SJohannes Berg 	const struct ieee80211_ht_cap *ht_cap_elem;
14574a3cb702SJohannes Berg 	const struct ieee80211_ht_operation *ht_operation;
14584a3cb702SJohannes Berg 	const struct ieee80211_vht_cap *vht_cap_elem;
14594a3cb702SJohannes Berg 	const struct ieee80211_vht_operation *vht_operation;
14604a3cb702SJohannes Berg 	const struct ieee80211_meshconf_ie *mesh_config;
14614a3cb702SJohannes Berg 	const u8 *mesh_id;
14624a3cb702SJohannes Berg 	const u8 *peering;
14634a3cb702SJohannes Berg 	const __le16 *awake_window;
14644a3cb702SJohannes Berg 	const u8 *preq;
14654a3cb702SJohannes Berg 	const u8 *prep;
14664a3cb702SJohannes Berg 	const u8 *perr;
14674a3cb702SJohannes Berg 	const struct ieee80211_rann_ie *rann;
14684a3cb702SJohannes Berg 	const struct ieee80211_channel_sw_ie *ch_switch_ie;
1469b4f286a1SJohannes Berg 	const struct ieee80211_ext_chansw_ie *ext_chansw_ie;
1470b2e506bfSJohannes Berg 	const struct ieee80211_wide_bw_chansw_ie *wide_bw_chansw_ie;
14714a3cb702SJohannes Berg 	const u8 *country_elem;
14724a3cb702SJohannes Berg 	const u8 *pwr_constr_elem;
1473c8d65917SSteinar H. Gunderson 	const u8 *cisco_dtpc_elem;
147479ba1d89SJohannes Berg 	const struct ieee80211_timeout_interval_ie *timeout_int;
14754a3cb702SJohannes Berg 	const u8 *opmode_notif;
147685220d71SJohannes Berg 	const struct ieee80211_sec_chan_offs_ie *sec_chan_offs;
14778f2535b9SChun-Yeow Yeoh 	const struct ieee80211_mesh_chansw_params_ie *mesh_chansw_params_ie;
1478e38a017bSAvraham Stern 	const struct ieee80211_bss_max_idle_period_ie *max_idle_period_ie;
1479dd76986bSJohannes Berg 
1480dd76986bSJohannes Berg 	/* length of them, respectively */
14819041c1faSArik Nemtsov 	u8 ext_capab_len;
1482dd76986bSJohannes Berg 	u8 ssid_len;
1483dd76986bSJohannes Berg 	u8 supp_rates_len;
1484dd76986bSJohannes Berg 	u8 tim_len;
1485dd76986bSJohannes Berg 	u8 challenge_len;
1486dd76986bSJohannes Berg 	u8 rsn_len;
1487dd76986bSJohannes Berg 	u8 ext_supp_rates_len;
1488dd76986bSJohannes Berg 	u8 wmm_info_len;
1489dd76986bSJohannes Berg 	u8 wmm_param_len;
1490dd76986bSJohannes Berg 	u8 mesh_id_len;
1491dd76986bSJohannes Berg 	u8 peering_len;
1492dd76986bSJohannes Berg 	u8 preq_len;
1493dd76986bSJohannes Berg 	u8 prep_len;
1494dd76986bSJohannes Berg 	u8 perr_len;
1495dd76986bSJohannes Berg 	u8 country_elem_len;
1496fcff4f10SPaul Stewart 
1497fcff4f10SPaul Stewart 	/* whether a parse error occurred while retrieving these elements */
1498fcff4f10SPaul Stewart 	bool parse_error;
1499dd76986bSJohannes Berg };
1500dd76986bSJohannes Berg 
1501f0706e82SJiri Benc static inline struct ieee80211_local *hw_to_local(
1502f0706e82SJiri Benc 	struct ieee80211_hw *hw)
1503f0706e82SJiri Benc {
1504f0706e82SJiri Benc 	return container_of(hw, struct ieee80211_local, hw);
1505f0706e82SJiri Benc }
1506f0706e82SJiri Benc 
1507ba8c3d6fSFelix Fietkau static inline struct txq_info *to_txq_info(struct ieee80211_txq *txq)
1508ba8c3d6fSFelix Fietkau {
1509ba8c3d6fSFelix Fietkau 	return container_of(txq, struct txq_info, txq);
1510ba8c3d6fSFelix Fietkau }
1511f0706e82SJiri Benc 
1512bb42f2d1SToke Høiland-Jørgensen static inline bool txq_has_queue(struct ieee80211_txq *txq)
1513bb42f2d1SToke Høiland-Jørgensen {
1514bb42f2d1SToke Høiland-Jørgensen 	struct txq_info *txqi = to_txq_info(txq);
1515bb42f2d1SToke Høiland-Jørgensen 
1516bb42f2d1SToke Høiland-Jørgensen 	return !(skb_queue_empty(&txqi->frags) && !txqi->tin.backlog_packets);
1517bb42f2d1SToke Høiland-Jørgensen }
1518bb42f2d1SToke Høiland-Jørgensen 
1519571ecf67SJohannes Berg static inline int ieee80211_bssid_match(const u8 *raddr, const u8 *addr)
1520571ecf67SJohannes Berg {
1521b203ca39SJoe Perches 	return ether_addr_equal(raddr, addr) ||
1522571ecf67SJohannes Berg 	       is_broadcast_ether_addr(raddr);
1523571ecf67SJohannes Berg }
1524571ecf67SJohannes Berg 
1525f4bda337SThomas Pedersen static inline bool
1526f4bda337SThomas Pedersen ieee80211_have_rx_timestamp(struct ieee80211_rx_status *status)
1527f4bda337SThomas Pedersen {
1528f4bda337SThomas Pedersen 	WARN_ON_ONCE(status->flag & RX_FLAG_MACTIME_START &&
1529f4bda337SThomas Pedersen 		     status->flag & RX_FLAG_MACTIME_END);
1530f4a0f0c5SJohannes Berg 	if (status->flag & (RX_FLAG_MACTIME_START | RX_FLAG_MACTIME_END))
1531f4a0f0c5SJohannes Berg 		return true;
1532da6a4352SJohannes Berg 	/* can't handle non-legacy preamble yet */
1533f4a0f0c5SJohannes Berg 	if (status->flag & RX_FLAG_MACTIME_PLCP_START &&
1534204a7dbcSAvraham Stern 	    status->encoding == RX_ENC_LEGACY)
1535f4a0f0c5SJohannes Berg 		return true;
1536f4a0f0c5SJohannes Berg 	return false;
1537f4bda337SThomas Pedersen }
1538571ecf67SJohannes Berg 
153972f15d53SMichael Braun void ieee80211_vif_inc_num_mcast(struct ieee80211_sub_if_data *sdata);
154072f15d53SMichael Braun void ieee80211_vif_dec_num_mcast(struct ieee80211_sub_if_data *sdata);
154172f15d53SMichael Braun 
154272f15d53SMichael Braun /* This function returns the number of multicast stations connected to this
154372f15d53SMichael Braun  * interface. It returns -1 if that number is not tracked, that is for netdevs
154472f15d53SMichael Braun  * not in AP or AP_VLAN mode or when using 4addr.
154572f15d53SMichael Braun  */
154672f15d53SMichael Braun static inline int
154772f15d53SMichael Braun ieee80211_vif_get_num_mcast_if(struct ieee80211_sub_if_data *sdata)
154872f15d53SMichael Braun {
154972f15d53SMichael Braun 	if (sdata->vif.type == NL80211_IFTYPE_AP)
155072f15d53SMichael Braun 		return atomic_read(&sdata->u.ap.num_mcast_sta);
155172f15d53SMichael Braun 	if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN && !sdata->u.vlan.sta)
155272f15d53SMichael Braun 		return atomic_read(&sdata->u.vlan.num_mcast_sta);
155372f15d53SMichael Braun 	return -1;
155472f15d53SMichael Braun }
155572f15d53SMichael Braun 
1556f4bda337SThomas Pedersen u64 ieee80211_calculate_rx_timestamp(struct ieee80211_local *local,
1557f4bda337SThomas Pedersen 				     struct ieee80211_rx_status *status,
1558f4bda337SThomas Pedersen 				     unsigned int mpdu_len,
1559f4bda337SThomas Pedersen 				     unsigned int mpdu_offset);
1560e8975581SJohannes Berg int ieee80211_hw_config(struct ieee80211_local *local, u32 changed);
15615cf121c3SJohannes Berg void ieee80211_tx_set_protected(struct ieee80211_tx_data *tx);
15629c6bd790SJohannes Berg void ieee80211_bss_info_change_notify(struct ieee80211_sub_if_data *sdata,
15639c6bd790SJohannes Berg 				      u32 changed);
15640d143fe1SJohannes Berg void ieee80211_configure_filter(struct ieee80211_local *local);
156546900298SJohannes Berg u32 ieee80211_reset_erp_info(struct ieee80211_sub_if_data *sdata);
1566f0706e82SJiri Benc 
1567a2fcfccbSJohannes Berg u64 ieee80211_mgmt_tx_cookie(struct ieee80211_local *local);
15685ee00dbdSJohannes Berg int ieee80211_attach_ack_skb(struct ieee80211_local *local, struct sk_buff *skb,
15695ee00dbdSJohannes Berg 			     u64 *cookie, gfp_t gfp);
1570a2fcfccbSJohannes Berg 
157149ddf8e6SJohannes Berg void ieee80211_check_fast_rx(struct sta_info *sta);
157249ddf8e6SJohannes Berg void __ieee80211_check_fast_rx_iface(struct ieee80211_sub_if_data *sdata);
157349ddf8e6SJohannes Berg void ieee80211_check_fast_rx_iface(struct ieee80211_sub_if_data *sdata);
157449ddf8e6SJohannes Berg void ieee80211_clear_fast_rx(struct sta_info *sta);
157549ddf8e6SJohannes Berg 
157646900298SJohannes Berg /* STA code */
15779c6bd790SJohannes Berg void ieee80211_sta_setup_sdata(struct ieee80211_sub_if_data *sdata);
157877fdaa12SJohannes Berg int ieee80211_mgd_auth(struct ieee80211_sub_if_data *sdata,
157977fdaa12SJohannes Berg 		       struct cfg80211_auth_request *req);
158077fdaa12SJohannes Berg int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata,
158177fdaa12SJohannes Berg 			struct cfg80211_assoc_request *req);
158277fdaa12SJohannes Berg int ieee80211_mgd_deauth(struct ieee80211_sub_if_data *sdata,
158363c9c5e7SJohannes Berg 			 struct cfg80211_deauth_request *req);
158477fdaa12SJohannes Berg int ieee80211_mgd_disassoc(struct ieee80211_sub_if_data *sdata,
158563c9c5e7SJohannes Berg 			   struct cfg80211_disassoc_request *req);
1586572e0012SKalle Valo void ieee80211_send_pspoll(struct ieee80211_local *local,
1587572e0012SKalle Valo 			   struct ieee80211_sub_if_data *sdata);
15884a733ef1SJohannes Berg void ieee80211_recalc_ps(struct ieee80211_local *local);
1589ab095877SEliad Peller void ieee80211_recalc_ps_vif(struct ieee80211_sub_if_data *sdata);
15902b2c009eSJuuso Oikarinen int ieee80211_set_arp_filter(struct ieee80211_sub_if_data *sdata);
15911fa57d01SJohannes Berg void ieee80211_sta_work(struct ieee80211_sub_if_data *sdata);
15921fa57d01SJohannes Berg void ieee80211_sta_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
15931fa57d01SJohannes Berg 				  struct sk_buff *skb);
1594d3a910a8SLuis R. Rodriguez void ieee80211_sta_reset_beacon_monitor(struct ieee80211_sub_if_data *sdata);
1595be099e82SLuis R. Rodriguez void ieee80211_sta_reset_conn_monitor(struct ieee80211_sub_if_data *sdata);
1596afa762f6SEliad Peller void ieee80211_mgd_stop(struct ieee80211_sub_if_data *sdata);
15971672c0e3SJohannes Berg void ieee80211_mgd_conn_tx_status(struct ieee80211_sub_if_data *sdata,
15981672c0e3SJohannes Berg 				  __le16 fc, bool acked);
15991a1cb744SJohannes Berg void ieee80211_mgd_quiesce(struct ieee80211_sub_if_data *sdata);
1600b8360ab8SJohannes Berg void ieee80211_sta_restart(struct ieee80211_sub_if_data *sdata);
160102219b3aSJohannes Berg void ieee80211_sta_handle_tspec_ac_params(struct ieee80211_sub_if_data *sdata);
16029c6bd790SJohannes Berg 
160346900298SJohannes Berg /* IBSS code */
160446900298SJohannes Berg void ieee80211_ibss_notify_scan_completed(struct ieee80211_local *local);
160546900298SJohannes Berg void ieee80211_ibss_setup_sdata(struct ieee80211_sub_if_data *sdata);
16068bf11d8dSJohannes Berg void ieee80211_ibss_rx_no_sta(struct ieee80211_sub_if_data *sdata,
16078bf11d8dSJohannes Berg 			      const u8 *bssid, const u8 *addr, u32 supp_rates);
1608af8cdcd8SJohannes Berg int ieee80211_ibss_join(struct ieee80211_sub_if_data *sdata,
1609af8cdcd8SJohannes Berg 			struct cfg80211_ibss_params *params);
1610af8cdcd8SJohannes Berg int ieee80211_ibss_leave(struct ieee80211_sub_if_data *sdata);
16111fa57d01SJohannes Berg void ieee80211_ibss_work(struct ieee80211_sub_if_data *sdata);
16121fa57d01SJohannes Berg void ieee80211_ibss_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
16131fa57d01SJohannes Berg 				   struct sk_buff *skb);
1614cd7760e6SSimon Wunderlich int ieee80211_ibss_csa_beacon(struct ieee80211_sub_if_data *sdata,
1615cd7760e6SSimon Wunderlich 			      struct cfg80211_csa_settings *csa_settings);
1616cd7760e6SSimon Wunderlich int ieee80211_ibss_finish_csa(struct ieee80211_sub_if_data *sdata);
1617cd7760e6SSimon Wunderlich void ieee80211_ibss_stop(struct ieee80211_sub_if_data *sdata);
16181fa57d01SJohannes Berg 
1619239281f8SRostislav Lisovy /* OCB code */
1620239281f8SRostislav Lisovy void ieee80211_ocb_work(struct ieee80211_sub_if_data *sdata);
1621239281f8SRostislav Lisovy void ieee80211_ocb_rx_no_sta(struct ieee80211_sub_if_data *sdata,
1622239281f8SRostislav Lisovy 			     const u8 *bssid, const u8 *addr, u32 supp_rates);
1623239281f8SRostislav Lisovy void ieee80211_ocb_setup_sdata(struct ieee80211_sub_if_data *sdata);
1624239281f8SRostislav Lisovy int ieee80211_ocb_join(struct ieee80211_sub_if_data *sdata,
1625239281f8SRostislav Lisovy 		       struct ocb_setup *setup);
1626239281f8SRostislav Lisovy int ieee80211_ocb_leave(struct ieee80211_sub_if_data *sdata);
1627239281f8SRostislav Lisovy 
16281fa57d01SJohannes Berg /* mesh code */
16291fa57d01SJohannes Berg void ieee80211_mesh_work(struct ieee80211_sub_if_data *sdata);
16301fa57d01SJohannes Berg void ieee80211_mesh_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
16311fa57d01SJohannes Berg 				   struct sk_buff *skb);
1632b8456a14SChun-Yeow Yeoh int ieee80211_mesh_csa_beacon(struct ieee80211_sub_if_data *sdata,
163366e01cf9SLuciano Coelho 			      struct cfg80211_csa_settings *csa_settings);
1634b8456a14SChun-Yeow Yeoh int ieee80211_mesh_finish_csa(struct ieee80211_sub_if_data *sdata);
163546900298SJohannes Berg 
16369c6bd790SJohannes Berg /* scan/BSS handling */
163746900298SJohannes Berg void ieee80211_scan_work(struct work_struct *work);
163834bcf715SStanislaw Gruszka int ieee80211_request_ibss_scan(struct ieee80211_sub_if_data *sdata,
1639be4a4b6aSJohannes Berg 				const u8 *ssid, u8 ssid_len,
164076bed0f4SJanusz.Dziedzic@tieto.com 				struct ieee80211_channel **channels,
164176bed0f4SJanusz.Dziedzic@tieto.com 				unsigned int n_channels,
16427ca15a0aSSimon Wunderlich 				enum nl80211_bss_scan_width scan_width);
1643c2b13452SJohannes Berg int ieee80211_request_scan(struct ieee80211_sub_if_data *sdata,
16442a519311SJohannes Berg 			   struct cfg80211_scan_request *req);
16455bb644a0SJohannes Berg void ieee80211_scan_cancel(struct ieee80211_local *local);
1646133d40f9SStanislaw Gruszka void ieee80211_run_deferred_scan(struct ieee80211_local *local);
1647d48b2968SJohannes Berg void ieee80211_scan_rx(struct ieee80211_local *local, struct sk_buff *skb);
16489c6bd790SJohannes Berg 
16490a51b27eSJohannes Berg void ieee80211_mlme_notify_scan_completed(struct ieee80211_local *local);
1650c2b13452SJohannes Berg struct ieee80211_bss *
165198c8fccfSJohannes Berg ieee80211_bss_info_update(struct ieee80211_local *local,
165298c8fccfSJohannes Berg 			  struct ieee80211_rx_status *rx_status,
165398c8fccfSJohannes Berg 			  struct ieee80211_mgmt *mgmt,
165498c8fccfSJohannes Berg 			  size_t len,
165598c8fccfSJohannes Berg 			  struct ieee802_11_elems *elems,
1656d45c4172SEmmanuel Grumbach 			  struct ieee80211_channel *channel);
165798c8fccfSJohannes Berg void ieee80211_rx_bss_put(struct ieee80211_local *local,
1658c2b13452SJohannes Berg 			  struct ieee80211_bss *bss);
1659ee385855SLuis Carlos Cobo 
166079f460caSLuciano Coelho /* scheduled scan handling */
1661d43c6b6eSDavid Spinadel int
1662d43c6b6eSDavid Spinadel __ieee80211_request_sched_scan_start(struct ieee80211_sub_if_data *sdata,
1663d43c6b6eSDavid Spinadel 				     struct cfg80211_sched_scan_request *req);
166479f460caSLuciano Coelho int ieee80211_request_sched_scan_start(struct ieee80211_sub_if_data *sdata,
166579f460caSLuciano Coelho 				       struct cfg80211_sched_scan_request *req);
16660d440ea2SEliad Peller int ieee80211_request_sched_scan_stop(struct ieee80211_local *local);
1667f6837ba8SJohannes Berg void ieee80211_sched_scan_end(struct ieee80211_local *local);
166885a9994aSLuciano Coelho void ieee80211_sched_scan_stopped_work(struct work_struct *work);
166979f460caSLuciano Coelho 
1670a2fcfccbSJohannes Berg /* off-channel/mgmt-tx */
1671aacde9eeSStanislaw Gruszka void ieee80211_offchannel_stop_vifs(struct ieee80211_local *local);
1672aacde9eeSStanislaw Gruszka void ieee80211_offchannel_return(struct ieee80211_local *local);
16732eb278e0SJohannes Berg void ieee80211_roc_setup(struct ieee80211_local *local);
16742eb278e0SJohannes Berg void ieee80211_start_next_roc(struct ieee80211_local *local);
1675c8f994eeSJohannes Berg void ieee80211_roc_purge(struct ieee80211_local *local,
1676c8f994eeSJohannes Berg 			 struct ieee80211_sub_if_data *sdata);
1677a2fcfccbSJohannes Berg int ieee80211_remain_on_channel(struct wiphy *wiphy, struct wireless_dev *wdev,
1678a2fcfccbSJohannes Berg 				struct ieee80211_channel *chan,
1679a2fcfccbSJohannes Berg 				unsigned int duration, u64 *cookie);
1680a2fcfccbSJohannes Berg int ieee80211_cancel_remain_on_channel(struct wiphy *wiphy,
1681a2fcfccbSJohannes Berg 				       struct wireless_dev *wdev, u64 cookie);
1682a2fcfccbSJohannes Berg int ieee80211_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev,
1683a2fcfccbSJohannes Berg 		      struct cfg80211_mgmt_tx_params *params, u64 *cookie);
1684a2fcfccbSJohannes Berg int ieee80211_mgmt_tx_cancel_wait(struct wiphy *wiphy,
1685a2fcfccbSJohannes Berg 				  struct wireless_dev *wdev, u64 cookie);
1686b203ffc3SJouni Malinen 
168773da7d5bSSimon Wunderlich /* channel switch handling */
168873da7d5bSSimon Wunderlich void ieee80211_csa_finalize_work(struct work_struct *work);
168982a8e17dSLuciano Coelho int ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev,
169082a8e17dSLuciano Coelho 			     struct cfg80211_csa_settings *params);
169173da7d5bSSimon Wunderlich 
16923e122be0SJohannes Berg /* interface handling */
169347846c9bSJohannes Berg int ieee80211_iface_init(void);
169447846c9bSJohannes Berg void ieee80211_iface_exit(void);
16953e122be0SJohannes Berg int ieee80211_if_add(struct ieee80211_local *local, const char *name,
16966bab2e19STom Gundersen 		     unsigned char name_assign_type,
169784efbb84SJohannes Berg 		     struct wireless_dev **new_wdev, enum nl80211_iftype type,
1698ee385855SLuis Carlos Cobo 		     struct vif_params *params);
1699f3947e2dSJohannes Berg int ieee80211_if_change_type(struct ieee80211_sub_if_data *sdata,
170005c914feSJohannes Berg 			     enum nl80211_iftype type);
1701f698d856SJasper Bryant-Greene void ieee80211_if_remove(struct ieee80211_sub_if_data *sdata);
170275636525SJohannes Berg void ieee80211_remove_interfaces(struct ieee80211_local *local);
1703382a103bSJohannes Berg u32 ieee80211_idle_off(struct ieee80211_local *local);
17045cff20e6SJohannes Berg void ieee80211_recalc_idle(struct ieee80211_local *local);
170585416a4fSChristian Lamparter void ieee80211_adjust_monitor_flags(struct ieee80211_sub_if_data *sdata,
170685416a4fSChristian Lamparter 				    const int offset);
1707f142c6b9SJohannes Berg int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up);
1708f142c6b9SJohannes Berg void ieee80211_sdata_stop(struct ieee80211_sub_if_data *sdata);
17093c3e21e7SJohannes Berg int ieee80211_add_virtual_monitor(struct ieee80211_local *local);
17103c3e21e7SJohannes Berg void ieee80211_del_virtual_monitor(struct ieee80211_local *local);
1711f0706e82SJiri Benc 
17121ea6f9c0SJohannes Berg bool __ieee80211_recalc_txpower(struct ieee80211_sub_if_data *sdata);
1713db82d8a9SLorenzo Bianconi void ieee80211_recalc_txpower(struct ieee80211_sub_if_data *sdata,
1714db82d8a9SLorenzo Bianconi 			      bool update_bss);
17151ea6f9c0SJohannes Berg 
17169607e6b6SJohannes Berg static inline bool ieee80211_sdata_running(struct ieee80211_sub_if_data *sdata)
17179607e6b6SJohannes Berg {
171834d4bc4dSJohannes Berg 	return test_bit(SDATA_STATE_RUNNING, &sdata->state);
17199607e6b6SJohannes Berg }
17209607e6b6SJohannes Berg 
1721e2ebc74dSJohannes Berg /* tx handling */
1722e2ebc74dSJohannes Berg void ieee80211_clear_tx_pending(struct ieee80211_local *local);
1723e2ebc74dSJohannes Berg void ieee80211_tx_pending(unsigned long data);
1724d0cf9c0dSStephen Hemminger netdev_tx_t ieee80211_monitor_start_xmit(struct sk_buff *skb,
1725d0cf9c0dSStephen Hemminger 					 struct net_device *dev);
1726d0cf9c0dSStephen Hemminger netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb,
1727d0cf9c0dSStephen Hemminger 				       struct net_device *dev);
172824d342c5SLiad Kaufman void __ieee80211_subif_start_xmit(struct sk_buff *skb,
172924d342c5SLiad Kaufman 				  struct net_device *dev,
173024d342c5SLiad Kaufman 				  u32 info_flags);
17311f98ab7fSFelix Fietkau void ieee80211_purge_tx_queue(struct ieee80211_hw *hw,
17321f98ab7fSFelix Fietkau 			      struct sk_buff_head *skbs);
17337528ec57SJohannes Berg struct sk_buff *
17347528ec57SJohannes Berg ieee80211_build_data_template(struct ieee80211_sub_if_data *sdata,
17357528ec57SJohannes Berg 			      struct sk_buff *skb, u32 info_flags);
17364dc792b8SHelmut Schaa void ieee80211_tx_monitor(struct ieee80211_local *local, struct sk_buff *skb,
17374dc792b8SHelmut Schaa 			  struct ieee80211_supported_band *sband,
17384dc792b8SHelmut Schaa 			  int retry_count, int shift, bool send_to_cooked);
1739e2ebc74dSJohannes Berg 
174017c18bf8SJohannes Berg void ieee80211_check_fast_xmit(struct sta_info *sta);
174117c18bf8SJohannes Berg void ieee80211_check_fast_xmit_all(struct ieee80211_local *local);
174217c18bf8SJohannes Berg void ieee80211_check_fast_xmit_iface(struct ieee80211_sub_if_data *sdata);
174317c18bf8SJohannes Berg void ieee80211_clear_fast_xmit(struct sta_info *sta);
174417c18bf8SJohannes Berg 
1745de1ede7aSJohannes Berg /* HT */
1746ef96a842SBen Greear void ieee80211_apply_htcap_overrides(struct ieee80211_sub_if_data *sdata,
1747ef96a842SBen Greear 				     struct ieee80211_sta_ht_cap *ht_cap);
1748e1a0c6b3SJohannes Berg bool ieee80211_ht_cap_ie_to_sta_ht_cap(struct ieee80211_sub_if_data *sdata,
1749ef96a842SBen Greear 				       struct ieee80211_supported_band *sband,
17504a3cb702SJohannes Berg 				       const struct ieee80211_ht_cap *ht_cap_ie,
1751e1a0c6b3SJohannes Berg 				       struct sta_info *sta);
1752b8695a8fSJohannes Berg void ieee80211_send_delba(struct ieee80211_sub_if_data *sdata,
1753b8695a8fSJohannes Berg 			  const u8 *da, u16 tid,
1754b8695a8fSJohannes Berg 			  u16 initiator, u16 reason_code);
17550f78231bSJohannes Berg int ieee80211_send_smps_action(struct ieee80211_sub_if_data *sdata,
17560f78231bSJohannes Berg 			       enum ieee80211_smps_mode smps, const u8 *da,
17570f78231bSJohannes Berg 			       const u8 *bssid);
1758687da132SEmmanuel Grumbach void ieee80211_request_smps_ap_work(struct work_struct *work);
1759687da132SEmmanuel Grumbach void ieee80211_request_smps_mgd_work(struct work_struct *work);
1760687da132SEmmanuel Grumbach bool ieee80211_smps_is_restrictive(enum ieee80211_smps_mode smps_mode_old,
1761687da132SEmmanuel Grumbach 				   enum ieee80211_smps_mode smps_mode_new);
1762de1ede7aSJohannes Berg 
17637c3b1dd8SJohannes Berg void ___ieee80211_stop_rx_ba_session(struct sta_info *sta, u16 tid,
176453f73c09SJohannes Berg 				     u16 initiator, u16 reason, bool stop);
1765849b7967SJohannes Berg void __ieee80211_stop_rx_ba_session(struct sta_info *sta, u16 tid,
176653f73c09SJohannes Berg 				    u16 initiator, u16 reason, bool stop);
176708cf42e8SMichal Kazior void __ieee80211_start_rx_ba_session(struct sta_info *sta,
176808cf42e8SMichal Kazior 				     u8 dialog_token, u16 timeout,
176908cf42e8SMichal Kazior 				     u16 start_seq_num, u16 ba_policy, u16 tid,
17704549cf2bSMichal Kazior 				     u16 buf_size, bool tx, bool auto_seq);
1771c82c4a80SJohannes Berg void ieee80211_sta_tear_down_BA_sessions(struct sta_info *sta,
1772c82c4a80SJohannes Berg 					 enum ieee80211_agg_stop_reason reason);
1773de1ede7aSJohannes Berg void ieee80211_process_delba(struct ieee80211_sub_if_data *sdata,
1774de1ede7aSJohannes Berg 			     struct sta_info *sta,
1775de1ede7aSJohannes Berg 			     struct ieee80211_mgmt *mgmt, size_t len);
1776de1ede7aSJohannes Berg void ieee80211_process_addba_resp(struct ieee80211_local *local,
1777de1ede7aSJohannes Berg 				  struct sta_info *sta,
1778de1ede7aSJohannes Berg 				  struct ieee80211_mgmt *mgmt,
1779de1ede7aSJohannes Berg 				  size_t len);
1780de1ede7aSJohannes Berg void ieee80211_process_addba_request(struct ieee80211_local *local,
1781de1ede7aSJohannes Berg 				     struct sta_info *sta,
1782de1ede7aSJohannes Berg 				     struct ieee80211_mgmt *mgmt,
1783de1ede7aSJohannes Berg 				     size_t len);
1784de1ede7aSJohannes Berg 
1785849b7967SJohannes Berg int __ieee80211_stop_tx_ba_session(struct sta_info *sta, u16 tid,
1786c82c4a80SJohannes Berg 				   enum ieee80211_agg_stop_reason reason);
178767c282c0SJohannes Berg int ___ieee80211_stop_tx_ba_session(struct sta_info *sta, u16 tid,
1788c82c4a80SJohannes Berg 				    enum ieee80211_agg_stop_reason reason);
17897a7c0a64SJohannes Berg void ieee80211_start_tx_ba_cb(struct sta_info *sta, int tid,
17907a7c0a64SJohannes Berg 			      struct tid_ampdu_tx *tid_tx);
17917a7c0a64SJohannes Berg void ieee80211_stop_tx_ba_cb(struct sta_info *sta, int tid,
17927a7c0a64SJohannes Berg 			     struct tid_ampdu_tx *tid_tx);
179367c282c0SJohannes Berg void ieee80211_ba_session_work(struct work_struct *work);
179467c282c0SJohannes Berg void ieee80211_tx_ba_session_handle_start(struct sta_info *sta, int tid);
17952bff8ebfSChristian Lamparter void ieee80211_release_reorder_timeout(struct sta_info *sta, int tid);
1796849b7967SJohannes Berg 
179704ecd257SJohannes Berg u8 ieee80211_mcs_to_chains(const struct ieee80211_mcs_info *mcs);
179804ecd257SJohannes Berg 
1799818255eaSMahesh Palivela /* VHT */
18004a3cb702SJohannes Berg void
18014a3cb702SJohannes Berg ieee80211_vht_cap_ie_to_sta_vht_cap(struct ieee80211_sub_if_data *sdata,
1802818255eaSMahesh Palivela 				    struct ieee80211_supported_band *sband,
18034a3cb702SJohannes Berg 				    const struct ieee80211_vht_cap *vht_cap_ie,
18044a34215eSJohannes Berg 				    struct sta_info *sta);
18051c45c5ceSEliad Peller enum ieee80211_sta_rx_bandwidth ieee80211_sta_cap_rx_bw(struct sta_info *sta);
1806e1a0c6b3SJohannes Berg enum ieee80211_sta_rx_bandwidth ieee80211_sta_cur_vht_bw(struct sta_info *sta);
18078921d04eSJohannes Berg void ieee80211_sta_set_rx_nss(struct sta_info *sta);
180859021c67SArik Nemtsov enum ieee80211_sta_rx_bandwidth
180959021c67SArik Nemtsov ieee80211_chan_width_to_rx_bw(enum nl80211_chan_width width);
181059021c67SArik Nemtsov enum nl80211_chan_width ieee80211_sta_cap_chan_bw(struct sta_info *sta);
181159021c67SArik Nemtsov void ieee80211_sta_set_rx_nss(struct sta_info *sta);
181223a1f8d4SSara Sharon void ieee80211_process_mu_groups(struct ieee80211_sub_if_data *sdata,
181323a1f8d4SSara Sharon 				 struct ieee80211_mgmt *mgmt);
1814b1bce14aSMarek Kwaczynski u32 __ieee80211_vht_handle_opmode(struct ieee80211_sub_if_data *sdata,
1815b1bce14aSMarek Kwaczynski                                   struct sta_info *sta, u8 opmode,
181657fbcce3SJohannes Berg 				  enum nl80211_band band);
18170af83d3dSJohannes Berg void ieee80211_vht_handle_opmode(struct ieee80211_sub_if_data *sdata,
18180af83d3dSJohannes Berg 				 struct sta_info *sta, u8 opmode,
181957fbcce3SJohannes Berg 				 enum nl80211_band band);
1820dd5ecfeaSJohannes Berg void ieee80211_apply_vhtcap_overrides(struct ieee80211_sub_if_data *sdata,
1821dd5ecfeaSJohannes Berg 				      struct ieee80211_sta_vht_cap *vht_cap);
1822b119ad6eSLorenzo Bianconi void ieee80211_get_vht_mask_from_cap(__le16 vht_cap,
1823b119ad6eSLorenzo Bianconi 				     u16 vht_mask[NL80211_VHT_NSS_MAX]);
18244a34215eSJohannes Berg 
182539192c0bSJohannes Berg /* Spectrum management */
182639192c0bSJohannes Berg void ieee80211_process_measurement_req(struct ieee80211_sub_if_data *sdata,
182739192c0bSJohannes Berg 				       struct ieee80211_mgmt *mgmt,
182839192c0bSJohannes Berg 				       size_t len);
1829e6b7cde4SSimon Wunderlich /**
1830e6b7cde4SSimon Wunderlich  * ieee80211_parse_ch_switch_ie - parses channel switch IEs
1831e6b7cde4SSimon Wunderlich  * @sdata: the sdata of the interface which has received the frame
1832e6b7cde4SSimon Wunderlich  * @elems: parsed 802.11 elements received with the frame
1833e6b7cde4SSimon Wunderlich  * @current_band: indicates the current band
1834e6b7cde4SSimon Wunderlich  * @sta_flags: contains information about own capabilities and restrictions
1835e6b7cde4SSimon Wunderlich  *	to decide which channel switch announcements can be accepted. Only the
1836e6b7cde4SSimon Wunderlich  *	following subset of &enum ieee80211_sta_flags are evaluated:
1837e6b7cde4SSimon Wunderlich  *	%IEEE80211_STA_DISABLE_HT, %IEEE80211_STA_DISABLE_VHT,
1838e6b7cde4SSimon Wunderlich  *	%IEEE80211_STA_DISABLE_40MHZ, %IEEE80211_STA_DISABLE_80P80MHZ,
1839e6b7cde4SSimon Wunderlich  *	%IEEE80211_STA_DISABLE_160MHZ.
1840e6b7cde4SSimon Wunderlich  * @bssid: the currently connected bssid (for reporting)
1841c0f17eb9SChun-Yeow Yeoh  * @csa_ie: parsed 802.11 csa elements on count, mode, chandef and mesh ttl.
1842c0f17eb9SChun-Yeow Yeoh 	All of them will be filled with if success only.
1843e6b7cde4SSimon Wunderlich  * Return: 0 on success, <0 on error and >0 if there is nothing to parse.
1844e6b7cde4SSimon Wunderlich  */
1845e6b7cde4SSimon Wunderlich int ieee80211_parse_ch_switch_ie(struct ieee80211_sub_if_data *sdata,
184684469a45SLuciano Coelho 				 struct ieee802_11_elems *elems,
184757fbcce3SJohannes Berg 				 enum nl80211_band current_band,
1848c0f17eb9SChun-Yeow Yeoh 				 u32 sta_flags, u8 *bssid,
1849c0f17eb9SChun-Yeow Yeoh 				 struct ieee80211_csa_ie *csa_ie);
185039192c0bSJohannes Berg 
1851f2753ddbSJohannes Berg /* Suspend/resume and hw reconfiguration */
1852f2753ddbSJohannes Berg int ieee80211_reconfig(struct ieee80211_local *local);
185384f6a01cSJohannes Berg void ieee80211_stop_device(struct ieee80211_local *local);
1854f2753ddbSJohannes Berg 
1855eecc4800SJohannes Berg int __ieee80211_suspend(struct ieee80211_hw *hw,
1856eecc4800SJohannes Berg 			struct cfg80211_wowlan *wowlan);
1857f2753ddbSJohannes Berg 
1858f2753ddbSJohannes Berg static inline int __ieee80211_resume(struct ieee80211_hw *hw)
1859f2753ddbSJohannes Berg {
186085f72bc8SJohn W. Linville 	struct ieee80211_local *local = hw_to_local(hw);
186185f72bc8SJohn W. Linville 
18629120d94eSLuciano Coelho 	WARN(test_bit(SCAN_HW_SCANNING, &local->scanning) &&
18639120d94eSLuciano Coelho 	     !test_bit(SCAN_COMPLETED, &local->scanning),
186485f72bc8SJohn W. Linville 		"%s: resume with hardware scan still in progress\n",
186585f72bc8SJohn W. Linville 		wiphy_name(hw->wiphy));
186685f72bc8SJohn W. Linville 
1867f2753ddbSJohannes Berg 	return ieee80211_reconfig(hw_to_local(hw));
1868f2753ddbSJohannes Berg }
1869665af4fcSBob Copeland 
1870c2d1560aSJohannes Berg /* utility functions/constants */
18718a47cea7SJohannes Berg extern const void *const mac80211_wiphy_privid; /* for wiphy privid */
187257fbcce3SJohannes Berg int ieee80211_frame_duration(enum nl80211_band band, size_t len,
1873438b61b7SSimon Wunderlich 			     int rate, int erp, int short_preamble,
1874438b61b7SSimon Wunderlich 			     int shift);
18753abead59SJohannes Berg void ieee80211_set_wmm_default(struct ieee80211_sub_if_data *sdata,
1876cec66283SJohannes Berg 			       bool bss_notify, bool enable_qos);
18777c10770fSJohannes Berg void ieee80211_xmit(struct ieee80211_sub_if_data *sdata,
18787c10770fSJohannes Berg 		    struct sta_info *sta, struct sk_buff *skb);
1879cf6bb79aSHelmut Schaa 
188055de908aSJohannes Berg void __ieee80211_tx_skb_tid_band(struct ieee80211_sub_if_data *sdata,
188155de908aSJohannes Berg 				 struct sk_buff *skb, int tid,
188257fbcce3SJohannes Berg 				 enum nl80211_band band);
188355de908aSJohannes Berg 
188455de908aSJohannes Berg static inline void
188555de908aSJohannes Berg ieee80211_tx_skb_tid_band(struct ieee80211_sub_if_data *sdata,
188655de908aSJohannes Berg 			  struct sk_buff *skb, int tid,
188757fbcce3SJohannes Berg 			  enum nl80211_band band)
188855de908aSJohannes Berg {
188955de908aSJohannes Berg 	rcu_read_lock();
189055de908aSJohannes Berg 	__ieee80211_tx_skb_tid_band(sdata, skb, tid, band);
189155de908aSJohannes Berg 	rcu_read_unlock();
189255de908aSJohannes Berg }
189355de908aSJohannes Berg 
189455de908aSJohannes Berg static inline void ieee80211_tx_skb_tid(struct ieee80211_sub_if_data *sdata,
189555de908aSJohannes Berg 					struct sk_buff *skb, int tid)
189655de908aSJohannes Berg {
189755de908aSJohannes Berg 	struct ieee80211_chanctx_conf *chanctx_conf;
189855de908aSJohannes Berg 
189955de908aSJohannes Berg 	rcu_read_lock();
190055de908aSJohannes Berg 	chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
190155de908aSJohannes Berg 	if (WARN_ON(!chanctx_conf)) {
190255de908aSJohannes Berg 		rcu_read_unlock();
190355de908aSJohannes Berg 		kfree_skb(skb);
190455de908aSJohannes Berg 		return;
190555de908aSJohannes Berg 	}
190655de908aSJohannes Berg 
190755de908aSJohannes Berg 	__ieee80211_tx_skb_tid_band(sdata, skb, tid,
19084bf88530SJohannes Berg 				    chanctx_conf->def.chan->band);
190955de908aSJohannes Berg 	rcu_read_unlock();
191055de908aSJohannes Berg }
191155de908aSJohannes Berg 
191255de908aSJohannes Berg static inline void ieee80211_tx_skb(struct ieee80211_sub_if_data *sdata,
1913cf6bb79aSHelmut Schaa 				    struct sk_buff *skb)
1914cf6bb79aSHelmut Schaa {
1915cf6bb79aSHelmut Schaa 	/* Send all internal mgmt frames on VO. Accordingly set TID to 7. */
1916cf6bb79aSHelmut Schaa 	ieee80211_tx_skb_tid(sdata, skb, 7);
1917cf6bb79aSHelmut Schaa }
1918cf6bb79aSHelmut Schaa 
191935d865afSJohannes Berg u32 ieee802_11_parse_elems_crc(const u8 *start, size_t len, bool action,
1920d91f36dbSJohannes Berg 			       struct ieee802_11_elems *elems,
1921d91f36dbSJohannes Berg 			       u64 filter, u32 crc);
192235d865afSJohannes Berg static inline void ieee802_11_parse_elems(const u8 *start, size_t len,
192335d865afSJohannes Berg 					  bool action,
1924ddc4db2eSJohannes Berg 					  struct ieee802_11_elems *elems)
1925ddc4db2eSJohannes Berg {
1926b2e506bfSJohannes Berg 	ieee802_11_parse_elems_crc(start, len, action, elems, 0, 0);
1927ddc4db2eSJohannes Berg }
1928ddc4db2eSJohannes Berg 
192983eb935eSMichal Kazior 
193002219b3aSJohannes Berg extern const int ieee802_1d_to_ac[8];
193102219b3aSJohannes Berg 
193202219b3aSJohannes Berg static inline int ieee80211_ac_from_tid(int tid)
193302219b3aSJohannes Berg {
193402219b3aSJohannes Berg 	return ieee802_1d_to_ac[tid & 7];
193502219b3aSJohannes Berg }
193602219b3aSJohannes Berg 
1937520eb820SKalle Valo void ieee80211_dynamic_ps_enable_work(struct work_struct *work);
1938520eb820SKalle Valo void ieee80211_dynamic_ps_disable_work(struct work_struct *work);
1939520eb820SKalle Valo void ieee80211_dynamic_ps_timer(unsigned long data);
1940a97b77b9SVivek Natarajan void ieee80211_send_nullfunc(struct ieee80211_local *local,
1941a97b77b9SVivek Natarajan 			     struct ieee80211_sub_if_data *sdata,
1942076cdcb1SJohannes Berg 			     bool powersave);
19433cf335d5SKalle Valo void ieee80211_sta_rx_notify(struct ieee80211_sub_if_data *sdata,
19443cf335d5SKalle Valo 			     struct ieee80211_hdr *hdr);
19454e5ff376SFelix Fietkau void ieee80211_sta_tx_notify(struct ieee80211_sub_if_data *sdata,
194602219b3aSJohannes Berg 			     struct ieee80211_hdr *hdr, bool ack, u16 tx_time);
1947520eb820SKalle Valo 
1948ce7c9111SKalle Valo void ieee80211_wake_queues_by_reason(struct ieee80211_hw *hw,
1949445ea4e8SJohannes Berg 				     unsigned long queues,
1950cca07b00SLuciano Coelho 				     enum queue_stop_reason reason,
1951cca07b00SLuciano Coelho 				     bool refcounted);
195226da23b6SLuciano Coelho void ieee80211_stop_vif_queues(struct ieee80211_local *local,
195326da23b6SLuciano Coelho 			       struct ieee80211_sub_if_data *sdata,
195426da23b6SLuciano Coelho 			       enum queue_stop_reason reason);
195526da23b6SLuciano Coelho void ieee80211_wake_vif_queues(struct ieee80211_local *local,
195626da23b6SLuciano Coelho 			       struct ieee80211_sub_if_data *sdata,
195726da23b6SLuciano Coelho 			       enum queue_stop_reason reason);
1958ce7c9111SKalle Valo void ieee80211_stop_queues_by_reason(struct ieee80211_hw *hw,
1959445ea4e8SJohannes Berg 				     unsigned long queues,
1960cca07b00SLuciano Coelho 				     enum queue_stop_reason reason,
1961cca07b00SLuciano Coelho 				     bool refcounted);
196296f5e66eSJohannes Berg void ieee80211_wake_queue_by_reason(struct ieee80211_hw *hw, int queue,
1963cca07b00SLuciano Coelho 				    enum queue_stop_reason reason,
1964cca07b00SLuciano Coelho 				    bool refcounted);
196596f5e66eSJohannes Berg void ieee80211_stop_queue_by_reason(struct ieee80211_hw *hw, int queue,
1966cca07b00SLuciano Coelho 				    enum queue_stop_reason reason,
1967cca07b00SLuciano Coelho 				    bool refcounted);
19683a25a8c8SJohannes Berg void ieee80211_propagate_queue_wake(struct ieee80211_local *local, int queue);
19698f77f384SJohannes Berg void ieee80211_add_pending_skb(struct ieee80211_local *local,
19708f77f384SJohannes Berg 			       struct sk_buff *skb);
1971e3685e03SJohannes Berg void ieee80211_add_pending_skbs(struct ieee80211_local *local,
1972e3685e03SJohannes Berg 				struct sk_buff_head *skbs);
197339ecc01dSJohannes Berg void ieee80211_flush_queues(struct ieee80211_local *local,
19743b24f4c6SEmmanuel Grumbach 			    struct ieee80211_sub_if_data *sdata, bool drop);
19754f9610d5SLiad Kaufman void __ieee80211_flush_queues(struct ieee80211_local *local,
19764f9610d5SLiad Kaufman 			      struct ieee80211_sub_if_data *sdata,
19773b24f4c6SEmmanuel Grumbach 			      unsigned int queues, bool drop);
1978ce7c9111SKalle Valo 
19794afaff17SEmmanuel Grumbach static inline bool ieee80211_can_run_worker(struct ieee80211_local *local)
19804afaff17SEmmanuel Grumbach {
19814afaff17SEmmanuel Grumbach 	/*
19824afaff17SEmmanuel Grumbach 	 * If quiescing is set, we are racing with __ieee80211_suspend.
19834afaff17SEmmanuel Grumbach 	 * __ieee80211_suspend flushes the workers after setting quiescing,
19844afaff17SEmmanuel Grumbach 	 * and we check quiescing / suspended before enqueing new workers.
19854afaff17SEmmanuel Grumbach 	 * We should abort the worker to avoid the races below.
19864afaff17SEmmanuel Grumbach 	 */
19874afaff17SEmmanuel Grumbach 	if (local->quiescing)
19884afaff17SEmmanuel Grumbach 		return false;
19894afaff17SEmmanuel Grumbach 
19904afaff17SEmmanuel Grumbach 	/*
19914afaff17SEmmanuel Grumbach 	 * We might already be suspended if the following scenario occurs:
19924afaff17SEmmanuel Grumbach 	 * __ieee80211_suspend		Control path
19934afaff17SEmmanuel Grumbach 	 *
19944afaff17SEmmanuel Grumbach 	 *				if (local->quiescing)
19954afaff17SEmmanuel Grumbach 	 *					return;
19964afaff17SEmmanuel Grumbach 	 * local->quiescing = true;
19974afaff17SEmmanuel Grumbach 	 * flush_workqueue();
19984afaff17SEmmanuel Grumbach 	 *				queue_work(...);
19994afaff17SEmmanuel Grumbach 	 * local->suspended = true;
20004afaff17SEmmanuel Grumbach 	 * local->quiescing = false;
20014afaff17SEmmanuel Grumbach 	 *				worker starts running...
20024afaff17SEmmanuel Grumbach 	 */
20034afaff17SEmmanuel Grumbach 	if (local->suspended)
20044afaff17SEmmanuel Grumbach 		return false;
20054afaff17SEmmanuel Grumbach 
20064afaff17SEmmanuel Grumbach 	return true;
20074afaff17SEmmanuel Grumbach }
20084afaff17SEmmanuel Grumbach 
2009fa962b92SMichal Kazior int ieee80211_txq_setup_flows(struct ieee80211_local *local);
2010fa962b92SMichal Kazior void ieee80211_txq_teardown_flows(struct ieee80211_local *local);
2011fa962b92SMichal Kazior void ieee80211_txq_init(struct ieee80211_sub_if_data *sdata,
2012ba8c3d6fSFelix Fietkau 			struct sta_info *sta,
2013ba8c3d6fSFelix Fietkau 			struct txq_info *txq, int tid);
2014fa962b92SMichal Kazior void ieee80211_txq_purge(struct ieee80211_local *local,
2015fa962b92SMichal Kazior 			 struct txq_info *txqi);
201646900298SJohannes Berg void ieee80211_send_auth(struct ieee80211_sub_if_data *sdata,
2017700e8ea6SJouni Malinen 			 u16 transaction, u16 auth_alg, u16 status,
20184a3cb702SJohannes Berg 			 const u8 *extra, size_t extra_len, const u8 *bssid,
20191672c0e3SJohannes Berg 			 const u8 *da, const u8 *key, u8 key_len, u8 key_idx,
20201672c0e3SJohannes Berg 			 u32 tx_flags);
20216ae16775SAntonio Quartulli void ieee80211_send_deauth_disassoc(struct ieee80211_sub_if_data *sdata,
20226ae16775SAntonio Quartulli 				    const u8 *bssid, u16 stype, u16 reason,
20236ae16775SAntonio Quartulli 				    bool send_frame, u8 *frame_buf);
2024de95a54bSJohannes Berg int ieee80211_build_preq_ies(struct ieee80211_local *local, u8 *buffer,
2025c56ef672SDavid Spinadel 			     size_t buffer_len,
2026c56ef672SDavid Spinadel 			     struct ieee80211_scan_ies *ie_desc,
2027c56ef672SDavid Spinadel 			     const u8 *ie, size_t ie_len,
2028c56ef672SDavid Spinadel 			     u8 bands_used, u32 *rate_masks,
20292103dec1SSimon Wunderlich 			     struct cfg80211_chan_def *chandef);
2030a619a4c0SJuuso Oikarinen struct sk_buff *ieee80211_build_probe_req(struct ieee80211_sub_if_data *sdata,
2031a344d677SJohannes Berg 					  const u8 *src, const u8 *dst,
2032a344d677SJohannes Berg 					  u32 ratemask,
20336b77863bSJohannes Berg 					  struct ieee80211_channel *chan,
2034a619a4c0SJuuso Oikarinen 					  const u8 *ssid, size_t ssid_len,
2035a806c558SPaul Stewart 					  const u8 *ie, size_t ie_len,
2036a806c558SPaul Stewart 					  bool directed);
2037a344d677SJohannes Berg void ieee80211_send_probe_req(struct ieee80211_sub_if_data *sdata,
2038a344d677SJohannes Berg 			      const u8 *src, const u8 *dst,
2039de95a54bSJohannes Berg 			      const u8 *ssid, size_t ssid_len,
2040a806c558SPaul Stewart 			      const u8 *ie, size_t ie_len,
20411672c0e3SJohannes Berg 			      u32 ratemask, bool directed, u32 tx_flags,
204255de908aSJohannes Berg 			      struct ieee80211_channel *channel, bool scan);
204346900298SJohannes Berg 
20442103dec1SSimon Wunderlich u32 ieee80211_sta_get_rates(struct ieee80211_sub_if_data *sdata,
204546900298SJohannes Berg 			    struct ieee802_11_elems *elems,
204657fbcce3SJohannes Berg 			    enum nl80211_band band, u32 *basic_rates);
2047687da132SEmmanuel Grumbach int __ieee80211_request_smps_mgd(struct ieee80211_sub_if_data *sdata,
2048687da132SEmmanuel Grumbach 				 enum ieee80211_smps_mode smps_mode);
2049687da132SEmmanuel Grumbach int __ieee80211_request_smps_ap(struct ieee80211_sub_if_data *sdata,
20500f78231bSJohannes Berg 				enum ieee80211_smps_mode smps_mode);
205104ecd257SJohannes Berg void ieee80211_recalc_smps(struct ieee80211_sub_if_data *sdata);
205221f659bfSEliad Peller void ieee80211_recalc_min_chandef(struct ieee80211_sub_if_data *sdata);
205346900298SJohannes Berg 
20548e664fb3SJohannes Berg size_t ieee80211_ie_split_vendor(const u8 *ies, size_t ielen, size_t offset);
2055ef96a842SBen Greear u8 *ieee80211_ie_build_ht_cap(u8 *pos, struct ieee80211_sta_ht_cap *ht_cap,
205642e7aa77SAlexander Simon 			      u16 cap);
2057074d46d1SJohannes Berg u8 *ieee80211_ie_build_ht_oper(u8 *pos, struct ieee80211_sta_ht_cap *ht_cap,
20584bf88530SJohannes Berg 			       const struct cfg80211_chan_def *chandef,
205957f255f5SArik Nemtsov 			       u16 prot_mode, bool rifs_mode);
2060ba0afa2fSMahesh Palivela u8 *ieee80211_ie_build_vht_cap(u8 *pos, struct ieee80211_sta_vht_cap *vht_cap,
2061ba0afa2fSMahesh Palivela 			       u32 cap);
2062fb28ec0cSArik Nemtsov u8 *ieee80211_ie_build_vht_oper(u8 *pos, struct ieee80211_sta_vht_cap *vht_cap,
2063fb28ec0cSArik Nemtsov 				const struct cfg80211_chan_def *chandef);
20642103dec1SSimon Wunderlich int ieee80211_parse_bitrates(struct cfg80211_chan_def *chandef,
20652103dec1SSimon Wunderlich 			     const struct ieee80211_supported_band *sband,
20662103dec1SSimon Wunderlich 			     const u8 *srates, int srates_len, u32 *rates);
2067fc8a7321SJohannes Berg int ieee80211_add_srates_ie(struct ieee80211_sub_if_data *sdata,
20686b77863bSJohannes Berg 			    struct sk_buff *skb, bool need_basic,
206957fbcce3SJohannes Berg 			    enum nl80211_band band);
2070fc8a7321SJohannes Berg int ieee80211_add_ext_srates_ie(struct ieee80211_sub_if_data *sdata,
20716b77863bSJohannes Berg 				struct sk_buff *skb, bool need_basic,
207257fbcce3SJohannes Berg 				enum nl80211_band band);
207340b861a0SArik Nemtsov u8 *ieee80211_add_wmm_info_ie(u8 *buf, u8 qosinfo);
20748e664fb3SJohannes Berg 
2075f444de05SJohannes Berg /* channel management */
20768ac3c704SJohannes Berg bool ieee80211_chandef_ht_oper(const struct ieee80211_ht_operation *ht_oper,
20774bf88530SJohannes Berg 			       struct cfg80211_chan_def *chandef);
20788ac3c704SJohannes Berg bool ieee80211_chandef_vht_oper(const struct ieee80211_vht_operation *oper,
2079abcff6efSJanusz.Dziedzic@tieto.com 				struct cfg80211_chan_def *chandef);
2080e6b7cde4SSimon Wunderlich u32 ieee80211_chandef_downgrade(struct cfg80211_chan_def *c);
2081f444de05SJohannes Berg 
2082d01a1e65SMichal Kazior int __must_check
2083d01a1e65SMichal Kazior ieee80211_vif_use_channel(struct ieee80211_sub_if_data *sdata,
20844bf88530SJohannes Berg 			  const struct cfg80211_chan_def *chandef,
2085d01a1e65SMichal Kazior 			  enum ieee80211_chanctx_mode mode);
20862c9b7359SJohannes Berg int __must_check
208711335a55SLuciano Coelho ieee80211_vif_reserve_chanctx(struct ieee80211_sub_if_data *sdata,
208811335a55SLuciano Coelho 			      const struct cfg80211_chan_def *chandef,
208909332481SMichal Kazior 			      enum ieee80211_chanctx_mode mode,
209009332481SMichal Kazior 			      bool radar_required);
209111335a55SLuciano Coelho int __must_check
20925bcae31dSMichal Kazior ieee80211_vif_use_reserved_context(struct ieee80211_sub_if_data *sdata);
209311335a55SLuciano Coelho int ieee80211_vif_unreserve_chanctx(struct ieee80211_sub_if_data *sdata);
209411335a55SLuciano Coelho 
209511335a55SLuciano Coelho int __must_check
20962c9b7359SJohannes Berg ieee80211_vif_change_bandwidth(struct ieee80211_sub_if_data *sdata,
20972c9b7359SJohannes Berg 			       const struct cfg80211_chan_def *chandef,
20982c9b7359SJohannes Berg 			       u32 *changed);
2099d01a1e65SMichal Kazior void ieee80211_vif_release_channel(struct ieee80211_sub_if_data *sdata);
21004d76d21bSJohannes Berg void ieee80211_vif_vlan_copy_chanctx(struct ieee80211_sub_if_data *sdata);
21011f4ac5a6SJohannes Berg void ieee80211_vif_copy_chanctx_to_vlans(struct ieee80211_sub_if_data *sdata,
21021f4ac5a6SJohannes Berg 					 bool clear);
2103c0166da9SMichal Kazior int ieee80211_chanctx_refcount(struct ieee80211_local *local,
2104c0166da9SMichal Kazior 			       struct ieee80211_chanctx *ctx);
2105d01a1e65SMichal Kazior 
210604ecd257SJohannes Berg void ieee80211_recalc_smps_chanctx(struct ieee80211_local *local,
210704ecd257SJohannes Berg 				   struct ieee80211_chanctx *chanctx);
210821f659bfSEliad Peller void ieee80211_recalc_chanctx_min_def(struct ieee80211_local *local,
210921f659bfSEliad Peller 				      struct ieee80211_chanctx *ctx);
21105cbc95a7SEliad Peller bool ieee80211_is_radar_required(struct ieee80211_local *local);
2111164eb02dSSimon Wunderlich 
2112164eb02dSSimon Wunderlich void ieee80211_dfs_cac_timer(unsigned long data);
2113164eb02dSSimon Wunderlich void ieee80211_dfs_cac_timer_work(struct work_struct *work);
2114164eb02dSSimon Wunderlich void ieee80211_dfs_cac_cancel(struct ieee80211_local *local);
2115164eb02dSSimon Wunderlich void ieee80211_dfs_radar_detected_work(struct work_struct *work);
2116c6da674aSChun-Yeow Yeoh int ieee80211_send_action_csa(struct ieee80211_sub_if_data *sdata,
2117c6da674aSChun-Yeow Yeoh 			      struct cfg80211_csa_settings *csa_settings);
211804ecd257SJohannes Berg 
21192475b1ccSMax Stepanov bool ieee80211_cs_valid(const struct ieee80211_cipher_scheme *cs);
21202475b1ccSMax Stepanov bool ieee80211_cs_list_valid(const struct ieee80211_cipher_scheme *cs, int n);
21212475b1ccSMax Stepanov const struct ieee80211_cipher_scheme *
21222475b1ccSMax Stepanov ieee80211_cs_get(struct ieee80211_local *local, u32 cipher,
21232475b1ccSMax Stepanov 		 enum nl80211_iftype iftype);
21242475b1ccSMax Stepanov int ieee80211_cs_headroom(struct ieee80211_local *local,
21252475b1ccSMax Stepanov 			  struct cfg80211_crypto_settings *crypto,
21262475b1ccSMax Stepanov 			  enum nl80211_iftype iftype);
2127057d5f4bSThomas Pedersen void ieee80211_recalc_dtim(struct ieee80211_local *local,
2128057d5f4bSThomas Pedersen 			   struct ieee80211_sub_if_data *sdata);
212973de86a3SLuciano Coelho int ieee80211_check_combinations(struct ieee80211_sub_if_data *sdata,
213073de86a3SLuciano Coelho 				 const struct cfg80211_chan_def *chandef,
213173de86a3SLuciano Coelho 				 enum ieee80211_chanctx_mode chanmode,
213273de86a3SLuciano Coelho 				 u8 radar_detect);
21336fa001bcSMichal Kazior int ieee80211_max_num_channels(struct ieee80211_local *local);
21340fabfaafSArik Nemtsov enum nl80211_chan_width ieee80211_get_sta_bw(struct ieee80211_sta *sta);
21350fabfaafSArik Nemtsov void ieee80211_recalc_chanctx_chantype(struct ieee80211_local *local,
21360fabfaafSArik Nemtsov 				       struct ieee80211_chanctx *ctx);
21372475b1ccSMax Stepanov 
213895224fe8SArik Nemtsov /* TDLS */
213995224fe8SArik Nemtsov int ieee80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
21403b3a0162SJohannes Berg 			const u8 *peer, u8 action_code, u8 dialog_token,
214195224fe8SArik Nemtsov 			u16 status_code, u32 peer_capability,
214231fa97c5SArik Nemtsov 			bool initiator, const u8 *extra_ies,
214331fa97c5SArik Nemtsov 			size_t extra_ies_len);
214495224fe8SArik Nemtsov int ieee80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
21453b3a0162SJohannes Berg 			const u8 *peer, enum nl80211_tdls_operation oper);
2146c10a1993SJohannes Berg void ieee80211_tdls_peer_del_work(struct work_struct *wk);
2147a7a6bdd0SArik Nemtsov int ieee80211_tdls_channel_switch(struct wiphy *wiphy, struct net_device *dev,
2148a7a6bdd0SArik Nemtsov 				  const u8 *addr, u8 oper_class,
2149a7a6bdd0SArik Nemtsov 				  struct cfg80211_chan_def *chandef);
2150a7a6bdd0SArik Nemtsov void ieee80211_tdls_cancel_channel_switch(struct wiphy *wiphy,
2151a7a6bdd0SArik Nemtsov 					  struct net_device *dev,
2152a7a6bdd0SArik Nemtsov 					  const u8 *addr);
2153d51c2ea3SArik Nemtsov void ieee80211_teardown_tdls_peers(struct ieee80211_sub_if_data *sdata);
2154c8ff71e6SArik Nemtsov void ieee80211_tdls_chsw_work(struct work_struct *wk);
215595224fe8SArik Nemtsov 
2156b7ffbd7eSJohannes Berg extern const struct ethtool_ops ieee80211_ethtool_ops;
2157b7ffbd7eSJohannes Berg 
2158f4ea83ddSJohannes Berg #ifdef CONFIG_MAC80211_NOINLINE
2159d9e8a70fSJohannes Berg #define debug_noinline noinline
2160d9e8a70fSJohannes Berg #else
2161d9e8a70fSJohannes Berg #define debug_noinline
2162d9e8a70fSJohannes Berg #endif
2163d9e8a70fSJohannes Berg 
2164f0706e82SJiri Benc #endif /* IEEE80211_I_H */
2165