diff options
Diffstat (limited to 'usr/src/cmd')
-rw-r--r-- | usr/src/cmd/fcinfo/fcinfo.c | 5 | ||||
-rw-r--r-- | usr/src/cmd/fcinfo/fcoeadm.c | 43 | ||||
-rw-r--r-- | usr/src/cmd/fcoesvc/Makefile | 44 | ||||
-rw-r--r-- | usr/src/cmd/fcoesvc/fcoe_initiator.xml | 102 | ||||
-rw-r--r-- | usr/src/cmd/fcoesvc/fcoeisvc.c | 64 |
5 files changed, 234 insertions, 24 deletions
diff --git a/usr/src/cmd/fcinfo/fcinfo.c b/usr/src/cmd/fcinfo/fcinfo.c index 8f94354c11..bb8b95ee60 100644 --- a/usr/src/cmd/fcinfo/fcinfo.c +++ b/usr/src/cmd/fcinfo/fcinfo.c @@ -78,6 +78,7 @@ optionTbl_t fcadmlongOptions[] = { {"scsi-target", no_argument, 's', NULL}, {"fcoe-force-promisc", no_argument, 'f', NULL}, {"target", no_argument, 't', NULL}, + {"initiator", no_argument, 'i', NULL}, {NULL, 0, 0} }; @@ -113,13 +114,13 @@ subCommandProps_t fcadmsubcommands[] = { npivCreatePortListFunc, NULL, NULL, NULL, OPERAND_NONE, NULL}, {"create-fcoe-port", - fcoeAdmCreatePortFunc, "tpnf", "t", NULL, + fcoeAdmCreatePortFunc, "itpnf", NULL, NULL, OPERAND_MANDATORY_SINGLE, "Network Interface Name"}, {"delete-fcoe-port", fcoeAdmDeletePortFunc, NULL, NULL, NULL, OPERAND_MANDATORY_SINGLE, "Network Interface Name"}, {"list-fcoe-ports", - fcoeListPortsFunc, "t", NULL, NULL, + fcoeListPortsFunc, "it", NULL, NULL, OPERAND_NONE, NULL}, {NULL, 0, NULL, NULL, NULL, 0, NULL, NULL} }; diff --git a/usr/src/cmd/fcinfo/fcoeadm.c b/usr/src/cmd/fcinfo/fcoeadm.c index c3ffe637b2..5d9a4a9dd3 100644 --- a/usr/src/cmd/fcinfo/fcoeadm.c +++ b/usr/src/cmd/fcinfo/fcoeadm.c @@ -86,11 +86,11 @@ printFCOEPortInfo(FCOE_PORT_ATTRIBUTE *attr) fprintf(stdout, gettext("\tMTU Size: %d\n"), attr->mtu_size); - fprintf(stdout, gettext("\tMAC Factory Address: ")); + fprintf(stdout, gettext("\tPrimary MAC Address: ")); for (i = 0; i < 6; i++) { fprintf(stdout, gettext("%02x"), attr->mac_factory_addr[i]); } - fprintf(stdout, gettext("\n\tMAC Current Address: ")); + fprintf(stdout, gettext("\n\tCurrent MAC Address: ")); for (i = 0; i < 6; i++) { fprintf(stdout, gettext("%02x"), attr->mac_current_addr[i]); } @@ -268,6 +268,9 @@ fcoe_adm_delete_port(int objects, char *argv[]) { FCOE_STATUS status; FCOE_UINT8 *macLinkName; + FCOE_UINT32 port_num; + FCOE_PORT_ATTRIBUTE *portlist = NULL; + int i; /* check the mac name operand */ assert(objects == 1); @@ -312,9 +315,39 @@ fcoe_adm_delete_port(int objects, char *argv[]) break; case FCOE_STATUS_ERROR_OFFLINE_DEV: - fprintf(stderr, - gettext("Error: Please use stmfadm to offline " - "the FCoE target first\n")); + status = FCOE_GetPortList(&port_num, &portlist); + if (status != FCOE_STATUS_OK || port_num == 0) { + fprintf(stderr, + gettext("Error: FCoE port not found on the " + "specified MAC link\n")); + break; + } + for (i = 0; i < port_num; i++) { + if (strcmp( + (char *)portlist[i].mac_link_name, + (char *)macLinkName) == 0) { + if (portlist[i].port_type == + FCOE_PORTTYPE_TARGET) { + fprintf(stderr, + gettext("Error: Please use " + "stmfadm to offline the " + "FCoE target first\n")); + } else { + fprintf(stderr, + gettext("Error: Failed to " + "delete FCoE port because " + "unable to offline the " + "device\n")); + } + break; + } + } + free(portlist); + if (i == port_num) { + fprintf(stderr, + gettext("Error: FCoE port not found on the " + "specified MAC link\n")); + } break; case FCOE_STATUS_ERROR_GET_LINKINFO: diff --git a/usr/src/cmd/fcoesvc/Makefile b/usr/src/cmd/fcoesvc/Makefile index ab4bd84e4b..e15836ce3c 100644 --- a/usr/src/cmd/fcoesvc/Makefile +++ b/usr/src/cmd/fcoesvc/Makefile @@ -24,31 +24,43 @@ # Use is subject to license terms. # -PROG = svc-fcoet +PROGFCOET = svc-fcoet +PROGFCOEI = svc-fcoei +PROG = ${PROGFCOET} ${PROGFCOEI} include ../Makefile.cmd -COMMONBASE = ../../common +COMMONBASE = ../../common -LOCAL_OBJS = fcoetsvc.o -LOCAL_SRCS = $(LOCAL_OBJS:%.o=%.c) -OBJS = $(LOCAL_OBJS) -SRCS = $(LOCAL_SRCS) +OBJSFCOET = fcoetsvc.o +OBJSFCOEI = fcoeisvc.o +SRCSFCOET = $(OBJSFCOET:%.o=%.c) +SRCSFCOEI = $(OBJSFCOEI:%.o=%.c) +SRCS = $(SRCSFCOET) ${SRCSFCOEI} -LDLIBS += -lfcoe +LDLIBS += -lfcoe -MANIFEST = fcoe_target.xml -SVCMETHOD = svc-fcoet +MANIFEST = fcoe_target.xml +MANIFEST += fcoe_initiator.xml +SVCMETHOD = svc-fcoet +SVCMETHOD += svc-fcoei ROOTMANIFESTDIR = $(ROOTSVCSYSTEM) $(ROOTSVCSYSTEM)/fcoe_target.xml := FILEMODE = 0444 +$(ROOTSVCSYSTEM)/fcoe_initiator.xml := OWNER = root +$(ROOTSVCSYSTEM)/fcoe_initiator.xml := GROUP = bin +$(ROOTSVCSYSTEM)/fcoe_initiator.xml := FILEMODE = 0444 .KEEP_STATE: all: $(PROG) -$(PROG): $(OBJS) - $(LINK.c) -o $@ $(OBJS) $(LDLIBS) +$(PROGFCOET): $(OBJSFCOET) + $(LINK.c) -o $@ $(OBJSFCOET) $(LDLIBS) + $(POST_PROCESS) + +$(PROGFCOEI): $(OBJSFCOEI) + $(LINK.c) -o $@ $(OBJSFCOEI) $(LDLIBS) $(POST_PROCESS) install: all $(ROOTMANIFEST) $(ROOTSVCMETHOD) @@ -56,13 +68,11 @@ install: all $(ROOTMANIFEST) $(ROOTSVCMETHOD) check: $(CHKMANIFEST) $(CSTYLE) -pPc $(SRCS:%=%) -cmdparse.o: - $(COMPILE.c) -o $@ - $(POST_PROCESS_O) - clean: - $(RM) $(OBJS) + $(RM) $(OBJSFCOET) ${OBJSFCOEI} -lint: lint_SRCS +lint: + $(LINT.c) $(SRCSFCOET) $(LDLIBS) + $(LINT.c) $(SRCSFCOEI) ${LDLIBS} include ../Makefile.targ diff --git a/usr/src/cmd/fcoesvc/fcoe_initiator.xml b/usr/src/cmd/fcoesvc/fcoe_initiator.xml new file mode 100644 index 0000000000..4fc2081d71 --- /dev/null +++ b/usr/src/cmd/fcoesvc/fcoe_initiator.xml @@ -0,0 +1,102 @@ +<?xml version="1.0"?> +<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1"> + +<!-- + +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 +or http://www.opensolaris.org/os/licensing. +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. + +Service manifests for the FCoE initiator configuration +--> + +<!-- + system/fcoe_initiator - Export FCoE initiator port services +--> + +<service_bundle type='manifest' name='SUNWfcprtr:fcoe_initiator'> + +<service + name='system/fcoe_initiator' + type='service' + version='1'> + + <create_default_instance enabled='true' /> + + <single_instance/> + + <dependency name = 'network' + grouping='require_any' + restart_on='error' + type='service'> + <service_fmri value='svc:/milestone/network'/> + </dependency> + + <exec_method + type='method' + name='start' + exec='/lib/svc/method/svc-fcoei' + timeout_seconds='600'> + <method_context> + <method_credential + user='root' + group='root' + privileges='basic,sys_devices' + /> + </method_context> + </exec_method> + + <exec_method + type='method' + name='stop' + exec=':true' + timeout_seconds='60'> + <method_context> + <method_credential + user='root' + group='root' + privileges='basic,sys_devices' + /> + </method_context> + </exec_method> + + <property_group name='startd' type='framework'> + <propval name='duration' type='astring' + value='transient' /> + </property_group> + + <stability value='Evolving' /> + + <template> + <common_name> + <loctext xml:lang='C'> + fcoe initiator service + </loctext> + </common_name> + <documentation> + <manpage title='fcadm' section='1M' + manpath='/usr/share/man' /> + </documentation> + </template> + +</service> + +</service_bundle> diff --git a/usr/src/cmd/fcoesvc/fcoeisvc.c b/usr/src/cmd/fcoesvc/fcoeisvc.c new file mode 100644 index 0000000000..99bd01b5c6 --- /dev/null +++ b/usr/src/cmd/fcoesvc/fcoeisvc.c @@ -0,0 +1,64 @@ +/* + * 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 + * or http://www.opensolaris.org/os/licensing. + * 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 <libfcoe.h> +#include <locale.h> + +int +main() +{ + FCOE_STATUS status; + PFCOE_SMF_PORT_LIST portlist = NULL; + PFCOE_SMF_PORT_INSTANCE port = NULL; + int i; + int ret; + + (void) setlocale(LC_ALL, ""); + + status = FCOE_LoadConfig(FCOE_PORTTYPE_INITIATOR, &portlist); + + if (status != FCOE_STATUS_OK) { + ret = 1; + } else if (portlist == NULL) { + return (0); + } else { + for (i = 0; i < portlist->port_num; i++) { + port = &portlist->ports[i]; + if (port->port_type == FCOE_PORTTYPE_INITIATOR) { + (void) FCOE_CreatePort(port->mac_link_name, + port->port_type, + port->port_pwwn, + port->port_nwwn, + port->mac_promisc); + } + } + ret = 0; + } + + if (portlist != NULL) { + free(portlist); + } + return (ret); +} /* end main */ |