fcoeadm.c revision 2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41
/*
* 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 "fcinfo.h"
#include <libintl.h>
#include <fcntl.h>
#include <errno.h>
#include <assert.h>
#include <ctype.h>
#include <stddef.h>
#include <strings.h>
#include <libfcoe.h>
#include <libscf.h>
#include <syslog.h>
static const char *FCOE_DRIVER_PATH = "/devices/fcoe:admin";
static char *
int j;
buf[0] = '\0';
for (j = 0; j < 16; j += 2) {
}
return (buf);
}
static int
isValidWWN(char *wwn)
{
int index;
return (0);
}
return (0);
}
continue;
}
return (0);
}
return (1);
}
{
}
/*
* prints out all the HBA port information
*/
void
{
int i;
return;
}
for (i = 0; i < 6; i++) {
}
for (i = 0; i < 6; i++) {
}
}
/*
* Initialize scf fcoe service access
* handle - returned handle
* service - returned service handle
*/
static int
{
int ret;
scf_strerror(scf_error()));
ret = FCOE_ERROR;
goto err;
}
scf_strerror(scf_error()));
ret = FCOE_ERROR;
goto err;
}
scf_strerror(scf_error()));
ret = FCOE_ERROR;
goto err;
}
scf_strerror(scf_error()));
ret = FCOE_ERROR;
goto err;
}
scf_strerror(scf_error()));
ret = FCOE_ERROR;
goto err;
}
scf_strerror(scf_error()));
goto err;
}
return (FCOE_SUCCESS);
err:
}
}
}
return (ret);
}
static int
{
int ret = FCOE_SUCCESS;
int lastAlloc = 0;
char buf[FCOE_PORT_LIST_LENGTH] = {0};
char memberName[FCOE_PORT_LIST_LENGTH] = {0};
int i = 0;
int valueArraySize = 0;
int commitRet;
if (ret != FCOE_SUCCESS) {
goto out;
}
ret = FCOE_ERROR;
goto out;
}
/* get property group or create it */
if ((scf_error() == SCF_ERROR_NOT_FOUND)) {
scf_strerror(scf_error()));
ret = FCOE_ERROR;
} else {
createProp = B_TRUE;
}
} else {
scf_strerror(scf_error()));
ret = FCOE_ERROR;
}
if (ret != FCOE_SUCCESS) {
goto out;
}
}
/* to make sure property exists */
if (createProp == B_FALSE) {
if ((scf_error() == SCF_ERROR_NOT_FOUND)) {
createProp = B_TRUE;
} else {
scf_strerror(scf_error()));
ret = FCOE_ERROR;
goto out;
}
}
}
/* Begin the transaction */
scf_strerror(scf_error()));
ret = FCOE_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 = FCOE_ERROR;
}
goto out;
}
} else {
"transaction property change failed - %s",
scf_strerror(scf_error()));
ret = FCOE_ERROR;
goto out;
}
scf_strerror(scf_error()));
ret = FCOE_ERROR;
goto out;
}
if (valueLookup == NULL) {
scf_strerror(scf_error()));
ret = FCOE_ERROR;
goto out;
}
scf_strerror(scf_error()));
ret = FCOE_ERROR;
goto out;
}
char *macnameIter = NULL;
char buftmp[FCOE_PORT_LIST_LENGTH] = {0};
scf_strerror(scf_error()));
ret = FCOE_ERROR;
break;
}
if (addRemoveFlag == FCOE_SCF_ADD) {
break;
} else {
continue;
}
}
scf_strerror(scf_error()));
ret = FCOE_ERROR;
break;
}
scf_strerror(scf_error()));
ret = FCOE_ERROR;
break;
}
scf_strerror(scf_error()));
ret = FCOE_ERROR;
break;
}
i++;
if (i >= lastAlloc) {
ret = FCOE_ERROR;
break;
}
}
}
}
valueArraySize = i;
}
if (ret != FCOE_SUCCESS) {
goto out;
}
if (addRemoveFlag == FCOE_SCF_ADD) {
/*
* Now create the new entry
*/
scf_strerror(scf_error()));
ret = FCOE_ERROR;
goto out;
} else {
}
/*
* Set the new member name
*/
scf_strerror(scf_error()));
ret = FCOE_ERROR;
goto out;
}
/*
* Add the new member
*/
scf_strerror(scf_error()));
ret = FCOE_ERROR;
goto out;
}
}
scf_strerror(scf_error()));
if (commitRet == 0) {
} else {
ret = FCOE_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);
}
int
{
FCOE_UINT8 promiscuous = 0;
/* check the mac name operand */
case 'i':
createini = 1;
break;
case 't':
createtgt = 1;
break;
case 'p':
gettext("Error: Invalid Port WWN\n"));
return (1);
}
break;
case 'n':
gettext("Error: Invalid Node WWN\n"));
return (1);
}
break;
case 'f':
promiscuous = 1;
break;
default:
return (1);
}
}
"not be both specified\n");
return (1);
}
if (status != FCOE_STATUS_OK) {
switch (status) {
case FCOE_STATUS_ERROR_BUSY:
gettext("Error: fcoe driver is busy\n"));
break;
gettext("Error: Existing FCoE port "
"found on the specified MAC link\n"));
break;
case FCOE_STATUS_ERROR_PERM:
gettext("Error: Not enough permission to "
"open fcoe device\n"));
break;
gettext("Error: Failed to open fcoe device\n"));
break;
gettext("Error: Port WWN is same as Node "
"WWN\n"));
break;
gettext("Error: MAC name exceeds maximum "
"length\n"));
break;
gettext("Error: The specified Port WWN "
"is already in use\n"));
break;
gettext("Error: The specified Node WWN "
"is already in use\n"));
break;
gettext("Error: MTU size of the specified "
"MAC link needs to be increased to 2500 "
"or above\n"));
break;
gettext("Error: Out of memory\n"));
break;
gettext("Error: Failed to open the "
"specified MAC link\n"));
break;
gettext("Error: Failed to create FCoE "
"port on the specified MAC link\n"));
break;
gettext("Error: VNIC is not supported\n"));
break;
case FCOE_STATUS_ERROR:
default:
}
return (1);
} else {
fcoe_adm_add_remove_scf_entry((char *)macLinkName,
return (0);
}
}
int
{
/* check the mac name operand */
if (status != FCOE_STATUS_OK) {
switch (status) {
case FCOE_STATUS_ERROR_BUSY:
gettext("Error: fcoe driver is busy\n"));
break;
gettext("Error: FCoE port not found on the "
"specified MAC link\n"));
break;
case FCOE_STATUS_ERROR_PERM:
gettext("Error: Not enough permission to "
"open fcoe device\n"));
break;
gettext("Failed: MAC name exceeds maximum "
"length 32\n"));
break;
gettext("Error: Failed to open fcoe device\n"));
break;
gettext("Error: FCoE port not found on the "
"specified MAC link\n"));
break;
gettext("Error: Please use stmfadm to offline "
"the FCoE target first\n"));
break;
case FCOE_STATUS_ERROR:
default:
}
return (1);
} else {
fcoe_adm_add_remove_scf_entry((char *)macLinkName,
"",
"",
0,
0,
return (0);
}
}
int
{
int i;
int ret;
case 'i':
showini = 1;
break;
case 't':
showtgt = 1;
break;
default:
return (1);
}
}
showini = 1;
showtgt = 1;
}
if (status != FCOE_STATUS_OK) {
switch (status) {
case FCOE_STATUS_ERROR_BUSY:
gettext("Error: fcoe driver is busy\n"));
break;
case FCOE_STATUS_ERROR_PERM:
gettext("Error: Not enough permission to "
"open fcoe device\n"));
break;
gettext("Error: Failed to open fcoe device\n"));
break;
gettext("Error: Invalid argument\n"));
break;
gettext("Error: More data\n"));
break;
case FCOE_STATUS_ERROR:
default:
}
ret = 1;
} else {
if (port_num == 0) {
} else {
for (i = 0; i < port_num; i++) {
printFCOEPortInfo(&portlist[i]);
}
}
}
ret = 0;
}
}
return (ret);
}
int
{
char buf[FCOE_PORT_LIST_LENGTH] = {0};
int commitRet;
int create_target = 0, create_initiator = 0;
/* Check what type of port list will be created */
case 'i':
create_initiator = 1;
break;
case 't':
create_target = 1;
break;
default:
return (1);
}
}
if (create_initiator == 0 && create_target == 0) {
create_initiator = 1;
create_target = 1;
}
if (commitRet != FCOE_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;
}
int is_target, is_promiscuous;
scf_strerror(scf_error()));
break;
}
if ((!create_target && is_target) ||
(!create_initiator && !is_target)) {
continue;
}
}
out:
/*
* Free resources
*/
}
}
}
}
}
}
}
if (valueLookup != NULL) {
}
return (0);
}