GUI: Fix Tomato RAF theme for all builds. Compilation typo.
[tomato.git] / release / src-rt-6.x.4708 / linux / linux-2.6.36 / drivers / net / wireless / ipw2x00 / libipw.h
blob3ecb276a34d9d45466843d50c7a0b4a937dd746d
1 /*
2 * Merged with mainline ieee80211.h in Aug 2004. Original ieee802_11
3 * remains copyright by the original authors
5 * Portions of the merged code are based on Host AP (software wireless
6 * LAN access point) driver for Intersil Prism2/2.5/3.
8 * Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen
9 * <j@w1.fi>
10 * Copyright (c) 2002-2003, Jouni Malinen <j@w1.fi>
12 * Adaption to a generic IEEE 802.11 stack by James Ketrenos
13 * <jketreno@linux.intel.com>
14 * Copyright (c) 2004-2005, Intel Corporation
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License version 2 as
18 * published by the Free Software Foundation. See README and COPYING for
19 * more details.
21 * API Version History
22 * 1.0.x -- Initial version
23 * 1.1.x -- Added radiotap, QoS, TIM, libipw_geo APIs,
24 * various structure changes, and crypto API init method
26 #ifndef LIBIPW_H
27 #define LIBIPW_H
28 #include <linux/if_ether.h> /* ETH_ALEN */
29 #include <linux/kernel.h> /* ARRAY_SIZE */
30 #include <linux/wireless.h>
31 #include <linux/ieee80211.h>
33 #include <net/lib80211.h>
34 #include <net/cfg80211.h>
36 #define LIBIPW_VERSION "git-1.1.13"
38 #define LIBIPW_DATA_LEN 2304
39 /* Maximum size for the MA-UNITDATA primitive, 802.11 standard section
40 6.2.1.1.2.
42 The figure in section 7.1.2 suggests a body size of up to 2312
43 bytes is allowed, which is a bit confusing, I suspect this
44 represents the 2304 bytes of real data, plus a possible 8 bytes of
45 WEP IV and ICV. (this interpretation suggested by Ramiro Barreiro) */
47 #define LIBIPW_1ADDR_LEN 10
48 #define LIBIPW_2ADDR_LEN 16
49 #define LIBIPW_3ADDR_LEN 24
50 #define LIBIPW_4ADDR_LEN 30
51 #define LIBIPW_FCS_LEN 4
52 #define LIBIPW_HLEN (LIBIPW_4ADDR_LEN)
53 #define LIBIPW_FRAME_LEN (LIBIPW_DATA_LEN + LIBIPW_HLEN)
55 #define MIN_FRAG_THRESHOLD 256U
56 #define MAX_FRAG_THRESHOLD 2346U
58 /* QOS control */
59 #define LIBIPW_QCTL_TID 0x000F
61 /* debug macros */
63 #ifdef CONFIG_LIBIPW_DEBUG
64 extern u32 libipw_debug_level;
65 #define LIBIPW_DEBUG(level, fmt, args...) \
66 do { if (libipw_debug_level & (level)) \
67 printk(KERN_DEBUG "libipw: %c %s " fmt, \
68 in_interrupt() ? 'I' : 'U', __func__ , ## args); } while (0)
69 static inline bool libipw_ratelimit_debug(u32 level)
71 return (libipw_debug_level & level) && net_ratelimit();
73 #else
74 #define LIBIPW_DEBUG(level, fmt, args...) do {} while (0)
75 static inline bool libipw_ratelimit_debug(u32 level)
77 return false;
79 #endif /* CONFIG_LIBIPW_DEBUG */
82 #define LIBIPW_DL_INFO (1<<0)
83 #define LIBIPW_DL_WX (1<<1)
84 #define LIBIPW_DL_SCAN (1<<2)
85 #define LIBIPW_DL_STATE (1<<3)
86 #define LIBIPW_DL_MGMT (1<<4)
87 #define LIBIPW_DL_FRAG (1<<5)
88 #define LIBIPW_DL_DROP (1<<7)
90 #define LIBIPW_DL_TX (1<<8)
91 #define LIBIPW_DL_RX (1<<9)
92 #define LIBIPW_DL_QOS (1<<31)
94 #define LIBIPW_ERROR(f, a...) printk(KERN_ERR "libipw: " f, ## a)
95 #define LIBIPW_WARNING(f, a...) printk(KERN_WARNING "libipw: " f, ## a)
96 #define LIBIPW_DEBUG_INFO(f, a...) LIBIPW_DEBUG(LIBIPW_DL_INFO, f, ## a)
98 #define LIBIPW_DEBUG_WX(f, a...) LIBIPW_DEBUG(LIBIPW_DL_WX, f, ## a)
99 #define LIBIPW_DEBUG_SCAN(f, a...) LIBIPW_DEBUG(LIBIPW_DL_SCAN, f, ## a)
100 #define LIBIPW_DEBUG_STATE(f, a...) LIBIPW_DEBUG(LIBIPW_DL_STATE, f, ## a)
101 #define LIBIPW_DEBUG_MGMT(f, a...) LIBIPW_DEBUG(LIBIPW_DL_MGMT, f, ## a)
102 #define LIBIPW_DEBUG_FRAG(f, a...) LIBIPW_DEBUG(LIBIPW_DL_FRAG, f, ## a)
103 #define LIBIPW_DEBUG_DROP(f, a...) LIBIPW_DEBUG(LIBIPW_DL_DROP, f, ## a)
104 #define LIBIPW_DEBUG_TX(f, a...) LIBIPW_DEBUG(LIBIPW_DL_TX, f, ## a)
105 #define LIBIPW_DEBUG_RX(f, a...) LIBIPW_DEBUG(LIBIPW_DL_RX, f, ## a)
106 #define LIBIPW_DEBUG_QOS(f, a...) LIBIPW_DEBUG(LIBIPW_DL_QOS, f, ## a)
107 #include <linux/netdevice.h>
108 #include <linux/if_arp.h> /* ARPHRD_ETHER */
110 #ifndef WIRELESS_SPY
111 #define WIRELESS_SPY /* enable iwspy support */
112 #endif
113 #include <net/iw_handler.h> /* new driver API */
115 #define ETH_P_PREAUTH 0x88C7 /* IEEE 802.11i pre-authentication */
117 #ifndef ETH_P_80211_RAW
118 #define ETH_P_80211_RAW (ETH_P_ECONET + 1)
119 #endif
121 /* IEEE 802.11 defines */
123 #define P80211_OUI_LEN 3
125 struct libipw_snap_hdr {
127 u8 dsap; /* always 0xAA */
128 u8 ssap; /* always 0xAA */
129 u8 ctrl; /* always 0x03 */
130 u8 oui[P80211_OUI_LEN]; /* organizational universal id */
132 } __packed;
134 #define SNAP_SIZE sizeof(struct libipw_snap_hdr)
136 #define WLAN_FC_GET_VERS(fc) ((fc) & IEEE80211_FCTL_VERS)
137 #define WLAN_FC_GET_TYPE(fc) ((fc) & IEEE80211_FCTL_FTYPE)
138 #define WLAN_FC_GET_STYPE(fc) ((fc) & IEEE80211_FCTL_STYPE)
140 #define WLAN_GET_SEQ_FRAG(seq) ((seq) & IEEE80211_SCTL_FRAG)
141 #define WLAN_GET_SEQ_SEQ(seq) (((seq) & IEEE80211_SCTL_SEQ) >> 4)
143 #define LIBIPW_STATMASK_SIGNAL (1<<0)
144 #define LIBIPW_STATMASK_RSSI (1<<1)
145 #define LIBIPW_STATMASK_NOISE (1<<2)
146 #define LIBIPW_STATMASK_RATE (1<<3)
147 #define LIBIPW_STATMASK_WEMASK 0x7
149 #define LIBIPW_CCK_MODULATION (1<<0)
150 #define LIBIPW_OFDM_MODULATION (1<<1)
152 #define LIBIPW_24GHZ_BAND (1<<0)
153 #define LIBIPW_52GHZ_BAND (1<<1)
155 #define LIBIPW_CCK_RATE_1MB 0x02
156 #define LIBIPW_CCK_RATE_2MB 0x04
157 #define LIBIPW_CCK_RATE_5MB 0x0B
158 #define LIBIPW_CCK_RATE_11MB 0x16
159 #define LIBIPW_OFDM_RATE_6MB 0x0C
160 #define LIBIPW_OFDM_RATE_9MB 0x12
161 #define LIBIPW_OFDM_RATE_12MB 0x18
162 #define LIBIPW_OFDM_RATE_18MB 0x24
163 #define LIBIPW_OFDM_RATE_24MB 0x30
164 #define LIBIPW_OFDM_RATE_36MB 0x48
165 #define LIBIPW_OFDM_RATE_48MB 0x60
166 #define LIBIPW_OFDM_RATE_54MB 0x6C
167 #define LIBIPW_BASIC_RATE_MASK 0x80
169 #define LIBIPW_CCK_RATE_1MB_MASK (1<<0)
170 #define LIBIPW_CCK_RATE_2MB_MASK (1<<1)
171 #define LIBIPW_CCK_RATE_5MB_MASK (1<<2)
172 #define LIBIPW_CCK_RATE_11MB_MASK (1<<3)
173 #define LIBIPW_OFDM_RATE_6MB_MASK (1<<4)
174 #define LIBIPW_OFDM_RATE_9MB_MASK (1<<5)
175 #define LIBIPW_OFDM_RATE_12MB_MASK (1<<6)
176 #define LIBIPW_OFDM_RATE_18MB_MASK (1<<7)
177 #define LIBIPW_OFDM_RATE_24MB_MASK (1<<8)
178 #define LIBIPW_OFDM_RATE_36MB_MASK (1<<9)
179 #define LIBIPW_OFDM_RATE_48MB_MASK (1<<10)
180 #define LIBIPW_OFDM_RATE_54MB_MASK (1<<11)
182 #define LIBIPW_CCK_RATES_MASK 0x0000000F
183 #define LIBIPW_CCK_BASIC_RATES_MASK (LIBIPW_CCK_RATE_1MB_MASK | \
184 LIBIPW_CCK_RATE_2MB_MASK)
185 #define LIBIPW_CCK_DEFAULT_RATES_MASK (LIBIPW_CCK_BASIC_RATES_MASK | \
186 LIBIPW_CCK_RATE_5MB_MASK | \
187 LIBIPW_CCK_RATE_11MB_MASK)
189 #define LIBIPW_OFDM_RATES_MASK 0x00000FF0
190 #define LIBIPW_OFDM_BASIC_RATES_MASK (LIBIPW_OFDM_RATE_6MB_MASK | \
191 LIBIPW_OFDM_RATE_12MB_MASK | \
192 LIBIPW_OFDM_RATE_24MB_MASK)
193 #define LIBIPW_OFDM_DEFAULT_RATES_MASK (LIBIPW_OFDM_BASIC_RATES_MASK | \
194 LIBIPW_OFDM_RATE_9MB_MASK | \
195 LIBIPW_OFDM_RATE_18MB_MASK | \
196 LIBIPW_OFDM_RATE_36MB_MASK | \
197 LIBIPW_OFDM_RATE_48MB_MASK | \
198 LIBIPW_OFDM_RATE_54MB_MASK)
199 #define LIBIPW_DEFAULT_RATES_MASK (LIBIPW_OFDM_DEFAULT_RATES_MASK | \
200 LIBIPW_CCK_DEFAULT_RATES_MASK)
202 #define LIBIPW_NUM_OFDM_RATES 8
203 #define LIBIPW_NUM_CCK_RATES 4
204 #define LIBIPW_OFDM_SHIFT_MASK_A 4
206 /* NOTE: This data is for statistical purposes; not all hardware provides this
207 * information for frames received.
208 * For libipw_rx_mgt, you need to set at least the 'len' parameter.
210 struct libipw_rx_stats {
211 u32 mac_time;
212 s8 rssi;
213 u8 signal;
214 u8 noise;
215 u16 rate; /* in 100 kbps */
216 u8 received_channel;
217 u8 control;
218 u8 mask;
219 u8 freq;
220 u16 len;
221 u64 tsf;
222 u32 beacon_time;
225 /* IEEE 802.11 requires that STA supports concurrent reception of at least
226 * three fragmented frames. This define can be increased to support more
227 * concurrent frames, but it should be noted that each entry can consume about
228 * 2 kB of RAM and increasing cache size will slow down frame reassembly. */
229 #define LIBIPW_FRAG_CACHE_LEN 4
231 struct libipw_frag_entry {
232 unsigned long first_frag_time;
233 unsigned int seq;
234 unsigned int last_frag;
235 struct sk_buff *skb;
236 u8 src_addr[ETH_ALEN];
237 u8 dst_addr[ETH_ALEN];
240 struct libipw_stats {
241 unsigned int tx_unicast_frames;
242 unsigned int tx_multicast_frames;
243 unsigned int tx_fragments;
244 unsigned int tx_unicast_octets;
245 unsigned int tx_multicast_octets;
246 unsigned int tx_deferred_transmissions;
247 unsigned int tx_single_retry_frames;
248 unsigned int tx_multiple_retry_frames;
249 unsigned int tx_retry_limit_exceeded;
250 unsigned int tx_discards;
251 unsigned int rx_unicast_frames;
252 unsigned int rx_multicast_frames;
253 unsigned int rx_fragments;
254 unsigned int rx_unicast_octets;
255 unsigned int rx_multicast_octets;
256 unsigned int rx_fcs_errors;
257 unsigned int rx_discards_no_buffer;
258 unsigned int tx_discards_wrong_sa;
259 unsigned int rx_discards_undecryptable;
260 unsigned int rx_message_in_msg_fragments;
261 unsigned int rx_message_in_bad_msg_fragments;
264 struct libipw_device;
266 #define SEC_KEY_1 (1<<0)
267 #define SEC_KEY_2 (1<<1)
268 #define SEC_KEY_3 (1<<2)
269 #define SEC_KEY_4 (1<<3)
270 #define SEC_ACTIVE_KEY (1<<4)
271 #define SEC_AUTH_MODE (1<<5)
272 #define SEC_UNICAST_GROUP (1<<6)
273 #define SEC_LEVEL (1<<7)
274 #define SEC_ENABLED (1<<8)
275 #define SEC_ENCRYPT (1<<9)
277 #define SEC_LEVEL_0 0 /* None */
278 #define SEC_LEVEL_1 1 /* WEP 40 and 104 bit */
279 #define SEC_LEVEL_2 2 /* Level 1 + TKIP */
280 #define SEC_LEVEL_2_CKIP 3 /* Level 1 + CKIP */
281 #define SEC_LEVEL_3 4 /* Level 2 + CCMP */
283 #define SEC_ALG_NONE 0
284 #define SEC_ALG_WEP 1
285 #define SEC_ALG_TKIP 2
286 #define SEC_ALG_CCMP 3
288 #define WEP_KEYS 4
289 #define WEP_KEY_LEN 13
290 #define SCM_KEY_LEN 32
291 #define SCM_TEMPORAL_KEY_LENGTH 16
293 struct libipw_security {
294 u16 active_key:2, enabled:1, unicast_uses_group:1, encrypt:1;
295 u8 auth_mode;
296 u8 encode_alg[WEP_KEYS];
297 u8 key_sizes[WEP_KEYS];
298 u8 keys[WEP_KEYS][SCM_KEY_LEN];
299 u8 level;
300 u16 flags;
301 } __packed;
305 802.11 data frame from AP
307 ,-------------------------------------------------------------------.
308 Bytes | 2 | 2 | 6 | 6 | 6 | 2 | 0..2312 | 4 |
309 |------|------|---------|---------|---------|------|---------|------|
310 Desc. | ctrl | dura | DA/RA | TA | SA | Sequ | frame | fcs |
311 | | tion | (BSSID) | | | ence | data | |
312 `-------------------------------------------------------------------'
314 Total: 28-2340 bytes
318 #define BEACON_PROBE_SSID_ID_POSITION 12
320 struct libipw_hdr_1addr {
321 __le16 frame_ctl;
322 __le16 duration_id;
323 u8 addr1[ETH_ALEN];
324 u8 payload[0];
325 } __packed;
327 struct libipw_hdr_2addr {
328 __le16 frame_ctl;
329 __le16 duration_id;
330 u8 addr1[ETH_ALEN];
331 u8 addr2[ETH_ALEN];
332 u8 payload[0];
333 } __packed;
335 struct libipw_hdr_3addr {
336 __le16 frame_ctl;
337 __le16 duration_id;
338 u8 addr1[ETH_ALEN];
339 u8 addr2[ETH_ALEN];
340 u8 addr3[ETH_ALEN];
341 __le16 seq_ctl;
342 u8 payload[0];
343 } __packed;
345 struct libipw_hdr_4addr {
346 __le16 frame_ctl;
347 __le16 duration_id;
348 u8 addr1[ETH_ALEN];
349 u8 addr2[ETH_ALEN];
350 u8 addr3[ETH_ALEN];
351 __le16 seq_ctl;
352 u8 addr4[ETH_ALEN];
353 u8 payload[0];
354 } __packed;
356 struct libipw_hdr_3addrqos {
357 __le16 frame_ctl;
358 __le16 duration_id;
359 u8 addr1[ETH_ALEN];
360 u8 addr2[ETH_ALEN];
361 u8 addr3[ETH_ALEN];
362 __le16 seq_ctl;
363 u8 payload[0];
364 __le16 qos_ctl;
365 } __packed;
367 struct libipw_info_element {
368 u8 id;
369 u8 len;
370 u8 data[0];
371 } __packed;
374 * These are the data types that can make up management packets
376 u16 auth_algorithm;
377 u16 auth_sequence;
378 u16 beacon_interval;
379 u16 capability;
380 u8 current_ap[ETH_ALEN];
381 u16 listen_interval;
382 struct {
383 u16 association_id:14, reserved:2;
384 } __packed;
385 u32 time_stamp[2];
386 u16 reason;
387 u16 status;
390 struct libipw_auth {
391 struct libipw_hdr_3addr header;
392 __le16 algorithm;
393 __le16 transaction;
394 __le16 status;
395 /* challenge */
396 struct libipw_info_element info_element[0];
397 } __packed;
399 struct libipw_channel_switch {
400 u8 id;
401 u8 len;
402 u8 mode;
403 u8 channel;
404 u8 count;
405 } __packed;
407 struct libipw_action {
408 struct libipw_hdr_3addr header;
409 u8 category;
410 u8 action;
411 union {
412 struct libipw_action_exchange {
413 u8 token;
414 struct libipw_info_element info_element[0];
415 } exchange;
416 struct libipw_channel_switch channel_switch;
418 } format;
419 } __packed;
421 struct libipw_disassoc {
422 struct libipw_hdr_3addr header;
423 __le16 reason;
424 } __packed;
426 /* Alias deauth for disassoc */
427 #define libipw_deauth libipw_disassoc
429 struct libipw_probe_request {
430 struct libipw_hdr_3addr header;
431 /* SSID, supported rates */
432 struct libipw_info_element info_element[0];
433 } __packed;
435 struct libipw_probe_response {
436 struct libipw_hdr_3addr header;
437 __le32 time_stamp[2];
438 __le16 beacon_interval;
439 __le16 capability;
440 /* SSID, supported rates, FH params, DS params,
441 * CF params, IBSS params, TIM (if beacon), RSN */
442 struct libipw_info_element info_element[0];
443 } __packed;
445 /* Alias beacon for probe_response */
446 #define libipw_beacon libipw_probe_response
448 struct libipw_assoc_request {
449 struct libipw_hdr_3addr header;
450 __le16 capability;
451 __le16 listen_interval;
452 /* SSID, supported rates, RSN */
453 struct libipw_info_element info_element[0];
454 } __packed;
456 struct libipw_reassoc_request {
457 struct libipw_hdr_3addr header;
458 __le16 capability;
459 __le16 listen_interval;
460 u8 current_ap[ETH_ALEN];
461 struct libipw_info_element info_element[0];
462 } __packed;
464 struct libipw_assoc_response {
465 struct libipw_hdr_3addr header;
466 __le16 capability;
467 __le16 status;
468 __le16 aid;
469 /* supported rates */
470 struct libipw_info_element info_element[0];
471 } __packed;
473 struct libipw_txb {
474 u8 nr_frags;
475 u8 encrypted;
476 u8 rts_included;
477 u8 reserved;
478 u16 frag_size;
479 u16 payload_size;
480 struct sk_buff *fragments[0];
483 /* SWEEP TABLE ENTRIES NUMBER */
484 #define MAX_SWEEP_TAB_ENTRIES 42
485 #define MAX_SWEEP_TAB_ENTRIES_PER_PACKET 7
486 /* MAX_RATES_LENGTH needs to be 12. The spec says 8, and many APs
487 * only use 8, and then use extended rates for the remaining supported
488 * rates. Other APs, however, stick all of their supported rates on the
489 * main rates information element... */
490 #define MAX_RATES_LENGTH ((u8)12)
491 #define MAX_RATES_EX_LENGTH ((u8)16)
492 #define MAX_NETWORK_COUNT 128
494 #define CRC_LENGTH 4U
496 #define MAX_WPA_IE_LEN 64
498 #define NETWORK_HAS_OFDM (1<<1)
499 #define NETWORK_HAS_CCK (1<<2)
501 /* QoS structure */
502 #define NETWORK_HAS_QOS_PARAMETERS (1<<3)
503 #define NETWORK_HAS_QOS_INFORMATION (1<<4)
504 #define NETWORK_HAS_QOS_MASK (NETWORK_HAS_QOS_PARAMETERS | \
505 NETWORK_HAS_QOS_INFORMATION)
507 /* 802.11h */
508 #define NETWORK_HAS_POWER_CONSTRAINT (1<<5)
509 #define NETWORK_HAS_CSA (1<<6)
510 #define NETWORK_HAS_QUIET (1<<7)
511 #define NETWORK_HAS_IBSS_DFS (1<<8)
512 #define NETWORK_HAS_TPC_REPORT (1<<9)
514 #define NETWORK_HAS_ERP_VALUE (1<<10)
516 #define QOS_QUEUE_NUM 4
517 #define QOS_OUI_LEN 3
518 #define QOS_OUI_TYPE 2
519 #define QOS_ELEMENT_ID 221
520 #define QOS_OUI_INFO_SUB_TYPE 0
521 #define QOS_OUI_PARAM_SUB_TYPE 1
522 #define QOS_VERSION_1 1
523 #define QOS_AIFSN_MIN_VALUE 2
525 struct libipw_qos_information_element {
526 u8 elementID;
527 u8 length;
528 u8 qui[QOS_OUI_LEN];
529 u8 qui_type;
530 u8 qui_subtype;
531 u8 version;
532 u8 ac_info;
533 } __packed;
535 struct libipw_qos_ac_parameter {
536 u8 aci_aifsn;
537 u8 ecw_min_max;
538 __le16 tx_op_limit;
539 } __packed;
541 struct libipw_qos_parameter_info {
542 struct libipw_qos_information_element info_element;
543 u8 reserved;
544 struct libipw_qos_ac_parameter ac_params_record[QOS_QUEUE_NUM];
545 } __packed;
547 struct libipw_qos_parameters {
548 __le16 cw_min[QOS_QUEUE_NUM];
549 __le16 cw_max[QOS_QUEUE_NUM];
550 u8 aifs[QOS_QUEUE_NUM];
551 u8 flag[QOS_QUEUE_NUM];
552 __le16 tx_op_limit[QOS_QUEUE_NUM];
553 } __packed;
555 struct libipw_qos_data {
556 struct libipw_qos_parameters parameters;
557 int active;
558 int supported;
559 u8 param_count;
560 u8 old_param_count;
563 struct libipw_tim_parameters {
564 u8 tim_count;
565 u8 tim_period;
566 } __packed;
568 /*******************************************************/
570 enum { /* libipw_basic_report.map */
571 LIBIPW_BASIC_MAP_BSS = (1 << 0),
572 LIBIPW_BASIC_MAP_OFDM = (1 << 1),
573 LIBIPW_BASIC_MAP_UNIDENTIFIED = (1 << 2),
574 LIBIPW_BASIC_MAP_RADAR = (1 << 3),
575 LIBIPW_BASIC_MAP_UNMEASURED = (1 << 4),
576 /* Bits 5-7 are reserved */
579 struct libipw_basic_report {
580 u8 channel;
581 __le64 start_time;
582 __le16 duration;
583 u8 map;
584 } __packed;
586 enum { /* libipw_measurement_request.mode */
587 /* Bit 0 is reserved */
588 LIBIPW_MEASUREMENT_ENABLE = (1 << 1),
589 LIBIPW_MEASUREMENT_REQUEST = (1 << 2),
590 LIBIPW_MEASUREMENT_REPORT = (1 << 3),
591 /* Bits 4-7 are reserved */
594 enum {
595 LIBIPW_REPORT_BASIC = 0, /* required */
596 LIBIPW_REPORT_CCA = 1, /* optional */
597 LIBIPW_REPORT_RPI = 2, /* optional */
598 /* 3-255 reserved */
601 struct libipw_measurement_params {
602 u8 channel;
603 __le64 start_time;
604 __le16 duration;
605 } __packed;
607 struct libipw_measurement_request {
608 struct libipw_info_element ie;
609 u8 token;
610 u8 mode;
611 u8 type;
612 struct libipw_measurement_params params[0];
613 } __packed;
615 struct libipw_measurement_report {
616 struct libipw_info_element ie;
617 u8 token;
618 u8 mode;
619 u8 type;
620 union {
621 struct libipw_basic_report basic[0];
622 } u;
623 } __packed;
625 struct libipw_tpc_report {
626 u8 transmit_power;
627 u8 link_margin;
628 } __packed;
630 struct libipw_channel_map {
631 u8 channel;
632 u8 map;
633 } __packed;
635 struct libipw_ibss_dfs {
636 struct libipw_info_element ie;
637 u8 owner[ETH_ALEN];
638 u8 recovery_interval;
639 struct libipw_channel_map channel_map[0];
642 struct libipw_csa {
643 u8 mode;
644 u8 channel;
645 u8 count;
646 } __packed;
648 struct libipw_quiet {
649 u8 count;
650 u8 period;
651 u8 duration;
652 u8 offset;
653 } __packed;
655 struct libipw_network {
656 /* These entries are used to identify a unique network */
657 u8 bssid[ETH_ALEN];
658 u8 channel;
659 /* Ensure null-terminated for any debug msgs */
660 u8 ssid[IW_ESSID_MAX_SIZE + 1];
661 u8 ssid_len;
663 struct libipw_qos_data qos_data;
665 /* These are network statistics */
666 struct libipw_rx_stats stats;
667 u16 capability;
668 u8 rates[MAX_RATES_LENGTH];
669 u8 rates_len;
670 u8 rates_ex[MAX_RATES_EX_LENGTH];
671 u8 rates_ex_len;
672 unsigned long last_scanned;
673 u8 mode;
674 u32 flags;
675 u32 last_associate;
676 u32 time_stamp[2];
677 u16 beacon_interval;
678 u16 listen_interval;
679 u16 atim_window;
680 u8 erp_value;
681 u8 wpa_ie[MAX_WPA_IE_LEN];
682 size_t wpa_ie_len;
683 u8 rsn_ie[MAX_WPA_IE_LEN];
684 size_t rsn_ie_len;
685 struct libipw_tim_parameters tim;
687 /* 802.11h info */
689 /* Power Constraint - mandatory if spctrm mgmt required */
690 u8 power_constraint;
692 /* TPC Report - mandatory if spctrm mgmt required */
693 struct libipw_tpc_report tpc_report;
695 /* IBSS DFS - mandatory if spctrm mgmt required and IBSS
696 * NOTE: This is variable length and so must be allocated dynamically */
697 struct libipw_ibss_dfs *ibss_dfs;
699 /* Channel Switch Announcement - optional if spctrm mgmt required */
700 struct libipw_csa csa;
702 /* Quiet - optional if spctrm mgmt required */
703 struct libipw_quiet quiet;
705 struct list_head list;
708 enum libipw_state {
709 LIBIPW_UNINITIALIZED = 0,
710 LIBIPW_INITIALIZED,
711 LIBIPW_ASSOCIATING,
712 LIBIPW_ASSOCIATED,
713 LIBIPW_AUTHENTICATING,
714 LIBIPW_AUTHENTICATED,
715 LIBIPW_SHUTDOWN
718 #define DEFAULT_MAX_SCAN_AGE (15 * HZ)
719 #define DEFAULT_FTS 2346
721 #define CFG_LIBIPW_RESERVE_FCS (1<<0)
722 #define CFG_LIBIPW_COMPUTE_FCS (1<<1)
723 #define CFG_LIBIPW_RTS (1<<2)
725 #define LIBIPW_24GHZ_MIN_CHANNEL 1
726 #define LIBIPW_24GHZ_MAX_CHANNEL 14
727 #define LIBIPW_24GHZ_CHANNELS (LIBIPW_24GHZ_MAX_CHANNEL - \
728 LIBIPW_24GHZ_MIN_CHANNEL + 1)
730 #define LIBIPW_52GHZ_MIN_CHANNEL 34
731 #define LIBIPW_52GHZ_MAX_CHANNEL 165
732 #define LIBIPW_52GHZ_CHANNELS (LIBIPW_52GHZ_MAX_CHANNEL - \
733 LIBIPW_52GHZ_MIN_CHANNEL + 1)
735 enum {
736 LIBIPW_CH_PASSIVE_ONLY = (1 << 0),
737 LIBIPW_CH_80211H_RULES = (1 << 1),
738 LIBIPW_CH_B_ONLY = (1 << 2),
739 LIBIPW_CH_NO_IBSS = (1 << 3),
740 LIBIPW_CH_UNIFORM_SPREADING = (1 << 4),
741 LIBIPW_CH_RADAR_DETECT = (1 << 5),
742 LIBIPW_CH_INVALID = (1 << 6),
745 struct libipw_channel {
746 u32 freq; /* in MHz */
747 u8 channel;
748 u8 flags;
749 u8 max_power; /* in dBm */
752 struct libipw_geo {
753 u8 name[4];
754 u8 bg_channels;
755 u8 a_channels;
756 struct libipw_channel bg[LIBIPW_24GHZ_CHANNELS];
757 struct libipw_channel a[LIBIPW_52GHZ_CHANNELS];
760 struct libipw_device {
761 struct net_device *dev;
762 struct wireless_dev wdev;
763 struct libipw_security sec;
765 /* Bookkeeping structures */
766 struct libipw_stats ieee_stats;
768 struct libipw_geo geo;
769 struct ieee80211_supported_band bg_band;
770 struct ieee80211_supported_band a_band;
772 /* Probe / Beacon management */
773 struct list_head network_free_list;
774 struct list_head network_list;
775 struct libipw_network *networks[MAX_NETWORK_COUNT];
776 int scans;
777 int scan_age;
779 int iw_mode; /* operating mode (IW_MODE_*) */
780 struct iw_spy_data spy_data; /* iwspy support */
782 spinlock_t lock;
784 int tx_headroom; /* Set to size of any additional room needed at front
785 * of allocated Tx SKBs */
786 u32 config;
788 /* WEP and other encryption related settings at the device level */
789 int open_wep; /* Set to 1 to allow unencrypted frames */
791 int reset_on_keychange; /* Set to 1 if the HW needs to be reset on
792 * WEP key changes */
794 /* If the host performs {en,de}cryption, then set to 1 */
795 int host_encrypt;
796 int host_encrypt_msdu;
797 int host_decrypt;
798 /* host performs multicast decryption */
799 int host_mc_decrypt;
801 /* host should strip IV and ICV from protected frames */
802 /* meaningful only when hardware decryption is being used */
803 int host_strip_iv_icv;
805 int host_open_frag;
806 int ieee802_1x; /* is IEEE 802.1X used */
808 /* WPA data */
809 int wpa_enabled;
810 int drop_unencrypted;
811 int privacy_invoked;
812 size_t wpa_ie_len;
813 u8 *wpa_ie;
815 struct lib80211_crypt_info crypt_info;
817 int bcrx_sta_key; /* use individual keys to override default keys even
818 * with RX of broad/multicast frames */
820 /* Fragmentation structures */
821 struct libipw_frag_entry frag_cache[LIBIPW_FRAG_CACHE_LEN];
822 unsigned int frag_next_idx;
823 u16 fts; /* Fragmentation Threshold */
824 u16 rts; /* RTS threshold */
826 /* Association info */
827 u8 bssid[ETH_ALEN];
829 enum libipw_state state;
831 int mode; /* A, B, G */
832 int modulation; /* CCK, OFDM */
833 int freq_band; /* 2.4Ghz, 5.2Ghz, Mixed */
834 int abg_true; /* ABG flag */
836 int perfect_rssi;
837 int worst_rssi;
839 u16 prev_seq_ctl; /* used to drop duplicate frames */
841 /* Callback functions */
842 void (*set_security) (struct net_device * dev,
843 struct libipw_security * sec);
844 netdev_tx_t (*hard_start_xmit) (struct libipw_txb * txb,
845 struct net_device * dev, int pri);
846 int (*reset_port) (struct net_device * dev);
847 int (*is_queue_full) (struct net_device * dev, int pri);
849 int (*handle_management) (struct net_device * dev,
850 struct libipw_network * network, u16 type);
851 int (*is_qos_active) (struct net_device *dev, struct sk_buff *skb);
853 /* Typical STA methods */
854 int (*handle_auth) (struct net_device * dev,
855 struct libipw_auth * auth);
856 int (*handle_deauth) (struct net_device * dev,
857 struct libipw_deauth * auth);
858 int (*handle_action) (struct net_device * dev,
859 struct libipw_action * action,
860 struct libipw_rx_stats * stats);
861 int (*handle_disassoc) (struct net_device * dev,
862 struct libipw_disassoc * assoc);
863 int (*handle_beacon) (struct net_device * dev,
864 struct libipw_beacon * beacon,
865 struct libipw_network * network);
866 int (*handle_probe_response) (struct net_device * dev,
867 struct libipw_probe_response * resp,
868 struct libipw_network * network);
869 int (*handle_probe_request) (struct net_device * dev,
870 struct libipw_probe_request * req,
871 struct libipw_rx_stats * stats);
872 int (*handle_assoc_response) (struct net_device * dev,
873 struct libipw_assoc_response * resp,
874 struct libipw_network * network);
876 /* Typical AP methods */
877 int (*handle_assoc_request) (struct net_device * dev);
878 int (*handle_reassoc_request) (struct net_device * dev,
879 struct libipw_reassoc_request * req);
881 /* This must be the last item so that it points to the data
882 * allocated beyond this structure by alloc_libipw */
883 u8 priv[0];
886 #define IEEE_A (1<<0)
887 #define IEEE_B (1<<1)
888 #define IEEE_G (1<<2)
889 #define IEEE_MODE_MASK (IEEE_A|IEEE_B|IEEE_G)
891 static inline void *libipw_priv(struct net_device *dev)
893 return ((struct libipw_device *)netdev_priv(dev))->priv;
896 static inline int libipw_is_valid_mode(struct libipw_device *ieee,
897 int mode)
900 * It is possible for both access points and our device to support
901 * combinations of modes, so as long as there is one valid combination
902 * of ap/device supported modes, then return success
905 if ((mode & IEEE_A) &&
906 (ieee->modulation & LIBIPW_OFDM_MODULATION) &&
907 (ieee->freq_band & LIBIPW_52GHZ_BAND))
908 return 1;
910 if ((mode & IEEE_G) &&
911 (ieee->modulation & LIBIPW_OFDM_MODULATION) &&
912 (ieee->freq_band & LIBIPW_24GHZ_BAND))
913 return 1;
915 if ((mode & IEEE_B) &&
916 (ieee->modulation & LIBIPW_CCK_MODULATION) &&
917 (ieee->freq_band & LIBIPW_24GHZ_BAND))
918 return 1;
920 return 0;
923 static inline int libipw_get_hdrlen(u16 fc)
925 int hdrlen = LIBIPW_3ADDR_LEN;
926 u16 stype = WLAN_FC_GET_STYPE(fc);
928 switch (WLAN_FC_GET_TYPE(fc)) {
929 case IEEE80211_FTYPE_DATA:
930 if ((fc & IEEE80211_FCTL_FROMDS) && (fc & IEEE80211_FCTL_TODS))
931 hdrlen = LIBIPW_4ADDR_LEN;
932 if (stype & IEEE80211_STYPE_QOS_DATA)
933 hdrlen += 2;
934 break;
935 case IEEE80211_FTYPE_CTL:
936 switch (WLAN_FC_GET_STYPE(fc)) {
937 case IEEE80211_STYPE_CTS:
938 case IEEE80211_STYPE_ACK:
939 hdrlen = LIBIPW_1ADDR_LEN;
940 break;
941 default:
942 hdrlen = LIBIPW_2ADDR_LEN;
943 break;
945 break;
948 return hdrlen;
951 static inline u8 *libipw_get_payload(struct ieee80211_hdr *hdr)
953 switch (libipw_get_hdrlen(le16_to_cpu(hdr->frame_control))) {
954 case LIBIPW_1ADDR_LEN:
955 return ((struct libipw_hdr_1addr *)hdr)->payload;
956 case LIBIPW_2ADDR_LEN:
957 return ((struct libipw_hdr_2addr *)hdr)->payload;
958 case LIBIPW_3ADDR_LEN:
959 return ((struct libipw_hdr_3addr *)hdr)->payload;
960 case LIBIPW_4ADDR_LEN:
961 return ((struct libipw_hdr_4addr *)hdr)->payload;
963 return NULL;
966 static inline int libipw_is_ofdm_rate(u8 rate)
968 switch (rate & ~LIBIPW_BASIC_RATE_MASK) {
969 case LIBIPW_OFDM_RATE_6MB:
970 case LIBIPW_OFDM_RATE_9MB:
971 case LIBIPW_OFDM_RATE_12MB:
972 case LIBIPW_OFDM_RATE_18MB:
973 case LIBIPW_OFDM_RATE_24MB:
974 case LIBIPW_OFDM_RATE_36MB:
975 case LIBIPW_OFDM_RATE_48MB:
976 case LIBIPW_OFDM_RATE_54MB:
977 return 1;
979 return 0;
982 static inline int libipw_is_cck_rate(u8 rate)
984 switch (rate & ~LIBIPW_BASIC_RATE_MASK) {
985 case LIBIPW_CCK_RATE_1MB:
986 case LIBIPW_CCK_RATE_2MB:
987 case LIBIPW_CCK_RATE_5MB:
988 case LIBIPW_CCK_RATE_11MB:
989 return 1;
991 return 0;
994 /* libipw.c */
995 extern void free_libipw(struct net_device *dev, int monitor);
996 extern struct net_device *alloc_libipw(int sizeof_priv, int monitor);
997 extern int libipw_change_mtu(struct net_device *dev, int new_mtu);
999 extern void libipw_networks_age(struct libipw_device *ieee,
1000 unsigned long age_secs);
1002 extern int libipw_set_encryption(struct libipw_device *ieee);
1004 /* libipw_tx.c */
1005 extern netdev_tx_t libipw_xmit(struct sk_buff *skb,
1006 struct net_device *dev);
1007 extern void libipw_txb_free(struct libipw_txb *);
1009 /* libipw_rx.c */
1010 extern void libipw_rx_any(struct libipw_device *ieee,
1011 struct sk_buff *skb, struct libipw_rx_stats *stats);
1012 extern int libipw_rx(struct libipw_device *ieee, struct sk_buff *skb,
1013 struct libipw_rx_stats *rx_stats);
1014 /* make sure to set stats->len */
1015 extern void libipw_rx_mgt(struct libipw_device *ieee,
1016 struct libipw_hdr_4addr *header,
1017 struct libipw_rx_stats *stats);
1018 extern void libipw_network_reset(struct libipw_network *network);
1020 /* libipw_geo.c */
1021 extern const struct libipw_geo *libipw_get_geo(struct libipw_device
1022 *ieee);
1023 extern int libipw_set_geo(struct libipw_device *ieee,
1024 const struct libipw_geo *geo);
1026 extern int libipw_is_valid_channel(struct libipw_device *ieee,
1027 u8 channel);
1028 extern int libipw_channel_to_index(struct libipw_device *ieee,
1029 u8 channel);
1030 extern u8 libipw_freq_to_channel(struct libipw_device *ieee, u32 freq);
1031 extern u8 libipw_get_channel_flags(struct libipw_device *ieee,
1032 u8 channel);
1033 extern const struct libipw_channel *libipw_get_channel(struct
1034 libipw_device
1035 *ieee, u8 channel);
1036 extern u32 libipw_channel_to_freq(struct libipw_device * ieee,
1037 u8 channel);
1039 /* libipw_wx.c */
1040 extern int libipw_wx_get_scan(struct libipw_device *ieee,
1041 struct iw_request_info *info,
1042 union iwreq_data *wrqu, char *key);
1043 extern int libipw_wx_set_encode(struct libipw_device *ieee,
1044 struct iw_request_info *info,
1045 union iwreq_data *wrqu, char *key);
1046 extern int libipw_wx_get_encode(struct libipw_device *ieee,
1047 struct iw_request_info *info,
1048 union iwreq_data *wrqu, char *key);
1049 extern int libipw_wx_set_encodeext(struct libipw_device *ieee,
1050 struct iw_request_info *info,
1051 union iwreq_data *wrqu, char *extra);
1052 extern int libipw_wx_get_encodeext(struct libipw_device *ieee,
1053 struct iw_request_info *info,
1054 union iwreq_data *wrqu, char *extra);
1056 static inline void libipw_increment_scans(struct libipw_device *ieee)
1058 ieee->scans++;
1061 static inline int libipw_get_scans(struct libipw_device *ieee)
1063 return ieee->scans;
1066 #endif /* LIBIPW_H */