184f7a9b9Shx147065 /* 2*6f12def4Spengcheng chen - Sun Microsystems - Beijing China * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 384f7a9b9Shx147065 * Use is subject to license terms. 484f7a9b9Shx147065 */ 584f7a9b9Shx147065 /* 684f7a9b9Shx147065 * Copyright (c) 2006 784f7a9b9Shx147065 * Damien Bergamini <damien.bergamini@free.fr> 884f7a9b9Shx147065 * 984f7a9b9Shx147065 * Permission to use, copy, modify, and distribute this software for any 1084f7a9b9Shx147065 * purpose with or without fee is hereby granted, provided that the above 1184f7a9b9Shx147065 * copyright notice and this permission notice appear in all copies. 1284f7a9b9Shx147065 * 1384f7a9b9Shx147065 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 1484f7a9b9Shx147065 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 1584f7a9b9Shx147065 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 1684f7a9b9Shx147065 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 1784f7a9b9Shx147065 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 1884f7a9b9Shx147065 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 1984f7a9b9Shx147065 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 2084f7a9b9Shx147065 */ 2184f7a9b9Shx147065 #ifndef _WPIVAR_H 2284f7a9b9Shx147065 #define _WPIVAR_H 2384f7a9b9Shx147065 2484f7a9b9Shx147065 #ifdef __cplusplus 2584f7a9b9Shx147065 extern "C" { 2684f7a9b9Shx147065 #endif 2784f7a9b9Shx147065 2884f7a9b9Shx147065 #ifdef WPI_BPF 2984f7a9b9Shx147065 typedef struct wpi_rx_radiotap_header { 3084f7a9b9Shx147065 struct ieee80211_radiotap_header wr_ihdr; 3184f7a9b9Shx147065 uint64_t wr_tsft; 3284f7a9b9Shx147065 uint8_t wr_flags; 3384f7a9b9Shx147065 uint8_t wr_rate; 3484f7a9b9Shx147065 uint16_t wr_chan_freq; 3584f7a9b9Shx147065 uint16_t wr_chan_flags; 3684f7a9b9Shx147065 int8_t wr_dbm_antsignal; 3784f7a9b9Shx147065 int8_t wr_dbm_antnoise; 3884f7a9b9Shx147065 uint8_t wr_antenna; 3984f7a9b9Shx147065 } wpi_rx_radiotap_header_t; 4084f7a9b9Shx147065 4184f7a9b9Shx147065 #define WPI_RX_RADIOTAP_PRESENT \ 4284f7a9b9Shx147065 ((1 << IEEE80211_RADIOTAP_TSFT) | \ 4384f7a9b9Shx147065 (1 << IEEE80211_RADIOTAP_FLAGS) | \ 4484f7a9b9Shx147065 (1 << IEEE80211_RADIOTAP_RATE) | \ 4584f7a9b9Shx147065 (1 << IEEE80211_RADIOTAP_CHANNEL) | \ 4684f7a9b9Shx147065 (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) | \ 4784f7a9b9Shx147065 (1 << IEEE80211_RADIOTAP_DBM_ANTNOISE) | \ 4884f7a9b9Shx147065 (1 << IEEE80211_RADIOTAP_ANTENNA)) 4984f7a9b9Shx147065 5084f7a9b9Shx147065 typedef struct wpi_tx_radiotap_header { 5184f7a9b9Shx147065 struct ieee80211_radiotap_header wt_ihdr; 5284f7a9b9Shx147065 uint8_t wt_flags; 5384f7a9b9Shx147065 uint8_t wt_rate; 5484f7a9b9Shx147065 uint16_t wt_chan_freq; 5584f7a9b9Shx147065 uint16_t wt_chan_flags; 5684f7a9b9Shx147065 } wpi_tx_radiotap_header_t; 5784f7a9b9Shx147065 5884f7a9b9Shx147065 #define WPI_TX_RADIOTAP_PRESENT \ 5984f7a9b9Shx147065 ((1 << IEEE80211_RADIOTAP_FLAGS) | \ 6084f7a9b9Shx147065 (1 << IEEE80211_RADIOTAP_RATE) | \ 6184f7a9b9Shx147065 (1 << IEEE80211_RADIOTAP_CHANNEL)) 6284f7a9b9Shx147065 #endif 6384f7a9b9Shx147065 6484f7a9b9Shx147065 #define WPI_DMA_SYNC(area, flag) \ 6584f7a9b9Shx147065 (void) ddi_dma_sync((area).dma_hdl, (area).offset, \ 6684f7a9b9Shx147065 (area).alength, (flag)) 6784f7a9b9Shx147065 68*6f12def4Spengcheng chen - Sun Microsystems - Beijing China #define WPI_CHK_FAST_RECOVER(sc) \ 69*6f12def4Spengcheng chen - Sun Microsystems - Beijing China (sc->sc_ic.ic_state == IEEE80211_S_RUN && \ 70*6f12def4Spengcheng chen - Sun Microsystems - Beijing China sc->sc_ic.ic_opmode == IEEE80211_M_STA) 71*6f12def4Spengcheng chen - Sun Microsystems - Beijing China 7284f7a9b9Shx147065 typedef struct wpi_dma_area { 7384f7a9b9Shx147065 ddi_acc_handle_t acc_hdl; /* handle for memory */ 7484f7a9b9Shx147065 caddr_t mem_va; /* CPU VA of memory */ 7584f7a9b9Shx147065 uint32_t nslots; /* number of slots */ 7684f7a9b9Shx147065 uint32_t size; /* size per slot */ 7784f7a9b9Shx147065 size_t alength; /* allocated size */ 7884f7a9b9Shx147065 /* >= product of above */ 7984f7a9b9Shx147065 ddi_dma_handle_t dma_hdl; /* DMA handle */ 8084f7a9b9Shx147065 offset_t offset; /* relative to handle */ 8184f7a9b9Shx147065 ddi_dma_cookie_t cookie; /* associated cookie */ 8284f7a9b9Shx147065 uint32_t ncookies; 8384f7a9b9Shx147065 uint32_t token; /* arbitrary identifier */ 8484f7a9b9Shx147065 } wpi_dma_t; 8584f7a9b9Shx147065 8684f7a9b9Shx147065 typedef struct wpi_tx_data { 8784f7a9b9Shx147065 wpi_dma_t dma_data; 8884f7a9b9Shx147065 wpi_tx_desc_t *desc; 8984f7a9b9Shx147065 uint32_t paddr_desc; 9084f7a9b9Shx147065 wpi_tx_cmd_t *cmd; 9184f7a9b9Shx147065 uint32_t paddr_cmd; 9284f7a9b9Shx147065 } wpi_tx_data_t; 9384f7a9b9Shx147065 9484f7a9b9Shx147065 typedef struct wpi_tx_ring { 9584f7a9b9Shx147065 wpi_dma_t dma_desc; 9684f7a9b9Shx147065 wpi_dma_t dma_cmd; 9784f7a9b9Shx147065 wpi_tx_data_t *data; 9884f7a9b9Shx147065 int qid; 9984f7a9b9Shx147065 int count; 10084f7a9b9Shx147065 int queued; 10184f7a9b9Shx147065 int cur; 10284f7a9b9Shx147065 } wpi_tx_ring_t; 10384f7a9b9Shx147065 10484f7a9b9Shx147065 typedef struct wpi_rx_data { 10584f7a9b9Shx147065 wpi_dma_t dma_data; 10684f7a9b9Shx147065 } wpi_rx_data_t; 10784f7a9b9Shx147065 10884f7a9b9Shx147065 typedef struct wpi_rx_ring { 10984f7a9b9Shx147065 wpi_dma_t dma_desc; 11084f7a9b9Shx147065 uint32_t *desc; 11184f7a9b9Shx147065 wpi_rx_data_t data[WPI_RX_RING_COUNT]; 11284f7a9b9Shx147065 int cur; 11384f7a9b9Shx147065 } wpi_rx_ring_t; 11484f7a9b9Shx147065 11584f7a9b9Shx147065 typedef struct wpi_amrr { 11684f7a9b9Shx147065 ieee80211_node_t in; /* must be the first */ 11784f7a9b9Shx147065 int txcnt; 11884f7a9b9Shx147065 int retrycnt; 11984f7a9b9Shx147065 int success; 12084f7a9b9Shx147065 int success_threshold; 12184f7a9b9Shx147065 int recovery; 12284f7a9b9Shx147065 } wpi_amrr_t; 12384f7a9b9Shx147065 12484f7a9b9Shx147065 typedef struct wpi_softc { 12584f7a9b9Shx147065 struct ieee80211com sc_ic; 12684f7a9b9Shx147065 dev_info_t *sc_dip; 12784f7a9b9Shx147065 int (*sc_newstate)(struct ieee80211com *, 12884f7a9b9Shx147065 enum ieee80211_state, int); 12984f7a9b9Shx147065 enum ieee80211_state sc_ostate; 13084f7a9b9Shx147065 kmutex_t sc_glock; 13184f7a9b9Shx147065 kmutex_t sc_mt_lock; 13284f7a9b9Shx147065 kmutex_t sc_tx_lock; 13384f7a9b9Shx147065 kcondvar_t sc_mt_cv; 13484f7a9b9Shx147065 kcondvar_t sc_tx_cv; 13584f7a9b9Shx147065 kcondvar_t sc_cmd_cv; 13684f7a9b9Shx147065 kcondvar_t sc_fw_cv; 13784f7a9b9Shx147065 13884f7a9b9Shx147065 kthread_t *sc_mf_thread; 13984f7a9b9Shx147065 uint32_t sc_mf_thread_switch; 14084f7a9b9Shx147065 14184f7a9b9Shx147065 uint32_t sc_flags; 14284f7a9b9Shx147065 uint32_t sc_dmabuf_sz; 14384f7a9b9Shx147065 uint16_t sc_clsz; 14484f7a9b9Shx147065 uint8_t sc_rev; 14584f7a9b9Shx147065 uint8_t sc_resv; 14684f7a9b9Shx147065 14784f7a9b9Shx147065 /* shared area */ 14884f7a9b9Shx147065 wpi_dma_t sc_dma_sh; 14984f7a9b9Shx147065 wpi_shared_t *sc_shared; 15084f7a9b9Shx147065 15184f7a9b9Shx147065 wpi_tx_ring_t sc_txq[4]; 15284f7a9b9Shx147065 wpi_tx_ring_t sc_cmdq; 15384f7a9b9Shx147065 wpi_tx_ring_t sc_svcq; 15484f7a9b9Shx147065 wpi_rx_ring_t sc_rxq; 15584f7a9b9Shx147065 15684f7a9b9Shx147065 /* dma */ 15784f7a9b9Shx147065 const wpi_firmware_hdr_t *sc_hdr; 15884f7a9b9Shx147065 const char *sc_boot; 15984f7a9b9Shx147065 const char *sc_text; 16084f7a9b9Shx147065 const char *sc_data; 16184f7a9b9Shx147065 wpi_dma_t sc_dma_fw_text; 16284f7a9b9Shx147065 ddi_dma_cookie_t sc_fw_text_cookie[4]; 16384f7a9b9Shx147065 wpi_dma_t sc_dma_fw_data; 16484f7a9b9Shx147065 ddi_dma_cookie_t sc_fw_data_cookie[4]; 16584f7a9b9Shx147065 16684f7a9b9Shx147065 ddi_acc_handle_t sc_handle; 16784f7a9b9Shx147065 caddr_t sc_base; 16884f7a9b9Shx147065 ddi_iblock_cookie_t sc_iblk; 16984f7a9b9Shx147065 17084f7a9b9Shx147065 wpi_config_t sc_config; 171*6f12def4Spengcheng chen - Sun Microsystems - Beijing China wpi_config_t sc_config_save; 172*6f12def4Spengcheng chen - Sun Microsystems - Beijing China 17384f7a9b9Shx147065 uint16_t sc_pwr1[14]; 17484f7a9b9Shx147065 uint16_t sc_pwr2[14]; 17584f7a9b9Shx147065 17684f7a9b9Shx147065 uint32_t sc_tx_timer; 177626dff79Spengcheng chen - Sun Microsystems - Beijing China uint32_t sc_scan_next; 178626dff79Spengcheng chen - Sun Microsystems - Beijing China uint32_t sc_scan_pending; 17984f7a9b9Shx147065 uint8_t *sc_fw_bin; 18084f7a9b9Shx147065 18184f7a9b9Shx147065 ddi_softintr_t sc_notif_softint_id; 18284f7a9b9Shx147065 uint32_t sc_notif_softint_pending; 18384f7a9b9Shx147065 uint32_t sc_need_reschedule; 18484f7a9b9Shx147065 18584f7a9b9Shx147065 clock_t sc_clk; 18684f7a9b9Shx147065 18784f7a9b9Shx147065 /* kstats */ 18884f7a9b9Shx147065 uint32_t sc_tx_nobuf; 18984f7a9b9Shx147065 uint32_t sc_rx_nobuf; 19084f7a9b9Shx147065 uint32_t sc_tx_err; 19184f7a9b9Shx147065 uint32_t sc_rx_err; 19284f7a9b9Shx147065 uint32_t sc_tx_retries; 19319b23afcShx147065 19484f7a9b9Shx147065 #ifdef WPI_BPF 19584f7a9b9Shx147065 struct bpf_if *sc_drvbpf; 19684f7a9b9Shx147065 19784f7a9b9Shx147065 union { 19884f7a9b9Shx147065 struct wpi_rx_radiotap_header th; 19984f7a9b9Shx147065 uint8_t pad[64]; 20084f7a9b9Shx147065 } sc_rxtapu; 20184f7a9b9Shx147065 #define sc_rxtap sc_rxtapu.th 20284f7a9b9Shx147065 int sc_rxtap_len; 20384f7a9b9Shx147065 20484f7a9b9Shx147065 union { 20584f7a9b9Shx147065 struct wpi_tx_radiotap_header th; 20684f7a9b9Shx147065 uint8_t pad[64]; 20784f7a9b9Shx147065 } sc_txtapu; 20884f7a9b9Shx147065 #define sc_txtap sc_txtapu.th 20984f7a9b9Shx147065 int sc_txtap_len; 21084f7a9b9Shx147065 #endif 21184f7a9b9Shx147065 } wpi_sc_t; 21284f7a9b9Shx147065 21384f7a9b9Shx147065 #define WPI_F_ATTACHED (1 << 0) 21484f7a9b9Shx147065 #define WPI_F_CMD_DONE (1 << 1) 21584f7a9b9Shx147065 #define WPI_F_FW_INIT (1 << 2) 21684f7a9b9Shx147065 #define WPI_F_HW_ERR_RECOVER (1 << 3) 21784f7a9b9Shx147065 #define WPI_F_RATE_AUTO_CTL (1 << 4) 21884f7a9b9Shx147065 #define WPI_F_RUNNING (1 << 5) 21919b23afcShx147065 #define WPI_F_SUSPEND (1 << 6) 22019b23afcShx147065 #define WPI_F_RADIO_OFF (1 << 7) 221626dff79Spengcheng chen - Sun Microsystems - Beijing China #define WPI_F_SCANNING (1 << 8) 222faceed93Sfei feng - Sun Microsystems - Beijing China #define WPI_F_QUIESCED (1 << 9) 223d40f4da4Spengcheng chen - Sun Microsystems - Beijing China #define WPI_F_LAZY_RESUME (1 << 10) 22484f7a9b9Shx147065 22584f7a9b9Shx147065 #define WPI_SUCCESS 0 22640db2e2bSzf162725 #define WPI_FAIL (EIO) 22784f7a9b9Shx147065 #ifdef __cplusplus 22884f7a9b9Shx147065 } 22984f7a9b9Shx147065 #endif 23084f7a9b9Shx147065 23184f7a9b9Shx147065 #endif /* _WPIVAR_H */ 232