xref: /openbmc/linux/net/mac80211/ieee80211_i.h (revision b4f286a1)
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 
5612d3952fSFelix Fietkau #define TU_TO_JIFFIES(x)	(usecs_to_jiffies((x) * 1024))
5712d3952fSFelix Fietkau #define TU_TO_EXP_TIME(x)	(jiffies + TU_TO_JIFFIES(x))
5820ad19d0SJohannes Berg 
591ea6f9c0SJohannes Berg /* power level hasn't been configured (or set to automatic) */
601ea6f9c0SJohannes Berg #define IEEE80211_UNSET_POWER_LEVEL	INT_MIN
611ea6f9c0SJohannes Berg 
62d6a4ed6fSArik Nemtsov /*
63d6a4ed6fSArik Nemtsov  * Some APs experience problems when working with U-APSD. Decrease the
64d6a4ed6fSArik Nemtsov  * probability of that happening by using legacy mode for all ACs but VO.
65d6a4ed6fSArik Nemtsov  * The AP that caused us trouble was a Cisco 4410N. It ignores our
66d6a4ed6fSArik Nemtsov  * setting, and always treats non-VO ACs as legacy.
67d6a4ed6fSArik Nemtsov  */
68ab13315aSKalle Valo #define IEEE80211_DEFAULT_UAPSD_QUEUES \
69d6a4ed6fSArik Nemtsov 	IEEE80211_WMM_IE_STA_QOSINFO_AC_VO
70ab13315aSKalle Valo 
71ab13315aSKalle Valo #define IEEE80211_DEFAULT_MAX_SP_LEN		\
72ab13315aSKalle Valo 	IEEE80211_WMM_IE_STA_QOSINFO_SP_ALL
73ab13315aSKalle Valo 
746ae16775SAntonio Quartulli #define IEEE80211_DEAUTH_FRAME_LEN	(24 /* hdr */ + 2 /* reason */)
756ae16775SAntonio Quartulli 
76f0706e82SJiri Benc struct ieee80211_fragment_entry {
77f0706e82SJiri Benc 	unsigned long first_frag_time;
78f0706e82SJiri Benc 	unsigned int seq;
79f0706e82SJiri Benc 	unsigned int rx_queue;
80f0706e82SJiri Benc 	unsigned int last_frag;
81f0706e82SJiri Benc 	unsigned int extra_len;
82f0706e82SJiri Benc 	struct sk_buff_head skb_list;
83f0706e82SJiri Benc 	int ccmp; /* Whether fragments were encrypted with CCMP */
84f0706e82SJiri Benc 	u8 last_pn[6]; /* PN of the last fragment if CCMP was used */
85f0706e82SJiri Benc };
86f0706e82SJiri Benc 
87f0706e82SJiri Benc 
88c2b13452SJohannes Berg struct ieee80211_bss {
89ef429dadSJohannes Berg 	u32 device_ts_beacon, device_ts_presp;
908c358bcdSJohannes Berg 
9143ac2ca3SJouni Malinen 	bool wmm_used;
92ab13315aSKalle Valo 	bool uapsd_supported;
9300d3f14cSJohannes Berg 
94f0706e82SJiri Benc #define IEEE80211_MAX_SUPP_RATES 32
95f0706e82SJiri Benc 	u8 supp_rates[IEEE80211_MAX_SUPP_RATES];
96f0706e82SJiri Benc 	size_t supp_rates_len;
97f0706e82SJiri Benc 
9800d3f14cSJohannes Berg 	/*
9925985edcSLucas De Marchi 	 * During association, we save an ERP value from a probe response so
1005628221cSDaniel Drake 	 * that we can feed ERP info to the driver when handling the
1015628221cSDaniel Drake 	 * association completes. these fields probably won't be up-to-date
10200d3f14cSJohannes Berg 	 * otherwise, you probably don't want to use them.
10300d3f14cSJohannes Berg 	 */
10400d3f14cSJohannes Berg 	bool has_erp_value;
1055628221cSDaniel Drake 	u8 erp_value;
106fcff4f10SPaul Stewart 
107fcff4f10SPaul Stewart 	/* Keep track of the corruption of the last beacon/probe response. */
108fcff4f10SPaul Stewart 	u8 corrupt_data;
109fcff4f10SPaul Stewart 
110fcff4f10SPaul Stewart 	/* Keep track of what bits of information we have valid info for. */
111fcff4f10SPaul Stewart 	u8 valid_data;
112fcff4f10SPaul Stewart };
113fcff4f10SPaul Stewart 
114fcff4f10SPaul Stewart /**
115fcff4f10SPaul Stewart  * enum ieee80211_corrupt_data_flags - BSS data corruption flags
116fcff4f10SPaul Stewart  * @IEEE80211_BSS_CORRUPT_BEACON: last beacon frame received was corrupted
117fcff4f10SPaul Stewart  * @IEEE80211_BSS_CORRUPT_PROBE_RESP: last probe response received was corrupted
118fcff4f10SPaul Stewart  *
119fcff4f10SPaul Stewart  * These are bss flags that are attached to a bss in the
120fcff4f10SPaul Stewart  * @corrupt_data field of &struct ieee80211_bss.
121fcff4f10SPaul Stewart  */
122fcff4f10SPaul Stewart enum ieee80211_bss_corrupt_data_flags {
123fcff4f10SPaul Stewart 	IEEE80211_BSS_CORRUPT_BEACON		= BIT(0),
124fcff4f10SPaul Stewart 	IEEE80211_BSS_CORRUPT_PROBE_RESP	= BIT(1)
125fcff4f10SPaul Stewart };
126fcff4f10SPaul Stewart 
127fcff4f10SPaul Stewart /**
128fcff4f10SPaul Stewart  * enum ieee80211_valid_data_flags - BSS valid data flags
129fcff4f10SPaul Stewart  * @IEEE80211_BSS_VALID_WMM: WMM/UAPSD data was gathered from non-corrupt IE
130fcff4f10SPaul Stewart  * @IEEE80211_BSS_VALID_RATES: Supported rates were gathered from non-corrupt IE
131fcff4f10SPaul Stewart  * @IEEE80211_BSS_VALID_ERP: ERP flag was gathered from non-corrupt IE
132fcff4f10SPaul Stewart  *
133fcff4f10SPaul Stewart  * These are bss flags that are attached to a bss in the
134fcff4f10SPaul Stewart  * @valid_data field of &struct ieee80211_bss.  They show which parts
135fcff4f10SPaul Stewart  * of the data structure were recieved as a result of an un-corrupted
136fcff4f10SPaul Stewart  * beacon/probe response.
137fcff4f10SPaul Stewart  */
138fcff4f10SPaul Stewart enum ieee80211_bss_valid_data_flags {
139fcff4f10SPaul Stewart 	IEEE80211_BSS_VALID_WMM			= BIT(1),
140fcff4f10SPaul Stewart 	IEEE80211_BSS_VALID_RATES		= BIT(2),
141fcff4f10SPaul Stewart 	IEEE80211_BSS_VALID_ERP			= BIT(3)
142f0706e82SJiri Benc };
143f0706e82SJiri Benc 
1449ae54c84SJohannes Berg typedef unsigned __bitwise__ ieee80211_tx_result;
1459ae54c84SJohannes Berg #define TX_CONTINUE	((__force ieee80211_tx_result) 0u)
1469ae54c84SJohannes Berg #define TX_DROP		((__force ieee80211_tx_result) 1u)
1479ae54c84SJohannes Berg #define TX_QUEUED	((__force ieee80211_tx_result) 2u)
1489ae54c84SJohannes Berg 
1495cf121c3SJohannes Berg #define IEEE80211_TX_UNICAST		BIT(1)
1505cf121c3SJohannes Berg #define IEEE80211_TX_PS_BUFFERED	BIT(2)
1519ae54c84SJohannes Berg 
1525cf121c3SJohannes Berg struct ieee80211_tx_data {
153f0706e82SJiri Benc 	struct sk_buff *skb;
154252b86c4SJohannes Berg 	struct sk_buff_head skbs;
155f0706e82SJiri Benc 	struct ieee80211_local *local;
156f0706e82SJiri Benc 	struct ieee80211_sub_if_data *sdata;
157f0706e82SJiri Benc 	struct sta_info *sta;
158f0706e82SJiri Benc 	struct ieee80211_key *key;
1595cf121c3SJohannes Berg 
160056cdd59SJohannes Berg 	unsigned int flags;
1615cf121c3SJohannes Berg };
1625cf121c3SJohannes Berg 
1635cf121c3SJohannes Berg 
1645cf121c3SJohannes Berg typedef unsigned __bitwise__ ieee80211_rx_result;
1655cf121c3SJohannes Berg #define RX_CONTINUE		((__force ieee80211_rx_result) 0u)
1665cf121c3SJohannes Berg #define RX_DROP_UNUSABLE	((__force ieee80211_rx_result) 1u)
1675cf121c3SJohannes Berg #define RX_DROP_MONITOR		((__force ieee80211_rx_result) 2u)
1685cf121c3SJohannes Berg #define RX_QUEUED		((__force ieee80211_rx_result) 3u)
1695cf121c3SJohannes Berg 
170554891e6SJohannes Berg /**
171554891e6SJohannes Berg  * enum ieee80211_packet_rx_flags - packet RX flags
172554891e6SJohannes Berg  * @IEEE80211_RX_RA_MATCH: frame is destined to interface currently processed
173554891e6SJohannes Berg  *	(incl. multicast frames)
174554891e6SJohannes Berg  * @IEEE80211_RX_FRAGMENTED: fragmented frame
175554891e6SJohannes Berg  * @IEEE80211_RX_AMSDU: a-MSDU packet
176554891e6SJohannes Berg  * @IEEE80211_RX_MALFORMED_ACTION_FRM: action frame is malformed
1774cfda47bSChristian Lamparter  * @IEEE80211_RX_DEFERRED_RELEASE: frame was subjected to receive reordering
178554891e6SJohannes Berg  *
179554891e6SJohannes Berg  * These are per-frame flags that are attached to a frame in the
180554891e6SJohannes Berg  * @rx_flags field of &struct ieee80211_rx_status.
181554891e6SJohannes Berg  */
182554891e6SJohannes Berg enum ieee80211_packet_rx_flags {
183554891e6SJohannes Berg 	IEEE80211_RX_RA_MATCH			= BIT(1),
184554891e6SJohannes Berg 	IEEE80211_RX_FRAGMENTED			= BIT(2),
185554891e6SJohannes Berg 	IEEE80211_RX_AMSDU			= BIT(3),
186554891e6SJohannes Berg 	IEEE80211_RX_MALFORMED_ACTION_FRM	= BIT(4),
1874cfda47bSChristian Lamparter 	IEEE80211_RX_DEFERRED_RELEASE		= BIT(5),
188554891e6SJohannes Berg };
189554891e6SJohannes Berg 
190554891e6SJohannes Berg /**
191554891e6SJohannes Berg  * enum ieee80211_rx_flags - RX data flags
192554891e6SJohannes Berg  *
193554891e6SJohannes Berg  * @IEEE80211_RX_CMNTR: received on cooked monitor already
194ee971924SJohannes Berg  * @IEEE80211_RX_BEACON_REPORTED: This frame was already reported
195ee971924SJohannes Berg  *	to cfg80211_report_obss_beacon().
196554891e6SJohannes Berg  *
197554891e6SJohannes Berg  * These flags are used across handling multiple interfaces
198554891e6SJohannes Berg  * for a single frame.
199554891e6SJohannes Berg  */
200554891e6SJohannes Berg enum ieee80211_rx_flags {
201554891e6SJohannes Berg 	IEEE80211_RX_CMNTR		= BIT(0),
202ee971924SJohannes Berg 	IEEE80211_RX_BEACON_REPORTED	= BIT(1),
203554891e6SJohannes Berg };
2045cf121c3SJohannes Berg 
2055cf121c3SJohannes Berg struct ieee80211_rx_data {
2065cf121c3SJohannes Berg 	struct sk_buff *skb;
2075cf121c3SJohannes Berg 	struct ieee80211_local *local;
2085cf121c3SJohannes Berg 	struct ieee80211_sub_if_data *sdata;
2095cf121c3SJohannes Berg 	struct sta_info *sta;
2105cf121c3SJohannes Berg 	struct ieee80211_key *key;
211056cdd59SJohannes Berg 
212056cdd59SJohannes Berg 	unsigned int flags;
2139e26297aSJohannes Berg 
2149e26297aSJohannes Berg 	/*
2159e26297aSJohannes Berg 	 * Index into sequence numbers array, 0..16
2169e26297aSJohannes Berg 	 * since the last (16) is used for non-QoS,
2179e26297aSJohannes Berg 	 * will be 16 on non-QoS frames.
2189e26297aSJohannes Berg 	 */
2199e26297aSJohannes Berg 	int seqno_idx;
2209e26297aSJohannes Berg 
2219e26297aSJohannes Berg 	/*
2229e26297aSJohannes Berg 	 * Index into the security IV/PN arrays, 0..16
2239e26297aSJohannes Berg 	 * since the last (16) is used for CCMP-encrypted
2249e26297aSJohannes Berg 	 * management frames, will be set to 16 on mgmt
2259e26297aSJohannes Berg 	 * frames and 0 on non-QoS frames.
2269e26297aSJohannes Berg 	 */
2279e26297aSJohannes Berg 	int security_idx;
2289e26297aSJohannes Berg 
22950741ae0SJohannes Berg 	u32 tkip_iv32;
23050741ae0SJohannes Berg 	u16 tkip_iv16;
231f0706e82SJiri Benc };
232f0706e82SJiri Benc 
2335dfdaf58SJohannes Berg struct beacon_data {
2345dfdaf58SJohannes Berg 	u8 *head, *tail;
2355dfdaf58SJohannes Berg 	int head_len, tail_len;
2368860020eSJohannes Berg 	struct rcu_head rcu_head;
2375dfdaf58SJohannes Berg };
2385dfdaf58SJohannes Berg 
239aa7a0080SEyal Shapira struct probe_resp {
240aa7a0080SEyal Shapira 	struct rcu_head rcu_head;
241aa7a0080SEyal Shapira 	int len;
242aa7a0080SEyal Shapira 	u8 data[0];
243aa7a0080SEyal Shapira };
244aa7a0080SEyal Shapira 
245d012a605SMarco Porsch struct ps_data {
246d012a605SMarco Porsch 	/* yes, this looks ugly, but guarantees that we can later use
247d012a605SMarco Porsch 	 * bitmap_empty :)
248d012a605SMarco Porsch 	 * NB: don't touch this bitmap, use sta_info_{set,clear}_tim_bit */
249d012a605SMarco Porsch 	u8 tim[sizeof(unsigned long) * BITS_TO_LONGS(IEEE80211_MAX_AID + 1)];
250d012a605SMarco Porsch 	struct sk_buff_head bc_buf;
251d012a605SMarco Porsch 	atomic_t num_sta_ps; /* number of stations in PS mode */
252d012a605SMarco Porsch 	int dtim_count;
253d012a605SMarco Porsch 	bool dtim_bc_mc;
254d012a605SMarco Porsch };
255d012a605SMarco Porsch 
256f0706e82SJiri Benc struct ieee80211_if_ap {
25740b275b6SJohannes Berg 	struct beacon_data __rcu *beacon;
258aa7a0080SEyal Shapira 	struct probe_resp __rcu *probe_resp;
259f0706e82SJiri Benc 
2600ec3ca44SJohannes Berg 	struct list_head vlans;
2610ec3ca44SJohannes Berg 
262d012a605SMarco Porsch 	struct ps_data ps;
263030ef8f8SFelix Fietkau 	atomic_t num_mcast_sta; /* number of stations receiving multicast */
264f0706e82SJiri Benc };
265f0706e82SJiri Benc 
266f0706e82SJiri Benc struct ieee80211_if_wds {
267f0706e82SJiri Benc 	struct sta_info *sta;
268056cdd59SJohannes Berg 	u8 remote_addr[ETH_ALEN];
269f0706e82SJiri Benc };
270f0706e82SJiri Benc 
271f0706e82SJiri Benc struct ieee80211_if_vlan {
2720ec3ca44SJohannes Berg 	struct list_head list;
273f14543eeSFelix Fietkau 
274f14543eeSFelix Fietkau 	/* used for all tx if the VLAN is configured to 4-addr mode */
27540b275b6SJohannes Berg 	struct sta_info __rcu *sta;
276f0706e82SJiri Benc };
277f0706e82SJiri Benc 
278ee385855SLuis Carlos Cobo struct mesh_stats {
279c8a61a7dSDaniel Walker 	__u32 fwded_mcast;		/* Mesh forwarded multicast frames */
280c8a61a7dSDaniel Walker 	__u32 fwded_unicast;		/* Mesh forwarded unicast frames */
281c8a61a7dSDaniel Walker 	__u32 fwded_frames;		/* Mesh total forwarded frames */
282ee385855SLuis Carlos Cobo 	__u32 dropped_frames_ttl;	/* Not transmitted since mesh_ttl == 0*/
283ee385855SLuis Carlos Cobo 	__u32 dropped_frames_no_route;	/* Not transmitted, no route found */
284cfee66b0SJavier Cardona 	__u32 dropped_frames_congestion;/* Not forwarded due to congestion */
285ee385855SLuis Carlos Cobo };
286ee385855SLuis Carlos Cobo 
287ee385855SLuis Carlos Cobo #define PREQ_Q_F_START		0x1
288ee385855SLuis Carlos Cobo #define PREQ_Q_F_REFRESH	0x2
289ee385855SLuis Carlos Cobo struct mesh_preq_queue {
290ee385855SLuis Carlos Cobo 	struct list_head list;
291ee385855SLuis Carlos Cobo 	u8 dst[ETH_ALEN];
292ee385855SLuis Carlos Cobo 	u8 flags;
293ee385855SLuis Carlos Cobo };
294ee385855SLuis Carlos Cobo 
2952eb278e0SJohannes Berg #if HZ/100 == 0
2962eb278e0SJohannes Berg #define IEEE80211_ROC_MIN_LEFT	1
2972eb278e0SJohannes Berg #else
2982eb278e0SJohannes Berg #define IEEE80211_ROC_MIN_LEFT	(HZ/100)
2992eb278e0SJohannes Berg #endif
30077fdaa12SJohannes Berg 
3012eb278e0SJohannes Berg struct ieee80211_roc_work {
30277fdaa12SJohannes Berg 	struct list_head list;
3032eb278e0SJohannes Berg 	struct list_head dependents;
304f679f65dSJohannes Berg 
3052eb278e0SJohannes Berg 	struct delayed_work work;
306af6b6374SJohannes Berg 
307af6b6374SJohannes Berg 	struct ieee80211_sub_if_data *sdata;
308af6b6374SJohannes Berg 
309f679f65dSJohannes Berg 	struct ieee80211_channel *chan;
310af6b6374SJohannes Berg 
3112eb278e0SJohannes Berg 	bool started, abort, hw_begun, notified;
312f679f65dSJohannes Berg 
3132eb278e0SJohannes Berg 	unsigned long hw_start_time;
314e4da8c37SJohannes Berg 
3152eb278e0SJohannes Berg 	u32 duration, req_duration;
316f30221e4SJohannes Berg 	struct sk_buff *frame;
31750febf6aSJohannes Berg 	u64 cookie, mgmt_tx_cookie;
318d339d5caSIlan Peer 	enum ieee80211_roc_type type;
31977fdaa12SJohannes Berg };
32077fdaa12SJohannes Berg 
32146900298SJohannes Berg /* flags used in struct ieee80211_if_managed.flags */
322ab1faeadSJohannes Berg enum ieee80211_sta_flags {
323b291ba11SJohannes Berg 	IEEE80211_STA_BEACON_POLL	= BIT(0),
324b291ba11SJohannes Berg 	IEEE80211_STA_CONNECTION_POLL	= BIT(1),
325b291ba11SJohannes Berg 	IEEE80211_STA_CONTROL_PORT	= BIT(2),
326a8243b72SJohannes Berg 	IEEE80211_STA_DISABLE_HT	= BIT(4),
327b291ba11SJohannes Berg 	IEEE80211_STA_CSA_RECEIVED	= BIT(5),
328b291ba11SJohannes Berg 	IEEE80211_STA_MFP_ENABLED	= BIT(6),
329ab13315aSKalle Valo 	IEEE80211_STA_UAPSD_ENABLED	= BIT(7),
330375177bfSVivek Natarajan 	IEEE80211_STA_NULLFUNC_ACKED	= BIT(8),
33117e4ec14SJouni Malinen 	IEEE80211_STA_RESET_SIGNAL_AVE	= BIT(9),
33224398e39SJohannes Berg 	IEEE80211_STA_DISABLE_40MHZ	= BIT(10),
333d545dabaSMahesh Palivela 	IEEE80211_STA_DISABLE_VHT	= BIT(11),
334f2d9d270SJohannes Berg 	IEEE80211_STA_DISABLE_80P80MHZ	= BIT(12),
335f2d9d270SJohannes Berg 	IEEE80211_STA_DISABLE_160MHZ	= BIT(13),
336ab1faeadSJohannes Berg };
337ab1faeadSJohannes Berg 
33866e67e41SJohannes Berg struct ieee80211_mgd_auth_data {
33966e67e41SJohannes Berg 	struct cfg80211_bss *bss;
34066e67e41SJohannes Berg 	unsigned long timeout;
34166e67e41SJohannes Berg 	int tries;
34266e67e41SJohannes Berg 	u16 algorithm, expected_transaction;
34366e67e41SJohannes Berg 
34466e67e41SJohannes Berg 	u8 key[WLAN_KEY_LEN_WEP104];
34566e67e41SJohannes Berg 	u8 key_len, key_idx;
34666e67e41SJohannes Berg 	bool done;
34789afe614SJohannes Berg 	bool timeout_started;
34866e67e41SJohannes Berg 
3496b8ece3aSJouni Malinen 	u16 sae_trans, sae_status;
3506b8ece3aSJouni Malinen 	size_t data_len;
3516b8ece3aSJouni Malinen 	u8 data[];
35266e67e41SJohannes Berg };
35366e67e41SJohannes Berg 
35466e67e41SJohannes Berg struct ieee80211_mgd_assoc_data {
35566e67e41SJohannes Berg 	struct cfg80211_bss *bss;
35666e67e41SJohannes Berg 	const u8 *supp_rates;
35766e67e41SJohannes Berg 
35866e67e41SJohannes Berg 	unsigned long timeout;
35966e67e41SJohannes Berg 	int tries;
36066e67e41SJohannes Berg 
36166e67e41SJohannes Berg 	u16 capability;
36266e67e41SJohannes Berg 	u8 prev_bssid[ETH_ALEN];
36366e67e41SJohannes Berg 	u8 ssid[IEEE80211_MAX_SSID_LEN];
36466e67e41SJohannes Berg 	u8 ssid_len;
36566e67e41SJohannes Berg 	u8 supp_rates_len;
36676f0303dSJohannes Berg 	bool wmm, uapsd;
367c65dd147SEmmanuel Grumbach 	bool have_beacon, need_beacon;
36866e67e41SJohannes Berg 	bool synced;
36989afe614SJohannes Berg 	bool timeout_started;
37066e67e41SJohannes Berg 
3719dde6423SJohannes Berg 	u8 ap_ht_param;
3729dde6423SJohannes Berg 
373b08fbbd8SJohannes Berg 	struct ieee80211_vht_cap ap_vht_cap;
374b08fbbd8SJohannes Berg 
37566e67e41SJohannes Berg 	size_t ie_len;
37666e67e41SJohannes Berg 	u8 ie[];
37766e67e41SJohannes Berg };
37866e67e41SJohannes Berg 
37946900298SJohannes Berg struct ieee80211_if_managed {
380056cdd59SJohannes Berg 	struct timer_list timer;
381b291ba11SJohannes Berg 	struct timer_list conn_mon_timer;
382b291ba11SJohannes Berg 	struct timer_list bcn_mon_timer;
383c481ec97SSujith 	struct timer_list chswitch_timer;
384b291ba11SJohannes Berg 	struct work_struct monitor_work;
385c481ec97SSujith 	struct work_struct chswitch_work;
3861e4dcd01SJuuso Oikarinen 	struct work_struct beacon_connection_loss_work;
387882a7c69SJohannes Berg 	struct work_struct csa_connection_drop_work;
38846900298SJohannes Berg 
3897ccc8bd7SFelix Fietkau 	unsigned long beacon_timeout;
390b291ba11SJohannes Berg 	unsigned long probe_timeout;
391a43abf29SMaxim Levitsky 	int probe_send_count;
39204ac3c0eSFelix Fietkau 	bool nullfunc_failed;
393682bd38bSJohannes Berg 	bool connection_loss;
394b291ba11SJohannes Berg 
39577fdaa12SJohannes Berg 	struct mutex mtx;
3960c1ad2caSJohannes Berg 	struct cfg80211_bss *associated;
39766e67e41SJohannes Berg 	struct ieee80211_mgd_auth_data *auth_data;
39866e67e41SJohannes Berg 	struct ieee80211_mgd_assoc_data *assoc_data;
39946900298SJohannes Berg 
40077fdaa12SJohannes Berg 	u8 bssid[ETH_ALEN];
40146900298SJohannes Berg 
402f0706e82SJiri Benc 	u16 aid;
403f0706e82SJiri Benc 
404965bedadSJohannes Berg 	bool powersave; /* powersave requested for this iface */
40505cb9108SJohannes Berg 	bool broken_ap; /* AP is broken -- turn off powersave */
406826262c3SJohannes Berg 	u8 dtim_period;
4070f78231bSJohannes Berg 	enum ieee80211_smps_mode req_smps, /* requested smps mode */
408d1f5b7a3SJohannes Berg 				 driver_smps_mode; /* smps mode request */
409d1f5b7a3SJohannes Berg 
410d1f5b7a3SJohannes Berg 	struct work_struct request_smps_work;
411965bedadSJohannes Berg 
412d6f2da5bSJiri Slaby 	unsigned int flags;
413f0706e82SJiri Benc 
414d8ec4433SJuuso Oikarinen 	bool beacon_crc_valid;
415d91f36dbSJohannes Berg 	u32 beacon_crc;
416d91f36dbSJohannes Berg 
4171672c0e3SJohannes Berg 	bool status_acked;
4181672c0e3SJohannes Berg 	bool status_received;
4191672c0e3SJohannes Berg 	__le16 status_fc;
4201672c0e3SJohannes Berg 
421fdfacf0aSJouni Malinen 	enum {
422fdfacf0aSJouni Malinen 		IEEE80211_MFP_DISABLED,
423fdfacf0aSJouni Malinen 		IEEE80211_MFP_OPTIONAL,
424fdfacf0aSJouni Malinen 		IEEE80211_MFP_REQUIRED
425fdfacf0aSJouni Malinen 	} mfp; /* management frame protection */
426fdfacf0aSJouni Malinen 
427dc41e4d4SEliad Peller 	/*
428dc41e4d4SEliad Peller 	 * Bitmask of enabled u-apsd queues,
429dc41e4d4SEliad Peller 	 * IEEE80211_WMM_IE_STA_QOSINFO_AC_BE & co. Needs a new association
430dc41e4d4SEliad Peller 	 * to take effect.
431dc41e4d4SEliad Peller 	 */
432dc41e4d4SEliad Peller 	unsigned int uapsd_queues;
433dc41e4d4SEliad Peller 
434dc41e4d4SEliad Peller 	/*
435dc41e4d4SEliad Peller 	 * Maximum number of buffered frames AP can deliver during a
436dc41e4d4SEliad Peller 	 * service period, IEEE80211_WMM_IE_STA_QOSINFO_SP_ALL or similar.
437dc41e4d4SEliad Peller 	 * Needs a new association to take effect.
438dc41e4d4SEliad Peller 	 */
439dc41e4d4SEliad Peller 	unsigned int uapsd_max_sp_len;
440dc41e4d4SEliad Peller 
441f0706e82SJiri Benc 	int wmm_last_param_set;
4429bc383deSJohannes Berg 
4439bc383deSJohannes Berg 	u8 use_4addr;
44417e4ec14SJouni Malinen 
44567baf663SJanusz Dziedzic 	s16 p2p_noa_index;
446488dd7b5SJohannes Berg 
44717e4ec14SJouni Malinen 	/* Signal strength from the last Beacon frame in the current BSS. */
44817e4ec14SJouni Malinen 	int last_beacon_signal;
44917e4ec14SJouni Malinen 
45017e4ec14SJouni Malinen 	/*
45117e4ec14SJouni Malinen 	 * Weighted average of the signal strength from Beacon frames in the
45217e4ec14SJouni Malinen 	 * current BSS. This is in units of 1/16 of the signal unit to maintain
45317e4ec14SJouni Malinen 	 * accuracy and to speed up calculations, i.e., the value need to be
45417e4ec14SJouni Malinen 	 * divided by 16 to get the actual value.
45517e4ec14SJouni Malinen 	 */
45617e4ec14SJouni Malinen 	int ave_beacon_signal;
45717e4ec14SJouni Malinen 
45817e4ec14SJouni Malinen 	/*
459391a200aSJouni Malinen 	 * Number of Beacon frames used in ave_beacon_signal. This can be used
460391a200aSJouni Malinen 	 * to avoid generating less reliable cqm events that would be based
461391a200aSJouni Malinen 	 * only on couple of received frames.
462391a200aSJouni Malinen 	 */
463391a200aSJouni Malinen 	unsigned int count_beacon_signal;
464391a200aSJouni Malinen 
465391a200aSJouni Malinen 	/*
46617e4ec14SJouni Malinen 	 * Last Beacon frame signal strength average (ave_beacon_signal / 16)
46717e4ec14SJouni Malinen 	 * that triggered a cqm event. 0 indicates that no event has been
46817e4ec14SJouni Malinen 	 * generated for the current association.
46917e4ec14SJouni Malinen 	 */
47017e4ec14SJouni Malinen 	int last_cqm_event_signal;
471615f7b9bSMeenakshi Venkataraman 
472615f7b9bSMeenakshi Venkataraman 	/*
473615f7b9bSMeenakshi Venkataraman 	 * State variables for keeping track of RSSI of the AP currently
474615f7b9bSMeenakshi Venkataraman 	 * connected to and informing driver when RSSI has gone
475615f7b9bSMeenakshi Venkataraman 	 * below/above a certain threshold.
476615f7b9bSMeenakshi Venkataraman 	 */
477615f7b9bSMeenakshi Venkataraman 	int rssi_min_thold, rssi_max_thold;
478615f7b9bSMeenakshi Venkataraman 	int last_ave_beacon_signal;
479ef96a842SBen Greear 
480ef96a842SBen Greear 	struct ieee80211_ht_cap ht_capa; /* configured ht-cap over-rides */
481ef96a842SBen Greear 	struct ieee80211_ht_cap ht_capa_mask; /* Valid parts of ht_capa */
482dd5ecfeaSJohannes Berg 	struct ieee80211_vht_cap vht_capa; /* configured VHT overrides */
483dd5ecfeaSJohannes Berg 	struct ieee80211_vht_cap vht_capa_mask; /* Valid parts of vht_capa */
484f0706e82SJiri Benc };
485f0706e82SJiri Benc 
48646900298SJohannes Berg struct ieee80211_if_ibss {
48746900298SJohannes Berg 	struct timer_list timer;
48846900298SJohannes Berg 
4897a17a33cSJohannes Berg 	struct mutex mtx;
4907a17a33cSJohannes Berg 
491af8cdcd8SJohannes Berg 	unsigned long last_scan_completed;
4925bb644a0SJohannes Berg 
493fbd2c8dcSTeemu Paasikivi 	u32 basic_rates;
494fbd2c8dcSTeemu Paasikivi 
495af8cdcd8SJohannes Berg 	bool fixed_bssid;
496af8cdcd8SJohannes Berg 	bool fixed_channel;
497fffd0934SJohannes Berg 	bool privacy;
49846900298SJohannes Berg 
499267335d6SAntonio Quartulli 	bool control_port;
5006abe0563SWill Hawkins 	unsigned int auth_frame_registrations;
501267335d6SAntonio Quartulli 
5024d196e4bSFelix Fietkau 	u8 bssid[ETH_ALEN] __aligned(2);
503af8cdcd8SJohannes Berg 	u8 ssid[IEEE80211_MAX_SSID_LEN];
504af8cdcd8SJohannes Berg 	u8 ssid_len, ie_len;
505af8cdcd8SJohannes Berg 	u8 *ie;
506af8cdcd8SJohannes Berg 	struct ieee80211_channel *channel;
50713c40c54SAlexander Simon 	enum nl80211_channel_type channel_type;
50846900298SJohannes Berg 
50946900298SJohannes Berg 	unsigned long ibss_join_req;
510af8cdcd8SJohannes Berg 	/* probe response/beacon for IBSS */
511c3ffeab4SJohannes Berg 	struct beacon_data __rcu *presp;
51246900298SJohannes Berg 
5138bf11d8dSJohannes Berg 	spinlock_t incomplete_lock;
5148bf11d8dSJohannes Berg 	struct list_head incomplete_stations;
5158bf11d8dSJohannes Berg 
51646900298SJohannes Berg 	enum {
51746900298SJohannes Berg 		IEEE80211_IBSS_MLME_SEARCH,
51846900298SJohannes Berg 		IEEE80211_IBSS_MLME_JOINED,
51946900298SJohannes Berg 	} state;
52046900298SJohannes Berg };
52146900298SJohannes Berg 
522dbf498fbSJavier Cardona /**
523dbf498fbSJavier Cardona  * struct ieee80211_mesh_sync_ops - Extensible synchronization framework interface
524dbf498fbSJavier Cardona  *
525dbf498fbSJavier Cardona  * these declarations define the interface, which enables
526dbf498fbSJavier Cardona  * vendor-specific mesh synchronization
527dbf498fbSJavier Cardona  *
528dbf498fbSJavier Cardona  */
529dbf498fbSJavier Cardona struct ieee802_11_elems;
530dbf498fbSJavier Cardona struct ieee80211_mesh_sync_ops {
531dbf498fbSJavier Cardona 	void (*rx_bcn_presp)(struct ieee80211_sub_if_data *sdata,
532dbf498fbSJavier Cardona 			     u16 stype,
533dbf498fbSJavier Cardona 			     struct ieee80211_mgmt *mgmt,
534dbf498fbSJavier Cardona 			     struct ieee802_11_elems *elems,
535dbf498fbSJavier Cardona 			     struct ieee80211_rx_status *rx_status);
536dbf498fbSJavier Cardona 	void (*adjust_tbtt)(struct ieee80211_sub_if_data *sdata);
537dbf498fbSJavier Cardona 	/* add other framework functions here */
538dbf498fbSJavier Cardona };
539dbf498fbSJavier Cardona 
540472dbc45SJohannes Berg struct ieee80211_if_mesh {
541472dbc45SJohannes Berg 	struct timer_list housekeeping_timer;
542472dbc45SJohannes Berg 	struct timer_list mesh_path_timer;
543e304bfd3SRui Paulo 	struct timer_list mesh_path_root_timer;
544472dbc45SJohannes Berg 
54518889231SJavier Cardona 	unsigned long wrkq_flags;
546472dbc45SJohannes Berg 
547472dbc45SJohannes Berg 	u8 mesh_id[IEEE80211_MAX_MESH_ID_LEN];
548472dbc45SJohannes Berg 	size_t mesh_id_len;
549472dbc45SJohannes Berg 	/* Active Path Selection Protocol Identifier */
5503491707aSRui Paulo 	u8 mesh_pp_id;
551472dbc45SJohannes Berg 	/* Active Path Selection Metric Identifier */
5523491707aSRui Paulo 	u8 mesh_pm_id;
553472dbc45SJohannes Berg 	/* Congestion Control Mode Identifier */
5543491707aSRui Paulo 	u8 mesh_cc_id;
5559e03fdfdSJavier Cardona 	/* Synchronization Protocol Identifier */
5563491707aSRui Paulo 	u8 mesh_sp_id;
5579e03fdfdSJavier Cardona 	/* Authentication Protocol Identifier */
5583491707aSRui Paulo 	u8 mesh_auth_id;
559d19b3bf6SRui Paulo 	/* Local mesh Sequence Number */
560d19b3bf6SRui Paulo 	u32 sn;
561472dbc45SJohannes Berg 	/* Last used PREQ ID */
562472dbc45SJohannes Berg 	u32 preq_id;
563472dbc45SJohannes Berg 	atomic_t mpaths;
564d19b3bf6SRui Paulo 	/* Timestamp of last SN update */
565d19b3bf6SRui Paulo 	unsigned long last_sn_update;
566dca7e943SThomas Pedersen 	/* Time when it's ok to send next PERR */
567dca7e943SThomas Pedersen 	unsigned long next_perr;
568dca7e943SThomas Pedersen 	/* Timestamp of last PREQ sent */
569472dbc45SJohannes Berg 	unsigned long last_preq;
570472dbc45SJohannes Berg 	struct mesh_rmc *rmc;
571472dbc45SJohannes Berg 	spinlock_t mesh_preq_queue_lock;
572472dbc45SJohannes Berg 	struct mesh_preq_queue preq_queue;
573472dbc45SJohannes Berg 	int preq_queue_len;
574472dbc45SJohannes Berg 	struct mesh_stats mshstats;
575472dbc45SJohannes Berg 	struct mesh_config mshcfg;
5761258d976SAshok Nagarajan 	atomic_t estab_plinks;
577472dbc45SJohannes Berg 	u32 mesh_seqnum;
578472dbc45SJohannes Berg 	bool accepting_plinks;
5795ee68e5bSJavier Cardona 	int num_gates;
5802b5e1967SThomas Pedersen 	struct beacon_data __rcu *beacon;
5812b5e1967SThomas Pedersen 	/* just protects beacon updates for now */
5822b5e1967SThomas Pedersen 	struct mutex mtx;
583581a8b0fSJavier Cardona 	const u8 *ie;
584581a8b0fSJavier Cardona 	u8 ie_len;
585b130e5ceSJavier Cardona 	enum {
586b130e5ceSJavier Cardona 		IEEE80211_MESH_SEC_NONE = 0x0,
587b130e5ceSJavier Cardona 		IEEE80211_MESH_SEC_AUTHED = 0x1,
588b130e5ceSJavier Cardona 		IEEE80211_MESH_SEC_SECURED = 0x2,
589b130e5ceSJavier Cardona 	} security;
590a6dad6a2SThomas Pedersen 	bool user_mpm;
591dbf498fbSJavier Cardona 	/* Extensible Synchronization Framework */
5928ba7acf3SJohannes Berg 	const struct ieee80211_mesh_sync_ops *sync_ops;
593dbf498fbSJavier Cardona 	s64 sync_offset_clockdrift_max;
594dbf498fbSJavier Cardona 	spinlock_t sync_offset_lock;
595dbf498fbSJavier Cardona 	bool adjusting_tbtt;
5963f52b7e3SMarco Porsch 	/* mesh power save */
5973f52b7e3SMarco Porsch 	enum nl80211_mesh_power_mode nonpeer_pm;
5983f52b7e3SMarco Porsch 	int ps_peers_light_sleep;
5993f52b7e3SMarco Porsch 	int ps_peers_deep_sleep;
6003f52b7e3SMarco Porsch 	struct ps_data ps;
601472dbc45SJohannes Berg };
602902acc78SJohannes Berg 
603902acc78SJohannes Berg #ifdef CONFIG_MAC80211_MESH
604472dbc45SJohannes Berg #define IEEE80211_IFSTA_MESH_CTR_INC(msh, name)	\
605472dbc45SJohannes Berg 	do { (msh)->mshstats.name++; } while (0)
606902acc78SJohannes Berg #else
607472dbc45SJohannes Berg #define IEEE80211_IFSTA_MESH_CTR_INC(msh, name) \
608902acc78SJohannes Berg 	do { } while (0)
609902acc78SJohannes Berg #endif
610f0706e82SJiri Benc 
611213cd118SJohannes Berg /**
612213cd118SJohannes Berg  * enum ieee80211_sub_if_data_flags - virtual interface flags
613213cd118SJohannes Berg  *
614213cd118SJohannes Berg  * @IEEE80211_SDATA_ALLMULTI: interface wants all multicast packets
615213cd118SJohannes Berg  * @IEEE80211_SDATA_PROMISC: interface is promisc
616213cd118SJohannes Berg  * @IEEE80211_SDATA_OPERATING_GMODE: operating in G-only mode
617213cd118SJohannes Berg  * @IEEE80211_SDATA_DONT_BRIDGE_PACKETS: bridge packets between
618213cd118SJohannes Berg  *	associated stations and deliver multicast frames both
619213cd118SJohannes Berg  *	back to wireless media and to the local net stack.
62095acac61SJohannes Berg  * @IEEE80211_SDATA_DISCONNECT_RESUME: Disconnect after resume.
6217b7eab6fSJohannes Berg  * @IEEE80211_SDATA_IN_DRIVER: indicates interface was added to driver
622213cd118SJohannes Berg  */
623213cd118SJohannes Berg enum ieee80211_sub_if_data_flags {
624213cd118SJohannes Berg 	IEEE80211_SDATA_ALLMULTI		= BIT(0),
625213cd118SJohannes Berg 	IEEE80211_SDATA_PROMISC			= BIT(1),
6267986cf95SJohannes Berg 	IEEE80211_SDATA_OPERATING_GMODE		= BIT(2),
6277986cf95SJohannes Berg 	IEEE80211_SDATA_DONT_BRIDGE_PACKETS	= BIT(3),
62895acac61SJohannes Berg 	IEEE80211_SDATA_DISCONNECT_RESUME	= BIT(4),
6297b7eab6fSJohannes Berg 	IEEE80211_SDATA_IN_DRIVER		= BIT(5),
630213cd118SJohannes Berg };
631213cd118SJohannes Berg 
63234d4bc4dSJohannes Berg /**
63334d4bc4dSJohannes Berg  * enum ieee80211_sdata_state_bits - virtual interface state bits
63434d4bc4dSJohannes Berg  * @SDATA_STATE_RUNNING: virtual interface is up & running; this
63534d4bc4dSJohannes Berg  *	mirrors netif_running() but is separate for interface type
63634d4bc4dSJohannes Berg  *	change handling while the interface is up
6375b714c6aSJohannes Berg  * @SDATA_STATE_OFFCHANNEL: This interface is currently in offchannel
6385b714c6aSJohannes Berg  *	mode, so queues are stopped
639d6a83228SJohannes Berg  * @SDATA_STATE_OFFCHANNEL_BEACON_STOPPED: Beaconing was stopped due
640d6a83228SJohannes Berg  *	to offchannel, reset when offchannel returns
64134d4bc4dSJohannes Berg  */
64234d4bc4dSJohannes Berg enum ieee80211_sdata_state_bits {
64334d4bc4dSJohannes Berg 	SDATA_STATE_RUNNING,
6445b714c6aSJohannes Berg 	SDATA_STATE_OFFCHANNEL,
645d6a83228SJohannes Berg 	SDATA_STATE_OFFCHANNEL_BEACON_STOPPED,
64634d4bc4dSJohannes Berg };
64734d4bc4dSJohannes Berg 
648d01a1e65SMichal Kazior /**
649d01a1e65SMichal Kazior  * enum ieee80211_chanctx_mode - channel context configuration mode
650d01a1e65SMichal Kazior  *
651d01a1e65SMichal Kazior  * @IEEE80211_CHANCTX_SHARED: channel context may be used by
652d01a1e65SMichal Kazior  *	multiple interfaces
653d01a1e65SMichal Kazior  * @IEEE80211_CHANCTX_EXCLUSIVE: channel context can be used
654d01a1e65SMichal Kazior  *	only by a single interface. This can be used for example for
655d01a1e65SMichal Kazior  *	non-fixed channel IBSS.
656d01a1e65SMichal Kazior  */
657d01a1e65SMichal Kazior enum ieee80211_chanctx_mode {
658d01a1e65SMichal Kazior 	IEEE80211_CHANCTX_SHARED,
659d01a1e65SMichal Kazior 	IEEE80211_CHANCTX_EXCLUSIVE
660d01a1e65SMichal Kazior };
661d01a1e65SMichal Kazior 
662d01a1e65SMichal Kazior struct ieee80211_chanctx {
663d01a1e65SMichal Kazior 	struct list_head list;
664d01a1e65SMichal Kazior 	struct rcu_head rcu_head;
665d01a1e65SMichal Kazior 
666d01a1e65SMichal Kazior 	enum ieee80211_chanctx_mode mode;
667d01a1e65SMichal Kazior 	int refcount;
6688a61af65SJohannes Berg 	bool driver_present;
669d01a1e65SMichal Kazior 
670d01a1e65SMichal Kazior 	struct ieee80211_chanctx_conf conf;
671d01a1e65SMichal Kazior };
672d01a1e65SMichal Kazior 
673f0706e82SJiri Benc struct ieee80211_sub_if_data {
674f0706e82SJiri Benc 	struct list_head list;
675f0706e82SJiri Benc 
676f0706e82SJiri Benc 	struct wireless_dev wdev;
677f0706e82SJiri Benc 
67811a843b7SJohannes Berg 	/* keys */
67911a843b7SJohannes Berg 	struct list_head key_list;
68011a843b7SJohannes Berg 
6813bff1865SYogesh Ashok Powar 	/* count for keys needing tailroom space allocation */
6823bff1865SYogesh Ashok Powar 	int crypto_tx_tailroom_needed_cnt;
6838d1f7ecdSJohannes Berg 	int crypto_tx_tailroom_pending_dec;
6848d1f7ecdSJohannes Berg 	struct delayed_work dec_tailroom_needed_wk;
6853bff1865SYogesh Ashok Powar 
686f0706e82SJiri Benc 	struct net_device *dev;
687f0706e82SJiri Benc 	struct ieee80211_local *local;
688f0706e82SJiri Benc 
68913262ffdSJiri Slaby 	unsigned int flags;
6907e9ed188SDaniel Drake 
69134d4bc4dSJohannes Berg 	unsigned long state;
69234d4bc4dSJohannes Berg 
693f0706e82SJiri Benc 	int drop_unencrypted;
694f0706e82SJiri Benc 
69547846c9bSJohannes Berg 	char name[IFNAMSIZ];
69647846c9bSJohannes Berg 
697f0706e82SJiri Benc 	/* Fragment table for host-based reassembly */
698f0706e82SJiri Benc 	struct ieee80211_fragment_entry	fragments[IEEE80211_FRAGMENT_MAX];
699f0706e82SJiri Benc 	unsigned int fragment_next;
700f0706e82SJiri Benc 
701b53be792SSimon Wunderlich 	/* TID bitmap for NoAck policy */
702b53be792SSimon Wunderlich 	u16 noack_map;
703b53be792SSimon Wunderlich 
70400e96decSYoni Divinsky 	/* bit field of ACM bits (BIT(802.1D tag)) */
70500e96decSYoni Divinsky 	u8 wmm_acm;
70600e96decSYoni Divinsky 
70740b275b6SJohannes Berg 	struct ieee80211_key __rcu *keys[NUM_DEFAULT_KEYS + NUM_DEFAULT_MGMT_KEYS];
70840b275b6SJohannes Berg 	struct ieee80211_key __rcu *default_unicast_key;
70940b275b6SJohannes Berg 	struct ieee80211_key __rcu *default_multicast_key;
71040b275b6SJohannes Berg 	struct ieee80211_key __rcu *default_mgmt_key;
711f0706e82SJiri Benc 
71294778280SJohannes Berg 	u16 sequence_number;
713a621fa4dSJohannes Berg 	__be16 control_port_protocol;
714a621fa4dSJohannes Berg 	bool control_port_no_encrypt;
71594778280SJohannes Berg 
71654bcbc69SJohannes Berg 	struct ieee80211_tx_queue_params tx_conf[IEEE80211_NUM_ACS];
717f6f3def3SEliad Peller 
71804ecd257SJohannes Berg 	/* used to reconfigure hardware SM PS */
71904ecd257SJohannes Berg 	struct work_struct recalc_smps;
72004ecd257SJohannes Berg 
72164592c8fSJohannes Berg 	struct work_struct work;
72235f20c14SJohannes Berg 	struct sk_buff_head skb_queue;
72335f20c14SJohannes Berg 
72404ecd257SJohannes Berg 	u8 needed_rx_chains;
72504ecd257SJohannes Berg 	enum ieee80211_smps_mode smps_mode;
72604ecd257SJohannes Berg 
7271ea6f9c0SJohannes Berg 	int user_power_level; /* in dBm */
7281ea6f9c0SJohannes Berg 	int ap_power_level; /* in dBm */
7291ea6f9c0SJohannes Berg 
730164eb02dSSimon Wunderlich 	bool radar_required;
731164eb02dSSimon Wunderlich 	struct delayed_work dfs_cac_timer_work;
732164eb02dSSimon Wunderlich 
7333e122be0SJohannes Berg 	/*
7343e122be0SJohannes Berg 	 * AP this belongs to: self in AP mode and
7353e122be0SJohannes Berg 	 * corresponding AP in VLAN mode, NULL for
7363e122be0SJohannes Berg 	 * all others (might be needed later in IBSS)
7373e122be0SJohannes Berg 	 */
7383e122be0SJohannes Berg 	struct ieee80211_if_ap *bss;
7393e122be0SJohannes Berg 
74037eb0b16SJouni Malinen 	/* bitmap of allowed (non-MCS) rate indexes for rate control */
74137eb0b16SJouni Malinen 	u32 rc_rateidx_mask[IEEE80211_NUM_BANDS];
74219468413SSimon Wunderlich 	u8  rc_rateidx_mcs_mask[IEEE80211_NUM_BANDS][IEEE80211_HT_MCS_MASK_LEN];
743f0706e82SJiri Benc 
744f0706e82SJiri Benc 	union {
745f0706e82SJiri Benc 		struct ieee80211_if_ap ap;
746f0706e82SJiri Benc 		struct ieee80211_if_wds wds;
747f0706e82SJiri Benc 		struct ieee80211_if_vlan vlan;
74846900298SJohannes Berg 		struct ieee80211_if_managed mgd;
74946900298SJohannes Berg 		struct ieee80211_if_ibss ibss;
750472dbc45SJohannes Berg 		struct ieee80211_if_mesh mesh;
7518cc9a739SMichael Wu 		u32 mntr_flags;
752f0706e82SJiri Benc 	} u;
753e9f207f0SJiri Benc 
75497f97b1fSJohannes Berg 	spinlock_t cleanup_stations_lock;
75597f97b1fSJohannes Berg 	struct list_head cleanup_stations;
75697f97b1fSJohannes Berg 	struct work_struct cleanup_stations_wk;
75797f97b1fSJohannes Berg 
758e9f207f0SJiri Benc #ifdef CONFIG_MAC80211_DEBUGFS
759e9f207f0SJiri Benc 	struct {
760295bafb4SBen Greear 		struct dentry *subdir_stations;
761f7e0104cSJohannes Berg 		struct dentry *default_unicast_key;
762f7e0104cSJohannes Berg 		struct dentry *default_multicast_key;
7633cfcf6acSJouni Malinen 		struct dentry *default_mgmt_key;
7647bcfaf2fSJohannes Berg 	} debugfs;
765e9f207f0SJiri Benc #endif
766529ba6e9SJohannes Berg 
76732bfd35dSJohannes Berg 	/* must be last, dynamically sized area in this! */
76832bfd35dSJohannes Berg 	struct ieee80211_vif vif;
769f0706e82SJiri Benc };
770f0706e82SJiri Benc 
77132bfd35dSJohannes Berg static inline
77232bfd35dSJohannes Berg struct ieee80211_sub_if_data *vif_to_sdata(struct ieee80211_vif *p)
77332bfd35dSJohannes Berg {
77432bfd35dSJohannes Berg 	return container_of(p, struct ieee80211_sub_if_data, vif);
77532bfd35dSJohannes Berg }
77632bfd35dSJohannes Berg 
77755de908aSJohannes Berg static inline enum ieee80211_band
77855de908aSJohannes Berg ieee80211_get_sdata_band(struct ieee80211_sub_if_data *sdata)
77955de908aSJohannes Berg {
78055de908aSJohannes Berg 	enum ieee80211_band band = IEEE80211_BAND_2GHZ;
78155de908aSJohannes Berg 	struct ieee80211_chanctx_conf *chanctx_conf;
78255de908aSJohannes Berg 
78355de908aSJohannes Berg 	rcu_read_lock();
78455de908aSJohannes Berg 	chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
78555de908aSJohannes Berg 	if (!WARN_ON(!chanctx_conf))
7864bf88530SJohannes Berg 		band = chanctx_conf->def.chan->band;
78755de908aSJohannes Berg 	rcu_read_unlock();
78855de908aSJohannes Berg 
78955de908aSJohannes Berg 	return band;
79055de908aSJohannes Berg }
79155de908aSJohannes Berg 
792c1475ca9SJohannes Berg enum sdata_queue_type {
793c1475ca9SJohannes Berg 	IEEE80211_SDATA_QUEUE_TYPE_FRAME	= 0,
794c1475ca9SJohannes Berg 	IEEE80211_SDATA_QUEUE_AGG_START		= 1,
795c1475ca9SJohannes Berg 	IEEE80211_SDATA_QUEUE_AGG_STOP		= 2,
796c1475ca9SJohannes Berg };
797c1475ca9SJohannes Berg 
798f0706e82SJiri Benc enum {
799f0706e82SJiri Benc 	IEEE80211_RX_MSG	= 1,
800f0706e82SJiri Benc 	IEEE80211_TX_STATUS_MSG	= 2,
801f0706e82SJiri Benc };
802f0706e82SJiri Benc 
803ce7c9111SKalle Valo enum queue_stop_reason {
804ce7c9111SKalle Valo 	IEEE80211_QUEUE_STOP_REASON_DRIVER,
805520eb820SKalle Valo 	IEEE80211_QUEUE_STOP_REASON_PS,
80696f5e66eSJohannes Berg 	IEEE80211_QUEUE_STOP_REASON_CSA,
80796f5e66eSJohannes Berg 	IEEE80211_QUEUE_STOP_REASON_AGGREGATION,
80825420604SJohannes Berg 	IEEE80211_QUEUE_STOP_REASON_SUSPEND,
8098f77f384SJohannes Berg 	IEEE80211_QUEUE_STOP_REASON_SKB_ADD,
8106c17b77bSSeth Forshee 	IEEE80211_QUEUE_STOP_REASON_OFFCHANNEL,
811445ea4e8SJohannes Berg 	IEEE80211_QUEUE_STOP_REASON_FLUSH,
812ce7c9111SKalle Valo };
813ce7c9111SKalle Valo 
81465a6538aSLuciano Coelho #ifdef CONFIG_MAC80211_LEDS
815e1e54068SJohannes Berg struct tpt_led_trigger {
816e1e54068SJohannes Berg 	struct led_trigger trig;
817e1e54068SJohannes Berg 	char name[32];
818e1e54068SJohannes Berg 	const struct ieee80211_tpt_blink *blink_table;
819e1e54068SJohannes Berg 	unsigned int blink_table_len;
820e1e54068SJohannes Berg 	struct timer_list timer;
821e1e54068SJohannes Berg 	unsigned long prev_traffic;
822e1e54068SJohannes Berg 	unsigned long tx_bytes, rx_bytes;
82367408c8cSJohannes Berg 	unsigned int active, want;
82467408c8cSJohannes Berg 	bool running;
825e1e54068SJohannes Berg };
82665a6538aSLuciano Coelho #endif
827e1e54068SJohannes Berg 
828142b9f50SHelmut Schaa /**
829142b9f50SHelmut Schaa  * mac80211 scan flags - currently active scan mode
830142b9f50SHelmut Schaa  *
831142b9f50SHelmut Schaa  * @SCAN_SW_SCANNING: We're currently in the process of scanning but may as
832142b9f50SHelmut Schaa  *	well be on the operating channel
833142b9f50SHelmut Schaa  * @SCAN_HW_SCANNING: The hardware is scanning for us, we have no way to
834142b9f50SHelmut Schaa  *	determine if we are on the operating channel or not
8358a690674SBen Greear  * @SCAN_ONCHANNEL_SCANNING:  Do a software scan on only the current operating
8368a690674SBen Greear  *	channel. This should not interrupt normal traffic.
8378789d459SJohannes Berg  * @SCAN_COMPLETED: Set for our scan work function when the driver reported
8388789d459SJohannes Berg  *	that the scan completed.
8398789d459SJohannes Berg  * @SCAN_ABORTED: Set for our scan work function when the driver reported
8408789d459SJohannes Berg  *	a scan complete for an aborted scan.
841142b9f50SHelmut Schaa  */
842fbe9c429SHelmut Schaa enum {
843fbe9c429SHelmut Schaa 	SCAN_SW_SCANNING,
844142b9f50SHelmut Schaa 	SCAN_HW_SCANNING,
8458a690674SBen Greear 	SCAN_ONCHANNEL_SCANNING,
8468789d459SJohannes Berg 	SCAN_COMPLETED,
8478789d459SJohannes Berg 	SCAN_ABORTED,
848142b9f50SHelmut Schaa };
849142b9f50SHelmut Schaa 
850142b9f50SHelmut Schaa /**
851142b9f50SHelmut Schaa  * enum mac80211_scan_state - scan state machine states
852142b9f50SHelmut Schaa  *
853142b9f50SHelmut Schaa  * @SCAN_DECISION: Main entry point to the scan state machine, this state
854142b9f50SHelmut Schaa  *	determines if we should keep on scanning or switch back to the
855142b9f50SHelmut Schaa  *	operating channel
856142b9f50SHelmut Schaa  * @SCAN_SET_CHANNEL: Set the next channel to be scanned
857142b9f50SHelmut Schaa  * @SCAN_SEND_PROBE: Send probe requests and wait for probe responses
85807ef03eeSJohannes Berg  * @SCAN_SUSPEND: Suspend the scan and go back to operating channel to
85907ef03eeSJohannes Berg  *	send out data
86007ef03eeSJohannes Berg  * @SCAN_RESUME: Resume the scan and scan the next channel
861cd2bb512SSam Leffler  * @SCAN_ABORT: Abort the scan and go back to operating channel
862142b9f50SHelmut Schaa  */
863142b9f50SHelmut Schaa enum mac80211_scan_state {
864142b9f50SHelmut Schaa 	SCAN_DECISION,
865142b9f50SHelmut Schaa 	SCAN_SET_CHANNEL,
866142b9f50SHelmut Schaa 	SCAN_SEND_PROBE,
86707ef03eeSJohannes Berg 	SCAN_SUSPEND,
86807ef03eeSJohannes Berg 	SCAN_RESUME,
869cd2bb512SSam Leffler 	SCAN_ABORT,
870fbe9c429SHelmut Schaa };
871fbe9c429SHelmut Schaa 
872f0706e82SJiri Benc struct ieee80211_local {
873f0706e82SJiri Benc 	/* embed the driver visible part.
874f0706e82SJiri Benc 	 * don't cast (use the static inlines below), but we keep
875f0706e82SJiri Benc 	 * it first anyway so they become a no-op */
876f0706e82SJiri Benc 	struct ieee80211_hw hw;
877f0706e82SJiri Benc 
878f0706e82SJiri Benc 	const struct ieee80211_ops *ops;
879f0706e82SJiri Benc 
88042935ecaSLuis R. Rodriguez 	/*
88142935ecaSLuis R. Rodriguez 	 * private workqueue to mac80211. mac80211 makes this accessible
88242935ecaSLuis R. Rodriguez 	 * via ieee80211_queue_work()
88342935ecaSLuis R. Rodriguez 	 */
88442935ecaSLuis R. Rodriguez 	struct workqueue_struct *workqueue;
88542935ecaSLuis R. Rodriguez 
886e4e72fb4SJohannes Berg 	unsigned long queue_stop_reasons[IEEE80211_MAX_QUEUES];
88796f5e66eSJohannes Berg 	/* also used to protect ampdu_ac_queue and amdpu_ac_stop_refcnt */
888ce7c9111SKalle Valo 	spinlock_t queue_stop_reason_lock;
88996f5e66eSJohannes Berg 
890f0706e82SJiri Benc 	int open_count;
8913d30d949SMichael Wu 	int monitors, cooked_mntrs;
8928cc9a739SMichael Wu 	/* number of interfaces with corresponding FIF_ flags */
8937be5086dSJohannes Berg 	int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss, fif_pspoll,
8947be5086dSJohannes Berg 	    fif_probe_req;
8957be5086dSJohannes Berg 	int probe_req_reg;
8964150c572SJohannes Berg 	unsigned int filter_flags; /* FIF_* */
8973b8d81e0SJohannes Berg 
8983ffc2a90SJohannes Berg 	bool wiphy_ciphers_allocated;
8993ffc2a90SJohannes Berg 
900fe57d9f5SJohannes Berg 	bool use_chanctx;
901fe57d9f5SJohannes Berg 
9023b8d81e0SJohannes Berg 	/* protects the aggregated multicast list and filter calls */
9033b8d81e0SJohannes Berg 	spinlock_t filter_lock;
9043b8d81e0SJohannes Berg 
9053ac64beeSJohannes Berg 	/* used for uploading changed mc list */
9063ac64beeSJohannes Berg 	struct work_struct reconfig_filter;
9073ac64beeSJohannes Berg 
9083b8d81e0SJohannes Berg 	/* aggregated multicast list */
90922bedad3SJiri Pirko 	struct netdev_hw_addr_list mc_list;
9103b8d81e0SJohannes Berg 
911d0709a65SJohannes Berg 	bool tim_in_locked_section; /* see ieee80211_beacon_get() */
9125bb644a0SJohannes Berg 
9135bb644a0SJohannes Berg 	/*
9145bb644a0SJohannes Berg 	 * suspended is true if we finished all the suspend _and_ we have
9155bb644a0SJohannes Berg 	 * not yet come up from resume. This is to be used by mac80211
9165bb644a0SJohannes Berg 	 * to ensure driver sanity during suspend and mac80211's own
9175bb644a0SJohannes Berg 	 * sanity. It can eventually be used for WoW as well.
9185bb644a0SJohannes Berg 	 */
9195bb644a0SJohannes Berg 	bool suspended;
9205bb644a0SJohannes Berg 
9215bb644a0SJohannes Berg 	/*
922ceb99fe0SJohannes Berg 	 * Resuming is true while suspended, but when we're reprogramming the
923ceb99fe0SJohannes Berg 	 * hardware -- at that time it's allowed to use ieee80211_queue_work()
924ceb99fe0SJohannes Berg 	 * again even though some other parts of the stack are still suspended
925ceb99fe0SJohannes Berg 	 * and we still drop received frames to avoid waking the stack.
926ceb99fe0SJohannes Berg 	 */
927ceb99fe0SJohannes Berg 	bool resuming;
928ceb99fe0SJohannes Berg 
929ceb99fe0SJohannes Berg 	/*
9305bb644a0SJohannes Berg 	 * quiescing is true during the suspend process _only_ to
9315bb644a0SJohannes Berg 	 * ease timer cancelling etc.
9325bb644a0SJohannes Berg 	 */
9335bb644a0SJohannes Berg 	bool quiescing;
9345bb644a0SJohannes Berg 
935ea77f12fSJohannes Berg 	/* device is started */
936ea77f12fSJohannes Berg 	bool started;
937ea77f12fSJohannes Berg 
93804800adaSArik Nemtsov 	/* device is during a HW reconfig */
93904800adaSArik Nemtsov 	bool in_reconfig;
94004800adaSArik Nemtsov 
941eecc4800SJohannes Berg 	/* wowlan is enabled -- don't reconfig on resume */
942eecc4800SJohannes Berg 	bool wowlan;
943eecc4800SJohannes Berg 
944164eb02dSSimon Wunderlich 	/* DFS/radar detection is enabled */
945164eb02dSSimon Wunderlich 	bool radar_detect_enabled;
946164eb02dSSimon Wunderlich 	struct work_struct radar_detected_work;
947164eb02dSSimon Wunderlich 
94804ecd257SJohannes Berg 	/* number of RX chains the hardware has */
94904ecd257SJohannes Berg 	u8 rx_chains;
95004ecd257SJohannes Berg 
951b306f453SJohannes Berg 	int tx_headroom; /* required headroom for hardware/radiotap */
952f0706e82SJiri Benc 
953f0706e82SJiri Benc 	/* Tasklet and skb queue to process calls from IRQ mode. All frames
954f0706e82SJiri Benc 	 * added to skb_queue will be processed, but frames in
955f0706e82SJiri Benc 	 * skb_queue_unreliable may be dropped if the total length of these
956f0706e82SJiri Benc 	 * queues increases over the limit. */
957f0706e82SJiri Benc #define IEEE80211_IRQSAFE_QUEUE_LIMIT 128
958f0706e82SJiri Benc 	struct tasklet_struct tasklet;
959f0706e82SJiri Benc 	struct sk_buff_head skb_queue;
960f0706e82SJiri Benc 	struct sk_buff_head skb_queue_unreliable;
961f0706e82SJiri Benc 
962f9e124fbSChristian Lamparter 	spinlock_t rx_path_lock;
96324a8fdadSChristian Lamparter 
964d0709a65SJohannes Berg 	/* Station data */
965d0709a65SJohannes Berg 	/*
9664d33960bSJohannes Berg 	 * The mutex only protects the list, hash table and
9674d33960bSJohannes Berg 	 * counter, reads are done with RCU.
968d0709a65SJohannes Berg 	 */
96934e89507SJohannes Berg 	struct mutex sta_mtx;
9704d33960bSJohannes Berg 	spinlock_t tim_lock;
971d0709a65SJohannes Berg 	unsigned long num_sta;
9724d33960bSJohannes Berg 	struct list_head sta_list;
97340b275b6SJohannes Berg 	struct sta_info __rcu *sta_hash[STA_HASH_SIZE];
974f0706e82SJiri Benc 	struct timer_list sta_cleanup;
975f5ea9120SJohannes Berg 	int sta_generation;
976f0706e82SJiri Benc 
9772a577d98SJohannes Berg 	struct sk_buff_head pending[IEEE80211_MAX_QUEUES];
978f0706e82SJiri Benc 	struct tasklet_struct tx_pending_tasklet;
979f0706e82SJiri Benc 
980a6a67db2SJohannes Berg 	atomic_t agg_queue_stop[IEEE80211_MAX_QUEUES];
981cd8ffc80SJohannes Berg 
982f0706e82SJiri Benc 	/* number of interfaces with corresponding IFF_ flags */
98353918994SJohannes Berg 	atomic_t iff_allmultis, iff_promiscs;
984f0706e82SJiri Benc 
985f0706e82SJiri Benc 	struct rate_control_ref *rate_ctrl;
986f0706e82SJiri Benc 
9875f9f1812SFelix Fietkau 	struct crypto_cipher *wep_tx_tfm;
9885f9f1812SFelix Fietkau 	struct crypto_cipher *wep_rx_tfm;
989f0706e82SJiri Benc 	u32 wep_iv;
990f0706e82SJiri Benc 
991c771c9d8SJohannes Berg 	/* see iface.c */
99279010420SJohannes Berg 	struct list_head interfaces;
993c771c9d8SJohannes Berg 	struct mutex iflist_mtx;
99479010420SJohannes Berg 
995b16bd15cSJohannes Berg 	/*
996ad0e2b5aSJohannes Berg 	 * Key mutex, protects sdata's key_list and sta_info's
997b16bd15cSJohannes Berg 	 * key pointers (write access, they're RCU.)
998b16bd15cSJohannes Berg 	 */
999ad0e2b5aSJohannes Berg 	struct mutex key_mtx;
1000b16bd15cSJohannes Berg 
1001a1699b75SJohannes Berg 	/* mutex for scan and work locking */
1002a1699b75SJohannes Berg 	struct mutex mtx;
1003b16bd15cSJohannes Berg 
1004c2b13452SJohannes Berg 	/* Scanning and BSS list */
1005fbe9c429SHelmut Schaa 	unsigned long scanning;
10062a519311SJohannes Berg 	struct cfg80211_ssid scan_ssid;
10075ba63533SJohannes Berg 	struct cfg80211_scan_request *int_scan_req;
10084d36ec58SJohannes Berg 	struct cfg80211_scan_request *scan_req, *hw_scan_req;
10092a519311SJohannes Berg 	struct ieee80211_channel *scan_channel;
10104d36ec58SJohannes Berg 	enum ieee80211_band hw_scan_band;
1011f0706e82SJiri Benc 	int scan_channel_idx;
1012de95a54bSJohannes Berg 	int scan_ies_len;
1013c604b9f2SJohannes Berg 	int hw_scan_ies_bufsize;
10148318d78aSJohannes Berg 
101585a9994aSLuciano Coelho 	struct work_struct sched_scan_stopped_work;
10165260a5b2SJohannes Berg 	struct ieee80211_sub_if_data __rcu *sched_scan_sdata;
101779f460caSLuciano Coelho 
1018df13cce5SHelmut Schaa 	unsigned long leave_oper_channel_time;
1019977923b0SHelmut Schaa 	enum mac80211_scan_state next_scan_state;
1020f0706e82SJiri Benc 	struct delayed_work scan_work;
1021e2fd5dbcSJohannes Berg 	struct ieee80211_sub_if_data __rcu *scan_sdata;
102255de908aSJohannes Berg 	struct ieee80211_channel *csa_channel;
102355de908aSJohannes Berg 	/* For backward compatibility only -- do not use */
1024675a0b04SKarl Beldan 	struct cfg80211_chan_def _oper_chandef;
1025f0706e82SJiri Benc 
1026b8bc4b0aSJohannes Berg 	/* Temporary remain-on-channel for off-channel operations */
1027b8bc4b0aSJohannes Berg 	struct ieee80211_channel *tmp_channel;
1028b8bc4b0aSJohannes Berg 
1029d01a1e65SMichal Kazior 	/* channel contexts */
1030d01a1e65SMichal Kazior 	struct list_head chanctx_list;
1031d01a1e65SMichal Kazior 	struct mutex chanctx_mtx;
1032d01a1e65SMichal Kazior 
1033f0706e82SJiri Benc 	/* SNMP counters */
1034f0706e82SJiri Benc 	/* dot11CountersTable */
1035f0706e82SJiri Benc 	u32 dot11TransmittedFragmentCount;
1036f0706e82SJiri Benc 	u32 dot11MulticastTransmittedFrameCount;
1037f0706e82SJiri Benc 	u32 dot11FailedCount;
1038f0706e82SJiri Benc 	u32 dot11RetryCount;
1039f0706e82SJiri Benc 	u32 dot11MultipleRetryCount;
1040f0706e82SJiri Benc 	u32 dot11FrameDuplicateCount;
1041f0706e82SJiri Benc 	u32 dot11ReceivedFragmentCount;
1042f0706e82SJiri Benc 	u32 dot11MulticastReceivedFrameCount;
1043f0706e82SJiri Benc 	u32 dot11TransmittedFrameCount;
1044f0706e82SJiri Benc 
1045f0706e82SJiri Benc #ifdef CONFIG_MAC80211_LEDS
1046f0706e82SJiri Benc 	int tx_led_counter, rx_led_counter;
1047cdcb006fSIvo van Doorn 	struct led_trigger *tx_led, *rx_led, *assoc_led, *radio_led;
1048e1e54068SJohannes Berg 	struct tpt_led_trigger *tpt_led_trigger;
1049cdcb006fSIvo van Doorn 	char tx_led_name[32], rx_led_name[32],
1050cdcb006fSIvo van Doorn 	     assoc_led_name[32], radio_led_name[32];
1051f0706e82SJiri Benc #endif
1052f0706e82SJiri Benc 
1053f0706e82SJiri Benc #ifdef CONFIG_MAC80211_DEBUG_COUNTERS
1054f0706e82SJiri Benc 	/* TX/RX handler statistics */
1055f0706e82SJiri Benc 	unsigned int tx_handlers_drop;
1056f0706e82SJiri Benc 	unsigned int tx_handlers_queued;
1057f0706e82SJiri Benc 	unsigned int tx_handlers_drop_unencrypted;
1058f0706e82SJiri Benc 	unsigned int tx_handlers_drop_fragment;
1059f0706e82SJiri Benc 	unsigned int tx_handlers_drop_wep;
1060f0706e82SJiri Benc 	unsigned int tx_handlers_drop_not_assoc;
1061f0706e82SJiri Benc 	unsigned int tx_handlers_drop_unauth_port;
1062f0706e82SJiri Benc 	unsigned int rx_handlers_drop;
1063f0706e82SJiri Benc 	unsigned int rx_handlers_queued;
1064f0706e82SJiri Benc 	unsigned int rx_handlers_drop_nullfunc;
1065f0706e82SJiri Benc 	unsigned int rx_handlers_drop_defrag;
1066f0706e82SJiri Benc 	unsigned int rx_handlers_drop_short;
1067f0706e82SJiri Benc 	unsigned int tx_expand_skb_head;
1068f0706e82SJiri Benc 	unsigned int tx_expand_skb_head_cloned;
1069f0706e82SJiri Benc 	unsigned int rx_expand_skb_head;
1070f0706e82SJiri Benc 	unsigned int rx_expand_skb_head2;
1071f0706e82SJiri Benc 	unsigned int rx_handlers_fragments;
1072f0706e82SJiri Benc 	unsigned int tx_status_drop;
1073f0706e82SJiri Benc #define I802_DEBUG_INC(c) (c)++
1074f0706e82SJiri Benc #else /* CONFIG_MAC80211_DEBUG_COUNTERS */
1075f0706e82SJiri Benc #define I802_DEBUG_INC(c) do { } while (0)
1076f0706e82SJiri Benc #endif /* CONFIG_MAC80211_DEBUG_COUNTERS */
1077f0706e82SJiri Benc 
1078f0706e82SJiri Benc 
1079f0706e82SJiri Benc 	int total_ps_buffered; /* total number of all buffered unicast and
1080f0706e82SJiri Benc 				* multicast packets for power saving stations
1081f0706e82SJiri Benc 				*/
1082520eb820SKalle Valo 
1083572e0012SKalle Valo 	bool pspolling;
1084b203ffc3SJouni Malinen 	bool offchannel_ps_enabled;
1085965bedadSJohannes Berg 	/*
1086965bedadSJohannes Berg 	 * PS can only be enabled when we have exactly one managed
1087965bedadSJohannes Berg 	 * interface (and monitors) in PS, this then points there.
1088965bedadSJohannes Berg 	 */
1089965bedadSJohannes Berg 	struct ieee80211_sub_if_data *ps_sdata;
1090520eb820SKalle Valo 	struct work_struct dynamic_ps_enable_work;
1091520eb820SKalle Valo 	struct work_struct dynamic_ps_disable_work;
1092520eb820SKalle Valo 	struct timer_list dynamic_ps_timer;
109310f644a4SJohannes Berg 	struct notifier_block network_latency_notifier;
10942b2c009eSJuuso Oikarinen 	struct notifier_block ifa_notifier;
1095a65240c1SJohannes Berg 	struct notifier_block ifa6_notifier;
1096f0706e82SJiri Benc 
1097ff616381SJuuso Oikarinen 	/*
1098ff616381SJuuso Oikarinen 	 * The dynamic ps timeout configured from user space via WEXT -
1099ff616381SJuuso Oikarinen 	 * this will override whatever chosen by mac80211 internally.
1100ff616381SJuuso Oikarinen 	 */
1101ff616381SJuuso Oikarinen 	int dynamic_ps_forced_timeout;
1102ff616381SJuuso Oikarinen 
11031ea6f9c0SJohannes Berg 	int user_power_level; /* in dBm, for all interfaces */
11042bf30fabSJohannes Berg 
11050f78231bSJohannes Berg 	enum ieee80211_smps_mode smps_mode;
11060f78231bSJohannes Berg 
1107f2753ddbSJohannes Berg 	struct work_struct restart_work;
1108f2753ddbSJohannes Berg 
1109e9f207f0SJiri Benc #ifdef CONFIG_MAC80211_DEBUGFS
1110e9f207f0SJiri Benc 	struct local_debugfsdentries {
11114b7679a5SJohannes Berg 		struct dentry *rcdir;
1112e9f207f0SJiri Benc 		struct dentry *keys;
1113e9f207f0SJiri Benc 	} debugfs;
1114e9f207f0SJiri Benc #endif
11154e6cbfd0SJohn W. Linville 
11162eb278e0SJohannes Berg 	/*
11172eb278e0SJohannes Berg 	 * Remain-on-channel support
11182eb278e0SJohannes Berg 	 */
11192eb278e0SJohannes Berg 	struct list_head roc_list;
112021f83589SJohannes Berg 	struct work_struct hw_roc_start, hw_roc_done;
11212eb278e0SJohannes Berg 	unsigned long hw_roc_start_time;
112250febf6aSJohannes Berg 	u64 roc_cookie_counter;
112321f83589SJohannes Berg 
1124a729cff8SJohannes Berg 	struct idr ack_status_frames;
1125a729cff8SJohannes Berg 	spinlock_t ack_status_lock;
1126a729cff8SJohannes Berg 
1127f142c6b9SJohannes Berg 	struct ieee80211_sub_if_data __rcu *p2p_sdata;
1128f142c6b9SJohannes Berg 
11294b6f1dd6SJohannes Berg 	/* virtual monitor interface */
11304b6f1dd6SJohannes Berg 	struct ieee80211_sub_if_data __rcu *monitor_sdata;
11314bf88530SJohannes Berg 	struct cfg80211_chan_def monitor_chandef;
1132f0706e82SJiri Benc };
1133f0706e82SJiri Benc 
11343e122be0SJohannes Berg static inline struct ieee80211_sub_if_data *
11353e122be0SJohannes Berg IEEE80211_DEV_TO_SUB_IF(struct net_device *dev)
11363e122be0SJohannes Berg {
11373e122be0SJohannes Berg 	return netdev_priv(dev);
11383e122be0SJohannes Berg }
11393e122be0SJohannes Berg 
114071bbc994SJohannes Berg static inline struct ieee80211_sub_if_data *
114171bbc994SJohannes Berg IEEE80211_WDEV_TO_SUB_IF(struct wireless_dev *wdev)
114271bbc994SJohannes Berg {
114371bbc994SJohannes Berg 	return container_of(wdev, struct ieee80211_sub_if_data, wdev);
114471bbc994SJohannes Berg }
114571bbc994SJohannes Berg 
1146c1475ca9SJohannes Berg /* this struct represents 802.11n's RA/TID combination */
1147eadc8d9eSRon Rindjunsky struct ieee80211_ra_tid {
1148eadc8d9eSRon Rindjunsky 	u8 ra[ETH_ALEN];
1149eadc8d9eSRon Rindjunsky 	u16 tid;
1150eadc8d9eSRon Rindjunsky };
1151eadc8d9eSRon Rindjunsky 
1152dd76986bSJohannes Berg /* Parsed Information Elements */
1153dd76986bSJohannes Berg struct ieee802_11_elems {
11544a3cb702SJohannes Berg 	const u8 *ie_start;
1155dd76986bSJohannes Berg 	size_t total_len;
1156dd76986bSJohannes Berg 
1157dd76986bSJohannes Berg 	/* pointers to IEs */
11584a3cb702SJohannes Berg 	const u8 *ssid;
11594a3cb702SJohannes Berg 	const u8 *supp_rates;
11604a3cb702SJohannes Berg 	const u8 *ds_params;
11614a3cb702SJohannes Berg 	const struct ieee80211_tim_ie *tim;
11624a3cb702SJohannes Berg 	const u8 *challenge;
11634a3cb702SJohannes Berg 	const u8 *rsn;
11644a3cb702SJohannes Berg 	const u8 *erp_info;
11654a3cb702SJohannes Berg 	const u8 *ext_supp_rates;
11664a3cb702SJohannes Berg 	const u8 *wmm_info;
11674a3cb702SJohannes Berg 	const u8 *wmm_param;
11684a3cb702SJohannes Berg 	const struct ieee80211_ht_cap *ht_cap_elem;
11694a3cb702SJohannes Berg 	const struct ieee80211_ht_operation *ht_operation;
11704a3cb702SJohannes Berg 	const struct ieee80211_vht_cap *vht_cap_elem;
11714a3cb702SJohannes Berg 	const struct ieee80211_vht_operation *vht_operation;
11724a3cb702SJohannes Berg 	const struct ieee80211_meshconf_ie *mesh_config;
11734a3cb702SJohannes Berg 	const u8 *mesh_id;
11744a3cb702SJohannes Berg 	const u8 *peering;
11754a3cb702SJohannes Berg 	const __le16 *awake_window;
11764a3cb702SJohannes Berg 	const u8 *preq;
11774a3cb702SJohannes Berg 	const u8 *prep;
11784a3cb702SJohannes Berg 	const u8 *perr;
11794a3cb702SJohannes Berg 	const struct ieee80211_rann_ie *rann;
11804a3cb702SJohannes Berg 	const struct ieee80211_channel_sw_ie *ch_switch_ie;
1181*b4f286a1SJohannes Berg 	const struct ieee80211_ext_chansw_ie *ext_chansw_ie;
11824a3cb702SJohannes Berg 	const u8 *country_elem;
11834a3cb702SJohannes Berg 	const u8 *pwr_constr_elem;
118479ba1d89SJohannes Berg 	const struct ieee80211_timeout_interval_ie *timeout_int;
11854a3cb702SJohannes Berg 	const u8 *opmode_notif;
1186dd76986bSJohannes Berg 
1187dd76986bSJohannes Berg 	/* length of them, respectively */
1188dd76986bSJohannes Berg 	u8 ssid_len;
1189dd76986bSJohannes Berg 	u8 supp_rates_len;
1190dd76986bSJohannes Berg 	u8 tim_len;
1191dd76986bSJohannes Berg 	u8 challenge_len;
1192dd76986bSJohannes Berg 	u8 rsn_len;
1193dd76986bSJohannes Berg 	u8 ext_supp_rates_len;
1194dd76986bSJohannes Berg 	u8 wmm_info_len;
1195dd76986bSJohannes Berg 	u8 wmm_param_len;
1196dd76986bSJohannes Berg 	u8 mesh_id_len;
1197dd76986bSJohannes Berg 	u8 peering_len;
1198dd76986bSJohannes Berg 	u8 preq_len;
1199dd76986bSJohannes Berg 	u8 prep_len;
1200dd76986bSJohannes Berg 	u8 perr_len;
1201dd76986bSJohannes Berg 	u8 country_elem_len;
1202fcff4f10SPaul Stewart 
1203fcff4f10SPaul Stewart 	/* whether a parse error occurred while retrieving these elements */
1204fcff4f10SPaul Stewart 	bool parse_error;
1205dd76986bSJohannes Berg };
1206dd76986bSJohannes Berg 
1207f0706e82SJiri Benc static inline struct ieee80211_local *hw_to_local(
1208f0706e82SJiri Benc 	struct ieee80211_hw *hw)
1209f0706e82SJiri Benc {
1210f0706e82SJiri Benc 	return container_of(hw, struct ieee80211_local, hw);
1211f0706e82SJiri Benc }
1212f0706e82SJiri Benc 
1213f0706e82SJiri Benc 
1214571ecf67SJohannes Berg static inline int ieee80211_bssid_match(const u8 *raddr, const u8 *addr)
1215571ecf67SJohannes Berg {
1216b203ca39SJoe Perches 	return ether_addr_equal(raddr, addr) ||
1217571ecf67SJohannes Berg 	       is_broadcast_ether_addr(raddr);
1218571ecf67SJohannes Berg }
1219571ecf67SJohannes Berg 
1220f4bda337SThomas Pedersen static inline bool
1221f4bda337SThomas Pedersen ieee80211_have_rx_timestamp(struct ieee80211_rx_status *status)
1222f4bda337SThomas Pedersen {
1223f4bda337SThomas Pedersen 	WARN_ON_ONCE(status->flag & RX_FLAG_MACTIME_START &&
1224f4bda337SThomas Pedersen 		     status->flag & RX_FLAG_MACTIME_END);
1225f4bda337SThomas Pedersen 	return status->flag & (RX_FLAG_MACTIME_START | RX_FLAG_MACTIME_END);
1226f4bda337SThomas Pedersen }
1227571ecf67SJohannes Berg 
1228f4bda337SThomas Pedersen u64 ieee80211_calculate_rx_timestamp(struct ieee80211_local *local,
1229f4bda337SThomas Pedersen 				     struct ieee80211_rx_status *status,
1230f4bda337SThomas Pedersen 				     unsigned int mpdu_len,
1231f4bda337SThomas Pedersen 				     unsigned int mpdu_offset);
1232e8975581SJohannes Berg int ieee80211_hw_config(struct ieee80211_local *local, u32 changed);
12335cf121c3SJohannes Berg void ieee80211_tx_set_protected(struct ieee80211_tx_data *tx);
12349c6bd790SJohannes Berg void ieee80211_bss_info_change_notify(struct ieee80211_sub_if_data *sdata,
12359c6bd790SJohannes Berg 				      u32 changed);
12360d143fe1SJohannes Berg void ieee80211_configure_filter(struct ieee80211_local *local);
123746900298SJohannes Berg u32 ieee80211_reset_erp_info(struct ieee80211_sub_if_data *sdata);
1238f0706e82SJiri Benc 
123946900298SJohannes Berg /* STA code */
12409c6bd790SJohannes Berg void ieee80211_sta_setup_sdata(struct ieee80211_sub_if_data *sdata);
124177fdaa12SJohannes Berg int ieee80211_mgd_auth(struct ieee80211_sub_if_data *sdata,
124277fdaa12SJohannes Berg 		       struct cfg80211_auth_request *req);
124377fdaa12SJohannes Berg int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata,
124477fdaa12SJohannes Berg 			struct cfg80211_assoc_request *req);
124577fdaa12SJohannes Berg int ieee80211_mgd_deauth(struct ieee80211_sub_if_data *sdata,
124663c9c5e7SJohannes Berg 			 struct cfg80211_deauth_request *req);
124777fdaa12SJohannes Berg int ieee80211_mgd_disassoc(struct ieee80211_sub_if_data *sdata,
124863c9c5e7SJohannes Berg 			   struct cfg80211_disassoc_request *req);
1249572e0012SKalle Valo void ieee80211_send_pspoll(struct ieee80211_local *local,
1250572e0012SKalle Valo 			   struct ieee80211_sub_if_data *sdata);
125110f644a4SJohannes Berg void ieee80211_recalc_ps(struct ieee80211_local *local, s32 latency);
1252ab095877SEliad Peller void ieee80211_recalc_ps_vif(struct ieee80211_sub_if_data *sdata);
125310f644a4SJohannes Berg int ieee80211_max_network_latency(struct notifier_block *nb,
125410f644a4SJohannes Berg 				  unsigned long data, void *dummy);
12552b2c009eSJuuso Oikarinen int ieee80211_set_arp_filter(struct ieee80211_sub_if_data *sdata);
12561fa57d01SJohannes Berg void ieee80211_sta_work(struct ieee80211_sub_if_data *sdata);
12571fa57d01SJohannes Berg void ieee80211_sta_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
12581fa57d01SJohannes Berg 				  struct sk_buff *skb);
1259d3a910a8SLuis R. Rodriguez void ieee80211_sta_reset_beacon_monitor(struct ieee80211_sub_if_data *sdata);
1260be099e82SLuis R. Rodriguez void ieee80211_sta_reset_conn_monitor(struct ieee80211_sub_if_data *sdata);
1261afa762f6SEliad Peller void ieee80211_mgd_stop(struct ieee80211_sub_if_data *sdata);
12621672c0e3SJohannes Berg void ieee80211_mgd_conn_tx_status(struct ieee80211_sub_if_data *sdata,
12631672c0e3SJohannes Berg 				  __le16 fc, bool acked);
12649c6bd790SJohannes Berg 
126546900298SJohannes Berg /* IBSS code */
126646900298SJohannes Berg void ieee80211_ibss_notify_scan_completed(struct ieee80211_local *local);
126746900298SJohannes Berg void ieee80211_ibss_setup_sdata(struct ieee80211_sub_if_data *sdata);
12688bf11d8dSJohannes Berg void ieee80211_ibss_rx_no_sta(struct ieee80211_sub_if_data *sdata,
12698bf11d8dSJohannes Berg 			      const u8 *bssid, const u8 *addr, u32 supp_rates);
1270af8cdcd8SJohannes Berg int ieee80211_ibss_join(struct ieee80211_sub_if_data *sdata,
1271af8cdcd8SJohannes Berg 			struct cfg80211_ibss_params *params);
1272af8cdcd8SJohannes Berg int ieee80211_ibss_leave(struct ieee80211_sub_if_data *sdata);
12731fa57d01SJohannes Berg void ieee80211_ibss_work(struct ieee80211_sub_if_data *sdata);
12741fa57d01SJohannes Berg void ieee80211_ibss_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
12751fa57d01SJohannes Berg 				   struct sk_buff *skb);
12761fa57d01SJohannes Berg 
12771fa57d01SJohannes Berg /* mesh code */
12781fa57d01SJohannes Berg void ieee80211_mesh_work(struct ieee80211_sub_if_data *sdata);
12791fa57d01SJohannes Berg void ieee80211_mesh_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
12801fa57d01SJohannes Berg 				   struct sk_buff *skb);
128146900298SJohannes Berg 
12829c6bd790SJohannes Berg /* scan/BSS handling */
128346900298SJohannes Berg void ieee80211_scan_work(struct work_struct *work);
128434bcf715SStanislaw Gruszka int ieee80211_request_ibss_scan(struct ieee80211_sub_if_data *sdata,
1285be4a4b6aSJohannes Berg 				const u8 *ssid, u8 ssid_len,
1286be4a4b6aSJohannes Berg 				struct ieee80211_channel *chan);
1287c2b13452SJohannes Berg int ieee80211_request_scan(struct ieee80211_sub_if_data *sdata,
12882a519311SJohannes Berg 			   struct cfg80211_scan_request *req);
12895bb644a0SJohannes Berg void ieee80211_scan_cancel(struct ieee80211_local *local);
1290133d40f9SStanislaw Gruszka void ieee80211_run_deferred_scan(struct ieee80211_local *local);
1291d48b2968SJohannes Berg void ieee80211_scan_rx(struct ieee80211_local *local, struct sk_buff *skb);
12929c6bd790SJohannes Berg 
12930a51b27eSJohannes Berg void ieee80211_mlme_notify_scan_completed(struct ieee80211_local *local);
1294c2b13452SJohannes Berg struct ieee80211_bss *
129598c8fccfSJohannes Berg ieee80211_bss_info_update(struct ieee80211_local *local,
129698c8fccfSJohannes Berg 			  struct ieee80211_rx_status *rx_status,
129798c8fccfSJohannes Berg 			  struct ieee80211_mgmt *mgmt,
129898c8fccfSJohannes Berg 			  size_t len,
129998c8fccfSJohannes Berg 			  struct ieee802_11_elems *elems,
1300d45c4172SEmmanuel Grumbach 			  struct ieee80211_channel *channel);
130198c8fccfSJohannes Berg void ieee80211_rx_bss_put(struct ieee80211_local *local,
1302c2b13452SJohannes Berg 			  struct ieee80211_bss *bss);
1303ee385855SLuis Carlos Cobo 
130479f460caSLuciano Coelho /* scheduled scan handling */
130579f460caSLuciano Coelho int ieee80211_request_sched_scan_start(struct ieee80211_sub_if_data *sdata,
130679f460caSLuciano Coelho 				       struct cfg80211_sched_scan_request *req);
130785a9994aSLuciano Coelho int ieee80211_request_sched_scan_stop(struct ieee80211_sub_if_data *sdata);
130885a9994aSLuciano Coelho void ieee80211_sched_scan_stopped_work(struct work_struct *work);
130979f460caSLuciano Coelho 
1310b203ffc3SJouni Malinen /* off-channel helpers */
1311aacde9eeSStanislaw Gruszka void ieee80211_offchannel_stop_vifs(struct ieee80211_local *local);
1312aacde9eeSStanislaw Gruszka void ieee80211_offchannel_return(struct ieee80211_local *local);
13132eb278e0SJohannes Berg void ieee80211_roc_setup(struct ieee80211_local *local);
13142eb278e0SJohannes Berg void ieee80211_start_next_roc(struct ieee80211_local *local);
1315c8f994eeSJohannes Berg void ieee80211_roc_purge(struct ieee80211_local *local,
1316c8f994eeSJohannes Berg 			 struct ieee80211_sub_if_data *sdata);
13172eb278e0SJohannes Berg void ieee80211_roc_notify_destroy(struct ieee80211_roc_work *roc);
13182eb278e0SJohannes Berg void ieee80211_sw_roc_work(struct work_struct *work);
13192eb278e0SJohannes Berg void ieee80211_handle_roc_started(struct ieee80211_roc_work *roc);
1320b203ffc3SJouni Malinen 
13213e122be0SJohannes Berg /* interface handling */
132247846c9bSJohannes Berg int ieee80211_iface_init(void);
132347846c9bSJohannes Berg void ieee80211_iface_exit(void);
13243e122be0SJohannes Berg int ieee80211_if_add(struct ieee80211_local *local, const char *name,
132584efbb84SJohannes Berg 		     struct wireless_dev **new_wdev, enum nl80211_iftype type,
1326ee385855SLuis Carlos Cobo 		     struct vif_params *params);
1327f3947e2dSJohannes Berg int ieee80211_if_change_type(struct ieee80211_sub_if_data *sdata,
132805c914feSJohannes Berg 			     enum nl80211_iftype type);
1329f698d856SJasper Bryant-Greene void ieee80211_if_remove(struct ieee80211_sub_if_data *sdata);
133075636525SJohannes Berg void ieee80211_remove_interfaces(struct ieee80211_local *local);
13315cff20e6SJohannes Berg void ieee80211_recalc_idle(struct ieee80211_local *local);
133285416a4fSChristian Lamparter void ieee80211_adjust_monitor_flags(struct ieee80211_sub_if_data *sdata,
133385416a4fSChristian Lamparter 				    const int offset);
1334f142c6b9SJohannes Berg int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up);
1335f142c6b9SJohannes Berg void ieee80211_sdata_stop(struct ieee80211_sub_if_data *sdata);
13363c3e21e7SJohannes Berg int ieee80211_add_virtual_monitor(struct ieee80211_local *local);
13373c3e21e7SJohannes Berg void ieee80211_del_virtual_monitor(struct ieee80211_local *local);
1338f0706e82SJiri Benc 
13391ea6f9c0SJohannes Berg bool __ieee80211_recalc_txpower(struct ieee80211_sub_if_data *sdata);
13401ea6f9c0SJohannes Berg void ieee80211_recalc_txpower(struct ieee80211_sub_if_data *sdata);
13411ea6f9c0SJohannes Berg 
13429607e6b6SJohannes Berg static inline bool ieee80211_sdata_running(struct ieee80211_sub_if_data *sdata)
13439607e6b6SJohannes Berg {
134434d4bc4dSJohannes Berg 	return test_bit(SDATA_STATE_RUNNING, &sdata->state);
13459607e6b6SJohannes Berg }
13469607e6b6SJohannes Berg 
1347e2ebc74dSJohannes Berg /* tx handling */
1348e2ebc74dSJohannes Berg void ieee80211_clear_tx_pending(struct ieee80211_local *local);
1349e2ebc74dSJohannes Berg void ieee80211_tx_pending(unsigned long data);
1350d0cf9c0dSStephen Hemminger netdev_tx_t ieee80211_monitor_start_xmit(struct sk_buff *skb,
1351d0cf9c0dSStephen Hemminger 					 struct net_device *dev);
1352d0cf9c0dSStephen Hemminger netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb,
1353d0cf9c0dSStephen Hemminger 				       struct net_device *dev);
13541f98ab7fSFelix Fietkau void ieee80211_purge_tx_queue(struct ieee80211_hw *hw,
13551f98ab7fSFelix Fietkau 			      struct sk_buff_head *skbs);
1356e2ebc74dSJohannes Berg 
1357de1ede7aSJohannes Berg /* HT */
1358ef96a842SBen Greear void ieee80211_apply_htcap_overrides(struct ieee80211_sub_if_data *sdata,
1359ef96a842SBen Greear 				     struct ieee80211_sta_ht_cap *ht_cap);
1360e1a0c6b3SJohannes Berg bool ieee80211_ht_cap_ie_to_sta_ht_cap(struct ieee80211_sub_if_data *sdata,
1361ef96a842SBen Greear 				       struct ieee80211_supported_band *sband,
13624a3cb702SJohannes Berg 				       const struct ieee80211_ht_cap *ht_cap_ie,
1363e1a0c6b3SJohannes Berg 				       struct sta_info *sta);
1364b8695a8fSJohannes Berg void ieee80211_send_delba(struct ieee80211_sub_if_data *sdata,
1365b8695a8fSJohannes Berg 			  const u8 *da, u16 tid,
1366b8695a8fSJohannes Berg 			  u16 initiator, u16 reason_code);
13670f78231bSJohannes Berg int ieee80211_send_smps_action(struct ieee80211_sub_if_data *sdata,
13680f78231bSJohannes Berg 			       enum ieee80211_smps_mode smps, const u8 *da,
13690f78231bSJohannes Berg 			       const u8 *bssid);
1370d1f5b7a3SJohannes Berg void ieee80211_request_smps_work(struct work_struct *work);
1371de1ede7aSJohannes Berg 
13727c3b1dd8SJohannes Berg void ___ieee80211_stop_rx_ba_session(struct sta_info *sta, u16 tid,
137353f73c09SJohannes Berg 				     u16 initiator, u16 reason, bool stop);
1374849b7967SJohannes Berg void __ieee80211_stop_rx_ba_session(struct sta_info *sta, u16 tid,
137553f73c09SJohannes Berg 				    u16 initiator, u16 reason, bool stop);
1376c82c4a80SJohannes Berg void ieee80211_sta_tear_down_BA_sessions(struct sta_info *sta,
1377c82c4a80SJohannes Berg 					 enum ieee80211_agg_stop_reason reason);
1378de1ede7aSJohannes Berg void ieee80211_process_delba(struct ieee80211_sub_if_data *sdata,
1379de1ede7aSJohannes Berg 			     struct sta_info *sta,
1380de1ede7aSJohannes Berg 			     struct ieee80211_mgmt *mgmt, size_t len);
1381de1ede7aSJohannes Berg void ieee80211_process_addba_resp(struct ieee80211_local *local,
1382de1ede7aSJohannes Berg 				  struct sta_info *sta,
1383de1ede7aSJohannes Berg 				  struct ieee80211_mgmt *mgmt,
1384de1ede7aSJohannes Berg 				  size_t len);
1385de1ede7aSJohannes Berg void ieee80211_process_addba_request(struct ieee80211_local *local,
1386de1ede7aSJohannes Berg 				     struct sta_info *sta,
1387de1ede7aSJohannes Berg 				     struct ieee80211_mgmt *mgmt,
1388de1ede7aSJohannes Berg 				     size_t len);
1389de1ede7aSJohannes Berg 
1390849b7967SJohannes Berg int __ieee80211_stop_tx_ba_session(struct sta_info *sta, u16 tid,
1391c82c4a80SJohannes Berg 				   enum ieee80211_agg_stop_reason reason);
139267c282c0SJohannes Berg int ___ieee80211_stop_tx_ba_session(struct sta_info *sta, u16 tid,
1393c82c4a80SJohannes Berg 				    enum ieee80211_agg_stop_reason reason);
13945d22c89bSJohannes Berg void ieee80211_start_tx_ba_cb(struct ieee80211_vif *vif, u8 *ra, u16 tid);
13955d22c89bSJohannes Berg void ieee80211_stop_tx_ba_cb(struct ieee80211_vif *vif, u8 *ra, u8 tid);
139667c282c0SJohannes Berg void ieee80211_ba_session_work(struct work_struct *work);
139767c282c0SJohannes Berg void ieee80211_tx_ba_session_handle_start(struct sta_info *sta, int tid);
13982bff8ebfSChristian Lamparter void ieee80211_release_reorder_timeout(struct sta_info *sta, int tid);
1399849b7967SJohannes Berg 
140004ecd257SJohannes Berg u8 ieee80211_mcs_to_chains(const struct ieee80211_mcs_info *mcs);
140104ecd257SJohannes Berg 
1402818255eaSMahesh Palivela /* VHT */
14034a3cb702SJohannes Berg void
14044a3cb702SJohannes Berg ieee80211_vht_cap_ie_to_sta_vht_cap(struct ieee80211_sub_if_data *sdata,
1405818255eaSMahesh Palivela 				    struct ieee80211_supported_band *sband,
14064a3cb702SJohannes Berg 				    const struct ieee80211_vht_cap *vht_cap_ie,
14074a34215eSJohannes Berg 				    struct sta_info *sta);
1408e1a0c6b3SJohannes Berg enum ieee80211_sta_rx_bandwidth ieee80211_sta_cur_vht_bw(struct sta_info *sta);
14098921d04eSJohannes Berg void ieee80211_sta_set_rx_nss(struct sta_info *sta);
14100af83d3dSJohannes Berg void ieee80211_vht_handle_opmode(struct ieee80211_sub_if_data *sdata,
14110af83d3dSJohannes Berg 				 struct sta_info *sta, u8 opmode,
1412bee7f586SJohannes Berg 				 enum ieee80211_band band, bool nss_only);
1413dd5ecfeaSJohannes Berg void ieee80211_apply_vhtcap_overrides(struct ieee80211_sub_if_data *sdata,
1414dd5ecfeaSJohannes Berg 				      struct ieee80211_sta_vht_cap *vht_cap);
14154a34215eSJohannes Berg 
141639192c0bSJohannes Berg /* Spectrum management */
141739192c0bSJohannes Berg void ieee80211_process_measurement_req(struct ieee80211_sub_if_data *sdata,
141839192c0bSJohannes Berg 				       struct ieee80211_mgmt *mgmt,
141939192c0bSJohannes Berg 				       size_t len);
142039192c0bSJohannes Berg 
1421f2753ddbSJohannes Berg /* Suspend/resume and hw reconfiguration */
1422f2753ddbSJohannes Berg int ieee80211_reconfig(struct ieee80211_local *local);
142384f6a01cSJohannes Berg void ieee80211_stop_device(struct ieee80211_local *local);
1424f2753ddbSJohannes Berg 
1425eecc4800SJohannes Berg int __ieee80211_suspend(struct ieee80211_hw *hw,
1426eecc4800SJohannes Berg 			struct cfg80211_wowlan *wowlan);
1427f2753ddbSJohannes Berg 
1428f2753ddbSJohannes Berg static inline int __ieee80211_resume(struct ieee80211_hw *hw)
1429f2753ddbSJohannes Berg {
143085f72bc8SJohn W. Linville 	struct ieee80211_local *local = hw_to_local(hw);
143185f72bc8SJohn W. Linville 
143285f72bc8SJohn W. Linville 	WARN(test_bit(SCAN_HW_SCANNING, &local->scanning),
143385f72bc8SJohn W. Linville 		"%s: resume with hardware scan still in progress\n",
143485f72bc8SJohn W. Linville 		wiphy_name(hw->wiphy));
143585f72bc8SJohn W. Linville 
1436f2753ddbSJohannes Berg 	return ieee80211_reconfig(hw_to_local(hw));
1437f2753ddbSJohannes Berg }
1438665af4fcSBob Copeland 
1439c2d1560aSJohannes Berg /* utility functions/constants */
1440c2d1560aSJohannes Berg extern void *mac80211_wiphy_privid; /* for wiphy privid */
144171364716SRon Rindjunsky u8 *ieee80211_get_bssid(struct ieee80211_hdr *hdr, size_t len,
144205c914feSJohannes Berg 			enum nl80211_iftype type);
14434ee73f33SMichal Kazior int ieee80211_frame_duration(enum ieee80211_band band, size_t len,
1444c2d1560aSJohannes Berg 			     int rate, int erp, int short_preamble);
1445f698d856SJasper Bryant-Greene void mac80211_ev_michael_mic_failure(struct ieee80211_sub_if_data *sdata, int keyidx,
1446e6d6e342SJohannes Berg 				     struct ieee80211_hdr *hdr, const u8 *tsc,
1447e6d6e342SJohannes Berg 				     gfp_t gfp);
14483abead59SJohannes Berg void ieee80211_set_wmm_default(struct ieee80211_sub_if_data *sdata,
14493abead59SJohannes Berg 			       bool bss_notify);
145055de908aSJohannes Berg void ieee80211_xmit(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb,
145155de908aSJohannes Berg 		    enum ieee80211_band band);
1452cf6bb79aSHelmut Schaa 
145355de908aSJohannes Berg void __ieee80211_tx_skb_tid_band(struct ieee80211_sub_if_data *sdata,
145455de908aSJohannes Berg 				 struct sk_buff *skb, int tid,
145555de908aSJohannes Berg 				 enum ieee80211_band band);
145655de908aSJohannes Berg 
145755de908aSJohannes Berg static inline void
145855de908aSJohannes Berg ieee80211_tx_skb_tid_band(struct ieee80211_sub_if_data *sdata,
145955de908aSJohannes Berg 			  struct sk_buff *skb, int tid,
146055de908aSJohannes Berg 			  enum ieee80211_band band)
146155de908aSJohannes Berg {
146255de908aSJohannes Berg 	rcu_read_lock();
146355de908aSJohannes Berg 	__ieee80211_tx_skb_tid_band(sdata, skb, tid, band);
146455de908aSJohannes Berg 	rcu_read_unlock();
146555de908aSJohannes Berg }
146655de908aSJohannes Berg 
146755de908aSJohannes Berg static inline void ieee80211_tx_skb_tid(struct ieee80211_sub_if_data *sdata,
146855de908aSJohannes Berg 					struct sk_buff *skb, int tid)
146955de908aSJohannes Berg {
147055de908aSJohannes Berg 	struct ieee80211_chanctx_conf *chanctx_conf;
147155de908aSJohannes Berg 
147255de908aSJohannes Berg 	rcu_read_lock();
147355de908aSJohannes Berg 	chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
147455de908aSJohannes Berg 	if (WARN_ON(!chanctx_conf)) {
147555de908aSJohannes Berg 		rcu_read_unlock();
147655de908aSJohannes Berg 		kfree_skb(skb);
147755de908aSJohannes Berg 		return;
147855de908aSJohannes Berg 	}
147955de908aSJohannes Berg 
148055de908aSJohannes Berg 	__ieee80211_tx_skb_tid_band(sdata, skb, tid,
14814bf88530SJohannes Berg 				    chanctx_conf->def.chan->band);
148255de908aSJohannes Berg 	rcu_read_unlock();
148355de908aSJohannes Berg }
148455de908aSJohannes Berg 
148555de908aSJohannes Berg static inline void ieee80211_tx_skb(struct ieee80211_sub_if_data *sdata,
1486cf6bb79aSHelmut Schaa 				    struct sk_buff *skb)
1487cf6bb79aSHelmut Schaa {
1488cf6bb79aSHelmut Schaa 	/* Send all internal mgmt frames on VO. Accordingly set TID to 7. */
1489cf6bb79aSHelmut Schaa 	ieee80211_tx_skb_tid(sdata, skb, 7);
1490cf6bb79aSHelmut Schaa }
1491cf6bb79aSHelmut Schaa 
1492d91f36dbSJohannes Berg u32 ieee802_11_parse_elems_crc(u8 *start, size_t len,
1493d91f36dbSJohannes Berg 			       struct ieee802_11_elems *elems,
1494d91f36dbSJohannes Berg 			       u64 filter, u32 crc);
1495ddc4db2eSJohannes Berg static inline void ieee802_11_parse_elems(u8 *start, size_t len,
1496ddc4db2eSJohannes Berg 					  struct ieee802_11_elems *elems)
1497ddc4db2eSJohannes Berg {
1498ddc4db2eSJohannes Berg 	ieee802_11_parse_elems_crc(start, len, elems, 0, 0);
1499ddc4db2eSJohannes Berg }
1500ddc4db2eSJohannes Berg 
1501881d948cSJohannes Berg u32 ieee80211_mandatory_rates(struct ieee80211_local *local,
150296dd22acSJohannes Berg 			      enum ieee80211_band band);
1503f0706e82SJiri Benc 
1504520eb820SKalle Valo void ieee80211_dynamic_ps_enable_work(struct work_struct *work);
1505520eb820SKalle Valo void ieee80211_dynamic_ps_disable_work(struct work_struct *work);
1506520eb820SKalle Valo void ieee80211_dynamic_ps_timer(unsigned long data);
1507a97b77b9SVivek Natarajan void ieee80211_send_nullfunc(struct ieee80211_local *local,
1508a97b77b9SVivek Natarajan 			     struct ieee80211_sub_if_data *sdata,
1509a97b77b9SVivek Natarajan 			     int powersave);
15103cf335d5SKalle Valo void ieee80211_sta_rx_notify(struct ieee80211_sub_if_data *sdata,
15113cf335d5SKalle Valo 			     struct ieee80211_hdr *hdr);
15124e5ff376SFelix Fietkau void ieee80211_sta_tx_notify(struct ieee80211_sub_if_data *sdata,
151304ac3c0eSFelix Fietkau 			     struct ieee80211_hdr *hdr, bool ack);
1514520eb820SKalle Valo 
1515ce7c9111SKalle Valo void ieee80211_wake_queues_by_reason(struct ieee80211_hw *hw,
1516445ea4e8SJohannes Berg 				     unsigned long queues,
1517ce7c9111SKalle Valo 				     enum queue_stop_reason reason);
1518ce7c9111SKalle Valo void ieee80211_stop_queues_by_reason(struct ieee80211_hw *hw,
1519445ea4e8SJohannes Berg 				     unsigned long queues,
1520ce7c9111SKalle Valo 				     enum queue_stop_reason reason);
152196f5e66eSJohannes Berg void ieee80211_wake_queue_by_reason(struct ieee80211_hw *hw, int queue,
152296f5e66eSJohannes Berg 				    enum queue_stop_reason reason);
152396f5e66eSJohannes Berg void ieee80211_stop_queue_by_reason(struct ieee80211_hw *hw, int queue,
152496f5e66eSJohannes Berg 				    enum queue_stop_reason reason);
15253a25a8c8SJohannes Berg void ieee80211_propagate_queue_wake(struct ieee80211_local *local, int queue);
15268f77f384SJohannes Berg void ieee80211_add_pending_skb(struct ieee80211_local *local,
15278f77f384SJohannes Berg 			       struct sk_buff *skb);
1528b0b97a8aSJohannes Berg void ieee80211_add_pending_skbs_fn(struct ieee80211_local *local,
152950a9432dSJohannes Berg 				   struct sk_buff_head *skbs,
153050a9432dSJohannes Berg 				   void (*fn)(void *data), void *data);
153178307daaSJohannes Berg static inline void ieee80211_add_pending_skbs(struct ieee80211_local *local,
153278307daaSJohannes Berg 					      struct sk_buff_head *skbs)
153378307daaSJohannes Berg {
153478307daaSJohannes Berg 	ieee80211_add_pending_skbs_fn(local, skbs, NULL, NULL);
153578307daaSJohannes Berg }
153639ecc01dSJohannes Berg void ieee80211_flush_queues(struct ieee80211_local *local,
153739ecc01dSJohannes Berg 			    struct ieee80211_sub_if_data *sdata);
1538ce7c9111SKalle Valo 
153946900298SJohannes Berg void ieee80211_send_auth(struct ieee80211_sub_if_data *sdata,
1540700e8ea6SJouni Malinen 			 u16 transaction, u16 auth_alg, u16 status,
15414a3cb702SJohannes Berg 			 const u8 *extra, size_t extra_len, const u8 *bssid,
15421672c0e3SJohannes Berg 			 const u8 *da, const u8 *key, u8 key_len, u8 key_idx,
15431672c0e3SJohannes Berg 			 u32 tx_flags);
15446ae16775SAntonio Quartulli void ieee80211_send_deauth_disassoc(struct ieee80211_sub_if_data *sdata,
15456ae16775SAntonio Quartulli 				    const u8 *bssid, u16 stype, u16 reason,
15466ae16775SAntonio Quartulli 				    bool send_frame, u8 *frame_buf);
1547de95a54bSJohannes Berg int ieee80211_build_preq_ies(struct ieee80211_local *local, u8 *buffer,
1548c604b9f2SJohannes Berg 			     size_t buffer_len, const u8 *ie, size_t ie_len,
1549651b5225SJouni Malinen 			     enum ieee80211_band band, u32 rate_mask,
1550651b5225SJouni Malinen 			     u8 channel);
1551a619a4c0SJuuso Oikarinen struct sk_buff *ieee80211_build_probe_req(struct ieee80211_sub_if_data *sdata,
155285a237feSJohannes Berg 					  u8 *dst, u32 ratemask,
15536b77863bSJohannes Berg 					  struct ieee80211_channel *chan,
1554a619a4c0SJuuso Oikarinen 					  const u8 *ssid, size_t ssid_len,
1555a806c558SPaul Stewart 					  const u8 *ie, size_t ie_len,
1556a806c558SPaul Stewart 					  bool directed);
155746900298SJohannes Berg void ieee80211_send_probe_req(struct ieee80211_sub_if_data *sdata, u8 *dst,
1558de95a54bSJohannes Berg 			      const u8 *ssid, size_t ssid_len,
1559a806c558SPaul Stewart 			      const u8 *ie, size_t ie_len,
15601672c0e3SJohannes Berg 			      u32 ratemask, bool directed, u32 tx_flags,
156155de908aSJohannes Berg 			      struct ieee80211_channel *channel, bool scan);
156246900298SJohannes Berg 
156346900298SJohannes Berg void ieee80211_sta_def_wmm_params(struct ieee80211_sub_if_data *sdata,
156446900298SJohannes Berg 				  const size_t supp_rates_len,
156546900298SJohannes Berg 				  const u8 *supp_rates);
156646900298SJohannes Berg u32 ieee80211_sta_get_rates(struct ieee80211_local *local,
156746900298SJohannes Berg 			    struct ieee802_11_elems *elems,
15689ebb61a2SAshok Nagarajan 			    enum ieee80211_band band, u32 *basic_rates);
15690f78231bSJohannes Berg int __ieee80211_request_smps(struct ieee80211_sub_if_data *sdata,
15700f78231bSJohannes Berg 			     enum ieee80211_smps_mode smps_mode);
157104ecd257SJohannes Berg void ieee80211_recalc_smps(struct ieee80211_sub_if_data *sdata);
157246900298SJohannes Berg 
15738e664fb3SJohannes Berg size_t ieee80211_ie_split(const u8 *ies, size_t ielen,
15748e664fb3SJohannes Berg 			  const u8 *ids, int n_ids, size_t offset);
15758e664fb3SJohannes Berg size_t ieee80211_ie_split_vendor(const u8 *ies, size_t ielen, size_t offset);
1576ef96a842SBen Greear u8 *ieee80211_ie_build_ht_cap(u8 *pos, struct ieee80211_sta_ht_cap *ht_cap,
157742e7aa77SAlexander Simon 			      u16 cap);
1578074d46d1SJohannes Berg u8 *ieee80211_ie_build_ht_oper(u8 *pos, struct ieee80211_sta_ht_cap *ht_cap,
15794bf88530SJohannes Berg 			       const struct cfg80211_chan_def *chandef,
1580431e3154SAshok Nagarajan 			       u16 prot_mode);
1581ba0afa2fSMahesh Palivela u8 *ieee80211_ie_build_vht_cap(u8 *pos, struct ieee80211_sta_vht_cap *vht_cap,
1582ba0afa2fSMahesh Palivela 			       u32 cap);
1583fc8a7321SJohannes Berg int ieee80211_add_srates_ie(struct ieee80211_sub_if_data *sdata,
15846b77863bSJohannes Berg 			    struct sk_buff *skb, bool need_basic,
15856b77863bSJohannes Berg 			    enum ieee80211_band band);
1586fc8a7321SJohannes Berg int ieee80211_add_ext_srates_ie(struct ieee80211_sub_if_data *sdata,
15876b77863bSJohannes Berg 				struct sk_buff *skb, bool need_basic,
15886b77863bSJohannes Berg 				enum ieee80211_band band);
15898e664fb3SJohannes Berg 
1590f444de05SJohannes Berg /* channel management */
15914bf88530SJohannes Berg void ieee80211_ht_oper_to_chandef(struct ieee80211_channel *control_chan,
15924a3cb702SJohannes Berg 				  const struct ieee80211_ht_operation *ht_oper,
15934bf88530SJohannes Berg 				  struct cfg80211_chan_def *chandef);
1594f444de05SJohannes Berg 
1595d01a1e65SMichal Kazior int __must_check
1596d01a1e65SMichal Kazior ieee80211_vif_use_channel(struct ieee80211_sub_if_data *sdata,
15974bf88530SJohannes Berg 			  const struct cfg80211_chan_def *chandef,
1598d01a1e65SMichal Kazior 			  enum ieee80211_chanctx_mode mode);
15992c9b7359SJohannes Berg int __must_check
16002c9b7359SJohannes Berg ieee80211_vif_change_bandwidth(struct ieee80211_sub_if_data *sdata,
16012c9b7359SJohannes Berg 			       const struct cfg80211_chan_def *chandef,
16022c9b7359SJohannes Berg 			       u32 *changed);
1603d01a1e65SMichal Kazior void ieee80211_vif_release_channel(struct ieee80211_sub_if_data *sdata);
16044d76d21bSJohannes Berg void ieee80211_vif_vlan_copy_chanctx(struct ieee80211_sub_if_data *sdata);
16051f4ac5a6SJohannes Berg void ieee80211_vif_copy_chanctx_to_vlans(struct ieee80211_sub_if_data *sdata,
16061f4ac5a6SJohannes Berg 					 bool clear);
1607d01a1e65SMichal Kazior 
160804ecd257SJohannes Berg void ieee80211_recalc_smps_chanctx(struct ieee80211_local *local,
160904ecd257SJohannes Berg 				   struct ieee80211_chanctx *chanctx);
1610164eb02dSSimon Wunderlich void ieee80211_recalc_radar_chanctx(struct ieee80211_local *local,
1611164eb02dSSimon Wunderlich 				    struct ieee80211_chanctx *chanctx);
1612164eb02dSSimon Wunderlich 
1613164eb02dSSimon Wunderlich void ieee80211_dfs_cac_timer(unsigned long data);
1614164eb02dSSimon Wunderlich void ieee80211_dfs_cac_timer_work(struct work_struct *work);
1615164eb02dSSimon Wunderlich void ieee80211_dfs_cac_cancel(struct ieee80211_local *local);
1616164eb02dSSimon Wunderlich void ieee80211_dfs_radar_detected_work(struct work_struct *work);
161704ecd257SJohannes Berg 
1618f4ea83ddSJohannes Berg #ifdef CONFIG_MAC80211_NOINLINE
1619d9e8a70fSJohannes Berg #define debug_noinline noinline
1620d9e8a70fSJohannes Berg #else
1621d9e8a70fSJohannes Berg #define debug_noinline
1622d9e8a70fSJohannes Berg #endif
1623d9e8a70fSJohannes Berg 
1624f0706e82SJiri Benc #endif /* IEEE80211_I_H */
1625