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