xref: /titanic_41/usr/src/lib/fm/libseslog/common/libseslog.h (revision 05ead181677a01a3a118f8b89ce79361113e34cf)
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 (c) 2010, Oracle and/or its affiliates. All rights reserved.
23  */
24 
25 
26 
27 #ifndef	_LIBSESLOG_H
28 #define	_LIBSESLOG_H
29 
30 #include <libnvpair.h>
31 #include <sys/types.h>
32 #include <sys/scsi/impl/uscsi.h>
33 
34 #ifdef	__cplusplus
35 extern "C" {
36 #endif
37 
38 /*
39  * Error definitions
40  */
41 
42 enum {
43 	SES_LOG_UNSUPPORTED_HW_ERROR = 1, /* Wrong product ID */
44 	SES_LOG_FAILED_TO_OPEN_DEVICE, /* Couldn't open dev path */
45 	SES_LOG_FAILED_TO_READ_DEVICE, /* Couldn't read the log data */
46 	SES_LOG_FAILED_NVLIST_PROTOCOL, /* Couldn't add protocol */
47 	SES_LOG_FAILED_NULL_TARGET_PATH, /* Null target path */
48 	SES_LOG_FAILED_BAD_TARGET_PATH, /* Couldn't find valid target path */
49 	SES_LOG_FAILED_MODE_SENSE, /* Mode sense error returned */
50 	SES_LOG_FAILED_MODE_SENSE_OFFSET, /* Offset not correct */
51 	SES_LOG_FAILED_BAD_DATA_LEN, /* Data length not correct */
52 	SES_LOG_FAILED_BAD_CONTENT_LEN, /* Content length not correct */
53 	SES_LOG_FAILED_FORMAT_PAGE_ERROR, /* Device doesn't support page */
54 	SES_LOG_FAILED_SHORT_LOG_PARAM_INIT, /* Log paramter was too short */
55 	SES_LOG_FAILED_SHORT_LOG_PARAM, /* Log paramter was too short */
56 	SES_LOG_FAILED_NV_UNIQUE, /* Couldn't add unique to nvlist */
57 	SES_LOG_FAILED_NV_LOG, /* Couldn't add log to nvlist */
58 	SES_LOG_FAILED_NV_CODE, /* Couldn't add code to nvlist */
59 	SES_LOG_FAILED_NV_SEV, /* Couldn't add sev to nvlist */
60 	SES_LOG_FAILED_NV_ENTRY, /* Couldn't add entry to nvlist */
61 	SES_LOG_FAILED_MODE_SELECT, /* Mode select failed */
62 	SES_LOG_FAILED_NVLIST_CREATE   /* Couldn't create a nvlist */
63 };
64 
65 /*
66  * define different levels of log entries that could be returned
67  */
68 #define	SES_LOG_LEVEL_NOTICE 0
69 #define	SES_LOG_LEVEL_DEBUG 1
70 #define	SES_LOG_LEVEL_WARNING 2
71 #define	SES_LOG_LEVEL_ERROR 3
72 #define	SES_LOG_LEVEL_FATAL 4
73 
74 /* Valid size of log entry being returned by expander */
75 #define	SES_LOG_VALID_LOG_SIZE 71
76 /* Index of where sequence number starts in returned string */
77 #define	SES_LOG_SEQ_NUM_START 27
78 /* Index of where log level starts in returned string */
79 #define	SES_LOG_LEVEL_START 40
80 
81 /*
82  * Error buffer size
83  */
84 #define	EBUFF_SZ	256
85 
86 #define	MX_ALLOC_LEN (0xfffc)
87 /*
88  * Sense return buffer length
89  * Arbitrary, could be larger
90  */
91 #define	SENSE_BUFF_LEN	32
92 /*
93  * 60 seconds
94  */
95 #define	DEF_PT_TIMEOUT	60
96 
97 
98 /*
99  * Defines for different SCSI cmd paramters
100  */
101 #define	MODE_SELECT10_CMDLEN  10
102 #define	MODE10_RESP_HDR_LEN   8
103 #define	MODE_SENSE10_CMDLEN   10
104 
105 
106 /*
107  * Defines for nvlist entries
108  */
109 #define	ENTRY_PREFIX	"entry"
110 #define	ENTRY_SEVERITY	"severity"
111 #define	ENTRY_CODE	"code"
112 #define	ENTRY_LOG	"log"
113 #define	PROTOCOL	"protocol"
114 #define	PROTOCOL_TYPE	"ses"
115 
116 
117 
118 /*
119  * Genesis specific log clear control struct
120  */
121 struct log_clear_control_struct {
122 	unsigned char pageControls;
123 	uint8_t subpage_code;
124 	uint8_t page_lengthUpper;
125 	uint8_t page_lengthLower;
126 	uint8_t host_id[16];
127 	uint8_t seq_clear[4];
128 	uint8_t timeout[2];
129 };
130 
131 
132 
133 /*
134  * Struct to contain information needed to read logs
135  */
136 struct ses_log_call_struct {
137 	char target_path[MAXPATHLEN]; /* Path to device, passed in */
138 	char product_id[MAXNAMELEN]; /* product id of expander, passed in */
139 	hrtime_t poll_time; /* nanosecond poll time, passed in */
140 	char last_log_entry[MAXNAMELEN]; /* Last entry read, passed in/out */
141 	int number_log_entries;  /* num of log entries read, passed back */
142 	int size_of_log_entries; /* Total size of all logs read passed back */
143 	nvlist_t *log_data;  /* Log data being returned, passed back */
144 };
145 
146 /*
147  * Basic library functions
148  */
149 extern int access_ses_log(struct ses_log_call_struct *);
150 
151 
152 #ifdef	__cplusplus
153 }
154 #endif
155 
156 #endif	/* _LIBSESLOG_H */
157