1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 /* 22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 26 #ifndef _FCINFO_H 27 #define _FCINFO_H 28 29 30 #ifdef __cplusplus 31 extern "C" { 32 #endif 33 34 #include <stdio.h> 35 #include <stdlib.h> 36 #include <string.h> 37 #include <libintl.h> 38 #include <hbaapi.h> 39 #include <hbaapi-sun.h> 40 #include <unistd.h> 41 #include <sys/scsi/scsi.h> 42 #include <sys/fibre-channel/fcio.h> 43 #include <sys/types.h> 44 #include <netinet/in.h> 45 #include <inttypes.h> 46 #include <cmdparse.h> 47 #include <locale.h> 48 49 #ifdef _BIG_ENDIAN 50 #define htonll(x) (x) 51 #define ntohll(x) (x) 52 #else 53 #define htonll(x) ((((unsigned long long)htonl(x)) << 32) + htonl(x >> 32)) 54 #define ntohll(x) ((((unsigned long long)ntohl(x)) << 32) + ntohl(x >> 32)) 55 #endif 56 57 /* DEFINES */ 58 59 /* SCSI TARGET TYPES */ 60 #define SCSI_TARGET_TYPE_UNKNOWN 0 61 #define SCSI_TARGET_TYPE_NO 1 62 #define SCSI_TARGET_TYPE_YES 2 63 64 #define DEFAULT_LUN_COUNT 1024 65 #define LUN_SIZE 8 66 #define LUN_HEADER_SIZE 8 67 #define LUN_LENGTH LUN_SIZE + LUN_HEADER_SIZE 68 #define DEFAULT_LUN_LENGTH DEFAULT_LUN_COUNT * \ 69 LUN_SIZE + \ 70 LUN_HEADER_SIZE 71 72 #define HBA_MAX_RETRIES 20 73 #define PORT_LIST_ALLOC 100 74 #define NPIV_PORT_LIST_LENGTH 255 75 76 #define NPIV_ADD 0 77 #define NPIV_REMOVE 1 78 79 #define NPIV_SUCCESS 0 80 #define NPIV_ERROR 1 81 #define NPIV_ERROR_NOT_FOUND 2 82 #define NPIV_ERROR_EXISTS 3 83 #define NPIV_ERROR_SERVICE_NOT_FOUND 4 84 #define NPIV_ERROR_NOMEM 5 85 #define NPIV_ERROR_MEMBER_NOT_FOUND 6 86 #define NPIV_ERROR_BUSY 7 87 88 #define NPIV_SERVICE "network/npiv_config" 89 #define NPIV_PG_NAME "npiv-port-list" 90 #define NPIV_PORT_LIST "port_list" 91 92 /* flags that are needed to be passed into processHBA */ 93 #define PRINT_LINKSTAT 0x00000001 /* print link statistics information */ 94 #define PRINT_SCSI_TARGET 0x00000010 /* print Scsi target information */ 95 #define PRINT_INITIATOR 0x00000100 /* print intiator port information */ 96 #define PRINT_TARGET 0x00001000 /* print target port information */ 97 #define PRINT_FCOE 0x00010000 /* print fcoe port information */ 98 99 /* flags for Adpater/port mode */ 100 #define INITIATOR_MODE 0x00000001 101 #define TARGET_MODE 0x00000010 102 103 /* FCOE */ 104 #define FCOE_USER_RAW_FRAME_SIZE 224 105 106 typedef struct _tgtPortWWNList { 107 HBA_WWN portWWN; 108 HBA_UINT32 scsiOSLun; 109 struct _tgtPortWWNList *next; 110 } tgtPortWWNList; 111 112 typedef struct _portWWNList { 113 HBA_WWN portWWN; 114 tgtPortWWNList *tgtPortWWN; 115 struct _portWWNList *next; 116 } portWWNList; 117 118 /* Discovered ports structure */ 119 typedef struct _discoveredDevice { 120 char OSDeviceName[MAXPATHLEN]; 121 portWWNList *HBAPortWWN; 122 char VID[8]; 123 char PID[16]; 124 boolean_t inqSuccess; 125 uchar_t dType; 126 struct _discoveredDevice *next; 127 } discoveredDevice; 128 129 /* globals */ 130 static char *cmdName; 131 132 /* print helper functions */ 133 void printHBAPortInfo(HBA_PORTATTRIBUTES *port, 134 HBA_ADAPTERATTRIBUTES *attrs, int mode); 135 void printDiscoPortInfo(HBA_PORTATTRIBUTES *discoPort, int scsiTargetType); 136 void printLUNInfo(struct scsi_inquiry *inq, HBA_UINT32 scsiLUN, char *devpath); 137 void printPortStat(fc_rls_acc_t *rls_payload); 138 void printScsiTarget(HBA_WWN); 139 void printStatus(HBA_STATUS status); 140 void printOSDeviceNameInfo(discoveredDevice *devListWalk, boolean_t verbose); 141 uint64_t wwnConversion(uchar_t *wwn); 142 143 int fc_util_list_hbaport(int wwnCount, char **wwn_argv, cmdOptions_t *options); 144 int fc_util_list_remoteport(int wwnCount, char **argv, cmdOptions_t *options); 145 int fc_util_list_logicalunit(int pathCount, char **argv, cmdOptions_t *options); 146 int fc_util_delete_npivport(int wwnCount, char **argv, cmdOptions_t *options); 147 int fc_util_create_npivport(int wwnCount, char **argv, cmdOptions_t *options); 148 int fc_util_create_portlist(); 149 int fc_util_force_lip(int objects, char *argv[]); 150 151 int fcoe_adm_create_port(int objects, char *argv[], 152 cmdOptions_t *options); 153 int fcoe_adm_delete_port(int objects, char *argv[]); 154 int fcoe_adm_list_ports(cmdOptions_t *options); 155 156 157 #ifdef __cplusplus 158 } 159 #endif 160 161 #endif /* _FCINFO_H */ 162