xref: /titanic_44/usr/src/lib/sun_fc/common/HBAPort.h (revision 2d6b5ea734bb47d251c82670646fde46af15fd69)
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	_HBAPORT_H
27 #define	_HBAPORT_H
28 
29 
30 
31 #include "Lockable.h"
32 #include "HBANPIVPort.h"
33 #include <string>
34 #include <map>
35 #include <vector>
36 #include <hbaapi.h>
37 #include <hbaapi-sun.h>
38 
39 /**
40  * @memo	    Represents a single HBA port
41  *
42  */
43 class HBAPort : public Lockable {
44 public:
45     HBAPort();
46     virtual ~HBAPort() {}
47     bool		    operator==(HBAPort &comp);
48     virtual void			validatePresent();
49     virtual std::string			getPath() = 0;
50     virtual uint64_t			getNodeWWN() = 0;
51     virtual uint64_t			getPortWWN() = 0;
52     virtual HBA_PORTATTRIBUTES		getPortAttributes(
53 					    uint64_t &stateChange) = 0;
54     virtual HBA_PORTATTRIBUTES		getDiscoveredAttributes(
55 					    HBA_UINT32 discoveredport,
56 					    uint64_t &stateChange) = 0;
57     virtual HBA_PORTATTRIBUTES		getDiscoveredAttributes(
58 					    uint64_t wwn,
59 					    uint64_t &stateChange) = 0;
60     virtual void	    getTargetMappings(
61 				PHBA_FCPTARGETMAPPINGV2 userMappings) = 0;
62     virtual void	    getRNIDMgmtInfo(PHBA_MGMTINFO info) = 0;
63     virtual void	    sendCTPassThru(void *requestBuffer,
64 				HBA_UINT32 requestSize,
65 				void *responseBuffer,
66 				HBA_UINT32 *responseSize) = 0;
67     virtual void	    sendRLS(uint64_t destWWN,
68 				void *pRspBuffer,
69 				HBA_UINT32 *pRspBufferSize) = 0;
70     virtual void	    sendRPL(uint64_t destWWN,
71 				HBA_UINT32 agent_domain,
72 				HBA_UINT32 port_index,
73 				void *pRspBuffer,
74 				HBA_UINT32 *pRspBufferSize) = 0;
75     virtual void	    sendRPS(uint64_t agentWWN,
76 				HBA_UINT32 agentDomain,
77 				uint64_t objectWWN,
78 				HBA_UINT32 objectPortNum,
79 				void *pRspBuffer,
80 				HBA_UINT32 *pRspBufferSize) = 0;
81     virtual void	    sendSRL(uint64_t destWWN,
82 				HBA_UINT32 agent_domain,
83 				void *pRspBuffer,
84 				HBA_UINT32 *pRspBufferSize) = 0;
85     virtual void	    sendLIRR(uint64_t destWWN,
86 				HBA_UINT8 function,
87 				HBA_UINT8 type,
88 				void *pRspBuffer,
89 				HBA_UINT32 *pRspBufferSize) = 0;
90     virtual void	    sendReportLUNs(uint64_t wwn,
91 				void *responseBuffer, HBA_UINT32 *responseSize,
92 				HBA_UINT8 *scsiStatus,
93 				void *senseBuffer, HBA_UINT32 *senseSize) = 0;
94     virtual void	    sendScsiInquiry(uint64_t wwn, HBA_UINT64 fcLun,
95 				HBA_UINT8 cdb1, HBA_UINT8 cdb2,
96 				void *responseBuffer, HBA_UINT32 *responseSize,
97 				HBA_UINT8 *scsiStatus, void *senseBuffer,
98 				HBA_UINT32 *senseSize) = 0;
99     virtual void	    sendReadCapacity(uint64_t pwwn,
100 				HBA_UINT64 fcLun, void *responseBuffer,
101 				HBA_UINT32 *responseSize, HBA_UINT8 *scsiStatus,
102 				void *senseBuffer, HBA_UINT32 *senseSize) = 0;
103 
104     static const int	    RNID_GENERAL_TOPOLOGY_DATA_FORMAT;
105     virtual void	    sendRNID(uint64_t destwwn, HBA_UINT32 destfcid,
106 				HBA_UINT32 nodeIdDataFormat, void *pRspBuffer,
107 				HBA_UINT32 *RspBufferSize) = 0;
108     virtual void	    setRNID(HBA_MGMTINFO info) = 0;
109 
110     static const uint8_t	HBA_NPIV_PORT_MAX;
111     void			addPort(HBANPIVPort* port);
112     HBANPIVPort*		getPort(uint64_t wwn);
113     HBANPIVPort*		getPortByIndex(int index);
114     virtual HBA_PORTNPIVATTRIBUTES	getPortNPIVAttributes(
115 					    uint64_t &stateChange) = 0;
116     virtual uint32_t			createNPIVPort(
117 					    uint64_t vnodewwn,
118 					    uint64_t vportwwn,
119 					    uint32_t vindex) = 0;
120     virtual uint32_t			deleteNPIVPort(
121 					    uint64_t vportwwn) = 0;
122 protected:
123     void		    convertToShortNames(PHBA_FCPTARGETMAPPINGV2 mappings);
124     std::string		    lookupControllerPath(std::string path);
125     std::map<uint64_t, HBANPIVPort*>	npivportsByWWN;
126     std::vector<HBANPIVPort*>		npivportsByIndex;
127 };
128 
129 
130 #endif /* _HBAPORT_H */
131