dmake: do not set MAKEFLAGS=k
[unleashed/tickless.git] / usr / src / lib / sun_fc / common / Handle.h
blobbea2999bb21801f251ad69674909d51fd46e1120
1 /*
2 * CDDL HEADER START
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]
19 * CDDL HEADER END
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 #ifndef _HANDLE_H
27 #define _HANDLE_H
31 // Forward Declarations
32 class Handle;
33 class HandlePort;
35 #include "Lockable.h"
36 #include "HBA.h"
37 #include "HandlePort.h"
38 #include <map>
39 #include <hbaapi.h>
40 #include <hbaapi-sun.h>
43 /**
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 {
51 public:
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); };
69 void refresh();
71 HBA_ADAPTERATTRIBUTES getHBAAttributes();
72 int doForceLip();
73 HBA_ADAPTERATTRIBUTES npivGetHBAAttributes();
74 HBA_PORTATTRIBUTES getPortAttributes(uint64_t wwn);
76 private:
77 HBA *hba;
78 HBA_HANDLE id;
79 MODE modeVal;
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 */