1*fcf3ce44SJohn Forte /*
2*fcf3ce44SJohn Forte * CDDL HEADER START
3*fcf3ce44SJohn Forte *
4*fcf3ce44SJohn Forte * The contents of this file are subject to the terms of the
5*fcf3ce44SJohn Forte * Common Development and Distribution License (the "License").
6*fcf3ce44SJohn Forte * You may not use this file except in compliance with the License.
7*fcf3ce44SJohn Forte *
8*fcf3ce44SJohn Forte * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*fcf3ce44SJohn Forte * or http://www.opensolaris.org/os/licensing.
10*fcf3ce44SJohn Forte * See the License for the specific language governing permissions
11*fcf3ce44SJohn Forte * and limitations under the License.
12*fcf3ce44SJohn Forte *
13*fcf3ce44SJohn Forte * When distributing Covered Code, include this CDDL HEADER in each
14*fcf3ce44SJohn Forte * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*fcf3ce44SJohn Forte * If applicable, add the following below this CDDL HEADER, with the
16*fcf3ce44SJohn Forte * fields enclosed by brackets "[]" replaced with your own identifying
17*fcf3ce44SJohn Forte * information: Portions Copyright [yyyy] [name of copyright owner]
18*fcf3ce44SJohn Forte *
19*fcf3ce44SJohn Forte * CDDL HEADER END
20*fcf3ce44SJohn Forte */
21*fcf3ce44SJohn Forte /*
22*fcf3ce44SJohn Forte * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23*fcf3ce44SJohn Forte * Use is subject to license terms.
24*fcf3ce44SJohn Forte */
25*fcf3ce44SJohn Forte
26*fcf3ce44SJohn Forte
27*fcf3ce44SJohn Forte #include <stdio.h>
28*fcf3ce44SJohn Forte #include <stdlib.h>
29*fcf3ce44SJohn Forte #include <unistd.h>
30*fcf3ce44SJohn Forte #include <hbaapi.h>
31*fcf3ce44SJohn Forte #include <errno.h>
32*fcf3ce44SJohn Forte #include <fcntl.h>
33*fcf3ce44SJohn Forte #include <string.h>
34*fcf3ce44SJohn Forte #include <sys/fibre-channel/fcio.h>
35*fcf3ce44SJohn Forte #include <sys/fibre-channel/impl/fc_error.h>
36*fcf3ce44SJohn Forte #include <sys/scsi/adapters/scsi_vhci.h>
37*fcf3ce44SJohn Forte #include "common.h"
38*fcf3ce44SJohn Forte #include "errorcodes.h"
39*fcf3ce44SJohn Forte #include <locale.h>
40*fcf3ce44SJohn Forte
41*fcf3ce44SJohn Forte /* The i18n catalog */
42*fcf3ce44SJohn Forte nl_catd l_catd;
43*fcf3ce44SJohn Forte
44*fcf3ce44SJohn Forte void
i18n_catopen()45*fcf3ce44SJohn Forte i18n_catopen() {
46*fcf3ce44SJohn Forte static int fileopen = 0;
47*fcf3ce44SJohn Forte
48*fcf3ce44SJohn Forte if (setlocale(LC_ALL, "") == NULL) {
49*fcf3ce44SJohn Forte (void) fprintf(stderr,
50*fcf3ce44SJohn Forte "Cannot operate in the locale requested. "
51*fcf3ce44SJohn Forte "Continuing in the default C locale\n");
52*fcf3ce44SJohn Forte }
53*fcf3ce44SJohn Forte if (!fileopen) {
54*fcf3ce44SJohn Forte l_catd = catopen("a5k_g_fc_i18n_cat", NL_CAT_LOCALE);
55*fcf3ce44SJohn Forte if (l_catd == (nl_catd)-1) {
56*fcf3ce44SJohn Forte return;
57*fcf3ce44SJohn Forte }
58*fcf3ce44SJohn Forte fileopen = 1;
59*fcf3ce44SJohn Forte }
60*fcf3ce44SJohn Forte return;
61*fcf3ce44SJohn Forte
62*fcf3ce44SJohn Forte }
63*fcf3ce44SJohn Forte
64*fcf3ce44SJohn Forte /*
65*fcf3ce44SJohn Forte * Given an error number, this functions
66*fcf3ce44SJohn Forte * calls the get_errString() to print a
67*fcf3ce44SJohn Forte * corresponding error message to the stderr.
68*fcf3ce44SJohn Forte * get_errString() always returns an error
69*fcf3ce44SJohn Forte * message, even in case of undefined error number.
70*fcf3ce44SJohn Forte * So, there is no need to check for a NULL pointer
71*fcf3ce44SJohn Forte * while printing the error message to the stdout.
72*fcf3ce44SJohn Forte *
73*fcf3ce44SJohn Forte * RETURNS: N/A
74*fcf3ce44SJohn Forte *
75*fcf3ce44SJohn Forte */
76*fcf3ce44SJohn Forte void
print_errString(int errnum,char * devpath)77*fcf3ce44SJohn Forte print_errString(int errnum, char *devpath)
78*fcf3ce44SJohn Forte {
79*fcf3ce44SJohn Forte
80*fcf3ce44SJohn Forte char *errStr;
81*fcf3ce44SJohn Forte
82*fcf3ce44SJohn Forte errStr = get_errString(errnum);
83*fcf3ce44SJohn Forte
84*fcf3ce44SJohn Forte if (devpath == NULL) {
85*fcf3ce44SJohn Forte (void) fprintf(stderr,
86*fcf3ce44SJohn Forte "%s \n\n", errStr);
87*fcf3ce44SJohn Forte } else {
88*fcf3ce44SJohn Forte (void) fprintf(stderr,
89*fcf3ce44SJohn Forte "%s - %s.\n\n", errStr, devpath);
90*fcf3ce44SJohn Forte }
91*fcf3ce44SJohn Forte
92*fcf3ce44SJohn Forte /* free the allocated memory for error string */
93*fcf3ce44SJohn Forte if (errStr != NULL)
94*fcf3ce44SJohn Forte (void) free(errStr);
95*fcf3ce44SJohn Forte }
96*fcf3ce44SJohn Forte
terminate()97*fcf3ce44SJohn Forte static void terminate() {
98*fcf3ce44SJohn Forte fprintf(stdout, MSGSTR(2506, "Unsupported"));
99*fcf3ce44SJohn Forte fprintf(stdout, "\n");
100*fcf3ce44SJohn Forte exit(1);
101*fcf3ce44SJohn Forte }
102*fcf3ce44SJohn Forte
103*fcf3ce44SJohn Forte /*ARGSUSED*/
adm_display_config(char ** a)104*fcf3ce44SJohn Forte int adm_display_config(char **a) {
105*fcf3ce44SJohn Forte terminate();
106*fcf3ce44SJohn Forte return (1);
107*fcf3ce44SJohn Forte }
108*fcf3ce44SJohn Forte
109*fcf3ce44SJohn Forte /*ARGSUSED*/
adm_download(char ** a,char * b)110*fcf3ce44SJohn Forte void adm_download(char **a, char *b) {
111*fcf3ce44SJohn Forte terminate();
112*fcf3ce44SJohn Forte }
113*fcf3ce44SJohn Forte
114*fcf3ce44SJohn Forte /*ARGSUSED*/
up_encl_name(char ** a,int b)115*fcf3ce44SJohn Forte void up_encl_name(char **a, int b) {
116*fcf3ce44SJohn Forte terminate();
117*fcf3ce44SJohn Forte }
118*fcf3ce44SJohn Forte
adm_failover(char ** argv)119*fcf3ce44SJohn Forte void adm_failover(char **argv) {
120*fcf3ce44SJohn Forte int path_index = 0, err = 0, fd;
121*fcf3ce44SJohn Forte char path_class[MAXNAMELEN];
122*fcf3ce44SJohn Forte char client_path[MAXPATHLEN];
123*fcf3ce44SJohn Forte char *path_phys = NULL, *trailingMinor;
124*fcf3ce44SJohn Forte sv_switch_to_cntlr_iocdata_t iocsc;
125*fcf3ce44SJohn Forte
126*fcf3ce44SJohn Forte (void) memset(path_class, 0, sizeof (path_class));
127*fcf3ce44SJohn Forte (void) strcpy(path_class, argv[path_index++]);
128*fcf3ce44SJohn Forte if ((strcmp(path_class, "primary") != 0) &&
129*fcf3ce44SJohn Forte (strcmp(path_class, "secondary") != 0)) {
130*fcf3ce44SJohn Forte (void) fprintf(stderr,
131*fcf3ce44SJohn Forte MSGSTR(2300, "Incorrect pathclass\n"));
132*fcf3ce44SJohn Forte exit(-1);
133*fcf3ce44SJohn Forte }
134*fcf3ce44SJohn Forte
135*fcf3ce44SJohn Forte if ((fd = open("/devices/scsi_vhci:devctl", O_RDWR)) < 0) {
136*fcf3ce44SJohn Forte print_errString(L_OPEN_PATH_FAIL, "/devices/scsi_vhci:devctl");
137*fcf3ce44SJohn Forte exit(-1);
138*fcf3ce44SJohn Forte }
139*fcf3ce44SJohn Forte
140*fcf3ce44SJohn Forte iocsc.client = client_path;
141*fcf3ce44SJohn Forte iocsc.class = path_class;
142*fcf3ce44SJohn Forte
143*fcf3ce44SJohn Forte while (argv[path_index] != NULL) {
144*fcf3ce44SJohn Forte path_phys =
145*fcf3ce44SJohn Forte get_slash_devices_from_osDevName(argv[path_index++],
146*fcf3ce44SJohn Forte STANDARD_DEVNAME_HANDLING);
147*fcf3ce44SJohn Forte if ((path_phys == NULL) ||
148*fcf3ce44SJohn Forte (strstr(path_phys, "/devices/scsi_vhci") == NULL)) {
149*fcf3ce44SJohn Forte (void) fprintf(stderr,
150*fcf3ce44SJohn Forte MSGSTR(2301, "Incorrect pathname\n"));
151*fcf3ce44SJohn Forte close(fd);
152*fcf3ce44SJohn Forte exit(-1);
153*fcf3ce44SJohn Forte }
154*fcf3ce44SJohn Forte
155*fcf3ce44SJohn Forte strcpy(iocsc.client, path_phys + strlen("/devices"));
156*fcf3ce44SJohn Forte
157*fcf3ce44SJohn Forte /* Now chop off the trailing ":xxx" portion if present */
158*fcf3ce44SJohn Forte if ((trailingMinor = strrchr(iocsc.client, ':')) != NULL) {
159*fcf3ce44SJohn Forte trailingMinor[0] = '\0';
160*fcf3ce44SJohn Forte }
161*fcf3ce44SJohn Forte
162*fcf3ce44SJohn Forte if (ioctl(fd, SCSI_VHCI_SWITCH_TO_CNTLR, &iocsc) != 0) {
163*fcf3ce44SJohn Forte switch (errno) {
164*fcf3ce44SJohn Forte case EALREADY:
165*fcf3ce44SJohn Forte err = L_SCSI_VHCI_ALREADY_ACTIVE;
166*fcf3ce44SJohn Forte break;
167*fcf3ce44SJohn Forte case ENXIO:
168*fcf3ce44SJohn Forte err = L_INVALID_PATH;
169*fcf3ce44SJohn Forte break;
170*fcf3ce44SJohn Forte case EIO:
171*fcf3ce44SJohn Forte err = L_SCSI_VHCI_NO_STANDBY;
172*fcf3ce44SJohn Forte break;
173*fcf3ce44SJohn Forte case ENOTSUP:
174*fcf3ce44SJohn Forte err = L_SCSI_VHCI_FAILOVER_NOTSUP;
175*fcf3ce44SJohn Forte break;
176*fcf3ce44SJohn Forte case EBUSY:
177*fcf3ce44SJohn Forte err = L_SCSI_VHCI_FAILOVER_BUSY;
178*fcf3ce44SJohn Forte break;
179*fcf3ce44SJohn Forte case EFAULT:
180*fcf3ce44SJohn Forte default:
181*fcf3ce44SJohn Forte err = L_SCSI_VHCI_ERROR;
182*fcf3ce44SJohn Forte }
183*fcf3ce44SJohn Forte }
184*fcf3ce44SJohn Forte
185*fcf3ce44SJohn Forte if (err != 0) {
186*fcf3ce44SJohn Forte close(fd);
187*fcf3ce44SJohn Forte print_errString(err, path_phys);
188*fcf3ce44SJohn Forte exit(-1);
189*fcf3ce44SJohn Forte }
190*fcf3ce44SJohn Forte }
191*fcf3ce44SJohn Forte
192*fcf3ce44SJohn Forte close(fd);
193*fcf3ce44SJohn Forte }
194*fcf3ce44SJohn Forte
195*fcf3ce44SJohn Forte /*ARGSUSED*/
adm_inquiry(char ** a)196*fcf3ce44SJohn Forte int adm_inquiry(char **a) {
197*fcf3ce44SJohn Forte terminate();
198*fcf3ce44SJohn Forte return (1);
199*fcf3ce44SJohn Forte }
200*fcf3ce44SJohn Forte
201*fcf3ce44SJohn Forte /*ARGSUSED*/
pho_probe()202*fcf3ce44SJohn Forte void pho_probe() {
203*fcf3ce44SJohn Forte terminate();
204*fcf3ce44SJohn Forte }
205*fcf3ce44SJohn Forte
206*fcf3ce44SJohn Forte /*ARGSUSED*/
non_encl_probe()207*fcf3ce44SJohn Forte void non_encl_probe() {
208*fcf3ce44SJohn Forte terminate();
209*fcf3ce44SJohn Forte }
210*fcf3ce44SJohn Forte
211*fcf3ce44SJohn Forte /*ARGSUSED*/
adm_led(char ** a,int b)212*fcf3ce44SJohn Forte void adm_led(char **a, int b) {
213*fcf3ce44SJohn Forte terminate();
214*fcf3ce44SJohn Forte }
215*fcf3ce44SJohn Forte
216*fcf3ce44SJohn Forte /*ARGSUSED*/
up_password(char ** a)217*fcf3ce44SJohn Forte void up_password(char **a) {
218*fcf3ce44SJohn Forte terminate();
219*fcf3ce44SJohn Forte }
220*fcf3ce44SJohn Forte
221*fcf3ce44SJohn Forte /*ARGSUSED*/
adm_reserve(char * path)222*fcf3ce44SJohn Forte int adm_reserve(char *path) {
223*fcf3ce44SJohn Forte terminate();
224*fcf3ce44SJohn Forte return (1);
225*fcf3ce44SJohn Forte }
226*fcf3ce44SJohn Forte
227*fcf3ce44SJohn Forte /*ARGSUSED*/
adm_release(char * path)228*fcf3ce44SJohn Forte int adm_release(char *path) {
229*fcf3ce44SJohn Forte terminate();
230*fcf3ce44SJohn Forte return (1);
231*fcf3ce44SJohn Forte }
232*fcf3ce44SJohn Forte
233*fcf3ce44SJohn Forte /*ARGSUSED*/
adm_start(char ** a)234*fcf3ce44SJohn Forte int adm_start(char **a) {
235*fcf3ce44SJohn Forte terminate();
236*fcf3ce44SJohn Forte return (1);
237*fcf3ce44SJohn Forte }
238*fcf3ce44SJohn Forte
239*fcf3ce44SJohn Forte /*ARGSUSED*/
adm_stop(char ** a)240*fcf3ce44SJohn Forte int adm_stop(char **a) {
241*fcf3ce44SJohn Forte terminate();
242*fcf3ce44SJohn Forte return (1);
243*fcf3ce44SJohn Forte }
244*fcf3ce44SJohn Forte
245*fcf3ce44SJohn Forte /*ARGSUSED*/
adm_power_off(char ** a,int b)246*fcf3ce44SJohn Forte int adm_power_off(char **a, int b) {
247*fcf3ce44SJohn Forte terminate();
248*fcf3ce44SJohn Forte return (1);
249*fcf3ce44SJohn Forte }
250*fcf3ce44SJohn Forte
251*fcf3ce44SJohn Forte int
adm_forcelip(char ** argv)252*fcf3ce44SJohn Forte adm_forcelip(char **argv)
253*fcf3ce44SJohn Forte {
254*fcf3ce44SJohn Forte int path_index = 0, fd;
255*fcf3ce44SJohn Forte uint64_t wwn;
256*fcf3ce44SJohn Forte fcio_t fcio;
257*fcf3ce44SJohn Forte HBA_HANDLE handle;
258*fcf3ce44SJohn Forte HBA_ADAPTERATTRIBUTES hbaAttrs;
259*fcf3ce44SJohn Forte HBA_PORTATTRIBUTES portAttrs;
260*fcf3ce44SJohn Forte HBA_FCPTARGETMAPPINGV2 *map;
261*fcf3ce44SJohn Forte HBA_STATUS status;
262*fcf3ce44SJohn Forte int count, adapterIndex, portIndex, mapIndex;
263*fcf3ce44SJohn Forte char name[256];
264*fcf3ce44SJohn Forte int matched, ret = 0, wwnCompare = 0, ntries;
265*fcf3ce44SJohn Forte char *physical = NULL, *slash_OSDeviceName = NULL;
266*fcf3ce44SJohn Forte
267*fcf3ce44SJohn Forte if ((status = loadLibrary())) {
268*fcf3ce44SJohn Forte /* loadLibrary print out error msg */
269*fcf3ce44SJohn Forte return (ret++);
270*fcf3ce44SJohn Forte }
271*fcf3ce44SJohn Forte for (path_index = 0; argv[path_index] != NULL; path_index++) {
272*fcf3ce44SJohn Forte
273*fcf3ce44SJohn Forte if (is_wwn(argv[path_index])) {
274*fcf3ce44SJohn Forte (void) sscanf(argv[path_index], "%016llx", &wwn);
275*fcf3ce44SJohn Forte wwnCompare = 1;
276*fcf3ce44SJohn Forte } else if (!is_path(argv[path_index])) {
277*fcf3ce44SJohn Forte print_errString(L_INVALID_PATH, argv[path_index]);
278*fcf3ce44SJohn Forte ret++;
279*fcf3ce44SJohn Forte continue;
280*fcf3ce44SJohn Forte }
281*fcf3ce44SJohn Forte if (!wwnCompare) {
282*fcf3ce44SJohn Forte /* Convert the paths to phsyical paths */
283*fcf3ce44SJohn Forte physical = get_slash_devices_from_osDevName(argv[path_index],
284*fcf3ce44SJohn Forte STANDARD_DEVNAME_HANDLING);
285*fcf3ce44SJohn Forte if (!physical) {
286*fcf3ce44SJohn Forte print_errString(L_INVALID_PATH, argv[path_index]);
287*fcf3ce44SJohn Forte ret++;
288*fcf3ce44SJohn Forte continue;
289*fcf3ce44SJohn Forte }
290*fcf3ce44SJohn Forte }
291*fcf3ce44SJohn Forte
292*fcf3ce44SJohn Forte count = getNumberOfAdapters();
293*fcf3ce44SJohn Forte
294*fcf3ce44SJohn Forte matched = 0;
295*fcf3ce44SJohn Forte for (adapterIndex = 0; adapterIndex < count; adapterIndex ++) {
296*fcf3ce44SJohn Forte status = HBA_GetAdapterName(adapterIndex, (char *)&name);
297*fcf3ce44SJohn Forte if (status != HBA_STATUS_OK) {
298*fcf3ce44SJohn Forte /* May have been DR'd */
299*fcf3ce44SJohn Forte continue;
300*fcf3ce44SJohn Forte }
301*fcf3ce44SJohn Forte handle = HBA_OpenAdapter(name);
302*fcf3ce44SJohn Forte if (handle == 0) {
303*fcf3ce44SJohn Forte /* May have been DR'd */
304*fcf3ce44SJohn Forte continue;
305*fcf3ce44SJohn Forte }
306*fcf3ce44SJohn Forte
307*fcf3ce44SJohn Forte if (getAdapterAttrs(handle, name, &hbaAttrs)) {
308*fcf3ce44SJohn Forte /* Should never happen */
309*fcf3ce44SJohn Forte HBA_CloseAdapter(handle);
310*fcf3ce44SJohn Forte continue;
311*fcf3ce44SJohn Forte }
312*fcf3ce44SJohn Forte
313*fcf3ce44SJohn Forte /* Loop over all HBA Ports */
314*fcf3ce44SJohn Forte for (portIndex = 0; portIndex < hbaAttrs.NumberOfPorts;
315*fcf3ce44SJohn Forte portIndex++) {
316*fcf3ce44SJohn Forte if (getAdapterPortAttrs(handle, name, portIndex,
317*fcf3ce44SJohn Forte &portAttrs)) {
318*fcf3ce44SJohn Forte continue;
319*fcf3ce44SJohn Forte }
320*fcf3ce44SJohn Forte
321*fcf3ce44SJohn Forte matched = 0;
322*fcf3ce44SJohn Forte if (is_wwn(argv[path_index])) {
323*fcf3ce44SJohn Forte if (wwn == wwnConversion(
324*fcf3ce44SJohn Forte portAttrs.NodeWWN.wwn) ||
325*fcf3ce44SJohn Forte wwn == wwnConversion(
326*fcf3ce44SJohn Forte portAttrs.PortWWN.wwn)) {
327*fcf3ce44SJohn Forte matched = 1;
328*fcf3ce44SJohn Forte }
329*fcf3ce44SJohn Forte } else {
330*fcf3ce44SJohn Forte slash_OSDeviceName = get_slash_devices_from_osDevName(
331*fcf3ce44SJohn Forte portAttrs.OSDeviceName, STANDARD_DEVNAME_HANDLING);
332*fcf3ce44SJohn Forte if (!slash_OSDeviceName) {
333*fcf3ce44SJohn Forte continue;
334*fcf3ce44SJohn Forte } else {
335*fcf3ce44SJohn Forte if (strncmp(physical, slash_OSDeviceName,
336*fcf3ce44SJohn Forte strlen(slash_OSDeviceName) -
337*fcf3ce44SJohn Forte strlen(strrchr(slash_OSDeviceName, ':')))
338*fcf3ce44SJohn Forte == 0) {
339*fcf3ce44SJohn Forte matched = 1;
340*fcf3ce44SJohn Forte }
341*fcf3ce44SJohn Forte free(slash_OSDeviceName);
342*fcf3ce44SJohn Forte }
343*fcf3ce44SJohn Forte }
344*fcf3ce44SJohn Forte
345*fcf3ce44SJohn Forte if (!matched) {
346*fcf3ce44SJohn Forte if (!fetch_mappings(handle, portAttrs.PortWWN, &map)) {
347*fcf3ce44SJohn Forte /*
348*fcf3ce44SJohn Forte * matchr_mapping checks the arg
349*fcf3ce44SJohn Forte * so we pass argv here.
350*fcf3ce44SJohn Forte */
351*fcf3ce44SJohn Forte mapIndex = match_mappings(argv[path_index], map);
352*fcf3ce44SJohn Forte if (mapIndex >= 0) {
353*fcf3ce44SJohn Forte matched = 1;
354*fcf3ce44SJohn Forte }
355*fcf3ce44SJohn Forte } else {
356*fcf3ce44SJohn Forte continue;
357*fcf3ce44SJohn Forte }
358*fcf3ce44SJohn Forte }
359*fcf3ce44SJohn Forte
360*fcf3ce44SJohn Forte if (matched) {
361*fcf3ce44SJohn Forte if ((fd = open(portAttrs.OSDeviceName,
362*fcf3ce44SJohn Forte O_RDONLY | O_EXCL)) == -1) {
363*fcf3ce44SJohn Forte print_errString(L_OPEN_PATH_FAIL,
364*fcf3ce44SJohn Forte portAttrs.OSDeviceName);
365*fcf3ce44SJohn Forte return (ret++);
366*fcf3ce44SJohn Forte }
367*fcf3ce44SJohn Forte
368*fcf3ce44SJohn Forte fcio.fcio_cmd = FCIO_RESET_LINK;
369*fcf3ce44SJohn Forte fcio.fcio_xfer = FCIO_XFER_WRITE;
370*fcf3ce44SJohn Forte /*
371*fcf3ce44SJohn Forte * Reset the local loop here (fcio_ibuf = 0).
372*fcf3ce44SJohn Forte * Reset a remote loop on the Fabric by
373*fcf3ce44SJohn Forte * passing its node wwn (fcio_len = sizeof(nwwn)
374*fcf3ce44SJohn Forte * and fcio_ibuf = (caddr_t)&nwwn) to the port driver.
375*fcf3ce44SJohn Forte */
376*fcf3ce44SJohn Forte (void) memset(&wwn, 0, sizeof (wwn));
377*fcf3ce44SJohn Forte fcio.fcio_ilen = sizeof (wwn);
378*fcf3ce44SJohn Forte fcio.fcio_ibuf = (caddr_t)&wwn;
379*fcf3ce44SJohn Forte
380*fcf3ce44SJohn Forte for (ntries = 0; ntries < RETRY_FCIO_IOCTL; ntries++) {
381*fcf3ce44SJohn Forte errno = 0;
382*fcf3ce44SJohn Forte if (ioctl(fd, FCIO_CMD, &fcio) != 0) {
383*fcf3ce44SJohn Forte /*
384*fcf3ce44SJohn Forte * When port is offlined, qlc
385*fcf3ce44SJohn Forte * returns the FC_OFFLINE error and errno
386*fcf3ce44SJohn Forte * is set to EIO.
387*fcf3ce44SJohn Forte * We do want to ignore this error,
388*fcf3ce44SJohn Forte * especially when an enclosure is
389*fcf3ce44SJohn Forte * removed from the loop.
390*fcf3ce44SJohn Forte */
391*fcf3ce44SJohn Forte if (fcio.fcio_errno == FC_OFFLINE)
392*fcf3ce44SJohn Forte break;
393*fcf3ce44SJohn Forte if ((errno == EAGAIN) &&
394*fcf3ce44SJohn Forte (ntries+1 < RETRY_FCIO_IOCTL)) {
395*fcf3ce44SJohn Forte /* wait WAIT_FCIO_IOCTL */
396*fcf3ce44SJohn Forte (void) usleep(WAIT_FCIO_IOCTL);
397*fcf3ce44SJohn Forte continue;
398*fcf3ce44SJohn Forte }
399*fcf3ce44SJohn Forte I_DPRINTF("FCIO ioctl failed.\n"
400*fcf3ce44SJohn Forte "Error: %s. fc_error = %d (0x%x)\n",
401*fcf3ce44SJohn Forte strerror(errno), fcio.fcio_errno,
402*fcf3ce44SJohn Forte fcio.fcio_errno);
403*fcf3ce44SJohn Forte close(fd);
404*fcf3ce44SJohn Forte print_errString(L_FCIO_FORCE_LIP_FAIL,
405*fcf3ce44SJohn Forte portAttrs.OSDeviceName);
406*fcf3ce44SJohn Forte return (ret++);
407*fcf3ce44SJohn Forte } else {
408*fcf3ce44SJohn Forte break; /* ioctl succeeds. */
409*fcf3ce44SJohn Forte }
410*fcf3ce44SJohn Forte }
411*fcf3ce44SJohn Forte close(fd);
412*fcf3ce44SJohn Forte if (ntries == RETRY_FCIO_IOCTL) {
413*fcf3ce44SJohn Forte print_errString(L_FCIO_FORCE_LIP_FAIL,
414*fcf3ce44SJohn Forte portAttrs.OSDeviceName);
415*fcf3ce44SJohn Forte return (ret++);
416*fcf3ce44SJohn Forte }
417*fcf3ce44SJohn Forte }
418*fcf3ce44SJohn Forte if (matched)
419*fcf3ce44SJohn Forte break; /* for HBA port for loop */
420*fcf3ce44SJohn Forte }
421*fcf3ce44SJohn Forte if (matched) /* HBA adapter for loop */
422*fcf3ce44SJohn Forte break;
423*fcf3ce44SJohn Forte }
424*fcf3ce44SJohn Forte
425*fcf3ce44SJohn Forte if (!matched) {
426*fcf3ce44SJohn Forte print_errString(L_INVALID_PATH, argv[path_index]);
427*fcf3ce44SJohn Forte ret++;
428*fcf3ce44SJohn Forte }
429*fcf3ce44SJohn Forte }
430*fcf3ce44SJohn Forte HBA_FreeLibrary();
431*fcf3ce44SJohn Forte return (ret);
432*fcf3ce44SJohn Forte }
433*fcf3ce44SJohn Forte
434*fcf3ce44SJohn Forte /*ARGSUSED*/
adm_bypass_enable(char ** argv,int bypass_flag)435*fcf3ce44SJohn Forte void adm_bypass_enable(char **argv, int bypass_flag) {
436*fcf3ce44SJohn Forte terminate();
437*fcf3ce44SJohn Forte }
438*fcf3ce44SJohn Forte
439*fcf3ce44SJohn Forte /*ARGSUSED*/
adm_port_offline_online(char ** a,int b)440*fcf3ce44SJohn Forte int adm_port_offline_online(char **a, int b) {
441*fcf3ce44SJohn Forte terminate();
442*fcf3ce44SJohn Forte return (1);
443*fcf3ce44SJohn Forte }
444*fcf3ce44SJohn Forte
445*fcf3ce44SJohn Forte /*ARGSUSED*/
display_link_status(char ** a)446*fcf3ce44SJohn Forte void display_link_status(char **a) {
447*fcf3ce44SJohn Forte terminate();
448*fcf3ce44SJohn Forte }
449*fcf3ce44SJohn Forte
450*fcf3ce44SJohn Forte /*ARGSUSED*/
dump_map(char ** argv)451*fcf3ce44SJohn Forte void dump_map(char **argv) {
452*fcf3ce44SJohn Forte terminate();
453*fcf3ce44SJohn Forte }
454*fcf3ce44SJohn Forte
455*fcf3ce44SJohn Forte /*ARGSUSED*/
adm_display_port(int a)456*fcf3ce44SJohn Forte int adm_display_port(int a) {
457*fcf3ce44SJohn Forte terminate();
458*fcf3ce44SJohn Forte return (1);
459*fcf3ce44SJohn Forte }
460*fcf3ce44SJohn Forte
461*fcf3ce44SJohn Forte /*ARGSUSED*/
adm_port_loopback(char * a,int b)462*fcf3ce44SJohn Forte int adm_port_loopback(char *a, int b) {
463*fcf3ce44SJohn Forte terminate();
464*fcf3ce44SJohn Forte return (1);
465*fcf3ce44SJohn Forte }
466*fcf3ce44SJohn Forte
467*fcf3ce44SJohn Forte /*ARGSUSED*/
hotplug_e(int todo,char ** argv,int verbose_flag,int force_flag)468*fcf3ce44SJohn Forte int hotplug_e(int todo, char **argv, int verbose_flag, int force_flag) {
469*fcf3ce44SJohn Forte terminate();
470*fcf3ce44SJohn Forte return (1);
471*fcf3ce44SJohn Forte }
472*fcf3ce44SJohn Forte
473*fcf3ce44SJohn Forte /*ARGSUSED*/
474*fcf3ce44SJohn Forte int
setboot(unsigned int yes,unsigned int verbose,char * fname)475*fcf3ce44SJohn Forte setboot(unsigned int yes, unsigned int verbose, char *fname)
476*fcf3ce44SJohn Forte {
477*fcf3ce44SJohn Forte terminate();
478*fcf3ce44SJohn Forte return (1);
479*fcf3ce44SJohn Forte }
480*fcf3ce44SJohn Forte
481*fcf3ce44SJohn Forte /*ARGSUSED*/
hotplug(int todo,char ** argv,int verbose_flag,int force_flag)482*fcf3ce44SJohn Forte int hotplug(int todo, char **argv, int verbose_flag, int force_flag) {
483*fcf3ce44SJohn Forte terminate();
484*fcf3ce44SJohn Forte return (1);
485*fcf3ce44SJohn Forte }
486*fcf3ce44SJohn Forte
487*fcf3ce44SJohn Forte /*ARGSUSED*/
adm_check_file(char ** argv,int flag)488*fcf3ce44SJohn Forte int adm_check_file(char **argv, int flag) {
489*fcf3ce44SJohn Forte terminate();
490*fcf3ce44SJohn Forte return (1);
491*fcf3ce44SJohn Forte }
492*fcf3ce44SJohn Forte
493*fcf3ce44SJohn Forte /*ARGSUSED*/
sysdump(int verbose)494*fcf3ce44SJohn Forte int sysdump(int verbose) {
495*fcf3ce44SJohn Forte terminate();
496*fcf3ce44SJohn Forte return (1);
497*fcf3ce44SJohn Forte }
498*fcf3ce44SJohn Forte
499*fcf3ce44SJohn Forte /*ARGSUSED*/
fcal_update(unsigned int verbose,char * file)500*fcf3ce44SJohn Forte int fcal_update(unsigned int verbose, char *file) {
501*fcf3ce44SJohn Forte terminate();
502*fcf3ce44SJohn Forte return (1);
503*fcf3ce44SJohn Forte }
504*fcf3ce44SJohn Forte
505*fcf3ce44SJohn Forte /*ARGSUSED*/
q_qlgc_update(unsigned int verbose,char * file)506*fcf3ce44SJohn Forte int q_qlgc_update(unsigned int verbose, char *file) {
507*fcf3ce44SJohn Forte terminate();
508*fcf3ce44SJohn Forte return (1);
509*fcf3ce44SJohn Forte }
510*fcf3ce44SJohn Forte
511*fcf3ce44SJohn Forte /*ARGSUSED*/
emulex_update(char * file)512*fcf3ce44SJohn Forte int emulex_update(char *file) {
513*fcf3ce44SJohn Forte terminate();
514*fcf3ce44SJohn Forte return (1);
515*fcf3ce44SJohn Forte }
516*fcf3ce44SJohn Forte
517*fcf3ce44SJohn Forte /*ARGSUSED*/
emulex_fcode_reader(int fcode_fd,char * pattern,char * pattern_value,uint32_t pattern_value_size)518*fcf3ce44SJohn Forte int emulex_fcode_reader(int fcode_fd, char *pattern, char *pattern_value,
519*fcf3ce44SJohn Forte uint32_t pattern_value_size) {
520*fcf3ce44SJohn Forte terminate();
521*fcf3ce44SJohn Forte return (1);
522*fcf3ce44SJohn Forte }
523*fcf3ce44SJohn Forte
524*fcf3ce44SJohn Forte /*ARGSUSED*/
dump(char ** argv)525*fcf3ce44SJohn Forte void dump(char **argv) {
526*fcf3ce44SJohn Forte terminate();
527*fcf3ce44SJohn Forte }
528*fcf3ce44SJohn Forte
529*fcf3ce44SJohn Forte /*ARGSUSED*/
h_insertSena_fcdev()530*fcf3ce44SJohn Forte int h_insertSena_fcdev() {
531*fcf3ce44SJohn Forte terminate();
532*fcf3ce44SJohn Forte return (1);
533*fcf3ce44SJohn Forte }
534