xref: /openbmc/linux/net/mac80211/ieee80211_i.h (revision 9306102e)
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>
5e039fa4aSJohannes Berg  * Copyright 2007-2008	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>
26f0706e82SJiri Benc #include <net/wireless.h>
272c8dccc7SJohannes Berg #include "key.h"
28f0706e82SJiri Benc #include "sta_info.h"
29f0706e82SJiri Benc 
30f0706e82SJiri Benc /* ieee80211.o internal definitions, etc. These are not included into
31f0706e82SJiri Benc  * low-level drivers. */
32f0706e82SJiri Benc 
33f0706e82SJiri Benc #ifndef ETH_P_PAE
34f0706e82SJiri Benc #define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
35f0706e82SJiri Benc #endif /* ETH_P_PAE */
36f0706e82SJiri Benc 
37f0706e82SJiri Benc #define WLAN_FC_DATA_PRESENT(fc) (((fc) & 0x4c) == 0x08)
38f0706e82SJiri Benc 
399cfb0009SJohannes Berg #define IEEE80211_FC(type, subtype) cpu_to_le16(type | subtype)
40f0706e82SJiri Benc 
419cfb0009SJohannes Berg struct ieee80211_local;
42f0706e82SJiri Benc 
43f0706e82SJiri Benc /* Maximum number of broadcast/multicast frames to buffer when some of the
44f0706e82SJiri Benc  * associated stations are using power saving. */
45f0706e82SJiri Benc #define AP_MAX_BC_BUFFER 128
46f0706e82SJiri Benc 
47f0706e82SJiri Benc /* Maximum number of frames buffered to all STAs, including multicast frames.
48f0706e82SJiri Benc  * Note: increasing this limit increases the potential memory requirement. Each
49f0706e82SJiri Benc  * frame can be up to about 2 kB long. */
50f0706e82SJiri Benc #define TOTAL_MAX_TX_BUFFER 512
51f0706e82SJiri Benc 
52f0706e82SJiri Benc /* Required encryption head and tailroom */
53f0706e82SJiri Benc #define IEEE80211_ENCRYPT_HEADROOM 8
54f0706e82SJiri Benc #define IEEE80211_ENCRYPT_TAILROOM 12
55f0706e82SJiri Benc 
56f0706e82SJiri Benc /* IEEE 802.11 (Ch. 9.5 Defragmentation) requires support for concurrent
57f0706e82SJiri Benc  * reception of at least three fragmented frames. This limit can be increased
58f0706e82SJiri Benc  * by changing this define, at the cost of slower frame reassembly and
59f0706e82SJiri Benc  * increased memory use (about 2 kB of RAM per entry). */
60f0706e82SJiri Benc #define IEEE80211_FRAGMENT_MAX 4
61f0706e82SJiri Benc 
62f0706e82SJiri Benc struct ieee80211_fragment_entry {
63f0706e82SJiri Benc 	unsigned long first_frag_time;
64f0706e82SJiri Benc 	unsigned int seq;
65f0706e82SJiri Benc 	unsigned int rx_queue;
66f0706e82SJiri Benc 	unsigned int last_frag;
67f0706e82SJiri Benc 	unsigned int extra_len;
68f0706e82SJiri Benc 	struct sk_buff_head skb_list;
69f0706e82SJiri Benc 	int ccmp; /* Whether fragments were encrypted with CCMP */
70f0706e82SJiri Benc 	u8 last_pn[6]; /* PN of the last fragment if CCMP was used */
71f0706e82SJiri Benc };
72f0706e82SJiri Benc 
73f0706e82SJiri Benc 
74f0706e82SJiri Benc struct ieee80211_sta_bss {
75f0706e82SJiri Benc 	struct list_head list;
76f0706e82SJiri Benc 	struct ieee80211_sta_bss *hnext;
77056cdd59SJohannes Berg 	size_t ssid_len;
78056cdd59SJohannes Berg 
79f0706e82SJiri Benc 	atomic_t users;
80f0706e82SJiri Benc 
81f0706e82SJiri Benc 	u8 bssid[ETH_ALEN];
82f0706e82SJiri Benc 	u8 ssid[IEEE80211_MAX_SSID_LEN];
83f0706e82SJiri Benc 	u16 capability; /* host byte order */
848318d78aSJohannes Berg 	enum ieee80211_band band;
85f0706e82SJiri Benc 	int freq;
86566bfe5aSBruno Randolf 	int signal, noise, qual;
87f0706e82SJiri Benc 	u8 *wpa_ie;
88f0706e82SJiri Benc 	size_t wpa_ie_len;
89f0706e82SJiri Benc 	u8 *rsn_ie;
90f0706e82SJiri Benc 	size_t rsn_ie_len;
91f0706e82SJiri Benc 	u8 *wmm_ie;
92f0706e82SJiri Benc 	size_t wmm_ie_len;
93c7153508SRon Rindjunsky 	u8 *ht_ie;
94c7153508SRon Rindjunsky 	size_t ht_ie_len;
959306102eSEmmanuel Grumbach 	u8 *ht_add_ie;
969306102eSEmmanuel Grumbach 	size_t ht_add_ie_len;
97ee385855SLuis Carlos Cobo #ifdef CONFIG_MAC80211_MESH
98ee385855SLuis Carlos Cobo 	u8 *mesh_id;
99ee385855SLuis Carlos Cobo 	size_t mesh_id_len;
10024736701SJohn W. Linville 	u8 *mesh_cfg;
101902acc78SJohannes Berg #endif
102f0706e82SJiri Benc #define IEEE80211_MAX_SUPP_RATES 32
103f0706e82SJiri Benc 	u8 supp_rates[IEEE80211_MAX_SUPP_RATES];
104f0706e82SJiri Benc 	size_t supp_rates_len;
105f0706e82SJiri Benc 	u64 timestamp;
106056cdd59SJohannes Berg 	int beacon_int;
107f0706e82SJiri Benc 
10830b89b0fSJohannes Berg 	bool probe_resp;
109f0706e82SJiri Benc 	unsigned long last_update;
110f0706e82SJiri Benc 
1115628221cSDaniel Drake 	/* during assocation, we save an ERP value from a probe response so
1125628221cSDaniel Drake 	 * that we can feed ERP info to the driver when handling the
1135628221cSDaniel Drake 	 * association completes. these fields probably won't be up-to-date
1145628221cSDaniel Drake 	 * otherwise, you probably don't want to use them. */
1155628221cSDaniel Drake 	int has_erp_value;
1165628221cSDaniel Drake 	u8 erp_value;
117f0706e82SJiri Benc };
118f0706e82SJiri Benc 
11924736701SJohn W. Linville static inline u8 *bss_mesh_cfg(struct ieee80211_sta_bss *bss)
120902acc78SJohannes Berg {
121902acc78SJohannes Berg #ifdef CONFIG_MAC80211_MESH
122902acc78SJohannes Berg 	return bss->mesh_cfg;
123902acc78SJohannes Berg #endif
124902acc78SJohannes Berg 	return NULL;
125902acc78SJohannes Berg }
126902acc78SJohannes Berg 
127902acc78SJohannes Berg static inline u8 *bss_mesh_id(struct ieee80211_sta_bss *bss)
128902acc78SJohannes Berg {
129902acc78SJohannes Berg #ifdef CONFIG_MAC80211_MESH
130902acc78SJohannes Berg 	return bss->mesh_id;
131902acc78SJohannes Berg #endif
132902acc78SJohannes Berg 	return NULL;
133902acc78SJohannes Berg }
134902acc78SJohannes Berg 
135902acc78SJohannes Berg static inline u8 bss_mesh_id_len(struct ieee80211_sta_bss *bss)
136902acc78SJohannes Berg {
137902acc78SJohannes Berg #ifdef CONFIG_MAC80211_MESH
138902acc78SJohannes Berg 	return bss->mesh_id_len;
139902acc78SJohannes Berg #endif
140902acc78SJohannes Berg 	return 0;
141902acc78SJohannes Berg }
142902acc78SJohannes Berg 
143f0706e82SJiri Benc 
1449ae54c84SJohannes Berg typedef unsigned __bitwise__ ieee80211_tx_result;
1459ae54c84SJohannes Berg #define TX_CONTINUE	((__force ieee80211_tx_result) 0u)
1469ae54c84SJohannes Berg #define TX_DROP		((__force ieee80211_tx_result) 1u)
1479ae54c84SJohannes Berg #define TX_QUEUED	((__force ieee80211_tx_result) 2u)
1489ae54c84SJohannes Berg 
1495cf121c3SJohannes Berg #define IEEE80211_TX_FRAGMENTED		BIT(0)
1505cf121c3SJohannes Berg #define IEEE80211_TX_UNICAST		BIT(1)
1515cf121c3SJohannes Berg #define IEEE80211_TX_PS_BUFFERED	BIT(2)
1525cf121c3SJohannes Berg #define IEEE80211_TX_PROBE_LAST_FRAG	BIT(3)
1539ae54c84SJohannes Berg 
1545cf121c3SJohannes Berg struct ieee80211_tx_data {
155f0706e82SJiri Benc 	struct sk_buff *skb;
156f0706e82SJiri Benc 	struct net_device *dev;
157f0706e82SJiri Benc 	struct ieee80211_local *local;
158f0706e82SJiri Benc 	struct ieee80211_sub_if_data *sdata;
159f0706e82SJiri Benc 	struct sta_info *sta;
160f0706e82SJiri Benc 	struct ieee80211_key *key;
1615cf121c3SJohannes Berg 
1628318d78aSJohannes Berg 	struct ieee80211_channel *channel;
1632e92e6f2SJohannes Berg 	s8 rate_idx;
164f0706e82SJiri Benc 	/* use this rate (if set) for last fragment; rate can
165f0706e82SJiri Benc 	 * be set to lower rate for the first fragments, e.g.,
166f0706e82SJiri Benc 	 * when using CTS protection with IEEE 802.11g. */
1672e92e6f2SJohannes Berg 	s8 last_frag_rate_idx;
168f0706e82SJiri Benc 
169f0706e82SJiri Benc 	/* Extra fragments (in addition to the first fragment
170f0706e82SJiri Benc 	 * in skb) */
171f0706e82SJiri Benc 	struct sk_buff **extra_frag;
172056cdd59SJohannes Berg 	int num_extra_frag;
173056cdd59SJohannes Berg 
174056cdd59SJohannes Berg 	u16 fc, ethertype;
175056cdd59SJohannes Berg 	unsigned int flags;
1765cf121c3SJohannes Berg };
1775cf121c3SJohannes Berg 
1785cf121c3SJohannes Berg 
1795cf121c3SJohannes Berg typedef unsigned __bitwise__ ieee80211_rx_result;
1805cf121c3SJohannes Berg #define RX_CONTINUE		((__force ieee80211_rx_result) 0u)
1815cf121c3SJohannes Berg #define RX_DROP_UNUSABLE	((__force ieee80211_rx_result) 1u)
1825cf121c3SJohannes Berg #define RX_DROP_MONITOR		((__force ieee80211_rx_result) 2u)
1835cf121c3SJohannes Berg #define RX_QUEUED		((__force ieee80211_rx_result) 3u)
1845cf121c3SJohannes Berg 
1855cf121c3SJohannes Berg #define IEEE80211_RX_IN_SCAN		BIT(0)
1865cf121c3SJohannes Berg /* frame is destined to interface currently processed (incl. multicast frames) */
1875cf121c3SJohannes Berg #define IEEE80211_RX_RA_MATCH		BIT(1)
1885cf121c3SJohannes Berg #define IEEE80211_RX_AMSDU		BIT(2)
1895cf121c3SJohannes Berg #define IEEE80211_RX_CMNTR_REPORTED	BIT(3)
1905cf121c3SJohannes Berg #define IEEE80211_RX_FRAGMENTED		BIT(4)
1915cf121c3SJohannes Berg 
1925cf121c3SJohannes Berg struct ieee80211_rx_data {
1935cf121c3SJohannes Berg 	struct sk_buff *skb;
1945cf121c3SJohannes Berg 	struct net_device *dev;
1955cf121c3SJohannes Berg 	struct ieee80211_local *local;
1965cf121c3SJohannes Berg 	struct ieee80211_sub_if_data *sdata;
1975cf121c3SJohannes Berg 	struct sta_info *sta;
1985cf121c3SJohannes Berg 	struct ieee80211_key *key;
199f0706e82SJiri Benc 	struct ieee80211_rx_status *status;
2008318d78aSJohannes Berg 	struct ieee80211_rate *rate;
201056cdd59SJohannes Berg 
202056cdd59SJohannes Berg 	u16 fc, ethertype;
203056cdd59SJohannes Berg 	unsigned int flags;
204f0706e82SJiri Benc 	int sent_ps_buffered;
205f0706e82SJiri Benc 	int queue;
20650741ae0SJohannes Berg 	u32 tkip_iv32;
20750741ae0SJohannes Berg 	u16 tkip_iv16;
208f0706e82SJiri Benc };
209f0706e82SJiri Benc 
210f0706e82SJiri Benc struct ieee80211_tx_stored_packet {
211f0706e82SJiri Benc 	struct sk_buff *skb;
212f0706e82SJiri Benc 	struct sk_buff **extra_frag;
2132e92e6f2SJohannes Berg 	s8 last_frag_rate_idx;
214056cdd59SJohannes Berg 	int num_extra_frag;
2152e92e6f2SJohannes Berg 	bool last_frag_rate_ctrl_probe;
216f0706e82SJiri Benc };
217f0706e82SJiri Benc 
2185dfdaf58SJohannes Berg struct beacon_data {
2195dfdaf58SJohannes Berg 	u8 *head, *tail;
2205dfdaf58SJohannes Berg 	int head_len, tail_len;
2215dfdaf58SJohannes Berg 	int dtim_period;
2225dfdaf58SJohannes Berg };
2235dfdaf58SJohannes Berg 
224f0706e82SJiri Benc struct ieee80211_if_ap {
2255dfdaf58SJohannes Berg 	struct beacon_data *beacon;
226f0706e82SJiri Benc 
2270ec3ca44SJohannes Berg 	struct list_head vlans;
2280ec3ca44SJohannes Berg 
229f0706e82SJiri Benc 	u8 ssid[IEEE80211_MAX_SSID_LEN];
230f0706e82SJiri Benc 	size_t ssid_len;
231f0706e82SJiri Benc 
232f0706e82SJiri Benc 	/* yes, this looks ugly, but guarantees that we can later use
233f0706e82SJiri Benc 	 * bitmap_empty :)
234004c872eSJohannes Berg 	 * NB: don't touch this bitmap, use sta_info_{set,clear}_tim_bit */
235f0706e82SJiri Benc 	u8 tim[sizeof(unsigned long) * BITS_TO_LONGS(IEEE80211_MAX_AID + 1)];
236f0706e82SJiri Benc 	struct sk_buff_head ps_bc_buf;
237056cdd59SJohannes Berg 	atomic_t num_sta_ps; /* number of stations in PS mode */
2385dfdaf58SJohannes Berg 	int dtim_count;
239f0706e82SJiri Benc 	int force_unicast_rateidx; /* forced TX rateidx for unicast frames */
240f0706e82SJiri Benc 	int max_ratectrl_rateidx; /* max TX rateidx for rate control */
241f0706e82SJiri Benc 	int num_beacons; /* number of TXed beacon frames for this BSS */
242f0706e82SJiri Benc };
243f0706e82SJiri Benc 
244f0706e82SJiri Benc struct ieee80211_if_wds {
245f0706e82SJiri Benc 	struct sta_info *sta;
246056cdd59SJohannes Berg 	u8 remote_addr[ETH_ALEN];
247f0706e82SJiri Benc };
248f0706e82SJiri Benc 
249f0706e82SJiri Benc struct ieee80211_if_vlan {
2500ec3ca44SJohannes Berg 	struct ieee80211_sub_if_data *ap;
2510ec3ca44SJohannes Berg 	struct list_head list;
252f0706e82SJiri Benc };
253f0706e82SJiri Benc 
254ee385855SLuis Carlos Cobo struct mesh_stats {
255ee385855SLuis Carlos Cobo 	__u32 fwded_frames;		/* Mesh forwarded frames */
256ee385855SLuis Carlos Cobo 	__u32 dropped_frames_ttl;	/* Not transmitted since mesh_ttl == 0*/
257ee385855SLuis Carlos Cobo 	__u32 dropped_frames_no_route;	/* Not transmitted, no route found */
258ee385855SLuis Carlos Cobo 	atomic_t estab_plinks;
259ee385855SLuis Carlos Cobo };
260ee385855SLuis Carlos Cobo 
261ee385855SLuis Carlos Cobo #define PREQ_Q_F_START		0x1
262ee385855SLuis Carlos Cobo #define PREQ_Q_F_REFRESH	0x2
263ee385855SLuis Carlos Cobo struct mesh_preq_queue {
264ee385855SLuis Carlos Cobo 	struct list_head list;
265ee385855SLuis Carlos Cobo 	u8 dst[ETH_ALEN];
266ee385855SLuis Carlos Cobo 	u8 flags;
267ee385855SLuis Carlos Cobo };
268ee385855SLuis Carlos Cobo 
269ee385855SLuis Carlos Cobo struct mesh_config {
270ee385855SLuis Carlos Cobo 	/* Timeouts in ms */
271ee385855SLuis Carlos Cobo 	/* Mesh plink management parameters */
272ee385855SLuis Carlos Cobo 	u16 dot11MeshRetryTimeout;
273ee385855SLuis Carlos Cobo 	u16 dot11MeshConfirmTimeout;
274ee385855SLuis Carlos Cobo 	u16 dot11MeshHoldingTimeout;
275ee385855SLuis Carlos Cobo 	u16 dot11MeshMaxPeerLinks;
276ee385855SLuis Carlos Cobo 	u8  dot11MeshMaxRetries;
277ee385855SLuis Carlos Cobo 	u8  dot11MeshTTL;
278ee385855SLuis Carlos Cobo 	bool auto_open_plinks;
279ee385855SLuis Carlos Cobo 	/* HWMP parameters */
280ee385855SLuis Carlos Cobo 	u8  dot11MeshHWMPmaxPREQretries;
281ee385855SLuis Carlos Cobo 	u32 path_refresh_time;
282ee385855SLuis Carlos Cobo 	u16 min_discovery_timeout;
283056cdd59SJohannes Berg 	u32 dot11MeshHWMPactivePathTimeout;
284056cdd59SJohannes Berg 	u16 dot11MeshHWMPpreqMinInterval;
285056cdd59SJohannes Berg 	u16 dot11MeshHWMPnetDiameterTraversalTime;
286ee385855SLuis Carlos Cobo };
287902acc78SJohannes Berg 
288ee385855SLuis Carlos Cobo 
289d6f2da5bSJiri Slaby /* flags used in struct ieee80211_if_sta.flags */
290d6f2da5bSJiri Slaby #define IEEE80211_STA_SSID_SET		BIT(0)
291d6f2da5bSJiri Slaby #define IEEE80211_STA_BSSID_SET		BIT(1)
292d6f2da5bSJiri Slaby #define IEEE80211_STA_PREV_BSSID_SET	BIT(2)
293d6f2da5bSJiri Slaby #define IEEE80211_STA_AUTHENTICATED	BIT(3)
294d6f2da5bSJiri Slaby #define IEEE80211_STA_ASSOCIATED	BIT(4)
295d6f2da5bSJiri Slaby #define IEEE80211_STA_PROBEREQ_POLL	BIT(5)
296d6f2da5bSJiri Slaby #define IEEE80211_STA_CREATE_IBSS	BIT(6)
297d6f2da5bSJiri Slaby #define IEEE80211_STA_MIXED_CELL	BIT(7)
298d6f2da5bSJiri Slaby #define IEEE80211_STA_WMM_ENABLED	BIT(8)
299d6f2da5bSJiri Slaby #define IEEE80211_STA_AUTO_SSID_SEL	BIT(10)
300d6f2da5bSJiri Slaby #define IEEE80211_STA_AUTO_BSSID_SEL	BIT(11)
301d6f2da5bSJiri Slaby #define IEEE80211_STA_AUTO_CHANNEL_SEL	BIT(12)
3025b98b1f7SJohannes Berg #define IEEE80211_STA_PRIVACY_INVOKED	BIT(13)
303f0706e82SJiri Benc struct ieee80211_if_sta {
304056cdd59SJohannes Berg 	struct timer_list timer;
305056cdd59SJohannes Berg 	struct work_struct work;
306056cdd59SJohannes Berg 	u8 bssid[ETH_ALEN], prev_bssid[ETH_ALEN];
307056cdd59SJohannes Berg 	u8 ssid[IEEE80211_MAX_SSID_LEN];
308f0706e82SJiri Benc 	enum {
309f0706e82SJiri Benc 		IEEE80211_DISABLED, IEEE80211_AUTHENTICATE,
310f0706e82SJiri Benc 		IEEE80211_ASSOCIATE, IEEE80211_ASSOCIATED,
311ee385855SLuis Carlos Cobo 		IEEE80211_IBSS_SEARCH, IEEE80211_IBSS_JOINED,
312ee385855SLuis Carlos Cobo 		IEEE80211_MESH_UP
313f0706e82SJiri Benc 	} state;
314f0706e82SJiri Benc 	size_t ssid_len;
315a0af5f14SHelmut Schaa 	u8 scan_ssid[IEEE80211_MAX_SSID_LEN];
316a0af5f14SHelmut Schaa 	size_t scan_ssid_len;
317ee385855SLuis Carlos Cobo #ifdef CONFIG_MAC80211_MESH
318ee385855SLuis Carlos Cobo 	struct timer_list mesh_path_timer;
319ee385855SLuis Carlos Cobo 	u8 mesh_id[IEEE80211_MAX_MESH_ID_LEN];
320ee385855SLuis Carlos Cobo 	size_t mesh_id_len;
321ee385855SLuis Carlos Cobo 	/* Active Path Selection Protocol Identifier */
322ee385855SLuis Carlos Cobo 	u8 mesh_pp_id[4];
323ee385855SLuis Carlos Cobo 	/* Active Path Selection Metric Identifier */
324ee385855SLuis Carlos Cobo 	u8 mesh_pm_id[4];
325ee385855SLuis Carlos Cobo 	/* Congestion Control Mode Identifier */
326ee385855SLuis Carlos Cobo 	u8 mesh_cc_id[4];
327ee385855SLuis Carlos Cobo 	/* Local mesh Destination Sequence Number */
328ee385855SLuis Carlos Cobo 	u32 dsn;
329ee385855SLuis Carlos Cobo 	/* Last used PREQ ID */
330ee385855SLuis Carlos Cobo 	u32 preq_id;
331ee385855SLuis Carlos Cobo 	atomic_t mpaths;
332ee385855SLuis Carlos Cobo 	/* Timestamp of last DSN update */
333ee385855SLuis Carlos Cobo 	unsigned long last_dsn_update;
334ee385855SLuis Carlos Cobo 	/* Timestamp of last DSN sent */
335ee385855SLuis Carlos Cobo 	unsigned long last_preq;
336ee385855SLuis Carlos Cobo 	struct mesh_rmc *rmc;
337ee385855SLuis Carlos Cobo 	spinlock_t mesh_preq_queue_lock;
338ee385855SLuis Carlos Cobo 	struct mesh_preq_queue preq_queue;
339ee385855SLuis Carlos Cobo 	int preq_queue_len;
340ee385855SLuis Carlos Cobo 	struct mesh_stats mshstats;
341ee385855SLuis Carlos Cobo 	struct mesh_config mshcfg;
34251ceddadSLuis Carlos Cobo 	u32 mesh_seqnum;
343056cdd59SJohannes Berg 	bool accepting_plinks;
344ee385855SLuis Carlos Cobo #endif
345f0706e82SJiri Benc 	u16 aid;
346f0706e82SJiri Benc 	u16 ap_capab, capab;
347f0706e82SJiri Benc 	u8 *extra_ie; /* to be added to the end of AssocReq */
348f0706e82SJiri Benc 	size_t extra_ie_len;
349f0706e82SJiri Benc 
350f0706e82SJiri Benc 	/* The last AssocReq/Resp IEs */
351f0706e82SJiri Benc 	u8 *assocreq_ies, *assocresp_ies;
352f0706e82SJiri Benc 	size_t assocreq_ies_len, assocresp_ies_len;
353f0706e82SJiri Benc 
354056cdd59SJohannes Berg 	struct sk_buff_head skb_queue;
355056cdd59SJohannes Berg 
356f0706e82SJiri Benc 	int auth_tries, assoc_tries;
357f0706e82SJiri Benc 
358056cdd59SJohannes Berg 	unsigned long request;
359056cdd59SJohannes Berg 
360056cdd59SJohannes Berg 	unsigned long last_probe;
361056cdd59SJohannes Berg 
362d6f2da5bSJiri Slaby 	unsigned int flags;
363f0706e82SJiri Benc #define IEEE80211_STA_REQ_SCAN 0
364f0706e82SJiri Benc #define IEEE80211_STA_REQ_AUTH 1
365f0706e82SJiri Benc #define IEEE80211_STA_REQ_RUN  2
366f0706e82SJiri Benc 
367f0706e82SJiri Benc #define IEEE80211_AUTH_ALG_OPEN BIT(0)
368f0706e82SJiri Benc #define IEEE80211_AUTH_ALG_SHARED_KEY BIT(1)
369f0706e82SJiri Benc #define IEEE80211_AUTH_ALG_LEAP BIT(2)
370f0706e82SJiri Benc 	unsigned int auth_algs; /* bitfield of allowed auth algs */
371f0706e82SJiri Benc 	int auth_alg; /* currently used IEEE 802.11 authentication algorithm */
372f0706e82SJiri Benc 	int auth_transaction;
373f0706e82SJiri Benc 
374f0706e82SJiri Benc 	unsigned long ibss_join_req;
375f0706e82SJiri Benc 	struct sk_buff *probe_resp; /* ProbeResp template for IBSS */
3768318d78aSJohannes Berg 	u32 supp_rates_bits[IEEE80211_NUM_BANDS];
377f0706e82SJiri Benc 
378f0706e82SJiri Benc 	int wmm_last_param_set;
379ee385855SLuis Carlos Cobo 	int num_beacons; /* number of TXed beacon frames by this STA */
380f0706e82SJiri Benc };
381f0706e82SJiri Benc 
382902acc78SJohannes Berg static inline void ieee80211_if_sta_set_mesh_id(struct ieee80211_if_sta *ifsta,
383902acc78SJohannes Berg 						u8 mesh_id_len, u8 *mesh_id)
384902acc78SJohannes Berg {
385902acc78SJohannes Berg #ifdef CONFIG_MAC80211_MESH
386902acc78SJohannes Berg 	ifsta->mesh_id_len = mesh_id_len;
387902acc78SJohannes Berg 	memcpy(ifsta->mesh_id, mesh_id, mesh_id_len);
388902acc78SJohannes Berg #endif
389902acc78SJohannes Berg }
390902acc78SJohannes Berg 
391902acc78SJohannes Berg #ifdef CONFIG_MAC80211_MESH
392902acc78SJohannes Berg #define IEEE80211_IFSTA_MESH_CTR_INC(sta, name)	\
393902acc78SJohannes Berg 	do { (sta)->mshstats.name++; } while (0)
394902acc78SJohannes Berg #else
395902acc78SJohannes Berg #define IEEE80211_IFSTA_MESH_CTR_INC(sta, name) \
396902acc78SJohannes Berg 	do { } while (0)
397902acc78SJohannes Berg #endif
398f0706e82SJiri Benc 
39913262ffdSJiri Slaby /* flags used in struct ieee80211_sub_if_data.flags */
40013262ffdSJiri Slaby #define IEEE80211_SDATA_ALLMULTI	BIT(0)
40113262ffdSJiri Slaby #define IEEE80211_SDATA_PROMISC		BIT(1)
402471b3efdSJohannes Berg #define IEEE80211_SDATA_USERSPACE_MLME	BIT(2)
4038318d78aSJohannes Berg #define IEEE80211_SDATA_OPERATING_GMODE	BIT(3)
404f0706e82SJiri Benc struct ieee80211_sub_if_data {
405f0706e82SJiri Benc 	struct list_head list;
406f0706e82SJiri Benc 
407f0706e82SJiri Benc 	struct wireless_dev wdev;
408f0706e82SJiri Benc 
40911a843b7SJohannes Berg 	/* keys */
41011a843b7SJohannes Berg 	struct list_head key_list;
41111a843b7SJohannes Berg 
412f0706e82SJiri Benc 	struct net_device *dev;
413f0706e82SJiri Benc 	struct ieee80211_local *local;
414f0706e82SJiri Benc 
41513262ffdSJiri Slaby 	unsigned int flags;
4167e9ed188SDaniel Drake 
417f0706e82SJiri Benc 	int drop_unencrypted;
418f0706e82SJiri Benc 
4198318d78aSJohannes Berg 	/*
4208318d78aSJohannes Berg 	 * basic rates of this AP or the AP we're associated to
4218318d78aSJohannes Berg 	 */
4228318d78aSJohannes Berg 	u64 basic_rates;
4238318d78aSJohannes Berg 
424f0706e82SJiri Benc 	u16 sequence;
425f0706e82SJiri Benc 
426f0706e82SJiri Benc 	/* Fragment table for host-based reassembly */
427f0706e82SJiri Benc 	struct ieee80211_fragment_entry	fragments[IEEE80211_FRAGMENT_MAX];
428f0706e82SJiri Benc 	unsigned int fragment_next;
429f0706e82SJiri Benc 
430f0706e82SJiri Benc #define NUM_DEFAULT_KEYS 4
431f0706e82SJiri Benc 	struct ieee80211_key *keys[NUM_DEFAULT_KEYS];
432f0706e82SJiri Benc 	struct ieee80211_key *default_key;
433f0706e82SJiri Benc 
434471b3efdSJohannes Berg 	/*
435471b3efdSJohannes Berg 	 * BSS configuration for this interface.
436471b3efdSJohannes Berg 	 *
437471b3efdSJohannes Berg 	 * FIXME: I feel bad putting this here when we already have a
438471b3efdSJohannes Berg 	 *	  bss pointer, but the bss pointer is just wrong when
439471b3efdSJohannes Berg 	 *	  you have multiple virtual STA mode interfaces...
440471b3efdSJohannes Berg 	 *	  This needs to be fixed.
441471b3efdSJohannes Berg 	 */
442471b3efdSJohannes Berg 	struct ieee80211_bss_conf bss_conf;
443f0706e82SJiri Benc 	struct ieee80211_if_ap *bss; /* BSS that this device belongs to */
444f0706e82SJiri Benc 
445f0706e82SJiri Benc 	union {
446f0706e82SJiri Benc 		struct ieee80211_if_ap ap;
447f0706e82SJiri Benc 		struct ieee80211_if_wds wds;
448f0706e82SJiri Benc 		struct ieee80211_if_vlan vlan;
449f0706e82SJiri Benc 		struct ieee80211_if_sta sta;
4508cc9a739SMichael Wu 		u32 mntr_flags;
451f0706e82SJiri Benc 	} u;
452e9f207f0SJiri Benc 
453e9f207f0SJiri Benc #ifdef CONFIG_MAC80211_DEBUGFS
454e9f207f0SJiri Benc 	struct dentry *debugfsdir;
455e9f207f0SJiri Benc 	union {
456e9f207f0SJiri Benc 		struct {
457e9f207f0SJiri Benc 			struct dentry *drop_unencrypted;
458e9f207f0SJiri Benc 			struct dentry *state;
459e9f207f0SJiri Benc 			struct dentry *bssid;
460e9f207f0SJiri Benc 			struct dentry *prev_bssid;
461e9f207f0SJiri Benc 			struct dentry *ssid_len;
462e9f207f0SJiri Benc 			struct dentry *aid;
463e9f207f0SJiri Benc 			struct dentry *ap_capab;
464e9f207f0SJiri Benc 			struct dentry *capab;
465e9f207f0SJiri Benc 			struct dentry *extra_ie_len;
466e9f207f0SJiri Benc 			struct dentry *auth_tries;
467e9f207f0SJiri Benc 			struct dentry *assoc_tries;
468e9f207f0SJiri Benc 			struct dentry *auth_algs;
469e9f207f0SJiri Benc 			struct dentry *auth_alg;
470e9f207f0SJiri Benc 			struct dentry *auth_transaction;
471e9f207f0SJiri Benc 			struct dentry *flags;
472ee385855SLuis Carlos Cobo 			struct dentry *num_beacons_sta;
473e9f207f0SJiri Benc 		} sta;
474e9f207f0SJiri Benc 		struct {
475e9f207f0SJiri Benc 			struct dentry *drop_unencrypted;
476e9f207f0SJiri Benc 			struct dentry *num_sta_ps;
477e9f207f0SJiri Benc 			struct dentry *dtim_count;
478e9f207f0SJiri Benc 			struct dentry *num_beacons;
479e9f207f0SJiri Benc 			struct dentry *force_unicast_rateidx;
480e9f207f0SJiri Benc 			struct dentry *max_ratectrl_rateidx;
481e9f207f0SJiri Benc 			struct dentry *num_buffered_multicast;
482e9f207f0SJiri Benc 		} ap;
483e9f207f0SJiri Benc 		struct {
484e9f207f0SJiri Benc 			struct dentry *drop_unencrypted;
485e9f207f0SJiri Benc 			struct dentry *peer;
486e9f207f0SJiri Benc 		} wds;
487e9f207f0SJiri Benc 		struct {
488e9f207f0SJiri Benc 			struct dentry *drop_unencrypted;
489e9f207f0SJiri Benc 		} vlan;
490e9f207f0SJiri Benc 		struct {
491e9f207f0SJiri Benc 			struct dentry *mode;
492e9f207f0SJiri Benc 		} monitor;
493e9f207f0SJiri Benc 		struct dentry *default_key;
494e9f207f0SJiri Benc 	} debugfs;
495ee385855SLuis Carlos Cobo 
496ee385855SLuis Carlos Cobo #ifdef CONFIG_MAC80211_MESH
497ee385855SLuis Carlos Cobo 	struct dentry *mesh_stats_dir;
498ee385855SLuis Carlos Cobo 	struct {
499ee385855SLuis Carlos Cobo 		struct dentry *fwded_frames;
500ee385855SLuis Carlos Cobo 		struct dentry *dropped_frames_ttl;
501ee385855SLuis Carlos Cobo 		struct dentry *dropped_frames_no_route;
502ee385855SLuis Carlos Cobo 		struct dentry *estab_plinks;
503ee385855SLuis Carlos Cobo 		struct timer_list mesh_path_timer;
504ee385855SLuis Carlos Cobo 	} mesh_stats;
505ee385855SLuis Carlos Cobo 
506ee385855SLuis Carlos Cobo 	struct dentry *mesh_config_dir;
507ee385855SLuis Carlos Cobo 	struct {
508ee385855SLuis Carlos Cobo 		struct dentry *dot11MeshRetryTimeout;
509ee385855SLuis Carlos Cobo 		struct dentry *dot11MeshConfirmTimeout;
510ee385855SLuis Carlos Cobo 		struct dentry *dot11MeshHoldingTimeout;
511ee385855SLuis Carlos Cobo 		struct dentry *dot11MeshMaxRetries;
512ee385855SLuis Carlos Cobo 		struct dentry *dot11MeshTTL;
513ee385855SLuis Carlos Cobo 		struct dentry *auto_open_plinks;
514ee385855SLuis Carlos Cobo 		struct dentry *dot11MeshMaxPeerLinks;
515ee385855SLuis Carlos Cobo 		struct dentry *dot11MeshHWMPactivePathTimeout;
516ee385855SLuis Carlos Cobo 		struct dentry *dot11MeshHWMPpreqMinInterval;
517ee385855SLuis Carlos Cobo 		struct dentry *dot11MeshHWMPnetDiameterTraversalTime;
518ee385855SLuis Carlos Cobo 		struct dentry *dot11MeshHWMPmaxPREQretries;
519ee385855SLuis Carlos Cobo 		struct dentry *path_refresh_time;
520ee385855SLuis Carlos Cobo 		struct dentry *min_discovery_timeout;
521ee385855SLuis Carlos Cobo 	} mesh_config;
522ee385855SLuis Carlos Cobo #endif
523ee385855SLuis Carlos Cobo 
524e9f207f0SJiri Benc #endif
52532bfd35dSJohannes Berg 	/* must be last, dynamically sized area in this! */
52632bfd35dSJohannes Berg 	struct ieee80211_vif vif;
527f0706e82SJiri Benc };
528f0706e82SJiri Benc 
52932bfd35dSJohannes Berg static inline
53032bfd35dSJohannes Berg struct ieee80211_sub_if_data *vif_to_sdata(struct ieee80211_vif *p)
53132bfd35dSJohannes Berg {
53232bfd35dSJohannes Berg 	return container_of(p, struct ieee80211_sub_if_data, vif);
53332bfd35dSJohannes Berg }
53432bfd35dSJohannes Berg 
535f0706e82SJiri Benc #define IEEE80211_DEV_TO_SUB_IF(dev) netdev_priv(dev)
536f0706e82SJiri Benc 
537f0706e82SJiri Benc enum {
538f0706e82SJiri Benc 	IEEE80211_RX_MSG	= 1,
539f0706e82SJiri Benc 	IEEE80211_TX_STATUS_MSG	= 2,
540eadc8d9eSRon Rindjunsky 	IEEE80211_DELBA_MSG	= 3,
541eadc8d9eSRon Rindjunsky 	IEEE80211_ADDBA_MSG	= 4,
542f0706e82SJiri Benc };
543f0706e82SJiri Benc 
544f0706e82SJiri Benc struct ieee80211_local {
545f0706e82SJiri Benc 	/* embed the driver visible part.
546f0706e82SJiri Benc 	 * don't cast (use the static inlines below), but we keep
547f0706e82SJiri Benc 	 * it first anyway so they become a no-op */
548f0706e82SJiri Benc 	struct ieee80211_hw hw;
549f0706e82SJiri Benc 
550f0706e82SJiri Benc 	const struct ieee80211_ops *ops;
551f0706e82SJiri Benc 
552f0706e82SJiri Benc 	struct net_device *mdev; /* wmaster# - "master" 802.11 device */
553f0706e82SJiri Benc 	int open_count;
5543d30d949SMichael Wu 	int monitors, cooked_mntrs;
5558cc9a739SMichael Wu 	/* number of interfaces with corresponding FIF_ flags */
5568cc9a739SMichael Wu 	int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss;
5574150c572SJohannes Berg 	unsigned int filter_flags; /* FIF_* */
558f0706e82SJiri Benc 	struct iw_statistics wstats;
559f0706e82SJiri Benc 	u8 wstats_flags;
560d0709a65SJohannes Berg 	bool tim_in_locked_section; /* see ieee80211_beacon_get() */
561b306f453SJohannes Berg 	int tx_headroom; /* required headroom for hardware/radiotap */
562f0706e82SJiri Benc 
563f0706e82SJiri Benc 	enum {
564f0706e82SJiri Benc 		IEEE80211_DEV_UNINITIALIZED = 0,
565f0706e82SJiri Benc 		IEEE80211_DEV_REGISTERED,
566f0706e82SJiri Benc 		IEEE80211_DEV_UNREGISTERED,
567f0706e82SJiri Benc 	} reg_state;
568f0706e82SJiri Benc 
569f0706e82SJiri Benc 	/* Tasklet and skb queue to process calls from IRQ mode. All frames
570f0706e82SJiri Benc 	 * added to skb_queue will be processed, but frames in
571f0706e82SJiri Benc 	 * skb_queue_unreliable may be dropped if the total length of these
572f0706e82SJiri Benc 	 * queues increases over the limit. */
573f0706e82SJiri Benc #define IEEE80211_IRQSAFE_QUEUE_LIMIT 128
574f0706e82SJiri Benc 	struct tasklet_struct tasklet;
575f0706e82SJiri Benc 	struct sk_buff_head skb_queue;
576f0706e82SJiri Benc 	struct sk_buff_head skb_queue_unreliable;
577f0706e82SJiri Benc 
578d0709a65SJohannes Berg 	/* Station data */
579d0709a65SJohannes Berg 	/*
580d0709a65SJohannes Berg 	 * The lock only protects the list, hash, timer and counter
581d0709a65SJohannes Berg 	 * against manipulation, reads are done in RCU. Additionally,
582b16bd15cSJohannes Berg 	 * the lock protects each BSS's TIM bitmap.
583d0709a65SJohannes Berg 	 */
584d0709a65SJohannes Berg 	spinlock_t sta_lock;
585d0709a65SJohannes Berg 	unsigned long num_sta;
586f0706e82SJiri Benc 	struct list_head sta_list;
587dc6676b7SJohannes Berg 	struct list_head sta_flush_list;
588dc6676b7SJohannes Berg 	struct work_struct sta_flush_work;
589f0706e82SJiri Benc 	struct sta_info *sta_hash[STA_HASH_SIZE];
590f0706e82SJiri Benc 	struct timer_list sta_cleanup;
591f0706e82SJiri Benc 
592e2530083SJohannes Berg 	unsigned long queues_pending[BITS_TO_LONGS(IEEE80211_MAX_QUEUES)];
593eefce91aSJohannes Berg 	struct ieee80211_tx_stored_packet pending_packet[IEEE80211_MAX_QUEUES];
594f0706e82SJiri Benc 	struct tasklet_struct tx_pending_tasklet;
595f0706e82SJiri Benc 
596f0706e82SJiri Benc 	/* number of interfaces with corresponding IFF_ flags */
59753918994SJohannes Berg 	atomic_t iff_allmultis, iff_promiscs;
598f0706e82SJiri Benc 
599f0706e82SJiri Benc 	struct rate_control_ref *rate_ctrl;
600f0706e82SJiri Benc 
601f0706e82SJiri Benc 	int rts_threshold;
602f0706e82SJiri Benc 	int fragmentation_threshold;
603f0706e82SJiri Benc 	int short_retry_limit; /* dot11ShortRetryLimit */
604f0706e82SJiri Benc 	int long_retry_limit; /* dot11LongRetryLimit */
605f0706e82SJiri Benc 
606f0706e82SJiri Benc 	struct crypto_blkcipher *wep_tx_tfm;
607f0706e82SJiri Benc 	struct crypto_blkcipher *wep_rx_tfm;
608f0706e82SJiri Benc 	u32 wep_iv;
609f0706e82SJiri Benc 
610f0706e82SJiri Benc 	int bridge_packets; /* bridge packets between associated stations and
611f0706e82SJiri Benc 			     * deliver multicast frames both back to wireless
612f0706e82SJiri Benc 			     * media and to the local net stack */
613f0706e82SJiri Benc 
61479010420SJohannes Berg 	struct list_head interfaces;
61579010420SJohannes Berg 
616b16bd15cSJohannes Berg 	/*
617b16bd15cSJohannes Berg 	 * Key lock, protects sdata's key_list and sta_info's
618b16bd15cSJohannes Berg 	 * key pointers (write access, they're RCU.)
619b16bd15cSJohannes Berg 	 */
620b16bd15cSJohannes Berg 	spinlock_t key_lock;
621b16bd15cSJohannes Berg 
622b16bd15cSJohannes Berg 
623ece8edddSZhu Yi 	bool sta_sw_scanning;
624ece8edddSZhu Yi 	bool sta_hw_scanning;
625f0706e82SJiri Benc 	int scan_channel_idx;
6268318d78aSJohannes Berg 	enum ieee80211_band scan_band;
6278318d78aSJohannes Berg 
628f0706e82SJiri Benc 	enum { SCAN_SET_CHANNEL, SCAN_SEND_PROBE } scan_state;
629f0706e82SJiri Benc 	unsigned long last_scan_completed;
630f0706e82SJiri Benc 	struct delayed_work scan_work;
631f0706e82SJiri Benc 	struct net_device *scan_dev;
632f0706e82SJiri Benc 	struct ieee80211_channel *oper_channel, *scan_channel;
633f0706e82SJiri Benc 	u8 scan_ssid[IEEE80211_MAX_SSID_LEN];
634f0706e82SJiri Benc 	size_t scan_ssid_len;
635f0706e82SJiri Benc 	struct list_head sta_bss_list;
636f0706e82SJiri Benc 	struct ieee80211_sta_bss *sta_bss_hash[STA_HASH_SIZE];
637f0706e82SJiri Benc 	spinlock_t sta_bss_lock;
638f0706e82SJiri Benc 
639f0706e82SJiri Benc 	/* SNMP counters */
640f0706e82SJiri Benc 	/* dot11CountersTable */
641f0706e82SJiri Benc 	u32 dot11TransmittedFragmentCount;
642f0706e82SJiri Benc 	u32 dot11MulticastTransmittedFrameCount;
643f0706e82SJiri Benc 	u32 dot11FailedCount;
644f0706e82SJiri Benc 	u32 dot11RetryCount;
645f0706e82SJiri Benc 	u32 dot11MultipleRetryCount;
646f0706e82SJiri Benc 	u32 dot11FrameDuplicateCount;
647f0706e82SJiri Benc 	u32 dot11ReceivedFragmentCount;
648f0706e82SJiri Benc 	u32 dot11MulticastReceivedFrameCount;
649f0706e82SJiri Benc 	u32 dot11TransmittedFrameCount;
650f0706e82SJiri Benc 	u32 dot11WEPUndecryptableCount;
651f0706e82SJiri Benc 
652f0706e82SJiri Benc #ifdef CONFIG_MAC80211_LEDS
653f0706e82SJiri Benc 	int tx_led_counter, rx_led_counter;
654cdcb006fSIvo van Doorn 	struct led_trigger *tx_led, *rx_led, *assoc_led, *radio_led;
655cdcb006fSIvo van Doorn 	char tx_led_name[32], rx_led_name[32],
656cdcb006fSIvo van Doorn 	     assoc_led_name[32], radio_led_name[32];
657f0706e82SJiri Benc #endif
658f0706e82SJiri Benc 
659e9f207f0SJiri Benc #ifdef CONFIG_MAC80211_DEBUGFS
660e9f207f0SJiri Benc 	struct work_struct sta_debugfs_add;
661e9f207f0SJiri Benc #endif
662e9f207f0SJiri Benc 
663f0706e82SJiri Benc #ifdef CONFIG_MAC80211_DEBUG_COUNTERS
664f0706e82SJiri Benc 	/* TX/RX handler statistics */
665f0706e82SJiri Benc 	unsigned int tx_handlers_drop;
666f0706e82SJiri Benc 	unsigned int tx_handlers_queued;
667f0706e82SJiri Benc 	unsigned int tx_handlers_drop_unencrypted;
668f0706e82SJiri Benc 	unsigned int tx_handlers_drop_fragment;
669f0706e82SJiri Benc 	unsigned int tx_handlers_drop_wep;
670f0706e82SJiri Benc 	unsigned int tx_handlers_drop_not_assoc;
671f0706e82SJiri Benc 	unsigned int tx_handlers_drop_unauth_port;
672f0706e82SJiri Benc 	unsigned int rx_handlers_drop;
673f0706e82SJiri Benc 	unsigned int rx_handlers_queued;
674f0706e82SJiri Benc 	unsigned int rx_handlers_drop_nullfunc;
675f0706e82SJiri Benc 	unsigned int rx_handlers_drop_defrag;
676f0706e82SJiri Benc 	unsigned int rx_handlers_drop_short;
677f0706e82SJiri Benc 	unsigned int rx_handlers_drop_passive_scan;
678f0706e82SJiri Benc 	unsigned int tx_expand_skb_head;
679f0706e82SJiri Benc 	unsigned int tx_expand_skb_head_cloned;
680f0706e82SJiri Benc 	unsigned int rx_expand_skb_head;
681f0706e82SJiri Benc 	unsigned int rx_expand_skb_head2;
682f0706e82SJiri Benc 	unsigned int rx_handlers_fragments;
683f0706e82SJiri Benc 	unsigned int tx_status_drop;
684f0706e82SJiri Benc #define I802_DEBUG_INC(c) (c)++
685f0706e82SJiri Benc #else /* CONFIG_MAC80211_DEBUG_COUNTERS */
686f0706e82SJiri Benc #define I802_DEBUG_INC(c) do { } while (0)
687f0706e82SJiri Benc #endif /* CONFIG_MAC80211_DEBUG_COUNTERS */
688f0706e82SJiri Benc 
689f0706e82SJiri Benc 
690f0706e82SJiri Benc 	int total_ps_buffered; /* total number of all buffered unicast and
691f0706e82SJiri Benc 				* multicast packets for power saving stations
692f0706e82SJiri Benc 				*/
693f0706e82SJiri Benc 	int wifi_wme_noack_test;
694f0706e82SJiri Benc 	unsigned int wmm_acm; /* bit field of ACM bits (BIT(802.1D tag)) */
695f0706e82SJiri Benc 
696e9f207f0SJiri Benc #ifdef CONFIG_MAC80211_DEBUGFS
697e9f207f0SJiri Benc 	struct local_debugfsdentries {
698e9f207f0SJiri Benc 		struct dentry *frequency;
699e9f207f0SJiri Benc 		struct dentry *antenna_sel_tx;
700e9f207f0SJiri Benc 		struct dentry *antenna_sel_rx;
701e9f207f0SJiri Benc 		struct dentry *bridge_packets;
702e9f207f0SJiri Benc 		struct dentry *rts_threshold;
703e9f207f0SJiri Benc 		struct dentry *fragmentation_threshold;
704e9f207f0SJiri Benc 		struct dentry *short_retry_limit;
705e9f207f0SJiri Benc 		struct dentry *long_retry_limit;
706e9f207f0SJiri Benc 		struct dentry *total_ps_buffered;
707e9f207f0SJiri Benc 		struct dentry *wep_iv;
708e9f207f0SJiri Benc 		struct dentry *statistics;
709e9f207f0SJiri Benc 		struct local_debugfsdentries_statsdentries {
710e9f207f0SJiri Benc 			struct dentry *transmitted_fragment_count;
711e9f207f0SJiri Benc 			struct dentry *multicast_transmitted_frame_count;
712e9f207f0SJiri Benc 			struct dentry *failed_count;
713e9f207f0SJiri Benc 			struct dentry *retry_count;
714e9f207f0SJiri Benc 			struct dentry *multiple_retry_count;
715e9f207f0SJiri Benc 			struct dentry *frame_duplicate_count;
716e9f207f0SJiri Benc 			struct dentry *received_fragment_count;
717e9f207f0SJiri Benc 			struct dentry *multicast_received_frame_count;
718e9f207f0SJiri Benc 			struct dentry *transmitted_frame_count;
719e9f207f0SJiri Benc 			struct dentry *wep_undecryptable_count;
720e9f207f0SJiri Benc 			struct dentry *num_scans;
721e9f207f0SJiri Benc #ifdef CONFIG_MAC80211_DEBUG_COUNTERS
722e9f207f0SJiri Benc 			struct dentry *tx_handlers_drop;
723e9f207f0SJiri Benc 			struct dentry *tx_handlers_queued;
724e9f207f0SJiri Benc 			struct dentry *tx_handlers_drop_unencrypted;
725e9f207f0SJiri Benc 			struct dentry *tx_handlers_drop_fragment;
726e9f207f0SJiri Benc 			struct dentry *tx_handlers_drop_wep;
727e9f207f0SJiri Benc 			struct dentry *tx_handlers_drop_not_assoc;
728e9f207f0SJiri Benc 			struct dentry *tx_handlers_drop_unauth_port;
729e9f207f0SJiri Benc 			struct dentry *rx_handlers_drop;
730e9f207f0SJiri Benc 			struct dentry *rx_handlers_queued;
731e9f207f0SJiri Benc 			struct dentry *rx_handlers_drop_nullfunc;
732e9f207f0SJiri Benc 			struct dentry *rx_handlers_drop_defrag;
733e9f207f0SJiri Benc 			struct dentry *rx_handlers_drop_short;
734e9f207f0SJiri Benc 			struct dentry *rx_handlers_drop_passive_scan;
735e9f207f0SJiri Benc 			struct dentry *tx_expand_skb_head;
736e9f207f0SJiri Benc 			struct dentry *tx_expand_skb_head_cloned;
737e9f207f0SJiri Benc 			struct dentry *rx_expand_skb_head;
738e9f207f0SJiri Benc 			struct dentry *rx_expand_skb_head2;
739e9f207f0SJiri Benc 			struct dentry *rx_handlers_fragments;
740e9f207f0SJiri Benc 			struct dentry *tx_status_drop;
741e9f207f0SJiri Benc #endif
742e9f207f0SJiri Benc 			struct dentry *dot11ACKFailureCount;
743e9f207f0SJiri Benc 			struct dentry *dot11RTSFailureCount;
744e9f207f0SJiri Benc 			struct dentry *dot11FCSErrorCount;
745e9f207f0SJiri Benc 			struct dentry *dot11RTSSuccessCount;
746e9f207f0SJiri Benc 		} stats;
747e9f207f0SJiri Benc 		struct dentry *stations;
748e9f207f0SJiri Benc 		struct dentry *keys;
749e9f207f0SJiri Benc 	} debugfs;
750e9f207f0SJiri Benc #endif
751f0706e82SJiri Benc };
752f0706e82SJiri Benc 
753e2530083SJohannes Berg static inline int ieee80211_is_multiqueue(struct ieee80211_local *local)
754e2530083SJohannes Berg {
755e2530083SJohannes Berg #ifdef CONFIG_MAC80211_QOS
756e2530083SJohannes Berg 	return netif_is_multiqueue(local->mdev);
757e2530083SJohannes Berg #else
758e2530083SJohannes Berg 	return 0;
759e2530083SJohannes Berg #endif
760e2530083SJohannes Berg }
761e2530083SJohannes Berg 
762eadc8d9eSRon Rindjunsky /* this struct represents 802.11n's RA/TID combination */
763eadc8d9eSRon Rindjunsky struct ieee80211_ra_tid {
764eadc8d9eSRon Rindjunsky 	u8 ra[ETH_ALEN];
765eadc8d9eSRon Rindjunsky 	u16 tid;
766eadc8d9eSRon Rindjunsky };
767eadc8d9eSRon Rindjunsky 
768ee385855SLuis Carlos Cobo /* Parsed Information Elements */
769ee385855SLuis Carlos Cobo struct ieee802_11_elems {
770ee385855SLuis Carlos Cobo 	/* pointers to IEs */
771ee385855SLuis Carlos Cobo 	u8 *ssid;
772ee385855SLuis Carlos Cobo 	u8 *supp_rates;
773ee385855SLuis Carlos Cobo 	u8 *fh_params;
774ee385855SLuis Carlos Cobo 	u8 *ds_params;
775ee385855SLuis Carlos Cobo 	u8 *cf_params;
776ee385855SLuis Carlos Cobo 	u8 *tim;
777ee385855SLuis Carlos Cobo 	u8 *ibss_params;
778ee385855SLuis Carlos Cobo 	u8 *challenge;
779ee385855SLuis Carlos Cobo 	u8 *wpa;
780ee385855SLuis Carlos Cobo 	u8 *rsn;
781ee385855SLuis Carlos Cobo 	u8 *erp_info;
782ee385855SLuis Carlos Cobo 	u8 *ext_supp_rates;
783ee385855SLuis Carlos Cobo 	u8 *wmm_info;
784ee385855SLuis Carlos Cobo 	u8 *wmm_param;
785ee385855SLuis Carlos Cobo 	u8 *ht_cap_elem;
786ee385855SLuis Carlos Cobo 	u8 *ht_info_elem;
787ee385855SLuis Carlos Cobo 	u8 *mesh_config;
788ee385855SLuis Carlos Cobo 	u8 *mesh_id;
789ee385855SLuis Carlos Cobo 	u8 *peer_link;
790ee385855SLuis Carlos Cobo 	u8 *preq;
791ee385855SLuis Carlos Cobo 	u8 *prep;
792ee385855SLuis Carlos Cobo 	u8 *perr;
793ee385855SLuis Carlos Cobo 
794ee385855SLuis Carlos Cobo 	/* length of them, respectively */
795ee385855SLuis Carlos Cobo 	u8 ssid_len;
796ee385855SLuis Carlos Cobo 	u8 supp_rates_len;
797ee385855SLuis Carlos Cobo 	u8 fh_params_len;
798ee385855SLuis Carlos Cobo 	u8 ds_params_len;
799ee385855SLuis Carlos Cobo 	u8 cf_params_len;
800ee385855SLuis Carlos Cobo 	u8 tim_len;
801ee385855SLuis Carlos Cobo 	u8 ibss_params_len;
802ee385855SLuis Carlos Cobo 	u8 challenge_len;
803ee385855SLuis Carlos Cobo 	u8 wpa_len;
804ee385855SLuis Carlos Cobo 	u8 rsn_len;
805ee385855SLuis Carlos Cobo 	u8 erp_info_len;
806ee385855SLuis Carlos Cobo 	u8 ext_supp_rates_len;
807ee385855SLuis Carlos Cobo 	u8 wmm_info_len;
808ee385855SLuis Carlos Cobo 	u8 wmm_param_len;
809ee385855SLuis Carlos Cobo 	u8 ht_cap_elem_len;
810ee385855SLuis Carlos Cobo 	u8 ht_info_elem_len;
811ee385855SLuis Carlos Cobo 	u8 mesh_config_len;
812ee385855SLuis Carlos Cobo 	u8 mesh_id_len;
813ee385855SLuis Carlos Cobo 	u8 peer_link_len;
814ee385855SLuis Carlos Cobo 	u8 preq_len;
815ee385855SLuis Carlos Cobo 	u8 prep_len;
816ee385855SLuis Carlos Cobo 	u8 perr_len;
817ee385855SLuis Carlos Cobo };
818ee385855SLuis Carlos Cobo 
819f0706e82SJiri Benc static inline struct ieee80211_local *hw_to_local(
820f0706e82SJiri Benc 	struct ieee80211_hw *hw)
821f0706e82SJiri Benc {
822f0706e82SJiri Benc 	return container_of(hw, struct ieee80211_local, hw);
823f0706e82SJiri Benc }
824f0706e82SJiri Benc 
825f0706e82SJiri Benc static inline struct ieee80211_hw *local_to_hw(
826f0706e82SJiri Benc 	struct ieee80211_local *local)
827f0706e82SJiri Benc {
828f0706e82SJiri Benc 	return &local->hw;
829f0706e82SJiri Benc }
830f0706e82SJiri Benc 
831f0706e82SJiri Benc struct sta_attribute {
832f0706e82SJiri Benc 	struct attribute attr;
833f0706e82SJiri Benc 	ssize_t (*show)(const struct sta_info *, char *buf);
834f0706e82SJiri Benc 	ssize_t (*store)(struct sta_info *, const char *buf, size_t count);
835f0706e82SJiri Benc };
836f0706e82SJiri Benc 
837571ecf67SJohannes Berg static inline int ieee80211_bssid_match(const u8 *raddr, const u8 *addr)
838571ecf67SJohannes Berg {
839571ecf67SJohannes Berg 	return compare_ether_addr(raddr, addr) == 0 ||
840571ecf67SJohannes Berg 	       is_broadcast_ether_addr(raddr);
841571ecf67SJohannes Berg }
842571ecf67SJohannes Berg 
843571ecf67SJohannes Berg 
844f0706e82SJiri Benc /* ieee80211.c */
845f0706e82SJiri Benc int ieee80211_hw_config(struct ieee80211_local *local);
846f0706e82SJiri Benc int ieee80211_if_config(struct net_device *dev);
847f0706e82SJiri Benc int ieee80211_if_config_beacon(struct net_device *dev);
8485cf121c3SJohannes Berg void ieee80211_tx_set_protected(struct ieee80211_tx_data *tx);
849f0706e82SJiri Benc void ieee80211_if_setup(struct net_device *dev);
85038668c05STomas Winkler u32 ieee80211_handle_ht(struct ieee80211_local *local, int enable_ht,
851d3c990fbSRon Rindjunsky 			struct ieee80211_ht_info *req_ht_cap,
852d3c990fbSRon Rindjunsky 			struct ieee80211_ht_bss_info *req_bss_cap);
853f0706e82SJiri Benc 
854f0706e82SJiri Benc /* ieee80211_ioctl.c */
855f0706e82SJiri Benc extern const struct iw_handler_def ieee80211_iw_handler_def;
8568318d78aSJohannes Berg int ieee80211_set_freq(struct ieee80211_local *local, int freq);
857f0706e82SJiri Benc /* ieee80211_sta.c */
858f0706e82SJiri Benc void ieee80211_sta_timer(unsigned long data);
859f0706e82SJiri Benc void ieee80211_sta_work(struct work_struct *work);
860f0706e82SJiri Benc void ieee80211_sta_scan_work(struct work_struct *work);
861f0706e82SJiri Benc void ieee80211_sta_rx_mgmt(struct net_device *dev, struct sk_buff *skb,
862f0706e82SJiri Benc 			   struct ieee80211_rx_status *rx_status);
863f0706e82SJiri Benc int ieee80211_sta_set_ssid(struct net_device *dev, char *ssid, size_t len);
864f0706e82SJiri Benc int ieee80211_sta_get_ssid(struct net_device *dev, char *ssid, size_t *len);
865f0706e82SJiri Benc int ieee80211_sta_set_bssid(struct net_device *dev, u8 *bssid);
866f0706e82SJiri Benc int ieee80211_sta_req_scan(struct net_device *dev, u8 *ssid, size_t ssid_len);
867f0706e82SJiri Benc void ieee80211_sta_req_auth(struct net_device *dev,
868f0706e82SJiri Benc 			    struct ieee80211_if_sta *ifsta);
869f0706e82SJiri Benc int ieee80211_sta_scan_results(struct net_device *dev, char *buf, size_t len);
8709ae54c84SJohannes Berg ieee80211_rx_result ieee80211_sta_rx_scan(
8719ae54c84SJohannes Berg 	struct net_device *dev, struct sk_buff *skb,
872f0706e82SJiri Benc 	struct ieee80211_rx_status *rx_status);
873f0706e82SJiri Benc void ieee80211_rx_bss_list_init(struct net_device *dev);
874f0706e82SJiri Benc void ieee80211_rx_bss_list_deinit(struct net_device *dev);
875f0706e82SJiri Benc int ieee80211_sta_set_extra_ie(struct net_device *dev, char *ie, size_t len);
876f0706e82SJiri Benc struct sta_info *ieee80211_ibss_add_sta(struct net_device *dev,
877f0706e82SJiri Benc 					struct sk_buff *skb, u8 *bssid,
878f0706e82SJiri Benc 					u8 *addr);
879f0706e82SJiri Benc int ieee80211_sta_deauthenticate(struct net_device *dev, u16 reason);
880f0706e82SJiri Benc int ieee80211_sta_disassociate(struct net_device *dev, u16 reason);
881471b3efdSJohannes Berg void ieee80211_bss_info_change_notify(struct ieee80211_sub_if_data *sdata,
882471b3efdSJohannes Berg 				      u32 changed);
883d9430a32SDaniel Drake void ieee80211_reset_erp_info(struct net_device *dev);
884c7153508SRon Rindjunsky int ieee80211_ht_cap_ie_to_ht_info(struct ieee80211_ht_cap *ht_cap_ie,
885c7153508SRon Rindjunsky 				   struct ieee80211_ht_info *ht_info);
886c7153508SRon Rindjunsky int ieee80211_ht_addt_info_ie_to_ht_bss_info(
887c7153508SRon Rindjunsky 			struct ieee80211_ht_addt_info *ht_add_info_ie,
888c7153508SRon Rindjunsky 			struct ieee80211_ht_bss_info *bss_info);
889eadc8d9eSRon Rindjunsky void ieee80211_send_addba_request(struct net_device *dev, const u8 *da,
890eadc8d9eSRon Rindjunsky 				  u16 tid, u8 dialog_token, u16 start_seq_num,
891eadc8d9eSRon Rindjunsky 				  u16 agg_size, u16 timeout);
892eadc8d9eSRon Rindjunsky void ieee80211_send_delba(struct net_device *dev, const u8 *da, u16 tid,
893eadc8d9eSRon Rindjunsky 				u16 initiator, u16 reason_code);
89485249e5fSRon Rindjunsky 
89507db2183SRon Rindjunsky void ieee80211_sta_stop_rx_ba_session(struct net_device *dev, u8 *da,
89607db2183SRon Rindjunsky 				u16 tid, u16 initiator, u16 reason);
897eadc8d9eSRon Rindjunsky void sta_addba_resp_timer_expired(unsigned long data);
89885249e5fSRon Rindjunsky void ieee80211_sta_tear_down_BA_sessions(struct net_device *dev, u8 *addr);
899ee385855SLuis Carlos Cobo u64 ieee80211_sta_get_rates(struct ieee80211_local *local,
900ee385855SLuis Carlos Cobo 			    struct ieee802_11_elems *elems,
901ee385855SLuis Carlos Cobo 			    enum ieee80211_band band);
902ee385855SLuis Carlos Cobo void ieee80211_sta_tx(struct net_device *dev, struct sk_buff *skb,
903ee385855SLuis Carlos Cobo 		int encrypt);
904ee385855SLuis Carlos Cobo void ieee802_11_parse_elems(u8 *start, size_t len,
905ee385855SLuis Carlos Cobo 				   struct ieee802_11_elems *elems);
906ee385855SLuis Carlos Cobo 
907902acc78SJohannes Berg #ifdef CONFIG_MAC80211_MESH
908902acc78SJohannes Berg void ieee80211_start_mesh(struct net_device *dev);
909902acc78SJohannes Berg #else
910902acc78SJohannes Berg static inline void ieee80211_start_mesh(struct net_device *dev)
911902acc78SJohannes Berg {}
912902acc78SJohannes Berg #endif
913ee385855SLuis Carlos Cobo 
914f0706e82SJiri Benc /* ieee80211_iface.c */
915f0706e82SJiri Benc int ieee80211_if_add(struct net_device *dev, const char *name,
916ee385855SLuis Carlos Cobo 		     struct net_device **new_dev, int type,
917ee385855SLuis Carlos Cobo 		     struct vif_params *params);
918f0706e82SJiri Benc void ieee80211_if_set_type(struct net_device *dev, int type);
919f0706e82SJiri Benc void ieee80211_if_reinit(struct net_device *dev);
920f0706e82SJiri Benc void __ieee80211_if_del(struct ieee80211_local *local,
921f0706e82SJiri Benc 			struct ieee80211_sub_if_data *sdata);
922f0706e82SJiri Benc int ieee80211_if_remove(struct net_device *dev, const char *name, int id);
923f0706e82SJiri Benc void ieee80211_if_free(struct net_device *dev);
924f0706e82SJiri Benc void ieee80211_if_sdata_init(struct ieee80211_sub_if_data *sdata);
925f0706e82SJiri Benc 
926e2ebc74dSJohannes Berg /* tx handling */
927e2ebc74dSJohannes Berg void ieee80211_clear_tx_pending(struct ieee80211_local *local);
928e2ebc74dSJohannes Berg void ieee80211_tx_pending(unsigned long data);
929e2ebc74dSJohannes Berg int ieee80211_master_start_xmit(struct sk_buff *skb, struct net_device *dev);
930e2ebc74dSJohannes Berg int ieee80211_monitor_start_xmit(struct sk_buff *skb, struct net_device *dev);
931e2ebc74dSJohannes Berg int ieee80211_subif_start_xmit(struct sk_buff *skb, struct net_device *dev);
932e2ebc74dSJohannes Berg 
933c2d1560aSJohannes Berg /* utility functions/constants */
934c2d1560aSJohannes Berg extern void *mac80211_wiphy_privid; /* for wiphy privid */
935c2d1560aSJohannes Berg extern const unsigned char rfc1042_header[6];
936c2d1560aSJohannes Berg extern const unsigned char bridge_tunnel_header[6];
93771364716SRon Rindjunsky u8 *ieee80211_get_bssid(struct ieee80211_hdr *hdr, size_t len,
93871364716SRon Rindjunsky 			enum ieee80211_if_types type);
939c2d1560aSJohannes Berg int ieee80211_frame_duration(struct ieee80211_local *local, size_t len,
940c2d1560aSJohannes Berg 			     int rate, int erp, int short_preamble);
941eb063c17SJohannes Berg void mac80211_ev_michael_mic_failure(struct net_device *dev, int keyidx,
942eb063c17SJohannes Berg 				     struct ieee80211_hdr *hdr);
943f0706e82SJiri Benc 
944f0706e82SJiri Benc #endif /* IEEE80211_I_H */
945