2 * Low-level hardware driver -- IEEE 802.11 driver (80211.o) interface
3 * Copyright 2002-2005, Devicescape Software, Inc.
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.
13 #include "ieee80211_shared.h"
15 /* Note! Only ieee80211_tx_status_irqsafe() and ieee80211_rx_irqsave() can be
16 * called in hardware interrupt context. The low-level driver must not call any
17 * other functions in hardware interrupt context. If there is a need for such
18 * call, the low-level driver should first ACK the interrupt and perform the
19 * IEEE 802.11 code call after this, e.g., from a scheduled tasklet (in
20 * software interrupt context).
24 * Frame format used when passing frame between low-level hardware drivers
25 * and IEEE 802.11 driver the same as used in the wireless media, i.e.,
26 * buffers start with IEEE 802.11 header and include the same octets that
29 * If hardware uses IEEE 802.3 headers (and perform 802.3 <-> 802.11
30 * conversion in firmware), upper layer 802.11 code needs to be changed to
33 * If the receive frame format is not the same as the real frame sent
34 * on the wireless media (e.g., due to padding etc.), upper layer 802.11 code
35 * could be updated to provide support for such format assuming this would
36 * optimize the performance, e.g., by removing need to re-allocation and
37 * copying of the data.
40 /* Interface version (used for compatibility verification) */
41 #define IEEE80211_VERSION 2
44 /* Channel information structure. Low-level driver is expected to fill in chan,
45 * freq, and val fields. Other fields will be filled in by 80211.o based on
46 * hostapd information and low-level driver does not need to use them. The
47 * limits for each channel will be provided in 'struct ieee80211_conf' when
48 * configuring the low-level driver with hw->config callback. */
49 struct ieee80211_channel
{
50 short chan
; /* channel number (IEEE 802.11) */
51 short freq
; /* frequency in MHz */
52 int val
; /* hw specific value for the channel */
53 int flag
; /* flag for hostapd use (IEEE80211_CHAN_*) */
54 unsigned char power_level
;
55 unsigned char antenna_max
;
58 struct ieee80211_rate
{
59 int rate
; /* rate in 100 kbps */
60 int val
; /* hw specific value for the rate */
61 int flags
; /* IEEE80211_RATE_ flags */
62 int val2
; /* hw specific value for the rate when using short preamble
63 * (only when IEEE80211_RATE_PREAMBLE2 flag is set, i.e., for
64 * 2, 5.5, and 11 Mbps) */
65 signed char min_rssi_ack
;
66 unsigned char min_rssi_ack_delta
;
68 /* following fields are set by 80211.o and need not be filled by the
70 int rate_inv
; /* inverse of the rate (LCM(all rates) / rate) for
71 * optimizing channel utilization estimates */
74 struct ieee80211_hw_modes
{
77 struct ieee80211_channel
*channels
;
79 struct ieee80211_rate
*rates
;
80 int xr_end
; /* only used with Atheros XR */
83 struct ieee80211_tx_queue_params
{
84 int aifs
; /* 0 .. 255; -1 = use default */
85 int cw_min
; /* 2^n-1: 1, 3, 7, .. , 1023; 0 = use default */
86 int cw_max
; /* 2^n-1: 1, 3, 7, .. , 1023; 0 = use default */
87 int burst_time
; /* maximum burst time in 0.1 ms (i.e., 10 = 1 ms);
91 #define NUM_TX_DATA_QUEUES 6
93 struct ieee80211_tx_queue_stats_data
{
94 unsigned int len
; /* num packets in queue */
95 unsigned int limit
; /* queue len (soft) limit */
96 unsigned int count
; /* total num frames sent */
99 struct ieee80211_tx_queue_stats
{
100 struct ieee80211_tx_queue_stats_data data
[NUM_TX_DATA_QUEUES
];
103 #ifndef IEEE80211_TX_QUEUE_NUMS
104 #define IEEE80211_TX_QUEUE_NUMS
105 /* TODO: these need to be synchronized with hostapd_ioctl.h; make a shared
106 * header file that can be included into low-level drivers, 80211.o, and
109 IEEE80211_TX_QUEUE_DATA0
= 0,
110 IEEE80211_TX_QUEUE_DATA1
= 1,
111 IEEE80211_TX_QUEUE_DATA2
= 2,
112 IEEE80211_TX_QUEUE_DATA3
= 3,
113 IEEE80211_TX_QUEUE_DATA4
= 4,
114 IEEE80211_TX_QUEUE_SVP
= 5,
115 IEEE80211_TX_QUEUE_AFTER_BEACON
= 6,
116 IEEE80211_TX_QUEUE_BEACON
= 7
118 #endif /* IEEE80211_TX_QUEUE_NUMS */
121 struct ieee80211_low_level_stats
{
122 unsigned int dot11ACKFailureCount
;
123 unsigned int dot11RTSFailureCount
;
124 unsigned int dot11FCSErrorCount
;
125 unsigned int dot11RTSSuccessCount
;
128 /* Transmit control fields. This data structure is passed to low-level driver
129 * with each TX frame. The low-level driver is responsible of configuring
130 * hardware to use given values (depending on what is supported). */
131 #define HW_KEY_IDX_INVALID -1
133 struct ieee80211_tx_control
{
134 enum { PKT_NORMAL
= 0, PKT_PROBE_RESP
} pkt_type
;
135 int tx_rate
; /* Transmit rate, given as the hw specific value for the
136 * rate (from struct ieee80211_rate) */
137 int rts_cts_rate
; /* Transmit rate for RTS/CTS frame, given as the hw
138 * specific value for the rate (from
139 * struct ieee80211_rate) */
140 /* 1 = only first attempt, 2 = one retry, .. */
141 unsigned int retry_limit
:8;
142 /* duration field for RTS/CTS frame */
143 unsigned int rts_cts_duration
:16;
144 /* TODO: change these bit flags to use one unsigned int variable and
145 * defines with BIT(n). These are copied to TX status structure and
146 * this will make the code faster and smaller. */
147 unsigned int req_tx_status
:1; /* request TX status callback for this
149 unsigned int do_not_encrypt
:1; /* send this frame without encryption;
150 * e.g., for EAPOL frames */
151 unsigned int use_rts_cts
:1; /* Use RTS-CTS before sending frame. */
152 unsigned int use_cts_protect
:1; /* Use CTS protection for the frame
153 * (e.g., for combined 802.11g /
154 * 802.11b networks) */
155 unsigned int no_ack
:1; /* Tell the low level not to wait for an ack */
156 unsigned int rate_ctrl_probe
:1;
157 unsigned int clear_dst_mask
:1;
158 unsigned int requeue
:1;
159 /* following three flags are only used with Atheros Super A/G */
160 unsigned int compress
:1;
161 unsigned int turbo_prime_notify
:1; /* notify HostaAPd after frame
163 unsigned int fast_frame
:1;
165 unsigned int atheros_xr
:1; /* only used with Atheros XR */
167 unsigned int power_level
:8; /* per-packet transmit power level, in dBm
169 unsigned int antenna_sel
:4; /* 0 = default/diversity,
170 * 1 = Ant0, 2 = Ant1 */
171 int key_idx
:8; /* -1 = do not encrypt, >= 0 keyidx from hw->set_key()
173 int icv_len
:8; /* Length of the ICV/MIC field in octets */
174 int iv_len
:8; /* Length of the IV field in octets */
175 unsigned int queue
:4; /* hardware queue to use for this frame;
176 * 0 = highest, hw->queues-1 = lowest */
177 unsigned int sw_retry_attempt
:4; /* no. of times hw has tried to
178 * transmit frame (not incl. hw retries) */
181 int rateidx
; /* internal 80211.o rateidx, to be copied to tx_status */
182 int alt_retry_rate
; /* retry rate for the last retries, given as the
183 * hw specific value for the rate (from
184 * struct ieee80211_rate). To be used to limit
185 * packet dropping when probing higher rates, if hw
186 * supports multiple retry rates. -1 = not used */
190 #define IEEE80211_CB_MAGIC 0xAAB80211
192 struct ieee80211_tx_packet_data
{
194 struct ieee80211_tx_control control
;
195 unsigned long jiffies
;
196 struct ieee80211_sub_if_data
*sdata
;
199 #define RX_FLAG_MMIC_ERROR 0x1
200 #define RX_FLAG_DECRYPTED 0x2
201 #define RX_FLAG_XR_DOUBLE_CHIRP 0x4
203 /* Receive status. The low-level driver should provide this information
204 * (the subset supported by hardware) to the 802.11 code with each received
206 * Current implementation copies this into skb->cb, so it must be less than
208 struct ieee80211_rx_status
{
213 int freq
; /* receive frequency in Mhz */
222 /* Transmit status. The low-level driver should provide this information
223 * (the subset supported by hardware) to the 802.11 code for each transmit
225 struct ieee80211_tx_status
{
226 /* flags copied from struct ieee80211_tx_control) */
227 unsigned int req_tx_status
:1; /* whether TX status was explicitly
229 unsigned int rate_ctrl_probe
:1; /* whether this was a probe packet from
231 unsigned int tx_filtered
:1;
233 /* following three fields are only used with Atheros Super A/G */
234 unsigned int turbo_prime_notify
:1; /* notify HostAPd - CTS for Turbo
236 int queue_length
; /* information about TX queue */
239 int ack
; /* whether the TX frame was ACKed */
240 int ack_signal
; /* measured signal strength of the ACK frame */
241 int excessive_retries
;
243 int rateidx
; /* internal 80211.o rateidx, to be copied to tx_status */
247 struct ieee80211_conf
{
248 int channel
; /* IEEE 802.11 channel number */
250 int channel_val
; /* hw specific value for the channel */
252 int mode
; /* IW_MODE_ */
254 int phymode
; /* MODE_IEEE80211A, .. */
255 unsigned int regulatory_domain
;
260 /* Bitfields, grouped together */
264 int short_slot_time
:1; /* use IEEE 802.11g Short Slot Time */
265 int ssid_hidden
:1; /* do not broadcast the ssid */
267 /* these fields are used by low level drivers for hardware
268 * that generate beacons independently */
272 size_t generic_elem_len
;
274 u8 power_level
; /* transmit power limit for current
275 * regulatory domain; in dBm */
276 u8 antenna_max
; /* maximum antenna gain */
277 short tx_power_reduction
; /* in 0.1 dBm */
279 int antenna_sel
; /* default antenna conf:
280 * 0 = default/diversity,
284 int calib_int
; /* hw/radio calibration interval in
289 u8 bssid_mask
[ETH_ALEN
]; /* ff:ff:ff:ff:ff:ff = 1 BSSID */
292 int atheros_super_ag_compression
;
293 int atheros_super_ag_fast_frame
;
294 int atheros_super_ag_burst
;
295 int atheros_super_ag_wme_ele
;
296 int atheros_super_ag_turbo_g
;
297 int atheros_super_ag_turbo_prime
;
301 u8 client_bssid
[ETH_ALEN
];
303 /* Following five fields are used for IEEE 802.11H */
304 unsigned int radar_detect
;
305 unsigned int spect_mgmt
;
306 unsigned int quiet_duration
; /* duration of quiet period */
307 unsigned int quiet_offset
; /* how far into the beacon is the quiet
309 unsigned int quiet_period
;
313 typedef enum { ALG_NONE
, ALG_WEP
, ALG_TKIP
, ALG_CCMP
, ALG_NULL
}
317 struct ieee80211_key_conf
{
319 int hw_key_idx
; /* filled + used by low-level driver */
320 ieee80211_key_alg alg
;
323 int force_sw_encrypt
:1; /* to be cleared by low-level driver */
324 int keyidx
:8; /* WEP key index */
325 int default_tx_key
:1; /* This key is the new default TX key
326 * (used only for broadcast keys). */
327 int default_wep_only
:1; /* static WEP is the only configured security
328 * policy; this allows some low-level drivers
329 * to determine when hwaccel can be used */
333 #define IEEE80211_SCAN_START 1
334 #define IEEE80211_SCAN_END 2
336 struct ieee80211_scan_conf
{
337 int scan_channel
; /* IEEE 802.11 channel number to do passive scan
339 int scan_freq
; /* new freq in MHz to switch to for passive scan
341 int scan_channel_val
; /* hw specific value for the channel */
342 int scan_phymode
; /* MODE_IEEE80211A, .. */
343 unsigned char scan_power_level
;
344 unsigned char scan_antenna_max
;
347 int running_channel
; /* IEEE 802.11 channel number we operate on
349 int running_freq
; /* freq in MHz we're operating on normally */
350 int running_channel_val
; /* hw specific value for the channel */
352 unsigned char running_power_level
;
353 unsigned char running_antenna_max
;
355 int scan_time
; /* time a scan will take in us */
358 struct sk_buff
*skb
; /* skb to transmit before changing channels, maybe
360 struct ieee80211_tx_control
*tx_control
;
364 #ifndef IW_MODE_ADHOC
365 #define IW_MODE_ADHOC 1
368 #ifndef IW_MODE_INFRA
369 #define IW_MODE_INFRA 2
372 #ifndef IW_MODE_MASTER
373 #define IW_MODE_MASTER 3
376 #ifndef IW_MODE_MONITOR
377 #define IW_MODE_MONITOR 6
380 #define IEEE80211_SEQ_COUNTER_RX 0
381 #define IEEE80211_SEQ_COUNTER_TX 1
384 SET_KEY
, DISABLE_KEY
, REMOVE_ALL_KEYS
,
385 ENABLE_COMPRESSION
, DISABLE_COMPRESSION
388 /* Configuration block used by the low-level driver to tell 802.11 code about
389 * supported hardware features and to pass function pointers for callback
391 struct ieee80211_hw
{
392 int version
; /* IEEE80211_VERSION */
397 /* TODO: frame_type 802.11/802.3, sw_encryption requirements */
399 /* Some wireless LAN chipsets generate beacons in the hardware/firmware
400 * and others rely on host generated beacons. This option is used to
401 * configure upper layer IEEE 802.11 module to generate beacons. The
402 * low-level driver can use ieee80211_beacon_get() to fetch next
404 int host_gen_beacon
:1;
407 /* Some devices handle decryption internally and do not
408 * indicate whether the frame was encrypted (unencrypted frames
409 * will be dropped by the hardware, unless specifically allowed
411 int device_hides_wep
:1;
413 /* Whether RX frames passed to ieee80211_rx() include FCS in the end
415 int rx_includes_fcs
:1;
417 /* Some wireless LAN chipsets buffer broadcast/multicast frames for
418 * power saving stations in the hardware/firmware and others rely on
419 * the host system for such buffering. This option is used to
420 * configure upper layer IEEE 802.11 to buffer broadcast/multicast
421 * frames when there are power saving stations so that low-level driver
422 * can fetch them with ieee80211_get_buffered_bc(). */
423 int host_broadcast_ps_buffering
:1;
425 int wep_include_iv
:1;
426 int data_nullfunc_ack
:1; /* will data nullfunc frames get proper
427 * TX status callback */
429 /* Force sw version of encryption for TKIP packets if WMM is enabled.
431 int no_tkip_wmm_hwaccel
:1;
433 /* 1 if the payload needs to be padded at even boundaries after the
435 unsigned int extra_hdr_room
:1;
437 /* Some devices handle Michael MIC internally and do not include MIC in
438 * the received packets given to 80211.o. device_strips_mic must be set
439 * for such devices. ISWEP bit is still expected to be set in the IEEE
440 * 802.11 header with this option unlike with device_hides_wep option.
442 unsigned int device_strips_mic
:1;
444 /* 1 = low-level driver supports skb fraglist (NETIF_F_FRAGLIST), i.e.,
445 * more than one skb per frame */
446 unsigned int fraglist
;
448 /* This is the time in us to change channels
450 int channel_change_time
;
453 struct ieee80211_hw_modes
*modes
;
455 /* Handler that 802.11 module calls for each transmitted frame.
456 * skb contains the buffer starting from the IEEE 802.11 header.
457 * The low-level driver should send the frame out based on
458 * configuration in the TX control data. */
459 int (*tx
)(struct net_device
*dev
, struct sk_buff
*skb
,
460 struct ieee80211_tx_control
*control
);
462 /* Handler for performing hardware reset. */
463 int (*reset
)(struct net_device
*dev
);
465 /* Handler that is called when any netdevice attached to the hardware
466 * device is set UP for the first time. This can be used, e.g., to
467 * enable interrupts and beacon sending. */
468 int (*open
)(struct net_device
*dev
);
470 /* Handler that is called when the last netdevice attached to the
471 * hardware device is set DOWN. This can be used, e.g., to disable
472 * interrupts and beacon sending. */
473 int (*stop
)(struct net_device
*dev
);
475 /* Handler for configuration requests. IEEE 802.11 code calls this
476 * function to change hardware configuration, e.g., channel. */
477 int (*config
)(struct net_device
*dev
, struct ieee80211_conf
*conf
);
479 /* Set TIM bit handler. If the hardware/firmware takes care of beacon
480 * generation, IEEE 802.11 code uses this function to tell the
481 * low-level to set (or clear if set==0) TIM bit for the given aid. If
482 * host system is used to generate beacons, this handler is not used
483 * and low-level driver should set it to NULL. */
484 int (*set_tim
)(struct net_device
*dev
, int aid
, int set
);
486 /* Set encryption key. IEEE 802.11 module calls this function to set
487 * encryption keys. addr is ff:ff:ff:ff:ff:ff for default keys and
488 * station hwaddr for individual keys. aid of the station is given
489 * to help low-level driver in selecting which key->hw_key_idx to use
490 * for this key. TX control data will use the hw_key_idx selected by
491 * the low-level driver. */
492 int (*set_key
)(struct net_device
*dev
, set_key_cmd cmd
, u8
*addr
,
493 struct ieee80211_key_conf
*key
, int aid
);
495 /* Set TX key index for default/broadcast keys. This is needed in cases
496 * where wlan card is doing full WEP/TKIP encapsulation (wep_include_iv
497 * is not set), in other cases, this function pointer can be set to
498 * NULL since 80211.o takes care of selecting the key index for each
500 int (*set_key_idx
)(struct net_device
*dev
, int idx
);
502 /* Enable/disable IEEE 802.1X. This item requests wlan card to pass
503 * unencrypted EAPOL-Key frames even when encryption is configured.
504 * If the wlan card does not require such a configuration, this
505 * function pointer can be set to NULL. 80211.o */
506 int (*set_ieee8021x
)(struct net_device
*dev
, int use_ieee8021x
);
508 /* Set port authorization state (IEEE 802.1X PAE) to be authorized
509 * (authorized=1) or unauthorized (authorized=0). This function can be
510 * used if the wlan hardware or low-level driver implements PAE.
511 * 80211.o module will anyway filter frames based on authorization
512 * state, so this function pointer can be NULL if low-level driver does
513 * not require event notification about port state changes. */
514 int (*set_port_auth
)(struct net_device
*dev
, u8
*addr
, int authorized
);
516 /* Ask the hardware to do a passive scan on a new channel. The hardware
517 * will do what ever is required to nicely leave the current channel
518 * including transmit any CTS packets, etc. */
519 int (*passive_scan
)(struct net_device
*dev
, int state
,
520 struct ieee80211_scan_conf
*conf
);
522 /* return low-level statistics */
523 int (*get_stats
)(struct net_device
*dev
,
524 struct ieee80211_low_level_stats
*stats
);
526 /* Enable/disable test modes; mode = IEEE80211_TEST_* */
527 int (*test_mode
)(struct net_device
*dev
, int mode
);
529 /* Configuration of test parameters */
530 int (*test_param
)(struct net_device
*dev
, int param
, int value
);
532 /* Change MAC address. addr is pointer to struct sockaddr. */
533 int (*set_mac_address
)(struct net_device
*dev
, void *addr
);
535 /* For devices that generate their own beacons and probe response
536 * or association responses this updates the state of privacy_invoked
537 * returns 0 for success or an error number */
539 int (*set_privacy_invoked
)(struct net_device
*dev
,
540 int privacy_invoked
);
542 /* For devices that have internal sequence counters, allow 802.11
543 * code to access the current value of a counter */
544 int (*get_sequence_counter
)(struct net_device
*dev
,
545 u8
* addr
, u8 keyidx
, u8 txrx
,
546 u32
* iv32
, u16
* iv16
);
548 /* Configuration of RTS threshold (if device needs it) */
549 int (*set_rts_threshold
)(struct net_device
*dev
, u32 value
);
551 /* Configuration of fragmentation threshold (if device needs it) */
552 int (*set_frag_threshold
)(struct net_device
*dev
, u32 value
);
554 /* Configuration of retry limits (if device needs it) */
555 int (*set_retry_limit
)(struct net_device
*dev
, u32 short_retry
,
558 /* Number of STAs in STA table notification (NULL = disabled) */
559 void (*sta_table_notification
)(struct net_device
*dev
, int num_sta
);
561 /* Configure TX queue parameters (EDCF (aifs, cw_min, cw_max),
562 * bursting) for a hardware TX queue.
563 * queue = IEEE80211_TX_QUEUE_*. */
564 int (*conf_tx
)(struct net_device
*dev
, int queue
,
565 const struct ieee80211_tx_queue_params
*params
);
567 /* Get statistics of the current TX queue status. This is used to get
568 * number of currently queued packets (queue length), maximum queue
569 * size (limit), and total number of packets sent using each TX queue
570 * (count). This information is used for WMM to find out which TX
571 * queues have room for more packets and by hostapd to provide
572 * statistics about the current queueing state to external programs. */
573 int (*get_tx_stats
)(struct net_device
*dev
,
574 struct ieee80211_tx_queue_stats
*stats
);
576 /* Number of available hardware TX queues for data packets.
577 * WMM requires at least four queues. */
580 /* Get the current TSF timer value from firmware/hardware. Currently,
581 * this is only used for IBSS mode debugging and, as such, is not a
582 * required function. */
583 u64 (*get_tsf
)(struct net_device
*dev
);
585 /* Reset the TSF timer and allow firmware/hardware to synchronize with
586 * other STAs in the IBSS. This is only used in IBSS mode. This
587 * function is optional if the firmware/hardware takes full care of
588 * TSF synchronization. */
589 void (*reset_tsf
)(struct net_device
*dev
);
591 /* Setup beacon data for IBSS beacons. Unlike access point (Master),
592 * IBSS uses a fixed beacon frame which is configured using this
593 * function. This handler is required only for IBSS mode. */
594 int (*beacon_update
)(struct net_device
*dev
, struct sk_buff
*skb
,
595 struct ieee80211_tx_control
*control
);
597 /* Determine whether the last IBSS beacon was sent by us. This is
598 * needed only for IBSS mode and the result of this function is used to
599 * determine whether to reply to Probe Requests. */
600 int (*tx_last_beacon
)(struct net_device
*dev
);
602 /* Optional handler for XR-in-use notification. */
603 int (*atheros_xr_in_use
)(struct net_device
*dev
, int in_use
);
606 /* Allocate a new hardware device. This must be called once for each
607 * hardware device. The returned pointer must be used to refer to this
608 * device when calling other functions. 802.11 code allocates a private data
609 * area for the low-level driver. The size of this area is given as
610 * priv_data_len. ieee80211_dev_hw_data() is used to get a pointer to the
613 * Note: in this version of the interface the returned pointer is struct
614 * net_device *. This may change in the future and low-level driver should
615 * not refer the device data directly to remain compatible with the future
616 * versions of the interface. */
617 struct net_device
*ieee80211_alloc_hw(size_t priv_data_len
,
618 void (*setup
)(struct net_device
*));
620 /* Register hardware device to the IEEE 802.11 code and kernel. Low-level
621 * drivers must call this function before using any other IEEE 802.11
623 int ieee80211_register_hw(struct net_device
*dev
, struct ieee80211_hw
*hw
);
625 /* This function is allowed to update hardware configuration (e.g., list of
626 * supported operation modes and rates). */
627 int ieee80211_update_hw(struct net_device
*dev
, struct ieee80211_hw
*hw
);
629 /* Unregister a hardware device. This function instructs 802.11 code to free
630 * allocated resources and unregister netdevices from the kernel. */
631 void ieee80211_unregister_hw(struct net_device
*dev
);
633 /* Free allocated net_device including private data of a driver. */
634 void ieee80211_free_hw(struct net_device
*dev
);
636 /* Receive frame callback function. The low-level driver uses this function to
637 * send received frames to the IEEE 802.11 code. Receive buffer (skb) must
638 * start with IEEE 802.11 header. */
639 void ieee80211_rx(struct net_device
*dev
, struct sk_buff
*skb
,
640 struct ieee80211_rx_status
*status
);
641 void ieee80211_rx_irqsafe(struct net_device
*dev
, struct sk_buff
*skb
,
642 struct ieee80211_rx_status
*status
);
644 /* Transmit status callback function. The low-level driver must call this
645 * function to report transmit status for all the TX frames that had
646 * req_tx_status set in the transmit control fields. In addition, this should
647 * be called at least for all unicast frames to provide information for TX rate
648 * control algorithm. In order to maintain all statistics, this function is
649 * recommended to be called after each frame, including multicast/broadcast, is
651 void ieee80211_tx_status(struct net_device
*dev
, struct sk_buff
*skb
,
652 struct ieee80211_tx_status
*status
);
653 void ieee80211_tx_status_irqsafe(struct net_device
*dev
, struct sk_buff
*skb
,
654 struct ieee80211_tx_status
*status
);
656 /* Beacon generation function. If the beacon frames are generated by the host
657 * system (i.e., not in hardware/firmware), the low-level driver uses this
658 * function to receive the next beacon frame from the 802.11 code. The
659 * low-level is responsible for calling this function before beacon data is
660 * needed (e.g., based on hardware interrupt). Returned skb is used only once
661 * and low-level driver is responsible of freeing it. */
662 struct sk_buff
* ieee80211_beacon_get(struct net_device
*dev
, int bss_idx
,
663 struct ieee80211_tx_control
*control
);
665 /* Function for accessing buffered broadcast and multicast frames. If
666 * hardware/firmware does not implement buffering of broadcast/multicast
667 * frames when power saving is used, 802.11 code buffers them in the host
668 * memory. The low-level driver uses this function to fetch next buffered
669 * frame. In most cases, this is used when generating beacon frame. This
670 * function returns a pointer to the next buffered skb or NULL if no more
671 * buffered frames are available.
673 * Note: buffered frames are returned only after DTIM beacon frame was
674 * generated with ieee80211_beacon_get() and the low-level driver must thus
675 * call ieee80211_beacon_get() first. ieee80211_get_buffered_bc() returns
676 * NULL if the previous generated beacon was not DTIM, so the low-level driver
677 * does not need to check for DTIM beacons separately and should be able to
678 * use common code for all beacons. */
680 ieee80211_get_buffered_bc(struct net_device
*dev
, int bss_idx
,
681 struct ieee80211_tx_control
*control
);
683 /* Low level drivers that have their own MLME and MAC indicate
684 * the aid for an associating station with this call */
685 int ieee80211_set_aid_for_sta(struct net_device
*dev
, u8
*peer_address
,
689 /* Given an sk_buff with a raw 802.11 header at the data pointer this function
690 * returns the 802.11 header length in bytes (not including encryption
691 * headers). If the data in the sk_buff is too short to contain a valid 802.11
692 * header the function returns 0.
694 int ieee80211_get_hdrlen_from_skb(struct sk_buff
*skb
);
696 /* Like ieee80211_get_hdrlen_from_skb() but takes a FC in CPU order. */
697 int ieee80211_get_hdrlen(u16 fc
);
699 /* Function for net interface operation. IEEE 802.11 may use multiple kernel
700 * netdevices for each hardware device. The low-level driver does not "see"
701 * these interfaces, so it should use this function to perform netif
702 * operations on all interface. */
704 NETIF_ATTACH
, NETIF_DETACH
, NETIF_START
, NETIF_STOP
, NETIF_WAKE
,
705 NETIF_IS_STOPPED
, NETIF_UPDATE_TX_START
707 int ieee80211_netif_oper(struct net_device
*dev
, Netif_Oper op
);
711 * Function to get hardware configuration information
712 * by the low level driver should it need it.
714 struct ieee80211_conf
*
715 ieee80211_get_hw_conf(struct net_device
*dev
);
718 /* Return a pointer to the low-level private data area for the given device. */
719 void * ieee80211_dev_hw_data(struct net_device
*dev
);
720 /* Return a pointer to network statistics data area for the given device. */
721 void * ieee80211_dev_stats(struct net_device
*dev
);
723 /* Function to indicate Radar Detection. The low level driver must call this
724 * function to indicate the presence of radar in the current channel.
725 * Additionally the radar type also could be sent */
726 int ieee80211_radar_status(struct net_device
*dev
, int channel
, int radar
,
731 IEEE80211_TEST_DISABLE
= 0 /* terminate testing */,
732 IEEE80211_TEST_UNMASK_CHANNELS
= 1 /* allow all channels to be used */,
733 IEEE80211_TEST_CONTINUOUS_TX
= 2,
736 /* Test parameters */
738 /* TX power in hardware specific raw value */
739 IEEE80211_TEST_PARAM_TX_POWER_RAW
= 0,
740 /* TX rate in hardware specific raw value */
741 IEEE80211_TEST_PARAM_TX_RATE_RAW
= 1,
742 /* Continuous TX pattern (32-bit) */
743 IEEE80211_TEST_PARAM_TX_PATTERN
= 2,
744 /* TX power in 0.1 dBm, 100 = 10 dBm */
745 IEEE80211_TEST_PARAM_TX_POWER
= 3,
746 /* TX rate in 100 kbps, 540 = 54 Mbps */
747 IEEE80211_TEST_PARAM_TX_RATE
= 4,
748 IEEE80211_TEST_PARAM_TX_ANT_SEL_RAW
= 5,
751 /* ieee80211_tx_led called with state == 1 when the first frame is queued
752 * with state == 0 when the last frame is transmitted and tx queue is empty
754 void ieee80211_tx_led(int state
, struct net_device
*dev
);
755 /* ieee80211_rx_led is called each time frame is received, state is not used
758 void ieee80211_rx_led(int state
, struct net_device
*dev
);
761 /* IEEE 802.11 defines */
765 #define WLAN_FC_PVER 0x0003
766 #define WLAN_FC_TODS 0x0100
767 #define WLAN_FC_FROMDS 0x0200
768 #define WLAN_FC_MOREFRAG 0x0400
769 #define WLAN_FC_RETRY 0x0800
770 #define WLAN_FC_PWRMGT 0x1000
771 #define WLAN_FC_MOREDATA 0x2000
772 #define WLAN_FC_ISWEP 0x4000
773 #define WLAN_FC_ORDER 0x8000
775 #define WLAN_FC_GET_TYPE(fc) (((fc) & 0x000c) >> 2)
776 #define WLAN_FC_GET_STYPE(fc) (((fc) & 0x00f0) >> 4)
778 #define WLAN_GET_SEQ_FRAG(seq) ((seq) & 0x000f)
779 #define WLAN_GET_SEQ_SEQ(seq) ((seq) >> 4)
781 #define WLAN_FC_DATA_PRESENT(fc) (((fc) & 0x4c) == 0x08)
783 #define WLAN_FC_TYPE_MGMT 0
784 #define WLAN_FC_TYPE_CTRL 1
785 #define WLAN_FC_TYPE_DATA 2
788 #define WLAN_FC_STYPE_ASSOC_REQ 0
789 #define WLAN_FC_STYPE_ASSOC_RESP 1
790 #define WLAN_FC_STYPE_REASSOC_REQ 2
791 #define WLAN_FC_STYPE_REASSOC_RESP 3
792 #define WLAN_FC_STYPE_PROBE_REQ 4
793 #define WLAN_FC_STYPE_PROBE_RESP 5
794 #define WLAN_FC_STYPE_BEACON 8
795 #define WLAN_FC_STYPE_ATIM 9
796 #define WLAN_FC_STYPE_DISASSOC 10
797 #define WLAN_FC_STYPE_AUTH 11
798 #define WLAN_FC_STYPE_DEAUTH 12
799 #define WLAN_FC_STYPE_ACTION 13
802 #define WLAN_FC_STYPE_PSPOLL 10
803 #define WLAN_FC_STYPE_RTS 11
804 #define WLAN_FC_STYPE_CTS 12
805 #define WLAN_FC_STYPE_ACK 13
806 #define WLAN_FC_STYPE_CFEND 14
807 #define WLAN_FC_STYPE_CFENDACK 15
810 #define WLAN_FC_STYPE_DATA 0
811 #define WLAN_FC_STYPE_DATA_CFACK 1
812 #define WLAN_FC_STYPE_DATA_CFPOLL 2
813 #define WLAN_FC_STYPE_DATA_CFACKPOLL 3
814 #define WLAN_FC_STYPE_NULLFUNC 4
815 #define WLAN_FC_STYPE_CFACK 5
816 #define WLAN_FC_STYPE_CFPOLL 6
817 #define WLAN_FC_STYPE_CFACKPOLL 7
818 #define WLAN_FC_STYPE_QOS_DATA 8
819 #define WLAN_FC_STYPE_QOS_DATA_CFACK 9
820 #define WLAN_FC_STYPE_QOS_DATA_CFPOLL 10
821 #define WLAN_FC_STYPE_QOS_DATA_CFACKPOLL 11
822 #define WLAN_FC_STYPE_QOS_NULLFUNC 12
823 #define WLAN_FC_STYPE_QOS_CFACK 13
824 #define WLAN_FC_STYPE_QOS_CFPOLL 14
825 #define WLAN_FC_STYPE_QOS_CFACKPOLL 15
828 #define IEEE80211_MAX_FRAG_THRESHOLD 2346
829 #define IEEE80211_MAX_RTS_THRESHOLD 2347
831 struct ieee80211_hdr
{
839 } __attribute__ ((packed
));
841 /* return a pointer to the source address (SA) */
842 static inline u8
*ieee80211_get_SA(struct ieee80211_hdr
*hdr
)
844 u8
*raw
= (u8
*) hdr
;
845 u8 tofrom
= (*(raw
+1)) & 3; /* get the TODS and FROMDS bits */
856 /* return a pointer to the destination address (DA) */
857 static inline u8
*ieee80211_get_DA(struct ieee80211_hdr
*hdr
)
859 u8
*raw
= (u8
*) hdr
;
860 u8 to_ds
= (*(raw
+1)) & 1; /* get the TODS bit */
867 static inline int ieee80211_get_morefrag(struct ieee80211_hdr
*hdr
)
869 return (le16_to_cpu(hdr
->frame_control
) & WLAN_FC_MOREFRAG
) != 0;
872 #endif /* IEEE80211_H */