xref: /onnv-gate/usr/src/uts/common/sys/stmf_ioctl.h (revision 9585:bf09620212ab)
17836SJohn.Forte@Sun.COM /*
27836SJohn.Forte@Sun.COM  * CDDL HEADER START
37836SJohn.Forte@Sun.COM  *
47836SJohn.Forte@Sun.COM  * The contents of this file are subject to the terms of the
57836SJohn.Forte@Sun.COM  * Common Development and Distribution License (the "License").
67836SJohn.Forte@Sun.COM  * You may not use this file except in compliance with the License.
77836SJohn.Forte@Sun.COM  *
87836SJohn.Forte@Sun.COM  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97836SJohn.Forte@Sun.COM  * or http://www.opensolaris.org/os/licensing.
107836SJohn.Forte@Sun.COM  * See the License for the specific language governing permissions
117836SJohn.Forte@Sun.COM  * and limitations under the License.
127836SJohn.Forte@Sun.COM  *
137836SJohn.Forte@Sun.COM  * When distributing Covered Code, include this CDDL HEADER in each
147836SJohn.Forte@Sun.COM  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157836SJohn.Forte@Sun.COM  * If applicable, add the following below this CDDL HEADER, with the
167836SJohn.Forte@Sun.COM  * fields enclosed by brackets "[]" replaced with your own identifying
177836SJohn.Forte@Sun.COM  * information: Portions Copyright [yyyy] [name of copyright owner]
187836SJohn.Forte@Sun.COM  *
197836SJohn.Forte@Sun.COM  * CDDL HEADER END
207836SJohn.Forte@Sun.COM  */
217836SJohn.Forte@Sun.COM /*
22*9585STim.Szeto@Sun.COM  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
237836SJohn.Forte@Sun.COM  * Use is subject to license terms.
247836SJohn.Forte@Sun.COM  */
257836SJohn.Forte@Sun.COM #ifndef	_STMF_IOCTL_H
267836SJohn.Forte@Sun.COM #define	_STMF_IOCTL_H
277836SJohn.Forte@Sun.COM 
287836SJohn.Forte@Sun.COM #ifdef	__cplusplus
297836SJohn.Forte@Sun.COM extern "C" {
307836SJohn.Forte@Sun.COM #endif
317836SJohn.Forte@Sun.COM 
327836SJohn.Forte@Sun.COM #define	STMF_VERSION_1			1
337836SJohn.Forte@Sun.COM 
347836SJohn.Forte@Sun.COM #define	STMF_IOCTL			(((uint32_t)'S') << 24)
357836SJohn.Forte@Sun.COM #define	STMF_IOCTL_LU_LIST			(STMF_IOCTL | 1)
367836SJohn.Forte@Sun.COM #define	STMF_IOCTL_TARGET_PORT_LIST		(STMF_IOCTL | 2)
377836SJohn.Forte@Sun.COM #define	STMF_IOCTL_SESSION_LIST			(STMF_IOCTL | 3)
387836SJohn.Forte@Sun.COM #define	STMF_IOCTL_GET_LU_PROPERTIES		(STMF_IOCTL | 4)
397836SJohn.Forte@Sun.COM #define	STMF_IOCTL_GET_TARGET_PORT_PROPERTIES	(STMF_IOCTL | 5)
407836SJohn.Forte@Sun.COM #define	STMF_IOCTL_SET_STMF_STATE		(STMF_IOCTL | 6)
417836SJohn.Forte@Sun.COM #define	STMF_IOCTL_GET_STMF_STATE		(STMF_IOCTL | 7)
427836SJohn.Forte@Sun.COM #define	STMF_IOCTL_SET_LU_STATE			(STMF_IOCTL | 8)
437836SJohn.Forte@Sun.COM #define	STMF_IOCTL_SET_TARGET_PORT_STATE	(STMF_IOCTL | 9)
447836SJohn.Forte@Sun.COM #define	STMF_IOCTL_CREATE_HOST_GROUP		(STMF_IOCTL | 10)
457836SJohn.Forte@Sun.COM #define	STMF_IOCTL_REMOVE_HOST_GROUP		(STMF_IOCTL | 11)
467836SJohn.Forte@Sun.COM #define	STMF_IOCTL_ADD_HG_ENTRY			(STMF_IOCTL | 12)
477836SJohn.Forte@Sun.COM #define	STMF_IOCTL_REMOVE_HG_ENTRY		(STMF_IOCTL | 13)
487836SJohn.Forte@Sun.COM #define	STMF_IOCTL_CREATE_TARGET_GROUP		(STMF_IOCTL | 14)
497836SJohn.Forte@Sun.COM #define	STMF_IOCTL_REMOVE_TARGET_GROUP		(STMF_IOCTL | 15)
507836SJohn.Forte@Sun.COM #define	STMF_IOCTL_ADD_TG_ENTRY			(STMF_IOCTL | 16)
517836SJohn.Forte@Sun.COM #define	STMF_IOCTL_REMOVE_TG_ENTRY		(STMF_IOCTL | 17)
527836SJohn.Forte@Sun.COM #define	STMF_IOCTL_ADD_VIEW_ENTRY		(STMF_IOCTL | 18)
537836SJohn.Forte@Sun.COM #define	STMF_IOCTL_REMOVE_VIEW_ENTRY		(STMF_IOCTL | 19)
547836SJohn.Forte@Sun.COM #define	STMF_IOCTL_GET_HG_LIST			(STMF_IOCTL | 20)
557836SJohn.Forte@Sun.COM #define	STMF_IOCTL_GET_TG_LIST			(STMF_IOCTL | 21)
567836SJohn.Forte@Sun.COM #define	STMF_IOCTL_GET_HG_ENTRIES		(STMF_IOCTL | 22)
577836SJohn.Forte@Sun.COM #define	STMF_IOCTL_GET_TG_ENTRIES		(STMF_IOCTL | 23)
587836SJohn.Forte@Sun.COM #define	STMF_IOCTL_GET_VE_LIST			(STMF_IOCTL | 24)
597836SJohn.Forte@Sun.COM #define	STMF_IOCTL_LOAD_PP_DATA			(STMF_IOCTL | 25)
607836SJohn.Forte@Sun.COM #define	STMF_IOCTL_CLEAR_PP_DATA		(STMF_IOCTL | 26)
61*9585STim.Szeto@Sun.COM #define	STMF_IOCTL_GET_PP_DATA			(STMF_IOCTL | 27)
62*9585STim.Szeto@Sun.COM #define	STMF_IOCTL_CLEAR_TRACE			(STMF_IOCTL | 28)
63*9585STim.Szeto@Sun.COM #define	STMF_IOCTL_ADD_TRACE			(STMF_IOCTL | 29)
64*9585STim.Szeto@Sun.COM #define	STMF_IOCTL_GET_TRACE_POSITION		(STMF_IOCTL | 30)
65*9585STim.Szeto@Sun.COM #define	STMF_IOCTL_GET_TRACE			(STMF_IOCTL | 31)
66*9585STim.Szeto@Sun.COM #define	STMF_IOCTL_REG_LU_LIST			(STMF_IOCTL | 32)
67*9585STim.Szeto@Sun.COM #define	STMF_IOCTL_VE_LU_LIST			(STMF_IOCTL | 33)
68*9585STim.Szeto@Sun.COM #define	STMF_IOCTL_LU_VE_LIST			(STMF_IOCTL | 34)
697836SJohn.Forte@Sun.COM 
707836SJohn.Forte@Sun.COM typedef	struct stmf_iocdata {
717836SJohn.Forte@Sun.COM 	uint32_t	stmf_version;
727836SJohn.Forte@Sun.COM 	uint32_t	stmf_error;
737836SJohn.Forte@Sun.COM 	uint32_t	stmf_ibuf_size;
747836SJohn.Forte@Sun.COM 	uint32_t	stmf_obuf_size;
757836SJohn.Forte@Sun.COM 	uint32_t	stmf_obuf_nentries;	/* # entries xferred */
767836SJohn.Forte@Sun.COM 	uint32_t	stmf_obuf_max_nentries;	/* #,could have been xferred */
777836SJohn.Forte@Sun.COM 	uint64_t	stmf_ibuf;
787836SJohn.Forte@Sun.COM 	uint64_t	stmf_obuf;
797836SJohn.Forte@Sun.COM } stmf_iocdata_t;
807836SJohn.Forte@Sun.COM 
817836SJohn.Forte@Sun.COM typedef	struct slist_lu {
827836SJohn.Forte@Sun.COM 	uint8_t		lu_guid[16];
837836SJohn.Forte@Sun.COM } slist_lu_t;
847836SJohn.Forte@Sun.COM 
857836SJohn.Forte@Sun.COM typedef	struct slist_target_port {
867836SJohn.Forte@Sun.COM 	uint8_t		target[260];
877836SJohn.Forte@Sun.COM } slist_target_port_t;
887836SJohn.Forte@Sun.COM 
897836SJohn.Forte@Sun.COM typedef	struct slist_scsi_session {
907836SJohn.Forte@Sun.COM 	uint8_t		initiator[260];
917836SJohn.Forte@Sun.COM 	/* creation_time is really time_t. But time_t is defined as long. */
927836SJohn.Forte@Sun.COM 	uint32_t	creation_time;
937836SJohn.Forte@Sun.COM 	char		alias[256];
947836SJohn.Forte@Sun.COM } slist_scsi_session_t;
957836SJohn.Forte@Sun.COM 
967836SJohn.Forte@Sun.COM /*
977836SJohn.Forte@Sun.COM  * States for LUs and LPORTs
987836SJohn.Forte@Sun.COM  */
997836SJohn.Forte@Sun.COM #define	STMF_STATE_OFFLINE		0
1007836SJohn.Forte@Sun.COM #define	STMF_STATE_ONLINING		1
1017836SJohn.Forte@Sun.COM #define	STMF_STATE_ONLINE		2
1027836SJohn.Forte@Sun.COM #define	STMF_STATE_OFFLINING		3
1037836SJohn.Forte@Sun.COM 
1047836SJohn.Forte@Sun.COM /*
1057836SJohn.Forte@Sun.COM  * States for the STMF config.
1067836SJohn.Forte@Sun.COM  */
1077836SJohn.Forte@Sun.COM #define	STMF_CONFIG_NONE		0
1087836SJohn.Forte@Sun.COM #define	STMF_CONFIG_INIT		1
1097836SJohn.Forte@Sun.COM #define	STMF_CONFIG_INIT_DONE		2
1107836SJohn.Forte@Sun.COM 
1117836SJohn.Forte@Sun.COM typedef struct sioc_lu_props {
1127836SJohn.Forte@Sun.COM 	uint8_t		lu_guid[16];
1137836SJohn.Forte@Sun.COM 	uint8_t		lu_state:4,
1147836SJohn.Forte@Sun.COM 			lu_present:1,
1157836SJohn.Forte@Sun.COM 			lu_rsvd:3;
1167836SJohn.Forte@Sun.COM 	char		lu_provider_name[255];
1177836SJohn.Forte@Sun.COM 	char		lu_alias[256];
1187836SJohn.Forte@Sun.COM } sioc_lu_props_t;
1197836SJohn.Forte@Sun.COM 
1207836SJohn.Forte@Sun.COM typedef struct sioc_target_port_props {
1217836SJohn.Forte@Sun.COM 	uint8_t		tgt_id[260];
1227836SJohn.Forte@Sun.COM 	uint8_t		tgt_state:4,
1237836SJohn.Forte@Sun.COM 			tgt_present:1,
1247836SJohn.Forte@Sun.COM 			tgt_rsvd:3;
1257836SJohn.Forte@Sun.COM 	char		tgt_provider_name[255];
1267836SJohn.Forte@Sun.COM 	char		tgt_alias[256];
1277836SJohn.Forte@Sun.COM } sioc_target_port_props_t;
1287836SJohn.Forte@Sun.COM 
1297836SJohn.Forte@Sun.COM /*
1307836SJohn.Forte@Sun.COM  * This struct is used for getting and setting state of LU/LPORT or STMF.
1317836SJohn.Forte@Sun.COM  */
1327836SJohn.Forte@Sun.COM typedef struct stmf_state_desc {
1337836SJohn.Forte@Sun.COM 	uint8_t		ident[260];	/* N/A for STMF itself */
1347836SJohn.Forte@Sun.COM 	uint8_t		state;
1357836SJohn.Forte@Sun.COM 	uint8_t		config_state;	/* N/A for LU/LPORTs */
1367836SJohn.Forte@Sun.COM } stmf_state_desc_t;
1377836SJohn.Forte@Sun.COM 
138*9585STim.Szeto@Sun.COM /* Error definitions for group/view entry/provider dataioctls */
1397836SJohn.Forte@Sun.COM #define	STMF_IOCERR_NONE			0
1407836SJohn.Forte@Sun.COM #define	STMF_IOCERR_HG_EXISTS			1
1417836SJohn.Forte@Sun.COM #define	STMF_IOCERR_INVALID_HG			2
1427836SJohn.Forte@Sun.COM #define	STMF_IOCERR_TG_EXISTS			3
1437836SJohn.Forte@Sun.COM #define	STMF_IOCERR_INVALID_TG			4
1447836SJohn.Forte@Sun.COM #define	STMF_IOCERR_HG_ENTRY_EXISTS		5
1457836SJohn.Forte@Sun.COM #define	STMF_IOCERR_INVALID_HG_ENTRY		6
1467836SJohn.Forte@Sun.COM #define	STMF_IOCERR_TG_ENTRY_EXISTS		7
1477836SJohn.Forte@Sun.COM #define	STMF_IOCERR_INVALID_TG_ENTRY		8
1487836SJohn.Forte@Sun.COM #define	STMF_IOCERR_TG_UPDATE_NEED_SVC_OFFLINE	9
1497836SJohn.Forte@Sun.COM #define	STMF_IOCERR_LU_NUMBER_IN_USE		10
1507836SJohn.Forte@Sun.COM #define	STMF_IOCERR_INVALID_LU_ID		11
1517836SJohn.Forte@Sun.COM #define	STMF_IOCERR_VIEW_ENTRY_CONFLICT		12
1527836SJohn.Forte@Sun.COM #define	STMF_IOCERR_HG_IN_USE			13
1537836SJohn.Forte@Sun.COM #define	STMF_IOCERR_TG_IN_USE			14
1547836SJohn.Forte@Sun.COM #define	STMF_IOCERR_INVALID_VIEW_ENTRY		15
1557836SJohn.Forte@Sun.COM #define	STMF_IOCERR_INVALID_VE_ID		16
1567836SJohn.Forte@Sun.COM #define	STMF_IOCERR_UPDATE_NEED_CFG_INIT	17
157*9585STim.Szeto@Sun.COM #define	STMF_IOCERR_PPD_UPDATED			18
158*9585STim.Szeto@Sun.COM #define	STMF_IOCERR_INSUFFICIENT_BUF		19
159*9585STim.Szeto@Sun.COM 
1607836SJohn.Forte@Sun.COM 
1617836SJohn.Forte@Sun.COM typedef struct stmf_group_name {
1627836SJohn.Forte@Sun.COM 	uint16_t	name_size;	/* in bytes */
1637836SJohn.Forte@Sun.COM 	uint16_t	rsvd_1;
1647836SJohn.Forte@Sun.COM 	uint32_t	rsvd_2;
1657836SJohn.Forte@Sun.COM 	uint8_t		name[512];	/* 256 * wchar_t */
1667836SJohn.Forte@Sun.COM } stmf_group_name_t;
1677836SJohn.Forte@Sun.COM 
1687836SJohn.Forte@Sun.COM /*
1697836SJohn.Forte@Sun.COM  * struct used to operate (add/remove entry) on a group.
1707836SJohn.Forte@Sun.COM  */
171*9585STim.Szeto@Sun.COM 
172*9585STim.Szeto@Sun.COM typedef struct stmf_ge_ident {
173*9585STim.Szeto@Sun.COM 	uint16_t    ident_size;
174*9585STim.Szeto@Sun.COM 	uint8_t	    ident[256];
175*9585STim.Szeto@Sun.COM } stmf_ge_ident_t;
1767836SJohn.Forte@Sun.COM 
1777836SJohn.Forte@Sun.COM typedef struct stmf_group_op_data {
1787836SJohn.Forte@Sun.COM 	stmf_group_name_t	group;
1797836SJohn.Forte@Sun.COM 	uint8_t			ident[260];
1807836SJohn.Forte@Sun.COM } stmf_group_op_data_t;
1817836SJohn.Forte@Sun.COM 
1827836SJohn.Forte@Sun.COM typedef struct stmf_view_op_entry {
1837836SJohn.Forte@Sun.COM 	uint32_t		ve_ndx_valid:1,
1847836SJohn.Forte@Sun.COM 				ve_lu_number_valid:1,
1857836SJohn.Forte@Sun.COM 				ve_all_hosts:1,
1867836SJohn.Forte@Sun.COM 				ve_all_targets:1,
1877836SJohn.Forte@Sun.COM 				rsvd:28;
1887836SJohn.Forte@Sun.COM 	uint32_t		ve_ndx;
1897836SJohn.Forte@Sun.COM 	uint8_t			ve_lu_nbr[8];
1907836SJohn.Forte@Sun.COM 	uint8_t			ve_guid[16];
1917836SJohn.Forte@Sun.COM 	stmf_group_name_t	ve_host_group;
1927836SJohn.Forte@Sun.COM 	stmf_group_name_t	ve_target_group;
1937836SJohn.Forte@Sun.COM } stmf_view_op_entry_t;
1947836SJohn.Forte@Sun.COM 
1957836SJohn.Forte@Sun.COM typedef struct stmf_ppioctl_data {
1967836SJohn.Forte@Sun.COM 	char		ppi_name[255];	/* Provider name including \0 */
1977836SJohn.Forte@Sun.COM 	uint8_t		ppi_port_provider:1,
1987836SJohn.Forte@Sun.COM 			ppi_lu_provider:1,
199*9585STim.Szeto@Sun.COM 			ppi_token_valid:1,
200*9585STim.Szeto@Sun.COM 			ppt_rsvd:5;
201*9585STim.Szeto@Sun.COM 	uint64_t	ppi_token;
2027836SJohn.Forte@Sun.COM 	uint64_t	ppi_data_size;
2037836SJohn.Forte@Sun.COM 	uint8_t		ppi_data[8];
2047836SJohn.Forte@Sun.COM } stmf_ppioctl_data_t;
2057836SJohn.Forte@Sun.COM 
2067836SJohn.Forte@Sun.COM /*
2077836SJohn.Forte@Sun.COM  * SCSI device ID descriptor as per SPC3 7.6.3
2087836SJohn.Forte@Sun.COM  */
2097836SJohn.Forte@Sun.COM typedef struct scsi_devid_desc {
2107836SJohn.Forte@Sun.COM #ifdef	_BIT_FIELDS_HTOL
2117836SJohn.Forte@Sun.COM 	uint8_t		protocol_id:4,
2127836SJohn.Forte@Sun.COM 			code_set:4;
2137836SJohn.Forte@Sun.COM 	uint8_t		piv:1,
2147836SJohn.Forte@Sun.COM 			rsvd1:1,
2157836SJohn.Forte@Sun.COM 			association:2,
2167836SJohn.Forte@Sun.COM 			ident_type:4;
2177836SJohn.Forte@Sun.COM #else
2187836SJohn.Forte@Sun.COM 	uint8_t		code_set:4,
2197836SJohn.Forte@Sun.COM 			protocol_id:4;
2207836SJohn.Forte@Sun.COM 	uint8_t		ident_type:4,
2217836SJohn.Forte@Sun.COM 			association:2,
2227836SJohn.Forte@Sun.COM 			rsvd1:1,
2237836SJohn.Forte@Sun.COM 			piv:1;
2247836SJohn.Forte@Sun.COM #endif
2257836SJohn.Forte@Sun.COM 	uint8_t		rsvd2;
2267836SJohn.Forte@Sun.COM 	uint8_t		ident_length;
2277836SJohn.Forte@Sun.COM 	uint8_t		ident[1];
2287836SJohn.Forte@Sun.COM } scsi_devid_desc_t;
2297836SJohn.Forte@Sun.COM 
2307836SJohn.Forte@Sun.COM /*
2317836SJohn.Forte@Sun.COM  * Protocol Identifier
2327836SJohn.Forte@Sun.COM  */
2337836SJohn.Forte@Sun.COM #define	PROTOCOL_FIBRE_CHANNEL		0
2347836SJohn.Forte@Sun.COM #define	PROTOCOL_PARALLEL_SCSI		1
2357836SJohn.Forte@Sun.COM #define	PROTOCOL_SSA			2
2367836SJohn.Forte@Sun.COM #define	PROTOCOL_IEEE_1394		3
2377836SJohn.Forte@Sun.COM #define	PROTOCOL_SRP			4
2387836SJohn.Forte@Sun.COM #define	PROTOCOL_iSCSI			5
2397836SJohn.Forte@Sun.COM #define	PROTOCOL_SAS			6
2407836SJohn.Forte@Sun.COM #define	PROTOCOL_ADT			7
2417836SJohn.Forte@Sun.COM #define	PROTOCOL_ATAPI			8
2427836SJohn.Forte@Sun.COM #define	PROTOCOL_ANY			15
2437836SJohn.Forte@Sun.COM 
2447836SJohn.Forte@Sun.COM /*
2457836SJohn.Forte@Sun.COM  * Code set definitions
2467836SJohn.Forte@Sun.COM  */
2477836SJohn.Forte@Sun.COM #define	CODE_SET_BINARY			1
2487836SJohn.Forte@Sun.COM #define	CODE_SET_ASCII			2
2497836SJohn.Forte@Sun.COM #define	CODE_SET_UTF8			3
2507836SJohn.Forte@Sun.COM 
2517836SJohn.Forte@Sun.COM /*
2527836SJohn.Forte@Sun.COM  * Association values
2537836SJohn.Forte@Sun.COM  */
2547836SJohn.Forte@Sun.COM #define	ID_IS_LOGICAL_UNIT		0
2557836SJohn.Forte@Sun.COM #define	ID_IS_TARGET_PORT		1
2567836SJohn.Forte@Sun.COM #define	ID_IS_TARGET_CONTAINING_LU	2
2577836SJohn.Forte@Sun.COM 
2587836SJohn.Forte@Sun.COM /*
2597836SJohn.Forte@Sun.COM  * ident type
2607836SJohn.Forte@Sun.COM  */
2617836SJohn.Forte@Sun.COM #define	ID_TYPE_VENDOR_SPECIFIC		0
2627836SJohn.Forte@Sun.COM #define	ID_TYPE_T10_VID			1
2637836SJohn.Forte@Sun.COM #define	ID_TYPE_EUI64			2
2647836SJohn.Forte@Sun.COM #define	ID_TYPE_NAA			3
2657836SJohn.Forte@Sun.COM #define	ID_TYPE_RELATIVE_TARGET_PORT	4
2667836SJohn.Forte@Sun.COM #define	ID_TYPE_TARGET_PORT_GROUP	5
2677836SJohn.Forte@Sun.COM #define	ID_TYPE_LOGICAL_UNIT_GROUP	6
2687836SJohn.Forte@Sun.COM #define	ID_TYPE_MD5_LOGICAL_UNIT	7
2697836SJohn.Forte@Sun.COM #define	ID_TYPE_SCSI_NAME_STRING	8
2707836SJohn.Forte@Sun.COM 
2717836SJohn.Forte@Sun.COM int stmf_copyin_iocdata(intptr_t data, int mode, stmf_iocdata_t **iocd,
2727836SJohn.Forte@Sun.COM     void **ibuf, void **obuf);
2737836SJohn.Forte@Sun.COM int stmf_copyout_iocdata(intptr_t data, int mode, stmf_iocdata_t *iocd,
2747836SJohn.Forte@Sun.COM     void *obuf);
2757836SJohn.Forte@Sun.COM 
2767836SJohn.Forte@Sun.COM #ifdef	__cplusplus
2777836SJohn.Forte@Sun.COM }
2787836SJohn.Forte@Sun.COM #endif
2797836SJohn.Forte@Sun.COM 
2807836SJohn.Forte@Sun.COM #endif /* _STMF_IOCTL_H */
281