xref: /titanic_52/usr/src/cmd/luxadm/g_adm.c (revision fcf3ce441efd61da9bb2884968af01cb7c1452cc)
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 
28*fcf3ce44SJohn Forte #define	LUX_SF_INST_SHIFT4MINOR 6
29*fcf3ce44SJohn Forte #define	LUX_SF_MINOR2INST(x)    (x >> LUX_SF_INST_SHIFT4MINOR)
30*fcf3ce44SJohn Forte 
31*fcf3ce44SJohn Forte #include	<stdlib.h>
32*fcf3ce44SJohn Forte #include	<stdio.h>
33*fcf3ce44SJohn Forte #include	<sys/file.h>
34*fcf3ce44SJohn Forte #include	<sys/errno.h>
35*fcf3ce44SJohn Forte #include	<sys/types.h>
36*fcf3ce44SJohn Forte #include	<sys/stat.h>
37*fcf3ce44SJohn Forte #include	<sys/param.h>
38*fcf3ce44SJohn Forte #include	<kstat.h>
39*fcf3ce44SJohn Forte #include	<sys/mkdev.h>
40*fcf3ce44SJohn Forte #include	<locale.h>
41*fcf3ce44SJohn Forte #include	<nl_types.h>
42*fcf3ce44SJohn Forte #include	<fcntl.h>
43*fcf3ce44SJohn Forte #include	<unistd.h>
44*fcf3ce44SJohn Forte #include	<strings.h>
45*fcf3ce44SJohn Forte #include	<ctype.h>
46*fcf3ce44SJohn Forte #include	<dirent.h>
47*fcf3ce44SJohn Forte #include	<limits.h>
48*fcf3ce44SJohn Forte #include	<stdarg.h>
49*fcf3ce44SJohn Forte #include	<termio.h>		/* For password */
50*fcf3ce44SJohn Forte #include	<signal.h>
51*fcf3ce44SJohn Forte #include	<sys/scsi/scsi.h>
52*fcf3ce44SJohn Forte #include	<sys/scsi/generic/commands.h>
53*fcf3ce44SJohn Forte #include	<l_common.h>
54*fcf3ce44SJohn Forte #include	<l_error.h>
55*fcf3ce44SJohn Forte #include	<stgcom.h>
56*fcf3ce44SJohn Forte #include	<a_state.h>
57*fcf3ce44SJohn Forte #include	<devid.h>
58*fcf3ce44SJohn Forte #include	<g_state.h>
59*fcf3ce44SJohn Forte #include	"common.h"
60*fcf3ce44SJohn Forte 
61*fcf3ce44SJohn Forte extern char		*dtype[];
62*fcf3ce44SJohn Forte extern char		*whoami;
63*fcf3ce44SJohn Forte extern	int	Options;
64*fcf3ce44SJohn Forte extern	const	int OPTION_A;
65*fcf3ce44SJohn Forte extern	const	int OPTION_B;
66*fcf3ce44SJohn Forte extern	const	int OPTION_C;
67*fcf3ce44SJohn Forte extern	const	int OPTION_D;
68*fcf3ce44SJohn Forte extern	const	int OPTION_E;
69*fcf3ce44SJohn Forte extern	const	int OPTION_F;
70*fcf3ce44SJohn Forte extern	const	int OPTION_L;
71*fcf3ce44SJohn Forte extern	const	int OPTION_P;
72*fcf3ce44SJohn Forte extern	const	int OPTION_R;
73*fcf3ce44SJohn Forte extern	const	int OPTION_T;
74*fcf3ce44SJohn Forte extern	const	int OPTION_V;
75*fcf3ce44SJohn Forte extern	const	int OPTION_Z;
76*fcf3ce44SJohn Forte extern	const	int OPTION_Y;
77*fcf3ce44SJohn Forte extern	const	int OPTION_CAPF;
78*fcf3ce44SJohn Forte extern	const	int PVERBOSE;
79*fcf3ce44SJohn Forte extern	const	int SAVE;
80*fcf3ce44SJohn Forte extern	const	int EXPERT;
81*fcf3ce44SJohn Forte 
82*fcf3ce44SJohn Forte static		struct termios	termios;
83*fcf3ce44SJohn Forte static		int termio_fd;
84*fcf3ce44SJohn Forte static	void	pho_display_config(char *);
85*fcf3ce44SJohn Forte static	void	dpm_display_config(char *);
86*fcf3ce44SJohn Forte static	void	n_rem_list_entry(uchar_t,  struct gfc_map *,
87*fcf3ce44SJohn Forte 		WWN_list **);
88*fcf3ce44SJohn Forte static	void	n_rem_list_entry_fabric(int, struct gfc_map *,
89*fcf3ce44SJohn Forte 		WWN_list **);
90*fcf3ce44SJohn Forte static	void	n_rem_wwn_entry(uchar_t *, WWN_list **);
91*fcf3ce44SJohn Forte static	void	display_disk_info(L_inquiry, L_disk_state,
92*fcf3ce44SJohn Forte 		Path_struct *, struct mode_page *, int, char *, int);
93*fcf3ce44SJohn Forte static	void	display_lun_info(L_disk_state, Path_struct *,
94*fcf3ce44SJohn Forte 		struct mode_page *, int, WWN_list *, char *);
95*fcf3ce44SJohn Forte static	void	display_fc_disk(struct path_struct *, char *, gfc_map_t *,
96*fcf3ce44SJohn Forte 		L_inquiry, int);
97*fcf3ce44SJohn Forte static 	void	adm_display_err(char *, int);
98*fcf3ce44SJohn Forte static	void	temperature_messages(struct l_state_struct *, int);
99*fcf3ce44SJohn Forte static	void	ctlr_messages(struct l_state_struct *, int, int);
100*fcf3ce44SJohn Forte static	void	fan_messages(struct l_state_struct *, int, int);
101*fcf3ce44SJohn Forte static	void	ps_messages(struct l_state_struct *, int, int);
102*fcf3ce44SJohn Forte static	void	abnormal_condition_display(struct l_state_struct *);
103*fcf3ce44SJohn Forte static	void	loop_messages(struct l_state_struct *, int, int);
104*fcf3ce44SJohn Forte static	void	revision_msg(struct l_state_struct *, int);
105*fcf3ce44SJohn Forte static	void	mb_messages(struct l_state_struct *, int, int);
106*fcf3ce44SJohn Forte static	void	back_plane_messages(struct l_state_struct *, int, int);
107*fcf3ce44SJohn Forte static	void	dpm_SSC100_messages(struct l_state_struct *, int, int);
108*fcf3ce44SJohn Forte static	void	mb_messages(struct l_state_struct *, int, int);
109*fcf3ce44SJohn Forte static	void	back_plane_messages(struct l_state_struct *, int, int);
110*fcf3ce44SJohn Forte static	void	dpm_SSC100_messages(struct l_state_struct *, int, int);
111*fcf3ce44SJohn Forte static	void	trans_decode(Trans_elem_st *trans);
112*fcf3ce44SJohn Forte static	void	trans_messages(struct l_state_struct *, int);
113*fcf3ce44SJohn Forte static	void	adm_print_pathlist(char *);
114*fcf3ce44SJohn Forte static	void	display_path_info(char *, char *, WWN_list *);
115*fcf3ce44SJohn Forte static void	copy_wwn_data_to_str(char *, const uchar_t *);
116*fcf3ce44SJohn Forte static void	adm_mplist_free(struct mplist_struct *);
117*fcf3ce44SJohn Forte static int	lun_display(Path_struct *path_struct, L_inquiry inq_struct,
118*fcf3ce44SJohn Forte 		int verbose);
119*fcf3ce44SJohn Forte static int	non_encl_fc_disk_display(Path_struct *path_struct,
120*fcf3ce44SJohn Forte 		L_inquiry inq_struct, int verbose);
121*fcf3ce44SJohn Forte static int	get_enclStatus(char *phys_path, char *encl_name, int off_flag);
122*fcf3ce44SJohn Forte static int	get_host_controller_pwwn(char *hba_path, uchar_t *pwwn);
123*fcf3ce44SJohn Forte static int	get_lun_capacity(char *devpath,
124*fcf3ce44SJohn Forte 		struct scsi_capacity_16 *cap_data);
125*fcf3ce44SJohn Forte static int	get_path_status(char *devpath, int *status);
126*fcf3ce44SJohn Forte static int	get_FC4_host_controller_pwwn(char *hba_path, uchar_t *pwwn);
127*fcf3ce44SJohn Forte 
128*fcf3ce44SJohn Forte /*
129*fcf3ce44SJohn Forte  * Gets the device's state from the SENA IB and
130*fcf3ce44SJohn Forte  * checks whether device is offlined, bypassed
131*fcf3ce44SJohn Forte  * or if the slot is empty and prints it to the
132*fcf3ce44SJohn Forte  * stdout.
133*fcf3ce44SJohn Forte  *
134*fcf3ce44SJohn Forte  * RETURNS:
135*fcf3ce44SJohn Forte  *	0	 O.K.
136*fcf3ce44SJohn Forte  *	non-zero otherwise
137*fcf3ce44SJohn Forte  */
138*fcf3ce44SJohn Forte int
139*fcf3ce44SJohn Forte print_devState(char *devname, char *ppath, int fr_flag, int slot,
140*fcf3ce44SJohn Forte 						int verbose_flag)
141*fcf3ce44SJohn Forte {
142*fcf3ce44SJohn Forte L_state		l_state;
143*fcf3ce44SJohn Forte int		err;
144*fcf3ce44SJohn Forte int		i, elem_index = 0;
145*fcf3ce44SJohn Forte uchar_t		device_off, ib_status_code, bypass_a_en, bypass_b_en;
146*fcf3ce44SJohn Forte Bp_elem_st	bpf, bpr;
147*fcf3ce44SJohn Forte 
148*fcf3ce44SJohn Forte 
149*fcf3ce44SJohn Forte 	if ((err = l_get_status(ppath, &l_state, verbose_flag)) != 0) {
150*fcf3ce44SJohn Forte 		(void) print_errString(err, ppath);
151*fcf3ce44SJohn Forte 		return (err);
152*fcf3ce44SJohn Forte 	}
153*fcf3ce44SJohn Forte 
154*fcf3ce44SJohn Forte 	for (i = 0; i <  (int)l_state.ib_tbl.config.enc_num_elem; i++) {
155*fcf3ce44SJohn Forte 		elem_index++;
156*fcf3ce44SJohn Forte 		if (l_state.ib_tbl.config.type_hdr[i].type == ELM_TYP_BP) {
157*fcf3ce44SJohn Forte 			break;
158*fcf3ce44SJohn Forte 		}
159*fcf3ce44SJohn Forte 		elem_index += l_state.ib_tbl.config.type_hdr[i].num;
160*fcf3ce44SJohn Forte 	}
161*fcf3ce44SJohn Forte 	(void) bcopy((const void *)
162*fcf3ce44SJohn Forte 			&(l_state.ib_tbl.p2_s.element[elem_index]),
163*fcf3ce44SJohn Forte 			(void *)&bpf, sizeof (bpf));
164*fcf3ce44SJohn Forte 	(void) bcopy((const void *)
165*fcf3ce44SJohn Forte 			&(l_state.ib_tbl.p2_s.element[elem_index + 1]),
166*fcf3ce44SJohn Forte 			(void *)&bpr, sizeof (bpr));
167*fcf3ce44SJohn Forte 
168*fcf3ce44SJohn Forte 	if (fr_flag) {
169*fcf3ce44SJohn Forte 		device_off = l_state.drv_front[slot].ib_status.dev_off;
170*fcf3ce44SJohn Forte 		bypass_a_en = l_state.drv_front[slot].ib_status.bypass_a_en;
171*fcf3ce44SJohn Forte 		bypass_b_en = l_state.drv_front[slot].ib_status.bypass_b_en;
172*fcf3ce44SJohn Forte 		ib_status_code = l_state.drv_front[slot].ib_status.code;
173*fcf3ce44SJohn Forte 	} else {
174*fcf3ce44SJohn Forte 		device_off = l_state.drv_rear[slot].ib_status.dev_off;
175*fcf3ce44SJohn Forte 		bypass_a_en = l_state.drv_rear[slot].ib_status.bypass_a_en;
176*fcf3ce44SJohn Forte 		bypass_b_en = l_state.drv_rear[slot].ib_status.bypass_b_en;
177*fcf3ce44SJohn Forte 		ib_status_code = l_state.drv_rear[slot].ib_status.code;
178*fcf3ce44SJohn Forte 	}
179*fcf3ce44SJohn Forte 	if (device_off) {
180*fcf3ce44SJohn Forte 		(void) fprintf(stdout,
181*fcf3ce44SJohn Forte 				MSGSTR(2000,
182*fcf3ce44SJohn Forte 				"%s is offlined and bypassed.\n"
183*fcf3ce44SJohn Forte 				" Could not get device specific"
184*fcf3ce44SJohn Forte 				" information.\n\n"),
185*fcf3ce44SJohn Forte 				devname);
186*fcf3ce44SJohn Forte 	} else if (bypass_a_en && bypass_b_en) {
187*fcf3ce44SJohn Forte 		(void) fprintf(stdout,
188*fcf3ce44SJohn Forte 				MSGSTR(2001,
189*fcf3ce44SJohn Forte 				"%s is bypassed (Port:AB).\n"
190*fcf3ce44SJohn Forte 				" Could not get device specific"
191*fcf3ce44SJohn Forte 				" information.\n\n"),
192*fcf3ce44SJohn Forte 				devname);
193*fcf3ce44SJohn Forte 	} else if (ib_status_code == S_NOT_INSTALLED) {
194*fcf3ce44SJohn Forte 		(void) fprintf(stdout,
195*fcf3ce44SJohn Forte 				MSGSTR(2002,
196*fcf3ce44SJohn Forte 				"Slot %s is empty.\n\n"),
197*fcf3ce44SJohn Forte 				devname);
198*fcf3ce44SJohn Forte 	} else if (((bpf.code != S_NOT_INSTALLED) &&
199*fcf3ce44SJohn Forte 		((bpf.byp_a_enabled || bpf.en_bypass_a) &&
200*fcf3ce44SJohn Forte 		(bpf.byp_b_enabled || bpf.en_bypass_b))) ||
201*fcf3ce44SJohn Forte 		((bpr.code != S_NOT_INSTALLED) &&
202*fcf3ce44SJohn Forte 		((bpr.byp_a_enabled || bpr.en_bypass_a) &&
203*fcf3ce44SJohn Forte 		(bpr.byp_b_enabled || bpr.en_bypass_b)))) {
204*fcf3ce44SJohn Forte 		(void) fprintf(stdout,
205*fcf3ce44SJohn Forte 				MSGSTR(2003,
206*fcf3ce44SJohn Forte 				"Backplane(Port:AB) is bypassed.\n"
207*fcf3ce44SJohn Forte 				" Could not get device specific"
208*fcf3ce44SJohn Forte 				" information for"
209*fcf3ce44SJohn Forte 				" %s.\n\n"), devname);
210*fcf3ce44SJohn Forte 	} else {
211*fcf3ce44SJohn Forte 		(void) fprintf(stderr,
212*fcf3ce44SJohn Forte 				MSGSTR(33,
213*fcf3ce44SJohn Forte 				" Error: converting"
214*fcf3ce44SJohn Forte 				" %s to physical path.\n"
215*fcf3ce44SJohn Forte 				" Invalid pathname.\n"),
216*fcf3ce44SJohn Forte 				devname);
217*fcf3ce44SJohn Forte 	}
218*fcf3ce44SJohn Forte 	return (-1);
219*fcf3ce44SJohn Forte }
220*fcf3ce44SJohn Forte 
221*fcf3ce44SJohn Forte /*
222*fcf3ce44SJohn Forte  * Given an error number, this functions
223*fcf3ce44SJohn Forte  * calls the get_errString() to print a
224*fcf3ce44SJohn Forte  * corresponding error message to the stderr.
225*fcf3ce44SJohn Forte  * get_errString() always returns an error
226*fcf3ce44SJohn Forte  * message, even in case of undefined error number.
227*fcf3ce44SJohn Forte  * So, there is no need to check for a NULL pointer
228*fcf3ce44SJohn Forte  * while printing the error message to the stdout.
229*fcf3ce44SJohn Forte  *
230*fcf3ce44SJohn Forte  * RETURNS: N/A
231*fcf3ce44SJohn Forte  *
232*fcf3ce44SJohn Forte  */
233*fcf3ce44SJohn Forte void
234*fcf3ce44SJohn Forte print_errString(int errnum, char *devpath)
235*fcf3ce44SJohn Forte {
236*fcf3ce44SJohn Forte 
237*fcf3ce44SJohn Forte char	*errStr;
238*fcf3ce44SJohn Forte 
239*fcf3ce44SJohn Forte 	errStr = g_get_errString(errnum);
240*fcf3ce44SJohn Forte 
241*fcf3ce44SJohn Forte 	if (devpath == NULL) {
242*fcf3ce44SJohn Forte 		(void) fprintf(stderr,
243*fcf3ce44SJohn Forte 				"%s \n\n", errStr);
244*fcf3ce44SJohn Forte 	} else {
245*fcf3ce44SJohn Forte 		(void) fprintf(stderr,
246*fcf3ce44SJohn Forte 				"%s - %s.\n\n", errStr, devpath);
247*fcf3ce44SJohn Forte 	}
248*fcf3ce44SJohn Forte 
249*fcf3ce44SJohn Forte 	/* free the allocated memory for error string */
250*fcf3ce44SJohn Forte 	if (errStr != NULL)
251*fcf3ce44SJohn Forte 		(void) free(errStr);
252*fcf3ce44SJohn Forte }
253*fcf3ce44SJohn Forte 
254*fcf3ce44SJohn Forte /*
255*fcf3ce44SJohn Forte  * adm_inquiry() Display the inquiry information for
256*fcf3ce44SJohn Forte  * a SENA enclosure(s) or disk(s).
257*fcf3ce44SJohn Forte  *
258*fcf3ce44SJohn Forte  * RETURNS:
259*fcf3ce44SJohn Forte  *	none.
260*fcf3ce44SJohn Forte  */
261*fcf3ce44SJohn Forte int
262*fcf3ce44SJohn Forte adm_inquiry(char **argv)
263*fcf3ce44SJohn Forte {
264*fcf3ce44SJohn Forte L_inquiry	inq;
265*fcf3ce44SJohn Forte L_inquiry80	inq80;
266*fcf3ce44SJohn Forte size_t		serial_len;
267*fcf3ce44SJohn Forte int		path_index = 0, retval = 0;
268*fcf3ce44SJohn Forte int		slot, f_r, err = 0, argpwwn, argnwwn;
269*fcf3ce44SJohn Forte char		inq_path[MAXNAMELEN];
270*fcf3ce44SJohn Forte char		*path_phys = NULL, *ptr;
271*fcf3ce44SJohn Forte Path_struct	*path_struct;
272*fcf3ce44SJohn Forte WWN_list	*wwn_list, *wwn_list_ptr, *list_start;
273*fcf3ce44SJohn Forte char		last_logical_path[MAXPATHLEN];
274*fcf3ce44SJohn Forte 
275*fcf3ce44SJohn Forte 	while (argv[path_index] != NULL) {
276*fcf3ce44SJohn Forte 	    if ((err = l_convert_name(argv[path_index], &path_phys,
277*fcf3ce44SJohn Forte 		&path_struct, Options & PVERBOSE)) != 0) {
278*fcf3ce44SJohn Forte 		(void) strcpy(inq_path, argv[path_index]);
279*fcf3ce44SJohn Forte 		if (((ptr = strstr(inq_path, ",")) != NULL) &&
280*fcf3ce44SJohn Forte 			((*(ptr + 1) == 'f') || (*(ptr + 1) == 'r') ||
281*fcf3ce44SJohn Forte 			    (*(ptr +1) == 's'))) {
282*fcf3ce44SJohn Forte 			if (err != -1) {
283*fcf3ce44SJohn Forte 				(void) print_errString(err, argv[path_index]);
284*fcf3ce44SJohn Forte 				path_index++;
285*fcf3ce44SJohn Forte 				retval++;
286*fcf3ce44SJohn Forte 				continue;
287*fcf3ce44SJohn Forte 			}
288*fcf3ce44SJohn Forte 			*ptr = NULL;
289*fcf3ce44SJohn Forte 			slot = path_struct->slot;
290*fcf3ce44SJohn Forte 			f_r = path_struct->f_flag;
291*fcf3ce44SJohn Forte 			path_phys = NULL;
292*fcf3ce44SJohn Forte 			if ((err = l_convert_name(inq_path, &path_phys,
293*fcf3ce44SJohn Forte 				&path_struct, Options & PVERBOSE)) != 0) {
294*fcf3ce44SJohn Forte 				(void) fprintf(stderr,
295*fcf3ce44SJohn Forte 					MSGSTR(33,
296*fcf3ce44SJohn Forte 					" Error: converting"
297*fcf3ce44SJohn Forte 					" %s to physical path.\n"
298*fcf3ce44SJohn Forte 					" Invalid pathname.\n"),
299*fcf3ce44SJohn Forte 					argv[path_index]);
300*fcf3ce44SJohn Forte 				if (err != -1) {
301*fcf3ce44SJohn Forte 					(void) print_errString(err,
302*fcf3ce44SJohn Forte 							argv[path_index]);
303*fcf3ce44SJohn Forte 				}
304*fcf3ce44SJohn Forte 				path_index++;
305*fcf3ce44SJohn Forte 				retval++;
306*fcf3ce44SJohn Forte 				continue;
307*fcf3ce44SJohn Forte 			}
308*fcf3ce44SJohn Forte 			if ((err = print_devState(argv[path_index],
309*fcf3ce44SJohn Forte 					path_struct->p_physical_path,
310*fcf3ce44SJohn Forte 					f_r, slot, Options & PVERBOSE)) != 0) {
311*fcf3ce44SJohn Forte 				path_index++;
312*fcf3ce44SJohn Forte 				retval++;
313*fcf3ce44SJohn Forte 				continue;
314*fcf3ce44SJohn Forte 			}
315*fcf3ce44SJohn Forte 		} else {
316*fcf3ce44SJohn Forte 			if (err != -1) {
317*fcf3ce44SJohn Forte 				(void) print_errString(err, argv[path_index]);
318*fcf3ce44SJohn Forte 			} else {
319*fcf3ce44SJohn Forte 			    (void) fprintf(stderr, "\n ");
320*fcf3ce44SJohn Forte 			    (void) fprintf(stderr,
321*fcf3ce44SJohn Forte 				MSGSTR(112, "Error: Invalid pathname (%s)"),
322*fcf3ce44SJohn Forte 				argv[path_index]);
323*fcf3ce44SJohn Forte 			    (void) fprintf(stderr, "\n");
324*fcf3ce44SJohn Forte 			}
325*fcf3ce44SJohn Forte 		}
326*fcf3ce44SJohn Forte 		path_index++;
327*fcf3ce44SJohn Forte 		retval++;
328*fcf3ce44SJohn Forte 		continue;
329*fcf3ce44SJohn Forte 	    }
330*fcf3ce44SJohn Forte 
331*fcf3ce44SJohn Forte 	    if (strstr(argv[path_index], "/") != NULL) {
332*fcf3ce44SJohn Forte 		if (err = g_get_inquiry(path_phys, &inq)) {
333*fcf3ce44SJohn Forte 		    (void) fprintf(stderr, "\n");
334*fcf3ce44SJohn Forte 		    (void) print_errString(err, argv[path_index]);
335*fcf3ce44SJohn Forte 		    (void) fprintf(stderr, "\n");
336*fcf3ce44SJohn Forte 		    path_index++;
337*fcf3ce44SJohn Forte 		    retval++;
338*fcf3ce44SJohn Forte 		    continue;
339*fcf3ce44SJohn Forte 		}
340*fcf3ce44SJohn Forte 
341*fcf3ce44SJohn Forte 		serial_len = sizeof (inq80.inq_serial);
342*fcf3ce44SJohn Forte 		if (err = g_get_serial_number(path_phys, inq80.inq_serial,
343*fcf3ce44SJohn Forte 		    &serial_len)) {
344*fcf3ce44SJohn Forte 		    (void) fprintf(stderr, "\n");
345*fcf3ce44SJohn Forte 		    (void) print_errString(err, argv[path_index]);
346*fcf3ce44SJohn Forte 		    (void) fprintf(stderr, "\n");
347*fcf3ce44SJohn Forte 		    path_index++;
348*fcf3ce44SJohn Forte 		    retval++;
349*fcf3ce44SJohn Forte 		    continue;
350*fcf3ce44SJohn Forte 		}
351*fcf3ce44SJohn Forte 		print_inq_data(argv[path_index], path_phys, inq,
352*fcf3ce44SJohn Forte 		    inq80.inq_serial, serial_len);
353*fcf3ce44SJohn Forte 		path_index++;
354*fcf3ce44SJohn Forte 		continue;
355*fcf3ce44SJohn Forte 	    }
356*fcf3ce44SJohn Forte 	    if ((err = g_get_wwn_list(&wwn_list, 0)) != 0) {
357*fcf3ce44SJohn Forte 		return (err);
358*fcf3ce44SJohn Forte 	    }
359*fcf3ce44SJohn Forte 	    g_sort_wwn_list(&wwn_list);
360*fcf3ce44SJohn Forte 	    list_start = wwn_list;
361*fcf3ce44SJohn Forte 	    argpwwn = argnwwn = 0;
362*fcf3ce44SJohn Forte 	    (void) strcpy(last_logical_path, path_phys);
363*fcf3ce44SJohn Forte 	    for (wwn_list_ptr = wwn_list; wwn_list_ptr != NULL;
364*fcf3ce44SJohn Forte 		wwn_list_ptr = wwn_list_ptr->wwn_next) {
365*fcf3ce44SJohn Forte 		if (strcasecmp(wwn_list_ptr->port_wwn_s, path_struct->argv) ==
366*fcf3ce44SJohn Forte 			0) {
367*fcf3ce44SJohn Forte 			list_start = wwn_list_ptr;
368*fcf3ce44SJohn Forte 			argpwwn = 1;
369*fcf3ce44SJohn Forte 			break;
370*fcf3ce44SJohn Forte 		} else if (strcasecmp(wwn_list_ptr->node_wwn_s,
371*fcf3ce44SJohn Forte 			path_struct->argv) == 0) {
372*fcf3ce44SJohn Forte 			list_start = wwn_list_ptr;
373*fcf3ce44SJohn Forte 			argnwwn = 1;
374*fcf3ce44SJohn Forte 			break;
375*fcf3ce44SJohn Forte 		}
376*fcf3ce44SJohn Forte 	    }
377*fcf3ce44SJohn Forte 
378*fcf3ce44SJohn Forte 	    if (!(argpwwn || argnwwn)) {
379*fcf3ce44SJohn Forte 		/*
380*fcf3ce44SJohn Forte 		 * if the wwn list is null or the arg device not found
381*fcf3ce44SJohn Forte 		 * from the wwn list, still go ahead to issue inquiry.
382*fcf3ce44SJohn Forte 		 */
383*fcf3ce44SJohn Forte 		if (err = g_get_inquiry(path_phys, &inq)) {
384*fcf3ce44SJohn Forte 		    (void) fprintf(stderr, "\n");
385*fcf3ce44SJohn Forte 		    (void) print_errString(err, argv[path_index]);
386*fcf3ce44SJohn Forte 		    (void) fprintf(stderr, "\n");
387*fcf3ce44SJohn Forte 		    path_index++;
388*fcf3ce44SJohn Forte 		    retval++;
389*fcf3ce44SJohn Forte 		    continue;
390*fcf3ce44SJohn Forte 		}
391*fcf3ce44SJohn Forte 
392*fcf3ce44SJohn Forte 		serial_len = sizeof (inq80.inq_serial);
393*fcf3ce44SJohn Forte 		if (err = g_get_serial_number(path_phys, inq80.inq_serial,
394*fcf3ce44SJohn Forte 		    &serial_len)) {
395*fcf3ce44SJohn Forte 		    (void) fprintf(stderr, "\n");
396*fcf3ce44SJohn Forte 		    (void) print_errString(err, argv[path_index]);
397*fcf3ce44SJohn Forte 		    (void) fprintf(stderr, "\n");
398*fcf3ce44SJohn Forte 		    path_index++;
399*fcf3ce44SJohn Forte 		    retval++;
400*fcf3ce44SJohn Forte 		    continue;
401*fcf3ce44SJohn Forte 		}
402*fcf3ce44SJohn Forte 		print_inq_data(argv[path_index], path_phys, inq,
403*fcf3ce44SJohn Forte 		    inq80.inq_serial, serial_len);
404*fcf3ce44SJohn Forte 		(void) g_free_wwn_list(&wwn_list);
405*fcf3ce44SJohn Forte 		path_index++;
406*fcf3ce44SJohn Forte 		continue;
407*fcf3ce44SJohn Forte 	    }
408*fcf3ce44SJohn Forte 
409*fcf3ce44SJohn Forte 	    for (wwn_list_ptr = list_start; wwn_list_ptr != NULL;
410*fcf3ce44SJohn Forte 			wwn_list_ptr = wwn_list_ptr->wwn_next) {
411*fcf3ce44SJohn Forte 		if (argpwwn) {
412*fcf3ce44SJohn Forte 			if (strcasecmp(wwn_list_ptr->port_wwn_s,
413*fcf3ce44SJohn Forte 				path_struct->argv) != 0) {
414*fcf3ce44SJohn Forte 				continue;
415*fcf3ce44SJohn Forte 			}
416*fcf3ce44SJohn Forte 			(void) strcpy(path_phys,
417*fcf3ce44SJohn Forte 				wwn_list_ptr->physical_path);
418*fcf3ce44SJohn Forte 		} else if (argnwwn) {
419*fcf3ce44SJohn Forte 			if (strcasecmp(wwn_list_ptr->node_wwn_s,
420*fcf3ce44SJohn Forte 				path_struct->argv) != 0) {
421*fcf3ce44SJohn Forte 				continue;
422*fcf3ce44SJohn Forte 			}
423*fcf3ce44SJohn Forte 			if (strstr(wwn_list_ptr->logical_path,
424*fcf3ce44SJohn Forte 				last_logical_path) != NULL) {
425*fcf3ce44SJohn Forte 				continue;
426*fcf3ce44SJohn Forte 			}
427*fcf3ce44SJohn Forte 			(void) strcpy(path_phys,
428*fcf3ce44SJohn Forte 				wwn_list_ptr->physical_path);
429*fcf3ce44SJohn Forte 			(void) strcpy(last_logical_path,
430*fcf3ce44SJohn Forte 				wwn_list_ptr->logical_path);
431*fcf3ce44SJohn Forte 		}
432*fcf3ce44SJohn Forte 
433*fcf3ce44SJohn Forte 		if (err = g_get_inquiry(path_phys, &inq)) {
434*fcf3ce44SJohn Forte 		    (void) fprintf(stderr, "\n");
435*fcf3ce44SJohn Forte 		    (void) print_errString(err, argv[path_index]);
436*fcf3ce44SJohn Forte 		    (void) fprintf(stderr, "\n");
437*fcf3ce44SJohn Forte 		    retval++;
438*fcf3ce44SJohn Forte 		    break;
439*fcf3ce44SJohn Forte 		}
440*fcf3ce44SJohn Forte 
441*fcf3ce44SJohn Forte 		serial_len = sizeof (inq80.inq_serial);
442*fcf3ce44SJohn Forte 		if (err = g_get_serial_number(path_phys, inq80.inq_serial,
443*fcf3ce44SJohn Forte 		    &serial_len)) {
444*fcf3ce44SJohn Forte 		    (void) fprintf(stderr, "\n");
445*fcf3ce44SJohn Forte 		    (void) print_errString(err, argv[path_index]);
446*fcf3ce44SJohn Forte 		    (void) fprintf(stderr, "\n");
447*fcf3ce44SJohn Forte 		    retval++;
448*fcf3ce44SJohn Forte 		    break;
449*fcf3ce44SJohn Forte 		}
450*fcf3ce44SJohn Forte 		print_inq_data(argv[path_index], path_phys, inq,
451*fcf3ce44SJohn Forte 		    inq80.inq_serial, serial_len);
452*fcf3ce44SJohn Forte 
453*fcf3ce44SJohn Forte 	    }
454*fcf3ce44SJohn Forte 
455*fcf3ce44SJohn Forte 	    (void) g_free_wwn_list(&wwn_list);
456*fcf3ce44SJohn Forte 	    path_index++;
457*fcf3ce44SJohn Forte 	}
458*fcf3ce44SJohn Forte 	return (retval);
459*fcf3ce44SJohn Forte }
460*fcf3ce44SJohn Forte 
461*fcf3ce44SJohn Forte /*
462*fcf3ce44SJohn Forte  *	FORCELIP expert function
463*fcf3ce44SJohn Forte  */
464*fcf3ce44SJohn Forte int
465*fcf3ce44SJohn Forte adm_forcelip(char **argv)
466*fcf3ce44SJohn Forte {
467*fcf3ce44SJohn Forte int		slot, f_r, path_index = 0, err = 0, retval = 0;
468*fcf3ce44SJohn Forte Path_struct	*path_struct = NULL;
469*fcf3ce44SJohn Forte char		*path_phys = NULL, *ptr;
470*fcf3ce44SJohn Forte char		 err_path[MAXNAMELEN];
471*fcf3ce44SJohn Forte 
472*fcf3ce44SJohn Forte 	while (argv[path_index] != NULL) {
473*fcf3ce44SJohn Forte 		if ((err = l_convert_name(argv[path_index], &path_phys,
474*fcf3ce44SJohn Forte 				&path_struct, Options & PVERBOSE)) != 0) {
475*fcf3ce44SJohn Forte 			(void) strcpy(err_path, argv[path_index]);
476*fcf3ce44SJohn Forte 			if (err != -1) {
477*fcf3ce44SJohn Forte 				(void) print_errString(err, argv[path_index]);
478*fcf3ce44SJohn Forte 				path_index++;
479*fcf3ce44SJohn Forte 				retval++;
480*fcf3ce44SJohn Forte 				continue;
481*fcf3ce44SJohn Forte 			}
482*fcf3ce44SJohn Forte 			if (((ptr = strstr(err_path, ", ")) != NULL) &&
483*fcf3ce44SJohn Forte 				((*(ptr + 1) == 'f') || (*(ptr + 1) == 'r') ||
484*fcf3ce44SJohn Forte 							(*(ptr +1) == 's'))) {
485*fcf3ce44SJohn Forte 				*ptr = NULL;
486*fcf3ce44SJohn Forte 				slot = path_struct->slot;
487*fcf3ce44SJohn Forte 				f_r = path_struct->f_flag;
488*fcf3ce44SJohn Forte 				path_phys = NULL;
489*fcf3ce44SJohn Forte 				if ((err = l_convert_name(err_path,
490*fcf3ce44SJohn Forte 						&path_phys, &path_struct,
491*fcf3ce44SJohn Forte 						Options & PVERBOSE)) != 0) {
492*fcf3ce44SJohn Forte 					(void) fprintf(stderr, MSGSTR(33,
493*fcf3ce44SJohn Forte 						" Error: converting"
494*fcf3ce44SJohn Forte 						" %s to physical path.\n"
495*fcf3ce44SJohn Forte 						" Invalid pathname.\n"),
496*fcf3ce44SJohn Forte 							argv[path_index]);
497*fcf3ce44SJohn Forte 					if (err != -1) {
498*fcf3ce44SJohn Forte 						(void) print_errString(err,
499*fcf3ce44SJohn Forte 							argv[path_index]);
500*fcf3ce44SJohn Forte 					}
501*fcf3ce44SJohn Forte 					path_index++;
502*fcf3ce44SJohn Forte 					retval++;
503*fcf3ce44SJohn Forte 					continue;
504*fcf3ce44SJohn Forte 				}
505*fcf3ce44SJohn Forte 				if ((err = print_devState(argv[path_index],
506*fcf3ce44SJohn Forte 					path_struct->p_physical_path,
507*fcf3ce44SJohn Forte 					f_r, slot, Options & PVERBOSE)) != 0) {
508*fcf3ce44SJohn Forte 					path_index++;
509*fcf3ce44SJohn Forte 					retval++;
510*fcf3ce44SJohn Forte 					continue;
511*fcf3ce44SJohn Forte 				}
512*fcf3ce44SJohn Forte 			} else {
513*fcf3ce44SJohn Forte 				(void) fprintf(stderr, "\n ");
514*fcf3ce44SJohn Forte 				(void) fprintf(stderr, MSGSTR(112,
515*fcf3ce44SJohn Forte 					"Error: Invalid pathname (%s)"),
516*fcf3ce44SJohn Forte 							argv[path_index]);
517*fcf3ce44SJohn Forte 				(void) fprintf(stderr, "\n");
518*fcf3ce44SJohn Forte 			}
519*fcf3ce44SJohn Forte 			path_index++;
520*fcf3ce44SJohn Forte 			retval++;
521*fcf3ce44SJohn Forte 			continue;
522*fcf3ce44SJohn Forte 		}
523*fcf3ce44SJohn Forte 		if (err = g_force_lip(path_phys, Options & PVERBOSE)) {
524*fcf3ce44SJohn Forte 			(void) print_errString(err, argv[path_index]);
525*fcf3ce44SJohn Forte 			path_index++;
526*fcf3ce44SJohn Forte 			retval++;
527*fcf3ce44SJohn Forte 			continue;
528*fcf3ce44SJohn Forte 		}
529*fcf3ce44SJohn Forte 		path_index++;
530*fcf3ce44SJohn Forte 		if (path_struct != NULL) {
531*fcf3ce44SJohn Forte 			(void) free(path_struct);
532*fcf3ce44SJohn Forte 		}
533*fcf3ce44SJohn Forte 	}
534*fcf3ce44SJohn Forte 	return (retval);
535*fcf3ce44SJohn Forte }
536*fcf3ce44SJohn Forte 
537*fcf3ce44SJohn Forte 
538*fcf3ce44SJohn Forte /*
539*fcf3ce44SJohn Forte  *	DISPLAY function
540*fcf3ce44SJohn Forte  *
541*fcf3ce44SJohn Forte  * RETURNS:
542*fcf3ce44SJohn Forte  *	0	O.K.
543*fcf3ce44SJohn Forte  */
544*fcf3ce44SJohn Forte int
545*fcf3ce44SJohn Forte adm_display_config(char **argv)
546*fcf3ce44SJohn Forte {
547*fcf3ce44SJohn Forte L_inquiry	inq, ses_inq;
548*fcf3ce44SJohn Forte int		i, slot, f_r, path_index = 0, err = 0, opnerr = 0;
549*fcf3ce44SJohn Forte int		retval = 0;
550*fcf3ce44SJohn Forte gfc_map_t	map;
551*fcf3ce44SJohn Forte Path_struct	*path_struct;
552*fcf3ce44SJohn Forte char		*path_phys = NULL, *ptr;
553*fcf3ce44SJohn Forte char		ses_path[MAXPATHLEN], inq_path[MAXNAMELEN];
554*fcf3ce44SJohn Forte 
555*fcf3ce44SJohn Forte 
556*fcf3ce44SJohn Forte 	while (argv[path_index] != NULL) {
557*fcf3ce44SJohn Forte 	    VERBPRINT(MSGSTR(2108, "  Displaying information for: %s\n"),
558*fcf3ce44SJohn Forte 			argv[path_index]);
559*fcf3ce44SJohn Forte 		map.dev_addr = (gfc_port_dev_info_t *)NULL;
560*fcf3ce44SJohn Forte 	    if ((err = l_convert_name(argv[path_index], &path_phys,
561*fcf3ce44SJohn Forte 		&path_struct, Options & PVERBOSE)) != 0) {
562*fcf3ce44SJohn Forte 		if (strstr(argv[path_index], SCSI_VHCI) == NULL) {
563*fcf3ce44SJohn Forte 
564*fcf3ce44SJohn Forte 			(void) strcpy(inq_path, argv[path_index]);
565*fcf3ce44SJohn Forte 			if (((ptr = strstr(inq_path, ",")) != NULL) &&
566*fcf3ce44SJohn Forte 				((*(ptr + 1) == 'f') || (*(ptr + 1) == 'r') ||
567*fcf3ce44SJohn Forte 				(*(ptr +1) == 's'))) {
568*fcf3ce44SJohn Forte 
569*fcf3ce44SJohn Forte 				if (err != -1) {
570*fcf3ce44SJohn Forte 					(void) print_errString(err,
571*fcf3ce44SJohn Forte 						argv[path_index]);
572*fcf3ce44SJohn Forte 					path_index++;
573*fcf3ce44SJohn Forte 					retval++;
574*fcf3ce44SJohn Forte 					continue;
575*fcf3ce44SJohn Forte 				}
576*fcf3ce44SJohn Forte 				*ptr = NULL;
577*fcf3ce44SJohn Forte 				slot = path_struct->slot;
578*fcf3ce44SJohn Forte 				f_r = path_struct->f_flag;
579*fcf3ce44SJohn Forte 				if ((err = l_convert_name(inq_path, &path_phys,
580*fcf3ce44SJohn Forte 					&path_struct, Options & PVERBOSE))
581*fcf3ce44SJohn Forte 					!= 0) {
582*fcf3ce44SJohn Forte 
583*fcf3ce44SJohn Forte 					(void) fprintf(stderr,
584*fcf3ce44SJohn Forte 						MSGSTR(33,
585*fcf3ce44SJohn Forte 						" Error: converting"
586*fcf3ce44SJohn Forte 						" %s to physical path.\n"
587*fcf3ce44SJohn Forte 						" Invalid pathname.\n"),
588*fcf3ce44SJohn Forte 						argv[path_index]);
589*fcf3ce44SJohn Forte 					if (err != -1) {
590*fcf3ce44SJohn Forte 						(void) print_errString(err,
591*fcf3ce44SJohn Forte 							argv[path_index]);
592*fcf3ce44SJohn Forte 					}
593*fcf3ce44SJohn Forte 					path_index++;
594*fcf3ce44SJohn Forte 					retval++;
595*fcf3ce44SJohn Forte 					continue;
596*fcf3ce44SJohn Forte 				}
597*fcf3ce44SJohn Forte 
598*fcf3ce44SJohn Forte 				if ((err = print_devState(argv[path_index],
599*fcf3ce44SJohn Forte 					path_struct->p_physical_path,
600*fcf3ce44SJohn Forte 					f_r, slot, Options & PVERBOSE)) != 0) {
601*fcf3ce44SJohn Forte 						path_index++;
602*fcf3ce44SJohn Forte 						retval++;
603*fcf3ce44SJohn Forte 						continue;
604*fcf3ce44SJohn Forte 				}
605*fcf3ce44SJohn Forte 			} else {
606*fcf3ce44SJohn Forte 				if (err != -1) {
607*fcf3ce44SJohn Forte 					(void) print_errString(err,
608*fcf3ce44SJohn Forte 						argv[path_index]);
609*fcf3ce44SJohn Forte 				} else {
610*fcf3ce44SJohn Forte 					(void) fprintf(stderr, "\n ");
611*fcf3ce44SJohn Forte 					(void) fprintf(stderr,
612*fcf3ce44SJohn Forte 						MSGSTR(112,
613*fcf3ce44SJohn Forte 					"Error: Invalid pathname (%s)"),
614*fcf3ce44SJohn Forte 						argv[path_index]);
615*fcf3ce44SJohn Forte 					(void) fprintf(stderr, "\n");
616*fcf3ce44SJohn Forte 				}
617*fcf3ce44SJohn Forte 			}
618*fcf3ce44SJohn Forte 
619*fcf3ce44SJohn Forte 		} else {
620*fcf3ce44SJohn Forte 			if (err != -1) {
621*fcf3ce44SJohn Forte 				(void) print_errString(err,
622*fcf3ce44SJohn Forte 					argv[path_index]);
623*fcf3ce44SJohn Forte 			} else {
624*fcf3ce44SJohn Forte 				(void) fprintf(stderr, "\n ");
625*fcf3ce44SJohn Forte 				(void) fprintf(stderr,
626*fcf3ce44SJohn Forte 					MSGSTR(112,
627*fcf3ce44SJohn Forte 				"Error: Invalid pathname (%s)"),
628*fcf3ce44SJohn Forte 					argv[path_index]);
629*fcf3ce44SJohn Forte 				(void) fprintf(stderr, "\n");
630*fcf3ce44SJohn Forte 			}
631*fcf3ce44SJohn Forte 		}
632*fcf3ce44SJohn Forte 
633*fcf3ce44SJohn Forte 		path_index++;
634*fcf3ce44SJohn Forte 		retval++;
635*fcf3ce44SJohn Forte 		continue;
636*fcf3ce44SJohn Forte 	    }
637*fcf3ce44SJohn Forte 
638*fcf3ce44SJohn Forte 	/*
639*fcf3ce44SJohn Forte 	 * See what kind of device we are talking to.
640*fcf3ce44SJohn Forte 	 */
641*fcf3ce44SJohn Forte 	if ((opnerr = g_get_inquiry(path_phys, &inq)) != 0) {
642*fcf3ce44SJohn Forte 		if (opnerr == L_OPEN_PATH_FAIL) {
643*fcf3ce44SJohn Forte 			/*
644*fcf3ce44SJohn Forte 			 * We check only for L_OPEN_PATH_FAIL because
645*fcf3ce44SJohn Forte 			 * that is the only error code returned by
646*fcf3ce44SJohn Forte 			 * g_get_inquiry() which is not got from the ioctl
647*fcf3ce44SJohn Forte 			 * call itself. So, we are dependent, in a way, on the
648*fcf3ce44SJohn Forte 			 * implementation of g_get_inquiry().
649*fcf3ce44SJohn Forte 			 *
650*fcf3ce44SJohn Forte 			 */
651*fcf3ce44SJohn Forte 			(void) print_errString(errno, argv[path_index]);
652*fcf3ce44SJohn Forte 			path_index++;
653*fcf3ce44SJohn Forte 			retval++;
654*fcf3ce44SJohn Forte 			continue;
655*fcf3ce44SJohn Forte 		}
656*fcf3ce44SJohn Forte 	    } else if (!g_enclDiskChk((char *)inq.inq_vid,
657*fcf3ce44SJohn Forte 			(char *)inq.inq_pid)) {
658*fcf3ce44SJohn Forte 		    if ((err = lun_display(path_struct,
659*fcf3ce44SJohn Forte 					inq, Options & PVERBOSE)) != 0) {
660*fcf3ce44SJohn Forte 			    (void) print_errString(err, path_phys);
661*fcf3ce44SJohn Forte 			    exit(1);
662*fcf3ce44SJohn Forte 		    }
663*fcf3ce44SJohn Forte 	    } else if (strstr((char *)inq.inq_pid, ENCLOSURE_PROD_ID) != NULL) {
664*fcf3ce44SJohn Forte 		/*
665*fcf3ce44SJohn Forte 		 * Display SENA enclosure.
666*fcf3ce44SJohn Forte 		 */
667*fcf3ce44SJohn Forte 		(void) fprintf(stdout, "\n\t\t\t\t   ");
668*fcf3ce44SJohn Forte 		print_chars(inq.inq_pid, sizeof (inq.inq_pid), 0);
669*fcf3ce44SJohn Forte 
670*fcf3ce44SJohn Forte 		(void) fprintf(stdout, "\n");
671*fcf3ce44SJohn Forte 		if (Options & OPTION_R) {
672*fcf3ce44SJohn Forte 			adm_display_err(path_phys,
673*fcf3ce44SJohn Forte 			    (inq.inq_dtype & DTYPE_MASK));
674*fcf3ce44SJohn Forte 		} else {
675*fcf3ce44SJohn Forte 			pho_display_config(path_phys);
676*fcf3ce44SJohn Forte 		}
677*fcf3ce44SJohn Forte 	    } else if ((((inq.inq_dtype & DTYPE_MASK) == DTYPE_ESI)) &&
678*fcf3ce44SJohn Forte 			(l_get_enc_type(inq) == DAK_ENC_TYPE)) {
679*fcf3ce44SJohn Forte 		/*
680*fcf3ce44SJohn Forte 		 *  Display for the Daktari/DPM
681*fcf3ce44SJohn Forte 		 */
682*fcf3ce44SJohn Forte 		(void) fprintf(stdout, "\n\t\t");
683*fcf3ce44SJohn Forte 		for (i = 0; i < sizeof (inq.inq_pid); i++) {
684*fcf3ce44SJohn Forte 		    (void) fprintf(stdout, "%c", inq.inq_pid[i]);
685*fcf3ce44SJohn Forte 		}
686*fcf3ce44SJohn Forte 		(void) fprintf(stdout, "\n");
687*fcf3ce44SJohn Forte 		if (Options & OPTION_R) {
688*fcf3ce44SJohn Forte 		    adm_display_err(path_phys,
689*fcf3ce44SJohn Forte 			(inq.inq_dtype & DTYPE_MASK));
690*fcf3ce44SJohn Forte 		} else {
691*fcf3ce44SJohn Forte 		    dpm_display_config(path_phys);
692*fcf3ce44SJohn Forte 		}
693*fcf3ce44SJohn Forte 		/*
694*fcf3ce44SJohn Forte 		 * if device is in SENA enclosure
695*fcf3ce44SJohn Forte 		 *
696*fcf3ce44SJohn Forte 		 * if the slot is valid, then I know this is a SENA enclosure
697*fcf3ce44SJohn Forte 		 * and can continue
698*fcf3ce44SJohn Forte 		 * otherwise:
699*fcf3ce44SJohn Forte 		 *	I first get the ses_path, if this doesn't fail
700*fcf3ce44SJohn Forte 		 *	I retrieve the inquiry data from the ses node
701*fcf3ce44SJohn Forte 		 *	    and check teh PID to make sure this is a SENA
702*fcf3ce44SJohn Forte 		 */
703*fcf3ce44SJohn Forte 	    } else if (((inq.inq_dtype & DTYPE_MASK) == DTYPE_DIRECT) &&
704*fcf3ce44SJohn Forte 			((path_struct->slot_valid == 1) ||
705*fcf3ce44SJohn Forte 			    ((g_get_dev_map(path_phys, &map,
706*fcf3ce44SJohn Forte 				(Options & PVERBOSE)) == 0) &&
707*fcf3ce44SJohn Forte 			    (l_get_ses_path(path_phys, ses_path,
708*fcf3ce44SJohn Forte 				&map, Options & PVERBOSE) == 0) &&
709*fcf3ce44SJohn Forte 			    (g_get_inquiry(ses_path, &ses_inq) == 0) &&
710*fcf3ce44SJohn Forte 			    ((strstr((char *)ses_inq.inq_pid, ENCLOSURE_PROD_ID)
711*fcf3ce44SJohn Forte 				!= NULL))))) {
712*fcf3ce44SJohn Forte 		if (Options & OPTION_R) {
713*fcf3ce44SJohn Forte 			adm_display_err(path_phys,
714*fcf3ce44SJohn Forte 			(inq.inq_dtype & DTYPE_MASK));
715*fcf3ce44SJohn Forte 		} else {
716*fcf3ce44SJohn Forte 			display_fc_disk(path_struct, ses_path, &map, inq,
717*fcf3ce44SJohn Forte 							Options & PVERBOSE);
718*fcf3ce44SJohn Forte 		}
719*fcf3ce44SJohn Forte 
720*fcf3ce44SJohn Forte 	    } else if (strstr((char *)inq.inq_pid, "SUN_SEN") != 0) {
721*fcf3ce44SJohn Forte 			if (strcmp(argv[path_index], path_phys) != 0) {
722*fcf3ce44SJohn Forte 				(void) fprintf(stdout, "  ");
723*fcf3ce44SJohn Forte 				(void) fprintf(stdout,
724*fcf3ce44SJohn Forte 				MSGSTR(5, "Physical Path:"));
725*fcf3ce44SJohn Forte 				(void) fprintf(stdout, "\n  %s\n", path_phys);
726*fcf3ce44SJohn Forte 			}
727*fcf3ce44SJohn Forte 			(void) fprintf(stdout, MSGSTR(2109, "DEVICE is a "));
728*fcf3ce44SJohn Forte 			print_chars(inq.inq_vid, sizeof (inq.inq_vid), 1);
729*fcf3ce44SJohn Forte 			(void) fprintf(stdout, " ");
730*fcf3ce44SJohn Forte 			print_chars(inq.inq_pid, sizeof (inq.inq_pid), 1);
731*fcf3ce44SJohn Forte 			(void) fprintf(stdout, MSGSTR(2110, " card."));
732*fcf3ce44SJohn Forte 			if (inq.inq_len > 31) {
733*fcf3ce44SJohn Forte 				(void) fprintf(stdout, "   ");
734*fcf3ce44SJohn Forte 				(void) fprintf(stdout, MSGSTR(26, "Revision:"));
735*fcf3ce44SJohn Forte 				(void) fprintf(stdout, " ");
736*fcf3ce44SJohn Forte 				print_chars(inq.inq_revision,
737*fcf3ce44SJohn Forte 					sizeof (inq.inq_revision), 0);
738*fcf3ce44SJohn Forte 			}
739*fcf3ce44SJohn Forte 			(void) fprintf(stdout, "\n");
740*fcf3ce44SJohn Forte 		/* if device is not in SENA or SSA enclosures. */
741*fcf3ce44SJohn Forte 	    } else if ((inq.inq_dtype & DTYPE_MASK) < 0x10) {
742*fcf3ce44SJohn Forte 		switch ((inq.inq_dtype & DTYPE_MASK)) {
743*fcf3ce44SJohn Forte 			case DTYPE_DIRECT:
744*fcf3ce44SJohn Forte 			case DTYPE_SEQUENTIAL: /* Tape */
745*fcf3ce44SJohn Forte 				if (Options & OPTION_R) {
746*fcf3ce44SJohn Forte 					adm_display_err(path_phys,
747*fcf3ce44SJohn Forte 					(inq.inq_dtype & DTYPE_MASK));
748*fcf3ce44SJohn Forte 				} else if (non_encl_fc_disk_display(path_struct,
749*fcf3ce44SJohn Forte 					inq, Options & PVERBOSE) != 0) {
750*fcf3ce44SJohn Forte 					(void) fprintf(stderr,
751*fcf3ce44SJohn Forte 						MSGSTR(2111,
752*fcf3ce44SJohn Forte 						"Error: getting the device"
753*fcf3ce44SJohn Forte 						" information.\n"));
754*fcf3ce44SJohn Forte 					retval++;
755*fcf3ce44SJohn Forte 				}
756*fcf3ce44SJohn Forte 				break;
757*fcf3ce44SJohn Forte 			/* case 0x01: same as default */
758*fcf3ce44SJohn Forte 			default:
759*fcf3ce44SJohn Forte 				(void) fprintf(stdout, "  ");
760*fcf3ce44SJohn Forte 				(void) fprintf(stdout, MSGSTR(35,
761*fcf3ce44SJohn Forte 						"Device Type:"));
762*fcf3ce44SJohn Forte 				(void) fprintf(stdout, "%s\n",
763*fcf3ce44SJohn Forte 					dtype[inq.inq_dtype & DTYPE_MASK]);
764*fcf3ce44SJohn Forte 				break;
765*fcf3ce44SJohn Forte 		}
766*fcf3ce44SJohn Forte 	    } else if ((inq.inq_dtype & DTYPE_MASK) < 0x1f) {
767*fcf3ce44SJohn Forte 			(void) fprintf(stdout,
768*fcf3ce44SJohn Forte 				MSGSTR(2112, "  Device type: Reserved"));
769*fcf3ce44SJohn Forte 			(void) fprintf(stdout, "\n");
770*fcf3ce44SJohn Forte 	    } else {
771*fcf3ce44SJohn Forte 			(void) fprintf(stdout,
772*fcf3ce44SJohn Forte 				MSGSTR(2113, "  Device type: Unknown device"));
773*fcf3ce44SJohn Forte 			(void) fprintf(stdout, "\n");
774*fcf3ce44SJohn Forte 	    }
775*fcf3ce44SJohn Forte 	    path_index++;
776*fcf3ce44SJohn Forte 	    if (map.dev_addr != NULL) {
777*fcf3ce44SJohn Forte 		free((void *)map.dev_addr);
778*fcf3ce44SJohn Forte 	    }
779*fcf3ce44SJohn Forte 	    (void) free(path_struct);
780*fcf3ce44SJohn Forte 	}
781*fcf3ce44SJohn Forte 	return (retval);
782*fcf3ce44SJohn Forte }
783*fcf3ce44SJohn Forte 
784*fcf3ce44SJohn Forte 
785*fcf3ce44SJohn Forte /*
786*fcf3ce44SJohn Forte  * Powers off a list of SENA enclosure(s)
787*fcf3ce44SJohn Forte  * and disk(s) which is provided by the user.
788*fcf3ce44SJohn Forte  *
789*fcf3ce44SJohn Forte  * RETURNS:
790*fcf3ce44SJohn Forte  *	none.
791*fcf3ce44SJohn Forte  */
792*fcf3ce44SJohn Forte int
793*fcf3ce44SJohn Forte adm_power_off(char **argv, int off_flag)
794*fcf3ce44SJohn Forte {
795*fcf3ce44SJohn Forte int		path_index = 0, err = 0, retval = 0;
796*fcf3ce44SJohn Forte L_inquiry	inq;
797*fcf3ce44SJohn Forte char		*path_phys = NULL;
798*fcf3ce44SJohn Forte Path_struct	*path_struct;
799*fcf3ce44SJohn Forte 
800*fcf3ce44SJohn Forte 	while (argv[path_index] != NULL) {
801*fcf3ce44SJohn Forte 		if ((err = l_convert_name(argv[path_index], &path_phys,
802*fcf3ce44SJohn Forte 			&path_struct, Options & PVERBOSE)) != 0) {
803*fcf3ce44SJohn Forte 			/*
804*fcf3ce44SJohn Forte 			 * In case we did not find the device
805*fcf3ce44SJohn Forte 			 * in the /devices directory.
806*fcf3ce44SJohn Forte 			 *
807*fcf3ce44SJohn Forte 			 * Only valid for pathnames like box,f1
808*fcf3ce44SJohn Forte 			 */
809*fcf3ce44SJohn Forte 			if (path_struct->ib_path_flag) {
810*fcf3ce44SJohn Forte 				path_phys = path_struct->p_physical_path;
811*fcf3ce44SJohn Forte 			} else {
812*fcf3ce44SJohn Forte 				(void) fprintf(stderr,
813*fcf3ce44SJohn Forte 					MSGSTR(33,
814*fcf3ce44SJohn Forte 				" Error: converting"
815*fcf3ce44SJohn Forte 				" %s to physical path.\n"
816*fcf3ce44SJohn Forte 				" Invalid pathname.\n"),
817*fcf3ce44SJohn Forte 					argv[path_index]);
818*fcf3ce44SJohn Forte 				if (err != -1) {
819*fcf3ce44SJohn Forte 					(void) print_errString(err,
820*fcf3ce44SJohn Forte 							argv[path_index]);
821*fcf3ce44SJohn Forte 				}
822*fcf3ce44SJohn Forte 				path_index++;
823*fcf3ce44SJohn Forte 				retval++;
824*fcf3ce44SJohn Forte 				continue;
825*fcf3ce44SJohn Forte 			}
826*fcf3ce44SJohn Forte 		}
827*fcf3ce44SJohn Forte 		if (path_struct->ib_path_flag) {
828*fcf3ce44SJohn Forte 			/*
829*fcf3ce44SJohn Forte 			 * We are addressing a disk using a path
830*fcf3ce44SJohn Forte 			 * format type box,f1.
831*fcf3ce44SJohn Forte 			 */
832*fcf3ce44SJohn Forte 			if (err = l_dev_pwr_up_down(path_phys,
833*fcf3ce44SJohn Forte 			    path_struct, off_flag, Options & PVERBOSE,
834*fcf3ce44SJohn Forte 			    Options & OPTION_CAPF)) {
835*fcf3ce44SJohn Forte 				/*
836*fcf3ce44SJohn Forte 				 * Is it Bypassed... try to give more
837*fcf3ce44SJohn Forte 				 * informtaion.
838*fcf3ce44SJohn Forte 				 */
839*fcf3ce44SJohn Forte 				print_devState(argv[path_index],
840*fcf3ce44SJohn Forte 					path_struct->p_physical_path,
841*fcf3ce44SJohn Forte 					path_struct->f_flag, path_struct->slot,
842*fcf3ce44SJohn Forte 					Options & PVERBOSE);
843*fcf3ce44SJohn Forte 				retval++;
844*fcf3ce44SJohn Forte 			}
845*fcf3ce44SJohn Forte 			path_index++;
846*fcf3ce44SJohn Forte 			continue;
847*fcf3ce44SJohn Forte 		}
848*fcf3ce44SJohn Forte 
849*fcf3ce44SJohn Forte 		if (err = g_get_inquiry(path_phys, &inq)) {
850*fcf3ce44SJohn Forte 			(void) print_errString(err, argv[path_index]);
851*fcf3ce44SJohn Forte 			path_index++;
852*fcf3ce44SJohn Forte 			retval++;
853*fcf3ce44SJohn Forte 			continue;
854*fcf3ce44SJohn Forte 		}
855*fcf3ce44SJohn Forte 		if ((strstr((char *)inq.inq_pid, ENCLOSURE_PROD_ID) != 0) ||
856*fcf3ce44SJohn Forte 			(strncmp((char *)inq.inq_vid, "SUN     ",
857*fcf3ce44SJohn Forte 			sizeof (inq.inq_vid)) &&
858*fcf3ce44SJohn Forte 			((inq.inq_dtype & DTYPE_MASK) == DTYPE_ESI))) {
859*fcf3ce44SJohn Forte 
860*fcf3ce44SJohn Forte 			if (get_enclStatus(path_phys, argv[path_index],
861*fcf3ce44SJohn Forte 						off_flag) != 0) {
862*fcf3ce44SJohn Forte 				path_index++;
863*fcf3ce44SJohn Forte 				retval++;
864*fcf3ce44SJohn Forte 				continue;
865*fcf3ce44SJohn Forte 			}
866*fcf3ce44SJohn Forte 			/* power off SENA enclosure. */
867*fcf3ce44SJohn Forte 			if (err = l_pho_pwr_up_down(argv[path_index], path_phys,
868*fcf3ce44SJohn Forte 			    off_flag, Options & PVERBOSE,
869*fcf3ce44SJohn Forte 			    Options & OPTION_CAPF)) {
870*fcf3ce44SJohn Forte 				(void) print_errString(err, argv[path_index]);
871*fcf3ce44SJohn Forte 				retval++;
872*fcf3ce44SJohn Forte 			}
873*fcf3ce44SJohn Forte 		} else if ((inq.inq_dtype & DTYPE_MASK) == DTYPE_DIRECT) {
874*fcf3ce44SJohn Forte 			if (err = l_dev_pwr_up_down(path_phys,
875*fcf3ce44SJohn Forte 			    path_struct, off_flag, Options & PVERBOSE,
876*fcf3ce44SJohn Forte 			    Options & OPTION_CAPF)) {
877*fcf3ce44SJohn Forte 				(void) print_errString(err, argv[path_index]);
878*fcf3ce44SJohn Forte 				retval++;
879*fcf3ce44SJohn Forte 			}
880*fcf3ce44SJohn Forte 		} else {
881*fcf3ce44SJohn Forte 			/*
882*fcf3ce44SJohn Forte 			 * SSA section:
883*fcf3ce44SJohn Forte 			 */
884*fcf3ce44SJohn Forte 			(void) print_errString(L_INVALID_PATH,
885*fcf3ce44SJohn Forte 						argv[path_index]);
886*fcf3ce44SJohn Forte 		}
887*fcf3ce44SJohn Forte 		path_index++;
888*fcf3ce44SJohn Forte 	}
889*fcf3ce44SJohn Forte 	return (retval);
890*fcf3ce44SJohn Forte }
891*fcf3ce44SJohn Forte 
892*fcf3ce44SJohn Forte 
893*fcf3ce44SJohn Forte 
894*fcf3ce44SJohn Forte void
895*fcf3ce44SJohn Forte adm_bypass_enable(char **argv, int bypass_flag)
896*fcf3ce44SJohn Forte {
897*fcf3ce44SJohn Forte int		path_index = 0, err = 0;
898*fcf3ce44SJohn Forte L_inquiry	inq;
899*fcf3ce44SJohn Forte char		*path_phys = NULL;
900*fcf3ce44SJohn Forte Path_struct	*path_struct;
901*fcf3ce44SJohn Forte 
902*fcf3ce44SJohn Forte 	if ((err = l_convert_name(argv[path_index], &path_phys,
903*fcf3ce44SJohn Forte 		&path_struct, Options & PVERBOSE)) != 0) {
904*fcf3ce44SJohn Forte 		/*
905*fcf3ce44SJohn Forte 		 * In case we did not find the device
906*fcf3ce44SJohn Forte 		 * in the /devices directory.
907*fcf3ce44SJohn Forte 		 *
908*fcf3ce44SJohn Forte 		 * Only valid for pathnames like box,f1
909*fcf3ce44SJohn Forte 		 */
910*fcf3ce44SJohn Forte 		if (path_struct->ib_path_flag) {
911*fcf3ce44SJohn Forte 			path_phys = path_struct->p_physical_path;
912*fcf3ce44SJohn Forte 		} else {
913*fcf3ce44SJohn Forte 			(void) fprintf(stderr,
914*fcf3ce44SJohn Forte 					MSGSTR(33,
915*fcf3ce44SJohn Forte 						" Error: converting"
916*fcf3ce44SJohn Forte 						" %s to physical path.\n"
917*fcf3ce44SJohn Forte 						" Invalid pathname.\n"),
918*fcf3ce44SJohn Forte 					argv[path_index]);
919*fcf3ce44SJohn Forte 			if (err != -1) {
920*fcf3ce44SJohn Forte 				(void) print_errString(err, argv[path_index]);
921*fcf3ce44SJohn Forte 			}
922*fcf3ce44SJohn Forte 			exit(-1);
923*fcf3ce44SJohn Forte 		}
924*fcf3ce44SJohn Forte 	}
925*fcf3ce44SJohn Forte 	if (path_struct->ib_path_flag) {
926*fcf3ce44SJohn Forte 		if (Options & OPTION_F) {
927*fcf3ce44SJohn Forte 			E_USEAGE();
928*fcf3ce44SJohn Forte 			exit(-1);
929*fcf3ce44SJohn Forte 		}
930*fcf3ce44SJohn Forte 		/*
931*fcf3ce44SJohn Forte 		 * We are addressing a disk using a path
932*fcf3ce44SJohn Forte 		 * format type box,f1 and no disk
933*fcf3ce44SJohn Forte 		 * path was found.
934*fcf3ce44SJohn Forte 		 * So set the Force flag so no reserved/busy
935*fcf3ce44SJohn Forte 		 * check is performed.
936*fcf3ce44SJohn Forte 		 */
937*fcf3ce44SJohn Forte 		if (err = l_dev_bypass_enable(path_struct,
938*fcf3ce44SJohn Forte 			bypass_flag, OPTION_CAPF,
939*fcf3ce44SJohn Forte 			Options & OPTION_A,
940*fcf3ce44SJohn Forte 			Options & PVERBOSE)) {
941*fcf3ce44SJohn Forte 			(void) print_errString(err, argv[path_index]);
942*fcf3ce44SJohn Forte 			exit(-1);
943*fcf3ce44SJohn Forte 		}
944*fcf3ce44SJohn Forte 		return;
945*fcf3ce44SJohn Forte 	}
946*fcf3ce44SJohn Forte 
947*fcf3ce44SJohn Forte 	if (err = g_get_inquiry(path_phys, &inq)) {
948*fcf3ce44SJohn Forte 		(void) print_errString(err, argv[path_index]);
949*fcf3ce44SJohn Forte 		exit(-1);
950*fcf3ce44SJohn Forte 	}
951*fcf3ce44SJohn Forte 	if ((strstr((char *)inq.inq_pid, ENCLOSURE_PROD_ID) != 0) ||
952*fcf3ce44SJohn Forte 		(strncmp((char *)inq.inq_vid, "SUN     ",
953*fcf3ce44SJohn Forte 		sizeof (inq.inq_vid)) &&
954*fcf3ce44SJohn Forte 		((inq.inq_dtype & DTYPE_MASK) == DTYPE_ESI))) {
955*fcf3ce44SJohn Forte 		if ((!((Options & OPTION_F) ||
956*fcf3ce44SJohn Forte 			(Options & OPTION_R))) ||
957*fcf3ce44SJohn Forte 			((Options & OPTION_R) &&
958*fcf3ce44SJohn Forte 			(Options & OPTION_F))) {
959*fcf3ce44SJohn Forte 			E_USEAGE();
960*fcf3ce44SJohn Forte 			exit(-1);
961*fcf3ce44SJohn Forte 		}
962*fcf3ce44SJohn Forte 		if (err = l_bp_bypass_enable(path_phys, bypass_flag,
963*fcf3ce44SJohn Forte 			Options & OPTION_A,
964*fcf3ce44SJohn Forte 			Options & OPTION_F,
965*fcf3ce44SJohn Forte 			Options & OPTION_CAPF,
966*fcf3ce44SJohn Forte 			Options & PVERBOSE)) {
967*fcf3ce44SJohn Forte 		    (void) print_errString(err, argv[path_index]);
968*fcf3ce44SJohn Forte 		    exit(-1);
969*fcf3ce44SJohn Forte 		}
970*fcf3ce44SJohn Forte 	} else if ((inq.inq_dtype & DTYPE_MASK) == DTYPE_DIRECT) {
971*fcf3ce44SJohn Forte 		if (Options & OPTION_F) {
972*fcf3ce44SJohn Forte 			E_USEAGE();
973*fcf3ce44SJohn Forte 			exit(-1);
974*fcf3ce44SJohn Forte 		}
975*fcf3ce44SJohn Forte 		if (err = l_dev_bypass_enable(path_struct,
976*fcf3ce44SJohn Forte 			bypass_flag, Options & OPTION_CAPF,
977*fcf3ce44SJohn Forte 			Options & OPTION_A,
978*fcf3ce44SJohn Forte 			Options & PVERBOSE)) {
979*fcf3ce44SJohn Forte 			(void) print_errString(err, argv[path_index]);
980*fcf3ce44SJohn Forte 			exit(-1);
981*fcf3ce44SJohn Forte 		}
982*fcf3ce44SJohn Forte 	}
983*fcf3ce44SJohn Forte }
984*fcf3ce44SJohn Forte 
985*fcf3ce44SJohn Forte /*
986*fcf3ce44SJohn Forte  * adm_download() Download subsystem microcode.
987*fcf3ce44SJohn Forte  * Path must point to a LUX IB.
988*fcf3ce44SJohn Forte  *
989*fcf3ce44SJohn Forte  * RETURNS:
990*fcf3ce44SJohn Forte  *	None.
991*fcf3ce44SJohn Forte  */
992*fcf3ce44SJohn Forte void
993*fcf3ce44SJohn Forte adm_download(char **argv, char *file_name)
994*fcf3ce44SJohn Forte {
995*fcf3ce44SJohn Forte int		path_index = 0, err = 0;
996*fcf3ce44SJohn Forte char		*path_phys = NULL;
997*fcf3ce44SJohn Forte L_inquiry	inq;
998*fcf3ce44SJohn Forte Path_struct	*path_struct;
999*fcf3ce44SJohn Forte 
1000*fcf3ce44SJohn Forte 	while (argv[path_index] != NULL) {
1001*fcf3ce44SJohn Forte 		/*
1002*fcf3ce44SJohn Forte 		 * See what kind of device we are talking to.
1003*fcf3ce44SJohn Forte 		 */
1004*fcf3ce44SJohn Forte 		if ((err = l_convert_name(argv[path_index], &path_phys,
1005*fcf3ce44SJohn Forte 			&path_struct, Options & PVERBOSE)) != 0) {
1006*fcf3ce44SJohn Forte 			(void) fprintf(stderr,
1007*fcf3ce44SJohn Forte 					MSGSTR(33,
1008*fcf3ce44SJohn Forte 						" Error: converting"
1009*fcf3ce44SJohn Forte 						" %s to physical path.\n"
1010*fcf3ce44SJohn Forte 						" Invalid pathname.\n"),
1011*fcf3ce44SJohn Forte 					argv[path_index]);
1012*fcf3ce44SJohn Forte 			if (err != -1) {
1013*fcf3ce44SJohn Forte 				(void) print_errString(err, argv[path_index]);
1014*fcf3ce44SJohn Forte 			}
1015*fcf3ce44SJohn Forte 			exit(-1);
1016*fcf3ce44SJohn Forte 		}
1017*fcf3ce44SJohn Forte 		if (err = g_get_inquiry(path_phys, &inq)) {
1018*fcf3ce44SJohn Forte 			(void) print_errString(err, argv[path_index]);
1019*fcf3ce44SJohn Forte 			exit(-1);
1020*fcf3ce44SJohn Forte 		}
1021*fcf3ce44SJohn Forte 		if ((strstr((char *)inq.inq_pid, ENCLOSURE_PROD_ID) != 0) ||
1022*fcf3ce44SJohn Forte 			(strncmp((char *)inq.inq_vid, "SUN     ",
1023*fcf3ce44SJohn Forte 			sizeof (inq.inq_vid)) &&
1024*fcf3ce44SJohn Forte 			((inq.inq_dtype & DTYPE_MASK) == DTYPE_ESI))) {
1025*fcf3ce44SJohn Forte 			if (err = l_download(path_phys,
1026*fcf3ce44SJohn Forte 				file_name, (Options & SAVE),
1027*fcf3ce44SJohn Forte 				(Options & PVERBOSE))) {
1028*fcf3ce44SJohn Forte 				(void) print_errString(err,
1029*fcf3ce44SJohn Forte 					(err == L_OPEN_PATH_FAIL) ?
1030*fcf3ce44SJohn Forte 					argv[path_index]: file_name);
1031*fcf3ce44SJohn Forte 				exit(-1);
1032*fcf3ce44SJohn Forte 			}
1033*fcf3ce44SJohn Forte 		} else {
1034*fcf3ce44SJohn Forte 			(void) fprintf(stderr,
1035*fcf3ce44SJohn Forte 				MSGSTR(112, "Error: Invalid pathname (%s)"),
1036*fcf3ce44SJohn Forte 				argv[path_index]);
1037*fcf3ce44SJohn Forte 		}
1038*fcf3ce44SJohn Forte 		path_index++;
1039*fcf3ce44SJohn Forte 	}
1040*fcf3ce44SJohn Forte }
1041*fcf3ce44SJohn Forte 
1042*fcf3ce44SJohn Forte /*
1043*fcf3ce44SJohn Forte  * display_link_status() Reads and displays the link status.
1044*fcf3ce44SJohn Forte  *
1045*fcf3ce44SJohn Forte  * RETURNS:
1046*fcf3ce44SJohn Forte  *	none.
1047*fcf3ce44SJohn Forte  */
1048*fcf3ce44SJohn Forte void
1049*fcf3ce44SJohn Forte display_link_status(char **argv)
1050*fcf3ce44SJohn Forte {
1051*fcf3ce44SJohn Forte AL_rls		*rls = NULL, *n;
1052*fcf3ce44SJohn Forte int		path_index = 0, err = 0;
1053*fcf3ce44SJohn Forte char		*path_phys = NULL;
1054*fcf3ce44SJohn Forte Path_struct	*path_struct;
1055*fcf3ce44SJohn Forte 
1056*fcf3ce44SJohn Forte 
1057*fcf3ce44SJohn Forte 	while (argv[path_index] != NULL) {
1058*fcf3ce44SJohn Forte 		if ((err = l_convert_name(argv[path_index], &path_phys,
1059*fcf3ce44SJohn Forte 			&path_struct, Options & PVERBOSE)) != 0) {
1060*fcf3ce44SJohn Forte 			(void) fprintf(stderr,
1061*fcf3ce44SJohn Forte 					MSGSTR(33,
1062*fcf3ce44SJohn Forte 						" Error: converting"
1063*fcf3ce44SJohn Forte 						" %s to physical path.\n"
1064*fcf3ce44SJohn Forte 						" Invalid pathname.\n"),
1065*fcf3ce44SJohn Forte 					argv[path_index]);
1066*fcf3ce44SJohn Forte 			if (err != -1) {
1067*fcf3ce44SJohn Forte 				(void) print_errString(err, argv[path_index]);
1068*fcf3ce44SJohn Forte 			}
1069*fcf3ce44SJohn Forte 			exit(-1);
1070*fcf3ce44SJohn Forte 		}
1071*fcf3ce44SJohn Forte 		if (err = g_rdls(path_phys, &rls, Options & PVERBOSE)) {
1072*fcf3ce44SJohn Forte 		    (void) print_errString(err, argv[path_index]);
1073*fcf3ce44SJohn Forte 		    exit(-1);
1074*fcf3ce44SJohn Forte 		}
1075*fcf3ce44SJohn Forte 		n = rls;
1076*fcf3ce44SJohn Forte 		if (n != NULL) {
1077*fcf3ce44SJohn Forte 			(void) fprintf(stdout,
1078*fcf3ce44SJohn Forte 			MSGSTR(2007, "\nLink Error Status "
1079*fcf3ce44SJohn Forte 				"information for loop:%s\n"),
1080*fcf3ce44SJohn Forte 				n->driver_path);
1081*fcf3ce44SJohn Forte 			(void) fprintf(stdout, MSGSTR(2008, "al_pa   lnk fail "
1082*fcf3ce44SJohn Forte 			"   sync loss   signal loss   sequence err"
1083*fcf3ce44SJohn Forte 			"   invalid word   CRC\n"));
1084*fcf3ce44SJohn Forte 		}
1085*fcf3ce44SJohn Forte 		while (n) {
1086*fcf3ce44SJohn Forte 			if ((n->payload.rls_linkfail == 0xffffffff) &&
1087*fcf3ce44SJohn Forte 			    (n->payload.rls_syncfail == 0xffffffff) &&
1088*fcf3ce44SJohn Forte 			    (n->payload.rls_sigfail == 0xffffffff) &&
1089*fcf3ce44SJohn Forte 			    (n->payload.rls_primitiverr == 0xffffffff) &&
1090*fcf3ce44SJohn Forte 			    (n->payload.rls_invalidword == 0xffffffff) &&
1091*fcf3ce44SJohn Forte 			    (n->payload.rls_invalidcrc == 0xffffffff)) {
1092*fcf3ce44SJohn Forte 				(void) fprintf(stdout,
1093*fcf3ce44SJohn Forte 					"%x\t%-12d%-12d%-14d%-15d%-15d%-12d\n",
1094*fcf3ce44SJohn Forte 					n->al_ha,
1095*fcf3ce44SJohn Forte 					n->payload.rls_linkfail,
1096*fcf3ce44SJohn Forte 					n->payload.rls_syncfail,
1097*fcf3ce44SJohn Forte 					n->payload.rls_sigfail,
1098*fcf3ce44SJohn Forte 					n->payload.rls_primitiverr,
1099*fcf3ce44SJohn Forte 					n->payload.rls_invalidword,
1100*fcf3ce44SJohn Forte 					n->payload.rls_invalidcrc);
1101*fcf3ce44SJohn Forte 			} else {
1102*fcf3ce44SJohn Forte 				(void) fprintf(stdout,
1103*fcf3ce44SJohn Forte 					"%x\t%-12u%-12u%-14u%-15u%-15u%-12u\n",
1104*fcf3ce44SJohn Forte 					n->al_ha,
1105*fcf3ce44SJohn Forte 					n->payload.rls_linkfail,
1106*fcf3ce44SJohn Forte 					n->payload.rls_syncfail,
1107*fcf3ce44SJohn Forte 					n->payload.rls_sigfail,
1108*fcf3ce44SJohn Forte 					n->payload.rls_primitiverr,
1109*fcf3ce44SJohn Forte 					n->payload.rls_invalidword,
1110*fcf3ce44SJohn Forte 					n->payload.rls_invalidcrc);
1111*fcf3ce44SJohn Forte 			}
1112*fcf3ce44SJohn Forte 			n = n->next;
1113*fcf3ce44SJohn Forte 		}
1114*fcf3ce44SJohn Forte 
1115*fcf3ce44SJohn Forte 		path_index++;
1116*fcf3ce44SJohn Forte 	}
1117*fcf3ce44SJohn Forte 	(void) fprintf(stdout,
1118*fcf3ce44SJohn Forte 		MSGSTR(2009, "NOTE: These LESB counts are not"
1119*fcf3ce44SJohn Forte 		" cleared by a reset, only power cycles.\n"
1120*fcf3ce44SJohn Forte 		"These counts must be compared"
1121*fcf3ce44SJohn Forte 		" to previously read counts.\n"));
1122*fcf3ce44SJohn Forte }
1123*fcf3ce44SJohn Forte 
1124*fcf3ce44SJohn Forte 
1125*fcf3ce44SJohn Forte /*
1126*fcf3ce44SJohn Forte  * ib_present_chk() Check to see if IB 0 or 1 is present in the box.
1127*fcf3ce44SJohn Forte  *
1128*fcf3ce44SJohn Forte  * RETURN:
1129*fcf3ce44SJohn Forte  *	1 if ib present
1130*fcf3ce44SJohn Forte  *	0 otherwise
1131*fcf3ce44SJohn Forte  */
1132*fcf3ce44SJohn Forte int
1133*fcf3ce44SJohn Forte ib_present_chk(struct l_state_struct *l_state, int which_one)
1134*fcf3ce44SJohn Forte {
1135*fcf3ce44SJohn Forte Ctlr_elem_st	ctlr;
1136*fcf3ce44SJohn Forte int	i;
1137*fcf3ce44SJohn Forte int	elem_index = 0;
1138*fcf3ce44SJohn Forte int	result = 1;
1139*fcf3ce44SJohn Forte 
1140*fcf3ce44SJohn Forte 	for (i = 0; i < (int)l_state->ib_tbl.config.enc_num_elem; i++) {
1141*fcf3ce44SJohn Forte 	    elem_index++;		/* skip global */
1142*fcf3ce44SJohn Forte 	    if (l_state->ib_tbl.config.type_hdr[i].type == ELM_TYP_IB) {
1143*fcf3ce44SJohn Forte 		(void) bcopy((const void *)
1144*fcf3ce44SJohn Forte 			&l_state->ib_tbl.p2_s.element[elem_index + which_one],
1145*fcf3ce44SJohn Forte 			(void *)&ctlr, sizeof (ctlr));
1146*fcf3ce44SJohn Forte 		if (ctlr.code == S_NOT_INSTALLED) {
1147*fcf3ce44SJohn Forte 			result = 0;
1148*fcf3ce44SJohn Forte 		}
1149*fcf3ce44SJohn Forte 		break;
1150*fcf3ce44SJohn Forte 	    }
1151*fcf3ce44SJohn Forte 	    elem_index += l_state->ib_tbl.config.type_hdr[i].num;
1152*fcf3ce44SJohn Forte 	}
1153*fcf3ce44SJohn Forte 	return (result);
1154*fcf3ce44SJohn Forte }
1155*fcf3ce44SJohn Forte 
1156*fcf3ce44SJohn Forte /*
1157*fcf3ce44SJohn Forte  * print_individual_state() Print individual disk status.
1158*fcf3ce44SJohn Forte  *
1159*fcf3ce44SJohn Forte  * RETURNS:
1160*fcf3ce44SJohn Forte  *	none.
1161*fcf3ce44SJohn Forte  */
1162*fcf3ce44SJohn Forte void
1163*fcf3ce44SJohn Forte print_individual_state(int status, int port)
1164*fcf3ce44SJohn Forte {
1165*fcf3ce44SJohn Forte 	if (status & L_OPEN_FAIL) {
1166*fcf3ce44SJohn Forte 		(void) fprintf(stdout, " (");
1167*fcf3ce44SJohn Forte 		(void) fprintf(stdout,
1168*fcf3ce44SJohn Forte 		MSGSTR(28, "Open Failed"));
1169*fcf3ce44SJohn Forte 		(void) fprintf(stdout, ")  ");
1170*fcf3ce44SJohn Forte 	} else if (status & L_NOT_READY) {
1171*fcf3ce44SJohn Forte 		(void) fprintf(stdout, " (");
1172*fcf3ce44SJohn Forte 		(void) fprintf(stdout,
1173*fcf3ce44SJohn Forte 			MSGSTR(20, "Not Ready"));
1174*fcf3ce44SJohn Forte 		(void) fprintf(stdout, ")    ");
1175*fcf3ce44SJohn Forte 	} else if (status & L_NOT_READABLE) {
1176*fcf3ce44SJohn Forte 		(void) fprintf(stdout, "(");
1177*fcf3ce44SJohn Forte 		(void) fprintf(stdout,
1178*fcf3ce44SJohn Forte 		MSGSTR(88, "Not Readable"));
1179*fcf3ce44SJohn Forte 		(void) fprintf(stdout, ")  ");
1180*fcf3ce44SJohn Forte 	} else if (status & L_SPUN_DWN_D) {
1181*fcf3ce44SJohn Forte 		(void) fprintf(stdout, " (");
1182*fcf3ce44SJohn Forte 		(void) fprintf(stdout,
1183*fcf3ce44SJohn Forte 		MSGSTR(68, "Spun Down"));
1184*fcf3ce44SJohn Forte 		(void) fprintf(stdout, ")    ");
1185*fcf3ce44SJohn Forte 	} else if (status & L_SCSI_ERR) {
1186*fcf3ce44SJohn Forte 		(void) fprintf(stdout, " (");
1187*fcf3ce44SJohn Forte 		(void) fprintf(stdout,
1188*fcf3ce44SJohn Forte 		MSGSTR(70, "SCSI Error"));
1189*fcf3ce44SJohn Forte 		(void) fprintf(stdout, ")   ");
1190*fcf3ce44SJohn Forte 	} else if (status & L_RESERVED) {
1191*fcf3ce44SJohn Forte 		if (port == PORT_A) {
1192*fcf3ce44SJohn Forte 			(void) fprintf(stdout,
1193*fcf3ce44SJohn Forte 			MSGSTR(2010,
1194*fcf3ce44SJohn Forte 				" (Rsrv cnflt:A) "));
1195*fcf3ce44SJohn Forte 		} else if (port == PORT_B) {
1196*fcf3ce44SJohn Forte 			(void) fprintf(stdout,
1197*fcf3ce44SJohn Forte 			MSGSTR(2011,
1198*fcf3ce44SJohn Forte 				" (Rsrv cnflt:B) "));
1199*fcf3ce44SJohn Forte 		} else {
1200*fcf3ce44SJohn Forte 			(void) fprintf(stdout,
1201*fcf3ce44SJohn Forte 			MSGSTR(2012,
1202*fcf3ce44SJohn Forte 				" (Reserve cnflt)"));
1203*fcf3ce44SJohn Forte 		}
1204*fcf3ce44SJohn Forte 	} else if (status & L_NO_LABEL) {
1205*fcf3ce44SJohn Forte 		(void) fprintf(stdout, "(");
1206*fcf3ce44SJohn Forte 		(void) fprintf(stdout,
1207*fcf3ce44SJohn Forte 			MSGSTR(92, "No UNIX Label"));
1208*fcf3ce44SJohn Forte 		(void) fprintf(stdout, ") ");
1209*fcf3ce44SJohn Forte 	}
1210*fcf3ce44SJohn Forte }
1211*fcf3ce44SJohn Forte 
1212*fcf3ce44SJohn Forte 
1213*fcf3ce44SJohn Forte /*
1214*fcf3ce44SJohn Forte  * display_disk_msg() Displays status for
1215*fcf3ce44SJohn Forte  * an individual SENA device.
1216*fcf3ce44SJohn Forte  *
1217*fcf3ce44SJohn Forte  * RETURNS:
1218*fcf3ce44SJohn Forte  *	none.
1219*fcf3ce44SJohn Forte  */
1220*fcf3ce44SJohn Forte void
1221*fcf3ce44SJohn Forte display_disk_msg(struct l_disk_state_struct *dsk_ptr,
1222*fcf3ce44SJohn Forte 	struct l_state_struct *l_state, Bp_elem_st *bp, int front_flag)
1223*fcf3ce44SJohn Forte {
1224*fcf3ce44SJohn Forte int	loop_flag = 0;
1225*fcf3ce44SJohn Forte int	a_and_b = 0;
1226*fcf3ce44SJohn Forte int	state_a = 0, state_b = 0;
1227*fcf3ce44SJohn Forte 
1228*fcf3ce44SJohn Forte 	if (dsk_ptr->ib_status.code == S_NOT_INSTALLED) {
1229*fcf3ce44SJohn Forte 		(void) fprintf(stdout,
1230*fcf3ce44SJohn Forte 			MSGSTR(30, "Not Installed"));
1231*fcf3ce44SJohn Forte 			(void) fprintf(stdout, " ");
1232*fcf3ce44SJohn Forte 		if (dsk_ptr->ib_status.fault ||
1233*fcf3ce44SJohn Forte 			dsk_ptr->ib_status.fault_req) {
1234*fcf3ce44SJohn Forte 			(void) fprintf(stdout, "(");
1235*fcf3ce44SJohn Forte 			(void) fprintf(stdout,
1236*fcf3ce44SJohn Forte 				MSGSTR(2013, "Faulted"));
1237*fcf3ce44SJohn Forte 			(void) fprintf(stdout,
1238*fcf3ce44SJohn Forte 						")           ");
1239*fcf3ce44SJohn Forte 		} else if (dsk_ptr->ib_status.ident ||
1240*fcf3ce44SJohn Forte 			dsk_ptr->ib_status.rdy_to_ins ||
1241*fcf3ce44SJohn Forte 			dsk_ptr->ib_status.rmv) {
1242*fcf3ce44SJohn Forte 			(void) fprintf(stdout,
1243*fcf3ce44SJohn Forte 				MSGSTR(2014,
1244*fcf3ce44SJohn Forte 						"(LED Blinking)      "));
1245*fcf3ce44SJohn Forte 		} else {
1246*fcf3ce44SJohn Forte 			(void) fprintf(stdout,
1247*fcf3ce44SJohn Forte 						"                    ");
1248*fcf3ce44SJohn Forte 		}
1249*fcf3ce44SJohn Forte 	} else if (dsk_ptr->ib_status.dev_off) {
1250*fcf3ce44SJohn Forte 		(void) fprintf(stdout, MSGSTR(2015, "Off"));
1251*fcf3ce44SJohn Forte 		if (dsk_ptr->ib_status.fault || dsk_ptr->ib_status.fault_req) {
1252*fcf3ce44SJohn Forte 			(void) fprintf(stdout, "(");
1253*fcf3ce44SJohn Forte 			(void) fprintf(stdout,
1254*fcf3ce44SJohn Forte 				MSGSTR(2016, "Faulted"));
1255*fcf3ce44SJohn Forte 			(void) fprintf(stdout,
1256*fcf3ce44SJohn Forte 					")                      ");
1257*fcf3ce44SJohn Forte 		} else if (dsk_ptr->ib_status.bypass_a_en &&
1258*fcf3ce44SJohn Forte 			dsk_ptr->ib_status.bypass_b_en) {
1259*fcf3ce44SJohn Forte 			(void) fprintf(stdout,
1260*fcf3ce44SJohn Forte 				MSGSTR(2017,
1261*fcf3ce44SJohn Forte 					"(Bypassed:AB)"));
1262*fcf3ce44SJohn Forte 			(void) fprintf(stdout,
1263*fcf3ce44SJohn Forte 					"                  ");
1264*fcf3ce44SJohn Forte 		} else if (dsk_ptr->ib_status.bypass_a_en) {
1265*fcf3ce44SJohn Forte 			(void) fprintf(stdout,
1266*fcf3ce44SJohn Forte 				MSGSTR(2018,
1267*fcf3ce44SJohn Forte 					"(Bypassed: A)"));
1268*fcf3ce44SJohn Forte 			(void) fprintf(stdout,
1269*fcf3ce44SJohn Forte 					"                  ");
1270*fcf3ce44SJohn Forte 		} else if (dsk_ptr->ib_status.bypass_b_en) {
1271*fcf3ce44SJohn Forte 			(void) fprintf(stdout,
1272*fcf3ce44SJohn Forte 				MSGSTR(2019,
1273*fcf3ce44SJohn Forte 					"(Bypassed: B)"));
1274*fcf3ce44SJohn Forte 			(void) fprintf(stdout,
1275*fcf3ce44SJohn Forte 					"                  ");
1276*fcf3ce44SJohn Forte 		} else {
1277*fcf3ce44SJohn Forte 			(void) fprintf(stdout,
1278*fcf3ce44SJohn Forte 					"                              ");
1279*fcf3ce44SJohn Forte 		}
1280*fcf3ce44SJohn Forte 	} else {
1281*fcf3ce44SJohn Forte 		(void) fprintf(stdout, MSGSTR(2020, "On"));
1282*fcf3ce44SJohn Forte 
1283*fcf3ce44SJohn Forte 		if (dsk_ptr->ib_status.fault || dsk_ptr->ib_status.fault_req) {
1284*fcf3ce44SJohn Forte 			(void) fprintf(stdout, " (");
1285*fcf3ce44SJohn Forte 			(void) fprintf(stdout,
1286*fcf3ce44SJohn Forte 				MSGSTR(2021, "Faulted"));
1287*fcf3ce44SJohn Forte 			(void) fprintf(stdout, ")      ");
1288*fcf3ce44SJohn Forte 		} else if (dsk_ptr->ib_status.bypass_a_en &&
1289*fcf3ce44SJohn Forte 			dsk_ptr->ib_status.bypass_b_en) {
1290*fcf3ce44SJohn Forte 			(void) fprintf(stdout, " ");
1291*fcf3ce44SJohn Forte 			(void) fprintf(stdout,
1292*fcf3ce44SJohn Forte 				MSGSTR(2022, "(Bypassed:AB)"));
1293*fcf3ce44SJohn Forte 			(void) fprintf(stdout, "  ");
1294*fcf3ce44SJohn Forte 		} else if (ib_present_chk(l_state, 0) &&
1295*fcf3ce44SJohn Forte 			dsk_ptr->ib_status.bypass_a_en) {
1296*fcf3ce44SJohn Forte 			/*
1297*fcf3ce44SJohn Forte 			 * Before printing that the port is bypassed
1298*fcf3ce44SJohn Forte 			 * verify that there is an IB for this port.
1299*fcf3ce44SJohn Forte 			 * If not then don't print.
1300*fcf3ce44SJohn Forte 			 */
1301*fcf3ce44SJohn Forte 			(void) fprintf(stdout, " ");
1302*fcf3ce44SJohn Forte 			(void) fprintf(stdout,
1303*fcf3ce44SJohn Forte 				MSGSTR(2023, "(Bypassed: A)"));
1304*fcf3ce44SJohn Forte 			(void) fprintf(stdout, "  ");
1305*fcf3ce44SJohn Forte 		} else if (ib_present_chk(l_state, 1) &&
1306*fcf3ce44SJohn Forte 			dsk_ptr->ib_status.bypass_b_en) {
1307*fcf3ce44SJohn Forte 			(void) fprintf(stdout, " ");
1308*fcf3ce44SJohn Forte 			(void) fprintf(stdout,
1309*fcf3ce44SJohn Forte 				MSGSTR(2024, "(Bypassed: B)"));
1310*fcf3ce44SJohn Forte 			(void) fprintf(stdout, "  ");
1311*fcf3ce44SJohn Forte 		} else if ((bp->code != S_NOT_INSTALLED) &&
1312*fcf3ce44SJohn Forte 				((bp->byp_a_enabled || bp->en_bypass_a) &&
1313*fcf3ce44SJohn Forte 				!(bp->byp_b_enabled || bp->en_bypass_b))) {
1314*fcf3ce44SJohn Forte 			(void) fprintf(stdout,
1315*fcf3ce44SJohn Forte 				MSGSTR(2025,
1316*fcf3ce44SJohn Forte 					" (Bypassed BP: A)"));
1317*fcf3ce44SJohn Forte 		} else if ((bp->code != S_NOT_INSTALLED) &&
1318*fcf3ce44SJohn Forte 				((bp->byp_b_enabled || bp->en_bypass_b) &&
1319*fcf3ce44SJohn Forte 				!(bp->byp_a_enabled || bp->en_bypass_a))) {
1320*fcf3ce44SJohn Forte 			(void) fprintf(stdout,
1321*fcf3ce44SJohn Forte 				MSGSTR(2026,
1322*fcf3ce44SJohn Forte 					"(Bypassed BP: B)"));
1323*fcf3ce44SJohn Forte 		} else if ((bp->code != S_NOT_INSTALLED) &&
1324*fcf3ce44SJohn Forte 				((bp->byp_a_enabled || bp->en_bypass_a) &&
1325*fcf3ce44SJohn Forte 				(bp->byp_b_enabled || bp->en_bypass_b))) {
1326*fcf3ce44SJohn Forte 			(void) fprintf(stdout,
1327*fcf3ce44SJohn Forte 				MSGSTR(2027,
1328*fcf3ce44SJohn Forte 					"(Bypassed BP:AB)"));
1329*fcf3ce44SJohn Forte 		} else {
1330*fcf3ce44SJohn Forte 			state_a = dsk_ptr->g_disk_state.d_state_flags[PORT_A];
1331*fcf3ce44SJohn Forte 			state_b = dsk_ptr->g_disk_state.d_state_flags[PORT_B];
1332*fcf3ce44SJohn Forte 			a_and_b = state_a & state_b;
1333*fcf3ce44SJohn Forte 
1334*fcf3ce44SJohn Forte 			if (dsk_ptr->l_state_flag & L_NO_LOOP) {
1335*fcf3ce44SJohn Forte 				(void) fprintf(stdout,
1336*fcf3ce44SJohn Forte 				MSGSTR(2028,
1337*fcf3ce44SJohn Forte 					" (Loop not accessible)"));
1338*fcf3ce44SJohn Forte 				loop_flag = 1;
1339*fcf3ce44SJohn Forte 			} else if (dsk_ptr->l_state_flag & L_INVALID_WWN) {
1340*fcf3ce44SJohn Forte 				(void) fprintf(stdout,
1341*fcf3ce44SJohn Forte 				MSGSTR(2029,
1342*fcf3ce44SJohn Forte 					" (Invalid WWN)  "));
1343*fcf3ce44SJohn Forte 			} else if (dsk_ptr->l_state_flag & L_INVALID_MAP) {
1344*fcf3ce44SJohn Forte 				(void) fprintf(stdout,
1345*fcf3ce44SJohn Forte 				MSGSTR(2030,
1346*fcf3ce44SJohn Forte 					" (Login failed) "));
1347*fcf3ce44SJohn Forte 			} else if (dsk_ptr->l_state_flag & L_NO_PATH_FOUND) {
1348*fcf3ce44SJohn Forte 				(void) fprintf(stdout,
1349*fcf3ce44SJohn Forte 				MSGSTR(2031,
1350*fcf3ce44SJohn Forte 					" (No path found)"));
1351*fcf3ce44SJohn Forte 			} else if (a_and_b) {
1352*fcf3ce44SJohn Forte 				print_individual_state(a_and_b, PORT_A_B);
1353*fcf3ce44SJohn Forte 			} else if (state_a && (!state_b)) {
1354*fcf3ce44SJohn Forte 				print_individual_state(state_a, PORT_A);
1355*fcf3ce44SJohn Forte 			} else if ((!state_a) && state_b) {
1356*fcf3ce44SJohn Forte 				print_individual_state(state_b, PORT_B);
1357*fcf3ce44SJohn Forte 			} else if (state_a || state_b) {
1358*fcf3ce44SJohn Forte 				/* NOTE: Double state - should do 2 lines. */
1359*fcf3ce44SJohn Forte 				print_individual_state(state_a | state_b,
1360*fcf3ce44SJohn Forte 								PORT_A_B);
1361*fcf3ce44SJohn Forte 			} else {
1362*fcf3ce44SJohn Forte 				(void) fprintf(stdout, " (");
1363*fcf3ce44SJohn Forte 				(void) fprintf(stdout,
1364*fcf3ce44SJohn Forte 					MSGSTR(29, "O.K."));
1365*fcf3ce44SJohn Forte 				(void) fprintf(stdout,
1366*fcf3ce44SJohn Forte 					")         ");
1367*fcf3ce44SJohn Forte 			}
1368*fcf3ce44SJohn Forte 		}
1369*fcf3ce44SJohn Forte 		if (loop_flag) {
1370*fcf3ce44SJohn Forte 			(void) fprintf(stdout, "          ");
1371*fcf3ce44SJohn Forte 		} else if (strlen(dsk_ptr->g_disk_state.node_wwn_s)) {
1372*fcf3ce44SJohn Forte 			(void) fprintf(stdout, "%s",
1373*fcf3ce44SJohn Forte 			dsk_ptr->g_disk_state.node_wwn_s);
1374*fcf3ce44SJohn Forte 		} else {
1375*fcf3ce44SJohn Forte 			(void) fprintf(stdout, "                ");
1376*fcf3ce44SJohn Forte 		}
1377*fcf3ce44SJohn Forte 	}
1378*fcf3ce44SJohn Forte 	if (front_flag) {
1379*fcf3ce44SJohn Forte 		(void) fprintf(stdout, "    ");
1380*fcf3ce44SJohn Forte 	}
1381*fcf3ce44SJohn Forte }
1382*fcf3ce44SJohn Forte 
1383*fcf3ce44SJohn Forte 
1384*fcf3ce44SJohn Forte 
1385*fcf3ce44SJohn Forte /*
1386*fcf3ce44SJohn Forte  * pho_display_config() Displays device status
1387*fcf3ce44SJohn Forte  * information for a SENA enclosure.
1388*fcf3ce44SJohn Forte  *
1389*fcf3ce44SJohn Forte  * RETURNS:
1390*fcf3ce44SJohn Forte  *	none.
1391*fcf3ce44SJohn Forte  */
1392*fcf3ce44SJohn Forte void
1393*fcf3ce44SJohn Forte pho_display_config(char *path_phys)
1394*fcf3ce44SJohn Forte {
1395*fcf3ce44SJohn Forte L_state		l_state;
1396*fcf3ce44SJohn Forte Bp_elem_st	bpf, bpr;
1397*fcf3ce44SJohn Forte int		i, j, elem_index = 0, err = 0;
1398*fcf3ce44SJohn Forte 
1399*fcf3ce44SJohn Forte 
1400*fcf3ce44SJohn Forte 	/* Get global status */
1401*fcf3ce44SJohn Forte 	if (err = l_get_status(path_phys, &l_state,
1402*fcf3ce44SJohn Forte 			(Options & PVERBOSE))) {
1403*fcf3ce44SJohn Forte 	    (void) print_errString(err, path_phys);
1404*fcf3ce44SJohn Forte 	    exit(-1);
1405*fcf3ce44SJohn Forte 	}
1406*fcf3ce44SJohn Forte 
1407*fcf3ce44SJohn Forte 	/*
1408*fcf3ce44SJohn Forte 	 * Look for abnormal status.
1409*fcf3ce44SJohn Forte 	 */
1410*fcf3ce44SJohn Forte 	if (l_state.ib_tbl.p2_s.ui.ab_cond) {
1411*fcf3ce44SJohn Forte 		abnormal_condition_display(&l_state);
1412*fcf3ce44SJohn Forte 	}
1413*fcf3ce44SJohn Forte 
1414*fcf3ce44SJohn Forte 	(void) fprintf(stdout,
1415*fcf3ce44SJohn Forte 		MSGSTR(2032, "                                 DISK STATUS \n"
1416*fcf3ce44SJohn Forte 		"SLOT   FRONT DISKS       (Node WWN)         "
1417*fcf3ce44SJohn Forte 		" REAR DISKS        (Node WWN)\n"));
1418*fcf3ce44SJohn Forte 	/*
1419*fcf3ce44SJohn Forte 	 * Print the status for each disk
1420*fcf3ce44SJohn Forte 	 */
1421*fcf3ce44SJohn Forte 	for (j = 0; j <  (int)l_state.ib_tbl.config.enc_num_elem; j++) {
1422*fcf3ce44SJohn Forte 		elem_index++;
1423*fcf3ce44SJohn Forte 		if (l_state.ib_tbl.config.type_hdr[j].type == ELM_TYP_BP)
1424*fcf3ce44SJohn Forte 			break;
1425*fcf3ce44SJohn Forte 		elem_index += l_state.ib_tbl.config.type_hdr[j].num;
1426*fcf3ce44SJohn Forte 	}
1427*fcf3ce44SJohn Forte 	(void) bcopy((const void *)
1428*fcf3ce44SJohn Forte 		&(l_state.ib_tbl.p2_s.element[elem_index]),
1429*fcf3ce44SJohn Forte 		(void *)&bpf, sizeof (bpf));
1430*fcf3ce44SJohn Forte 	(void) bcopy((const void *)
1431*fcf3ce44SJohn Forte 		&(l_state.ib_tbl.p2_s.element[elem_index + 1]),
1432*fcf3ce44SJohn Forte 		(void *)&bpr, sizeof (bpr));
1433*fcf3ce44SJohn Forte 
1434*fcf3ce44SJohn Forte 	for (i = 0; i < (int)l_state.total_num_drv/2; i++) {
1435*fcf3ce44SJohn Forte 		(void) fprintf(stdout, "%-2d     ", i);
1436*fcf3ce44SJohn Forte 		display_disk_msg(&l_state.drv_front[i], &l_state, &bpf, 1);
1437*fcf3ce44SJohn Forte 		display_disk_msg(&l_state.drv_rear[i], &l_state, &bpr, 0);
1438*fcf3ce44SJohn Forte 		(void) fprintf(stdout, "\n");
1439*fcf3ce44SJohn Forte 	}
1440*fcf3ce44SJohn Forte 
1441*fcf3ce44SJohn Forte 
1442*fcf3ce44SJohn Forte 
1443*fcf3ce44SJohn Forte 	/*
1444*fcf3ce44SJohn Forte 	 * Display the subsystem status.
1445*fcf3ce44SJohn Forte 	 */
1446*fcf3ce44SJohn Forte 	(void) fprintf(stdout,
1447*fcf3ce44SJohn Forte 		MSGSTR(2242,
1448*fcf3ce44SJohn Forte 	"                                SUBSYSTEM STATUS\nFW Revision:"));
1449*fcf3ce44SJohn Forte 	print_chars(l_state.ib_tbl.config.prod_revision,
1450*fcf3ce44SJohn Forte 		sizeof (l_state.ib_tbl.config.prod_revision), 1);
1451*fcf3ce44SJohn Forte 	(void) fprintf(stdout, MSGSTR(2034, "   Box ID:%d"),
1452*fcf3ce44SJohn Forte 		l_state.ib_tbl.box_id);
1453*fcf3ce44SJohn Forte 	(void) fprintf(stdout, "   ");
1454*fcf3ce44SJohn Forte 	(void) fprintf(stdout, MSGSTR(90, "Node WWN:"));
1455*fcf3ce44SJohn Forte 	for (i = 0; i < 8; i++) {
1456*fcf3ce44SJohn Forte 		(void) fprintf(stdout, "%1.2x",
1457*fcf3ce44SJohn Forte 		l_state.ib_tbl.config.enc_node_wwn[i]);
1458*fcf3ce44SJohn Forte 	}
1459*fcf3ce44SJohn Forte 	/* Make sure NULL terminated  although it is supposed to be */
1460*fcf3ce44SJohn Forte 	if (strlen((const char *)l_state.ib_tbl.enclosure_name) <=
1461*fcf3ce44SJohn Forte 		sizeof (l_state.ib_tbl.enclosure_name)) {
1462*fcf3ce44SJohn Forte 		(void) fprintf(stdout, MSGSTR(2035, "   Enclosure Name:%s\n"),
1463*fcf3ce44SJohn Forte 			l_state.ib_tbl.enclosure_name);
1464*fcf3ce44SJohn Forte 	}
1465*fcf3ce44SJohn Forte 
1466*fcf3ce44SJohn Forte 	/*
1467*fcf3ce44SJohn Forte 	 *
1468*fcf3ce44SJohn Forte 	 */
1469*fcf3ce44SJohn Forte 	elem_index = 0;
1470*fcf3ce44SJohn Forte 	/* Get and print CONTROLLER messages */
1471*fcf3ce44SJohn Forte 	for (i = 0; i < (int)l_state.ib_tbl.config.enc_num_elem; i++) {
1472*fcf3ce44SJohn Forte 	    elem_index++;		/* skip global */
1473*fcf3ce44SJohn Forte 	    switch (l_state.ib_tbl.config.type_hdr[i].type) {
1474*fcf3ce44SJohn Forte 		case ELM_TYP_PS:
1475*fcf3ce44SJohn Forte 			ps_messages(&l_state, i, elem_index);
1476*fcf3ce44SJohn Forte 			break;
1477*fcf3ce44SJohn Forte 		case ELM_TYP_FT:
1478*fcf3ce44SJohn Forte 			fan_messages(&l_state, i, elem_index);
1479*fcf3ce44SJohn Forte 			break;
1480*fcf3ce44SJohn Forte 		case ELM_TYP_BP:
1481*fcf3ce44SJohn Forte 			back_plane_messages(&l_state, i, elem_index);
1482*fcf3ce44SJohn Forte 			break;
1483*fcf3ce44SJohn Forte 		case ELM_TYP_IB:
1484*fcf3ce44SJohn Forte 			ctlr_messages(&l_state, i, elem_index);
1485*fcf3ce44SJohn Forte 			break;
1486*fcf3ce44SJohn Forte 		case ELM_TYP_LN:
1487*fcf3ce44SJohn Forte 			/*
1488*fcf3ce44SJohn Forte 			 * NOTE: I just use the Photon's message
1489*fcf3ce44SJohn Forte 			 * string here and don't look at the
1490*fcf3ce44SJohn Forte 			 * language code. The string includes
1491*fcf3ce44SJohn Forte 			 * the language name.
1492*fcf3ce44SJohn Forte 			 */
1493*fcf3ce44SJohn Forte 			if (l_state.ib_tbl.config.type_hdr[i].text_len != 0) {
1494*fcf3ce44SJohn Forte 				(void) fprintf(stdout, "%s\t",
1495*fcf3ce44SJohn Forte 				l_state.ib_tbl.config.text[i]);
1496*fcf3ce44SJohn Forte 			}
1497*fcf3ce44SJohn Forte 			break;
1498*fcf3ce44SJohn Forte 		case ELM_TYP_LO:	/* Loop configuration */
1499*fcf3ce44SJohn Forte 			loop_messages(&l_state, i, elem_index);
1500*fcf3ce44SJohn Forte 			break;
1501*fcf3ce44SJohn Forte 		case ELM_TYP_MB:	/* Loop configuration */
1502*fcf3ce44SJohn Forte 			mb_messages(&l_state, i, elem_index);
1503*fcf3ce44SJohn Forte 			break;
1504*fcf3ce44SJohn Forte 
1505*fcf3ce44SJohn Forte 	    }
1506*fcf3ce44SJohn Forte 		/*
1507*fcf3ce44SJohn Forte 		 * Calculate the index to each element.
1508*fcf3ce44SJohn Forte 		 */
1509*fcf3ce44SJohn Forte 		elem_index += l_state.ib_tbl.config.type_hdr[i].num;
1510*fcf3ce44SJohn Forte 	}
1511*fcf3ce44SJohn Forte 	(void) fprintf(stdout, "\n");
1512*fcf3ce44SJohn Forte }
1513*fcf3ce44SJohn Forte 
1514*fcf3ce44SJohn Forte 
1515*fcf3ce44SJohn Forte 
1516*fcf3ce44SJohn Forte 
1517*fcf3ce44SJohn Forte /*
1518*fcf3ce44SJohn Forte  * dpm_display_config() Displays device status
1519*fcf3ce44SJohn Forte  * information for a DAKTARI enclosure.
1520*fcf3ce44SJohn Forte  *
1521*fcf3ce44SJohn Forte  * RETURNS:
1522*fcf3ce44SJohn Forte  *	none.
1523*fcf3ce44SJohn Forte  */
1524*fcf3ce44SJohn Forte void
1525*fcf3ce44SJohn Forte dpm_display_config(char *path_phys)
1526*fcf3ce44SJohn Forte {
1527*fcf3ce44SJohn Forte L_state		l_state;
1528*fcf3ce44SJohn Forte Bp_elem_st	bpf, bpr;
1529*fcf3ce44SJohn Forte int		i, j, elem_index = 0, err = 0, count;
1530*fcf3ce44SJohn Forte 
1531*fcf3ce44SJohn Forte 
1532*fcf3ce44SJohn Forte 	/* Get global status */
1533*fcf3ce44SJohn Forte 	if (err = l_get_status(path_phys, &l_state,
1534*fcf3ce44SJohn Forte 			(Options & PVERBOSE))) {
1535*fcf3ce44SJohn Forte 	    (void) print_errString(err, path_phys);
1536*fcf3ce44SJohn Forte 	    exit(-1);
1537*fcf3ce44SJohn Forte 	}
1538*fcf3ce44SJohn Forte 
1539*fcf3ce44SJohn Forte 	/*
1540*fcf3ce44SJohn Forte 	 * Look for abnormal status.
1541*fcf3ce44SJohn Forte 	 */
1542*fcf3ce44SJohn Forte 	if (l_state.ib_tbl.p2_s.ui.ab_cond) {
1543*fcf3ce44SJohn Forte 		abnormal_condition_display(&l_state);
1544*fcf3ce44SJohn Forte 	}
1545*fcf3ce44SJohn Forte 
1546*fcf3ce44SJohn Forte 	(void) fprintf(stdout,
1547*fcf3ce44SJohn Forte 		MSGSTR(2247, "                 DISK STATUS \n"
1548*fcf3ce44SJohn Forte 		"SLOT   DISKS             (Node WWN)         \n"));
1549*fcf3ce44SJohn Forte 	/*
1550*fcf3ce44SJohn Forte 	 * Print the status for each disk
1551*fcf3ce44SJohn Forte 	 */
1552*fcf3ce44SJohn Forte 	for (j = 0; j <  (int)l_state.ib_tbl.config.enc_num_elem; j++) {
1553*fcf3ce44SJohn Forte 		elem_index++;
1554*fcf3ce44SJohn Forte 		if (l_state.ib_tbl.config.type_hdr[j].type == ELM_TYP_BP)
1555*fcf3ce44SJohn Forte 			break;
1556*fcf3ce44SJohn Forte 		elem_index += l_state.ib_tbl.config.type_hdr[j].num;
1557*fcf3ce44SJohn Forte 	}
1558*fcf3ce44SJohn Forte 	(void) bcopy((const void *)
1559*fcf3ce44SJohn Forte 		&(l_state.ib_tbl.p2_s.element[elem_index]),
1560*fcf3ce44SJohn Forte 		(void *)&bpf, sizeof (bpf));
1561*fcf3ce44SJohn Forte 	(void) bcopy((const void *)
1562*fcf3ce44SJohn Forte 		&(l_state.ib_tbl.p2_s.element[elem_index + 1]),
1563*fcf3ce44SJohn Forte 		(void *)&bpr, sizeof (bpr));
1564*fcf3ce44SJohn Forte 
1565*fcf3ce44SJohn Forte 	for (i = 0, count = 0;
1566*fcf3ce44SJohn Forte 			i < (int)l_state.total_num_drv/2;
1567*fcf3ce44SJohn Forte 			i++, count++) {
1568*fcf3ce44SJohn Forte 		(void) fprintf(stdout, "%-2d     ", count);
1569*fcf3ce44SJohn Forte 		display_disk_msg(&l_state.drv_front[i], &l_state, &bpf, 1);
1570*fcf3ce44SJohn Forte 		(void) fprintf(stdout, "\n");
1571*fcf3ce44SJohn Forte 	}
1572*fcf3ce44SJohn Forte 	for (i = 0; i < (int)l_state.total_num_drv/2; i++, count++) {
1573*fcf3ce44SJohn Forte 		(void) fprintf(stdout, "%-2d     ", count);
1574*fcf3ce44SJohn Forte 		display_disk_msg(&l_state.drv_rear[i], &l_state, &bpf, 1);
1575*fcf3ce44SJohn Forte 		(void) fprintf(stdout, "\n");
1576*fcf3ce44SJohn Forte 	}
1577*fcf3ce44SJohn Forte 
1578*fcf3ce44SJohn Forte 
1579*fcf3ce44SJohn Forte 	/*
1580*fcf3ce44SJohn Forte 	 * Display the subsystem status.
1581*fcf3ce44SJohn Forte 	 */
1582*fcf3ce44SJohn Forte 	(void) fprintf(stdout,
1583*fcf3ce44SJohn Forte 		MSGSTR(2033,
1584*fcf3ce44SJohn Forte 	"\t\tSUBSYSTEM STATUS\nFW Revision:"));
1585*fcf3ce44SJohn Forte 	for (i = 0; i < sizeof (l_state.ib_tbl.config.prod_revision); i++) {
1586*fcf3ce44SJohn Forte 		(void) fprintf(stdout, "%c",
1587*fcf3ce44SJohn Forte 			l_state.ib_tbl.config.prod_revision[i]);
1588*fcf3ce44SJohn Forte 	}
1589*fcf3ce44SJohn Forte 	(void) fprintf(stdout, MSGSTR(2034, "   Box ID:%d"),
1590*fcf3ce44SJohn Forte 		l_state.ib_tbl.box_id);
1591*fcf3ce44SJohn Forte 	(void) fprintf(stdout, "\n  ");
1592*fcf3ce44SJohn Forte 
1593*fcf3ce44SJohn Forte 	(void) fprintf(stdout, MSGSTR(90, "Node WWN:"));
1594*fcf3ce44SJohn Forte 
1595*fcf3ce44SJohn Forte 	for (i = 0; i < 8; i++) {
1596*fcf3ce44SJohn Forte 		(void) fprintf(stdout, "%1.2x",
1597*fcf3ce44SJohn Forte 		l_state.ib_tbl.config.enc_node_wwn[i]);
1598*fcf3ce44SJohn Forte 	}
1599*fcf3ce44SJohn Forte 	/* Make sure NULL terminated  although it is supposed to be */
1600*fcf3ce44SJohn Forte 	if (strlen((const char *)l_state.ib_tbl.enclosure_name) <=
1601*fcf3ce44SJohn Forte 		sizeof (l_state.ib_tbl.enclosure_name)) {
1602*fcf3ce44SJohn Forte 		(void) fprintf(stdout, MSGSTR(2035, "   Enclosure Name:%s\n"),
1603*fcf3ce44SJohn Forte 			l_state.ib_tbl.enclosure_name);
1604*fcf3ce44SJohn Forte 	}
1605*fcf3ce44SJohn Forte 
1606*fcf3ce44SJohn Forte 	/*
1607*fcf3ce44SJohn Forte 	 *
1608*fcf3ce44SJohn Forte 	 */
1609*fcf3ce44SJohn Forte 	elem_index = 0;
1610*fcf3ce44SJohn Forte 	/* Get and print CONTROLLER messages */
1611*fcf3ce44SJohn Forte 	for (i = 0; i < (int)l_state.ib_tbl.config.enc_num_elem; i++) {
1612*fcf3ce44SJohn Forte 	    elem_index++;		/* skip global */
1613*fcf3ce44SJohn Forte 	    switch (l_state.ib_tbl.config.type_hdr[i].type) {
1614*fcf3ce44SJohn Forte 		case ELM_TYP_PS:
1615*fcf3ce44SJohn Forte 			ps_messages(&l_state, i, elem_index);
1616*fcf3ce44SJohn Forte 			break;
1617*fcf3ce44SJohn Forte 		case ELM_TYP_FT:
1618*fcf3ce44SJohn Forte 			fan_messages(&l_state, i, elem_index);
1619*fcf3ce44SJohn Forte 			break;
1620*fcf3ce44SJohn Forte 		case ELM_TYP_BP:
1621*fcf3ce44SJohn Forte 			dpm_SSC100_messages(&l_state, i, elem_index);
1622*fcf3ce44SJohn Forte 			break;
1623*fcf3ce44SJohn Forte 		case ELM_TYP_IB:
1624*fcf3ce44SJohn Forte 			ctlr_messages(&l_state, i, elem_index);
1625*fcf3ce44SJohn Forte 			break;
1626*fcf3ce44SJohn Forte 		case ELM_TYP_LN:
1627*fcf3ce44SJohn Forte 			/*
1628*fcf3ce44SJohn Forte 			 * NOTE: I just use the Photon's message
1629*fcf3ce44SJohn Forte 			 * string here and don't look at the
1630*fcf3ce44SJohn Forte 			 * language code. The string includes
1631*fcf3ce44SJohn Forte 			 * the language name.
1632*fcf3ce44SJohn Forte 			 */
1633*fcf3ce44SJohn Forte 			if (l_state.ib_tbl.config.type_hdr[i].text_len != 0) {
1634*fcf3ce44SJohn Forte 				(void) fprintf(stdout, "%s\t",
1635*fcf3ce44SJohn Forte 				l_state.ib_tbl.config.text[i]);
1636*fcf3ce44SJohn Forte 			}
1637*fcf3ce44SJohn Forte 			break;
1638*fcf3ce44SJohn Forte 		case ELM_TYP_LO:	/* Loop configuration */
1639*fcf3ce44SJohn Forte 			loop_messages(&l_state, i, elem_index);
1640*fcf3ce44SJohn Forte 			break;
1641*fcf3ce44SJohn Forte 		case ELM_TYP_MB:	/* Loop configuration */
1642*fcf3ce44SJohn Forte 			mb_messages(&l_state, i, elem_index);
1643*fcf3ce44SJohn Forte 			break;
1644*fcf3ce44SJohn Forte 		case ELM_TYP_FL:
1645*fcf3ce44SJohn Forte 			trans_messages(&l_state, 1);
1646*fcf3ce44SJohn Forte 			break;
1647*fcf3ce44SJohn Forte 
1648*fcf3ce44SJohn Forte 	    }
1649*fcf3ce44SJohn Forte 		/*
1650*fcf3ce44SJohn Forte 		 * Calculate the index to each element.
1651*fcf3ce44SJohn Forte 		 */
1652*fcf3ce44SJohn Forte 		elem_index += l_state.ib_tbl.config.type_hdr[i].num;
1653*fcf3ce44SJohn Forte 	}
1654*fcf3ce44SJohn Forte 	(void) fprintf(stdout, "\n");
1655*fcf3ce44SJohn Forte }
1656*fcf3ce44SJohn Forte 
1657*fcf3ce44SJohn Forte 
1658*fcf3ce44SJohn Forte 
1659*fcf3ce44SJohn Forte 
1660*fcf3ce44SJohn Forte 
1661*fcf3ce44SJohn Forte 
1662*fcf3ce44SJohn Forte /*
1663*fcf3ce44SJohn Forte  * Change the FPM (Front Panel Module) password of the
1664*fcf3ce44SJohn Forte  * subsystem associated with the IB addressed by the
1665*fcf3ce44SJohn Forte  * enclosure or pathname to name.
1666*fcf3ce44SJohn Forte  *
1667*fcf3ce44SJohn Forte  */
1668*fcf3ce44SJohn Forte void
1669*fcf3ce44SJohn Forte intfix(void)
1670*fcf3ce44SJohn Forte {
1671*fcf3ce44SJohn Forte 	if (termio_fd) {
1672*fcf3ce44SJohn Forte 		termios.c_lflag |= ECHO;
1673*fcf3ce44SJohn Forte 		ioctl(termio_fd, TCSETS, &termios);
1674*fcf3ce44SJohn Forte 	}
1675*fcf3ce44SJohn Forte 	exit(SIGINT);
1676*fcf3ce44SJohn Forte }
1677*fcf3ce44SJohn Forte 
1678*fcf3ce44SJohn Forte 
1679*fcf3ce44SJohn Forte /*
1680*fcf3ce44SJohn Forte  * up_password() Changes the password for SENA enclosure.
1681*fcf3ce44SJohn Forte  *
1682*fcf3ce44SJohn Forte  * RETURNS:
1683*fcf3ce44SJohn Forte  *	none.
1684*fcf3ce44SJohn Forte  */
1685*fcf3ce44SJohn Forte void
1686*fcf3ce44SJohn Forte up_password(char **argv)
1687*fcf3ce44SJohn Forte {
1688*fcf3ce44SJohn Forte int		path_index = 0, err = 0;
1689*fcf3ce44SJohn Forte char		password[1024];
1690*fcf3ce44SJohn Forte char		input[1024];
1691*fcf3ce44SJohn Forte int		i, j, matched, equal;
1692*fcf3ce44SJohn Forte L_inquiry	inq;
1693*fcf3ce44SJohn Forte void		(*sig)();
1694*fcf3ce44SJohn Forte char		*path_phys = NULL;
1695*fcf3ce44SJohn Forte Path_struct	*path_struct;
1696*fcf3ce44SJohn Forte 
1697*fcf3ce44SJohn Forte 
1698*fcf3ce44SJohn Forte 	if ((termio_fd = open("/dev/tty", O_RDONLY)) == -1) {
1699*fcf3ce44SJohn Forte 		(void) fprintf(stderr,
1700*fcf3ce44SJohn Forte 		MSGSTR(2036, "Error: tty open failed.\n"));
1701*fcf3ce44SJohn Forte 		exit(-1);
1702*fcf3ce44SJohn Forte 	}
1703*fcf3ce44SJohn Forte 	ioctl(termio_fd, TCGETS, &termios);
1704*fcf3ce44SJohn Forte 	sig = sigset(SIGINT, (void (*)())intfix);
1705*fcf3ce44SJohn Forte 	/*
1706*fcf3ce44SJohn Forte 	 * Make sure path valid and is to a PHO
1707*fcf3ce44SJohn Forte 	 * before bothering operator.
1708*fcf3ce44SJohn Forte 	 */
1709*fcf3ce44SJohn Forte 	if ((err = l_convert_name(argv[path_index], &path_phys,
1710*fcf3ce44SJohn Forte 		&path_struct, Options & PVERBOSE)) != 0) {
1711*fcf3ce44SJohn Forte 		(void) fprintf(stderr,
1712*fcf3ce44SJohn Forte 			MSGSTR(33,
1713*fcf3ce44SJohn Forte 				" Error: converting"
1714*fcf3ce44SJohn Forte 				" %s to physical path.\n"
1715*fcf3ce44SJohn Forte 				" Invalid pathname.\n"),
1716*fcf3ce44SJohn Forte 				argv[path_index]);
1717*fcf3ce44SJohn Forte 		if (err != -1) {
1718*fcf3ce44SJohn Forte 			(void) print_errString(err, argv[path_index]);
1719*fcf3ce44SJohn Forte 		}
1720*fcf3ce44SJohn Forte 		exit(-1);
1721*fcf3ce44SJohn Forte 	}
1722*fcf3ce44SJohn Forte 	if (err = g_get_inquiry(path_phys, &inq)) {
1723*fcf3ce44SJohn Forte 		(void) print_errString(err, argv[path_index]);
1724*fcf3ce44SJohn Forte 		exit(-1);
1725*fcf3ce44SJohn Forte 	}
1726*fcf3ce44SJohn Forte 	if ((strstr((char *)inq.inq_pid, ENCLOSURE_PROD_ID) == 0) &&
1727*fcf3ce44SJohn Forte 			(!(strncmp((char *)inq.inq_vid, "SUN     ",
1728*fcf3ce44SJohn Forte 			sizeof (inq.inq_vid)) &&
1729*fcf3ce44SJohn Forte 			((inq.inq_dtype & DTYPE_MASK) == DTYPE_ESI)))) {
1730*fcf3ce44SJohn Forte 		/*
1731*fcf3ce44SJohn Forte 		 * Again this is like the ssaadm code in that the name
1732*fcf3ce44SJohn Forte 		 * is still not defined before this code must be released.
1733*fcf3ce44SJohn Forte 		 */
1734*fcf3ce44SJohn Forte 		(void) fprintf(stderr,
1735*fcf3ce44SJohn Forte 		MSGSTR(2037, "Error: Enclosure is not a %s\n"),
1736*fcf3ce44SJohn Forte 			ENCLOSURE_PROD_ID);
1737*fcf3ce44SJohn Forte 		exit(-1);
1738*fcf3ce44SJohn Forte 	}
1739*fcf3ce44SJohn Forte 	(void) fprintf(stdout,
1740*fcf3ce44SJohn Forte 			MSGSTR(2038,
1741*fcf3ce44SJohn Forte 			"Changing FPM password for subsystem %s\n"),
1742*fcf3ce44SJohn Forte 			argv[path_index]);
1743*fcf3ce44SJohn Forte 
1744*fcf3ce44SJohn Forte 	equal = 0;
1745*fcf3ce44SJohn Forte 	while (!equal) {
1746*fcf3ce44SJohn Forte 		memset(input, 0, sizeof (input));
1747*fcf3ce44SJohn Forte 		memset(password, 0, sizeof (password));
1748*fcf3ce44SJohn Forte 		(void) fprintf(stdout,
1749*fcf3ce44SJohn Forte 		MSGSTR(2039, "New password: "));
1750*fcf3ce44SJohn Forte 
1751*fcf3ce44SJohn Forte 		termios.c_lflag &= ~ECHO;
1752*fcf3ce44SJohn Forte 		ioctl(termio_fd, TCSETS, &termios);
1753*fcf3ce44SJohn Forte 
1754*fcf3ce44SJohn Forte 		(void) gets(input);
1755*fcf3ce44SJohn Forte 		(void) fprintf(stdout,
1756*fcf3ce44SJohn Forte 		MSGSTR(2040, "\nRe-enter new password: "));
1757*fcf3ce44SJohn Forte 		(void) gets(password);
1758*fcf3ce44SJohn Forte 		termios.c_lflag |= ECHO;
1759*fcf3ce44SJohn Forte 		ioctl(termio_fd, TCSETS, &termios);
1760*fcf3ce44SJohn Forte 		for (i = 0; input[i]; i++) {
1761*fcf3ce44SJohn Forte 			if (!isdigit(input[i])) {
1762*fcf3ce44SJohn Forte 				(void) fprintf(stderr,
1763*fcf3ce44SJohn Forte 			MSGSTR(2041, "\nError: Invalid password."
1764*fcf3ce44SJohn Forte 			" The password"
1765*fcf3ce44SJohn Forte 			" must be 4 decimal-digit characters.\n"));
1766*fcf3ce44SJohn Forte 				exit(-1);
1767*fcf3ce44SJohn Forte 			}
1768*fcf3ce44SJohn Forte 		}
1769*fcf3ce44SJohn Forte 		if (i && (i != 4)) {
1770*fcf3ce44SJohn Forte 			(void) fprintf(stderr,
1771*fcf3ce44SJohn Forte 			MSGSTR(2042, "\nError: Invalid password."
1772*fcf3ce44SJohn Forte 			" The password"
1773*fcf3ce44SJohn Forte 			" must be 4 decimal-digit characters.\n"));
1774*fcf3ce44SJohn Forte 			exit(-1);
1775*fcf3ce44SJohn Forte 		}
1776*fcf3ce44SJohn Forte 		for (j = 0; password[j]; j++) {
1777*fcf3ce44SJohn Forte 			if (!isdigit(password[j])) {
1778*fcf3ce44SJohn Forte 				(void) fprintf(stderr,
1779*fcf3ce44SJohn Forte 			MSGSTR(2043, "\nError: Invalid password."
1780*fcf3ce44SJohn Forte 			" The password"
1781*fcf3ce44SJohn Forte 			" must be 4 decimal-digit characters.\n"));
1782*fcf3ce44SJohn Forte 				exit(-1);
1783*fcf3ce44SJohn Forte 			}
1784*fcf3ce44SJohn Forte 		}
1785*fcf3ce44SJohn Forte 		if (i != j) {
1786*fcf3ce44SJohn Forte 			matched = -1;
1787*fcf3ce44SJohn Forte 		} else for (i = matched = 0; password[i]; i++) {
1788*fcf3ce44SJohn Forte 			if (password[i] == input[i]) {
1789*fcf3ce44SJohn Forte 				matched++;
1790*fcf3ce44SJohn Forte 			}
1791*fcf3ce44SJohn Forte 		}
1792*fcf3ce44SJohn Forte 		if ((matched != -1) && (matched == i)) {
1793*fcf3ce44SJohn Forte 			equal = 1;
1794*fcf3ce44SJohn Forte 		} else {
1795*fcf3ce44SJohn Forte 			(void) fprintf(stdout,
1796*fcf3ce44SJohn Forte 			MSGSTR(2044, "\npassword: They don't match;"
1797*fcf3ce44SJohn Forte 			" try again.\n"));
1798*fcf3ce44SJohn Forte 		}
1799*fcf3ce44SJohn Forte 	}
1800*fcf3ce44SJohn Forte 	(void) fprintf(stdout, "\n");
1801*fcf3ce44SJohn Forte 	sscanf(input, "%s", password);
1802*fcf3ce44SJohn Forte 	(void) signal(SIGINT, sig);	/* restore signal handler */
1803*fcf3ce44SJohn Forte 
1804*fcf3ce44SJohn Forte 	/*  Send new password to IB */
1805*fcf3ce44SJohn Forte 	if (l_new_password(path_phys, input)) {
1806*fcf3ce44SJohn Forte 		(void) print_errString(err, path_phys);
1807*fcf3ce44SJohn Forte 		exit(-1);
1808*fcf3ce44SJohn Forte 	}
1809*fcf3ce44SJohn Forte }
1810*fcf3ce44SJohn Forte 
1811*fcf3ce44SJohn Forte /*
1812*fcf3ce44SJohn Forte  * Call g_failover to process failover command
1813*fcf3ce44SJohn Forte  */
1814*fcf3ce44SJohn Forte void
1815*fcf3ce44SJohn Forte adm_failover(char **argv)
1816*fcf3ce44SJohn Forte {
1817*fcf3ce44SJohn Forte int		path_index = 0, err = 0;
1818*fcf3ce44SJohn Forte char		pathclass[20];
1819*fcf3ce44SJohn Forte char		*path_phys = NULL;
1820*fcf3ce44SJohn Forte 
1821*fcf3ce44SJohn Forte 	(void) memset(pathclass, 0, sizeof (pathclass));
1822*fcf3ce44SJohn Forte 	(void) strcpy(pathclass, argv[path_index++]);
1823*fcf3ce44SJohn Forte 	if ((strcmp(pathclass, "primary") != 0) &&
1824*fcf3ce44SJohn Forte 		(strcmp(pathclass, "secondary") != 0)) {
1825*fcf3ce44SJohn Forte 			(void) fprintf(stderr,
1826*fcf3ce44SJohn Forte 			MSGSTR(2300, "Incorrect pathclass\n"));
1827*fcf3ce44SJohn Forte 			exit(-1);
1828*fcf3ce44SJohn Forte 	}
1829*fcf3ce44SJohn Forte 
1830*fcf3ce44SJohn Forte 	while (argv[path_index] != NULL) {
1831*fcf3ce44SJohn Forte 		path_phys = g_get_physical_name(argv[path_index++]);
1832*fcf3ce44SJohn Forte 		if ((path_phys == NULL) ||
1833*fcf3ce44SJohn Forte 			(strstr(path_phys, SCSI_VHCI) == NULL)) {
1834*fcf3ce44SJohn Forte 				(void) fprintf(stderr,
1835*fcf3ce44SJohn Forte 				MSGSTR(2301, "Incorrect pathname\n"));
1836*fcf3ce44SJohn Forte 				exit(-1);
1837*fcf3ce44SJohn Forte 		}
1838*fcf3ce44SJohn Forte 
1839*fcf3ce44SJohn Forte 		if (err = g_failover(path_phys, pathclass)) {
1840*fcf3ce44SJohn Forte 			(void) print_errString(err, NULL);
1841*fcf3ce44SJohn Forte 			exit(-1);
1842*fcf3ce44SJohn Forte 		}
1843*fcf3ce44SJohn Forte 	}
1844*fcf3ce44SJohn Forte }
1845*fcf3ce44SJohn Forte 
1846*fcf3ce44SJohn Forte 
1847*fcf3ce44SJohn Forte 
1848*fcf3ce44SJohn Forte /*
1849*fcf3ce44SJohn Forte  * up_encl_name() Update the enclosures logical name.
1850*fcf3ce44SJohn Forte  *
1851*fcf3ce44SJohn Forte  * RETURNS:
1852*fcf3ce44SJohn Forte  *	none.
1853*fcf3ce44SJohn Forte  */
1854*fcf3ce44SJohn Forte void
1855*fcf3ce44SJohn Forte up_encl_name(char **argv, int argc)
1856*fcf3ce44SJohn Forte {
1857*fcf3ce44SJohn Forte int		i, rval, al_pa, path_index = 0, err = 0;
1858*fcf3ce44SJohn Forte L_inquiry	inq;
1859*fcf3ce44SJohn Forte Box_list	*b_list = NULL;
1860*fcf3ce44SJohn Forte uchar_t		node_wwn[WWN_SIZE], port_wwn[WWN_SIZE];
1861*fcf3ce44SJohn Forte char		wwn1[(WWN_SIZE*2)+1], name[1024], *path_phys = NULL;
1862*fcf3ce44SJohn Forte Path_struct	*path_struct;
1863*fcf3ce44SJohn Forte 
1864*fcf3ce44SJohn Forte 	(void) memset(name, 0, sizeof (name));
1865*fcf3ce44SJohn Forte 	(void) memset(&inq, 0, sizeof (inq));
1866*fcf3ce44SJohn Forte 	(void) sscanf(argv[path_index++], "%s", name);
1867*fcf3ce44SJohn Forte 	for (i = 0; name[i]; i++) {
1868*fcf3ce44SJohn Forte 		if ((!isalnum(name[i]) &&
1869*fcf3ce44SJohn Forte 			((name[i] != '#') &&
1870*fcf3ce44SJohn Forte 			(name[i] != '-') &&
1871*fcf3ce44SJohn Forte 			(name[i] != '_') &&
1872*fcf3ce44SJohn Forte 			(name[i] != '.'))) || i >= 16) {
1873*fcf3ce44SJohn Forte 			(void) fprintf(stderr,
1874*fcf3ce44SJohn Forte 			MSGSTR(2045, "Error: Invalid enclosure name.\n"));
1875*fcf3ce44SJohn Forte 			(void) fprintf(stderr, MSGSTR(2046,
1876*fcf3ce44SJohn Forte 			"Usage: %s [-v] subcommand {a name consisting of"
1877*fcf3ce44SJohn Forte 			" 1-16 alphanumeric characters}"
1878*fcf3ce44SJohn Forte 			" {enclosure... | pathname...}\n"), whoami);
1879*fcf3ce44SJohn Forte 			exit(-1);
1880*fcf3ce44SJohn Forte 		}
1881*fcf3ce44SJohn Forte 	}
1882*fcf3ce44SJohn Forte 
1883*fcf3ce44SJohn Forte 	if (((Options & PVERBOSE) && (argc != 5)) ||
1884*fcf3ce44SJohn Forte 		(!(Options & PVERBOSE) && (argc != 4))) {
1885*fcf3ce44SJohn Forte 		(void) fprintf(stderr,
1886*fcf3ce44SJohn Forte 		MSGSTR(114, "Error: Incorrect number of arguments.\n"));
1887*fcf3ce44SJohn Forte 		(void) fprintf(stderr,  MSGSTR(2047,
1888*fcf3ce44SJohn Forte 		"Usage: %s [-v] subcommand {a name consisting of"
1889*fcf3ce44SJohn Forte 		" 1-16 alphanumeric characters}"
1890*fcf3ce44SJohn Forte 		" {enclosure... | pathname...}\n"), whoami);
1891*fcf3ce44SJohn Forte 		exit(-1);
1892*fcf3ce44SJohn Forte 	}
1893*fcf3ce44SJohn Forte 
1894*fcf3ce44SJohn Forte 	if ((err = l_convert_name(argv[path_index], &path_phys,
1895*fcf3ce44SJohn Forte 		&path_struct, Options & PVERBOSE)) != 0) {
1896*fcf3ce44SJohn Forte 		(void) fprintf(stderr,
1897*fcf3ce44SJohn Forte 				MSGSTR(33,
1898*fcf3ce44SJohn Forte 				" Error: converting"
1899*fcf3ce44SJohn Forte 				" %s to physical path.\n"
1900*fcf3ce44SJohn Forte 				" Invalid pathname.\n"),
1901*fcf3ce44SJohn Forte 				argv[path_index]);
1902*fcf3ce44SJohn Forte 		if (err != -1) {
1903*fcf3ce44SJohn Forte 			(void) print_errString(err, argv[path_index]);
1904*fcf3ce44SJohn Forte 		}
1905*fcf3ce44SJohn Forte 		exit(-1);
1906*fcf3ce44SJohn Forte 	}
1907*fcf3ce44SJohn Forte 	/*
1908*fcf3ce44SJohn Forte 	 * Make sure we are talking to an IB.
1909*fcf3ce44SJohn Forte 	 */
1910*fcf3ce44SJohn Forte 	if (err = g_get_inquiry(path_phys, &inq)) {
1911*fcf3ce44SJohn Forte 		(void) print_errString(err, argv[path_index]);
1912*fcf3ce44SJohn Forte 		exit(-1);
1913*fcf3ce44SJohn Forte 	}
1914*fcf3ce44SJohn Forte 	if ((strstr((char *)inq.inq_pid, ENCLOSURE_PROD_ID) == 0) &&
1915*fcf3ce44SJohn Forte 			(!(strncmp((char *)inq.inq_vid, "SUN     ",
1916*fcf3ce44SJohn Forte 			sizeof (inq.inq_vid)) &&
1917*fcf3ce44SJohn Forte 			((inq.inq_dtype & DTYPE_MASK) == DTYPE_ESI)))) {
1918*fcf3ce44SJohn Forte 		/*
1919*fcf3ce44SJohn Forte 		 * Again this is like the ssaadm code in that the name
1920*fcf3ce44SJohn Forte 		 * is still not defined before this code must be released.
1921*fcf3ce44SJohn Forte 		 */
1922*fcf3ce44SJohn Forte 		(void) fprintf(stderr,
1923*fcf3ce44SJohn Forte 		MSGSTR(2048, "Error: Pathname does not point to a %s"
1924*fcf3ce44SJohn Forte 		" enclosure\n"), ENCLOSURE_PROD_NAME);
1925*fcf3ce44SJohn Forte 		exit(-1);
1926*fcf3ce44SJohn Forte 	}
1927*fcf3ce44SJohn Forte 
1928*fcf3ce44SJohn Forte 	if (err = g_get_wwn(path_phys, port_wwn, node_wwn, &al_pa,
1929*fcf3ce44SJohn Forte 		Options & PVERBOSE)) {
1930*fcf3ce44SJohn Forte 		(void) print_errString(err, argv[path_index]);
1931*fcf3ce44SJohn Forte 		exit(-1);
1932*fcf3ce44SJohn Forte 	}
1933*fcf3ce44SJohn Forte 
1934*fcf3ce44SJohn Forte 	for (i = 0; i < WWN_SIZE; i++) {
1935*fcf3ce44SJohn Forte 		(void) sprintf(&wwn1[i << 1], "%02x", node_wwn[i]);
1936*fcf3ce44SJohn Forte 	}
1937*fcf3ce44SJohn Forte 	if ((err = l_get_box_list(&b_list, Options & PVERBOSE)) != 0) {
1938*fcf3ce44SJohn Forte 		(void) print_errString(err, argv[path_index]);
1939*fcf3ce44SJohn Forte 		exit(-1);
1940*fcf3ce44SJohn Forte 	}
1941*fcf3ce44SJohn Forte 	if (b_list == NULL) {
1942*fcf3ce44SJohn Forte 		(void) fprintf(stdout,
1943*fcf3ce44SJohn Forte 			MSGSTR(93, "No %s enclosures found "
1944*fcf3ce44SJohn Forte 			"in /dev/es\n"), ENCLOSURE_PROD_NAME);
1945*fcf3ce44SJohn Forte 		exit(-1);
1946*fcf3ce44SJohn Forte 	} else if (l_duplicate_names(b_list, wwn1, name,
1947*fcf3ce44SJohn Forte 		Options & PVERBOSE)) {
1948*fcf3ce44SJohn Forte 		(void) fprintf(stderr,
1949*fcf3ce44SJohn Forte 		MSGSTR(2049, "Warning: The name you selected, %s,"
1950*fcf3ce44SJohn Forte 		" is already being used.\n"
1951*fcf3ce44SJohn Forte 		"Please choose a unique name.\n"
1952*fcf3ce44SJohn Forte 		"You can use the \"probe\" subcommand to"
1953*fcf3ce44SJohn Forte 		" see all of the enclosure names.\n"),
1954*fcf3ce44SJohn Forte 		name);
1955*fcf3ce44SJohn Forte 		(void) l_free_box_list(&b_list);
1956*fcf3ce44SJohn Forte 		exit(-1);
1957*fcf3ce44SJohn Forte 	}
1958*fcf3ce44SJohn Forte 	(void) l_free_box_list(&b_list);
1959*fcf3ce44SJohn Forte 
1960*fcf3ce44SJohn Forte 	/*  Send new name to IB */
1961*fcf3ce44SJohn Forte 	if (rval = l_new_name(path_phys, name)) {
1962*fcf3ce44SJohn Forte 		(void) print_errString(rval, path_phys);
1963*fcf3ce44SJohn Forte 		exit(-1);
1964*fcf3ce44SJohn Forte 	}
1965*fcf3ce44SJohn Forte 	if (Options & PVERBOSE) {
1966*fcf3ce44SJohn Forte 		(void) fprintf(stdout,
1967*fcf3ce44SJohn Forte 			MSGSTR(2050, "The enclosure has been renamed to %s\n"),
1968*fcf3ce44SJohn Forte 			name);
1969*fcf3ce44SJohn Forte 	}
1970*fcf3ce44SJohn Forte }
1971*fcf3ce44SJohn Forte 
1972*fcf3ce44SJohn Forte 
1973*fcf3ce44SJohn Forte static int
1974*fcf3ce44SJohn Forte get_enclStatus(char *phys_path, char *encl_name, int off_flag)
1975*fcf3ce44SJohn Forte {
1976*fcf3ce44SJohn Forte int	found_pwrOnDrv = 0, slot;
1977*fcf3ce44SJohn Forte int	found_pwrOffDrv = 0, err = 0;
1978*fcf3ce44SJohn Forte L_state	l_state;
1979*fcf3ce44SJohn Forte 
1980*fcf3ce44SJohn Forte 	if ((err = l_get_status(phys_path,
1981*fcf3ce44SJohn Forte 				&l_state, Options & PVERBOSE)) != 0) {
1982*fcf3ce44SJohn Forte 		(void) print_errString(err, encl_name);
1983*fcf3ce44SJohn Forte 		return (err);
1984*fcf3ce44SJohn Forte 	}
1985*fcf3ce44SJohn Forte 
1986*fcf3ce44SJohn Forte 	if (off_flag) {
1987*fcf3ce44SJohn Forte 		for (slot = 0; slot < l_state.total_num_drv/2;
1988*fcf3ce44SJohn Forte 							slot++) {
1989*fcf3ce44SJohn Forte 			if (((l_state.drv_front[slot].ib_status.code !=
1990*fcf3ce44SJohn Forte 							S_NOT_INSTALLED) &&
1991*fcf3ce44SJohn Forte 			(!l_state.drv_front[slot].ib_status.dev_off)) ||
1992*fcf3ce44SJohn Forte 			((l_state.drv_rear[slot].ib_status.code !=
1993*fcf3ce44SJohn Forte 							S_NOT_INSTALLED) &&
1994*fcf3ce44SJohn Forte 			(!l_state.drv_rear[slot].ib_status.dev_off))) {
1995*fcf3ce44SJohn Forte 				found_pwrOnDrv++;
1996*fcf3ce44SJohn Forte 				break;
1997*fcf3ce44SJohn Forte 			}
1998*fcf3ce44SJohn Forte 		}
1999*fcf3ce44SJohn Forte 		if (!found_pwrOnDrv) {
2000*fcf3ce44SJohn Forte 			(void) fprintf(stdout,
2001*fcf3ce44SJohn Forte 				MSGSTR(2051,
2002*fcf3ce44SJohn Forte 				"Notice: Drives in enclosure"
2003*fcf3ce44SJohn Forte 				" \"%s\" have already been"
2004*fcf3ce44SJohn Forte 				" powered off.\n\n"),
2005*fcf3ce44SJohn Forte 				encl_name);
2006*fcf3ce44SJohn Forte 			return (-1);
2007*fcf3ce44SJohn Forte 		}
2008*fcf3ce44SJohn Forte 	} else {
2009*fcf3ce44SJohn Forte 		for (slot  = 0; slot < l_state.total_num_drv/2;
2010*fcf3ce44SJohn Forte 							slot++) {
2011*fcf3ce44SJohn Forte 			if (((l_state.drv_front[slot].ib_status.code !=
2012*fcf3ce44SJohn Forte 							S_NOT_INSTALLED) &&
2013*fcf3ce44SJohn Forte 			(l_state.drv_front[slot].ib_status.dev_off)) ||
2014*fcf3ce44SJohn Forte 			((l_state.drv_rear[slot].ib_status.code !=
2015*fcf3ce44SJohn Forte 							S_NOT_INSTALLED) &&
2016*fcf3ce44SJohn Forte 			(l_state.drv_rear[slot].ib_status.dev_off))) {
2017*fcf3ce44SJohn Forte 				found_pwrOffDrv++;
2018*fcf3ce44SJohn Forte 				break;
2019*fcf3ce44SJohn Forte 			}
2020*fcf3ce44SJohn Forte 		}
2021*fcf3ce44SJohn Forte 		if (!found_pwrOffDrv) {
2022*fcf3ce44SJohn Forte 			(void) fprintf(stdout,
2023*fcf3ce44SJohn Forte 				MSGSTR(2052,
2024*fcf3ce44SJohn Forte 				"Notice: Drives in enclosure"
2025*fcf3ce44SJohn Forte 				" \"%s\" have already been"
2026*fcf3ce44SJohn Forte 				" powered on.\n\n"),
2027*fcf3ce44SJohn Forte 				encl_name);
2028*fcf3ce44SJohn Forte 			return (-1);
2029*fcf3ce44SJohn Forte 		}
2030*fcf3ce44SJohn Forte 	}
2031*fcf3ce44SJohn Forte 	return (0);
2032*fcf3ce44SJohn Forte }
2033*fcf3ce44SJohn Forte 
2034*fcf3ce44SJohn Forte 
2035*fcf3ce44SJohn Forte 
2036*fcf3ce44SJohn Forte 
2037*fcf3ce44SJohn Forte 
2038*fcf3ce44SJohn Forte /*
2039*fcf3ce44SJohn Forte  * adm_led() The led_request subcommand requests the subsystem
2040*fcf3ce44SJohn Forte  * to display the current state or turn off, on, or blink
2041*fcf3ce44SJohn Forte  * the yellow LED associated with the disk specified by the
2042*fcf3ce44SJohn Forte  * enclosure or pathname.
2043*fcf3ce44SJohn Forte  *
2044*fcf3ce44SJohn Forte  * RETURNS:
2045*fcf3ce44SJohn Forte  *	none.
2046*fcf3ce44SJohn Forte  */
2047*fcf3ce44SJohn Forte void
2048*fcf3ce44SJohn Forte adm_led(char **argv, int led_action)
2049*fcf3ce44SJohn Forte {
2050*fcf3ce44SJohn Forte int		path_index = 0, err = 0;
2051*fcf3ce44SJohn Forte gfc_map_t	map;
2052*fcf3ce44SJohn Forte L_inquiry	inq;
2053*fcf3ce44SJohn Forte Dev_elem_st	status;
2054*fcf3ce44SJohn Forte char		*path_phys = NULL;
2055*fcf3ce44SJohn Forte Path_struct	*path_struct;
2056*fcf3ce44SJohn Forte int		enc_t = 0;		/* enclosure type */
2057*fcf3ce44SJohn Forte char		ses_path[MAXPATHLEN];
2058*fcf3ce44SJohn Forte L_inquiry	ses_inq;
2059*fcf3ce44SJohn Forte 
2060*fcf3ce44SJohn Forte 	while (argv[path_index] != NULL) {
2061*fcf3ce44SJohn Forte 		if ((err = l_convert_name(argv[path_index], &path_phys,
2062*fcf3ce44SJohn Forte 			&path_struct, Options & PVERBOSE)) != 0) {
2063*fcf3ce44SJohn Forte 			/* Make sure we have a device path. */
2064*fcf3ce44SJohn Forte 			if (path_struct->ib_path_flag) {
2065*fcf3ce44SJohn Forte 				path_phys = path_struct->p_physical_path;
2066*fcf3ce44SJohn Forte 			} else {
2067*fcf3ce44SJohn Forte 				(void) fprintf(stderr,
2068*fcf3ce44SJohn Forte 					MSGSTR(33,
2069*fcf3ce44SJohn Forte 				" Error: converting"
2070*fcf3ce44SJohn Forte 				" %s to physical path.\n"
2071*fcf3ce44SJohn Forte 				" Invalid pathname.\n"),
2072*fcf3ce44SJohn Forte 					argv[path_index]);
2073*fcf3ce44SJohn Forte 				if (err != -1) {
2074*fcf3ce44SJohn Forte 					(void) print_errString(err,
2075*fcf3ce44SJohn Forte 							argv[path_index]);
2076*fcf3ce44SJohn Forte 				}
2077*fcf3ce44SJohn Forte 				exit(-1);
2078*fcf3ce44SJohn Forte 			}
2079*fcf3ce44SJohn Forte 		}
2080*fcf3ce44SJohn Forte 		if (!path_struct->ib_path_flag) {
2081*fcf3ce44SJohn Forte 			if (err = g_get_inquiry(path_phys, &inq)) {
2082*fcf3ce44SJohn Forte 				(void) print_errString(err, argv[path_index]);
2083*fcf3ce44SJohn Forte 				exit(-1);
2084*fcf3ce44SJohn Forte 			}
2085*fcf3ce44SJohn Forte 			if ((inq.inq_dtype & DTYPE_MASK) != DTYPE_DIRECT) {
2086*fcf3ce44SJohn Forte 				(void) fprintf(stderr,
2087*fcf3ce44SJohn Forte 				MSGSTR(2053,
2088*fcf3ce44SJohn Forte 				"Error: pathname must be to a disk device.\n"
2089*fcf3ce44SJohn Forte 				" %s\n"), argv[path_index]);
2090*fcf3ce44SJohn Forte 				exit(-1);
2091*fcf3ce44SJohn Forte 			}
2092*fcf3ce44SJohn Forte 		}
2093*fcf3ce44SJohn Forte 		/*
2094*fcf3ce44SJohn Forte 		 * See if we are in fact talking to a loop or not.
2095*fcf3ce44SJohn Forte 		 */
2096*fcf3ce44SJohn Forte 		if (err = g_get_dev_map(path_phys, &map,
2097*fcf3ce44SJohn Forte 			(Options & PVERBOSE))) {
2098*fcf3ce44SJohn Forte 			(void) print_errString(err, argv[path_index]);
2099*fcf3ce44SJohn Forte 
2100*fcf3ce44SJohn Forte 		}
2101*fcf3ce44SJohn Forte 		    if (led_action == L_LED_ON) {
2102*fcf3ce44SJohn Forte 			(void) fprintf(stderr, MSGSTR(2054,
2103*fcf3ce44SJohn Forte 			    "The led_on functionality is not applicable "
2104*fcf3ce44SJohn Forte 			    "to this subsystem.\n"));
2105*fcf3ce44SJohn Forte 			exit(-1);
2106*fcf3ce44SJohn Forte 		    }
2107*fcf3ce44SJohn Forte 		    if (err = l_led(path_struct, led_action, &status,
2108*fcf3ce44SJohn Forte 			    (Options & PVERBOSE))) {
2109*fcf3ce44SJohn Forte 			(void) print_errString(err, argv[path_index]);
2110*fcf3ce44SJohn Forte 			exit(-1);
2111*fcf3ce44SJohn Forte 		    }
2112*fcf3ce44SJohn Forte 
2113*fcf3ce44SJohn Forte 		    /* Check to see if we have a daktari */
2114*fcf3ce44SJohn Forte 		    if (l_get_ses_path(path_phys, ses_path, &map,
2115*fcf3ce44SJohn Forte 			    (Options & PVERBOSE)) == 0) {
2116*fcf3ce44SJohn Forte 			if (g_get_inquiry(ses_path, &ses_inq) == 0) {
2117*fcf3ce44SJohn Forte 			    enc_t = l_get_enc_type(ses_inq);
2118*fcf3ce44SJohn Forte 			}
2119*fcf3ce44SJohn Forte 		    }
2120*fcf3ce44SJohn Forte 		    switch (led_action) {
2121*fcf3ce44SJohn Forte 		    case L_LED_STATUS:
2122*fcf3ce44SJohn Forte 			if (status.fault || status.fault_req) {
2123*fcf3ce44SJohn Forte 			    if (!path_struct->slot_valid) {
2124*fcf3ce44SJohn Forte 				(void) fprintf(stdout,
2125*fcf3ce44SJohn Forte 				    MSGSTR(2055, "LED state is ON for "
2126*fcf3ce44SJohn Forte 				    "device:\n  %s\n"), path_phys);
2127*fcf3ce44SJohn Forte 			    } else {
2128*fcf3ce44SJohn Forte 				if (enc_t == DAK_ENC_TYPE) {
2129*fcf3ce44SJohn Forte 				    if (path_struct->f_flag) {
2130*fcf3ce44SJohn Forte 					(void) fprintf(stdout,
2131*fcf3ce44SJohn Forte 					    MSGSTR(2236, "LED state is ON for "
2132*fcf3ce44SJohn Forte 					    "device in location: slot %d\n"),
2133*fcf3ce44SJohn Forte 					    path_struct->slot);
2134*fcf3ce44SJohn Forte 				    } else {
2135*fcf3ce44SJohn Forte 					(void) fprintf(stdout,
2136*fcf3ce44SJohn Forte 					    MSGSTR(2236, "LED state is ON for "
2137*fcf3ce44SJohn Forte 					    "device in location: slot %d\n"),
2138*fcf3ce44SJohn Forte 					    path_struct->slot +
2139*fcf3ce44SJohn Forte 							(MAX_DRIVES_DAK/2));
2140*fcf3ce44SJohn Forte 				    }
2141*fcf3ce44SJohn Forte 				} else {
2142*fcf3ce44SJohn Forte 				    (void) fprintf(stdout,
2143*fcf3ce44SJohn Forte 				    (path_struct->f_flag) ?
2144*fcf3ce44SJohn Forte 				    MSGSTR(2056, "LED state is ON for "
2145*fcf3ce44SJohn Forte 				    "device in location: front,slot %d\n")
2146*fcf3ce44SJohn Forte 				    : MSGSTR(2057, "LED state is ON for "
2147*fcf3ce44SJohn Forte 				    "device in location: rear,slot %d\n"),
2148*fcf3ce44SJohn Forte 				    path_struct->slot);
2149*fcf3ce44SJohn Forte 				    }
2150*fcf3ce44SJohn Forte 			    }
2151*fcf3ce44SJohn Forte 			} else if (status.ident || status.rdy_to_ins ||
2152*fcf3ce44SJohn Forte 				status.rmv) {
2153*fcf3ce44SJohn Forte 			    if (!path_struct->slot_valid) {
2154*fcf3ce44SJohn Forte 				(void) fprintf(stdout, MSGSTR(2058,
2155*fcf3ce44SJohn Forte 				    "LED state is BLINKING for "
2156*fcf3ce44SJohn Forte 				    "device:\n  %s\n"), path_phys);
2157*fcf3ce44SJohn Forte 			    } else {
2158*fcf3ce44SJohn Forte 				if (enc_t == DAK_ENC_TYPE) {
2159*fcf3ce44SJohn Forte 				    if (path_struct->f_flag) {
2160*fcf3ce44SJohn Forte 					(void) fprintf(stdout, MSGSTR(2237,
2161*fcf3ce44SJohn Forte 					"LED state is BLINKING for "
2162*fcf3ce44SJohn Forte 					"device in location: slot %d\n"),
2163*fcf3ce44SJohn Forte 					path_struct->slot);
2164*fcf3ce44SJohn Forte 				    } else {
2165*fcf3ce44SJohn Forte 					(void) fprintf(stdout, MSGSTR(2237,
2166*fcf3ce44SJohn Forte 					"LED state is BLINKING for "
2167*fcf3ce44SJohn Forte 					"device in location: slot %d\n"),
2168*fcf3ce44SJohn Forte 					path_struct->slot + (MAX_DRIVES_DAK/2));
2169*fcf3ce44SJohn Forte 				    }
2170*fcf3ce44SJohn Forte 				} else {
2171*fcf3ce44SJohn Forte 				    (void) fprintf(stdout,
2172*fcf3ce44SJohn Forte 				    (path_struct->f_flag) ?
2173*fcf3ce44SJohn Forte 				    MSGSTR(2059, "LED state is BLINKING for "
2174*fcf3ce44SJohn Forte 				    "device in location: front,slot %d\n")
2175*fcf3ce44SJohn Forte 				    : MSGSTR(2060, "LED state is BLINKING for "
2176*fcf3ce44SJohn Forte 				    "device in location: rear,slot %d\n"),
2177*fcf3ce44SJohn Forte 				    path_struct->slot);
2178*fcf3ce44SJohn Forte 				}
2179*fcf3ce44SJohn Forte 			    }
2180*fcf3ce44SJohn Forte 			} else {
2181*fcf3ce44SJohn Forte 			    if (!path_struct->slot_valid) {
2182*fcf3ce44SJohn Forte 				(void) fprintf(stdout,
2183*fcf3ce44SJohn Forte 				MSGSTR(2061, "LED state is OFF for "
2184*fcf3ce44SJohn Forte 				"device:\n  %s\n"), path_phys);
2185*fcf3ce44SJohn Forte 			    } else {
2186*fcf3ce44SJohn Forte 				if (enc_t == DAK_ENC_TYPE) {
2187*fcf3ce44SJohn Forte 				    if (path_struct->f_flag) {
2188*fcf3ce44SJohn Forte 					(void) fprintf(stdout, MSGSTR(2238,
2189*fcf3ce44SJohn Forte 					"LED state is OFF for "
2190*fcf3ce44SJohn Forte 					"device in location: slot %d\n"),
2191*fcf3ce44SJohn Forte 					path_struct->slot);
2192*fcf3ce44SJohn Forte 				    } else {
2193*fcf3ce44SJohn Forte 					(void) fprintf(stdout, MSGSTR(2238,
2194*fcf3ce44SJohn Forte 					"LED state is OFF for "
2195*fcf3ce44SJohn Forte 					"device in location: slot %d\n"),
2196*fcf3ce44SJohn Forte 					path_struct->slot + MAX_DRIVES_DAK/2);
2197*fcf3ce44SJohn Forte 				    }
2198*fcf3ce44SJohn Forte 				} else {
2199*fcf3ce44SJohn Forte 				    (void) fprintf(stdout,
2200*fcf3ce44SJohn Forte 					(path_struct->f_flag) ?
2201*fcf3ce44SJohn Forte 					MSGSTR(2062, "LED state is OFF for "
2202*fcf3ce44SJohn Forte 					"device in location: front,slot %d\n")
2203*fcf3ce44SJohn Forte 					: MSGSTR(2063, "LED state is OFF for "
2204*fcf3ce44SJohn Forte 					"device in location: rear,slot %d\n"),
2205*fcf3ce44SJohn Forte 					path_struct->slot);
2206*fcf3ce44SJohn Forte 				}
2207*fcf3ce44SJohn Forte 			    }
2208*fcf3ce44SJohn Forte 			}
2209*fcf3ce44SJohn Forte 			break;
2210*fcf3ce44SJohn Forte 		    }
2211*fcf3ce44SJohn Forte 		    free((void *)map.dev_addr);
2212*fcf3ce44SJohn Forte 		    path_index++;
2213*fcf3ce44SJohn Forte 	}
2214*fcf3ce44SJohn Forte }
2215*fcf3ce44SJohn Forte 
2216*fcf3ce44SJohn Forte 
2217*fcf3ce44SJohn Forte 
2218*fcf3ce44SJohn Forte 
2219*fcf3ce44SJohn Forte 
2220*fcf3ce44SJohn Forte /*
2221*fcf3ce44SJohn Forte  * dump() Dump information
2222*fcf3ce44SJohn Forte  *
2223*fcf3ce44SJohn Forte  * RETURNS:
2224*fcf3ce44SJohn Forte  *	none.
2225*fcf3ce44SJohn Forte  */
2226*fcf3ce44SJohn Forte void
2227*fcf3ce44SJohn Forte dump(char **argv)
2228*fcf3ce44SJohn Forte {
2229*fcf3ce44SJohn Forte uchar_t		*buf;
2230*fcf3ce44SJohn Forte int		path_index = 0, err = 0;
2231*fcf3ce44SJohn Forte L_inquiry	inq;
2232*fcf3ce44SJohn Forte char		hdr_buf[MAXNAMELEN];
2233*fcf3ce44SJohn Forte Rec_diag_hdr	*hdr, *hdr_ptr;
2234*fcf3ce44SJohn Forte char		*path_phys = NULL;
2235*fcf3ce44SJohn Forte Path_struct	*path_struct;
2236*fcf3ce44SJohn Forte 
2237*fcf3ce44SJohn Forte 	/*
2238*fcf3ce44SJohn Forte 	 * get big buffer
2239*fcf3ce44SJohn Forte 	 */
2240*fcf3ce44SJohn Forte 	if ((hdr = (struct rec_diag_hdr *)calloc(1, MAX_REC_DIAG_LENGTH)) ==
2241*fcf3ce44SJohn Forte 								NULL) {
2242*fcf3ce44SJohn Forte 		(void) print_errString(L_MALLOC_FAILED, NULL);
2243*fcf3ce44SJohn Forte 		exit(-1);
2244*fcf3ce44SJohn Forte 	}
2245*fcf3ce44SJohn Forte 	buf = (uchar_t *)hdr;
2246*fcf3ce44SJohn Forte 
2247*fcf3ce44SJohn Forte 	while (argv[path_index] != NULL) {
2248*fcf3ce44SJohn Forte 		if ((err = l_convert_name(argv[path_index], &path_phys,
2249*fcf3ce44SJohn Forte 			&path_struct, Options & PVERBOSE)) != 0) {
2250*fcf3ce44SJohn Forte 			(void) fprintf(stderr,
2251*fcf3ce44SJohn Forte 				MSGSTR(33,
2252*fcf3ce44SJohn Forte 					" Error: converting"
2253*fcf3ce44SJohn Forte 					" %s to physical path.\n"
2254*fcf3ce44SJohn Forte 					" Invalid pathname.\n"),
2255*fcf3ce44SJohn Forte 				argv[path_index]);
2256*fcf3ce44SJohn Forte 			if (err != -1) {
2257*fcf3ce44SJohn Forte 				(void) print_errString(err, argv[path_index]);
2258*fcf3ce44SJohn Forte 			}
2259*fcf3ce44SJohn Forte 			exit(-1);
2260*fcf3ce44SJohn Forte 		}
2261*fcf3ce44SJohn Forte 		if (err = g_get_inquiry(path_phys, &inq)) {
2262*fcf3ce44SJohn Forte 			(void) print_errString(err, argv[path_index]);
2263*fcf3ce44SJohn Forte 		} else {
2264*fcf3ce44SJohn Forte 			(void) g_dump(MSGSTR(2065, "INQUIRY data:   "),
2265*fcf3ce44SJohn Forte 			(uchar_t *)&inq, 5 + inq.inq_len, HEX_ASCII);
2266*fcf3ce44SJohn Forte 		}
2267*fcf3ce44SJohn Forte 
2268*fcf3ce44SJohn Forte 		(void) memset(buf, 0, MAX_REC_DIAG_LENGTH);
2269*fcf3ce44SJohn Forte 		if (err = l_get_envsen(path_phys, buf, MAX_REC_DIAG_LENGTH,
2270*fcf3ce44SJohn Forte 			(Options & PVERBOSE))) {
2271*fcf3ce44SJohn Forte 		    (void) print_errString(err, argv[path_index]);
2272*fcf3ce44SJohn Forte 		    exit(-1);
2273*fcf3ce44SJohn Forte 		}
2274*fcf3ce44SJohn Forte 		(void) fprintf(stdout,
2275*fcf3ce44SJohn Forte 			MSGSTR(2066, "\t\tEnvironmental Sense Information\n"));
2276*fcf3ce44SJohn Forte 
2277*fcf3ce44SJohn Forte 		/*
2278*fcf3ce44SJohn Forte 		 * Dump all pages.
2279*fcf3ce44SJohn Forte 		 */
2280*fcf3ce44SJohn Forte 		hdr_ptr = hdr;
2281*fcf3ce44SJohn Forte 
2282*fcf3ce44SJohn Forte 		while (hdr_ptr->page_len != 0) {
2283*fcf3ce44SJohn Forte 			(void) sprintf(hdr_buf, MSGSTR(2067, "Page %d:   "),
2284*fcf3ce44SJohn Forte 				hdr_ptr->page_code);
2285*fcf3ce44SJohn Forte 			(void) g_dump(hdr_buf, (uchar_t *)hdr_ptr,
2286*fcf3ce44SJohn Forte 				HEADER_LEN + hdr_ptr->page_len, HEX_ASCII);
2287*fcf3ce44SJohn Forte 			hdr_ptr += ((HEADER_LEN + hdr_ptr->page_len) /
2288*fcf3ce44SJohn Forte 				sizeof (struct	rec_diag_hdr));
2289*fcf3ce44SJohn Forte 		}
2290*fcf3ce44SJohn Forte 		path_index++;
2291*fcf3ce44SJohn Forte 	}
2292*fcf3ce44SJohn Forte 	(void) free(buf);
2293*fcf3ce44SJohn Forte }
2294*fcf3ce44SJohn Forte 
2295*fcf3ce44SJohn Forte 
2296*fcf3ce44SJohn Forte 
2297*fcf3ce44SJohn Forte /*
2298*fcf3ce44SJohn Forte  * display_socal_stats() Display socal driver kstat information.
2299*fcf3ce44SJohn Forte  *
2300*fcf3ce44SJohn Forte  * RETURNS:
2301*fcf3ce44SJohn Forte  *	none.
2302*fcf3ce44SJohn Forte  */
2303*fcf3ce44SJohn Forte void
2304*fcf3ce44SJohn Forte display_socal_stats(int port, char *socal_path, struct socal_stats *fc_stats)
2305*fcf3ce44SJohn Forte {
2306*fcf3ce44SJohn Forte int		i;
2307*fcf3ce44SJohn Forte int		header_flag = 0;
2308*fcf3ce44SJohn Forte char		status_msg_buf[MAXNAMELEN];
2309*fcf3ce44SJohn Forte int		num_status_entries;
2310*fcf3ce44SJohn Forte 
2311*fcf3ce44SJohn Forte 	(void) fprintf(stdout, MSGSTR(2068,
2312*fcf3ce44SJohn Forte 		"\tInformation for FC Loop on port %d of"
2313*fcf3ce44SJohn Forte 		" FC100/S Host Adapter\n\tat path: %s\n"),
2314*fcf3ce44SJohn Forte 		port, socal_path);
2315*fcf3ce44SJohn Forte 	if (fc_stats->version > 1) {
2316*fcf3ce44SJohn Forte 		(void) fprintf(stdout, "\t");
2317*fcf3ce44SJohn Forte 		(void) fprintf(stdout, MSGSTR(32,
2318*fcf3ce44SJohn Forte 			"Information from %s"), fc_stats->drvr_name);
2319*fcf3ce44SJohn Forte 		(void) fprintf(stdout, "\n");
2320*fcf3ce44SJohn Forte 		if ((*fc_stats->node_wwn != NULL) &&
2321*fcf3ce44SJohn Forte 			(*fc_stats->port_wwn[port] != NULL)) {
2322*fcf3ce44SJohn Forte 			(void) fprintf(stdout, MSGSTR(104,
2323*fcf3ce44SJohn Forte 				"  Host Adapter WWN's: Node:%s"
2324*fcf3ce44SJohn Forte 				"  Port:%s\n"),
2325*fcf3ce44SJohn Forte 				fc_stats->node_wwn,
2326*fcf3ce44SJohn Forte 				fc_stats->port_wwn[port]);
2327*fcf3ce44SJohn Forte 		}
2328*fcf3ce44SJohn Forte 		if (*fc_stats->fw_revision != NULL) {
2329*fcf3ce44SJohn Forte 			(void) fprintf(stdout, MSGSTR(105,
2330*fcf3ce44SJohn Forte 				"  Host Adapter Firmware Revision: %s\n"),
2331*fcf3ce44SJohn Forte 				fc_stats->fw_revision);
2332*fcf3ce44SJohn Forte 		}
2333*fcf3ce44SJohn Forte 		if (fc_stats->parity_chk_enabled != 0) {
2334*fcf3ce44SJohn Forte 			(void) fprintf(stdout, MSGSTR(2069,
2335*fcf3ce44SJohn Forte 			"  This Host Adapter checks S-Bus parity.\n"));
2336*fcf3ce44SJohn Forte 		}
2337*fcf3ce44SJohn Forte 	}
2338*fcf3ce44SJohn Forte 
2339*fcf3ce44SJohn Forte 	(void) fprintf(stdout, MSGSTR(2070,
2340*fcf3ce44SJohn Forte 		"  Version Resets  Req_Q_Intrpts  Qfulls"
2341*fcf3ce44SJohn Forte 		" Unsol_Resps Lips\n"));
2342*fcf3ce44SJohn Forte 
2343*fcf3ce44SJohn Forte 	(void) fprintf(stdout,  "  %4d%8d%11d%13d%10d%7d\n",
2344*fcf3ce44SJohn Forte 			fc_stats->version,
2345*fcf3ce44SJohn Forte 			fc_stats->resets,
2346*fcf3ce44SJohn Forte 			fc_stats->reqq_intrs,
2347*fcf3ce44SJohn Forte 			fc_stats->qfulls,
2348*fcf3ce44SJohn Forte 			fc_stats->pstats[port].unsol_resps,
2349*fcf3ce44SJohn Forte 			fc_stats->pstats[port].lips);
2350*fcf3ce44SJohn Forte 
2351*fcf3ce44SJohn Forte 	(void) fprintf(stdout, MSGSTR(2071,
2352*fcf3ce44SJohn Forte 		"  Els_rcvd  Abts"
2353*fcf3ce44SJohn Forte 		"     Abts_ok Offlines Loop_onlines Onlines\n"));
2354*fcf3ce44SJohn Forte 
2355*fcf3ce44SJohn Forte 	(void) fprintf(stdout, "  %4d%9d%10d%9d%13d%10d\n",
2356*fcf3ce44SJohn Forte 			fc_stats->pstats[port].els_rcvd,
2357*fcf3ce44SJohn Forte 			fc_stats->pstats[port].abts,
2358*fcf3ce44SJohn Forte 			fc_stats->pstats[port].abts_ok,
2359*fcf3ce44SJohn Forte 			fc_stats->pstats[port].offlines,
2360*fcf3ce44SJohn Forte 			fc_stats->pstats[port].online_loops,
2361*fcf3ce44SJohn Forte 			fc_stats->pstats[port].onlines);
2362*fcf3ce44SJohn Forte 
2363*fcf3ce44SJohn Forte 	/* If any status conditions exist then display */
2364*fcf3ce44SJohn Forte 	if (fc_stats->version > 1) {
2365*fcf3ce44SJohn Forte 		num_status_entries = FC_STATUS_ENTRIES;
2366*fcf3ce44SJohn Forte 	} else {
2367*fcf3ce44SJohn Forte 		num_status_entries = 64;
2368*fcf3ce44SJohn Forte 	}
2369*fcf3ce44SJohn Forte 
2370*fcf3ce44SJohn Forte 	for (i = 0; i < num_status_entries; i++) {
2371*fcf3ce44SJohn Forte 		if (fc_stats->pstats[port].resp_status[i] != 0) {
2372*fcf3ce44SJohn Forte 			if (header_flag++ == 0) {
2373*fcf3ce44SJohn Forte 				(void) fprintf(stdout, MSGSTR(2072,
2374*fcf3ce44SJohn Forte 				"  Fibre Channel Transport status:\n        "
2375*fcf3ce44SJohn Forte 				"Status                       Value"
2376*fcf3ce44SJohn Forte 				"           Count\n"));
2377*fcf3ce44SJohn Forte 			}
2378*fcf3ce44SJohn Forte 			(void) l_format_fc_status_msg(status_msg_buf,
2379*fcf3ce44SJohn Forte 			fc_stats->pstats[port].resp_status[i], i);
2380*fcf3ce44SJohn Forte 			(void) fprintf(stdout, "        %s\n",
2381*fcf3ce44SJohn Forte 				status_msg_buf);
2382*fcf3ce44SJohn Forte 		}
2383*fcf3ce44SJohn Forte 	}
2384*fcf3ce44SJohn Forte }
2385*fcf3ce44SJohn Forte 
2386*fcf3ce44SJohn Forte 
2387*fcf3ce44SJohn Forte 
2388*fcf3ce44SJohn Forte /*
2389*fcf3ce44SJohn Forte  * display_sf_stats() Display sf driver kstat information.
2390*fcf3ce44SJohn Forte  *
2391*fcf3ce44SJohn Forte  * This routine is called by private loop device only
2392*fcf3ce44SJohn Forte  *
2393*fcf3ce44SJohn Forte  * RETURNS:
2394*fcf3ce44SJohn Forte  *	none.
2395*fcf3ce44SJohn Forte  */
2396*fcf3ce44SJohn Forte void
2397*fcf3ce44SJohn Forte display_sf_stats(char *path_phys, int dtype, struct sf_stats *sf_stats)
2398*fcf3ce44SJohn Forte {
2399*fcf3ce44SJohn Forte int		i, al_pa, err = 0;
2400*fcf3ce44SJohn Forte gfc_map_t	map;
2401*fcf3ce44SJohn Forte uchar_t		node_wwn[WWN_SIZE];
2402*fcf3ce44SJohn Forte uchar_t		port_wwn[WWN_SIZE];
2403*fcf3ce44SJohn Forte gfc_port_dev_info_t	*dev_addr_list;
2404*fcf3ce44SJohn Forte 
2405*fcf3ce44SJohn Forte 	if (sf_stats->version > 1) {
2406*fcf3ce44SJohn Forte 		(void) fprintf(stdout, "\n\t");
2407*fcf3ce44SJohn Forte 		(void) fprintf(stdout, MSGSTR(32,
2408*fcf3ce44SJohn Forte 			"Information from %s"),
2409*fcf3ce44SJohn Forte 			sf_stats->drvr_name);
2410*fcf3ce44SJohn Forte 		(void) fprintf(stdout, "\n");
2411*fcf3ce44SJohn Forte 	} else {
2412*fcf3ce44SJohn Forte 		(void) fprintf(stdout,
2413*fcf3ce44SJohn Forte 			MSGSTR(2073, "\n\t\tInformation from sf driver:\n"));
2414*fcf3ce44SJohn Forte 	}
2415*fcf3ce44SJohn Forte 
2416*fcf3ce44SJohn Forte 	(void) fprintf(stdout, MSGSTR(2074,
2417*fcf3ce44SJohn Forte 		"  Version  Lip_count  Lip_fail"
2418*fcf3ce44SJohn Forte 		" Alloc_fail  #_cmds "
2419*fcf3ce44SJohn Forte 		"Throttle_limit  Pool_size\n"));
2420*fcf3ce44SJohn Forte 
2421*fcf3ce44SJohn Forte 	(void) fprintf(stdout, "  %4d%9d%12d%11d%10d%11d%12d\n",
2422*fcf3ce44SJohn Forte 			sf_stats->version,
2423*fcf3ce44SJohn Forte 			sf_stats->lip_count,
2424*fcf3ce44SJohn Forte 			sf_stats->lip_failures,
2425*fcf3ce44SJohn Forte 			sf_stats->cralloc_failures,
2426*fcf3ce44SJohn Forte 			sf_stats->ncmds,
2427*fcf3ce44SJohn Forte 			sf_stats->throttle_limit,
2428*fcf3ce44SJohn Forte 			sf_stats->cr_pool_size);
2429*fcf3ce44SJohn Forte 
2430*fcf3ce44SJohn Forte 	(void) fprintf(stdout, MSGSTR(2075,
2431*fcf3ce44SJohn Forte 		"\n\t\tTARGET ERROR INFORMATION:\n"));
2432*fcf3ce44SJohn Forte 	(void) fprintf(stdout, MSGSTR(2076,
2433*fcf3ce44SJohn Forte 		"AL_PA  Els_fail Timouts Abts_fail"
2434*fcf3ce44SJohn Forte 		" Tsk_m_fail "
2435*fcf3ce44SJohn Forte 		" Data_ro_mis Dl_len_mis Logouts\n"));
2436*fcf3ce44SJohn Forte 
2437*fcf3ce44SJohn Forte 	if (err = g_get_dev_map(path_phys, &map, (Options & PVERBOSE))) {
2438*fcf3ce44SJohn Forte 		(void) print_errString(err, path_phys);
2439*fcf3ce44SJohn Forte 		exit(-1);
2440*fcf3ce44SJohn Forte 	}
2441*fcf3ce44SJohn Forte 
2442*fcf3ce44SJohn Forte 	if (dtype == DTYPE_DIRECT) {
2443*fcf3ce44SJohn Forte 		if (err = g_get_wwn(path_phys, port_wwn, node_wwn, &al_pa,
2444*fcf3ce44SJohn Forte 			Options & PVERBOSE)) {
2445*fcf3ce44SJohn Forte 			(void) print_errString(err, path_phys);
2446*fcf3ce44SJohn Forte 			exit(-1);
2447*fcf3ce44SJohn Forte 		}
2448*fcf3ce44SJohn Forte 		/* for san toleration, only need to modify the code    */
2449*fcf3ce44SJohn Forte 		/* such that the current sf_al_map structure replaced  */
2450*fcf3ce44SJohn Forte 		/* by the new gfc_map structure for private loop device */
2451*fcf3ce44SJohn Forte 		for (i = 0, dev_addr_list = map.dev_addr; i < map.count;
2452*fcf3ce44SJohn Forte 			i++, dev_addr_list++) {
2453*fcf3ce44SJohn Forte 			if (dev_addr_list->gfc_port_dev.priv_port.sf_al_pa
2454*fcf3ce44SJohn Forte 					== al_pa) {
2455*fcf3ce44SJohn Forte 				(void) fprintf(stdout,
2456*fcf3ce44SJohn Forte 				"%3x%10d%8d%10d%11d%13d%11d%9d\n",
2457*fcf3ce44SJohn Forte 				al_pa,
2458*fcf3ce44SJohn Forte 				sf_stats->tstats[i].els_failures,
2459*fcf3ce44SJohn Forte 				sf_stats->tstats[i].timeouts,
2460*fcf3ce44SJohn Forte 				sf_stats->tstats[i].abts_failures,
2461*fcf3ce44SJohn Forte 				sf_stats->tstats[i].task_mgmt_failures,
2462*fcf3ce44SJohn Forte 				sf_stats->tstats[i].data_ro_mismatches,
2463*fcf3ce44SJohn Forte 				sf_stats->tstats[i].dl_len_mismatches,
2464*fcf3ce44SJohn Forte 				sf_stats->tstats[i].logouts_recvd);
2465*fcf3ce44SJohn Forte 				break;
2466*fcf3ce44SJohn Forte 			}
2467*fcf3ce44SJohn Forte 		}
2468*fcf3ce44SJohn Forte 		if (i >= map.count) {
2469*fcf3ce44SJohn Forte 			(void) print_errString(L_INVALID_LOOP_MAP, path_phys);
2470*fcf3ce44SJohn Forte 			exit(-1);
2471*fcf3ce44SJohn Forte 		}
2472*fcf3ce44SJohn Forte 	} else {
2473*fcf3ce44SJohn Forte 		for (i = 0, dev_addr_list = map.dev_addr; i < map.count;
2474*fcf3ce44SJohn Forte 			i++, dev_addr_list++) {
2475*fcf3ce44SJohn Forte 			(void) fprintf(stdout,
2476*fcf3ce44SJohn Forte 			"%3x%10d%8d%10d%11d%13d%11d%9d\n",
2477*fcf3ce44SJohn Forte 			dev_addr_list->gfc_port_dev.priv_port.sf_al_pa,
2478*fcf3ce44SJohn Forte 			sf_stats->tstats[i].els_failures,
2479*fcf3ce44SJohn Forte 			sf_stats->tstats[i].timeouts,
2480*fcf3ce44SJohn Forte 			sf_stats->tstats[i].abts_failures,
2481*fcf3ce44SJohn Forte 			sf_stats->tstats[i].task_mgmt_failures,
2482*fcf3ce44SJohn Forte 			sf_stats->tstats[i].data_ro_mismatches,
2483*fcf3ce44SJohn Forte 			sf_stats->tstats[i].dl_len_mismatches,
2484*fcf3ce44SJohn Forte 			sf_stats->tstats[i].logouts_recvd);
2485*fcf3ce44SJohn Forte 		}
2486*fcf3ce44SJohn Forte 	}
2487*fcf3ce44SJohn Forte 	free((void *)map.dev_addr);
2488*fcf3ce44SJohn Forte }
2489*fcf3ce44SJohn Forte 
2490*fcf3ce44SJohn Forte 
2491*fcf3ce44SJohn Forte 
2492*fcf3ce44SJohn Forte /*
2493*fcf3ce44SJohn Forte  * adm_display_err() Displays enclosure specific
2494*fcf3ce44SJohn Forte  * error information.
2495*fcf3ce44SJohn Forte  *
2496*fcf3ce44SJohn Forte  * RETURNS:
2497*fcf3ce44SJohn Forte  *	none.
2498*fcf3ce44SJohn Forte  */
2499*fcf3ce44SJohn Forte static void
2500*fcf3ce44SJohn Forte adm_display_err(char *path_phys, int dtype)
2501*fcf3ce44SJohn Forte {
2502*fcf3ce44SJohn Forte int		i, drvr_inst, sf_inst, socal_inst, port, al_pa, err = 0;
2503*fcf3ce44SJohn Forte char		*char_ptr, socal_path[MAXPATHLEN], drvr_path[MAXPATHLEN];
2504*fcf3ce44SJohn Forte struct		stat sbuf;
2505*fcf3ce44SJohn Forte kstat_ctl_t	*kc;
2506*fcf3ce44SJohn Forte kstat_t		*ifp_ks, *sf_ks, *fc_ks;
2507*fcf3ce44SJohn Forte sf_stats_t	sf_stats;
2508*fcf3ce44SJohn Forte socal_stats_t	fc_stats;
2509*fcf3ce44SJohn Forte ifp_stats_t	ifp_stats;
2510*fcf3ce44SJohn Forte int		header_flag = 0, pathcnt = 1;
2511*fcf3ce44SJohn Forte char		status_msg_buf[MAXNAMELEN];
2512*fcf3ce44SJohn Forte gfc_map_t	map;
2513*fcf3ce44SJohn Forte uchar_t		node_wwn[WWN_SIZE], port_wwn[WWN_SIZE];
2514*fcf3ce44SJohn Forte uint_t		path_type;
2515*fcf3ce44SJohn Forte gfc_port_dev_info_t	*dev_addr_list;
2516*fcf3ce44SJohn Forte mp_pathlist_t	pathlist;
2517*fcf3ce44SJohn Forte int		p_on = 0, p_st = 0;
2518*fcf3ce44SJohn Forte 
2519*fcf3ce44SJohn Forte 	if ((kc = kstat_open()) == (kstat_ctl_t *)NULL) {
2520*fcf3ce44SJohn Forte 		(void) fprintf(stderr,
2521*fcf3ce44SJohn Forte 			MSGSTR(2077, " Error: can't open kstat\n"));
2522*fcf3ce44SJohn Forte 		exit(-1);
2523*fcf3ce44SJohn Forte 	}
2524*fcf3ce44SJohn Forte 
2525*fcf3ce44SJohn Forte 	if (strstr(path_phys, SCSI_VHCI)) {
2526*fcf3ce44SJohn Forte 		(void) strcpy(drvr_path, path_phys);
2527*fcf3ce44SJohn Forte 		if (err = g_get_pathlist(drvr_path, &pathlist)) {
2528*fcf3ce44SJohn Forte 			(void) print_errString(err, NULL);
2529*fcf3ce44SJohn Forte 			exit(-1);
2530*fcf3ce44SJohn Forte 		}
2531*fcf3ce44SJohn Forte 		pathcnt = pathlist.path_count;
2532*fcf3ce44SJohn Forte 		p_on = p_st = 0;
2533*fcf3ce44SJohn Forte 		for (i = 0; i < pathcnt; i++) {
2534*fcf3ce44SJohn Forte 			if (pathlist.path_info[i].path_state < MAXPATHSTATE) {
2535*fcf3ce44SJohn Forte 				if (pathlist.path_info[i].path_state ==
2536*fcf3ce44SJohn Forte 					MDI_PATHINFO_STATE_ONLINE) {
2537*fcf3ce44SJohn Forte 					p_on = i;
2538*fcf3ce44SJohn Forte 					break;
2539*fcf3ce44SJohn Forte 				} else if (pathlist.path_info[i].path_state ==
2540*fcf3ce44SJohn Forte 					MDI_PATHINFO_STATE_STANDBY) {
2541*fcf3ce44SJohn Forte 					p_st = i;
2542*fcf3ce44SJohn Forte 				}
2543*fcf3ce44SJohn Forte 			}
2544*fcf3ce44SJohn Forte 		}
2545*fcf3ce44SJohn Forte 		if (pathlist.path_info[p_on].path_state ==
2546*fcf3ce44SJohn Forte 		    MDI_PATHINFO_STATE_ONLINE) {
2547*fcf3ce44SJohn Forte 			/* on_line path */
2548*fcf3ce44SJohn Forte 			(void) strcpy(drvr_path,
2549*fcf3ce44SJohn Forte 				pathlist.path_info[p_on].path_hba);
2550*fcf3ce44SJohn Forte 		} else {
2551*fcf3ce44SJohn Forte 			/* standby or path0 */
2552*fcf3ce44SJohn Forte 			(void) strcpy(drvr_path,
2553*fcf3ce44SJohn Forte 				pathlist.path_info[p_st].path_hba);
2554*fcf3ce44SJohn Forte 		}
2555*fcf3ce44SJohn Forte 		free(pathlist.path_info);
2556*fcf3ce44SJohn Forte 	} else {
2557*fcf3ce44SJohn Forte 
2558*fcf3ce44SJohn Forte 		(void) strcpy(drvr_path, path_phys);
2559*fcf3ce44SJohn Forte 
2560*fcf3ce44SJohn Forte 		if ((char_ptr = strrchr(drvr_path, '/')) == NULL) {
2561*fcf3ce44SJohn Forte 			(void) print_errString(L_INVLD_PATH_NO_SLASH_FND,
2562*fcf3ce44SJohn Forte 				path_phys);
2563*fcf3ce44SJohn Forte 			exit(-1);
2564*fcf3ce44SJohn Forte 		}
2565*fcf3ce44SJohn Forte 		*char_ptr = '\0';   /* Make into nexus or HBA driver path. */
2566*fcf3ce44SJohn Forte 	}
2567*fcf3ce44SJohn Forte 	/*
2568*fcf3ce44SJohn Forte 	 * Each HBA and driver stack has its own structures
2569*fcf3ce44SJohn Forte 	 * for this, so we have to handle each one individually.
2570*fcf3ce44SJohn Forte 	 */
2571*fcf3ce44SJohn Forte 	path_type = g_get_path_type(drvr_path);
2572*fcf3ce44SJohn Forte 
2573*fcf3ce44SJohn Forte 	if (path_type) { /* Quick sanity check for valid path */
2574*fcf3ce44SJohn Forte 		if ((err = g_get_nexus_path(drvr_path, &char_ptr)) != 0) {
2575*fcf3ce44SJohn Forte 			(void) print_errString(err, path_phys);
2576*fcf3ce44SJohn Forte 			exit(-1);
2577*fcf3ce44SJohn Forte 		}
2578*fcf3ce44SJohn Forte 		(void) strcpy(socal_path, char_ptr);
2579*fcf3ce44SJohn Forte 
2580*fcf3ce44SJohn Forte 	}
2581*fcf3ce44SJohn Forte 
2582*fcf3ce44SJohn Forte 	/* attach :devctl to get node stat instead of dir stat. */
2583*fcf3ce44SJohn Forte 	(void) strcat(drvr_path, FC_CTLR);
2584*fcf3ce44SJohn Forte 
2585*fcf3ce44SJohn Forte 	if (stat(drvr_path, &sbuf) < 0) {
2586*fcf3ce44SJohn Forte 		(void) print_errString(L_LSTAT_ERROR, path_phys);
2587*fcf3ce44SJohn Forte 		exit(-1);
2588*fcf3ce44SJohn Forte 	}
2589*fcf3ce44SJohn Forte 
2590*fcf3ce44SJohn Forte 	drvr_inst = minor(sbuf.st_rdev);
2591*fcf3ce44SJohn Forte 
2592*fcf3ce44SJohn Forte 
2593*fcf3ce44SJohn Forte 	/*
2594*fcf3ce44SJohn Forte 	 * first take care of ifp card.
2595*fcf3ce44SJohn Forte 	 */
2596*fcf3ce44SJohn Forte 	if (path_type & FC4_PCI_FCA) {
2597*fcf3ce44SJohn Forte 	    if ((ifp_ks = kstat_lookup(kc, "ifp",
2598*fcf3ce44SJohn Forte 			drvr_inst, "statistics")) != NULL) {
2599*fcf3ce44SJohn Forte 
2600*fcf3ce44SJohn Forte 		if (kstat_read(kc, ifp_ks, &ifp_stats) < 0) {
2601*fcf3ce44SJohn Forte 			(void) fprintf(stderr,
2602*fcf3ce44SJohn Forte 				MSGSTR(2082,
2603*fcf3ce44SJohn Forte 				"Error: could not read ifp%d\n"), drvr_inst);
2604*fcf3ce44SJohn Forte 			exit(-1);
2605*fcf3ce44SJohn Forte 		}
2606*fcf3ce44SJohn Forte 		(void) fprintf(stdout, MSGSTR(2083,
2607*fcf3ce44SJohn Forte 			"\tInformation for FC Loop of"
2608*fcf3ce44SJohn Forte 			" FC100/P Host Adapter\n\tat path: %s\n"),
2609*fcf3ce44SJohn Forte 			drvr_path);
2610*fcf3ce44SJohn Forte 		if (ifp_stats.version > 1) {
2611*fcf3ce44SJohn Forte 			(void) fprintf(stdout, "\t");
2612*fcf3ce44SJohn Forte 			(void) fprintf(stdout, MSGSTR(32,
2613*fcf3ce44SJohn Forte 				"Information from %s"),
2614*fcf3ce44SJohn Forte 				ifp_stats.drvr_name);
2615*fcf3ce44SJohn Forte 			(void) fprintf(stdout, "\n");
2616*fcf3ce44SJohn Forte 			if ((*ifp_stats.node_wwn != NULL) &&
2617*fcf3ce44SJohn Forte 				(*ifp_stats.port_wwn != NULL)) {
2618*fcf3ce44SJohn Forte 				(void) fprintf(stdout, MSGSTR(104,
2619*fcf3ce44SJohn Forte 					"  Host Adapter WWN's: Node:%s"
2620*fcf3ce44SJohn Forte 					"  Port:%s\n"),
2621*fcf3ce44SJohn Forte 					ifp_stats.node_wwn,
2622*fcf3ce44SJohn Forte 					ifp_stats.port_wwn);
2623*fcf3ce44SJohn Forte 			}
2624*fcf3ce44SJohn Forte 			if (*ifp_stats.fw_revision != NULL) {
2625*fcf3ce44SJohn Forte 				(void) fprintf(stdout, MSGSTR(105,
2626*fcf3ce44SJohn Forte 				"  Host Adapter Firmware Revision: %s\n"),
2627*fcf3ce44SJohn Forte 				ifp_stats.fw_revision);
2628*fcf3ce44SJohn Forte 			}
2629*fcf3ce44SJohn Forte 			if (ifp_stats.parity_chk_enabled != 0) {
2630*fcf3ce44SJohn Forte 				(void) fprintf(stdout, MSGSTR(2084,
2631*fcf3ce44SJohn Forte 				"  This Host Adapter checks "
2632*fcf3ce44SJohn Forte 				"PCI-Bus parity.\n"));
2633*fcf3ce44SJohn Forte 			}
2634*fcf3ce44SJohn Forte 		}
2635*fcf3ce44SJohn Forte 
2636*fcf3ce44SJohn Forte 		(void) fprintf(stdout, MSGSTR(2085,
2637*fcf3ce44SJohn Forte 			"        Version Lips\n"));
2638*fcf3ce44SJohn Forte 		(void) fprintf(stdout, "  %10d%7d\n",
2639*fcf3ce44SJohn Forte 				ifp_stats.version,
2640*fcf3ce44SJohn Forte 				ifp_stats.lip_count);
2641*fcf3ce44SJohn Forte 		/* If any status conditions exist then display */
2642*fcf3ce44SJohn Forte 		for (i = 0; i < FC_STATUS_ENTRIES; i++) {
2643*fcf3ce44SJohn Forte 			if (ifp_stats.resp_status[i] != 0) {
2644*fcf3ce44SJohn Forte 				if (header_flag++ == 0) {
2645*fcf3ce44SJohn Forte 					(void) fprintf(stdout, MSGSTR(2086,
2646*fcf3ce44SJohn Forte 					"  Fibre Channel Transport "
2647*fcf3ce44SJohn Forte 					"status:\n        "
2648*fcf3ce44SJohn Forte 					"Status           "
2649*fcf3ce44SJohn Forte 					"            Value"
2650*fcf3ce44SJohn Forte 					"           Count\n"));
2651*fcf3ce44SJohn Forte 				}
2652*fcf3ce44SJohn Forte 				(void) l_format_ifp_status_msg(
2653*fcf3ce44SJohn Forte 					status_msg_buf,
2654*fcf3ce44SJohn Forte 					ifp_stats.resp_status[i], i);
2655*fcf3ce44SJohn Forte 					(void) fprintf(stdout, "        %s\n",
2656*fcf3ce44SJohn Forte 					status_msg_buf);
2657*fcf3ce44SJohn Forte 			}
2658*fcf3ce44SJohn Forte 		}
2659*fcf3ce44SJohn Forte 
2660*fcf3ce44SJohn Forte 		(void) fprintf(stdout, MSGSTR(2087,
2661*fcf3ce44SJohn Forte 			"\n\t\tTARGET ERROR INFORMATION:\n"));
2662*fcf3ce44SJohn Forte 		(void) fprintf(stdout, MSGSTR(2088,
2663*fcf3ce44SJohn Forte 			"AL_PA  logouts_recvd  task_mgmt_failures"
2664*fcf3ce44SJohn Forte 			"  data_ro_mismatches  data_len_mismatch\n"));
2665*fcf3ce44SJohn Forte 
2666*fcf3ce44SJohn Forte 		if (err = g_get_dev_map(path_phys, &map,
2667*fcf3ce44SJohn Forte 					(Options & PVERBOSE))) {
2668*fcf3ce44SJohn Forte 			(void) print_errString(err, path_phys);
2669*fcf3ce44SJohn Forte 			exit(-1);
2670*fcf3ce44SJohn Forte 		}
2671*fcf3ce44SJohn Forte 
2672*fcf3ce44SJohn Forte 
2673*fcf3ce44SJohn Forte 		if (dtype == DTYPE_DIRECT) {
2674*fcf3ce44SJohn Forte 			if (err = g_get_wwn(path_phys, port_wwn,
2675*fcf3ce44SJohn Forte 				node_wwn, &al_pa,
2676*fcf3ce44SJohn Forte 				Options & PVERBOSE)) {
2677*fcf3ce44SJohn Forte 				(void) print_errString(err,
2678*fcf3ce44SJohn Forte 				path_phys);
2679*fcf3ce44SJohn Forte 				exit(-1);
2680*fcf3ce44SJohn Forte 			}
2681*fcf3ce44SJohn Forte 			for (i = 0, dev_addr_list = map.dev_addr;
2682*fcf3ce44SJohn Forte 				i < map.count; i++,
2683*fcf3ce44SJohn Forte 				dev_addr_list++) {
2684*fcf3ce44SJohn Forte 				if (dev_addr_list->gfc_port_dev.
2685*fcf3ce44SJohn Forte 					priv_port.sf_al_pa
2686*fcf3ce44SJohn Forte 					== al_pa) {
2687*fcf3ce44SJohn Forte 					(void) fprintf
2688*fcf3ce44SJohn Forte 					(stdout,
2689*fcf3ce44SJohn Forte 					"%3x%14d%18d%20d%20d\n",
2690*fcf3ce44SJohn Forte 					al_pa,
2691*fcf3ce44SJohn Forte 					ifp_stats.tstats[i].
2692*fcf3ce44SJohn Forte 						logouts_recvd,
2693*fcf3ce44SJohn Forte 					ifp_stats.tstats[i].
2694*fcf3ce44SJohn Forte 						task_mgmt_failures,
2695*fcf3ce44SJohn Forte 					ifp_stats.tstats[i].
2696*fcf3ce44SJohn Forte 						data_ro_mismatches,
2697*fcf3ce44SJohn Forte 					ifp_stats.tstats[i].
2698*fcf3ce44SJohn Forte 						dl_len_mismatches);
2699*fcf3ce44SJohn Forte 					break;
2700*fcf3ce44SJohn Forte 				}
2701*fcf3ce44SJohn Forte 			}
2702*fcf3ce44SJohn Forte 			if (i >= map.count) {
2703*fcf3ce44SJohn Forte 
2704*fcf3ce44SJohn Forte 				(void) print_errString(
2705*fcf3ce44SJohn Forte 				L_INVALID_LOOP_MAP, path_phys);
2706*fcf3ce44SJohn Forte 				exit(-1);
2707*fcf3ce44SJohn Forte 			}
2708*fcf3ce44SJohn Forte 
2709*fcf3ce44SJohn Forte 		} else {
2710*fcf3ce44SJohn Forte 			for (i = 0, dev_addr_list = map.dev_addr;
2711*fcf3ce44SJohn Forte 				i < map.count; i++,
2712*fcf3ce44SJohn Forte 				dev_addr_list++) {
2713*fcf3ce44SJohn Forte 				(void) fprintf(stdout,
2714*fcf3ce44SJohn Forte 				"%3x%14d%18d%20d%20d\n",
2715*fcf3ce44SJohn Forte 				dev_addr_list->gfc_port_dev.
2716*fcf3ce44SJohn Forte 					priv_port.sf_al_pa,
2717*fcf3ce44SJohn Forte 				ifp_stats.tstats[i].logouts_recvd,
2718*fcf3ce44SJohn Forte 				ifp_stats.tstats[i].task_mgmt_failures,
2719*fcf3ce44SJohn Forte 				ifp_stats.tstats[i].data_ro_mismatches,
2720*fcf3ce44SJohn Forte 				ifp_stats.tstats[i].dl_len_mismatches);
2721*fcf3ce44SJohn Forte 			}
2722*fcf3ce44SJohn Forte 		}
2723*fcf3ce44SJohn Forte 
2724*fcf3ce44SJohn Forte 		free((void *)map.dev_addr);
2725*fcf3ce44SJohn Forte 	    }
2726*fcf3ce44SJohn Forte 	} else if (path_type & FC4_SF_XPORT) {
2727*fcf3ce44SJohn Forte 	/*
2728*fcf3ce44SJohn Forte 	 * process cards with sf xport nodes.
2729*fcf3ce44SJohn Forte 	 */
2730*fcf3ce44SJohn Forte 	    if (stat(socal_path, &sbuf) < 0) {
2731*fcf3ce44SJohn Forte 		(void) print_errString(L_LSTAT_ERROR, path_phys);
2732*fcf3ce44SJohn Forte 		exit(-1);
2733*fcf3ce44SJohn Forte 	    }
2734*fcf3ce44SJohn Forte 	    socal_inst = minor(sbuf.st_rdev)/2;
2735*fcf3ce44SJohn Forte 	    port = socal_inst%2;
2736*fcf3ce44SJohn Forte 
2737*fcf3ce44SJohn Forte 	    sf_inst = LUX_SF_MINOR2INST(minor(sbuf.st_rdev));
2738*fcf3ce44SJohn Forte 	    if (!(sf_ks = kstat_lookup(kc, "sf", sf_inst,
2739*fcf3ce44SJohn Forte 		"statistics"))) {
2740*fcf3ce44SJohn Forte 		(void) fprintf(stderr,
2741*fcf3ce44SJohn Forte 			MSGSTR(2078,
2742*fcf3ce44SJohn Forte 		" Error: could not lookup driver stats for sf%d\n"),
2743*fcf3ce44SJohn Forte 			sf_inst);
2744*fcf3ce44SJohn Forte 		exit(-1);
2745*fcf3ce44SJohn Forte 	    }
2746*fcf3ce44SJohn Forte 	    if (!(fc_ks = kstat_lookup(kc, "socal", socal_inst,
2747*fcf3ce44SJohn Forte 					"statistics"))) {
2748*fcf3ce44SJohn Forte 		(void) fprintf(stderr,
2749*fcf3ce44SJohn Forte 			MSGSTR(2079,
2750*fcf3ce44SJohn Forte 		" Error: could not lookup driver stats for socal%d\n"),
2751*fcf3ce44SJohn Forte 			socal_inst);
2752*fcf3ce44SJohn Forte 		exit(-1);
2753*fcf3ce44SJohn Forte 	    }
2754*fcf3ce44SJohn Forte 	    if (kstat_read(kc, sf_ks, &sf_stats) < 0) {
2755*fcf3ce44SJohn Forte 		(void) fprintf(stderr,
2756*fcf3ce44SJohn Forte 			MSGSTR(2080,
2757*fcf3ce44SJohn Forte 		" Error: could not read driver stats for sf%d\n"),
2758*fcf3ce44SJohn Forte 			sf_inst);
2759*fcf3ce44SJohn Forte 		exit(-1);
2760*fcf3ce44SJohn Forte 	    }
2761*fcf3ce44SJohn Forte 	    if (kstat_read(kc, fc_ks, &fc_stats) < 0) {
2762*fcf3ce44SJohn Forte 		(void) fprintf(stderr,
2763*fcf3ce44SJohn Forte 			MSGSTR(2081,
2764*fcf3ce44SJohn Forte 		" Error: could not read driver stats for socal%d\n"),
2765*fcf3ce44SJohn Forte 			socal_inst);
2766*fcf3ce44SJohn Forte 		exit(-1);
2767*fcf3ce44SJohn Forte 	    }
2768*fcf3ce44SJohn Forte 	    (void) display_socal_stats(port, socal_path, &fc_stats);
2769*fcf3ce44SJohn Forte 	    (void) display_sf_stats(path_phys, dtype, &sf_stats);
2770*fcf3ce44SJohn Forte 	} else if ((path_type & FC_FCA_MASK) == FC_PCI_FCA) {
2771*fcf3ce44SJohn Forte 		fprintf(stderr, MSGSTR(2252,
2772*fcf3ce44SJohn Forte 			"\n WARNING!! display -r on qlc is"
2773*fcf3ce44SJohn Forte 			" currently not supported.\n"));
2774*fcf3ce44SJohn Forte 	} else {
2775*fcf3ce44SJohn Forte 		fprintf(stderr, MSGSTR(2253,
2776*fcf3ce44SJohn Forte 			"\n WARNING!! display -r is not supported on path\n"
2777*fcf3ce44SJohn Forte 			" %s\n"), drvr_path);
2778*fcf3ce44SJohn Forte 	}
2779*fcf3ce44SJohn Forte 	(void) kstat_close(kc);
2780*fcf3ce44SJohn Forte 
2781*fcf3ce44SJohn Forte }
2782*fcf3ce44SJohn Forte 
2783*fcf3ce44SJohn Forte 
2784*fcf3ce44SJohn Forte 
2785*fcf3ce44SJohn Forte /*ARGSUSED*/
2786*fcf3ce44SJohn Forte /*
2787*fcf3ce44SJohn Forte  * adm_display_verbose_disk() Gets the mode page information
2788*fcf3ce44SJohn Forte  * for a SENA disk and prints that information.
2789*fcf3ce44SJohn Forte  *
2790*fcf3ce44SJohn Forte  * RETURNS:
2791*fcf3ce44SJohn Forte  *	none.
2792*fcf3ce44SJohn Forte  */
2793*fcf3ce44SJohn Forte void
2794*fcf3ce44SJohn Forte adm_display_verbose_disk(char *path, int verbose)
2795*fcf3ce44SJohn Forte {
2796*fcf3ce44SJohn Forte uchar_t		*pg_buf;
2797*fcf3ce44SJohn Forte Mode_header_10	*mode_header_ptr;
2798*fcf3ce44SJohn Forte Mp_01		*pg1_buf;
2799*fcf3ce44SJohn Forte Mp_04		*pg4_buf;
2800*fcf3ce44SJohn Forte struct mode_page *pg_hdr;
2801*fcf3ce44SJohn Forte int		offset, hdr_printed = 0, err = 0;
2802*fcf3ce44SJohn Forte 
2803*fcf3ce44SJohn Forte 	if ((err = l_get_mode_pg(path, &pg_buf, verbose)) == 0) {
2804*fcf3ce44SJohn Forte 
2805*fcf3ce44SJohn Forte 		mode_header_ptr = (struct mode_header_10_struct *)(int)pg_buf;
2806*fcf3ce44SJohn Forte 		pg_hdr = ((struct mode_page *)((int)pg_buf +
2807*fcf3ce44SJohn Forte 		    (uchar_t)sizeof (struct mode_header_10_struct) +
2808*fcf3ce44SJohn Forte 		    (uchar_t *)(uintptr_t)(mode_header_ptr->bdesc_length)));
2809*fcf3ce44SJohn Forte 		offset = sizeof (struct mode_header_10_struct) +
2810*fcf3ce44SJohn Forte 		    mode_header_ptr->bdesc_length;
2811*fcf3ce44SJohn Forte 		while (offset < (mode_header_ptr->length +
2812*fcf3ce44SJohn Forte 			sizeof (mode_header_ptr->length))) {
2813*fcf3ce44SJohn Forte 			switch (pg_hdr->code) {
2814*fcf3ce44SJohn Forte 				case 0x01:
2815*fcf3ce44SJohn Forte 				pg1_buf = (struct mode_page_01_struct *)
2816*fcf3ce44SJohn Forte 					(int)pg_hdr;
2817*fcf3ce44SJohn Forte 				P_DPRINTF("  adm_display_verbose_disk:"
2818*fcf3ce44SJohn Forte 					"Mode Sense page 1 found.\n");
2819*fcf3ce44SJohn Forte 				if (hdr_printed++ == 0) {
2820*fcf3ce44SJohn Forte 					(void) fprintf(stdout,
2821*fcf3ce44SJohn Forte 						MSGSTR(2089,
2822*fcf3ce44SJohn Forte 						"  Mode Sense data:\n"));
2823*fcf3ce44SJohn Forte 				}
2824*fcf3ce44SJohn Forte 				(void) fprintf(stdout,
2825*fcf3ce44SJohn Forte 					MSGSTR(2090,
2826*fcf3ce44SJohn Forte 					"    AWRE:\t\t\t%d\n"
2827*fcf3ce44SJohn Forte 					"    ARRE:\t\t\t%d\n"
2828*fcf3ce44SJohn Forte 					"    Read Retry Count:\t\t"
2829*fcf3ce44SJohn Forte 					"%d\n"
2830*fcf3ce44SJohn Forte 					"    Write Retry Count:\t\t"
2831*fcf3ce44SJohn Forte 					"%d\n"),
2832*fcf3ce44SJohn Forte 					pg1_buf->awre,
2833*fcf3ce44SJohn Forte 					pg1_buf->arre,
2834*fcf3ce44SJohn Forte 					pg1_buf->read_retry_count,
2835*fcf3ce44SJohn Forte 					pg1_buf->write_retry_count);
2836*fcf3ce44SJohn Forte 				break;
2837*fcf3ce44SJohn Forte 				case MODEPAGE_GEOMETRY:
2838*fcf3ce44SJohn Forte 				pg4_buf = (struct mode_page_04_struct *)
2839*fcf3ce44SJohn Forte 					(int)pg_hdr;
2840*fcf3ce44SJohn Forte 				P_DPRINTF("  adm_display_verbose_disk:"
2841*fcf3ce44SJohn Forte 					"Mode Sense page 4 found.\n");
2842*fcf3ce44SJohn Forte 				if (hdr_printed++ == 0) {
2843*fcf3ce44SJohn Forte 					(void) fprintf(stdout,
2844*fcf3ce44SJohn Forte 						MSGSTR(2091,
2845*fcf3ce44SJohn Forte 						"  Mode Sense data:\n"));
2846*fcf3ce44SJohn Forte 				}
2847*fcf3ce44SJohn Forte 				if (pg4_buf->rpm) {
2848*fcf3ce44SJohn Forte 					(void) fprintf(stdout,
2849*fcf3ce44SJohn Forte 						MSGSTR(2092,
2850*fcf3ce44SJohn Forte 						"    Medium rotation rate:\t"
2851*fcf3ce44SJohn Forte 						"%d RPM\n"), pg4_buf->rpm);
2852*fcf3ce44SJohn Forte 				}
2853*fcf3ce44SJohn Forte 				break;
2854*fcf3ce44SJohn Forte 			}
2855*fcf3ce44SJohn Forte 			offset += pg_hdr->length + sizeof (struct mode_page);
2856*fcf3ce44SJohn Forte 			pg_hdr = ((struct mode_page *)((int)pg_buf +
2857*fcf3ce44SJohn Forte 				(uchar_t)offset));
2858*fcf3ce44SJohn Forte 		}
2859*fcf3ce44SJohn Forte 
2860*fcf3ce44SJohn Forte 
2861*fcf3ce44SJohn Forte 
2862*fcf3ce44SJohn Forte 
2863*fcf3ce44SJohn Forte 
2864*fcf3ce44SJohn Forte 	} else if (getenv("_LUX_P_DEBUG") != NULL) {
2865*fcf3ce44SJohn Forte 			(void) print_errString(err, path);
2866*fcf3ce44SJohn Forte 	}
2867*fcf3ce44SJohn Forte }
2868*fcf3ce44SJohn Forte 
2869*fcf3ce44SJohn Forte /*
2870*fcf3ce44SJohn Forte  * Print out the port_wwn or node_wwn
2871*fcf3ce44SJohn Forte  */
2872*fcf3ce44SJohn Forte void
2873*fcf3ce44SJohn Forte print_wwn(FILE *fd, uchar_t *pn_wwn)
2874*fcf3ce44SJohn Forte {
2875*fcf3ce44SJohn Forte 
2876*fcf3ce44SJohn Forte 	(void) fprintf(fd,
2877*fcf3ce44SJohn Forte 		" %1.2x%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x",
2878*fcf3ce44SJohn Forte 		pn_wwn[0], pn_wwn[1], pn_wwn[2], pn_wwn[3],
2879*fcf3ce44SJohn Forte 		pn_wwn[4], pn_wwn[5], pn_wwn[6], pn_wwn[7]);
2880*fcf3ce44SJohn Forte }
2881*fcf3ce44SJohn Forte 
2882*fcf3ce44SJohn Forte /*
2883*fcf3ce44SJohn Forte  * Print out the fabric dev port_id, hard_addr, port_wwn and node_wwn
2884*fcf3ce44SJohn Forte  */
2885*fcf3ce44SJohn Forte void
2886*fcf3ce44SJohn Forte print_fabric_prop(int pos, uchar_t *port_wwn, uchar_t *node_wwn, int port_addr,
2887*fcf3ce44SJohn Forte 	int hard_addr)
2888*fcf3ce44SJohn Forte {
2889*fcf3ce44SJohn Forte 	(void) fprintf(stdout, "%-4d %-6x  %-6x   ",
2890*fcf3ce44SJohn Forte 		pos, port_addr, hard_addr);
2891*fcf3ce44SJohn Forte 	print_wwn(stdout, port_wwn);
2892*fcf3ce44SJohn Forte 	print_wwn(stdout, node_wwn);
2893*fcf3ce44SJohn Forte }
2894*fcf3ce44SJohn Forte 
2895*fcf3ce44SJohn Forte /*
2896*fcf3ce44SJohn Forte  * Print out the private loop dev port_id, hard_addr, port_wwn and node_wwn
2897*fcf3ce44SJohn Forte  */
2898*fcf3ce44SJohn Forte void
2899*fcf3ce44SJohn Forte print_private_loop_prop(int pos, uchar_t *port_wwn, uchar_t *node_wwn,
2900*fcf3ce44SJohn Forte 	int port_addr, int hard_addr)
2901*fcf3ce44SJohn Forte {
2902*fcf3ce44SJohn Forte 	(void) fprintf(stdout, "%-3d   %-2x  %-2x    %-2x    ",
2903*fcf3ce44SJohn Forte 		pos, port_addr, g_sf_alpa_to_switch[port_addr], hard_addr);
2904*fcf3ce44SJohn Forte 	print_wwn(stdout, port_wwn);
2905*fcf3ce44SJohn Forte 	print_wwn(stdout, node_wwn);
2906*fcf3ce44SJohn Forte }
2907*fcf3ce44SJohn Forte 
2908*fcf3ce44SJohn Forte /*
2909*fcf3ce44SJohn Forte  * Get the device map from
2910*fcf3ce44SJohn Forte  * fc nexus driver and prints the map.
2911*fcf3ce44SJohn Forte  *
2912*fcf3ce44SJohn Forte  * RETURNS:
2913*fcf3ce44SJohn Forte  *	none.
2914*fcf3ce44SJohn Forte  */
2915*fcf3ce44SJohn Forte void
2916*fcf3ce44SJohn Forte dump_map(char **argv)
2917*fcf3ce44SJohn Forte {
2918*fcf3ce44SJohn Forte int		i = 0, path_index = 0, pathcnt = 1;
2919*fcf3ce44SJohn Forte int		limited_map_flag = 0, err = 0;
2920*fcf3ce44SJohn Forte char		*path_phys = NULL;
2921*fcf3ce44SJohn Forte Path_struct	*path_struct;
2922*fcf3ce44SJohn Forte struct lilpmap	limited_map;
2923*fcf3ce44SJohn Forte uint_t		dev_type;
2924*fcf3ce44SJohn Forte char		temp2path[MAXPATHLEN];
2925*fcf3ce44SJohn Forte mp_pathlist_t	pathlist;
2926*fcf3ce44SJohn Forte int		p_pw = 0, p_on = 0, p_st = 0;
2927*fcf3ce44SJohn Forte gfc_dev_t	map_root, map_dev;
2928*fcf3ce44SJohn Forte int 		*port_addr, *hard_addr, pos = 0, count;
2929*fcf3ce44SJohn Forte uchar_t		*hba_port_wwn, *port_wwn, *node_wwn, *dtype_prop;
2930*fcf3ce44SJohn Forte uint_t		map_topo;
2931*fcf3ce44SJohn Forte 
2932*fcf3ce44SJohn Forte 	while (argv[path_index] != NULL) {
2933*fcf3ce44SJohn Forte 		if ((err = l_convert_name(argv[path_index], &path_phys,
2934*fcf3ce44SJohn Forte 			&path_struct, Options & PVERBOSE)) != 0) {
2935*fcf3ce44SJohn Forte 			(void) fprintf(stderr,
2936*fcf3ce44SJohn Forte 				MSGSTR(33,
2937*fcf3ce44SJohn Forte 					" Error: converting"
2938*fcf3ce44SJohn Forte 					" %s to physical path.\n"
2939*fcf3ce44SJohn Forte 					" Invalid pathname.\n"),
2940*fcf3ce44SJohn Forte 				argv[path_index]);
2941*fcf3ce44SJohn Forte 			if (err != -1) {
2942*fcf3ce44SJohn Forte 				(void) print_errString(err, argv[path_index]);
2943*fcf3ce44SJohn Forte 			}
2944*fcf3ce44SJohn Forte 			exit(-1);
2945*fcf3ce44SJohn Forte 		}
2946*fcf3ce44SJohn Forte 
2947*fcf3ce44SJohn Forte 		if (strstr(path_phys, SCSI_VHCI) != NULL) {
2948*fcf3ce44SJohn Forte 			/* obtain phci */
2949*fcf3ce44SJohn Forte 			(void) strcpy(temp2path, path_phys);
2950*fcf3ce44SJohn Forte 			if (err = g_get_pathlist(temp2path, &pathlist)) {
2951*fcf3ce44SJohn Forte 				(void) print_errString(err, NULL);
2952*fcf3ce44SJohn Forte 				exit(-1);
2953*fcf3ce44SJohn Forte 			}
2954*fcf3ce44SJohn Forte 			pathcnt = pathlist.path_count;
2955*fcf3ce44SJohn Forte 			p_pw = p_on = p_st = 0;
2956*fcf3ce44SJohn Forte 			for (i = 0; i < pathcnt; i++) {
2957*fcf3ce44SJohn Forte 				if (pathlist.path_info[i].path_state <
2958*fcf3ce44SJohn Forte 					MAXPATHSTATE) {
2959*fcf3ce44SJohn Forte 					if (strstr(pathlist.path_info[i].
2960*fcf3ce44SJohn Forte 						path_addr,
2961*fcf3ce44SJohn Forte 						path_struct->argv) != NULL) {
2962*fcf3ce44SJohn Forte 						p_pw = i;
2963*fcf3ce44SJohn Forte 						break;
2964*fcf3ce44SJohn Forte 					}
2965*fcf3ce44SJohn Forte 					if (pathlist.path_info[i].path_state ==
2966*fcf3ce44SJohn Forte 						MDI_PATHINFO_STATE_ONLINE) {
2967*fcf3ce44SJohn Forte 						p_on = i;
2968*fcf3ce44SJohn Forte 					}
2969*fcf3ce44SJohn Forte 					if (pathlist.path_info[i].path_state ==
2970*fcf3ce44SJohn Forte 						MDI_PATHINFO_STATE_STANDBY) {
2971*fcf3ce44SJohn Forte 						p_st = i;
2972*fcf3ce44SJohn Forte 					}
2973*fcf3ce44SJohn Forte 				}
2974*fcf3ce44SJohn Forte 			}
2975*fcf3ce44SJohn Forte 			if (strstr(pathlist.path_info[p_pw].path_addr,
2976*fcf3ce44SJohn Forte 				path_struct->argv) != NULL) {
2977*fcf3ce44SJohn Forte 				/* matching input pwwn */
2978*fcf3ce44SJohn Forte 				(void) strcpy(temp2path,
2979*fcf3ce44SJohn Forte 					pathlist.path_info[p_pw].path_hba);
2980*fcf3ce44SJohn Forte 			} else if (pathlist.path_info[p_on].path_state ==
2981*fcf3ce44SJohn Forte 				MDI_PATHINFO_STATE_ONLINE) {
2982*fcf3ce44SJohn Forte 				/* on_line path */
2983*fcf3ce44SJohn Forte 				(void) strcpy(temp2path,
2984*fcf3ce44SJohn Forte 					pathlist.path_info[p_on].path_hba);
2985*fcf3ce44SJohn Forte 			} else {
2986*fcf3ce44SJohn Forte 				/* standby or path0 */
2987*fcf3ce44SJohn Forte 				(void) strcpy(temp2path,
2988*fcf3ce44SJohn Forte 					pathlist.path_info[p_st].path_hba);
2989*fcf3ce44SJohn Forte 			}
2990*fcf3ce44SJohn Forte 			free(pathlist.path_info);
2991*fcf3ce44SJohn Forte 			(void) strcat(temp2path, FC_CTLR);
2992*fcf3ce44SJohn Forte 		} else {
2993*fcf3ce44SJohn Forte 			(void) strcpy(temp2path, path_phys);
2994*fcf3ce44SJohn Forte 		}
2995*fcf3ce44SJohn Forte 
2996*fcf3ce44SJohn Forte 		if ((dev_type = g_get_path_type(temp2path)) == 0) {
2997*fcf3ce44SJohn Forte 			(void) print_errString(L_INVALID_PATH,
2998*fcf3ce44SJohn Forte 						argv[path_index]);
2999*fcf3ce44SJohn Forte 			exit(-1);
3000*fcf3ce44SJohn Forte 		}
3001*fcf3ce44SJohn Forte 
3002*fcf3ce44SJohn Forte 		if ((map_root = g_dev_map_init(temp2path, &err,
3003*fcf3ce44SJohn Forte 			MAP_FORMAT_LILP)) == NULL) {
3004*fcf3ce44SJohn Forte 		    if (dev_type & FC_FCA_MASK) {
3005*fcf3ce44SJohn Forte 			(void) print_errString(err, argv[path_index]);
3006*fcf3ce44SJohn Forte 			exit(-1);
3007*fcf3ce44SJohn Forte 		    } else {
3008*fcf3ce44SJohn Forte 			/*
3009*fcf3ce44SJohn Forte 			 * This did not work so try the FCIO_GETMAP
3010*fcf3ce44SJohn Forte 			 * type ioctl.
3011*fcf3ce44SJohn Forte 			 */
3012*fcf3ce44SJohn Forte 			if (err = g_get_limited_map(path_phys,
3013*fcf3ce44SJohn Forte 				&limited_map, (Options & PVERBOSE))) {
3014*fcf3ce44SJohn Forte 				(void) print_errString(err,
3015*fcf3ce44SJohn Forte 						argv[path_index]);
3016*fcf3ce44SJohn Forte 				exit(-1);
3017*fcf3ce44SJohn Forte 			}
3018*fcf3ce44SJohn Forte 			limited_map_flag++;
3019*fcf3ce44SJohn Forte 		    }
3020*fcf3ce44SJohn Forte 
3021*fcf3ce44SJohn Forte 		}
3022*fcf3ce44SJohn Forte 
3023*fcf3ce44SJohn Forte 		if (limited_map_flag) {
3024*fcf3ce44SJohn Forte 		    (void) fprintf(stdout,
3025*fcf3ce44SJohn Forte 			MSGSTR(2093,
3026*fcf3ce44SJohn Forte 			"Host Adapter AL_PA: %x\n"),
3027*fcf3ce44SJohn Forte 			limited_map.lilp_myalpa);
3028*fcf3ce44SJohn Forte 
3029*fcf3ce44SJohn Forte 		    (void) fprintf(stdout,
3030*fcf3ce44SJohn Forte 			MSGSTR(2094,
3031*fcf3ce44SJohn Forte 			"Pos AL_PA\n"));
3032*fcf3ce44SJohn Forte 		    for (i = 0; i < (uint_t)limited_map.lilp_length; i++) {
3033*fcf3ce44SJohn Forte 			(void) fprintf(stdout, "%-3d   %-2x\n",
3034*fcf3ce44SJohn Forte 				i, limited_map.lilp_list[i]);
3035*fcf3ce44SJohn Forte 		    }
3036*fcf3ce44SJohn Forte 		} else {
3037*fcf3ce44SJohn Forte 		    if ((err = g_dev_prop_lookup_bytes(map_root,
3038*fcf3ce44SJohn Forte 			PORT_WWN_PROP, &count, &hba_port_wwn)) != 0) {
3039*fcf3ce44SJohn Forte 			g_dev_map_fini(map_root);
3040*fcf3ce44SJohn Forte 			(void) print_errString(err, argv[path_index]);
3041*fcf3ce44SJohn Forte 			exit(-1);
3042*fcf3ce44SJohn Forte 		    }
3043*fcf3ce44SJohn Forte 		    if ((err = g_get_map_topology(
3044*fcf3ce44SJohn Forte 				map_root, &map_topo)) != 0) {
3045*fcf3ce44SJohn Forte 			(void) print_errString(err, argv[path_index]);
3046*fcf3ce44SJohn Forte 			exit(-1);
3047*fcf3ce44SJohn Forte 		    }
3048*fcf3ce44SJohn Forte 
3049*fcf3ce44SJohn Forte 		    if ((map_dev = g_get_first_dev(map_root, &err)) == NULL) {
3050*fcf3ce44SJohn Forte 			if (err == L_NO_SUCH_DEV_FOUND) {
3051*fcf3ce44SJohn Forte 			    g_dev_map_fini(map_root);
3052*fcf3ce44SJohn Forte 			    (void) fprintf(stderr,
3053*fcf3ce44SJohn Forte 			    MSGSTR(2308, " No devices are found on %s.\n"),
3054*fcf3ce44SJohn Forte 			    argv[path_index]);
3055*fcf3ce44SJohn Forte 			    exit(-1);
3056*fcf3ce44SJohn Forte 			} else {
3057*fcf3ce44SJohn Forte 			    g_dev_map_fini(map_root);
3058*fcf3ce44SJohn Forte 			    (void) print_errString(err, argv[path_index]);
3059*fcf3ce44SJohn Forte 			    exit(-1);
3060*fcf3ce44SJohn Forte 			}
3061*fcf3ce44SJohn Forte 		    }
3062*fcf3ce44SJohn Forte 
3063*fcf3ce44SJohn Forte 		    switch (map_topo) {
3064*fcf3ce44SJohn Forte 		    case FC_TOP_FABRIC:
3065*fcf3ce44SJohn Forte 		    case FC_TOP_PUBLIC_LOOP:
3066*fcf3ce44SJohn Forte 		    case FC_TOP_PT_PT:
3067*fcf3ce44SJohn Forte 			(void) fprintf(stdout,
3068*fcf3ce44SJohn Forte 			MSGSTR(2095, "Pos  Port_ID Hard_Addr Port WWN"
3069*fcf3ce44SJohn Forte 			"         Node WWN         Type\n"));
3070*fcf3ce44SJohn Forte 			while (map_dev) {
3071*fcf3ce44SJohn Forte 			    if ((err = g_dev_prop_lookup_ints(
3072*fcf3ce44SJohn Forte 				map_dev, PORT_ADDR_PROP, &port_addr)) != 0) {
3073*fcf3ce44SJohn Forte 				g_dev_map_fini(map_root);
3074*fcf3ce44SJohn Forte 				(void) print_errString(err, argv[path_index]);
3075*fcf3ce44SJohn Forte 				exit(-1);
3076*fcf3ce44SJohn Forte 			    }
3077*fcf3ce44SJohn Forte 			    if ((err = g_dev_prop_lookup_bytes(map_dev,
3078*fcf3ce44SJohn Forte 				PORT_WWN_PROP, &count, &port_wwn)) != 0) {
3079*fcf3ce44SJohn Forte 				g_dev_map_fini(map_root);
3080*fcf3ce44SJohn Forte 				(void) print_errString(err, argv[path_index]);
3081*fcf3ce44SJohn Forte 				exit(-1);
3082*fcf3ce44SJohn Forte 			    }
3083*fcf3ce44SJohn Forte 			    if ((err = g_dev_prop_lookup_bytes(map_dev,
3084*fcf3ce44SJohn Forte 				NODE_WWN_PROP, &count, &node_wwn)) != 0) {
3085*fcf3ce44SJohn Forte 				g_dev_map_fini(map_root);
3086*fcf3ce44SJohn Forte 				(void) print_errString(err, argv[path_index]);
3087*fcf3ce44SJohn Forte 				exit(-1);
3088*fcf3ce44SJohn Forte 			    }
3089*fcf3ce44SJohn Forte 			    if ((err = g_dev_prop_lookup_ints(
3090*fcf3ce44SJohn Forte 				map_dev, HARD_ADDR_PROP, &hard_addr)) != 0) {
3091*fcf3ce44SJohn Forte 				g_dev_map_fini(map_root);
3092*fcf3ce44SJohn Forte 				(void) print_errString(err, argv[path_index]);
3093*fcf3ce44SJohn Forte 				exit(-1);
3094*fcf3ce44SJohn Forte 			    }
3095*fcf3ce44SJohn Forte 			    print_fabric_prop(pos++, port_wwn,
3096*fcf3ce44SJohn Forte 					node_wwn, *port_addr, *hard_addr);
3097*fcf3ce44SJohn Forte 			    if ((err =  g_dev_prop_lookup_bytes(map_dev,
3098*fcf3ce44SJohn Forte 				INQ_DTYPE_PROP, &count, &dtype_prop)) != 0) {
3099*fcf3ce44SJohn Forte 				(void) fprintf(stdout,
3100*fcf3ce44SJohn Forte 				MSGSTR(2307, " Failed to get the type.\n"));
3101*fcf3ce44SJohn Forte 			    } else {
3102*fcf3ce44SJohn Forte 				print_fabric_dtype_prop(hba_port_wwn, port_wwn,
3103*fcf3ce44SJohn Forte 					*dtype_prop);
3104*fcf3ce44SJohn Forte 			    }
3105*fcf3ce44SJohn Forte 
3106*fcf3ce44SJohn Forte 			    if (((map_dev = g_get_next_dev(
3107*fcf3ce44SJohn Forte 				map_dev, &err)) == NULL) &&
3108*fcf3ce44SJohn Forte 				(err != L_NO_SUCH_DEV_FOUND)) {
3109*fcf3ce44SJohn Forte 				g_dev_map_fini(map_root);
3110*fcf3ce44SJohn Forte 				(void) print_errString(err, argv[path_index]);
3111*fcf3ce44SJohn Forte 				exit(-1);
3112*fcf3ce44SJohn Forte 			    }
3113*fcf3ce44SJohn Forte 			}
3114*fcf3ce44SJohn Forte 			break;
3115*fcf3ce44SJohn Forte 		    case FC_TOP_PRIVATE_LOOP:
3116*fcf3ce44SJohn Forte 			(void) fprintf(stdout,
3117*fcf3ce44SJohn Forte 			MSGSTR(2295,
3118*fcf3ce44SJohn Forte 			"Pos AL_PA ID Hard_Addr "
3119*fcf3ce44SJohn Forte 			"Port WWN         Node WWN         Type\n"));
3120*fcf3ce44SJohn Forte 
3121*fcf3ce44SJohn Forte 			while (map_dev) {
3122*fcf3ce44SJohn Forte 			    if ((err = g_dev_prop_lookup_ints(
3123*fcf3ce44SJohn Forte 				map_dev, PORT_ADDR_PROP, &port_addr)) != 0) {
3124*fcf3ce44SJohn Forte 				g_dev_map_fini(map_root);
3125*fcf3ce44SJohn Forte 				(void) print_errString(err, argv[path_index]);
3126*fcf3ce44SJohn Forte 				exit(-1);
3127*fcf3ce44SJohn Forte 			    }
3128*fcf3ce44SJohn Forte 			    if ((err = g_dev_prop_lookup_bytes(map_dev,
3129*fcf3ce44SJohn Forte 				PORT_WWN_PROP, &count, &port_wwn)) != 0) {
3130*fcf3ce44SJohn Forte 				g_dev_map_fini(map_root);
3131*fcf3ce44SJohn Forte 				(void) print_errString(err, argv[path_index]);
3132*fcf3ce44SJohn Forte 				exit(-1);
3133*fcf3ce44SJohn Forte 			    }
3134*fcf3ce44SJohn Forte 			    if ((err = g_dev_prop_lookup_bytes(map_dev,
3135*fcf3ce44SJohn Forte 				NODE_WWN_PROP, &count, &node_wwn)) != 0) {
3136*fcf3ce44SJohn Forte 				g_dev_map_fini(map_root);
3137*fcf3ce44SJohn Forte 				(void) print_errString(err, argv[path_index]);
3138*fcf3ce44SJohn Forte 				exit(-1);
3139*fcf3ce44SJohn Forte 			    }
3140*fcf3ce44SJohn Forte 			    if ((err = g_dev_prop_lookup_ints(
3141*fcf3ce44SJohn Forte 				map_dev, HARD_ADDR_PROP, &hard_addr)) != 0) {
3142*fcf3ce44SJohn Forte 				g_dev_map_fini(map_root);
3143*fcf3ce44SJohn Forte 				(void) print_errString(err, argv[path_index]);
3144*fcf3ce44SJohn Forte 				exit(-1);
3145*fcf3ce44SJohn Forte 			    }
3146*fcf3ce44SJohn Forte 			    print_private_loop_prop(pos++, port_wwn,
3147*fcf3ce44SJohn Forte 					node_wwn, *port_addr, *hard_addr);
3148*fcf3ce44SJohn Forte 			    if ((err =  g_dev_prop_lookup_bytes(map_dev,
3149*fcf3ce44SJohn Forte 				INQ_DTYPE_PROP, &count, &dtype_prop)) != 0) {
3150*fcf3ce44SJohn Forte 				(void) fprintf(stdout,
3151*fcf3ce44SJohn Forte 				MSGSTR(2307, " Failed to get the type.\n"));
3152*fcf3ce44SJohn Forte 			    } else {
3153*fcf3ce44SJohn Forte 				print_private_loop_dtype_prop(hba_port_wwn,
3154*fcf3ce44SJohn Forte 					port_wwn, *dtype_prop);
3155*fcf3ce44SJohn Forte 			    }
3156*fcf3ce44SJohn Forte 
3157*fcf3ce44SJohn Forte 			    if (((map_dev = g_get_next_dev(
3158*fcf3ce44SJohn Forte 				map_dev, &err)) == NULL) &&
3159*fcf3ce44SJohn Forte 				(err != L_NO_SUCH_DEV_FOUND)) {
3160*fcf3ce44SJohn Forte 				g_dev_map_fini(map_root);
3161*fcf3ce44SJohn Forte 				(void) print_errString(err, argv[path_index]);
3162*fcf3ce44SJohn Forte 				exit(-1);
3163*fcf3ce44SJohn Forte 			    }
3164*fcf3ce44SJohn Forte 			}
3165*fcf3ce44SJohn Forte 			break;
3166*fcf3ce44SJohn Forte 		    default:
3167*fcf3ce44SJohn Forte 			(void) print_errString(L_UNEXPECTED_FC_TOPOLOGY,
3168*fcf3ce44SJohn Forte 			argv[path_index]);
3169*fcf3ce44SJohn Forte 			exit(-1);
3170*fcf3ce44SJohn Forte 		    }
3171*fcf3ce44SJohn Forte 		    g_dev_map_fini(map_root);
3172*fcf3ce44SJohn Forte 		}
3173*fcf3ce44SJohn Forte 		limited_map_flag = 0;
3174*fcf3ce44SJohn Forte 		path_index++;
3175*fcf3ce44SJohn Forte 	}
3176*fcf3ce44SJohn Forte }
3177*fcf3ce44SJohn Forte 
3178*fcf3ce44SJohn Forte /*
3179*fcf3ce44SJohn Forte  * Gets a list of non-SENA fcal devices
3180*fcf3ce44SJohn Forte  * found on the system.
3181*fcf3ce44SJohn Forte  *
3182*fcf3ce44SJohn Forte  * OUTPUT:
3183*fcf3ce44SJohn Forte  *	wwn_list pointer
3184*fcf3ce44SJohn Forte  *			NULL: No non-enclosure devices found.
3185*fcf3ce44SJohn Forte  *			!NULL: Devices found
3186*fcf3ce44SJohn Forte  *                      wwn_list points to a linked list of wwn's.
3187*fcf3ce44SJohn Forte  * RETURNS:
3188*fcf3ce44SJohn Forte  *	0	O.K.
3189*fcf3ce44SJohn Forte  */
3190*fcf3ce44SJohn Forte int
3191*fcf3ce44SJohn Forte n_get_non_encl_list(WWN_list **wwn_list_ptr, int verbose)
3192*fcf3ce44SJohn Forte {
3193*fcf3ce44SJohn Forte int		i, j, k, err, found_ib = 0, pathcnt = 1;
3194*fcf3ce44SJohn Forte WWN_list	*wwn_list;
3195*fcf3ce44SJohn Forte Box_list	*b_list = NULL;
3196*fcf3ce44SJohn Forte gfc_map_t	map;
3197*fcf3ce44SJohn Forte uchar_t		box_id;
3198*fcf3ce44SJohn Forte gfc_port_dev_info_t	*dev_addr_list;
3199*fcf3ce44SJohn Forte char		phci_path[MAXPATHLEN], oldphci_path[MAXPATHLEN];
3200*fcf3ce44SJohn Forte mp_pathlist_t	pathlist;
3201*fcf3ce44SJohn Forte 
3202*fcf3ce44SJohn Forte 
3203*fcf3ce44SJohn Forte 	/*
3204*fcf3ce44SJohn Forte 	 * Only interested in devices that are not part of
3205*fcf3ce44SJohn Forte 	 * a Photon enclosure.
3206*fcf3ce44SJohn Forte 	 */
3207*fcf3ce44SJohn Forte 	if ((err = l_get_box_list(&b_list, verbose)) != 0) {
3208*fcf3ce44SJohn Forte 		return (err);	/* Failure */
3209*fcf3ce44SJohn Forte 	}
3210*fcf3ce44SJohn Forte 
3211*fcf3ce44SJohn Forte 	if (err = g_get_wwn_list(&wwn_list, verbose)) {
3212*fcf3ce44SJohn Forte 		(void) l_free_box_list(&b_list);
3213*fcf3ce44SJohn Forte 		return (err);
3214*fcf3ce44SJohn Forte 	}
3215*fcf3ce44SJohn Forte 
3216*fcf3ce44SJohn Forte 	while (b_list != NULL) {
3217*fcf3ce44SJohn Forte 
3218*fcf3ce44SJohn Forte 		pathcnt = 1;
3219*fcf3ce44SJohn Forte 		if (strstr(b_list->b_physical_path, SCSI_VHCI) != NULL) {
3220*fcf3ce44SJohn Forte 			(void) strcpy(phci_path, b_list->b_physical_path);
3221*fcf3ce44SJohn Forte 			if (err = g_get_pathlist(phci_path, &pathlist)) {
3222*fcf3ce44SJohn Forte 				(void) print_errString(err, NULL);
3223*fcf3ce44SJohn Forte 				exit(-1);
3224*fcf3ce44SJohn Forte 			}
3225*fcf3ce44SJohn Forte 			pathcnt = pathlist.path_count;
3226*fcf3ce44SJohn Forte 		}
3227*fcf3ce44SJohn Forte 
3228*fcf3ce44SJohn Forte 		for (k = 0; k < pathcnt; k++) {
3229*fcf3ce44SJohn Forte 
3230*fcf3ce44SJohn Forte 		if ((k > 0) && (strstr(oldphci_path,
3231*fcf3ce44SJohn Forte 			pathlist.path_info[k].path_hba))) {
3232*fcf3ce44SJohn Forte 				continue;
3233*fcf3ce44SJohn Forte 		}
3234*fcf3ce44SJohn Forte 
3235*fcf3ce44SJohn Forte 		if (strstr(b_list->b_physical_path, SCSI_VHCI) == NULL) {
3236*fcf3ce44SJohn Forte 			if ((err = g_get_dev_map(b_list->b_physical_path,
3237*fcf3ce44SJohn Forte 				&map, verbose)) != 0) {
3238*fcf3ce44SJohn Forte 				(void) g_free_wwn_list(&wwn_list);
3239*fcf3ce44SJohn Forte 				(void) l_free_box_list(&b_list);
3240*fcf3ce44SJohn Forte 				return (err);
3241*fcf3ce44SJohn Forte 			}
3242*fcf3ce44SJohn Forte 		} else {
3243*fcf3ce44SJohn Forte 			(void) strcpy(phci_path,
3244*fcf3ce44SJohn Forte 				pathlist.path_info[k].path_hba);
3245*fcf3ce44SJohn Forte 			(void) strcpy(oldphci_path, phci_path);
3246*fcf3ce44SJohn Forte 			(void) strcat(phci_path, FC_CTLR);
3247*fcf3ce44SJohn Forte 			if (g_get_dev_map(phci_path, &map, verbose)) {
3248*fcf3ce44SJohn Forte 				continue;
3249*fcf3ce44SJohn Forte 			}
3250*fcf3ce44SJohn Forte 			if (pathcnt == 1) {
3251*fcf3ce44SJohn Forte 				free(pathlist.path_info);
3252*fcf3ce44SJohn Forte 			}
3253*fcf3ce44SJohn Forte 		}
3254*fcf3ce44SJohn Forte 
3255*fcf3ce44SJohn Forte 
3256*fcf3ce44SJohn Forte 		switch (map.hba_addr.port_topology) {
3257*fcf3ce44SJohn Forte 		case FC_TOP_FABRIC:
3258*fcf3ce44SJohn Forte 		case FC_TOP_PUBLIC_LOOP:
3259*fcf3ce44SJohn Forte 
3260*fcf3ce44SJohn Forte 			for (i = 0, dev_addr_list = map.dev_addr;
3261*fcf3ce44SJohn Forte 				i < map.count; i++, dev_addr_list++) {
3262*fcf3ce44SJohn Forte 				for (found_ib = 1, j = 0; j < WWN_SIZE;
3263*fcf3ce44SJohn Forte 					j++) {
3264*fcf3ce44SJohn Forte 					if (b_list->b_node_wwn[j] !=
3265*fcf3ce44SJohn Forte 						dev_addr_list->gfc_port_dev.
3266*fcf3ce44SJohn Forte 						pub_port.dev_nwwn.raw_wwn[j]) {
3267*fcf3ce44SJohn Forte 						found_ib = 0;
3268*fcf3ce44SJohn Forte 					}
3269*fcf3ce44SJohn Forte 				}
3270*fcf3ce44SJohn Forte 				if (found_ib) {
3271*fcf3ce44SJohn Forte 					(void) n_rem_list_entry_fabric(
3272*fcf3ce44SJohn Forte 					dev_addr_list->gfc_port_dev.
3273*fcf3ce44SJohn Forte 					pub_port.dev_did.port_id, &map,
3274*fcf3ce44SJohn Forte 					&wwn_list);
3275*fcf3ce44SJohn Forte 				}
3276*fcf3ce44SJohn Forte 			}
3277*fcf3ce44SJohn Forte 			break;
3278*fcf3ce44SJohn Forte 
3279*fcf3ce44SJohn Forte 		case FC_TOP_PRIVATE_LOOP:
3280*fcf3ce44SJohn Forte 
3281*fcf3ce44SJohn Forte 			for (i = 0, dev_addr_list = map.dev_addr;
3282*fcf3ce44SJohn Forte 				i < map.count; i++, dev_addr_list++) {
3283*fcf3ce44SJohn Forte 				for (found_ib = 1, j = 0; j < WWN_SIZE;
3284*fcf3ce44SJohn Forte 					j++) {
3285*fcf3ce44SJohn Forte 					if (b_list->b_node_wwn[j] !=
3286*fcf3ce44SJohn Forte 						dev_addr_list->gfc_port_dev.
3287*fcf3ce44SJohn Forte 						priv_port.sf_node_wwn[j]) {
3288*fcf3ce44SJohn Forte 							found_ib = 0;
3289*fcf3ce44SJohn Forte 					}
3290*fcf3ce44SJohn Forte 				}
3291*fcf3ce44SJohn Forte 				if (found_ib) {
3292*fcf3ce44SJohn Forte 					box_id = g_sf_alpa_to_switch
3293*fcf3ce44SJohn Forte 						[dev_addr_list->gfc_port_dev.
3294*fcf3ce44SJohn Forte 						priv_port.sf_al_pa] &
3295*fcf3ce44SJohn Forte 						BOX_ID_MASK;
3296*fcf3ce44SJohn Forte 					/* This function has been added */
3297*fcf3ce44SJohn Forte 					/* here only to keep from having */
3298*fcf3ce44SJohn Forte 					/* to tab over farther */
3299*fcf3ce44SJohn Forte 					(void) n_rem_list_entry(box_id, &map,
3300*fcf3ce44SJohn Forte 						&wwn_list);
3301*fcf3ce44SJohn Forte 					if (wwn_list == NULL) {
3302*fcf3ce44SJohn Forte 						/* Return the list */
3303*fcf3ce44SJohn Forte 						*wwn_list_ptr = NULL;
3304*fcf3ce44SJohn Forte 						break;
3305*fcf3ce44SJohn Forte 					}
3306*fcf3ce44SJohn Forte 				}
3307*fcf3ce44SJohn Forte 			}
3308*fcf3ce44SJohn Forte 			break;
3309*fcf3ce44SJohn Forte 		case FC_TOP_PT_PT:
3310*fcf3ce44SJohn Forte 			(void) free((void *)map.dev_addr);
3311*fcf3ce44SJohn Forte 			return (L_PT_PT_FC_TOP_NOT_SUPPORTED);
3312*fcf3ce44SJohn Forte 		default:
3313*fcf3ce44SJohn Forte 			(void) free((void *)map.dev_addr);
3314*fcf3ce44SJohn Forte 			return (L_UNEXPECTED_FC_TOPOLOGY);
3315*fcf3ce44SJohn Forte 		}
3316*fcf3ce44SJohn Forte 		free((void *)map.dev_addr);
3317*fcf3ce44SJohn Forte 
3318*fcf3ce44SJohn Forte 		}
3319*fcf3ce44SJohn Forte 		if (pathcnt > 1) {
3320*fcf3ce44SJohn Forte 			free(pathlist.path_info);
3321*fcf3ce44SJohn Forte 		}
3322*fcf3ce44SJohn Forte 
3323*fcf3ce44SJohn Forte 		b_list = b_list->box_next;
3324*fcf3ce44SJohn Forte 	}
3325*fcf3ce44SJohn Forte 	/* Return the list */
3326*fcf3ce44SJohn Forte 	*wwn_list_ptr = wwn_list;
3327*fcf3ce44SJohn Forte 	(void) l_free_box_list(&b_list);
3328*fcf3ce44SJohn Forte 	return (0);
3329*fcf3ce44SJohn Forte }
3330*fcf3ce44SJohn Forte 
3331*fcf3ce44SJohn Forte 
3332*fcf3ce44SJohn Forte 
3333*fcf3ce44SJohn Forte /*
3334*fcf3ce44SJohn Forte  * n_rem_list_entry() We found an IB so remove disks that
3335*fcf3ce44SJohn Forte  * are in the Photon from the individual device list.
3336*fcf3ce44SJohn Forte  *
3337*fcf3ce44SJohn Forte  * OUTPUT:
3338*fcf3ce44SJohn Forte  *	wwn_list - removes the fcal disks that are in SENA enclosure
3339*fcf3ce44SJohn Forte  *
3340*fcf3ce44SJohn Forte  * RETURNS:
3341*fcf3ce44SJohn Forte  *	none
3342*fcf3ce44SJohn Forte  */
3343*fcf3ce44SJohn Forte void
3344*fcf3ce44SJohn Forte n_rem_list_entry(uchar_t box_id,  struct gfc_map *map,
3345*fcf3ce44SJohn Forte 	struct	wwn_list_struct **wwn_list)
3346*fcf3ce44SJohn Forte {
3347*fcf3ce44SJohn Forte int		k;
3348*fcf3ce44SJohn Forte gfc_port_dev_info_t	*dev_addr_list;
3349*fcf3ce44SJohn Forte 
3350*fcf3ce44SJohn Forte 	N_DPRINTF("  n_rem_list_entry: Removing devices"
3351*fcf3ce44SJohn Forte 		" with box_id=0x%x from device list.\n", box_id);
3352*fcf3ce44SJohn Forte 
3353*fcf3ce44SJohn Forte 
3354*fcf3ce44SJohn Forte 		for (k = 0, dev_addr_list = map->dev_addr; k < map->count;
3355*fcf3ce44SJohn Forte 			k++, dev_addr_list++) {
3356*fcf3ce44SJohn Forte 			if ((g_sf_alpa_to_switch[dev_addr_list->gfc_port_dev.
3357*fcf3ce44SJohn Forte 				priv_port.sf_hard_address] & BOX_ID_MASK)
3358*fcf3ce44SJohn Forte 				== box_id) {
3359*fcf3ce44SJohn Forte 				n_rem_wwn_entry(dev_addr_list->gfc_port_dev.
3360*fcf3ce44SJohn Forte 					priv_port.sf_node_wwn, wwn_list);
3361*fcf3ce44SJohn Forte 			}
3362*fcf3ce44SJohn Forte 		}
3363*fcf3ce44SJohn Forte 
3364*fcf3ce44SJohn Forte }
3365*fcf3ce44SJohn Forte 
3366*fcf3ce44SJohn Forte 
3367*fcf3ce44SJohn Forte 
3368*fcf3ce44SJohn Forte /*
3369*fcf3ce44SJohn Forte  * n_rem_list_entry_fabric() We found an IB so remove disks that
3370*fcf3ce44SJohn Forte  * are in the Photon from the individual device list.
3371*fcf3ce44SJohn Forte  *
3372*fcf3ce44SJohn Forte  * OUTPUT:
3373*fcf3ce44SJohn Forte  *	wwn_list - removes the fcal disks that are in SENA enclosure
3374*fcf3ce44SJohn Forte  *
3375*fcf3ce44SJohn Forte  * RETURNS:
3376*fcf3ce44SJohn Forte  *	none
3377*fcf3ce44SJohn Forte  */
3378*fcf3ce44SJohn Forte void
3379*fcf3ce44SJohn Forte n_rem_list_entry_fabric(int pa,  struct gfc_map *map,
3380*fcf3ce44SJohn Forte 	struct	wwn_list_struct **wwn_list)
3381*fcf3ce44SJohn Forte {
3382*fcf3ce44SJohn Forte int		k;
3383*fcf3ce44SJohn Forte gfc_port_dev_info_t	*dev_addr_ptr;
3384*fcf3ce44SJohn Forte 
3385*fcf3ce44SJohn Forte 	N_DPRINTF("  n_rem_list_entry: Removing devices"
3386*fcf3ce44SJohn Forte 		" with the same domain and area ID as"
3387*fcf3ce44SJohn Forte 		" 0x%x PA from device list.\n", pa);
3388*fcf3ce44SJohn Forte 	for (k = 0, dev_addr_ptr = map->dev_addr; k < map->count;
3389*fcf3ce44SJohn Forte 				k++, dev_addr_ptr++) {
3390*fcf3ce44SJohn Forte 
3391*fcf3ce44SJohn Forte 		/* matching the domain and area id with input alpa, */
3392*fcf3ce44SJohn Forte 		/* ignoring last 8 bits. */
3393*fcf3ce44SJohn Forte 		if ((dev_addr_ptr->gfc_port_dev.pub_port.dev_did.port_id |
3394*fcf3ce44SJohn Forte 				0xff) == (pa | 0xff)) {
3395*fcf3ce44SJohn Forte 			n_rem_wwn_entry(dev_addr_ptr->
3396*fcf3ce44SJohn Forte 				gfc_port_dev.pub_port.dev_nwwn.raw_wwn,
3397*fcf3ce44SJohn Forte 				wwn_list);
3398*fcf3ce44SJohn Forte 		}
3399*fcf3ce44SJohn Forte 	}
3400*fcf3ce44SJohn Forte }
3401*fcf3ce44SJohn Forte 
3402*fcf3ce44SJohn Forte 
3403*fcf3ce44SJohn Forte /*
3404*fcf3ce44SJohn Forte  * n_rem_wwn_entry() removes input wwn from wwn_list.
3405*fcf3ce44SJohn Forte  *
3406*fcf3ce44SJohn Forte  * OUTPUT:
3407*fcf3ce44SJohn Forte  *	wwn_list - removes the input wwn from wwn_list if found.
3408*fcf3ce44SJohn Forte  *
3409*fcf3ce44SJohn Forte  * RETURNS:
3410*fcf3ce44SJohn Forte  *	none
3411*fcf3ce44SJohn Forte  */
3412*fcf3ce44SJohn Forte void
3413*fcf3ce44SJohn Forte n_rem_wwn_entry(uchar_t node_wwn[], struct  wwn_list_struct **wwn_list)
3414*fcf3ce44SJohn Forte {
3415*fcf3ce44SJohn Forte int		l, found_dev;
3416*fcf3ce44SJohn Forte WWN_list	*inner, *l1;
3417*fcf3ce44SJohn Forte 
3418*fcf3ce44SJohn Forte 	inner = *wwn_list;
3419*fcf3ce44SJohn Forte 	while (inner != NULL) {
3420*fcf3ce44SJohn Forte 		for (found_dev = 1, l = 0; l < WWN_SIZE; l++) {
3421*fcf3ce44SJohn Forte 			if (inner->w_node_wwn[l] != node_wwn[l]) {
3422*fcf3ce44SJohn Forte 				found_dev = 0;
3423*fcf3ce44SJohn Forte 			}
3424*fcf3ce44SJohn Forte 		}
3425*fcf3ce44SJohn Forte 		if (found_dev) {
3426*fcf3ce44SJohn Forte 			/* Remove this entry from the list */
3427*fcf3ce44SJohn Forte 			if (inner->wwn_prev != NULL) {
3428*fcf3ce44SJohn Forte 				inner->wwn_prev->wwn_next =
3429*fcf3ce44SJohn Forte 					inner->wwn_next;
3430*fcf3ce44SJohn Forte 			} else {
3431*fcf3ce44SJohn Forte 				*wwn_list = inner->wwn_next;
3432*fcf3ce44SJohn Forte 			}
3433*fcf3ce44SJohn Forte 			if (inner->wwn_next != NULL) {
3434*fcf3ce44SJohn Forte 				inner->wwn_next->wwn_prev =
3435*fcf3ce44SJohn Forte 					inner->wwn_prev;
3436*fcf3ce44SJohn Forte 			}
3437*fcf3ce44SJohn Forte 			l1 = inner;
3438*fcf3ce44SJohn Forte 			N_DPRINTF("  n_rem_wwn_entry: "
3439*fcf3ce44SJohn Forte 				"Removing Logical=%s "
3440*fcf3ce44SJohn Forte 				"Current=0x%x, "
3441*fcf3ce44SJohn Forte 				"Prev=0x%x, Next=0x%x\n",
3442*fcf3ce44SJohn Forte 				l1->logical_path,
3443*fcf3ce44SJohn Forte 				l1,
3444*fcf3ce44SJohn Forte 				l1->wwn_prev,
3445*fcf3ce44SJohn Forte 				l1->wwn_next);
3446*fcf3ce44SJohn Forte 			inner = inner->wwn_next;
3447*fcf3ce44SJohn Forte 			if ((l1->wwn_prev == NULL) &&
3448*fcf3ce44SJohn Forte 				(l1->wwn_next) == NULL) {
3449*fcf3ce44SJohn Forte 				(void) free(l1->physical_path);
3450*fcf3ce44SJohn Forte 				(void) free(l1->logical_path);
3451*fcf3ce44SJohn Forte 				(void) free(l1);
3452*fcf3ce44SJohn Forte 				*wwn_list = NULL;
3453*fcf3ce44SJohn Forte 				N_DPRINTF("  n_rem_list_entry: "
3454*fcf3ce44SJohn Forte 				"No non-Photon "
3455*fcf3ce44SJohn Forte 				"devices left"
3456*fcf3ce44SJohn Forte 				" in the list.\n");
3457*fcf3ce44SJohn Forte 				return;
3458*fcf3ce44SJohn Forte 			}
3459*fcf3ce44SJohn Forte 				(void) free(l1->physical_path);
3460*fcf3ce44SJohn Forte 				(void) free(l1->logical_path);
3461*fcf3ce44SJohn Forte 				(void) free(l1);
3462*fcf3ce44SJohn Forte 		} else {
3463*fcf3ce44SJohn Forte 			inner = inner->wwn_next;
3464*fcf3ce44SJohn Forte 		}
3465*fcf3ce44SJohn Forte 	}
3466*fcf3ce44SJohn Forte }
3467*fcf3ce44SJohn Forte 
3468*fcf3ce44SJohn Forte 
3469*fcf3ce44SJohn Forte /*
3470*fcf3ce44SJohn Forte  * non_encl_probe() Finds and displays a list of
3471*fcf3ce44SJohn Forte  * non-SENA fcal devices which is found on the
3472*fcf3ce44SJohn Forte  * system.
3473*fcf3ce44SJohn Forte  *
3474*fcf3ce44SJohn Forte  * RETURNS:
3475*fcf3ce44SJohn Forte  *	none.
3476*fcf3ce44SJohn Forte  */
3477*fcf3ce44SJohn Forte void
3478*fcf3ce44SJohn Forte non_encl_probe()
3479*fcf3ce44SJohn Forte {
3480*fcf3ce44SJohn Forte WWN_list	*wwn_list, *wwn_listh, *inner, *l1;
3481*fcf3ce44SJohn Forte int		err = 0;
3482*fcf3ce44SJohn Forte char		lun_a[MAXPATHLEN], lun_b[MAXPATHLEN], temppath[MAXPATHLEN];
3483*fcf3ce44SJohn Forte char		*tempptra, *tempptrb, *tempptr;
3484*fcf3ce44SJohn Forte mp_pathlist_t	pathlist;
3485*fcf3ce44SJohn Forte int		compare_result, retr_outer = 0;
3486*fcf3ce44SJohn Forte ddi_devid_t	devid1 = NULL, devid2 = NULL;
3487*fcf3ce44SJohn Forte di_node_t	root = DI_NODE_NIL;
3488*fcf3ce44SJohn Forte 
3489*fcf3ce44SJohn Forte 	if (err = n_get_non_encl_list(&wwn_list, (Options & PVERBOSE))) {
3490*fcf3ce44SJohn Forte 		(void) print_errString(err, NULL);
3491*fcf3ce44SJohn Forte 		exit(-1);
3492*fcf3ce44SJohn Forte 	}
3493*fcf3ce44SJohn Forte 
3494*fcf3ce44SJohn Forte 	g_sort_wwn_list(&wwn_list);
3495*fcf3ce44SJohn Forte 
3496*fcf3ce44SJohn Forte 	wwn_listh = wwn_list;
3497*fcf3ce44SJohn Forte 
3498*fcf3ce44SJohn Forte 	if (wwn_list != NULL) {
3499*fcf3ce44SJohn Forte 		if (wwn_list->wwn_next != NULL) {
3500*fcf3ce44SJohn Forte 			(void) fprintf(stdout,
3501*fcf3ce44SJohn Forte 			    MSGSTR(2098, "\nFound Fibre Channel device(s):\n"));
3502*fcf3ce44SJohn Forte 		} else {
3503*fcf3ce44SJohn Forte 			(void) fprintf(stdout,
3504*fcf3ce44SJohn Forte 			    MSGSTR(2099, "\nFound Fibre Channel device:\n"));
3505*fcf3ce44SJohn Forte 		}
3506*fcf3ce44SJohn Forte 	} else {
3507*fcf3ce44SJohn Forte 		return;
3508*fcf3ce44SJohn Forte 	}
3509*fcf3ce44SJohn Forte 
3510*fcf3ce44SJohn Forte 	while (wwn_list != NULL) {
3511*fcf3ce44SJohn Forte 	    if (strstr(wwn_list->physical_path, SCSI_VHCI) != NULL) {
3512*fcf3ce44SJohn Forte 		(void) strcpy(temppath, wwn_list->physical_path);
3513*fcf3ce44SJohn Forte 		if ((!g_get_pathlist(temppath,
3514*fcf3ce44SJohn Forte 		    &pathlist)) &&
3515*fcf3ce44SJohn Forte 		    ((tempptra = strchr(pathlist.path_info[0].
3516*fcf3ce44SJohn Forte 		    path_addr, ','))) != NULL) {
3517*fcf3ce44SJohn Forte 			tempptra++;
3518*fcf3ce44SJohn Forte 			(void) strcpy(lun_a, tempptra);
3519*fcf3ce44SJohn Forte 			free(pathlist.path_info);
3520*fcf3ce44SJohn Forte 		}
3521*fcf3ce44SJohn Forte 	    } else {
3522*fcf3ce44SJohn Forte 		if ((((tempptr = strstr(wwn_list->physical_path,
3523*fcf3ce44SJohn Forte 		    SLSH_DRV_NAME_ST)) != NULL) ||
3524*fcf3ce44SJohn Forte 		    ((tempptr = strstr(wwn_list->physical_path,
3525*fcf3ce44SJohn Forte 		    SLSH_DRV_NAME_SSD)) != NULL)) &&
3526*fcf3ce44SJohn Forte 		    ((tempptra = strchr(tempptr, ',')) != NULL)) {
3527*fcf3ce44SJohn Forte 			tempptra++;
3528*fcf3ce44SJohn Forte 			(void) strcpy(lun_a, tempptra);
3529*fcf3ce44SJohn Forte 		}
3530*fcf3ce44SJohn Forte 	    }
3531*fcf3ce44SJohn Forte 	    (void) fprintf(stdout, "  ");
3532*fcf3ce44SJohn Forte 	    (void) fprintf(stdout, MSGSTR(90, "Node WWN:"));
3533*fcf3ce44SJohn Forte 	    (void) fprintf(stdout, "%s  ", wwn_list->node_wwn_s);
3534*fcf3ce44SJohn Forte 
3535*fcf3ce44SJohn Forte 	    if (wwn_list->device_type < 0x10) {
3536*fcf3ce44SJohn Forte 		(void) fprintf(stdout, MSGSTR(35, "Device Type:"));
3537*fcf3ce44SJohn Forte 		(void) fprintf(stdout, "%s",
3538*fcf3ce44SJohn Forte 		dtype[wwn_list->device_type]);
3539*fcf3ce44SJohn Forte 	    } else if (wwn_list->device_type < 0x1f) {
3540*fcf3ce44SJohn Forte 			(void) fprintf(stdout, MSGSTR(2100,
3541*fcf3ce44SJohn Forte 			"Type:Reserved"));
3542*fcf3ce44SJohn Forte 	    } else {
3543*fcf3ce44SJohn Forte 			(void) fprintf(stdout, MSGSTR(2101,
3544*fcf3ce44SJohn Forte 			"Type:Unknown"));
3545*fcf3ce44SJohn Forte 	    }
3546*fcf3ce44SJohn Forte 	    (void) fprintf(stdout, "\n    ");
3547*fcf3ce44SJohn Forte 	    (void) fprintf(stdout, MSGSTR(31, "Logical Path:%s"),
3548*fcf3ce44SJohn Forte 			wwn_list->logical_path);
3549*fcf3ce44SJohn Forte 	    (void) fprintf(stdout, "\n");
3550*fcf3ce44SJohn Forte 
3551*fcf3ce44SJohn Forte 	    if (Options & OPTION_P) {
3552*fcf3ce44SJohn Forte 		(void) fprintf(stdout, "    ");
3553*fcf3ce44SJohn Forte 		(void) fprintf(stdout,
3554*fcf3ce44SJohn Forte 		MSGSTR(5, "Physical Path:"));
3555*fcf3ce44SJohn Forte 		(void) fprintf(stdout, "\n     %s\n", wwn_list->physical_path);
3556*fcf3ce44SJohn Forte 	    }
3557*fcf3ce44SJohn Forte 	    inner = wwn_list->wwn_next;
3558*fcf3ce44SJohn Forte 
3559*fcf3ce44SJohn Forte 	    while (inner != NULL) {
3560*fcf3ce44SJohn Forte 		if (strcmp(inner->node_wwn_s, wwn_list->node_wwn_s) == 0) {
3561*fcf3ce44SJohn Forte 
3562*fcf3ce44SJohn Forte 		    if (tempptra != NULL) {
3563*fcf3ce44SJohn Forte 			if (strstr(inner->physical_path,
3564*fcf3ce44SJohn Forte 			    SCSI_VHCI) != NULL) {
3565*fcf3ce44SJohn Forte 			    (void) strcpy(temppath,
3566*fcf3ce44SJohn Forte 			    inner->physical_path);
3567*fcf3ce44SJohn Forte 
3568*fcf3ce44SJohn Forte 			    if ((!g_get_pathlist(temppath, &pathlist)) &&
3569*fcf3ce44SJohn Forte 				((tempptrb = strchr(
3570*fcf3ce44SJohn Forte 				pathlist.path_info[0].path_addr, ','))) !=
3571*fcf3ce44SJohn Forte 				    NULL) {
3572*fcf3ce44SJohn Forte 				tempptrb++;
3573*fcf3ce44SJohn Forte 				(void) strcpy(lun_b, tempptrb);
3574*fcf3ce44SJohn Forte 				free(pathlist.path_info);
3575*fcf3ce44SJohn Forte 			    }
3576*fcf3ce44SJohn Forte 			} else {
3577*fcf3ce44SJohn Forte 			    if ((((tempptr = strstr(inner->physical_path,
3578*fcf3ce44SJohn Forte 				SLSH_DRV_NAME_ST)) != NULL) ||
3579*fcf3ce44SJohn Forte 				((tempptr = strstr(inner->physical_path,
3580*fcf3ce44SJohn Forte 				SLSH_DRV_NAME_SSD)) != NULL)) &&
3581*fcf3ce44SJohn Forte 				((tempptrb = strchr(tempptr, ',')) != NULL)) {
3582*fcf3ce44SJohn Forte 				tempptrb++;
3583*fcf3ce44SJohn Forte 				(void) strcpy(lun_b, tempptrb);
3584*fcf3ce44SJohn Forte 			    }
3585*fcf3ce44SJohn Forte 			}
3586*fcf3ce44SJohn Forte 		    }
3587*fcf3ce44SJohn Forte 
3588*fcf3ce44SJohn Forte 		    if (((tempptra == NULL) || (strcmp(lun_a, lun_b)) == 0)) {
3589*fcf3ce44SJohn Forte 
3590*fcf3ce44SJohn Forte 			/*
3591*fcf3ce44SJohn Forte 			 * Have we retrieved a snapshot yet?
3592*fcf3ce44SJohn Forte 			 */
3593*fcf3ce44SJohn Forte 			if (root == DI_NODE_NIL) {
3594*fcf3ce44SJohn Forte 			    if ((root = di_init("/", DINFOCPYALL)) ==
3595*fcf3ce44SJohn Forte 				DI_NODE_NIL) {
3596*fcf3ce44SJohn Forte 				(void) fprintf(stdout,
3597*fcf3ce44SJohn Forte 				    MSGSTR(2319,
3598*fcf3ce44SJohn Forte 				    "\nFailed to get device tree snapshot:\n"));
3599*fcf3ce44SJohn Forte 				exit(1);
3600*fcf3ce44SJohn Forte 			    }
3601*fcf3ce44SJohn Forte 			}
3602*fcf3ce44SJohn Forte 
3603*fcf3ce44SJohn Forte 			/* Apply devid to ssd devices only */
3604*fcf3ce44SJohn Forte 			if (!retr_outer && strstr(wwn_list->physical_path,
3605*fcf3ce44SJohn Forte 			    SLSH_DRV_NAME_SSD) != NULL) {
3606*fcf3ce44SJohn Forte 			    if ((err = g_devid_get(wwn_list->physical_path,
3607*fcf3ce44SJohn Forte 				&devid1, root, SSD_DRVR_NAME)) != 0) {
3608*fcf3ce44SJohn Forte 				(void) print_errString(err,
3609*fcf3ce44SJohn Forte 				    wwn_list->physical_path);
3610*fcf3ce44SJohn Forte 			    }
3611*fcf3ce44SJohn Forte 			/*
3612*fcf3ce44SJohn Forte 			 * Try retrieve of devid only once. If it fails
3613*fcf3ce44SJohn Forte 			 * don't try it again but print error,
3614*fcf3ce44SJohn Forte 			 * There should be a devid prop.
3615*fcf3ce44SJohn Forte 			 */
3616*fcf3ce44SJohn Forte 			    retr_outer = 1;
3617*fcf3ce44SJohn Forte 			}
3618*fcf3ce44SJohn Forte 			/*
3619*fcf3ce44SJohn Forte 			 * Apply devid to block devices only.
3620*fcf3ce44SJohn Forte 			 * Get devid of inner path and compare
3621*fcf3ce44SJohn Forte 			 * with outer path's devid.
3622*fcf3ce44SJohn Forte 			 */
3623*fcf3ce44SJohn Forte 			if ((strstr(inner->physical_path,
3624*fcf3ce44SJohn Forte 			    SLSH_DRV_NAME_SSD) != NULL) &&
3625*fcf3ce44SJohn Forte 			    devid1 != NULL) {
3626*fcf3ce44SJohn Forte 
3627*fcf3ce44SJohn Forte 			    if ((err = g_devid_get(inner->physical_path,
3628*fcf3ce44SJohn Forte 				&devid2, root, SSD_DRVR_NAME)) != 0) {
3629*fcf3ce44SJohn Forte 
3630*fcf3ce44SJohn Forte 				(void) print_errString(err,
3631*fcf3ce44SJohn Forte 				    inner->physical_path);
3632*fcf3ce44SJohn Forte 				compare_result = 0;
3633*fcf3ce44SJohn Forte 			    } else {
3634*fcf3ce44SJohn Forte 				compare_result = devid_compare(devid1, devid2);
3635*fcf3ce44SJohn Forte 			    }
3636*fcf3ce44SJohn Forte 			} else {
3637*fcf3ce44SJohn Forte 			    /* devid isn't applied */
3638*fcf3ce44SJohn Forte 			    compare_result = 0;
3639*fcf3ce44SJohn Forte 			}
3640*fcf3ce44SJohn Forte 
3641*fcf3ce44SJohn Forte 			if (compare_result == 0) {
3642*fcf3ce44SJohn Forte 
3643*fcf3ce44SJohn Forte 			    if (strcmp(wwn_list->logical_path,
3644*fcf3ce44SJohn Forte 				inner->logical_path)) {
3645*fcf3ce44SJohn Forte 				(void) fprintf(stdout, "    ");
3646*fcf3ce44SJohn Forte 				(void) fprintf(stdout,
3647*fcf3ce44SJohn Forte 				    MSGSTR(31, "Logical Path:%s"),
3648*fcf3ce44SJohn Forte 					inner->logical_path);
3649*fcf3ce44SJohn Forte 				(void) fprintf(stdout, "\n");
3650*fcf3ce44SJohn Forte 
3651*fcf3ce44SJohn Forte 				if (Options & OPTION_P) {
3652*fcf3ce44SJohn Forte 				    (void) fprintf(stdout, "    ");
3653*fcf3ce44SJohn Forte 				    (void) fprintf(stdout, MSGSTR(5,
3654*fcf3ce44SJohn Forte 					"Physical Path:"));
3655*fcf3ce44SJohn Forte 				    (void) fprintf(stdout, "\n     %s\n",
3656*fcf3ce44SJohn Forte 					inner->physical_path);
3657*fcf3ce44SJohn Forte 				}
3658*fcf3ce44SJohn Forte 			    }
3659*fcf3ce44SJohn Forte 
3660*fcf3ce44SJohn Forte 			    /* Remove this entry from the list */
3661*fcf3ce44SJohn Forte 			    if (inner->wwn_prev != NULL) {
3662*fcf3ce44SJohn Forte 				inner->wwn_prev->wwn_next =
3663*fcf3ce44SJohn Forte 				inner->wwn_next;
3664*fcf3ce44SJohn Forte 			    }
3665*fcf3ce44SJohn Forte 
3666*fcf3ce44SJohn Forte 			    if (inner->wwn_next != NULL) {
3667*fcf3ce44SJohn Forte 				inner->wwn_next->wwn_prev =
3668*fcf3ce44SJohn Forte 				inner->wwn_prev;
3669*fcf3ce44SJohn Forte 			    }
3670*fcf3ce44SJohn Forte 			    free(inner->physical_path);
3671*fcf3ce44SJohn Forte 			    free(inner->logical_path);
3672*fcf3ce44SJohn Forte 			    l1 = inner;
3673*fcf3ce44SJohn Forte 			    inner = inner->wwn_next;
3674*fcf3ce44SJohn Forte 			    (void) free(l1);
3675*fcf3ce44SJohn Forte 
3676*fcf3ce44SJohn Forte 			} else {
3677*fcf3ce44SJohn Forte 			    inner = inner->wwn_next;
3678*fcf3ce44SJohn Forte 			} /* End if (compare_result == 0) */
3679*fcf3ce44SJohn Forte 
3680*fcf3ce44SJohn Forte 		    } else {
3681*fcf3ce44SJohn Forte 			inner = inner->wwn_next;
3682*fcf3ce44SJohn Forte 		    }
3683*fcf3ce44SJohn Forte 		} else {
3684*fcf3ce44SJohn Forte 		    inner = inner->wwn_next;
3685*fcf3ce44SJohn Forte 		}
3686*fcf3ce44SJohn Forte 		devid2 = NULL;
3687*fcf3ce44SJohn Forte 	    }
3688*fcf3ce44SJohn Forte 	    wwn_list = wwn_list->wwn_next;
3689*fcf3ce44SJohn Forte 	    retr_outer = 0;
3690*fcf3ce44SJohn Forte 	    devid1 = NULL;
3691*fcf3ce44SJohn Forte 	} /* End while (wwn_list != NULL) */
3692*fcf3ce44SJohn Forte 
3693*fcf3ce44SJohn Forte 	(void) g_free_wwn_list(&wwn_listh);
3694*fcf3ce44SJohn Forte 	(void) di_fini(root);
3695*fcf3ce44SJohn Forte }
3696*fcf3ce44SJohn Forte 
3697*fcf3ce44SJohn Forte void
3698*fcf3ce44SJohn Forte pho_probe()
3699*fcf3ce44SJohn Forte {
3700*fcf3ce44SJohn Forte 
3701*fcf3ce44SJohn Forte Box_list	*b_list, *o_list, *c_list;
3702*fcf3ce44SJohn Forte int		multi_path_flag, multi_print_flag;
3703*fcf3ce44SJohn Forte int		duplicate_names_found = 0, err = 0;
3704*fcf3ce44SJohn Forte 
3705*fcf3ce44SJohn Forte 	b_list = o_list = c_list = NULL;
3706*fcf3ce44SJohn Forte 	if ((err = l_get_box_list(&b_list, Options & PVERBOSE)) != 0) {
3707*fcf3ce44SJohn Forte 		(void) print_errString(err, NULL);
3708*fcf3ce44SJohn Forte 		exit(-1);
3709*fcf3ce44SJohn Forte 	}
3710*fcf3ce44SJohn Forte 	if (b_list == NULL) {
3711*fcf3ce44SJohn Forte 		(void) fprintf(stdout,
3712*fcf3ce44SJohn Forte 			MSGSTR(93, "No %s enclosures found "
3713*fcf3ce44SJohn Forte 			"in /dev/es\n"), ENCLOSURE_PROD_NAME);
3714*fcf3ce44SJohn Forte 	} else {
3715*fcf3ce44SJohn Forte 		o_list = b_list;
3716*fcf3ce44SJohn Forte 		if (b_list->box_next != NULL) {
3717*fcf3ce44SJohn Forte 			(void) fprintf(stdout, MSGSTR(2102,
3718*fcf3ce44SJohn Forte 				"Found Enclosure(s)"));
3719*fcf3ce44SJohn Forte 		} else {
3720*fcf3ce44SJohn Forte 			(void) fprintf(stdout, MSGSTR(2103, "Found Enclosure"));
3721*fcf3ce44SJohn Forte 		}
3722*fcf3ce44SJohn Forte 		(void) fprintf(stdout, ":\n");
3723*fcf3ce44SJohn Forte 		while (b_list != NULL) {
3724*fcf3ce44SJohn Forte 			/* Don't re-print multiple paths */
3725*fcf3ce44SJohn Forte 			c_list = o_list;
3726*fcf3ce44SJohn Forte 			multi_print_flag = 0;
3727*fcf3ce44SJohn Forte 			while (c_list != b_list) {
3728*fcf3ce44SJohn Forte 				if (strcmp(c_list->b_node_wwn_s,
3729*fcf3ce44SJohn Forte 					b_list->b_node_wwn_s) == 0) {
3730*fcf3ce44SJohn Forte 					multi_print_flag = 1;
3731*fcf3ce44SJohn Forte 					break;
3732*fcf3ce44SJohn Forte 				}
3733*fcf3ce44SJohn Forte 				c_list = c_list->box_next;
3734*fcf3ce44SJohn Forte 			}
3735*fcf3ce44SJohn Forte 			if (multi_print_flag) {
3736*fcf3ce44SJohn Forte 				b_list = b_list->box_next;
3737*fcf3ce44SJohn Forte 				continue;
3738*fcf3ce44SJohn Forte 			}
3739*fcf3ce44SJohn Forte 			(void) fprintf(stdout,
3740*fcf3ce44SJohn Forte 			MSGSTR(2104, "%s   Name:%s   Node WWN:%s   "),
3741*fcf3ce44SJohn Forte 			b_list->prod_id_s, b_list->b_name,
3742*fcf3ce44SJohn Forte 				b_list->b_node_wwn_s);
3743*fcf3ce44SJohn Forte 			/*
3744*fcf3ce44SJohn Forte 			 * Print logical path on same line if not multipathed.
3745*fcf3ce44SJohn Forte 			 */
3746*fcf3ce44SJohn Forte 			multi_path_flag = 0;
3747*fcf3ce44SJohn Forte 			c_list = o_list;
3748*fcf3ce44SJohn Forte 			while (c_list != NULL) {
3749*fcf3ce44SJohn Forte 				if ((c_list != b_list) &&
3750*fcf3ce44SJohn Forte 					(strcmp(c_list->b_node_wwn_s,
3751*fcf3ce44SJohn Forte 					b_list->b_node_wwn_s) == 0)) {
3752*fcf3ce44SJohn Forte 					multi_path_flag = 1;
3753*fcf3ce44SJohn Forte 				}
3754*fcf3ce44SJohn Forte 				c_list = c_list->box_next;
3755*fcf3ce44SJohn Forte 			}
3756*fcf3ce44SJohn Forte 			if (multi_path_flag) {
3757*fcf3ce44SJohn Forte 				(void) fprintf(stdout, "\n  ");
3758*fcf3ce44SJohn Forte 			}
3759*fcf3ce44SJohn Forte 			(void) fprintf(stdout,
3760*fcf3ce44SJohn Forte 			MSGSTR(31, "Logical Path:%s"),
3761*fcf3ce44SJohn Forte 			b_list->logical_path);
3762*fcf3ce44SJohn Forte 
3763*fcf3ce44SJohn Forte 			if (Options & OPTION_P) {
3764*fcf3ce44SJohn Forte 				(void) fprintf(stdout, "\n  ");
3765*fcf3ce44SJohn Forte 				(void) fprintf(stdout,
3766*fcf3ce44SJohn Forte 				MSGSTR(5, "Physical Path:"));
3767*fcf3ce44SJohn Forte 				(void) fprintf(stdout, "%s",
3768*fcf3ce44SJohn Forte 				b_list->b_physical_path);
3769*fcf3ce44SJohn Forte 			}
3770*fcf3ce44SJohn Forte 			c_list = o_list;
3771*fcf3ce44SJohn Forte 			while (c_list != NULL) {
3772*fcf3ce44SJohn Forte 				if ((c_list != b_list) &&
3773*fcf3ce44SJohn Forte 				(strcmp(c_list->b_node_wwn_s,
3774*fcf3ce44SJohn Forte 					b_list->b_node_wwn_s) == 0)) {
3775*fcf3ce44SJohn Forte 					(void) fprintf(stdout, "\n  ");
3776*fcf3ce44SJohn Forte 					(void) fprintf(stdout,
3777*fcf3ce44SJohn Forte 					MSGSTR(31, "Logical Path:%s"),
3778*fcf3ce44SJohn Forte 					c_list->logical_path);
3779*fcf3ce44SJohn Forte 					if (Options & OPTION_P) {
3780*fcf3ce44SJohn Forte 						(void) fprintf(stdout, "\n  ");
3781*fcf3ce44SJohn Forte 						(void) fprintf(stdout,
3782*fcf3ce44SJohn Forte 						MSGSTR(5, "Physical Path:"));
3783*fcf3ce44SJohn Forte 						(void) fprintf(stdout, "%s",
3784*fcf3ce44SJohn Forte 						c_list->b_physical_path);
3785*fcf3ce44SJohn Forte 					}
3786*fcf3ce44SJohn Forte 				}
3787*fcf3ce44SJohn Forte 				c_list = c_list->box_next;
3788*fcf3ce44SJohn Forte 			}
3789*fcf3ce44SJohn Forte 			(void) fprintf(stdout, "\n");
3790*fcf3ce44SJohn Forte 			/* Check for duplicate names */
3791*fcf3ce44SJohn Forte 			if (l_duplicate_names(o_list, b_list->b_node_wwn_s,
3792*fcf3ce44SJohn Forte 				(char *)b_list->b_name,
3793*fcf3ce44SJohn Forte 				Options & PVERBOSE)) {
3794*fcf3ce44SJohn Forte 				duplicate_names_found++;
3795*fcf3ce44SJohn Forte 			}
3796*fcf3ce44SJohn Forte 			b_list = b_list->box_next;
3797*fcf3ce44SJohn Forte 		}
3798*fcf3ce44SJohn Forte 	}
3799*fcf3ce44SJohn Forte 	if (duplicate_names_found) {
3800*fcf3ce44SJohn Forte 		(void) fprintf(stdout,
3801*fcf3ce44SJohn Forte 			MSGSTR(2105, "\nWARNING: There are enclosures with "
3802*fcf3ce44SJohn Forte 			"the same names.\n"
3803*fcf3ce44SJohn Forte 			"You can not use the \"enclosure\""
3804*fcf3ce44SJohn Forte 			" name to specify these subsystems.\n"
3805*fcf3ce44SJohn Forte 			"Please use the \"enclosure_name\""
3806*fcf3ce44SJohn Forte 			" subcommand to select unique names.\n\n"));
3807*fcf3ce44SJohn Forte 	}
3808*fcf3ce44SJohn Forte 	(void) l_free_box_list(&b_list);
3809*fcf3ce44SJohn Forte }
3810*fcf3ce44SJohn Forte 
3811*fcf3ce44SJohn Forte /*
3812*fcf3ce44SJohn Forte  * display_port_status() Prints the device's
3813*fcf3ce44SJohn Forte  * port status.
3814*fcf3ce44SJohn Forte  *
3815*fcf3ce44SJohn Forte  * RETURNS:
3816*fcf3ce44SJohn Forte  *	none.
3817*fcf3ce44SJohn Forte  */
3818*fcf3ce44SJohn Forte void
3819*fcf3ce44SJohn Forte display_port_status(int d_state_flag)
3820*fcf3ce44SJohn Forte {
3821*fcf3ce44SJohn Forte 
3822*fcf3ce44SJohn Forte 	if (d_state_flag & L_OPEN_FAIL) {
3823*fcf3ce44SJohn Forte 		(void) fprintf(stdout, MSGSTR(28, "Open Failed"));
3824*fcf3ce44SJohn Forte 	} else if (d_state_flag & L_NOT_READY) {
3825*fcf3ce44SJohn Forte 		(void) fprintf(stdout, MSGSTR(20, "Not Ready"));
3826*fcf3ce44SJohn Forte 	} else if (d_state_flag & L_NOT_READABLE) {
3827*fcf3ce44SJohn Forte 		(void) fprintf(stdout, MSGSTR(88, "Not Readable"));
3828*fcf3ce44SJohn Forte 	} else if (d_state_flag & L_SPUN_DWN_D) {
3829*fcf3ce44SJohn Forte 		(void) fprintf(stdout, MSGSTR(68, "Spun Down"));
3830*fcf3ce44SJohn Forte 	} else if (d_state_flag & L_SCSI_ERR) {
3831*fcf3ce44SJohn Forte 		(void) fprintf(stdout, MSGSTR(70, "SCSI Error"));
3832*fcf3ce44SJohn Forte 	} else if (d_state_flag & L_RESERVED) {
3833*fcf3ce44SJohn Forte 		(void) fprintf(stdout, MSGSTR(73, "Reservation conflict"));
3834*fcf3ce44SJohn Forte 	} else if (d_state_flag & L_NO_LABEL) {
3835*fcf3ce44SJohn Forte 		(void) fprintf(stdout, MSGSTR(92, "No UNIX Label"));
3836*fcf3ce44SJohn Forte 	} else {
3837*fcf3ce44SJohn Forte 		(void) fprintf(stdout, MSGSTR(29, "O.K."));
3838*fcf3ce44SJohn Forte 	}
3839*fcf3ce44SJohn Forte 	(void) fprintf(stdout, "\n");
3840*fcf3ce44SJohn Forte }
3841*fcf3ce44SJohn Forte 
3842*fcf3ce44SJohn Forte /*
3843*fcf3ce44SJohn Forte  * Displays individual SENA
3844*fcf3ce44SJohn Forte  * FC disk information.
3845*fcf3ce44SJohn Forte  *
3846*fcf3ce44SJohn Forte  * Caller to this routine should free the storage due to
3847*fcf3ce44SJohn Forte  * the use of g_get_dev_map
3848*fcf3ce44SJohn Forte  *
3849*fcf3ce44SJohn Forte  * RETURNS:
3850*fcf3ce44SJohn Forte  *	none.
3851*fcf3ce44SJohn Forte  */
3852*fcf3ce44SJohn Forte void
3853*fcf3ce44SJohn Forte display_fc_disk(struct path_struct *path_struct, char *ses_path,
3854*fcf3ce44SJohn Forte 	gfc_map_t *map, L_inquiry inq, int verbose)
3855*fcf3ce44SJohn Forte {
3856*fcf3ce44SJohn Forte static WWN_list		*wwn_list = NULL;
3857*fcf3ce44SJohn Forte static char		path_phys[MAXPATHLEN];
3858*fcf3ce44SJohn Forte static L_disk_state	l_disk_state;
3859*fcf3ce44SJohn Forte static L_inquiry	local_inq;
3860*fcf3ce44SJohn Forte static uchar_t		node_wwn[WWN_SIZE];
3861*fcf3ce44SJohn Forte char			same_path_phys = B_FALSE; /* To chk for repeat args */
3862*fcf3ce44SJohn Forte uchar_t			port_wwn[WWN_SIZE], *pg_buf;
3863*fcf3ce44SJohn Forte char			logical_path[MAXPATHLEN];
3864*fcf3ce44SJohn Forte int			al_pa, port_a_flag = 0;
3865*fcf3ce44SJohn Forte int			offset, mode_data_avail = 0;
3866*fcf3ce44SJohn Forte int			no_path_flag = 0, err = 0;
3867*fcf3ce44SJohn Forte L_state			l_state;
3868*fcf3ce44SJohn Forte Mode_header_10		*mode_header_ptr = NULL;
3869*fcf3ce44SJohn Forte struct mode_page	*pg_hdr;
3870*fcf3ce44SJohn Forte 
3871*fcf3ce44SJohn Forte 	/*
3872*fcf3ce44SJohn Forte 	 * Do a quick check to see if its the same path as in last call.
3873*fcf3ce44SJohn Forte 	 * path_phys is a static array and so dont worry about its
3874*fcf3ce44SJohn Forte 	 * initialization.
3875*fcf3ce44SJohn Forte 	 */
3876*fcf3ce44SJohn Forte 	if (strcmp(path_phys, path_struct->p_physical_path) == 0)
3877*fcf3ce44SJohn Forte 		same_path_phys = B_TRUE;
3878*fcf3ce44SJohn Forte 
3879*fcf3ce44SJohn Forte 	(void) strcpy(path_phys, path_struct->p_physical_path);
3880*fcf3ce44SJohn Forte 	(void) memset((char *)logical_path, 0, sizeof (logical_path));
3881*fcf3ce44SJohn Forte 
3882*fcf3ce44SJohn Forte 	/*
3883*fcf3ce44SJohn Forte 	 * slot_valid is 1 when argument is of the form 'enclosure,[f|r]<n>'.
3884*fcf3ce44SJohn Forte 	 * If slot_valid != 1, g_get_dev_map and l_get_ses_path would
3885*fcf3ce44SJohn Forte 	 * already have been called
3886*fcf3ce44SJohn Forte 	 */
3887*fcf3ce44SJohn Forte 	if (path_struct->slot_valid == 1) {
3888*fcf3ce44SJohn Forte 		/* Get the location information. */
3889*fcf3ce44SJohn Forte 		if (err = g_get_dev_map(path_phys, map, (Options & PVERBOSE))) {
3890*fcf3ce44SJohn Forte 			(void) print_errString(err, path_phys);
3891*fcf3ce44SJohn Forte 			exit(-1);
3892*fcf3ce44SJohn Forte 		}
3893*fcf3ce44SJohn Forte 		if (err = l_get_ses_path(path_phys, ses_path, map,
3894*fcf3ce44SJohn Forte 			(Options & PVERBOSE))) {
3895*fcf3ce44SJohn Forte 			(void) print_errString(err, path_phys);
3896*fcf3ce44SJohn Forte 			exit(-1);
3897*fcf3ce44SJohn Forte 		}
3898*fcf3ce44SJohn Forte 	}
3899*fcf3ce44SJohn Forte 
3900*fcf3ce44SJohn Forte 	/*
3901*fcf3ce44SJohn Forte 	 * Get the WWN for our disk if we already haven't or if there was an
3902*fcf3ce44SJohn Forte 	 * error earlier
3903*fcf3ce44SJohn Forte 	 */
3904*fcf3ce44SJohn Forte 	if (same_path_phys == B_FALSE) {
3905*fcf3ce44SJohn Forte 		if (err = g_get_wwn(path_phys, port_wwn, node_wwn,
3906*fcf3ce44SJohn Forte 			&al_pa, (Options & PVERBOSE))) {
3907*fcf3ce44SJohn Forte 			(void) print_errString(err, path_phys);
3908*fcf3ce44SJohn Forte 			exit(-1);
3909*fcf3ce44SJohn Forte 		}
3910*fcf3ce44SJohn Forte 
3911*fcf3ce44SJohn Forte 		if (err = g_get_inquiry(ses_path, &local_inq)) {
3912*fcf3ce44SJohn Forte 			(void) print_errString(err, ses_path);
3913*fcf3ce44SJohn Forte 			exit(-1);
3914*fcf3ce44SJohn Forte 		}
3915*fcf3ce44SJohn Forte 	}
3916*fcf3ce44SJohn Forte 
3917*fcf3ce44SJohn Forte 	/*
3918*fcf3ce44SJohn Forte 	 * We are interested only a couple of ib_tbl fields and
3919*fcf3ce44SJohn Forte 	 * those get filled using l_get_ib_status.
3920*fcf3ce44SJohn Forte 	 * Note that NOT ALL of ib_tbl fields get filled here
3921*fcf3ce44SJohn Forte 	 */
3922*fcf3ce44SJohn Forte 	if ((err = l_get_ib_status(ses_path, &l_state,
3923*fcf3ce44SJohn Forte 				Options & PVERBOSE)) != 0) {
3924*fcf3ce44SJohn Forte 		(void) print_errString(err, ses_path);
3925*fcf3ce44SJohn Forte 		exit(-1);
3926*fcf3ce44SJohn Forte 	}
3927*fcf3ce44SJohn Forte 
3928*fcf3ce44SJohn Forte 	/*
3929*fcf3ce44SJohn Forte 	 * Get path to all the FC disk and tape devices.
3930*fcf3ce44SJohn Forte 	 * if we haven't already done so in a previous pass
3931*fcf3ce44SJohn Forte 	 */
3932*fcf3ce44SJohn Forte 	if ((wwn_list == NULL) && (err = g_get_wwn_list(&wwn_list, verbose))) {
3933*fcf3ce44SJohn Forte 		(void) print_errString(err, ses_path);
3934*fcf3ce44SJohn Forte 		exit(-1);   /* Failure */
3935*fcf3ce44SJohn Forte 	}
3936*fcf3ce44SJohn Forte 
3937*fcf3ce44SJohn Forte 	/*
3938*fcf3ce44SJohn Forte 	 * Get the disk status if it is a different path_phys from
3939*fcf3ce44SJohn Forte 	 * last time.
3940*fcf3ce44SJohn Forte 	 */
3941*fcf3ce44SJohn Forte 	if (same_path_phys == B_FALSE) {
3942*fcf3ce44SJohn Forte 		(void) memset(&l_disk_state, 0,
3943*fcf3ce44SJohn Forte 				sizeof (struct l_disk_state_struct));
3944*fcf3ce44SJohn Forte 		if (err = l_get_disk_status(path_phys, &l_disk_state,
3945*fcf3ce44SJohn Forte 				wwn_list, (Options & PVERBOSE))) {
3946*fcf3ce44SJohn Forte 			(void) print_errString(err, path_phys);
3947*fcf3ce44SJohn Forte 			exit(-1);
3948*fcf3ce44SJohn Forte 		}
3949*fcf3ce44SJohn Forte 	}
3950*fcf3ce44SJohn Forte 
3951*fcf3ce44SJohn Forte 	if (l_disk_state.l_state_flag & L_NO_PATH_FOUND) {
3952*fcf3ce44SJohn Forte 		(void) fprintf(stderr, MSGSTR(2106,
3953*fcf3ce44SJohn Forte 			"\nWARNING: No path found "
3954*fcf3ce44SJohn Forte 			"in /dev/rdsk directory\n"
3955*fcf3ce44SJohn Forte 			"  Please check the logical links in /dev/rdsk\n"
3956*fcf3ce44SJohn Forte 			"  (It may be necessary to run the \"disks\" "
3957*fcf3ce44SJohn Forte 			"program.)\n\n"));
3958*fcf3ce44SJohn Forte 
3959*fcf3ce44SJohn Forte 		/* Just call to get the status directly. */
3960*fcf3ce44SJohn Forte 		if (err = l_get_port(ses_path, &port_a_flag, verbose)) {
3961*fcf3ce44SJohn Forte 			(void) print_errString(err, ses_path);
3962*fcf3ce44SJohn Forte 			exit(-1);
3963*fcf3ce44SJohn Forte 		}
3964*fcf3ce44SJohn Forte 		if (err = l_get_disk_port_status(path_phys,
3965*fcf3ce44SJohn Forte 			&l_disk_state, port_a_flag,
3966*fcf3ce44SJohn Forte 			(Options & PVERBOSE))) {
3967*fcf3ce44SJohn Forte 			(void) print_errString(err, path_phys);
3968*fcf3ce44SJohn Forte 			exit(-1);
3969*fcf3ce44SJohn Forte 		}
3970*fcf3ce44SJohn Forte 		no_path_flag++;
3971*fcf3ce44SJohn Forte 	}
3972*fcf3ce44SJohn Forte 
3973*fcf3ce44SJohn Forte 	if (strlen(l_disk_state.g_disk_state.node_wwn_s) == 0) {
3974*fcf3ce44SJohn Forte 		(void) sprintf(l_disk_state.g_disk_state.node_wwn_s,
3975*fcf3ce44SJohn Forte 			"%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x",
3976*fcf3ce44SJohn Forte 			node_wwn[0], node_wwn[1], node_wwn[2], node_wwn[3],
3977*fcf3ce44SJohn Forte 			node_wwn[4], node_wwn[5], node_wwn[6], node_wwn[7]);
3978*fcf3ce44SJohn Forte 	}
3979*fcf3ce44SJohn Forte 
3980*fcf3ce44SJohn Forte 	/* get mode page information for FC device */
3981*fcf3ce44SJohn Forte 	if (l_get_mode_pg(path_phys, &pg_buf, Options & PVERBOSE) == 0) {
3982*fcf3ce44SJohn Forte 		mode_header_ptr = (struct mode_header_10_struct *)(int)pg_buf;
3983*fcf3ce44SJohn Forte 		pg_hdr = ((struct mode_page *)((int)pg_buf +
3984*fcf3ce44SJohn Forte 			(uchar_t)sizeof (struct mode_header_10_struct) +
3985*fcf3ce44SJohn Forte 			(uchar_t *)(uintptr_t)(mode_header_ptr->bdesc_length)));
3986*fcf3ce44SJohn Forte 		offset = sizeof (struct mode_header_10_struct) +
3987*fcf3ce44SJohn Forte 			mode_header_ptr->bdesc_length;
3988*fcf3ce44SJohn Forte 		while (offset < (mode_header_ptr->length +
3989*fcf3ce44SJohn Forte 			sizeof (mode_header_ptr->length)) &&
3990*fcf3ce44SJohn Forte 						!mode_data_avail) {
3991*fcf3ce44SJohn Forte 			if (pg_hdr->code == MODEPAGE_CACHING) {
3992*fcf3ce44SJohn Forte 				mode_data_avail++;
3993*fcf3ce44SJohn Forte 				break;
3994*fcf3ce44SJohn Forte 			}
3995*fcf3ce44SJohn Forte 			offset += pg_hdr->length + sizeof (struct mode_page);
3996*fcf3ce44SJohn Forte 			pg_hdr = ((struct mode_page *)((int)pg_buf +
3997*fcf3ce44SJohn Forte 				(uchar_t)offset));
3998*fcf3ce44SJohn Forte 		}
3999*fcf3ce44SJohn Forte 	}
4000*fcf3ce44SJohn Forte 
4001*fcf3ce44SJohn Forte 	switch ((inq.inq_dtype & DTYPE_MASK)) {
4002*fcf3ce44SJohn Forte 	case DTYPE_DIRECT:
4003*fcf3ce44SJohn Forte 	    fprintf(stdout, MSGSTR(121, "DEVICE PROPERTIES for disk: %s\n"),
4004*fcf3ce44SJohn Forte 		path_struct->argv);
4005*fcf3ce44SJohn Forte 	    break;
4006*fcf3ce44SJohn Forte 	case DTYPE_SEQUENTIAL: /* Tape */
4007*fcf3ce44SJohn Forte 	    fprintf(stdout, MSGSTR(2249, "DEVICE PROPERTIES for tape: %s\n"),
4008*fcf3ce44SJohn Forte 		path_struct->argv);
4009*fcf3ce44SJohn Forte 	    break;
4010*fcf3ce44SJohn Forte 	default:
4011*fcf3ce44SJohn Forte 	    fprintf(stdout, MSGSTR(2250, "DEVICE PROPERTIES for: %s\n"),
4012*fcf3ce44SJohn Forte 		path_struct->argv);
4013*fcf3ce44SJohn Forte 	    break;
4014*fcf3ce44SJohn Forte 	}
4015*fcf3ce44SJohn Forte 
4016*fcf3ce44SJohn Forte 	if (l_disk_state.g_disk_state.port_a_valid) {
4017*fcf3ce44SJohn Forte 		(void) fprintf(stdout, "  ");
4018*fcf3ce44SJohn Forte 		(void) fprintf(stdout, MSGSTR(141, "Status(Port A):"));
4019*fcf3ce44SJohn Forte 		(void) fprintf(stdout, "\t");
4020*fcf3ce44SJohn Forte 		display_port_status(
4021*fcf3ce44SJohn Forte 			l_disk_state.g_disk_state.d_state_flags[PORT_A]);
4022*fcf3ce44SJohn Forte 	} else {
4023*fcf3ce44SJohn Forte 		if (path_struct->f_flag) {
4024*fcf3ce44SJohn Forte 			if ((ib_present_chk(&l_state, 0) == 1) &&
4025*fcf3ce44SJohn Forte 		(l_state.drv_front[path_struct->slot].ib_status.bypass_a_en)) {
4026*fcf3ce44SJohn Forte 				(void) fprintf(stdout,
4027*fcf3ce44SJohn Forte 					MSGSTR(66,
4028*fcf3ce44SJohn Forte 					"  Status(Port A):\tBYPASSED\n"));
4029*fcf3ce44SJohn Forte 			}
4030*fcf3ce44SJohn Forte 		} else {
4031*fcf3ce44SJohn Forte 			if ((ib_present_chk(&l_state, 0) == 1) &&
4032*fcf3ce44SJohn Forte 		(l_state.drv_rear[path_struct->slot].ib_status.bypass_a_en)) {
4033*fcf3ce44SJohn Forte 				(void) fprintf(stdout,
4034*fcf3ce44SJohn Forte 					MSGSTR(66,
4035*fcf3ce44SJohn Forte 					"  Status(Port A):\tBYPASSED\n"));
4036*fcf3ce44SJohn Forte 			}
4037*fcf3ce44SJohn Forte 		}
4038*fcf3ce44SJohn Forte 	}
4039*fcf3ce44SJohn Forte 
4040*fcf3ce44SJohn Forte 	if (l_disk_state.g_disk_state.port_b_valid) {
4041*fcf3ce44SJohn Forte 		(void) fprintf(stdout, "  ");
4042*fcf3ce44SJohn Forte 		(void) fprintf(stdout, MSGSTR(142, "Status(Port B):"));
4043*fcf3ce44SJohn Forte 		(void) fprintf(stdout, "\t");
4044*fcf3ce44SJohn Forte 	display_port_status(l_disk_state.g_disk_state.d_state_flags[PORT_B]);
4045*fcf3ce44SJohn Forte 	} else {
4046*fcf3ce44SJohn Forte 		if (path_struct->f_flag) {
4047*fcf3ce44SJohn Forte 			if ((ib_present_chk(&l_state, 1) == 1) &&
4048*fcf3ce44SJohn Forte 		(l_state.drv_front[path_struct->slot].ib_status.bypass_b_en)) {
4049*fcf3ce44SJohn Forte 				(void) fprintf(stdout,
4050*fcf3ce44SJohn Forte 					MSGSTR(65,
4051*fcf3ce44SJohn Forte 					"  Status(Port B):\tBYPASSED\n"));
4052*fcf3ce44SJohn Forte 			}
4053*fcf3ce44SJohn Forte 		} else {
4054*fcf3ce44SJohn Forte 			if ((ib_present_chk(&l_state, 1) == 1) &&
4055*fcf3ce44SJohn Forte 		(l_state.drv_rear[path_struct->slot].ib_status.bypass_b_en)) {
4056*fcf3ce44SJohn Forte 				(void) fprintf(stdout,
4057*fcf3ce44SJohn Forte 					MSGSTR(65,
4058*fcf3ce44SJohn Forte 					"  Status(Port B):\tBYPASSED\n"));
4059*fcf3ce44SJohn Forte 			}
4060*fcf3ce44SJohn Forte 		}
4061*fcf3ce44SJohn Forte 	}
4062*fcf3ce44SJohn Forte 
4063*fcf3ce44SJohn Forte 	if (no_path_flag) {
4064*fcf3ce44SJohn Forte 		(void) fprintf(stdout, "  ");
4065*fcf3ce44SJohn Forte 		if (port_a_flag != NULL) {
4066*fcf3ce44SJohn Forte 			(void) fprintf(stdout, MSGSTR(142, "Status(Port B):"));
4067*fcf3ce44SJohn Forte 		} else {
4068*fcf3ce44SJohn Forte 			(void) fprintf(stdout, MSGSTR(141, "Status(Port A):"));
4069*fcf3ce44SJohn Forte 		}
4070*fcf3ce44SJohn Forte 		(void) fprintf(stdout, "\t");
4071*fcf3ce44SJohn Forte 		display_port_status(
4072*fcf3ce44SJohn Forte 		l_disk_state.g_disk_state.d_state_flags[port_a_flag]);
4073*fcf3ce44SJohn Forte 	} else if ((!l_disk_state.g_disk_state.port_a_valid) &&
4074*fcf3ce44SJohn Forte 			(!l_disk_state.g_disk_state.port_b_valid)) {
4075*fcf3ce44SJohn Forte 		(void) fprintf(stdout, MSGSTR(2107, "  Status:\t\t"
4076*fcf3ce44SJohn Forte 		"No state available.\n"));
4077*fcf3ce44SJohn Forte 	}
4078*fcf3ce44SJohn Forte 
4079*fcf3ce44SJohn Forte 	(void) display_disk_info(inq, l_disk_state, path_struct, pg_hdr,
4080*fcf3ce44SJohn Forte 		mode_data_avail, (char *)local_inq.inq_box_name, verbose);
4081*fcf3ce44SJohn Forte }
4082*fcf3ce44SJohn Forte 
4083*fcf3ce44SJohn Forte 
4084*fcf3ce44SJohn Forte 
4085*fcf3ce44SJohn Forte 
4086*fcf3ce44SJohn Forte 
4087*fcf3ce44SJohn Forte /*
4088*fcf3ce44SJohn Forte  * non_encl_fc_disk_display() Prints the device specific
4089*fcf3ce44SJohn Forte  * information for an individual fcal device.
4090*fcf3ce44SJohn Forte  *
4091*fcf3ce44SJohn Forte  * RETURNS:
4092*fcf3ce44SJohn Forte  *	none.
4093*fcf3ce44SJohn Forte  */
4094*fcf3ce44SJohn Forte static int
4095*fcf3ce44SJohn Forte non_encl_fc_disk_display(Path_struct *path_struct,
4096*fcf3ce44SJohn Forte 				L_inquiry inq_struct, int verbose)
4097*fcf3ce44SJohn Forte {
4098*fcf3ce44SJohn Forte 
4099*fcf3ce44SJohn Forte char			phys_path[MAXPATHLEN];
4100*fcf3ce44SJohn Forte uchar_t			node_wwn[WWN_SIZE], port_wwn[WWN_SIZE], *pg_buf = NULL;
4101*fcf3ce44SJohn Forte L_disk_state		l_disk_state;
4102*fcf3ce44SJohn Forte struct dlist		*mlist;
4103*fcf3ce44SJohn Forte int			i = 0, al_pa, offset, mode_data_avail = 0, err = 0;
4104*fcf3ce44SJohn Forte int			path_a_found = 0, path_b_found = 0, argpwwn = 0,
4105*fcf3ce44SJohn Forte 			argnwwn = 0, pathcnt = 1;
4106*fcf3ce44SJohn Forte L_inquiry		local_inq;
4107*fcf3ce44SJohn Forte Mode_header_10		*mode_header_ptr;
4108*fcf3ce44SJohn Forte struct mode_page	*pg_hdr;
4109*fcf3ce44SJohn Forte WWN_list		*wwn_list, *wwn_list_ptr, *list_start;
4110*fcf3ce44SJohn Forte char			temppath[MAXPATHLEN], last_logical_path[MAXPATHLEN];
4111*fcf3ce44SJohn Forte mp_pathlist_t		pathlist;
4112*fcf3ce44SJohn Forte 
4113*fcf3ce44SJohn Forte 	(void) strcpy(phys_path, path_struct->p_physical_path);
4114*fcf3ce44SJohn Forte 
4115*fcf3ce44SJohn Forte 	/* Get path to all the FC disk and tape devices. */
4116*fcf3ce44SJohn Forte 	if (err = g_get_wwn_list(&wwn_list, verbose)) {
4117*fcf3ce44SJohn Forte 		return (err);
4118*fcf3ce44SJohn Forte 	}
4119*fcf3ce44SJohn Forte 
4120*fcf3ce44SJohn Forte 	g_sort_wwn_list(&wwn_list);
4121*fcf3ce44SJohn Forte 
4122*fcf3ce44SJohn Forte 	list_start = wwn_list;
4123*fcf3ce44SJohn Forte 	(void) strcpy(last_logical_path, phys_path);
4124*fcf3ce44SJohn Forte 
4125*fcf3ce44SJohn Forte 	for (wwn_list_ptr = wwn_list; wwn_list_ptr != NULL;
4126*fcf3ce44SJohn Forte 		wwn_list_ptr = wwn_list_ptr->wwn_next) {
4127*fcf3ce44SJohn Forte 		if (strcasecmp(wwn_list_ptr->port_wwn_s,
4128*fcf3ce44SJohn Forte 			path_struct->argv) == 0) {
4129*fcf3ce44SJohn Forte 			list_start = wwn_list_ptr;
4130*fcf3ce44SJohn Forte 			argpwwn = 1;
4131*fcf3ce44SJohn Forte 			break;
4132*fcf3ce44SJohn Forte 		} else if (strcasecmp(wwn_list_ptr->node_wwn_s,
4133*fcf3ce44SJohn Forte 			path_struct->argv) == 0) {
4134*fcf3ce44SJohn Forte 			list_start = wwn_list_ptr;
4135*fcf3ce44SJohn Forte 			argnwwn = 1;
4136*fcf3ce44SJohn Forte 			break;
4137*fcf3ce44SJohn Forte 		}
4138*fcf3ce44SJohn Forte 	}
4139*fcf3ce44SJohn Forte 
4140*fcf3ce44SJohn Forte 	for (wwn_list_ptr = list_start; wwn_list_ptr != NULL;
4141*fcf3ce44SJohn Forte 		wwn_list_ptr = wwn_list_ptr->wwn_next) {
4142*fcf3ce44SJohn Forte 
4143*fcf3ce44SJohn Forte 
4144*fcf3ce44SJohn Forte 	if (argpwwn) {
4145*fcf3ce44SJohn Forte 		if (strcasecmp(wwn_list_ptr->port_wwn_s,
4146*fcf3ce44SJohn Forte 			path_struct->argv) != 0) {
4147*fcf3ce44SJohn Forte 			continue;
4148*fcf3ce44SJohn Forte 		}
4149*fcf3ce44SJohn Forte 		(void) strcpy(phys_path, wwn_list_ptr->physical_path);
4150*fcf3ce44SJohn Forte 		path_a_found = 0;
4151*fcf3ce44SJohn Forte 		path_b_found = 0;
4152*fcf3ce44SJohn Forte 		mode_data_avail = 0;
4153*fcf3ce44SJohn Forte 	} else if (argnwwn) {
4154*fcf3ce44SJohn Forte 		if (strstr(wwn_list_ptr->logical_path,
4155*fcf3ce44SJohn Forte 			last_logical_path) != NULL) {
4156*fcf3ce44SJohn Forte 			continue;
4157*fcf3ce44SJohn Forte 		}
4158*fcf3ce44SJohn Forte 		if (strcasecmp(wwn_list_ptr->node_wwn_s,
4159*fcf3ce44SJohn Forte 			path_struct->argv) != 0) {
4160*fcf3ce44SJohn Forte 			continue;
4161*fcf3ce44SJohn Forte 		}
4162*fcf3ce44SJohn Forte 		(void) strcpy(phys_path, wwn_list_ptr->physical_path);
4163*fcf3ce44SJohn Forte 		(void) strcpy(last_logical_path,
4164*fcf3ce44SJohn Forte 			wwn_list_ptr->logical_path);
4165*fcf3ce44SJohn Forte 		path_a_found = 0;
4166*fcf3ce44SJohn Forte 		path_b_found = 0;
4167*fcf3ce44SJohn Forte 		mode_data_avail = 0;
4168*fcf3ce44SJohn Forte 	}
4169*fcf3ce44SJohn Forte 
4170*fcf3ce44SJohn Forte 	(void) memset(&l_disk_state, 0, sizeof (struct l_disk_state_struct));
4171*fcf3ce44SJohn Forte 
4172*fcf3ce44SJohn Forte 	if ((err = g_get_multipath(phys_path,
4173*fcf3ce44SJohn Forte 		&(l_disk_state.g_disk_state.multipath_list),
4174*fcf3ce44SJohn Forte 		wwn_list, verbose)) != 0) {
4175*fcf3ce44SJohn Forte 		return (err);
4176*fcf3ce44SJohn Forte 	}
4177*fcf3ce44SJohn Forte 	mlist = l_disk_state.g_disk_state.multipath_list;
4178*fcf3ce44SJohn Forte 	if (mlist == NULL) {
4179*fcf3ce44SJohn Forte 		l_disk_state.l_state_flag = L_NO_PATH_FOUND;
4180*fcf3ce44SJohn Forte 		N_DPRINTF(" non_encl_fc_disk_display: Error finding"
4181*fcf3ce44SJohn Forte 			" multiple paths to the disk.\n");
4182*fcf3ce44SJohn Forte 		(void) g_free_wwn_list(&wwn_list);
4183*fcf3ce44SJohn Forte 		return (-1);
4184*fcf3ce44SJohn Forte 	}
4185*fcf3ce44SJohn Forte 
4186*fcf3ce44SJohn Forte 	/* get mode page information for FC device */
4187*fcf3ce44SJohn Forte 	if (l_get_mode_pg(phys_path, &pg_buf, verbose) == 0) {
4188*fcf3ce44SJohn Forte 		mode_header_ptr = (struct mode_header_10_struct *)(int)pg_buf;
4189*fcf3ce44SJohn Forte 		pg_hdr = ((struct mode_page *)((int)pg_buf +
4190*fcf3ce44SJohn Forte 			(uchar_t)sizeof (struct mode_header_10_struct) +
4191*fcf3ce44SJohn Forte 			(uchar_t *)(uintptr_t)(mode_header_ptr->bdesc_length)));
4192*fcf3ce44SJohn Forte 		offset = sizeof (struct mode_header_10_struct) +
4193*fcf3ce44SJohn Forte 			mode_header_ptr->bdesc_length;
4194*fcf3ce44SJohn Forte 		while (offset < (mode_header_ptr->length +
4195*fcf3ce44SJohn Forte 			sizeof (mode_header_ptr->length)) &&
4196*fcf3ce44SJohn Forte 						!mode_data_avail) {
4197*fcf3ce44SJohn Forte 			if (pg_hdr->code == MODEPAGE_CACHING) {
4198*fcf3ce44SJohn Forte 				mode_data_avail++;
4199*fcf3ce44SJohn Forte 				break;
4200*fcf3ce44SJohn Forte 			}
4201*fcf3ce44SJohn Forte 			offset += pg_hdr->length + sizeof (struct mode_page);
4202*fcf3ce44SJohn Forte 			pg_hdr = ((struct mode_page *)((int)pg_buf +
4203*fcf3ce44SJohn Forte 				(uchar_t)offset));
4204*fcf3ce44SJohn Forte 		}
4205*fcf3ce44SJohn Forte 	}
4206*fcf3ce44SJohn Forte 
4207*fcf3ce44SJohn Forte 	switch ((inq_struct.inq_dtype & DTYPE_MASK)) {
4208*fcf3ce44SJohn Forte 	case DTYPE_DIRECT:
4209*fcf3ce44SJohn Forte 	    fprintf(stdout, MSGSTR(121, "DEVICE PROPERTIES for disk: %s\n"),
4210*fcf3ce44SJohn Forte 		path_struct->argv);
4211*fcf3ce44SJohn Forte 	    break;
4212*fcf3ce44SJohn Forte 	case DTYPE_SEQUENTIAL: /* Tape */
4213*fcf3ce44SJohn Forte 	    fprintf(stdout, MSGSTR(2249, "DEVICE PROPERTIES for tape: %s\n"),
4214*fcf3ce44SJohn Forte 		path_struct->argv);
4215*fcf3ce44SJohn Forte 	    break;
4216*fcf3ce44SJohn Forte 	default:
4217*fcf3ce44SJohn Forte 	    fprintf(stdout, MSGSTR(2250, "DEVICE PROPERTIES for: %s\n"),
4218*fcf3ce44SJohn Forte 		path_struct->argv);
4219*fcf3ce44SJohn Forte 	    break;
4220*fcf3ce44SJohn Forte 	}
4221*fcf3ce44SJohn Forte 	while ((mlist != NULL) && (!(path_a_found && path_b_found))) {
4222*fcf3ce44SJohn Forte 		(void) strcpy(phys_path, mlist->dev_path);
4223*fcf3ce44SJohn Forte 		if (err = g_get_inquiry(phys_path, &local_inq)) {
4224*fcf3ce44SJohn Forte 			(void) fprintf(stderr,
4225*fcf3ce44SJohn Forte 				MSGSTR(2114,
4226*fcf3ce44SJohn Forte 				"non_encl_fc_disk_display: Inquiry failed\n"));
4227*fcf3ce44SJohn Forte 			(void) print_errString(err, phys_path);
4228*fcf3ce44SJohn Forte 			(void) g_free_multipath(
4229*fcf3ce44SJohn Forte 				l_disk_state.g_disk_state.multipath_list);
4230*fcf3ce44SJohn Forte 			(void) g_free_wwn_list(&wwn_list);
4231*fcf3ce44SJohn Forte 			return (-1);
4232*fcf3ce44SJohn Forte 		}
4233*fcf3ce44SJohn Forte 		if ((err = g_get_wwn(mlist->dev_path, port_wwn, node_wwn,
4234*fcf3ce44SJohn Forte 					&al_pa, verbose)) != 0) {
4235*fcf3ce44SJohn Forte 			(void) print_errString(err, mlist->dev_path);
4236*fcf3ce44SJohn Forte 			(void) g_free_multipath(
4237*fcf3ce44SJohn Forte 				l_disk_state.g_disk_state.multipath_list);
4238*fcf3ce44SJohn Forte 			(void) g_free_wwn_list(&wwn_list);
4239*fcf3ce44SJohn Forte 			return (-1);
4240*fcf3ce44SJohn Forte 		}
4241*fcf3ce44SJohn Forte 		if (strlen(l_disk_state.g_disk_state.node_wwn_s) == 0) {
4242*fcf3ce44SJohn Forte 			(void) sprintf(l_disk_state.g_disk_state.node_wwn_s,
4243*fcf3ce44SJohn Forte 			"%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x",
4244*fcf3ce44SJohn Forte 			node_wwn[0], node_wwn[1], node_wwn[2], node_wwn[3],
4245*fcf3ce44SJohn Forte 			node_wwn[4], node_wwn[5], node_wwn[6], node_wwn[7]);
4246*fcf3ce44SJohn Forte 		}
4247*fcf3ce44SJohn Forte 		if ((err = l_get_disk_port_status(phys_path, &l_disk_state,
4248*fcf3ce44SJohn Forte 				(local_inq.inq_port) ? FC_PORT_B : FC_PORT_A,
4249*fcf3ce44SJohn Forte 				verbose)) != 0) {
4250*fcf3ce44SJohn Forte 			(void) print_errString(err, phys_path);
4251*fcf3ce44SJohn Forte 			(void) g_free_multipath(
4252*fcf3ce44SJohn Forte 				l_disk_state.g_disk_state.multipath_list);
4253*fcf3ce44SJohn Forte 			exit(-1);
4254*fcf3ce44SJohn Forte 		}
4255*fcf3ce44SJohn Forte 
4256*fcf3ce44SJohn Forte 		if ((!local_inq.inq_port) && (!path_a_found)) {
4257*fcf3ce44SJohn Forte 			(void) sprintf(l_disk_state.g_disk_state.port_a_wwn_s,
4258*fcf3ce44SJohn Forte 				"%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x",
4259*fcf3ce44SJohn Forte 			port_wwn[0], port_wwn[1], port_wwn[2], port_wwn[3],
4260*fcf3ce44SJohn Forte 			port_wwn[4], port_wwn[5], port_wwn[6], port_wwn[7]);
4261*fcf3ce44SJohn Forte 		path_a_found = l_disk_state.g_disk_state.port_a_valid = 1;
4262*fcf3ce44SJohn Forte 		}
4263*fcf3ce44SJohn Forte 		if ((local_inq.inq_port) && (!path_b_found)) {
4264*fcf3ce44SJohn Forte 		path_b_found = l_disk_state.g_disk_state.port_b_valid = 1;
4265*fcf3ce44SJohn Forte 			(void) sprintf(l_disk_state.g_disk_state.port_b_wwn_s,
4266*fcf3ce44SJohn Forte 				"%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x",
4267*fcf3ce44SJohn Forte 			port_wwn[0], port_wwn[1], port_wwn[2], port_wwn[3],
4268*fcf3ce44SJohn Forte 			port_wwn[4], port_wwn[5], port_wwn[6], port_wwn[7]);
4269*fcf3ce44SJohn Forte 		}
4270*fcf3ce44SJohn Forte 
4271*fcf3ce44SJohn Forte 		if ((strstr(mlist->dev_path, SCSI_VHCI) != NULL) &&
4272*fcf3ce44SJohn Forte 			(!l_get_disk_port_status(phys_path, &l_disk_state,
4273*fcf3ce44SJohn Forte 			(!local_inq.inq_port) ? FC_PORT_B : FC_PORT_A,
4274*fcf3ce44SJohn Forte 			verbose))) {
4275*fcf3ce44SJohn Forte 			(void) strcpy(temppath, mlist->dev_path);
4276*fcf3ce44SJohn Forte 			if (err = g_get_pathlist(temppath, &pathlist)) {
4277*fcf3ce44SJohn Forte 				(void) print_errString(err, NULL);
4278*fcf3ce44SJohn Forte 				exit(-1);
4279*fcf3ce44SJohn Forte 			}
4280*fcf3ce44SJohn Forte 			pathcnt = pathlist.path_count;
4281*fcf3ce44SJohn Forte 			if (pathcnt > 1) {
4282*fcf3ce44SJohn Forte 				for (i = 0; i < pathcnt; i++) {
4283*fcf3ce44SJohn Forte 					if ((!path_a_found) &&
4284*fcf3ce44SJohn Forte 						(path_b_found) &&
4285*fcf3ce44SJohn Forte 						(strstr(pathlist.path_info[i].
4286*fcf3ce44SJohn Forte 						path_addr,
4287*fcf3ce44SJohn Forte 						l_disk_state.g_disk_state.
4288*fcf3ce44SJohn Forte 						port_b_wwn_s) == NULL)) {
4289*fcf3ce44SJohn Forte 
4290*fcf3ce44SJohn Forte 						(void) strncpy(l_disk_state.
4291*fcf3ce44SJohn Forte 						g_disk_state.port_a_wwn_s,
4292*fcf3ce44SJohn Forte 						pathlist.path_info[i].
4293*fcf3ce44SJohn Forte 						path_addr, 16);
4294*fcf3ce44SJohn Forte 						path_a_found = l_disk_state.
4295*fcf3ce44SJohn Forte 						g_disk_state.port_a_valid = 1;
4296*fcf3ce44SJohn Forte 					}
4297*fcf3ce44SJohn Forte 					if ((path_a_found) &&
4298*fcf3ce44SJohn Forte 						(!path_b_found) &&
4299*fcf3ce44SJohn Forte 						(strstr(pathlist.path_info[i].
4300*fcf3ce44SJohn Forte 						path_addr,
4301*fcf3ce44SJohn Forte 						l_disk_state.g_disk_state.
4302*fcf3ce44SJohn Forte 						port_a_wwn_s) == NULL)) {
4303*fcf3ce44SJohn Forte 
4304*fcf3ce44SJohn Forte 						(void) strncpy(l_disk_state.
4305*fcf3ce44SJohn Forte 						g_disk_state.port_b_wwn_s,
4306*fcf3ce44SJohn Forte 						pathlist.path_info[i].
4307*fcf3ce44SJohn Forte 						path_addr, 16);
4308*fcf3ce44SJohn Forte 						path_b_found = l_disk_state.
4309*fcf3ce44SJohn Forte 						g_disk_state.port_b_valid = 1;
4310*fcf3ce44SJohn Forte 					}
4311*fcf3ce44SJohn Forte 					if ((path_a_found) && (path_b_found)) {
4312*fcf3ce44SJohn Forte 						break;
4313*fcf3ce44SJohn Forte 					}
4314*fcf3ce44SJohn Forte 				}
4315*fcf3ce44SJohn Forte 			}
4316*fcf3ce44SJohn Forte 			free(pathlist.path_info);
4317*fcf3ce44SJohn Forte 		}
4318*fcf3ce44SJohn Forte 
4319*fcf3ce44SJohn Forte 		mlist = mlist->next;
4320*fcf3ce44SJohn Forte 	}
4321*fcf3ce44SJohn Forte 
4322*fcf3ce44SJohn Forte 	if (l_disk_state.g_disk_state.port_a_valid) {
4323*fcf3ce44SJohn Forte 		(void) fprintf(stdout, "  ");
4324*fcf3ce44SJohn Forte 		(void) fprintf(stdout, MSGSTR(141, "Status(Port A):"));
4325*fcf3ce44SJohn Forte 		(void) fprintf(stdout, "\t");
4326*fcf3ce44SJohn Forte 	display_port_status(l_disk_state.g_disk_state.d_state_flags[FC_PORT_A]);
4327*fcf3ce44SJohn Forte 	}
4328*fcf3ce44SJohn Forte 
4329*fcf3ce44SJohn Forte 	if (l_disk_state.g_disk_state.port_b_valid) {
4330*fcf3ce44SJohn Forte 		(void) fprintf(stdout, "  ");
4331*fcf3ce44SJohn Forte 		(void) fprintf(stdout, MSGSTR(142, "Status(Port B):"));
4332*fcf3ce44SJohn Forte 		(void) fprintf(stdout, "\t");
4333*fcf3ce44SJohn Forte 	display_port_status(l_disk_state.g_disk_state.d_state_flags[FC_PORT_B]);
4334*fcf3ce44SJohn Forte 	}
4335*fcf3ce44SJohn Forte 
4336*fcf3ce44SJohn Forte 	(void) display_disk_info(local_inq, l_disk_state, path_struct,
4337*fcf3ce44SJohn Forte 				pg_hdr, mode_data_avail, NULL, verbose);
4338*fcf3ce44SJohn Forte 	(void) g_free_multipath(l_disk_state.g_disk_state.multipath_list);
4339*fcf3ce44SJohn Forte 
4340*fcf3ce44SJohn Forte 	if (!(argpwwn || argnwwn)) {
4341*fcf3ce44SJohn Forte 		break;
4342*fcf3ce44SJohn Forte 	}
4343*fcf3ce44SJohn Forte 
4344*fcf3ce44SJohn Forte 	}
4345*fcf3ce44SJohn Forte 	(void) g_free_wwn_list(&wwn_list);
4346*fcf3ce44SJohn Forte 	return (0);
4347*fcf3ce44SJohn Forte }
4348*fcf3ce44SJohn Forte 
4349*fcf3ce44SJohn Forte 
4350*fcf3ce44SJohn Forte 
4351*fcf3ce44SJohn Forte /*
4352*fcf3ce44SJohn Forte  * display_disk_info() Prints the device specific information
4353*fcf3ce44SJohn Forte  * for any FC_AL disk device.
4354*fcf3ce44SJohn Forte  *
4355*fcf3ce44SJohn Forte  * RETURNS:
4356*fcf3ce44SJohn Forte  *	none.
4357*fcf3ce44SJohn Forte  */
4358*fcf3ce44SJohn Forte void
4359*fcf3ce44SJohn Forte display_disk_info(L_inquiry inq, L_disk_state l_disk_state,
4360*fcf3ce44SJohn Forte 		Path_struct *path_struct, struct mode_page *pg_hdr,
4361*fcf3ce44SJohn Forte 		int mode_data_avail, char *name_buf, int options)
4362*fcf3ce44SJohn Forte {
4363*fcf3ce44SJohn Forte float		num_blks;
4364*fcf3ce44SJohn Forte struct dlist	*mlist;
4365*fcf3ce44SJohn Forte int		port_a, port_b;
4366*fcf3ce44SJohn Forte struct	my_mode_caching	*pg8_buf;
4367*fcf3ce44SJohn Forte L_inquiry	enc_inq;
4368*fcf3ce44SJohn Forte char		*enc_phys_path;
4369*fcf3ce44SJohn Forte Path_struct	*enc_path_struct;
4370*fcf3ce44SJohn Forte int		enc_type = 0;
4371*fcf3ce44SJohn Forte L_inquiry80	inq80;
4372*fcf3ce44SJohn Forte size_t		serial_len;
4373*fcf3ce44SJohn Forte int		err;
4374*fcf3ce44SJohn Forte 
4375*fcf3ce44SJohn Forte 	serial_len = sizeof (inq80.inq_serial);
4376*fcf3ce44SJohn Forte 	err = g_get_serial_number(path_struct->p_physical_path,
4377*fcf3ce44SJohn Forte 	    inq80.inq_serial, &serial_len);
4378*fcf3ce44SJohn Forte 	if (err) {
4379*fcf3ce44SJohn Forte 		fprintf(stderr, "\n");
4380*fcf3ce44SJohn Forte 		print_errString(err, path_struct->p_physical_path);
4381*fcf3ce44SJohn Forte 		fprintf(stderr, "\n");
4382*fcf3ce44SJohn Forte 		exit(1);
4383*fcf3ce44SJohn Forte 	}
4384*fcf3ce44SJohn Forte 	(void) fprintf(stdout, "  ");
4385*fcf3ce44SJohn Forte 	(void) fprintf(stdout, MSGSTR(3, "Vendor:"));
4386*fcf3ce44SJohn Forte 	(void) fprintf(stdout, "\t\t");
4387*fcf3ce44SJohn Forte 	print_chars(inq.inq_vid, sizeof (inq.inq_vid), 0);
4388*fcf3ce44SJohn Forte 
4389*fcf3ce44SJohn Forte 	(void) fprintf(stdout, MSGSTR(2115, "\n  Product ID:\t\t"));
4390*fcf3ce44SJohn Forte 	print_chars(inq.inq_pid, sizeof (inq.inq_pid), 0);
4391*fcf3ce44SJohn Forte 
4392*fcf3ce44SJohn Forte 	(void) fprintf(stdout, MSGSTR(2116, "\n  WWN(Node):\t\t%s"),
4393*fcf3ce44SJohn Forte 				l_disk_state.g_disk_state.node_wwn_s);
4394*fcf3ce44SJohn Forte 
4395*fcf3ce44SJohn Forte 	if (l_disk_state.g_disk_state.port_a_valid) {
4396*fcf3ce44SJohn Forte 		(void) fprintf(stdout, MSGSTR(2117, "\n  WWN(Port A):\t\t%s"),
4397*fcf3ce44SJohn Forte 				l_disk_state.g_disk_state.port_a_wwn_s);
4398*fcf3ce44SJohn Forte 	}
4399*fcf3ce44SJohn Forte 	if (l_disk_state.g_disk_state.port_b_valid) {
4400*fcf3ce44SJohn Forte 		(void) fprintf(stdout, MSGSTR(2118, "\n  WWN(Port B):\t\t%s"),
4401*fcf3ce44SJohn Forte 				l_disk_state.g_disk_state.port_b_wwn_s);
4402*fcf3ce44SJohn Forte 	}
4403*fcf3ce44SJohn Forte 	(void) fprintf(stdout, "\n  ");
4404*fcf3ce44SJohn Forte 	(void) fprintf(stdout, MSGSTR(2119, "Revision:"));
4405*fcf3ce44SJohn Forte 	(void) fprintf(stdout, "\t\t");
4406*fcf3ce44SJohn Forte 	print_chars(inq.inq_revision, sizeof (inq.inq_revision), 0);
4407*fcf3ce44SJohn Forte 
4408*fcf3ce44SJohn Forte 	(void) fprintf(stdout, "\n  ");
4409*fcf3ce44SJohn Forte 	(void) fprintf(stdout, MSGSTR(17, "Serial Num:"));
4410*fcf3ce44SJohn Forte 	(void) fprintf(stdout, "\t\t");
4411*fcf3ce44SJohn Forte 	print_chars(inq80.inq_serial, serial_len, 0);
4412*fcf3ce44SJohn Forte 	num_blks = l_disk_state.g_disk_state.num_blocks;
4413*fcf3ce44SJohn Forte 	if (num_blks) {
4414*fcf3ce44SJohn Forte 		num_blks /= 2048;	/* get Mbytes */
4415*fcf3ce44SJohn Forte 		(void) fprintf(stdout, "\n  ");
4416*fcf3ce44SJohn Forte 		(void) fprintf(stdout,
4417*fcf3ce44SJohn Forte 			MSGSTR(60,
4418*fcf3ce44SJohn Forte 		"Unformatted capacity:\t%6.3f MBytes"), num_blks);
4419*fcf3ce44SJohn Forte 	}
4420*fcf3ce44SJohn Forte 	(void) fprintf(stdout, "\n");
4421*fcf3ce44SJohn Forte 
4422*fcf3ce44SJohn Forte 	if (l_disk_state.g_disk_state.persistent_reserv_flag) {
4423*fcf3ce44SJohn Forte 		(void) fprintf(stdout,
4424*fcf3ce44SJohn Forte 			MSGSTR(2120, "  Persistent Reserve:\t"));
4425*fcf3ce44SJohn Forte 		if (l_disk_state.g_disk_state.persistent_active) {
4426*fcf3ce44SJohn Forte 			(void) fprintf(stdout,
4427*fcf3ce44SJohn Forte 				MSGSTR(39, "Active"));
4428*fcf3ce44SJohn Forte 				(void) fprintf(stdout, "\n");
4429*fcf3ce44SJohn Forte 		}
4430*fcf3ce44SJohn Forte 		if (l_disk_state.g_disk_state.persistent_registered) {
4431*fcf3ce44SJohn Forte 			(void) fprintf(stdout,
4432*fcf3ce44SJohn Forte 				MSGSTR(2121, "Found Registered Keys"));
4433*fcf3ce44SJohn Forte 		} else {
4434*fcf3ce44SJohn Forte 			(void) fprintf(stdout,
4435*fcf3ce44SJohn Forte 				MSGSTR(87, "Not being used"));
4436*fcf3ce44SJohn Forte 		}
4437*fcf3ce44SJohn Forte 		(void) fprintf(stdout, "\n");
4438*fcf3ce44SJohn Forte 	}
4439*fcf3ce44SJohn Forte 
4440*fcf3ce44SJohn Forte 	if ((mode_data_avail) && (pg_hdr->code == MODEPAGE_CACHING)) {
4441*fcf3ce44SJohn Forte 		pg8_buf = (struct my_mode_caching *)(int)pg_hdr;
4442*fcf3ce44SJohn Forte 		if (pg8_buf->wce) {
4443*fcf3ce44SJohn Forte 			(void) fprintf(stdout,
4444*fcf3ce44SJohn Forte 				MSGSTR(2122,
4445*fcf3ce44SJohn Forte 				"  Write Cache:\t\t"
4446*fcf3ce44SJohn Forte 				"Enabled\n"));
4447*fcf3ce44SJohn Forte 		}
4448*fcf3ce44SJohn Forte 		if (pg8_buf->rcd == 0) {
4449*fcf3ce44SJohn Forte 			(void) fprintf(stdout,
4450*fcf3ce44SJohn Forte 				MSGSTR(2123,
4451*fcf3ce44SJohn Forte 				"  Read Cache:\t\t"
4452*fcf3ce44SJohn Forte 				"Enabled\n"));
4453*fcf3ce44SJohn Forte 			(void) fprintf(stdout,
4454*fcf3ce44SJohn Forte 				MSGSTR(2320,
4455*fcf3ce44SJohn Forte 				"    Minimum prefetch:"
4456*fcf3ce44SJohn Forte 				"\t0x%x\n"
4457*fcf3ce44SJohn Forte 				"    Maximum prefetch:"
4458*fcf3ce44SJohn Forte 				"\t0x%x\n"),
4459*fcf3ce44SJohn Forte 				pg8_buf->min_prefetch,
4460*fcf3ce44SJohn Forte 				pg8_buf->max_prefetch);
4461*fcf3ce44SJohn Forte 		}
4462*fcf3ce44SJohn Forte 	}
4463*fcf3ce44SJohn Forte 
4464*fcf3ce44SJohn Forte 	/*
4465*fcf3ce44SJohn Forte 	 * When /dev/rdsk/cxtxdxsx form of input is specified
4466*fcf3ce44SJohn Forte 	 * for display command the initial library version didn't
4467*fcf3ce44SJohn Forte 	 * display Location information.  The change is made
4468*fcf3ce44SJohn Forte 	 * to display the same Location info as the non-library version.
4469*fcf3ce44SJohn Forte 	 */
4470*fcf3ce44SJohn Forte 
4471*fcf3ce44SJohn Forte 	if (name_buf != NULL) {
4472*fcf3ce44SJohn Forte 	    fprintf(stdout, MSGSTR(2125, "  Location:\t\t"));
4473*fcf3ce44SJohn Forte 	    if (path_struct->slot_valid) {
4474*fcf3ce44SJohn Forte 		/*
4475*fcf3ce44SJohn Forte 		 * We have to do another inquiry on the enclosure (name_buf)
4476*fcf3ce44SJohn Forte 		 * to determine if this device is within a daktari, or
4477*fcf3ce44SJohn Forte 		 * a two sided device.
4478*fcf3ce44SJohn Forte 		 */
4479*fcf3ce44SJohn Forte 		if (!l_convert_name(name_buf, &enc_phys_path,
4480*fcf3ce44SJohn Forte 			&enc_path_struct, 0)) {
4481*fcf3ce44SJohn Forte 		    if (!g_get_inquiry(enc_phys_path, &enc_inq)) {
4482*fcf3ce44SJohn Forte 			enc_type = l_get_enc_type(enc_inq);
4483*fcf3ce44SJohn Forte 		    }
4484*fcf3ce44SJohn Forte 		}
4485*fcf3ce44SJohn Forte 		/* If either of the above fail, we just assume the default */
4486*fcf3ce44SJohn Forte 		free(enc_phys_path);
4487*fcf3ce44SJohn Forte 		free(enc_path_struct);
4488*fcf3ce44SJohn Forte 		if (enc_type == DAK_ENC_TYPE) {
4489*fcf3ce44SJohn Forte 			if (path_struct->f_flag) {
4490*fcf3ce44SJohn Forte 				(void) fprintf(stdout, MSGSTR(2239,
4491*fcf3ce44SJohn Forte 				    "In slot %d in the enclosure named: %s\n"),
4492*fcf3ce44SJohn Forte 				    path_struct->slot, name_buf);
4493*fcf3ce44SJohn Forte 			} else {
4494*fcf3ce44SJohn Forte 				(void) fprintf(stdout, MSGSTR(2239,
4495*fcf3ce44SJohn Forte 				    "In slot %d in the enclosure named: %s\n"),
4496*fcf3ce44SJohn Forte 				    path_struct->slot + (MAX_DRIVES_DAK/2),
4497*fcf3ce44SJohn Forte 								name_buf);
4498*fcf3ce44SJohn Forte 			}
4499*fcf3ce44SJohn Forte 		} else	{  /* Default enclosure type */
4500*fcf3ce44SJohn Forte 		    (void) fprintf(stdout, path_struct->f_flag ?
4501*fcf3ce44SJohn Forte 				MSGSTR(2126,
4502*fcf3ce44SJohn Forte 			"In slot %d in the Front of the enclosure named: %s\n")
4503*fcf3ce44SJohn Forte 				: MSGSTR(2127,
4504*fcf3ce44SJohn Forte 			"In slot %d in the Rear of the enclosure named: %s\n"),
4505*fcf3ce44SJohn Forte 				path_struct->slot, name_buf);
4506*fcf3ce44SJohn Forte 		}
4507*fcf3ce44SJohn Forte 	    } else {
4508*fcf3ce44SJohn Forte 		(void) fprintf(stdout, MSGSTR(2228,
4509*fcf3ce44SJohn Forte 			"In the enclosure named: %s\n"),
4510*fcf3ce44SJohn Forte 			name_buf);
4511*fcf3ce44SJohn Forte 	    }
4512*fcf3ce44SJohn Forte 	}
4513*fcf3ce44SJohn Forte 
4514*fcf3ce44SJohn Forte 	(void) fprintf(stdout, "  %s\t\t%s\n",
4515*fcf3ce44SJohn Forte 			MSGSTR(35, "Device Type:"),
4516*fcf3ce44SJohn Forte 			dtype[inq.inq_dtype & DTYPE_MASK]);
4517*fcf3ce44SJohn Forte 
4518*fcf3ce44SJohn Forte 	mlist = l_disk_state.g_disk_state.multipath_list;
4519*fcf3ce44SJohn Forte 	(void) fprintf(stdout, MSGSTR(2128, "  Path(s):\n"));
4520*fcf3ce44SJohn Forte 	if (strstr(mlist->dev_path, SCSI_VHCI) != NULL) {
4521*fcf3ce44SJohn Forte 		(void) fprintf(stdout, "  %s\n  %s\n",
4522*fcf3ce44SJohn Forte 			mlist->logical_path, mlist->dev_path);
4523*fcf3ce44SJohn Forte 		(void) adm_print_pathlist(mlist->dev_path);
4524*fcf3ce44SJohn Forte 	} else {
4525*fcf3ce44SJohn Forte 		while (mlist) {
4526*fcf3ce44SJohn Forte 			(void) fprintf(stdout, "  %s\n  %s\n",
4527*fcf3ce44SJohn Forte 				mlist->logical_path, mlist->dev_path);
4528*fcf3ce44SJohn Forte 			mlist = mlist->next;
4529*fcf3ce44SJohn Forte 		}
4530*fcf3ce44SJohn Forte 	}
4531*fcf3ce44SJohn Forte 
4532*fcf3ce44SJohn Forte 	if (Options & OPTION_V) {
4533*fcf3ce44SJohn Forte 		if (path_struct->slot_valid) {
4534*fcf3ce44SJohn Forte 			port_a = PORT_A;
4535*fcf3ce44SJohn Forte 			port_b = PORT_B;
4536*fcf3ce44SJohn Forte 		} else {
4537*fcf3ce44SJohn Forte 			port_a = FC_PORT_A;
4538*fcf3ce44SJohn Forte 			port_b = FC_PORT_B;
4539*fcf3ce44SJohn Forte 		}
4540*fcf3ce44SJohn Forte 		/* Only bother if the state is O.K. */
4541*fcf3ce44SJohn Forte 		if ((l_disk_state.g_disk_state.port_a_valid) &&
4542*fcf3ce44SJohn Forte 			(l_disk_state.g_disk_state.d_state_flags[port_a] == 0))
4543*fcf3ce44SJohn Forte 		adm_display_verbose_disk(path_struct->p_physical_path, options);
4544*fcf3ce44SJohn Forte 		else if ((l_disk_state.g_disk_state.port_b_valid) &&
4545*fcf3ce44SJohn Forte 			(l_disk_state.g_disk_state.d_state_flags[port_b] == 0))
4546*fcf3ce44SJohn Forte 		adm_display_verbose_disk(path_struct->p_physical_path, options);
4547*fcf3ce44SJohn Forte 	}
4548*fcf3ce44SJohn Forte 	(void) fprintf(stdout, "\n");
4549*fcf3ce44SJohn Forte 
4550*fcf3ce44SJohn Forte }
4551*fcf3ce44SJohn Forte 
4552*fcf3ce44SJohn Forte 
4553*fcf3ce44SJohn Forte 
4554*fcf3ce44SJohn Forte /*
4555*fcf3ce44SJohn Forte  * temp_decode() Display temperature bytes 1-3 state.
4556*fcf3ce44SJohn Forte  *
4557*fcf3ce44SJohn Forte  * RETURNS:
4558*fcf3ce44SJohn Forte  *	none.
4559*fcf3ce44SJohn Forte  */
4560*fcf3ce44SJohn Forte void
4561*fcf3ce44SJohn Forte temp_decode(Temp_elem_st *temp)
4562*fcf3ce44SJohn Forte {
4563*fcf3ce44SJohn Forte 	if (temp->ot_fail) {
4564*fcf3ce44SJohn Forte 		(void) fprintf(stdout, MSGSTR(2129,
4565*fcf3ce44SJohn Forte 			": FAILURE - Over Temperature"));
4566*fcf3ce44SJohn Forte 	}
4567*fcf3ce44SJohn Forte 	if (temp->ut_fail) {
4568*fcf3ce44SJohn Forte 		(void) fprintf(stdout, MSGSTR(2130,
4569*fcf3ce44SJohn Forte 			": FAILURE - Under Temperature"));
4570*fcf3ce44SJohn Forte 	}
4571*fcf3ce44SJohn Forte 	if (temp->ot_warn) {
4572*fcf3ce44SJohn Forte 		(void) fprintf(stdout, MSGSTR(2131,
4573*fcf3ce44SJohn Forte 			": WARNING - Over Temperature"));
4574*fcf3ce44SJohn Forte 	}
4575*fcf3ce44SJohn Forte 	if (temp->ut_warn) {
4576*fcf3ce44SJohn Forte 		(void) fprintf(stdout, MSGSTR(2132,
4577*fcf3ce44SJohn Forte 			": WARNING - Under Temperature"));
4578*fcf3ce44SJohn Forte 	}
4579*fcf3ce44SJohn Forte }
4580*fcf3ce44SJohn Forte 
4581*fcf3ce44SJohn Forte 
4582*fcf3ce44SJohn Forte 
4583*fcf3ce44SJohn Forte /*
4584*fcf3ce44SJohn Forte  * disp_degree() Display temperature in Degrees Celsius.
4585*fcf3ce44SJohn Forte  *
4586*fcf3ce44SJohn Forte  * RETURNS:
4587*fcf3ce44SJohn Forte  *	none.
4588*fcf3ce44SJohn Forte  */
4589*fcf3ce44SJohn Forte void
4590*fcf3ce44SJohn Forte disp_degree(Temp_elem_st *temp)
4591*fcf3ce44SJohn Forte {
4592*fcf3ce44SJohn Forte int	t;
4593*fcf3ce44SJohn Forte 
4594*fcf3ce44SJohn Forte 	t = temp->degrees;
4595*fcf3ce44SJohn Forte 	t -= 20;	/* re-adjust */
4596*fcf3ce44SJohn Forte 	/*
4597*fcf3ce44SJohn Forte 	 * NL_Comment
4598*fcf3ce44SJohn Forte 	 * The %c is the degree symbol.
4599*fcf3ce44SJohn Forte 	 */
4600*fcf3ce44SJohn Forte 	(void) fprintf(stdout, ":%1.2d%cC ", t, 186);
4601*fcf3ce44SJohn Forte }
4602*fcf3ce44SJohn Forte 
4603*fcf3ce44SJohn Forte 
4604*fcf3ce44SJohn Forte 
4605*fcf3ce44SJohn Forte /*
4606*fcf3ce44SJohn Forte  * trans_decode() Display tranceivers state.
4607*fcf3ce44SJohn Forte  *
4608*fcf3ce44SJohn Forte  * RETURNS:
4609*fcf3ce44SJohn Forte  *	none.
4610*fcf3ce44SJohn Forte  */
4611*fcf3ce44SJohn Forte void
4612*fcf3ce44SJohn Forte trans_decode(Trans_elem_st *trans)
4613*fcf3ce44SJohn Forte {
4614*fcf3ce44SJohn Forte 	if (trans->disabled) {
4615*fcf3ce44SJohn Forte 		(void) fprintf(stdout, ": ");
4616*fcf3ce44SJohn Forte 		(void) fprintf(stdout, MSGSTR(34,
4617*fcf3ce44SJohn Forte 			"Disabled"));
4618*fcf3ce44SJohn Forte 	}
4619*fcf3ce44SJohn Forte 	if (trans->lol) {
4620*fcf3ce44SJohn Forte 		(void) fprintf(stdout, MSGSTR(2133,
4621*fcf3ce44SJohn Forte 			": Not receiving a signal"));
4622*fcf3ce44SJohn Forte 	}
4623*fcf3ce44SJohn Forte 	if (trans->lsr_fail) {
4624*fcf3ce44SJohn Forte 		(void) fprintf(stdout, MSGSTR(2134,
4625*fcf3ce44SJohn Forte 			": Laser failed"));
4626*fcf3ce44SJohn Forte 	}
4627*fcf3ce44SJohn Forte }
4628*fcf3ce44SJohn Forte 
4629*fcf3ce44SJohn Forte 
4630*fcf3ce44SJohn Forte 
4631*fcf3ce44SJohn Forte /*
4632*fcf3ce44SJohn Forte  * trans_messages() Display tranceiver status.
4633*fcf3ce44SJohn Forte  *
4634*fcf3ce44SJohn Forte  * NOTE: The decoding of the status assumes that the elements
4635*fcf3ce44SJohn Forte  * are in order with the first two elements are for the
4636*fcf3ce44SJohn Forte  * "A" IB. It also assumes the tranceivers are numbered
4637*fcf3ce44SJohn Forte  * 0 and 1.
4638*fcf3ce44SJohn Forte  *
4639*fcf3ce44SJohn Forte  * RETURNS:
4640*fcf3ce44SJohn Forte  *	none.
4641*fcf3ce44SJohn Forte  */
4642*fcf3ce44SJohn Forte void
4643*fcf3ce44SJohn Forte trans_messages(struct l_state_struct *l_state, int ib_a_flag)
4644*fcf3ce44SJohn Forte {
4645*fcf3ce44SJohn Forte Trans_elem_st	trans;
4646*fcf3ce44SJohn Forte int	i, j, k;
4647*fcf3ce44SJohn Forte int	count = 0;
4648*fcf3ce44SJohn Forte int	elem_index = 0;
4649*fcf3ce44SJohn Forte 
4650*fcf3ce44SJohn Forte 	/* Get and print messages */
4651*fcf3ce44SJohn Forte 	for (i = 0; i < (int)l_state->ib_tbl.config.enc_num_elem; i++) {
4652*fcf3ce44SJohn Forte 	    elem_index++;
4653*fcf3ce44SJohn Forte 	    if (l_state->ib_tbl.config.type_hdr[i].type == ELM_TYP_FL) {
4654*fcf3ce44SJohn Forte 
4655*fcf3ce44SJohn Forte 		if (l_state->ib_tbl.config.type_hdr[i].text_len != 0) {
4656*fcf3ce44SJohn Forte 			(void) fprintf(stdout, "\n\t\t%s\n",
4657*fcf3ce44SJohn Forte 			l_state->ib_tbl.config.text[i]);
4658*fcf3ce44SJohn Forte 		}
4659*fcf3ce44SJohn Forte 		count = k = 0;
4660*fcf3ce44SJohn Forte 
4661*fcf3ce44SJohn Forte 		for (j = 0; j <
4662*fcf3ce44SJohn Forte 			(int)l_state->ib_tbl.config.type_hdr[i].num; j++) {
4663*fcf3ce44SJohn Forte 			/*
4664*fcf3ce44SJohn Forte 			 * Only display the status for the selected IB.
4665*fcf3ce44SJohn Forte 			 */
4666*fcf3ce44SJohn Forte 		    if ((count < 2 && ib_a_flag) ||
4667*fcf3ce44SJohn Forte 				(count >= 2 && !ib_a_flag)) {
4668*fcf3ce44SJohn Forte 			(void) bcopy((const void *)
4669*fcf3ce44SJohn Forte 				&l_state->ib_tbl.p2_s.element[elem_index + j],
4670*fcf3ce44SJohn Forte 				(void *)&trans, sizeof (trans));
4671*fcf3ce44SJohn Forte 
4672*fcf3ce44SJohn Forte 			if (k == 0) {
4673*fcf3ce44SJohn Forte 				(void) fprintf(stdout, "\t\t%d ", k);
4674*fcf3ce44SJohn Forte 			} else {
4675*fcf3ce44SJohn Forte 				(void) fprintf(stdout, "\n\t\t%d ", k);
4676*fcf3ce44SJohn Forte 			}
4677*fcf3ce44SJohn Forte 			if (trans.code == S_OK) {
4678*fcf3ce44SJohn Forte 				(void) fprintf(stdout,
4679*fcf3ce44SJohn Forte 				MSGSTR(29, "O.K."));
4680*fcf3ce44SJohn Forte 				revision_msg(l_state, elem_index + j);
4681*fcf3ce44SJohn Forte 			} else if ((trans.code == S_CRITICAL) ||
4682*fcf3ce44SJohn Forte 				(trans.code == S_NONCRITICAL)) {
4683*fcf3ce44SJohn Forte 				(void) fprintf(stdout,
4684*fcf3ce44SJohn Forte 				MSGSTR(2135, "Failed"));
4685*fcf3ce44SJohn Forte 				revision_msg(l_state, elem_index + j);
4686*fcf3ce44SJohn Forte 				trans_decode(&trans);
4687*fcf3ce44SJohn Forte 			} else if (trans.code == S_NOT_INSTALLED) {
4688*fcf3ce44SJohn Forte 				(void) fprintf(stdout,
4689*fcf3ce44SJohn Forte 				MSGSTR(30, "Not Installed"));
4690*fcf3ce44SJohn Forte 			} else if (trans.code == S_NOT_AVAILABLE) {
4691*fcf3ce44SJohn Forte 				(void) fprintf(stdout,
4692*fcf3ce44SJohn Forte 				MSGSTR(34, "Disabled"));
4693*fcf3ce44SJohn Forte 				revision_msg(l_state, elem_index + j);
4694*fcf3ce44SJohn Forte 			} else {
4695*fcf3ce44SJohn Forte 				(void) fprintf(stdout,
4696*fcf3ce44SJohn Forte 				MSGSTR(4, "Unknown status"));
4697*fcf3ce44SJohn Forte 			}
4698*fcf3ce44SJohn Forte 			k++;
4699*fcf3ce44SJohn Forte 		    }
4700*fcf3ce44SJohn Forte 		    count++;
4701*fcf3ce44SJohn Forte 		}
4702*fcf3ce44SJohn Forte 	    }
4703*fcf3ce44SJohn Forte 		/*
4704*fcf3ce44SJohn Forte 		 * Calculate the index to each element.
4705*fcf3ce44SJohn Forte 		 */
4706*fcf3ce44SJohn Forte 		elem_index += l_state->ib_tbl.config.type_hdr[i].num;
4707*fcf3ce44SJohn Forte 	}
4708*fcf3ce44SJohn Forte 	(void) fprintf(stdout, "\n");
4709*fcf3ce44SJohn Forte }
4710*fcf3ce44SJohn Forte 
4711*fcf3ce44SJohn Forte 
4712*fcf3ce44SJohn Forte 
4713*fcf3ce44SJohn Forte /*
4714*fcf3ce44SJohn Forte  * temperature_messages() Display temperature status.
4715*fcf3ce44SJohn Forte  *
4716*fcf3ce44SJohn Forte  * RETURNS:
4717*fcf3ce44SJohn Forte  *	none.
4718*fcf3ce44SJohn Forte  */
4719*fcf3ce44SJohn Forte void
4720*fcf3ce44SJohn Forte temperature_messages(struct l_state_struct *l_state, int rear_flag)
4721*fcf3ce44SJohn Forte {
4722*fcf3ce44SJohn Forte Temp_elem_st	temp;
4723*fcf3ce44SJohn Forte int	i, j, last_ok = 0;
4724*fcf3ce44SJohn Forte int	all_ok = 1;
4725*fcf3ce44SJohn Forte int	elem_index = 0;
4726*fcf3ce44SJohn Forte 
4727*fcf3ce44SJohn Forte 	/* Get and print messages */
4728*fcf3ce44SJohn Forte 	for (i = 0; i < (int)l_state->ib_tbl.config.enc_num_elem; i++) {
4729*fcf3ce44SJohn Forte 	    elem_index++;	/* skip global */
4730*fcf3ce44SJohn Forte 	    if (l_state->ib_tbl.config.type_hdr[i].type == ELM_TYP_TS) {
4731*fcf3ce44SJohn Forte 		if (!rear_flag) {
4732*fcf3ce44SJohn Forte 		rear_flag = 1;		/* only do front or rear backplane */
4733*fcf3ce44SJohn Forte 		if (l_state->ib_tbl.config.type_hdr[i].text_len != 0) {
4734*fcf3ce44SJohn Forte 			(void) fprintf(stdout, "\t  %s",
4735*fcf3ce44SJohn Forte 			l_state->ib_tbl.config.text[i]);
4736*fcf3ce44SJohn Forte 		}
4737*fcf3ce44SJohn Forte 
4738*fcf3ce44SJohn Forte 		/*
4739*fcf3ce44SJohn Forte 		 * Check global status and if not all O.K.
4740*fcf3ce44SJohn Forte 		 * then print individually.
4741*fcf3ce44SJohn Forte 		 */
4742*fcf3ce44SJohn Forte 		(void) bcopy((const void *)&l_state->ib_tbl.p2_s.element[i],
4743*fcf3ce44SJohn Forte 			(void *)&temp, sizeof (temp));
4744*fcf3ce44SJohn Forte 		for (j = 0; j <
4745*fcf3ce44SJohn Forte 			(int)l_state->ib_tbl.config.type_hdr[i].num; j++) {
4746*fcf3ce44SJohn Forte 			(void) bcopy((const void *)
4747*fcf3ce44SJohn Forte 			&l_state->ib_tbl.p2_s.element[elem_index + j],
4748*fcf3ce44SJohn Forte 				(void *)&temp, sizeof (temp));
4749*fcf3ce44SJohn Forte 
4750*fcf3ce44SJohn Forte 			if ((j == 0) && (temp.code == S_OK) &&
4751*fcf3ce44SJohn Forte 				(!(temp.ot_fail || temp.ot_warn ||
4752*fcf3ce44SJohn Forte 					temp.ut_fail || temp.ut_warn))) {
4753*fcf3ce44SJohn Forte 				(void) fprintf(stdout, "\n\t  %d", j);
4754*fcf3ce44SJohn Forte 			} else if ((j == 6) && (temp.code == S_OK) &&
4755*fcf3ce44SJohn Forte 				all_ok) {
4756*fcf3ce44SJohn Forte 				(void) fprintf(stdout, "\n\t  %d", j);
4757*fcf3ce44SJohn Forte 			} else if (last_ok && (temp.code == S_OK)) {
4758*fcf3ce44SJohn Forte 				(void) fprintf(stdout, "%d", j);
4759*fcf3ce44SJohn Forte 			} else {
4760*fcf3ce44SJohn Forte 				(void) fprintf(stdout, "\n\t\t%d", j);
4761*fcf3ce44SJohn Forte 			}
4762*fcf3ce44SJohn Forte 			if (temp.code == S_OK) {
4763*fcf3ce44SJohn Forte 				disp_degree(&temp);
4764*fcf3ce44SJohn Forte 				if (temp.ot_fail || temp.ot_warn ||
4765*fcf3ce44SJohn Forte 					temp.ut_fail || temp.ut_warn) {
4766*fcf3ce44SJohn Forte 					temp_decode(&temp);
4767*fcf3ce44SJohn Forte 					all_ok = 0;
4768*fcf3ce44SJohn Forte 					last_ok = 0;
4769*fcf3ce44SJohn Forte 				} else {
4770*fcf3ce44SJohn Forte 					last_ok++;
4771*fcf3ce44SJohn Forte 				}
4772*fcf3ce44SJohn Forte 			} else if (temp.code == S_CRITICAL) {
4773*fcf3ce44SJohn Forte 				(void) fprintf(stdout,
4774*fcf3ce44SJohn Forte 				MSGSTR(122, "Critical failure"));
4775*fcf3ce44SJohn Forte 				last_ok = 0;
4776*fcf3ce44SJohn Forte 				all_ok = 0;
4777*fcf3ce44SJohn Forte 			} else if (temp.code == S_NONCRITICAL) {
4778*fcf3ce44SJohn Forte 				(void) fprintf(stdout,
4779*fcf3ce44SJohn Forte 				MSGSTR(89, "Non-Critical Failure"));
4780*fcf3ce44SJohn Forte 				last_ok = 0;
4781*fcf3ce44SJohn Forte 				all_ok = 0;
4782*fcf3ce44SJohn Forte 			} else if (temp.code == S_NOT_INSTALLED) {
4783*fcf3ce44SJohn Forte 				(void) fprintf(stdout,
4784*fcf3ce44SJohn Forte 				MSGSTR(30, "Not Installed"));
4785*fcf3ce44SJohn Forte 				last_ok = 0;
4786*fcf3ce44SJohn Forte 				all_ok = 0;
4787*fcf3ce44SJohn Forte 			} else if (temp.code == S_NOT_AVAILABLE) {
4788*fcf3ce44SJohn Forte 				(void) fprintf(stdout,
4789*fcf3ce44SJohn Forte 				MSGSTR(34, "Disabled"));
4790*fcf3ce44SJohn Forte 				last_ok = 0;
4791*fcf3ce44SJohn Forte 				all_ok = 0;
4792*fcf3ce44SJohn Forte 			} else {
4793*fcf3ce44SJohn Forte 				(void) fprintf(stdout,
4794*fcf3ce44SJohn Forte 				MSGSTR(4, "Unknown status"));
4795*fcf3ce44SJohn Forte 				last_ok = 0;
4796*fcf3ce44SJohn Forte 				all_ok = 0;
4797*fcf3ce44SJohn Forte 			}
4798*fcf3ce44SJohn Forte 		}
4799*fcf3ce44SJohn Forte 		if (all_ok) {
4800*fcf3ce44SJohn Forte 			(void) fprintf(stdout,
4801*fcf3ce44SJohn Forte 			MSGSTR(2136, " (All temperatures are "
4802*fcf3ce44SJohn Forte 			"NORMAL.)"));
4803*fcf3ce44SJohn Forte 		}
4804*fcf3ce44SJohn Forte 		all_ok = 1;
4805*fcf3ce44SJohn Forte 		(void) fprintf(stdout, "\n");
4806*fcf3ce44SJohn Forte 	    } else {
4807*fcf3ce44SJohn Forte 		rear_flag = 0;
4808*fcf3ce44SJohn Forte 	    }
4809*fcf3ce44SJohn Forte 	    }
4810*fcf3ce44SJohn Forte 	    elem_index += l_state->ib_tbl.config.type_hdr[i].num;
4811*fcf3ce44SJohn Forte 	}
4812*fcf3ce44SJohn Forte }
4813*fcf3ce44SJohn Forte 
4814*fcf3ce44SJohn Forte 
4815*fcf3ce44SJohn Forte 
4816*fcf3ce44SJohn Forte /*
4817*fcf3ce44SJohn Forte  * ib_decode() Display IB byte 3 state.
4818*fcf3ce44SJohn Forte  *
4819*fcf3ce44SJohn Forte  * RETURNS:
4820*fcf3ce44SJohn Forte  *	none.
4821*fcf3ce44SJohn Forte  */
4822*fcf3ce44SJohn Forte void
4823*fcf3ce44SJohn Forte ib_decode(Ctlr_elem_st *ctlr)
4824*fcf3ce44SJohn Forte {
4825*fcf3ce44SJohn Forte 	if (ctlr->overtemp_alart) {
4826*fcf3ce44SJohn Forte 		(void) fprintf(stdout, MSGSTR(2137,
4827*fcf3ce44SJohn Forte 			" - IB Over Temperature Alert "));
4828*fcf3ce44SJohn Forte 	}
4829*fcf3ce44SJohn Forte 	if (ctlr->ib_loop_1_fail) {
4830*fcf3ce44SJohn Forte 		(void) fprintf(stdout, MSGSTR(2138,
4831*fcf3ce44SJohn Forte 			" - IB Loop 1 has failed "));
4832*fcf3ce44SJohn Forte 	}
4833*fcf3ce44SJohn Forte 	if (ctlr->ib_loop_0_fail) {
4834*fcf3ce44SJohn Forte 		(void) fprintf(stdout, MSGSTR(2139,
4835*fcf3ce44SJohn Forte 			" - IB Loop 0 has failed "));
4836*fcf3ce44SJohn Forte 	}
4837*fcf3ce44SJohn Forte }
4838*fcf3ce44SJohn Forte 
4839*fcf3ce44SJohn Forte 
4840*fcf3ce44SJohn Forte 
4841*fcf3ce44SJohn Forte /*
4842*fcf3ce44SJohn Forte  * mb_messages() Display motherboard
4843*fcf3ce44SJohn Forte  * (interconnect assembly) messages.
4844*fcf3ce44SJohn Forte  *
4845*fcf3ce44SJohn Forte  * RETURNS:
4846*fcf3ce44SJohn Forte  *	none.
4847*fcf3ce44SJohn Forte  */
4848*fcf3ce44SJohn Forte void
4849*fcf3ce44SJohn Forte mb_messages(struct l_state_struct *l_state, int index, int elem_index)
4850*fcf3ce44SJohn Forte {
4851*fcf3ce44SJohn Forte int		j;
4852*fcf3ce44SJohn Forte Interconnect_st	interconnect;
4853*fcf3ce44SJohn Forte 
4854*fcf3ce44SJohn Forte 	if (l_state->ib_tbl.config.type_hdr[index].text_len != 0) {
4855*fcf3ce44SJohn Forte 		(void) fprintf(stdout, "%s\n",
4856*fcf3ce44SJohn Forte 		l_state->ib_tbl.config.text[index]);
4857*fcf3ce44SJohn Forte 	}
4858*fcf3ce44SJohn Forte 	for (j = 0; j < (int)l_state->ib_tbl.config.type_hdr[index].num;
4859*fcf3ce44SJohn Forte 			j++) {
4860*fcf3ce44SJohn Forte 		(void) bcopy((const void *)
4861*fcf3ce44SJohn Forte 			&l_state->ib_tbl.p2_s.element[elem_index + j],
4862*fcf3ce44SJohn Forte 			(void *)&interconnect, sizeof (interconnect));
4863*fcf3ce44SJohn Forte 		(void) fprintf(stdout, "\t");
4864*fcf3ce44SJohn Forte 
4865*fcf3ce44SJohn Forte 		if (interconnect.code == S_OK) {
4866*fcf3ce44SJohn Forte 			(void) fprintf(stdout,
4867*fcf3ce44SJohn Forte 			MSGSTR(29, "O.K."));
4868*fcf3ce44SJohn Forte 			revision_msg(l_state, elem_index + j);
4869*fcf3ce44SJohn Forte 		} else if (interconnect.code == S_NOT_INSTALLED) {
4870*fcf3ce44SJohn Forte 			(void) fprintf(stdout,
4871*fcf3ce44SJohn Forte 			MSGSTR(30, "Not Installed"));
4872*fcf3ce44SJohn Forte 		} else if (interconnect.code == S_CRITICAL) {
4873*fcf3ce44SJohn Forte 			if (interconnect.eprom_fail != NULL) {
4874*fcf3ce44SJohn Forte 				(void) fprintf(stdout, MSGSTR(2140,
4875*fcf3ce44SJohn Forte 					"Critical Failure: EEPROM failure"));
4876*fcf3ce44SJohn Forte 			} else {
4877*fcf3ce44SJohn Forte 				(void) fprintf(stdout, MSGSTR(2141,
4878*fcf3ce44SJohn Forte 					"Critical Failure: Unknown failure"));
4879*fcf3ce44SJohn Forte 			}
4880*fcf3ce44SJohn Forte 			revision_msg(l_state, elem_index + j);
4881*fcf3ce44SJohn Forte 		} else if (interconnect.code == S_NONCRITICAL) {
4882*fcf3ce44SJohn Forte 			if (interconnect.eprom_fail != NULL) {
4883*fcf3ce44SJohn Forte 				(void) fprintf(stdout, MSGSTR(2142,
4884*fcf3ce44SJohn Forte 				"Non-Critical Failure: EEPROM failure"));
4885*fcf3ce44SJohn Forte 			} else {
4886*fcf3ce44SJohn Forte 				(void) fprintf(stdout, MSGSTR(2143,
4887*fcf3ce44SJohn Forte 				"Non-Critical Failure: Unknown failure"));
4888*fcf3ce44SJohn Forte 			}
4889*fcf3ce44SJohn Forte 			revision_msg(l_state, elem_index + j);
4890*fcf3ce44SJohn Forte 		} else if (interconnect.code == S_NOT_AVAILABLE) {
4891*fcf3ce44SJohn Forte 			(void) fprintf(stdout,
4892*fcf3ce44SJohn Forte 			MSGSTR(34, "Disabled"));
4893*fcf3ce44SJohn Forte 			revision_msg(l_state, elem_index + j);
4894*fcf3ce44SJohn Forte 		} else {
4895*fcf3ce44SJohn Forte 			(void) fprintf(stdout,
4896*fcf3ce44SJohn Forte 			MSGSTR(4, "Unknown status"));
4897*fcf3ce44SJohn Forte 		}
4898*fcf3ce44SJohn Forte 		(void) fprintf(stdout, "\n");
4899*fcf3ce44SJohn Forte 	}
4900*fcf3ce44SJohn Forte 
4901*fcf3ce44SJohn Forte 
4902*fcf3ce44SJohn Forte }
4903*fcf3ce44SJohn Forte 
4904*fcf3ce44SJohn Forte 
4905*fcf3ce44SJohn Forte 
4906*fcf3ce44SJohn Forte /*
4907*fcf3ce44SJohn Forte  * back_plane_messages() Display back_plane messages
4908*fcf3ce44SJohn Forte  * including the temperature's.
4909*fcf3ce44SJohn Forte  *
4910*fcf3ce44SJohn Forte  * RETURNS:
4911*fcf3ce44SJohn Forte  *	none.
4912*fcf3ce44SJohn Forte  */
4913*fcf3ce44SJohn Forte void
4914*fcf3ce44SJohn Forte back_plane_messages(struct l_state_struct *l_state, int index, int elem_index)
4915*fcf3ce44SJohn Forte {
4916*fcf3ce44SJohn Forte Bp_elem_st	bp;
4917*fcf3ce44SJohn Forte int		j;
4918*fcf3ce44SJohn Forte char		status_string[MAXPATHLEN];
4919*fcf3ce44SJohn Forte 
4920*fcf3ce44SJohn Forte 	if (l_state->ib_tbl.config.type_hdr[index].text_len != 0) {
4921*fcf3ce44SJohn Forte 		(void) fprintf(stdout, "%s\n",
4922*fcf3ce44SJohn Forte 		l_state->ib_tbl.config.text[index]);
4923*fcf3ce44SJohn Forte 	}
4924*fcf3ce44SJohn Forte 	for (j = 0; j < (int)l_state->ib_tbl.config.type_hdr[index].num;
4925*fcf3ce44SJohn Forte 			j++) {
4926*fcf3ce44SJohn Forte 		(void) bcopy((const void *)
4927*fcf3ce44SJohn Forte 			&l_state->ib_tbl.p2_s.element[elem_index + j],
4928*fcf3ce44SJohn Forte 			(void *)&bp, sizeof (bp));
4929*fcf3ce44SJohn Forte 		if (j == 0) {
4930*fcf3ce44SJohn Forte 			(void) fprintf(stdout,
4931*fcf3ce44SJohn Forte 				MSGSTR(2144, "\tFront Backplane: "));
4932*fcf3ce44SJohn Forte 		} else {
4933*fcf3ce44SJohn Forte 			(void) fprintf(stdout,
4934*fcf3ce44SJohn Forte 				MSGSTR(2145, "\tRear Backplane:  "));
4935*fcf3ce44SJohn Forte 		}
4936*fcf3ce44SJohn Forte 
4937*fcf3ce44SJohn Forte 		(void) l_element_msg_string(bp.code, status_string);
4938*fcf3ce44SJohn Forte 		(void) fprintf(stdout, "%s", status_string);
4939*fcf3ce44SJohn Forte 
4940*fcf3ce44SJohn Forte 		if (bp.code != S_NOT_INSTALLED) {
4941*fcf3ce44SJohn Forte 			revision_msg(l_state, elem_index + j);
4942*fcf3ce44SJohn Forte 			if ((bp.byp_a_enabled || bp.en_bypass_a) &&
4943*fcf3ce44SJohn Forte 				!(bp.byp_b_enabled || bp.en_bypass_b)) {
4944*fcf3ce44SJohn Forte 				(void) fprintf(stdout, " (");
4945*fcf3ce44SJohn Forte 				(void) fprintf(stdout,
4946*fcf3ce44SJohn Forte 				MSGSTR(130, "Bypass A enabled"));
4947*fcf3ce44SJohn Forte 				(void) fprintf(stdout, ")");
4948*fcf3ce44SJohn Forte 			} else if ((bp.byp_b_enabled || bp.en_bypass_b) &&
4949*fcf3ce44SJohn Forte 				!(bp.byp_a_enabled || bp.en_bypass_a)) {
4950*fcf3ce44SJohn Forte 				(void) fprintf(stdout, " (");
4951*fcf3ce44SJohn Forte 				(void) fprintf(stdout,
4952*fcf3ce44SJohn Forte 				MSGSTR(129, "Bypass B enabled"));
4953*fcf3ce44SJohn Forte 				(void) fprintf(stdout, ")");
4954*fcf3ce44SJohn Forte 			/* This case covers where a and b are bypassed */
4955*fcf3ce44SJohn Forte 			} else if (bp.byp_b_enabled || bp.en_bypass_b) {
4956*fcf3ce44SJohn Forte 				(void) fprintf(stdout,
4957*fcf3ce44SJohn Forte 				MSGSTR(2146, " (Bypass's A & B enabled)"));
4958*fcf3ce44SJohn Forte 			}
4959*fcf3ce44SJohn Forte 			(void) fprintf(stdout, "\n");
4960*fcf3ce44SJohn Forte 			temperature_messages(l_state, j);
4961*fcf3ce44SJohn Forte 		} else {
4962*fcf3ce44SJohn Forte 			(void) fprintf(stdout, "\n");
4963*fcf3ce44SJohn Forte 		}
4964*fcf3ce44SJohn Forte 	}
4965*fcf3ce44SJohn Forte }
4966*fcf3ce44SJohn Forte 
4967*fcf3ce44SJohn Forte 
4968*fcf3ce44SJohn Forte /*
4969*fcf3ce44SJohn Forte  * dpm_SSC100_messages() Display SSC100 messages
4970*fcf3ce44SJohn Forte  * including the temperature's.
4971*fcf3ce44SJohn Forte  *
4972*fcf3ce44SJohn Forte  * RETURNS:
4973*fcf3ce44SJohn Forte  *	none.
4974*fcf3ce44SJohn Forte  */
4975*fcf3ce44SJohn Forte void
4976*fcf3ce44SJohn Forte dpm_SSC100_messages(struct l_state_struct *l_state, int index, int elem_index)
4977*fcf3ce44SJohn Forte {
4978*fcf3ce44SJohn Forte Bp_elem_st	bp;
4979*fcf3ce44SJohn Forte int		j;
4980*fcf3ce44SJohn Forte char		status_string[MAXPATHLEN];
4981*fcf3ce44SJohn Forte 
4982*fcf3ce44SJohn Forte 	if (l_state->ib_tbl.config.type_hdr[index].text_len != 0) {
4983*fcf3ce44SJohn Forte 		(void) fprintf(stdout, "%s\n",
4984*fcf3ce44SJohn Forte 		l_state->ib_tbl.config.text[index]);
4985*fcf3ce44SJohn Forte 	}
4986*fcf3ce44SJohn Forte 	for (j = 0; j < (int)l_state->ib_tbl.config.type_hdr[index].num;
4987*fcf3ce44SJohn Forte 			j++) {
4988*fcf3ce44SJohn Forte 		(void) bcopy((const void *)
4989*fcf3ce44SJohn Forte 			&l_state->ib_tbl.p2_s.element[elem_index + j],
4990*fcf3ce44SJohn Forte 			(void *)&bp, sizeof (bp));
4991*fcf3ce44SJohn Forte 		(void) fprintf(stdout, MSGSTR(2246, "    SSC100 #%d:    "), j);
4992*fcf3ce44SJohn Forte 
4993*fcf3ce44SJohn Forte 		(void) l_element_msg_string(bp.code, status_string);
4994*fcf3ce44SJohn Forte 		(void) fprintf(stdout, "%s", status_string);
4995*fcf3ce44SJohn Forte 
4996*fcf3ce44SJohn Forte 		if (bp.code != S_NOT_INSTALLED) {
4997*fcf3ce44SJohn Forte 			revision_msg(l_state, elem_index + j);
4998*fcf3ce44SJohn Forte 			if ((bp.byp_a_enabled || bp.en_bypass_a) &&
4999*fcf3ce44SJohn Forte 				!(bp.byp_b_enabled || bp.en_bypass_b)) {
5000*fcf3ce44SJohn Forte 				(void) fprintf(stdout, " (");
5001*fcf3ce44SJohn Forte 				(void) fprintf(stdout,
5002*fcf3ce44SJohn Forte 				MSGSTR(130, "Bypass A enabled"));
5003*fcf3ce44SJohn Forte 				(void) fprintf(stdout, ")");
5004*fcf3ce44SJohn Forte 			} else if ((bp.byp_b_enabled || bp.en_bypass_b) &&
5005*fcf3ce44SJohn Forte 				!(bp.byp_a_enabled || bp.en_bypass_a)) {
5006*fcf3ce44SJohn Forte 				(void) fprintf(stdout, " (");
5007*fcf3ce44SJohn Forte 				(void) fprintf(stdout,
5008*fcf3ce44SJohn Forte 				MSGSTR(129, "Bypass B enabled"));
5009*fcf3ce44SJohn Forte 				(void) fprintf(stdout, ")");
5010*fcf3ce44SJohn Forte 			/* This case covers where a and b are bypassed */
5011*fcf3ce44SJohn Forte 			} else if (bp.byp_b_enabled || bp.en_bypass_b) {
5012*fcf3ce44SJohn Forte 				(void) fprintf(stdout,
5013*fcf3ce44SJohn Forte 				MSGSTR(2146, " (Bypass's A & B enabled)"));
5014*fcf3ce44SJohn Forte 			}
5015*fcf3ce44SJohn Forte 			(void) fprintf(stdout, "\n");
5016*fcf3ce44SJohn Forte 		} else {
5017*fcf3ce44SJohn Forte 			(void) fprintf(stdout, "\n");
5018*fcf3ce44SJohn Forte 		}
5019*fcf3ce44SJohn Forte 	}
5020*fcf3ce44SJohn Forte 	temperature_messages(l_state, 0);
5021*fcf3ce44SJohn Forte }
5022*fcf3ce44SJohn Forte 
5023*fcf3ce44SJohn Forte 
5024*fcf3ce44SJohn Forte 
5025*fcf3ce44SJohn Forte 
5026*fcf3ce44SJohn Forte /*
5027*fcf3ce44SJohn Forte  * loop_messages() Display loop messages.
5028*fcf3ce44SJohn Forte  *
5029*fcf3ce44SJohn Forte  * RETURNS:
5030*fcf3ce44SJohn Forte  *	none.
5031*fcf3ce44SJohn Forte  */
5032*fcf3ce44SJohn Forte void
5033*fcf3ce44SJohn Forte loop_messages(struct l_state_struct *l_state, int index, int elem_index)
5034*fcf3ce44SJohn Forte {
5035*fcf3ce44SJohn Forte Loop_elem_st	loop;
5036*fcf3ce44SJohn Forte int		j;
5037*fcf3ce44SJohn Forte 
5038*fcf3ce44SJohn Forte 	if (l_state->ib_tbl.config.type_hdr[index].text_len != 0) {
5039*fcf3ce44SJohn Forte 		(void) fprintf(stdout, "%s\n",
5040*fcf3ce44SJohn Forte 		l_state->ib_tbl.config.text[index]);
5041*fcf3ce44SJohn Forte 	}
5042*fcf3ce44SJohn Forte 	for (j = 0; j < (int)l_state->ib_tbl.config.type_hdr[index].num;
5043*fcf3ce44SJohn Forte 			j++) {
5044*fcf3ce44SJohn Forte 		(void) bcopy((const void *)
5045*fcf3ce44SJohn Forte 			&l_state->ib_tbl.p2_s.element[elem_index + j],
5046*fcf3ce44SJohn Forte 			(void *)&loop, sizeof (loop));
5047*fcf3ce44SJohn Forte 
5048*fcf3ce44SJohn Forte 		(void) fprintf(stdout, "\t");
5049*fcf3ce44SJohn Forte 		if (j == 0) {
5050*fcf3ce44SJohn Forte 			if (loop.code == S_NOT_INSTALLED) {
5051*fcf3ce44SJohn Forte 				(void) fprintf(stdout,
5052*fcf3ce44SJohn Forte 				MSGSTR(2147, "Loop A is not installed"));
5053*fcf3ce44SJohn Forte 			} else {
5054*fcf3ce44SJohn Forte 				if (loop.split) {
5055*fcf3ce44SJohn Forte 					(void) fprintf(stdout, MSGSTR(2148,
5056*fcf3ce44SJohn Forte 				"Loop A is configured as two separate loops."));
5057*fcf3ce44SJohn Forte 				} else {
5058*fcf3ce44SJohn Forte 					(void) fprintf(stdout, MSGSTR(2149,
5059*fcf3ce44SJohn Forte 				"Loop A is configured as a single loop."));
5060*fcf3ce44SJohn Forte 				}
5061*fcf3ce44SJohn Forte 			}
5062*fcf3ce44SJohn Forte 		} else {
5063*fcf3ce44SJohn Forte 			if (loop.code == S_NOT_INSTALLED) {
5064*fcf3ce44SJohn Forte 				(void) fprintf(stdout,
5065*fcf3ce44SJohn Forte 				MSGSTR(2150, "Loop B is not installed"));
5066*fcf3ce44SJohn Forte 			} else {
5067*fcf3ce44SJohn Forte 				if (loop.split) {
5068*fcf3ce44SJohn Forte 					(void) fprintf(stdout, MSGSTR(2151,
5069*fcf3ce44SJohn Forte 				"Loop B is configured as two separate loops."));
5070*fcf3ce44SJohn Forte 				} else {
5071*fcf3ce44SJohn Forte 					(void) fprintf(stdout, MSGSTR(2152,
5072*fcf3ce44SJohn Forte 				"Loop B is configured as a single loop."));
5073*fcf3ce44SJohn Forte 				}
5074*fcf3ce44SJohn Forte 			}
5075*fcf3ce44SJohn Forte 		}
5076*fcf3ce44SJohn Forte 		(void) fprintf(stdout, "\n");
5077*fcf3ce44SJohn Forte 	}
5078*fcf3ce44SJohn Forte }
5079*fcf3ce44SJohn Forte 
5080*fcf3ce44SJohn Forte 
5081*fcf3ce44SJohn Forte 
5082*fcf3ce44SJohn Forte /*
5083*fcf3ce44SJohn Forte  * ctlr_messages() Display ESI Controller status.
5084*fcf3ce44SJohn Forte  *
5085*fcf3ce44SJohn Forte  * RETURNS:
5086*fcf3ce44SJohn Forte  *	none.
5087*fcf3ce44SJohn Forte  */
5088*fcf3ce44SJohn Forte void
5089*fcf3ce44SJohn Forte ctlr_messages(struct l_state_struct *l_state, int index, int elem_index)
5090*fcf3ce44SJohn Forte {
5091*fcf3ce44SJohn Forte Ctlr_elem_st	ctlr;
5092*fcf3ce44SJohn Forte int		j;
5093*fcf3ce44SJohn Forte int		ib_a_flag = 1;
5094*fcf3ce44SJohn Forte 
5095*fcf3ce44SJohn Forte 	if (l_state->ib_tbl.config.type_hdr[index].text_len != 0) {
5096*fcf3ce44SJohn Forte 		(void) fprintf(stdout, "%s\n",
5097*fcf3ce44SJohn Forte 		l_state->ib_tbl.config.text[index]);
5098*fcf3ce44SJohn Forte 	}
5099*fcf3ce44SJohn Forte 	for (j = 0; j < (int)l_state->ib_tbl.config.type_hdr[index].num;
5100*fcf3ce44SJohn Forte 			j++) {
5101*fcf3ce44SJohn Forte 		(void) bcopy((const void *)
5102*fcf3ce44SJohn Forte 			&l_state->ib_tbl.p2_s.element[elem_index + j],
5103*fcf3ce44SJohn Forte 			(void *)&ctlr, sizeof (ctlr));
5104*fcf3ce44SJohn Forte 		if (j == 0) {
5105*fcf3ce44SJohn Forte 			(void) fprintf(stdout, MSGSTR(2153, "\tA: "));
5106*fcf3ce44SJohn Forte 		} else {
5107*fcf3ce44SJohn Forte 			(void) fprintf(stdout, MSGSTR(2154, "\tB: "));
5108*fcf3ce44SJohn Forte 			ib_a_flag = 0;
5109*fcf3ce44SJohn Forte 		}
5110*fcf3ce44SJohn Forte 		if (ctlr.code == S_OK) {
5111*fcf3ce44SJohn Forte 			(void) fprintf(stdout, MSGSTR(29, "O.K."));
5112*fcf3ce44SJohn Forte 			/* If any byte 3 bits set display */
5113*fcf3ce44SJohn Forte 			ib_decode(&ctlr);
5114*fcf3ce44SJohn Forte 			/* Display Version message */
5115*fcf3ce44SJohn Forte 			revision_msg(l_state, elem_index + j);
5116*fcf3ce44SJohn Forte 			/*
5117*fcf3ce44SJohn Forte 			 * Display the tranciver module state for this
5118*fcf3ce44SJohn Forte 			 * IB.
5119*fcf3ce44SJohn Forte 			 */
5120*fcf3ce44SJohn Forte 			trans_messages(l_state, ib_a_flag);
5121*fcf3ce44SJohn Forte 		} else if (ctlr.code == S_CRITICAL) {
5122*fcf3ce44SJohn Forte 			(void) fprintf(stdout,
5123*fcf3ce44SJohn Forte 			MSGSTR(122, "Critical failure"));
5124*fcf3ce44SJohn Forte 			ib_decode(&ctlr);
5125*fcf3ce44SJohn Forte 			(void) fprintf(stdout, "\n");
5126*fcf3ce44SJohn Forte 		} else if (ctlr.code == S_NONCRITICAL) {
5127*fcf3ce44SJohn Forte 			(void) fprintf(stdout,
5128*fcf3ce44SJohn Forte 			MSGSTR(89, "Non-Critical Failure"));
5129*fcf3ce44SJohn Forte 			ib_decode(&ctlr);
5130*fcf3ce44SJohn Forte 			(void) fprintf(stdout, "\n");
5131*fcf3ce44SJohn Forte 		} else if (ctlr.code == S_NOT_INSTALLED) {
5132*fcf3ce44SJohn Forte 			(void) fprintf(stdout,
5133*fcf3ce44SJohn Forte 			MSGSTR(30, "Not Installed"));
5134*fcf3ce44SJohn Forte 			(void) fprintf(stdout, "\n");
5135*fcf3ce44SJohn Forte 		} else if (ctlr.code == S_NOT_AVAILABLE) {
5136*fcf3ce44SJohn Forte 			(void) fprintf(stdout,
5137*fcf3ce44SJohn Forte 			MSGSTR(34, "Disabled"));
5138*fcf3ce44SJohn Forte 			(void) fprintf(stdout, "\n");
5139*fcf3ce44SJohn Forte 		} else {
5140*fcf3ce44SJohn Forte 			(void) fprintf(stdout,
5141*fcf3ce44SJohn Forte 			MSGSTR(4, "Unknown status"));
5142*fcf3ce44SJohn Forte 			(void) fprintf(stdout, "\n");
5143*fcf3ce44SJohn Forte 		}
5144*fcf3ce44SJohn Forte 	}
5145*fcf3ce44SJohn Forte }
5146*fcf3ce44SJohn Forte 
5147*fcf3ce44SJohn Forte 
5148*fcf3ce44SJohn Forte 
5149*fcf3ce44SJohn Forte /*
5150*fcf3ce44SJohn Forte  * fan_decode() Display Fans bytes 1-3 state.
5151*fcf3ce44SJohn Forte  *
5152*fcf3ce44SJohn Forte  * RETURNS:
5153*fcf3ce44SJohn Forte  *	none.
5154*fcf3ce44SJohn Forte  */
5155*fcf3ce44SJohn Forte void
5156*fcf3ce44SJohn Forte fan_decode(Fan_elem_st *fan)
5157*fcf3ce44SJohn Forte {
5158*fcf3ce44SJohn Forte 	if (fan->fail) {
5159*fcf3ce44SJohn Forte 		(void) fprintf(stdout, MSGSTR(2155,
5160*fcf3ce44SJohn Forte 			":Yellow LED is on"));
5161*fcf3ce44SJohn Forte 	}
5162*fcf3ce44SJohn Forte 	if (fan->speed == 0) {
5163*fcf3ce44SJohn Forte 		(void) fprintf(stdout, MSGSTR(2156,
5164*fcf3ce44SJohn Forte 			":Fan stopped"));
5165*fcf3ce44SJohn Forte 	} else if (fan->speed < S_HI_SPEED) {
5166*fcf3ce44SJohn Forte 		(void) fprintf(stdout, MSGSTR(2157,
5167*fcf3ce44SJohn Forte 			":Fan speed Low"));
5168*fcf3ce44SJohn Forte 	} else {
5169*fcf3ce44SJohn Forte 		(void) fprintf(stdout, MSGSTR(2158,
5170*fcf3ce44SJohn Forte 			":Fan speed Hi"));
5171*fcf3ce44SJohn Forte 	}
5172*fcf3ce44SJohn Forte }
5173*fcf3ce44SJohn Forte 
5174*fcf3ce44SJohn Forte /*
5175*fcf3ce44SJohn Forte  * fan_messages() Display Fan status.
5176*fcf3ce44SJohn Forte  *
5177*fcf3ce44SJohn Forte  * RETURNS:
5178*fcf3ce44SJohn Forte  *	none.
5179*fcf3ce44SJohn Forte  */
5180*fcf3ce44SJohn Forte void
5181*fcf3ce44SJohn Forte fan_messages(struct l_state_struct *l_state, int hdr_index, int elem_index)
5182*fcf3ce44SJohn Forte {
5183*fcf3ce44SJohn Forte Fan_elem_st	fan;
5184*fcf3ce44SJohn Forte int	j;
5185*fcf3ce44SJohn Forte 
5186*fcf3ce44SJohn Forte 	/* Get and print messages */
5187*fcf3ce44SJohn Forte 	if (l_state->ib_tbl.config.type_hdr[hdr_index].text_len != 0) {
5188*fcf3ce44SJohn Forte 		(void) fprintf(stdout, "%s\n",
5189*fcf3ce44SJohn Forte 		l_state->ib_tbl.config.text[hdr_index]);
5190*fcf3ce44SJohn Forte 	}
5191*fcf3ce44SJohn Forte 	for (j = 0; j < (int)l_state->ib_tbl.config.type_hdr[hdr_index].num;
5192*fcf3ce44SJohn Forte 			j++) {
5193*fcf3ce44SJohn Forte 		(void) bcopy((const void *)
5194*fcf3ce44SJohn Forte 			&l_state->ib_tbl.p2_s.element[elem_index + j],
5195*fcf3ce44SJohn Forte 			(void *)&fan, sizeof (fan));
5196*fcf3ce44SJohn Forte 		(void) fprintf(stdout, "\t%d ", j);
5197*fcf3ce44SJohn Forte 		if (fan.code == S_OK) {
5198*fcf3ce44SJohn Forte 			(void) fprintf(stdout, MSGSTR(29, "O.K."));
5199*fcf3ce44SJohn Forte 			revision_msg(l_state, elem_index + j);
5200*fcf3ce44SJohn Forte 		} else if (fan.code == S_CRITICAL) {
5201*fcf3ce44SJohn Forte 			(void) fprintf(stdout,
5202*fcf3ce44SJohn Forte 			MSGSTR(122, "Critical failure"));
5203*fcf3ce44SJohn Forte 			fan_decode(&fan);
5204*fcf3ce44SJohn Forte 			revision_msg(l_state, elem_index + j);
5205*fcf3ce44SJohn Forte 		} else if (fan.code == S_NONCRITICAL) {
5206*fcf3ce44SJohn Forte 			(void) fprintf(stdout,
5207*fcf3ce44SJohn Forte 			MSGSTR(89, "Non-Critical Failure"));
5208*fcf3ce44SJohn Forte 			fan_decode(&fan);
5209*fcf3ce44SJohn Forte 			revision_msg(l_state, elem_index + j);
5210*fcf3ce44SJohn Forte 		} else if (fan.code == S_NOT_INSTALLED) {
5211*fcf3ce44SJohn Forte 			(void) fprintf(stdout,
5212*fcf3ce44SJohn Forte 			MSGSTR(30, "Not Installed"));
5213*fcf3ce44SJohn Forte 		} else if (fan.code == S_NOT_AVAILABLE) {
5214*fcf3ce44SJohn Forte 			(void) fprintf(stdout,
5215*fcf3ce44SJohn Forte 			MSGSTR(34, "Disabled"));
5216*fcf3ce44SJohn Forte 			revision_msg(l_state, elem_index + j);
5217*fcf3ce44SJohn Forte 		} else {
5218*fcf3ce44SJohn Forte 			(void) fprintf(stdout,
5219*fcf3ce44SJohn Forte 			MSGSTR(4, "Unknown status"));
5220*fcf3ce44SJohn Forte 		}
5221*fcf3ce44SJohn Forte 	}
5222*fcf3ce44SJohn Forte 	(void) fprintf(stdout, "\n");
5223*fcf3ce44SJohn Forte }
5224*fcf3ce44SJohn Forte 
5225*fcf3ce44SJohn Forte 
5226*fcf3ce44SJohn Forte 
5227*fcf3ce44SJohn Forte /*
5228*fcf3ce44SJohn Forte  * ps_decode() Display Power Supply bytes 1-3 state.
5229*fcf3ce44SJohn Forte  *
5230*fcf3ce44SJohn Forte  * RETURNS:
5231*fcf3ce44SJohn Forte  *	none.
5232*fcf3ce44SJohn Forte  */
5233*fcf3ce44SJohn Forte void
5234*fcf3ce44SJohn Forte ps_decode(Ps_elem_st *ps)
5235*fcf3ce44SJohn Forte {
5236*fcf3ce44SJohn Forte 	if (ps->dc_over) {
5237*fcf3ce44SJohn Forte 		(void) fprintf(stdout, MSGSTR(2159,
5238*fcf3ce44SJohn Forte 			": DC Voltage too high"));
5239*fcf3ce44SJohn Forte 	}
5240*fcf3ce44SJohn Forte 	if (ps->dc_under) {
5241*fcf3ce44SJohn Forte 		(void) fprintf(stdout, MSGSTR(2160,
5242*fcf3ce44SJohn Forte 			": DC Voltage too low"));
5243*fcf3ce44SJohn Forte 	}
5244*fcf3ce44SJohn Forte 	if (ps->dc_over_i) {
5245*fcf3ce44SJohn Forte 		(void) fprintf(stdout, MSGSTR(2161,
5246*fcf3ce44SJohn Forte 			": DC Current too high"));
5247*fcf3ce44SJohn Forte 	}
5248*fcf3ce44SJohn Forte 	if (ps->ovrtmp_fail || ps->temp_warn) {
5249*fcf3ce44SJohn Forte 		(void) fprintf(stdout, MSGSTR(2162,
5250*fcf3ce44SJohn Forte 			": Temperature too high"));
5251*fcf3ce44SJohn Forte 	}
5252*fcf3ce44SJohn Forte 	if (ps->ac_fail) {
5253*fcf3ce44SJohn Forte 		(void) fprintf(stdout, MSGSTR(2163,
5254*fcf3ce44SJohn Forte 			": AC Failed"));
5255*fcf3ce44SJohn Forte 	}
5256*fcf3ce44SJohn Forte 	if (ps->dc_fail) {
5257*fcf3ce44SJohn Forte 		(void) fprintf(stdout, MSGSTR(2164,
5258*fcf3ce44SJohn Forte 			": DC Failed"));
5259*fcf3ce44SJohn Forte 	}
5260*fcf3ce44SJohn Forte }
5261*fcf3ce44SJohn Forte 
5262*fcf3ce44SJohn Forte 
5263*fcf3ce44SJohn Forte 
5264*fcf3ce44SJohn Forte /*
5265*fcf3ce44SJohn Forte  * revision_msg() Print the revision message from page 7.
5266*fcf3ce44SJohn Forte  *
5267*fcf3ce44SJohn Forte  * RETURNS:
5268*fcf3ce44SJohn Forte  *	none.
5269*fcf3ce44SJohn Forte  */
5270*fcf3ce44SJohn Forte void
5271*fcf3ce44SJohn Forte revision_msg(struct l_state_struct *l_state, int index)
5272*fcf3ce44SJohn Forte {
5273*fcf3ce44SJohn Forte 	if (strlen((const char *)
5274*fcf3ce44SJohn Forte 		l_state->ib_tbl.p7_s.element_desc[index].desc_string)) {
5275*fcf3ce44SJohn Forte 		(void) fprintf(stdout, "(%s)",
5276*fcf3ce44SJohn Forte 		l_state->ib_tbl.p7_s.element_desc[index].desc_string);
5277*fcf3ce44SJohn Forte 	}
5278*fcf3ce44SJohn Forte }
5279*fcf3ce44SJohn Forte 
5280*fcf3ce44SJohn Forte 
5281*fcf3ce44SJohn Forte 
5282*fcf3ce44SJohn Forte /*
5283*fcf3ce44SJohn Forte  * ps_messages() Display Power Supply status.
5284*fcf3ce44SJohn Forte  *
5285*fcf3ce44SJohn Forte  * RETURNS:
5286*fcf3ce44SJohn Forte  *	none.
5287*fcf3ce44SJohn Forte  */
5288*fcf3ce44SJohn Forte void
5289*fcf3ce44SJohn Forte ps_messages(struct l_state_struct *l_state, int	index, int elem_index)
5290*fcf3ce44SJohn Forte {
5291*fcf3ce44SJohn Forte Ps_elem_st	ps;
5292*fcf3ce44SJohn Forte int	j;
5293*fcf3ce44SJohn Forte 
5294*fcf3ce44SJohn Forte 	/* Get and print Power Supply messages */
5295*fcf3ce44SJohn Forte 
5296*fcf3ce44SJohn Forte 	if (l_state->ib_tbl.config.type_hdr[index].text_len != 0) {
5297*fcf3ce44SJohn Forte 		(void) fprintf(stdout, "%s\n",
5298*fcf3ce44SJohn Forte 		l_state->ib_tbl.config.text[index]);
5299*fcf3ce44SJohn Forte 	}
5300*fcf3ce44SJohn Forte 
5301*fcf3ce44SJohn Forte 	for (j = 0; j < (int)l_state->ib_tbl.config.type_hdr[index].num;
5302*fcf3ce44SJohn Forte 		j++) {
5303*fcf3ce44SJohn Forte 		(void) bcopy((const void *)
5304*fcf3ce44SJohn Forte 			&l_state->ib_tbl.p2_s.element[elem_index + j],
5305*fcf3ce44SJohn Forte 			(void *)&ps, sizeof (ps));
5306*fcf3ce44SJohn Forte 		(void) fprintf(stdout, "\t%d ", j);
5307*fcf3ce44SJohn Forte 		if (ps.code == S_OK) {
5308*fcf3ce44SJohn Forte 			(void) fprintf(stdout, MSGSTR(29, "O.K."));
5309*fcf3ce44SJohn Forte 			revision_msg(l_state, elem_index + j);
5310*fcf3ce44SJohn Forte 		} else if (ps.code == S_CRITICAL) {
5311*fcf3ce44SJohn Forte 			(void) fprintf(stdout,
5312*fcf3ce44SJohn Forte 			MSGSTR(122, "Critical failure"));
5313*fcf3ce44SJohn Forte 			ps_decode(&ps);
5314*fcf3ce44SJohn Forte 			revision_msg(l_state, elem_index + j);
5315*fcf3ce44SJohn Forte 		} else if (ps.code == S_NONCRITICAL) {
5316*fcf3ce44SJohn Forte 			(void) fprintf(stdout,
5317*fcf3ce44SJohn Forte 			MSGSTR(89, "Non-Critical Failure"));
5318*fcf3ce44SJohn Forte 			ps_decode(&ps);
5319*fcf3ce44SJohn Forte 			revision_msg(l_state, elem_index + j);
5320*fcf3ce44SJohn Forte 		} else if (ps.code == S_NOT_INSTALLED) {
5321*fcf3ce44SJohn Forte 			(void) fprintf(stdout,
5322*fcf3ce44SJohn Forte 			MSGSTR(30, "Not Installed"));
5323*fcf3ce44SJohn Forte 		} else if (ps.code == S_NOT_AVAILABLE) {
5324*fcf3ce44SJohn Forte 			(void) fprintf(stdout,
5325*fcf3ce44SJohn Forte 			MSGSTR(34, "Disabled"));
5326*fcf3ce44SJohn Forte 			revision_msg(l_state, elem_index + j);
5327*fcf3ce44SJohn Forte 		} else {
5328*fcf3ce44SJohn Forte 			(void) fprintf(stdout,
5329*fcf3ce44SJohn Forte 			MSGSTR(4, "Unknown status"));
5330*fcf3ce44SJohn Forte 		}
5331*fcf3ce44SJohn Forte 
5332*fcf3ce44SJohn Forte 	}
5333*fcf3ce44SJohn Forte 	(void) fprintf(stdout, "\n");
5334*fcf3ce44SJohn Forte }
5335*fcf3ce44SJohn Forte 
5336*fcf3ce44SJohn Forte 
5337*fcf3ce44SJohn Forte 
5338*fcf3ce44SJohn Forte /*
5339*fcf3ce44SJohn Forte  * abnormal_condition() Display any abnormal condition messages.
5340*fcf3ce44SJohn Forte  *
5341*fcf3ce44SJohn Forte  * RETURNS:
5342*fcf3ce44SJohn Forte  *	none.
5343*fcf3ce44SJohn Forte  */
5344*fcf3ce44SJohn Forte void
5345*fcf3ce44SJohn Forte abnormal_condition_display(struct l_state_struct *l_state)
5346*fcf3ce44SJohn Forte {
5347*fcf3ce44SJohn Forte 
5348*fcf3ce44SJohn Forte 	(void) fprintf(stdout, "\n");
5349*fcf3ce44SJohn Forte 	if (l_state->ib_tbl.p2_s.ui.crit) {
5350*fcf3ce44SJohn Forte 		(void) fprintf(stdout,
5351*fcf3ce44SJohn Forte 			MSGSTR(2165, "                         "
5352*fcf3ce44SJohn Forte 			"CRITICAL CONDITION DETECTED\n"));
5353*fcf3ce44SJohn Forte 	}
5354*fcf3ce44SJohn Forte 	if (l_state->ib_tbl.p2_s.ui.non_crit) {
5355*fcf3ce44SJohn Forte 		(void) fprintf(stdout,
5356*fcf3ce44SJohn Forte 			MSGSTR(2166, "                   "
5357*fcf3ce44SJohn Forte 			"WARNING: NON-CRITICAL CONDITION DETECTED\n"));
5358*fcf3ce44SJohn Forte 	}
5359*fcf3ce44SJohn Forte 	if (l_state->ib_tbl.p2_s.ui.invop) {
5360*fcf3ce44SJohn Forte 		(void) fprintf(stdout,
5361*fcf3ce44SJohn Forte 			MSGSTR(2167, "                      "
5362*fcf3ce44SJohn Forte 			"WARNING: Invalid Operation bit set.\n"
5363*fcf3ce44SJohn Forte 			"\tThis means an Enclosure Control page"
5364*fcf3ce44SJohn Forte 			" or an Array Control page with an invalid\n"
5365*fcf3ce44SJohn Forte 			"\tformat has previously been transmitted to the"
5366*fcf3ce44SJohn Forte 			" Enclosure Services card by a\n\tSend Diagnostic"
5367*fcf3ce44SJohn Forte 			" SCSI command.\n"));
5368*fcf3ce44SJohn Forte 	}
5369*fcf3ce44SJohn Forte 	(void) fprintf(stdout, "\n");
5370*fcf3ce44SJohn Forte }
5371*fcf3ce44SJohn Forte 
5372*fcf3ce44SJohn Forte 
5373*fcf3ce44SJohn Forte 
5374*fcf3ce44SJohn Forte 
5375*fcf3ce44SJohn Forte 
5376*fcf3ce44SJohn Forte /*
5377*fcf3ce44SJohn Forte  * adm_start() Spin up the given list
5378*fcf3ce44SJohn Forte  * of SENA devices.
5379*fcf3ce44SJohn Forte  *
5380*fcf3ce44SJohn Forte  * RETURNS:
5381*fcf3ce44SJohn Forte  *	none.
5382*fcf3ce44SJohn Forte  */
5383*fcf3ce44SJohn Forte int
5384*fcf3ce44SJohn Forte adm_start(char **argv)
5385*fcf3ce44SJohn Forte {
5386*fcf3ce44SJohn Forte char		*path_phys = NULL;
5387*fcf3ce44SJohn Forte Path_struct	*path_struct;
5388*fcf3ce44SJohn Forte int		err = 0, retval = 0;
5389*fcf3ce44SJohn Forte 
5390*fcf3ce44SJohn Forte 	while (*argv != NULL) {
5391*fcf3ce44SJohn Forte 		if ((err = l_convert_name(*argv, &path_phys,
5392*fcf3ce44SJohn Forte 			&path_struct, Options & PVERBOSE)) != 0) {
5393*fcf3ce44SJohn Forte 			(void) fprintf(stderr, MSGSTR(33,
5394*fcf3ce44SJohn Forte 				" Error: converting"
5395*fcf3ce44SJohn Forte 				" %s to physical path.\n"
5396*fcf3ce44SJohn Forte 				" Invalid pathname.\n"),
5397*fcf3ce44SJohn Forte 				*argv);
5398*fcf3ce44SJohn Forte 		if (err != -1) {
5399*fcf3ce44SJohn Forte 			(void) print_errString(err, *argv);
5400*fcf3ce44SJohn Forte 		}
5401*fcf3ce44SJohn Forte 		(argv)++;
5402*fcf3ce44SJohn Forte 		retval++;
5403*fcf3ce44SJohn Forte 		continue;
5404*fcf3ce44SJohn Forte 	    }
5405*fcf3ce44SJohn Forte 	    VERBPRINT(MSGSTR(101, "Issuing start to:\n %s\n"), *argv);
5406*fcf3ce44SJohn Forte 	    if (err = g_start(path_phys))  {
5407*fcf3ce44SJohn Forte 		(void) print_errString(err, *argv);
5408*fcf3ce44SJohn Forte 		(argv)++;
5409*fcf3ce44SJohn Forte 		retval++;
5410*fcf3ce44SJohn Forte 		continue;
5411*fcf3ce44SJohn Forte 	    }
5412*fcf3ce44SJohn Forte 	    (argv)++;
5413*fcf3ce44SJohn Forte 	}
5414*fcf3ce44SJohn Forte 	return (retval);
5415*fcf3ce44SJohn Forte }
5416*fcf3ce44SJohn Forte 
5417*fcf3ce44SJohn Forte 
5418*fcf3ce44SJohn Forte 
5419*fcf3ce44SJohn Forte /*
5420*fcf3ce44SJohn Forte  * adm_stop() Spin down a
5421*fcf3ce44SJohn Forte  * given list of SENA devices.
5422*fcf3ce44SJohn Forte  *
5423*fcf3ce44SJohn Forte  * RETURNS:
5424*fcf3ce44SJohn Forte  *	none.
5425*fcf3ce44SJohn Forte  */
5426*fcf3ce44SJohn Forte int
5427*fcf3ce44SJohn Forte adm_stop(char **argv)
5428*fcf3ce44SJohn Forte {
5429*fcf3ce44SJohn Forte char		*path_phys = NULL;
5430*fcf3ce44SJohn Forte Path_struct	*path_struct;
5431*fcf3ce44SJohn Forte int		err = 0, retval = 0;
5432*fcf3ce44SJohn Forte 
5433*fcf3ce44SJohn Forte 	while (*argv != NULL) {
5434*fcf3ce44SJohn Forte 		if ((err = l_convert_name(*argv, &path_phys,
5435*fcf3ce44SJohn Forte 		    &path_struct, Options & PVERBOSE)) != 0) {
5436*fcf3ce44SJohn Forte 			(void) fprintf(stderr,
5437*fcf3ce44SJohn Forte 			    MSGSTR(33,
5438*fcf3ce44SJohn Forte 			    " Error: converting"
5439*fcf3ce44SJohn Forte 			    " %s to physical path.\n"
5440*fcf3ce44SJohn Forte 			    " Invalid pathname.\n"),
5441*fcf3ce44SJohn Forte 			    *argv);
5442*fcf3ce44SJohn Forte 			if (err != -1) {
5443*fcf3ce44SJohn Forte 				(void) print_errString(err, *argv);
5444*fcf3ce44SJohn Forte 			}
5445*fcf3ce44SJohn Forte 			(argv)++;
5446*fcf3ce44SJohn Forte 			retval++;
5447*fcf3ce44SJohn Forte 			continue;
5448*fcf3ce44SJohn Forte 		}
5449*fcf3ce44SJohn Forte 
5450*fcf3ce44SJohn Forte 		/*
5451*fcf3ce44SJohn Forte 		 * scsi stop is not supported for tape drives.
5452*fcf3ce44SJohn Forte 		 * The scsi unload op code for tape is the same as a
5453*fcf3ce44SJohn Forte 		 * scsi stop for disk so this command will eject the tape.
5454*fcf3ce44SJohn Forte 		 * If an eject is the desired behavior then remove the
5455*fcf3ce44SJohn Forte 		 * following if block. ('mt offline' will give you
5456*fcf3ce44SJohn Forte 		 * the same eject functionality).
5457*fcf3ce44SJohn Forte 		 */
5458*fcf3ce44SJohn Forte 		if (strstr(path_phys, SLSH_DRV_NAME_ST)) {
5459*fcf3ce44SJohn Forte 			errno = ENOTSUP;
5460*fcf3ce44SJohn Forte 			(void) print_errString(0, path_phys);
5461*fcf3ce44SJohn Forte 			(argv)++;
5462*fcf3ce44SJohn Forte 			continue;
5463*fcf3ce44SJohn Forte 		}
5464*fcf3ce44SJohn Forte 
5465*fcf3ce44SJohn Forte 		VERBPRINT(MSGSTR(100, "Issuing stop to:\n %s\n"), *argv);
5466*fcf3ce44SJohn Forte 			if (err = g_stop(path_phys, 1))  {
5467*fcf3ce44SJohn Forte 			(void) print_errString(err, *argv);
5468*fcf3ce44SJohn Forte 			(argv)++;
5469*fcf3ce44SJohn Forte 			retval++;
5470*fcf3ce44SJohn Forte 			continue;
5471*fcf3ce44SJohn Forte 		}
5472*fcf3ce44SJohn Forte 		(argv)++;
5473*fcf3ce44SJohn Forte 	}
5474*fcf3ce44SJohn Forte 	return (retval);
5475*fcf3ce44SJohn Forte }
5476*fcf3ce44SJohn Forte 
5477*fcf3ce44SJohn Forte 
5478*fcf3ce44SJohn Forte /*
5479*fcf3ce44SJohn Forte  * On a SOC+ chip, the port is either put into (offline) or pulled out
5480*fcf3ce44SJohn Forte  * of (online) a loopback mode since the laser cannot be turned on or off.
5481*fcf3ce44SJohn Forte  * As of this writing, this feature is yet to be supported by the ifp
5482*fcf3ce44SJohn Forte  * driver on a QLogic card.
5483*fcf3ce44SJohn Forte  *
5484*fcf3ce44SJohn Forte  * INPUT :
5485*fcf3ce44SJohn Forte  *	Command line args and flag - LUX_P_ONLINE or LUX_P_OFFLINE
5486*fcf3ce44SJohn Forte  *	The path that is passed has to be the physical path to the port.
5487*fcf3ce44SJohn Forte  *	For example :
5488*fcf3ce44SJohn Forte  *	/devices/sbus@2,0/SUNW,socal@2,0:0
5489*fcf3ce44SJohn Forte  *	/devices/io-unit@f,e0200000/sbi@0,0/SUNW,socal@2,0:0
5490*fcf3ce44SJohn Forte  *	/devices/pci@1f,4000/SUNW,ifp@2:devctl
5491*fcf3ce44SJohn Forte  * RETURNS :
5492*fcf3ce44SJohn Forte  *	Nothing
5493*fcf3ce44SJohn Forte  */
5494*fcf3ce44SJohn Forte int
5495*fcf3ce44SJohn Forte adm_port_offline_online(char *argv[], int flag)
5496*fcf3ce44SJohn Forte {
5497*fcf3ce44SJohn Forte 	int		err, retval = 0;
5498*fcf3ce44SJohn Forte 	char		*path_phys = NULL;
5499*fcf3ce44SJohn Forte 	char		*nexus_path_ptr = NULL;
5500*fcf3ce44SJohn Forte 	Path_struct	*path_struct = NULL;
5501*fcf3ce44SJohn Forte 
5502*fcf3ce44SJohn Forte 	while (*argv != NULL) {
5503*fcf3ce44SJohn Forte 		if ((err = l_convert_name(*argv, &path_phys,
5504*fcf3ce44SJohn Forte 			&path_struct, Options & PVERBOSE)) != 0) {
5505*fcf3ce44SJohn Forte 			(void) fprintf(stderr,
5506*fcf3ce44SJohn Forte 				MSGSTR(33,
5507*fcf3ce44SJohn Forte 					" Error: converting"
5508*fcf3ce44SJohn Forte 					" %s to physical path.\n"
5509*fcf3ce44SJohn Forte 					" Invalid pathname.\n"),
5510*fcf3ce44SJohn Forte 				*argv);
5511*fcf3ce44SJohn Forte 			if (err != -1) {
5512*fcf3ce44SJohn Forte 				(void) print_errString(err, *argv);
5513*fcf3ce44SJohn Forte 			}
5514*fcf3ce44SJohn Forte 			argv++;
5515*fcf3ce44SJohn Forte 			retval++;
5516*fcf3ce44SJohn Forte 			continue;
5517*fcf3ce44SJohn Forte 		}
5518*fcf3ce44SJohn Forte 
5519*fcf3ce44SJohn Forte 		/* Get the nexus path - need this to print messages */
5520*fcf3ce44SJohn Forte 		if ((err = g_get_nexus_path(path_phys, &nexus_path_ptr)) != 0) {
5521*fcf3ce44SJohn Forte 			(void) print_errString(err, *argv);
5522*fcf3ce44SJohn Forte 			retval++;
5523*fcf3ce44SJohn Forte 			goto cleanup_and_go;
5524*fcf3ce44SJohn Forte 		}
5525*fcf3ce44SJohn Forte 
5526*fcf3ce44SJohn Forte 		if (flag == LUX_P_OFFLINE) {
5527*fcf3ce44SJohn Forte 			if ((err = g_port_offline(nexus_path_ptr))) {
5528*fcf3ce44SJohn Forte 				(void) print_errString(err, nexus_path_ptr);
5529*fcf3ce44SJohn Forte 				retval++;
5530*fcf3ce44SJohn Forte 				goto cleanup_and_go;
5531*fcf3ce44SJohn Forte 			}
5532*fcf3ce44SJohn Forte 			fprintf(stdout,
5533*fcf3ce44SJohn Forte 				MSGSTR(2223, "Port %s has been disabled\n"),
5534*fcf3ce44SJohn Forte 					nexus_path_ptr);
5535*fcf3ce44SJohn Forte 		} else if (flag == LUX_P_ONLINE) {
5536*fcf3ce44SJohn Forte 			if ((err = g_port_online(nexus_path_ptr))) {
5537*fcf3ce44SJohn Forte 				(void) print_errString(err, nexus_path_ptr);
5538*fcf3ce44SJohn Forte 				retval++;
5539*fcf3ce44SJohn Forte 				goto cleanup_and_go;
5540*fcf3ce44SJohn Forte 			}
5541*fcf3ce44SJohn Forte 			fprintf(stdout,
5542*fcf3ce44SJohn Forte 				MSGSTR(2224, "Port %s has been enabled\n"),
5543*fcf3ce44SJohn Forte 					nexus_path_ptr);
5544*fcf3ce44SJohn Forte 		} else {
5545*fcf3ce44SJohn Forte 			(void) fprintf(stderr,
5546*fcf3ce44SJohn Forte 					MSGSTR(2225,
5547*fcf3ce44SJohn Forte 					"Unknown action requested "
5548*fcf3ce44SJohn Forte 					"on port - %d\nIgnoring."),
5549*fcf3ce44SJohn Forte 					flag);
5550*fcf3ce44SJohn Forte 			retval++;
5551*fcf3ce44SJohn Forte 		}
5552*fcf3ce44SJohn Forte cleanup_and_go:
5553*fcf3ce44SJohn Forte 		free(path_phys);
5554*fcf3ce44SJohn Forte 		free(path_struct);
5555*fcf3ce44SJohn Forte 		free(nexus_path_ptr);
5556*fcf3ce44SJohn Forte 		argv++;
5557*fcf3ce44SJohn Forte 	}
5558*fcf3ce44SJohn Forte 	return (retval);
5559*fcf3ce44SJohn Forte }
5560*fcf3ce44SJohn Forte 
5561*fcf3ce44SJohn Forte /*
5562*fcf3ce44SJohn Forte  * Expert level subcommand 'luxadm -e port'
5563*fcf3ce44SJohn Forte  * which displays all FC ports on a host and state information for
5564*fcf3ce44SJohn Forte  * connectivity (CONNECTED or NOT CONNECTED) indicating whether there
5565*fcf3ce44SJohn Forte  * are devices attached to the port.
5566*fcf3ce44SJohn Forte  *
5567*fcf3ce44SJohn Forte  * Sample output for ifp:
5568*fcf3ce44SJohn Forte  *
5569*fcf3ce44SJohn Forte  * /devices/pci@1f,4000/SUNW,ifp@2:devctl 		CONNECTED
5570*fcf3ce44SJohn Forte  * /devices/pci@1f,2000/SUNW,ifp@1:devctl		NOT CONNECTED
5571*fcf3ce44SJohn Forte  *
5572*fcf3ce44SJohn Forte  * Sample output for socal:
5573*fcf3ce44SJohn Forte  *
5574*fcf3ce44SJohn Forte  * /devices/sbus@2,0/SUNW,socal@d,10000:0               CONNECTED
5575*fcf3ce44SJohn Forte  * /devices/sbus@2,0/SUNW,socal@d,10000:1               NOT CONNECTED
5576*fcf3ce44SJohn Forte  * /devices/sbus@2,0/SUNW,socal@2,0:0                   NOT CONNECTED
5577*fcf3ce44SJohn Forte  * /devices/sbus@2,0/SUNW,socal@2,0:1                   CONNECTED
5578*fcf3ce44SJohn Forte  *
5579*fcf3ce44SJohn Forte  * Note: for socal the path returned is not a devctl path as there is no
5580*fcf3ce44SJohn Forte  * devctl path for socal.
5581*fcf3ce44SJohn Forte  *
5582*fcf3ce44SJohn Forte  * Sample output for fp:
5583*fcf3ce44SJohn Forte  *
5584*fcf3ce44SJohn Forte  * /devices/sbus@2,0/SUNW,qlc@5/fp@0,0:devctl        CONNECTED
5585*fcf3ce44SJohn Forte  * /devices/sbus@2,0/SUNW,qlc@4/fp@1,0:devctl        CONNECTED
5586*fcf3ce44SJohn Forte  */
5587*fcf3ce44SJohn Forte int
5588*fcf3ce44SJohn Forte adm_display_port(int verbose)
5589*fcf3ce44SJohn Forte {
5590*fcf3ce44SJohn Forte 	/*
5591*fcf3ce44SJohn Forte 	 * If another port driver needs to be searched, add it here
5592*fcf3ce44SJohn Forte 	 */
5593*fcf3ce44SJohn Forte 	static char *portdrvr_list[] = {"socal",
5594*fcf3ce44SJohn Forte 					"fp",
5595*fcf3ce44SJohn Forte 					"ifp",
5596*fcf3ce44SJohn Forte 					NULL};
5597*fcf3ce44SJohn Forte 	portlist_t portlist;
5598*fcf3ce44SJohn Forte 	int x = 0, err = 0, retval = 0;
5599*fcf3ce44SJohn Forte 	int port_state;
5600*fcf3ce44SJohn Forte 
5601*fcf3ce44SJohn Forte 	portlist.hbacnt = 0;
5602*fcf3ce44SJohn Forte 
5603*fcf3ce44SJohn Forte 	/*
5604*fcf3ce44SJohn Forte 	 * Look for all HBA ports as listed in portdrvr_list[]
5605*fcf3ce44SJohn Forte 	 */
5606*fcf3ce44SJohn Forte 	while (portdrvr_list[x]) {
5607*fcf3ce44SJohn Forte 		if (err = g_get_port_path(portdrvr_list[x], &portlist)) {
5608*fcf3ce44SJohn Forte 			if (err != L_PORT_DRIVER_NOT_FOUND &&
5609*fcf3ce44SJohn Forte 			    err != L_PHYS_PATH_NOT_FOUND) {
5610*fcf3ce44SJohn Forte 				(void) print_errString(err, portdrvr_list[x]);
5611*fcf3ce44SJohn Forte 				retval++;
5612*fcf3ce44SJohn Forte 			}
5613*fcf3ce44SJohn Forte 		}
5614*fcf3ce44SJohn Forte 		x++;
5615*fcf3ce44SJohn Forte 	}
5616*fcf3ce44SJohn Forte 
5617*fcf3ce44SJohn Forte 
5618*fcf3ce44SJohn Forte 	/*
5619*fcf3ce44SJohn Forte 	 * For each port path found get the connection state.
5620*fcf3ce44SJohn Forte 	 * If there are devices attached the state is considered connected.
5621*fcf3ce44SJohn Forte 	 */
5622*fcf3ce44SJohn Forte 	for (x = 0; x < portlist.hbacnt; x++) {
5623*fcf3ce44SJohn Forte 		if (err = g_get_port_state(portlist.physpath[x],
5624*fcf3ce44SJohn Forte 			    &port_state, verbose)) {
5625*fcf3ce44SJohn Forte 			(void) print_errString(err, portlist.physpath[x]);
5626*fcf3ce44SJohn Forte 			retval++;
5627*fcf3ce44SJohn Forte 		} else {
5628*fcf3ce44SJohn Forte 			fprintf(stdout, "%-65s  ", portlist.physpath[x]);
5629*fcf3ce44SJohn Forte 			if (port_state == PORT_CONNECTED) {
5630*fcf3ce44SJohn Forte 				(void) fprintf(stdout,
5631*fcf3ce44SJohn Forte 						MSGSTR(2233,
5632*fcf3ce44SJohn Forte 						"CONNECTED\n"));
5633*fcf3ce44SJohn Forte 			} else {
5634*fcf3ce44SJohn Forte 				(void) fprintf(stdout,
5635*fcf3ce44SJohn Forte 						MSGSTR(2234,
5636*fcf3ce44SJohn Forte 						"NOT CONNECTED\n"));
5637*fcf3ce44SJohn Forte 			}
5638*fcf3ce44SJohn Forte 		}
5639*fcf3ce44SJohn Forte 	}
5640*fcf3ce44SJohn Forte 	g_free_portlist(&portlist);
5641*fcf3ce44SJohn Forte 	return (retval);
5642*fcf3ce44SJohn Forte }
5643*fcf3ce44SJohn Forte 
5644*fcf3ce44SJohn Forte /*
5645*fcf3ce44SJohn Forte  * Expert level subcommand 'luxadm -e external_loopback <portpath>
5646*fcf3ce44SJohn Forte  *				      internal_loopback
5647*fcf3ce44SJohn Forte  *				      no_loopback
5648*fcf3ce44SJohn Forte  * Does just what you would think. Sets port in designated loopback
5649*fcf3ce44SJohn Forte  * mode.
5650*fcf3ce44SJohn Forte  * INPUT:  portpath - path to device on which to set loopback mode
5651*fcf3ce44SJohn Forte  *	   flag     - loopback mode to set. Values are:
5652*fcf3ce44SJohn Forte  *			EXT_LOOPBACK
5653*fcf3ce44SJohn Forte  *			INT_LOOPBACK
5654*fcf3ce44SJohn Forte  *			NO_LOOPBACK
5655*fcf3ce44SJohn Forte  *
5656*fcf3ce44SJohn Forte  * RETURN: 0 on success
5657*fcf3ce44SJohn Forte  *         non-zero on failure
5658*fcf3ce44SJohn Forte  */
5659*fcf3ce44SJohn Forte int
5660*fcf3ce44SJohn Forte adm_port_loopback(char *portpath, int flag)
5661*fcf3ce44SJohn Forte {
5662*fcf3ce44SJohn Forte 	int		err;
5663*fcf3ce44SJohn Forte 	char		*path_phys = NULL;
5664*fcf3ce44SJohn Forte 	Path_struct	*path_struct = NULL;
5665*fcf3ce44SJohn Forte 	int		cmd;
5666*fcf3ce44SJohn Forte 
5667*fcf3ce44SJohn Forte 	if ((err = l_convert_name(portpath, &path_phys,
5668*fcf3ce44SJohn Forte 		&path_struct, Options & PVERBOSE)) != 0) {
5669*fcf3ce44SJohn Forte 		(void) fprintf(stderr,
5670*fcf3ce44SJohn Forte 			MSGSTR(33,
5671*fcf3ce44SJohn Forte 				" Error: converting"
5672*fcf3ce44SJohn Forte 				" %s to physical path.\n"
5673*fcf3ce44SJohn Forte 				" Invalid pathname.\n"),
5674*fcf3ce44SJohn Forte 			portpath);
5675*fcf3ce44SJohn Forte 		if (err != -1) {
5676*fcf3ce44SJohn Forte 			(void) print_errString(err, portpath);
5677*fcf3ce44SJohn Forte 		}
5678*fcf3ce44SJohn Forte 		return (-1);
5679*fcf3ce44SJohn Forte 	}
5680*fcf3ce44SJohn Forte 
5681*fcf3ce44SJohn Forte 	switch (flag) {
5682*fcf3ce44SJohn Forte 		case EXT_LOOPBACK:
5683*fcf3ce44SJohn Forte 			cmd = EXT_LPBACK;
5684*fcf3ce44SJohn Forte 			break;
5685*fcf3ce44SJohn Forte 		case INT_LOOPBACK:
5686*fcf3ce44SJohn Forte 			cmd = INT_LPBACK;
5687*fcf3ce44SJohn Forte 			break;
5688*fcf3ce44SJohn Forte 		case NO_LOOPBACK:
5689*fcf3ce44SJohn Forte 			cmd = NO_LPBACK;
5690*fcf3ce44SJohn Forte 			break;
5691*fcf3ce44SJohn Forte 		default:
5692*fcf3ce44SJohn Forte 			(void) fprintf(stderr,
5693*fcf3ce44SJohn Forte 					MSGSTR(2225,
5694*fcf3ce44SJohn Forte 					"Unknown action requested "
5695*fcf3ce44SJohn Forte 					"on port - %d\nIgnoring."),
5696*fcf3ce44SJohn Forte 					flag);
5697*fcf3ce44SJohn Forte 			free(path_phys);
5698*fcf3ce44SJohn Forte 			free(path_struct);
5699*fcf3ce44SJohn Forte 			return (-1);
5700*fcf3ce44SJohn Forte 	}
5701*fcf3ce44SJohn Forte 
5702*fcf3ce44SJohn Forte 
5703*fcf3ce44SJohn Forte 	if ((err = g_loopback_mode(path_phys, cmd)) != 0) {
5704*fcf3ce44SJohn Forte 		(void) print_errString(err, portpath);
5705*fcf3ce44SJohn Forte 		free(path_phys);
5706*fcf3ce44SJohn Forte 		free(path_struct);
5707*fcf3ce44SJohn Forte 		return (-1);
5708*fcf3ce44SJohn Forte 	} else {
5709*fcf3ce44SJohn Forte 		switch (flag) {
5710*fcf3ce44SJohn Forte 			case EXT_LOOPBACK:
5711*fcf3ce44SJohn Forte 				(void) fprintf(stdout,
5712*fcf3ce44SJohn Forte 						MSGSTR(2230,
5713*fcf3ce44SJohn Forte 						"External loopback mode set "
5714*fcf3ce44SJohn Forte 						"on:\n%s\n"),
5715*fcf3ce44SJohn Forte 						portpath);
5716*fcf3ce44SJohn Forte 				break;
5717*fcf3ce44SJohn Forte 			case INT_LOOPBACK:
5718*fcf3ce44SJohn Forte 				(void) fprintf(stdout,
5719*fcf3ce44SJohn Forte 						MSGSTR(2231,
5720*fcf3ce44SJohn Forte 						"Internal loopback mode set "
5721*fcf3ce44SJohn Forte 						"on:\n%s\n"),
5722*fcf3ce44SJohn Forte 						portpath);
5723*fcf3ce44SJohn Forte 				break;
5724*fcf3ce44SJohn Forte 			case NO_LOOPBACK:
5725*fcf3ce44SJohn Forte 				(void) fprintf(stdout,
5726*fcf3ce44SJohn Forte 						MSGSTR(2232,
5727*fcf3ce44SJohn Forte 						"Loopback mode unset "
5728*fcf3ce44SJohn Forte 						"on:\n%s\n"),
5729*fcf3ce44SJohn Forte 						portpath);
5730*fcf3ce44SJohn Forte 				break;
5731*fcf3ce44SJohn Forte 			default:
5732*fcf3ce44SJohn Forte 				fprintf(stderr,
5733*fcf3ce44SJohn Forte 					MSGSTR(2248, "Undefined command\n"));
5734*fcf3ce44SJohn Forte 				break;
5735*fcf3ce44SJohn Forte 		}
5736*fcf3ce44SJohn Forte 	}
5737*fcf3ce44SJohn Forte 	free(path_phys);
5738*fcf3ce44SJohn Forte 	free(path_struct);
5739*fcf3ce44SJohn Forte 	return (0);
5740*fcf3ce44SJohn Forte }
5741*fcf3ce44SJohn Forte 
5742*fcf3ce44SJohn Forte 
5743*fcf3ce44SJohn Forte 
5744*fcf3ce44SJohn Forte /*
5745*fcf3ce44SJohn Forte  * To print the pathlist and mpxio path attributes
5746*fcf3ce44SJohn Forte  */
5747*fcf3ce44SJohn Forte void
5748*fcf3ce44SJohn Forte adm_print_pathlist(char *dev_path)
5749*fcf3ce44SJohn Forte {
5750*fcf3ce44SJohn Forte 	int		i, pathcnt = 1;
5751*fcf3ce44SJohn Forte 	mp_pathlist_t	pathlist;
5752*fcf3ce44SJohn Forte 	int		retval = 0;
5753*fcf3ce44SJohn Forte 	char		temppath[MAXPATHLEN];
5754*fcf3ce44SJohn Forte 	char		wwns[(WWN_SIZE *2) +1];
5755*fcf3ce44SJohn Forte 	uchar_t		wwn_data[WWN_SIZE];
5756*fcf3ce44SJohn Forte 	int		err;
5757*fcf3ce44SJohn Forte 	int		state, ext_state = 0;
5758*fcf3ce44SJohn Forte 	char	*path_state[5];
5759*fcf3ce44SJohn Forte 
5760*fcf3ce44SJohn Forte 	path_state[0] = MSGSTR(2400, "INIT");
5761*fcf3ce44SJohn Forte 	path_state[1] = MSGSTR(2401, "ONLINE");
5762*fcf3ce44SJohn Forte 	path_state[2] = MSGSTR(2402, "STANDBY");
5763*fcf3ce44SJohn Forte 	path_state[3] = MSGSTR(2403, "FAULT");
5764*fcf3ce44SJohn Forte 	path_state[4] = MSGSTR(2404, "OFFLINE");
5765*fcf3ce44SJohn Forte 
5766*fcf3ce44SJohn Forte 	(void) strcpy(temppath, dev_path);
5767*fcf3ce44SJohn Forte 	retval = g_get_pathlist(temppath, &pathlist);
5768*fcf3ce44SJohn Forte 	if (retval != 0) {
5769*fcf3ce44SJohn Forte 		(void) print_errString(retval, NULL);
5770*fcf3ce44SJohn Forte 		exit(-1);
5771*fcf3ce44SJohn Forte 	}
5772*fcf3ce44SJohn Forte 	pathcnt = pathlist.path_count;
5773*fcf3ce44SJohn Forte 	for (i = 0; i < pathcnt; i++) {
5774*fcf3ce44SJohn Forte 		(void) fprintf(stdout,
5775*fcf3ce44SJohn Forte 		MSGSTR(2303, "   Controller      \t%s\n"),
5776*fcf3ce44SJohn Forte 			pathlist.path_info[i].path_hba);
5777*fcf3ce44SJohn Forte 
5778*fcf3ce44SJohn Forte 		(void) fprintf(stdout,
5779*fcf3ce44SJohn Forte 		MSGSTR(2304, "    Device Address\t\t%s\n"),
5780*fcf3ce44SJohn Forte 			pathlist.path_info[i].path_addr);
5781*fcf3ce44SJohn Forte 
5782*fcf3ce44SJohn Forte 		if ((err = get_host_controller_pwwn(
5783*fcf3ce44SJohn Forte 				pathlist.path_info[i].path_hba,
5784*fcf3ce44SJohn Forte 				(uchar_t *)&wwn_data)) != 0) {
5785*fcf3ce44SJohn Forte 			if (err != ENOTSUP) {
5786*fcf3ce44SJohn Forte 				(void) print_errString(err,
5787*fcf3ce44SJohn Forte 					pathlist.path_info[i].path_hba);
5788*fcf3ce44SJohn Forte 				exit(1);
5789*fcf3ce44SJohn Forte 			}
5790*fcf3ce44SJohn Forte 		}
5791*fcf3ce44SJohn Forte 
5792*fcf3ce44SJohn Forte 		if (!err) {
5793*fcf3ce44SJohn Forte 			copy_wwn_data_to_str(wwns, wwn_data);
5794*fcf3ce44SJohn Forte 			(void) fprintf(stdout,
5795*fcf3ce44SJohn Forte 			    MSGSTR(2326, "    Host controller port WWN\t%s\n"),
5796*fcf3ce44SJohn Forte 				wwns);
5797*fcf3ce44SJohn Forte 		}
5798*fcf3ce44SJohn Forte 
5799*fcf3ce44SJohn Forte 		(void) fprintf(stdout,
5800*fcf3ce44SJohn Forte 		MSGSTR(2305, "    Class\t\t\t%s\n"),
5801*fcf3ce44SJohn Forte 			pathlist.path_info[i].path_class);
5802*fcf3ce44SJohn Forte 		if (pathlist.path_info[i].path_state < MAXPATHSTATE) {
5803*fcf3ce44SJohn Forte 			(void) fprintf(stdout,
5804*fcf3ce44SJohn Forte 			MSGSTR(2306, "    State\t\t\t%s\n"),
5805*fcf3ce44SJohn Forte 			path_state[pathlist.path_info[i].path_state]);
5806*fcf3ce44SJohn Forte 		}
5807*fcf3ce44SJohn Forte 		if ((err = g_stms_get_path_state(dev_path,
5808*fcf3ce44SJohn Forte 				pathlist.path_info[i].path_hba, &state,
5809*fcf3ce44SJohn Forte 				&ext_state)) != 0) {
5810*fcf3ce44SJohn Forte 			(void) print_errString(err,
5811*fcf3ce44SJohn Forte 				pathlist.path_info[i].path_hba);
5812*fcf3ce44SJohn Forte 			exit(1);
5813*fcf3ce44SJohn Forte 		} else {
5814*fcf3ce44SJohn Forte 			if ((ext_state & MDI_PATHINFO_STATE_USER_DISABLE)
5815*fcf3ce44SJohn Forte 				== MDI_PATHINFO_STATE_USER_DISABLE) {
5816*fcf3ce44SJohn Forte 				ext_state = 0;
5817*fcf3ce44SJohn Forte 				fprintf(stdout,
5818*fcf3ce44SJohn Forte 				MSGSTR(2327,
5819*fcf3ce44SJohn Forte 				"    I/Os disabled on this %s path\n\n"),
5820*fcf3ce44SJohn Forte 				path_state[pathlist.path_info[i].path_state]);
5821*fcf3ce44SJohn Forte 			}
5822*fcf3ce44SJohn Forte 		}
5823*fcf3ce44SJohn Forte 	}
5824*fcf3ce44SJohn Forte 	/* Free memory for per path info properties */
5825*fcf3ce44SJohn Forte 	free(pathlist.path_info);
5826*fcf3ce44SJohn Forte }
5827*fcf3ce44SJohn Forte 
5828*fcf3ce44SJohn Forte /*
5829*fcf3ce44SJohn Forte  * compare_multipath
5830*fcf3ce44SJohn Forte  * compares path with all paths in pathlist
5831*fcf3ce44SJohn Forte  * If there is a match, 0 is returned, otherwise 1 is returned
5832*fcf3ce44SJohn Forte  */
5833*fcf3ce44SJohn Forte int
5834*fcf3ce44SJohn Forte compare_multipath(char *path, struct mplist_struct *pathlist)
5835*fcf3ce44SJohn Forte {
5836*fcf3ce44SJohn Forte 
5837*fcf3ce44SJohn Forte 	while (pathlist != NULL) {
5838*fcf3ce44SJohn Forte 		if (strncmp(path, pathlist->devpath, MAXPATHLEN) == 0) {
5839*fcf3ce44SJohn Forte 			return (0);
5840*fcf3ce44SJohn Forte 		}
5841*fcf3ce44SJohn Forte 		pathlist = pathlist->next;
5842*fcf3ce44SJohn Forte 	}
5843*fcf3ce44SJohn Forte 	return (1);
5844*fcf3ce44SJohn Forte }
5845*fcf3ce44SJohn Forte 
5846*fcf3ce44SJohn Forte /*
5847*fcf3ce44SJohn Forte  * lun_display() Prints the
5848*fcf3ce44SJohn Forte  * information for an individual lun.
5849*fcf3ce44SJohn Forte  *
5850*fcf3ce44SJohn Forte  * RETURNS:
5851*fcf3ce44SJohn Forte  *	none.
5852*fcf3ce44SJohn Forte  */
5853*fcf3ce44SJohn Forte static int
5854*fcf3ce44SJohn Forte lun_display(Path_struct *path_struct, L_inquiry inq_struct, int verbose)
5855*fcf3ce44SJohn Forte {
5856*fcf3ce44SJohn Forte 
5857*fcf3ce44SJohn Forte char			phys_path[MAXPATHLEN], last_logical_path[MAXPATHLEN];
5858*fcf3ce44SJohn Forte uchar_t			*pg_buf = NULL;
5859*fcf3ce44SJohn Forte L_disk_state		l_disk_state;
5860*fcf3ce44SJohn Forte struct dlist		*mlist;
5861*fcf3ce44SJohn Forte int			offset, mode_data_avail, err = 0;
5862*fcf3ce44SJohn Forte Mode_header_10		*mode_header_ptr;
5863*fcf3ce44SJohn Forte struct mode_page	*pg_hdr;
5864*fcf3ce44SJohn Forte WWN_list		*wwn_list, *list_start, *wwn_list_ptr;
5865*fcf3ce44SJohn Forte WWN_list		*wwn_list_find;
5866*fcf3ce44SJohn Forte int			found = 0;
5867*fcf3ce44SJohn Forte int			argpwwn = 0, argnwwn = 0;
5868*fcf3ce44SJohn Forte struct mplist_struct	*mplistp, *mpl, *mpln;
5869*fcf3ce44SJohn Forte struct dlist		*dlist;
5870*fcf3ce44SJohn Forte 
5871*fcf3ce44SJohn Forte 
5872*fcf3ce44SJohn Forte 
5873*fcf3ce44SJohn Forte 	strcpy(phys_path, path_struct->p_physical_path);
5874*fcf3ce44SJohn Forte 	strcpy(last_logical_path, phys_path);
5875*fcf3ce44SJohn Forte 
5876*fcf3ce44SJohn Forte 	mplistp = mpl = mpln = (struct mplist_struct *)NULL;
5877*fcf3ce44SJohn Forte 	/*
5878*fcf3ce44SJohn Forte 	 * Get path to all the FC disk and tape devices.
5879*fcf3ce44SJohn Forte 	 * If there is no slash in the argument in this routine, we assume
5880*fcf3ce44SJohn Forte 	 * it is a wwn argument.
5881*fcf3ce44SJohn Forte 	 */
5882*fcf3ce44SJohn Forte 	if (strstr(path_struct->argv, "/") != NULL) {
5883*fcf3ce44SJohn Forte 		if ((err = g_devices_get_all(&wwn_list)) != 0) {
5884*fcf3ce44SJohn Forte 			return (err);
5885*fcf3ce44SJohn Forte 		}
5886*fcf3ce44SJohn Forte 	} else {
5887*fcf3ce44SJohn Forte 		if ((err = g_get_wwn_list(&wwn_list, verbose)) != 0) {
5888*fcf3ce44SJohn Forte 			return (err);
5889*fcf3ce44SJohn Forte 		}
5890*fcf3ce44SJohn Forte 	}
5891*fcf3ce44SJohn Forte 
5892*fcf3ce44SJohn Forte 	g_sort_wwn_list(&wwn_list);
5893*fcf3ce44SJohn Forte 
5894*fcf3ce44SJohn Forte 	list_start = wwn_list;
5895*fcf3ce44SJohn Forte 
5896*fcf3ce44SJohn Forte 	for (wwn_list_ptr = wwn_list; wwn_list_ptr != NULL;
5897*fcf3ce44SJohn Forte 		wwn_list_ptr = wwn_list_ptr->wwn_next) {
5898*fcf3ce44SJohn Forte 		if (strcasecmp(wwn_list_ptr->port_wwn_s,
5899*fcf3ce44SJohn Forte 			path_struct->argv) == 0) {
5900*fcf3ce44SJohn Forte 			list_start = wwn_list_ptr;
5901*fcf3ce44SJohn Forte 			argpwwn = 1;
5902*fcf3ce44SJohn Forte 			break;
5903*fcf3ce44SJohn Forte 		} else if (strcasecmp(wwn_list_ptr->node_wwn_s,
5904*fcf3ce44SJohn Forte 			path_struct->argv) == 0) {
5905*fcf3ce44SJohn Forte 			list_start = wwn_list_ptr;
5906*fcf3ce44SJohn Forte 			argnwwn = 1;
5907*fcf3ce44SJohn Forte 			break;
5908*fcf3ce44SJohn Forte 		}
5909*fcf3ce44SJohn Forte 	}
5910*fcf3ce44SJohn Forte 
5911*fcf3ce44SJohn Forte 	for (wwn_list_ptr = list_start; wwn_list_ptr != NULL;
5912*fcf3ce44SJohn Forte 		wwn_list_ptr = wwn_list_ptr->wwn_next) {
5913*fcf3ce44SJohn Forte 
5914*fcf3ce44SJohn Forte 
5915*fcf3ce44SJohn Forte 	if (argpwwn) {
5916*fcf3ce44SJohn Forte 		if (strcasecmp(wwn_list_ptr->port_wwn_s,
5917*fcf3ce44SJohn Forte 			path_struct->argv) != 0) {
5918*fcf3ce44SJohn Forte 			continue;
5919*fcf3ce44SJohn Forte 		}
5920*fcf3ce44SJohn Forte 		(void) strcpy(phys_path, wwn_list_ptr->physical_path);
5921*fcf3ce44SJohn Forte 	} else if (argnwwn) {
5922*fcf3ce44SJohn Forte 		if (strstr(wwn_list_ptr->logical_path,
5923*fcf3ce44SJohn Forte 			last_logical_path) != NULL) {
5924*fcf3ce44SJohn Forte 			continue;
5925*fcf3ce44SJohn Forte 		}
5926*fcf3ce44SJohn Forte 		if (strcasecmp(wwn_list_ptr->node_wwn_s,
5927*fcf3ce44SJohn Forte 			path_struct->argv) != 0) {
5928*fcf3ce44SJohn Forte 			continue;
5929*fcf3ce44SJohn Forte 		}
5930*fcf3ce44SJohn Forte 		(void) strcpy(phys_path, wwn_list_ptr->physical_path);
5931*fcf3ce44SJohn Forte 		(void) strcpy(last_logical_path,
5932*fcf3ce44SJohn Forte 			wwn_list_ptr->logical_path);
5933*fcf3ce44SJohn Forte 	}
5934*fcf3ce44SJohn Forte 
5935*fcf3ce44SJohn Forte 	if (argnwwn || argpwwn) {
5936*fcf3ce44SJohn Forte 		if (compare_multipath(wwn_list_ptr->logical_path,
5937*fcf3ce44SJohn Forte 			mplistp) == 0) {
5938*fcf3ce44SJohn Forte 			continue;
5939*fcf3ce44SJohn Forte 		}
5940*fcf3ce44SJohn Forte 	}
5941*fcf3ce44SJohn Forte 
5942*fcf3ce44SJohn Forte 	mode_data_avail = 0;
5943*fcf3ce44SJohn Forte 
5944*fcf3ce44SJohn Forte 	(void) memset(&l_disk_state, 0, sizeof (struct l_disk_state_struct));
5945*fcf3ce44SJohn Forte 
5946*fcf3ce44SJohn Forte 	/*
5947*fcf3ce44SJohn Forte 	 * Don't call g_get_multipath if this is a SCSI_VHCI device
5948*fcf3ce44SJohn Forte 	 * dlist gets alloc'ed here to retain the free at the end
5949*fcf3ce44SJohn Forte 	 */
5950*fcf3ce44SJohn Forte 	if (strstr(phys_path, SCSI_VHCI) == NULL) {
5951*fcf3ce44SJohn Forte 		if ((err = g_get_multipath(phys_path,
5952*fcf3ce44SJohn Forte 				    &(l_disk_state.g_disk_state.multipath_list),
5953*fcf3ce44SJohn Forte 				    wwn_list, verbose)) != 0) {
5954*fcf3ce44SJohn Forte 			return (err);
5955*fcf3ce44SJohn Forte 		}
5956*fcf3ce44SJohn Forte 
5957*fcf3ce44SJohn Forte 		mlist = l_disk_state.g_disk_state.multipath_list;
5958*fcf3ce44SJohn Forte 		if (mlist == NULL) {
5959*fcf3ce44SJohn Forte 			l_disk_state.l_state_flag = L_NO_PATH_FOUND;
5960*fcf3ce44SJohn Forte 			N_DPRINTF(" lun_display: Error finding"
5961*fcf3ce44SJohn Forte 			    " multiple paths to the disk.\n");
5962*fcf3ce44SJohn Forte 			(void) g_free_wwn_list(&wwn_list);
5963*fcf3ce44SJohn Forte 			return (L_NO_VALID_PATH);
5964*fcf3ce44SJohn Forte 		}
5965*fcf3ce44SJohn Forte 	} else {
5966*fcf3ce44SJohn Forte 		/* Search for match on physical path name */
5967*fcf3ce44SJohn Forte 		for (wwn_list_find = list_start; wwn_list_find != NULL;
5968*fcf3ce44SJohn Forte 		    wwn_list_find = wwn_list_find->wwn_next) {
5969*fcf3ce44SJohn Forte 			if (strncmp(wwn_list_find->physical_path, phys_path,
5970*fcf3ce44SJohn Forte 				    strlen(wwn_list_find->physical_path))
5971*fcf3ce44SJohn Forte 				    == 0) {
5972*fcf3ce44SJohn Forte 				found++;
5973*fcf3ce44SJohn Forte 				break;
5974*fcf3ce44SJohn Forte 			}
5975*fcf3ce44SJohn Forte 		}
5976*fcf3ce44SJohn Forte 
5977*fcf3ce44SJohn Forte 		if (!found) {
5978*fcf3ce44SJohn Forte 			return (L_NO_VALID_PATH);
5979*fcf3ce44SJohn Forte 		} else {
5980*fcf3ce44SJohn Forte 			found = 0;
5981*fcf3ce44SJohn Forte 		}
5982*fcf3ce44SJohn Forte 
5983*fcf3ce44SJohn Forte 		if ((dlist = (struct dlist *)
5984*fcf3ce44SJohn Forte 			    calloc(1, sizeof (struct dlist))) == NULL) {
5985*fcf3ce44SJohn Forte 			    return (L_MALLOC_FAILED);
5986*fcf3ce44SJohn Forte 		}
5987*fcf3ce44SJohn Forte 		if ((dlist->logical_path = (char *)calloc(1,
5988*fcf3ce44SJohn Forte 			    strlen(wwn_list_find->logical_path) + 1)) == NULL) {
5989*fcf3ce44SJohn Forte 			return (L_MALLOC_FAILED);
5990*fcf3ce44SJohn Forte 		}
5991*fcf3ce44SJohn Forte 		if ((dlist->dev_path = (char *)calloc(1,
5992*fcf3ce44SJohn Forte 			    strlen(phys_path) + 1)) == NULL) {
5993*fcf3ce44SJohn Forte 			return (L_MALLOC_FAILED);
5994*fcf3ce44SJohn Forte 		}
5995*fcf3ce44SJohn Forte 		strncpy(dlist->logical_path, wwn_list_find->logical_path,
5996*fcf3ce44SJohn Forte 		    strlen(wwn_list_find->logical_path));
5997*fcf3ce44SJohn Forte 		strncpy(dlist->dev_path, phys_path, strlen(phys_path));
5998*fcf3ce44SJohn Forte 		l_disk_state.g_disk_state.multipath_list = dlist;
5999*fcf3ce44SJohn Forte 	}
6000*fcf3ce44SJohn Forte 
6001*fcf3ce44SJohn Forte 	if (argnwwn || argpwwn) {
6002*fcf3ce44SJohn Forte 		for (mlist = l_disk_state.g_disk_state.multipath_list;
6003*fcf3ce44SJohn Forte 		    mlist != NULL; mlist = mlist->next) {
6004*fcf3ce44SJohn Forte 			/* add the path to the list for compare */
6005*fcf3ce44SJohn Forte 			if ((mpl = (struct mplist_struct *)
6006*fcf3ce44SJohn Forte 				    calloc(1, sizeof (struct mplist_struct)))
6007*fcf3ce44SJohn Forte 			    == NULL) {
6008*fcf3ce44SJohn Forte 				adm_mplist_free(mplistp);
6009*fcf3ce44SJohn Forte 				return (L_MALLOC_FAILED);
6010*fcf3ce44SJohn Forte 			}
6011*fcf3ce44SJohn Forte 
6012*fcf3ce44SJohn Forte 			mpl->devpath = (char *)calloc(1, MAXPATHLEN+1);
6013*fcf3ce44SJohn Forte 			if (mpl->devpath == NULL) {
6014*fcf3ce44SJohn Forte 				adm_mplist_free(mplistp);
6015*fcf3ce44SJohn Forte 				return (L_MALLOC_FAILED);
6016*fcf3ce44SJohn Forte 			}
6017*fcf3ce44SJohn Forte 			strncpy(mpl->devpath, mlist->logical_path,
6018*fcf3ce44SJohn Forte 			    strlen(mlist->logical_path));
6019*fcf3ce44SJohn Forte 			if (mplistp == NULL) {
6020*fcf3ce44SJohn Forte 				mplistp = mpln = mpl;
6021*fcf3ce44SJohn Forte 			} else {
6022*fcf3ce44SJohn Forte 				mpln->next = mpl;
6023*fcf3ce44SJohn Forte 				mpln = mpl;
6024*fcf3ce44SJohn Forte 			}
6025*fcf3ce44SJohn Forte 		}
6026*fcf3ce44SJohn Forte 	}
6027*fcf3ce44SJohn Forte 
6028*fcf3ce44SJohn Forte 	/* get mode page information for FC device */
6029*fcf3ce44SJohn Forte 	if (l_get_mode_pg(phys_path, &pg_buf, verbose) == 0) {
6030*fcf3ce44SJohn Forte 		mode_header_ptr = (struct mode_header_10_struct *)
6031*fcf3ce44SJohn Forte 					(void *)pg_buf;
6032*fcf3ce44SJohn Forte 		offset = sizeof (struct mode_header_10_struct) +
6033*fcf3ce44SJohn Forte 			mode_header_ptr->bdesc_length;
6034*fcf3ce44SJohn Forte 		pg_hdr = (struct mode_page *)&pg_buf[offset];
6035*fcf3ce44SJohn Forte 
6036*fcf3ce44SJohn Forte 		while (offset < (mode_header_ptr->length +
6037*fcf3ce44SJohn Forte 			sizeof (mode_header_ptr->length)) &&
6038*fcf3ce44SJohn Forte 						!mode_data_avail) {
6039*fcf3ce44SJohn Forte 			if (pg_hdr->code == MODEPAGE_CACHING) {
6040*fcf3ce44SJohn Forte 				mode_data_avail++;
6041*fcf3ce44SJohn Forte 				break;
6042*fcf3ce44SJohn Forte 			}
6043*fcf3ce44SJohn Forte 			offset += pg_hdr->length + sizeof (struct mode_page);
6044*fcf3ce44SJohn Forte 			pg_hdr = (struct mode_page *)&pg_buf[offset];
6045*fcf3ce44SJohn Forte 		}
6046*fcf3ce44SJohn Forte 	}
6047*fcf3ce44SJohn Forte 
6048*fcf3ce44SJohn Forte 	switch ((inq_struct.inq_dtype & DTYPE_MASK)) {
6049*fcf3ce44SJohn Forte 	case DTYPE_DIRECT:
6050*fcf3ce44SJohn Forte 	    fprintf(stdout, MSGSTR(121, "DEVICE PROPERTIES for disk: %s\n"),
6051*fcf3ce44SJohn Forte 		path_struct->argv);
6052*fcf3ce44SJohn Forte 	    break;
6053*fcf3ce44SJohn Forte 	case DTYPE_SEQUENTIAL: /* Tape */
6054*fcf3ce44SJohn Forte 	    fprintf(stdout, MSGSTR(2249, "DEVICE PROPERTIES for tape: %s\n"),
6055*fcf3ce44SJohn Forte 		path_struct->argv);
6056*fcf3ce44SJohn Forte 	    break;
6057*fcf3ce44SJohn Forte 	default:
6058*fcf3ce44SJohn Forte 	    fprintf(stdout, MSGSTR(2250, "DEVICE PROPERTIES for: %s\n"),
6059*fcf3ce44SJohn Forte 		path_struct->argv);
6060*fcf3ce44SJohn Forte 	    break;
6061*fcf3ce44SJohn Forte 	}
6062*fcf3ce44SJohn Forte 
6063*fcf3ce44SJohn Forte 	(void) display_lun_info(l_disk_state, path_struct, pg_hdr,
6064*fcf3ce44SJohn Forte 			mode_data_avail, wwn_list, phys_path);
6065*fcf3ce44SJohn Forte 
6066*fcf3ce44SJohn Forte 	(void) g_free_multipath(l_disk_state.g_disk_state.multipath_list);
6067*fcf3ce44SJohn Forte 
6068*fcf3ce44SJohn Forte 	if (!(argpwwn || argnwwn)) {
6069*fcf3ce44SJohn Forte 		break;
6070*fcf3ce44SJohn Forte 	}
6071*fcf3ce44SJohn Forte 
6072*fcf3ce44SJohn Forte 	} /* End for wwn_list_ptr = list_start... */
6073*fcf3ce44SJohn Forte 
6074*fcf3ce44SJohn Forte 	(void) g_free_wwn_list(&wwn_list);
6075*fcf3ce44SJohn Forte 	adm_mplist_free(mplistp);
6076*fcf3ce44SJohn Forte 	return (0);
6077*fcf3ce44SJohn Forte }
6078*fcf3ce44SJohn Forte 
6079*fcf3ce44SJohn Forte /*
6080*fcf3ce44SJohn Forte  * display_lun_info() Prints the device specific information
6081*fcf3ce44SJohn Forte  * for a lun.
6082*fcf3ce44SJohn Forte  *
6083*fcf3ce44SJohn Forte  * RETURNS:
6084*fcf3ce44SJohn Forte  *	none.
6085*fcf3ce44SJohn Forte  */
6086*fcf3ce44SJohn Forte void
6087*fcf3ce44SJohn Forte display_lun_info(L_disk_state l_disk_state, Path_struct *path_struct,
6088*fcf3ce44SJohn Forte 		struct mode_page *pg_hdr, int mode_data_avail, WWN_list
6089*fcf3ce44SJohn Forte 		*wwn_list, char *phys_path)
6090*fcf3ce44SJohn Forte {
6091*fcf3ce44SJohn Forte float		lunMbytes;
6092*fcf3ce44SJohn Forte struct scsi_capacity_16 cap_data;
6093*fcf3ce44SJohn Forte struct dlist	*mlist;
6094*fcf3ce44SJohn Forte struct	my_mode_caching	*pg8_buf;
6095*fcf3ce44SJohn Forte int		err;
6096*fcf3ce44SJohn Forte L_inquiry	inq;
6097*fcf3ce44SJohn Forte hrtime_t	start_time, end_time;
6098*fcf3ce44SJohn Forte char		*envdb = NULL;
6099*fcf3ce44SJohn Forte int		peripheral_qual;
6100*fcf3ce44SJohn Forte L_inquiry80	inq80;
6101*fcf3ce44SJohn Forte size_t		serial_len = sizeof (inq80.inq_serial);
6102*fcf3ce44SJohn Forte 
6103*fcf3ce44SJohn Forte 	if ((envdb = getenv("_LUX_T_DEBUG")) != NULL) {
6104*fcf3ce44SJohn Forte 		start_time = gethrtime();
6105*fcf3ce44SJohn Forte 	}
6106*fcf3ce44SJohn Forte 
6107*fcf3ce44SJohn Forte 	memset(&cap_data, 0, sizeof (cap_data));
6108*fcf3ce44SJohn Forte 
6109*fcf3ce44SJohn Forte 	if (err = g_get_inquiry(phys_path, &inq)) {
6110*fcf3ce44SJohn Forte 	    fprintf(stderr, "\n");
6111*fcf3ce44SJohn Forte 	    print_errString(err, phys_path);
6112*fcf3ce44SJohn Forte 	    fprintf(stderr, "\n");
6113*fcf3ce44SJohn Forte 	    exit(1);
6114*fcf3ce44SJohn Forte 	}
6115*fcf3ce44SJohn Forte 
6116*fcf3ce44SJohn Forte 	if (err = g_get_serial_number(phys_path, inq80.inq_serial,
6117*fcf3ce44SJohn Forte 	    &serial_len)) {
6118*fcf3ce44SJohn Forte 		fprintf(stderr, "\n");
6119*fcf3ce44SJohn Forte 		print_errString(err, phys_path);
6120*fcf3ce44SJohn Forte 		fprintf(stderr, "\n");
6121*fcf3ce44SJohn Forte 		exit(1);
6122*fcf3ce44SJohn Forte 	}
6123*fcf3ce44SJohn Forte 	/*
6124*fcf3ce44SJohn Forte 	 * check to see if the peripheral qualifier is zero
6125*fcf3ce44SJohn Forte 	 * if it is non-zero, we will return with an error.
6126*fcf3ce44SJohn Forte 	 */
6127*fcf3ce44SJohn Forte 	peripheral_qual = inq.inq_dtype & ~DTYPE_MASK;
6128*fcf3ce44SJohn Forte 	if (peripheral_qual != DPQ_POSSIBLE) {
6129*fcf3ce44SJohn Forte 		fprintf(stderr, MSGSTR(2254, "\n Error: Logical Unit "
6130*fcf3ce44SJohn Forte 			    "(%s) is not available.\n"), phys_path);
6131*fcf3ce44SJohn Forte 		exit(1);
6132*fcf3ce44SJohn Forte 	}
6133*fcf3ce44SJohn Forte 
6134*fcf3ce44SJohn Forte 	fprintf(stdout, "  ");
6135*fcf3ce44SJohn Forte 	fprintf(stdout, MSGSTR(3, "Vendor:"));
6136*fcf3ce44SJohn Forte 	fprintf(stdout, "\t\t");
6137*fcf3ce44SJohn Forte 	print_chars(inq.inq_vid, sizeof (inq.inq_vid), 0);
6138*fcf3ce44SJohn Forte 	fprintf(stdout, MSGSTR(2115, "\n  Product ID:\t\t"));
6139*fcf3ce44SJohn Forte 	print_chars(inq.inq_pid, sizeof (inq.inq_pid), 0);
6140*fcf3ce44SJohn Forte 
6141*fcf3ce44SJohn Forte 	fprintf(stdout, "\n  ");
6142*fcf3ce44SJohn Forte 	fprintf(stdout, MSGSTR(2119, "Revision:"));
6143*fcf3ce44SJohn Forte 	fprintf(stdout, "\t\t");
6144*fcf3ce44SJohn Forte 	print_chars(inq.inq_revision, sizeof (inq.inq_revision), 0);
6145*fcf3ce44SJohn Forte 
6146*fcf3ce44SJohn Forte 	fprintf(stdout, "\n  ");
6147*fcf3ce44SJohn Forte 	fprintf(stdout, MSGSTR(17, "Serial Num:"));
6148*fcf3ce44SJohn Forte 	fprintf(stdout, "\t\t");
6149*fcf3ce44SJohn Forte 	print_chars(inq80.inq_serial, serial_len, 0);
6150*fcf3ce44SJohn Forte 
6151*fcf3ce44SJohn Forte 	if ((inq.inq_dtype & DTYPE_MASK) == DTYPE_DIRECT) {
6152*fcf3ce44SJohn Forte 		if ((err = get_lun_capacity(phys_path, &cap_data)) != 0) {
6153*fcf3ce44SJohn Forte 			print_errString(err, phys_path);
6154*fcf3ce44SJohn Forte 			exit(1);
6155*fcf3ce44SJohn Forte 		}
6156*fcf3ce44SJohn Forte 
6157*fcf3ce44SJohn Forte 		if (cap_data.sc_capacity > 0 && cap_data.sc_lbasize > 0) {
6158*fcf3ce44SJohn Forte 			lunMbytes = cap_data.sc_capacity + 1;
6159*fcf3ce44SJohn Forte 			lunMbytes *= cap_data.sc_lbasize;
6160*fcf3ce44SJohn Forte 			lunMbytes /= (float)(1024*1024);
6161*fcf3ce44SJohn Forte 			fprintf(stdout, "\n  ");
6162*fcf3ce44SJohn Forte 			fprintf(stdout, MSGSTR(60,
6163*fcf3ce44SJohn Forte 			"Unformatted capacity:\t%6.3f MBytes"), lunMbytes);
6164*fcf3ce44SJohn Forte 		}
6165*fcf3ce44SJohn Forte 	}
6166*fcf3ce44SJohn Forte 
6167*fcf3ce44SJohn Forte 	fprintf(stdout, "\n");
6168*fcf3ce44SJohn Forte 
6169*fcf3ce44SJohn Forte 	if ((mode_data_avail) && (pg_hdr->code == MODEPAGE_CACHING)) {
6170*fcf3ce44SJohn Forte 		pg8_buf = (struct my_mode_caching *)(void *)pg_hdr;
6171*fcf3ce44SJohn Forte 		if (pg8_buf->wce) {
6172*fcf3ce44SJohn Forte 			fprintf(stdout, MSGSTR(2122, "  Write Cache:\t\t"
6173*fcf3ce44SJohn Forte 				"Enabled\n"));
6174*fcf3ce44SJohn Forte 		}
6175*fcf3ce44SJohn Forte 		if (pg8_buf->rcd == 0) {
6176*fcf3ce44SJohn Forte 			fprintf(stdout, MSGSTR(2123, "  Read Cache:\t\t"
6177*fcf3ce44SJohn Forte 				"Enabled\n"));
6178*fcf3ce44SJohn Forte 			fprintf(stdout, MSGSTR(2124, "    Minimum prefetch:"
6179*fcf3ce44SJohn Forte 				"\t0x%x\n    Maximum prefetch:\t0x%x\n"),
6180*fcf3ce44SJohn Forte 				pg8_buf->min_prefetch,
6181*fcf3ce44SJohn Forte 				pg8_buf->max_prefetch);
6182*fcf3ce44SJohn Forte 		}
6183*fcf3ce44SJohn Forte 	}
6184*fcf3ce44SJohn Forte 
6185*fcf3ce44SJohn Forte 	fprintf(stdout, "  %s\t\t%s\n", MSGSTR(35, "Device Type:"),
6186*fcf3ce44SJohn Forte 			dtype[inq.inq_dtype & DTYPE_MASK]);
6187*fcf3ce44SJohn Forte 
6188*fcf3ce44SJohn Forte 
6189*fcf3ce44SJohn Forte 	fprintf(stdout, MSGSTR(2128, "  Path(s):\n"));
6190*fcf3ce44SJohn Forte 	fprintf(stdout, "\n");
6191*fcf3ce44SJohn Forte 
6192*fcf3ce44SJohn Forte 	if ((mlist = l_disk_state.g_disk_state.multipath_list) == NULL) {
6193*fcf3ce44SJohn Forte 		fprintf(stderr, MSGSTR(2323, "Error: No paths found (%s)"),
6194*fcf3ce44SJohn Forte 			path_struct->argv);
6195*fcf3ce44SJohn Forte 		exit(1);
6196*fcf3ce44SJohn Forte 	}
6197*fcf3ce44SJohn Forte 
6198*fcf3ce44SJohn Forte 
6199*fcf3ce44SJohn Forte 	if (strstr(mlist->dev_path, SCSI_VHCI) != NULL) {
6200*fcf3ce44SJohn Forte 		fprintf(stdout, "  %s\n  %s\n",
6201*fcf3ce44SJohn Forte 			mlist->logical_path, mlist->dev_path);
6202*fcf3ce44SJohn Forte 		adm_print_pathlist(mlist->dev_path);
6203*fcf3ce44SJohn Forte 	} else {
6204*fcf3ce44SJohn Forte 		/*
6205*fcf3ce44SJohn Forte 		 * first display user's requested path
6206*fcf3ce44SJohn Forte 		 * This will avoid duplicate inquiries as well
6207*fcf3ce44SJohn Forte 		 */
6208*fcf3ce44SJohn Forte 		for (mlist = l_disk_state.g_disk_state.multipath_list;
6209*fcf3ce44SJohn Forte 			mlist != NULL; mlist = mlist->next) {
6210*fcf3ce44SJohn Forte 		    if ((strcmp(mlist->dev_path, path_struct->p_physical_path))
6211*fcf3ce44SJohn Forte 				== 0) {
6212*fcf3ce44SJohn Forte 			display_path_info(mlist->dev_path, mlist->logical_path,
6213*fcf3ce44SJohn Forte 				wwn_list);
6214*fcf3ce44SJohn Forte 			break;
6215*fcf3ce44SJohn Forte 		    }
6216*fcf3ce44SJohn Forte 		}
6217*fcf3ce44SJohn Forte 
6218*fcf3ce44SJohn Forte 		/*
6219*fcf3ce44SJohn Forte 		 * Now display rest of paths
6220*fcf3ce44SJohn Forte 		 * skipping one already displayed
6221*fcf3ce44SJohn Forte 		 */
6222*fcf3ce44SJohn Forte 		for (mlist = l_disk_state.g_disk_state.multipath_list;
6223*fcf3ce44SJohn Forte 			mlist != NULL; mlist = mlist->next) {
6224*fcf3ce44SJohn Forte 		    if ((strcmp(mlist->dev_path, path_struct->p_physical_path))
6225*fcf3ce44SJohn Forte 				== 0) {
6226*fcf3ce44SJohn Forte 			continue;
6227*fcf3ce44SJohn Forte 		    }
6228*fcf3ce44SJohn Forte 		    if (err = g_get_inquiry(mlist->dev_path, &inq)) {
6229*fcf3ce44SJohn Forte 			fprintf(stderr, "\n");
6230*fcf3ce44SJohn Forte 			print_errString(err, mlist->dev_path);
6231*fcf3ce44SJohn Forte 			fprintf(stderr, "\n");
6232*fcf3ce44SJohn Forte 			exit(1);
6233*fcf3ce44SJohn Forte 		    }
6234*fcf3ce44SJohn Forte 		    display_path_info(mlist->dev_path, mlist->logical_path,
6235*fcf3ce44SJohn Forte 				wwn_list);
6236*fcf3ce44SJohn Forte 		}
6237*fcf3ce44SJohn Forte 	}
6238*fcf3ce44SJohn Forte 	fprintf(stdout, "\n");
6239*fcf3ce44SJohn Forte 
6240*fcf3ce44SJohn Forte 	if (envdb != NULL) {
6241*fcf3ce44SJohn Forte 		end_time = gethrtime();
6242*fcf3ce44SJohn Forte 		fprintf(stdout, "      display_lun_info: "
6243*fcf3ce44SJohn Forte 		"\t\tTime = %lld millisec\n",
6244*fcf3ce44SJohn Forte 		(end_time - start_time)/1000000);
6245*fcf3ce44SJohn Forte 	}
6246*fcf3ce44SJohn Forte }
6247*fcf3ce44SJohn Forte 
6248*fcf3ce44SJohn Forte /*
6249*fcf3ce44SJohn Forte  * display_path_info() Prints the path specific information
6250*fcf3ce44SJohn Forte  * for a lun.
6251*fcf3ce44SJohn Forte  * Note: Only applies to ssd nodes currently
6252*fcf3ce44SJohn Forte  *
6253*fcf3ce44SJohn Forte  * RETURNS:
6254*fcf3ce44SJohn Forte  *	none.
6255*fcf3ce44SJohn Forte  */
6256*fcf3ce44SJohn Forte static void
6257*fcf3ce44SJohn Forte display_path_info(char *devpath, char *logicalpath, WWN_list *wwn_list)
6258*fcf3ce44SJohn Forte {
6259*fcf3ce44SJohn Forte WWN_list	*wwn_list_walk;
6260*fcf3ce44SJohn Forte int		err;
6261*fcf3ce44SJohn Forte uchar_t		wwn_data[WWN_SIZE];
6262*fcf3ce44SJohn Forte char		wwns[(WWN_SIZE *2) +1];
6263*fcf3ce44SJohn Forte char		drvr_path[MAXPATHLEN];
6264*fcf3ce44SJohn Forte char		*cptr;
6265*fcf3ce44SJohn Forte int		status;
6266*fcf3ce44SJohn Forte 
6267*fcf3ce44SJohn Forte 	fprintf(stdout, "  %s\n", logicalpath);
6268*fcf3ce44SJohn Forte 	fprintf(stdout, "  %s\n", devpath);
6269*fcf3ce44SJohn Forte 	fprintf(stdout, "    %s\t\t", MSGSTR(2321, "LUN path port WWN:"));
6270*fcf3ce44SJohn Forte 
6271*fcf3ce44SJohn Forte 	/*
6272*fcf3ce44SJohn Forte 	 * Walk the wwn list passed in and print the
6273*fcf3ce44SJohn Forte 	 * port wwn matching the device path
6274*fcf3ce44SJohn Forte 	 */
6275*fcf3ce44SJohn Forte 	for (wwn_list_walk = wwn_list; wwn_list_walk != NULL;
6276*fcf3ce44SJohn Forte 		wwn_list_walk = wwn_list_walk->wwn_next) {
6277*fcf3ce44SJohn Forte 		if (strcmp(wwn_list_walk->physical_path, devpath) == 0) {
6278*fcf3ce44SJohn Forte 			fprintf(stdout, "%s", wwn_list_walk->port_wwn_s);
6279*fcf3ce44SJohn Forte 			break;
6280*fcf3ce44SJohn Forte 		}
6281*fcf3ce44SJohn Forte 	}
6282*fcf3ce44SJohn Forte 	/*
6283*fcf3ce44SJohn Forte 	 * newline here in case port wwn not found
6284*fcf3ce44SJohn Forte 	 */
6285*fcf3ce44SJohn Forte 	fprintf(stdout, "\n");
6286*fcf3ce44SJohn Forte 
6287*fcf3ce44SJohn Forte 	drvr_path[0] = '\0';
6288*fcf3ce44SJohn Forte 	(void) strcat(drvr_path, devpath);
6289*fcf3ce44SJohn Forte 	if (((cptr = strstr(drvr_path, SLSH_DRV_NAME_SSD)) != NULL) ||
6290*fcf3ce44SJohn Forte 		((cptr = strstr(drvr_path, SLSH_DRV_NAME_ST)) != NULL)) {;
6291*fcf3ce44SJohn Forte 		*cptr = '\0';
6292*fcf3ce44SJohn Forte 	} else {
6293*fcf3ce44SJohn Forte 		fprintf(stderr, MSGSTR(2324, "Error: Incorrect path (%s)\n"),
6294*fcf3ce44SJohn Forte 				drvr_path);
6295*fcf3ce44SJohn Forte 		exit(1);
6296*fcf3ce44SJohn Forte 	}
6297*fcf3ce44SJohn Forte 	*cptr = '\0';
6298*fcf3ce44SJohn Forte 
6299*fcf3ce44SJohn Forte 	if ((err = get_host_controller_pwwn(drvr_path,
6300*fcf3ce44SJohn Forte 			(uchar_t *)&wwn_data)) != 0) {
6301*fcf3ce44SJohn Forte 		print_errString(err, drvr_path);
6302*fcf3ce44SJohn Forte 		exit(1);
6303*fcf3ce44SJohn Forte 	}
6304*fcf3ce44SJohn Forte 
6305*fcf3ce44SJohn Forte 	copy_wwn_data_to_str(wwns, wwn_data);
6306*fcf3ce44SJohn Forte 	fprintf(stdout, "    %s\t%s\n",
6307*fcf3ce44SJohn Forte 		MSGSTR(2322, "Host controller port WWN:"), wwns);
6308*fcf3ce44SJohn Forte 
6309*fcf3ce44SJohn Forte 	/*
6310*fcf3ce44SJohn Forte 	 * Determine path status
6311*fcf3ce44SJohn Forte 	 */
6312*fcf3ce44SJohn Forte 	if ((err = get_path_status(devpath, &status)) != 0) {
6313*fcf3ce44SJohn Forte 		print_errString(err, devpath);
6314*fcf3ce44SJohn Forte 		exit(1);
6315*fcf3ce44SJohn Forte 	} else {
6316*fcf3ce44SJohn Forte 		fprintf(stdout, "    %s\t\t", MSGSTR(2329, "Path status:"));
6317*fcf3ce44SJohn Forte 		display_port_status(status);
6318*fcf3ce44SJohn Forte 	}
6319*fcf3ce44SJohn Forte }
6320*fcf3ce44SJohn Forte 
6321*fcf3ce44SJohn Forte /*
6322*fcf3ce44SJohn Forte  * Retrieves the lun capacity
6323*fcf3ce44SJohn Forte  */
6324*fcf3ce44SJohn Forte static int
6325*fcf3ce44SJohn Forte get_lun_capacity(char *devpath, struct scsi_capacity_16 *cap_data)
6326*fcf3ce44SJohn Forte {
6327*fcf3ce44SJohn Forte int	fd;
6328*fcf3ce44SJohn Forte 
6329*fcf3ce44SJohn Forte 	if (devpath == NULL || cap_data == NULL) {
6330*fcf3ce44SJohn Forte 		return (L_INVALID_PATH);
6331*fcf3ce44SJohn Forte 	}
6332*fcf3ce44SJohn Forte 
6333*fcf3ce44SJohn Forte 	if ((fd = g_object_open(devpath, O_RDONLY | O_NDELAY)) == -1) {
6334*fcf3ce44SJohn Forte 		return (L_OPEN_PATH_FAIL);
6335*fcf3ce44SJohn Forte 	} else {
6336*fcf3ce44SJohn Forte 		(void) g_scsi_read_capacity_1016_cmd(fd, cap_data,
6337*fcf3ce44SJohn Forte 			sizeof (struct scsi_capacity_16));
6338*fcf3ce44SJohn Forte 		close(fd);
6339*fcf3ce44SJohn Forte 	}
6340*fcf3ce44SJohn Forte 	return (0);
6341*fcf3ce44SJohn Forte }
6342*fcf3ce44SJohn Forte 
6343*fcf3ce44SJohn Forte /*
6344*fcf3ce44SJohn Forte  * Retrieves the reservation status
6345*fcf3ce44SJohn Forte  */
6346*fcf3ce44SJohn Forte static int
6347*fcf3ce44SJohn Forte get_path_status(char *devpath, int *status)
6348*fcf3ce44SJohn Forte {
6349*fcf3ce44SJohn Forte int	fd, mystatus = 0;
6350*fcf3ce44SJohn Forte 
6351*fcf3ce44SJohn Forte 
6352*fcf3ce44SJohn Forte 	if (devpath == NULL || status == NULL) {
6353*fcf3ce44SJohn Forte 		return (L_INVALID_PATH);
6354*fcf3ce44SJohn Forte 	}
6355*fcf3ce44SJohn Forte 
6356*fcf3ce44SJohn Forte 	*status = 0;
6357*fcf3ce44SJohn Forte 	if ((fd = g_object_open(devpath, O_RDONLY | O_NDELAY)) == -1) {
6358*fcf3ce44SJohn Forte 		return (L_OPEN_PATH_FAIL);
6359*fcf3ce44SJohn Forte 	} else {
6360*fcf3ce44SJohn Forte 		if ((mystatus = g_scsi_tur(fd)) != 0) {
6361*fcf3ce44SJohn Forte 			if ((mystatus & L_SCSI_ERROR) &&
6362*fcf3ce44SJohn Forte 				((mystatus & ~L_SCSI_ERROR) == STATUS_CHECK)) {
6363*fcf3ce44SJohn Forte 				*status = L_NOT_READY;
6364*fcf3ce44SJohn Forte 			} else if ((mystatus & L_SCSI_ERROR) &&
6365*fcf3ce44SJohn Forte 				((mystatus & ~L_SCSI_ERROR) ==
6366*fcf3ce44SJohn Forte 					STATUS_RESERVATION_CONFLICT)) {
6367*fcf3ce44SJohn Forte 				*status = L_RESERVED;
6368*fcf3ce44SJohn Forte 			} else {
6369*fcf3ce44SJohn Forte 				*status = L_SCSI_ERR;
6370*fcf3ce44SJohn Forte 			}
6371*fcf3ce44SJohn Forte 		}
6372*fcf3ce44SJohn Forte 	}
6373*fcf3ce44SJohn Forte 	close(fd);
6374*fcf3ce44SJohn Forte 	return (0);
6375*fcf3ce44SJohn Forte }
6376*fcf3ce44SJohn Forte 
6377*fcf3ce44SJohn Forte /*
6378*fcf3ce44SJohn Forte  * Description:
6379*fcf3ce44SJohn Forte  *	Retrieves the port wwn associated with the hba node
6380*fcf3ce44SJohn Forte  *
6381*fcf3ce44SJohn Forte  * hba_path: /devices/pci@8,600000/SUNW,qlc@4/fp@0,0
6382*fcf3ce44SJohn Forte  * pwwn: ptr to a uchar_t array of size WWN_SIZE
6383*fcf3ce44SJohn Forte  */
6384*fcf3ce44SJohn Forte static int
6385*fcf3ce44SJohn Forte get_host_controller_pwwn(char *hba_path, uchar_t *pwwn)
6386*fcf3ce44SJohn Forte {
6387*fcf3ce44SJohn Forte char *cptr, *portptr;
6388*fcf3ce44SJohn Forte int found = 0, err, devlen;
6389*fcf3ce44SJohn Forte char my_hba_path[MAXPATHLEN];
6390*fcf3ce44SJohn Forte di_node_t node;
6391*fcf3ce44SJohn Forte di_prom_prop_t promprop;
6392*fcf3ce44SJohn Forte uchar_t *port_wwn_data = NULL;
6393*fcf3ce44SJohn Forte int di_ret;
6394*fcf3ce44SJohn Forte di_prom_handle_t ph;
6395*fcf3ce44SJohn Forte char *promname;
6396*fcf3ce44SJohn Forte uchar_t *promdata;
6397*fcf3ce44SJohn Forte uint_t path_type;
6398*fcf3ce44SJohn Forte fc_port_dev_t hba_port;
6399*fcf3ce44SJohn Forte 
6400*fcf3ce44SJohn Forte 	if (hba_path == NULL || pwwn == NULL) {
6401*fcf3ce44SJohn Forte 		return (L_INVALID_PATH);
6402*fcf3ce44SJohn Forte 	}
6403*fcf3ce44SJohn Forte 
6404*fcf3ce44SJohn Forte 	if ((path_type = g_get_path_type(hba_path)) == 0) {
6405*fcf3ce44SJohn Forte 		return (L_INVALID_PATH);
6406*fcf3ce44SJohn Forte 	}
6407*fcf3ce44SJohn Forte 
6408*fcf3ce44SJohn Forte 	/*
6409*fcf3ce44SJohn Forte 	 * ifp nodes do not have a port-wwn prom property
6410*fcf3ce44SJohn Forte 	 * so handle them via FC4 device map
6411*fcf3ce44SJohn Forte 	 */
6412*fcf3ce44SJohn Forte 	if (path_type & FC4_XPORT_MASK) {
6413*fcf3ce44SJohn Forte 		if ((err = get_FC4_host_controller_pwwn(hba_path, pwwn)) != 0) {
6414*fcf3ce44SJohn Forte 			return (err);
6415*fcf3ce44SJohn Forte 		} else {
6416*fcf3ce44SJohn Forte 			return (0);
6417*fcf3ce44SJohn Forte 		}
6418*fcf3ce44SJohn Forte 	/* For Leadville path get the port wwn through g_get_host param. */
6419*fcf3ce44SJohn Forte 	} else if ((path_type & FC_GEN_XPORT) &&
6420*fcf3ce44SJohn Forte 		((path_type & FC_FCA_MASK) == FC_FCA_MASK)) {
6421*fcf3ce44SJohn Forte 		/*
6422*fcf3ce44SJohn Forte 		 * For Leadville path, get the port wwn through
6423*fcf3ce44SJohn Forte 		 * g_get_host param. This is a general solution
6424*fcf3ce44SJohn Forte 		 * to support 3rd party vendor Leadville FCA.
6425*fcf3ce44SJohn Forte 		 */
6426*fcf3ce44SJohn Forte 		my_hba_path[0] = '\0';
6427*fcf3ce44SJohn Forte 		(void) strlcat(my_hba_path, hba_path, sizeof (my_hba_path));
6428*fcf3ce44SJohn Forte 		(void) snprintf(my_hba_path, sizeof (my_hba_path), "%s%s",
6429*fcf3ce44SJohn Forte 			hba_path, FC_CTLR);
6430*fcf3ce44SJohn Forte 		if ((err = g_get_host_params(
6431*fcf3ce44SJohn Forte 			my_hba_path, &hba_port, 0)) != 0) {
6432*fcf3ce44SJohn Forte 			return (err);
6433*fcf3ce44SJohn Forte 		} else {
6434*fcf3ce44SJohn Forte 			(void) memcpy(pwwn, &hba_port.dev_pwwn.raw_wwn[0],
6435*fcf3ce44SJohn Forte 			    WWN_SIZE);
6436*fcf3ce44SJohn Forte 			return (0);
6437*fcf3ce44SJohn Forte 		}
6438*fcf3ce44SJohn Forte 	} else if ((path_type & FC_FCA_MASK) == FC_PCI_FCA) {
6439*fcf3ce44SJohn Forte 		/*
6440*fcf3ce44SJohn Forte 		 * Get port WWN through prom property
6441*fcf3ce44SJohn Forte 		 */
6442*fcf3ce44SJohn Forte 		my_hba_path[0] = '\0';
6443*fcf3ce44SJohn Forte 		(void) strlcat(my_hba_path, hba_path, sizeof (my_hba_path));
6444*fcf3ce44SJohn Forte 		/*
6445*fcf3ce44SJohn Forte 		 * sanity check for /devices mount point
6446*fcf3ce44SJohn Forte 		 */
6447*fcf3ce44SJohn Forte 		if (strlen(my_hba_path) > (devlen = strlen("/devices"))) {
6448*fcf3ce44SJohn Forte 			cptr = &my_hba_path[devlen];
6449*fcf3ce44SJohn Forte 		} else {
6450*fcf3ce44SJohn Forte 			return (L_INVALID_PATH);
6451*fcf3ce44SJohn Forte 		}
6452*fcf3ce44SJohn Forte 
6453*fcf3ce44SJohn Forte 		/*
6454*fcf3ce44SJohn Forte 		 * Now strip off the trailing "/fp@"
6455*fcf3ce44SJohn Forte 		 */
6456*fcf3ce44SJohn Forte 		if ((portptr = strstr(cptr, "/fp@")) != NULL) {
6457*fcf3ce44SJohn Forte 			*portptr = '\0';
6458*fcf3ce44SJohn Forte 		}
6459*fcf3ce44SJohn Forte 
6460*fcf3ce44SJohn Forte 		if ((node = di_init(cptr, DINFOCPYALL)) == DI_NODE_NIL) {
6461*fcf3ce44SJohn Forte 			return (L_DEV_SNAPSHOT_FAILED);
6462*fcf3ce44SJohn Forte 		}
6463*fcf3ce44SJohn Forte 
6464*fcf3ce44SJohn Forte 		if (di_nodeid(node) == DI_SID_NODEID) {
6465*fcf3ce44SJohn Forte 			di_ret = di_prop_lookup_bytes(DDI_DEV_T_ANY, node,
6466*fcf3ce44SJohn Forte 				"port-wwn", &port_wwn_data);
6467*fcf3ce44SJohn Forte 			if (di_ret == -1 || port_wwn_data == NULL) {
6468*fcf3ce44SJohn Forte 				di_fini(node);
6469*fcf3ce44SJohn Forte 				return (L_NO_WWN_PROP_FOUND);
6470*fcf3ce44SJohn Forte 			} else {
6471*fcf3ce44SJohn Forte 				(void) memcpy(pwwn, port_wwn_data, WWN_SIZE);
6472*fcf3ce44SJohn Forte 				found++;
6473*fcf3ce44SJohn Forte 			}
6474*fcf3ce44SJohn Forte 		} else if (di_nodeid(node) == DI_PROM_NODEID) {
6475*fcf3ce44SJohn Forte 		    if ((ph = di_prom_init()) == DI_PROM_HANDLE_NIL) {
6476*fcf3ce44SJohn Forte 			di_fini(node);
6477*fcf3ce44SJohn Forte 			return (L_PROM_INIT_FAILED);
6478*fcf3ce44SJohn Forte 		    }
6479*fcf3ce44SJohn Forte 
6480*fcf3ce44SJohn Forte 		    for (promprop = di_prom_prop_next(ph, node,
6481*fcf3ce44SJohn Forte 			DI_PROM_PROP_NIL);
6482*fcf3ce44SJohn Forte 			promprop != DI_PROM_PROP_NIL;
6483*fcf3ce44SJohn Forte 			promprop = di_prom_prop_next(ph, node, promprop)) {
6484*fcf3ce44SJohn Forte 			if (((promname = di_prom_prop_name(
6485*fcf3ce44SJohn Forte 				promprop)) != NULL) &&
6486*fcf3ce44SJohn Forte 				(strcmp(promname, "port-wwn") == 0) &&
6487*fcf3ce44SJohn Forte 				(di_prom_prop_data(promprop,
6488*fcf3ce44SJohn Forte 					&promdata) == WWN_SIZE)) {
6489*fcf3ce44SJohn Forte 				/* Found port-wwn */
6490*fcf3ce44SJohn Forte 				(void) memcpy(pwwn, promdata, WWN_SIZE);
6491*fcf3ce44SJohn Forte 				found++;
6492*fcf3ce44SJohn Forte 				break;
6493*fcf3ce44SJohn Forte 			}
6494*fcf3ce44SJohn Forte 		    }
6495*fcf3ce44SJohn Forte 		    di_prom_fini(ph);
6496*fcf3ce44SJohn Forte 		}
6497*fcf3ce44SJohn Forte 
6498*fcf3ce44SJohn Forte 		di_fini(node);
6499*fcf3ce44SJohn Forte 		if (found) {
6500*fcf3ce44SJohn Forte 			return (0);
6501*fcf3ce44SJohn Forte 		} else {
6502*fcf3ce44SJohn Forte 			return (L_INVALID_PATH);
6503*fcf3ce44SJohn Forte 		}
6504*fcf3ce44SJohn Forte 	} else {
6505*fcf3ce44SJohn Forte 		return (L_INVALID_PATH_TYPE);
6506*fcf3ce44SJohn Forte 	}
6507*fcf3ce44SJohn Forte }
6508*fcf3ce44SJohn Forte 
6509*fcf3ce44SJohn Forte 
6510*fcf3ce44SJohn Forte /*
6511*fcf3ce44SJohn Forte  * Description:
6512*fcf3ce44SJohn Forte  *    Retrieve pwwn via SFIOCGMAP
6513*fcf3ce44SJohn Forte  */
6514*fcf3ce44SJohn Forte static int
6515*fcf3ce44SJohn Forte get_FC4_host_controller_pwwn(char *hba_path, uchar_t *pwwn)
6516*fcf3ce44SJohn Forte {
6517*fcf3ce44SJohn Forte sf_al_map_t sf_map;
6518*fcf3ce44SJohn Forte char my_hba_path[MAXPATHLEN];
6519*fcf3ce44SJohn Forte int fd;
6520*fcf3ce44SJohn Forte 
6521*fcf3ce44SJohn Forte 	if (hba_path == NULL || pwwn == NULL) {
6522*fcf3ce44SJohn Forte 		return (L_INVALID_PATH);
6523*fcf3ce44SJohn Forte 	}
6524*fcf3ce44SJohn Forte 
6525*fcf3ce44SJohn Forte 	(void) snprintf(my_hba_path, sizeof (my_hba_path), "%s%s",
6526*fcf3ce44SJohn Forte 			hba_path, FC_CTLR);
6527*fcf3ce44SJohn Forte 
6528*fcf3ce44SJohn Forte 	if ((fd = g_object_open(my_hba_path, O_NDELAY | O_RDONLY)) == -1) {
6529*fcf3ce44SJohn Forte 		return (errno);
6530*fcf3ce44SJohn Forte 	}
6531*fcf3ce44SJohn Forte 
6532*fcf3ce44SJohn Forte 	memset(&sf_map, 0, sizeof (sf_al_map_t));
6533*fcf3ce44SJohn Forte 
6534*fcf3ce44SJohn Forte 	if (ioctl(fd, SFIOCGMAP, &sf_map) != 0) {
6535*fcf3ce44SJohn Forte 		close(fd);
6536*fcf3ce44SJohn Forte 		return (L_SFIOCGMAP_IOCTL_FAIL);
6537*fcf3ce44SJohn Forte 	}
6538*fcf3ce44SJohn Forte 
6539*fcf3ce44SJohn Forte 	close(fd);
6540*fcf3ce44SJohn Forte 
6541*fcf3ce44SJohn Forte 	if (sf_map.sf_count == 0) {
6542*fcf3ce44SJohn Forte 		close(fd);
6543*fcf3ce44SJohn Forte 		return (L_SFIOCGMAP_IOCTL_FAIL);
6544*fcf3ce44SJohn Forte 	}
6545*fcf3ce44SJohn Forte 
6546*fcf3ce44SJohn Forte 	(void) memcpy(pwwn, &sf_map.sf_hba_addr.sf_port_wwn[0], WWN_SIZE);
6547*fcf3ce44SJohn Forte 
6548*fcf3ce44SJohn Forte 	return (0);
6549*fcf3ce44SJohn Forte }
6550*fcf3ce44SJohn Forte 
6551*fcf3ce44SJohn Forte /*
6552*fcf3ce44SJohn Forte  * from_ptr: ptr to uchar_t array of size WWN_SIZE
6553*fcf3ce44SJohn Forte  * to_ptr: char ptr to string of size WWN_SIZE*2+1
6554*fcf3ce44SJohn Forte  */
6555*fcf3ce44SJohn Forte void
6556*fcf3ce44SJohn Forte copy_wwn_data_to_str(char *to_ptr, const uchar_t *from_ptr)
6557*fcf3ce44SJohn Forte {
6558*fcf3ce44SJohn Forte 	if ((to_ptr == NULL) || (from_ptr == NULL))
6559*fcf3ce44SJohn Forte 		return;
6560*fcf3ce44SJohn Forte 
6561*fcf3ce44SJohn Forte 	sprintf(to_ptr, "%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x",
6562*fcf3ce44SJohn Forte 	from_ptr[0], from_ptr[1], from_ptr[2], from_ptr[3],
6563*fcf3ce44SJohn Forte 	from_ptr[4], from_ptr[5], from_ptr[6], from_ptr[7]);
6564*fcf3ce44SJohn Forte }
6565*fcf3ce44SJohn Forte 
6566*fcf3ce44SJohn Forte /*
6567*fcf3ce44SJohn Forte  * Frees a previously allocated mplist_struct
6568*fcf3ce44SJohn Forte  */
6569*fcf3ce44SJohn Forte void
6570*fcf3ce44SJohn Forte adm_mplist_free(struct mplist_struct *mplistp)
6571*fcf3ce44SJohn Forte {
6572*fcf3ce44SJohn Forte struct mplist_struct *mplistn;
6573*fcf3ce44SJohn Forte 
6574*fcf3ce44SJohn Forte 	while (mplistp != NULL) {
6575*fcf3ce44SJohn Forte 		mplistn = mplistp->next;
6576*fcf3ce44SJohn Forte 		if (mplistp->devpath != NULL) {
6577*fcf3ce44SJohn Forte 			free(mplistp->devpath);
6578*fcf3ce44SJohn Forte 			mplistp->devpath = NULL;
6579*fcf3ce44SJohn Forte 		}
6580*fcf3ce44SJohn Forte 		free(mplistp);
6581*fcf3ce44SJohn Forte 		mplistp = mplistn;
6582*fcf3ce44SJohn Forte 	}
6583*fcf3ce44SJohn Forte }
6584*fcf3ce44SJohn Forte 
6585*fcf3ce44SJohn Forte int
6586*fcf3ce44SJohn Forte adm_reserve(char *path)
6587*fcf3ce44SJohn Forte {
6588*fcf3ce44SJohn Forte 	char	*path_phys = NULL;
6589*fcf3ce44SJohn Forte 	int	err;
6590*fcf3ce44SJohn Forte 	if ((path_phys =
6591*fcf3ce44SJohn Forte 		    g_get_physical_name(path)) == NULL) {
6592*fcf3ce44SJohn Forte 
6593*fcf3ce44SJohn Forte 		(void) fprintf(stderr, "%s: ", whoami);
6594*fcf3ce44SJohn Forte 		(void) fprintf(stderr,
6595*fcf3ce44SJohn Forte 			MSGSTR(112, "Error: Invalid pathname (%s)"),
6596*fcf3ce44SJohn Forte 			path);
6597*fcf3ce44SJohn Forte 		(void) fprintf(stderr, "\n");
6598*fcf3ce44SJohn Forte 		return (1);
6599*fcf3ce44SJohn Forte 	}
6600*fcf3ce44SJohn Forte 
6601*fcf3ce44SJohn Forte 	if ((err = g_reserve(path_phys)) != 0) {
6602*fcf3ce44SJohn Forte 	    (void) print_errString(err, path);
6603*fcf3ce44SJohn Forte 	    return (1);
6604*fcf3ce44SJohn Forte 	}
6605*fcf3ce44SJohn Forte 	return (0);
6606*fcf3ce44SJohn Forte }
6607*fcf3ce44SJohn Forte 
6608*fcf3ce44SJohn Forte int
6609*fcf3ce44SJohn Forte adm_release(char *path)
6610*fcf3ce44SJohn Forte {
6611*fcf3ce44SJohn Forte 	char	*path_phys = NULL;
6612*fcf3ce44SJohn Forte 	int	err;
6613*fcf3ce44SJohn Forte 	if ((path_phys =
6614*fcf3ce44SJohn Forte 		    g_get_physical_name(path)) == NULL) {
6615*fcf3ce44SJohn Forte 
6616*fcf3ce44SJohn Forte 		(void) fprintf(stderr, "%s: ", whoami);
6617*fcf3ce44SJohn Forte 		(void) fprintf(stderr,
6618*fcf3ce44SJohn Forte 			MSGSTR(112, "Error: Invalid pathname (%s)"),
6619*fcf3ce44SJohn Forte 			path);
6620*fcf3ce44SJohn Forte 		(void) fprintf(stderr, "\n");
6621*fcf3ce44SJohn Forte 		return (1);
6622*fcf3ce44SJohn Forte 	}
6623*fcf3ce44SJohn Forte 
6624*fcf3ce44SJohn Forte 	if ((err = g_release(path_phys)) != 0) {
6625*fcf3ce44SJohn Forte 	    (void) print_errString(err, path);
6626*fcf3ce44SJohn Forte 	    return (1);
6627*fcf3ce44SJohn Forte 	}
6628*fcf3ce44SJohn Forte 	return (0);
6629*fcf3ce44SJohn Forte }
6630*fcf3ce44SJohn Forte 
6631*fcf3ce44SJohn Forte void
6632*fcf3ce44SJohn Forte i18n_catopen() {
6633*fcf3ce44SJohn Forte     (void) g_i18n_catopen();
6634*fcf3ce44SJohn Forte }
6635*fcf3ce44SJohn Forte 
6636*fcf3ce44SJohn Forte int adm_check_file(char **path, int flag) {
6637*fcf3ce44SJohn Forte 	int err;
6638*fcf3ce44SJohn Forte 	if (err = l_check_file(*path, flag)) {
6639*fcf3ce44SJohn Forte 	    (void) print_errString(err, *path);
6640*fcf3ce44SJohn Forte 	    return (-1);
6641*fcf3ce44SJohn Forte 	}
6642*fcf3ce44SJohn Forte 
6643*fcf3ce44SJohn Forte 	(void) fprintf(stdout, MSGSTR(2212, "Download file O.K. \n\n"));
6644*fcf3ce44SJohn Forte 	return (0);
6645*fcf3ce44SJohn Forte }
6646*fcf3ce44SJohn Forte 
6647*fcf3ce44SJohn Forte /*
6648*fcf3ce44SJohn Forte  * Print out private loop dev dtype
6649*fcf3ce44SJohn Forte  */
6650*fcf3ce44SJohn Forte void
6651*fcf3ce44SJohn Forte print_private_loop_dtype_prop(uchar_t *hba_port_wwn, uchar_t *port_wwn,
6652*fcf3ce44SJohn Forte 	uchar_t dtype_prop)
6653*fcf3ce44SJohn Forte {
6654*fcf3ce44SJohn Forte 	if ((dtype_prop & DTYPE_MASK) < 0x10) {
6655*fcf3ce44SJohn Forte 		(void) fprintf(stdout, " 0x%-2x (%s",
6656*fcf3ce44SJohn Forte 		(dtype_prop & DTYPE_MASK), dtype[(dtype_prop & DTYPE_MASK)]);
6657*fcf3ce44SJohn Forte 	} else if ((dtype_prop & DTYPE_MASK) < 0x1f) {
6658*fcf3ce44SJohn Forte 		(void) fprintf(stdout,
6659*fcf3ce44SJohn Forte 		MSGSTR(2243, " 0x%-2x (Reserved"),
6660*fcf3ce44SJohn Forte 		(dtype_prop & DTYPE_MASK));
6661*fcf3ce44SJohn Forte 	} else {
6662*fcf3ce44SJohn Forte 		(void) fprintf(stdout, MSGSTR(2245,
6663*fcf3ce44SJohn Forte 		" 0x%-2x (Unknown Type"), (dtype_prop & DTYPE_MASK));
6664*fcf3ce44SJohn Forte 	}
6665*fcf3ce44SJohn Forte 	/* Check to see if this is the HBA */
6666*fcf3ce44SJohn Forte 	if (wwnConversion(hba_port_wwn) == wwnConversion(port_wwn)) {
6667*fcf3ce44SJohn Forte 		/* MATCH */
6668*fcf3ce44SJohn Forte 		(void) fprintf(stdout, MSGSTR(2244,
6669*fcf3ce44SJohn Forte 		",Host Bus Adapter)\n"));
6670*fcf3ce44SJohn Forte 	} else {
6671*fcf3ce44SJohn Forte 		(void) fprintf(stdout, ")\n");
6672*fcf3ce44SJohn Forte 	}
6673*fcf3ce44SJohn Forte }
6674