1e4f5a11dSJames Kremer /* 2e4f5a11dSJames Kremer * CDDL HEADER START 3e4f5a11dSJames Kremer * 4e4f5a11dSJames Kremer * The contents of this file are subject to the terms of the 5e4f5a11dSJames Kremer * Common Development and Distribution License (the "License"). 6e4f5a11dSJames Kremer * You may not use this file except in compliance with the License. 7e4f5a11dSJames Kremer * 8e4f5a11dSJames Kremer * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9e4f5a11dSJames Kremer * or http://www.opensolaris.org/os/licensing. 10e4f5a11dSJames Kremer * See the License for the specific language governing permissions 11e4f5a11dSJames Kremer * and limitations under the License. 12e4f5a11dSJames Kremer * 13e4f5a11dSJames Kremer * When distributing Covered Code, include this CDDL HEADER in each 14e4f5a11dSJames Kremer * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15e4f5a11dSJames Kremer * If applicable, add the following below this CDDL HEADER, with the 16e4f5a11dSJames Kremer * fields enclosed by brackets "[]" replaced with your own identifying 17e4f5a11dSJames Kremer * information: Portions Copyright [yyyy] [name of copyright owner] 18e4f5a11dSJames Kremer * 19e4f5a11dSJames Kremer * CDDL HEADER END 20e4f5a11dSJames Kremer */ 21e4f5a11dSJames Kremer /* 22e4f5a11dSJames Kremer * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 23e4f5a11dSJames Kremer */ 24e4f5a11dSJames Kremer 25e4f5a11dSJames Kremer 26e4f5a11dSJames Kremer 27e4f5a11dSJames Kremer #ifndef _LIBSESLOG_H 28e4f5a11dSJames Kremer #define _LIBSESLOG_H 29e4f5a11dSJames Kremer 30e4f5a11dSJames Kremer #include <libnvpair.h> 31e4f5a11dSJames Kremer #include <sys/types.h> 32e4f5a11dSJames Kremer #include <sys/scsi/impl/uscsi.h> 33e4f5a11dSJames Kremer 34e4f5a11dSJames Kremer #ifdef __cplusplus 35e4f5a11dSJames Kremer extern "C" { 36e4f5a11dSJames Kremer #endif 37e4f5a11dSJames Kremer 38e4f5a11dSJames Kremer /* 39e4f5a11dSJames Kremer * Error definitions 40e4f5a11dSJames Kremer */ 41e4f5a11dSJames Kremer 42e4f5a11dSJames Kremer enum { 43*5cf8276bSTodd McKenney SES_LOG_FAILED_TO_OPEN_DEVICE = 1, /* Couldn't open dev path */ 44e4f5a11dSJames Kremer SES_LOG_FAILED_TO_READ_DEVICE, /* Couldn't read the log data */ 45e4f5a11dSJames Kremer SES_LOG_FAILED_NULL_TARGET_PATH, /* Null target path */ 46e4f5a11dSJames Kremer SES_LOG_FAILED_BAD_TARGET_PATH, /* Couldn't find valid target path */ 47e4f5a11dSJames Kremer SES_LOG_FAILED_MODE_SENSE, /* Mode sense error returned */ 48e4f5a11dSJames Kremer SES_LOG_FAILED_MODE_SENSE_OFFSET, /* Offset not correct */ 49e4f5a11dSJames Kremer SES_LOG_FAILED_BAD_DATA_LEN, /* Data length not correct */ 50e4f5a11dSJames Kremer SES_LOG_FAILED_BAD_CONTENT_LEN, /* Content length not correct */ 51*5cf8276bSTodd McKenney SES_LOG_FAILED_FORMAT_PAGE_ERR, /* Device doesn't support page */ 52e4f5a11dSJames Kremer SES_LOG_FAILED_NV_UNIQUE, /* Couldn't add unique to nvlist */ 53e4f5a11dSJames Kremer SES_LOG_FAILED_NV_LOG, /* Couldn't add log to nvlist */ 54e4f5a11dSJames Kremer SES_LOG_FAILED_NV_CODE, /* Couldn't add code to nvlist */ 55e4f5a11dSJames Kremer SES_LOG_FAILED_NV_SEV, /* Couldn't add sev to nvlist */ 56e4f5a11dSJames Kremer SES_LOG_FAILED_NV_ENTRY, /* Couldn't add entry to nvlist */ 57e4f5a11dSJames Kremer SES_LOG_FAILED_MODE_SELECT, /* Mode select failed */ 58e4f5a11dSJames Kremer SES_LOG_FAILED_NVLIST_CREATE /* Couldn't create a nvlist */ 59e4f5a11dSJames Kremer }; 60e4f5a11dSJames Kremer 61e4f5a11dSJames Kremer /* 62e4f5a11dSJames Kremer * define different levels of log entries that could be returned 63e4f5a11dSJames Kremer */ 64e4f5a11dSJames Kremer #define SES_LOG_LEVEL_NOTICE 0 65e4f5a11dSJames Kremer #define SES_LOG_LEVEL_DEBUG 1 66e4f5a11dSJames Kremer #define SES_LOG_LEVEL_WARNING 2 67*5cf8276bSTodd McKenney #define SES_LOG_LEVEL_NO_MASK 3 68*5cf8276bSTodd McKenney #define SES_LOG_LEVEL_ERROR 4 69*5cf8276bSTodd McKenney #define SES_LOG_LEVEL_FATAL 5 70e4f5a11dSJames Kremer 71e4f5a11dSJames Kremer /* Valid size of log entry being returned by expander */ 72e4f5a11dSJames Kremer #define SES_LOG_VALID_LOG_SIZE 71 73*5cf8276bSTodd McKenney 74*5cf8276bSTodd McKenney /* The string log is made from 8 char entries */ 75*5cf8276bSTodd McKenney #define SES_LOG_SPECIFIC_ENTRY_SIZE 8 76*5cf8276bSTodd McKenney 77e4f5a11dSJames Kremer /* Index of where sequence number starts in returned string */ 78e4f5a11dSJames Kremer #define SES_LOG_SEQ_NUM_START 27 79*5cf8276bSTodd McKenney /* Index of where log code starts */ 80*5cf8276bSTodd McKenney #define SES_LOG_CODE_START 36 81e4f5a11dSJames Kremer /* Index of where log level starts in returned string */ 82e4f5a11dSJames Kremer #define SES_LOG_LEVEL_START 40 83e4f5a11dSJames Kremer 84*5cf8276bSTodd McKenney /* Maximum size the each sub log entry can be */ 85*5cf8276bSTodd McKenney #define ENTRY_MAX_SIZE 10 86*5cf8276bSTodd McKenney /* Maximum save buffer log entry size */ 87*5cf8276bSTodd McKenney #define MAX_LOG_ENTRY_SZ 256 88e4f5a11dSJames Kremer 89*5cf8276bSTodd McKenney #define MAX_ALLOC_LEN (0xfffc) 90e4f5a11dSJames Kremer /* 91e4f5a11dSJames Kremer * Sense return buffer length 92e4f5a11dSJames Kremer * Arbitrary, could be larger 93e4f5a11dSJames Kremer */ 94e4f5a11dSJames Kremer #define SENSE_BUFF_LEN 32 95e4f5a11dSJames Kremer /* 96*5cf8276bSTodd McKenney * 60 seconds for SCSI timeout 97e4f5a11dSJames Kremer */ 98e4f5a11dSJames Kremer #define DEF_PT_TIMEOUT 60 99e4f5a11dSJames Kremer 100e4f5a11dSJames Kremer 101e4f5a11dSJames Kremer /* 102e4f5a11dSJames Kremer * Defines for different SCSI cmd paramters 103e4f5a11dSJames Kremer */ 104e4f5a11dSJames Kremer #define MODE_SELECT10_CMDLEN 10 105e4f5a11dSJames Kremer #define MODE10_RESP_HDR_LEN 8 106e4f5a11dSJames Kremer #define MODE_SENSE10_CMDLEN 10 107e4f5a11dSJames Kremer 108e4f5a11dSJames Kremer 109e4f5a11dSJames Kremer /* 110e4f5a11dSJames Kremer * Defines for nvlist entries 111e4f5a11dSJames Kremer */ 112e4f5a11dSJames Kremer #define ENTRY_PREFIX "entry" 113e4f5a11dSJames Kremer #define ENTRY_SEVERITY "severity" 114e4f5a11dSJames Kremer #define ENTRY_CODE "code" 115e4f5a11dSJames Kremer #define ENTRY_LOG "log" 116e4f5a11dSJames Kremer 117e4f5a11dSJames Kremer 118e4f5a11dSJames Kremer 119e4f5a11dSJames Kremer /* 120e4f5a11dSJames Kremer * Genesis specific log clear control struct 121e4f5a11dSJames Kremer */ 122e4f5a11dSJames Kremer struct log_clear_control_struct { 123e4f5a11dSJames Kremer unsigned char pageControls; 124e4f5a11dSJames Kremer uint8_t subpage_code; 125e4f5a11dSJames Kremer uint8_t page_lengthUpper; 126e4f5a11dSJames Kremer uint8_t page_lengthLower; 127e4f5a11dSJames Kremer uint8_t host_id[16]; 128e4f5a11dSJames Kremer uint8_t seq_clear[4]; 129e4f5a11dSJames Kremer uint8_t timeout[2]; 130e4f5a11dSJames Kremer }; 131e4f5a11dSJames Kremer 132e4f5a11dSJames Kremer 133e4f5a11dSJames Kremer 134e4f5a11dSJames Kremer /* 135e4f5a11dSJames Kremer * Struct to contain information needed to read logs 136e4f5a11dSJames Kremer */ 137*5cf8276bSTodd McKenney typedef struct ses_log_call_struct { 138e4f5a11dSJames Kremer char target_path[MAXPATHLEN]; /* Path to device, passed in */ 139e4f5a11dSJames Kremer char product_id[MAXNAMELEN]; /* product id of expander, passed in */ 140e4f5a11dSJames Kremer hrtime_t poll_time; /* nanosecond poll time, passed in */ 141e4f5a11dSJames Kremer char last_log_entry[MAXNAMELEN]; /* Last entry read, passed in/out */ 142e4f5a11dSJames Kremer int number_log_entries; /* num of log entries read, passed back */ 143e4f5a11dSJames Kremer int size_of_log_entries; /* Total size of all logs read passed back */ 144e4f5a11dSJames Kremer nvlist_t *log_data; /* Log data being returned, passed back */ 145*5cf8276bSTodd McKenney } ses_log_call_t; 146e4f5a11dSJames Kremer 147e4f5a11dSJames Kremer /* 148e4f5a11dSJames Kremer * Basic library functions 149e4f5a11dSJames Kremer */ 150e4f5a11dSJames Kremer extern int access_ses_log(struct ses_log_call_struct *); 151e4f5a11dSJames Kremer 152e4f5a11dSJames Kremer 153e4f5a11dSJames Kremer #ifdef __cplusplus 154e4f5a11dSJames Kremer } 155e4f5a11dSJames Kremer #endif 156e4f5a11dSJames Kremer 157e4f5a11dSJames Kremer #endif /* _LIBSESLOG_H */ 158