xref: /titanic_41/usr/src/lib/sun_fc/common/HBA.h (revision b3697b90e692e3e5d859fb77d285d4c056d99eda)
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 2009 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_HBA_H
27 #define	_HBA_H
28 
29 
30 
31 // Forward declarations
32 class HBA;
33 class HBAPort;
34 
35 #include "Lockable.h"
36 #include "HBAPort.h"
37 #include <map>
38 #include <string>
39 #include <vector>
40 #include <map>
41 #include <hbaapi.h>
42 #include <hbaapi-sun.h>
43 
44 
45 /*
46  * @memo	    Used to track an individual HBA
47  * @see		    HBAList
48  *
49  * @doc		    During discovery, as HBAs are found on the system,
50  *		    instances of this class will be created, and stored
51  *		    in the HBAList class.
52  */
53 class HBA : public Lockable {
54 public:
55 	HBA() {}
56 	virtual ~HBA();
57 	bool				operator == (HBA &comp);
58 	static const uint8_t		HBA_PORT_MAX;
59 	void				addPort(HBAPort* port);
60 	HBAPort*			getPort(uint64_t wwn);
61 	bool				containsWWN(uint64_t wwn);
62 
63 	virtual HBA_ADAPTERATTRIBUTES	getHBAAttributes() = 0;
64 	virtual int			doForceLip() = 0;
65 	virtual HBA_ADAPTERATTRIBUTES	npivGetHBAAttributes() = 0;
66 	void				setRNID(HBA_MGMTINFO info);
67 	/*
68 	 * Fetch the name, excluding the trailing "-" and index number
69 	 */
70 	virtual std::string		getName() = 0;
71 
72 	void				validatePresent();
73 
74 	HBAPort*			getPortByIndex(int index);
75 	uint8_t				getNumberOfPorts();
76 
77 	// Utility routines: Could be moved elsewhere
78 	// Each routine throws exceptions on error (and logs)
79 	static int			_open(std::string path, int flag);
80 	static void			_ioctl(int fd, int type, uchar_t *arg);
81 
82 private:
83 	std::map<uint64_t, HBAPort *>	portsByWWN;
84 	std::vector<HBAPort*>		portsByIndex;
85 };
86 
87 
88 #endif /* _HBA_H */
89