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	_HBALIST_H
27#define	_HBALIST_H
28
29
30
31#include "Lockable.h"
32#include "HBA.h"
33#include "Handle.h"
34#include <vector>
35#include <string>
36#include <hbaapi.h>
37
38/**
39 * @memo	    Singleton class that represents the entire list of HBAs
40 *		    known to the system.
41 *
42 * @doc		    This class and its single instance is used to track
43 *		    all the known HBAs on the system.  This class
44 *		    will gracefully handle dynamic reconfiguration
45 *		    in accordance with the FC-HBA specification.
46 *		    HBA_MAX_PER_LIST represents the maximum number of
47 *		    adapters that are supported by this class.
48 */
49class HBAList : public Lockable{
50public:
51    static HBAList*	    instance();
52    ~HBAList();
53    static const int32_t    HBA_MAX_PER_LIST;
54    HBA_STATUS		    load();
55    HBA_STATUS		    unload();
56    int			    getNumberofAdapters();
57    int			    getNumberofTgtAdapters();
58    std::string		    getHBAName(int index);
59    std::string		    getTgtHBAName(int index);
60    Handle*		    openHBA(std::string name);
61    Handle*		    openTgtHBA(std::string name);
62    Handle*		    openHBA(uint64_t wwn);
63    Handle*		    openTgtHBA(uint64_t wwn);
64    HBA_LIBRARYATTRIBUTES   getVSLAttributes();
65
66protected:
67    HBAList(); // Singleton
68
69    // Prevent ambiguity
70    using Lockable::lock;
71    using Lockable::unlock;
72
73private:
74    static HBAList*	    _instance;
75    std::vector<HBA*>	    hbas;
76    std::vector<HBA*>	    tgthbas;
77};
78
79#endif /* _HBALIST_H */
80