1*f77d3fa4Srs /*
2*f77d3fa4Srs  * CDDL HEADER START
3*f77d3fa4Srs  *
4*f77d3fa4Srs  * The contents of this file are subject to the terms of the
5*f77d3fa4Srs  * Common Development and Distribution License (the "License").
6*f77d3fa4Srs  * You may not use this file except in compliance with the License.
7*f77d3fa4Srs  *
8*f77d3fa4Srs  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*f77d3fa4Srs  * or http://www.opensolaris.org/os/licensing.
10*f77d3fa4Srs  * See the License for the specific language governing permissions
11*f77d3fa4Srs  * and limitations under the License.
12*f77d3fa4Srs  *
13*f77d3fa4Srs  * When distributing Covered Code, include this CDDL HEADER in each
14*f77d3fa4Srs  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*f77d3fa4Srs  * If applicable, add the following below this CDDL HEADER, with the
16*f77d3fa4Srs  * fields enclosed by brackets "[]" replaced with your own identifying
17*f77d3fa4Srs  * information: Portions Copyright [yyyy] [name of copyright owner]
18*f77d3fa4Srs  *
19*f77d3fa4Srs  * CDDL HEADER END
20*f77d3fa4Srs  */
218c4f8890Srs /*
228c4f8890Srs  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
238c4f8890Srs  * Use is subject to license terms.
248c4f8890Srs  */
258c4f8890Srs 
268c4f8890Srs #ifndef _SYS_SCSI_ADAPTERS_MPAPI_SCSI_VHCI_H
278c4f8890Srs #define	_SYS_SCSI_ADAPTERS_MPAPI_SCSI_VHCI_H
288c4f8890Srs 
298c4f8890Srs #pragma ident	"%Z%%M%	%I%	%E% SMI"
308c4f8890Srs 
318c4f8890Srs #ifdef __cplusplus
328c4f8890Srs extern "C" {
338c4f8890Srs #endif
348c4f8890Srs 
358c4f8890Srs #if !defined(_BIT_FIELDS_LTOH) && !defined(_BIT_FIELDS_HTOL)
368c4f8890Srs #error  One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined
378c4f8890Srs #endif  /* _BIT_FIELDS_LTOH */
388c4f8890Srs 
398c4f8890Srs 
408c4f8890Srs #include <sys/scsi/adapters/mpapi_impl.h>
418c4f8890Srs 
428c4f8890Srs /* Structure for MP_OID (kernel level only) */
438c4f8890Srs 
448c4f8890Srs typedef struct mp_oid {
458c4f8890Srs #if defined(_BIT_FIELDS_HTOL)
468c4f8890Srs 	uint32_t	tstamp;
478c4f8890Srs 	uint32_t	type:8,
488c4f8890Srs 			seq_id:24;
498c4f8890Srs #else
508c4f8890Srs 	uint32_t	seq_id:24,
518c4f8890Srs 			type:8;
528c4f8890Srs 	uint32_t	tstamp;
538c4f8890Srs #endif
548c4f8890Srs } mp_oid_t;
558c4f8890Srs 
568c4f8890Srs typedef union mpoid {
578c4f8890Srs 	uint64_t	raw_oid;	/* raw oid */
588c4f8890Srs 	mp_oid_t	disc_oid;	/* discrete oid */
598c4f8890Srs } mpoid_t;
608c4f8890Srs 
618c4f8890Srs 
628c4f8890Srs /*
638c4f8890Srs  * MP API item - A generic one to use in a list setup
648c4f8890Srs  * in a common way for all types of elements of
658c4f8890Srs  * Object type items required for mpapi.
668c4f8890Srs  */
678c4f8890Srs 
688c4f8890Srs typedef	struct mpapi_item {
698c4f8890Srs 	mpoid_t			oid;
708c4f8890Srs 	void			*idata; /* item data */
718c4f8890Srs }mpapi_item_t;
728c4f8890Srs 
738c4f8890Srs typedef	struct mpapi_item_list {
748c4f8890Srs 	mpapi_item_t		*item;
758c4f8890Srs 	struct mpapi_item_list	*next;
768c4f8890Srs }mpapi_item_list_t;
778c4f8890Srs 
788c4f8890Srs /*
798c4f8890Srs  * MP API item header definition.
808c4f8890Srs  */
818c4f8890Srs 
828c4f8890Srs typedef struct mpapi_list_header {
838c4f8890Srs 	mpapi_item_list_t	*head;
848c4f8890Srs 	mpapi_item_list_t	*tail;
858c4f8890Srs }mpapi_list_header_t;
868c4f8890Srs 
878c4f8890Srs /*
88*f77d3fa4Srs  * Structure to maintain mpapi initiator data.
898c4f8890Srs  */
908c4f8890Srs typedef struct mpapi_initiator_data {
91*f77d3fa4Srs 	void			*resp; /* initiator-port prop */
928c4f8890Srs 	mpapi_list_header_t	*path_list;
938c4f8890Srs 	int			valid;
948c4f8890Srs 	mp_init_port_prop_t	prop;
958c4f8890Srs } mpapi_initiator_data_t;
968c4f8890Srs 
978c4f8890Srs /*
98*f77d3fa4Srs  * Structure to maintain mpapi lu data.
998c4f8890Srs  */
1008c4f8890Srs typedef struct mpapi_lu_data {
1018c4f8890Srs 	void			*resp; /* vlun */
1028c4f8890Srs 	mpapi_list_header_t	*path_list;
1038c4f8890Srs 	mpapi_list_header_t	*tpg_list;
1048c4f8890Srs 	int			valid;
1058c4f8890Srs 	mp_logical_unit_prop_t	prop;
1068c4f8890Srs } mpapi_lu_data_t;
1078c4f8890Srs 
1088c4f8890Srs /*
109*f77d3fa4Srs  * Structure to maintain mpapi path data.
1108c4f8890Srs  */
1118c4f8890Srs typedef struct mpapi_path_data {
1128c4f8890Srs 	void			*resp; /* pip */
1138c4f8890Srs 	char			*path_name;
1148c4f8890Srs 	int			valid;
1158c4f8890Srs 	mp_path_prop_t		prop;
1168c4f8890Srs } mpapi_path_data_t;
1178c4f8890Srs 
1188c4f8890Srs /*
119*f77d3fa4Srs  * Structure to maintain mpapi tpg data.
1208c4f8890Srs  */
1218c4f8890Srs typedef struct mpapi_tpg_data {
122*f77d3fa4Srs 	void			*resp;
1238c4f8890Srs 	mpapi_list_header_t	*tport_list;
1248c4f8890Srs 	mpapi_list_header_t	*lu_list; /* mpath lu or lun list */
1258c4f8890Srs 	int			valid;
1268c4f8890Srs 	mp_tpg_prop_t		prop;
1278c4f8890Srs } mpapi_tpg_data_t;
1288c4f8890Srs 
1298c4f8890Srs /*
130*f77d3fa4Srs  * Structure to maintain mpapi tport data.
1318c4f8890Srs  */
1328c4f8890Srs typedef struct mpapi_tport_data {
1338c4f8890Srs 	void			*resp; /* target port prop */
1348c4f8890Srs 	mpapi_list_header_t	*path_list;
1358c4f8890Srs 	int			valid;
1368c4f8890Srs 	mp_target_port_prop_t	prop;
1378c4f8890Srs } mpapi_tport_data_t;
1388c4f8890Srs 
1398c4f8890Srs 
1408c4f8890Srs /* Structure for mpapi private data */
1418c4f8890Srs 
1428c4f8890Srs typedef struct mpapi_priv {
1438c4f8890Srs 
1448c4f8890Srs 	/*
145*f77d3fa4Srs 	 * Will be initialized with tod(time of day)
146*f77d3fa4Srs 	 * This will enable detection of stale OIDs used by the upper layers.
1478c4f8890Srs 	 */
1488c4f8890Srs 	uint32_t		tstamp;
1498c4f8890Srs 	/*
150*f77d3fa4Srs 	 * The Sequence number space is unique within an Object Type -
151*f77d3fa4Srs 	 * that is there can be a seq# 2 in Object Type "initiator port"
152*f77d3fa4Srs 	 * and also a seq#2 in object type 'Path LU'.
153*f77d3fa4Srs 	 * Even though the Seq# space collides, the Object type field
154*f77d3fa4Srs 	 * will make the OIDs unique.
155*f77d3fa4Srs 	 * The following field will indicate what the next sequence number
156*f77d3fa4Srs 	 * that can be used for a particular type of Object type -
157*f77d3fa4Srs 	 * Object type will be used to index into the array element.
1588c4f8890Srs 	 */
1598c4f8890Srs 	uint32_t		oid_seq[MP_MAX_OBJECT_TYPE];
1608c4f8890Srs 
1618c4f8890Srs 	/*
1628c4f8890Srs 	 * One list for each type of object.
1638c4f8890Srs 	 */
1648c4f8890Srs 	mpapi_list_header_t	*obj_hdr_list[MP_MAX_OBJECT_TYPE];
1658c4f8890Srs 
1668c4f8890Srs } mpapi_priv_t;
1678c4f8890Srs 
1688c4f8890Srs #ifdef __cplusplus
1698c4f8890Srs }
1708c4f8890Srs #endif
1718c4f8890Srs 
1728c4f8890Srs #endif /* _SYS_SCSI_ADAPTERS_MPAPI_SCSI_VHCI_H */
173