1bb5e3b2fSeh146360 /* 2*0f1b305eSSeth Goldberg * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 3bb5e3b2fSeh146360 * Use is subject to license terms. 4bb5e3b2fSeh146360 */ 5bb5e3b2fSeh146360 6bb5e3b2fSeh146360 /* 7bb5e3b2fSeh146360 * Copyright(c) 2004 8bb5e3b2fSeh146360 * Damien Bergamini <damien.bergamini@free.fr>. All rights reserved. 9bb5e3b2fSeh146360 * 10bb5e3b2fSeh146360 * Redistribution and use in source and binary forms, with or without 11bb5e3b2fSeh146360 * modification, are permitted provided that the following conditions 12bb5e3b2fSeh146360 * are met: 13bb5e3b2fSeh146360 * 1. Redistributions of source code must retain the above copyright 14bb5e3b2fSeh146360 * notice unmodified, this list of conditions, and the following 15bb5e3b2fSeh146360 * disclaimer. 16bb5e3b2fSeh146360 * 2. Redistributions in binary form must reproduce the above copyright 17bb5e3b2fSeh146360 * notice, this list of conditions and the following disclaimer in the 18bb5e3b2fSeh146360 * documentation and/or other materials provided with the distribution. 19bb5e3b2fSeh146360 * 20bb5e3b2fSeh146360 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 21bb5e3b2fSeh146360 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22bb5e3b2fSeh146360 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23bb5e3b2fSeh146360 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 24bb5e3b2fSeh146360 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25bb5e3b2fSeh146360 * DAMAGES(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26bb5e3b2fSeh146360 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27bb5e3b2fSeh146360 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28bb5e3b2fSeh146360 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29bb5e3b2fSeh146360 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30bb5e3b2fSeh146360 * SUCH DAMAGE. 31bb5e3b2fSeh146360 */ 32bb5e3b2fSeh146360 33bb5e3b2fSeh146360 #ifndef _SYS_IPW2100_IMPL_H 34bb5e3b2fSeh146360 #define _SYS_IPW2100_IMPL_H 35bb5e3b2fSeh146360 36bb5e3b2fSeh146360 #ifdef __cplusplus 37bb5e3b2fSeh146360 extern "C" { 38bb5e3b2fSeh146360 #endif 39bb5e3b2fSeh146360 40bb5e3b2fSeh146360 /* 41bb5e3b2fSeh146360 * Intel Wireless PRO/2100 mini-PCI adapter driver 42bb5e3b2fSeh146360 * ipw2100_impl.h includes: 43bb5e3b2fSeh146360 * . implementation of ipw2100 44bb5e3b2fSeh146360 * . hardware operation and interface define for ipw2100 45bb5e3b2fSeh146360 * . firmware operation and interface define for ipw2100 46bb5e3b2fSeh146360 */ 47bb5e3b2fSeh146360 #include <sys/ddi.h> 48bb5e3b2fSeh146360 #include <sys/sunddi.h> 49bb5e3b2fSeh146360 #include <sys/mac.h> 50bb5e3b2fSeh146360 #include <sys/net80211.h> 51bb5e3b2fSeh146360 52bb5e3b2fSeh146360 /* 53bb5e3b2fSeh146360 * Implementation of ipw2100 54bb5e3b2fSeh146360 */ 55bb5e3b2fSeh146360 #define IPW2100_NODENAME "ipw" 56bb5e3b2fSeh146360 57bb5e3b2fSeh146360 #define IPW2100_PCI_CFG_RNUM (0) /* pci config space */ 58bb5e3b2fSeh146360 #define IPW2100_PCI_CSR_RNUM (1) /* device CSR space */ 59bb5e3b2fSeh146360 60bb5e3b2fSeh146360 #define IPW2100_NUM_TXBD (128) 61bb5e3b2fSeh146360 #define IPW2100_TXBD_SIZE (IPW2100_NUM_TXBD * sizeof (struct ipw2100_bd)) 62bb5e3b2fSeh146360 #define IPW2100_NUM_TXBUF (IPW2100_NUM_TXBD/2) /* ipw2100_txb number */ 63bb5e3b2fSeh146360 #define IPW2100_TXBUF_SIZE (sizeof (struct ipw2100_txb)) 64bb5e3b2fSeh146360 65bb5e3b2fSeh146360 #define IPW2100_NUM_RXBD (128) 66bb5e3b2fSeh146360 #define IPW2100_STATUS_SIZE (IPW2100_NUM_RXBD * sizeof (struct ipw2100_status)) 67bb5e3b2fSeh146360 #define IPW2100_RXBD_SIZE (IPW2100_NUM_RXBD * sizeof (struct ipw2100_bd)) 68bb5e3b2fSeh146360 #define IPW2100_NUM_RXBUF (IPW2100_NUM_RXBD) 69bb5e3b2fSeh146360 #define IPW2100_RXBUF_SIZE (sizeof (struct ipw2100_rxb)) 70bb5e3b2fSeh146360 71bb5e3b2fSeh146360 #define IPW2100_CMD_SIZE (sizeof (struct ipw2100_cmd)) 72bb5e3b2fSeh146360 73bb5e3b2fSeh146360 struct dma_region { 74bb5e3b2fSeh146360 ddi_dma_handle_t dr_hnd; 75bb5e3b2fSeh146360 ddi_acc_handle_t dr_acc; 76bb5e3b2fSeh146360 ddi_dma_cookie_t dr_cookie; 77bb5e3b2fSeh146360 uint_t dr_ccnt; 78bb5e3b2fSeh146360 uint32_t dr_pbase; 79bb5e3b2fSeh146360 caddr_t dr_base; 80bb5e3b2fSeh146360 size_t dr_size; 81bb5e3b2fSeh146360 const char *dr_name; 82bb5e3b2fSeh146360 }; 83bb5e3b2fSeh146360 84bb5e3b2fSeh146360 struct ipw2100_firmware { 85bb5e3b2fSeh146360 uint8_t *bin_base; /* image */ 86bb5e3b2fSeh146360 size_t bin_size; 87bb5e3b2fSeh146360 uint8_t *fw_base; /* firmware code */ 88bb5e3b2fSeh146360 size_t fw_size; 89bb5e3b2fSeh146360 uint8_t *uc_base; /* u-controller code */ 90bb5e3b2fSeh146360 size_t uc_size; 91bb5e3b2fSeh146360 }; 92bb5e3b2fSeh146360 93bb5e3b2fSeh146360 /* 94bb5e3b2fSeh146360 * per-instance soft-state structure 95bb5e3b2fSeh146360 */ 96bb5e3b2fSeh146360 struct ipw2100_softc { 97bb5e3b2fSeh146360 struct ieee80211com sc_ic; 98bb5e3b2fSeh146360 dev_info_t *sc_dip; 99bb5e3b2fSeh146360 int (*sc_newstate)(struct ieee80211com *, 100bb5e3b2fSeh146360 enum ieee80211_state, int); 101bb5e3b2fSeh146360 int sc_authmode; 102*0f1b305eSSeth Goldberg int sc_suspended; 103bb5e3b2fSeh146360 /* CSR */ 104bb5e3b2fSeh146360 ddi_acc_handle_t sc_ioh; 105bb5e3b2fSeh146360 caddr_t sc_regs; 106bb5e3b2fSeh146360 /* interrupt */ 107bb5e3b2fSeh146360 ddi_iblock_cookie_t sc_iblk; 108bb5e3b2fSeh146360 /* soft interrupt */ 109bb5e3b2fSeh146360 ddi_softintr_t sc_link_softint; 110bb5e3b2fSeh146360 /* link state */ 111bb5e3b2fSeh146360 int32_t sc_linkstate; 112bb5e3b2fSeh146360 /* mutex to protect interrupt handler */ 113bb5e3b2fSeh146360 kmutex_t sc_ilock; 114bb5e3b2fSeh146360 kcondvar_t sc_fw_cond; 115bb5e3b2fSeh146360 /* flags */ 116bb5e3b2fSeh146360 uint_t sc_flags; 117bb5e3b2fSeh146360 #define IPW2100_FLAG_FW_CACHED (1 << 0) 118bb5e3b2fSeh146360 #define IPW2100_FLAG_FW_INITED (1 << 1) 119bb5e3b2fSeh146360 #define IPW2100_FLAG_RUNNING (1 << 2) 120bb5e3b2fSeh146360 #define IPW2100_FLAG_LINK_CHANGE (1 << 3) 121bb5e3b2fSeh146360 #define IPW2100_FLAG_TX_SCHED (1 << 4) 122bb5e3b2fSeh146360 #define IPW2100_FLAG_CMD_WAIT (1 << 5) 123bb5e3b2fSeh146360 #define IPW2100_FLAG_SCAN_COMPLETE (1 << 6) 124bb5e3b2fSeh146360 #define IPW2100_FLAG_HW_ERR_RECOVER (1 << 7) 125799aa485SKonstantin Ananyev #define IPW2100_FLAG_QUIESCED (1 << 8) 126bb5e3b2fSeh146360 #define IPW2100_FLAG_HAS_RADIO_SWITCH (1 << 16) 127bb5e3b2fSeh146360 /* command */ 128bb5e3b2fSeh146360 struct ipw2100_cmd *sc_cmd; 129bb5e3b2fSeh146360 int sc_done; /* command is done */ 130bb5e3b2fSeh146360 kcondvar_t sc_cmd_cond; 131bb5e3b2fSeh146360 /* reschedule lock */ 132bb5e3b2fSeh146360 kmutex_t sc_resched_lock; 133bb5e3b2fSeh146360 /* tx ring, bd->hdr&buf */ 134bb5e3b2fSeh146360 kmutex_t sc_tx_lock; 135bb5e3b2fSeh146360 kcondvar_t sc_tx_cond; 136bb5e3b2fSeh146360 uint32_t sc_tx_cur; 137bb5e3b2fSeh146360 uint32_t sc_tx_free; 138bb5e3b2fSeh146360 struct ipw2100_bd *sc_txbd; 139bb5e3b2fSeh146360 struct ipw2100_txb *sc_txbufs[IPW2100_NUM_TXBUF]; 140bb5e3b2fSeh146360 /* rx ring, status, bd->buf */ 141bb5e3b2fSeh146360 uint32_t sc_rx_cur; 142bb5e3b2fSeh146360 uint32_t sc_rx_free; 143bb5e3b2fSeh146360 struct ipw2100_status *sc_status; 144bb5e3b2fSeh146360 struct ipw2100_bd *sc_rxbd; 145bb5e3b2fSeh146360 struct ipw2100_rxb *sc_rxbufs[IPW2100_NUM_RXBUF]; 146bb5e3b2fSeh146360 /* DMA resources */ 147bb5e3b2fSeh146360 struct dma_region sc_dma_txbd; /* tx buffer descriptor */ 148bb5e3b2fSeh146360 struct dma_region sc_dma_txbufs[IPW2100_NUM_TXBUF]; 149bb5e3b2fSeh146360 struct dma_region sc_dma_rxbd; /* rx buffer descriptor */ 150bb5e3b2fSeh146360 struct dma_region sc_dma_rxbufs[IPW2100_NUM_RXBUF]; 151bb5e3b2fSeh146360 struct dma_region sc_dma_status; 152bb5e3b2fSeh146360 struct dma_region sc_dma_cmd; /* command */ 153bb5e3b2fSeh146360 /* hw configuration values */ 154bb5e3b2fSeh146360 uint8_t sc_macaddr[IEEE80211_ADDR_LEN]; 155bb5e3b2fSeh146360 uint16_t sc_chmask; 156bb5e3b2fSeh146360 /* MAC address string */ 157bb5e3b2fSeh146360 char sc_macstr[32]; 158bb5e3b2fSeh146360 /* tables */ 159bb5e3b2fSeh146360 uint32_t sc_table1_base; 160bb5e3b2fSeh146360 uint32_t sc_table2_base; 161bb5e3b2fSeh146360 /* firmware */ 162bb5e3b2fSeh146360 struct ipw2100_firmware sc_fw; 163bb5e3b2fSeh146360 /* mfthread related */ 164bb5e3b2fSeh146360 kmutex_t sc_mflock; 165bb5e3b2fSeh146360 kcondvar_t sc_mfthread_cv; 166bb5e3b2fSeh146360 kcondvar_t sc_scan_cv; /* used for active scan */ 167bb5e3b2fSeh146360 kthread_t *sc_mf_thread; 168bb5e3b2fSeh146360 uint32_t sc_mfthread_switch; /* 0/1 indicate off/on */ 169bb5e3b2fSeh146360 int if_flags; 170bb5e3b2fSeh146360 }; 171bb5e3b2fSeh146360 172bb5e3b2fSeh146360 /* 173bb5e3b2fSeh146360 * RING_BACKWARD - move 'x' backward 's' steps in a 'b'-sized ring 174bb5e3b2fSeh146360 * RING_FORWARD - move 'x' forward 's' steps in a 'b'-sized ring 175bb5e3b2fSeh146360 * 176bb5e3b2fSeh146360 * note that there must be 0 <= 'x' < 'b' && 0 <= 's' < 'b' 177bb5e3b2fSeh146360 */ 178bb5e3b2fSeh146360 #define RING_FLEN(x, y, b) ((((x) > (y)) ? ((b)+(y)-(x)) : ((y)-(x)))) 179bb5e3b2fSeh146360 #define RING_FORWARD(x, s, b) (((x)+(s))%(b)) 180bb5e3b2fSeh146360 #define RING_BACKWARD(x, s, b) RING_FORWARD((x), (b)-(s), (b)) 181bb5e3b2fSeh146360 182bb5e3b2fSeh146360 /* 183bb5e3b2fSeh146360 * field_offset 184bb5e3b2fSeh146360 */ 185bb5e3b2fSeh146360 #define OFFSETOF(s, m) ((size_t)(&(((s *)0)->m))) 186bb5e3b2fSeh146360 187bb5e3b2fSeh146360 extern int ipw2100_init(struct ipw2100_softc *sc); 188bb5e3b2fSeh146360 extern int ipw2100_disable(struct ipw2100_softc *sc); 189bb5e3b2fSeh146360 190bb5e3b2fSeh146360 /* 191bb5e3b2fSeh146360 * Below structure and functions will be used for statistic 192bb5e3b2fSeh146360 */ 193bb5e3b2fSeh146360 struct statistic { 194bb5e3b2fSeh146360 int index; 195bb5e3b2fSeh146360 const char *desc; 196bb5e3b2fSeh146360 int unit; 197bb5e3b2fSeh146360 #define INT 1 198bb5e3b2fSeh146360 #define HEX 2 199bb5e3b2fSeh146360 #define MASK HEX 200bb5e3b2fSeh146360 #define PERCENTAGE 3 201bb5e3b2fSeh146360 #define BOOL 4 202bb5e3b2fSeh146360 }; 203bb5e3b2fSeh146360 extern void ipw2100_get_statistics(struct ipw2100_softc *sc); 204bb5e3b2fSeh146360 205bb5e3b2fSeh146360 /* 206bb5e3b2fSeh146360 * Hardware related definations and interfaces. 207bb5e3b2fSeh146360 */ 208bb5e3b2fSeh146360 #define IPW2100_CSR_INTR (0x0008) 209bb5e3b2fSeh146360 #define IPW2100_CSR_INTR_MASK (0x000c) 210bb5e3b2fSeh146360 #define IPW2100_CSR_INDIRECT_ADDR (0x0010) 211bb5e3b2fSeh146360 #define IPW2100_CSR_INDIRECT_DATA (0x0014) 212bb5e3b2fSeh146360 #define IPW2100_CSR_AUTOINC_ADDR (0x0018) 213bb5e3b2fSeh146360 #define IPW2100_CSR_AUTOINC_DATA (0x001c) 214bb5e3b2fSeh146360 #define IPW2100_CSR_RST (0x0020) 215bb5e3b2fSeh146360 #define IPW2100_CSR_CTL (0x0024) 216bb5e3b2fSeh146360 #define IPW2100_CSR_IO (0x0030) 217bb5e3b2fSeh146360 #define IPW2100_CSR_DEBUG_AREA (0x0090) 218bb5e3b2fSeh146360 219bb5e3b2fSeh146360 #define IPW2100_CSR_TX_BD_BASE (0x0200) 220bb5e3b2fSeh146360 #define IPW2100_CSR_TX_BD_SIZE (0x0204) 221bb5e3b2fSeh146360 #define IPW2100_CSR_RX_BD_BASE (0x0240) 222bb5e3b2fSeh146360 #define IPW2100_CSR_RX_STATUS_BASE (0x0244) 223bb5e3b2fSeh146360 #define IPW2100_CSR_RX_BD_SIZE (0x0248) 224bb5e3b2fSeh146360 #define IPW2100_CSR_TABLE1_BASE (0x0380) 225bb5e3b2fSeh146360 #define IPW2100_CSR_TABLE2_BASE (0x0384) 226bb5e3b2fSeh146360 /* 227bb5e3b2fSeh146360 * tx-rd-index the entry to be processed by HW, i.e. empty tx buffer 228bb5e3b2fSeh146360 * tx-wr-index the entry just being filled by SW with new data to transmit 229bb5e3b2fSeh146360 */ 230bb5e3b2fSeh146360 #define IPW2100_CSR_TX_READ_INDEX (0x0280) 231bb5e3b2fSeh146360 #define IPW2100_CSR_TX_WRITE_INDEX (0x0f80) 232bb5e3b2fSeh146360 /* 233bb5e3b2fSeh146360 * rx-rd-index the entry just being processed by HW, i.e. new received data 234bb5e3b2fSeh146360 * rx-wr-index the entry just being set by SW to empty buffer to receive 235bb5e3b2fSeh146360 */ 236bb5e3b2fSeh146360 #define IPW2100_CSR_RX_READ_INDEX (0x02a0) 237bb5e3b2fSeh146360 #define IPW2100_CSR_RX_WRITE_INDEX (0x0fa0) 238bb5e3b2fSeh146360 239bb5e3b2fSeh146360 /* 240bb5e3b2fSeh146360 * CSR flags: IPW2100_CSR_INTR 241bb5e3b2fSeh146360 * The interrupt register is used to indicate the h/w status 242bb5e3b2fSeh146360 */ 243bb5e3b2fSeh146360 #define IPW2100_INTR_TX_TRANSFER (0x00000001) 244bb5e3b2fSeh146360 #define IPW2100_INTR_RX_TRANSFER (0x00000002) 245bb5e3b2fSeh146360 #define IPW2100_INTR_STATUS_CHANGE (0x00000010) 246bb5e3b2fSeh146360 #define IPW2100_INTR_COMMAND_DONE (0x00010000) 247bb5e3b2fSeh146360 #define IPW2100_INTR_FW_INIT_DONE (0x01000000) 248bb5e3b2fSeh146360 #define IPW2100_INTR_FATAL_ERROR (0x40000000) 249bb5e3b2fSeh146360 #define IPW2100_INTR_PARITY_ERROR (0x80000000) 250bb5e3b2fSeh146360 #define IPW2100_INTR_MASK_ALL (IPW2100_INTR_TX_TRANSFER | \ 251bb5e3b2fSeh146360 IPW2100_INTR_RX_TRANSFER | \ 252bb5e3b2fSeh146360 IPW2100_INTR_STATUS_CHANGE | \ 253bb5e3b2fSeh146360 IPW2100_INTR_COMMAND_DONE | \ 254bb5e3b2fSeh146360 IPW2100_INTR_FW_INIT_DONE | \ 255bb5e3b2fSeh146360 IPW2100_INTR_FATAL_ERROR | \ 256bb5e3b2fSeh146360 IPW2100_INTR_PARITY_ERROR) 257bb5e3b2fSeh146360 #define IPW2100_INTR_MASK_ERR (IPW2100_INTR_FATAL_ERROR | \ 258bb5e3b2fSeh146360 IPW2100_INTR_PARITY_ERROR) 259bb5e3b2fSeh146360 260bb5e3b2fSeh146360 /* 261bb5e3b2fSeh146360 * CSR flags: IPW2100_CSR_RST 262bb5e3b2fSeh146360 * The reset register is used to reset hardware 263bb5e3b2fSeh146360 */ 264bb5e3b2fSeh146360 #define IPW2100_RST_PRINCETON_RESET (0x00000001) 265bb5e3b2fSeh146360 #define IPW2100_RST_SW_RESET (0x00000080) 266bb5e3b2fSeh146360 #define IPW2100_RST_MASTER_DISABLED (0x00000100) 267bb5e3b2fSeh146360 #define IPW2100_RST_STOP_MASTER (0x00000200) 268bb5e3b2fSeh146360 269bb5e3b2fSeh146360 /* 270bb5e3b2fSeh146360 * CSR flags: IPW2100_CSR_CTL 271bb5e3b2fSeh146360 */ 272bb5e3b2fSeh146360 #define IPW2100_CTL_CLOCK_READY (0x00000001) 273bb5e3b2fSeh146360 #define IPW2100_CTL_ALLOW_STANDBY (0x00000002) 274bb5e3b2fSeh146360 #define IPW2100_CTL_INIT (0x00000004) 275bb5e3b2fSeh146360 276bb5e3b2fSeh146360 /* 277bb5e3b2fSeh146360 * CSR flags: IPW2100_CSR_IO 278bb5e3b2fSeh146360 */ 279bb5e3b2fSeh146360 #define IPW2100_IO_GPIO1_ENABLE (0x00000008) 280bb5e3b2fSeh146360 #define IPW2100_IO_GPIO1_MASK (0x0000000c) 281bb5e3b2fSeh146360 #define IPW2100_IO_GPIO3_MASK (0x000000c0) 282bb5e3b2fSeh146360 #define IPW2100_IO_LED_OFF (0x00002000) 283bb5e3b2fSeh146360 #define IPW2100_IO_RADIO_DISABLED (0x00010000) 284bb5e3b2fSeh146360 285bb5e3b2fSeh146360 /* 286bb5e3b2fSeh146360 * States code 287bb5e3b2fSeh146360 */ 288bb5e3b2fSeh146360 #define IPW2100_STATE_ASSOCIATED (0x0004) 289bb5e3b2fSeh146360 #define IPW2100_STATE_ASSOCIATION_LOST (0x0008) 290bb5e3b2fSeh146360 #define IPW2100_STATE_SCAN_COMPLETE (0x0020) 291bb5e3b2fSeh146360 #define IPW2100_STATE_RADIO_DISABLED (0x0100) 292bb5e3b2fSeh146360 #define IPW2100_STATE_DISABLED (0x0200) 293bb5e3b2fSeh146360 #define IPW2100_STATE_SCANNING (0x0800) 294bb5e3b2fSeh146360 295bb5e3b2fSeh146360 /* 296bb5e3b2fSeh146360 * table1 offsets 297bb5e3b2fSeh146360 */ 298bb5e3b2fSeh146360 #define IPW2100_INFO_LOCK (480) 299bb5e3b2fSeh146360 #define IPW2100_INFO_APS_CNT (604) 300bb5e3b2fSeh146360 #define IPW2100_INFO_APS_BASE (608) 301bb5e3b2fSeh146360 #define IPW2100_INFO_CARD_DISABLED (628) 302bb5e3b2fSeh146360 #define IPW2100_INFO_CURRENT_CHANNEL (756) 303bb5e3b2fSeh146360 #define IPW2100_INFO_CURRENT_TX_RATE (768) 304bb5e3b2fSeh146360 305bb5e3b2fSeh146360 /* 306bb5e3b2fSeh146360 * table2 offsets 307bb5e3b2fSeh146360 */ 308bb5e3b2fSeh146360 #define IPW2100_INFO_CURRENT_SSID (48) 309bb5e3b2fSeh146360 #define IPW2100_INFO_CURRENT_BSSID (112) 310bb5e3b2fSeh146360 311bb5e3b2fSeh146360 /* 312bb5e3b2fSeh146360 * supported rates 313bb5e3b2fSeh146360 */ 314bb5e3b2fSeh146360 #define IPW2100_RATE_DS1 (1) 315bb5e3b2fSeh146360 #define IPW2100_RATE_DS2 (2) 316bb5e3b2fSeh146360 #define IPW2100_RATE_DS5 (4) 317bb5e3b2fSeh146360 #define IPW2100_RATE_DS11 (8) 318bb5e3b2fSeh146360 319bb5e3b2fSeh146360 /* hw structures, packed */ 320bb5e3b2fSeh146360 #pragma pack(1) 321bb5e3b2fSeh146360 /* 322bb5e3b2fSeh146360 * firmware binary image header 323bb5e3b2fSeh146360 */ 324bb5e3b2fSeh146360 struct ipw2100_firmware_hdr { 325bb5e3b2fSeh146360 uint32_t version; 326bb5e3b2fSeh146360 uint32_t fw_size; 327bb5e3b2fSeh146360 uint32_t uc_size; 328bb5e3b2fSeh146360 }; 329bb5e3b2fSeh146360 330bb5e3b2fSeh146360 /* 331bb5e3b2fSeh146360 * buffer descriptor 332bb5e3b2fSeh146360 */ 333bb5e3b2fSeh146360 struct ipw2100_bd { 334bb5e3b2fSeh146360 uint32_t phyaddr; 335bb5e3b2fSeh146360 uint32_t len; 336bb5e3b2fSeh146360 uint8_t flags; 337bb5e3b2fSeh146360 /* flags */ 338bb5e3b2fSeh146360 #define IPW2100_BD_FLAG_TX_LAST_FRAGMENT (0x08) 339bb5e3b2fSeh146360 #define IPW2100_BD_FLAG_TX_NOT_LAST_FRAGMENT (0x01) 340bb5e3b2fSeh146360 /* data content */ 341bb5e3b2fSeh146360 #define IPW2100_BD_FLAG_TX_FRAME_802_3 (0x00) 342bb5e3b2fSeh146360 #define IPW2100_BD_FLAG_TX_FRAME_COMMAND (0x02) 343bb5e3b2fSeh146360 #define IPW2100_BD_FLAG_TX_FRAME_802_11 (0x04) 344bb5e3b2fSeh146360 /* number of fragments, only 1st BD is needed */ 345bb5e3b2fSeh146360 uint8_t nfrag; 346bb5e3b2fSeh146360 uint8_t reserved[6]; 347bb5e3b2fSeh146360 }; 348bb5e3b2fSeh146360 349bb5e3b2fSeh146360 /* 350bb5e3b2fSeh146360 * status descriptor 351bb5e3b2fSeh146360 */ 352bb5e3b2fSeh146360 struct ipw2100_status { 353bb5e3b2fSeh146360 uint32_t len; 354bb5e3b2fSeh146360 uint16_t code; 355bb5e3b2fSeh146360 #define IPW2100_STATUS_CODE_COMMAND (0) 356bb5e3b2fSeh146360 #define IPW2100_STATUS_CODE_NEWSTATE (1) 357bb5e3b2fSeh146360 #define IPW2100_STATUS_CODE_DATA_802_11 (2) 358bb5e3b2fSeh146360 #define IPW2100_STATUS_CODE_DATA_802_3 (3) 359bb5e3b2fSeh146360 #define IPW2100_STATUS_CODE_NOTIFICATION (4) 360bb5e3b2fSeh146360 uint8_t flags; 361bb5e3b2fSeh146360 #define IPW2100_STATUS_FLAG_DECRYPTED (0x01) 362bb5e3b2fSeh146360 #define IPW2100_STATUS_FLAG_WEP_ENCRYPTED (0x02) 363bb5e3b2fSeh146360 #define IPW2100_STATUS_FLAG_CRC_ERROR (0x04) 364bb5e3b2fSeh146360 /* received signal strength indicator */ 365bb5e3b2fSeh146360 uint8_t rssi; 366bb5e3b2fSeh146360 }; 367bb5e3b2fSeh146360 368bb5e3b2fSeh146360 /* 369bb5e3b2fSeh146360 * data header 370bb5e3b2fSeh146360 */ 371bb5e3b2fSeh146360 struct ipw2100_hdr { 372bb5e3b2fSeh146360 uint32_t type; 373bb5e3b2fSeh146360 uint32_t subtype; 374bb5e3b2fSeh146360 uint8_t encrypted; 375bb5e3b2fSeh146360 uint8_t encrypt; 376bb5e3b2fSeh146360 uint8_t keyidx; 377bb5e3b2fSeh146360 uint8_t keysz; 378bb5e3b2fSeh146360 uint8_t key[IEEE80211_KEYBUF_SIZE]; 379bb5e3b2fSeh146360 uint8_t reserved[10]; 380bb5e3b2fSeh146360 uint8_t saddr[IEEE80211_ADDR_LEN]; 381bb5e3b2fSeh146360 uint8_t daddr[IEEE80211_ADDR_LEN]; 382bb5e3b2fSeh146360 uint16_t fragsz; 383bb5e3b2fSeh146360 }; 384bb5e3b2fSeh146360 385bb5e3b2fSeh146360 /* 386bb5e3b2fSeh146360 * command 387bb5e3b2fSeh146360 */ 388bb5e3b2fSeh146360 struct ipw2100_cmd { 389bb5e3b2fSeh146360 uint32_t type; 390bb5e3b2fSeh146360 #define IPW2100_CMD_ENABLE (2) 391bb5e3b2fSeh146360 #define IPW2100_CMD_SET_CONFIGURATION (6) 392bb5e3b2fSeh146360 #define IPW2100_CMD_SET_ESSID (8) 393bb5e3b2fSeh146360 #define IPW2100_CMD_SET_MANDATORY_BSSID (9) 394bb5e3b2fSeh146360 #define IPW2100_CMD_SET_AUTH_TYPE (10) 395bb5e3b2fSeh146360 #define IPW2100_CMD_SET_MAC_ADDRESS (11) 396bb5e3b2fSeh146360 #define IPW2100_CMD_SET_MODE (12) 397bb5e3b2fSeh146360 #define IPW2100_CMD_SET_I18N_MODE (13) 398bb5e3b2fSeh146360 #define IPW2100_CMD_SET_CHANNEL (14) 399bb5e3b2fSeh146360 #define IPW2100_CMD_SET_RTS_THRESHOLD (15) 400bb5e3b2fSeh146360 #define IPW2100_CMD_SET_FRAG_THRESHOLD (16) 401bb5e3b2fSeh146360 #define IPW2100_CMD_SET_POWER_MODE (17) 402bb5e3b2fSeh146360 #define IPW2100_CMD_SET_TX_RATES (18) 403bb5e3b2fSeh146360 #define IPW2100_CMD_SET_BASIC_TX_RATES (19) 404bb5e3b2fSeh146360 #define IPW2100_CMD_SET_WEP_KEY (20) 405bb5e3b2fSeh146360 #define IPW2100_CMD_SET_WEP_KEY_INDEX (25) 406bb5e3b2fSeh146360 #define IPW2100_CMD_SET_WEP_FLAGS (26) 407bb5e3b2fSeh146360 #define IPW2100_CMD_ADD_MULTICAST (27) 408bb5e3b2fSeh146360 #define IPW2100_CMD_CLR_MULTICAST (28) 409bb5e3b2fSeh146360 #define IPW2100_CMD_SET_BEACON_INTERVAL (29) 410bb5e3b2fSeh146360 #define IPW2100_CMD_CLR_STATISTICS (31) 411bb5e3b2fSeh146360 #define IPW2100_CMD_SEND (33) 412bb5e3b2fSeh146360 #define IPW2100_CMD_SET_TX_POWER_INDEX (36) 413bb5e3b2fSeh146360 #define IPW2100_CMD_BROADCAST_SCAN (43) 414bb5e3b2fSeh146360 #define IPW2100_CMD_DISABLE (44) 415bb5e3b2fSeh146360 #define IPW2100_CMD_SET_DESIRED_BSSID (45) 416bb5e3b2fSeh146360 #define IPW2100_CMD_SET_SCAN_OPTIONS (46) 417bb5e3b2fSeh146360 #define IPW2100_CMD_PREPARE_POWER_DOWN (58) 418bb5e3b2fSeh146360 #define IPW2100_CMD_DISABLE_PHY (61) 419bb5e3b2fSeh146360 #define IPW2100_CMD_SET_SECURITY_INFORMATION (67) 420bb5e3b2fSeh146360 #define IPW2100_CMD_SET_WPA_IE (69) 421bb5e3b2fSeh146360 uint32_t subtype; 422bb5e3b2fSeh146360 uint32_t seq; 423bb5e3b2fSeh146360 uint32_t len; 424bb5e3b2fSeh146360 uint8_t data[400]; 425bb5e3b2fSeh146360 uint32_t status; 426bb5e3b2fSeh146360 uint8_t reserved[68]; 427bb5e3b2fSeh146360 }; 428bb5e3b2fSeh146360 429bb5e3b2fSeh146360 /* 430bb5e3b2fSeh146360 * IPW2100_CMD_SET_POWER_MODE 431bb5e3b2fSeh146360 */ 432bb5e3b2fSeh146360 #define IPW2100_POWER_MODE_CAM (0) 433bb5e3b2fSeh146360 #define IPW2100_POWER_AUTOMATIC (6) 434bb5e3b2fSeh146360 435bb5e3b2fSeh146360 /* 436bb5e3b2fSeh146360 * IPW2100_CMD_SET_MODE 437bb5e3b2fSeh146360 */ 438bb5e3b2fSeh146360 #define IPW2100_MODE_BSS (0) 439bb5e3b2fSeh146360 #define IPW2100_MODE_IBSS (1) 440bb5e3b2fSeh146360 #define IPW2100_MODE_MONITOR (2) 441bb5e3b2fSeh146360 442bb5e3b2fSeh146360 /* 443bb5e3b2fSeh146360 * structure for IPW2100_CMD_SET_WEP_KEY 444bb5e3b2fSeh146360 */ 445bb5e3b2fSeh146360 struct ipw2100_wep_key { 446bb5e3b2fSeh146360 uint8_t idx; 447bb5e3b2fSeh146360 uint8_t len; 448bb5e3b2fSeh146360 uint8_t key[13]; 449bb5e3b2fSeh146360 }; 450bb5e3b2fSeh146360 451bb5e3b2fSeh146360 /* 452bb5e3b2fSeh146360 * structure for IPW2100_CMD_SET_SECURITY_INFORMATION 453bb5e3b2fSeh146360 */ 454bb5e3b2fSeh146360 struct ipw2100_security { 455bb5e3b2fSeh146360 uint32_t ciphers; 456bb5e3b2fSeh146360 #define IPW2100_CIPHER_NONE (0x00000001) 457bb5e3b2fSeh146360 #define IPW2100_CIPHER_WEP40 (0x00000002) 458bb5e3b2fSeh146360 #define IPW2100_CIPHER_WEP104 (0x00000020) 459bb5e3b2fSeh146360 uint16_t version; 460bb5e3b2fSeh146360 uint8_t authmode; 461bb5e3b2fSeh146360 #define IPW2100_AUTH_OPEN (0) 462bb5e3b2fSeh146360 #define IPW2100_AUTH_SHARED (1) 463bb5e3b2fSeh146360 uint8_t replay_counters_number; 464bb5e3b2fSeh146360 uint8_t unicast_using_group; 465bb5e3b2fSeh146360 }; 466bb5e3b2fSeh146360 467bb5e3b2fSeh146360 /* 468bb5e3b2fSeh146360 * structure for IPW2100_CMD_SET_SCAN_OPTIONS 469bb5e3b2fSeh146360 */ 470bb5e3b2fSeh146360 struct ipw2100_scan_options { 471bb5e3b2fSeh146360 uint32_t flags; 472bb5e3b2fSeh146360 #define IPW2100_SCAN_DO_NOT_ASSOCIATE (0x00000001) 473bb5e3b2fSeh146360 #define IPW2100_SCAN_PASSIVE (0x00000008) 474bb5e3b2fSeh146360 uint32_t channels; 475bb5e3b2fSeh146360 }; 476bb5e3b2fSeh146360 477bb5e3b2fSeh146360 /* 478bb5e3b2fSeh146360 * structure for IPW2100_CMD_SET_CONFIGURATION 479bb5e3b2fSeh146360 */ 480bb5e3b2fSeh146360 struct ipw2100_configuration { 481bb5e3b2fSeh146360 uint32_t flags; 482bb5e3b2fSeh146360 #define IPW2100_CFG_PROMISCUOUS (0x00000004) 483bb5e3b2fSeh146360 #define IPW2100_CFG_PREAMBLE_AUTO (0x00000010) 484bb5e3b2fSeh146360 #define IPW2100_CFG_IBSS_AUTO_START (0x00000020) 485bb5e3b2fSeh146360 #define IPW2100_CFG_802_1x_ENABLE (0x00004000) 486bb5e3b2fSeh146360 #define IPW2100_CFG_BSS_MASK (0x00008000) 487bb5e3b2fSeh146360 #define IPW2100_CFG_IBSS_MASK (0x00010000) 488bb5e3b2fSeh146360 uint32_t bss_chan; 489bb5e3b2fSeh146360 uint32_t ibss_chan; 490bb5e3b2fSeh146360 }; 491bb5e3b2fSeh146360 492bb5e3b2fSeh146360 /* 493bb5e3b2fSeh146360 * element in AP table 494bb5e3b2fSeh146360 */ 495bb5e3b2fSeh146360 struct ipw2100_node { 496bb5e3b2fSeh146360 uint32_t reserved_1[2]; 497bb5e3b2fSeh146360 uint8_t bssid[IEEE80211_ADDR_LEN]; 498bb5e3b2fSeh146360 uint8_t chan; 499bb5e3b2fSeh146360 uint8_t rates; 500bb5e3b2fSeh146360 uint16_t reserved_2; 501bb5e3b2fSeh146360 uint16_t capinfo; 502bb5e3b2fSeh146360 uint16_t reserved_3; 503bb5e3b2fSeh146360 uint16_t intval; 504bb5e3b2fSeh146360 uint8_t reserved_4[28]; 505bb5e3b2fSeh146360 uint8_t essid[IEEE80211_NWID_LEN]; 506bb5e3b2fSeh146360 uint16_t reserved_5; 507bb5e3b2fSeh146360 uint8_t esslen; 508bb5e3b2fSeh146360 uint8_t reserved_6[7]; 509bb5e3b2fSeh146360 uint8_t rssi; 510bb5e3b2fSeh146360 }; 511bb5e3b2fSeh146360 #pragma pack() 512bb5e3b2fSeh146360 513bb5e3b2fSeh146360 /* 514bb5e3b2fSeh146360 * transmit buffer block 515bb5e3b2fSeh146360 */ 516bb5e3b2fSeh146360 struct ipw2100_txb { 517bb5e3b2fSeh146360 struct ipw2100_hdr txb_hdr; /* header */ 518bb5e3b2fSeh146360 uint8_t txb_dat[IEEE80211_MAX_LEN]; /* payload */ 519bb5e3b2fSeh146360 }; 520bb5e3b2fSeh146360 521bb5e3b2fSeh146360 /* 522bb5e3b2fSeh146360 * maximum frame header lenght: 4 MAC addresses + 1 fc + 1 id + 1 seqctl 523bb5e3b2fSeh146360 */ 524bb5e3b2fSeh146360 #define IEEE80211_MAX_FHLEN (4*6+2+2+2) 525bb5e3b2fSeh146360 526bb5e3b2fSeh146360 /* 527bb5e3b2fSeh146360 * receive buffer block 528bb5e3b2fSeh146360 */ 529bb5e3b2fSeh146360 struct ipw2100_rxb { 530bb5e3b2fSeh146360 uint8_t rxb_dat[IEEE80211_MAX_FHLEN /* frame */ 531bb5e3b2fSeh146360 + IEEE80211_MAX_LEN /* payload */ 532bb5e3b2fSeh146360 + IEEE80211_CRC_LEN]; /* FCS */ 533bb5e3b2fSeh146360 }; 534bb5e3b2fSeh146360 535bb5e3b2fSeh146360 /* 536bb5e3b2fSeh146360 * ROM entries 537bb5e3b2fSeh146360 */ 538bb5e3b2fSeh146360 #define IPW2100_ROM_RADIO (0x11) 539bb5e3b2fSeh146360 #define IPW2100_ROM_MAC (0x21) 540bb5e3b2fSeh146360 #define IPW2100_ROM_CHANNEL_LIST (0x37) 541bb5e3b2fSeh146360 542bb5e3b2fSeh146360 /* 543bb5e3b2fSeh146360 * EEPROM controls 544bb5e3b2fSeh146360 */ 545bb5e3b2fSeh146360 #define IPW2100_IMEM_EEPROM_CTL (0x00300040) 546bb5e3b2fSeh146360 #define IPW2100_EEPROM_DELAY (1) 547bb5e3b2fSeh146360 548bb5e3b2fSeh146360 /* 549bb5e3b2fSeh146360 * CSR access routines 550bb5e3b2fSeh146360 */ 551bb5e3b2fSeh146360 extern uint8_t ipw2100_csr_get8(struct ipw2100_softc *sc, uint32_t off); 552bb5e3b2fSeh146360 extern uint16_t ipw2100_csr_get16(struct ipw2100_softc *sc, uint32_t off); 553bb5e3b2fSeh146360 extern uint32_t ipw2100_csr_get32(struct ipw2100_softc *sc, uint32_t off); 554bb5e3b2fSeh146360 extern void ipw2100_csr_rep_get16(struct ipw2100_softc *sc, uint32_t off, 555bb5e3b2fSeh146360 uint16_t *buf, size_t cnt); 556bb5e3b2fSeh146360 extern void ipw2100_csr_put8(struct ipw2100_softc *sc, uint32_t off, 557bb5e3b2fSeh146360 uint8_t val); 558bb5e3b2fSeh146360 extern void ipw2100_csr_put16(struct ipw2100_softc *sc, 559bb5e3b2fSeh146360 uint32_t off, uint16_t val); 560bb5e3b2fSeh146360 extern void ipw2100_csr_put32(struct ipw2100_softc *sc, 561bb5e3b2fSeh146360 uint32_t off, uint32_t val); 562bb5e3b2fSeh146360 extern void ipw2100_csr_rep_put8(struct ipw2100_softc *sc, 563bb5e3b2fSeh146360 uint32_t off, uint8_t *buf, size_t cnt); 564bb5e3b2fSeh146360 extern uint8_t ipw2100_imem_get8(struct ipw2100_softc *sc, int32_t addr); 565bb5e3b2fSeh146360 extern uint16_t ipw2100_imem_get16(struct ipw2100_softc *sc, 566bb5e3b2fSeh146360 uint32_t addr); 567bb5e3b2fSeh146360 extern uint32_t ipw2100_imem_get32(struct ipw2100_softc *sc, 568bb5e3b2fSeh146360 uint32_t addr); 569bb5e3b2fSeh146360 extern void ipw2100_imem_rep_get16(struct ipw2100_softc *sc, 570bb5e3b2fSeh146360 uint32_t addr, uint16_t *buf, size_t cnt); 571bb5e3b2fSeh146360 extern void ipw2100_imem_put8(struct ipw2100_softc *sc, 572bb5e3b2fSeh146360 uint32_t addr, uint8_t val); 573bb5e3b2fSeh146360 extern void ipw2100_imem_put16(struct ipw2100_softc *sc, 574bb5e3b2fSeh146360 uint32_t addr, uint16_t val); 575bb5e3b2fSeh146360 extern void ipw2100_imem_put32(struct ipw2100_softc *sc, 576bb5e3b2fSeh146360 uint32_t addr, uint32_t val); 577bb5e3b2fSeh146360 extern void ipw2100_imem_rep_put8(struct ipw2100_softc *sc, 578bb5e3b2fSeh146360 uint32_t addr, uint8_t *buf, size_t cnt); 579bb5e3b2fSeh146360 extern void ipw2100_imem_getbuf(struct ipw2100_softc *sc, 580bb5e3b2fSeh146360 uint32_t addr, uint8_t *buf, size_t cnt); 581bb5e3b2fSeh146360 extern void ipw2100_imem_putbuf(struct ipw2100_softc *sc, 582bb5e3b2fSeh146360 uint32_t addr, uint8_t *buf, size_t cnt); 583bb5e3b2fSeh146360 extern void ipw2100_rom_control(struct ipw2100_softc *sc, uint32_t val); 584bb5e3b2fSeh146360 extern uint8_t ipw2100_table1_get8(struct ipw2100_softc *sc, uint32_t off); 585bb5e3b2fSeh146360 extern uint32_t ipw2100_table1_get32(struct ipw2100_softc *sc, 586bb5e3b2fSeh146360 uint32_t off); 587bb5e3b2fSeh146360 extern void ipw2100_table1_put32(struct ipw2100_softc *sc, 588bb5e3b2fSeh146360 uint32_t off, uint32_t val); 589bb5e3b2fSeh146360 extern int ipw2100_table2_getbuf(struct ipw2100_softc *sc, 590bb5e3b2fSeh146360 uint32_t off, uint8_t *buf, uint32_t *len); 591bb5e3b2fSeh146360 592bb5e3b2fSeh146360 extern uint16_t ipw2100_rom_get16(struct ipw2100_softc *sc, uint8_t addr); 593bb5e3b2fSeh146360 594bb5e3b2fSeh146360 /* 595bb5e3b2fSeh146360 * Firmware related definations and interfaces. 596bb5e3b2fSeh146360 */ 597bb5e3b2fSeh146360 extern int ipw2100_cache_firmware(struct ipw2100_softc *sc); 598bb5e3b2fSeh146360 extern int ipw2100_free_firmware(struct ipw2100_softc *sc); 599bb5e3b2fSeh146360 extern int ipw2100_load_uc(struct ipw2100_softc *sc); 600bb5e3b2fSeh146360 extern int ipw2100_load_fw(struct ipw2100_softc *sc); 601bb5e3b2fSeh146360 602bb5e3b2fSeh146360 #ifdef __cplusplus 603bb5e3b2fSeh146360 } 604bb5e3b2fSeh146360 #endif 605bb5e3b2fSeh146360 606bb5e3b2fSeh146360 #endif /* _SYS_IPW2100_IMPL_H */ 607