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 log event type starts */ 78 #define SES_LOG_EVENT_TYPE_START 4 79 /* Index of where sequence number starts in returned string */ 80 #define SES_LOG_SEQ_NUM_START 27 81 /* Index of where log code starts */ 82 #define SES_LOG_CODE_START 36 83 /* Index of where log level starts in returned string */ 84 #define SES_LOG_LEVEL_START 40 85 86 /* Maximum size the each sub log entry can be */ 87 #define ENTRY_MAX_SIZE 10 88 /* Maximum save buffer log entry size */ 89 #define MAX_LOG_ENTRY_SZ 256 90 91 #define MAX_ALLOC_LEN (0xfffc) 92 /* 93 * Sense return buffer length 94 * Arbitrary, could be larger 95 */ 96 #define SENSE_BUFF_LEN 32 97 /* 98 * 60 seconds for SCSI timeout 99 */ 100 #define DEF_PT_TIMEOUT 60 101 102 103 /* 104 * Defines for different SCSI cmd paramters 105 */ 106 #define MODE_SELECT10_CMDLEN 10 107 #define MODE10_RESP_HDR_LEN 8 108 #define MODE_SENSE10_CMDLEN 10 109 110 111 /* 112 * Defines for nvlist entries 113 */ 114 #define ENTRY_PREFIX "entry" 115 #define ENTRY_SEVERITY "severity" 116 #define ENTRY_CODE "code" 117 #define ENTRY_LOG "log" 118 119 120 121 /* 122 * Genesis specific log clear control struct 123 */ 124 struct log_clear_control_struct { 125 unsigned char pageControls; 126 uint8_t subpage_code; 127 uint8_t page_lengthUpper; 128 uint8_t page_lengthLower; 129 uint8_t host_id[16]; 130 uint8_t seq_clear[4]; 131 uint8_t timeout[2]; 132 }; 133 134 135 136 /* 137 * Struct to contain information needed to read logs 138 */ 139 typedef struct ses_log_call_struct { 140 char target_path[MAXPATHLEN]; /* Path to device, passed in */ 141 char product_id[MAXNAMELEN]; /* product id of expander, passed in */ 142 hrtime_t poll_time; /* nanosecond poll time, passed in */ 143 char last_log_entry[MAXNAMELEN]; /* Last entry read, passed in/out */ 144 int number_log_entries; /* num of log entries read, passed back */ 145 int size_of_log_entries; /* Total size of all logs read passed back */ 146 nvlist_t *log_data; /* Log data being returned, passed back */ 147 } ses_log_call_t; 148 149 /* 150 * Basic library functions 151 */ 152 extern int access_ses_log(struct ses_log_call_struct *); 153 154 155 #ifdef __cplusplus 156 } 157 #endif 158 159 #endif /* _LIBSESLOG_H */ 160