]> CyberLeo.Net >> Repos - FreeBSD/releng/7.2.git/blob - sys/dev/wi/if_wivar.h
Create releng/7.2 from stable/7 in preparation for 7.2-RELEASE.
[FreeBSD/releng/7.2.git] / sys / dev / wi / if_wivar.h
1 /*-
2  * Copyright (c) 2002
3  *      M Warner Losh <imp@freebsd.org>.  All rights reserved.
4  * Copyright (c) 1997, 1998, 1999
5  *      Bill Paul <wpaul@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  * $FreeBSD$
35  */
36
37 #if 0
38 #define WICACHE                 /* turn on signal strength cache code */  
39 #define MAXWICACHE      10
40 #endif
41
42 /*
43  * Encryption controls. We can enable or disable encryption as
44  * well as specify up to 4 encryption keys. We can also specify
45  * which of the four keys will be used for transmit encryption.
46  */
47 #define WI_RID_ENCRYPTION       0xFC20
48 #define WI_RID_AUTHTYPE         0xFC21
49 #define WI_RID_DEFLT_CRYPT_KEYS 0xFCB0
50 #define WI_RID_TX_CRYPT_KEY     0xFCB1
51 #define WI_RID_WEP_AVAIL        0xFD4F
52 #define WI_RID_P2_TX_CRYPT_KEY  0xFC23
53 #define WI_RID_P2_CRYPT_KEY0    0xFC24
54 #define WI_RID_P2_CRYPT_KEY1    0xFC25
55 #define WI_RID_MICROWAVE_OVEN   0xFC25
56 #define WI_RID_P2_CRYPT_KEY2    0xFC26
57 #define WI_RID_P2_CRYPT_KEY3    0xFC27
58 #define WI_RID_P2_ENCRYPTION    0xFC28
59 #define WI_RID_ROAMING_MODE     0xFC2D
60 #define WI_RID_CUR_TX_RATE      0xFD44 /* current TX rate */
61
62 #define WI_MAX_AID              256     /* max stations for ap operation */
63
64 struct wi_softc {
65         struct ifnet            *sc_ifp;
66         struct ieee80211com     sc_ic;
67         int                     (*sc_newstate)(struct ieee80211com *,
68                                         enum ieee80211_state, int);
69         int                     (*sc_key_alloc)(struct ieee80211com *,
70                                         const struct ieee80211_key *,
71                                         ieee80211_keyix *, ieee80211_keyix *);
72         device_t                sc_dev;
73         struct mtx              sc_mtx;
74         struct callout          sc_watchdog;
75         int                     sc_unit;
76         int                     wi_gone;
77         int                     sc_enabled;
78         int                     sc_reset;
79         int                     sc_firmware_type;
80 #define WI_NOTYPE       0
81 #define WI_LUCENT       1
82 #define WI_INTERSIL     2
83 #define WI_SYMBOL       3
84         int                     sc_pri_firmware_ver;    /* Primary firmware */
85         int                     sc_sta_firmware_ver;    /* Station firmware */
86
87         int                     wi_bus_type;    /* Bus attachment type */
88         struct resource *       local;
89         int                     local_rid;
90         struct resource *       iobase;
91         int                     iobase_rid;
92         struct resource *       irq;
93         int                     irq_rid;
94         struct resource *       mem;
95         int                     mem_rid;
96         bus_space_handle_t      wi_localhandle;
97         bus_space_tag_t         wi_localtag;
98         bus_space_handle_t      wi_bhandle;
99         bus_space_tag_t         wi_btag;
100         bus_space_handle_t      wi_bmemhandle;
101         bus_space_tag_t         wi_bmemtag;
102         void *                  wi_intrhand;
103         struct ieee80211_channel *wi_channel;
104         int                     wi_io_addr;
105         int                     wi_cmd_count;
106
107         struct bpf_if           *sc_drvbpf;
108         int                     sc_flags;
109         int                     sc_if_flags;
110         int                     sc_bap_id;
111         int                     sc_bap_off;
112         
113         u_int16_t               sc_procframe;
114         u_int16_t               sc_portnum;
115
116         /* RSSI interpretation */
117         u_int16_t               sc_min_rssi;    /* clamp sc_min_rssi < RSSI */
118         u_int16_t               sc_max_rssi;    /* clamp RSSI < sc_max_rssi */
119         u_int16_t               sc_dbm_offset;  /* dBm ~ RSSI - sc_dbm_offset */
120
121         u_int16_t               sc_max_datalen;
122         u_int16_t               sc_system_scale;
123         u_int16_t               sc_cnfauthmode;
124         u_int16_t               sc_roaming_mode;
125         u_int16_t               sc_microwave_oven;
126         u_int16_t               sc_authtype;
127         u_int16_t               sc_encryption;
128
129         int                     sc_nodelen;
130         char                    sc_nodename[IEEE80211_NWID_LEN];
131         char                    sc_net_name[IEEE80211_NWID_LEN];
132         uint8_t                 sc_hintmacaddr[IEEE80211_ADDR_LEN];
133
134         int                     sc_buflen;              /* TX buffer size */
135         int                     sc_ntxbuf;
136 #define WI_NTXBUF       3
137         struct {
138                 int             d_fid;
139                 int             d_len;
140         }                       sc_txd[WI_NTXBUF];      /* TX buffers */
141         int                     sc_txnext;              /* index of next TX */
142         int                     sc_txcur;               /* index of current TX*/
143         int                     sc_tx_timer;
144         int                     sc_scan_timer;
145
146         struct wi_counters      sc_stats;
147         u_int16_t               sc_ibss_port;
148
149 #define WI_MAXAPINFO            30
150         struct wi_apinfo        sc_aps[WI_MAXAPINFO];
151         int                     sc_naps;
152
153         struct {
154                 u_int16_t               wi_sleep;
155                 u_int16_t               wi_delaysupp;
156                 u_int16_t               wi_txsupp;
157                 u_int16_t               wi_monitor;
158                 u_int16_t               wi_ledtest;
159                 u_int16_t               wi_ledtest_param0;
160                 u_int16_t               wi_ledtest_param1;
161                 u_int16_t               wi_conttx;
162                 u_int16_t               wi_conttx_param0;
163                 u_int16_t               wi_contrx;
164                 u_int16_t               wi_sigstate;
165                 u_int16_t               wi_sigstate_param0;
166                 u_int16_t               wi_confbits;
167                 u_int16_t               wi_confbits_param0;
168         } wi_debug;
169
170         struct timeval          sc_last_syn;
171         int                     sc_false_syns;
172
173         u_int16_t               sc_txbuf[IEEE80211_MAX_LEN/2];
174
175         union {
176                 struct wi_tx_radiotap_header th;
177                 u_int8_t        pad[64];
178         } u_tx_rt;
179         int                     sc_tx_th_len;
180         union {
181                 struct wi_rx_radiotap_header th;
182                 u_int8_t        pad[64];
183         } u_rx_rt;
184         int                     sc_rx_th_len;
185 };
186 #define sc_tx_th                u_tx_rt.th
187 #define sc_rx_th                u_rx_rt.th
188
189 /* maximum consecutive false change-of-BSSID indications */
190 #define WI_MAX_FALSE_SYNS               10      
191
192 #define WI_SCAN_INQWAIT                 3       /* wait sec before inquire */
193 #define WI_SCAN_WAIT                    5       /* maximum scan wait */
194
195 #define WI_FLAGS_ATTACHED               0x0001
196 #define WI_FLAGS_INITIALIZED            0x0002
197 #define WI_FLAGS_OUTRANGE               0x0004
198 #define WI_FLAGS_HAS_MOR                0x0010
199 #define WI_FLAGS_HAS_ROAMING            0x0020
200 #define WI_FLAGS_HAS_DIVERSITY          0x0040
201 #define WI_FLAGS_HAS_SYSSCALE           0x0080
202 #define WI_FLAGS_BUG_AUTOINC            0x0100
203 #define WI_FLAGS_HAS_FRAGTHR            0x0200
204 #define WI_FLAGS_HAS_DBMADJUST          0x0400
205 #define WI_FLAGS_SCANNING               0x0800
206
207
208 /* driver-specific node state */
209 struct wi_node {
210         struct ieee80211_node ni;       /* base class */
211 };
212
213 struct wi_card_ident {
214         u_int16_t       card_id;
215         char            *card_name;
216         u_int8_t        firm_type;
217 };
218
219 #define WI_PRISM_MIN_RSSI       0x1b
220 #define WI_PRISM_MAX_RSSI       0x9a
221 #define WI_PRISM_DBM_OFFSET     100 /* XXX */
222
223 #define WI_LUCENT_MIN_RSSI      47
224 #define WI_LUCENT_MAX_RSSI      138
225 #define WI_LUCENT_DBM_OFFSET    149
226
227 #define WI_RSSI_TO_DBM(sc, rssi) (MIN((sc)->sc_max_rssi, \
228     MAX((sc)->sc_min_rssi, (rssi))) - (sc)->sc_dbm_offset)
229
230 #define WI_LOCK(_sc)            mtx_lock(&(_sc)->sc_mtx)
231 #define WI_UNLOCK(_sc)          mtx_unlock(&(_sc)->sc_mtx)
232 #define WI_LOCK_ASSERT(_sc)     mtx_assert(&(_sc)->sc_mtx, MA_OWNED)
233
234 int     wi_attach(device_t);
235 int     wi_detach(device_t);
236 void    wi_shutdown(device_t);
237 int     wi_alloc(device_t, int);
238 void    wi_free(device_t);
239 extern devclass_t wi_devclass;
240 void    wi_init(void *);
241 void    wi_intr(void *);
242 int     wi_mgmt_xmit(struct wi_softc *, caddr_t, int);
243 void    wi_stop(struct ifnet *, int);
244 int     wi_symbol_load_firm(struct wi_softc *, const void *, int, const void *, int);