xref: /onnv-gate/usr/src/lib/sun_fc/common/FCSyseventBridge.h (revision 7836:4e95154b5b7a)
1*7836SJohn.Forte@Sun.COM /*
2*7836SJohn.Forte@Sun.COM  * CDDL HEADER START
3*7836SJohn.Forte@Sun.COM  *
4*7836SJohn.Forte@Sun.COM  * The contents of this file are subject to the terms of the
5*7836SJohn.Forte@Sun.COM  * Common Development and Distribution License (the "License").
6*7836SJohn.Forte@Sun.COM  * You may not use this file except in compliance with the License.
7*7836SJohn.Forte@Sun.COM  *
8*7836SJohn.Forte@Sun.COM  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*7836SJohn.Forte@Sun.COM  * or http://www.opensolaris.org/os/licensing.
10*7836SJohn.Forte@Sun.COM  * See the License for the specific language governing permissions
11*7836SJohn.Forte@Sun.COM  * and limitations under the License.
12*7836SJohn.Forte@Sun.COM  *
13*7836SJohn.Forte@Sun.COM  * When distributing Covered Code, include this CDDL HEADER in each
14*7836SJohn.Forte@Sun.COM  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*7836SJohn.Forte@Sun.COM  * If applicable, add the following below this CDDL HEADER, with the
16*7836SJohn.Forte@Sun.COM  * fields enclosed by brackets "[]" replaced with your own identifying
17*7836SJohn.Forte@Sun.COM  * information: Portions Copyright [yyyy] [name of copyright owner]
18*7836SJohn.Forte@Sun.COM  *
19*7836SJohn.Forte@Sun.COM  * CDDL HEADER END
20*7836SJohn.Forte@Sun.COM  */
21*7836SJohn.Forte@Sun.COM /*
22*7836SJohn.Forte@Sun.COM  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23*7836SJohn.Forte@Sun.COM  * Use is subject to license terms.
24*7836SJohn.Forte@Sun.COM  */
25*7836SJohn.Forte@Sun.COM 
26*7836SJohn.Forte@Sun.COM #ifndef	_FCSYSEVENTBRIDGE_H
27*7836SJohn.Forte@Sun.COM #define	_FCSYSEVENTBRIDGE_H
28*7836SJohn.Forte@Sun.COM 
29*7836SJohn.Forte@Sun.COM 
30*7836SJohn.Forte@Sun.COM 
31*7836SJohn.Forte@Sun.COM #include "AdapterAddEventBridge.h"
32*7836SJohn.Forte@Sun.COM #include "AdapterEventBridge.h"
33*7836SJohn.Forte@Sun.COM #include "AdapterPortEventBridge.h"
34*7836SJohn.Forte@Sun.COM #include "AdapterDeviceEventBridge.h"
35*7836SJohn.Forte@Sun.COM #include "TargetEventBridge.h"
36*7836SJohn.Forte@Sun.COM #include "Lockable.h"
37*7836SJohn.Forte@Sun.COM #include <vector>
38*7836SJohn.Forte@Sun.COM #include <libsysevent.h>
39*7836SJohn.Forte@Sun.COM 
40*7836SJohn.Forte@Sun.COM /**
41*7836SJohn.Forte@Sun.COM  * Note: Even though we take various arguments in within the API,
42*7836SJohn.Forte@Sun.COM  * we don't actually filter anything, since sys-even is either on
43*7836SJohn.Forte@Sun.COM  * or off.  The idea is that the actual Listener themselves will perform
44*7836SJohn.Forte@Sun.COM  * a final filter pass, so why do the work twice.  If we were going to
45*7836SJohn.Forte@Sun.COM  * use proprietary IOCTLs or some other event plumbing that allowed filtering,
46*7836SJohn.Forte@Sun.COM  * we could use the passed in arguments to do useful work.  In short,
47*7836SJohn.Forte@Sun.COM  * once turned on, we send events of a given type and rely on
48*7836SJohn.Forte@Sun.COM  * someone downstream to filter.
49*7836SJohn.Forte@Sun.COM  */
50*7836SJohn.Forte@Sun.COM class FCSyseventBridge :
51*7836SJohn.Forte@Sun.COM 	public AdapterAddEventBridge,
52*7836SJohn.Forte@Sun.COM 	public AdapterEventBridge,
53*7836SJohn.Forte@Sun.COM 	public AdapterPortEventBridge,
54*7836SJohn.Forte@Sun.COM 	public AdapterDeviceEventBridge,
55*7836SJohn.Forte@Sun.COM 	public TargetEventBridge,
56*7836SJohn.Forte@Sun.COM 	public Lockable {
57*7836SJohn.Forte@Sun.COM public:
58*7836SJohn.Forte@Sun.COM     static FCSyseventBridge* getInstance();
59*7836SJohn.Forte@Sun.COM     virtual int32_t getMaxListener();
60*7836SJohn.Forte@Sun.COM     virtual void addListener(AdapterAddEventListener *listener);
61*7836SJohn.Forte@Sun.COM     virtual void addListener(AdapterEventListener *listener, HBA *hba);
62*7836SJohn.Forte@Sun.COM     virtual void addListener(AdapterPortEventListener *listener, HBAPort *port);
63*7836SJohn.Forte@Sun.COM     virtual void addListener(AdapterDeviceEventListener *listener,
64*7836SJohn.Forte@Sun.COM 	     HBAPort *port);
65*7836SJohn.Forte@Sun.COM     virtual void addListener(TargetEventListener *listener,
66*7836SJohn.Forte@Sun.COM 	    HBAPort *port, uint64_t targetWWN, bool filter);
67*7836SJohn.Forte@Sun.COM     virtual void removeListener(AdapterAddEventListener *listener);
68*7836SJohn.Forte@Sun.COM     virtual void removeListener(AdapterEventListener *listener);
69*7836SJohn.Forte@Sun.COM     virtual void removeListener(AdapterPortEventListener *listener);
70*7836SJohn.Forte@Sun.COM     virtual void removeListener(AdapterDeviceEventListener *listener);
71*7836SJohn.Forte@Sun.COM     virtual void removeListener(TargetEventListener *listener);
72*7836SJohn.Forte@Sun.COM 
73*7836SJohn.Forte@Sun.COM     /* Private function, called by handler.  Friend maybe? */
74*7836SJohn.Forte@Sun.COM     void dispatch(sysevent_t *ev);
75*7836SJohn.Forte@Sun.COM 
76*7836SJohn.Forte@Sun.COM private:
FCSyseventBridge()77*7836SJohn.Forte@Sun.COM     FCSyseventBridge() :handle(NULL) { }
78*7836SJohn.Forte@Sun.COM     /**
79*7836SJohn.Forte@Sun.COM      * Subscribe if we need to, or unsubscribe if nobody is left
80*7836SJohn.Forte@Sun.COM      * Instance lock must already be held!
81*7836SJohn.Forte@Sun.COM      */
82*7836SJohn.Forte@Sun.COM     void validateRegistration();
83*7836SJohn.Forte@Sun.COM     sysevent_handle_t *handle;
84*7836SJohn.Forte@Sun.COM     static FCSyseventBridge*	_instance;
85*7836SJohn.Forte@Sun.COM 
86*7836SJohn.Forte@Sun.COM 
87*7836SJohn.Forte@Sun.COM     std::vector<AdapterAddEventListener*>	adapterAddEventListeners;
88*7836SJohn.Forte@Sun.COM     std::vector<AdapterEventListener*>		adapterEventListeners;
89*7836SJohn.Forte@Sun.COM     std::vector<AdapterPortEventListener*>	adapterPortEventListeners;
90*7836SJohn.Forte@Sun.COM     std::vector<AdapterDeviceEventListener*>	adapterDeviceEventListeners;
91*7836SJohn.Forte@Sun.COM     std::vector<TargetEventListener*>		targetEventListeners;
92*7836SJohn.Forte@Sun.COM };
93*7836SJohn.Forte@Sun.COM 
94*7836SJohn.Forte@Sun.COM #endif /* _FCSYSEVENTBRIDGE_H */
95