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
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*LINTLIBRARY*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This module is part of fibre channel interface library.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * I18N message number ranges
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This file: 11000 - 11499
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Shared common messages: 1 - 1999
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* #define _POSIX_SOURCE 1 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Includes */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <stdlib.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <stdio.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/file.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/errno.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/types.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/param.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/stat.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <fcntl.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <unistd.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <errno.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <string.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <strings.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/sunddi.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/scsi/scsi.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <nl_types.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <l_common.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <stgcom.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <l_error.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <g_state.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Forward declarations */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int issue_lip(char *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Global variables */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern uchar_t g_switch_to_alpa[];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern uchar_t g_sf_alpa_to_switch[];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * starts a device.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * RETURNS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 0 if O.K.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * non-zero otherwise
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteg_dev_start(char *drv_path, int verbose)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((drv_path != NULL) && (*drv_path != '\0')) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status = g_start(drv_path)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_INVALID_PATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * stops a device. If the device was
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * reserved by a host, it gets multiple
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * paths to the device and try to stop the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * device using a different path.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 0 if OK
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * -1 otherwise
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteg_dev_stop(char *drv_path, struct wwn_list_struct *wwn_list,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int verbose)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint status, err;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortechar *phys_path;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestruct dlist *ml = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* stop the device */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Make the stop NOT immediate, so we wait. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((drv_path == NULL) || (*drv_path == '\0')) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_INVALID_PATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((status = g_stop(drv_path, 0)) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * In case of reservation conflict,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * get the multiple paths and try to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * stop the device through the path
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * which held the reservations.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((status & ~L_SCSI_ERROR) == STATUS_RESERVATION_CONFLICT) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((phys_path = g_get_physical_name(drv_path))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_INVALID_PATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((err = g_get_multipath(phys_path, &ml,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wwn_list, verbose)) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (err);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (ml != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (g_stop(ml->logical_path, 0) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_free_multipath(ml);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto done;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ml = ml->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_free_multipath(ml);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortedone:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This function is for Leadville devices only
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * It takes as input the actual path on which to issue the LIP and issues it
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * INPUT :
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Path to the FCA devctl node.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * For example,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * /devices/pci@6,2000/pci@2/SUNW,qlc@4/fp@0,0:devctl
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * No SCSI_VHCI paths will work. No checks are done and we'll let the ioctl
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * handle any failures if it is passed in.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * RETURNS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 0 on Success
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * non-zero otherwise
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteissue_lip(char *fp_path, int verbose)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int fp_fd;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte la_wwn_t wwn;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcio_t fcio;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * open fp path with exclusive path, otherwise,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * FCIO_RESET_LINK ioctl will fail with permission
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * denied error.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((fp_fd = g_object_open(fp_path, O_RDONLY | O_EXCL)) < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_OPEN_PATH_FAIL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (verbose) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, MSGSTR(11001,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " Reinitializing the loop at: %s\n"), fp_path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcio.fcio_cmd = FCIO_RESET_LINK;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcio.fcio_xfer = FCIO_XFER_WRITE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Reset the local loop here (fcio_ibuf = 0).
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Reset a remote loop on the Fabric by
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * passing its node wwn (fcio_len = sizeof(nwwn)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and fcio_ibuf = (caddr_t)&nwwn) to the port driver.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) bzero((caddr_t)&wwn, sizeof (wwn));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcio.fcio_ilen = sizeof (wwn);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcio.fcio_ibuf = (caddr_t)&wwn;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (g_issue_fcio_ioctl(fp_fd, &fcio, verbose) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte I_DPRINTF(" issue_lip: FCIO_RESET_LINK"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " ioctl failed: %s\n", fp_path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) close(fp_fd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_FCIO_RESET_LINK_FAIL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) close(fp_fd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Issues the LIP (Loop Intialization Protocol)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * on a nexus path (in case of socal) or on an
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fp path (in case of fabric).
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * RETURNS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 0 O.K.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * non-zero otherwise
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteg_force_lip(char *path_phys, int verbose)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint fd, err = 0, i = 0, pathcnt = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortechar nexus_path[MAXPATHLEN], *nexus_path_ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortechar *charPtr, fp_path[MAXPATHLEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestruct stat stbuf;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteuint_t dev_type;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortemp_pathlist_t pathlist;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortemp_pathinfo_t *pinfop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* return invalid path if path_phys NULL */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (path_phys == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_INVALID_PATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Make a copy of the arg passed in ... we'll need it down */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcpy(fp_path, path_phys);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strstr(path_phys, SCSI_VHCI) != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Its an MPXIO device path
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * First, Get a list of all the pHCI for the given vHCI
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Then issue a LIP on all the pHCI FCAs that are in the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * MDI_PATHINFO_STATE_ONLINE or MDI_PATHINFO_STATE_STANDBY
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * states.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (g_get_pathlist(fp_path, &pathlist)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_INVALID_PATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < pathlist.path_count; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pinfop = &pathlist.path_info[i];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((pinfop->path_state ==
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MDI_PATHINFO_STATE_ONLINE) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (pinfop->path_state ==
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MDI_PATHINFO_STATE_STANDBY)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pathcnt++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sprintf(fp_path, "%s%s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pinfop->path_hba, FC_CTLR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (issue_lip(fp_path, verbose) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte err++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(pathlist.path_info);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err == 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err == pathcnt)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_FCIO_FORCE_LIP_FAIL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_FCIO_FORCE_LIP_PARTIAL_FAIL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Non-MPXIO case */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((dev_type = g_get_path_type(fp_path)) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_INVALID_PATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (dev_type & FC_FCA_MASK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strstr(fp_path, DRV_NAME_SSD) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strstr(fp_path, SES_NAME) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strstr(fp_path, DRV_NAME_ST)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((charPtr = strrchr(fp_path, '/')) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_INVALID_PATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *charPtr = '\0';
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* append devctl to the path */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcat(fp_path, FC_CTLR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* should have fp transport node to continue. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!(dev_type & FC_XPORT_MASK)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_INVALID_PATH_TYPE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (stat(fp_path, &stbuf) < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_LSTAT_ERROR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((stbuf.st_mode & S_IFMT) == S_IFDIR) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* append devctl to the path */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcat(fp_path, FC_CTLR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (issue_lip(fp_path, verbose));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else { /* for fc4 devices */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((err = g_get_nexus_path(path_phys,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &nexus_path_ptr)) != 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (err);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcpy(nexus_path, nexus_path_ptr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_destroy_data(nexus_path_ptr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte P_DPRINTF(" g_force_lip: Force lip on:"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " Path %s\n", nexus_path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* open driver */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((fd = g_object_open(nexus_path,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte O_NDELAY | O_RDONLY)) == -1)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_OPEN_PATH_FAIL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (verbose) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(11000,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " Forcing lip (Loop Initialization "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Protocol)"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "\n on loop at: %s\n"), nexus_path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ioctl(fd, FCIO_FORCE_LIP) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte I_DPRINTF(" FCIO_FORCE_LIP ioctl failed.\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) close(fd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_FCIO_FORCE_LIP_FAIL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) close(fd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Takes one or more drives offline.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If the force flag is supplied then: (1) don't pass the exclusive flag
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * to the acquire routine and (2) allow the offline to fail
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If any acquire fails, print an error message and continue.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * RETURNS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 0 iff each offline succeeds
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * non-zero otherwise
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteg_offline_drive(struct dlist *dl, int force_flag)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortedevctl_hdl_t devhdl;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* for each drive attempt to take it offline */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (; dl != NULL; dl = dl->next) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* attempt to acquire the device */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((devhdl = devctl_device_acquire(dl->dev_path,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte force_flag ? 0 : DC_EXCL)) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (errno != EBUSY) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte P_DPRINTF("%s: Could not acquire"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " the device: %s\n\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strerror(errno), dl->dev_path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* attempt to offline the drive */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((devctl_device_offline(devhdl) != 0) && !force_flag) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) devctl_release(devhdl);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_DEV_BUSY);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* offline succeeded -- release handle acquired above */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) devctl_release(devhdl);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Brings one or more drives online.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If the force flag is supplied then: (1) don't pass the exclusive
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * flag to the acquire routine and (2) allow the offline to fail
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If any acquire fails, continue with the next device.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * RETURNS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * None.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteg_online_drive(struct dlist *dl, int force_flag)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortedevctl_hdl_t devhdl;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (dl != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((devhdl = devctl_device_acquire(dl->dev_path,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte force_flag ? 0 : DC_EXCL)) != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) devctl_device_online(devhdl);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) devctl_release(devhdl);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dl = dl->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteg_ll_to_str(uchar_t *wwn_ll, char *wwn_str)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint j, k, fnib, snib;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteuchar_t c;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (j = 0, k = 0; j < 8; j++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte c = wwn_ll[j];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fnib = ((int)(c & 0xf0) >> 4);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte snib = (c & 0x0f);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (fnib >= 0 && fnib <= 9)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wwn_str[k++] = '0' + fnib;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else if (fnib >= 10 && fnib <= 15)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wwn_str[k++] = 'a' + fnib - 10;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (snib >= 0 && snib <= 9)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wwn_str[k++] = '0' + snib;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else if (snib >= 10 && snib <= 15)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wwn_str[k++] = 'a' + snib - 10;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wwn_str[k] = '\0';
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Creates a list of nexus paths for each
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * hotpluggable device and sends the list to g_force_lip(),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * which forces the LIP on each nexus path in the list.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * RETURNS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * None.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteg_forcelip_all(struct hotplug_disk_list *disk_list)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortechar *p;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint len, ndevs = 0, err = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestruct dlist *dl;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestruct loop_list { /* adp_name holds full dev path for MPXIO devices */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char adp_name[MAXPATHLEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct loop_list *next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct loop_list *prev;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } *llist_head, *llist_tail, *llist, *llist1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte llist_head = llist_tail = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (disk_list) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (disk_list->dev_location == SENA) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dl = disk_list->seslist;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dl = disk_list->dlhead;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (dl != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strstr(dl->dev_path, SCSI_VHCI) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* non-MPXIO device path */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (disk_list->dev_location == SENA) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte p = strstr(dl->dev_path, SLASH_SES);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte p = strstr(dl->dev_path, SLSH_DRV_NAME_SSD);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (p == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte p = strstr(dl->dev_path,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SLSH_DRV_NAME_ST);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (p == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte P_DPRINTF(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " g_forcelip_all: Not able to do"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " LIP on this path because path "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "invalid.\n Path: %s\n", dl->dev_path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dl = dl->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte len = strlen(dl->dev_path) - strlen(p);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* MPXIO path */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte len = strlen(dl->dev_path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Avoid issuing forcelip
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * on the same HA more than once
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (llist_head != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (llist1 = llist_head; llist1 != NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte llist1 = llist1->next) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strncmp(llist1->adp_name,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dl->dev_path, len) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (llist1 != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dl = dl->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((llist = (struct loop_list *)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte g_zalloc(sizeof (struct loop_list))) == NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_MALLOC_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(llist->adp_name, dl->dev_path, len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte llist->adp_name[len] = '\0';
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ndevs++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (llist_head == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte llist_head = llist_tail = llist;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte llist->prev = llist_tail;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte llist_tail = llist_tail->next = llist;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dl = dl->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte disk_list = disk_list->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (llist_head) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((err = g_force_lip(llist_head->adp_name, 0)) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_destroy_data(llist);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_destroy_data(llist_head);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (err);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte llist = llist_head;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte llist_head = llist_head->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_destroy_data((char *)llist);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sleep(ndevs*10);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}