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