1 4128 hx147065 /* 2 8902 Pengcheng * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 3 4128 hx147065 * Use is subject to license terms. 4 4128 hx147065 */ 5 4128 hx147065 /* 6 4128 hx147065 * Copyright (c) 2006 7 4128 hx147065 * Damien Bergamini <damien.bergamini (at) free.fr> 8 4128 hx147065 * 9 4128 hx147065 * Permission to use, copy, modify, and distribute this software for any 10 4128 hx147065 * purpose with or without fee is hereby granted, provided that the above 11 4128 hx147065 * copyright notice and this permission notice appear in all copies. 12 4128 hx147065 * 13 4128 hx147065 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 14 4128 hx147065 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 15 4128 hx147065 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 16 4128 hx147065 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 17 4128 hx147065 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 18 4128 hx147065 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 19 4128 hx147065 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 20 4128 hx147065 */ 21 4128 hx147065 #ifndef _WPIVAR_H 22 4128 hx147065 #define _WPIVAR_H 23 4128 hx147065 24 4128 hx147065 #ifdef __cplusplus 25 4128 hx147065 extern "C" { 26 4128 hx147065 #endif 27 4128 hx147065 28 4128 hx147065 #ifdef WPI_BPF 29 4128 hx147065 typedef struct wpi_rx_radiotap_header { 30 4128 hx147065 struct ieee80211_radiotap_header wr_ihdr; 31 4128 hx147065 uint64_t wr_tsft; 32 4128 hx147065 uint8_t wr_flags; 33 4128 hx147065 uint8_t wr_rate; 34 4128 hx147065 uint16_t wr_chan_freq; 35 4128 hx147065 uint16_t wr_chan_flags; 36 4128 hx147065 int8_t wr_dbm_antsignal; 37 4128 hx147065 int8_t wr_dbm_antnoise; 38 4128 hx147065 uint8_t wr_antenna; 39 4128 hx147065 } wpi_rx_radiotap_header_t; 40 4128 hx147065 41 4128 hx147065 #define WPI_RX_RADIOTAP_PRESENT \ 42 4128 hx147065 ((1 << IEEE80211_RADIOTAP_TSFT) | \ 43 4128 hx147065 (1 << IEEE80211_RADIOTAP_FLAGS) | \ 44 4128 hx147065 (1 << IEEE80211_RADIOTAP_RATE) | \ 45 4128 hx147065 (1 << IEEE80211_RADIOTAP_CHANNEL) | \ 46 4128 hx147065 (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) | \ 47 4128 hx147065 (1 << IEEE80211_RADIOTAP_DBM_ANTNOISE) | \ 48 4128 hx147065 (1 << IEEE80211_RADIOTAP_ANTENNA)) 49 4128 hx147065 50 4128 hx147065 typedef struct wpi_tx_radiotap_header { 51 4128 hx147065 struct ieee80211_radiotap_header wt_ihdr; 52 4128 hx147065 uint8_t wt_flags; 53 4128 hx147065 uint8_t wt_rate; 54 4128 hx147065 uint16_t wt_chan_freq; 55 4128 hx147065 uint16_t wt_chan_flags; 56 4128 hx147065 } wpi_tx_radiotap_header_t; 57 4128 hx147065 58 4128 hx147065 #define WPI_TX_RADIOTAP_PRESENT \ 59 4128 hx147065 ((1 << IEEE80211_RADIOTAP_FLAGS) | \ 60 4128 hx147065 (1 << IEEE80211_RADIOTAP_RATE) | \ 61 4128 hx147065 (1 << IEEE80211_RADIOTAP_CHANNEL)) 62 4128 hx147065 #endif 63 4128 hx147065 64 4128 hx147065 #define WPI_DMA_SYNC(area, flag) \ 65 4128 hx147065 (void) ddi_dma_sync((area).dma_hdl, (area).offset, \ 66 4128 hx147065 (area).alength, (flag)) 67 8902 Pengcheng 68 8902 Pengcheng #define WPI_CHK_FAST_RECOVER(sc) \ 69 8902 Pengcheng (sc->sc_ic.ic_state == IEEE80211_S_RUN && \ 70 8902 Pengcheng sc->sc_ic.ic_opmode == IEEE80211_M_STA) 71 4128 hx147065 72 4128 hx147065 typedef struct wpi_dma_area { 73 4128 hx147065 ddi_acc_handle_t acc_hdl; /* handle for memory */ 74 4128 hx147065 caddr_t mem_va; /* CPU VA of memory */ 75 4128 hx147065 uint32_t nslots; /* number of slots */ 76 4128 hx147065 uint32_t size; /* size per slot */ 77 4128 hx147065 size_t alength; /* allocated size */ 78 4128 hx147065 /* >= product of above */ 79 4128 hx147065 ddi_dma_handle_t dma_hdl; /* DMA handle */ 80 4128 hx147065 offset_t offset; /* relative to handle */ 81 4128 hx147065 ddi_dma_cookie_t cookie; /* associated cookie */ 82 4128 hx147065 uint32_t ncookies; 83 4128 hx147065 uint32_t token; /* arbitrary identifier */ 84 4128 hx147065 } wpi_dma_t; 85 4128 hx147065 86 4128 hx147065 typedef struct wpi_tx_data { 87 4128 hx147065 wpi_dma_t dma_data; 88 4128 hx147065 wpi_tx_desc_t *desc; 89 4128 hx147065 uint32_t paddr_desc; 90 4128 hx147065 wpi_tx_cmd_t *cmd; 91 4128 hx147065 uint32_t paddr_cmd; 92 4128 hx147065 } wpi_tx_data_t; 93 4128 hx147065 94 4128 hx147065 typedef struct wpi_tx_ring { 95 4128 hx147065 wpi_dma_t dma_desc; 96 4128 hx147065 wpi_dma_t dma_cmd; 97 4128 hx147065 wpi_tx_data_t *data; 98 4128 hx147065 int qid; 99 4128 hx147065 int count; 100 4128 hx147065 int queued; 101 4128 hx147065 int cur; 102 4128 hx147065 } wpi_tx_ring_t; 103 4128 hx147065 104 4128 hx147065 typedef struct wpi_rx_data { 105 4128 hx147065 wpi_dma_t dma_data; 106 4128 hx147065 } wpi_rx_data_t; 107 4128 hx147065 108 4128 hx147065 typedef struct wpi_rx_ring { 109 4128 hx147065 wpi_dma_t dma_desc; 110 4128 hx147065 uint32_t *desc; 111 4128 hx147065 wpi_rx_data_t data[WPI_RX_RING_COUNT]; 112 4128 hx147065 int cur; 113 4128 hx147065 } wpi_rx_ring_t; 114 4128 hx147065 115 4128 hx147065 typedef struct wpi_amrr { 116 4128 hx147065 ieee80211_node_t in; /* must be the first */ 117 4128 hx147065 int txcnt; 118 4128 hx147065 int retrycnt; 119 4128 hx147065 int success; 120 4128 hx147065 int success_threshold; 121 4128 hx147065 int recovery; 122 4128 hx147065 } wpi_amrr_t; 123 4128 hx147065 124 4128 hx147065 typedef struct wpi_softc { 125 4128 hx147065 struct ieee80211com sc_ic; 126 4128 hx147065 dev_info_t *sc_dip; 127 4128 hx147065 int (*sc_newstate)(struct ieee80211com *, 128 4128 hx147065 enum ieee80211_state, int); 129 4128 hx147065 enum ieee80211_state sc_ostate; 130 4128 hx147065 kmutex_t sc_glock; 131 4128 hx147065 kmutex_t sc_mt_lock; 132 4128 hx147065 kmutex_t sc_tx_lock; 133 4128 hx147065 kcondvar_t sc_mt_cv; 134 4128 hx147065 kcondvar_t sc_tx_cv; 135 4128 hx147065 kcondvar_t sc_cmd_cv; 136 4128 hx147065 kcondvar_t sc_fw_cv; 137 4128 hx147065 138 4128 hx147065 kthread_t *sc_mf_thread; 139 4128 hx147065 uint32_t sc_mf_thread_switch; 140 4128 hx147065 141 4128 hx147065 uint32_t sc_flags; 142 4128 hx147065 uint32_t sc_dmabuf_sz; 143 4128 hx147065 uint16_t sc_clsz; 144 4128 hx147065 uint8_t sc_rev; 145 4128 hx147065 uint8_t sc_resv; 146 4128 hx147065 147 4128 hx147065 /* shared area */ 148 4128 hx147065 wpi_dma_t sc_dma_sh; 149 4128 hx147065 wpi_shared_t *sc_shared; 150 4128 hx147065 151 4128 hx147065 wpi_tx_ring_t sc_txq[4]; 152 4128 hx147065 wpi_tx_ring_t sc_cmdq; 153 4128 hx147065 wpi_tx_ring_t sc_svcq; 154 4128 hx147065 wpi_rx_ring_t sc_rxq; 155 4128 hx147065 156 4128 hx147065 /* dma */ 157 4128 hx147065 const wpi_firmware_hdr_t *sc_hdr; 158 4128 hx147065 const char *sc_boot; 159 4128 hx147065 const char *sc_text; 160 4128 hx147065 const char *sc_data; 161 4128 hx147065 wpi_dma_t sc_dma_fw_text; 162 4128 hx147065 ddi_dma_cookie_t sc_fw_text_cookie[4]; 163 4128 hx147065 wpi_dma_t sc_dma_fw_data; 164 4128 hx147065 ddi_dma_cookie_t sc_fw_data_cookie[4]; 165 4128 hx147065 166 4128 hx147065 ddi_acc_handle_t sc_handle; 167 4128 hx147065 caddr_t sc_base; 168 4128 hx147065 ddi_iblock_cookie_t sc_iblk; 169 4128 hx147065 170 4128 hx147065 wpi_config_t sc_config; 171 8902 Pengcheng wpi_config_t sc_config_save; 172 8902 Pengcheng 173 4128 hx147065 uint16_t sc_pwr1[14]; 174 4128 hx147065 uint16_t sc_pwr2[14]; 175 4128 hx147065 176 4128 hx147065 uint32_t sc_tx_timer; 177 7865 Pengcheng uint32_t sc_scan_next; 178 7865 Pengcheng uint32_t sc_scan_pending; 179 4128 hx147065 uint8_t *sc_fw_bin; 180 4128 hx147065 181 4128 hx147065 ddi_softintr_t sc_notif_softint_id; 182 4128 hx147065 uint32_t sc_notif_softint_pending; 183 4128 hx147065 uint32_t sc_need_reschedule; 184 4128 hx147065 185 4128 hx147065 clock_t sc_clk; 186 4128 hx147065 187 4128 hx147065 /* kstats */ 188 4128 hx147065 uint32_t sc_tx_nobuf; 189 4128 hx147065 uint32_t sc_rx_nobuf; 190 4128 hx147065 uint32_t sc_tx_err; 191 4128 hx147065 uint32_t sc_rx_err; 192 4128 hx147065 uint32_t sc_tx_retries; 193 6062 hx147065 194 4128 hx147065 #ifdef WPI_BPF 195 4128 hx147065 struct bpf_if *sc_drvbpf; 196 4128 hx147065 197 4128 hx147065 union { 198 4128 hx147065 struct wpi_rx_radiotap_header th; 199 4128 hx147065 uint8_t pad[64]; 200 4128 hx147065 } sc_rxtapu; 201 4128 hx147065 #define sc_rxtap sc_rxtapu.th 202 4128 hx147065 int sc_rxtap_len; 203 4128 hx147065 204 4128 hx147065 union { 205 4128 hx147065 struct wpi_tx_radiotap_header th; 206 4128 hx147065 uint8_t pad[64]; 207 4128 hx147065 } sc_txtapu; 208 4128 hx147065 #define sc_txtap sc_txtapu.th 209 4128 hx147065 int sc_txtap_len; 210 4128 hx147065 #endif 211 4128 hx147065 } wpi_sc_t; 212 4128 hx147065 213 4128 hx147065 #define WPI_F_ATTACHED (1 << 0) 214 4128 hx147065 #define WPI_F_CMD_DONE (1 << 1) 215 4128 hx147065 #define WPI_F_FW_INIT (1 << 2) 216 4128 hx147065 #define WPI_F_HW_ERR_RECOVER (1 << 3) 217 4128 hx147065 #define WPI_F_RATE_AUTO_CTL (1 << 4) 218 4128 hx147065 #define WPI_F_RUNNING (1 << 5) 219 6062 hx147065 #define WPI_F_SUSPEND (1 << 6) 220 6062 hx147065 #define WPI_F_RADIO_OFF (1 << 7) 221 7865 Pengcheng #define WPI_F_SCANNING (1 << 8) 222 8165 Fei #define WPI_F_QUIESCED (1 << 9) 223 8349 Pengcheng #define WPI_F_LAZY_RESUME (1 << 10) 224 4128 hx147065 225 4128 hx147065 #define WPI_SUCCESS 0 226 6629 zf162725 #define WPI_FAIL (EIO) 227 4128 hx147065 #ifdef __cplusplus 228 4128 hx147065 } 229 4128 hx147065 #endif 230 4128 hx147065 231 4128 hx147065 #endif /* _WPIVAR_H */ 232