if_wivar.h revision 147256
1139749Simp/*- 293611Simp * Copyright (c) 2002 393611Simp * M Warner Losh <imp@freebsd.org>. All rights reserved. 493611Simp * Copyright (c) 1997, 1998, 1999 593611Simp * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved. 693611Simp * 793611Simp * Redistribution and use in source and binary forms, with or without 893611Simp * modification, are permitted provided that the following conditions 993611Simp * are met: 1093611Simp * 1. Redistributions of source code must retain the above copyright 1193611Simp * notice, this list of conditions and the following disclaimer. 1293611Simp * 2. Redistributions in binary form must reproduce the above copyright 1393611Simp * notice, this list of conditions and the following disclaimer in the 1493611Simp * documentation and/or other materials provided with the distribution. 1593611Simp * 3. All advertising materials mentioning features or use of this software 1693611Simp * must display the following acknowledgement: 1793611Simp * This product includes software developed by Bill Paul. 1893611Simp * 4. Neither the name of the author nor the names of any co-contributors 1993611Simp * may be used to endorse or promote products derived from this software 2093611Simp * without specific prior written permission. 2193611Simp * 2293611Simp * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND 2393611Simp * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2493611Simp * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2593611Simp * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD 2693611Simp * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 2793611Simp * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 2893611Simp * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 2993611Simp * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 3093611Simp * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 3193611Simp * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 3293611Simp * THE POSSIBILITY OF SUCH DAMAGE. 3393611Simp * 3493611Simp * $FreeBSD: head/sys/dev/wi/if_wivar.h 147256 2005-06-10 16:49:24Z brooks $ 3593611Simp */ 3693611Simp 37109323Ssam#if 0 3893611Simp#define WICACHE /* turn on signal strength cache code */ 3993611Simp#define MAXWICACHE 10 40109323Ssam#endif 4193611Simp 4293611Simp/* 4393611Simp * Encryption controls. We can enable or disable encryption as 4493611Simp * well as specify up to 4 encryption keys. We can also specify 4593611Simp * which of the four keys will be used for transmit encryption. 4693611Simp */ 4793611Simp#define WI_RID_ENCRYPTION 0xFC20 4893611Simp#define WI_RID_AUTHTYPE 0xFC21 4993611Simp#define WI_RID_DEFLT_CRYPT_KEYS 0xFCB0 5093611Simp#define WI_RID_TX_CRYPT_KEY 0xFCB1 5193611Simp#define WI_RID_WEP_AVAIL 0xFD4F 5293611Simp#define WI_RID_P2_TX_CRYPT_KEY 0xFC23 5393611Simp#define WI_RID_P2_CRYPT_KEY0 0xFC24 5493611Simp#define WI_RID_P2_CRYPT_KEY1 0xFC25 5593611Simp#define WI_RID_MICROWAVE_OVEN 0xFC25 5693611Simp#define WI_RID_P2_CRYPT_KEY2 0xFC26 5793611Simp#define WI_RID_P2_CRYPT_KEY3 0xFC27 5893611Simp#define WI_RID_P2_ENCRYPTION 0xFC28 5993611Simp#define WI_RID_ROAMING_MODE 0xFC2D 6093611Simp#define WI_RID_CUR_TX_RATE 0xFD44 /* current TX rate */ 6193611Simp 62138571Ssam#define WI_MAX_AID 256 /* max stations for ap operation */ 63138571Ssam 64109323Ssamstruct wi_softc { 65147256Sbrooks struct ifnet *sc_ifp; 66109323Ssam struct ieee80211com sc_ic; 67117812Ssam int (*sc_newstate)(struct ieee80211com *, 68117812Ssam enum ieee80211_state, int); 69109323Ssam device_t sc_dev; 70109323Ssam#if __FreeBSD_version >= 500000 71109323Ssam struct mtx sc_mtx; 72109323Ssam#endif 73109323Ssam int sc_unit; 74109323Ssam int wi_gone; 75109323Ssam int sc_enabled; 76112362Simp int sc_reset; 77109323Ssam int sc_firmware_type; 78109323Ssam#define WI_NOTYPE 0 79109323Ssam#define WI_LUCENT 1 80109323Ssam#define WI_INTERSIL 2 81109323Ssam#define WI_SYMBOL 3 82109323Ssam int sc_pri_firmware_ver; /* Primary firmware */ 83109323Ssam int sc_sta_firmware_ver; /* Station firmware */ 8493611Simp 85109323Ssam int wi_bus_type; /* Bus attachment type */ 8693611Simp struct resource * local; 87109323Ssam int local_rid; 8893611Simp struct resource * iobase; 89109323Ssam int iobase_rid; 9093611Simp struct resource * irq; 91109323Ssam int irq_rid; 9293611Simp struct resource * mem; 93109323Ssam int mem_rid; 9493611Simp bus_space_handle_t wi_localhandle; 9593611Simp bus_space_tag_t wi_localtag; 9693611Simp bus_space_handle_t wi_bhandle; 9793611Simp bus_space_tag_t wi_btag; 9893611Simp bus_space_handle_t wi_bmemhandle; 9993611Simp bus_space_tag_t wi_bmemtag; 10093611Simp void * wi_intrhand; 10193733Simp int wi_io_addr; 102123339Simp int wi_cmd_count; 103109323Ssam 104109323Ssam struct bpf_if *sc_drvbpf; 105109323Ssam int sc_flags; 106109323Ssam int sc_if_flags; 107109323Ssam int sc_bap_id; 108109323Ssam int sc_bap_off; 109109323Ssam 110109323Ssam u_int16_t sc_procframe; 111109323Ssam u_int16_t sc_portnum; 112109323Ssam 113119784Ssam /* RSSI interpretation */ 114119784Ssam u_int16_t sc_min_rssi; /* clamp sc_min_rssi < RSSI */ 115119784Ssam u_int16_t sc_max_rssi; /* clamp RSSI < sc_max_rssi */ 116119784Ssam u_int16_t sc_dbm_offset; /* dBm ~ RSSI - sc_dbm_offset */ 117119784Ssam 118109323Ssam u_int16_t sc_max_datalen; 119109323Ssam u_int16_t sc_system_scale; 120109323Ssam u_int16_t sc_cnfauthmode; 121109323Ssam u_int16_t sc_roaming_mode; 122109323Ssam u_int16_t sc_microwave_oven; 123109323Ssam u_int16_t sc_authtype; 124109323Ssam 125109323Ssam int sc_nodelen; 126109323Ssam char sc_nodename[IEEE80211_NWID_LEN]; 127109323Ssam char sc_net_name[IEEE80211_NWID_LEN]; 128109323Ssam 129109323Ssam int sc_buflen; /* TX buffer size */ 130112363Simp int sc_ntxbuf; 131109323Ssam#define WI_NTXBUF 3 13293611Simp struct { 133109323Ssam int d_fid; 134109323Ssam int d_len; 135109323Ssam } sc_txd[WI_NTXBUF]; /* TX buffers */ 136109323Ssam int sc_txnext; /* index of next TX */ 137109323Ssam int sc_txcur; /* index of current TX*/ 138109323Ssam int sc_tx_timer; 139109323Ssam int sc_scan_timer; 140109323Ssam 141109323Ssam struct wi_counters sc_stats; 142109323Ssam u_int16_t sc_ibss_port; 143109323Ssam 144109323Ssam#define WI_MAXAPINFO 30 145109323Ssam struct wi_apinfo sc_aps[WI_MAXAPINFO]; 146109323Ssam int sc_naps; 147109323Ssam 148109323Ssam struct { 14993611Simp u_int16_t wi_sleep; 15093611Simp u_int16_t wi_delaysupp; 15193611Simp u_int16_t wi_txsupp; 15293611Simp u_int16_t wi_monitor; 15393611Simp u_int16_t wi_ledtest; 15493611Simp u_int16_t wi_ledtest_param0; 15593611Simp u_int16_t wi_ledtest_param1; 15693611Simp u_int16_t wi_conttx; 15793611Simp u_int16_t wi_conttx_param0; 15893611Simp u_int16_t wi_contrx; 15993611Simp u_int16_t wi_sigstate; 16093611Simp u_int16_t wi_sigstate_param0; 16193611Simp u_int16_t wi_confbits; 16293611Simp u_int16_t wi_confbits_param0; 16393611Simp } wi_debug; 16493611Simp 165138571Ssam struct timeval sc_last_syn; 166109323Ssam int sc_false_syns; 167109323Ssam 168109323Ssam u_int16_t sc_txbuf[IEEE80211_MAX_LEN/2]; 169119784Ssam 170119784Ssam union { 171119784Ssam struct wi_tx_radiotap_header th; 172119784Ssam u_int8_t pad[64]; 173119784Ssam } u_tx_rt; 174127698Ssam int sc_tx_th_len; 175119784Ssam union { 176119784Ssam struct wi_rx_radiotap_header th; 177119784Ssam u_int8_t pad[64]; 178119784Ssam } u_rx_rt; 179127698Ssam int sc_rx_th_len; 18093611Simp}; 181119784Ssam#define sc_tx_th u_tx_rt.th 182119784Ssam#define sc_rx_th u_rx_rt.th 18393611Simp 184109323Ssam/* maximum consecutive false change-of-BSSID indications */ 185109323Ssam#define WI_MAX_FALSE_SYNS 10 186109323Ssam 187109323Ssam#define WI_SCAN_INQWAIT 3 /* wait sec before inquire */ 188109323Ssam#define WI_SCAN_WAIT 5 /* maximum scan wait */ 189109323Ssam 190109323Ssam#define WI_FLAGS_ATTACHED 0x0001 191109323Ssam#define WI_FLAGS_INITIALIZED 0x0002 192109323Ssam#define WI_FLAGS_OUTRANGE 0x0004 193109323Ssam#define WI_FLAGS_HAS_MOR 0x0010 194109323Ssam#define WI_FLAGS_HAS_ROAMING 0x0020 195109323Ssam#define WI_FLAGS_HAS_DIVERSITY 0x0040 196109323Ssam#define WI_FLAGS_HAS_SYSSCALE 0x0080 197109323Ssam#define WI_FLAGS_BUG_AUTOINC 0x0100 198109323Ssam#define WI_FLAGS_HAS_FRAGTHR 0x0200 199109323Ssam#define WI_FLAGS_HAS_DBMADJUST 0x0400 200109323Ssam 20193825Simpstruct wi_card_ident { 20293825Simp u_int16_t card_id; 20393825Simp char *card_name; 20493825Simp u_int8_t firm_type; 20593825Simp}; 20693825Simp 207119784Ssam#define WI_PRISM_MIN_RSSI 0x1b 208119784Ssam#define WI_PRISM_MAX_RSSI 0x9a 209119784Ssam#define WI_PRISM_DBM_OFFSET 100 /* XXX */ 210119784Ssam 211119784Ssam#define WI_LUCENT_MIN_RSSI 47 212119784Ssam#define WI_LUCENT_MAX_RSSI 138 213119784Ssam#define WI_LUCENT_DBM_OFFSET 149 214119784Ssam 215119784Ssam#define WI_RSSI_TO_DBM(sc, rssi) (MIN((sc)->sc_max_rssi, \ 216119784Ssam MAX((sc)->sc_min_rssi, (rssi))) - (sc)->sc_dbm_offset) 217119784Ssam 21895534Simp#if __FreeBSD_version < 500000 21995534Simp/* 22095534Simp * Various compat hacks/kludges 22195534Simp */ 22295534Simp#define le16toh(x) (x) 22395534Simp#define htole16(x) (x) 22495534Simp#define ifaddr_byindex(idx) ifnet_addrs[(idx) - 1]; 225109323Ssam#define WI_LOCK_DECL() int s 226109323Ssam#define WI_LOCK(_sc) s = splimp() 227109323Ssam#define WI_UNLOCK(_sc) splx(s) 22895534Simp#else 229109323Ssam#define WI_LOCK_DECL() 230109323Ssam#define WI_LOCK(_sc) mtx_lock(&(_sc)->sc_mtx) 231109323Ssam#define WI_UNLOCK(_sc) mtx_unlock(&(_sc)->sc_mtx) 23295534Simp#endif 23393611Simp 234109323Ssamint wi_attach(device_t); 235109323Ssamint wi_detach(device_t); 236109323Ssamvoid wi_shutdown(device_t); 237109323Ssamint wi_alloc(device_t, int); 238109323Ssamvoid wi_free(device_t); 23993611Simpextern devclass_t wi_devclass; 240109323Ssamvoid wi_init(void *); 241109323Ssamvoid wi_intr(void *); 242109323Ssamint wi_mgmt_xmit(struct wi_softc *, caddr_t, int); 243109323Ssamvoid wi_stop(struct ifnet *, int); 244109323Ssamint wi_symbol_load_firm(struct wi_softc *, const void *, int, const void *, int); 245