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