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/*
c946faca5d4627284fb79c6b04e652b471034495allan * Copyright 2009 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 <TgtFCHBAPort.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <Exceptions.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <Trace.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sun_fc.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <iostream>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <iomanip>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/types.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/mkdev.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/stat.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <fcntl.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <unistd.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <stropts.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <dirent.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/fibre-channel/fc.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/fctio.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/fibre-channel/impl/fc_error.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/fibre-channel/fc_appif.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/scsi/generic/commands.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/scsi/impl/commands.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/scsi/impl/sense.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/scsi/generic/inquiry.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/scsi/generic/status.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <errno.h>
f3aaec0a97c3584095582719a0149d5e94c06ea2Richard Lowe#include <cstdlib>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteusing namespace std;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteconst int TgtFCHBAPort::MAX_FCTIO_MSG_LEN = 256;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteconst string TgtFCHBAPort::FCT_DRIVER_PATH = "/devices/pseudo/fct@0:admin";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Interpret the error code in the fctio_t structure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * message must be at least MAX_FCTIO_MSG_LEN in length.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteTgtFCHBAPort::transportError(uint32_t fctio_errno, char *message) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Trace log("transportError");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte string fcioErrorString;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (message == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log.internalError("NULL routine argument");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (fctio_errno) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case (uint32_t)FC_FAILURE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcioErrorString = "general failure";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case (uint32_t)FC_FAILURE_SILENT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcioErrorString = "general failure but fail silently";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FC_SUCCESS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcioErrorString = "successful completion";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FC_CAP_ERROR:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcioErrorString = "FCA capability error";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FC_CAP_FOUND:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcioErrorString = "FCA capability unsettable";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FC_CAP_SETTABLE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcioErrorString = "FCA capability settable";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FC_UNBOUND:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcioErrorString = "unbound stuff";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FC_NOMEM:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcioErrorString = "allocation error";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FC_BADPACKET:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcioErrorString = "invalid packet specified/supplied";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FC_OFFLINE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcioErrorString = "I/O resource unavailable";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FC_OLDPORT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcioErrorString = "operation on non-loop port";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FC_NO_MAP:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcioErrorString = "requested map unavailable";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FC_TRANSPORT_ERROR:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcioErrorString = "unable to transport I/O";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FC_ELS_FREJECT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcioErrorString = "ELS rejected by a Fabric";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FC_ELS_PREJECT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcioErrorString = "ELS rejected by an N_port";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FC_ELS_BAD:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcioErrorString = "ELS rejected by FCA/fctl";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FC_ELS_MALFORMED:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcioErrorString = "poorly formed ELS request";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FC_TOOMANY:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcioErrorString = "resource request too large";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FC_UB_BADTOKEN:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcioErrorString = "invalid unsolicited buffer token";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FC_UB_ERROR:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcioErrorString = "invalid unsol buf request";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FC_UB_BUSY:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcioErrorString = "buffer already in use";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FC_BADULP:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcioErrorString = "Unknown ulp";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FC_BADTYPE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcioErrorString = "ULP not registered to handle this FC4 type";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FC_UNCLAIMED:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcioErrorString = "request or data not claimed";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FC_ULP_SAMEMODULE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcioErrorString = "module already in use";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FC_ULP_SAMETYPE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcioErrorString = "FC4 module already in use";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FC_ABORTED:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcioErrorString = "request aborted";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FC_ABORT_FAILED:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcioErrorString = "abort request failed";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FC_BADEXCHANGE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcioErrorString = "exchange doesn�t exist";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FC_BADWWN:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcioErrorString = "WWN not recognized";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FC_BADDEV:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcioErrorString = "device unrecognized";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FC_BADCMD:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcioErrorString = "invalid command issued";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FC_BADOBJECT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcioErrorString = "invalid object requested";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FC_BADPORT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcioErrorString = "invalid port specified";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FC_NOTTHISPORT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcioErrorString = "resource not at this port";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FC_PREJECT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcioErrorString = "reject at remote N_Port";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FC_FREJECT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcioErrorString = "reject at remote Fabric";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FC_PBUSY:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcioErrorString = "remote N_Port busy";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FC_FBUSY:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcioErrorString = "remote Fabric busy";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FC_ALREADY:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcioErrorString = "already logged in";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FC_LOGINREQ:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcioErrorString = "login required";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FC_RESETFAIL:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcioErrorString = "reset failed";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FC_INVALID_REQUEST:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcioErrorString = "request is invalid";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FC_OUTOFBOUNDS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcioErrorString = "port number is out of bounds";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FC_TRAN_BUSY:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcioErrorString = "command transport busy";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FC_STATEC_BUSY:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcioErrorString = "port driver currently busy";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FC_DEVICE_BUSY:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcioErrorString = "transport working on this device";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FC_DEVICE_NOT_TGT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcioErrorString = "device is not a SCSI target";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte snprintf(message, MAX_FCTIO_MSG_LEN, "Unknown error code 0x%x",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fctio_errno);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte snprintf(message, MAX_FCTIO_MSG_LEN, "%s", fcioErrorString.c_str());
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteTgtFCHBAPort::TgtFCHBAPort(string thePath) : HBAPort() {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Trace log("TgtFCHBAPort::TgtFCHBAPort");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log.debug("Initializing HBA port %s", path.c_str());
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte path = thePath;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // This routine is not index based, so we can discard stateChange
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint64_t tmp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_PORTATTRIBUTES attrs = getPortAttributes(tmp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte memcpy(&tmp, &attrs.PortWWN, 8);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte portWWN = ntohll(tmp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte memcpy(&tmp, &attrs.NodeWWN, 8);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nodeWWN = ntohll(tmp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // For reference, here's how to dump WWN's through C++ streams.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // cout << "\tPort WWN: " << hex << setfill('0') << setw(16) << portWWN
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // << endl;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // cout << "\tNode WWN: " << hex << setfill('0') << setw(16) << nodeWWN
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // << endl;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_PORTATTRIBUTES TgtFCHBAPort::getPortAttributes(uint64_t &stateChange) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Trace log("TgtFCHBAPort::getPortAttributes");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_PORTATTRIBUTES attributes;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fctio_t fctio;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fc_tgt_hba_port_attributes_t attrs;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte memset(&fctio, 0, sizeof (fctio));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte memset(&attributes, 0, sizeof (attributes));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint64_t portwwn = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte try {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte string::size_type offset = path.find_last_of(".");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (offset >= 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte string portwwnString = path.substr(offset+1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte portwwn = strtoull(portwwnString.c_str(), NULL, 16);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } catch (...) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte throw BadArgumentException();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint64_t en_wwn = htonll(portwwn);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fctio.fctio_cmd = FCTIO_GET_ADAPTER_PORT_ATTRIBUTES;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fctio.fctio_ilen = 8;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fctio.fctio_ibuf = (uint64_t)(uintptr_t)&en_wwn;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fctio.fctio_xfer = FCTIO_XFER_READ;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fctio.fctio_olen = (uint32_t)(sizeof (attrs));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fctio.fctio_obuf = (uint64_t)(uintptr_t)&attrs;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fct_ioctl(FCTIO_CMD, &fctio);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stateChange = attrs.lastChange;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attributes.PortFcId = attrs.PortFcId;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attributes.PortType = attrs.PortType;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attributes.PortState = attrs.PortState;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attributes.PortSupportedClassofService = attrs.PortSupportedClassofService;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attributes.PortSupportedSpeed = attrs.PortSupportedSpeed;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attributes.PortSpeed = attrs.PortSpeed;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attributes.PortMaxFrameSize = attrs.PortMaxFrameSize;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attributes.NumberofDiscoveredPorts = attrs.NumberofDiscoveredPorts;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte memcpy(&attributes.NodeWWN, &attrs.NodeWWN, 8);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte memcpy(&attributes.PortWWN, &attrs.PortWWN, 8);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte memcpy(&attributes.FabricName, &attrs.FabricName, 8);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte memcpy(&attributes.PortSupportedFc4Types, &attrs.PortSupportedFc4Types, 32);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte memcpy(&attributes.PortActiveFc4Types, &attrs.PortActiveFc4Types, 32);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte memcpy(&attributes.PortSymbolicName, &attrs.PortSymbolicName, 256);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy((char *)attributes.OSDeviceName, "Not Applicable", 15);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (attributes);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_PORTATTRIBUTES TgtFCHBAPort::getDiscoveredAttributes(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 discoveredport, uint64_t &stateChange) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Trace log("TgtFCHBAPort::getDiscoverdAttributes(i)");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_PORTATTRIBUTES attributes;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fctio_t fctio;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fc_tgt_hba_port_attributes_t attrs;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte memset(&fctio, 0, sizeof (fctio));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte memset(&attributes, 0, sizeof (attributes));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint64_t portwwn = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte try {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte string::size_type offset = path.find_last_of(".");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (offset >= 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte string portwwnString = path.substr(offset+1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte portwwn = strtoull(portwwnString.c_str(), NULL, 16);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } catch (...) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte throw BadArgumentException();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint64_t en_wwn = htonll(portwwn);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fctio.fctio_cmd = FCTIO_GET_DISCOVERED_PORT_ATTRIBUTES;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fctio.fctio_ilen = 8;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fctio.fctio_ibuf = (uint64_t)(uintptr_t)&en_wwn;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fctio.fctio_xfer = FCTIO_XFER_READ;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fctio.fctio_olen = (uint32_t)(sizeof (attrs));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fctio.fctio_obuf = (uint64_t)(uintptr_t)&attrs;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fctio.fctio_alen = (uint32_t)(sizeof (discoveredport));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fctio.fctio_abuf = (uint64_t)(uintptr_t)&discoveredport;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fct_ioctl(FCTIO_CMD, &fctio);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stateChange = attrs.lastChange;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attributes.PortFcId = attrs.PortFcId;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attributes.PortType = attrs.PortType;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attributes.PortState = attrs.PortState;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attributes.PortSupportedClassofService = attrs.PortSupportedClassofService;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attributes.PortSupportedSpeed = attrs.PortSupportedSpeed;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attributes.PortSpeed = attrs.PortSpeed;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attributes.PortMaxFrameSize = attrs.PortMaxFrameSize;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attributes.NumberofDiscoveredPorts = attrs.NumberofDiscoveredPorts;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte memcpy(&attributes.NodeWWN, &attrs.NodeWWN, 8);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte memcpy(&attributes.PortWWN, &attrs.PortWWN, 8);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte memcpy(&attributes.FabricName, &attrs.FabricName, 8);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte memcpy(&attributes.PortSupportedFc4Types, &attrs.PortSupportedFc4Types, 32);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte memcpy(&attributes.PortActiveFc4Types, &attrs.PortActiveFc4Types, 32);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte memcpy(&attributes.PortSymbolicName, &attrs.PortSymbolicName, 256);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (attributes);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_PORTATTRIBUTES TgtFCHBAPort::getDiscoveredAttributes(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint64_t wwn, uint64_t &stateChange) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Trace log("TgtFCHBAPort::getDiscoverdAttributes(p)");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_PORTATTRIBUTES attributes;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fctio_t fctio;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fc_tgt_hba_port_attributes_t attrs;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte memset(&fctio, 0, sizeof (fctio));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte memset(&attributes, 0, sizeof (attributes));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint64_t en_wwn = htonll(wwn);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fctio.fctio_cmd = FCTIO_GET_PORT_ATTRIBUTES;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fctio.fctio_olen = (uint32_t)(sizeof (attrs));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fctio.fctio_xfer = FCTIO_XFER_READ;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fctio.fctio_obuf = (uint64_t)(uintptr_t)&attrs;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fctio.fctio_ilen = (uint32_t)(sizeof (wwn));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fctio.fctio_ibuf = (uint64_t)(uintptr_t)&en_wwn;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fct_ioctl(FCTIO_CMD, &fctio);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stateChange = attrs.lastChange;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attributes.PortFcId = attrs.PortFcId;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attributes.PortType = attrs.PortType;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attributes.PortState = attrs.PortState;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attributes.PortSupportedClassofService = attrs.PortSupportedClassofService;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attributes.PortSupportedSpeed = attrs.PortSupportedSpeed;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attributes.PortSpeed = attrs.PortSpeed;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attributes.PortMaxFrameSize = attrs.PortMaxFrameSize;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attributes.NumberofDiscoveredPorts = attrs.NumberofDiscoveredPorts;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte memcpy(&attributes.NodeWWN, &attrs.NodeWWN, 8);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte memcpy(&attributes.PortWWN, &attrs.PortWWN, 8);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte memcpy(&attributes.FabricName, &attrs.FabricName, 8);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte memcpy(&attributes.PortSupportedFc4Types, &attrs.PortSupportedFc4Types, 32);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte memcpy(&attributes.PortActiveFc4Types, &attrs.PortActiveFc4Types, 32);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte memcpy(&attributes.PortSymbolicName, &attrs.PortSymbolicName, 256);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (attributes);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid TgtFCHBAPort::sendRLS(uint64_t destWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *pRspBuffer,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 *pRspBufferSize) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Trace log("FCHBAPort::sendRLS");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fctio_t fctio;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // fc_hba_adapter_port_stats_t fc_port_stat;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint64_t en_portWWN;
c946faca5d4627284fb79c6b04e652b471034495allan uint64_t DestPortID;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // Validate the arguments
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pRspBuffer == NULL ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pRspBufferSize == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log.userError("NULL hba");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte throw BadArgumentException();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // check to see if we are sending RLS to the HBA
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_PORTATTRIBUTES attrs;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint64_t tmp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte portWWN = getPortWWN();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte en_portWWN = htonll(portWWN);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* The destWWN is either the adapter port or a discovered port. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte memset(&fctio, 0, sizeof (fctio));
c946faca5d4627284fb79c6b04e652b471034495allan fctio.fctio_cmd = FCTIO_GET_LINK_STATUS;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fctio.fctio_ibuf = (uint64_t)(uintptr_t)&en_portWWN;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fctio.fctio_ilen = (uint32_t)(sizeof (en_portWWN));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (portWWN != destWWN) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attrs = getDiscoveredAttributes(destWWN, tmp);
c946faca5d4627284fb79c6b04e652b471034495allan DestPortID = (uint64_t)attrs.PortFcId;
c946faca5d4627284fb79c6b04e652b471034495allan fctio.fctio_abuf = (uint64_t)(uintptr_t)&DestPortID;
c946faca5d4627284fb79c6b04e652b471034495allan fctio.fctio_alen = (uint32_t)(sizeof (DestPortID));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fctio.fctio_xfer = FCTIO_XFER_READ;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fctio.fctio_flags = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fctio.fctio_obuf = (uint64_t)(uintptr_t)new uchar_t[*pRspBufferSize];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fctio.fctio_olen = *pRspBufferSize;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (fctio.fctio_obuf == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log.noMemory();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte throw InternalError();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fct_ioctl(FCTIO_CMD, &fctio);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte memcpy(pRspBuffer, (uchar_t *)(uintptr_t)fctio.fctio_obuf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *pRspBufferSize);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (fctio.fctio_obuf != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte delete((uchar_t *)(uintptr_t)fctio.fctio_obuf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/**
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @memo Validate that the port is still present in the system
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @exception UnavailableException if the port is not present
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @version 1.7
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @doc If the port is still present on the system, the routine
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * will return normally. If the port is not present
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * an exception will be thrown.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid TgtFCHBAPort::validatePresent() {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Trace log("TgtFCHBAPort::validatePresent");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // We already got the adapter list through the ioctl
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // so calling it again to validate it is too expensive.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid TgtFCHBAPort::fct_ioctl(int cmd, fctio_t *fctio) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Trace log("TgtFCHBAPort::fct_ioctl");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char fcioErrorString[MAX_FCTIO_MSG_LEN] = "";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int fd = HBA::_open(FCT_DRIVER_PATH, O_NDELAY | O_RDONLY);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte try {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA::_ioctl(fd, cmd, (uchar_t *)fctio);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte close(fd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (fctio->fctio_errno) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte throw IOError("IOCTL transport failure");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } catch (...) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte close(fd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte transportError(fctio->fctio_errno, fcioErrorString);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log.genericIOError("ioctl (0x%x) failed. Transport: \"%s\"", cmd,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcioErrorString);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (fctio->fctio_errno) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FC_BADWWN:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte throw IllegalWWNException();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FC_BADPORT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte throw IllegalWWNException();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FC_OUTOFBOUNDS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte throw IllegalIndexException();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FC_PBUSY:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FC_FBUSY:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FC_TRAN_BUSY:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FC_STATEC_BUSY:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FC_DEVICE_BUSY:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte throw BusyException();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FC_SUCCESS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte throw;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}