xref: /onnv-gate/usr/src/uts/common/sys/scsi/adapters/mpapi_scsi_vhci.h (revision 10696:cd0f390dd9e2)
11018Srs135747 /*
21018Srs135747  * CDDL HEADER START
31018Srs135747  *
41018Srs135747  * The contents of this file are subject to the terms of the
51018Srs135747  * Common Development and Distribution License (the "License").
61018Srs135747  * You may not use this file except in compliance with the License.
71018Srs135747  *
81018Srs135747  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
91018Srs135747  * or http://www.opensolaris.org/os/licensing.
101018Srs135747  * See the License for the specific language governing permissions
111018Srs135747  * and limitations under the License.
121018Srs135747  *
131018Srs135747  * When distributing Covered Code, include this CDDL HEADER in each
141018Srs135747  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
151018Srs135747  * If applicable, add the following below this CDDL HEADER, with the
161018Srs135747  * fields enclosed by brackets "[]" replaced with your own identifying
171018Srs135747  * information: Portions Copyright [yyyy] [name of copyright owner]
181018Srs135747  *
191018Srs135747  * CDDL HEADER END
201018Srs135747  */
21893Srs135747 /*
22*10696SDavid.Hollister@Sun.COM  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23893Srs135747  * Use is subject to license terms.
24893Srs135747  */
25893Srs135747 
26893Srs135747 #ifndef _SYS_SCSI_ADAPTERS_MPAPI_SCSI_VHCI_H
27893Srs135747 #define	_SYS_SCSI_ADAPTERS_MPAPI_SCSI_VHCI_H
28893Srs135747 
29893Srs135747 #ifdef __cplusplus
30893Srs135747 extern "C" {
31893Srs135747 #endif
32893Srs135747 
33893Srs135747 #if !defined(_BIT_FIELDS_LTOH) && !defined(_BIT_FIELDS_HTOL)
34893Srs135747 #error  One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined
35893Srs135747 #endif  /* _BIT_FIELDS_LTOH */
36893Srs135747 
37893Srs135747 
38893Srs135747 #include <sys/scsi/adapters/mpapi_impl.h>
39893Srs135747 
401227Srs135747 #define	MPAPI_SCSI_MAXPCLASSLEN	25
411227Srs135747 
42893Srs135747 /* Structure for MP_OID (kernel level only) */
43893Srs135747 
44893Srs135747 typedef struct mp_oid {
45893Srs135747 #if defined(_BIT_FIELDS_HTOL)
46893Srs135747 	uint32_t	tstamp;
47893Srs135747 	uint32_t	type:8,
48893Srs135747 			seq_id:24;
49893Srs135747 #else
50893Srs135747 	uint32_t	seq_id:24,
51893Srs135747 			type:8;
52893Srs135747 	uint32_t	tstamp;
53893Srs135747 #endif
54893Srs135747 } mp_oid_t;
55893Srs135747 
56893Srs135747 typedef union mpoid {
57893Srs135747 	uint64_t	raw_oid;	/* raw oid */
58893Srs135747 	mp_oid_t	disc_oid;	/* discrete oid */
59893Srs135747 } mpoid_t;
60893Srs135747 
61893Srs135747 
62893Srs135747 /*
63893Srs135747  * MP API item - A generic one to use in a list setup
64893Srs135747  * in a common way for all types of elements of
65893Srs135747  * Object type items required for mpapi.
66893Srs135747  */
67893Srs135747 
68893Srs135747 typedef	struct mpapi_item {
69893Srs135747 	mpoid_t			oid;
70893Srs135747 	void			*idata; /* item data */
713410Scm136836 	kmutex_t		item_mutex;
721227Srs135747 } mpapi_item_t;
73893Srs135747 
74893Srs135747 typedef	struct mpapi_item_list {
75893Srs135747 	mpapi_item_t		*item;
76893Srs135747 	struct mpapi_item_list	*next;
771227Srs135747 } mpapi_item_list_t;
78893Srs135747 
79893Srs135747 /*
80893Srs135747  * MP API item header definition.
81893Srs135747  */
82893Srs135747 
83893Srs135747 typedef struct mpapi_list_header {
84893Srs135747 	mpapi_item_list_t	*head;
85893Srs135747 	mpapi_item_list_t	*tail;
861227Srs135747 } mpapi_list_header_t;
87893Srs135747 
88893Srs135747 /*
891018Srs135747  * Structure to maintain mpapi initiator data.
90893Srs135747  */
91893Srs135747 typedef struct mpapi_initiator_data {
921018Srs135747 	void			*resp; /* initiator-port prop */
93893Srs135747 	mpapi_list_header_t	*path_list;
94893Srs135747 	int			valid;
95893Srs135747 	mp_init_port_prop_t	prop;
96893Srs135747 } mpapi_initiator_data_t;
97893Srs135747 
98893Srs135747 /*
991018Srs135747  * Structure to maintain mpapi lu data.
100893Srs135747  */
101893Srs135747 typedef struct mpapi_lu_data {
102893Srs135747 	void			*resp; /* vlun */
103893Srs135747 	mpapi_list_header_t	*path_list;
104893Srs135747 	mpapi_list_header_t	*tpg_list;
105893Srs135747 	int			valid;
106893Srs135747 	mp_logical_unit_prop_t	prop;
107893Srs135747 } mpapi_lu_data_t;
108893Srs135747 
109893Srs135747 /*
1101018Srs135747  * Structure to maintain mpapi path data.
111*10696SDavid.Hollister@Sun.COM  *
112*10696SDavid.Hollister@Sun.COM  * The hide flag is set when pip was detroyed or should
113*10696SDavid.Hollister@Sun.COM  * have been destroyed(MDI_PATHINFO_FLAGS_DEVICE_REMOVED).
114*10696SDavid.Hollister@Sun.COM  * The valid flag is set to 0 when the path is neither online
115*10696SDavid.Hollister@Sun.COM  * nor standby state. When hide flag is set the valid flag set
116*10696SDavid.Hollister@Sun.COM  * to 0 also.
117893Srs135747  */
118893Srs135747 typedef struct mpapi_path_data {
119893Srs135747 	void			*resp; /* pip */
120893Srs135747 	char			*path_name;
121893Srs135747 	int			valid;
122*10696SDavid.Hollister@Sun.COM 	int			hide;
1231227Srs135747 	char			pclass[MPAPI_SCSI_MAXPCLASSLEN];
124893Srs135747 	mp_path_prop_t		prop;
125893Srs135747 } mpapi_path_data_t;
126893Srs135747 
127893Srs135747 /*
1281018Srs135747  * Structure to maintain mpapi tpg data.
129893Srs135747  */
130893Srs135747 typedef struct mpapi_tpg_data {
1311018Srs135747 	void			*resp;
132893Srs135747 	mpapi_list_header_t	*tport_list;
133893Srs135747 	mpapi_list_header_t	*lu_list; /* mpath lu or lun list */
134893Srs135747 	int			valid;
1351227Srs135747 	char			pclass[MPAPI_SCSI_MAXPCLASSLEN];
136893Srs135747 	mp_tpg_prop_t		prop;
137893Srs135747 } mpapi_tpg_data_t;
138893Srs135747 
139893Srs135747 /*
1401018Srs135747  * Structure to maintain mpapi tport data.
141893Srs135747  */
142893Srs135747 typedef struct mpapi_tport_data {
143893Srs135747 	void			*resp; /* target port prop */
144893Srs135747 	mpapi_list_header_t	*path_list;
145893Srs135747 	int			valid;
146893Srs135747 	mp_target_port_prop_t	prop;
147893Srs135747 } mpapi_tport_data_t;
148893Srs135747 
149893Srs135747 
150893Srs135747 /* Structure for mpapi private data */
151893Srs135747 
152893Srs135747 typedef struct mpapi_priv {
153893Srs135747 
154893Srs135747 	/*
1551018Srs135747 	 * Will be initialized with tod(time of day)
1561018Srs135747 	 * This will enable detection of stale OIDs used by the upper layers.
157893Srs135747 	 */
158893Srs135747 	uint32_t		tstamp;
159893Srs135747 	/*
1601018Srs135747 	 * The Sequence number space is unique within an Object Type -
1611018Srs135747 	 * that is there can be a seq# 2 in Object Type "initiator port"
1621018Srs135747 	 * and also a seq#2 in object type 'Path LU'.
1631018Srs135747 	 * Even though the Seq# space collides, the Object type field
1641018Srs135747 	 * will make the OIDs unique.
1651018Srs135747 	 * The following field will indicate what the next sequence number
1661018Srs135747 	 * that can be used for a particular type of Object type -
1671018Srs135747 	 * Object type will be used to index into the array element.
168893Srs135747 	 */
169893Srs135747 	uint32_t		oid_seq[MP_MAX_OBJECT_TYPE];
170893Srs135747 
171893Srs135747 	/*
172893Srs135747 	 * One list for each type of object.
173893Srs135747 	 */
174893Srs135747 	mpapi_list_header_t	*obj_hdr_list[MP_MAX_OBJECT_TYPE];
175893Srs135747 
176893Srs135747 } mpapi_priv_t;
177893Srs135747 
178893Srs135747 #ifdef __cplusplus
179893Srs135747 }
180893Srs135747 #endif
181893Srs135747 
182893Srs135747 #endif /* _SYS_SCSI_ADAPTERS_MPAPI_SCSI_VHCI_H */
183