xref: /illumos-gate/usr/src/uts/common/sys/scsi/adapters/mpapi_impl.h (revision d6bb6a8465e557cb946ef49d56ed3202f6218652)
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 usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
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  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef _SYS_SCSI_ADAPTERS_MPAPI_IMPL_H
27 #define	_SYS_SCSI_ADAPTERS_MPAPI_IMPL_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #include <sys/sunmdi.h>
32 #include <sys/sunddi.h>
33 #include <sys/mdi_impldefs.h>
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
39 #if !defined(_BIT_FIELDS_LTOH) && !defined(_BIT_FIELDS_HTOL)
40 #error  One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined
41 #endif  /* _BIT_FIELDS_LTOH */
42 
43 /*
44  * All the structures (except mp_iocdata_t) are 64-bit aligned (padded,
45  * where necessary) to facilitate the use of the same structure for
46  * handling ioctl calls made by both 32-bit and 64-bit applications.
47  * There are no pointers to other structures inside these structures
48  * as copyout to user land may not produce desired result.
49  * The caddr_t structure is kept at the end due to the undeterminstic
50  * size it could accrue to its parent structure.
51  */
52 
53 /* Structure for MP_PLUGIN_PROPERTIES */
54 
55 typedef struct mp_driver_prop {
56 	char		driverVersion[256];
57 	uint32_t	supportedLoadBalanceTypes;
58 	boolean_t	canSetTPGAccess;
59 	boolean_t	canOverridePaths;
60 	boolean_t	exposesPathDeviceFiles;
61 	char		deviceFileNamespace[256];
62 	uint32_t	onlySupportsSpecifiedProducts;
63 	uint32_t	maximumWeight;
64 	uint32_t	failbackPollingRateMax;
65 	uint32_t	currentFailbackPollingRate;
66 	uint32_t	autoFailbackSupport;
67 	uint32_t	autoFailbackEnabled;
68 	uint32_t	defaultLoadBalanceType;
69 	uint32_t	probingPollingRateMax;
70 	uint32_t	currentProbingPollingRate;
71 	uint32_t	autoProbingSupport;
72 	uint32_t	autoProbingEnabled;
73 	uint32_t	proprietaryPropSize;
74 	caddr_t		proprietaryProp;
75 } mp_driver_prop_t;
76 
77 
78 /* Size of "proprietaryProp" field */
79 
80 #define	MP_MAX_PROP_BUF_SIZE				1024
81 
82 
83 /* Constants for autoFailbackSupport */
84 
85 /*
86  * Both MP_DRVR_AUTO_FAILBACK_SUPPORT and
87  * MP_DRVR_AUTO_FAILBACK_SUPPORT_LU
88  * can be supported at the same time.
89  */
90 
91 #define	MP_DRVR_AUTO_FAILBACK_SUPPORT_NONE		0
92 #define	MP_DRVR_AUTO_FAILBACK_SUPPORT			(1<<0)
93 #define	MP_DRVR_AUTO_FAILBACK_SUPPORT_LU		(1<<1)
94 
95 
96 
97 /*
98  * Declaration of the MP_LOAD_BALANCE_TYPE constants - should be
99  * the same defines as in mpapi.h
100  */
101 #define	MP_DRVR_LOAD_BALANCE_TYPE_NONE			0
102 #define	MP_DRVR_LOAD_BALANCE_TYPE_UNKNOWN		(1<<0)
103 #define	MP_DRVR_LOAD_BALANCE_TYPE_ROUNDROBIN		(1<<1)
104 #define	MP_DRVR_LOAD_BALANCE_TYPE_LEASTBLOCKS		(1<<2)
105 #define	MP_DRVR_LOAD_BALANCE_TYPE_LEASTIO		(1<<3)
106 #define	MP_DRVR_LOAD_BALANCE_TYPE_DEVICE_PRODUCT	(1<<4)
107 #define	MP_DRVR_LOAD_BALANCE_TYPE_LBA_REGION		(1<<5)
108 #define	MP_DRVR_LOAD_BALANCE_TYPE_FAILOVER_ONLY		(1<<6)
109 /*
110  * Proprietary load balance type should start from 0x10000(1<<16) or greater.
111  * It is exposed through API MP_GetProprietaryLoadBalanceProperties if exists.
112  */
113 #define	MP_DRVR_LOAD_BALANCE_TYPE_PROPRIETARY1		(1<<16)
114 #define	MP_DRVR_LOAD_BALANCE_TYPE_PROPRIETARY2		(1<<17)
115 
116 /* Constants for autoProbingSupport */
117 
118 /*
119  * Both MP_DRVR_AUTO_PROBING_SUPPORT and
120  * MP_DRVR_AUTO_PROBING_SUPPORT_LU
121  * can be supported at the same time.
122  */
123 
124 #define	MP_DRVR_AUTO_PROBING_SUPPORT_NONE		0
125 #define	MP_DRVR_AUTO_PROBING_SUPPORT			(1<<0)
126 #define	MP_DRVR_AUTO_PROBING_SUPPORT_LU			(1<<1)
127 
128 
129 /* Structures for MP_DEVICE_PRODUCT_PROPERTIES */
130 
131 typedef struct mp_vendor_prod_info {
132 	char	vendor[8];
133 	char	product[16];
134 	char	revision[4];
135 	char	reserved[4]; /* padding for 64bit alignment */
136 } mp_vendor_prod_info_t;
137 
138 typedef struct mp_dev_prod_prop {
139 	struct mp_vendor_prod_info	prodInfo;
140 	uint32_t			supportedLoadBalanceTypes;
141 	uint32_t			reserved; /* 64bit alignment padding */
142 	uint64_t			id;
143 } mp_dev_prod_prop_t;
144 
145 
146 /* Structure for MP_MULTIPATH_LOGICAL_UNIT_PROPERTIES */
147 
148 typedef struct mp_logical_unit_prop {
149 	struct mp_vendor_prod_info	prodInfo;
150 	char				name[256];  /* guid */
151 	uint32_t			nameType;
152 	uint32_t			luGroupID;
153 	char				deviceFileName[256];
154 	uint64_t			id;
155 	boolean_t			asymmetric;
156 	uint32_t			currentLoadBalanceType;
157 	boolean_t			autoFailbackEnabled;
158 	uint32_t			failbackPollingRateMax;
159 	uint32_t			currentFailBackPollingRate;
160 	uint32_t			autoProbingEnabled;
161 	uint32_t			probingPollingRateMax;
162 	uint32_t			currentProbingPollingRate;
163 	uint64_t			overridePathID;
164 	boolean_t			overridePathInUse;
165 	uint32_t			proprietaryPropSize;
166 	caddr_t				proprietaryProp;
167 } mp_logical_unit_prop_t;
168 
169 
170 /* Constants for nameType */
171 
172 #define	MP_DRVR_NAME_TYPE_UNKNOWN		0
173 #define	MP_DRVR_NAME_TYPE_VPD83_TYPE1		1
174 #define	MP_DRVR_NAME_TYPE_VPD83_TYPE2		2
175 #define	MP_DRVR_NAME_TYPE_VPD83_TYPE3		3
176 #define	MP_DRVR_NAME_TYPE_DEVICE_SPECIFIC	4
177 
178 
179 /* Structure for MP_INITIATOR_PORT_PROPERTIES */
180 
181 typedef struct mp_init_port_prop {
182 	char		portID[256];
183 	char		osDeviceFile[256];
184 	uint32_t	portType;
185 	uint32_t	reserved; /* padding for 64bit alignment */
186 	uint64_t	id;
187 } mp_init_port_prop_t;
188 
189 
190 /* Constants for portType */
191 
192 #define	MP_DRVR_TRANSPORT_TYPE_UNKNOWN	0
193 #define	MP_DRVR_TRANSPORT_TYPE_FC	2
194 #define	MP_DRVR_TRANSPORT_TYPE_SPI	3
195 #define	MP_DRVR_TRANSPORT_TYPE_ISCSI	4
196 #define	MP_DRVR_TRANSPORT_TYPE_IFB	5
197 
198 
199 /* Structure for MP_TARGET_PORT_PROPERTIES */
200 
201 typedef struct mp_target_port_prop {
202 	char		portName[256];
203 	uint32_t	relativePortID;
204 	uint32_t	reserved; /* padding for 64bit alignment */
205 	uint64_t	id;
206 } mp_target_port_prop_t;
207 
208 
209 /* Structure for MP_TARGET_PORT_GROUP_PROPERTIES */
210 
211 typedef struct mp_tpg_prop {
212 	uint32_t	accessState;
213 	boolean_t	explicitFailover;
214 	uint32_t	tpgId; /* T10 defined id in report/set TPG */
215 	boolean_t	preferredLuPath;
216 	boolean_t	supportsLuAssignment;
217 	uint32_t	reserved; /* padding for 64bit alignment */
218 	uint64_t	id;
219 } mp_tpg_prop_t;
220 
221 
222 /* Constants for accessState */
223 
224 #define	MP_DRVR_ACCESS_STATE_ACTIVE_OPTIMIZED		0
225 #define	MP_DRVR_ACCESS_STATE_ACTIVE_NONOPTIMIZED	0x1
226 #define	MP_DRVR_ACCESS_STATE_STANDBY			0x2
227 #define	MP_DRVR_ACCESS_STATE_UNAVAILABLE		0x3
228 #define	MP_DRVR_ACCESS_STATE_TRANSITIONING		0xf
229 #define	MP_DRVR_ACCESS_STATE_ACTIVE			0x10
230 
231 
232 /* Structure for MP_PATH_LOGICAL_UNIT_PROPERTIES */
233 
234 typedef struct mp_path_prop {
235 	uint32_t			weight;
236 	uint32_t			pathState;
237 	boolean_t			disabled;
238 	uint32_t			reserved; /* 64bit alignment padding */
239 	uint64_t			id;
240 	struct mp_init_port_prop	initPort;
241 	struct mp_target_port_prop	targetPort;
242 	struct mp_logical_unit_prop	logicalUnit;
243 } mp_path_prop_t;
244 
245 
246 /* Constants for pathState */
247 
248 #define	MP_DRVR_PATH_STATE_ACTIVE		0
249 #define	MP_DRVR_PATH_STATE_PASSIVE		1
250 #define	MP_DRVR_PATH_STATE_PATH_ERR		2
251 #define	MP_DRVR_PATH_STATE_LU_ERR		3
252 #define	MP_DRVR_PATH_STATE_RESERVED		4
253 #define	MP_DRVR_PATH_STATE_REMOVED		5
254 #define	MP_DRVR_PATH_STATE_TRANSITIONING	6
255 #define	MP_DRVR_PATH_STATE_UNKNOWN		7
256 
257 
258 /* Structure for MP_PROPRIETARY_LOAD_BALANCE_PROPERTIES */
259 
260 typedef struct mp_proprietary_loadbalance_prop {
261 	char		name[256];
262 	char		vendorName[256];
263 	uint64_t	id;
264 	uint32_t	typeIndex;
265 	uint32_t	proprietaryPropSize;
266 	caddr_t		proprietaryProp;
267 } mp_proprietary_loadbalance_prop_t;
268 
269 
270 /*
271  * Structure used as input to
272  * MP_ASSIGN_LU_TO_TPG subcmd.
273  */
274 
275 typedef struct mp_lu_tpg_pair {
276 	uint64_t	luId;
277 	uint64_t	tpgId;
278 } mp_lu_tpg_pair_t;
279 
280 
281 /*
282  * Structure used as input to
283  * MP_SET_TPG_ACCESS_STATE subcmd.
284  */
285 
286 typedef struct mp_set_tpg_state_req {
287 	struct mp_lu_tpg_pair	luTpgPair;
288 	uint32_t		desiredState;
289 	uint32_t		reserved; /* padding for 64bit boundary */
290 } mp_set_tpg_state_req_t;
291 
292 
293 /*
294  * Structure for ioctl data
295  */
296 typedef struct mp_iocdata {
297 	uint16_t	mp_xfer;	/* direction */
298 	uint16_t	mp_cmd;		/* sub command */
299 	uint16_t	mp_flags;	/* flags */
300 	uint16_t	mp_cmd_flags;	/* command specific flags */
301 	size_t		mp_ilen;	/* Input buffer length */
302 	caddr_t		mp_ibuf;	/* Input buffer */
303 	size_t		mp_olen;	/* Output buffer length */
304 	caddr_t		mp_obuf;	/* Output buffer */
305 	size_t		mp_alen;	/* Auxiliary buffer length */
306 	caddr_t		mp_abuf;	/* Auxiliary buffer */
307 	int		mp_errno;	/* MPAPI driver internal error code */
308 } mp_iocdata_t;
309 
310 
311 #ifdef _KERNEL
312 
313 #if defined(_SYSCALL32)
314 
315 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
316 #pragma pack(4)
317 #endif
318 
319 /*
320  * Structure for 32-bit ioctl data
321  */
322 
323 typedef struct mp_iocdata32 {
324 	uint16_t	mp_xfer;	/* direction */
325 	uint16_t	mp_cmd;		/* sub command */
326 	uint16_t	mp_flags;	/* flags */
327 	uint16_t	mp_cmd_flags;	/* command specific flags */
328 	uint32_t	mp_ilen;	/* Input buffer length */
329 	caddr32_t	mp_ibuf;	/* Input buffer */
330 	uint32_t	mp_olen;	/* Output buffer length */
331 	caddr32_t	mp_obuf;	/* Output buffer */
332 	uint32_t	mp_alen;	/* Auxiliary buffer length */
333 	caddr32_t	mp_abuf;	/* Auxiliary buffer */
334 	int32_t		mp_errno;	/* MPAPI driver internal error code */
335 } mp_iocdata32_t;
336 
337 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
338 #pragma pack()
339 #endif
340 
341 #endif  /* _SYSCALL32 */
342 
343 #endif /* _KERNEL */
344 
345 
346 /* Constants for MP_XFER */
347 
348 #define	MP_XFER_NONE	0x00
349 #define	MP_XFER_READ	0x01
350 #define	MP_XFER_WRITE	0x02
351 #define	MP_XFER_RW	(MP_XFER_READ | MP_XFER_WRITE)
352 
353 
354 /* Constants for MP_OBJECT_TYPE */
355 
356 #define	MP_OBJECT_TYPE_UNKNOWN			0
357 #define	MP_OBJECT_TYPE_PLUGIN			1
358 #define	MP_OBJECT_TYPE_INITIATOR_PORT		2
359 #define	MP_OBJECT_TYPE_TARGET_PORT		3
360 #define	MP_OBJECT_TYPE_MULTIPATH_LU		4
361 #define	MP_OBJECT_TYPE_PATH_LU			5
362 #define	MP_OBJECT_TYPE_DEVICE_PRODUCT		6
363 #define	MP_OBJECT_TYPE_TARGET_PORT_GROUP	7
364 #define	MP_OBJECT_TYPE_PROPRIETARY_LOAD_BALANCE	8
365 #define	MP_OBJECT_TYPE_LAST_ENTRY 	MP_OBJECT_TYPE_PROPRIETARY_LOAD_BALANCE
366 #define	MP_MAX_OBJECT_TYPE	(MP_OBJECT_TYPE_LAST_ENTRY + 1)
367 
368 
369 /* Constants for MP_CMD */
370 
371 #define	MPAPI_CTL				('m'<<8)
372 #define	MP_CMD					(MPAPI_CTL | 2005)
373 #define	MP_SUB_CMD				('M'<<8)
374 
375 #define	MP_API_SUBCMD_MIN			(MP_SUB_CMD + 0x01)
376 #define	MP_GET_DRIVER_PROP			(MP_SUB_CMD + 0x01)
377 #define	MP_GET_DEV_PROD_LIST			(MP_SUB_CMD + 0x02)
378 #define	MP_GET_DEV_PROD_PROP			(MP_SUB_CMD + 0x03)
379 #define	MP_GET_LU_LIST				(MP_SUB_CMD + 0x04)
380 #define	MP_GET_LU_LIST_FROM_TPG			(MP_SUB_CMD + 0x05)
381 #define	MP_GET_LU_PROP				(MP_SUB_CMD + 0x06)
382 #define	MP_GET_PATH_LIST_FOR_MP_LU		(MP_SUB_CMD + 0x07)
383 #define	MP_GET_PATH_LIST_FOR_INIT_PORT		(MP_SUB_CMD + 0x08)
384 #define	MP_GET_PATH_LIST_FOR_TARGET_PORT	(MP_SUB_CMD + 0x09)
385 #define	MP_GET_PATH_PROP			(MP_SUB_CMD + 0x0a)
386 #define	MP_GET_INIT_PORT_LIST			(MP_SUB_CMD + 0x0b)
387 #define	MP_GET_INIT_PORT_PROP			(MP_SUB_CMD + 0x0c)
388 #define	MP_GET_TARGET_PORT_PROP			(MP_SUB_CMD + 0x0d)
389 #define	MP_GET_TPG_LIST				(MP_SUB_CMD + 0x0e)
390 #define	MP_GET_TPG_PROP				(MP_SUB_CMD + 0x0f)
391 #define	MP_GET_TPG_LIST_FOR_LU			(MP_SUB_CMD + 0x10)
392 #define	MP_GET_TARGET_PORT_LIST_FOR_TPG		(MP_SUB_CMD + 0x11)
393 #define	MP_SET_TPG_ACCESS_STATE			(MP_SUB_CMD + 0x12)
394 #define	MP_ENABLE_AUTO_FAILBACK			(MP_SUB_CMD + 0x13)
395 #define	MP_DISABLE_AUTO_FAILBACK 		(MP_SUB_CMD + 0x14)
396 #define	MP_ENABLE_PATH				(MP_SUB_CMD + 0x15)
397 #define	MP_DISABLE_PATH				(MP_SUB_CMD + 0x16)
398 #define	MP_GET_PROPRIETARY_LOADBALANCE_LIST	(MP_SUB_CMD + 0x17)
399 #define	MP_GET_PROPRIETARY_LOADBALANCE_PROP	(MP_SUB_CMD + 0x18)
400 #define	MP_ASSIGN_LU_TO_TPG			(MP_SUB_CMD + 0x19)
401 #define	MP_API_SUBCMD_MAX			(MP_ASSIGN_LU_TO_TPG)
402 
403 
404 /*
405  * Typical MP API ioctl interface specific Return Values
406  */
407 
408 #define	MP_IOCTL_ERROR_START			0x5533
409 #define	MP_MORE_DATA				(MP_IOCTL_ERROR_START + 1)
410 #define	MP_DRVR_INVALID_ID			(MP_IOCTL_ERROR_START + 2)
411 #define	MP_DRVR_ID_OBSOLETE			(MP_IOCTL_ERROR_START + 3)
412 #define	MP_DRVR_ACCESS_SYMMETRIC		(MP_IOCTL_ERROR_START + 4)
413 #define	MP_DRVR_PATH_UNAVAILABLE		(MP_IOCTL_ERROR_START + 5)
414 #define	MP_DRVR_IDS_NOT_ASSOCIATED		(MP_IOCTL_ERROR_START + 6)
415 #define	MP_DRVR_ILLEGAL_ACCESS_STATE_REQUEST	(MP_IOCTL_ERROR_START + 7)
416 
417 /*
418  * Macros for OID operations
419  */
420 #define	MP_ID_SHIFT4MAJOR		32
421 #define	MP_GET_MAJOR_FROM_ID(id)	((id) >> MP_ID_SHIFT4MAJOR)
422 #define	MP_GET_INST_FROM_ID(id)		((id) & 0x00000000ffffffff)
423 #define	MP_STORE_INST_TO_ID(inst, id)	(((uint64_t)(inst)) | id)
424 #define	MP_STORE_MAJOR_TO_ID(major, id)	\
425 	((((uint64_t)(major)) << MP_ID_SHIFT4MAJOR) | id)
426 
427 /*
428  * Event Class and Sub-Class definitions
429  */
430 #define	EC_SUN_MP			"EC_sun_mp"
431 
432 #define	ESC_SUN_MP_LU_CHANGE		"ESC_sun_mp_lu_change"
433 
434 #define	ESC_SUN_MP_PATH_CHANGE		"ESC_sun_mp_path_change"
435 #define	ESC_SUN_MP_PATH_ADD		"ESC_sun_mp_path_add"
436 #define	ESC_SUN_MP_PATH_REMOVE		"ESC_sun_mp_path_remove"
437 
438 #define	ESC_SUN_MP_INIT_PORT_CHANGE	"ESC_sun_mp_init_port_change"
439 
440 #define	ESC_SUN_MP_TPG_CHANGE		"ESC_sun_mp_tpg_change"
441 #define	ESC_SUN_MP_TPG_ADD		"ESC_sun_mp_tpg_add"
442 #define	ESC_SUN_MP_TPG_REMOVE		"ESC_sun_mp_tpg_remove"
443 
444 #define	ESC_SUN_MP_TARGET_PORT_CHANGE	"ESC_sun_mp_target_port_change"
445 #define	ESC_SUN_MP_TARGET_PORT_ADD	"ESC_sun_mp_target_port_add"
446 #define	ESC_SUN_MP_TARGET_PORT_REMOVE	"ESC_sun_mp_target_port_remove"
447 
448 #define	ESC_SUN_MP_DEV_PROD_CHANGE	"ESC_sun_mp_dev_prod_change"
449 #define	ESC_SUN_MP_DEV_PROD_ADD		"ESC_sun_mp_dev_prod_add"
450 #define	ESC_SUN_MP_DEV_PROD_REMOVE	"ESC_sun_mp_dev_prod_remove"
451 
452 #ifdef __cplusplus
453 }
454 #endif
455 
456 #endif /* _SYS_SCSI_ADAPTERS_MPAPI_IMPL_H */
457