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-2012 Emulex. All rights reserved.
248252773Sukumar Swaminathan * Use is subject to license terms.
25a317005Paul Winder * Copyright 2020 RackTop Systems, Inc.
26fcf3ce4John Forte */
27fcf3ce4John Forte
28291a2b4Sukumar Swaminathan#define	DEF_ICFG	1
29fcf3ce4John Forte
30291a2b4Sukumar Swaminathan#include <emlxs.h>
31291a2b4Sukumar Swaminathan#include <emlxs_version.h>
32fcf3ce4John Forte
338252773Sukumar Swaminathan
348f23e9fHans Rosenfeldstatic char emlxs_copyright[] = EMLXS_COPYRIGHT;
35291a2b4Sukumar Swaminathanchar emlxs_revision[] = EMLXS_REVISION;
36291a2b4Sukumar Swaminathanchar emlxs_version[] = EMLXS_VERSION;
37291a2b4Sukumar Swaminathanchar emlxs_name[] = EMLXS_NAME;
38291a2b4Sukumar Swaminathanchar emlxs_label[] = EMLXS_LABEL;
39fcf3ce4John Forte
40fcf3ce4John Forte/* Required for EMLXS_CONTEXT in EMLXS_MSGF calls */
41fcf3ce4John ForteEMLXS_MSG_DEF(EMLXS_SOLARIS_C);
42fcf3ce4John Forte
43fcf3ce4John Forte#ifdef MENLO_SUPPORT
44291a2b4Sukumar Swaminathanstatic int32_t  emlxs_send_menlo(emlxs_port_t *port, emlxs_buf_t *sbp);
45291a2b4Sukumar Swaminathan#endif /* MENLO_SUPPORT */
46291a2b4Sukumar Swaminathan
47291a2b4Sukumar Swaminathanstatic void	emlxs_fca_attach(emlxs_hba_t *hba);
48291a2b4Sukumar Swaminathanstatic void	emlxs_fca_detach(emlxs_hba_t *hba);
49291a2b4Sukumar Swaminathanstatic void	emlxs_drv_banner(emlxs_hba_t *hba);
50291a2b4Sukumar Swaminathan
51291a2b4Sukumar Swaminathanstatic int32_t	emlxs_get_props(emlxs_hba_t *hba);
52a9800beGarrett D'Amorestatic int32_t	emlxs_send_fcp_cmd(emlxs_port_t *port, emlxs_buf_t *sbp,
53a9800beGarrett D'Amore		    uint32_t *pkt_flags);
54291a2b4Sukumar Swaminathanstatic int32_t	emlxs_send_fct_status(emlxs_port_t *port, emlxs_buf_t *sbp);
55291a2b4Sukumar Swaminathanstatic int32_t	emlxs_send_fct_abort(emlxs_port_t *port, emlxs_buf_t *sbp);
56291a2b4Sukumar Swaminathanstatic int32_t	emlxs_send_ip(emlxs_port_t *port, emlxs_buf_t *sbp);
57291a2b4Sukumar Swaminathanstatic int32_t	emlxs_send_els(emlxs_port_t *port, emlxs_buf_t *sbp);
58291a2b4Sukumar Swaminathanstatic int32_t	emlxs_send_els_rsp(emlxs_port_t *port, emlxs_buf_t *sbp);
59291a2b4Sukumar Swaminathanstatic int32_t	emlxs_send_ct(emlxs_port_t *port, emlxs_buf_t *sbp);
60291a2b4Sukumar Swaminathanstatic int32_t	emlxs_send_ct_rsp(emlxs_port_t *port, emlxs_buf_t *sbp);
61fcf3ce4John Fortestatic uint32_t emlxs_add_instance(int32_t ddiinst);
62291a2b4Sukumar Swaminathanstatic void	emlxs_iodone(emlxs_buf_t *sbp);
63291a2b4Sukumar Swaminathanstatic int	emlxs_pm_lower_power(dev_info_t *dip);
64291a2b4Sukumar Swaminathanstatic int	emlxs_pm_raise_power(dev_info_t *dip);
65291a2b4Sukumar Swaminathanstatic void	emlxs_driver_remove(dev_info_t *dip, uint32_t init_flag,
66291a2b4Sukumar Swaminathan		    uint32_t failed);
67291a2b4Sukumar Swaminathanstatic void	emlxs_iodone_server(void *arg1, void *arg2, void *arg3);
68291a2b4Sukumar Swaminathanstatic uint32_t	emlxs_integrity_check(emlxs_hba_t *hba);
69291a2b4Sukumar Swaminathanstatic uint32_t	emlxs_test(emlxs_hba_t *hba, uint32_t test_code,
70291a2b4Sukumar Swaminathan		    uint32_t args, uint32_t *arg);
71fcf3ce4John Forte
72a9800beGarrett D'Amore#if (EMLXS_MODREV >= EMLXS_MODREV3) && (EMLXS_MODREV <= EMLXS_MODREV4)
73291a2b4Sukumar Swaminathanstatic void	emlxs_read_vport_prop(emlxs_hba_t *hba);
748f23e9fHans Rosenfeld#endif	/* EMLXS_MODREV3 && EMLXS_MODREV4 */
758252773Sukumar Swaminathan
768f23e9fHans Rosenfeldstatic void	emlxs_mode_init_masks(emlxs_hba_t *hba);
77fcf3ce4John Forte
78fcf3ce4John Forte
79a9800beGarrett D'Amoreextern int
80a9800beGarrett D'Amoreemlxs_msiid_to_chan(emlxs_hba_t *hba, int msi_id);
81a9800beGarrett D'Amoreextern int
82a9800beGarrett D'Amoreemlxs_select_msiid(emlxs_hba_t *hba);
838f23e9fHans Rosenfeldextern void
848f23e9fHans Rosenfeldemlxs_sli4_zero_queue_stat(emlxs_hba_t *hba);
85a9800beGarrett D'Amore
86fcf3ce4John Forte/*
87fcf3ce4John Forte * Driver Entry Routines.
88fcf3ce4John Forte */
89291a2b4Sukumar Swaminathanstatic int32_t	emlxs_detach(dev_info_t *, ddi_detach_cmd_t);
90291a2b4Sukumar Swaminathanstatic int32_t	emlxs_attach(dev_info_t *, ddi_attach_cmd_t);
91291a2b4Sukumar Swaminathanstatic int32_t	emlxs_open(dev_t *, int32_t, int32_t, cred_t *);
92291a2b4Sukumar Swaminathanstatic int32_t	emlxs_close(dev_t, int32_t, int32_t, cred_t *);
93291a2b4Sukumar Swaminathanstatic int32_t	emlxs_ioctl(dev_t, int32_t, intptr_t, int32_t,
94291a2b4Sukumar Swaminathan		    cred_t *, int32_t *);
95291a2b4Sukumar Swaminathanstatic int32_t	emlxs_info(dev_info_t *, ddi_info_cmd_t, void *, void **);
96fcf3ce4John Forte
97fcf3ce4John Forte
98fcf3ce4John Forte/*
99fcf3ce4John Forte * FC_AL Transport Functions.
100fcf3ce4John Forte */
101a9800beGarrett D'Amorestatic opaque_t	emlxs_fca_bind_port(dev_info_t *, fc_fca_port_info_t *,
102291a2b4Sukumar Swaminathan		    fc_fca_bind_info_t *);
103a9800beGarrett D'Amorestatic void	emlxs_fca_unbind_port(opaque_t);
104291a2b4Sukumar Swaminathanstatic void	emlxs_initialize_pkt(emlxs_port_t *, emlxs_buf_t *);
105a9800beGarrett D'Amorestatic int32_t	emlxs_fca_get_cap(opaque_t, char *, void *);
106a9800beGarrett D'Amorestatic int32_t	emlxs_fca_set_cap(opaque_t, char *, void *);
107a9800beGarrett D'Amorestatic int32_t	emlxs_fca_get_map(opaque_t, fc_lilpmap_t *);
108a9800beGarrett D'Amorestatic int32_t	emlxs_fca_ub_alloc(opaque_t, uint64_t *, uint32_t,
109291a2b4Sukumar Swaminathan		    uint32_t *, uint32_t);
110a9800beGarrett D'Amorestatic int32_t	emlxs_fca_ub_free(opaque_t, uint32_t, uint64_t *);
111291a2b4Sukumar Swaminathan
112a9800beGarrett D'Amorestatic opaque_t	emlxs_fca_get_device(opaque_t, fc_portid_t);
113a9800beGarrett D'Amorestatic int32_t	emlxs_fca_notify(opaque_t, uint32_t);
114291a2b4Sukumar Swaminathanstatic void	emlxs_ub_els_reject(emlxs_port_t *, fc_unsol_buf_t *);
115fcf3ce4John Forte
116fcf3ce4John Forte/*
117fcf3ce4John Forte * Driver Internal Functions.
118fcf3ce4John Forte */
119fcf3ce4John Forte
120291a2b4Sukumar Swaminathanstatic void	emlxs_poll(emlxs_port_t *, emlxs_buf_t *);
121291a2b4Sukumar Swaminathanstatic int32_t	emlxs_power(dev_info_t *, int32_t, int32_t);
122291a2b4Sukumar Swaminathan#ifdef EMLXS_I386
123291a2b4Sukumar Swaminathan#ifdef S11
124291a2b4Sukumar Swaminathanstatic int32_t	emlxs_quiesce(dev_info_t *);
1258f23e9fHans Rosenfeld#endif /* S11 */
1268f23e9fHans Rosenfeld#endif /* EMLXS_I386 */
127291a2b4Sukumar Swaminathanstatic int32_t	emlxs_hba_resume(dev_info_t *);
128291a2b4Sukumar Swaminathanstatic int32_t	emlxs_hba_suspend(dev_info_t *);
129291a2b4Sukumar Swaminathanstatic int32_t	emlxs_hba_detach(dev_info_t *);
130291a2b4Sukumar Swaminathanstatic int32_t	emlxs_hba_attach(dev_info_t *);
131291a2b4Sukumar Swaminathanstatic void	emlxs_lock_destroy(emlxs_hba_t *);
132291a2b4Sukumar Swaminathanstatic void	emlxs_lock_init(emlxs_hba_t *);
133291a2b4Sukumar Swaminathan
134291a2b4Sukumar Swaminathanchar *emlxs_pm_components[] = {
1358f23e9fHans Rosenfeld	"NAME=" DRIVER_NAME "000",
136fcf3ce4John Forte	"0=Device D3 State",
137fcf3ce4John Forte	"1=Device D0 State"
138fcf3ce4John Forte};
139fcf3ce4John Forte
140fcf3ce4John Forte
141fcf3ce4John Forte/*
142fcf3ce4John Forte * Default emlx dma limits
143fcf3ce4John Forte */
144291a2b4Sukumar Swaminathanddi_dma_lim_t emlxs_dma_lim = {
145291a2b4Sukumar Swaminathan	(uint32_t)0,				/* dlim_addr_lo */
146291a2b4Sukumar Swaminathan	(uint32_t)0xffffffff,			/* dlim_addr_hi */
147291a2b4Sukumar Swaminathan	(uint_t)0x00ffffff,			/* dlim_cntr_max */
148fcf3ce4John Forte	DEFAULT_BURSTSIZE | BURST32 | BURST64,	/* dlim_burstsizes */
149291a2b4Sukumar Swaminathan	1,					/* dlim_minxfer */
150291a2b4Sukumar Swaminathan	0x00ffffff				/* dlim_dmaspeed */
151fcf3ce4John Forte};
152fcf3ce4John Forte
153fcf3ce4John Forte/*
154fcf3ce4John Forte * Be careful when using these attributes; the defaults listed below are
155291a2b4Sukumar Swaminathan * (almost) the most general case, permitting allocation in almost any
156291a2b4Sukumar Swaminathan * way supported by the LightPulse family.  The sole exception is the
157291a2b4Sukumar Swaminathan * alignment specified as requiring memory allocation on a 4-byte boundary;
158fcf3ce4John Forte * the Lightpulse can DMA memory on any byte boundary.
159fcf3ce4John Forte *
160fcf3ce4John Forte * The LightPulse family currently is limited to 16M transfers;
161291a2b4Sukumar Swaminathan * this restriction affects the dma_attr_count_max and dma_attr_maxxfer fields.
162fcf3ce4John Forte */
163291a2b4Sukumar Swaminathanddi_dma_attr_t emlxs_dma_attr = {
164291a2b4Sukumar Swaminathan	DMA_ATTR_V0,				/* dma_attr_version */
165291a2b4Sukumar Swaminathan	(uint64_t)0,				/* dma_attr_addr_lo */
166291a2b4Sukumar Swaminathan	(uint64_t)0xffffffffffffffff,		/* dma_attr_addr_hi */
167291a2b4Sukumar Swaminathan	(uint64_t)0x00ffffff,			/* dma_attr_count_max */
168291a2b4Sukumar Swaminathan	1,					/* dma_attr_align */
169fcf3ce4John Forte	DEFAULT_BURSTSIZE | BURST32 | BURST64,	/* dma_attr_burstsizes */
170291a2b4Sukumar Swaminathan	1,					/* dma_attr_minxfer */
171291a2b4Sukumar Swaminathan	(uint64_t)0x00ffffff,			/* dma_attr_maxxfer */
172291a2b4Sukumar Swaminathan	(uint64_t)0xffffffff,			/* dma_attr_seg */
1738f23e9fHans Rosenfeld	1,					/* dma_attr_sgllen */
174291a2b4Sukumar Swaminathan	1,					/* dma_attr_granular */
175291a2b4Sukumar Swaminathan	0					/* dma_attr_flags */
176fcf3ce4John Forte};
177fcf3ce4John Forte
178291a2b4Sukumar Swaminathanddi_dma_attr_t emlxs_dma_attr_ro = {
179291a2b4Sukumar Swaminathan	DMA_ATTR_V0,				/* dma_attr_version */
180291a2b4Sukumar Swaminathan	(uint64_t)0,				/* dma_attr_addr_lo */
181291a2b4Sukumar Swaminathan	(uint64_t)0xffffffffffffffff,		/* dma_attr_addr_hi */
182291a2b4Sukumar Swaminathan	(uint64_t)0x00ffffff,			/* dma_attr_count_max */
183291a2b4Sukumar Swaminathan	1,					/* dma_attr_align */
184fcf3ce4John Forte	DEFAULT_BURSTSIZE | BURST32 | BURST64,	/* dma_attr_burstsizes */
185291a2b4Sukumar Swaminathan	1,					/* dma_attr_minxfer */
186291a2b4Sukumar Swaminathan	(uint64_t)0x00ffffff,			/* dma_attr_maxxfer */
187291a2b4Sukumar Swaminathan	(uint64_t)0xffffffff,			/* dma_attr_seg */
1888f23e9fHans Rosenfeld	1,					/* dma_attr_sgllen */
189291a2b4Sukumar Swaminathan	1,					/* dma_attr_granular */
190291a2b4Sukumar Swaminathan	DDI_DMA_RELAXED_ORDERING		/* dma_attr_flags */
191fcf3ce4John Forte};
192fcf3ce4John Forte
193291a2b4Sukumar Swaminathanddi_dma_attr_t emlxs_dma_attr_1sg = {
194291a2b4Sukumar Swaminathan	DMA_ATTR_V0,				/* dma_attr_version */
195291a2b4Sukumar Swaminathan	(uint64_t)0,				/* dma_attr_addr_lo */
196291a2b4Sukumar Swaminathan	(uint64_t)0xffffffffffffffff,		/* dma_attr_addr_hi */
197291a2b4Sukumar Swaminathan	(uint64_t)0x00ffffff,			/* dma_attr_count_max */
198291a2b4Sukumar Swaminathan	1,					/* dma_attr_align */
199fcf3ce4John Forte	DEFAULT_BURSTSIZE | BURST32 | BURST64,	/* dma_attr_burstsizes */
200291a2b4Sukumar Swaminathan	1,					/* dma_attr_minxfer */
201291a2b4Sukumar Swaminathan	(uint64_t)0x00ffffff,			/* dma_attr_maxxfer */
202291a2b4Sukumar Swaminathan	(uint64_t)0xffffffff,			/* dma_attr_seg */
203291a2b4Sukumar Swaminathan	1,					/* dma_attr_sgllen */
204291a2b4Sukumar Swaminathan	1,					/* dma_attr_granular */
205291a2b4Sukumar Swaminathan	0					/* dma_attr_flags */
206fcf3ce4John Forte};
207fcf3ce4John Forte
208fcf3ce4John Forte#if (EMLXS_MODREV >= EMLXS_MODREV3)
209291a2b4Sukumar Swaminathanddi_dma_attr_t emlxs_dma_attr_fcip_rsp = {
210291a2b4Sukumar Swaminathan	DMA_ATTR_V0,				/* dma_attr_version */
211291a2b4Sukumar Swaminathan	(uint64_t)0,				/* dma_attr_addr_lo */
212291a2b4Sukumar Swaminathan	(uint64_t)0xffffffffffffffff,		/* dma_attr_addr_hi */
213291a2b4Sukumar Swaminathan	(uint64_t)0x00ffffff,			/* dma_attr_count_max */
214291a2b4Sukumar Swaminathan	1,					/* dma_attr_align */
215fcf3ce4John Forte	DEFAULT_BURSTSIZE | BURST32 | BURST64,	/* dma_attr_burstsizes */
216291a2b4Sukumar Swaminathan	1,					/* dma_attr_minxfer */
217291a2b4Sukumar Swaminathan	(uint64_t)0x00ffffff,			/* dma_attr_maxxfer */
218291a2b4Sukumar Swaminathan	(uint64_t)0xffffffff,			/* dma_attr_seg */
2198f23e9fHans Rosenfeld	1,					/* dma_attr_sgllen */
220291a2b4Sukumar Swaminathan	1,					/* dma_attr_granular */
221291a2b4Sukumar Swaminathan	0					/* dma_attr_flags */
222fcf3ce4John Forte};
223fcf3ce4John Forte#endif	/* >= EMLXS_MODREV3 */
224fcf3ce4John Forte
225fcf3ce4John Forte/*
226fcf3ce4John Forte * DDI access attributes for device
227fcf3ce4John Forte */
228291a2b4Sukumar Swaminathanddi_device_acc_attr_t emlxs_dev_acc_attr = {
229bb63f56Sukumar Swaminathan	DDI_DEVICE_ATTR_V1,	/* devacc_attr_version		*/
230bb63f56Sukumar Swaminathan	DDI_STRUCTURE_LE_ACC,	/* PCI is Little Endian		*/
231bb63f56Sukumar Swaminathan	DDI_STRICTORDER_ACC,	/* devacc_attr_dataorder	*/
232bb63f56Sukumar Swaminathan	DDI_DEFAULT_ACC		/* devacc_attr_access		*/
233fcf3ce4John Forte};
234fcf3ce4John Forte
235fcf3ce4John Forte/*
236fcf3ce4John Forte * DDI access attributes for data
237fcf3ce4John Forte */
238291a2b4Sukumar Swaminathanddi_device_acc_attr_t emlxs_data_acc_attr = {
239bb63f56Sukumar Swaminathan	DDI_DEVICE_ATTR_V1,	/* devacc_attr_version		*/
240bb63f56Sukumar Swaminathan	DDI_NEVERSWAP_ACC,	/* don't swap for Data		*/
241bb63f56Sukumar Swaminathan	DDI_STRICTORDER_ACC,	/* devacc_attr_dataorder	*/
242bb63f56Sukumar Swaminathan	DDI_DEFAULT_ACC		/* devacc_attr_access		*/
243fcf3ce4John Forte};
244fcf3ce4John Forte
245fcf3ce4John Forte/*
246291a2b4Sukumar Swaminathan * Fill in the FC Transport structure,
247291a2b4Sukumar Swaminathan * as defined in the Fibre Channel Transport Programmming Guide.
248fcf3ce4John Forte */
249fcf3ce4John Forte#if (EMLXS_MODREV == EMLXS_MODREV5)
250291a2b4Sukumar Swaminathan	static fc_fca_tran_t emlxs_fca_tran = {
2518bb4c5aToomas Soome	FCTL_FCA_MODREV_5,		/* fca_version, with SUN NPIV support */
252291a2b4Sukumar Swaminathan	MAX_VPORTS,			/* fca numerb of ports */
253291a2b4Sukumar Swaminathan	sizeof (emlxs_buf_t),		/* fca pkt size */
254291a2b4Sukumar Swaminathan	2048,				/* fca cmd max */
255291a2b4Sukumar Swaminathan	&emlxs_dma_lim,			/* fca dma limits */
256291a2b4Sukumar Swaminathan	0,				/* fca iblock, to be filled in later */
257291a2b4Sukumar Swaminathan	&emlxs_dma_attr,		/* fca dma attributes */
258291a2b4Sukumar Swaminathan	&emlxs_dma_attr_1sg,		/* fca dma fcp cmd attributes */
259291a2b4Sukumar Swaminathan	&emlxs_dma_attr_1sg,		/* fca dma fcp rsp attributes */
260291a2b4Sukumar Swaminathan	&emlxs_dma_attr_ro,		/* fca dma fcp data attributes */
261291a2b4Sukumar Swaminathan	&emlxs_dma_attr_1sg,		/* fca dma fcip cmd attributes */
262fcf3ce4John Forte	&emlxs_dma_attr_fcip_rsp,	/* fca dma fcip rsp attributes */
263291a2b4Sukumar Swaminathan	&emlxs_dma_attr_1sg,		/* fca dma fcsm cmd attributes */
264291a2b4Sukumar Swaminathan	&emlxs_dma_attr,		/* fca dma fcsm rsp attributes */
2658bb4c5aToomas Soome	&emlxs_data_acc_attr,		/* fca access atributes */
266291a2b4Sukumar Swaminathan	0,				/* fca_num_npivports */
267fcf3ce4John Forte	{0, 0, 0, 0, 0, 0, 0, 0},	/* Physical port WWPN */
268a9800beGarrett D'Amore	emlxs_fca_bind_port,
269a9800beGarrett D'Amore	emlxs_fca_unbind_port,
270a9800beGarrett D'Amore	emlxs_fca_pkt_init,
271a9800beGarrett D'Amore	emlxs_fca_pkt_uninit,
272a9800beGarrett D'Amore	emlxs_fca_transport,
273a9800beGarrett D'Amore	emlxs_fca_get_cap,
274a9800beGarrett D'Amore	emlxs_fca_set_cap,
275a9800beGarrett D'Amore	emlxs_fca_get_map,
276a9800beGarrett D'Amore	emlxs_fca_transport,
277a9800beGarrett D'Amore	emlxs_fca_ub_alloc,
278a9800beGarrett D'Amore	emlxs_fca_ub_free,
279a9800beGarrett D'Amore	emlxs_fca_ub_release,
280a9800beGarrett D'Amore	emlxs_fca_pkt_abort,
2816a573d8Sukumar Swaminathan	emlxs_fca_reset,
282a9800beGarrett D'Amore	emlxs_fca_port_manage,
283a9800beGarrett D'Amore	emlxs_fca_get_device,
284a9800beGarrett D'Amore	emlxs_fca_notify
285fcf3ce4John Forte};
286fcf3ce4John Forte#endif	/* EMLXS_MODREV5 */
287fcf3ce4John Forte
288fcf3ce4John Forte
289fcf3ce4John Forte#if (EMLXS_MODREV == EMLXS_MODREV4)
290291a2b4Sukumar Swaminathanstatic fc_fca_tran_t emlxs_fca_tran = {
291291a2b4Sukumar Swaminathan	FCTL_FCA_MODREV_4,		/* fca_version */
292291a2b4Sukumar Swaminathan	MAX_VPORTS,			/* fca numerb of ports */
293291a2b4Sukumar Swaminathan	sizeof (emlxs_buf_t),		/* fca pkt size */
294291a2b4Sukumar Swaminathan	2048,				/* fca cmd max */
295291a2b4Sukumar Swaminathan	&emlxs_dma_lim,			/* fca dma limits */
296291a2b4Sukumar Swaminathan	0,				/* fca iblock, to be filled in later */
297291a2b4Sukumar Swaminathan	&emlxs_dma_attr,		/* fca dma attributes */
298291a2b4Sukumar Swaminathan	&emlxs_dma_attr_1sg,		/* fca dma fcp cmd attributes */
299291a2b4Sukumar Swaminathan	&emlxs_dma_attr_1sg,		/* fca dma fcp rsp attributes */
300291a2b4Sukumar Swaminathan	&emlxs_dma_attr_ro,		/* fca dma fcp data attributes */
301291a2b4Sukumar Swaminathan	&emlxs_dma_attr_1sg,		/* fca dma fcip cmd attributes */
302fcf3ce4John Forte	&emlxs_dma_attr_fcip_rsp,	/* fca dma fcip rsp attributes */
303291a2b4Sukumar Swaminathan	&emlxs_dma_attr_1sg,		/* fca dma fcsm cmd attributes */
304291a2b4Sukumar Swaminathan	&emlxs_dma_attr,		/* fca dma fcsm rsp attributes */
305291a2b4Sukumar Swaminathan	&emlxs_data_acc_attr,		/* fca access atributes */
306a9800beGarrett D'Amore	emlxs_fca_bind_port,
307a9800beGarrett D'Amore	emlxs_fca_unbind_port,
308a9800beGarrett D'Amore	emlxs_fca_pkt_init,
309a9800beGarrett D'Amore	emlxs_fca_pkt_uninit,
310a9800beGarrett D'Amore	emlxs_fca_transport,
311a9800beGarrett D'Amore	emlxs_fca_get_cap,
312a9800beGarrett D'Amore	emlxs_fca_set_cap,
313a9800beGarrett D'Amore	emlxs_fca_get_map,
314a9800beGarrett D'Amore	emlxs_fca_transport,
315a9800beGarrett D'Amore	emlxs_fca_ub_alloc,
316a9800beGarrett D'Amore	emlxs_fca_ub_free,
317a9800beGarrett D'Amore	emlxs_fca_ub_release,
318a9800beGarrett D'Amore	emlxs_fca_pkt_abort,
3196a573d8Sukumar Swaminathan	emlxs_fca_reset,
320a9800beGarrett D'Amore	emlxs_fca_port_manage,
321a9800beGarrett D'Amore	emlxs_fca_get_device,
322a9800beGarrett D'Amore	emlxs_fca_notify
323fcf3ce4John Forte};
324fcf3ce4John Forte#endif	/* EMLXS_MODEREV4 */
325fcf3ce4John Forte
326fcf3ce4John Forte
327fcf3ce4John Forte#if (EMLXS_MODREV == EMLXS_MODREV3)
328291a2b4Sukumar Swaminathanstatic fc_fca_tran_t emlxs_fca_tran = {
329291a2b4Sukumar Swaminathan	FCTL_FCA_MODREV_3,		/* fca_version */
330291a2b4Sukumar Swaminathan	MAX_VPORTS,			/* fca numerb of ports */
331291a2b4Sukumar Swaminathan	sizeof (emlxs_buf_t),		/* fca pkt size */
332291a2b4Sukumar Swaminathan	2048,				/* fca cmd max */
333291a2b4Sukumar Swaminathan	&emlxs_dma_lim,			/* fca dma limits */
334291a2b4Sukumar Swaminathan	0,				/* fca iblock, to be filled in later */
335291a2b4Sukumar Swaminathan	&emlxs_dma_attr,		/* fca dma attributes */
336291a2b4Sukumar Swaminathan	&emlxs_dma_attr_1sg,		/* fca dma fcp cmd attributes */
337291a2b4Sukumar Swaminathan	&emlxs_dma_attr_1sg,		/* fca dma fcp rsp attributes */
338291a2b4Sukumar Swaminathan	&emlxs_dma_attr_ro,		/* fca dma fcp data attributes */
339291a2b4Sukumar Swaminathan	&emlxs_dma_attr_1sg,		/* fca dma fcip cmd attributes */
340fcf3ce4John Forte	&emlxs_dma_attr_fcip_rsp,	/* fca dma fcip rsp attributes */
341291a2b4Sukumar Swaminathan	&emlxs_dma_attr_1sg,		/* fca dma fcsm cmd attributes */
342291a2b4Sukumar Swaminathan	&emlxs_dma_attr,		/* fca dma fcsm rsp attributes */
343291a2b4Sukumar Swaminathan	&emlxs_data_acc_attr,		/* fca access atributes */
344a9800beGarrett D'Amore	emlxs_fca_bind_port,
345a9800beGarrett D'Amore	emlxs_fca_unbind_port,
346a9800beGarrett D'Amore	emlxs_fca_pkt_init,
347a9800beGarrett D'Amore	emlxs_fca_pkt_uninit,
348a9800beGarrett D'Amore	emlxs_fca_transport,
349a9800beGarrett D'Amore	emlxs_fca_get_cap,
350a9800beGarrett D'Amore	emlxs_fca_set_cap,
351a9800beGarrett D'Amore	emlxs_fca_get_map,
352a9800beGarrett D'Amore	emlxs_fca_transport,
353a9800beGarrett D'Amore	emlxs_fca_ub_alloc,
354a9800beGarrett D'Amore	emlxs_fca_ub_free,
355a9800beGarrett D'Amore	emlxs_fca_ub_release,
356a9800beGarrett D'Amore	emlxs_fca_pkt_abort,
3576a573d8Sukumar Swaminathan	emlxs_fca_reset,
358a9800beGarrett D'Amore	emlxs_fca_port_manage,
359a9800beGarrett D'Amore	emlxs_fca_get_device,
360a9800beGarrett D'Amore	emlxs_fca_notify
361fcf3ce4John Forte};
362fcf3ce4John Forte#endif	/* EMLXS_MODREV3 */
363fcf3ce4John Forte
364fcf3ce4John Forte
365fcf3ce4John Forte#if (EMLXS_MODREV == EMLXS_MODREV2)
366291a2b4Sukumar Swaminathanstatic fc_fca_tran_t emlxs_fca_tran = {
367291a2b4Sukumar Swaminathan	FCTL_FCA_MODREV_2,		/* fca_version */
368291a2b4Sukumar Swaminathan	MAX_VPORTS,			/* number of ports */
369291a2b4Sukumar Swaminathan	sizeof (emlxs_buf_t),		/* pkt size */
370291a2b4Sukumar Swaminathan	2048,				/* max cmds */
371291a2b4Sukumar Swaminathan	&emlxs_dma_lim,			/* DMA limits */
372291a2b4Sukumar Swaminathan	0,				/* iblock, to be filled in later */
373291a2b4Sukumar Swaminathan	&emlxs_dma_attr,		/* dma attributes */
374291a2b4Sukumar Swaminathan	&emlxs_data_acc_attr,		/* access atributes */
375a9800beGarrett D'Amore	emlxs_fca_bind_port,
376a9800beGarrett D'Amore	emlxs_fca_unbind_port,
377a9800beGarrett D'Amore	emlxs_fca_pkt_init,
378a9800beGarrett D'Amore	emlxs_fca_pkt_uninit,
379a9800beGarrett D'Amore	emlxs_fca_transport,
380a9800beGarrett D'Amore	emlxs_fca_get_cap,
381a9800beGarrett D'Amore	emlxs_fca_set_cap,
382a9800beGarrett D'Amore	emlxs_fca_get_map,
383a9800beGarrett D'Amore	emlxs_fca_transport,
384a9800beGarrett D'Amore	emlxs_fca_ub_alloc,
385a9800beGarrett D'Amore	emlxs_fca_ub_free,
386a9800beGarrett D'Amore	emlxs_fca_ub_release,
387a9800beGarrett D'Amore	emlxs_fca_pkt_abort,
3886a573d8Sukumar Swaminathan	emlxs_fca_reset,
389a9800beGarrett D'Amore	emlxs_fca_port_manage,
390a9800beGarrett D'Amore	emlxs_fca_get_device,
391a9800beGarrett D'Amore	emlxs_fca_notify
392fcf3ce4John Forte};
393fcf3ce4John Forte#endif	/* EMLXS_MODREV2 */
394fcf3ce4John Forte
3958f23e9fHans Rosenfeld
396fcf3ce4John Forte/*
397291a2b4Sukumar Swaminathan * state pointer which the implementation uses as a place to
398291a2b4Sukumar Swaminathan * hang a set of per-driver structures;
399291a2b4Sukumar Swaminathan *
400fcf3ce4John Forte */
401291a2b4Sukumar Swaminathanvoid		*emlxs_soft_state = NULL;
402fcf3ce4John Forte
403fcf3ce4John Forte/*
404fcf3ce4John Forte * Driver Global variables.
405fcf3ce4John Forte */
406291a2b4Sukumar Swaminathanint32_t		emlxs_scsi_reset_delay = 3000;	/* milliseconds */
407fcf3ce4John Forte
408291a2b4Sukumar Swaminathanemlxs_device_t  emlxs_device;
409fcf3ce4John Forte
410291a2b4Sukumar Swaminathanuint32_t	emlxs_instance[MAX_FC_BRDS];	/* uses emlxs_device.lock */
411291a2b4Sukumar Swaminathanuint32_t	emlxs_instance_count = 0;	/* uses emlxs_device.lock */
412a9800beGarrett D'Amoreuint32_t	emlxs_instance_flag = 0;	/* uses emlxs_device.lock */
413a9800beGarrett D'Amore#define	EMLXS_FW_SHOW		0x00000001
414fcf3ce4John Forte
415fcf3ce4John Forte
416fcf3ce4John Forte/*
417fcf3ce4John Forte * CB ops vector.  Used for administration only.
418fcf3ce4John Forte */
419291a2b4Sukumar Swaminathanstatic struct cb_ops emlxs_cb_ops = {
420291a2b4Sukumar Swaminathan	emlxs_open,	/* cb_open	*/
421291a2b4Sukumar Swaminathan	emlxs_close,	/* cb_close	*/
422291a2b4Sukumar Swaminathan	nodev,		/* cb_strategy	*/
423291a2b4Sukumar Swaminathan	nodev,		/* cb_print	*/
424291a2b4Sukumar Swaminathan	nodev,		/* cb_dump	*/
425291a2b4Sukumar Swaminathan	nodev,		/* cb_read	*/
426291a2b4Sukumar Swaminathan	nodev,		/* cb_write	*/
427291a2b4Sukumar Swaminathan	emlxs_ioctl,	/* cb_ioctl	*/
428291a2b4Sukumar Swaminathan	nodev,		/* cb_devmap	*/
429291a2b4Sukumar Swaminathan	nodev,		/* cb_mmap	*/
430291a2b4Sukumar Swaminathan	nodev,		/* cb_segmap	*/
431291a2b4Sukumar Swaminathan	nochpoll,	/* cb_chpoll	*/
432291a2b4Sukumar Swaminathan	ddi_prop_op,	/* cb_prop_op	*/
433291a2b4Sukumar Swaminathan	0,		/* cb_stream	*/
434fcf3ce4John Forte#ifdef _LP64
435fcf3ce4John Forte	D_64BIT | D_HOTPLUG | D_MP | D_NEW,	/* cb_flag */
436fcf3ce4John Forte#else
437291a2b4Sukumar Swaminathan	D_HOTPLUG | D_MP | D_NEW,		/* cb_flag */
438fcf3ce4John Forte#endif
439291a2b4Sukumar Swaminathan	CB_REV,		/* rev		*/
440291a2b4Sukumar Swaminathan	nodev,		/* cb_aread	*/
441291a2b4Sukumar Swaminathan	nodev		/* cb_awrite	*/
442fcf3ce4John Forte};
443fcf3ce4John Forte
444291a2b4Sukumar Swaminathanstatic struct dev_ops emlxs_ops = {
445fcf3ce4John Forte	DEVO_REV,	/* rev */
446fcf3ce4John Forte	0,	/* refcnt */
447291a2b4Sukumar Swaminathan	emlxs_info,	/* getinfo	*/
448291a2b4Sukumar Swaminathan	nulldev,	/* identify	*/
449291a2b4Sukumar Swaminathan	nulldev,	/* probe	*/
450291a2b4Sukumar Swaminathan	emlxs_attach,	/* attach	*/
451291a2b4Sukumar Swaminathan	emlxs_detach,	/* detach	*/
452291a2b4Sukumar Swaminathan	nodev,		/* reset	*/
453291a2b4Sukumar Swaminathan	&emlxs_cb_ops,	/* devo_cb_ops	*/
4544baa2c2Sukumar Swaminathan	NULL,		/* devo_bus_ops */
455291a2b4Sukumar Swaminathan	emlxs_power,	/* power ops	*/
456291a2b4Sukumar Swaminathan#ifdef EMLXS_I386
457291a2b4Sukumar Swaminathan#ifdef S11
458291a2b4Sukumar Swaminathan	emlxs_quiesce,	/* quiesce	*/
4598f23e9fHans Rosenfeld#endif /* S11 */
4608f23e9fHans Rosenfeld#endif /* EMLXS_I386 */
461fcf3ce4John Forte};
462fcf3ce4John Forte
463fcf3ce4John Forte#include <sys/modctl.h>
464fcf3ce4John Forteextern struct mod_ops mod_driverops;
465fcf3ce4John Forte
466291a2b4Sukumar Swaminathan#ifdef SAN_DIAG_SUPPORT
4678f23e9fHans Rosenfeldextern kmutex_t		emlxs_sd_bucket_mutex;
4688f23e9fHans Rosenfeldextern sd_bucket_info_t	emlxs_sd_bucket;
469291a2b4Sukumar Swaminathan#endif /* SAN_DIAG_SUPPORT */
470291a2b4Sukumar Swaminathan
471fcf3ce4John Forte/*
472fcf3ce4John Forte * Module linkage information for the kernel.
473fcf3ce4John Forte */
474291a2b4Sukumar Swaminathanstatic struct modldrv emlxs_modldrv = {
475fcf3ce4John Forte	&mod_driverops,	/* module type - driver */
476fcf3ce4John Forte	emlxs_name,	/* module name */
477fcf3ce4John Forte	&emlxs_ops,	/* driver ops */
478fcf3ce4John Forte};
479fcf3ce4John Forte
480fcf3ce4John Forte
481fcf3ce4John Forte/*
482fcf3ce4John Forte * Driver module linkage structure
483fcf3ce4John Forte */
484fcf3ce4John Fortestatic struct modlinkage emlxs_modlinkage = {
485fcf3ce4John Forte	MODREV_1,	/* ml_rev - must be MODREV_1 */
486fcf3ce4John Forte	&emlxs_modldrv,	/* ml_linkage */
487fcf3ce4John Forte	NULL	/* end of driver linkage */
488fcf3ce4John Forte};
489fcf3ce4John Forte
490fcf3ce4John Forte
491fcf3ce4John Forte/* We only need to add entries for non-default return codes. */
492fcf3ce4John Forte/* Entries do not need to be in order. */
493291a2b4Sukumar Swaminathan/* Default:	FC_PKT_TRAN_ERROR,	FC_REASON_ABORTED, */
494291a2b4Sukumar Swaminathan/*		FC_EXPLN_NONE,		FC_ACTION_RETRYABLE */
495291a2b4Sukumar Swaminathan
496291a2b4Sukumar Swaminathanemlxs_xlat_err_t emlxs_iostat_tbl[] = {
4978bb4c5aToomas Soome/*	{f/w code, pkt_state, pkt_reason,	*/
4988bb4c5aToomas Soome/*		pkt_expln, pkt_action}		*/
499fcf3ce4John Forte
500fcf3ce4John Forte	/* 0x00 - Do not remove */
501fcf3ce4John Forte	{IOSTAT_SUCCESS, FC_PKT_SUCCESS, FC_REASON_NONE,
502291a2b4Sukumar Swaminathan		FC_EXPLN_NONE, FC_ACTION_RETRYABLE},
503fcf3ce4John Forte
504fcf3ce4John Forte	/* 0x01 - Do not remove */
505fcf3ce4John Forte	{IOSTAT_FCP_RSP_ERROR, FC_PKT_SUCCESS, FC_REASON_NONE,
506291a2b4Sukumar Swaminathan		FC_EXPLN_NONE, FC_ACTION_RETRYABLE},
507fcf3ce4John Forte
508fcf3ce4John Forte	/* 0x02 */
509fcf3ce4John Forte	{IOSTAT_REMOTE_STOP, FC_PKT_REMOTE_STOP, FC_REASON_ABTS,
510291a2b4Sukumar Swaminathan		FC_EXPLN_NONE, FC_ACTION_NON_RETRYABLE},
511fcf3ce4John Forte
512fcf3ce4John Forte	/*
513291a2b4Sukumar Swaminathan	 * This is a default entry.
514291a2b4Sukumar Swaminathan	 * The real codes are written dynamically in emlxs_els.c
515fcf3ce4John Forte	 */
516291a2b4Sukumar Swaminathan	/* 0x09 */
517291a2b4Sukumar Swaminathan	{IOSTAT_LS_RJT, FC_PKT_LS_RJT, FC_REASON_CMD_UNABLE,
518291a2b4Sukumar Swaminathan		FC_EXPLN_NONE, FC_ACTION_RETRYABLE},
519fcf3ce4John Forte
520fcf3ce4John Forte	/* Special error code */
521fcf3ce4John Forte	/* 0x10 */
522fcf3ce4John Forte	{IOSTAT_DATA_OVERRUN, FC_PKT_TRAN_ERROR, FC_REASON_OVERRUN,
523291a2b4Sukumar Swaminathan		FC_EXPLN_NONE, FC_ACTION_RETRYABLE},
524fcf3ce4John Forte
525fcf3ce4John Forte	/* Special error code */
526fcf3ce4John Forte	/* 0x11 */
527fcf3ce4John Forte	{IOSTAT_DATA_UNDERRUN, FC_PKT_TRAN_ERROR, FC_REASON_ABORTED,
528291a2b4Sukumar Swaminathan		FC_EXPLN_NONE, FC_ACTION_RETRYABLE},
529fcf3ce4John Forte
5308f23e9fHans Rosenfeld	/* Special error code */
5318f23e9fHans Rosenfeld	/* 0x12 */
5328f23e9fHans Rosenfeld	{IOSTAT_RSP_INVALID, FC_PKT_TRAN_ERROR, FC_REASON_ABORTED,
5338f23e9fHans Rosenfeld		FC_EXPLN_NONE, FC_ACTION_RETRYABLE},
5348f23e9fHans Rosenfeld
535fcf3ce4John Forte	/* CLASS 2 only */
536fcf3ce4John Forte	/* 0x04 */
537fcf3ce4John Forte	{IOSTAT_NPORT_RJT, FC_PKT_NPORT_RJT, FC_REASON_PROTOCOL_ERROR,
538291a2b4Sukumar Swaminathan		FC_EXPLN_NONE, FC_ACTION_RETRYABLE},
539fcf3ce4John Forte
540fcf3ce4John Forte	/* CLASS 2 only */
541fcf3ce4John Forte	/* 0x05 */
542fcf3ce4John Forte	{IOSTAT_FABRIC_RJT, FC_PKT_FABRIC_RJT, FC_REASON_PROTOCOL_ERROR,
543291a2b4Sukumar Swaminathan		FC_EXPLN_NONE, FC_ACTION_RETRYABLE},
544fcf3ce4John Forte
545fcf3ce4John Forte	/* CLASS 2 only */
546fcf3ce4John Forte	/* 0x06 */
547fcf3ce4John Forte	{IOSTAT_NPORT_BSY, FC_PKT_NPORT_BSY, FC_REASON_PHYSICAL_BUSY,
548291a2b4Sukumar Swaminathan		FC_EXPLN_NONE, FC_ACTION_SEQ_TERM_RETRY},
549fcf3ce4John Forte
550fcf3ce4John Forte	/* CLASS 2 only */
551fcf3ce4John Forte	/* 0x07 */
552fcf3ce4John Forte	{IOSTAT_FABRIC_BSY, FC_PKT_FABRIC_BSY, FC_REASON_FABRIC_BSY,
553291a2b4Sukumar Swaminathan		FC_EXPLN_NONE, FC_ACTION_SEQ_TERM_RETRY},
554fcf3ce4John Forte};
555291a2b4Sukumar Swaminathan
556291a2b4Sukumar Swaminathan#define	IOSTAT_MAX (sizeof (emlxs_iostat_tbl)/sizeof (emlxs_xlat_err_t))
557fcf3ce4John Forte
558fcf3ce4John Forte
559fcf3ce4John Forte/* We only need to add entries for non-default return codes. */
560fcf3ce4John Forte/* Entries do not need to be in order. */
561291a2b4Sukumar Swaminathan/* Default:	FC_PKT_TRAN_ERROR,	FC_REASON_ABORTED, */
562291a2b4Sukumar Swaminathan/*		FC_EXPLN_NONE,		FC_ACTION_RETRYABLE} */
563291a2b4Sukumar Swaminathan
564291a2b4Sukumar Swaminathanemlxs_xlat_err_t emlxs_ioerr_tbl[] = {
565291a2b4Sukumar Swaminathan/*	{f/w code, pkt_state, pkt_reason,	*/
566291a2b4Sukumar Swaminathan/*		pkt_expln, pkt_action}		*/
567291a2b4Sukumar Swaminathan
568fcf3ce4John Forte	/* 0x01 */
569fcf3ce4John Forte	{IOERR_MISSING_CONTINUE, FC_PKT_TRAN_ERROR, FC_REASON_OVERRUN,
570291a2b4Sukumar Swaminathan		FC_EXPLN_NONE, FC_ACTION_RETRYABLE},
571fcf3ce4John Forte
572fcf3ce4John Forte	/* 0x02 */
573fcf3ce4John Forte	{IOERR_SEQUENCE_TIMEOUT, FC_PKT_TIMEOUT, FC_REASON_SEQ_TIMEOUT,
574291a2b4Sukumar Swaminathan		FC_EXPLN_NONE, FC_ACTION_RETRYABLE},
575fcf3ce4John Forte
576fcf3ce4John Forte	/* 0x04 */
577fcf3ce4John Forte	{IOERR_INVALID_RPI, FC_PKT_PORT_OFFLINE, FC_REASON_OFFLINE,
578291a2b4Sukumar Swaminathan		FC_EXPLN_NONE, FC_ACTION_RETRYABLE},
579fcf3ce4John Forte
580fcf3ce4John Forte	/* 0x05 */
581fcf3ce4John Forte	{IOERR_NO_XRI, FC_PKT_LOCAL_RJT, FC_REASON_XCHG_DROPPED,
582291a2b4Sukumar Swaminathan		FC_EXPLN_NONE, FC_ACTION_RETRYABLE},
583fcf3ce4John Forte
584fcf3ce4John Forte	/* 0x06 */
585291a2b4Sukumar Swaminathan	{IOERR_ILLEGAL_COMMAND,	FC_PKT_LOCAL_RJT, FC_REASON_ILLEGAL_REQ,
586291a2b4Sukumar Swaminathan		FC_EXPLN_NONE, FC_ACTION_RETRYABLE},
587fcf3ce4John Forte
588fcf3ce4John Forte	/* 0x07 */
589291a2b4Sukumar Swaminathan	{IOERR_XCHG_DROPPED, FC_PKT_LOCAL_RJT,	FC_REASON_XCHG_DROPPED,
590291a2b4Sukumar Swaminathan		FC_EXPLN_NONE, FC_ACTION_RETRYABLE},
591fcf3ce4John Forte
592fcf3ce4John Forte	/* 0x08 */
593291a2b4Sukumar Swaminathan	{IOERR_ILLEGAL_FIELD, FC_PKT_LOCAL_RJT,	FC_REASON_ILLEGAL_REQ,
594291a2b4Sukumar Swaminathan		FC_EXPLN_NONE, FC_ACTION_RETRYABLE},
595fcf3ce4John Forte
596fcf3ce4John Forte	/* 0x0B */
597fcf3ce4John Forte	{IOERR_RCV_BUFFER_WAITING, FC_PKT_LOCAL_RJT, FC_REASON_NOMEM,
598291a2b4Sukumar Swaminathan		FC_EXPLN_NONE, FC_ACTION_RETRYABLE},
599fcf3ce4John Forte
600fcf3ce4John Forte	/* 0x0D */
601291a2b4Sukumar Swaminathan	{IOERR_TX_DMA_FAILED, FC_PKT_LOCAL_RJT,	FC_REASON_DMA_ERROR,
602291a2b4Sukumar Swaminathan		FC_EXPLN_NONE, FC_ACTION_RETRYABLE},
603fcf3ce4John Forte
604fcf3ce4John Forte	/* 0x0E */
605291a2b4Sukumar Swaminathan	{IOERR_RX_DMA_FAILED, FC_PKT_LOCAL_RJT,	FC_REASON_DMA_ERROR,
606291a2b4Sukumar Swaminathan		FC_EXPLN_NONE, FC_ACTION_RETRYABLE},
607fcf3ce4John Forte
608fcf3ce4John Forte	/* 0x0F */
609291a2b4Sukumar Swaminathan	{IOERR_ILLEGAL_FRAME, FC_PKT_LOCAL_RJT,	FC_REASON_ILLEGAL_FRAME,
610291a2b4Sukumar Swaminathan		FC_EXPLN_NONE, FC_ACTION_RETRYABLE},
611fcf3ce4John Forte
612fcf3ce4John Forte	/* 0x11 */
613291a2b4Sukumar Swaminathan	{IOERR_NO_RESOURCES, FC_PKT_LOCAL_RJT,	FC_REASON_NOMEM,
614291a2b4Sukumar Swaminathan		FC_EXPLN_NONE, FC_ACTION_RETRYABLE},
615fcf3ce4John Forte
616fcf3ce4John Forte	/* 0x13 */
617fcf3ce4John Forte	{IOERR_ILLEGAL_LENGTH, FC_PKT_LOCAL_RJT, FC_REASON_ILLEGAL_LENGTH,
618291a2b4Sukumar Swaminathan		FC_EXPLN_NONE, FC_ACTION_RETRYABLE},
619fcf3ce4John Forte
620fcf3ce4John Forte	/* 0x14 */
621fcf3ce4John Forte	{IOERR_UNSUPPORTED_FEATURE, FC_PKT_LOCAL_RJT, FC_REASON_UNSUPPORTED,
622291a2b4Sukumar Swaminathan		FC_EXPLN_NONE, FC_ACTION_RETRYABLE},
623fcf3ce4John Forte
624fcf3ce4John Forte	/* 0x15 */
625fcf3ce4John Forte	{IOERR_ABORT_IN_PROGRESS, FC_PKT_LOCAL_RJT, FC_REASON_ABORTED,
626291a2b4Sukumar Swaminathan		FC_EXPLN_NONE, FC_ACTION_RETRYABLE},
627fcf3ce4John Forte
628fcf3ce4John Forte	/* 0x16 */
629fcf3ce4John Forte	{IOERR_ABORT_REQUESTED, FC_PKT_LOCAL_RJT, FC_REASON_ABORTED,
630291a2b4Sukumar Swaminathan		FC_EXPLN_NONE, FC_ACTION_RETRYABLE},
631fcf3ce4John Forte
632fcf3ce4John Forte	/* 0x17 */
633fcf3ce4John Forte	{IOERR_RCV_BUFFER_TIMEOUT, FC_PKT_LOCAL_RJT, FC_REASON_RX_BUF_TIMEOUT,
634291a2b4Sukumar Swaminathan		FC_EXPLN_NONE, FC_ACTION_RETRYABLE},
635fcf3ce4John Forte
636fcf3ce4John Forte	/* 0x18 */
637fcf3ce4John Forte	{IOERR_LOOP_OPEN_FAILURE, FC_PKT_LOCAL_RJT, FC_REASON_FCAL_OPN_FAIL,
638291a2b4Sukumar Swaminathan		FC_EXPLN_NONE, FC_ACTION_RETRYABLE},
639fcf3ce4John Forte
640fcf3ce4John Forte	/* 0x1A */
641fcf3ce4John Forte	{IOERR_LINK_DOWN, FC_PKT_PORT_OFFLINE, FC_REASON_OFFLINE,
642291a2b4Sukumar Swaminathan		FC_EXPLN_NONE, FC_ACTION_RETRYABLE},
643fcf3ce4John Forte
644fcf3ce4John Forte	/* 0x21 */
645fcf3ce4John Forte	{IOERR_BAD_HOST_ADDRESS, FC_PKT_LOCAL_RJT, FC_REASON_BAD_SID,
646291a2b4Sukumar Swaminathan		FC_EXPLN_NONE, FC_ACTION_RETRYABLE},
647fcf3ce4John Forte
648fcf3ce4John Forte	/* Occurs at link down */
649fcf3ce4John Forte	/* 0x28 */
650fcf3ce4John Forte	{IOERR_BUFFER_SHORTAGE, FC_PKT_PORT_OFFLINE, FC_REASON_OFFLINE,
651291a2b4Sukumar Swaminathan		FC_EXPLN_NONE, FC_ACTION_RETRYABLE},
652fcf3ce4John Forte
653fcf3ce4John Forte	/* 0xF0 */
654fcf3ce4John Forte	{IOERR_ABORT_TIMEOUT, FC_PKT_TIMEOUT, FC_REASON_SEQ_TIMEOUT,
655291a2b4Sukumar Swaminathan		FC_EXPLN_NONE, FC_ACTION_RETRYABLE},
656fcf3ce4John Forte};
657291a2b4Sukumar Swaminathan
658fcf3ce4John Forte#define	IOERR_MAX    (sizeof (emlxs_ioerr_tbl)/sizeof (emlxs_xlat_err_t))
659fcf3ce4John Forte
660fcf3ce4John Forte
661fcf3ce4John Forte
662291a2b4Sukumar Swaminathanemlxs_table_t emlxs_error_table[] = {
663fcf3ce4John Forte	{IOERR_SUCCESS, "No error."},
664fcf3ce4John Forte	{IOERR_MISSING_CONTINUE, "Missing continue."},
665fcf3ce4John Forte	{IOERR_SEQUENCE_TIMEOUT, "Sequence timeout."},
666fcf3ce4John Forte	{IOERR_INTERNAL_ERROR, "Internal error."},
667fcf3ce4John Forte	{IOERR_INVALID_RPI, "Invalid RPI."},
668fcf3ce4John Forte	{IOERR_NO_XRI, "No XRI."},
669fcf3ce4John Forte	{IOERR_ILLEGAL_COMMAND, "Illegal command."},
670fcf3ce4John Forte	{IOERR_XCHG_DROPPED, "Exchange dropped."},
671fcf3ce4John Forte	{IOERR_ILLEGAL_FIELD, "Illegal field."},
672fcf3ce4John Forte	{IOERR_RCV_BUFFER_WAITING, "RX buffer waiting."},
673fcf3ce4John Forte	{IOERR_TX_DMA_FAILED, "TX DMA failed."},
674fcf3ce4John Forte	{IOERR_RX_DMA_FAILED, "RX DMA failed."},
675fcf3ce4John Forte	{IOERR_ILLEGAL_FRAME, "Illegal frame."},
676fcf3ce4John Forte	{IOERR_NO_RESOURCES, "No resources."},
677fcf3ce4John Forte	{IOERR_ILLEGAL_LENGTH, "Illegal length."},
678fcf3ce4John Forte	{IOERR_UNSUPPORTED_FEATURE, "Unsupported feature."},
679fcf3ce4John Forte	{IOERR_ABORT_IN_PROGRESS, "Abort in progess."},
680fcf3ce4John Forte	{IOERR_ABORT_REQUESTED, "Abort requested."},
681fcf3ce4John Forte	{IOERR_RCV_BUFFER_TIMEOUT, "RX buffer timeout."},
682fcf3ce4John Forte	{IOERR_LOOP_OPEN_FAILURE, "Loop open failed."},
683fcf3ce4John Forte	{IOERR_RING_RESET, "Ring reset."},
684fcf3ce4John Forte	{IOERR_LINK_DOWN, "Link down."},
685fcf3ce4John Forte	{IOERR_CORRUPTED_DATA, "Corrupted data."},
686fcf3ce4John Forte	{IOERR_CORRUPTED_RPI, "Corrupted RPI."},
687fcf3ce4John Forte	{IOERR_OUT_OF_ORDER_DATA, "Out-of-order data."},
688fcf3ce4John Forte	{IOERR_OUT_OF_ORDER_ACK, "Out-of-order ack."},
689fcf3ce4John Forte	{IOERR_DUP_FRAME, "Duplicate frame."},
690fcf3ce4John Forte	{IOERR_LINK_CONTROL_FRAME, "Link control frame."},
691fcf3ce4John Forte	{IOERR_BAD_HOST_ADDRESS, "Bad host address."},
692fcf3ce4John Forte	{IOERR_RCV_HDRBUF_WAITING, "RX header buffer waiting."},
693fcf3ce4John Forte	{IOERR_MISSING_HDR_BUFFER, "Missing header buffer."},
694fcf3ce4John Forte	{IOERR_MSEQ_CHAIN_CORRUPTED, "MSEQ chain corrupted."},
695fcf3ce4John Forte	{IOERR_ABORTMULT_REQUESTED, "Abort multiple requested."},
696fcf3ce4John Forte	{IOERR_BUFFER_SHORTAGE, "Buffer shortage."},
697fcf3ce4John Forte	{IOERR_XRIBUF_WAITING, "XRI buffer shortage"},
698fcf3ce4John Forte	{IOERR_XRIBUF_MISSING, "XRI buffer missing"},
699fcf3ce4John Forte	{IOERR_ROFFSET_INVAL, "Relative offset invalid."},
700fcf3ce4John Forte	{IOERR_ROFFSET_MISSING, "Relative offset missing."},
701fcf3ce4John Forte	{IOERR_INSUF_BUFFER, "Buffer too small."},
702fcf3ce4John Forte	{IOERR_MISSING_SI, "ELS frame missing SI"},
703fcf3ce4John Forte	{IOERR_MISSING_ES, "Exhausted burst without ES"},
704fcf3ce4John Forte	{IOERR_INCOMP_XFER, "Transfer incomplete."},
705fcf3ce4John Forte	{IOERR_ABORT_TIMEOUT, "Abort timeout."}
706fcf3ce4John Forte
707fcf3ce4John Forte};	/* emlxs_error_table */
708fcf3ce4John Forte
709fcf3ce4John Forte
710291a2b4Sukumar Swaminathanemlxs_table_t emlxs_state_table[] = {
711fcf3ce4John Forte	{IOSTAT_SUCCESS, "Success."},
712fcf3ce4John Forte	{IOSTAT_FCP_RSP_ERROR, "FCP response error."},
713fcf3ce4John Forte	{IOSTAT_REMOTE_STOP, "Remote stop."},
714fcf3ce4John Forte	{IOSTAT_LOCAL_REJECT, "Local reject."},
715fcf3ce4John Forte	{IOSTAT_NPORT_RJT, "NPort reject."},
716fcf3ce4John Forte	{IOSTAT_FABRIC_RJT, "Fabric reject."},
717fcf3ce4John Forte	{IOSTAT_NPORT_BSY, "Nport busy."},
718fcf3ce4John Forte	{IOSTAT_FABRIC_BSY, "Fabric busy."},
719fcf3ce4John Forte	{IOSTAT_INTERMED_RSP, "Intermediate response."},
720fcf3ce4John Forte	{IOSTAT_LS_RJT, "LS reject."},
721291a2b4Sukumar Swaminathan	{IOSTAT_CMD_REJECT,		"Cmd reject."},
722fcf3ce4John Forte	{IOSTAT_FCP_TGT_LENCHK, "TGT length check."},
7238252773Sukumar Swaminathan	{IOSTAT_NEED_BUFF_ENTRY, "Need buffer entry."},
724fcf3ce4John Forte	{IOSTAT_DATA_UNDERRUN, "Data underrun."},
725291a2b4Sukumar Swaminathan	{IOSTAT_DATA_OVERRUN,  "Data overrun."},
7268f23e9fHans Rosenfeld	{IOSTAT_RSP_INVALID,  "Response Invalid."},
727fcf3ce4John Forte
728fcf3ce4John Forte};	/* emlxs_state_table */
729fcf3ce4John Forte
730fcf3ce4John Forte
731fcf3ce4John Forte#ifdef MENLO_SUPPORT
732291a2b4Sukumar Swaminathanemlxs_table_t emlxs_menlo_cmd_table[] = {
733291a2b4Sukumar Swaminathan	{MENLO_CMD_INITIALIZE,		"MENLO_INIT"},
734291a2b4Sukumar Swaminathan	{MENLO_CMD_FW_DOWNLOAD,		"MENLO_FW_DOWNLOAD"},
735291a2b4Sukumar Swaminathan	{MENLO_CMD_READ_MEMORY,		"MENLO_READ_MEM"},
736291a2b4Sukumar Swaminathan	{MENLO_CMD_WRITE_MEMORY,	"MENLO_WRITE_MEM"},
737291a2b4Sukumar Swaminathan	{MENLO_CMD_FTE_INSERT,		"MENLO_FTE_INSERT"},
738291a2b4Sukumar Swaminathan	{MENLO_CMD_FTE_DELETE,		"MENLO_FTE_DELETE"},
739291a2b4Sukumar Swaminathan
740291a2b4Sukumar Swaminathan	{MENLO_CMD_GET_INIT,		"MENLO_GET_INIT"},
741291a2b4Sukumar Swaminathan	{MENLO_CMD_GET_CONFIG,		"MENLO_GET_CONFIG"},
742