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.
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.
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]
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
31 // Forward Declarations
37 #include "HandlePort.h"
40 #include <hbaapi-sun.h>
44 * @memo Represents an open HBA port
46 * @doc This class represents an open HBA. However,
47 * what we really care about is the HBA port's underneath.
48 * So, we also track HandlePorts internally.
50 class Handle
: public Lockable
{
52 enum MODE
{ INITIATOR
, TARGET
};
53 Handle(HBA
*hba
); // Generate ID, and add to vector
54 // Handle(HBA *hba, MODE m); // Generate ID based on target or initiator mode
55 ~Handle(); // Free and remove from vector
57 static Handle
* findHandle(HBA_HANDLE index
);
58 static Handle
* findHandle(uint64_t wwn
);
59 static void closeHandle(HBA_HANDLE index
);
61 HBA_HANDLE
getHandle();
63 bool operator==(Handle comp
);
65 HBA
* getHBA() { return (hba
); }
66 HandlePort
* getHandlePortByIndex(int index
);
67 HandlePort
* getHandlePort(uint64_t wwn
);
68 MODE
getMode() { return (modeVal
); };
71 HBA_ADAPTERATTRIBUTES
getHBAAttributes();
73 HBA_ADAPTERATTRIBUTES
npivGetHBAAttributes();
74 HBA_PORTATTRIBUTES
getPortAttributes(uint64_t wwn
);
80 static pthread_mutex_t staticLock
;
82 static HBA_HANDLE prevOpen
;
83 static HBA_HANDLE prevTgtOpen
;
84 static std::map
<HBA_HANDLE
, Handle
*> openHandles
;
85 std::map
<uint64_t, HandlePort
*> portHandles
;
88 #endif /* _HANDLE_H */