16169Shx147065 /* 28594SFei.Feng@Sun.COM * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 36169Shx147065 * Use is subject to license terms. 46169Shx147065 */ 56169Shx147065 66169Shx147065 /* 76169Shx147065 * Copyright (c) 2007, Intel Corporation 86169Shx147065 * All rights reserved. 96169Shx147065 */ 106169Shx147065 116169Shx147065 /* 126169Shx147065 * Copyright (c) 2006 136169Shx147065 * Copyright (c) 2007 146169Shx147065 * Damien Bergamini <damien.bergamini@free.fr> 156169Shx147065 * 166169Shx147065 * Permission to use, copy, modify, and distribute this software for any 176169Shx147065 * purpose with or without fee is hereby granted, provided that the above 186169Shx147065 * copyright notice and this permission notice appear in all copies. 196169Shx147065 * 206169Shx147065 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 216169Shx147065 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 226169Shx147065 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 236169Shx147065 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 246169Shx147065 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 256169Shx147065 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 266169Shx147065 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 276169Shx147065 */ 286169Shx147065 296169Shx147065 #ifndef _IWK_VAR_H 306169Shx147065 #define _IWK_VAR_H 316169Shx147065 326169Shx147065 #ifdef __cplusplus 336169Shx147065 extern "C" { 346169Shx147065 #endif 356169Shx147065 366169Shx147065 #define IWK_DMA_SYNC(area, flag) \ 376169Shx147065 (void) ddi_dma_sync((area).dma_hdl, (area).offset, \ 386169Shx147065 (area).alength, (flag)) 396169Shx147065 40*8902SPengcheng.Chen@Sun.COM #define IWK_CHK_FAST_RECOVER(sc) \ 41*8902SPengcheng.Chen@Sun.COM (sc->sc_ic.ic_state == IEEE80211_S_RUN && \ 42*8902SPengcheng.Chen@Sun.COM sc->sc_ic.ic_opmode == IEEE80211_M_STA) 43*8902SPengcheng.Chen@Sun.COM 446169Shx147065 typedef struct iwk_dma_area { 456169Shx147065 ddi_acc_handle_t acc_hdl; /* handle for memory */ 466169Shx147065 caddr_t mem_va; /* CPU VA of memory */ 476169Shx147065 uint32_t nslots; /* number of slots */ 486169Shx147065 uint32_t size; /* size per slot */ 496169Shx147065 size_t alength; /* allocated size */ 506169Shx147065 /* >= product of above */ 516169Shx147065 ddi_dma_handle_t dma_hdl; /* DMA handle */ 526169Shx147065 offset_t offset; /* relative to handle */ 536169Shx147065 ddi_dma_cookie_t cookie; /* associated cookie */ 546169Shx147065 uint32_t ncookies; 556169Shx147065 uint32_t token; /* arbitrary identifier */ 566169Shx147065 } iwk_dma_t; 576169Shx147065 586169Shx147065 typedef struct iwk_tx_data { 596169Shx147065 iwk_dma_t dma_data; 606169Shx147065 iwk_tx_desc_t *desc; 616169Shx147065 uint32_t paddr_desc; 626169Shx147065 iwk_cmd_t *cmd; 636169Shx147065 uint32_t paddr_cmd; 646169Shx147065 } iwk_tx_data_t; 656169Shx147065 666169Shx147065 typedef struct iwk_tx_ring { 676169Shx147065 iwk_dma_t dma_desc; 686169Shx147065 iwk_dma_t dma_cmd; 696169Shx147065 iwk_tx_data_t *data; 706169Shx147065 int qid; 716169Shx147065 int count; 726169Shx147065 int window; 736169Shx147065 int queued; 746169Shx147065 int cur; 756169Shx147065 } iwk_tx_ring_t; 766169Shx147065 776169Shx147065 typedef struct iwk_rx_data { 786169Shx147065 iwk_dma_t dma_data; 796169Shx147065 } iwk_rx_data_t; 806169Shx147065 816169Shx147065 typedef struct iwk_rx_ring { 826169Shx147065 iwk_dma_t dma_desc; 836169Shx147065 uint32_t *desc; 846169Shx147065 iwk_rx_data_t data[RX_QUEUE_SIZE]; 856169Shx147065 int cur; 866169Shx147065 } iwk_rx_ring_t; 876169Shx147065 886249Shx147065 typedef struct iwk_amrr { 896249Shx147065 ieee80211_node_t in; /* must be the first */ 906249Shx147065 int txcnt; 916249Shx147065 int retrycnt; 926249Shx147065 int success; 936249Shx147065 int success_threshold; 946249Shx147065 int recovery; 956249Shx147065 } iwk_amrr_t; 966249Shx147065 978594SFei.Feng@Sun.COM typedef struct iwk_ibss_node { 988594SFei.Feng@Sun.COM iwk_add_sta_t node; 998594SFei.Feng@Sun.COM int8_t used; 1008594SFei.Feng@Sun.COM } iwk_ibss_node_t; 1018594SFei.Feng@Sun.COM 1028594SFei.Feng@Sun.COM typedef struct iwk_ibss_beacon { 1038594SFei.Feng@Sun.COM /* for update beacon frame dynamically */ 1048594SFei.Feng@Sun.COM struct ieee80211_beacon_offsets iwk_boff; 1058594SFei.Feng@Sun.COM uint32_t beacon_cmd_len; 1068594SFei.Feng@Sun.COM iwk_tx_beacon_cmd_t beacon_cmd; 1078594SFei.Feng@Sun.COM uint8_t syncbeacon; 1088594SFei.Feng@Sun.COM /* beacon frame allocated from net80211 module */ 1098594SFei.Feng@Sun.COM mblk_t *mp; 1108594SFei.Feng@Sun.COM } iwk_ibss_beacon_t; 1118594SFei.Feng@Sun.COM 1128594SFei.Feng@Sun.COM typedef struct iwk_ibss { 1138594SFei.Feng@Sun.COM iwk_ibss_node_t ibss_node_tb[IWK_STATION_COUNT]; 1148594SFei.Feng@Sun.COM uint32_t node_number; 1158594SFei.Feng@Sun.COM kmutex_t node_tb_lock; 1168594SFei.Feng@Sun.COM iwk_ibss_beacon_t ibss_beacon; 1178594SFei.Feng@Sun.COM } iwk_ibss_t; 1188594SFei.Feng@Sun.COM 1196169Shx147065 typedef struct iwk_softc { 1206169Shx147065 struct ieee80211com sc_ic; 1216169Shx147065 dev_info_t *sc_dip; 1226169Shx147065 int (*sc_newstate)(struct ieee80211com *, 1236169Shx147065 enum ieee80211_state, int); 1247569SXinghua.Wen@Sun.COM void (*sc_recv_mgmt)(ieee80211com_t *, mblk_t *, 1257569SXinghua.Wen@Sun.COM ieee80211_node_t *, int, int, uint32_t); 1266169Shx147065 enum ieee80211_state sc_ostate; 1276169Shx147065 kmutex_t sc_glock; 1286169Shx147065 kmutex_t sc_mt_lock; 1296169Shx147065 kmutex_t sc_tx_lock; 1306169Shx147065 kcondvar_t sc_mt_cv; 1316169Shx147065 kcondvar_t sc_tx_cv; 1326169Shx147065 kcondvar_t sc_cmd_cv; 1336169Shx147065 kcondvar_t sc_fw_cv; 1346169Shx147065 1356169Shx147065 kthread_t *sc_mf_thread; 1366169Shx147065 uint32_t sc_mf_thread_switch; 1376169Shx147065 1386169Shx147065 uint32_t sc_flags; 1396169Shx147065 uint32_t sc_dmabuf_sz; 1406169Shx147065 uint16_t sc_clsz; 1416169Shx147065 uint8_t sc_rev; 1426169Shx147065 uint8_t sc_resv; 1436169Shx147065 uint16_t sc_assoc_id; 1446169Shx147065 uint16_t sc_reserved0; 1456169Shx147065 1466169Shx147065 /* shared area */ 1476169Shx147065 iwk_dma_t sc_dma_sh; 1486169Shx147065 iwk_shared_t *sc_shared; 1496169Shx147065 /* keep warm area */ 1506169Shx147065 iwk_dma_t sc_dma_kw; 1516169Shx147065 /* tx scheduler base address */ 1526169Shx147065 uint32_t sc_scd_base_addr; 1536169Shx147065 1546169Shx147065 iwk_tx_ring_t sc_txq[IWK_NUM_QUEUES]; 1556169Shx147065 iwk_rx_ring_t sc_rxq; 1566169Shx147065 1576169Shx147065 /* firmware dma */ 1586169Shx147065 iwk_firmware_hdr_t *sc_hdr; 1596169Shx147065 char *sc_boot; 1606169Shx147065 iwk_dma_t sc_dma_fw_text; 1616169Shx147065 iwk_dma_t sc_dma_fw_init_text; 1626169Shx147065 iwk_dma_t sc_dma_fw_data; 1636169Shx147065 iwk_dma_t sc_dma_fw_data_bak; 1646169Shx147065 iwk_dma_t sc_dma_fw_init_data; 1656169Shx147065 1666169Shx147065 ddi_acc_handle_t sc_cfg_handle; 1676169Shx147065 caddr_t sc_cfg_base; 1686169Shx147065 ddi_acc_handle_t sc_handle; 1696169Shx147065 caddr_t sc_base; 1707569SXinghua.Wen@Sun.COM ddi_intr_handle_t *sc_intr_htable; 1717569SXinghua.Wen@Sun.COM uint_t sc_intr_pri; 1726169Shx147065 173*8902SPengcheng.Chen@Sun.COM iwk_rxon_cmd_t sc_config; 174*8902SPengcheng.Chen@Sun.COM iwk_rxon_cmd_t sc_config_save; 1756169Shx147065 struct iwk_eep sc_eep_map; /* eeprom map */ 1766169Shx147065 uint32_t sc_scd_base; 1776169Shx147065 1786169Shx147065 struct iwk_alive_resp sc_card_alive_run; 1796169Shx147065 struct iwk_init_alive_resp sc_card_alive_init; 1806169Shx147065 1817569SXinghua.Wen@Sun.COM int32_t sc_tempera; 1827569SXinghua.Wen@Sun.COM int32_t sc_last_tempera; 1837569SXinghua.Wen@Sun.COM int32_t sc_user_txpower; 1847569SXinghua.Wen@Sun.COM struct iwk_notif_statistics sc_statistics; 1857569SXinghua.Wen@Sun.COM struct iwk_rx_gain_diff sc_rxgain_diff; 1867569SXinghua.Wen@Sun.COM struct iwk_rx_sensitivity sc_rx_sens; 1877569SXinghua.Wen@Sun.COM 1886169Shx147065 uint32_t sc_tx_timer; 1897691SPengcheng.Chen@Sun.COM uint32_t sc_scan_pending; 1906169Shx147065 uint8_t *sc_fw_bin; 1916169Shx147065 1927569SXinghua.Wen@Sun.COM ddi_softint_handle_t sc_soft_hdl; 1936169Shx147065 uint32_t sc_rx_softint_pending; 1946169Shx147065 uint32_t sc_need_reschedule; 1956169Shx147065 1966249Shx147065 clock_t sc_clk; 1976249Shx147065 1986169Shx147065 /* kstats */ 1996169Shx147065 uint32_t sc_tx_nobuf; 2006169Shx147065 uint32_t sc_rx_nobuf; 2016169Shx147065 uint32_t sc_tx_err; 2026169Shx147065 uint32_t sc_rx_err; 2036169Shx147065 uint32_t sc_tx_retries; 2048594SFei.Feng@Sun.COM iwk_ibss_t sc_ibss; 2056169Shx147065 } iwk_sc_t; 2066169Shx147065 2076169Shx147065 #define IWK_F_ATTACHED (1 << 0) 2086169Shx147065 #define IWK_F_CMD_DONE (1 << 1) 2096169Shx147065 #define IWK_F_FW_INIT (1 << 2) 2106249Shx147065 #define IWK_F_HW_ERR_RECOVER (1 << 3) 2116249Shx147065 #define IWK_F_RATE_AUTO_CTL (1 << 4) 2126169Shx147065 #define IWK_F_RUNNING (1 << 5) 2136169Shx147065 #define IWK_F_SCANNING (1 << 6) 2146249Shx147065 #define IWK_F_SUSPEND (1 << 7) 2156249Shx147065 #define IWK_F_RADIO_OFF (1 << 8) 2167569SXinghua.Wen@Sun.COM #define IWK_F_STATISTICS (1 << 9) 2177891SPengcheng.Chen@Sun.COM #define IWK_F_QUIESCED (1 << 10) 2188349SPengcheng.Chen@Sun.COM #define IWK_F_LAZY_RESUME (1 << 11) 2196169Shx147065 2206169Shx147065 #define IWK_SUCCESS 0 2216249Shx147065 #define IWK_FAIL EIO 222*8902SPengcheng.Chen@Sun.COM 2236169Shx147065 #ifdef __cplusplus 2246169Shx147065 } 2256169Shx147065 #endif 2266169Shx147065 2276169Shx147065 #endif /* _IWK_VAR_H */ 228