if_wivar.h revision 127698
193611Simp/* 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 127698 2004-04-01 00:38:45Z sam $ 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 62109323Ssamstruct wi_softc { 63109323Ssam struct ieee80211com sc_ic; 64117812Ssam int (*sc_newstate)(struct ieee80211com *, 65117812Ssam enum ieee80211_state, int); 66109323Ssam device_t sc_dev; 67109323Ssam#if __FreeBSD_version >= 500000 68109323Ssam struct mtx sc_mtx; 69109323Ssam#endif 70109323Ssam int sc_unit; 71109323Ssam int wi_gone; 72109323Ssam int sc_enabled; 73112362Simp int sc_reset; 74109323Ssam int sc_firmware_type; 75109323Ssam#define WI_NOTYPE 0 76109323Ssam#define WI_LUCENT 1 77109323Ssam#define WI_INTERSIL 2 78109323Ssam#define WI_SYMBOL 3 79109323Ssam int sc_pri_firmware_ver; /* Primary firmware */ 80109323Ssam int sc_sta_firmware_ver; /* Station firmware */ 8193611Simp 82109323Ssam int wi_bus_type; /* Bus attachment type */ 8393611Simp struct resource * local; 84109323Ssam int local_rid; 8593611Simp struct resource * iobase; 86109323Ssam int iobase_rid; 8793611Simp struct resource * irq; 88109323Ssam int irq_rid; 8993611Simp struct resource * mem; 90109323Ssam int mem_rid; 9193611Simp bus_space_handle_t wi_localhandle; 9293611Simp bus_space_tag_t wi_localtag; 9393611Simp bus_space_handle_t wi_bhandle; 9493611Simp bus_space_tag_t wi_btag; 9593611Simp bus_space_handle_t wi_bmemhandle; 9693611Simp bus_space_tag_t wi_bmemtag; 9793611Simp void * wi_intrhand; 9893733Simp int wi_io_addr; 99123339Simp int wi_cmd_count; 100109323Ssam 101109323Ssam struct bpf_if *sc_drvbpf; 102109323Ssam int sc_flags; 103109323Ssam int sc_if_flags; 104109323Ssam int sc_bap_id; 105109323Ssam int sc_bap_off; 106109323Ssam 107109323Ssam u_int16_t sc_procframe; 108109323Ssam u_int16_t sc_portnum; 109109323Ssam 110119784Ssam /* RSSI interpretation */ 111119784Ssam u_int16_t sc_min_rssi; /* clamp sc_min_rssi < RSSI */ 112119784Ssam u_int16_t sc_max_rssi; /* clamp RSSI < sc_max_rssi */ 113119784Ssam u_int16_t sc_dbm_offset; /* dBm ~ RSSI - sc_dbm_offset */ 114119784Ssam 115109323Ssam u_int16_t sc_max_datalen; 116109323Ssam u_int16_t sc_system_scale; 117109323Ssam u_int16_t sc_cnfauthmode; 118109323Ssam u_int16_t sc_roaming_mode; 119109323Ssam u_int16_t sc_microwave_oven; 120109323Ssam u_int16_t sc_authtype; 121109323Ssam 122109323Ssam int sc_nodelen; 123109323Ssam char sc_nodename[IEEE80211_NWID_LEN]; 124109323Ssam char sc_net_name[IEEE80211_NWID_LEN]; 125109323Ssam 126109323Ssam int sc_buflen; /* TX buffer size */ 127112363Simp int sc_ntxbuf; 128109323Ssam#define WI_NTXBUF 3 12993611Simp struct { 130109323Ssam int d_fid; 131109323Ssam int d_len; 132109323Ssam } sc_txd[WI_NTXBUF]; /* TX buffers */ 133109323Ssam int sc_txnext; /* index of next TX */ 134109323Ssam int sc_txcur; /* index of current TX*/ 135109323Ssam int sc_tx_timer; 136109323Ssam int sc_scan_timer; 137109323Ssam int sc_syn_timer; 138109323Ssam 139109323Ssam struct wi_counters sc_stats; 140109323Ssam u_int16_t sc_ibss_port; 141109323Ssam 142109323Ssam#define WI_MAXAPINFO 30 143109323Ssam struct wi_apinfo sc_aps[WI_MAXAPINFO]; 144109323Ssam int sc_naps; 145109323Ssam 146109323Ssam struct { 14793611Simp u_int16_t wi_sleep; 14893611Simp u_int16_t wi_delaysupp; 14993611Simp u_int16_t wi_txsupp; 15093611Simp u_int16_t wi_monitor; 15193611Simp u_int16_t wi_ledtest; 15293611Simp u_int16_t wi_ledtest_param0; 15393611Simp u_int16_t wi_ledtest_param1; 15493611Simp u_int16_t wi_conttx; 15593611Simp u_int16_t wi_conttx_param0; 15693611Simp u_int16_t wi_contrx; 15793611Simp u_int16_t wi_sigstate; 15893611Simp u_int16_t wi_sigstate_param0; 15993611Simp u_int16_t wi_confbits; 16093611Simp u_int16_t wi_confbits_param0; 16193611Simp } wi_debug; 16293611Simp 163109323Ssam int sc_false_syns; 164109323Ssam 165109323Ssam u_int16_t sc_txbuf[IEEE80211_MAX_LEN/2]; 166119784Ssam 167119784Ssam union { 168119784Ssam struct wi_tx_radiotap_header th; 169119784Ssam u_int8_t pad[64]; 170119784Ssam } u_tx_rt; 171127698Ssam int sc_tx_th_len; 172119784Ssam union { 173119784Ssam struct wi_rx_radiotap_header th; 174119784Ssam u_int8_t pad[64]; 175119784Ssam } u_rx_rt; 176127698Ssam int sc_rx_th_len; 17793611Simp}; 178109323Ssam#define sc_if sc_ic.ic_if 179119784Ssam#define sc_tx_th u_tx_rt.th 180119784Ssam#define sc_rx_th u_rx_rt.th 18193611Simp 182109323Ssam/* maximum consecutive false change-of-BSSID indications */ 183109323Ssam#define WI_MAX_FALSE_SYNS 10 184109323Ssam 185109323Ssam#define WI_SCAN_INQWAIT 3 /* wait sec before inquire */ 186109323Ssam#define WI_SCAN_WAIT 5 /* maximum scan wait */ 187109323Ssam 188109323Ssam#define WI_FLAGS_ATTACHED 0x0001 189109323Ssam#define WI_FLAGS_INITIALIZED 0x0002 190109323Ssam#define WI_FLAGS_OUTRANGE 0x0004 191109323Ssam#define WI_FLAGS_HAS_MOR 0x0010 192109323Ssam#define WI_FLAGS_HAS_ROAMING 0x0020 193109323Ssam#define WI_FLAGS_HAS_DIVERSITY 0x0040 194109323Ssam#define WI_FLAGS_HAS_SYSSCALE 0x0080 195109323Ssam#define WI_FLAGS_BUG_AUTOINC 0x0100 196109323Ssam#define WI_FLAGS_HAS_FRAGTHR 0x0200 197109323Ssam#define WI_FLAGS_HAS_DBMADJUST 0x0400 198109323Ssam 19993825Simpstruct wi_card_ident { 20093825Simp u_int16_t card_id; 20193825Simp char *card_name; 20293825Simp u_int8_t firm_type; 20393825Simp}; 20493825Simp 205119784Ssam#define WI_PRISM_MIN_RSSI 0x1b 206119784Ssam#define WI_PRISM_MAX_RSSI 0x9a 207119784Ssam#define WI_PRISM_DBM_OFFSET 100 /* XXX */ 208119784Ssam 209119784Ssam#define WI_LUCENT_MIN_RSSI 47 210119784Ssam#define WI_LUCENT_MAX_RSSI 138 211119784Ssam#define WI_LUCENT_DBM_OFFSET 149 212119784Ssam 213119784Ssam#define WI_RSSI_TO_DBM(sc, rssi) (MIN((sc)->sc_max_rssi, \ 214119784Ssam MAX((sc)->sc_min_rssi, (rssi))) - (sc)->sc_dbm_offset) 215119784Ssam 21695534Simp#if __FreeBSD_version < 500000 21795534Simp/* 21895534Simp * Various compat hacks/kludges 21995534Simp */ 22095534Simp#define le16toh(x) (x) 22195534Simp#define htole16(x) (x) 22295534Simp#define ifaddr_byindex(idx) ifnet_addrs[(idx) - 1]; 223109323Ssam#define WI_LOCK_DECL() int s 224109323Ssam#define WI_LOCK(_sc) s = splimp() 225109323Ssam#define WI_UNLOCK(_sc) splx(s) 22695534Simp#else 227109323Ssam#define WI_LOCK_DECL() 228109323Ssam#define WI_LOCK(_sc) mtx_lock(&(_sc)->sc_mtx) 229109323Ssam#define WI_UNLOCK(_sc) mtx_unlock(&(_sc)->sc_mtx) 23095534Simp#endif 23193611Simp 232109323Ssamint wi_attach(device_t); 233109323Ssamint wi_detach(device_t); 234109323Ssamvoid wi_shutdown(device_t); 235109323Ssamint wi_alloc(device_t, int); 236109323Ssamvoid wi_free(device_t); 23793611Simpextern devclass_t wi_devclass; 238109323Ssamvoid wi_init(void *); 239109323Ssamvoid wi_intr(void *); 240109323Ssamint wi_mgmt_xmit(struct wi_softc *, caddr_t, int); 241109323Ssamvoid wi_stop(struct ifnet *, int); 242109323Ssamint wi_symbol_load_firm(struct wi_softc *, const void *, int, const void *, int); 243