cfg80211 API for channels/bitrates, mac80211 and driver conversion
[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
72
73struct ieee80211_sta_bss {
74 struct list_head list;
75 struct ieee80211_sta_bss *hnext;
76 atomic_t users;
77
78 u8 bssid[ETH_ALEN];
79 u8 ssid[IEEE80211_MAX_SSID_LEN];
80 size_t ssid_len;
81 u16 capability; /* host byte order */
8318d78a 82 enum ieee80211_band band;
f0706e82
JB
83 int freq;
84 int rssi, signal, noise;
85 u8 *wpa_ie;
86 size_t wpa_ie_len;
87 u8 *rsn_ie;
88 size_t rsn_ie_len;
89 u8 *wmm_ie;
90 size_t wmm_ie_len;
c7153508
RR
91 u8 *ht_ie;
92 size_t ht_ie_len;
f0706e82
JB
93#define IEEE80211_MAX_SUPP_RATES 32
94 u8 supp_rates[IEEE80211_MAX_SUPP_RATES];
95 size_t supp_rates_len;
96 int beacon_int;
97 u64 timestamp;
98
99 int probe_resp;
100 unsigned long last_update;
101
5628221c
DD
102 /* during assocation, we save an ERP value from a probe response so
103 * that we can feed ERP info to the driver when handling the
104 * association completes. these fields probably won't be up-to-date
105 * otherwise, you probably don't want to use them. */
106 int has_erp_value;
107 u8 erp_value;
f0706e82
JB
108};
109
110
111typedef enum {
112 TXRX_CONTINUE, TXRX_DROP, TXRX_QUEUED
113} ieee80211_txrx_result;
114
badffb72
JS
115/* flags used in struct ieee80211_txrx_data.flags */
116/* whether the MSDU was fragmented */
117#define IEEE80211_TXRXD_FRAGMENTED BIT(0)
118#define IEEE80211_TXRXD_TXUNICAST BIT(1)
119#define IEEE80211_TXRXD_TXPS_BUFFERED BIT(2)
120#define IEEE80211_TXRXD_TXPROBE_LAST_FRAG BIT(3)
121#define IEEE80211_TXRXD_RXIN_SCAN BIT(4)
122/* frame is destined to interface currently processed (incl. multicast frames) */
123#define IEEE80211_TXRXD_RXRA_MATCH BIT(5)
58d4185e 124#define IEEE80211_TXRXD_TX_INJECTED BIT(6)
64bd4b69 125#define IEEE80211_TXRXD_RX_AMSDU BIT(7)
f0706e82
JB
126struct ieee80211_txrx_data {
127 struct sk_buff *skb;
128 struct net_device *dev;
129 struct ieee80211_local *local;
130 struct ieee80211_sub_if_data *sdata;
131 struct sta_info *sta;
132 u16 fc, ethertype;
133 struct ieee80211_key *key;
badffb72 134 unsigned int flags;
f0706e82
JB
135 union {
136 struct {
137 struct ieee80211_tx_control *control;
8318d78a 138 struct ieee80211_channel *channel;
f0706e82
JB
139 struct ieee80211_rate *rate;
140 /* use this rate (if set) for last fragment; rate can
141 * be set to lower rate for the first fragments, e.g.,
142 * when using CTS protection with IEEE 802.11g. */
143 struct ieee80211_rate *last_frag_rate;
f0706e82
JB
144
145 /* Extra fragments (in addition to the first fragment
146 * in skb) */
147 int num_extra_frag;
148 struct sk_buff **extra_frag;
149 } tx;
150 struct {
151 struct ieee80211_rx_status *status;
8318d78a 152 struct ieee80211_rate *rate;
f0706e82
JB
153 int sent_ps_buffered;
154 int queue;
155 int load;
50741ae0
JB
156 u32 tkip_iv32;
157 u16 tkip_iv16;
f0706e82
JB
158 } rx;
159 } u;
160};
161
e8bf9649
JS
162/* flags used in struct ieee80211_tx_packet_data.flags */
163#define IEEE80211_TXPD_REQ_TX_STATUS BIT(0)
164#define IEEE80211_TXPD_DO_NOT_ENCRYPT BIT(1)
165#define IEEE80211_TXPD_REQUEUE BIT(2)
678f5f71 166#define IEEE80211_TXPD_EAPOL_FRAME BIT(3)
9e723492 167#define IEEE80211_TXPD_AMPDU BIT(4)
f0706e82
JB
168/* Stored in sk_buff->cb */
169struct ieee80211_tx_packet_data {
170 int ifindex;
171 unsigned long jiffies;
e8bf9649
JS
172 unsigned int flags;
173 u8 queue;
f0706e82
JB
174};
175
176struct ieee80211_tx_stored_packet {
177 struct ieee80211_tx_control control;
178 struct sk_buff *skb;
179 int num_extra_frag;
180 struct sk_buff **extra_frag;
f0706e82 181 struct ieee80211_rate *last_frag_rate;
badffb72 182 unsigned int last_frag_rate_ctrl_probe;
f0706e82
JB
183};
184
185typedef ieee80211_txrx_result (*ieee80211_tx_handler)
186(struct ieee80211_txrx_data *tx);
187
188typedef ieee80211_txrx_result (*ieee80211_rx_handler)
189(struct ieee80211_txrx_data *rx);
190
5dfdaf58
JB
191struct beacon_data {
192 u8 *head, *tail;
193 int head_len, tail_len;
194 int dtim_period;
195};
196
f0706e82 197struct ieee80211_if_ap {
5dfdaf58 198 struct beacon_data *beacon;
f0706e82 199
0ec3ca44
JB
200 struct list_head vlans;
201
f0706e82
JB
202 u8 ssid[IEEE80211_MAX_SSID_LEN];
203 size_t ssid_len;
f0706e82
JB
204
205 /* yes, this looks ugly, but guarantees that we can later use
206 * bitmap_empty :)
207 * NB: don't ever use set_bit, use bss_tim_set/bss_tim_clear! */
208 u8 tim[sizeof(unsigned long) * BITS_TO_LONGS(IEEE80211_MAX_AID + 1)];
209 atomic_t num_sta_ps; /* number of stations in PS mode */
210 struct sk_buff_head ps_bc_buf;
5dfdaf58 211 int dtim_count;
f0706e82
JB
212 int force_unicast_rateidx; /* forced TX rateidx for unicast frames */
213 int max_ratectrl_rateidx; /* max TX rateidx for rate control */
214 int num_beacons; /* number of TXed beacon frames for this BSS */
215};
216
217struct ieee80211_if_wds {
218 u8 remote_addr[ETH_ALEN];
219 struct sta_info *sta;
220};
221
222struct ieee80211_if_vlan {
0ec3ca44
JB
223 struct ieee80211_sub_if_data *ap;
224 struct list_head list;
f0706e82
JB
225};
226
d6f2da5b
JS
227/* flags used in struct ieee80211_if_sta.flags */
228#define IEEE80211_STA_SSID_SET BIT(0)
229#define IEEE80211_STA_BSSID_SET BIT(1)
230#define IEEE80211_STA_PREV_BSSID_SET BIT(2)
231#define IEEE80211_STA_AUTHENTICATED BIT(3)
232#define IEEE80211_STA_ASSOCIATED BIT(4)
233#define IEEE80211_STA_PROBEREQ_POLL BIT(5)
234#define IEEE80211_STA_CREATE_IBSS BIT(6)
235#define IEEE80211_STA_MIXED_CELL BIT(7)
236#define IEEE80211_STA_WMM_ENABLED BIT(8)
237#define IEEE80211_STA_AUTO_SSID_SEL BIT(10)
238#define IEEE80211_STA_AUTO_BSSID_SEL BIT(11)
239#define IEEE80211_STA_AUTO_CHANNEL_SEL BIT(12)
5b98b1f7 240#define IEEE80211_STA_PRIVACY_INVOKED BIT(13)
f0706e82
JB
241struct ieee80211_if_sta {
242 enum {
243 IEEE80211_DISABLED, IEEE80211_AUTHENTICATE,
244 IEEE80211_ASSOCIATE, IEEE80211_ASSOCIATED,
245 IEEE80211_IBSS_SEARCH, IEEE80211_IBSS_JOINED
246 } state;
247 struct timer_list timer;
248 struct work_struct work;
249 u8 bssid[ETH_ALEN], prev_bssid[ETH_ALEN];
250 u8 ssid[IEEE80211_MAX_SSID_LEN];
251 size_t ssid_len;
a0af5f14
HS
252 u8 scan_ssid[IEEE80211_MAX_SSID_LEN];
253 size_t scan_ssid_len;
f0706e82
JB
254 u16 aid;
255 u16 ap_capab, capab;
256 u8 *extra_ie; /* to be added to the end of AssocReq */
257 size_t extra_ie_len;
258
259 /* The last AssocReq/Resp IEs */
260 u8 *assocreq_ies, *assocresp_ies;
261 size_t assocreq_ies_len, assocresp_ies_len;
262
263 int auth_tries, assoc_tries;
264
d6f2da5b 265 unsigned int flags;
f0706e82
JB
266#define IEEE80211_STA_REQ_SCAN 0
267#define IEEE80211_STA_REQ_AUTH 1
268#define IEEE80211_STA_REQ_RUN 2
269 unsigned long request;
270 struct sk_buff_head skb_queue;
271
f0706e82
JB
272 unsigned long last_probe;
273
274#define IEEE80211_AUTH_ALG_OPEN BIT(0)
275#define IEEE80211_AUTH_ALG_SHARED_KEY BIT(1)
276#define IEEE80211_AUTH_ALG_LEAP BIT(2)
277 unsigned int auth_algs; /* bitfield of allowed auth algs */
278 int auth_alg; /* currently used IEEE 802.11 authentication algorithm */
279 int auth_transaction;
280
281 unsigned long ibss_join_req;
282 struct sk_buff *probe_resp; /* ProbeResp template for IBSS */
8318d78a 283 u32 supp_rates_bits[IEEE80211_NUM_BANDS];
f0706e82
JB
284
285 int wmm_last_param_set;
286};
287
288
13262ffd
JS
289/* flags used in struct ieee80211_sub_if_data.flags */
290#define IEEE80211_SDATA_ALLMULTI BIT(0)
291#define IEEE80211_SDATA_PROMISC BIT(1)
471b3efd 292#define IEEE80211_SDATA_USERSPACE_MLME BIT(2)
8318d78a 293#define IEEE80211_SDATA_OPERATING_GMODE BIT(3)
f0706e82
JB
294struct ieee80211_sub_if_data {
295 struct list_head list;
f0706e82
JB
296
297 struct wireless_dev wdev;
298
11a843b7
JB
299 /* keys */
300 struct list_head key_list;
301
f0706e82
JB
302 struct net_device *dev;
303 struct ieee80211_local *local;
304
13262ffd 305 unsigned int flags;
7e9ed188 306
f0706e82 307 int drop_unencrypted;
ce3edf6d
JB
308 /*
309 * IEEE 802.1X Port access control in effect,
310 * drop packets to/from unauthorized port
311 */
312 int ieee802_1x_pac;
f0706e82 313
8318d78a
JB
314 /*
315 * basic rates of this AP or the AP we're associated to
316 */
317 u64 basic_rates;
318
f0706e82
JB
319 u16 sequence;
320
321 /* Fragment table for host-based reassembly */
322 struct ieee80211_fragment_entry fragments[IEEE80211_FRAGMENT_MAX];
323 unsigned int fragment_next;
324
325#define NUM_DEFAULT_KEYS 4
326 struct ieee80211_key *keys[NUM_DEFAULT_KEYS];
327 struct ieee80211_key *default_key;
328
471b3efd
JB
329 /*
330 * BSS configuration for this interface.
331 *
332 * FIXME: I feel bad putting this here when we already have a
333 * bss pointer, but the bss pointer is just wrong when
334 * you have multiple virtual STA mode interfaces...
335 * This needs to be fixed.
336 */
337 struct ieee80211_bss_conf bss_conf;
f0706e82
JB
338 struct ieee80211_if_ap *bss; /* BSS that this device belongs to */
339
340 union {
341 struct ieee80211_if_ap ap;
342 struct ieee80211_if_wds wds;
343 struct ieee80211_if_vlan vlan;
344 struct ieee80211_if_sta sta;
345 } u;
346 int channel_use;
347 int channel_use_raw;
e9f207f0
JB
348
349#ifdef CONFIG_MAC80211_DEBUGFS
350 struct dentry *debugfsdir;
351 union {
352 struct {
353 struct dentry *channel_use;
354 struct dentry *drop_unencrypted;
ce3edf6d 355 struct dentry *ieee802_1x_pac;
e9f207f0
JB
356 struct dentry *state;
357 struct dentry *bssid;
358 struct dentry *prev_bssid;
359 struct dentry *ssid_len;
360 struct dentry *aid;
361 struct dentry *ap_capab;
362 struct dentry *capab;
363 struct dentry *extra_ie_len;
364 struct dentry *auth_tries;
365 struct dentry *assoc_tries;
366 struct dentry *auth_algs;
367 struct dentry *auth_alg;
368 struct dentry *auth_transaction;
369 struct dentry *flags;
370 } sta;
371 struct {
372 struct dentry *channel_use;
373 struct dentry *drop_unencrypted;
ce3edf6d 374 struct dentry *ieee802_1x_pac;
e9f207f0 375 struct dentry *num_sta_ps;
e9f207f0
JB
376 struct dentry *dtim_count;
377 struct dentry *num_beacons;
378 struct dentry *force_unicast_rateidx;
379 struct dentry *max_ratectrl_rateidx;
380 struct dentry *num_buffered_multicast;
e9f207f0
JB
381 } ap;
382 struct {
383 struct dentry *channel_use;
384 struct dentry *drop_unencrypted;
ce3edf6d 385 struct dentry *ieee802_1x_pac;
e9f207f0
JB
386 struct dentry *peer;
387 } wds;
388 struct {
389 struct dentry *channel_use;
390 struct dentry *drop_unencrypted;
ce3edf6d 391 struct dentry *ieee802_1x_pac;
e9f207f0
JB
392 } vlan;
393 struct {
394 struct dentry *mode;
395 } monitor;
396 struct dentry *default_key;
397 } debugfs;
398#endif
32bfd35d
JB
399 /* must be last, dynamically sized area in this! */
400 struct ieee80211_vif vif;
f0706e82
JB
401};
402
32bfd35d
JB
403static inline
404struct ieee80211_sub_if_data *vif_to_sdata(struct ieee80211_vif *p)
405{
406 return container_of(p, struct ieee80211_sub_if_data, vif);
407}
408
f0706e82
JB
409#define IEEE80211_DEV_TO_SUB_IF(dev) netdev_priv(dev)
410
411enum {
412 IEEE80211_RX_MSG = 1,
413 IEEE80211_TX_STATUS_MSG = 2,
eadc8d9e
RR
414 IEEE80211_DELBA_MSG = 3,
415 IEEE80211_ADDBA_MSG = 4,
f0706e82
JB
416};
417
418struct ieee80211_local {
419 /* embed the driver visible part.
420 * don't cast (use the static inlines below), but we keep
421 * it first anyway so they become a no-op */
422 struct ieee80211_hw hw;
423
424 const struct ieee80211_ops *ops;
425
f0706e82 426 struct net_device *mdev; /* wmaster# - "master" 802.11 device */
f0706e82
JB
427 int open_count;
428 int monitors;
4150c572 429 unsigned int filter_flags; /* FIF_* */
f0706e82
JB
430 struct iw_statistics wstats;
431 u8 wstats_flags;
b306f453 432 int tx_headroom; /* required headroom for hardware/radiotap */
f0706e82
JB
433
434 enum {
435 IEEE80211_DEV_UNINITIALIZED = 0,
436 IEEE80211_DEV_REGISTERED,
437 IEEE80211_DEV_UNREGISTERED,
438 } reg_state;
439
440 /* Tasklet and skb queue to process calls from IRQ mode. All frames
441 * added to skb_queue will be processed, but frames in
442 * skb_queue_unreliable may be dropped if the total length of these
443 * queues increases over the limit. */
444#define IEEE80211_IRQSAFE_QUEUE_LIMIT 128
445 struct tasklet_struct tasklet;
446 struct sk_buff_head skb_queue;
447 struct sk_buff_head skb_queue_unreliable;
448
449 /* Station data structures */
be8755e1 450 rwlock_t sta_lock; /* protects STA data structures */
f0706e82
JB
451 int num_sta; /* number of stations in sta_list */
452 struct list_head sta_list;
f0706e82
JB
453 struct sta_info *sta_hash[STA_HASH_SIZE];
454 struct timer_list sta_cleanup;
455
9e723492
RR
456 unsigned long state[NUM_TX_DATA_QUEUES_AMPDU];
457 struct ieee80211_tx_stored_packet pending_packet[NUM_TX_DATA_QUEUES_AMPDU];
f0706e82
JB
458 struct tasklet_struct tx_pending_tasklet;
459
53918994
JB
460 /* number of interfaces with corresponding IFF_ flags */
461 atomic_t iff_allmultis, iff_promiscs;
f0706e82
JB
462
463 struct rate_control_ref *rate_ctrl;
464
f0706e82 465 int rts_threshold;
f0706e82
JB
466 int fragmentation_threshold;
467 int short_retry_limit; /* dot11ShortRetryLimit */
468 int long_retry_limit; /* dot11LongRetryLimit */
f0706e82
JB
469
470 struct crypto_blkcipher *wep_tx_tfm;
471 struct crypto_blkcipher *wep_rx_tfm;
472 u32 wep_iv;
f0706e82
JB
473
474 int bridge_packets; /* bridge packets between associated stations and
475 * deliver multicast frames both back to wireless
476 * media and to the local net stack */
477
f0706e82
JB
478 ieee80211_rx_handler *rx_handlers;
479 ieee80211_tx_handler *tx_handlers;
480
79010420
JB
481 struct list_head interfaces;
482
ece8eddd
ZY
483 bool sta_sw_scanning;
484 bool sta_hw_scanning;
f0706e82 485 int scan_channel_idx;
8318d78a
JB
486 enum ieee80211_band scan_band;
487
f0706e82
JB
488 enum { SCAN_SET_CHANNEL, SCAN_SEND_PROBE } scan_state;
489 unsigned long last_scan_completed;
490 struct delayed_work scan_work;
491 struct net_device *scan_dev;
492 struct ieee80211_channel *oper_channel, *scan_channel;
f0706e82
JB
493 u8 scan_ssid[IEEE80211_MAX_SSID_LEN];
494 size_t scan_ssid_len;
495 struct list_head sta_bss_list;
496 struct ieee80211_sta_bss *sta_bss_hash[STA_HASH_SIZE];
497 spinlock_t sta_bss_lock;
f0706e82
JB
498
499 /* SNMP counters */
500 /* dot11CountersTable */
501 u32 dot11TransmittedFragmentCount;
502 u32 dot11MulticastTransmittedFrameCount;
503 u32 dot11FailedCount;
504 u32 dot11RetryCount;
505 u32 dot11MultipleRetryCount;
506 u32 dot11FrameDuplicateCount;
507 u32 dot11ReceivedFragmentCount;
508 u32 dot11MulticastReceivedFrameCount;
509 u32 dot11TransmittedFrameCount;
510 u32 dot11WEPUndecryptableCount;
511
512#ifdef CONFIG_MAC80211_LEDS
513 int tx_led_counter, rx_led_counter;
cdcb006f
ID
514 struct led_trigger *tx_led, *rx_led, *assoc_led, *radio_led;
515 char tx_led_name[32], rx_led_name[32],
516 assoc_led_name[32], radio_led_name[32];
f0706e82
JB
517#endif
518
519 u32 channel_use;
520 u32 channel_use_raw;
f0706e82 521
e9f207f0
JB
522#ifdef CONFIG_MAC80211_DEBUGFS
523 struct work_struct sta_debugfs_add;
524#endif
525
f0706e82
JB
526#ifdef CONFIG_MAC80211_DEBUG_COUNTERS
527 /* TX/RX handler statistics */
528 unsigned int tx_handlers_drop;
529 unsigned int tx_handlers_queued;
530 unsigned int tx_handlers_drop_unencrypted;
531 unsigned int tx_handlers_drop_fragment;
532 unsigned int tx_handlers_drop_wep;
533 unsigned int tx_handlers_drop_not_assoc;
534 unsigned int tx_handlers_drop_unauth_port;
535 unsigned int rx_handlers_drop;
536 unsigned int rx_handlers_queued;
537 unsigned int rx_handlers_drop_nullfunc;
538 unsigned int rx_handlers_drop_defrag;
539 unsigned int rx_handlers_drop_short;
540 unsigned int rx_handlers_drop_passive_scan;
541 unsigned int tx_expand_skb_head;
542 unsigned int tx_expand_skb_head_cloned;
543 unsigned int rx_expand_skb_head;
544 unsigned int rx_expand_skb_head2;
545 unsigned int rx_handlers_fragments;
546 unsigned int tx_status_drop;
547 unsigned int wme_rx_queue[NUM_RX_DATA_QUEUES];
548 unsigned int wme_tx_queue[NUM_RX_DATA_QUEUES];
549#define I802_DEBUG_INC(c) (c)++
550#else /* CONFIG_MAC80211_DEBUG_COUNTERS */
551#define I802_DEBUG_INC(c) do { } while (0)
552#endif /* CONFIG_MAC80211_DEBUG_COUNTERS */
553
554
f0706e82
JB
555 int total_ps_buffered; /* total number of all buffered unicast and
556 * multicast packets for power saving stations
557 */
f0706e82
JB
558 int wifi_wme_noack_test;
559 unsigned int wmm_acm; /* bit field of ACM bits (BIT(802.1D tag)) */
560
e9f207f0
JB
561#ifdef CONFIG_MAC80211_DEBUGFS
562 struct local_debugfsdentries {
e9f207f0 563 struct dentry *frequency;
e9f207f0
JB
564 struct dentry *antenna_sel_tx;
565 struct dentry *antenna_sel_rx;
566 struct dentry *bridge_packets;
e9f207f0
JB
567 struct dentry *rts_threshold;
568 struct dentry *fragmentation_threshold;
569 struct dentry *short_retry_limit;
570 struct dentry *long_retry_limit;
571 struct dentry *total_ps_buffered;
e9f207f0 572 struct dentry *wep_iv;
e9f207f0
JB
573 struct dentry *statistics;
574 struct local_debugfsdentries_statsdentries {
575 struct dentry *transmitted_fragment_count;
576 struct dentry *multicast_transmitted_frame_count;
577 struct dentry *failed_count;
578 struct dentry *retry_count;
579 struct dentry *multiple_retry_count;
580 struct dentry *frame_duplicate_count;
581 struct dentry *received_fragment_count;
582 struct dentry *multicast_received_frame_count;
583 struct dentry *transmitted_frame_count;
584 struct dentry *wep_undecryptable_count;
585 struct dentry *num_scans;
586#ifdef CONFIG_MAC80211_DEBUG_COUNTERS
587 struct dentry *tx_handlers_drop;
588 struct dentry *tx_handlers_queued;
589 struct dentry *tx_handlers_drop_unencrypted;
590 struct dentry *tx_handlers_drop_fragment;
591 struct dentry *tx_handlers_drop_wep;
592 struct dentry *tx_handlers_drop_not_assoc;
593 struct dentry *tx_handlers_drop_unauth_port;
594 struct dentry *rx_handlers_drop;
595 struct dentry *rx_handlers_queued;
596 struct dentry *rx_handlers_drop_nullfunc;
597 struct dentry *rx_handlers_drop_defrag;
598 struct dentry *rx_handlers_drop_short;
599 struct dentry *rx_handlers_drop_passive_scan;
600 struct dentry *tx_expand_skb_head;
601 struct dentry *tx_expand_skb_head_cloned;
602 struct dentry *rx_expand_skb_head;
603 struct dentry *rx_expand_skb_head2;
604 struct dentry *rx_handlers_fragments;
605 struct dentry *tx_status_drop;
606 struct dentry *wme_tx_queue;
607 struct dentry *wme_rx_queue;
608#endif
609 struct dentry *dot11ACKFailureCount;
610 struct dentry *dot11RTSFailureCount;
611 struct dentry *dot11FCSErrorCount;
612 struct dentry *dot11RTSSuccessCount;
613 } stats;
614 struct dentry *stations;
615 struct dentry *keys;
616 } debugfs;
617#endif
f0706e82
JB
618};
619
eadc8d9e
RR
620/* this struct represents 802.11n's RA/TID combination */
621struct ieee80211_ra_tid {
622 u8 ra[ETH_ALEN];
623 u16 tid;
624};
625
f0706e82
JB
626static inline struct ieee80211_local *hw_to_local(
627 struct ieee80211_hw *hw)
628{
629 return container_of(hw, struct ieee80211_local, hw);
630}
631
632static inline struct ieee80211_hw *local_to_hw(
633 struct ieee80211_local *local)
634{
635 return &local->hw;
636}
637
638enum ieee80211_link_state_t {
639 IEEE80211_LINK_STATE_XOFF = 0,
640 IEEE80211_LINK_STATE_PENDING,
641};
642
643struct sta_attribute {
644 struct attribute attr;
645 ssize_t (*show)(const struct sta_info *, char *buf);
646 ssize_t (*store)(struct sta_info *, const char *buf, size_t count);
647};
648
30ccb088 649static inline void __bss_tim_set(struct ieee80211_if_ap *bss, u16 aid)
f0706e82
JB
650{
651 /*
30ccb088 652 * This format has been mandated by the IEEE specifications,
f0706e82
JB
653 * so this line may not be changed to use the __set_bit() format.
654 */
30ccb088 655 bss->tim[aid / 8] |= (1 << (aid % 8));
f0706e82
JB
656}
657
658static inline void bss_tim_set(struct ieee80211_local *local,
30ccb088 659 struct ieee80211_if_ap *bss, u16 aid)
f0706e82 660{
be8755e1 661 read_lock_bh(&local->sta_lock);
f0706e82 662 __bss_tim_set(bss, aid);
be8755e1 663 read_unlock_bh(&local->sta_lock);
f0706e82
JB
664}
665
30ccb088 666static inline void __bss_tim_clear(struct ieee80211_if_ap *bss, u16 aid)
f0706e82
JB
667{
668 /*
30ccb088 669 * This format has been mandated by the IEEE specifications,
f0706e82
JB
670 * so this line may not be changed to use the __clear_bit() format.
671 */
30ccb088 672 bss->tim[aid / 8] &= ~(1 << (aid % 8));
f0706e82
JB
673}
674
675static inline void bss_tim_clear(struct ieee80211_local *local,
30ccb088 676 struct ieee80211_if_ap *bss, u16 aid)
f0706e82 677{
be8755e1 678 read_lock_bh(&local->sta_lock);
f0706e82 679 __bss_tim_clear(bss, aid);
be8755e1 680 read_unlock_bh(&local->sta_lock);
f0706e82
JB
681}
682
571ecf67
JB
683static inline int ieee80211_bssid_match(const u8 *raddr, const u8 *addr)
684{
685 return compare_ether_addr(raddr, addr) == 0 ||
686 is_broadcast_ether_addr(raddr);
687}
688
689
f0706e82
JB
690/* ieee80211.c */
691int ieee80211_hw_config(struct ieee80211_local *local);
692int ieee80211_if_config(struct net_device *dev);
693int ieee80211_if_config_beacon(struct net_device *dev);
f0706e82
JB
694void ieee80211_tx_set_iswep(struct ieee80211_txrx_data *tx);
695int ieee80211_if_update_wds(struct net_device *dev, u8 *remote_addr);
696void ieee80211_if_setup(struct net_device *dev);
d3c990fb
RR
697int ieee80211_hw_config_ht(struct ieee80211_local *local, int enable_ht,
698 struct ieee80211_ht_info *req_ht_cap,
699 struct ieee80211_ht_bss_info *req_bss_cap);
f0706e82
JB
700
701/* ieee80211_ioctl.c */
702extern const struct iw_handler_def ieee80211_iw_handler_def;
703
f0706e82
JB
704
705/* Least common multiple of the used rates (in 100 kbps). This is used to
706 * calculate rate_inv values for each rate so that only integers are needed. */
707#define CHAN_UTIL_RATE_LCM 95040
708/* 1 usec is 1/8 * (95040/10) = 1188 */
709#define CHAN_UTIL_PER_USEC 1188
710/* Amount of bits to shift the result right to scale the total utilization
711 * to values that will not wrap around 32-bit integers. */
712#define CHAN_UTIL_SHIFT 9
713/* Theoretical maximum of channel utilization counter in 10 ms (stat_time=1):
714 * (CHAN_UTIL_PER_USEC * 10000) >> CHAN_UTIL_SHIFT = 23203. So dividing the
715 * raw value with about 23 should give utilization in 10th of a percentage
716 * (1/1000). However, utilization is only estimated and not all intervals
717 * between frames etc. are calculated. 18 seems to give numbers that are closer
718 * to the real maximum. */
719#define CHAN_UTIL_PER_10MS 18
720#define CHAN_UTIL_HDR_LONG (202 * CHAN_UTIL_PER_USEC)
721#define CHAN_UTIL_HDR_SHORT (40 * CHAN_UTIL_PER_USEC)
722
723
724/* ieee80211_ioctl.c */
725int ieee80211_set_compression(struct ieee80211_local *local,
726 struct net_device *dev, struct sta_info *sta);
8318d78a 727int ieee80211_set_freq(struct ieee80211_local *local, int freq);
f0706e82
JB
728/* ieee80211_sta.c */
729void ieee80211_sta_timer(unsigned long data);
730void ieee80211_sta_work(struct work_struct *work);
731void ieee80211_sta_scan_work(struct work_struct *work);
732void ieee80211_sta_rx_mgmt(struct net_device *dev, struct sk_buff *skb,
733 struct ieee80211_rx_status *rx_status);
734int ieee80211_sta_set_ssid(struct net_device *dev, char *ssid, size_t len);
735int ieee80211_sta_get_ssid(struct net_device *dev, char *ssid, size_t *len);
736int ieee80211_sta_set_bssid(struct net_device *dev, u8 *bssid);
737int ieee80211_sta_req_scan(struct net_device *dev, u8 *ssid, size_t ssid_len);
738void ieee80211_sta_req_auth(struct net_device *dev,
739 struct ieee80211_if_sta *ifsta);
740int ieee80211_sta_scan_results(struct net_device *dev, char *buf, size_t len);
ece8eddd
ZY
741ieee80211_txrx_result ieee80211_sta_rx_scan(struct net_device *dev,
742 struct sk_buff *skb,
f0706e82
JB
743 struct ieee80211_rx_status *rx_status);
744void ieee80211_rx_bss_list_init(struct net_device *dev);
745void ieee80211_rx_bss_list_deinit(struct net_device *dev);
746int ieee80211_sta_set_extra_ie(struct net_device *dev, char *ie, size_t len);
747struct sta_info * ieee80211_ibss_add_sta(struct net_device *dev,
748 struct sk_buff *skb, u8 *bssid,
749 u8 *addr);
750int ieee80211_sta_deauthenticate(struct net_device *dev, u16 reason);
751int ieee80211_sta_disassociate(struct net_device *dev, u16 reason);
471b3efd
JB
752void ieee80211_bss_info_change_notify(struct ieee80211_sub_if_data *sdata,
753 u32 changed);
d9430a32 754void ieee80211_reset_erp_info(struct net_device *dev);
c7153508
RR
755int ieee80211_ht_cap_ie_to_ht_info(struct ieee80211_ht_cap *ht_cap_ie,
756 struct ieee80211_ht_info *ht_info);
757int ieee80211_ht_addt_info_ie_to_ht_bss_info(
758 struct ieee80211_ht_addt_info *ht_add_info_ie,
759 struct ieee80211_ht_bss_info *bss_info);
eadc8d9e
RR
760void ieee80211_send_addba_request(struct net_device *dev, const u8 *da,
761 u16 tid, u8 dialog_token, u16 start_seq_num,
762 u16 agg_size, u16 timeout);
763void ieee80211_send_delba(struct net_device *dev, const u8 *da, u16 tid,
764 u16 initiator, u16 reason_code);
07db2183
RR
765void ieee80211_sta_stop_rx_ba_session(struct net_device *dev, u8 *da,
766 u16 tid, u16 initiator, u16 reason);
767void sta_rx_agg_session_timer_expired(unsigned long data);
eadc8d9e 768void sta_addba_resp_timer_expired(unsigned long data);
f0706e82
JB
769/* ieee80211_iface.c */
770int ieee80211_if_add(struct net_device *dev, const char *name,
771 struct net_device **new_dev, int type);
772void ieee80211_if_set_type(struct net_device *dev, int type);
773void ieee80211_if_reinit(struct net_device *dev);
774void __ieee80211_if_del(struct ieee80211_local *local,
775 struct ieee80211_sub_if_data *sdata);
776int ieee80211_if_remove(struct net_device *dev, const char *name, int id);
777void ieee80211_if_free(struct net_device *dev);
778void ieee80211_if_sdata_init(struct ieee80211_sub_if_data *sdata);
f0706e82 779
571ecf67 780/* rx handling */
571ecf67
JB
781extern ieee80211_rx_handler ieee80211_rx_handlers[];
782
e2ebc74d
JB
783/* tx handling */
784extern ieee80211_tx_handler ieee80211_tx_handlers[];
785void ieee80211_clear_tx_pending(struct ieee80211_local *local);
786void ieee80211_tx_pending(unsigned long data);
787int ieee80211_master_start_xmit(struct sk_buff *skb, struct net_device *dev);
788int ieee80211_monitor_start_xmit(struct sk_buff *skb, struct net_device *dev);
789int ieee80211_subif_start_xmit(struct sk_buff *skb, struct net_device *dev);
e2ebc74d 790
c2d1560a
JB
791/* utility functions/constants */
792extern void *mac80211_wiphy_privid; /* for wiphy privid */
793extern const unsigned char rfc1042_header[6];
794extern const unsigned char bridge_tunnel_header[6];
71364716
RR
795u8 *ieee80211_get_bssid(struct ieee80211_hdr *hdr, size_t len,
796 enum ieee80211_if_types type);
c2d1560a
JB
797int ieee80211_frame_duration(struct ieee80211_local *local, size_t len,
798 int rate, int erp, int short_preamble);
eb063c17
JB
799void mac80211_ev_michael_mic_failure(struct net_device *dev, int keyidx,
800 struct ieee80211_hdr *hdr);
f0706e82
JB
801
802#endif /* IEEE80211_I_H */