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$ 3593611Simp */ 3693611Simp 3793611Simp/* 3893611Simp * Encryption controls. We can enable or disable encryption as 3993611Simp * well as specify up to 4 encryption keys. We can also specify 4093611Simp * which of the four keys will be used for transmit encryption. 4193611Simp */ 4293611Simp#define WI_RID_ENCRYPTION 0xFC20 4393611Simp#define WI_RID_AUTHTYPE 0xFC21 4493611Simp#define WI_RID_DEFLT_CRYPT_KEYS 0xFCB0 4593611Simp#define WI_RID_TX_CRYPT_KEY 0xFCB1 4693611Simp#define WI_RID_WEP_AVAIL 0xFD4F 4793611Simp#define WI_RID_P2_TX_CRYPT_KEY 0xFC23 4893611Simp#define WI_RID_P2_CRYPT_KEY0 0xFC24 4993611Simp#define WI_RID_P2_CRYPT_KEY1 0xFC25 5093611Simp#define WI_RID_MICROWAVE_OVEN 0xFC25 5193611Simp#define WI_RID_P2_CRYPT_KEY2 0xFC26 5293611Simp#define WI_RID_P2_CRYPT_KEY3 0xFC27 5393611Simp#define WI_RID_P2_ENCRYPTION 0xFC28 5493611Simp#define WI_RID_ROAMING_MODE 0xFC2D 5593611Simp#define WI_RID_CUR_TX_RATE 0xFD44 /* current TX rate */ 5693611Simp 57138571Ssam#define WI_MAX_AID 256 /* max stations for ap operation */ 58138571Ssam 59178354Ssamstruct wi_vap { 60178354Ssam struct ieee80211vap wv_vap; 61178354Ssam 62192468Ssam void (*wv_recv_mgmt)(struct ieee80211_node *, struct mbuf *, 63283535Sadrian int, const struct ieee80211_rx_stats *rxs, int, int); 64178354Ssam int (*wv_newstate)(struct ieee80211vap *, 65178354Ssam enum ieee80211_state, int); 66178354Ssam}; 67178354Ssam#define WI_VAP(vap) ((struct wi_vap *)(vap)) 68178354Ssam 69109323Ssamstruct wi_softc { 70287197Sglebius struct ieee80211com sc_ic; 71287197Sglebius struct mbufq sc_snd; 72109323Ssam device_t sc_dev; 73109323Ssam struct mtx sc_mtx; 74165089Ssam struct callout sc_watchdog; 75109323Ssam int sc_unit; 76109323Ssam int wi_gone; 77109323Ssam int sc_enabled; 78112362Simp int sc_reset; 79109323Ssam int sc_firmware_type; 80109323Ssam#define WI_NOTYPE 0 81109323Ssam#define WI_LUCENT 1 82109323Ssam#define WI_INTERSIL 2 83109323Ssam#define WI_SYMBOL 3 84109323Ssam int sc_pri_firmware_ver; /* Primary firmware */ 85109323Ssam int sc_sta_firmware_ver; /* Station firmware */ 86180919Simp unsigned int sc_nic_id; /* Type of NIC */ 87180919Simp char * sc_nic_name; 8893611Simp 89109323Ssam int wi_bus_type; /* Bus attachment type */ 9093611Simp struct resource * local; 91109323Ssam int local_rid; 9293611Simp struct resource * iobase; 93109323Ssam int iobase_rid; 9493611Simp struct resource * irq; 95109323Ssam int irq_rid; 9693611Simp struct resource * mem; 97109323Ssam int mem_rid; 9893611Simp bus_space_handle_t wi_localhandle; 9993611Simp bus_space_tag_t wi_localtag; 10093611Simp bus_space_handle_t wi_bhandle; 10193611Simp bus_space_tag_t wi_btag; 10293611Simp bus_space_handle_t wi_bmemhandle; 10393611Simp bus_space_tag_t wi_bmemtag; 10493611Simp void * wi_intrhand; 105170530Ssam struct ieee80211_channel *wi_channel; 10693733Simp int wi_io_addr; 107123339Simp int wi_cmd_count; 108109323Ssam 109109323Ssam int sc_flags; 110109323Ssam int sc_bap_id; 111109323Ssam int sc_bap_off; 112178354Ssam 113178354Ssam int sc_porttype; 114109323Ssam u_int16_t sc_portnum; 115178354Ssam u_int16_t sc_encryption; 116178354Ssam u_int16_t sc_monitor_port; 117300238Savos u_int16_t sc_chanmask; 118109323Ssam 119119784Ssam /* RSSI interpretation */ 120119784Ssam u_int16_t sc_min_rssi; /* clamp sc_min_rssi < RSSI */ 121119784Ssam u_int16_t sc_max_rssi; /* clamp RSSI < sc_max_rssi */ 122119784Ssam u_int16_t sc_dbm_offset; /* dBm ~ RSSI - sc_dbm_offset */ 123119784Ssam 124109323Ssam int sc_buflen; /* TX buffer size */ 125112363Simp int sc_ntxbuf; 126109323Ssam#define WI_NTXBUF 3 12793611Simp struct { 128109323Ssam int d_fid; 129109323Ssam int d_len; 130109323Ssam } sc_txd[WI_NTXBUF]; /* TX buffers */ 131109323Ssam int sc_txnext; /* index of next TX */ 132109323Ssam int sc_txcur; /* index of current TX*/ 133109323Ssam int sc_tx_timer; 134109323Ssam 135109323Ssam struct wi_counters sc_stats; 136109323Ssam u_int16_t sc_ibss_port; 137109323Ssam 138138571Ssam struct timeval sc_last_syn; 139109323Ssam int sc_false_syns; 140109323Ssam 141109323Ssam u_int16_t sc_txbuf[IEEE80211_MAX_LEN/2]; 142119784Ssam 143178354Ssam struct wi_tx_radiotap_header sc_tx_th; 144178354Ssam struct wi_rx_radiotap_header sc_rx_th; 14593611Simp}; 14693611Simp 147109323Ssam/* maximum consecutive false change-of-BSSID indications */ 148109323Ssam#define WI_MAX_FALSE_SYNS 10 149109323Ssam 150178354Ssam#define WI_FLAGS_HAS_ENHSECURITY 0x0001 151178354Ssam#define WI_FLAGS_HAS_WPASUPPORT 0x0002 152109323Ssam#define WI_FLAGS_HAS_ROAMING 0x0020 153109323Ssam#define WI_FLAGS_HAS_FRAGTHR 0x0200 154109323Ssam#define WI_FLAGS_HAS_DBMADJUST 0x0400 155287197Sglebius#define WI_FLAGS_RUNNING 0x0800 156287197Sglebius#define WI_FLAGS_PROMISC 0x1000 157109323Ssam 15893825Simpstruct wi_card_ident { 15993825Simp u_int16_t card_id; 16093825Simp char *card_name; 16193825Simp u_int8_t firm_type; 16293825Simp}; 16393825Simp 164119784Ssam#define WI_PRISM_MIN_RSSI 0x1b 165119784Ssam#define WI_PRISM_MAX_RSSI 0x9a 166119784Ssam#define WI_PRISM_DBM_OFFSET 100 /* XXX */ 167119784Ssam 168119784Ssam#define WI_LUCENT_MIN_RSSI 47 169119784Ssam#define WI_LUCENT_MAX_RSSI 138 170119784Ssam#define WI_LUCENT_DBM_OFFSET 149 171119784Ssam 172119784Ssam#define WI_RSSI_TO_DBM(sc, rssi) (MIN((sc)->sc_max_rssi, \ 173119784Ssam MAX((sc)->sc_min_rssi, (rssi))) - (sc)->sc_dbm_offset) 174119784Ssam 175109323Ssam#define WI_LOCK(_sc) mtx_lock(&(_sc)->sc_mtx) 176109323Ssam#define WI_UNLOCK(_sc) mtx_unlock(&(_sc)->sc_mtx) 177165087Ssam#define WI_LOCK_ASSERT(_sc) mtx_assert(&(_sc)->sc_mtx, MA_OWNED) 17893611Simp 179109323Ssamint wi_attach(device_t); 180109323Ssamint wi_detach(device_t); 181194023Savgint wi_shutdown(device_t); 182109323Ssamint wi_alloc(device_t, int); 183109323Ssamvoid wi_free(device_t); 18493611Simpextern devclass_t wi_devclass; 185109323Ssamvoid wi_intr(void *); 186109323Ssamint wi_mgmt_xmit(struct wi_softc *, caddr_t, int); 187178354Ssamvoid wi_stop(struct wi_softc *, int); 188287197Sglebiusvoid wi_init(struct wi_softc *); 189