xref: /openbmc/linux/net/mac80211/ieee80211_i.h (revision 34d4bc4d)
1f0706e82SJiri Benc /*
2f0706e82SJiri Benc  * Copyright 2002-2005, Instant802 Networks, Inc.
3f0706e82SJiri Benc  * Copyright 2005, Devicescape Software, Inc.
4f0706e82SJiri Benc  * Copyright 2006-2007	Jiri Benc <jbenc@suse.cz>
5026331c4SJouni Malinen  * Copyright 2007-2010	Johannes Berg <johannes@sipsolutions.net>
6f0706e82SJiri Benc  *
7f0706e82SJiri Benc  * This program is free software; you can redistribute it and/or modify
8f0706e82SJiri Benc  * it under the terms of the GNU General Public License version 2 as
9f0706e82SJiri Benc  * published by the Free Software Foundation.
10f0706e82SJiri Benc  */
11f0706e82SJiri Benc 
12f0706e82SJiri Benc #ifndef IEEE80211_I_H
13f0706e82SJiri Benc #define IEEE80211_I_H
14f0706e82SJiri Benc 
15f0706e82SJiri Benc #include <linux/kernel.h>
16f0706e82SJiri Benc #include <linux/device.h>
17f0706e82SJiri Benc #include <linux/if_ether.h>
18f0706e82SJiri Benc #include <linux/interrupt.h>
19f0706e82SJiri Benc #include <linux/list.h>
20f0706e82SJiri Benc #include <linux/netdevice.h>
21f0706e82SJiri Benc #include <linux/skbuff.h>
22f0706e82SJiri Benc #include <linux/workqueue.h>
23f0706e82SJiri Benc #include <linux/types.h>
24f0706e82SJiri Benc #include <linux/spinlock.h>
25571ecf67SJohannes Berg #include <linux/etherdevice.h>
26fe7a5d5cSJohannes Berg #include <net/ieee80211_radiotap.h>
2793da9cc1Scolin@cozybit.com #include <net/cfg80211.h>
2851cb6db0SDavid S. Miller #include <net/mac80211.h>
292c8dccc7SJohannes Berg #include "key.h"
30f0706e82SJiri Benc #include "sta_info.h"
31f0706e82SJiri Benc 
329cfb0009SJohannes Berg struct ieee80211_local;
33f0706e82SJiri Benc 
34f0706e82SJiri Benc /* Maximum number of broadcast/multicast frames to buffer when some of the
35f0706e82SJiri Benc  * associated stations are using power saving. */
36f0706e82SJiri Benc #define AP_MAX_BC_BUFFER 128
37f0706e82SJiri Benc 
38f0706e82SJiri Benc /* Maximum number of frames buffered to all STAs, including multicast frames.
39f0706e82SJiri Benc  * Note: increasing this limit increases the potential memory requirement. Each
40f0706e82SJiri Benc  * frame can be up to about 2 kB long. */
41f0706e82SJiri Benc #define TOTAL_MAX_TX_BUFFER 512
42f0706e82SJiri Benc 
43f0706e82SJiri Benc /* Required encryption head and tailroom */
44f0706e82SJiri Benc #define IEEE80211_ENCRYPT_HEADROOM 8
45765cb46aSJouni Malinen #define IEEE80211_ENCRYPT_TAILROOM 18
46f0706e82SJiri Benc 
47f0706e82SJiri Benc /* IEEE 802.11 (Ch. 9.5 Defragmentation) requires support for concurrent
48f0706e82SJiri Benc  * reception of at least three fragmented frames. This limit can be increased
49f0706e82SJiri Benc  * by changing this define, at the cost of slower frame reassembly and
50f0706e82SJiri Benc  * increased memory use (about 2 kB of RAM per entry). */
51f0706e82SJiri Benc #define IEEE80211_FRAGMENT_MAX 4
52f0706e82SJiri Benc 
5320ad19d0SJohannes Berg #define TU_TO_EXP_TIME(x)	(jiffies + usecs_to_jiffies((x) * 1024))
5420ad19d0SJohannes Berg 
55ab13315aSKalle Valo #define IEEE80211_DEFAULT_UAPSD_QUEUES \
56ab13315aSKalle Valo 	(IEEE80211_WMM_IE_STA_QOSINFO_AC_BK |	\
57ab13315aSKalle Valo 	 IEEE80211_WMM_IE_STA_QOSINFO_AC_BE |	\
58ab13315aSKalle Valo 	 IEEE80211_WMM_IE_STA_QOSINFO_AC_VI |	\
59ab13315aSKalle Valo 	 IEEE80211_WMM_IE_STA_QOSINFO_AC_VO)
60ab13315aSKalle Valo 
61ab13315aSKalle Valo #define IEEE80211_DEFAULT_MAX_SP_LEN		\
62ab13315aSKalle Valo 	IEEE80211_WMM_IE_STA_QOSINFO_SP_ALL
63ab13315aSKalle Valo 
64f0706e82SJiri Benc struct ieee80211_fragment_entry {
65f0706e82SJiri Benc 	unsigned long first_frag_time;
66f0706e82SJiri Benc 	unsigned int seq;
67f0706e82SJiri Benc 	unsigned int rx_queue;
68f0706e82SJiri Benc 	unsigned int last_frag;
69f0706e82SJiri Benc 	unsigned int extra_len;
70f0706e82SJiri Benc 	struct sk_buff_head skb_list;
71f0706e82SJiri Benc 	int ccmp; /* Whether fragments were encrypted with CCMP */
72f0706e82SJiri Benc 	u8 last_pn[6]; /* PN of the last fragment if CCMP was used */
73f0706e82SJiri Benc };
74f0706e82SJiri Benc 
75f0706e82SJiri Benc 
76c2b13452SJohannes Berg struct ieee80211_bss {
7700d3f14cSJohannes Berg 	/* don't want to look up all the time */
78056cdd59SJohannes Berg 	size_t ssid_len;
79f0706e82SJiri Benc 	u8 ssid[IEEE80211_MAX_SSID_LEN];
8000d3f14cSJohannes Berg 
8198f7dfd8SEmmanuel Grumbach 	u8 dtim_period;
8200d3f14cSJohannes Berg 
8343ac2ca3SJouni Malinen 	bool wmm_used;
84ab13315aSKalle Valo 	bool uapsd_supported;
8500d3f14cSJohannes Berg 
8600d3f14cSJohannes Berg 	unsigned long last_probe_resp;
8700d3f14cSJohannes Berg 
88ee385855SLuis Carlos Cobo #ifdef CONFIG_MAC80211_MESH
89ee385855SLuis Carlos Cobo 	u8 *mesh_id;
90ee385855SLuis Carlos Cobo 	size_t mesh_id_len;
9124736701SJohn W. Linville 	u8 *mesh_cfg;
92902acc78SJohannes Berg #endif
9300d3f14cSJohannes Berg 
94f0706e82SJiri Benc #define IEEE80211_MAX_SUPP_RATES 32
95f0706e82SJiri Benc 	u8 supp_rates[IEEE80211_MAX_SUPP_RATES];
96f0706e82SJiri Benc 	size_t supp_rates_len;
97f0706e82SJiri Benc 
9800d3f14cSJohannes Berg 	/*
9900d3f14cSJohannes Berg 	 * During assocation, we save an ERP value from a probe response so
1005628221cSDaniel Drake 	 * that we can feed ERP info to the driver when handling the
1015628221cSDaniel Drake 	 * association completes. these fields probably won't be up-to-date
10200d3f14cSJohannes Berg 	 * otherwise, you probably don't want to use them.
10300d3f14cSJohannes Berg 	 */
10400d3f14cSJohannes Berg 	bool has_erp_value;
1055628221cSDaniel Drake 	u8 erp_value;
106f0706e82SJiri Benc };
107f0706e82SJiri Benc 
108c2b13452SJohannes Berg static inline u8 *bss_mesh_cfg(struct ieee80211_bss *bss)
109902acc78SJohannes Berg {
110902acc78SJohannes Berg #ifdef CONFIG_MAC80211_MESH
111902acc78SJohannes Berg 	return bss->mesh_cfg;
112902acc78SJohannes Berg #endif
113902acc78SJohannes Berg 	return NULL;
114902acc78SJohannes Berg }
115902acc78SJohannes Berg 
116c2b13452SJohannes Berg static inline u8 *bss_mesh_id(struct ieee80211_bss *bss)
117902acc78SJohannes Berg {
118902acc78SJohannes Berg #ifdef CONFIG_MAC80211_MESH
119902acc78SJohannes Berg 	return bss->mesh_id;
120902acc78SJohannes Berg #endif
121902acc78SJohannes Berg 	return NULL;
122902acc78SJohannes Berg }
123902acc78SJohannes Berg 
124c2b13452SJohannes Berg static inline u8 bss_mesh_id_len(struct ieee80211_bss *bss)
125902acc78SJohannes Berg {
126902acc78SJohannes Berg #ifdef CONFIG_MAC80211_MESH
127902acc78SJohannes Berg 	return bss->mesh_id_len;
128902acc78SJohannes Berg #endif
129902acc78SJohannes Berg 	return 0;
130902acc78SJohannes Berg }
131902acc78SJohannes Berg 
132f0706e82SJiri Benc 
1339ae54c84SJohannes Berg typedef unsigned __bitwise__ ieee80211_tx_result;
1349ae54c84SJohannes Berg #define TX_CONTINUE	((__force ieee80211_tx_result) 0u)
1359ae54c84SJohannes Berg #define TX_DROP		((__force ieee80211_tx_result) 1u)
1369ae54c84SJohannes Berg #define TX_QUEUED	((__force ieee80211_tx_result) 2u)
1379ae54c84SJohannes Berg 
1385cf121c3SJohannes Berg #define IEEE80211_TX_FRAGMENTED		BIT(0)
1395cf121c3SJohannes Berg #define IEEE80211_TX_UNICAST		BIT(1)
1405cf121c3SJohannes Berg #define IEEE80211_TX_PS_BUFFERED	BIT(2)
1419ae54c84SJohannes Berg 
1425cf121c3SJohannes Berg struct ieee80211_tx_data {
143f0706e82SJiri Benc 	struct sk_buff *skb;
144f0706e82SJiri Benc 	struct ieee80211_local *local;
145f0706e82SJiri Benc 	struct ieee80211_sub_if_data *sdata;
146f0706e82SJiri Benc 	struct sta_info *sta;
147f0706e82SJiri Benc 	struct ieee80211_key *key;
1485cf121c3SJohannes Berg 
1498318d78aSJohannes Berg 	struct ieee80211_channel *channel;
150f0706e82SJiri Benc 
151a4b7d7bdSHarvey Harrison 	u16 ethertype;
152056cdd59SJohannes Berg 	unsigned int flags;
1535cf121c3SJohannes Berg };
1545cf121c3SJohannes Berg 
1555cf121c3SJohannes Berg 
1565cf121c3SJohannes Berg typedef unsigned __bitwise__ ieee80211_rx_result;
1575cf121c3SJohannes Berg #define RX_CONTINUE		((__force ieee80211_rx_result) 0u)
1585cf121c3SJohannes Berg #define RX_DROP_UNUSABLE	((__force ieee80211_rx_result) 1u)
1595cf121c3SJohannes Berg #define RX_DROP_MONITOR		((__force ieee80211_rx_result) 2u)
1605cf121c3SJohannes Berg #define RX_QUEUED		((__force ieee80211_rx_result) 3u)
1615cf121c3SJohannes Berg 
1625cf121c3SJohannes Berg #define IEEE80211_RX_IN_SCAN		BIT(0)
1635cf121c3SJohannes Berg /* frame is destined to interface currently processed (incl. multicast frames) */
1645cf121c3SJohannes Berg #define IEEE80211_RX_RA_MATCH		BIT(1)
1655cf121c3SJohannes Berg #define IEEE80211_RX_AMSDU		BIT(2)
1668c0c709eSJohannes Berg #define IEEE80211_RX_FRAGMENTED		BIT(3)
1672e161f78SJohannes Berg #define IEEE80211_MALFORMED_ACTION_FRM	BIT(4)
1682569a826SJohannes Berg /* only add flags here that do not change with subframes of an aMPDU */
1695cf121c3SJohannes Berg 
1705cf121c3SJohannes Berg struct ieee80211_rx_data {
1715cf121c3SJohannes Berg 	struct sk_buff *skb;
1725cf121c3SJohannes Berg 	struct ieee80211_local *local;
1735cf121c3SJohannes Berg 	struct ieee80211_sub_if_data *sdata;
1745cf121c3SJohannes Berg 	struct sta_info *sta;
1755cf121c3SJohannes Berg 	struct ieee80211_key *key;
176056cdd59SJohannes Berg 
177056cdd59SJohannes Berg 	unsigned int flags;
178f0706e82SJiri Benc 	int queue;
17950741ae0SJohannes Berg 	u32 tkip_iv32;
18050741ae0SJohannes Berg 	u16 tkip_iv16;
181f0706e82SJiri Benc };
182f0706e82SJiri Benc 
1835dfdaf58SJohannes Berg struct beacon_data {
1845dfdaf58SJohannes Berg 	u8 *head, *tail;
1855dfdaf58SJohannes Berg 	int head_len, tail_len;
1865dfdaf58SJohannes Berg 	int dtim_period;
1875dfdaf58SJohannes Berg };
1885dfdaf58SJohannes Berg 
189f0706e82SJiri Benc struct ieee80211_if_ap {
1905dfdaf58SJohannes Berg 	struct beacon_data *beacon;
191f0706e82SJiri Benc 
1920ec3ca44SJohannes Berg 	struct list_head vlans;
1930ec3ca44SJohannes Berg 
194f0706e82SJiri Benc 	/* yes, this looks ugly, but guarantees that we can later use
195f0706e82SJiri Benc 	 * bitmap_empty :)
196004c872eSJohannes Berg 	 * NB: don't touch this bitmap, use sta_info_{set,clear}_tim_bit */
197f0706e82SJiri Benc 	u8 tim[sizeof(unsigned long) * BITS_TO_LONGS(IEEE80211_MAX_AID + 1)];
198f0706e82SJiri Benc 	struct sk_buff_head ps_bc_buf;
199056cdd59SJohannes Berg 	atomic_t num_sta_ps; /* number of stations in PS mode */
2005dfdaf58SJohannes Berg 	int dtim_count;
201f0706e82SJiri Benc };
202f0706e82SJiri Benc 
203f0706e82SJiri Benc struct ieee80211_if_wds {
204f0706e82SJiri Benc 	struct sta_info *sta;
205056cdd59SJohannes Berg 	u8 remote_addr[ETH_ALEN];
206f0706e82SJiri Benc };
207f0706e82SJiri Benc 
208f0706e82SJiri Benc struct ieee80211_if_vlan {
2090ec3ca44SJohannes Berg 	struct list_head list;
210f14543eeSFelix Fietkau 
211f14543eeSFelix Fietkau 	/* used for all tx if the VLAN is configured to 4-addr mode */
212f14543eeSFelix Fietkau 	struct sta_info *sta;
213f0706e82SJiri Benc };
214f0706e82SJiri Benc 
215ee385855SLuis Carlos Cobo struct mesh_stats {
216c8a61a7dSDaniel Walker 	__u32 fwded_mcast;		/* Mesh forwarded multicast frames */
217c8a61a7dSDaniel Walker 	__u32 fwded_unicast;		/* Mesh forwarded unicast frames */
218c8a61a7dSDaniel Walker 	__u32 fwded_frames;		/* Mesh total forwarded frames */
219ee385855SLuis Carlos Cobo 	__u32 dropped_frames_ttl;	/* Not transmitted since mesh_ttl == 0*/
220ee385855SLuis Carlos Cobo 	__u32 dropped_frames_no_route;	/* Not transmitted, no route found */
221ee385855SLuis Carlos Cobo 	atomic_t estab_plinks;
222ee385855SLuis Carlos Cobo };
223ee385855SLuis Carlos Cobo 
224ee385855SLuis Carlos Cobo #define PREQ_Q_F_START		0x1
225ee385855SLuis Carlos Cobo #define PREQ_Q_F_REFRESH	0x2
226ee385855SLuis Carlos Cobo struct mesh_preq_queue {
227ee385855SLuis Carlos Cobo 	struct list_head list;
228ee385855SLuis Carlos Cobo 	u8 dst[ETH_ALEN];
229ee385855SLuis Carlos Cobo 	u8 flags;
230ee385855SLuis Carlos Cobo };
231ee385855SLuis Carlos Cobo 
232f679f65dSJohannes Berg enum ieee80211_work_type {
233b8bc4b0aSJohannes Berg 	IEEE80211_WORK_ABORT,
234af6b6374SJohannes Berg 	IEEE80211_WORK_DIRECT_PROBE,
235f679f65dSJohannes Berg 	IEEE80211_WORK_AUTH,
236e5b900d2SJohannes Berg 	IEEE80211_WORK_ASSOC_BEACON_WAIT,
237f679f65dSJohannes Berg 	IEEE80211_WORK_ASSOC,
238b8bc4b0aSJohannes Berg 	IEEE80211_WORK_REMAIN_ON_CHANNEL,
23977fdaa12SJohannes Berg };
24077fdaa12SJohannes Berg 
241af6b6374SJohannes Berg /**
242af6b6374SJohannes Berg  * enum work_done_result - indicates what to do after work was done
243af6b6374SJohannes Berg  *
244af6b6374SJohannes Berg  * @WORK_DONE_DESTROY: This work item is no longer needed, destroy.
245af6b6374SJohannes Berg  * @WORK_DONE_REQUEUE: This work item was reset to be reused, and
246af6b6374SJohannes Berg  *	should be requeued.
247af6b6374SJohannes Berg  */
248af6b6374SJohannes Berg enum work_done_result {
249af6b6374SJohannes Berg 	WORK_DONE_DESTROY,
250af6b6374SJohannes Berg 	WORK_DONE_REQUEUE,
251af6b6374SJohannes Berg };
252af6b6374SJohannes Berg 
253f679f65dSJohannes Berg struct ieee80211_work {
25477fdaa12SJohannes Berg 	struct list_head list;
255f679f65dSJohannes Berg 
256af6b6374SJohannes Berg 	struct rcu_head rcu_head;
257af6b6374SJohannes Berg 
258af6b6374SJohannes Berg 	struct ieee80211_sub_if_data *sdata;
259af6b6374SJohannes Berg 
260af6b6374SJohannes Berg 	enum work_done_result (*done)(struct ieee80211_work *wk,
261af6b6374SJohannes Berg 				      struct sk_buff *skb);
262af6b6374SJohannes Berg 
263f679f65dSJohannes Berg 	struct ieee80211_channel *chan;
264e4da8c37SJohannes Berg 	enum nl80211_channel_type chan_type;
265af6b6374SJohannes Berg 
266f679f65dSJohannes Berg 	unsigned long timeout;
267f679f65dSJohannes Berg 	enum ieee80211_work_type type;
268f679f65dSJohannes Berg 
269af6b6374SJohannes Berg 	u8 filter_ta[ETH_ALEN];
270af6b6374SJohannes Berg 
271e4da8c37SJohannes Berg 	bool started;
272e4da8c37SJohannes Berg 
273f679f65dSJohannes Berg 	union {
274f679f65dSJohannes Berg 		struct {
275f679f65dSJohannes Berg 			int tries;
276f679f65dSJohannes Berg 			u16 algorithm, transaction;
27777fdaa12SJohannes Berg 			u8 ssid[IEEE80211_MAX_SSID_LEN];
27877fdaa12SJohannes Berg 			u8 ssid_len;
279fffd0934SJohannes Berg 			u8 key[WLAN_KEY_LEN_WEP104];
280fffd0934SJohannes Berg 			u8 key_len, key_idx;
281f679f65dSJohannes Berg 			bool privacy;
282af6b6374SJohannes Berg 		} probe_auth;
283f679f65dSJohannes Berg 		struct {
2840c1ad2caSJohannes Berg 			struct cfg80211_bss *bss;
285f679f65dSJohannes Berg 			const u8 *supp_rates;
286f679f65dSJohannes Berg 			const u8 *ht_information_ie;
287af6b6374SJohannes Berg 			enum ieee80211_smps_mode smps;
288f679f65dSJohannes Berg 			int tries;
289f679f65dSJohannes Berg 			u16 capability;
290af6b6374SJohannes Berg 			u8 prev_bssid[ETH_ALEN];
291f679f65dSJohannes Berg 			u8 ssid[IEEE80211_MAX_SSID_LEN];
292f679f65dSJohannes Berg 			u8 ssid_len;
293f679f65dSJohannes Berg 			u8 supp_rates_len;
294ab13315aSKalle Valo 			bool wmm_used, use_11n, uapsd_used;
295f679f65dSJohannes Berg 		} assoc;
296b8bc4b0aSJohannes Berg 		struct {
297e4da8c37SJohannes Berg 			u32 duration;
298b8bc4b0aSJohannes Berg 		} remain;
299f679f65dSJohannes Berg 	};
300fffd0934SJohannes Berg 
301f679f65dSJohannes Berg 	int ie_len;
30277fdaa12SJohannes Berg 	/* must be last */
303f679f65dSJohannes Berg 	u8 ie[0];
30477fdaa12SJohannes Berg };
30577fdaa12SJohannes Berg 
30646900298SJohannes Berg /* flags used in struct ieee80211_if_managed.flags */
307ab1faeadSJohannes Berg enum ieee80211_sta_flags {
308b291ba11SJohannes Berg 	IEEE80211_STA_BEACON_POLL	= BIT(0),
309b291ba11SJohannes Berg 	IEEE80211_STA_CONNECTION_POLL	= BIT(1),
310b291ba11SJohannes Berg 	IEEE80211_STA_CONTROL_PORT	= BIT(2),
311b291ba11SJohannes Berg 	IEEE80211_STA_DISABLE_11N	= BIT(4),
312b291ba11SJohannes Berg 	IEEE80211_STA_CSA_RECEIVED	= BIT(5),
313b291ba11SJohannes Berg 	IEEE80211_STA_MFP_ENABLED	= BIT(6),
314ab13315aSKalle Valo 	IEEE80211_STA_UAPSD_ENABLED	= BIT(7),
315375177bfSVivek Natarajan 	IEEE80211_STA_NULLFUNC_ACKED	= BIT(8),
31617e4ec14SJouni Malinen 	IEEE80211_STA_RESET_SIGNAL_AVE	= BIT(9),
317ab1faeadSJohannes Berg };
318ab1faeadSJohannes Berg 
31946900298SJohannes Berg struct ieee80211_if_managed {
320056cdd59SJohannes Berg 	struct timer_list timer;
321b291ba11SJohannes Berg 	struct timer_list conn_mon_timer;
322b291ba11SJohannes Berg 	struct timer_list bcn_mon_timer;
323c481ec97SSujith 	struct timer_list chswitch_timer;
324b291ba11SJohannes Berg 	struct work_struct monitor_work;
325c481ec97SSujith 	struct work_struct chswitch_work;
3261e4dcd01SJuuso Oikarinen 	struct work_struct beacon_connection_loss_work;
32746900298SJohannes Berg 
328b291ba11SJohannes Berg 	unsigned long probe_timeout;
329a43abf29SMaxim Levitsky 	int probe_send_count;
330b291ba11SJohannes Berg 
33177fdaa12SJohannes Berg 	struct mutex mtx;
3320c1ad2caSJohannes Berg 	struct cfg80211_bss *associated;
33346900298SJohannes Berg 
33477fdaa12SJohannes Berg 	u8 bssid[ETH_ALEN];
33546900298SJohannes Berg 
336f0706e82SJiri Benc 	u16 aid;
337f0706e82SJiri Benc 
3385bb644a0SJohannes Berg 	unsigned long timers_running; /* used for quiesce/restart */
339965bedadSJohannes Berg 	bool powersave; /* powersave requested for this iface */
3400f78231bSJohannes Berg 	enum ieee80211_smps_mode req_smps, /* requested smps mode */
341d1f5b7a3SJohannes Berg 				 ap_smps, /* smps mode AP thinks we're in */
342d1f5b7a3SJohannes Berg 				 driver_smps_mode; /* smps mode request */
343d1f5b7a3SJohannes Berg 
344d1f5b7a3SJohannes Berg 	struct work_struct request_smps_work;
345965bedadSJohannes Berg 
346d6f2da5bSJiri Slaby 	unsigned int flags;
347f0706e82SJiri Benc 
348d91f36dbSJohannes Berg 	u32 beacon_crc;
349d91f36dbSJohannes Berg 
350fdfacf0aSJouni Malinen 	enum {
351fdfacf0aSJouni Malinen 		IEEE80211_MFP_DISABLED,
352fdfacf0aSJouni Malinen 		IEEE80211_MFP_OPTIONAL,
353fdfacf0aSJouni Malinen 		IEEE80211_MFP_REQUIRED
354fdfacf0aSJouni Malinen 	} mfp; /* management frame protection */
355fdfacf0aSJouni Malinen 
356f0706e82SJiri Benc 	int wmm_last_param_set;
3579bc383deSJohannes Berg 
3589bc383deSJohannes Berg 	u8 use_4addr;
35917e4ec14SJouni Malinen 
36017e4ec14SJouni Malinen 	/* Signal strength from the last Beacon frame in the current BSS. */
36117e4ec14SJouni Malinen 	int last_beacon_signal;
36217e4ec14SJouni Malinen 
36317e4ec14SJouni Malinen 	/*
36417e4ec14SJouni Malinen 	 * Weighted average of the signal strength from Beacon frames in the
36517e4ec14SJouni Malinen 	 * current BSS. This is in units of 1/16 of the signal unit to maintain
36617e4ec14SJouni Malinen 	 * accuracy and to speed up calculations, i.e., the value need to be
36717e4ec14SJouni Malinen 	 * divided by 16 to get the actual value.
36817e4ec14SJouni Malinen 	 */
36917e4ec14SJouni Malinen 	int ave_beacon_signal;
37017e4ec14SJouni Malinen 
37117e4ec14SJouni Malinen 	/*
37217e4ec14SJouni Malinen 	 * Last Beacon frame signal strength average (ave_beacon_signal / 16)
37317e4ec14SJouni Malinen 	 * that triggered a cqm event. 0 indicates that no event has been
37417e4ec14SJouni Malinen 	 * generated for the current association.
37517e4ec14SJouni Malinen 	 */
37617e4ec14SJouni Malinen 	int last_cqm_event_signal;
377f0706e82SJiri Benc };
378f0706e82SJiri Benc 
37946900298SJohannes Berg struct ieee80211_if_ibss {
38046900298SJohannes Berg 	struct timer_list timer;
38146900298SJohannes Berg 
3827a17a33cSJohannes Berg 	struct mutex mtx;
3837a17a33cSJohannes Berg 
384af8cdcd8SJohannes Berg 	unsigned long last_scan_completed;
3855bb644a0SJohannes Berg 
386fbd2c8dcSTeemu Paasikivi 	u32 basic_rates;
387fbd2c8dcSTeemu Paasikivi 
3885bb644a0SJohannes Berg 	bool timer_running;
3895bb644a0SJohannes Berg 
390af8cdcd8SJohannes Berg 	bool fixed_bssid;
391af8cdcd8SJohannes Berg 	bool fixed_channel;
392fffd0934SJohannes Berg 	bool privacy;
39346900298SJohannes Berg 
39446900298SJohannes Berg 	u8 bssid[ETH_ALEN];
395af8cdcd8SJohannes Berg 	u8 ssid[IEEE80211_MAX_SSID_LEN];
396af8cdcd8SJohannes Berg 	u8 ssid_len, ie_len;
397af8cdcd8SJohannes Berg 	u8 *ie;
398af8cdcd8SJohannes Berg 	struct ieee80211_channel *channel;
39946900298SJohannes Berg 
40046900298SJohannes Berg 	unsigned long ibss_join_req;
401af8cdcd8SJohannes Berg 	/* probe response/beacon for IBSS */
402af8cdcd8SJohannes Berg 	struct sk_buff *presp, *skb;
40346900298SJohannes Berg 
40446900298SJohannes Berg 	enum {
40546900298SJohannes Berg 		IEEE80211_IBSS_MLME_SEARCH,
40646900298SJohannes Berg 		IEEE80211_IBSS_MLME_JOINED,
40746900298SJohannes Berg 	} state;
40846900298SJohannes Berg };
40946900298SJohannes Berg 
410472dbc45SJohannes Berg struct ieee80211_if_mesh {
411472dbc45SJohannes Berg 	struct timer_list housekeeping_timer;
412472dbc45SJohannes Berg 	struct timer_list mesh_path_timer;
413e304bfd3SRui Paulo 	struct timer_list mesh_path_root_timer;
414472dbc45SJohannes Berg 
4155bb644a0SJohannes Berg 	unsigned long timers_running;
4165bb644a0SJohannes Berg 
41718889231SJavier Cardona 	unsigned long wrkq_flags;
418472dbc45SJohannes Berg 
419472dbc45SJohannes Berg 	u8 mesh_id[IEEE80211_MAX_MESH_ID_LEN];
420472dbc45SJohannes Berg 	size_t mesh_id_len;
421472dbc45SJohannes Berg 	/* Active Path Selection Protocol Identifier */
4223491707aSRui Paulo 	u8 mesh_pp_id;
423472dbc45SJohannes Berg 	/* Active Path Selection Metric Identifier */
4243491707aSRui Paulo 	u8 mesh_pm_id;
425472dbc45SJohannes Berg 	/* Congestion Control Mode Identifier */
4263491707aSRui Paulo 	u8 mesh_cc_id;
4279e03fdfdSJavier Cardona 	/* Synchronization Protocol Identifier */
4283491707aSRui Paulo 	u8 mesh_sp_id;
4299e03fdfdSJavier Cardona 	/* Authentication Protocol Identifier */
4303491707aSRui Paulo 	u8 mesh_auth_id;
431d19b3bf6SRui Paulo 	/* Local mesh Sequence Number */
432d19b3bf6SRui Paulo 	u32 sn;
433472dbc45SJohannes Berg 	/* Last used PREQ ID */
434472dbc45SJohannes Berg 	u32 preq_id;
435472dbc45SJohannes Berg 	atomic_t mpaths;
436d19b3bf6SRui Paulo 	/* Timestamp of last SN update */
437d19b3bf6SRui Paulo 	unsigned long last_sn_update;
438d19b3bf6SRui Paulo 	/* Timestamp of last SN sent */
439472dbc45SJohannes Berg 	unsigned long last_preq;
440472dbc45SJohannes Berg 	struct mesh_rmc *rmc;
441472dbc45SJohannes Berg 	spinlock_t mesh_preq_queue_lock;
442472dbc45SJohannes Berg 	struct mesh_preq_queue preq_queue;
443472dbc45SJohannes Berg 	int preq_queue_len;
444472dbc45SJohannes Berg 	struct mesh_stats mshstats;
445472dbc45SJohannes Berg 	struct mesh_config mshcfg;
446472dbc45SJohannes Berg 	u32 mesh_seqnum;
447472dbc45SJohannes Berg 	bool accepting_plinks;
448472dbc45SJohannes Berg };
449902acc78SJohannes Berg 
450902acc78SJohannes Berg #ifdef CONFIG_MAC80211_MESH
451472dbc45SJohannes Berg #define IEEE80211_IFSTA_MESH_CTR_INC(msh, name)	\
452472dbc45SJohannes Berg 	do { (msh)->mshstats.name++; } while (0)
453902acc78SJohannes Berg #else
454472dbc45SJohannes Berg #define IEEE80211_IFSTA_MESH_CTR_INC(msh, name) \
455902acc78SJohannes Berg 	do { } while (0)
456902acc78SJohannes Berg #endif
457f0706e82SJiri Benc 
458213cd118SJohannes Berg /**
459213cd118SJohannes Berg  * enum ieee80211_sub_if_data_flags - virtual interface flags
460213cd118SJohannes Berg  *
461213cd118SJohannes Berg  * @IEEE80211_SDATA_ALLMULTI: interface wants all multicast packets
462213cd118SJohannes Berg  * @IEEE80211_SDATA_PROMISC: interface is promisc
463213cd118SJohannes Berg  * @IEEE80211_SDATA_OPERATING_GMODE: operating in G-only mode
464213cd118SJohannes Berg  * @IEEE80211_SDATA_DONT_BRIDGE_PACKETS: bridge packets between
465213cd118SJohannes Berg  *	associated stations and deliver multicast frames both
466213cd118SJohannes Berg  *	back to wireless media and to the local net stack.
467213cd118SJohannes Berg  */
468213cd118SJohannes Berg enum ieee80211_sub_if_data_flags {
469213cd118SJohannes Berg 	IEEE80211_SDATA_ALLMULTI		= BIT(0),
470213cd118SJohannes Berg 	IEEE80211_SDATA_PROMISC			= BIT(1),
4717986cf95SJohannes Berg 	IEEE80211_SDATA_OPERATING_GMODE		= BIT(2),
4727986cf95SJohannes Berg 	IEEE80211_SDATA_DONT_BRIDGE_PACKETS	= BIT(3),
473213cd118SJohannes Berg };
474213cd118SJohannes Berg 
47534d4bc4dSJohannes Berg /**
47634d4bc4dSJohannes Berg  * enum ieee80211_sdata_state_bits - virtual interface state bits
47734d4bc4dSJohannes Berg  * @SDATA_STATE_RUNNING: virtual interface is up & running; this
47834d4bc4dSJohannes Berg  *	mirrors netif_running() but is separate for interface type
47934d4bc4dSJohannes Berg  *	change handling while the interface is up
48034d4bc4dSJohannes Berg  */
48134d4bc4dSJohannes Berg enum ieee80211_sdata_state_bits {
48234d4bc4dSJohannes Berg 	SDATA_STATE_RUNNING,
48334d4bc4dSJohannes Berg };
48434d4bc4dSJohannes Berg 
485f0706e82SJiri Benc struct ieee80211_sub_if_data {
486f0706e82SJiri Benc 	struct list_head list;
487f0706e82SJiri Benc 
488f0706e82SJiri Benc 	struct wireless_dev wdev;
489f0706e82SJiri Benc 
49011a843b7SJohannes Berg 	/* keys */
49111a843b7SJohannes Berg 	struct list_head key_list;
49211a843b7SJohannes Berg 
493f0706e82SJiri Benc 	struct net_device *dev;
494f0706e82SJiri Benc 	struct ieee80211_local *local;
495f0706e82SJiri Benc 
49613262ffdSJiri Slaby 	unsigned int flags;
4977e9ed188SDaniel Drake 
49834d4bc4dSJohannes Berg 	unsigned long state;
49934d4bc4dSJohannes Berg 
500f0706e82SJiri Benc 	int drop_unencrypted;
501f0706e82SJiri Benc 
50247846c9bSJohannes Berg 	char name[IFNAMSIZ];
50347846c9bSJohannes Berg 
504413ad50aSJohannes Berg 	/*
505413ad50aSJohannes Berg 	 * keep track of whether the HT opmode (stored in
506413ad50aSJohannes Berg 	 * vif.bss_info.ht_operation_mode) is valid.
507413ad50aSJohannes Berg 	 */
508413ad50aSJohannes Berg 	bool ht_opmode_valid;
509413ad50aSJohannes Berg 
5107da7cc1dSJohannes Berg 	/* to detect idle changes */
5117da7cc1dSJohannes Berg 	bool old_idle;
5127da7cc1dSJohannes Berg 
513f0706e82SJiri Benc 	/* Fragment table for host-based reassembly */
514f0706e82SJiri Benc 	struct ieee80211_fragment_entry	fragments[IEEE80211_FRAGMENT_MAX];
515f0706e82SJiri Benc 	unsigned int fragment_next;
516f0706e82SJiri Benc 
517f0706e82SJiri Benc #define NUM_DEFAULT_KEYS 4
5183cfcf6acSJouni Malinen #define NUM_DEFAULT_MGMT_KEYS 2
5193cfcf6acSJouni Malinen 	struct ieee80211_key *keys[NUM_DEFAULT_KEYS + NUM_DEFAULT_MGMT_KEYS];
520f0706e82SJiri Benc 	struct ieee80211_key *default_key;
5213cfcf6acSJouni Malinen 	struct ieee80211_key *default_mgmt_key;
522f0706e82SJiri Benc 
52394778280SJohannes Berg 	u16 sequence_number;
524a621fa4dSJohannes Berg 	__be16 control_port_protocol;
525a621fa4dSJohannes Berg 	bool control_port_no_encrypt;
52694778280SJohannes Berg 
52764592c8fSJohannes Berg 	struct work_struct work;
52835f20c14SJohannes Berg 	struct sk_buff_head skb_queue;
52935f20c14SJohannes Berg 
53068542962SJuuso Oikarinen 	bool arp_filter_state;
53168542962SJuuso Oikarinen 
5323e122be0SJohannes Berg 	/*
5333e122be0SJohannes Berg 	 * AP this belongs to: self in AP mode and
5343e122be0SJohannes Berg 	 * corresponding AP in VLAN mode, NULL for
5353e122be0SJohannes Berg 	 * all others (might be needed later in IBSS)
5363e122be0SJohannes Berg 	 */
5373e122be0SJohannes Berg 	struct ieee80211_if_ap *bss;
5383e122be0SJohannes Berg 
53937eb0b16SJouni Malinen 	/* bitmap of allowed (non-MCS) rate indexes for rate control */
54037eb0b16SJouni Malinen 	u32 rc_rateidx_mask[IEEE80211_NUM_BANDS];
541f0706e82SJiri Benc 
542f0706e82SJiri Benc 	union {
543f0706e82SJiri Benc 		struct ieee80211_if_ap ap;
544f0706e82SJiri Benc 		struct ieee80211_if_wds wds;
545f0706e82SJiri Benc 		struct ieee80211_if_vlan vlan;
54646900298SJohannes Berg 		struct ieee80211_if_managed mgd;
54746900298SJohannes Berg 		struct ieee80211_if_ibss ibss;
548472dbc45SJohannes Berg #ifdef CONFIG_MAC80211_MESH
549472dbc45SJohannes Berg 		struct ieee80211_if_mesh mesh;
550472dbc45SJohannes Berg #endif
5518cc9a739SMichael Wu 		u32 mntr_flags;
552f0706e82SJiri Benc 	} u;
553e9f207f0SJiri Benc 
554e9f207f0SJiri Benc #ifdef CONFIG_MAC80211_DEBUGFS
555e9f207f0SJiri Benc 	struct {
5567bcfaf2fSJohannes Berg 		struct dentry *dir;
5572b58b209SJouni Malinen 		struct dentry *default_key;
5583cfcf6acSJouni Malinen 		struct dentry *default_mgmt_key;
5597bcfaf2fSJohannes Berg 	} debugfs;
560e9f207f0SJiri Benc #endif
56132bfd35dSJohannes Berg 	/* must be last, dynamically sized area in this! */
56232bfd35dSJohannes Berg 	struct ieee80211_vif vif;
563f0706e82SJiri Benc };
564f0706e82SJiri Benc 
56532bfd35dSJohannes Berg static inline
56632bfd35dSJohannes Berg struct ieee80211_sub_if_data *vif_to_sdata(struct ieee80211_vif *p)
56732bfd35dSJohannes Berg {
56832bfd35dSJohannes Berg 	return container_of(p, struct ieee80211_sub_if_data, vif);
56932bfd35dSJohannes Berg }
57032bfd35dSJohannes Berg 
571472dbc45SJohannes Berg static inline void
572472dbc45SJohannes Berg ieee80211_sdata_set_mesh_id(struct ieee80211_sub_if_data *sdata,
573472dbc45SJohannes Berg 			    u8 mesh_id_len, u8 *mesh_id)
574472dbc45SJohannes Berg {
575472dbc45SJohannes Berg #ifdef CONFIG_MAC80211_MESH
576472dbc45SJohannes Berg 	struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
577472dbc45SJohannes Berg 	ifmsh->mesh_id_len = mesh_id_len;
578472dbc45SJohannes Berg 	memcpy(ifmsh->mesh_id, mesh_id, mesh_id_len);
579472dbc45SJohannes Berg #else
580472dbc45SJohannes Berg 	WARN_ON(1);
581472dbc45SJohannes Berg #endif
582472dbc45SJohannes Berg }
583472dbc45SJohannes Berg 
584c1475ca9SJohannes Berg enum sdata_queue_type {
585c1475ca9SJohannes Berg 	IEEE80211_SDATA_QUEUE_TYPE_FRAME	= 0,
586c1475ca9SJohannes Berg 	IEEE80211_SDATA_QUEUE_AGG_START		= 1,
587c1475ca9SJohannes Berg 	IEEE80211_SDATA_QUEUE_AGG_STOP		= 2,
588c1475ca9SJohannes Berg };
589c1475ca9SJohannes Berg 
590f0706e82SJiri Benc enum {
591f0706e82SJiri Benc 	IEEE80211_RX_MSG	= 1,
592f0706e82SJiri Benc 	IEEE80211_TX_STATUS_MSG	= 2,
593f0706e82SJiri Benc };
594f0706e82SJiri Benc 
595ce7c9111SKalle Valo enum queue_stop_reason {
596ce7c9111SKalle Valo 	IEEE80211_QUEUE_STOP_REASON_DRIVER,
597520eb820SKalle Valo 	IEEE80211_QUEUE_STOP_REASON_PS,
59896f5e66eSJohannes Berg 	IEEE80211_QUEUE_STOP_REASON_CSA,
59996f5e66eSJohannes Berg 	IEEE80211_QUEUE_STOP_REASON_AGGREGATION,
60025420604SJohannes Berg 	IEEE80211_QUEUE_STOP_REASON_SUSPEND,
6018f77f384SJohannes Berg 	IEEE80211_QUEUE_STOP_REASON_SKB_ADD,
602ce7c9111SKalle Valo };
603ce7c9111SKalle Valo 
604142b9f50SHelmut Schaa /**
605142b9f50SHelmut Schaa  * mac80211 scan flags - currently active scan mode
606142b9f50SHelmut Schaa  *
607142b9f50SHelmut Schaa  * @SCAN_SW_SCANNING: We're currently in the process of scanning but may as
608142b9f50SHelmut Schaa  *	well be on the operating channel
609142b9f50SHelmut Schaa  * @SCAN_HW_SCANNING: The hardware is scanning for us, we have no way to
610142b9f50SHelmut Schaa  *	determine if we are on the operating channel or not
611142b9f50SHelmut Schaa  * @SCAN_OFF_CHANNEL: We're off our operating channel for scanning,
612142b9f50SHelmut Schaa  *	gets only set in conjunction with SCAN_SW_SCANNING
6138789d459SJohannes Berg  * @SCAN_COMPLETED: Set for our scan work function when the driver reported
6148789d459SJohannes Berg  *	that the scan completed.
6158789d459SJohannes Berg  * @SCAN_ABORTED: Set for our scan work function when the driver reported
6168789d459SJohannes Berg  *	a scan complete for an aborted scan.
617142b9f50SHelmut Schaa  */
618fbe9c429SHelmut Schaa enum {
619fbe9c429SHelmut Schaa 	SCAN_SW_SCANNING,
620142b9f50SHelmut Schaa 	SCAN_HW_SCANNING,
621142b9f50SHelmut Schaa 	SCAN_OFF_CHANNEL,
6228789d459SJohannes Berg 	SCAN_COMPLETED,
6238789d459SJohannes Berg 	SCAN_ABORTED,
624142b9f50SHelmut Schaa };
625142b9f50SHelmut Schaa 
626142b9f50SHelmut Schaa /**
627142b9f50SHelmut Schaa  * enum mac80211_scan_state - scan state machine states
628142b9f50SHelmut Schaa  *
629142b9f50SHelmut Schaa  * @SCAN_DECISION: Main entry point to the scan state machine, this state
630142b9f50SHelmut Schaa  *	determines if we should keep on scanning or switch back to the
631142b9f50SHelmut Schaa  *	operating channel
632142b9f50SHelmut Schaa  * @SCAN_SET_CHANNEL: Set the next channel to be scanned
633142b9f50SHelmut Schaa  * @SCAN_SEND_PROBE: Send probe requests and wait for probe responses
634142b9f50SHelmut Schaa  * @SCAN_LEAVE_OPER_CHANNEL: Leave the operating channel, notify the AP
635142b9f50SHelmut Schaa  *	about us leaving the channel and stop all associated STA interfaces
636142b9f50SHelmut Schaa  * @SCAN_ENTER_OPER_CHANNEL: Enter the operating channel again, notify the
637142b9f50SHelmut Schaa  *	AP about us being back and restart all associated STA interfaces
638142b9f50SHelmut Schaa  */
639142b9f50SHelmut Schaa enum mac80211_scan_state {
640142b9f50SHelmut Schaa 	SCAN_DECISION,
641142b9f50SHelmut Schaa 	SCAN_SET_CHANNEL,
642142b9f50SHelmut Schaa 	SCAN_SEND_PROBE,
643142b9f50SHelmut Schaa 	SCAN_LEAVE_OPER_CHANNEL,
644142b9f50SHelmut Schaa 	SCAN_ENTER_OPER_CHANNEL,
645fbe9c429SHelmut Schaa };
646fbe9c429SHelmut Schaa 
647f0706e82SJiri Benc struct ieee80211_local {
648f0706e82SJiri Benc 	/* embed the driver visible part.
649f0706e82SJiri Benc 	 * don't cast (use the static inlines below), but we keep
650f0706e82SJiri Benc 	 * it first anyway so they become a no-op */
651f0706e82SJiri Benc 	struct ieee80211_hw hw;
652f0706e82SJiri Benc 
653f0706e82SJiri Benc 	const struct ieee80211_ops *ops;
654f0706e82SJiri Benc 
65542935ecaSLuis R. Rodriguez 	/*
656af6b6374SJohannes Berg 	 * work stuff, potentially off-channel (in the future)
657af6b6374SJohannes Berg 	 */
658af6b6374SJohannes Berg 	struct list_head work_list;
659af6b6374SJohannes Berg 	struct timer_list work_timer;
660af6b6374SJohannes Berg 	struct work_struct work_work;
661af6b6374SJohannes Berg 	struct sk_buff_head work_skb_queue;
662af6b6374SJohannes Berg 
663af6b6374SJohannes Berg 	/*
66442935ecaSLuis R. Rodriguez 	 * private workqueue to mac80211. mac80211 makes this accessible
66542935ecaSLuis R. Rodriguez 	 * via ieee80211_queue_work()
66642935ecaSLuis R. Rodriguez 	 */
66742935ecaSLuis R. Rodriguez 	struct workqueue_struct *workqueue;
66842935ecaSLuis R. Rodriguez 
669e4e72fb4SJohannes Berg 	unsigned long queue_stop_reasons[IEEE80211_MAX_QUEUES];
67096f5e66eSJohannes Berg 	/* also used to protect ampdu_ac_queue and amdpu_ac_stop_refcnt */
671ce7c9111SKalle Valo 	spinlock_t queue_stop_reason_lock;
67296f5e66eSJohannes Berg 
673f0706e82SJiri Benc 	int open_count;
6743d30d949SMichael Wu 	int monitors, cooked_mntrs;
6758cc9a739SMichael Wu 	/* number of interfaces with corresponding FIF_ flags */
676e3b90ca2SIgor Perminov 	int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss, fif_pspoll;
6774150c572SJohannes Berg 	unsigned int filter_flags; /* FIF_* */
6783b8d81e0SJohannes Berg 
6793ffc2a90SJohannes Berg 	bool wiphy_ciphers_allocated;
6803ffc2a90SJohannes Berg 
6813b8d81e0SJohannes Berg 	/* protects the aggregated multicast list and filter calls */
6823b8d81e0SJohannes Berg 	spinlock_t filter_lock;
6833b8d81e0SJohannes Berg 
6843ac64beeSJohannes Berg 	/* used for uploading changed mc list */
6853ac64beeSJohannes Berg 	struct work_struct reconfig_filter;
6863ac64beeSJohannes Berg 
6870f78231bSJohannes Berg 	/* used to reconfigure hardware SM PS */
6880f78231bSJohannes Berg 	struct work_struct recalc_smps;
6890f78231bSJohannes Berg 
6903b8d81e0SJohannes Berg 	/* aggregated multicast list */
69122bedad3SJiri Pirko 	struct netdev_hw_addr_list mc_list;
6923b8d81e0SJohannes Berg 
693d0709a65SJohannes Berg 	bool tim_in_locked_section; /* see ieee80211_beacon_get() */
6945bb644a0SJohannes Berg 
6955bb644a0SJohannes Berg 	/*
6965bb644a0SJohannes Berg 	 * suspended is true if we finished all the suspend _and_ we have
6975bb644a0SJohannes Berg 	 * not yet come up from resume. This is to be used by mac80211
6985bb644a0SJohannes Berg 	 * to ensure driver sanity during suspend and mac80211's own
6995bb644a0SJohannes Berg 	 * sanity. It can eventually be used for WoW as well.
7005bb644a0SJohannes Berg 	 */
7015bb644a0SJohannes Berg 	bool suspended;
7025bb644a0SJohannes Berg 
7035bb644a0SJohannes Berg 	/*
704ceb99fe0SJohannes Berg 	 * Resuming is true while suspended, but when we're reprogramming the
705ceb99fe0SJohannes Berg 	 * hardware -- at that time it's allowed to use ieee80211_queue_work()
706ceb99fe0SJohannes Berg 	 * again even though some other parts of the stack are still suspended
707ceb99fe0SJohannes Berg 	 * and we still drop received frames to avoid waking the stack.
708ceb99fe0SJohannes Berg 	 */
709ceb99fe0SJohannes Berg 	bool resuming;
710ceb99fe0SJohannes Berg 
711ceb99fe0SJohannes Berg 	/*
7125bb644a0SJohannes Berg 	 * quiescing is true during the suspend process _only_ to
7135bb644a0SJohannes Berg 	 * ease timer cancelling etc.
7145bb644a0SJohannes Berg 	 */
7155bb644a0SJohannes Berg 	bool quiescing;
7165bb644a0SJohannes Berg 
717ea77f12fSJohannes Berg 	/* device is started */
718ea77f12fSJohannes Berg 	bool started;
719ea77f12fSJohannes Berg 
720b306f453SJohannes Berg 	int tx_headroom; /* required headroom for hardware/radiotap */
721f0706e82SJiri Benc 
722f0706e82SJiri Benc 	/* Tasklet and skb queue to process calls from IRQ mode. All frames
723f0706e82SJiri Benc 	 * added to skb_queue will be processed, but frames in
724f0706e82SJiri Benc 	 * skb_queue_unreliable may be dropped if the total length of these
725f0706e82SJiri Benc 	 * queues increases over the limit. */
726f0706e82SJiri Benc #define IEEE80211_IRQSAFE_QUEUE_LIMIT 128
727f0706e82SJiri Benc 	struct tasklet_struct tasklet;
728f0706e82SJiri Benc 	struct sk_buff_head skb_queue;
729f0706e82SJiri Benc 	struct sk_buff_head skb_queue_unreliable;
730f0706e82SJiri Benc 
731d0709a65SJohannes Berg 	/* Station data */
732d0709a65SJohannes Berg 	/*
73334e89507SJohannes Berg 	 * The mutex only protects the list and counter,
73434e89507SJohannes Berg 	 * reads are done in RCU.
73534e89507SJohannes Berg 	 * Additionally, the lock protects the hash table,
73634e89507SJohannes Berg 	 * the pending list and each BSS's TIM bitmap.
737d0709a65SJohannes Berg 	 */
73834e89507SJohannes Berg 	struct mutex sta_mtx;
739d0709a65SJohannes Berg 	spinlock_t sta_lock;
740d0709a65SJohannes Berg 	unsigned long num_sta;
74134e89507SJohannes Berg 	struct list_head sta_list, sta_pending_list;
742f0706e82SJiri Benc 	struct sta_info *sta_hash[STA_HASH_SIZE];
743f0706e82SJiri Benc 	struct timer_list sta_cleanup;
74434e89507SJohannes Berg 	struct work_struct sta_finish_work;
745f5ea9120SJohannes Berg 	int sta_generation;
746f0706e82SJiri Benc 
7472a577d98SJohannes Berg 	struct sk_buff_head pending[IEEE80211_MAX_QUEUES];
748f0706e82SJiri Benc 	struct tasklet_struct tx_pending_tasklet;
749f0706e82SJiri Benc 
750a6a67db2SJohannes Berg 	atomic_t agg_queue_stop[IEEE80211_MAX_QUEUES];
751cd8ffc80SJohannes Berg 
752f0706e82SJiri Benc 	/* number of interfaces with corresponding IFF_ flags */
75353918994SJohannes Berg 	atomic_t iff_allmultis, iff_promiscs;
754f0706e82SJiri Benc 
755f0706e82SJiri Benc 	struct rate_control_ref *rate_ctrl;
756f0706e82SJiri Benc 
757f0706e82SJiri Benc 	struct crypto_blkcipher *wep_tx_tfm;
758f0706e82SJiri Benc 	struct crypto_blkcipher *wep_rx_tfm;
759f0706e82SJiri Benc 	u32 wep_iv;
760f0706e82SJiri Benc 
761c771c9d8SJohannes Berg 	/* see iface.c */
76279010420SJohannes Berg 	struct list_head interfaces;
763c771c9d8SJohannes Berg 	struct mutex iflist_mtx;
76479010420SJohannes Berg 
765b16bd15cSJohannes Berg 	/*
766ad0e2b5aSJohannes Berg 	 * Key mutex, protects sdata's key_list and sta_info's
767b16bd15cSJohannes Berg 	 * key pointers (write access, they're RCU.)
768b16bd15cSJohannes Berg 	 */
769ad0e2b5aSJohannes Berg 	struct mutex key_mtx;
770b16bd15cSJohannes Berg 
771a1699b75SJohannes Berg 	/* mutex for scan and work locking */
772a1699b75SJohannes Berg 	struct mutex mtx;
773b16bd15cSJohannes Berg 
774c2b13452SJohannes Berg 	/* Scanning and BSS list */
775fbe9c429SHelmut Schaa 	unsigned long scanning;
7762a519311SJohannes Berg 	struct cfg80211_ssid scan_ssid;
7775ba63533SJohannes Berg 	struct cfg80211_scan_request *int_scan_req;
7784d36ec58SJohannes Berg 	struct cfg80211_scan_request *scan_req, *hw_scan_req;
7792a519311SJohannes Berg 	struct ieee80211_channel *scan_channel;
7804d36ec58SJohannes Berg 	enum ieee80211_band hw_scan_band;
781f0706e82SJiri Benc 	int scan_channel_idx;
782de95a54bSJohannes Berg 	int scan_ies_len;
7838318d78aSJohannes Berg 
784df13cce5SHelmut Schaa 	unsigned long leave_oper_channel_time;
785977923b0SHelmut Schaa 	enum mac80211_scan_state next_scan_state;
786f0706e82SJiri Benc 	struct delayed_work scan_work;
787491775a5SJohannes Berg 	struct ieee80211_sub_if_data *scan_sdata;
7880aaffa9bSJohannes Berg 	enum nl80211_channel_type _oper_channel_type;
7892a519311SJohannes Berg 	struct ieee80211_channel *oper_channel, *csa_channel;
790f0706e82SJiri Benc 
791b8bc4b0aSJohannes Berg 	/* Temporary remain-on-channel for off-channel operations */
792b8bc4b0aSJohannes Berg 	struct ieee80211_channel *tmp_channel;
793b8bc4b0aSJohannes Berg 	enum nl80211_channel_type tmp_channel_type;
794b8bc4b0aSJohannes Berg 
795f0706e82SJiri Benc 	/* SNMP counters */
796f0706e82SJiri Benc 	/* dot11CountersTable */
797f0706e82SJiri Benc 	u32 dot11TransmittedFragmentCount;
798f0706e82SJiri Benc 	u32 dot11MulticastTransmittedFrameCount;
799f0706e82SJiri Benc 	u32 dot11FailedCount;
800f0706e82SJiri Benc 	u32 dot11RetryCount;
801f0706e82SJiri Benc 	u32 dot11MultipleRetryCount;
802f0706e82SJiri Benc 	u32 dot11FrameDuplicateCount;
803f0706e82SJiri Benc 	u32 dot11ReceivedFragmentCount;
804f0706e82SJiri Benc 	u32 dot11MulticastReceivedFrameCount;
805f0706e82SJiri Benc 	u32 dot11TransmittedFrameCount;
806f0706e82SJiri Benc 
807f0706e82SJiri Benc #ifdef CONFIG_MAC80211_LEDS
808f0706e82SJiri Benc 	int tx_led_counter, rx_led_counter;
809cdcb006fSIvo van Doorn 	struct led_trigger *tx_led, *rx_led, *assoc_led, *radio_led;
810cdcb006fSIvo van Doorn 	char tx_led_name[32], rx_led_name[32],
811cdcb006fSIvo van Doorn 	     assoc_led_name[32], radio_led_name[32];
812f0706e82SJiri Benc #endif
813f0706e82SJiri Benc 
814f0706e82SJiri Benc #ifdef CONFIG_MAC80211_DEBUG_COUNTERS
815f0706e82SJiri Benc 	/* TX/RX handler statistics */
816f0706e82SJiri Benc 	unsigned int tx_handlers_drop;
817f0706e82SJiri Benc 	unsigned int tx_handlers_queued;
818f0706e82SJiri Benc 	unsigned int tx_handlers_drop_unencrypted;
819f0706e82SJiri Benc 	unsigned int tx_handlers_drop_fragment;
820f0706e82SJiri Benc 	unsigned int tx_handlers_drop_wep;
821f0706e82SJiri Benc 	unsigned int tx_handlers_drop_not_assoc;
822f0706e82SJiri Benc 	unsigned int tx_handlers_drop_unauth_port;
823f0706e82SJiri Benc 	unsigned int rx_handlers_drop;
824f0706e82SJiri Benc 	unsigned int rx_handlers_queued;
825f0706e82SJiri Benc 	unsigned int rx_handlers_drop_nullfunc;
826f0706e82SJiri Benc 	unsigned int rx_handlers_drop_defrag;
827f0706e82SJiri Benc 	unsigned int rx_handlers_drop_short;
828f0706e82SJiri Benc 	unsigned int rx_handlers_drop_passive_scan;
829f0706e82SJiri Benc 	unsigned int tx_expand_skb_head;
830f0706e82SJiri Benc 	unsigned int tx_expand_skb_head_cloned;
831f0706e82SJiri Benc 	unsigned int rx_expand_skb_head;
832f0706e82SJiri Benc 	unsigned int rx_expand_skb_head2;
833f0706e82SJiri Benc 	unsigned int rx_handlers_fragments;
834f0706e82SJiri Benc 	unsigned int tx_status_drop;
835f0706e82SJiri Benc #define I802_DEBUG_INC(c) (c)++
836f0706e82SJiri Benc #else /* CONFIG_MAC80211_DEBUG_COUNTERS */
837f0706e82SJiri Benc #define I802_DEBUG_INC(c) do { } while (0)
838f0706e82SJiri Benc #endif /* CONFIG_MAC80211_DEBUG_COUNTERS */
839f0706e82SJiri Benc 
840f0706e82SJiri Benc 
841f0706e82SJiri Benc 	int total_ps_buffered; /* total number of all buffered unicast and
842f0706e82SJiri Benc 				* multicast packets for power saving stations
843f0706e82SJiri Benc 				*/
844f0706e82SJiri Benc 	int wifi_wme_noack_test;
845f0706e82SJiri Benc 	unsigned int wmm_acm; /* bit field of ACM bits (BIT(802.1D tag)) */
846520eb820SKalle Valo 
84750ae0cf1SKalle Valo 	/*
84850ae0cf1SKalle Valo 	 * Bitmask of enabled u-apsd queues,
84950ae0cf1SKalle Valo 	 * IEEE80211_WMM_IE_STA_QOSINFO_AC_BE & co. Needs a new association
85050ae0cf1SKalle Valo 	 * to take effect.
85150ae0cf1SKalle Valo 	 */
85250ae0cf1SKalle Valo 	unsigned int uapsd_queues;
85350ae0cf1SKalle Valo 
85450ae0cf1SKalle Valo 	/*
85550ae0cf1SKalle Valo 	 * Maximum number of buffered frames AP can deliver during a
85650ae0cf1SKalle Valo 	 * service period, IEEE80211_WMM_IE_STA_QOSINFO_SP_ALL or similar.
85750ae0cf1SKalle Valo 	 * Needs a new association to take effect.
85850ae0cf1SKalle Valo 	 */
85950ae0cf1SKalle Valo 	unsigned int uapsd_max_sp_len;
86050ae0cf1SKalle Valo 
861572e0012SKalle Valo 	bool pspolling;
862b203ffc3SJouni Malinen 	bool offchannel_ps_enabled;
863965bedadSJohannes Berg 	/*
864965bedadSJohannes Berg 	 * PS can only be enabled when we have exactly one managed
865965bedadSJohannes Berg 	 * interface (and monitors) in PS, this then points there.
866965bedadSJohannes Berg 	 */
867965bedadSJohannes Berg 	struct ieee80211_sub_if_data *ps_sdata;
868520eb820SKalle Valo 	struct work_struct dynamic_ps_enable_work;
869520eb820SKalle Valo 	struct work_struct dynamic_ps_disable_work;
870520eb820SKalle Valo 	struct timer_list dynamic_ps_timer;
87110f644a4SJohannes Berg 	struct notifier_block network_latency_notifier;
8722b2c009eSJuuso Oikarinen 	struct notifier_block ifa_notifier;
873f0706e82SJiri Benc 
874ff616381SJuuso Oikarinen 	/*
875ff616381SJuuso Oikarinen 	 * The dynamic ps timeout configured from user space via WEXT -
876ff616381SJuuso Oikarinen 	 * this will override whatever chosen by mac80211 internally.
877ff616381SJuuso Oikarinen 	 */
878ff616381SJuuso Oikarinen 	int dynamic_ps_forced_timeout;
879f90754c1SJuuso Oikarinen 	int dynamic_ps_user_timeout;
880f90754c1SJuuso Oikarinen 	bool disable_dynamic_ps;
881ff616381SJuuso Oikarinen 
8822bf30fabSJohannes Berg 	int user_power_level; /* in dBm */
883a8302de9SVasanthakumar Thiagarajan 	int power_constr_level; /* in dBm */
8842bf30fabSJohannes Berg 
8850f78231bSJohannes Berg 	enum ieee80211_smps_mode smps_mode;
8860f78231bSJohannes Berg 
887f2753ddbSJohannes Berg 	struct work_struct restart_work;
888f2753ddbSJohannes Berg 
889e9f207f0SJiri Benc #ifdef CONFIG_MAC80211_DEBUGFS
890e9f207f0SJiri Benc 	struct local_debugfsdentries {
8914b7679a5SJohannes Berg 		struct dentry *rcdir;
892e9f207f0SJiri Benc 		struct dentry *stations;
893e9f207f0SJiri Benc 		struct dentry *keys;
894e9f207f0SJiri Benc 	} debugfs;
895e9f207f0SJiri Benc #endif
8964e6cbfd0SJohn W. Linville 
8974e6cbfd0SJohn W. Linville 	/* dummy netdev for use w/ NAPI */
8984e6cbfd0SJohn W. Linville 	struct net_device napi_dev;
8994e6cbfd0SJohn W. Linville 
9004e6cbfd0SJohn W. Linville 	struct napi_struct napi;
901f0706e82SJiri Benc };
902f0706e82SJiri Benc 
9033e122be0SJohannes Berg static inline struct ieee80211_sub_if_data *
9043e122be0SJohannes Berg IEEE80211_DEV_TO_SUB_IF(struct net_device *dev)
9053e122be0SJohannes Berg {
9063e122be0SJohannes Berg 	return netdev_priv(dev);
9073e122be0SJohannes Berg }
9083e122be0SJohannes Berg 
909c1475ca9SJohannes Berg /* this struct represents 802.11n's RA/TID combination */
910eadc8d9eSRon Rindjunsky struct ieee80211_ra_tid {
911eadc8d9eSRon Rindjunsky 	u8 ra[ETH_ALEN];
912eadc8d9eSRon Rindjunsky 	u16 tid;
913eadc8d9eSRon Rindjunsky };
914eadc8d9eSRon Rindjunsky 
915ee385855SLuis Carlos Cobo /* Parsed Information Elements */
916ee385855SLuis Carlos Cobo struct ieee802_11_elems {
91743ac2ca3SJouni Malinen 	u8 *ie_start;
91843ac2ca3SJouni Malinen 	size_t total_len;
91943ac2ca3SJouni Malinen 
920ee385855SLuis Carlos Cobo 	/* pointers to IEs */
921ee385855SLuis Carlos Cobo 	u8 *ssid;
922ee385855SLuis Carlos Cobo 	u8 *supp_rates;
923ee385855SLuis Carlos Cobo 	u8 *fh_params;
924ee385855SLuis Carlos Cobo 	u8 *ds_params;
925ee385855SLuis Carlos Cobo 	u8 *cf_params;
926e7ec86f5SJohannes Berg 	struct ieee80211_tim_ie *tim;
927ee385855SLuis Carlos Cobo 	u8 *ibss_params;
928ee385855SLuis Carlos Cobo 	u8 *challenge;
929ee385855SLuis Carlos Cobo 	u8 *wpa;
930ee385855SLuis Carlos Cobo 	u8 *rsn;
931ee385855SLuis Carlos Cobo 	u8 *erp_info;
932ee385855SLuis Carlos Cobo 	u8 *ext_supp_rates;
933ee385855SLuis Carlos Cobo 	u8 *wmm_info;
934ee385855SLuis Carlos Cobo 	u8 *wmm_param;
93509914813SJohannes Berg 	struct ieee80211_ht_cap *ht_cap_elem;
936d9fe60deSJohannes Berg 	struct ieee80211_ht_info *ht_info_elem;
937136cfa28SRui Paulo 	struct ieee80211_meshconf_ie *mesh_config;
938ee385855SLuis Carlos Cobo 	u8 *mesh_id;
939ee385855SLuis Carlos Cobo 	u8 *peer_link;
940ee385855SLuis Carlos Cobo 	u8 *preq;
941ee385855SLuis Carlos Cobo 	u8 *prep;
942ee385855SLuis Carlos Cobo 	u8 *perr;
94390a5e169SRui Paulo 	struct ieee80211_rann_ie *rann;
944f2df3859SAssaf Krauss 	u8 *ch_switch_elem;
945f2df3859SAssaf Krauss 	u8 *country_elem;
946f2df3859SAssaf Krauss 	u8 *pwr_constr_elem;
947f2df3859SAssaf Krauss 	u8 *quiet_elem; 	/* first quite element */
948f797eb7eSJouni Malinen 	u8 *timeout_int;
949ee385855SLuis Carlos Cobo 
950ee385855SLuis Carlos Cobo 	/* length of them, respectively */
951ee385855SLuis Carlos Cobo 	u8 ssid_len;
952ee385855SLuis Carlos Cobo 	u8 supp_rates_len;
953ee385855SLuis Carlos Cobo 	u8 fh_params_len;
954ee385855SLuis Carlos Cobo 	u8 ds_params_len;
955ee385855SLuis Carlos Cobo 	u8 cf_params_len;
956ee385855SLuis Carlos Cobo 	u8 tim_len;
957ee385855SLuis Carlos Cobo 	u8 ibss_params_len;
958ee385855SLuis Carlos Cobo 	u8 challenge_len;
959ee385855SLuis Carlos Cobo 	u8 wpa_len;
960ee385855SLuis Carlos Cobo 	u8 rsn_len;
961ee385855SLuis Carlos Cobo 	u8 erp_info_len;
962ee385855SLuis Carlos Cobo 	u8 ext_supp_rates_len;
963ee385855SLuis Carlos Cobo 	u8 wmm_info_len;
964ee385855SLuis Carlos Cobo 	u8 wmm_param_len;
965ee385855SLuis Carlos Cobo 	u8 mesh_id_len;
966ee385855SLuis Carlos Cobo 	u8 peer_link_len;
967ee385855SLuis Carlos Cobo 	u8 preq_len;
968ee385855SLuis Carlos Cobo 	u8 prep_len;
969ee385855SLuis Carlos Cobo 	u8 perr_len;
970f2df3859SAssaf Krauss 	u8 ch_switch_elem_len;
971f2df3859SAssaf Krauss 	u8 country_elem_len;
972f2df3859SAssaf Krauss 	u8 pwr_constr_elem_len;
973f2df3859SAssaf Krauss 	u8 quiet_elem_len;
974f2df3859SAssaf Krauss 	u8 num_of_quiet_elem;	/* can be more the one */
975f797eb7eSJouni Malinen 	u8 timeout_int_len;
976ee385855SLuis Carlos Cobo };
977ee385855SLuis Carlos Cobo 
978f0706e82SJiri Benc static inline struct ieee80211_local *hw_to_local(
979f0706e82SJiri Benc 	struct ieee80211_hw *hw)
980f0706e82SJiri Benc {
981f0706e82SJiri Benc 	return container_of(hw, struct ieee80211_local, hw);
982f0706e82SJiri Benc }
983f0706e82SJiri Benc 
984f0706e82SJiri Benc static inline struct ieee80211_hw *local_to_hw(
985f0706e82SJiri Benc 	struct ieee80211_local *local)
986f0706e82SJiri Benc {
987f0706e82SJiri Benc 	return &local->hw;
988f0706e82SJiri Benc }
989f0706e82SJiri Benc 
990f0706e82SJiri Benc 
991571ecf67SJohannes Berg static inline int ieee80211_bssid_match(const u8 *raddr, const u8 *addr)
992571ecf67SJohannes Berg {
993571ecf67SJohannes Berg 	return compare_ether_addr(raddr, addr) == 0 ||
994571ecf67SJohannes Berg 	       is_broadcast_ether_addr(raddr);
995571ecf67SJohannes Berg }
996571ecf67SJohannes Berg 
997571ecf67SJohannes Berg 
998e8975581SJohannes Berg int ieee80211_hw_config(struct ieee80211_local *local, u32 changed);
9995cf121c3SJohannes Berg void ieee80211_tx_set_protected(struct ieee80211_tx_data *tx);
10009c6bd790SJohannes Berg void ieee80211_bss_info_change_notify(struct ieee80211_sub_if_data *sdata,
10019c6bd790SJohannes Berg 				      u32 changed);
10020d143fe1SJohannes Berg void ieee80211_configure_filter(struct ieee80211_local *local);
100346900298SJohannes Berg u32 ieee80211_reset_erp_info(struct ieee80211_sub_if_data *sdata);
1004f0706e82SJiri Benc 
1005f38fd12fSJohannes Berg extern bool ieee80211_disable_40mhz_24ghz;
1006f38fd12fSJohannes Berg 
100746900298SJohannes Berg /* STA code */
10089c6bd790SJohannes Berg void ieee80211_sta_setup_sdata(struct ieee80211_sub_if_data *sdata);
100977fdaa12SJohannes Berg int ieee80211_mgd_auth(struct ieee80211_sub_if_data *sdata,
101077fdaa12SJohannes Berg 		       struct cfg80211_auth_request *req);
101177fdaa12SJohannes Berg int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata,
101277fdaa12SJohannes Berg 			struct cfg80211_assoc_request *req);
101377fdaa12SJohannes Berg int ieee80211_mgd_deauth(struct ieee80211_sub_if_data *sdata,
1014667503ddSJohannes Berg 			 struct cfg80211_deauth_request *req,
1015667503ddSJohannes Berg 			 void *cookie);
101677fdaa12SJohannes Berg int ieee80211_mgd_disassoc(struct ieee80211_sub_if_data *sdata,
1017667503ddSJohannes Berg 			   struct cfg80211_disassoc_request *req,
1018667503ddSJohannes Berg 			   void *cookie);
1019572e0012SKalle Valo void ieee80211_send_pspoll(struct ieee80211_local *local,
1020572e0012SKalle Valo 			   struct ieee80211_sub_if_data *sdata);
102110f644a4SJohannes Berg void ieee80211_recalc_ps(struct ieee80211_local *local, s32 latency);
102210f644a4SJohannes Berg int ieee80211_max_network_latency(struct notifier_block *nb,
102310f644a4SJohannes Berg 				  unsigned long data, void *dummy);
10242b2c009eSJuuso Oikarinen int ieee80211_set_arp_filter(struct ieee80211_sub_if_data *sdata);
1025cc32abd4SJohannes Berg void ieee80211_sta_process_chanswitch(struct ieee80211_sub_if_data *sdata,
1026cc32abd4SJohannes Berg 				      struct ieee80211_channel_sw_ie *sw_elem,
10275ce6e438SJohannes Berg 				      struct ieee80211_bss *bss,
10285ce6e438SJohannes Berg 				      u64 timestamp);
10295bb644a0SJohannes Berg void ieee80211_sta_quiesce(struct ieee80211_sub_if_data *sdata);
10305bb644a0SJohannes Berg void ieee80211_sta_restart(struct ieee80211_sub_if_data *sdata);
10311fa57d01SJohannes Berg void ieee80211_sta_work(struct ieee80211_sub_if_data *sdata);
10321fa57d01SJohannes Berg void ieee80211_sta_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
10331fa57d01SJohannes Berg 				  struct sk_buff *skb);
10349c6bd790SJohannes Berg 
103546900298SJohannes Berg /* IBSS code */
103646900298SJohannes Berg void ieee80211_ibss_notify_scan_completed(struct ieee80211_local *local);
103746900298SJohannes Berg void ieee80211_ibss_setup_sdata(struct ieee80211_sub_if_data *sdata);
103846900298SJohannes Berg struct sta_info *ieee80211_ibss_add_sta(struct ieee80211_sub_if_data *sdata,
103934e89507SJohannes Berg 					u8 *bssid, u8 *addr, u32 supp_rates,
104034e89507SJohannes Berg 					gfp_t gfp);
1041af8cdcd8SJohannes Berg int ieee80211_ibss_join(struct ieee80211_sub_if_data *sdata,
1042af8cdcd8SJohannes Berg 			struct cfg80211_ibss_params *params);
1043af8cdcd8SJohannes Berg int ieee80211_ibss_leave(struct ieee80211_sub_if_data *sdata);
10445bb644a0SJohannes Berg void ieee80211_ibss_quiesce(struct ieee80211_sub_if_data *sdata);
10455bb644a0SJohannes Berg void ieee80211_ibss_restart(struct ieee80211_sub_if_data *sdata);
10461fa57d01SJohannes Berg void ieee80211_ibss_work(struct ieee80211_sub_if_data *sdata);
10471fa57d01SJohannes Berg void ieee80211_ibss_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
10481fa57d01SJohannes Berg 				   struct sk_buff *skb);
10491fa57d01SJohannes Berg 
10501fa57d01SJohannes Berg /* mesh code */
10511fa57d01SJohannes Berg void ieee80211_mesh_work(struct ieee80211_sub_if_data *sdata);
10521fa57d01SJohannes Berg void ieee80211_mesh_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
10531fa57d01SJohannes Berg 				   struct sk_buff *skb);
105446900298SJohannes Berg 
10559c6bd790SJohannes Berg /* scan/BSS handling */
105646900298SJohannes Berg void ieee80211_scan_work(struct work_struct *work);
1057f3b85252SJohannes Berg int ieee80211_request_internal_scan(struct ieee80211_sub_if_data *sdata,
1058be4a4b6aSJohannes Berg 				    const u8 *ssid, u8 ssid_len,
1059be4a4b6aSJohannes Berg 				    struct ieee80211_channel *chan);
1060c2b13452SJohannes Berg int ieee80211_request_scan(struct ieee80211_sub_if_data *sdata,
10612a519311SJohannes Berg 			   struct cfg80211_scan_request *req);
10625bb644a0SJohannes Berg void ieee80211_scan_cancel(struct ieee80211_local *local);
1063c2b13452SJohannes Berg ieee80211_rx_result
1064f1d58c25SJohannes Berg ieee80211_scan_rx(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb);
10659c6bd790SJohannes Berg 
10660a51b27eSJohannes Berg void ieee80211_mlme_notify_scan_completed(struct ieee80211_local *local);
1067c2b13452SJohannes Berg struct ieee80211_bss *
106898c8fccfSJohannes Berg ieee80211_bss_info_update(struct ieee80211_local *local,
106998c8fccfSJohannes Berg 			  struct ieee80211_rx_status *rx_status,
107098c8fccfSJohannes Berg 			  struct ieee80211_mgmt *mgmt,
107198c8fccfSJohannes Berg 			  size_t len,
107298c8fccfSJohannes Berg 			  struct ieee802_11_elems *elems,
10732a519311SJohannes Berg 			  struct ieee80211_channel *channel,
10742a519311SJohannes Berg 			  bool beacon);
1075c2b13452SJohannes Berg struct ieee80211_bss *
10765484e237SJohannes Berg ieee80211_rx_bss_get(struct ieee80211_local *local, u8 *bssid, int freq,
10775484e237SJohannes Berg 		     u8 *ssid, u8 ssid_len);
107898c8fccfSJohannes Berg void ieee80211_rx_bss_put(struct ieee80211_local *local,
1079c2b13452SJohannes Berg 			  struct ieee80211_bss *bss);
1080ee385855SLuis Carlos Cobo 
1081b203ffc3SJouni Malinen /* off-channel helpers */
1082b203ffc3SJouni Malinen void ieee80211_offchannel_stop_beaconing(struct ieee80211_local *local);
1083b203ffc3SJouni Malinen void ieee80211_offchannel_stop_station(struct ieee80211_local *local);
1084b203ffc3SJouni Malinen void ieee80211_offchannel_return(struct ieee80211_local *local,
1085b203ffc3SJouni Malinen 				 bool enable_beaconing);
1086b203ffc3SJouni Malinen 
10873e122be0SJohannes Berg /* interface handling */
108847846c9bSJohannes Berg int ieee80211_iface_init(void);
108947846c9bSJohannes Berg void ieee80211_iface_exit(void);
10903e122be0SJohannes Berg int ieee80211_if_add(struct ieee80211_local *local, const char *name,
109105c914feSJohannes Berg 		     struct net_device **new_dev, enum nl80211_iftype type,
1092ee385855SLuis Carlos Cobo 		     struct vif_params *params);
1093f3947e2dSJohannes Berg int ieee80211_if_change_type(struct ieee80211_sub_if_data *sdata,
109405c914feSJohannes Berg 			     enum nl80211_iftype type);
1095f698d856SJasper Bryant-Greene void ieee80211_if_remove(struct ieee80211_sub_if_data *sdata);
109675636525SJohannes Berg void ieee80211_remove_interfaces(struct ieee80211_local *local);
10975cff20e6SJohannes Berg u32 __ieee80211_recalc_idle(struct ieee80211_local *local);
10985cff20e6SJohannes Berg void ieee80211_recalc_idle(struct ieee80211_local *local);
1099f0706e82SJiri Benc 
11009607e6b6SJohannes Berg static inline bool ieee80211_sdata_running(struct ieee80211_sub_if_data *sdata)
11019607e6b6SJohannes Berg {
110234d4bc4dSJohannes Berg 	return test_bit(SDATA_STATE_RUNNING, &sdata->state);
11039607e6b6SJohannes Berg }
11049607e6b6SJohannes Berg 
1105e2ebc74dSJohannes Berg /* tx handling */
1106e2ebc74dSJohannes Berg void ieee80211_clear_tx_pending(struct ieee80211_local *local);
1107e2ebc74dSJohannes Berg void ieee80211_tx_pending(unsigned long data);
1108d0cf9c0dSStephen Hemminger netdev_tx_t ieee80211_monitor_start_xmit(struct sk_buff *skb,
1109d0cf9c0dSStephen Hemminger 					 struct net_device *dev);
1110d0cf9c0dSStephen Hemminger netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb,
1111d0cf9c0dSStephen Hemminger 				       struct net_device *dev);
1112e2ebc74dSJohannes Berg 
1113fe7a5d5cSJohannes Berg /*
1114fe7a5d5cSJohannes Berg  * radiotap header for status frames
1115fe7a5d5cSJohannes Berg  */
1116fe7a5d5cSJohannes Berg struct ieee80211_tx_status_rtap_hdr {
1117fe7a5d5cSJohannes Berg 	struct ieee80211_radiotap_header hdr;
1118fe7a5d5cSJohannes Berg 	u8 rate;
1119fe7a5d5cSJohannes Berg 	u8 padding_for_rate;
1120fe7a5d5cSJohannes Berg 	__le16 tx_flags;
1121fe7a5d5cSJohannes Berg 	u8 data_retries;
1122bc10502dSEric Dumazet } __packed;
1123fe7a5d5cSJohannes Berg 
1124fe7a5d5cSJohannes Berg 
1125de1ede7aSJohannes Berg /* HT */
1126ae5eb026SJohannes Berg void ieee80211_ht_cap_ie_to_sta_ht_cap(struct ieee80211_supported_band *sband,
1127ae5eb026SJohannes Berg 				       struct ieee80211_ht_cap *ht_cap_ie,
1128d9fe60deSJohannes Berg 				       struct ieee80211_sta_ht_cap *ht_cap);
1129de1ede7aSJohannes Berg void ieee80211_send_bar(struct ieee80211_sub_if_data *sdata, u8 *ra, u16 tid, u16 ssn);
1130b8695a8fSJohannes Berg void ieee80211_send_delba(struct ieee80211_sub_if_data *sdata,
1131b8695a8fSJohannes Berg 			  const u8 *da, u16 tid,
1132b8695a8fSJohannes Berg 			  u16 initiator, u16 reason_code);
11330f78231bSJohannes Berg int ieee80211_send_smps_action(struct ieee80211_sub_if_data *sdata,
11340f78231bSJohannes Berg 			       enum ieee80211_smps_mode smps, const u8 *da,
11350f78231bSJohannes Berg 			       const u8 *bssid);
1136d1f5b7a3SJohannes Berg void ieee80211_request_smps_work(struct work_struct *work);
1137de1ede7aSJohannes Berg 
11387c3b1dd8SJohannes Berg void ___ieee80211_stop_rx_ba_session(struct sta_info *sta, u16 tid,
11397c3b1dd8SJohannes Berg 				     u16 initiator, u16 reason);
1140849b7967SJohannes Berg void __ieee80211_stop_rx_ba_session(struct sta_info *sta, u16 tid,
1141849b7967SJohannes Berg 				    u16 initiator, u16 reason);
11422dace10eSJohannes Berg void ieee80211_sta_tear_down_BA_sessions(struct sta_info *sta);
1143de1ede7aSJohannes Berg void ieee80211_process_delba(struct ieee80211_sub_if_data *sdata,
1144de1ede7aSJohannes Berg 			     struct sta_info *sta,
1145de1ede7aSJohannes Berg 			     struct ieee80211_mgmt *mgmt, size_t len);
1146de1ede7aSJohannes Berg void ieee80211_process_addba_resp(struct ieee80211_local *local,
1147de1ede7aSJohannes Berg 				  struct sta_info *sta,
1148de1ede7aSJohannes Berg 				  struct ieee80211_mgmt *mgmt,
1149de1ede7aSJohannes Berg 				  size_t len);
1150de1ede7aSJohannes Berg void ieee80211_process_addba_request(struct ieee80211_local *local,
1151de1ede7aSJohannes Berg 				     struct sta_info *sta,
1152de1ede7aSJohannes Berg 				     struct ieee80211_mgmt *mgmt,
1153de1ede7aSJohannes Berg 				     size_t len);
1154de1ede7aSJohannes Berg 
1155849b7967SJohannes Berg int __ieee80211_stop_tx_ba_session(struct sta_info *sta, u16 tid,
1156849b7967SJohannes Berg 				   enum ieee80211_back_parties initiator);
115767c282c0SJohannes Berg int ___ieee80211_stop_tx_ba_session(struct sta_info *sta, u16 tid,
115867c282c0SJohannes Berg 				    enum ieee80211_back_parties initiator);
11595d22c89bSJohannes Berg void ieee80211_start_tx_ba_cb(struct ieee80211_vif *vif, u8 *ra, u16 tid);
11605d22c89bSJohannes Berg void ieee80211_stop_tx_ba_cb(struct ieee80211_vif *vif, u8 *ra, u8 tid);
116167c282c0SJohannes Berg void ieee80211_ba_session_work(struct work_struct *work);
116267c282c0SJohannes Berg void ieee80211_tx_ba_session_handle_start(struct sta_info *sta, int tid);
11632bff8ebfSChristian Lamparter void ieee80211_release_reorder_timeout(struct sta_info *sta, int tid);
1164849b7967SJohannes Berg 
116539192c0bSJohannes Berg /* Spectrum management */
116639192c0bSJohannes Berg void ieee80211_process_measurement_req(struct ieee80211_sub_if_data *sdata,
116739192c0bSJohannes Berg 				       struct ieee80211_mgmt *mgmt,
116839192c0bSJohannes Berg 				       size_t len);
116939192c0bSJohannes Berg 
1170f2753ddbSJohannes Berg /* Suspend/resume and hw reconfiguration */
1171f2753ddbSJohannes Berg int ieee80211_reconfig(struct ieee80211_local *local);
117284f6a01cSJohannes Berg void ieee80211_stop_device(struct ieee80211_local *local);
1173f2753ddbSJohannes Berg 
1174827b1fb4SJohannes Berg #ifdef CONFIG_PM
1175665af4fcSBob Copeland int __ieee80211_suspend(struct ieee80211_hw *hw);
1176f2753ddbSJohannes Berg 
1177f2753ddbSJohannes Berg static inline int __ieee80211_resume(struct ieee80211_hw *hw)
1178f2753ddbSJohannes Berg {
1179f2753ddbSJohannes Berg 	return ieee80211_reconfig(hw_to_local(hw));
1180f2753ddbSJohannes Berg }
1181827b1fb4SJohannes Berg #else
1182827b1fb4SJohannes Berg static inline int __ieee80211_suspend(struct ieee80211_hw *hw)
1183827b1fb4SJohannes Berg {
1184827b1fb4SJohannes Berg 	return 0;
1185827b1fb4SJohannes Berg }
1186f2753ddbSJohannes Berg 
1187827b1fb4SJohannes Berg static inline int __ieee80211_resume(struct ieee80211_hw *hw)
1188827b1fb4SJohannes Berg {
1189827b1fb4SJohannes Berg 	return 0;
1190827b1fb4SJohannes Berg }
1191827b1fb4SJohannes Berg #endif
1192665af4fcSBob Copeland 
1193c2d1560aSJohannes Berg /* utility functions/constants */
1194c2d1560aSJohannes Berg extern void *mac80211_wiphy_privid; /* for wiphy privid */
119571364716SRon Rindjunsky u8 *ieee80211_get_bssid(struct ieee80211_hdr *hdr, size_t len,
119605c914feSJohannes Berg 			enum nl80211_iftype type);
1197c2d1560aSJohannes Berg int ieee80211_frame_duration(struct ieee80211_local *local, size_t len,
1198c2d1560aSJohannes Berg 			     int rate, int erp, int short_preamble);
1199f698d856SJasper Bryant-Greene void mac80211_ev_michael_mic_failure(struct ieee80211_sub_if_data *sdata, int keyidx,
1200e6d6e342SJohannes Berg 				     struct ieee80211_hdr *hdr, const u8 *tsc,
1201e6d6e342SJohannes Berg 				     gfp_t gfp);
12025825fe10SJohannes Berg void ieee80211_set_wmm_default(struct ieee80211_sub_if_data *sdata);
120362ae67beSJohannes Berg void ieee80211_tx_skb(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb);
12049c6bd790SJohannes Berg void ieee802_11_parse_elems(u8 *start, size_t len,
12059c6bd790SJohannes Berg 			    struct ieee802_11_elems *elems);
1206d91f36dbSJohannes Berg u32 ieee802_11_parse_elems_crc(u8 *start, size_t len,
1207d91f36dbSJohannes Berg 			       struct ieee802_11_elems *elems,
1208d91f36dbSJohannes Berg 			       u64 filter, u32 crc);
1209881d948cSJohannes Berg u32 ieee80211_mandatory_rates(struct ieee80211_local *local,
121096dd22acSJohannes Berg 			      enum ieee80211_band band);
1211f0706e82SJiri Benc 
1212520eb820SKalle Valo void ieee80211_dynamic_ps_enable_work(struct work_struct *work);
1213520eb820SKalle Valo void ieee80211_dynamic_ps_disable_work(struct work_struct *work);
1214520eb820SKalle Valo void ieee80211_dynamic_ps_timer(unsigned long data);
1215a97b77b9SVivek Natarajan void ieee80211_send_nullfunc(struct ieee80211_local *local,
1216a97b77b9SVivek Natarajan 			     struct ieee80211_sub_if_data *sdata,
1217a97b77b9SVivek Natarajan 			     int powersave);
12183cf335d5SKalle Valo void ieee80211_sta_rx_notify(struct ieee80211_sub_if_data *sdata,
12193cf335d5SKalle Valo 			     struct ieee80211_hdr *hdr);
12201e4dcd01SJuuso Oikarinen void ieee80211_beacon_connection_loss_work(struct work_struct *work);
1221520eb820SKalle Valo 
1222ce7c9111SKalle Valo void ieee80211_wake_queues_by_reason(struct ieee80211_hw *hw,
1223ce7c9111SKalle Valo 				     enum queue_stop_reason reason);
1224ce7c9111SKalle Valo void ieee80211_stop_queues_by_reason(struct ieee80211_hw *hw,
1225ce7c9111SKalle Valo 				     enum queue_stop_reason reason);
122696f5e66eSJohannes Berg void ieee80211_wake_queue_by_reason(struct ieee80211_hw *hw, int queue,
122796f5e66eSJohannes Berg 				    enum queue_stop_reason reason);
122896f5e66eSJohannes Berg void ieee80211_stop_queue_by_reason(struct ieee80211_hw *hw, int queue,
122996f5e66eSJohannes Berg 				    enum queue_stop_reason reason);
12308f77f384SJohannes Berg void ieee80211_add_pending_skb(struct ieee80211_local *local,
12318f77f384SJohannes Berg 			       struct sk_buff *skb);
12328f77f384SJohannes Berg int ieee80211_add_pending_skbs(struct ieee80211_local *local,
12338f77f384SJohannes Berg 			       struct sk_buff_head *skbs);
1234ce7c9111SKalle Valo 
123546900298SJohannes Berg void ieee80211_send_auth(struct ieee80211_sub_if_data *sdata,
123646900298SJohannes Berg 			 u16 transaction, u16 auth_alg,
1237fffd0934SJohannes Berg 			 u8 *extra, size_t extra_len, const u8 *bssid,
1238fffd0934SJohannes Berg 			 const u8 *key, u8 key_len, u8 key_idx);
1239de95a54bSJohannes Berg int ieee80211_build_preq_ies(struct ieee80211_local *local, u8 *buffer,
12404d36ec58SJohannes Berg 			     const u8 *ie, size_t ie_len,
12414d36ec58SJohannes Berg 			     enum ieee80211_band band);
124246900298SJohannes Berg void ieee80211_send_probe_req(struct ieee80211_sub_if_data *sdata, u8 *dst,
1243de95a54bSJohannes Berg 			      const u8 *ssid, size_t ssid_len,
1244de95a54bSJohannes Berg 			      const u8 *ie, size_t ie_len);
124546900298SJohannes Berg 
124646900298SJohannes Berg void ieee80211_sta_def_wmm_params(struct ieee80211_sub_if_data *sdata,
124746900298SJohannes Berg 				  const size_t supp_rates_len,
124846900298SJohannes Berg 				  const u8 *supp_rates);
124946900298SJohannes Berg u32 ieee80211_sta_get_rates(struct ieee80211_local *local,
125046900298SJohannes Berg 			    struct ieee802_11_elems *elems,
125146900298SJohannes Berg 			    enum ieee80211_band band);
12520f78231bSJohannes Berg int __ieee80211_request_smps(struct ieee80211_sub_if_data *sdata,
12530f78231bSJohannes Berg 			     enum ieee80211_smps_mode smps_mode);
12540f78231bSJohannes Berg void ieee80211_recalc_smps(struct ieee80211_local *local,
12550f78231bSJohannes Berg 			   struct ieee80211_sub_if_data *forsdata);
125646900298SJohannes Berg 
12578e664fb3SJohannes Berg size_t ieee80211_ie_split(const u8 *ies, size_t ielen,
12588e664fb3SJohannes Berg 			  const u8 *ids, int n_ids, size_t offset);
12598e664fb3SJohannes Berg size_t ieee80211_ie_split_vendor(const u8 *ies, size_t ielen, size_t offset);
12608e664fb3SJohannes Berg 
1261af6b6374SJohannes Berg /* internal work items */
1262af6b6374SJohannes Berg void ieee80211_work_init(struct ieee80211_local *local);
1263af6b6374SJohannes Berg void ieee80211_add_work(struct ieee80211_work *wk);
1264af6b6374SJohannes Berg void free_work(struct ieee80211_work *wk);
1265af6b6374SJohannes Berg void ieee80211_work_purge(struct ieee80211_sub_if_data *sdata);
1266af6b6374SJohannes Berg ieee80211_rx_result ieee80211_work_rx_mgmt(struct ieee80211_sub_if_data *sdata,
1267af6b6374SJohannes Berg 					   struct sk_buff *skb);
1268b8bc4b0aSJohannes Berg int ieee80211_wk_remain_on_channel(struct ieee80211_sub_if_data *sdata,
1269b8bc4b0aSJohannes Berg 				   struct ieee80211_channel *chan,
1270b8bc4b0aSJohannes Berg 				   enum nl80211_channel_type channel_type,
1271b8bc4b0aSJohannes Berg 				   unsigned int duration, u64 *cookie);
1272b8bc4b0aSJohannes Berg int ieee80211_wk_cancel_remain_on_channel(
1273b8bc4b0aSJohannes Berg 	struct ieee80211_sub_if_data *sdata, u64 cookie);
1274af6b6374SJohannes Berg 
1275f444de05SJohannes Berg /* channel management */
1276f444de05SJohannes Berg enum ieee80211_chan_mode {
1277f444de05SJohannes Berg 	CHAN_MODE_UNDEFINED,
1278f444de05SJohannes Berg 	CHAN_MODE_HOPPING,
1279f444de05SJohannes Berg 	CHAN_MODE_FIXED,
1280f444de05SJohannes Berg };
1281f444de05SJohannes Berg 
1282f444de05SJohannes Berg enum ieee80211_chan_mode
1283f444de05SJohannes Berg ieee80211_get_channel_mode(struct ieee80211_local *local,
1284f444de05SJohannes Berg 			   struct ieee80211_sub_if_data *ignore);
12850aaffa9bSJohannes Berg bool ieee80211_set_channel_type(struct ieee80211_local *local,
12860aaffa9bSJohannes Berg 				struct ieee80211_sub_if_data *sdata,
12870aaffa9bSJohannes Berg 				enum nl80211_channel_type chantype);
1288f444de05SJohannes Berg 
1289f4ea83ddSJohannes Berg #ifdef CONFIG_MAC80211_NOINLINE
1290d9e8a70fSJohannes Berg #define debug_noinline noinline
1291d9e8a70fSJohannes Berg #else
1292d9e8a70fSJohannes Berg #define debug_noinline
1293d9e8a70fSJohannes Berg #endif
1294d9e8a70fSJohannes Berg 
1295f0706e82SJiri Benc #endif /* IEEE80211_I_H */
1296