xref: /titanic_50/usr/src/uts/common/io/iwk/iwk2_var.h (revision 6f5f1c638c7bce3a35e88526a88fc78bdfd58ffe)
1 /*
2  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
3  * Use is subject to license terms.
4  */
5 
6 /*
7  * Copyright (c) 2007, Intel Corporation
8  * All rights reserved.
9  */
10 
11 /*
12  * Copyright (c) 2006
13  * Copyright (c) 2007
14  *	Damien Bergamini <damien.bergamini@free.fr>
15  *
16  * Permission to use, copy, modify, and distribute this software for any
17  * purpose with or without fee is hereby granted, provided that the above
18  * copyright notice and this permission notice appear in all copies.
19  *
20  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
21  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
22  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
23  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
24  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
25  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
26  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
27  */
28 
29 #ifndef _IWK_VAR_H
30 #define	_IWK_VAR_H
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 #define	IWK_DMA_SYNC(area, flag) \
37 	(void) ddi_dma_sync((area).dma_hdl, (area).offset, \
38 	(area).alength, (flag))
39 
40 typedef struct iwk_dma_area {
41 	ddi_acc_handle_t	acc_hdl; /* handle for memory */
42 	caddr_t			mem_va; /* CPU VA of memory */
43 	uint32_t		nslots; /* number of slots */
44 	uint32_t		size;   /* size per slot */
45 	size_t			alength; /* allocated size */
46 					/* >= product of above */
47 	ddi_dma_handle_t	dma_hdl; /* DMA handle */
48 	offset_t		offset;  /* relative to handle */
49 	ddi_dma_cookie_t	cookie; /* associated cookie */
50 	uint32_t		ncookies;
51 	uint32_t		token; /* arbitrary identifier */
52 } iwk_dma_t;
53 
54 typedef struct iwk_tx_data {
55 	iwk_dma_t		dma_data;
56 	iwk_tx_desc_t		*desc;
57 	uint32_t		paddr_desc;
58 	iwk_cmd_t		*cmd;
59 	uint32_t		paddr_cmd;
60 } iwk_tx_data_t;
61 
62 typedef struct iwk_tx_ring {
63 	iwk_dma_t		dma_desc;
64 	iwk_dma_t		dma_cmd;
65 	iwk_tx_data_t	*data;
66 	int			qid;
67 	int			count;
68 	int			window;
69 	int			queued;
70 	int			cur;
71 } iwk_tx_ring_t;
72 
73 typedef struct iwk_rx_data {
74 	iwk_dma_t		dma_data;
75 } iwk_rx_data_t;
76 
77 typedef struct iwk_rx_ring {
78 	iwk_dma_t		dma_desc;
79 	uint32_t 		*desc;
80 	iwk_rx_data_t	data[RX_QUEUE_SIZE];
81 	int			cur;
82 } iwk_rx_ring_t;
83 
84 typedef struct iwk_amrr {
85 	ieee80211_node_t in;	/* must be the first */
86 	int	txcnt;
87 	int	retrycnt;
88 	int	success;
89 	int	success_threshold;
90 	int	recovery;
91 } iwk_amrr_t;
92 
93 typedef struct iwk_softc {
94 	struct ieee80211com	sc_ic;
95 	dev_info_t		*sc_dip;
96 	int			(*sc_newstate)(struct ieee80211com *,
97 	    enum ieee80211_state, int);
98 	void			(*sc_recv_mgmt)(ieee80211com_t *, mblk_t *,
99 	    ieee80211_node_t *, int, int, uint32_t);
100 	enum ieee80211_state	sc_ostate;
101 	kmutex_t		sc_glock;
102 	kmutex_t		sc_mt_lock;
103 	kmutex_t		sc_tx_lock;
104 	kcondvar_t		sc_mt_cv;
105 	kcondvar_t		sc_tx_cv;
106 	kcondvar_t		sc_cmd_cv;
107 	kcondvar_t		sc_fw_cv;
108 
109 	kthread_t		*sc_mf_thread;
110 	uint32_t		sc_mf_thread_switch;
111 
112 	uint32_t		sc_flags;
113 	uint32_t		sc_dmabuf_sz;
114 	uint16_t		sc_clsz;
115 	uint8_t			sc_rev;
116 	uint8_t			sc_resv;
117 	uint16_t		sc_assoc_id;
118 	uint16_t		sc_reserved0;
119 
120 	/* shared area */
121 	iwk_dma_t		sc_dma_sh;
122 	iwk_shared_t		*sc_shared;
123 	/* keep warm area */
124 	iwk_dma_t		sc_dma_kw;
125 	/* tx scheduler base address */
126 	uint32_t		sc_scd_base_addr;
127 
128 	iwk_tx_ring_t		sc_txq[IWK_NUM_QUEUES];
129 	iwk_rx_ring_t		sc_rxq;
130 
131 	/* firmware dma */
132 	iwk_firmware_hdr_t	*sc_hdr;
133 	char			*sc_boot;
134 	iwk_dma_t		sc_dma_fw_text;
135 	iwk_dma_t		sc_dma_fw_init_text;
136 	iwk_dma_t		sc_dma_fw_data;
137 	iwk_dma_t		sc_dma_fw_data_bak;
138 	iwk_dma_t		sc_dma_fw_init_data;
139 
140 	ddi_acc_handle_t	sc_cfg_handle;
141 	caddr_t			sc_cfg_base;
142 	ddi_acc_handle_t	sc_handle;
143 	caddr_t			sc_base;
144 	ddi_intr_handle_t	*sc_intr_htable;
145 	uint_t			sc_intr_pri;
146 
147 	iwk_rxon_cmd_t	sc_config;
148 	struct iwk_eep		sc_eep_map; /* eeprom map */
149 	uint32_t		sc_scd_base;
150 
151 	struct iwk_alive_resp	sc_card_alive_run;
152 	struct iwk_init_alive_resp	sc_card_alive_init;
153 
154 	int32_t			sc_tempera;
155 	int32_t			sc_last_tempera;
156 	int32_t			sc_user_txpower;
157 	struct iwk_notif_statistics	sc_statistics;
158 	struct iwk_rx_gain_diff		sc_rxgain_diff;
159 	struct iwk_rx_sensitivity	sc_rx_sens;
160 
161 	uint32_t		sc_tx_timer;
162 	uint32_t		sc_scan_pending;
163 	uint8_t			*sc_fw_bin;
164 
165 	ddi_softint_handle_t    sc_soft_hdl;
166 	uint32_t		sc_rx_softint_pending;
167 	uint32_t		sc_need_reschedule;
168 
169 	clock_t			sc_clk;
170 
171 	/* kstats */
172 	uint32_t		sc_tx_nobuf;
173 	uint32_t		sc_rx_nobuf;
174 	uint32_t		sc_tx_err;
175 	uint32_t		sc_rx_err;
176 	uint32_t		sc_tx_retries;
177 } iwk_sc_t;
178 
179 #define	IWK_F_ATTACHED		(1 << 0)
180 #define	IWK_F_CMD_DONE		(1 << 1)
181 #define	IWK_F_FW_INIT		(1 << 2)
182 #define	IWK_F_HW_ERR_RECOVER	(1 << 3)
183 #define	IWK_F_RATE_AUTO_CTL	(1 << 4)
184 #define	IWK_F_RUNNING		(1 << 5)
185 #define	IWK_F_SCANNING		(1 << 6)
186 #define	IWK_F_SUSPEND		(1 << 7)
187 #define	IWK_F_RADIO_OFF		(1 << 8)
188 #define	IWK_F_STATISTICS	(1 << 9)
189 #define	IWK_F_QUIESCED		(1 << 10)
190 
191 #define	IWK_SUCCESS		0
192 #define	IWK_FAIL		EIO
193 #ifdef __cplusplus
194 }
195 #endif
196 
197 #endif /* _IWK_VAR_H */
198