xref: /onnv-gate/usr/src/lib/sun_fc/common/FCHBAPort.h (revision 7836:4e95154b5b7a)
1*7836SJohn.Forte@Sun.COM /*
2*7836SJohn.Forte@Sun.COM  * CDDL HEADER START
3*7836SJohn.Forte@Sun.COM  *
4*7836SJohn.Forte@Sun.COM  * The contents of this file are subject to the terms of the
5*7836SJohn.Forte@Sun.COM  * Common Development and Distribution License (the "License").
6*7836SJohn.Forte@Sun.COM  * You may not use this file except in compliance with the License.
7*7836SJohn.Forte@Sun.COM  *
8*7836SJohn.Forte@Sun.COM  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*7836SJohn.Forte@Sun.COM  * or http://www.opensolaris.org/os/licensing.
10*7836SJohn.Forte@Sun.COM  * See the License for the specific language governing permissions
11*7836SJohn.Forte@Sun.COM  * and limitations under the License.
12*7836SJohn.Forte@Sun.COM  *
13*7836SJohn.Forte@Sun.COM  * When distributing Covered Code, include this CDDL HEADER in each
14*7836SJohn.Forte@Sun.COM  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*7836SJohn.Forte@Sun.COM  * If applicable, add the following below this CDDL HEADER, with the
16*7836SJohn.Forte@Sun.COM  * fields enclosed by brackets "[]" replaced with your own identifying
17*7836SJohn.Forte@Sun.COM  * information: Portions Copyright [yyyy] [name of copyright owner]
18*7836SJohn.Forte@Sun.COM  *
19*7836SJohn.Forte@Sun.COM  * CDDL HEADER END
20*7836SJohn.Forte@Sun.COM  */
21*7836SJohn.Forte@Sun.COM /*
22*7836SJohn.Forte@Sun.COM  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23*7836SJohn.Forte@Sun.COM  * Use is subject to license terms.
24*7836SJohn.Forte@Sun.COM  */
25*7836SJohn.Forte@Sun.COM 
26*7836SJohn.Forte@Sun.COM #ifndef	_FCHBAPORT_H
27*7836SJohn.Forte@Sun.COM #define	_FCHBAPORT_H
28*7836SJohn.Forte@Sun.COM 
29*7836SJohn.Forte@Sun.COM 
30*7836SJohn.Forte@Sun.COM 
31*7836SJohn.Forte@Sun.COM #include <Lockable.h>
32*7836SJohn.Forte@Sun.COM #include <HBAPort.h>
33*7836SJohn.Forte@Sun.COM #include <Exceptions.h>
34*7836SJohn.Forte@Sun.COM #include <string>
35*7836SJohn.Forte@Sun.COM #include <hbaapi.h>
36*7836SJohn.Forte@Sun.COM #include <sys/param.h>
37*7836SJohn.Forte@Sun.COM #include <sys/fibre-channel/fcio.h>
38*7836SJohn.Forte@Sun.COM 
39*7836SJohn.Forte@Sun.COM #ifdef	__cplusplus
40*7836SJohn.Forte@Sun.COM extern "C" {
41*7836SJohn.Forte@Sun.COM #endif
42*7836SJohn.Forte@Sun.COM 
43*7836SJohn.Forte@Sun.COM /*
44*7836SJohn.Forte@Sun.COM  * Represents a single HBA port
45*7836SJohn.Forte@Sun.COM  */
46*7836SJohn.Forte@Sun.COM class FCHBAPort : public HBAPort {
47*7836SJohn.Forte@Sun.COM public:
48*7836SJohn.Forte@Sun.COM     FCHBAPort(std::string path);
getPath()49*7836SJohn.Forte@Sun.COM     virtual std::string			getPath()
50*7836SJohn.Forte@Sun.COM 					    { return path; }
getNodeWWN()51*7836SJohn.Forte@Sun.COM     virtual uint64_t			getNodeWWN()
52*7836SJohn.Forte@Sun.COM 					    { return nodeWWN; }
getPortWWN()53*7836SJohn.Forte@Sun.COM     virtual uint64_t			getPortWWN()
54*7836SJohn.Forte@Sun.COM 					    { return portWWN; }
55*7836SJohn.Forte@Sun.COM     virtual HBA_PORTATTRIBUTES		getPortAttributes(
56*7836SJohn.Forte@Sun.COM 					    uint64_t &stateChange);
57*7836SJohn.Forte@Sun.COM     virtual HBA_PORTNPIVATTRIBUTES		getPortNPIVAttributes(
58*7836SJohn.Forte@Sun.COM 					    uint64_t &stateChange);
59*7836SJohn.Forte@Sun.COM     virtual uint32_t			createNPIVPort(
60*7836SJohn.Forte@Sun.COM 					    uint64_t vnodewwn,
61*7836SJohn.Forte@Sun.COM 					    uint64_t vportwwn,
62*7836SJohn.Forte@Sun.COM 					    uint32_t vindex);
63*7836SJohn.Forte@Sun.COM     virtual uint32_t			deleteNPIVPort(
64*7836SJohn.Forte@Sun.COM 					    uint64_t vportwwn);
65*7836SJohn.Forte@Sun.COM     virtual HBA_PORTATTRIBUTES		getDiscoveredAttributes(
66*7836SJohn.Forte@Sun.COM 					    HBA_UINT32 discoveredport,
67*7836SJohn.Forte@Sun.COM 					    uint64_t &stateChange);
68*7836SJohn.Forte@Sun.COM     virtual HBA_PORTATTRIBUTES		getDiscoveredAttributes(
69*7836SJohn.Forte@Sun.COM 					    uint64_t wwn,
70*7836SJohn.Forte@Sun.COM 					    uint64_t &stateChange);
71*7836SJohn.Forte@Sun.COM     virtual void	    getTargetMappings(
72*7836SJohn.Forte@Sun.COM 				PHBA_FCPTARGETMAPPINGV2 userMappings);
73*7836SJohn.Forte@Sun.COM     virtual void	    getRNIDMgmtInfo(PHBA_MGMTINFO info);
74*7836SJohn.Forte@Sun.COM     virtual void	    sendCTPassThru(void *requestBuffer,
75*7836SJohn.Forte@Sun.COM 				HBA_UINT32 requestSize,
76*7836SJohn.Forte@Sun.COM 				void *responseBuffer,
77*7836SJohn.Forte@Sun.COM 				HBA_UINT32 *responseSize);
78*7836SJohn.Forte@Sun.COM     virtual void	    sendRLS(uint64_t destWWN,
79*7836SJohn.Forte@Sun.COM 				void *pRspBuffer,
80*7836SJohn.Forte@Sun.COM 				HBA_UINT32 *pRspBufferSize);
sendRPL(uint64_t destWWN,HBA_UINT32 agent_domain,HBA_UINT32 port_index,void * pRspBuffer,HBA_UINT32 * pRspBufferSize)81*7836SJohn.Forte@Sun.COM     virtual void	    sendRPL(uint64_t destWWN,
82*7836SJohn.Forte@Sun.COM 				HBA_UINT32 agent_domain,
83*7836SJohn.Forte@Sun.COM 				HBA_UINT32 port_index,
84*7836SJohn.Forte@Sun.COM 				void *pRspBuffer,
85*7836SJohn.Forte@Sun.COM 				HBA_UINT32 *pRspBufferSize) {
86*7836SJohn.Forte@Sun.COM 				throw NotSupportedException(); }
sendRPS(uint64_t agentWWN,HBA_UINT32 agentDomain,uint64_t objectWWN,HBA_UINT32 objectPortNum,void * pRspBuffer,HBA_UINT32 * pRspBufferSize)87*7836SJohn.Forte@Sun.COM     virtual void	    sendRPS(uint64_t agentWWN,
88*7836SJohn.Forte@Sun.COM 				HBA_UINT32 agentDomain,
89*7836SJohn.Forte@Sun.COM 				uint64_t objectWWN,
90*7836SJohn.Forte@Sun.COM 				HBA_UINT32 objectPortNum,
91*7836SJohn.Forte@Sun.COM 				void *pRspBuffer,
92*7836SJohn.Forte@Sun.COM 				HBA_UINT32 *pRspBufferSize) {
93*7836SJohn.Forte@Sun.COM 				throw NotSupportedException(); }
sendSRL(uint64_t destWWN,HBA_UINT32 agent_domain,void * pRspBuffer,HBA_UINT32 * pRspBufferSize)94*7836SJohn.Forte@Sun.COM     virtual void	    sendSRL(uint64_t destWWN,
95*7836SJohn.Forte@Sun.COM 				HBA_UINT32 agent_domain,
96*7836SJohn.Forte@Sun.COM 				void *pRspBuffer,
97*7836SJohn.Forte@Sun.COM 				HBA_UINT32 *pRspBufferSize) {
98*7836SJohn.Forte@Sun.COM 				throw NotSupportedException(); }
sendLIRR(uint64_t destWWN,HBA_UINT8 function,HBA_UINT8 type,void * pRspBuffer,HBA_UINT32 * pRspBufferSize)99*7836SJohn.Forte@Sun.COM     virtual void	    sendLIRR(uint64_t destWWN,
100*7836SJohn.Forte@Sun.COM 				HBA_UINT8 function,
101*7836SJohn.Forte@Sun.COM 				HBA_UINT8 type,
102*7836SJohn.Forte@Sun.COM 				void *pRspBuffer,
103*7836SJohn.Forte@Sun.COM 				HBA_UINT32 *pRspBufferSize) {
104*7836SJohn.Forte@Sun.COM 				throw NotSupportedException(); }
105*7836SJohn.Forte@Sun.COM     virtual void	    sendReportLUNs(uint64_t wwn,
106*7836SJohn.Forte@Sun.COM 				void *responseBuffer, HBA_UINT32 *responseSize,
107*7836SJohn.Forte@Sun.COM 				HBA_UINT8 *scsiStatus,
108*7836SJohn.Forte@Sun.COM 				void *senseBuffer, HBA_UINT32 *senseSize);
109*7836SJohn.Forte@Sun.COM     virtual void	    sendScsiInquiry(uint64_t wwn, HBA_UINT64 fcLun,
110*7836SJohn.Forte@Sun.COM 				HBA_UINT8 cdb1, HBA_UINT8 cdb2,
111*7836SJohn.Forte@Sun.COM 				void *responseBuffer, HBA_UINT32 *responseSize,
112*7836SJohn.Forte@Sun.COM 				HBA_UINT8 *scsiStatus, void *senseBuffer,
113*7836SJohn.Forte@Sun.COM 				HBA_UINT32 *senseSize);
114*7836SJohn.Forte@Sun.COM     virtual void	    sendReadCapacity(uint64_t pwwn,
115*7836SJohn.Forte@Sun.COM 				HBA_UINT64 fcLun, void *responseBuffer,
116*7836SJohn.Forte@Sun.COM 				HBA_UINT32 *responseSize, HBA_UINT8 *scsiStatus,
117*7836SJohn.Forte@Sun.COM 				void *senseBuffer, HBA_UINT32 *senseSize);
118*7836SJohn.Forte@Sun.COM     virtual void	    sendRNID(uint64_t destwwn, HBA_UINT32 destfcid,
119*7836SJohn.Forte@Sun.COM 				HBA_UINT32 nodeIdDataFormat, void *pRspBuffer,
120*7836SJohn.Forte@Sun.COM 				HBA_UINT32 *RspBufferSize);
121*7836SJohn.Forte@Sun.COM     virtual void	    setRNID(HBA_MGMTINFO info);
122*7836SJohn.Forte@Sun.COM 
123*7836SJohn.Forte@Sun.COM 
124*7836SJohn.Forte@Sun.COM private:
125*7836SJohn.Forte@Sun.COM     std::string		    path;
126*7836SJohn.Forte@Sun.COM     uint64_t		    portWWN;
127*7836SJohn.Forte@Sun.COM     uint64_t		    nodeWWN;
128*7836SJohn.Forte@Sun.COM     uint32_t		    instanceNumber;
129*7836SJohn.Forte@Sun.COM     int			    controllerNumber;
130*7836SJohn.Forte@Sun.COM     void		    sendSCSIPassThru(struct fcp_scsi_cmd *fscsi,
131*7836SJohn.Forte@Sun.COM 				HBA_UINT32 *responseSize, HBA_UINT32 *senseSize,
132*7836SJohn.Forte@Sun.COM 				HBA_UINT8 *scsiStatus);
133*7836SJohn.Forte@Sun.COM     static const std::string	FCSM_DRIVER_PATH;
134*7836SJohn.Forte@Sun.COM     static const int		MAX_FCIO_MSG_LEN;
135*7836SJohn.Forte@Sun.COM     static const std::string	FCP_DRIVER_PATH;
136*7836SJohn.Forte@Sun.COM     static void transportError(uint32_t fcio_errno, char *message);
137*7836SJohn.Forte@Sun.COM 
138*7836SJohn.Forte@Sun.COM 	// Wrapper routines to handle error cases
139*7836SJohn.Forte@Sun.COM     static void		    fp_ioctl(std::string path, int cmd, fcio_t *arg);
140*7836SJohn.Forte@Sun.COM     static void		    fp_ioctl(std::string path, int cmd, fcio_t *arg,
141*7836SJohn.Forte@Sun.COM 				int openflag);
142*7836SJohn.Forte@Sun.COM     static void		    fcsm_ioctl(int cmd, fcio_t *arg);
143*7836SJohn.Forte@Sun.COM };
144*7836SJohn.Forte@Sun.COM 
145*7836SJohn.Forte@Sun.COM #ifdef	__cplusplus
146*7836SJohn.Forte@Sun.COM }
147*7836SJohn.Forte@Sun.COM #endif
148*7836SJohn.Forte@Sun.COM 
149*7836SJohn.Forte@Sun.COM #endif /* _FCHBAPORT_H */
150