1c533a883Shx147065 /* 219d332feSfei feng - Sun Microsystems - Beijing China * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 3c533a883Shx147065 * Use is subject to license terms. 4c533a883Shx147065 */ 5c533a883Shx147065 6c533a883Shx147065 /* 7c533a883Shx147065 * Copyright (c) 2007, Intel Corporation 8c533a883Shx147065 * All rights reserved. 9c533a883Shx147065 */ 10c533a883Shx147065 11c533a883Shx147065 /* 12c533a883Shx147065 * Copyright (c) 2006 13c533a883Shx147065 * Copyright (c) 2007 14c533a883Shx147065 * Damien Bergamini <damien.bergamini@free.fr> 15c533a883Shx147065 * 16c533a883Shx147065 * Permission to use, copy, modify, and distribute this software for any 17c533a883Shx147065 * purpose with or without fee is hereby granted, provided that the above 18c533a883Shx147065 * copyright notice and this permission notice appear in all copies. 19c533a883Shx147065 * 20c533a883Shx147065 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 21c533a883Shx147065 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 22c533a883Shx147065 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 23c533a883Shx147065 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 24c533a883Shx147065 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 25c533a883Shx147065 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 26c533a883Shx147065 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 27c533a883Shx147065 */ 28c533a883Shx147065 29c533a883Shx147065 #ifndef _IWK_VAR_H 30c533a883Shx147065 #define _IWK_VAR_H 31c533a883Shx147065 32c533a883Shx147065 #ifdef __cplusplus 33c533a883Shx147065 extern "C" { 34c533a883Shx147065 #endif 35c533a883Shx147065 36c533a883Shx147065 #define IWK_DMA_SYNC(area, flag) \ 37c533a883Shx147065 (void) ddi_dma_sync((area).dma_hdl, (area).offset, \ 38c533a883Shx147065 (area).alength, (flag)) 39c533a883Shx147065 40*6f12def4Spengcheng chen - Sun Microsystems - Beijing China #define IWK_CHK_FAST_RECOVER(sc) \ 41*6f12def4Spengcheng chen - Sun Microsystems - Beijing China (sc->sc_ic.ic_state == IEEE80211_S_RUN && \ 42*6f12def4Spengcheng chen - Sun Microsystems - Beijing China sc->sc_ic.ic_opmode == IEEE80211_M_STA) 43*6f12def4Spengcheng chen - Sun Microsystems - Beijing China 44c533a883Shx147065 typedef struct iwk_dma_area { 45c533a883Shx147065 ddi_acc_handle_t acc_hdl; /* handle for memory */ 46c533a883Shx147065 caddr_t mem_va; /* CPU VA of memory */ 47c533a883Shx147065 uint32_t nslots; /* number of slots */ 48c533a883Shx147065 uint32_t size; /* size per slot */ 49c533a883Shx147065 size_t alength; /* allocated size */ 50c533a883Shx147065 /* >= product of above */ 51c533a883Shx147065 ddi_dma_handle_t dma_hdl; /* DMA handle */ 52c533a883Shx147065 offset_t offset; /* relative to handle */ 53c533a883Shx147065 ddi_dma_cookie_t cookie; /* associated cookie */ 54c533a883Shx147065 uint32_t ncookies; 55c533a883Shx147065 uint32_t token; /* arbitrary identifier */ 56c533a883Shx147065 } iwk_dma_t; 57c533a883Shx147065 58c533a883Shx147065 typedef struct iwk_tx_data { 59c533a883Shx147065 iwk_dma_t dma_data; 60c533a883Shx147065 iwk_tx_desc_t *desc; 61c533a883Shx147065 uint32_t paddr_desc; 62c533a883Shx147065 iwk_cmd_t *cmd; 63c533a883Shx147065 uint32_t paddr_cmd; 64c533a883Shx147065 } iwk_tx_data_t; 65c533a883Shx147065 66c533a883Shx147065 typedef struct iwk_tx_ring { 67c533a883Shx147065 iwk_dma_t dma_desc; 68c533a883Shx147065 iwk_dma_t dma_cmd; 69c533a883Shx147065 iwk_tx_data_t *data; 70c533a883Shx147065 int qid; 71c533a883Shx147065 int count; 72c533a883Shx147065 int window; 73c533a883Shx147065 int queued; 74c533a883Shx147065 int cur; 75c533a883Shx147065 } iwk_tx_ring_t; 76c533a883Shx147065 77c533a883Shx147065 typedef struct iwk_rx_data { 78c533a883Shx147065 iwk_dma_t dma_data; 79c533a883Shx147065 } iwk_rx_data_t; 80c533a883Shx147065 81c533a883Shx147065 typedef struct iwk_rx_ring { 82c533a883Shx147065 iwk_dma_t dma_desc; 83c533a883Shx147065 uint32_t *desc; 84c533a883Shx147065 iwk_rx_data_t data[RX_QUEUE_SIZE]; 85c533a883Shx147065 int cur; 86c533a883Shx147065 } iwk_rx_ring_t; 87c533a883Shx147065 8843439c96Shx147065 typedef struct iwk_amrr { 8943439c96Shx147065 ieee80211_node_t in; /* must be the first */ 9043439c96Shx147065 int txcnt; 9143439c96Shx147065 int retrycnt; 9243439c96Shx147065 int success; 9343439c96Shx147065 int success_threshold; 9443439c96Shx147065 int recovery; 9543439c96Shx147065 } iwk_amrr_t; 9643439c96Shx147065 9719d332feSfei feng - Sun Microsystems - Beijing China typedef struct iwk_ibss_node { 9819d332feSfei feng - Sun Microsystems - Beijing China iwk_add_sta_t node; 9919d332feSfei feng - Sun Microsystems - Beijing China int8_t used; 10019d332feSfei feng - Sun Microsystems - Beijing China } iwk_ibss_node_t; 10119d332feSfei feng - Sun Microsystems - Beijing China 10219d332feSfei feng - Sun Microsystems - Beijing China typedef struct iwk_ibss_beacon { 10319d332feSfei feng - Sun Microsystems - Beijing China /* for update beacon frame dynamically */ 10419d332feSfei feng - Sun Microsystems - Beijing China struct ieee80211_beacon_offsets iwk_boff; 10519d332feSfei feng - Sun Microsystems - Beijing China uint32_t beacon_cmd_len; 10619d332feSfei feng - Sun Microsystems - Beijing China iwk_tx_beacon_cmd_t beacon_cmd; 10719d332feSfei feng - Sun Microsystems - Beijing China uint8_t syncbeacon; 10819d332feSfei feng - Sun Microsystems - Beijing China /* beacon frame allocated from net80211 module */ 10919d332feSfei feng - Sun Microsystems - Beijing China mblk_t *mp; 11019d332feSfei feng - Sun Microsystems - Beijing China } iwk_ibss_beacon_t; 11119d332feSfei feng - Sun Microsystems - Beijing China 11219d332feSfei feng - Sun Microsystems - Beijing China typedef struct iwk_ibss { 11319d332feSfei feng - Sun Microsystems - Beijing China iwk_ibss_node_t ibss_node_tb[IWK_STATION_COUNT]; 11419d332feSfei feng - Sun Microsystems - Beijing China uint32_t node_number; 11519d332feSfei feng - Sun Microsystems - Beijing China kmutex_t node_tb_lock; 11619d332feSfei feng - Sun Microsystems - Beijing China iwk_ibss_beacon_t ibss_beacon; 11719d332feSfei feng - Sun Microsystems - Beijing China } iwk_ibss_t; 11819d332feSfei feng - Sun Microsystems - Beijing China 119c533a883Shx147065 typedef struct iwk_softc { 120c533a883Shx147065 struct ieee80211com sc_ic; 121c533a883Shx147065 dev_info_t *sc_dip; 122c533a883Shx147065 int (*sc_newstate)(struct ieee80211com *, 123c533a883Shx147065 enum ieee80211_state, int); 124cdc64593Sxinghua wen - Sun Microsystems - Beijing China void (*sc_recv_mgmt)(ieee80211com_t *, mblk_t *, 125cdc64593Sxinghua wen - Sun Microsystems - Beijing China ieee80211_node_t *, int, int, uint32_t); 126c533a883Shx147065 enum ieee80211_state sc_ostate; 127c533a883Shx147065 kmutex_t sc_glock; 128c533a883Shx147065 kmutex_t sc_mt_lock; 129c533a883Shx147065 kmutex_t sc_tx_lock; 130c533a883Shx147065 kcondvar_t sc_mt_cv; 131c533a883Shx147065 kcondvar_t sc_tx_cv; 132c533a883Shx147065 kcondvar_t sc_cmd_cv; 133c533a883Shx147065 kcondvar_t sc_fw_cv; 134c533a883Shx147065 135c533a883Shx147065 kthread_t *sc_mf_thread; 136c533a883Shx147065 uint32_t sc_mf_thread_switch; 137c533a883Shx147065 138c533a883Shx147065 uint32_t sc_flags; 139c533a883Shx147065 uint32_t sc_dmabuf_sz; 140c533a883Shx147065 uint16_t sc_clsz; 141c533a883Shx147065 uint8_t sc_rev; 142c533a883Shx147065 uint8_t sc_resv; 143c533a883Shx147065 uint16_t sc_assoc_id; 144c533a883Shx147065 uint16_t sc_reserved0; 145c533a883Shx147065 146c533a883Shx147065 /* shared area */ 147c533a883Shx147065 iwk_dma_t sc_dma_sh; 148c533a883Shx147065 iwk_shared_t *sc_shared; 149c533a883Shx147065 /* keep warm area */ 150c533a883Shx147065 iwk_dma_t sc_dma_kw; 151c533a883Shx147065 /* tx scheduler base address */ 152c533a883Shx147065 uint32_t sc_scd_base_addr; 153c533a883Shx147065 154c533a883Shx147065 iwk_tx_ring_t sc_txq[IWK_NUM_QUEUES]; 155c533a883Shx147065 iwk_rx_ring_t sc_rxq; 156c533a883Shx147065 157c533a883Shx147065 /* firmware dma */ 158c533a883Shx147065 iwk_firmware_hdr_t *sc_hdr; 159c533a883Shx147065 char *sc_boot; 160c533a883Shx147065 iwk_dma_t sc_dma_fw_text; 161c533a883Shx147065 iwk_dma_t sc_dma_fw_init_text; 162c533a883Shx147065 iwk_dma_t sc_dma_fw_data; 163c533a883Shx147065 iwk_dma_t sc_dma_fw_data_bak; 164c533a883Shx147065 iwk_dma_t sc_dma_fw_init_data; 165c533a883Shx147065 166c533a883Shx147065 ddi_acc_handle_t sc_cfg_handle; 167c533a883Shx147065 caddr_t sc_cfg_base; 168c533a883Shx147065 ddi_acc_handle_t sc_handle; 169c533a883Shx147065 caddr_t sc_base; 170cdc64593Sxinghua wen - Sun Microsystems - Beijing China ddi_intr_handle_t *sc_intr_htable; 171cdc64593Sxinghua wen - Sun Microsystems - Beijing China uint_t sc_intr_pri; 172c533a883Shx147065 173c533a883Shx147065 iwk_rxon_cmd_t sc_config; 174*6f12def4Spengcheng chen - Sun Microsystems - Beijing China iwk_rxon_cmd_t sc_config_save; 175c533a883Shx147065 struct iwk_eep sc_eep_map; /* eeprom map */ 176c533a883Shx147065 uint32_t sc_scd_base; 177c533a883Shx147065 178c533a883Shx147065 struct iwk_alive_resp sc_card_alive_run; 179c533a883Shx147065 struct iwk_init_alive_resp sc_card_alive_init; 180c533a883Shx147065 181cdc64593Sxinghua wen - Sun Microsystems - Beijing China int32_t sc_tempera; 182cdc64593Sxinghua wen - Sun Microsystems - Beijing China int32_t sc_last_tempera; 183cdc64593Sxinghua wen - Sun Microsystems - Beijing China int32_t sc_user_txpower; 184cdc64593Sxinghua wen - Sun Microsystems - Beijing China struct iwk_notif_statistics sc_statistics; 185cdc64593Sxinghua wen - Sun Microsystems - Beijing China struct iwk_rx_gain_diff sc_rxgain_diff; 186cdc64593Sxinghua wen - Sun Microsystems - Beijing China struct iwk_rx_sensitivity sc_rx_sens; 187cdc64593Sxinghua wen - Sun Microsystems - Beijing China 188c533a883Shx147065 uint32_t sc_tx_timer; 189c50ced99Spengcheng chen - Sun Microsystems - Beijing China uint32_t sc_scan_pending; 190c533a883Shx147065 uint8_t *sc_fw_bin; 191c533a883Shx147065 192cdc64593Sxinghua wen - Sun Microsystems - Beijing China ddi_softint_handle_t sc_soft_hdl; 193c533a883Shx147065 uint32_t sc_rx_softint_pending; 194c533a883Shx147065 uint32_t sc_need_reschedule; 195c533a883Shx147065 19643439c96Shx147065 clock_t sc_clk; 19743439c96Shx147065 198c533a883Shx147065 /* kstats */ 199c533a883Shx147065 uint32_t sc_tx_nobuf; 200c533a883Shx147065 uint32_t sc_rx_nobuf; 201c533a883Shx147065 uint32_t sc_tx_err; 202c533a883Shx147065 uint32_t sc_rx_err; 203c533a883Shx147065 uint32_t sc_tx_retries; 20419d332feSfei feng - Sun Microsystems - Beijing China iwk_ibss_t sc_ibss; 205c533a883Shx147065 } iwk_sc_t; 206c533a883Shx147065 207c533a883Shx147065 #define IWK_F_ATTACHED (1 << 0) 208c533a883Shx147065 #define IWK_F_CMD_DONE (1 << 1) 209c533a883Shx147065 #define IWK_F_FW_INIT (1 << 2) 210c533a883Shx147065 #define IWK_F_HW_ERR_RECOVER (1 << 3) 211c533a883Shx147065 #define IWK_F_RATE_AUTO_CTL (1 << 4) 212c533a883Shx147065 #define IWK_F_RUNNING (1 << 5) 213c533a883Shx147065 #define IWK_F_SCANNING (1 << 6) 21443439c96Shx147065 #define IWK_F_SUSPEND (1 << 7) 21543439c96Shx147065 #define IWK_F_RADIO_OFF (1 << 8) 216cdc64593Sxinghua wen - Sun Microsystems - Beijing China #define IWK_F_STATISTICS (1 << 9) 217d2a61391Spengcheng chen - Sun Microsystems - Beijing China #define IWK_F_QUIESCED (1 << 10) 218d40f4da4Spengcheng chen - Sun Microsystems - Beijing China #define IWK_F_LAZY_RESUME (1 << 11) 219c533a883Shx147065 220c533a883Shx147065 #define IWK_SUCCESS 0 22143439c96Shx147065 #define IWK_FAIL EIO 222*6f12def4Spengcheng chen - Sun Microsystems - Beijing China 223c533a883Shx147065 #ifdef __cplusplus 224c533a883Shx147065 } 225c533a883Shx147065 #endif 226c533a883Shx147065 227c533a883Shx147065 #endif /* _IWK_VAR_H */ 228