xref: /openbmc/linux/net/mac80211/ieee80211_i.h (revision 4e141dad)
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>
6f0706e82SJiri Benc  *
7f0706e82SJiri Benc  * This program is free software; you can redistribute it and/or modify
8f0706e82SJiri Benc  * it under the terms of the GNU General Public License version 2 as
9f0706e82SJiri Benc  * published by the Free Software Foundation.
10f0706e82SJiri Benc  */
11f0706e82SJiri Benc 
12f0706e82SJiri Benc #ifndef IEEE80211_I_H
13f0706e82SJiri Benc #define IEEE80211_I_H
14f0706e82SJiri Benc 
15f0706e82SJiri Benc #include <linux/kernel.h>
16f0706e82SJiri Benc #include <linux/device.h>
17f0706e82SJiri Benc #include <linux/if_ether.h>
18f0706e82SJiri Benc #include <linux/interrupt.h>
19f0706e82SJiri Benc #include <linux/list.h>
20f0706e82SJiri Benc #include <linux/netdevice.h>
21f0706e82SJiri Benc #include <linux/skbuff.h>
22f0706e82SJiri Benc #include <linux/workqueue.h>
23f0706e82SJiri Benc #include <linux/types.h>
24f0706e82SJiri Benc #include <linux/spinlock.h>
25571ecf67SJohannes Berg #include <linux/etherdevice.h>
26e1e54068SJohannes Berg #include <linux/leds.h>
27a729cff8SJohannes Berg #include <linux/idr.h>
28fe7a5d5cSJohannes Berg #include <net/ieee80211_radiotap.h>
2993da9cc1Scolin@cozybit.com #include <net/cfg80211.h>
3051cb6db0SDavid S. Miller #include <net/mac80211.h>
312c8dccc7SJohannes Berg #include "key.h"
32f0706e82SJiri Benc #include "sta_info.h"
33bdcbd8e0SJohannes Berg #include "debug.h"
34f0706e82SJiri Benc 
359cfb0009SJohannes Berg struct ieee80211_local;
36f0706e82SJiri Benc 
37f0706e82SJiri Benc /* Maximum number of broadcast/multicast frames to buffer when some of the
38f0706e82SJiri Benc  * associated stations are using power saving. */
39f0706e82SJiri Benc #define AP_MAX_BC_BUFFER 128
40f0706e82SJiri Benc 
41f0706e82SJiri Benc /* Maximum number of frames buffered to all STAs, including multicast frames.
42f0706e82SJiri Benc  * Note: increasing this limit increases the potential memory requirement. Each
43f0706e82SJiri Benc  * frame can be up to about 2 kB long. */
44f0706e82SJiri Benc #define TOTAL_MAX_TX_BUFFER 512
45f0706e82SJiri Benc 
46f0706e82SJiri Benc /* Required encryption head and tailroom */
47f0706e82SJiri Benc #define IEEE80211_ENCRYPT_HEADROOM 8
48765cb46aSJouni Malinen #define IEEE80211_ENCRYPT_TAILROOM 18
49f0706e82SJiri Benc 
50f0706e82SJiri Benc /* IEEE 802.11 (Ch. 9.5 Defragmentation) requires support for concurrent
51f0706e82SJiri Benc  * reception of at least three fragmented frames. This limit can be increased
52f0706e82SJiri Benc  * by changing this define, at the cost of slower frame reassembly and
53f0706e82SJiri Benc  * increased memory use (about 2 kB of RAM per entry). */
54f0706e82SJiri Benc #define IEEE80211_FRAGMENT_MAX 4
55f0706e82SJiri Benc 
561ea6f9c0SJohannes Berg /* power level hasn't been configured (or set to automatic) */
571ea6f9c0SJohannes Berg #define IEEE80211_UNSET_POWER_LEVEL	INT_MIN
581ea6f9c0SJohannes Berg 
59d6a4ed6fSArik Nemtsov /*
60d6a4ed6fSArik Nemtsov  * Some APs experience problems when working with U-APSD. Decrease the
61d6a4ed6fSArik Nemtsov  * probability of that happening by using legacy mode for all ACs but VO.
62d6a4ed6fSArik Nemtsov  * The AP that caused us trouble was a Cisco 4410N. It ignores our
63d6a4ed6fSArik Nemtsov  * setting, and always treats non-VO ACs as legacy.
64d6a4ed6fSArik Nemtsov  */
65ab13315aSKalle Valo #define IEEE80211_DEFAULT_UAPSD_QUEUES \
66d6a4ed6fSArik Nemtsov 	IEEE80211_WMM_IE_STA_QOSINFO_AC_VO
67ab13315aSKalle Valo 
68ab13315aSKalle Valo #define IEEE80211_DEFAULT_MAX_SP_LEN		\
69ab13315aSKalle Valo 	IEEE80211_WMM_IE_STA_QOSINFO_SP_ALL
70ab13315aSKalle Valo 
716ae16775SAntonio Quartulli #define IEEE80211_DEAUTH_FRAME_LEN	(24 /* hdr */ + 2 /* reason */)
726ae16775SAntonio Quartulli 
73f0706e82SJiri Benc struct ieee80211_fragment_entry {
74f0706e82SJiri Benc 	unsigned long first_frag_time;
75f0706e82SJiri Benc 	unsigned int seq;
76f0706e82SJiri Benc 	unsigned int rx_queue;
77f0706e82SJiri Benc 	unsigned int last_frag;
78f0706e82SJiri Benc 	unsigned int extra_len;
79f0706e82SJiri Benc 	struct sk_buff_head skb_list;
80f0706e82SJiri Benc 	int ccmp; /* Whether fragments were encrypted with CCMP */
81f0706e82SJiri Benc 	u8 last_pn[6]; /* PN of the last fragment if CCMP was used */
82f0706e82SJiri Benc };
83f0706e82SJiri Benc 
84f0706e82SJiri Benc 
85c2b13452SJohannes Berg struct ieee80211_bss {
86ef429dadSJohannes Berg 	u32 device_ts_beacon, device_ts_presp;
878c358bcdSJohannes Berg 
8843ac2ca3SJouni Malinen 	bool wmm_used;
89ab13315aSKalle Valo 	bool uapsd_supported;
9000d3f14cSJohannes Berg 
91f0706e82SJiri Benc #define IEEE80211_MAX_SUPP_RATES 32
92f0706e82SJiri Benc 	u8 supp_rates[IEEE80211_MAX_SUPP_RATES];
93f0706e82SJiri Benc 	size_t supp_rates_len;
94817cee76SAlexander Bondar 	struct ieee80211_rate *beacon_rate;
95f0706e82SJiri Benc 
9600d3f14cSJohannes Berg 	/*
9725985edcSLucas De Marchi 	 * During association, we save an ERP value from a probe response so
985628221cSDaniel Drake 	 * that we can feed ERP info to the driver when handling the
995628221cSDaniel Drake 	 * association completes. these fields probably won't be up-to-date
10000d3f14cSJohannes Berg 	 * otherwise, you probably don't want to use them.
10100d3f14cSJohannes Berg 	 */
10200d3f14cSJohannes Berg 	bool has_erp_value;
1035628221cSDaniel Drake 	u8 erp_value;
104fcff4f10SPaul Stewart 
105fcff4f10SPaul Stewart 	/* Keep track of the corruption of the last beacon/probe response. */
106fcff4f10SPaul Stewart 	u8 corrupt_data;
107fcff4f10SPaul Stewart 
108fcff4f10SPaul Stewart 	/* Keep track of what bits of information we have valid info for. */
109fcff4f10SPaul Stewart 	u8 valid_data;
110fcff4f10SPaul Stewart };
111fcff4f10SPaul Stewart 
112fcff4f10SPaul Stewart /**
113fcff4f10SPaul Stewart  * enum ieee80211_corrupt_data_flags - BSS data corruption flags
114fcff4f10SPaul Stewart  * @IEEE80211_BSS_CORRUPT_BEACON: last beacon frame received was corrupted
115fcff4f10SPaul Stewart  * @IEEE80211_BSS_CORRUPT_PROBE_RESP: last probe response received was corrupted
116fcff4f10SPaul Stewart  *
117fcff4f10SPaul Stewart  * These are bss flags that are attached to a bss in the
118fcff4f10SPaul Stewart  * @corrupt_data field of &struct ieee80211_bss.
119fcff4f10SPaul Stewart  */
120fcff4f10SPaul Stewart enum ieee80211_bss_corrupt_data_flags {
121fcff4f10SPaul Stewart 	IEEE80211_BSS_CORRUPT_BEACON		= BIT(0),
122fcff4f10SPaul Stewart 	IEEE80211_BSS_CORRUPT_PROBE_RESP	= BIT(1)
123fcff4f10SPaul Stewart };
124fcff4f10SPaul Stewart 
125fcff4f10SPaul Stewart /**
126fcff4f10SPaul Stewart  * enum ieee80211_valid_data_flags - BSS valid data flags
127fcff4f10SPaul Stewart  * @IEEE80211_BSS_VALID_WMM: WMM/UAPSD data was gathered from non-corrupt IE
128fcff4f10SPaul Stewart  * @IEEE80211_BSS_VALID_RATES: Supported rates were gathered from non-corrupt IE
129fcff4f10SPaul Stewart  * @IEEE80211_BSS_VALID_ERP: ERP flag was gathered from non-corrupt IE
130fcff4f10SPaul Stewart  *
131fcff4f10SPaul Stewart  * These are bss flags that are attached to a bss in the
132fcff4f10SPaul Stewart  * @valid_data field of &struct ieee80211_bss.  They show which parts
133fcff4f10SPaul Stewart  * of the data structure were recieved as a result of an un-corrupted
134fcff4f10SPaul Stewart  * beacon/probe response.
135fcff4f10SPaul Stewart  */
136fcff4f10SPaul Stewart enum ieee80211_bss_valid_data_flags {
137fcff4f10SPaul Stewart 	IEEE80211_BSS_VALID_WMM			= BIT(1),
138fcff4f10SPaul Stewart 	IEEE80211_BSS_VALID_RATES		= BIT(2),
139fcff4f10SPaul Stewart 	IEEE80211_BSS_VALID_ERP			= BIT(3)
140f0706e82SJiri Benc };
141f0706e82SJiri Benc 
1429ae54c84SJohannes Berg typedef unsigned __bitwise__ ieee80211_tx_result;
1439ae54c84SJohannes Berg #define TX_CONTINUE	((__force ieee80211_tx_result) 0u)
1449ae54c84SJohannes Berg #define TX_DROP		((__force ieee80211_tx_result) 1u)
1459ae54c84SJohannes Berg #define TX_QUEUED	((__force ieee80211_tx_result) 2u)
1469ae54c84SJohannes Berg 
1475cf121c3SJohannes Berg #define IEEE80211_TX_UNICAST		BIT(1)
1485cf121c3SJohannes Berg #define IEEE80211_TX_PS_BUFFERED	BIT(2)
1499ae54c84SJohannes Berg 
1505cf121c3SJohannes Berg struct ieee80211_tx_data {
151f0706e82SJiri Benc 	struct sk_buff *skb;
152252b86c4SJohannes Berg 	struct sk_buff_head skbs;
153f0706e82SJiri Benc 	struct ieee80211_local *local;
154f0706e82SJiri Benc 	struct ieee80211_sub_if_data *sdata;
155f0706e82SJiri Benc 	struct sta_info *sta;
156f0706e82SJiri Benc 	struct ieee80211_key *key;
1570d528d85SFelix Fietkau 	struct ieee80211_tx_rate rate;
1585cf121c3SJohannes Berg 
159056cdd59SJohannes Berg 	unsigned int flags;
1605cf121c3SJohannes Berg };
1615cf121c3SJohannes Berg 
1625cf121c3SJohannes Berg 
1635cf121c3SJohannes Berg typedef unsigned __bitwise__ ieee80211_rx_result;
1645cf121c3SJohannes Berg #define RX_CONTINUE		((__force ieee80211_rx_result) 0u)
1655cf121c3SJohannes Berg #define RX_DROP_UNUSABLE	((__force ieee80211_rx_result) 1u)
1665cf121c3SJohannes Berg #define RX_DROP_MONITOR		((__force ieee80211_rx_result) 2u)
1675cf121c3SJohannes Berg #define RX_QUEUED		((__force ieee80211_rx_result) 3u)
1685cf121c3SJohannes Berg 
169554891e6SJohannes Berg /**
170554891e6SJohannes Berg  * enum ieee80211_packet_rx_flags - packet RX flags
171554891e6SJohannes Berg  * @IEEE80211_RX_RA_MATCH: frame is destined to interface currently processed
172554891e6SJohannes Berg  *	(incl. multicast frames)
173554891e6SJohannes Berg  * @IEEE80211_RX_FRAGMENTED: fragmented frame
174554891e6SJohannes Berg  * @IEEE80211_RX_AMSDU: a-MSDU packet
175554891e6SJohannes Berg  * @IEEE80211_RX_MALFORMED_ACTION_FRM: action frame is malformed
1764cfda47bSChristian Lamparter  * @IEEE80211_RX_DEFERRED_RELEASE: frame was subjected to receive reordering
177554891e6SJohannes Berg  *
178554891e6SJohannes Berg  * These are per-frame flags that are attached to a frame in the
179554891e6SJohannes Berg  * @rx_flags field of &struct ieee80211_rx_status.
180554891e6SJohannes Berg  */
181554891e6SJohannes Berg enum ieee80211_packet_rx_flags {
182554891e6SJohannes Berg 	IEEE80211_RX_RA_MATCH			= BIT(1),
183554891e6SJohannes Berg 	IEEE80211_RX_FRAGMENTED			= BIT(2),
184554891e6SJohannes Berg 	IEEE80211_RX_AMSDU			= BIT(3),
185554891e6SJohannes Berg 	IEEE80211_RX_MALFORMED_ACTION_FRM	= BIT(4),
1864cfda47bSChristian Lamparter 	IEEE80211_RX_DEFERRED_RELEASE		= BIT(5),
187554891e6SJohannes Berg };
188554891e6SJohannes Berg 
189554891e6SJohannes Berg /**
190554891e6SJohannes Berg  * enum ieee80211_rx_flags - RX data flags
191554891e6SJohannes Berg  *
192554891e6SJohannes Berg  * @IEEE80211_RX_CMNTR: received on cooked monitor already
193ee971924SJohannes Berg  * @IEEE80211_RX_BEACON_REPORTED: This frame was already reported
194ee971924SJohannes Berg  *	to cfg80211_report_obss_beacon().
195554891e6SJohannes Berg  *
196554891e6SJohannes Berg  * These flags are used across handling multiple interfaces
197554891e6SJohannes Berg  * for a single frame.
198554891e6SJohannes Berg  */
199554891e6SJohannes Berg enum ieee80211_rx_flags {
200554891e6SJohannes Berg 	IEEE80211_RX_CMNTR		= BIT(0),
201ee971924SJohannes Berg 	IEEE80211_RX_BEACON_REPORTED	= BIT(1),
202554891e6SJohannes Berg };
2035cf121c3SJohannes Berg 
2045cf121c3SJohannes Berg struct ieee80211_rx_data {
2055cf121c3SJohannes Berg 	struct sk_buff *skb;
2065cf121c3SJohannes Berg 	struct ieee80211_local *local;
2075cf121c3SJohannes Berg 	struct ieee80211_sub_if_data *sdata;
2085cf121c3SJohannes Berg 	struct sta_info *sta;
2095cf121c3SJohannes Berg 	struct ieee80211_key *key;
210056cdd59SJohannes Berg 
211056cdd59SJohannes Berg 	unsigned int flags;
2129e26297aSJohannes Berg 
2139e26297aSJohannes Berg 	/*
2149e26297aSJohannes Berg 	 * Index into sequence numbers array, 0..16
2159e26297aSJohannes Berg 	 * since the last (16) is used for non-QoS,
2169e26297aSJohannes Berg 	 * will be 16 on non-QoS frames.
2179e26297aSJohannes Berg 	 */
2189e26297aSJohannes Berg 	int seqno_idx;
2199e26297aSJohannes Berg 
2209e26297aSJohannes Berg 	/*
2219e26297aSJohannes Berg 	 * Index into the security IV/PN arrays, 0..16
2229e26297aSJohannes Berg 	 * since the last (16) is used for CCMP-encrypted
2239e26297aSJohannes Berg 	 * management frames, will be set to 16 on mgmt
2249e26297aSJohannes Berg 	 * frames and 0 on non-QoS frames.
2259e26297aSJohannes Berg 	 */
2269e26297aSJohannes Berg 	int security_idx;
2279e26297aSJohannes Berg 
22850741ae0SJohannes Berg 	u32 tkip_iv32;
22950741ae0SJohannes Berg 	u16 tkip_iv16;
230f0706e82SJiri Benc };
231f0706e82SJiri Benc 
2325dfdaf58SJohannes Berg struct beacon_data {
2335dfdaf58SJohannes Berg 	u8 *head, *tail;
2345dfdaf58SJohannes Berg 	int head_len, tail_len;
23543552be1SThomas Pedersen 	struct ieee80211_meshconf_ie *meshconf;
2368860020eSJohannes Berg 	struct rcu_head rcu_head;
2375dfdaf58SJohannes Berg };
2385dfdaf58SJohannes Berg 
239aa7a0080SEyal Shapira struct probe_resp {
240aa7a0080SEyal Shapira 	struct rcu_head rcu_head;
241aa7a0080SEyal Shapira 	int len;
242aa7a0080SEyal Shapira 	u8 data[0];
243aa7a0080SEyal Shapira };
244aa7a0080SEyal Shapira 
245d012a605SMarco Porsch struct ps_data {
246d012a605SMarco Porsch 	/* yes, this looks ugly, but guarantees that we can later use
247d012a605SMarco Porsch 	 * bitmap_empty :)
248d012a605SMarco Porsch 	 * NB: don't touch this bitmap, use sta_info_{set,clear}_tim_bit */
2495fe2bb86SJoe Perches 	u8 tim[sizeof(unsigned long) * BITS_TO_LONGS(IEEE80211_MAX_AID + 1)]
2505fe2bb86SJoe Perches 			__aligned(__alignof__(unsigned long));
251d012a605SMarco Porsch 	struct sk_buff_head bc_buf;
252d012a605SMarco Porsch 	atomic_t num_sta_ps; /* number of stations in PS mode */
253d012a605SMarco Porsch 	int dtim_count;
254d012a605SMarco Porsch 	bool dtim_bc_mc;
255d012a605SMarco Porsch };
256d012a605SMarco Porsch 
257f0706e82SJiri Benc struct ieee80211_if_ap {
25840b275b6SJohannes Berg 	struct beacon_data __rcu *beacon;
259aa7a0080SEyal Shapira 	struct probe_resp __rcu *probe_resp;
260f0706e82SJiri Benc 
26173da7d5bSSimon Wunderlich 	/* to be used after channel switch. */
26273da7d5bSSimon Wunderlich 	struct cfg80211_beacon_data *next_beacon;
2634e141dadSMichal Kazior 	struct list_head vlans; /* write-protected with RTNL and local->mtx */
2640ec3ca44SJohannes Berg 
265d012a605SMarco Porsch 	struct ps_data ps;
266030ef8f8SFelix Fietkau 	atomic_t num_mcast_sta; /* number of stations receiving multicast */
267687da132SEmmanuel Grumbach 	enum ieee80211_smps_mode req_smps, /* requested smps mode */
268687da132SEmmanuel Grumbach 			 driver_smps_mode; /* smps mode request */
269687da132SEmmanuel Grumbach 
270687da132SEmmanuel Grumbach 	struct work_struct request_smps_work;
271f0706e82SJiri Benc };
272f0706e82SJiri Benc 
273f0706e82SJiri Benc struct ieee80211_if_wds {
274f0706e82SJiri Benc 	struct sta_info *sta;
275056cdd59SJohannes Berg 	u8 remote_addr[ETH_ALEN];
276f0706e82SJiri Benc };
277f0706e82SJiri Benc 
278f0706e82SJiri Benc struct ieee80211_if_vlan {
2794e141dadSMichal Kazior 	struct list_head list; /* write-protected with RTNL and local->mtx */
280f14543eeSFelix Fietkau 
281f14543eeSFelix Fietkau 	/* used for all tx if the VLAN is configured to 4-addr mode */
28240b275b6SJohannes Berg 	struct sta_info __rcu *sta;
283f0706e82SJiri Benc };
284f0706e82SJiri Benc 
285ee385855SLuis Carlos Cobo struct mesh_stats {
286c8a61a7dSDaniel Walker 	__u32 fwded_mcast;		/* Mesh forwarded multicast frames */
287c8a61a7dSDaniel Walker 	__u32 fwded_unicast;		/* Mesh forwarded unicast frames */
288c8a61a7dSDaniel Walker 	__u32 fwded_frames;		/* Mesh total forwarded frames */
289ee385855SLuis Carlos Cobo 	__u32 dropped_frames_ttl;	/* Not transmitted since mesh_ttl == 0*/
290ee385855SLuis Carlos Cobo 	__u32 dropped_frames_no_route;	/* Not transmitted, no route found */
291cfee66b0SJavier Cardona 	__u32 dropped_frames_congestion;/* Not forwarded due to congestion */
292ee385855SLuis Carlos Cobo };
293ee385855SLuis Carlos Cobo 
294ee385855SLuis Carlos Cobo #define PREQ_Q_F_START		0x1
295ee385855SLuis Carlos Cobo #define PREQ_Q_F_REFRESH	0x2
296ee385855SLuis Carlos Cobo struct mesh_preq_queue {
297ee385855SLuis Carlos Cobo 	struct list_head list;
298ee385855SLuis Carlos Cobo 	u8 dst[ETH_ALEN];
299ee385855SLuis Carlos Cobo 	u8 flags;
300ee385855SLuis Carlos Cobo };
301ee385855SLuis Carlos Cobo 
3022eb278e0SJohannes Berg #if HZ/100 == 0
3032eb278e0SJohannes Berg #define IEEE80211_ROC_MIN_LEFT	1
3042eb278e0SJohannes Berg #else
3052eb278e0SJohannes Berg #define IEEE80211_ROC_MIN_LEFT	(HZ/100)
3062eb278e0SJohannes Berg #endif
30777fdaa12SJohannes Berg 
3082eb278e0SJohannes Berg struct ieee80211_roc_work {
30977fdaa12SJohannes Berg 	struct list_head list;
3102eb278e0SJohannes Berg 	struct list_head dependents;
311f679f65dSJohannes Berg 
3122eb278e0SJohannes Berg 	struct delayed_work work;
313af6b6374SJohannes Berg 
314af6b6374SJohannes Berg 	struct ieee80211_sub_if_data *sdata;
315af6b6374SJohannes Berg 
316f679f65dSJohannes Berg 	struct ieee80211_channel *chan;
317af6b6374SJohannes Berg 
3182eb278e0SJohannes Berg 	bool started, abort, hw_begun, notified;
3193fbd45caSJohannes Berg 	bool to_be_freed;
320f679f65dSJohannes Berg 
3212eb278e0SJohannes Berg 	unsigned long hw_start_time;
322e4da8c37SJohannes Berg 
3232eb278e0SJohannes Berg 	u32 duration, req_duration;
324f30221e4SJohannes Berg 	struct sk_buff *frame;
32550febf6aSJohannes Berg 	u64 cookie, mgmt_tx_cookie;
326d339d5caSIlan Peer 	enum ieee80211_roc_type type;
32777fdaa12SJohannes Berg };
32877fdaa12SJohannes Berg 
32946900298SJohannes Berg /* flags used in struct ieee80211_if_managed.flags */
330ab1faeadSJohannes Berg enum ieee80211_sta_flags {
331b291ba11SJohannes Berg 	IEEE80211_STA_CONNECTION_POLL	= BIT(1),
332b291ba11SJohannes Berg 	IEEE80211_STA_CONTROL_PORT	= BIT(2),
333a8243b72SJohannes Berg 	IEEE80211_STA_DISABLE_HT	= BIT(4),
334b291ba11SJohannes Berg 	IEEE80211_STA_CSA_RECEIVED	= BIT(5),
335b291ba11SJohannes Berg 	IEEE80211_STA_MFP_ENABLED	= BIT(6),
336ab13315aSKalle Valo 	IEEE80211_STA_UAPSD_ENABLED	= BIT(7),
337375177bfSVivek Natarajan 	IEEE80211_STA_NULLFUNC_ACKED	= BIT(8),
33817e4ec14SJouni Malinen 	IEEE80211_STA_RESET_SIGNAL_AVE	= BIT(9),
33924398e39SJohannes Berg 	IEEE80211_STA_DISABLE_40MHZ	= BIT(10),
340d545dabaSMahesh Palivela 	IEEE80211_STA_DISABLE_VHT	= BIT(11),
341f2d9d270SJohannes Berg 	IEEE80211_STA_DISABLE_80P80MHZ	= BIT(12),
342f2d9d270SJohannes Berg 	IEEE80211_STA_DISABLE_160MHZ	= BIT(13),
343095d81ceSJohannes Berg 	IEEE80211_STA_DISABLE_WMM	= BIT(14),
344ab1faeadSJohannes Berg };
345ab1faeadSJohannes Berg 
34666e67e41SJohannes Berg struct ieee80211_mgd_auth_data {
34766e67e41SJohannes Berg 	struct cfg80211_bss *bss;
34866e67e41SJohannes Berg 	unsigned long timeout;
34966e67e41SJohannes Berg 	int tries;
35066e67e41SJohannes Berg 	u16 algorithm, expected_transaction;
35166e67e41SJohannes Berg 
35266e67e41SJohannes Berg 	u8 key[WLAN_KEY_LEN_WEP104];
35366e67e41SJohannes Berg 	u8 key_len, key_idx;
35466e67e41SJohannes Berg 	bool done;
35589afe614SJohannes Berg 	bool timeout_started;
35666e67e41SJohannes Berg 
3576b8ece3aSJouni Malinen 	u16 sae_trans, sae_status;
3586b8ece3aSJouni Malinen 	size_t data_len;
3596b8ece3aSJouni Malinen 	u8 data[];
36066e67e41SJohannes Berg };
36166e67e41SJohannes Berg 
36266e67e41SJohannes Berg struct ieee80211_mgd_assoc_data {
36366e67e41SJohannes Berg 	struct cfg80211_bss *bss;
36466e67e41SJohannes Berg 	const u8 *supp_rates;
36566e67e41SJohannes Berg 
36666e67e41SJohannes Berg 	unsigned long timeout;
36766e67e41SJohannes Berg 	int tries;
36866e67e41SJohannes Berg 
36966e67e41SJohannes Berg 	u16 capability;
37066e67e41SJohannes Berg 	u8 prev_bssid[ETH_ALEN];
37166e67e41SJohannes Berg 	u8 ssid[IEEE80211_MAX_SSID_LEN];
37266e67e41SJohannes Berg 	u8 ssid_len;
37366e67e41SJohannes Berg 	u8 supp_rates_len;
37476f0303dSJohannes Berg 	bool wmm, uapsd;
375989c6505SAlexander Bondar 	bool need_beacon;
37666e67e41SJohannes Berg 	bool synced;
37789afe614SJohannes Berg 	bool timeout_started;
37866e67e41SJohannes Berg 
3799dde6423SJohannes Berg 	u8 ap_ht_param;
3809dde6423SJohannes Berg 
381b08fbbd8SJohannes Berg 	struct ieee80211_vht_cap ap_vht_cap;
382b08fbbd8SJohannes Berg 
38366e67e41SJohannes Berg 	size_t ie_len;
38466e67e41SJohannes Berg 	u8 ie[];
38566e67e41SJohannes Berg };
38666e67e41SJohannes Berg 
38746900298SJohannes Berg struct ieee80211_if_managed {
388056cdd59SJohannes Berg 	struct timer_list timer;
389b291ba11SJohannes Berg 	struct timer_list conn_mon_timer;
390b291ba11SJohannes Berg 	struct timer_list bcn_mon_timer;
391c481ec97SSujith 	struct timer_list chswitch_timer;
392b291ba11SJohannes Berg 	struct work_struct monitor_work;
393c481ec97SSujith 	struct work_struct chswitch_work;
3941e4dcd01SJuuso Oikarinen 	struct work_struct beacon_connection_loss_work;
395882a7c69SJohannes Berg 	struct work_struct csa_connection_drop_work;
39646900298SJohannes Berg 
3977ccc8bd7SFelix Fietkau 	unsigned long beacon_timeout;
398b291ba11SJohannes Berg 	unsigned long probe_timeout;
399a43abf29SMaxim Levitsky 	int probe_send_count;
40004ac3c0eSFelix Fietkau 	bool nullfunc_failed;
401682bd38bSJohannes Berg 	bool connection_loss;
402b291ba11SJohannes Berg 
4030c1ad2caSJohannes Berg 	struct cfg80211_bss *associated;
40466e67e41SJohannes Berg 	struct ieee80211_mgd_auth_data *auth_data;
40566e67e41SJohannes Berg 	struct ieee80211_mgd_assoc_data *assoc_data;
40646900298SJohannes Berg 
40777fdaa12SJohannes Berg 	u8 bssid[ETH_ALEN];
40846900298SJohannes Berg 
409f0706e82SJiri Benc 	u16 aid;
410f0706e82SJiri Benc 
411965bedadSJohannes Berg 	bool powersave; /* powersave requested for this iface */
41205cb9108SJohannes Berg 	bool broken_ap; /* AP is broken -- turn off powersave */
413989c6505SAlexander Bondar 	bool have_beacon;
414826262c3SJohannes Berg 	u8 dtim_period;
4150f78231bSJohannes Berg 	enum ieee80211_smps_mode req_smps, /* requested smps mode */
416d1f5b7a3SJohannes Berg 				 driver_smps_mode; /* smps mode request */
417d1f5b7a3SJohannes Berg 
418d1f5b7a3SJohannes Berg 	struct work_struct request_smps_work;
419965bedadSJohannes Berg 
420d6f2da5bSJiri Slaby 	unsigned int flags;
421f0706e82SJiri Benc 
422d8ec4433SJuuso Oikarinen 	bool beacon_crc_valid;
423d91f36dbSJohannes Berg 	u32 beacon_crc;
424d91f36dbSJohannes Berg 
4251672c0e3SJohannes Berg 	bool status_acked;
4261672c0e3SJohannes Berg 	bool status_received;
4271672c0e3SJohannes Berg 	__le16 status_fc;
4281672c0e3SJohannes Berg 
429fdfacf0aSJouni Malinen 	enum {
430fdfacf0aSJouni Malinen 		IEEE80211_MFP_DISABLED,
431fdfacf0aSJouni Malinen 		IEEE80211_MFP_OPTIONAL,
432fdfacf0aSJouni Malinen 		IEEE80211_MFP_REQUIRED
433fdfacf0aSJouni Malinen 	} mfp; /* management frame protection */
434fdfacf0aSJouni Malinen 
435dc41e4d4SEliad Peller 	/*
436dc41e4d4SEliad Peller 	 * Bitmask of enabled u-apsd queues,
437dc41e4d4SEliad Peller 	 * IEEE80211_WMM_IE_STA_QOSINFO_AC_BE & co. Needs a new association
438dc41e4d4SEliad Peller 	 * to take effect.
439dc41e4d4SEliad Peller 	 */
440dc41e4d4SEliad Peller 	unsigned int uapsd_queues;
441dc41e4d4SEliad Peller 
442dc41e4d4SEliad Peller 	/*
443dc41e4d4SEliad Peller 	 * Maximum number of buffered frames AP can deliver during a
444dc41e4d4SEliad Peller 	 * service period, IEEE80211_WMM_IE_STA_QOSINFO_SP_ALL or similar.
445dc41e4d4SEliad Peller 	 * Needs a new association to take effect.
446dc41e4d4SEliad Peller 	 */
447dc41e4d4SEliad Peller 	unsigned int uapsd_max_sp_len;
448dc41e4d4SEliad Peller 
449f0706e82SJiri Benc 	int wmm_last_param_set;
4509bc383deSJohannes Berg 
4519bc383deSJohannes Berg 	u8 use_4addr;
45217e4ec14SJouni Malinen 
45367baf663SJanusz Dziedzic 	s16 p2p_noa_index;
454488dd7b5SJohannes Berg 
45517e4ec14SJouni Malinen 	/* Signal strength from the last Beacon frame in the current BSS. */
45617e4ec14SJouni Malinen 	int last_beacon_signal;
45717e4ec14SJouni Malinen 
45817e4ec14SJouni Malinen 	/*
45917e4ec14SJouni Malinen 	 * Weighted average of the signal strength from Beacon frames in the
46017e4ec14SJouni Malinen 	 * current BSS. This is in units of 1/16 of the signal unit to maintain
46117e4ec14SJouni Malinen 	 * accuracy and to speed up calculations, i.e., the value need to be
46217e4ec14SJouni Malinen 	 * divided by 16 to get the actual value.
46317e4ec14SJouni Malinen 	 */
46417e4ec14SJouni Malinen 	int ave_beacon_signal;
46517e4ec14SJouni Malinen 
46617e4ec14SJouni Malinen 	/*
467391a200aSJouni Malinen 	 * Number of Beacon frames used in ave_beacon_signal. This can be used
468391a200aSJouni Malinen 	 * to avoid generating less reliable cqm events that would be based
469391a200aSJouni Malinen 	 * only on couple of received frames.
470391a200aSJouni Malinen 	 */
471391a200aSJouni Malinen 	unsigned int count_beacon_signal;
472391a200aSJouni Malinen 
473391a200aSJouni Malinen 	/*
47417e4ec14SJouni Malinen 	 * Last Beacon frame signal strength average (ave_beacon_signal / 16)
47517e4ec14SJouni Malinen 	 * that triggered a cqm event. 0 indicates that no event has been
47617e4ec14SJouni Malinen 	 * generated for the current association.
47717e4ec14SJouni Malinen 	 */
47817e4ec14SJouni Malinen 	int last_cqm_event_signal;
479615f7b9bSMeenakshi Venkataraman 
480615f7b9bSMeenakshi Venkataraman 	/*
481615f7b9bSMeenakshi Venkataraman 	 * State variables for keeping track of RSSI of the AP currently
482615f7b9bSMeenakshi Venkataraman 	 * connected to and informing driver when RSSI has gone
483615f7b9bSMeenakshi Venkataraman 	 * below/above a certain threshold.
484615f7b9bSMeenakshi Venkataraman 	 */
485615f7b9bSMeenakshi Venkataraman 	int rssi_min_thold, rssi_max_thold;
486615f7b9bSMeenakshi Venkataraman 	int last_ave_beacon_signal;
487ef96a842SBen Greear 
488ef96a842SBen Greear 	struct ieee80211_ht_cap ht_capa; /* configured ht-cap over-rides */
489ef96a842SBen Greear 	struct ieee80211_ht_cap ht_capa_mask; /* Valid parts of ht_capa */
490dd5ecfeaSJohannes Berg 	struct ieee80211_vht_cap vht_capa; /* configured VHT overrides */
491dd5ecfeaSJohannes Berg 	struct ieee80211_vht_cap vht_capa_mask; /* Valid parts of vht_capa */
492f0706e82SJiri Benc };
493f0706e82SJiri Benc 
49446900298SJohannes Berg struct ieee80211_if_ibss {
49546900298SJohannes Berg 	struct timer_list timer;
496cd7760e6SSimon Wunderlich 	struct work_struct csa_connection_drop_work;
49746900298SJohannes Berg 
498af8cdcd8SJohannes Berg 	unsigned long last_scan_completed;
4995bb644a0SJohannes Berg 
500fbd2c8dcSTeemu Paasikivi 	u32 basic_rates;
501fbd2c8dcSTeemu Paasikivi 
502af8cdcd8SJohannes Berg 	bool fixed_bssid;
503af8cdcd8SJohannes Berg 	bool fixed_channel;
504fffd0934SJohannes Berg 	bool privacy;
50546900298SJohannes Berg 
506267335d6SAntonio Quartulli 	bool control_port;
5078e8d347dSSimon Wunderlich 	bool userspace_handles_dfs;
508267335d6SAntonio Quartulli 
5094d196e4bSFelix Fietkau 	u8 bssid[ETH_ALEN] __aligned(2);
510af8cdcd8SJohannes Berg 	u8 ssid[IEEE80211_MAX_SSID_LEN];
511af8cdcd8SJohannes Berg 	u8 ssid_len, ie_len;
512af8cdcd8SJohannes Berg 	u8 *ie;
5133aede78aSSimon Wunderlich 	struct cfg80211_chan_def chandef;
51446900298SJohannes Berg 
51546900298SJohannes Berg 	unsigned long ibss_join_req;
516af8cdcd8SJohannes Berg 	/* probe response/beacon for IBSS */
517c3ffeab4SJohannes Berg 	struct beacon_data __rcu *presp;
51846900298SJohannes Berg 
519822854b0SSimon Wunderlich 	struct ieee80211_ht_cap ht_capa; /* configured ht-cap over-rides */
520822854b0SSimon Wunderlich 	struct ieee80211_ht_cap ht_capa_mask; /* Valid parts of ht_capa */
521822854b0SSimon Wunderlich 
5228bf11d8dSJohannes Berg 	spinlock_t incomplete_lock;
5238bf11d8dSJohannes Berg 	struct list_head incomplete_stations;
5248bf11d8dSJohannes Berg 
52546900298SJohannes Berg 	enum {
52646900298SJohannes Berg 		IEEE80211_IBSS_MLME_SEARCH,
52746900298SJohannes Berg 		IEEE80211_IBSS_MLME_JOINED,
52846900298SJohannes Berg 	} state;
52946900298SJohannes Berg };
53046900298SJohannes Berg 
531dbf498fbSJavier Cardona /**
532dbf498fbSJavier Cardona  * struct ieee80211_mesh_sync_ops - Extensible synchronization framework interface
533dbf498fbSJavier Cardona  *
534dbf498fbSJavier Cardona  * these declarations define the interface, which enables
535dbf498fbSJavier Cardona  * vendor-specific mesh synchronization
536dbf498fbSJavier Cardona  *
537dbf498fbSJavier Cardona  */
538dbf498fbSJavier Cardona struct ieee802_11_elems;
539dbf498fbSJavier Cardona struct ieee80211_mesh_sync_ops {
540dbf498fbSJavier Cardona 	void (*rx_bcn_presp)(struct ieee80211_sub_if_data *sdata,
541dbf498fbSJavier Cardona 			     u16 stype,
542dbf498fbSJavier Cardona 			     struct ieee80211_mgmt *mgmt,
543dbf498fbSJavier Cardona 			     struct ieee802_11_elems *elems,
544dbf498fbSJavier Cardona 			     struct ieee80211_rx_status *rx_status);
54543552be1SThomas Pedersen 
54643552be1SThomas Pedersen 	/* should be called with beacon_data under RCU read lock */
54743552be1SThomas Pedersen 	void (*adjust_tbtt)(struct ieee80211_sub_if_data *sdata,
54843552be1SThomas Pedersen 			    struct beacon_data *beacon);
549dbf498fbSJavier Cardona 	/* add other framework functions here */
550dbf498fbSJavier Cardona };
551dbf498fbSJavier Cardona 
552b8456a14SChun-Yeow Yeoh struct mesh_csa_settings {
553b8456a14SChun-Yeow Yeoh 	struct rcu_head rcu_head;
554b8456a14SChun-Yeow Yeoh 	struct cfg80211_csa_settings settings;
555b8456a14SChun-Yeow Yeoh };
556b8456a14SChun-Yeow Yeoh 
557472dbc45SJohannes Berg struct ieee80211_if_mesh {
558472dbc45SJohannes Berg 	struct timer_list housekeeping_timer;
559472dbc45SJohannes Berg 	struct timer_list mesh_path_timer;
560e304bfd3SRui Paulo 	struct timer_list mesh_path_root_timer;
561472dbc45SJohannes Berg 
56218889231SJavier Cardona 	unsigned long wrkq_flags;
563f81a9dedSThomas Pedersen 	unsigned long mbss_changed;
564472dbc45SJohannes Berg 
565472dbc45SJohannes Berg 	u8 mesh_id[IEEE80211_MAX_MESH_ID_LEN];
566472dbc45SJohannes Berg 	size_t mesh_id_len;
567472dbc45SJohannes Berg 	/* Active Path Selection Protocol Identifier */
5683491707aSRui Paulo 	u8 mesh_pp_id;
569472dbc45SJohannes Berg 	/* Active Path Selection Metric Identifier */
5703491707aSRui Paulo 	u8 mesh_pm_id;
571472dbc45SJohannes Berg 	/* Congestion Control Mode Identifier */
5723491707aSRui Paulo 	u8 mesh_cc_id;
5739e03fdfdSJavier Cardona 	/* Synchronization Protocol Identifier */
5743491707aSRui Paulo 	u8 mesh_sp_id;
5759e03fdfdSJavier Cardona 	/* Authentication Protocol Identifier */
5763491707aSRui Paulo 	u8 mesh_auth_id;
577d19b3bf6SRui Paulo 	/* Local mesh Sequence Number */
578d19b3bf6SRui Paulo 	u32 sn;
579472dbc45SJohannes Berg 	/* Last used PREQ ID */
580472dbc45SJohannes Berg 	u32 preq_id;
581472dbc45SJohannes Berg 	atomic_t mpaths;
582d19b3bf6SRui Paulo 	/* Timestamp of last SN update */
583d19b3bf6SRui Paulo 	unsigned long last_sn_update;
584dca7e943SThomas Pedersen 	/* Time when it's ok to send next PERR */
585dca7e943SThomas Pedersen 	unsigned long next_perr;
586dca7e943SThomas Pedersen 	/* Timestamp of last PREQ sent */
587472dbc45SJohannes Berg 	unsigned long last_preq;
588472dbc45SJohannes Berg 	struct mesh_rmc *rmc;
589472dbc45SJohannes Berg 	spinlock_t mesh_preq_queue_lock;
590472dbc45SJohannes Berg 	struct mesh_preq_queue preq_queue;
591472dbc45SJohannes Berg 	int preq_queue_len;
592472dbc45SJohannes Berg 	struct mesh_stats mshstats;
593472dbc45SJohannes Berg 	struct mesh_config mshcfg;
5941258d976SAshok Nagarajan 	atomic_t estab_plinks;
595472dbc45SJohannes Berg 	u32 mesh_seqnum;
596472dbc45SJohannes Berg 	bool accepting_plinks;
5975ee68e5bSJavier Cardona 	int num_gates;
5982b5e1967SThomas Pedersen 	struct beacon_data __rcu *beacon;
599581a8b0fSJavier Cardona 	const u8 *ie;
600581a8b0fSJavier Cardona 	u8 ie_len;
601b130e5ceSJavier Cardona 	enum {
602b130e5ceSJavier Cardona 		IEEE80211_MESH_SEC_NONE = 0x0,
603b130e5ceSJavier Cardona 		IEEE80211_MESH_SEC_AUTHED = 0x1,
604b130e5ceSJavier Cardona 		IEEE80211_MESH_SEC_SECURED = 0x2,
605b130e5ceSJavier Cardona 	} security;
606a6dad6a2SThomas Pedersen 	bool user_mpm;
607dbf498fbSJavier Cardona 	/* Extensible Synchronization Framework */
6088ba7acf3SJohannes Berg 	const struct ieee80211_mesh_sync_ops *sync_ops;
609dbf498fbSJavier Cardona 	s64 sync_offset_clockdrift_max;
610dbf498fbSJavier Cardona 	spinlock_t sync_offset_lock;
611dbf498fbSJavier Cardona 	bool adjusting_tbtt;
6123f52b7e3SMarco Porsch 	/* mesh power save */
6133f52b7e3SMarco Porsch 	enum nl80211_mesh_power_mode nonpeer_pm;
6143f52b7e3SMarco Porsch 	int ps_peers_light_sleep;
6153f52b7e3SMarco Porsch 	int ps_peers_deep_sleep;
6163f52b7e3SMarco Porsch 	struct ps_data ps;
6178f2535b9SChun-Yeow Yeoh 	/* Channel Switching Support */
618b8456a14SChun-Yeow Yeoh 	struct mesh_csa_settings __rcu *csa;
6190cb4d4dcSLuciano Coelho 	enum {
6200cb4d4dcSLuciano Coelho 		IEEE80211_MESH_CSA_ROLE_NONE,
6210cb4d4dcSLuciano Coelho 		IEEE80211_MESH_CSA_ROLE_INIT,
6220cb4d4dcSLuciano Coelho 		IEEE80211_MESH_CSA_ROLE_REPEATER,
6230cb4d4dcSLuciano Coelho 	} csa_role;
624b8456a14SChun-Yeow Yeoh 	u8 chsw_ttl;
6258f2535b9SChun-Yeow Yeoh 	u16 pre_value;
62643552be1SThomas Pedersen 
62743552be1SThomas Pedersen 	/* offset from skb->data while building IE */
62843552be1SThomas Pedersen 	int meshconf_offset;
629472dbc45SJohannes Berg };
630902acc78SJohannes Berg 
631902acc78SJohannes Berg #ifdef CONFIG_MAC80211_MESH
632472dbc45SJohannes Berg #define IEEE80211_IFSTA_MESH_CTR_INC(msh, name)	\
633472dbc45SJohannes Berg 	do { (msh)->mshstats.name++; } while (0)
634902acc78SJohannes Berg #else
635472dbc45SJohannes Berg #define IEEE80211_IFSTA_MESH_CTR_INC(msh, name) \
636902acc78SJohannes Berg 	do { } while (0)
637902acc78SJohannes Berg #endif
638f0706e82SJiri Benc 
639213cd118SJohannes Berg /**
640213cd118SJohannes Berg  * enum ieee80211_sub_if_data_flags - virtual interface flags
641213cd118SJohannes Berg  *
642213cd118SJohannes Berg  * @IEEE80211_SDATA_ALLMULTI: interface wants all multicast packets
643213cd118SJohannes Berg  * @IEEE80211_SDATA_PROMISC: interface is promisc
644213cd118SJohannes Berg  * @IEEE80211_SDATA_OPERATING_GMODE: operating in G-only mode
645213cd118SJohannes Berg  * @IEEE80211_SDATA_DONT_BRIDGE_PACKETS: bridge packets between
646213cd118SJohannes Berg  *	associated stations and deliver multicast frames both
647213cd118SJohannes Berg  *	back to wireless media and to the local net stack.
64895acac61SJohannes Berg  * @IEEE80211_SDATA_DISCONNECT_RESUME: Disconnect after resume.
6497b7eab6fSJohannes Berg  * @IEEE80211_SDATA_IN_DRIVER: indicates interface was added to driver
650213cd118SJohannes Berg  */
651213cd118SJohannes Berg enum ieee80211_sub_if_data_flags {
652213cd118SJohannes Berg 	IEEE80211_SDATA_ALLMULTI		= BIT(0),
653213cd118SJohannes Berg 	IEEE80211_SDATA_PROMISC			= BIT(1),
6547986cf95SJohannes Berg 	IEEE80211_SDATA_OPERATING_GMODE		= BIT(2),
6557986cf95SJohannes Berg 	IEEE80211_SDATA_DONT_BRIDGE_PACKETS	= BIT(3),
65695acac61SJohannes Berg 	IEEE80211_SDATA_DISCONNECT_RESUME	= BIT(4),
6577b7eab6fSJohannes Berg 	IEEE80211_SDATA_IN_DRIVER		= BIT(5),
658213cd118SJohannes Berg };
659213cd118SJohannes Berg 
66034d4bc4dSJohannes Berg /**
66134d4bc4dSJohannes Berg  * enum ieee80211_sdata_state_bits - virtual interface state bits
66234d4bc4dSJohannes Berg  * @SDATA_STATE_RUNNING: virtual interface is up & running; this
66334d4bc4dSJohannes Berg  *	mirrors netif_running() but is separate for interface type
66434d4bc4dSJohannes Berg  *	change handling while the interface is up
6655b714c6aSJohannes Berg  * @SDATA_STATE_OFFCHANNEL: This interface is currently in offchannel
6665b714c6aSJohannes Berg  *	mode, so queues are stopped
667d6a83228SJohannes Berg  * @SDATA_STATE_OFFCHANNEL_BEACON_STOPPED: Beaconing was stopped due
668d6a83228SJohannes Berg  *	to offchannel, reset when offchannel returns
66934d4bc4dSJohannes Berg  */
67034d4bc4dSJohannes Berg enum ieee80211_sdata_state_bits {
67134d4bc4dSJohannes Berg 	SDATA_STATE_RUNNING,
6725b714c6aSJohannes Berg 	SDATA_STATE_OFFCHANNEL,
673d6a83228SJohannes Berg 	SDATA_STATE_OFFCHANNEL_BEACON_STOPPED,
67434d4bc4dSJohannes Berg };
67534d4bc4dSJohannes Berg 
676d01a1e65SMichal Kazior /**
677d01a1e65SMichal Kazior  * enum ieee80211_chanctx_mode - channel context configuration mode
678d01a1e65SMichal Kazior  *
679d01a1e65SMichal Kazior  * @IEEE80211_CHANCTX_SHARED: channel context may be used by
680d01a1e65SMichal Kazior  *	multiple interfaces
681d01a1e65SMichal Kazior  * @IEEE80211_CHANCTX_EXCLUSIVE: channel context can be used
682d01a1e65SMichal Kazior  *	only by a single interface. This can be used for example for
683d01a1e65SMichal Kazior  *	non-fixed channel IBSS.
684d01a1e65SMichal Kazior  */
685d01a1e65SMichal Kazior enum ieee80211_chanctx_mode {
686d01a1e65SMichal Kazior 	IEEE80211_CHANCTX_SHARED,
687d01a1e65SMichal Kazior 	IEEE80211_CHANCTX_EXCLUSIVE
688d01a1e65SMichal Kazior };
689d01a1e65SMichal Kazior 
690d01a1e65SMichal Kazior struct ieee80211_chanctx {
691d01a1e65SMichal Kazior 	struct list_head list;
692d01a1e65SMichal Kazior 	struct rcu_head rcu_head;
693d01a1e65SMichal Kazior 
694d01a1e65SMichal Kazior 	enum ieee80211_chanctx_mode mode;
695d01a1e65SMichal Kazior 	int refcount;
6968a61af65SJohannes Berg 	bool driver_present;
697d01a1e65SMichal Kazior 
698d01a1e65SMichal Kazior 	struct ieee80211_chanctx_conf conf;
699d01a1e65SMichal Kazior };
700d01a1e65SMichal Kazior 
70132db6b54SKyeyoon Park struct mac80211_qos_map {
70232db6b54SKyeyoon Park 	struct cfg80211_qos_map qos_map;
70332db6b54SKyeyoon Park 	struct rcu_head rcu_head;
70432db6b54SKyeyoon Park };
70532db6b54SKyeyoon Park 
706f0706e82SJiri Benc struct ieee80211_sub_if_data {
707f0706e82SJiri Benc 	struct list_head list;
708f0706e82SJiri Benc 
709f0706e82SJiri Benc 	struct wireless_dev wdev;
710f0706e82SJiri Benc 
71111a843b7SJohannes Berg 	/* keys */
71211a843b7SJohannes Berg 	struct list_head key_list;
71311a843b7SJohannes Berg 
7143bff1865SYogesh Ashok Powar 	/* count for keys needing tailroom space allocation */
7153bff1865SYogesh Ashok Powar 	int crypto_tx_tailroom_needed_cnt;
7168d1f7ecdSJohannes Berg 	int crypto_tx_tailroom_pending_dec;
7178d1f7ecdSJohannes Berg 	struct delayed_work dec_tailroom_needed_wk;
7183bff1865SYogesh Ashok Powar 
719f0706e82SJiri Benc 	struct net_device *dev;
720f0706e82SJiri Benc 	struct ieee80211_local *local;
721f0706e82SJiri Benc 
72213262ffdSJiri Slaby 	unsigned int flags;
7237e9ed188SDaniel Drake 
72434d4bc4dSJohannes Berg 	unsigned long state;
72534d4bc4dSJohannes Berg 
726f0706e82SJiri Benc 	int drop_unencrypted;
727f0706e82SJiri Benc 
72847846c9bSJohannes Berg 	char name[IFNAMSIZ];
72947846c9bSJohannes Berg 
730f0706e82SJiri Benc 	/* Fragment table for host-based reassembly */
731f0706e82SJiri Benc 	struct ieee80211_fragment_entry	fragments[IEEE80211_FRAGMENT_MAX];
732f0706e82SJiri Benc 	unsigned int fragment_next;
733f0706e82SJiri Benc 
734b53be792SSimon Wunderlich 	/* TID bitmap for NoAck policy */
735b53be792SSimon Wunderlich 	u16 noack_map;
736b53be792SSimon Wunderlich 
73700e96decSYoni Divinsky 	/* bit field of ACM bits (BIT(802.1D tag)) */
73800e96decSYoni Divinsky 	u8 wmm_acm;
73900e96decSYoni Divinsky 
74040b275b6SJohannes Berg 	struct ieee80211_key __rcu *keys[NUM_DEFAULT_KEYS + NUM_DEFAULT_MGMT_KEYS];
74140b275b6SJohannes Berg 	struct ieee80211_key __rcu *default_unicast_key;
74240b275b6SJohannes Berg 	struct ieee80211_key __rcu *default_multicast_key;
74340b275b6SJohannes Berg 	struct ieee80211_key __rcu *default_mgmt_key;
744f0706e82SJiri Benc 
74594778280SJohannes Berg 	u16 sequence_number;
746a621fa4dSJohannes Berg 	__be16 control_port_protocol;
747a621fa4dSJohannes Berg 	bool control_port_no_encrypt;
7482475b1ccSMax Stepanov 	int encrypt_headroom;
74994778280SJohannes Berg 
75054bcbc69SJohannes Berg 	struct ieee80211_tx_queue_params tx_conf[IEEE80211_NUM_ACS];
75132db6b54SKyeyoon Park 	struct mac80211_qos_map __rcu *qos_map;
752f6f3def3SEliad Peller 
75373da7d5bSSimon Wunderlich 	struct work_struct csa_finalize_work;
75473da7d5bSSimon Wunderlich 	int csa_counter_offset_beacon;
75573da7d5bSSimon Wunderlich 	int csa_counter_offset_presp;
75673da7d5bSSimon Wunderlich 	bool csa_radar_required;
75733787fc4SLuciano Coelho 	struct cfg80211_chan_def csa_chandef;
75873da7d5bSSimon Wunderlich 
75904ecd257SJohannes Berg 	/* used to reconfigure hardware SM PS */
76004ecd257SJohannes Berg 	struct work_struct recalc_smps;
76104ecd257SJohannes Berg 
76264592c8fSJohannes Berg 	struct work_struct work;
76335f20c14SJohannes Berg 	struct sk_buff_head skb_queue;
76435f20c14SJohannes Berg 
76504ecd257SJohannes Berg 	u8 needed_rx_chains;
76604ecd257SJohannes Berg 	enum ieee80211_smps_mode smps_mode;
76704ecd257SJohannes Berg 
7681ea6f9c0SJohannes Berg 	int user_power_level; /* in dBm */
7691ea6f9c0SJohannes Berg 	int ap_power_level; /* in dBm */
7701ea6f9c0SJohannes Berg 
771164eb02dSSimon Wunderlich 	bool radar_required;
772164eb02dSSimon Wunderlich 	struct delayed_work dfs_cac_timer_work;
773164eb02dSSimon Wunderlich 
7743e122be0SJohannes Berg 	/*
7753e122be0SJohannes Berg 	 * AP this belongs to: self in AP mode and
7763e122be0SJohannes Berg 	 * corresponding AP in VLAN mode, NULL for
7773e122be0SJohannes Berg 	 * all others (might be needed later in IBSS)
7783e122be0SJohannes Berg 	 */
7793e122be0SJohannes Berg 	struct ieee80211_if_ap *bss;
7803e122be0SJohannes Berg 
78137eb0b16SJouni Malinen 	/* bitmap of allowed (non-MCS) rate indexes for rate control */
78237eb0b16SJouni Malinen 	u32 rc_rateidx_mask[IEEE80211_NUM_BANDS];
7832ffbe6d3SFelix Fietkau 
7842ffbe6d3SFelix Fietkau 	bool rc_has_mcs_mask[IEEE80211_NUM_BANDS];
78519468413SSimon Wunderlich 	u8  rc_rateidx_mcs_mask[IEEE80211_NUM_BANDS][IEEE80211_HT_MCS_MASK_LEN];
786f0706e82SJiri Benc 
787f0706e82SJiri Benc 	union {
788f0706e82SJiri Benc 		struct ieee80211_if_ap ap;
789f0706e82SJiri Benc 		struct ieee80211_if_wds wds;
790f0706e82SJiri Benc 		struct ieee80211_if_vlan vlan;
79146900298SJohannes Berg 		struct ieee80211_if_managed mgd;
79246900298SJohannes Berg 		struct ieee80211_if_ibss ibss;
793472dbc45SJohannes Berg 		struct ieee80211_if_mesh mesh;
7948cc9a739SMichael Wu 		u32 mntr_flags;
795f0706e82SJiri Benc 	} u;
796e9f207f0SJiri Benc 
797e9f207f0SJiri Benc #ifdef CONFIG_MAC80211_DEBUGFS
798e9f207f0SJiri Benc 	struct {
799295bafb4SBen Greear 		struct dentry *subdir_stations;
800f7e0104cSJohannes Berg 		struct dentry *default_unicast_key;
801f7e0104cSJohannes Berg 		struct dentry *default_multicast_key;
8023cfcf6acSJouni Malinen 		struct dentry *default_mgmt_key;
8037bcfaf2fSJohannes Berg 	} debugfs;
804e9f207f0SJiri Benc #endif
805529ba6e9SJohannes Berg 
80632bfd35dSJohannes Berg 	/* must be last, dynamically sized area in this! */
80732bfd35dSJohannes Berg 	struct ieee80211_vif vif;
808f0706e82SJiri Benc };
809f0706e82SJiri Benc 
81032bfd35dSJohannes Berg static inline
81132bfd35dSJohannes Berg struct ieee80211_sub_if_data *vif_to_sdata(struct ieee80211_vif *p)
81232bfd35dSJohannes Berg {
81332bfd35dSJohannes Berg 	return container_of(p, struct ieee80211_sub_if_data, vif);
81432bfd35dSJohannes Berg }
81532bfd35dSJohannes Berg 
8168d61ffa5SJohannes Berg static inline void sdata_lock(struct ieee80211_sub_if_data *sdata)
8178d61ffa5SJohannes Berg 	__acquires(&sdata->wdev.mtx)
8188d61ffa5SJohannes Berg {
8198d61ffa5SJohannes Berg 	mutex_lock(&sdata->wdev.mtx);
8208d61ffa5SJohannes Berg 	__acquire(&sdata->wdev.mtx);
8218d61ffa5SJohannes Berg }
8228d61ffa5SJohannes Berg 
8238d61ffa5SJohannes Berg static inline void sdata_unlock(struct ieee80211_sub_if_data *sdata)
8248d61ffa5SJohannes Berg 	__releases(&sdata->wdev.mtx)
8258d61ffa5SJohannes Berg {
8268d61ffa5SJohannes Berg 	mutex_unlock(&sdata->wdev.mtx);
8278d61ffa5SJohannes Berg 	__release(&sdata->wdev.mtx);
8288d61ffa5SJohannes Berg }
8298d61ffa5SJohannes Berg 
8307ca133bcSSimon Wunderlich #define sdata_dereference(p, sdata) \
8317ca133bcSSimon Wunderlich 	rcu_dereference_protected(p, lockdep_is_held(&sdata->wdev.mtx))
8327ca133bcSSimon Wunderlich 
8338d61ffa5SJohannes Berg static inline void
8348d61ffa5SJohannes Berg sdata_assert_lock(struct ieee80211_sub_if_data *sdata)
8358d61ffa5SJohannes Berg {
8368d61ffa5SJohannes Berg 	lockdep_assert_held(&sdata->wdev.mtx);
8378d61ffa5SJohannes Berg }
8388d61ffa5SJohannes Berg 
83955de908aSJohannes Berg static inline enum ieee80211_band
84055de908aSJohannes Berg ieee80211_get_sdata_band(struct ieee80211_sub_if_data *sdata)
84155de908aSJohannes Berg {
84255de908aSJohannes Berg 	enum ieee80211_band band = IEEE80211_BAND_2GHZ;
84355de908aSJohannes Berg 	struct ieee80211_chanctx_conf *chanctx_conf;
84455de908aSJohannes Berg 
84555de908aSJohannes Berg 	rcu_read_lock();
84655de908aSJohannes Berg 	chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
84755de908aSJohannes Berg 	if (!WARN_ON(!chanctx_conf))
8484bf88530SJohannes Berg 		band = chanctx_conf->def.chan->band;
84955de908aSJohannes Berg 	rcu_read_unlock();
85055de908aSJohannes Berg 
85155de908aSJohannes Berg 	return band;
85255de908aSJohannes Berg }
85355de908aSJohannes Berg 
854438b61b7SSimon Wunderlich static inline int
855438b61b7SSimon Wunderlich ieee80211_chandef_get_shift(struct cfg80211_chan_def *chandef)
856438b61b7SSimon Wunderlich {
857438b61b7SSimon Wunderlich 	switch (chandef->width) {
858438b61b7SSimon Wunderlich 	case NL80211_CHAN_WIDTH_5:
859438b61b7SSimon Wunderlich 		return 2;
860438b61b7SSimon Wunderlich 	case NL80211_CHAN_WIDTH_10:
861438b61b7SSimon Wunderlich 		return 1;
862438b61b7SSimon Wunderlich 	default:
863438b61b7SSimon Wunderlich 		return 0;
864438b61b7SSimon Wunderlich 	}
865438b61b7SSimon Wunderlich }
866438b61b7SSimon Wunderlich 
867438b61b7SSimon Wunderlich static inline int
868438b61b7SSimon Wunderlich ieee80211_vif_get_shift(struct ieee80211_vif *vif)
869438b61b7SSimon Wunderlich {
870438b61b7SSimon Wunderlich 	struct ieee80211_chanctx_conf *chanctx_conf;
871438b61b7SSimon Wunderlich 	int shift = 0;
872438b61b7SSimon Wunderlich 
873438b61b7SSimon Wunderlich 	rcu_read_lock();
874438b61b7SSimon Wunderlich 	chanctx_conf = rcu_dereference(vif->chanctx_conf);
875438b61b7SSimon Wunderlich 	if (chanctx_conf)
876438b61b7SSimon Wunderlich 		shift = ieee80211_chandef_get_shift(&chanctx_conf->def);
877438b61b7SSimon Wunderlich 	rcu_read_unlock();
878438b61b7SSimon Wunderlich 
879438b61b7SSimon Wunderlich 	return shift;
880438b61b7SSimon Wunderlich }
881438b61b7SSimon Wunderlich 
882c1475ca9SJohannes Berg enum sdata_queue_type {
883c1475ca9SJohannes Berg 	IEEE80211_SDATA_QUEUE_TYPE_FRAME	= 0,
884c1475ca9SJohannes Berg 	IEEE80211_SDATA_QUEUE_AGG_START		= 1,
885c1475ca9SJohannes Berg 	IEEE80211_SDATA_QUEUE_AGG_STOP		= 2,
886c1475ca9SJohannes Berg };
887c1475ca9SJohannes Berg 
888f0706e82SJiri Benc enum {
889f0706e82SJiri Benc 	IEEE80211_RX_MSG	= 1,
890f0706e82SJiri Benc 	IEEE80211_TX_STATUS_MSG	= 2,
891f0706e82SJiri Benc };
892f0706e82SJiri Benc 
893ce7c9111SKalle Valo enum queue_stop_reason {
894ce7c9111SKalle Valo 	IEEE80211_QUEUE_STOP_REASON_DRIVER,
895520eb820SKalle Valo 	IEEE80211_QUEUE_STOP_REASON_PS,
89696f5e66eSJohannes Berg 	IEEE80211_QUEUE_STOP_REASON_CSA,
89796f5e66eSJohannes Berg 	IEEE80211_QUEUE_STOP_REASON_AGGREGATION,
89825420604SJohannes Berg 	IEEE80211_QUEUE_STOP_REASON_SUSPEND,
8998f77f384SJohannes Berg 	IEEE80211_QUEUE_STOP_REASON_SKB_ADD,
9006c17b77bSSeth Forshee 	IEEE80211_QUEUE_STOP_REASON_OFFCHANNEL,
901445ea4e8SJohannes Berg 	IEEE80211_QUEUE_STOP_REASON_FLUSH,
902ce7c9111SKalle Valo };
903ce7c9111SKalle Valo 
90465a6538aSLuciano Coelho #ifdef CONFIG_MAC80211_LEDS
905e1e54068SJohannes Berg struct tpt_led_trigger {
906e1e54068SJohannes Berg 	struct led_trigger trig;
907e1e54068SJohannes Berg 	char name[32];
908e1e54068SJohannes Berg 	const struct ieee80211_tpt_blink *blink_table;
909e1e54068SJohannes Berg 	unsigned int blink_table_len;
910e1e54068SJohannes Berg 	struct timer_list timer;
911e1e54068SJohannes Berg 	unsigned long prev_traffic;
912e1e54068SJohannes Berg 	unsigned long tx_bytes, rx_bytes;
91367408c8cSJohannes Berg 	unsigned int active, want;
91467408c8cSJohannes Berg 	bool running;
915e1e54068SJohannes Berg };
91665a6538aSLuciano Coelho #endif
917e1e54068SJohannes Berg 
918ad38bfc9SMatti Gottlieb /*
919ad38bfc9SMatti Gottlieb  * struct ieee80211_tx_latency_bin_ranges - Tx latency statistics bins ranges
920ad38bfc9SMatti Gottlieb  *
921ad38bfc9SMatti Gottlieb  * Measuring Tx latency statistics. Counts how many Tx frames transmitted in a
922ad38bfc9SMatti Gottlieb  * certain latency range (in Milliseconds). Each station that uses these
923ad38bfc9SMatti Gottlieb  * ranges will have bins to count the amount of frames received in that range.
924ad38bfc9SMatti Gottlieb  * The user can configure the ranges via debugfs.
925ad38bfc9SMatti Gottlieb  * If ranges is NULL then Tx latency statistics bins are disabled for all
926ad38bfc9SMatti Gottlieb  * stations.
927ad38bfc9SMatti Gottlieb  *
928ad38bfc9SMatti Gottlieb  * @n_ranges: number of ranges that are taken in account
929ad38bfc9SMatti Gottlieb  * @ranges: the ranges that the user requested or NULL if disabled.
930ad38bfc9SMatti Gottlieb  */
931ad38bfc9SMatti Gottlieb struct ieee80211_tx_latency_bin_ranges {
932ad38bfc9SMatti Gottlieb 	int n_ranges;
933ad38bfc9SMatti Gottlieb 	u32 ranges[];
934ad38bfc9SMatti Gottlieb };
935ad38bfc9SMatti Gottlieb 
936142b9f50SHelmut Schaa /**
937142b9f50SHelmut Schaa  * mac80211 scan flags - currently active scan mode
938142b9f50SHelmut Schaa  *
939142b9f50SHelmut Schaa  * @SCAN_SW_SCANNING: We're currently in the process of scanning but may as
940142b9f50SHelmut Schaa  *	well be on the operating channel
941142b9f50SHelmut Schaa  * @SCAN_HW_SCANNING: The hardware is scanning for us, we have no way to
942142b9f50SHelmut Schaa  *	determine if we are on the operating channel or not
9438a690674SBen Greear  * @SCAN_ONCHANNEL_SCANNING:  Do a software scan on only the current operating
9448a690674SBen Greear  *	channel. This should not interrupt normal traffic.
9458789d459SJohannes Berg  * @SCAN_COMPLETED: Set for our scan work function when the driver reported
9468789d459SJohannes Berg  *	that the scan completed.
9478789d459SJohannes Berg  * @SCAN_ABORTED: Set for our scan work function when the driver reported
9488789d459SJohannes Berg  *	a scan complete for an aborted scan.
949a754055aSEmmanuel Grumbach  * @SCAN_HW_CANCELLED: Set for our scan work function when the scan is being
950a754055aSEmmanuel Grumbach  *	cancelled.
951142b9f50SHelmut Schaa  */
952fbe9c429SHelmut Schaa enum {
953fbe9c429SHelmut Schaa 	SCAN_SW_SCANNING,
954142b9f50SHelmut Schaa 	SCAN_HW_SCANNING,
9558a690674SBen Greear 	SCAN_ONCHANNEL_SCANNING,
9568789d459SJohannes Berg 	SCAN_COMPLETED,
9578789d459SJohannes Berg 	SCAN_ABORTED,
958a754055aSEmmanuel Grumbach 	SCAN_HW_CANCELLED,
959142b9f50SHelmut Schaa };
960142b9f50SHelmut Schaa 
961142b9f50SHelmut Schaa /**
962142b9f50SHelmut Schaa  * enum mac80211_scan_state - scan state machine states
963142b9f50SHelmut Schaa  *
964142b9f50SHelmut Schaa  * @SCAN_DECISION: Main entry point to the scan state machine, this state
965142b9f50SHelmut Schaa  *	determines if we should keep on scanning or switch back to the
966142b9f50SHelmut Schaa  *	operating channel
967142b9f50SHelmut Schaa  * @SCAN_SET_CHANNEL: Set the next channel to be scanned
968142b9f50SHelmut Schaa  * @SCAN_SEND_PROBE: Send probe requests and wait for probe responses
96907ef03eeSJohannes Berg  * @SCAN_SUSPEND: Suspend the scan and go back to operating channel to
97007ef03eeSJohannes Berg  *	send out data
97107ef03eeSJohannes Berg  * @SCAN_RESUME: Resume the scan and scan the next channel
972cd2bb512SSam Leffler  * @SCAN_ABORT: Abort the scan and go back to operating channel
973142b9f50SHelmut Schaa  */
974142b9f50SHelmut Schaa enum mac80211_scan_state {
975142b9f50SHelmut Schaa 	SCAN_DECISION,
976142b9f50SHelmut Schaa 	SCAN_SET_CHANNEL,
977142b9f50SHelmut Schaa 	SCAN_SEND_PROBE,
97807ef03eeSJohannes Berg 	SCAN_SUSPEND,
97907ef03eeSJohannes Berg 	SCAN_RESUME,
980cd2bb512SSam Leffler 	SCAN_ABORT,
981fbe9c429SHelmut Schaa };
982fbe9c429SHelmut Schaa 
983f0706e82SJiri Benc struct ieee80211_local {
984f0706e82SJiri Benc 	/* embed the driver visible part.
985f0706e82SJiri Benc 	 * don't cast (use the static inlines below), but we keep
986f0706e82SJiri Benc 	 * it first anyway so they become a no-op */
987f0706e82SJiri Benc 	struct ieee80211_hw hw;
988f0706e82SJiri Benc 
989f0706e82SJiri Benc 	const struct ieee80211_ops *ops;
990f0706e82SJiri Benc 
99142935ecaSLuis R. Rodriguez 	/*
99242935ecaSLuis R. Rodriguez 	 * private workqueue to mac80211. mac80211 makes this accessible
99342935ecaSLuis R. Rodriguez 	 * via ieee80211_queue_work()
99442935ecaSLuis R. Rodriguez 	 */
99542935ecaSLuis R. Rodriguez 	struct workqueue_struct *workqueue;
99642935ecaSLuis R. Rodriguez 
997e4e72fb4SJohannes Berg 	unsigned long queue_stop_reasons[IEEE80211_MAX_QUEUES];
99896f5e66eSJohannes Berg 	/* also used to protect ampdu_ac_queue and amdpu_ac_stop_refcnt */
999ce7c9111SKalle Valo 	spinlock_t queue_stop_reason_lock;
100096f5e66eSJohannes Berg 
1001f0706e82SJiri Benc 	int open_count;
10023d30d949SMichael Wu 	int monitors, cooked_mntrs;
10038cc9a739SMichael Wu 	/* number of interfaces with corresponding FIF_ flags */
10047be5086dSJohannes Berg 	int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss, fif_pspoll,
10057be5086dSJohannes Berg 	    fif_probe_req;
10067be5086dSJohannes Berg 	int probe_req_reg;
10074150c572SJohannes Berg 	unsigned int filter_flags; /* FIF_* */
10083b8d81e0SJohannes Berg 
10093ffc2a90SJohannes Berg 	bool wiphy_ciphers_allocated;
10103ffc2a90SJohannes Berg 
1011fe57d9f5SJohannes Berg 	bool use_chanctx;
1012fe57d9f5SJohannes Berg 
10133b8d81e0SJohannes Berg 	/* protects the aggregated multicast list and filter calls */
10143b8d81e0SJohannes Berg 	spinlock_t filter_lock;
10153b8d81e0SJohannes Berg 
10163ac64beeSJohannes Berg 	/* used for uploading changed mc list */
10173ac64beeSJohannes Berg 	struct work_struct reconfig_filter;
10183ac64beeSJohannes Berg 
10193b8d81e0SJohannes Berg 	/* aggregated multicast list */
102022bedad3SJiri Pirko 	struct netdev_hw_addr_list mc_list;
10213b8d81e0SJohannes Berg 
1022d0709a65SJohannes Berg 	bool tim_in_locked_section; /* see ieee80211_beacon_get() */
10235bb644a0SJohannes Berg 
10245bb644a0SJohannes Berg 	/*
10255bb644a0SJohannes Berg 	 * suspended is true if we finished all the suspend _and_ we have
10265bb644a0SJohannes Berg 	 * not yet come up from resume. This is to be used by mac80211
10275bb644a0SJohannes Berg 	 * to ensure driver sanity during suspend and mac80211's own
10285bb644a0SJohannes Berg 	 * sanity. It can eventually be used for WoW as well.
10295bb644a0SJohannes Berg 	 */
10305bb644a0SJohannes Berg 	bool suspended;
10315bb644a0SJohannes Berg 
10325bb644a0SJohannes Berg 	/*
1033ceb99fe0SJohannes Berg 	 * Resuming is true while suspended, but when we're reprogramming the
1034ceb99fe0SJohannes Berg 	 * hardware -- at that time it's allowed to use ieee80211_queue_work()
1035ceb99fe0SJohannes Berg 	 * again even though some other parts of the stack are still suspended
1036ceb99fe0SJohannes Berg 	 * and we still drop received frames to avoid waking the stack.
1037ceb99fe0SJohannes Berg 	 */
1038ceb99fe0SJohannes Berg 	bool resuming;
1039ceb99fe0SJohannes Berg 
1040ceb99fe0SJohannes Berg 	/*
10415bb644a0SJohannes Berg 	 * quiescing is true during the suspend process _only_ to
10425bb644a0SJohannes Berg 	 * ease timer cancelling etc.
10435bb644a0SJohannes Berg 	 */
10445bb644a0SJohannes Berg 	bool quiescing;
10455bb644a0SJohannes Berg 
1046ea77f12fSJohannes Berg 	/* device is started */
1047ea77f12fSJohannes Berg 	bool started;
1048ea77f12fSJohannes Berg 
104904800adaSArik Nemtsov 	/* device is during a HW reconfig */
105004800adaSArik Nemtsov 	bool in_reconfig;
105104800adaSArik Nemtsov 
1052eecc4800SJohannes Berg 	/* wowlan is enabled -- don't reconfig on resume */
1053eecc4800SJohannes Berg 	bool wowlan;
1054eecc4800SJohannes Berg 
1055164eb02dSSimon Wunderlich 	/* DFS/radar detection is enabled */
1056164eb02dSSimon Wunderlich 	bool radar_detect_enabled;
1057164eb02dSSimon Wunderlich 	struct work_struct radar_detected_work;
1058164eb02dSSimon Wunderlich 
105904ecd257SJohannes Berg 	/* number of RX chains the hardware has */
106004ecd257SJohannes Berg 	u8 rx_chains;
106104ecd257SJohannes Berg 
1062b306f453SJohannes Berg 	int tx_headroom; /* required headroom for hardware/radiotap */
1063f0706e82SJiri Benc 
1064f0706e82SJiri Benc 	/* Tasklet and skb queue to process calls from IRQ mode. All frames
1065f0706e82SJiri Benc 	 * added to skb_queue will be processed, but frames in
1066f0706e82SJiri Benc 	 * skb_queue_unreliable may be dropped if the total length of these
1067f0706e82SJiri Benc 	 * queues increases over the limit. */
1068f0706e82SJiri Benc #define IEEE80211_IRQSAFE_QUEUE_LIMIT 128
1069f0706e82SJiri Benc 	struct tasklet_struct tasklet;
1070f0706e82SJiri Benc 	struct sk_buff_head skb_queue;
1071f0706e82SJiri Benc 	struct sk_buff_head skb_queue_unreliable;
1072f0706e82SJiri Benc 
1073f9e124fbSChristian Lamparter 	spinlock_t rx_path_lock;
107424a8fdadSChristian Lamparter 
1075d0709a65SJohannes Berg 	/* Station data */
1076d0709a65SJohannes Berg 	/*
10774d33960bSJohannes Berg 	 * The mutex only protects the list, hash table and
10784d33960bSJohannes Berg 	 * counter, reads are done with RCU.
1079d0709a65SJohannes Berg 	 */
108034e89507SJohannes Berg 	struct mutex sta_mtx;
10814d33960bSJohannes Berg 	spinlock_t tim_lock;
1082d0709a65SJohannes Berg 	unsigned long num_sta;
10834d33960bSJohannes Berg 	struct list_head sta_list;
108440b275b6SJohannes Berg 	struct sta_info __rcu *sta_hash[STA_HASH_SIZE];
1085f0706e82SJiri Benc 	struct timer_list sta_cleanup;
1086f5ea9120SJohannes Berg 	int sta_generation;
1087f0706e82SJiri Benc 
1088ad38bfc9SMatti Gottlieb 	/*
1089ad38bfc9SMatti Gottlieb 	 * Tx latency statistics parameters for all stations.
1090ad38bfc9SMatti Gottlieb 	 * Can enable via debugfs (NULL when disabled).
1091ad38bfc9SMatti Gottlieb 	 */
1092ad38bfc9SMatti Gottlieb 	struct ieee80211_tx_latency_bin_ranges __rcu *tx_latency;
1093ad38bfc9SMatti Gottlieb 
10942a577d98SJohannes Berg 	struct sk_buff_head pending[IEEE80211_MAX_QUEUES];
1095f0706e82SJiri Benc 	struct tasklet_struct tx_pending_tasklet;
1096f0706e82SJiri Benc 
1097a6a67db2SJohannes Berg 	atomic_t agg_queue_stop[IEEE80211_MAX_QUEUES];
1098cd8ffc80SJohannes Berg 
1099f0706e82SJiri Benc 	/* number of interfaces with corresponding IFF_ flags */
110053918994SJohannes Berg 	atomic_t iff_allmultis, iff_promiscs;
1101f0706e82SJiri Benc 
1102f0706e82SJiri Benc 	struct rate_control_ref *rate_ctrl;
1103f0706e82SJiri Benc 
11045f9f1812SFelix Fietkau 	struct crypto_cipher *wep_tx_tfm;
11055f9f1812SFelix Fietkau 	struct crypto_cipher *wep_rx_tfm;
1106f0706e82SJiri Benc 	u32 wep_iv;
1107f0706e82SJiri Benc 
1108c771c9d8SJohannes Berg 	/* see iface.c */
110979010420SJohannes Berg 	struct list_head interfaces;
1110c771c9d8SJohannes Berg 	struct mutex iflist_mtx;
111179010420SJohannes Berg 
1112b16bd15cSJohannes Berg 	/*
1113ad0e2b5aSJohannes Berg 	 * Key mutex, protects sdata's key_list and sta_info's
1114b16bd15cSJohannes Berg 	 * key pointers (write access, they're RCU.)
1115b16bd15cSJohannes Berg 	 */
1116ad0e2b5aSJohannes Berg 	struct mutex key_mtx;
1117b16bd15cSJohannes Berg 
1118a1699b75SJohannes Berg 	/* mutex for scan and work locking */
1119a1699b75SJohannes Berg 	struct mutex mtx;
1120b16bd15cSJohannes Berg 
1121c2b13452SJohannes Berg 	/* Scanning and BSS list */
1122fbe9c429SHelmut Schaa 	unsigned long scanning;
11232a519311SJohannes Berg 	struct cfg80211_ssid scan_ssid;
11245ba63533SJohannes Berg 	struct cfg80211_scan_request *int_scan_req;
11254d36ec58SJohannes Berg 	struct cfg80211_scan_request *scan_req, *hw_scan_req;
11267ca15a0aSSimon Wunderlich 	struct cfg80211_chan_def scan_chandef;
11274d36ec58SJohannes Berg 	enum ieee80211_band hw_scan_band;
1128f0706e82SJiri Benc 	int scan_channel_idx;
1129de95a54bSJohannes Berg 	int scan_ies_len;
1130c604b9f2SJohannes Berg 	int hw_scan_ies_bufsize;
11318318d78aSJohannes Berg 
113285a9994aSLuciano Coelho 	struct work_struct sched_scan_stopped_work;
11335260a5b2SJohannes Berg 	struct ieee80211_sub_if_data __rcu *sched_scan_sdata;
1134d43c6b6eSDavid Spinadel 	struct cfg80211_sched_scan_request *sched_scan_req;
113579f460caSLuciano Coelho 
1136df13cce5SHelmut Schaa 	unsigned long leave_oper_channel_time;
1137977923b0SHelmut Schaa 	enum mac80211_scan_state next_scan_state;
1138f0706e82SJiri Benc 	struct delayed_work scan_work;
1139e2fd5dbcSJohannes Berg 	struct ieee80211_sub_if_data __rcu *scan_sdata;
114055de908aSJohannes Berg 	/* For backward compatibility only -- do not use */
1141675a0b04SKarl Beldan 	struct cfg80211_chan_def _oper_chandef;
1142f0706e82SJiri Benc 
1143b8bc4b0aSJohannes Berg 	/* Temporary remain-on-channel for off-channel operations */
1144b8bc4b0aSJohannes Berg 	struct ieee80211_channel *tmp_channel;
1145b8bc4b0aSJohannes Berg 
1146d01a1e65SMichal Kazior 	/* channel contexts */
1147d01a1e65SMichal Kazior 	struct list_head chanctx_list;
1148d01a1e65SMichal Kazior 	struct mutex chanctx_mtx;
1149d01a1e65SMichal Kazior 
1150f0706e82SJiri Benc 	/* SNMP counters */
1151f0706e82SJiri Benc 	/* dot11CountersTable */
1152f0706e82SJiri Benc 	u32 dot11TransmittedFragmentCount;
1153f0706e82SJiri Benc 	u32 dot11MulticastTransmittedFrameCount;
1154f0706e82SJiri Benc 	u32 dot11FailedCount;
1155f0706e82SJiri Benc 	u32 dot11RetryCount;
1156f0706e82SJiri Benc 	u32 dot11MultipleRetryCount;
1157f0706e82SJiri Benc 	u32 dot11FrameDuplicateCount;
1158f0706e82SJiri Benc 	u32 dot11ReceivedFragmentCount;
1159f0706e82SJiri Benc 	u32 dot11MulticastReceivedFrameCount;
1160f0706e82SJiri Benc 	u32 dot11TransmittedFrameCount;
1161f0706e82SJiri Benc 
1162f0706e82SJiri Benc #ifdef CONFIG_MAC80211_LEDS
1163cdcb006fSIvo van Doorn 	struct led_trigger *tx_led, *rx_led, *assoc_led, *radio_led;
1164e1e54068SJohannes Berg 	struct tpt_led_trigger *tpt_led_trigger;
1165cdcb006fSIvo van Doorn 	char tx_led_name[32], rx_led_name[32],
1166cdcb006fSIvo van Doorn 	     assoc_led_name[32], radio_led_name[32];
1167f0706e82SJiri Benc #endif
1168f0706e82SJiri Benc 
1169f0706e82SJiri Benc #ifdef CONFIG_MAC80211_DEBUG_COUNTERS
1170f0706e82SJiri Benc 	/* TX/RX handler statistics */
1171f0706e82SJiri Benc 	unsigned int tx_handlers_drop;
1172f0706e82SJiri Benc 	unsigned int tx_handlers_queued;
1173f0706e82SJiri Benc 	unsigned int tx_handlers_drop_unencrypted;
1174f0706e82SJiri Benc 	unsigned int tx_handlers_drop_fragment;
1175f0706e82SJiri Benc 	unsigned int tx_handlers_drop_wep;
1176f0706e82SJiri Benc 	unsigned int tx_handlers_drop_not_assoc;
1177f0706e82SJiri Benc 	unsigned int tx_handlers_drop_unauth_port;
1178f0706e82SJiri Benc 	unsigned int rx_handlers_drop;
1179f0706e82SJiri Benc 	unsigned int rx_handlers_queued;
1180f0706e82SJiri Benc 	unsigned int rx_handlers_drop_nullfunc;
1181f0706e82SJiri Benc 	unsigned int rx_handlers_drop_defrag;
1182f0706e82SJiri Benc 	unsigned int rx_handlers_drop_short;
1183f0706e82SJiri Benc 	unsigned int tx_expand_skb_head;
1184f0706e82SJiri Benc 	unsigned int tx_expand_skb_head_cloned;
1185f0706e82SJiri Benc 	unsigned int rx_expand_skb_head;
1186f0706e82SJiri Benc 	unsigned int rx_expand_skb_head2;
1187f0706e82SJiri Benc 	unsigned int rx_handlers_fragments;
1188f0706e82SJiri Benc 	unsigned int tx_status_drop;
1189f0706e82SJiri Benc #define I802_DEBUG_INC(c) (c)++
1190f0706e82SJiri Benc #else /* CONFIG_MAC80211_DEBUG_COUNTERS */
1191f0706e82SJiri Benc #define I802_DEBUG_INC(c) do { } while (0)
1192f0706e82SJiri Benc #endif /* CONFIG_MAC80211_DEBUG_COUNTERS */
1193f0706e82SJiri Benc 
1194f0706e82SJiri Benc 
1195f0706e82SJiri Benc 	int total_ps_buffered; /* total number of all buffered unicast and
1196f0706e82SJiri Benc 				* multicast packets for power saving stations
1197f0706e82SJiri Benc 				*/
1198520eb820SKalle Valo 
1199572e0012SKalle Valo 	bool pspolling;
1200b203ffc3SJouni Malinen 	bool offchannel_ps_enabled;
1201965bedadSJohannes Berg 	/*
1202965bedadSJohannes Berg 	 * PS can only be enabled when we have exactly one managed
1203965bedadSJohannes Berg 	 * interface (and monitors) in PS, this then points there.
1204965bedadSJohannes Berg 	 */
1205965bedadSJohannes Berg 	struct ieee80211_sub_if_data *ps_sdata;
1206520eb820SKalle Valo 	struct work_struct dynamic_ps_enable_work;
1207520eb820SKalle Valo 	struct work_struct dynamic_ps_disable_work;
1208520eb820SKalle Valo 	struct timer_list dynamic_ps_timer;
120910f644a4SJohannes Berg 	struct notifier_block network_latency_notifier;
12102b2c009eSJuuso Oikarinen 	struct notifier_block ifa_notifier;
1211a65240c1SJohannes Berg 	struct notifier_block ifa6_notifier;
1212f0706e82SJiri Benc 
1213ff616381SJuuso Oikarinen 	/*
1214ff616381SJuuso Oikarinen 	 * The dynamic ps timeout configured from user space via WEXT -
1215ff616381SJuuso Oikarinen 	 * this will override whatever chosen by mac80211 internally.
1216ff616381SJuuso Oikarinen 	 */
1217ff616381SJuuso Oikarinen 	int dynamic_ps_forced_timeout;
1218ff616381SJuuso Oikarinen 
12191ea6f9c0SJohannes Berg 	int user_power_level; /* in dBm, for all interfaces */
12202bf30fabSJohannes Berg 
12210f78231bSJohannes Berg 	enum ieee80211_smps_mode smps_mode;
12220f78231bSJohannes Berg 
1223f2753ddbSJohannes Berg 	struct work_struct restart_work;
1224f2753ddbSJohannes Berg 
1225e9f207f0SJiri Benc #ifdef CONFIG_MAC80211_DEBUGFS
1226e9f207f0SJiri Benc 	struct local_debugfsdentries {
12274b7679a5SJohannes Berg 		struct dentry *rcdir;
1228e9f207f0SJiri Benc 		struct dentry *keys;
1229e9f207f0SJiri Benc 	} debugfs;
1230e9f207f0SJiri Benc #endif
12314e6cbfd0SJohn W. Linville 
12322eb278e0SJohannes Berg 	/*
12332eb278e0SJohannes Berg 	 * Remain-on-channel support
12342eb278e0SJohannes Berg 	 */
12352eb278e0SJohannes Berg 	struct list_head roc_list;
123621f83589SJohannes Berg 	struct work_struct hw_roc_start, hw_roc_done;
12372eb278e0SJohannes Berg 	unsigned long hw_roc_start_time;
123850febf6aSJohannes Berg 	u64 roc_cookie_counter;
123921f83589SJohannes Berg 
1240a729cff8SJohannes Berg 	struct idr ack_status_frames;
1241a729cff8SJohannes Berg 	spinlock_t ack_status_lock;
1242a729cff8SJohannes Berg 
1243f142c6b9SJohannes Berg 	struct ieee80211_sub_if_data __rcu *p2p_sdata;
1244f142c6b9SJohannes Berg 
124506d181a8SJohannes Berg 	struct napi_struct *napi;
124606d181a8SJohannes Berg 
12474b6f1dd6SJohannes Berg 	/* virtual monitor interface */
12484b6f1dd6SJohannes Berg 	struct ieee80211_sub_if_data __rcu *monitor_sdata;
12494bf88530SJohannes Berg 	struct cfg80211_chan_def monitor_chandef;
1250f0706e82SJiri Benc };
1251f0706e82SJiri Benc 
12523e122be0SJohannes Berg static inline struct ieee80211_sub_if_data *
12533e122be0SJohannes Berg IEEE80211_DEV_TO_SUB_IF(struct net_device *dev)
12543e122be0SJohannes Berg {
12553e122be0SJohannes Berg 	return netdev_priv(dev);
12563e122be0SJohannes Berg }
12573e122be0SJohannes Berg 
125871bbc994SJohannes Berg static inline struct ieee80211_sub_if_data *
125971bbc994SJohannes Berg IEEE80211_WDEV_TO_SUB_IF(struct wireless_dev *wdev)
126071bbc994SJohannes Berg {
126171bbc994SJohannes Berg 	return container_of(wdev, struct ieee80211_sub_if_data, wdev);
126271bbc994SJohannes Berg }
126371bbc994SJohannes Berg 
1264c1475ca9SJohannes Berg /* this struct represents 802.11n's RA/TID combination */
1265eadc8d9eSRon Rindjunsky struct ieee80211_ra_tid {
1266eadc8d9eSRon Rindjunsky 	u8 ra[ETH_ALEN];
1267eadc8d9eSRon Rindjunsky 	u16 tid;
1268eadc8d9eSRon Rindjunsky };
1269eadc8d9eSRon Rindjunsky 
1270c0f17eb9SChun-Yeow Yeoh /* this struct holds the value parsing from channel switch IE  */
1271c0f17eb9SChun-Yeow Yeoh struct ieee80211_csa_ie {
1272c0f17eb9SChun-Yeow Yeoh 	struct cfg80211_chan_def chandef;
1273c0f17eb9SChun-Yeow Yeoh 	u8 mode;
1274c0f17eb9SChun-Yeow Yeoh 	u8 count;
1275c0f17eb9SChun-Yeow Yeoh 	u8 ttl;
12763f718fd8SChun-Yeow Yeoh 	u16 pre_value;
1277c0f17eb9SChun-Yeow Yeoh };
1278c0f17eb9SChun-Yeow Yeoh 
1279dd76986bSJohannes Berg /* Parsed Information Elements */
1280dd76986bSJohannes Berg struct ieee802_11_elems {
12814a3cb702SJohannes Berg 	const u8 *ie_start;
1282dd76986bSJohannes Berg 	size_t total_len;
1283dd76986bSJohannes Berg 
1284dd76986bSJohannes Berg 	/* pointers to IEs */
12854a3cb702SJohannes Berg 	const u8 *ssid;
12864a3cb702SJohannes Berg 	const u8 *supp_rates;
12874a3cb702SJohannes Berg 	const u8 *ds_params;
12884a3cb702SJohannes Berg 	const struct ieee80211_tim_ie *tim;
12894a3cb702SJohannes Berg 	const u8 *challenge;
12904a3cb702SJohannes Berg 	const u8 *rsn;
12914a3cb702SJohannes Berg 	const u8 *erp_info;
12924a3cb702SJohannes Berg 	const u8 *ext_supp_rates;
12934a3cb702SJohannes Berg 	const u8 *wmm_info;
12944a3cb702SJohannes Berg 	const u8 *wmm_param;
12954a3cb702SJohannes Berg 	const struct ieee80211_ht_cap *ht_cap_elem;
12964a3cb702SJohannes Berg 	const struct ieee80211_ht_operation *ht_operation;
12974a3cb702SJohannes Berg 	const struct ieee80211_vht_cap *vht_cap_elem;
12984a3cb702SJohannes Berg 	const struct ieee80211_vht_operation *vht_operation;
12994a3cb702SJohannes Berg 	const struct ieee80211_meshconf_ie *mesh_config;
13004a3cb702SJohannes Berg 	const u8 *mesh_id;
13014a3cb702SJohannes Berg 	const u8 *peering;
13024a3cb702SJohannes Berg 	const __le16 *awake_window;
13034a3cb702SJohannes Berg 	const u8 *preq;
13044a3cb702SJohannes Berg 	const u8 *prep;
13054a3cb702SJohannes Berg 	const u8 *perr;
13064a3cb702SJohannes Berg 	const struct ieee80211_rann_ie *rann;
13074a3cb702SJohannes Berg 	const struct ieee80211_channel_sw_ie *ch_switch_ie;
1308b4f286a1SJohannes Berg 	const struct ieee80211_ext_chansw_ie *ext_chansw_ie;
1309b2e506bfSJohannes Berg 	const struct ieee80211_wide_bw_chansw_ie *wide_bw_chansw_ie;
13104a3cb702SJohannes Berg 	const u8 *country_elem;
13114a3cb702SJohannes Berg 	const u8 *pwr_constr_elem;
131279ba1d89SJohannes Berg 	const struct ieee80211_timeout_interval_ie *timeout_int;
13134a3cb702SJohannes Berg 	const u8 *opmode_notif;
131485220d71SJohannes Berg 	const struct ieee80211_sec_chan_offs_ie *sec_chan_offs;
13158f2535b9SChun-Yeow Yeoh 	const struct ieee80211_mesh_chansw_params_ie *mesh_chansw_params_ie;
1316dd76986bSJohannes Berg 
1317dd76986bSJohannes Berg 	/* length of them, respectively */
1318dd76986bSJohannes Berg 	u8 ssid_len;
1319dd76986bSJohannes Berg 	u8 supp_rates_len;
1320dd76986bSJohannes Berg 	u8 tim_len;
1321dd76986bSJohannes Berg 	u8 challenge_len;
1322dd76986bSJohannes Berg 	u8 rsn_len;
1323dd76986bSJohannes Berg 	u8 ext_supp_rates_len;
1324dd76986bSJohannes Berg 	u8 wmm_info_len;
1325dd76986bSJohannes Berg 	u8 wmm_param_len;
1326dd76986bSJohannes Berg 	u8 mesh_id_len;
1327dd76986bSJohannes Berg 	u8 peering_len;
1328dd76986bSJohannes Berg 	u8 preq_len;
1329dd76986bSJohannes Berg 	u8 prep_len;
1330dd76986bSJohannes Berg 	u8 perr_len;
1331dd76986bSJohannes Berg 	u8 country_elem_len;
1332fcff4f10SPaul Stewart 
1333fcff4f10SPaul Stewart 	/* whether a parse error occurred while retrieving these elements */
1334fcff4f10SPaul Stewart 	bool parse_error;
1335dd76986bSJohannes Berg };
1336dd76986bSJohannes Berg 
1337f0706e82SJiri Benc static inline struct ieee80211_local *hw_to_local(
1338f0706e82SJiri Benc 	struct ieee80211_hw *hw)
1339f0706e82SJiri Benc {
1340f0706e82SJiri Benc 	return container_of(hw, struct ieee80211_local, hw);
1341f0706e82SJiri Benc }
1342f0706e82SJiri Benc 
1343f0706e82SJiri Benc 
1344571ecf67SJohannes Berg static inline int ieee80211_bssid_match(const u8 *raddr, const u8 *addr)
1345571ecf67SJohannes Berg {
1346b203ca39SJoe Perches 	return ether_addr_equal(raddr, addr) ||
1347571ecf67SJohannes Berg 	       is_broadcast_ether_addr(raddr);
1348571ecf67SJohannes Berg }
1349571ecf67SJohannes Berg 
1350f4bda337SThomas Pedersen static inline bool
1351f4bda337SThomas Pedersen ieee80211_have_rx_timestamp(struct ieee80211_rx_status *status)
1352f4bda337SThomas Pedersen {
1353f4bda337SThomas Pedersen 	WARN_ON_ONCE(status->flag & RX_FLAG_MACTIME_START &&
1354f4bda337SThomas Pedersen 		     status->flag & RX_FLAG_MACTIME_END);
1355f4bda337SThomas Pedersen 	return status->flag & (RX_FLAG_MACTIME_START | RX_FLAG_MACTIME_END);
1356f4bda337SThomas Pedersen }
1357571ecf67SJohannes Berg 
1358f4bda337SThomas Pedersen u64 ieee80211_calculate_rx_timestamp(struct ieee80211_local *local,
1359f4bda337SThomas Pedersen 				     struct ieee80211_rx_status *status,
1360f4bda337SThomas Pedersen 				     unsigned int mpdu_len,
1361f4bda337SThomas Pedersen 				     unsigned int mpdu_offset);
1362e8975581SJohannes Berg int ieee80211_hw_config(struct ieee80211_local *local, u32 changed);
13635cf121c3SJohannes Berg void ieee80211_tx_set_protected(struct ieee80211_tx_data *tx);
13649c6bd790SJohannes Berg void ieee80211_bss_info_change_notify(struct ieee80211_sub_if_data *sdata,
13659c6bd790SJohannes Berg 				      u32 changed);
13660d143fe1SJohannes Berg void ieee80211_configure_filter(struct ieee80211_local *local);
136746900298SJohannes Berg u32 ieee80211_reset_erp_info(struct ieee80211_sub_if_data *sdata);
1368f0706e82SJiri Benc 
136946900298SJohannes Berg /* STA code */
13709c6bd790SJohannes Berg void ieee80211_sta_setup_sdata(struct ieee80211_sub_if_data *sdata);
137177fdaa12SJohannes Berg int ieee80211_mgd_auth(struct ieee80211_sub_if_data *sdata,
137277fdaa12SJohannes Berg 		       struct cfg80211_auth_request *req);
137377fdaa12SJohannes Berg int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata,
137477fdaa12SJohannes Berg 			struct cfg80211_assoc_request *req);
137577fdaa12SJohannes Berg int ieee80211_mgd_deauth(struct ieee80211_sub_if_data *sdata,
137663c9c5e7SJohannes Berg 			 struct cfg80211_deauth_request *req);
137777fdaa12SJohannes Berg int ieee80211_mgd_disassoc(struct ieee80211_sub_if_data *sdata,
137863c9c5e7SJohannes Berg 			   struct cfg80211_disassoc_request *req);
1379572e0012SKalle Valo void ieee80211_send_pspoll(struct ieee80211_local *local,
1380572e0012SKalle Valo 			   struct ieee80211_sub_if_data *sdata);
138110f644a4SJohannes Berg void ieee80211_recalc_ps(struct ieee80211_local *local, s32 latency);
1382ab095877SEliad Peller void ieee80211_recalc_ps_vif(struct ieee80211_sub_if_data *sdata);
138310f644a4SJohannes Berg int ieee80211_max_network_latency(struct notifier_block *nb,
138410f644a4SJohannes Berg 				  unsigned long data, void *dummy);
13852b2c009eSJuuso Oikarinen int ieee80211_set_arp_filter(struct ieee80211_sub_if_data *sdata);
13861fa57d01SJohannes Berg void ieee80211_sta_work(struct ieee80211_sub_if_data *sdata);
13871fa57d01SJohannes Berg void ieee80211_sta_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
13881fa57d01SJohannes Berg 				  struct sk_buff *skb);
1389d3a910a8SLuis R. Rodriguez void ieee80211_sta_reset_beacon_monitor(struct ieee80211_sub_if_data *sdata);
1390be099e82SLuis R. Rodriguez void ieee80211_sta_reset_conn_monitor(struct ieee80211_sub_if_data *sdata);
1391afa762f6SEliad Peller void ieee80211_mgd_stop(struct ieee80211_sub_if_data *sdata);
13921672c0e3SJohannes Berg void ieee80211_mgd_conn_tx_status(struct ieee80211_sub_if_data *sdata,
13931672c0e3SJohannes Berg 				  __le16 fc, bool acked);
13941a1cb744SJohannes Berg void ieee80211_mgd_quiesce(struct ieee80211_sub_if_data *sdata);
1395b8360ab8SJohannes Berg void ieee80211_sta_restart(struct ieee80211_sub_if_data *sdata);
13969c6bd790SJohannes Berg 
139746900298SJohannes Berg /* IBSS code */
139846900298SJohannes Berg void ieee80211_ibss_notify_scan_completed(struct ieee80211_local *local);
139946900298SJohannes Berg void ieee80211_ibss_setup_sdata(struct ieee80211_sub_if_data *sdata);
14008bf11d8dSJohannes Berg void ieee80211_ibss_rx_no_sta(struct ieee80211_sub_if_data *sdata,
14018bf11d8dSJohannes Berg 			      const u8 *bssid, const u8 *addr, u32 supp_rates);
1402af8cdcd8SJohannes Berg int ieee80211_ibss_join(struct ieee80211_sub_if_data *sdata,
1403af8cdcd8SJohannes Berg 			struct cfg80211_ibss_params *params);
1404af8cdcd8SJohannes Berg int ieee80211_ibss_leave(struct ieee80211_sub_if_data *sdata);
14051fa57d01SJohannes Berg void ieee80211_ibss_work(struct ieee80211_sub_if_data *sdata);
14061fa57d01SJohannes Berg void ieee80211_ibss_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
14071fa57d01SJohannes Berg 				   struct sk_buff *skb);
1408cd7760e6SSimon Wunderlich int ieee80211_ibss_csa_beacon(struct ieee80211_sub_if_data *sdata,
1409cd7760e6SSimon Wunderlich 			      struct cfg80211_csa_settings *csa_settings);
1410cd7760e6SSimon Wunderlich int ieee80211_ibss_finish_csa(struct ieee80211_sub_if_data *sdata);
1411cd7760e6SSimon Wunderlich void ieee80211_ibss_stop(struct ieee80211_sub_if_data *sdata);
14121fa57d01SJohannes Berg 
14131fa57d01SJohannes Berg /* mesh code */
14141fa57d01SJohannes Berg void ieee80211_mesh_work(struct ieee80211_sub_if_data *sdata);
14151fa57d01SJohannes Berg void ieee80211_mesh_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
14161fa57d01SJohannes Berg 				   struct sk_buff *skb);
1417b8456a14SChun-Yeow Yeoh int ieee80211_mesh_csa_beacon(struct ieee80211_sub_if_data *sdata,
141866e01cf9SLuciano Coelho 			      struct cfg80211_csa_settings *csa_settings);
1419b8456a14SChun-Yeow Yeoh int ieee80211_mesh_finish_csa(struct ieee80211_sub_if_data *sdata);
142046900298SJohannes Berg 
14219c6bd790SJohannes Berg /* scan/BSS handling */
142246900298SJohannes Berg void ieee80211_scan_work(struct work_struct *work);
142334bcf715SStanislaw Gruszka int ieee80211_request_ibss_scan(struct ieee80211_sub_if_data *sdata,
1424be4a4b6aSJohannes Berg 				const u8 *ssid, u8 ssid_len,
14257ca15a0aSSimon Wunderlich 				struct ieee80211_channel *chan,
14267ca15a0aSSimon Wunderlich 				enum nl80211_bss_scan_width scan_width);
1427c2b13452SJohannes Berg int ieee80211_request_scan(struct ieee80211_sub_if_data *sdata,
14282a519311SJohannes Berg 			   struct cfg80211_scan_request *req);
14295bb644a0SJohannes Berg void ieee80211_scan_cancel(struct ieee80211_local *local);
1430133d40f9SStanislaw Gruszka void ieee80211_run_deferred_scan(struct ieee80211_local *local);
1431d48b2968SJohannes Berg void ieee80211_scan_rx(struct ieee80211_local *local, struct sk_buff *skb);
14329c6bd790SJohannes Berg 
14330a51b27eSJohannes Berg void ieee80211_mlme_notify_scan_completed(struct ieee80211_local *local);
1434c2b13452SJohannes Berg struct ieee80211_bss *
143598c8fccfSJohannes Berg ieee80211_bss_info_update(struct ieee80211_local *local,
143698c8fccfSJohannes Berg 			  struct ieee80211_rx_status *rx_status,
143798c8fccfSJohannes Berg 			  struct ieee80211_mgmt *mgmt,
143898c8fccfSJohannes Berg 			  size_t len,
143998c8fccfSJohannes Berg 			  struct ieee802_11_elems *elems,
1440d45c4172SEmmanuel Grumbach 			  struct ieee80211_channel *channel);
144198c8fccfSJohannes Berg void ieee80211_rx_bss_put(struct ieee80211_local *local,
1442c2b13452SJohannes Berg 			  struct ieee80211_bss *bss);
1443ee385855SLuis Carlos Cobo 
144479f460caSLuciano Coelho /* scheduled scan handling */
1445d43c6b6eSDavid Spinadel int
1446d43c6b6eSDavid Spinadel __ieee80211_request_sched_scan_start(struct ieee80211_sub_if_data *sdata,
1447d43c6b6eSDavid Spinadel 				     struct cfg80211_sched_scan_request *req);
144879f460caSLuciano Coelho int ieee80211_request_sched_scan_start(struct ieee80211_sub_if_data *sdata,
144979f460caSLuciano Coelho 				       struct cfg80211_sched_scan_request *req);
145085a9994aSLuciano Coelho int ieee80211_request_sched_scan_stop(struct ieee80211_sub_if_data *sdata);
145185a9994aSLuciano Coelho void ieee80211_sched_scan_stopped_work(struct work_struct *work);
145279f460caSLuciano Coelho 
1453b203ffc3SJouni Malinen /* off-channel helpers */
1454aacde9eeSStanislaw Gruszka void ieee80211_offchannel_stop_vifs(struct ieee80211_local *local);
1455aacde9eeSStanislaw Gruszka void ieee80211_offchannel_return(struct ieee80211_local *local);
14562eb278e0SJohannes Berg void ieee80211_roc_setup(struct ieee80211_local *local);
14572eb278e0SJohannes Berg void ieee80211_start_next_roc(struct ieee80211_local *local);
1458c8f994eeSJohannes Berg void ieee80211_roc_purge(struct ieee80211_local *local,
1459c8f994eeSJohannes Berg 			 struct ieee80211_sub_if_data *sdata);
14603fbd45caSJohannes Berg void ieee80211_roc_notify_destroy(struct ieee80211_roc_work *roc, bool free);
14612eb278e0SJohannes Berg void ieee80211_sw_roc_work(struct work_struct *work);
14622eb278e0SJohannes Berg void ieee80211_handle_roc_started(struct ieee80211_roc_work *roc);
1463b203ffc3SJouni Malinen 
146473da7d5bSSimon Wunderlich /* channel switch handling */
146573da7d5bSSimon Wunderlich void ieee80211_csa_finalize_work(struct work_struct *work);
146682a8e17dSLuciano Coelho int ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev,
146782a8e17dSLuciano Coelho 			     struct cfg80211_csa_settings *params);
146873da7d5bSSimon Wunderlich 
14693e122be0SJohannes Berg /* interface handling */
147047846c9bSJohannes Berg int ieee80211_iface_init(void);
147147846c9bSJohannes Berg void ieee80211_iface_exit(void);
14723e122be0SJohannes Berg int ieee80211_if_add(struct ieee80211_local *local, const char *name,
147384efbb84SJohannes Berg 		     struct wireless_dev **new_wdev, enum nl80211_iftype type,
1474ee385855SLuis Carlos Cobo 		     struct vif_params *params);
1475f3947e2dSJohannes Berg int ieee80211_if_change_type(struct ieee80211_sub_if_data *sdata,
147605c914feSJohannes Berg 			     enum nl80211_iftype type);
1477f698d856SJasper Bryant-Greene void ieee80211_if_remove(struct ieee80211_sub_if_data *sdata);
147875636525SJohannes Berg void ieee80211_remove_interfaces(struct ieee80211_local *local);
1479382a103bSJohannes Berg u32 ieee80211_idle_off(struct ieee80211_local *local);
14805cff20e6SJohannes Berg void ieee80211_recalc_idle(struct ieee80211_local *local);
148185416a4fSChristian Lamparter void ieee80211_adjust_monitor_flags(struct ieee80211_sub_if_data *sdata,
148285416a4fSChristian Lamparter 				    const int offset);
1483f142c6b9SJohannes Berg int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up);
1484f142c6b9SJohannes Berg void ieee80211_sdata_stop(struct ieee80211_sub_if_data *sdata);
14853c3e21e7SJohannes Berg int ieee80211_add_virtual_monitor(struct ieee80211_local *local);
14863c3e21e7SJohannes Berg void ieee80211_del_virtual_monitor(struct ieee80211_local *local);
1487f0706e82SJiri Benc 
14881ea6f9c0SJohannes Berg bool __ieee80211_recalc_txpower(struct ieee80211_sub_if_data *sdata);
14891ea6f9c0SJohannes Berg void ieee80211_recalc_txpower(struct ieee80211_sub_if_data *sdata);
14901ea6f9c0SJohannes Berg 
14919607e6b6SJohannes Berg static inline bool ieee80211_sdata_running(struct ieee80211_sub_if_data *sdata)
14929607e6b6SJohannes Berg {
149334d4bc4dSJohannes Berg 	return test_bit(SDATA_STATE_RUNNING, &sdata->state);
14949607e6b6SJohannes Berg }
14959607e6b6SJohannes Berg 
1496e2ebc74dSJohannes Berg /* tx handling */
1497e2ebc74dSJohannes Berg void ieee80211_clear_tx_pending(struct ieee80211_local *local);
1498e2ebc74dSJohannes Berg void ieee80211_tx_pending(unsigned long data);
1499d0cf9c0dSStephen Hemminger netdev_tx_t ieee80211_monitor_start_xmit(struct sk_buff *skb,
1500d0cf9c0dSStephen Hemminger 					 struct net_device *dev);
1501d0cf9c0dSStephen Hemminger netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb,
1502d0cf9c0dSStephen Hemminger 				       struct net_device *dev);
15031f98ab7fSFelix Fietkau void ieee80211_purge_tx_queue(struct ieee80211_hw *hw,
15041f98ab7fSFelix Fietkau 			      struct sk_buff_head *skbs);
1505e2ebc74dSJohannes Berg 
1506de1ede7aSJohannes Berg /* HT */
1507ef96a842SBen Greear void ieee80211_apply_htcap_overrides(struct ieee80211_sub_if_data *sdata,
1508ef96a842SBen Greear 				     struct ieee80211_sta_ht_cap *ht_cap);
1509e1a0c6b3SJohannes Berg bool ieee80211_ht_cap_ie_to_sta_ht_cap(struct ieee80211_sub_if_data *sdata,
1510ef96a842SBen Greear 				       struct ieee80211_supported_band *sband,
15114a3cb702SJohannes Berg 				       const struct ieee80211_ht_cap *ht_cap_ie,
1512e1a0c6b3SJohannes Berg 				       struct sta_info *sta);
1513b8695a8fSJohannes Berg void ieee80211_send_delba(struct ieee80211_sub_if_data *sdata,
1514b8695a8fSJohannes Berg 			  const u8 *da, u16 tid,
1515b8695a8fSJohannes Berg 			  u16 initiator, u16 reason_code);
15160f78231bSJohannes Berg int ieee80211_send_smps_action(struct ieee80211_sub_if_data *sdata,
15170f78231bSJohannes Berg 			       enum ieee80211_smps_mode smps, const u8 *da,
15180f78231bSJohannes Berg 			       const u8 *bssid);
1519687da132SEmmanuel Grumbach void ieee80211_request_smps_ap_work(struct work_struct *work);
1520687da132SEmmanuel Grumbach void ieee80211_request_smps_mgd_work(struct work_struct *work);
1521687da132SEmmanuel Grumbach bool ieee80211_smps_is_restrictive(enum ieee80211_smps_mode smps_mode_old,
1522687da132SEmmanuel Grumbach 				   enum ieee80211_smps_mode smps_mode_new);
1523de1ede7aSJohannes Berg 
15247c3b1dd8SJohannes Berg void ___ieee80211_stop_rx_ba_session(struct sta_info *sta, u16 tid,
152553f73c09SJohannes Berg 				     u16 initiator, u16 reason, bool stop);
1526849b7967SJohannes Berg void __ieee80211_stop_rx_ba_session(struct sta_info *sta, u16 tid,
152753f73c09SJohannes Berg 				    u16 initiator, u16 reason, bool stop);
1528c82c4a80SJohannes Berg void ieee80211_sta_tear_down_BA_sessions(struct sta_info *sta,
1529c82c4a80SJohannes Berg 					 enum ieee80211_agg_stop_reason reason);
1530de1ede7aSJohannes Berg void ieee80211_process_delba(struct ieee80211_sub_if_data *sdata,
1531de1ede7aSJohannes Berg 			     struct sta_info *sta,
1532de1ede7aSJohannes Berg 			     struct ieee80211_mgmt *mgmt, size_t len);
1533de1ede7aSJohannes Berg void ieee80211_process_addba_resp(struct ieee80211_local *local,
1534de1ede7aSJohannes Berg 				  struct sta_info *sta,
1535de1ede7aSJohannes Berg 				  struct ieee80211_mgmt *mgmt,
1536de1ede7aSJohannes Berg 				  size_t len);
1537de1ede7aSJohannes Berg void ieee80211_process_addba_request(struct ieee80211_local *local,
1538de1ede7aSJohannes Berg 				     struct sta_info *sta,
1539de1ede7aSJohannes Berg 				     struct ieee80211_mgmt *mgmt,
1540de1ede7aSJohannes Berg 				     size_t len);
1541de1ede7aSJohannes Berg 
1542849b7967SJohannes Berg int __ieee80211_stop_tx_ba_session(struct sta_info *sta, u16 tid,
1543c82c4a80SJohannes Berg 				   enum ieee80211_agg_stop_reason reason);
154467c282c0SJohannes Berg int ___ieee80211_stop_tx_ba_session(struct sta_info *sta, u16 tid,
1545c82c4a80SJohannes Berg 				    enum ieee80211_agg_stop_reason reason);
15465d22c89bSJohannes Berg void ieee80211_start_tx_ba_cb(struct ieee80211_vif *vif, u8 *ra, u16 tid);
15475d22c89bSJohannes Berg void ieee80211_stop_tx_ba_cb(struct ieee80211_vif *vif, u8 *ra, u8 tid);
154867c282c0SJohannes Berg void ieee80211_ba_session_work(struct work_struct *work);
154967c282c0SJohannes Berg void ieee80211_tx_ba_session_handle_start(struct sta_info *sta, int tid);
15502bff8ebfSChristian Lamparter void ieee80211_release_reorder_timeout(struct sta_info *sta, int tid);
1551849b7967SJohannes Berg 
155204ecd257SJohannes Berg u8 ieee80211_mcs_to_chains(const struct ieee80211_mcs_info *mcs);
155304ecd257SJohannes Berg 
1554818255eaSMahesh Palivela /* VHT */
15554a3cb702SJohannes Berg void
15564a3cb702SJohannes Berg ieee80211_vht_cap_ie_to_sta_vht_cap(struct ieee80211_sub_if_data *sdata,
1557818255eaSMahesh Palivela 				    struct ieee80211_supported_band *sband,
15584a3cb702SJohannes Berg 				    const struct ieee80211_vht_cap *vht_cap_ie,
15594a34215eSJohannes Berg 				    struct sta_info *sta);
1560e1a0c6b3SJohannes Berg enum ieee80211_sta_rx_bandwidth ieee80211_sta_cur_vht_bw(struct sta_info *sta);
15618921d04eSJohannes Berg void ieee80211_sta_set_rx_nss(struct sta_info *sta);
1562b1bce14aSMarek Kwaczynski u32 __ieee80211_vht_handle_opmode(struct ieee80211_sub_if_data *sdata,
1563b1bce14aSMarek Kwaczynski                                   struct sta_info *sta, u8 opmode,
1564b1bce14aSMarek Kwaczynski                                   enum ieee80211_band band, bool nss_only);
15650af83d3dSJohannes Berg void ieee80211_vht_handle_opmode(struct ieee80211_sub_if_data *sdata,
15660af83d3dSJohannes Berg 				 struct sta_info *sta, u8 opmode,
1567bee7f586SJohannes Berg 				 enum ieee80211_band band, bool nss_only);
1568dd5ecfeaSJohannes Berg void ieee80211_apply_vhtcap_overrides(struct ieee80211_sub_if_data *sdata,
1569dd5ecfeaSJohannes Berg 				      struct ieee80211_sta_vht_cap *vht_cap);
15704a34215eSJohannes Berg 
157139192c0bSJohannes Berg /* Spectrum management */
157239192c0bSJohannes Berg void ieee80211_process_measurement_req(struct ieee80211_sub_if_data *sdata,
157339192c0bSJohannes Berg 				       struct ieee80211_mgmt *mgmt,
157439192c0bSJohannes Berg 				       size_t len);
1575e6b7cde4SSimon Wunderlich /**
1576e6b7cde4SSimon Wunderlich  * ieee80211_parse_ch_switch_ie - parses channel switch IEs
1577e6b7cde4SSimon Wunderlich  * @sdata: the sdata of the interface which has received the frame
1578e6b7cde4SSimon Wunderlich  * @elems: parsed 802.11 elements received with the frame
1579e6b7cde4SSimon Wunderlich  * @beacon: indicates if the frame was a beacon or probe response
1580e6b7cde4SSimon Wunderlich  * @current_band: indicates the current band
1581e6b7cde4SSimon Wunderlich  * @sta_flags: contains information about own capabilities and restrictions
1582e6b7cde4SSimon Wunderlich  *	to decide which channel switch announcements can be accepted. Only the
1583e6b7cde4SSimon Wunderlich  *	following subset of &enum ieee80211_sta_flags are evaluated:
1584e6b7cde4SSimon Wunderlich  *	%IEEE80211_STA_DISABLE_HT, %IEEE80211_STA_DISABLE_VHT,
1585e6b7cde4SSimon Wunderlich  *	%IEEE80211_STA_DISABLE_40MHZ, %IEEE80211_STA_DISABLE_80P80MHZ,
1586e6b7cde4SSimon Wunderlich  *	%IEEE80211_STA_DISABLE_160MHZ.
1587e6b7cde4SSimon Wunderlich  * @bssid: the currently connected bssid (for reporting)
1588c0f17eb9SChun-Yeow Yeoh  * @csa_ie: parsed 802.11 csa elements on count, mode, chandef and mesh ttl.
1589c0f17eb9SChun-Yeow Yeoh 	All of them will be filled with if success only.
1590e6b7cde4SSimon Wunderlich  * Return: 0 on success, <0 on error and >0 if there is nothing to parse.
1591e6b7cde4SSimon Wunderlich  */
1592e6b7cde4SSimon Wunderlich int ieee80211_parse_ch_switch_ie(struct ieee80211_sub_if_data *sdata,
1593e6b7cde4SSimon Wunderlich 				 struct ieee802_11_elems *elems, bool beacon,
1594e6b7cde4SSimon Wunderlich 				 enum ieee80211_band current_band,
1595c0f17eb9SChun-Yeow Yeoh 				 u32 sta_flags, u8 *bssid,
1596c0f17eb9SChun-Yeow Yeoh 				 struct ieee80211_csa_ie *csa_ie);
159739192c0bSJohannes Berg 
1598f2753ddbSJohannes Berg /* Suspend/resume and hw reconfiguration */
1599f2753ddbSJohannes Berg int ieee80211_reconfig(struct ieee80211_local *local);
160084f6a01cSJohannes Berg void ieee80211_stop_device(struct ieee80211_local *local);
1601f2753ddbSJohannes Berg 
1602eecc4800SJohannes Berg int __ieee80211_suspend(struct ieee80211_hw *hw,
1603eecc4800SJohannes Berg 			struct cfg80211_wowlan *wowlan);
1604f2753ddbSJohannes Berg 
1605f2753ddbSJohannes Berg static inline int __ieee80211_resume(struct ieee80211_hw *hw)
1606f2753ddbSJohannes Berg {
160785f72bc8SJohn W. Linville 	struct ieee80211_local *local = hw_to_local(hw);
160885f72bc8SJohn W. Linville 
160985f72bc8SJohn W. Linville 	WARN(test_bit(SCAN_HW_SCANNING, &local->scanning),
161085f72bc8SJohn W. Linville 		"%s: resume with hardware scan still in progress\n",
161185f72bc8SJohn W. Linville 		wiphy_name(hw->wiphy));
161285f72bc8SJohn W. Linville 
1613f2753ddbSJohannes Berg 	return ieee80211_reconfig(hw_to_local(hw));
1614f2753ddbSJohannes Berg }
1615665af4fcSBob Copeland 
1616c2d1560aSJohannes Berg /* utility functions/constants */
16178a47cea7SJohannes Berg extern const void *const mac80211_wiphy_privid; /* for wiphy privid */
161871364716SRon Rindjunsky u8 *ieee80211_get_bssid(struct ieee80211_hdr *hdr, size_t len,
161905c914feSJohannes Berg 			enum nl80211_iftype type);
16204ee73f33SMichal Kazior int ieee80211_frame_duration(enum ieee80211_band band, size_t len,
1621438b61b7SSimon Wunderlich 			     int rate, int erp, int short_preamble,
1622438b61b7SSimon Wunderlich 			     int shift);
1623f698d856SJasper Bryant-Greene void mac80211_ev_michael_mic_failure(struct ieee80211_sub_if_data *sdata, int keyidx,
1624e6d6e342SJohannes Berg 				     struct ieee80211_hdr *hdr, const u8 *tsc,
1625e6d6e342SJohannes Berg 				     gfp_t gfp);
16263abead59SJohannes Berg void ieee80211_set_wmm_default(struct ieee80211_sub_if_data *sdata,
16273abead59SJohannes Berg 			       bool bss_notify);
162855de908aSJohannes Berg void ieee80211_xmit(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb,
162955de908aSJohannes Berg 		    enum ieee80211_band band);
1630cf6bb79aSHelmut Schaa 
163155de908aSJohannes Berg void __ieee80211_tx_skb_tid_band(struct ieee80211_sub_if_data *sdata,
163255de908aSJohannes Berg 				 struct sk_buff *skb, int tid,
163355de908aSJohannes Berg 				 enum ieee80211_band band);
163455de908aSJohannes Berg 
163555de908aSJohannes Berg static inline void
163655de908aSJohannes Berg ieee80211_tx_skb_tid_band(struct ieee80211_sub_if_data *sdata,
163755de908aSJohannes Berg 			  struct sk_buff *skb, int tid,
163855de908aSJohannes Berg 			  enum ieee80211_band band)
163955de908aSJohannes Berg {
164055de908aSJohannes Berg 	rcu_read_lock();
164155de908aSJohannes Berg 	__ieee80211_tx_skb_tid_band(sdata, skb, tid, band);
164255de908aSJohannes Berg 	rcu_read_unlock();
164355de908aSJohannes Berg }
164455de908aSJohannes Berg 
164555de908aSJohannes Berg static inline void ieee80211_tx_skb_tid(struct ieee80211_sub_if_data *sdata,
164655de908aSJohannes Berg 					struct sk_buff *skb, int tid)
164755de908aSJohannes Berg {
164855de908aSJohannes Berg 	struct ieee80211_chanctx_conf *chanctx_conf;
164955de908aSJohannes Berg 
165055de908aSJohannes Berg 	rcu_read_lock();
165155de908aSJohannes Berg 	chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
165255de908aSJohannes Berg 	if (WARN_ON(!chanctx_conf)) {
165355de908aSJohannes Berg 		rcu_read_unlock();
165455de908aSJohannes Berg 		kfree_skb(skb);
165555de908aSJohannes Berg 		return;
165655de908aSJohannes Berg 	}
165755de908aSJohannes Berg 
165855de908aSJohannes Berg 	__ieee80211_tx_skb_tid_band(sdata, skb, tid,
16594bf88530SJohannes Berg 				    chanctx_conf->def.chan->band);
166055de908aSJohannes Berg 	rcu_read_unlock();
166155de908aSJohannes Berg }
166255de908aSJohannes Berg 
166355de908aSJohannes Berg static inline void ieee80211_tx_skb(struct ieee80211_sub_if_data *sdata,
1664cf6bb79aSHelmut Schaa 				    struct sk_buff *skb)
1665cf6bb79aSHelmut Schaa {
1666cf6bb79aSHelmut Schaa 	/* Send all internal mgmt frames on VO. Accordingly set TID to 7. */
1667cf6bb79aSHelmut Schaa 	ieee80211_tx_skb_tid(sdata, skb, 7);
1668cf6bb79aSHelmut Schaa }
1669cf6bb79aSHelmut Schaa 
167035d865afSJohannes Berg u32 ieee802_11_parse_elems_crc(const u8 *start, size_t len, bool action,
1671d91f36dbSJohannes Berg 			       struct ieee802_11_elems *elems,
1672d91f36dbSJohannes Berg 			       u64 filter, u32 crc);
167335d865afSJohannes Berg static inline void ieee802_11_parse_elems(const u8 *start, size_t len,
167435d865afSJohannes Berg 					  bool action,
1675ddc4db2eSJohannes Berg 					  struct ieee802_11_elems *elems)
1676ddc4db2eSJohannes Berg {
1677b2e506bfSJohannes Berg 	ieee802_11_parse_elems_crc(start, len, action, elems, 0, 0);
1678ddc4db2eSJohannes Berg }
1679ddc4db2eSJohannes Berg 
1680520eb820SKalle Valo void ieee80211_dynamic_ps_enable_work(struct work_struct *work);
1681520eb820SKalle Valo void ieee80211_dynamic_ps_disable_work(struct work_struct *work);
1682520eb820SKalle Valo void ieee80211_dynamic_ps_timer(unsigned long data);
1683a97b77b9SVivek Natarajan void ieee80211_send_nullfunc(struct ieee80211_local *local,
1684a97b77b9SVivek Natarajan 			     struct ieee80211_sub_if_data *sdata,
1685a97b77b9SVivek Natarajan 			     int powersave);
16863cf335d5SKalle Valo void ieee80211_sta_rx_notify(struct ieee80211_sub_if_data *sdata,
16873cf335d5SKalle Valo 			     struct ieee80211_hdr *hdr);
16884e5ff376SFelix Fietkau void ieee80211_sta_tx_notify(struct ieee80211_sub_if_data *sdata,
168904ac3c0eSFelix Fietkau 			     struct ieee80211_hdr *hdr, bool ack);
1690520eb820SKalle Valo 
1691ce7c9111SKalle Valo void ieee80211_wake_queues_by_reason(struct ieee80211_hw *hw,
1692445ea4e8SJohannes Berg 				     unsigned long queues,
1693ce7c9111SKalle Valo 				     enum queue_stop_reason reason);
1694ce7c9111SKalle Valo void ieee80211_stop_queues_by_reason(struct ieee80211_hw *hw,
1695445ea4e8SJohannes Berg 				     unsigned long queues,
1696ce7c9111SKalle Valo 				     enum queue_stop_reason reason);
169796f5e66eSJohannes Berg void ieee80211_wake_queue_by_reason(struct ieee80211_hw *hw, int queue,
169896f5e66eSJohannes Berg 				    enum queue_stop_reason reason);
169996f5e66eSJohannes Berg void ieee80211_stop_queue_by_reason(struct ieee80211_hw *hw, int queue,
170096f5e66eSJohannes Berg 				    enum queue_stop_reason reason);
17013a25a8c8SJohannes Berg void ieee80211_propagate_queue_wake(struct ieee80211_local *local, int queue);
17028f77f384SJohannes Berg void ieee80211_add_pending_skb(struct ieee80211_local *local,
17038f77f384SJohannes Berg 			       struct sk_buff *skb);
1704e3685e03SJohannes Berg void ieee80211_add_pending_skbs(struct ieee80211_local *local,
1705e3685e03SJohannes Berg 				struct sk_buff_head *skbs);
170639ecc01dSJohannes Berg void ieee80211_flush_queues(struct ieee80211_local *local,
170739ecc01dSJohannes Berg 			    struct ieee80211_sub_if_data *sdata);
1708ce7c9111SKalle Valo 
170946900298SJohannes Berg void ieee80211_send_auth(struct ieee80211_sub_if_data *sdata,
1710700e8ea6SJouni Malinen 			 u16 transaction, u16 auth_alg, u16 status,
17114a3cb702SJohannes Berg 			 const u8 *extra, size_t extra_len, const u8 *bssid,
17121672c0e3SJohannes Berg 			 const u8 *da, const u8 *key, u8 key_len, u8 key_idx,
17131672c0e3SJohannes Berg 			 u32 tx_flags);
17146ae16775SAntonio Quartulli void ieee80211_send_deauth_disassoc(struct ieee80211_sub_if_data *sdata,
17156ae16775SAntonio Quartulli 				    const u8 *bssid, u16 stype, u16 reason,
17166ae16775SAntonio Quartulli 				    bool send_frame, u8 *frame_buf);
1717de95a54bSJohannes Berg int ieee80211_build_preq_ies(struct ieee80211_local *local, u8 *buffer,
1718c604b9f2SJohannes Berg 			     size_t buffer_len, const u8 *ie, size_t ie_len,
1719651b5225SJouni Malinen 			     enum ieee80211_band band, u32 rate_mask,
17202103dec1SSimon Wunderlich 			     struct cfg80211_chan_def *chandef);
1721a619a4c0SJuuso Oikarinen struct sk_buff *ieee80211_build_probe_req(struct ieee80211_sub_if_data *sdata,
172285a237feSJohannes Berg 					  u8 *dst, u32 ratemask,
17236b77863bSJohannes Berg 					  struct ieee80211_channel *chan,
1724a619a4c0SJuuso Oikarinen 					  const u8 *ssid, size_t ssid_len,
1725a806c558SPaul Stewart 					  const u8 *ie, size_t ie_len,
1726a806c558SPaul Stewart 					  bool directed);
172746900298SJohannes Berg void ieee80211_send_probe_req(struct ieee80211_sub_if_data *sdata, u8 *dst,
1728de95a54bSJohannes Berg 			      const u8 *ssid, size_t ssid_len,
1729a806c558SPaul Stewart 			      const u8 *ie, size_t ie_len,
17301672c0e3SJohannes Berg 			      u32 ratemask, bool directed, u32 tx_flags,
173155de908aSJohannes Berg 			      struct ieee80211_channel *channel, bool scan);
173246900298SJohannes Berg 
17332103dec1SSimon Wunderlich u32 ieee80211_sta_get_rates(struct ieee80211_sub_if_data *sdata,
173446900298SJohannes Berg 			    struct ieee802_11_elems *elems,
17359ebb61a2SAshok Nagarajan 			    enum ieee80211_band band, u32 *basic_rates);
1736687da132SEmmanuel Grumbach int __ieee80211_request_smps_mgd(struct ieee80211_sub_if_data *sdata,
1737687da132SEmmanuel Grumbach 				 enum ieee80211_smps_mode smps_mode);
1738687da132SEmmanuel Grumbach int __ieee80211_request_smps_ap(struct ieee80211_sub_if_data *sdata,
17390f78231bSJohannes Berg 				enum ieee80211_smps_mode smps_mode);
174004ecd257SJohannes Berg void ieee80211_recalc_smps(struct ieee80211_sub_if_data *sdata);
174121f659bfSEliad Peller void ieee80211_recalc_min_chandef(struct ieee80211_sub_if_data *sdata);
174246900298SJohannes Berg 
17438e664fb3SJohannes Berg size_t ieee80211_ie_split(const u8 *ies, size_t ielen,
17448e664fb3SJohannes Berg 			  const u8 *ids, int n_ids, size_t offset);
17458e664fb3SJohannes Berg size_t ieee80211_ie_split_vendor(const u8 *ies, size_t ielen, size_t offset);
1746ef96a842SBen Greear u8 *ieee80211_ie_build_ht_cap(u8 *pos, struct ieee80211_sta_ht_cap *ht_cap,
174742e7aa77SAlexander Simon 			      u16 cap);
1748074d46d1SJohannes Berg u8 *ieee80211_ie_build_ht_oper(u8 *pos, struct ieee80211_sta_ht_cap *ht_cap,
17494bf88530SJohannes Berg 			       const struct cfg80211_chan_def *chandef,
1750431e3154SAshok Nagarajan 			       u16 prot_mode);
1751ba0afa2fSMahesh Palivela u8 *ieee80211_ie_build_vht_cap(u8 *pos, struct ieee80211_sta_vht_cap *vht_cap,
1752ba0afa2fSMahesh Palivela 			       u32 cap);
17532103dec1SSimon Wunderlich int ieee80211_parse_bitrates(struct cfg80211_chan_def *chandef,
17542103dec1SSimon Wunderlich 			     const struct ieee80211_supported_band *sband,
17552103dec1SSimon Wunderlich 			     const u8 *srates, int srates_len, u32 *rates);
1756fc8a7321SJohannes Berg int ieee80211_add_srates_ie(struct ieee80211_sub_if_data *sdata,
17576b77863bSJohannes Berg 			    struct sk_buff *skb, bool need_basic,
17586b77863bSJohannes Berg 			    enum ieee80211_band band);
1759fc8a7321SJohannes Berg int ieee80211_add_ext_srates_ie(struct ieee80211_sub_if_data *sdata,
17606b77863bSJohannes Berg 				struct sk_buff *skb, bool need_basic,
17616b77863bSJohannes Berg 				enum ieee80211_band band);
17628e664fb3SJohannes Berg 
1763f444de05SJohannes Berg /* channel management */
17644bf88530SJohannes Berg void ieee80211_ht_oper_to_chandef(struct ieee80211_channel *control_chan,
17654a3cb702SJohannes Berg 				  const struct ieee80211_ht_operation *ht_oper,
17664bf88530SJohannes Berg 				  struct cfg80211_chan_def *chandef);
1767e6b7cde4SSimon Wunderlich u32 ieee80211_chandef_downgrade(struct cfg80211_chan_def *c);
1768f444de05SJohannes Berg 
1769d01a1e65SMichal Kazior int __must_check
1770d01a1e65SMichal Kazior ieee80211_vif_use_channel(struct ieee80211_sub_if_data *sdata,
17714bf88530SJohannes Berg 			  const struct cfg80211_chan_def *chandef,
1772d01a1e65SMichal Kazior 			  enum ieee80211_chanctx_mode mode);
17732c9b7359SJohannes Berg int __must_check
17742c9b7359SJohannes Berg ieee80211_vif_change_bandwidth(struct ieee80211_sub_if_data *sdata,
17752c9b7359SJohannes Berg 			       const struct cfg80211_chan_def *chandef,
17762c9b7359SJohannes Berg 			       u32 *changed);
177773da7d5bSSimon Wunderlich /* NOTE: only use ieee80211_vif_change_channel() for channel switch */
177873da7d5bSSimon Wunderlich int __must_check
177973da7d5bSSimon Wunderlich ieee80211_vif_change_channel(struct ieee80211_sub_if_data *sdata,
178073da7d5bSSimon Wunderlich 			     u32 *changed);
1781d01a1e65SMichal Kazior void ieee80211_vif_release_channel(struct ieee80211_sub_if_data *sdata);
17824d76d21bSJohannes Berg void ieee80211_vif_vlan_copy_chanctx(struct ieee80211_sub_if_data *sdata);
17831f4ac5a6SJohannes Berg void ieee80211_vif_copy_chanctx_to_vlans(struct ieee80211_sub_if_data *sdata,
17841f4ac5a6SJohannes Berg 					 bool clear);
1785d01a1e65SMichal Kazior 
178604ecd257SJohannes Berg void ieee80211_recalc_smps_chanctx(struct ieee80211_local *local,
178704ecd257SJohannes Berg 				   struct ieee80211_chanctx *chanctx);
178821f659bfSEliad Peller void ieee80211_recalc_chanctx_min_def(struct ieee80211_local *local,
178921f659bfSEliad Peller 				      struct ieee80211_chanctx *ctx);
1790164eb02dSSimon Wunderlich 
1791164eb02dSSimon Wunderlich void ieee80211_dfs_cac_timer(unsigned long data);
1792164eb02dSSimon Wunderlich void ieee80211_dfs_cac_timer_work(struct work_struct *work);
1793164eb02dSSimon Wunderlich void ieee80211_dfs_cac_cancel(struct ieee80211_local *local);
1794164eb02dSSimon Wunderlich void ieee80211_dfs_radar_detected_work(struct work_struct *work);
1795c6da674aSChun-Yeow Yeoh int ieee80211_send_action_csa(struct ieee80211_sub_if_data *sdata,
1796c6da674aSChun-Yeow Yeoh 			      struct cfg80211_csa_settings *csa_settings);
179704ecd257SJohannes Berg 
17982475b1ccSMax Stepanov bool ieee80211_cs_valid(const struct ieee80211_cipher_scheme *cs);
17992475b1ccSMax Stepanov bool ieee80211_cs_list_valid(const struct ieee80211_cipher_scheme *cs, int n);
18002475b1ccSMax Stepanov const struct ieee80211_cipher_scheme *
18012475b1ccSMax Stepanov ieee80211_cs_get(struct ieee80211_local *local, u32 cipher,
18022475b1ccSMax Stepanov 		 enum nl80211_iftype iftype);
18032475b1ccSMax Stepanov int ieee80211_cs_headroom(struct ieee80211_local *local,
18042475b1ccSMax Stepanov 			  struct cfg80211_crypto_settings *crypto,
18052475b1ccSMax Stepanov 			  enum nl80211_iftype iftype);
1806057d5f4bSThomas Pedersen void ieee80211_recalc_dtim(struct ieee80211_local *local,
1807057d5f4bSThomas Pedersen 			   struct ieee80211_sub_if_data *sdata);
180873de86a3SLuciano Coelho int ieee80211_check_combinations(struct ieee80211_sub_if_data *sdata,
180973de86a3SLuciano Coelho 				 const struct cfg80211_chan_def *chandef,
181073de86a3SLuciano Coelho 				 enum ieee80211_chanctx_mode chanmode,
181173de86a3SLuciano Coelho 				 u8 radar_detect);
18122475b1ccSMax Stepanov 
1813f4ea83ddSJohannes Berg #ifdef CONFIG_MAC80211_NOINLINE
1814d9e8a70fSJohannes Berg #define debug_noinline noinline
1815d9e8a70fSJohannes Berg #else
1816d9e8a70fSJohannes Berg #define debug_noinline
1817d9e8a70fSJohannes Berg #endif
1818d9e8a70fSJohannes Berg 
1819f0706e82SJiri Benc #endif /* IEEE80211_I_H */
1820