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 * I18N message number ranges
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This file: 9000 - 9499
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Shared common messages: 1 - 1999
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This module is part of the photon library
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/types.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/stat.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/param.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <fcntl.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <unistd.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <errno.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <string.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <assert.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/scsi/scsi.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <dirent.h> /* for DIR */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/vtoc.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/dkio.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <nl_types.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <strings.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/ddi.h> /* for max */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <l_common.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <stgcom.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <l_error.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <rom.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <exec.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <a_state.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <a5k.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Defines */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define PLNDEF "SUNW,pln" /* check if box name starts with 'c' */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define DOWNLOAD_RETRIES 60*5 /* 5 minutes */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define IBFIRMWARE_FILE "/usr/lib/locale/C/LC_MESSAGES/ibfirmware"
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/* Forward declarations */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int pwr_up_down(char *, L_state *, int, int, int, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int load_flds_if_enc_disk(char *, struct path_struct **);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int copy_config_page(struct l_state_struct *, uchar_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void copy_page_7(struct l_state_struct *, uchar_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int l_get_node_status(char *, struct l_disk_state_struct *,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int *, WWN_list *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int check_file(int, int, uchar_t **, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int check_dpm_file(int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int ib_download_code_cmd(int, int, int, uchar_t *, int, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int dak_download_code_cmd(int, uchar_t *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void free_mp_dev_map(struct gfc_map_mp **);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int get_mp_dev_map(char *, struct gfc_map_mp **, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * l_get_mode_pg() - Read all mode pages.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * RETURNS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 0 O.K.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * non-zero otherwise
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * INPUTS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * path pointer to device path
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * pg_buf ptr to mode pages
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*ARGSUSED*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortel_get_mode_pg(char *path, uchar_t **pg_buf, int verbose)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteMode_header_10 *mode_header_ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint status, size, fd;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte P_DPRINTF(" l_get_mode_pg: Reading Mode Sense pages.\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* do not do mode sense if this is a tape device */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* mode sense will rewind the tape */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strstr(path, SLSH_DRV_NAME_ST)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* open controller */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((fd = g_object_open(path, O_NDELAY | O_RDWR)) == -1)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_OPEN_PATH_FAIL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Read the first part of the page to get the page size
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size = 20;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((*pg_buf = (uchar_t *)g_zalloc(size)) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) close(fd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_MALLOC_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* read page */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status = g_scsi_mode_sense_cmd(fd, *pg_buf, size,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0, MODEPAGE_ALLPAGES)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) close(fd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_destroy_data((char *)*pg_buf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Now get the size for all pages */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mode_header_ptr = (struct mode_header_10_struct *)(void *)*pg_buf;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size = mode_header_ptr->length + sizeof (mode_header_ptr->length);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_destroy_data((char *)*pg_buf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((*pg_buf = (uchar_t *)g_zalloc(size)) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) close(fd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_MALLOC_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* read all pages */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status = g_scsi_mode_sense_cmd(fd, *pg_buf, size,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0, MODEPAGE_ALLPAGES)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) close(fd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_destroy_data((char *)*pg_buf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) close(fd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Format QLA21xx status
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * INPUTS: message buffer
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Count
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * status
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * OUTPUT: Message of this format in message buffer
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * "status type: 0xstatus count"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortel_format_ifp_status_msg(char *status_msg_buf, int count, int status)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status_msg_buf == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (status) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case IFP_CMD_CMPLT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(status_msg_buf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(9000, "O.K. 0x%-2x"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " %d"), status, count);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case IFP_CMD_INCOMPLETE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(status_msg_buf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(9001, "Cmd incomplete 0x%-2x"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " %d"), status, count);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case IFP_CMD_DMA_DERR:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(status_msg_buf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(9002, "DMA direction error 0x%-2x"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " %d"), status, count);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case IFP_CMD_TRAN_ERR:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(status_msg_buf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(9003, "Unspecified transport error 0x%-2x"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " %d"), status, count);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case IFP_CMD_RESET:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(status_msg_buf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(9004, "Reset aborted transport 0x%-2x"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " %d"), status, count);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case IFP_CMD_ABORTED:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(status_msg_buf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(9005, "Cmd aborted 0x%-2x"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " %d"), status, count);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case IFP_CMD_TIMEOUT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(status_msg_buf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(9006, "Cmd Timeout 0x%-2x"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " %d"), status, count);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case IFP_CMD_DATA_OVR:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(status_msg_buf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(9007, "Data Overrun 0x%-2x"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " %d"), status, count);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case IFP_CMD_ABORT_REJECTED:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(status_msg_buf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(9008, "Target rejected abort msg 0x%-2x"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " %d"), status, count);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case IFP_CMD_RESET_REJECTED:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(status_msg_buf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(9009, "Target rejected reset msg 0x%-2x"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " %d"), status, count);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case IFP_CMD_DATA_UNDER:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(status_msg_buf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(9010, "Data underrun 0x%-2x"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " %d"), status, count);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case IFP_CMD_QUEUE_FULL:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(status_msg_buf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(9011, "Queue full SCSI status 0x%-2x"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " %d"), status, count);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case IFP_CMD_PORT_UNAVAIL:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(status_msg_buf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(9012, "Port unavailable 0x%-2x"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " %d"), status, count);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case IFP_CMD_PORT_LOGGED_OUT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(status_msg_buf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(9013, "Port loged out 0x%-2x"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " %d"), status, count);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case IFP_CMD_PORT_CONFIG_CHANGED:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Not enough packets for given request */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(status_msg_buf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(9014, "Port name changed 0x%-2x"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " %d"), status, count);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(status_msg_buf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%s 0x%-2x"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " %d", MSGSTR(4, "Unknown status"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status, count);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } /* End of switch() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Format Fibre Channel status
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * INPUTS: message buffer
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Count
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * status
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * OUTPUT: Message of this format in message buffer
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * "status type: 0xstatus count"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortel_format_fc_status_msg(char *status_msg_buf, int count, int status)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status_msg_buf == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (status) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FCAL_STATUS_OK:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(status_msg_buf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(9015, "O.K. 0x%-2x"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " %d"), status, count);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FCAL_STATUS_P_RJT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(status_msg_buf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(9016, "P_RJT (Frame Rejected) 0x%-2x"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " %d"), status, count);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FCAL_STATUS_F_RJT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(status_msg_buf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(9017, "F_RJT (Frame Rejected) 0x%-2x"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " %d"), status, count);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FCAL_STATUS_P_BSY:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(status_msg_buf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(9018, "P_BSY (Port Busy) 0x%-2x"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " %d"), status, count);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FCAL_STATUS_F_BSY:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(status_msg_buf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(9019, "F_BSY (Port Busy) 0x%-2x"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " %d"), status, count);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FCAL_STATUS_OLDPORT_ONLINE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Should not happen. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(status_msg_buf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(9020, "Old port Online 0x%-2x"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " %d"), status, count);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FCAL_STATUS_ERR_OFFLINE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(status_msg_buf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(9021, "Link Offline 0x%-2x"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " %d"), status, count);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FCAL_STATUS_TIMEOUT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Should not happen. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(status_msg_buf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(9022, "Sequence Timeout 0x%-2x"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " %d"), status, count);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FCAL_STATUS_ERR_OVERRUN:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(status_msg_buf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(9023, "Sequence Payload Overrun 0x%-2x"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " %d"), status, count);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FCAL_STATUS_LOOP_ONLINE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(status_msg_buf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(9060, "Loop Online 0x%-2x"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " %d"), status, count);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FCAL_STATUS_OLD_PORT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(status_msg_buf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(9061, "Old port 0x%-2x"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " %d"), status, count);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FCAL_STATUS_AL_PORT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(status_msg_buf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(9062, "AL port 0x%-2x"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " %d"), status, count);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FCAL_STATUS_UNKNOWN_CQ_TYPE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(status_msg_buf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(9024, "Unknown request type 0x%-2x"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " %d"), status, count);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FCAL_STATUS_BAD_SEG_CNT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(status_msg_buf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(9025, "Bad segment count 0x%-2x"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " %d"), status, count);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FCAL_STATUS_MAX_XCHG_EXCEEDED:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(status_msg_buf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(9026, "Maximum exchanges exceeded 0x%-2x"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " %d"), status, count);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FCAL_STATUS_BAD_XID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(status_msg_buf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(9027, "Bad exchange identifier 0x%-2x"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " %d"), status, count);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FCAL_STATUS_XCHG_BUSY:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(status_msg_buf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(9028, "Duplicate exchange request 0x%-2x"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " %d"), status, count);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FCAL_STATUS_BAD_POOL_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(status_msg_buf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(9029, "Bad memory pool ID 0x%-2x"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " %d"), status, count);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FCAL_STATUS_INSUFFICIENT_CQES:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Not enough packets for given request */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(status_msg_buf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(9030, "Invalid # of segments for req 0x%-2x"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " %d"), status, count);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FCAL_STATUS_ALLOC_FAIL:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(status_msg_buf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(9031, "Resource allocation failure 0x%-2x"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " %d"), status, count);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FCAL_STATUS_BAD_SID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(status_msg_buf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(9032, "Bad Source Identifier(S_ID) 0x%-2x"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " %d"), status, count);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FCAL_STATUS_NO_SEQ_INIT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(status_msg_buf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(9033, "No sequence initiative 0x%-2x"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " %d"), status, count);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FCAL_STATUS_BAD_DID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(status_msg_buf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(9034, "Bad Destination ID(D_ID) 0x%-2x"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " %d"), status, count);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FCAL_STATUS_ABORTED:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(status_msg_buf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(9035, "Received BA_ACC from abort 0x%-2x"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " %d"), status, count);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FCAL_STATUS_ABORT_FAILED:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(status_msg_buf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(9036, "Received BA_RJT from abort 0x%-2x"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " %d"), status, count);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FCAL_STATUS_DIAG_BUSY:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(status_msg_buf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(9037, "Diagnostics currently busy 0x%-2x"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " %d"), status, count);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FCAL_STATUS_DIAG_INVALID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(status_msg_buf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(9038, "Diagnostics illegal request 0x%-2x"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " %d"), status, count);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FCAL_STATUS_INCOMPLETE_DMA_ERR:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(status_msg_buf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(9039, "SBus DMA did not complete 0x%-2x"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " %d"), status, count);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FCAL_STATUS_CRC_ERR:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(status_msg_buf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(9040, "CRC error detected 0x%-2x"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " %d"), status, count);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FCAL_STATUS_OPEN_FAIL:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(status_msg_buf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(9063, "Open failure 0x%-2x"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " %d"), status, count);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FCAL_STATUS_ERROR:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(status_msg_buf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(9041, "Invalid status error 0x%-2x"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " %d"), status, count);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FCAL_STATUS_ONLINE_TIMEOUT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(status_msg_buf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(9042, "Timed out before ONLINE 0x%-2x"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " %d"), status, count);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(status_msg_buf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%s 0x%-2x"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " %d", MSGSTR(4, "Unknown status"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status, count);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } /* End of switch() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get the indexes to the disk device elements in page 2,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * based on the locations found in page 1.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * RETURNS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 0 O.K.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * non-zero otherwise
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortel_get_disk_element_index(struct l_state_struct *l_state, int *front_index,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int *rear_index)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint index = 0, front_flag = 0, local_front = 0, local_rear = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint i, rear_flag = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((l_state == NULL) || (front_index == NULL) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (rear_index == NULL)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_INVALID_PATH_FORMAT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *front_index = *rear_index = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get the indexes to the disk device elements */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < (int)l_state->ib_tbl.config.enc_num_elem; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (l_state->ib_tbl.config.type_hdr[i].type == ELM_TYP_DD) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (front_flag) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte local_rear = index;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rear_flag = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte local_front = index;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte front_flag = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte index += l_state->ib_tbl.config.type_hdr[i].num;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte index++; /* for global element */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte D_DPRINTF(" l_get_disk_element_index:"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " Index to front disk elements 0x%x\n"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " l_get_disk_element_index:"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " Index to rear disk elements 0x%x\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte local_front, local_rear);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!front_flag && !rear_flag) { /* neither is found */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_RD_NO_DISK_ELEM);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *front_index = local_front;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *rear_index = local_rear;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * l_led() manage the device led's
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * RETURNS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 0 O.K.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * non-zero otherwise
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortel_led(struct path_struct *path_struct, int led_action,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct device_element *status,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int verbose)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortegfc_map_t map;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortechar ses_path[MAXPATHLEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteuchar_t *page_buf;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint err, write, fd, front_index, rear_index, offset;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteunsigned short page_len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestruct device_element *elem;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteL_state *l_state;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint enc_type;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((path_struct == NULL) || (status == NULL)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_INVALID_PATH_FORMAT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Need to get a valid location, front/rear & slot.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The path_struct will return a valid slot
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and the IB path or a disk path.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte map.dev_addr = (gfc_port_dev_info_t *)NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!path_struct->ib_path_flag) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((err = g_get_dev_map(path_struct->p_physical_path,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &map, verbose)) != 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (err);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((err = l_get_ses_path(path_struct->p_physical_path,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ses_path, &map, verbose)) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free((void *)map.dev_addr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (err);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcpy(ses_path, path_struct->p_physical_path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((l_state = (L_state *)calloc(1, sizeof (L_state))) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free((void *)map.dev_addr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_MALLOC_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!path_struct->slot_valid) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((map.dev_addr != NULL) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (err = g_get_dev_map(path_struct->p_physical_path,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &map, verbose)) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) l_free_lstate(&l_state);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (err);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((err = l_get_ses_path(path_struct->p_physical_path,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ses_path, &map, verbose)) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) l_free_lstate(&l_state);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free((void *)map.dev_addr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (err);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((err = l_get_status(ses_path, l_state, verbose)) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) l_free_lstate(&l_state);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free((void *)map.dev_addr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (err);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* We are passing the disks path */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err = l_get_slot(path_struct, l_state, verbose)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) l_free_lstate(&l_state);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free((void *)map.dev_addr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (err);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (map.dev_addr != NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free((void *)map.dev_addr); /* Not used anymore */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((page_buf = (uchar_t *)calloc(1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MAX_REC_DIAG_LENGTH)) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) l_free_lstate(&l_state);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_MALLOC_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((fd = g_object_open(ses_path, O_NDELAY | O_RDWR)) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) l_free_lstate(&l_state);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_destroy_data(page_buf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_OPEN_PATH_FAIL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err = l_get_envsen_page(fd, page_buf, MAX_REC_DIAG_LENGTH,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte L_PAGE_2, verbose)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) l_free_lstate(&l_state);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) close(fd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_destroy_data(page_buf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (err);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte page_len = (page_buf[2] << 8 | page_buf[3]) + HEADER_LEN;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get index to the disk we are interested in */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err = l_get_status(ses_path, l_state, verbose)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) l_free_lstate(&l_state);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) close(fd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_destroy_data(page_buf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (err);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* find enclosure type */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((strncmp((char *)l_state->ib_tbl.config.prod_id, DAK_OFF_NAME,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strlen(DAK_OFF_NAME)) == 0) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (strncmp((char *)l_state->ib_tbl.config.prod_id, DAK_PROD_STR,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strlen(DAK_PROD_STR)) == 0)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte enc_type = DAK_ENC_TYPE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte enc_type = SENA_ENC_TYPE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Double check slot. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (path_struct->slot >= l_state->total_num_drv/2) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) l_free_lstate(&l_state);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_INVALID_SLOT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err = l_get_disk_element_index(l_state, &front_index,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &rear_index)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) l_free_lstate(&l_state);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (err);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Skip global element */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte front_index++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (enc_type == DAK_ENC_TYPE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rear_index += l_state->total_num_drv/2 + 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rear_index++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (path_struct->f_flag) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte offset = (8 + (front_index + path_struct->slot)*4);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte offset = (8 + (rear_index + path_struct->slot)*4);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte elem = (struct device_element *)(page_buf + offset);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * now do requested action.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy((const void *)elem, (void *)status,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (struct device_element)); /* save status */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(elem, sizeof (struct device_element));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte elem->select = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte elem->dev_off = status->dev_off;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte elem->en_bypass_a = status->en_bypass_a;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte elem->en_bypass_b = status->en_bypass_b;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte write = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (led_action) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case L_LED_STATUS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte write = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case L_LED_RQST_IDENTIFY:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte elem->ident = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (verbose) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (enc_type == DAK_ENC_TYPE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(9043, " Blinking LED for slot %d in enclosure"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " %s\n"), path_struct->f_flag ? path_struct->slot :
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte path_struct->slot + (MAX_DRIVES_DAK/2),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte l_state->ib_tbl.enclosure_name);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(9043, " Blinking LED for slot %d in enclosure"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " %s\n"), path_struct->slot,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte l_state->ib_tbl.enclosure_name);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case L_LED_OFF:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (verbose) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (enc_type == DAK_ENC_TYPE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(9044,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " Turning off LED for slot %d in enclosure"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " %s\n"), path_struct->f_flag ? path_struct->slot
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte : path_struct->slot + (MAX_DRIVES_DAK/2),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte l_state->ib_tbl.enclosure_name);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(9044,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " Turning off LED for slot %d in enclosure"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " %s\n"), path_struct->slot,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte l_state->ib_tbl.enclosure_name);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) l_free_lstate(&l_state);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_INVALID_LED_RQST);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } /* End of switch */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (write) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (getenv("_LUX_D_DEBUG") != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte g_dump(" l_led: Updating led state: "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Device Status Element ",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uchar_t *)elem, sizeof (struct device_element),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HEX_ONLY);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err = g_scsi_send_diag_cmd(fd,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uchar_t *)page_buf, page_len)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) close(fd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_destroy_data(page_buf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) l_free_lstate(&l_state);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (err);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(page_buf, MAX_REC_DIAG_LENGTH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err = l_get_envsen_page(fd, page_buf, MAX_REC_DIAG_LENGTH,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte L_PAGE_2, verbose)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_destroy_data(page_buf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) close(fd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) l_free_lstate(&l_state);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (err);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte elem = (struct device_element *)(page_buf + offset);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy((const void *)elem, (void *)status,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (struct device_element));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (getenv("_LUX_D_DEBUG") != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte g_dump(" l_led: Device Status Element ",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uchar_t *)status, sizeof (struct device_element),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HEX_ONLY);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) l_free_lstate(&l_state);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) close(fd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_destroy_data(page_buf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * frees the previously alloced l_state
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * structure.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * RETURNS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 0 O.K.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * non-zero otherwise
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortel_free_lstate(L_state **l_state)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((l_state == NULL) || (*l_state == NULL))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < (int)(*l_state)->total_num_drv/2; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((*l_state)->drv_front[i].g_disk_state.multipath_list != NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_free_multipath(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (*l_state)->drv_front[i].g_disk_state.multipath_list);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((*l_state)->drv_rear[i].g_disk_state.multipath_list != NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_free_multipath(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (*l_state)->drv_rear[i].g_disk_state.multipath_list);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_destroy_data (*l_state);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte l_state = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Set the state of an individual disk
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * in the Photon enclosure the powered
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * up/down mode. The path must point to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * a disk or the ib_path_flag must be set.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * RETURNS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 0 O.K.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * non-zero otherwise
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortel_dev_pwr_up_down(char *path_phys, struct path_struct *path_struct,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int power_off_flag, int verbose, int force_flag)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*ARGSUSED*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortegfc_map_t map;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortechar ses_path[MAXPATHLEN], dev_path[MAXPATHLEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint slot, err = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteL_state *l_state = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestruct l_disk_state_struct *drive;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestruct dlist *dl, *dl1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortedevctl_hdl_t devhdl;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteWWN_list *wwn_list = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteL_inquiry inq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (path_struct == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_INVALID_PATH_FORMAT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dl = (struct dlist *)NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte map.dev_addr = (gfc_port_dev_info_t *)NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err = g_get_dev_map(path_struct->p_physical_path,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &map, verbose))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (err);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err = l_get_ses_path(path_struct->p_physical_path,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ses_path, &map, verbose)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free((void *)map.dev_addr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (err);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free((void *)map.dev_addr); /* Not used anymore */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check to see if we have a photon, and if not, don't allow
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * this operation
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err = g_get_inquiry(ses_path, &inq)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (err);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (l_get_enc_type(inq) != SENA_ENC_TYPE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_ENCL_INVALID_PATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * OK, so we have a photon... we can continue
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((l_state = (L_state *)calloc(1, sizeof (L_state))) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_MALLOC_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err = l_get_status(ses_path, l_state, verbose)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) l_free_lstate(&l_state);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (err);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!path_struct->slot_valid) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* We are passing the disks path */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err = l_get_slot(path_struct, l_state, verbose)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) l_free_lstate(&l_state);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (err);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte slot = path_struct->slot;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcpy(dev_path, path_struct->p_physical_path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Either front or rear drive
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (path_struct->f_flag) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte drive = &l_state->drv_front[slot];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte drive = &l_state->drv_rear[slot];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check for drive presence always
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (drive->ib_status.code == S_NOT_INSTALLED) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) l_free_lstate(&l_state);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_SLOT_EMPTY);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check disk state
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * before the power off.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (power_off_flag && !force_flag) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto pre_pwr_dwn;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto pwr_up_dwn;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortepre_pwr_dwn:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check whether disk
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * is reserved by another
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * host
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((drive->g_disk_state.d_state_flags[PORT_A] & L_RESERVED) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (drive->g_disk_state.d_state_flags[PORT_B] &
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte L_RESERVED)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) l_free_lstate(&l_state);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_DEVICE_RESERVED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((dl = (struct dlist *)g_zalloc(sizeof (struct dlist))) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) l_free_lstate(&l_state);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_MALLOC_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * NOTE: It is not necessary to get the multipath list here as ------
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * we alread have it after getting the status earlier.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * - REWRITE -
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get path to all the FC disk and tape devices.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * I get this now and pass down for performance
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * reasons.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If for some reason the list can become invalid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * i.e. device being offlined, then the list
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * must be re-gotten.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err = g_get_wwn_list(&wwn_list, verbose)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_destroy_data(dl);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) l_free_lstate(&l_state);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (err); /* Failure */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dl->dev_path = dev_path;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((err = g_get_multipath(dev_path,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &(dl->multipath), wwn_list, verbose)) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_destroy_data(dl);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_free_wwn_list(&wwn_list);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) l_free_lstate(&l_state);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (err);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (dl1 = dl->multipath; dl1 != NULL; dl1 = dl1->next) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((devhdl = devctl_device_acquire(dl1->dev_path,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DC_EXCL)) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (errno != EBUSY) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ER_DPRINTF("%s could not acquire"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " the device: %s\n\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strerror(errno), dl1->dev_path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (devctl_device_offline(devhdl) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) devctl_release(devhdl);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_free_multipath(dl->multipath);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_destroy_data(dl);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_free_wwn_list(&wwn_list);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) l_free_lstate(&l_state);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_POWER_OFF_FAIL_BUSY);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) devctl_release(devhdl);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortepwr_up_dwn:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte err = pwr_up_down(ses_path, l_state, path_struct->f_flag,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte path_struct->slot, power_off_flag, verbose);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (dl != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_free_multipath(dl->multipath);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_destroy_data(dl);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_free_wwn_list(&wwn_list);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) l_free_lstate(&l_state);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (err);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * l_pho_pwr_up_down() Set the state of the Photon enclosure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the powered up/down mode.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The path must point to an IB.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * RETURNS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 0 O.K.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * non-zero otherwise
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortel_pho_pwr_up_down(char *dev_name, char *path_phys, int power_off_flag,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int verbose, int force_flag)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteL_state *l_state = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint i, err = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestruct dlist *dl, *dl1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortechar dev_path[MAXPATHLEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortedevctl_hdl_t devhdl;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteWWN_list *wwn_list = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (path_phys == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_INVALID_PATH_FORMAT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dl = (struct dlist *)NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((l_state = (L_state *)calloc(1, sizeof (L_state))) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_MALLOC_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err = l_get_status(path_phys, l_state, verbose)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) l_free_lstate(&l_state);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (err);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (power_off_flag && !force_flag) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto pre_pwr_dwn;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto pwr_up_dwn;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortepre_pwr_dwn:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check if any disk in this enclosure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * is reserved by another host before
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the power off.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < l_state->total_num_drv/2; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((l_state->drv_front[i].g_disk_state.d_state_flags[PORT_A] &
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte L_RESERVED) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (l_state->drv_front[i].g_disk_state.d_state_flags[PORT_B] &
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte L_RESERVED) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (l_state->drv_rear[i].g_disk_state.d_state_flags[PORT_A] &
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte L_RESERVED) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (l_state->drv_rear[i].g_disk_state.d_state_flags[PORT_B] &
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte L_RESERVED)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_DISKS_RESERVED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check if any disk in this enclosure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get path to all the FC disk and tape devices.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * I get this now and pass down for performance
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * reasons.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If for some reason the list can become invalid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * i.e. device being offlined, then the list
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * must be re-gotten.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err = g_get_wwn_list(&wwn_list, verbose)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) l_free_lstate(&l_state);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (err); /* Failure */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < l_state->total_num_drv/2; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*l_state->drv_front[i].g_disk_state.physical_path) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memset(dev_path, 0, MAXPATHLEN);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcpy(dev_path,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (char *)&l_state->drv_front[i].g_disk_state.physical_path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((dl = (struct dlist *)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte g_zalloc(sizeof (struct dlist))) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_free_wwn_list(&wwn_list);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) l_free_lstate(&l_state);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_MALLOC_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dl->dev_path = dev_path;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (g_get_multipath(dev_path, &(dl->multipath),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wwn_list, verbose) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_destroy_data(dl);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (dl1 = dl->multipath;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dl1 != NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dl1 = dl1->next) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* attempt to acquire the device */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((devhdl = devctl_device_acquire(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dl1->dev_path, DC_EXCL)) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (errno != EBUSY) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ER_DPRINTF("%s: Could not "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "acquire the device: %s\n\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strerror(errno),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dl1->dev_path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* attempt to offline the device */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (devctl_device_offline(devhdl) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) devctl_release(devhdl);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_free_multipath(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dl->multipath);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_destroy_data(dl);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_free_wwn_list(&wwn_list);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) l_free_lstate(&l_state);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_POWER_OFF_FAIL_BUSY);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* release handle acquired above */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) devctl_release(devhdl);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_free_multipath(dl->multipath);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_destroy_data(dl);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*l_state->drv_rear[i].g_disk_state.physical_path) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memset(dev_path, 0, MAXPATHLEN);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcpy(dev_path,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (char *)&l_state->drv_rear[i].g_disk_state.physical_path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((dl = (struct dlist *)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte g_zalloc(sizeof (struct dlist))) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_free_wwn_list(&wwn_list);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) l_free_lstate(&l_state);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_MALLOC_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dl->dev_path = dev_path;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (g_get_multipath(dev_path, &(dl->multipath),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wwn_list, verbose) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_destroy_data(dl);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (dl1 = dl->multipath;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dl1 != NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dl1 = dl1->next) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* attempt to acquire the device */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((devhdl = devctl_device_acquire(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dl1->dev_path, DC_EXCL)) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (errno != EBUSY) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ER_DPRINTF("%s: Could not "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "acquire the device: %s\n\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strerror(errno),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dl1->dev_path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* attempt to offline the device */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (devctl_device_offline(devhdl) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) devctl_release(devhdl);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_free_multipath(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dl->multipath);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_destroy_data(dl);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_free_wwn_list(&wwn_list);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) l_free_lstate(&l_state);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_POWER_OFF_FAIL_BUSY);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* release handle acquired above */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) devctl_release(devhdl);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_free_multipath(dl->multipath);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_destroy_data(dl);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortepwr_up_dwn:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_free_wwn_list(&wwn_list);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((err = pwr_up_down(path_phys, l_state, 0, -1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte power_off_flag, verbose)) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) l_free_lstate(&l_state);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (err);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) l_free_lstate(&l_state);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Set the state of the Photon enclosure or disk
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * powered up/down mode.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The path must point to an IB.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * slot == -1 implies entire enclosure.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * RETURNS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 0 O.K.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * non-zero otherwise
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortepwr_up_down(char *path_phys, L_state *l_state, int front, int slot,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int power_off_flag, int verbose)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteL_inquiry inq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint fd, status, err;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteuchar_t *page_buf;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint front_index, rear_index, front_offset, rear_offset;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteunsigned short page_len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestruct device_element *front_elem, *rear_elem;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memset(&inq, 0, sizeof (inq));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((fd = g_object_open(path_phys, O_NDELAY | O_RDONLY)) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_OPEN_PATH_FAIL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Verify it is a Photon */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status = g_scsi_inquiry_cmd(fd,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uchar_t *)&inq, sizeof (struct l_inquiry_struct))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) close(fd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((strstr((char *)inq.inq_pid, ENCLOSURE_PROD_ID) == 0) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (!(strncmp((char *)inq.inq_vid, "SUN ",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (inq.inq_vid)) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((inq.inq_dtype & DTYPE_MASK) == DTYPE_ESI)))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) close(fd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_ENCL_INVALID_PATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * To power up/down a Photon we use the Driver Off
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * bit in the global device control element.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((page_buf = (uchar_t *)malloc(MAX_REC_DIAG_LENGTH)) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_MALLOC_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err = l_get_envsen_page(fd, page_buf, MAX_REC_DIAG_LENGTH,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte L_PAGE_2, verbose)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) close(fd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_destroy_data(page_buf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (err);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte page_len = (page_buf[2] << 8 | page_buf[3]) + HEADER_LEN;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Double check slot as convert_name only does gross check */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (slot >= l_state->total_num_drv/2) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) close(fd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_destroy_data(page_buf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_INVALID_SLOT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err = l_get_disk_element_index(l_state, &front_index,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &rear_index)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) close(fd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_destroy_data(page_buf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (err);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Skip global element */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte front_index++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rear_index++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte front_offset = (8 + (front_index + slot)*4);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rear_offset = (8 + (rear_index + slot)*4);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte front_elem = (struct device_element *)(page_buf + front_offset);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rear_elem = (struct device_element *)(page_buf + rear_offset);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (front || slot == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * now do requested action.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(front_elem, sizeof (struct device_element));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set/reset power off bit */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte front_elem->dev_off = power_off_flag;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte front_elem->select = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!front || slot == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Now do rear */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(rear_elem, sizeof (struct device_element));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set/reset power off bit */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rear_elem->dev_off = power_off_flag;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rear_elem->select = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (getenv("_LUX_D_DEBUG") != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (front || slot == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte g_dump(" pwr_up_down: "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Front Device Status Element ",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uchar_t *)front_elem,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (struct device_element),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HEX_ONLY);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!front || slot == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte g_dump(" pwr_up_down: "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Rear Device Status Element ",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uchar_t *)rear_elem,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (struct device_element),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HEX_ONLY);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err = g_scsi_send_diag_cmd(fd,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uchar_t *)page_buf, page_len)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) close(fd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_destroy_data(page_buf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (err);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) close(fd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_destroy_data(page_buf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Set the password of the FPM by sending the password
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * in page 4 of the Send Diagnostic command.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The path must point to an IB.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The size of the password string must be <= 8 bytes.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The string can also be NULL. This is the way the user
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * chooses to not have a password.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * I then tell the photon by giving him 4 NULL bytes.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * RETURNS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 0 O.K.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * non-zero otherwise
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortel_new_password(char *path_phys, char *password)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortePage4_name page4;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteL_inquiry inq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint fd, status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memset(&inq, 0, sizeof (inq));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memset(&page4, 0, sizeof (page4));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((fd = g_object_open(path_phys, O_NDELAY | O_RDONLY)) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_OPEN_PATH_FAIL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Verify it is a Photon */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status = g_scsi_inquiry_cmd(fd,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uchar_t *)&inq, sizeof (struct l_inquiry_struct))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) close(fd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((strstr((char *)inq.inq_pid, ENCLOSURE_PROD_ID) == 0) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (!(strncmp((char *)inq.inq_vid, "SUN ",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (inq.inq_vid)) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((inq.inq_dtype & DTYPE_MASK) == DTYPE_ESI)))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) close(fd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_ENCL_INVALID_PATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte page4.page_code = L_PAGE_4;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte page4.page_len = (ushort_t)max((strlen(password) + 4), 8);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Double check */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strlen(password) > 8) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_INVALID_PASSWORD_LEN);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte page4.string_code = L_PASSWORD;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte page4.enable = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcpy((char *)page4.name, password);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status = g_scsi_send_diag_cmd(fd, (uchar_t *)&page4,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte page4.page_len + HEADER_LEN)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) close(fd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) close(fd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Set the name of the enclosure by sending the name
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * in page 4 of the Send Diagnostic command.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The path must point to an IB.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * RETURNS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 0 O.K.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * non-zero otherwise
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortel_new_name(char *path_phys, char *name)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortePage4_name page4;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteL_inquiry inq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint fd, status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((path_phys == NULL) || (name == NULL)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_INVALID_PATH_FORMAT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memset(&inq, 0, sizeof (inq));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memset(&page4, 0, sizeof (page4));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((fd = g_object_open(path_phys, O_NDELAY | O_RDONLY)) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_OPEN_PATH_FAIL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Verify it is a Photon */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status = g_scsi_inquiry_cmd(fd,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uchar_t *)&inq, sizeof (struct l_inquiry_struct))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) close(fd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((strstr((char *)inq.inq_pid, ENCLOSURE_PROD_ID) == 0) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (!(strncmp((char *)inq.inq_vid, "SUN ",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (inq.inq_vid)) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((inq.inq_dtype & DTYPE_MASK) == DTYPE_ESI)))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) close(fd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_ENCL_INVALID_PATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte page4.page_code = L_PAGE_4;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte page4.page_len = (ushort_t)((sizeof (struct page4_name) - 4));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte page4.string_code = L_ENCL_NAME;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte page4.enable = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy((char *)page4.name, name, sizeof (page4.name));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status = g_scsi_send_diag_cmd(fd, (uchar_t *)&page4,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (page4))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) close(fd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check the name really changed.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status = g_scsi_inquiry_cmd(fd,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uchar_t *)&inq, sizeof (struct l_inquiry_struct))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) close(fd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strncmp((char *)inq.inq_box_name, name, sizeof (page4.name)) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char name_buf[MAXNAMELEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) close(fd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy((char *)name_buf, (char *)inq.inq_box_name,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (inq.inq_box_name));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_ENCL_NAME_CHANGE_FAIL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) close(fd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Issue a Loop Port enable Primitive sequence
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * to the device specified by the pathname.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortel_enable(char *path, int verbose)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*ARGSUSED*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Issue a Loop Port Bypass Primitive sequence
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * to the device specified by the pathname. This requests the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * device to set its L_Port into the bypass mode.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortel_bypass(char *path, int verbose)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*ARGSUSED*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Create a linked list of all the Photon enclosures that
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * are attached to this host.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * RETURN VALUES: 0 O.K.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * box_list pointer:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * NULL: No enclosures found.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * !NULL: Enclosures found
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * box_list points to a linked list of boxes.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortel_get_box_list(struct box_list_struct **box_list_ptr, int verbose)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortechar *dev_name;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteDIR *dirp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestruct dirent *entp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortechar namebuf[MAXPATHLEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestruct stat sb;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortechar *result = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint fd, status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteL_inquiry inq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteBox_list *box_list, *l1, *l2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteIB_page_config page1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteuchar_t node_wwn[WWN_SIZE], port_wwn[WWN_SIZE];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint al_pa;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (box_list_ptr == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_INVALID_PATH_FORMAT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte box_list = *box_list_ptr = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((dev_name = (char *)g_zalloc(sizeof ("/dev/es"))) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_MALLOC_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf((char *)dev_name, "/dev/es");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (verbose) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(9045,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " Searching directory %s for links to enclosures\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dev_name);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((dirp = opendir(dev_name)) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_destroy_data(dev_name);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* No Photons found */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte B_DPRINTF(" l_get_box_list: No Photons found\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while ((entp = readdir(dirp)) != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp(entp->d_name, ".") == 0 ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strcmp(entp->d_name, "..") == 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(namebuf, "%s/%s", dev_name, entp->d_name);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((lstat(namebuf, &sb)) < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ER_DPRINTF("Warning: Cannot stat %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte namebuf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!S_ISLNK(sb.st_mode)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ER_DPRINTF("Warning: %s is not a symbolic link\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte namebuf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((result = g_get_physical_name_from_link(namebuf)) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ER_DPRINTF(" Warning: Get physical name from"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " link failed. Link=%s\n", namebuf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Found a SES card. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte B_DPRINTF(" l_get_box_list: Link to SES Card found: %s/%s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dev_name, entp->d_name);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((fd = g_object_open(result, O_NDELAY | O_RDONLY)) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte g_destroy_data(result);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue; /* Ignore errors */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get the box name */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status = g_scsi_inquiry_cmd(fd,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uchar_t *)&inq, sizeof (struct l_inquiry_struct))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) close(fd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte g_destroy_data(result);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue; /* Ignore errors */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((strstr((char *)inq.inq_pid, ENCLOSURE_PROD_ID) != NULL) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (((inq.inq_dtype & DTYPE_MASK) == DTYPE_ESI) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (l_get_enc_type(inq) == DAK_ENC_TYPE))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Found Photon/Daktari
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get the port WWN from the IB, page 1 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((status = l_get_envsen_page(fd, (uchar_t *)&page1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (page1), 1, 0)) != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) close(fd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte g_destroy_data(result);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_destroy_data(dev_name);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte closedir(dirp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Build list of names.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((l2 = (struct box_list_struct *)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte g_zalloc(sizeof (struct box_list_struct)))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) close(fd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte g_destroy_data(result);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte g_destroy_data(dev_name);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte closedir(dirp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_MALLOC_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Fill in structure */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcpy((char *)l2->b_physical_path,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (char *)result);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcpy((char *)l2->logical_path,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (char *)namebuf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy((void *)page1.enc_node_wwn,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void *)l2->b_node_wwn, WWN_SIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(l2->b_node_wwn_s,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte page1.enc_node_wwn[0],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte page1.enc_node_wwn[1],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte page1.enc_node_wwn[2],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte page1.enc_node_wwn[3],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte page1.enc_node_wwn[4],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte page1.enc_node_wwn[5],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte page1.enc_node_wwn[6],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte page1.enc_node_wwn[7]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy((char *)l2->prod_id_s,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (char *)inq.inq_pid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (inq.inq_pid));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy((char *)l2->b_name,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (char *)inq.inq_box_name,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (inq.inq_box_name));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* make sure null terminated */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte l2->b_name[sizeof (l2->b_name) - 1] = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Now get the port WWN for the port
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * we are connected to.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = g_get_wwn(result, port_wwn, node_wwn,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &al_pa, verbose);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(l2->b_port_wwn_s,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port_wwn[0], port_wwn[1], port_wwn[2],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port_wwn[3], port_wwn[4], port_wwn[5],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port_wwn[6], port_wwn[7]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy((void *)port_wwn,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void *)l2->b_port_wwn, WWN_SIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte B_DPRINTF(" l_get_box_list:"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " Found enclosure named:%s\n", l2->b_name);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (box_list == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte l1 = box_list = l2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte l2->box_prev = l1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte l1 = l1->box_next = l2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) close(fd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte g_destroy_data(result);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_destroy_data(dev_name);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_destroy_data(l2);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte closedir(dirp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte g_destroy_data(result);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) close(fd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *box_list_ptr = box_list; /* pass back ptr to list */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_destroy_data(dev_name);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte closedir(dirp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortel_free_box_list(struct box_list_struct **box_list)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteBox_list *next = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (box_list == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (; *box_list != NULL; *box_list = next) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte next = (*box_list)->box_next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_destroy_data(*box_list);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *box_list = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Finds out if there are any other boxes
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * with the same name as "name".
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * RETURNS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 0 There are no other boxes with the same name.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * >0 if duplicate names found
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*ARGSUSED*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortel_duplicate_names(Box_list *b_list, char wwn[], char *name, int verbose)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint dup_flag = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteBox_list *box_list_ptr = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((name == NULL) || (wwn == NULL))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte box_list_ptr = b_list;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (box_list_ptr != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((strcmp(name, (const char *)box_list_ptr->b_name) == 0) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (strcmp(box_list_ptr->b_node_wwn_s, wwn) != 0)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dup_flag++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte box_list_ptr = box_list_ptr->box_next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (dup_flag);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Checks for a name conflict with an SSA cN type name.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortel_get_conflict(char *name, char **result, int verbose)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortechar s[MAXPATHLEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortechar *p = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortechar *pp = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteBox_list *box_list = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint found_box = 0, err = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcpy(s, name);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((*result = g_get_physical_name(s)) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((strstr((const char *)*result, PLNDEF)) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_destroy_data(*result);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *result = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte P_DPRINTF(" l_get_conflict: Found "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "SSA path using %s\n", s);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Find path to IB */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((err = l_get_box_list(&box_list, verbose)) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (err); /* Failure */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Valid cN type name found.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (box_list != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((strcmp((char *)s,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (char *)box_list->b_name)) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte found_box = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (p == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((p = g_zalloc(strlen(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte box_list->b_physical_path)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte + 2)) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) l_free_box_list(&box_list);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (errno);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((pp = g_zalloc(strlen(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte box_list->b_physical_path)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte + strlen(p)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte + 2)) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) l_free_box_list(&box_list);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (errno);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcpy(pp, p);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_destroy_data(p);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte p = pp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcat(p, box_list->b_physical_path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcat(p, "\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte box_list = box_list->box_next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (found_box) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte D_DPRINTF("There is a conflict between the "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "enclosure\nwith this name, %s, "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "and a SSA name of the same form.\n"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Please use one of the following physical "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "pathnames:\n%s\n%s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte s, *result, p);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) l_free_box_list(&box_list);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_destroy_data(p);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_SSA_CONFLICT); /* failure */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) l_free_box_list(&box_list);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This function sets the "slot", "slot_valid" and "f_flag" fields of the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * path_struct that is passed in IFF the device path passed in ("phys_path")
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * is a disk in an A5K or a Daktari. This is achieved by calling l_get_slot().
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * INPUT :
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * phys_path - physical path to a device
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * path_sturct - Pointer to pointer to a path_struct data structure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * OUTPUT :
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * if phys_path is that of an A5K/Daktari disk
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * path_struct->slot is set to the slot position in enclosure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * path_struct->slot_valid is set to 1
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * path_struct->f_flag is set to 1 if in the front of an A5k
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * or if among the first 6 disks on a Daktari
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * they are left as they were
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * RETURNS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 0 on SUCCESS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * non-zero otherwise
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteload_flds_if_enc_disk(char *phys_path, struct path_struct **path_struct)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int err = 0, verbose = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char ses_path[MAXPATHLEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gfc_map_t map;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte L_inquiry inq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte L_state *l_state = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((path_struct == NULL) || (*path_struct == NULL) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (phys_path == NULL) || (*phys_path == NULL)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_INVALID_PATH_FORMAT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((strstr(phys_path, SLSH_DRV_NAME_SSD) == NULL) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (g_get_path_type(phys_path) == 0)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Don't proceed when not a disk device or if it is not a
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * valid FC device on which g_get_dev_map() can be done
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * (for example, g_get_dev_map() will fail on SSAs).
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Just return success
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((*path_struct)->ib_path_flag) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If this flag is set, l_get_slot() should not be called
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * So, no point in proceeding. Just return success.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((err = g_get_dev_map(phys_path, &map, verbose)) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (err);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((err = l_get_ses_path(phys_path, ses_path, &map, verbose)) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) free(map.dev_addr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err == L_NO_SES_PATH) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This is not an error since this could be a device
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * which does not have SES nodes
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (err);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * There is a SES path on the same FCA as the given disk. But if the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * SES node is not of a photon/Daktari, we dont proceed
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((err = g_get_inquiry(ses_path, &inq)) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) free(map.dev_addr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (err);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * only want to continue if this is a photon or a Daktari
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * if product ID is not SENA or VID is not "SUN" (checks for photon)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and if enclosure type is not a Daktari, then I return
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (((strstr((char *)inq.inq_pid, ENCLOSURE_PROD_ID) == 0) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (strncmp((char *)inq.inq_vid, "SUN ",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (inq.inq_vid)) != 0)) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((l_get_enc_type(inq) != DAK_ENC_TYPE))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Not a photon/Daktari */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) free(map.dev_addr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Now, set some fields that l_get_slot() uses and then call it */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((l_state = (L_state *)g_zalloc(sizeof (L_state))) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) free(map.dev_addr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_MALLOC_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((err = l_get_ib_status(ses_path, l_state, verbose)) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) free(map.dev_addr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) l_free_lstate(&l_state);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (err);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((err = l_get_slot(*path_struct, l_state, verbose)) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) free(map.dev_addr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) l_free_lstate(&l_state);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (err);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) free(map.dev_addr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) l_free_lstate(&l_state);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * convert box name or WWN or logical path to physical path.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * OUTPUT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * path_struct:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * - This structure is used to return more detailed
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * information about the path.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * - *p_physical_path
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Normally this is the requested physical path.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If the requested path is not found then iff the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ib_path_flag is set this is the IB path.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * - *argv
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This is the argument variable input. e.g. Bob,f1
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * - slot_valid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * - slot
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This is the slot number that was entered when using
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the box,[fr]slot format. It is only valid if the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * slot_valid flag is set.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * - f_flag
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Front flag - If set, the requested device is located in the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * front of the enclosure.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * - ib_path_flag
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If this flag is set it means a devices path was requested
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * but could not be found but an IB's path was found and
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the p_physical_path points to that path.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * - **phys_path
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * physical path to the device.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * RETURNS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * - 0 if O.K.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * - error otherwise.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortel_convert_name(char *name, char **phys_path,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct path_struct **path_struct, int verbose)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortechar tmp_name[MAXPATHLEN], ses_path[MAXPATHLEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortechar *char_ptr, *ptr = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortechar *result = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortechar *env = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortechar save_frd; /* which designator was it? */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint slot = 0, slot_flag = 0, found_box = 0, found_comma = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint err = 0, enc_type = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortehrtime_t start_time, end_time;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteBox_list *box_list = NULL, *box_list_ptr = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteL_inquiry inq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteL_state *l_state = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortePath_struct *path_ptr = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteWWN_list *wwn_list, *wwn_list_ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((name == NULL) || (phys_path == NULL) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (path_struct == NULL)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_INVALID_PATH_FORMAT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((env = getenv("_LUX_T_DEBUG")) != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte start_time = gethrtime();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((*path_struct = path_ptr = (struct path_struct *)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte g_zalloc(sizeof (struct path_struct))) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_MALLOC_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *phys_path = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If the path contains a "/" then assume
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * it is a logical or physical path as the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * box name or wwn can not contain "/"s.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strchr(name, '/') != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((result = g_get_physical_name(name)) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_NO_PHYS_PATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte path_ptr->p_physical_path = result;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Make sure it's a disk or tape path
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strstr(name, DEV_RDIR) || strstr(name, SLSH_DRV_NAME_SSD) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strstr(name, DEV_TAPE_DIR) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strstr(name, SLSH_DRV_NAME_ST)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((err = g_get_inquiry(result, &inq)) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) free(result);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_SCSI_ERROR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check to see if it is not a
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * A5K/v880/v890 disk
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!g_enclDiskChk((char *)inq.inq_vid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (char *)inq.inq_pid)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte path_ptr->argv = name;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *phys_path = result;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err = load_flds_if_enc_disk(result, path_struct)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) free(result);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (err);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto done;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcpy(tmp_name, name);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((tmp_name[0] == 'c') &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((int)strlen(tmp_name) > 1) && ((int)strlen(tmp_name) < 5)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((err = l_get_conflict(tmp_name, &result, verbose)) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (result != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_destroy_data(result);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (err);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (result != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte path_ptr->p_physical_path = result;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((err = g_get_inquiry(result, &inq)) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) free(result);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_SCSI_ERROR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check to see if it is a supported
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * A5K/v880/v890 storage subsystem disk
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (g_enclDiskChk((char *)inq.inq_vid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (char *)inq.inq_pid)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err = load_flds_if_enc_disk(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte result, path_struct)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) free(result);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (err);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto done;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check to see if we have a box or WWN name.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If it contains a , then the format must be
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * box_name,f1 where f is front and 1 is the slot number
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * or it is a format like
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ssd@w2200002037049adf,0:h,raw
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * or
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * SUNW,pln@a0000000,77791d:ctlr
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (((char_ptr = strstr(tmp_name, ",")) != NULL) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((*(char_ptr + 1) == 'f') || (*(char_ptr + 1) == 'r') ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (*(char_ptr + 1) == 's'))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char_ptr++; /* point to f/r */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((*char_ptr == 'f') || (*char_ptr == 's')) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte path_ptr->f_flag = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (*char_ptr != 'r') {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_INVALID_PATH_FORMAT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte save_frd = (char)*char_ptr; /* save it */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char_ptr++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte slot = strtol(char_ptr, &ptr, 10);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * NOTE: Need to double check the slot when we get
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the number of the devices actually in the box.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((slot < 0) || (ptr == char_ptr) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((save_frd == 's' && slot >= MAX_DRIVES_DAK) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((save_frd != 's' && slot >= (MAX_DRIVES_PER_BOX/2))))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_INVALID_SLOT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Say slot valid. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte slot_flag = path_ptr->slot_valid = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (save_frd == 's' && slot >= (MAX_DRIVES_DAK/2)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte path_ptr->slot = slot = slot % (MAX_DRIVES_DAK/2);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte path_ptr->f_flag = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte path_ptr->slot = slot;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (((char_ptr = strstr(tmp_name, ",")) != NULL) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((*(char_ptr + 1) == 'f') || (*(char_ptr + 1) == 'r') ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (*(char_ptr + 1) == 's'))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *char_ptr = NULL; /* make just box name */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte found_comma = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Find path to IB */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((err = l_get_box_list(&box_list, verbose)) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) l_free_box_list(&box_list);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (err);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte box_list_ptr = box_list;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Look for box name. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (box_list != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((strcmp((char *)tmp_name, (char *)box_list->b_name)) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte result =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte g_alloc_string(box_list->b_physical_path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte L_DPRINTF(" l_convert_name:"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " Found subsystem: name %s WWN %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte box_list->b_name, box_list->b_node_wwn_s);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check for another box with this name.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (l_duplicate_names(box_list_ptr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte box_list->b_node_wwn_s,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (char *)box_list->b_name,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte verbose)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) l_free_box_list(&box_list_ptr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_destroy_data(result);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_DUPLICATE_ENCLOSURES);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte found_box = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte box_list = box_list->box_next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check to see if we must get individual disks path.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (found_box && slot_flag) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((l_state = (L_state *)g_zalloc(sizeof (L_state))) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_destroy_data(result);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) l_free_box_list(&box_list_ptr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_MALLOC_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcpy(ses_path, result);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((err = l_get_status(ses_path, l_state,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte verbose)) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_destroy_data(result);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_destroy_data(l_state);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) l_free_box_list(&box_list_ptr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (err);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Now double check the slot number.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (slot >= l_state->total_num_drv/2) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte path_ptr->slot_valid = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_destroy_data(result);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) l_free_box_list(&box_list_ptr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) l_free_lstate(&l_state);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_INVALID_SLOT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Only allow the single slot version for Daktari */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (g_get_inquiry(ses_path, &inq)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_SCSI_ERROR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte enc_type = l_get_enc_type(inq);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (((enc_type == DAK_ENC_TYPE) && (save_frd != 's')) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((enc_type != DAK_ENC_TYPE) && (save_frd == 's'))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte path_ptr->slot_valid = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_destroy_data(result);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) l_free_box_list(&box_list_ptr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) l_free_lstate(&l_state);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_INVALID_SLOT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (path_ptr->f_flag) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*l_state->drv_front[slot].g_disk_state.physical_path) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte result =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte g_alloc_string(l_state->drv_front[slot].g_disk_state.physical_path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Result is the IB path */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte path_ptr->ib_path_flag = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte path_ptr->p_physical_path =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte g_alloc_string(result);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_destroy_data(result);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte result = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*l_state->drv_rear[slot].g_disk_state.physical_path) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte result =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte g_alloc_string(l_state->drv_rear[slot].g_disk_state.physical_path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Result is the IB path */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte path_ptr->ib_path_flag = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte path_ptr->p_physical_path =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte g_alloc_string(result);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_destroy_data(result);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte result = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) l_free_lstate(&l_state);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto done;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (found_box || found_comma) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto done;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * No luck with the box name.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Try WWN's
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Look for the SES's WWN */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte box_list = box_list_ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (box_list != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (((strcasecmp((char *)tmp_name,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (char *)box_list->b_port_wwn_s)) == 0) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((strcasecmp((char *)tmp_name,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (char *)box_list->b_node_wwn_s)) == 0)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte result =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte g_alloc_string(box_list->b_physical_path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte L_DPRINTF(" l_convert_name:"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " Found subsystem using the WWN"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ": name %s WWN %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte box_list->b_name, box_list->b_node_wwn_s);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto done;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte box_list = box_list->box_next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Look for a device's WWN */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strlen(tmp_name) <= L_WWN_LENGTH) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((err = g_get_wwn_list(&wwn_list, verbose)) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) l_free_box_list(&box_list_ptr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (err);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (wwn_list_ptr = wwn_list; wwn_list_ptr != NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wwn_list_ptr = wwn_list_ptr->wwn_next) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (((strcasecmp((char *)tmp_name,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (char *)wwn_list_ptr->node_wwn_s)) == 0) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((strcasecmp((char *)tmp_name,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (char *)wwn_list_ptr->port_wwn_s)) == 0)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Found the device's WWN in the global WWN list.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * It MAY be in a photon/Daktari. If it is, we'll set
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * additional fields in path_struct.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte result = g_alloc_string(wwn_list_ptr->physical_path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte L_DPRINTF(" l_convert_name:"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " Found device: WWN %s Path %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_name, wwn_list_ptr->logical_path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_free_wwn_list(&wwn_list);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Now check if it is a disk in an A5K and set
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * path_struct fields
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte path_ptr->p_physical_path = result;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((err = g_get_inquiry(result, &inq)) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) free(result);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_SCSI_ERROR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check to see if it is a supported
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * A5K/v880/v890 storage subsystem disk
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (g_enclDiskChk((char *)inq.inq_vid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (char *)inq.inq_pid)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err = load_flds_if_enc_disk(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte result, path_struct)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) free(result);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (err);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto done;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Try again in case we were in the /dev
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * or /devices directory.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte result = g_get_physical_name(name);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortedone:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) l_free_box_list(&box_list_ptr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte path_ptr->argv = name;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (result == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!path_ptr->ib_path_flag)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte path_ptr->p_physical_path = result;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte L_DPRINTF(" l_convert_name: path_struct:\n\tphysical_path:\n\t %s\n"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "\targv:\t\t%s"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "\n\tslot_valid\t%d"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "\n\tslot\t\t%d"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "\n\tf_flag\t\t%d"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "\n\tib_path_flag\t%d\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte path_ptr->p_physical_path,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte path_ptr->argv,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte path_ptr->slot_valid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte path_ptr->slot,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte path_ptr->f_flag,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte path_ptr->ib_path_flag);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (env != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte end_time = gethrtime();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, " l_convert_name: "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Time = %lld millisec\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (end_time - start_time)/1000000);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (path_ptr->ib_path_flag)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *phys_path = result;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Gets envsen information of an enclosure from IB
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * RETURNS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 0 O.K.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * non-zero otherwise
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortel_get_envsen_page(int fd, uchar_t *buf, int buf_size, uchar_t page_code,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int verbose)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteRec_diag_hdr hdr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteuchar_t *pg;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint size, new_size, status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (buf == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_INVALID_BUF_LEN);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (verbose) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(9046, " Reading SES page %x\n"), page_code);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memset(&hdr, 0, sizeof (struct rec_diag_hdr));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status = g_scsi_rec_diag_cmd(fd, (uchar_t *)&hdr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (struct rec_diag_hdr), page_code)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((hdr.page_code != page_code) || (hdr.page_len == 0)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_RD_PG_INVLD_CODE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size = HEADER_LEN + hdr.page_len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Because of a hardware restriction in the soc+ chip
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the transfers must be word aligned.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (size & 0x03) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (size > buf_size) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_RD_PG_MIN_BUFF);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte P_DPRINTF(" l_get_envsen_page: Adjusting size of the "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "g_scsi_rec_diag_cmd buffer.\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((pg = (uchar_t *)g_zalloc(size)) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_MALLOC_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte P_DPRINTF(" l_get_envsen_page: Reading page %x of size 0x%x\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte page_code, size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status = g_scsi_rec_diag_cmd(fd, pg, size, page_code)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_destroy_data((char *)pg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte new_size = MIN(size, buf_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy((const void *)pg, (void *)buf, (size_t)new_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_destroy_data(pg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get consolidated copy of all environmental information
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * into buf structure.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * RETURNS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 0 O.K.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * non-zero otherwise
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortel_get_envsen(char *path_phys, uchar_t *buf, int size, int verbose)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint fd, rval;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteuchar_t *page_list_ptr, page_code, *local_buf_ptr = buf;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteRec_diag_hdr *hdr = (struct rec_diag_hdr *)(void *)buf;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteushort_t num_pages;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((path_phys == NULL) || (buf == NULL)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_INVALID_PATH_FORMAT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte page_code = L_PAGE_PAGE_LIST;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* open IB */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((fd = g_object_open(path_phys, O_NDELAY | O_RDONLY)) == -1)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_OPEN_PATH_FAIL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte P_DPRINTF(" l_get_envsen: Getting list of supported"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " pages from IB\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (verbose) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(9047, " Getting list of supported pages from IB\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get page 0 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((rval = l_get_envsen_page(fd, local_buf_ptr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size, page_code, verbose)) != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) close(fd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rval);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte page_list_ptr = buf + HEADER_LEN + 1; /* +1 to skip page 0 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte num_pages = hdr->page_len - 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * check whether the number of pages received
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * from IB are valid. SENA enclosure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * supports only 8 pages of sense information.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * According to SES specification dpANS X3.xxx-1997
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * X3T10/Project 1212-D/Rev 8a, the enclosure supported
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * pages can go upto L_MAX_POSSIBLE_PAGES (0xFF).
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Return an error if no. of pages exceeds L_MAX_POSSIBLE_PAGES.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See if (num_pages >= L_MAX_POSSIBLE_PAGES) since 1 page (page 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * was already subtracted from the total number of pages before.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (num_pages < 1 || num_pages >= L_MAX_POSSIBLE_PAGES) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_INVALID_NO_OF_ENVSEN_PAGES);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Buffer size of MAX_REC_DIAG_LENGTH can be small if the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * number of pages exceed more than L_MAX_SENAIB_PAGES
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * but less than L_MAX_POSSIBLE_PAGES.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (size == MAX_REC_DIAG_LENGTH &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte num_pages >= L_MAX_SENAIB_PAGES) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_INVALID_BUF_LEN);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Align buffer */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (hdr->page_len & 0x03) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hdr->page_len++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte local_buf_ptr += HEADER_LEN + hdr->page_len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Getting all pages and appending to buf
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (; num_pages--; page_list_ptr++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The fifth byte of page 0 is the start
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * of the list of pages not including page 0.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte page_code = *page_list_ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((rval = l_get_envsen_page(fd, local_buf_ptr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size, page_code, verbose)) != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) close(fd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rval);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hdr = (struct rec_diag_hdr *)(void *)local_buf_ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte local_buf_ptr += HEADER_LEN + hdr->page_len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) close(fd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get the individual disk status.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Path must be physical and point to a disk.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This function updates the d_state_flags, port WWN's
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and num_blocks for all accessiable ports
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * in l_disk_state->g_disk_state structure.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * RETURNS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 0 O.K.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * non-zero otherwise
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortel_get_disk_status(char *path, struct l_disk_state_struct *l_disk_state,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte WWN_list *wwn_list, int verbose)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestruct dlist *ml;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortechar path_a[MAXPATHLEN], path_b[MAXPATHLEN], ses_path[MAXPATHLEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortegfc_map_t map;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint path_a_found = 0, path_b_found = 0, local_port_a_flag;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteuchar_t node_wwn[WWN_SIZE], port_wwn[WWN_SIZE];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint al_pa, err, pathcnt = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint i = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortechar temppath[MAXPATHLEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortemp_pathlist_t pathlist;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortechar pwwn[WWN_S_LEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestruct stat sbuf;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((path == NULL) || (l_disk_state == NULL)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_INVALID_PATH_FORMAT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check device name */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (stat(path, &sbuf) || (sbuf.st_rdev == NODEV)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte G_DPRINTF(" l_get_disk_status: invalid device %s\n", path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_INVALID_PATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Initialize */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *path_a = *path_b = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte l_disk_state->g_disk_state.num_blocks = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get paths. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte g_get_multipath(path,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &(l_disk_state->g_disk_state.multipath_list),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wwn_list, verbose);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ml = l_disk_state->g_disk_state.multipath_list;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ml == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte l_disk_state->l_state_flag = L_NO_PATH_FOUND;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte G_DPRINTF(" l_get_disk_status: Error finding a "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "multipath to the disk.\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strstr(path, SCSI_VHCI) != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * It is an MPXIO Path
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcpy(temppath, path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (g_get_pathlist(temppath, &pathlist)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pathcnt = pathlist.path_count;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < pathcnt; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Skip inactive paths.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * A path that is not in either
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * MDI_PATHINFO_STATE_ONLINE or
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * MDI_PATHINFO_STATE_STANDBY state is not
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * an active path.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * When a disk port is bypassed and mpxio is
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * enabled, the path_state for that path goes to the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * offline state
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pathlist.path_info[i].path_state !=
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MDI_PATHINFO_STATE_ONLINE &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pathlist.path_info[i].path_state !=
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MDI_PATHINFO_STATE_STANDBY) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(pwwn, pathlist.path_info[i].path_addr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte L_WWN_LENGTH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pwwn[L_WWN_LENGTH] = '\0';
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!(path_a_found || path_b_found)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pwwn[1] == '1') {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte local_port_a_flag = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte local_port_a_flag = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (path_a_found &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (strstr(l_disk_state->g_disk_state.port_a_wwn_s,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pwwn) == NULL)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* do port b */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte local_port_a_flag = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (path_b_found &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (strstr(l_disk_state->g_disk_state.port_b_wwn_s,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pwwn) == NULL)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* do port a */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte local_port_a_flag = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err = l_get_disk_port_status(path,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte l_disk_state, local_port_a_flag, verbose)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (err);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (local_port_a_flag && (!path_a_found)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcpy(l_disk_state->
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte g_disk_state.port_a_wwn_s, pwwn);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte l_disk_state->g_disk_state.port_a_valid++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte path_a_found++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((!local_port_a_flag) && (!path_b_found)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcpy(l_disk_state->
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte g_disk_state.port_b_wwn_s, pwwn);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte l_disk_state->g_disk_state.port_b_valid++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte path_b_found++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(pathlist.path_info);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (ml && (!(path_a_found && path_b_found))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err = g_get_dev_map(ml->dev_path, &map, verbose)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_free_multipath(ml);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (err);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((err = l_get_ses_path(ml->dev_path, ses_path,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &map, verbose)) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_free_multipath(ml);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free((void *)map.dev_addr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (err);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free((void *)map.dev_addr); /* Not used anymore */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get the port, A or B, of the disk,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * by passing the IB path.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err = l_get_port(ses_path, &local_port_a_flag, verbose)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_free_multipath(ml);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (err);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (local_port_a_flag && (!path_a_found)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte G_DPRINTF(" l_get_disk_status: Path to Port A "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "found: %s\n", ml->dev_path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err = l_get_disk_port_status(ml->dev_path,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte l_disk_state, local_port_a_flag, verbose)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_free_multipath(ml);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (err);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err = g_get_wwn(ml->dev_path,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port_wwn, node_wwn,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &al_pa, verbose)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_free_multipath(ml);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (err);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(l_disk_state->g_disk_state.port_a_wwn_s,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port_wwn[0], port_wwn[1], port_wwn[2], port_wwn[3],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port_wwn[4], port_wwn[5], port_wwn[6], port_wwn[7]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte l_disk_state->g_disk_state.port_a_valid++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte path_a_found++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((!local_port_a_flag) && (!path_b_found)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte G_DPRINTF(" l_get_disk_status: Path to Port B "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "found: %s\n", ml->dev_path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err = l_get_disk_port_status(ml->dev_path,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte l_disk_state, local_port_a_flag, verbose)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (err);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err = g_get_wwn(ml->dev_path,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port_wwn, node_wwn,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &al_pa, verbose)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_free_multipath(ml);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (err);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(l_disk_state->g_disk_state.port_b_wwn_s,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port_wwn[0], port_wwn[1], port_wwn[2], port_wwn[3],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port_wwn[4], port_wwn[5], port_wwn[6], port_wwn[7]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte l_disk_state->g_disk_state.port_b_valid++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte path_b_found++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ml = ml->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check for Persistent Reservations.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortel_persistent_check(int fd, struct l_disk_state_struct *l_disk_state,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int verbose)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteRead_keys read_key_buf;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteRead_reserv read_reserv_buf;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memset(&read_key_buf, 0, sizeof (struct read_keys_struct));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((status = g_scsi_persistent_reserve_in_cmd(fd,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uchar_t *)&read_key_buf, sizeof (struct read_keys_struct),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ACTION_READ_KEYS))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* This means persistent reservations are supported by the disk. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte l_disk_state->g_disk_state.persistent_reserv_flag = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (read_key_buf.rk_length) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte l_disk_state->g_disk_state.persistent_registered = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memset(&read_reserv_buf, 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (struct read_reserv_struct));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((status = g_scsi_persistent_reserve_in_cmd(fd,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uchar_t *)&read_reserv_buf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (struct read_reserv_struct),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ACTION_READ_RESERV))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (read_reserv_buf.rr_length) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte l_disk_state->g_disk_state.persistent_active = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (verbose) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(9048, " Checking for Persistent "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Reservations:"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (l_disk_state->g_disk_state.persistent_reserv_flag) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (l_disk_state->g_disk_state.persistent_active != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, MSGSTR(39, "Active"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, MSGSTR(9049, "Registered"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(87,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Not being used"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Gets the disk status and
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * updates the l_disk_state_struct structure.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Checks for open fail, Reservation Conflicts,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Not Ready and so on.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * RETURNS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 0 O.K.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * non-zero otherwise
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortel_get_disk_port_status(char *path, struct l_disk_state_struct *l_disk_state,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int port_a_flag, int verbose)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint fd, status = 0, local_state = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteRead_capacity_data capacity; /* local read capacity buffer */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestruct vtoc vtoc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((path == NULL) || (l_disk_state == NULL)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_INVALID_PATH_FORMAT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Try to open drive.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((fd = g_object_open(path, O_RDONLY)) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((fd = g_object_open(path,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte O_RDONLY | O_NDELAY)) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte G_DPRINTF(" l_get_disk_port_status: Error "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "opening drive %s\n", path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte local_state = L_OPEN_FAIL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* See if drive ready */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status = g_scsi_tur(fd)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((status & L_SCSI_ERROR) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((status & ~L_SCSI_ERROR) == STATUS_CHECK)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * TBD
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This is where I should figure out
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * if the device is Not Ready or whatever.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte local_state = L_NOT_READY;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if ((status & L_SCSI_ERROR) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((status & ~L_SCSI_ERROR) ==
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte STATUS_RESERVATION_CONFLICT)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* mark reserved */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte local_state = L_RESERVED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte local_state = L_SCSI_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * There may not be a label on the drive - check
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (ioctl(fd, DKIOCGVTOC, &vtoc) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Sanity-check the vtoc
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (vtoc.v_sanity != VTOC_SANE ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte vtoc.v_sectorsz != DEV_BSIZE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte local_state = L_NO_LABEL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte G_DPRINTF(" l_get_disk_port_status: "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Checking vtoc - No Label found.\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (errno != ENOTSUP) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte I_DPRINTF("\t- DKIOCGVTOC ioctl failed: "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " invalid geometry\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte local_state = L_NO_LABEL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Need an extra check for tape devices
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * read capacity should not be run on tape devices.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * It will always return Not Readable
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (((local_state == 0) || (local_state == L_NO_LABEL)) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ! (strstr(path, SLSH_DRV_NAME_ST))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status = g_scsi_read_capacity_cmd(fd, (uchar_t *)&capacity,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (capacity))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte G_DPRINTF(" l_get_disk_port_status: "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Read Capacity failed.\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status & L_SCSI_ERROR) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((status & ~L_SCSI_ERROR) ==
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte STATUS_RESERVATION_CONFLICT) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* mark reserved */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte local_state |= L_RESERVED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* mark bad */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte local_state |= L_NOT_READABLE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * TBD
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Need a more complete state definition here.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte l_disk_state->g_disk_state.d_state_flags[port_a_flag] =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte L_SCSI_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) close(fd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* save capacity */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte l_disk_state->g_disk_state.num_blocks =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte capacity.last_block_addr + 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) close(fd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte l_disk_state->g_disk_state.d_state_flags[port_a_flag] = local_state;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte G_DPRINTF(" l_get_disk_port_status: Individual Disk"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " Status: 0x%x for"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " port %s for path:"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " %s\n", local_state,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port_a_flag ? "A" : "B", path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Copy and format page 1 from big buffer to state structure.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * RETURNS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 0 O.K.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * non-zero otherwise
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortecopy_config_page(struct l_state_struct *l_state, uchar_t *from_ptr)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteIB_page_config *encl_ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint size, i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte encl_ptr = (struct ib_page_config *)(void *)from_ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Sanity check. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((encl_ptr->enc_len > MAX_VEND_SPECIFIC_ENC) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (encl_ptr->enc_len == 0)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_REC_DIAG_PG1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((encl_ptr->enc_num_elem > MAX_IB_ELEMENTS) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (encl_ptr->enc_num_elem == 0)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_REC_DIAG_PG1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size = HEADER_LEN + 4 + HEADER_LEN + encl_ptr->enc_len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy((void *)(from_ptr),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void *)&l_state->ib_tbl.config, (size_t)size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Copy Type Descriptors seperately to get aligned.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte from_ptr += size;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size = (sizeof (struct type_desc_hdr))*encl_ptr->enc_num_elem;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy((void *)(from_ptr),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void *)&l_state->ib_tbl.config.type_hdr, (size_t)size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Copy Text Descriptors seperately to get aligned.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Must use the text size from the Type Descriptors.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte from_ptr += size;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < (int)l_state->ib_tbl.config.enc_num_elem; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size = l_state->ib_tbl.config.type_hdr[i].text_len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy((void *)(from_ptr),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void *)&l_state->ib_tbl.config.text[i], (size_t)size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte from_ptr += size;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Copy page 7 (Element Descriptor page) to state structure.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Copy header then copy each element descriptor
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * seperately.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * RETURNS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 0 O.K.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * non-zero otherwise
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortecopy_page_7(struct l_state_struct *l_state, uchar_t *from_ptr)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteuchar_t *my_from_ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint size, j, k, p7_index;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size = HEADER_LEN +
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (l_state->ib_tbl.p7_s.gen_code);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy((void *)(from_ptr),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void *)&l_state->ib_tbl.p7_s, (size_t)size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte my_from_ptr = from_ptr + size;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (getenv("_LUX_D_DEBUG") != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte g_dump(" copy_page_7: Page 7 header: ",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uchar_t *)&l_state->ib_tbl.p7_s, size,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HEX_ASCII);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " copy_page_7: Elements being stored "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "in state table\n"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " ");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* I am assuming page 1 has been read. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (j = 0, p7_index = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte j < (int)l_state->ib_tbl.config.enc_num_elem; j++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Copy global element */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size = HEADER_LEN +
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((*(my_from_ptr + 2) << 8) | *(my_from_ptr + 3));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy((void *)(my_from_ptr),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void *)&l_state->ib_tbl.p7_s.element_desc[p7_index++],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (size_t)size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte my_from_ptr += size;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (k = 0; k < (int)l_state->ib_tbl.config.type_hdr[j].num;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte k++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Copy individual elements */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size = HEADER_LEN +
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((*(my_from_ptr + 2) << 8) |
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *(my_from_ptr + 3));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy((void *)(my_from_ptr),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void *)&l_state->ib_tbl.p7_s.element_desc[p7_index++],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (size_t)size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte my_from_ptr += size;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte D_DPRINTF(".");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte D_DPRINTF("\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Gets IB diagnostic pages on a given pathname from l_get_envsen().
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * It also fills up the individual device element of l_state_struct using
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * diagnostics pages.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Gets IB diagnostic pages on a given pathname from l_get_envsen().
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * It also fills up the individual device element of l_state_struct using
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * diagnostics pages.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The path must be of the ses driver.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * e.g.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * /devices/sbus@1f,0/SUNW,socal@1,0/SUNW,sf@0,0/ses@e,0:0
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * or
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * /devices/sbus@1f,0/SUNW,socal@1,0/SUNW,sf@0,0/ses@WWN,0:0
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * RETURNS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 0 O.K.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * non-zero otherwise
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortel_get_ib_status(char *path, struct l_state_struct *l_state,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int verbose)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteL_inquiry inq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteuchar_t *ib_buf, *from_ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint num_pages, i, size, err;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteIB_page_2 *encl_ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint front_index, rear_index;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint enc_type = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((path == NULL) || (l_state == NULL)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_INVALID_PATH_FORMAT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * get big buffer
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((ib_buf = (uchar_t *)calloc(1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MAX_REC_DIAG_LENGTH)) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_MALLOC_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get IB information
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Even if there are 2 IB's in this box on this loop don't bother
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * talking to the other one as both IB's in a box
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * are supposed to report the same information.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err = l_get_envsen(path, ib_buf, MAX_REC_DIAG_LENGTH,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte verbose)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_destroy_data(ib_buf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (err);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Set up state structure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy((void *)ib_buf, (void *)&l_state->ib_tbl.p0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (size_t)sizeof (struct ib_page_0));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte num_pages = l_state->ib_tbl.p0.page_len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte from_ptr = ib_buf + HEADER_LEN + l_state->ib_tbl.p0.page_len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 1; i < num_pages; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (l_state->ib_tbl.p0.sup_page_codes[i] == L_PAGE_1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err = copy_config_page(l_state, from_ptr)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (err);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (l_state->ib_tbl.p0.sup_page_codes[i] ==
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte L_PAGE_2) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte encl_ptr = (struct ib_page_2 *)(void *)from_ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size = HEADER_LEN + encl_ptr->page_len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy((void *)(from_ptr),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void *)&l_state->ib_tbl.p2_s, (size_t)size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (getenv("_LUX_D_DEBUG") != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte g_dump(" l_get_ib_status: Page 2: ",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uchar_t *)&l_state->ib_tbl.p2_s, size,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HEX_ONLY);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (l_state->ib_tbl.p0.sup_page_codes[i] ==
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte L_PAGE_7) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) copy_page_7(l_state, from_ptr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte from_ptr += ((*(from_ptr + 2) << 8) | *(from_ptr + 3));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte from_ptr += HEADER_LEN;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_destroy_data(ib_buf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte G_DPRINTF(" l_get_ib_status: Read %d Receive Diagnostic pages "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "from the IB.\n", num_pages);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err = g_get_inquiry(path, &inq)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (err);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte enc_type = l_get_enc_type(inq);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get the total number of drives per box.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This assumes front & rear are the same.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte l_state->total_num_drv = 0; /* default to use as a flag */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < (int)l_state->ib_tbl.config.enc_num_elem; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (l_state->ib_tbl.config.type_hdr[i].type == ELM_TYP_DD) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (l_state->total_num_drv) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (l_state->total_num_drv !=
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (l_state->ib_tbl.config.type_hdr[i].num * 2)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_INVALID_NUM_DISKS_ENCL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (enc_type == DAK_ENC_TYPE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte l_state->total_num_drv =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte l_state->ib_tbl.config.type_hdr[i].num;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte l_state->total_num_drv =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte l_state->ib_tbl.config.type_hdr[i].num * 2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * transfer the individual drive Device Element information
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * from IB state to drive state.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err = l_get_disk_element_index(l_state, &front_index,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &rear_index)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (err);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Skip global element */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte front_index++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (enc_type == DAK_ENC_TYPE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rear_index += l_state->total_num_drv/2 + 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rear_index++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < l_state->total_num_drv/2; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy((void *)&l_state->ib_tbl.p2_s.element[front_index + i],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void *)&l_state->drv_front[i].ib_status,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (size_t)sizeof (struct device_element));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy((void *)&l_state->ib_tbl.p2_s.element[rear_index + i],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void *)&l_state->drv_rear[i].ib_status,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (size_t)sizeof (struct device_element));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (getenv("_LUX_G_DEBUG") != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte g_dump(" l_get_ib_status: disk elements: ",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uchar_t *)&l_state->ib_tbl.p2_s.element[front_index],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((sizeof (struct device_element)) * (l_state->total_num_drv)),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HEX_ONLY);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Given an IB path get the port, A or B.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * OUTPUT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * port_a: sets to 1 for port A
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and 0 for port B.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * RETURNS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * err: 0 O.k.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * non-zero otherwise
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortel_get_port(char *ses_path, int *port_a, int verbose)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteL_state *ib_state = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteCtlr_elem_st ctlr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint i, err, elem_index = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((ses_path == NULL) || (port_a == NULL)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_NO_SES_PATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((ib_state = (L_state *)calloc(1, sizeof (L_state))) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_MALLOC_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(&ctlr, sizeof (ctlr));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err = l_get_ib_status(ses_path, ib_state, verbose)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) l_free_lstate(&ib_state);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (err);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < (int)ib_state->ib_tbl.config.enc_num_elem; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte elem_index++; /* skip global */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ib_state->ib_tbl.config.type_hdr[i].type == ELM_TYP_IB) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy((const void *)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &ib_state->ib_tbl.p2_s.element[elem_index],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void *)&ctlr, sizeof (ctlr));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte elem_index += ib_state->ib_tbl.config.type_hdr[i].num;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *port_a = ctlr.report;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte G_DPRINTF(" l_get_port: Found ses is the %s card.\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ctlr.report ? "A" : "B");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) l_free_lstate(&ib_state);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This function expects a pointer to a device path ending in the form
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * .../ses@w<NODEWWN>,<something> or .../ssd@w<NODEWWN>,<something>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * No validity checking of the path is done by the function.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * It gets the wwn (node wwn) out of the passed string, searches the passed
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * map for a match, gets the corresponding phys addr (port id) for that entry
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and stores in the pointer the caller has passed as an argument (pid)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This function is to be called only for public/fabric topologies
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If this interface is going to get exported, one point to be
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * considered is if a call to g_get_path_type() has to be made.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * INPUT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * path - pointer to the enclosure/disk device path
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * map - pointer to the map
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * OUTPUT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * pid - the physical address associated for the node WWN that was found
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * in the map
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * RETURNS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 0 - on success
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * non-zero - otherwise
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortel_get_pid_from_path(const char *path, const gfc_map_t *map, int *pid)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteunsigned long long ll_wwn;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortechar *char_ptr, wwn_str[WWN_SIZE * 2 + 1];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortechar *byte_ptr, *temp_ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortegfc_port_dev_info_t *dev_addr_ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortemp_pathlist_t pathlist;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortechar path0[MAXPATHLEN], pwwn0[WWN_S_LEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* if mpxio device */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strstr(path, SCSI_VHCI) != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcpy(path0, path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (g_get_pathlist(path0, &pathlist)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_INVALID_PATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(pwwn0, pathlist.path_info[0].
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte path_addr, L_WWN_LENGTH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pwwn0[L_WWN_LENGTH] = '\0';
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(pathlist.path_info);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char_ptr = pwwn0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* First a quick check on the path */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (((char_ptr = strrchr(path, '@')) == NULL) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (*++char_ptr != 'w')) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_INVALID_PATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char_ptr++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strlen(char_ptr) < (WWN_SIZE * 2)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_INVALID_PATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(wwn_str, char_ptr, WWN_SIZE * 2);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wwn_str[WWN_SIZE * 2] = '\0';
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte errno = 0; /* For error checking */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ll_wwn = strtoull(wwn_str, &temp_ptr, L_WWN_LENGTH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (errno || (temp_ptr != (wwn_str + (WWN_SIZE * 2)))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_INVALID_PATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte byte_ptr = (char *)&ll_wwn;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Search for the ses's node wwn in map to get the area and
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * domain ids from the corresponding port id (phys address).
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (dev_addr_ptr = map->dev_addr, i = 0; i < map->count;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dev_addr_ptr++, i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (bcmp((char *)dev_addr_ptr->gfc_port_dev.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pub_port.dev_nwwn.raw_wwn, byte_ptr, WWN_SIZE) == 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (i >= map->count)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_INVALID_PATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *pid = dev_addr_ptr->gfc_port_dev.pub_port.dev_did.port_id;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Finds the disk's node wwn string, and
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * port A and B's WWNs and their port status.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * INPUT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * path - pointer to a ses path
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * wwn_list - pointer to the wwn_list
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * OUTPUT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * state - node_wwn and wwn of ports A & B of disk, etc are inited
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * - by l_get_disk_status()
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * found_flag - incremented after each examined element in the map
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * RETURNS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 0 O.K.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * non-zero otherwise.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortel_get_node_status(char *path, struct l_disk_state_struct *state,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int *found_flag, WWN_list *wwn_list, int verbose)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint j, select_id, err;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint path_pid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortechar temp_path[MAXPATHLEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortechar sbuf[MAXPATHLEN], *char_ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortegfc_map_mp_t *map_mp, *map_ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestruct stat stat_buf;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteWWN_list *wwnlp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortechar wwnp[WWN_S_LEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get a new map.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte map_mp = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err = get_mp_dev_map(path, &map_mp, verbose))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (err);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (map_ptr = map_mp; map_ptr != NULL; map_ptr = map_ptr->map_next) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (map_ptr->map.hba_addr.port_topology) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FC_TOP_PRIVATE_LOOP:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (j = 0; j < map_ptr->map.count; j++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get a generic path to a device
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This assumes the path looks something like this
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * /devices/sbus@1f,0/SUNW,socal@1,0/SUNW,sf@0,0/...
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ...ses@x,0:0
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * then creates a path that looks like
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * /devices/sbus@1f,0/SUNW,socal@1,0/SUNW,sf@0,0/ssd@
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcpy(temp_path, path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((char_ptr = strrchr(temp_path, '/')) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free_mp_dev_map(&map_mp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_INVALID_PATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *char_ptr = '\0'; /* Terminate sting */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcat(temp_path, SLSH_DRV_NAME_SSD);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Create complete path.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Build entry ssd@xx,0:c,raw
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * where xx is the WWN.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte select_id = g_sf_alpa_to_switch[map_ptr->map.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dev_addr[j].gfc_port_dev.priv_port.sf_al_pa];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte G_DPRINTF(" l_get_node_status: Searching loop map "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "to find disk: ID:0x%x"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " AL_PA:0x%x\n", select_id,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte state->ib_status.sel_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strstr(path, SCSI_VHCI) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(sbuf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "w%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x,0:c,raw",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte map_ptr->map.dev_addr[j].gfc_port_dev.priv_port.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sf_port_wwn[0],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte map_ptr->map.dev_addr[j].gfc_port_dev.priv_port.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sf_port_wwn[1],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte map_ptr->map.dev_addr[j].gfc_port_dev.priv_port.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sf_port_wwn[2],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte map_ptr->map.dev_addr[j].gfc_port_dev.priv_port.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sf_port_wwn[3],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte map_ptr->map.dev_addr[j].gfc_port_dev.priv_port.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sf_port_wwn[4],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte map_ptr->map.dev_addr[j].gfc_port_dev.priv_port.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sf_port_wwn[5],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte map_ptr->map.dev_addr[j].gfc_port_dev.priv_port.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sf_port_wwn[6],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte map_ptr->map.dev_addr[j].gfc_port_dev.priv_port.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sf_port_wwn[7]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcat(temp_path, sbuf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If we find a device on this loop in this box
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * update its status.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (state->ib_status.sel_id == select_id) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Found a device on this loop in this box.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Update state.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(state->g_disk_state.node_wwn_s,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte map_ptr->map.dev_addr[j].gfc_port_dev.priv_port.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sf_node_wwn[0],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte map_ptr->map.dev_addr[j].gfc_port_dev.priv_port.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sf_node_wwn[1],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte map_ptr->map.dev_addr[j].gfc_port_dev.priv_port.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sf_node_wwn[2],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte map_ptr->map.dev_addr[j].gfc_port_dev.priv_port.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sf_node_wwn[3],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte map_ptr->map.dev_addr[j].gfc_port_dev.priv_port.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sf_node_wwn[4],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte map_ptr->map.dev_addr[j].gfc_port_dev.priv_port.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sf_node_wwn[5],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte map_ptr->map.dev_addr[j].gfc_port_dev.priv_port.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sf_node_wwn[6],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte map_ptr->map.dev_addr[j].gfc_port_dev.priv_port.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sf_node_wwn[7]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strstr(path, SCSI_VHCI) != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_ll_to_str(map_ptr->map.dev_addr[j].gfc_port_dev.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte priv_port.sf_node_wwn, wwnp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (wwnlp = wwn_list; wwnlp != NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wwnlp = wwnlp->wwn_next) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp(wwnlp->node_wwn_s, wwnp) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcpy(temp_path, wwnlp->physical_path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (wwnlp == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(sbuf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "g%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x:c,raw",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte map_ptr->map.dev_addr[j].gfc_port_dev.priv_port.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sf_node_wwn[0],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte map_ptr->map.dev_addr[j].gfc_port_dev.priv_port.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sf_node_wwn[1],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte map_ptr->map.dev_addr[j].gfc_port_dev.priv_port.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sf_node_wwn[2],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte map_ptr->map.dev_addr[j].gfc_port_dev.priv_port.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sf_node_wwn[3],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte map_ptr->map.dev_addr[j].gfc_port_dev.priv_port.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sf_node_wwn[4],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte map_ptr->map.dev_addr[j].gfc_port_dev.priv_port.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sf_node_wwn[5],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte map_ptr->map.dev_addr[j].gfc_port_dev.priv_port.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sf_node_wwn[6],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte map_ptr->map.dev_addr[j].gfc_port_dev.priv_port.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sf_node_wwn[7]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcat(temp_path, sbuf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * check to make sure this is a valid path.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Paths may not always be created on the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * host. So, we make a quick check.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (stat(temp_path, &stat_buf) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free_mp_dev_map(&map_mp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (errno);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcpy(state->g_disk_state.physical_path,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte temp_path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Bad if WWN is all zeros. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (is_null_wwn(map_ptr->map.dev_addr[j].
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gfc_port_dev.priv_port.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sf_node_wwn)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte state->l_state_flag = L_INVALID_WWN;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte G_DPRINTF(" l_get_node_status: "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Disk state was "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " Invalid WWN.\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (*found_flag)++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free_mp_dev_map(&map_mp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get device status */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err = l_get_disk_status(temp_path, state,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wwn_list, verbose)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free_mp_dev_map(&map_mp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (err);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * found device in map. Don't need to look
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * any further
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (*found_flag)++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free_mp_dev_map(&map_mp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } /* for loop */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FC_TOP_PUBLIC_LOOP:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FC_TOP_FABRIC:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get a generic path to a device
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This assumes the path looks something like this
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * /devices/sbus@1f,0/SUNW,socal@1,0/SUNW,sf@0,0/ses@wWWN,0:0
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * then creates a path that looks like
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * /devices/sbus@1f,0/SUNW,socal@1,0/SUNW,sf@0,0/ssd@
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcpy(temp_path, path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((char_ptr = strrchr(temp_path, '/')) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free_mp_dev_map(&map_mp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_INVALID_PATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *char_ptr = '\0'; /* Terminate sting */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err = l_get_pid_from_path(path, &map_ptr->map, &path_pid)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free_mp_dev_map(&map_mp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (err);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Now append the ssd string */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcat(temp_path, SLSH_DRV_NAME_SSD);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Create complete path.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Build entry ssd@WWN,0:c,raw
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * First, search the map for a device with the area code and
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * domain as in 'path_pid'.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (j = 0; j < map_ptr->map.count; j++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (map_ptr->map.dev_addr[j].gfc_port_dev.pub_port.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dev_dtype != DTYPE_ESI) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte select_id = g_sf_alpa_to_switch[map_ptr->map.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dev_addr[j].gfc_port_dev.pub_port.dev_did.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port_id & 0xFF];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (((map_ptr->map.dev_addr[j].gfc_port_dev.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pub_port.dev_did.port_id &
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte AREA_DOMAIN_ID) ==
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (path_pid & AREA_DOMAIN_ID)) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (state->ib_status.sel_id == select_id)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Found the device. Update state.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strstr(temp_path, SCSI_VHCI) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(sbuf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "w%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x,0:c,raw",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte map_ptr->map.dev_addr[j].gfc_port_dev.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pub_port.dev_pwwn.raw_wwn[0],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte map_ptr->map.dev_addr[j].gfc_port_dev.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pub_port.dev_pwwn.raw_wwn[1],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte map_ptr->map.dev_addr[j].gfc_port_dev.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pub_port.dev_pwwn.raw_wwn[2],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte map_ptr->map.dev_addr[j].gfc_port_dev.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pub_port.dev_pwwn.raw_wwn[3],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte map_ptr->map.dev_addr[j].gfc_port_dev.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pub_port.dev_pwwn.raw_wwn[4],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte map_ptr->map.dev_addr[j].gfc_port_dev.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pub_port.dev_pwwn.raw_wwn[5],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte map_ptr->map.dev_addr[j].gfc_port_dev.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pub_port.dev_pwwn.raw_wwn[6],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte map_ptr->map.dev_addr[j].gfc_port_dev.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pub_port.dev_pwwn.raw_wwn[7]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcat(temp_path, sbuf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Paths for fabric cases may not always
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * be created on the host. So, we make a
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * quick check.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (stat(temp_path, &stat_buf) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free_mp_dev_map(&map_mp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (errno);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(state->
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte g_disk_state.node_wwn_s,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte map_ptr->map.dev_addr[j].gfc_port_dev.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pub_port.dev_nwwn.raw_wwn[0],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte map_ptr->map.dev_addr[j].gfc_port_dev.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pub_port.dev_nwwn.raw_wwn[1],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte map_ptr->map.dev_addr[j].gfc_port_dev.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pub_port.dev_nwwn.raw_wwn[2],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte map_ptr->map.dev_addr[j].gfc_port_dev.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pub_port.dev_nwwn.raw_wwn[3],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte map_ptr->map.dev_addr[j].gfc_port_dev.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pub_port.dev_nwwn.raw_wwn[4],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte map_ptr->map.dev_addr[j].gfc_port_dev.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pub_port.dev_nwwn.raw_wwn[5],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte map_ptr->map.dev_addr[j].gfc_port_dev.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pub_port.dev_nwwn.raw_wwn[6],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte map_ptr->map.dev_addr[j].gfc_port_dev.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pub_port.dev_nwwn.raw_wwn[7]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_ll_to_str(map_ptr->map.dev_addr[j].gfc_port_dev.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte priv_port.sf_node_wwn, wwnp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (wwnlp = wwn_list; wwnlp != NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wwnlp = wwnlp->wwn_next) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp(wwnlp->node_wwn_s, wwnp) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcpy(temp_path, wwnlp->physical_path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (wwnlp == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(sbuf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "w%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x,0:c,raw",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte map_ptr->map.dev_addr[j].gfc_port_dev.pub_port.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dev_nwwn.raw_wwn[0],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte map_ptr->map.dev_addr[j].gfc_port_dev.pub_port.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dev_nwwn.raw_wwn[1],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte map_ptr->map.dev_addr[j].gfc_port_dev.pub_port.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dev_nwwn.raw_wwn[2],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte map_ptr->map.dev_addr[j].gfc_port_dev.pub_port.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dev_nwwn.raw_wwn[3],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte map_ptr->map.dev_addr[j].gfc_port_dev.pub_port.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dev_nwwn.raw_wwn[4],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte map_ptr->map.dev_addr[j].gfc_port_dev.pub_port.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dev_nwwn.raw_wwn[5],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte map_ptr->map.dev_addr[j].gfc_port_dev.pub_port.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dev_nwwn.raw_wwn[6],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte map_ptr->map.dev_addr[j].gfc_port_dev.pub_port.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dev_nwwn.raw_wwn[7]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcat(temp_path, sbuf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcpy(state->g_disk_state.physical_path,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte temp_path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Bad if WWN is all zeros. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (is_null_wwn(map_ptr->map.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dev_addr[j].gfc_port_dev.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pub_port.dev_nwwn.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte raw_wwn)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte state->l_state_flag =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte L_INVALID_WWN;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte G_DPRINTF(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " l_get_node_status: "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Disk state was "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " Invalid WWN.\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (*found_flag)++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free_mp_dev_map(&map_mp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get device status */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err = l_get_disk_status(temp_path,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte state, wwn_list, verbose)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free_mp_dev_map(&map_mp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (err);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (*found_flag)++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free_mp_dev_map(&map_mp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } /* if select_id match */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } /* if !DTYPE_ESI */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } /* for loop */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FC_TOP_PT_PT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free_mp_dev_map(&map_mp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_PT_PT_FC_TOP_NOT_SUPPORTED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free_mp_dev_map(&map_mp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_UNEXPECTED_FC_TOPOLOGY);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } /* End of switch on port_topology */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free_mp_dev_map(&map_mp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get the individual drives status for the device specified by the index.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * device at the path where the path is of the IB and updates the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * g_disk_state_struct structure.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If the disk's port is bypassed, it gets the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * drive status such as node WWN from the second port.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * RETURNS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 0 O.K.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * non-zero otherwise
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortel_get_individual_state(char *path,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct l_disk_state_struct *state, Ib_state *ib_state,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int front_flag, struct box_list_struct *box_list,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct wwn_list_struct *wwn_list, int verbose)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint found_flag = 0, elem_index = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint port_a_flag, err, j;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestruct dlist *seslist = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteBp_elem_st bpf, bpr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortehrtime_t start_time, end_time;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((path == NULL) || (state == NULL) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (ib_state == NULL) || (box_list == NULL)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_INVALID_PATH_FORMAT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte start_time = gethrtime();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((state->ib_status.code != S_NOT_INSTALLED) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (state->ib_status.code != S_NOT_AVAILABLE)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Disk could have been bypassed on this loop.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check the port state before l_state_flag
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * is set to L_INVALID_MAP.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (j = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte j < (int)ib_state->config.enc_num_elem;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte j++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte elem_index++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ib_state->config.type_hdr[j].type ==
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ELM_TYP_BP)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte elem_index +=
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ib_state->config.type_hdr[j].num;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * check if port A & B of backplane are bypassed.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If so, do not bother.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (front_flag) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy((const void *)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &(ib_state->p2_s.element[elem_index]),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void *)&bpf, sizeof (bpf));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((bpf.byp_a_enabled || bpf.en_bypass_a) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (bpf.byp_b_enabled || bpf.en_bypass_b))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* if disk is in rear slot */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy((const void *)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &(ib_state->p2_s.element[elem_index+1]),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void *)&bpr, sizeof (bpr));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((bpr.byp_b_enabled || bpr.en_bypass_b) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (bpr.byp_a_enabled || bpr.en_bypass_a))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((err = l_get_node_status(path, state,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &found_flag, wwn_list, verbose)) != 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (err);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!found_flag) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((err = l_get_allses(path, box_list,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &seslist, 0)) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (err);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err = l_get_port(path, &port_a_flag, verbose))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto done;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (port_a_flag) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((state->ib_status.bypass_a_en &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte !(state->ib_status.bypass_b_en)) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte !(state->ib_status.bypass_b_en)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (seslist != NULL && !found_flag) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err = l_get_port(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte seslist->dev_path,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &port_a_flag, verbose)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto done;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((strcmp(seslist->dev_path,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte path) != 0) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte !port_a_flag) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *path = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcpy(path,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte seslist->dev_path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte l_get_node_status(path,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte state, &found_flag,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wwn_list, verbose)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto done;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte seslist = seslist->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((state->ib_status.bypass_b_en &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte !(state->ib_status.bypass_a_en)) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte !(state->ib_status.bypass_a_en)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (seslist != NULL && !found_flag) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err = l_get_port(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte seslist->dev_path,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &port_a_flag, verbose)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto done;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((strcmp(seslist->dev_path,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte path) != 0) && port_a_flag) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *path = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcpy(path,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte seslist->dev_path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte l_get_node_status(path,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte state, &found_flag,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wwn_list, verbose)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto done;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte seslist = seslist->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!found_flag) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte state->l_state_flag = L_INVALID_MAP;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte G_DPRINTF(" l_get_individual_state: "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Disk state was "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Not in map.\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte G_DPRINTF(" l_get_individual_state: "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Disk was found in the map.\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (seslist != NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_free_multipath(seslist);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte G_DPRINTF(" l_get_individual_state: Disk state was %s.\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (state->ib_status.code == S_NOT_INSTALLED) ?
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Not Installed" : "Not Available");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (getenv("_LUX_T_DEBUG") != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte end_time = gethrtime();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, " l_get_individual_state:"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "\tTime = %lld millisec\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (end_time - start_time)/1000000);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortedone:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_free_multipath(seslist);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (err);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get the global state of the photon.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * INPUT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * path and verbose flag
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * "path" must be of the ses driver.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * e.g.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * /devices/sbus@1f,0/SUNW,socal@1,0/SUNW,sf@0,0/ses@e,0:0
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * or
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * /devices/sbus@1f,0/SUNW,socal@1,0/SUNW,sf@0,0/ses@WWN,0:0
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * OUTPUT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The struct l_state (which was passed in) has the status info
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * RETURNS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 0 O.K.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * non-zero otherwise
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortel_get_status(char *path, struct l_state_struct *l_state, int verbose)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint err = 0, i, count;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteL_inquiry inq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteuchar_t node_wwn[WWN_SIZE], port_wwn[WWN_SIZE];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint al_pa, found_front, found_rear, front_flag, enc_type;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortechar ses_path_front[MAXPATHLEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortechar ses_path_rear[MAXPATHLEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteBox_list *b_list = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteBox_list *o_list = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortechar node_wwn_s[(WWN_SIZE*2)+1];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteuint_t select_id;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortehrtime_t start_time, end_time;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteWWN_list *wwn_list = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((path == NULL) || (l_state == NULL)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_INVALID_PATH_FORMAT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte start_time = gethrtime();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte G_DPRINTF(" l_get_status: Get Status for enclosure at: "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " %s\n", path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* initialization */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memset(l_state, 0, sizeof (struct l_state_struct));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err = g_get_inquiry(path, &inq)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (err);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((strstr((char *)inq.inq_pid, ENCLOSURE_PROD_ID) == 0) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (!(strncmp((char *)inq.inq_vid, "SUN ",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (inq.inq_vid)) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((inq.inq_dtype & DTYPE_MASK) == DTYPE_ESI)))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_ENCL_INVALID_PATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy((char *)l_state->ib_tbl.enclosure_name,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (char *)inq.inq_box_name, sizeof (inq.inq_box_name));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get all of the IB Receive Diagnostic pages.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err = l_get_ib_status(path, l_state, verbose)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (err);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Now get the individual devices information from
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the device itself.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * May need to use multiple paths to get to the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * front and rear drives in the box.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If the loop is split some drives may not even be available
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * from this host.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The way this works is in the select ID the front disks
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * are accessed via the IB with the bit 4 = 0
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and the rear disks by the IB with bit 4 = 1.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * First get device map from fc nexus driver for this loop.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get the boxes node WWN & al_pa for this path.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err = g_get_wwn(path, port_wwn, node_wwn, &al_pa, verbose)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (err);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err = l_get_box_list(&o_list, verbose)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) l_free_box_list(&o_list);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (err); /* Failure */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte found_front = found_rear = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < WWN_SIZE; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(&node_wwn_s[i << 1], "%02x", node_wwn[i]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The al_pa (or pa) can be 24 bits in size for fabric loops.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * But we will take only the low order byte to get the select_id.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Private loops have al_pa which is only a byte in size.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte select_id = g_sf_alpa_to_switch[al_pa & 0xFF];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte l_state->ib_tbl.box_id = (select_id & BOX_ID_MASK) >> 5;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte G_DPRINTF(" l_get_status: Using this select_id 0x%x "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "and node WWN %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte select_id, node_wwn_s);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strstr(path, SCSI_VHCI) != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* there is no way to obtain all the al_pa with */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* current implementation. assume both front */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* and rear. need changes later on. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte found_rear = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte found_front = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcpy(ses_path_rear, path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcpy(ses_path_front, path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (select_id & ALT_BOX_ID) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte found_rear = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcpy(ses_path_rear, path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte b_list = o_list;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (b_list) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp(b_list->b_node_wwn_s, node_wwn_s) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err = g_get_wwn(b_list->b_physical_path,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port_wwn, node_wwn,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &al_pa, verbose)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) l_free_box_list(&o_list);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (err);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Take the low order byte of al_pa */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte select_id = g_sf_alpa_to_switch[al_pa & 0xFF];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!(select_id & ALT_BOX_ID)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcpy(ses_path_front,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte b_list->b_physical_path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte found_front = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte b_list = b_list->box_next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcpy(ses_path_front, path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte found_front = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte b_list = o_list;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (b_list) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp(b_list->b_node_wwn_s, node_wwn_s) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err = g_get_wwn(b_list->b_physical_path,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port_wwn, node_wwn,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &al_pa, verbose)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) l_free_box_list(&o_list);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (err);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte select_id = g_sf_alpa_to_switch[al_pa & 0xFF];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (select_id & ALT_BOX_ID) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcpy(ses_path_rear,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte b_list->b_physical_path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte found_rear = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte b_list = b_list->box_next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (getenv("_LUX_G_DEBUG") != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!found_front) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf("l_get_status: Loop to front disks not found.\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!found_rear) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf("l_get_status: Loop to rear disks not found.\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get path to all the FC disk and tape devices.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * I get this now and pass down for performance
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * reasons.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If for some reason the list can become invalid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * i.e. device being offlined, then the list
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * must be re-gotten.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err = g_get_wwn_list(&wwn_list, verbose)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (err); /* Failure */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte enc_type = l_get_enc_type(inq);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (found_front) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte front_flag = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0, count = 0; i < l_state->total_num_drv/2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte count++, i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (enc_type == DAK_ENC_TYPE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte G_DPRINTF(" l_get_status: Getting individual"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " State for disk in slot %d\n", count);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte G_DPRINTF(" l_get_status: Getting individual"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " State for front disk in slot %d\n", i);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err = l_get_individual_state(ses_path_front,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (struct l_disk_state_struct *)&l_state->drv_front[i],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &l_state->ib_tbl, front_flag, o_list,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wwn_list, verbose)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) l_free_box_list(&o_list);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_free_wwn_list(&wwn_list);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (err);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set to loop not accessable. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < l_state->total_num_drv/2; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte l_state->drv_front[i].l_state_flag = L_NO_LOOP;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * For Daktari's, disk 0-5 information are located in the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * l_state->drv_front array
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * For Daktari's, disk 6-11 information are located in the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * l_state->drv_rear array
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * For this reason, on daktari's, I ignore the found_front and
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * found_rear flags and check both the drv_front and drv_rear
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (enc_type == DAK_ENC_TYPE && found_front) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte front_flag = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < l_state->total_num_drv/2; i++, count++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte G_DPRINTF(" l_get_status: Getting individual"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " State for disk in slot %d\n", count);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err = l_get_individual_state(ses_path_front,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (struct l_disk_state_struct *)&l_state->drv_rear[i],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &l_state->ib_tbl, front_flag, o_list,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wwn_list, verbose)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) l_free_box_list(&o_list);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_free_wwn_list(&wwn_list);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (err);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (enc_type != DAK_ENC_TYPE && found_rear) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < l_state->total_num_drv/2; i++, count++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte G_DPRINTF(" l_get_status: Getting individual"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " State for rear disk in slot %d\n", i);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err = l_get_individual_state(ses_path_rear,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (struct l_disk_state_struct *)&l_state->drv_rear[i],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &l_state->ib_tbl, front_flag, o_list,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wwn_list, verbose)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) l_free_box_list(&o_list);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_free_wwn_list(&wwn_list);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (err);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (enc_type != DAK_ENC_TYPE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set to loop not accessable. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < l_state->total_num_drv/2; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte l_state->drv_rear[i].l_state_flag = L_NO_LOOP;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) l_free_box_list(&o_list);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_free_wwn_list(&wwn_list);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (getenv("_LUX_T_DEBUG") != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte end_time = gethrtime();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, " l_get_status: "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Time = %lld millisec\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (end_time - start_time)/1000000);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check the SENA file for validity:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * - verify the size is that of 3 proms worth of text.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * - verify PROM_MAGIC.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * - verify (and print) the date.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * - verify the checksum.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * - verify the WWN == 0.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Since this requires reading the entire file, do it now and pass a pointer
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * to the allocated buffer back to the calling routine (which is responsible
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * for freeing it). If the buffer is not allocated it will be NULL.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * RETURNS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 0 O.K.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * non-zero otherwise
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortecheck_file(int fd, int verbose, uchar_t **buf_ptr, int dl_info_offset)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestruct exec the_exec;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint temp, i, j, *p, size, *start;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteuchar_t *buf;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortechar *date_str;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestruct dl_info *dl_info;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *buf_ptr = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* read exec header */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (lseek(fd, 0, SEEK_SET) == -1)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (errno);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((temp = read(fd, (char *)&the_exec, sizeof (the_exec))) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_DWNLD_READ_HEADER_FAIL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (temp != sizeof (the_exec)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_DWNLD_READ_INCORRECT_BYTES);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (the_exec.a_text != PROMSIZE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_DWNLD_INVALID_TEXT_SIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!(buf = (uchar_t *)g_zalloc(PROMSIZE)))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_MALLOC_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((temp = read(fd, buf, PROMSIZE)) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_DWNLD_READ_ERROR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (temp != PROMSIZE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_DWNLD_READ_INCORRECT_BYTES);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* check the IB firmware MAGIC */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dl_info = (struct dl_info *)(unsigned long)(buf + dl_info_offset);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (dl_info->magic != PROM_MAGIC) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_DWNLD_BAD_FRMWARE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get the date
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte date_str = ctime(&dl_info->datecode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (verbose) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(9050, " IB Prom Date: %s"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte date_str);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * verify checksum
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (dl_info_offset == FPM_DL_INFO) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte start = (int *)(long)(buf + FPM_OFFSET);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size = FPM_SZ;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte start = (int *)(long)buf;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size = TEXT_SZ + IDATA_SZ;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (j = 0, p = start, i = 0; i < (size/ 4); i++, j ^= *p++);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (j != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_DWNLD_CHKSUM_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* file verified */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *buf_ptr = buf;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check the DPM file for validity:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * RETURNS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 0 O.K.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * non-zero otherwise
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define dakstring "64616B74617269"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define dakoffs "BFC00000"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortecheck_dpm_file(int fd)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct s3hdr {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char rtype[2];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char rlen[2];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char data[255];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } theRec;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int nread;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int reclen;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (fd < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_DWNLD_READ_ERROR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lseek(fd, 0, SEEK_SET);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* First record */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte memset((void*)&theRec, 0, sizeof (struct s3hdr));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nread = read(fd, (void *)&theRec, 4);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (nread != 4) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* error reading first record/length */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_DWNLD_READ_ERROR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strncmp((char *)&theRec.rtype[0], "S0", 2) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* error in first record type */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_DWNLD_READ_HEADER_FAIL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte reclen = strtol(&theRec.rlen[0], (char **)NULL, 16);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (reclen == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* error in length == 0 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_DWNLD_READ_HEADER_FAIL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nread = read(fd, (void *)&theRec.data[0], ((reclen*2) +1));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (nread != ((reclen*2) +1)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* error in trying to read data */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_DWNLD_READ_HEADER_FAIL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strncmp(&theRec.data[4], dakstring, 14) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* error in compiled file name */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_DWNLD_READ_HEADER_FAIL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Second record */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte memset((void*)&theRec, 0, sizeof (struct s3hdr));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nread = read(fd, (void *)&theRec, 4);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (nread != 4) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* error reading second record/length */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_DWNLD_READ_ERROR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strncmp((char *)&theRec.rtype[0], "S3", 2) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* error in second record type */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_DWNLD_READ_HEADER_FAIL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte reclen = strtol(&theRec.rlen[0], (char **)NULL, 16);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (reclen == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* error in length == 0 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_DWNLD_READ_HEADER_FAIL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nread = read(fd, (void *)&theRec.data[0], ((reclen*2) +1));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (nread != ((reclen*2) +1)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* error in trying to read data */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_DWNLD_READ_HEADER_FAIL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strncmp(&theRec.data[0], dakoffs, 8) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* error in SSC100 offset pointer */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_DWNLD_READ_HEADER_FAIL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lseek(fd, 0, SEEK_SET);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortel_check_file(char *file, int verbose)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint file_fd;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint err;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteuchar_t *buf;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((file_fd = g_object_open(file, O_RDONLY)) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_OPEN_PATH_FAIL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte err = check_file(file_fd, verbose, &buf, FW_DL_INFO);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (buf)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_destroy_data((char *)buf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (err);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Write buffer command set up to download
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * firmware to the Photon IB.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * RETURNS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * status
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteib_download_code_cmd(int fd, int promid, int off, uchar_t *buf_ptr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int buf_len, int sp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint status, sz;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (buf_len) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sz = MIN(256, buf_len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte buf_len -= sz;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = g_scsi_writebuffer_cmd(fd, off, buf_ptr, sz,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (sp) ? 3 : 2, promid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte buf_ptr += sz;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte off += sz;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Downloads the code to the DAKTARI/DPM with the hdr set correctly
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Inputs:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fd - int for the file descriptor
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * buf_ptr - uchar_t pointer to the firmware itself
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * buf_len - int for the length of the data
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * status: 0 indicates success, != 0 failure, returned from writebuffer
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortedak_download_code_cmd(int fd, uchar_t *buf_ptr, int buf_len)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int status = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int sz = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int offs = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (buf_len > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sz = MIN(256, buf_len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte buf_len -= sz;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = g_scsi_writebuffer_cmd(fd, offs, buf_ptr, sz, 0x07, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte buf_ptr += sz;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte offs += sz;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Downloads the new prom image to IB.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * INPUTS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * path - physical path of Photon SES card
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * file - input file for new code (may be NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ps - whether the "save" bit should be set
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * verbose - to be verbose or not
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * RETURNS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 0 O.K.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * non-zero otherwise
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortel_download(char *path_phys, char *file, int ps, int verbose)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint file_fd, controller_fd;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint err, status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteuchar_t *buf_ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortechar printbuf[MAXPATHLEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint retry;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortechar file_path[MAXPATHLEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestruct stat statbuf;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint enc_type;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteL_inquiry inq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (path_phys == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_INVALID_PATH_FORMAT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!file) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcpy(file_path, IBFIRMWARE_FILE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(file_path, file, sizeof (file_path));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (verbose)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "%s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(9051, " Opening the IB for I/O."));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((controller_fd = g_object_open(path_phys, O_NDELAY | O_RDWR)) == -1)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_OPEN_PATH_FAIL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(printbuf, MSGSTR(9052, " Doing download to:"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "\n\t%s.\n From file: %s."), path_phys, file_path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (verbose)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "%s\n", printbuf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte P_DPRINTF(" Doing download to:"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "\n\t%s\n From file: %s\n", path_phys, file_path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((file_fd = g_object_open(file_path, O_NDELAY | O_RDONLY)) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Return a different error code here to differentiate between
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * this failure in g_object_open() and the one above.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_INVALID_PATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (g_scsi_inquiry_cmd(controller_fd, (uchar_t *)&inq, sizeof (inq))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_SCSI_ERROR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte enc_type = l_get_enc_type(inq);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (enc_type) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DAK_ENC_TYPE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * We don't have a default daktari file location, so
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the user must specify the firmware file on the command line
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!file) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_REQUIRE_FILE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Validate the file */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((err = check_dpm_file(file_fd))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (err);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Now go ahead and load up the data */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (fstat(file_fd, &statbuf) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte err = errno;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "%s %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(9101, " Stat'ing the F/W file:"), strerror(err));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_OPEN_PATH_FAIL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte buf_ptr = (uchar_t *)g_zalloc(statbuf.st_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (buf_ptr == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte err = errno;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "%s %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(9102, " Cannot alloc mem to read F/W file:"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strerror(err));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_MALLOC_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (read(file_fd, buf_ptr, statbuf.st_size) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte err = errno;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "%s %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(9103, " Reading F/W file:"), strerror(err));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte g_destroy_data((char *)buf_ptr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_DWNLD_READ_ERROR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err = check_file(file_fd, verbose, &buf_ptr, FW_DL_INFO)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (buf_ptr) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_destroy_data((char *)buf_ptr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (err);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (verbose) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, " ");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, MSGSTR(127, "Checkfile O.K."));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte P_DPRINTF(" Checkfile OK.\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) close(file_fd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (verbose) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, MSGSTR(9053,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " Verifying the IB is available.\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte retry = DOWNLOAD_RETRIES;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (retry) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((status = g_scsi_tur(controller_fd)) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((retry % 30) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ER_DPRINTF(" Waiting for the IB to be"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " available.\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sleep(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!retry) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (buf_ptr)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_destroy_data((char *)buf_ptr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) close(controller_fd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (verbose)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "%s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(9054, " Writing new text image to IB."));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte P_DPRINTF(" Writing new image to IB\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (enc_type) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DAK_ENC_TYPE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = dak_download_code_cmd(controller_fd, buf_ptr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte statbuf.st_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (buf_ptr != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte g_destroy_data((char *)buf_ptr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) close(controller_fd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = ib_download_code_cmd(controller_fd, IBEEPROM, TEXT_OFFSET,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uchar_t *)(buf_ptr + TEXT_OFFSET), TEXT_SZ, ps);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) close(controller_fd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_destroy_data((char *)buf_ptr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (verbose) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "%s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(9055, " Writing new data image to IB."));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = ib_download_code_cmd(controller_fd, IBEEPROM, IDATA_OFFSET,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uchar_t *)(buf_ptr + IDATA_OFFSET), IDATA_SZ, ps);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) close(controller_fd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_destroy_data((char *)buf_ptr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (verbose) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, MSGSTR(9056,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " Re-verifying the IB is available.\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte retry = DOWNLOAD_RETRIES;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (retry) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((status = g_scsi_tur(controller_fd)) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((retry % 30) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ER_DPRINTF(" Waiting for the IB to be"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " available.\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sleep(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte retry--;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!retry) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) close(controller_fd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_destroy_data((char *)buf_ptr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_DWNLD_TIMED_OUT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (enc_type) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DAK_ENC_TYPE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (verbose) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "%s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(9057, " Writing new image to FPM."));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = ib_download_code_cmd(controller_fd, MBEEPROM, FPM_OFFSET,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uchar_t *)(buf_ptr + FPM_OFFSET), FPM_SZ, ps);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((!status) && ps) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Reset the IB
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = g_scsi_reset(controller_fd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) close(controller_fd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Set the World Wide Name
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * in page 4 of the Send Diagnostic command.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Is it allowed to change the wwn ???
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The path must point to an IB.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortel_set_wwn(char *path_phys, char *wwn)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortePage4_name page4;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteL_inquiry inq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint fd, status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortechar wwnp[WWN_SIZE];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memset(&inq, 0, sizeof (inq));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memset(&page4, 0, sizeof (page4));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((fd = g_object_open(path_phys, O_NDELAY | O_RDONLY)) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_OPEN_PATH_FAIL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Verify it is a Photon */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status = g_scsi_inquiry_cmd(fd,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uchar_t *)&inq, sizeof (struct l_inquiry_struct))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) close(fd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((strstr((char *)inq.inq_pid, ENCLOSURE_PROD_ID) == 0) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (!(strncmp((char *)inq.inq_vid, "SUN ",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (inq.inq_vid)) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((inq.inq_dtype & DTYPE_MASK) == DTYPE_ESI)))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) close(fd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_ENCL_INVALID_PATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte page4.page_code = L_PAGE_4;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte page4.page_len = (ushort_t)((sizeof (struct page4_name) - 4));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte page4.string_code = L_WWN;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte page4.enable = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (g_string_to_wwn((uchar_t *)wwn, (uchar_t *)&page4.name)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte close(fd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (EINVAL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy((void *)wwnp, (void *)page4.name, (size_t)WWN_SIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status = g_scsi_send_diag_cmd(fd, (uchar_t *)&page4,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (page4))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) close(fd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check the wwn really changed.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero((char *)page4.name, 32);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status = g_scsi_rec_diag_cmd(fd, (uchar_t *)&page4,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (page4), L_PAGE_4)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) close(fd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (bcmp((char *)page4.name, wwnp, WWN_SIZE)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) close(fd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_WARNING);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) close(fd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use a physical path to a disk in a Photon box
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * as the base to genererate a path to a SES
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * card in this box.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * path_phys: Physical path to a Photon disk.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ses_path: This must be a pointer to an already allocated path string.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * RETURNS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 0 O.K.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * non-zero otherwise
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortel_get_ses_path(char *path_phys, char *ses_path, gfc_map_t *map,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int verbose)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortechar *char_ptr, id_buf[MAXPATHLEN], wwn[20];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteuchar_t t_wwn[20], *ses_wwn, *ses_wwn1, *ses_nwwn;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint j, al_pa, al_pa1, box_id, fd, disk_flag = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint err, found = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortegfc_port_dev_info_t *dev_addr_ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((path_phys == NULL) || (ses_path == NULL) || (map == NULL)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_NO_SES_PATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcpy(ses_path, path_phys);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((char_ptr = strrchr(ses_path, '/')) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_INVLD_PATH_NO_SLASH_FND);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte disk_flag++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *char_ptr = '\0'; /* Terminate sting */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcat(ses_path, SLSH_SES_NAME);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Figure out and create the boxes pathname.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * NOTE: This uses the fact that the disks's
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * AL_PA and the boxes AL_PA must match
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the assigned hard address in the current
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * implementations. This may not be true in the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * future.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((char_ptr = strrchr(path_phys, '@')) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_INVLD_PATH_NO_ATSIGN_FND);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char_ptr++; /* point to the loop identifier */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((err = g_get_wwn(path_phys, t_wwn, t_wwn,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &al_pa, verbose)) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (err);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte box_id = g_sf_alpa_to_switch[al_pa & 0xFF] & BOX_ID_MASK;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (map->hba_addr.port_topology) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FC_TOP_PRIVATE_LOOP:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (j = 0, dev_addr_ptr = map->dev_addr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte j < map->count; j++, dev_addr_ptr++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (dev_addr_ptr->gfc_port_dev.priv_port.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sf_inq_dtype == DTYPE_ESI) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte al_pa1 = dev_addr_ptr->gfc_port_dev.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte priv_port.sf_al_pa;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (box_id == (g_sf_alpa_to_switch[al_pa1] &
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte BOX_ID_MASK)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!found) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ses_wwn = dev_addr_ptr->
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gfc_port_dev.priv_port.sf_port_wwn;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ses_nwwn = dev_addr_ptr->
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gfc_port_dev.priv_port.sf_node_wwn;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (getenv("_LUX_P_DEBUG")) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_ll_to_str(ses_wwn,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (char *)t_wwn);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " l_get_ses_path: "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Found ses wwn = %s "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "al_pa 0x%x\n", t_wwn, al_pa1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ses_wwn1 = dev_addr_ptr->
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gfc_port_dev.priv_port.sf_port_wwn;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (getenv("_LUX_P_DEBUG")) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_ll_to_str(ses_wwn1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (char *)t_wwn);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " l_get_ses_path: "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Found second ses " "wwn = %s "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "al_pa 0x%x\n", t_wwn, al_pa1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte found++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FC_TOP_FABRIC:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FC_TOP_PUBLIC_LOOP:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (j = 0, dev_addr_ptr = map->dev_addr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte j < map->count; j++, dev_addr_ptr++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (dev_addr_ptr->gfc_port_dev.pub_port.dev_dtype ==
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DTYPE_ESI) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * We found an enclosure, lets match the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * area and domain codes for this enclosure with
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * that of the ses path since there may be
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * multiple enclosures with same box id on a
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fabric
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte al_pa1 = dev_addr_ptr->gfc_port_dev.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pub_port.dev_did.port_id;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((al_pa & AREA_DOMAIN_ID) ==
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (al_pa1 & AREA_DOMAIN_ID)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The area and domain matched. Now, we
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * match the box id of the disk with
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * this enclosure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (box_id ==
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (g_sf_alpa_to_switch[al_pa1 &
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0xFF] & BOX_ID_MASK)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!found) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ses_wwn = dev_addr_ptr->
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gfc_port_dev.pub_port.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dev_pwwn.raw_wwn;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ses_nwwn = dev_addr_ptr->
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gfc_port_dev.pub_port.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dev_nwwn.raw_wwn;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (getenv("_LUX_P_DEBUG")) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_ll_to_str(ses_wwn,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (char *)t_wwn);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " l_get_ses_path: "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Found ses wwn = %s "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "al_pa 0x%x\n", t_wwn,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte al_pa1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ses_wwn1 = dev_addr_ptr->
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gfc_port_dev.pub_port.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dev_pwwn.raw_wwn;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (getenv("_LUX_P_DEBUG")) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_ll_to_str(ses_wwn1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (char *)t_wwn);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " l_get_ses_path: "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Found second ses "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "wwn = %s "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "al_pa 0x%x\n", t_wwn,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte al_pa1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte found++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FC_TOP_PT_PT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_PT_PT_FC_TOP_NOT_SUPPORTED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_UNEXPECTED_FC_TOPOLOGY);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } /* End of switch on port_topology */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!found) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_NO_SES_PATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strstr(path_phys, SCSI_VHCI) != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_ll_to_str(ses_nwwn, wwn);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(id_buf, "g%s:0", wwn);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_ll_to_str(ses_wwn, wwn);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(id_buf, "w%s,0:0", wwn);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcat(ses_path, id_buf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (verbose) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(9058, " Creating enclosure path:\n %s\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ses_path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * see if these paths exist.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((fd = g_object_open(ses_path, O_NDELAY | O_RDONLY)) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strstr(path_phys, SCSI_VHCI) != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_INVALID_PATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char_ptr = strrchr(ses_path, '/');
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *char_ptr = '\0';
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcat(ses_path, SLSH_SES_NAME);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (found > 1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_ll_to_str(ses_wwn1, wwn);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte P_DPRINTF(" l_get_ses_path: "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Using second path, ses wwn1 = %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wwn);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(id_buf, "w%s,0:0", wwn);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strcat(ses_path, id_buf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_NO_SES_PATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte close(fd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get a valid location, front/rear & slot.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * path_struct->p_physical_path must be of a disk.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * OUTPUT: path_struct->slot_valid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * path_struct->slot
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * path_struct->f_flag
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * RETURN:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 0 O.K.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * non-zero otherwise
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortel_get_slot(struct path_struct *path_struct, L_state *l_state, int verbose)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint err, al_pa, slot, found = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteuchar_t node_wwn[WWN_SIZE], port_wwn[WWN_SIZE];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteuint_t select_id;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((path_struct == NULL) || (l_state == NULL)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_INVALID_PATH_FORMAT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Double check to see if we need to calculate. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (path_struct->slot_valid)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Programming error if this occures */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte assert(path_struct->ib_path_flag == 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strstr(path_struct->p_physical_path, "ssd") == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_INVLD_PHYS_PATH_TO_DISK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err = g_get_wwn(path_struct->p_physical_path, port_wwn, node_wwn,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &al_pa, verbose)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (err);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Find the slot by searching for the matching hard address.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Take only the low order byte ignoring area and domain code in
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fabric devices' 24 bit al_pa
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte select_id = g_sf_alpa_to_switch[al_pa & 0xFF];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte P_DPRINTF(" l_get_slot: Searching Receive Diagnostic page 2, "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "to find the slot number with this ID:0x%x\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte select_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (slot = 0; slot < l_state->total_num_drv/2; slot++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (l_state->drv_front[slot].ib_status.sel_id ==
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte select_id) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte path_struct->f_flag = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte found = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (l_state->drv_rear[slot].ib_status.sel_id ==
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte select_id) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte path_struct->f_flag = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte found = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!found) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_INVALID_SLOT); /* Failure */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((strncmp((char *)l_state->ib_tbl.config.prod_id, DAK_OFF_NAME,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strlen(DAK_OFF_NAME)) == 0) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (strncmp((char *)l_state->ib_tbl.config.prod_id, DAK_PROD_STR,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strlen(DAK_OFF_NAME)) == 0)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte P_DPRINTF(" l_get_slot: Found slot %d.\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte path_struct->f_flag ? slot : slot + (MAX_DRIVES_DAK/2));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte P_DPRINTF(" l_get_slot: Found slot %d %s.\n", slot,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte path_struct->f_flag ? "Front" : "Rear");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte path_struct->slot = slot;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte path_struct->slot_valid = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortel_element_msg_string(uchar_t code, char *es)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (code == S_OK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(es, MSGSTR(29, "O.K."));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (code == S_NOT_AVAILABLE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(es, MSGSTR(34, "Disabled"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (code == S_NOT_INSTALLED) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(es, MSGSTR(30, "Not Installed"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (code == S_NONCRITICAL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(es, MSGSTR(9059, "Noncritical failure"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (code == S_CRITICAL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(es, MSGSTR(122, "Critical failure"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(es, MSGSTR(4, "Unknown status"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get all ses paths paths to a given box.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The arg should be the physical path to one of the box's IB.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * NOTE: The caller must free the allocated lists.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * OUTPUT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * a pointer to a list of ses paths if found
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * NULL on error.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * RETURNS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 0 if O.K.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * non-zero otherwise
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortel_get_allses(char *path, struct box_list_struct *box_list,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct dlist **ses_list, int verbose)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestruct box_list_struct *box_list_ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortechar node_wwn_s[WWN_S_LEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestruct dlist *dlt, *dl;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((path == NULL) || (box_list == NULL) || (ses_list == NULL)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_INVALID_PATH_FORMAT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Initialize lists/arrays */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *ses_list = dlt = dl = (struct dlist *)NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte node_wwn_s[0] = '\0';
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte H_DPRINTF(" l_get_allses: Looking for all ses paths for"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " box at path: %s\n", path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (box_list_ptr = box_list; box_list_ptr != NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte box_list_ptr = box_list_ptr->box_next) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte H_DPRINTF(" l_get_allses: physical_path= %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte box_list_ptr->b_physical_path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp(path, box_list_ptr->b_physical_path) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcpy(node_wwn_s, box_list_ptr->b_node_wwn_s);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (node_wwn_s[0] == '\0') {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte H_DPRINTF("node_wwn_s is NULL!\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_NO_NODE_WWN_IN_BOXLIST);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte H_DPRINTF(" l_get_allses: node_wwn=%s\n", node_wwn_s);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (box_list_ptr = box_list; box_list_ptr != NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte box_list_ptr = box_list_ptr->box_next) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp(node_wwn_s, box_list_ptr->b_node_wwn_s) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((dl = (struct dlist *)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte g_zalloc(sizeof (struct dlist))) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (*ses_list != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dl = dlt->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_destroy_data(dlt);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dlt = dl;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_MALLOC_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte H_DPRINTF(" l_get_allses: Found ses=%s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte box_list_ptr->b_physical_path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dl->dev_path = strdup(box_list_ptr->b_physical_path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dl->logical_path = strdup(box_list_ptr->logical_path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*ses_list == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *ses_list = dlt = dl;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dlt->next = dl;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dl->prev = dlt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dlt = dl;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Routine to return the enclosure type pointed to by the path.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Inputs: The inquiry data for the device in question
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Return: >= 0 is the type:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Types are defined in storage/libg_fc/common/hdrs/g_state.h:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 0 -> default (SENA)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 1 -> Daktari
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 2 -> Other Enclosures
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortel_get_enc_type(L_inquiry inq)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strncmp((char *)&inq.inq_pid[0], ENCLOSURE_PROD_ID,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strlen(ENCLOSURE_PROD_ID)) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (SENA_ENC_TYPE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strncmp((char *)&inq.inq_pid[0], DAK_OFF_NAME,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strlen(DAK_OFF_NAME)) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DAK_ENC_TYPE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strncmp((char *)&inq.inq_pid[0], DAK_PROD_STR,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strlen(DAK_PROD_STR)) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DAK_ENC_TYPE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ADD OTHERS here if ever needed/wanted, and add to def's
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * as noted above
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (UNDEF_ENC_TYPE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefree_mp_dev_map(gfc_map_mp_t **map_mp_ptr) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gfc_map_mp_t *next = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (; *map_mp_ptr != NULL; *map_mp_ptr = next) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte next = (*map_mp_ptr)->map_next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_destroy_data((*map_mp_ptr)->map.dev_addr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_destroy_data(*map_mp_ptr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *map_mp_ptr = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This function will return a linked list of device maps
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * An example of when this will be used is when we want to return the device
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * map of a vhci path.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteget_mp_dev_map(char *path, gfc_map_mp_t **map_mp_ptr, int verbose) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int pathcnt, i, err;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mp_pathlist_t pathlist;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gfc_map_mp_t *new_map_mp_ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char drvr_path[MAXPATHLEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strstr(path, SCSI_VHCI)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (g_get_pathlist(path, &pathlist)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_INVALID_PATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pathcnt = pathlist.path_count;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < pathcnt; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pathlist.path_info[i].path_state < MAXPATHSTATE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * only pay attention to paths that are either
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ONLINE or STANDBY
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((pathlist.path_info[i].path_state ==
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MDI_PATHINFO_STATE_ONLINE) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (pathlist.path_info[i].path_state ==
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MDI_PATHINFO_STATE_STANDBY)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((new_map_mp_ptr = (gfc_map_mp_t *)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte g_zalloc(sizeof (gfc_map_mp_t)))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(pathlist.path_info);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free_mp_dev_map(map_mp_ptr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_MALLOC_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcpy(drvr_path,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pathlist.path_info[i].path_hba);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcat(drvr_path, FC_CTLR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err = g_get_dev_map(drvr_path,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &(new_map_mp_ptr->map),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte verbose)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(pathlist.path_info);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free_mp_dev_map(map_mp_ptr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (err);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* add newly created map onto list */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*map_mp_ptr == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte new_map_mp_ptr->map_next = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *map_mp_ptr = new_map_mp_ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte new_map_mp_ptr->map_next =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *map_mp_ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *map_mp_ptr = new_map_mp_ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(pathlist.path_info);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((new_map_mp_ptr = (gfc_map_mp_t *)g_zalloc
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (sizeof (gfc_map_mp_t))) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (L_MALLOC_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte g_get_dev_map(path, &(new_map_mp_ptr->map), verbose);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *map_mp_ptr = new_map_mp_ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}