xref: /openbmc/linux/net/mac80211/ieee80211_i.h (revision 8ed28747)
1f0706e82SJiri Benc /*
2f0706e82SJiri Benc  * Copyright 2002-2005, Instant802 Networks, Inc.
3f0706e82SJiri Benc  * Copyright 2005, Devicescape Software, Inc.
4f0706e82SJiri Benc  * Copyright 2006-2007	Jiri Benc <jbenc@suse.cz>
5026331c4SJouni Malinen  * Copyright 2007-2010	Johannes Berg <johannes@sipsolutions.net>
6d98ad83eSJohannes Berg  * Copyright 2013-2014  Intel Mobile Communications GmbH
7f0706e82SJiri Benc  *
8f0706e82SJiri Benc  * This program is free software; you can redistribute it and/or modify
9f0706e82SJiri Benc  * it under the terms of the GNU General Public License version 2 as
10f0706e82SJiri Benc  * published by the Free Software Foundation.
11f0706e82SJiri Benc  */
12f0706e82SJiri Benc 
13f0706e82SJiri Benc #ifndef IEEE80211_I_H
14f0706e82SJiri Benc #define IEEE80211_I_H
15f0706e82SJiri Benc 
16f0706e82SJiri Benc #include <linux/kernel.h>
17f0706e82SJiri Benc #include <linux/device.h>
18f0706e82SJiri Benc #include <linux/if_ether.h>
19f0706e82SJiri Benc #include <linux/interrupt.h>
20f0706e82SJiri Benc #include <linux/list.h>
21f0706e82SJiri Benc #include <linux/netdevice.h>
22f0706e82SJiri Benc #include <linux/skbuff.h>
23f0706e82SJiri Benc #include <linux/workqueue.h>
24f0706e82SJiri Benc #include <linux/types.h>
25f0706e82SJiri Benc #include <linux/spinlock.h>
26571ecf67SJohannes Berg #include <linux/etherdevice.h>
27e1e54068SJohannes Berg #include <linux/leds.h>
28a729cff8SJohannes Berg #include <linux/idr.h>
29fe7a5d5cSJohannes Berg #include <net/ieee80211_radiotap.h>
3093da9cc1Scolin@cozybit.com #include <net/cfg80211.h>
3151cb6db0SDavid S. Miller #include <net/mac80211.h>
322c8dccc7SJohannes Berg #include "key.h"
33f0706e82SJiri Benc #include "sta_info.h"
34bdcbd8e0SJohannes Berg #include "debug.h"
35f0706e82SJiri Benc 
369cfb0009SJohannes Berg struct ieee80211_local;
37f0706e82SJiri Benc 
38f0706e82SJiri Benc /* Maximum number of broadcast/multicast frames to buffer when some of the
39f0706e82SJiri Benc  * associated stations are using power saving. */
40f0706e82SJiri Benc #define AP_MAX_BC_BUFFER 128
41f0706e82SJiri Benc 
42f0706e82SJiri Benc /* Maximum number of frames buffered to all STAs, including multicast frames.
43f0706e82SJiri Benc  * Note: increasing this limit increases the potential memory requirement. Each
44f0706e82SJiri Benc  * frame can be up to about 2 kB long. */
45f0706e82SJiri Benc #define TOTAL_MAX_TX_BUFFER 512
46f0706e82SJiri Benc 
47f0706e82SJiri Benc /* Required encryption head and tailroom */
48f0706e82SJiri Benc #define IEEE80211_ENCRYPT_HEADROOM 8
49765cb46aSJouni Malinen #define IEEE80211_ENCRYPT_TAILROOM 18
50f0706e82SJiri Benc 
51f0706e82SJiri Benc /* IEEE 802.11 (Ch. 9.5 Defragmentation) requires support for concurrent
52f0706e82SJiri Benc  * reception of at least three fragmented frames. This limit can be increased
53f0706e82SJiri Benc  * by changing this define, at the cost of slower frame reassembly and
54f0706e82SJiri Benc  * increased memory use (about 2 kB of RAM per entry). */
55f0706e82SJiri Benc #define IEEE80211_FRAGMENT_MAX 4
56f0706e82SJiri Benc 
571ea6f9c0SJohannes Berg /* power level hasn't been configured (or set to automatic) */
581ea6f9c0SJohannes Berg #define IEEE80211_UNSET_POWER_LEVEL	INT_MIN
591ea6f9c0SJohannes Berg 
60d6a4ed6fSArik Nemtsov /*
61d6a4ed6fSArik Nemtsov  * Some APs experience problems when working with U-APSD. Decrease the
62d6a4ed6fSArik Nemtsov  * probability of that happening by using legacy mode for all ACs but VO.
63d6a4ed6fSArik Nemtsov  * The AP that caused us trouble was a Cisco 4410N. It ignores our
64d6a4ed6fSArik Nemtsov  * setting, and always treats non-VO ACs as legacy.
65d6a4ed6fSArik Nemtsov  */
66ab13315aSKalle Valo #define IEEE80211_DEFAULT_UAPSD_QUEUES \
67d6a4ed6fSArik Nemtsov 	IEEE80211_WMM_IE_STA_QOSINFO_AC_VO
68ab13315aSKalle Valo 
69ab13315aSKalle Valo #define IEEE80211_DEFAULT_MAX_SP_LEN		\
70ab13315aSKalle Valo 	IEEE80211_WMM_IE_STA_QOSINFO_SP_ALL
71ab13315aSKalle Valo 
726ae16775SAntonio Quartulli #define IEEE80211_DEAUTH_FRAME_LEN	(24 /* hdr */ + 2 /* reason */)
736ae16775SAntonio Quartulli 
74f0706e82SJiri Benc struct ieee80211_fragment_entry {
75f0706e82SJiri Benc 	unsigned long first_frag_time;
76f0706e82SJiri Benc 	unsigned int seq;
77f0706e82SJiri Benc 	unsigned int rx_queue;
78f0706e82SJiri Benc 	unsigned int last_frag;
79f0706e82SJiri Benc 	unsigned int extra_len;
80f0706e82SJiri Benc 	struct sk_buff_head skb_list;
81f0706e82SJiri Benc 	int ccmp; /* Whether fragments were encrypted with CCMP */
82f0706e82SJiri Benc 	u8 last_pn[6]; /* PN of the last fragment if CCMP was used */
83f0706e82SJiri Benc };
84f0706e82SJiri Benc 
85f0706e82SJiri Benc 
86c2b13452SJohannes Berg struct ieee80211_bss {
87ef429dadSJohannes Berg 	u32 device_ts_beacon, device_ts_presp;
888c358bcdSJohannes Berg 
8943ac2ca3SJouni Malinen 	bool wmm_used;
90ab13315aSKalle Valo 	bool uapsd_supported;
9100d3f14cSJohannes Berg 
92f0706e82SJiri Benc #define IEEE80211_MAX_SUPP_RATES 32
93f0706e82SJiri Benc 	u8 supp_rates[IEEE80211_MAX_SUPP_RATES];
94f0706e82SJiri Benc 	size_t supp_rates_len;
95817cee76SAlexander Bondar 	struct ieee80211_rate *beacon_rate;
96f0706e82SJiri Benc 
9700d3f14cSJohannes Berg 	/*
9825985edcSLucas De Marchi 	 * During association, we save an ERP value from a probe response so
995628221cSDaniel Drake 	 * that we can feed ERP info to the driver when handling the
1005628221cSDaniel Drake 	 * association completes. these fields probably won't be up-to-date
10100d3f14cSJohannes Berg 	 * otherwise, you probably don't want to use them.
10200d3f14cSJohannes Berg 	 */
10300d3f14cSJohannes Berg 	bool has_erp_value;
1045628221cSDaniel Drake 	u8 erp_value;
105fcff4f10SPaul Stewart 
106fcff4f10SPaul Stewart 	/* Keep track of the corruption of the last beacon/probe response. */
107fcff4f10SPaul Stewart 	u8 corrupt_data;
108fcff4f10SPaul Stewart 
109fcff4f10SPaul Stewart 	/* Keep track of what bits of information we have valid info for. */
110fcff4f10SPaul Stewart 	u8 valid_data;
111fcff4f10SPaul Stewart };
112fcff4f10SPaul Stewart 
113fcff4f10SPaul Stewart /**
114fcff4f10SPaul Stewart  * enum ieee80211_corrupt_data_flags - BSS data corruption flags
115fcff4f10SPaul Stewart  * @IEEE80211_BSS_CORRUPT_BEACON: last beacon frame received was corrupted
116fcff4f10SPaul Stewart  * @IEEE80211_BSS_CORRUPT_PROBE_RESP: last probe response received was corrupted
117fcff4f10SPaul Stewart  *
118fcff4f10SPaul Stewart  * These are bss flags that are attached to a bss in the
119fcff4f10SPaul Stewart  * @corrupt_data field of &struct ieee80211_bss.
120fcff4f10SPaul Stewart  */
121fcff4f10SPaul Stewart enum ieee80211_bss_corrupt_data_flags {
122fcff4f10SPaul Stewart 	IEEE80211_BSS_CORRUPT_BEACON		= BIT(0),
123fcff4f10SPaul Stewart 	IEEE80211_BSS_CORRUPT_PROBE_RESP	= BIT(1)
124fcff4f10SPaul Stewart };
125fcff4f10SPaul Stewart 
126fcff4f10SPaul Stewart /**
127fcff4f10SPaul Stewart  * enum ieee80211_valid_data_flags - BSS valid data flags
128fcff4f10SPaul Stewart  * @IEEE80211_BSS_VALID_WMM: WMM/UAPSD data was gathered from non-corrupt IE
129fcff4f10SPaul Stewart  * @IEEE80211_BSS_VALID_RATES: Supported rates were gathered from non-corrupt IE
130fcff4f10SPaul Stewart  * @IEEE80211_BSS_VALID_ERP: ERP flag was gathered from non-corrupt IE
131fcff4f10SPaul Stewart  *
132fcff4f10SPaul Stewart  * These are bss flags that are attached to a bss in the
133fcff4f10SPaul Stewart  * @valid_data field of &struct ieee80211_bss.  They show which parts
134d070f913SStephen Hemminger  * of the data structure were received as a result of an un-corrupted
135fcff4f10SPaul Stewart  * beacon/probe response.
136fcff4f10SPaul Stewart  */
137fcff4f10SPaul Stewart enum ieee80211_bss_valid_data_flags {
138fcff4f10SPaul Stewart 	IEEE80211_BSS_VALID_WMM			= BIT(1),
139fcff4f10SPaul Stewart 	IEEE80211_BSS_VALID_RATES		= BIT(2),
140fcff4f10SPaul Stewart 	IEEE80211_BSS_VALID_ERP			= BIT(3)
141f0706e82SJiri Benc };
142f0706e82SJiri Benc 
1439ae54c84SJohannes Berg typedef unsigned __bitwise__ ieee80211_tx_result;
1449ae54c84SJohannes Berg #define TX_CONTINUE	((__force ieee80211_tx_result) 0u)
1459ae54c84SJohannes Berg #define TX_DROP		((__force ieee80211_tx_result) 1u)
1469ae54c84SJohannes Berg #define TX_QUEUED	((__force ieee80211_tx_result) 2u)
1479ae54c84SJohannes Berg 
1485cf121c3SJohannes Berg #define IEEE80211_TX_UNICAST		BIT(1)
1495cf121c3SJohannes Berg #define IEEE80211_TX_PS_BUFFERED	BIT(2)
1509ae54c84SJohannes Berg 
1515cf121c3SJohannes Berg struct ieee80211_tx_data {
152f0706e82SJiri Benc 	struct sk_buff *skb;
153252b86c4SJohannes Berg 	struct sk_buff_head skbs;
154f0706e82SJiri Benc 	struct ieee80211_local *local;
155f0706e82SJiri Benc 	struct ieee80211_sub_if_data *sdata;
156f0706e82SJiri Benc 	struct sta_info *sta;
157f0706e82SJiri Benc 	struct ieee80211_key *key;
1580d528d85SFelix Fietkau 	struct ieee80211_tx_rate rate;
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 
233af296bdbSMichal Kazior struct ieee80211_csa_settings {
234af296bdbSMichal Kazior 	const u16 *counter_offsets_beacon;
235af296bdbSMichal Kazior 	const u16 *counter_offsets_presp;
236af296bdbSMichal Kazior 
237af296bdbSMichal Kazior 	int n_counter_offsets_beacon;
238af296bdbSMichal Kazior 	int n_counter_offsets_presp;
239af296bdbSMichal Kazior 
240af296bdbSMichal Kazior 	u8 count;
241af296bdbSMichal Kazior };
242af296bdbSMichal Kazior 
2435dfdaf58SJohannes Berg struct beacon_data {
2445dfdaf58SJohannes Berg 	u8 *head, *tail;
2455dfdaf58SJohannes Berg 	int head_len, tail_len;
24643552be1SThomas Pedersen 	struct ieee80211_meshconf_ie *meshconf;
247af296bdbSMichal Kazior 	u16 csa_counter_offsets[IEEE80211_MAX_CSA_COUNTERS_NUM];
248af296bdbSMichal Kazior 	u8 csa_current_counter;
2498860020eSJohannes Berg 	struct rcu_head rcu_head;
2505dfdaf58SJohannes Berg };
2515dfdaf58SJohannes Berg 
252aa7a0080SEyal Shapira struct probe_resp {
253aa7a0080SEyal Shapira 	struct rcu_head rcu_head;
254aa7a0080SEyal Shapira 	int len;
255af296bdbSMichal Kazior 	u16 csa_counter_offsets[IEEE80211_MAX_CSA_COUNTERS_NUM];
256aa7a0080SEyal Shapira 	u8 data[0];
257aa7a0080SEyal Shapira };
258aa7a0080SEyal Shapira 
259d012a605SMarco Porsch struct ps_data {
260d012a605SMarco Porsch 	/* yes, this looks ugly, but guarantees that we can later use
261d012a605SMarco Porsch 	 * bitmap_empty :)
262d012a605SMarco Porsch 	 * NB: don't touch this bitmap, use sta_info_{set,clear}_tim_bit */
2635fe2bb86SJoe Perches 	u8 tim[sizeof(unsigned long) * BITS_TO_LONGS(IEEE80211_MAX_AID + 1)]
2645fe2bb86SJoe Perches 			__aligned(__alignof__(unsigned long));
265d012a605SMarco Porsch 	struct sk_buff_head bc_buf;
266d012a605SMarco Porsch 	atomic_t num_sta_ps; /* number of stations in PS mode */
267d012a605SMarco Porsch 	int dtim_count;
268d012a605SMarco Porsch 	bool dtim_bc_mc;
269d012a605SMarco Porsch };
270d012a605SMarco Porsch 
271f0706e82SJiri Benc struct ieee80211_if_ap {
27240b275b6SJohannes Berg 	struct beacon_data __rcu *beacon;
273aa7a0080SEyal Shapira 	struct probe_resp __rcu *probe_resp;
274f0706e82SJiri Benc 
27573da7d5bSSimon Wunderlich 	/* to be used after channel switch. */
27673da7d5bSSimon Wunderlich 	struct cfg80211_beacon_data *next_beacon;
2774e141dadSMichal Kazior 	struct list_head vlans; /* write-protected with RTNL and local->mtx */
2780ec3ca44SJohannes Berg 
279d012a605SMarco Porsch 	struct ps_data ps;
280030ef8f8SFelix Fietkau 	atomic_t num_mcast_sta; /* number of stations receiving multicast */
281687da132SEmmanuel Grumbach 	enum ieee80211_smps_mode req_smps, /* requested smps mode */
282687da132SEmmanuel Grumbach 			 driver_smps_mode; /* smps mode request */
283687da132SEmmanuel Grumbach 
284687da132SEmmanuel Grumbach 	struct work_struct request_smps_work;
285f0706e82SJiri Benc };
286f0706e82SJiri Benc 
287f0706e82SJiri Benc struct ieee80211_if_wds {
288f0706e82SJiri Benc 	struct sta_info *sta;
289056cdd59SJohannes Berg 	u8 remote_addr[ETH_ALEN];
290f0706e82SJiri Benc };
291f0706e82SJiri Benc 
292f0706e82SJiri Benc struct ieee80211_if_vlan {
2934e141dadSMichal Kazior 	struct list_head list; /* write-protected with RTNL and local->mtx */
294f14543eeSFelix Fietkau 
295f14543eeSFelix Fietkau 	/* used for all tx if the VLAN is configured to 4-addr mode */
29640b275b6SJohannes Berg 	struct sta_info __rcu *sta;
297f0706e82SJiri Benc };
298f0706e82SJiri Benc 
299ee385855SLuis Carlos Cobo struct mesh_stats {
300c8a61a7dSDaniel Walker 	__u32 fwded_mcast;		/* Mesh forwarded multicast frames */
301c8a61a7dSDaniel Walker 	__u32 fwded_unicast;		/* Mesh forwarded unicast frames */
302c8a61a7dSDaniel Walker 	__u32 fwded_frames;		/* Mesh total forwarded frames */
303ee385855SLuis Carlos Cobo 	__u32 dropped_frames_ttl;	/* Not transmitted since mesh_ttl == 0*/
304ee385855SLuis Carlos Cobo 	__u32 dropped_frames_no_route;	/* Not transmitted, no route found */
305cfee66b0SJavier Cardona 	__u32 dropped_frames_congestion;/* Not forwarded due to congestion */
306ee385855SLuis Carlos Cobo };
307ee385855SLuis Carlos Cobo 
308ee385855SLuis Carlos Cobo #define PREQ_Q_F_START		0x1
309ee385855SLuis Carlos Cobo #define PREQ_Q_F_REFRESH	0x2
310ee385855SLuis Carlos Cobo struct mesh_preq_queue {
311ee385855SLuis Carlos Cobo 	struct list_head list;
312ee385855SLuis Carlos Cobo 	u8 dst[ETH_ALEN];
313ee385855SLuis Carlos Cobo 	u8 flags;
314ee385855SLuis Carlos Cobo };
315ee385855SLuis Carlos Cobo 
3162eb278e0SJohannes Berg #if HZ/100 == 0
3172eb278e0SJohannes Berg #define IEEE80211_ROC_MIN_LEFT	1
3182eb278e0SJohannes Berg #else
3192eb278e0SJohannes Berg #define IEEE80211_ROC_MIN_LEFT	(HZ/100)
3202eb278e0SJohannes Berg #endif
32177fdaa12SJohannes Berg 
3222eb278e0SJohannes Berg struct ieee80211_roc_work {
32377fdaa12SJohannes Berg 	struct list_head list;
3242eb278e0SJohannes Berg 	struct list_head dependents;
325f679f65dSJohannes Berg 
3262eb278e0SJohannes Berg 	struct delayed_work work;
327af6b6374SJohannes Berg 
328af6b6374SJohannes Berg 	struct ieee80211_sub_if_data *sdata;
329af6b6374SJohannes Berg 
330f679f65dSJohannes Berg 	struct ieee80211_channel *chan;
331af6b6374SJohannes Berg 
3322eb278e0SJohannes Berg 	bool started, abort, hw_begun, notified;
3333fbd45caSJohannes Berg 	bool to_be_freed;
334b4b177a5SJohannes Berg 	bool on_channel;
335f679f65dSJohannes Berg 
3362eb278e0SJohannes Berg 	unsigned long hw_start_time;
337e4da8c37SJohannes Berg 
3382eb278e0SJohannes Berg 	u32 duration, req_duration;
339f30221e4SJohannes Berg 	struct sk_buff *frame;
34050febf6aSJohannes Berg 	u64 cookie, mgmt_tx_cookie;
341d339d5caSIlan Peer 	enum ieee80211_roc_type type;
34277fdaa12SJohannes Berg };
34377fdaa12SJohannes Berg 
34446900298SJohannes Berg /* flags used in struct ieee80211_if_managed.flags */
345ab1faeadSJohannes Berg enum ieee80211_sta_flags {
346b291ba11SJohannes Berg 	IEEE80211_STA_CONNECTION_POLL	= BIT(1),
347b291ba11SJohannes Berg 	IEEE80211_STA_CONTROL_PORT	= BIT(2),
348a8243b72SJohannes Berg 	IEEE80211_STA_DISABLE_HT	= BIT(4),
349b291ba11SJohannes Berg 	IEEE80211_STA_MFP_ENABLED	= BIT(6),
350ab13315aSKalle Valo 	IEEE80211_STA_UAPSD_ENABLED	= BIT(7),
351375177bfSVivek Natarajan 	IEEE80211_STA_NULLFUNC_ACKED	= BIT(8),
35217e4ec14SJouni Malinen 	IEEE80211_STA_RESET_SIGNAL_AVE	= BIT(9),
35324398e39SJohannes Berg 	IEEE80211_STA_DISABLE_40MHZ	= BIT(10),
354d545dabaSMahesh Palivela 	IEEE80211_STA_DISABLE_VHT	= BIT(11),
355f2d9d270SJohannes Berg 	IEEE80211_STA_DISABLE_80P80MHZ	= BIT(12),
356f2d9d270SJohannes Berg 	IEEE80211_STA_DISABLE_160MHZ	= BIT(13),
357095d81ceSJohannes Berg 	IEEE80211_STA_DISABLE_WMM	= BIT(14),
358cd2f5dd7SAssaf Krauss 	IEEE80211_STA_ENABLE_RRM	= BIT(15),
359ab1faeadSJohannes Berg };
360ab1faeadSJohannes Berg 
36166e67e41SJohannes Berg struct ieee80211_mgd_auth_data {
36266e67e41SJohannes Berg 	struct cfg80211_bss *bss;
36366e67e41SJohannes Berg 	unsigned long timeout;
36466e67e41SJohannes Berg 	int tries;
36566e67e41SJohannes Berg 	u16 algorithm, expected_transaction;
36666e67e41SJohannes Berg 
36766e67e41SJohannes Berg 	u8 key[WLAN_KEY_LEN_WEP104];
36866e67e41SJohannes Berg 	u8 key_len, key_idx;
36966e67e41SJohannes Berg 	bool done;
37089afe614SJohannes Berg 	bool timeout_started;
37166e67e41SJohannes Berg 
3726b8ece3aSJouni Malinen 	u16 sae_trans, sae_status;
3736b8ece3aSJouni Malinen 	size_t data_len;
3746b8ece3aSJouni Malinen 	u8 data[];
37566e67e41SJohannes Berg };
37666e67e41SJohannes Berg 
37766e67e41SJohannes Berg struct ieee80211_mgd_assoc_data {
37866e67e41SJohannes Berg 	struct cfg80211_bss *bss;
37966e67e41SJohannes Berg 	const u8 *supp_rates;
38066e67e41SJohannes Berg 
38166e67e41SJohannes Berg 	unsigned long timeout;
38266e67e41SJohannes Berg 	int tries;
38366e67e41SJohannes Berg 
38466e67e41SJohannes Berg 	u16 capability;
38566e67e41SJohannes Berg 	u8 prev_bssid[ETH_ALEN];
38666e67e41SJohannes Berg 	u8 ssid[IEEE80211_MAX_SSID_LEN];
38766e67e41SJohannes Berg 	u8 ssid_len;
38866e67e41SJohannes Berg 	u8 supp_rates_len;
38976f0303dSJohannes Berg 	bool wmm, uapsd;
390989c6505SAlexander Bondar 	bool need_beacon;
39166e67e41SJohannes Berg 	bool synced;
39289afe614SJohannes Berg 	bool timeout_started;
39366e67e41SJohannes Berg 
3949dde6423SJohannes Berg 	u8 ap_ht_param;
3959dde6423SJohannes Berg 
396b08fbbd8SJohannes Berg 	struct ieee80211_vht_cap ap_vht_cap;
397b08fbbd8SJohannes Berg 
39866e67e41SJohannes Berg 	size_t ie_len;
39966e67e41SJohannes Berg 	u8 ie[];
40066e67e41SJohannes Berg };
40166e67e41SJohannes Berg 
40202219b3aSJohannes Berg struct ieee80211_sta_tx_tspec {
40302219b3aSJohannes Berg 	/* timestamp of the first packet in the time slice */
40402219b3aSJohannes Berg 	unsigned long time_slice_start;
40502219b3aSJohannes Berg 
40602219b3aSJohannes Berg 	u32 admitted_time; /* in usecs, unlike over the air */
40702219b3aSJohannes Berg 	u8 tsid;
40802219b3aSJohannes Berg 	s8 up; /* signed to be able to invalidate with -1 during teardown */
40902219b3aSJohannes Berg 
41002219b3aSJohannes Berg 	/* consumed TX time in microseconds in the time slice */
41102219b3aSJohannes Berg 	u32 consumed_tx_time;
41202219b3aSJohannes Berg 	enum {
41302219b3aSJohannes Berg 		TX_TSPEC_ACTION_NONE = 0,
41402219b3aSJohannes Berg 		TX_TSPEC_ACTION_DOWNGRADE,
41502219b3aSJohannes Berg 		TX_TSPEC_ACTION_STOP_DOWNGRADE,
41602219b3aSJohannes Berg 	} action;
41702219b3aSJohannes Berg 	bool downgraded;
41802219b3aSJohannes Berg };
41902219b3aSJohannes Berg 
42046900298SJohannes Berg struct ieee80211_if_managed {
421056cdd59SJohannes Berg 	struct timer_list timer;
422b291ba11SJohannes Berg 	struct timer_list conn_mon_timer;
423b291ba11SJohannes Berg 	struct timer_list bcn_mon_timer;
424c481ec97SSujith 	struct timer_list chswitch_timer;
425b291ba11SJohannes Berg 	struct work_struct monitor_work;
426c481ec97SSujith 	struct work_struct chswitch_work;
4271e4dcd01SJuuso Oikarinen 	struct work_struct beacon_connection_loss_work;
428882a7c69SJohannes Berg 	struct work_struct csa_connection_drop_work;
42946900298SJohannes Berg 
4307ccc8bd7SFelix Fietkau 	unsigned long beacon_timeout;
431b291ba11SJohannes Berg 	unsigned long probe_timeout;
432a43abf29SMaxim Levitsky 	int probe_send_count;
43304ac3c0eSFelix Fietkau 	bool nullfunc_failed;
434682bd38bSJohannes Berg 	bool connection_loss;
435b291ba11SJohannes Berg 
4360c1ad2caSJohannes Berg 	struct cfg80211_bss *associated;
43766e67e41SJohannes Berg 	struct ieee80211_mgd_auth_data *auth_data;
43866e67e41SJohannes Berg 	struct ieee80211_mgd_assoc_data *assoc_data;
43946900298SJohannes Berg 
44077fdaa12SJohannes Berg 	u8 bssid[ETH_ALEN];
44146900298SJohannes Berg 
442f0706e82SJiri Benc 	u16 aid;
443f0706e82SJiri Benc 
444965bedadSJohannes Berg 	bool powersave; /* powersave requested for this iface */
44505cb9108SJohannes Berg 	bool broken_ap; /* AP is broken -- turn off powersave */
446989c6505SAlexander Bondar 	bool have_beacon;
447826262c3SJohannes Berg 	u8 dtim_period;
4480f78231bSJohannes Berg 	enum ieee80211_smps_mode req_smps, /* requested smps mode */
449d1f5b7a3SJohannes Berg 				 driver_smps_mode; /* smps mode request */
450d1f5b7a3SJohannes Berg 
451d1f5b7a3SJohannes Berg 	struct work_struct request_smps_work;
452965bedadSJohannes Berg 
453d6f2da5bSJiri Slaby 	unsigned int flags;
454f0706e82SJiri Benc 
4550c21e632SLuciano Coelho 	bool csa_waiting_bcn;
4560c21e632SLuciano Coelho 
457d8ec4433SJuuso Oikarinen 	bool beacon_crc_valid;
458d91f36dbSJohannes Berg 	u32 beacon_crc;
459d91f36dbSJohannes Berg 
4601672c0e3SJohannes Berg 	bool status_acked;
4611672c0e3SJohannes Berg 	bool status_received;
4621672c0e3SJohannes Berg 	__le16 status_fc;
4631672c0e3SJohannes Berg 
464fdfacf0aSJouni Malinen 	enum {
465fdfacf0aSJouni Malinen 		IEEE80211_MFP_DISABLED,
466fdfacf0aSJouni Malinen 		IEEE80211_MFP_OPTIONAL,
467fdfacf0aSJouni Malinen 		IEEE80211_MFP_REQUIRED
468fdfacf0aSJouni Malinen 	} mfp; /* management frame protection */
469fdfacf0aSJouni Malinen 
470dc41e4d4SEliad Peller 	/*
471dc41e4d4SEliad Peller 	 * Bitmask of enabled u-apsd queues,
472dc41e4d4SEliad Peller 	 * IEEE80211_WMM_IE_STA_QOSINFO_AC_BE & co. Needs a new association
473dc41e4d4SEliad Peller 	 * to take effect.
474dc41e4d4SEliad Peller 	 */
475dc41e4d4SEliad Peller 	unsigned int uapsd_queues;
476dc41e4d4SEliad Peller 
477dc41e4d4SEliad Peller 	/*
478dc41e4d4SEliad Peller 	 * Maximum number of buffered frames AP can deliver during a
479dc41e4d4SEliad Peller 	 * service period, IEEE80211_WMM_IE_STA_QOSINFO_SP_ALL or similar.
480dc41e4d4SEliad Peller 	 * Needs a new association to take effect.
481dc41e4d4SEliad Peller 	 */
482dc41e4d4SEliad Peller 	unsigned int uapsd_max_sp_len;
483dc41e4d4SEliad Peller 
484f0706e82SJiri Benc 	int wmm_last_param_set;
4859bc383deSJohannes Berg 
4869bc383deSJohannes Berg 	u8 use_4addr;
48717e4ec14SJouni Malinen 
48867baf663SJanusz Dziedzic 	s16 p2p_noa_index;
489488dd7b5SJohannes Berg 
49017e4ec14SJouni Malinen 	/* Signal strength from the last Beacon frame in the current BSS. */
49117e4ec14SJouni Malinen 	int last_beacon_signal;
49217e4ec14SJouni Malinen 
49317e4ec14SJouni Malinen 	/*
49417e4ec14SJouni Malinen 	 * Weighted average of the signal strength from Beacon frames in the
49517e4ec14SJouni Malinen 	 * current BSS. This is in units of 1/16 of the signal unit to maintain
49617e4ec14SJouni Malinen 	 * accuracy and to speed up calculations, i.e., the value need to be
49717e4ec14SJouni Malinen 	 * divided by 16 to get the actual value.
49817e4ec14SJouni Malinen 	 */
49917e4ec14SJouni Malinen 	int ave_beacon_signal;
50017e4ec14SJouni Malinen 
50117e4ec14SJouni Malinen 	/*
502391a200aSJouni Malinen 	 * Number of Beacon frames used in ave_beacon_signal. This can be used
503391a200aSJouni Malinen 	 * to avoid generating less reliable cqm events that would be based
504391a200aSJouni Malinen 	 * only on couple of received frames.
505391a200aSJouni Malinen 	 */
506391a200aSJouni Malinen 	unsigned int count_beacon_signal;
507391a200aSJouni Malinen 
508391a200aSJouni Malinen 	/*
50917e4ec14SJouni Malinen 	 * Last Beacon frame signal strength average (ave_beacon_signal / 16)
51017e4ec14SJouni Malinen 	 * that triggered a cqm event. 0 indicates that no event has been
51117e4ec14SJouni Malinen 	 * generated for the current association.
51217e4ec14SJouni Malinen 	 */
51317e4ec14SJouni Malinen 	int last_cqm_event_signal;
514615f7b9bSMeenakshi Venkataraman 
515615f7b9bSMeenakshi Venkataraman 	/*
516615f7b9bSMeenakshi Venkataraman 	 * State variables for keeping track of RSSI of the AP currently
517615f7b9bSMeenakshi Venkataraman 	 * connected to and informing driver when RSSI has gone
518615f7b9bSMeenakshi Venkataraman 	 * below/above a certain threshold.
519615f7b9bSMeenakshi Venkataraman 	 */
520615f7b9bSMeenakshi Venkataraman 	int rssi_min_thold, rssi_max_thold;
521615f7b9bSMeenakshi Venkataraman 	int last_ave_beacon_signal;
522ef96a842SBen Greear 
523ef96a842SBen Greear 	struct ieee80211_ht_cap ht_capa; /* configured ht-cap over-rides */
524ef96a842SBen Greear 	struct ieee80211_ht_cap ht_capa_mask; /* Valid parts of ht_capa */
525dd5ecfeaSJohannes Berg 	struct ieee80211_vht_cap vht_capa; /* configured VHT overrides */
526dd5ecfeaSJohannes Berg 	struct ieee80211_vht_cap vht_capa_mask; /* Valid parts of vht_capa */
52781dd2b88SArik Nemtsov 
52881dd2b88SArik Nemtsov 	u8 tdls_peer[ETH_ALEN] __aligned(2);
52981dd2b88SArik Nemtsov 	struct delayed_work tdls_peer_del_work;
53002219b3aSJohannes Berg 
53102219b3aSJohannes Berg 	/* WMM-AC TSPEC support */
53202219b3aSJohannes Berg 	struct ieee80211_sta_tx_tspec tx_tspec[IEEE80211_NUM_ACS];
53302219b3aSJohannes Berg 	/* Use a separate work struct so that we can do something here
53402219b3aSJohannes Berg 	 * while the sdata->work is flushing the queues, for example.
53502219b3aSJohannes Berg 	 * otherwise, in scenarios where we hardly get any traffic out
53602219b3aSJohannes Berg 	 * on the BE queue, but there's a lot of VO traffic, we might
53702219b3aSJohannes Berg 	 * get stuck in a downgraded situation and flush takes forever.
53802219b3aSJohannes Berg 	 */
53902219b3aSJohannes Berg 	struct delayed_work tx_tspec_wk;
540f0706e82SJiri Benc };
541f0706e82SJiri Benc 
54246900298SJohannes Berg struct ieee80211_if_ibss {
54346900298SJohannes Berg 	struct timer_list timer;
544cd7760e6SSimon Wunderlich 	struct work_struct csa_connection_drop_work;
54546900298SJohannes Berg 
546af8cdcd8SJohannes Berg 	unsigned long last_scan_completed;
5475bb644a0SJohannes Berg 
548fbd2c8dcSTeemu Paasikivi 	u32 basic_rates;
549fbd2c8dcSTeemu Paasikivi 
550af8cdcd8SJohannes Berg 	bool fixed_bssid;
551af8cdcd8SJohannes Berg 	bool fixed_channel;
552fffd0934SJohannes Berg 	bool privacy;
55346900298SJohannes Berg 
554267335d6SAntonio Quartulli 	bool control_port;
5558e8d347dSSimon Wunderlich 	bool userspace_handles_dfs;
556267335d6SAntonio Quartulli 
5574d196e4bSFelix Fietkau 	u8 bssid[ETH_ALEN] __aligned(2);
558af8cdcd8SJohannes Berg 	u8 ssid[IEEE80211_MAX_SSID_LEN];
559af8cdcd8SJohannes Berg 	u8 ssid_len, ie_len;
560af8cdcd8SJohannes Berg 	u8 *ie;
5613aede78aSSimon Wunderlich 	struct cfg80211_chan_def chandef;
56246900298SJohannes Berg 
56346900298SJohannes Berg 	unsigned long ibss_join_req;
564af8cdcd8SJohannes Berg 	/* probe response/beacon for IBSS */
565c3ffeab4SJohannes Berg 	struct beacon_data __rcu *presp;
56646900298SJohannes Berg 
567822854b0SSimon Wunderlich 	struct ieee80211_ht_cap ht_capa; /* configured ht-cap over-rides */
568822854b0SSimon Wunderlich 	struct ieee80211_ht_cap ht_capa_mask; /* Valid parts of ht_capa */
569822854b0SSimon Wunderlich 
5708bf11d8dSJohannes Berg 	spinlock_t incomplete_lock;
5718bf11d8dSJohannes Berg 	struct list_head incomplete_stations;
5728bf11d8dSJohannes Berg 
57346900298SJohannes Berg 	enum {
57446900298SJohannes Berg 		IEEE80211_IBSS_MLME_SEARCH,
57546900298SJohannes Berg 		IEEE80211_IBSS_MLME_JOINED,
57646900298SJohannes Berg 	} state;
57746900298SJohannes Berg };
57846900298SJohannes Berg 
579dbf498fbSJavier Cardona /**
580239281f8SRostislav Lisovy  * struct ieee80211_if_ocb - OCB mode state
581239281f8SRostislav Lisovy  *
582239281f8SRostislav Lisovy  * @housekeeping_timer: timer for periodic invocation of a housekeeping task
583239281f8SRostislav Lisovy  * @wrkq_flags: OCB deferred task action
584239281f8SRostislav Lisovy  * @incomplete_lock: delayed STA insertion lock
585239281f8SRostislav Lisovy  * @incomplete_stations: list of STAs waiting for delayed insertion
586239281f8SRostislav Lisovy  * @joined: indication if the interface is connected to an OCB network
587239281f8SRostislav Lisovy  */
588239281f8SRostislav Lisovy struct ieee80211_if_ocb {
589239281f8SRostislav Lisovy 	struct timer_list housekeeping_timer;
590239281f8SRostislav Lisovy 	unsigned long wrkq_flags;
591239281f8SRostislav Lisovy 
592239281f8SRostislav Lisovy 	spinlock_t incomplete_lock;
593239281f8SRostislav Lisovy 	struct list_head incomplete_stations;
594239281f8SRostislav Lisovy 
595239281f8SRostislav Lisovy 	bool joined;
596239281f8SRostislav Lisovy };
597239281f8SRostislav Lisovy 
598239281f8SRostislav Lisovy /**
599dbf498fbSJavier Cardona  * struct ieee80211_mesh_sync_ops - Extensible synchronization framework interface
600dbf498fbSJavier Cardona  *
601dbf498fbSJavier Cardona  * these declarations define the interface, which enables
602dbf498fbSJavier Cardona  * vendor-specific mesh synchronization
603dbf498fbSJavier Cardona  *
604dbf498fbSJavier Cardona  */
605dbf498fbSJavier Cardona struct ieee802_11_elems;
606dbf498fbSJavier Cardona struct ieee80211_mesh_sync_ops {
607dbf498fbSJavier Cardona 	void (*rx_bcn_presp)(struct ieee80211_sub_if_data *sdata,
608dbf498fbSJavier Cardona 			     u16 stype,
609dbf498fbSJavier Cardona 			     struct ieee80211_mgmt *mgmt,
610dbf498fbSJavier Cardona 			     struct ieee802_11_elems *elems,
611dbf498fbSJavier Cardona 			     struct ieee80211_rx_status *rx_status);
61243552be1SThomas Pedersen 
61343552be1SThomas Pedersen 	/* should be called with beacon_data under RCU read lock */
61443552be1SThomas Pedersen 	void (*adjust_tbtt)(struct ieee80211_sub_if_data *sdata,
61543552be1SThomas Pedersen 			    struct beacon_data *beacon);
616dbf498fbSJavier Cardona 	/* add other framework functions here */
617dbf498fbSJavier Cardona };
618dbf498fbSJavier Cardona 
619b8456a14SChun-Yeow Yeoh struct mesh_csa_settings {
620b8456a14SChun-Yeow Yeoh 	struct rcu_head rcu_head;
621b8456a14SChun-Yeow Yeoh 	struct cfg80211_csa_settings settings;
622b8456a14SChun-Yeow Yeoh };
623b8456a14SChun-Yeow Yeoh 
624472dbc45SJohannes Berg struct ieee80211_if_mesh {
625472dbc45SJohannes Berg 	struct timer_list housekeeping_timer;
626472dbc45SJohannes Berg 	struct timer_list mesh_path_timer;
627e304bfd3SRui Paulo 	struct timer_list mesh_path_root_timer;
628472dbc45SJohannes Berg 
62918889231SJavier Cardona 	unsigned long wrkq_flags;
630f81a9dedSThomas Pedersen 	unsigned long mbss_changed;
631472dbc45SJohannes Berg 
632472dbc45SJohannes Berg 	u8 mesh_id[IEEE80211_MAX_MESH_ID_LEN];
633472dbc45SJohannes Berg 	size_t mesh_id_len;
634472dbc45SJohannes Berg 	/* Active Path Selection Protocol Identifier */
6353491707aSRui Paulo 	u8 mesh_pp_id;
636472dbc45SJohannes Berg 	/* Active Path Selection Metric Identifier */
6373491707aSRui Paulo 	u8 mesh_pm_id;
638472dbc45SJohannes Berg 	/* Congestion Control Mode Identifier */
6393491707aSRui Paulo 	u8 mesh_cc_id;
6409e03fdfdSJavier Cardona 	/* Synchronization Protocol Identifier */
6413491707aSRui Paulo 	u8 mesh_sp_id;
6429e03fdfdSJavier Cardona 	/* Authentication Protocol Identifier */
6433491707aSRui Paulo 	u8 mesh_auth_id;
644d19b3bf6SRui Paulo 	/* Local mesh Sequence Number */
645d19b3bf6SRui Paulo 	u32 sn;
646472dbc45SJohannes Berg 	/* Last used PREQ ID */
647472dbc45SJohannes Berg 	u32 preq_id;
648472dbc45SJohannes Berg 	atomic_t mpaths;
649d19b3bf6SRui Paulo 	/* Timestamp of last SN update */
650d19b3bf6SRui Paulo 	unsigned long last_sn_update;
651dca7e943SThomas Pedersen 	/* Time when it's ok to send next PERR */
652dca7e943SThomas Pedersen 	unsigned long next_perr;
653dca7e943SThomas Pedersen 	/* Timestamp of last PREQ sent */
654472dbc45SJohannes Berg 	unsigned long last_preq;
655472dbc45SJohannes Berg 	struct mesh_rmc *rmc;
656472dbc45SJohannes Berg 	spinlock_t mesh_preq_queue_lock;
657472dbc45SJohannes Berg 	struct mesh_preq_queue preq_queue;
658472dbc45SJohannes Berg 	int preq_queue_len;
659472dbc45SJohannes Berg 	struct mesh_stats mshstats;
660472dbc45SJohannes Berg 	struct mesh_config mshcfg;
6611258d976SAshok Nagarajan 	atomic_t estab_plinks;
662472dbc45SJohannes Berg 	u32 mesh_seqnum;
663472dbc45SJohannes Berg 	bool accepting_plinks;
6645ee68e5bSJavier Cardona 	int num_gates;
6652b5e1967SThomas Pedersen 	struct beacon_data __rcu *beacon;
666581a8b0fSJavier Cardona 	const u8 *ie;
667581a8b0fSJavier Cardona 	u8 ie_len;
668b130e5ceSJavier Cardona 	enum {
669b130e5ceSJavier Cardona 		IEEE80211_MESH_SEC_NONE = 0x0,
670b130e5ceSJavier Cardona 		IEEE80211_MESH_SEC_AUTHED = 0x1,
671b130e5ceSJavier Cardona 		IEEE80211_MESH_SEC_SECURED = 0x2,
672b130e5ceSJavier Cardona 	} security;
673a6dad6a2SThomas Pedersen 	bool user_mpm;
674dbf498fbSJavier Cardona 	/* Extensible Synchronization Framework */
6758ba7acf3SJohannes Berg 	const struct ieee80211_mesh_sync_ops *sync_ops;
676dbf498fbSJavier Cardona 	s64 sync_offset_clockdrift_max;
677dbf498fbSJavier Cardona 	spinlock_t sync_offset_lock;
678dbf498fbSJavier Cardona 	bool adjusting_tbtt;
6793f52b7e3SMarco Porsch 	/* mesh power save */
6803f52b7e3SMarco Porsch 	enum nl80211_mesh_power_mode nonpeer_pm;
6813f52b7e3SMarco Porsch 	int ps_peers_light_sleep;
6823f52b7e3SMarco Porsch 	int ps_peers_deep_sleep;
6833f52b7e3SMarco Porsch 	struct ps_data ps;
6848f2535b9SChun-Yeow Yeoh 	/* Channel Switching Support */
685b8456a14SChun-Yeow Yeoh 	struct mesh_csa_settings __rcu *csa;
6860cb4d4dcSLuciano Coelho 	enum {
6870cb4d4dcSLuciano Coelho 		IEEE80211_MESH_CSA_ROLE_NONE,
6880cb4d4dcSLuciano Coelho 		IEEE80211_MESH_CSA_ROLE_INIT,
6890cb4d4dcSLuciano Coelho 		IEEE80211_MESH_CSA_ROLE_REPEATER,
6900cb4d4dcSLuciano Coelho 	} csa_role;
691b8456a14SChun-Yeow Yeoh 	u8 chsw_ttl;
6928f2535b9SChun-Yeow Yeoh 	u16 pre_value;
69343552be1SThomas Pedersen 
69443552be1SThomas Pedersen 	/* offset from skb->data while building IE */
69543552be1SThomas Pedersen 	int meshconf_offset;
696472dbc45SJohannes Berg };
697902acc78SJohannes Berg 
698902acc78SJohannes Berg #ifdef CONFIG_MAC80211_MESH
699472dbc45SJohannes Berg #define IEEE80211_IFSTA_MESH_CTR_INC(msh, name)	\
700472dbc45SJohannes Berg 	do { (msh)->mshstats.name++; } while (0)
701902acc78SJohannes Berg #else
702472dbc45SJohannes Berg #define IEEE80211_IFSTA_MESH_CTR_INC(msh, name) \
703902acc78SJohannes Berg 	do { } while (0)
704902acc78SJohannes Berg #endif
705f0706e82SJiri Benc 
706213cd118SJohannes Berg /**
707213cd118SJohannes Berg  * enum ieee80211_sub_if_data_flags - virtual interface flags
708213cd118SJohannes Berg  *
709213cd118SJohannes Berg  * @IEEE80211_SDATA_ALLMULTI: interface wants all multicast packets
710213cd118SJohannes Berg  * @IEEE80211_SDATA_PROMISC: interface is promisc
711213cd118SJohannes Berg  * @IEEE80211_SDATA_OPERATING_GMODE: operating in G-only mode
712213cd118SJohannes Berg  * @IEEE80211_SDATA_DONT_BRIDGE_PACKETS: bridge packets between
713213cd118SJohannes Berg  *	associated stations and deliver multicast frames both
714213cd118SJohannes Berg  *	back to wireless media and to the local net stack.
71595acac61SJohannes Berg  * @IEEE80211_SDATA_DISCONNECT_RESUME: Disconnect after resume.
7167b7eab6fSJohannes Berg  * @IEEE80211_SDATA_IN_DRIVER: indicates interface was added to driver
717213cd118SJohannes Berg  */
718213cd118SJohannes Berg enum ieee80211_sub_if_data_flags {
719213cd118SJohannes Berg 	IEEE80211_SDATA_ALLMULTI		= BIT(0),
720213cd118SJohannes Berg 	IEEE80211_SDATA_PROMISC			= BIT(1),
7217986cf95SJohannes Berg 	IEEE80211_SDATA_OPERATING_GMODE		= BIT(2),
7227986cf95SJohannes Berg 	IEEE80211_SDATA_DONT_BRIDGE_PACKETS	= BIT(3),
72395acac61SJohannes Berg 	IEEE80211_SDATA_DISCONNECT_RESUME	= BIT(4),
7247b7eab6fSJohannes Berg 	IEEE80211_SDATA_IN_DRIVER		= BIT(5),
725213cd118SJohannes Berg };
726213cd118SJohannes Berg 
72734d4bc4dSJohannes Berg /**
72834d4bc4dSJohannes Berg  * enum ieee80211_sdata_state_bits - virtual interface state bits
72934d4bc4dSJohannes Berg  * @SDATA_STATE_RUNNING: virtual interface is up & running; this
73034d4bc4dSJohannes Berg  *	mirrors netif_running() but is separate for interface type
73134d4bc4dSJohannes Berg  *	change handling while the interface is up
7325b714c6aSJohannes Berg  * @SDATA_STATE_OFFCHANNEL: This interface is currently in offchannel
7335b714c6aSJohannes Berg  *	mode, so queues are stopped
734d6a83228SJohannes Berg  * @SDATA_STATE_OFFCHANNEL_BEACON_STOPPED: Beaconing was stopped due
735d6a83228SJohannes Berg  *	to offchannel, reset when offchannel returns
73634d4bc4dSJohannes Berg  */
73734d4bc4dSJohannes Berg enum ieee80211_sdata_state_bits {
73834d4bc4dSJohannes Berg 	SDATA_STATE_RUNNING,
7395b714c6aSJohannes Berg 	SDATA_STATE_OFFCHANNEL,
740d6a83228SJohannes Berg 	SDATA_STATE_OFFCHANNEL_BEACON_STOPPED,
74134d4bc4dSJohannes Berg };
74234d4bc4dSJohannes Berg 
743d01a1e65SMichal Kazior /**
744d01a1e65SMichal Kazior  * enum ieee80211_chanctx_mode - channel context configuration mode
745d01a1e65SMichal Kazior  *
746d01a1e65SMichal Kazior  * @IEEE80211_CHANCTX_SHARED: channel context may be used by
747d01a1e65SMichal Kazior  *	multiple interfaces
748d01a1e65SMichal Kazior  * @IEEE80211_CHANCTX_EXCLUSIVE: channel context can be used
749d01a1e65SMichal Kazior  *	only by a single interface. This can be used for example for
750d01a1e65SMichal Kazior  *	non-fixed channel IBSS.
751d01a1e65SMichal Kazior  */
752d01a1e65SMichal Kazior enum ieee80211_chanctx_mode {
753d01a1e65SMichal Kazior 	IEEE80211_CHANCTX_SHARED,
754d01a1e65SMichal Kazior 	IEEE80211_CHANCTX_EXCLUSIVE
755d01a1e65SMichal Kazior };
756d01a1e65SMichal Kazior 
7575bcae31dSMichal Kazior /**
7585bcae31dSMichal Kazior  * enum ieee80211_chanctx_replace_state - channel context replacement state
7595bcae31dSMichal Kazior  *
7605bcae31dSMichal Kazior  * This is used for channel context in-place reservations that require channel
7615bcae31dSMichal Kazior  * context switch/swap.
7625bcae31dSMichal Kazior  *
7635bcae31dSMichal Kazior  * @IEEE80211_CHANCTX_REPLACE_NONE: no replacement is taking place
7645bcae31dSMichal Kazior  * @IEEE80211_CHANCTX_WILL_BE_REPLACED: this channel context will be replaced
7655bcae31dSMichal Kazior  *	by a (not yet registered) channel context pointed by %replace_ctx.
7665bcae31dSMichal Kazior  * @IEEE80211_CHANCTX_REPLACES_OTHER: this (not yet registered) channel context
7675bcae31dSMichal Kazior  *	replaces an existing channel context pointed to by %replace_ctx.
7685bcae31dSMichal Kazior  */
7695bcae31dSMichal Kazior enum ieee80211_chanctx_replace_state {
7705bcae31dSMichal Kazior 	IEEE80211_CHANCTX_REPLACE_NONE,
7715bcae31dSMichal Kazior 	IEEE80211_CHANCTX_WILL_BE_REPLACED,
7725bcae31dSMichal Kazior 	IEEE80211_CHANCTX_REPLACES_OTHER,
7735bcae31dSMichal Kazior };
7745bcae31dSMichal Kazior 
775d01a1e65SMichal Kazior struct ieee80211_chanctx {
776d01a1e65SMichal Kazior 	struct list_head list;
777d01a1e65SMichal Kazior 	struct rcu_head rcu_head;
778d01a1e65SMichal Kazior 
779484298adSMichal Kazior 	struct list_head assigned_vifs;
780e3afb920SMichal Kazior 	struct list_head reserved_vifs;
781484298adSMichal Kazior 
7825bcae31dSMichal Kazior 	enum ieee80211_chanctx_replace_state replace_state;
7835bcae31dSMichal Kazior 	struct ieee80211_chanctx *replace_ctx;
7845bcae31dSMichal Kazior 
785d01a1e65SMichal Kazior 	enum ieee80211_chanctx_mode mode;
7868a61af65SJohannes Berg 	bool driver_present;
787d01a1e65SMichal Kazior 
788d01a1e65SMichal Kazior 	struct ieee80211_chanctx_conf conf;
789d01a1e65SMichal Kazior };
790d01a1e65SMichal Kazior 
79132db6b54SKyeyoon Park struct mac80211_qos_map {
79232db6b54SKyeyoon Park 	struct cfg80211_qos_map qos_map;
79332db6b54SKyeyoon Park 	struct rcu_head rcu_head;
79432db6b54SKyeyoon Park };
79532db6b54SKyeyoon Park 
796f0706e82SJiri Benc struct ieee80211_sub_if_data {
797f0706e82SJiri Benc 	struct list_head list;
798f0706e82SJiri Benc 
799f0706e82SJiri Benc 	struct wireless_dev wdev;
800f0706e82SJiri Benc 
80111a843b7SJohannes Berg 	/* keys */
80211a843b7SJohannes Berg 	struct list_head key_list;
80311a843b7SJohannes Berg 
8043bff1865SYogesh Ashok Powar 	/* count for keys needing tailroom space allocation */
8053bff1865SYogesh Ashok Powar 	int crypto_tx_tailroom_needed_cnt;
8068d1f7ecdSJohannes Berg 	int crypto_tx_tailroom_pending_dec;
8078d1f7ecdSJohannes Berg 	struct delayed_work dec_tailroom_needed_wk;
8083bff1865SYogesh Ashok Powar 
809f0706e82SJiri Benc 	struct net_device *dev;
810f0706e82SJiri Benc 	struct ieee80211_local *local;
811f0706e82SJiri Benc 
81213262ffdSJiri Slaby 	unsigned int flags;
8137e9ed188SDaniel Drake 
81434d4bc4dSJohannes Berg 	unsigned long state;
81534d4bc4dSJohannes Berg 
816f0706e82SJiri Benc 	int drop_unencrypted;
817f0706e82SJiri Benc 
81847846c9bSJohannes Berg 	char name[IFNAMSIZ];
81947846c9bSJohannes Berg 
820f0706e82SJiri Benc 	/* Fragment table for host-based reassembly */
821f0706e82SJiri Benc 	struct ieee80211_fragment_entry	fragments[IEEE80211_FRAGMENT_MAX];
822f0706e82SJiri Benc 	unsigned int fragment_next;
823f0706e82SJiri Benc 
824b53be792SSimon Wunderlich 	/* TID bitmap for NoAck policy */
825b53be792SSimon Wunderlich 	u16 noack_map;
826b53be792SSimon Wunderlich 
82700e96decSYoni Divinsky 	/* bit field of ACM bits (BIT(802.1D tag)) */
82800e96decSYoni Divinsky 	u8 wmm_acm;
82900e96decSYoni Divinsky 
83040b275b6SJohannes Berg 	struct ieee80211_key __rcu *keys[NUM_DEFAULT_KEYS + NUM_DEFAULT_MGMT_KEYS];
83140b275b6SJohannes Berg 	struct ieee80211_key __rcu *default_unicast_key;
83240b275b6SJohannes Berg 	struct ieee80211_key __rcu *default_multicast_key;
83340b275b6SJohannes Berg 	struct ieee80211_key __rcu *default_mgmt_key;
834f0706e82SJiri Benc 
83594778280SJohannes Berg 	u16 sequence_number;
836a621fa4dSJohannes Berg 	__be16 control_port_protocol;
837a621fa4dSJohannes Berg 	bool control_port_no_encrypt;
8382475b1ccSMax Stepanov 	int encrypt_headroom;
83994778280SJohannes Berg 
84054bcbc69SJohannes Berg 	struct ieee80211_tx_queue_params tx_conf[IEEE80211_NUM_ACS];
84132db6b54SKyeyoon Park 	struct mac80211_qos_map __rcu *qos_map;
842f6f3def3SEliad Peller 
84373da7d5bSSimon Wunderlich 	struct work_struct csa_finalize_work;
84459af6928SMichal Kazior 	bool csa_block_tx; /* write-protected by sdata_lock and local->mtx */
84533787fc4SLuciano Coelho 	struct cfg80211_chan_def csa_chandef;
84673da7d5bSSimon Wunderlich 
847484298adSMichal Kazior 	struct list_head assigned_chanctx_list; /* protected by chanctx_mtx */
848e3afb920SMichal Kazior 	struct list_head reserved_chanctx_list; /* protected by chanctx_mtx */
849484298adSMichal Kazior 
85011335a55SLuciano Coelho 	/* context reservation -- protected with chanctx_mtx */
85111335a55SLuciano Coelho 	struct ieee80211_chanctx *reserved_chanctx;
85211335a55SLuciano Coelho 	struct cfg80211_chan_def reserved_chandef;
85309332481SMichal Kazior 	bool reserved_radar_required;
8545bcae31dSMichal Kazior 	bool reserved_ready;
85511335a55SLuciano Coelho 
85604ecd257SJohannes Berg 	/* used to reconfigure hardware SM PS */
85704ecd257SJohannes Berg 	struct work_struct recalc_smps;
85804ecd257SJohannes Berg 
85964592c8fSJohannes Berg 	struct work_struct work;
86035f20c14SJohannes Berg 	struct sk_buff_head skb_queue;
86135f20c14SJohannes Berg 
86204ecd257SJohannes Berg 	u8 needed_rx_chains;
86304ecd257SJohannes Berg 	enum ieee80211_smps_mode smps_mode;
86404ecd257SJohannes Berg 
8651ea6f9c0SJohannes Berg 	int user_power_level; /* in dBm */
8661ea6f9c0SJohannes Berg 	int ap_power_level; /* in dBm */
8671ea6f9c0SJohannes Berg 
868164eb02dSSimon Wunderlich 	bool radar_required;
869164eb02dSSimon Wunderlich 	struct delayed_work dfs_cac_timer_work;
870164eb02dSSimon Wunderlich 
8713e122be0SJohannes Berg 	/*
8723e122be0SJohannes Berg 	 * AP this belongs to: self in AP mode and
8733e122be0SJohannes Berg 	 * corresponding AP in VLAN mode, NULL for
8743e122be0SJohannes Berg 	 * all others (might be needed later in IBSS)
8753e122be0SJohannes Berg 	 */
8763e122be0SJohannes Berg 	struct ieee80211_if_ap *bss;
8773e122be0SJohannes Berg 
87837eb0b16SJouni Malinen 	/* bitmap of allowed (non-MCS) rate indexes for rate control */
87937eb0b16SJouni Malinen 	u32 rc_rateidx_mask[IEEE80211_NUM_BANDS];
8802ffbe6d3SFelix Fietkau 
8812ffbe6d3SFelix Fietkau 	bool rc_has_mcs_mask[IEEE80211_NUM_BANDS];
88219468413SSimon Wunderlich 	u8  rc_rateidx_mcs_mask[IEEE80211_NUM_BANDS][IEEE80211_HT_MCS_MASK_LEN];
883f0706e82SJiri Benc 
884f0706e82SJiri Benc 	union {
885f0706e82SJiri Benc 		struct ieee80211_if_ap ap;
886f0706e82SJiri Benc 		struct ieee80211_if_wds wds;
887f0706e82SJiri Benc 		struct ieee80211_if_vlan vlan;
88846900298SJohannes Berg 		struct ieee80211_if_managed mgd;
88946900298SJohannes Berg 		struct ieee80211_if_ibss ibss;
890472dbc45SJohannes Berg 		struct ieee80211_if_mesh mesh;
891239281f8SRostislav Lisovy 		struct ieee80211_if_ocb ocb;
8928cc9a739SMichael Wu 		u32 mntr_flags;
893f0706e82SJiri Benc 	} u;
894e9f207f0SJiri Benc 
895e9f207f0SJiri Benc #ifdef CONFIG_MAC80211_DEBUGFS
896e9f207f0SJiri Benc 	struct {
897295bafb4SBen Greear 		struct dentry *subdir_stations;
898f7e0104cSJohannes Berg 		struct dentry *default_unicast_key;
899f7e0104cSJohannes Berg 		struct dentry *default_multicast_key;
9003cfcf6acSJouni Malinen 		struct dentry *default_mgmt_key;
9017bcfaf2fSJohannes Berg 	} debugfs;
902e9f207f0SJiri Benc #endif
903529ba6e9SJohannes Berg 
90432bfd35dSJohannes Berg 	/* must be last, dynamically sized area in this! */
90532bfd35dSJohannes Berg 	struct ieee80211_vif vif;
906f0706e82SJiri Benc };
907f0706e82SJiri Benc 
90832bfd35dSJohannes Berg static inline
90932bfd35dSJohannes Berg struct ieee80211_sub_if_data *vif_to_sdata(struct ieee80211_vif *p)
91032bfd35dSJohannes Berg {
91132bfd35dSJohannes Berg 	return container_of(p, struct ieee80211_sub_if_data, vif);
91232bfd35dSJohannes Berg }
91332bfd35dSJohannes Berg 
9148d61ffa5SJohannes Berg static inline void sdata_lock(struct ieee80211_sub_if_data *sdata)
9158d61ffa5SJohannes Berg 	__acquires(&sdata->wdev.mtx)
9168d61ffa5SJohannes Berg {
9178d61ffa5SJohannes Berg 	mutex_lock(&sdata->wdev.mtx);
9188d61ffa5SJohannes Berg 	__acquire(&sdata->wdev.mtx);
9198d61ffa5SJohannes Berg }
9208d61ffa5SJohannes Berg 
9218d61ffa5SJohannes Berg static inline void sdata_unlock(struct ieee80211_sub_if_data *sdata)
9228d61ffa5SJohannes Berg 	__releases(&sdata->wdev.mtx)
9238d61ffa5SJohannes Berg {
9248d61ffa5SJohannes Berg 	mutex_unlock(&sdata->wdev.mtx);
9258d61ffa5SJohannes Berg 	__release(&sdata->wdev.mtx);
9268d61ffa5SJohannes Berg }
9278d61ffa5SJohannes Berg 
9287ca133bcSSimon Wunderlich #define sdata_dereference(p, sdata) \
9297ca133bcSSimon Wunderlich 	rcu_dereference_protected(p, lockdep_is_held(&sdata->wdev.mtx))
9307ca133bcSSimon Wunderlich 
9318d61ffa5SJohannes Berg static inline void
9328d61ffa5SJohannes Berg sdata_assert_lock(struct ieee80211_sub_if_data *sdata)
9338d61ffa5SJohannes Berg {
9348d61ffa5SJohannes Berg 	lockdep_assert_held(&sdata->wdev.mtx);
9358d61ffa5SJohannes Berg }
9368d61ffa5SJohannes Berg 
93755de908aSJohannes Berg static inline enum ieee80211_band
93855de908aSJohannes Berg ieee80211_get_sdata_band(struct ieee80211_sub_if_data *sdata)
93955de908aSJohannes Berg {
94055de908aSJohannes Berg 	enum ieee80211_band band = IEEE80211_BAND_2GHZ;
94155de908aSJohannes Berg 	struct ieee80211_chanctx_conf *chanctx_conf;
94255de908aSJohannes Berg 
94355de908aSJohannes Berg 	rcu_read_lock();
94455de908aSJohannes Berg 	chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
94555de908aSJohannes Berg 	if (!WARN_ON(!chanctx_conf))
9464bf88530SJohannes Berg 		band = chanctx_conf->def.chan->band;
94755de908aSJohannes Berg 	rcu_read_unlock();
94855de908aSJohannes Berg 
94955de908aSJohannes Berg 	return band;
95055de908aSJohannes Berg }
95155de908aSJohannes Berg 
952438b61b7SSimon Wunderlich static inline int
953438b61b7SSimon Wunderlich ieee80211_chandef_get_shift(struct cfg80211_chan_def *chandef)
954438b61b7SSimon Wunderlich {
955438b61b7SSimon Wunderlich 	switch (chandef->width) {
956438b61b7SSimon Wunderlich 	case NL80211_CHAN_WIDTH_5:
957438b61b7SSimon Wunderlich 		return 2;
958438b61b7SSimon Wunderlich 	case NL80211_CHAN_WIDTH_10:
959438b61b7SSimon Wunderlich 		return 1;
960438b61b7SSimon Wunderlich 	default:
961438b61b7SSimon Wunderlich 		return 0;
962438b61b7SSimon Wunderlich 	}
963438b61b7SSimon Wunderlich }
964438b61b7SSimon Wunderlich 
965438b61b7SSimon Wunderlich static inline int
966438b61b7SSimon Wunderlich ieee80211_vif_get_shift(struct ieee80211_vif *vif)
967438b61b7SSimon Wunderlich {
968438b61b7SSimon Wunderlich 	struct ieee80211_chanctx_conf *chanctx_conf;
969438b61b7SSimon Wunderlich 	int shift = 0;
970438b61b7SSimon Wunderlich 
971438b61b7SSimon Wunderlich 	rcu_read_lock();
972438b61b7SSimon Wunderlich 	chanctx_conf = rcu_dereference(vif->chanctx_conf);
973438b61b7SSimon Wunderlich 	if (chanctx_conf)
974438b61b7SSimon Wunderlich 		shift = ieee80211_chandef_get_shift(&chanctx_conf->def);
975438b61b7SSimon Wunderlich 	rcu_read_unlock();
976438b61b7SSimon Wunderlich 
977438b61b7SSimon Wunderlich 	return shift;
978438b61b7SSimon Wunderlich }
979438b61b7SSimon Wunderlich 
98008cf42e8SMichal Kazior struct ieee80211_rx_agg {
98108cf42e8SMichal Kazior 	u8 addr[ETH_ALEN];
98208cf42e8SMichal Kazior 	u16 tid;
98308cf42e8SMichal Kazior };
98408cf42e8SMichal Kazior 
985c1475ca9SJohannes Berg enum sdata_queue_type {
986c1475ca9SJohannes Berg 	IEEE80211_SDATA_QUEUE_TYPE_FRAME	= 0,
987c1475ca9SJohannes Berg 	IEEE80211_SDATA_QUEUE_AGG_START		= 1,
988c1475ca9SJohannes Berg 	IEEE80211_SDATA_QUEUE_AGG_STOP		= 2,
98908cf42e8SMichal Kazior 	IEEE80211_SDATA_QUEUE_RX_AGG_START	= 3,
99008cf42e8SMichal Kazior 	IEEE80211_SDATA_QUEUE_RX_AGG_STOP	= 4,
991c1475ca9SJohannes Berg };
992c1475ca9SJohannes Berg 
993f0706e82SJiri Benc enum {
994f0706e82SJiri Benc 	IEEE80211_RX_MSG	= 1,
995f0706e82SJiri Benc 	IEEE80211_TX_STATUS_MSG	= 2,
996f0706e82SJiri Benc };
997f0706e82SJiri Benc 
998ce7c9111SKalle Valo enum queue_stop_reason {
999ce7c9111SKalle Valo 	IEEE80211_QUEUE_STOP_REASON_DRIVER,
1000520eb820SKalle Valo 	IEEE80211_QUEUE_STOP_REASON_PS,
100196f5e66eSJohannes Berg 	IEEE80211_QUEUE_STOP_REASON_CSA,
100296f5e66eSJohannes Berg 	IEEE80211_QUEUE_STOP_REASON_AGGREGATION,
100325420604SJohannes Berg 	IEEE80211_QUEUE_STOP_REASON_SUSPEND,
10048f77f384SJohannes Berg 	IEEE80211_QUEUE_STOP_REASON_SKB_ADD,
10056c17b77bSSeth Forshee 	IEEE80211_QUEUE_STOP_REASON_OFFCHANNEL,
1006445ea4e8SJohannes Berg 	IEEE80211_QUEUE_STOP_REASON_FLUSH,
1007db67d661SArik Nemtsov 	IEEE80211_QUEUE_STOP_REASON_TDLS_TEARDOWN,
1008cca07b00SLuciano Coelho 
1009cca07b00SLuciano Coelho 	IEEE80211_QUEUE_STOP_REASONS,
1010ce7c9111SKalle Valo };
1011ce7c9111SKalle Valo 
101265a6538aSLuciano Coelho #ifdef CONFIG_MAC80211_LEDS
1013e1e54068SJohannes Berg struct tpt_led_trigger {
1014e1e54068SJohannes Berg 	struct led_trigger trig;
1015e1e54068SJohannes Berg 	char name[32];
1016e1e54068SJohannes Berg 	const struct ieee80211_tpt_blink *blink_table;
1017e1e54068SJohannes Berg 	unsigned int blink_table_len;
1018e1e54068SJohannes Berg 	struct timer_list timer;
1019e1e54068SJohannes Berg 	unsigned long prev_traffic;
1020e1e54068SJohannes Berg 	unsigned long tx_bytes, rx_bytes;
102167408c8cSJohannes Berg 	unsigned int active, want;
102267408c8cSJohannes Berg 	bool running;
1023e1e54068SJohannes Berg };
102465a6538aSLuciano Coelho #endif
1025e1e54068SJohannes Berg 
1026ad38bfc9SMatti Gottlieb /*
1027ad38bfc9SMatti Gottlieb  * struct ieee80211_tx_latency_bin_ranges - Tx latency statistics bins ranges
1028ad38bfc9SMatti Gottlieb  *
1029ad38bfc9SMatti Gottlieb  * Measuring Tx latency statistics. Counts how many Tx frames transmitted in a
1030ad38bfc9SMatti Gottlieb  * certain latency range (in Milliseconds). Each station that uses these
1031ad38bfc9SMatti Gottlieb  * ranges will have bins to count the amount of frames received in that range.
1032ad38bfc9SMatti Gottlieb  * The user can configure the ranges via debugfs.
1033ad38bfc9SMatti Gottlieb  * If ranges is NULL then Tx latency statistics bins are disabled for all
1034ad38bfc9SMatti Gottlieb  * stations.
1035ad38bfc9SMatti Gottlieb  *
1036ad38bfc9SMatti Gottlieb  * @n_ranges: number of ranges that are taken in account
1037ad38bfc9SMatti Gottlieb  * @ranges: the ranges that the user requested or NULL if disabled.
1038ad38bfc9SMatti Gottlieb  */
1039ad38bfc9SMatti Gottlieb struct ieee80211_tx_latency_bin_ranges {
1040ad38bfc9SMatti Gottlieb 	int n_ranges;
1041ad38bfc9SMatti Gottlieb 	u32 ranges[];
1042ad38bfc9SMatti Gottlieb };
1043ad38bfc9SMatti Gottlieb 
1044142b9f50SHelmut Schaa /**
1045142b9f50SHelmut Schaa  * mac80211 scan flags - currently active scan mode
1046142b9f50SHelmut Schaa  *
1047142b9f50SHelmut Schaa  * @SCAN_SW_SCANNING: We're currently in the process of scanning but may as
1048142b9f50SHelmut Schaa  *	well be on the operating channel
1049142b9f50SHelmut Schaa  * @SCAN_HW_SCANNING: The hardware is scanning for us, we have no way to
1050142b9f50SHelmut Schaa  *	determine if we are on the operating channel or not
10518a690674SBen Greear  * @SCAN_ONCHANNEL_SCANNING:  Do a software scan on only the current operating
10528a690674SBen Greear  *	channel. This should not interrupt normal traffic.
10538789d459SJohannes Berg  * @SCAN_COMPLETED: Set for our scan work function when the driver reported
10548789d459SJohannes Berg  *	that the scan completed.
10558789d459SJohannes Berg  * @SCAN_ABORTED: Set for our scan work function when the driver reported
10568789d459SJohannes Berg  *	a scan complete for an aborted scan.
1057a754055aSEmmanuel Grumbach  * @SCAN_HW_CANCELLED: Set for our scan work function when the scan is being
1058a754055aSEmmanuel Grumbach  *	cancelled.
1059142b9f50SHelmut Schaa  */
1060fbe9c429SHelmut Schaa enum {
1061fbe9c429SHelmut Schaa 	SCAN_SW_SCANNING,
1062142b9f50SHelmut Schaa 	SCAN_HW_SCANNING,
10638a690674SBen Greear 	SCAN_ONCHANNEL_SCANNING,
10648789d459SJohannes Berg 	SCAN_COMPLETED,
10658789d459SJohannes Berg 	SCAN_ABORTED,
1066a754055aSEmmanuel Grumbach 	SCAN_HW_CANCELLED,
1067142b9f50SHelmut Schaa };
1068142b9f50SHelmut Schaa 
1069142b9f50SHelmut Schaa /**
1070142b9f50SHelmut Schaa  * enum mac80211_scan_state - scan state machine states
1071142b9f50SHelmut Schaa  *
1072142b9f50SHelmut Schaa  * @SCAN_DECISION: Main entry point to the scan state machine, this state
1073142b9f50SHelmut Schaa  *	determines if we should keep on scanning or switch back to the
1074142b9f50SHelmut Schaa  *	operating channel
1075142b9f50SHelmut Schaa  * @SCAN_SET_CHANNEL: Set the next channel to be scanned
1076142b9f50SHelmut Schaa  * @SCAN_SEND_PROBE: Send probe requests and wait for probe responses
107707ef03eeSJohannes Berg  * @SCAN_SUSPEND: Suspend the scan and go back to operating channel to
107807ef03eeSJohannes Berg  *	send out data
107907ef03eeSJohannes Berg  * @SCAN_RESUME: Resume the scan and scan the next channel
1080cd2bb512SSam Leffler  * @SCAN_ABORT: Abort the scan and go back to operating channel
1081142b9f50SHelmut Schaa  */
1082142b9f50SHelmut Schaa enum mac80211_scan_state {
1083142b9f50SHelmut Schaa 	SCAN_DECISION,
1084142b9f50SHelmut Schaa 	SCAN_SET_CHANNEL,
1085142b9f50SHelmut Schaa 	SCAN_SEND_PROBE,
108607ef03eeSJohannes Berg 	SCAN_SUSPEND,
108707ef03eeSJohannes Berg 	SCAN_RESUME,
1088cd2bb512SSam Leffler 	SCAN_ABORT,
1089fbe9c429SHelmut Schaa };
1090fbe9c429SHelmut Schaa 
1091f0706e82SJiri Benc struct ieee80211_local {
1092f0706e82SJiri Benc 	/* embed the driver visible part.
1093f0706e82SJiri Benc 	 * don't cast (use the static inlines below), but we keep
1094f0706e82SJiri Benc 	 * it first anyway so they become a no-op */
1095f0706e82SJiri Benc 	struct ieee80211_hw hw;
1096f0706e82SJiri Benc 
1097f0706e82SJiri Benc 	const struct ieee80211_ops *ops;
1098f0706e82SJiri Benc 
109942935ecaSLuis R. Rodriguez 	/*
110042935ecaSLuis R. Rodriguez 	 * private workqueue to mac80211. mac80211 makes this accessible
110142935ecaSLuis R. Rodriguez 	 * via ieee80211_queue_work()
110242935ecaSLuis R. Rodriguez 	 */
110342935ecaSLuis R. Rodriguez 	struct workqueue_struct *workqueue;
110442935ecaSLuis R. Rodriguez 
1105e4e72fb4SJohannes Berg 	unsigned long queue_stop_reasons[IEEE80211_MAX_QUEUES];
1106cca07b00SLuciano Coelho 	int q_stop_reasons[IEEE80211_MAX_QUEUES][IEEE80211_QUEUE_STOP_REASONS];
110796f5e66eSJohannes Berg 	/* also used to protect ampdu_ac_queue and amdpu_ac_stop_refcnt */
1108ce7c9111SKalle Valo 	spinlock_t queue_stop_reason_lock;
110996f5e66eSJohannes Berg 
1110f0706e82SJiri Benc 	int open_count;
11113d30d949SMichael Wu 	int monitors, cooked_mntrs;
11128cc9a739SMichael Wu 	/* number of interfaces with corresponding FIF_ flags */
11137be5086dSJohannes Berg 	int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss, fif_pspoll,
11147be5086dSJohannes Berg 	    fif_probe_req;
11157be5086dSJohannes Berg 	int probe_req_reg;
11164150c572SJohannes Berg 	unsigned int filter_flags; /* FIF_* */
11173b8d81e0SJohannes Berg 
11183ffc2a90SJohannes Berg 	bool wiphy_ciphers_allocated;
11193ffc2a90SJohannes Berg 
1120fe57d9f5SJohannes Berg 	bool use_chanctx;
1121fe57d9f5SJohannes Berg 
11223b8d81e0SJohannes Berg 	/* protects the aggregated multicast list and filter calls */
11233b8d81e0SJohannes Berg 	spinlock_t filter_lock;
11243b8d81e0SJohannes Berg 
11253ac64beeSJohannes Berg 	/* used for uploading changed mc list */
11263ac64beeSJohannes Berg 	struct work_struct reconfig_filter;
11273ac64beeSJohannes Berg 
11283b8d81e0SJohannes Berg 	/* aggregated multicast list */
112922bedad3SJiri Pirko 	struct netdev_hw_addr_list mc_list;
11303b8d81e0SJohannes Berg 
1131d0709a65SJohannes Berg 	bool tim_in_locked_section; /* see ieee80211_beacon_get() */
11325bb644a0SJohannes Berg 
11335bb644a0SJohannes Berg 	/*
11345bb644a0SJohannes Berg 	 * suspended is true if we finished all the suspend _and_ we have
11355bb644a0SJohannes Berg 	 * not yet come up from resume. This is to be used by mac80211
11365bb644a0SJohannes Berg 	 * to ensure driver sanity during suspend and mac80211's own
11375bb644a0SJohannes Berg 	 * sanity. It can eventually be used for WoW as well.
11385bb644a0SJohannes Berg 	 */
11395bb644a0SJohannes Berg 	bool suspended;
11405bb644a0SJohannes Berg 
11415bb644a0SJohannes Berg 	/*
1142ceb99fe0SJohannes Berg 	 * Resuming is true while suspended, but when we're reprogramming the
1143ceb99fe0SJohannes Berg 	 * hardware -- at that time it's allowed to use ieee80211_queue_work()
1144ceb99fe0SJohannes Berg 	 * again even though some other parts of the stack are still suspended
1145ceb99fe0SJohannes Berg 	 * and we still drop received frames to avoid waking the stack.
1146ceb99fe0SJohannes Berg 	 */
1147ceb99fe0SJohannes Berg 	bool resuming;
1148ceb99fe0SJohannes Berg 
1149ceb99fe0SJohannes Berg 	/*
11505bb644a0SJohannes Berg 	 * quiescing is true during the suspend process _only_ to
11515bb644a0SJohannes Berg 	 * ease timer cancelling etc.
11525bb644a0SJohannes Berg 	 */
11535bb644a0SJohannes Berg 	bool quiescing;
11545bb644a0SJohannes Berg 
1155ea77f12fSJohannes Berg 	/* device is started */
1156ea77f12fSJohannes Berg 	bool started;
1157ea77f12fSJohannes Berg 
115804800adaSArik Nemtsov 	/* device is during a HW reconfig */
115904800adaSArik Nemtsov 	bool in_reconfig;
116004800adaSArik Nemtsov 
1161eecc4800SJohannes Berg 	/* wowlan is enabled -- don't reconfig on resume */
1162eecc4800SJohannes Berg 	bool wowlan;
1163eecc4800SJohannes Berg 
1164164eb02dSSimon Wunderlich 	/* DFS/radar detection is enabled */
1165164eb02dSSimon Wunderlich 	bool radar_detect_enabled;
1166164eb02dSSimon Wunderlich 	struct work_struct radar_detected_work;
1167164eb02dSSimon Wunderlich 
116804ecd257SJohannes Berg 	/* number of RX chains the hardware has */
116904ecd257SJohannes Berg 	u8 rx_chains;
117004ecd257SJohannes Berg 
1171b306f453SJohannes Berg 	int tx_headroom; /* required headroom for hardware/radiotap */
1172f0706e82SJiri Benc 
1173f0706e82SJiri Benc 	/* Tasklet and skb queue to process calls from IRQ mode. All frames
1174f0706e82SJiri Benc 	 * added to skb_queue will be processed, but frames in
1175f0706e82SJiri Benc 	 * skb_queue_unreliable may be dropped if the total length of these
1176f0706e82SJiri Benc 	 * queues increases over the limit. */
1177f0706e82SJiri Benc #define IEEE80211_IRQSAFE_QUEUE_LIMIT 128
1178f0706e82SJiri Benc 	struct tasklet_struct tasklet;
1179f0706e82SJiri Benc 	struct sk_buff_head skb_queue;
1180f0706e82SJiri Benc 	struct sk_buff_head skb_queue_unreliable;
1181f0706e82SJiri Benc 
1182f9e124fbSChristian Lamparter 	spinlock_t rx_path_lock;
118324a8fdadSChristian Lamparter 
1184d0709a65SJohannes Berg 	/* Station data */
1185d0709a65SJohannes Berg 	/*
11864d33960bSJohannes Berg 	 * The mutex only protects the list, hash table and
11874d33960bSJohannes Berg 	 * counter, reads are done with RCU.
1188d0709a65SJohannes Berg 	 */
118934e89507SJohannes Berg 	struct mutex sta_mtx;
11904d33960bSJohannes Berg 	spinlock_t tim_lock;
1191d0709a65SJohannes Berg 	unsigned long num_sta;
11924d33960bSJohannes Berg 	struct list_head sta_list;
119340b275b6SJohannes Berg 	struct sta_info __rcu *sta_hash[STA_HASH_SIZE];
1194f0706e82SJiri Benc 	struct timer_list sta_cleanup;
1195f5ea9120SJohannes Berg 	int sta_generation;
1196f0706e82SJiri Benc 
1197ad38bfc9SMatti Gottlieb 	/*
1198ad38bfc9SMatti Gottlieb 	 * Tx latency statistics parameters for all stations.
1199ad38bfc9SMatti Gottlieb 	 * Can enable via debugfs (NULL when disabled).
1200ad38bfc9SMatti Gottlieb 	 */
1201ad38bfc9SMatti Gottlieb 	struct ieee80211_tx_latency_bin_ranges __rcu *tx_latency;
1202ad38bfc9SMatti Gottlieb 
12032a577d98SJohannes Berg 	struct sk_buff_head pending[IEEE80211_MAX_QUEUES];
1204f0706e82SJiri Benc 	struct tasklet_struct tx_pending_tasklet;
1205f0706e82SJiri Benc 
1206a6a67db2SJohannes Berg 	atomic_t agg_queue_stop[IEEE80211_MAX_QUEUES];
1207cd8ffc80SJohannes Berg 
1208f0706e82SJiri Benc 	/* number of interfaces with corresponding IFF_ flags */
120953918994SJohannes Berg 	atomic_t iff_allmultis, iff_promiscs;
1210f0706e82SJiri Benc 
1211f0706e82SJiri Benc 	struct rate_control_ref *rate_ctrl;
1212f0706e82SJiri Benc 
12135f9f1812SFelix Fietkau 	struct crypto_cipher *wep_tx_tfm;
12145f9f1812SFelix Fietkau 	struct crypto_cipher *wep_rx_tfm;
1215f0706e82SJiri Benc 	u32 wep_iv;
1216f0706e82SJiri Benc 
1217c771c9d8SJohannes Berg 	/* see iface.c */
121879010420SJohannes Berg 	struct list_head interfaces;
1219c771c9d8SJohannes Berg 	struct mutex iflist_mtx;
122079010420SJohannes Berg 
1221b16bd15cSJohannes Berg 	/*
1222ad0e2b5aSJohannes Berg 	 * Key mutex, protects sdata's key_list and sta_info's
1223b16bd15cSJohannes Berg 	 * key pointers (write access, they're RCU.)
1224b16bd15cSJohannes Berg 	 */
1225ad0e2b5aSJohannes Berg 	struct mutex key_mtx;
1226b16bd15cSJohannes Berg 
1227a1699b75SJohannes Berg 	/* mutex for scan and work locking */
1228a1699b75SJohannes Berg 	struct mutex mtx;
1229b16bd15cSJohannes Berg 
1230c2b13452SJohannes Berg 	/* Scanning and BSS list */
1231fbe9c429SHelmut Schaa 	unsigned long scanning;
12322a519311SJohannes Berg 	struct cfg80211_ssid scan_ssid;
12335ba63533SJohannes Berg 	struct cfg80211_scan_request *int_scan_req;
1234c56ef672SDavid Spinadel 	struct cfg80211_scan_request *scan_req;
1235c56ef672SDavid Spinadel 	struct ieee80211_scan_request *hw_scan_req;
12367ca15a0aSSimon Wunderlich 	struct cfg80211_chan_def scan_chandef;
12374d36ec58SJohannes Berg 	enum ieee80211_band hw_scan_band;
1238f0706e82SJiri Benc 	int scan_channel_idx;
1239de95a54bSJohannes Berg 	int scan_ies_len;
1240c604b9f2SJohannes Berg 	int hw_scan_ies_bufsize;
12418318d78aSJohannes Berg 
124285a9994aSLuciano Coelho 	struct work_struct sched_scan_stopped_work;
12435260a5b2SJohannes Berg 	struct ieee80211_sub_if_data __rcu *sched_scan_sdata;
1244d43c6b6eSDavid Spinadel 	struct cfg80211_sched_scan_request *sched_scan_req;
124579f460caSLuciano Coelho 
1246df13cce5SHelmut Schaa 	unsigned long leave_oper_channel_time;
1247977923b0SHelmut Schaa 	enum mac80211_scan_state next_scan_state;
1248f0706e82SJiri Benc 	struct delayed_work scan_work;
1249e2fd5dbcSJohannes Berg 	struct ieee80211_sub_if_data __rcu *scan_sdata;
125055de908aSJohannes Berg 	/* For backward compatibility only -- do not use */
1251675a0b04SKarl Beldan 	struct cfg80211_chan_def _oper_chandef;
1252f0706e82SJiri Benc 
1253b8bc4b0aSJohannes Berg 	/* Temporary remain-on-channel for off-channel operations */
1254b8bc4b0aSJohannes Berg 	struct ieee80211_channel *tmp_channel;
1255b8bc4b0aSJohannes Berg 
1256d01a1e65SMichal Kazior 	/* channel contexts */
1257d01a1e65SMichal Kazior 	struct list_head chanctx_list;
1258d01a1e65SMichal Kazior 	struct mutex chanctx_mtx;
1259d01a1e65SMichal Kazior 
1260f0706e82SJiri Benc 	/* SNMP counters */
1261f0706e82SJiri Benc 	/* dot11CountersTable */
1262f0706e82SJiri Benc 	u32 dot11TransmittedFragmentCount;
1263f0706e82SJiri Benc 	u32 dot11MulticastTransmittedFrameCount;
1264f0706e82SJiri Benc 	u32 dot11FailedCount;
1265f0706e82SJiri Benc 	u32 dot11RetryCount;
1266f0706e82SJiri Benc 	u32 dot11MultipleRetryCount;
1267f0706e82SJiri Benc 	u32 dot11FrameDuplicateCount;
1268f0706e82SJiri Benc 	u32 dot11ReceivedFragmentCount;
1269f0706e82SJiri Benc 	u32 dot11MulticastReceivedFrameCount;
1270f0706e82SJiri Benc 	u32 dot11TransmittedFrameCount;
1271f0706e82SJiri Benc 
1272f0706e82SJiri Benc #ifdef CONFIG_MAC80211_LEDS
1273cdcb006fSIvo van Doorn 	struct led_trigger *tx_led, *rx_led, *assoc_led, *radio_led;
1274e1e54068SJohannes Berg 	struct tpt_led_trigger *tpt_led_trigger;
1275cdcb006fSIvo van Doorn 	char tx_led_name[32], rx_led_name[32],
1276cdcb006fSIvo van Doorn 	     assoc_led_name[32], radio_led_name[32];
1277f0706e82SJiri Benc #endif
1278f0706e82SJiri Benc 
1279f0706e82SJiri Benc #ifdef CONFIG_MAC80211_DEBUG_COUNTERS
1280f0706e82SJiri Benc 	/* TX/RX handler statistics */
1281f0706e82SJiri Benc 	unsigned int tx_handlers_drop;
1282f0706e82SJiri Benc 	unsigned int tx_handlers_queued;
1283f0706e82SJiri Benc 	unsigned int tx_handlers_drop_unencrypted;
1284f0706e82SJiri Benc 	unsigned int tx_handlers_drop_fragment;
1285f0706e82SJiri Benc 	unsigned int tx_handlers_drop_wep;
1286f0706e82SJiri Benc 	unsigned int tx_handlers_drop_not_assoc;
1287f0706e82SJiri Benc 	unsigned int tx_handlers_drop_unauth_port;
1288f0706e82SJiri Benc 	unsigned int rx_handlers_drop;
1289f0706e82SJiri Benc 	unsigned int rx_handlers_queued;
1290f0706e82SJiri Benc 	unsigned int rx_handlers_drop_nullfunc;
1291f0706e82SJiri Benc 	unsigned int rx_handlers_drop_defrag;
1292f0706e82SJiri Benc 	unsigned int rx_handlers_drop_short;
1293f0706e82SJiri Benc 	unsigned int tx_expand_skb_head;
1294f0706e82SJiri Benc 	unsigned int tx_expand_skb_head_cloned;
1295f0706e82SJiri Benc 	unsigned int rx_expand_skb_head;
1296f0706e82SJiri Benc 	unsigned int rx_expand_skb_head2;
1297f0706e82SJiri Benc 	unsigned int rx_handlers_fragments;
1298f0706e82SJiri Benc 	unsigned int tx_status_drop;
1299f0706e82SJiri Benc #define I802_DEBUG_INC(c) (c)++
1300f0706e82SJiri Benc #else /* CONFIG_MAC80211_DEBUG_COUNTERS */
1301f0706e82SJiri Benc #define I802_DEBUG_INC(c) do { } while (0)
1302f0706e82SJiri Benc #endif /* CONFIG_MAC80211_DEBUG_COUNTERS */
1303f0706e82SJiri Benc 
1304f0706e82SJiri Benc 
1305f0706e82SJiri Benc 	int total_ps_buffered; /* total number of all buffered unicast and
1306f0706e82SJiri Benc 				* multicast packets for power saving stations
1307f0706e82SJiri Benc 				*/
1308520eb820SKalle Valo 
1309572e0012SKalle Valo 	bool pspolling;
1310b203ffc3SJouni Malinen 	bool offchannel_ps_enabled;
1311965bedadSJohannes Berg 	/*
1312965bedadSJohannes Berg 	 * PS can only be enabled when we have exactly one managed
1313965bedadSJohannes Berg 	 * interface (and monitors) in PS, this then points there.
1314965bedadSJohannes Berg 	 */
1315965bedadSJohannes Berg 	struct ieee80211_sub_if_data *ps_sdata;
1316520eb820SKalle Valo 	struct work_struct dynamic_ps_enable_work;
1317520eb820SKalle Valo 	struct work_struct dynamic_ps_disable_work;
1318520eb820SKalle Valo 	struct timer_list dynamic_ps_timer;
131910f644a4SJohannes Berg 	struct notifier_block network_latency_notifier;
13202b2c009eSJuuso Oikarinen 	struct notifier_block ifa_notifier;
1321a65240c1SJohannes Berg 	struct notifier_block ifa6_notifier;
1322f0706e82SJiri Benc 
1323ff616381SJuuso Oikarinen 	/*
1324ff616381SJuuso Oikarinen 	 * The dynamic ps timeout configured from user space via WEXT -
1325ff616381SJuuso Oikarinen 	 * this will override whatever chosen by mac80211 internally.
1326ff616381SJuuso Oikarinen 	 */
1327ff616381SJuuso Oikarinen 	int dynamic_ps_forced_timeout;
1328ff616381SJuuso Oikarinen 
13291ea6f9c0SJohannes Berg 	int user_power_level; /* in dBm, for all interfaces */
13302bf30fabSJohannes Berg 
13310f78231bSJohannes Berg 	enum ieee80211_smps_mode smps_mode;
13320f78231bSJohannes Berg 
1333f2753ddbSJohannes Berg 	struct work_struct restart_work;
1334f2753ddbSJohannes Berg 
1335e9f207f0SJiri Benc #ifdef CONFIG_MAC80211_DEBUGFS
1336e9f207f0SJiri Benc 	struct local_debugfsdentries {
13374b7679a5SJohannes Berg 		struct dentry *rcdir;
1338e9f207f0SJiri Benc 		struct dentry *keys;
1339e9f207f0SJiri Benc 	} debugfs;
1340e9f207f0SJiri Benc #endif
13414e6cbfd0SJohn W. Linville 
13422eb278e0SJohannes Berg 	/*
13432eb278e0SJohannes Berg 	 * Remain-on-channel support
13442eb278e0SJohannes Berg 	 */
13452eb278e0SJohannes Berg 	struct list_head roc_list;
134621f83589SJohannes Berg 	struct work_struct hw_roc_start, hw_roc_done;
13472eb278e0SJohannes Berg 	unsigned long hw_roc_start_time;
134850febf6aSJohannes Berg 	u64 roc_cookie_counter;
134921f83589SJohannes Berg 
1350a729cff8SJohannes Berg 	struct idr ack_status_frames;
1351a729cff8SJohannes Berg 	spinlock_t ack_status_lock;
1352a729cff8SJohannes Berg 
1353f142c6b9SJohannes Berg 	struct ieee80211_sub_if_data __rcu *p2p_sdata;
1354f142c6b9SJohannes Berg 
135506d181a8SJohannes Berg 	struct napi_struct *napi;
135606d181a8SJohannes Berg 
13574b6f1dd6SJohannes Berg 	/* virtual monitor interface */
13584b6f1dd6SJohannes Berg 	struct ieee80211_sub_if_data __rcu *monitor_sdata;
13594bf88530SJohannes Berg 	struct cfg80211_chan_def monitor_chandef;
1360e9a21949SLuciano Coelho 
1361e9a21949SLuciano Coelho 	/* extended capabilities provided by mac80211 */
1362e9a21949SLuciano Coelho 	u8 ext_capa[8];
1363f0706e82SJiri Benc };
1364f0706e82SJiri Benc 
13653e122be0SJohannes Berg static inline struct ieee80211_sub_if_data *
13663e122be0SJohannes Berg IEEE80211_DEV_TO_SUB_IF(struct net_device *dev)
13673e122be0SJohannes Berg {
13683e122be0SJohannes Berg 	return netdev_priv(dev);
13693e122be0SJohannes Berg }
13703e122be0SJohannes Berg 
137171bbc994SJohannes Berg static inline struct ieee80211_sub_if_data *
137271bbc994SJohannes Berg IEEE80211_WDEV_TO_SUB_IF(struct wireless_dev *wdev)
137371bbc994SJohannes Berg {
137471bbc994SJohannes Berg 	return container_of(wdev, struct ieee80211_sub_if_data, wdev);
137571bbc994SJohannes Berg }
137671bbc994SJohannes Berg 
1377c1475ca9SJohannes Berg /* this struct represents 802.11n's RA/TID combination */
1378eadc8d9eSRon Rindjunsky struct ieee80211_ra_tid {
1379eadc8d9eSRon Rindjunsky 	u8 ra[ETH_ALEN];
1380eadc8d9eSRon Rindjunsky 	u16 tid;
1381eadc8d9eSRon Rindjunsky };
1382eadc8d9eSRon Rindjunsky 
1383c0f17eb9SChun-Yeow Yeoh /* this struct holds the value parsing from channel switch IE  */
1384c0f17eb9SChun-Yeow Yeoh struct ieee80211_csa_ie {
1385c0f17eb9SChun-Yeow Yeoh 	struct cfg80211_chan_def chandef;
1386c0f17eb9SChun-Yeow Yeoh 	u8 mode;
1387c0f17eb9SChun-Yeow Yeoh 	u8 count;
1388c0f17eb9SChun-Yeow Yeoh 	u8 ttl;
13893f718fd8SChun-Yeow Yeoh 	u16 pre_value;
1390c0f17eb9SChun-Yeow Yeoh };
1391c0f17eb9SChun-Yeow Yeoh 
1392dd76986bSJohannes Berg /* Parsed Information Elements */
1393dd76986bSJohannes Berg struct ieee802_11_elems {
13944a3cb702SJohannes Berg 	const u8 *ie_start;
1395dd76986bSJohannes Berg 	size_t total_len;
1396dd76986bSJohannes Berg 
1397dd76986bSJohannes Berg 	/* pointers to IEs */
13984a3cb702SJohannes Berg 	const u8 *ssid;
13994a3cb702SJohannes Berg 	const u8 *supp_rates;
14004a3cb702SJohannes Berg 	const u8 *ds_params;
14014a3cb702SJohannes Berg 	const struct ieee80211_tim_ie *tim;
14024a3cb702SJohannes Berg 	const u8 *challenge;
14034a3cb702SJohannes Berg 	const u8 *rsn;
14044a3cb702SJohannes Berg 	const u8 *erp_info;
14054a3cb702SJohannes Berg 	const u8 *ext_supp_rates;
14064a3cb702SJohannes Berg 	const u8 *wmm_info;
14074a3cb702SJohannes Berg 	const u8 *wmm_param;
14084a3cb702SJohannes Berg 	const struct ieee80211_ht_cap *ht_cap_elem;
14094a3cb702SJohannes Berg 	const struct ieee80211_ht_operation *ht_operation;
14104a3cb702SJohannes Berg 	const struct ieee80211_vht_cap *vht_cap_elem;
14114a3cb702SJohannes Berg 	const struct ieee80211_vht_operation *vht_operation;
14124a3cb702SJohannes Berg 	const struct ieee80211_meshconf_ie *mesh_config;
14134a3cb702SJohannes Berg 	const u8 *mesh_id;
14144a3cb702SJohannes Berg 	const u8 *peering;
14154a3cb702SJohannes Berg 	const __le16 *awake_window;
14164a3cb702SJohannes Berg 	const u8 *preq;
14174a3cb702SJohannes Berg 	const u8 *prep;
14184a3cb702SJohannes Berg 	const u8 *perr;
14194a3cb702SJohannes Berg 	const struct ieee80211_rann_ie *rann;
14204a3cb702SJohannes Berg 	const struct ieee80211_channel_sw_ie *ch_switch_ie;
1421b4f286a1SJohannes Berg 	const struct ieee80211_ext_chansw_ie *ext_chansw_ie;
1422b2e506bfSJohannes Berg 	const struct ieee80211_wide_bw_chansw_ie *wide_bw_chansw_ie;
14234a3cb702SJohannes Berg 	const u8 *country_elem;
14244a3cb702SJohannes Berg 	const u8 *pwr_constr_elem;
1425c8d65917SSteinar H. Gunderson 	const u8 *cisco_dtpc_elem;
142679ba1d89SJohannes Berg 	const struct ieee80211_timeout_interval_ie *timeout_int;
14274a3cb702SJohannes Berg 	const u8 *opmode_notif;
142885220d71SJohannes Berg 	const struct ieee80211_sec_chan_offs_ie *sec_chan_offs;
14298f2535b9SChun-Yeow Yeoh 	const struct ieee80211_mesh_chansw_params_ie *mesh_chansw_params_ie;
1430dd76986bSJohannes Berg 
1431dd76986bSJohannes Berg 	/* length of them, respectively */
1432dd76986bSJohannes Berg 	u8 ssid_len;
1433dd76986bSJohannes Berg 	u8 supp_rates_len;
1434dd76986bSJohannes Berg 	u8 tim_len;
1435dd76986bSJohannes Berg 	u8 challenge_len;
1436dd76986bSJohannes Berg 	u8 rsn_len;
1437dd76986bSJohannes Berg 	u8 ext_supp_rates_len;
1438dd76986bSJohannes Berg 	u8 wmm_info_len;
1439dd76986bSJohannes Berg 	u8 wmm_param_len;
1440dd76986bSJohannes Berg 	u8 mesh_id_len;
1441dd76986bSJohannes Berg 	u8 peering_len;
1442dd76986bSJohannes Berg 	u8 preq_len;
1443dd76986bSJohannes Berg 	u8 prep_len;
1444dd76986bSJohannes Berg 	u8 perr_len;
1445dd76986bSJohannes Berg 	u8 country_elem_len;
1446fcff4f10SPaul Stewart 
1447fcff4f10SPaul Stewart 	/* whether a parse error occurred while retrieving these elements */
1448fcff4f10SPaul Stewart 	bool parse_error;
1449dd76986bSJohannes Berg };
1450dd76986bSJohannes Berg 
1451f0706e82SJiri Benc static inline struct ieee80211_local *hw_to_local(
1452f0706e82SJiri Benc 	struct ieee80211_hw *hw)
1453f0706e82SJiri Benc {
1454f0706e82SJiri Benc 	return container_of(hw, struct ieee80211_local, hw);
1455f0706e82SJiri Benc }
1456f0706e82SJiri Benc 
1457f0706e82SJiri Benc 
1458571ecf67SJohannes Berg static inline int ieee80211_bssid_match(const u8 *raddr, const u8 *addr)
1459571ecf67SJohannes Berg {
1460b203ca39SJoe Perches 	return ether_addr_equal(raddr, addr) ||
1461571ecf67SJohannes Berg 	       is_broadcast_ether_addr(raddr);
1462571ecf67SJohannes Berg }
1463571ecf67SJohannes Berg 
1464f4bda337SThomas Pedersen static inline bool
1465f4bda337SThomas Pedersen ieee80211_have_rx_timestamp(struct ieee80211_rx_status *status)
1466f4bda337SThomas Pedersen {
1467f4bda337SThomas Pedersen 	WARN_ON_ONCE(status->flag & RX_FLAG_MACTIME_START &&
1468f4bda337SThomas Pedersen 		     status->flag & RX_FLAG_MACTIME_END);
1469f4bda337SThomas Pedersen 	return status->flag & (RX_FLAG_MACTIME_START | RX_FLAG_MACTIME_END);
1470f4bda337SThomas Pedersen }
1471571ecf67SJohannes Berg 
1472f4bda337SThomas Pedersen u64 ieee80211_calculate_rx_timestamp(struct ieee80211_local *local,
1473f4bda337SThomas Pedersen 				     struct ieee80211_rx_status *status,
1474f4bda337SThomas Pedersen 				     unsigned int mpdu_len,
1475f4bda337SThomas Pedersen 				     unsigned int mpdu_offset);
1476e8975581SJohannes Berg int ieee80211_hw_config(struct ieee80211_local *local, u32 changed);
14775cf121c3SJohannes Berg void ieee80211_tx_set_protected(struct ieee80211_tx_data *tx);
14789c6bd790SJohannes Berg void ieee80211_bss_info_change_notify(struct ieee80211_sub_if_data *sdata,
14799c6bd790SJohannes Berg 				      u32 changed);
14800d143fe1SJohannes Berg void ieee80211_configure_filter(struct ieee80211_local *local);
148146900298SJohannes Berg u32 ieee80211_reset_erp_info(struct ieee80211_sub_if_data *sdata);
1482f0706e82SJiri Benc 
148346900298SJohannes Berg /* STA code */
14849c6bd790SJohannes Berg void ieee80211_sta_setup_sdata(struct ieee80211_sub_if_data *sdata);
148577fdaa12SJohannes Berg int ieee80211_mgd_auth(struct ieee80211_sub_if_data *sdata,
148677fdaa12SJohannes Berg 		       struct cfg80211_auth_request *req);
148777fdaa12SJohannes Berg int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata,
148877fdaa12SJohannes Berg 			struct cfg80211_assoc_request *req);
148977fdaa12SJohannes Berg int ieee80211_mgd_deauth(struct ieee80211_sub_if_data *sdata,
149063c9c5e7SJohannes Berg 			 struct cfg80211_deauth_request *req);
149177fdaa12SJohannes Berg int ieee80211_mgd_disassoc(struct ieee80211_sub_if_data *sdata,
149263c9c5e7SJohannes Berg 			   struct cfg80211_disassoc_request *req);
1493572e0012SKalle Valo void ieee80211_send_pspoll(struct ieee80211_local *local,
1494572e0012SKalle Valo 			   struct ieee80211_sub_if_data *sdata);
149510f644a4SJohannes Berg void ieee80211_recalc_ps(struct ieee80211_local *local, s32 latency);
1496ab095877SEliad Peller void ieee80211_recalc_ps_vif(struct ieee80211_sub_if_data *sdata);
149710f644a4SJohannes Berg int ieee80211_max_network_latency(struct notifier_block *nb,
149810f644a4SJohannes Berg 				  unsigned long data, void *dummy);
14992b2c009eSJuuso Oikarinen int ieee80211_set_arp_filter(struct ieee80211_sub_if_data *sdata);
15001fa57d01SJohannes Berg void ieee80211_sta_work(struct ieee80211_sub_if_data *sdata);
15011fa57d01SJohannes Berg void ieee80211_sta_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
15021fa57d01SJohannes Berg 				  struct sk_buff *skb);
1503d3a910a8SLuis R. Rodriguez void ieee80211_sta_reset_beacon_monitor(struct ieee80211_sub_if_data *sdata);
1504be099e82SLuis R. Rodriguez void ieee80211_sta_reset_conn_monitor(struct ieee80211_sub_if_data *sdata);
1505afa762f6SEliad Peller void ieee80211_mgd_stop(struct ieee80211_sub_if_data *sdata);
15061672c0e3SJohannes Berg void ieee80211_mgd_conn_tx_status(struct ieee80211_sub_if_data *sdata,
15071672c0e3SJohannes Berg 				  __le16 fc, bool acked);
15081a1cb744SJohannes Berg void ieee80211_mgd_quiesce(struct ieee80211_sub_if_data *sdata);
1509b8360ab8SJohannes Berg void ieee80211_sta_restart(struct ieee80211_sub_if_data *sdata);
151002219b3aSJohannes Berg void ieee80211_sta_handle_tspec_ac_params(struct ieee80211_sub_if_data *sdata);
15119c6bd790SJohannes Berg 
151246900298SJohannes Berg /* IBSS code */
151346900298SJohannes Berg void ieee80211_ibss_notify_scan_completed(struct ieee80211_local *local);
151446900298SJohannes Berg void ieee80211_ibss_setup_sdata(struct ieee80211_sub_if_data *sdata);
15158bf11d8dSJohannes Berg void ieee80211_ibss_rx_no_sta(struct ieee80211_sub_if_data *sdata,
15168bf11d8dSJohannes Berg 			      const u8 *bssid, const u8 *addr, u32 supp_rates);
1517af8cdcd8SJohannes Berg int ieee80211_ibss_join(struct ieee80211_sub_if_data *sdata,
1518af8cdcd8SJohannes Berg 			struct cfg80211_ibss_params *params);
1519af8cdcd8SJohannes Berg int ieee80211_ibss_leave(struct ieee80211_sub_if_data *sdata);
15201fa57d01SJohannes Berg void ieee80211_ibss_work(struct ieee80211_sub_if_data *sdata);
15211fa57d01SJohannes Berg void ieee80211_ibss_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
15221fa57d01SJohannes Berg 				   struct sk_buff *skb);
1523cd7760e6SSimon Wunderlich int ieee80211_ibss_csa_beacon(struct ieee80211_sub_if_data *sdata,
1524cd7760e6SSimon Wunderlich 			      struct cfg80211_csa_settings *csa_settings);
1525cd7760e6SSimon Wunderlich int ieee80211_ibss_finish_csa(struct ieee80211_sub_if_data *sdata);
1526cd7760e6SSimon Wunderlich void ieee80211_ibss_stop(struct ieee80211_sub_if_data *sdata);
15271fa57d01SJohannes Berg 
1528239281f8SRostislav Lisovy /* OCB code */
1529239281f8SRostislav Lisovy void ieee80211_ocb_work(struct ieee80211_sub_if_data *sdata);
1530239281f8SRostislav Lisovy void ieee80211_ocb_rx_no_sta(struct ieee80211_sub_if_data *sdata,
1531239281f8SRostislav Lisovy 			     const u8 *bssid, const u8 *addr, u32 supp_rates);
1532239281f8SRostislav Lisovy void ieee80211_ocb_setup_sdata(struct ieee80211_sub_if_data *sdata);
1533239281f8SRostislav Lisovy int ieee80211_ocb_join(struct ieee80211_sub_if_data *sdata,
1534239281f8SRostislav Lisovy 		       struct ocb_setup *setup);
1535239281f8SRostislav Lisovy int ieee80211_ocb_leave(struct ieee80211_sub_if_data *sdata);
1536239281f8SRostislav Lisovy 
15371fa57d01SJohannes Berg /* mesh code */
15381fa57d01SJohannes Berg void ieee80211_mesh_work(struct ieee80211_sub_if_data *sdata);
15391fa57d01SJohannes Berg void ieee80211_mesh_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
15401fa57d01SJohannes Berg 				   struct sk_buff *skb);
1541b8456a14SChun-Yeow Yeoh int ieee80211_mesh_csa_beacon(struct ieee80211_sub_if_data *sdata,
154266e01cf9SLuciano Coelho 			      struct cfg80211_csa_settings *csa_settings);
1543b8456a14SChun-Yeow Yeoh int ieee80211_mesh_finish_csa(struct ieee80211_sub_if_data *sdata);
154446900298SJohannes Berg 
15459c6bd790SJohannes Berg /* scan/BSS handling */
154646900298SJohannes Berg void ieee80211_scan_work(struct work_struct *work);
154734bcf715SStanislaw Gruszka int ieee80211_request_ibss_scan(struct ieee80211_sub_if_data *sdata,
1548be4a4b6aSJohannes Berg 				const u8 *ssid, u8 ssid_len,
15497ca15a0aSSimon Wunderlich 				struct ieee80211_channel *chan,
15507ca15a0aSSimon Wunderlich 				enum nl80211_bss_scan_width scan_width);
1551c2b13452SJohannes Berg int ieee80211_request_scan(struct ieee80211_sub_if_data *sdata,
15522a519311SJohannes Berg 			   struct cfg80211_scan_request *req);
15535bb644a0SJohannes Berg void ieee80211_scan_cancel(struct ieee80211_local *local);
1554133d40f9SStanislaw Gruszka void ieee80211_run_deferred_scan(struct ieee80211_local *local);
1555d48b2968SJohannes Berg void ieee80211_scan_rx(struct ieee80211_local *local, struct sk_buff *skb);
15569c6bd790SJohannes Berg 
15570a51b27eSJohannes Berg void ieee80211_mlme_notify_scan_completed(struct ieee80211_local *local);
1558c2b13452SJohannes Berg struct ieee80211_bss *
155998c8fccfSJohannes Berg ieee80211_bss_info_update(struct ieee80211_local *local,
156098c8fccfSJohannes Berg 			  struct ieee80211_rx_status *rx_status,
156198c8fccfSJohannes Berg 			  struct ieee80211_mgmt *mgmt,
156298c8fccfSJohannes Berg 			  size_t len,
156398c8fccfSJohannes Berg 			  struct ieee802_11_elems *elems,
1564d45c4172SEmmanuel Grumbach 			  struct ieee80211_channel *channel);
156598c8fccfSJohannes Berg void ieee80211_rx_bss_put(struct ieee80211_local *local,
1566c2b13452SJohannes Berg 			  struct ieee80211_bss *bss);
1567ee385855SLuis Carlos Cobo 
156879f460caSLuciano Coelho /* scheduled scan handling */
1569d43c6b6eSDavid Spinadel int
1570d43c6b6eSDavid Spinadel __ieee80211_request_sched_scan_start(struct ieee80211_sub_if_data *sdata,
1571d43c6b6eSDavid Spinadel 				     struct cfg80211_sched_scan_request *req);
157279f460caSLuciano Coelho int ieee80211_request_sched_scan_start(struct ieee80211_sub_if_data *sdata,
157379f460caSLuciano Coelho 				       struct cfg80211_sched_scan_request *req);
157485a9994aSLuciano Coelho int ieee80211_request_sched_scan_stop(struct ieee80211_sub_if_data *sdata);
1575f6837ba8SJohannes Berg void ieee80211_sched_scan_end(struct ieee80211_local *local);
157685a9994aSLuciano Coelho void ieee80211_sched_scan_stopped_work(struct work_struct *work);
157779f460caSLuciano Coelho 
1578b203ffc3SJouni Malinen /* off-channel helpers */
1579aacde9eeSStanislaw Gruszka void ieee80211_offchannel_stop_vifs(struct ieee80211_local *local);
1580aacde9eeSStanislaw Gruszka void ieee80211_offchannel_return(struct ieee80211_local *local);
15812eb278e0SJohannes Berg void ieee80211_roc_setup(struct ieee80211_local *local);
15822eb278e0SJohannes Berg void ieee80211_start_next_roc(struct ieee80211_local *local);
1583c8f994eeSJohannes Berg void ieee80211_roc_purge(struct ieee80211_local *local,
1584c8f994eeSJohannes Berg 			 struct ieee80211_sub_if_data *sdata);
15853fbd45caSJohannes Berg void ieee80211_roc_notify_destroy(struct ieee80211_roc_work *roc, bool free);
15862eb278e0SJohannes Berg void ieee80211_sw_roc_work(struct work_struct *work);
15872eb278e0SJohannes Berg void ieee80211_handle_roc_started(struct ieee80211_roc_work *roc);
1588b203ffc3SJouni Malinen 
158973da7d5bSSimon Wunderlich /* channel switch handling */
159073da7d5bSSimon Wunderlich void ieee80211_csa_finalize_work(struct work_struct *work);
159182a8e17dSLuciano Coelho int ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev,
159282a8e17dSLuciano Coelho 			     struct cfg80211_csa_settings *params);
159373da7d5bSSimon Wunderlich 
15943e122be0SJohannes Berg /* interface handling */
159547846c9bSJohannes Berg int ieee80211_iface_init(void);
159647846c9bSJohannes Berg void ieee80211_iface_exit(void);
15973e122be0SJohannes Berg int ieee80211_if_add(struct ieee80211_local *local, const char *name,
159884efbb84SJohannes Berg 		     struct wireless_dev **new_wdev, enum nl80211_iftype type,
1599ee385855SLuis Carlos Cobo 		     struct vif_params *params);
1600f3947e2dSJohannes Berg int ieee80211_if_change_type(struct ieee80211_sub_if_data *sdata,
160105c914feSJohannes Berg 			     enum nl80211_iftype type);
1602f698d856SJasper Bryant-Greene void ieee80211_if_remove(struct ieee80211_sub_if_data *sdata);
160375636525SJohannes Berg void ieee80211_remove_interfaces(struct ieee80211_local *local);
1604382a103bSJohannes Berg u32 ieee80211_idle_off(struct ieee80211_local *local);
16055cff20e6SJohannes Berg void ieee80211_recalc_idle(struct ieee80211_local *local);
160685416a4fSChristian Lamparter void ieee80211_adjust_monitor_flags(struct ieee80211_sub_if_data *sdata,
160785416a4fSChristian Lamparter 				    const int offset);
1608f142c6b9SJohannes Berg int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up);
1609f142c6b9SJohannes Berg void ieee80211_sdata_stop(struct ieee80211_sub_if_data *sdata);
16103c3e21e7SJohannes Berg int ieee80211_add_virtual_monitor(struct ieee80211_local *local);
16113c3e21e7SJohannes Berg void ieee80211_del_virtual_monitor(struct ieee80211_local *local);
1612f0706e82SJiri Benc 
16131ea6f9c0SJohannes Berg bool __ieee80211_recalc_txpower(struct ieee80211_sub_if_data *sdata);
16141ea6f9c0SJohannes Berg void ieee80211_recalc_txpower(struct ieee80211_sub_if_data *sdata);
16151ea6f9c0SJohannes Berg 
16169607e6b6SJohannes Berg static inline bool ieee80211_sdata_running(struct ieee80211_sub_if_data *sdata)
16179607e6b6SJohannes Berg {
161834d4bc4dSJohannes Berg 	return test_bit(SDATA_STATE_RUNNING, &sdata->state);
16199607e6b6SJohannes Berg }
16209607e6b6SJohannes Berg 
1621e2ebc74dSJohannes Berg /* tx handling */
1622e2ebc74dSJohannes Berg void ieee80211_clear_tx_pending(struct ieee80211_local *local);
1623e2ebc74dSJohannes Berg void ieee80211_tx_pending(unsigned long data);
1624d0cf9c0dSStephen Hemminger netdev_tx_t ieee80211_monitor_start_xmit(struct sk_buff *skb,
1625d0cf9c0dSStephen Hemminger 					 struct net_device *dev);
1626d0cf9c0dSStephen Hemminger netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb,
1627d0cf9c0dSStephen Hemminger 				       struct net_device *dev);
16281f98ab7fSFelix Fietkau void ieee80211_purge_tx_queue(struct ieee80211_hw *hw,
16291f98ab7fSFelix Fietkau 			      struct sk_buff_head *skbs);
1630e2ebc74dSJohannes Berg 
1631de1ede7aSJohannes Berg /* HT */
1632ef96a842SBen Greear void ieee80211_apply_htcap_overrides(struct ieee80211_sub_if_data *sdata,
1633ef96a842SBen Greear 				     struct ieee80211_sta_ht_cap *ht_cap);
1634e1a0c6b3SJohannes Berg bool ieee80211_ht_cap_ie_to_sta_ht_cap(struct ieee80211_sub_if_data *sdata,
1635ef96a842SBen Greear 				       struct ieee80211_supported_band *sband,
16364a3cb702SJohannes Berg 				       const struct ieee80211_ht_cap *ht_cap_ie,
1637e1a0c6b3SJohannes Berg 				       struct sta_info *sta);
1638b8695a8fSJohannes Berg void ieee80211_send_delba(struct ieee80211_sub_if_data *sdata,
1639b8695a8fSJohannes Berg 			  const u8 *da, u16 tid,
1640b8695a8fSJohannes Berg 			  u16 initiator, u16 reason_code);
16410f78231bSJohannes Berg int ieee80211_send_smps_action(struct ieee80211_sub_if_data *sdata,
16420f78231bSJohannes Berg 			       enum ieee80211_smps_mode smps, const u8 *da,
16430f78231bSJohannes Berg 			       const u8 *bssid);
1644687da132SEmmanuel Grumbach void ieee80211_request_smps_ap_work(struct work_struct *work);
1645687da132SEmmanuel Grumbach void ieee80211_request_smps_mgd_work(struct work_struct *work);
1646687da132SEmmanuel Grumbach bool ieee80211_smps_is_restrictive(enum ieee80211_smps_mode smps_mode_old,
1647687da132SEmmanuel Grumbach 				   enum ieee80211_smps_mode smps_mode_new);
1648de1ede7aSJohannes Berg 
16497c3b1dd8SJohannes Berg void ___ieee80211_stop_rx_ba_session(struct sta_info *sta, u16 tid,
165053f73c09SJohannes Berg 				     u16 initiator, u16 reason, bool stop);
1651849b7967SJohannes Berg void __ieee80211_stop_rx_ba_session(struct sta_info *sta, u16 tid,
165253f73c09SJohannes Berg 				    u16 initiator, u16 reason, bool stop);
165308cf42e8SMichal Kazior void __ieee80211_start_rx_ba_session(struct sta_info *sta,
165408cf42e8SMichal Kazior 				     u8 dialog_token, u16 timeout,
165508cf42e8SMichal Kazior 				     u16 start_seq_num, u16 ba_policy, u16 tid,
16564549cf2bSMichal Kazior 				     u16 buf_size, bool tx, bool auto_seq);
1657c82c4a80SJohannes Berg void ieee80211_sta_tear_down_BA_sessions(struct sta_info *sta,
1658c82c4a80SJohannes Berg 					 enum ieee80211_agg_stop_reason reason);
1659de1ede7aSJohannes Berg void ieee80211_process_delba(struct ieee80211_sub_if_data *sdata,
1660de1ede7aSJohannes Berg 			     struct sta_info *sta,
1661de1ede7aSJohannes Berg 			     struct ieee80211_mgmt *mgmt, size_t len);
1662de1ede7aSJohannes Berg void ieee80211_process_addba_resp(struct ieee80211_local *local,
1663de1ede7aSJohannes Berg 				  struct sta_info *sta,
1664de1ede7aSJohannes Berg 				  struct ieee80211_mgmt *mgmt,
1665de1ede7aSJohannes Berg 				  size_t len);
1666de1ede7aSJohannes Berg void ieee80211_process_addba_request(struct ieee80211_local *local,
1667de1ede7aSJohannes Berg 				     struct sta_info *sta,
1668de1ede7aSJohannes Berg 				     struct ieee80211_mgmt *mgmt,
1669de1ede7aSJohannes Berg 				     size_t len);
1670de1ede7aSJohannes Berg 
1671849b7967SJohannes Berg int __ieee80211_stop_tx_ba_session(struct sta_info *sta, u16 tid,
1672c82c4a80SJohannes Berg 				   enum ieee80211_agg_stop_reason reason);
167367c282c0SJohannes Berg int ___ieee80211_stop_tx_ba_session(struct sta_info *sta, u16 tid,
1674c82c4a80SJohannes Berg 				    enum ieee80211_agg_stop_reason reason);
16755d22c89bSJohannes Berg void ieee80211_start_tx_ba_cb(struct ieee80211_vif *vif, u8 *ra, u16 tid);
16765d22c89bSJohannes Berg void ieee80211_stop_tx_ba_cb(struct ieee80211_vif *vif, u8 *ra, u8 tid);
167767c282c0SJohannes Berg void ieee80211_ba_session_work(struct work_struct *work);
167867c282c0SJohannes Berg void ieee80211_tx_ba_session_handle_start(struct sta_info *sta, int tid);
16792bff8ebfSChristian Lamparter void ieee80211_release_reorder_timeout(struct sta_info *sta, int tid);
1680849b7967SJohannes Berg 
168104ecd257SJohannes Berg u8 ieee80211_mcs_to_chains(const struct ieee80211_mcs_info *mcs);
168204ecd257SJohannes Berg 
1683818255eaSMahesh Palivela /* VHT */
16844a3cb702SJohannes Berg void
16854a3cb702SJohannes Berg ieee80211_vht_cap_ie_to_sta_vht_cap(struct ieee80211_sub_if_data *sdata,
1686818255eaSMahesh Palivela 				    struct ieee80211_supported_band *sband,
16874a3cb702SJohannes Berg 				    const struct ieee80211_vht_cap *vht_cap_ie,
16884a34215eSJohannes Berg 				    struct sta_info *sta);
1689e1a0c6b3SJohannes Berg enum ieee80211_sta_rx_bandwidth ieee80211_sta_cur_vht_bw(struct sta_info *sta);
16908921d04eSJohannes Berg void ieee80211_sta_set_rx_nss(struct sta_info *sta);
1691b1bce14aSMarek Kwaczynski u32 __ieee80211_vht_handle_opmode(struct ieee80211_sub_if_data *sdata,
1692b1bce14aSMarek Kwaczynski                                   struct sta_info *sta, u8 opmode,
1693b1bce14aSMarek Kwaczynski                                   enum ieee80211_band band, bool nss_only);
16940af83d3dSJohannes Berg void ieee80211_vht_handle_opmode(struct ieee80211_sub_if_data *sdata,
16950af83d3dSJohannes Berg 				 struct sta_info *sta, u8 opmode,
1696bee7f586SJohannes Berg 				 enum ieee80211_band band, bool nss_only);
1697dd5ecfeaSJohannes Berg void ieee80211_apply_vhtcap_overrides(struct ieee80211_sub_if_data *sdata,
1698dd5ecfeaSJohannes Berg 				      struct ieee80211_sta_vht_cap *vht_cap);
16994a34215eSJohannes Berg 
170039192c0bSJohannes Berg /* Spectrum management */
170139192c0bSJohannes Berg void ieee80211_process_measurement_req(struct ieee80211_sub_if_data *sdata,
170239192c0bSJohannes Berg 				       struct ieee80211_mgmt *mgmt,
170339192c0bSJohannes Berg 				       size_t len);
1704e6b7cde4SSimon Wunderlich /**
1705e6b7cde4SSimon Wunderlich  * ieee80211_parse_ch_switch_ie - parses channel switch IEs
1706e6b7cde4SSimon Wunderlich  * @sdata: the sdata of the interface which has received the frame
1707e6b7cde4SSimon Wunderlich  * @elems: parsed 802.11 elements received with the frame
1708e6b7cde4SSimon Wunderlich  * @beacon: indicates if the frame was a beacon or probe response
1709e6b7cde4SSimon Wunderlich  * @current_band: indicates the current band
1710e6b7cde4SSimon Wunderlich  * @sta_flags: contains information about own capabilities and restrictions
1711e6b7cde4SSimon Wunderlich  *	to decide which channel switch announcements can be accepted. Only the
1712e6b7cde4SSimon Wunderlich  *	following subset of &enum ieee80211_sta_flags are evaluated:
1713e6b7cde4SSimon Wunderlich  *	%IEEE80211_STA_DISABLE_HT, %IEEE80211_STA_DISABLE_VHT,
1714e6b7cde4SSimon Wunderlich  *	%IEEE80211_STA_DISABLE_40MHZ, %IEEE80211_STA_DISABLE_80P80MHZ,
1715e6b7cde4SSimon Wunderlich  *	%IEEE80211_STA_DISABLE_160MHZ.
1716e6b7cde4SSimon Wunderlich  * @bssid: the currently connected bssid (for reporting)
1717c0f17eb9SChun-Yeow Yeoh  * @csa_ie: parsed 802.11 csa elements on count, mode, chandef and mesh ttl.
1718c0f17eb9SChun-Yeow Yeoh 	All of them will be filled with if success only.
1719e6b7cde4SSimon Wunderlich  * Return: 0 on success, <0 on error and >0 if there is nothing to parse.
1720e6b7cde4SSimon Wunderlich  */
1721e6b7cde4SSimon Wunderlich int ieee80211_parse_ch_switch_ie(struct ieee80211_sub_if_data *sdata,
1722e6b7cde4SSimon Wunderlich 				 struct ieee802_11_elems *elems, bool beacon,
1723e6b7cde4SSimon Wunderlich 				 enum ieee80211_band current_band,
1724c0f17eb9SChun-Yeow Yeoh 				 u32 sta_flags, u8 *bssid,
1725c0f17eb9SChun-Yeow Yeoh 				 struct ieee80211_csa_ie *csa_ie);
172639192c0bSJohannes Berg 
1727f2753ddbSJohannes Berg /* Suspend/resume and hw reconfiguration */
1728f2753ddbSJohannes Berg int ieee80211_reconfig(struct ieee80211_local *local);
172984f6a01cSJohannes Berg void ieee80211_stop_device(struct ieee80211_local *local);
1730f2753ddbSJohannes Berg 
1731eecc4800SJohannes Berg int __ieee80211_suspend(struct ieee80211_hw *hw,
1732eecc4800SJohannes Berg 			struct cfg80211_wowlan *wowlan);
1733f2753ddbSJohannes Berg 
1734f2753ddbSJohannes Berg static inline int __ieee80211_resume(struct ieee80211_hw *hw)
1735f2753ddbSJohannes Berg {
173685f72bc8SJohn W. Linville 	struct ieee80211_local *local = hw_to_local(hw);
173785f72bc8SJohn W. Linville 
173885f72bc8SJohn W. Linville 	WARN(test_bit(SCAN_HW_SCANNING, &local->scanning),
173985f72bc8SJohn W. Linville 		"%s: resume with hardware scan still in progress\n",
174085f72bc8SJohn W. Linville 		wiphy_name(hw->wiphy));
174185f72bc8SJohn W. Linville 
1742f2753ddbSJohannes Berg 	return ieee80211_reconfig(hw_to_local(hw));
1743f2753ddbSJohannes Berg }
1744665af4fcSBob Copeland 
1745c2d1560aSJohannes Berg /* utility functions/constants */
17468a47cea7SJohannes Berg extern const void *const mac80211_wiphy_privid; /* for wiphy privid */
174771364716SRon Rindjunsky u8 *ieee80211_get_bssid(struct ieee80211_hdr *hdr, size_t len,
174805c914feSJohannes Berg 			enum nl80211_iftype type);
17494ee73f33SMichal Kazior int ieee80211_frame_duration(enum ieee80211_band band, size_t len,
1750438b61b7SSimon Wunderlich 			     int rate, int erp, int short_preamble,
1751438b61b7SSimon Wunderlich 			     int shift);
1752f698d856SJasper Bryant-Greene void mac80211_ev_michael_mic_failure(struct ieee80211_sub_if_data *sdata, int keyidx,
1753e6d6e342SJohannes Berg 				     struct ieee80211_hdr *hdr, const u8 *tsc,
1754e6d6e342SJohannes Berg 				     gfp_t gfp);
17553abead59SJohannes Berg void ieee80211_set_wmm_default(struct ieee80211_sub_if_data *sdata,
17563abead59SJohannes Berg 			       bool bss_notify);
175755de908aSJohannes Berg void ieee80211_xmit(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb,
175855de908aSJohannes Berg 		    enum ieee80211_band band);
1759cf6bb79aSHelmut Schaa 
176055de908aSJohannes Berg void __ieee80211_tx_skb_tid_band(struct ieee80211_sub_if_data *sdata,
176155de908aSJohannes Berg 				 struct sk_buff *skb, int tid,
176255de908aSJohannes Berg 				 enum ieee80211_band band);
176355de908aSJohannes Berg 
176455de908aSJohannes Berg static inline void
176555de908aSJohannes Berg ieee80211_tx_skb_tid_band(struct ieee80211_sub_if_data *sdata,
176655de908aSJohannes Berg 			  struct sk_buff *skb, int tid,
176755de908aSJohannes Berg 			  enum ieee80211_band band)
176855de908aSJohannes Berg {
176955de908aSJohannes Berg 	rcu_read_lock();
177055de908aSJohannes Berg 	__ieee80211_tx_skb_tid_band(sdata, skb, tid, band);
177155de908aSJohannes Berg 	rcu_read_unlock();
177255de908aSJohannes Berg }
177355de908aSJohannes Berg 
177455de908aSJohannes Berg static inline void ieee80211_tx_skb_tid(struct ieee80211_sub_if_data *sdata,
177555de908aSJohannes Berg 					struct sk_buff *skb, int tid)
177655de908aSJohannes Berg {
177755de908aSJohannes Berg 	struct ieee80211_chanctx_conf *chanctx_conf;
177855de908aSJohannes Berg 
177955de908aSJohannes Berg 	rcu_read_lock();
178055de908aSJohannes Berg 	chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
178155de908aSJohannes Berg 	if (WARN_ON(!chanctx_conf)) {
178255de908aSJohannes Berg 		rcu_read_unlock();
178355de908aSJohannes Berg 		kfree_skb(skb);
178455de908aSJohannes Berg 		return;
178555de908aSJohannes Berg 	}
178655de908aSJohannes Berg 
178755de908aSJohannes Berg 	__ieee80211_tx_skb_tid_band(sdata, skb, tid,
17884bf88530SJohannes Berg 				    chanctx_conf->def.chan->band);
178955de908aSJohannes Berg 	rcu_read_unlock();
179055de908aSJohannes Berg }
179155de908aSJohannes Berg 
179255de908aSJohannes Berg static inline void ieee80211_tx_skb(struct ieee80211_sub_if_data *sdata,
1793cf6bb79aSHelmut Schaa 				    struct sk_buff *skb)
1794cf6bb79aSHelmut Schaa {
1795cf6bb79aSHelmut Schaa 	/* Send all internal mgmt frames on VO. Accordingly set TID to 7. */
1796cf6bb79aSHelmut Schaa 	ieee80211_tx_skb_tid(sdata, skb, 7);
1797cf6bb79aSHelmut Schaa }
1798cf6bb79aSHelmut Schaa 
179935d865afSJohannes Berg u32 ieee802_11_parse_elems_crc(const u8 *start, size_t len, bool action,
1800d91f36dbSJohannes Berg 			       struct ieee802_11_elems *elems,
1801d91f36dbSJohannes Berg 			       u64 filter, u32 crc);
180235d865afSJohannes Berg static inline void ieee802_11_parse_elems(const u8 *start, size_t len,
180335d865afSJohannes Berg 					  bool action,
1804ddc4db2eSJohannes Berg 					  struct ieee802_11_elems *elems)
1805ddc4db2eSJohannes Berg {
1806b2e506bfSJohannes Berg 	ieee802_11_parse_elems_crc(start, len, action, elems, 0, 0);
1807ddc4db2eSJohannes Berg }
1808ddc4db2eSJohannes Berg 
180983eb935eSMichal Kazior static inline bool ieee80211_rx_reorder_ready(struct sk_buff_head *frames)
181083eb935eSMichal Kazior {
181183eb935eSMichal Kazior 	struct sk_buff *tail = skb_peek_tail(frames);
181283eb935eSMichal Kazior 	struct ieee80211_rx_status *status;
181383eb935eSMichal Kazior 
181483eb935eSMichal Kazior 	if (!tail)
181583eb935eSMichal Kazior 		return false;
181683eb935eSMichal Kazior 
181783eb935eSMichal Kazior 	status = IEEE80211_SKB_RXCB(tail);
181883eb935eSMichal Kazior 	if (status->flag & RX_FLAG_AMSDU_MORE)
181983eb935eSMichal Kazior 		return false;
182083eb935eSMichal Kazior 
182183eb935eSMichal Kazior 	return true;
182283eb935eSMichal Kazior }
182383eb935eSMichal Kazior 
182402219b3aSJohannes Berg extern const int ieee802_1d_to_ac[8];
182502219b3aSJohannes Berg 
182602219b3aSJohannes Berg static inline int ieee80211_ac_from_tid(int tid)
182702219b3aSJohannes Berg {
182802219b3aSJohannes Berg 	return ieee802_1d_to_ac[tid & 7];
182902219b3aSJohannes Berg }
183002219b3aSJohannes Berg 
1831520eb820SKalle Valo void ieee80211_dynamic_ps_enable_work(struct work_struct *work);
1832520eb820SKalle Valo void ieee80211_dynamic_ps_disable_work(struct work_struct *work);
1833520eb820SKalle Valo void ieee80211_dynamic_ps_timer(unsigned long data);
1834a97b77b9SVivek Natarajan void ieee80211_send_nullfunc(struct ieee80211_local *local,
1835a97b77b9SVivek Natarajan 			     struct ieee80211_sub_if_data *sdata,
1836a97b77b9SVivek Natarajan 			     int powersave);
18373cf335d5SKalle Valo void ieee80211_sta_rx_notify(struct ieee80211_sub_if_data *sdata,
18383cf335d5SKalle Valo 			     struct ieee80211_hdr *hdr);
18394e5ff376SFelix Fietkau void ieee80211_sta_tx_notify(struct ieee80211_sub_if_data *sdata,
184002219b3aSJohannes Berg 			     struct ieee80211_hdr *hdr, bool ack, u16 tx_time);
1841520eb820SKalle Valo 
1842ce7c9111SKalle Valo void ieee80211_wake_queues_by_reason(struct ieee80211_hw *hw,
1843445ea4e8SJohannes Berg 				     unsigned long queues,
1844cca07b00SLuciano Coelho 				     enum queue_stop_reason reason,
1845cca07b00SLuciano Coelho 				     bool refcounted);
184626da23b6SLuciano Coelho void ieee80211_stop_vif_queues(struct ieee80211_local *local,
184726da23b6SLuciano Coelho 			       struct ieee80211_sub_if_data *sdata,
184826da23b6SLuciano Coelho 			       enum queue_stop_reason reason);
184926da23b6SLuciano Coelho void ieee80211_wake_vif_queues(struct ieee80211_local *local,
185026da23b6SLuciano Coelho 			       struct ieee80211_sub_if_data *sdata,
185126da23b6SLuciano Coelho 			       enum queue_stop_reason reason);
1852ce7c9111SKalle Valo void ieee80211_stop_queues_by_reason(struct ieee80211_hw *hw,
1853445ea4e8SJohannes Berg 				     unsigned long queues,
1854cca07b00SLuciano Coelho 				     enum queue_stop_reason reason,
1855cca07b00SLuciano Coelho 				     bool refcounted);
185696f5e66eSJohannes Berg void ieee80211_wake_queue_by_reason(struct ieee80211_hw *hw, int queue,
1857cca07b00SLuciano Coelho 				    enum queue_stop_reason reason,
1858cca07b00SLuciano Coelho 				    bool refcounted);
185996f5e66eSJohannes Berg void ieee80211_stop_queue_by_reason(struct ieee80211_hw *hw, int queue,
1860cca07b00SLuciano Coelho 				    enum queue_stop_reason reason,
1861cca07b00SLuciano Coelho 				    bool refcounted);
18623a25a8c8SJohannes Berg void ieee80211_propagate_queue_wake(struct ieee80211_local *local, int queue);
18638f77f384SJohannes Berg void ieee80211_add_pending_skb(struct ieee80211_local *local,
18648f77f384SJohannes Berg 			       struct sk_buff *skb);
1865e3685e03SJohannes Berg void ieee80211_add_pending_skbs(struct ieee80211_local *local,
1866e3685e03SJohannes Berg 				struct sk_buff_head *skbs);
186739ecc01dSJohannes Berg void ieee80211_flush_queues(struct ieee80211_local *local,
186839ecc01dSJohannes Berg 			    struct ieee80211_sub_if_data *sdata);
1869ce7c9111SKalle Valo 
187046900298SJohannes Berg void ieee80211_send_auth(struct ieee80211_sub_if_data *sdata,
1871700e8ea6SJouni Malinen 			 u16 transaction, u16 auth_alg, u16 status,
18724a3cb702SJohannes Berg 			 const u8 *extra, size_t extra_len, const u8 *bssid,
18731672c0e3SJohannes Berg 			 const u8 *da, const u8 *key, u8 key_len, u8 key_idx,
18741672c0e3SJohannes Berg 			 u32 tx_flags);
18756ae16775SAntonio Quartulli void ieee80211_send_deauth_disassoc(struct ieee80211_sub_if_data *sdata,
18766ae16775SAntonio Quartulli 				    const u8 *bssid, u16 stype, u16 reason,
18776ae16775SAntonio Quartulli 				    bool send_frame, u8 *frame_buf);
1878de95a54bSJohannes Berg int ieee80211_build_preq_ies(struct ieee80211_local *local, u8 *buffer,
1879c56ef672SDavid Spinadel 			     size_t buffer_len,
1880c56ef672SDavid Spinadel 			     struct ieee80211_scan_ies *ie_desc,
1881c56ef672SDavid Spinadel 			     const u8 *ie, size_t ie_len,
1882c56ef672SDavid Spinadel 			     u8 bands_used, u32 *rate_masks,
18832103dec1SSimon Wunderlich 			     struct cfg80211_chan_def *chandef);
1884a619a4c0SJuuso Oikarinen struct sk_buff *ieee80211_build_probe_req(struct ieee80211_sub_if_data *sdata,
188585a237feSJohannes Berg 					  u8 *dst, u32 ratemask,
18866b77863bSJohannes Berg 					  struct ieee80211_channel *chan,
1887a619a4c0SJuuso Oikarinen 					  const u8 *ssid, size_t ssid_len,
1888a806c558SPaul Stewart 					  const u8 *ie, size_t ie_len,
1889a806c558SPaul Stewart 					  bool directed);
189046900298SJohannes Berg void ieee80211_send_probe_req(struct ieee80211_sub_if_data *sdata, u8 *dst,
1891de95a54bSJohannes Berg 			      const u8 *ssid, size_t ssid_len,
1892a806c558SPaul Stewart 			      const u8 *ie, size_t ie_len,
18931672c0e3SJohannes Berg 			      u32 ratemask, bool directed, u32 tx_flags,
189455de908aSJohannes Berg 			      struct ieee80211_channel *channel, bool scan);
189546900298SJohannes Berg 
18962103dec1SSimon Wunderlich u32 ieee80211_sta_get_rates(struct ieee80211_sub_if_data *sdata,
189746900298SJohannes Berg 			    struct ieee802_11_elems *elems,
18989ebb61a2SAshok Nagarajan 			    enum ieee80211_band band, u32 *basic_rates);
1899687da132SEmmanuel Grumbach int __ieee80211_request_smps_mgd(struct ieee80211_sub_if_data *sdata,
1900687da132SEmmanuel Grumbach 				 enum ieee80211_smps_mode smps_mode);
1901687da132SEmmanuel Grumbach int __ieee80211_request_smps_ap(struct ieee80211_sub_if_data *sdata,
19020f78231bSJohannes Berg 				enum ieee80211_smps_mode smps_mode);
190304ecd257SJohannes Berg void ieee80211_recalc_smps(struct ieee80211_sub_if_data *sdata);
190421f659bfSEliad Peller void ieee80211_recalc_min_chandef(struct ieee80211_sub_if_data *sdata);
190546900298SJohannes Berg 
19068ed28747SJohannes Berg size_t ieee80211_ie_split_ric(const u8 *ies, size_t ielen,
19078ed28747SJohannes Berg 			      const u8 *ids, int n_ids,
19088ed28747SJohannes Berg 			      const u8 *after_ric, int n_after_ric,
19098ed28747SJohannes Berg 			      size_t offset);
19108e664fb3SJohannes Berg size_t ieee80211_ie_split_vendor(const u8 *ies, size_t ielen, size_t offset);
1911ef96a842SBen Greear u8 *ieee80211_ie_build_ht_cap(u8 *pos, struct ieee80211_sta_ht_cap *ht_cap,
191242e7aa77SAlexander Simon 			      u16 cap);
1913074d46d1SJohannes Berg u8 *ieee80211_ie_build_ht_oper(u8 *pos, struct ieee80211_sta_ht_cap *ht_cap,
19144bf88530SJohannes Berg 			       const struct cfg80211_chan_def *chandef,
1915431e3154SAshok Nagarajan 			       u16 prot_mode);
1916ba0afa2fSMahesh Palivela u8 *ieee80211_ie_build_vht_cap(u8 *pos, struct ieee80211_sta_vht_cap *vht_cap,
1917ba0afa2fSMahesh Palivela 			       u32 cap);
19182103dec1SSimon Wunderlich int ieee80211_parse_bitrates(struct cfg80211_chan_def *chandef,
19192103dec1SSimon Wunderlich 			     const struct ieee80211_supported_band *sband,
19202103dec1SSimon Wunderlich 			     const u8 *srates, int srates_len, u32 *rates);
1921fc8a7321SJohannes Berg int ieee80211_add_srates_ie(struct ieee80211_sub_if_data *sdata,
19226b77863bSJohannes Berg 			    struct sk_buff *skb, bool need_basic,
19236b77863bSJohannes Berg 			    enum ieee80211_band band);
1924fc8a7321SJohannes Berg int ieee80211_add_ext_srates_ie(struct ieee80211_sub_if_data *sdata,
19256b77863bSJohannes Berg 				struct sk_buff *skb, bool need_basic,
19266b77863bSJohannes Berg 				enum ieee80211_band band);
192740b861a0SArik Nemtsov u8 *ieee80211_add_wmm_info_ie(u8 *buf, u8 qosinfo);
19288e664fb3SJohannes Berg 
1929f444de05SJohannes Berg /* channel management */
19304bf88530SJohannes Berg void ieee80211_ht_oper_to_chandef(struct ieee80211_channel *control_chan,
19314a3cb702SJohannes Berg 				  const struct ieee80211_ht_operation *ht_oper,
19324bf88530SJohannes Berg 				  struct cfg80211_chan_def *chandef);
1933e6b7cde4SSimon Wunderlich u32 ieee80211_chandef_downgrade(struct cfg80211_chan_def *c);
1934f444de05SJohannes Berg 
1935d01a1e65SMichal Kazior int __must_check
1936d01a1e65SMichal Kazior ieee80211_vif_use_channel(struct ieee80211_sub_if_data *sdata,
19374bf88530SJohannes Berg 			  const struct cfg80211_chan_def *chandef,
1938d01a1e65SMichal Kazior 			  enum ieee80211_chanctx_mode mode);
19392c9b7359SJohannes Berg int __must_check
194011335a55SLuciano Coelho ieee80211_vif_reserve_chanctx(struct ieee80211_sub_if_data *sdata,
194111335a55SLuciano Coelho 			      const struct cfg80211_chan_def *chandef,
194209332481SMichal Kazior 			      enum ieee80211_chanctx_mode mode,
194309332481SMichal Kazior 			      bool radar_required);
194411335a55SLuciano Coelho int __must_check
19455bcae31dSMichal Kazior ieee80211_vif_use_reserved_context(struct ieee80211_sub_if_data *sdata);
194611335a55SLuciano Coelho int ieee80211_vif_unreserve_chanctx(struct ieee80211_sub_if_data *sdata);
194711335a55SLuciano Coelho 
194811335a55SLuciano Coelho int __must_check
19492c9b7359SJohannes Berg ieee80211_vif_change_bandwidth(struct ieee80211_sub_if_data *sdata,
19502c9b7359SJohannes Berg 			       const struct cfg80211_chan_def *chandef,
19512c9b7359SJohannes Berg 			       u32 *changed);
1952d01a1e65SMichal Kazior void ieee80211_vif_release_channel(struct ieee80211_sub_if_data *sdata);
19534d76d21bSJohannes Berg void ieee80211_vif_vlan_copy_chanctx(struct ieee80211_sub_if_data *sdata);
19541f4ac5a6SJohannes Berg void ieee80211_vif_copy_chanctx_to_vlans(struct ieee80211_sub_if_data *sdata,
19551f4ac5a6SJohannes Berg 					 bool clear);
1956c0166da9SMichal Kazior int ieee80211_chanctx_refcount(struct ieee80211_local *local,
1957c0166da9SMichal Kazior 			       struct ieee80211_chanctx *ctx);
1958d01a1e65SMichal Kazior 
195904ecd257SJohannes Berg void ieee80211_recalc_smps_chanctx(struct ieee80211_local *local,
196004ecd257SJohannes Berg 				   struct ieee80211_chanctx *chanctx);
196121f659bfSEliad Peller void ieee80211_recalc_chanctx_min_def(struct ieee80211_local *local,
196221f659bfSEliad Peller 				      struct ieee80211_chanctx *ctx);
1963164eb02dSSimon Wunderlich 
1964164eb02dSSimon Wunderlich void ieee80211_dfs_cac_timer(unsigned long data);
1965164eb02dSSimon Wunderlich void ieee80211_dfs_cac_timer_work(struct work_struct *work);
1966164eb02dSSimon Wunderlich void ieee80211_dfs_cac_cancel(struct ieee80211_local *local);
1967164eb02dSSimon Wunderlich void ieee80211_dfs_radar_detected_work(struct work_struct *work);
1968c6da674aSChun-Yeow Yeoh int ieee80211_send_action_csa(struct ieee80211_sub_if_data *sdata,
1969c6da674aSChun-Yeow Yeoh 			      struct cfg80211_csa_settings *csa_settings);
197004ecd257SJohannes Berg 
19712475b1ccSMax Stepanov bool ieee80211_cs_valid(const struct ieee80211_cipher_scheme *cs);
19722475b1ccSMax Stepanov bool ieee80211_cs_list_valid(const struct ieee80211_cipher_scheme *cs, int n);
19732475b1ccSMax Stepanov const struct ieee80211_cipher_scheme *
19742475b1ccSMax Stepanov ieee80211_cs_get(struct ieee80211_local *local, u32 cipher,
19752475b1ccSMax Stepanov 		 enum nl80211_iftype iftype);
19762475b1ccSMax Stepanov int ieee80211_cs_headroom(struct ieee80211_local *local,
19772475b1ccSMax Stepanov 			  struct cfg80211_crypto_settings *crypto,
19782475b1ccSMax Stepanov 			  enum nl80211_iftype iftype);
1979057d5f4bSThomas Pedersen void ieee80211_recalc_dtim(struct ieee80211_local *local,
1980057d5f4bSThomas Pedersen 			   struct ieee80211_sub_if_data *sdata);
198173de86a3SLuciano Coelho int ieee80211_check_combinations(struct ieee80211_sub_if_data *sdata,
198273de86a3SLuciano Coelho 				 const struct cfg80211_chan_def *chandef,
198373de86a3SLuciano Coelho 				 enum ieee80211_chanctx_mode chanmode,
198473de86a3SLuciano Coelho 				 u8 radar_detect);
19856fa001bcSMichal Kazior int ieee80211_max_num_channels(struct ieee80211_local *local);
19862475b1ccSMax Stepanov 
198795224fe8SArik Nemtsov /* TDLS */
198895224fe8SArik Nemtsov int ieee80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
19893b3a0162SJohannes Berg 			const u8 *peer, u8 action_code, u8 dialog_token,
199095224fe8SArik Nemtsov 			u16 status_code, u32 peer_capability,
199131fa97c5SArik Nemtsov 			bool initiator, const u8 *extra_ies,
199231fa97c5SArik Nemtsov 			size_t extra_ies_len);
199395224fe8SArik Nemtsov int ieee80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
19943b3a0162SJohannes Berg 			const u8 *peer, enum nl80211_tdls_operation oper);
1995c10a1993SJohannes Berg void ieee80211_tdls_peer_del_work(struct work_struct *wk);
199695224fe8SArik Nemtsov 
1997b7ffbd7eSJohannes Berg extern const struct ethtool_ops ieee80211_ethtool_ops;
1998b7ffbd7eSJohannes Berg 
1999f4ea83ddSJohannes Berg #ifdef CONFIG_MAC80211_NOINLINE
2000d9e8a70fSJohannes Berg #define debug_noinline noinline
2001d9e8a70fSJohannes Berg #else
2002d9e8a70fSJohannes Berg #define debug_noinline
2003d9e8a70fSJohannes Berg #endif
2004d9e8a70fSJohannes Berg 
2005f0706e82SJiri Benc #endif /* IEEE80211_I_H */
2006