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