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.8.2.3 2002/08/02 07:11:34 imp Exp $ 35 * $DragonFly: src/sys/dev/netif/wi/if_wivar.h,v 1.3 2004/02/13 02:44:48 joerg Exp $ 36 */ 37 38 #define WICACHE /* turn on signal strength cache code */ 39 #define MAXWICACHE 10 40 41 struct wi_counters { 42 u_int32_t wi_tx_unicast_frames; 43 u_int32_t wi_tx_multicast_frames; 44 u_int32_t wi_tx_fragments; 45 u_int32_t wi_tx_unicast_octets; 46 u_int32_t wi_tx_multicast_octets; 47 u_int32_t wi_tx_deferred_xmits; 48 u_int32_t wi_tx_single_retries; 49 u_int32_t wi_tx_multi_retries; 50 u_int32_t wi_tx_retry_limit; 51 u_int32_t wi_tx_discards; 52 u_int32_t wi_rx_unicast_frames; 53 u_int32_t wi_rx_multicast_frames; 54 u_int32_t wi_rx_fragments; 55 u_int32_t wi_rx_unicast_octets; 56 u_int32_t wi_rx_multicast_octets; 57 u_int32_t wi_rx_fcs_errors; 58 u_int32_t wi_rx_discards_nobuf; 59 u_int32_t wi_tx_discards_wrong_sa; 60 u_int32_t wi_rx_WEP_cant_decrypt; 61 u_int32_t wi_rx_msg_in_msg_frags; 62 u_int32_t wi_rx_msg_in_bad_msg_frags; 63 }; 64 65 /* 66 * Encryption controls. We can enable or disable encryption as 67 * well as specify up to 4 encryption keys. We can also specify 68 * which of the four keys will be used for transmit encryption. 69 */ 70 #define WI_RID_ENCRYPTION 0xFC20 71 #define WI_RID_AUTHTYPE 0xFC21 72 #define WI_RID_DEFLT_CRYPT_KEYS 0xFCB0 73 #define WI_RID_TX_CRYPT_KEY 0xFCB1 74 #define WI_RID_WEP_AVAIL 0xFD4F 75 #define WI_RID_P2_TX_CRYPT_KEY 0xFC23 76 #define WI_RID_P2_CRYPT_KEY0 0xFC24 77 #define WI_RID_P2_CRYPT_KEY1 0xFC25 78 #define WI_RID_MICROWAVE_OVEN 0xFC25 79 #define WI_RID_P2_CRYPT_KEY2 0xFC26 80 #define WI_RID_P2_CRYPT_KEY3 0xFC27 81 #define WI_RID_P2_ENCRYPTION 0xFC28 82 #define WI_RID_ROAMING_MODE 0xFC2D 83 #define WI_RID_CUR_TX_RATE 0xFD44 /* current TX rate */ 84 struct wi_key { 85 u_int16_t wi_keylen; 86 u_int8_t wi_keydat[14]; 87 }; 88 89 struct wi_ltv_keys { 90 u_int16_t wi_len; 91 u_int16_t wi_type; 92 struct wi_key wi_keys[4]; 93 }; 94 95 struct wi_softc { 96 struct arpcom arpcom; 97 struct ifmedia ifmedia; 98 device_t dev; 99 int wi_unit; 100 struct resource * local; 101 int local_rid; 102 struct resource * iobase; 103 int iobase_rid; 104 struct resource * irq; 105 int irq_rid; 106 struct resource * mem; 107 int mem_rid; 108 bus_space_handle_t wi_localhandle; 109 bus_space_tag_t wi_localtag; 110 bus_space_handle_t wi_bhandle; 111 bus_space_tag_t wi_btag; 112 bus_space_handle_t wi_bmemhandle; 113 bus_space_tag_t wi_bmemtag; 114 void * wi_intrhand; 115 int sc_firmware_type; 116 #define WI_NOTYPE 0 117 #define WI_LUCENT 1 118 #define WI_INTERSIL 2 119 #define WI_SYMBOL 3 120 int sc_pri_firmware_ver; /* Primary firmware */ 121 int sc_sta_firmware_ver; /* Station firmware */ 122 int sc_enabled; 123 int wi_io_addr; 124 int wi_tx_data_id; 125 int wi_tx_mgmt_id; 126 int wi_gone; 127 int wi_flags; 128 #define WI_FLAGS_ATTACHED 0x01 129 #define WI_FLAGS_INITIALIZED 0x02 130 #define WI_FLAGS_HAS_WEP 0x04 131 #define WI_FLAGS_HAS_IBSS 0x08 132 #define WI_FLAGS_HAS_CREATE_IBSS 0x10 133 #define WI_FLAGS_HAS_MOR 0x20 134 #define WI_FLAGS_HAS_ROAMING 0x30 135 #define WI_FLAGS_HAS_DIVERSITY 0x40 136 #define WI_FLAGS_HAS_HOSTAP 0x80 137 int wi_if_flags; 138 u_int16_t wi_procframe; 139 u_int16_t wi_ptype; 140 u_int16_t wi_portnum; 141 u_int16_t wi_max_data_len; 142 u_int16_t wi_rts_thresh; 143 u_int16_t wi_ap_density; 144 u_int16_t wi_tx_rate; 145 u_int16_t wi_create_ibss; 146 u_int16_t wi_channel; 147 u_int16_t wi_pm_enabled; 148 u_int16_t wi_mor_enabled; 149 u_int16_t wi_max_sleep; 150 u_int16_t wi_supprates; 151 u_int16_t wi_authtype; 152 u_int16_t wi_roaming; 153 char wi_node_name[32]; 154 char wi_net_name[32]; 155 char wi_ibss_name[32]; 156 u_int8_t wi_txbuf[1596]; 157 u_int8_t wi_scanbuf[1596]; 158 int wi_scanbuf_len; 159 struct wi_counters wi_stats; 160 int wi_has_wep; 161 int wi_use_wep; 162 int wi_authmode; 163 int wi_tx_key; 164 struct wi_ltv_keys wi_keys; 165 #ifdef WICACHE 166 int wi_sigitems; 167 struct wi_sigcache wi_sigcache[MAXWICACHE]; 168 int wi_nextitem; 169 #endif 170 struct wihap_info wi_hostap_info; 171 u_int32_t wi_icv; 172 int wi_icv_flag; 173 int wi_ibss_port; 174 struct callout_handle wi_stat_ch; 175 #if defined(__FreeBSD__) && __FreeBSD_version >= 500000 176 struct mtx wi_mtx; 177 #endif 178 int wi_nic_type; 179 int wi_bus_type; /* Bus attachment type */ 180 struct { 181 u_int16_t wi_sleep; 182 u_int16_t wi_delaysupp; 183 u_int16_t wi_txsupp; 184 u_int16_t wi_monitor; 185 u_int16_t wi_ledtest; 186 u_int16_t wi_ledtest_param0; 187 u_int16_t wi_ledtest_param1; 188 u_int16_t wi_conttx; 189 u_int16_t wi_conttx_param0; 190 u_int16_t wi_contrx; 191 u_int16_t wi_sigstate; 192 u_int16_t wi_sigstate_param0; 193 u_int16_t wi_confbits; 194 u_int16_t wi_confbits_param0; 195 } wi_debug; 196 197 }; 198 199 struct wi_card_ident { 200 u_int16_t card_id; 201 char *card_name; 202 u_int8_t firm_type; 203 }; 204 205 #if defined(__DragonFly__) || __FreeBSD_version < 500000 206 /* 207 * Various compat hacks/kludges 208 */ 209 #define le16toh(x) (x) 210 #define htole16(x) (x) 211 #define ifaddr_byindex(idx) ifnet_addrs[(idx) - 1]; 212 #define WI_LOCK(_sc, _s) s = splimp() 213 #define WI_UNLOCK(_sc, _s) splx(s) 214 #else 215 #define WI_LOCK(_sc, _s) _s = 1 216 #define WI_UNLOCK(_sc, _s) 217 #endif 218 219 int wi_generic_attach(device_t); 220 int wi_generic_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 int wi_mgmt_xmit(struct wi_softc *, caddr_t, int); 226