awivar.h revision 1.6 1 /* $NetBSD: awivar.h,v 1.6 2000/03/22 11:22:22 onoe Exp $ */
2
3 /*
4 * Copyright (c) 2000 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Atsushi Onoe
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 /* timer values in msec */
40 #define AWI_SELFTEST_TIMEOUT 5000
41 #define AWI_CMD_TIMEOUT 2000
42 #define AWI_LOCKOUT_TIMEOUT 50
43 #define AWI_ASCAN_DURATION 100
44 #define AWI_ASCAN_WAIT 3000
45 #define AWI_PSCAN_DURATION 200
46 #define AWI_PSCAN_WAIT 5000
47 #define AWI_TRANS_TIMEOUT 2000
48
49 #define AWI_NTXBUFS 4
50
51 enum awi_status {
52 AWI_ST_INIT,
53 AWI_ST_SCAN,
54 AWI_ST_SETSS,
55 AWI_ST_SYNC,
56 AWI_ST_AUTH,
57 AWI_ST_ASSOC,
58 AWI_ST_RUNNING
59 };
60
61 struct awi_bss
62 {
63 TAILQ_ENTRY(awi_bss) list;
64 u_int8_t esrc[ETHER_ADDR_LEN];
65 u_int8_t chanset; /* channel set to use */
66 u_int8_t pattern; /* hop pattern to use */
67 u_int8_t index; /* index to use */
68 u_int8_t rssi; /* strength of this beacon */
69 u_int16_t dwell_time; /* dwell time */
70 u_int8_t timestamp[8]; /* timestamp of this bss */
71 u_int8_t bssid[ETHER_ADDR_LEN];
72 u_int32_t rxtime; /* unit's local time */
73 u_int16_t interval; /* beacon interval */
74 u_int8_t txrate;
75 u_int8_t fails;
76 u_int8_t essid[IEEE80211_NWID_LEN + 2];
77 };
78
79 struct awi_softc
80 {
81 #ifdef __NetBSD__
82 struct device sc_dev;
83 struct ethercom sc_ec;
84 void *sc_ih; /* interrupt handler */
85 #endif
86 #ifdef __FreeBSD__
87 #if __FreeBSD__ >= 4
88 struct {
89 char dv_xname[64]; /*XXX*/
90 } sc_dev;
91 #else
92 struct device sc_dev;
93 #endif
94 struct arpcom sc_ec;
95 struct callout_handle sc_tohandle;
96 #endif
97 struct am79c930_softc sc_chip;
98 struct ifnet *sc_ifp;
99 int (*sc_enable) __P((struct awi_softc *));
100 void (*sc_disable) __P((struct awi_softc *));
101
102 struct ifmedia sc_media;
103 enum awi_status sc_status;
104 unsigned int sc_enabled:1,
105 sc_busy:1,
106 sc_cansleep:1,
107 sc_invalid:1,
108 sc_cmd_inprog:1,
109 sc_format_llc:1,
110 sc_start_bss:1,
111 sc_rawbpf:1,
112 sc_no_bssid:1,
113 sc_active_scan:1;
114 int sc_sleep_cnt;
115
116 int sc_mgt_timer;
117
118 TAILQ_HEAD(, awi_bss) sc_scan;
119 u_int8_t sc_scan_cur;
120 u_int8_t sc_scan_min;
121 u_int8_t sc_scan_max;
122 u_int8_t sc_scan_set;
123 struct awi_bss sc_bss;
124
125 int sc_rx_timer;
126 u_int32_t sc_rxdoff;
127 u_int32_t sc_rxmoff;
128 struct mbuf *sc_rxpend;
129
130 int sc_tx_timer;
131 u_int8_t sc_tx_rate;
132 struct ifqueue sc_mgtq;
133 u_int32_t sc_txbase;
134 u_int32_t sc_txend;
135 u_int32_t sc_txnext;
136 u_int32_t sc_txdone;
137
138 struct awi_mib_local sc_mib_local;
139 struct awi_mib_addr sc_mib_addr;
140 struct awi_mib_mac sc_mib_mac;
141 struct awi_mib_stat sc_mib_stat;
142 struct awi_mib_mgt sc_mib_mgt;
143 struct awi_mib_phy sc_mib_phy;
144 };
145
146 #define awi_read_1(sc, off) ((sc)->sc_chip.sc_ops->read_1)(&sc->sc_chip, off)
147 #define awi_read_2(sc, off) ((sc)->sc_chip.sc_ops->read_2)(&sc->sc_chip, off)
148 #define awi_read_4(sc, off) ((sc)->sc_chip.sc_ops->read_4)(&sc->sc_chip, off)
149 #define awi_read_bytes(sc, off, ptr, len) ((sc)->sc_chip.sc_ops->read_bytes)(&sc->sc_chip, off, ptr, len)
150
151 #define awi_write_1(sc, off, val) \
152 ((sc)->sc_chip.sc_ops->write_1)(&sc->sc_chip, off, val)
153 #define awi_write_2(sc, off, val) \
154 ((sc)->sc_chip.sc_ops->write_2)(&sc->sc_chip, off, val)
155 #define awi_write_4(sc, off, val) \
156 ((sc)->sc_chip.sc_ops->write_4)(&sc->sc_chip, off, val)
157 #define awi_write_bytes(sc, off, ptr, len) \
158 ((sc)->sc_chip.sc_ops->write_bytes)(&sc->sc_chip, off, ptr, len)
159
160 #define awi_drvstate(sc, state) \
161 awi_write_1(sc, AWI_DRIVERSTATE, \
162 ((state) | AWI_DRV_AUTORXLED|AWI_DRV_AUTOTXLED))
163
164 /* unalligned little endian access */
165 #define LE_READ_2(p) \
166 (((u_int8_t *)(p))[0] | (((u_int8_t *)(p))[1] << 8))
167 #define LE_READ_4(p) \
168 (((u_int8_t *)(p))[0] | (((u_int8_t *)(p))[1] << 8) | \
169 (((u_int8_t *)(p))[2] << 16) | (((u_int8_t *)(p))[3] << 24))
170 #define LE_WRITE_2(p, v) \
171 ((((u_int8_t *)(p))[0] = ((u_int32_t)(v) & 0xff)), \
172 (((u_int8_t *)(p))[1] = (((u_int32_t)(v) >> 8) & 0xff)))
173 #define LE_WRITE_4(p, v) \
174 ((((u_int8_t *)(p))[0] = ((u_int32_t)(v) & 0xff)), \
175 (((u_int8_t *)(p))[1] = (((u_int32_t)(v) >> 8) & 0xff)), \
176 (((u_int8_t *)(p))[2] = (((u_int32_t)(v) >> 16) & 0xff)), \
177 (((u_int8_t *)(p))[3] = (((u_int32_t)(v) >> 24) & 0xff)))
178
179 #define AWI_80211_RATE(rate) (((rate) & 0x7f) * 5)
180
181 int awi_attach __P((struct awi_softc *));
182 int awi_intr __P((void *));
183 void awi_reset __P((struct awi_softc *));
184 #ifdef __NetBSD__
185 int awi_activate __P((struct device *, enum devact));
186 int awi_detach __P((struct awi_softc *));
187 #endif
188