awivar.h revision 1.1 1 1.1 sommerfe /*-
2 1.1 sommerfe * Copyright (c) 1999 The NetBSD Foundation, Inc.
3 1.1 sommerfe * All rights reserved.
4 1.1 sommerfe *
5 1.1 sommerfe * This code is derived from software contributed to The NetBSD Foundation
6 1.1 sommerfe * by Bill Sommerfeld
7 1.1 sommerfe *
8 1.1 sommerfe * Redistribution and use in source and binary forms, with or without
9 1.1 sommerfe * modification, are permitted provided that the following conditions
10 1.1 sommerfe * are met:
11 1.1 sommerfe * 1. Redistributions of source code must retain the above copyright
12 1.1 sommerfe * notice, this list of conditions and the following disclaimer.
13 1.1 sommerfe * 2. Redistributions in binary form must reproduce the above copyright
14 1.1 sommerfe * notice, this list of conditions and the following disclaimer in the
15 1.1 sommerfe * documentation and/or other materials provided with the distribution.
16 1.1 sommerfe * 3. All advertising materials mentioning features or use of this software
17 1.1 sommerfe * must display the following acknowledgement:
18 1.1 sommerfe * This product includes software developed by the NetBSD
19 1.1 sommerfe * Foundation, Inc. and its contributors.
20 1.1 sommerfe * 4. Neither the name of The NetBSD Foundation nor the names of its
21 1.1 sommerfe * contributors may be used to endorse or promote products derived
22 1.1 sommerfe * from this software without specific prior written permission.
23 1.1 sommerfe *
24 1.1 sommerfe * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
25 1.1 sommerfe * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
26 1.1 sommerfe * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
27 1.1 sommerfe * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
28 1.1 sommerfe * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 1.1 sommerfe * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 1.1 sommerfe * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 1.1 sommerfe * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32 1.1 sommerfe * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 1.1 sommerfe * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 1.1 sommerfe * POSSIBILITY OF SUCH DAMAGE.
35 1.1 sommerfe */
36 1.1 sommerfe
37 1.1 sommerfe
38 1.1 sommerfe enum awi_state {
39 1.1 sommerfe AWI_ST_OFF, /* powered off */
40 1.1 sommerfe AWI_ST_SELFTEST, /* waiting for selftest to complete*/
41 1.1 sommerfe AWI_ST_IFTEST, /* waiting for interface to respond */
42 1.1 sommerfe AWI_ST_MIB_GET, /* fetching MIB variables */
43 1.1 sommerfe AWI_ST_MIB_SET, /* stuffing MIB variables */
44 1.1 sommerfe AWI_ST_TXINIT, /* initializing TX side */
45 1.1 sommerfe AWI_ST_RXINIT, /* initializing RX side */
46 1.1 sommerfe AWI_ST_SCAN, /* hunting for a BSS */
47 1.1 sommerfe AWI_ST_SYNCED, /* synced? trying to auth.. */
48 1.1 sommerfe /* there are probably some missing 802.11 states here.. */
49 1.1 sommerfe AWI_ST_AUTHED, /* authenticated */
50 1.1 sommerfe AWI_ST_RUNNING, /* ready to send user data.. */
51 1.1 sommerfe AWI_ST_INSANE, /* failed to respond.. */
52 1.1 sommerfe };
53 1.1 sommerfe
54 1.1 sommerfe #define AWI_FL_CMD_INPROG 0x0001
55 1.1 sommerfe
56 1.1 sommerfe #define AWI_SSID_LEN 33
57 1.1 sommerfe
58 1.1 sommerfe struct awi_bss_binding
59 1.1 sommerfe {
60 1.1 sommerfe u_int8_t chanset; /* channel set to use */
61 1.1 sommerfe u_int8_t pattern; /* hop pattern to use */
62 1.1 sommerfe u_int8_t index; /* index to use */
63 1.1 sommerfe u_int8_t rssi; /* strenght of this beacon */
64 1.1 sommerfe u_int16_t dwell_time; /* dwell time */
65 1.1 sommerfe u_int8_t bss_timestamp[8]; /* timestamp of this bss */
66 1.1 sommerfe u_int8_t bss_id[6];
67 1.1 sommerfe u_int32_t rxtime; /* unit's local time */
68 1.1 sommerfe u_int8_t sslen;
69 1.1 sommerfe u_int8_t ssid[AWI_SSID_LEN];
70 1.1 sommerfe };
71 1.1 sommerfe
72 1.1 sommerfe #define NBND 4
73 1.1 sommerfe #define NTXD 4
74 1.1 sommerfe
75 1.1 sommerfe struct awi_txbd
76 1.1 sommerfe {
77 1.1 sommerfe u_int32_t descr; /* offset to descriptor */
78 1.1 sommerfe u_int32_t frame; /* offset to frame */
79 1.1 sommerfe u_int32_t len; /* frame length */
80 1.1 sommerfe };
81 1.1 sommerfe
82 1.1 sommerfe struct awi_softc
83 1.1 sommerfe {
84 1.1 sommerfe struct device sc_dev;
85 1.1 sommerfe struct am79c930_softc sc_chip;
86 1.1 sommerfe struct ethercom sc_ec;
87 1.1 sommerfe int sc_enabled;
88 1.1 sommerfe enum awi_state sc_state;
89 1.1 sommerfe int sc_flags;
90 1.1 sommerfe void *sc_ih; /* interrupt handler */
91 1.1 sommerfe struct ifnet *sc_ifp; /* XXX */
92 1.1 sommerfe int (*sc_enable) __P((struct awi_softc *));
93 1.1 sommerfe void (*sc_disable) __P((struct awi_softc *));
94 1.1 sommerfe void (*sc_completion) __P((struct awi_softc *,
95 1.1 sommerfe u_int8_t));
96 1.1 sommerfe
97 1.1 sommerfe struct ifqueue sc_mgtq;
98 1.1 sommerfe
99 1.1 sommerfe u_int32_t sc_txbase;
100 1.1 sommerfe u_int32_t sc_txlen;
101 1.1 sommerfe u_int32_t sc_rxbase;
102 1.1 sommerfe u_int32_t sc_rxlen;
103 1.1 sommerfe
104 1.1 sommerfe u_int32_t sc_rx_data_desc;
105 1.1 sommerfe u_int32_t sc_rx_mgt_desc;
106 1.1 sommerfe
107 1.1 sommerfe u_int16_t sc_scan_duration;
108 1.1 sommerfe u_int8_t sc_scan_chanset;
109 1.1 sommerfe u_int8_t sc_scan_pattern;
110 1.1 sommerfe
111 1.1 sommerfe int sc_nbindings;
112 1.1 sommerfe
113 1.1 sommerfe u_int8_t sc_my_addr[6];
114 1.1 sommerfe
115 1.1 sommerfe int sc_new_bss;
116 1.1 sommerfe struct awi_bss_binding sc_active_bss;
117 1.1 sommerfe /*
118 1.1 sommerfe * BSS's found during a scan.. XXX doesn't need to be in-line
119 1.1 sommerfe */
120 1.1 sommerfe struct awi_bss_binding sc_bindings[NBND];
121 1.1 sommerfe
122 1.1 sommerfe int sc_txpending;
123 1.1 sommerfe int sc_ntxd;
124 1.1 sommerfe int sc_txnext; /* next txd to be given to driver */
125 1.1 sommerfe int sc_txfirst; /* first unsent txd dev has */
126 1.1 sommerfe struct awi_txbd sc_txd[NTXD];
127 1.1 sommerfe u_int8_t sc_curmib;
128 1.1 sommerfe
129 1.1 sommerfe int sc_scan_timer;
130 1.1 sommerfe int sc_tx_timer;
131 1.1 sommerfe int sc_mgt_timer;
132 1.1 sommerfe int sc_cmd_timer;
133 1.1 sommerfe int sc_selftest_tries;
134 1.1 sommerfe };
135 1.1 sommerfe
136 1.1 sommerfe extern int awi_activate __P((struct device *, enum devact));
137 1.1 sommerfe extern int awi_attach __P((struct awi_softc *));
138 1.1 sommerfe
139 1.1 sommerfe #define awi_read_1(sc, off) ((sc)->sc_chip.sc_ops->read_1)(&sc->sc_chip, off)
140 1.1 sommerfe #define awi_read_2(sc, off) ((sc)->sc_chip.sc_ops->read_2)(&sc->sc_chip, off)
141 1.1 sommerfe #define awi_read_4(sc, off) ((sc)->sc_chip.sc_ops->read_4)(&sc->sc_chip, off)
142 1.1 sommerfe #define awi_read_bytes(sc, off, ptr, len) ((sc)->sc_chip.sc_ops->read_bytes)(&sc->sc_chip, off, ptr, len)
143 1.1 sommerfe
144 1.1 sommerfe #define awi_write_1(sc, off, val) \
145 1.1 sommerfe ((sc)->sc_chip.sc_ops->write_1)(&sc->sc_chip, off, val)
146 1.1 sommerfe #define awi_write_2(sc, off, val) \
147 1.1 sommerfe ((sc)->sc_chip.sc_ops->write_2)(&sc->sc_chip, off, val)
148 1.1 sommerfe #define awi_write_4(sc, off, val) \
149 1.1 sommerfe ((sc)->sc_chip.sc_ops->write_4)(&sc->sc_chip, off, val)
150 1.1 sommerfe #define awi_write_bytes(sc, off, ptr, len) \
151 1.1 sommerfe ((sc)->sc_chip.sc_ops->write_bytes)(&sc->sc_chip, off, ptr, len)
152 1.1 sommerfe
153 1.1 sommerfe #define awi_drvstate(sc, state) \
154 1.1 sommerfe awi_write_1(sc, AWI_DRIVERSTATE, \
155 1.1 sommerfe ((state) | AWI_DRV_AUTORXLED|AWI_DRV_AUTOTXLED));
156 1.1 sommerfe
157 1.1 sommerfe /* Number of trips around the loop waiting for the device.. */
158 1.1 sommerfe
159 1.1 sommerfe #define AWI_LOCKOUT_SPIN 10000 /* 10ms */
160 1.1 sommerfe
161 1.1 sommerfe /* 24-byte mac header + 8 byte SNAP header + 1500-byte ether MTU */
162 1.1 sommerfe #define AWI_FRAME_SIZE 1532
163 1.1 sommerfe
164 1.1 sommerfe /* refresh associations every 300s */
165 1.1 sommerfe
166 1.1 sommerfe #define AWI_ASSOC_REFRESH 300
167 1.1 sommerfe
168 1.1 sommerfe extern int awi_intr __P((void *));
169