wivar.h revision 1.36 1 /* $NetBSD: wivar.h,v 1.36 2003/07/06 20:01:18 dyoung Exp $ */
2
3 /*
4 * Copyright (c) 1997, 1998, 1999
5 * Bill Paul <wpaul (at) ctr.columbia.edu>. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by Bill Paul.
18 * 4. Neither the name of the author nor the names of any co-contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
26 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 * THE POSSIBILITY OF SUCH DAMAGE.
33 */
34
35 /*
36 * FreeBSD driver ported to NetBSD by Bill Sommerfeld in the back of the
37 * Oslo IETF plenary meeting.
38 */
39 struct wi_softc {
40 struct device sc_dev;
41 struct ieee80211com sc_ic;
42 void *sc_ih; /* interrupt handler */
43 int (*sc_enable)(struct wi_softc *);
44 void (*sc_disable)(struct wi_softc *);
45 void (*sc_reset)(struct wi_softc *);
46
47 int sc_attached;
48 int sc_enabled;
49 int sc_invalid;
50 int sc_firmware_type;
51 #define WI_NOTYPE 0
52 #define WI_LUCENT 1
53 #define WI_INTERSIL 2
54 #define WI_SYMBOL 3
55 int sc_pri_firmware_ver; /* Primary firm vers */
56 int sc_sta_firmware_ver; /* Station firm vers */
57 int sc_pci; /* attach to PCI-Bus */
58
59 bus_space_tag_t sc_iot; /* bus cookie */
60 bus_space_handle_t sc_ioh; /* bus i/o handle */
61
62 caddr_t sc_drvbpf;
63 int sc_flags;
64 int sc_bap_id;
65 int sc_bap_off;
66
67 u_int16_t sc_portnum;
68
69 /* RSSI interpretation */
70 u_int16_t sc_min_rssi; /* clamp sc_min_rssi < RSSI */
71 u_int16_t sc_max_rssi; /* clamp RSSI < sc_max_rssi */
72 u_int16_t sc_dbm_offset; /* dBm ~ RSSI - sc_dbm_offset */
73 u_int16_t sc_max_datalen;
74 u_int16_t sc_frag_thresh;
75 u_int16_t sc_rts_thresh;
76 u_int16_t sc_system_scale;
77 u_int16_t sc_tx_rate;
78 u_int16_t sc_cnfauthmode;
79 u_int16_t sc_roaming_mode;
80 u_int16_t sc_microwave_oven;
81
82 int sc_nodelen;
83 char sc_nodename[IEEE80211_NWID_LEN];
84
85 int sc_buflen;
86 #define WI_NTXBUF 3
87 struct sc_txdesc {
88 int d_fid;
89 int d_len;
90 } sc_txd[WI_NTXBUF];
91 int sc_txnext;
92 int sc_txcur;
93 int sc_tx_timer;
94 int sc_scan_timer;
95 int sc_syn_timer;
96
97 struct wi_counters sc_stats;
98 u_int16_t sc_ibss_port;
99
100 struct wi_apinfo sc_aps[MAXAPINFO];
101 int sc_naps;
102
103 int sc_false_syns;
104
105 u_int16_t sc_txbuf[IEEE80211_MAX_LEN/2];
106 };
107
108 #define sc_if sc_ic.ic_if
109
110 /* maximum consecutive false change-of-BSSID indications */
111 #define WI_MAX_FALSE_SYNS 10
112
113 #define WI_PRISM_MIN_RSSI 0x1b
114 #define WI_PRISM_MAX_RSSI 0x9a
115 #define WI_PRISM_DBM_OFFSET 100 /* XXX */
116
117 #define WI_LUCENT_MIN_RSSI 47
118 #define WI_LUCENT_MAX_RSSI 138
119 #define WI_LUCENT_DBM_OFFSET 149
120
121 #define WI_RSSI_TO_DBM(sc, rssi) (MIN((sc)->sc_max_rssi, \
122 MAX((sc)->sc_min_rssi, (rssi))) - (sc)->sc_dbm_offset)
123
124 #define WI_SCAN_INQWAIT 3 /* wait sec before inquire */
125 #define WI_SCAN_WAIT 5 /* maximum scan wait */
126
127 /* Values for wi_flags. */
128 #define WI_FLAGS_ATTACHED 0x0001
129 #define WI_FLAGS_INITIALIZED 0x0002
130 #define WI_FLAGS_OUTRANGE 0x0004
131 #define WI_FLAGS_HAS_MOR 0x0010
132 #define WI_FLAGS_HAS_ROAMING 0x0020
133 #define WI_FLAGS_HAS_DIVERSITY 0x0040
134 #define WI_FLAGS_HAS_SYSSCALE 0x0080
135 #define WI_FLAGS_BUG_AUTOINC 0x0100
136 #define WI_FLAGS_HAS_FRAGTHR 0x0200
137 #define WI_FLAGS_HAS_DBMADJUST 0x0400
138
139 struct wi_card_ident {
140 u_int16_t card_id;
141 char *card_name;
142 u_int8_t firm_type;
143 };
144
145 /*
146 * register space access macros
147 */
148 #ifdef WI_AT_BIGENDIAN_BUS_HACK
149 /*
150 * XXX - ugly hack for sparc bus_space_* macro deficiencies:
151 * assume the bus we are accessing is big endian.
152 */
153
154 #define CSR_WRITE_4(sc, reg, val) \
155 bus_space_write_4(sc->sc_iot, sc->sc_ioh, \
156 (sc->sc_pci? reg * 2: reg) , htole32(val))
157 #define CSR_WRITE_2(sc, reg, val) \
158 bus_space_write_2(sc->sc_iot, sc->sc_ioh, \
159 (sc->sc_pci? reg * 2: reg), htole16(val))
160 #define CSR_WRITE_1(sc, reg, val) \
161 bus_space_write_1(sc->sc_iot, sc->sc_ioh, \
162 (sc->sc_pci? reg * 2: reg), val)
163
164 #define CSR_READ_4(sc, reg) \
165 le32toh(bus_space_read_4(sc->sc_iot, sc->sc_ioh, \
166 (sc->sc_pci? reg * 2: reg)))
167 #define CSR_READ_2(sc, reg) \
168 le16toh(bus_space_read_2(sc->sc_iot, sc->sc_ioh, \
169 (sc->sc_pci? reg * 2: reg)))
170 #define CSR_READ_1(sc, reg) \
171 bus_space_read_1(sc->sc_iot, sc->sc_ioh, \
172 (sc->sc_pci? reg * 2: reg))
173
174 #else
175
176 #define CSR_WRITE_4(sc, reg, val) \
177 bus_space_write_4(sc->sc_iot, sc->sc_ioh, \
178 (sc->sc_pci? reg * 2: reg) , val)
179 #define CSR_WRITE_2(sc, reg, val) \
180 bus_space_write_2(sc->sc_iot, sc->sc_ioh, \
181 (sc->sc_pci? reg * 2: reg), val)
182 #define CSR_WRITE_1(sc, reg, val) \
183 bus_space_write_1(sc->sc_iot, sc->sc_ioh, \
184 (sc->sc_pci? reg * 2: reg), val)
185
186 #define CSR_READ_4(sc, reg) \
187 bus_space_read_4(sc->sc_iot, sc->sc_ioh, \
188 (sc->sc_pci? reg * 2: reg))
189 #define CSR_READ_2(sc, reg) \
190 bus_space_read_2(sc->sc_iot, sc->sc_ioh, \
191 (sc->sc_pci? reg * 2: reg))
192 #define CSR_READ_1(sc, reg) \
193 bus_space_read_1(sc->sc_iot, sc->sc_ioh, \
194 (sc->sc_pci? reg * 2: reg))
195 #endif
196
197 #ifndef __BUS_SPACE_HAS_STREAM_METHODS
198 #define bus_space_write_stream_2 bus_space_write_2
199 #define bus_space_write_multi_stream_2 bus_space_write_multi_2
200 #define bus_space_read_stream_2 bus_space_read_2
201 #define bus_space_read_multi_stream_2 bus_space_read_multi_2
202 #endif
203
204 #define CSR_WRITE_STREAM_2(sc, reg, val) \
205 bus_space_write_stream_2(sc->sc_iot, sc->sc_ioh, \
206 (sc->sc_pci? reg * 2: reg), val)
207 #define CSR_WRITE_MULTI_STREAM_2(sc, reg, val, count) \
208 bus_space_write_multi_stream_2(sc->sc_iot, sc->sc_ioh, \
209 (sc->sc_pci? reg * 2: reg), val, count)
210 #define CSR_READ_STREAM_2(sc, reg) \
211 bus_space_read_stream_2(sc->sc_iot, sc->sc_ioh, \
212 (sc->sc_pci? reg * 2: reg))
213 #define CSR_READ_MULTI_STREAM_2(sc, reg, buf, count) \
214 bus_space_read_multi_stream_2(sc->sc_iot, sc->sc_ioh, \
215 (sc->sc_pci? reg * 2: reg), buf, count)
216
217
218 int wi_attach(struct wi_softc *);
219 int wi_detach(struct wi_softc *);
220 int wi_activate(struct device *, enum devact);
221 int wi_intr(void *arg);
222 void wi_power(struct wi_softc *, int);
223 void wi_shutdown(struct wi_softc *);
224