Original 0.2.0pre8_plus_fixes_12 tarball
[acx-mac80211.git] / include / acx100_helper.h
blob3cc8fa474716230a05079ed9fd29412667f4bfc5
1 /* include/acx100_helper.h
3 * --------------------------------------------------------------------
5 * Copyright (C) 2003 ACX100 Open Source Project
7 * The contents of this file are subject to the Mozilla Public
8 * License Version 1.1 (the "License"); you may not use this file
9 * except in compliance with the License. You may obtain a copy of
10 * the License at http://www.mozilla.org/MPL/
12 * Software distributed under the License is distributed on an "AS
13 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
14 * implied. See the License for the specific language governing
15 * rights and limitations under the License.
17 * Alternatively, the contents of this file may be used under the
18 * terms of the GNU Public License version 2 (the "GPL"), in which
19 * case the provisions of the GPL are applicable instead of the
20 * above. If you wish to allow the use of your version of this file
21 * only under the terms of the GPL and not to allow others to use
22 * your version of this file under the MPL, indicate your decision
23 * by deleting the provisions above and replace them with the notice
24 * and other provisions required by the GPL. If you do not delete
25 * the provisions above, a recipient may use your version of this
26 * file under either the MPL or the GPL.
28 * --------------------------------------------------------------------
30 * Inquiries regarding the ACX100 Open Source Project can be
31 * made directly to:
33 * acx100-users@lists.sf.net
34 * http://acx100.sf.net
36 * --------------------------------------------------------------------
38 #ifndef __ACX_ACX100_HELPER_H
39 #define __ACX_ACX100_HELPER_H
41 #define ISTATUS_0_STARTED 0
42 #define ISTATUS_1_SCANNING 1
43 #define ISTATUS_2_WAIT_AUTH 2
44 #define ISTATUS_3_AUTHENTICATED 3
45 #define ISTATUS_4_ASSOCIATED 4
46 #define ISTATUS_5_UNKNOWN 5
50 /* a helper struct for quick implementation of commands */
51 typedef struct GenericPacket {
52 UINT8 bytes[32];
53 } GenericPacket_t;
56 typedef struct acx100_memmap {
57 UINT16 rid;
58 UINT16 len;
59 UINT32 CodeStart;
60 UINT32 CodeEnd;
61 UINT32 WEPCacheStart;
62 UINT32 WEPCacheEnd;
63 UINT32 PacketTemplateStart;
64 UINT32 PacketTemplateEnd;
65 UINT32 QueueStart;
66 UINT32 QueueEnd;
67 UINT32 PoolStart;
68 UINT32 PoolEnd;
69 } acx100_memmap_t;
71 typedef struct acx100_memconfigoption {
72 UINT16 rid;
73 UINT16 len;
74 UINT32 DMA_config;
75 UINT32 pRxHostDesc; /* val0x8 */
76 UINT32 rx_mem;
77 UINT32 tx_mem;
78 UINT16 TxBlockNum;
79 UINT16 RxBlockNum;
80 } acx100_memconfigoption_t;
83 typedef struct QueueConfig {
84 UINT16 rid; /* rid */
85 UINT16 len; /* length */
86 UINT32 AreaSize;
87 UINT32 RxQueueStart;
88 UINT8 QueueOptions; /* queue options, val0xd */
89 UINT8 NumTxQueues; /* # tx queues, val0xe */
90 UINT8 NumRxDesc; /* for USB only */
91 UINT8 padf2; /* # rx buffers */
92 UINT32 QueueEnd;
93 UINT32 HostQueueEnd; /* QueueEnd2*/
94 UINT32 TxQueueStart;
95 UINT8 TxQueuePri;
96 UINT8 NumTxDesc;
97 UINT16 pad;
98 } QueueConfig_t;
100 typedef struct ACX111QueueConfig {
102 UINT16 type;
103 UINT16 length;
104 UINT32 tx_memory_block_address;
105 UINT32 rx_memory_block_address;
106 UINT32 rx1_queue_address;
107 UINT32 reserved1;
108 UINT32 tx1_queue_address;
109 UINT8 tx1_attributes;
110 UINT16 reserved2;
111 UINT8 reserved3;
113 } __WLAN_ATTRIB_PACK__ ACX111QueueConfig_t;
115 typedef struct ACX111MemoryConfig {
117 UINT16 type;
118 UINT16 length;
119 UINT16 no_of_stations;
120 UINT16 memory_block_size;
121 UINT8 tx_rx_memory_block_allocation;
122 UINT8 count_rx_queues;
123 UINT8 count_tx_queues;
124 UINT8 options;
125 UINT8 fragmentation;
126 UINT16 reserved1;
127 UINT8 reserved2;
129 /* start of rx1 block */
130 UINT8 rx_queue1_count_descs;
131 UINT8 rx_queue1_reserved1;
132 UINT8 rx_queue1_reserved2; /* must be set to 7 */
133 UINT8 rx_queue1_reserved3; /* must be set to 0 */
134 UINT32 rx_queue1_host_rx_start;
135 /* end of rx1 block */
137 /* start of tx1 block */
138 UINT8 tx_queue1_count_descs;
139 UINT8 tx_queue1_reserved1;
140 UINT8 tx_queue1_reserved2;
141 UINT8 tx_queue1_attributes;
142 /* end of tx1 block */
144 } __WLAN_ATTRIB_PACK__ ACX111MemoryConfig_t;
146 #if MAYBE_BOGUS
147 typedef struct wep {
148 UINT16 vala;
150 UINT8 wep_key[MAX_KEYLEN];
151 char key_name[0x16];
152 } wep_t;
153 #endif
155 typedef struct associd {
156 UINT16 vala;
157 } associd_t;
159 #define PS_CFG_ENABLE 0x80
160 #define PS_CFG_PENDING 0x40 /* status flag when entering PS */
161 #define PS_CFG_WAKEUP_MODE_MASK 0x07
162 #define PS_CFG_WAKEUP_BY_HOST 0x03
163 #define PS_CFG_WAKEUP_EACH_ITVL 0x02
164 #define PS_CFG_WAKEUP_ON_DTIM 0x01
165 #define PS_CFG_WAKEUP_ALL_BEAC 0x00
167 #define PS_OPT_ENA_ENHANCED_PS 0x04 /* Enhanced PS mode: sleep until Rx Beacon w/ the STA's AID bit set in the TIM; newer firmwares only(?) */
168 #define PS_OPT_STILL_RCV_BCASTS 0x01
170 typedef struct acx100_powermgmt {
171 UINT32 rid;
172 UINT32 len;
173 UINT8 wakeup_cfg;
174 UINT8 listen_interval; /* for EACH_ITVL: wake up every "beacon units" interval */
175 UINT8 options;
176 UINT8 hangover_period; /* remaining wake time after Tx MPDU w/ PS bit, in values of 1/1024 seconds */
177 UINT16 enhanced_ps_transition_time; /* rem. wake time for Enh. PS */
178 } acx100_powermgmt_t;
180 typedef struct acx111_powermgmt {
181 UINT32 rid;
182 UINT32 len;
183 UINT8 wakeup_cfg;
184 UINT8 listen_interval; /* for EACH_ITVL: wake up every "beacon units" interval */
185 UINT8 options;
186 UINT8 hangover_period; /* remaining wake time after Tx MPDU w/ PS bit, in values of 1/1024 seconds */
187 UINT32 beaconRxTime;
188 UINT32 enhanced_ps_transition_time; /* rem. wake time for Enh. PS */
189 } acx111_powermgmt_t;
191 typedef struct defaultkey {
192 UINT8 num;
193 } defaultkey_t;
195 typedef struct memmap {
196 UINT16 type;
197 UINT16 length;
198 union data {
199 struct GenericPacket gp;
200 /* struct wep wp; */
201 struct associd asid;
202 struct defaultkey dkey;
203 } m;
204 } memmap_t;
206 typedef struct sub3info {
207 UINT8 size;
208 UINT8 buf[0x4];
209 } sub3info_t;
211 typedef struct subsubinfo {
212 UINT8 size;
213 struct sub3info buf;
214 } subsubinfo_t;
216 typedef struct subinfo {
217 UINT16 size;
218 char buf[0x8];
219 struct subsubinfo buf2;
220 char buf3[0x8];
221 } subinfo_t;
223 typedef struct beaconinfo {
224 UINT16 size;
225 UINT16 status;
226 UINT8 addr1[0x6];
227 UINT8 addr2[0x6];
228 UINT8 addr3[0x6];
229 struct subinfo inf;
230 UINT8 buf[0x1c];
231 } beaconinfo_t;
233 typedef struct beacon {
234 UINT16 size;
235 struct beaconinfo inf;
236 /* UINT16 vala; */
237 } beacon_t;
239 #define ACX_SCAN_ACTIVE 0
240 #define ACX_SCAN_PASSIVE 1
241 #define ACX_SCAN_BACKGROUND 2
243 typedef struct scan {
244 UINT16 count; /* number of scans to do, 0xffff == continuous */
245 UINT16 start_chan;
246 UINT16 flags; /* channel list mask; 0x8000 == all channels? */
247 UINT8 max_rate; /* max. probe rate */
248 UINT8 options; /* scan mode: 0 == active, 1 == passive, 2 == background */
249 UINT16 chan_duration;
250 UINT16 max_probe_delay;
251 } scan_t; /* length 0xc */
253 typedef struct acx111_scan {
254 UINT16 count; /* number of scans to do */
255 UINT8 channel_list_select;
256 UINT16 reserved1;
257 UINT8 reserved2;
258 UINT8 rate;
259 UINT8 options;
260 UINT16 chan_duration;
261 UINT16 max_probe_delay;
262 UINT8 modulation;
263 UINT8 channel_list[26];
264 } __WLAN_ATTRIB_PACK__ acx111_scan_t;
267 typedef struct tim {
268 UINT16 size;
269 UINT8 buf[0x100];
270 } tim_t;
272 typedef struct proberesp {
273 UINT16 size;
274 char buf[0x54];
275 } __WLAN_ATTRIB_PACK__ proberesp_t;
277 typedef struct probereq {
278 UINT16 size;
279 char buf[0x44];
280 } __WLAN_ATTRIB_PACK__ probereq_t;
282 typedef struct joinbss {
283 UINT8 bssid[ETH_ALEN];
284 UINT16 beacon_interval;
285 UINT8 dtim_interval;
286 UINT8 rates_basic;
287 UINT8 rates_supported;
288 UINT8 txrate_val;
289 UINT8 preamble_type;
290 UINT8 macmode;
291 UINT8 channel;
292 UINT8 essid_len;
293 char essid[IW_ESSID_MAX_SIZE];
294 } __WLAN_ATTRIB_PACK__ joinbss_t; /* ACX100 specific join struct */
297 * I am temporarily redefining this because the above struct is somewhat wrong.
299 * NOTE: this is a generic struct for all sorts of different packet types.
300 * As such I guess that someone got confused about structure layout.
301 * In other words: it always has an "official" packet header (A4?)
302 * and then a custom packet body.
303 * The current form is probably a bit sub-optimal. However let's keep it
304 * for now and then redefine it later. Or maybe change it now to have a
305 * better struct layout for all sorts of management packets?
307 typedef struct acxp80211_hdr {
308 p80211_hdr_a3_t a4;
309 UINT8 val0x18[8]; /* this contains the Logical Link Control data
310 the first three bytes are the dsap, ssap and control
311 respectively. the following 3 bytes are either ieee_oui
312 or an RFC. See p80211conv.c/h for more. */
313 UINT16 beacon_interval;
314 UINT16 caps;
315 UINT8 info[0x30]; /* 0x24 */
317 * info[1] is essid_len
318 * &info[2] is essid (max. 32 chars)
319 * FIXME: huh, then sizeof(info) == 0x18 cannot be correct! Adjusting
320 * to 0x30, which extends to end of this struct
322 /* p80211_hdr_a4_t b4; */
323 } acxp80211_hdr_t; /* size: 0x54 */
325 /* struct used for Beacon and for Probe Response frames */
326 typedef struct acxp80211_beacon_prb_resp {
327 p80211_hdr_a3_t hdr; /* 24 Bytes */
328 UINT8 timestamp[8]; /* 8 Bytes */
329 UINT16 beacon_interval; /* 2 Bytes */
330 UINT16 caps; /* 2 Bytes */
331 UINT8 info[48]; /* 48 Bytes */
332 #if INFO_CONSISTS_OF
333 UINT8 ssid[1+1+IW_ESSID_MAX_SIZE]; /* 34 Bytes */
334 UINT8 supp_rates[1+1+8]; /* 10 Bytes */
335 UINT8 ds_parms[1+1+1]; /* 3 Bytes */
336 UINT8 filler; /* 1 Byte alignment filler */
337 #endif
338 } acxp80211_beacon_prb_resp_t;
340 typedef struct acxp80211_packet {
341 UINT16 size; /* packet len indicator for firmware */
342 struct acxp80211_hdr hdr; /* actual packet */
343 } acxp80211_packet_t; /* size: 0x56 */
345 typedef struct {
346 UINT16 addr;
347 UINT16 type; /* 0x0 int. RAM / 0xffff MAC reg. / 0x81 PHY RAM / 0x82 PHY reg. */
348 UINT32 len;
349 UINT8 data[256];
350 } mem_read_write_t;
352 typedef struct acxp80211_beacon_prb_resp_template {
353 UINT16 size; /* packet len indicator for firmware */
354 struct acxp80211_beacon_prb_resp pkt;
355 } acxp80211_beacon_prb_resp_template_t;
357 typedef struct acxp80211_nullframe {
358 UINT16 size;
359 struct p80211_hdr_a3 hdr;
360 } acxp80211_nullframe_t;
362 typedef struct {
363 UINT32 chksum;
364 UINT32 size;
365 UINT8 data[1]; /* the byte array of the actual firmware... */
366 } firmware_image_t;
368 typedef struct {
369 UINT32 offset;
370 UINT32 len;
371 } radioinit_t;
374 typedef struct acx100_wep_options {
375 UINT16 rid;
376 UINT16 len;
377 UINT16 NumKeys; /* max # of keys */
378 UINT8 WEPOption;
379 UINT8 Pad; /* used only for acx111 */
380 } acx100_wep_options_t;
382 typedef struct dot11WEPDefaultKey {
383 UINT16 rid;
384 UINT16 len;
385 UINT8 Action;
386 UINT8 KeySize;
387 UINT8 defaultKeyNum;
388 UINT8 Key[29]; /* check this! was Key[19]. */
389 } dot11WEPDefaultKey_t;
391 typedef struct dot11WEPDefaultKeyID {
392 UINT16 rid;
393 UINT16 len;
394 UINT8 KeyID;
395 } dot11WEPDefaultKeyID_t;
397 typedef struct acx100_wep_mgmt {
398 UINT8 MacAddr[ETH_ALEN];
399 UINT16 Action;
400 UINT16 KeySize;
401 UINT8 Key[29]; /* 29*8 == 232bits == WEP256 */
402 } acx100_wep_mgmt_t;
407 void acx100_schedule(long timeout);
408 int acx100_reset_dev(netdevice_t *dev);
409 void acx100_join_bssid(wlandevice_t *priv);
410 int acx100_init_mac(netdevice_t *dev, UINT16 init);
411 int acx100_set_defaults(wlandevice_t *priv);
412 void acx100_set_reg_domain(wlandevice_t *priv, unsigned char reg_dom_id);
413 int acx100_set_probe_response_template(wlandevice_t *priv);
414 int acx100_set_beacon_template(wlandevice_t *priv);
415 void acx100_set_timer(wlandevice_t *priv, UINT32 time);
416 void acx100_update_capabilities(wlandevice_t *priv);
417 UINT16 acx100_read_eeprom_offset(wlandevice_t *priv, UINT16 addr,
418 UINT8 *charbuf);
419 UINT16 acx100_read_eeprom_area(wlandevice_t *priv);
420 UINT16 acx100_write_eeprom_offset(wlandevice_t *priv, UINT16 addr,
421 UINT16 len, UINT8 *charbuf);
422 UINT16 acx100_read_phy_reg(wlandevice_t *priv, UINT16 reg, UINT8 *charbuf);
423 UINT16 acx100_write_phy_reg(wlandevice_t *priv, UINT16 reg, UINT8 value);
424 void acx100_start(wlandevice_t *priv);
425 void acx100_reset_mac(wlandevice_t *priv);
426 int acx100_check_file(const char *file);
427 /*@null@*/ firmware_image_t *acx_read_fw( const char *file, UINT32 *size);
428 int acx100_upload_fw(wlandevice_t *priv);
429 int acx100_write_fw(wlandevice_t *priv, const firmware_image_t *apfw_image, UINT32 offset);
430 int acx100_validate_fw(wlandevice_t *priv, const firmware_image_t *apfw_mage, UINT32 offset);
431 int acx100_verify_init(wlandevice_t *priv);
432 void acx100_init_mboxes(wlandevice_t *priv);
433 int acx100_init_wep(wlandevice_t *priv, acx100_memmap_t *pt);
434 int acx100_init_packet_templates(wlandevice_t *priv, acx100_memmap_t *pt);
435 int acx100_init_max_probe_request_template(wlandevice_t *priv);
436 int acx100_init_max_null_data_template(wlandevice_t *priv);
437 int acx100_init_max_beacon_template(wlandevice_t *priv);
438 int acx100_init_max_tim_template(wlandevice_t *priv);
439 int acx100_init_max_probe_response_template(wlandevice_t *priv);
440 int acx100_set_tim_template(wlandevice_t *priv);
441 int acx100_set_generic_beacon_probe_response_frame(wlandevice_t *priv,
442 struct acxp80211_beacon_prb_resp *bcn);
443 void acx100_update_card_settings(wlandevice_t *priv, int init, int get_all, int set_all);
444 int acx_ioctl_old(netdevice_t *dev, struct ifreq *ifr, int cmd);
445 void acx100_set_probe_request_template(wlandevice_t *priv);
446 void acx100_scan_chan(wlandevice_t *priv);
447 void acx100_scan_chan_p(wlandevice_t *priv, struct scan *s);
448 void acx111_scan_chan_p(wlandevice_t *priv, struct acx111_scan *s);
449 int acx100_set_rxconfig(wlandevice_t *priv);
450 int acx100_load_radio(wlandevice_t *priv);
451 int acx100_read_proc(char *page, char **start, off_t offset, int count,
452 int *eof, void *data);
453 int acx100_read_proc_diag(char *page, char **start, off_t offset, int count,
454 int *eof, void *data);
455 int acx100_read_proc_eeprom(char *page, char **start, off_t offset, int count,
456 int *eof, void *data);
457 int acx100_read_proc_phy(char *page, char **start, off_t offset, int count,
458 int *eof, void *data);
459 int acx100_proc_output(char *buf, wlandevice_t *priv);
460 int acx100_proc_diag_output(char *buf, wlandevice_t *priv);
461 int acx100_proc_eeprom_output(char *buf, wlandevice_t *priv);
462 int acx100_proc_phy_output(char *buf, wlandevice_t *priv);
463 #endif /* __ACX_ACX100_HELPER_H */