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 #ifndef _FCINFO_H 27*fcf3ce44SJohn Forte #define _FCINFO_H 28*fcf3ce44SJohn Forte 29*fcf3ce44SJohn Forte 30*fcf3ce44SJohn Forte #ifdef __cplusplus 31*fcf3ce44SJohn Forte extern "C" { 32*fcf3ce44SJohn Forte #endif 33*fcf3ce44SJohn Forte 34*fcf3ce44SJohn Forte #include <stdio.h> 35*fcf3ce44SJohn Forte #include <stdlib.h> 36*fcf3ce44SJohn Forte #include <string.h> 37*fcf3ce44SJohn Forte #include <libintl.h> 38*fcf3ce44SJohn Forte #include <hbaapi.h> 39*fcf3ce44SJohn Forte #include <hbaapi-sun.h> 40*fcf3ce44SJohn Forte #include <unistd.h> 41*fcf3ce44SJohn Forte #include <sys/scsi/scsi.h> 42*fcf3ce44SJohn Forte #include <sys/fibre-channel/fcio.h> 43*fcf3ce44SJohn Forte #include <sys/types.h> 44*fcf3ce44SJohn Forte #include <netinet/in.h> 45*fcf3ce44SJohn Forte #include <inttypes.h> 46*fcf3ce44SJohn Forte #include <cmdparse.h> 47*fcf3ce44SJohn Forte 48*fcf3ce44SJohn Forte #ifdef _BIG_ENDIAN 49*fcf3ce44SJohn Forte #define htonll(x) (x) 50*fcf3ce44SJohn Forte #define ntohll(x) (x) 51*fcf3ce44SJohn Forte #else 52*fcf3ce44SJohn Forte #define htonll(x) ((((unsigned long long)htonl(x)) << 32) + htonl(x >> 32)) 53*fcf3ce44SJohn Forte #define ntohll(x) ((((unsigned long long)ntohl(x)) << 32) + ntohl(x >> 32)) 54*fcf3ce44SJohn Forte #endif 55*fcf3ce44SJohn Forte 56*fcf3ce44SJohn Forte /* DEFINES */ 57*fcf3ce44SJohn Forte 58*fcf3ce44SJohn Forte /* SCSI TARGET TYPES */ 59*fcf3ce44SJohn Forte #define SCSI_TARGET_TYPE_UNKNOWN 0 60*fcf3ce44SJohn Forte #define SCSI_TARGET_TYPE_NO 1 61*fcf3ce44SJohn Forte #define SCSI_TARGET_TYPE_YES 2 62*fcf3ce44SJohn Forte 63*fcf3ce44SJohn Forte #define DEFAULT_LUN_COUNT 1024 64*fcf3ce44SJohn Forte #define LUN_SIZE 8 65*fcf3ce44SJohn Forte #define LUN_HEADER_SIZE 8 66*fcf3ce44SJohn Forte #define LUN_LENGTH LUN_SIZE + LUN_HEADER_SIZE 67*fcf3ce44SJohn Forte #define DEFAULT_LUN_LENGTH DEFAULT_LUN_COUNT * \ 68*fcf3ce44SJohn Forte LUN_SIZE + \ 69*fcf3ce44SJohn Forte LUN_HEADER_SIZE 70*fcf3ce44SJohn Forte 71*fcf3ce44SJohn Forte #define HBA_MAX_RETRIES 20 72*fcf3ce44SJohn Forte #define PORT_LIST_ALLOC 100 73*fcf3ce44SJohn Forte #define NPIV_PORT_LIST_LENGTH 255 74*fcf3ce44SJohn Forte 75*fcf3ce44SJohn Forte #define NPIV_ADD 0 76*fcf3ce44SJohn Forte #define NPIV_REMOVE 1 77*fcf3ce44SJohn Forte 78*fcf3ce44SJohn Forte #define NPIV_SUCCESS 0 79*fcf3ce44SJohn Forte #define NPIV_ERROR 1 80*fcf3ce44SJohn Forte #define NPIV_ERROR_NOT_FOUND 2 81*fcf3ce44SJohn Forte #define NPIV_ERROR_EXISTS 3 82*fcf3ce44SJohn Forte #define NPIV_ERROR_SERVICE_NOT_FOUND 4 83*fcf3ce44SJohn Forte #define NPIV_ERROR_NOMEM 5 84*fcf3ce44SJohn Forte #define NPIV_ERROR_MEMBER_NOT_FOUND 6 85*fcf3ce44SJohn Forte #define NPIV_ERROR_BUSY 7 86*fcf3ce44SJohn Forte 87*fcf3ce44SJohn Forte #define NPIV_SERVICE "network/npiv_config" 88*fcf3ce44SJohn Forte #define NPIV_PG_NAME "npiv-port-list" 89*fcf3ce44SJohn Forte #define NPIV_PORT_LIST "port_list" 90*fcf3ce44SJohn Forte 91*fcf3ce44SJohn Forte /* flags that are needed to be passed into processHBA */ 92*fcf3ce44SJohn Forte #define PRINT_LINKSTAT 0x00000001 /* print link statistics information */ 93*fcf3ce44SJohn Forte #define PRINT_SCSI_TARGET 0x00000010 /* print Scsi target information */ 94*fcf3ce44SJohn Forte #define PRINT_INITIATOR 0x00000100 /* print intiator port information */ 95*fcf3ce44SJohn Forte #define PRINT_TARGET 0x00001000 /* print target port information */ 96*fcf3ce44SJohn Forte 97*fcf3ce44SJohn Forte /* flags for Adpater/port mode */ 98*fcf3ce44SJohn Forte #define INITIATOR_MODE 0x00000001 99*fcf3ce44SJohn Forte #define TARGET_MODE 0x00000010 100*fcf3ce44SJohn Forte 101*fcf3ce44SJohn Forte typedef struct _tgtPortWWNList { 102*fcf3ce44SJohn Forte HBA_WWN portWWN; 103*fcf3ce44SJohn Forte HBA_UINT32 scsiOSLun; 104*fcf3ce44SJohn Forte struct _tgtPortWWNList *next; 105*fcf3ce44SJohn Forte } tgtPortWWNList; 106*fcf3ce44SJohn Forte 107*fcf3ce44SJohn Forte typedef struct _portWWNList { 108*fcf3ce44SJohn Forte HBA_WWN portWWN; 109*fcf3ce44SJohn Forte tgtPortWWNList *tgtPortWWN; 110*fcf3ce44SJohn Forte struct _portWWNList *next; 111*fcf3ce44SJohn Forte } portWWNList; 112*fcf3ce44SJohn Forte 113*fcf3ce44SJohn Forte /* Discovered ports structure */ 114*fcf3ce44SJohn Forte typedef struct _discoveredDevice { 115*fcf3ce44SJohn Forte char OSDeviceName[MAXPATHLEN]; 116*fcf3ce44SJohn Forte portWWNList *HBAPortWWN; 117*fcf3ce44SJohn Forte char VID[8]; 118*fcf3ce44SJohn Forte char PID[16]; 119*fcf3ce44SJohn Forte boolean_t inqSuccess; 120*fcf3ce44SJohn Forte uchar_t dType; 121*fcf3ce44SJohn Forte struct _discoveredDevice *next; 122*fcf3ce44SJohn Forte } discoveredDevice; 123*fcf3ce44SJohn Forte 124*fcf3ce44SJohn Forte /* globals */ 125*fcf3ce44SJohn Forte static char *cmdName; 126*fcf3ce44SJohn Forte 127*fcf3ce44SJohn Forte /* print helper functions */ 128*fcf3ce44SJohn Forte void printHBAPortInfo(HBA_PORTATTRIBUTES *port, 129*fcf3ce44SJohn Forte HBA_ADAPTERATTRIBUTES *attrs, int mode); 130*fcf3ce44SJohn Forte void printDiscoPortInfo(HBA_PORTATTRIBUTES *discoPort, int scsiTargetType); 131*fcf3ce44SJohn Forte void printLUNInfo(struct scsi_inquiry *inq, HBA_UINT32 scsiLUN, char *devpath); 132*fcf3ce44SJohn Forte void printPortStat(fc_rls_acc_t *rls_payload); 133*fcf3ce44SJohn Forte void printScsiTarget(HBA_WWN); 134*fcf3ce44SJohn Forte void printStatus(HBA_STATUS status); 135*fcf3ce44SJohn Forte void printOSDeviceNameInfo(discoveredDevice *devListWalk, boolean_t verbose); 136*fcf3ce44SJohn Forte uint64_t wwnConversion(uchar_t *wwn); 137*fcf3ce44SJohn Forte 138*fcf3ce44SJohn Forte int fc_util_list_hbaport(int wwnCount, char **wwn_argv, cmdOptions_t *options); 139*fcf3ce44SJohn Forte int fc_util_list_remoteport(int wwnCount, char **argv, cmdOptions_t *options); 140*fcf3ce44SJohn Forte int fc_util_list_logicalunit(int pathCount, char **argv, cmdOptions_t *options); 141*fcf3ce44SJohn Forte int fc_util_delete_npivport(int wwnCount, char **argv, cmdOptions_t *options); 142*fcf3ce44SJohn Forte int fc_util_create_npivport(int wwnCount, char **argv, cmdOptions_t *options); 143*fcf3ce44SJohn Forte int fc_util_create_portlist(); 144*fcf3ce44SJohn Forte 145*fcf3ce44SJohn Forte #ifdef __cplusplus 146*fcf3ce44SJohn Forte } 147*fcf3ce44SJohn Forte #endif 148*fcf3ce44SJohn Forte 149*fcf3ce44SJohn Forte #endif /* _FCINFO_H */ 150