xref: /openbmc/linux/net/mac80211/ieee80211_i.h (revision d43c6b6e)
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;
2358860020eSJohannes Berg 	struct rcu_head rcu_head;
2365dfdaf58SJohannes Berg };
2375dfdaf58SJohannes Berg 
238aa7a0080SEyal Shapira struct probe_resp {
239aa7a0080SEyal Shapira 	struct rcu_head rcu_head;
240aa7a0080SEyal Shapira 	int len;
241aa7a0080SEyal Shapira 	u8 data[0];
242aa7a0080SEyal Shapira };
243aa7a0080SEyal Shapira 
244d012a605SMarco Porsch struct ps_data {
245d012a605SMarco Porsch 	/* yes, this looks ugly, but guarantees that we can later use
246d012a605SMarco Porsch 	 * bitmap_empty :)
247d012a605SMarco Porsch 	 * NB: don't touch this bitmap, use sta_info_{set,clear}_tim_bit */
248d012a605SMarco Porsch 	u8 tim[sizeof(unsigned long) * BITS_TO_LONGS(IEEE80211_MAX_AID + 1)];
249d012a605SMarco Porsch 	struct sk_buff_head bc_buf;
250d012a605SMarco Porsch 	atomic_t num_sta_ps; /* number of stations in PS mode */
251d012a605SMarco Porsch 	int dtim_count;
252d012a605SMarco Porsch 	bool dtim_bc_mc;
253d012a605SMarco Porsch };
254d012a605SMarco Porsch 
255f0706e82SJiri Benc struct ieee80211_if_ap {
25640b275b6SJohannes Berg 	struct beacon_data __rcu *beacon;
257aa7a0080SEyal Shapira 	struct probe_resp __rcu *probe_resp;
258f0706e82SJiri Benc 
25973da7d5bSSimon Wunderlich 	/* to be used after channel switch. */
26073da7d5bSSimon Wunderlich 	struct cfg80211_beacon_data *next_beacon;
2610ec3ca44SJohannes Berg 	struct list_head vlans;
2620ec3ca44SJohannes Berg 
263d012a605SMarco Porsch 	struct ps_data ps;
264030ef8f8SFelix Fietkau 	atomic_t num_mcast_sta; /* number of stations receiving multicast */
265687da132SEmmanuel Grumbach 	enum ieee80211_smps_mode req_smps, /* requested smps mode */
266687da132SEmmanuel Grumbach 			 driver_smps_mode; /* smps mode request */
267687da132SEmmanuel Grumbach 
268687da132SEmmanuel Grumbach 	struct work_struct request_smps_work;
269f0706e82SJiri Benc };
270f0706e82SJiri Benc 
271f0706e82SJiri Benc struct ieee80211_if_wds {
272f0706e82SJiri Benc 	struct sta_info *sta;
273056cdd59SJohannes Berg 	u8 remote_addr[ETH_ALEN];
274f0706e82SJiri Benc };
275f0706e82SJiri Benc 
276f0706e82SJiri Benc struct ieee80211_if_vlan {
2770ec3ca44SJohannes Berg 	struct list_head list;
278f14543eeSFelix Fietkau 
279f14543eeSFelix Fietkau 	/* used for all tx if the VLAN is configured to 4-addr mode */
28040b275b6SJohannes Berg 	struct sta_info __rcu *sta;
281f0706e82SJiri Benc };
282f0706e82SJiri Benc 
283ee385855SLuis Carlos Cobo struct mesh_stats {
284c8a61a7dSDaniel Walker 	__u32 fwded_mcast;		/* Mesh forwarded multicast frames */
285c8a61a7dSDaniel Walker 	__u32 fwded_unicast;		/* Mesh forwarded unicast frames */
286c8a61a7dSDaniel Walker 	__u32 fwded_frames;		/* Mesh total forwarded frames */
287ee385855SLuis Carlos Cobo 	__u32 dropped_frames_ttl;	/* Not transmitted since mesh_ttl == 0*/
288ee385855SLuis Carlos Cobo 	__u32 dropped_frames_no_route;	/* Not transmitted, no route found */
289cfee66b0SJavier Cardona 	__u32 dropped_frames_congestion;/* Not forwarded due to congestion */
290ee385855SLuis Carlos Cobo };
291ee385855SLuis Carlos Cobo 
292ee385855SLuis Carlos Cobo #define PREQ_Q_F_START		0x1
293ee385855SLuis Carlos Cobo #define PREQ_Q_F_REFRESH	0x2
294ee385855SLuis Carlos Cobo struct mesh_preq_queue {
295ee385855SLuis Carlos Cobo 	struct list_head list;
296ee385855SLuis Carlos Cobo 	u8 dst[ETH_ALEN];
297ee385855SLuis Carlos Cobo 	u8 flags;
298ee385855SLuis Carlos Cobo };
299ee385855SLuis Carlos Cobo 
3002eb278e0SJohannes Berg #if HZ/100 == 0
3012eb278e0SJohannes Berg #define IEEE80211_ROC_MIN_LEFT	1
3022eb278e0SJohannes Berg #else
3032eb278e0SJohannes Berg #define IEEE80211_ROC_MIN_LEFT	(HZ/100)
3042eb278e0SJohannes Berg #endif
30577fdaa12SJohannes Berg 
3062eb278e0SJohannes Berg struct ieee80211_roc_work {
30777fdaa12SJohannes Berg 	struct list_head list;
3082eb278e0SJohannes Berg 	struct list_head dependents;
309f679f65dSJohannes Berg 
3102eb278e0SJohannes Berg 	struct delayed_work work;
311af6b6374SJohannes Berg 
312af6b6374SJohannes Berg 	struct ieee80211_sub_if_data *sdata;
313af6b6374SJohannes Berg 
314f679f65dSJohannes Berg 	struct ieee80211_channel *chan;
315af6b6374SJohannes Berg 
3162eb278e0SJohannes Berg 	bool started, abort, hw_begun, notified;
3173fbd45caSJohannes Berg 	bool to_be_freed;
318f679f65dSJohannes Berg 
3192eb278e0SJohannes Berg 	unsigned long hw_start_time;
320e4da8c37SJohannes Berg 
3212eb278e0SJohannes Berg 	u32 duration, req_duration;
322f30221e4SJohannes Berg 	struct sk_buff *frame;
32350febf6aSJohannes Berg 	u64 cookie, mgmt_tx_cookie;
324d339d5caSIlan Peer 	enum ieee80211_roc_type type;
32577fdaa12SJohannes Berg };
32677fdaa12SJohannes Berg 
32746900298SJohannes Berg /* flags used in struct ieee80211_if_managed.flags */
328ab1faeadSJohannes Berg enum ieee80211_sta_flags {
329b291ba11SJohannes Berg 	IEEE80211_STA_CONNECTION_POLL	= BIT(1),
330b291ba11SJohannes Berg 	IEEE80211_STA_CONTROL_PORT	= BIT(2),
331a8243b72SJohannes Berg 	IEEE80211_STA_DISABLE_HT	= BIT(4),
332b291ba11SJohannes Berg 	IEEE80211_STA_CSA_RECEIVED	= BIT(5),
333b291ba11SJohannes Berg 	IEEE80211_STA_MFP_ENABLED	= BIT(6),
334ab13315aSKalle Valo 	IEEE80211_STA_UAPSD_ENABLED	= BIT(7),
335375177bfSVivek Natarajan 	IEEE80211_STA_NULLFUNC_ACKED	= BIT(8),
33617e4ec14SJouni Malinen 	IEEE80211_STA_RESET_SIGNAL_AVE	= BIT(9),
33724398e39SJohannes Berg 	IEEE80211_STA_DISABLE_40MHZ	= BIT(10),
338d545dabaSMahesh Palivela 	IEEE80211_STA_DISABLE_VHT	= BIT(11),
339f2d9d270SJohannes Berg 	IEEE80211_STA_DISABLE_80P80MHZ	= BIT(12),
340f2d9d270SJohannes Berg 	IEEE80211_STA_DISABLE_160MHZ	= BIT(13),
341095d81ceSJohannes Berg 	IEEE80211_STA_DISABLE_WMM	= BIT(14),
342ab1faeadSJohannes Berg };
343ab1faeadSJohannes Berg 
34466e67e41SJohannes Berg struct ieee80211_mgd_auth_data {
34566e67e41SJohannes Berg 	struct cfg80211_bss *bss;
34666e67e41SJohannes Berg 	unsigned long timeout;
34766e67e41SJohannes Berg 	int tries;
34866e67e41SJohannes Berg 	u16 algorithm, expected_transaction;
34966e67e41SJohannes Berg 
35066e67e41SJohannes Berg 	u8 key[WLAN_KEY_LEN_WEP104];
35166e67e41SJohannes Berg 	u8 key_len, key_idx;
35266e67e41SJohannes Berg 	bool done;
35389afe614SJohannes Berg 	bool timeout_started;
35466e67e41SJohannes Berg 
3556b8ece3aSJouni Malinen 	u16 sae_trans, sae_status;
3566b8ece3aSJouni Malinen 	size_t data_len;
3576b8ece3aSJouni Malinen 	u8 data[];
35866e67e41SJohannes Berg };
35966e67e41SJohannes Berg 
36066e67e41SJohannes Berg struct ieee80211_mgd_assoc_data {
36166e67e41SJohannes Berg 	struct cfg80211_bss *bss;
36266e67e41SJohannes Berg 	const u8 *supp_rates;
36366e67e41SJohannes Berg 
36466e67e41SJohannes Berg 	unsigned long timeout;
36566e67e41SJohannes Berg 	int tries;
36666e67e41SJohannes Berg 
36766e67e41SJohannes Berg 	u16 capability;
36866e67e41SJohannes Berg 	u8 prev_bssid[ETH_ALEN];
36966e67e41SJohannes Berg 	u8 ssid[IEEE80211_MAX_SSID_LEN];
37066e67e41SJohannes Berg 	u8 ssid_len;
37166e67e41SJohannes Berg 	u8 supp_rates_len;
37276f0303dSJohannes Berg 	bool wmm, uapsd;
373989c6505SAlexander Bondar 	bool need_beacon;
37466e67e41SJohannes Berg 	bool synced;
37589afe614SJohannes Berg 	bool timeout_started;
37666e67e41SJohannes Berg 
3779dde6423SJohannes Berg 	u8 ap_ht_param;
3789dde6423SJohannes Berg 
379b08fbbd8SJohannes Berg 	struct ieee80211_vht_cap ap_vht_cap;
380b08fbbd8SJohannes Berg 
38166e67e41SJohannes Berg 	size_t ie_len;
38266e67e41SJohannes Berg 	u8 ie[];
38366e67e41SJohannes Berg };
38466e67e41SJohannes Berg 
38546900298SJohannes Berg struct ieee80211_if_managed {
386056cdd59SJohannes Berg 	struct timer_list timer;
387b291ba11SJohannes Berg 	struct timer_list conn_mon_timer;
388b291ba11SJohannes Berg 	struct timer_list bcn_mon_timer;
389c481ec97SSujith 	struct timer_list chswitch_timer;
390b291ba11SJohannes Berg 	struct work_struct monitor_work;
391c481ec97SSujith 	struct work_struct chswitch_work;
3921e4dcd01SJuuso Oikarinen 	struct work_struct beacon_connection_loss_work;
393882a7c69SJohannes Berg 	struct work_struct csa_connection_drop_work;
39446900298SJohannes Berg 
3957ccc8bd7SFelix Fietkau 	unsigned long beacon_timeout;
396b291ba11SJohannes Berg 	unsigned long probe_timeout;
397a43abf29SMaxim Levitsky 	int probe_send_count;
39804ac3c0eSFelix Fietkau 	bool nullfunc_failed;
399682bd38bSJohannes Berg 	bool connection_loss;
400b291ba11SJohannes Berg 
4010c1ad2caSJohannes Berg 	struct cfg80211_bss *associated;
40266e67e41SJohannes Berg 	struct ieee80211_mgd_auth_data *auth_data;
40366e67e41SJohannes Berg 	struct ieee80211_mgd_assoc_data *assoc_data;
40446900298SJohannes Berg 
40577fdaa12SJohannes Berg 	u8 bssid[ETH_ALEN];
40646900298SJohannes Berg 
407f0706e82SJiri Benc 	u16 aid;
408f0706e82SJiri Benc 
409965bedadSJohannes Berg 	bool powersave; /* powersave requested for this iface */
41005cb9108SJohannes Berg 	bool broken_ap; /* AP is broken -- turn off powersave */
411989c6505SAlexander Bondar 	bool have_beacon;
412826262c3SJohannes Berg 	u8 dtim_period;
4130f78231bSJohannes Berg 	enum ieee80211_smps_mode req_smps, /* requested smps mode */
414d1f5b7a3SJohannes Berg 				 driver_smps_mode; /* smps mode request */
415d1f5b7a3SJohannes Berg 
416d1f5b7a3SJohannes Berg 	struct work_struct request_smps_work;
417965bedadSJohannes Berg 
418d6f2da5bSJiri Slaby 	unsigned int flags;
419f0706e82SJiri Benc 
420d8ec4433SJuuso Oikarinen 	bool beacon_crc_valid;
421d91f36dbSJohannes Berg 	u32 beacon_crc;
422d91f36dbSJohannes Berg 
4231672c0e3SJohannes Berg 	bool status_acked;
4241672c0e3SJohannes Berg 	bool status_received;
4251672c0e3SJohannes Berg 	__le16 status_fc;
4261672c0e3SJohannes Berg 
427fdfacf0aSJouni Malinen 	enum {
428fdfacf0aSJouni Malinen 		IEEE80211_MFP_DISABLED,
429fdfacf0aSJouni Malinen 		IEEE80211_MFP_OPTIONAL,
430fdfacf0aSJouni Malinen 		IEEE80211_MFP_REQUIRED
431fdfacf0aSJouni Malinen 	} mfp; /* management frame protection */
432fdfacf0aSJouni Malinen 
433dc41e4d4SEliad Peller 	/*
434dc41e4d4SEliad Peller 	 * Bitmask of enabled u-apsd queues,
435dc41e4d4SEliad Peller 	 * IEEE80211_WMM_IE_STA_QOSINFO_AC_BE & co. Needs a new association
436dc41e4d4SEliad Peller 	 * to take effect.
437dc41e4d4SEliad Peller 	 */
438dc41e4d4SEliad Peller 	unsigned int uapsd_queues;
439dc41e4d4SEliad Peller 
440dc41e4d4SEliad Peller 	/*
441dc41e4d4SEliad Peller 	 * Maximum number of buffered frames AP can deliver during a
442dc41e4d4SEliad Peller 	 * service period, IEEE80211_WMM_IE_STA_QOSINFO_SP_ALL or similar.
443dc41e4d4SEliad Peller 	 * Needs a new association to take effect.
444dc41e4d4SEliad Peller 	 */
445dc41e4d4SEliad Peller 	unsigned int uapsd_max_sp_len;
446dc41e4d4SEliad Peller 
447f0706e82SJiri Benc 	int wmm_last_param_set;
4489bc383deSJohannes Berg 
4499bc383deSJohannes Berg 	u8 use_4addr;
45017e4ec14SJouni Malinen 
45167baf663SJanusz Dziedzic 	s16 p2p_noa_index;
452488dd7b5SJohannes Berg 
45317e4ec14SJouni Malinen 	/* Signal strength from the last Beacon frame in the current BSS. */
45417e4ec14SJouni Malinen 	int last_beacon_signal;
45517e4ec14SJouni Malinen 
45617e4ec14SJouni Malinen 	/*
45717e4ec14SJouni Malinen 	 * Weighted average of the signal strength from Beacon frames in the
45817e4ec14SJouni Malinen 	 * current BSS. This is in units of 1/16 of the signal unit to maintain
45917e4ec14SJouni Malinen 	 * accuracy and to speed up calculations, i.e., the value need to be
46017e4ec14SJouni Malinen 	 * divided by 16 to get the actual value.
46117e4ec14SJouni Malinen 	 */
46217e4ec14SJouni Malinen 	int ave_beacon_signal;
46317e4ec14SJouni Malinen 
46417e4ec14SJouni Malinen 	/*
465391a200aSJouni Malinen 	 * Number of Beacon frames used in ave_beacon_signal. This can be used
466391a200aSJouni Malinen 	 * to avoid generating less reliable cqm events that would be based
467391a200aSJouni Malinen 	 * only on couple of received frames.
468391a200aSJouni Malinen 	 */
469391a200aSJouni Malinen 	unsigned int count_beacon_signal;
470391a200aSJouni Malinen 
471391a200aSJouni Malinen 	/*
47217e4ec14SJouni Malinen 	 * Last Beacon frame signal strength average (ave_beacon_signal / 16)
47317e4ec14SJouni Malinen 	 * that triggered a cqm event. 0 indicates that no event has been
47417e4ec14SJouni Malinen 	 * generated for the current association.
47517e4ec14SJouni Malinen 	 */
47617e4ec14SJouni Malinen 	int last_cqm_event_signal;
477615f7b9bSMeenakshi Venkataraman 
478615f7b9bSMeenakshi Venkataraman 	/*
479615f7b9bSMeenakshi Venkataraman 	 * State variables for keeping track of RSSI of the AP currently
480615f7b9bSMeenakshi Venkataraman 	 * connected to and informing driver when RSSI has gone
481615f7b9bSMeenakshi Venkataraman 	 * below/above a certain threshold.
482615f7b9bSMeenakshi Venkataraman 	 */
483615f7b9bSMeenakshi Venkataraman 	int rssi_min_thold, rssi_max_thold;
484615f7b9bSMeenakshi Venkataraman 	int last_ave_beacon_signal;
485ef96a842SBen Greear 
486ef96a842SBen Greear 	struct ieee80211_ht_cap ht_capa; /* configured ht-cap over-rides */
487ef96a842SBen Greear 	struct ieee80211_ht_cap ht_capa_mask; /* Valid parts of ht_capa */
488dd5ecfeaSJohannes Berg 	struct ieee80211_vht_cap vht_capa; /* configured VHT overrides */
489dd5ecfeaSJohannes Berg 	struct ieee80211_vht_cap vht_capa_mask; /* Valid parts of vht_capa */
490f0706e82SJiri Benc };
491f0706e82SJiri Benc 
49246900298SJohannes Berg struct ieee80211_if_ibss {
49346900298SJohannes Berg 	struct timer_list timer;
494cd7760e6SSimon Wunderlich 	struct work_struct csa_connection_drop_work;
49546900298SJohannes Berg 
496af8cdcd8SJohannes Berg 	unsigned long last_scan_completed;
4975bb644a0SJohannes Berg 
498fbd2c8dcSTeemu Paasikivi 	u32 basic_rates;
499fbd2c8dcSTeemu Paasikivi 
500af8cdcd8SJohannes Berg 	bool fixed_bssid;
501af8cdcd8SJohannes Berg 	bool fixed_channel;
502fffd0934SJohannes Berg 	bool privacy;
50346900298SJohannes Berg 
504267335d6SAntonio Quartulli 	bool control_port;
5058e8d347dSSimon Wunderlich 	bool userspace_handles_dfs;
506267335d6SAntonio Quartulli 
5074d196e4bSFelix Fietkau 	u8 bssid[ETH_ALEN] __aligned(2);
508af8cdcd8SJohannes Berg 	u8 ssid[IEEE80211_MAX_SSID_LEN];
509af8cdcd8SJohannes Berg 	u8 ssid_len, ie_len;
510af8cdcd8SJohannes Berg 	u8 *ie;
5113aede78aSSimon Wunderlich 	struct cfg80211_chan_def chandef;
51246900298SJohannes Berg 
51346900298SJohannes Berg 	unsigned long ibss_join_req;
514af8cdcd8SJohannes Berg 	/* probe response/beacon for IBSS */
515c3ffeab4SJohannes Berg 	struct beacon_data __rcu *presp;
51646900298SJohannes Berg 
517822854b0SSimon Wunderlich 	struct ieee80211_ht_cap ht_capa; /* configured ht-cap over-rides */
518822854b0SSimon Wunderlich 	struct ieee80211_ht_cap ht_capa_mask; /* Valid parts of ht_capa */
519822854b0SSimon Wunderlich 
5208bf11d8dSJohannes Berg 	spinlock_t incomplete_lock;
5218bf11d8dSJohannes Berg 	struct list_head incomplete_stations;
5228bf11d8dSJohannes Berg 
52346900298SJohannes Berg 	enum {
52446900298SJohannes Berg 		IEEE80211_IBSS_MLME_SEARCH,
52546900298SJohannes Berg 		IEEE80211_IBSS_MLME_JOINED,
52646900298SJohannes Berg 	} state;
52746900298SJohannes Berg };
52846900298SJohannes Berg 
529dbf498fbSJavier Cardona /**
530dbf498fbSJavier Cardona  * struct ieee80211_mesh_sync_ops - Extensible synchronization framework interface
531dbf498fbSJavier Cardona  *
532dbf498fbSJavier Cardona  * these declarations define the interface, which enables
533dbf498fbSJavier Cardona  * vendor-specific mesh synchronization
534dbf498fbSJavier Cardona  *
535dbf498fbSJavier Cardona  */
536dbf498fbSJavier Cardona struct ieee802_11_elems;
537dbf498fbSJavier Cardona struct ieee80211_mesh_sync_ops {
538dbf498fbSJavier Cardona 	void (*rx_bcn_presp)(struct ieee80211_sub_if_data *sdata,
539dbf498fbSJavier Cardona 			     u16 stype,
540dbf498fbSJavier Cardona 			     struct ieee80211_mgmt *mgmt,
541dbf498fbSJavier Cardona 			     struct ieee802_11_elems *elems,
542dbf498fbSJavier Cardona 			     struct ieee80211_rx_status *rx_status);
543dbf498fbSJavier Cardona 	void (*adjust_tbtt)(struct ieee80211_sub_if_data *sdata);
544dbf498fbSJavier Cardona 	/* add other framework functions here */
545dbf498fbSJavier Cardona };
546dbf498fbSJavier Cardona 
547b8456a14SChun-Yeow Yeoh struct mesh_csa_settings {
548b8456a14SChun-Yeow Yeoh 	struct rcu_head rcu_head;
549b8456a14SChun-Yeow Yeoh 	struct cfg80211_csa_settings settings;
550b8456a14SChun-Yeow Yeoh };
551b8456a14SChun-Yeow Yeoh 
552472dbc45SJohannes Berg struct ieee80211_if_mesh {
553472dbc45SJohannes Berg 	struct timer_list housekeeping_timer;
554472dbc45SJohannes Berg 	struct timer_list mesh_path_timer;
555e304bfd3SRui Paulo 	struct timer_list mesh_path_root_timer;
556472dbc45SJohannes Berg 
55718889231SJavier Cardona 	unsigned long wrkq_flags;
558f81a9dedSThomas Pedersen 	unsigned long mbss_changed;
559472dbc45SJohannes Berg 
560472dbc45SJohannes Berg 	u8 mesh_id[IEEE80211_MAX_MESH_ID_LEN];
561472dbc45SJohannes Berg 	size_t mesh_id_len;
562472dbc45SJohannes Berg 	/* Active Path Selection Protocol Identifier */
5633491707aSRui Paulo 	u8 mesh_pp_id;
564472dbc45SJohannes Berg 	/* Active Path Selection Metric Identifier */
5653491707aSRui Paulo 	u8 mesh_pm_id;
566472dbc45SJohannes Berg 	/* Congestion Control Mode Identifier */
5673491707aSRui Paulo 	u8 mesh_cc_id;
5689e03fdfdSJavier Cardona 	/* Synchronization Protocol Identifier */
5693491707aSRui Paulo 	u8 mesh_sp_id;
5709e03fdfdSJavier Cardona 	/* Authentication Protocol Identifier */
5713491707aSRui Paulo 	u8 mesh_auth_id;
572d19b3bf6SRui Paulo 	/* Local mesh Sequence Number */
573d19b3bf6SRui Paulo 	u32 sn;
574472dbc45SJohannes Berg 	/* Last used PREQ ID */
575472dbc45SJohannes Berg 	u32 preq_id;
576472dbc45SJohannes Berg 	atomic_t mpaths;
577d19b3bf6SRui Paulo 	/* Timestamp of last SN update */
578d19b3bf6SRui Paulo 	unsigned long last_sn_update;
579dca7e943SThomas Pedersen 	/* Time when it's ok to send next PERR */
580dca7e943SThomas Pedersen 	unsigned long next_perr;
581dca7e943SThomas Pedersen 	/* Timestamp of last PREQ sent */
582472dbc45SJohannes Berg 	unsigned long last_preq;
583472dbc45SJohannes Berg 	struct mesh_rmc *rmc;
584472dbc45SJohannes Berg 	spinlock_t mesh_preq_queue_lock;
585472dbc45SJohannes Berg 	struct mesh_preq_queue preq_queue;
586472dbc45SJohannes Berg 	int preq_queue_len;
587472dbc45SJohannes Berg 	struct mesh_stats mshstats;
588472dbc45SJohannes Berg 	struct mesh_config mshcfg;
5891258d976SAshok Nagarajan 	atomic_t estab_plinks;
590472dbc45SJohannes Berg 	u32 mesh_seqnum;
591472dbc45SJohannes Berg 	bool accepting_plinks;
5925ee68e5bSJavier Cardona 	int num_gates;
5932b5e1967SThomas Pedersen 	struct beacon_data __rcu *beacon;
594581a8b0fSJavier Cardona 	const u8 *ie;
595581a8b0fSJavier Cardona 	u8 ie_len;
596b130e5ceSJavier Cardona 	enum {
597b130e5ceSJavier Cardona 		IEEE80211_MESH_SEC_NONE = 0x0,
598b130e5ceSJavier Cardona 		IEEE80211_MESH_SEC_AUTHED = 0x1,
599b130e5ceSJavier Cardona 		IEEE80211_MESH_SEC_SECURED = 0x2,
600b130e5ceSJavier Cardona 	} security;
601a6dad6a2SThomas Pedersen 	bool user_mpm;
602dbf498fbSJavier Cardona 	/* Extensible Synchronization Framework */
6038ba7acf3SJohannes Berg 	const struct ieee80211_mesh_sync_ops *sync_ops;
604dbf498fbSJavier Cardona 	s64 sync_offset_clockdrift_max;
605dbf498fbSJavier Cardona 	spinlock_t sync_offset_lock;
606dbf498fbSJavier Cardona 	bool adjusting_tbtt;
6073f52b7e3SMarco Porsch 	/* mesh power save */
6083f52b7e3SMarco Porsch 	enum nl80211_mesh_power_mode nonpeer_pm;
6093f52b7e3SMarco Porsch 	int ps_peers_light_sleep;
6103f52b7e3SMarco Porsch 	int ps_peers_deep_sleep;
6113f52b7e3SMarco Porsch 	struct ps_data ps;
6128f2535b9SChun-Yeow Yeoh 	/* Channel Switching Support */
613b8456a14SChun-Yeow Yeoh 	struct mesh_csa_settings __rcu *csa;
6148f2535b9SChun-Yeow Yeoh 	bool chsw_init;
615b8456a14SChun-Yeow Yeoh 	u8 chsw_ttl;
6168f2535b9SChun-Yeow Yeoh 	u16 pre_value;
617472dbc45SJohannes Berg };
618902acc78SJohannes Berg 
619902acc78SJohannes Berg #ifdef CONFIG_MAC80211_MESH
620472dbc45SJohannes Berg #define IEEE80211_IFSTA_MESH_CTR_INC(msh, name)	\
621472dbc45SJohannes Berg 	do { (msh)->mshstats.name++; } while (0)
622902acc78SJohannes Berg #else
623472dbc45SJohannes Berg #define IEEE80211_IFSTA_MESH_CTR_INC(msh, name) \
624902acc78SJohannes Berg 	do { } while (0)
625902acc78SJohannes Berg #endif
626f0706e82SJiri Benc 
627213cd118SJohannes Berg /**
628213cd118SJohannes Berg  * enum ieee80211_sub_if_data_flags - virtual interface flags
629213cd118SJohannes Berg  *
630213cd118SJohannes Berg  * @IEEE80211_SDATA_ALLMULTI: interface wants all multicast packets
631213cd118SJohannes Berg  * @IEEE80211_SDATA_PROMISC: interface is promisc
632213cd118SJohannes Berg  * @IEEE80211_SDATA_OPERATING_GMODE: operating in G-only mode
633213cd118SJohannes Berg  * @IEEE80211_SDATA_DONT_BRIDGE_PACKETS: bridge packets between
634213cd118SJohannes Berg  *	associated stations and deliver multicast frames both
635213cd118SJohannes Berg  *	back to wireless media and to the local net stack.
63695acac61SJohannes Berg  * @IEEE80211_SDATA_DISCONNECT_RESUME: Disconnect after resume.
6377b7eab6fSJohannes Berg  * @IEEE80211_SDATA_IN_DRIVER: indicates interface was added to driver
638213cd118SJohannes Berg  */
639213cd118SJohannes Berg enum ieee80211_sub_if_data_flags {
640213cd118SJohannes Berg 	IEEE80211_SDATA_ALLMULTI		= BIT(0),
641213cd118SJohannes Berg 	IEEE80211_SDATA_PROMISC			= BIT(1),
6427986cf95SJohannes Berg 	IEEE80211_SDATA_OPERATING_GMODE		= BIT(2),
6437986cf95SJohannes Berg 	IEEE80211_SDATA_DONT_BRIDGE_PACKETS	= BIT(3),
64495acac61SJohannes Berg 	IEEE80211_SDATA_DISCONNECT_RESUME	= BIT(4),
6457b7eab6fSJohannes Berg 	IEEE80211_SDATA_IN_DRIVER		= BIT(5),
646213cd118SJohannes Berg };
647213cd118SJohannes Berg 
64834d4bc4dSJohannes Berg /**
64934d4bc4dSJohannes Berg  * enum ieee80211_sdata_state_bits - virtual interface state bits
65034d4bc4dSJohannes Berg  * @SDATA_STATE_RUNNING: virtual interface is up & running; this
65134d4bc4dSJohannes Berg  *	mirrors netif_running() but is separate for interface type
65234d4bc4dSJohannes Berg  *	change handling while the interface is up
6535b714c6aSJohannes Berg  * @SDATA_STATE_OFFCHANNEL: This interface is currently in offchannel
6545b714c6aSJohannes Berg  *	mode, so queues are stopped
655d6a83228SJohannes Berg  * @SDATA_STATE_OFFCHANNEL_BEACON_STOPPED: Beaconing was stopped due
656d6a83228SJohannes Berg  *	to offchannel, reset when offchannel returns
65734d4bc4dSJohannes Berg  */
65834d4bc4dSJohannes Berg enum ieee80211_sdata_state_bits {
65934d4bc4dSJohannes Berg 	SDATA_STATE_RUNNING,
6605b714c6aSJohannes Berg 	SDATA_STATE_OFFCHANNEL,
661d6a83228SJohannes Berg 	SDATA_STATE_OFFCHANNEL_BEACON_STOPPED,
66234d4bc4dSJohannes Berg };
66334d4bc4dSJohannes Berg 
664d01a1e65SMichal Kazior /**
665d01a1e65SMichal Kazior  * enum ieee80211_chanctx_mode - channel context configuration mode
666d01a1e65SMichal Kazior  *
667d01a1e65SMichal Kazior  * @IEEE80211_CHANCTX_SHARED: channel context may be used by
668d01a1e65SMichal Kazior  *	multiple interfaces
669d01a1e65SMichal Kazior  * @IEEE80211_CHANCTX_EXCLUSIVE: channel context can be used
670d01a1e65SMichal Kazior  *	only by a single interface. This can be used for example for
671d01a1e65SMichal Kazior  *	non-fixed channel IBSS.
672d01a1e65SMichal Kazior  */
673d01a1e65SMichal Kazior enum ieee80211_chanctx_mode {
674d01a1e65SMichal Kazior 	IEEE80211_CHANCTX_SHARED,
675d01a1e65SMichal Kazior 	IEEE80211_CHANCTX_EXCLUSIVE
676d01a1e65SMichal Kazior };
677d01a1e65SMichal Kazior 
678d01a1e65SMichal Kazior struct ieee80211_chanctx {
679d01a1e65SMichal Kazior 	struct list_head list;
680d01a1e65SMichal Kazior 	struct rcu_head rcu_head;
681d01a1e65SMichal Kazior 
682d01a1e65SMichal Kazior 	enum ieee80211_chanctx_mode mode;
683d01a1e65SMichal Kazior 	int refcount;
6848a61af65SJohannes Berg 	bool driver_present;
685d01a1e65SMichal Kazior 
686d01a1e65SMichal Kazior 	struct ieee80211_chanctx_conf conf;
687d01a1e65SMichal Kazior };
688d01a1e65SMichal Kazior 
689f0706e82SJiri Benc struct ieee80211_sub_if_data {
690f0706e82SJiri Benc 	struct list_head list;
691f0706e82SJiri Benc 
692f0706e82SJiri Benc 	struct wireless_dev wdev;
693f0706e82SJiri Benc 
69411a843b7SJohannes Berg 	/* keys */
69511a843b7SJohannes Berg 	struct list_head key_list;
69611a843b7SJohannes Berg 
6973bff1865SYogesh Ashok Powar 	/* count for keys needing tailroom space allocation */
6983bff1865SYogesh Ashok Powar 	int crypto_tx_tailroom_needed_cnt;
6998d1f7ecdSJohannes Berg 	int crypto_tx_tailroom_pending_dec;
7008d1f7ecdSJohannes Berg 	struct delayed_work dec_tailroom_needed_wk;
7013bff1865SYogesh Ashok Powar 
702f0706e82SJiri Benc 	struct net_device *dev;
703f0706e82SJiri Benc 	struct ieee80211_local *local;
704f0706e82SJiri Benc 
70513262ffdSJiri Slaby 	unsigned int flags;
7067e9ed188SDaniel Drake 
70734d4bc4dSJohannes Berg 	unsigned long state;
70834d4bc4dSJohannes Berg 
709f0706e82SJiri Benc 	int drop_unencrypted;
710f0706e82SJiri Benc 
71147846c9bSJohannes Berg 	char name[IFNAMSIZ];
71247846c9bSJohannes Berg 
713f0706e82SJiri Benc 	/* Fragment table for host-based reassembly */
714f0706e82SJiri Benc 	struct ieee80211_fragment_entry	fragments[IEEE80211_FRAGMENT_MAX];
715f0706e82SJiri Benc 	unsigned int fragment_next;
716f0706e82SJiri Benc 
717b53be792SSimon Wunderlich 	/* TID bitmap for NoAck policy */
718b53be792SSimon Wunderlich 	u16 noack_map;
719b53be792SSimon Wunderlich 
72000e96decSYoni Divinsky 	/* bit field of ACM bits (BIT(802.1D tag)) */
72100e96decSYoni Divinsky 	u8 wmm_acm;
72200e96decSYoni Divinsky 
72340b275b6SJohannes Berg 	struct ieee80211_key __rcu *keys[NUM_DEFAULT_KEYS + NUM_DEFAULT_MGMT_KEYS];
72440b275b6SJohannes Berg 	struct ieee80211_key __rcu *default_unicast_key;
72540b275b6SJohannes Berg 	struct ieee80211_key __rcu *default_multicast_key;
72640b275b6SJohannes Berg 	struct ieee80211_key __rcu *default_mgmt_key;
727f0706e82SJiri Benc 
72894778280SJohannes Berg 	u16 sequence_number;
729a621fa4dSJohannes Berg 	__be16 control_port_protocol;
730a621fa4dSJohannes Berg 	bool control_port_no_encrypt;
7312475b1ccSMax Stepanov 	int encrypt_headroom;
73294778280SJohannes Berg 
73354bcbc69SJohannes Berg 	struct ieee80211_tx_queue_params tx_conf[IEEE80211_NUM_ACS];
734f6f3def3SEliad Peller 
73573da7d5bSSimon Wunderlich 	struct work_struct csa_finalize_work;
73673da7d5bSSimon Wunderlich 	int csa_counter_offset_beacon;
73773da7d5bSSimon Wunderlich 	int csa_counter_offset_presp;
73873da7d5bSSimon Wunderlich 	bool csa_radar_required;
73933787fc4SLuciano Coelho 	struct cfg80211_chan_def csa_chandef;
74073da7d5bSSimon Wunderlich 
74104ecd257SJohannes Berg 	/* used to reconfigure hardware SM PS */
74204ecd257SJohannes Berg 	struct work_struct recalc_smps;
74304ecd257SJohannes Berg 
74464592c8fSJohannes Berg 	struct work_struct work;
74535f20c14SJohannes Berg 	struct sk_buff_head skb_queue;
74635f20c14SJohannes Berg 
74704ecd257SJohannes Berg 	u8 needed_rx_chains;
74804ecd257SJohannes Berg 	enum ieee80211_smps_mode smps_mode;
74904ecd257SJohannes Berg 
7501ea6f9c0SJohannes Berg 	int user_power_level; /* in dBm */
7511ea6f9c0SJohannes Berg 	int ap_power_level; /* in dBm */
7521ea6f9c0SJohannes Berg 
753164eb02dSSimon Wunderlich 	bool radar_required;
754164eb02dSSimon Wunderlich 	struct delayed_work dfs_cac_timer_work;
755164eb02dSSimon Wunderlich 
7563e122be0SJohannes Berg 	/*
7573e122be0SJohannes Berg 	 * AP this belongs to: self in AP mode and
7583e122be0SJohannes Berg 	 * corresponding AP in VLAN mode, NULL for
7593e122be0SJohannes Berg 	 * all others (might be needed later in IBSS)
7603e122be0SJohannes Berg 	 */
7613e122be0SJohannes Berg 	struct ieee80211_if_ap *bss;
7623e122be0SJohannes Berg 
76337eb0b16SJouni Malinen 	/* bitmap of allowed (non-MCS) rate indexes for rate control */
76437eb0b16SJouni Malinen 	u32 rc_rateidx_mask[IEEE80211_NUM_BANDS];
7652ffbe6d3SFelix Fietkau 
7662ffbe6d3SFelix Fietkau 	bool rc_has_mcs_mask[IEEE80211_NUM_BANDS];
76719468413SSimon Wunderlich 	u8  rc_rateidx_mcs_mask[IEEE80211_NUM_BANDS][IEEE80211_HT_MCS_MASK_LEN];
768f0706e82SJiri Benc 
769f0706e82SJiri Benc 	union {
770f0706e82SJiri Benc 		struct ieee80211_if_ap ap;
771f0706e82SJiri Benc 		struct ieee80211_if_wds wds;
772f0706e82SJiri Benc 		struct ieee80211_if_vlan vlan;
77346900298SJohannes Berg 		struct ieee80211_if_managed mgd;
77446900298SJohannes Berg 		struct ieee80211_if_ibss ibss;
775472dbc45SJohannes Berg 		struct ieee80211_if_mesh mesh;
7768cc9a739SMichael Wu 		u32 mntr_flags;
777f0706e82SJiri Benc 	} u;
778e9f207f0SJiri Benc 
779e9f207f0SJiri Benc #ifdef CONFIG_MAC80211_DEBUGFS
780e9f207f0SJiri Benc 	struct {
781295bafb4SBen Greear 		struct dentry *subdir_stations;
782f7e0104cSJohannes Berg 		struct dentry *default_unicast_key;
783f7e0104cSJohannes Berg 		struct dentry *default_multicast_key;
7843cfcf6acSJouni Malinen 		struct dentry *default_mgmt_key;
7857bcfaf2fSJohannes Berg 	} debugfs;
786e9f207f0SJiri Benc #endif
787529ba6e9SJohannes Berg 
78832bfd35dSJohannes Berg 	/* must be last, dynamically sized area in this! */
78932bfd35dSJohannes Berg 	struct ieee80211_vif vif;
790f0706e82SJiri Benc };
791f0706e82SJiri Benc 
79232bfd35dSJohannes Berg static inline
79332bfd35dSJohannes Berg struct ieee80211_sub_if_data *vif_to_sdata(struct ieee80211_vif *p)
79432bfd35dSJohannes Berg {
79532bfd35dSJohannes Berg 	return container_of(p, struct ieee80211_sub_if_data, vif);
79632bfd35dSJohannes Berg }
79732bfd35dSJohannes Berg 
7988d61ffa5SJohannes Berg static inline void sdata_lock(struct ieee80211_sub_if_data *sdata)
7998d61ffa5SJohannes Berg 	__acquires(&sdata->wdev.mtx)
8008d61ffa5SJohannes Berg {
8018d61ffa5SJohannes Berg 	mutex_lock(&sdata->wdev.mtx);
8028d61ffa5SJohannes Berg 	__acquire(&sdata->wdev.mtx);
8038d61ffa5SJohannes Berg }
8048d61ffa5SJohannes Berg 
8058d61ffa5SJohannes Berg static inline void sdata_unlock(struct ieee80211_sub_if_data *sdata)
8068d61ffa5SJohannes Berg 	__releases(&sdata->wdev.mtx)
8078d61ffa5SJohannes Berg {
8088d61ffa5SJohannes Berg 	mutex_unlock(&sdata->wdev.mtx);
8098d61ffa5SJohannes Berg 	__release(&sdata->wdev.mtx);
8108d61ffa5SJohannes Berg }
8118d61ffa5SJohannes Berg 
8127ca133bcSSimon Wunderlich #define sdata_dereference(p, sdata) \
8137ca133bcSSimon Wunderlich 	rcu_dereference_protected(p, lockdep_is_held(&sdata->wdev.mtx))
8147ca133bcSSimon Wunderlich 
8158d61ffa5SJohannes Berg static inline void
8168d61ffa5SJohannes Berg sdata_assert_lock(struct ieee80211_sub_if_data *sdata)
8178d61ffa5SJohannes Berg {
8188d61ffa5SJohannes Berg 	lockdep_assert_held(&sdata->wdev.mtx);
8198d61ffa5SJohannes Berg }
8208d61ffa5SJohannes Berg 
82155de908aSJohannes Berg static inline enum ieee80211_band
82255de908aSJohannes Berg ieee80211_get_sdata_band(struct ieee80211_sub_if_data *sdata)
82355de908aSJohannes Berg {
82455de908aSJohannes Berg 	enum ieee80211_band band = IEEE80211_BAND_2GHZ;
82555de908aSJohannes Berg 	struct ieee80211_chanctx_conf *chanctx_conf;
82655de908aSJohannes Berg 
82755de908aSJohannes Berg 	rcu_read_lock();
82855de908aSJohannes Berg 	chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
82955de908aSJohannes Berg 	if (!WARN_ON(!chanctx_conf))
8304bf88530SJohannes Berg 		band = chanctx_conf->def.chan->band;
83155de908aSJohannes Berg 	rcu_read_unlock();
83255de908aSJohannes Berg 
83355de908aSJohannes Berg 	return band;
83455de908aSJohannes Berg }
83555de908aSJohannes Berg 
836438b61b7SSimon Wunderlich static inline int
837438b61b7SSimon Wunderlich ieee80211_chandef_get_shift(struct cfg80211_chan_def *chandef)
838438b61b7SSimon Wunderlich {
839438b61b7SSimon Wunderlich 	switch (chandef->width) {
840438b61b7SSimon Wunderlich 	case NL80211_CHAN_WIDTH_5:
841438b61b7SSimon Wunderlich 		return 2;
842438b61b7SSimon Wunderlich 	case NL80211_CHAN_WIDTH_10:
843438b61b7SSimon Wunderlich 		return 1;
844438b61b7SSimon Wunderlich 	default:
845438b61b7SSimon Wunderlich 		return 0;
846438b61b7SSimon Wunderlich 	}
847438b61b7SSimon Wunderlich }
848438b61b7SSimon Wunderlich 
849438b61b7SSimon Wunderlich static inline int
850438b61b7SSimon Wunderlich ieee80211_vif_get_shift(struct ieee80211_vif *vif)
851438b61b7SSimon Wunderlich {
852438b61b7SSimon Wunderlich 	struct ieee80211_chanctx_conf *chanctx_conf;
853438b61b7SSimon Wunderlich 	int shift = 0;
854438b61b7SSimon Wunderlich 
855438b61b7SSimon Wunderlich 	rcu_read_lock();
856438b61b7SSimon Wunderlich 	chanctx_conf = rcu_dereference(vif->chanctx_conf);
857438b61b7SSimon Wunderlich 	if (chanctx_conf)
858438b61b7SSimon Wunderlich 		shift = ieee80211_chandef_get_shift(&chanctx_conf->def);
859438b61b7SSimon Wunderlich 	rcu_read_unlock();
860438b61b7SSimon Wunderlich 
861438b61b7SSimon Wunderlich 	return shift;
862438b61b7SSimon Wunderlich }
863438b61b7SSimon Wunderlich 
864c1475ca9SJohannes Berg enum sdata_queue_type {
865c1475ca9SJohannes Berg 	IEEE80211_SDATA_QUEUE_TYPE_FRAME	= 0,
866c1475ca9SJohannes Berg 	IEEE80211_SDATA_QUEUE_AGG_START		= 1,
867c1475ca9SJohannes Berg 	IEEE80211_SDATA_QUEUE_AGG_STOP		= 2,
868c1475ca9SJohannes Berg };
869c1475ca9SJohannes Berg 
870f0706e82SJiri Benc enum {
871f0706e82SJiri Benc 	IEEE80211_RX_MSG	= 1,
872f0706e82SJiri Benc 	IEEE80211_TX_STATUS_MSG	= 2,
873f0706e82SJiri Benc };
874f0706e82SJiri Benc 
875ce7c9111SKalle Valo enum queue_stop_reason {
876ce7c9111SKalle Valo 	IEEE80211_QUEUE_STOP_REASON_DRIVER,
877520eb820SKalle Valo 	IEEE80211_QUEUE_STOP_REASON_PS,
87896f5e66eSJohannes Berg 	IEEE80211_QUEUE_STOP_REASON_CSA,
87996f5e66eSJohannes Berg 	IEEE80211_QUEUE_STOP_REASON_AGGREGATION,
88025420604SJohannes Berg 	IEEE80211_QUEUE_STOP_REASON_SUSPEND,
8818f77f384SJohannes Berg 	IEEE80211_QUEUE_STOP_REASON_SKB_ADD,
8826c17b77bSSeth Forshee 	IEEE80211_QUEUE_STOP_REASON_OFFCHANNEL,
883445ea4e8SJohannes Berg 	IEEE80211_QUEUE_STOP_REASON_FLUSH,
884ce7c9111SKalle Valo };
885ce7c9111SKalle Valo 
88665a6538aSLuciano Coelho #ifdef CONFIG_MAC80211_LEDS
887e1e54068SJohannes Berg struct tpt_led_trigger {
888e1e54068SJohannes Berg 	struct led_trigger trig;
889e1e54068SJohannes Berg 	char name[32];
890e1e54068SJohannes Berg 	const struct ieee80211_tpt_blink *blink_table;
891e1e54068SJohannes Berg 	unsigned int blink_table_len;
892e1e54068SJohannes Berg 	struct timer_list timer;
893e1e54068SJohannes Berg 	unsigned long prev_traffic;
894e1e54068SJohannes Berg 	unsigned long tx_bytes, rx_bytes;
89567408c8cSJohannes Berg 	unsigned int active, want;
89667408c8cSJohannes Berg 	bool running;
897e1e54068SJohannes Berg };
89865a6538aSLuciano Coelho #endif
899e1e54068SJohannes Berg 
900ad38bfc9SMatti Gottlieb /*
901ad38bfc9SMatti Gottlieb  * struct ieee80211_tx_latency_bin_ranges - Tx latency statistics bins ranges
902ad38bfc9SMatti Gottlieb  *
903ad38bfc9SMatti Gottlieb  * Measuring Tx latency statistics. Counts how many Tx frames transmitted in a
904ad38bfc9SMatti Gottlieb  * certain latency range (in Milliseconds). Each station that uses these
905ad38bfc9SMatti Gottlieb  * ranges will have bins to count the amount of frames received in that range.
906ad38bfc9SMatti Gottlieb  * The user can configure the ranges via debugfs.
907ad38bfc9SMatti Gottlieb  * If ranges is NULL then Tx latency statistics bins are disabled for all
908ad38bfc9SMatti Gottlieb  * stations.
909ad38bfc9SMatti Gottlieb  *
910ad38bfc9SMatti Gottlieb  * @n_ranges: number of ranges that are taken in account
911ad38bfc9SMatti Gottlieb  * @ranges: the ranges that the user requested or NULL if disabled.
912ad38bfc9SMatti Gottlieb  */
913ad38bfc9SMatti Gottlieb struct ieee80211_tx_latency_bin_ranges {
914ad38bfc9SMatti Gottlieb 	int n_ranges;
915ad38bfc9SMatti Gottlieb 	u32 ranges[];
916ad38bfc9SMatti Gottlieb };
917ad38bfc9SMatti Gottlieb 
918142b9f50SHelmut Schaa /**
919142b9f50SHelmut Schaa  * mac80211 scan flags - currently active scan mode
920142b9f50SHelmut Schaa  *
921142b9f50SHelmut Schaa  * @SCAN_SW_SCANNING: We're currently in the process of scanning but may as
922142b9f50SHelmut Schaa  *	well be on the operating channel
923142b9f50SHelmut Schaa  * @SCAN_HW_SCANNING: The hardware is scanning for us, we have no way to
924142b9f50SHelmut Schaa  *	determine if we are on the operating channel or not
9258a690674SBen Greear  * @SCAN_ONCHANNEL_SCANNING:  Do a software scan on only the current operating
9268a690674SBen Greear  *	channel. This should not interrupt normal traffic.
9278789d459SJohannes Berg  * @SCAN_COMPLETED: Set for our scan work function when the driver reported
9288789d459SJohannes Berg  *	that the scan completed.
9298789d459SJohannes Berg  * @SCAN_ABORTED: Set for our scan work function when the driver reported
9308789d459SJohannes Berg  *	a scan complete for an aborted scan.
931a754055aSEmmanuel Grumbach  * @SCAN_HW_CANCELLED: Set for our scan work function when the scan is being
932a754055aSEmmanuel Grumbach  *	cancelled.
933142b9f50SHelmut Schaa  */
934fbe9c429SHelmut Schaa enum {
935fbe9c429SHelmut Schaa 	SCAN_SW_SCANNING,
936142b9f50SHelmut Schaa 	SCAN_HW_SCANNING,
9378a690674SBen Greear 	SCAN_ONCHANNEL_SCANNING,
9388789d459SJohannes Berg 	SCAN_COMPLETED,
9398789d459SJohannes Berg 	SCAN_ABORTED,
940a754055aSEmmanuel Grumbach 	SCAN_HW_CANCELLED,
941142b9f50SHelmut Schaa };
942142b9f50SHelmut Schaa 
943142b9f50SHelmut Schaa /**
944142b9f50SHelmut Schaa  * enum mac80211_scan_state - scan state machine states
945142b9f50SHelmut Schaa  *
946142b9f50SHelmut Schaa  * @SCAN_DECISION: Main entry point to the scan state machine, this state
947142b9f50SHelmut Schaa  *	determines if we should keep on scanning or switch back to the
948142b9f50SHelmut Schaa  *	operating channel
949142b9f50SHelmut Schaa  * @SCAN_SET_CHANNEL: Set the next channel to be scanned
950142b9f50SHelmut Schaa  * @SCAN_SEND_PROBE: Send probe requests and wait for probe responses
95107ef03eeSJohannes Berg  * @SCAN_SUSPEND: Suspend the scan and go back to operating channel to
95207ef03eeSJohannes Berg  *	send out data
95307ef03eeSJohannes Berg  * @SCAN_RESUME: Resume the scan and scan the next channel
954cd2bb512SSam Leffler  * @SCAN_ABORT: Abort the scan and go back to operating channel
955142b9f50SHelmut Schaa  */
956142b9f50SHelmut Schaa enum mac80211_scan_state {
957142b9f50SHelmut Schaa 	SCAN_DECISION,
958142b9f50SHelmut Schaa 	SCAN_SET_CHANNEL,
959142b9f50SHelmut Schaa 	SCAN_SEND_PROBE,
96007ef03eeSJohannes Berg 	SCAN_SUSPEND,
96107ef03eeSJohannes Berg 	SCAN_RESUME,
962cd2bb512SSam Leffler 	SCAN_ABORT,
963fbe9c429SHelmut Schaa };
964fbe9c429SHelmut Schaa 
965f0706e82SJiri Benc struct ieee80211_local {
966f0706e82SJiri Benc 	/* embed the driver visible part.
967f0706e82SJiri Benc 	 * don't cast (use the static inlines below), but we keep
968f0706e82SJiri Benc 	 * it first anyway so they become a no-op */
969f0706e82SJiri Benc 	struct ieee80211_hw hw;
970f0706e82SJiri Benc 
971f0706e82SJiri Benc 	const struct ieee80211_ops *ops;
972f0706e82SJiri Benc 
97342935ecaSLuis R. Rodriguez 	/*
97442935ecaSLuis R. Rodriguez 	 * private workqueue to mac80211. mac80211 makes this accessible
97542935ecaSLuis R. Rodriguez 	 * via ieee80211_queue_work()
97642935ecaSLuis R. Rodriguez 	 */
97742935ecaSLuis R. Rodriguez 	struct workqueue_struct *workqueue;
97842935ecaSLuis R. Rodriguez 
979e4e72fb4SJohannes Berg 	unsigned long queue_stop_reasons[IEEE80211_MAX_QUEUES];
98096f5e66eSJohannes Berg 	/* also used to protect ampdu_ac_queue and amdpu_ac_stop_refcnt */
981ce7c9111SKalle Valo 	spinlock_t queue_stop_reason_lock;
98296f5e66eSJohannes Berg 
983f0706e82SJiri Benc 	int open_count;
9843d30d949SMichael Wu 	int monitors, cooked_mntrs;
9858cc9a739SMichael Wu 	/* number of interfaces with corresponding FIF_ flags */
9867be5086dSJohannes Berg 	int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss, fif_pspoll,
9877be5086dSJohannes Berg 	    fif_probe_req;
9887be5086dSJohannes Berg 	int probe_req_reg;
9894150c572SJohannes Berg 	unsigned int filter_flags; /* FIF_* */
9903b8d81e0SJohannes Berg 
9913ffc2a90SJohannes Berg 	bool wiphy_ciphers_allocated;
9923ffc2a90SJohannes Berg 
993fe57d9f5SJohannes Berg 	bool use_chanctx;
994fe57d9f5SJohannes Berg 
9953b8d81e0SJohannes Berg 	/* protects the aggregated multicast list and filter calls */
9963b8d81e0SJohannes Berg 	spinlock_t filter_lock;
9973b8d81e0SJohannes Berg 
9983ac64beeSJohannes Berg 	/* used for uploading changed mc list */
9993ac64beeSJohannes Berg 	struct work_struct reconfig_filter;
10003ac64beeSJohannes Berg 
10013b8d81e0SJohannes Berg 	/* aggregated multicast list */
100222bedad3SJiri Pirko 	struct netdev_hw_addr_list mc_list;
10033b8d81e0SJohannes Berg 
1004d0709a65SJohannes Berg 	bool tim_in_locked_section; /* see ieee80211_beacon_get() */
10055bb644a0SJohannes Berg 
10065bb644a0SJohannes Berg 	/*
10075bb644a0SJohannes Berg 	 * suspended is true if we finished all the suspend _and_ we have
10085bb644a0SJohannes Berg 	 * not yet come up from resume. This is to be used by mac80211
10095bb644a0SJohannes Berg 	 * to ensure driver sanity during suspend and mac80211's own
10105bb644a0SJohannes Berg 	 * sanity. It can eventually be used for WoW as well.
10115bb644a0SJohannes Berg 	 */
10125bb644a0SJohannes Berg 	bool suspended;
10135bb644a0SJohannes Berg 
10145bb644a0SJohannes Berg 	/*
1015ceb99fe0SJohannes Berg 	 * Resuming is true while suspended, but when we're reprogramming the
1016ceb99fe0SJohannes Berg 	 * hardware -- at that time it's allowed to use ieee80211_queue_work()
1017ceb99fe0SJohannes Berg 	 * again even though some other parts of the stack are still suspended
1018ceb99fe0SJohannes Berg 	 * and we still drop received frames to avoid waking the stack.
1019ceb99fe0SJohannes Berg 	 */
1020ceb99fe0SJohannes Berg 	bool resuming;
1021ceb99fe0SJohannes Berg 
1022ceb99fe0SJohannes Berg 	/*
10235bb644a0SJohannes Berg 	 * quiescing is true during the suspend process _only_ to
10245bb644a0SJohannes Berg 	 * ease timer cancelling etc.
10255bb644a0SJohannes Berg 	 */
10265bb644a0SJohannes Berg 	bool quiescing;
10275bb644a0SJohannes Berg 
1028ea77f12fSJohannes Berg 	/* device is started */
1029ea77f12fSJohannes Berg 	bool started;
1030ea77f12fSJohannes Berg 
103104800adaSArik Nemtsov 	/* device is during a HW reconfig */
103204800adaSArik Nemtsov 	bool in_reconfig;
103304800adaSArik Nemtsov 
1034eecc4800SJohannes Berg 	/* wowlan is enabled -- don't reconfig on resume */
1035eecc4800SJohannes Berg 	bool wowlan;
1036eecc4800SJohannes Berg 
1037164eb02dSSimon Wunderlich 	/* DFS/radar detection is enabled */
1038164eb02dSSimon Wunderlich 	bool radar_detect_enabled;
1039164eb02dSSimon Wunderlich 	struct work_struct radar_detected_work;
1040164eb02dSSimon Wunderlich 
104104ecd257SJohannes Berg 	/* number of RX chains the hardware has */
104204ecd257SJohannes Berg 	u8 rx_chains;
104304ecd257SJohannes Berg 
1044b306f453SJohannes Berg 	int tx_headroom; /* required headroom for hardware/radiotap */
1045f0706e82SJiri Benc 
1046f0706e82SJiri Benc 	/* Tasklet and skb queue to process calls from IRQ mode. All frames
1047f0706e82SJiri Benc 	 * added to skb_queue will be processed, but frames in
1048f0706e82SJiri Benc 	 * skb_queue_unreliable may be dropped if the total length of these
1049f0706e82SJiri Benc 	 * queues increases over the limit. */
1050f0706e82SJiri Benc #define IEEE80211_IRQSAFE_QUEUE_LIMIT 128
1051f0706e82SJiri Benc 	struct tasklet_struct tasklet;
1052f0706e82SJiri Benc 	struct sk_buff_head skb_queue;
1053f0706e82SJiri Benc 	struct sk_buff_head skb_queue_unreliable;
1054f0706e82SJiri Benc 
1055f9e124fbSChristian Lamparter 	spinlock_t rx_path_lock;
105624a8fdadSChristian Lamparter 
1057d0709a65SJohannes Berg 	/* Station data */
1058d0709a65SJohannes Berg 	/*
10594d33960bSJohannes Berg 	 * The mutex only protects the list, hash table and
10604d33960bSJohannes Berg 	 * counter, reads are done with RCU.
1061d0709a65SJohannes Berg 	 */
106234e89507SJohannes Berg 	struct mutex sta_mtx;
10634d33960bSJohannes Berg 	spinlock_t tim_lock;
1064d0709a65SJohannes Berg 	unsigned long num_sta;
10654d33960bSJohannes Berg 	struct list_head sta_list;
106640b275b6SJohannes Berg 	struct sta_info __rcu *sta_hash[STA_HASH_SIZE];
1067f0706e82SJiri Benc 	struct timer_list sta_cleanup;
1068f5ea9120SJohannes Berg 	int sta_generation;
1069f0706e82SJiri Benc 
1070ad38bfc9SMatti Gottlieb 	/*
1071ad38bfc9SMatti Gottlieb 	 * Tx latency statistics parameters for all stations.
1072ad38bfc9SMatti Gottlieb 	 * Can enable via debugfs (NULL when disabled).
1073ad38bfc9SMatti Gottlieb 	 */
1074ad38bfc9SMatti Gottlieb 	struct ieee80211_tx_latency_bin_ranges __rcu *tx_latency;
1075ad38bfc9SMatti Gottlieb 
10762a577d98SJohannes Berg 	struct sk_buff_head pending[IEEE80211_MAX_QUEUES];
1077f0706e82SJiri Benc 	struct tasklet_struct tx_pending_tasklet;
1078f0706e82SJiri Benc 
1079a6a67db2SJohannes Berg 	atomic_t agg_queue_stop[IEEE80211_MAX_QUEUES];
1080cd8ffc80SJohannes Berg 
1081f0706e82SJiri Benc 	/* number of interfaces with corresponding IFF_ flags */
108253918994SJohannes Berg 	atomic_t iff_allmultis, iff_promiscs;
1083f0706e82SJiri Benc 
1084f0706e82SJiri Benc 	struct rate_control_ref *rate_ctrl;
1085f0706e82SJiri Benc 
10865f9f1812SFelix Fietkau 	struct crypto_cipher *wep_tx_tfm;
10875f9f1812SFelix Fietkau 	struct crypto_cipher *wep_rx_tfm;
1088f0706e82SJiri Benc 	u32 wep_iv;
1089f0706e82SJiri Benc 
1090c771c9d8SJohannes Berg 	/* see iface.c */
109179010420SJohannes Berg 	struct list_head interfaces;
1092c771c9d8SJohannes Berg 	struct mutex iflist_mtx;
109379010420SJohannes Berg 
1094b16bd15cSJohannes Berg 	/*
1095ad0e2b5aSJohannes Berg 	 * Key mutex, protects sdata's key_list and sta_info's
1096b16bd15cSJohannes Berg 	 * key pointers (write access, they're RCU.)
1097b16bd15cSJohannes Berg 	 */
1098ad0e2b5aSJohannes Berg 	struct mutex key_mtx;
1099b16bd15cSJohannes Berg 
1100a1699b75SJohannes Berg 	/* mutex for scan and work locking */
1101a1699b75SJohannes Berg 	struct mutex mtx;
1102b16bd15cSJohannes Berg 
1103c2b13452SJohannes Berg 	/* Scanning and BSS list */
1104fbe9c429SHelmut Schaa 	unsigned long scanning;
11052a519311SJohannes Berg 	struct cfg80211_ssid scan_ssid;
11065ba63533SJohannes Berg 	struct cfg80211_scan_request *int_scan_req;
11074d36ec58SJohannes Berg 	struct cfg80211_scan_request *scan_req, *hw_scan_req;
11087ca15a0aSSimon Wunderlich 	struct cfg80211_chan_def scan_chandef;
11094d36ec58SJohannes Berg 	enum ieee80211_band hw_scan_band;
1110f0706e82SJiri Benc 	int scan_channel_idx;
1111de95a54bSJohannes Berg 	int scan_ies_len;
1112c604b9f2SJohannes Berg 	int hw_scan_ies_bufsize;
11138318d78aSJohannes Berg 
111485a9994aSLuciano Coelho 	struct work_struct sched_scan_stopped_work;
11155260a5b2SJohannes Berg 	struct ieee80211_sub_if_data __rcu *sched_scan_sdata;
1116d43c6b6eSDavid Spinadel 	struct cfg80211_sched_scan_request *sched_scan_req;
111779f460caSLuciano Coelho 
1118df13cce5SHelmut Schaa 	unsigned long leave_oper_channel_time;
1119977923b0SHelmut Schaa 	enum mac80211_scan_state next_scan_state;
1120f0706e82SJiri Benc 	struct delayed_work scan_work;
1121e2fd5dbcSJohannes Berg 	struct ieee80211_sub_if_data __rcu *scan_sdata;
112255de908aSJohannes Berg 	/* For backward compatibility only -- do not use */
1123675a0b04SKarl Beldan 	struct cfg80211_chan_def _oper_chandef;
1124f0706e82SJiri Benc 
1125b8bc4b0aSJohannes Berg 	/* Temporary remain-on-channel for off-channel operations */
1126b8bc4b0aSJohannes Berg 	struct ieee80211_channel *tmp_channel;
1127b8bc4b0aSJohannes Berg 
1128d01a1e65SMichal Kazior 	/* channel contexts */
1129d01a1e65SMichal Kazior 	struct list_head chanctx_list;
1130d01a1e65SMichal Kazior 	struct mutex chanctx_mtx;
1131d01a1e65SMichal Kazior 
1132f0706e82SJiri Benc 	/* SNMP counters */
1133f0706e82SJiri Benc 	/* dot11CountersTable */
1134f0706e82SJiri Benc 	u32 dot11TransmittedFragmentCount;
1135f0706e82SJiri Benc 	u32 dot11MulticastTransmittedFrameCount;
1136f0706e82SJiri Benc 	u32 dot11FailedCount;
1137f0706e82SJiri Benc 	u32 dot11RetryCount;
1138f0706e82SJiri Benc 	u32 dot11MultipleRetryCount;
1139f0706e82SJiri Benc 	u32 dot11FrameDuplicateCount;
1140f0706e82SJiri Benc 	u32 dot11ReceivedFragmentCount;
1141f0706e82SJiri Benc 	u32 dot11MulticastReceivedFrameCount;
1142f0706e82SJiri Benc 	u32 dot11TransmittedFrameCount;
1143f0706e82SJiri Benc 
1144f0706e82SJiri Benc #ifdef CONFIG_MAC80211_LEDS
1145cdcb006fSIvo van Doorn 	struct led_trigger *tx_led, *rx_led, *assoc_led, *radio_led;
1146e1e54068SJohannes Berg 	struct tpt_led_trigger *tpt_led_trigger;
1147cdcb006fSIvo van Doorn 	char tx_led_name[32], rx_led_name[32],
1148cdcb006fSIvo van Doorn 	     assoc_led_name[32], radio_led_name[32];
1149f0706e82SJiri Benc #endif
1150f0706e82SJiri Benc 
1151f0706e82SJiri Benc #ifdef CONFIG_MAC80211_DEBUG_COUNTERS
1152f0706e82SJiri Benc 	/* TX/RX handler statistics */
1153f0706e82SJiri Benc 	unsigned int tx_handlers_drop;
1154f0706e82SJiri Benc 	unsigned int tx_handlers_queued;
1155f0706e82SJiri Benc 	unsigned int tx_handlers_drop_unencrypted;
1156f0706e82SJiri Benc 	unsigned int tx_handlers_drop_fragment;
1157f0706e82SJiri Benc 	unsigned int tx_handlers_drop_wep;
1158f0706e82SJiri Benc 	unsigned int tx_handlers_drop_not_assoc;
1159f0706e82SJiri Benc 	unsigned int tx_handlers_drop_unauth_port;
1160f0706e82SJiri Benc 	unsigned int rx_handlers_drop;
1161f0706e82SJiri Benc 	unsigned int rx_handlers_queued;
1162f0706e82SJiri Benc 	unsigned int rx_handlers_drop_nullfunc;
1163f0706e82SJiri Benc 	unsigned int rx_handlers_drop_defrag;
1164f0706e82SJiri Benc 	unsigned int rx_handlers_drop_short;
1165f0706e82SJiri Benc 	unsigned int tx_expand_skb_head;
1166f0706e82SJiri Benc 	unsigned int tx_expand_skb_head_cloned;
1167f0706e82SJiri Benc 	unsigned int rx_expand_skb_head;
1168f0706e82SJiri Benc 	unsigned int rx_expand_skb_head2;
1169f0706e82SJiri Benc 	unsigned int rx_handlers_fragments;
1170f0706e82SJiri Benc 	unsigned int tx_status_drop;
1171f0706e82SJiri Benc #define I802_DEBUG_INC(c) (c)++
1172f0706e82SJiri Benc #else /* CONFIG_MAC80211_DEBUG_COUNTERS */
1173f0706e82SJiri Benc #define I802_DEBUG_INC(c) do { } while (0)
1174f0706e82SJiri Benc #endif /* CONFIG_MAC80211_DEBUG_COUNTERS */
1175f0706e82SJiri Benc 
1176f0706e82SJiri Benc 
1177f0706e82SJiri Benc 	int total_ps_buffered; /* total number of all buffered unicast and
1178f0706e82SJiri Benc 				* multicast packets for power saving stations
1179f0706e82SJiri Benc 				*/
1180520eb820SKalle Valo 
1181572e0012SKalle Valo 	bool pspolling;
1182b203ffc3SJouni Malinen 	bool offchannel_ps_enabled;
1183965bedadSJohannes Berg 	/*
1184965bedadSJohannes Berg 	 * PS can only be enabled when we have exactly one managed
1185965bedadSJohannes Berg 	 * interface (and monitors) in PS, this then points there.
1186965bedadSJohannes Berg 	 */
1187965bedadSJohannes Berg 	struct ieee80211_sub_if_data *ps_sdata;
1188520eb820SKalle Valo 	struct work_struct dynamic_ps_enable_work;
1189520eb820SKalle Valo 	struct work_struct dynamic_ps_disable_work;
1190520eb820SKalle Valo 	struct timer_list dynamic_ps_timer;
119110f644a4SJohannes Berg 	struct notifier_block network_latency_notifier;
11922b2c009eSJuuso Oikarinen 	struct notifier_block ifa_notifier;
1193a65240c1SJohannes Berg 	struct notifier_block ifa6_notifier;
1194f0706e82SJiri Benc 
1195ff616381SJuuso Oikarinen 	/*
1196ff616381SJuuso Oikarinen 	 * The dynamic ps timeout configured from user space via WEXT -
1197ff616381SJuuso Oikarinen 	 * this will override whatever chosen by mac80211 internally.
1198ff616381SJuuso Oikarinen 	 */
1199ff616381SJuuso Oikarinen 	int dynamic_ps_forced_timeout;
1200ff616381SJuuso Oikarinen 
12011ea6f9c0SJohannes Berg 	int user_power_level; /* in dBm, for all interfaces */
12022bf30fabSJohannes Berg 
12030f78231bSJohannes Berg 	enum ieee80211_smps_mode smps_mode;
12040f78231bSJohannes Berg 
1205f2753ddbSJohannes Berg 	struct work_struct restart_work;
1206f2753ddbSJohannes Berg 
1207e9f207f0SJiri Benc #ifdef CONFIG_MAC80211_DEBUGFS
1208e9f207f0SJiri Benc 	struct local_debugfsdentries {
12094b7679a5SJohannes Berg 		struct dentry *rcdir;
1210e9f207f0SJiri Benc 		struct dentry *keys;
1211e9f207f0SJiri Benc 	} debugfs;
1212e9f207f0SJiri Benc #endif
12134e6cbfd0SJohn W. Linville 
12142eb278e0SJohannes Berg 	/*
12152eb278e0SJohannes Berg 	 * Remain-on-channel support
12162eb278e0SJohannes Berg 	 */
12172eb278e0SJohannes Berg 	struct list_head roc_list;
121821f83589SJohannes Berg 	struct work_struct hw_roc_start, hw_roc_done;
12192eb278e0SJohannes Berg 	unsigned long hw_roc_start_time;
122050febf6aSJohannes Berg 	u64 roc_cookie_counter;
122121f83589SJohannes Berg 
1222a729cff8SJohannes Berg 	struct idr ack_status_frames;
1223a729cff8SJohannes Berg 	spinlock_t ack_status_lock;
1224a729cff8SJohannes Berg 
1225f142c6b9SJohannes Berg 	struct ieee80211_sub_if_data __rcu *p2p_sdata;
1226f142c6b9SJohannes Berg 
12274b6f1dd6SJohannes Berg 	/* virtual monitor interface */
12284b6f1dd6SJohannes Berg 	struct ieee80211_sub_if_data __rcu *monitor_sdata;
12294bf88530SJohannes Berg 	struct cfg80211_chan_def monitor_chandef;
1230f0706e82SJiri Benc };
1231f0706e82SJiri Benc 
12323e122be0SJohannes Berg static inline struct ieee80211_sub_if_data *
12333e122be0SJohannes Berg IEEE80211_DEV_TO_SUB_IF(struct net_device *dev)
12343e122be0SJohannes Berg {
12353e122be0SJohannes Berg 	return netdev_priv(dev);
12363e122be0SJohannes Berg }
12373e122be0SJohannes Berg 
123871bbc994SJohannes Berg static inline struct ieee80211_sub_if_data *
123971bbc994SJohannes Berg IEEE80211_WDEV_TO_SUB_IF(struct wireless_dev *wdev)
124071bbc994SJohannes Berg {
124171bbc994SJohannes Berg 	return container_of(wdev, struct ieee80211_sub_if_data, wdev);
124271bbc994SJohannes Berg }
124371bbc994SJohannes Berg 
1244c1475ca9SJohannes Berg /* this struct represents 802.11n's RA/TID combination */
1245eadc8d9eSRon Rindjunsky struct ieee80211_ra_tid {
1246eadc8d9eSRon Rindjunsky 	u8 ra[ETH_ALEN];
1247eadc8d9eSRon Rindjunsky 	u16 tid;
1248eadc8d9eSRon Rindjunsky };
1249eadc8d9eSRon Rindjunsky 
1250c0f17eb9SChun-Yeow Yeoh /* this struct holds the value parsing from channel switch IE  */
1251c0f17eb9SChun-Yeow Yeoh struct ieee80211_csa_ie {
1252c0f17eb9SChun-Yeow Yeoh 	struct cfg80211_chan_def chandef;
1253c0f17eb9SChun-Yeow Yeoh 	u8 mode;
1254c0f17eb9SChun-Yeow Yeoh 	u8 count;
1255c0f17eb9SChun-Yeow Yeoh 	u8 ttl;
12563f718fd8SChun-Yeow Yeoh 	u16 pre_value;
1257c0f17eb9SChun-Yeow Yeoh };
1258c0f17eb9SChun-Yeow Yeoh 
1259dd76986bSJohannes Berg /* Parsed Information Elements */
1260dd76986bSJohannes Berg struct ieee802_11_elems {
12614a3cb702SJohannes Berg 	const u8 *ie_start;
1262dd76986bSJohannes Berg 	size_t total_len;
1263dd76986bSJohannes Berg 
1264dd76986bSJohannes Berg 	/* pointers to IEs */
12654a3cb702SJohannes Berg 	const u8 *ssid;
12664a3cb702SJohannes Berg 	const u8 *supp_rates;
12674a3cb702SJohannes Berg 	const u8 *ds_params;
12684a3cb702SJohannes Berg 	const struct ieee80211_tim_ie *tim;
12694a3cb702SJohannes Berg 	const u8 *challenge;
12704a3cb702SJohannes Berg 	const u8 *rsn;
12714a3cb702SJohannes Berg 	const u8 *erp_info;
12724a3cb702SJohannes Berg 	const u8 *ext_supp_rates;
12734a3cb702SJohannes Berg 	const u8 *wmm_info;
12744a3cb702SJohannes Berg 	const u8 *wmm_param;
12754a3cb702SJohannes Berg 	const struct ieee80211_ht_cap *ht_cap_elem;
12764a3cb702SJohannes Berg 	const struct ieee80211_ht_operation *ht_operation;
12774a3cb702SJohannes Berg 	const struct ieee80211_vht_cap *vht_cap_elem;
12784a3cb702SJohannes Berg 	const struct ieee80211_vht_operation *vht_operation;
12794a3cb702SJohannes Berg 	const struct ieee80211_meshconf_ie *mesh_config;
12804a3cb702SJohannes Berg 	const u8 *mesh_id;
12814a3cb702SJohannes Berg 	const u8 *peering;
12824a3cb702SJohannes Berg 	const __le16 *awake_window;
12834a3cb702SJohannes Berg 	const u8 *preq;
12844a3cb702SJohannes Berg 	const u8 *prep;
12854a3cb702SJohannes Berg 	const u8 *perr;
12864a3cb702SJohannes Berg 	const struct ieee80211_rann_ie *rann;
12874a3cb702SJohannes Berg 	const struct ieee80211_channel_sw_ie *ch_switch_ie;
1288b4f286a1SJohannes Berg 	const struct ieee80211_ext_chansw_ie *ext_chansw_ie;
1289b2e506bfSJohannes Berg 	const struct ieee80211_wide_bw_chansw_ie *wide_bw_chansw_ie;
12904a3cb702SJohannes Berg 	const u8 *country_elem;
12914a3cb702SJohannes Berg 	const u8 *pwr_constr_elem;
129279ba1d89SJohannes Berg 	const struct ieee80211_timeout_interval_ie *timeout_int;
12934a3cb702SJohannes Berg 	const u8 *opmode_notif;
129485220d71SJohannes Berg 	const struct ieee80211_sec_chan_offs_ie *sec_chan_offs;
12958f2535b9SChun-Yeow Yeoh 	const struct ieee80211_mesh_chansw_params_ie *mesh_chansw_params_ie;
1296dd76986bSJohannes Berg 
1297dd76986bSJohannes Berg 	/* length of them, respectively */
1298dd76986bSJohannes Berg 	u8 ssid_len;
1299dd76986bSJohannes Berg 	u8 supp_rates_len;
1300dd76986bSJohannes Berg 	u8 tim_len;
1301dd76986bSJohannes Berg 	u8 challenge_len;
1302dd76986bSJohannes Berg 	u8 rsn_len;
1303dd76986bSJohannes Berg 	u8 ext_supp_rates_len;
1304dd76986bSJohannes Berg 	u8 wmm_info_len;
1305dd76986bSJohannes Berg 	u8 wmm_param_len;
1306dd76986bSJohannes Berg 	u8 mesh_id_len;
1307dd76986bSJohannes Berg 	u8 peering_len;
1308dd76986bSJohannes Berg 	u8 preq_len;
1309dd76986bSJohannes Berg 	u8 prep_len;
1310dd76986bSJohannes Berg 	u8 perr_len;
1311dd76986bSJohannes Berg 	u8 country_elem_len;
1312fcff4f10SPaul Stewart 
1313fcff4f10SPaul Stewart 	/* whether a parse error occurred while retrieving these elements */
1314fcff4f10SPaul Stewart 	bool parse_error;
1315dd76986bSJohannes Berg };
1316dd76986bSJohannes Berg 
1317f0706e82SJiri Benc static inline struct ieee80211_local *hw_to_local(
1318f0706e82SJiri Benc 	struct ieee80211_hw *hw)
1319f0706e82SJiri Benc {
1320f0706e82SJiri Benc 	return container_of(hw, struct ieee80211_local, hw);
1321f0706e82SJiri Benc }
1322f0706e82SJiri Benc 
1323f0706e82SJiri Benc 
1324571ecf67SJohannes Berg static inline int ieee80211_bssid_match(const u8 *raddr, const u8 *addr)
1325571ecf67SJohannes Berg {
1326b203ca39SJoe Perches 	return ether_addr_equal(raddr, addr) ||
1327571ecf67SJohannes Berg 	       is_broadcast_ether_addr(raddr);
1328571ecf67SJohannes Berg }
1329571ecf67SJohannes Berg 
1330f4bda337SThomas Pedersen static inline bool
1331f4bda337SThomas Pedersen ieee80211_have_rx_timestamp(struct ieee80211_rx_status *status)
1332f4bda337SThomas Pedersen {
1333f4bda337SThomas Pedersen 	WARN_ON_ONCE(status->flag & RX_FLAG_MACTIME_START &&
1334f4bda337SThomas Pedersen 		     status->flag & RX_FLAG_MACTIME_END);
1335f4bda337SThomas Pedersen 	return status->flag & (RX_FLAG_MACTIME_START | RX_FLAG_MACTIME_END);
1336f4bda337SThomas Pedersen }
1337571ecf67SJohannes Berg 
1338f4bda337SThomas Pedersen u64 ieee80211_calculate_rx_timestamp(struct ieee80211_local *local,
1339f4bda337SThomas Pedersen 				     struct ieee80211_rx_status *status,
1340f4bda337SThomas Pedersen 				     unsigned int mpdu_len,
1341f4bda337SThomas Pedersen 				     unsigned int mpdu_offset);
1342e8975581SJohannes Berg int ieee80211_hw_config(struct ieee80211_local *local, u32 changed);
13435cf121c3SJohannes Berg void ieee80211_tx_set_protected(struct ieee80211_tx_data *tx);
13449c6bd790SJohannes Berg void ieee80211_bss_info_change_notify(struct ieee80211_sub_if_data *sdata,
13459c6bd790SJohannes Berg 				      u32 changed);
13460d143fe1SJohannes Berg void ieee80211_configure_filter(struct ieee80211_local *local);
134746900298SJohannes Berg u32 ieee80211_reset_erp_info(struct ieee80211_sub_if_data *sdata);
1348f0706e82SJiri Benc 
134946900298SJohannes Berg /* STA code */
13509c6bd790SJohannes Berg void ieee80211_sta_setup_sdata(struct ieee80211_sub_if_data *sdata);
135177fdaa12SJohannes Berg int ieee80211_mgd_auth(struct ieee80211_sub_if_data *sdata,
135277fdaa12SJohannes Berg 		       struct cfg80211_auth_request *req);
135377fdaa12SJohannes Berg int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata,
135477fdaa12SJohannes Berg 			struct cfg80211_assoc_request *req);
135577fdaa12SJohannes Berg int ieee80211_mgd_deauth(struct ieee80211_sub_if_data *sdata,
135663c9c5e7SJohannes Berg 			 struct cfg80211_deauth_request *req);
135777fdaa12SJohannes Berg int ieee80211_mgd_disassoc(struct ieee80211_sub_if_data *sdata,
135863c9c5e7SJohannes Berg 			   struct cfg80211_disassoc_request *req);
1359572e0012SKalle Valo void ieee80211_send_pspoll(struct ieee80211_local *local,
1360572e0012SKalle Valo 			   struct ieee80211_sub_if_data *sdata);
136110f644a4SJohannes Berg void ieee80211_recalc_ps(struct ieee80211_local *local, s32 latency);
1362ab095877SEliad Peller void ieee80211_recalc_ps_vif(struct ieee80211_sub_if_data *sdata);
136310f644a4SJohannes Berg int ieee80211_max_network_latency(struct notifier_block *nb,
136410f644a4SJohannes Berg 				  unsigned long data, void *dummy);
13652b2c009eSJuuso Oikarinen int ieee80211_set_arp_filter(struct ieee80211_sub_if_data *sdata);
13661fa57d01SJohannes Berg void ieee80211_sta_work(struct ieee80211_sub_if_data *sdata);
13671fa57d01SJohannes Berg void ieee80211_sta_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
13681fa57d01SJohannes Berg 				  struct sk_buff *skb);
1369d3a910a8SLuis R. Rodriguez void ieee80211_sta_reset_beacon_monitor(struct ieee80211_sub_if_data *sdata);
1370be099e82SLuis R. Rodriguez void ieee80211_sta_reset_conn_monitor(struct ieee80211_sub_if_data *sdata);
1371afa762f6SEliad Peller void ieee80211_mgd_stop(struct ieee80211_sub_if_data *sdata);
13721672c0e3SJohannes Berg void ieee80211_mgd_conn_tx_status(struct ieee80211_sub_if_data *sdata,
13731672c0e3SJohannes Berg 				  __le16 fc, bool acked);
1374b8360ab8SJohannes Berg void ieee80211_sta_restart(struct ieee80211_sub_if_data *sdata);
13759c6bd790SJohannes Berg 
137646900298SJohannes Berg /* IBSS code */
137746900298SJohannes Berg void ieee80211_ibss_notify_scan_completed(struct ieee80211_local *local);
137846900298SJohannes Berg void ieee80211_ibss_setup_sdata(struct ieee80211_sub_if_data *sdata);
13798bf11d8dSJohannes Berg void ieee80211_ibss_rx_no_sta(struct ieee80211_sub_if_data *sdata,
13808bf11d8dSJohannes Berg 			      const u8 *bssid, const u8 *addr, u32 supp_rates);
1381af8cdcd8SJohannes Berg int ieee80211_ibss_join(struct ieee80211_sub_if_data *sdata,
1382af8cdcd8SJohannes Berg 			struct cfg80211_ibss_params *params);
1383af8cdcd8SJohannes Berg int ieee80211_ibss_leave(struct ieee80211_sub_if_data *sdata);
13841fa57d01SJohannes Berg void ieee80211_ibss_work(struct ieee80211_sub_if_data *sdata);
13851fa57d01SJohannes Berg void ieee80211_ibss_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
13861fa57d01SJohannes Berg 				   struct sk_buff *skb);
1387cd7760e6SSimon Wunderlich int ieee80211_ibss_csa_beacon(struct ieee80211_sub_if_data *sdata,
1388cd7760e6SSimon Wunderlich 			      struct cfg80211_csa_settings *csa_settings);
1389cd7760e6SSimon Wunderlich int ieee80211_ibss_finish_csa(struct ieee80211_sub_if_data *sdata);
1390cd7760e6SSimon Wunderlich void ieee80211_ibss_stop(struct ieee80211_sub_if_data *sdata);
13911fa57d01SJohannes Berg 
13921fa57d01SJohannes Berg /* mesh code */
13931fa57d01SJohannes Berg void ieee80211_mesh_work(struct ieee80211_sub_if_data *sdata);
13941fa57d01SJohannes Berg void ieee80211_mesh_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
13951fa57d01SJohannes Berg 				   struct sk_buff *skb);
1396b8456a14SChun-Yeow Yeoh int ieee80211_mesh_csa_beacon(struct ieee80211_sub_if_data *sdata,
1397b8456a14SChun-Yeow Yeoh 			      struct cfg80211_csa_settings *csa_settings,
1398b8456a14SChun-Yeow Yeoh 			      bool csa_action);
1399b8456a14SChun-Yeow Yeoh int ieee80211_mesh_finish_csa(struct ieee80211_sub_if_data *sdata);
140046900298SJohannes Berg 
14019c6bd790SJohannes Berg /* scan/BSS handling */
140246900298SJohannes Berg void ieee80211_scan_work(struct work_struct *work);
140334bcf715SStanislaw Gruszka int ieee80211_request_ibss_scan(struct ieee80211_sub_if_data *sdata,
1404be4a4b6aSJohannes Berg 				const u8 *ssid, u8 ssid_len,
14057ca15a0aSSimon Wunderlich 				struct ieee80211_channel *chan,
14067ca15a0aSSimon Wunderlich 				enum nl80211_bss_scan_width scan_width);
1407c2b13452SJohannes Berg int ieee80211_request_scan(struct ieee80211_sub_if_data *sdata,
14082a519311SJohannes Berg 			   struct cfg80211_scan_request *req);
14095bb644a0SJohannes Berg void ieee80211_scan_cancel(struct ieee80211_local *local);
1410133d40f9SStanislaw Gruszka void ieee80211_run_deferred_scan(struct ieee80211_local *local);
1411d48b2968SJohannes Berg void ieee80211_scan_rx(struct ieee80211_local *local, struct sk_buff *skb);
14129c6bd790SJohannes Berg 
14130a51b27eSJohannes Berg void ieee80211_mlme_notify_scan_completed(struct ieee80211_local *local);
1414c2b13452SJohannes Berg struct ieee80211_bss *
141598c8fccfSJohannes Berg ieee80211_bss_info_update(struct ieee80211_local *local,
141698c8fccfSJohannes Berg 			  struct ieee80211_rx_status *rx_status,
141798c8fccfSJohannes Berg 			  struct ieee80211_mgmt *mgmt,
141898c8fccfSJohannes Berg 			  size_t len,
141998c8fccfSJohannes Berg 			  struct ieee802_11_elems *elems,
1420d45c4172SEmmanuel Grumbach 			  struct ieee80211_channel *channel);
142198c8fccfSJohannes Berg void ieee80211_rx_bss_put(struct ieee80211_local *local,
1422c2b13452SJohannes Berg 			  struct ieee80211_bss *bss);
1423ee385855SLuis Carlos Cobo 
142479f460caSLuciano Coelho /* scheduled scan handling */
1425d43c6b6eSDavid Spinadel int
1426d43c6b6eSDavid Spinadel __ieee80211_request_sched_scan_start(struct ieee80211_sub_if_data *sdata,
1427d43c6b6eSDavid Spinadel 				     struct cfg80211_sched_scan_request *req);
142879f460caSLuciano Coelho int ieee80211_request_sched_scan_start(struct ieee80211_sub_if_data *sdata,
142979f460caSLuciano Coelho 				       struct cfg80211_sched_scan_request *req);
143085a9994aSLuciano Coelho int ieee80211_request_sched_scan_stop(struct ieee80211_sub_if_data *sdata);
143185a9994aSLuciano Coelho void ieee80211_sched_scan_stopped_work(struct work_struct *work);
143279f460caSLuciano Coelho 
1433b203ffc3SJouni Malinen /* off-channel helpers */
1434aacde9eeSStanislaw Gruszka void ieee80211_offchannel_stop_vifs(struct ieee80211_local *local);
1435aacde9eeSStanislaw Gruszka void ieee80211_offchannel_return(struct ieee80211_local *local);
14362eb278e0SJohannes Berg void ieee80211_roc_setup(struct ieee80211_local *local);
14372eb278e0SJohannes Berg void ieee80211_start_next_roc(struct ieee80211_local *local);
1438c8f994eeSJohannes Berg void ieee80211_roc_purge(struct ieee80211_local *local,
1439c8f994eeSJohannes Berg 			 struct ieee80211_sub_if_data *sdata);
14403fbd45caSJohannes Berg void ieee80211_roc_notify_destroy(struct ieee80211_roc_work *roc, bool free);
14412eb278e0SJohannes Berg void ieee80211_sw_roc_work(struct work_struct *work);
14422eb278e0SJohannes Berg void ieee80211_handle_roc_started(struct ieee80211_roc_work *roc);
1443b203ffc3SJouni Malinen 
144473da7d5bSSimon Wunderlich /* channel switch handling */
144573da7d5bSSimon Wunderlich void ieee80211_csa_finalize_work(struct work_struct *work);
144673da7d5bSSimon Wunderlich 
14473e122be0SJohannes Berg /* interface handling */
144847846c9bSJohannes Berg int ieee80211_iface_init(void);
144947846c9bSJohannes Berg void ieee80211_iface_exit(void);
14503e122be0SJohannes Berg int ieee80211_if_add(struct ieee80211_local *local, const char *name,
145184efbb84SJohannes Berg 		     struct wireless_dev **new_wdev, enum nl80211_iftype type,
1452ee385855SLuis Carlos Cobo 		     struct vif_params *params);
1453f3947e2dSJohannes Berg int ieee80211_if_change_type(struct ieee80211_sub_if_data *sdata,
145405c914feSJohannes Berg 			     enum nl80211_iftype type);
1455f698d856SJasper Bryant-Greene void ieee80211_if_remove(struct ieee80211_sub_if_data *sdata);
145675636525SJohannes Berg void ieee80211_remove_interfaces(struct ieee80211_local *local);
1457382a103bSJohannes Berg u32 ieee80211_idle_off(struct ieee80211_local *local);
14585cff20e6SJohannes Berg void ieee80211_recalc_idle(struct ieee80211_local *local);
145985416a4fSChristian Lamparter void ieee80211_adjust_monitor_flags(struct ieee80211_sub_if_data *sdata,
146085416a4fSChristian Lamparter 				    const int offset);
1461f142c6b9SJohannes Berg int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up);
1462f142c6b9SJohannes Berg void ieee80211_sdata_stop(struct ieee80211_sub_if_data *sdata);
14633c3e21e7SJohannes Berg int ieee80211_add_virtual_monitor(struct ieee80211_local *local);
14643c3e21e7SJohannes Berg void ieee80211_del_virtual_monitor(struct ieee80211_local *local);
1465f0706e82SJiri Benc 
14661ea6f9c0SJohannes Berg bool __ieee80211_recalc_txpower(struct ieee80211_sub_if_data *sdata);
14671ea6f9c0SJohannes Berg void ieee80211_recalc_txpower(struct ieee80211_sub_if_data *sdata);
14681ea6f9c0SJohannes Berg 
14699607e6b6SJohannes Berg static inline bool ieee80211_sdata_running(struct ieee80211_sub_if_data *sdata)
14709607e6b6SJohannes Berg {
147134d4bc4dSJohannes Berg 	return test_bit(SDATA_STATE_RUNNING, &sdata->state);
14729607e6b6SJohannes Berg }
14739607e6b6SJohannes Berg 
1474e2ebc74dSJohannes Berg /* tx handling */
1475e2ebc74dSJohannes Berg void ieee80211_clear_tx_pending(struct ieee80211_local *local);
1476e2ebc74dSJohannes Berg void ieee80211_tx_pending(unsigned long data);
1477d0cf9c0dSStephen Hemminger netdev_tx_t ieee80211_monitor_start_xmit(struct sk_buff *skb,
1478d0cf9c0dSStephen Hemminger 					 struct net_device *dev);
1479d0cf9c0dSStephen Hemminger netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb,
1480d0cf9c0dSStephen Hemminger 				       struct net_device *dev);
14811f98ab7fSFelix Fietkau void ieee80211_purge_tx_queue(struct ieee80211_hw *hw,
14821f98ab7fSFelix Fietkau 			      struct sk_buff_head *skbs);
1483e2ebc74dSJohannes Berg 
1484de1ede7aSJohannes Berg /* HT */
1485ef96a842SBen Greear void ieee80211_apply_htcap_overrides(struct ieee80211_sub_if_data *sdata,
1486ef96a842SBen Greear 				     struct ieee80211_sta_ht_cap *ht_cap);
1487e1a0c6b3SJohannes Berg bool ieee80211_ht_cap_ie_to_sta_ht_cap(struct ieee80211_sub_if_data *sdata,
1488ef96a842SBen Greear 				       struct ieee80211_supported_band *sband,
14894a3cb702SJohannes Berg 				       const struct ieee80211_ht_cap *ht_cap_ie,
1490e1a0c6b3SJohannes Berg 				       struct sta_info *sta);
1491b8695a8fSJohannes Berg void ieee80211_send_delba(struct ieee80211_sub_if_data *sdata,
1492b8695a8fSJohannes Berg 			  const u8 *da, u16 tid,
1493b8695a8fSJohannes Berg 			  u16 initiator, u16 reason_code);
14940f78231bSJohannes Berg int ieee80211_send_smps_action(struct ieee80211_sub_if_data *sdata,
14950f78231bSJohannes Berg 			       enum ieee80211_smps_mode smps, const u8 *da,
14960f78231bSJohannes Berg 			       const u8 *bssid);
1497687da132SEmmanuel Grumbach void ieee80211_request_smps_ap_work(struct work_struct *work);
1498687da132SEmmanuel Grumbach void ieee80211_request_smps_mgd_work(struct work_struct *work);
1499687da132SEmmanuel Grumbach bool ieee80211_smps_is_restrictive(enum ieee80211_smps_mode smps_mode_old,
1500687da132SEmmanuel Grumbach 				   enum ieee80211_smps_mode smps_mode_new);
1501de1ede7aSJohannes Berg 
15027c3b1dd8SJohannes Berg void ___ieee80211_stop_rx_ba_session(struct sta_info *sta, u16 tid,
150353f73c09SJohannes Berg 				     u16 initiator, u16 reason, bool stop);
1504849b7967SJohannes Berg void __ieee80211_stop_rx_ba_session(struct sta_info *sta, u16 tid,
150553f73c09SJohannes Berg 				    u16 initiator, u16 reason, bool stop);
1506c82c4a80SJohannes Berg void ieee80211_sta_tear_down_BA_sessions(struct sta_info *sta,
1507c82c4a80SJohannes Berg 					 enum ieee80211_agg_stop_reason reason);
1508de1ede7aSJohannes Berg void ieee80211_process_delba(struct ieee80211_sub_if_data *sdata,
1509de1ede7aSJohannes Berg 			     struct sta_info *sta,
1510de1ede7aSJohannes Berg 			     struct ieee80211_mgmt *mgmt, size_t len);
1511de1ede7aSJohannes Berg void ieee80211_process_addba_resp(struct ieee80211_local *local,
1512de1ede7aSJohannes Berg 				  struct sta_info *sta,
1513de1ede7aSJohannes Berg 				  struct ieee80211_mgmt *mgmt,
1514de1ede7aSJohannes Berg 				  size_t len);
1515de1ede7aSJohannes Berg void ieee80211_process_addba_request(struct ieee80211_local *local,
1516de1ede7aSJohannes Berg 				     struct sta_info *sta,
1517de1ede7aSJohannes Berg 				     struct ieee80211_mgmt *mgmt,
1518de1ede7aSJohannes Berg 				     size_t len);
1519de1ede7aSJohannes Berg 
1520849b7967SJohannes Berg int __ieee80211_stop_tx_ba_session(struct sta_info *sta, u16 tid,
1521c82c4a80SJohannes Berg 				   enum ieee80211_agg_stop_reason reason);
152267c282c0SJohannes Berg int ___ieee80211_stop_tx_ba_session(struct sta_info *sta, u16 tid,
1523c82c4a80SJohannes Berg 				    enum ieee80211_agg_stop_reason reason);
15245d22c89bSJohannes Berg void ieee80211_start_tx_ba_cb(struct ieee80211_vif *vif, u8 *ra, u16 tid);
15255d22c89bSJohannes Berg void ieee80211_stop_tx_ba_cb(struct ieee80211_vif *vif, u8 *ra, u8 tid);
152667c282c0SJohannes Berg void ieee80211_ba_session_work(struct work_struct *work);
152767c282c0SJohannes Berg void ieee80211_tx_ba_session_handle_start(struct sta_info *sta, int tid);
15282bff8ebfSChristian Lamparter void ieee80211_release_reorder_timeout(struct sta_info *sta, int tid);
1529849b7967SJohannes Berg 
153004ecd257SJohannes Berg u8 ieee80211_mcs_to_chains(const struct ieee80211_mcs_info *mcs);
153104ecd257SJohannes Berg 
1532818255eaSMahesh Palivela /* VHT */
15334a3cb702SJohannes Berg void
15344a3cb702SJohannes Berg ieee80211_vht_cap_ie_to_sta_vht_cap(struct ieee80211_sub_if_data *sdata,
1535818255eaSMahesh Palivela 				    struct ieee80211_supported_band *sband,
15364a3cb702SJohannes Berg 				    const struct ieee80211_vht_cap *vht_cap_ie,
15374a34215eSJohannes Berg 				    struct sta_info *sta);
1538e1a0c6b3SJohannes Berg enum ieee80211_sta_rx_bandwidth ieee80211_sta_cur_vht_bw(struct sta_info *sta);
15398921d04eSJohannes Berg void ieee80211_sta_set_rx_nss(struct sta_info *sta);
15400af83d3dSJohannes Berg void ieee80211_vht_handle_opmode(struct ieee80211_sub_if_data *sdata,
15410af83d3dSJohannes Berg 				 struct sta_info *sta, u8 opmode,
1542bee7f586SJohannes Berg 				 enum ieee80211_band band, bool nss_only);
1543dd5ecfeaSJohannes Berg void ieee80211_apply_vhtcap_overrides(struct ieee80211_sub_if_data *sdata,
1544dd5ecfeaSJohannes Berg 				      struct ieee80211_sta_vht_cap *vht_cap);
15454a34215eSJohannes Berg 
154639192c0bSJohannes Berg /* Spectrum management */
154739192c0bSJohannes Berg void ieee80211_process_measurement_req(struct ieee80211_sub_if_data *sdata,
154839192c0bSJohannes Berg 				       struct ieee80211_mgmt *mgmt,
154939192c0bSJohannes Berg 				       size_t len);
1550e6b7cde4SSimon Wunderlich /**
1551e6b7cde4SSimon Wunderlich  * ieee80211_parse_ch_switch_ie - parses channel switch IEs
1552e6b7cde4SSimon Wunderlich  * @sdata: the sdata of the interface which has received the frame
1553e6b7cde4SSimon Wunderlich  * @elems: parsed 802.11 elements received with the frame
1554e6b7cde4SSimon Wunderlich  * @beacon: indicates if the frame was a beacon or probe response
1555e6b7cde4SSimon Wunderlich  * @current_band: indicates the current band
1556e6b7cde4SSimon Wunderlich  * @sta_flags: contains information about own capabilities and restrictions
1557e6b7cde4SSimon Wunderlich  *	to decide which channel switch announcements can be accepted. Only the
1558e6b7cde4SSimon Wunderlich  *	following subset of &enum ieee80211_sta_flags are evaluated:
1559e6b7cde4SSimon Wunderlich  *	%IEEE80211_STA_DISABLE_HT, %IEEE80211_STA_DISABLE_VHT,
1560e6b7cde4SSimon Wunderlich  *	%IEEE80211_STA_DISABLE_40MHZ, %IEEE80211_STA_DISABLE_80P80MHZ,
1561e6b7cde4SSimon Wunderlich  *	%IEEE80211_STA_DISABLE_160MHZ.
1562e6b7cde4SSimon Wunderlich  * @bssid: the currently connected bssid (for reporting)
1563c0f17eb9SChun-Yeow Yeoh  * @csa_ie: parsed 802.11 csa elements on count, mode, chandef and mesh ttl.
1564c0f17eb9SChun-Yeow Yeoh 	All of them will be filled with if success only.
1565e6b7cde4SSimon Wunderlich  * Return: 0 on success, <0 on error and >0 if there is nothing to parse.
1566e6b7cde4SSimon Wunderlich  */
1567e6b7cde4SSimon Wunderlich int ieee80211_parse_ch_switch_ie(struct ieee80211_sub_if_data *sdata,
1568e6b7cde4SSimon Wunderlich 				 struct ieee802_11_elems *elems, bool beacon,
1569e6b7cde4SSimon Wunderlich 				 enum ieee80211_band current_band,
1570c0f17eb9SChun-Yeow Yeoh 				 u32 sta_flags, u8 *bssid,
1571c0f17eb9SChun-Yeow Yeoh 				 struct ieee80211_csa_ie *csa_ie);
157239192c0bSJohannes Berg 
1573f2753ddbSJohannes Berg /* Suspend/resume and hw reconfiguration */
1574f2753ddbSJohannes Berg int ieee80211_reconfig(struct ieee80211_local *local);
157584f6a01cSJohannes Berg void ieee80211_stop_device(struct ieee80211_local *local);
1576f2753ddbSJohannes Berg 
1577eecc4800SJohannes Berg int __ieee80211_suspend(struct ieee80211_hw *hw,
1578eecc4800SJohannes Berg 			struct cfg80211_wowlan *wowlan);
1579f2753ddbSJohannes Berg 
1580f2753ddbSJohannes Berg static inline int __ieee80211_resume(struct ieee80211_hw *hw)
1581f2753ddbSJohannes Berg {
158285f72bc8SJohn W. Linville 	struct ieee80211_local *local = hw_to_local(hw);
158385f72bc8SJohn W. Linville 
158485f72bc8SJohn W. Linville 	WARN(test_bit(SCAN_HW_SCANNING, &local->scanning),
158585f72bc8SJohn W. Linville 		"%s: resume with hardware scan still in progress\n",
158685f72bc8SJohn W. Linville 		wiphy_name(hw->wiphy));
158785f72bc8SJohn W. Linville 
1588f2753ddbSJohannes Berg 	return ieee80211_reconfig(hw_to_local(hw));
1589f2753ddbSJohannes Berg }
1590665af4fcSBob Copeland 
1591c2d1560aSJohannes Berg /* utility functions/constants */
1592c2d1560aSJohannes Berg extern void *mac80211_wiphy_privid; /* for wiphy privid */
159371364716SRon Rindjunsky u8 *ieee80211_get_bssid(struct ieee80211_hdr *hdr, size_t len,
159405c914feSJohannes Berg 			enum nl80211_iftype type);
15954ee73f33SMichal Kazior int ieee80211_frame_duration(enum ieee80211_band band, size_t len,
1596438b61b7SSimon Wunderlich 			     int rate, int erp, int short_preamble,
1597438b61b7SSimon Wunderlich 			     int shift);
1598f698d856SJasper Bryant-Greene void mac80211_ev_michael_mic_failure(struct ieee80211_sub_if_data *sdata, int keyidx,
1599e6d6e342SJohannes Berg 				     struct ieee80211_hdr *hdr, const u8 *tsc,
1600e6d6e342SJohannes Berg 				     gfp_t gfp);
16013abead59SJohannes Berg void ieee80211_set_wmm_default(struct ieee80211_sub_if_data *sdata,
16023abead59SJohannes Berg 			       bool bss_notify);
160355de908aSJohannes Berg void ieee80211_xmit(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb,
160455de908aSJohannes Berg 		    enum ieee80211_band band);
1605cf6bb79aSHelmut Schaa 
160655de908aSJohannes Berg void __ieee80211_tx_skb_tid_band(struct ieee80211_sub_if_data *sdata,
160755de908aSJohannes Berg 				 struct sk_buff *skb, int tid,
160855de908aSJohannes Berg 				 enum ieee80211_band band);
160955de908aSJohannes Berg 
161055de908aSJohannes Berg static inline void
161155de908aSJohannes Berg ieee80211_tx_skb_tid_band(struct ieee80211_sub_if_data *sdata,
161255de908aSJohannes Berg 			  struct sk_buff *skb, int tid,
161355de908aSJohannes Berg 			  enum ieee80211_band band)
161455de908aSJohannes Berg {
161555de908aSJohannes Berg 	rcu_read_lock();
161655de908aSJohannes Berg 	__ieee80211_tx_skb_tid_band(sdata, skb, tid, band);
161755de908aSJohannes Berg 	rcu_read_unlock();
161855de908aSJohannes Berg }
161955de908aSJohannes Berg 
162055de908aSJohannes Berg static inline void ieee80211_tx_skb_tid(struct ieee80211_sub_if_data *sdata,
162155de908aSJohannes Berg 					struct sk_buff *skb, int tid)
162255de908aSJohannes Berg {
162355de908aSJohannes Berg 	struct ieee80211_chanctx_conf *chanctx_conf;
162455de908aSJohannes Berg 
162555de908aSJohannes Berg 	rcu_read_lock();
162655de908aSJohannes Berg 	chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
162755de908aSJohannes Berg 	if (WARN_ON(!chanctx_conf)) {
162855de908aSJohannes Berg 		rcu_read_unlock();
162955de908aSJohannes Berg 		kfree_skb(skb);
163055de908aSJohannes Berg 		return;
163155de908aSJohannes Berg 	}
163255de908aSJohannes Berg 
163355de908aSJohannes Berg 	__ieee80211_tx_skb_tid_band(sdata, skb, tid,
16344bf88530SJohannes Berg 				    chanctx_conf->def.chan->band);
163555de908aSJohannes Berg 	rcu_read_unlock();
163655de908aSJohannes Berg }
163755de908aSJohannes Berg 
163855de908aSJohannes Berg static inline void ieee80211_tx_skb(struct ieee80211_sub_if_data *sdata,
1639cf6bb79aSHelmut Schaa 				    struct sk_buff *skb)
1640cf6bb79aSHelmut Schaa {
1641cf6bb79aSHelmut Schaa 	/* Send all internal mgmt frames on VO. Accordingly set TID to 7. */
1642cf6bb79aSHelmut Schaa 	ieee80211_tx_skb_tid(sdata, skb, 7);
1643cf6bb79aSHelmut Schaa }
1644cf6bb79aSHelmut Schaa 
164535d865afSJohannes Berg u32 ieee802_11_parse_elems_crc(const u8 *start, size_t len, bool action,
1646d91f36dbSJohannes Berg 			       struct ieee802_11_elems *elems,
1647d91f36dbSJohannes Berg 			       u64 filter, u32 crc);
164835d865afSJohannes Berg static inline void ieee802_11_parse_elems(const u8 *start, size_t len,
164935d865afSJohannes Berg 					  bool action,
1650ddc4db2eSJohannes Berg 					  struct ieee802_11_elems *elems)
1651ddc4db2eSJohannes Berg {
1652b2e506bfSJohannes Berg 	ieee802_11_parse_elems_crc(start, len, action, elems, 0, 0);
1653ddc4db2eSJohannes Berg }
1654ddc4db2eSJohannes Berg 
1655520eb820SKalle Valo void ieee80211_dynamic_ps_enable_work(struct work_struct *work);
1656520eb820SKalle Valo void ieee80211_dynamic_ps_disable_work(struct work_struct *work);
1657520eb820SKalle Valo void ieee80211_dynamic_ps_timer(unsigned long data);
1658a97b77b9SVivek Natarajan void ieee80211_send_nullfunc(struct ieee80211_local *local,
1659a97b77b9SVivek Natarajan 			     struct ieee80211_sub_if_data *sdata,
1660a97b77b9SVivek Natarajan 			     int powersave);
16613cf335d5SKalle Valo void ieee80211_sta_rx_notify(struct ieee80211_sub_if_data *sdata,
16623cf335d5SKalle Valo 			     struct ieee80211_hdr *hdr);
16634e5ff376SFelix Fietkau void ieee80211_sta_tx_notify(struct ieee80211_sub_if_data *sdata,
166404ac3c0eSFelix Fietkau 			     struct ieee80211_hdr *hdr, bool ack);
1665520eb820SKalle Valo 
1666ce7c9111SKalle Valo void ieee80211_wake_queues_by_reason(struct ieee80211_hw *hw,
1667445ea4e8SJohannes Berg 				     unsigned long queues,
1668ce7c9111SKalle Valo 				     enum queue_stop_reason reason);
1669ce7c9111SKalle Valo void ieee80211_stop_queues_by_reason(struct ieee80211_hw *hw,
1670445ea4e8SJohannes Berg 				     unsigned long queues,
1671ce7c9111SKalle Valo 				     enum queue_stop_reason reason);
167296f5e66eSJohannes Berg void ieee80211_wake_queue_by_reason(struct ieee80211_hw *hw, int queue,
167396f5e66eSJohannes Berg 				    enum queue_stop_reason reason);
167496f5e66eSJohannes Berg void ieee80211_stop_queue_by_reason(struct ieee80211_hw *hw, int queue,
167596f5e66eSJohannes Berg 				    enum queue_stop_reason reason);
16763a25a8c8SJohannes Berg void ieee80211_propagate_queue_wake(struct ieee80211_local *local, int queue);
16778f77f384SJohannes Berg void ieee80211_add_pending_skb(struct ieee80211_local *local,
16788f77f384SJohannes Berg 			       struct sk_buff *skb);
1679b0b97a8aSJohannes Berg void ieee80211_add_pending_skbs_fn(struct ieee80211_local *local,
168050a9432dSJohannes Berg 				   struct sk_buff_head *skbs,
168150a9432dSJohannes Berg 				   void (*fn)(void *data), void *data);
168278307daaSJohannes Berg static inline void ieee80211_add_pending_skbs(struct ieee80211_local *local,
168378307daaSJohannes Berg 					      struct sk_buff_head *skbs)
168478307daaSJohannes Berg {
168578307daaSJohannes Berg 	ieee80211_add_pending_skbs_fn(local, skbs, NULL, NULL);
168678307daaSJohannes Berg }
168739ecc01dSJohannes Berg void ieee80211_flush_queues(struct ieee80211_local *local,
168839ecc01dSJohannes Berg 			    struct ieee80211_sub_if_data *sdata);
1689ce7c9111SKalle Valo 
169046900298SJohannes Berg void ieee80211_send_auth(struct ieee80211_sub_if_data *sdata,
1691700e8ea6SJouni Malinen 			 u16 transaction, u16 auth_alg, u16 status,
16924a3cb702SJohannes Berg 			 const u8 *extra, size_t extra_len, const u8 *bssid,
16931672c0e3SJohannes Berg 			 const u8 *da, const u8 *key, u8 key_len, u8 key_idx,
16941672c0e3SJohannes Berg 			 u32 tx_flags);
16956ae16775SAntonio Quartulli void ieee80211_send_deauth_disassoc(struct ieee80211_sub_if_data *sdata,
16966ae16775SAntonio Quartulli 				    const u8 *bssid, u16 stype, u16 reason,
16976ae16775SAntonio Quartulli 				    bool send_frame, u8 *frame_buf);
1698de95a54bSJohannes Berg int ieee80211_build_preq_ies(struct ieee80211_local *local, u8 *buffer,
1699c604b9f2SJohannes Berg 			     size_t buffer_len, const u8 *ie, size_t ie_len,
1700651b5225SJouni Malinen 			     enum ieee80211_band band, u32 rate_mask,
17012103dec1SSimon Wunderlich 			     struct cfg80211_chan_def *chandef);
1702a619a4c0SJuuso Oikarinen struct sk_buff *ieee80211_build_probe_req(struct ieee80211_sub_if_data *sdata,
170385a237feSJohannes Berg 					  u8 *dst, u32 ratemask,
17046b77863bSJohannes Berg 					  struct ieee80211_channel *chan,
1705a619a4c0SJuuso Oikarinen 					  const u8 *ssid, size_t ssid_len,
1706a806c558SPaul Stewart 					  const u8 *ie, size_t ie_len,
1707a806c558SPaul Stewart 					  bool directed);
170846900298SJohannes Berg void ieee80211_send_probe_req(struct ieee80211_sub_if_data *sdata, u8 *dst,
1709de95a54bSJohannes Berg 			      const u8 *ssid, size_t ssid_len,
1710a806c558SPaul Stewart 			      const u8 *ie, size_t ie_len,
17111672c0e3SJohannes Berg 			      u32 ratemask, bool directed, u32 tx_flags,
171255de908aSJohannes Berg 			      struct ieee80211_channel *channel, bool scan);
171346900298SJohannes Berg 
17142103dec1SSimon Wunderlich u32 ieee80211_sta_get_rates(struct ieee80211_sub_if_data *sdata,
171546900298SJohannes Berg 			    struct ieee802_11_elems *elems,
17169ebb61a2SAshok Nagarajan 			    enum ieee80211_band band, u32 *basic_rates);
1717687da132SEmmanuel Grumbach int __ieee80211_request_smps_mgd(struct ieee80211_sub_if_data *sdata,
1718687da132SEmmanuel Grumbach 				 enum ieee80211_smps_mode smps_mode);
1719687da132SEmmanuel Grumbach int __ieee80211_request_smps_ap(struct ieee80211_sub_if_data *sdata,
17200f78231bSJohannes Berg 				enum ieee80211_smps_mode smps_mode);
172104ecd257SJohannes Berg void ieee80211_recalc_smps(struct ieee80211_sub_if_data *sdata);
172221f659bfSEliad Peller void ieee80211_recalc_min_chandef(struct ieee80211_sub_if_data *sdata);
172346900298SJohannes Berg 
17248e664fb3SJohannes Berg size_t ieee80211_ie_split(const u8 *ies, size_t ielen,
17258e664fb3SJohannes Berg 			  const u8 *ids, int n_ids, size_t offset);
17268e664fb3SJohannes Berg size_t ieee80211_ie_split_vendor(const u8 *ies, size_t ielen, size_t offset);
1727ef96a842SBen Greear u8 *ieee80211_ie_build_ht_cap(u8 *pos, struct ieee80211_sta_ht_cap *ht_cap,
172842e7aa77SAlexander Simon 			      u16 cap);
1729074d46d1SJohannes Berg u8 *ieee80211_ie_build_ht_oper(u8 *pos, struct ieee80211_sta_ht_cap *ht_cap,
17304bf88530SJohannes Berg 			       const struct cfg80211_chan_def *chandef,
1731431e3154SAshok Nagarajan 			       u16 prot_mode);
1732ba0afa2fSMahesh Palivela u8 *ieee80211_ie_build_vht_cap(u8 *pos, struct ieee80211_sta_vht_cap *vht_cap,
1733ba0afa2fSMahesh Palivela 			       u32 cap);
17342103dec1SSimon Wunderlich int ieee80211_parse_bitrates(struct cfg80211_chan_def *chandef,
17352103dec1SSimon Wunderlich 			     const struct ieee80211_supported_band *sband,
17362103dec1SSimon Wunderlich 			     const u8 *srates, int srates_len, u32 *rates);
1737fc8a7321SJohannes Berg int ieee80211_add_srates_ie(struct ieee80211_sub_if_data *sdata,
17386b77863bSJohannes Berg 			    struct sk_buff *skb, bool need_basic,
17396b77863bSJohannes Berg 			    enum ieee80211_band band);
1740fc8a7321SJohannes Berg int ieee80211_add_ext_srates_ie(struct ieee80211_sub_if_data *sdata,
17416b77863bSJohannes Berg 				struct sk_buff *skb, bool need_basic,
17426b77863bSJohannes Berg 				enum ieee80211_band band);
17438e664fb3SJohannes Berg 
1744f444de05SJohannes Berg /* channel management */
17454bf88530SJohannes Berg void ieee80211_ht_oper_to_chandef(struct ieee80211_channel *control_chan,
17464a3cb702SJohannes Berg 				  const struct ieee80211_ht_operation *ht_oper,
17474bf88530SJohannes Berg 				  struct cfg80211_chan_def *chandef);
1748e6b7cde4SSimon Wunderlich u32 ieee80211_chandef_downgrade(struct cfg80211_chan_def *c);
1749f444de05SJohannes Berg 
1750d01a1e65SMichal Kazior int __must_check
1751d01a1e65SMichal Kazior ieee80211_vif_use_channel(struct ieee80211_sub_if_data *sdata,
17524bf88530SJohannes Berg 			  const struct cfg80211_chan_def *chandef,
1753d01a1e65SMichal Kazior 			  enum ieee80211_chanctx_mode mode);
17542c9b7359SJohannes Berg int __must_check
17552c9b7359SJohannes Berg ieee80211_vif_change_bandwidth(struct ieee80211_sub_if_data *sdata,
17562c9b7359SJohannes Berg 			       const struct cfg80211_chan_def *chandef,
17572c9b7359SJohannes Berg 			       u32 *changed);
175873da7d5bSSimon Wunderlich /* NOTE: only use ieee80211_vif_change_channel() for channel switch */
175973da7d5bSSimon Wunderlich int __must_check
176073da7d5bSSimon Wunderlich ieee80211_vif_change_channel(struct ieee80211_sub_if_data *sdata,
176173da7d5bSSimon Wunderlich 			     u32 *changed);
1762d01a1e65SMichal Kazior void ieee80211_vif_release_channel(struct ieee80211_sub_if_data *sdata);
17634d76d21bSJohannes Berg void ieee80211_vif_vlan_copy_chanctx(struct ieee80211_sub_if_data *sdata);
17641f4ac5a6SJohannes Berg void ieee80211_vif_copy_chanctx_to_vlans(struct ieee80211_sub_if_data *sdata,
17651f4ac5a6SJohannes Berg 					 bool clear);
1766d01a1e65SMichal Kazior 
176704ecd257SJohannes Berg void ieee80211_recalc_smps_chanctx(struct ieee80211_local *local,
176804ecd257SJohannes Berg 				   struct ieee80211_chanctx *chanctx);
1769164eb02dSSimon Wunderlich void ieee80211_recalc_radar_chanctx(struct ieee80211_local *local,
1770164eb02dSSimon Wunderlich 				    struct ieee80211_chanctx *chanctx);
177121f659bfSEliad Peller void ieee80211_recalc_chanctx_min_def(struct ieee80211_local *local,
177221f659bfSEliad Peller 				      struct ieee80211_chanctx *ctx);
1773164eb02dSSimon Wunderlich 
1774164eb02dSSimon Wunderlich void ieee80211_dfs_cac_timer(unsigned long data);
1775164eb02dSSimon Wunderlich void ieee80211_dfs_cac_timer_work(struct work_struct *work);
1776164eb02dSSimon Wunderlich void ieee80211_dfs_cac_cancel(struct ieee80211_local *local);
1777164eb02dSSimon Wunderlich void ieee80211_dfs_radar_detected_work(struct work_struct *work);
1778c6da674aSChun-Yeow Yeoh int ieee80211_send_action_csa(struct ieee80211_sub_if_data *sdata,
1779c6da674aSChun-Yeow Yeoh 			      struct cfg80211_csa_settings *csa_settings);
178004ecd257SJohannes Berg 
17812475b1ccSMax Stepanov bool ieee80211_cs_valid(const struct ieee80211_cipher_scheme *cs);
17822475b1ccSMax Stepanov bool ieee80211_cs_list_valid(const struct ieee80211_cipher_scheme *cs, int n);
17832475b1ccSMax Stepanov const struct ieee80211_cipher_scheme *
17842475b1ccSMax Stepanov ieee80211_cs_get(struct ieee80211_local *local, u32 cipher,
17852475b1ccSMax Stepanov 		 enum nl80211_iftype iftype);
17862475b1ccSMax Stepanov int ieee80211_cs_headroom(struct ieee80211_local *local,
17872475b1ccSMax Stepanov 			  struct cfg80211_crypto_settings *crypto,
17882475b1ccSMax Stepanov 			  enum nl80211_iftype iftype);
17892475b1ccSMax Stepanov 
1790f4ea83ddSJohannes Berg #ifdef CONFIG_MAC80211_NOINLINE
1791d9e8a70fSJohannes Berg #define debug_noinline noinline
1792d9e8a70fSJohannes Berg #else
1793d9e8a70fSJohannes Berg #define debug_noinline
1794d9e8a70fSJohannes Berg #endif
1795d9e8a70fSJohannes Berg 
1796f0706e82SJiri Benc #endif /* IEEE80211_I_H */
1797