xref: /onnv-gate/usr/src/lib/sun_fc/common/Handle.h (revision 10275:f0b35eb34c31)
17836SJohn.Forte@Sun.COM /*
27836SJohn.Forte@Sun.COM  * CDDL HEADER START
37836SJohn.Forte@Sun.COM  *
47836SJohn.Forte@Sun.COM  * The contents of this file are subject to the terms of the
57836SJohn.Forte@Sun.COM  * Common Development and Distribution License (the "License").
67836SJohn.Forte@Sun.COM  * You may not use this file except in compliance with the License.
77836SJohn.Forte@Sun.COM  *
87836SJohn.Forte@Sun.COM  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97836SJohn.Forte@Sun.COM  * or http://www.opensolaris.org/os/licensing.
107836SJohn.Forte@Sun.COM  * See the License for the specific language governing permissions
117836SJohn.Forte@Sun.COM  * and limitations under the License.
127836SJohn.Forte@Sun.COM  *
137836SJohn.Forte@Sun.COM  * When distributing Covered Code, include this CDDL HEADER in each
147836SJohn.Forte@Sun.COM  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157836SJohn.Forte@Sun.COM  * If applicable, add the following below this CDDL HEADER, with the
167836SJohn.Forte@Sun.COM  * fields enclosed by brackets "[]" replaced with your own identifying
177836SJohn.Forte@Sun.COM  * information: Portions Copyright [yyyy] [name of copyright owner]
187836SJohn.Forte@Sun.COM  *
197836SJohn.Forte@Sun.COM  * CDDL HEADER END
207836SJohn.Forte@Sun.COM  */
217836SJohn.Forte@Sun.COM /*
22*10275SReed.Liu@Sun.COM  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
237836SJohn.Forte@Sun.COM  * Use is subject to license terms.
247836SJohn.Forte@Sun.COM  */
257836SJohn.Forte@Sun.COM 
267836SJohn.Forte@Sun.COM #ifndef	_HANDLE_H
277836SJohn.Forte@Sun.COM #define	_HANDLE_H
287836SJohn.Forte@Sun.COM 
297836SJohn.Forte@Sun.COM 
307836SJohn.Forte@Sun.COM 
317836SJohn.Forte@Sun.COM // Forward Declarations
327836SJohn.Forte@Sun.COM class Handle;
337836SJohn.Forte@Sun.COM class HandlePort;
347836SJohn.Forte@Sun.COM 
357836SJohn.Forte@Sun.COM #include "Lockable.h"
367836SJohn.Forte@Sun.COM #include "HBA.h"
377836SJohn.Forte@Sun.COM #include "HandlePort.h"
387836SJohn.Forte@Sun.COM #include <map>
397836SJohn.Forte@Sun.COM #include <hbaapi.h>
407836SJohn.Forte@Sun.COM #include <hbaapi-sun.h>
417836SJohn.Forte@Sun.COM 
427836SJohn.Forte@Sun.COM 
437836SJohn.Forte@Sun.COM /**
447836SJohn.Forte@Sun.COM  * @memo	    Represents an open HBA port
457836SJohn.Forte@Sun.COM  *
467836SJohn.Forte@Sun.COM  * @doc		    This class represents an open HBA.  However,
477836SJohn.Forte@Sun.COM  *		    what we really care about is the HBA port's underneath.
487836SJohn.Forte@Sun.COM  *		    So, we also track HandlePorts internally.
497836SJohn.Forte@Sun.COM  */
507836SJohn.Forte@Sun.COM class Handle : public Lockable {
517836SJohn.Forte@Sun.COM public:
527836SJohn.Forte@Sun.COM     enum MODE { INITIATOR, TARGET };
537836SJohn.Forte@Sun.COM     Handle(HBA *hba); // Generate ID, and add to vector
547836SJohn.Forte@Sun.COM     //    Handle(HBA *hba, MODE m); // Generate ID based on target or initiator mode
557836SJohn.Forte@Sun.COM     ~Handle(); // Free and remove from vector
567836SJohn.Forte@Sun.COM 
577836SJohn.Forte@Sun.COM     static Handle*	    findHandle(HBA_HANDLE index);
587836SJohn.Forte@Sun.COM     static Handle*	    findHandle(uint64_t wwn);
597836SJohn.Forte@Sun.COM     static void		    closeHandle(HBA_HANDLE index);
607836SJohn.Forte@Sun.COM 
617836SJohn.Forte@Sun.COM     HBA_HANDLE		    getHandle();
627836SJohn.Forte@Sun.COM 
637836SJohn.Forte@Sun.COM     bool		    operator==(Handle comp);
647836SJohn.Forte@Sun.COM 
getHBA()657836SJohn.Forte@Sun.COM     HBA*		    getHBA() { return (hba); }
667836SJohn.Forte@Sun.COM     HandlePort*		    getHandlePortByIndex(int index);
677836SJohn.Forte@Sun.COM     HandlePort*		    getHandlePort(uint64_t wwn);
getMode()687836SJohn.Forte@Sun.COM     MODE		    getMode() { return (modeVal); };
697836SJohn.Forte@Sun.COM     void		    refresh();
707836SJohn.Forte@Sun.COM 
717836SJohn.Forte@Sun.COM     HBA_ADAPTERATTRIBUTES	    getHBAAttributes();
72*10275SReed.Liu@Sun.COM     int				    doForceLip();
737836SJohn.Forte@Sun.COM     HBA_ADAPTERATTRIBUTES	    npivGetHBAAttributes();
747836SJohn.Forte@Sun.COM     HBA_PORTATTRIBUTES		    getPortAttributes(uint64_t wwn);
757836SJohn.Forte@Sun.COM 
767836SJohn.Forte@Sun.COM private:
777836SJohn.Forte@Sun.COM     HBA				    *hba;
787836SJohn.Forte@Sun.COM     HBA_HANDLE			    id;
797836SJohn.Forte@Sun.COM     MODE			    modeVal;
807836SJohn.Forte@Sun.COM     static pthread_mutex_t	    staticLock;
817836SJohn.Forte@Sun.COM 
827836SJohn.Forte@Sun.COM     static HBA_HANDLE		    prevOpen;
837836SJohn.Forte@Sun.COM     static HBA_HANDLE		    prevTgtOpen;
847836SJohn.Forte@Sun.COM     static std::map<HBA_HANDLE, Handle*>    openHandles;
857836SJohn.Forte@Sun.COM     std::map<uint64_t, HandlePort*>	    portHandles;
867836SJohn.Forte@Sun.COM };
877836SJohn.Forte@Sun.COM 
887836SJohn.Forte@Sun.COM #endif /* _HANDLE_H */
89