/*
* 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 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <libscf.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <syslog.h>
#include <strings.h>
#include <ctype.h>
#include <fcinfo.h>
static char *
int j;
buf[0] = '\0';
for (j = 0; j < 16; j += 2) {
}
return (buf);
}
static int
{
int index;
return (0);
}
return (0);
}
continue;
}
return (0);
}
return (1);
}
/*
* Initialize scf stmf service access
* handle - returned handle
* service - returned service handle
*/
static int
{
int ret;
/* log error */
ret = NPIV_ERROR;
goto err;
}
/* log error */
ret = NPIV_ERROR;
goto err;
}
/* log error */
ret = NPIV_ERROR;
goto err;
}
/* log error */
ret = NPIV_ERROR;
goto err;
}
/* log error */
ret = NPIV_ERROR;
goto err;
}
/* log error */
goto err;
}
return (NPIV_SUCCESS);
err:
}
}
}
return (ret);
}
static int
int lastAlloc = 0;
int i = 0;
int valueArraySize = 0;
int commitRet;
if (vnwwn) {
} else {
}
if (ret != NPIV_SUCCESS) {
goto out;
}
ret = NPIV_ERROR;
goto out;
}
/* get property group or create it */
if ((scf_error() == SCF_ERROR_NOT_FOUND) &&
(addRemoveFlag == NPIV_ADD)) {
scf_strerror(scf_error()));
ret = NPIV_ERROR;
} else {
createProp = B_TRUE;
}
} else if (scf_error() == SCF_ERROR_NOT_FOUND) {
} else {
scf_strerror(scf_error()));
ret = NPIV_ERROR;
}
if (ret != NPIV_SUCCESS) {
goto out;
}
}
/* Begin the transaction */
scf_strerror(scf_error()));
ret = NPIV_ERROR;
goto out;
}
* (lastAlloc = PORT_LIST_ALLOC));
goto out;
}
if (createProp) {
SCF_TYPE_USTRING) == -1) {
if (scf_error() == SCF_ERROR_EXISTS) {
} else {
"transaction property new failed - %s",
scf_strerror(scf_error()));
ret = NPIV_ERROR;
}
goto out;
}
} else {
"transaction property change failed - %s",
scf_strerror(scf_error()));
ret = NPIV_ERROR;
goto out;
}
scf_strerror(scf_error()));
ret = NPIV_ERROR;
goto out;
}
if (valueLookup == NULL) {
scf_strerror(scf_error()));
ret = NPIV_ERROR;
goto out;
}
scf_strerror(scf_error()));
ret = NPIV_ERROR;
goto out;
}
scf_strerror(scf_error()));
ret = NPIV_ERROR;
break;
}
if (addRemoveFlag == NPIV_ADD) {
break;
} else {
continue;
}
}
scf_strerror(scf_error()));
ret = NPIV_ERROR;
break;
}
scf_strerror(scf_error()));
ret = NPIV_ERROR;
break;
}
scf_strerror(scf_error()));
ret = NPIV_ERROR;
break;
}
i++;
if (i >= lastAlloc) {
ret = NPIV_ERROR;
break;
}
}
}
}
valueArraySize = i;
}
if (ret != NPIV_SUCCESS) {
goto out;
}
if (addRemoveFlag == NPIV_ADD) {
/*
* Now create the new entry
*/
scf_strerror(scf_error()));
ret = NPIV_ERROR;
goto out;
} else {
}
/*
* Set the new member name
*/
scf_strerror(scf_error()));
ret = NPIV_ERROR;
goto out;
}
/*
* Add the new member
*/
scf_strerror(scf_error()));
ret = NPIV_ERROR;
goto out;
}
}
scf_strerror(scf_error()));
if (commitRet == 0) {
} else {
ret = NPIV_ERROR;
}
goto out;
}
out:
/*
* Free resources
*/
}
}
}
}
}
}
}
if (valueLookup != NULL) {
}
/*
* Free valueSet scf resources
*/
if (valueArraySize > 0) {
for (i = 0; i < valueArraySize; i++) {
}
}
/*
* Now free the pointer array to the resources
*/
}
return (ret);
}
static int
int portCtr;
int times = 0;
/* argument checking */
return (1);
}
while ((status == HBA_STATUS_ERROR_TRY_AGAIN ||
status == HBA_STATUS_ERROR_BUSY) &&
times++ < 130) {
if (status == HBA_STATUS_OK) {
break;
}
(void) sleep(1);
}
if (status != HBA_STATUS_OK) {
return (1);
}
times = 0;
while ((status == HBA_STATUS_ERROR_TRY_AGAIN ||
status == HBA_STATUS_ERROR_BUSY) &&
times++ < HBA_MAX_RETRIES) {
if (status == HBA_STATUS_OK) {
break;
}
(void) sleep(1);
}
if (status != HBA_STATUS_OK) {
return (1);
}
break;
}
}
*portIndex = 0;
return (1);
}
times = 0;
while ((status == HBA_STATUS_ERROR_TRY_AGAIN ||
status == HBA_STATUS_ERROR_BUSY) &&
times++ < HBA_MAX_RETRIES) {
if (status == HBA_STATUS_OK) {
break;
}
(void) sleep(1);
}
if (status != HBA_STATUS_OK) {
return (1);
}
return (0);
}
int
{
int times;
if (wwnCount != 1) {
gettext("Invalid Parameter\n"));
return (1);
}
case 'p':
gettext("Invalid Port WWN\n"));
return (1);
}
break;
default:
return (1);
}
}
if (!isValidWWN(wwn_argv[0])) {
gettext("Invalid Physical Port WWN\n"));
return (1);
}
gettext("Failed to load FC-HBA common library\n"));
return (1);
}
if (status != HBA_STATUS_OK) {
gettext("Error: HBA port %s: not found\n"),
wwn_argv[0]);
return (1);
}
/* Get physical port NPIV attributes */
/* Check port NPIV attributes */
if (npivattrs.MaxNumberOfNPIVPorts == 0) {
gettext("Error: NPIV not Supported\n"));
return (1);
}
/* Delete a virtual port */
vportWWN);
times = 0;
while ((status == HBA_STATUS_ERROR_TRY_AGAIN ||
status == HBA_STATUS_ERROR_BUSY) &&
times++ < HBA_MAX_RETRIES) {
(void) sleep(1);
vportWWN);
if (status == HBA_STATUS_OK) {
break;
}
}
if (status != HBA_STATUS_OK) {
gettext("Error: failed to delete a npiv port\n"));
return (1);
}
} else {
gettext("Error: failed to get port NPIV attributes\n"));
return (1);
}
return (0);
}
int
{
int randomflag = 0;
int times;
if (wwnCount != 1) {
gettext("Invalid Parameter\n"));
return (1);
}
case 'p':
gettext("Invalid Port WWN\n"));
return (1);
}
randomflag++;
break;
case 'n':
gettext("Invalid Node WWN\n"));
return (1);
}
randomflag++;
break;
default:
return (1);
}
}
if (!isValidWWN(wwn_argv[0])) {
gettext("Invalid Physical Port WWN\n"));
wwnCount = 0;
return (1);
}
gettext("Failed to load FC-HBA common library\n"));
return (1);
}
if (status != HBA_STATUS_OK) {
gettext("Error: HBA port %s: not found\n"),
wwn_argv[0]);
return (1);
}
if (randomflag != 2) {
if (status != HBA_STATUS_OK) {
gettext("Error: Fail to get Random WWN\n"));
return (1);
}
} else {
}
gettext("Error: Port WWN is same as Node WWN\n"));
return (1);
}
/* Get physical port NPIV attributes */
/* Check port NPIV attributes */
if (npivattrs.MaxNumberOfNPIVPorts == 0) {
gettext("Error: NPIV not Supported\n"));
return (1);
}
if (npivattrs.MaxNumberOfNPIVPorts ==
gettext("Error: Can not create more NPIV port\n"));
return (1);
}
/* Create a virtual port */
times = 0;
while ((status == HBA_STATUS_ERROR_TRY_AGAIN ||
status == HBA_STATUS_ERROR_BUSY) &&
times++ < HBA_MAX_RETRIES) {
(void) sleep(1);
if (status == HBA_STATUS_OK) {
break;
}
}
if (status != HBA_STATUS_OK) {
gettext("Error: failed to create a npiv port\n"));
return (1);
}
} else {
gettext("Error: failed to get port NPIV attributes\n"));
return (1);
}
return (0);
}
int
{
int times = 0;
while (status == HBA_STATUS_ERROR_TRY_AGAIN ||
status == HBA_STATUS_ERROR_BUSY) {
(void) sleep(FCADM_SLEEP_TIME);
if (times++ > FCADM_RETRY_TIMES) {
return (1);
}
}
/* Get physical port NPIV attributes */
/* Check port NPIV attributes */
if (npivattrs.MaxNumberOfNPIVPorts == 0) {
goto failed;
}
if (npivattrs.MaxNumberOfNPIVPorts ==
goto failed;
}
/* Create a virtual port */
times = 0;
while (status == HBA_STATUS_ERROR_TRY_AGAIN ||
status == HBA_STATUS_ERROR_BUSY) {
(void) sleep(FCADM_SLEEP_TIME);
if (times++ > FCADM_RETRY_TIMES) {
goto failed;
}
}
}
return (0);
}
int
{
int commitRet;
if (commitRet != NPIV_SUCCESS) {
goto out;
}
goto out;
}
/* get property group or create it */
goto out;
}
scf_strerror(scf_error()));
goto out;
}
if (valueLookup == NULL) {
scf_strerror(scf_error()));
goto out;
}
scf_strerror(scf_error()));
goto out;
}
if (HBA_LoadLibrary() != HBA_STATUS_OK) {
goto out;
}
int vindex = 0;
scf_strerror(scf_error()));
break;
}
}
out:
/*
* Free resources
*/
}
}
}
}
}
}
}
if (valueLookup != NULL) {
}
return (0);
}
/* ARGSUSED */
int
{
int rval = 0;
return (1);
}
/*
* Try target mode first
*/
/*
* Continue to try initiator mode
*/
argv[0]);
return (0);
}
}
"link of HBA %s\n"), argv[0]);
}
return (0);
}