xref: /illumos-gate/usr/src/uts/common/sys/fibre-channel/fca/emlxs/emlxs_os.h (revision bb63f56ebeb244bd34f5e8d50900e3420f01b394)
1fcf3ce44SJohn Forte /*
2fcf3ce44SJohn Forte  * CDDL HEADER START
3fcf3ce44SJohn Forte  *
4fcf3ce44SJohn Forte  * The contents of this file are subject to the terms of the
5fcf3ce44SJohn Forte  * Common Development and Distribution License (the "License").
6fcf3ce44SJohn Forte  * You may not use this file except in compliance with the License.
7fcf3ce44SJohn Forte  *
8fcf3ce44SJohn Forte  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9fcf3ce44SJohn Forte  * or http://www.opensolaris.org/os/licensing.
10fcf3ce44SJohn Forte  * See the License for the specific language governing permissions
11fcf3ce44SJohn Forte  * and limitations under the License.
12fcf3ce44SJohn Forte  *
13fcf3ce44SJohn Forte  * When distributing Covered Code, include this CDDL HEADER in each
14fcf3ce44SJohn Forte  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15fcf3ce44SJohn Forte  * If applicable, add the following below this CDDL HEADER, with the
16fcf3ce44SJohn Forte  * fields enclosed by brackets "[]" replaced with your own identifying
17fcf3ce44SJohn Forte  * information: Portions Copyright [yyyy] [name of copyright owner]
18fcf3ce44SJohn Forte  *
19fcf3ce44SJohn Forte  * CDDL HEADER END
20fcf3ce44SJohn Forte  */
21fcf3ce44SJohn Forte 
22fcf3ce44SJohn Forte /*
23291a2b48SSukumar Swaminathan  * Copyright 2009 Emulex.  All rights reserved.
24fcf3ce44SJohn Forte  * Use is subject to License terms.
25fcf3ce44SJohn Forte  */
26fcf3ce44SJohn Forte 
27fcf3ce44SJohn Forte 
28fcf3ce44SJohn Forte #ifndef _EMLXS_OS_H
29fcf3ce44SJohn Forte #define	_EMLXS_OS_H
30fcf3ce44SJohn Forte 
31fcf3ce44SJohn Forte #ifdef	__cplusplus
32fcf3ce44SJohn Forte extern "C" {
33fcf3ce44SJohn Forte #endif
34fcf3ce44SJohn Forte 
35291a2b48SSukumar Swaminathan #define	EMLXS_MODREV2    2	/* Old Solaris 8 & 9 interface */
36291a2b48SSukumar Swaminathan #define	EMLXS_MODREV3    3	/* New Solaris 10 & 11 interface */
37291a2b48SSukumar Swaminathan #define	EMLXS_MODREV4    4	/* Sun FC packet change */
38291a2b48SSukumar Swaminathan 				/* Symbolic Node Name interface */
39291a2b48SSukumar Swaminathan #define	EMLXS_MODREV5    5	/* New Sun NPIV Interface */
40fcf3ce44SJohn Forte 
41291a2b48SSukumar Swaminathan #define	EMLXS_MODREV2X   2	/* Old Solaris 8 & 9 x86 interface */
42291a2b48SSukumar Swaminathan #define	EMLXS_MODREV3X   3	/* New Solaris 10 & 11 x86 interface */
43fcf3ce44SJohn Forte 
44fcf3ce44SJohn Forte 
45fcf3ce44SJohn Forte /*
46291a2b48SSukumar Swaminathan  * DRIVER LEVEL FEATURES
47fcf3ce44SJohn Forte  */
48fcf3ce44SJohn Forte #define	DFC_SUPPORT		/* 2.20 driver */
49fcf3ce44SJohn Forte #define	DHCHAP_SUPPORT		/* 2.21 driver */
50fcf3ce44SJohn Forte 
51fcf3ce44SJohn Forte #define	SATURN_MSI_SUPPORT	/* 2.30 driver */
52fcf3ce44SJohn Forte 
53fcf3ce44SJohn Forte #define	MENLO_SUPPORT		/* 2.30 driver */
54fcf3ce44SJohn Forte 
55fcf3ce44SJohn Forte #define	MBOX_EXT_SUPPORT	/* 2.30 driver */
56fcf3ce44SJohn Forte #define	SLI3_SUPPORT		/* 2.30 driver - Required for NPIV */
57fcf3ce44SJohn Forte 
58291a2b48SSukumar Swaminathan #define	DUMP_SUPPORT		/* 2.40 driver */
59291a2b48SSukumar Swaminathan #define	SAN_DIAG_SUPPORT	/* 2.40 driver */
60*bb63f56eSSukumar Swaminathan /* #define	FMA_SUPPORT	2.40 driver - Not yet */
61fcf3ce44SJohn Forte 
62291a2b48SSukumar Swaminathan /* #define	IDLE_TIMER	 Not yet - untested */
63fcf3ce44SJohn Forte 
64fcf3ce44SJohn Forte /*
65291a2b48SSukumar Swaminathan  * OS LEVEL FEATURES
66fcf3ce44SJohn Forte  */
67fcf3ce44SJohn Forte #ifdef S10
68291a2b48SSukumar Swaminathan #define	 EMLXS_MODREV EMLXS_MODREV3
69291a2b48SSukumar Swaminathan #define	 MSI_SUPPORT
70fcf3ce44SJohn Forte 
71fcf3ce44SJohn Forte #ifdef SLI3_SUPPORT
72fcf3ce44SJohn Forte #define	NPIV_SUPPORT
73fcf3ce44SJohn Forte #endif	/* SLI3_SUPPORT */
74fcf3ce44SJohn Forte 
75fcf3ce44SJohn Forte #ifdef EMLXS_I386
76291a2b48SSukumar Swaminathan #define	 EMLXS_MODREVX EMLXS_MODREV2X
77fcf3ce44SJohn Forte #endif	/* EMLXS_I386 */
78fcf3ce44SJohn Forte #endif	/* S10 */
79fcf3ce44SJohn Forte 
80fcf3ce44SJohn Forte 
81fcf3ce44SJohn Forte #ifdef S11
82fcf3ce44SJohn Forte #define	MSI_SUPPORT
83291a2b48SSukumar Swaminathan #define	SFCT_SUPPORT  /* COMSTAR Support */
84291a2b48SSukumar Swaminathan #define	MODFW_SUPPORT /* Dynamic firmware module support */
85fcf3ce44SJohn Forte 
86fcf3ce44SJohn Forte #ifdef SLI3_SUPPORT
87fcf3ce44SJohn Forte #define	NPIV_SUPPORT
88fcf3ce44SJohn Forte 
89fcf3ce44SJohn Forte #ifdef NPIV_SUPPORT
90291a2b48SSukumar Swaminathan #define	SUN_NPIV_SUPPORT  /* Nevada Build 92+ */
91291a2b48SSukumar Swaminathan #endif /* NPIV_SUPPORT */
92fcf3ce44SJohn Forte #endif	/* SLI3_SUPPORT */
93fcf3ce44SJohn Forte 
94fcf3ce44SJohn Forte #ifdef SUN_NPIV_SUPPORT
95291a2b48SSukumar Swaminathan #define	 EMLXS_MODREV EMLXS_MODREV5		/* Sun NPIV Enhancement */
96fcf3ce44SJohn Forte #else
97291a2b48SSukumar Swaminathan define	EMLXS_MODREV	EMLXS_MODREV4
98291a2b48SSukumar Swaminathan #endif /* SUN_NPIV_SUPPORT */
99fcf3ce44SJohn Forte 
100fcf3ce44SJohn Forte #ifdef EMLXS_I386
101291a2b48SSukumar Swaminathan #define	 EMLXS_MODREVX EMLXS_MODREV2X
102fcf3ce44SJohn Forte #endif	/* EMLXS_I386 */
103fcf3ce44SJohn Forte #endif	/* S11 */
104fcf3ce44SJohn Forte 
105fcf3ce44SJohn Forte /*
106291a2b48SSukumar Swaminathan  * SUBFEATURES
107fcf3ce44SJohn Forte  */
108fcf3ce44SJohn Forte #ifdef SFCT_SUPPORT
109291a2b48SSukumar Swaminathan #define	MODSYM_SUPPORT		/* Dynamic Module Loading Support */
110291a2b48SSukumar Swaminathan #define	FCIO_SUPPORT		/* FCIO IOCTL support */
111291a2b48SSukumar Swaminathan #endif /* SFCT_SUPPORT */
112fcf3ce44SJohn Forte 
113fcf3ce44SJohn Forte 
114fcf3ce44SJohn Forte #ifndef EMLXS_MODREV
115fcf3ce44SJohn Forte #define	EMLXS_MODREV			0
116291a2b48SSukumar Swaminathan #endif /* EMLXS_MODREV */
117fcf3ce44SJohn Forte 
118fcf3ce44SJohn Forte #ifndef EMLXS_MODREVX
119fcf3ce44SJohn Forte #define	EMLXS_MODREVX			0
120291a2b48SSukumar Swaminathan #endif /* EMLXS_MODREVX */
121fcf3ce44SJohn Forte 
122fcf3ce44SJohn Forte /* Create combined definition */
123fcf3ce44SJohn Forte #if defined(S10) || defined(S11)
124fcf3ce44SJohn Forte #define	S10S11
125291a2b48SSukumar Swaminathan #endif /* S10 or S11 */
126fcf3ce44SJohn Forte 
127291a2b48SSukumar Swaminathan #define	DRIVER_NAME   "emlxs"
128fcf3ce44SJohn Forte 
129fcf3ce44SJohn Forte #include <sys/types.h>
130fcf3ce44SJohn Forte #include <sys/varargs.h>
131fcf3ce44SJohn Forte #include <sys/devops.h>
132fcf3ce44SJohn Forte #include <sys/param.h>
133fcf3ce44SJohn Forte #include <sys/user.h>
134fcf3ce44SJohn Forte #include <sys/buf.h>
135fcf3ce44SJohn Forte #include <sys/ioctl.h>
136fcf3ce44SJohn Forte #include <sys/uio.h>
137fcf3ce44SJohn Forte #include <sys/fcntl.h>
138fcf3ce44SJohn Forte 
139fcf3ce44SJohn Forte #include <sys/cmn_err.h>
140fcf3ce44SJohn Forte #include <sys/stropts.h>
141fcf3ce44SJohn Forte #include <sys/kmem.h>
142fcf3ce44SJohn Forte 
143fcf3ce44SJohn Forte #include <sys/errno.h>
144fcf3ce44SJohn Forte #include <sys/open.h>
145fcf3ce44SJohn Forte #include <sys/kmem.h>
146fcf3ce44SJohn Forte #include <sys/poll.h>
147fcf3ce44SJohn Forte #include <sys/thread.h>
148fcf3ce44SJohn Forte #include <sys/taskq.h>
149fcf3ce44SJohn Forte #include <sys/debug.h>
150fcf3ce44SJohn Forte #include <sys/cpu.h>
151fcf3ce44SJohn Forte #include <sys/autoconf.h>
152fcf3ce44SJohn Forte #include <sys/conf.h>
153fcf3ce44SJohn Forte #include <sys/stat.h>
154fcf3ce44SJohn Forte #include <sys/var.h>
155fcf3ce44SJohn Forte 
156fcf3ce44SJohn Forte #include <sys/map.h>
157fcf3ce44SJohn Forte #include <sys/file.h>
158fcf3ce44SJohn Forte #include <sys/syslog.h>
159fcf3ce44SJohn Forte #include <sys/disp.h>
160fcf3ce44SJohn Forte #include <sys/taskq.h>
161fcf3ce44SJohn Forte 
162fcf3ce44SJohn Forte #include <sys/ddi.h>
163fcf3ce44SJohn Forte #include <sys/sunddi.h>
164fcf3ce44SJohn Forte #include <sys/promif.h>
165fcf3ce44SJohn Forte #include <sys/ethernet.h>
166fcf3ce44SJohn Forte #include <vm/seg_kmem.h>
167fcf3ce44SJohn Forte #include <sys/utsname.h>
168fcf3ce44SJohn Forte #include <sys/modctl.h>
169fcf3ce44SJohn Forte #include <sys/scsi/scsi.h>
170fcf3ce44SJohn Forte #include <sys/varargs.h>
171fcf3ce44SJohn Forte #include <sys/atomic.h>
172fcf3ce44SJohn Forte 
173fcf3ce44SJohn Forte #include <emlxs_hbaapi.h>
174fcf3ce44SJohn Forte 
175291a2b48SSukumar Swaminathan #ifdef FMA_SUPPORT
176291a2b48SSukumar Swaminathan #include <sys/ddifm.h>
177291a2b48SSukumar Swaminathan #include <sys/fm/protocol.h>
178291a2b48SSukumar Swaminathan #include <sys/fm/util.h>
179291a2b48SSukumar Swaminathan #endif	/* FMA_SUPPORT */
180291a2b48SSukumar Swaminathan #include <sys/fm/io/ddi.h>
181fcf3ce44SJohn Forte 
182fcf3ce44SJohn Forte #ifdef S11
183fcf3ce44SJohn Forte 
184fcf3ce44SJohn Forte /* ULP header files */
185fcf3ce44SJohn Forte #include <sys/fibre-channel/fc.h>
186fcf3ce44SJohn Forte #include <sys/fibre-channel/impl/fc_fcaif.h>
187fcf3ce44SJohn Forte 
188fcf3ce44SJohn Forte #else	/* !S11 */
189fcf3ce44SJohn Forte 
190fcf3ce44SJohn Forte /* ULP header files */
191fcf3ce44SJohn Forte #include <sys/fibre-channel/fcio.h>
192fcf3ce44SJohn Forte #include <sys/fibre-channel/fc.h>
193fcf3ce44SJohn Forte #include <sys/fibre-channel/fc_appif.h>
194fcf3ce44SJohn Forte #include <sys/fibre-channel/fc_types.h>
195fcf3ce44SJohn Forte #include <sys/fibre-channel/impl/fc_error.h>
196fcf3ce44SJohn Forte #include <sys/fibre-channel/impl/fc_fla.h>
197fcf3ce44SJohn Forte #include <sys/fibre-channel/impl/fc_linkapp.h>
198fcf3ce44SJohn Forte #include <sys/fibre-channel/impl/fcal.h>
199fcf3ce44SJohn Forte #include <sys/fibre-channel/impl/fcgs2.h>
200fcf3ce44SJohn Forte #include <sys/fibre-channel/impl/fcph.h>
201fcf3ce44SJohn Forte #include <sys/fibre-channel/impl/fc_ulpif.h>
202fcf3ce44SJohn Forte #include <sys/fibre-channel/impl/fc_fcaif.h>
203fcf3ce44SJohn Forte #include <sys/fibre-channel/impl/fctl.h>
204fcf3ce44SJohn Forte #include <sys/fibre-channel/impl/fctl_private.h>
205fcf3ce44SJohn Forte #include <sys/fibre-channel/ulp/fcp.h>
206fcf3ce44SJohn Forte #include <sys/fibre-channel/ulp/fcp_util.h>
207fcf3ce44SJohn Forte 
208fcf3ce44SJohn Forte #endif	/* S11 */
209fcf3ce44SJohn Forte 
210fcf3ce44SJohn Forte #ifndef FC_HBA_PORTSPEED_8GBIT
211fcf3ce44SJohn Forte #define	FC_HBA_PORTSPEED_8GBIT		16
212fcf3ce44SJohn Forte #endif	/* FC_HBA_PORTSPEED_8GBIT */
213fcf3ce44SJohn Forte 
214fcf3ce44SJohn Forte #ifndef FP_DEFAULT_SID
215fcf3ce44SJohn Forte #define	FP_DEFAULT_SID		(0x000AE)
216fcf3ce44SJohn Forte #endif	/* FP_DEFAULT_SID */
217fcf3ce44SJohn Forte 
218fcf3ce44SJohn Forte #ifndef FP_DEFAULT_DID
219fcf3ce44SJohn Forte #define	FP_DEFAULT_DID		(0x000EA)
220fcf3ce44SJohn Forte #endif	/* FP_DEFAULT_DID */
221fcf3ce44SJohn Forte 
222fcf3ce44SJohn Forte #ifdef MSI_SUPPORT
223fcf3ce44SJohn Forte #pragma weak ddi_intr_get_supported_types
224fcf3ce44SJohn Forte #pragma weak ddi_intr_get_nintrs
225fcf3ce44SJohn Forte #pragma weak ddi_intr_add_handler
226fcf3ce44SJohn Forte #pragma weak ddi_intr_remove_handler
227fcf3ce44SJohn Forte #pragma weak ddi_intr_get_hilevel_pri
228fcf3ce44SJohn Forte #pragma weak ddi_intr_enable
229fcf3ce44SJohn Forte #pragma weak ddi_intr_disable
230fcf3ce44SJohn Forte #pragma weak ddi_intr_get_cap
231fcf3ce44SJohn Forte #pragma weak ddi_intr_get_pri
232fcf3ce44SJohn Forte #pragma weak ddi_intr_alloc
233fcf3ce44SJohn Forte #pragma weak ddi_intr_free
234fcf3ce44SJohn Forte #pragma weak ddi_intr_block_enable
235fcf3ce44SJohn Forte #pragma weak ddi_intr_block_disable
236fcf3ce44SJohn Forte extern int ddi_intr_get_supported_types();
237fcf3ce44SJohn Forte #endif	/* MSI_SUPPORT */
238fcf3ce44SJohn Forte 
239fcf3ce44SJohn Forte #ifndef MODSYM_SUPPORT
240fcf3ce44SJohn Forte #pragma weak fc_fca_init
241fcf3ce44SJohn Forte #pragma weak fc_fca_attach
242fcf3ce44SJohn Forte #pragma weak fc_fca_detach
243291a2b48SSukumar Swaminathan #endif /* MODSYM_SUPPORT */
244fcf3ce44SJohn Forte 
245fcf3ce44SJohn Forte /* S11 flag for dma_attr_flags for ddi_dma_attr_t */
246fcf3ce44SJohn Forte #ifndef DDI_DMA_RELAXED_ORDERING
247fcf3ce44SJohn Forte #define	DDI_DMA_RELAXED_ORDERING	0x400
248fcf3ce44SJohn Forte #endif	/* DDI_DMA_RELAXED_ORDERING */
249fcf3ce44SJohn Forte 
250291a2b48SSukumar Swaminathan #ifdef FMA_SUPPORT
251291a2b48SSukumar Swaminathan /* FMA Support */
252291a2b48SSukumar Swaminathan #pragma weak ddi_fm_acc_err_clear
253*bb63f56eSSukumar Swaminathan extern void ddi_fm_acc_err_clear();
254291a2b48SSukumar Swaminathan #endif	/* FMA_SUPPORT */
255fcf3ce44SJohn Forte 
256fcf3ce44SJohn Forte #ifdef EMLXS_SPARC
257fcf3ce44SJohn Forte #define	EMLXS_BIG_ENDIAN
258fcf3ce44SJohn Forte #endif	/* EMLXS_SPARC */
259fcf3ce44SJohn Forte 
260fcf3ce44SJohn Forte #ifdef EMLXS_I386
261fcf3ce44SJohn Forte #define	EMLXS_LITTLE_ENDIAN
262fcf3ce44SJohn Forte #endif	/* EMLXS_I386 */
263fcf3ce44SJohn Forte 
264fcf3ce44SJohn Forte 
265fcf3ce44SJohn Forte /* Solaris 8 does not define this */
266fcf3ce44SJohn Forte #ifndef TASKQ_DYNAMIC
267291a2b48SSukumar Swaminathan #define	TASKQ_DYNAMIC	0x0004
268fcf3ce44SJohn Forte #endif	/* TASKQ_DYNAMIC */
269fcf3ce44SJohn Forte 
270fcf3ce44SJohn Forte #ifdef _LP64
271291a2b48SSukumar Swaminathan #define	DEAD_PTR   0xdeadbeefdeadbeef
272fcf3ce44SJohn Forte #else
273291a2b48SSukumar Swaminathan #define	DEAD_PTR   0xdeadbeef
274fcf3ce44SJohn Forte #endif	/* _LP64 */
275fcf3ce44SJohn Forte 
276fcf3ce44SJohn Forte #ifndef FC_STATE_8GBIT_SPEED
277fcf3ce44SJohn Forte /* This was obtained from OpenSolaris */
278fcf3ce44SJohn Forte #define	FC_STATE_8GBIT_SPEED		0x0700	/* 8 Gbit/sec */
279fcf3ce44SJohn Forte #endif	/* FC_STATE_8GBIT_SPEED */
280fcf3ce44SJohn Forte 
281fcf3ce44SJohn Forte #define	FC_STATE_QUAD_SPEED		0x0500
282fcf3ce44SJohn Forte 
283fcf3ce44SJohn Forte #ifndef BURSTSIZE
284fcf3ce44SJohn Forte #define	BURSTSIZE
285291a2b48SSukumar Swaminathan #define	BURST1			0x01
286291a2b48SSukumar Swaminathan #define	BURST2			0x02
287291a2b48SSukumar Swaminathan #define	BURST4			0x04
288291a2b48SSukumar Swaminathan #define	BURST8			0x08
289291a2b48SSukumar Swaminathan #define	BURST16			0x10
290291a2b48SSukumar Swaminathan #define	BURST32			0x20
291291a2b48SSukumar Swaminathan #define	BURST64			0x40
292fcf3ce44SJohn Forte #ifdef _LP64
293291a2b48SSukumar Swaminathan #define	BURSTSIZE_MASK		0x7f
294fcf3ce44SJohn Forte #else
295291a2b48SSukumar Swaminathan #define	BURSTSIZE_MASK		0x3f
296fcf3ce44SJohn Forte #endif	/* _LP64 */
297fcf3ce44SJohn Forte #define	DEFAULT_BURSTSIZE	(BURSTSIZE_MASK)	/* all burst sizes */
298fcf3ce44SJohn Forte #endif	/* BURSTSIZE */
299fcf3ce44SJohn Forte 
300291a2b48SSukumar Swaminathan #define	putPaddrLow(addr)	((uint32_t)(((unsigned long)(addr)) \
301291a2b48SSukumar Swaminathan 					& 0xffffffff))
302291a2b48SSukumar Swaminathan #define	putPaddrHigh(addr)	((uint32_t)(((uint64_t)(unsigned long)(addr))  \
303291a2b48SSukumar Swaminathan 					>> 32))
304291a2b48SSukumar Swaminathan #define	getPaddr(high, low)	((uint64_t)((((uint64_t)(high)) << 32) \
305291a2b48SSukumar Swaminathan 					| (((uint64_t)(low)) & 0xffffffff)))
306fcf3ce44SJohn Forte 
307fcf3ce44SJohn Forte #ifndef TRUE
308fcf3ce44SJohn Forte #define	TRUE	1
309fcf3ce44SJohn Forte #endif	/* TRUE */
310fcf3ce44SJohn Forte 
311fcf3ce44SJohn Forte #ifndef FALSE
312fcf3ce44SJohn Forte #define	FALSE	0
313fcf3ce44SJohn Forte #endif	/* FALSE */
314fcf3ce44SJohn Forte 
315291a2b48SSukumar Swaminathan #define	DMA_READ_WRITE		0
316291a2b48SSukumar Swaminathan #define	DMA_READ_ONLY		1
317291a2b48SSukumar Swaminathan #define	DMA_WRITE_ONLY		2
318fcf3ce44SJohn Forte 
319291a2b48SSukumar Swaminathan #define	DMA_SUCC		1
320fcf3ce44SJohn Forte 
321291a2b48SSukumar Swaminathan #define	MAX_FC_BRDS		256	/* Maximum # boards per system */
322fcf3ce44SJohn Forte 
323fcf3ce44SJohn Forte #define	DELAYMS(ms)		drv_usecwait((ms*1000))
324fcf3ce44SJohn Forte #define	DELAYUS(us)		drv_usecwait(us)
325fcf3ce44SJohn Forte 
326291a2b48SSukumar Swaminathan #ifdef FMA_SUPPORT
327291a2b48SSukumar Swaminathan #define	emlxs_mpdata_sync(h, a, b, c)  \
328291a2b48SSukumar Swaminathan 	if (h)  { \
329291a2b48SSukumar Swaminathan 		(void) ddi_dma_sync((ddi_dma_handle_t)(h), \
330291a2b48SSukumar Swaminathan 			(off_t)(a), (size_t)(b), (uint_t)c); \
331*bb63f56eSSukumar Swaminathan 		if (emlxs_fm_check_dma_handle(hba, h) != DDI_FM_OK) { \
332*bb63f56eSSukumar Swaminathan 			EMLXS_MSGF(EMLXS_CONTEXT, \
333*bb63f56eSSukumar Swaminathan 			    &emlxs_invalid_dma_handle_msg, \
334*bb63f56eSSukumar Swaminathan 			    "ddi_dma_sync hdl=%p off=%x " \
335*bb63f56eSSukumar Swaminathan 			    "size=%d dir=%x ", \
336*bb63f56eSSukumar Swaminathan 			    h, a, b, c); \
337291a2b48SSukumar Swaminathan 		} \
338291a2b48SSukumar Swaminathan 	}
339291a2b48SSukumar Swaminathan #else	/* !FMA_SUPPORT */
340291a2b48SSukumar Swaminathan #define	emlxs_mpdata_sync(h, a, b, c)  \
341291a2b48SSukumar Swaminathan 	if (h)  { \
342291a2b48SSukumar Swaminathan 		(void) ddi_dma_sync((ddi_dma_handle_t)(h), \
343291a2b48SSukumar Swaminathan 			(off_t)(a), (size_t)(b), (uint_t)c); \
344fcf3ce44SJohn Forte 	}
345291a2b48SSukumar Swaminathan #endif	/* FMA_SUPPORT */
346fcf3ce44SJohn Forte 
347fcf3ce44SJohn Forte 
348fcf3ce44SJohn Forte 
349fcf3ce44SJohn Forte #define	PKT2PRIV(pkt)		((emlxs_buf_t *)(pkt)->pkt_fca_private)
350fcf3ce44SJohn Forte #define	PRIV2PKT(sbp)		sbp->pkt
351fcf3ce44SJohn Forte 
352fcf3ce44SJohn Forte #define	EMLXS_INUMBER		0
353fcf3ce44SJohn Forte #define	EMLXS_MSI_INUMBER 	0
354fcf3ce44SJohn Forte 
355fcf3ce44SJohn Forte #define	EMLXS_DMA_ALIGN		BURST16
356fcf3ce44SJohn Forte 
357fcf3ce44SJohn Forte /*
358291a2b48SSukumar Swaminathan  * Register indices in PCI configuration space.
359fcf3ce44SJohn Forte  */
360291a2b48SSukumar Swaminathan #define	SBUS_FLASH_RD			0	/* FCODE-Flash Read only */
361291a2b48SSukumar Swaminathan 						/* index */
362291a2b48SSukumar Swaminathan #define	SBUS_FLASH_RDWR			1	/* FCODE-Flash Read/Write */
363291a2b48SSukumar Swaminathan 						/* index */
364291a2b48SSukumar Swaminathan #define	SBUS_DFLY_SLIM_RINDEX	  2	/* DragonFly SLIM regs index */
365291a2b48SSukumar Swaminathan #define	SBUS_DFLY_CSR_RINDEX	  3	/* DragonFly I/O regs index */
366291a2b48SSukumar Swaminathan #define	SBUS_TITAN_CORE_RINDEX	  4	/* TITAN Core register index */
367291a2b48SSukumar Swaminathan #define	SBUS_DFLY_PCI_CFG_RINDEX	5	/* DragonFly PCI ConfigSpace */
368291a2b48SSukumar Swaminathan 						/* regs index */
369291a2b48SSukumar Swaminathan #define	SBUS_TITAN_PCI_CFG_RINDEX	6	/* TITAN PCI ConfigSpace regs */
370291a2b48SSukumar Swaminathan 						/* index */
371291a2b48SSukumar Swaminathan #define	SBUS_TITAN_CSR_RINDEX		7	/* TITAN Control/Status regs */
372291a2b48SSukumar Swaminathan 						/* index */
373291a2b48SSukumar Swaminathan 
374291a2b48SSukumar Swaminathan #define	PCI_CFG_RINDEX		  0
375291a2b48SSukumar Swaminathan #define	PCI_SLIM_RINDEX		  1
376291a2b48SSukumar Swaminathan #define	PCI_CSR_RINDEX		  2
377fcf3ce44SJohn Forte 
378fcf3ce44SJohn Forte #define	EMLXS_MAX_UBUFS		65535
379fcf3ce44SJohn Forte 
380fcf3ce44SJohn Forte /* Tokens < EMLXS_UB_TOKEN_OFFSET are reserved for ELS response oxids */
381291a2b48SSukumar Swaminathan #define	EMLXS_UB_TOKEN_OFFSET	0x100
382fcf3ce44SJohn Forte 
383291a2b48SSukumar Swaminathan typedef struct emlxs_ub_priv
384291a2b48SSukumar Swaminathan {
385291a2b48SSukumar Swaminathan 	fc_unsol_buf_t	*ubp;
386291a2b48SSukumar Swaminathan 	void		*port;
387fcf3ce44SJohn Forte 
388291a2b48SSukumar Swaminathan 	uint32_t	bpl_size;
389291a2b48SSukumar Swaminathan 	uint8_t		*bpl_virt;	/* virtual address ptr */
390291a2b48SSukumar Swaminathan 	uint64_t	bpl_phys;	/* mapped address */
391291a2b48SSukumar Swaminathan 	void		*bpl_data_handle;
392291a2b48SSukumar Swaminathan 	void		*bpl_dma_handle;
393fcf3ce44SJohn Forte 
394291a2b48SSukumar Swaminathan 	uint32_t	ip_ub_size;
395291a2b48SSukumar Swaminathan 	uint8_t		*ip_ub_virt;	/* virtual address ptr */
396fcf3ce44SJohn Forte 	ddi_dma_cookie_t ip_ub_dma_cookies[64];
397fcf3ce44SJohn Forte 	ddi_acc_handle_t ip_ub_data_handle;
398fcf3ce44SJohn Forte 	ddi_dma_handle_t ip_ub_dma_handle;
399291a2b48SSukumar Swaminathan 	uint32_t	ip_ub_cookie_cnt;
400291a2b48SSukumar Swaminathan 	uint32_t	FC4type;
401fcf3ce44SJohn Forte 
402291a2b48SSukumar Swaminathan 	uint16_t	flags;
403fcf3ce44SJohn Forte #define	EMLXS_UB_FREE		0x0000
404fcf3ce44SJohn Forte #define	EMLXS_UB_IN_USE		0x0001
405fcf3ce44SJohn Forte #define	EMLXS_UB_REPLY		0x0002
406fcf3ce44SJohn Forte #define	EMLXS_UB_RESV		0x0004
407fcf3ce44SJohn Forte #define	EMLXS_UB_TIMEOUT	0x0008
408fcf3ce44SJohn Forte #define	EMLXS_UB_INTERCEPT	0x0010
409fcf3ce44SJohn Forte 
410291a2b48SSukumar Swaminathan 	uint16_t	available;
411fcf3ce44SJohn Forte 
412291a2b48SSukumar Swaminathan 	uint32_t	timeout;	/* Timeout period in seconds */
413291a2b48SSukumar Swaminathan 	uint32_t	time;	/* EMLXS_UB_IN_USE timestamp */
414291a2b48SSukumar Swaminathan 	uint32_t	cmd;
415291a2b48SSukumar Swaminathan 	uint32_t	token;
416fcf3ce44SJohn Forte 
417fcf3ce44SJohn Forte 	struct emlxs_unsol_buf *pool;
418fcf3ce44SJohn Forte 	struct emlxs_ub_priv *next;
419fcf3ce44SJohn Forte } emlxs_ub_priv_t;
420fcf3ce44SJohn Forte 
421fcf3ce44SJohn Forte 
422291a2b48SSukumar Swaminathan typedef struct emlxs_unsol_buf
423291a2b48SSukumar Swaminathan {
424291a2b48SSukumar Swaminathan 	struct emlxs_unsol_buf	*pool_prev;		/* ptr to prev type */
425291a2b48SSukumar Swaminathan 							/* of unsol_buf hdr */
426291a2b48SSukumar Swaminathan 	struct emlxs_unsol_buf	*pool_next;		/* ptr to next type */
427291a2b48SSukumar Swaminathan 							/* of unsol_buf hdr */
428fcf3ce44SJohn Forte 
429291a2b48SSukumar Swaminathan 	uint32_t		pool_type;		/* FC-4 type */
430291a2b48SSukumar Swaminathan 	uint32_t		pool_buf_size;		/* buffer size for */
431291a2b48SSukumar Swaminathan 							/* this pool */
432fcf3ce44SJohn Forte 
433291a2b48SSukumar Swaminathan 	uint32_t		pool_nentries;		/* no. of bufs in */
434291a2b48SSukumar Swaminathan 							/* pool */
435291a2b48SSukumar Swaminathan 	uint32_t		pool_available;		/* no. of bufs avail */
436291a2b48SSukumar Swaminathan 							/* in pool */
437fcf3ce44SJohn Forte 
438291a2b48SSukumar Swaminathan 	uint32_t		pool_flags;
439291a2b48SSukumar Swaminathan #define	POOL_DESTROY		0x00000001		/* Pool is marked for */
440291a2b48SSukumar Swaminathan 							/* destruction */
441fcf3ce44SJohn Forte 
442291a2b48SSukumar Swaminathan 	uint32_t		pool_free;		/* Number of free */
443291a2b48SSukumar Swaminathan 							/* buffers */
444291a2b48SSukumar Swaminathan 	uint32_t		pool_free_resv;		/* Number of free */
445291a2b48SSukumar Swaminathan 							/* reserved buffers */
446fcf3ce44SJohn Forte 
447291a2b48SSukumar Swaminathan 	uint32_t		pool_first_token;	/* First token */
448291a2b48SSukumar Swaminathan 							/* in pool */
449291a2b48SSukumar Swaminathan 	uint32_t		pool_last_token;	/* Last token */
450291a2b48SSukumar Swaminathan 							/* in pool */
451fcf3ce44SJohn Forte 
452291a2b48SSukumar Swaminathan 	fc_unsol_buf_t		*fc_ubufs;		/* array of unsol buf */
453291a2b48SSukumar Swaminathan 							/* structs */
454fcf3ce44SJohn Forte } emlxs_unsol_buf_t;
455fcf3ce44SJohn Forte 
456fcf3ce44SJohn Forte 
457fcf3ce44SJohn Forte #ifndef FC_REASON_NONE
458fcf3ce44SJohn Forte #define	FC_REASON_NONE			0
459291a2b48SSukumar Swaminathan #endif /* FC_REASON_NONE */
460fcf3ce44SJohn Forte 
461fcf3ce44SJohn Forte #ifndef FC_ACTION_NONE
462fcf3ce44SJohn Forte #define	FC_ACTION_NONE			0
463291a2b48SSukumar Swaminathan #endif /* FC_ACTION_NONE */
464fcf3ce44SJohn Forte 
465fcf3ce44SJohn Forte /*
466fcf3ce44SJohn Forte  * emlx status translation table
467fcf3ce44SJohn Forte  */
468291a2b48SSukumar Swaminathan typedef struct emlxs_xlat_err
469291a2b48SSukumar Swaminathan {
470291a2b48SSukumar Swaminathan 	uint32_t	emlxs_status;
471291a2b48SSukumar Swaminathan 	uint32_t	pkt_state;
472291a2b48SSukumar Swaminathan 	uint32_t	pkt_reason;
473291a2b48SSukumar Swaminathan 	uint32_t	pkt_expln;
474291a2b48SSukumar Swaminathan 	uint32_t	pkt_action;
475fcf3ce44SJohn Forte } emlxs_xlat_err_t;
476fcf3ce44SJohn Forte 
477fcf3ce44SJohn Forte 
478291a2b48SSukumar Swaminathan typedef struct emlxs_table
479291a2b48SSukumar Swaminathan {
480291a2b48SSukumar Swaminathan 	uint32_t	code;
481291a2b48SSukumar Swaminathan 	char		string[32];
482fcf3ce44SJohn Forte } emlxs_table_t;
483fcf3ce44SJohn Forte 
484fcf3ce44SJohn Forte #ifdef	__cplusplus
485fcf3ce44SJohn Forte }
486fcf3ce44SJohn Forte #endif
487fcf3ce44SJohn Forte 
488fcf3ce44SJohn Forte #endif	/* _EMLXS_OS_H */
489