xref: /onnv-gate/usr/src/lib/fm/libseslog/common/libseslog.h (revision 12906:00c95d1e0c4d)
112767SJames.Kremer@Sun.COM /*
212767SJames.Kremer@Sun.COM  * CDDL HEADER START
312767SJames.Kremer@Sun.COM  *
412767SJames.Kremer@Sun.COM  * The contents of this file are subject to the terms of the
512767SJames.Kremer@Sun.COM  * Common Development and Distribution License (the "License").
612767SJames.Kremer@Sun.COM  * You may not use this file except in compliance with the License.
712767SJames.Kremer@Sun.COM  *
812767SJames.Kremer@Sun.COM  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
912767SJames.Kremer@Sun.COM  * or http://www.opensolaris.org/os/licensing.
1012767SJames.Kremer@Sun.COM  * See the License for the specific language governing permissions
1112767SJames.Kremer@Sun.COM  * and limitations under the License.
1212767SJames.Kremer@Sun.COM  *
1312767SJames.Kremer@Sun.COM  * When distributing Covered Code, include this CDDL HEADER in each
1412767SJames.Kremer@Sun.COM  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1512767SJames.Kremer@Sun.COM  * If applicable, add the following below this CDDL HEADER, with the
1612767SJames.Kremer@Sun.COM  * fields enclosed by brackets "[]" replaced with your own identifying
1712767SJames.Kremer@Sun.COM  * information: Portions Copyright [yyyy] [name of copyright owner]
1812767SJames.Kremer@Sun.COM  *
1912767SJames.Kremer@Sun.COM  * CDDL HEADER END
2012767SJames.Kremer@Sun.COM  */
2112767SJames.Kremer@Sun.COM /*
2212767SJames.Kremer@Sun.COM  * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
2312767SJames.Kremer@Sun.COM  */
2412767SJames.Kremer@Sun.COM 
2512767SJames.Kremer@Sun.COM 
2612767SJames.Kremer@Sun.COM 
2712767SJames.Kremer@Sun.COM #ifndef	_LIBSESLOG_H
2812767SJames.Kremer@Sun.COM #define	_LIBSESLOG_H
2912767SJames.Kremer@Sun.COM 
3012767SJames.Kremer@Sun.COM #include <libnvpair.h>
3112767SJames.Kremer@Sun.COM #include <sys/types.h>
3212767SJames.Kremer@Sun.COM #include <sys/scsi/impl/uscsi.h>
3312767SJames.Kremer@Sun.COM 
3412767SJames.Kremer@Sun.COM #ifdef	__cplusplus
3512767SJames.Kremer@Sun.COM extern "C" {
3612767SJames.Kremer@Sun.COM #endif
3712767SJames.Kremer@Sun.COM 
3812767SJames.Kremer@Sun.COM /*
3912767SJames.Kremer@Sun.COM  * Error definitions
4012767SJames.Kremer@Sun.COM  */
4112767SJames.Kremer@Sun.COM 
4212767SJames.Kremer@Sun.COM enum {
43*12843Stodd.mckenney@oracle.com 	SES_LOG_FAILED_TO_OPEN_DEVICE = 1, /* Couldn't open dev path */
44*12843Stodd.mckenney@oracle.com 	SES_LOG_FAILED_TO_READ_DEVICE,	/* Couldn't read the log data */
45*12843Stodd.mckenney@oracle.com 	SES_LOG_FAILED_NULL_TARGET_PATH,	/* Null target path */
46*12843Stodd.mckenney@oracle.com 	SES_LOG_FAILED_BAD_TARGET_PATH,	/* Couldn't find valid target path */
47*12843Stodd.mckenney@oracle.com 	SES_LOG_FAILED_MODE_SENSE,    	/* Mode sense error returned */
48*12843Stodd.mckenney@oracle.com 	SES_LOG_FAILED_MODE_SENSE_OFFSET,	/* Offset not correct */
49*12843Stodd.mckenney@oracle.com 	SES_LOG_FAILED_BAD_DATA_LEN, 	/* Data length not correct */
50*12843Stodd.mckenney@oracle.com 	SES_LOG_FAILED_BAD_CONTENT_LEN,	/* Content length not correct */
51*12843Stodd.mckenney@oracle.com 	SES_LOG_FAILED_FORMAT_PAGE_ERR,	/* Device doesn't support page */
52*12843Stodd.mckenney@oracle.com 	SES_LOG_FAILED_NV_UNIQUE,	/* Couldn't add unique to nvlist */
53*12843Stodd.mckenney@oracle.com 	SES_LOG_FAILED_NV_LOG,		/* Couldn't add log to nvlist */
54*12843Stodd.mckenney@oracle.com 	SES_LOG_FAILED_NV_CODE,		/* Couldn't add code to nvlist */
55*12843Stodd.mckenney@oracle.com 	SES_LOG_FAILED_NV_SEV,		/* Couldn't add sev to nvlist */
56*12843Stodd.mckenney@oracle.com 	SES_LOG_FAILED_NV_ENTRY,    	/* Couldn't add entry to nvlist */
57*12843Stodd.mckenney@oracle.com 	SES_LOG_FAILED_MODE_SELECT,	/* Mode select failed */
58*12843Stodd.mckenney@oracle.com 	SES_LOG_FAILED_NVLIST_CREATE	/* Couldn't create a nvlist */
5912767SJames.Kremer@Sun.COM };
6012767SJames.Kremer@Sun.COM 
6112767SJames.Kremer@Sun.COM /*
6212767SJames.Kremer@Sun.COM  * define different levels of log entries that could be returned
6312767SJames.Kremer@Sun.COM  */
6412767SJames.Kremer@Sun.COM #define	SES_LOG_LEVEL_NOTICE 0
6512767SJames.Kremer@Sun.COM #define	SES_LOG_LEVEL_DEBUG 1
6612767SJames.Kremer@Sun.COM #define	SES_LOG_LEVEL_WARNING 2
67*12843Stodd.mckenney@oracle.com #define	SES_LOG_LEVEL_NO_MASK 3
68*12843Stodd.mckenney@oracle.com #define	SES_LOG_LEVEL_ERROR 4
69*12843Stodd.mckenney@oracle.com #define	SES_LOG_LEVEL_FATAL 5
7012767SJames.Kremer@Sun.COM 
7112767SJames.Kremer@Sun.COM /* Valid size of log entry being returned by expander */
7212767SJames.Kremer@Sun.COM #define	SES_LOG_VALID_LOG_SIZE 71
73*12843Stodd.mckenney@oracle.com 
74*12843Stodd.mckenney@oracle.com /* The string log is made from 8 char entries */
75*12843Stodd.mckenney@oracle.com #define	SES_LOG_SPECIFIC_ENTRY_SIZE 8
76*12843Stodd.mckenney@oracle.com 
7712767SJames.Kremer@Sun.COM /* Index of where sequence number starts in returned string */
7812767SJames.Kremer@Sun.COM #define	SES_LOG_SEQ_NUM_START 27
79*12843Stodd.mckenney@oracle.com /* Index of where log code starts */
80*12843Stodd.mckenney@oracle.com #define	SES_LOG_CODE_START 36
8112767SJames.Kremer@Sun.COM /* Index of where log level starts in returned string */
8212767SJames.Kremer@Sun.COM #define	SES_LOG_LEVEL_START 40
8312767SJames.Kremer@Sun.COM 
84*12843Stodd.mckenney@oracle.com /* Maximum size the each sub log entry can be */
85*12843Stodd.mckenney@oracle.com #define	ENTRY_MAX_SIZE	10
86*12843Stodd.mckenney@oracle.com /* Maximum save buffer log entry size */
87*12843Stodd.mckenney@oracle.com #define	MAX_LOG_ENTRY_SZ	256
8812767SJames.Kremer@Sun.COM 
89*12843Stodd.mckenney@oracle.com #define	MAX_ALLOC_LEN (0xfffc)
9012767SJames.Kremer@Sun.COM /*
9112767SJames.Kremer@Sun.COM  * Sense return buffer length
9212767SJames.Kremer@Sun.COM  * Arbitrary, could be larger
9312767SJames.Kremer@Sun.COM  */
9412767SJames.Kremer@Sun.COM #define	SENSE_BUFF_LEN	32
9512767SJames.Kremer@Sun.COM /*
96*12843Stodd.mckenney@oracle.com  * 60 seconds for SCSI timeout
9712767SJames.Kremer@Sun.COM  */
9812767SJames.Kremer@Sun.COM #define	DEF_PT_TIMEOUT	60
9912767SJames.Kremer@Sun.COM 
10012767SJames.Kremer@Sun.COM 
10112767SJames.Kremer@Sun.COM /*
10212767SJames.Kremer@Sun.COM  * Defines for different SCSI cmd paramters
10312767SJames.Kremer@Sun.COM  */
10412767SJames.Kremer@Sun.COM #define	MODE_SELECT10_CMDLEN  10
10512767SJames.Kremer@Sun.COM #define	MODE10_RESP_HDR_LEN   8
10612767SJames.Kremer@Sun.COM #define	MODE_SENSE10_CMDLEN   10
10712767SJames.Kremer@Sun.COM 
10812767SJames.Kremer@Sun.COM 
10912767SJames.Kremer@Sun.COM /*
11012767SJames.Kremer@Sun.COM  * Defines for nvlist entries
11112767SJames.Kremer@Sun.COM  */
11212767SJames.Kremer@Sun.COM #define	ENTRY_PREFIX	"entry"
11312767SJames.Kremer@Sun.COM #define	ENTRY_SEVERITY	"severity"
11412767SJames.Kremer@Sun.COM #define	ENTRY_CODE	"code"
11512767SJames.Kremer@Sun.COM #define	ENTRY_LOG	"log"
11612767SJames.Kremer@Sun.COM 
11712767SJames.Kremer@Sun.COM 
11812767SJames.Kremer@Sun.COM 
11912767SJames.Kremer@Sun.COM /*
12012767SJames.Kremer@Sun.COM  * Genesis specific log clear control struct
12112767SJames.Kremer@Sun.COM  */
12212767SJames.Kremer@Sun.COM struct log_clear_control_struct {
12312767SJames.Kremer@Sun.COM 	unsigned char pageControls;
12412767SJames.Kremer@Sun.COM 	uint8_t subpage_code;
12512767SJames.Kremer@Sun.COM 	uint8_t page_lengthUpper;
12612767SJames.Kremer@Sun.COM 	uint8_t page_lengthLower;
12712767SJames.Kremer@Sun.COM 	uint8_t host_id[16];
12812767SJames.Kremer@Sun.COM 	uint8_t seq_clear[4];
12912767SJames.Kremer@Sun.COM 	uint8_t timeout[2];
13012767SJames.Kremer@Sun.COM };
13112767SJames.Kremer@Sun.COM 
13212767SJames.Kremer@Sun.COM 
13312767SJames.Kremer@Sun.COM 
13412767SJames.Kremer@Sun.COM /*
13512767SJames.Kremer@Sun.COM  * Struct to contain information needed to read logs
13612767SJames.Kremer@Sun.COM  */
137*12843Stodd.mckenney@oracle.com typedef struct ses_log_call_struct {
13812767SJames.Kremer@Sun.COM 	char target_path[MAXPATHLEN]; /* Path to device, passed in */
13912767SJames.Kremer@Sun.COM 	char product_id[MAXNAMELEN]; /* product id of expander, passed in */
14012767SJames.Kremer@Sun.COM 	hrtime_t poll_time; /* nanosecond poll time, passed in */
14112767SJames.Kremer@Sun.COM 	char last_log_entry[MAXNAMELEN]; /* Last entry read, passed in/out */
14212767SJames.Kremer@Sun.COM 	int number_log_entries;  /* num of log entries read, passed back */
14312767SJames.Kremer@Sun.COM 	int size_of_log_entries; /* Total size of all logs read passed back */
14412767SJames.Kremer@Sun.COM 	nvlist_t *log_data;  /* Log data being returned, passed back */
145*12843Stodd.mckenney@oracle.com } ses_log_call_t;
14612767SJames.Kremer@Sun.COM 
14712767SJames.Kremer@Sun.COM /*
14812767SJames.Kremer@Sun.COM  * Basic library functions
14912767SJames.Kremer@Sun.COM  */
15012767SJames.Kremer@Sun.COM extern int access_ses_log(struct ses_log_call_struct *);
15112767SJames.Kremer@Sun.COM 
15212767SJames.Kremer@Sun.COM 
15312767SJames.Kremer@Sun.COM #ifdef	__cplusplus
15412767SJames.Kremer@Sun.COM }
15512767SJames.Kremer@Sun.COM #endif
15612767SJames.Kremer@Sun.COM 
15712767SJames.Kremer@Sun.COM #endif	/* _LIBSESLOG_H */
158