xref: /onnv-gate/usr/src/cmd/fcinfo/printAttrs.c (revision 7836:4e95154b5b7a)
1*7836SJohn.Forte@Sun.COM /*
2*7836SJohn.Forte@Sun.COM  * CDDL HEADER START
3*7836SJohn.Forte@Sun.COM  *
4*7836SJohn.Forte@Sun.COM  * The contents of this file are subject to the terms of the
5*7836SJohn.Forte@Sun.COM  * Common Development and Distribution License (the "License").
6*7836SJohn.Forte@Sun.COM  * You may not use this file except in compliance with the License.
7*7836SJohn.Forte@Sun.COM  *
8*7836SJohn.Forte@Sun.COM  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*7836SJohn.Forte@Sun.COM  * or http://www.opensolaris.org/os/licensing.
10*7836SJohn.Forte@Sun.COM  * See the License for the specific language governing permissions
11*7836SJohn.Forte@Sun.COM  * and limitations under the License.
12*7836SJohn.Forte@Sun.COM  *
13*7836SJohn.Forte@Sun.COM  * When distributing Covered Code, include this CDDL HEADER in each
14*7836SJohn.Forte@Sun.COM  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*7836SJohn.Forte@Sun.COM  * If applicable, add the following below this CDDL HEADER, with the
16*7836SJohn.Forte@Sun.COM  * fields enclosed by brackets "[]" replaced with your own identifying
17*7836SJohn.Forte@Sun.COM  * information: Portions Copyright [yyyy] [name of copyright owner]
18*7836SJohn.Forte@Sun.COM  *
19*7836SJohn.Forte@Sun.COM  * CDDL HEADER END
20*7836SJohn.Forte@Sun.COM  */
21*7836SJohn.Forte@Sun.COM /*
22*7836SJohn.Forte@Sun.COM  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23*7836SJohn.Forte@Sun.COM  * Use is subject to license terms.
24*7836SJohn.Forte@Sun.COM  */
25*7836SJohn.Forte@Sun.COM 
26*7836SJohn.Forte@Sun.COM 
27*7836SJohn.Forte@Sun.COM 
28*7836SJohn.Forte@Sun.COM #include <stdio.h>
29*7836SJohn.Forte@Sun.COM #include <hbaapi.h>
30*7836SJohn.Forte@Sun.COM #include <string.h>
31*7836SJohn.Forte@Sun.COM #include <sys/types.h>
32*7836SJohn.Forte@Sun.COM #include <netinet/in.h>
33*7836SJohn.Forte@Sun.COM #include <inttypes.h>
34*7836SJohn.Forte@Sun.COM #include <ctype.h>
35*7836SJohn.Forte@Sun.COM #include "fcinfo.h"
36*7836SJohn.Forte@Sun.COM 
37*7836SJohn.Forte@Sun.COM #ifdef _BIG_ENDIAN
38*7836SJohn.Forte@Sun.COM #define	htonll(x)   (x)
39*7836SJohn.Forte@Sun.COM #define	ntohll(x)   (x)
40*7836SJohn.Forte@Sun.COM #else
41*7836SJohn.Forte@Sun.COM #define	htonll(x)   ((((unsigned long long)htonl(x)) << 32) + htonl(x >> 32))
42*7836SJohn.Forte@Sun.COM #define	ntohll(x)   ((((unsigned long long)ntohl(x)) << 32) + ntohl(x >> 32))
43*7836SJohn.Forte@Sun.COM #endif
44*7836SJohn.Forte@Sun.COM 
45*7836SJohn.Forte@Sun.COM /* Fc4 Types Format */
46*7836SJohn.Forte@Sun.COM #define	FC4_TYPE_WORD_POS(x)	    ((uint_t)((uint_t)(x) >> 5))
47*7836SJohn.Forte@Sun.COM #define	FC4_TYPE_BIT_POS(x)	    ((uchar_t)(x) & 0x1F)
48*7836SJohn.Forte@Sun.COM 
49*7836SJohn.Forte@Sun.COM #define	TYPE_IP_FC		    0x05
50*7836SJohn.Forte@Sun.COM #define	TYPE_SCSI_FCP		    0x08
51*7836SJohn.Forte@Sun.COM 
52*7836SJohn.Forte@Sun.COM static int fc4_map_is_set(uint32_t *map, uchar_t ulp_type);
53*7836SJohn.Forte@Sun.COM static char *getPortType(HBA_PORTTYPE portType);
54*7836SJohn.Forte@Sun.COM static char *getPortState(HBA_PORTSTATE portState);
55*7836SJohn.Forte@Sun.COM static void printPortSpeed(HBA_PORTSPEED portSpeed);
56*7836SJohn.Forte@Sun.COM static char *getDTypeString(uchar_t dType);
57*7836SJohn.Forte@Sun.COM 
wwnConversion(uchar_t * wwn)58*7836SJohn.Forte@Sun.COM uint64_t wwnConversion(uchar_t *wwn) {
59*7836SJohn.Forte@Sun.COM 	uint64_t tmp;
60*7836SJohn.Forte@Sun.COM 	memcpy(&tmp, wwn, sizeof (uint64_t));
61*7836SJohn.Forte@Sun.COM 	return (ntohll(tmp));
62*7836SJohn.Forte@Sun.COM }
63*7836SJohn.Forte@Sun.COM 
64*7836SJohn.Forte@Sun.COM static char *
getPortType(HBA_PORTTYPE portType)65*7836SJohn.Forte@Sun.COM getPortType(HBA_PORTTYPE portType) {
66*7836SJohn.Forte@Sun.COM 	switch (portType) {
67*7836SJohn.Forte@Sun.COM 	case HBA_PORTTYPE_UNKNOWN:
68*7836SJohn.Forte@Sun.COM 	    return ("unknown");
69*7836SJohn.Forte@Sun.COM 	case HBA_PORTTYPE_OTHER:
70*7836SJohn.Forte@Sun.COM 	    return ("other");
71*7836SJohn.Forte@Sun.COM 	case HBA_PORTTYPE_NOTPRESENT:
72*7836SJohn.Forte@Sun.COM 	    return ("not present");
73*7836SJohn.Forte@Sun.COM 	case HBA_PORTTYPE_NPORT:
74*7836SJohn.Forte@Sun.COM 	    return ("N-port");
75*7836SJohn.Forte@Sun.COM 	case HBA_PORTTYPE_NLPORT:
76*7836SJohn.Forte@Sun.COM 	    return ("NL-port");
77*7836SJohn.Forte@Sun.COM 	case HBA_PORTTYPE_FLPORT:
78*7836SJohn.Forte@Sun.COM 	    return ("FL-port");
79*7836SJohn.Forte@Sun.COM 	case HBA_PORTTYPE_FPORT:
80*7836SJohn.Forte@Sun.COM 	    return ("F-port");
81*7836SJohn.Forte@Sun.COM 	case HBA_PORTTYPE_LPORT:
82*7836SJohn.Forte@Sun.COM 	    return ("L-port");
83*7836SJohn.Forte@Sun.COM 	case HBA_PORTTYPE_PTP:
84*7836SJohn.Forte@Sun.COM 	    return ("point-to-point");
85*7836SJohn.Forte@Sun.COM 	default:
86*7836SJohn.Forte@Sun.COM 	    return ("unrecognized type");
87*7836SJohn.Forte@Sun.COM 	}
88*7836SJohn.Forte@Sun.COM }
89*7836SJohn.Forte@Sun.COM 
90*7836SJohn.Forte@Sun.COM static char *
getPortState(HBA_PORTSTATE portState)91*7836SJohn.Forte@Sun.COM getPortState(HBA_PORTSTATE portState) {
92*7836SJohn.Forte@Sun.COM 	switch (portState) {
93*7836SJohn.Forte@Sun.COM 	case HBA_PORTSTATE_UNKNOWN:
94*7836SJohn.Forte@Sun.COM 	    return ("unknown");
95*7836SJohn.Forte@Sun.COM 	case HBA_PORTSTATE_ONLINE:
96*7836SJohn.Forte@Sun.COM 	    return ("online");
97*7836SJohn.Forte@Sun.COM 	case HBA_PORTSTATE_OFFLINE:
98*7836SJohn.Forte@Sun.COM 	    return ("offline");
99*7836SJohn.Forte@Sun.COM 	case HBA_PORTSTATE_BYPASSED:
100*7836SJohn.Forte@Sun.COM 	    return ("bypassed");
101*7836SJohn.Forte@Sun.COM 	case HBA_PORTSTATE_DIAGNOSTICS:
102*7836SJohn.Forte@Sun.COM 	    return ("diagnostics");
103*7836SJohn.Forte@Sun.COM 	case HBA_PORTSTATE_LINKDOWN:
104*7836SJohn.Forte@Sun.COM 	    return ("link down");
105*7836SJohn.Forte@Sun.COM 	case HBA_PORTSTATE_ERROR:
106*7836SJohn.Forte@Sun.COM 	    return ("error");
107*7836SJohn.Forte@Sun.COM 	case HBA_PORTSTATE_LOOPBACK:
108*7836SJohn.Forte@Sun.COM 	    return ("loopback");
109*7836SJohn.Forte@Sun.COM 	default:
110*7836SJohn.Forte@Sun.COM 	    return ("unrecognized state");
111*7836SJohn.Forte@Sun.COM 	}
112*7836SJohn.Forte@Sun.COM }
113*7836SJohn.Forte@Sun.COM 
114*7836SJohn.Forte@Sun.COM static void
printPortSpeed(HBA_PORTSPEED portSpeed)115*7836SJohn.Forte@Sun.COM printPortSpeed(HBA_PORTSPEED portSpeed) {
116*7836SJohn.Forte@Sun.COM 	int foundSpeed = 0;
117*7836SJohn.Forte@Sun.COM 
118*7836SJohn.Forte@Sun.COM 	if ((portSpeed & HBA_PORTSPEED_1GBIT) == HBA_PORTSPEED_1GBIT) {
119*7836SJohn.Forte@Sun.COM 		fprintf(stdout, "1Gb ");
120*7836SJohn.Forte@Sun.COM 		foundSpeed = 1;
121*7836SJohn.Forte@Sun.COM 	}
122*7836SJohn.Forte@Sun.COM 	if ((portSpeed & HBA_PORTSPEED_2GBIT) == HBA_PORTSPEED_2GBIT) {
123*7836SJohn.Forte@Sun.COM 		fprintf(stdout, "2Gb ");
124*7836SJohn.Forte@Sun.COM 		foundSpeed = 1;
125*7836SJohn.Forte@Sun.COM 	}
126*7836SJohn.Forte@Sun.COM 	if ((portSpeed & HBA_PORTSPEED_4GBIT) == HBA_PORTSPEED_4GBIT) {
127*7836SJohn.Forte@Sun.COM 		fprintf(stdout, "4Gb ");
128*7836SJohn.Forte@Sun.COM 		foundSpeed = 1;
129*7836SJohn.Forte@Sun.COM 	}
130*7836SJohn.Forte@Sun.COM 	if ((portSpeed & HBA_PORTSPEED_8GBIT) == HBA_PORTSPEED_8GBIT) {
131*7836SJohn.Forte@Sun.COM 		fprintf(stdout, "8Gb ");
132*7836SJohn.Forte@Sun.COM 		foundSpeed = 1;
133*7836SJohn.Forte@Sun.COM 	}
134*7836SJohn.Forte@Sun.COM 	if ((portSpeed & HBA_PORTSPEED_10GBIT) == HBA_PORTSPEED_10GBIT) {
135*7836SJohn.Forte@Sun.COM 		fprintf(stdout, "10Gb ");
136*7836SJohn.Forte@Sun.COM 		foundSpeed = 1;
137*7836SJohn.Forte@Sun.COM 	}
138*7836SJohn.Forte@Sun.COM 	if ((portSpeed & HBA_PORTSPEED_16GBIT) == HBA_PORTSPEED_16GBIT) {
139*7836SJohn.Forte@Sun.COM 		fprintf(stdout, "16Gb ");
140*7836SJohn.Forte@Sun.COM 		foundSpeed = 1;
141*7836SJohn.Forte@Sun.COM 	}
142*7836SJohn.Forte@Sun.COM 	if ((portSpeed & HBA_PORTSPEED_NOT_NEGOTIATED)
143*7836SJohn.Forte@Sun.COM 	    == HBA_PORTSPEED_NOT_NEGOTIATED) {
144*7836SJohn.Forte@Sun.COM 		fprintf(stdout, "not established ");
145*7836SJohn.Forte@Sun.COM 		foundSpeed = 1;
146*7836SJohn.Forte@Sun.COM 	}
147*7836SJohn.Forte@Sun.COM 	if (foundSpeed == 0) {
148*7836SJohn.Forte@Sun.COM 		fprintf(stdout, "not established ");
149*7836SJohn.Forte@Sun.COM 	}
150*7836SJohn.Forte@Sun.COM }
151*7836SJohn.Forte@Sun.COM 
152*7836SJohn.Forte@Sun.COM void
printDiscoPortInfo(HBA_PORTATTRIBUTES * discoPort,int scsiTargetType)153*7836SJohn.Forte@Sun.COM printDiscoPortInfo(HBA_PORTATTRIBUTES *discoPort, int scsiTargetType) {
154*7836SJohn.Forte@Sun.COM 	int fc4_types = 0;
155*7836SJohn.Forte@Sun.COM 
156*7836SJohn.Forte@Sun.COM 	fprintf(stdout, gettext("Remote Port WWN: %016llx\n"),
157*7836SJohn.Forte@Sun.COM 	    wwnConversion(discoPort->PortWWN.wwn));
158*7836SJohn.Forte@Sun.COM 	fprintf(stdout, gettext("\tActive FC4 Types: "));
159*7836SJohn.Forte@Sun.COM 	if (fc4_map_is_set(
160*7836SJohn.Forte@Sun.COM 		    (uint32_t *)discoPort->PortActiveFc4Types.bits,
161*7836SJohn.Forte@Sun.COM 		    TYPE_SCSI_FCP)) {
162*7836SJohn.Forte@Sun.COM 		fprintf(stdout, gettext("SCSI"));
163*7836SJohn.Forte@Sun.COM 		fc4_types++;
164*7836SJohn.Forte@Sun.COM 	}
165*7836SJohn.Forte@Sun.COM 	if (fc4_map_is_set(
166*7836SJohn.Forte@Sun.COM 		    (uint32_t *)discoPort->PortActiveFc4Types.bits,
167*7836SJohn.Forte@Sun.COM 		    TYPE_IP_FC)) {
168*7836SJohn.Forte@Sun.COM 		if (fc4_types != 0) {
169*7836SJohn.Forte@Sun.COM 			fprintf(stdout, ",");
170*7836SJohn.Forte@Sun.COM 		}
171*7836SJohn.Forte@Sun.COM 		fprintf(stdout, gettext("IP"));
172*7836SJohn.Forte@Sun.COM 		fc4_types++;
173*7836SJohn.Forte@Sun.COM 	}
174*7836SJohn.Forte@Sun.COM 	fprintf(stdout, "\n");
175*7836SJohn.Forte@Sun.COM 
176*7836SJohn.Forte@Sun.COM 	/* print out scsi target type information */
177*7836SJohn.Forte@Sun.COM 	fprintf(stdout, gettext("\tSCSI Target: "));
178*7836SJohn.Forte@Sun.COM 	if (scsiTargetType == SCSI_TARGET_TYPE_YES) {
179*7836SJohn.Forte@Sun.COM 		fprintf(stdout, gettext("yes\n"));
180*7836SJohn.Forte@Sun.COM 	} else if (scsiTargetType == SCSI_TARGET_TYPE_NO) {
181*7836SJohn.Forte@Sun.COM 		fprintf(stdout, gettext("no\n"));
182*7836SJohn.Forte@Sun.COM 	} else {
183*7836SJohn.Forte@Sun.COM 		fprintf(stdout, gettext("unknown\n"));
184*7836SJohn.Forte@Sun.COM 	}
185*7836SJohn.Forte@Sun.COM 	fprintf(stdout, gettext("\tPort Symbolic Name: %s\n"),
186*7836SJohn.Forte@Sun.COM 	    discoPort->PortSymbolicName);
187*7836SJohn.Forte@Sun.COM 	fprintf(stdout, gettext("\tNode WWN: %016llx\n"),
188*7836SJohn.Forte@Sun.COM 	    wwnConversion(discoPort->NodeWWN.wwn));
189*7836SJohn.Forte@Sun.COM }
190*7836SJohn.Forte@Sun.COM 
191*7836SJohn.Forte@Sun.COM /*
192*7836SJohn.Forte@Sun.COM  * scan the bitmap array for the specifed ULP type. The bit map array
193*7836SJohn.Forte@Sun.COM  * is 32 bytes long
194*7836SJohn.Forte@Sun.COM  */
195*7836SJohn.Forte@Sun.COM static int
fc4_map_is_set(uint32_t * map,uchar_t ulp_type)196*7836SJohn.Forte@Sun.COM fc4_map_is_set(uint32_t *map, uchar_t ulp_type)
197*7836SJohn.Forte@Sun.COM {
198*7836SJohn.Forte@Sun.COM 
199*7836SJohn.Forte@Sun.COM 	map += FC4_TYPE_WORD_POS(ulp_type) * 4;
200*7836SJohn.Forte@Sun.COM 
201*7836SJohn.Forte@Sun.COM 	if (ntohl((*(uint32_t *)map)) & (1 << FC4_TYPE_BIT_POS(ulp_type))) {
202*7836SJohn.Forte@Sun.COM 		return (1);
203*7836SJohn.Forte@Sun.COM 	}
204*7836SJohn.Forte@Sun.COM 
205*7836SJohn.Forte@Sun.COM 	return (0);
206*7836SJohn.Forte@Sun.COM }
207*7836SJohn.Forte@Sun.COM 
208*7836SJohn.Forte@Sun.COM /*
209*7836SJohn.Forte@Sun.COM  * prints out all the HBA port information
210*7836SJohn.Forte@Sun.COM  */
211*7836SJohn.Forte@Sun.COM void
printHBAPortInfo(HBA_PORTATTRIBUTES * port,HBA_ADAPTERATTRIBUTES * attrs,int mode)212*7836SJohn.Forte@Sun.COM printHBAPortInfo(HBA_PORTATTRIBUTES *port,
213*7836SJohn.Forte@Sun.COM     HBA_ADAPTERATTRIBUTES *attrs, int mode) {
214*7836SJohn.Forte@Sun.COM 	if (attrs == NULL || port == NULL) {
215*7836SJohn.Forte@Sun.COM 		return;
216*7836SJohn.Forte@Sun.COM 	}
217*7836SJohn.Forte@Sun.COM 	fprintf(stdout, gettext("HBA Port WWN: %016llx\n"),
218*7836SJohn.Forte@Sun.COM 		wwnConversion(port->PortWWN.wwn));
219*7836SJohn.Forte@Sun.COM 	fprintf(stdout, gettext("\tPort Mode: %s\n"),
220*7836SJohn.Forte@Sun.COM 	    (mode == INITIATOR_MODE) ? "Initiator" : "Target");
221*7836SJohn.Forte@Sun.COM 	fprintf(stdout, gettext("\tPort ID: %x\n"),
222*7836SJohn.Forte@Sun.COM 	    port->PortFcId);
223*7836SJohn.Forte@Sun.COM 	fprintf(stdout, gettext("\tOS Device Name: %s\n"), port->OSDeviceName);
224*7836SJohn.Forte@Sun.COM 
225*7836SJohn.Forte@Sun.COM 	fprintf(stdout, gettext("\tManufacturer: %s\n"),
226*7836SJohn.Forte@Sun.COM 	    attrs->Manufacturer);
227*7836SJohn.Forte@Sun.COM 	fprintf(stdout, gettext("\tModel: %s\n"), attrs->Model);
228*7836SJohn.Forte@Sun.COM 	fprintf(stdout, gettext("\tFirmware Version: %s\n"),
229*7836SJohn.Forte@Sun.COM 	    attrs->FirmwareVersion);
230*7836SJohn.Forte@Sun.COM 	fprintf(stdout, gettext("\tFCode/BIOS Version: %s\n"),
231*7836SJohn.Forte@Sun.COM 	    attrs->OptionROMVersion);
232*7836SJohn.Forte@Sun.COM 	fprintf(stdout, gettext("\tSerial Number: %s\n"),
233*7836SJohn.Forte@Sun.COM 	    attrs->SerialNumber[0] == 0? "not available":attrs->SerialNumber);
234*7836SJohn.Forte@Sun.COM 
235*7836SJohn.Forte@Sun.COM 	fprintf(stdout, gettext("\tDriver Name: %s\n"),
236*7836SJohn.Forte@Sun.COM 	    attrs->DriverName[0] == 0? "not available":attrs->DriverName);
237*7836SJohn.Forte@Sun.COM 	fprintf(stdout, gettext("\tDriver Version: %s\n"),
238*7836SJohn.Forte@Sun.COM 	    attrs->DriverVersion[0] == 0? "not available":attrs->DriverVersion);
239*7836SJohn.Forte@Sun.COM 
240*7836SJohn.Forte@Sun.COM 	fprintf(stdout, gettext("\tType: %s\n"),
241*7836SJohn.Forte@Sun.COM 	    getPortType(port->PortType));
242*7836SJohn.Forte@Sun.COM 	fprintf(stdout, gettext("\tState: %s\n"),
243*7836SJohn.Forte@Sun.COM 	    getPortState(port->PortState));
244*7836SJohn.Forte@Sun.COM 
245*7836SJohn.Forte@Sun.COM 	fprintf(stdout, gettext("\tSupported Speeds: "));
246*7836SJohn.Forte@Sun.COM 	printPortSpeed(port->PortSupportedSpeed);
247*7836SJohn.Forte@Sun.COM 	fprintf(stdout, "\n");
248*7836SJohn.Forte@Sun.COM 
249*7836SJohn.Forte@Sun.COM 	fprintf(stdout, gettext("\tCurrent Speed: "));
250*7836SJohn.Forte@Sun.COM 	printPortSpeed(port->PortSpeed);
251*7836SJohn.Forte@Sun.COM 	fprintf(stdout, "\n");
252*7836SJohn.Forte@Sun.COM 
253*7836SJohn.Forte@Sun.COM 	fprintf(stdout, gettext("\tNode WWN: %016llx\n"),
254*7836SJohn.Forte@Sun.COM 	    wwnConversion(port->NodeWWN.wwn));
255*7836SJohn.Forte@Sun.COM }
256*7836SJohn.Forte@Sun.COM 
257*7836SJohn.Forte@Sun.COM void
printStatus(HBA_STATUS status)258*7836SJohn.Forte@Sun.COM printStatus(HBA_STATUS status) {
259*7836SJohn.Forte@Sun.COM 	switch (status) {
260*7836SJohn.Forte@Sun.COM 		case HBA_STATUS_OK:
261*7836SJohn.Forte@Sun.COM 			fprintf(stderr, gettext("OK"));
262*7836SJohn.Forte@Sun.COM 			return;
263*7836SJohn.Forte@Sun.COM 		case HBA_STATUS_ERROR:
264*7836SJohn.Forte@Sun.COM 			fprintf(stderr, gettext("ERROR"));
265*7836SJohn.Forte@Sun.COM 			return;
266*7836SJohn.Forte@Sun.COM 		case HBA_STATUS_ERROR_NOT_SUPPORTED:
267*7836SJohn.Forte@Sun.COM 			fprintf(stderr, gettext("NOT SUPPORTED"));
268*7836SJohn.Forte@Sun.COM 			return;
269*7836SJohn.Forte@Sun.COM 		case HBA_STATUS_ERROR_INVALID_HANDLE:
270*7836SJohn.Forte@Sun.COM 			fprintf(stderr, gettext("INVALID HANDLE"));
271*7836SJohn.Forte@Sun.COM 			return;
272*7836SJohn.Forte@Sun.COM 		case HBA_STATUS_ERROR_ARG:
273*7836SJohn.Forte@Sun.COM 			fprintf(stderr, gettext("ERROR ARG"));
274*7836SJohn.Forte@Sun.COM 			return;
275*7836SJohn.Forte@Sun.COM 		case HBA_STATUS_ERROR_ILLEGAL_WWN:
276*7836SJohn.Forte@Sun.COM 			fprintf(stderr, gettext("ILLEGAL WWN"));
277*7836SJohn.Forte@Sun.COM 			return;
278*7836SJohn.Forte@Sun.COM 		case HBA_STATUS_ERROR_ILLEGAL_INDEX:
279*7836SJohn.Forte@Sun.COM 			fprintf(stderr, gettext("ILLEGAL INDEX"));
280*7836SJohn.Forte@Sun.COM 			return;
281*7836SJohn.Forte@Sun.COM 		case HBA_STATUS_ERROR_MORE_DATA:
282*7836SJohn.Forte@Sun.COM 			fprintf(stderr, gettext("MORE DATA"));
283*7836SJohn.Forte@Sun.COM 			return;
284*7836SJohn.Forte@Sun.COM 		case HBA_STATUS_ERROR_STALE_DATA:
285*7836SJohn.Forte@Sun.COM 			fprintf(stderr, gettext("STALE DATA"));
286*7836SJohn.Forte@Sun.COM 			return;
287*7836SJohn.Forte@Sun.COM 		case HBA_STATUS_SCSI_CHECK_CONDITION:
288*7836SJohn.Forte@Sun.COM 			fprintf(stderr, gettext("SCSI CHECK CONDITION"));
289*7836SJohn.Forte@Sun.COM 			return;
290*7836SJohn.Forte@Sun.COM 		case HBA_STATUS_ERROR_BUSY:
291*7836SJohn.Forte@Sun.COM 			fprintf(stderr, gettext("BUSY"));
292*7836SJohn.Forte@Sun.COM 			return;
293*7836SJohn.Forte@Sun.COM 		case HBA_STATUS_ERROR_TRY_AGAIN:
294*7836SJohn.Forte@Sun.COM 			fprintf(stderr, gettext("TRY AGAIN"));
295*7836SJohn.Forte@Sun.COM 			return;
296*7836SJohn.Forte@Sun.COM 		case HBA_STATUS_ERROR_UNAVAILABLE:
297*7836SJohn.Forte@Sun.COM 			fprintf(stderr, gettext("UNAVAILABLE"));
298*7836SJohn.Forte@Sun.COM 			return;
299*7836SJohn.Forte@Sun.COM 		default:
300*7836SJohn.Forte@Sun.COM 			fprintf(stderr, "%s %d",
301*7836SJohn.Forte@Sun.COM 			    gettext("Undefined error code "), status);
302*7836SJohn.Forte@Sun.COM 			return;
303*7836SJohn.Forte@Sun.COM 	}
304*7836SJohn.Forte@Sun.COM }
305*7836SJohn.Forte@Sun.COM 
306*7836SJohn.Forte@Sun.COM void
printLUNInfo(struct scsi_inquiry * inq,HBA_UINT32 scsiLUN,char * devpath)307*7836SJohn.Forte@Sun.COM printLUNInfo(struct scsi_inquiry *inq, HBA_UINT32 scsiLUN, char *devpath) {
308*7836SJohn.Forte@Sun.COM 	fprintf(stdout, "\tLUN: %d\n", scsiLUN);
309*7836SJohn.Forte@Sun.COM 	fprintf(stdout, "\t  Vendor: %c%c%c%c%c%c%c%c\n",
310*7836SJohn.Forte@Sun.COM 	    inq->inq_vid[0],
311*7836SJohn.Forte@Sun.COM 	    inq->inq_vid[1],
312*7836SJohn.Forte@Sun.COM 	    inq->inq_vid[2],
313*7836SJohn.Forte@Sun.COM 	    inq->inq_vid[3],
314*7836SJohn.Forte@Sun.COM 	    inq->inq_vid[4],
315*7836SJohn.Forte@Sun.COM 	    inq->inq_vid[5],
316*7836SJohn.Forte@Sun.COM 	    inq->inq_vid[6],
317*7836SJohn.Forte@Sun.COM 	    inq->inq_vid[7]);
318*7836SJohn.Forte@Sun.COM 	fprintf(stdout, "\t  Product: %c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c\n",
319*7836SJohn.Forte@Sun.COM 		    inq->inq_pid[0],
320*7836SJohn.Forte@Sun.COM 		    inq->inq_pid[1],
321*7836SJohn.Forte@Sun.COM 		    inq->inq_pid[2],
322*7836SJohn.Forte@Sun.COM 		    inq->inq_pid[3],
323*7836SJohn.Forte@Sun.COM 		    inq->inq_pid[4],
324*7836SJohn.Forte@Sun.COM 		    inq->inq_pid[5],
325*7836SJohn.Forte@Sun.COM 		    inq->inq_pid[6],
326*7836SJohn.Forte@Sun.COM 		    inq->inq_pid[7],
327*7836SJohn.Forte@Sun.COM 		    inq->inq_pid[8],
328*7836SJohn.Forte@Sun.COM 		    inq->inq_pid[9],
329*7836SJohn.Forte@Sun.COM 		    inq->inq_pid[10],
330*7836SJohn.Forte@Sun.COM 		    inq->inq_pid[11],
331*7836SJohn.Forte@Sun.COM 		    inq->inq_pid[12],
332*7836SJohn.Forte@Sun.COM 		    inq->inq_pid[13],
333*7836SJohn.Forte@Sun.COM 		    inq->inq_pid[14],
334*7836SJohn.Forte@Sun.COM 		    inq->inq_pid[15]);
335*7836SJohn.Forte@Sun.COM 	fprintf(stdout, gettext("\t  OS Device Name: %s\n"), devpath);
336*7836SJohn.Forte@Sun.COM }
337*7836SJohn.Forte@Sun.COM 
338*7836SJohn.Forte@Sun.COM void
printPortStat(fc_rls_acc_t * rls_payload)339*7836SJohn.Forte@Sun.COM printPortStat(fc_rls_acc_t *rls_payload) {
340*7836SJohn.Forte@Sun.COM 	fprintf(stdout, gettext("\tLink Error Statistics:\n"));
341*7836SJohn.Forte@Sun.COM 	fprintf(stdout, gettext("\t\tLink Failure Count: %u\n"),
342*7836SJohn.Forte@Sun.COM 	    rls_payload->rls_link_fail);
343*7836SJohn.Forte@Sun.COM 	fprintf(stdout, gettext("\t\tLoss of Sync Count: %u\n"),
344*7836SJohn.Forte@Sun.COM 	    rls_payload->rls_sync_loss);
345*7836SJohn.Forte@Sun.COM 	fprintf(stdout, gettext("\t\tLoss of Signal Count: %u\n"),
346*7836SJohn.Forte@Sun.COM 	    rls_payload->rls_sig_loss);
347*7836SJohn.Forte@Sun.COM 	fprintf(stdout, gettext("\t\tPrimitive Seq Protocol Error Count: %u\n"),
348*7836SJohn.Forte@Sun.COM 	    rls_payload->rls_prim_seq_err);
349*7836SJohn.Forte@Sun.COM 	fprintf(stdout, gettext("\t\tInvalid Tx Word Count: %u\n"),
350*7836SJohn.Forte@Sun.COM 	    rls_payload->rls_invalid_word);
351*7836SJohn.Forte@Sun.COM 	fprintf(stdout, gettext("\t\tInvalid CRC Count: %u\n"),
352*7836SJohn.Forte@Sun.COM 	    rls_payload->rls_invalid_crc);
353*7836SJohn.Forte@Sun.COM }
354*7836SJohn.Forte@Sun.COM 
355*7836SJohn.Forte@Sun.COM /*
356*7836SJohn.Forte@Sun.COM  * return device type description
357*7836SJohn.Forte@Sun.COM  *
358*7836SJohn.Forte@Sun.COM  * Arguments:
359*7836SJohn.Forte@Sun.COM  *	dType - Device type returned from Standard INQUIRY
360*7836SJohn.Forte@Sun.COM  * Returns:
361*7836SJohn.Forte@Sun.COM  *	char string description for device type
362*7836SJohn.Forte@Sun.COM  */
363*7836SJohn.Forte@Sun.COM static char *
getDTypeString(uchar_t dType)364*7836SJohn.Forte@Sun.COM getDTypeString(uchar_t dType)
365*7836SJohn.Forte@Sun.COM {
366*7836SJohn.Forte@Sun.COM 	switch (dType & DTYPE_MASK) {
367*7836SJohn.Forte@Sun.COM 		case DTYPE_DIRECT:
368*7836SJohn.Forte@Sun.COM 			return ("Disk Device");
369*7836SJohn.Forte@Sun.COM 		case DTYPE_SEQUENTIAL:
370*7836SJohn.Forte@Sun.COM 			return ("Tape Device");
371*7836SJohn.Forte@Sun.COM 		case DTYPE_PRINTER:
372*7836SJohn.Forte@Sun.COM 			return ("Printer Device");
373*7836SJohn.Forte@Sun.COM 		case DTYPE_PROCESSOR:
374*7836SJohn.Forte@Sun.COM 			return ("Processor Device");
375*7836SJohn.Forte@Sun.COM 		case DTYPE_WORM:
376*7836SJohn.Forte@Sun.COM 			return ("WORM Device");
377*7836SJohn.Forte@Sun.COM 		case DTYPE_RODIRECT:
378*7836SJohn.Forte@Sun.COM 			return ("CD/DVD Device");
379*7836SJohn.Forte@Sun.COM 		case DTYPE_SCANNER:
380*7836SJohn.Forte@Sun.COM 			return ("Scanner Device");
381*7836SJohn.Forte@Sun.COM 		case DTYPE_OPTICAL:
382*7836SJohn.Forte@Sun.COM 			return ("Optical Memory Device");
383*7836SJohn.Forte@Sun.COM 		case DTYPE_CHANGER:
384*7836SJohn.Forte@Sun.COM 			return ("Medium Changer Device");
385*7836SJohn.Forte@Sun.COM 		case DTYPE_COMM:
386*7836SJohn.Forte@Sun.COM 			return ("Communications Device");
387*7836SJohn.Forte@Sun.COM 		case DTYPE_ARRAY_CTRL:
388*7836SJohn.Forte@Sun.COM 			return ("Storage Array Controller Device");
389*7836SJohn.Forte@Sun.COM 		case DTYPE_ESI:
390*7836SJohn.Forte@Sun.COM 			return ("Enclosure Services Device");
391*7836SJohn.Forte@Sun.COM 		case DTYPE_RBC:
392*7836SJohn.Forte@Sun.COM 			return ("Simplified Direct-access Device");
393*7836SJohn.Forte@Sun.COM 		case DTYPE_OCRW:
394*7836SJohn.Forte@Sun.COM 			return ("Optical Card Reader/Writer Device");
395*7836SJohn.Forte@Sun.COM 		case DTYPE_BCC:
396*7836SJohn.Forte@Sun.COM 			return ("Bridge Controller Commands");
397*7836SJohn.Forte@Sun.COM 		case DTYPE_OSD:
398*7836SJohn.Forte@Sun.COM 			return ("Object-based Storage Device");
399*7836SJohn.Forte@Sun.COM 		case DTYPE_ADC:
400*7836SJohn.Forte@Sun.COM 			return ("Automation/Drive Interface");
401*7836SJohn.Forte@Sun.COM 		case DTYPE_WELLKNOWN:
402*7836SJohn.Forte@Sun.COM 			return ("Well Known Logical Unit");
403*7836SJohn.Forte@Sun.COM 		case DTYPE_UNKNOWN:
404*7836SJohn.Forte@Sun.COM 			return ("Unknown Device");
405*7836SJohn.Forte@Sun.COM 		default:
406*7836SJohn.Forte@Sun.COM 			return ("Undefined");
407*7836SJohn.Forte@Sun.COM 	}
408*7836SJohn.Forte@Sun.COM }
409*7836SJohn.Forte@Sun.COM 
410*7836SJohn.Forte@Sun.COM /*
411*7836SJohn.Forte@Sun.COM  * print the OS device name for the logical-unit object
412*7836SJohn.Forte@Sun.COM  *
413*7836SJohn.Forte@Sun.COM  * Arguments:
414*7836SJohn.Forte@Sun.COM  *	devListWalk - OS device path info
415*7836SJohn.Forte@Sun.COM  *	verbose - boolean indicating whether to display additional info
416*7836SJohn.Forte@Sun.COM  *
417*7836SJohn.Forte@Sun.COM  * returns:
418*7836SJohn.Forte@Sun.COM  *	none
419*7836SJohn.Forte@Sun.COM  */
420*7836SJohn.Forte@Sun.COM void
printOSDeviceNameInfo(discoveredDevice * devListWalk,boolean_t verbose)421*7836SJohn.Forte@Sun.COM printOSDeviceNameInfo(discoveredDevice *devListWalk, boolean_t verbose)
422*7836SJohn.Forte@Sun.COM {
423*7836SJohn.Forte@Sun.COM 	portWWNList		*WWNList;
424*7836SJohn.Forte@Sun.COM 	tgtPortWWNList		*tgtWWNList;
425*7836SJohn.Forte@Sun.COM 	int			i, count;
426*7836SJohn.Forte@Sun.COM 
427*7836SJohn.Forte@Sun.COM 	fprintf(stdout, "OS Device Name: %s\n", devListWalk->OSDeviceName);
428*7836SJohn.Forte@Sun.COM 	if (verbose == B_TRUE) {
429*7836SJohn.Forte@Sun.COM 		for (WWNList = devListWalk->HBAPortWWN;
430*7836SJohn.Forte@Sun.COM 		    WWNList != NULL; WWNList = WWNList->next) {
431*7836SJohn.Forte@Sun.COM 			fprintf(stdout, "\tHBA Port WWN: ");
432*7836SJohn.Forte@Sun.COM 			fprintf(stdout, "%016llx",
433*7836SJohn.Forte@Sun.COM 			    wwnConversion(WWNList->portWWN.wwn));
434*7836SJohn.Forte@Sun.COM 			for (tgtWWNList = WWNList->tgtPortWWN;
435*7836SJohn.Forte@Sun.COM 			    tgtWWNList != NULL; tgtWWNList = tgtWWNList->next) {
436*7836SJohn.Forte@Sun.COM 				fprintf(stdout, "\n\t\tRemote Port WWN: ");
437*7836SJohn.Forte@Sun.COM 				fprintf(stdout, "%016llx",
438*7836SJohn.Forte@Sun.COM 				    wwnConversion(tgtWWNList->portWWN.wwn));
439*7836SJohn.Forte@Sun.COM 				fprintf(stdout, "\n\t\t\tLUN: %d",
440*7836SJohn.Forte@Sun.COM 				    tgtWWNList->scsiOSLun);
441*7836SJohn.Forte@Sun.COM 			}
442*7836SJohn.Forte@Sun.COM 			fprintf(stdout, "\n");
443*7836SJohn.Forte@Sun.COM 		}
444*7836SJohn.Forte@Sun.COM 
445*7836SJohn.Forte@Sun.COM 		fprintf(stdout, "\tVendor: ");
446*7836SJohn.Forte@Sun.COM 		for (count = sizeof (devListWalk->VID), i = 0; i < count; i++) {
447*7836SJohn.Forte@Sun.COM 			if (isprint(devListWalk->VID[i]))
448*7836SJohn.Forte@Sun.COM 				fprintf(stdout, "%c", devListWalk->VID[i]);
449*7836SJohn.Forte@Sun.COM 		}
450*7836SJohn.Forte@Sun.COM 
451*7836SJohn.Forte@Sun.COM 		fprintf(stdout, "\n\tProduct: ");
452*7836SJohn.Forte@Sun.COM 		for (count = sizeof (devListWalk->PID), i = 0; i < count; i++) {
453*7836SJohn.Forte@Sun.COM 			if (isprint(devListWalk->PID[i]))
454*7836SJohn.Forte@Sun.COM 				fprintf(stdout, "%c", devListWalk->PID[i]);
455*7836SJohn.Forte@Sun.COM 		}
456*7836SJohn.Forte@Sun.COM 
457*7836SJohn.Forte@Sun.COM 		fprintf(stdout, "\n\tDevice Type: %s\n",
458*7836SJohn.Forte@Sun.COM 		    getDTypeString(devListWalk->dType));
459*7836SJohn.Forte@Sun.COM 	}
460*7836SJohn.Forte@Sun.COM }
461