/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
*/
#include <errno.h>
#include <unistd.h>
#include <stropts.h>
#include <fcntl.h>
#include <libdevinfo.h>
#include "mp_utils.h"
/*
* The plugin library will call MP_CMD ioctl with
* MP_GET_TARGET_PORT_LIST_FOR_TPG subcommand.
* For each target port, the plugin will get the target port name property.
*
* A scsi_vhci device with pathinfo containing matching target port name
* may potentially be associated with the given TPG.
* The plugin library will check the TPG list for qualifying scsi_vhci
* devices and find a matching TPG id.
*
* An rfe was filed against MDI to
* refresh DINFOCACHE snapshot for pathinfo update.
*/
/*
* Returns MP_TRUE if the ID found in the dev info snapshot matches the ID
* provided by the schi_vhci driver.
*/
{
int tpg = 0;
if (MP_STATUS_SUCCESS != mpStatus) {
" - getAssociatedTPGOidList() failed: %d",
mpStatus);
return (MP_FALSE);
}
&tpgProps);
if (MP_STATUS_SUCCESS != mpStatus) {
" - getTargetPortGroupProperties() failed: %d",
mpStatus);
return (MP_FALSE);
}
" - found a match");
break;
}
}
return (status);
}
/*
* Returns the number of matches found. If pOidList is not NULL, then
* populate it. A return values of -1 indicates and error, zerom menas
* no match is found.
*/
{
int numNodes = 0;
int tp = 0;
int ioctlStatus = 0;
int match = 0;
int sv_child_inst = 0;
int sv_child_major = 0;
/* Look through the list of target ports for a portName that matches */
"mp_ioctl.mp_cmd (MP_GET_TARGET_PORT_PROP) : %d",
if (ioctlStatus < 0) {
ioctlStatus = errno;
}
if (ioctlStatus != 0) {
"IOCTL call failed. IOCTL error is: %d",
"IOCTL call failed. IOCTL error is: %s",
"IOCTL call failed. mp_ioctl.mp_errno: %x",
return (-1);
}
if (DI_NODE_NIL == sv_node) {
" - di_drv_first_node() failed");
return (-1);
}
while (DI_NODE_NIL != child_node) {
match = 0;
while (DI_PATH_NIL != path) {
(void) di_path_prop_lookup_strings(path,
"target-port", &portName);
match = 1;
break;
}
}
}
if (match) {
" - got a match");
if (status < 0) {
" - stat() call failed: %d",
status);
" - errno: [%d].", errno);
" - strerror(errno): [%s].",
" - error exit.");
return (-1);
}
osn = 0;
osn);
/*
* OK, found an portName that matches, let's
* to see if the IDs match.
*/
if (MP_TRUE != hasTpgMatch) {
continue;
}
if (haveList &&
osn;
}
++numNodes;
}
}
}
return (numNodes);
}
/*
* Called by the common layer to request a list of multipath logical units
* associated with a given target port group.
*/
{
int i = 0;
int numNodes = 0;
"oid.objectSequenceNumber = %llx",
if (MP_STATUS_SUCCESS != mpStatus) {
" - getTargetPortGroupProperties() failed: %d",
mpStatus);
return (mpStatus);
}
/* The TPG ID we will use as a serch key */
/* Get a list of target ports for the TPG */
if (MP_STATUS_SUCCESS != mpStatus) {
" - getTargetPortOidList() failed: %d", mpStatus);
return (mpStatus);
}
/* Take a snapshot */
if (DI_NODE_NIL == root_node) {
" - di_init() failed");
return (MP_STATUS_FAILED);
}
/* search for the number of multipath logical units that match */
if (numNodes < 0) {
" - unable to get OID list.");
" - error exit");
return (MP_STATUS_FAILED);
}
if (0 == numNodes) {
" - unable to create OID list.");
return (MP_STATUS_INSUFFICIENT_MEMORY);
}
" - returning empty list.");
return (MP_STATUS_SUCCESS);
}
"no memory for *ppList");
" - error exit");
return (MP_STATUS_INSUFFICIENT_MEMORY);
}
/* now populate the list */
"(*ppList)->oids[%d].objectType = %d",
"(*ppList)->oids[%d].ownerId = %d",
"(*ppList)->oids[%d].objectSequenceNumber = %llx",
}
return (MP_STATUS_SUCCESS);
}