xref: /openbmc/linux/net/mac80211/ieee80211_i.h (revision d0709a65)
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>
5f0706e82SJiri Benc  *
6f0706e82SJiri Benc  * This program is free software; you can redistribute it and/or modify
7f0706e82SJiri Benc  * it under the terms of the GNU General Public License version 2 as
8f0706e82SJiri Benc  * published by the Free Software Foundation.
9f0706e82SJiri Benc  */
10f0706e82SJiri Benc 
11f0706e82SJiri Benc #ifndef IEEE80211_I_H
12f0706e82SJiri Benc #define IEEE80211_I_H
13f0706e82SJiri Benc 
14f0706e82SJiri Benc #include <linux/kernel.h>
15f0706e82SJiri Benc #include <linux/device.h>
16f0706e82SJiri Benc #include <linux/if_ether.h>
17f0706e82SJiri Benc #include <linux/interrupt.h>
18f0706e82SJiri Benc #include <linux/list.h>
19f0706e82SJiri Benc #include <linux/netdevice.h>
20f0706e82SJiri Benc #include <linux/skbuff.h>
21f0706e82SJiri Benc #include <linux/workqueue.h>
22f0706e82SJiri Benc #include <linux/types.h>
23f0706e82SJiri Benc #include <linux/spinlock.h>
24571ecf67SJohannes Berg #include <linux/etherdevice.h>
25f0706e82SJiri Benc #include <net/wireless.h>
26f0706e82SJiri Benc #include "ieee80211_key.h"
27f0706e82SJiri Benc #include "sta_info.h"
28f0706e82SJiri Benc 
29f0706e82SJiri Benc /* ieee80211.o internal definitions, etc. These are not included into
30f0706e82SJiri Benc  * low-level drivers. */
31f0706e82SJiri Benc 
32f0706e82SJiri Benc #ifndef ETH_P_PAE
33f0706e82SJiri Benc #define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
34f0706e82SJiri Benc #endif /* ETH_P_PAE */
35f0706e82SJiri Benc 
36f0706e82SJiri Benc #define WLAN_FC_DATA_PRESENT(fc) (((fc) & 0x4c) == 0x08)
37f0706e82SJiri Benc 
38f0706e82SJiri Benc struct ieee80211_local;
39f0706e82SJiri Benc 
40f0706e82SJiri Benc #define IEEE80211_ALIGN32_PAD(a) ((4 - ((a) & 3)) & 3)
41f0706e82SJiri Benc 
42f0706e82SJiri Benc /* Maximum number of broadcast/multicast frames to buffer when some of the
43f0706e82SJiri Benc  * associated stations are using power saving. */
44f0706e82SJiri Benc #define AP_MAX_BC_BUFFER 128
45f0706e82SJiri Benc 
46f0706e82SJiri Benc /* Maximum number of frames buffered to all STAs, including multicast frames.
47f0706e82SJiri Benc  * Note: increasing this limit increases the potential memory requirement. Each
48f0706e82SJiri Benc  * frame can be up to about 2 kB long. */
49f0706e82SJiri Benc #define TOTAL_MAX_TX_BUFFER 512
50f0706e82SJiri Benc 
51f0706e82SJiri Benc /* Required encryption head and tailroom */
52f0706e82SJiri Benc #define IEEE80211_ENCRYPT_HEADROOM 8
53f0706e82SJiri Benc #define IEEE80211_ENCRYPT_TAILROOM 12
54f0706e82SJiri Benc 
55f0706e82SJiri Benc /* IEEE 802.11 (Ch. 9.5 Defragmentation) requires support for concurrent
56f0706e82SJiri Benc  * reception of at least three fragmented frames. This limit can be increased
57f0706e82SJiri Benc  * by changing this define, at the cost of slower frame reassembly and
58f0706e82SJiri Benc  * increased memory use (about 2 kB of RAM per entry). */
59f0706e82SJiri Benc #define IEEE80211_FRAGMENT_MAX 4
60f0706e82SJiri Benc 
61f0706e82SJiri Benc struct ieee80211_fragment_entry {
62f0706e82SJiri Benc 	unsigned long first_frag_time;
63f0706e82SJiri Benc 	unsigned int seq;
64f0706e82SJiri Benc 	unsigned int rx_queue;
65f0706e82SJiri Benc 	unsigned int last_frag;
66f0706e82SJiri Benc 	unsigned int extra_len;
67f0706e82SJiri Benc 	struct sk_buff_head skb_list;
68f0706e82SJiri Benc 	int ccmp; /* Whether fragments were encrypted with CCMP */
69f0706e82SJiri Benc 	u8 last_pn[6]; /* PN of the last fragment if CCMP was used */
70f0706e82SJiri Benc };
71f0706e82SJiri Benc 
72f0706e82SJiri Benc 
73f0706e82SJiri Benc struct ieee80211_sta_bss {
74f0706e82SJiri Benc 	struct list_head list;
75f0706e82SJiri Benc 	struct ieee80211_sta_bss *hnext;
76f0706e82SJiri Benc 	atomic_t users;
77f0706e82SJiri Benc 
78f0706e82SJiri Benc 	u8 bssid[ETH_ALEN];
79f0706e82SJiri Benc 	u8 ssid[IEEE80211_MAX_SSID_LEN];
80f0706e82SJiri Benc 	size_t ssid_len;
81f0706e82SJiri Benc 	u16 capability; /* host byte order */
828318d78aSJohannes Berg 	enum ieee80211_band band;
83f0706e82SJiri Benc 	int freq;
84f0706e82SJiri Benc 	int rssi, signal, noise;
85f0706e82SJiri Benc 	u8 *wpa_ie;
86f0706e82SJiri Benc 	size_t wpa_ie_len;
87f0706e82SJiri Benc 	u8 *rsn_ie;
88f0706e82SJiri Benc 	size_t rsn_ie_len;
89f0706e82SJiri Benc 	u8 *wmm_ie;
90f0706e82SJiri Benc 	size_t wmm_ie_len;
91c7153508SRon Rindjunsky 	u8 *ht_ie;
92c7153508SRon Rindjunsky 	size_t ht_ie_len;
93ee385855SLuis Carlos Cobo #ifdef CONFIG_MAC80211_MESH
94ee385855SLuis Carlos Cobo 	u8 *mesh_id;
95ee385855SLuis Carlos Cobo 	size_t mesh_id_len;
96ee385855SLuis Carlos Cobo 	u8 *mesh_cfg;
97902acc78SJohannes Berg #endif
98f0706e82SJiri Benc #define IEEE80211_MAX_SUPP_RATES 32
99f0706e82SJiri Benc 	u8 supp_rates[IEEE80211_MAX_SUPP_RATES];
100f0706e82SJiri Benc 	size_t supp_rates_len;
101f0706e82SJiri Benc 	int beacon_int;
102f0706e82SJiri Benc 	u64 timestamp;
103f0706e82SJiri Benc 
104f0706e82SJiri Benc 	int probe_resp;
105f0706e82SJiri Benc 	unsigned long last_update;
106f0706e82SJiri Benc 
1075628221cSDaniel Drake 	/* during assocation, we save an ERP value from a probe response so
1085628221cSDaniel Drake 	 * that we can feed ERP info to the driver when handling the
1095628221cSDaniel Drake 	 * association completes. these fields probably won't be up-to-date
1105628221cSDaniel Drake 	 * otherwise, you probably don't want to use them. */
1115628221cSDaniel Drake 	int has_erp_value;
1125628221cSDaniel Drake 	u8 erp_value;
113f0706e82SJiri Benc };
114f0706e82SJiri Benc 
115902acc78SJohannes Berg static inline u8 *bss_mesh_cfg(struct ieee80211_sta_bss *bss)
116902acc78SJohannes Berg {
117902acc78SJohannes Berg #ifdef CONFIG_MAC80211_MESH
118902acc78SJohannes Berg 	return bss->mesh_cfg;
119902acc78SJohannes Berg #endif
120902acc78SJohannes Berg 	return NULL;
121902acc78SJohannes Berg }
122902acc78SJohannes Berg 
123902acc78SJohannes Berg static inline u8 *bss_mesh_id(struct ieee80211_sta_bss *bss)
124902acc78SJohannes Berg {
125902acc78SJohannes Berg #ifdef CONFIG_MAC80211_MESH
126902acc78SJohannes Berg 	return bss->mesh_id;
127902acc78SJohannes Berg #endif
128902acc78SJohannes Berg 	return NULL;
129902acc78SJohannes Berg }
130902acc78SJohannes Berg 
131902acc78SJohannes Berg static inline u8 bss_mesh_id_len(struct ieee80211_sta_bss *bss)
132902acc78SJohannes Berg {
133902acc78SJohannes Berg #ifdef CONFIG_MAC80211_MESH
134902acc78SJohannes Berg 	return bss->mesh_id_len;
135902acc78SJohannes Berg #endif
136902acc78SJohannes Berg 	return 0;
137902acc78SJohannes Berg }
138902acc78SJohannes Berg 
139f0706e82SJiri Benc 
1409ae54c84SJohannes Berg typedef unsigned __bitwise__ ieee80211_tx_result;
1419ae54c84SJohannes Berg #define TX_CONTINUE	((__force ieee80211_tx_result) 0u)
1429ae54c84SJohannes Berg #define TX_DROP		((__force ieee80211_tx_result) 1u)
1439ae54c84SJohannes Berg #define TX_QUEUED	((__force ieee80211_tx_result) 2u)
1449ae54c84SJohannes Berg 
1455cf121c3SJohannes Berg #define IEEE80211_TX_FRAGMENTED		BIT(0)
1465cf121c3SJohannes Berg #define IEEE80211_TX_UNICAST		BIT(1)
1475cf121c3SJohannes Berg #define IEEE80211_TX_PS_BUFFERED	BIT(2)
1485cf121c3SJohannes Berg #define IEEE80211_TX_PROBE_LAST_FRAG	BIT(3)
1495cf121c3SJohannes Berg #define IEEE80211_TX_INJECTED		BIT(4)
1509ae54c84SJohannes Berg 
1515cf121c3SJohannes Berg struct ieee80211_tx_data {
152f0706e82SJiri Benc 	struct sk_buff *skb;
153f0706e82SJiri Benc 	struct net_device *dev;
154f0706e82SJiri Benc 	struct ieee80211_local *local;
155f0706e82SJiri Benc 	struct ieee80211_sub_if_data *sdata;
156f0706e82SJiri Benc 	struct sta_info *sta;
157f0706e82SJiri Benc 	u16 fc, ethertype;
158f0706e82SJiri Benc 	struct ieee80211_key *key;
159badffb72SJiri Slaby 	unsigned int flags;
1605cf121c3SJohannes Berg 
161f0706e82SJiri Benc 	struct ieee80211_tx_control *control;
1628318d78aSJohannes Berg 	struct ieee80211_channel *channel;
163f0706e82SJiri Benc 	struct ieee80211_rate *rate;
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. */
167f0706e82SJiri Benc 	struct ieee80211_rate *last_frag_rate;
168f0706e82SJiri Benc 
169f0706e82SJiri Benc 	/* Extra fragments (in addition to the first fragment
170f0706e82SJiri Benc 	 * in skb) */
171f0706e82SJiri Benc 	int num_extra_frag;
172f0706e82SJiri Benc 	struct sk_buff **extra_frag;
1735cf121c3SJohannes Berg };
1745cf121c3SJohannes Berg 
1755cf121c3SJohannes Berg 
1765cf121c3SJohannes Berg typedef unsigned __bitwise__ ieee80211_rx_result;
1775cf121c3SJohannes Berg #define RX_CONTINUE		((__force ieee80211_rx_result) 0u)
1785cf121c3SJohannes Berg #define RX_DROP_UNUSABLE	((__force ieee80211_rx_result) 1u)
1795cf121c3SJohannes Berg #define RX_DROP_MONITOR		((__force ieee80211_rx_result) 2u)
1805cf121c3SJohannes Berg #define RX_QUEUED		((__force ieee80211_rx_result) 3u)
1815cf121c3SJohannes Berg 
1825cf121c3SJohannes Berg #define IEEE80211_RX_IN_SCAN		BIT(0)
1835cf121c3SJohannes Berg /* frame is destined to interface currently processed (incl. multicast frames) */
1845cf121c3SJohannes Berg #define IEEE80211_RX_RA_MATCH		BIT(1)
1855cf121c3SJohannes Berg #define IEEE80211_RX_AMSDU		BIT(2)
1865cf121c3SJohannes Berg #define IEEE80211_RX_CMNTR_REPORTED	BIT(3)
1875cf121c3SJohannes Berg #define IEEE80211_RX_FRAGMENTED		BIT(4)
1885cf121c3SJohannes Berg 
1895cf121c3SJohannes Berg struct ieee80211_rx_data {
1905cf121c3SJohannes Berg 	struct sk_buff *skb;
1915cf121c3SJohannes Berg 	struct net_device *dev;
1925cf121c3SJohannes Berg 	struct ieee80211_local *local;
1935cf121c3SJohannes Berg 	struct ieee80211_sub_if_data *sdata;
1945cf121c3SJohannes Berg 	struct sta_info *sta;
1955cf121c3SJohannes Berg 	u16 fc, ethertype;
1965cf121c3SJohannes Berg 	struct ieee80211_key *key;
1975cf121c3SJohannes Berg 	unsigned int flags;
1985cf121c3SJohannes Berg 
199f0706e82SJiri Benc 	struct ieee80211_rx_status *status;
2008318d78aSJohannes Berg 	struct ieee80211_rate *rate;
201f0706e82SJiri Benc 	int sent_ps_buffered;
202f0706e82SJiri Benc 	int queue;
203f0706e82SJiri Benc 	int load;
20450741ae0SJohannes Berg 	u32 tkip_iv32;
20550741ae0SJohannes Berg 	u16 tkip_iv16;
206f0706e82SJiri Benc };
207f0706e82SJiri Benc 
208e8bf9649SJiri Slaby /* flags used in struct ieee80211_tx_packet_data.flags */
209e8bf9649SJiri Slaby #define IEEE80211_TXPD_REQ_TX_STATUS	BIT(0)
210e8bf9649SJiri Slaby #define IEEE80211_TXPD_DO_NOT_ENCRYPT	BIT(1)
211e8bf9649SJiri Slaby #define IEEE80211_TXPD_REQUEUE		BIT(2)
212678f5f71SJohannes Berg #define IEEE80211_TXPD_EAPOL_FRAME	BIT(3)
2139e723492SRon Rindjunsky #define IEEE80211_TXPD_AMPDU		BIT(4)
214f0706e82SJiri Benc /* Stored in sk_buff->cb */
215f0706e82SJiri Benc struct ieee80211_tx_packet_data {
216f0706e82SJiri Benc 	int ifindex;
217f0706e82SJiri Benc 	unsigned long jiffies;
218e8bf9649SJiri Slaby 	unsigned int flags;
219e8bf9649SJiri Slaby 	u8 queue;
220f0706e82SJiri Benc };
221f0706e82SJiri Benc 
222f0706e82SJiri Benc struct ieee80211_tx_stored_packet {
223f0706e82SJiri Benc 	struct ieee80211_tx_control control;
224f0706e82SJiri Benc 	struct sk_buff *skb;
225f0706e82SJiri Benc 	int num_extra_frag;
226f0706e82SJiri Benc 	struct sk_buff **extra_frag;
227f0706e82SJiri Benc 	struct ieee80211_rate *last_frag_rate;
228badffb72SJiri Slaby 	unsigned int last_frag_rate_ctrl_probe;
229f0706e82SJiri Benc };
230f0706e82SJiri Benc 
2315dfdaf58SJohannes Berg struct beacon_data {
2325dfdaf58SJohannes Berg 	u8 *head, *tail;
2335dfdaf58SJohannes Berg 	int head_len, tail_len;
2345dfdaf58SJohannes Berg 	int dtim_period;
2355dfdaf58SJohannes Berg };
2365dfdaf58SJohannes Berg 
237f0706e82SJiri Benc struct ieee80211_if_ap {
2385dfdaf58SJohannes Berg 	struct beacon_data *beacon;
239f0706e82SJiri Benc 
2400ec3ca44SJohannes Berg 	struct list_head vlans;
2410ec3ca44SJohannes Berg 
242f0706e82SJiri Benc 	u8 ssid[IEEE80211_MAX_SSID_LEN];
243f0706e82SJiri Benc 	size_t ssid_len;
244f0706e82SJiri Benc 
245f0706e82SJiri Benc 	/* yes, this looks ugly, but guarantees that we can later use
246f0706e82SJiri Benc 	 * bitmap_empty :)
247004c872eSJohannes Berg 	 * NB: don't touch this bitmap, use sta_info_{set,clear}_tim_bit */
248f0706e82SJiri Benc 	u8 tim[sizeof(unsigned long) * BITS_TO_LONGS(IEEE80211_MAX_AID + 1)];
249f0706e82SJiri Benc 	atomic_t num_sta_ps; /* number of stations in PS mode */
250f0706e82SJiri Benc 	struct sk_buff_head ps_bc_buf;
2515dfdaf58SJohannes Berg 	int dtim_count;
252f0706e82SJiri Benc 	int force_unicast_rateidx; /* forced TX rateidx for unicast frames */
253f0706e82SJiri Benc 	int max_ratectrl_rateidx; /* max TX rateidx for rate control */
254f0706e82SJiri Benc 	int num_beacons; /* number of TXed beacon frames for this BSS */
255f0706e82SJiri Benc };
256f0706e82SJiri Benc 
257f0706e82SJiri Benc struct ieee80211_if_wds {
258f0706e82SJiri Benc 	u8 remote_addr[ETH_ALEN];
259f0706e82SJiri Benc 	struct sta_info *sta;
260f0706e82SJiri Benc };
261f0706e82SJiri Benc 
262f0706e82SJiri Benc struct ieee80211_if_vlan {
2630ec3ca44SJohannes Berg 	struct ieee80211_sub_if_data *ap;
2640ec3ca44SJohannes Berg 	struct list_head list;
265f0706e82SJiri Benc };
266f0706e82SJiri Benc 
267ee385855SLuis Carlos Cobo struct mesh_stats {
268ee385855SLuis Carlos Cobo 	__u32 fwded_frames;		/* Mesh forwarded frames */
269ee385855SLuis Carlos Cobo 	__u32 dropped_frames_ttl;	/* Not transmitted since mesh_ttl == 0*/
270ee385855SLuis Carlos Cobo 	__u32 dropped_frames_no_route;	/* Not transmitted, no route found */
271ee385855SLuis Carlos Cobo 	atomic_t estab_plinks;
272ee385855SLuis Carlos Cobo };
273ee385855SLuis Carlos Cobo 
274ee385855SLuis Carlos Cobo #define PREQ_Q_F_START		0x1
275ee385855SLuis Carlos Cobo #define PREQ_Q_F_REFRESH	0x2
276ee385855SLuis Carlos Cobo struct mesh_preq_queue {
277ee385855SLuis Carlos Cobo 	struct list_head list;
278ee385855SLuis Carlos Cobo 	u8 dst[ETH_ALEN];
279ee385855SLuis Carlos Cobo 	u8 flags;
280ee385855SLuis Carlos Cobo };
281ee385855SLuis Carlos Cobo 
282ee385855SLuis Carlos Cobo struct mesh_config {
283ee385855SLuis Carlos Cobo 	/* Timeouts in ms */
284ee385855SLuis Carlos Cobo 	/* Mesh plink management parameters */
285ee385855SLuis Carlos Cobo 	u16 dot11MeshRetryTimeout;
286ee385855SLuis Carlos Cobo 	u16 dot11MeshConfirmTimeout;
287ee385855SLuis Carlos Cobo 	u16 dot11MeshHoldingTimeout;
288ee385855SLuis Carlos Cobo 	u16 dot11MeshMaxPeerLinks;
289ee385855SLuis Carlos Cobo 	u8  dot11MeshMaxRetries;
290ee385855SLuis Carlos Cobo 	u8  dot11MeshTTL;
291ee385855SLuis Carlos Cobo 	bool auto_open_plinks;
292ee385855SLuis Carlos Cobo 	/* HWMP parameters */
293ee385855SLuis Carlos Cobo 	u32 dot11MeshHWMPactivePathTimeout;
294ee385855SLuis Carlos Cobo 	u16 dot11MeshHWMPpreqMinInterval;
295ee385855SLuis Carlos Cobo 	u16 dot11MeshHWMPnetDiameterTraversalTime;
296ee385855SLuis Carlos Cobo 	u8  dot11MeshHWMPmaxPREQretries;
297ee385855SLuis Carlos Cobo 	u32 path_refresh_time;
298ee385855SLuis Carlos Cobo 	u16 min_discovery_timeout;
299ee385855SLuis Carlos Cobo };
300902acc78SJohannes Berg 
301ee385855SLuis Carlos Cobo 
302d6f2da5bSJiri Slaby /* flags used in struct ieee80211_if_sta.flags */
303d6f2da5bSJiri Slaby #define IEEE80211_STA_SSID_SET		BIT(0)
304d6f2da5bSJiri Slaby #define IEEE80211_STA_BSSID_SET		BIT(1)
305d6f2da5bSJiri Slaby #define IEEE80211_STA_PREV_BSSID_SET	BIT(2)
306d6f2da5bSJiri Slaby #define IEEE80211_STA_AUTHENTICATED	BIT(3)
307d6f2da5bSJiri Slaby #define IEEE80211_STA_ASSOCIATED	BIT(4)
308d6f2da5bSJiri Slaby #define IEEE80211_STA_PROBEREQ_POLL	BIT(5)
309d6f2da5bSJiri Slaby #define IEEE80211_STA_CREATE_IBSS	BIT(6)
310d6f2da5bSJiri Slaby #define IEEE80211_STA_MIXED_CELL	BIT(7)
311d6f2da5bSJiri Slaby #define IEEE80211_STA_WMM_ENABLED	BIT(8)
312d6f2da5bSJiri Slaby #define IEEE80211_STA_AUTO_SSID_SEL	BIT(10)
313d6f2da5bSJiri Slaby #define IEEE80211_STA_AUTO_BSSID_SEL	BIT(11)
314d6f2da5bSJiri Slaby #define IEEE80211_STA_AUTO_CHANNEL_SEL	BIT(12)
3155b98b1f7SJohannes Berg #define IEEE80211_STA_PRIVACY_INVOKED	BIT(13)
316f0706e82SJiri Benc struct ieee80211_if_sta {
317f0706e82SJiri Benc 	enum {
318f0706e82SJiri Benc 		IEEE80211_DISABLED, IEEE80211_AUTHENTICATE,
319f0706e82SJiri Benc 		IEEE80211_ASSOCIATE, IEEE80211_ASSOCIATED,
320ee385855SLuis Carlos Cobo 		IEEE80211_IBSS_SEARCH, IEEE80211_IBSS_JOINED,
321ee385855SLuis Carlos Cobo 		IEEE80211_MESH_UP
322f0706e82SJiri Benc 	} state;
323f0706e82SJiri Benc 	struct timer_list timer;
324f0706e82SJiri Benc 	struct work_struct work;
325f0706e82SJiri Benc 	u8 bssid[ETH_ALEN], prev_bssid[ETH_ALEN];
326f0706e82SJiri Benc 	u8 ssid[IEEE80211_MAX_SSID_LEN];
327f0706e82SJiri Benc 	size_t ssid_len;
328a0af5f14SHelmut Schaa 	u8 scan_ssid[IEEE80211_MAX_SSID_LEN];
329a0af5f14SHelmut Schaa 	size_t scan_ssid_len;
330ee385855SLuis Carlos Cobo #ifdef CONFIG_MAC80211_MESH
331ee385855SLuis Carlos Cobo 	struct timer_list mesh_path_timer;
332ee385855SLuis Carlos Cobo 	u8 mesh_id[IEEE80211_MAX_MESH_ID_LEN];
333ee385855SLuis Carlos Cobo 	bool accepting_plinks;
334ee385855SLuis Carlos Cobo 	size_t mesh_id_len;
335ee385855SLuis Carlos Cobo 	/* Active Path Selection Protocol Identifier */
336ee385855SLuis Carlos Cobo 	u8 mesh_pp_id[4];
337ee385855SLuis Carlos Cobo 	/* Active Path Selection Metric Identifier */
338ee385855SLuis Carlos Cobo 	u8 mesh_pm_id[4];
339ee385855SLuis Carlos Cobo 	/* Congestion Control Mode Identifier */
340ee385855SLuis Carlos Cobo 	u8 mesh_cc_id[4];
341ee385855SLuis Carlos Cobo 	/* Local mesh Destination Sequence Number */
342ee385855SLuis Carlos Cobo 	u32 dsn;
343ee385855SLuis Carlos Cobo 	/* Last used PREQ ID */
344ee385855SLuis Carlos Cobo 	u32 preq_id;
345ee385855SLuis Carlos Cobo 	atomic_t mpaths;
346ee385855SLuis Carlos Cobo 	/* Timestamp of last DSN update */
347ee385855SLuis Carlos Cobo 	unsigned long last_dsn_update;
348ee385855SLuis Carlos Cobo 	/* Timestamp of last DSN sent */
349ee385855SLuis Carlos Cobo 	unsigned long last_preq;
350ee385855SLuis Carlos Cobo 	struct mesh_rmc *rmc;
351ee385855SLuis Carlos Cobo 	spinlock_t mesh_preq_queue_lock;
352ee385855SLuis Carlos Cobo 	struct mesh_preq_queue preq_queue;
353ee385855SLuis Carlos Cobo 	int preq_queue_len;
354ee385855SLuis Carlos Cobo 	struct mesh_stats mshstats;
355ee385855SLuis Carlos Cobo 	struct mesh_config mshcfg;
356ee385855SLuis Carlos Cobo 	u8 mesh_seqnum[3];
357ee385855SLuis Carlos Cobo #endif
358f0706e82SJiri Benc 	u16 aid;
359f0706e82SJiri Benc 	u16 ap_capab, capab;
360f0706e82SJiri Benc 	u8 *extra_ie; /* to be added to the end of AssocReq */
361f0706e82SJiri Benc 	size_t extra_ie_len;
362f0706e82SJiri Benc 
363f0706e82SJiri Benc 	/* The last AssocReq/Resp IEs */
364f0706e82SJiri Benc 	u8 *assocreq_ies, *assocresp_ies;
365f0706e82SJiri Benc 	size_t assocreq_ies_len, assocresp_ies_len;
366f0706e82SJiri Benc 
367f0706e82SJiri Benc 	int auth_tries, assoc_tries;
368f0706e82SJiri Benc 
369d6f2da5bSJiri Slaby 	unsigned int flags;
370f0706e82SJiri Benc #define IEEE80211_STA_REQ_SCAN 0
371f0706e82SJiri Benc #define IEEE80211_STA_REQ_AUTH 1
372f0706e82SJiri Benc #define IEEE80211_STA_REQ_RUN  2
373f0706e82SJiri Benc 	unsigned long request;
374f0706e82SJiri Benc 	struct sk_buff_head skb_queue;
375f0706e82SJiri Benc 
376f0706e82SJiri Benc 	unsigned long last_probe;
377f0706e82SJiri Benc 
378f0706e82SJiri Benc #define IEEE80211_AUTH_ALG_OPEN BIT(0)
379f0706e82SJiri Benc #define IEEE80211_AUTH_ALG_SHARED_KEY BIT(1)
380f0706e82SJiri Benc #define IEEE80211_AUTH_ALG_LEAP BIT(2)
381f0706e82SJiri Benc 	unsigned int auth_algs; /* bitfield of allowed auth algs */
382f0706e82SJiri Benc 	int auth_alg; /* currently used IEEE 802.11 authentication algorithm */
383f0706e82SJiri Benc 	int auth_transaction;
384f0706e82SJiri Benc 
385f0706e82SJiri Benc 	unsigned long ibss_join_req;
386f0706e82SJiri Benc 	struct sk_buff *probe_resp; /* ProbeResp template for IBSS */
3878318d78aSJohannes Berg 	u32 supp_rates_bits[IEEE80211_NUM_BANDS];
388f0706e82SJiri Benc 
389f0706e82SJiri Benc 	int wmm_last_param_set;
390ee385855SLuis Carlos Cobo 	int num_beacons; /* number of TXed beacon frames by this STA */
391f0706e82SJiri Benc };
392f0706e82SJiri Benc 
393902acc78SJohannes Berg static inline void ieee80211_if_sta_set_mesh_id(struct ieee80211_if_sta *ifsta,
394902acc78SJohannes Berg 						u8 mesh_id_len, u8 *mesh_id)
395902acc78SJohannes Berg {
396902acc78SJohannes Berg #ifdef CONFIG_MAC80211_MESH
397902acc78SJohannes Berg 	ifsta->mesh_id_len = mesh_id_len;
398902acc78SJohannes Berg 	memcpy(ifsta->mesh_id, mesh_id, mesh_id_len);
399902acc78SJohannes Berg #endif
400902acc78SJohannes Berg }
401902acc78SJohannes Berg 
402902acc78SJohannes Berg #ifdef CONFIG_MAC80211_MESH
403902acc78SJohannes Berg #define IEEE80211_IFSTA_MESH_CTR_INC(sta, name)	\
404902acc78SJohannes Berg 	do { (sta)->mshstats.name++; } while (0)
405902acc78SJohannes Berg #else
406902acc78SJohannes Berg #define IEEE80211_IFSTA_MESH_CTR_INC(sta, name) \
407902acc78SJohannes Berg 	do { } while (0)
408902acc78SJohannes Berg #endif
409f0706e82SJiri Benc 
41013262ffdSJiri Slaby /* flags used in struct ieee80211_sub_if_data.flags */
41113262ffdSJiri Slaby #define IEEE80211_SDATA_ALLMULTI	BIT(0)
41213262ffdSJiri Slaby #define IEEE80211_SDATA_PROMISC		BIT(1)
413471b3efdSJohannes Berg #define IEEE80211_SDATA_USERSPACE_MLME	BIT(2)
4148318d78aSJohannes Berg #define IEEE80211_SDATA_OPERATING_GMODE	BIT(3)
415f0706e82SJiri Benc struct ieee80211_sub_if_data {
416f0706e82SJiri Benc 	struct list_head list;
417f0706e82SJiri Benc 
418f0706e82SJiri Benc 	struct wireless_dev wdev;
419f0706e82SJiri Benc 
42011a843b7SJohannes Berg 	/* keys */
42111a843b7SJohannes Berg 	struct list_head key_list;
42211a843b7SJohannes Berg 
423f0706e82SJiri Benc 	struct net_device *dev;
424f0706e82SJiri Benc 	struct ieee80211_local *local;
425f0706e82SJiri Benc 
42613262ffdSJiri Slaby 	unsigned int flags;
4277e9ed188SDaniel Drake 
428f0706e82SJiri Benc 	int drop_unencrypted;
429f0706e82SJiri Benc 
4308318d78aSJohannes Berg 	/*
4318318d78aSJohannes Berg 	 * basic rates of this AP or the AP we're associated to
4328318d78aSJohannes Berg 	 */
4338318d78aSJohannes Berg 	u64 basic_rates;
4348318d78aSJohannes Berg 
435f0706e82SJiri Benc 	u16 sequence;
436f0706e82SJiri Benc 
437f0706e82SJiri Benc 	/* Fragment table for host-based reassembly */
438f0706e82SJiri Benc 	struct ieee80211_fragment_entry	fragments[IEEE80211_FRAGMENT_MAX];
439f0706e82SJiri Benc 	unsigned int fragment_next;
440f0706e82SJiri Benc 
441f0706e82SJiri Benc #define NUM_DEFAULT_KEYS 4
442f0706e82SJiri Benc 	struct ieee80211_key *keys[NUM_DEFAULT_KEYS];
443f0706e82SJiri Benc 	struct ieee80211_key *default_key;
444f0706e82SJiri Benc 
445471b3efdSJohannes Berg 	/*
446471b3efdSJohannes Berg 	 * BSS configuration for this interface.
447471b3efdSJohannes Berg 	 *
448471b3efdSJohannes Berg 	 * FIXME: I feel bad putting this here when we already have a
449471b3efdSJohannes Berg 	 *	  bss pointer, but the bss pointer is just wrong when
450471b3efdSJohannes Berg 	 *	  you have multiple virtual STA mode interfaces...
451471b3efdSJohannes Berg 	 *	  This needs to be fixed.
452471b3efdSJohannes Berg 	 */
453471b3efdSJohannes Berg 	struct ieee80211_bss_conf bss_conf;
454f0706e82SJiri Benc 	struct ieee80211_if_ap *bss; /* BSS that this device belongs to */
455f0706e82SJiri Benc 
456f0706e82SJiri Benc 	union {
457f0706e82SJiri Benc 		struct ieee80211_if_ap ap;
458f0706e82SJiri Benc 		struct ieee80211_if_wds wds;
459f0706e82SJiri Benc 		struct ieee80211_if_vlan vlan;
460f0706e82SJiri Benc 		struct ieee80211_if_sta sta;
4618cc9a739SMichael Wu 		u32 mntr_flags;
462f0706e82SJiri Benc 	} u;
463f0706e82SJiri Benc 	int channel_use;
464f0706e82SJiri Benc 	int channel_use_raw;
465e9f207f0SJiri Benc 
466e9f207f0SJiri Benc #ifdef CONFIG_MAC80211_DEBUGFS
467e9f207f0SJiri Benc 	struct dentry *debugfsdir;
468e9f207f0SJiri Benc 	union {
469e9f207f0SJiri Benc 		struct {
470e9f207f0SJiri Benc 			struct dentry *channel_use;
471e9f207f0SJiri Benc 			struct dentry *drop_unencrypted;
472e9f207f0SJiri Benc 			struct dentry *state;
473e9f207f0SJiri Benc 			struct dentry *bssid;
474e9f207f0SJiri Benc 			struct dentry *prev_bssid;
475e9f207f0SJiri Benc 			struct dentry *ssid_len;
476e9f207f0SJiri Benc 			struct dentry *aid;
477e9f207f0SJiri Benc 			struct dentry *ap_capab;
478e9f207f0SJiri Benc 			struct dentry *capab;
479e9f207f0SJiri Benc 			struct dentry *extra_ie_len;
480e9f207f0SJiri Benc 			struct dentry *auth_tries;
481e9f207f0SJiri Benc 			struct dentry *assoc_tries;
482e9f207f0SJiri Benc 			struct dentry *auth_algs;
483e9f207f0SJiri Benc 			struct dentry *auth_alg;
484e9f207f0SJiri Benc 			struct dentry *auth_transaction;
485e9f207f0SJiri Benc 			struct dentry *flags;
486ee385855SLuis Carlos Cobo 			struct dentry *num_beacons_sta;
487e9f207f0SJiri Benc 		} sta;
488e9f207f0SJiri Benc 		struct {
489e9f207f0SJiri Benc 			struct dentry *channel_use;
490e9f207f0SJiri Benc 			struct dentry *drop_unencrypted;
491e9f207f0SJiri Benc 			struct dentry *num_sta_ps;
492e9f207f0SJiri Benc 			struct dentry *dtim_count;
493e9f207f0SJiri Benc 			struct dentry *num_beacons;
494e9f207f0SJiri Benc 			struct dentry *force_unicast_rateidx;
495e9f207f0SJiri Benc 			struct dentry *max_ratectrl_rateidx;
496e9f207f0SJiri Benc 			struct dentry *num_buffered_multicast;
497e9f207f0SJiri Benc 		} ap;
498e9f207f0SJiri Benc 		struct {
499e9f207f0SJiri Benc 			struct dentry *channel_use;
500e9f207f0SJiri Benc 			struct dentry *drop_unencrypted;
501e9f207f0SJiri Benc 			struct dentry *peer;
502e9f207f0SJiri Benc 		} wds;
503e9f207f0SJiri Benc 		struct {
504e9f207f0SJiri Benc 			struct dentry *channel_use;
505e9f207f0SJiri Benc 			struct dentry *drop_unencrypted;
506e9f207f0SJiri Benc 		} vlan;
507e9f207f0SJiri Benc 		struct {
508e9f207f0SJiri Benc 			struct dentry *mode;
509e9f207f0SJiri Benc 		} monitor;
510e9f207f0SJiri Benc 		struct dentry *default_key;
511e9f207f0SJiri Benc 	} debugfs;
512ee385855SLuis Carlos Cobo 
513ee385855SLuis Carlos Cobo #ifdef CONFIG_MAC80211_MESH
514ee385855SLuis Carlos Cobo 	struct dentry *mesh_stats_dir;
515ee385855SLuis Carlos Cobo 	struct {
516ee385855SLuis Carlos Cobo 		struct dentry *fwded_frames;
517ee385855SLuis Carlos Cobo 		struct dentry *dropped_frames_ttl;
518ee385855SLuis Carlos Cobo 		struct dentry *dropped_frames_no_route;
519ee385855SLuis Carlos Cobo 		struct dentry *estab_plinks;
520ee385855SLuis Carlos Cobo 		struct timer_list mesh_path_timer;
521ee385855SLuis Carlos Cobo 	} mesh_stats;
522ee385855SLuis Carlos Cobo 
523ee385855SLuis Carlos Cobo 	struct dentry *mesh_config_dir;
524ee385855SLuis Carlos Cobo 	struct {
525ee385855SLuis Carlos Cobo 		struct dentry *dot11MeshRetryTimeout;
526ee385855SLuis Carlos Cobo 		struct dentry *dot11MeshConfirmTimeout;
527ee385855SLuis Carlos Cobo 		struct dentry *dot11MeshHoldingTimeout;
528ee385855SLuis Carlos Cobo 		struct dentry *dot11MeshMaxRetries;
529ee385855SLuis Carlos Cobo 		struct dentry *dot11MeshTTL;
530ee385855SLuis Carlos Cobo 		struct dentry *auto_open_plinks;
531ee385855SLuis Carlos Cobo 		struct dentry *dot11MeshMaxPeerLinks;
532ee385855SLuis Carlos Cobo 		struct dentry *dot11MeshHWMPactivePathTimeout;
533ee385855SLuis Carlos Cobo 		struct dentry *dot11MeshHWMPpreqMinInterval;
534ee385855SLuis Carlos Cobo 		struct dentry *dot11MeshHWMPnetDiameterTraversalTime;
535ee385855SLuis Carlos Cobo 		struct dentry *dot11MeshHWMPmaxPREQretries;
536ee385855SLuis Carlos Cobo 		struct dentry *path_refresh_time;
537ee385855SLuis Carlos Cobo 		struct dentry *min_discovery_timeout;
538ee385855SLuis Carlos Cobo 	} mesh_config;
539ee385855SLuis Carlos Cobo #endif
540ee385855SLuis Carlos Cobo 
541e9f207f0SJiri Benc #endif
54232bfd35dSJohannes Berg 	/* must be last, dynamically sized area in this! */
54332bfd35dSJohannes Berg 	struct ieee80211_vif vif;
544f0706e82SJiri Benc };
545f0706e82SJiri Benc 
54632bfd35dSJohannes Berg static inline
54732bfd35dSJohannes Berg struct ieee80211_sub_if_data *vif_to_sdata(struct ieee80211_vif *p)
54832bfd35dSJohannes Berg {
54932bfd35dSJohannes Berg 	return container_of(p, struct ieee80211_sub_if_data, vif);
55032bfd35dSJohannes Berg }
55132bfd35dSJohannes Berg 
552f0706e82SJiri Benc #define IEEE80211_DEV_TO_SUB_IF(dev) netdev_priv(dev)
553f0706e82SJiri Benc 
554f0706e82SJiri Benc enum {
555f0706e82SJiri Benc 	IEEE80211_RX_MSG	= 1,
556f0706e82SJiri Benc 	IEEE80211_TX_STATUS_MSG	= 2,
557eadc8d9eSRon Rindjunsky 	IEEE80211_DELBA_MSG	= 3,
558eadc8d9eSRon Rindjunsky 	IEEE80211_ADDBA_MSG	= 4,
559f0706e82SJiri Benc };
560f0706e82SJiri Benc 
561f0706e82SJiri Benc struct ieee80211_local {
562f0706e82SJiri Benc 	/* embed the driver visible part.
563f0706e82SJiri Benc 	 * don't cast (use the static inlines below), but we keep
564f0706e82SJiri Benc 	 * it first anyway so they become a no-op */
565f0706e82SJiri Benc 	struct ieee80211_hw hw;
566f0706e82SJiri Benc 
567f0706e82SJiri Benc 	const struct ieee80211_ops *ops;
568f0706e82SJiri Benc 
569f0706e82SJiri Benc 	struct net_device *mdev; /* wmaster# - "master" 802.11 device */
570f0706e82SJiri Benc 	int open_count;
5713d30d949SMichael Wu 	int monitors, cooked_mntrs;
5728cc9a739SMichael Wu 	/* number of interfaces with corresponding FIF_ flags */
5738cc9a739SMichael Wu 	int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss;
5744150c572SJohannes Berg 	unsigned int filter_flags; /* FIF_* */
575f0706e82SJiri Benc 	struct iw_statistics wstats;
576f0706e82SJiri Benc 	u8 wstats_flags;
577d0709a65SJohannes Berg 	bool tim_in_locked_section; /* see ieee80211_beacon_get() */
578b306f453SJohannes Berg 	int tx_headroom; /* required headroom for hardware/radiotap */
579f0706e82SJiri Benc 
580f0706e82SJiri Benc 	enum {
581f0706e82SJiri Benc 		IEEE80211_DEV_UNINITIALIZED = 0,
582f0706e82SJiri Benc 		IEEE80211_DEV_REGISTERED,
583f0706e82SJiri Benc 		IEEE80211_DEV_UNREGISTERED,
584f0706e82SJiri Benc 	} reg_state;
585f0706e82SJiri Benc 
586f0706e82SJiri Benc 	/* Tasklet and skb queue to process calls from IRQ mode. All frames
587f0706e82SJiri Benc 	 * added to skb_queue will be processed, but frames in
588f0706e82SJiri Benc 	 * skb_queue_unreliable may be dropped if the total length of these
589f0706e82SJiri Benc 	 * queues increases over the limit. */
590f0706e82SJiri Benc #define IEEE80211_IRQSAFE_QUEUE_LIMIT 128
591f0706e82SJiri Benc 	struct tasklet_struct tasklet;
592f0706e82SJiri Benc 	struct sk_buff_head skb_queue;
593f0706e82SJiri Benc 	struct sk_buff_head skb_queue_unreliable;
594f0706e82SJiri Benc 
595d0709a65SJohannes Berg 	/* Station data */
596d0709a65SJohannes Berg 	/*
597d0709a65SJohannes Berg 	 * The lock only protects the list, hash, timer and counter
598d0709a65SJohannes Berg 	 * against manipulation, reads are done in RCU. Additionally,
599d0709a65SJohannes Berg 	 * the lock protects each BSS's TIM bitmap and a few items
600d0709a65SJohannes Berg 	 * in a STA info structure.
601d0709a65SJohannes Berg 	 */
602d0709a65SJohannes Berg 	spinlock_t sta_lock;
603d0709a65SJohannes Berg 	unsigned long num_sta;
604f0706e82SJiri Benc 	struct list_head sta_list;
605f0706e82SJiri Benc 	struct sta_info *sta_hash[STA_HASH_SIZE];
606f0706e82SJiri Benc 	struct timer_list sta_cleanup;
607f0706e82SJiri Benc 
6089e723492SRon Rindjunsky 	unsigned long state[NUM_TX_DATA_QUEUES_AMPDU];
6099e723492SRon Rindjunsky 	struct ieee80211_tx_stored_packet pending_packet[NUM_TX_DATA_QUEUES_AMPDU];
610f0706e82SJiri Benc 	struct tasklet_struct tx_pending_tasklet;
611f0706e82SJiri Benc 
612f0706e82SJiri Benc 	/* number of interfaces with corresponding IFF_ flags */
61353918994SJohannes Berg 	atomic_t iff_allmultis, iff_promiscs;
614f0706e82SJiri Benc 
615f0706e82SJiri Benc 	struct rate_control_ref *rate_ctrl;
616f0706e82SJiri Benc 
617f0706e82SJiri Benc 	int rts_threshold;
618f0706e82SJiri Benc 	int fragmentation_threshold;
619f0706e82SJiri Benc 	int short_retry_limit; /* dot11ShortRetryLimit */
620f0706e82SJiri Benc 	int long_retry_limit; /* dot11LongRetryLimit */
621f0706e82SJiri Benc 
622f0706e82SJiri Benc 	struct crypto_blkcipher *wep_tx_tfm;
623f0706e82SJiri Benc 	struct crypto_blkcipher *wep_rx_tfm;
624f0706e82SJiri Benc 	u32 wep_iv;
625f0706e82SJiri Benc 
626f0706e82SJiri Benc 	int bridge_packets; /* bridge packets between associated stations and
627f0706e82SJiri Benc 			     * deliver multicast frames both back to wireless
628f0706e82SJiri Benc 			     * media and to the local net stack */
629f0706e82SJiri Benc 
63079010420SJohannes Berg 	struct list_head interfaces;
63179010420SJohannes Berg 
632ece8edddSZhu Yi 	bool sta_sw_scanning;
633ece8edddSZhu Yi 	bool sta_hw_scanning;
634f0706e82SJiri Benc 	int scan_channel_idx;
6358318d78aSJohannes Berg 	enum ieee80211_band scan_band;
6368318d78aSJohannes Berg 
637f0706e82SJiri Benc 	enum { SCAN_SET_CHANNEL, SCAN_SEND_PROBE } scan_state;
638f0706e82SJiri Benc 	unsigned long last_scan_completed;
639f0706e82SJiri Benc 	struct delayed_work scan_work;
640f0706e82SJiri Benc 	struct net_device *scan_dev;
641f0706e82SJiri Benc 	struct ieee80211_channel *oper_channel, *scan_channel;
642f0706e82SJiri Benc 	u8 scan_ssid[IEEE80211_MAX_SSID_LEN];
643f0706e82SJiri Benc 	size_t scan_ssid_len;
644f0706e82SJiri Benc 	struct list_head sta_bss_list;
645f0706e82SJiri Benc 	struct ieee80211_sta_bss *sta_bss_hash[STA_HASH_SIZE];
646f0706e82SJiri Benc 	spinlock_t sta_bss_lock;
647f0706e82SJiri Benc 
648f0706e82SJiri Benc 	/* SNMP counters */
649f0706e82SJiri Benc 	/* dot11CountersTable */
650f0706e82SJiri Benc 	u32 dot11TransmittedFragmentCount;
651f0706e82SJiri Benc 	u32 dot11MulticastTransmittedFrameCount;
652f0706e82SJiri Benc 	u32 dot11FailedCount;
653f0706e82SJiri Benc 	u32 dot11RetryCount;
654f0706e82SJiri Benc 	u32 dot11MultipleRetryCount;
655f0706e82SJiri Benc 	u32 dot11FrameDuplicateCount;
656f0706e82SJiri Benc 	u32 dot11ReceivedFragmentCount;
657f0706e82SJiri Benc 	u32 dot11MulticastReceivedFrameCount;
658f0706e82SJiri Benc 	u32 dot11TransmittedFrameCount;
659f0706e82SJiri Benc 	u32 dot11WEPUndecryptableCount;
660f0706e82SJiri Benc 
661f0706e82SJiri Benc #ifdef CONFIG_MAC80211_LEDS
662f0706e82SJiri Benc 	int tx_led_counter, rx_led_counter;
663cdcb006fSIvo van Doorn 	struct led_trigger *tx_led, *rx_led, *assoc_led, *radio_led;
664cdcb006fSIvo van Doorn 	char tx_led_name[32], rx_led_name[32],
665cdcb006fSIvo van Doorn 	     assoc_led_name[32], radio_led_name[32];
666f0706e82SJiri Benc #endif
667f0706e82SJiri Benc 
668f0706e82SJiri Benc 	u32 channel_use;
669f0706e82SJiri Benc 	u32 channel_use_raw;
670f0706e82SJiri Benc 
671e9f207f0SJiri Benc #ifdef CONFIG_MAC80211_DEBUGFS
672e9f207f0SJiri Benc 	struct work_struct sta_debugfs_add;
673e9f207f0SJiri Benc #endif
674e9f207f0SJiri Benc 
675f0706e82SJiri Benc #ifdef CONFIG_MAC80211_DEBUG_COUNTERS
676f0706e82SJiri Benc 	/* TX/RX handler statistics */
677f0706e82SJiri Benc 	unsigned int tx_handlers_drop;
678f0706e82SJiri Benc 	unsigned int tx_handlers_queued;
679f0706e82SJiri Benc 	unsigned int tx_handlers_drop_unencrypted;
680f0706e82SJiri Benc 	unsigned int tx_handlers_drop_fragment;
681f0706e82SJiri Benc 	unsigned int tx_handlers_drop_wep;
682f0706e82SJiri Benc 	unsigned int tx_handlers_drop_not_assoc;
683f0706e82SJiri Benc 	unsigned int tx_handlers_drop_unauth_port;
684f0706e82SJiri Benc 	unsigned int rx_handlers_drop;
685f0706e82SJiri Benc 	unsigned int rx_handlers_queued;
686f0706e82SJiri Benc 	unsigned int rx_handlers_drop_nullfunc;
687f0706e82SJiri Benc 	unsigned int rx_handlers_drop_defrag;
688f0706e82SJiri Benc 	unsigned int rx_handlers_drop_short;
689f0706e82SJiri Benc 	unsigned int rx_handlers_drop_passive_scan;
690f0706e82SJiri Benc 	unsigned int tx_expand_skb_head;
691f0706e82SJiri Benc 	unsigned int tx_expand_skb_head_cloned;
692f0706e82SJiri Benc 	unsigned int rx_expand_skb_head;
693f0706e82SJiri Benc 	unsigned int rx_expand_skb_head2;
694f0706e82SJiri Benc 	unsigned int rx_handlers_fragments;
695f0706e82SJiri Benc 	unsigned int tx_status_drop;
696f0706e82SJiri Benc 	unsigned int wme_rx_queue[NUM_RX_DATA_QUEUES];
697f0706e82SJiri Benc 	unsigned int wme_tx_queue[NUM_RX_DATA_QUEUES];
698f0706e82SJiri Benc #define I802_DEBUG_INC(c) (c)++
699f0706e82SJiri Benc #else /* CONFIG_MAC80211_DEBUG_COUNTERS */
700f0706e82SJiri Benc #define I802_DEBUG_INC(c) do { } while (0)
701f0706e82SJiri Benc #endif /* CONFIG_MAC80211_DEBUG_COUNTERS */
702f0706e82SJiri Benc 
703f0706e82SJiri Benc 
704f0706e82SJiri Benc 	int total_ps_buffered; /* total number of all buffered unicast and
705f0706e82SJiri Benc 				* multicast packets for power saving stations
706f0706e82SJiri Benc 				*/
707f0706e82SJiri Benc 	int wifi_wme_noack_test;
708f0706e82SJiri Benc 	unsigned int wmm_acm; /* bit field of ACM bits (BIT(802.1D tag)) */
709f0706e82SJiri Benc 
710e9f207f0SJiri Benc #ifdef CONFIG_MAC80211_DEBUGFS
711e9f207f0SJiri Benc 	struct local_debugfsdentries {
712e9f207f0SJiri Benc 		struct dentry *frequency;
713e9f207f0SJiri Benc 		struct dentry *antenna_sel_tx;
714e9f207f0SJiri Benc 		struct dentry *antenna_sel_rx;
715e9f207f0SJiri Benc 		struct dentry *bridge_packets;
716e9f207f0SJiri Benc 		struct dentry *rts_threshold;
717e9f207f0SJiri Benc 		struct dentry *fragmentation_threshold;
718e9f207f0SJiri Benc 		struct dentry *short_retry_limit;
719e9f207f0SJiri Benc 		struct dentry *long_retry_limit;
720e9f207f0SJiri Benc 		struct dentry *total_ps_buffered;
721e9f207f0SJiri Benc 		struct dentry *wep_iv;
722e9f207f0SJiri Benc 		struct dentry *statistics;
723e9f207f0SJiri Benc 		struct local_debugfsdentries_statsdentries {
724e9f207f0SJiri Benc 			struct dentry *transmitted_fragment_count;
725e9f207f0SJiri Benc 			struct dentry *multicast_transmitted_frame_count;
726e9f207f0SJiri Benc 			struct dentry *failed_count;
727e9f207f0SJiri Benc 			struct dentry *retry_count;
728e9f207f0SJiri Benc 			struct dentry *multiple_retry_count;
729e9f207f0SJiri Benc 			struct dentry *frame_duplicate_count;
730e9f207f0SJiri Benc 			struct dentry *received_fragment_count;
731e9f207f0SJiri Benc 			struct dentry *multicast_received_frame_count;
732e9f207f0SJiri Benc 			struct dentry *transmitted_frame_count;
733e9f207f0SJiri Benc 			struct dentry *wep_undecryptable_count;
734e9f207f0SJiri Benc 			struct dentry *num_scans;
735e9f207f0SJiri Benc #ifdef CONFIG_MAC80211_DEBUG_COUNTERS
736e9f207f0SJiri Benc 			struct dentry *tx_handlers_drop;
737e9f207f0SJiri Benc 			struct dentry *tx_handlers_queued;
738e9f207f0SJiri Benc 			struct dentry *tx_handlers_drop_unencrypted;
739e9f207f0SJiri Benc 			struct dentry *tx_handlers_drop_fragment;
740e9f207f0SJiri Benc 			struct dentry *tx_handlers_drop_wep;
741e9f207f0SJiri Benc 			struct dentry *tx_handlers_drop_not_assoc;
742e9f207f0SJiri Benc 			struct dentry *tx_handlers_drop_unauth_port;
743e9f207f0SJiri Benc 			struct dentry *rx_handlers_drop;
744e9f207f0SJiri Benc 			struct dentry *rx_handlers_queued;
745e9f207f0SJiri Benc 			struct dentry *rx_handlers_drop_nullfunc;
746e9f207f0SJiri Benc 			struct dentry *rx_handlers_drop_defrag;
747e9f207f0SJiri Benc 			struct dentry *rx_handlers_drop_short;
748e9f207f0SJiri Benc 			struct dentry *rx_handlers_drop_passive_scan;
749e9f207f0SJiri Benc 			struct dentry *tx_expand_skb_head;
750e9f207f0SJiri Benc 			struct dentry *tx_expand_skb_head_cloned;
751e9f207f0SJiri Benc 			struct dentry *rx_expand_skb_head;
752e9f207f0SJiri Benc 			struct dentry *rx_expand_skb_head2;
753e9f207f0SJiri Benc 			struct dentry *rx_handlers_fragments;
754e9f207f0SJiri Benc 			struct dentry *tx_status_drop;
755e9f207f0SJiri Benc 			struct dentry *wme_tx_queue;
756e9f207f0SJiri Benc 			struct dentry *wme_rx_queue;
757e9f207f0SJiri Benc #endif
758e9f207f0SJiri Benc 			struct dentry *dot11ACKFailureCount;
759e9f207f0SJiri Benc 			struct dentry *dot11RTSFailureCount;
760e9f207f0SJiri Benc 			struct dentry *dot11FCSErrorCount;
761e9f207f0SJiri Benc 			struct dentry *dot11RTSSuccessCount;
762e9f207f0SJiri Benc 		} stats;
763e9f207f0SJiri Benc 		struct dentry *stations;
764e9f207f0SJiri Benc 		struct dentry *keys;
765e9f207f0SJiri Benc 	} debugfs;
766e9f207f0SJiri Benc #endif
767f0706e82SJiri Benc };
768f0706e82SJiri Benc 
769eadc8d9eSRon Rindjunsky /* this struct represents 802.11n's RA/TID combination */
770eadc8d9eSRon Rindjunsky struct ieee80211_ra_tid {
771eadc8d9eSRon Rindjunsky 	u8 ra[ETH_ALEN];
772eadc8d9eSRon Rindjunsky 	u16 tid;
773eadc8d9eSRon Rindjunsky };
774eadc8d9eSRon Rindjunsky 
775ee385855SLuis Carlos Cobo /* Parsed Information Elements */
776ee385855SLuis Carlos Cobo struct ieee802_11_elems {
777ee385855SLuis Carlos Cobo 	/* pointers to IEs */
778ee385855SLuis Carlos Cobo 	u8 *ssid;
779ee385855SLuis Carlos Cobo 	u8 *supp_rates;
780ee385855SLuis Carlos Cobo 	u8 *fh_params;
781ee385855SLuis Carlos Cobo 	u8 *ds_params;
782ee385855SLuis Carlos Cobo 	u8 *cf_params;
783ee385855SLuis Carlos Cobo 	u8 *tim;
784ee385855SLuis Carlos Cobo 	u8 *ibss_params;
785ee385855SLuis Carlos Cobo 	u8 *challenge;
786ee385855SLuis Carlos Cobo 	u8 *wpa;
787ee385855SLuis Carlos Cobo 	u8 *rsn;
788ee385855SLuis Carlos Cobo 	u8 *erp_info;
789ee385855SLuis Carlos Cobo 	u8 *ext_supp_rates;
790ee385855SLuis Carlos Cobo 	u8 *wmm_info;
791ee385855SLuis Carlos Cobo 	u8 *wmm_param;
792ee385855SLuis Carlos Cobo 	u8 *ht_cap_elem;
793ee385855SLuis Carlos Cobo 	u8 *ht_info_elem;
794ee385855SLuis Carlos Cobo 	u8 *mesh_config;
795ee385855SLuis Carlos Cobo 	u8 *mesh_id;
796ee385855SLuis Carlos Cobo 	u8 *peer_link;
797ee385855SLuis Carlos Cobo 	u8 *preq;
798ee385855SLuis Carlos Cobo 	u8 *prep;
799ee385855SLuis Carlos Cobo 	u8 *perr;
800ee385855SLuis Carlos Cobo 
801ee385855SLuis Carlos Cobo 	/* length of them, respectively */
802ee385855SLuis Carlos Cobo 	u8 ssid_len;
803ee385855SLuis Carlos Cobo 	u8 supp_rates_len;
804ee385855SLuis Carlos Cobo 	u8 fh_params_len;
805ee385855SLuis Carlos Cobo 	u8 ds_params_len;
806ee385855SLuis Carlos Cobo 	u8 cf_params_len;
807ee385855SLuis Carlos Cobo 	u8 tim_len;
808ee385855SLuis Carlos Cobo 	u8 ibss_params_len;
809ee385855SLuis Carlos Cobo 	u8 challenge_len;
810ee385855SLuis Carlos Cobo 	u8 wpa_len;
811ee385855SLuis Carlos Cobo 	u8 rsn_len;
812ee385855SLuis Carlos Cobo 	u8 erp_info_len;
813ee385855SLuis Carlos Cobo 	u8 ext_supp_rates_len;
814ee385855SLuis Carlos Cobo 	u8 wmm_info_len;
815ee385855SLuis Carlos Cobo 	u8 wmm_param_len;
816ee385855SLuis Carlos Cobo 	u8 ht_cap_elem_len;
817ee385855SLuis Carlos Cobo 	u8 ht_info_elem_len;
818ee385855SLuis Carlos Cobo 	u8 mesh_config_len;
819ee385855SLuis Carlos Cobo 	u8 mesh_id_len;
820ee385855SLuis Carlos Cobo 	u8 peer_link_len;
821ee385855SLuis Carlos Cobo 	u8 preq_len;
822ee385855SLuis Carlos Cobo 	u8 prep_len;
823ee385855SLuis Carlos Cobo 	u8 perr_len;
824ee385855SLuis Carlos Cobo };
825ee385855SLuis Carlos Cobo 
826f0706e82SJiri Benc static inline struct ieee80211_local *hw_to_local(
827f0706e82SJiri Benc 	struct ieee80211_hw *hw)
828f0706e82SJiri Benc {
829f0706e82SJiri Benc 	return container_of(hw, struct ieee80211_local, hw);
830f0706e82SJiri Benc }
831f0706e82SJiri Benc 
832f0706e82SJiri Benc static inline struct ieee80211_hw *local_to_hw(
833f0706e82SJiri Benc 	struct ieee80211_local *local)
834f0706e82SJiri Benc {
835f0706e82SJiri Benc 	return &local->hw;
836f0706e82SJiri Benc }
837f0706e82SJiri Benc 
838f0706e82SJiri Benc enum ieee80211_link_state_t {
839f0706e82SJiri Benc 	IEEE80211_LINK_STATE_XOFF = 0,
840f0706e82SJiri Benc 	IEEE80211_LINK_STATE_PENDING,
841f0706e82SJiri Benc };
842f0706e82SJiri Benc 
843f0706e82SJiri Benc struct sta_attribute {
844f0706e82SJiri Benc 	struct attribute attr;
845f0706e82SJiri Benc 	ssize_t (*show)(const struct sta_info *, char *buf);
846f0706e82SJiri Benc 	ssize_t (*store)(struct sta_info *, const char *buf, size_t count);
847f0706e82SJiri Benc };
848f0706e82SJiri Benc 
849571ecf67SJohannes Berg static inline int ieee80211_bssid_match(const u8 *raddr, const u8 *addr)
850571ecf67SJohannes Berg {
851571ecf67SJohannes Berg 	return compare_ether_addr(raddr, addr) == 0 ||
852571ecf67SJohannes Berg 	       is_broadcast_ether_addr(raddr);
853571ecf67SJohannes Berg }
854571ecf67SJohannes Berg 
855571ecf67SJohannes Berg 
856f0706e82SJiri Benc /* ieee80211.c */
857f0706e82SJiri Benc int ieee80211_hw_config(struct ieee80211_local *local);
858f0706e82SJiri Benc int ieee80211_if_config(struct net_device *dev);
859f0706e82SJiri Benc int ieee80211_if_config_beacon(struct net_device *dev);
8605cf121c3SJohannes Berg void ieee80211_tx_set_protected(struct ieee80211_tx_data *tx);
861f0706e82SJiri Benc int ieee80211_if_update_wds(struct net_device *dev, u8 *remote_addr);
862f0706e82SJiri Benc void ieee80211_if_setup(struct net_device *dev);
863d3c990fbSRon Rindjunsky int ieee80211_hw_config_ht(struct ieee80211_local *local, int enable_ht,
864d3c990fbSRon Rindjunsky 			   struct ieee80211_ht_info *req_ht_cap,
865d3c990fbSRon Rindjunsky 			   struct ieee80211_ht_bss_info *req_bss_cap);
866f0706e82SJiri Benc 
867f0706e82SJiri Benc /* ieee80211_ioctl.c */
868f0706e82SJiri Benc extern const struct iw_handler_def ieee80211_iw_handler_def;
869f0706e82SJiri Benc 
870f0706e82SJiri Benc 
871f0706e82SJiri Benc /* Least common multiple of the used rates (in 100 kbps). This is used to
872f0706e82SJiri Benc  * calculate rate_inv values for each rate so that only integers are needed. */
873f0706e82SJiri Benc #define CHAN_UTIL_RATE_LCM 95040
874f0706e82SJiri Benc /* 1 usec is 1/8 * (95040/10) = 1188 */
875f0706e82SJiri Benc #define CHAN_UTIL_PER_USEC 1188
876f0706e82SJiri Benc /* Amount of bits to shift the result right to scale the total utilization
877f0706e82SJiri Benc  * to values that will not wrap around 32-bit integers. */
878f0706e82SJiri Benc #define CHAN_UTIL_SHIFT 9
879f0706e82SJiri Benc /* Theoretical maximum of channel utilization counter in 10 ms (stat_time=1):
880f0706e82SJiri Benc  * (CHAN_UTIL_PER_USEC * 10000) >> CHAN_UTIL_SHIFT = 23203. So dividing the
881f0706e82SJiri Benc  * raw value with about 23 should give utilization in 10th of a percentage
882f0706e82SJiri Benc  * (1/1000). However, utilization is only estimated and not all intervals
883f0706e82SJiri Benc  * between frames etc. are calculated. 18 seems to give numbers that are closer
884f0706e82SJiri Benc  * to the real maximum. */
885f0706e82SJiri Benc #define CHAN_UTIL_PER_10MS 18
886f0706e82SJiri Benc #define CHAN_UTIL_HDR_LONG (202 * CHAN_UTIL_PER_USEC)
887f0706e82SJiri Benc #define CHAN_UTIL_HDR_SHORT (40 * CHAN_UTIL_PER_USEC)
888f0706e82SJiri Benc 
889f0706e82SJiri Benc 
890f0706e82SJiri Benc /* ieee80211_ioctl.c */
891f0706e82SJiri Benc int ieee80211_set_compression(struct ieee80211_local *local,
892f0706e82SJiri Benc 			      struct net_device *dev, struct sta_info *sta);
8938318d78aSJohannes Berg int ieee80211_set_freq(struct ieee80211_local *local, int freq);
894f0706e82SJiri Benc /* ieee80211_sta.c */
895ee385855SLuis Carlos Cobo #define IEEE80211_FC(type, stype) cpu_to_le16(type | stype)
896f0706e82SJiri Benc void ieee80211_sta_timer(unsigned long data);
897f0706e82SJiri Benc void ieee80211_sta_work(struct work_struct *work);
898f0706e82SJiri Benc void ieee80211_sta_scan_work(struct work_struct *work);
899f0706e82SJiri Benc void ieee80211_sta_rx_mgmt(struct net_device *dev, struct sk_buff *skb,
900f0706e82SJiri Benc 			   struct ieee80211_rx_status *rx_status);
901f0706e82SJiri Benc int ieee80211_sta_set_ssid(struct net_device *dev, char *ssid, size_t len);
902f0706e82SJiri Benc int ieee80211_sta_get_ssid(struct net_device *dev, char *ssid, size_t *len);
903f0706e82SJiri Benc int ieee80211_sta_set_bssid(struct net_device *dev, u8 *bssid);
904f0706e82SJiri Benc int ieee80211_sta_req_scan(struct net_device *dev, u8 *ssid, size_t ssid_len);
905f0706e82SJiri Benc void ieee80211_sta_req_auth(struct net_device *dev,
906f0706e82SJiri Benc 			    struct ieee80211_if_sta *ifsta);
907f0706e82SJiri Benc int ieee80211_sta_scan_results(struct net_device *dev, char *buf, size_t len);
9089ae54c84SJohannes Berg ieee80211_rx_result ieee80211_sta_rx_scan(
9099ae54c84SJohannes Berg 	struct net_device *dev, struct sk_buff *skb,
910f0706e82SJiri Benc 	struct ieee80211_rx_status *rx_status);
911f0706e82SJiri Benc void ieee80211_rx_bss_list_init(struct net_device *dev);
912f0706e82SJiri Benc void ieee80211_rx_bss_list_deinit(struct net_device *dev);
913f0706e82SJiri Benc int ieee80211_sta_set_extra_ie(struct net_device *dev, char *ie, size_t len);
914f0706e82SJiri Benc struct sta_info * ieee80211_ibss_add_sta(struct net_device *dev,
915f0706e82SJiri Benc 					 struct sk_buff *skb, u8 *bssid,
916f0706e82SJiri Benc 					 u8 *addr);
917f0706e82SJiri Benc int ieee80211_sta_deauthenticate(struct net_device *dev, u16 reason);
918f0706e82SJiri Benc int ieee80211_sta_disassociate(struct net_device *dev, u16 reason);
919471b3efdSJohannes Berg void ieee80211_bss_info_change_notify(struct ieee80211_sub_if_data *sdata,
920471b3efdSJohannes Berg 				      u32 changed);
921d9430a32SDaniel Drake void ieee80211_reset_erp_info(struct net_device *dev);
922c7153508SRon Rindjunsky int ieee80211_ht_cap_ie_to_ht_info(struct ieee80211_ht_cap *ht_cap_ie,
923c7153508SRon Rindjunsky 				   struct ieee80211_ht_info *ht_info);
924c7153508SRon Rindjunsky int ieee80211_ht_addt_info_ie_to_ht_bss_info(
925c7153508SRon Rindjunsky 			struct ieee80211_ht_addt_info *ht_add_info_ie,
926c7153508SRon Rindjunsky 			struct ieee80211_ht_bss_info *bss_info);
927eadc8d9eSRon Rindjunsky void ieee80211_send_addba_request(struct net_device *dev, const u8 *da,
928eadc8d9eSRon Rindjunsky 				  u16 tid, u8 dialog_token, u16 start_seq_num,
929eadc8d9eSRon Rindjunsky 				  u16 agg_size, u16 timeout);
930eadc8d9eSRon Rindjunsky void ieee80211_send_delba(struct net_device *dev, const u8 *da, u16 tid,
931eadc8d9eSRon Rindjunsky 				u16 initiator, u16 reason_code);
93207db2183SRon Rindjunsky void ieee80211_sta_stop_rx_ba_session(struct net_device *dev, u8 *da,
93307db2183SRon Rindjunsky 				u16 tid, u16 initiator, u16 reason);
93407db2183SRon Rindjunsky void sta_rx_agg_session_timer_expired(unsigned long data);
935eadc8d9eSRon Rindjunsky void sta_addba_resp_timer_expired(unsigned long data);
936ee385855SLuis Carlos Cobo u64 ieee80211_sta_get_rates(struct ieee80211_local *local,
937ee385855SLuis Carlos Cobo 			    struct ieee802_11_elems *elems,
938ee385855SLuis Carlos Cobo 			    enum ieee80211_band band);
939ee385855SLuis Carlos Cobo void ieee80211_sta_tx(struct net_device *dev, struct sk_buff *skb,
940ee385855SLuis Carlos Cobo 		int encrypt);
941ee385855SLuis Carlos Cobo void ieee802_11_parse_elems(u8 *start, size_t len,
942ee385855SLuis Carlos Cobo 				   struct ieee802_11_elems *elems);
943ee385855SLuis Carlos Cobo 
944902acc78SJohannes Berg #ifdef CONFIG_MAC80211_MESH
945902acc78SJohannes Berg void ieee80211_start_mesh(struct net_device *dev);
946902acc78SJohannes Berg #else
947902acc78SJohannes Berg static inline void ieee80211_start_mesh(struct net_device *dev)
948902acc78SJohannes Berg {}
949902acc78SJohannes Berg #endif
950ee385855SLuis Carlos Cobo 
951f0706e82SJiri Benc /* ieee80211_iface.c */
952f0706e82SJiri Benc int ieee80211_if_add(struct net_device *dev, const char *name,
953ee385855SLuis Carlos Cobo 		     struct net_device **new_dev, int type,
954ee385855SLuis Carlos Cobo 		     struct vif_params *params);
955f0706e82SJiri Benc void ieee80211_if_set_type(struct net_device *dev, int type);
956f0706e82SJiri Benc void ieee80211_if_reinit(struct net_device *dev);
957f0706e82SJiri Benc void __ieee80211_if_del(struct ieee80211_local *local,
958f0706e82SJiri Benc 			struct ieee80211_sub_if_data *sdata);
959f0706e82SJiri Benc int ieee80211_if_remove(struct net_device *dev, const char *name, int id);
960f0706e82SJiri Benc void ieee80211_if_free(struct net_device *dev);
961f0706e82SJiri Benc void ieee80211_if_sdata_init(struct ieee80211_sub_if_data *sdata);
962f0706e82SJiri Benc 
963e2ebc74dSJohannes Berg /* tx handling */
964e2ebc74dSJohannes Berg void ieee80211_clear_tx_pending(struct ieee80211_local *local);
965e2ebc74dSJohannes Berg void ieee80211_tx_pending(unsigned long data);
966e2ebc74dSJohannes Berg int ieee80211_master_start_xmit(struct sk_buff *skb, struct net_device *dev);
967e2ebc74dSJohannes Berg int ieee80211_monitor_start_xmit(struct sk_buff *skb, struct net_device *dev);
968e2ebc74dSJohannes Berg int ieee80211_subif_start_xmit(struct sk_buff *skb, struct net_device *dev);
969e2ebc74dSJohannes Berg 
970c2d1560aSJohannes Berg /* utility functions/constants */
971c2d1560aSJohannes Berg extern void *mac80211_wiphy_privid; /* for wiphy privid */
972c2d1560aSJohannes Berg extern const unsigned char rfc1042_header[6];
973c2d1560aSJohannes Berg extern const unsigned char bridge_tunnel_header[6];
97471364716SRon Rindjunsky u8 *ieee80211_get_bssid(struct ieee80211_hdr *hdr, size_t len,
97571364716SRon Rindjunsky 			enum ieee80211_if_types type);
976c2d1560aSJohannes Berg int ieee80211_frame_duration(struct ieee80211_local *local, size_t len,
977c2d1560aSJohannes Berg 			     int rate, int erp, int short_preamble);
978eb063c17SJohannes Berg void mac80211_ev_michael_mic_failure(struct net_device *dev, int keyidx,
979eb063c17SJohannes Berg 				     struct ieee80211_hdr *hdr);
980f0706e82SJiri Benc 
981f0706e82SJiri Benc #endif /* IEEE80211_I_H */
982