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 /* 22*2a8164dfSZhong 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> 47*2a8164dfSZhong 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 92*2a8164dfSZhong Wang #define FCOE_SCF_ADD 0 93*2a8164dfSZhong Wang #define FCOE_SCF_REMOVE 1 94*2a8164dfSZhong Wang 95*2a8164dfSZhong Wang #define FCOE_SUCCESS 0 96*2a8164dfSZhong Wang #define FCOE_ERROR 1 97*2a8164dfSZhong Wang #define FCOE_ERROR_NOT_FOUND 2 98*2a8164dfSZhong Wang #define FCOE_ERROR_EXISTS 3 99*2a8164dfSZhong Wang #define FCOE_ERROR_SERVICE_NOT_FOUND 4 100*2a8164dfSZhong Wang #define FCOE_ERROR_NOMEM 5 101*2a8164dfSZhong Wang #define FCOE_ERROR_MEMBER_NOT_FOUND 6 102*2a8164dfSZhong Wang #define FCOE_ERROR_BUSY 7 103*2a8164dfSZhong Wang 104*2a8164dfSZhong Wang #define FCOE_PORT_LIST_LENGTH 255 105*2a8164dfSZhong Wang 106*2a8164dfSZhong Wang #define FCOE_SERVICE "network/fcoe_config" 107*2a8164dfSZhong Wang #define FCOE_PG_NAME "fcoe-port-list-pg" 108*2a8164dfSZhong Wang #define FCOE_PORT_LIST "port_list_p" 109*2a8164dfSZhong Wang 110fcf3ce44SJohn Forte /* flags that are needed to be passed into processHBA */ 111fcf3ce44SJohn Forte #define PRINT_LINKSTAT 0x00000001 /* print link statistics information */ 112fcf3ce44SJohn Forte #define PRINT_SCSI_TARGET 0x00000010 /* print Scsi target information */ 113fcf3ce44SJohn Forte #define PRINT_INITIATOR 0x00000100 /* print intiator port information */ 114fcf3ce44SJohn Forte #define PRINT_TARGET 0x00001000 /* print target port information */ 115*2a8164dfSZhong Wang #define PRINT_FCOE 0x00010000 /* print fcoe port information */ 116fcf3ce44SJohn Forte 117fcf3ce44SJohn Forte /* flags for Adpater/port mode */ 118fcf3ce44SJohn Forte #define INITIATOR_MODE 0x00000001 119fcf3ce44SJohn Forte #define TARGET_MODE 0x00000010 120fcf3ce44SJohn Forte 121*2a8164dfSZhong Wang /* FCOE */ 122*2a8164dfSZhong Wang #define FCOE_MAX_MAC_NAME_LEN 32 123*2a8164dfSZhong Wang #define FCOE_USER_RAW_FRAME_SIZE 224 124*2a8164dfSZhong Wang 125fcf3ce44SJohn Forte typedef struct _tgtPortWWNList { 126fcf3ce44SJohn Forte HBA_WWN portWWN; 127fcf3ce44SJohn Forte HBA_UINT32 scsiOSLun; 128fcf3ce44SJohn Forte struct _tgtPortWWNList *next; 129fcf3ce44SJohn Forte } tgtPortWWNList; 130fcf3ce44SJohn Forte 131fcf3ce44SJohn Forte typedef struct _portWWNList { 132fcf3ce44SJohn Forte HBA_WWN portWWN; 133fcf3ce44SJohn Forte tgtPortWWNList *tgtPortWWN; 134fcf3ce44SJohn Forte struct _portWWNList *next; 135fcf3ce44SJohn Forte } portWWNList; 136fcf3ce44SJohn Forte 137fcf3ce44SJohn Forte /* Discovered ports structure */ 138fcf3ce44SJohn Forte typedef struct _discoveredDevice { 139fcf3ce44SJohn Forte char OSDeviceName[MAXPATHLEN]; 140fcf3ce44SJohn Forte portWWNList *HBAPortWWN; 141fcf3ce44SJohn Forte char VID[8]; 142fcf3ce44SJohn Forte char PID[16]; 143fcf3ce44SJohn Forte boolean_t inqSuccess; 144fcf3ce44SJohn Forte uchar_t dType; 145fcf3ce44SJohn Forte struct _discoveredDevice *next; 146fcf3ce44SJohn Forte } discoveredDevice; 147fcf3ce44SJohn Forte 148fcf3ce44SJohn Forte /* globals */ 149fcf3ce44SJohn Forte static char *cmdName; 150fcf3ce44SJohn Forte 151fcf3ce44SJohn Forte /* print helper functions */ 152fcf3ce44SJohn Forte void printHBAPortInfo(HBA_PORTATTRIBUTES *port, 153fcf3ce44SJohn Forte HBA_ADAPTERATTRIBUTES *attrs, int mode); 154fcf3ce44SJohn Forte void printDiscoPortInfo(HBA_PORTATTRIBUTES *discoPort, int scsiTargetType); 155fcf3ce44SJohn Forte void printLUNInfo(struct scsi_inquiry *inq, HBA_UINT32 scsiLUN, char *devpath); 156fcf3ce44SJohn Forte void printPortStat(fc_rls_acc_t *rls_payload); 157fcf3ce44SJohn Forte void printScsiTarget(HBA_WWN); 158fcf3ce44SJohn Forte void printStatus(HBA_STATUS status); 159fcf3ce44SJohn Forte void printOSDeviceNameInfo(discoveredDevice *devListWalk, boolean_t verbose); 160fcf3ce44SJohn Forte uint64_t wwnConversion(uchar_t *wwn); 161fcf3ce44SJohn Forte 162fcf3ce44SJohn Forte int fc_util_list_hbaport(int wwnCount, char **wwn_argv, cmdOptions_t *options); 163fcf3ce44SJohn Forte int fc_util_list_remoteport(int wwnCount, char **argv, cmdOptions_t *options); 164fcf3ce44SJohn Forte int fc_util_list_logicalunit(int pathCount, char **argv, cmdOptions_t *options); 165fcf3ce44SJohn Forte int fc_util_delete_npivport(int wwnCount, char **argv, cmdOptions_t *options); 166fcf3ce44SJohn Forte int fc_util_create_npivport(int wwnCount, char **argv, cmdOptions_t *options); 167fcf3ce44SJohn Forte int fc_util_create_portlist(); 168fcf3ce44SJohn Forte 169*2a8164dfSZhong Wang int fcoe_adm_create_port(int objects, char *argv[], 170*2a8164dfSZhong Wang cmdOptions_t *options); 171*2a8164dfSZhong Wang int fcoe_adm_delete_port(int objects, char *argv[]); 172*2a8164dfSZhong Wang int fcoe_adm_list_ports(cmdOptions_t *options); 173*2a8164dfSZhong Wang int fcoe_adm_create_portlist(cmdOptions_t *options); 174*2a8164dfSZhong Wang 175*2a8164dfSZhong Wang 176fcf3ce44SJohn Forte #ifdef __cplusplus 177fcf3ce44SJohn Forte } 178fcf3ce44SJohn Forte #endif 179fcf3ce44SJohn Forte 180fcf3ce44SJohn Forte #endif /* _FCINFO_H */ 181