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.
36 MP_GetPathLogicalUnitProperties(MP_OID oid
,
37 MP_PATH_LOGICAL_UNIT_PROPERTIES
*pProps
)
39 mp_iocdata_t mp_ioctl
;
40 mp_path_prop_t pathInfo
;
48 MP_STATUS mpStatus
= MP_STATUS_SUCCESS
;
52 log(LOG_INFO
, "MP_GetPathLogicalUnitProperties()", " - enter");
55 log(LOG_INFO
, "MP_GetPathLogicalUnitProperties()",
56 "oid.objectSequenceNumber = %llx",
57 oid
.objectSequenceNumber
);
60 if (g_scsi_vhci_fd
< 0) {
61 log(LOG_INFO
, "MP_GetPathLogicalUnitProperties()",
62 "invalid driver file handle");
63 log(LOG_INFO
, "MP_GetPathLogicalUnitProperties()",
65 return (MP_STATUS_FAILED
);
68 (void) memset(&mp_ioctl
, 0, sizeof (mp_iocdata_t
));
69 (void) memset(&pathInfo
, 0, sizeof (mp_path_prop_t
));
71 mp_ioctl
.mp_cmd
= MP_GET_PATH_PROP
;
72 mp_ioctl
.mp_ibuf
= (caddr_t
)&oid
.objectSequenceNumber
;
73 mp_ioctl
.mp_ilen
= sizeof (oid
.objectSequenceNumber
);
74 mp_ioctl
.mp_obuf
= (caddr_t
)&pathInfo
;
75 mp_ioctl
.mp_olen
= sizeof (mp_path_prop_t
);
76 mp_ioctl
.mp_xfer
= MP_XFER_READ
;
78 ioctlStatus
= ioctl(g_scsi_vhci_fd
, MP_CMD
, &mp_ioctl
);
80 log(LOG_INFO
, "MP_GetPathLogicalUnitProperties()",
81 " IOCTL call returned: %d", ioctlStatus
);
83 if (ioctlStatus
< 0) {
87 if (ioctlStatus
!= 0) {
88 log(LOG_INFO
, "MP_GetPathLogicalUnitProperties()",
89 "IOCTL call failed. IOCTL error is: %d",
91 log(LOG_INFO
, "MP_GetPathLogicalUnitProperties()",
92 "IOCTL call failed. IOCTL error is: %s",
93 strerror(ioctlStatus
));
94 log(LOG_INFO
, "MP_GetPathLogicalUnitProperties()",
95 "IOCTL call failed. mp_ioctl.mp_errno: %x",
98 if (ENOTSUP
== ioctlStatus
) {
99 mpStatus
= MP_STATUS_UNSUPPORTED
;
100 } else if (0 == mp_ioctl
.mp_errno
) {
101 mpStatus
= MP_STATUS_FAILED
;
103 mpStatus
= getStatus4ErrorCode(mp_ioctl
.mp_errno
);
106 log(LOG_INFO
, "MP_GetPathLogicalUnitProperties()",
112 (void) memset(pProps
, 0, sizeof (MP_PATH_LOGICAL_UNIT_PROPERTIES
));
114 pProps
->disabled
= pathInfo
.disabled
;
116 initPortOID
.objectSequenceNumber
= pathInfo
.initPort
.id
;
117 initPortOID
.objectType
= MP_OBJECT_TYPE_INITIATOR_PORT
;
118 initPortOID
.ownerId
= g_pluginOwnerID
;
120 (void) memcpy(&pProps
->initiatorPortOid
, &initPortOID
, sizeof (MP_OID
));
122 targetPortOID
.objectSequenceNumber
= pathInfo
.targetPort
.id
;
123 targetPortOID
.objectType
= MP_OBJECT_TYPE_TARGET_PORT
;
124 targetPortOID
.ownerId
= g_pluginOwnerID
;
126 (void) memcpy(&pProps
->targetPortOid
, &targetPortOID
, sizeof (MP_OID
));
128 luOID
.objectSequenceNumber
= pathInfo
.logicalUnit
.id
;
129 luOID
.objectType
= MP_OBJECT_TYPE_MULTIPATH_LU
;
130 luOID
.ownerId
= g_pluginOwnerID
;
132 (void) memcpy(&pProps
->logicalUnitOid
, &luOID
, sizeof (MP_OID
));
134 pProps
->logicalUnitNumber
= pathInfo
.logicalUnit
.id
;
136 switch (pathInfo
.pathState
) {
138 case MP_DRVR_PATH_STATE_ACTIVE
:
139 case MP_DRVR_PATH_STATE_PASSIVE
:
140 pProps
->pathState
= MP_PATH_STATE_OKAY
;
143 case MP_DRVR_PATH_STATE_PATH_ERR
:
144 pProps
->pathState
= MP_PATH_STATE_PATH_ERR
;
147 case MP_DRVR_PATH_STATE_LU_ERR
:
148 pProps
->pathState
= MP_PATH_STATE_LU_ERR
;
151 case MP_DRVR_PATH_STATE_RESERVED
:
152 pProps
->pathState
= MP_PATH_STATE_RESERVED
;
155 case MP_DRVR_PATH_STATE_REMOVED
:
156 pProps
->pathState
= MP_PATH_STATE_REMOVED
;
159 case MP_DRVR_PATH_STATE_TRANSITIONING
:
160 pProps
->pathState
= MP_PATH_STATE_TRANSITIONING
;
164 pProps
->pathState
= MP_PATH_STATE_UNKNOWN
;
168 pProps
->weight
= pathInfo
.weight
;
171 log(LOG_INFO
, "MP_GetPathLogicalUnitProperties()", " - exit");
173 return (MP_STATUS_SUCCESS
);