diff options
author | Reed <Reed.Liu@Sun.COM> | 2009-08-07 15:32:17 +0800 |
---|---|---|
committer | Reed <Reed.Liu@Sun.COM> | 2009-08-07 15:32:17 +0800 |
commit | a79493184c9332129c9c91500069322f6f3fafdd (patch) | |
tree | 90e7abfdcfe6414f4323049e97dbcd53b6face02 /usr/src/cmd/fcinfo | |
parent | bcee7a0b0779fb8c238fd397238e77e5e5940577 (diff) | |
download | illumos-gate-a79493184c9332129c9c91500069322f6f3fafdd.tar.gz |
PSARC/2009/401 Fibre Channel port link reinitialize support
6858288 add subcommand force-lip to fcadm
Diffstat (limited to 'usr/src/cmd/fcinfo')
-rw-r--r-- | usr/src/cmd/fcinfo/fcadm-list.c | 48 | ||||
-rw-r--r-- | usr/src/cmd/fcinfo/fcinfo.c | 15 | ||||
-rw-r--r-- | usr/src/cmd/fcinfo/fcinfo.h | 1 |
3 files changed, 63 insertions, 1 deletions
diff --git a/usr/src/cmd/fcinfo/fcadm-list.c b/usr/src/cmd/fcinfo/fcadm-list.c index 1c2f4f11d7..092890c625 100644 --- a/usr/src/cmd/fcinfo/fcadm-list.c +++ b/usr/src/cmd/fcinfo/fcadm-list.c @@ -19,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -943,3 +943,49 @@ out: return (0); } + +/* ARGSUSED */ +int +fc_util_force_lip(int objects, char *argv[]) +{ + uint64_t hbaWWN; + HBA_WWN myWWN; + HBA_HANDLE handle; + HBA_STATUS status; + int rval = 0; + + if ((status = HBA_LoadLibrary()) != HBA_STATUS_OK) { + fprintf(stderr, gettext("Failed to load FC-HBA library\n")); + printStatus(status); + fprintf(stderr, "\n"); + return (1); + } + + sscanf(argv[0], "%016llx", &hbaWWN); + hbaWWN = htonll(hbaWWN); + memcpy(myWWN.wwn, &hbaWWN, sizeof (hbaWWN)); + + /* + * Try target mode first + */ + if ((status = Sun_HBA_OpenTgtAdapterByWWN(&handle, myWWN)) != + HBA_STATUS_OK) { + /* + * Continue to try initiator mode + */ + if ((status = HBA_OpenAdapterByWWN(&handle, myWWN)) != + HBA_STATUS_OK) { + fprintf(stderr, gettext("Error: HBA %s not found\n"), + argv[0]); + return (0); + } + } + + status = Sun_HBA_ForceLip(handle, &rval); + if ((status != HBA_STATUS_OK) || (rval != 0)) { + fprintf(stderr, gettext("Error: Failed to reinitialize the " + "link of HBA %s\n"), argv[0]); + } + + return (0); +} diff --git a/usr/src/cmd/fcinfo/fcinfo.c b/usr/src/cmd/fcinfo/fcinfo.c index bb8b95ee60..44e93541e3 100644 --- a/usr/src/cmd/fcinfo/fcinfo.c +++ b/usr/src/cmd/fcinfo/fcinfo.c @@ -53,6 +53,7 @@ static int npivListRemotePortFunc(int, char **, cmdOptions_t *, void *); static int fcoeAdmCreatePortFunc(int, char **, cmdOptions_t *, void *); static int fcoeListPortsFunc(int, char **, cmdOptions_t *, void *); static int fcoeAdmDeletePortFunc(int, char **, cmdOptions_t *, void *); +static int fcadmForceLipFunc(int, char **, cmdOptions_t *, void *); static char *getExecBasename(char *); /* @@ -122,6 +123,9 @@ subCommandProps_t fcadmsubcommands[] = { {"list-fcoe-ports", fcoeListPortsFunc, "it", NULL, NULL, OPERAND_NONE, NULL}, + {"force-lip", + fcadmForceLipFunc, NULL, NULL, NULL, + OPERAND_MANDATORY_SINGLE, "WWN"}, {NULL, 0, NULL, NULL, NULL, 0, NULL, NULL} }; @@ -240,6 +244,17 @@ fcoeListPortsFunc(int objects, char *argv[], cmdOptions_t *options, } /* + * Pass in options/arguments, rest of arguments + */ +/*ARGSUSED*/ +static int +fcadmForceLipFunc(int objects, char *argv[], cmdOptions_t *options, + void *addArgs) +{ + return (fc_util_force_lip(objects, argv)); +} + +/* * input: * execFullName - exec name of program (argv[0]) * diff --git a/usr/src/cmd/fcinfo/fcinfo.h b/usr/src/cmd/fcinfo/fcinfo.h index d9a0f4c683..3001bf2654 100644 --- a/usr/src/cmd/fcinfo/fcinfo.h +++ b/usr/src/cmd/fcinfo/fcinfo.h @@ -146,6 +146,7 @@ int fc_util_list_logicalunit(int pathCount, char **argv, cmdOptions_t *options); int fc_util_delete_npivport(int wwnCount, char **argv, cmdOptions_t *options); int fc_util_create_npivport(int wwnCount, char **argv, cmdOptions_t *options); int fc_util_create_portlist(); +int fc_util_force_lip(int objects, char *argv[]); int fcoe_adm_create_port(int objects, char *argv[], cmdOptions_t *options); |