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 the photon Command Line
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Interface program.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * I18N message number ranges
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This file: 9500 - 9999
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Shared common messages: 1 - 1999
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Includes */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Defines */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Global variables */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* External functions */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int rand_r(unsigned int *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get the system time and use "system seconds"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * as 'seed' to generate a random number. Then,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * wait between 1/10 - 1/2 seconds before retry.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get the current process id and ex-or it with
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the seed so that the random number is always
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * different even in case of multiple processes
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * generate a random number at the same time.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get a random number. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Execute a command and determine the result.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortecmd(int file, struct uscsi_cmd *command, int flag)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Set function flags for driver.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Set Automatic request sense enable
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* intialize error message array */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* print command for debug */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "SCSI command: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte g_scsi_find_command_name(command->uscsi_cdb[0]));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < (int)command->uscsi_cdblen; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf("\n\tlen=0x%x bufaddr=0x%x buflen=0x%x"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " flags=0x%x\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Default command timeout in case command left it 0
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Issue command - finally */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((status != 0) && (command->uscsi_status == 0)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf("Unexpected USCSICMD ioctl error: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Just a SCSI error, create error message
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Retry once for Unit Attention,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Not Ready, and Aborted Command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (((char)command->uscsi_rqlen - (char)command->uscsi_rqresid) > 0)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rqbuf = (struct scsi_extended_sense *)command->uscsi_rqbuf;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " Retrying...\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " UNIT_ATTENTION: Retrying...\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " Retrying...\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (struct scsi_extended_sense *)command->uscsi_rqbuf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Retry 5 times in case of BUSY, and only
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * once for Reservation-conflict, Command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Termination and Queue Full. Wait for
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * random amount of time (between 1/10 - 1/2 secs.)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * between each retry. This random wait is to avoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the multiple threads being executed at the same time
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and also the constraint in Photon IB, where the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * command queue has a depth of one command.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch ((uchar_t)command->uscsi_status & STATUS_MASK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " STATUS_BUSY: Retrying...\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " RESERVATION_CONFLICT:"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " Retrying...\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " Retrying...\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " Retrying...\n");