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.
37 * Called by the common layer to request the plugin to set the
38 * access state for a list of target port groups.
42 MP_SetTPGAccess(MP_OID oid
, MP_UINT32 count
,
43 MP_TPG_STATE_PAIR
*pTpgStateList
)
46 MP_TPG_STATE_PAIR
*head
= pTpgStateList
;
48 mp_iocdata_t mp_ioctl
;
49 mp_set_tpg_state_req_t setTpgStateRequest
;
55 MP_STATUS mpStatus
= MP_STATUS_SUCCESS
;
59 log(LOG_INFO
, "MP_SetTPGAccess()", " - enter");
62 if (NULL
== pTpgStateList
) {
64 log(LOG_INFO
, "MP_SetTPGAccess()",
65 "pTpgStateList is NULL");
67 return (MP_STATUS_INVALID_PARAMETER
);
71 if (g_scsi_vhci_fd
< 0) {
72 log(LOG_INFO
, "MP_SetTPGAccess()",
73 "invalid driver file handle");
74 log(LOG_INFO
, "MP_SetTPGAccess()", " - error exit");
75 return (MP_STATUS_FAILED
);
79 log(LOG_INFO
, "MP_SetTPGAccess()",
83 log(LOG_INFO
, "MP_SetTPGAccess()",
84 "oid.objectType = %d",
87 log(LOG_INFO
, "MP_SetTPGAccess()",
88 "oid.objectSequenceNumber = %llx",
89 oid
.objectSequenceNumber
);
92 log(LOG_INFO
, "MP_SetTPGAccess()",
97 for (r
= 0; r
< count
; r
++) {
99 if (head
->tpgOid
.ownerId
!= g_pluginOwnerID
) {
101 log(LOG_INFO
, "MP_SetTPGAccess()",
102 "pTpgStateList->tpgOid.ownerId is not for"
105 log(LOG_INFO
, "MP_SetTPGAccess()",
108 return (MP_STATUS_INVALID_PARAMETER
);
111 if (head
->tpgOid
.objectType
!=
112 MP_OBJECT_TYPE_TARGET_PORT_GROUP
) {
114 log(LOG_INFO
, "MP_SetTPGAccess()",
115 "pTpgStateList->tpgOid.objectType is not"
116 " MP_OBJECT_TYPE_TARGET_PORT_GROUP");
118 log(LOG_INFO
, "MP_SetTPGAccess()",
121 return (MP_STATUS_INVALID_PARAMETER
);
129 head
= pTpgStateList
;
131 for (r
= 0; r
< count
; r
++) {
133 (void) memset(&mp_ioctl
, 0, sizeof (mp_iocdata_t
));
134 (void) memset(&setTpgStateRequest
, 0,
135 sizeof (mp_set_tpg_state_req_t
));
137 setTpgStateRequest
.desiredState
138 = head
->desiredState
;
139 setTpgStateRequest
.luTpgPair
.luId
140 = oid
.objectSequenceNumber
;
141 setTpgStateRequest
.luTpgPair
.tpgId
142 = head
->tpgOid
.objectSequenceNumber
;
144 mp_ioctl
.mp_cmd
= MP_SET_TPG_ACCESS_STATE
;
145 mp_ioctl
.mp_ibuf
= (caddr_t
)&setTpgStateRequest
;
146 mp_ioctl
.mp_ilen
= sizeof (mp_set_tpg_state_req_t
);
147 mp_ioctl
.mp_xfer
= MP_XFER_WRITE
;
149 log(LOG_INFO
, "MP_SetTPGAccess()",
150 "mp_ioctl.mp_cmd (MP_SET_TPG_ACCESS_STATE) : %d",
153 log(LOG_INFO
, "MP_SetTPGAccess()",
154 "setTpgStateRequest.luTpgPair.luId = %llx",
155 setTpgStateRequest
.luTpgPair
.luId
);
157 log(LOG_INFO
, "MP_SetTPGAccess()",
158 "setTpgStateRequest.luTpgPair.tpgId = %llx",
159 setTpgStateRequest
.luTpgPair
.tpgId
);
161 log(LOG_INFO
, "MP_SetTPGAccess()",
162 "setTpgStateRequest.desiredState = %d",
163 setTpgStateRequest
.desiredState
);
165 ioctlStatus
= ioctl(g_scsi_vhci_fd
, MP_CMD
, &mp_ioctl
);
167 log(LOG_INFO
, "MP_SetTPGAccess()",
168 " IOCTL call returned: %d", ioctlStatus
);
170 if (ioctlStatus
< 0) {
174 if (ioctlStatus
!= 0) {
175 log(LOG_INFO
, "MP_SetTPGAccess()",
176 "IOCTL call failed. IOCTL error is: %d",
178 log(LOG_INFO
, "MP_SetTPGAccess()",
179 "IOCTL call failed. IOCTL error is: %s",
180 strerror(ioctlStatus
));
181 log(LOG_INFO
, "MP_SetTPGAccess()",
182 "IOCTL call failed. mp_ioctl.mp_errno: %x",
185 if (ENOTSUP
== ioctlStatus
) {
186 mpStatus
= MP_STATUS_UNSUPPORTED
;
187 } else if (0 == mp_ioctl
.mp_errno
) {
188 mpStatus
= MP_STATUS_FAILED
;
191 getStatus4ErrorCode(mp_ioctl
.mp_errno
);
194 log(LOG_INFO
, "MP_SetTPGAccess()",
204 log(LOG_INFO
, "MP_SetTPGAccess()", " - exit");
206 return (MP_STATUS_SUCCESS
);