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