2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License (the "License").
2N/A * You may not use this file except in compliance with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A */
2N/A/*
2N/A * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
2N/A * Use is subject to license terms.
2N/A */
2N/A
2N/A#include <syslog.h>
2N/A#include <errno.h>
2N/A#include <unistd.h>
2N/A#include <stropts.h>
2N/A
2N/A#include "mp_utils.h"
2N/A
2N/A
2N/A/*
2N/A * Called by the common layer to request to disable a path
2N/A */
2N/A
2N/AMP_STATUS
2N/AMP_DisablePath(MP_OID oid)
2N/A{
2N/A mp_iocdata_t mp_ioctl;
2N/A
2N/A int ioctlStatus = 0;
2N/A
2N/A MP_STATUS mpStatus = MP_STATUS_SUCCESS;
2N/A
2N/A
2N/A
2N/A log(LOG_INFO, "MP_DisablePath()", " - enter");
2N/A
2N/A
2N/A log(LOG_INFO, "MP_DisablePath()",
2N/A "oid.objectSequenceNumber = %llx",
2N/A oid.objectSequenceNumber);
2N/A
2N/A if (g_scsi_vhci_fd < 0) {
2N/A log(LOG_INFO, "MP_DisablePath()",
2N/A "invalid driver file handle");
2N/A log(LOG_INFO, "MP_DisablePath()", " - error exit");
2N/A return (MP_STATUS_FAILED);
2N/A }
2N/A
2N/A (void) memset(&mp_ioctl, 0, sizeof (mp_iocdata_t));
2N/A
2N/A mp_ioctl.mp_cmd = MP_DISABLE_PATH;
2N/A mp_ioctl.mp_ibuf = (caddr_t)&oid.objectSequenceNumber;
2N/A mp_ioctl.mp_ilen = sizeof (oid.objectSequenceNumber);
2N/A mp_ioctl.mp_xfer = MP_XFER_WRITE;
2N/A
2N/A log(LOG_INFO, "MP_DisablePath()",
2N/A "mp_ioctl.mp_cmd (MP_DISABLE_PATH) : %d",
2N/A mp_ioctl.mp_cmd);
2N/A
2N/A ioctlStatus = ioctl(g_scsi_vhci_fd, MP_CMD, &mp_ioctl);
2N/A
2N/A log(LOG_INFO, "MP_DisablePath()",
2N/A " IOCTL call returned: %d", ioctlStatus);
2N/A
2N/A if (ioctlStatus < 0) {
2N/A ioctlStatus = errno;
2N/A }
2N/A
2N/A if (ioctlStatus != 0) {
2N/A log(LOG_INFO, "MP_DisablePath()",
2N/A "IOCTL call failed. IOCTL error is: %d",
2N/A ioctlStatus);
2N/A log(LOG_INFO, "MP_DisablePath()",
2N/A "IOCTL call failed. IOCTL error is: %s",
2N/A strerror(ioctlStatus));
2N/A log(LOG_INFO, "MP_DisablePath()",
2N/A "IOCTL call failed. mp_ioctl.mp_errno: %x",
2N/A mp_ioctl.mp_errno);
2N/A
2N/A if (ENOTSUP == ioctlStatus) {
2N/A mpStatus = MP_STATUS_UNSUPPORTED;
2N/A } else if (0 == mp_ioctl.mp_errno) {
2N/A mpStatus = MP_STATUS_FAILED;
2N/A } else {
2N/A mpStatus = getStatus4ErrorCode(mp_ioctl.mp_errno);
2N/A }
2N/A
2N/A log(LOG_INFO, "MP_DisablePath()",
2N/A " - error exit");
2N/A
2N/A return (mpStatus);
2N/A }
2N/A
2N/A
2N/A log(LOG_INFO, "MP_DisablePath()", " - exit");
2N/A
2N/A return (MP_STATUS_SUCCESS);
2N/A}