1fcf3ce4John Forte/*
2fcf3ce4John Forte * CDDL HEADER START
3fcf3ce4John Forte *
4fcf3ce4John Forte * The contents of this file are subject to the terms of the
5fcf3ce4John Forte * Common Development and Distribution License (the "License").
6fcf3ce4John Forte * You may not use this file except in compliance with the License.
7fcf3ce4John Forte *
88f23e9fHans Rosenfeld * You can obtain a copy of the license at
98f23e9fHans Rosenfeld * http://www.opensource.org/licenses/cddl1.txt.
10fcf3ce4John Forte * See the License for the specific language governing permissions
11fcf3ce4John Forte * and limitations under the License.
12fcf3ce4John Forte *
13fcf3ce4John Forte * When distributing Covered Code, include this CDDL HEADER in each
14fcf3ce4John Forte * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15fcf3ce4John Forte * If applicable, add the following below this CDDL HEADER, with the
16fcf3ce4John Forte * fields enclosed by brackets "[]" replaced with your own identifying
17fcf3ce4John Forte * information: Portions Copyright [yyyy] [name of copyright owner]
18fcf3ce4John Forte *
19fcf3ce4John Forte * CDDL HEADER END
20fcf3ce4John Forte */
21fcf3ce4John Forte
22fcf3ce4John Forte/*
238f23e9fHans Rosenfeld * Copyright (c) 2004-2011 Emulex. All rights reserved.
248252773Sukumar Swaminathan * Use is subject to license terms.
25fcf3ce4John Forte */
26fcf3ce4John Forte
27fcf3ce4John Forte#ifndef _EMLXS_OS_H
28fcf3ce4John Forte#define	_EMLXS_OS_H
29fcf3ce4John Forte
30fcf3ce4John Forte#ifdef	__cplusplus
31fcf3ce4John Forteextern "C" {
32fcf3ce4John Forte#endif
33fcf3ce4John Forte
34291a2b4Sukumar Swaminathan#define	EMLXS_MODREV2    2	/* Old Solaris 8 & 9 interface */
35291a2b4Sukumar Swaminathan#define	EMLXS_MODREV3    3	/* New Solaris 10 & 11 interface */
36291a2b4Sukumar Swaminathan#define	EMLXS_MODREV4    4	/* Sun FC packet change */
37291a2b4Sukumar Swaminathan				/* Symbolic Node Name interface */
38291a2b4Sukumar Swaminathan#define	EMLXS_MODREV5    5	/* New Sun NPIV Interface */
39fcf3ce4John Forte
40291a2b4Sukumar Swaminathan#define	EMLXS_MODREV2X   2	/* Old Solaris 8 & 9 x86 interface */
41291a2b4Sukumar Swaminathan#define	EMLXS_MODREV3X   3	/* New Solaris 10 & 11 x86 interface */
42fcf3ce4John Forte
43fcf3ce4John Forte
44fcf3ce4John Forte/*
45291a2b4Sukumar Swaminathan * DRIVER LEVEL FEATURES
46fcf3ce4John Forte */
47fcf3ce4John Forte#define	DHCHAP_SUPPORT		/* 2.21 driver */
48fcf3ce4John Forte
49fcf3ce4John Forte#define	SATURN_MSI_SUPPORT	/* 2.30 driver */
50fcf3ce4John Forte#define	MENLO_SUPPORT		/* 2.30 driver */
51fcf3ce4John Forte#define	MBOX_EXT_SUPPORT	/* 2.30 driver */
52fcf3ce4John Forte
53291a2b4Sukumar Swaminathan#define	DUMP_SUPPORT		/* 2.40 driver */
54291a2b4Sukumar Swaminathan#define	SAN_DIAG_SUPPORT	/* 2.40 driver */
554baa2c2Sukumar Swaminathan#define	FMA_SUPPORT		/* 2.40 driver */
56fcf3ce4John Forte
578f23e9fHans Rosenfeld#define	NODE_THROTTLE_SUPPORT	/* 2.70 driver */
588f23e9fHans Rosenfeld
59291a2b4Sukumar Swaminathan/* #define	IDLE_TIMER	 Not yet - untested */
60fcf3ce4John Forte
61fcf3ce4John Forte/*
62291a2b4Sukumar Swaminathan * OS LEVEL FEATURES
63fcf3ce4John Forte */
64fcf3ce4John Forte
65fcf3ce4John Forte
66fcf3ce4John Forte#ifdef S11
67fcf3ce4John Forte#define	MSI_SUPPORT
68291a2b4Sukumar Swaminathan#define	SFCT_SUPPORT  /* COMSTAR Support */
69291a2b4Sukumar Swaminathan#define	MODFW_SUPPORT /* Dynamic firmware module support */
708f23e9fHans Rosenfeld#define	EMLXS_MODREV EMLXS_MODREV5 /* Sun NPIV Enhancement */
71fcf3ce4John Forte
72fcf3ce4John Forte#ifdef EMLXS_I386
738252773Sukumar Swaminathan#define	EMLXS_MODREVX EMLXS_MODREV2X
748f23e9fHans Rosenfeld#endif /* i386 */
758f23e9fHans Rosenfeld#endif /* S11 */
76fcf3ce4John Forte
77fcf3ce4John Forte/*
78291a2b4Sukumar Swaminathan * SUBFEATURES
79fcf3ce4John Forte */
80fcf3ce4John Forte#ifdef SFCT_SUPPORT
81291a2b4Sukumar Swaminathan#define	MODSYM_SUPPORT		/* Dynamic Module Loading Support */
82291a2b4Sukumar Swaminathan#define	FCIO_SUPPORT		/* FCIO IOCTL support */
83291a2b4Sukumar Swaminathan#endif /* SFCT_SUPPORT */
84fcf3ce4John Forte
85fcf3ce4John Forte
86fcf3ce4John Forte#ifndef EMLXS_MODREV
87fcf3ce4John Forte#define	EMLXS_MODREV			0
88291a2b4Sukumar Swaminathan#endif /* EMLXS_MODREV */
89fcf3ce4John Forte
90fcf3ce4John Forte#ifndef EMLXS_MODREVX
91fcf3ce4John Forte#define	EMLXS_MODREVX			0
92291a2b4Sukumar Swaminathan#endif /* EMLXS_MODREVX */
93fcf3ce4John Forte
94fcf3ce4John Forte/* Create combined definition */
95fcf3ce4John Forte#if defined(S10) || defined(S11)
96fcf3ce4John Forte#define	S10S11
97291a2b4Sukumar Swaminathan#endif /* S10 or S11 */
98fcf3ce4John Forte
99fcf3ce4John Forte#include <sys/types.h>
100fcf3ce4John Forte#include <sys/varargs.h>
101fcf3ce4John Forte#include <sys/devops.h>
102fcf3ce4John Forte#include <sys/param.h>
103fcf3ce4John Forte#include <sys/user.h>
104fcf3ce4John Forte#include <sys/buf.h>
105fcf3ce4John Forte#include <sys/ioctl.h>
106fcf3ce4John Forte#include <sys/uio.h>
107fcf3ce4John Forte#include <sys/fcntl.h>
108fcf3ce4John Forte
109fcf3ce4John Forte#include <sys/cmn_err.h>
110fcf3ce4John Forte#include <sys/stropts.h>
111fcf3ce4John Forte#include <sys/kmem.h>
112fcf3ce4John Forte
113fcf3ce4John Forte#include <sys/errno.h>
114fcf3ce4John Forte#include <sys/open.h>
115fcf3ce4John Forte#include <sys/kmem.h>
116fcf3ce4John Forte#include <sys/poll.h>
117fcf3ce4John Forte#include <sys/thread.h>
118fcf3ce4John Forte#include <sys/taskq.h>
119fcf3ce4John Forte#include <sys/debug.h>
120fcf3ce4John Forte#include <sys/cpu.h>
121fcf3ce4John Forte#include <sys/autoconf.h>
122fcf3ce4John Forte#include <sys/conf.h>
123fcf3ce4John Forte#include <sys/stat.h>
124fcf3ce4John Forte#include <sys/var.h>
125fcf3ce4John Forte
126fcf3ce4John Forte#include <sys/map.h>
127fcf3ce4John Forte#include <sys/file.h>
128fcf3ce4John Forte#include <sys/syslog.h>
129fcf3ce4John Forte#include <sys/disp.h>
130fcf3ce4John Forte#include <sys/taskq.h>
131fcf3ce4John Forte
132fcf3ce4John Forte#include <sys/ddi.h>
133fcf3ce4John Forte#include <sys/sunddi.h>
134fcf3ce4John Forte#include <sys/promif.h>
135fcf3ce4John Forte#include <sys/ethernet.h>
136fcf3ce4John Forte#include <vm/seg_kmem.h>
137fcf3ce4John Forte#include <sys/utsname.h>
138fcf3ce4John Forte#include <sys/modctl.h>
139fcf3ce4John Forte#include <sys/scsi/scsi.h>
140fcf3ce4John Forte#include <sys/varargs.h>
141fcf3ce4John Forte#include <sys/atomic.h>
142a9800beGarrett D'Amore#ifdef S11
143a9800beGarrett D'Amore#include <sys/pci.h>
1448f23e9fHans Rosenfeld#include <sys/pcie.h>
145a9800beGarrett D'Amore#else	/* !S11 */
146a9800beGarrett D'Amore/*
147a9800beGarrett D'Amore * Capabilities linked list entry offsets
148a9800beGarrett D'Amore */
149a9800beGarrett D'Amore#define	PCI_CAP_ID		0x0	/* capability identifier, 1 byte */
150a9800beGarrett D'Amore#define	PCI_CAP_NEXT_PTR	0x1	/* next entry pointer, 1 byte */
151a9800beGarrett D'Amore#define	PCI_CAP_ID_REGS_OFF	0x2	/* cap id register offset */
152a9800beGarrett D'Amore#define	PCI_CAP_MAX_PTR		0x30	/* maximum number of cap pointers */
153a9800beGarrett D'Amore#define	PCI_CAP_PTR_OFF		0x40	/* minimum cap pointer offset */
154a9800beGarrett D'Amore#define	PCI_CAP_PTR_MASK	0xFC	/* mask for capability pointer */
155a9800beGarrett D'Amore
156a9800beGarrett D'Amore/*
157a9800beGarrett D'Amore * Capability identifier values
158a9800beGarrett D'Amore */
159a9800beGarrett D'Amore#define	PCI_CAP_ID_PM		0x1	/* power management entry */
160a9800beGarrett D'Amore#define	PCI_CAP_ID_AGP		0x2	/* AGP supported */
161a9800beGarrett D'Amore#define	PCI_CAP_ID_VPD		0x3	/* VPD supported */
162a9800beGarrett D'Amore#define	PCI_CAP_ID_SLOT_ID	0x4	/* Slot Identification supported */
163a9800beGarrett D'Amore#define	PCI_CAP_ID_MSI		0x5	/* MSI supported */
164a9800beGarrett D'Amore#define	PCI_CAP_ID_cPCI_HS	0x6	/* CompactPCI Host Swap supported */
165a9800beGarrett D'Amore#define	PCI_CAP_ID_PCIX		0x7	/* PCI-X supported */
166a9800beGarrett D'Amore#define	PCI_CAP_ID_HT		0x8	/* HyperTransport supported */
167a9800beGarrett D'Amore#define	PCI_CAP_ID_VS		0x9	/* Vendor Specific */
168a9800beGarrett D'Amore#define	PCI_CAP_ID_DEBUG_PORT	0xA	/* Debug Port supported */
169a9800beGarrett D'Amore#define	PCI_CAP_ID_cPCI_CRC	0xB	/* CompactPCI central resource ctrl */
170a9800beGarrett D'Amore#define	PCI_CAP_ID_PCI_HOTPLUG	0xC	/* PCI Hot Plug supported */
171a9800beGarrett D'Amore#define	PCI_CAP_ID_P2P_SUBSYS	0xD	/* PCI bridge Sub-system ID */
172a9800beGarrett D'Amore#define	PCI_CAP_ID_AGP_8X	0xE	/* AGP 8X supported */
173a9800beGarrett D'Amore#define	PCI_CAP_ID_SECURE_DEV	0xF	/* Secure Device supported */
174a9800beGarrett D'Amore#define	PCI_CAP_ID_PCI_E	0x10	/* PCI Express supported */
175a9800beGarrett D'Amore#define	PCI_CAP_ID_MSI_X	0x11	/* MSI-X supported */
176a9800beGarrett D'Amore#define	PCI_CAP_ID_SATA		0x12	/* SATA Data/Index Config supported */
177a9800beGarrett D'Amore#define	PCI_CAP_ID_FLR		0x13	/* Function Level Reset supported */
178a9800beGarrett D'Amore
179a9800beGarrett D'Amore/*
180a9800beGarrett D'Amore * PCI power management (PM) capability entry offsets
181a9800beGarrett D'Amore */
182a9800beGarrett D'Amore#define	PCI_PMCAP		0x2	/* PM capabilities, 2 bytes */
183a9800beGarrett D'Amore#define	PCI_PMCSR		0x4	/* PM control/status reg, 2 bytes */
184a9800beGarrett D'Amore#define	PCI_PMCSR_BSE		0x6	/* PCI-PCI bridge extensions, 1 byte */
185a9800beGarrett D'Amore#define	PCI_PMDATA		0x7	/* PM data, 1 byte */
186a9800beGarrett D'Amore
187a9800beGarrett D'Amore/*
188a9800beGarrett D'Amore * PM control/status values - 2 bytes
189a9800beGarrett D'Amore */
190a9800beGarrett D'Amore#define	PCI_PMCSR_D0			0x0	/* power state D0 */
191a9800beGarrett D'Amore#define	PCI_PMCSR_D1			0x1	/* power state D1 */
192a9800beGarrett D'Amore#define	PCI_PMCSR_D2			0x2	/* power state D2 */
193a9800beGarrett D'Amore#define	PCI_PMCSR_D3HOT			0x3	/* power state D3hot */
1948f23e9fHans Rosenfeld
1958f23e9fHans Rosenfeld
1968f23e9fHans Rosenfeld/*
1978f23e9fHans Rosenfeld * PCI Express capability registers in PCI configuration space relative to
1988f23e9fHans Rosenfeld * the PCI Express Capability structure.
1998f23e9fHans Rosenfeld */
2008f23e9fHans Rosenfeld#define	PCIE_CAP_ID			PCI_CAP_ID
2018f23e9fHans Rosenfeld#define	PCIE_CAP_NEXT_PTR		PCI_CAP_NEXT_PTR
2028f23e9fHans Rosenfeld#define	PCIE_PCIECAP			0x02	/* PCI-e Capability Reg */
2038f23e9fHans Rosenfeld#define	PCIE_DEVCAP			0x04	/* Device Capability */
2048f23e9fHans Rosenfeld#define	PCIE_DEVCTL			0x08	/* Device Control */
2058f23e9fHans Rosenfeld#define	PCIE_DEVSTS			0x0A	/* Device Status */
2068f23e9fHans Rosenfeld#define	PCIE_LINKCAP			0x0C	/* Link Capability */
2078f23e9fHans Rosenfeld#define	PCIE_LINKCTL			0x10	/* Link Control */
2088f23e9fHans Rosenfeld#define	PCIE_LINKSTS			0x12	/* Link Status */
2098f23e9fHans Rosenfeld#define	PCIE_SLOTCAP			0x14	/* Slot Capability */
2108f23e9fHans Rosenfeld#define	PCIE_SLOTCTL			0x18	/* Slot Control */
2118f23e9fHans Rosenfeld#define	PCIE_SLOTSTS			0x1A	/* Slot Status */
2128f23e9fHans Rosenfeld#define	PCIE_ROOTCTL			0x1C	/* Root Control */
2138f23e9fHans Rosenfeld#define	PCIE_ROOTSTS			0x20	/* Root Status */
2148f23e9fHans Rosenfeld
2158f23e9fHans Rosenfeld/*
2168f23e9fHans Rosenfeld * PCI-Express Enhanced Capabilities Link Entry Bit Offsets
2178f23e9fHans Rosenfeld */
2188f23e9fHans Rosenfeld#define	PCIE_EXT_CAP			0x100	/* Base Address of Ext Cap */
2198f23e9fHans Rosenfeld
2208f23e9fHans Rosenfeld#define	PCIE_EXT_CAP_ID_SHIFT		0	/* PCI-e Ext Cap ID */
2218f23e9fHans Rosenfeld#define	PCIE_EXT_CAP_ID_MASK		0xFFFF
2228f23e9fHans Rosenfeld#define	PCIE_EXT_CAP_VER_SHIFT		16	/* PCI-e Ext Cap Ver */
2238f23e9fHans Rosenfeld#define	PCIE_EXT_CAP_VER_MASK		0xF
2248f23e9fHans Rosenfeld#define	PCIE_EXT_CAP_NEXT_PTR_SHIFT	20	/* PCI-e Ext Cap Next Ptr */
2258f23e9fHans Rosenfeld#define	PCIE_EXT_CAP_NEXT_PTR_MASK	0xFFF
2268f23e9fHans Rosenfeld
2278f23e9fHans Rosenfeld#define	PCIE_EXT_CAP_NEXT_PTR_NULL	0x0
2288f23e9fHans Rosenfeld
2298f23e9fHans Rosenfeld/*
2308f23e9fHans Rosenfeld * PCI-Express Enhanced Capability Identifier Values
2318f23e9fHans Rosenfeld */
2328f23e9fHans Rosenfeld#define	PCIE_EXT_CAP_ID_AER		0x1	/* Advanced Error Handling */
2338f23e9fHans Rosenfeld#define	PCIE_EXT_CAP_ID_VC		0x2	/* Virtual Channel, no MFVC */
2348f23e9fHans Rosenfeld#define	PCIE_EXT_CAP_ID_SER		0x3	/* Serial Number */
2358f23e9fHans Rosenfeld#define	PCIE_EXT_CAP_ID_PWR_BUDGET	0x4	/* Power Budgeting */
2368f23e9fHans Rosenfeld#define	PCIE_EXT_CAP_ID_RC_LINK_DECL	0x5	/* RC Link Declaration */
2378f23e9fHans Rosenfeld#define	PCIE_EXT_CAP_ID_RC_INT_LINKCTRL	0x6	/* RC Internal Link Control */
2388f23e9fHans Rosenfeld#define	PCIE_EXT_CAP_ID_RC_EVNT_CEA	0x7	/* RC Event Collector */
2398f23e9fHans Rosenfeld						/* Endpoint Association */
2408f23e9fHans Rosenfeld#define	PCIE_EXT_CAP_ID_MFVC		0x8	/* Multi-func Virtual Channel */
2418f23e9fHans Rosenfeld#define	PCIE_EXT_CAP_ID_VC_WITH_MFVC	0x9	/* Virtual Channel w/ MFVC */
2428f23e9fHans Rosenfeld#define	PCIE_EXT_CAP_ID_RCRB		0xA	/* Root Complex Register Blck */
2438f23e9fHans Rosenfeld#define	PCIE_EXT_CAP_ID_VS		0xB	/* Vendor Spec Extended Cap */
2448f23e9fHans Rosenfeld#define	PCIE_EXT_CAP_ID_CAC		0xC	/* Config Access Correlation */
2458f23e9fHans Rosenfeld#define	PCIE_EXT_CAP_ID_ACS		0xD	/* Access Control Services */
2468f23e9fHans Rosenfeld#define	PCIE_EXT_CAP_ID_ARI		0xE	/* Alternative Routing ID */
2478f23e9fHans Rosenfeld#define	PCIE_EXT_CAP_ID_ATS		0xF	/* Address Translation Svcs */
248a9800beGarrett D'Amore#endif	/* S11 */
249fcf3ce4John Forte
250fcf3ce4John Forte#include <emlxs_hbaapi.h>
251fcf3ce4John Forte
252291a2b4Sukumar Swaminathan#ifdef FMA_SUPPORT
253291a2b4Sukumar Swaminathan#include <sys/ddifm.h>
254291a2b4Sukumar Swaminathan#include <sys/fm/protocol.h>
255291a2b4Sukumar Swaminathan#include <sys/fm/util.h>
256291a2b4Sukumar Swaminathan#endif	/* FMA_SUPPORT */
257291a2b4Sukumar Swaminathan#include <sys/fm/io/ddi.h>
258fcf3ce4John Forte
259fcf3ce4John Forte#ifdef S11
260fcf3ce4John Forte
261fcf3ce4John Forte/* ULP header files */
262fcf3ce4John Forte#include <sys/fibre-channel/fc.h>
263fcf3ce4John Forte#include <sys/fibre-channel/impl/fc_fcaif.h>
264fcf3ce4John Forte
265fcf3ce4John Forte#else	/* !S11 */
266fcf3ce4John Forte
267fcf3ce4John Forte/* ULP header files */
268fcf3ce4John Forte#include <sys/fibre-channel/fcio.h>
269fcf3ce4John Forte#include <sys/fibre-channel/fc.h>
270fcf3ce4John Forte#include <sys/fibre-channel/fc_appif.h>
271fcf3ce4John Forte#include <sys/fibre-channel/fc_types.h>
272fcf3ce4John Forte#include <sys/fibre-channel/impl/fc_error.h>
273fcf3ce4John Forte#include <sys/fibre-channel/impl/fc_fla.h>
274fcf3ce4John Forte#include <sys/fibre-channel/impl/fc_linkapp.h>
275fcf3ce4John Forte#include <sys/fibre-channel/impl/fcal.h>
276fcf3ce4John Forte#include <sys/fibre-channel/impl/fcgs2.h>
277fcf3ce4John Forte#include <sys/fibre-channel/impl/fcph.h>
278fcf3ce4John Forte#include <sys/fibre-channel/impl/fc_ulpif.h>
279fcf3ce4John Forte#include <sys/fibre-channel/impl/fc_fcaif.h>
280fcf3ce4John Forte#include <sys/fibre-channel/impl/fctl.h>
281fcf3ce4John Forte#include <sys/fibre-channel/impl/fctl_private.h>
282fcf3ce4John Forte#include <sys/fibre-channel/ulp/fcp.h>
283fcf3ce4John Forte#include <sys/fibre-channel/ulp/fcp_util.h>
284fcf3ce4John Forte
285fcf3ce4John Forte#endif	/* S11 */
286fcf3ce4John Forte
287fcf3ce4John Forte#ifndef FC_HBA_PORTSPEED_8GBIT
288fcf3ce4John Forte#define	FC_HBA_PORTSPEED_8GBIT		16
289fcf3ce4John Forte#endif	/* FC_HBA_PORTSPEED_8GBIT */
290fcf3ce4John Forte
291fcf3ce4John Forte#ifndef FP_DEFAULT_SID
292fcf3ce4John Forte#define	FP_DEFAULT_SID		(0x000AE)
293fcf3ce4John Forte#endif	/* FP_DEFAULT_SID */
294fcf3ce4John Forte
295fcf3ce4John Forte#ifndef FP_DEFAULT_DID
296fcf3ce4John Forte#define	FP_DEFAULT_DID		(0x000EA)
297fcf3ce4John Forte#endif	/* FP_DEFAULT_DID */
298fcf3ce4John Forte
299fcf3ce4John Forte#ifdef MSI_SUPPORT
300fcf3ce4John Forte#pragma weak ddi_intr_get_supported_types
301fcf3ce4John Forte#pragma weak ddi_intr_get_nintrs
302fcf3ce4John Forte#pragma weak ddi_intr_add_handler
303fcf3ce4John Forte#pragma weak ddi_intr_remove_handler
304fcf3ce4John Forte#pragma weak ddi_intr_get_hilevel_pri
305fcf3ce4John Forte#pragma weak ddi_intr_enable
306fcf3ce4John Forte#pragma weak ddi_intr_disable
307fcf3ce4John Forte#pragma weak ddi_intr_get_cap
308fcf3ce4John Forte#pragma weak ddi_intr_get_pri
309fcf3ce4John Forte#pragma weak ddi_intr_alloc
310fcf3ce4John Forte#pragma weak ddi_intr_free
311fcf3ce4John Forte#pragma weak ddi_intr_block_enable
312fcf3ce4John Forte#pragma weak ddi_intr_block_disable
313fcf3ce4John Forteextern int ddi_intr_get_supported_types();
314fcf3ce4John Forte#endif	/* MSI_SUPPORT */
315fcf3ce4John Forte
316fcf3ce4John Forte#ifndef MODSYM_SUPPORT
317fcf3ce4John Forte#pragma weak fc_fca_init
318fcf3ce4John Forte#pragma weak fc_fca_attach
319fcf3ce4John Forte#pragma weak fc_fca_detach
320291a2b4Sukumar Swaminathan#endif /* MODSYM_SUPPORT */
321fcf3ce4John Forte
322fcf3ce4John Forte/* S11 flag for dma_attr_flags for ddi_dma_attr_t */
323fcf3ce4John Forte#ifndef DDI_DMA_RELAXED_ORDERING
324fcf3ce4John Forte#define	DDI_DMA_RELAXED_ORDERING	0x400
325fcf3ce4John Forte#endif	/* DDI_DMA_RELAXED_ORDERING */
326fcf3ce4John Forte
327291a2b4Sukumar Swaminathan#ifdef FMA_SUPPORT
328291a2b4Sukumar Swaminathan/* FMA Support */
329291a2b4Sukumar Swaminathan#pragma weak ddi_fm_acc_err_clear
330bb63f56Sukumar Swaminathanextern void ddi_fm_acc_err_clear();
331291a2b4Sukumar Swaminathan#endif	/* FMA_SUPPORT */
332fcf3ce4John Forte
333fcf3ce4John Forte#ifdef EMLXS_SPARC
334fcf3ce4John Forte#define	EMLXS_BIG_ENDIAN
335fcf3ce4John Forte#endif	/* EMLXS_SPARC */
336fcf3ce4John Forte
337fcf3ce4John Forte#ifdef EMLXS_I386
338fcf3ce4John Forte#define	EMLXS_LITTLE_ENDIAN
339fcf3ce4John Forte#endif	/* EMLXS_I386 */
340fcf3ce4John Forte
341fcf3ce4John Forte
342fcf3ce4John Forte/* Solaris 8 does not define this */
343fcf3ce4John Forte#ifndef TASKQ_DYNAMIC
344291a2b4Sukumar Swaminathan#define	TASKQ_DYNAMIC	0x0004
345fcf3ce4John Forte#endif	/* TASKQ_DYNAMIC */
346fcf3ce4John Forte
347fcf3ce4John Forte#ifdef _LP64
348291a2b4Sukumar Swaminathan#define	DEAD_PTR   0xdeadbeefdeadbeef
349fcf3ce4John Forte#else
350291a2b4Sukumar Swaminathan#define	DEAD_PTR   0xdeadbeef
351fcf3ce4John Forte#endif	/* _LP64 */
352fcf3ce4John Forte
353fcf3ce4John Forte#ifndef FC_STATE_8GBIT_SPEED
354fcf3ce4John Forte/* This was obtained from OpenSolaris */
355fcf3ce4John Forte#define	FC_STATE_8GBIT_SPEED		0x0700	/* 8 Gbit/sec */
356fcf3ce4John Forte#endif	/* FC_STATE_8GBIT_SPEED */
357fcf3ce4John Forte
358fcf3ce4John Forte#define	FC_STATE_QUAD_SPEED		0x0500
359fcf3ce4John Forte
360fcf3ce4John Forte#ifndef BURSTSIZE
361fcf3ce4John Forte#define	BURSTSIZE
362291a2b4Sukumar Swaminathan#define	BURST1			0x01
363291a2b4Sukumar Swaminathan#define	BURST2			0x02
364291a2b4Sukumar Swaminathan#define	BURST4			0x04
365291a2b4Sukumar Swaminathan#define	BURST8			0x08
366291a2b4Sukumar Swaminathan#define	BURST16			0x10
367291a2b4Sukumar Swaminathan#define	BURST32			0x20
368291a2b4Sukumar Swaminathan#define	BURST64			0x40
369fcf3ce4John Forte#ifdef _LP64
370291a2b4Sukumar Swaminathan#define	BURSTSIZE_MASK		0x7f
371fcf3ce4John Forte#else
372291a2b4Sukumar Swaminathan#define	BURSTSIZE_MASK		0x3f
373fcf3ce4John Forte#endif	/* _LP64 */
374fcf3ce4John Forte#define	DEFAULT_BURSTSIZE	(BURSTSIZE_MASK)	/* all burst sizes */
375fcf3ce4John Forte#endif	/* BURSTSIZE */
376fcf3ce4John Forte
3778252773Sukumar Swaminathan#define	PADDR_LO(addr)		((uint32_t)(((uint64_t)(addr)) & 0xffffffff))
3788252773Sukumar Swaminathan#define	PADDR_HI(addr)		((uint32_t)(((uint64_t)(addr)) >> 32))
3798252773Sukumar Swaminathan#define	PADDR(high, low)	((uint64_t)((((uint64_t)(high)) << 32) \
380291a2b4Sukumar Swaminathan					| (((uint64_t)(low)) & 0xffffffff)))
381fcf3ce4John Forte
382fcf3ce4John Forte#ifndef TRUE
383fcf3ce4John Forte#define	TRUE	1
384fcf3ce4John Forte#endif	/* TRUE */
385fcf3ce4John Forte
386fcf3ce4John Forte#ifndef FALSE
387fcf3ce4John Forte#define	FALSE	0
388fcf3ce4John Forte#endif	/* FALSE */
389fcf3ce4John Forte
390291a2b4Sukumar Swaminathan#define	DMA_READ_WRITE		0
391291a2b4Sukumar Swaminathan#define	DMA_READ_ONLY		1
392291a2b4Sukumar Swaminathan#define	DMA_WRITE_ONLY		2
393fcf3ce4John Forte
394291a2b4Sukumar Swaminathan#define	DMA_SUCC		1
395fcf3ce4John Forte
396291a2b4Sukumar Swaminathan#define	MAX_FC_BRDS		256	/* Maximum # boards per system */
397fcf3ce4John Forte
3988f23e9fHans Rosenfeld#define	BUSYWAIT_MS(ms)		drv_usecwait((ms*1000))
3998f23e9fHans Rosenfeld#define	BUSYWAIT_US(us)		drv_usecwait(us)
400fcf3ce4John Forte
4018252773Sukumar Swaminathan#define	EMLXS_MPDATA_SYNC(h, a, b, c)  \
402291a2b4Sukumar Swaminathan	if (h)  { \
403291a2b4Sukumar Swaminathan		(void) ddi_dma_sync((ddi_dma_handle_t)(h), \
404291a2b4Sukumar Swaminathan			(off_t)(a), (size_t)(b), (uint_t)c); \
405fcf3ce4John Forte	}
406fcf3ce4John Forte
407fcf3ce4John Forte#define	PKT2PRIV(pkt)		((emlxs_buf_t *)(pkt)->pkt_fca_private)
408fcf3ce4John Forte#define	PRIV2PKT(sbp)		sbp->pkt
409fcf3ce4John Forte
410fcf3ce4John Forte#define	EMLXS_INUMBER		0
411fcf3ce4John Forte#define	EMLXS_MSI_INUMBER 	0
412fcf3ce4John Forte
413fcf3ce4John Forte#define	EMLXS_DMA_ALIGN		BURST16
414fcf3ce4John Forte
415fcf3ce4John Forte/*
416291a2b4Sukumar Swaminathan * Register indices in PCI configuration space.
417fcf3ce4John Forte */
418291a2b4Sukumar Swaminathan#define	SBUS_FLASH_RD			0	/* FCODE-Flash Read only */
419291a2b4Sukumar Swaminathan						/* index */
420291a2b4Sukumar Swaminathan#define	SBUS_FLASH_RDWR			1	/* FCODE-Flash Read/Write */
421291a2b4Sukumar Swaminathan						/* index */
422291a2b4Sukumar Swaminathan#define	SBUS_DFLY_SLIM_RINDEX	  2	/* DragonFly SLIM regs index */
423291a2b4Sukumar Swaminathan#define	SBUS_DFLY_CSR_RINDEX	  3	/* DragonFly I/O regs index */
424291a2b4Sukumar Swaminathan#define	SBUS_TITAN_CORE_RINDEX	  4	/* TITAN Core register index */
425291a2b4Sukumar Swaminathan#define	SBUS_DFLY_PCI_CFG_RINDEX	5	/* DragonFly PCI ConfigSpace */
426291a2b4Sukumar Swaminathan						/* regs index */
427291a2b4Sukumar Swaminathan#define	SBUS_TITAN_PCI_CFG_RINDEX	6	/* TITAN PCI ConfigSpace regs */
428291a2b4Sukumar Swaminathan						/* index */
429291a2b4Sukumar Swaminathan#define	SBUS_TITAN_CSR_RINDEX		7	/* TITAN Control/Status regs */
430291a2b4Sukumar Swaminathan						/* index */
431291a2b4Sukumar Swaminathan
432291a2b4Sukumar Swaminathan#define	PCI_CFG_RINDEX		  0
433291a2b4Sukumar Swaminathan#define	PCI_SLIM_RINDEX		  1
434291a2b4Sukumar Swaminathan#define	PCI_CSR_RINDEX		  2
435fcf3ce4John Forte
4368f23e9fHans Rosenfeld#define	PCI_BAR0_RINDEX		  1
4378252773Sukumar Swaminathan#define	PCI_BAR1_RINDEX		  2
4388252773Sukumar Swaminathan#define	PCI_BAR2_RINDEX		  3
4398252773Sukumar Swaminathan
4408252773Sukumar Swaminathan
441fcf3ce4John Forte#define	EMLXS_MAX_UBUFS		65535
442fcf3ce4John Forte
443fcf3ce4John Forte/* Tokens < EMLXS_UB_TOKEN_OFFSET are reserved for ELS response oxids */
444291a2b4Sukumar Swaminathan#define	EMLXS_UB_TOKEN_OFFSET	0x100
445fcf3ce4John Forte
446291a2b4Sukumar Swaminathantypedef struct emlxs_ub_priv
447291a2b4Sukumar Swaminathan{
448291a2b4Sukumar Swaminathan	fc_unsol_buf_t	*ubp;
449291a2b4Sukumar Swaminathan	void		*port;
450fcf3ce4John Forte
451291a2b4Sukumar Swaminathan	uint32_t	bpl_size;
452291a2b4Sukumar Swaminathan	uint8_t		*bpl_virt;	/* virtual address ptr */
453291a2b4Sukumar Swaminathan	uint64_t	bpl_phys;	/* mapped address */
454291a2b4Sukumar Swaminathan	void		*bpl_data_handle;
455291a2b4Sukumar Swaminathan	void		*bpl_dma_handle;
456fcf3ce4John Forte
457291a2b4Sukumar Swaminathan	uint32_t	ip_ub_size;
458291a2b4Sukumar Swaminathan	uint8_t		*ip_ub_virt;	/* virtual address ptr */
459fcf3ce4John Forte	ddi_dma_cookie_t ip_ub_dma_cookies[64];
460fcf3ce4John Forte	ddi_acc_handle_t ip_ub_data_handle;
461fcf3ce4John Forte	ddi_dma_handle_t ip_ub_dma_handle;
462291a2b4Sukumar Swaminathan	uint32_t	ip_ub_cookie_cnt;
463291a2b4Sukumar Swaminathan	uint32_t	FC4type;
464fcf3ce4John Forte
465291a2b4Sukumar Swaminathan	uint16_t	flags;
466fcf3ce4John Forte#define	EMLXS_UB_FREE		0x0000
467fcf3ce4John Forte#define	EMLXS_UB_IN_USE		0x0001
468fcf3ce4John Forte#define	EMLXS_UB_REPLY		0x0002
469fcf3ce4John Forte#define	EMLXS_UB_RESV		0x0004
470fcf3ce4John Forte#define	EMLXS_UB_TIMEOUT	0x0008
471fcf3ce4John Forte#define	EMLXS_UB_INTERCEPT	0x0010
472fcf3ce4John Forte
473291a2b4Sukumar Swaminathan	uint16_t	available;
474fcf3ce4John Forte
475291a2b4Sukumar Swaminathan	uint32_t	timeout;	/* Timeout period in seconds */
476291a2b4Sukumar Swaminathan	uint32_t	time;	/* EMLXS_UB_IN_USE timestamp */
477291a2b4Sukumar Swaminathan	uint32_t	cmd;
478291a2b4Sukumar Swaminathan	uint32_t	token;
479fcf3ce4John Forte
480fcf3ce4John Forte	struct emlxs_unsol_buf *pool;
481fcf3ce4John Forte	struct emlxs_ub_priv *next;
482fcf3ce4John Forte} emlxs_ub_priv_t;
483fcf3ce4John Forte
484fcf3ce4John Forte
485291a2b4Sukumar Swaminathantypedef struct emlxs_unsol_buf
486291a2b4Sukumar Swaminathan{
487291a2b4Sukumar Swaminathan	struct emlxs_unsol_buf	*pool_prev;		/* ptr to prev type */
488291a2b4Sukumar Swaminathan							/* of unsol_buf hdr */
489291a2b4Sukumar Swaminathan	struct emlxs_unsol_buf	*pool_next;		/* ptr to next type */
490291a2b4Sukumar Swaminathan							/* of unsol_buf hdr */
491fcf3ce4John Forte
492291a2b4Sukumar Swaminathan	uint32_t		pool_type;		/* FC-4 type */
493291a2b4Sukumar Swaminathan	uint32_t		pool_buf_size;		/* buffer size for */
494291a2b4Sukumar Swaminathan							/* this pool */
495fcf3ce4John Forte
496291a2b4Sukumar Swaminathan	uint32_t		pool_nentries;		/* no. of bufs in */
497291a2b4Sukumar Swaminathan							/* pool */
498291a2b4Sukumar Swaminathan	uint32_t		pool_available;		/* no. of bufs avail */
499291a2b4Sukumar Swaminathan							/* in pool */
500fcf3ce4John Forte
501291a2b4Sukumar Swaminathan	uint32_t		pool_flags;
502291a2b4Sukumar Swaminathan#define	POOL_DESTROY		0x00000001		/* Pool is marked for */
503291a2b4Sukumar Swaminathan							/* destruction */
504fcf3ce4John Forte
505291a2b4Sukumar Swaminathan	uint32_t		pool_free;		/* Number of free */
506291a2b4Sukumar Swaminathan							/* buffers */
507291a2b4Sukumar Swaminathan	uint32_t		pool_free_resv;		/* Number of free */
508291a2b4Sukumar Swaminathan							/* reserved buffers */
509fcf3ce4John Forte
510291a2b4Sukumar Swaminathan	uint32_t		pool_first_token;	/* First token */
511291a2b4Sukumar Swaminathan							/* in pool */
512291a2b4Sukumar Swaminathan	uint32_t		pool_last_token;	/* Last token */
513291a2b4Sukumar Swaminathan							/* in pool */
514fcf3ce4John Forte
515291a2b4Sukumar Swaminathan	fc_unsol_buf_t		*fc_ubufs;		/* array of unsol buf */
516291a2b4Sukumar Swaminathan							/* structs */
517fcf3ce4John Forte} emlxs_unsol_buf_t;
518fcf3ce4John Forte
519fcf3ce4John Forte
520fcf3ce4John Forte#ifndef FC_REASON_NONE
521fcf3ce4John Forte#define	FC_REASON_NONE			0
522291a2b4Sukumar Swaminathan#endif /* FC_REASON_NONE */
523fcf3ce4John Forte
524fcf3ce4John Forte#ifndef FC_ACTION_NONE
525fcf3ce4John Forte#define	FC_ACTION_NONE			0
526291a2b4Sukumar Swaminathan#endif /* FC_ACTION_NONE */
527fcf3ce4John Forte
528fcf3ce4John Forte/*
529fcf3ce4John Forte * emlx status translation table
530fcf3ce4John Forte */
531291a2b4Sukumar Swaminathantypedef struct emlxs_xlat_err
532291a2b4Sukumar Swaminathan{
533291a2b4Sukumar Swaminathan	uint32_t	emlxs_status;
534291a2b4Sukumar Swaminathan	uint32_t	pkt_state;
535291a2b4Sukumar Swaminathan	uint32_t	pkt_reason;
536291a2b4Sukumar Swaminathan	uint32_t	pkt_expln;
537291a2b4Sukumar Swaminathan	uint32_t	pkt_action;
538fcf3ce4John Forte} emlxs_xlat_err_t;
539fcf3ce4John Forte
540fcf3ce4John Forte
541291a2b4Sukumar Swaminathantypedef struct emlxs_table
542291a2b4Sukumar Swaminathan{
543291a2b4Sukumar Swaminathan	uint32_t	code;
5448f23e9fHans Rosenfeld	char		string[48];
545fcf3ce4John Forte} emlxs_table_t;
546fcf3ce4John Forte
5478252773Sukumar Swaminathan
5488252773Sukumar Swaminathan/* PATCH MASK DEFINES */
5498252773Sukumar Swaminathan#define	EMLXS_PATCH1		0x00000001
5508252773Sukumar Swaminathan#define	EMLXS_PATCH2		0x00000002
5518252773Sukumar Swaminathan#define	EMLXS_PATCH3		0x00000004
5528252773Sukumar Swaminathan#define	EMLXS_PATCH4		0x00000008
5538252773Sukumar Swaminathan#define	EMLXS_PATCH5		0x00000010
5548252773Sukumar Swaminathan#define	EMLXS_PATCH6		0x00000020
5558252773Sukumar Swaminathan#define	EMLXS_PATCH7		0x00000040
5568252773Sukumar Swaminathan#define	EMLXS_PATCH8		0x00000080
5578252773Sukumar Swaminathan#define	EMLXS_PATCH9		0x00000100
5588252773Sukumar Swaminathan#define	EMLXS_PATCH10		0x00000200
5598252773Sukumar Swaminathan#define	EMLXS_PATCH11		0x00000400
5608252773Sukumar Swaminathan#define	EMLXS_PATCH12		0x00000800
5618252773Sukumar Swaminathan#define	EMLXS_PATCH13		0x00001000
5628252773Sukumar Swaminathan#define	EMLXS_PATCH14		0x00002000
5638252773Sukumar Swaminathan#define	EMLXS_PATCH15		0x00004000
5648252773Sukumar Swaminathan#define	EMLXS_PATCH16		0x00008000
5658252773Sukumar Swaminathan#define	EMLXS_PATCH17		0x00010000
5668252773Sukumar Swaminathan#define	EMLXS_PATCH18		0x00020000
5678252773Sukumar Swaminathan#define	EMLXS_PATCH19		0x00040000
5688252773Sukumar Swaminathan#define	EMLXS_PATCH20		0x00080000
5698252773Sukumar Swaminathan#define	EMLXS_PATCH21		0x00100000
5708252773Sukumar Swaminathan#define	EMLXS_PATCH22		0x00200000
5718252773Sukumar Swaminathan#define	EMLXS_PATCH23		0x00400000
5728252773Sukumar Swaminathan#define	EMLXS_PATCH24		0x00800000
5738252773Sukumar Swaminathan#define	EMLXS_PATCH25		0x01000000
5748252773Sukumar Swaminathan#define	EMLXS_PATCH26		0x02000000
5758252773Sukumar Swaminathan#define	EMLXS_PATCH27		0x04000000
5768252773Sukumar Swaminathan#define	EMLXS_PATCH28		0x08000000
5778252773Sukumar Swaminathan#define	EMLXS_PATCH29		0x10000000
5788252773Sukumar Swaminathan#define	EMLXS_PATCH30		0x20000000
5798252773Sukumar Swaminathan#define	EMLXS_PATCH31		0x40000000
5808252773Sukumar Swaminathan#define	EMLXS_PATCH32		0x80000000
5818252773Sukumar Swaminathan
5828252773Sukumar Swaminathan
5838252773Sukumar Swaminathan/* ULP Patches: */
5848252773Sukumar Swaminathan
5858252773Sukumar Swaminathan/* This patch enables the driver to auto respond to unsolicited LOGO's */
5868252773Sukumar Swaminathan/* This is needed because ULP is sometimes doesn't reply itself */
5878252773Sukumar Swaminathan#define	ULP_PATCH2	EMLXS_PATCH2
5888252773Sukumar Swaminathan
5898252773Sukumar Swaminathan/* This patch enables the driver to auto respond to unsolicited PRLI's */
5908252773Sukumar Swaminathan/* This is needed because ULP is known to panic sometimes */
5918252773Sukumar Swaminathan#define	ULP_PATCH3	EMLXS_PATCH3
5928252773Sukumar Swaminathan
5938252773Sukumar Swaminathan/* This patch enables the driver to auto respond to unsolicited PRLO's */
5948252773Sukumar Swaminathan/* This is needed because ULP is known to panic sometimes */
5958252773Sukumar Swaminathan#define	ULP_PATCH4	EMLXS_PATCH4
5968252773Sukumar Swaminathan
5978252773Sukumar Swaminathan/* This patch enables the driver to fail pkt abort requests */
5988252773Sukumar Swaminathan#define	ULP_PATCH5	EMLXS_PATCH5
5998252773Sukumar Swaminathan
6008252773Sukumar Swaminathan/* This patch enables the driver to generate an RSCN for unsolicited PRLO's */
6018252773Sukumar Swaminathan/* and LOGO's */
6028252773Sukumar Swaminathan#define	ULP_PATCH6	EMLXS_PATCH6
6038252773Sukumar Swaminathan
6048252773Sukumar Swaminathan/* Sun Disk Array Patches: */
6058252773Sukumar Swaminathan
6068252773Sukumar Swaminathan/* This patch enables the driver to fix a residual underrun issue with */
6078252773Sukumar Swaminathan/* check conditions */
6088252773Sukumar Swaminathan#define	FCP_UNDERRUN_PATCH1	EMLXS_PATCH9
6098252773Sukumar Swaminathan
6108252773Sukumar Swaminathan/* This patch enables the driver to fix a residual underrun issue with */
6118252773Sukumar Swaminathan/* SCSI inquiry commands */
6128252773Sukumar Swaminathan#define	FCP_UNDERRUN_PATCH2	EMLXS_PATCH10
6138252773Sukumar Swaminathan
6148252773Sukumar Swaminathan
6158252773Sukumar Swaminathan#define	DEFAULT_PATCHES	(ULP_PATCH2 | ULP_PATCH3 | \
6168252773Sukumar Swaminathan			    ULP_PATCH5 | ULP_PATCH6 | \
6178252773Sukumar Swaminathan			    FCP_UNDERRUN_PATCH1 | FCP_UNDERRUN_PATCH2)
6188252773Sukumar Swaminathan
619fcf3ce4John Forte#ifdef	__cplusplus
620fcf3ce4John Forte}
621fcf3ce4John Forte#endif
622fcf3ce4John Forte
623fcf3ce4John Forte#endif	/* _EMLXS_OS_H */
624