fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER START
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 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See the License for the specific language governing permissions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and limitations under the License.
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 * CDDL HEADER END
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use is subject to license terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*LINTLIBRARY*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This module is part of fibre channel interface library.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * I18N message number ranges
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This file: 11000 - 11499
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Shared common messages: 1 - 1999
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* #define _POSIX_SOURCE 1 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Includes */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Forward declarations */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int issue_lip(char *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Global variables */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * starts a device.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * non-zero otherwise
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 * -1 otherwise
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteg_dev_stop(char *drv_path, struct wwn_list_struct *wwn_list,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* stop the device */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Make the stop NOT immediate, so we wait. */
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 if ((status & ~L_SCSI_ERROR) == STATUS_RESERVATION_CONFLICT) {
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 * Path to the FCA devctl node.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * For example,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * /devices/pci@6,2000/pci@2/SUNW,qlc@4/fp@0,0:devctl
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 * 0 on Success
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * non-zero otherwise
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 if ((fp_fd = g_object_open(fp_path, O_RDONLY | O_EXCL)) < 0) {
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 if (g_issue_fcio_ioctl(fp_fd, &fcio, verbose) != 0) {
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 * non-zero otherwise
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* return invalid path if path_phys NULL */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Make a copy of the arg passed in ... we'll need it down */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Its an MPXIO device path
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 /* Non-MPXIO case */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((dev_type = g_get_path_type(fp_path)) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* append devctl to the path */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* should have fp transport node to continue. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* append devctl to the path */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else { /* for fc4 devices */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* open driver */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " Forcing lip (Loop Initialization "
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 * 0 iff each offline succeeds
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * non-zero otherwise
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* for each drive attempt to take it offline */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* attempt to acquire the device */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((devhdl = devctl_device_acquire(dl->dev_path,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " the device: %s\n\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* attempt to offline the drive */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((devctl_device_offline(devhdl) != 0) && !force_flag) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* offline succeeded -- release handle acquired above */
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 if ((devhdl = devctl_device_acquire(dl->dev_path,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (j = 0, k = 0; j < 8; j++) {
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 Forteg_forcelip_all(struct hotplug_disk_list *disk_list)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestruct loop_list { /* adp_name holds full dev path for MPXIO devices */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* non-MPXIO device path */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " g_forcelip_all: Not able to do"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " LIP on this path because path "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* MPXIO path */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Avoid issuing forcelip
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * on the same HA more than once
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(llist->adp_name, dl->dev_path, len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((err = g_force_lip(llist_head->adp_name, 0)) != 0) {