Make all network interrupt service routines MPSAFE part 1/3.
[dragonfly.git] / sys / dev / netif / awi / awivar.h
... / ...
CommitLineData
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.7 2005/11/28 17:13:41 dillon Exp $ */
4
5/*-
6 * Copyright (c) 1999 The NetBSD Foundation, Inc.
7 * All rights reserved.
8 *
9 * This code is derived from software contributed to The NetBSD Foundation
10 * by Bill Sommerfeld
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
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.
27 *
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.
39 */
40
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
50
51#define AWI_NTXBUFS 4
52#define AWI_MAX_KEYLEN 16
53
54enum awi_status {
55 AWI_ST_INIT,
56 AWI_ST_SCAN,
57 AWI_ST_SETSS,
58 AWI_ST_SYNC,
59 AWI_ST_AUTH,
60 AWI_ST_ASSOC,
61 AWI_ST_RUNNING
62};
63
64struct awi_bss
65{
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];
75 u_int16_t capinfo;
76 u_int32_t rxtime; /* unit's local time */
77 u_int16_t interval; /* beacon interval */
78 u_int8_t txrate;
79 u_int8_t fails;
80 u_int8_t essid[IEEE80211_NWID_LEN + 2];
81};
82
83struct awi_wep_algo {
84 char *awa_name;
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);
89};
90
91struct awi_softc
92{
93 struct arpcom sc_ec;
94 struct am79c930_softc sc_chip;
95 struct ifnet *sc_ifp;
96 int (*sc_enable) (struct awi_softc *);
97 void (*sc_disable) (struct awi_softc *);
98
99 struct ifmedia sc_media;
100 enum awi_status sc_status;
101 unsigned int sc_enabled:1,
102 sc_invalid:1,
103 sc_enab_intr:1,
104 sc_format_llc:1,
105 sc_start_bss:1,
106 sc_rawbpf:1,
107 sc_no_bssid:1,
108 sc_active_scan:1,
109 sc_attached:1; /* attach has succeeded */
110 u_int8_t sc_cmd_inprog;
111 int sc_sleep_cnt;
112
113 int sc_mgt_timer;
114
115 TAILQ_HEAD(, awi_bss) sc_scan;
116 u_int8_t sc_scan_cur;
117 u_int8_t sc_scan_min;
118 u_int8_t sc_scan_max;
119 u_int8_t sc_scan_set;
120 struct awi_bss sc_bss;
121 u_int8_t sc_ownssid[IEEE80211_NWID_LEN + 2];
122 u_int8_t sc_ownch;
123
124 int sc_rx_timer;
125 u_int32_t sc_rxdoff;
126 u_int32_t sc_rxmoff;
127 struct mbuf *sc_rxpend;
128
129 int sc_tx_timer;
130 u_int8_t sc_tx_rate;
131 struct ifqueue sc_mgtq;
132 u_int32_t sc_txbase;
133 u_int32_t sc_txend;
134 u_int32_t sc_txnext;
135 u_int32_t sc_txdone;
136
137 int sc_wep_keylen[IEEE80211_WEP_NKID]; /* keylen */
138 u_int8_t sc_wep_key[IEEE80211_WEP_NKID][AWI_MAX_KEYLEN];
139 int sc_wep_defkid;
140 void *sc_wep_ctx; /* work area */
141 struct awi_wep_algo *sc_wep_algo;
142
143 u_char sc_banner[AWI_BANNER_LEN];
144 struct awi_mib_local sc_mib_local;
145 struct awi_mib_addr sc_mib_addr;
146 struct awi_mib_mac sc_mib_mac;
147 struct awi_mib_stat sc_mib_stat;
148 struct awi_mib_mgt sc_mib_mgt;
149 struct awi_mib_phy sc_mib_phy;
150};
151
152#define awi_read_1(sc, off) ((sc)->sc_chip.sc_ops->read_1)(&sc->sc_chip, off)
153#define awi_read_2(sc, off) ((sc)->sc_chip.sc_ops->read_2)(&sc->sc_chip, off)
154#define awi_read_4(sc, off) ((sc)->sc_chip.sc_ops->read_4)(&sc->sc_chip, off)
155#define awi_read_bytes(sc, off, ptr, len) ((sc)->sc_chip.sc_ops->read_bytes)(&sc->sc_chip, off, ptr, len)
156
157#define awi_write_1(sc, off, val) \
158 ((sc)->sc_chip.sc_ops->write_1)(&sc->sc_chip, off, val)
159#define awi_write_2(sc, off, val) \
160 ((sc)->sc_chip.sc_ops->write_2)(&sc->sc_chip, off, val)
161#define awi_write_4(sc, off, val) \
162 ((sc)->sc_chip.sc_ops->write_4)(&sc->sc_chip, off, val)
163#define awi_write_bytes(sc, off, ptr, len) \
164 ((sc)->sc_chip.sc_ops->write_bytes)(&sc->sc_chip, off, ptr, len)
165
166#define awi_drvstate(sc, state) \
167 awi_write_1(sc, AWI_DRIVERSTATE, \
168 ((state) | AWI_DRV_AUTORXLED|AWI_DRV_AUTOTXLED))
169
170/* unalligned little endian access */
171#define LE_READ_2(p) \
172 (((u_int8_t *)(p))[0] | (((u_int8_t *)(p))[1] << 8))
173#define LE_READ_4(p) \
174 (((u_int8_t *)(p))[0] | (((u_int8_t *)(p))[1] << 8) | \
175 (((u_int8_t *)(p))[2] << 16) | (((u_int8_t *)(p))[3] << 24))
176#define LE_WRITE_2(p, v) \
177 ((((u_int8_t *)(p))[0] = ((u_int32_t)(v) & 0xff)), \
178 (((u_int8_t *)(p))[1] = (((u_int32_t)(v) >> 8) & 0xff)))
179#define LE_WRITE_4(p, v) \
180 ((((u_int8_t *)(p))[0] = ((u_int32_t)(v) & 0xff)), \
181 (((u_int8_t *)(p))[1] = (((u_int32_t)(v) >> 8) & 0xff)), \
182 (((u_int8_t *)(p))[2] = (((u_int32_t)(v) >> 16) & 0xff)), \
183 (((u_int8_t *)(p))[3] = (((u_int32_t)(v) >> 24) & 0xff)))
184
185#define AWI_80211_RATE(rate) (((rate) & 0x7f) * 5)
186
187int awi_attach (struct awi_softc *);
188int awi_intr (void *);
189void awi_reset (struct awi_softc *);
190
191void awi_stop (struct awi_softc *sc);
192int awi_init (struct awi_softc *sc);
193int awi_init_region (struct awi_softc *);
194int awi_wicfg (struct ifnet *, u_long, caddr_t);
195
196int awi_wep_setnwkey (struct awi_softc *, struct ieee80211_nwkey *);
197int awi_wep_getnwkey (struct awi_softc *, struct ieee80211_nwkey *);
198int awi_wep_getalgo (struct awi_softc *);
199int awi_wep_setalgo (struct awi_softc *, int);
200int awi_wep_setkey (struct awi_softc *, int, unsigned char *, int);
201int awi_wep_getkey (struct awi_softc *, int, unsigned char *, int *);
202struct mbuf *awi_wep_encrypt (struct awi_softc *, struct mbuf *, int);