xref: /illumos-gate/usr/src/lib/sun_fc/common/HBAPort.h (revision 55fea89d)
1fcf3ce44SJohn Forte /*
2fcf3ce44SJohn Forte  * CDDL HEADER START
3fcf3ce44SJohn Forte  *
4fcf3ce44SJohn Forte  * The contents of this file are subject to the terms of the
5fcf3ce44SJohn Forte  * Common Development and Distribution License (the "License").
6fcf3ce44SJohn Forte  * You may not use this file except in compliance with the License.
7fcf3ce44SJohn Forte  *
8fcf3ce44SJohn Forte  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9fcf3ce44SJohn Forte  * or http://www.opensolaris.org/os/licensing.
10fcf3ce44SJohn Forte  * See the License for the specific language governing permissions
11fcf3ce44SJohn Forte  * and limitations under the License.
12fcf3ce44SJohn Forte  *
13fcf3ce44SJohn Forte  * When distributing Covered Code, include this CDDL HEADER in each
14fcf3ce44SJohn Forte  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15fcf3ce44SJohn Forte  * If applicable, add the following below this CDDL HEADER, with the
16fcf3ce44SJohn Forte  * fields enclosed by brackets "[]" replaced with your own identifying
17fcf3ce44SJohn Forte  * information: Portions Copyright [yyyy] [name of copyright owner]
18fcf3ce44SJohn Forte  *
19fcf3ce44SJohn Forte  * CDDL HEADER END
20fcf3ce44SJohn Forte  */
21fcf3ce44SJohn Forte /*
22fcf3ce44SJohn Forte  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23fcf3ce44SJohn Forte  * Use is subject to license terms.
24fcf3ce44SJohn Forte  */
25fcf3ce44SJohn Forte 
26fcf3ce44SJohn Forte #ifndef	_HBAPORT_H
27fcf3ce44SJohn Forte #define	_HBAPORT_H
28fcf3ce44SJohn Forte 
29fcf3ce44SJohn Forte 
30fcf3ce44SJohn Forte 
31fcf3ce44SJohn Forte #include "Lockable.h"
32fcf3ce44SJohn Forte #include "HBANPIVPort.h"
33fcf3ce44SJohn Forte #include <string>
34fcf3ce44SJohn Forte #include <map>
35fcf3ce44SJohn Forte #include <vector>
36fcf3ce44SJohn Forte #include <hbaapi.h>
37fcf3ce44SJohn Forte #include <hbaapi-sun.h>
38fcf3ce44SJohn Forte 
39fcf3ce44SJohn Forte /**
40fcf3ce44SJohn Forte  * @memo	    Represents a single HBA port
41*55fea89dSDan Cross  *
42fcf3ce44SJohn Forte  */
43fcf3ce44SJohn Forte class HBAPort : public Lockable {
44fcf3ce44SJohn Forte public:
45fcf3ce44SJohn Forte     HBAPort();
~HBAPort()46fcf3ce44SJohn Forte     virtual ~HBAPort() {}
47fcf3ce44SJohn Forte     bool		    operator==(HBAPort &comp);
48fcf3ce44SJohn Forte     virtual void			validatePresent();
49fcf3ce44SJohn Forte     virtual std::string			getPath() = 0;
50fcf3ce44SJohn Forte     virtual uint64_t			getNodeWWN() = 0;
51fcf3ce44SJohn Forte     virtual uint64_t			getPortWWN() = 0;
52fcf3ce44SJohn Forte     virtual HBA_PORTATTRIBUTES		getPortAttributes(
53fcf3ce44SJohn Forte 					    uint64_t &stateChange) = 0;
54fcf3ce44SJohn Forte     virtual HBA_PORTATTRIBUTES		getDiscoveredAttributes(
55fcf3ce44SJohn Forte 					    HBA_UINT32 discoveredport,
56fcf3ce44SJohn Forte 					    uint64_t &stateChange) = 0;
57fcf3ce44SJohn Forte     virtual HBA_PORTATTRIBUTES		getDiscoveredAttributes(
58fcf3ce44SJohn Forte 					    uint64_t wwn,
59fcf3ce44SJohn Forte 					    uint64_t &stateChange) = 0;
60fcf3ce44SJohn Forte     virtual void	    getTargetMappings(
61fcf3ce44SJohn Forte 				PHBA_FCPTARGETMAPPINGV2 userMappings) = 0;
62fcf3ce44SJohn Forte     virtual void	    getRNIDMgmtInfo(PHBA_MGMTINFO info) = 0;
63fcf3ce44SJohn Forte     virtual void	    sendCTPassThru(void *requestBuffer,
64fcf3ce44SJohn Forte 				HBA_UINT32 requestSize,
65fcf3ce44SJohn Forte 				void *responseBuffer,
66fcf3ce44SJohn Forte 				HBA_UINT32 *responseSize) = 0;
67fcf3ce44SJohn Forte     virtual void	    sendRLS(uint64_t destWWN,
68fcf3ce44SJohn Forte 				void *pRspBuffer,
69fcf3ce44SJohn Forte 				HBA_UINT32 *pRspBufferSize) = 0;
70fcf3ce44SJohn Forte     virtual void	    sendRPL(uint64_t destWWN,
71fcf3ce44SJohn Forte 				HBA_UINT32 agent_domain,
72fcf3ce44SJohn Forte 				HBA_UINT32 port_index,
73fcf3ce44SJohn Forte 				void *pRspBuffer,
74fcf3ce44SJohn Forte 				HBA_UINT32 *pRspBufferSize) = 0;
75fcf3ce44SJohn Forte     virtual void	    sendRPS(uint64_t agentWWN,
76fcf3ce44SJohn Forte 				HBA_UINT32 agentDomain,
77fcf3ce44SJohn Forte 				uint64_t objectWWN,
78fcf3ce44SJohn Forte 				HBA_UINT32 objectPortNum,
79fcf3ce44SJohn Forte 				void *pRspBuffer,
80fcf3ce44SJohn Forte 				HBA_UINT32 *pRspBufferSize) = 0;
81fcf3ce44SJohn Forte     virtual void	    sendSRL(uint64_t destWWN,
82fcf3ce44SJohn Forte 				HBA_UINT32 agent_domain,
83fcf3ce44SJohn Forte 				void *pRspBuffer,
84fcf3ce44SJohn Forte 				HBA_UINT32 *pRspBufferSize) = 0;
85fcf3ce44SJohn Forte     virtual void	    sendLIRR(uint64_t destWWN,
86fcf3ce44SJohn Forte 				HBA_UINT8 function,
87fcf3ce44SJohn Forte 				HBA_UINT8 type,
88fcf3ce44SJohn Forte 				void *pRspBuffer,
89fcf3ce44SJohn Forte 				HBA_UINT32 *pRspBufferSize) = 0;
90fcf3ce44SJohn Forte     virtual void	    sendReportLUNs(uint64_t wwn,
91fcf3ce44SJohn Forte 				void *responseBuffer, HBA_UINT32 *responseSize,
92fcf3ce44SJohn Forte 				HBA_UINT8 *scsiStatus,
93fcf3ce44SJohn Forte 				void *senseBuffer, HBA_UINT32 *senseSize) = 0;
94fcf3ce44SJohn Forte     virtual void	    sendScsiInquiry(uint64_t wwn, HBA_UINT64 fcLun,
95fcf3ce44SJohn Forte 				HBA_UINT8 cdb1, HBA_UINT8 cdb2,
96fcf3ce44SJohn Forte 				void *responseBuffer, HBA_UINT32 *responseSize,
97fcf3ce44SJohn Forte 				HBA_UINT8 *scsiStatus, void *senseBuffer,
98fcf3ce44SJohn Forte 				HBA_UINT32 *senseSize) = 0;
99fcf3ce44SJohn Forte     virtual void	    sendReadCapacity(uint64_t pwwn,
100fcf3ce44SJohn Forte 				HBA_UINT64 fcLun, void *responseBuffer,
101fcf3ce44SJohn Forte 				HBA_UINT32 *responseSize, HBA_UINT8 *scsiStatus,
102fcf3ce44SJohn Forte 				void *senseBuffer, HBA_UINT32 *senseSize) = 0;
103fcf3ce44SJohn Forte 
104fcf3ce44SJohn Forte     static const int	    RNID_GENERAL_TOPOLOGY_DATA_FORMAT;
105fcf3ce44SJohn Forte     virtual void	    sendRNID(uint64_t destwwn, HBA_UINT32 destfcid,
106fcf3ce44SJohn Forte 				HBA_UINT32 nodeIdDataFormat, void *pRspBuffer,
107fcf3ce44SJohn Forte 				HBA_UINT32 *RspBufferSize) = 0;
108fcf3ce44SJohn Forte     virtual void	    setRNID(HBA_MGMTINFO info) = 0;
109fcf3ce44SJohn Forte 
110fcf3ce44SJohn Forte     static const uint8_t	HBA_NPIV_PORT_MAX;
111fcf3ce44SJohn Forte     void			addPort(HBANPIVPort* port);
112fcf3ce44SJohn Forte     HBANPIVPort*		getPort(uint64_t wwn);
113fcf3ce44SJohn Forte     HBANPIVPort*		getPortByIndex(int index);
114fcf3ce44SJohn Forte     virtual HBA_PORTNPIVATTRIBUTES	getPortNPIVAttributes(
115fcf3ce44SJohn Forte 					    uint64_t &stateChange) = 0;
116fcf3ce44SJohn Forte     virtual uint32_t			createNPIVPort(
117fcf3ce44SJohn Forte 					    uint64_t vnodewwn,
118fcf3ce44SJohn Forte 					    uint64_t vportwwn,
119fcf3ce44SJohn Forte 					    uint32_t vindex) = 0;
120fcf3ce44SJohn Forte     virtual uint32_t			deleteNPIVPort(
121fcf3ce44SJohn Forte 					    uint64_t vportwwn) = 0;
122fcf3ce44SJohn Forte protected:
123fcf3ce44SJohn Forte     void		    convertToShortNames(PHBA_FCPTARGETMAPPINGV2 mappings);
124fcf3ce44SJohn Forte     std::string		    lookupControllerPath(std::string path);
125fcf3ce44SJohn Forte     std::map<uint64_t, HBANPIVPort*>	npivportsByWWN;
126fcf3ce44SJohn Forte     std::vector<HBANPIVPort*>		npivportsByIndex;
127fcf3ce44SJohn Forte };
128fcf3ce44SJohn Forte 
129fcf3ce44SJohn Forte 
130fcf3ce44SJohn Forte #endif /* _HBAPORT_H */
131