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