acx_struct.h: simplify the IS_PCI/IS_USB macros
[acx-mac80211.git] / acxusb.h
blob4074c3ca7008dcbc47709a5432524df7c02f21f7
1 #ifndef _ACXUSB_H_
2 #define _ACXUSB_H_
4 /*
5 * acxusb.h: USB specific constants and structures.
7 * Copyright (c) 2008 Francis Galiegue <fgaliegue@gmail.com> for the ACX100
8 * driver project.
10 * This file is licensed under the GPLv2. See the README file for details.
12 /* Used for usb_txbuffer.desc field */
13 #define USB_TXBUF_TXDESC 0xA
14 /* Size of header (everything up to data[]) */
15 #define USB_TXBUF_HDRSIZE 14
16 typedef struct usb_txbuffer {
17 u16 desc;
18 u16 mpdu_len;
19 u8 queue_index;
20 u8 rate;
21 u32 hostdata;
22 u8 ctrl1;
23 u8 ctrl2;
24 u16 data_len;
25 /* wlan packet content is placed here: */
26 u8 data[30 + 2312 + 4]; /*WLAN_A4FR_MAXLEN_WEP_FCS]*/
27 } __attribute__ ((packed)) usb_txbuffer_t;
29 /* USB returns either rx packets (see rxbuffer) or
30 ** these "tx status" structs: */
31 typedef struct usb_txstatus {
32 u16 mac_cnt_rcvd; /* only 12 bits are len! (0xfff) */
33 u8 queue_index;
34 u8 mac_status; /* seen 0x20 on tx failure */
35 u32 hostdata;
36 u8 rate;
37 u8 ack_failures;
38 u8 rts_failures;
39 u8 rts_ok;
40 // struct ieee80211_tx_status txstatus;
41 // struct sk_buff *skb;
42 } __attribute__ ((packed)) usb_txstatus_t;
44 typedef struct usb_tx {
45 unsigned busy:1;
46 struct urb *urb;
47 acx_device_t *adev;
48 /* actual USB bulk output data block is here: */
49 usb_txbuffer_t bulkout;
50 } usb_tx_t;
52 struct usb_rx_plain {
53 unsigned busy:1;
54 struct urb *urb;
55 acx_device_t *adev;
56 rxbuffer_t bulkin;
59 typedef struct usb_rx {
60 unsigned busy:1;
61 struct urb *urb;
62 acx_device_t *adev;
63 rxbuffer_t bulkin;
64 /* Make entire structure 4k */
65 u8 padding[4*1024 - sizeof(struct usb_rx_plain)];
66 } usb_rx_t;
68 #if 0
69 struct acx_device {
70 /* most frequent accesses first (dereferencing and cache line!) */
73 * Locking
75 struct mutex mutex;
76 spinlock_t spinlock;
77 spinlock_t irqlock;
79 * IRQ handling
81 /* The IRQ we have inherited */
82 unsigned int irq;
83 /* Are IRQs currently activated? FIXME: should get rid of this */
84 u8 irqs_active;
85 /* The interrupts we can acknowledge (see acx_irq.h) */
86 u16 irq_mask;
87 /* The mask of IRQs saved by the IRQ top half routine */
88 u16 irq_saved_mask;
90 * FIXME: these ones should disappear
92 unsigned int irq_loops_this_jiffy;
93 unsigned long irq_last_jiffies;
94 /* Barely used in USB case (FIXME?) */
95 u16 irq_status;
96 int irq_reason; /* FIXME: should be u16 */
97 /* Mask of jobs we have to schedule post interrupt */
98 u8 after_interrupt_jobs;
99 /*
100 * Work queue for the bottom half. FIXME: only one, consider a
101 * delayed_work struct some day?
103 struct work_struct after_interrupt_task;
104 #if defined(PARANOID_LOCKING) /* Lock debugging */
105 const char *last_sem;
106 const char *last_lock;
107 unsigned long sem_time;
108 unsigned long lock_time;
109 #endif
111 /*** Linux network device ***/
112 //struct device *dev; /* pointer to linux netdevice */
114 /*** Device statistics ***/
115 struct ieee80211_low_level_stats ieee_stats; /* wireless device statistics */
117 /*** Device statistics ***/
118 struct net_device_stats stats; /* net device statistics */
120 #ifdef WIRELESS_EXT
121 // struct iw_statistics wstats; /* wireless statistics */
122 #endif
123 struct ieee80211_hw *ieee;
124 struct ieee80211_hw_mode modes[2];
125 struct ieee80211_rx_status rx_status;
127 struct ieee80211_vif *vif;
129 /*** Power managment ***/
130 struct pm_dev *pm; /* PM crap */
132 /*** Management timer ***/
133 struct timer_list mgmt_timer;
135 /*** Hardware identification ***/
136 const char *chip_name;
137 u8 dev_type;
138 u8 chip_type;
139 u8 form_factor;
140 u8 radio_type;
141 u8 eeprom_version;
143 /*** Config retrieved from EEPROM ***/
144 char cfgopt_NVSv[8];
145 u16 cfgopt_NVS_vendor_offs;
146 u8 cfgopt_MAC[6];
147 u16 cfgopt_probe_delay;
148 u32 cfgopt_eof_memory;
149 u8 cfgopt_dot11CCAModes;
150 u8 cfgopt_dot11Diversity;
151 u8 cfgopt_dot11ShortPreambleOption;
152 u8 cfgopt_dot11PBCCOption;
153 u8 cfgopt_dot11ChannelAgility;
154 u8 cfgopt_dot11PhyType;
155 u8 cfgopt_dot11TempType;
156 co_antennas_t cfgopt_antennas;
157 co_powerlevels_t cfgopt_power_levels;
158 co_datarates_t cfgopt_data_rates;
159 co_domains_t cfgopt_domains;
160 co_product_id_t cfgopt_product_id;
161 co_manuf_t cfgopt_manufacturer;
163 /*** Firmware identification ***/
164 char firmware_version[FW_ID_SIZE+1];
165 u32 firmware_numver;
166 u32 firmware_id;
167 const u16 *ie_len;
168 const u16 *ie_len_dot11;
170 /*** Device state ***/
171 u16 dev_state_mask;
172 u8 led_power; /* power LED status */
173 u32 get_mask; /* mask of settings to fetch from the card */
174 u32 set_mask; /* mask of settings to write to the card */
175 u32 initialized:1;
178 /*** scanning ***/
179 u16 scan_count; /* number of times to do channel scan */
180 u8 scan_mode; /* 0 == active, 1 == passive, 2 == background */
181 u8 scan_rate;
182 u16 scan_duration;
183 u16 scan_probe_delay;
184 #if WIRELESS_EXT > 15
185 // struct iw_spy_data spy_data; /* FIXME: needs to be implemented! */
186 #endif
188 /*** Virtual interface struct ***/
189 struct acx_interface interface;
191 /*** Wireless network settings ***/
192 /* copy of the device address (ifconfig hw ether) that we actually use
193 ** for 802.11; copied over from the network device's MAC address
194 ** (ifconfig) when it makes sense only */
195 u8 dev_addr[MAX_ADDR_LEN];
196 u8 bssid[ETH_ALEN]; /* the BSSID after having joined */
197 u8 ap[ETH_ALEN]; /* The AP we want, FF:FF:FF:FF:FF:FF is any */
198 u16 aid; /* The Association ID sent from the AP / last used AID if we're an AP */
199 u16 mode; /* mode from iwconfig */
200 int monitor_type; /* ARPHRD_IEEE80211 or ARPHRD_IEEE80211_PRISM */
201 u16 status; /* 802.11 association status */
202 u8 essid_active; /* specific ESSID active, or select any? */
203 u8 essid_len; /* to avoid dozens of strlen() */
204 /* INCLUDES \0 termination for easy printf - but many places
205 ** simply want the string data memcpy'd plus a length indicator!
206 ** Keep that in mind... */
207 char essid[IW_ESSID_MAX_SIZE+1];
208 /* essid we are going to use for association, in case of "essid 'any'"
209 ** and in case of hidden ESSID (use configured ESSID then) */
210 char essid_for_assoc[IW_ESSID_MAX_SIZE+1];
211 char nick[IW_ESSID_MAX_SIZE+1]; /* see essid! */
212 u8 channel;
213 u8 reg_dom_id; /* reg domain setting */
214 u16 reg_dom_chanmask;
215 u16 auth_or_assoc_retries;
216 u16 scan_retries;
217 unsigned long scan_start; /* YES, jiffies is defined as "unsigned long" */
220 /* MAC80211 Template Reference */
221 struct sk_buff *beacon_cache;
222 /* stations known to us (if we're an ap) */
223 // client_t sta_list[32]; /* tab is larger than list, so that */
224 // client_t *sta_hash_tab[64]; /* hash collisions are not likely */
225 // client_t *ap_client; /* this one is our AP (STA mode only) */
227 int dup_count;
228 int nondup_count;
229 unsigned long dup_msg_expiry;
230 u16 last_seq_ctrl; /* duplicate packet detection */
232 /* 802.11 power save mode */
233 u8 ps_wakeup_cfg;
234 u8 ps_listen_interval;
235 u8 ps_options;
236 u8 ps_hangover_period;
237 u32 ps_enhanced_transition_time;
238 u32 ps_beacon_rx_time;
240 /*** PHY settings ***/
241 u8 fallback_threshold;
242 u8 stepup_threshold;
243 u16 rate_basic;
244 u16 rate_oper;
245 u16 rate_bcast;
246 u16 rate_bcast100;
247 u8 rate_auto; /* false if "iwconfig rate N" (WITHOUT 'auto'!) */
248 u8 preamble_mode; /* 0 == Long Preamble, 1 == Short, 2 == Auto */
249 u8 preamble_cur;
251 u8 tx_disabled;
252 u8 tx_level_dbm;
253 /* u8 tx_level_val; */
254 /* u8 tx_level_auto; whether to do automatic power adjustment */
256 unsigned long recalib_time_last_success;
257 unsigned long recalib_time_last_attempt;
258 int recalib_failure_count;
259 int recalib_msg_ratelimit;
260 int retry_errors_msg_ratelimit;
262 unsigned long brange_time_last_state_change; /* time the power LED was last changed */
263 u8 brange_last_state; /* last state of the LED */
264 u8 brange_max_quality; /* maximum quality that equates to full speed */
266 u8 sensitivity;
267 u8 antenna; /* antenna settings */
268 u8 ed_threshold; /* energy detect threshold */
269 u8 cca; /* clear channel assessment */
271 u16 rts_threshold;
272 u16 frag_threshold;
273 u32 short_retry;
274 u32 long_retry;
275 u16 msdu_lifetime;
276 u16 listen_interval; /* given in units of beacon interval */
277 u32 beacon_interval;
279 u16 capabilities;
280 u8 rate_supported_len;
281 u8 rate_supported[13];
283 /*** Encryption settings (WEP) ***/
284 u32 auth_alg; /* used in transmit_authen1 */
285 u8 wep_enabled;
286 u8 wep_restricted;
287 u8 wep_current_index;
288 wep_key_t wep_keys[DOT11_MAX_DEFAULT_WEP_KEYS]; /* the default WEP keys */
290 key_struct_t wep_key_struct[10];
292 /*** Encryption Replacement for mac80211 ***/
293 struct acx_key key[54];
294 u16 security_offset;
295 u8 default_key_idx;
298 /*** Unknown ***/
299 u8 dtim_interval;
301 /*** Card Rx/Tx management ***/
302 u16 rx_config_1;
303 u16 rx_config_2;
304 u16 memblocksize;
305 unsigned int tx_free;
306 unsigned int tx_head; /* keep as close as possible to Tx stuff below (cache line) */
307 u16 phy_header_len;
310 * Bus specific (USB here) stuff.
313 /* hack to let common code compile. FIXME */
314 dma_addr_t rxhostdesc_startphy;
316 struct usb_device *usbdev;
318 rxbuffer_t rxtruncbuf;
320 usb_tx_t *usb_tx;
321 usb_rx_t *usb_rx;
323 int bulkinep; /* bulk-in endpoint */
324 int bulkoutep; /* bulk-out endpoint */
325 int rxtruncsize;
328 #endif
330 #endif /* _ACXUSB_H_ */