1a72f7ea6Sql147931 /* 2*9aa73b68SQin Michael Li * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 3a72f7ea6Sql147931 * Use is subject to license terms. 4a72f7ea6Sql147931 */ 5a72f7ea6Sql147931 /* 6a72f7ea6Sql147931 * Copyright (c) 2004, 2005 David Young. All rights reserved. 7a72f7ea6Sql147931 * 8a72f7ea6Sql147931 * Driver for the Realtek RTL8180 802.11 MAC/BBP by David Young. 9a72f7ea6Sql147931 * 10a72f7ea6Sql147931 * Redistribution and use in source and binary forms, with or without 11a72f7ea6Sql147931 * modification, are permitted provided that the following conditions 12a72f7ea6Sql147931 * are met: 13a72f7ea6Sql147931 * 1. Redistributions of source code must retain the above copyright 14a72f7ea6Sql147931 * notice, this list of conditions and the following disclaimer. 15a72f7ea6Sql147931 * 2. Redistributions in binary form must reproduce the above copyright 16a72f7ea6Sql147931 * notice, this list of conditions and the following disclaimer in the 17a72f7ea6Sql147931 * documentation and/or other materials provided with the distribution. 18a72f7ea6Sql147931 * 3. The name of David Young may not be used to endorse or promote 19a72f7ea6Sql147931 * products derived from this software without specific prior 20a72f7ea6Sql147931 * written permission. 21a72f7ea6Sql147931 * 22a72f7ea6Sql147931 * THIS SOFTWARE IS PROVIDED BY David Young ``AS IS'' AND ANY 23a72f7ea6Sql147931 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 24a72f7ea6Sql147931 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 25a72f7ea6Sql147931 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL David 26a72f7ea6Sql147931 * Young BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 27a72f7ea6Sql147931 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 28a72f7ea6Sql147931 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29a72f7ea6Sql147931 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 30a72f7ea6Sql147931 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 31a72f7ea6Sql147931 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32a72f7ea6Sql147931 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 33a72f7ea6Sql147931 * OF SUCH DAMAGE. 34a72f7ea6Sql147931 */ 35a72f7ea6Sql147931 #ifndef _RTWVAR_H_ 36a72f7ea6Sql147931 #define _RTWVAR_H_ 37a72f7ea6Sql147931 38*9aa73b68SQin Michael Li #ifdef __cplusplus 39*9aa73b68SQin Michael Li extern "C" { 40*9aa73b68SQin Michael Li #endif 41*9aa73b68SQin Michael Li 42a72f7ea6Sql147931 #include <sys/list.h> 43a72f7ea6Sql147931 #include <sys/net80211.h> 44a72f7ea6Sql147931 45a72f7ea6Sql147931 #ifndef __func__ 46a72f7ea6Sql147931 #define __func__ "" 47a72f7ea6Sql147931 #endif 48a72f7ea6Sql147931 49a72f7ea6Sql147931 extern void rtw_dbg(uint32_t dbg_flags, const int8_t *fmt, ...); 50a72f7ea6Sql147931 51a72f7ea6Sql147931 #define RTW_DEBUG_TUNE 0x000001 52a72f7ea6Sql147931 #define RTW_DEBUG_PKTFILT 0x000002 53a72f7ea6Sql147931 #define RTW_DEBUG_XMIT 0x000004 54a72f7ea6Sql147931 #define RTW_DEBUG_DMA 0x000008 55a72f7ea6Sql147931 #define RTW_DEBUG_NODE 0x000010 56a72f7ea6Sql147931 #define RTW_DEBUG_PWR 0x000020 57a72f7ea6Sql147931 #define RTW_DEBUG_ATTACH 0x000040 58a72f7ea6Sql147931 #define RTW_DEBUG_REGDUMP 0x000080 59a72f7ea6Sql147931 #define RTW_DEBUG_ACCESS 0x000100 60a72f7ea6Sql147931 #define RTW_DEBUG_RESET 0x000200 61a72f7ea6Sql147931 #define RTW_DEBUG_INIT 0x000400 62a72f7ea6Sql147931 #define RTW_DEBUG_PKTDUMP 0x000800 63a72f7ea6Sql147931 #define RTW_DEBUG_RECV 0x001000 64a72f7ea6Sql147931 #define RTW_DEBUG_RECV_DESC 0x002000 65a72f7ea6Sql147931 #define RTW_DEBUG_IOSTATE 0x004000 66a72f7ea6Sql147931 #define RTW_DEBUG_INTR 0x008000 67a72f7ea6Sql147931 #define RTW_DEBUG_PHY 0x010000 68a72f7ea6Sql147931 #define RTW_DEBUG_PHYIO 0x020000 69a72f7ea6Sql147931 #define RTW_DEBUG_PHYBITIO 0x040000 70a72f7ea6Sql147931 #define RTW_DEBUG_TIMEOUT 0x080000 71a72f7ea6Sql147931 #define RTW_DEBUG_BUGS 0x100000 72a72f7ea6Sql147931 #define RTW_DEBUG_BEACON 0x200000 73a72f7ea6Sql147931 #define RTW_DEBUG_WIFICFG 0x400000 74a72f7ea6Sql147931 #define RTW_DEBUG_80211 0x800000 75a72f7ea6Sql147931 #define RTW_DEBUG_MAX 0xffffff 76a72f7ea6Sql147931 77a72f7ea6Sql147931 #ifdef DEBUG 78a72f7ea6Sql147931 #define RTW_DPRINTF \ 79a72f7ea6Sql147931 rtw_dbg 80a72f7ea6Sql147931 #else /* DEBUG */ 81a72f7ea6Sql147931 #define RTW_DPRINTF 82a72f7ea6Sql147931 #endif /* DEBUG */ 83a72f7ea6Sql147931 84a72f7ea6Sql147931 enum rtw_locale { 85a72f7ea6Sql147931 RTW_LOCALE_USA = 0, 86a72f7ea6Sql147931 RTW_LOCALE_EUROPE, 87a72f7ea6Sql147931 RTW_LOCALE_JAPAN, 88a72f7ea6Sql147931 RTW_LOCALE_UNKNOWN 89a72f7ea6Sql147931 }; 90a72f7ea6Sql147931 91a72f7ea6Sql147931 enum rtw_rfchipid { 92a72f7ea6Sql147931 RTW_RFCHIPID_RESERVED = 0, 93a72f7ea6Sql147931 RTW_RFCHIPID_INTERSIL = 1, 94a72f7ea6Sql147931 RTW_RFCHIPID_RFMD = 2, 95a72f7ea6Sql147931 RTW_RFCHIPID_PHILIPS = 3, 96a72f7ea6Sql147931 RTW_RFCHIPID_MAXIM = 4, 97a72f7ea6Sql147931 RTW_RFCHIPID_GCT = 5 98a72f7ea6Sql147931 }; 99a72f7ea6Sql147931 100a72f7ea6Sql147931 /* 101a72f7ea6Sql147931 * sc_flags 102a72f7ea6Sql147931 */ 103a72f7ea6Sql147931 #define RTW_F_ENABLED 0x00000001 /* chip is enabled */ 104a72f7ea6Sql147931 #define RTW_F_DIGPHY 0x00000002 /* digital PHY */ 105a72f7ea6Sql147931 #define RTW_F_DFLANTB 0x00000004 /* B antenna is default */ 106a72f7ea6Sql147931 #define RTW_F_ANTDIV 0x00000010 /* h/w antenna diversity */ 107a72f7ea6Sql147931 #define RTW_F_9356SROM 0x00000020 /* 93c56 SROM */ 108a72f7ea6Sql147931 #define RTW_F_SLEEP 0x00000040 /* chip is asleep */ 109a72f7ea6Sql147931 #define RTW_F_INVALID 0x00000080 /* chip is absent */ 110*9aa73b68SQin Michael Li #define RTW_F_SUSPEND 0x00000100 /* driver is suspended */ 111*9aa73b68SQin Michael Li #define RTW_F_PLUMBED 0x00000200 /* driver is plumbed */ 112a72f7ea6Sql147931 #define RTW_F_ATTACHED 0x01000000 /* driver is attached */ 113a72f7ea6Sql147931 /* 114a72f7ea6Sql147931 * all PHY flags 115a72f7ea6Sql147931 */ 116a72f7ea6Sql147931 #define RTW_F_ALLPHY (RTW_F_DIGPHY|RTW_F_DFLANTB|RTW_F_ANTDIV) 117a72f7ea6Sql147931 118a72f7ea6Sql147931 enum rtw_access {RTW_ACCESS_NONE = 0, 119a72f7ea6Sql147931 RTW_ACCESS_CONFIG = 1, 120a72f7ea6Sql147931 RTW_ACCESS_ANAPARM = 2}; 121a72f7ea6Sql147931 122a72f7ea6Sql147931 struct rtw_regs { 123a72f7ea6Sql147931 ddi_acc_handle_t r_handle; 124a72f7ea6Sql147931 caddr_t r_base; 125a72f7ea6Sql147931 enum rtw_access r_access; 126a72f7ea6Sql147931 }; 127a72f7ea6Sql147931 128a72f7ea6Sql147931 #define RTW_SR_GET(sr, ofs) \ 129a72f7ea6Sql147931 (((sr)->sr_content[(ofs)/2] >> (((ofs) % 2 == 0) ? 0 : 8)) & 0xff) 130a72f7ea6Sql147931 131a72f7ea6Sql147931 #define RTW_SR_GET16(sr, ofs) \ 132a72f7ea6Sql147931 (RTW_SR_GET((sr), (ofs)) | (RTW_SR_GET((sr), (ofs) + 1) << 8)) 133a72f7ea6Sql147931 134a72f7ea6Sql147931 struct rtw_srom { 135a72f7ea6Sql147931 uint16_t *sr_content; 136a72f7ea6Sql147931 uint16_t sr_size; 137a72f7ea6Sql147931 }; 138a72f7ea6Sql147931 139a72f7ea6Sql147931 140a72f7ea6Sql147931 #define RTW_NTXPRI 4 /* number of Tx priorities */ 141a72f7ea6Sql147931 #define RTW_TXPRILO 0 142a72f7ea6Sql147931 #define RTW_TXPRIMD 1 143a72f7ea6Sql147931 #define RTW_TXPRIHI 2 144a72f7ea6Sql147931 #define RTW_TXPRIBCN 3 /* beacon priority */ 145a72f7ea6Sql147931 146a72f7ea6Sql147931 #define RTW_MAXPKTSEGS 64 /* Max 64 segments per Tx packet */ 147a72f7ea6Sql147931 148a72f7ea6Sql147931 /* 149a72f7ea6Sql147931 * Note well: the descriptor rings must begin on RTW_DESC_ALIGNMENT 150a72f7ea6Sql147931 * boundaries. I allocate them consecutively from one buffer, so 151a72f7ea6Sql147931 * just round up. 152a72f7ea6Sql147931 */ 153a72f7ea6Sql147931 #define RTW_TXQLENLO 64 /* low-priority queue length */ 154a72f7ea6Sql147931 #define RTW_TXQLENMD 64 /* medium-priority */ 155a72f7ea6Sql147931 #define RTW_TXQLENHI 64 /* high-priority */ 156a72f7ea6Sql147931 #define RTW_TXQLENBCN 2 /* beacon */ 157a72f7ea6Sql147931 158a72f7ea6Sql147931 #define RTW_NTXDESCLO RTW_TXQLENLO 159a72f7ea6Sql147931 #define RTW_NTXDESCMD RTW_TXQLENMD 160a72f7ea6Sql147931 #define RTW_NTXDESCHI RTW_TXQLENHI 161a72f7ea6Sql147931 #define RTW_NTXDESCBCN RTW_TXQLENBCN 162a72f7ea6Sql147931 163a72f7ea6Sql147931 #define RTW_NTXDESCTOTAL (RTW_NTXDESCLO + RTW_NTXDESCMD + \ 164a72f7ea6Sql147931 RTW_NTXDESCHI + RTW_NTXDESCBCN) 165a72f7ea6Sql147931 166a72f7ea6Sql147931 #define RTW_RXQLEN 64 167a72f7ea6Sql147931 #define RTW_DMA_SYNC(area, flag) ((void) ddi_dma_sync((area).dma_hdl,\ 168a72f7ea6Sql147931 (area).offset, (area).alength, (flag))) 169a72f7ea6Sql147931 170a72f7ea6Sql147931 #define RTW_DMA_SYNC_DESC(area, offset, len, flag) \ 171a72f7ea6Sql147931 ((void) ddi_dma_sync((area).dma_hdl, offset, len, (flag))) 172a72f7ea6Sql147931 173a72f7ea6Sql147931 #define RTW_MINC(x, y) (x) = ((x + 1) % y) 174a72f7ea6Sql147931 #define list_empty(a) ((a)->list_head.list_next == &(a)->list_head) 175a72f7ea6Sql147931 176a72f7ea6Sql147931 typedef struct dma_area { 177a72f7ea6Sql147931 ddi_acc_handle_t acc_hdl; /* handle for memory */ 178a72f7ea6Sql147931 caddr_t mem_va; /* CPU VA of memory */ 179a72f7ea6Sql147931 uint32_t nslots; /* number of slots */ 180a72f7ea6Sql147931 uint32_t size; /* size per slot */ 181a72f7ea6Sql147931 size_t alength; /* allocated size */ 182a72f7ea6Sql147931 /* >= product of above */ 183a72f7ea6Sql147931 184a72f7ea6Sql147931 ddi_dma_handle_t dma_hdl; /* DMA handle */ 185a72f7ea6Sql147931 offset_t offset; /* relative to handle */ 186a72f7ea6Sql147931 ddi_dma_cookie_t cookie; /* associated cookie */ 187a72f7ea6Sql147931 uint32_t ncookies; /* must be 1 */ 188a72f7ea6Sql147931 uint32_t token; /* arbitrary identifier */ 189a72f7ea6Sql147931 } dma_area_t; /* 0x50 (80) bytes */ 190a72f7ea6Sql147931 191a72f7ea6Sql147931 struct rtw_txbuf { 192a72f7ea6Sql147931 struct rtw_txdesc *txdesc; /* virtual addr of desc */ 193a72f7ea6Sql147931 uint32_t bf_daddr; /* physical addr of desc */ 194a72f7ea6Sql147931 uint32_t next_bf_daddr; /* physical addr of next desc */ 195a72f7ea6Sql147931 dma_area_t bf_dma; /* dma area for buf */ 196a72f7ea6Sql147931 struct ieee80211_node *bf_in; /* pointer to the node */ 197a72f7ea6Sql147931 list_node_t bf_node; 198a72f7ea6Sql147931 uint32_t order; 199a72f7ea6Sql147931 }; 200a72f7ea6Sql147931 201a72f7ea6Sql147931 struct rtw_rxbuf { 202a72f7ea6Sql147931 struct rtw_rxdesc *rxdesc; /* virtual addr of desc */ 203a72f7ea6Sql147931 uint32_t bf_daddr; /* physical addr of desc */ 204a72f7ea6Sql147931 dma_area_t bf_dma; /* dma area for buf */ 205a72f7ea6Sql147931 }; 206a72f7ea6Sql147931 207a72f7ea6Sql147931 struct rtw_txq { 208a72f7ea6Sql147931 struct rtw_txdesc *txdesc_h; 209a72f7ea6Sql147931 struct rtw_txbuf *txbuf_h; 210a72f7ea6Sql147931 uint32_t tx_prod; 211a72f7ea6Sql147931 uint32_t tx_cons; 212a72f7ea6Sql147931 uint32_t tx_nfree; 213a72f7ea6Sql147931 kmutex_t txbuf_lock; 214a72f7ea6Sql147931 list_t tx_free_list; 215a72f7ea6Sql147931 list_t tx_dirty_list; 216a72f7ea6Sql147931 }; 217a72f7ea6Sql147931 218a72f7ea6Sql147931 struct rtw_descs { 219a72f7ea6Sql147931 struct rtw_txdesc hd_txlo[RTW_NTXDESCLO]; 220a72f7ea6Sql147931 struct rtw_txdesc hd_txmd[RTW_NTXDESCMD]; 221a72f7ea6Sql147931 struct rtw_txdesc hd_txhi[RTW_NTXDESCHI]; 222a72f7ea6Sql147931 struct rtw_rxdesc hd_rx[RTW_RXQLEN]; 223a72f7ea6Sql147931 struct rtw_txdesc hd_bcn[RTW_NTXDESCBCN]; 224a72f7ea6Sql147931 }; 225a72f7ea6Sql147931 #define RTW_DESC_OFFSET(ring, i) offsetof(struct rtw_descs, ring[i]) 226a72f7ea6Sql147931 #define RTW_RING_OFFSET(ring) RTW_DESC_OFFSET(ring, 0) 227a72f7ea6Sql147931 #define RTW_RING_BASE(baseaddr0, ring) \ 228a72f7ea6Sql147931 (baseaddr0 + RTW_RING_OFFSET(ring)) 229a72f7ea6Sql147931 230a72f7ea6Sql147931 /* 231a72f7ea6Sql147931 * One Time Unit (TU) is 1Kus = 1024 microseconds. 232a72f7ea6Sql147931 */ 233a72f7ea6Sql147931 #define IEEE80211_DUR_TU 1024 234a72f7ea6Sql147931 235a72f7ea6Sql147931 /* 236a72f7ea6Sql147931 * IEEE 802.11b durations for DSSS PHY in microseconds 237a72f7ea6Sql147931 */ 238a72f7ea6Sql147931 #define IEEE80211_DUR_DS_LONG_PREAMBLE 144 239a72f7ea6Sql147931 #define IEEE80211_DUR_DS_SHORT_PREAMBLE 72 240a72f7ea6Sql147931 241a72f7ea6Sql147931 #define IEEE80211_DUR_DS_SLOW_PLCPHDR 48 242a72f7ea6Sql147931 #define IEEE80211_DUR_DS_FAST_PLCPHDR 24 243a72f7ea6Sql147931 #define IEEE80211_DUR_DS_SLOW_ACK 112 244a72f7ea6Sql147931 #define IEEE80211_DUR_DS_FAST_ACK 56 245a72f7ea6Sql147931 #define IEEE80211_DUR_DS_SLOW_CTS 112 246a72f7ea6Sql147931 #define IEEE80211_DUR_DS_FAST_CTS 56 247a72f7ea6Sql147931 248a72f7ea6Sql147931 #define IEEE80211_DUR_DS_SLOT 20 249a72f7ea6Sql147931 #define IEEE80211_DUR_DS_SIFS 10 250a72f7ea6Sql147931 #define IEEE80211_DUR_DS_PIFS (IEEE80211_DUR_DS_SIFS + IEEE80211_DUR_DS_SLOT) 251a72f7ea6Sql147931 #define IEEE80211_DUR_DS_DIFS (IEEE80211_DUR_DS_SIFS + \ 252a72f7ea6Sql147931 2 * IEEE80211_DUR_DS_SLOT) 253a72f7ea6Sql147931 #define IEEE80211_DUR_DS_EIFS (IEEE80211_DUR_DS_SIFS + \ 254a72f7ea6Sql147931 IEEE80211_DUR_DS_SLOW_ACK + \ 255a72f7ea6Sql147931 IEEE80211_DUR_DS_LONG_PREAMBLE + \ 256a72f7ea6Sql147931 IEEE80211_DUR_DS_SLOW_PLCPHDR + \ 257a72f7ea6Sql147931 IEEE80211_DUR_DIFS) 258a72f7ea6Sql147931 259a72f7ea6Sql147931 /* 260a72f7ea6Sql147931 * 802.11 frame duration definitions. 261a72f7ea6Sql147931 */ 262a72f7ea6Sql147931 struct rtw_ieee80211_duration { 263a72f7ea6Sql147931 uint16_t d_rts_dur; 264a72f7ea6Sql147931 uint16_t d_data_dur; 265a72f7ea6Sql147931 uint16_t d_plcp_len; 266a72f7ea6Sql147931 uint8_t d_residue; /* unused octets in time slot */ 267a72f7ea6Sql147931 uint8_t resv; 268a72f7ea6Sql147931 }; 269a72f7ea6Sql147931 270a72f7ea6Sql147931 271a72f7ea6Sql147931 #ifdef RTW_RADIOTAP 272a72f7ea6Sql147931 /* 273a72f7ea6Sql147931 * Radio capture format for RTL8180. 274a72f7ea6Sql147931 */ 275a72f7ea6Sql147931 276a72f7ea6Sql147931 #define RTW_RX_RADIOTAP_PRESENT \ 277a72f7ea6Sql147931 ((1 << IEEE80211_RADIOTAP_TSFT) | \ 278a72f7ea6Sql147931 (1 << IEEE80211_RADIOTAP_FLAGS) | \ 279a72f7ea6Sql147931 (1 << IEEE80211_RADIOTAP_RATE) | \ 280a72f7ea6Sql147931 (1 << IEEE80211_RADIOTAP_CHANNEL) | \ 281a72f7ea6Sql147931 (1 << IEEE80211_RADIOTAP_LOCK_QUALITY) | \ 282a72f7ea6Sql147931 (1 << IEEE80211_RADIOTAP_DB_ANTSIGNAL) | \ 283a72f7ea6Sql147931 0) 284a72f7ea6Sql147931 285a72f7ea6Sql147931 struct rtw_rx_radiotap_header { 286a72f7ea6Sql147931 struct ieee80211_radiotap_header rr_ihdr; 287a72f7ea6Sql147931 uint64_t rr_tsft; 288a72f7ea6Sql147931 uint8_t rr_flags; 289a72f7ea6Sql147931 uint8_t rr_rate; 290a72f7ea6Sql147931 uint16_t rr_chan_freq; 291a72f7ea6Sql147931 uint16_t rr_chan_flags; 292a72f7ea6Sql147931 uint16_t rr_barker_lock; 293a72f7ea6Sql147931 uint8_t rr_antsignal; 294a72f7ea6Sql147931 } __attribute__((__packed__)); 295a72f7ea6Sql147931 296a72f7ea6Sql147931 #define RTW_TX_RADIOTAP_PRESENT \ 297a72f7ea6Sql147931 ((1 << IEEE80211_RADIOTAP_FLAGS) | \ 298a72f7ea6Sql147931 (1 << IEEE80211_RADIOTAP_RATE) | \ 299a72f7ea6Sql147931 (1 << IEEE80211_RADIOTAP_CHANNEL) | \ 300a72f7ea6Sql147931 0) 301a72f7ea6Sql147931 302a72f7ea6Sql147931 struct rtw_tx_radiotap_header { 303a72f7ea6Sql147931 struct ieee80211_radiotap_header rt_ihdr; 304a72f7ea6Sql147931 uint8_t rt_flags; 305a72f7ea6Sql147931 uint8_t rt_rate; 306a72f7ea6Sql147931 uint16_t rt_chan_freq; 307a72f7ea6Sql147931 uint16_t rt_chan_flags; 308a72f7ea6Sql147931 } __attribute__((__packed__)); 309a72f7ea6Sql147931 #endif 310a72f7ea6Sql147931 311a72f7ea6Sql147931 enum rtw_attach_state {FINISHED, FINISH_DESCMAP_LOAD, FINISH_DESCMAP_CREATE, 312a72f7ea6Sql147931 FINISH_DESC_MAP, FINISH_DESC_ALLOC, FINISH_RXMAPS_CREATE, 313a72f7ea6Sql147931 FINISH_TXMAPS_CREATE, FINISH_RESET, FINISH_READ_SROM, FINISH_PARSE_SROM, 314a72f7ea6Sql147931 FINISH_RF_ATTACH, FINISH_ID_STA, FINISH_TXDESCBLK_SETUP, 315a72f7ea6Sql147931 FINISH_TXCTLBLK_SETUP, DETACHED}; 316a72f7ea6Sql147931 317a72f7ea6Sql147931 struct rtw_hooks { 318a72f7ea6Sql147931 void *rh_shutdown; /* shutdown hook */ 319a72f7ea6Sql147931 void *rh_power; /* power management hook */ 320a72f7ea6Sql147931 }; 321a72f7ea6Sql147931 322a72f7ea6Sql147931 enum rtw_pwrstate { RTW_OFF = 0, RTW_SLEEP, RTW_ON }; 323a72f7ea6Sql147931 324a72f7ea6Sql147931 typedef void (*rtw_continuous_tx_cb_t)(void *arg, int); 325a72f7ea6Sql147931 326a72f7ea6Sql147931 struct rtw_phy { 327a72f7ea6Sql147931 struct rtw_rf *p_rf; 328a72f7ea6Sql147931 struct rtw_regs *p_regs; 329a72f7ea6Sql147931 }; 330a72f7ea6Sql147931 331a72f7ea6Sql147931 struct rtw_bbpset { 332a72f7ea6Sql147931 uint_t bb_antatten; 333a72f7ea6Sql147931 uint_t bb_chestlim; 334a72f7ea6Sql147931 uint_t bb_chsqlim; 335a72f7ea6Sql147931 uint_t bb_ifagcdet; 336a72f7ea6Sql147931 uint_t bb_ifagcini; 337a72f7ea6Sql147931 uint_t bb_ifagclimit; 338a72f7ea6Sql147931 uint_t bb_lnadet; 339a72f7ea6Sql147931 uint_t bb_sys1; 340a72f7ea6Sql147931 uint_t bb_sys2; 341a72f7ea6Sql147931 uint_t bb_sys3; 342a72f7ea6Sql147931 uint_t bb_trl; 343a72f7ea6Sql147931 uint_t bb_txagc; 344a72f7ea6Sql147931 }; 345a72f7ea6Sql147931 346a72f7ea6Sql147931 struct rtw_rf { 347a72f7ea6Sql147931 void (*rf_destroy)(struct rtw_rf *); 348a72f7ea6Sql147931 /* 349a72f7ea6Sql147931 * args: frequency, txpower, power state 350a72f7ea6Sql147931 */ 351a72f7ea6Sql147931 int (*rf_init)(struct rtw_rf *, uint_t, uint8_t, enum rtw_pwrstate); 352a72f7ea6Sql147931 /* 353a72f7ea6Sql147931 * arg: power state 354a72f7ea6Sql147931 */ 355a72f7ea6Sql147931 int (*rf_pwrstate)(struct rtw_rf *, enum rtw_pwrstate); 356a72f7ea6Sql147931 /* 357a72f7ea6Sql147931 * arg: frequency 358a72f7ea6Sql147931 */ 359a72f7ea6Sql147931 int (*rf_tune)(struct rtw_rf *, uint_t); 360a72f7ea6Sql147931 /* 361a72f7ea6Sql147931 * arg: txpower 362a72f7ea6Sql147931 */ 363a72f7ea6Sql147931 int (*rf_txpower)(struct rtw_rf *, uint8_t); 364a72f7ea6Sql147931 rtw_continuous_tx_cb_t rf_continuous_tx_cb; 365a72f7ea6Sql147931 void *rf_continuous_tx_arg; 366a72f7ea6Sql147931 struct rtw_bbpset rf_bbpset; 367a72f7ea6Sql147931 }; 368a72f7ea6Sql147931 369a72f7ea6Sql147931 typedef int (*rtw_rf_write_t)(struct rtw_regs *, enum rtw_rfchipid, uint_t, 370a72f7ea6Sql147931 uint32_t); 371a72f7ea6Sql147931 372a72f7ea6Sql147931 struct rtw_rfbus { 373a72f7ea6Sql147931 struct rtw_regs *b_regs; 374a72f7ea6Sql147931 rtw_rf_write_t b_write; 375a72f7ea6Sql147931 }; 376a72f7ea6Sql147931 377a72f7ea6Sql147931 struct rtw_max2820 { 378a72f7ea6Sql147931 struct rtw_rf mx_rf; 379a72f7ea6Sql147931 struct rtw_rfbus mx_bus; 380a72f7ea6Sql147931 int mx_is_a; /* 1: MAX2820A/MAX2821A */ 381a72f7ea6Sql147931 }; 382a72f7ea6Sql147931 383a72f7ea6Sql147931 struct rtw_sa2400 { 384a72f7ea6Sql147931 struct rtw_rf sa_rf; 385a72f7ea6Sql147931 struct rtw_rfbus sa_bus; 386a72f7ea6Sql147931 int sa_digphy; /* 1: digital PHY */ 387a72f7ea6Sql147931 }; 388a72f7ea6Sql147931 389a72f7ea6Sql147931 typedef void (*rtw_pwrstate_t)(struct rtw_regs *, enum rtw_pwrstate, int, int); 390a72f7ea6Sql147931 391a72f7ea6Sql147931 union rtw_keys { 392a72f7ea6Sql147931 uint8_t rk_keys[4][16]; 393a72f7ea6Sql147931 uint32_t rk_words[16]; 394a72f7ea6Sql147931 }; 395a72f7ea6Sql147931 396a72f7ea6Sql147931 #define RTW_LED_SLOW_TICKS MAX(1, hz/2) 397a72f7ea6Sql147931 #define RTW_LED_FAST_TICKS MAX(1, hz/10) 398a72f7ea6Sql147931 399a72f7ea6Sql147931 struct rtw_led_state { 400a72f7ea6Sql147931 #define RTW_LED0 0x1 401a72f7ea6Sql147931 #define RTW_LED1 0x2 402a72f7ea6Sql147931 uint8_t ls_slowblink:2; 403a72f7ea6Sql147931 uint8_t ls_actblink:2; 404a72f7ea6Sql147931 uint8_t ls_default:2; 405a72f7ea6Sql147931 uint8_t ls_state; 406a72f7ea6Sql147931 uint8_t ls_event; 407a72f7ea6Sql147931 #define RTW_LED_S_RX 0x1 408a72f7ea6Sql147931 #define RTW_LED_S_TX 0x2 409a72f7ea6Sql147931 #define RTW_LED_S_SLOW 0x4 410a72f7ea6Sql147931 }; 411a72f7ea6Sql147931 412a72f7ea6Sql147931 typedef struct rtw_softc { 413a72f7ea6Sql147931 ieee80211com_t sc_ic; /* IEEE 802.11 common */ 414a72f7ea6Sql147931 dev_info_t *sc_dev; /* back pointer to dev_info_t */ 415a72f7ea6Sql147931 kmutex_t sc_genlock; 416a72f7ea6Sql147931 struct rtw_regs sc_regs; 417a72f7ea6Sql147931 ddi_acc_handle_t sc_cfg_handle; 418a72f7ea6Sql147931 caddr_t sc_cfg_base; 419a72f7ea6Sql147931 enum ieee80211_phymode sc_curmode; 420a72f7ea6Sql147931 uint32_t sc_flags; 421a72f7ea6Sql147931 uint32_t sc_invalid; 422a72f7ea6Sql147931 ddi_iblock_cookie_t sc_iblock; 423a72f7ea6Sql147931 uint32_t sc_need_reschedule; 424a72f7ea6Sql147931 uint16_t sc_cachelsz; /* cache line size */ 425a72f7ea6Sql147931 uchar_t sc_macaddr[6]; 426a72f7ea6Sql147931 427a72f7ea6Sql147931 enum rtw_rfchipid sc_rfchipid; 428a72f7ea6Sql147931 enum rtw_locale sc_locale; 429a72f7ea6Sql147931 uint8_t sc_phydelay; 430a72f7ea6Sql147931 431a72f7ea6Sql147931 uint32_t sc_dmabuf_size; 432a72f7ea6Sql147931 dma_area_t sc_desc_dma; 433a72f7ea6Sql147931 434a72f7ea6Sql147931 struct rtw_txq sc_txq[RTW_NTXPRI]; 435a72f7ea6Sql147931 436a72f7ea6Sql147931 struct rtw_rxdesc *rxdesc_h; 437a72f7ea6Sql147931 struct rtw_rxbuf *rxbuf_h; 438a72f7ea6Sql147931 uint32_t rx_next; 439a72f7ea6Sql147931 kmutex_t rxbuf_lock; 440a72f7ea6Sql147931 kmutex_t sc_txlock; 441a72f7ea6Sql147931 442a72f7ea6Sql147931 struct rtw_srom sc_srom; 443a72f7ea6Sql147931 enum rtw_pwrstate sc_pwrstate; 444a72f7ea6Sql147931 rtw_pwrstate_t sc_pwrstate_cb; 445a72f7ea6Sql147931 struct rtw_rf *sc_rf; 446a72f7ea6Sql147931 447a72f7ea6Sql147931 uint16_t sc_inten; 448a72f7ea6Sql147931 449a72f7ea6Sql147931 void (*sc_intr_ack)(struct rtw_regs *); 450a72f7ea6Sql147931 451a72f7ea6Sql147931 int (*sc_enable)(struct rtw_softc *); 452a72f7ea6Sql147931 void (*sc_disable)(struct rtw_softc *); 453a72f7ea6Sql147931 void (*sc_power)(struct rtw_softc *, int); 454a72f7ea6Sql147931 struct rtw_hooks sc_hooks; 455a72f7ea6Sql147931 456a72f7ea6Sql147931 uint_t sc_cur_chan; 457a72f7ea6Sql147931 458a72f7ea6Sql147931 uint32_t sc_tsfth; /* most significant TSFT bits */ 459a72f7ea6Sql147931 uint32_t sc_rcr; /* RTW_RCR */ 460a72f7ea6Sql147931 uint8_t sc_csthr; /* carrier-sense threshold */ 461a72f7ea6Sql147931 462a72f7ea6Sql147931 uint8_t sc_rev; /* PCI/Cardbus revision */ 463a72f7ea6Sql147931 464a72f7ea6Sql147931 uint32_t sc_anaparm; /* register RTW_ANAPARM */ 465a72f7ea6Sql147931 #ifdef RTW_RADIOTAP 466a72f7ea6Sql147931 union { 467a72f7ea6Sql147931 struct rtw_rx_radiotap_header tap; 468a72f7ea6Sql147931 uint8_t pad[64]; 469a72f7ea6Sql147931 } sc_rxtapu; 470a72f7ea6Sql147931 union { 471a72f7ea6Sql147931 struct rtw_tx_radiotap_header tap; 472a72f7ea6Sql147931 uint8_t pad[64]; 473a72f7ea6Sql147931 } sc_txtapu; 474a72f7ea6Sql147931 #endif 475a72f7ea6Sql147931 union rtw_keys sc_keys; 476a72f7ea6Sql147931 int sc_txkey; 477a72f7ea6Sql147931 struct rtw_led_state sc_led_state; 478a72f7ea6Sql147931 int sc_hwverid; 479a72f7ea6Sql147931 480a72f7ea6Sql147931 int (*sc_newstate)(ieee80211com_t *, 481a72f7ea6Sql147931 enum ieee80211_state, int); 482a72f7ea6Sql147931 483a72f7ea6Sql147931 timeout_id_t sc_scan_id; 484a72f7ea6Sql147931 timeout_id_t sc_ratectl_id; 485a72f7ea6Sql147931 uint32_t sc_tx_ok; 486a72f7ea6Sql147931 uint32_t sc_tx_err; 487a72f7ea6Sql147931 uint32_t sc_tx_retr; 488a72f7ea6Sql147931 uint32_t sc_xmtretry; 489a72f7ea6Sql147931 uint32_t sc_noxmtbuf; 490a72f7ea6Sql147931 uint32_t sc_norcvbuf; 491a72f7ea6Sql147931 uint32_t sc_bytexmt64; 492a72f7ea6Sql147931 uint32_t sc_bytercv64; 493a72f7ea6Sql147931 uint32_t sc_pktxmt64; 494a72f7ea6Sql147931 uint32_t sc_pktrcv64; 495a72f7ea6Sql147931 uint32_t sc_intr; 496a72f7ea6Sql147931 uint32_t sc_ioerror; 497a72f7ea6Sql147931 uint32_t hw_start; 498a72f7ea6Sql147931 uint32_t hw_go; 499a72f7ea6Sql147931 } rtw_softc_t; 500a72f7ea6Sql147931 501a72f7ea6Sql147931 #define RTW_SC(ic) ((rtw_softc_t *)ic) 502*9aa73b68SQin Michael Li #ifdef __cplusplus 503*9aa73b68SQin Michael Li } 504*9aa73b68SQin Michael Li #endif 505a72f7ea6Sql147931 506a72f7ea6Sql147931 #endif /* _RTWVAR_H_ */ 507