xref: /onnv-gate/usr/src/cmd/sasinfo/sasinfo.h (revision 10652:9d0aff74d6fd)
1*10652SHyon.Kim@Sun.COM /*
2*10652SHyon.Kim@Sun.COM  * CDDL HEADER START
3*10652SHyon.Kim@Sun.COM  *
4*10652SHyon.Kim@Sun.COM  * The contents of this file are subject to the terms of the
5*10652SHyon.Kim@Sun.COM  * Common Development and Distribution License (the "License").
6*10652SHyon.Kim@Sun.COM  * You may not use this file except in compliance with the License.
7*10652SHyon.Kim@Sun.COM  *
8*10652SHyon.Kim@Sun.COM  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*10652SHyon.Kim@Sun.COM  * or http://www.opensolaris.org/os/licensing.
10*10652SHyon.Kim@Sun.COM  * See the License for the specific language governing permissions
11*10652SHyon.Kim@Sun.COM  * and limitations under the License.
12*10652SHyon.Kim@Sun.COM  *
13*10652SHyon.Kim@Sun.COM  * When distributing Covered Code, include this CDDL HEADER in each
14*10652SHyon.Kim@Sun.COM  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*10652SHyon.Kim@Sun.COM  * If applicable, add the following below this CDDL HEADER, with the
16*10652SHyon.Kim@Sun.COM  * fields enclosed by brackets "[]" replaced with your own identifying
17*10652SHyon.Kim@Sun.COM  * information: Portions Copyright [yyyy] [name of copyright owner]
18*10652SHyon.Kim@Sun.COM  *
19*10652SHyon.Kim@Sun.COM  * CDDL HEADER END
20*10652SHyon.Kim@Sun.COM  */
21*10652SHyon.Kim@Sun.COM /*
22*10652SHyon.Kim@Sun.COM  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23*10652SHyon.Kim@Sun.COM  * Use is subject to license terms.
24*10652SHyon.Kim@Sun.COM  */
25*10652SHyon.Kim@Sun.COM 
26*10652SHyon.Kim@Sun.COM #ifndef _SASINFO_H
27*10652SHyon.Kim@Sun.COM #define	_SASINFO_H
28*10652SHyon.Kim@Sun.COM 
29*10652SHyon.Kim@Sun.COM #ifdef	__cplusplus
30*10652SHyon.Kim@Sun.COM extern "C" {
31*10652SHyon.Kim@Sun.COM #endif
32*10652SHyon.Kim@Sun.COM 
33*10652SHyon.Kim@Sun.COM #include <stdio.h>
34*10652SHyon.Kim@Sun.COM #include <stdlib.h>
35*10652SHyon.Kim@Sun.COM #include <string.h>
36*10652SHyon.Kim@Sun.COM #include <libintl.h>
37*10652SHyon.Kim@Sun.COM #include <smhbaapi.h>
38*10652SHyon.Kim@Sun.COM #include <sys/types.h>
39*10652SHyon.Kim@Sun.COM #include <sys/scsi/scsi.h>
40*10652SHyon.Kim@Sun.COM #include <inttypes.h>
41*10652SHyon.Kim@Sun.COM #include <cmdparse.h>
42*10652SHyon.Kim@Sun.COM #include <netinet/in.h>
43*10652SHyon.Kim@Sun.COM #include <inttypes.h>
44*10652SHyon.Kim@Sun.COM #include <locale.h>
45*10652SHyon.Kim@Sun.COM 
46*10652SHyon.Kim@Sun.COM #ifdef _BIG_ENDIAN
47*10652SHyon.Kim@Sun.COM #define	htonll(x)   (x)
48*10652SHyon.Kim@Sun.COM #define	ntohll(x)   (x)
49*10652SHyon.Kim@Sun.COM #else
50*10652SHyon.Kim@Sun.COM #define	htonll(x)   ((((unsigned long long)htonl(x)) << 32) + htonl(x >> 32))
51*10652SHyon.Kim@Sun.COM #define	ntohll(x)   ((((unsigned long long)ntohl(x)) << 32) + ntohl(x >> 32))
52*10652SHyon.Kim@Sun.COM #endif
53*10652SHyon.Kim@Sun.COM 
54*10652SHyon.Kim@Sun.COM /* DEFINES */
55*10652SHyon.Kim@Sun.COM #define	DEFAULT_LUN_COUNT	1024
56*10652SHyon.Kim@Sun.COM #define	LUN_SIZE		8
57*10652SHyon.Kim@Sun.COM #define	LUN_HEADER_SIZE		8
58*10652SHyon.Kim@Sun.COM #define	LUN_LENGTH		LUN_SIZE + LUN_HEADER_SIZE
59*10652SHyon.Kim@Sun.COM #define	DEFAULT_LUN_LENGTH	DEFAULT_LUN_COUNT  * \
60*10652SHyon.Kim@Sun.COM 				LUN_SIZE	   + \
61*10652SHyon.Kim@Sun.COM 				LUN_HEADER_SIZE
62*10652SHyon.Kim@Sun.COM 
63*10652SHyon.Kim@Sun.COM /* flags that are needed to be passed into porcessHBA */
64*10652SHyon.Kim@Sun.COM #define	PRINT_VERBOSE		0x00000001
65*10652SHyon.Kim@Sun.COM #define	PRINT_PHY		0x00000002 /* print phy addresses */
66*10652SHyon.Kim@Sun.COM #define	PRINT_PHY_LINKSTAT	0x00000004 /* print phy link statistics */
67*10652SHyon.Kim@Sun.COM #define	PRINT_TARGET_PORT	0x00000008 /* print target os deivce info */
68*10652SHyon.Kim@Sun.COM #define	PRINT_CHILD		0x00000010 /* print descendant nodes */
69*10652SHyon.Kim@Sun.COM #define	PRINT_TARGET_SCSI	0x00000020 /* print descendant nodes */
70*10652SHyon.Kim@Sun.COM 
71*10652SHyon.Kim@Sun.COM #define	HBA_MAX_RETRIES		20
72*10652SHyon.Kim@Sun.COM 
73*10652SHyon.Kim@Sun.COM typedef struct _tgtPortWWNList {
74*10652SHyon.Kim@Sun.COM 	HBA_WWN portWWN;
75*10652SHyon.Kim@Sun.COM 	HBA_UINT32	scsiOSLun;
76*10652SHyon.Kim@Sun.COM 	struct _tgtPortWWNList *next;
77*10652SHyon.Kim@Sun.COM } tgtPortWWNList;
78*10652SHyon.Kim@Sun.COM 
79*10652SHyon.Kim@Sun.COM typedef struct _portList {
80*10652SHyon.Kim@Sun.COM 	char		portName[MAXPATHLEN];
81*10652SHyon.Kim@Sun.COM 	tgtPortWWNList	*tgtPortWWN;
82*10652SHyon.Kim@Sun.COM 	struct _portList	*next;
83*10652SHyon.Kim@Sun.COM } portList;
84*10652SHyon.Kim@Sun.COM 
85*10652SHyon.Kim@Sun.COM /* Discovered LU structure */
86*10652SHyon.Kim@Sun.COM typedef struct _discoveredDevice {
87*10652SHyon.Kim@Sun.COM 	boolean_t	inquiryFailed;
88*10652SHyon.Kim@Sun.COM 	char 		OSDeviceName[MAXPATHLEN];
89*10652SHyon.Kim@Sun.COM 	portList	*HBAPortList;
90*10652SHyon.Kim@Sun.COM 	char		VID[8];
91*10652SHyon.Kim@Sun.COM 	char		PID[16];
92*10652SHyon.Kim@Sun.COM 	uchar_t		dType;
93*10652SHyon.Kim@Sun.COM 	struct _discoveredDevice *next;
94*10652SHyon.Kim@Sun.COM } discoveredDevice;
95*10652SHyon.Kim@Sun.COM 
96*10652SHyon.Kim@Sun.COM typedef struct targetPortMappingData {
97*10652SHyon.Kim@Sun.COM 	boolean_t	mappingExist;
98*10652SHyon.Kim@Sun.COM 	boolean_t	inquiryFailed;
99*10652SHyon.Kim@Sun.COM 	HBA_UINT32	osLUN;
100*10652SHyon.Kim@Sun.COM 	SMHBA_SCSILUN	reportLUN;
101*10652SHyon.Kim@Sun.COM 	char		osDeviceName[256];
102*10652SHyon.Kim@Sun.COM 	uchar_t		inq_vid[8];
103*10652SHyon.Kim@Sun.COM 	uchar_t		inq_pid[16];
104*10652SHyon.Kim@Sun.COM 	uchar_t		inq_dtype;
105*10652SHyon.Kim@Sun.COM 	struct targetPortMappingData   *next;
106*10652SHyon.Kim@Sun.COM } targetPortMappingData_t;
107*10652SHyon.Kim@Sun.COM 
108*10652SHyon.Kim@Sun.COM typedef struct targetPortConfig {
109*10652SHyon.Kim@Sun.COM 	char 		hbaPortName[256];
110*10652SHyon.Kim@Sun.COM 	HBA_WWN		expanderSASAddr;
111*10652SHyon.Kim@Sun.COM 	int 		expanderValid;
112*10652SHyon.Kim@Sun.COM 	boolean_t   	reportLUNsFailed;
113*10652SHyon.Kim@Sun.COM 	struct 		targetPortMappingData    *map;
114*10652SHyon.Kim@Sun.COM 	struct 		targetPortConfig    *next;
115*10652SHyon.Kim@Sun.COM } targetPortConfig_t;
116*10652SHyon.Kim@Sun.COM 
117*10652SHyon.Kim@Sun.COM typedef struct targetPortList {
118*10652SHyon.Kim@Sun.COM 	SMHBA_PORTATTRIBUTES	targetattr;
119*10652SHyon.Kim@Sun.COM 	SMHBA_SAS_PORT		sasattr;
120*10652SHyon.Kim@Sun.COM 	struct targetPortConfig *configEntry;
121*10652SHyon.Kim@Sun.COM 	struct targetPortList	*next;
122*10652SHyon.Kim@Sun.COM } targetPortList_t;
123*10652SHyon.Kim@Sun.COM 
124*10652SHyon.Kim@Sun.COM int sas_util_list_hba(int hbaCount, char **hba_argv, cmdOptions_t *options);
125*10652SHyon.Kim@Sun.COM int sas_util_list_hbaport(int wwnCount, char **wwn_argv, cmdOptions_t *options);
126*10652SHyon.Kim@Sun.COM int sas_util_list_expander(int wwnCount, char **wwn_argv,
127*10652SHyon.Kim@Sun.COM     cmdOptions_t *options);
128*10652SHyon.Kim@Sun.COM int sas_util_list_targetport(int tpCount, char **tpArgv, cmdOptions_t *options);
129*10652SHyon.Kim@Sun.COM int sas_util_list_remoteport(int wwnCount, char **wwn_argv,
130*10652SHyon.Kim@Sun.COM     cmdOptions_t *options);
131*10652SHyon.Kim@Sun.COM int
132*10652SHyon.Kim@Sun.COM sas_util_list_logicalunit(int luCount, char **luArgv, cmdOptions_t *options);
133*10652SHyon.Kim@Sun.COM 
134*10652SHyon.Kim@Sun.COM #ifdef	__cplusplus
135*10652SHyon.Kim@Sun.COM }
136*10652SHyon.Kim@Sun.COM #endif
137*10652SHyon.Kim@Sun.COM 
138*10652SHyon.Kim@Sun.COM #endif /* _SASINFO_H */
139