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.
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.
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]
22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
30 * Multiplexed I/O global include
34 #include <sys/esunddi.h>
35 #include <sys/sunddi.h>
36 #include <sys/ddipropdefs.h>
43 * Most MDI functions return success or failure
45 #define MDI_SUCCESS 0 /* Call Success */
46 #define MDI_FAILURE -1 /* Unspecified Error */
47 #define MDI_NOMEM -2 /* No resources available */
48 #define MDI_ACCEPT -3 /* Request accepted */
49 #define MDI_BUSY -4 /* Busy */
50 #define MDI_NOPATH -5 /* No more paths are available */
51 #define MDI_EINVAL -6 /* Invalid parameter */
52 #define MDI_NOT_SUPPORTED -8 /* Device not supported */
53 #define MDI_DEVI_ONLINING -9 /* Devi is onlining */
56 * handle to mdi_pathinfo node
58 typedef struct x_mdi_pathinfo
*mdi_pathinfo_t
;
61 * Path info node state definitions
64 MDI_PATHINFO_STATE_INIT
,
65 MDI_PATHINFO_STATE_ONLINE
,
66 MDI_PATHINFO_STATE_STANDBY
,
67 MDI_PATHINFO_STATE_FAULT
,
68 MDI_PATHINFO_STATE_OFFLINE
69 } mdi_pathinfo_state_t
;
72 * MDI vHCI class definitions
74 #define MDI_HCI_CLASS_SCSI "scsi_vhci"
75 #define MDI_HCI_CLASS_IB "ib"
80 * mpxio component definitions: Every registered component of the
81 * mpxio system has a "mpxio-component" property attached to it.
82 * Identify its function
84 #define MDI_COMPONENT_NONE 0
85 #define MDI_COMPONENT_VHCI 0x1
86 #define MDI_COMPONENT_PHCI 0x2
87 #define MDI_COMPONENT_CLIENT 0x4
90 * mdi_pathinfo node state utility definitions
92 #define MDI_PATHINFO_STATE_TRANSIENT 0x00010000
93 #define MDI_PATHINFO_STATE_USER_DISABLE 0x00100000
94 #define MDI_PATHINFO_STATE_DRV_DISABLE 0x00200000
95 #define MDI_PATHINFO_STATE_DRV_DISABLE_TRANSIENT 0x00400000
96 #define MDI_PATHINFO_STATE_MASK 0x0000FFFF
97 #define MDI_PATHINFO_EXT_STATE_MASK 0xFFF00000
99 #define USER_DISABLE 1
100 #define DRIVER_DISABLE 2
101 #define DRIVER_DISABLE_TRANSIENT 3
105 * Most MDI functions return success or failure
107 #define MDI_SUCCESS 0 /* Call Success */
108 #define MDI_FAILURE -1 /* Unspecified Error */
109 #define MDI_NOMEM -2 /* No resources available */
110 #define MDI_ACCEPT -3 /* Request accepted */
111 #define MDI_BUSY -4 /* Busy */
112 #define MDI_NOPATH -5 /* No more paths are available */
113 #define MDI_EINVAL -6 /* Invalid parameter */
114 #define MDI_NOT_SUPPORTED -8 /* Device not supported */
115 #define MDI_DEVI_ONLINING -9 /* Devi is onlining */
118 * MDI operation vector structure definition
120 #define MDI_OPS_REV_1 1
121 #define MDI_OPS_REV MDI_OPS_REV_1
123 #define MDI_VHCI(dip) (DEVI(dip)->devi_mdi_component & MDI_COMPONENT_VHCI)
124 #define MDI_PHCI(dip) (DEVI(dip)->devi_mdi_component & MDI_COMPONENT_PHCI)
125 #define MDI_CLIENT(dip) (DEVI(dip)->devi_mdi_component & MDI_COMPONENT_CLIENT)
128 * MDI device hotplug notification
130 int mdi_devi_online(dev_info_t
*, uint_t
);
131 int mdi_devi_offline(dev_info_t
*, uint_t
);
134 * MDI path retire interfaces
136 void mdi_phci_mark_retiring(dev_info_t
*dip
, char **cons_array
);
137 void mdi_phci_retire_notify(dev_info_t
*dip
, int *constraint
);
138 void mdi_phci_retire_finalize(dev_info_t
*dip
, int phci_only
);
139 void mdi_phci_unretire(dev_info_t
*dip
);
142 * MDI devinfo locking functions.
144 void mdi_devi_enter(dev_info_t
*, int *);
145 void mdi_devi_exit_phci(dev_info_t
*, int);
146 void mdi_devi_enter_phci(dev_info_t
*, int *);
147 void mdi_devi_exit(dev_info_t
*, int);
150 * MDI device support functions.
152 dev_info_t
*mdi_devi_get_vdip(dev_info_t
*);
153 int mdi_devi_pdip_entered(dev_info_t
*);
156 * MDI component device instance attach/detach notification
158 int mdi_pre_attach(dev_info_t
*, ddi_attach_cmd_t
);
159 void mdi_post_attach(dev_info_t
*, ddi_attach_cmd_t
, int);
160 int mdi_pre_detach(dev_info_t
*, ddi_detach_cmd_t
);
161 void mdi_post_detach(dev_info_t
*, ddi_detach_cmd_t
, int);
164 * mdi_pathinfo management functions.
166 * Find, allocate and Free functions.
168 mdi_pathinfo_t
*mdi_pi_find(dev_info_t
*, char *, char *);
169 int mdi_pi_alloc(dev_info_t
*, char *, char *, char *, int, mdi_pathinfo_t
**);
170 int mdi_pi_alloc_compatible(dev_info_t
*, char *, char *, char *,
171 char **, int, int, mdi_pathinfo_t
**);
172 int mdi_pi_free(mdi_pathinfo_t
*, int);
174 void mdi_hold_path(mdi_pathinfo_t
*);
175 void mdi_rele_path(mdi_pathinfo_t
*);
178 * mdi_pathinfo node state change functions.
180 int mdi_pi_online(mdi_pathinfo_t
*, int);
181 int mdi_pi_standby(mdi_pathinfo_t
*, int);
182 int mdi_pi_fault(mdi_pathinfo_t
*, int);
183 int mdi_pi_offline(mdi_pathinfo_t
*, int);
185 * NOTE: the next 2 interfaces will be removed once the NWS files are
186 * changed to use the new mdi_{enable,disable}_path interfaces
188 int mdi_pi_disable(dev_info_t
*, dev_info_t
*, int);
189 int mdi_pi_enable(dev_info_t
*, dev_info_t
*, int);
190 int mdi_pi_disable_path(mdi_pathinfo_t
*, int);
191 int mdi_pi_enable_path(mdi_pathinfo_t
*, int);
197 MDI_PM_PRE_CONFIG
= 0,
200 MDI_PM_POST_UNCONFIG
,
206 mdi_bus_power(dev_info_t
*, void *, pm_bus_power_op_t
, void *, void *);
209 mdi_power(dev_info_t
*, mdi_pm_op_t
, void *, char *, int);
212 * mdi_pathinfo node walker function.
214 int mdi_component_is_vhci(dev_info_t
*, const char **);
215 int mdi_component_is_phci(dev_info_t
*, const char **);
216 int mdi_component_is_client(dev_info_t
*, const char **);
217 mdi_pathinfo_t
*mdi_get_next_phci_path(dev_info_t
*, mdi_pathinfo_t
*);
218 mdi_pathinfo_t
*mdi_get_next_client_path(dev_info_t
*, mdi_pathinfo_t
*);
221 * mdi_pathinfo node member functions
223 void mdi_pi_lock(mdi_pathinfo_t
*);
224 void mdi_pi_unlock(mdi_pathinfo_t
*);
225 dev_info_t
*mdi_pi_get_client(mdi_pathinfo_t
*);
226 dev_info_t
*mdi_pi_get_phci(mdi_pathinfo_t
*);
227 char *mdi_pi_get_addr(mdi_pathinfo_t
*);
228 mdi_pathinfo_state_t
mdi_pi_get_state(mdi_pathinfo_t
*);
229 int mdi_pi_get_path_instance(mdi_pathinfo_t
*);
230 char *mdi_pi_pathname_by_instance(int path_instance
);
231 char *mdi_pi_pathname(mdi_pathinfo_t
*);
232 char *mdi_pi_pathname_obp(mdi_pathinfo_t
*, char *);
233 int mdi_pi_pathname_obp_set(mdi_pathinfo_t
*, char *);
236 * mdi_pathinfo Property handling functions
238 int mdi_prop_remove(mdi_pathinfo_t
*, char *);
239 int mdi_prop_update_byte_array(mdi_pathinfo_t
*, char *, uchar_t
*, uint_t
);
240 int mdi_prop_update_int(mdi_pathinfo_t
*, char *, int);
241 int mdi_prop_update_int64(mdi_pathinfo_t
*, char *, int64_t);
242 int mdi_prop_update_int_array(mdi_pathinfo_t
*, char *, int *, uint_t
);
243 int mdi_prop_update_string(mdi_pathinfo_t
*, char *, char *);
244 int mdi_prop_update_string_array(mdi_pathinfo_t
*, char *, char **, uint_t
);
245 nvpair_t
*mdi_pi_get_next_prop(mdi_pathinfo_t
*, nvpair_t
*);
247 int mdi_prop_lookup_byte_array(mdi_pathinfo_t
*, char *, uchar_t
**, uint_t
*);
248 int mdi_prop_lookup_int(mdi_pathinfo_t
*, char *, int *);
249 int mdi_prop_lookup_int64(mdi_pathinfo_t
*, char *, int64_t *);
250 int mdi_prop_lookup_int_array(mdi_pathinfo_t
*, char *, int **, uint_t
*);
251 int mdi_prop_lookup_string(mdi_pathinfo_t
*, char *, char **);
252 int mdi_prop_lookup_string_array(mdi_pathinfo_t
*, char *, char ***, uint_t
*);
253 int mdi_prop_free(void *);
256 * pHCI driver instance registration/unregistration
258 * mdi_phci_register() is called by a pHCI drivers to register itself as a
259 * transport provider for a specific 'class' (see mdi_vhci_register() above);
260 * it should be called from attach(9e).
262 * mdi_phci_unregister() is called from detach(9e) to unregister a pHCI
263 * instance from the framework.
265 int mdi_phci_register(char *, dev_info_t
*, int);
266 int mdi_phci_unregister(dev_info_t
*, int);
268 /* get set phci private data */
269 caddr_t
mdi_pi_get_phci_private(mdi_pathinfo_t
*);
270 void mdi_pi_set_phci_private(mdi_pathinfo_t
*, caddr_t
);
272 int mdi_vhci_bus_config(dev_info_t
*, uint_t
, ddi_bus_config_op_t
, void *,
273 dev_info_t
**, char *);
276 * mdi_vhci node walker function
278 void mdi_walk_vhcis(int (*f
)(dev_info_t
*, void *), void *arg
);
281 * mdi_phci node walker function
283 void mdi_vhci_walk_phcis(dev_info_t
*, int (*f
)(dev_info_t
*, void *),
287 * mdi_client node walker function
289 void mdi_vhci_walk_clients(dev_info_t
*, int (*f
)(dev_info_t
*, void *),
293 * MDI PHCI driver list helper functions
295 char **mdi_get_phci_driver_list(char *vhci_class
, int *ndrivers
);
296 void mdi_free_phci_driver_list(char **driver_list
, int ndrivers
);
304 #endif /* _SYS_SUNMDI_H */