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.
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.
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]
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
39 #include <hbaapi-sun.h>
41 #include <sys/scsi/scsi.h>
42 #include <sys/fibre-channel/fcio.h>
43 #include <sys/types.h>
44 #include <netinet/in.h>
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))
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
64 #define DEFAULT_LUN_COUNT 1024
66 #define LUN_HEADER_SIZE 8
67 #define LUN_LENGTH LUN_SIZE + LUN_HEADER_SIZE
68 #define DEFAULT_LUN_LENGTH DEFAULT_LUN_COUNT * \
72 #define HBA_MAX_RETRIES 20
73 #define PORT_LIST_ALLOC 100
74 #define NPIV_PORT_LIST_LENGTH 255
79 #define NPIV_SUCCESS 0
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
88 #define NPIV_SERVICE "network/npiv_config"
89 #define NPIV_PG_NAME "npiv-port-list"
90 #define NPIV_PORT_LIST "port_list"
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 */
99 /* flags for Adpater/port mode */
100 #define INITIATOR_MODE 0x00000001
101 #define TARGET_MODE 0x00000010
104 #define FCOE_USER_RAW_FRAME_SIZE 224
106 typedef struct _tgtPortWWNList
{
108 HBA_UINT32 scsiOSLun
;
109 struct _tgtPortWWNList
*next
;
112 typedef struct _portWWNList
{
114 tgtPortWWNList
*tgtPortWWN
;
115 struct _portWWNList
*next
;
118 /* Discovered ports structure */
119 typedef struct _discoveredDevice
{
120 char OSDeviceName
[MAXPATHLEN
];
121 portWWNList
*HBAPortWWN
;
124 boolean_t inqSuccess
;
126 struct _discoveredDevice
*next
;
130 static char *cmdName
;
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
);
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
[]);
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
);
161 #endif /* _FCINFO_H */