Fix the infinite-watchdog timeout problem. the pending_txs count was not
[dragonfly.git] / sys / dev / netif / 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: src/sys/dev/wi/if_wivar.h,v 1.22 2004/04/01 00:38:45 sam Exp $
35  * $DragonFly: src/sys/dev/netif/wi/if_wivar.h,v 1.8 2005/06/30 15:57:27 joerg Exp $
36  */
37
38 #if 0
39 #define WICACHE                 /* turn on signal strength cache code */  
40 #define MAXWICACHE      10
41 #endif
42
43 /*
44  * Encryption controls. We can enable or disable encryption as
45  * well as specify up to 4 encryption keys. We can also specify
46  * which of the four keys will be used for transmit encryption.
47  */
48 #define WI_RID_ENCRYPTION       0xFC20
49 #define WI_RID_AUTHTYPE         0xFC21
50 #define WI_RID_DEFLT_CRYPT_KEYS 0xFCB0
51 #define WI_RID_TX_CRYPT_KEY     0xFCB1
52 #define WI_RID_WEP_AVAIL        0xFD4F
53 #define WI_RID_P2_TX_CRYPT_KEY  0xFC23
54 #define WI_RID_P2_CRYPT_KEY0    0xFC24
55 #define WI_RID_P2_CRYPT_KEY1    0xFC25
56 #define WI_RID_MICROWAVE_OVEN   0xFC25
57 #define WI_RID_P2_CRYPT_KEY2    0xFC26
58 #define WI_RID_P2_CRYPT_KEY3    0xFC27
59 #define WI_RID_P2_ENCRYPTION    0xFC28
60 #define WI_RID_ROAMING_MODE     0xFC2D
61 #define WI_RID_CUR_TX_RATE      0xFD44 /* current TX rate */
62
63 struct wi_softc {
64         struct ieee80211com     sc_ic;
65         int                     (*sc_newstate)(struct ieee80211com *,
66                                         enum ieee80211_state, int);
67         int                     wi_gone;
68         int                     sc_enabled;
69         int                     sc_reset;
70         int                     sc_firmware_type;
71 #define WI_NOTYPE       0
72 #define WI_LUCENT       1
73 #define WI_INTERSIL     2
74 #define WI_SYMBOL       3
75         int                     sc_pri_firmware_ver;    /* Primary firmware */
76         int                     sc_sta_firmware_ver;    /* Station firmware */
77
78         int                     wi_bus_type;    /* Bus attachment type */
79         struct resource *       local;
80         int                     local_rid;
81         struct resource *       iobase;
82         int                     iobase_rid;
83         struct resource *       irq;
84         int                     irq_rid;
85         struct resource *       mem;
86         int                     mem_rid;
87         bus_space_handle_t      wi_localhandle;
88         bus_space_tag_t         wi_localtag;
89         bus_space_handle_t      wi_bhandle;
90         bus_space_tag_t         wi_btag;
91         bus_space_handle_t      wi_bmemhandle;
92         bus_space_tag_t         wi_bmemtag;
93         void *                  wi_intrhand;
94         int                     wi_io_addr;
95         int                     wi_cmd_count;
96
97         struct bpf_if           *sc_drvbpf;
98         int                     sc_flags;
99         int                     sc_if_flags;
100         int                     sc_bap_id;
101         int                     sc_bap_off;
102
103         u_int16_t               sc_procframe;
104         u_int16_t               sc_portnum;
105
106         /* RSSI interpretation */
107         u_int16_t               sc_min_rssi;    /* clamp sc_min_rssi < RSSI */
108         u_int16_t               sc_max_rssi;    /* clamp RSSI < sc_max_rssi */
109         u_int16_t               sc_dbm_offset;  /* dBm ~ RSSI - sc_dbm_offset */
110
111         u_int16_t               sc_max_datalen;
112         u_int16_t               sc_system_scale;
113         u_int16_t               sc_cnfauthmode;
114         u_int16_t               sc_roaming_mode;
115         u_int16_t               sc_microwave_oven;
116         u_int16_t               sc_authtype;
117
118         int                     sc_nodelen;
119         char                    sc_nodename[IEEE80211_NWID_LEN];
120         char                    sc_net_name[IEEE80211_NWID_LEN];
121
122         int                     sc_buflen;              /* TX buffer size */
123         int                     sc_ntxbuf;
124 #define WI_NTXBUF       3
125         struct {
126                 int             d_fid;
127                 int             d_len;
128         }                       sc_txd[WI_NTXBUF];      /* TX buffers */
129         int                     sc_txnext;              /* index of next TX */
130         int                     sc_txcur;               /* index of current TX*/
131         int                     sc_tx_timer;
132         int                     sc_scan_timer;
133         int                     sc_syn_timer;
134
135         struct wi_counters      sc_stats;
136         u_int16_t               sc_ibss_port;
137
138 #define WI_MAXAPINFO            30
139         struct wi_apinfo        sc_aps[WI_MAXAPINFO];
140         int                     sc_naps;
141
142         struct {
143                 u_int16_t               wi_sleep;
144                 u_int16_t               wi_delaysupp;
145                 u_int16_t               wi_txsupp;
146                 u_int16_t               wi_monitor;
147                 u_int16_t               wi_ledtest;
148                 u_int16_t               wi_ledtest_param0;
149                 u_int16_t               wi_ledtest_param1;
150                 u_int16_t               wi_conttx;
151                 u_int16_t               wi_conttx_param0;
152                 u_int16_t               wi_contrx;
153                 u_int16_t               wi_sigstate;
154                 u_int16_t               wi_sigstate_param0;
155                 u_int16_t               wi_confbits;
156                 u_int16_t               wi_confbits_param0;
157         } wi_debug;
158
159         int                     sc_false_syns;
160
161         u_int16_t               sc_txbuf[IEEE80211_MAX_LEN/2];
162
163         union {
164                 struct wi_tx_radiotap_header th;
165                 u_int8_t        pad[64];
166         } u_tx_rt;
167         int                     sc_tx_th_len;
168         union {
169                 struct wi_rx_radiotap_header th;
170                 u_int8_t        pad[64];
171         } u_rx_rt;
172         int                     sc_rx_th_len;
173 };
174 #define sc_if                   sc_ic.ic_if
175 #define sc_tx_th                u_tx_rt.th
176 #define sc_rx_th                u_rx_rt.th
177
178 /* maximum consecutive false change-of-BSSID indications */
179 #define WI_MAX_FALSE_SYNS               10      
180
181 #define WI_SCAN_INQWAIT                 3       /* wait sec before inquire */
182 #define WI_SCAN_WAIT                    5       /* maximum scan wait */
183
184 #define WI_FLAGS_ATTACHED               0x0001
185 #define WI_FLAGS_INITIALIZED            0x0002
186 #define WI_FLAGS_OUTRANGE               0x0004
187 #define WI_FLAGS_HAS_MOR                0x0010
188 #define WI_FLAGS_HAS_ROAMING            0x0020
189 #define WI_FLAGS_HAS_DIVERSITY          0x0040
190 #define WI_FLAGS_HAS_SYSSCALE           0x0080
191 #define WI_FLAGS_BUG_AUTOINC            0x0100
192 #define WI_FLAGS_HAS_FRAGTHR            0x0200
193 #define WI_FLAGS_HAS_DBMADJUST          0x0400
194
195 struct wi_card_ident {
196         u_int16_t       card_id;
197         char            *card_name;
198         u_int8_t        firm_type;
199 };
200
201 #define WI_PRISM_MIN_RSSI       0x1b
202 #define WI_PRISM_MAX_RSSI       0x9a
203 #define WI_PRISM_DBM_OFFSET     100 /* XXX */
204
205 #define WI_LUCENT_MIN_RSSI      47
206 #define WI_LUCENT_MAX_RSSI      138
207 #define WI_LUCENT_DBM_OFFSET    149
208
209 #define WI_RSSI_TO_DBM(sc, rssi) (MIN((sc)->sc_max_rssi, \
210     MAX((sc)->sc_min_rssi, (rssi))) - (sc)->sc_dbm_offset)
211
212 /*
213  * Various compat hacks/kludges
214  */
215 #define WI_LOCK_DECL()
216 #define WI_LOCK(_sc)            crit_enter()
217 #define WI_UNLOCK(_sc)          crit_exit()
218
219 int     wi_attach(device_t);
220 int     wi_detach(device_t);
221 void    wi_shutdown(device_t);
222 int     wi_alloc(device_t, int);
223 void    wi_free(device_t);
224 extern devclass_t wi_devclass;
225 void    wi_init(void *);
226 void    wi_intr(void *);
227 void    wi_stop(struct ifnet *, int);
228 int     wi_symbol_load_firm(struct wi_softc *, const void *, int, const void *, int);