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: head/sys/dev/wi/if_wivar.h 288095 2015-09-22 06:34:07Z adrian $ 35 */ 36 37 /* 38 * Encryption controls. We can enable or disable encryption as 39 * well as specify up to 4 encryption keys. We can also specify 40 * which of the four keys will be used for transmit encryption. 41 */ 42 #define WI_RID_ENCRYPTION 0xFC20 43 #define WI_RID_AUTHTYPE 0xFC21 44 #define WI_RID_DEFLT_CRYPT_KEYS 0xFCB0 45 #define WI_RID_TX_CRYPT_KEY 0xFCB1 46 #define WI_RID_WEP_AVAIL 0xFD4F 47 #define WI_RID_P2_TX_CRYPT_KEY 0xFC23 48 #define WI_RID_P2_CRYPT_KEY0 0xFC24 49 #define WI_RID_P2_CRYPT_KEY1 0xFC25 50 #define WI_RID_MICROWAVE_OVEN 0xFC25 51 #define WI_RID_P2_CRYPT_KEY2 0xFC26 52 #define WI_RID_P2_CRYPT_KEY3 0xFC27 53 #define WI_RID_P2_ENCRYPTION 0xFC28 54 #define WI_RID_ROAMING_MODE 0xFC2D 55 #define WI_RID_CUR_TX_RATE 0xFD44 /* current TX rate */ 56 57 #define WI_MAX_AID 256 /* max stations for ap operation */ 58 59 struct wi_vap { 60 struct ieee80211vap wv_vap; 61 62 void (*wv_recv_mgmt)(struct ieee80211_node *, struct mbuf *, 63 int, const struct ieee80211_rx_stats *rxs, int, int); 64 int (*wv_newstate)(struct ieee80211vap *, 65 enum ieee80211_state, int); 66 }; 67 #define WI_VAP(vap) ((struct wi_vap *)(vap)) 68 69 struct wi_softc { 70 struct ieee80211com sc_ic; 71 struct mbufq sc_snd; 72 device_t sc_dev; 73 #if defined(__DragonFly__) 74 struct lock sc_lk; 75 #else 76 struct mtx sc_mtx; 77 #endif 78 struct callout sc_watchdog; 79 int sc_unit; 80 int wi_gone; 81 int sc_enabled; 82 int sc_reset; 83 int sc_firmware_type; 84 #define WI_NOTYPE 0 85 #define WI_LUCENT 1 86 #define WI_INTERSIL 2 87 #define WI_SYMBOL 3 88 int sc_pri_firmware_ver; /* Primary firmware */ 89 int sc_sta_firmware_ver; /* Station firmware */ 90 unsigned int sc_nic_id; /* Type of NIC */ 91 char * sc_nic_name; 92 93 int wi_bus_type; /* Bus attachment type */ 94 struct resource * local; 95 int local_rid; 96 struct resource * iobase; 97 int iobase_rid; 98 struct resource * irq; 99 int irq_rid; 100 struct resource * mem; 101 int mem_rid; 102 bus_space_handle_t wi_localhandle; 103 bus_space_tag_t wi_localtag; 104 bus_space_handle_t wi_bhandle; 105 bus_space_tag_t wi_btag; 106 bus_space_handle_t wi_bmemhandle; 107 bus_space_tag_t wi_bmemtag; 108 void * wi_intrhand; 109 struct ieee80211_channel *wi_channel; 110 int wi_io_addr; 111 int wi_cmd_count; 112 113 int sc_flags; 114 int sc_bap_id; 115 int sc_bap_off; 116 117 int sc_porttype; 118 u_int16_t sc_portnum; 119 u_int16_t sc_encryption; 120 u_int16_t sc_monitor_port; 121 122 /* RSSI interpretation */ 123 u_int16_t sc_min_rssi; /* clamp sc_min_rssi < RSSI */ 124 u_int16_t sc_max_rssi; /* clamp RSSI < sc_max_rssi */ 125 u_int16_t sc_dbm_offset; /* dBm ~ RSSI - sc_dbm_offset */ 126 127 int sc_buflen; /* TX buffer size */ 128 int sc_ntxbuf; 129 #define WI_NTXBUF 3 130 struct { 131 int d_fid; 132 int d_len; 133 } sc_txd[WI_NTXBUF]; /* TX buffers */ 134 int sc_txnext; /* index of next TX */ 135 int sc_txcur; /* index of current TX*/ 136 int sc_tx_timer; 137 138 struct wi_counters sc_stats; 139 u_int16_t sc_ibss_port; 140 141 struct timeval sc_last_syn; 142 int sc_false_syns; 143 144 u_int16_t sc_txbuf[IEEE80211_MAX_LEN/2]; 145 146 struct wi_tx_radiotap_header sc_tx_th; 147 struct wi_rx_radiotap_header sc_rx_th; 148 }; 149 150 /* maximum consecutive false change-of-BSSID indications */ 151 #define WI_MAX_FALSE_SYNS 10 152 153 #define WI_FLAGS_HAS_ENHSECURITY 0x0001 154 #define WI_FLAGS_HAS_WPASUPPORT 0x0002 155 #define WI_FLAGS_HAS_ROAMING 0x0020 156 #define WI_FLAGS_HAS_FRAGTHR 0x0200 157 #define WI_FLAGS_HAS_DBMADJUST 0x0400 158 #define WI_FLAGS_RUNNING 0x0800 159 #define WI_FLAGS_PROMISC 0x1000 160 161 struct wi_card_ident { 162 u_int16_t card_id; 163 char *card_name; 164 u_int8_t firm_type; 165 }; 166 167 #define WI_PRISM_MIN_RSSI 0x1b 168 #define WI_PRISM_MAX_RSSI 0x9a 169 #define WI_PRISM_DBM_OFFSET 100 /* XXX */ 170 171 #define WI_LUCENT_MIN_RSSI 47 172 #define WI_LUCENT_MAX_RSSI 138 173 #define WI_LUCENT_DBM_OFFSET 149 174 175 #define WI_RSSI_TO_DBM(sc, rssi) (MIN((sc)->sc_max_rssi, \ 176 MAX((sc)->sc_min_rssi, (rssi))) - (sc)->sc_dbm_offset) 177 178 #if defined(__DragonFly__) 179 #define WI_LOCK(_sc) lockmgr(&(_sc)->sc_lk, LK_EXCLUSIVE) 180 #define WI_UNLOCK(_sc) lockmgr(&(_sc)->sc_lk, LK_RELEASE) 181 #define WI_LOCK_ASSERT(_sc) KKASSERT(lockstatus(&(_sc)->sc_lk, curthread) == LK_EXCLUSIVE) 182 #else 183 #define WI_LOCK(_sc) mtx_lock(&(_sc)->sc_mtx) 184 #define WI_UNLOCK(_sc) mtx_unlock(&(_sc)->sc_mtx) 185 #define WI_LOCK_ASSERT(_sc) mtx_assert(&(_sc)->sc_mtx, MA_OWNED) 186 #endif 187 188 int wi_attach(device_t); 189 int wi_detach(device_t); 190 int wi_shutdown(device_t); 191 int wi_alloc(device_t, int); 192 void wi_free(device_t); 193 extern devclass_t wi_devclass; 194 void wi_intr(void *); 195 int wi_mgmt_xmit(struct wi_softc *, caddr_t, int); 196 void wi_stop(struct wi_softc *, int); 197 void wi_init(struct wi_softc *); 198