add d80211 from a recent wireless-dev checkout
[openwrt.git] / package / d80211 / src / ieee80211_i.h
1 /*
2  * Copyright 2002-2005, Instant802 Networks, Inc.
3  * Copyright 2005, Devicescape Software, Inc.
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation.
8  */
9
10 #ifndef IEEE80211_I_H
11 #define IEEE80211_I_H
12
13 #include <linux/kernel.h>
14 #include <linux/device.h>
15 #include <linux/if_ether.h>
16 #include <linux/interrupt.h>
17 #include <linux/list.h>
18 #include <linux/netdevice.h>
19 #include <linux/skbuff.h>
20 #include <linux/workqueue.h>
21 #include <linux/types.h>
22 #include <linux/spinlock.h>
23 #include "ieee80211_key.h"
24 #include "sta_info.h"
25
26 /* ieee80211.o internal definitions, etc. These are not included into
27  * low-level drivers. */
28
29 #ifndef ETH_P_PAE
30 #define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
31 #endif /* ETH_P_PAE */
32
33 #define IEEE80211_MAX_SSID_LEN 32
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
53 /* IEEE 802.11 (Ch. 9.5 Defragmentation) requires support for concurrent
54  * reception of at least three fragmented frames. This limit can be increased
55  * by changing this define, at the cost of slower frame reassembly and
56  * increased memory use (about 2 kB of RAM per entry). */
57 #define IEEE80211_FRAGMENT_MAX 4
58
59 struct ieee80211_fragment_entry {
60         unsigned long first_frag_time;
61         unsigned int seq;
62         unsigned int rx_queue;
63         unsigned int last_frag;
64         unsigned int extra_len;
65         struct sk_buff_head skb_list;
66         int ccmp; /* Whether fragments were encrypted with CCMP */
67         u8 last_pn[6]; /* PN of the last fragment if CCMP was used */
68 };
69
70
71 struct ieee80211_sta_bss {
72         struct list_head list;
73         struct ieee80211_sta_bss *hnext;
74         atomic_t users;
75
76         u8 bssid[ETH_ALEN];
77         u8 ssid[IEEE80211_MAX_SSID_LEN];
78         size_t ssid_len;
79         u16 capability; /* host byte order */
80         int hw_mode;
81         int channel;
82         int freq;
83         int rssi;
84         u8 *wpa_ie;
85         size_t wpa_ie_len;
86         u8 *rsn_ie;
87         size_t rsn_ie_len;
88         u8 *wmm_ie;
89         size_t wmm_ie_len;
90 #define IEEE80211_MAX_SUPP_RATES 32
91         u8 supp_rates[IEEE80211_MAX_SUPP_RATES];
92         size_t supp_rates_len;
93         int beacon_int;
94         u64 timestamp;
95
96         int probe_resp;
97         unsigned long last_update;
98
99 };
100
101
102 typedef enum {
103         TXRX_CONTINUE, TXRX_DROP, TXRX_QUEUED
104 } ieee80211_txrx_result;
105
106 struct ieee80211_txrx_data {
107         struct sk_buff *skb;
108         struct net_device *dev;
109         struct ieee80211_local *local;
110         struct ieee80211_sub_if_data *sdata;
111         struct sta_info *sta;
112         u16 fc, ethertype;
113         struct ieee80211_key *key;
114         unsigned int fragmented:1; /* whether the MSDU was fragmented */
115         union {
116                 struct {
117                         struct ieee80211_tx_control *control;
118                         unsigned int unicast:1;
119                         unsigned int ps_buffered:1;
120                         unsigned int short_preamble:1;
121                         unsigned int probe_last_frag:1;
122                         struct ieee80211_rate *rate;
123                         /* use this rate (if set) for last fragment; rate can
124                          * be set to lower rate for the first fragments, e.g.,
125                          * when using CTS protection with IEEE 802.11g. */
126                         struct ieee80211_rate *last_frag_rate;
127                         int last_frag_rateidx;
128                         int last_frag_hwrate;
129                         int mgmt_interface;
130
131                         /* Extra fragments (in addition to the first fragment
132                          * in skb) */
133                         int num_extra_frag;
134                         struct sk_buff **extra_frag;
135                 } tx;
136                 struct {
137                         struct ieee80211_rx_status *status;
138                         int sent_ps_buffered;
139                         int queue;
140                         int load;
141                         unsigned int in_scan:1;
142                         /* frame is destined to interface currently processed
143                          * (including multicast frames) */
144                         unsigned int ra_match:1;
145                 } rx;
146         } u;
147 #ifdef CONFIG_HOSTAPD_WPA_TESTING
148         int wpa_test;
149 #endif /* CONFIG_HOSTAPD_WPA_TESTING */
150 };
151
152 /* Stored in sk_buff->cb */
153 struct ieee80211_tx_packet_data {
154         int ifindex;
155         unsigned long jiffies;
156         unsigned int req_tx_status:1;
157         unsigned int do_not_encrypt:1;
158         unsigned int pkt_probe_resp:1;
159         unsigned int requeue:1;
160         unsigned int queue:4;
161         unsigned int mgmt_iface:1;
162 };
163
164 struct ieee80211_tx_stored_packet {
165         struct ieee80211_tx_control control;
166         struct sk_buff *skb;
167         int num_extra_frag;
168         struct sk_buff **extra_frag;
169         int last_frag_rateidx;
170         int last_frag_hwrate;
171         unsigned int last_frag_rate_ctrl_probe:1;
172 };
173
174 struct ieee80211_passive_scan {
175         unsigned int in_scan:1; /* this must be cleared before calling
176                                  * netif_oper(WAKEUP) */
177         unsigned int our_mode_only:1; /* only scan our physical mode a/b/g/etc
178                                        */
179         int interval; /* time in seconds between scans */
180         int time; /* time in microseconds to scan for */
181         int channel; /* channel to be scanned */
182         int tries;
183
184         int mode_idx;
185         int chan_idx;
186
187         int freq;
188         int rx_packets;
189         int rx_beacon;
190         int txrx_count;
191
192         struct timer_list timer;
193
194         struct sk_buff *skb; /* skb to transmit before changing channels,
195                               * maybe null for none */
196         struct ieee80211_tx_control tx_control;
197
198         unsigned int num_scans;
199 };
200
201 typedef ieee80211_txrx_result (*ieee80211_tx_handler)
202 (struct ieee80211_txrx_data *tx);
203
204 typedef ieee80211_txrx_result (*ieee80211_rx_handler)
205 (struct ieee80211_txrx_data *rx);
206
207 struct ieee80211_if_ap {
208         u8 *beacon_head, *beacon_tail;
209         int beacon_head_len, beacon_tail_len;
210
211         u8 ssid[IEEE80211_MAX_SSID_LEN];
212         size_t ssid_len;
213         u8 *generic_elem;
214         size_t generic_elem_len;
215
216         /* yes, this looks ugly, but guarantees that we can later use
217          * bitmap_empty :)
218          * NB: don't ever use set_bit, use bss_tim_set/bss_tim_clear! */
219         u8 tim[sizeof(unsigned long) * BITS_TO_LONGS(IEEE80211_MAX_AID + 1)];
220         atomic_t num_sta_ps; /* number of stations in PS mode */
221         struct sk_buff_head ps_bc_buf;
222         int dtim_period, dtim_count;
223         int force_unicast_rateidx; /* forced TX rateidx for unicast frames */
224         int max_ratectrl_rateidx; /* max TX rateidx for rate control */
225         int num_beacons; /* number of TXed beacon frames for this BSS */
226 };
227
228 struct ieee80211_if_wds {
229         u8 remote_addr[ETH_ALEN];
230         struct sta_info *sta;
231 };
232
233 struct ieee80211_if_vlan {
234         u8 id;
235 };
236
237 struct ieee80211_if_sta {
238         enum {
239                 IEEE80211_DISABLED, IEEE80211_AUTHENTICATE,
240                 IEEE80211_ASSOCIATE, IEEE80211_ASSOCIATED,
241                 IEEE80211_IBSS_SEARCH, IEEE80211_IBSS_JOINED
242         } state;
243         struct work_struct work;
244         u8 bssid[ETH_ALEN], prev_bssid[ETH_ALEN];
245         u8 ssid[IEEE80211_MAX_SSID_LEN];
246         size_t ssid_len;
247         u16 aid;
248         u16 ap_capab, capab;
249         u8 *extra_ie; /* to be added to the end of AssocReq */
250         size_t extra_ie_len;
251
252         /* The last AssocReq/Resp IEs */
253         u8 *assocreq_ies, *assocresp_ies;
254         size_t assocreq_ies_len, assocresp_ies_len;
255
256         int auth_tries, assoc_tries;
257
258         unsigned int ssid_set:1;
259         unsigned int bssid_set:1;
260         unsigned int prev_bssid_set:1;
261         unsigned int authenticated:1;
262         unsigned int associated:1;
263         unsigned int probereq_poll:1;
264         unsigned int use_protection:1;
265         unsigned int create_ibss:1;
266         unsigned int mixed_cell:1;
267         unsigned int wmm_enabled:1;
268
269         int key_mgmt;
270         unsigned long last_probe;
271
272 #define IEEE80211_AUTH_ALG_OPEN BIT(0)
273 #define IEEE80211_AUTH_ALG_SHARED_KEY BIT(1)
274 #define IEEE80211_AUTH_ALG_LEAP BIT(2)
275         unsigned int auth_algs; /* bitfield of allowed auth algs */
276         int auth_alg; /* currently used IEEE 802.11 authentication algorithm */
277         int auth_transaction;
278
279         unsigned long ibss_join_req;
280         struct sk_buff *probe_resp; /* ProbeResp template for IBSS */
281         u32 supp_rates_bits;
282
283         int wmm_last_param_set;
284 };
285
286
287 struct ieee80211_sub_if_data {
288         struct list_head list;
289         unsigned int type;
290
291         struct net_device *dev;
292         struct ieee80211_local *local;
293
294         int mc_count;
295         unsigned int allmulti:1;
296         unsigned int promisc:1;
297
298         struct net_device_stats stats;
299         int drop_unencrypted;
300         int eapol; /* 0 = process EAPOL frames as normal data frames,
301                     * 1 = send EAPOL frames through wlan#ap to hostapd
302                     *     (default) */
303         int ieee802_1x; /* IEEE 802.1X PAE - drop packet to/from unauthorized
304                          * port */
305
306         /* Fragment table for host-based reassembly */
307         struct ieee80211_fragment_entry fragments[IEEE80211_FRAGMENT_MAX];
308         unsigned int fragment_next;
309
310 #define NUM_DEFAULT_KEYS 4
311         struct ieee80211_key *keys[NUM_DEFAULT_KEYS];
312         struct ieee80211_key *default_key;
313         struct kset key_kset;
314
315         struct ieee80211_if_ap *bss; /* BSS that this device belongs to */
316
317         union {
318                 struct ieee80211_if_ap ap;
319                 struct ieee80211_if_wds wds;
320                 struct ieee80211_if_vlan vlan;
321                 struct ieee80211_if_sta sta;
322         } u;
323         int channel_use;
324         int channel_use_raw;
325
326         struct attribute_group *sysfs_group;
327 };
328
329 #define IEEE80211_DEV_TO_SUB_IF(dev) netdev_priv(dev)
330
331 struct ieee80211_local {
332         /* embed the driver visible part.
333          * don't cast (use the static inlines below), but we keep
334          * it first anyway so they become a no-op */
335         struct ieee80211_hw hw;
336
337         struct ieee80211_ops *ops;
338
339         struct net_device *mdev; /* wmaster# - "master" 802.11 device */
340         struct net_device *apdev; /* wlan#ap - management frames (hostapd) */
341         int open_count;
342         int monitors;
343         struct iw_statistics wstats;
344
345         struct class_device class_dev;
346
347         enum {
348                 IEEE80211_DEV_UNITIALIZED = 0,
349                 IEEE80211_DEV_REGISTERED,
350                 IEEE80211_DEV_UNREGISTERED,
351         } reg_state;
352
353         /* Tasklet and skb queue to process calls from IRQ mode. All frames
354          * added to skb_queue will be processed, but frames in
355          * skb_queue_unreliable may be dropped if the total length of these
356          * queues increases over the limit. */
357 #define IEEE80211_IRQSAFE_QUEUE_LIMIT 128
358         struct tasklet_struct tasklet;
359         struct sk_buff_head skb_queue;
360         struct sk_buff_head skb_queue_unreliable;
361         enum {
362                 ieee80211_rx_msg = 1,
363                 ieee80211_tx_status_msg = 2
364         } ieee80211_msg_enum;
365
366         spinlock_t generic_lock;
367         /* Station data structures */
368         struct kset sta_kset;
369         spinlock_t sta_lock; /* mutex for STA data structures */
370         int num_sta; /* number of stations in sta_list */
371         struct list_head sta_list;
372         struct list_head deleted_sta_list;
373         struct sta_info *sta_hash[STA_HASH_SIZE];
374         struct timer_list sta_cleanup;
375
376         unsigned long state[NUM_TX_DATA_QUEUES];
377         struct ieee80211_tx_stored_packet pending_packet[NUM_TX_DATA_QUEUES];
378         struct tasklet_struct tx_pending_tasklet;
379
380         int mc_count;   /* total count of multicast entries in all interfaces */
381         int iff_allmultis, iff_promiscs;
382                         /* number of interfaces with corresponding IFF_ flags */
383
384         /* Current rate table. This is a pointer to hw->modes structure. */
385         struct ieee80211_rate *curr_rates;
386         int num_curr_rates;
387
388         struct rate_control_ref *rate_ctrl;
389
390         int next_mode; /* MODE_IEEE80211*
391                         * The mode preference for next channel change. This is
392                         * used to select .11g vs. .11b channels (or 4.9 GHz vs.
393                         * .11a) when the channel number is not unique. */
394
395         /* Supported and basic rate filters for different modes. These are
396          * pointers to -1 terminated lists and rates in 100 kbps units. */
397         int *supp_rates[NUM_IEEE80211_MODES];
398         int *basic_rates[NUM_IEEE80211_MODES];
399
400         int rts_threshold;
401         int cts_protect_erp_frames;
402         int fragmentation_threshold;
403         int short_retry_limit; /* dot11ShortRetryLimit */
404         int long_retry_limit; /* dot11LongRetryLimit */
405         int short_preamble; /* use short preamble with IEEE 802.11b */
406
407         struct crypto_blkcipher *wep_tx_tfm;
408         struct crypto_blkcipher *wep_rx_tfm;
409         u32 wep_iv;
410         int key_tx_rx_threshold; /* number of times any key can be used in TX
411                                   * or RX before generating a rekey
412                                   * notification; 0 = notification disabled. */
413
414         int bridge_packets; /* bridge packets between associated stations and
415                              * deliver multicast frames both back to wireless
416                              * media and to the local net stack */
417
418         struct ieee80211_passive_scan scan;
419
420
421         ieee80211_rx_handler *rx_pre_handlers;
422         ieee80211_rx_handler *rx_handlers;
423         ieee80211_tx_handler *tx_handlers;
424
425         spinlock_t sub_if_lock; /* mutex for STA data structures */
426         struct list_head sub_if_list;
427         int sta_scanning;
428         int scan_hw_mode_idx;
429         int scan_channel_idx;
430         enum { SCAN_SET_CHANNEL, SCAN_SEND_PROBE } scan_state;
431         unsigned long last_scan_completed;
432         struct work_struct scan_work;
433         int scan_oper_channel;
434         int scan_oper_channel_val;
435         int scan_oper_power_level;
436         int scan_oper_freq;
437         int scan_oper_phymode;
438         int scan_oper_antenna_max;
439         u8 scan_ssid[IEEE80211_MAX_SSID_LEN];
440         size_t scan_ssid_len;
441         struct list_head sta_bss_list;
442         struct ieee80211_sta_bss *sta_bss_hash[STA_HASH_SIZE];
443         spinlock_t sta_bss_lock;
444 #define IEEE80211_SCAN_MATCH_SSID BIT(0)
445 #define IEEE80211_SCAN_WPA_ONLY BIT(1)
446 #define IEEE80211_SCAN_EXTRA_INFO BIT(2)
447         int scan_flags;
448
449 #ifdef CONFIG_HOSTAPD_WPA_TESTING
450         u32 wpa_trigger;
451 #endif /* CONFIG_HOSTAPD_WPA_TESTING */
452         /* SNMP counters */
453         /* dot11CountersTable */
454         u32 dot11TransmittedFragmentCount;
455         u32 dot11MulticastTransmittedFrameCount;
456         u32 dot11FailedCount;
457         u32 dot11RetryCount;
458         u32 dot11MultipleRetryCount;
459         u32 dot11FrameDuplicateCount;
460         u32 dot11ReceivedFragmentCount;
461         u32 dot11MulticastReceivedFrameCount;
462         u32 dot11TransmittedFrameCount;
463         u32 dot11WEPUndecryptableCount;
464
465 #ifdef CONFIG_D80211_LEDS
466         int tx_led_counter, rx_led_counter;
467         struct led_trigger *tx_led, *rx_led;
468         char tx_led_name[32], rx_led_name[32];
469 #endif
470
471         u32 channel_use;
472         u32 channel_use_raw;
473         u32 stat_time;
474         struct timer_list stat_timer;
475
476         struct proc_dir_entry *proc, *proc_sta, *proc_iface;
477
478         struct work_struct sta_proc_add;
479
480         enum {
481                 STA_ANTENNA_SEL_AUTO = 0,
482                 STA_ANTENNA_SEL_SW_CTRL = 1,
483                 STA_ANTENNA_SEL_SW_CTRL_DEBUG = 2
484         } sta_antenna_sel;
485
486         int rate_ctrl_num_up, rate_ctrl_num_down;
487
488 #ifdef CONFIG_D80211_DEBUG_COUNTERS
489         /* TX/RX handler statistics */
490         unsigned int tx_handlers_drop;
491         unsigned int tx_handlers_queued;
492         unsigned int tx_handlers_drop_unencrypted;
493         unsigned int tx_handlers_drop_fragment;
494         unsigned int tx_handlers_drop_wep;
495         unsigned int tx_handlers_drop_not_assoc;
496         unsigned int tx_handlers_drop_unauth_port;
497         unsigned int rx_handlers_drop;
498         unsigned int rx_handlers_queued;
499         unsigned int rx_handlers_drop_nullfunc;
500         unsigned int rx_handlers_drop_defrag;
501         unsigned int rx_handlers_drop_short;
502         unsigned int rx_handlers_drop_passive_scan;
503         unsigned int tx_expand_skb_head;
504         unsigned int tx_expand_skb_head_cloned;
505         unsigned int rx_expand_skb_head;
506         unsigned int rx_expand_skb_head2;
507         unsigned int rx_handlers_fragments;
508         unsigned int tx_status_drop;
509         unsigned int wme_rx_queue[NUM_RX_DATA_QUEUES];
510         unsigned int wme_tx_queue[NUM_RX_DATA_QUEUES];
511 #define I802_DEBUG_INC(c) (c)++
512 #else /* CONFIG_D80211_DEBUG_COUNTERS */
513 #define I802_DEBUG_INC(c) do { } while (0)
514 #endif /* CONFIG_D80211_DEBUG_COUNTERS */
515
516
517         int default_wep_only; /* only default WEP keys are used with this
518                                * interface; this is used to decide when hwaccel
519                                * can be used with default keys */
520         int total_ps_buffered; /* total number of all buffered unicast and
521                                 * multicast packets for power saving stations
522                                 */
523         int allow_broadcast_always; /* whether to allow TX of broadcast frames
524                                      * even when there are no associated STAs
525                                      */
526
527         int wifi_wme_noack_test;
528         unsigned int wmm_acm; /* bit field of ACM bits (BIT(802.1D tag)) */
529
530         unsigned int enabled_modes; /* bitfield of allowed modes;
531                                       * (1 << MODE_*) */
532         unsigned int hw_modes; /* bitfield of supported hardware modes;
533                                 * (1 << MODE_*) */
534
535         int user_space_mlme;
536 };
537
538 static inline struct ieee80211_local *hw_to_local(
539         struct ieee80211_hw *hw)
540 {
541         return container_of(hw, struct ieee80211_local, hw);
542 }
543
544 static inline struct ieee80211_hw *local_to_hw(
545         struct ieee80211_local *local)
546 {
547         return &local->hw;
548 }
549
550 enum ieee80211_link_state_t {
551         IEEE80211_LINK_STATE_XOFF = 0,
552         IEEE80211_LINK_STATE_PENDING,
553 };
554
555 struct sta_attribute {
556         struct attribute attr;
557         ssize_t (*show)(const struct sta_info *, char *buf);
558         ssize_t (*store)(struct sta_info *, const char *buf, size_t count);
559 };
560
561 static inline void bss_tim_set(struct ieee80211_local *local,
562                                struct ieee80211_if_ap *bss, int aid)
563 {
564         spin_lock(&local->sta_lock);
565         bss->tim[(aid)/8] |= 1<<((aid) % 8);
566         spin_unlock(&local->sta_lock);
567 }
568
569 static inline void bss_tim_clear(struct ieee80211_local *local,
570                                  struct ieee80211_if_ap *bss, int aid)
571 {
572         spin_lock(&local->sta_lock);
573         bss->tim[(aid)/8] &= !(1<<((aid) % 8));
574         spin_unlock(&local->sta_lock);
575 }
576
577 /* ieee80211.c */
578 void ieee80211_release_hw(struct ieee80211_local *local);
579 int ieee80211_hw_config(struct ieee80211_local *local);
580 int ieee80211_if_config(struct net_device *dev);
581 int ieee80211_if_config_beacon(struct net_device *dev);
582 struct ieee80211_key_conf *
583 ieee80211_key_data2conf(struct ieee80211_local *local,
584                         struct ieee80211_key *data);
585 struct ieee80211_key *ieee80211_key_alloc(struct ieee80211_sub_if_data *sdata,
586                                           int idx, size_t key_len, gfp_t flags);
587 void ieee80211_key_free(struct ieee80211_key *key);
588 void ieee80211_key_release(struct kobject *kobj);
589 void ieee80211_rx_mgmt(struct ieee80211_local *local, struct sk_buff *skb,
590                        struct ieee80211_rx_status *status, u32 msg_type);
591 void ieee80211_prepare_rates(struct ieee80211_local *local);
592 void ieee80211_tx_set_iswep(struct ieee80211_txrx_data *tx);
593 int ieee80211_if_update_wds(struct net_device *dev, u8 *remote_addr);
594 void ieee80211_if_setup(struct net_device *dev);
595 void ieee80211_if_mgmt_setup(struct net_device *dev);
596 void ieee80211_if_shutdown(struct net_device *dev);
597 int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
598                                  const char *name);
599 struct net_device_stats *ieee80211_dev_stats(struct net_device *dev);
600
601 /* ieee80211_ioctl.c */
602 int ieee80211_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
603 extern const struct iw_handler_def ieee80211_iw_handler_def;
604 extern const struct iw_handler_def ieee80211_iw_master_handler_def;
605
606 /* Set hw encryption from ieee80211 */
607 int ieee80211_set_hw_encryption(struct net_device *dev,
608                                 struct sta_info *sta, u8 addr[ETH_ALEN],
609                                 struct ieee80211_key *key);
610
611 /* ieee80211_scan.c */
612 void ieee80211_init_scan(struct ieee80211_local *local);
613 void ieee80211_stop_scan(struct ieee80211_local *local);
614
615
616
617 /* Least common multiple of the used rates (in 100 kbps). This is used to
618  * calculate rate_inv values for each rate so that only integers are needed. */
619 #define CHAN_UTIL_RATE_LCM 95040
620 /* 1 usec is 1/8 * (95040/10) = 1188 */
621 #define CHAN_UTIL_PER_USEC 1188
622 /* Amount of bits to shift the result right to scale the total utilization
623  * to values that will not wrap around 32-bit integers. */
624 #define CHAN_UTIL_SHIFT 9
625 /* Theoretical maximum of channel utilization counter in 10 ms (stat_time=1):
626  * (CHAN_UTIL_PER_USEC * 10000) >> CHAN_UTIL_SHIFT = 23203. So dividing the
627  * raw value with about 23 should give utilization in 10th of a percentage
628  * (1/1000). However, utilization is only estimated and not all intervals
629  * between frames etc. are calculated. 18 seems to give numbers that are closer
630  * to the real maximum. */
631 #define CHAN_UTIL_PER_10MS 18
632 #define CHAN_UTIL_HDR_LONG (202 * CHAN_UTIL_PER_USEC)
633 #define CHAN_UTIL_HDR_SHORT (40 * CHAN_UTIL_PER_USEC)
634
635
636 /* ieee80211_ioctl.c */
637 int ieee80211_set_compression(struct ieee80211_local *local,
638                               struct net_device *dev, struct sta_info *sta);
639 int ieee80211_init_client(struct net_device *dev);
640 /* ieee80211_sta.c */
641 void ieee80211_sta_work(void *ptr);
642 void ieee80211_sta_rx_mgmt(struct net_device *dev, struct sk_buff *skb,
643                            struct ieee80211_rx_status *rx_status);
644 int ieee80211_sta_set_ssid(struct net_device *dev, char *ssid, size_t len);
645 int ieee80211_sta_get_ssid(struct net_device *dev, char *ssid, size_t *len);
646 int ieee80211_sta_set_bssid(struct net_device *dev, u8 *bssid);
647 int ieee80211_sta_req_scan(struct net_device *dev, u8 *ssid, size_t ssid_len);
648 int ieee80211_sta_scan_results(struct net_device *dev, char *buf, size_t len);
649 void ieee80211_sta_rx_scan(struct net_device *dev, struct sk_buff *skb,
650                            struct ieee80211_rx_status *rx_status);
651 void ieee80211_rx_bss_list_init(struct net_device *dev);
652 void ieee80211_rx_bss_list_deinit(struct net_device *dev);
653 int ieee80211_sta_set_extra_ie(struct net_device *dev, char *ie, size_t len);
654 struct sta_info * ieee80211_ibss_add_sta(struct net_device *dev,
655                                          struct sk_buff *skb, u8 *bssid,
656                                          u8 *addr);
657 int ieee80211_sta_deauthenticate(struct net_device *dev, u16 reason);
658 int ieee80211_sta_disassociate(struct net_device *dev, u16 reason);
659
660 /* ieee80211_dev.c */
661 int ieee80211_dev_alloc_index(struct ieee80211_local *local);
662 void ieee80211_dev_free_index(struct ieee80211_local *local);
663 struct ieee80211_local *ieee80211_dev_find(int index);
664 int ieee80211_dev_find_index(struct ieee80211_local *local);
665 struct ieee80211_local *ieee80211_dev_alloc(gfp_t flags);
666 void ieee80211_dev_free(struct ieee80211_local *local);
667
668 /* ieee80211_iface.c */
669 int ieee80211_if_add(struct net_device *dev, const char *name,
670                      int format, struct net_device **new_dev);
671 void ieee80211_if_set_type(struct net_device *dev, int type);
672 void ieee80211_if_reinit(struct net_device *dev);
673 void __ieee80211_if_del(struct ieee80211_local *local,
674                         struct ieee80211_sub_if_data *sdata);
675 void ieee80211_if_del(struct net_device *dev);
676 int ieee80211_if_remove(struct net_device *dev, const char *name, int id);
677 void ieee80211_if_free(struct net_device *dev);
678 void ieee80211_if_flush(struct net_device *dev);
679 void ieee80211_if_sdata_init(struct ieee80211_sub_if_data *sdata);
680 int ieee80211_if_add_mgmt(struct ieee80211_local *local);
681 void ieee80211_if_del_mgmt(struct ieee80211_local *local);
682
683 /* ieee80211_sysfs.c */
684 int ieee80211_sysfs_add_netdevice(struct net_device *dev);
685 void ieee80211_sysfs_remove_netdevice(struct net_device *dev);
686 void ieee80211_dev_sysfs_init(struct ieee80211_local *local);
687 void ieee80211_dev_sysfs_put(struct ieee80211_local *local);
688 int ieee80211_dev_sysfs_add(struct ieee80211_local *local);
689 void ieee80211_dev_sysfs_del(struct ieee80211_local *local);
690 int ieee80211_sysfs_init(void);
691 void ieee80211_sysfs_deinit(void);
692 int ieee80211_sysfs_change_if_type(struct net_device *dev);
693
694 /* ieee80211_sysfs_sta.c */
695 int ieee80211_sta_kset_sysfs_register(struct ieee80211_local *local);
696 void ieee80211_sta_kset_sysfs_unregister(struct ieee80211_local *local);
697 int ieee80211_sta_sysfs_add(struct sta_info *sta);
698 void ieee80211_sta_sysfs_remove(struct sta_info *sta);
699 int ieee80211_key_kset_sysfs_register(struct ieee80211_sub_if_data *sdata);
700 void ieee80211_key_kset_sysfs_unregister(struct ieee80211_sub_if_data *sdata);
701 void ieee80211_key_sysfs_set_kset(struct ieee80211_key *key, struct kset *kset);
702 int ieee80211_key_sysfs_add(struct ieee80211_key *key);
703 void ieee80211_key_sysfs_remove(struct ieee80211_key *key);
704 int ieee80211_key_sysfs_add_default(struct ieee80211_sub_if_data *sdata);
705 void ieee80211_key_sysfs_remove_default(struct ieee80211_sub_if_data *sdata);
706
707 #endif /* IEEE80211_I_H */