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#ifndef _FCHBAPORT_H
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define _FCHBAPORT_H
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <Lockable.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <HBAPort.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <Exceptions.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <string>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <hbaapi.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/param.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/fibre-channel/fcio.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef __cplusplus
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern "C" {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Represents a single HBA port
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteclass FCHBAPort : public HBAPort {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortepublic:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte FCHBAPort(std::string path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte virtual std::string getPath()
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { return path; }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte virtual uint64_t getNodeWWN()
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { return nodeWWN; }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte virtual uint64_t getPortWWN()
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { return portWWN; }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte virtual HBA_PORTATTRIBUTES getPortAttributes(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint64_t &stateChange);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte virtual HBA_PORTNPIVATTRIBUTES getPortNPIVAttributes(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint64_t &stateChange);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte virtual uint32_t createNPIVPort(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint64_t vnodewwn,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint64_t vportwwn,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t vindex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte virtual uint32_t deleteNPIVPort(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint64_t vportwwn);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte virtual HBA_PORTATTRIBUTES getDiscoveredAttributes(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 discoveredport,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint64_t &stateChange);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte virtual HBA_PORTATTRIBUTES getDiscoveredAttributes(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint64_t wwn,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint64_t &stateChange);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte virtual void getTargetMappings(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PHBA_FCPTARGETMAPPINGV2 userMappings);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte virtual void getRNIDMgmtInfo(PHBA_MGMTINFO info);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte virtual void sendCTPassThru(void *requestBuffer,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 requestSize,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *responseBuffer,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 *responseSize);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte virtual void sendRLS(uint64_t destWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *pRspBuffer,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 *pRspBufferSize);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte virtual void sendRPL(uint64_t destWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 agent_domain,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 port_index,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *pRspBuffer,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 *pRspBufferSize) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte throw NotSupportedException(); }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte virtual void sendRPS(uint64_t agentWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 agentDomain,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint64_t objectWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 objectPortNum,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *pRspBuffer,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 *pRspBufferSize) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte throw NotSupportedException(); }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte virtual void sendSRL(uint64_t destWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 agent_domain,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *pRspBuffer,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 *pRspBufferSize) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte throw NotSupportedException(); }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte virtual void sendLIRR(uint64_t destWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT8 function,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT8 type,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *pRspBuffer,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 *pRspBufferSize) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte throw NotSupportedException(); }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte virtual void sendReportLUNs(uint64_t wwn,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *responseBuffer, HBA_UINT32 *responseSize,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT8 *scsiStatus,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *senseBuffer, HBA_UINT32 *senseSize);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte virtual void sendScsiInquiry(uint64_t wwn, HBA_UINT64 fcLun,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT8 cdb1, HBA_UINT8 cdb2,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *responseBuffer, HBA_UINT32 *responseSize,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT8 *scsiStatus, void *senseBuffer,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 *senseSize);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte virtual void sendReadCapacity(uint64_t pwwn,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT64 fcLun, void *responseBuffer,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 *responseSize, HBA_UINT8 *scsiStatus,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *senseBuffer, HBA_UINT32 *senseSize);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte virtual void sendRNID(uint64_t destwwn, HBA_UINT32 destfcid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 nodeIdDataFormat, void *pRspBuffer,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 *RspBufferSize);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte virtual void setRNID(HBA_MGMTINFO info);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteprivate:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte std::string path;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint64_t portWWN;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint64_t nodeWWN;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t instanceNumber;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int controllerNumber;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void sendSCSIPassThru(struct fcp_scsi_cmd *fscsi,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 *responseSize, HBA_UINT32 *senseSize,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT8 *scsiStatus);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte static const std::string FCSM_DRIVER_PATH;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte static const int MAX_FCIO_MSG_LEN;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte static const std::string FCP_DRIVER_PATH;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte static void transportError(uint32_t fcio_errno, char *message);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // Wrapper routines to handle error cases
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte static void fp_ioctl(std::string path, int cmd, fcio_t *arg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte static void fp_ioctl(std::string path, int cmd, fcio_t *arg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int openflag);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte static void fcsm_ioctl(int cmd, fcio_t *arg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef __cplusplus
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* _FCHBAPORT_H */