xref: /illumos-gate/usr/src/cmd/sasinfo/sasinfo.h (revision 533affcbc7fc4d0c8132976ea454aaa715fe2307)
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 _SASINFO_H
27 #define	_SASINFO_H
28 
29 #ifdef	__cplusplus
30 extern "C" {
31 #endif
32 
33 #include <stdio.h>
34 #include <stdlib.h>
35 #include <string.h>
36 #include <libintl.h>
37 #include <smhbaapi.h>
38 #include <sys/types.h>
39 #include <sys/scsi/scsi.h>
40 #include <inttypes.h>
41 #include <cmdparse.h>
42 #include <netinet/in.h>
43 #include <inttypes.h>
44 #include <locale.h>
45 
46 #ifdef _BIG_ENDIAN
47 #define	htonll(x)   (x)
48 #define	ntohll(x)   (x)
49 #else
50 #define	htonll(x)   ((((unsigned long long)htonl(x)) << 32) + htonl(x >> 32))
51 #define	ntohll(x)   ((((unsigned long long)ntohl(x)) << 32) + ntohl(x >> 32))
52 #endif
53 
54 /* DEFINES */
55 #define	DEFAULT_LUN_COUNT	1024
56 #define	LUN_SIZE		8
57 #define	LUN_HEADER_SIZE		8
58 #define	LUN_LENGTH		LUN_SIZE + LUN_HEADER_SIZE
59 #define	DEFAULT_LUN_LENGTH	DEFAULT_LUN_COUNT  * \
60 				LUN_SIZE	   + \
61 				LUN_HEADER_SIZE
62 
63 /* flags that are needed to be passed into porcessHBA */
64 #define	PRINT_VERBOSE		0x00000001
65 #define	PRINT_PHY		0x00000002 /* print phy addresses */
66 #define	PRINT_PHY_LINKSTAT	0x00000004 /* print phy link statistics */
67 #define	PRINT_TARGET_PORT	0x00000008 /* print target os deivce info */
68 #define	PRINT_CHILD		0x00000010 /* print descendant nodes */
69 #define	PRINT_TARGET_SCSI	0x00000020 /* print descendant nodes */
70 
71 #define	HBA_MAX_RETRIES		20
72 
73 typedef struct _tgtPortWWNList {
74 	HBA_WWN portWWN;
75 	HBA_UINT32	scsiOSLun;
76 	struct _tgtPortWWNList *next;
77 } tgtPortWWNList;
78 
79 typedef struct _portList {
80 	char		portName[MAXPATHLEN];
81 	tgtPortWWNList	*tgtPortWWN;
82 	struct _portList	*next;
83 } portList;
84 
85 /* Discovered LU structure */
86 typedef struct _discoveredDevice {
87 	boolean_t	inquiryFailed;
88 	char 		OSDeviceName[MAXPATHLEN];
89 	portList	*HBAPortList;
90 	char		VID[8];
91 	char		PID[16];
92 	uchar_t		dType;
93 	struct _discoveredDevice *next;
94 } discoveredDevice;
95 
96 typedef struct targetPortMappingData {
97 	boolean_t	mappingExist;
98 	boolean_t	inquiryFailed;
99 	HBA_UINT32	osLUN;
100 	SMHBA_SCSILUN	reportLUN;
101 	char		osDeviceName[256];
102 	uchar_t		inq_vid[8];
103 	uchar_t		inq_pid[16];
104 	uchar_t		inq_dtype;
105 	struct targetPortMappingData   *next;
106 } targetPortMappingData_t;
107 
108 typedef struct targetPortConfig {
109 	char 		hbaPortName[256];
110 	HBA_WWN		expanderSASAddr;
111 	int 		expanderValid;
112 	boolean_t   	reportLUNsFailed;
113 	struct 		targetPortMappingData    *map;
114 	struct 		targetPortConfig    *next;
115 } targetPortConfig_t;
116 
117 typedef struct targetPortList {
118 	SMHBA_PORTATTRIBUTES	targetattr;
119 	SMHBA_SAS_PORT		sasattr;
120 	struct targetPortConfig *configEntry;
121 	struct targetPortList	*next;
122 } targetPortList_t;
123 
124 int sas_util_list_hba(int hbaCount, char **hba_argv, cmdOptions_t *options);
125 int sas_util_list_hbaport(int wwnCount, char **wwn_argv, cmdOptions_t *options);
126 int sas_util_list_expander(int wwnCount, char **wwn_argv,
127     cmdOptions_t *options);
128 int sas_util_list_targetport(int tpCount, char **tpArgv, cmdOptions_t *options);
129 int sas_util_list_remoteport(int wwnCount, char **wwn_argv,
130     cmdOptions_t *options);
131 int
132 sas_util_list_logicalunit(int luCount, char **luArgv, cmdOptions_t *options);
133 
134 #ifdef	__cplusplus
135 }
136 #endif
137 
138 #endif /* _SASINFO_H */
139