1291a2b48SSukumar Swaminathan /*
2291a2b48SSukumar Swaminathan  * CDDL HEADER START
3291a2b48SSukumar Swaminathan  *
4291a2b48SSukumar Swaminathan  * The contents of this file are subject to the terms of the
5291a2b48SSukumar Swaminathan  * Common Development and Distribution License (the "License").
6291a2b48SSukumar Swaminathan  * You may not use this file except in compliance with the License.
7291a2b48SSukumar Swaminathan  *
8*8f23e9faSHans Rosenfeld  * You can obtain a copy of the license at
9*8f23e9faSHans Rosenfeld  * http://www.opensource.org/licenses/cddl1.txt.
10291a2b48SSukumar Swaminathan  * See the License for the specific language governing permissions
11291a2b48SSukumar Swaminathan  * and limitations under the License.
12291a2b48SSukumar Swaminathan  *
13291a2b48SSukumar Swaminathan  * When distributing Covered Code, include this CDDL HEADER in each
14291a2b48SSukumar Swaminathan  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15291a2b48SSukumar Swaminathan  * If applicable, add the following below this CDDL HEADER, with the
16291a2b48SSukumar Swaminathan  * fields enclosed by brackets "[]" replaced with your own identifying
17291a2b48SSukumar Swaminathan  * information: Portions Copyright [yyyy] [name of copyright owner]
18291a2b48SSukumar Swaminathan  *
19291a2b48SSukumar Swaminathan  * CDDL HEADER END
20291a2b48SSukumar Swaminathan  */
21291a2b48SSukumar Swaminathan 
22291a2b48SSukumar Swaminathan /*
23*8f23e9faSHans Rosenfeld  * Copyright (c) 2004-2011 Emulex. All rights reserved.
2482527734SSukumar Swaminathan  * Use is subject to license terms.
25291a2b48SSukumar Swaminathan  */
26291a2b48SSukumar Swaminathan 
27291a2b48SSukumar Swaminathan #ifndef _EMLXS_SDAPI_H
28291a2b48SSukumar Swaminathan #define	_EMLXS_SDAPI_H
29291a2b48SSukumar Swaminathan 
30291a2b48SSukumar Swaminathan #ifdef	__cplusplus
31291a2b48SSukumar Swaminathan extern "C" {
32291a2b48SSukumar Swaminathan #endif
33291a2b48SSukumar Swaminathan 
34291a2b48SSukumar Swaminathan /*
35291a2b48SSukumar Swaminathan  * Although information in this file can be used by app, libdfc or driver,
36291a2b48SSukumar Swaminathan  * its purpose is for communication between app and libdfc.
37291a2b48SSukumar Swaminathan  * Its content come from the SAN Diag API Specification.
38291a2b48SSukumar Swaminathan  */
39291a2b48SSukumar Swaminathan 
40291a2b48SSukumar Swaminathan 
41291a2b48SSukumar Swaminathan /* Define for refering SCSI_IO_LATENCY */
42291a2b48SSukumar Swaminathan #define	SD_SCSI_IO_LATENCY_TYPE		0x01
43291a2b48SSukumar Swaminathan 
44291a2b48SSukumar Swaminathan #define	SD_IO_LATENCY_MAX_BUCKETS	20	/* Size of array range */
45291a2b48SSukumar Swaminathan 
46291a2b48SSukumar Swaminathan /* Masks for ELS Commands */
47291a2b48SSukumar Swaminathan #define	SD_ELS_SUBCATEGORY_PLOGI_RCV	0x01
48291a2b48SSukumar Swaminathan #define	SD_ELS_SUBCATEGORY_PRLO_RCV	0x02
49291a2b48SSukumar Swaminathan #define	SD_ELS_SUBCATEGORY_ADISC_RCV	0x04
50291a2b48SSukumar Swaminathan #define	SD_ELS_SUBCATEGORY_LSRJT_RCV	0x08
51291a2b48SSukumar Swaminathan #define	SD_ELS_SUBCATEGORY_LOGO_RCV	0x10
52291a2b48SSukumar Swaminathan #define	SD_ELS_SUBCATEGORY_RSCN_RCV	0x20
53291a2b48SSukumar Swaminathan 
54291a2b48SSukumar Swaminathan /* Masks for Fabric events */
55291a2b48SSukumar Swaminathan #define	SD_FABRIC_SUBCATEGORY_FABRIC_BUSY	0x01
56291a2b48SSukumar Swaminathan #define	SD_FABRIC_SUBCATEGORY_PORT_BUSY		0x02
57291a2b48SSukumar Swaminathan #define	SD_FABRIC_SUBCATEGORY_FCPRDCHKERR	0x04
58291a2b48SSukumar Swaminathan 
59291a2b48SSukumar Swaminathan /* Masks for SCSI events */
60291a2b48SSukumar Swaminathan #define	SD_SCSI_SUBCATEGORY_QFULL			0x0001
61291a2b48SSukumar Swaminathan #define	SD_SCSI_SUBCATEGORY_DEVBSY			0x0002
62291a2b48SSukumar Swaminathan #define	SD_SCSI_SUBCATEGORY_CHECKCONDITION		0x0004
63291a2b48SSukumar Swaminathan #define	SD_SCSI_SUBCATEGORY_LUNRESET			0x0008
64291a2b48SSukumar Swaminathan #define	SD_SCSI_SUBCATEGORY_TGTRESET			0x0010
65291a2b48SSukumar Swaminathan #define	SD_SCSI_SUBCATEGORY_BUSRESET			0x0020
66291a2b48SSukumar Swaminathan #define	SD_SCSI_SUBCATEGORY_VARQUEDEPTH			0x0040
67291a2b48SSukumar Swaminathan 
68291a2b48SSukumar Swaminathan /* Masks for Board Events */
69291a2b48SSukumar Swaminathan #define	SD_BOARD_SUBCATEGORY_PORTINTERR		0x01
70291a2b48SSukumar Swaminathan #define	SD_BOARD_SUBCATEGORY_LINKATTE		0x02
71291a2b48SSukumar Swaminathan 
72291a2b48SSukumar Swaminathan /* Masks for Adapter Events */
73291a2b48SSukumar Swaminathan #define	SD_ADAPTER_SUBCATEGORY_ARRIVAL		0x01
74291a2b48SSukumar Swaminathan #define	SD_ADAPTER_SUBCATEGORY_DEPARTURE	0x02
75291a2b48SSukumar Swaminathan 
76291a2b48SSukumar Swaminathan /* Struct to hold SCSI IO Latency statistics per bucket */
77291a2b48SSukumar Swaminathan struct SD_time_stats_v0 {
78291a2b48SSukumar Swaminathan 	int sd_tstats_bucket_count;
79291a2b48SSukumar Swaminathan };
80291a2b48SSukumar Swaminathan 
81291a2b48SSukumar Swaminathan /* Struct per target for SCSI IO Latency */
82291a2b48SSukumar Swaminathan struct SD_IO_Latency_Response {
83291a2b48SSukumar Swaminathan 	HBA_WWN sd_iolatency_target_wwpn;
84291a2b48SSukumar Swaminathan 	/* Size of array depends on range size */
85291a2b48SSukumar Swaminathan 	struct SD_time_stats_v0 sd_time_stats_array[SD_IO_LATENCY_MAX_BUCKETS];
86291a2b48SSukumar Swaminathan };
87291a2b48SSukumar Swaminathan 
88291a2b48SSukumar Swaminathan /* Return Codes */
89291a2b48SSukumar Swaminathan enum SD_RETURN_CODES {
90291a2b48SSukumar Swaminathan 	SD_OK,
91291a2b48SSukumar Swaminathan 	SD_ERROR_GENERIC,
92291a2b48SSukumar Swaminathan 	SD_ERROR_ARG,
93291a2b48SSukumar Swaminathan 	SD_ERROR_INVALID_BOARD_ID,
94291a2b48SSukumar Swaminathan 	SD_ERROR_INVALID_VPORT,
95291a2b48SSukumar Swaminathan 	SD_ERROR_NOT_SUPPORTED,
96291a2b48SSukumar Swaminathan 	SD_ERROR_CATEGORY_NOT_SUPPORTED,
97291a2b48SSukumar Swaminathan 	SD_ERROR_SUBCATEGORY_NOT_SUPPORTED,
98291a2b48SSukumar Swaminathan 	SD_ERROR_MORE_DATA_AVAILABLE,
99291a2b48SSukumar Swaminathan 	SD_ERROR_EVENT_ALREADY_REGISTERED,
100291a2b48SSukumar Swaminathan 	SD_ERROR_NO_ACTIVE_REGISTRATION,
101291a2b48SSukumar Swaminathan 	SD_ERROR_ARG_MISSING,
102291a2b48SSukumar Swaminathan 	SD_ERROR_NO_MEMORY,
103291a2b48SSukumar Swaminathan 	SD_ERROR_BUCKET_NOTSET,
104291a2b48SSukumar Swaminathan 	SD_ERROR_REG_HANDLE,
105291a2b48SSukumar Swaminathan 	SD_ERROR_INVALID_SEARCH_TYPE,
106291a2b48SSukumar Swaminathan 	SD_ERROR_FUNCTION_NOT_SUPPORTED,
107291a2b48SSukumar Swaminathan 	SD_ERROR_OUT_OF_HANDLES,
108291a2b48SSukumar Swaminathan 	SD_ERROR_LIB_NOT_INIT,
109291a2b48SSukumar Swaminathan 	SD_ERROR_DATA_COLLECTION_ACTIVE,
110291a2b48SSukumar Swaminathan 	SD_ERROR_DATA_COLLECTION_NOT_ACTIVE,
111291a2b48SSukumar Swaminathan 	SD_MAX_RETURN_CODES
112291a2b48SSukumar Swaminathan };
113291a2b48SSukumar Swaminathan 
114291a2b48SSukumar Swaminathan 
115291a2b48SSukumar Swaminathan #define	SD_SEARCH_LINEAR	0x01
116291a2b48SSukumar Swaminathan #define	SD_SEARCH_POWER_2	0x02
117291a2b48SSukumar Swaminathan 
118291a2b48SSukumar Swaminathan 
119291a2b48SSukumar Swaminathan extern uint32_t	DFC_SD_Get_Granularity(void);
120291a2b48SSukumar Swaminathan 
121291a2b48SSukumar Swaminathan extern int32_t	DFC_SD_Set_Bucket(uint16_t type,
122291a2b48SSukumar Swaminathan 				uint16_t search_type,
123291a2b48SSukumar Swaminathan 				uint32_t base,
124291a2b48SSukumar Swaminathan 				uint32_t step);
125291a2b48SSukumar Swaminathan 
126291a2b48SSukumar Swaminathan extern int32_t	DFC_SD_Destroy_Bucket(uint16_t type);
127291a2b48SSukumar Swaminathan 
128291a2b48SSukumar Swaminathan extern int32_t	DFC_SD_Get_Bucket(uint16_t type,
129291a2b48SSukumar Swaminathan 				uint16_t *search_type,
130291a2b48SSukumar Swaminathan 				uint32_t *base,
131291a2b48SSukumar Swaminathan 				uint32_t *step,
132291a2b48SSukumar Swaminathan 				uint64_t *values);
133291a2b48SSukumar Swaminathan 
134291a2b48SSukumar Swaminathan extern int32_t	DFC_SD_Start_Data_Collection(uint32_t board,
135291a2b48SSukumar Swaminathan 				HBA_WWN port_id,
136291a2b48SSukumar Swaminathan 				uint16_t type,
137291a2b48SSukumar Swaminathan 				void *arg);
138291a2b48SSukumar Swaminathan 
139291a2b48SSukumar Swaminathan extern int32_t	DFC_SD_Stop_Data_Collection(uint32_t board,
140291a2b48SSukumar Swaminathan 				HBA_WWN port_id,
141291a2b48SSukumar Swaminathan 				uint16_t type);
142291a2b48SSukumar Swaminathan 
143291a2b48SSukumar Swaminathan extern int32_t	DFC_SD_Reset_Data_Collection(uint32_t board,
144291a2b48SSukumar Swaminathan 				HBA_WWN port_id,
145291a2b48SSukumar Swaminathan 				uint16_t type);
146291a2b48SSukumar Swaminathan 
147291a2b48SSukumar Swaminathan extern int32_t	DFC_SD_Get_Data(uint32_t board,
148291a2b48SSukumar Swaminathan 				HBA_WWN port_id,
149291a2b48SSukumar Swaminathan 				uint16_t type,
150291a2b48SSukumar Swaminathan 				uint16_t *target,
151291a2b48SSukumar Swaminathan 				uint32_t buf_size,
152291a2b48SSukumar Swaminathan 				void *buff);
153291a2b48SSukumar Swaminathan 
154291a2b48SSukumar Swaminathan #define	SD_REG_ELS_EVENT	0x01
155291a2b48SSukumar Swaminathan #define	SD_REG_FABRIC_EVENT	0x02
156291a2b48SSukumar Swaminathan #define	SD_REG_SCSI_EVENT	0x04
157291a2b48SSukumar Swaminathan #define	SD_REG_BOARD_EVENT	0x08
158291a2b48SSukumar Swaminathan #define	SD_REG_ADAPTER_EVENT	0x10
159291a2b48SSukumar Swaminathan 
160291a2b48SSukumar Swaminathan 
161291a2b48SSukumar Swaminathan #define	SD_ELS_SUBCATEGORY_VALID_MASK	(SD_ELS_SUBCATEGORY_PLOGI_RCV | \
162291a2b48SSukumar Swaminathan 	SD_ELS_SUBCATEGORY_PRLO_RCV | SD_ELS_SUBCATEGORY_ADISC_RCV | \
163291a2b48SSukumar Swaminathan 	SD_ELS_SUBCATEGORY_LSRJT_RCV | SD_ELS_SUBCATEGORY_LOGO_RCV | \
164291a2b48SSukumar Swaminathan 	SD_ELS_SUBCATEGORY_RSCN_RCV)
165291a2b48SSukumar Swaminathan 
166291a2b48SSukumar Swaminathan 
167291a2b48SSukumar Swaminathan /* Generic Payload */
168291a2b48SSukumar Swaminathan struct sd_event {
169291a2b48SSukumar Swaminathan 	uint32_t	sd_evt_version;
170291a2b48SSukumar Swaminathan 	size_t		sd_evt_size;
171291a2b48SSukumar Swaminathan 	void		*sd_evt_payload;
172291a2b48SSukumar Swaminathan };
173291a2b48SSukumar Swaminathan 
174291a2b48SSukumar Swaminathan 
175291a2b48SSukumar Swaminathan struct sd_els_event_details_v0 {
176291a2b48SSukumar Swaminathan 	uint32_t	sd_elsevt_version;
177291a2b48SSukumar Swaminathan 	void		*sd_elsevt_payload;
178291a2b48SSukumar Swaminathan };
179291a2b48SSukumar Swaminathan 
180291a2b48SSukumar Swaminathan 
181291a2b48SSukumar Swaminathan struct sd_plogi_rcv_v0 {
182291a2b48SSukumar Swaminathan 	uint32_t	sd_plogir_version;
183291a2b48SSukumar Swaminathan 	HBA_WWN		sd_plogir_portname;
184291a2b48SSukumar Swaminathan 	HBA_WWN		sd_plogir_nodename;
185291a2b48SSukumar Swaminathan };
186291a2b48SSukumar Swaminathan 
187291a2b48SSukumar Swaminathan 
188291a2b48SSukumar Swaminathan struct sd_prlo_rcv_v0 {
189291a2b48SSukumar Swaminathan 	uint32_t	sd_prlor_version;
190291a2b48SSukumar Swaminathan 	HBA_WWN		sd_prlor_remoteport;
191291a2b48SSukumar Swaminathan };
192291a2b48SSukumar Swaminathan 
193291a2b48SSukumar Swaminathan 
194291a2b48SSukumar Swaminathan struct sd_lsrjt_rcv_v0 {
195291a2b48SSukumar Swaminathan 	uint32_t	sd_lsrjtr_version;
196291a2b48SSukumar Swaminathan 	HBA_WWN		sd_lsrjtr_remoteport;
197291a2b48SSukumar Swaminathan 	uint32_t	sd_lsrjtr_original_cmd;
198291a2b48SSukumar Swaminathan 	uint32_t	sd_lsrjtr_reasoncode;
199291a2b48SSukumar Swaminathan 	uint32_t	sd_lsrjtr_reasoncodeexpl;
200291a2b48SSukumar Swaminathan };
201291a2b48SSukumar Swaminathan 
202291a2b48SSukumar Swaminathan 
203291a2b48SSukumar Swaminathan struct sd_adisc_rcv_v0 {
204291a2b48SSukumar Swaminathan 	uint32_t	sd_adiscr_version;
205291a2b48SSukumar Swaminathan 	HBA_WWN		sd_adiscr_portname;
206291a2b48SSukumar Swaminathan 	HBA_WWN		sd_adiscr_nodename;
207291a2b48SSukumar Swaminathan };
208291a2b48SSukumar Swaminathan 
209291a2b48SSukumar Swaminathan 
210291a2b48SSukumar Swaminathan #define	SD_FABRIC_SUBCATEGORY_VALID_MASK	(\
211291a2b48SSukumar Swaminathan 	SD_FABRIC_SUBCATEGORY_FABRIC_BUSY | SD_FABRIC_SUBCATEGORY_PORT_BUSY | \
212291a2b48SSukumar Swaminathan 	SD_FABRIC_SUBCATEGORY_FCPRDCHKERR)
213291a2b48SSukumar Swaminathan 
214291a2b48SSukumar Swaminathan 
215291a2b48SSukumar Swaminathan struct sd_fabric_event_details_v0 {
216291a2b48SSukumar Swaminathan 	uint32_t	sd_fabric_evt_version;
217291a2b48SSukumar Swaminathan 	void		*sd_fabric_evt_payload;
218291a2b48SSukumar Swaminathan };
219291a2b48SSukumar Swaminathan 
220291a2b48SSukumar Swaminathan 
221291a2b48SSukumar Swaminathan struct sd_pbsy_rcv_v0 {
222291a2b48SSukumar Swaminathan 	uint32_t	sd_pbsyr_evt_version;
223291a2b48SSukumar Swaminathan 	HBA_WWN		sd_pbsyr_rport;
224291a2b48SSukumar Swaminathan };
225291a2b48SSukumar Swaminathan 
226291a2b48SSukumar Swaminathan 
227291a2b48SSukumar Swaminathan struct sd_fcprdchkerr_v0 {
228291a2b48SSukumar Swaminathan 	uint32_t	sd_fcprdchkerr_version;
229291a2b48SSukumar Swaminathan 	HBA_WWN		sd_fcprdchkerr_rport;
230291a2b48SSukumar Swaminathan 	uint32_t	sd_fcprdchkerr_lun;
231291a2b48SSukumar Swaminathan 	uint32_t	sd_fcprdchkerr_opcode;
232291a2b48SSukumar Swaminathan 	uint32_t	sd_fcprdchkerr_fcpiparam;
233291a2b48SSukumar Swaminathan };
234291a2b48SSukumar Swaminathan 
235291a2b48SSukumar Swaminathan 
236291a2b48SSukumar Swaminathan #define	SD_SCSI_SUBCATEGORY_VALID_MASK	(\
237291a2b48SSukumar Swaminathan 	SD_SCSI_SUBCATEGORY_QFULL | SD_SCSI_SUBCATEGORY_DEVBSY | \
238291a2b48SSukumar Swaminathan 	SD_SCSI_SUBCATEGORY_CHECKCONDITION | SD_SCSI_SUBCATEGORY_LUNRESET | \
239291a2b48SSukumar Swaminathan 	SD_SCSI_SUBCATEGORY_TGTRESET | SD_SCSI_SUBCATEGORY_BUSRESET | \
240291a2b48SSukumar Swaminathan 	SD_SCSI_SUBCATEGORY_VARQUEDEPTH)
241291a2b48SSukumar Swaminathan 
242291a2b48SSukumar Swaminathan struct sd_scsi_event_details_v0 {
243291a2b48SSukumar Swaminathan 	uint32_t	sd_scsi_evt_version;
244291a2b48SSukumar Swaminathan 	void		*sd_scsi_evt_payload;
245291a2b48SSukumar Swaminathan };
246291a2b48SSukumar Swaminathan 
247291a2b48SSukumar Swaminathan 
248291a2b48SSukumar Swaminathan struct sd_scsi_generic_v0 {
249291a2b48SSukumar Swaminathan 	uint32_t	sd_scsi_generic_version;
250291a2b48SSukumar Swaminathan 	HBA_WWN		sd_scsi_generic_rport;
251291a2b48SSukumar Swaminathan 	int32_t		sd_scsi_generic_lun;
252291a2b48SSukumar Swaminathan };
253291a2b48SSukumar Swaminathan 
254291a2b48SSukumar Swaminathan 
255291a2b48SSukumar Swaminathan struct sd_scsi_checkcond_v0 {
256291a2b48SSukumar Swaminathan 	uint32_t	sd_scsi_checkcond_version;
257291a2b48SSukumar Swaminathan 	HBA_WWN		sd_scsi_checkcond_rport;
258291a2b48SSukumar Swaminathan 	uint32_t	sd_scsi_checkcond_lun;
259291a2b48SSukumar Swaminathan 	uint32_t	sd_scsi_checkcond_cmdcode;
260291a2b48SSukumar Swaminathan 	uint32_t	sd_scsi_checkcond_sensekey;
261291a2b48SSukumar Swaminathan 	uint32_t	sd_scsi_checkcond_asc;
262291a2b48SSukumar Swaminathan 	uint32_t	sd_scsi_checkcond_ascq;
263291a2b48SSukumar Swaminathan };
264291a2b48SSukumar Swaminathan 
265291a2b48SSukumar Swaminathan 
266291a2b48SSukumar Swaminathan struct sd_scsi_varquedepth_v0 {
267291a2b48SSukumar Swaminathan 	uint32_t	sd_varquedepth_version;
268291a2b48SSukumar Swaminathan 	HBA_WWN		sd_varquedepth_rport;
269291a2b48SSukumar Swaminathan 	int32_t		sd_varquedepth_lun;
270291a2b48SSukumar Swaminathan 	uint32_t	sd_varquedepth_oldval;
271291a2b48SSukumar Swaminathan 	uint32_t	sd_varquedepth_newval;
272291a2b48SSukumar Swaminathan };
273291a2b48SSukumar Swaminathan 
274291a2b48SSukumar Swaminathan 
275291a2b48SSukumar Swaminathan /* Prototype for callback */
276291a2b48SSukumar Swaminathan typedef void sd_callback(uint32_t board_id,
277291a2b48SSukumar Swaminathan 			HBA_WWN 	ort_id,
278291a2b48SSukumar Swaminathan 			uint32_t	category,
279291a2b48SSukumar Swaminathan 			uint32_t	subcategory,
280291a2b48SSukumar Swaminathan 			void		*context,
281291a2b48SSukumar Swaminathan 			struct sd_event	*sd_data);
282291a2b48SSukumar Swaminathan 
283291a2b48SSukumar Swaminathan /* Register for event */
284291a2b48SSukumar Swaminathan extern int32_t DFC_SD_RegisterForEvent(uint32_t board_id,
285291a2b48SSukumar Swaminathan 				HBA_WWN		port_id,
286291a2b48SSukumar Swaminathan 				uint32_t	category,
287291a2b48SSukumar Swaminathan 				uint32_t	subcategory,
288291a2b48SSukumar Swaminathan 				void		*context,
289291a2b48SSukumar Swaminathan 				uint32_t	*reg_handle,
290291a2b48SSukumar Swaminathan 				sd_callback	*func);
291291a2b48SSukumar Swaminathan 
292291a2b48SSukumar Swaminathan 
293291a2b48SSukumar Swaminathan /* Deregister a event */
294291a2b48SSukumar Swaminathan extern int32_t DFC_SD_unRegisterForEvent(uint32_t board_id,
295291a2b48SSukumar Swaminathan 				HBA_WWN		vport_id,
296291a2b48SSukumar Swaminathan 				uint32_t	reg_handle);
297291a2b48SSukumar Swaminathan 
298291a2b48SSukumar Swaminathan 
299291a2b48SSukumar Swaminathan #ifdef	__cplusplus
300291a2b48SSukumar Swaminathan }
301291a2b48SSukumar Swaminathan #endif
302291a2b48SSukumar Swaminathan 
303291a2b48SSukumar Swaminathan #endif	/* _EMLXS_SDAPI_H */
304