add devicescape 802.11 stack
[openwrt.git] / target / linux / package / ieee80211-dscape / src / include / net / ieee80211.h
1 /*
2  * Low-level hardware driver -- IEEE 802.11 driver (80211.o) interface
3  * Copyright 2002-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_H
11 #define IEEE80211_H
12
13 #include "ieee80211_shared.h"
14
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).
21  */
22
23 /*
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
27  * are sent over air.
28  *
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
31  * support this.
32  *
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.
38  */
39
40 /* Interface version (used for compatibility verification) */
41 #define IEEE80211_VERSION 2
42
43
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;
56 };
57
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;
67
68         /* following fields are set by 80211.o and need not be filled by the
69          * low-level driver */
70         int rate_inv; /* inverse of the rate (LCM(all rates) / rate) for
71                        * optimizing channel utilization estimates */
72 };
73
74 struct ieee80211_hw_modes {
75         int mode;
76         int num_channels;
77         struct ieee80211_channel *channels;
78         int num_rates;
79         struct ieee80211_rate *rates;
80         int xr_end; /* only used with Atheros XR */
81 };
82
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);
88                          * 0 = disabled */
89 };
90
91 #define NUM_TX_DATA_QUEUES 6
92
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 */
97 };
98
99 struct ieee80211_tx_queue_stats {
100         struct ieee80211_tx_queue_stats_data data[NUM_TX_DATA_QUEUES];
101 };
102
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
107  * hostapd */
108 enum {
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
117 };
118 #endif /* IEEE80211_TX_QUEUE_NUMS */
119
120
121 struct ieee80211_low_level_stats {
122         unsigned int dot11ACKFailureCount;
123         unsigned int dot11RTSFailureCount;
124         unsigned int dot11FCSErrorCount;
125         unsigned int dot11RTSSuccessCount;
126 };
127
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
132
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
148                                        * frame */
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
162                                             * transmission */
163         unsigned int fast_frame:1;
164
165         unsigned int atheros_xr:1; /* only used with Atheros XR */
166
167         unsigned int power_level:8; /* per-packet transmit power level, in dBm
168                                      */
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()
172                         */
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) */
179
180 #if 0
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 */
187 #endif
188 };
189
190 #define IEEE80211_CB_MAGIC 0xAAB80211
191
192 struct ieee80211_tx_packet_data {
193         unsigned int magic;
194         struct ieee80211_tx_control control;
195         unsigned long jiffies;
196         struct ieee80211_sub_if_data *sdata;
197 };
198
199 #define RX_FLAG_MMIC_ERROR       0x1
200 #define RX_FLAG_DECRYPTED        0x2
201 #define RX_FLAG_XR_DOUBLE_CHIRP  0x4
202
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
205  * frame.
206  * Current implementation copies this into skb->cb, so it must be less than
207  * 48 bytes. */
208 struct ieee80211_rx_status {
209 #if 0
210         u64 hosttime;
211         u64 mactime;
212 #endif
213         int freq; /* receive frequency in Mhz */
214         int channel;
215         int phymode;
216         int ssi;
217         int antenna;
218         int rate;
219         int flag;
220 };
221
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
224  * frame. */
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
228                                        * requested */
229         unsigned int rate_ctrl_probe:1; /* whether this was a probe packet from
230                                          * rate control */
231         unsigned int tx_filtered:1;
232
233         /* following three fields are only used with Atheros Super A/G */
234         unsigned int turbo_prime_notify:1; /* notify HostAPd - CTS for Turbo
235                                             * Prime is sent */
236         int queue_length;      /* information about TX queue */
237         int queue_number;
238
239         int ack; /* whether the TX frame was ACKed */
240         int ack_signal; /* measured signal strength of the ACK frame */
241         int excessive_retries;
242         int retry_count;
243         int rateidx; /* internal 80211.o rateidx, to be copied to tx_status */
244 };
245
246
247 struct ieee80211_conf {
248         int channel;                    /* IEEE 802.11 channel number */
249         int freq;                       /* MHz */
250         int channel_val;                /* hw specific value for the channel */
251
252         int mode;                       /* IW_MODE_ */
253
254         int phymode;                    /* MODE_IEEE80211A, .. */
255         unsigned int regulatory_domain;
256         int adm_status;
257
258         int beacon_int;
259
260         /* Bitfields, grouped together */
261
262         int sw_encrypt:1;
263         int sw_decrypt:1;
264         int short_slot_time:1;          /* use IEEE 802.11g Short Slot Time */
265         int ssid_hidden:1;              /* do not broadcast the ssid */
266
267         /* these fields are used by low level drivers for hardware
268          * that generate beacons independently */
269         u8 *ssid;
270         size_t ssid_len;
271         u8 *generic_elem;
272         size_t generic_elem_len;
273
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 */
278
279         int antenna_sel;                /* default antenna conf:
280                                          *      0 = default/diversity,
281                                          *      1 = Ant0,
282                                          *      2 = Ant1 */
283
284         int calib_int;                  /* hw/radio calibration interval in
285                                          * seconds */
286         int antenna_def;
287         int antenna_mode;
288
289         u8 bssid_mask[ETH_ALEN];        /* ff:ff:ff:ff:ff:ff = 1 BSSID */
290         int bss_count;
291
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;
298
299         int atheros_xr;
300
301         u8 client_bssid[ETH_ALEN];
302
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
308                                     * period */
309         unsigned int quiet_period;
310 };
311
312
313 typedef enum { ALG_NONE, ALG_WEP, ALG_TKIP, ALG_CCMP, ALG_NULL }
314 ieee80211_key_alg;
315
316
317 struct ieee80211_key_conf {
318
319         int hw_key_idx;                 /* filled + used by low-level driver */
320         ieee80211_key_alg alg;
321         int keylen;
322
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 */
330         u8 key[0];
331 };
332
333 #define IEEE80211_SCAN_START 1
334 #define IEEE80211_SCAN_END   2
335
336 struct ieee80211_scan_conf {
337         int scan_channel;     /* IEEE 802.11 channel number to do passive scan
338                                * on */
339         int scan_freq;        /* new freq in MHz to switch to for passive scan
340                                */
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;
345
346
347         int running_channel; /* IEEE 802.11 channel number we operate on
348                               * normally */
349         int running_freq;    /* freq in MHz we're operating on normally */
350         int running_channel_val; /* hw specific value for the channel */
351         int running_phymode;
352         unsigned char running_power_level;
353         unsigned char running_antenna_max;
354
355         int scan_time;       /* time a scan will take in us */
356         int tries;
357
358         struct sk_buff *skb; /* skb to transmit before changing channels, maybe
359                               * NULL for none */
360         struct ieee80211_tx_control *tx_control;
361
362 };
363
364 #ifndef IW_MODE_ADHOC
365 #define IW_MODE_ADHOC 1
366 #endif
367
368 #ifndef IW_MODE_INFRA
369 #define IW_MODE_INFRA 2
370 #endif
371
372 #ifndef IW_MODE_MASTER
373 #define IW_MODE_MASTER 3
374 #endif
375
376 #ifndef IW_MODE_MONITOR
377 #define IW_MODE_MONITOR 6
378 #endif
379
380 #define IEEE80211_SEQ_COUNTER_RX        0
381 #define IEEE80211_SEQ_COUNTER_TX        1
382
383 typedef enum {
384         SET_KEY, DISABLE_KEY, REMOVE_ALL_KEYS,
385         ENABLE_COMPRESSION, DISABLE_COMPRESSION
386 } set_key_cmd;
387
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
390  * functions. */
391 struct ieee80211_hw {
392         int version; /* IEEE80211_VERSION */
393
394         /* Driver name */
395         char *name;
396
397         /* TODO: frame_type 802.11/802.3, sw_encryption requirements */
398
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
403          * beacon frame. */
404         int host_gen_beacon:1;
405
406
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
410          * through) */
411         int device_hides_wep:1;
412
413         /* Whether RX frames passed to ieee80211_rx() include FCS in the end
414          */
415         int rx_includes_fcs:1;
416
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;
424
425         int wep_include_iv:1;
426         int data_nullfunc_ack:1; /* will data nullfunc frames get proper
427                                   * TX status callback */
428
429         /* Force sw version of encryption for TKIP packets if WMM is enabled.
430          */
431         int no_tkip_wmm_hwaccel:1;
432
433         /* 1 if the payload needs to be padded at even boundaries after the
434          * header */
435         unsigned int extra_hdr_room:1;
436
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.
441          */
442         unsigned int device_strips_mic:1;
443
444         /* 1 = low-level driver supports skb fraglist (NETIF_F_FRAGLIST), i.e.,
445          * more than one skb per frame */
446         unsigned int fraglist;
447
448         /* This is the time in us to change channels
449          */
450         int channel_change_time;
451
452         int num_modes;
453         struct ieee80211_hw_modes *modes;
454
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);
461
462         /* Handler for performing hardware reset. */
463         int (*reset)(struct net_device *dev);
464
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);
469
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);
474
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);
478
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);
485
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);
494
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
499          * TX frame. */
500         int (*set_key_idx)(struct net_device *dev, int idx);
501
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);
507
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);
515
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);
521
522         /* return low-level statistics */
523         int (*get_stats)(struct net_device *dev,
524                          struct ieee80211_low_level_stats *stats);
525
526         /* Enable/disable test modes; mode = IEEE80211_TEST_* */
527         int (*test_mode)(struct net_device *dev, int mode);
528
529         /* Configuration of test parameters */
530         int (*test_param)(struct net_device *dev, int param, int value);
531
532         /* Change MAC address. addr is pointer to struct sockaddr. */
533         int (*set_mac_address)(struct net_device *dev, void *addr);
534
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 */
538
539         int (*set_privacy_invoked)(struct net_device *dev,
540                                    int privacy_invoked);
541
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);
547
548         /* Configuration of RTS threshold (if device needs it) */
549         int (*set_rts_threshold)(struct net_device *dev, u32 value);
550
551         /* Configuration of fragmentation threshold (if device needs it) */
552         int (*set_frag_threshold)(struct net_device *dev, u32 value);
553
554         /* Configuration of retry limits (if device needs it) */
555         int (*set_retry_limit)(struct net_device *dev, u32 short_retry,
556                                u32 long_retr);
557
558         /* Number of STAs in STA table notification (NULL = disabled) */
559         void (*sta_table_notification)(struct net_device *dev, int num_sta);
560
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);
566
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);
575
576         /* Number of available hardware TX queues for data packets.
577          * WMM requires at least four queues. */
578         int queues;
579
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);
584
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);
590
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);
596
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);
601
602         /* Optional handler for XR-in-use notification. */
603         int (*atheros_xr_in_use)(struct net_device *dev, int in_use);
604 };
605
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
611  * private data area.
612  *
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 *));
619
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
622  * function. */
623 int ieee80211_register_hw(struct net_device *dev, struct ieee80211_hw *hw);
624
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);
628
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);
632
633 /* Free allocated net_device including private data of a driver. */
634 void ieee80211_free_hw(struct net_device *dev);
635
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);
643
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
650  * sent. */
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);
655
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);
664
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.
672  *
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. */
679 struct sk_buff *
680 ieee80211_get_buffered_bc(struct net_device *dev, int bss_idx,
681                           struct ieee80211_tx_control *control);
682
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,
686                               u16 aid);
687
688
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.
693  */
694 int ieee80211_get_hdrlen_from_skb(struct sk_buff *skb);
695
696 /* Like ieee80211_get_hdrlen_from_skb() but takes a FC in CPU order. */
697 int ieee80211_get_hdrlen(u16 fc);
698
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. */
703 typedef enum {
704         NETIF_ATTACH, NETIF_DETACH, NETIF_START, NETIF_STOP, NETIF_WAKE,
705         NETIF_IS_STOPPED, NETIF_UPDATE_TX_START
706 } Netif_Oper;
707 int ieee80211_netif_oper(struct net_device *dev, Netif_Oper op);
708
709
710 /*
711  * Function to get hardware configuration information
712  * by the low level driver should it need it.
713  */
714 struct ieee80211_conf *
715 ieee80211_get_hw_conf(struct net_device *dev);
716
717
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);
722
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,
727                             int radar_type);
728
729 /* Test modes */
730 enum {
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,
734 };
735
736 /* Test parameters */
737 enum {
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,
749 };
750
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
753  */
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
756  * (== 2)
757  */
758 void ieee80211_rx_led(int state, struct net_device *dev);
759
760
761 /* IEEE 802.11 defines */
762
763 #define FCS_LEN 4
764
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
774
775 #define WLAN_FC_GET_TYPE(fc)    (((fc) & 0x000c) >> 2)
776 #define WLAN_FC_GET_STYPE(fc)   (((fc) & 0x00f0) >> 4)
777
778 #define WLAN_GET_SEQ_FRAG(seq)  ((seq) & 0x000f)
779 #define WLAN_GET_SEQ_SEQ(seq)   ((seq) >> 4)
780
781 #define WLAN_FC_DATA_PRESENT(fc) (((fc) & 0x4c) == 0x08)
782
783 #define WLAN_FC_TYPE_MGMT       0
784 #define WLAN_FC_TYPE_CTRL       1
785 #define WLAN_FC_TYPE_DATA       2
786
787 /* management */
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
800
801 /* control */
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
808
809 /* data */
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
826
827
828 #define IEEE80211_MAX_FRAG_THRESHOLD 2346
829 #define IEEE80211_MAX_RTS_THRESHOLD 2347
830
831 struct ieee80211_hdr {
832         u16 frame_control;
833         u16 duration_id;
834         u8 addr1[6];
835         u8 addr2[6];
836         u8 addr3[6];
837         u16 seq_ctrl;
838         u8 addr4[6];
839 } __attribute__ ((packed));
840
841 /* return a pointer to the source address (SA) */
842 static inline u8 *ieee80211_get_SA(struct ieee80211_hdr *hdr)
843 {
844         u8 *raw = (u8 *) hdr;
845         u8 tofrom = (*(raw+1)) & 3; /* get the TODS and FROMDS bits */
846
847         switch (tofrom) {
848                 case 2:
849                         return hdr->addr3;
850                 case 3:
851                         return hdr->addr4;
852         }
853         return hdr->addr2;
854 }
855
856 /* return a pointer to the destination address (DA) */
857 static inline u8 *ieee80211_get_DA(struct ieee80211_hdr *hdr)
858 {
859         u8 *raw = (u8 *) hdr;
860         u8 to_ds = (*(raw+1)) & 1; /* get the TODS bit */
861
862         if (to_ds)
863                 return hdr->addr3;
864         return hdr->addr1;
865 }
866
867 static inline int ieee80211_get_morefrag(struct ieee80211_hdr *hdr)
868 {
869         return (le16_to_cpu(hdr->frame_control) & WLAN_FC_MOREFRAG) != 0;
870 }
871
872 #endif /* IEEE80211_H */