Merge mac80211 driver from tree at bu3sch.de, pulled 24/6
[librecmc/librecmc.git] / package / mac80211 / src / mac80211 / ieee80211_i.h
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 <net/wireless.h>
25 #include "ieee80211_key.h"
26 #include "sta_info.h"
27
28 /* ieee80211.o internal definitions, etc. These are not included into
29  * low-level drivers. */
30
31 #ifndef ETH_P_PAE
32 #define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
33 #endif /* ETH_P_PAE */
34
35 #define WLAN_FC_DATA_PRESENT(fc) (((fc) & 0x4c) == 0x08)
36
37 struct ieee80211_local;
38
39 #define BIT(x) (1 << (x))
40
41 #define IEEE80211_ALIGN32_PAD(a) ((4 - ((a) & 3)) & 3)
42
43 /* Maximum number of broadcast/multicast frames to buffer when some of the
44  * associated stations are using power saving. */
45 #define AP_MAX_BC_BUFFER 128
46
47 /* Maximum number of frames buffered to all STAs, including multicast frames.
48  * Note: increasing this limit increases the potential memory requirement. Each
49  * frame can be up to about 2 kB long. */
50 #define TOTAL_MAX_TX_BUFFER 512
51
52 /* Required encryption head and tailroom */
53 #define IEEE80211_ENCRYPT_HEADROOM 8
54 #define IEEE80211_ENCRYPT_TAILROOM 12
55
56 /* IEEE 802.11 (Ch. 9.5 Defragmentation) requires support for concurrent
57  * reception of at least three fragmented frames. This limit can be increased
58  * by changing this define, at the cost of slower frame reassembly and
59  * increased memory use (about 2 kB of RAM per entry). */
60 #define IEEE80211_FRAGMENT_MAX 4
61
62 /* Minimum and Maximum TSID used by EDCA. EDCA uses 0~7; HCCA uses 8~15 */
63 #define EDCA_TSID_MIN 0
64 #define EDCA_TSID_MAX 7
65
66 struct ieee80211_fragment_entry {
67         unsigned long first_frag_time;
68         unsigned int seq;
69         unsigned int rx_queue;
70         unsigned int last_frag;
71         unsigned int extra_len;
72         struct sk_buff_head skb_list;
73         int ccmp; /* Whether fragments were encrypted with CCMP */
74         u8 last_pn[6]; /* PN of the last fragment if CCMP was used */
75 };
76
77
78 struct ieee80211_sta_bss {
79         struct list_head list;
80         struct ieee80211_sta_bss *hnext;
81         atomic_t users;
82
83         u8 bssid[ETH_ALEN];
84         u8 ssid[IEEE80211_MAX_SSID_LEN];
85         size_t ssid_len;
86         u16 capability; /* host byte order */
87         int hw_mode;
88         int channel;
89         int freq;
90         int rssi, signal, noise;
91         u8 *wpa_ie;
92         size_t wpa_ie_len;
93         u8 *rsn_ie;
94         size_t rsn_ie_len;
95         u8 *wmm_ie;
96         size_t wmm_ie_len;
97         u8 *ht_ie;
98         size_t ht_ie_len;
99 #define IEEE80211_MAX_SUPP_RATES 32
100         u8 supp_rates[IEEE80211_MAX_SUPP_RATES];
101         size_t supp_rates_len;
102         int beacon_int;
103         u64 timestamp;
104
105         int probe_resp;
106         unsigned long last_update;
107
108 };
109
110
111 typedef enum {
112         TXRX_CONTINUE, TXRX_DROP, TXRX_QUEUED
113 } ieee80211_txrx_result;
114
115 struct ieee80211_txrx_data {
116         struct sk_buff *skb;
117         struct net_device *dev;
118         struct ieee80211_local *local;
119         struct ieee80211_sub_if_data *sdata;
120         struct sta_info *sta;
121         u16 fc, ethertype;
122         struct ieee80211_key *key;
123         unsigned int fragmented:1; /* whether the MSDU was fragmented */
124         union {
125                 struct {
126                         struct ieee80211_tx_control *control;
127                         unsigned int unicast:1;
128                         unsigned int ps_buffered:1;
129                         unsigned int short_preamble:1;
130                         unsigned int probe_last_frag:1;
131                         struct ieee80211_hw_mode *mode;
132                         struct ieee80211_rate *rate;
133                         /* use this rate (if set) for last fragment; rate can
134                          * be set to lower rate for the first fragments, e.g.,
135                          * when using CTS protection with IEEE 802.11g. */
136                         struct ieee80211_rate *last_frag_rate;
137                         int last_frag_hwrate;
138                         int mgmt_interface;
139
140                         /* Extra fragments (in addition to the first fragment
141                          * in skb) */
142                         int num_extra_frag;
143                         struct sk_buff **extra_frag;
144                 } tx;
145                 struct {
146                         struct ieee80211_rx_status *status;
147                         int sent_ps_buffered;
148                         int queue;
149                         int load;
150                         u16 qos_control;
151                         unsigned int in_scan:1;
152                         /* frame is destined to interface currently processed
153                          * (including multicast frames) */
154                         unsigned int ra_match:1;
155                         unsigned int is_agg_frame:1;
156                 } rx;
157         } u;
158 #ifdef CONFIG_HOSTAPD_WPA_TESTING
159         int wpa_test;
160 #endif /* CONFIG_HOSTAPD_WPA_TESTING */
161 };
162
163 /* Stored in sk_buff->cb */
164 struct ieee80211_tx_packet_data {
165         int ifindex;
166         unsigned long jiffies;
167         unsigned int req_tx_status:1;
168         unsigned int do_not_encrypt:1;
169         unsigned int requeue:1;
170         unsigned int mgmt_iface:1;
171         unsigned int queue:4;
172 };
173
174 struct ieee80211_tx_stored_packet {
175         struct ieee80211_tx_control control;
176         struct sk_buff *skb;
177         int num_extra_frag;
178         struct sk_buff **extra_frag;
179         int last_frag_rateidx;
180         int last_frag_hwrate;
181         struct ieee80211_rate *last_frag_rate;
182         unsigned int last_frag_rate_ctrl_probe:1;
183 };
184
185 struct sta_ts_data {
186         enum {
187                 TS_STATUS_UNUSED        = 0,
188                 TS_STATUS_ACTIVE        = 1,
189                 TS_STATUS_INACTIVE      = 2,
190                 TS_STATUS_THROTTLING    = 3,
191         } status;
192         u8 dialog_token;
193         u8 up;
194         u32 admitted_time_usec;
195         u32 used_time_usec;
196 };
197
198 typedef ieee80211_txrx_result (*ieee80211_tx_handler)
199 (struct ieee80211_txrx_data *tx);
200
201 typedef ieee80211_txrx_result (*ieee80211_rx_handler)
202 (struct ieee80211_txrx_data *rx);
203
204 struct ieee80211_if_ap {
205         u8 *beacon_head, *beacon_tail;
206         int beacon_head_len, beacon_tail_len;
207
208         u8 ssid[IEEE80211_MAX_SSID_LEN];
209         size_t ssid_len;
210         u8 *generic_elem;
211         size_t generic_elem_len;
212
213         /* yes, this looks ugly, but guarantees that we can later use
214          * bitmap_empty :)
215          * NB: don't ever use set_bit, use bss_tim_set/bss_tim_clear! */
216         u8 tim[sizeof(unsigned long) * BITS_TO_LONGS(IEEE80211_MAX_AID + 1)];
217         atomic_t num_sta_ps; /* number of stations in PS mode */
218         struct sk_buff_head ps_bc_buf;
219         int dtim_period, dtim_count;
220         int force_unicast_rateidx; /* forced TX rateidx for unicast frames */
221         int max_ratectrl_rateidx; /* max TX rateidx for rate control */
222         int num_beacons; /* number of TXed beacon frames for this BSS */
223 };
224
225 struct ieee80211_if_wds {
226         u8 remote_addr[ETH_ALEN];
227         struct sta_info *sta;
228 };
229
230 struct ieee80211_if_vlan {
231         u8 id;
232 };
233
234 struct ieee80211_if_sta {
235         enum {
236                 IEEE80211_DISABLED, IEEE80211_AUTHENTICATE,
237                 IEEE80211_ASSOCIATE, IEEE80211_ASSOCIATED,
238                 IEEE80211_IBSS_SEARCH, IEEE80211_IBSS_JOINED
239         } state;
240         struct timer_list timer;
241         struct work_struct work;
242         struct timer_list admit_timer; /* Recompute EDCA admitted time */
243         u8 bssid[ETH_ALEN], prev_bssid[ETH_ALEN];
244         u8 ssid[IEEE80211_MAX_SSID_LEN];
245         size_t ssid_len;
246         u16 aid;
247         u16 ap_capab, capab;
248         u8 *extra_ie; /* to be added to the end of AssocReq */
249         size_t extra_ie_len;
250
251         /* The last AssocReq/Resp IEs */
252         u8 *assocreq_ies, *assocresp_ies;
253         size_t assocreq_ies_len, assocresp_ies_len;
254
255         int auth_tries, assoc_tries;
256
257         unsigned int ssid_set:1;
258         unsigned int bssid_set:1;
259         unsigned int prev_bssid_set:1;
260         unsigned int authenticated:1;
261         unsigned int associated:1;
262         unsigned int probereq_poll:1;
263         unsigned int use_protection:1;
264         unsigned int create_ibss:1;
265         unsigned int mixed_cell:1;
266         unsigned int wmm_enabled:1;
267         unsigned int ht_enabled:1;
268         unsigned int auto_ssid_sel:1;
269         unsigned int auto_bssid_sel:1;
270         unsigned int auto_channel_sel:1;
271 #define IEEE80211_STA_REQ_SCAN 0
272 #define IEEE80211_STA_REQ_AUTH 1
273 #define IEEE80211_STA_REQ_RUN  2
274         unsigned long request;
275         struct sk_buff_head skb_queue;
276
277         int key_mgmt;
278         unsigned long last_probe;
279
280 #define IEEE80211_AUTH_ALG_OPEN BIT(0)
281 #define IEEE80211_AUTH_ALG_SHARED_KEY BIT(1)
282 #define IEEE80211_AUTH_ALG_LEAP BIT(2)
283         unsigned int auth_algs; /* bitfield of allowed auth algs */
284         int auth_alg; /* currently used IEEE 802.11 authentication algorithm */
285         int auth_transaction;
286
287         unsigned long ibss_join_req;
288         struct sk_buff *probe_resp; /* ProbeResp template for IBSS */
289         u32 supp_rates_bits;
290
291         int wmm_last_param_set;
292
293         u32 dot11EDCAAveragingPeriod;
294         u32 MPDUExchangeTime;
295 #define STA_TSID_NUM   16
296 #define STA_TSDIR_NUM  2
297         /* EDCA: 0~7, HCCA: 8~15 */
298         struct sta_ts_data ts_data[STA_TSID_NUM][STA_TSDIR_NUM];
299 #ifdef CONFIG_MAC80211_DEBUGFS
300         struct ieee80211_elem_tspec tspec;
301         u8 dls_mac[ETH_ALEN];
302 #endif
303 };
304
305
306 struct ieee80211_sub_if_data {
307         struct list_head list;
308         unsigned int type;
309
310         struct wireless_dev wdev;
311
312         struct net_device *dev;
313         struct ieee80211_local *local;
314
315         int mc_count;
316         unsigned int allmulti:1;
317         unsigned int promisc:1;
318
319         struct net_device_stats stats;
320         int drop_unencrypted;
321         int eapol; /* 0 = process EAPOL frames as normal data frames,
322                     * 1 = send EAPOL frames through wlan#ap to hostapd
323                     *     (default) */
324         int ieee802_1x; /* IEEE 802.1X PAE - drop packet to/from unauthorized
325                          * port */
326
327         u16 sequence;
328
329         /* Fragment table for host-based reassembly */
330         struct ieee80211_fragment_entry fragments[IEEE80211_FRAGMENT_MAX];
331         unsigned int fragment_next;
332
333 #define NUM_DEFAULT_KEYS 4
334         struct ieee80211_key *keys[NUM_DEFAULT_KEYS];
335         struct ieee80211_key *default_key;
336
337         struct ieee80211_if_ap *bss; /* BSS that this device belongs to */
338
339         union {
340                 struct ieee80211_if_ap ap;
341                 struct ieee80211_if_wds wds;
342                 struct ieee80211_if_vlan vlan;
343                 struct ieee80211_if_sta sta;
344         } u;
345         int channel_use;
346         int channel_use_raw;
347
348 #ifdef CONFIG_MAC80211_DEBUGFS
349         struct dentry *debugfsdir;
350         union {
351                 struct {
352                         struct dentry *channel_use;
353                         struct dentry *drop_unencrypted;
354                         struct dentry *eapol;
355                         struct dentry *ieee8021_x;
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                         struct dentry *qos_dir;
371                         struct {
372                                 struct dentry *addts_11e;
373                                 struct dentry *addts_wmm;
374                                 struct dentry *delts_11e;
375                                 struct dentry *delts_wmm;
376                                 struct dentry *dls_mac;
377                                 struct dentry *dls_op;
378                         } qos;
379                         struct dentry *tsinfo_dir;
380                         struct {
381                                 struct dentry *tsid;
382                                 struct dentry *direction;
383                                 struct dentry *up;
384                         } tsinfo;
385                         struct dentry *tspec_dir;
386                         struct {
387                                 struct dentry *nominal_msdu_size;
388                                 struct dentry *max_msdu_size;
389                                 struct dentry *min_service_interval;
390                                 struct dentry *max_service_interval;
391                                 struct dentry *inactivity_interval;
392                                 struct dentry *suspension_interval;
393                                 struct dentry *service_start_time;
394                                 struct dentry *min_data_rate;
395                                 struct dentry *mean_data_rate;
396                                 struct dentry *peak_data_rate;
397                                 struct dentry *burst_size;
398                                 struct dentry *delay_bound;
399                                 struct dentry *min_phy_rate;
400                                 struct dentry *surplus_band_allow;
401                                 struct dentry *medium_time;
402                         } tspec;
403                 } sta;
404                 struct {
405                         struct dentry *channel_use;
406                         struct dentry *drop_unencrypted;
407                         struct dentry *eapol;
408                         struct dentry *ieee8021_x;
409                         struct dentry *num_sta_ps;
410                         struct dentry *dtim_period;
411                         struct dentry *dtim_count;
412                         struct dentry *num_beacons;
413                         struct dentry *force_unicast_rateidx;
414                         struct dentry *max_ratectrl_rateidx;
415                         struct dentry *num_buffered_multicast;
416                         struct dentry *beacon_head_len;
417                         struct dentry *beacon_tail_len;
418                 } ap;
419                 struct {
420                         struct dentry *channel_use;
421                         struct dentry *drop_unencrypted;
422                         struct dentry *eapol;
423                         struct dentry *ieee8021_x;
424                         struct dentry *peer;
425                 } wds;
426                 struct {
427                         struct dentry *channel_use;
428                         struct dentry *drop_unencrypted;
429                         struct dentry *eapol;
430                         struct dentry *ieee8021_x;
431                         struct dentry *vlan_id;
432                 } vlan;
433                 struct {
434                         struct dentry *mode;
435                 } monitor;
436                 struct dentry *default_key;
437         } debugfs;
438 #endif
439 };
440
441 #define IEEE80211_DEV_TO_SUB_IF(dev) netdev_priv(dev)
442
443 enum {
444         IEEE80211_RX_MSG        = 1,
445         IEEE80211_TX_STATUS_MSG = 2,
446 };
447
448 struct ieee80211_local {
449         /* embed the driver visible part.
450          * don't cast (use the static inlines below), but we keep
451          * it first anyway so they become a no-op */
452         struct ieee80211_hw hw;
453
454         const struct ieee80211_ops *ops;
455
456         /* List of registered struct ieee80211_hw_mode */
457         struct list_head modes_list;
458
459         struct net_device *mdev; /* wmaster# - "master" 802.11 device */
460         struct net_device *apdev; /* wlan#ap - management frames (hostapd) */
461         int open_count;
462         int monitors;
463         struct iw_statistics wstats;
464         u8 wstats_flags;
465
466         enum {
467                 IEEE80211_DEV_UNINITIALIZED = 0,
468                 IEEE80211_DEV_REGISTERED,
469                 IEEE80211_DEV_UNREGISTERED,
470         } reg_state;
471
472         /* Tasklet and skb queue to process calls from IRQ mode. All frames
473          * added to skb_queue will be processed, but frames in
474          * skb_queue_unreliable may be dropped if the total length of these
475          * queues increases over the limit. */
476 #define IEEE80211_IRQSAFE_QUEUE_LIMIT 128
477         struct tasklet_struct tasklet;
478         struct sk_buff_head skb_queue;
479         struct sk_buff_head skb_queue_unreliable;
480
481         /* Station data structures */
482         spinlock_t sta_lock; /* mutex for STA data structures */
483         int num_sta; /* number of stations in sta_list */
484         struct list_head sta_list;
485         struct list_head deleted_sta_list;
486         struct sta_info *sta_hash[STA_HASH_SIZE];
487         struct timer_list sta_cleanup;
488
489         unsigned long state[NUM_TX_DATA_QUEUES];
490         struct ieee80211_tx_stored_packet pending_packet[NUM_TX_DATA_QUEUES];
491         struct tasklet_struct tx_pending_tasklet;
492
493         int mc_count;   /* total count of multicast entries in all interfaces */
494         int iff_allmultis, iff_promiscs;
495                         /* number of interfaces with corresponding IFF_ flags */
496
497         struct rate_control_ref *rate_ctrl;
498
499         int next_mode; /* MODE_IEEE80211*
500                         * The mode preference for next channel change. This is
501                         * used to select .11g vs. .11b channels (or 4.9 GHz vs.
502                         * .11a) when the channel number is not unique. */
503
504         /* Supported and basic rate filters for different modes. These are
505          * pointers to -1 terminated lists and rates in 100 kbps units. */
506         int *supp_rates[NUM_IEEE80211_MODES];
507         int *basic_rates[NUM_IEEE80211_MODES];
508
509         int rts_threshold;
510         int cts_protect_erp_frames;
511         int fragmentation_threshold;
512         int short_retry_limit; /* dot11ShortRetryLimit */
513         int long_retry_limit; /* dot11LongRetryLimit */
514         int short_preamble; /* use short preamble with IEEE 802.11b */
515
516         struct crypto_blkcipher *wep_tx_tfm;
517         struct crypto_blkcipher *wep_rx_tfm;
518         u32 wep_iv;
519         int key_tx_rx_threshold; /* number of times any key can be used in TX
520                                   * or RX before generating a rekey
521                                   * notification; 0 = notification disabled. */
522
523         int bridge_packets; /* bridge packets between associated stations and
524                              * deliver multicast frames both back to wireless
525                              * media and to the local net stack */
526
527         ieee80211_rx_handler *rx_pre_handlers;
528         ieee80211_rx_handler *rx_handlers;
529         ieee80211_tx_handler *tx_handlers;
530
531         rwlock_t sub_if_lock; /* Protects sub_if_list. Cannot be taken under
532                                * sta_bss_lock or sta_lock. */
533         struct list_head sub_if_list;
534         int sta_scanning;
535         int scan_channel_idx;
536         enum { SCAN_SET_CHANNEL, SCAN_SEND_PROBE } scan_state;
537         unsigned long last_scan_completed;
538         struct delayed_work scan_work;
539         struct net_device *scan_dev;
540         struct ieee80211_channel *oper_channel, *scan_channel;
541         struct ieee80211_hw_mode *oper_hw_mode, *scan_hw_mode;
542         u8 scan_ssid[IEEE80211_MAX_SSID_LEN];
543         size_t scan_ssid_len;
544         struct list_head sta_bss_list;
545         struct ieee80211_sta_bss *sta_bss_hash[STA_HASH_SIZE];
546         spinlock_t sta_bss_lock;
547 #define IEEE80211_SCAN_MATCH_SSID BIT(0)
548 #define IEEE80211_SCAN_WPA_ONLY BIT(1)
549 #define IEEE80211_SCAN_EXTRA_INFO BIT(2)
550         int scan_flags;
551
552 #ifdef CONFIG_HOSTAPD_WPA_TESTING
553         u32 wpa_trigger;
554 #endif /* CONFIG_HOSTAPD_WPA_TESTING */
555         /* SNMP counters */
556         /* dot11CountersTable */
557         u32 dot11TransmittedFragmentCount;
558         u32 dot11MulticastTransmittedFrameCount;
559         u32 dot11FailedCount;
560         u32 dot11RetryCount;
561         u32 dot11MultipleRetryCount;
562         u32 dot11FrameDuplicateCount;
563         u32 dot11ReceivedFragmentCount;
564         u32 dot11MulticastReceivedFrameCount;
565         u32 dot11TransmittedFrameCount;
566         u32 dot11WEPUndecryptableCount;
567
568 #ifdef CONFIG_MAC80211_LEDS
569         int tx_led_counter, rx_led_counter;
570         struct led_trigger *tx_led, *rx_led;
571         char tx_led_name[32], rx_led_name[32];
572 #endif
573
574         u32 channel_use;
575         u32 channel_use_raw;
576         u32 stat_time;
577         struct timer_list stat_timer;
578
579 #ifdef CONFIG_MAC80211_DEBUGFS
580         struct work_struct sta_debugfs_add;
581 #endif
582
583         enum {
584                 STA_ANTENNA_SEL_AUTO = 0,
585                 STA_ANTENNA_SEL_SW_CTRL = 1,
586                 STA_ANTENNA_SEL_SW_CTRL_DEBUG = 2
587         } sta_antenna_sel;
588
589         int rate_ctrl_num_up, rate_ctrl_num_down;
590
591 #ifdef CONFIG_MAC80211_DEBUG_COUNTERS
592         /* TX/RX handler statistics */
593         unsigned int tx_handlers_drop;
594         unsigned int tx_handlers_queued;
595         unsigned int tx_handlers_drop_unencrypted;
596         unsigned int tx_handlers_drop_fragment;
597         unsigned int tx_handlers_drop_wep;
598         unsigned int tx_handlers_drop_not_assoc;
599         unsigned int tx_handlers_drop_unauth_port;
600         unsigned int rx_handlers_drop;
601         unsigned int rx_handlers_queued;
602         unsigned int rx_handlers_drop_nullfunc;
603         unsigned int rx_handlers_drop_defrag;
604         unsigned int rx_handlers_drop_short;
605         unsigned int rx_handlers_drop_passive_scan;
606         unsigned int tx_expand_skb_head;
607         unsigned int tx_expand_skb_head_cloned;
608         unsigned int rx_expand_skb_head;
609         unsigned int rx_expand_skb_head2;
610         unsigned int rx_handlers_fragments;
611         unsigned int tx_status_drop;
612         unsigned int wme_rx_queue[NUM_RX_DATA_QUEUES];
613         unsigned int wme_tx_queue[NUM_RX_DATA_QUEUES];
614 #define I802_DEBUG_INC(c) (c)++
615 #else /* CONFIG_MAC80211_DEBUG_COUNTERS */
616 #define I802_DEBUG_INC(c) do { } while (0)
617 #endif /* CONFIG_MAC80211_DEBUG_COUNTERS */
618
619
620         int default_wep_only; /* only default WEP keys are used with this
621                                * interface; this is used to decide when hwaccel
622                                * can be used with default keys */
623         int total_ps_buffered; /* total number of all buffered unicast and
624                                 * multicast packets for power saving stations
625                                 */
626         int allow_broadcast_always; /* whether to allow TX of broadcast frames
627                                      * even when there are no associated STAs
628                                      */
629
630         int wifi_wme_noack_test;
631         unsigned int wmm_acm; /* bit field of ACM bits (BIT(802.1D tag)) */
632
633         unsigned int enabled_modes; /* bitfield of allowed modes;
634                                       * (1 << MODE_*) */
635         unsigned int hw_modes; /* bitfield of supported hardware modes;
636                                 * (1 << MODE_*) */
637
638         int user_space_mlme;
639
640 #ifdef CONFIG_MAC80211_DEBUGFS
641         struct local_debugfsdentries {
642                 struct dentry *channel;
643                 struct dentry *frequency;
644                 struct dentry *radar_detect;
645                 struct dentry *antenna_sel_tx;
646                 struct dentry *antenna_sel_rx;
647                 struct dentry *bridge_packets;
648                 struct dentry *key_tx_rx_threshold;
649                 struct dentry *rts_threshold;
650                 struct dentry *fragmentation_threshold;
651                 struct dentry *short_retry_limit;
652                 struct dentry *long_retry_limit;
653                 struct dentry *total_ps_buffered;
654                 struct dentry *mode;
655                 struct dentry *wep_iv;
656                 struct dentry *rate_ctrl_alg;
657                 struct dentry *tx_power_reduction;
658                 struct dentry *modes;
659                 struct dentry *statistics;
660                 struct local_debugfsdentries_statsdentries {
661                         struct dentry *transmitted_fragment_count;
662                         struct dentry *multicast_transmitted_frame_count;
663                         struct dentry *failed_count;
664                         struct dentry *retry_count;
665                         struct dentry *multiple_retry_count;
666                         struct dentry *frame_duplicate_count;
667                         struct dentry *received_fragment_count;
668                         struct dentry *multicast_received_frame_count;
669                         struct dentry *transmitted_frame_count;
670                         struct dentry *wep_undecryptable_count;
671                         struct dentry *num_scans;
672 #ifdef CONFIG_MAC80211_DEBUG_COUNTERS
673                         struct dentry *tx_handlers_drop;
674                         struct dentry *tx_handlers_queued;
675                         struct dentry *tx_handlers_drop_unencrypted;
676                         struct dentry *tx_handlers_drop_fragment;
677                         struct dentry *tx_handlers_drop_wep;
678                         struct dentry *tx_handlers_drop_not_assoc;
679                         struct dentry *tx_handlers_drop_unauth_port;
680                         struct dentry *rx_handlers_drop;
681                         struct dentry *rx_handlers_queued;
682                         struct dentry *rx_handlers_drop_nullfunc;
683                         struct dentry *rx_handlers_drop_defrag;
684                         struct dentry *rx_handlers_drop_short;
685                         struct dentry *rx_handlers_drop_passive_scan;
686                         struct dentry *tx_expand_skb_head;
687                         struct dentry *tx_expand_skb_head_cloned;
688                         struct dentry *rx_expand_skb_head;
689                         struct dentry *rx_expand_skb_head2;
690                         struct dentry *rx_handlers_fragments;
691                         struct dentry *tx_status_drop;
692                         struct dentry *wme_tx_queue;
693                         struct dentry *wme_rx_queue;
694 #endif
695                         struct dentry *dot11ACKFailureCount;
696                         struct dentry *dot11RTSFailureCount;
697                         struct dentry *dot11FCSErrorCount;
698                         struct dentry *dot11RTSSuccessCount;
699                 } stats;
700                 struct dentry *stations;
701                 struct dentry *keys;
702         } debugfs;
703 #endif
704 };
705
706 enum sta_link_direction {
707         STA_TS_UPLINK = 0,
708         STA_TS_DOWNLINK = 1,
709 };
710
711 static inline struct ieee80211_local *hw_to_local(
712         struct ieee80211_hw *hw)
713 {
714         return container_of(hw, struct ieee80211_local, hw);
715 }
716
717 static inline struct ieee80211_hw *local_to_hw(
718         struct ieee80211_local *local)
719 {
720         return &local->hw;
721 }
722
723 enum ieee80211_link_state_t {
724         IEEE80211_LINK_STATE_XOFF = 0,
725         IEEE80211_LINK_STATE_PENDING,
726 };
727
728 struct sta_attribute {
729         struct attribute attr;
730         ssize_t (*show)(const struct sta_info *, char *buf);
731         ssize_t (*store)(struct sta_info *, const char *buf, size_t count);
732 };
733
734 static inline void __bss_tim_set(struct ieee80211_if_ap *bss, int aid)
735 {
736         /*
737          * This format has ben mandated by the IEEE specifications,
738          * so this line may not be changed to use the __set_bit() format.
739          */
740         bss->tim[(aid)/8] |= 1<<((aid) % 8);
741 }
742
743 static inline void bss_tim_set(struct ieee80211_local *local,
744                                struct ieee80211_if_ap *bss, int aid)
745 {
746         spin_lock_bh(&local->sta_lock);
747         __bss_tim_set(bss, aid);
748         spin_unlock_bh(&local->sta_lock);
749 }
750
751 static inline void __bss_tim_clear(struct ieee80211_if_ap *bss, int aid)
752 {
753         /*
754          * This format has ben mandated by the IEEE specifications,
755          * so this line may not be changed to use the __clear_bit() format.
756          */
757         bss->tim[(aid)/8] &= !(1<<((aid) % 8));
758 }
759
760 static inline void bss_tim_clear(struct ieee80211_local *local,
761                                  struct ieee80211_if_ap *bss, int aid)
762 {
763         spin_lock_bh(&local->sta_lock);
764         __bss_tim_clear(bss, aid);
765         spin_unlock_bh(&local->sta_lock);
766 }
767
768 /**
769  * ieee80211_is_erp_rate - Check if a rate is an ERP rate
770  * @phymode: The PHY-mode for this rate (MODE_IEEE80211...)
771  * @rate: Transmission rate to check, in 100 kbps
772  *
773  * Check if a given rate is an Extended Rate PHY (ERP) rate.
774  */
775 static inline int ieee80211_is_erp_rate(int phymode, int rate)
776 {
777         if (phymode == MODE_IEEE80211G) {
778                 if (rate != 10 && rate != 20 &&
779                     rate != 55 && rate != 110)
780                         return 1;
781         }
782         return 0;
783 }
784
785 /* ieee80211.c */
786 int ieee80211_hw_config(struct ieee80211_local *local);
787 int ieee80211_if_config(struct net_device *dev);
788 int ieee80211_if_config_beacon(struct net_device *dev);
789 struct ieee80211_key_conf *
790 ieee80211_key_data2conf(struct ieee80211_local *local,
791                         const struct ieee80211_key *data);
792 struct ieee80211_key *ieee80211_key_alloc(struct ieee80211_sub_if_data *sdata,
793                                           int idx, size_t key_len, gfp_t flags);
794 void ieee80211_key_free(struct ieee80211_key *key);
795 void ieee80211_rx_mgmt(struct ieee80211_local *local, struct sk_buff *skb,
796                        struct ieee80211_rx_status *status, u32 msg_type);
797 void ieee80211_prepare_rates(struct ieee80211_local *local,
798                              struct ieee80211_hw_mode *mode);
799 void ieee80211_tx_set_iswep(struct ieee80211_txrx_data *tx);
800 int ieee80211_if_update_wds(struct net_device *dev, u8 *remote_addr);
801 void ieee80211_if_setup(struct net_device *dev);
802 void ieee80211_if_mgmt_setup(struct net_device *dev);
803 int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
804                                  const char *name);
805 struct net_device_stats *ieee80211_dev_stats(struct net_device *dev);
806
807 /* ieee80211_ioctl.c */
808 int ieee80211_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
809 extern const struct iw_handler_def ieee80211_iw_handler_def;
810
811 /* Set hw encryption from ieee80211 */
812 int ieee80211_set_hw_encryption(struct net_device *dev,
813                                 struct sta_info *sta, u8 addr[ETH_ALEN],
814                                 struct ieee80211_key *key);
815 void ieee80211_update_default_wep_only(struct ieee80211_local *local);
816
817
818 /* Least common multiple of the used rates (in 100 kbps). This is used to
819  * calculate rate_inv values for each rate so that only integers are needed. */
820 #define CHAN_UTIL_RATE_LCM 95040
821 /* 1 usec is 1/8 * (95040/10) = 1188 */
822 #define CHAN_UTIL_PER_USEC 1188
823 /* Amount of bits to shift the result right to scale the total utilization
824  * to values that will not wrap around 32-bit integers. */
825 #define CHAN_UTIL_SHIFT 9
826 /* Theoretical maximum of channel utilization counter in 10 ms (stat_time=1):
827  * (CHAN_UTIL_PER_USEC * 10000) >> CHAN_UTIL_SHIFT = 23203. So dividing the
828  * raw value with about 23 should give utilization in 10th of a percentage
829  * (1/1000). However, utilization is only estimated and not all intervals
830  * between frames etc. are calculated. 18 seems to give numbers that are closer
831  * to the real maximum. */
832 #define CHAN_UTIL_PER_10MS 18
833 #define CHAN_UTIL_HDR_LONG (202 * CHAN_UTIL_PER_USEC)
834 #define CHAN_UTIL_HDR_SHORT (40 * CHAN_UTIL_PER_USEC)
835
836
837 /* ieee80211_ioctl.c */
838 int ieee80211_set_compression(struct ieee80211_local *local,
839                               struct net_device *dev, struct sta_info *sta);
840 int ieee80211_set_channel(struct ieee80211_local *local, int channel, int freq);
841 /* ieee80211_sta.c */
842 void ieee80211_sta_timer(unsigned long data);
843 void ieee80211_sta_work(struct work_struct *work);
844 void ieee80211_admit_refresh(unsigned long ptr);
845 void ieee80211_sta_scan_work(struct work_struct *work);
846 void ieee80211_sta_rx_mgmt(struct net_device *dev, struct sk_buff *skb,
847                            struct ieee80211_rx_status *rx_status);
848 int ieee80211_sta_set_ssid(struct net_device *dev, char *ssid, size_t len);
849 int ieee80211_sta_get_ssid(struct net_device *dev, char *ssid, size_t *len);
850 int ieee80211_sta_set_bssid(struct net_device *dev, u8 *bssid);
851 int ieee80211_sta_req_scan(struct net_device *dev, u8 *ssid, size_t ssid_len);
852 void ieee80211_sta_req_auth(struct net_device *dev,
853                             struct ieee80211_if_sta *ifsta);
854 int ieee80211_sta_scan_results(struct net_device *dev, char *buf, size_t len);
855 void ieee80211_sta_rx_scan(struct net_device *dev, struct sk_buff *skb,
856                            struct ieee80211_rx_status *rx_status);
857 void ieee80211_rx_bss_list_init(struct net_device *dev);
858 void ieee80211_rx_bss_list_deinit(struct net_device *dev);
859 int ieee80211_sta_set_extra_ie(struct net_device *dev, char *ie, size_t len);
860 struct sta_info * ieee80211_ibss_add_sta(struct net_device *dev,
861                                          struct sk_buff *skb, u8 *bssid,
862                                          u8 *addr);
863 int ieee80211_sta_deauthenticate(struct net_device *dev, u16 reason);
864 int ieee80211_sta_disassociate(struct net_device *dev, u16 reason);
865 void ieee80211_send_addts(struct net_device *dev,
866                           struct ieee80211_if_sta *ifsta,
867                           struct ieee80211_elem_tspec *tspec);
868 void wmm_send_addts(struct net_device *dev,
869                     struct ieee80211_if_sta *ifsta,
870                     struct ieee80211_elem_tspec *tspec);
871 void ieee80211_send_delts(struct net_device *dev,
872                           struct ieee80211_if_sta *ifsta,
873                           struct ieee80211_elem_tspec *tp);
874 void wmm_send_delts(struct net_device *dev,
875                     struct ieee80211_if_sta *ifsta,
876                     struct ieee80211_elem_tspec *tp);
877 void ieee80211_send_dls_req(struct net_device *dev,
878                             struct ieee80211_if_sta *ifsta,
879                             u8 *addr, u16 timeout);
880 void ieee80211_send_dls_teardown(struct net_device *dev,
881                                  struct ieee80211_if_sta *ifsta,
882                                  u8 *mac, u16 reason);
883 struct sta_info *dls_info_get(struct ieee80211_local *local, u8 *addr);
884 void dls_info_add(struct ieee80211_if_sta *ifsta, struct sta_info *dls);
885 void dls_info_stop(struct ieee80211_if_sta *ifsta);
886 int dls_link_status(struct ieee80211_local *local, u8 *addr);
887
888 /* ieee80211_iface.c */
889 int ieee80211_if_add(struct net_device *dev, const char *name,
890                      struct net_device **new_dev, int type);
891 void ieee80211_if_set_type(struct net_device *dev, int type);
892 void ieee80211_if_reinit(struct net_device *dev);
893 void __ieee80211_if_del(struct ieee80211_local *local,
894                         struct ieee80211_sub_if_data *sdata);
895 int ieee80211_if_remove(struct net_device *dev, const char *name, int id);
896 void ieee80211_if_free(struct net_device *dev);
897 void ieee80211_if_sdata_init(struct ieee80211_sub_if_data *sdata);
898 int ieee80211_if_add_mgmt(struct ieee80211_local *local);
899 void ieee80211_if_del_mgmt(struct ieee80211_local *local);
900
901 /* regdomain.c */
902 void ieee80211_regdomain_init(void);
903 void ieee80211_set_default_regdomain(struct ieee80211_hw_mode *mode);
904
905 /* for wiphy privid */
906 extern void *mac80211_wiphy_privid;
907
908 #endif /* IEEE80211_I_H */