xref: /onnv-gate/usr/src/uts/common/io/wpi/wpivar.h (revision 8902:1ad4510e484d)
14128Shx147065 /*
2*8902SPengcheng.Chen@Sun.COM  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
34128Shx147065  * Use is subject to license terms.
44128Shx147065  */
54128Shx147065 /*
64128Shx147065  * Copyright (c) 2006
74128Shx147065  *	Damien Bergamini <damien.bergamini@free.fr>
84128Shx147065  *
94128Shx147065  * Permission to use, copy, modify, and distribute this software for any
104128Shx147065  * purpose with or without fee is hereby granted, provided that the above
114128Shx147065  * copyright notice and this permission notice appear in all copies.
124128Shx147065  *
134128Shx147065  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
144128Shx147065  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
154128Shx147065  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
164128Shx147065  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
174128Shx147065  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
184128Shx147065  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
194128Shx147065  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
204128Shx147065  */
214128Shx147065 #ifndef _WPIVAR_H
224128Shx147065 #define	_WPIVAR_H
234128Shx147065 
244128Shx147065 #ifdef __cplusplus
254128Shx147065 extern "C" {
264128Shx147065 #endif
274128Shx147065 
284128Shx147065 #ifdef WPI_BPF
294128Shx147065 typedef struct wpi_rx_radiotap_header {
304128Shx147065 	struct ieee80211_radiotap_header wr_ihdr;
314128Shx147065 	uint64_t	wr_tsft;
324128Shx147065 	uint8_t		wr_flags;
334128Shx147065 	uint8_t		wr_rate;
344128Shx147065 	uint16_t	wr_chan_freq;
354128Shx147065 	uint16_t	wr_chan_flags;
364128Shx147065 	int8_t		wr_dbm_antsignal;
374128Shx147065 	int8_t		wr_dbm_antnoise;
384128Shx147065 	uint8_t		wr_antenna;
394128Shx147065 } wpi_rx_radiotap_header_t;
404128Shx147065 
414128Shx147065 #define	WPI_RX_RADIOTAP_PRESENT						\
424128Shx147065 	((1 << IEEE80211_RADIOTAP_TSFT) |				\
434128Shx147065 	(1 << IEEE80211_RADIOTAP_FLAGS) |				\
444128Shx147065 	(1 << IEEE80211_RADIOTAP_RATE) |				\
454128Shx147065 	(1 << IEEE80211_RADIOTAP_CHANNEL) |				\
464128Shx147065 	(1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) |			\
474128Shx147065 	(1 << IEEE80211_RADIOTAP_DBM_ANTNOISE) |			\
484128Shx147065 	(1 << IEEE80211_RADIOTAP_ANTENNA))
494128Shx147065 
504128Shx147065 typedef struct wpi_tx_radiotap_header {
514128Shx147065 	struct ieee80211_radiotap_header wt_ihdr;
524128Shx147065 	uint8_t		wt_flags;
534128Shx147065 	uint8_t		wt_rate;
544128Shx147065 	uint16_t	wt_chan_freq;
554128Shx147065 	uint16_t	wt_chan_flags;
564128Shx147065 } wpi_tx_radiotap_header_t;
574128Shx147065 
584128Shx147065 #define	WPI_TX_RADIOTAP_PRESENT						\
594128Shx147065 	((1 << IEEE80211_RADIOTAP_FLAGS) |				\
604128Shx147065 	(1 << IEEE80211_RADIOTAP_RATE) |				\
614128Shx147065 	(1 << IEEE80211_RADIOTAP_CHANNEL))
624128Shx147065 #endif
634128Shx147065 
644128Shx147065 #define	WPI_DMA_SYNC(area, flag) \
654128Shx147065 	(void) ddi_dma_sync((area).dma_hdl, (area).offset, \
664128Shx147065 	(area).alength, (flag))
674128Shx147065 
68*8902SPengcheng.Chen@Sun.COM #define	WPI_CHK_FAST_RECOVER(sc) \
69*8902SPengcheng.Chen@Sun.COM 	(sc->sc_ic.ic_state == IEEE80211_S_RUN && \
70*8902SPengcheng.Chen@Sun.COM 	sc->sc_ic.ic_opmode == IEEE80211_M_STA)
71*8902SPengcheng.Chen@Sun.COM 
724128Shx147065 typedef struct wpi_dma_area {
734128Shx147065 	ddi_acc_handle_t	acc_hdl; /* handle for memory */
744128Shx147065 	caddr_t			mem_va; /* CPU VA of memory */
754128Shx147065 	uint32_t		nslots; /* number of slots */
764128Shx147065 	uint32_t		size;   /* size per slot */
774128Shx147065 	size_t			alength; /* allocated size */
784128Shx147065 					/* >= product of above */
794128Shx147065 	ddi_dma_handle_t	dma_hdl; /* DMA handle */
804128Shx147065 	offset_t		offset;  /* relative to handle */
814128Shx147065 	ddi_dma_cookie_t	cookie; /* associated cookie */
824128Shx147065 	uint32_t		ncookies;
834128Shx147065 	uint32_t		token; /* arbitrary identifier */
844128Shx147065 } wpi_dma_t;
854128Shx147065 
864128Shx147065 typedef struct wpi_tx_data {
874128Shx147065 	wpi_dma_t		dma_data;
884128Shx147065 	wpi_tx_desc_t		*desc;
894128Shx147065 	uint32_t		paddr_desc;
904128Shx147065 	wpi_tx_cmd_t		*cmd;
914128Shx147065 	uint32_t		paddr_cmd;
924128Shx147065 } wpi_tx_data_t;
934128Shx147065 
944128Shx147065 typedef struct wpi_tx_ring {
954128Shx147065 	wpi_dma_t		dma_desc;
964128Shx147065 	wpi_dma_t		dma_cmd;
974128Shx147065 	wpi_tx_data_t		*data;
984128Shx147065 	int			qid;
994128Shx147065 	int			count;
1004128Shx147065 	int			queued;
1014128Shx147065 	int			cur;
1024128Shx147065 } wpi_tx_ring_t;
1034128Shx147065 
1044128Shx147065 typedef struct wpi_rx_data {
1054128Shx147065 	wpi_dma_t		dma_data;
1064128Shx147065 } wpi_rx_data_t;
1074128Shx147065 
1084128Shx147065 typedef struct wpi_rx_ring {
1094128Shx147065 	wpi_dma_t		dma_desc;
1104128Shx147065 	uint32_t 		*desc;
1114128Shx147065 	wpi_rx_data_t		data[WPI_RX_RING_COUNT];
1124128Shx147065 	int			cur;
1134128Shx147065 } wpi_rx_ring_t;
1144128Shx147065 
1154128Shx147065 typedef struct wpi_amrr {
1164128Shx147065 	ieee80211_node_t in;	/* must be the first */
1174128Shx147065 	int	txcnt;
1184128Shx147065 	int	retrycnt;
1194128Shx147065 	int	success;
1204128Shx147065 	int	success_threshold;
1214128Shx147065 	int	recovery;
1224128Shx147065 } wpi_amrr_t;
1234128Shx147065 
1244128Shx147065 typedef struct wpi_softc {
1254128Shx147065 	struct ieee80211com	sc_ic;
1264128Shx147065 	dev_info_t		*sc_dip;
1274128Shx147065 	int			(*sc_newstate)(struct ieee80211com *,
1284128Shx147065 				    enum ieee80211_state, int);
1294128Shx147065 	enum ieee80211_state	sc_ostate;
1304128Shx147065 	kmutex_t		sc_glock;
1314128Shx147065 	kmutex_t		sc_mt_lock;
1324128Shx147065 	kmutex_t		sc_tx_lock;
1334128Shx147065 	kcondvar_t		sc_mt_cv;
1344128Shx147065 	kcondvar_t		sc_tx_cv;
1354128Shx147065 	kcondvar_t		sc_cmd_cv;
1364128Shx147065 	kcondvar_t		sc_fw_cv;
1374128Shx147065 
1384128Shx147065 	kthread_t		*sc_mf_thread;
1394128Shx147065 	uint32_t		sc_mf_thread_switch;
1404128Shx147065 
1414128Shx147065 	uint32_t		sc_flags;
1424128Shx147065 	uint32_t		sc_dmabuf_sz;
1434128Shx147065 	uint16_t		sc_clsz;
1444128Shx147065 	uint8_t			sc_rev;
1454128Shx147065 	uint8_t			sc_resv;
1464128Shx147065 
1474128Shx147065 	/* shared area */
1484128Shx147065 	wpi_dma_t		sc_dma_sh;
1494128Shx147065 	wpi_shared_t		*sc_shared;
1504128Shx147065 
1514128Shx147065 	wpi_tx_ring_t		sc_txq[4];
1524128Shx147065 	wpi_tx_ring_t		sc_cmdq;
1534128Shx147065 	wpi_tx_ring_t		sc_svcq;
1544128Shx147065 	wpi_rx_ring_t		sc_rxq;
1554128Shx147065 
1564128Shx147065 	/* dma */
1574128Shx147065 	const wpi_firmware_hdr_t *sc_hdr;
1584128Shx147065 	const char		*sc_boot;
1594128Shx147065 	const char		*sc_text;
1604128Shx147065 	const char		*sc_data;
1614128Shx147065 	wpi_dma_t		sc_dma_fw_text;
1624128Shx147065 	ddi_dma_cookie_t	sc_fw_text_cookie[4];
1634128Shx147065 	wpi_dma_t		sc_dma_fw_data;
1644128Shx147065 	ddi_dma_cookie_t	sc_fw_data_cookie[4];
1654128Shx147065 
1664128Shx147065 	ddi_acc_handle_t	sc_handle;
1674128Shx147065 	caddr_t			sc_base;
1684128Shx147065 	ddi_iblock_cookie_t	sc_iblk;
1694128Shx147065 
1704128Shx147065 	wpi_config_t		sc_config;
171*8902SPengcheng.Chen@Sun.COM 	wpi_config_t		sc_config_save;
172*8902SPengcheng.Chen@Sun.COM 
1734128Shx147065 	uint16_t		sc_pwr1[14];
1744128Shx147065 	uint16_t		sc_pwr2[14];
1754128Shx147065 
1764128Shx147065 	uint32_t		sc_tx_timer;
1777865SPengcheng.Chen@Sun.COM 	uint32_t		sc_scan_next;
1787865SPengcheng.Chen@Sun.COM 	uint32_t		sc_scan_pending;
1794128Shx147065 	uint8_t			*sc_fw_bin;
1804128Shx147065 
1814128Shx147065 	ddi_softintr_t		sc_notif_softint_id;
1824128Shx147065 	uint32_t		sc_notif_softint_pending;
1834128Shx147065 	uint32_t		sc_need_reschedule;
1844128Shx147065 
1854128Shx147065 	clock_t			sc_clk;
1864128Shx147065 
1874128Shx147065 	/* kstats */
1884128Shx147065 	uint32_t		sc_tx_nobuf;
1894128Shx147065 	uint32_t		sc_rx_nobuf;
1904128Shx147065 	uint32_t		sc_tx_err;
1914128Shx147065 	uint32_t		sc_rx_err;
1924128Shx147065 	uint32_t		sc_tx_retries;
1936062Shx147065 
1944128Shx147065 #ifdef WPI_BPF
1954128Shx147065 	struct bpf_if		*sc_drvbpf;
1964128Shx147065 
1974128Shx147065 	union {
1984128Shx147065 		struct wpi_rx_radiotap_header th;
1994128Shx147065 		uint8_t	pad[64];
2004128Shx147065 	} sc_rxtapu;
2014128Shx147065 #define	sc_rxtap	sc_rxtapu.th
2024128Shx147065 	int			sc_rxtap_len;
2034128Shx147065 
2044128Shx147065 	union {
2054128Shx147065 		struct wpi_tx_radiotap_header th;
2064128Shx147065 		uint8_t	pad[64];
2074128Shx147065 	} sc_txtapu;
2084128Shx147065 #define	sc_txtap	sc_txtapu.th
2094128Shx147065 	int			sc_txtap_len;
2104128Shx147065 #endif
2114128Shx147065 } wpi_sc_t;
2124128Shx147065 
2134128Shx147065 #define	WPI_F_ATTACHED		(1 << 0)
2144128Shx147065 #define	WPI_F_CMD_DONE		(1 << 1)
2154128Shx147065 #define	WPI_F_FW_INIT		(1 << 2)
2164128Shx147065 #define	WPI_F_HW_ERR_RECOVER	(1 << 3)
2174128Shx147065 #define	WPI_F_RATE_AUTO_CTL	(1 << 4)
2184128Shx147065 #define	WPI_F_RUNNING		(1 << 5)
2196062Shx147065 #define	WPI_F_SUSPEND		(1 << 6)
2206062Shx147065 #define	WPI_F_RADIO_OFF		(1 << 7)
2217865SPengcheng.Chen@Sun.COM #define	WPI_F_SCANNING		(1 << 8)
2228165SFei.Feng@Sun.COM #define	WPI_F_QUIESCED		(1 << 9)
2238349SPengcheng.Chen@Sun.COM #define	WPI_F_LAZY_RESUME	(1 << 10)
2244128Shx147065 
2254128Shx147065 #define	WPI_SUCCESS		0
2266629Szf162725 #define	WPI_FAIL		(EIO)
2274128Shx147065 #ifdef __cplusplus
2284128Shx147065 }
2294128Shx147065 #endif
2304128Shx147065 
2314128Shx147065 #endif /* _WPIVAR_H */
232