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.
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.
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]
22 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
30 #include <libnvpair.h>
31 #include <sys/types.h>
32 #include <sys/scsi/impl/uscsi.h>
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 */
62 * define different levels of log entries that could be returned
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
71 /* Valid size of log entry being returned by expander */
72 #define SES_LOG_VALID_LOG_SIZE 71
74 /* The string log is made from 8 char entries */
75 #define SES_LOG_SPECIFIC_ENTRY_SIZE 8
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
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
89 #define MAX_ALLOC_LEN (0xfffc)
91 * Sense return buffer length
92 * Arbitrary, could be larger
94 #define SENSE_BUFF_LEN 32
96 * 60 seconds for SCSI timeout
98 #define DEF_PT_TIMEOUT 60
102 * Defines for different SCSI cmd paramters
104 #define MODE_SELECT10_CMDLEN 10
105 #define MODE10_RESP_HDR_LEN 8
106 #define MODE_SENSE10_CMDLEN 10
110 * Defines for nvlist entries
112 #define ENTRY_PREFIX "entry"
113 #define ENTRY_SEVERITY "severity"
114 #define ENTRY_CODE "code"
115 #define ENTRY_LOG "log"
120 * Genesis specific log clear control struct
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
;
128 uint8_t seq_clear
[4];
135 * Struct to contain information needed to read logs
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 */
148 * Basic library functions
150 extern int access_ses_log(struct ses_log_call_struct
*);
157 #endif /* _LIBSESLOG_H */