1 /* $NetBSD: awivar.h,v 1.12 2000/07/21 04:48:56 onoe Exp $ */
2 /* $FreeBSD: src/sys/dev/awi/awivar.h,v 1.6.2.1 2000/12/07 04:09:39 imp Exp $ */
3 /* $DragonFly: src/sys/dev/netif/awi/Attic/awivar.h,v 1.5 2004/07/10 12:48:55 joerg Exp $ */
6 * Copyright (c) 1999 The NetBSD Foundation, Inc.
9 * This code is derived from software contributed to The NetBSD Foundation
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
20 * 3. All advertising materials mentioning features or use of this software
21 * must display the following acknowledgement:
22 * This product includes software developed by the NetBSD
23 * Foundation, Inc. and its contributors.
24 * 4. Neither the name of The NetBSD Foundation nor the names of its
25 * contributors may be used to endorse or promote products derived
26 * from this software without specific prior written permission.
28 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
29 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
30 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
31 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
32 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
33 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
34 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
35 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
36 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
37 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38 * POSSIBILITY OF SUCH DAMAGE.
41 /* timer values in msec */
42 #define AWI_SELFTEST_TIMEOUT 5000
43 #define AWI_CMD_TIMEOUT 2000
44 #define AWI_LOCKOUT_TIMEOUT 50
45 #define AWI_ASCAN_DURATION 100
46 #define AWI_ASCAN_WAIT 3000
47 #define AWI_PSCAN_DURATION 200
48 #define AWI_PSCAN_WAIT 5000
49 #define AWI_TRANS_TIMEOUT 2000
52 #define AWI_MAX_KEYLEN 16
66 TAILQ_ENTRY(awi_bss) list;
67 u_int8_t esrc[ETHER_ADDR_LEN];
68 u_int8_t chanset; /* channel set to use */
69 u_int8_t pattern; /* hop pattern to use */
70 u_int8_t index; /* index to use */
71 u_int8_t rssi; /* strength of this beacon */
72 u_int16_t dwell_time; /* dwell time */
73 u_int8_t timestamp[8]; /* timestamp of this bss */
74 u_int8_t bssid[ETHER_ADDR_LEN];
76 u_int32_t rxtime; /* unit's local time */
77 u_int16_t interval; /* beacon interval */
80 u_int8_t essid[IEEE80211_NWID_LEN + 2];
85 int (*awa_ctxlen) (void);
86 void (*awa_setkey) (void *, u_char *, int);
87 void (*awa_encrypt) (void *, u_char *, u_char *, int);
88 void (*awa_decrypt) (void *, u_char *, u_char *, int);
95 struct ethercom sc_ec;
96 void *sc_ih; /* interrupt handler */
98 #if defined(__DragonFly__) || defined(__FreeBSD__)
101 struct am79c930_softc sc_chip;
102 struct ifnet *sc_ifp;
103 int (*sc_enable) (struct awi_softc *);
104 void (*sc_disable) (struct awi_softc *);
106 struct ifmedia sc_media;
107 enum awi_status sc_status;
108 unsigned int sc_enabled:1,
118 sc_attached:1; /* attach has succeeded */
119 u_int8_t sc_cmd_inprog;
124 TAILQ_HEAD(, awi_bss) sc_scan;
125 u_int8_t sc_scan_cur;
126 u_int8_t sc_scan_min;
127 u_int8_t sc_scan_max;
128 u_int8_t sc_scan_set;
129 struct awi_bss sc_bss;
130 u_int8_t sc_ownssid[IEEE80211_NWID_LEN + 2];
136 struct mbuf *sc_rxpend;
140 struct ifqueue sc_mgtq;
146 int sc_wep_keylen[IEEE80211_WEP_NKID]; /* keylen */
147 u_int8_t sc_wep_key[IEEE80211_WEP_NKID][AWI_MAX_KEYLEN];
149 void *sc_wep_ctx; /* work area */
150 struct awi_wep_algo *sc_wep_algo;
152 u_char sc_banner[AWI_BANNER_LEN];
153 struct awi_mib_local sc_mib_local;
154 struct awi_mib_addr sc_mib_addr;
155 struct awi_mib_mac sc_mib_mac;
156 struct awi_mib_stat sc_mib_stat;
157 struct awi_mib_mgt sc_mib_mgt;
158 struct awi_mib_phy sc_mib_phy;
161 #define awi_read_1(sc, off) ((sc)->sc_chip.sc_ops->read_1)(&sc->sc_chip, off)
162 #define awi_read_2(sc, off) ((sc)->sc_chip.sc_ops->read_2)(&sc->sc_chip, off)
163 #define awi_read_4(sc, off) ((sc)->sc_chip.sc_ops->read_4)(&sc->sc_chip, off)
164 #define awi_read_bytes(sc, off, ptr, len) ((sc)->sc_chip.sc_ops->read_bytes)(&sc->sc_chip, off, ptr, len)
166 #define awi_write_1(sc, off, val) \
167 ((sc)->sc_chip.sc_ops->write_1)(&sc->sc_chip, off, val)
168 #define awi_write_2(sc, off, val) \
169 ((sc)->sc_chip.sc_ops->write_2)(&sc->sc_chip, off, val)
170 #define awi_write_4(sc, off, val) \
171 ((sc)->sc_chip.sc_ops->write_4)(&sc->sc_chip, off, val)
172 #define awi_write_bytes(sc, off, ptr, len) \
173 ((sc)->sc_chip.sc_ops->write_bytes)(&sc->sc_chip, off, ptr, len)
175 #define awi_drvstate(sc, state) \
176 awi_write_1(sc, AWI_DRIVERSTATE, \
177 ((state) | AWI_DRV_AUTORXLED|AWI_DRV_AUTOTXLED))
179 /* unalligned little endian access */
180 #define LE_READ_2(p) \
181 (((u_int8_t *)(p))[0] | (((u_int8_t *)(p))[1] << 8))
182 #define LE_READ_4(p) \
183 (((u_int8_t *)(p))[0] | (((u_int8_t *)(p))[1] << 8) | \
184 (((u_int8_t *)(p))[2] << 16) | (((u_int8_t *)(p))[3] << 24))
185 #define LE_WRITE_2(p, v) \
186 ((((u_int8_t *)(p))[0] = ((u_int32_t)(v) & 0xff)), \
187 (((u_int8_t *)(p))[1] = (((u_int32_t)(v) >> 8) & 0xff)))
188 #define LE_WRITE_4(p, v) \
189 ((((u_int8_t *)(p))[0] = ((u_int32_t)(v) & 0xff)), \
190 (((u_int8_t *)(p))[1] = (((u_int32_t)(v) >> 8) & 0xff)), \
191 (((u_int8_t *)(p))[2] = (((u_int32_t)(v) >> 16) & 0xff)), \
192 (((u_int8_t *)(p))[3] = (((u_int32_t)(v) >> 24) & 0xff)))
194 #define AWI_80211_RATE(rate) (((rate) & 0x7f) * 5)
196 int awi_attach (struct awi_softc *);
197 int awi_intr (void *);
198 void awi_reset (struct awi_softc *);
200 int awi_activate (struct device *, enum devact);
201 int awi_detach (struct awi_softc *);
202 void awi_power (struct awi_softc *, int);
205 void awi_stop (struct awi_softc *sc);
206 int awi_init (struct awi_softc *sc);
207 int awi_init_region (struct awi_softc *);
208 int awi_wicfg (struct ifnet *, u_long, caddr_t);
210 int awi_wep_setnwkey (struct awi_softc *, struct ieee80211_nwkey *);
211 int awi_wep_getnwkey (struct awi_softc *, struct ieee80211_nwkey *);
212 int awi_wep_getalgo (struct awi_softc *);
213 int awi_wep_setalgo (struct awi_softc *, int);
214 int awi_wep_setkey (struct awi_softc *, int, unsigned char *, int);
215 int awi_wep_getkey (struct awi_softc *, int, unsigned char *, int *);
216 struct mbuf *awi_wep_encrypt (struct awi_softc *, struct mbuf *, int);