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 2005 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef _SYS_SCSI_ADAPTERS_MPAPI_SCSI_VHCI_H
27 #define	_SYS_SCSI_ADAPTERS_MPAPI_SCSI_VHCI_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
35 #if !defined(_BIT_FIELDS_LTOH) && !defined(_BIT_FIELDS_HTOL)
36 #error  One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined
37 #endif  /* _BIT_FIELDS_LTOH */
38 
39 
40 #include <sys/scsi/adapters/mpapi_impl.h>
41 
42 /* Structure for MP_OID (kernel level only) */
43 
44 typedef struct mp_oid {
45 #if defined(_BIT_FIELDS_HTOL)
46 	uint32_t	tstamp;
47 	uint32_t	type:8,
48 			seq_id:24;
49 #else
50 	uint32_t	seq_id:24,
51 			type:8;
52 	uint32_t	tstamp;
53 #endif
54 } mp_oid_t;
55 
56 typedef union mpoid {
57 	uint64_t	raw_oid;	/* raw oid */
58 	mp_oid_t	disc_oid;	/* discrete oid */
59 } mpoid_t;
60 
61 
62 /*
63  * MP API item - A generic one to use in a list setup
64  * in a common way for all types of elements of
65  * Object type items required for mpapi.
66  */
67 
68 typedef	struct mpapi_item {
69 	mpoid_t			oid;
70 	void			*idata; /* item data */
71 }mpapi_item_t;
72 
73 typedef	struct mpapi_item_list {
74 	mpapi_item_t		*item;
75 	struct mpapi_item_list	*next;
76 }mpapi_item_list_t;
77 
78 /*
79  * MP API item header definition.
80  */
81 
82 typedef struct mpapi_list_header {
83 	mpapi_item_list_t	*head;
84 	mpapi_item_list_t	*tail;
85 }mpapi_list_header_t;
86 
87 /*
88  * Structure to maintain mpapi initiator data.
89  */
90 typedef struct mpapi_initiator_data {
91 	void			*resp; /* initiator-port prop */
92 	mpapi_list_header_t	*path_list;
93 	int			valid;
94 	mp_init_port_prop_t	prop;
95 } mpapi_initiator_data_t;
96 
97 /*
98  * Structure to maintain mpapi lu data.
99  */
100 typedef struct mpapi_lu_data {
101 	void			*resp; /* vlun */
102 	mpapi_list_header_t	*path_list;
103 	mpapi_list_header_t	*tpg_list;
104 	int			valid;
105 	mp_logical_unit_prop_t	prop;
106 } mpapi_lu_data_t;
107 
108 /*
109  * Structure to maintain mpapi path data.
110  */
111 typedef struct mpapi_path_data {
112 	void			*resp; /* pip */
113 	char			*path_name;
114 	int			valid;
115 	mp_path_prop_t		prop;
116 } mpapi_path_data_t;
117 
118 /*
119  * Structure to maintain mpapi tpg data.
120  */
121 typedef struct mpapi_tpg_data {
122 	void			*resp;
123 	mpapi_list_header_t	*tport_list;
124 	mpapi_list_header_t	*lu_list; /* mpath lu or lun list */
125 	int			valid;
126 	mp_tpg_prop_t		prop;
127 } mpapi_tpg_data_t;
128 
129 /*
130  * Structure to maintain mpapi tport data.
131  */
132 typedef struct mpapi_tport_data {
133 	void			*resp; /* target port prop */
134 	mpapi_list_header_t	*path_list;
135 	int			valid;
136 	mp_target_port_prop_t	prop;
137 } mpapi_tport_data_t;
138 
139 
140 /* Structure for mpapi private data */
141 
142 typedef struct mpapi_priv {
143 
144 	/*
145 	 * Will be initialized with tod(time of day)
146 	 * This will enable detection of stale OIDs used by the upper layers.
147 	 */
148 	uint32_t		tstamp;
149 	/*
150 	 * The Sequence number space is unique within an Object Type -
151 	 * that is there can be a seq# 2 in Object Type "initiator port"
152 	 * and also a seq#2 in object type 'Path LU'.
153 	 * Even though the Seq# space collides, the Object type field
154 	 * will make the OIDs unique.
155 	 * The following field will indicate what the next sequence number
156 	 * that can be used for a particular type of Object type -
157 	 * Object type will be used to index into the array element.
158 	 */
159 	uint32_t		oid_seq[MP_MAX_OBJECT_TYPE];
160 
161 	/*
162 	 * One list for each type of object.
163 	 */
164 	mpapi_list_header_t	*obj_hdr_list[MP_MAX_OBJECT_TYPE];
165 
166 } mpapi_priv_t;
167 
168 #ifdef __cplusplus
169 }
170 #endif
171 
172 #endif /* _SYS_SCSI_ADAPTERS_MPAPI_SCSI_VHCI_H */
173