xref: /titanic_44/usr/src/uts/common/sys/fibre-channel/fca/emlxs/emlxs_sdapi.h (revision 8f23e9fa8abcb5857661066b954e63400d589b65)
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-2011 Emulex. All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _EMLXS_SDAPI_H
28 #define	_EMLXS_SDAPI_H
29 
30 #ifdef	__cplusplus
31 extern "C" {
32 #endif
33 
34 /*
35  * Although information in this file can be used by app, libdfc or driver,
36  * its purpose is for communication between app and libdfc.
37  * Its content come from the SAN Diag API Specification.
38  */
39 
40 
41 /* Define for refering SCSI_IO_LATENCY */
42 #define	SD_SCSI_IO_LATENCY_TYPE		0x01
43 
44 #define	SD_IO_LATENCY_MAX_BUCKETS	20	/* Size of array range */
45 
46 /* Masks for ELS Commands */
47 #define	SD_ELS_SUBCATEGORY_PLOGI_RCV	0x01
48 #define	SD_ELS_SUBCATEGORY_PRLO_RCV	0x02
49 #define	SD_ELS_SUBCATEGORY_ADISC_RCV	0x04
50 #define	SD_ELS_SUBCATEGORY_LSRJT_RCV	0x08
51 #define	SD_ELS_SUBCATEGORY_LOGO_RCV	0x10
52 #define	SD_ELS_SUBCATEGORY_RSCN_RCV	0x20
53 
54 /* Masks for Fabric events */
55 #define	SD_FABRIC_SUBCATEGORY_FABRIC_BUSY	0x01
56 #define	SD_FABRIC_SUBCATEGORY_PORT_BUSY		0x02
57 #define	SD_FABRIC_SUBCATEGORY_FCPRDCHKERR	0x04
58 
59 /* Masks for SCSI events */
60 #define	SD_SCSI_SUBCATEGORY_QFULL			0x0001
61 #define	SD_SCSI_SUBCATEGORY_DEVBSY			0x0002
62 #define	SD_SCSI_SUBCATEGORY_CHECKCONDITION		0x0004
63 #define	SD_SCSI_SUBCATEGORY_LUNRESET			0x0008
64 #define	SD_SCSI_SUBCATEGORY_TGTRESET			0x0010
65 #define	SD_SCSI_SUBCATEGORY_BUSRESET			0x0020
66 #define	SD_SCSI_SUBCATEGORY_VARQUEDEPTH			0x0040
67 
68 /* Masks for Board Events */
69 #define	SD_BOARD_SUBCATEGORY_PORTINTERR		0x01
70 #define	SD_BOARD_SUBCATEGORY_LINKATTE		0x02
71 
72 /* Masks for Adapter Events */
73 #define	SD_ADAPTER_SUBCATEGORY_ARRIVAL		0x01
74 #define	SD_ADAPTER_SUBCATEGORY_DEPARTURE	0x02
75 
76 /* Struct to hold SCSI IO Latency statistics per bucket */
77 struct SD_time_stats_v0 {
78 	int sd_tstats_bucket_count;
79 };
80 
81 /* Struct per target for SCSI IO Latency */
82 struct SD_IO_Latency_Response {
83 	HBA_WWN sd_iolatency_target_wwpn;
84 	/* Size of array depends on range size */
85 	struct SD_time_stats_v0 sd_time_stats_array[SD_IO_LATENCY_MAX_BUCKETS];
86 };
87 
88 /* Return Codes */
89 enum SD_RETURN_CODES {
90 	SD_OK,
91 	SD_ERROR_GENERIC,
92 	SD_ERROR_ARG,
93 	SD_ERROR_INVALID_BOARD_ID,
94 	SD_ERROR_INVALID_VPORT,
95 	SD_ERROR_NOT_SUPPORTED,
96 	SD_ERROR_CATEGORY_NOT_SUPPORTED,
97 	SD_ERROR_SUBCATEGORY_NOT_SUPPORTED,
98 	SD_ERROR_MORE_DATA_AVAILABLE,
99 	SD_ERROR_EVENT_ALREADY_REGISTERED,
100 	SD_ERROR_NO_ACTIVE_REGISTRATION,
101 	SD_ERROR_ARG_MISSING,
102 	SD_ERROR_NO_MEMORY,
103 	SD_ERROR_BUCKET_NOTSET,
104 	SD_ERROR_REG_HANDLE,
105 	SD_ERROR_INVALID_SEARCH_TYPE,
106 	SD_ERROR_FUNCTION_NOT_SUPPORTED,
107 	SD_ERROR_OUT_OF_HANDLES,
108 	SD_ERROR_LIB_NOT_INIT,
109 	SD_ERROR_DATA_COLLECTION_ACTIVE,
110 	SD_ERROR_DATA_COLLECTION_NOT_ACTIVE,
111 	SD_MAX_RETURN_CODES
112 };
113 
114 
115 #define	SD_SEARCH_LINEAR	0x01
116 #define	SD_SEARCH_POWER_2	0x02
117 
118 
119 extern uint32_t	DFC_SD_Get_Granularity(void);
120 
121 extern int32_t	DFC_SD_Set_Bucket(uint16_t type,
122 				uint16_t search_type,
123 				uint32_t base,
124 				uint32_t step);
125 
126 extern int32_t	DFC_SD_Destroy_Bucket(uint16_t type);
127 
128 extern int32_t	DFC_SD_Get_Bucket(uint16_t type,
129 				uint16_t *search_type,
130 				uint32_t *base,
131 				uint32_t *step,
132 				uint64_t *values);
133 
134 extern int32_t	DFC_SD_Start_Data_Collection(uint32_t board,
135 				HBA_WWN port_id,
136 				uint16_t type,
137 				void *arg);
138 
139 extern int32_t	DFC_SD_Stop_Data_Collection(uint32_t board,
140 				HBA_WWN port_id,
141 				uint16_t type);
142 
143 extern int32_t	DFC_SD_Reset_Data_Collection(uint32_t board,
144 				HBA_WWN port_id,
145 				uint16_t type);
146 
147 extern int32_t	DFC_SD_Get_Data(uint32_t board,
148 				HBA_WWN port_id,
149 				uint16_t type,
150 				uint16_t *target,
151 				uint32_t buf_size,
152 				void *buff);
153 
154 #define	SD_REG_ELS_EVENT	0x01
155 #define	SD_REG_FABRIC_EVENT	0x02
156 #define	SD_REG_SCSI_EVENT	0x04
157 #define	SD_REG_BOARD_EVENT	0x08
158 #define	SD_REG_ADAPTER_EVENT	0x10
159 
160 
161 #define	SD_ELS_SUBCATEGORY_VALID_MASK	(SD_ELS_SUBCATEGORY_PLOGI_RCV | \
162 	SD_ELS_SUBCATEGORY_PRLO_RCV | SD_ELS_SUBCATEGORY_ADISC_RCV | \
163 	SD_ELS_SUBCATEGORY_LSRJT_RCV | SD_ELS_SUBCATEGORY_LOGO_RCV | \
164 	SD_ELS_SUBCATEGORY_RSCN_RCV)
165 
166 
167 /* Generic Payload */
168 struct sd_event {
169 	uint32_t	sd_evt_version;
170 	size_t		sd_evt_size;
171 	void		*sd_evt_payload;
172 };
173 
174 
175 struct sd_els_event_details_v0 {
176 	uint32_t	sd_elsevt_version;
177 	void		*sd_elsevt_payload;
178 };
179 
180 
181 struct sd_plogi_rcv_v0 {
182 	uint32_t	sd_plogir_version;
183 	HBA_WWN		sd_plogir_portname;
184 	HBA_WWN		sd_plogir_nodename;
185 };
186 
187 
188 struct sd_prlo_rcv_v0 {
189 	uint32_t	sd_prlor_version;
190 	HBA_WWN		sd_prlor_remoteport;
191 };
192 
193 
194 struct sd_lsrjt_rcv_v0 {
195 	uint32_t	sd_lsrjtr_version;
196 	HBA_WWN		sd_lsrjtr_remoteport;
197 	uint32_t	sd_lsrjtr_original_cmd;
198 	uint32_t	sd_lsrjtr_reasoncode;
199 	uint32_t	sd_lsrjtr_reasoncodeexpl;
200 };
201 
202 
203 struct sd_adisc_rcv_v0 {
204 	uint32_t	sd_adiscr_version;
205 	HBA_WWN		sd_adiscr_portname;
206 	HBA_WWN		sd_adiscr_nodename;
207 };
208 
209 
210 #define	SD_FABRIC_SUBCATEGORY_VALID_MASK	(\
211 	SD_FABRIC_SUBCATEGORY_FABRIC_BUSY | SD_FABRIC_SUBCATEGORY_PORT_BUSY | \
212 	SD_FABRIC_SUBCATEGORY_FCPRDCHKERR)
213 
214 
215 struct sd_fabric_event_details_v0 {
216 	uint32_t	sd_fabric_evt_version;
217 	void		*sd_fabric_evt_payload;
218 };
219 
220 
221 struct sd_pbsy_rcv_v0 {
222 	uint32_t	sd_pbsyr_evt_version;
223 	HBA_WWN		sd_pbsyr_rport;
224 };
225 
226 
227 struct sd_fcprdchkerr_v0 {
228 	uint32_t	sd_fcprdchkerr_version;
229 	HBA_WWN		sd_fcprdchkerr_rport;
230 	uint32_t	sd_fcprdchkerr_lun;
231 	uint32_t	sd_fcprdchkerr_opcode;
232 	uint32_t	sd_fcprdchkerr_fcpiparam;
233 };
234 
235 
236 #define	SD_SCSI_SUBCATEGORY_VALID_MASK	(\
237 	SD_SCSI_SUBCATEGORY_QFULL | SD_SCSI_SUBCATEGORY_DEVBSY | \
238 	SD_SCSI_SUBCATEGORY_CHECKCONDITION | SD_SCSI_SUBCATEGORY_LUNRESET | \
239 	SD_SCSI_SUBCATEGORY_TGTRESET | SD_SCSI_SUBCATEGORY_BUSRESET | \
240 	SD_SCSI_SUBCATEGORY_VARQUEDEPTH)
241 
242 struct sd_scsi_event_details_v0 {
243 	uint32_t	sd_scsi_evt_version;
244 	void		*sd_scsi_evt_payload;
245 };
246 
247 
248 struct sd_scsi_generic_v0 {
249 	uint32_t	sd_scsi_generic_version;
250 	HBA_WWN		sd_scsi_generic_rport;
251 	int32_t		sd_scsi_generic_lun;
252 };
253 
254 
255 struct sd_scsi_checkcond_v0 {
256 	uint32_t	sd_scsi_checkcond_version;
257 	HBA_WWN		sd_scsi_checkcond_rport;
258 	uint32_t	sd_scsi_checkcond_lun;
259 	uint32_t	sd_scsi_checkcond_cmdcode;
260 	uint32_t	sd_scsi_checkcond_sensekey;
261 	uint32_t	sd_scsi_checkcond_asc;
262 	uint32_t	sd_scsi_checkcond_ascq;
263 };
264 
265 
266 struct sd_scsi_varquedepth_v0 {
267 	uint32_t	sd_varquedepth_version;
268 	HBA_WWN		sd_varquedepth_rport;
269 	int32_t		sd_varquedepth_lun;
270 	uint32_t	sd_varquedepth_oldval;
271 	uint32_t	sd_varquedepth_newval;
272 };
273 
274 
275 /* Prototype for callback */
276 typedef void sd_callback(uint32_t board_id,
277 			HBA_WWN 	ort_id,
278 			uint32_t	category,
279 			uint32_t	subcategory,
280 			void		*context,
281 			struct sd_event	*sd_data);
282 
283 /* Register for event */
284 extern int32_t DFC_SD_RegisterForEvent(uint32_t board_id,
285 				HBA_WWN		port_id,
286 				uint32_t	category,
287 				uint32_t	subcategory,
288 				void		*context,
289 				uint32_t	*reg_handle,
290 				sd_callback	*func);
291 
292 
293 /* Deregister a event */
294 extern int32_t DFC_SD_unRegisterForEvent(uint32_t board_id,
295 				HBA_WWN		vport_id,
296 				uint32_t	reg_handle);
297 
298 
299 #ifdef	__cplusplus
300 }
301 #endif
302 
303 #endif	/* _EMLXS_SDAPI_H */
304