HBAList.cc revision f3aaec0a97c3584095582719a0149d5e94c06ea2
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include "HBAList.h"
#include "Exceptions.h"
#include "Trace.h"
#include "sun_fc_version.h"
#include <string>
#include <sstream>
#include "FCHBA.h"
#include "TgtFCHBA.h"
#include <cstring>
#include <climits>
#include <cstdlib>
using namespace std;
/**
* @memo Private constructor (used to create singleton instance)
* @see HBAList::instance
*/
/**
* Internal singleton instance
*/
/**
* Max number of adapters that this class supports.
*/
/**
* @memo Free up resources held by this HBA list
* @postcondition All memory used by this list will be freed
* @return HBA_STATUS_OK on success
*
*/
lock();
unlock();
return (HBA_STATUS_OK);
}
/**
* @memo Fetch the singleton instance
* @return The singleton instance
*
* @doc Only one instance of HBAList must be present
* per address space at a time. The singleton design pattern
* is used to enforce this behavior.
*/
if (_instance == 0) {
}
return (_instance);
}
/**
* @memo Fetch an HBA based on name.
* Always returns non-null or throw an Exception.
* @precondition HBAs must be loaded in the list
* @postcondition A handle will be opened. The caller must close the handle
* at some later time to prevent leakage.
* @exception BadArgumentException if the name is not properly formatted
* @exception IllegalIndexException if the name does not match any
* present HBAs within this list.
* @return A valid handle for future API calls
* @param name The name of the HBA to open
*
* @doc This routine will always return a handle (ie, non null)
* or will throw an exception.
*/
int index = -1;
try {
if (offset >= 0) {
}
} catch (...) {
throw BadArgumentException();
}
lock();
unlock();
throw IllegalIndexException();
} else {
unlock();
tmp->validatePresent();
}
}
/**
* @memo Fetch an target mode FC HBA based on name.
* Always returns non-null or throw an Exception.
* @precondition Target mode HBAs must be loaded in the list
* @postcondition A handle will be opened. The caller must close the handle
* at some later time to prevent leakage.
* @exception BadArgumentException if the name is not properly formatted
* @exception IllegalIndexException if the name does not match any
* present HBAs within this list.
* @return A valid handle for future API calls
* @param name The name of the target mode HBA to open
*
* @doc This routine will always return a handle (ie, non null)
* or will throw an exception.
*/
int index = -1;
try {
if (offset >= 0) {
}
} catch (...) {
throw BadArgumentException();
}
lock();
unlock();
throw IllegalIndexException();
} else {
unlock();
tmp->validatePresent();
}
}
/**
* @memo Get the name of an HBA at the given index
* @precondition HBAs must be loaded in the list
* @exception IllegalIndexException Thrown if the index doesn't match any
* HBA in the list
* @return The name of the specified HBA
* @param index The zero based index of the desired HBA
*
*/
lock();
unlock();
throw IllegalIndexException();
} else {
unlock();
tmp->validatePresent();
char buf[128];
return (name);
}
}
/**
* @memo Get the name of an target mode HBA at the given index
* @precondition Target mode HBAs must be loaded in the list
* @exception IllegalIndexException Thrown if the index doesn't match any
* HBA in the list
* @return The name of the specified target mode HBA
* @param index The zero based index of the desired target mode HBA
*
*/
lock();
unlock();
throw IllegalIndexException();
} else {
unlock();
tmp->validatePresent();
char buf[128];
return (name);
}
}
/**
* @memo Open an HBA based on a WWN
* @precondition HBAs must be loaded in the list
* @postcondition A handle will be opened. The caller must close the handle
* at some later time to prevent leakage.
* @exception IllegalWWNException Thrown if the wwn doesn't match any
* HBA in the list
* @return A valid Handle for later use by API calls
* @param wwn The node or any port WWN of HBA to open
* @see HBA::containsWWN
*
* @doc This routine will accept both Node and Port WWNs based
* on the HBA routine containsWWN
*/
lock();
unlock();
tmp->validatePresent();
}
}
unlock();
throw IllegalWWNException();
}
/**
* @memo Open an target mode HBA based on a WWN
* @precondition Targee mode HBAs must be loaded in the list
* @postcondition A handle will be opened. The caller must close the handle
* at some later time to prevent leakage.
* @exception IllegalWWNException Thrown if the wwn doesn't match any
* target mode HBA in the list
* @return A valid Handle for later use by API calls
* @param The node WWN or any port WWN of target mode HBA to open
* @see HBA::containsWWN
*
* @doc This routine will accept both Node and Port WWNs based
* on the HBA routine containsWWN
*/
lock();
unlock();
tmp->validatePresent();
}
}
unlock();
throw IllegalWWNException();
}
/**
* @memo Get the number of adapters present in the list
* @postcondition List of HBAs will be loaded
* @exception ... Underlying exceptions will be thrown
* @return The number of adapters in the list
*
* @doc This routine will triger discovery of HBAs on the system.
* based on dynamic reconfiguration operations. The max
* number of HBAs that HBA API supports is up to the
* uint32_t size. VSL supports up to int32_t size thus
* it gives enough room for the HBA API library
* to handle up to max uint32_t number if adapters.
*/
int HBAList::getNumberofAdapters() {
lock();
try {
// First pass, just store them all blindly
} else {
// Second pass, do the update operation
bool matched;
matched = false;
matched = true;
break;
}
}
if (matched) {
delete (tmp[i]);
} else {
}
}
}
} catch (...) {
unlock();
throw;
}
unlock();
// When there is more than HBA_MAX_PER_LIST(= int32_max)
// VSL returns an error so it is safe to cast it here.
}
/**
* @memo Get the number of target mode adapters present in the list
* @postcondition List of TgtHBAs will be loaded
* @exception ... Underlying exceptions will be thrown
* @return The number of target mode adapters in the list
*
* @doc This routine will triger discovery of Target mode HBAs on
* mode HBAs in the list based on dynamic reconfiguration
* operations. The max number of target mode HBAs that
* HBA API supports is up to the
* uint32_t size. VSL supports up to int32_t size thus
* it gives enough room for the HBA API library
* to handle up to max uint32_t number of adapters.
*/
int HBAList::getNumberofTgtAdapters() {
lock();
try {
// First pass, just store them all blindly
} else {
// Second pass, do the update operation
bool matched;
matched = false;
matched = true;
break;
}
}
if (matched) {
delete (tmp[i]);
} else {
}
}
}
} catch (...) {
unlock();
throw;
}
unlock();
// When there is more than HBA_MAX_PER_LIST(= int32_max)
// VSL returns an error so it is safe to cast it here.
}
/**
* @memo Load the list
* @return HBA_STATUS_OK
*
* @doc Currently this routine is a no-op and may be a cantidate
* for removal in the future.
*/
// No lock is required since no VSL specific action requried.
return (HBA_STATUS_OK);
}
/**
* @memo Free up resources
*/
delete (hbas[i]);
}
delete (tgthbas[i]);
}
}
char build_time[] = BUILD_TIME;
return (attrs);
}