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