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/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use is subject to license terms.
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
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "mp_utils.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteMP_STATUS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteMP_GetTargetPortOidList(MP_OID oid, MP_OID_LIST **ppList)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_STATUS mpStatus = MP_STATUS_SUCCESS;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "MP_GetTargetPortOidList()", " - enter");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mpStatus = getTargetPortOidList(oid, ppList);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "MP_GetTargetPortOidList()", " - exit");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (mpStatus);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteMP_STATUS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortegetTargetPortOidList(MP_OID oid, MP_OID_LIST **ppList)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mp_iocdata_t mp_ioctl;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint64_t *objList = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int numOBJ = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ioctlStatus = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_STATUS mpStatus = MP_STATUS_SUCCESS;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "getTargetPortOidList()", " - enter");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "getTargetPortOidList()",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "oid.objectSequenceNumber = %llx",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte oid.objectSequenceNumber);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (g_scsi_vhci_fd < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "getTargetPortOidList()",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "invalid driver file handle");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "getTargetPortOidList()", " - error exit");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (MP_STATUS_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte objList = (uint64_t *)calloc(1, DEFAULT_BUFFER_SIZE_TPG);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (NULL == objList) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "getTargetPortOidList()",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "no memory for objList(1)");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "getTargetPortOidList()",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " - error exit");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (MP_STATUS_INSUFFICIENT_MEMORY);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memset(&mp_ioctl, 0, sizeof (mp_iocdata_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mp_ioctl.mp_cmd = MP_GET_TARGET_PORT_LIST_FOR_TPG;
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)objList;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mp_ioctl.mp_olen = DEFAULT_BUFFER_SIZE_TPG;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mp_ioctl.mp_xfer = MP_XFER_READ;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "getTargetPortOidList()",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "mp_ioctl.mp_cmd (MP_GET_TARGET_PORT_LIST_FOR_TPG): %d",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mp_ioctl.mp_cmd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "getTargetPortOidList()",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "mp_ioctl.mp_obuf: %x", mp_ioctl.mp_obuf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "getTargetPortOidList()",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "mp_ioctl.mp_olen: %d", mp_ioctl.mp_olen);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "getTargetPortOidList()",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "mp_ioctl.mp_xfer: %d (MP_XFER_READ)",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mp_ioctl.mp_xfer);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ioctlStatus = ioctl(g_scsi_vhci_fd, MP_CMD, &mp_ioctl);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "getTargetPortOidList()",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "ioctl call returned ioctlStatus: %d",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ioctlStatus);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ioctlStatus < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ioctlStatus = errno;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((ioctlStatus != 0) && (MP_MORE_DATA != mp_ioctl.mp_errno)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "getTargetPortOidList()",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "IOCTL call failed. IOCTL error is: %d",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ioctlStatus);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "getTargetPortOidList()",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "IOCTL call failed. IOCTL error is: %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strerror(ioctlStatus));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "getTargetPortOidList()",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "IOCTL call failed. mp_ioctl.mp_errno: %x",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mp_ioctl.mp_errno);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(objList);
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, "getTargetPortOidList()",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " - error exit");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (mpStatus);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "getTargetPortOidList()",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " - mp_ioctl.mp_alen : %d",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mp_ioctl.mp_alen);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "getTargetPortOidList()",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " - sizeof (uint64_t): %d",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (uint64_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte numOBJ = mp_ioctl.mp_alen / sizeof (uint64_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "getTargetPortOidList()",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Length of list: %d", numOBJ);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (numOBJ < 1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "getTargetPortOidList()",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "driver returned empty list.");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(objList);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *ppList = createOidList(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (NULL == *ppList) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "getTargetPortOidList()",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "no memory for MP_OID_LIST");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "getTargetPortOidList()",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " - error exit");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (MP_STATUS_INSUFFICIENT_MEMORY);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (MP_STATUS_SUCCESS);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mp_ioctl.mp_alen > DEFAULT_BUFFER_SIZE_TPG) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "getTargetPortOidList()",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "buffer size too small, need : %d",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mp_ioctl.mp_alen);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(objList);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte objList = (uint64_t *)calloc(1, numOBJ * sizeof (uint64_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (NULL == objList) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "getTargetPortOidList()",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "no memory for objList(2)");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "getTargetPortOidList()",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " - error exit");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (MP_STATUS_INSUFFICIENT_MEMORY);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memset(&mp_ioctl, 0, sizeof (mp_iocdata_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mp_ioctl.mp_cmd = MP_GET_TARGET_PORT_LIST_FOR_TPG;
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)objList;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mp_ioctl.mp_olen = numOBJ * sizeof (uint64_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mp_ioctl.mp_xfer = MP_XFER_READ;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "getTargetPortOidList()",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "mp_ioctl.mp_cmd (MP_GET_TARGET_PORT_LIST_FOR_TPG): %d",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mp_ioctl.mp_cmd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "getTargetPortOidList()",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "mp_ioctl.mp_obuf: %x", mp_ioctl.mp_obuf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "getTargetPortOidList()",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "mp_ioctl.mp_olen: %d", mp_ioctl.mp_olen);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "getTargetPortOidList()",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "mp_ioctl.mp_xfer: %d (MP_XFER_READ)",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mp_ioctl.mp_xfer);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ioctlStatus = ioctl(g_scsi_vhci_fd, MP_CMD, &mp_ioctl);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "getTargetPortOidList()",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "ioctl call returned ioctlStatus: %d",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ioctlStatus);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ioctlStatus < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ioctlStatus = errno;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ioctlStatus != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "getTargetPortOidList()",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "IOCTL call failed. IOCTL error is: %d",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ioctlStatus);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "getTargetPortOidList()",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "IOCTL call failed. IOCTL error is: %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strerror(ioctlStatus));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "getTargetPortOidList()",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "IOCTL call failed. mp_ioctl.mp_errno: %x",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mp_ioctl.mp_errno);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(objList);
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 =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte getStatus4ErrorCode(mp_ioctl.mp_errno);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "getTargetPortOidList()",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " - error exit");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (mpStatus);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *ppList = createOidList(numOBJ);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (NULL == *ppList) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "getTargetPortOidList()",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "no memory for *ppList");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(objList);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "getTargetPortOidList()",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " - error exit");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (MP_STATUS_INSUFFICIENT_MEMORY);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (*ppList)->oidCount = numOBJ;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "getTargetPortOidList()",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "(*ppList)->oidCount = %d",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (*ppList)->oidCount);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < numOBJ; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (*ppList)->oids[i].objectType = MP_OBJECT_TYPE_TARGET_PORT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (*ppList)->oids[i].ownerId = g_pluginOwnerID;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (*ppList)->oids[i].objectSequenceNumber = objList[i];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "getTargetPortOidList()",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "(*ppList)->oids[%d].objectType = %d",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i, (*ppList)->oids[i].objectType);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "getTargetPortOidList()",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "(*ppList)->oids[%d].ownerId = %d",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i, (*ppList)->oids[i].ownerId);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "getTargetPortOidList()",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "(*ppList)->oids[%d].objectSequenceNumber = %llx",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i, (*ppList)->oids[i].objectSequenceNumber);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(objList);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "getTargetPortOidList()", " - exit");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (MP_STATUS_SUCCESS);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}