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