1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at
9 * http://www.opensource.org/licenses/cddl1.txt.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22/*
23 * Copyright (c) 2004-2012 Emulex. All rights reserved.
24 * Use is subject to license terms.
25 */
26
27#ifndef _EMLXS_FCIO_H
28#define	_EMLXS_FCIO_H
29
30#ifdef	__cplusplus
31extern "C" {
32#endif
33
34/*
35 * FCIO_REV: 1 - Initial implementation 2 - Added EMLXS_GET_FCIO_REV support
36 */
37#define	FCIO_REV	2
38
39
40/* Emulex ULP Diag Codes */
41#define	EMLXS_DIAG			('E'<< 8)
42
43#define	EMLXS_DIAG_BIU			(EMLXS_DIAG | 100)
44#define	EMLXS_DIAG_POST			(EMLXS_DIAG | 101)
45#define	EMLXS_DIAG_ECHO			(EMLXS_DIAG | 102)
46
47#define	EMLXS_PARM_GET_NUM		(EMLXS_DIAG | 200)
48#define	EMLXS_PARM_GET_LIST		(EMLXS_DIAG | 201)
49#define	EMLXS_PARM_GET			(EMLXS_DIAG | 202)
50#define	EMLXS_PARM_SET			(EMLXS_DIAG | 203)
51#define	EMLXS_GET_BOOT_REV		(EMLXS_DIAG | 204)
52#define	EMLXS_DOWNLOAD_BOOT		(EMLXS_DIAG | 205)
53#define	EMLXS_DOWNLOAD_CFL		(EMLXS_DIAG | 206)
54#define	EMLXS_VPD_GET   		(EMLXS_DIAG | 207)
55#define	EMLXS_GET_FCIO_REV   		(EMLXS_DIAG | 208)
56#define	EMLXS_SET_BOOT_STATE_old	(EMLXS_DIAG | 209)
57#define	EMLXS_GET_BOOT_STATE_old	(EMLXS_DIAG | 210)
58#define	EMLXS_DFC_COMMAND		(EMLXS_DIAG | 211)
59#define	EMLXS_SET_BOOT_STATE		(EMLXS_DIAG | 212)
60#define	EMLXS_GET_BOOT_STATE		(EMLXS_DIAG | 213)
61#define	EMLXS_GET_DFC_REV		(EMLXS_DIAG | 214)
62#define	EMLXS_PHY_GET			(EMLXS_DIAG | 215)
63#define	EMLXS_SET_THROTTLE		(EMLXS_DIAG | 216)
64#define	EMLXS_GET_THROTTLE		(EMLXS_DIAG | 217)
65#define	EMLXS_VPD_GET_V2   		(EMLXS_DIAG | 218)
66
67#define	EMLXS_BAR_IO			(EMLXS_DIAG | 253)
68#define	EMLXS_TEST_CODE   		(EMLXS_DIAG | 254)
69#define	EMLXS_HW_ERROR_TEST   		(EMLXS_DIAG | 255)
70#define	EMLXS_MB_TIMEOUT_TEST		(EMLXS_DIAG | 256)
71
72#define	EMLXS_LOG_GET			(EMLXS_DIAG | 300)
73
74
75/* DUMP file ids */
76#define	EMLXS_TXT_FILE_ID			1
77#define	EMLXS_DMP_FILE_ID			2
78#define	EMLXS_CEE_FILE_ID			3
79#define	EMLXS_FAT_FILE_ID			4
80
81
82/* Emulex specific error codes */
83#define	EMLXS_ERRNO_START		0x100
84#define	EMLXS_TEST_FAILED		(EMLXS_ERRNO_START + 0)	/* Diagnostic */
85								/* test fail */
86#define	EMLXS_IMAGE_BAD			(EMLXS_ERRNO_START + 1)	/* Image has */
87								/* bad data */
88#define	EMLXS_IMAGE_INCOMPATIBLE	(EMLXS_ERRNO_START + 2)	/* Image not */
89								/* compatible */
90								/* with H/W */
91#define	EMLXS_IMAGE_FAILED		(EMLXS_ERRNO_START + 3)	/* Image */
92								/* download */
93								/* failed */
94#define	EMLXS_OFFLINE_FAILED		(EMLXS_ERRNO_START + 4)	/* Unable to */
95								/* take HBA */
96								/* offline */
97#define	EMLXS_NO_BOOT_CODE		(EMLXS_ERRNO_START + 5)	/* No boot */
98								/* code image */
99#define	EMLXS_OP_NOT_SUP		(EMLXS_ERRNO_START + 6)	/* Operation */
100								/* not supp */
101#define	EMLXS_REBOOT_REQUIRED		(EMLXS_ERRNO_START + 7)	/* Reboot */
102								/* required */
103#define	EMLXS_ERRNO_END			(EMLXS_ERRNO_START + 7)
104
105
106typedef struct emlxs_parm
107{
108	char		label[32];
109	uint32_t	min;
110	uint32_t	max;
111	uint32_t	def;
112	uint32_t	current;
113	uint32_t	flags;
114	char		help[128];
115} emlxs_parm_t;
116
117/* emlxs_parm_t flags */
118#define	PARM_DYNAMIC	0x00000001	/* Reboot not required */
119#define	PARM_BOOLEAN	0x00000002
120#define	PARM_HEX	0x00000004
121
122/* PARM_DYNAMIC subtypes */
123#define	PARM_DYNAMIC_RESET	(PARM_DYNAMIC | 0x00000010)	/* Hard reset */
124								/* required */
125#define	PARM_DYNAMIC_LINK	(PARM_DYNAMIC | 0x00000020)	/* Link reset */
126								/* required */
127
128typedef struct emlxs_vpd_desc
129{
130	char	id[80];
131	char	part_num[32];
132	char	eng_change[32];
133	char	manufacturer[80];
134	char	serial_num[32];
135	char	model[32];
136	char	model_desc[80];
137	char	port_num[4];
138	char	prog_types[80];
139} emlxs_vpd_desc_t;
140
141typedef struct emlxs_vpd_desc_v2
142{
143	char	id[256];
144	char	part_num[256];
145	char	eng_change[256];
146	char	manufacturer[256];
147	char	serial_num[256];
148	char	model[256];
149	char	model_desc[256];
150	char	port_num[256];
151	char	prog_types[256];
152} emlxs_vpd_desc_v2_t;
153
154typedef struct emlxs_phy_desc
155{
156	uint32_t phy_type;
157	uint32_t interface_type;
158	uint32_t misc_params;
159	uint32_t rsvd[4];
160
161} emlxs_phy_desc_t;
162
163typedef struct emlxs_throttle_desc
164{
165	uint8_t wwpn[8];
166	uint32_t throttle;
167
168} emlxs_throttle_desc_t;
169
170typedef struct emlxs_log_req
171{
172	uint32_t	first;	/* First msg id requested */
173	uint32_t	count;	/* Maximum number of messages */
174				/* capable of receiving */
175				/* This value can be set to zero */
176				/* to receive just log stats */
177} emlxs_log_req_t;
178
179
180typedef struct emlxs_log_resp
181{
182	uint32_t	first;	/* Actual starting msg id in resp buffer */
183				/* This represents the first available */
184				/* msg id >= first id requested */
185	uint32_t	last;	/* Current last msg id in log file */
186	uint32_t	count;	/* Total number of messages in resp buffer */
187				/* This value will be <= the max count */
188				/* requested */
189
190				/* If count > 0, then the response buffer */
191				/* will immediately follow this structure */
192				/* The response buffer will be an array of */
193				/* string buffers MAX_MSG_LENGTH in size */
194#define	MAX_LOG_MSG_LENGTH	160
195} emlxs_log_resp_t;
196
197typedef struct FCIO_EQ_DESC
198{
199	uint32_t	host_index;
200	uint32_t	max_index;
201	uint32_t	qid;
202	uint32_t	msix_vector;
203
204	uint32_t	phys;	/* specifies physical buffer pointer */
205	uint32_t	virt;	/* specifies virtual buffer pointer */
206	uint32_t	virt_hi; /* specifies virtual buffer pointer */
207
208	/* Statistics */
209	uint32_t	max_proc;
210	uint32_t	isr_count;
211	uint32_t	num_proc;
212} FCIO_EQ_DESC_t;
213
214
215typedef struct FCIO_CQ_DESC
216{
217	uint32_t	host_index;
218	uint32_t	max_index;
219	uint32_t	qid;
220	uint32_t	eqid;
221	uint32_t	type;
222
223	uint32_t	phys;	/* specifies physical buffer pointer */
224	uint32_t	virt;	/* specifies virtual buffer pointer */
225	uint32_t	virt_hi; /* specifies virtual buffer pointer */
226
227	/* Statistics */
228	uint32_t	max_proc;
229	uint32_t	isr_count;
230	uint32_t	num_proc;
231	uint32_t	rsvd;
232} FCIO_CQ_DESC_t;
233
234
235typedef struct FCIO_WQ_DESC
236{
237	uint32_t	host_index;
238	uint32_t	max_index;
239	uint32_t	port_index;
240	uint32_t	release_depth;
241	uint32_t	qid;
242	uint32_t	cqid;
243
244	uint32_t	phys;	/* specifies physical buffer pointer */
245	uint32_t	virt;	/* specifies virtual buffer pointer */
246	uint32_t	virt_hi; /* specifies virtual buffer pointer */
247
248	/* Statistics */
249	uint32_t	num_proc;
250	uint32_t	num_busy;
251	uint32_t	rsvd;
252} FCIO_WQ_DESC_t;
253
254
255typedef struct FCIO_RQ_DESC
256{
257	uint32_t	host_index;
258	uint32_t	max_index;
259	uint32_t	qid;
260	uint32_t	cqid;
261
262	uint32_t	phys;	/* specifies physical buffer pointer */
263	uint32_t	virt;	/* specifies virtual buffer pointer */
264	uint32_t	virt_hi; /* specifies virtual buffer pointer */
265
266	/* Statistics */
267	uint32_t	num_proc;
268} FCIO_RQ_DESC_t;
269
270
271#define	FCIO_MSI_MAX_INTRS	8
272#define	FCIO_MAX_WQS_PER_EQ	4
273#define	FCIO_MAX_EQS	FCIO_MSI_MAX_INTRS
274#define	FCIO_MAX_WQS	FCIO_MAX_WQS_PER_EQ * FCIO_MAX_EQS
275#define	FCIO_MAX_RQS	2	/* ONLY 1 pair is allowed */
276
277/* One CQ for each WQ & (RQ pair) plus one for the MQ */
278#define	FCIO_MAX_CQS	(FCIO_MAX_WQS + (FCIO_MAX_RQS/2) + 1)
279
280typedef struct FCIO_Q_STAT
281{
282	FCIO_EQ_DESC_t	eq[FCIO_MAX_EQS];
283	FCIO_CQ_DESC_t	cq[FCIO_MAX_CQS];
284	FCIO_WQ_DESC_t	wq[FCIO_MAX_WQS];
285	FCIO_RQ_DESC_t	rq[FCIO_MAX_RQS];
286	uint32_t	que_start_timer;
287	uint32_t	que_current_timer;
288	uint32_t	intr_count;
289} FCIO_Q_STAT_t;
290
291
292#ifdef	__cplusplus
293}
294#endif
295
296#endif	/* _EMLXS_FCIO_H */
297