xref: /titanic_41/usr/src/lib/fm/libseslog/common/libseslog.h (revision e5803b76927480e8f9b67b22201c484ccf4c2bcf)
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_FAILED_TO_OPEN_DEVICE = 1, /* Couldn't open dev path */
44 	SES_LOG_FAILED_TO_READ_DEVICE,	/* Couldn't read the log data */
45 	SES_LOG_FAILED_NULL_TARGET_PATH,	/* Null target path */
46 	SES_LOG_FAILED_BAD_TARGET_PATH,	/* Couldn't find valid target path */
47 	SES_LOG_FAILED_MODE_SENSE,    	/* Mode sense error returned */
48 	SES_LOG_FAILED_MODE_SENSE_OFFSET,	/* Offset not correct */
49 	SES_LOG_FAILED_BAD_DATA_LEN, 	/* Data length not correct */
50 	SES_LOG_FAILED_BAD_CONTENT_LEN,	/* Content length not correct */
51 	SES_LOG_FAILED_FORMAT_PAGE_ERR,	/* Device doesn't support page */
52 	SES_LOG_FAILED_NV_UNIQUE,	/* Couldn't add unique to nvlist */
53 	SES_LOG_FAILED_NV_LOG,		/* Couldn't add log to nvlist */
54 	SES_LOG_FAILED_NV_CODE,		/* Couldn't add code to nvlist */
55 	SES_LOG_FAILED_NV_SEV,		/* Couldn't add sev to nvlist */
56 	SES_LOG_FAILED_NV_ENTRY,    	/* Couldn't add entry to nvlist */
57 	SES_LOG_FAILED_MODE_SELECT,	/* Mode select failed */
58 	SES_LOG_FAILED_NVLIST_CREATE	/* Couldn't create a nvlist */
59 };
60 
61 /*
62  * define different levels of log entries that could be returned
63  */
64 #define	SES_LOG_LEVEL_NOTICE 0
65 #define	SES_LOG_LEVEL_DEBUG 1
66 #define	SES_LOG_LEVEL_WARNING 2
67 #define	SES_LOG_LEVEL_NO_MASK 3
68 #define	SES_LOG_LEVEL_ERROR 4
69 #define	SES_LOG_LEVEL_FATAL 5
70 
71 /* Valid size of log entry being returned by expander */
72 #define	SES_LOG_VALID_LOG_SIZE 71
73 
74 /* The string log is made from 8 char entries */
75 #define	SES_LOG_SPECIFIC_ENTRY_SIZE 8
76 
77 /* Index of where sequence number starts in returned string */
78 #define	SES_LOG_SEQ_NUM_START 27
79 /* Index of where log code starts */
80 #define	SES_LOG_CODE_START 36
81 /* Index of where log level starts in returned string */
82 #define	SES_LOG_LEVEL_START 40
83 
84 /* Maximum size the each sub log entry can be */
85 #define	ENTRY_MAX_SIZE	10
86 /* Maximum save buffer log entry size */
87 #define	MAX_LOG_ENTRY_SZ	256
88 
89 #define	MAX_ALLOC_LEN (0xfffc)
90 /*
91  * Sense return buffer length
92  * Arbitrary, could be larger
93  */
94 #define	SENSE_BUFF_LEN	32
95 /*
96  * 60 seconds for SCSI timeout
97  */
98 #define	DEF_PT_TIMEOUT	60
99 
100 
101 /*
102  * Defines for different SCSI cmd paramters
103  */
104 #define	MODE_SELECT10_CMDLEN  10
105 #define	MODE10_RESP_HDR_LEN   8
106 #define	MODE_SENSE10_CMDLEN   10
107 
108 
109 /*
110  * Defines for nvlist entries
111  */
112 #define	ENTRY_PREFIX	"entry"
113 #define	ENTRY_SEVERITY	"severity"
114 #define	ENTRY_CODE	"code"
115 #define	ENTRY_LOG	"log"
116 
117 
118 
119 /*
120  * Genesis specific log clear control struct
121  */
122 struct log_clear_control_struct {
123 	unsigned char pageControls;
124 	uint8_t subpage_code;
125 	uint8_t page_lengthUpper;
126 	uint8_t page_lengthLower;
127 	uint8_t host_id[16];
128 	uint8_t seq_clear[4];
129 	uint8_t timeout[2];
130 };
131 
132 
133 
134 /*
135  * Struct to contain information needed to read logs
136  */
137 typedef struct ses_log_call_struct {
138 	char target_path[MAXPATHLEN]; /* Path to device, passed in */
139 	char product_id[MAXNAMELEN]; /* product id of expander, passed in */
140 	hrtime_t poll_time; /* nanosecond poll time, passed in */
141 	char last_log_entry[MAXNAMELEN]; /* Last entry read, passed in/out */
142 	int number_log_entries;  /* num of log entries read, passed back */
143 	int size_of_log_entries; /* Total size of all logs read passed back */
144 	nvlist_t *log_data;  /* Log data being returned, passed back */
145 } ses_log_call_t;
146 
147 /*
148  * Basic library functions
149  */
150 extern int access_ses_log(struct ses_log_call_struct *);
151 
152 
153 #ifdef	__cplusplus
154 }
155 #endif
156 
157 #endif	/* _LIBSESLOG_H */
158