xref: /onnv-gate/usr/src/cmd/fcinfo/fcinfo.h (revision 10275:f0b35eb34c31)
17836SJohn.Forte@Sun.COM /*
27836SJohn.Forte@Sun.COM  * CDDL HEADER START
37836SJohn.Forte@Sun.COM  *
47836SJohn.Forte@Sun.COM  * The contents of this file are subject to the terms of the
57836SJohn.Forte@Sun.COM  * Common Development and Distribution License (the "License").
67836SJohn.Forte@Sun.COM  * You may not use this file except in compliance with the License.
77836SJohn.Forte@Sun.COM  *
87836SJohn.Forte@Sun.COM  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97836SJohn.Forte@Sun.COM  * or http://www.opensolaris.org/os/licensing.
107836SJohn.Forte@Sun.COM  * See the License for the specific language governing permissions
117836SJohn.Forte@Sun.COM  * and limitations under the License.
127836SJohn.Forte@Sun.COM  *
137836SJohn.Forte@Sun.COM  * When distributing Covered Code, include this CDDL HEADER in each
147836SJohn.Forte@Sun.COM  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157836SJohn.Forte@Sun.COM  * If applicable, add the following below this CDDL HEADER, with the
167836SJohn.Forte@Sun.COM  * fields enclosed by brackets "[]" replaced with your own identifying
177836SJohn.Forte@Sun.COM  * information: Portions Copyright [yyyy] [name of copyright owner]
187836SJohn.Forte@Sun.COM  *
197836SJohn.Forte@Sun.COM  * CDDL HEADER END
207836SJohn.Forte@Sun.COM  */
217836SJohn.Forte@Sun.COM /*
229087SZhong.Wang@Sun.COM  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
237836SJohn.Forte@Sun.COM  * Use is subject to license terms.
247836SJohn.Forte@Sun.COM  */
257836SJohn.Forte@Sun.COM 
267836SJohn.Forte@Sun.COM #ifndef _FCINFO_H
277836SJohn.Forte@Sun.COM #define	_FCINFO_H
287836SJohn.Forte@Sun.COM 
297836SJohn.Forte@Sun.COM 
307836SJohn.Forte@Sun.COM #ifdef	__cplusplus
317836SJohn.Forte@Sun.COM extern "C" {
327836SJohn.Forte@Sun.COM #endif
337836SJohn.Forte@Sun.COM 
347836SJohn.Forte@Sun.COM #include <stdio.h>
357836SJohn.Forte@Sun.COM #include <stdlib.h>
367836SJohn.Forte@Sun.COM #include <string.h>
377836SJohn.Forte@Sun.COM #include <libintl.h>
387836SJohn.Forte@Sun.COM #include <hbaapi.h>
397836SJohn.Forte@Sun.COM #include <hbaapi-sun.h>
407836SJohn.Forte@Sun.COM #include <unistd.h>
417836SJohn.Forte@Sun.COM #include <sys/scsi/scsi.h>
427836SJohn.Forte@Sun.COM #include <sys/fibre-channel/fcio.h>
437836SJohn.Forte@Sun.COM #include <sys/types.h>
447836SJohn.Forte@Sun.COM #include <netinet/in.h>
457836SJohn.Forte@Sun.COM #include <inttypes.h>
467836SJohn.Forte@Sun.COM #include <cmdparse.h>
479087SZhong.Wang@Sun.COM #include <locale.h>
487836SJohn.Forte@Sun.COM 
497836SJohn.Forte@Sun.COM #ifdef _BIG_ENDIAN
507836SJohn.Forte@Sun.COM #define	htonll(x)   (x)
517836SJohn.Forte@Sun.COM #define	ntohll(x)   (x)
527836SJohn.Forte@Sun.COM #else
537836SJohn.Forte@Sun.COM #define	htonll(x)   ((((unsigned long long)htonl(x)) << 32) + htonl(x >> 32))
547836SJohn.Forte@Sun.COM #define	ntohll(x)   ((((unsigned long long)ntohl(x)) << 32) + ntohl(x >> 32))
557836SJohn.Forte@Sun.COM #endif
567836SJohn.Forte@Sun.COM 
577836SJohn.Forte@Sun.COM /* DEFINES */
587836SJohn.Forte@Sun.COM 
597836SJohn.Forte@Sun.COM /* SCSI TARGET TYPES */
607836SJohn.Forte@Sun.COM #define	SCSI_TARGET_TYPE_UNKNOWN    0
617836SJohn.Forte@Sun.COM #define	SCSI_TARGET_TYPE_NO	    1
627836SJohn.Forte@Sun.COM #define	SCSI_TARGET_TYPE_YES	    2
637836SJohn.Forte@Sun.COM 
647836SJohn.Forte@Sun.COM #define	DEFAULT_LUN_COUNT	    1024
657836SJohn.Forte@Sun.COM #define	LUN_SIZE		    8
667836SJohn.Forte@Sun.COM #define	LUN_HEADER_SIZE		    8
677836SJohn.Forte@Sun.COM #define	LUN_LENGTH		    LUN_SIZE + LUN_HEADER_SIZE
687836SJohn.Forte@Sun.COM #define	DEFAULT_LUN_LENGTH	    DEFAULT_LUN_COUNT	* \
697836SJohn.Forte@Sun.COM 				    LUN_SIZE		+ \
707836SJohn.Forte@Sun.COM 				    LUN_HEADER_SIZE
717836SJohn.Forte@Sun.COM 
727836SJohn.Forte@Sun.COM #define	HBA_MAX_RETRIES		20
737836SJohn.Forte@Sun.COM #define	PORT_LIST_ALLOC		100
747836SJohn.Forte@Sun.COM #define	NPIV_PORT_LIST_LENGTH	255
757836SJohn.Forte@Sun.COM 
767836SJohn.Forte@Sun.COM #define	NPIV_ADD		0
777836SJohn.Forte@Sun.COM #define	NPIV_REMOVE		1
787836SJohn.Forte@Sun.COM 
797836SJohn.Forte@Sun.COM #define	NPIV_SUCCESS			0
807836SJohn.Forte@Sun.COM #define	NPIV_ERROR			1
817836SJohn.Forte@Sun.COM #define	NPIV_ERROR_NOT_FOUND		2
827836SJohn.Forte@Sun.COM #define	NPIV_ERROR_EXISTS		3
837836SJohn.Forte@Sun.COM #define	NPIV_ERROR_SERVICE_NOT_FOUND	4
847836SJohn.Forte@Sun.COM #define	NPIV_ERROR_NOMEM		5
857836SJohn.Forte@Sun.COM #define	NPIV_ERROR_MEMBER_NOT_FOUND	6
867836SJohn.Forte@Sun.COM #define	NPIV_ERROR_BUSY			7
877836SJohn.Forte@Sun.COM 
887836SJohn.Forte@Sun.COM #define	NPIV_SERVICE	"network/npiv_config"
897836SJohn.Forte@Sun.COM #define	NPIV_PG_NAME	"npiv-port-list"
907836SJohn.Forte@Sun.COM #define	NPIV_PORT_LIST	"port_list"
917836SJohn.Forte@Sun.COM 
927836SJohn.Forte@Sun.COM /* flags that are needed to be passed into processHBA */
937836SJohn.Forte@Sun.COM #define	PRINT_LINKSTAT	    0x00000001	/* print link statistics information */
947836SJohn.Forte@Sun.COM #define	PRINT_SCSI_TARGET   0x00000010	/* print Scsi target information */
957836SJohn.Forte@Sun.COM #define	PRINT_INITIATOR	    0x00000100	/* print intiator port information */
967836SJohn.Forte@Sun.COM #define	PRINT_TARGET	    0x00001000	/* print target port information */
979087SZhong.Wang@Sun.COM #define	PRINT_FCOE	    0x00010000	/* print fcoe port information */
987836SJohn.Forte@Sun.COM 
997836SJohn.Forte@Sun.COM /* flags for Adpater/port mode */
1007836SJohn.Forte@Sun.COM #define	INITIATOR_MODE	    0x00000001
1017836SJohn.Forte@Sun.COM #define	TARGET_MODE	    0x00000010
1027836SJohn.Forte@Sun.COM 
1039087SZhong.Wang@Sun.COM /* FCOE */
1049087SZhong.Wang@Sun.COM #define	FCOE_USER_RAW_FRAME_SIZE	224
1059087SZhong.Wang@Sun.COM 
1067836SJohn.Forte@Sun.COM typedef struct _tgtPortWWNList {
1077836SJohn.Forte@Sun.COM 	HBA_WWN portWWN;
1087836SJohn.Forte@Sun.COM 	HBA_UINT32	scsiOSLun;
1097836SJohn.Forte@Sun.COM 	struct _tgtPortWWNList *next;
1107836SJohn.Forte@Sun.COM } tgtPortWWNList;
1117836SJohn.Forte@Sun.COM 
1127836SJohn.Forte@Sun.COM typedef struct _portWWNList {
1137836SJohn.Forte@Sun.COM 	HBA_WWN	portWWN;
1147836SJohn.Forte@Sun.COM 	tgtPortWWNList *tgtPortWWN;
1157836SJohn.Forte@Sun.COM 	struct _portWWNList *next;
1167836SJohn.Forte@Sun.COM } portWWNList;
1177836SJohn.Forte@Sun.COM 
1187836SJohn.Forte@Sun.COM /* Discovered ports structure */
1197836SJohn.Forte@Sun.COM typedef struct _discoveredDevice {
1207836SJohn.Forte@Sun.COM 	char	OSDeviceName[MAXPATHLEN];
1217836SJohn.Forte@Sun.COM 	portWWNList *HBAPortWWN;
1227836SJohn.Forte@Sun.COM 	char    VID[8];
1237836SJohn.Forte@Sun.COM 	char    PID[16];
1247836SJohn.Forte@Sun.COM 	boolean_t   inqSuccess;
1257836SJohn.Forte@Sun.COM 	uchar_t	dType;
1267836SJohn.Forte@Sun.COM 	struct  _discoveredDevice *next;
1277836SJohn.Forte@Sun.COM } discoveredDevice;
1287836SJohn.Forte@Sun.COM 
1297836SJohn.Forte@Sun.COM /* globals */
1307836SJohn.Forte@Sun.COM static char *cmdName;
1317836SJohn.Forte@Sun.COM 
1327836SJohn.Forte@Sun.COM /* print helper functions */
1337836SJohn.Forte@Sun.COM void printHBAPortInfo(HBA_PORTATTRIBUTES *port,
1347836SJohn.Forte@Sun.COM     HBA_ADAPTERATTRIBUTES *attrs, int mode);
1357836SJohn.Forte@Sun.COM void printDiscoPortInfo(HBA_PORTATTRIBUTES *discoPort, int scsiTargetType);
1367836SJohn.Forte@Sun.COM void printLUNInfo(struct scsi_inquiry *inq, HBA_UINT32 scsiLUN, char *devpath);
1377836SJohn.Forte@Sun.COM void printPortStat(fc_rls_acc_t *rls_payload);
1387836SJohn.Forte@Sun.COM void printScsiTarget(HBA_WWN);
1397836SJohn.Forte@Sun.COM void printStatus(HBA_STATUS status);
1407836SJohn.Forte@Sun.COM void printOSDeviceNameInfo(discoveredDevice *devListWalk, boolean_t verbose);
1417836SJohn.Forte@Sun.COM uint64_t wwnConversion(uchar_t *wwn);
1427836SJohn.Forte@Sun.COM 
1437836SJohn.Forte@Sun.COM int fc_util_list_hbaport(int wwnCount, char **wwn_argv, cmdOptions_t *options);
1447836SJohn.Forte@Sun.COM int fc_util_list_remoteport(int wwnCount, char **argv, cmdOptions_t *options);
1457836SJohn.Forte@Sun.COM int fc_util_list_logicalunit(int pathCount, char **argv, cmdOptions_t *options);
1467836SJohn.Forte@Sun.COM int fc_util_delete_npivport(int wwnCount, char **argv, cmdOptions_t *options);
1477836SJohn.Forte@Sun.COM int fc_util_create_npivport(int wwnCount, char **argv, cmdOptions_t *options);
1487836SJohn.Forte@Sun.COM int fc_util_create_portlist();
149*10275SReed.Liu@Sun.COM int fc_util_force_lip(int objects, char *argv[]);
1507836SJohn.Forte@Sun.COM 
1519087SZhong.Wang@Sun.COM int fcoe_adm_create_port(int objects, char *argv[],
1529087SZhong.Wang@Sun.COM     cmdOptions_t *options);
1539087SZhong.Wang@Sun.COM int fcoe_adm_delete_port(int objects, char *argv[]);
1549087SZhong.Wang@Sun.COM int fcoe_adm_list_ports(cmdOptions_t *options);
1559087SZhong.Wang@Sun.COM 
1569087SZhong.Wang@Sun.COM 
1577836SJohn.Forte@Sun.COM #ifdef	__cplusplus
1587836SJohn.Forte@Sun.COM }
1597836SJohn.Forte@Sun.COM #endif
1607836SJohn.Forte@Sun.COM 
1617836SJohn.Forte@Sun.COM #endif /* _FCINFO_H */
162