/*
* 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 <stdlib.h>
#include <stdio.h>
#include <wchar.h>
#include <strings.h>
#include <fcntl.h>
#include <unistd.h>
#include <libintl.h>
#include <errno.h>
#include <string.h>
#include <assert.h>
#include <syslog.h>
#include <libfcoe.h>
#include <libdllink.h>
#include <fcoeio.h>
#include <libscf.h>
#include <inttypes.h>
#define OPEN_FCOE 0
/*
* Open for fcoe module
*
* flag - open flag (OPEN_FCOE, OPEN_EXCL_FCOE)
* fd - pointer to integer. On success, contains the fcoe file descriptor
*/
static int
{
} else {
} else {
}
}
return (ret);
}
static void
int j;
buf[0] = '\0';
for (j = 0; j < 16; j += 2) {
}
}
static int
{
int i;
for (i = 0; i < size; i++) {
return (0);
}
}
return (1);
}
/*
* 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;
}
*service) == -1) {
scf_strerror(scf_error()));
goto err;
}
return (FCOE_SUCCESS);
err:
}
}
}
return (ret);
}
static int
{
int lastAlloc = 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 = portListAlloc));
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;
}
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);
}
const FCOE_UINT8 *macLinkName,
{
int fcoe_fd;
if (macLinkName == NULL) {
return (FCOE_STATUS_ERROR_INVAL_ARG);
}
return (FCOE_STATUS_ERROR_MAC_LEN);
}
return (FCOE_STATUS_ERROR);
}
(void) fcoe_add_remove_scf_entry((char *)macLinkName,
"",
"",
0,
return (FCOE_STATUS_ERROR_GET_LINKINFO);
}
if (class != DATALINK_CLASS_PHYS) {
return (FCOE_STATUS_ERROR_CLASS_UNSUPPORT);
}
if (portType != FCOE_PORTTYPE_INITIATOR &&
portType != FCOE_PORTTYPE_TARGET) {
return (FCOE_STATUS_ERROR_INVAL_ARG);
}
}
}
return (FCOE_STATUS_ERROR_WWN_SAME);
}
return (status);
}
switch (fcoeio.fcoeio_status) {
case FCOEIOE_INVAL_ARG:
break;
case FCOEIOE_BUSY:
break;
case FCOEIOE_ALREADY:
break;
case FCOEIOE_PWWN_CONFLICTED:
break;
case FCOEIOE_NWWN_CONFLICTED:
break;
case FCOEIOE_CREATE_MAC:
break;
case FCOEIOE_OPEN_MAC:
break;
case FCOEIOE_CREATE_PORT:
break;
case FCOEIOE_NEED_JUMBO_FRAME:
break;
default:
}
} else {
(void) fcoe_add_remove_scf_entry((char *)macLinkName,
}
return (status);
}
{
int fcoe_fd;
int io_ret = 0;
if (macLinkName == NULL) {
return (FCOE_STATUS_ERROR_INVAL_ARG);
}
return (FCOE_STATUS_ERROR_MAC_LEN);
}
return (FCOE_STATUS_ERROR);
}
return (FCOE_STATUS_ERROR_GET_LINKINFO);
}
return (status);
}
/* only 4 bytes here, need to change */
if (io_ret != 0) {
switch (fcoeio.fcoeio_status) {
case FCOEIOE_INVAL_ARG:
break;
case FCOEIOE_BUSY:
break;
case FCOEIOE_ALREADY:
break;
case FCOEIOE_MAC_NOT_FOUND:
break;
case FCOEIOE_OFFLINE_FAILURE:
break;
default:
}
} else {
(void) fcoe_add_remove_scf_entry((char *)macLinkName,
"",
"",
0,
}
if (io_ret == FCOEIOE_MAC_NOT_FOUND) {
(void) fcoe_add_remove_scf_entry((char *)macLinkName,
"",
"",
0,
0,
(void) fcoe_add_remove_scf_entry((char *)macLinkName,
"",
"",
1,
0,
}
return (status);
}
{
int fcoe_fd;
int i;
int retry = 0;
int bufsize;
return (FCOE_STATUS_ERROR_INVAL_ARG);
}
*port_num = 0;
return (status);
}
/* Get fcoe port list */
retry = 0;
do {
sizeof (fcoe_port_list_t);
}
switch (fcoeio.fcoeio_status) {
case FCOEIOE_INVAL_ARG:
return (status);
case FCOEIOE_BUSY:
retry++;
break;
case FCOEIOE_MORE_DATA:
retry++;
default:
return (status);
}
} else {
break;
}
}
for (i = 0; i < inportlist->numPorts; i++) {
!= DLADM_STATUS_OK) {
"<unknown>");
} else {
mac_name);
}
}
}
*portlist = outportlist;
} else {
*port_num = 0;
}
return (status);
}
{
int commitRet;
int pg_or_prop_not_found = 0;
if (commitRet != FCOE_SUCCESS) {
goto out;
}
goto out;
}
pg_or_prop_not_found = 1;
goto out;
}
pg_or_prop_not_found = 1;
goto out;
}
if (valueLookup == NULL) {
scf_strerror(scf_error()));
goto out;
}
portIndex = 0;
do {
scf_strerror(scf_error()));
goto out;
}
retry = 0;
sizeof (FCOE_SMF_PORT_LIST);
MAXNAMELEN) == -1) {
scf_strerror(scf_error()));
break;
}
retry = 1;
size *= 2;
break;
} else {
(char *)macLinkName);
sizeof (FCOE_PORT_WWN));
sizeof (FCOE_PORT_WWN));
}
}
} while (retry == 1);
return (FCOE_STATUS_OK);
out:
/*
* Free resources
*/
}
}
}
}
}
}
}
if (valueLookup != NULL) {
}
if (pg_or_prop_not_found == 1) {
return (FCOE_STATUS_OK);
} else {
return (FCOE_STATUS_ERROR);
}
}