pci.c: fix missing newline in acx_log_dump()
[acx-mac80211.git] / acx_struct.h
blob6cb26846ccf30eb64a2d009db4a086bb8873015a
1 #ifndef _ACX_STRUCT_H_
2 #define _ACX_STRUCT_H_
4 /*
5 * acx_struct.h: common structures.
7 * Copyright (C) 2003-2008, the ACX100 Open Source Project.
9 * This file is licensed under the GPL version 2. See the README file for more
10 * information.
12 #include <linux/version.h>
13 #include "acx_commands.h"
16 * We must not even enter here if neither USB nor PCI support are enabled. This
17 * file will take care of that for us.
19 * FIXME: hack!
21 #include "acx_config.h"
22 #include "acx_mac80211.h"
23 #include "acx_debug.h"
25 /***********************************************************************
26 ** Forward declarations of types
28 typedef struct tx tx_t;
29 typedef struct acx_device acx_device_t;
30 typedef struct client client_t;
31 typedef struct rxdesc rxdesc_t;
32 typedef struct txdesc txdesc_t;
33 typedef struct rxhostdesc rxhostdesc_t;
34 typedef struct txhostdesc txhostdesc_t;
37 /***********************************************************************
38 ** Constants
40 #define OK 0
41 #define NOT_OK 1
43 /* The supported chip models */
44 #define CHIPTYPE_ACX100 1
45 #define CHIPTYPE_ACX111 2
47 #define IS_ACX100(adev) ((adev)->chip_type == CHIPTYPE_ACX100)
48 #define IS_ACX111(adev) ((adev)->chip_type == CHIPTYPE_ACX111)
50 #if defined(CONFIG_ACX_MAC80211_PCI)
51 #define IS_PCI(adev) (1)
52 #define IS_USB(adev) (0)
53 #else
55 * If not PCI, it IS a USB device. We cannot have both at the same time.
57 #define IS_PCI(adev) (0)
58 #define IS_USB(adev) (1)
59 #endif /* !defined(CONFIG_ACX_MAC80211_PCI) */
61 /* Driver defaults */
62 #define DEFAULT_DTIM_INTERVAL 10
63 /* used to be 2048, but FreeBSD driver changed it to 4096 to work properly
64 ** in noisy wlans */
65 #define DEFAULT_MSDU_LIFETIME 4096
66 #define DEFAULT_RTS_THRESHOLD 2312 /* max. size: disable RTS mechanism */
67 #define DEFAULT_BEACON_INTERVAL 100
69 #define ACX100_BAP_DATALEN_MAX 4096
70 #define ACX100_RID_GUESSING_MAXLEN 2048 /* I'm not really sure */
71 #define ACX100_RIDDATA_MAXLEN ACX100_RID_GUESSING_MAXLEN
73 /* Support Constants */
74 /* Radio type names, found in Win98 driver's TIACXLN.INF */
75 #define RADIO_MAXIM_0D 0x0d
76 #define RADIO_RFMD_11 0x11
77 #define RADIO_RALINK_15 0x15
78 /* used in ACX111 cards (WG311v2, WL-121, ...): */
79 #define RADIO_RADIA_16 0x16
80 /* most likely *sometimes* used in ACX111 cards: */
81 #define RADIO_UNKNOWN_17 0x17
82 /* FwRad19.bin was found in a Safecom driver; must be an ACX111 radio: */
83 #define RADIO_UNKNOWN_19 0x19
84 #define RADIO_UNKNOWN_1B 0x1b /* radio in SafeCom SWLUT-54125 USB adapter; entirely unknown!! */
86 /* Controller Commands */
87 /* can be found in table cmdTable in firmware "Rev. 1.5.0" (FW150) */
88 #define ACX1xx_CMD_RESET 0x00
89 #define ACX1xx_CMD_INTERROGATE 0x01
90 #define ACX1xx_CMD_CONFIGURE 0x02
91 #define ACX1xx_CMD_ENABLE_RX 0x03
92 #define ACX1xx_CMD_ENABLE_TX 0x04
93 #define ACX1xx_CMD_DISABLE_RX 0x05
94 #define ACX1xx_CMD_DISABLE_TX 0x06
95 #define ACX1xx_CMD_FLUSH_QUEUE 0x07
96 #define ACX1xx_CMD_SCAN 0x08
97 #define ACX1xx_CMD_STOP_SCAN 0x09
98 #define ACX1xx_CMD_CONFIG_TIM 0x0a
99 #define ACX1xx_CMD_JOIN 0x0b
100 #define ACX1xx_CMD_WEP_MGMT 0x0c
101 #ifdef OLD_FIRMWARE_VERSIONS
102 #define ACX100_CMD_HALT 0x0e /* mapped to unknownCMD in FW150 */
103 #else
104 #define ACX1xx_CMD_MEM_READ 0x0d
105 #define ACX1xx_CMD_MEM_WRITE 0x0e
106 #endif
107 #define ACX1xx_CMD_SLEEP 0x0f
108 #define ACX1xx_CMD_WAKE 0x10
109 #define ACX1xx_CMD_UNKNOWN_11 0x11 /* mapped to unknownCMD in FW150 */
110 #define ACX100_CMD_INIT_MEMORY 0x12
111 #define ACX1FF_CMD_DISABLE_RADIO 0x12 /* new firmware? TNETW1450? */
112 #define ACX1xx_CMD_CONFIG_BEACON 0x13
113 #define ACX1xx_CMD_CONFIG_PROBE_RESPONSE 0x14
114 #define ACX1xx_CMD_CONFIG_NULL_DATA 0x15
115 #define ACX1xx_CMD_CONFIG_PROBE_REQUEST 0x16
116 #define ACX1xx_CMD_FCC_TEST 0x17
117 #define ACX1xx_CMD_RADIOINIT 0x18
118 #define ACX111_CMD_RADIOCALIB 0x19
119 #define ACX1FF_CMD_NOISE_HISTOGRAM 0x1c /* new firmware? TNETW1450? */
120 #define ACX1FF_CMD_RX_RESET 0x1d /* new firmware? TNETW1450? */
121 #define ACX1FF_CMD_LNA_CONTROL 0x20 /* new firmware? TNETW1450? */
122 #define ACX1FF_CMD_CONTROL_DBG_TRACE 0x21 /* new firmware? TNETW1450? */
124 /***********************************************************************
125 ** Tx/Rx buffer sizes and watermarks
127 ** This will alloc and use DMAable buffers of
128 ** WLAN_A4FR_MAXLEN_WEP_FCS * (RX_CNT + TX_CNT) bytes
129 ** RX/TX_CNT=32 -> ~150k DMA buffers
130 ** RX/TX_CNT=16 -> ~75k DMA buffers
132 ** 2005-10-10: reduced memory usage by lowering both to 16
134 #define RX_CNT 16
135 #define TX_CNT 16
137 /* we clean up txdescs when we have N free txdesc: */
138 #define TX_CLEAN_BACKLOG (TX_CNT/4)
139 #define TX_START_CLEAN (TX_CNT - TX_CLEAN_BACKLOG)
140 #define TX_EMERG_CLEAN 2
141 /* we stop queue if we have < N free txbufs: */
142 #define TX_STOP_QUEUE 3
143 /* we start queue if we have >= N free txbufs: */
144 #define TX_START_QUEUE 5
147 /***********************************************************************
148 **Information Frames Structures
151 /* Used in beacon frames and the like */
152 #define DOT11RATEBYTE_1 (1*2)
153 #define DOT11RATEBYTE_2 (2*2)
154 #define DOT11RATEBYTE_5_5 (5*2+1)
155 #define DOT11RATEBYTE_11 (11*2)
156 #define DOT11RATEBYTE_22 (22*2)
157 #define DOT11RATEBYTE_6_G (6*2)
158 #define DOT11RATEBYTE_9_G (9*2)
159 #define DOT11RATEBYTE_12_G (12*2)
160 #define DOT11RATEBYTE_18_G (18*2)
161 #define DOT11RATEBYTE_24_G (24*2)
162 #define DOT11RATEBYTE_36_G (36*2)
163 #define DOT11RATEBYTE_48_G (48*2)
164 #define DOT11RATEBYTE_54_G (54*2)
165 #define DOT11RATEBYTE_BASIC 0x80 /* flags rates included in basic rate set */
168 /***********************************************************************
169 ** rxbuffer_t
171 ** This is the format of rx data returned by acx
174 /* I've hoped it's a 802.11 PHY header, but no...
175 * so far, I've seen on acx111:
176 * 0000 3a00 0000 0000 IBSS Beacons
177 * 0000 3c00 0000 0000 ESS Beacons
178 * 0000 2700 0000 0000 Probe requests
179 * --vda
181 typedef struct phy_hdr {
182 u8 unknown[4];
183 u8 acx111_unknown[4];
184 } __attribute__ ((packed)) phy_hdr_t;
186 /* seems to be a bit similar to hfa384x_rx_frame.
187 * These fields are still not quite obvious, though.
188 * Some seem to have different meanings... */
190 #define RXBUF_HDRSIZE 12
191 #define RXBUF_BYTES_RCVD(adev, rxbuf) \
192 ((le16_to_cpu((rxbuf)->mac_cnt_rcvd) & 0xfff) - (adev)->phy_header_len)
193 #define RXBUF_BYTES_USED(rxbuf) \
194 ((le16_to_cpu((rxbuf)->mac_cnt_rcvd) & 0xfff) + RXBUF_HDRSIZE)
195 /* USBism */
196 #define RXBUF_IS_TXSTAT(rxbuf) (le16_to_cpu((rxbuf)->mac_cnt_rcvd) & 0x8000)
198 mac_cnt_rcvd:
199 12 bits: length of frame from control field to first byte of FCS
200 3 bits: reserved
201 1 bit: 1 = it's a tx status info, not a rx packet (USB only)
203 mac_cnt_mblks:
204 6 bits: number of memory block used to store frame in adapter memory
205 1 bit: Traffic Indicator bit in TIM of received Beacon was set
207 mac_status: 1 byte (bitmap):
208 7 Matching BSSID
209 6 Matching SSID
210 5 BDCST Address 1 field is a broadcast
211 4 VBM received beacon frame has more than one set bit (?!)
212 3 TIM Set bit representing this station is set in TIM of received beacon
213 2 GROUP Address 1 is a multicast
214 1 ADDR1 Address 1 matches our MAC
215 0 FCSGD FSC is good
217 phy_stat_baseband: 1 byte (bitmap):
218 7 Preamble frame had a long preamble
219 6 PLCP Error CRC16 error in PLCP header
220 5 Unsup_Mod unsupported modulation
221 4 Selected Antenna antenna 1 was used to receive this frame
222 3 PBCC/CCK frame used: 1=PBCC, 0=CCK modulation
223 2 OFDM frame used OFDM modulation
224 1 TI Protection protection frame was detected
225 0 Reserved
227 phy_plcp_signal: 1 byte:
228 Receive PLCP Signal field from the Baseband Processor
230 phy_level: 1 byte:
231 receive AGC gain level (can be used to measure receive signal strength)
233 phy_snr: 1 byte:
234 estimated noise power of equalized receive signal
235 at input of FEC decoder (can be used to measure receive signal quality)
237 time: 4 bytes:
238 timestamp sampled from either the Access Manager TSF counter
239 or free-running microsecond counter when the MAC receives
240 first byte of PLCP header.
243 typedef struct rxbuffer {
244 u16 mac_cnt_rcvd; /* only 12 bits are len! (0xfff) */
245 u8 mac_cnt_mblks;
246 u8 mac_status;
247 u8 phy_stat_baseband; /* bit 0x80: used LNA (Low-Noise Amplifier) */
248 u8 phy_plcp_signal;
249 u8 phy_level; /* PHY stat */
250 u8 phy_snr; /* PHY stat */
251 u32 time; /* timestamp upon MAC rcv first byte */
252 /* 4-byte (acx100) or 8-byte (acx111) phy header will be here
253 ** if RX_CFG1_INCLUDE_PHY_HDR is in effect:
254 ** phy_hdr_t phy */
255 struct ieee80211_hdr hdr_a3;
256 /* maximally sized data part of wlan packet */
257 u8 data_a3[30 + 2312 + 4 - 24]; /*WLAN_A4FR_MAXLEN_WEP_FCS - WLAN_HDR_A3_LEN]*/
258 /* can add hdr/data_a4 if needed */
259 } __attribute__ ((packed)) rxbuffer_t;
262 /*--- Firmware statistics ----------------------------------------------------*/
264 /* define a random 100 bytes more to catch firmware versions which
265 * provide a bigger struct */
266 #define FW_STATS_FUTURE_EXTENSION 100
268 typedef struct fw_stats_tx {
269 u32 tx_desc_of;
270 } __attribute__ ((packed)) fw_stats_tx_t;
272 typedef struct fw_stats_rx {
273 u32 rx_oom;
274 u32 rx_hdr_of;
275 u32 rx_hw_stuck; /* old: u32 rx_hdr_use_next */
276 u32 rx_dropped_frame;
277 u32 rx_frame_ptr_err;
278 u32 rx_xfr_hint_trig;
279 u32 rx_aci_events; /* later versions only */
280 u32 rx_aci_resets; /* later versions only */
281 } __attribute__ ((packed)) fw_stats_rx_t;
283 typedef struct fw_stats_dma {
284 u32 rx_dma_req;
285 u32 rx_dma_err;
286 u32 tx_dma_req;
287 u32 tx_dma_err;
288 } __attribute__ ((packed)) fw_stats_dma_t;
290 typedef struct fw_stats_irq {
291 u32 cmd_cplt;
292 u32 fiq;
293 u32 rx_hdrs;
294 u32 rx_cmplt;
295 u32 rx_mem_of;
296 u32 rx_rdys;
297 u32 irqs;
298 u32 tx_procs;
299 u32 decrypt_done;
300 u32 dma_0_done;
301 u32 dma_1_done;
302 u32 tx_exch_complet;
303 u32 commands;
304 u32 rx_procs;
305 u32 hw_pm_mode_changes;
306 u32 host_acks;
307 u32 pci_pm;
308 u32 acm_wakeups;
309 } __attribute__ ((packed)) fw_stats_irq_t;
311 typedef struct fw_stats_wep {
312 u32 wep_key_count;
313 u32 wep_default_key_count;
314 u32 dot11_def_key_mib;
315 u32 wep_key_not_found;
316 u32 wep_decrypt_fail;
317 u32 wep_pkt_decrypt;
318 u32 wep_decrypt_irqs;
319 } __attribute__ ((packed)) fw_stats_wep_t;
321 typedef struct fw_stats_pwr {
322 u32 tx_start_ctr;
323 u32 no_ps_tx_too_short;
324 u32 rx_start_ctr;
325 u32 no_ps_rx_too_short;
326 u32 lppd_started;
327 u32 no_lppd_too_noisy;
328 u32 no_lppd_too_short;
329 u32 no_lppd_matching_frame;
330 } __attribute__ ((packed)) fw_stats_pwr_t;
332 typedef struct fw_stats_mic {
333 u32 mic_rx_pkts;
334 u32 mic_calc_fail;
335 } __attribute__ ((packed)) fw_stats_mic_t;
337 typedef struct fw_stats_aes {
338 u32 aes_enc_fail;
339 u32 aes_dec_fail;
340 u32 aes_enc_pkts;
341 u32 aes_dec_pkts;
342 u32 aes_enc_irq;
343 u32 aes_dec_irq;
344 } __attribute__ ((packed)) fw_stats_aes_t;
346 typedef struct fw_stats_event {
347 u32 heartbeat;
348 u32 calibration;
349 u32 rx_mismatch;
350 u32 rx_mem_empty;
351 u32 rx_pool;
352 u32 oom_late;
353 u32 phy_tx_err;
354 u32 tx_stuck;
355 } __attribute__ ((packed)) fw_stats_event_t;
357 /* mainly for size calculation only */
358 typedef struct fw_stats {
359 u16 type;
360 u16 len;
361 fw_stats_tx_t tx;
362 fw_stats_rx_t rx;
363 fw_stats_dma_t dma;
364 fw_stats_irq_t irq;
365 fw_stats_wep_t wep;
366 fw_stats_pwr_t pwr;
367 fw_stats_mic_t mic;
368 fw_stats_aes_t aes;
369 fw_stats_event_t evt;
370 u8 _padding[FW_STATS_FUTURE_EXTENSION];
371 } fw_stats_t;
373 /* Firmware version struct */
375 typedef struct fw_ver {
376 u16 cmd;
377 u16 size;
378 char fw_id[20];
379 u32 hw_id;
380 } __attribute__ ((packed)) fw_ver_t;
382 #define FW_ID_SIZE 20
385 /*--- WEP stuff --------------------------------------------------------------*/
386 #define DOT11_MAX_DEFAULT_WEP_KEYS 4
388 /* non-firmware struct, no packing necessary */
389 typedef struct wep_key {
390 size_t size; /* most often used member first */
391 u8 index;
392 u8 key[29];
393 u16 strange_filler;
394 } wep_key_t; /* size = 264 bytes (33*8) */
395 /* FIXME: We don't have size 264! Or is there 2 bytes beyond the key
396 * (strange_filler)? */
398 /* non-firmware struct, no packing necessary */
399 typedef struct key_struct {
400 u8 addr[ETH_ALEN]; /* 0x00 */
401 u16 filler1; /* 0x06 */
402 u32 filler2; /* 0x08 */
403 u32 index; /* 0x0c */
404 u16 len; /* 0x10 */
405 u8 key[29]; /* 0x12; is this long enough??? */
406 } key_struct_t; /* size = 276. FIXME: where is the remaining space?? */
409 /*--- Client (peer) info -----------------------------------------------------*/
410 /* adev->sta_list[] is used for:
411 ** accumulating and processing of scan results
412 ** keeping client info in AP mode
413 ** keeping AP info in STA mode (AP is the only one 'client')
414 ** keeping peer info in ad-hoc mode
415 ** non-firmware struct --> no packing necessary */
416 enum {
417 CLIENT_EMPTY_SLOT_0 = 0,
418 CLIENT_EXIST_1 = 1,
419 CLIENT_AUTHENTICATED_2 = 2,
420 CLIENT_ASSOCIATED_3 = 3,
421 CLIENT_JOIN_CANDIDATE = 4
423 struct client {
424 /* most frequent access first */
425 u8 used; /* misnamed, more like 'status' */
426 struct client* next;
427 unsigned long mtime; /* last time we heard it, in jiffies */
428 size_t essid_len; /* length of ESSID (without '\0') */
429 u32 sir; /* Standard IR */
430 u32 snr; /* Signal to Noise Ratio */
431 u16 aid; /* association ID */
432 u16 seq; /* from client's auth req */
433 u16 auth_alg; /* from client's auth req */
434 u16 cap_info; /* from client's assoc req */
435 u16 rate_cap; /* what client supports (all rates) */
436 u16 rate_bas; /* what client supports (basic rates) */
437 u16 rate_cfg; /* what is allowed (by iwconfig etc) */
438 u16 rate_cur; /* currently used rate mask */
439 u8 rate_100; /* currently used rate byte (acx100 only) */
440 u8 address[ETH_ALEN];
441 u8 bssid[ETH_ALEN]; /* ad-hoc hosts can have bssid != mac */
442 u8 channel;
443 u8 auth_step;
444 u8 ignore_count;
445 u8 fallback_count;
446 u8 stepup_count;
447 char essid[IW_ESSID_MAX_SIZE + 1]; /* ESSID and trailing '\0' */
448 /* FIXME: this one is too damn big */
449 char challenge_text[128]; /*WLAN_CHALLENGE_LEN*/
453 /***********************************************************************
454 ** Hardware structures
457 /* An opaque typesafe helper type
459 * Some hardware fields are actually pointers,
460 * but they have to remain u32, since using ptr instead
461 * (8 bytes on 64bit systems!) would disrupt the fixed descriptor
462 * format the acx firmware expects in the non-user area.
463 * Since we cannot cram an 8 byte ptr into 4 bytes, we need to
464 * enforce that pointed to data remains in low memory
465 * (address value needs to fit in 4 bytes) on 64bit systems.
467 * This is easy to get wrong, thus we are using a small struct
468 * and special macros to access it. Macros will check for
469 * attempts to overflow an acx_ptr with value > 0xffffffff.
471 * Attempts to use acx_ptr without macros result in compile-time errors */
473 typedef struct {
474 u32 v;
475 } __attribute__ ((packed)) acx_ptr;
477 #if ACX_DEBUG
478 #define CHECK32(n) BUG_ON(sizeof(n)>4 && (long)(n)>0xffffff00)
479 #else
480 #define CHECK32(n) ((void)0)
481 #endif
483 /* acx_ptr <-> integer conversion */
484 #define cpu2acx(n) ({ CHECK32(n); ((acx_ptr){ .v = cpu_to_le32(n) }); })
485 #define acx2cpu(a) (le32_to_cpu(a.v))
487 /* acx_ptr <-> pointer conversion */
488 #define ptr2acx(p) ({ CHECK32(p); ((acx_ptr){ .v = cpu_to_le32((u32)(long)(p)) }); })
489 #define acx2ptr(a) ((void*)le32_to_cpu(a.v))
491 /* Values for rate field (acx100 only) */
492 #define RATE100_1 10
493 #define RATE100_2 20
494 #define RATE100_5 55
495 #define RATE100_11 110
496 #define RATE100_22 220
497 /* This bit denotes use of PBCC:
498 ** (PBCC encoding is usable with 11 and 22 Mbps speeds only) */
499 #define RATE100_PBCC511 0x80
501 /* Bit values for rate111 field */
502 #define RATE111_1 0x0001 /* DBPSK */
503 #define RATE111_2 0x0002 /* DQPSK */
504 #define RATE111_5 0x0004 /* CCK or PBCC */
505 #define RATE111_6 0x0008 /* CCK-OFDM or OFDM */
506 #define RATE111_9 0x0010 /* CCK-OFDM or OFDM */
507 #define RATE111_11 0x0020 /* CCK or PBCC */
508 #define RATE111_12 0x0040 /* CCK-OFDM or OFDM */
509 #define RATE111_18 0x0080 /* CCK-OFDM or OFDM */
510 #define RATE111_22 0x0100 /* PBCC */
511 #define RATE111_24 0x0200 /* CCK-OFDM or OFDM */
512 #define RATE111_36 0x0400 /* CCK-OFDM or OFDM */
513 #define RATE111_48 0x0800 /* CCK-OFDM or OFDM */
514 #define RATE111_54 0x1000 /* CCK-OFDM or OFDM */
515 #define RATE111_RESERVED 0x2000
516 #define RATE111_PBCC511 0x4000 /* PBCC mod at 5.5 or 11Mbit (else CCK) */
517 #define RATE111_SHORTPRE 0x8000 /* short preamble */
518 /* Special 'try everything' value */
519 #define RATE111_ALL 0x1fff
520 /* These bits denote acx100 compatible settings */
521 #define RATE111_ACX100_COMPAT 0x0127
522 /* These bits denote 802.11b compatible settings */
523 #define RATE111_80211B_COMPAT 0x0027
525 /* Descriptor Ctl field bits
526 * init value is 0x8e, "idle" value is 0x82 (in idle tx descs)
528 #define DESC_CTL_SHORT_PREAMBLE 0x01 /* preamble type: 0 = long; 1 = short */
529 #define DESC_CTL_FIRSTFRAG 0x02 /* this is the 1st frag of the frame */
530 #define DESC_CTL_AUTODMA 0x04
531 #define DESC_CTL_RECLAIM 0x08 /* ready to reuse */
532 #define DESC_CTL_HOSTDONE 0x20 /* host has finished processing */
533 #define DESC_CTL_ACXDONE 0x40 /* acx has finished processing */
534 /* host owns the desc [has to be released last, AFTER modifying all other desc fields!] */
535 #define DESC_CTL_HOSTOWN 0x80
536 #define DESC_CTL_ACXDONE_HOSTOWN (DESC_CTL_ACXDONE | DESC_CTL_HOSTOWN)
538 /* Descriptor Status field
540 #define DESC_STATUS_FULL (1 << 31)
542 /* NB: some bits may be interesting for Monitor mode tx (aka Raw tx): */
543 #define DESC_CTL2_SEQ 0x01 /* don't increase sequence field */
544 #define DESC_CTL2_FCS 0x02 /* don't add the FCS */
545 #define DESC_CTL2_MORE_FRAG 0x04
546 #define DESC_CTL2_RETRY 0x08 /* don't increase retry field */
547 #define DESC_CTL2_POWER 0x10 /* don't increase power mgmt. field */
548 #define DESC_CTL2_RTS 0x20 /* do RTS/CTS magic before sending */
549 #define DESC_CTL2_WEP 0x40 /* encrypt this frame */
550 #define DESC_CTL2_DUR 0x80 /* don't increase duration field */
552 /***********************************************************************
553 ** PCI structures
556 /* Outside of "#ifdef PCI" because USB needs to know sizeof()
557 ** of txdesc and rxdesc: */
558 struct txdesc {
559 acx_ptr pNextDesc; /* pointer to next txdesc */
560 acx_ptr HostMemPtr; /* 0x04 */
561 acx_ptr AcxMemPtr; /* 0x08 */
562 u32 tx_time; /* 0x0c */
563 u16 total_length; /* 0x10 */
564 u16 Reserved; /* 0x12 */
566 /* The following 16 bytes do not change when acx100 owns the descriptor */
567 /* BUG: fw clears last byte of this area which is supposedly reserved
568 ** for driver use. amd64 blew up. We dare not use it now */
569 u32 dummy[4];
571 u8 Ctl_8; /* 0x24, 8bit value */
572 u8 Ctl2_8; /* 0x25, 8bit value */
573 u8 error; /* 0x26 */
574 u8 ack_failures; /* 0x27 */
575 u8 rts_failures; /* 0x28 */
576 u8 rts_ok; /* 0x29 */
577 union {
578 struct {
579 u8 rate; /* 0x2a */
580 u8 queue_ctrl; /* 0x2b */
581 } __attribute__ ((packed)) r1;
582 struct {
583 u16 rate111; /* 0x2a */
584 } __attribute__ ((packed)) r2;
585 } __attribute__ ((packed)) u;
586 u32 queue_info; /* 0x2c (acx100, reserved on acx111) */
587 } __attribute__ ((packed)); /* size : 48 = 0x30 */
588 /* NB: acx111 txdesc structure is 4 byte larger */
589 /* All these 4 extra bytes are reserved. tx alloc code takes them into account */
591 struct rxdesc {
592 acx_ptr pNextDesc; /* 0x00 */
593 acx_ptr HostMemPtr; /* 0x04 */
594 acx_ptr ACXMemPtr; /* 0x08 */
595 u32 rx_time; /* 0x0c */
596 u16 total_length; /* 0x10 */
597 u16 WEP_length; /* 0x12 */
598 u32 WEP_ofs; /* 0x14 */
600 /* the following 16 bytes do not change when acx100 owns the descriptor */
601 u8 driverWorkspace[16]; /* 0x18 */
603 u8 Ctl_8;
604 u8 rate;
605 u8 error;
606 u8 SNR; /* Signal-to-Noise Ratio */
607 u8 RxLevel;
608 u8 queue_ctrl;
609 u16 unknown;
610 u32 unknown2;
611 } __attribute__ ((packed)); /* size 52 = 0x34 */
613 /***********************************************************************
614 ** USB structures and constants
616 #ifdef ACX_MAC80211_USB
618 /* Used for usb_txbuffer.desc field */
619 #define USB_TXBUF_TXDESC 0xA
620 /* Size of header (everything up to data[]) */
621 #define USB_TXBUF_HDRSIZE 14
622 typedef struct usb_txbuffer {
623 u16 desc;
624 u16 mpdu_len;
625 u8 queue_index;
626 u8 rate;
627 u32 hostdata;
628 u8 ctrl1;
629 u8 ctrl2;
630 u16 data_len;
631 /* wlan packet content is placed here: */
632 u8 data[30 + 2312 + 4]; /*WLAN_A4FR_MAXLEN_WEP_FCS]*/
633 } __attribute__ ((packed)) usb_txbuffer_t;
635 /* USB returns either rx packets (see rxbuffer) or
636 ** these "tx status" structs: */
637 typedef struct usb_txstatus {
638 u16 mac_cnt_rcvd; /* only 12 bits are len! (0xfff) */
639 u8 queue_index;
640 u8 mac_status; /* seen 0x20 on tx failure */
641 u32 hostdata;
642 u8 rate;
643 u8 ack_failures;
644 u8 rts_failures;
645 u8 rts_ok;
646 // struct ieee80211_tx_status txstatus;
647 // struct sk_buff *skb;
648 } __attribute__ ((packed)) usb_txstatus_t;
650 typedef struct usb_tx {
651 unsigned busy:1;
652 struct urb *urb;
653 acx_device_t *adev;
654 /* actual USB bulk output data block is here: */
655 usb_txbuffer_t bulkout;
656 } usb_tx_t;
658 struct usb_rx_plain {
659 unsigned busy:1;
660 struct urb *urb;
661 acx_device_t *adev;
662 rxbuffer_t bulkin;
665 typedef struct usb_rx {
666 unsigned busy:1;
667 struct urb *urb;
668 acx_device_t *adev;
669 rxbuffer_t bulkin;
670 /* Make entire structure 4k */
671 u8 padding[4*1024 - sizeof(struct usb_rx_plain)];
672 } usb_rx_t;
673 #endif /* ACX_USB */
676 /* Config Option structs */
678 typedef struct co_antennas {
679 u8 type;
680 u8 len;
681 u8 list[2];
682 } __attribute__ ((packed)) co_antennas_t;
684 typedef struct co_powerlevels {
685 u8 type;
686 u8 len;
687 u16 list[8];
688 } __attribute__ ((packed)) co_powerlevels_t;
690 typedef struct co_datarates {
691 u8 type;
692 u8 len;
693 u8 list[8];
694 } __attribute__ ((packed)) co_datarates_t;
696 typedef struct co_domains {
697 u8 type;
698 u8 len;
699 u8 list[6];
700 } __attribute__ ((packed)) co_domains_t;
702 typedef struct co_product_id {
703 u8 type;
704 u8 len;
705 u8 list[128];
706 } __attribute__ ((packed)) co_product_id_t;
708 typedef struct co_manuf_id {
709 u8 type;
710 u8 len;
711 u8 list[128];
712 } __attribute__ ((packed)) co_manuf_t;
714 typedef struct co_fixed {
715 char NVSv[8];
716 /* u16 NVS_vendor_offs; ACX111-only */
717 /* u16 unknown; ACX111-only */
718 u8 MAC[6]; /* ACX100-only */
719 u16 probe_delay; /* ACX100-only */
720 u32 eof_memory;
721 u8 dot11CCAModes;
722 u8 dot11Diversity;
723 u8 dot11ShortPreambleOption;
724 u8 dot11PBCCOption;
725 u8 dot11ChannelAgility;
726 u8 dot11PhyType; /* FIXME: does 802.11 call it "dot11PHYType"? */
727 u8 dot11TempType;
728 u8 table_count;
729 } __attribute__ ((packed)) co_fixed_t;
731 typedef struct acx111_ie_configoption {
732 u16 type;
733 u16 len;
734 /* Do not access below members directly, they are in fact variable length */
735 co_fixed_t fixed;
736 co_antennas_t antennas;
737 co_powerlevels_t power_levels;
738 co_datarates_t data_rates;
739 co_domains_t domains;
740 co_product_id_t product_id;
741 co_manuf_t manufacturer;
742 u8 _padding[4];
743 } __attribute__ ((packed)) acx111_ie_configoption_t;
745 /***********************************************************************
746 ** Main acx per-device data structure
748 #define ACX_STATE_FW_LOADED 0x01
749 #define ACX_STATE_IFACE_UP 0x02
751 /* MAC mode (BSS type) defines
752 * Note that they shouldn't be redefined, since they are also used
753 * during communication with firmware */
754 #define ACX_MODE_0_ADHOC 0
755 #define ACX_MODE_1_UNUSED 1
756 #define ACX_MODE_2_STA 2
757 #define ACX_MODE_3_AP 3
758 /* These are our own inventions. Sending these to firmware
759 ** makes it stop emitting beacons, which is exactly what we want
760 ** for these modes */
761 #define ACX_MODE_MONITOR 0xfe
762 #define ACX_MODE_OFF 0xff
763 /* 'Submode': identifies exact status of ADHOC/STA host */
764 #define ACX_STATUS_0_STOPPED 0
765 #define ACX_STATUS_1_SCANNING 1
766 #define ACX_STATUS_2_WAIT_AUTH 2
767 #define ACX_STATUS_3_AUTHENTICATED 3
768 #define ACX_STATUS_4_ASSOCIATED 4
770 /* FIXME: this should be named something like struct acx_priv (typedef'd to
771 * acx_priv_t) */
773 /* non-firmware struct, no packing necessary */
774 struct acx_device {
775 /* most frequent accesses first (dereferencing and cache line!) */
778 * Locking
780 struct mutex mutex;
781 spinlock_t spinlock;
782 spinlock_t irqlock;
784 * IRQ handling
786 /* The IRQ we have inherited */
787 unsigned int irq;
788 /* Are IRQs currently activated? FIXME: should get rid of this */
789 u8 irqs_active;
790 /* The interrupts we can acknowledge (see acx_irq.h) */
791 u16 irq_mask;
792 /* The mask of IRQs saved by the IRQ top half routine */
793 u16 irq_saved_mask;
795 * FIXME: these ones should disappear
797 unsigned int irq_loops_this_jiffy;
798 unsigned long irq_last_jiffies;
799 /* Barely used in USB case (FIXME?) */
800 u16 irq_status;
801 int irq_reason; /* FIXME: should be u16 */
802 /* Mask of jobs we have to schedule post interrupt */
803 u8 after_interrupt_jobs;
805 * Work queue for the bottom half. FIXME: only one, consider a
806 * delayed_work struct some day?
808 struct work_struct after_interrupt_task;
809 #if defined(PARANOID_LOCKING) /* Lock debugging */
810 const char *last_sem;
811 const char *last_lock;
812 unsigned long sem_time;
813 unsigned long lock_time;
814 #endif
816 /*** Linux network device ***/
817 //struct device *dev; /* pointer to linux netdevice */
819 /*** Device statistics ***/
820 struct ieee80211_low_level_stats ieee_stats; /* wireless device statistics */
822 /*** Device statistics ***/
823 struct net_device_stats stats; /* net device statistics */
825 #ifdef WIRELESS_EXT
826 // struct iw_statistics wstats; /* wireless statistics */
827 #endif
828 struct ieee80211_hw *ieee;
829 struct ieee80211_hw_mode modes[2];
830 struct ieee80211_rx_status rx_status;
832 struct ieee80211_vif *vif;
834 /*** Power managment ***/
835 struct pm_dev *pm; /* PM crap */
837 /*** Management timer ***/
838 struct timer_list mgmt_timer;
840 /*** Hardware identification ***/
841 const char *chip_name;
842 u8 chip_type;
843 u8 form_factor;
844 u8 radio_type;
845 u8 eeprom_version;
847 /*** Config retrieved from EEPROM ***/
848 char cfgopt_NVSv[8];
849 u16 cfgopt_NVS_vendor_offs;
850 u8 cfgopt_MAC[6];
851 u16 cfgopt_probe_delay;
852 u32 cfgopt_eof_memory;
853 u8 cfgopt_dot11CCAModes;
854 u8 cfgopt_dot11Diversity;
855 u8 cfgopt_dot11ShortPreambleOption;
856 u8 cfgopt_dot11PBCCOption;
857 u8 cfgopt_dot11ChannelAgility;
858 u8 cfgopt_dot11PhyType;
859 u8 cfgopt_dot11TempType;
860 co_antennas_t cfgopt_antennas;
861 co_powerlevels_t cfgopt_power_levels;
862 co_datarates_t cfgopt_data_rates;
863 co_domains_t cfgopt_domains;
864 co_product_id_t cfgopt_product_id;
865 co_manuf_t cfgopt_manufacturer;
867 /*** Firmware identification ***/
868 char firmware_version[FW_ID_SIZE+1];
869 u32 firmware_numver;
870 u32 firmware_id;
871 const u16 *ie_len;
872 const u16 *ie_len_dot11;
874 /*** Device state ***/
875 u16 dev_state_mask;
876 u8 led_power; /* power LED status */
877 u32 get_mask; /* mask of settings to fetch from the card */
878 u32 set_mask; /* mask of settings to write to the card */
879 u32 initialized:1;
882 /*** scanning ***/
883 u16 scan_count; /* number of times to do channel scan */
884 u8 scan_mode; /* 0 == active, 1 == passive, 2 == background */
885 u8 scan_rate;
886 u16 scan_duration;
887 u16 scan_probe_delay;
888 #if WIRELESS_EXT > 15
889 // struct iw_spy_data spy_data; /* FIXME: needs to be implemented! */
890 #endif
892 /*** Virtual interface struct ***/
893 struct acx_interface interface;
895 /*** Wireless network settings ***/
896 /* copy of the device address (ifconfig hw ether) that we actually use
897 ** for 802.11; copied over from the network device's MAC address
898 ** (ifconfig) when it makes sense only */
899 u8 dev_addr[MAX_ADDR_LEN];
900 u8 bssid[ETH_ALEN]; /* the BSSID after having joined */
901 u8 ap[ETH_ALEN]; /* The AP we want, FF:FF:FF:FF:FF:FF is any */
902 u16 aid; /* The Association ID sent from the AP / last used AID if we're an AP */
903 u16 mode; /* mode from iwconfig */
904 int monitor_type; /* ARPHRD_IEEE80211 or ARPHRD_IEEE80211_PRISM */
905 u16 status; /* 802.11 association status */
906 u8 essid_active; /* specific ESSID active, or select any? */
907 u8 essid_len; /* to avoid dozens of strlen() */
908 /* INCLUDES \0 termination for easy printf - but many places
909 ** simply want the string data memcpy'd plus a length indicator!
910 ** Keep that in mind... */
911 char essid[IW_ESSID_MAX_SIZE+1];
912 /* essid we are going to use for association, in case of "essid 'any'"
913 ** and in case of hidden ESSID (use configured ESSID then) */
914 char essid_for_assoc[IW_ESSID_MAX_SIZE+1];
915 char nick[IW_ESSID_MAX_SIZE+1]; /* see essid! */
916 u8 channel;
917 u8 reg_dom_id; /* reg domain setting */
918 u16 reg_dom_chanmask;
919 u16 auth_or_assoc_retries;
920 u16 scan_retries;
921 unsigned long scan_start; /* YES, jiffies is defined as "unsigned long" */
924 /* MAC80211 Template Reference */
925 struct sk_buff *beacon_cache;
926 /* stations known to us (if we're an ap) */
927 // client_t sta_list[32]; /* tab is larger than list, so that */
928 // client_t *sta_hash_tab[64]; /* hash collisions are not likely */
929 // client_t *ap_client; /* this one is our AP (STA mode only) */
931 int dup_count;
932 int nondup_count;
933 unsigned long dup_msg_expiry;
934 u16 last_seq_ctrl; /* duplicate packet detection */
936 /* 802.11 power save mode */
937 u8 ps_wakeup_cfg;
938 u8 ps_listen_interval;
939 u8 ps_options;
940 u8 ps_hangover_period;
941 u32 ps_enhanced_transition_time;
942 u32 ps_beacon_rx_time;
944 /*** PHY settings ***/
945 u8 fallback_threshold;
946 u8 stepup_threshold;
947 u16 rate_basic;
948 u16 rate_oper;
949 u16 rate_bcast;
950 u16 rate_bcast100;
951 u8 rate_auto; /* false if "iwconfig rate N" (WITHOUT 'auto'!) */
952 u8 preamble_mode; /* 0 == Long Preamble, 1 == Short, 2 == Auto */
953 u8 preamble_cur;
955 u8 tx_disabled;
956 u8 tx_level_dbm;
957 /* u8 tx_level_val; */
958 /* u8 tx_level_auto; whether to do automatic power adjustment */
960 unsigned long recalib_time_last_success;
961 unsigned long recalib_time_last_attempt;
962 int recalib_failure_count;
963 int recalib_msg_ratelimit;
964 int retry_errors_msg_ratelimit;
966 unsigned long brange_time_last_state_change; /* time the power LED was last changed */
967 u8 brange_last_state; /* last state of the LED */
968 u8 brange_max_quality; /* maximum quality that equates to full speed */
970 u8 sensitivity;
971 u8 antenna; /* antenna settings */
972 u8 ed_threshold; /* energy detect threshold */
973 u8 cca; /* clear channel assessment */
975 u16 rts_threshold;
976 u16 frag_threshold;
977 u32 short_retry;
978 u32 long_retry;
979 u16 msdu_lifetime;
980 u16 listen_interval; /* given in units of beacon interval */
981 u32 beacon_interval;
983 u16 capabilities;
984 u8 rate_supported_len;
985 u8 rate_supported[13];
987 /*** Encryption settings (WEP) ***/
988 u32 auth_alg; /* used in transmit_authen1 */
989 u8 wep_enabled;
990 u8 wep_restricted;
991 u8 wep_current_index;
992 wep_key_t wep_keys[DOT11_MAX_DEFAULT_WEP_KEYS]; /* the default WEP keys */
994 key_struct_t wep_key_struct[10];
996 /*** Encryption Replacement for mac80211 ***/
997 struct acx_key key[54];
998 u16 security_offset;
999 u8 default_key_idx;
1002 /*** Unknown ***/
1003 u8 dtim_interval;
1005 /*** Card Rx/Tx management ***/
1006 u16 rx_config_1;
1007 u16 rx_config_2;
1008 u16 memblocksize;
1009 unsigned int tx_free;
1010 unsigned int tx_head; /* keep as close as possible to Tx stuff below (cache line) */
1011 u16 phy_header_len;
1013 /*************************************************************************
1014 *** PCI/USB/... must be last or else hw agnostic code breaks horribly ***
1015 *************************************************************************/
1017 /* hack to let common code compile. FIXME */
1018 dma_addr_t rxhostdesc_startphy;
1020 /*** PCI stuff ***/
1021 #ifdef ACX_MAC80211_PCI
1022 /* pointers to tx buffers, tx host descriptors (in host memory)
1023 ** and tx descs in device memory */
1024 unsigned int tx_tail;
1025 u8 *txbuf_start;
1026 txhostdesc_t *txhostdesc_start;
1027 txdesc_t *txdesc_start; /* points to PCI-mapped memory */
1028 dma_addr_t txbuf_startphy;
1029 dma_addr_t txhostdesc_startphy;
1030 /* sizes of above host memory areas */
1031 unsigned int txbuf_area_size;
1032 unsigned int txhostdesc_area_size;
1034 unsigned int txdesc_size; /* size of txdesc; ACX111 = ACX100 + 4 */
1035 client_t *txc[TX_CNT];
1036 u16 txr[TX_CNT];
1038 /* same for rx */
1039 unsigned int rx_tail;
1040 rxbuffer_t *rxbuf_start;
1041 rxhostdesc_t *rxhostdesc_start;
1042 rxdesc_t *rxdesc_start;
1043 /* physical addresses of above host memory areas */
1044 dma_addr_t rxbuf_startphy;
1045 /* dma_addr_t rxhostdesc_startphy; */
1046 unsigned int rxbuf_area_size;
1047 unsigned int rxhostdesc_area_size;
1049 u8 need_radio_fw;
1051 const u16 *io; /* points to ACX100 or ACX111 PCI I/O register address set */
1053 #ifdef CONFIG_PCI
1054 struct pci_dev *pdev;
1055 #endif
1056 #ifdef CONFIG_VLYNQ
1057 struct vlynq_device *vdev;
1058 #endif
1059 struct device *bus_dev;
1060 unsigned long membase;
1061 unsigned long membase2;
1062 void __iomem *iobase;
1063 void __iomem *iobase2;
1064 /* command interface */
1065 u8 __iomem *cmd_area;
1066 u8 __iomem *info_area;
1068 #endif
1070 /*** USB stuff ***/
1071 #ifdef ACX_MAC80211_USB
1072 struct usb_device *usbdev;
1074 rxbuffer_t rxtruncbuf;
1076 usb_tx_t *usb_tx;
1077 usb_rx_t *usb_rx;
1079 int bulkinep; /* bulk-in endpoint */
1080 int bulkoutep; /* bulk-out endpoint */
1081 int rxtruncsize;
1082 #endif
1087 #define ieee2adev(ieee80211_hw) ((ieee80211_hw)->priv)
1089 /* For use with ACX1xx_IE_RXCONFIG */
1090 /* bit description
1091 * 13 include additional header (length etc.) *required*
1092 * struct is defined in 'struct rxbuffer'
1093 * is this bit acx100 only? does acx111 always put the header,
1094 * and bit setting is irrelevant? --vda
1095 * 10 receive frames only with SSID used in last join cmd
1096 * 9 discard broadcast
1097 * 8 receive packets for multicast address 1
1098 * 7 receive packets for multicast address 0
1099 * 6 discard all multicast packets
1100 * 5 discard frames from foreign BSSID
1101 * 4 discard frames with foreign destination MAC address
1102 * 3 promiscuous mode (receive ALL frames, disable filter)
1103 * 2 include FCS
1104 * 1 include phy header
1105 * 0 ???
1107 #define RX_CFG1_INCLUDE_RXBUF_HDR 0x2000 /* ACX100 only */
1108 #define RX_CFG1_FILTER_SSID 0x0400
1109 #define RX_CFG1_FILTER_BCAST 0x0200
1110 #define RX_CFG1_RCV_MC_ADDR1 0x0100
1111 #define RX_CFG1_RCV_MC_ADDR0 0x0080
1112 #define RX_CFG1_FILTER_ALL_MULTI 0x0040
1113 #define RX_CFG1_FILTER_BSSID 0x0020
1114 #define RX_CFG1_FILTER_MAC 0x0010
1115 #define RX_CFG1_RCV_PROMISCUOUS 0x0008
1116 #define RX_CFG1_INCLUDE_FCS 0x0004
1117 #define RX_CFG1_INCLUDE_PHY_HDR (WANT_PHY_HDR ? 0x0002 : 0)
1118 /* bit description
1119 * 11 receive association requests etc.
1120 * 10 receive authentication frames
1121 * 9 receive beacon frames
1122 * 8 receive contention free packets
1123 * 7 receive control frames
1124 * 6 receive data frames
1125 * 5 receive broken frames
1126 * 4 receive management frames
1127 * 3 receive probe requests
1128 * 2 receive probe responses
1129 * 1 receive RTS/CTS/ACK frames
1130 * 0 receive other
1132 #define RX_CFG2_RCV_ASSOC_REQ 0x0800
1133 #define RX_CFG2_RCV_AUTH_FRAMES 0x0400
1134 #define RX_CFG2_RCV_BEACON_FRAMES 0x0200
1135 #define RX_CFG2_RCV_CONTENTION_FREE 0x0100
1136 #define RX_CFG2_RCV_CTRL_FRAMES 0x0080
1137 #define RX_CFG2_RCV_DATA_FRAMES 0x0040
1138 #define RX_CFG2_RCV_BROKEN_FRAMES 0x0020
1139 #define RX_CFG2_RCV_MGMT_FRAMES 0x0010
1140 #define RX_CFG2_RCV_PROBE_REQ 0x0008
1141 #define RX_CFG2_RCV_PROBE_RESP 0x0004
1142 #define RX_CFG2_RCV_ACK_FRAMES 0x0002
1143 #define RX_CFG2_RCV_OTHER 0x0001
1145 /* For use with ACX1xx_IE_FEATURE_CONFIG */
1146 #define FEATURE1_80MHZ_CLOCK 0x00000040L
1147 #define FEATURE1_4X 0x00000020L
1148 #define FEATURE1_LOW_RX 0x00000008L
1149 #define FEATURE1_EXTRA_LOW_RX 0x00000001L
1151 #define FEATURE2_SNIFFER 0x00000080L
1152 #define FEATURE2_NO_TXCRYPT 0x00000001L
1154 /*-- get and set mask values --*/
1155 #define GETSET_LED_POWER 0x00000001L
1156 #define GETSET_STATION_ID 0x00000002L
1157 #define SET_TEMPLATES 0x00000004L
1158 #define SET_STA_LIST 0x00000008L
1159 #define GETSET_TX 0x00000010L
1160 #define GETSET_RX 0x00000020L
1161 #define SET_RXCONFIG 0x00000040L
1162 #define GETSET_ANTENNA 0x00000080L
1163 #define GETSET_SENSITIVITY 0x00000100L
1164 #define GETSET_TXPOWER 0x00000200L
1165 #define GETSET_ED_THRESH 0x00000400L
1166 #define GETSET_CCA 0x00000800L
1167 #define GETSET_POWER_80211 0x00001000L
1168 #define GETSET_RETRY 0x00002000L
1169 #define GETSET_REG_DOMAIN 0x00004000L
1170 #define GETSET_CHANNEL 0x00008000L
1171 /* Used when ESSID changes etc and we need to scan for AP anew */
1172 #define GETSET_RESCAN 0x00010000L
1173 #define GETSET_MODE 0x00020000L
1174 #define GETSET_WEP 0x00040000L
1175 #define SET_WEP_OPTIONS 0x00080000L
1176 #define SET_MSDU_LIFETIME 0x00100000L
1177 #define SET_RATE_FALLBACK 0x00200000L
1179 /* keep in sync with the above */
1180 #define GETSET_ALL (0 \
1181 /* GETSET_LED_POWER */ | 0x00000001L \
1182 /* GETSET_STATION_ID */ | 0x00000002L \
1183 /* SET_TEMPLATES */ | 0x00000004L \
1184 /* SET_STA_LIST */ | 0x00000008L \
1185 /* GETSET_TX */ | 0x00000010L \
1186 /* GETSET_RX */ | 0x00000020L \
1187 /* SET_RXCONFIG */ | 0x00000040L \
1188 /* GETSET_ANTENNA */ | 0x00000080L \
1189 /* GETSET_SENSITIVITY */| 0x00000100L \
1190 /* GETSET_TXPOWER */ | 0x00000200L \
1191 /* GETSET_ED_THRESH */ | 0x00000400L \
1192 /* GETSET_CCA */ | 0x00000800L \
1193 /* GETSET_POWER_80211 */| 0x00001000L \
1194 /* GETSET_RETRY */ | 0x00002000L \
1195 /* GETSET_REG_DOMAIN */ | 0x00004000L \
1196 /* GETSET_CHANNEL */ | 0x00008000L \
1197 /* GETSET_RESCAN */ | 0x00010000L \
1198 /* GETSET_MODE */ | 0x00020000L \
1199 /* GETSET_WEP */ | 0x00040000L \
1200 /* SET_WEP_OPTIONS */ | 0x00080000L \
1201 /* SET_MSDU_LIFETIME */ | 0x00100000L \
1202 /* SET_RATE_FALLBACK */ | 0x00200000L \
1205 /***********************************************************************
1207 typedef struct acx100_ie_memblocksize {
1208 u16 type;
1209 u16 len;
1210 u16 size;
1211 } __attribute__ ((packed)) acx100_ie_memblocksize_t;
1213 typedef struct acx100_ie_queueconfig {
1214 u16 type;
1215 u16 len;
1216 u32 AreaSize;
1217 u32 RxQueueStart;
1218 u8 QueueOptions;
1219 u8 NumTxQueues;
1220 u8 NumRxDesc; /* for USB only */
1221 u8 pad1;
1222 u32 QueueEnd;
1223 u32 HostQueueEnd; /* QueueEnd2 */
1224 u32 TxQueueStart;
1225 u8 TxQueuePri;
1226 u8 NumTxDesc;
1227 u16 pad2;
1228 } __attribute__ ((packed)) acx100_ie_queueconfig_t;
1230 typedef struct acx111_ie_queueconfig {
1231 u16 type;
1232 u16 len;
1233 u32 tx_memory_block_address;
1234 u32 rx_memory_block_address;
1235 u32 rx1_queue_address;
1236 u32 reserved1;
1237 u32 tx1_queue_address;
1238 u8 tx1_attributes;
1239 u16 reserved2;
1240 u8 reserved3;
1241 } __attribute__ ((packed)) acx111_ie_queueconfig_t;
1243 typedef struct acx100_ie_memconfigoption {
1244 u16 type;
1245 u16 len;
1246 u32 DMA_config;
1247 acx_ptr pRxHostDesc;
1248 u32 rx_mem;
1249 u32 tx_mem;
1250 u16 RxBlockNum;
1251 u16 TxBlockNum;
1252 } __attribute__ ((packed)) acx100_ie_memconfigoption_t;
1254 typedef struct acx111_ie_memoryconfig {
1255 u16 type;
1256 u16 len;
1257 u16 no_of_stations;
1258 u16 memory_block_size;
1259 u8 tx_rx_memory_block_allocation;
1260 u8 count_rx_queues;
1261 u8 count_tx_queues;
1262 u8 options;
1263 u8 fragmentation;
1264 u16 reserved1;
1265 u8 reserved2;
1267 /* start of rx1 block */
1268 u8 rx_queue1_count_descs;
1269 u8 rx_queue1_reserved1;
1270 u8 rx_queue1_type; /* must be set to 7 */
1271 u8 rx_queue1_prio; /* must be set to 0 */
1272 acx_ptr rx_queue1_host_rx_start;
1273 /* end of rx1 block */
1275 /* start of tx1 block */
1276 u8 tx_queue1_count_descs;
1277 u8 tx_queue1_reserved1;
1278 u8 tx_queue1_reserved2;
1279 u8 tx_queue1_attributes;
1280 /* end of tx1 block */
1281 } __attribute__ ((packed)) acx111_ie_memoryconfig_t;
1283 typedef struct acx_ie_memmap {
1284 u16 type;
1285 u16 len;
1286 u32 CodeStart;
1287 u32 CodeEnd;
1288 u32 WEPCacheStart;
1289 u32 WEPCacheEnd;
1290 u32 PacketTemplateStart;
1291 u32 PacketTemplateEnd;
1292 u32 QueueStart;
1293 u32 QueueEnd;
1294 u32 PoolStart;
1295 u32 PoolEnd;
1296 } __attribute__ ((packed)) acx_ie_memmap_t;
1298 typedef struct acx111_ie_feature_config {
1299 u16 type;
1300 u16 len;
1301 u32 feature_options;
1302 u32 data_flow_options;
1303 } __attribute__ ((packed)) acx111_ie_feature_config_t;
1305 typedef struct acx111_ie_tx_level {
1306 u16 type;
1307 u16 len;
1308 u8 level;
1309 } __attribute__ ((packed)) acx111_ie_tx_level_t;
1311 #define PS_CFG_ENABLE 0x80
1312 #define PS_CFG_PENDING 0x40 /* status flag when entering PS */
1313 #define PS_CFG_WAKEUP_MODE_MASK 0x07
1314 #define PS_CFG_WAKEUP_BY_HOST 0x03
1315 #define PS_CFG_WAKEUP_EACH_ITVL 0x02
1316 #define PS_CFG_WAKEUP_ON_DTIM 0x01
1317 #define PS_CFG_WAKEUP_ALL_BEAC 0x00
1319 /* Enhanced PS mode: sleep until Rx Beacon w/ the STA's AID bit set
1320 ** in the TIM; newer firmwares only(?) */
1321 #define PS_OPT_ENA_ENHANCED_PS 0x04
1322 #define PS_OPT_TX_PSPOLL 0x02 /* send PSPoll frame to fetch waiting frames from AP (on frame with matching AID) */
1323 #define PS_OPT_STILL_RCV_BCASTS 0x01
1325 typedef struct acx100_ie_powersave {
1326 u16 type;
1327 u16 len;
1328 u8 wakeup_cfg;
1329 u8 listen_interval; /* for EACH_ITVL: wake up every "beacon units" interval */
1330 u8 options;
1331 u8 hangover_period; /* remaining wake time after Tx MPDU w/ PS bit, in values of 1/1024 seconds */
1332 u16 enhanced_ps_transition_time; /* rem. wake time for Enh. PS */
1333 } __attribute__ ((packed)) acx100_ie_powersave_t;
1335 typedef struct acx111_ie_powersave {
1336 u16 type;
1337 u16 len;
1338 u8 wakeup_cfg;
1339 u8 listen_interval; /* for EACH_ITVL: wake up every "beacon units" interval */
1340 u8 options;
1341 u8 hangover_period; /* remaining wake time after Tx MPDU w/ PS bit, in values of 1/1024 seconds */
1342 u32 beacon_rx_time;
1343 u32 enhanced_ps_transition_time; /* rem. wake time for Enh. PS */
1344 } __attribute__ ((packed)) acx111_ie_powersave_t;
1347 /***********************************************************************
1348 ** Commands and template structures
1352 ** SCAN command structure
1354 ** even though acx100 scan rates match RATE100 constants,
1355 ** acx111 ones do not match! Therefore we do not use RATE100 #defines */
1356 #define ACX_SCAN_RATE_1 10
1357 #define ACX_SCAN_RATE_2 20
1358 #define ACX_SCAN_RATE_5 55
1359 #define ACX_SCAN_RATE_11 110
1360 #define ACX_SCAN_RATE_22 220
1361 #define ACX_SCAN_RATE_PBCC 0x80 /* OR with this if needed */
1362 #define ACX_SCAN_OPT_ACTIVE 0x00 /* a bit mask */
1363 #define ACX_SCAN_OPT_PASSIVE 0x01
1364 /* Background scan: we go into Power Save mode (by transmitting
1365 ** NULL data frame to AP with the power mgmt bit set), do the scan,
1366 ** and then exit Power Save mode. A plus is that AP buffers frames
1367 ** for us while we do background scan. Thus we avoid frame losses.
1368 ** Background scan can be active or passive, just like normal one */
1369 #define ACX_SCAN_OPT_BACKGROUND 0x02
1370 typedef struct acx100_scan {
1371 u16 count; /* number of scans to do, 0xffff == continuous */
1372 u16 start_chan;
1373 u16 flags; /* channel list mask; 0x8000 == all channels? */
1374 u8 max_rate; /* max. probe rate */
1375 u8 options; /* bit mask, see defines above */
1376 u16 chan_duration;
1377 u16 max_probe_delay;
1378 } __attribute__ ((packed)) acx100_scan_t; /* length 0xc */
1380 #define ACX111_SCAN_RATE_6 0x0B
1381 #define ACX111_SCAN_RATE_9 0x0F
1382 #define ACX111_SCAN_RATE_12 0x0A
1383 #define ACX111_SCAN_RATE_18 0x0E
1384 #define ACX111_SCAN_RATE_24 0x09
1385 #define ACX111_SCAN_RATE_36 0x0D
1386 #define ACX111_SCAN_RATE_48 0x08
1387 #define ACX111_SCAN_RATE_54 0x0C
1388 #define ACX111_SCAN_OPT_5GHZ 0x04 /* else 2.4GHZ */
1389 #define ACX111_SCAN_MOD_SHORTPRE 0x01 /* you can combine SHORTPRE and PBCC */
1390 #define ACX111_SCAN_MOD_PBCC 0x80
1391 #define ACX111_SCAN_MOD_OFDM 0x40
1392 typedef struct acx111_scan {
1393 u16 count; /* number of scans to do */
1394 u8 channel_list_select; /* 0: scan all channels, 1: from chan_list only */
1395 u16 reserved1;
1396 u8 reserved2;
1397 u8 rate; /* rate for probe requests (if active scan) */
1398 u8 options; /* bit mask, see defines above */
1399 u16 chan_duration; /* min time to wait for reply on one channel (in TU) */
1400 /* (active scan only) (802.11 section 11.1.3.2.2) */
1401 u16 max_probe_delay; /* max time to wait for reply on one channel (active scan) */
1402 /* time to listen on a channel (passive scan) */
1403 u8 modulation;
1404 u8 channel_list[26]; /* bits 7:0 first byte: channels 8:1 */
1405 /* bits 7:0 second byte: channels 16:9 */
1406 /* 26 bytes is enough to cover 802.11a */
1407 } __attribute__ ((packed)) acx111_scan_t;
1410 ** Radio calibration command structure
1412 typedef struct acx111_cmd_radiocalib {
1413 /* 0x80000000 == automatic calibration by firmware, according to interval;
1414 * bits 0..3: select calibration methods to go through:
1415 * calib based on DC, AfeDC, Tx mismatch, Tx equilization */
1416 u32 methods;
1417 u32 interval;
1418 } __attribute__ ((packed)) acx111_cmd_radiocalib_t;
1421 ** Packet template structures
1423 ** Packet templates store contents of Beacon, Probe response, Probe request,
1424 ** Null data frame, and TIM data frame. Firmware automatically transmits
1425 ** contents of template at appropriate time:
1426 ** - Beacon: when configured as AP or Ad-hoc
1427 ** - Probe response: when configured as AP or Ad-hoc, whenever
1428 ** a Probe request frame is received
1429 ** - Probe request: when host issues SCAN command (active)
1430 ** - Null data frame: when entering 802.11 power save mode
1431 ** - TIM data: at the end of Beacon frames (if no TIM template
1432 ** is configured, then transmits default TIM)
1433 ** NB:
1434 ** - size field must be set to size of actual template
1435 ** (NOT sizeof(struct) - templates are variable in length),
1436 ** size field is not itself counted.
1437 ** - members flagged with an asterisk must be initialized with host,
1438 ** rest must be zero filled.
1439 ** - variable length fields shown only in comments */
1440 typedef struct acx_template_tim {
1441 u16 size;
1442 u8 tim_eid; /* 00 1 TIM IE ID * */
1443 u8 len; /* 01 1 Length * */
1444 u8 dtim_cnt; /* 02 1 DTIM Count */
1445 u8 dtim_period; /* 03 1 DTIM Period */
1446 u8 bitmap_ctrl; /* 04 1 Bitmap Control * (except bit0) */
1447 /* 05 n Partial Virtual Bitmap * */
1448 u8 variable[0x100 - 1-1-1-1-1];
1449 } __attribute__ ((packed)) acx_template_tim_t;
1451 typedef struct acx_template_probereq {
1452 u16 size;
1453 u16 fc; /* 00 2 fc * */
1454 u16 dur; /* 02 2 Duration */
1455 u8 da[6]; /* 04 6 Destination Address * */
1456 u8 sa[6]; /* 0A 6 Source Address * */
1457 u8 bssid[6]; /* 10 6 BSSID * */
1458 u16 seq; /* 16 2 Sequence Control */
1459 /* 18 n SSID * */
1460 /* nn n Supported Rates * */
1461 u8 variable[0x44 - 2-2-6-6-6-2];
1462 } __attribute__ ((packed)) acx_template_probereq_t;
1464 typedef struct acx_template_proberesp {
1465 u16 size;
1466 u16 fc; /* 00 2 fc * (bits [15:12] and [10:8] per 802.11 section 7.1.3.1) */
1467 u16 dur; /* 02 2 Duration */
1468 u8 da[6]; /* 04 6 Destination Address */
1469 u8 sa[6]; /* 0A 6 Source Address */
1470 u8 bssid[6]; /* 10 6 BSSID */
1471 u16 seq; /* 16 2 Sequence Control */
1472 u8 timestamp[8];/* 18 8 Timestamp */
1473 u16 beacon_interval; /* 20 2 Beacon Interval * */
1474 u16 cap; /* 22 2 Capability Information * */
1475 /* 24 n SSID * */
1476 /* nn n Supported Rates * */
1477 /* nn 1 DS Parameter Set * */
1478 u8 variable[0x54 - 2-2-6-6-6-2-8-2-2];
1479 } __attribute__ ((packed)) acx_template_proberesp_t;
1480 #define acx_template_beacon_t acx_template_proberesp_t
1481 #define acx_template_beacon acx_template_proberesp
1483 typedef struct acx_template_nullframe {
1484 u16 size;
1485 struct ieee80211_hdr hdr;
1486 } __attribute__ ((packed)) acx_template_nullframe_t;
1490 ** JOIN command structure
1492 ** as opposed to acx100, acx111 dtim interval is AFTER rates_basic111.
1493 ** NOTE: took me about an hour to get !@#$%^& packing right --> struct packing is eeeeevil... */
1494 typedef struct acx_joinbss {
1495 u8 bssid[ETH_ALEN];
1496 u16 beacon_interval;
1497 union {
1498 struct {
1499 u8 dtim_interval;
1500 u8 rates_basic;
1501 u8 rates_supported;
1502 } __attribute__ ((packed)) acx100;
1503 struct {
1504 u16 rates_basic;
1505 u8 dtim_interval;
1506 } __attribute__ ((packed)) acx111;
1507 } __attribute__ ((packed)) u;
1508 u8 genfrm_txrate; /* generated frame (bcn, proberesp, RTS, PSpoll) tx rate */
1509 u8 genfrm_mod_pre; /* generated frame modulation/preamble:
1510 ** bit7: PBCC, bit6: OFDM (else CCK/DQPSK/DBPSK)
1511 ** bit5: short pre */
1512 u8 macmode; /* BSS Type, must be one of ACX_MODE_xxx */
1513 u8 channel;
1514 u8 essid_len;
1515 char essid[IW_ESSID_MAX_SIZE];
1516 } __attribute__ ((packed)) acx_joinbss_t;
1518 #define JOINBSS_RATES_1 0x01
1519 #define JOINBSS_RATES_2 0x02
1520 #define JOINBSS_RATES_5 0x04
1521 #define JOINBSS_RATES_11 0x08
1522 #define JOINBSS_RATES_22 0x10
1524 /* Looks like missing bits are used to indicate 11g rates!
1525 ** (it follows from the fact that constants below match 1:1 to RATE111_nn)
1526 ** This was actually seen! Look at that Assoc Request sent by acx111,
1527 ** it _does_ contain 11g rates in basic set:
1528 01:30:20.070772 Beacon (xxx) [1.0* 2.0* 5.5* 11.0* 6.0* 9.0* 12.0* 18.0* 24.0* 36.0* 48.0* 54.0* Mbit] ESS CH: 1
1529 01:30:20.074425 Authentication (Open System)-1: Succesful
1530 01:30:20.076539 Authentication (Open System)-2:
1531 01:30:20.076620 Acknowledgment
1532 01:30:20.088546 Assoc Request (xxx) [1.0* 2.0* 5.5* 6.0* 9.0* 11.0* 12.0* 18.0* 24.0* 36.0* 48.0* 54.0* Mbit]
1533 01:30:20.122413 Assoc Response AID(1) :: Succesful
1534 01:30:20.122679 Acknowledgment
1535 01:30:20.173204 Beacon (xxx) [1.0* 2.0* 5.5* 11.0* 6.0* 9.0* 12.0* 18.0* 24.0* 36.0* 48.0* 54.0* Mbit] ESS CH: 1
1537 #define JOINBSS_RATES_BASIC111_1 0x0001
1538 #define JOINBSS_RATES_BASIC111_2 0x0002
1539 #define JOINBSS_RATES_BASIC111_5 0x0004
1540 #define JOINBSS_RATES_BASIC111_11 0x0020
1541 #define JOINBSS_RATES_BASIC111_22 0x0100
1544 /***********************************************************************
1546 typedef struct mem_read_write {
1547 u16 addr;
1548 u16 type; /* 0x0 int. RAM / 0xffff MAC reg. / 0x81 PHY RAM / 0x82 PHY reg.; or maybe it's actually 0x30 for MAC? Better verify it by writing and reading back and checking whether the value holds! */
1549 u32 len;
1550 u32 data;
1551 } __attribute__ ((packed)) mem_read_write_t;
1553 typedef struct firmware_image {
1554 u32 chksum;
1555 u32 size;
1556 u8 data[1]; /* the byte array of the actual firmware... */
1557 } __attribute__ ((packed)) firmware_image_t;
1559 typedef struct acx_cmd_radioinit {
1560 u32 offset;
1561 u32 len;
1562 } __attribute__ ((packed)) acx_cmd_radioinit_t;
1564 typedef struct acx100_ie_wep_options {
1565 u16 type;
1566 u16 len;
1567 u16 NumKeys; /* max # of keys */
1568 u8 WEPOption; /* 0 == decrypt default key only, 1 == override decrypt */
1569 u8 Pad; /* used only for acx111 */
1570 } __attribute__ ((packed)) acx100_ie_wep_options_t;
1572 typedef struct ie_dot11WEPDefaultKey {
1573 u16 type;
1574 u16 len;
1575 u8 action;
1576 u8 keySize;
1577 u8 defaultKeyNum;
1578 u8 key[29]; /* check this! was Key[19] */
1579 } __attribute__ ((packed)) ie_dot11WEPDefaultKey_t;
1581 typedef struct acx111WEPDefaultKey {
1582 u8 MacAddr[ETH_ALEN];
1583 u16 action; /* NOTE: this is a u16, NOT a u8!! */
1584 u16 reserved;
1585 u8 keySize;
1586 u8 type;
1587 u8 index;
1588 u8 defaultKeyNum;
1589 u8 counter[6];
1590 u8 key[32]; /* up to 32 bytes (for TKIP!) */
1591 } __attribute__ ((packed)) acx111WEPDefaultKey_t;
1593 typedef struct ie_dot11WEPDefaultKeyID {
1594 u16 type;
1595 u16 len;
1596 u8 KeyID;
1597 } __attribute__ ((packed)) ie_dot11WEPDefaultKeyID_t;
1599 typedef struct acx100_cmd_wep_mgmt {
1600 u8 MacAddr[ETH_ALEN];
1601 u16 Action;
1602 u16 KeySize;
1603 u8 Key[29]; /* 29*8 == 232bits == WEP256 */
1604 } __attribute__ ((packed)) acx100_cmd_wep_mgmt_t;
1606 typedef struct acx_ie_generic {
1607 u16 type;
1608 u16 len;
1609 union {
1610 /* Association ID IE: just a 16bit value: */
1611 u16 aid;
1612 /* generic member for quick implementation of commands */
1613 u8 bytes[32];
1614 } __attribute__ ((packed)) m;
1615 } __attribute__ ((packed)) acx_ie_generic_t;
1617 #define ACX_SEC_KEYSIZE 16
1618 /* Security algorithms. */
1619 enum {
1620 ACX_SEC_ALG,
1621 ACX_SEC_ALGO_NONE = 0, /* unencrypted, as of TX header. */
1622 ACX_SEC_ALGO_WEP,
1623 ACX_SEC_ALGO_UNKNOWN,
1624 ACX_SEC_ALGO_AES,
1625 ACX_SEC_ALGO_WEP104,
1626 ACX_SEC_ALGO_TKIP,
1628 /***********************************************************************
1630 #define CHECK_SIZEOF(type,size) { \
1631 extern void BUG_bad_size_for_##type(void); \
1632 if (sizeof(type)!=(size)) BUG_bad_size_for_##type(); \
1635 static inline void
1636 acx_struct_size_check(void)
1638 CHECK_SIZEOF(txdesc_t, 0x30);
1639 CHECK_SIZEOF(acx100_ie_memconfigoption_t, 24);
1640 CHECK_SIZEOF(acx100_ie_queueconfig_t, 0x20);
1641 CHECK_SIZEOF(acx_joinbss_t, 0x30);
1642 /* IEs need 4 bytes for (type,len) tuple */
1643 CHECK_SIZEOF(acx111_ie_configoption_t, ACX111_IE_CONFIG_OPTIONS_LEN + 4);
1647 /***********************************************************************
1648 ** Global data
1650 extern const u8 acx_bitpos2ratebyte[];
1651 extern const u8 acx_bitpos2rate100[];
1653 extern const u8 acx_reg_domain_ids[];
1654 extern const char * const acx_reg_domain_strings[];
1655 enum {
1656 acx_reg_domain_ids_len = 8
1659 //extern const struct iw_handler_def acx_ioctl_handler_def;
1661 #endif /* _ACX_STRUCT_H_ */