fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER START
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The contents of this file are subject to the terms of the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Common Development and Distribution License (the "License").
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You may not use this file except in compliance with the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See the License for the specific language governing permissions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and limitations under the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * When distributing Covered Code, include this CDDL HEADER in each
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If applicable, add the following below this CDDL HEADER, with the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fields enclosed by brackets "[]" replaced with your own identifying
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * information: Portions Copyright [yyyy] [name of copyright owner]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER END
c465437abaf8cc10b6cafec2fc1576bc770537baallan * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use is subject to license terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteusing namespace std;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteconst string FCHBAPort::FCSM_DRIVER_PATH = "/devices/pseudo/fcsm@0:fcsm";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteconst string FCHBAPort::FCP_DRIVER_PATH = "/devices/pseudo/fcp@0:fcp";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Interpret the error code in the fcio_t structure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * message must be at least MAX_FCIO_MSG_LEN in length.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteFCHBAPort::transportError(uint32_t fcio_errno, char *message) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcioErrorString = "general failure but fail silently";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcioErrorString = "invalid packet specified/supplied";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcioErrorString = "invalid unsolicited buffer token";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcioErrorString = "ULP not registered to handle this FC4 type";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcioErrorString = "port number is out of bounds";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcioErrorString = "transport working on this device";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte snprintf(message, MAX_FCIO_MSG_LEN, "Unknown error code 0x%x",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte snprintf(message, MAX_FCIO_MSG_LEN, "%s", fcioErrorString.c_str());
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortereportSense(struct scsi_extended_sense *sense, const char *routine) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log.internalError("NULL sense argument passed.");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log.internalError("NULL routine argument passed.");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log.genericIOError("\tSense key: %s", msg.c_str());
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log.genericIOError("\tASC = 0x%x", sense->es_add_code);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log.genericIOError("\tASCQ = 0x%x", sense->es_qual_code);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Issue a SCSI pass thru command.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns a scsi status value.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid FCHBAPort::sendSCSIPassThru(struct fcp_scsi_cmd *fscsi,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte memcpy(&wwn, fscsi->scsi_fc_pwwn.raw_wwn, sizeof (la_wwn_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fd = HBA::_open(FCP_DRIVER_PATH, O_RDONLY | O_NDELAY);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* save off errno */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * collect SCSI status first regrardless of the value.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 0 is a good status so this should be okay
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *scsiStatus = fscsi->scsi_bufstatus & STATUS_MASK;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte transportError(fscsi->scsi_fc_status, fcioErrorString);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Did we get a check condition? */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((fscsi->scsi_bufstatus & STATUS_MASK) == STATUS_CHECK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (fscsi->scsi_fc_status == FC_DEVICE_NOT_TGT) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fcp driver returns FC_DEVICE_NOT_TGT when the node is not
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * scsi-capable like remote hba nodes.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (fscsi->scsi_fc_status == FC_INVALID_LUN) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Just in case, check for a check-condition state */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((fscsi->scsi_bufstatus & STATUS_MASK) == STATUS_CHECK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *scsiStatus = fscsi->scsi_bufstatus & STATUS_MASK;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Record the response data */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *scsiStatus = fscsi->scsi_bufstatus & STATUS_MASK;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Do some quick duration calcuations */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "target %016llx was %.4f seconds", getPath().c_str(),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Did we have any failure */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Ioctl failed for device \"%s\" target %016llx."
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " Errno: \"%s\"(%d), "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Transport: \"%s\", SCSI Status: 0x%x"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "responseSize = %d, senseSize = %d",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte getPath().c_str(), wwnConversion(fscsi->scsi_fc_pwwn.raw_wwn),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strerror(ioctl_errno), ioctl_errno, fcioErrorString,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* We may or may not have sense data */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte reportSense((struct scsi_extended_sense *)fscsi->scsi_rqbufaddr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * constructs the fcp_scsi_cmd struct for SCSI_Inquiry, SendReadCapacity, or
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * SendReportLUNs
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortescsi_cmd_init(struct fcp_scsi_cmd *fscsi, const char *portname, void *reqbuf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size_t req_len, void *responseBuffer, size_t resp_len,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteFCHBAPort::FCHBAPort(string thePath) : HBAPort() {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log.debug("Initializing HBA port %s", thePath.c_str());
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sscanf(path.c_str(), "/dev/cfg/c%d", &controllerNumber);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } catch (...) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log.debug("Unable to lookup controller path and number for %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // Fetch the minor number for later use
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte throw IOError("Unable to stat device path: " + path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // This routine is not index based, so we can discard stateChange
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_PORTATTRIBUTES attrs = getPortAttributes(tmp);
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 // cout << "\tNode WWN: " << hex << setfill('0') << setw(16) << nodeWWN
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // we should add code here to build NPIVPORT instance
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // Get Port's NPIV port list ( include nwwn and pwwn and path)
c465437abaf8cc10b6cafec2fc1576bc770537baallan bufSize = MAXPATHLEN * (size - 1) + (int) sizeof (fc_hba_npiv_port_list_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pathList = (fc_hba_npiv_port_list_t *) new uchar_t[bufSize];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log.debug("Buffer too small for number of NPIV Port.Retry.");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log.debug("Get %d npiv ports", pathList->numAdapters);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // Make instance for each NPIV Port
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for ( int i = 0; i < pathList->numAdapters; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte addPort(new FCHBANPIVPort(pathList->hbaPaths[i]));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } catch (...) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteuint32_t FCHBAPort::deleteNPIVPort(uint64_t vportwwn) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteuint32_t FCHBAPort::createNPIVPort(uint64_t vnodewwn, uint64_t vportwwn, uint32_t vindex) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte memcpy(&entrybuf.VNodeWWN, &en_wwn, sizeof (en_wwn));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte memcpy(&entrybuf.VPortWWN, &en_wwn, sizeof (en_wwn));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_PORTNPIVATTRIBUTES FCHBAPort::getPortNPIVAttributes(uint64_t &stateChange) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcio.fcio_cmd = FCIO_GET_ADAPTER_PORT_NPIV_ATTRIBUTES;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attributes.MaxNumberOfNPIVPorts = attrs.MaxNumberOfNPIVPorts;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attributes.NumberOfNPIVPorts = attrs.NumberOfNPIVPorts;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_PORTATTRIBUTES FCHBAPort::getPortAttributes(uint64_t &stateChange) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcio.fcio_cmd = FCIO_GET_ADAPTER_PORT_ATTRIBUTES;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attributes.PortSupportedClassofService = attrs.PortSupportedClassofService;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attributes.PortSupportedSpeed = attrs.PortSupportedSpeed;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attributes.PortMaxFrameSize = attrs.PortMaxFrameSize;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attributes.NumberofDiscoveredPorts = attrs.NumberofDiscoveredPorts;
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 strncpy((char *)attributes.OSDeviceName, getPath().c_str(), 256);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_PORTATTRIBUTES FCHBAPort::getDiscoveredAttributes(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 discoveredport, uint64_t &stateChange) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Trace log("FCHBAPort::getDiscoverdAttributes(i)");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcio.fcio_cmd = FCIO_GET_DISCOVERED_PORT_ATTRIBUTES;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attributes.PortSupportedClassofService = attrs.PortSupportedClassofService;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attributes.PortSupportedSpeed = attrs.PortSupportedSpeed;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attributes.PortMaxFrameSize = attrs.PortMaxFrameSize;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attributes.NumberofDiscoveredPorts = attrs.NumberofDiscoveredPorts;
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 ForteHBA_PORTATTRIBUTES FCHBAPort::getDiscoveredAttributes(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Trace log("FCHBAPort::getDiscoverdAttributes(p)");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attributes.PortSupportedClassofService = attrs.PortSupportedClassofService;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attributes.PortSupportedSpeed = attrs.PortSupportedSpeed;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attributes.PortMaxFrameSize = attrs.PortMaxFrameSize;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attributes.NumberofDiscoveredPorts = attrs.NumberofDiscoveredPorts;
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 Fortevoid FCHBAPort::getTargetMappings(PHBA_FCPTARGETMAPPINGV2 userMappings) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* It's possible they didn't give any space */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* We have to give the driver at least one space */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mappings = (fc_hba_target_mappings_t *)new uchar_t[
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fioctl.listlen = ((uint32_t) (sizeof (fc_hba_mapping_entry_t))) *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fd = HBA::_open(FCP_DRIVER_PATH, O_RDONLY | O_NDELAY);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ioctl(fd, FCP_GET_TARGET_MAPPINGS, &fioctl) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte throw IOError("Unable to fetch target mappings");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // Quickly iterate through and copy the data over to the client
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < userMappings->NumberOfEntries && !zeroLength &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log.internalError("Bad target mapping without path, truncating.");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Ideally, we'd like to ask some standard Solaris interface
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * "What is the prefered minor node for this target?"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * but no such interface exists today. So, for now,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * we just hard-code ":n" for tapes, ":c,raw" for disks,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and ":0" for enclosures.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Devices with other generic names will be presented through
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * first matching /dev path.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Unrecognized target driver (%s), using first matching /dev path",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte snprintf(userMappings->entry[i].ScsiId.OSDeviceName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (userMappings->entry[i].ScsiId.OSDeviceName),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mappings->numLuns, mappings->entries[i].osLUN, mappings->entries[i].samLUN);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // If everything is good, convert paths to sym-links
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (userMappings->NumberOfEntries >= mappings->numLuns) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // User buffer is larger than needed. (All is good)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte userMappings->NumberOfEntries = mappings->numLuns;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // User buffer is non zero, but too small. Don't bother with links
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte userMappings->NumberOfEntries = mappings->numLuns;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // Zero length buffer, but we've got mappings
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte userMappings->NumberOfEntries = mappings->numLuns;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // No mappings, no worries
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid FCHBAPort::getRNIDMgmtInfo(PHBA_MGMTINFO info) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // Get the RNID information from the first port
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // Copy out the struct members of rnid into PHBA_MGMTINFO struct
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte memcpy(&info->wwn, &(rnid.global_id), sizeof (info->wwn));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte memcpy(&info->unittype, &(rnid.unit_type), sizeof (info->unittype));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte memcpy(&info->PortId, &(rnid.port_id), sizeof (info->PortId));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte memcpy(&info->NumberOfAttachedNodes, &(rnid.num_attached),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte memcpy(&info->IPVersion, &(rnid.ip_version), sizeof (info->IPVersion));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte memcpy(&info->UDPPort, &(rnid.udp_port), sizeof (info->UDPPort));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte memcpy(&info->IPAddress, &(rnid.ip_addr), sizeof (info->IPAddress));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte memcpy(&info->TopologyDiscoveryFlags, &(rnid.topo_flags),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid FCHBAPort::sendCTPassThru(void *requestBuffer, HBA_UINT32 requestSize,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *responseBuffer, HBA_UINT32 *responseSize) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // Validate the arguments
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // construct fcio struct
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // Do some calculations on the duration of the ioctl.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Total CTPASS ioctl call for HBA %s was %.4f seconds",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // Validate the arguments
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // check to see if we are sending RLS to the HBA
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcio.fcio_cmd_flags = FCIO_CFLAGS_RLS_DEST_NPORT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcio.fcio_obuf = (char *)new uchar_t[*pRspBufferSize];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte memcpy(pRspBuffer, fcio.fcio_obuf, *pRspBufferSize);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // Validate the arguments
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte memcpy(fscsi.scsi_fc_pwwn.raw_wwn, &targetWwn, sizeof (la_wwn_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte scsi_cmd_init(&fscsi, getPath().c_str(), &scsi_rl_req,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (scsi_rl_req), responseBuffer, *responseSize,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sendSCSIPassThru(&fscsi, responseSize, senseSize, scsiStatus);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * arguments:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * wwn - remote target WWN where the SCSI Inquiry shall be sent
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fcLun - the SCSI LUN to which the SCSI Inquiry shall be sent
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cdb1 - the second byte of the CDB for the SCSI Inquiry
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cdb2 - the third byte of teh CDB for the SCSI Inquiry
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * responseBuffer - shall be a pointer to a buffer to receive the SCSI
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Inquiry command response
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * responseSize - a pointer to the size of the buffer to receive
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the SCSI Inquiry.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * scsiStatus - a pointer to a buffer to receive SCSI status
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * senseBuffer - pointer to a buffer to receive SCSI sense data
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * seneseSize - pointer to the size of the buffer to receive SCSI sense
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid FCHBAPort::sendScsiInquiry(uint64_t wwn, HBA_UINT64 fcLun,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT8 cdb1, HBA_UINT8 cdb2, void *responseBuffer,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 *responseSize, HBA_UINT8 *scsiStatus, void *senseBuffer,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // Validate the arguments
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte memcpy(fscsi.scsi_fc_pwwn.raw_wwn, &targetWwn, sizeof (la_wwn_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte scsi_cmd_init(&fscsi, getPath().c_str(), &scsi_inq_req,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (scsi_inq_req), responseBuffer, *responseSize,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sendSCSIPassThru(&fscsi, responseSize, senseSize, scsiStatus);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // Validate the arguments
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte scsi_cmd_init(&fscsi, getPath().c_str(), &scsi_rc_req,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (scsi_rc_req), responseBuffer, *responseSize,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte memcpy(fscsi.scsi_fc_pwwn.raw_wwn, &targetWwn, sizeof (la_wwn_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sendSCSIPassThru(&fscsi, responseSize, senseSize, scsiStatus);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid FCHBAPort::sendRNID(uint64_t destwwn, HBA_UINT32 destfcid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // Validate the arguments
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // NodeIdDataFormat must be within the range of 0x00 and 0xff
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "NodeIdDataFormat must be within the range of 0x00 "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "and 0xFF");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_PORTATTRIBUTES attrs = getDiscoveredAttributes(destwwn,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } catch (HBAException &e) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Send RNID if destination port not
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * present in the discovered ports table
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // Can we log something so we can figure out why?
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcio.fcio_obuf = (char *)new uchar_t[*RspBufferSize];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte memcpy(pRspBuffer, fcio.fcio_obuf, *RspBufferSize);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // Copy the HBA_MGMTINFO into fc_rnid_t struct
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte memcpy(&(rnid.unit_type), &(info.unittype), sizeof (rnid.unit_type));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte memcpy(&(rnid.port_id), &(info.PortId), sizeof (rnid.port_id));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte memcpy(&(rnid.global_id), &(info.wwn), sizeof (info.wwn));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte memcpy(&(rnid.num_attached), &(info.NumberOfAttachedNodes),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte memcpy(&(rnid.ip_version), &(info.IPVersion), sizeof (rnid.ip_version));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte memcpy(&(rnid.udp_port), &(info.UDPPort), sizeof (rnid.udp_port));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte memcpy(&(rnid.ip_addr), &info.IPAddress, sizeof (rnid.ip_addr));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte memcpy(&(rnid.topo_flags), &(info.TopologyDiscoveryFlags),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fp_ioctl(getPath(), FCIO_CMD, &fcio, O_NDELAY | O_RDONLY | O_EXCL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid FCHBAPort::fp_ioctl(string path, int cmd, fcio_t *fcio, int openflag) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } catch (...) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte transportError(fcio->fcio_errno, fcioErrorString);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log.genericIOError("ioctl (0x%x) failed. Transport: \"%s\"", cmd,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid FCHBAPort::fp_ioctl(string path, int cmd, fcio_t *fcio) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid FCHBAPort::fcsm_ioctl(int cmd, fcio_t *fcio) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // We use the same error handling as fp, so just re-use