xref: /onnv-gate/usr/src/uts/common/sys/stmf_ioctl.h (revision 10691:36de6b202f7e)
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 /*
229585STim.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)
619585STim.Szeto@Sun.COM #define	STMF_IOCTL_GET_PP_DATA			(STMF_IOCTL | 27)
629585STim.Szeto@Sun.COM #define	STMF_IOCTL_CLEAR_TRACE			(STMF_IOCTL | 28)
639585STim.Szeto@Sun.COM #define	STMF_IOCTL_ADD_TRACE			(STMF_IOCTL | 29)
649585STim.Szeto@Sun.COM #define	STMF_IOCTL_GET_TRACE_POSITION		(STMF_IOCTL | 30)
659585STim.Szeto@Sun.COM #define	STMF_IOCTL_GET_TRACE			(STMF_IOCTL | 31)
669585STim.Szeto@Sun.COM #define	STMF_IOCTL_REG_LU_LIST			(STMF_IOCTL | 32)
679585STim.Szeto@Sun.COM #define	STMF_IOCTL_VE_LU_LIST			(STMF_IOCTL | 33)
689585STim.Szeto@Sun.COM #define	STMF_IOCTL_LU_VE_LIST			(STMF_IOCTL | 34)
69*10691STim.Szeto@Sun.COM #define	STMF_IOCTL_VALIDATE_VIEW		(STMF_IOCTL | 35)
707836SJohn.Forte@Sun.COM 
717836SJohn.Forte@Sun.COM typedef	struct stmf_iocdata {
727836SJohn.Forte@Sun.COM 	uint32_t	stmf_version;
737836SJohn.Forte@Sun.COM 	uint32_t	stmf_error;
747836SJohn.Forte@Sun.COM 	uint32_t	stmf_ibuf_size;
757836SJohn.Forte@Sun.COM 	uint32_t	stmf_obuf_size;
767836SJohn.Forte@Sun.COM 	uint32_t	stmf_obuf_nentries;	/* # entries xferred */
777836SJohn.Forte@Sun.COM 	uint32_t	stmf_obuf_max_nentries;	/* #,could have been xferred */
787836SJohn.Forte@Sun.COM 	uint64_t	stmf_ibuf;
797836SJohn.Forte@Sun.COM 	uint64_t	stmf_obuf;
807836SJohn.Forte@Sun.COM } stmf_iocdata_t;
817836SJohn.Forte@Sun.COM 
827836SJohn.Forte@Sun.COM typedef	struct slist_lu {
837836SJohn.Forte@Sun.COM 	uint8_t		lu_guid[16];
847836SJohn.Forte@Sun.COM } slist_lu_t;
857836SJohn.Forte@Sun.COM 
867836SJohn.Forte@Sun.COM typedef	struct slist_target_port {
877836SJohn.Forte@Sun.COM 	uint8_t		target[260];
887836SJohn.Forte@Sun.COM } slist_target_port_t;
897836SJohn.Forte@Sun.COM 
907836SJohn.Forte@Sun.COM typedef	struct slist_scsi_session {
917836SJohn.Forte@Sun.COM 	uint8_t		initiator[260];
927836SJohn.Forte@Sun.COM 	/* creation_time is really time_t. But time_t is defined as long. */
937836SJohn.Forte@Sun.COM 	uint32_t	creation_time;
947836SJohn.Forte@Sun.COM 	char		alias[256];
957836SJohn.Forte@Sun.COM } slist_scsi_session_t;
967836SJohn.Forte@Sun.COM 
977836SJohn.Forte@Sun.COM /*
987836SJohn.Forte@Sun.COM  * States for LUs and LPORTs
997836SJohn.Forte@Sun.COM  */
1007836SJohn.Forte@Sun.COM #define	STMF_STATE_OFFLINE		0
1017836SJohn.Forte@Sun.COM #define	STMF_STATE_ONLINING		1
1027836SJohn.Forte@Sun.COM #define	STMF_STATE_ONLINE		2
1037836SJohn.Forte@Sun.COM #define	STMF_STATE_OFFLINING		3
1047836SJohn.Forte@Sun.COM 
1057836SJohn.Forte@Sun.COM /*
1067836SJohn.Forte@Sun.COM  * States for the STMF config.
1077836SJohn.Forte@Sun.COM  */
1087836SJohn.Forte@Sun.COM #define	STMF_CONFIG_NONE		0
1097836SJohn.Forte@Sun.COM #define	STMF_CONFIG_INIT		1
1107836SJohn.Forte@Sun.COM #define	STMF_CONFIG_INIT_DONE		2
1117836SJohn.Forte@Sun.COM 
1127836SJohn.Forte@Sun.COM typedef struct sioc_lu_props {
1137836SJohn.Forte@Sun.COM 	uint8_t		lu_guid[16];
1147836SJohn.Forte@Sun.COM 	uint8_t		lu_state:4,
1157836SJohn.Forte@Sun.COM 			lu_present:1,
1167836SJohn.Forte@Sun.COM 			lu_rsvd:3;
1177836SJohn.Forte@Sun.COM 	char		lu_provider_name[255];
1187836SJohn.Forte@Sun.COM 	char		lu_alias[256];
1197836SJohn.Forte@Sun.COM } sioc_lu_props_t;
1207836SJohn.Forte@Sun.COM 
1217836SJohn.Forte@Sun.COM typedef struct sioc_target_port_props {
1227836SJohn.Forte@Sun.COM 	uint8_t		tgt_id[260];
1237836SJohn.Forte@Sun.COM 	uint8_t		tgt_state:4,
1247836SJohn.Forte@Sun.COM 			tgt_present:1,
1257836SJohn.Forte@Sun.COM 			tgt_rsvd:3;
1267836SJohn.Forte@Sun.COM 	char		tgt_provider_name[255];
1277836SJohn.Forte@Sun.COM 	char		tgt_alias[256];
1287836SJohn.Forte@Sun.COM } sioc_target_port_props_t;
1297836SJohn.Forte@Sun.COM 
1307836SJohn.Forte@Sun.COM /*
1317836SJohn.Forte@Sun.COM  * This struct is used for getting and setting state of LU/LPORT or STMF.
1327836SJohn.Forte@Sun.COM  */
1337836SJohn.Forte@Sun.COM typedef struct stmf_state_desc {
1347836SJohn.Forte@Sun.COM 	uint8_t		ident[260];	/* N/A for STMF itself */
1357836SJohn.Forte@Sun.COM 	uint8_t		state;
1367836SJohn.Forte@Sun.COM 	uint8_t		config_state;	/* N/A for LU/LPORTs */
1377836SJohn.Forte@Sun.COM } stmf_state_desc_t;
1387836SJohn.Forte@Sun.COM 
1399585STim.Szeto@Sun.COM /* Error definitions for group/view entry/provider dataioctls */
1407836SJohn.Forte@Sun.COM #define	STMF_IOCERR_NONE			0
1417836SJohn.Forte@Sun.COM #define	STMF_IOCERR_HG_EXISTS			1
1427836SJohn.Forte@Sun.COM #define	STMF_IOCERR_INVALID_HG			2
1437836SJohn.Forte@Sun.COM #define	STMF_IOCERR_TG_EXISTS			3
1447836SJohn.Forte@Sun.COM #define	STMF_IOCERR_INVALID_TG			4
1457836SJohn.Forte@Sun.COM #define	STMF_IOCERR_HG_ENTRY_EXISTS		5
1467836SJohn.Forte@Sun.COM #define	STMF_IOCERR_INVALID_HG_ENTRY		6
1477836SJohn.Forte@Sun.COM #define	STMF_IOCERR_TG_ENTRY_EXISTS		7
1487836SJohn.Forte@Sun.COM #define	STMF_IOCERR_INVALID_TG_ENTRY		8
1497836SJohn.Forte@Sun.COM #define	STMF_IOCERR_TG_UPDATE_NEED_SVC_OFFLINE	9
1507836SJohn.Forte@Sun.COM #define	STMF_IOCERR_LU_NUMBER_IN_USE		10
1517836SJohn.Forte@Sun.COM #define	STMF_IOCERR_INVALID_LU_ID		11
1527836SJohn.Forte@Sun.COM #define	STMF_IOCERR_VIEW_ENTRY_CONFLICT		12
1537836SJohn.Forte@Sun.COM #define	STMF_IOCERR_HG_IN_USE			13
1547836SJohn.Forte@Sun.COM #define	STMF_IOCERR_TG_IN_USE			14
1557836SJohn.Forte@Sun.COM #define	STMF_IOCERR_INVALID_VIEW_ENTRY		15
1567836SJohn.Forte@Sun.COM #define	STMF_IOCERR_INVALID_VE_ID		16
1577836SJohn.Forte@Sun.COM #define	STMF_IOCERR_UPDATE_NEED_CFG_INIT	17
1589585STim.Szeto@Sun.COM #define	STMF_IOCERR_PPD_UPDATED			18
1599585STim.Szeto@Sun.COM #define	STMF_IOCERR_INSUFFICIENT_BUF		19
1609884STim.Szeto@Sun.COM #define	STMF_IOCERR_TG_NEED_TG_OFFLINE		20
1619585STim.Szeto@Sun.COM 
1627836SJohn.Forte@Sun.COM 
1637836SJohn.Forte@Sun.COM typedef struct stmf_group_name {
1647836SJohn.Forte@Sun.COM 	uint16_t	name_size;	/* in bytes */
1657836SJohn.Forte@Sun.COM 	uint16_t	rsvd_1;
1667836SJohn.Forte@Sun.COM 	uint32_t	rsvd_2;
1677836SJohn.Forte@Sun.COM 	uint8_t		name[512];	/* 256 * wchar_t */
1687836SJohn.Forte@Sun.COM } stmf_group_name_t;
1697836SJohn.Forte@Sun.COM 
1707836SJohn.Forte@Sun.COM /*
1717836SJohn.Forte@Sun.COM  * struct used to operate (add/remove entry) on a group.
1727836SJohn.Forte@Sun.COM  */
1739585STim.Szeto@Sun.COM 
1749585STim.Szeto@Sun.COM typedef struct stmf_ge_ident {
1759585STim.Szeto@Sun.COM 	uint16_t    ident_size;
1769585STim.Szeto@Sun.COM 	uint8_t	    ident[256];
1779585STim.Szeto@Sun.COM } stmf_ge_ident_t;
1787836SJohn.Forte@Sun.COM 
1797836SJohn.Forte@Sun.COM typedef struct stmf_group_op_data {
1807836SJohn.Forte@Sun.COM 	stmf_group_name_t	group;
1817836SJohn.Forte@Sun.COM 	uint8_t			ident[260];
1827836SJohn.Forte@Sun.COM } stmf_group_op_data_t;
1837836SJohn.Forte@Sun.COM 
1847836SJohn.Forte@Sun.COM typedef struct stmf_view_op_entry {
1857836SJohn.Forte@Sun.COM 	uint32_t		ve_ndx_valid:1,
1867836SJohn.Forte@Sun.COM 				ve_lu_number_valid:1,
1877836SJohn.Forte@Sun.COM 				ve_all_hosts:1,
1887836SJohn.Forte@Sun.COM 				ve_all_targets:1,
1897836SJohn.Forte@Sun.COM 				rsvd:28;
1907836SJohn.Forte@Sun.COM 	uint32_t		ve_ndx;
1917836SJohn.Forte@Sun.COM 	uint8_t			ve_lu_nbr[8];
1927836SJohn.Forte@Sun.COM 	uint8_t			ve_guid[16];
1937836SJohn.Forte@Sun.COM 	stmf_group_name_t	ve_host_group;
1947836SJohn.Forte@Sun.COM 	stmf_group_name_t	ve_target_group;
1957836SJohn.Forte@Sun.COM } stmf_view_op_entry_t;
1967836SJohn.Forte@Sun.COM 
1977836SJohn.Forte@Sun.COM typedef struct stmf_ppioctl_data {
1987836SJohn.Forte@Sun.COM 	char		ppi_name[255];	/* Provider name including \0 */
1997836SJohn.Forte@Sun.COM 	uint8_t		ppi_port_provider:1,
2007836SJohn.Forte@Sun.COM 			ppi_lu_provider:1,
2019585STim.Szeto@Sun.COM 			ppi_token_valid:1,
2029585STim.Szeto@Sun.COM 			ppt_rsvd:5;
2039585STim.Szeto@Sun.COM 	uint64_t	ppi_token;
2047836SJohn.Forte@Sun.COM 	uint64_t	ppi_data_size;
2057836SJohn.Forte@Sun.COM 	uint8_t		ppi_data[8];
2067836SJohn.Forte@Sun.COM } stmf_ppioctl_data_t;
2077836SJohn.Forte@Sun.COM 
2087836SJohn.Forte@Sun.COM /*
2097836SJohn.Forte@Sun.COM  * SCSI device ID descriptor as per SPC3 7.6.3
2107836SJohn.Forte@Sun.COM  */
2117836SJohn.Forte@Sun.COM typedef struct scsi_devid_desc {
2127836SJohn.Forte@Sun.COM #ifdef	_BIT_FIELDS_HTOL
2137836SJohn.Forte@Sun.COM 	uint8_t		protocol_id:4,
2147836SJohn.Forte@Sun.COM 			code_set:4;
2157836SJohn.Forte@Sun.COM 	uint8_t		piv:1,
2167836SJohn.Forte@Sun.COM 			rsvd1:1,
2177836SJohn.Forte@Sun.COM 			association:2,
2187836SJohn.Forte@Sun.COM 			ident_type:4;
2197836SJohn.Forte@Sun.COM #else
2207836SJohn.Forte@Sun.COM 	uint8_t		code_set:4,
2217836SJohn.Forte@Sun.COM 			protocol_id:4;
2227836SJohn.Forte@Sun.COM 	uint8_t		ident_type:4,
2237836SJohn.Forte@Sun.COM 			association:2,
2247836SJohn.Forte@Sun.COM 			rsvd1:1,
2257836SJohn.Forte@Sun.COM 			piv:1;
2267836SJohn.Forte@Sun.COM #endif
2277836SJohn.Forte@Sun.COM 	uint8_t		rsvd2;
2287836SJohn.Forte@Sun.COM 	uint8_t		ident_length;
2297836SJohn.Forte@Sun.COM 	uint8_t		ident[1];
2307836SJohn.Forte@Sun.COM } scsi_devid_desc_t;
2317836SJohn.Forte@Sun.COM 
2327836SJohn.Forte@Sun.COM /*
2337836SJohn.Forte@Sun.COM  * Protocol Identifier
2347836SJohn.Forte@Sun.COM  */
2357836SJohn.Forte@Sun.COM #define	PROTOCOL_FIBRE_CHANNEL		0
2367836SJohn.Forte@Sun.COM #define	PROTOCOL_PARALLEL_SCSI		1
2377836SJohn.Forte@Sun.COM #define	PROTOCOL_SSA			2
2387836SJohn.Forte@Sun.COM #define	PROTOCOL_IEEE_1394		3
2397836SJohn.Forte@Sun.COM #define	PROTOCOL_SRP			4
2407836SJohn.Forte@Sun.COM #define	PROTOCOL_iSCSI			5
2417836SJohn.Forte@Sun.COM #define	PROTOCOL_SAS			6
2427836SJohn.Forte@Sun.COM #define	PROTOCOL_ADT			7
2437836SJohn.Forte@Sun.COM #define	PROTOCOL_ATAPI			8
2447836SJohn.Forte@Sun.COM #define	PROTOCOL_ANY			15
2457836SJohn.Forte@Sun.COM 
2467836SJohn.Forte@Sun.COM /*
2477836SJohn.Forte@Sun.COM  * Code set definitions
2487836SJohn.Forte@Sun.COM  */
2497836SJohn.Forte@Sun.COM #define	CODE_SET_BINARY			1
2507836SJohn.Forte@Sun.COM #define	CODE_SET_ASCII			2
2517836SJohn.Forte@Sun.COM #define	CODE_SET_UTF8			3
2527836SJohn.Forte@Sun.COM 
2537836SJohn.Forte@Sun.COM /*
2547836SJohn.Forte@Sun.COM  * Association values
2557836SJohn.Forte@Sun.COM  */
2567836SJohn.Forte@Sun.COM #define	ID_IS_LOGICAL_UNIT		0
2577836SJohn.Forte@Sun.COM #define	ID_IS_TARGET_PORT		1
2587836SJohn.Forte@Sun.COM #define	ID_IS_TARGET_CONTAINING_LU	2
2597836SJohn.Forte@Sun.COM 
2607836SJohn.Forte@Sun.COM /*
2617836SJohn.Forte@Sun.COM  * ident type
2627836SJohn.Forte@Sun.COM  */
2637836SJohn.Forte@Sun.COM #define	ID_TYPE_VENDOR_SPECIFIC		0
2647836SJohn.Forte@Sun.COM #define	ID_TYPE_T10_VID			1
2657836SJohn.Forte@Sun.COM #define	ID_TYPE_EUI64			2
2667836SJohn.Forte@Sun.COM #define	ID_TYPE_NAA			3
2677836SJohn.Forte@Sun.COM #define	ID_TYPE_RELATIVE_TARGET_PORT	4
2687836SJohn.Forte@Sun.COM #define	ID_TYPE_TARGET_PORT_GROUP	5
2697836SJohn.Forte@Sun.COM #define	ID_TYPE_LOGICAL_UNIT_GROUP	6
2707836SJohn.Forte@Sun.COM #define	ID_TYPE_MD5_LOGICAL_UNIT	7
2717836SJohn.Forte@Sun.COM #define	ID_TYPE_SCSI_NAME_STRING	8
2727836SJohn.Forte@Sun.COM 
2737836SJohn.Forte@Sun.COM int stmf_copyin_iocdata(intptr_t data, int mode, stmf_iocdata_t **iocd,
2747836SJohn.Forte@Sun.COM     void **ibuf, void **obuf);
2757836SJohn.Forte@Sun.COM int stmf_copyout_iocdata(intptr_t data, int mode, stmf_iocdata_t *iocd,
2767836SJohn.Forte@Sun.COM     void *obuf);
2777836SJohn.Forte@Sun.COM 
2787836SJohn.Forte@Sun.COM #ifdef	__cplusplus
2797836SJohn.Forte@Sun.COM }
2807836SJohn.Forte@Sun.COM #endif
2817836SJohn.Forte@Sun.COM 
2827836SJohn.Forte@Sun.COM #endif /* _STMF_IOCTL_H */
283