2 * Copyright 2002-2005, Instant802 Networks, Inc.
3 * Copyright 2005, Devicescape Software, Inc.
4 * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz>
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.
14 #include <linux/kernel.h>
15 #include <linux/device.h>
16 #include <linux/if_ether.h>
17 #include <linux/interrupt.h>
18 #include <linux/list.h>
19 #include <linux/netdevice.h>
20 #include <linux/skbuff.h>
21 #include <linux/workqueue.h>
22 #include <linux/types.h>
23 #include <linux/spinlock.h>
24 #include <linux/etherdevice.h>
25 #include <net/wireless.h>
26 #include "ieee80211_key.h"
29 /* ieee80211.o internal definitions, etc. These are not included into
30 * low-level drivers. */
33 #define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
34 #endif /* ETH_P_PAE */
36 #define WLAN_FC_DATA_PRESENT(fc) (((fc) & 0x4c) == 0x08)
38 struct ieee80211_local
;
40 #define BIT(x) (1 << (x))
42 #define IEEE80211_ALIGN32_PAD(a) ((4 - ((a) & 3)) & 3)
44 /* Maximum number of broadcast/multicast frames to buffer when some of the
45 * associated stations are using power saving. */
46 #define AP_MAX_BC_BUFFER 128
48 /* Maximum number of frames buffered to all STAs, including multicast frames.
49 * Note: increasing this limit increases the potential memory requirement. Each
50 * frame can be up to about 2 kB long. */
51 #define TOTAL_MAX_TX_BUFFER 512
53 /* Required encryption head and tailroom */
54 #define IEEE80211_ENCRYPT_HEADROOM 8
55 #define IEEE80211_ENCRYPT_TAILROOM 12
57 /* IEEE 802.11 (Ch. 9.5 Defragmentation) requires support for concurrent
58 * reception of at least three fragmented frames. This limit can be increased
59 * by changing this define, at the cost of slower frame reassembly and
60 * increased memory use (about 2 kB of RAM per entry). */
61 #define IEEE80211_FRAGMENT_MAX 4
63 struct ieee80211_fragment_entry
{
64 unsigned long first_frag_time
;
66 unsigned int rx_queue
;
67 unsigned int last_frag
;
68 unsigned int extra_len
;
69 struct sk_buff_head skb_list
;
70 int ccmp
; /* Whether fragments were encrypted with CCMP */
71 u8 last_pn
[6]; /* PN of the last fragment if CCMP was used */
75 struct ieee80211_sta_bss
{
76 struct list_head list
;
77 struct ieee80211_sta_bss
*hnext
;
81 u8 ssid
[IEEE80211_MAX_SSID_LEN
];
83 u16 capability
; /* host byte order */
87 int rssi
, signal
, noise
;
94 #define IEEE80211_MAX_SUPP_RATES 32
95 u8 supp_rates
[IEEE80211_MAX_SUPP_RATES
];
96 size_t supp_rates_len
;
101 unsigned long last_update
;
103 /* during assocation, we save an ERP value from a probe response so
104 * that we can feed ERP info to the driver when handling the
105 * association completes. these fields probably won't be up-to-date
106 * otherwise, you probably don't want to use them. */
113 TXRX_CONTINUE
, TXRX_DROP
, TXRX_QUEUED
114 } ieee80211_txrx_result
;
116 /* flags used in struct ieee80211_txrx_data.flags */
117 /* whether the MSDU was fragmented */
118 #define IEEE80211_TXRXD_FRAGMENTED BIT(0)
119 #define IEEE80211_TXRXD_TXUNICAST BIT(1)
120 #define IEEE80211_TXRXD_TXPS_BUFFERED BIT(2)
121 #define IEEE80211_TXRXD_TXPROBE_LAST_FRAG BIT(3)
122 #define IEEE80211_TXRXD_RXIN_SCAN BIT(4)
123 /* frame is destined to interface currently processed (incl. multicast frames) */
124 #define IEEE80211_TXRXD_RXRA_MATCH BIT(5)
125 struct ieee80211_txrx_data
{
127 struct net_device
*dev
;
128 struct ieee80211_local
*local
;
129 struct ieee80211_sub_if_data
*sdata
;
130 struct sta_info
*sta
;
132 struct ieee80211_key
*key
;
136 struct ieee80211_tx_control
*control
;
137 struct ieee80211_hw_mode
*mode
;
138 struct ieee80211_rate
*rate
;
139 /* use this rate (if set) for last fragment; rate can
140 * be set to lower rate for the first fragments, e.g.,
141 * when using CTS protection with IEEE 802.11g. */
142 struct ieee80211_rate
*last_frag_rate
;
143 int last_frag_hwrate
;
146 /* Extra fragments (in addition to the first fragment
149 struct sk_buff
**extra_frag
;
152 struct ieee80211_rx_status
*status
;
153 int sent_ps_buffered
;
160 /* flags used in struct ieee80211_tx_packet_data.flags */
161 #define IEEE80211_TXPD_REQ_TX_STATUS BIT(0)
162 #define IEEE80211_TXPD_DO_NOT_ENCRYPT BIT(1)
163 #define IEEE80211_TXPD_REQUEUE BIT(2)
164 #define IEEE80211_TXPD_MGMT_IFACE BIT(3)
165 /* Stored in sk_buff->cb */
166 struct ieee80211_tx_packet_data
{
168 unsigned long jiffies
;
173 struct ieee80211_tx_stored_packet
{
174 struct ieee80211_tx_control control
;
177 struct sk_buff
**extra_frag
;
178 int last_frag_rateidx
;
179 int last_frag_hwrate
;
180 struct ieee80211_rate
*last_frag_rate
;
181 unsigned int last_frag_rate_ctrl_probe
;
184 typedef ieee80211_txrx_result (*ieee80211_tx_handler
)
185 (struct ieee80211_txrx_data
*tx
);
187 typedef ieee80211_txrx_result (*ieee80211_rx_handler
)
188 (struct ieee80211_txrx_data
*rx
);
190 struct ieee80211_if_ap
{
191 u8
*beacon_head
, *beacon_tail
;
192 int beacon_head_len
, beacon_tail_len
;
194 u8 ssid
[IEEE80211_MAX_SSID_LEN
];
197 size_t generic_elem_len
;
199 /* yes, this looks ugly, but guarantees that we can later use
201 * NB: don't ever use set_bit, use bss_tim_set/bss_tim_clear! */
202 u8 tim
[sizeof(unsigned long) * BITS_TO_LONGS(IEEE80211_MAX_AID
+ 1)];
203 atomic_t num_sta_ps
; /* number of stations in PS mode */
204 struct sk_buff_head ps_bc_buf
;
205 int dtim_period
, dtim_count
;
206 int force_unicast_rateidx
; /* forced TX rateidx for unicast frames */
207 int max_ratectrl_rateidx
; /* max TX rateidx for rate control */
208 int num_beacons
; /* number of TXed beacon frames for this BSS */
211 struct ieee80211_if_wds
{
212 u8 remote_addr
[ETH_ALEN
];
213 struct sta_info
*sta
;
216 struct ieee80211_if_vlan
{
220 struct ieee80211_if_sta
{
222 IEEE80211_DISABLED
, IEEE80211_AUTHENTICATE
,
223 IEEE80211_ASSOCIATE
, IEEE80211_ASSOCIATED
,
224 IEEE80211_IBSS_SEARCH
, IEEE80211_IBSS_JOINED
226 struct timer_list timer
;
227 struct work_struct work
;
228 u8 bssid
[ETH_ALEN
], prev_bssid
[ETH_ALEN
];
229 u8 ssid
[IEEE80211_MAX_SSID_LEN
];
233 u8
*extra_ie
; /* to be added to the end of AssocReq */
236 /* The last AssocReq/Resp IEs */
237 u8
*assocreq_ies
, *assocresp_ies
;
238 size_t assocreq_ies_len
, assocresp_ies_len
;
240 int auth_tries
, assoc_tries
;
242 unsigned int ssid_set
:1;
243 unsigned int bssid_set
:1;
244 unsigned int prev_bssid_set
:1;
245 unsigned int authenticated
:1;
246 unsigned int associated
:1;
247 unsigned int probereq_poll
:1;
248 unsigned int create_ibss
:1;
249 unsigned int mixed_cell
:1;
250 unsigned int wmm_enabled
:1;
251 unsigned int auto_ssid_sel
:1;
252 unsigned int auto_bssid_sel
:1;
253 unsigned int auto_channel_sel
:1;
254 #define IEEE80211_STA_REQ_SCAN 0
255 #define IEEE80211_STA_REQ_AUTH 1
256 #define IEEE80211_STA_REQ_RUN 2
257 unsigned long request
;
258 struct sk_buff_head skb_queue
;
260 int key_management_enabled
;
261 unsigned long last_probe
;
263 #define IEEE80211_AUTH_ALG_OPEN BIT(0)
264 #define IEEE80211_AUTH_ALG_SHARED_KEY BIT(1)
265 #define IEEE80211_AUTH_ALG_LEAP BIT(2)
266 unsigned int auth_algs
; /* bitfield of allowed auth algs */
267 int auth_alg
; /* currently used IEEE 802.11 authentication algorithm */
268 int auth_transaction
;
270 unsigned long ibss_join_req
;
271 struct sk_buff
*probe_resp
; /* ProbeResp template for IBSS */
274 int wmm_last_param_set
;
278 struct ieee80211_sub_if_data
{
279 struct list_head list
;
282 struct wireless_dev wdev
;
284 struct net_device
*dev
;
285 struct ieee80211_local
*local
;
288 unsigned int allmulti
:1;
289 unsigned int promisc
:1;
290 unsigned int use_protection
:1; /* CTS protect ERP frames */
292 /* use short preamble with IEEE 802.11b: this flag is set when the AP
293 * or beacon generator reports that there are no present stations that
294 * cannot support short preambles */
295 unsigned int short_preamble
:1;
297 struct net_device_stats stats
;
298 int drop_unencrypted
;
299 int eapol
; /* 0 = process EAPOL frames as normal data frames,
300 * 1 = send EAPOL frames through wlan#ap to hostapd
302 int ieee802_1x
; /* IEEE 802.1X PAE - drop packet to/from unauthorized
307 /* Fragment table for host-based reassembly */
308 struct ieee80211_fragment_entry fragments
[IEEE80211_FRAGMENT_MAX
];
309 unsigned int fragment_next
;
311 #define NUM_DEFAULT_KEYS 4
312 struct ieee80211_key
*keys
[NUM_DEFAULT_KEYS
];
313 struct ieee80211_key
*default_key
;
315 struct ieee80211_if_ap
*bss
; /* BSS that this device belongs to */
318 struct ieee80211_if_ap ap
;
319 struct ieee80211_if_wds wds
;
320 struct ieee80211_if_vlan vlan
;
321 struct ieee80211_if_sta sta
;
326 #ifdef CONFIG_MAC80211_DEBUGFS
327 struct dentry
*debugfsdir
;
330 struct dentry
*channel_use
;
331 struct dentry
*drop_unencrypted
;
332 struct dentry
*eapol
;
333 struct dentry
*ieee8021_x
;
334 struct dentry
*state
;
335 struct dentry
*bssid
;
336 struct dentry
*prev_bssid
;
337 struct dentry
*ssid_len
;
339 struct dentry
*ap_capab
;
340 struct dentry
*capab
;
341 struct dentry
*extra_ie_len
;
342 struct dentry
*auth_tries
;
343 struct dentry
*assoc_tries
;
344 struct dentry
*auth_algs
;
345 struct dentry
*auth_alg
;
346 struct dentry
*auth_transaction
;
347 struct dentry
*flags
;
350 struct dentry
*channel_use
;
351 struct dentry
*drop_unencrypted
;
352 struct dentry
*eapol
;
353 struct dentry
*ieee8021_x
;
354 struct dentry
*num_sta_ps
;
355 struct dentry
*dtim_period
;
356 struct dentry
*dtim_count
;
357 struct dentry
*num_beacons
;
358 struct dentry
*force_unicast_rateidx
;
359 struct dentry
*max_ratectrl_rateidx
;
360 struct dentry
*num_buffered_multicast
;
361 struct dentry
*beacon_head_len
;
362 struct dentry
*beacon_tail_len
;
365 struct dentry
*channel_use
;
366 struct dentry
*drop_unencrypted
;
367 struct dentry
*eapol
;
368 struct dentry
*ieee8021_x
;
372 struct dentry
*channel_use
;
373 struct dentry
*drop_unencrypted
;
374 struct dentry
*eapol
;
375 struct dentry
*ieee8021_x
;
376 struct dentry
*vlan_id
;
381 struct dentry
*default_key
;
386 #define IEEE80211_DEV_TO_SUB_IF(dev) netdev_priv(dev)
389 IEEE80211_RX_MSG
= 1,
390 IEEE80211_TX_STATUS_MSG
= 2,
393 struct ieee80211_local
{
394 /* embed the driver visible part.
395 * don't cast (use the static inlines below), but we keep
396 * it first anyway so they become a no-op */
397 struct ieee80211_hw hw
;
399 const struct ieee80211_ops
*ops
;
401 /* List of registered struct ieee80211_hw_mode */
402 struct list_head modes_list
;
404 struct net_device
*mdev
; /* wmaster# - "master" 802.11 device */
405 struct net_device
*apdev
; /* wlan#ap - management frames (hostapd) */
408 struct iw_statistics wstats
;
410 int tx_headroom
; /* required headroom for hardware/radiotap */
413 IEEE80211_DEV_UNINITIALIZED
= 0,
414 IEEE80211_DEV_REGISTERED
,
415 IEEE80211_DEV_UNREGISTERED
,
418 /* Tasklet and skb queue to process calls from IRQ mode. All frames
419 * added to skb_queue will be processed, but frames in
420 * skb_queue_unreliable may be dropped if the total length of these
421 * queues increases over the limit. */
422 #define IEEE80211_IRQSAFE_QUEUE_LIMIT 128
423 struct tasklet_struct tasklet
;
424 struct sk_buff_head skb_queue
;
425 struct sk_buff_head skb_queue_unreliable
;
427 /* Station data structures */
428 rwlock_t sta_lock
; /* protects STA data structures */
429 int num_sta
; /* number of stations in sta_list */
430 struct list_head sta_list
;
431 struct sta_info
*sta_hash
[STA_HASH_SIZE
];
432 struct timer_list sta_cleanup
;
434 unsigned long state
[NUM_TX_DATA_QUEUES
];
435 struct ieee80211_tx_stored_packet pending_packet
[NUM_TX_DATA_QUEUES
];
436 struct tasklet_struct tx_pending_tasklet
;
438 int mc_count
; /* total count of multicast entries in all interfaces */
439 int iff_allmultis
, iff_promiscs
;
440 /* number of interfaces with corresponding IFF_ flags */
442 struct rate_control_ref
*rate_ctrl
;
444 int next_mode
; /* MODE_IEEE80211*
445 * The mode preference for next channel change. This is
446 * used to select .11g vs. .11b channels (or 4.9 GHz vs.
447 * .11a) when the channel number is not unique. */
449 /* Supported and basic rate filters for different modes. These are
450 * pointers to -1 terminated lists and rates in 100 kbps units. */
451 int *supp_rates
[NUM_IEEE80211_MODES
];
452 int *basic_rates
[NUM_IEEE80211_MODES
];
455 int fragmentation_threshold
;
456 int short_retry_limit
; /* dot11ShortRetryLimit */
457 int long_retry_limit
; /* dot11LongRetryLimit */
459 struct crypto_blkcipher
*wep_tx_tfm
;
460 struct crypto_blkcipher
*wep_rx_tfm
;
462 int key_tx_rx_threshold
; /* number of times any key can be used in TX
463 * or RX before generating a rekey
464 * notification; 0 = notification disabled. */
466 int bridge_packets
; /* bridge packets between associated stations and
467 * deliver multicast frames both back to wireless
468 * media and to the local net stack */
470 ieee80211_rx_handler
*rx_pre_handlers
;
471 ieee80211_rx_handler
*rx_handlers
;
472 ieee80211_tx_handler
*tx_handlers
;
474 rwlock_t sub_if_lock
; /* Protects sub_if_list. Cannot be taken under
475 * sta_bss_lock or sta_lock. */
476 struct list_head sub_if_list
;
478 int scan_channel_idx
;
479 enum { SCAN_SET_CHANNEL
, SCAN_SEND_PROBE
} scan_state
;
480 unsigned long last_scan_completed
;
481 struct delayed_work scan_work
;
482 struct net_device
*scan_dev
;
483 struct ieee80211_channel
*oper_channel
, *scan_channel
;
484 struct ieee80211_hw_mode
*oper_hw_mode
, *scan_hw_mode
;
485 u8 scan_ssid
[IEEE80211_MAX_SSID_LEN
];
486 size_t scan_ssid_len
;
487 struct list_head sta_bss_list
;
488 struct ieee80211_sta_bss
*sta_bss_hash
[STA_HASH_SIZE
];
489 spinlock_t sta_bss_lock
;
490 #define IEEE80211_SCAN_MATCH_SSID BIT(0)
491 #define IEEE80211_SCAN_WPA_ONLY BIT(1)
492 #define IEEE80211_SCAN_EXTRA_INFO BIT(2)
496 /* dot11CountersTable */
497 u32 dot11TransmittedFragmentCount
;
498 u32 dot11MulticastTransmittedFrameCount
;
499 u32 dot11FailedCount
;
501 u32 dot11MultipleRetryCount
;
502 u32 dot11FrameDuplicateCount
;
503 u32 dot11ReceivedFragmentCount
;
504 u32 dot11MulticastReceivedFrameCount
;
505 u32 dot11TransmittedFrameCount
;
506 u32 dot11WEPUndecryptableCount
;
508 #ifdef CONFIG_MAC80211_LEDS
509 int tx_led_counter
, rx_led_counter
;
510 struct led_trigger
*tx_led
, *rx_led
;
511 char tx_led_name
[32], rx_led_name
[32];
517 #ifdef CONFIG_MAC80211_DEBUGFS
518 struct work_struct sta_debugfs_add
;
521 #ifdef CONFIG_MAC80211_DEBUG_COUNTERS
522 /* TX/RX handler statistics */
523 unsigned int tx_handlers_drop
;
524 unsigned int tx_handlers_queued
;
525 unsigned int tx_handlers_drop_unencrypted
;
526 unsigned int tx_handlers_drop_fragment
;
527 unsigned int tx_handlers_drop_wep
;
528 unsigned int tx_handlers_drop_not_assoc
;
529 unsigned int tx_handlers_drop_unauth_port
;
530 unsigned int rx_handlers_drop
;
531 unsigned int rx_handlers_queued
;
532 unsigned int rx_handlers_drop_nullfunc
;
533 unsigned int rx_handlers_drop_defrag
;
534 unsigned int rx_handlers_drop_short
;
535 unsigned int rx_handlers_drop_passive_scan
;
536 unsigned int tx_expand_skb_head
;
537 unsigned int tx_expand_skb_head_cloned
;
538 unsigned int rx_expand_skb_head
;
539 unsigned int rx_expand_skb_head2
;
540 unsigned int rx_handlers_fragments
;
541 unsigned int tx_status_drop
;
542 unsigned int wme_rx_queue
[NUM_RX_DATA_QUEUES
];
543 unsigned int wme_tx_queue
[NUM_RX_DATA_QUEUES
];
544 #define I802_DEBUG_INC(c) (c)++
545 #else /* CONFIG_MAC80211_DEBUG_COUNTERS */
546 #define I802_DEBUG_INC(c) do { } while (0)
547 #endif /* CONFIG_MAC80211_DEBUG_COUNTERS */
550 int default_wep_only
; /* only default WEP keys are used with this
551 * interface; this is used to decide when hwaccel
552 * can be used with default keys */
553 int total_ps_buffered
; /* total number of all buffered unicast and
554 * multicast packets for power saving stations
556 int wifi_wme_noack_test
;
557 unsigned int wmm_acm
; /* bit field of ACM bits (BIT(802.1D tag)) */
559 unsigned int enabled_modes
; /* bitfield of allowed modes;
561 unsigned int hw_modes
; /* bitfield of supported hardware modes;
566 #ifdef CONFIG_MAC80211_DEBUGFS
567 struct local_debugfsdentries
{
568 struct dentry
*channel
;
569 struct dentry
*frequency
;
570 struct dentry
*antenna_sel_tx
;
571 struct dentry
*antenna_sel_rx
;
572 struct dentry
*bridge_packets
;
573 struct dentry
*key_tx_rx_threshold
;
574 struct dentry
*rts_threshold
;
575 struct dentry
*fragmentation_threshold
;
576 struct dentry
*short_retry_limit
;
577 struct dentry
*long_retry_limit
;
578 struct dentry
*total_ps_buffered
;
580 struct dentry
*wep_iv
;
581 struct dentry
*modes
;
582 struct dentry
*statistics
;
583 struct local_debugfsdentries_statsdentries
{
584 struct dentry
*transmitted_fragment_count
;
585 struct dentry
*multicast_transmitted_frame_count
;
586 struct dentry
*failed_count
;
587 struct dentry
*retry_count
;
588 struct dentry
*multiple_retry_count
;
589 struct dentry
*frame_duplicate_count
;
590 struct dentry
*received_fragment_count
;
591 struct dentry
*multicast_received_frame_count
;
592 struct dentry
*transmitted_frame_count
;
593 struct dentry
*wep_undecryptable_count
;
594 struct dentry
*num_scans
;
595 #ifdef CONFIG_MAC80211_DEBUG_COUNTERS
596 struct dentry
*tx_handlers_drop
;
597 struct dentry
*tx_handlers_queued
;
598 struct dentry
*tx_handlers_drop_unencrypted
;
599 struct dentry
*tx_handlers_drop_fragment
;
600 struct dentry
*tx_handlers_drop_wep
;
601 struct dentry
*tx_handlers_drop_not_assoc
;
602 struct dentry
*tx_handlers_drop_unauth_port
;
603 struct dentry
*rx_handlers_drop
;
604 struct dentry
*rx_handlers_queued
;
605 struct dentry
*rx_handlers_drop_nullfunc
;
606 struct dentry
*rx_handlers_drop_defrag
;
607 struct dentry
*rx_handlers_drop_short
;
608 struct dentry
*rx_handlers_drop_passive_scan
;
609 struct dentry
*tx_expand_skb_head
;
610 struct dentry
*tx_expand_skb_head_cloned
;
611 struct dentry
*rx_expand_skb_head
;
612 struct dentry
*rx_expand_skb_head2
;
613 struct dentry
*rx_handlers_fragments
;
614 struct dentry
*tx_status_drop
;
615 struct dentry
*wme_tx_queue
;
616 struct dentry
*wme_rx_queue
;
618 struct dentry
*dot11ACKFailureCount
;
619 struct dentry
*dot11RTSFailureCount
;
620 struct dentry
*dot11FCSErrorCount
;
621 struct dentry
*dot11RTSSuccessCount
;
623 struct dentry
*stations
;
629 static inline struct ieee80211_local
*hw_to_local(
630 struct ieee80211_hw
*hw
)
632 return container_of(hw
, struct ieee80211_local
, hw
);
635 static inline struct ieee80211_hw
*local_to_hw(
636 struct ieee80211_local
*local
)
641 enum ieee80211_link_state_t
{
642 IEEE80211_LINK_STATE_XOFF
= 0,
643 IEEE80211_LINK_STATE_PENDING
,
646 struct sta_attribute
{
647 struct attribute attr
;
648 ssize_t (*show
)(const struct sta_info
*, char *buf
);
649 ssize_t (*store
)(struct sta_info
*, const char *buf
, size_t count
);
652 static inline void __bss_tim_set(struct ieee80211_if_ap
*bss
, int aid
)
655 * This format has ben mandated by the IEEE specifications,
656 * so this line may not be changed to use the __set_bit() format.
658 bss
->tim
[(aid
)/8] |= 1<<((aid
) % 8);
661 static inline void bss_tim_set(struct ieee80211_local
*local
,
662 struct ieee80211_if_ap
*bss
, int aid
)
664 read_lock_bh(&local
->sta_lock
);
665 __bss_tim_set(bss
, aid
);
666 read_unlock_bh(&local
->sta_lock
);
669 static inline void __bss_tim_clear(struct ieee80211_if_ap
*bss
, int aid
)
672 * This format has ben mandated by the IEEE specifications,
673 * so this line may not be changed to use the __clear_bit() format.
675 bss
->tim
[(aid
)/8] &= !(1<<((aid
) % 8));
678 static inline void bss_tim_clear(struct ieee80211_local
*local
,
679 struct ieee80211_if_ap
*bss
, int aid
)
681 read_lock_bh(&local
->sta_lock
);
682 __bss_tim_clear(bss
, aid
);
683 read_unlock_bh(&local
->sta_lock
);
687 * ieee80211_is_erp_rate - Check if a rate is an ERP rate
688 * @phymode: The PHY-mode for this rate (MODE_IEEE80211...)
689 * @rate: Transmission rate to check, in 100 kbps
691 * Check if a given rate is an Extended Rate PHY (ERP) rate.
693 static inline int ieee80211_is_erp_rate(int phymode
, int rate
)
695 if (phymode
== MODE_IEEE80211G
) {
696 if (rate
!= 10 && rate
!= 20 &&
697 rate
!= 55 && rate
!= 110)
703 static inline int ieee80211_bssid_match(const u8
*raddr
, const u8
*addr
)
705 return compare_ether_addr(raddr
, addr
) == 0 ||
706 is_broadcast_ether_addr(raddr
);
711 int ieee80211_hw_config(struct ieee80211_local
*local
);
712 int ieee80211_if_config(struct net_device
*dev
);
713 int ieee80211_if_config_beacon(struct net_device
*dev
);
714 void ieee80211_rx_mgmt(struct ieee80211_local
*local
, struct sk_buff
*skb
,
715 struct ieee80211_rx_status
*status
, u32 msg_type
);
716 void ieee80211_prepare_rates(struct ieee80211_local
*local
,
717 struct ieee80211_hw_mode
*mode
);
718 void ieee80211_tx_set_iswep(struct ieee80211_txrx_data
*tx
);
719 int ieee80211_if_update_wds(struct net_device
*dev
, u8
*remote_addr
);
720 void ieee80211_if_setup(struct net_device
*dev
);
721 void ieee80211_if_mgmt_setup(struct net_device
*dev
);
722 struct net_device_stats
*ieee80211_dev_stats(struct net_device
*dev
);
723 struct ieee80211_rate
*ieee80211_get_rate(struct ieee80211_local
*local
,
724 int phymode
, int hwrate
);
725 void ieee80211_key_threshold_notify(struct net_device
*dev
,
726 struct ieee80211_key
*key
,
727 struct sta_info
*sta
);
729 /* ieee80211_ioctl.c */
730 extern const struct iw_handler_def ieee80211_iw_handler_def
;
732 void ieee80211_update_default_wep_only(struct ieee80211_local
*local
);
735 /* Least common multiple of the used rates (in 100 kbps). This is used to
736 * calculate rate_inv values for each rate so that only integers are needed. */
737 #define CHAN_UTIL_RATE_LCM 95040
738 /* 1 usec is 1/8 * (95040/10) = 1188 */
739 #define CHAN_UTIL_PER_USEC 1188
740 /* Amount of bits to shift the result right to scale the total utilization
741 * to values that will not wrap around 32-bit integers. */
742 #define CHAN_UTIL_SHIFT 9
743 /* Theoretical maximum of channel utilization counter in 10 ms (stat_time=1):
744 * (CHAN_UTIL_PER_USEC * 10000) >> CHAN_UTIL_SHIFT = 23203. So dividing the
745 * raw value with about 23 should give utilization in 10th of a percentage
746 * (1/1000). However, utilization is only estimated and not all intervals
747 * between frames etc. are calculated. 18 seems to give numbers that are closer
748 * to the real maximum. */
749 #define CHAN_UTIL_PER_10MS 18
750 #define CHAN_UTIL_HDR_LONG (202 * CHAN_UTIL_PER_USEC)
751 #define CHAN_UTIL_HDR_SHORT (40 * CHAN_UTIL_PER_USEC)
754 /* ieee80211_ioctl.c */
755 int ieee80211_set_compression(struct ieee80211_local
*local
,
756 struct net_device
*dev
, struct sta_info
*sta
);
757 int ieee80211_set_channel(struct ieee80211_local
*local
, int channel
, int freq
);
758 /* ieee80211_sta.c */
759 void ieee80211_sta_timer(unsigned long data
);
760 void ieee80211_sta_work(struct work_struct
*work
);
761 void ieee80211_sta_scan_work(struct work_struct
*work
);
762 void ieee80211_sta_rx_mgmt(struct net_device
*dev
, struct sk_buff
*skb
,
763 struct ieee80211_rx_status
*rx_status
);
764 int ieee80211_sta_set_ssid(struct net_device
*dev
, char *ssid
, size_t len
);
765 int ieee80211_sta_get_ssid(struct net_device
*dev
, char *ssid
, size_t *len
);
766 int ieee80211_sta_set_bssid(struct net_device
*dev
, u8
*bssid
);
767 int ieee80211_sta_req_scan(struct net_device
*dev
, u8
*ssid
, size_t ssid_len
);
768 void ieee80211_sta_req_auth(struct net_device
*dev
,
769 struct ieee80211_if_sta
*ifsta
);
770 int ieee80211_sta_scan_results(struct net_device
*dev
, char *buf
, size_t len
);
771 void ieee80211_sta_rx_scan(struct net_device
*dev
, struct sk_buff
*skb
,
772 struct ieee80211_rx_status
*rx_status
);
773 void ieee80211_rx_bss_list_init(struct net_device
*dev
);
774 void ieee80211_rx_bss_list_deinit(struct net_device
*dev
);
775 int ieee80211_sta_set_extra_ie(struct net_device
*dev
, char *ie
, size_t len
);
776 struct sta_info
* ieee80211_ibss_add_sta(struct net_device
*dev
,
777 struct sk_buff
*skb
, u8
*bssid
,
779 int ieee80211_sta_deauthenticate(struct net_device
*dev
, u16 reason
);
780 int ieee80211_sta_disassociate(struct net_device
*dev
, u16 reason
);
781 void ieee80211_erp_info_change_notify(struct net_device
*dev
, u8 changes
);
782 void ieee80211_reset_erp_info(struct net_device
*dev
);
784 /* ieee80211_iface.c */
785 int ieee80211_if_add(struct net_device
*dev
, const char *name
,
786 struct net_device
**new_dev
, int type
);
787 void ieee80211_if_set_type(struct net_device
*dev
, int type
);
788 void ieee80211_if_reinit(struct net_device
*dev
);
789 void __ieee80211_if_del(struct ieee80211_local
*local
,
790 struct ieee80211_sub_if_data
*sdata
);
791 int ieee80211_if_remove(struct net_device
*dev
, const char *name
, int id
);
792 void ieee80211_if_free(struct net_device
*dev
);
793 void ieee80211_if_sdata_init(struct ieee80211_sub_if_data
*sdata
);
794 int ieee80211_if_add_mgmt(struct ieee80211_local
*local
);
795 void ieee80211_if_del_mgmt(struct ieee80211_local
*local
);
798 void ieee80211_regdomain_init(void);
799 void ieee80211_set_default_regdomain(struct ieee80211_hw_mode
*mode
);
802 extern ieee80211_rx_handler ieee80211_rx_pre_handlers
[];
803 extern ieee80211_rx_handler ieee80211_rx_handlers
[];
806 extern ieee80211_tx_handler ieee80211_tx_handlers
[];
807 void ieee80211_clear_tx_pending(struct ieee80211_local
*local
);
808 void ieee80211_tx_pending(unsigned long data
);
809 int ieee80211_master_start_xmit(struct sk_buff
*skb
, struct net_device
*dev
);
810 int ieee80211_monitor_start_xmit(struct sk_buff
*skb
, struct net_device
*dev
);
811 int ieee80211_subif_start_xmit(struct sk_buff
*skb
, struct net_device
*dev
);
812 int ieee80211_mgmt_start_xmit(struct sk_buff
*skb
, struct net_device
*dev
);
815 struct ieee80211_key_conf
*
816 ieee80211_key_data2conf(struct ieee80211_local
*local
,
817 const struct ieee80211_key
*data
);
818 struct ieee80211_key
*ieee80211_key_alloc(struct ieee80211_sub_if_data
*sdata
,
819 int idx
, size_t key_len
, gfp_t flags
);
820 void ieee80211_key_free(struct ieee80211_key
*key
);
822 /* utility functions/constants */
823 extern void *mac80211_wiphy_privid
; /* for wiphy privid */
824 extern const unsigned char rfc1042_header
[6];
825 extern const unsigned char bridge_tunnel_header
[6];
826 u8
*ieee80211_get_bssid(struct ieee80211_hdr
*hdr
, size_t len
);
827 int ieee80211_is_eapol(const struct sk_buff
*skb
);
828 int ieee80211_frame_duration(struct ieee80211_local
*local
, size_t len
,
829 int rate
, int erp
, int short_preamble
);
830 void mac80211_ev_michael_mic_failure(struct net_device
*dev
, int keyidx
,
831 struct ieee80211_hdr
*hdr
);
833 #endif /* IEEE80211_I_H */