xref: /titanic_44/usr/src/uts/common/io/rwn/rt2860_var.h (revision 860387ebc186ce5dc552b18d01f5124739a10eed)
18a3c961bSfei feng - Sun Microsystems - Beijing China /*
28a3c961bSfei feng - Sun Microsystems - Beijing China  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
38a3c961bSfei feng - Sun Microsystems - Beijing China  * Use is subject to license terms.
48a3c961bSfei feng - Sun Microsystems - Beijing China  */
58a3c961bSfei feng - Sun Microsystems - Beijing China 
68a3c961bSfei feng - Sun Microsystems - Beijing China /*
78a3c961bSfei feng - Sun Microsystems - Beijing China  * Copyright (c) 2007, 2008
88a3c961bSfei feng - Sun Microsystems - Beijing China  *	Damien Bergamini <damien.bergamini@free.fr>
98a3c961bSfei feng - Sun Microsystems - Beijing China  *
108a3c961bSfei feng - Sun Microsystems - Beijing China  * Permission to use, copy, modify, and distribute this software for any
118a3c961bSfei feng - Sun Microsystems - Beijing China  * purpose with or without fee is hereby granted, provided that the above
128a3c961bSfei feng - Sun Microsystems - Beijing China  * copyright notice and this permission notice appear in all copies.
138a3c961bSfei feng - Sun Microsystems - Beijing China  *
148a3c961bSfei feng - Sun Microsystems - Beijing China  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
158a3c961bSfei feng - Sun Microsystems - Beijing China  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
168a3c961bSfei feng - Sun Microsystems - Beijing China  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
178a3c961bSfei feng - Sun Microsystems - Beijing China  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
188a3c961bSfei feng - Sun Microsystems - Beijing China  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
198a3c961bSfei feng - Sun Microsystems - Beijing China  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
208a3c961bSfei feng - Sun Microsystems - Beijing China  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
218a3c961bSfei feng - Sun Microsystems - Beijing China  */
228a3c961bSfei feng - Sun Microsystems - Beijing China 
238a3c961bSfei feng - Sun Microsystems - Beijing China #ifndef	_RT2860_VAR_H
248a3c961bSfei feng - Sun Microsystems - Beijing China #define	_RT2860_VAR_H
258a3c961bSfei feng - Sun Microsystems - Beijing China 
268a3c961bSfei feng - Sun Microsystems - Beijing China #include <sys/queue.h>
278a3c961bSfei feng - Sun Microsystems - Beijing China 
288a3c961bSfei feng - Sun Microsystems - Beijing China #ifdef __cplusplus
298a3c961bSfei feng - Sun Microsystems - Beijing China extern "C" {
308a3c961bSfei feng - Sun Microsystems - Beijing China #endif
318a3c961bSfei feng - Sun Microsystems - Beijing China 
328a3c961bSfei feng - Sun Microsystems - Beijing China /*
338a3c961bSfei feng - Sun Microsystems - Beijing China  * EDCA Access Categories.
348a3c961bSfei feng - Sun Microsystems - Beijing China  */
358a3c961bSfei feng - Sun Microsystems - Beijing China enum ieee80211_edca_ac {
368a3c961bSfei feng - Sun Microsystems - Beijing China 	EDCA_AC_BK  = 1,	/* Background */
378a3c961bSfei feng - Sun Microsystems - Beijing China 	EDCA_AC_BE  = 0,	/* Best Effort */
388a3c961bSfei feng - Sun Microsystems - Beijing China 	EDCA_AC_VI  = 2,	/* Video */
398a3c961bSfei feng - Sun Microsystems - Beijing China 	EDCA_AC_VO  = 3		/* Voice */
408a3c961bSfei feng - Sun Microsystems - Beijing China };
418a3c961bSfei feng - Sun Microsystems - Beijing China #define	EDCA_NUM_AC	4
428a3c961bSfei feng - Sun Microsystems - Beijing China 
438a3c961bSfei feng - Sun Microsystems - Beijing China #define	RT2860_SUCCESS		0
448a3c961bSfei feng - Sun Microsystems - Beijing China 
458a3c961bSfei feng - Sun Microsystems - Beijing China #define	RT2860_TX_RING_COUNT	64
468a3c961bSfei feng - Sun Microsystems - Beijing China #define	RT2860_RX_RING_COUNT	128
478a3c961bSfei feng - Sun Microsystems - Beijing China #define	RT2860_TX_POOL_COUNT	(RT2860_TX_RING_COUNT * 2)
488a3c961bSfei feng - Sun Microsystems - Beijing China 
498a3c961bSfei feng - Sun Microsystems - Beijing China #define	RT2860_MAX_SCATTER	((RT2860_TX_RING_COUNT * 2) - 1)
508a3c961bSfei feng - Sun Microsystems - Beijing China 
51*860387ebSfei feng - Sun Microsystems - Beijing China #define	RT2860_RSSI_OFFSET	92
52*860387ebSfei feng - Sun Microsystems - Beijing China 
538a3c961bSfei feng - Sun Microsystems - Beijing China /* HW supports up to 255 STAs */
548a3c961bSfei feng - Sun Microsystems - Beijing China #define	RT2860_WCID_MAX		254
558a3c961bSfei feng - Sun Microsystems - Beijing China #define	RT2860_AID2WCID(aid)	((aid) & 0xff)
568a3c961bSfei feng - Sun Microsystems - Beijing China 
578a3c961bSfei feng - Sun Microsystems - Beijing China struct dma_area {
588a3c961bSfei feng - Sun Microsystems - Beijing China 	ddi_acc_handle_t	acc_hdl;	/* handle for memory */
598a3c961bSfei feng - Sun Microsystems - Beijing China 	caddr_t			mem_va;		/* CPU VA of memory */
608a3c961bSfei feng - Sun Microsystems - Beijing China 	uint32_t		nslots;		/* number of slots */
618a3c961bSfei feng - Sun Microsystems - Beijing China 	uint32_t		size;		/* size per slot */
628a3c961bSfei feng - Sun Microsystems - Beijing China 	size_t			alength;	/* allocated size */
638a3c961bSfei feng - Sun Microsystems - Beijing China 
648a3c961bSfei feng - Sun Microsystems - Beijing China 	ddi_dma_handle_t	dma_hdl;	/* DMA handle */
658a3c961bSfei feng - Sun Microsystems - Beijing China 	offset_t		offset;		/* relative to handle */
668a3c961bSfei feng - Sun Microsystems - Beijing China 	ddi_dma_cookie_t	cookie;		/* associated cookie */
678a3c961bSfei feng - Sun Microsystems - Beijing China 	uint32_t		ncookies;	/* must be 1 */
688a3c961bSfei feng - Sun Microsystems - Beijing China 	uint32_t		token;		/* arbitrary identifier */
698a3c961bSfei feng - Sun Microsystems - Beijing China };
708a3c961bSfei feng - Sun Microsystems - Beijing China 
718a3c961bSfei feng - Sun Microsystems - Beijing China struct rt2860_txd;
728a3c961bSfei feng - Sun Microsystems - Beijing China 
738a3c961bSfei feng - Sun Microsystems - Beijing China struct rt2860_tx_data {
748a3c961bSfei feng - Sun Microsystems - Beijing China 	struct dma_area			txbuf_dma;
758a3c961bSfei feng - Sun Microsystems - Beijing China 	struct rt2860_txwi		*txwi;
768a3c961bSfei feng - Sun Microsystems - Beijing China 	uint32_t			paddr;
778a3c961bSfei feng - Sun Microsystems - Beijing China 	struct ieee80211_node		*ni;
788a3c961bSfei feng - Sun Microsystems - Beijing China 	SLIST_ENTRY(rt2860_tx_data)	next;
798a3c961bSfei feng - Sun Microsystems - Beijing China };
808a3c961bSfei feng - Sun Microsystems - Beijing China 
818a3c961bSfei feng - Sun Microsystems - Beijing China struct rt2860_tx_ring {
828a3c961bSfei feng - Sun Microsystems - Beijing China 	struct dma_area		txdesc_dma;
838a3c961bSfei feng - Sun Microsystems - Beijing China 	struct rt2860_txd	*txd;
848a3c961bSfei feng - Sun Microsystems - Beijing China 	uint32_t		paddr;
858a3c961bSfei feng - Sun Microsystems - Beijing China 	struct rt2860_tx_data	*data[RT2860_TX_RING_COUNT];
868a3c961bSfei feng - Sun Microsystems - Beijing China 	int			cur;
878a3c961bSfei feng - Sun Microsystems - Beijing China 	int			next;
888a3c961bSfei feng - Sun Microsystems - Beijing China 	int			queued;
898a3c961bSfei feng - Sun Microsystems - Beijing China };
908a3c961bSfei feng - Sun Microsystems - Beijing China 
918a3c961bSfei feng - Sun Microsystems - Beijing China struct rt2860_rx_data {
928a3c961bSfei feng - Sun Microsystems - Beijing China 	struct dma_area		rxbuf_dma;
938a3c961bSfei feng - Sun Microsystems - Beijing China };
948a3c961bSfei feng - Sun Microsystems - Beijing China 
958a3c961bSfei feng - Sun Microsystems - Beijing China struct rt2860_rx_ring {
968a3c961bSfei feng - Sun Microsystems - Beijing China 	struct dma_area		rxdesc_dma;
978a3c961bSfei feng - Sun Microsystems - Beijing China 	struct rt2860_rxd	*rxd;
988a3c961bSfei feng - Sun Microsystems - Beijing China 	uint32_t		paddr;
998a3c961bSfei feng - Sun Microsystems - Beijing China 	unsigned int		cur;	/* must be unsigned */
1008a3c961bSfei feng - Sun Microsystems - Beijing China 	struct rt2860_rx_data	data[RT2860_RX_RING_COUNT];
1018a3c961bSfei feng - Sun Microsystems - Beijing China };
1028a3c961bSfei feng - Sun Microsystems - Beijing China 
1038a3c961bSfei feng - Sun Microsystems - Beijing China struct rt2860_amrr {
1048a3c961bSfei feng - Sun Microsystems - Beijing China 	uint_t	amrr_min_success_threshold;
1058a3c961bSfei feng - Sun Microsystems - Beijing China 	uint_t	amrr_max_success_threshold;
1068a3c961bSfei feng - Sun Microsystems - Beijing China };
1078a3c961bSfei feng - Sun Microsystems - Beijing China 
1088a3c961bSfei feng - Sun Microsystems - Beijing China struct rt2860_amrr_node {
1098a3c961bSfei feng - Sun Microsystems - Beijing China 	int	amn_success;
1108a3c961bSfei feng - Sun Microsystems - Beijing China 	int	amn_recovery;
1118a3c961bSfei feng - Sun Microsystems - Beijing China 	int	amn_success_threshold;
1128a3c961bSfei feng - Sun Microsystems - Beijing China 	int	amn_txcnt;
1138a3c961bSfei feng - Sun Microsystems - Beijing China 	int	amn_retrycnt;
1148a3c961bSfei feng - Sun Microsystems - Beijing China };
1158a3c961bSfei feng - Sun Microsystems - Beijing China 
1168a3c961bSfei feng - Sun Microsystems - Beijing China #define	RT2860_DMA_SYNC(area, flag) ((void) ddi_dma_sync((area).dma_hdl,\
1178a3c961bSfei feng - Sun Microsystems - Beijing China 	(area).offset, (area).alength, (flag)))
1188a3c961bSfei feng - Sun Microsystems - Beijing China #define	RT2860_IS_RUNNING(_sc)		(((_sc)->sc_flags & RT2860_F_RUNNING))
1198a3c961bSfei feng - Sun Microsystems - Beijing China #define	RT2860_IS_INITED(_sc)		((_sc)->sc_flags & RT2860_F_RUNNING)
1208a3c961bSfei feng - Sun Microsystems - Beijing China #define	RT2860_IS_SUSPEND(_sc)		((_sc)->sc_flags & RT2860_F_SUSPEND)
1218a3c961bSfei feng - Sun Microsystems - Beijing China #define	RT2860_GLOCK(_sc)		mutex_enter(&(_sc)->sc_genlock)
1228a3c961bSfei feng - Sun Microsystems - Beijing China #define	RT2860_GUNLOCK(_sc)		mutex_exit(&(_sc)->sc_genlock)
1238a3c961bSfei feng - Sun Microsystems - Beijing China 
1248a3c961bSfei feng - Sun Microsystems - Beijing China 
1258a3c961bSfei feng - Sun Microsystems - Beijing China struct rt2860_softc {
1268a3c961bSfei feng - Sun Microsystems - Beijing China 	struct ieee80211com	sc_ic;
1278a3c961bSfei feng - Sun Microsystems - Beijing China 	dev_info_t		*sc_dev;
1288a3c961bSfei feng - Sun Microsystems - Beijing China 
1298a3c961bSfei feng - Sun Microsystems - Beijing China 	/* ddi reg handler */
1308a3c961bSfei feng - Sun Microsystems - Beijing China 	ddi_acc_handle_t	sc_cfg_handle;
1318a3c961bSfei feng - Sun Microsystems - Beijing China 	caddr_t			sc_cfg_base;
1328a3c961bSfei feng - Sun Microsystems - Beijing China 	/* ddi i/o handler */
1338a3c961bSfei feng - Sun Microsystems - Beijing China 	ddi_acc_handle_t	sc_io_handle;
1348a3c961bSfei feng - Sun Microsystems - Beijing China 	caddr_t			sc_io_base;
1358a3c961bSfei feng - Sun Microsystems - Beijing China 	/* interrupt */
1368a3c961bSfei feng - Sun Microsystems - Beijing China 	ddi_iblock_cookie_t	sc_iblock;
1378a3c961bSfei feng - Sun Microsystems - Beijing China 	kmutex_t		sc_genlock;
1388a3c961bSfei feng - Sun Microsystems - Beijing China 	kmutex_t		sc_txlock;
1398a3c961bSfei feng - Sun Microsystems - Beijing China 	kmutex_t		sc_rxlock;
1408a3c961bSfei feng - Sun Microsystems - Beijing China 	timeout_id_t		sc_scan_id;
1418a3c961bSfei feng - Sun Microsystems - Beijing China 	timeout_id_t		sc_rssadapt_id;
1428a3c961bSfei feng - Sun Microsystems - Beijing China 	timeout_id_t		sc_state_id;
1438a3c961bSfei feng - Sun Microsystems - Beijing China 	struct rt2860_amrr	amrr;
1448a3c961bSfei feng - Sun Microsystems - Beijing China 	enum ieee80211_state	sc_ostate;
1458a3c961bSfei feng - Sun Microsystems - Beijing China 
1468a3c961bSfei feng - Sun Microsystems - Beijing China #define	RT2860_ENABLED		(1 << 0)
1478a3c961bSfei feng - Sun Microsystems - Beijing China #define	RT2860_FWLOADED		(1 << 1)
1488a3c961bSfei feng - Sun Microsystems - Beijing China #define	RT2860_UPD_BEACON	(1 << 2)
1498a3c961bSfei feng - Sun Microsystems - Beijing China #define	RT2860_ADVANCED_PS	(1 << 3)
1508a3c961bSfei feng - Sun Microsystems - Beijing China #define	RT2860_F_RUNNING	(1 << 4)
1518a3c961bSfei feng - Sun Microsystems - Beijing China #define	RT2860_F_SUSPEND	(1 << 5)
1528a3c961bSfei feng - Sun Microsystems - Beijing China #define	RT2860_F_QUIESCE	(1 << 6)
1538a3c961bSfei feng - Sun Microsystems - Beijing China 
1548a3c961bSfei feng - Sun Microsystems - Beijing China 	uint32_t			sc_ic_flags;
1558a3c961bSfei feng - Sun Microsystems - Beijing China 	uint32_t			sc_dmabuf_size;
1568a3c961bSfei feng - Sun Microsystems - Beijing China 	struct rt2860_tx_ring		txq[6];
1578a3c961bSfei feng - Sun Microsystems - Beijing China 	struct rt2860_rx_ring		rxq;
1588a3c961bSfei feng - Sun Microsystems - Beijing China 
1598a3c961bSfei feng - Sun Microsystems - Beijing China 	struct dma_area			txpool_dma;
1608a3c961bSfei feng - Sun Microsystems - Beijing China 	struct rt2860_txwi		*txwi;
1618a3c961bSfei feng - Sun Microsystems - Beijing China 	struct rt2860_tx_data		data[RT2860_TX_POOL_COUNT];
1628a3c961bSfei feng - Sun Microsystems - Beijing China 	SLIST_HEAD(, rt2860_tx_data)	data_pool;
1638a3c961bSfei feng - Sun Microsystems - Beijing China 
1648a3c961bSfei feng - Sun Microsystems - Beijing China 	int			sc_tx_timer;
1658a3c961bSfei feng - Sun Microsystems - Beijing China 	int			mgtqid;
1668a3c961bSfei feng - Sun Microsystems - Beijing China 	int			sifs;
1678a3c961bSfei feng - Sun Microsystems - Beijing China 
1688a3c961bSfei feng - Sun Microsystems - Beijing China 	/* firmware related info */
1698a3c961bSfei feng - Sun Microsystems - Beijing China 	uint32_t		mac_rev;
1708a3c961bSfei feng - Sun Microsystems - Beijing China 	uint8_t			rf_rev;
1718a3c961bSfei feng - Sun Microsystems - Beijing China 	uint8_t			freq;
1728a3c961bSfei feng - Sun Microsystems - Beijing China 	uint8_t			ntxchains;
1738a3c961bSfei feng - Sun Microsystems - Beijing China 	uint8_t			nrxchains;
1748a3c961bSfei feng - Sun Microsystems - Beijing China 	uint8_t			pslevel;
1758a3c961bSfei feng - Sun Microsystems - Beijing China 	int8_t			txpow1[50];
1768a3c961bSfei feng - Sun Microsystems - Beijing China 	int8_t			txpow2[50];
1778a3c961bSfei feng - Sun Microsystems - Beijing China 	int8_t			rssi_2ghz[3];
1788a3c961bSfei feng - Sun Microsystems - Beijing China 	int8_t			rssi_5ghz[3];
1798a3c961bSfei feng - Sun Microsystems - Beijing China 	uint8_t			lna[4];
1808a3c961bSfei feng - Sun Microsystems - Beijing China 	uint8_t			calib_2ghz;
1818a3c961bSfei feng - Sun Microsystems - Beijing China 	uint8_t			calib_5ghz;
1828a3c961bSfei feng - Sun Microsystems - Beijing China 	uint8_t			tssi_2ghz[9];
1838a3c961bSfei feng - Sun Microsystems - Beijing China 	uint8_t			tssi_5ghz[9];
1848a3c961bSfei feng - Sun Microsystems - Beijing China 	uint8_t			step_2ghz;
1858a3c961bSfei feng - Sun Microsystems - Beijing China 	uint8_t			step_5ghz;
1868a3c961bSfei feng - Sun Microsystems - Beijing China 
1878a3c961bSfei feng - Sun Microsystems - Beijing China 	uint32_t		sc_need_sched;
1888a3c961bSfei feng - Sun Microsystems - Beijing China 	uint32_t		sc_flags;
1898a3c961bSfei feng - Sun Microsystems - Beijing China 	/* RT2860 RCR */
1908a3c961bSfei feng - Sun Microsystems - Beijing China 	uint32_t		sc_rcr;
1918a3c961bSfei feng - Sun Microsystems - Beijing China 
1928a3c961bSfei feng - Sun Microsystems - Beijing China 	uint16_t		sc_cachelsz;
1938a3c961bSfei feng - Sun Microsystems - Beijing China 	ddi_softintr_t		sc_softintr_hdl;
1948a3c961bSfei feng - Sun Microsystems - Beijing China 
1958a3c961bSfei feng - Sun Microsystems - Beijing China 	uint32_t		sc_rx_pend;
1968a3c961bSfei feng - Sun Microsystems - Beijing China 
1978a3c961bSfei feng - Sun Microsystems - Beijing China 	uint32_t		rf_regs[4];
1988a3c961bSfei feng - Sun Microsystems - Beijing China 	uint8_t			txpow[14];
1998a3c961bSfei feng - Sun Microsystems - Beijing China 
2008a3c961bSfei feng - Sun Microsystems - Beijing China 	struct {
2018a3c961bSfei feng - Sun Microsystems - Beijing China 		uint8_t	reg;
2028a3c961bSfei feng - Sun Microsystems - Beijing China 		uint8_t	val;
2038a3c961bSfei feng - Sun Microsystems - Beijing China 	}			bbp[8];
2048a3c961bSfei feng - Sun Microsystems - Beijing China 	uint8_t			leds;
2058a3c961bSfei feng - Sun Microsystems - Beijing China 	uint16_t		led[3];
2068a3c961bSfei feng - Sun Microsystems - Beijing China 	uint32_t		txpow20mhz[5];
2078a3c961bSfei feng - Sun Microsystems - Beijing China 	uint32_t		txpow40mhz_2ghz[5];
2088a3c961bSfei feng - Sun Microsystems - Beijing China 	uint32_t		txpow40mhz_5ghz[5];
2098a3c961bSfei feng - Sun Microsystems - Beijing China 
2108a3c961bSfei feng - Sun Microsystems - Beijing China 	struct rt2860_amrr_node	amn[RT2860_WCID_MAX + 1];
2118a3c961bSfei feng - Sun Microsystems - Beijing China 
2128a3c961bSfei feng - Sun Microsystems - Beijing China 	int			led_mode;
2138a3c961bSfei feng - Sun Microsystems - Beijing China 	int			hw_radio;
2148a3c961bSfei feng - Sun Microsystems - Beijing China 	int			rx_ant;
2158a3c961bSfei feng - Sun Microsystems - Beijing China 	int			tx_ant;
2168a3c961bSfei feng - Sun Microsystems - Beijing China 	int			nb_ant;
2178a3c961bSfei feng - Sun Microsystems - Beijing China 
2188a3c961bSfei feng - Sun Microsystems - Beijing China 	int			dwelltime;
2198a3c961bSfei feng - Sun Microsystems - Beijing China 
2208a3c961bSfei feng - Sun Microsystems - Beijing China 	/* kstats */
2218a3c961bSfei feng - Sun Microsystems - Beijing China 	uint32_t		sc_tx_nobuf;
2228a3c961bSfei feng - Sun Microsystems - Beijing China 	uint32_t		sc_rx_nobuf;
2238a3c961bSfei feng - Sun Microsystems - Beijing China 	uint32_t		sc_tx_err;
2248a3c961bSfei feng - Sun Microsystems - Beijing China 	uint32_t		sc_rx_err;
2258a3c961bSfei feng - Sun Microsystems - Beijing China 	uint32_t		sc_tx_retries;
2268a3c961bSfei feng - Sun Microsystems - Beijing China 
2278a3c961bSfei feng - Sun Microsystems - Beijing China 	int			(*sc_newstate)(struct ieee80211com *,
2288a3c961bSfei feng - Sun Microsystems - Beijing China 				    enum ieee80211_state, int);
2298a3c961bSfei feng - Sun Microsystems - Beijing China };
2308a3c961bSfei feng - Sun Microsystems - Beijing China 
2318a3c961bSfei feng - Sun Microsystems - Beijing China #ifdef __cplusplus
2328a3c961bSfei feng - Sun Microsystems - Beijing China }
2338a3c961bSfei feng - Sun Microsystems - Beijing China #endif
2348a3c961bSfei feng - Sun Microsystems - Beijing China 
2358a3c961bSfei feng - Sun Microsystems - Beijing China #endif /* _RT2860_VAR_H */
236