Initial import from FreeBSD RELENG_4:
[dragonfly.git] / sys / dev / netif / ray / if_rayreg.h
1 /*
2  * Copyright (C) 2000
3  * Dr. Duncan McLennan Barclay, dmlb@ragnet.demon.co.uk.
4  *
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  * 3. Neither the name of the author nor the names of any co-contributors
16  *    may be used to endorse or promote products derived from this software
17  *    without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY DUNCAN BARCLAY AND CONTRIBUTORS ``AS IS'' AND
20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED.  IN NO EVENT SHALL DUNCAN BARCLAY OR CONTRIBUTORS BE LIABLE
23  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29  * SUCH DAMAGE.
30  *
31  * $FreeBSD: src/sys/dev/ray/if_rayreg.h,v 1.10.2.3 2001/01/03 10:45:39 dmlb Exp $
32  *
33  */
34
35 /*      $NetBSD: if_rayreg.h,v 1.1 2000/01/23 23:59:22 chopps Exp $     */
36 /* 
37  * Copyright (c) 2000 Christian E. Hopps
38  * All rights reserved.
39  * 
40  * Redistribution and use in source and binary forms, with or without
41  * modification, are permitted provided that the following conditions
42  * are met:
43  * 1. Redistributions of source code must retain the above copyright
44  *    notice, this list of conditions and the following disclaimer.
45  * 2. Redistributions in binary form must reproduce the above copyright
46  *    notice, this list of conditions and the following disclaimer in the
47  *    documentation and/or other materials provided with the distribution.
48  * 3. Neither the name of the author nor the names of any co-contributors
49  *    may be used to endorse or promote products derived from this software
50  *    without specific prior written permission.
51  *
52  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
53  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
54  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
55  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
56  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
57  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
58  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
59  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
60  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
61  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
62  * SUCH DAMAGE.
63  */
64
65 /*
66  * CCR registers, appearing in the attribute memory space
67  */
68 #define RAY_CCR         0xf00                   /* CCR register offset */
69 #define RAY_COR         (RAY_CCR + 0x00)        /* config option register */
70 #define RAY_CCSR        (RAY_CCR + 0x01)        /* config/status register */
71 #define RAY_PIN         (RAY_CCR + 0x02)        /* not used by hw */
72 #define RAY_SOCKETCOPY  (RAY_CCR + 0x03)        /* not used by hw */
73 #define RAY_HCSIR       (RAY_CCR + 0x05)        /* HCS intr register */
74 #define RAY_ECFIR       (RAY_CCR + 0x06)        /* ECF intr register */
75 /*
76  * We don't seem to be able to access these in a simple manner
77  */
78 #define RAY_AR0         (RAY_CCR + 0x08)        /* authorization register 0 (unused) */
79 #define RAY_AR1         (RAY_CCR + 0x09)        /* authorization register 1 (unused) */
80 #define RAY_PMR         (RAY_CCR + 0x0a)        /* program mode register (unused) */
81 #define RAY_TMR         (RAY_CCR + 0x0b)        /* pc test mode register (unused) */
82 #define RAY_FCWR        (RAY_CCR + 0x10)        /* frequency control word register */
83 #define RAY_TMC1        (RAY_CCR + 0x14)        /* test mode control 1 (unused) */
84 #define RAY_TMC2        (RAY_CCR + 0x15)        /* test mode control 1 (unused) */
85 #define RAY_TMC3        (RAY_CCR + 0x16)        /* test mode control 1 (unused) */
86 #define RAY_TMC4        (RAY_CCR + 0x17)        /* test mode control 1 (unused) */
87
88 /*
89  * COR register bits
90  */
91 #define RAY_COR_CFG_NUM         0x01    /* currently ignored and set */
92 #define RAY_COR_CFG_MASK        0x3f    /* mask for function */
93 #define RAY_COR_LEVEL_IRQ       0x40    /* currently ignored and set */
94 #define RAY_COR_RESET           0x80    /* soft-reset the card */
95 #define RAY_COR_DEFAULT         (RAY_COR_CFG_NUM | RAY_COR_LEVEL_IRQ)
96
97 /*
98  * CCS register bits
99  */
100 #define RAY_CCS_NORMAL          0x00    /* normal operation */
101 #define RAY_CCS_IRQ             0x02    /* interrupt pending */
102 #define RAY_CCS_POWER_DOWN      0x04    /* when written powers down card */
103
104 /*
105  * HCSIR bits
106  *
107  * the host can only clear this bit.
108  */
109 #define RAY_HCSIR_IRQ           0x01    /* indicates an interrupt */
110
111 /*
112  * ECFIR values
113  */
114 #define RAY_ECFIR_IRQ           0x01    /* interrupt the card */
115
116 /*
117  * AR0 values
118  * used for testing/programming the card (unused)
119  */
120 #define RAY_AR0_ON              0x57
121
122 /*
123  * AR1 values
124  * used for testing/programming the card (unused)
125  */
126 #define RAY_AR1_ON              0x82
127
128 /*
129  * PMR bits 
130  * these are used to program the card (unused)
131  */
132 #define RAY_PMR_NORMAL          0x00    /* normal operation */
133 #define RAY_PMR_PC2PM           0x02    /* grant access to firmware flash */
134 #define RAY_PMR_PC2CAL          0x10    /* read access to the A/D modem inp */
135 #define RAY_PMR_MLSE            0x20    /* read access to the MSLE prom */
136
137 /*
138  * TMR bits
139  * get access to test modes (unused)
140  */
141 #define RAY_TMR_NORMAL          0x00    /* normal operation */
142 #define RAY_TMR_TEST            0x08    /* test mode */
143
144 /*
145  * FCWR -- frequency control word, values from [0x02,0xA6] map to
146  * RF frequency values.
147  */
148
149 /*
150  * 48k of memory
151  */
152 #define RAY_SRAM_MEM_BASE       0
153 #define RAY_SRAM_MEM_SIZE       0xc000
154
155 /*
156  * offsets into shared ram
157  */
158 #define RAY_SCB_BASE            0x0000  /* cfg/status/ctl area */
159 #define RAY_STATUS_BASE         0x0100
160 #define RAY_HOST_TO_ECF_BASE    0x0200
161 #define RAY_ECF_TO_HOST_BASE    0x0300
162 #define RAY_CCS_BASE            0x0400
163 #define RAY_RCS_BASE            0x0800
164 #define RAY_APOINT_TIM_BASE     0x0c00
165 #define RAY_SSID_LIST_BASE      0x0d00
166 #define RAY_TX_BASE             0x1000
167 #define RAY_TX_SIZE             0x7000
168 #define RAY_TX_END              0x8000
169 #define RAY_RX_BASE             0x8000
170 #define RAY_RX_END              0xc000
171 #define RAY_RX_MASK             0x3fff
172
173 /*
174  * Startup reporting stucture
175  */
176 struct ray_ecf_startup_v4 {
177     u_int8_t    e_status;
178     u_int8_t    e_station_addr[ETHER_ADDR_LEN];
179     u_int8_t    e_prg_cksum;
180     u_int8_t    e_cis_cksum;
181     u_int8_t    e_resv0[7];
182     u_int8_t    e_japan_callsign[12];
183 };
184 struct ray_ecf_startup_v5 {
185     u_int8_t    e_status;
186     u_int8_t    e_station_addr[ETHER_ADDR_LEN];
187     u_int8_t    e_resv0;
188     u_int8_t    e_rates[8];
189     u_int8_t    e_japan_callsign[12];
190     u_int8_t    e_prg_cksum;
191     u_int8_t    e_cis_cksum;
192     u_int8_t    e_fw_build_string;
193     u_int8_t    e_fw_build;
194     u_int8_t    e_fw_resv;
195     u_int8_t    e_asic_version;
196     u_int8_t    e_tibsize;
197     u_int8_t    e_resv1[29];
198 };
199
200 /*
201  * Startup status word result codes
202  */
203 #define RAY_ECFS_RESERVED0              0x01
204 #define RAY_ECFS_PROC_SELF_TEST         0x02
205 #define RAY_ECFS_PROG_MEM_CHECKSUM      0x04
206 #define RAY_ECFS_DATA_MEM_TEST          0x08
207 #define RAY_ECFS_RX_CALIBRATION         0x10
208 #define RAY_ECFS_FW_VERSION_COMPAT      0x20
209 #define RAY_ECFS_RERSERVED1             0x40
210 #define RAY_ECFS_TEST_COMPLETE          0x80
211 #define RAY_ECFS_CARD_OK                RAY_ECFS_TEST_COMPLETE
212 #define RAY_ECFS_PRINTFB        \
213         "\020"                  \
214         "\001RESERVED0"         \
215         "\002PROC_SELF_TEST"    \
216         "\003PROG_MEM_CHECKSUM" \
217         "\004DATA_MEM_TEST"     \
218         "\005RX_CALIBRATION"    \
219         "\006FW_VERSION_COMPAT" \
220         "\007RERSERVED1"        \
221         "\010TEST_COMPLETE"
222
223 /*
224  * Firmware build codes
225  */
226 #define RAY_ECFS_BUILD_4                0x55
227 #define RAY_ECFS_BUILD_5                0x5
228
229 /*
230  * System Control Block
231  */
232 #define RAY_SCB_CCSI            0x00    /* host CCS index */
233 #define RAY_SCB_RCSI            0x01    /* ecf RCS index */
234
235 /*
236  * command control structures (for CCSR commands)
237  */
238
239 /*
240  * commands for CCSR
241  */
242 #define RAY_CMD_DOWNLOAD_PARAMS 0x01    /* download start params */
243 #define RAY_CMD_UPDATE_PARAMS   0x02    /* update params */
244 #define RAY_CMD_REPORT_PARAMS   0x03    /* report params */
245 #define RAY_CMD_UPDATE_MCAST    0x04    /* update mcast list */
246 #define RAY_CMD_UPDATE_APM      0x05    /* update power saving mode */
247 #define RAY_CMD_START_NET       0x06
248 #define RAY_CMD_JOIN_NET        0x07
249 #define RAY_CMD_START_ASSOC     0x08
250 #define RAY_CMD_TX_REQ          0x09
251 #define RAY_CMD_TEST_MEM        0x0a
252 #define RAY_CMD_SHUTDOWN        0x0b
253 #define RAY_CMD_DUMP_MEM        0x0c
254 #define RAY_CMD_START_TIMER     0x0d
255 #define RAY_CMD_MAX             0x0e
256
257 /*
258  * unsolicted commands from the ECF
259  */
260 #define RAY_ECMD_RX_DONE                0x80    /* process rx packet */
261 #define RAY_ECMD_REJOIN_DONE            0x81    /* rejoined the network */
262 #define RAY_ECMD_ROAM_START             0x82    /* romaining started */
263 #define RAY_ECMD_JAPAN_CALL_SIGNAL      0x83    /* japan test thing */
264
265
266 /*
267  * Configure/status/control memory
268  */
269 struct ray_csc {
270     u_int8_t    csc_mrxo_own;           /* 0 ECF writes, 1 host write */
271     u_int8_t    csc_mrxc_own;           /* 0 ECF writes, 1 host write */
272     u_int8_t    csc_rxhc_own;           /* 0 ECF writes, 1 host write */
273     u_int8_t    csc_resv;
274     u_int16_t   csc_mrx_overflow;       /* ECF incs on rx overflow */
275     u_int16_t   csc_mrx_cksum;          /* ECF incs on cksum error */
276     u_int16_t   csc_rx_hcksum;          /* ECF incs on header cksum error */
277     u_int8_t    csc_rx_noise;           /* average RSL measuremant */
278 };
279
280 /*
281  * CCS area
282  */
283 #define RAY_CCS_LINK_NULL       0xff
284 #define RAY_CCS_SIZE            16
285
286 #define RAY_CCS_TX_FIRST        0
287 #define RAY_CCS_TX_LAST         13
288 #define RAY_CCS_NTX             (RAY_CCS_TX_LAST - RAY_CCS_TX_FIRST + 1)
289 #define RAY_TX_BUF_SIZE         2048
290 #define RAY_CCS_CMD_FIRST       14
291 #define RAY_CCS_CMD_LAST        63
292 #define RAY_CCS_NCMD            (RAY_CCS_CMD_LAST - RAY_CCS_CMD_FIRST + 1)
293 #define RAY_CCS_LAST            63
294
295 #define RAY_CCS_INDEX(ccs)      (((ccs) - RAY_CCS_BASE) / RAY_CCS_SIZE)
296 #define RAY_CCS_ADDRESS(i)      (RAY_CCS_BASE + (i) * RAY_CCS_SIZE)
297
298 /*
299  * RCS area
300  */
301 #define RAY_RCS_FIRST   64
302 #define RAY_RCS_LAST    127
303
304 /*
305  * CCS commands
306  */
307 struct ray_cmd {
308     u_int8_t    c_status;               /* ccs generic header */
309     u_int8_t    c_cmd;                  /* " */
310     u_int8_t    c_link;                 /* " */
311 };
312
313 #define RAY_CCS_STATUS_FREE             0x0
314 #define RAY_CCS_STATUS_BUSY             0x1
315 #define RAY_CCS_STATUS_COMPLETE         0x2
316 #define RAY_CCS_STATUS_FAIL             0x3
317 #define RAY_CCS_STATUS_STRINGS {        \
318     "free",                             \
319     "busy",                             \
320     "complete",                         \
321     "fail"                              \
322 }
323
324 /* RAY_CMD_UPDATE_PARAMS */
325 struct ray_cmd_update {
326     u_int8_t    c_status;               /* ccs generic header */
327     u_int8_t    c_cmd;                  /* " */
328     u_int8_t    c_link;                 /* " */
329     u_int8_t    c_paramid;
330     u_int8_t    c_nparam;
331     u_int8_t    c_failcause;
332 };
333
334 /* RAY_CMD_REPORT_PARAMS */
335 struct ray_cmd_report {
336     u_int8_t    c_status;               /* ccs generic header */
337     u_int8_t    c_cmd;                  /* " */
338     u_int8_t    c_link;                 /* " */
339     u_int8_t    c_paramid;
340     u_int8_t    c_nparam;
341     u_int8_t    c_failcause;
342     u_int8_t    c_len;
343 };
344
345 /* RAY_CMD_UPDATE_MCAST */
346 struct ray_cmd_update_mcast {
347     u_int8_t    c_status;               /* ccs generic header */
348     u_int8_t    c_cmd;                  /* " */
349     u_int8_t    c_link;                 /* " */
350     u_int8_t    c_nmcast;
351 };
352
353 /* RAY_CMD_UPDATE_APM */
354 struct ray_cmd_udpate_apm {
355     u_int8_t    c_status;               /* ccs generic header */
356     u_int8_t    c_cmd;                  /* " */
357     u_int8_t    c_link;                 /* " */
358     u_int8_t    c_mode;
359 };
360
361 /* RAY_CMD_START_NET and RAY_CMD_JOIN_NET */
362 struct ray_cmd_net {
363     u_int8_t    c_status;               /* ccs generic header */
364     u_int8_t    c_cmd;                  /* " */
365     u_int8_t    c_link;                 /* " */
366     u_int8_t    c_upd_param;
367     u_int8_t    c_bss_id[ETHER_ADDR_LEN];
368     u_int8_t    c_inited;
369     u_int8_t    c_def_txrate;
370     u_int8_t    c_encrypt;
371 };
372 /* Parameters passed in HOST_TO_ECF section when c_upd_param is set in
373  * ray_cmd_net. */
374 struct ray_net_params {
375     u_int8_t    p_net_type;
376     u_int8_t    p_ssid[32];
377     u_int8_t    p_privacy_must_start;
378     u_int8_t    p_privacy_can_join;
379 };
380
381 /* RAY_CMD_START_ASSOC */
382 struct ray_cmd_update_assoc {
383     u_int8_t    c_status;               /* ccs generic header */
384     u_int8_t    c_cmd;                  /* " */
385     u_int8_t    c_link;                 /* " */
386     u_int8_t    c_astatus;
387     u_int8_t    c_aid[2];
388 };
389
390 /* RAY_CMD_TX_REQ */
391 struct ray_cmd_tx {
392     u_int8_t    c_status;               /* ccs generic header */
393     u_int8_t    c_cmd;                  /* " */
394     u_int8_t    c_link;                 /* " */
395     u_int8_t    c_bufp[2];
396     u_int8_t    c_len[2];
397     u_int8_t    c_resv[5];
398     u_int8_t    c_tx_rate;
399     u_int8_t    c_apm_mode;
400     u_int8_t    c_nretry;
401     u_int8_t    c_antenna;
402 };
403 struct ray_cmd_tx_4 {
404     u_int8_t    c_status;               /* ccs generic header */
405     u_int8_t    c_cmd;                  /* " */
406     u_int8_t    c_link;                 /* " */
407     u_int8_t    c_bufp[2];
408     u_int8_t    c_len[2];
409     u_int8_t    c_addr[ETHER_ADDR_LEN];
410     u_int8_t    c_apm_mode;
411     u_int8_t    c_nretry;
412     u_int8_t    c_antenna;
413 };
414
415 /* RAY_CMD_DUMP_MEM */
416 struct ray_cmd_dump_mem {
417     u_int8_t    c_status;               /* ccs generic header */
418     u_int8_t    c_cmd;                  /* " */
419     u_int8_t    c_link;                 /* " */
420     u_int8_t    c_memtype;
421     u_int8_t    c_memp[2];
422     u_int8_t    c_len;
423 };
424
425 /* RAY_CMD_START_TIMER */
426 struct ray_cmd_start_timer {
427     u_int8_t    c_status;               /* ccs generic header */
428     u_int8_t    c_cmd;                  /* " */
429     u_int8_t    c_link;                 /* " */
430     u_int8_t    c_duration[2];
431 };
432
433 /* RAY_ECMD_RX_DONE */
434 struct ray_cmd_rx {
435     u_int8_t    c_status;               /* ccs generic header */
436     u_int8_t    c_cmd;                  /* " */
437     u_int8_t    c_link;                 /* " */
438     u_int8_t    c_bufp[2];              /* buffer pointer */
439     u_int8_t    c_len[2];               /* length */
440     u_int8_t    c_siglev;               /* signal level */
441     u_int8_t    c_nextfrag;             /* next fragment in packet */
442     u_int8_t    c_pktlen[2];            /* total packet length */
443     u_int8_t    c_antenna;              /* ant. with best reception */
444     u_int8_t    c_updbss;               /* only 1 for beacon messages */
445 };
446
447 /*
448  * Transmit scratch space and phy header structures
449  */
450 struct ray_tx_tib {
451     u_int8_t    t_ccs_index;
452     u_int8_t    t_psm;
453     u_int8_t    t_pass_fail;
454     u_int8_t    t_retry_count;
455     u_int8_t    t_max_retries;
456     u_int8_t    t_frags_remaining;
457     u_int8_t    t_no_rb;
458     u_int8_t    t_rts_reqd;
459     u_int8_t    t_csma_tx_cntrl_2;
460     u_int8_t    t_sifs_tx_cntrl_2;
461     u_int8_t    t_tx_dma_addr_1[2];
462     u_int8_t    t_tx_dma_addr_2[2];
463     u_int8_t    t_var_dur_2mhz[2];
464     u_int8_t    t_var_dur_1mhz[2];
465     u_int8_t    t_max_dur_2mhz[2];
466     u_int8_t    t_max_dur_1mhz[2];
467     u_int8_t    t_hdr_len;
468     u_int8_t    t_max_frag_len[2];
469     u_int8_t    t_var_len[2];
470     u_int8_t    t_phy_hdr_4;
471     u_int8_t    t_mac_hdr_1;
472     u_int8_t    t_mac_hdr_2;
473     u_int8_t    t_sid[2];
474 };
475
476 struct ray_tx_phy_header {
477     u_int8_t    t_sfd[2];
478     u_int8_t    t_hdr_3;
479     u_int8_t    t_hdr_4;
480 };