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
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <hbaapi.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <stdio.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <unistd.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <stdlib.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/param.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/types.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/stat.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <string.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <strings.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <ctype.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/scsi/generic/sense.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/scsi/generic/mode.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/scsi/generic/inquiry.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <errno.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <libdevice.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <config_admin.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/byteorder.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/fibre-channel/fcio.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "common.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "sun_fc_version.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define DEFAULT_LUN_COUNT 1024
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define LUN_SIZE 8
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define LUN_HEADER_SIZE 8
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define DEFAULT_LUN_LENGTH DEFAULT_LUN_COUNT * \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LUN_SIZE + \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LUN_HEADER_SIZE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestruct lun_val {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uchar_t val[8];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestruct rep_luns_rsp {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t length;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t rsrvd;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct lun_val lun[1];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Extracted from the old scsi.h file */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestruct capacity_data_struct {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint_t last_block_addr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint_t block_size;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Structure to handle the inq. page 0x80 serial number */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestruct page80 {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uchar_t inq_dtype;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uchar_t inq_page_code;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uchar_t reserved;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uchar_t inq_page_len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uchar_t inq_serial[251];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern char *dtype[];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int Options;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern const int OPTION_P;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint skip_hba(int i);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint find_supported_inq_page(HBA_HANDLE handle, HBA_WWN hwwn, HBA_WWN pwwn,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint64_t lun, int page_num);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The routines within this file operate against the T11
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * HBA API interface. In some cases, proprietary Sun driver
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * interface are also called to add additional information
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * above what the standard library supports.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteuint64_t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortewwnConversion(uchar_t *wwn) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint64_t tmp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memcpy(&tmp, wwn, sizeof (uint64_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ntohll(tmp));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid printStatus(HBA_STATUS status) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (status) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case HBA_STATUS_OK:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printf(MSGSTR(2410, "OK"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case HBA_STATUS_ERROR:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printf(MSGSTR(2411, "ERROR"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case HBA_STATUS_ERROR_NOT_SUPPORTED:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printf(MSGSTR(2412, "NOT SUPPORTED"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case HBA_STATUS_ERROR_INVALID_HANDLE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printf(MSGSTR(2413, "INVALID HANDLE"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case HBA_STATUS_ERROR_ARG:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printf(MSGSTR(2414, "ERROR ARG"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case HBA_STATUS_ERROR_ILLEGAL_WWN:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printf(MSGSTR(2415, "ILLEGAL WWN"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case HBA_STATUS_ERROR_ILLEGAL_INDEX:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printf(MSGSTR(2416, "ILLEGAL INDEX"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case HBA_STATUS_ERROR_MORE_DATA:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printf(MSGSTR(2417, "MORE DATA"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case HBA_STATUS_ERROR_STALE_DATA:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printf(MSGSTR(2418, "STALE DATA"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case HBA_STATUS_SCSI_CHECK_CONDITION:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printf(MSGSTR(2419, "SCSI CHECK CONDITION"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case HBA_STATUS_ERROR_BUSY:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printf(MSGSTR(2420, "BUSY"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case HBA_STATUS_ERROR_TRY_AGAIN:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printf(MSGSTR(2421, "TRY AGAIN"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case HBA_STATUS_ERROR_UNAVAILABLE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printf(MSGSTR(2422, "UNAVAILABLE"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printf(MSGSTR(2423, "UNKNOWN ERROR TYPE %d"), status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteuint32_t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortegetNumberOfAdapters() {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t count = HBA_GetNumberOfAdapters();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (count == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stderr, MSGSTR(2405,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "\nERROR: No Fibre Channel Adapters found.\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (count);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define MAX_RETRIES 10
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns non-zero on failure (aka, HBA_STATUS_ERROR_*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Will handle retries if applicable.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortegetAdapterAttrs(HBA_HANDLE handle, char *name, HBA_ADAPTERATTRIBUTES *attrs) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int count = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_STATUS status = HBA_STATUS_ERROR_TRY_AGAIN; /* force first pass */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Loop as long as we have a retryable error */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while ((status == HBA_STATUS_ERROR_TRY_AGAIN ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status == HBA_STATUS_ERROR_BUSY) && count++ < MAX_RETRIES) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = HBA_GetAdapterAttributes(handle, attrs);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status == HBA_STATUS_OK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sleep(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status != HBA_STATUS_OK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* We encountered a non-retryable error */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stderr, MSGSTR(2501,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "\nERROR: Unable to retrieve adapter port details (%s)"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte name);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printStatus(status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stderr, "\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns non-zero on failure (aka, HBA_STATUS_ERROR_*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Will handle retries if applicable.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortegetAdapterPortAttrs(HBA_HANDLE handle, char *name, int portIndex,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_PORTATTRIBUTES *attrs) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int count = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_STATUS status = HBA_STATUS_ERROR_TRY_AGAIN; /* force first pass */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Loop as long as we have a retryable error */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while ((status == HBA_STATUS_ERROR_TRY_AGAIN ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status == HBA_STATUS_ERROR_BUSY) && count++ < MAX_RETRIES) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = HBA_GetAdapterPortAttributes(handle, portIndex, attrs);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status == HBA_STATUS_OK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* The odds of this occuring are very slim, but possible. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status == HBA_STATUS_ERROR_STALE_DATA) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If we hit a stale data scenario,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * we'll just tell the user to try again.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = HBA_STATUS_ERROR_TRY_AGAIN;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sleep(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status != HBA_STATUS_OK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* We encountered a non-retryable error */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stderr, MSGSTR(2501,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "\nERROR: Unable to retrieve adapter port details (%s)"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte name);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printStatus(status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stderr, "\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns non-zero on failure (aka, HBA_STATUS_ERROR_*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Will handle retries if applicable.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortegetDiscPortAttrs(HBA_HANDLE handle, char *name, int portIndex, int discIndex,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_PORTATTRIBUTES *attrs) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int count = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_STATUS status = HBA_STATUS_ERROR_TRY_AGAIN; /* force first pass */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Loop as long as we have a retryable error */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while ((status == HBA_STATUS_ERROR_TRY_AGAIN ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status == HBA_STATUS_ERROR_BUSY) && count++ < MAX_RETRIES) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = HBA_GetDiscoveredPortAttributes(handle, portIndex,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte discIndex, attrs);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status == HBA_STATUS_OK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* The odds of this occuring are very slim, but possible. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status == HBA_STATUS_ERROR_STALE_DATA) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If we hit a stale data scenario, we'll just tell the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * user to try again.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = HBA_STATUS_ERROR_TRY_AGAIN;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sleep(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status != HBA_STATUS_OK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* We encountered a non-retryable error */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stderr, MSGSTR(2504,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "\nERROR: Unable to retrieve target port details (%s)"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte name);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printStatus(status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stderr, "\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*ARGSUSED*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefchba_display_port(int verbose)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int retval = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE handle;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_ADAPTERATTRIBUTES hbaAttrs;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_PORTATTRIBUTES portAttrs;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int count, adapterIndex, portIndex;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char name[256];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *physical = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char path[MAXPATHLEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((retval = loadLibrary())) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (retval);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte count = getNumberOfAdapters();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (adapterIndex = 0; adapterIndex < count; adapterIndex ++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (skip_hba(adapterIndex)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = HBA_GetAdapterName(adapterIndex, (char *)&name);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status != HBA_STATUS_OK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Just skip it, maybe it was DR'd */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte handle = HBA_OpenAdapter(name);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (handle == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Just skip it, maybe it was DR'd */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (getAdapterAttrs(handle, name, &hbaAttrs)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* This should never happen, we'll just skip the adapter */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_CloseAdapter(handle);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (portIndex = 0; portIndex < hbaAttrs.NumberOfPorts;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte portIndex++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (getAdapterPortAttrs(handle, name, portIndex,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &portAttrs)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte physical = get_slash_devices_from_osDevName(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte portAttrs.OSDeviceName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte STANDARD_DEVNAME_HANDLING);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (physical) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *tmp = strstr(physical, ":fc");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (tmp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *tmp = '\0';
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(path, MAXPATHLEN, "%s:devctl",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte physical);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(path, MAXPATHLEN, "%s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte physical);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(physical);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte physical = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf("%-65s ", path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf("%-65s ", portAttrs.OSDeviceName);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (portAttrs.NumberofDiscoveredPorts > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printf(MSGSTR(2233, "CONNECTED\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printf(MSGSTR(2234, "NOT CONNECTED\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) HBA_FreeLibrary();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (retval);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Internal routines/structure to deal with a path list
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * so we can ensure uniqueness
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestruct path_entry {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char path[MAXPATHLEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT8 wwn[8];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uchar_t dtype;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct path_entry *next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid add_path(struct path_entry *head, struct path_entry *cur) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct path_entry *tmp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (tmp = head; tmp->next != NULL; tmp = tmp->next) { }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp->next = cur;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestruct path_entry *is_duplicate_path(struct path_entry *head, char *path) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct path_entry *tmp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (tmp = head; tmp != NULL; tmp = tmp->next) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strncmp(tmp->path, path, sizeof (tmp->path)) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (tmp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid free_path_list(struct path_entry *head) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct path_entry *tmp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct path_entry *tmp2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (tmp = head; tmp != NULL; ) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp2 = tmp->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(tmp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp = tmp2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteis_wwn(char *arg) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strlen(arg) == 16) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < 16; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!isxdigit(arg[i])) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteis_path(char *arg) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct stat buf;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (stat(arg, &buf)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* We take a wild guess for our first get target mappings call */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define MAP_GUESS 50
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_STATUS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefetch_mappings(HBA_HANDLE handle, HBA_WWN pwwn, HBA_FCPTARGETMAPPINGV2 **map) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int loop = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int count = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_STATUS status = HBA_STATUS_ERROR_TRY_AGAIN; /* force first pass */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *map = (HBA_FCPTARGETMAPPINGV2 *) calloc(1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (sizeof (HBA_FCPSCSIENTRYV2)* (MAP_GUESS-1)) +
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (HBA_FCPTARGETMAPPINGV2));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Loop as long as we have a retryable error */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while ((status == HBA_STATUS_ERROR_TRY_AGAIN ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status == HBA_STATUS_ERROR_BUSY ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status == HBA_STATUS_ERROR_MORE_DATA) && loop++ < MAX_RETRIES) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = HBA_GetFcpTargetMappingV2(handle, pwwn, *map);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status == HBA_STATUS_OK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (status == HBA_STATUS_ERROR_MORE_DATA) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte count = (*map)->NumberOfEntries;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(*map);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *map = (HBA_FCPTARGETMAPPINGV2 *) calloc(1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (sizeof (HBA_FCPSCSIENTRYV2)* (count-1)) +
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (HBA_FCPTARGETMAPPINGV2));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (*map)->NumberOfEntries = count;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sleep(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status != HBA_STATUS_OK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* We encountered a non-retryable error */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stderr, MSGSTR(2502,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "\nERROR: Unable to retrieve SCSI device paths "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "(HBA Port WWN %016llx)"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wwnConversion(pwwn.wwn));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printStatus(status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stderr, "\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns the index of the first match, or -1 if no match
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortematch_mappings(char *compare, HBA_FCPTARGETMAPPINGV2 *map) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int mapIndex;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *physical = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *tmp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int wwnCompare = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint64_t wwn;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (map == NULL || compare == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (is_wwn(compare)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wwnCompare = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sscanf(compare, "%016llx", &wwn);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Convert the paths to phsyical paths */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte physical = get_slash_devices_from_osDevName(compare,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte STANDARD_DEVNAME_HANDLING);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (mapIndex = 0; mapIndex < map->NumberOfEntries; mapIndex ++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (wwnCompare) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (wwn == wwnConversion(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte map->entry[mapIndex].FcpId.NodeWWN.wwn) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wwn == wwnConversion(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte map->entry[mapIndex].FcpId.PortWWN.wwn)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (mapIndex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (physical != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp = get_slash_devices_from_osDevName(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte map->entry[mapIndex].ScsiId.OSDeviceName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte STANDARD_DEVNAME_HANDLING);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((tmp != NULL) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncmp(physical, tmp, MAXPATHLEN) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(physical);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (mapIndex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (physical) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(physical);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * returns non-zero on failure (aka HBA_STATUS_ERROR_*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteloadLibrary() {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int status = HBA_LoadLibrary();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status != HBA_STATUS_OK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stderr, MSGSTR(2505,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "ERROR: Unable to load HBA API library: "));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printStatus(status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stderr, "\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefchba_non_encl_probe() {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE handle;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_ADAPTERATTRIBUTES hbaAttrs;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_PORTATTRIBUTES portAttrs;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_FCPTARGETMAPPINGV2 *map;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int count, adapterIndex, portIndex, mapIndex;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char name[256];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct path_entry *head = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint64_t lun = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte L_inquiry inq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct scsi_extended_sense sense;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT8 scsiStatus;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t inquirySize = sizeof (inq), senseSize = sizeof (sense);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (loadLibrary()) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte count = getNumberOfAdapters();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Loop over all HBAs */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (adapterIndex = 0; adapterIndex < count; adapterIndex ++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (skip_hba(adapterIndex)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = HBA_GetAdapterName(adapterIndex, (char *)&name);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status != HBA_STATUS_OK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* May have been DR'd */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte handle = HBA_OpenAdapter(name);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (handle == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* May have been DR'd */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (getAdapterAttrs(handle, name, &hbaAttrs)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Should not happen, just skip it */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_CloseAdapter(handle);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Loop over all HBA Ports */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (portIndex = 0; portIndex < hbaAttrs.NumberOfPorts;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte portIndex++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (getAdapterPortAttrs(handle, name, portIndex,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &portAttrs)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (fetch_mappings(handle, portAttrs.PortWWN, &map)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Loop over all target Mapping entries */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (mapIndex = 0; mapIndex < map->NumberOfEntries;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mapIndex ++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct path_entry *tmpPath = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int doInquiry = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!head) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte head = (struct path_entry *)calloc(1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (struct path_entry));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmpPath = head;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(head->path,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte map->entry[mapIndex].ScsiId.OSDeviceName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (map->entry[mapIndex].ScsiId.OSDeviceName));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memcpy(tmpPath->wwn,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte map->entry[mapIndex].FcpId.NodeWWN.wwn,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (HBA_UINT8) * 8);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte doInquiry = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (tmpPath = is_duplicate_path(head,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte map->entry[mapIndex].ScsiId.OSDeviceName)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (tmpPath->dtype != 0x1f) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte doInquiry = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte doInquiry = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmpPath = (struct path_entry *)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte calloc(1, sizeof (struct path_entry));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(tmpPath->path,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte map->entry[mapIndex].ScsiId.OSDeviceName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (map->entry[mapIndex].ScsiId.OSDeviceName));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memcpy(tmpPath->wwn,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte map->entry[mapIndex].FcpId.NodeWWN.wwn,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (HBA_UINT8) * 8);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte add_path(head, tmpPath);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte doInquiry = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (doInquiry) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lun = map->entry[mapIndex].FcpId.FcpLun;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte memset(&inq, 0, sizeof (inq));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte memset(&sense, 0, sizeof (sense));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = HBA_ScsiInquiryV2(handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte portAttrs.PortWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte map->entry[mapIndex].FcpId.PortWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lun, 0, 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &inq, &inquirySize,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &scsiStatus,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &sense, &senseSize);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status != HBA_STATUS_OK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte inq.inq_dtype = 0x1f;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmpPath->dtype = inq.inq_dtype;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (head) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct path_entry *tmp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printf(MSGSTR(2098, "\nFound Fibre Channel device(s):\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (tmp = head; tmp != NULL; tmp = tmp->next) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printf(" ");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printf(MSGSTR(90, "Node WWN:"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printf("%016llx ", wwnConversion(tmp->wwn));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stdout, MSGSTR(35, "Device Type:"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fflush(stdout);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((tmp->dtype & DTYPE_MASK) < 0x10) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stdout, "%s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dtype[tmp->dtype & DTYPE_MASK]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if ((tmp->dtype & DTYPE_MASK) < 0x1f) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stdout, MSGSTR(2406,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Reserved"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stdout, MSGSTR(2407,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Unknown"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printf("\n ");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printf(MSGSTR(31, "Logical Path:%s"), tmp->path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printf("\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* We probably shouldn't be using a g_fc interface here */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (Options & OPTION_P) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *phys_path =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte get_slash_devices_from_osDevName(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp->path,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte STANDARD_DEVNAME_HANDLING);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (phys_path != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stdout, " ");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stdout, MSGSTR(5, "Physical Path:"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stdout, "\n %s\n", phys_path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(phys_path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free_path_list(head);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_FreeLibrary();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefchba_inquiry(char **argv)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int path_index = 0, found = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint64_t wwn;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint64_t lun = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE handle;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_ADAPTERATTRIBUTES hbaAttrs;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_PORTATTRIBUTES portAttrs;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_FCPTARGETMAPPINGV2 *map;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int count, adapterIndex, portIndex, mapIndex;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char name[256];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte L_inquiry inq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct page80 serial;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t serialSize = sizeof (serial);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct scsi_extended_sense sense;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT8 scsiStatus;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t inquirySize = sizeof (inq), senseSize = sizeof (sense);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte boolean_t goodPath = B_FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int matched = 0, wwnCompare = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *tmp, *physical = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ret = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (loadLibrary()) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (path_index = 0; argv[path_index] != NULL; path_index++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goodPath = B_FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte found = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (is_wwn(argv[path_index])) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sscanf(argv[path_index], "%016llx", &wwn);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wwnCompare = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (!is_path(argv[path_index])) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stderr, MSGSTR(112, "Error: Invalid pathname (%s)"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte argv[path_index]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stderr, "\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = -1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!wwnCompare) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Convert the paths to phsyical paths */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte physical = get_slash_devices_from_osDevName(argv[path_index],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte STANDARD_DEVNAME_HANDLING);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!physical) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stderr, MSGSTR(112,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Error: Invalid pathname (%s)"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte argv[path_index]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stderr, "\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = -1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte count = getNumberOfAdapters();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Loop over all HBAs */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (adapterIndex = 0; adapterIndex < count; adapterIndex ++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (skip_hba(adapterIndex)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = HBA_GetAdapterName(adapterIndex, (char *)&name);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status != HBA_STATUS_OK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* May have been DR'd */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte handle = HBA_OpenAdapter(name);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (handle == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* May have been DR'd */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (getAdapterAttrs(handle, name, &hbaAttrs)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Should never happen */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_CloseAdapter(handle);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Loop over all HBA Ports */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (portIndex = 0; portIndex < hbaAttrs.NumberOfPorts;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte portIndex++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (getAdapterPortAttrs(handle, name, portIndex,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &portAttrs)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (fetch_mappings(handle, portAttrs.PortWWN, &map)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (mapIndex = 0; mapIndex < map->NumberOfEntries;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mapIndex ++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte matched = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (wwnCompare) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (wwn == wwnConversion(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte map->entry[mapIndex].FcpId.NodeWWN.wwn) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wwn == wwnConversion(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte map->entry[mapIndex].FcpId.PortWWN.wwn)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lun = map->entry[mapIndex].FcpId.FcpLun;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte matched = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp = get_slash_devices_from_osDevName(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte map->entry[mapIndex].ScsiId.OSDeviceName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte STANDARD_DEVNAME_HANDLING);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((tmp != NULL) && (strncmp(physical, tmp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MAXPATHLEN) == 0)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lun = map->entry[mapIndex].FcpId.FcpLun;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte matched = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(tmp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (matched) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte memset(&inq, 0, sizeof (inq));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte memset(&sense, 0, sizeof (sense));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = HBA_ScsiInquiryV2(handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte portAttrs.PortWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte map->entry[mapIndex].FcpId.PortWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lun, 0, 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &inq, &inquirySize,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &scsiStatus,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &sense, &senseSize);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status == HBA_STATUS_OK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goodPath = B_TRUE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Call the inquiry cmd on page 0x80 only if
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the vendor supports page 0x80
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte memset(&serial, 0, sizeof (serial));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((find_supported_inq_page(handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte portAttrs.PortWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte map->entry[mapIndex].FcpId.PortWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lun, 0x80))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = HBA_ScsiInquiryV2(handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte portAttrs.PortWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte map->entry[mapIndex].FcpId.PortWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lun, 1, 0x80,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &serial, &serialSize,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &scsiStatus,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &sense, &senseSize);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status != HBA_STATUS_OK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (char *)serial.inq_serial,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Unavailable",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (serial.inq_serial));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy((char *)serial.inq_serial,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Unsupported",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (serial.inq_serial));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * we are adding serial number information
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * from 0x80. If length is less than 39,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * then we want to increase length to 52 to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * reflect the fact that we have serial number
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * information
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (inq.inq_len < 39) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte inq.inq_len = 52;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte print_inq_data(argv[path_index],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte map->entry[mapIndex].ScsiId.OSDeviceName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte inq, serial.inq_serial,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (serial.inq_serial));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (! wwnCompare) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte found = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stderr, MSGSTR(2430,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Error: I/O failure communicating with %s "),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte map->entry[mapIndex].ScsiId.OSDeviceName);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printStatus(status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stderr, "\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (found == 1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (found == 1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (physical) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(physical);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!goodPath) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stderr, MSGSTR(112, "Error: Invalid pathname (%s)"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte argv[path_index]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stderr, "\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = -1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefchba_dump_map(char **argv)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int path_index = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint64_t wwn;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint64_t lun = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE handle;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_ADAPTERATTRIBUTES hbaAttrs;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_PORTATTRIBUTES portAttrs;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_PORTATTRIBUTES discPortAttrs;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_FCPTARGETMAPPINGV2 *map;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int count, adapterIndex, portIndex, mapIndex, discIndex;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char name[256], *physical, *comp_phys;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte L_inquiry inq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct scsi_extended_sense sense;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT8 scsiStatus;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int matched;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int done;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t inquirySize = sizeof (inq), senseSize = sizeof (sense);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte boolean_t goodPath = B_FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ret = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t responseSize = DEFAULT_LUN_LENGTH;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uchar_t raw_luns[DEFAULT_LUN_LENGTH];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct rep_luns_rsp *lun_resp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (loadLibrary()) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (path_index = 0; argv[path_index] != NULL; path_index++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goodPath = B_FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (is_wwn(argv[path_index])) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sscanf(argv[path_index], "%016llx", &wwn);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (!is_path(argv[path_index])) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stderr, MSGSTR(112, "Error: Invalid pathname (%s)"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte argv[path_index]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stderr, "\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = -1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte count = getNumberOfAdapters();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte done = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Loop over all HBAs */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (adapterIndex = 0; adapterIndex < count && !done;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte adapterIndex ++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (skip_hba(adapterIndex)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = HBA_GetAdapterName(adapterIndex, (char *)&name);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status != HBA_STATUS_OK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* May have been DR'd */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte handle = HBA_OpenAdapter(name);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (handle == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* May have been DR'd */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (getAdapterAttrs(handle, name, &hbaAttrs)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Should never happen */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_CloseAdapter(handle);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Loop over all HBA Ports */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (portIndex = 0; portIndex < hbaAttrs.NumberOfPorts && !done;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte portIndex++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (getAdapterPortAttrs(handle, name, portIndex,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &portAttrs)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte matched = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (is_wwn(argv[path_index])) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (wwn == wwnConversion(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte portAttrs.NodeWWN.wwn) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wwn == wwnConversion(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte portAttrs.PortWWN.wwn)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte matched = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (is_path(argv[path_index]) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((physical = get_slash_devices_from_osDevName(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte argv[path_index],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte STANDARD_DEVNAME_HANDLING)) != NULL) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((comp_phys = get_slash_devices_from_osDevName(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte portAttrs.OSDeviceName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte STANDARD_DEVNAME_HANDLING)) != NULL)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *tmp = strstr(physical, ":devctl");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (tmp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *tmp = '\0';
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp = strstr(physical, ":fc");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (tmp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *tmp = '\0';
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strstr(comp_phys, physical)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte matched = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (physical) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(physical);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte physical = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (comp_phys) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(comp_phys);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte comp_phys = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!fetch_mappings(handle, portAttrs.PortWWN, &map)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mapIndex = match_mappings(argv[path_index], map);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mapIndex >= 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte matched = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (matched) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goodPath = B_TRUE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printf(MSGSTR(2095,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Pos Port_ID Hard_Addr Port WWN"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " Node WWN Type\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (discIndex = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte discIndex < portAttrs.NumberofDiscoveredPorts;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte discIndex++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (getDiscPortAttrs(handle, name, portIndex,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte discIndex, &discPortAttrs)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Move on to the next target */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printf("%-4d %-6x %-6x %016llx %016llx",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte discIndex,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte discPortAttrs.PortFcId, 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wwnConversion(discPortAttrs.PortWWN.wwn),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wwnConversion(discPortAttrs.NodeWWN.wwn));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * devices are not all required to respond to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Scsi Inquiry calls sent to LUN 0. We must
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fisrt issue a ReportLUN and then send the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * SCSI Inquiry call to the first LUN Returned
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * from the ReportLUN call
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte memset(&sense, 0, sizeof (sense));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = HBA_ScsiReportLUNsV2(handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte portAttrs.PortWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte discPortAttrs.PortWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void *)raw_luns, &responseSize, &scsiStatus,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void *)&sense, &senseSize);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status == HBA_STATUS_OK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lun_resp =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (struct rep_luns_rsp *)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (unsigned long)raw_luns;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lun = ntohll(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wwnConversion(lun_resp->lun[0].val));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * in case we are unable to retrieve report
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * LUN data, we will blindly try sending the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * INQUIRY to lun 0.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lun = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte memset(&sense, 0, sizeof (sense));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = HBA_ScsiInquiryV2(handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte portAttrs.PortWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte discPortAttrs.PortWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lun, 0, 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &inq, &inquirySize,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &scsiStatus,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &sense, &senseSize);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status != HBA_STATUS_OK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte inq.inq_dtype = 0x1f;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte print_fabric_dtype_prop(portAttrs.PortWWN.wwn,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte map->entry[mapIndex].FcpId.PortWWN.wwn,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte inq.inq_dtype);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Now dump this HBA's stats */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printf("%-4d %-6x %-6x %016llx %016llx",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte discIndex,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte portAttrs.PortFcId, 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wwnConversion(portAttrs.PortWWN.wwn),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wwnConversion(portAttrs.NodeWWN.wwn));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte print_fabric_dtype_prop(portAttrs.PortWWN.wwn,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte portAttrs.PortWWN.wwn, 0x1f);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte done = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!goodPath) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stderr, MSGSTR(112, "Error: Invalid pathname (%s)"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte argv[path_index]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stderr, "\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = -1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefchba_display_link_status(char **argv)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int path_index = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint64_t wwn;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE handle;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_ADAPTERATTRIBUTES hbaAttrs;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_PORTATTRIBUTES portAttrs;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_PORTATTRIBUTES discPortAttrs;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_FCPTARGETMAPPINGV2 *map;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int count, adapterIndex, portIndex, discIndex;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char name[256], *physical, *comp_phys;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int matched;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct fc_rls_acc_params rls;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t rls_size = sizeof (rls);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte boolean_t goodPath = B_FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ret = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (loadLibrary()) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (path_index = 0; argv[path_index] != NULL; path_index++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goodPath = B_FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (is_wwn(argv[path_index])) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sscanf(argv[path_index], "%016llx", &wwn);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (!is_path(argv[path_index])) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stderr, MSGSTR(112, "Error: Invalid pathname (%s)"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte argv[path_index]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stderr, "\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = -1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte count = getNumberOfAdapters();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Loop over all HBAs */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (adapterIndex = 0; adapterIndex < count; adapterIndex ++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (skip_hba(adapterIndex)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = HBA_GetAdapterName(adapterIndex, (char *)&name);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status != HBA_STATUS_OK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* May have been DR'd */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte handle = HBA_OpenAdapter(name);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (handle == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* May have been DR'd */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (getAdapterAttrs(handle, name, &hbaAttrs)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Should never happen */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_CloseAdapter(handle);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Loop over all HBA Ports */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (portIndex = 0; portIndex < hbaAttrs.NumberOfPorts;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte portIndex++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (getAdapterPortAttrs(handle, name, portIndex,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &portAttrs)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte matched = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (is_wwn(argv[path_index])) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (wwn == wwnConversion(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte portAttrs.NodeWWN.wwn) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wwn == wwnConversion(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte portAttrs.PortWWN.wwn)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte matched = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (is_path(argv[path_index]) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((physical = get_slash_devices_from_osDevName(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte argv[path_index],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte STANDARD_DEVNAME_HANDLING)) != NULL) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((comp_phys = get_slash_devices_from_osDevName(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte portAttrs.OSDeviceName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte STANDARD_DEVNAME_HANDLING)) != NULL)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *tmp = strstr(physical, ":devctl");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (tmp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *tmp = '\0';
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp = strstr(physical, ":fc");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (tmp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *tmp = '\0';
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strstr(comp_phys, physical)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte matched = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (physical) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(physical);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte physical = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (comp_phys) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(comp_phys);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte comp_phys = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!matched) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (fetch_mappings(handle, portAttrs.PortWWN, &map)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (matched || match_mappings(argv[path_index], map) >= 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goodPath = B_TRUE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stdout,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(2007, "\nLink Error Status "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "information for loop:%s\n"), argv[path_index]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stdout, MSGSTR(2008, "al_pa lnk fail "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " sync loss signal loss sequence err"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " invalid word CRC\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (discIndex = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte discIndex < portAttrs.NumberofDiscoveredPorts;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte discIndex++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (getDiscPortAttrs(handle, name, portIndex,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte discIndex, &discPortAttrs)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = HBA_SendRLS(handle, portAttrs.PortWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte discPortAttrs.PortWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &rls, &rls_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status != HBA_STATUS_OK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte memset(&rls, 0xff, sizeof (rls));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((rls.rls_link_fail == 0xffffffff) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (rls.rls_sync_loss == 0xffffffff) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (rls.rls_sig_loss == 0xffffffff) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (rls.rls_prim_seq_err == 0xffffffff) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (rls.rls_invalid_word == 0xffffffff) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (rls.rls_invalid_crc == 0xffffffff)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stdout,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%x\t%-12d%-12d%-14d%-15d%-15d%-12d\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte discPortAttrs.PortFcId,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rls.rls_link_fail,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rls.rls_sync_loss,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rls.rls_sig_loss,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rls.rls_prim_seq_err,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rls.rls_invalid_word,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rls.rls_invalid_crc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stdout,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%x\t%-12u%-12u%-14u%-15u%-15u%-12u\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte discPortAttrs.PortFcId,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rls.rls_link_fail,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rls.rls_sync_loss,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rls.rls_sig_loss,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rls.rls_prim_seq_err,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rls.rls_invalid_word,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rls.rls_invalid_crc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Now dump this HBA's stats */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = HBA_SendRLS(handle, portAttrs.PortWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte portAttrs.PortWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &rls, &rls_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status != HBA_STATUS_OK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte memset(&rls, 0xff, sizeof (rls));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((rls.rls_link_fail == 0xffffffff) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (rls.rls_sync_loss == 0xffffffff) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (rls.rls_sig_loss == 0xffffffff) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (rls.rls_prim_seq_err == 0xffffffff) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (rls.rls_invalid_word == 0xffffffff) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (rls.rls_invalid_crc == 0xffffffff)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stdout,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%x\t%-12d%-12d%-14d%-15d%-15d%-12d\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte portAttrs.PortFcId,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rls.rls_link_fail,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rls.rls_sync_loss,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rls.rls_sig_loss,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rls.rls_prim_seq_err,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rls.rls_invalid_word,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rls.rls_invalid_crc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stdout,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%x\t%-12u%-12u%-14u%-15u%-15u%-12u\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte portAttrs.PortFcId,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rls.rls_link_fail,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rls.rls_sync_loss,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rls.rls_sig_loss,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rls.rls_prim_seq_err,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rls.rls_invalid_word,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rls.rls_invalid_crc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!goodPath) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stderr, MSGSTR(112, "Error: Invalid pathname (%s)"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte argv[path_index]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stderr, "\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = -1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(2009, "NOTE: These LESB counts are not"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " cleared by a reset, only power cycles.\n"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "These counts must be compared"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " to previously read counts.\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct _PathInformation {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char pathClass[MAXPATHLEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char pathState[MAXPATHLEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int32_t pathInfoState;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int32_t pathInfoExternalState;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} PathInformation;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestruct lun_tracking {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_FCPSCSIENTRYV2 map;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_WWN hba_pwwn;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char hba_path[MAXPATHLEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PathInformation info;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Points to another lun_tracking instance with the same map->LUID */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct lun_tracking *next_path;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Points to next lun_tracking with a different map->LUID */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct lun_tracking *next_lun;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic const char VHCI_COMPONENT[] = "scsi_vhci";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortescsi_vhci_details(struct lun_tracking *lun)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_FCPSCSIENTRYV2 entry = lun->map;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int retval = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int pathcnt, i, count, found = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char temppath[MAXPATHLEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char buf[MAXPATHLEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *path_state[5];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *phys_path = get_slash_devices_from_osDevName(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte entry.ScsiId.OSDeviceName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte STANDARD_DEVNAME_HANDLING);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *devPath = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *trailingCruft = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char devaddr[MAXPATHLEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sv_iocdata_t ioc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int prop_buf_size = SV_PROP_MAX_BUF_SIZE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *path_class_val = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char client_path[MAXPATHLEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char phci_path[MAXPATHLEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Only proceed if we are an mpxio path */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (phys_path == NULL || strstr(phys_path, VHCI_COMPONENT) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte path_state[0] = MSGSTR(2400, "INIT");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte path_state[1] = MSGSTR(2401, "ONLINE");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte path_state[2] = MSGSTR(2402, "STANDBY");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte path_state[3] = MSGSTR(2403, "FAULT");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte path_state[4] = MSGSTR(2404, "OFFLINE");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sprintf(devaddr, "%016llx,%x", wwnConversion(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte entry.FcpId.PortWWN.wwn),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte entry.ScsiId.ScsiOSLun);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* First get the controller path */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sprintf(temppath, "/dev/cfg/c%d", entry.ScsiId.ScsiBusNumber);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((count = readlink(temppath, buf, sizeof (buf)))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte buf[count] = '\0';
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Now skip over the leading "../.." */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte devPath = strstr(buf, "/devices/");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (devPath == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strcpy(lun->info.pathClass, "Unavailable");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strcpy(lun->info.pathState, "Unavailable");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(phys_path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Now chop off the trailing ":xxx" portion if present */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte trailingCruft = strrchr(buf, ':');
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (trailingCruft) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte trailingCruft[0] = '\0';
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strcpy(lun->info.pathClass, "Unavailable");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strcpy(lun->info.pathState, "Unavailable");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(phys_path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ioc.client = client_path;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ioc.phci = phci_path;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte retval = get_scsi_vhci_pathinfo(phys_path, &ioc, &pathcnt);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (retval != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte print_errString(retval, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < pathcnt; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nvlist_t *nvl;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strstr(devPath, ioc.ret_buf[i].device.ret_phci)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* This could break someday if MPxIO changes devaddr */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strstr(ioc.ret_buf[i].ret_addr, devaddr)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte retval = nvlist_unpack(ioc.ret_buf[i].ret_prop.buf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte prop_buf_size, &nvl, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (retval != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strcpy(lun->info.pathClass,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "UNKNOWN PROB");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strcpy(lun->info.pathState,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte path_state[ioc.ret_buf[i].ret_state]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lun->info.pathInfoState = ioc.ret_buf[i].ret_state;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lun->info.pathInfoExternalState =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ioc.ret_buf[i].ret_ext_state;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (nvlist_lookup_string(nvl, "path-class",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &path_class_val) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strcpy(lun->info.pathClass, path_class_val);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strcpy(lun->info.pathClass, "UNKNOWN");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nvlist_free(nvl);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte found++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!found) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strcpy(lun->info.pathClass, "Unavailable");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strcpy(lun->info.pathState, "Unavailable");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(phys_path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* free everything we alloced */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < ioc.buf_elem; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(ioc.ret_buf[i].ret_prop.buf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(ioc.ret_buf[i].ret_prop.ret_buf_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(ioc.ret_buf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Utility routine to add new entries to the list (ignores dups) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteadd_lun_path(struct lun_tracking *head, HBA_FCPSCSIENTRYV2 *map,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_WWN pwwn, char *path)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct lun_tracking *tmp = NULL, *cmp = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (tmp = head; tmp != NULL; tmp = tmp->next_lun) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (memcmp(&tmp->map.LUID, &map->LUID,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (HBA_LUID)) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Ensure this isn't a duplicate */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (cmp = tmp; cmp->next_path != NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmp = cmp->next_path) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (memcmp(&cmp->map, map, sizeof (cmp->map)) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (memcmp(&cmp->map, map, sizeof (cmp->map)) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* We have a new entry to add */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmp->next_path = (struct lun_tracking *)calloc(1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (struct lun_tracking));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmp = cmp->next_path;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memcpy(&cmp->map, map,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (cmp->map));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memcpy(&cmp->hba_pwwn, &pwwn,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (cmp->hba_pwwn));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(cmp->hba_path, MAXPATHLEN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte scsi_vhci_details(cmp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Append a new LUN at the end of the list */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (tmp = head; tmp->next_lun != NULL; tmp = tmp->next_lun) {}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp->next_lun = (struct lun_tracking *)calloc(1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (struct lun_tracking));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp = tmp->next_lun;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memcpy(&tmp->map, map,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (tmp->map));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memcpy(&tmp->hba_pwwn, &pwwn,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (tmp->hba_pwwn));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(tmp->hba_path, MAXPATHLEN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte scsi_vhci_details(tmp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*ARGSUSED*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefchba_display_config(char **argv, int option_t_input, int argc)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int path_index = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint64_t wwn;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint64_t lun = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE handle;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_ADAPTERATTRIBUTES hbaAttrs;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_PORTATTRIBUTES portAttrs;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_FCPTARGETMAPPINGV2 *map;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int count, adapterIndex, portIndex;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char name[256];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte L_inquiry inq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct scsi_extended_sense sense;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct page80 serial;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT8 scsiStatus;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t inquirySize = sizeof (inq), senseSize = sizeof (sense);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t serialSize = sizeof (serial);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct mode_page *pg_hdr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uchar_t *pg_buf;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte float lunMbytes;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct capacity_data_struct cap_data;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t cap_data_size = sizeof (cap_data);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct mode_header_g1 *mode_header_ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int offset;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *phys_path = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int mpxio = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int wwnCompare = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *physical = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct lun_tracking *head = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte boolean_t goodPath = B_FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ret = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((status = loadLibrary())) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (path_index = 0; argv[path_index] != NULL; path_index++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goodPath = B_FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (is_wwn(argv[path_index])) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sscanf(argv[path_index], "%016llx", &wwn);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wwnCompare = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (!is_path(argv[path_index])) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stderr, MSGSTR(112, "Error: Invalid pathname (%s)"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte argv[path_index]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stderr, "\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = -1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!wwnCompare) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Convert the paths to phsyical paths */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte physical = get_slash_devices_from_osDevName(argv[path_index],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte STANDARD_DEVNAME_HANDLING);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!physical) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stderr, MSGSTR(112,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Error: Invalid pathname (%s)"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte argv[path_index]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stderr, "\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = -1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte count = getNumberOfAdapters();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * We have to loop twice to ensure we don't miss any
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * extra paths for other targets in a multi-target device
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* First check WWN/path comparisons */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (adapterIndex = 0; adapterIndex < count; adapterIndex ++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (skip_hba(adapterIndex)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = HBA_GetAdapterName(adapterIndex, (char *)&name);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status != HBA_STATUS_OK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* May have been DR'd */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte handle = HBA_OpenAdapter(name);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (handle == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* May have been DR'd */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (getAdapterAttrs(handle, name, &hbaAttrs)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Should never happen */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_CloseAdapter(handle);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Loop over all HBA Ports */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (portIndex = 0; portIndex < hbaAttrs.NumberOfPorts;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte portIndex++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int matched = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int mapIndex;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *tmp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (getAdapterPortAttrs(handle, name, portIndex,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &portAttrs)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (fetch_mappings(handle, portAttrs.PortWWN, &map)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (mapIndex = 0; mapIndex < map->NumberOfEntries;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mapIndex ++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte matched = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (wwnCompare) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (wwn == wwnConversion(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte map->entry[mapIndex].FcpId.NodeWWN.wwn) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wwn == wwnConversion(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte map->entry[mapIndex].FcpId.PortWWN.wwn)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte matched = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp = get_slash_devices_from_osDevName(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte map->entry[mapIndex].ScsiId.OSDeviceName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte STANDARD_DEVNAME_HANDLING);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((tmp != NULL) && (strncmp(physical, tmp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MAXPATHLEN) == 0)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte matched = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(tmp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (matched && head == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goodPath = B_TRUE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte head = (struct lun_tracking *)calloc(1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (struct lun_tracking));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memcpy(&head->map, &map->entry[mapIndex],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (head->map));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memcpy(&head->hba_pwwn, &portAttrs.PortWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (head->hba_pwwn));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(head->hba_path, MAXPATHLEN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte portAttrs.OSDeviceName);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte scsi_vhci_details(head);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (matched) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goodPath = B_TRUE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte add_lun_path(head, &map->entry[mapIndex],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte portAttrs.PortWWN, portAttrs.OSDeviceName);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (physical) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(physical);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Now do it again and look for matching LUIDs (aka GUIDs) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (adapterIndex = 0; adapterIndex < count; adapterIndex ++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (skip_hba(adapterIndex)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = HBA_GetAdapterName(adapterIndex, (char *)&name);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status != HBA_STATUS_OK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* May have been DR'd */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte handle = HBA_OpenAdapter(name);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (handle == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* May have been DR'd */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (getAdapterAttrs(handle, name, &hbaAttrs)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Should never happen */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_CloseAdapter(handle);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Loop over all HBA Ports */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (portIndex = 0; portIndex < hbaAttrs.NumberOfPorts;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte portIndex++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int matched = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int mapIndex;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (getAdapterPortAttrs(handle, name, portIndex,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &portAttrs)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (fetch_mappings(handle, portAttrs.PortWWN, &map)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (mapIndex = 0; mapIndex < map->NumberOfEntries;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mapIndex ++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct lun_tracking *outer;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte matched = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (outer = head; outer != NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte outer = outer->next_lun) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct lun_tracking *inner;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (inner = outer; inner != NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte inner = inner->next_path) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (memcmp(&inner->map.LUID,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &map->entry[mapIndex].LUID,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (HBA_LUID)) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte matched = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (matched) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (matched && head == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goodPath = B_TRUE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte head = (struct lun_tracking *)calloc(1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (struct lun_tracking));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memcpy(&head->map, &map->entry[mapIndex],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (head->map));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memcpy(&head->hba_pwwn, &portAttrs.PortWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (head->hba_pwwn));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(head->hba_path, MAXPATHLEN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte portAttrs.OSDeviceName);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte scsi_vhci_details(head);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (matched) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goodPath = B_TRUE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte add_lun_path(head, &map->entry[mapIndex],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte portAttrs.PortWWN, portAttrs.OSDeviceName);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!goodPath) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stderr, MSGSTR(112, "Error: Invalid pathname (%s)"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte argv[path_index]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stderr, "\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = -1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Just bomb out instead of going on */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Now display all the LUNs that we found that matched */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct lun_tracking *first_time;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct lun_tracking *tmp_path;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (first_time = head; first_time != NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte first_time = first_time->next_lun) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct lun_tracking *path;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte phys_path = get_slash_devices_from_osDevName(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte first_time->map.ScsiId.OSDeviceName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte STANDARD_DEVNAME_HANDLING);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Change behavior if this is an MPxIO device */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (phys_path != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strstr(phys_path, VHCI_COMPONENT) != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mpxio = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (tmp_path = first_time; tmp_path != NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_path = tmp_path->next_path) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mpxio && (strncmp(tmp_path->info.pathState,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "ONLINE", strlen(tmp_path->info.pathState)))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* continue to next online path */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = HBA_OpenAdapterByWWN(&handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_path->hba_pwwn);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status != HBA_STATUS_OK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stderr, MSGSTR(2431,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Error: Failed to get handle for %s "),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_path->hba_path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printStatus(status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stderr, "\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* continue to next path */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lun = tmp_path->map.FcpId.FcpLun;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte memset(&inq, 0, sizeof (inq));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte memset(&sense, 0, sizeof (sense));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = HBA_ScsiInquiryV2(handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_path->hba_pwwn,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_path->map.FcpId.PortWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lun, 0, 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &inq, &inquirySize,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &scsiStatus,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &sense, &senseSize);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status == HBA_STATUS_OK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_CloseAdapter(handle);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (tmp_path == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stderr, MSGSTR(2430,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Error: I/O failure communicating with %s "),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte first_time->map.ScsiId.OSDeviceName);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printStatus(status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stderr, "\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch ((inq.inq_dtype & DTYPE_MASK)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DTYPE_DIRECT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stdout, MSGSTR(121,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "DEVICE PROPERTIES for disk: %s\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte first_time->map.ScsiId.OSDeviceName);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DTYPE_SEQUENTIAL: /* Tape */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stdout, MSGSTR(2249,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "DEVICE PROPERTIES for tape: %s\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte first_time->map.ScsiId.OSDeviceName);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stdout, MSGSTR(2250,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "DEVICE PROPERTIES for: %s\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte first_time->map.ScsiId.OSDeviceName);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stdout, " ");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stdout, MSGSTR(3, "Vendor:"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stdout, "\t\t");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte print_chars(inq.inq_vid, sizeof (inq.inq_vid), 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stdout, MSGSTR(2115, "\n Product ID:\t\t"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte print_chars(inq.inq_pid, sizeof (inq.inq_pid), 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stdout, "\n ");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stdout, MSGSTR(2119, "Revision:"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stdout, "\t\t");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte print_chars(inq.inq_revision, sizeof (inq.inq_revision), 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stdout, "\n ");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stdout, MSGSTR(17, "Serial Num:"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stdout, "\t\t");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fflush(stdout);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Call the inquiry cmd on page 0x80 only if the vendor
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * supports page 0x80.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((find_supported_inq_page(handle, first_time->hba_pwwn,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte first_time->map.FcpId.PortWWN, lun, 0x80))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte memset(&serial, 0, sizeof (serial));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = HBA_ScsiInquiryV2(handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte first_time->hba_pwwn,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte first_time->map.FcpId.PortWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lun, 1, 0x80,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &serial, &serialSize,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &scsiStatus,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &sense, &senseSize);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status == HBA_STATUS_OK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte print_chars(serial.inq_serial,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (serial.inq_serial), 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stdout, MSGSTR(2506, "Unsupported"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stdout, MSGSTR(2506, "Unsupported"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_CloseAdapter(handle);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((inq.inq_dtype & DTYPE_MASK) == DTYPE_DIRECT) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Read capacity wont work on standby paths, so try till OK */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (tmp_path = first_time; tmp_path != NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_path = tmp_path->next_path) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mpxio && (strncmp(tmp_path->info.pathState,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "ONLINE", strlen(tmp_path->info.pathState)))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* continue to next online path */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = HBA_OpenAdapterByWWN(&handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_path->hba_pwwn);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status != HBA_STATUS_OK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* continue to next path */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = HBA_ScsiReadCapacityV2(handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_path->hba_pwwn,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_path->map.FcpId.PortWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_path->map.FcpId.FcpLun,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &cap_data, &cap_data_size,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &scsiStatus,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &sense, &senseSize);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status == HBA_STATUS_OK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (status == HBA_STATUS_SCSI_CHECK_CONDITION &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sense.es_key == KEY_UNIT_ATTENTION) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * retry for check-condition state when unit attention
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * condition has been established
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = HBA_ScsiReadCapacityV2(handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_path->hba_pwwn,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_path->map.FcpId.PortWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_path->map.FcpId.FcpLun,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &cap_data, &cap_data_size,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &scsiStatus,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &sense, &senseSize);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status == HBA_STATUS_OK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_CloseAdapter(handle);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (handle != HBA_HANDLE_INVALID) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_CloseAdapter(handle);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status != HBA_STATUS_OK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Make sure we don't display garbage */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cap_data.block_size = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cap_data.last_block_addr = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cap_data.block_size > 0 &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cap_data.last_block_addr > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lunMbytes = ntohl(cap_data.last_block_addr) + 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lunMbytes *= ntohl(cap_data.block_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lunMbytes /= (float)(1024*1024);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stdout, "\n ");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stdout, MSGSTR(60,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Unformatted capacity:\t%6.3f MBytes"), lunMbytes);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stdout, "\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * get mode page information for FC device.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * do not do mode sense if this is a tape device.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mode sense will rewind the tape
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((inq.inq_dtype & DTYPE_MASK) != DTYPE_SEQUENTIAL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (get_mode_page(first_time->map.ScsiId.OSDeviceName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &pg_buf) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mode_header_ptr = (struct mode_header_g1 *)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void *)pg_buf;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte offset = sizeof (struct mode_header_g1) +
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ntohs(mode_header_ptr->bdesc_length);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pg_hdr = (struct mode_page *)&pg_buf[offset];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (offset < (ntohs(mode_header_ptr->length) +
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (mode_header_ptr->length))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pg_hdr->code == MODEPAGE_CACHING) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct mode_caching *pg8_buf;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pg8_buf = (struct mode_caching *)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void *)pg_hdr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pg8_buf->wce) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stdout, MSGSTR(2122,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " Write Cache:\t\t"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Enabled\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pg8_buf->rcd == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stdout, MSGSTR(2123,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " Read Cache:\t\t"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Enabled\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stdout, MSGSTR(2509,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " Minimum prefetch:\t0x%x\n"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " Maximum prefetch:\t0x%x\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pg8_buf->min_prefetch,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pg8_buf->max_prefetch);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte offset += pg_hdr->length +
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (struct mode_page);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pg_hdr = (struct mode_page *)&pg_buf[offset];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stdout, " %s\t\t", MSGSTR(35, "Device Type:"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((inq.inq_dtype & DTYPE_MASK) < 0x10) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stdout, "%s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dtype[inq.inq_dtype & DTYPE_MASK]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if ((inq.inq_dtype & DTYPE_MASK) < 0x1f) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stdout, MSGSTR(2432, "Reserved"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* dtype of 0x1f is returned */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stdout, MSGSTR(2433, "Unknown"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stdout, MSGSTR(2128, " Path(s):\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stdout, "\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stdout, " %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte first_time->map.ScsiId.OSDeviceName);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (phys_path != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stdout, " %s\n", phys_path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Now display all paths to this LUN */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (path = first_time; path != NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte path = path->next_path) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Display the controller information */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stdout, MSGSTR(2303, " Controller \t%s\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte path->hba_path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stdout, MSGSTR(2507,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " Device Address\t\t%016llx,%x\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wwnConversion(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte path->map.FcpId.PortWWN.wwn),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte path->map.ScsiId.ScsiOSLun);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stdout, MSGSTR(2508,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " Host controller port WWN\t%016llx\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wwnConversion(path->hba_pwwn.wwn));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mpxio) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stdout, MSGSTR(2305,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " Class\t\t\t%s\n"), path->info.pathClass);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stdout, MSGSTR(2306,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " State\t\t\t%s\n"), path->info.pathState);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (phys_path != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(phys_path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte phys_path = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printf("\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * handle expert-mode hotplug commands
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return 0 iff all is okay
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefchba_hotplug_e(int todo, char **argv, int verbose_flag, int force_flag)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortechar *path_phys = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint exit_code;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortedevctl_hdl_t dcp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (todo != DEV_ONLINE &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte todo != DEV_OFFLINE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stderr, "%s\n", strerror(ENOTSUP));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Convert the paths to phsyical paths */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte path_phys = get_slash_devices_from_osDevName(argv[0],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NOT_IGNORE_DANGLING_LINK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!path_phys) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stderr, MSGSTR(112,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Error: Invalid pathname (%s)"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte argv[0]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stderr, "\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (verbose_flag) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(5516,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "phys path = \"%s\"\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte path_phys);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* acquire rights to hack on device */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((dcp = devctl_device_acquire(path_phys,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte force_flag ? 0 : DC_EXCL)) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, MSGSTR(5517,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Error: can't acquire \"%s\": %s\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte path_phys, strerror(errno));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (todo) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DEV_ONLINE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit_code = devctl_device_online(dcp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DEV_OFFLINE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit_code = devctl_device_offline(dcp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (exit_code != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte perror(MSGSTR(5518, "devctl"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* all done now -- release device */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte devctl_release(dcp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (path_phys) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(path_phys);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (exit_code);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns non zero if we should use FC-HBA.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * For x86, luxadm uses FC-HBA.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteuse_fchba()
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef __x86
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns non-zero if we should skip the HBA at index "i"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteskip_hba(int i) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_LIBRARYATTRIBUTES lib_attrs;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) HBA_GetVendorLibraryAttributes(i, &lib_attrs);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strncmp(lib_attrs.VName, VSL_NAME,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (lib_attrs.VName)) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Function to determine if the given page is supported by vendor.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefind_supported_inq_page(HBA_HANDLE handle, HBA_WWN hwwn, HBA_WWN pwwn,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint64_t lun, int page_num)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct scsi_extended_sense sense;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte L_inquiry00 inq00;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uchar_t *data;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_STATUS status = HBA_STATUS_ERROR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int index;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT8 scsiStatus;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t inqSize = sizeof (inq00);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t senseSize = sizeof (sense);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = HBA_ScsiInquiryV2(handle, hwwn, pwwn, lun, 1, 0x00,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &inq00, &inqSize, &scsiStatus, &sense, &senseSize);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status == HBA_STATUS_OK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte data = (uchar_t *)&inq00;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (index = 4; (index <= inq00.len+3)&&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (data[index] <= page_num); index ++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (data[index] == page_num) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}