xref: /titanic_41/usr/src/lib/sun_fc/common/HBA.h (revision ee9c203b1f94e95f194b035c4166c79fab792a78)
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	_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 HBA_ADAPTERATTRIBUTES	npivGetHBAAttributes() = 0;
65 	void				setRNID(HBA_MGMTINFO info);
66 	/*
67 	 * Fetch the name, excluding the trailing "-" and index number
68 	 */
69 	virtual std::string		getName() = 0;
70 
71 	void				validatePresent();
72 
73 	HBAPort*			getPortByIndex(int index);
74 	uint8_t				getNumberOfPorts();
75 
76 	// Utility routines: Could be moved elsewhere
77 	// Each routine throws exceptions on error (and logs)
78 	static int			_open(std::string path, int flag);
79 	static void			_ioctl(int fd, int type, uchar_t *arg);
80 
81 private:
82 	std::map<uint64_t, HBAPort *>	portsByWWN;
83 	std::vector<HBAPort*>		portsByIndex;
84 };
85 
86 
87 #endif /* _HBA_H */
88