/*
* 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
*/
/*
*/
#include <limits.h>
#include <ctype.h>
#include <fcntl.h>
#include <errno.h>
#include <unistd.h>
#include <strings.h>
#include <libintl.h>
#include <libscf.h>
#include <libnvpair.h>
#include <libstmf.h>
#include <libsrpt.h>
#include "srpt_common.h"
/*
* Function: srpt_GetConfig()
*
* Parameters:
* cfg Current SRPT configuration in nvlist form
* token Configuration generation number. Use this token
* if updating the configuration with srpt_SetConfig.
*
* Return Values:
* 0 Success
* ENOMEM Could not allocate resources
* EINVAL Invalid parameter
*/
int
{
int ret = 0;
if (!cfg) {
return (EINVAL);
}
if (ret == STMF_STATUS_SUCCESS) {
ret = 0;
} else if (ret == STMF_ERROR_NOT_FOUND) {
/* Not initialized yet */
if (ret != 0) {
return (ret);
}
/* create the HCA list */
if (ret == 0) {
hcanv);
if (ret != 0) {
}
}
if (ret != 0) {
}
} else if (ret == STMF_ERROR_NOMEM) {
} else {
}
*token = stmf_token;
return (ret);
}
/*
* Function: srpt_SetConfig()
*
* Parameters:
* cfg SRPT configuration in nvlist form
* token Configuration generation number from srpt_GetConfig.
* Use this token to ensure the configuration hasn't been
* updated by another user since the time it was fetched.
*
* Return Values:
* 0 Success
* ENOMEM Could not allocate resources
* EINVAL Invalid parameter
* ECANCELED Configuration updated by another user
*/
int
{
int ret = 0;
if (ret == STMF_STATUS_SUCCESS) {
ret = 0;
} else if (ret == STMF_ERROR_NOMEM) {
} else if (ret == STMF_ERROR_PROV_DATA_STALE) {
} else {
}
return (ret);
}
/*
* Function: srpt_GetDefaultState()
*
* Parameters:
* enabled If B_TRUE, indicates that targets will be created for all
* discovered HCAs that have not been specifically disabled.
* If B_FALSE, targets will not be created unless the HCA has
* been specifically enabled. See also srpt_SetDefaultState().
*
* Return Values:
* 0 Success
* ENOMEM Could not allocate resources
* EINVAL Invalid parameter
*/
int
{
int ret;
return (EINVAL);
}
if (ret != 0) {
return (ret);
}
ret = 0;
}
}
return (ret);
}
/*
* Function: srpt_SetDefaultState()
*
* Parameters:
* enabled If B_TRUE, indicates that targets will be created for all
* discovered HCAs that have not been specifically disabled.
* If B_FALSE, targets will not be created unless the HCA has
* been specifically enabled. See also srpt_SetDefaultState().
*
* Return Values:
* 0 Success
* ENOMEM Could not allocate resources
* EINVAL Invalid parameter
*/
int
{
int ret;
if (ret != 0) {
return (ret);
}
if (ret != 0) {
return (ret);
}
}
enabled);
if (ret == 0) {
}
return (ret);
}
/*
* Function: srpt_SetTargetState()
*
* Parameters:
* hca_guid HCA GUID. See description of srpt_NormalizeGuid
* enabled If B_TRUE, indicates that a target will be created for
* this HCA when the SRPT SMF service is enabled. If B_FALSE,
* a target will not be created
*
* Return Values:
* 0 Success
* ENOMEM Could not allocate resources
* EINVAL Invalid parameter
*/
int
{
int ret;
return (EINVAL);
}
if (ret != 0) {
return (ret);
}
if (ret != 0) {
return (ret);
}
/* get the list of HCAs */
if (ret != 0) {
return (ret);
}
/* no entry yet */
if (ret == 0) {
}
}
if (ret == 0) {
enabled);
}
if (ret == 0) {
}
if (ret == 0) {
}
return (ret);
}
/*
* Function: srpt_GetTargetState()
*
* Parameters:
* hca_guid HCA GUID. See description of srpt_NormalizeGuid
* enabled If B_TRUE, indicates that a target will be created for
* this HCA when the SRPT SMF service is enabled. If B_FALSE,
* a target will not be created
*
* Return Values:
* 0 Success
* ENOMEM Could not allocate resources
* EINVAL Invalid parameter
*/
int
{
int ret;
return (EINVAL);
}
if (ret != 0) {
return (ret);
}
if (ret != 0) {
return (ret);
}
/* get the list of HCAs */
if (ret != 0) {
return (ret);
}
/*
* Find the default, for the likely case that this HCA isn't
* explicitly set.
*/
&defaultState);
if (ret == 0) {
enabled);
}
/* not explicitly set, use the default */
*enabled = defaultState;
ret = 0;
}
return (ret);
}
/*
* Function: srpt_ResetTarget()
*
* Clears the HCA-specific configuration. Target creation will revert to
* the default.
*
* Parameters:
* hca_guid HCA GUID. See description of srpt_NormalizeGuid
*
* Return Values:
* 0 Success
* ENOMEM Could not allocate resources
* EINVAL Invalid parameter
*/
int
{
int ret;
return (EINVAL);
}
if (ret != 0) {
return (ret);
}
if (ret != 0) {
return (ret);
}
/* get the list of HCAs */
if (ret != 0) {
return (ret);
}
/* don't set config if we don't actually change anything */
if (ret == 0) {
}
}
return (ret);
}
/*
* srpt_NormalizeGuid()
*
* Parameters:
* in HCA GUID. Must be in one of the following forms:
* 3BA000100CD18 - base hex form
* 0003BA000100CD18 - base hex form with leading zeroes
* eui.0003BA000100CD18 - EUI form
*
* buf Buffer to hold normalized guid string. Must be at least
* 17 chars long.
* buflen Length of provided buffer
* int_guid Optional. If not NULL, the integer form of the GUID will also
* be returned.
* Return Values:
* 0 Success
* EINVAL Invalid HCA GUID or invalid parameter.
*/
int
{
return (EINVAL);
}
/* EUI form */
bufp += 4;
bufp += 4;
}
/*
* strtoull() does not return EINVAL as documented. Lucky
* for us, neither 0 nor ULLONG_MAX will be valid. Trap on
* those and fail.
*/
return (EINVAL);
}
#if 0
#endif
if (int_guid) {
}
return (0);
}