2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License (the "License").
2N/A * You may not use this file except in compliance with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A */
2N/A/*
2N/A * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
2N/A */
2N/A
2N/A#ifndef _HANDLE_H
2N/A#define _HANDLE_H
2N/A
2N/A
2N/A
2N/A// Forward Declarations
2N/Aclass Handle;
2N/Aclass HandlePort;
2N/A
2N/A#include "Lockable.h"
2N/A#include "HBA.h"
2N/A#include "HandlePort.h"
2N/A#include <map>
2N/A#include <hbaapi.h>
2N/A#include <hbaapi-sun.h>
2N/A
2N/A
2N/A/*
2N/A * @memo Represents an open HBA port
2N/A *
2N/A * @doc This class represents an open HBA. However,
2N/A * what we really care about is the HBA port's underneath.
2N/A * So, we also track HandlePorts internally.
2N/A */
2N/Aclass Handle : public Lockable {
2N/Apublic:
2N/A enum MODE { INITIATOR, TARGET };
2N/A Handle(HBA *hba, int portIndex = 0); // Generate ID, and add to vector
2N/A ~Handle(); // Free and remove from vector
2N/A
2N/A static Handle* findHandle(HBA_HANDLE index);
2N/A static Handle* findHandle(uint64_t wwn);
2N/A static void closeHandle(HBA_HANDLE index);
2N/A
2N/A HBA_HANDLE getHandle();
2N/A
2N/A bool operator == (Handle comp);
2N/A
2N/A HBA* getHBA() { return (hba); }
2N/A HandlePort* getHandlePortByIndex(int index);
2N/A HandlePort* getHandlePort(uint64_t wwn);
2N/A MODE getMode() { return (modeVal); };
2N/A void refresh();
2N/A
2N/A HBA_ADAPTERATTRIBUTES getHBAAttributes();
2N/A int doForceLip();
2N/A HBA_ADAPTERATTRIBUTES npivGetHBAAttributes();
2N/A HBA_PORTATTRIBUTES getPortAttributes(uint64_t wwn);
2N/A
2N/Aprivate:
2N/A HBA *hba;
2N/A HBA_HANDLE id;
2N/A MODE modeVal;
2N/A // portIndexForHandle is used in special cases that the
2N/A // Handle is explictly used for a specified port
2N/A int portIndexForHandle;
2N/A static pthread_mutex_t staticLock;
2N/A
2N/A static HBA_HANDLE prevOpen;
2N/A static HBA_HANDLE prevTgtOpen;
2N/A static std::map < HBA_HANDLE, Handle* > openHandles;
2N/A std::map < uint64_t, HandlePort* > portHandles;
2N/A};
2N/A
2N/A#endif /* _HANDLE_H */