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