fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER START
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The contents of this file are subject to the terms of the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Common Development and Distribution License (the "License").
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You may not use this file except in compliance with the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * or http://www.opensolaris.org/os/licensing.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See the License for the specific language governing permissions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and limitations under the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * When distributing Covered Code, include this CDDL HEADER in each
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If applicable, add the following below this CDDL HEADER, with the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fields enclosed by brackets "[]" replaced with your own identifying
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * information: Portions Copyright [yyyy] [name of copyright owner]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER END
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
0c034175550709323575bc82b80a835256239e86Jiri Svoboda * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <string.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <syslog.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <errno.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <unistd.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <stropts.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <libdevinfo.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "mp_utils.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct walk_devlink {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *path;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size_t len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char **linkpp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} walk_devlink_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteget_devlink(di_devlink_t devlink, void *arg) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte walk_devlink_t *warg = (walk_devlink_t *)arg;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "get_devlink()", " - enter");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *(warg->linkpp) = strdup(di_devlink_path(devlink));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "get_devlink()", " - exit");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DI_WALK_TERMINATE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortechar
0c034175550709323575bc82b80a835256239e86Jiri Svoboda*getDeviceFileName(MP_UINT64 objectSequenceNumber)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *deviceFileName = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte di_node_t root_node = DI_NODE_NIL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte di_node_t cur_node = DI_NODE_NIL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
0c034175550709323575bc82b80a835256239e86Jiri Svoboda int instNum;
0c034175550709323575bc82b80a835256239e86Jiri Svoboda int majorNum;
0c034175550709323575bc82b80a835256239e86Jiri Svoboda MP_UINT64 osn;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *pathName = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *minorName = "c,raw";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *devLink = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char fullName[512];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte walk_devlink_t warg;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte di_devlink_handle_t dlHandle = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int diStatus = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "getDeviceFileName()", " - enter");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "getDeviceFileName()",
0c034175550709323575bc82b80a835256239e86Jiri Svoboda " - objectSequenceNumber: %llx",
0c034175550709323575bc82b80a835256239e86Jiri Svoboda objectSequenceNumber);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte root_node = di_init("/", DINFOCACHE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (DI_NODE_NIL == root_node) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "MP_GetMultipathLusPlugin()",
6162934bde6d217b658d7a46f26727932be8f711Ramesh Chitrothu " - $ERROR, di_init() failed");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cur_node = di_drv_first_node("scsi_vhci", root_node);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (DI_NODE_NIL == cur_node) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "getDeviceFileName()",
6162934bde6d217b658d7a46f26727932be8f711Ramesh Chitrothu " - $ERROR, di_drv_first_node() failed");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte di_fini(root_node);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cur_node = di_child_node(cur_node);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (DI_NODE_NIL != cur_node) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
0c034175550709323575bc82b80a835256239e86Jiri Svoboda instNum = di_instance(cur_node);
0c034175550709323575bc82b80a835256239e86Jiri Svoboda majorNum = di_driver_major(cur_node);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
0c034175550709323575bc82b80a835256239e86Jiri Svoboda osn = 0;
0c034175550709323575bc82b80a835256239e86Jiri Svoboda osn = MP_STORE_INST_TO_ID(instNum, osn);
0c034175550709323575bc82b80a835256239e86Jiri Svoboda osn = MP_STORE_MAJOR_TO_ID(majorNum, osn);
0c034175550709323575bc82b80a835256239e86Jiri Svoboda
0c034175550709323575bc82b80a835256239e86Jiri Svoboda if (osn == objectSequenceNumber) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "getDeviceFileName()",
6162934bde6d217b658d7a46f26727932be8f711Ramesh Chitrothu " - found node.");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cur_node = di_sibling_node(cur_node);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (DI_NODE_NIL != cur_node) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dlHandle = di_devlink_init(NULL, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (NULL == dlHandle) {
6162934bde6d217b658d7a46f26727932be8f711Ramesh Chitrothu log(LOG_INFO, "getDeviceFileName()",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " - $ERROR, di_devlink_init() failed.");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
6162934bde6d217b658d7a46f26727932be8f711Ramesh Chitrothu di_fini(root_node);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
6162934bde6d217b658d7a46f26727932be8f711Ramesh Chitrothu return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pathName = di_devfs_path(cur_node);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(fullName, 511, "%s:%s", pathName, minorName);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "getDeviceFileName()",
6162934bde6d217b658d7a46f26727932be8f711Ramesh Chitrothu " - fullName: {%s]", fullName);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memset(&warg, 0, sizeof (walk_devlink_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte devLink = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte warg.linkpp = &devLink;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte diStatus = di_devlink_walk(dlHandle,
6162934bde6d217b658d7a46f26727932be8f711Ramesh Chitrothu NULL,
6162934bde6d217b658d7a46f26727932be8f711Ramesh Chitrothu fullName,
6162934bde6d217b658d7a46f26727932be8f711Ramesh Chitrothu DI_PRIMARY_LINK,
6162934bde6d217b658d7a46f26727932be8f711Ramesh Chitrothu (void *)&warg,
6162934bde6d217b658d7a46f26727932be8f711Ramesh Chitrothu get_devlink);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (diStatus != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "getDeviceFileName()",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "diStatus: %d", diStatus);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (diStatus < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte diStatus = errno;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "getDeviceFileName()",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "diStatus: %d", diStatus);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "getDeviceFileName()",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "strerror(diStatus): %s", strerror(diStatus));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (NULL != devLink) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte deviceFileName =
6162934bde6d217b658d7a46f26727932be8f711Ramesh Chitrothu (char *)calloc(1, strlen(devLink) + 1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(deviceFileName, devLink,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strlen(devLink));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "getDeviceFileName()",
6162934bde6d217b658d7a46f26727932be8f711Ramesh Chitrothu " - $ERROR, devLink is NULL.");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte deviceFileName =
6162934bde6d217b658d7a46f26727932be8f711Ramesh Chitrothu (char *)calloc(1, 256);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(deviceFileName, pathName, 255);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte di_devfs_path_free(pathName);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) di_devlink_fini(&dlHandle);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte di_fini(root_node);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
6162934bde6d217b658d7a46f26727932be8f711Ramesh Chitrothu free(devLink);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "getDeviceFileName()", " - exit");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (deviceFileName);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteMP_STATUS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteMP_GetMPLogicalUnitProperties(MP_OID oid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_MULTIPATH_LOGICAL_UNIT_PROPERTIES *pProps)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mp_iocdata_t mp_ioctl;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mp_logical_unit_prop_t luInfo;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OID overridePathOID;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ioctlStatus = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int vendorLength = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int productLength = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int revisionLength = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *deviceFileName = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_STATUS mpStatus = MP_STATUS_SUCCESS;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "MP_GetMPLogicalUnitProperties()", " - enter");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "MP_GetMPLogicalUnitProperties()",
6162934bde6d217b658d7a46f26727932be8f711Ramesh Chitrothu "oid.objectSequenceNumber = %llx",
6162934bde6d217b658d7a46f26727932be8f711Ramesh Chitrothu oid.objectSequenceNumber);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (g_scsi_vhci_fd < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "MP_GetMPLogicalUnitProperties()",
6162934bde6d217b658d7a46f26727932be8f711Ramesh Chitrothu "invalid driver file handle");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "MP_GetMPLogicalUnitProperties()",
6162934bde6d217b658d7a46f26727932be8f711Ramesh Chitrothu " - error exit");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (MP_STATUS_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memset(&mp_ioctl, 0, sizeof (mp_iocdata_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memset(&luInfo, 0, sizeof (mp_logical_unit_prop_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mp_ioctl.mp_cmd = MP_GET_LU_PROP;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mp_ioctl.mp_ibuf = (caddr_t)&oid.objectSequenceNumber;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mp_ioctl.mp_ilen = sizeof (oid.objectSequenceNumber);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mp_ioctl.mp_obuf = (caddr_t)&luInfo;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mp_ioctl.mp_olen = sizeof (mp_logical_unit_prop_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mp_ioctl.mp_xfer = MP_XFER_READ;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ioctlStatus = ioctl(g_scsi_vhci_fd, MP_CMD, &mp_ioctl);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "MP_GetMPLogicalUnitProperties()",
6162934bde6d217b658d7a46f26727932be8f711Ramesh Chitrothu " IOCTL call returned: %d", ioctlStatus);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ioctlStatus < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ioctlStatus = errno;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ioctlStatus != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "MP_GetMPLogicalUnitProperties()",
6162934bde6d217b658d7a46f26727932be8f711Ramesh Chitrothu "IOCTL call failed. IOCTL error is: %d",
6162934bde6d217b658d7a46f26727932be8f711Ramesh Chitrothu ioctlStatus);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "MP_GetMPLogicalUnitProperties()",
6162934bde6d217b658d7a46f26727932be8f711Ramesh Chitrothu "IOCTL call failed. IOCTL error is: %s",
6162934bde6d217b658d7a46f26727932be8f711Ramesh Chitrothu strerror(ioctlStatus));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "MP_GetMPLogicalUnitProperties()",
6162934bde6d217b658d7a46f26727932be8f711Ramesh Chitrothu "IOCTL call failed. mp_ioctl.mp_errno: %x",
6162934bde6d217b658d7a46f26727932be8f711Ramesh Chitrothu mp_ioctl.mp_errno);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ENOTSUP == ioctlStatus) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mpStatus = MP_STATUS_UNSUPPORTED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (0 == mp_ioctl.mp_errno) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mpStatus = MP_STATUS_FAILED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mpStatus = getStatus4ErrorCode(mp_ioctl.mp_errno);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "MP_GetMPLogicalUnitProperties()",
6162934bde6d217b658d7a46f26727932be8f711Ramesh Chitrothu " - error exit");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (mpStatus);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memset(pProps, 0, sizeof (MP_MULTIPATH_LOGICAL_UNIT_PROPERTIES));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pProps->asymmetric = luInfo.asymmetric;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pProps->autoFailbackEnabled = luInfo.autoFailbackEnabled;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pProps->autoProbingEnabled = luInfo.autoProbingEnabled;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pProps->currentFailbackPollingRate = luInfo.currentFailBackPollingRate;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pProps->currentLoadBalanceType = luInfo.currentLoadBalanceType;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pProps->currentProbingPollingRate = luInfo.currentProbingPollingRate;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte deviceFileName = getDeviceFileName(oid.objectSequenceNumber);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (NULL != deviceFileName) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "MP_GetMPLogicalUnitProperties()",
6162934bde6d217b658d7a46f26727932be8f711Ramesh Chitrothu "deviceFileName: %s",
6162934bde6d217b658d7a46f26727932be8f711Ramesh Chitrothu deviceFileName);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(pProps->deviceFileName,
6162934bde6d217b658d7a46f26727932be8f711Ramesh Chitrothu deviceFileName,
6162934bde6d217b658d7a46f26727932be8f711Ramesh Chitrothu sizeof (pProps->deviceFileName) - 1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(deviceFileName);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pProps->failbackPollingRateMax = luInfo.failbackPollingRateMax;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pProps->logicalUnitGroupID = luInfo.luGroupID;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(pProps->name, luInfo.name, sizeof (pProps->name) - 1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pProps->nameType = luInfo.nameType;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte overridePathOID.objectSequenceNumber = luInfo.overridePathID;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte overridePathOID.objectType = MP_OBJECT_TYPE_PATH_LU;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte overridePathOID.ownerId = g_pluginOwnerID;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memcpy(&pProps->overridePath, &overridePathOID, sizeof (MP_OID));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pProps->probingPollingRateMax = luInfo.probingPollingRateMax;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte vendorLength = sizeof (pProps->vendor);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte productLength = sizeof (pProps->product);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte revisionLength = sizeof (pProps->revision);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(pProps->vendor,
6162934bde6d217b658d7a46f26727932be8f711Ramesh Chitrothu luInfo.prodInfo.vendor,
6162934bde6d217b658d7a46f26727932be8f711Ramesh Chitrothu vendorLength);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(pProps->product,
6162934bde6d217b658d7a46f26727932be8f711Ramesh Chitrothu luInfo.prodInfo.product,
6162934bde6d217b658d7a46f26727932be8f711Ramesh Chitrothu productLength);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(pProps->revision,
6162934bde6d217b658d7a46f26727932be8f711Ramesh Chitrothu luInfo.prodInfo.revision,
6162934bde6d217b658d7a46f26727932be8f711Ramesh Chitrothu revisionLength);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "MP_GetMPLogicalUnitProperties()", " - exit");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (MP_STATUS_SUCCESS);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}