2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License (the "License").
2N/A * You may not use this file except in compliance with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A */
2N/A/*
2N/A * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
2N/A */
2N/A
2N/A
2N/A
2N/A#ifndef _LIBSESLOG_H
2N/A#define _LIBSESLOG_H
2N/A
2N/A#include <libnvpair.h>
2N/A#include <sys/types.h>
2N/A#include <sys/scsi/impl/uscsi.h>
2N/A#include <sys/uuid.h>
2N/A
2N/A#ifdef __cplusplus
2N/Aextern "C" {
2N/A#endif
2N/A
2N/A/*
2N/A * Error definitions
2N/A */
2N/A
2N/Aenum {
2N/A SES_LOG_FAILED_TO_OPEN_DEVICE = 1, /* Couldn't open dev path */
2N/A SES_LOG_FAILED_TO_READ_DEVICE, /* Couldn't read the log data */
2N/A SES_LOG_FAILED_NULL_TARGET_PATH, /* Null target path */
2N/A SES_LOG_FAILED_BAD_TARGET_PATH, /* Couldn't find valid target path */
2N/A SES_LOG_FAILED_MODE_SENSE, /* Mode sense error returned */
2N/A SES_LOG_FAILED_MODE_SENSE_OFFSET, /* Offset not correct */
2N/A SES_LOG_FAILED_BAD_DATA_LEN, /* Data length not correct */
2N/A SES_LOG_FAILED_BAD_CONTENT_LEN, /* Content length not correct */
2N/A SES_LOG_FAILED_FORMAT_PAGE_ERR, /* Device doesn't support page */
2N/A SES_LOG_FAILED_NV_UNIQUE, /* Couldn't add unique to nvlist */
2N/A SES_LOG_FAILED_NV_LOG, /* Couldn't add log to nvlist */
2N/A SES_LOG_FAILED_NV_CODE, /* Couldn't add code to nvlist */
2N/A SES_LOG_FAILED_NV_SEV, /* Couldn't add sev to nvlist */
2N/A SES_LOG_FAILED_NV_ENTRY, /* Couldn't add entry to nvlist */
2N/A SES_LOG_FAILED_MODE_SELECT, /* Mode select failed */
2N/A SES_LOG_FAILED_NVLIST_CREATE /* Couldn't create a nvlist */
2N/A};
2N/A
2N/A/*
2N/A * define different levels of log entries that could be returned
2N/A */
2N/A#define SES_LOG_LEVEL_NOTICE 0
2N/A#define SES_LOG_LEVEL_DEBUG 1
2N/A#define SES_LOG_LEVEL_WARNING 2
2N/A#define SES_LOG_LEVEL_NO_MASK 3
2N/A#define SES_LOG_LEVEL_ERROR 4
2N/A#define SES_LOG_LEVEL_FATAL 5
2N/A
2N/A/* Valid size of log entry being returned by expander */
2N/A#define SES_LOG_VALID_LOG_SIZE 71
2N/A
2N/A/* The string log is made from 8 char entries */
2N/A#define SES_LOG_SPECIFIC_ENTRY_SIZE 8
2N/A
2N/A/* Index of where sequence number starts in returned string */
2N/A#define SES_LOG_SEQ_NUM_START 27
2N/A/* Index of where log code starts */
2N/A#define SES_LOG_CODE_START 36
2N/A/* Index of where log level starts in returned string */
2N/A#define SES_LOG_LEVEL_START 40
2N/A
2N/A/* Maximum size the each sub log entry can be */
2N/A#define ENTRY_MAX_SIZE 10
2N/A/* Maximum save buffer log entry size */
2N/A#define MAX_LOG_ENTRY_SZ 256
2N/A
2N/A#define MAX_ALLOC_LEN (0xfffc)
2N/A/*
2N/A * Sense return buffer length
2N/A * Arbitrary, could be larger
2N/A */
2N/A#define SENSE_BUFF_LEN 32
2N/A/*
2N/A * 60 seconds for SCSI timeout
2N/A */
2N/A#define DEF_PT_TIMEOUT 60
2N/A
2N/A
2N/A/*
2N/A * Defines for different SCSI cmd paramters
2N/A */
2N/A#define MODE_SELECT10_CMDLEN 10
2N/A#define MODE10_RESP_HDR_LEN 8
2N/A#define MODE_SENSE10_CMDLEN 10
2N/A
2N/A
2N/A/*
2N/A * Defines for nvlist entries
2N/A */
2N/A#define ENTRY_PREFIX "entry"
2N/A#define ENTRY_SEVERITY "severity"
2N/A#define ENTRY_CODE "code"
2N/A#define ENTRY_LOG "log"
2N/A
2N/A
2N/A
2N/A/*
2N/A * Genesis specific log clear control struct
2N/A */
2N/Astruct log_clear_control_struct {
2N/A unsigned char pageControls;
2N/A uint8_t subpage_code;
2N/A uint8_t page_lengthUpper;
2N/A uint8_t page_lengthLower;
2N/A uint8_t host_id[UUID_LEN];
2N/A uint8_t seq_clear[4];
2N/A uint8_t timeout[2];
2N/A};
2N/A
2N/A
2N/A
2N/A/*
2N/A * Struct to contain information needed to read logs
2N/A */
2N/Atypedef struct ses_log_call_struct {
2N/A char target_path[MAXPATHLEN]; /* Path to device, passed in */
2N/A char product_id[MAXNAMELEN]; /* product id of expander, passed in */
2N/A hrtime_t poll_time; /* nanosecond poll time, passed in */
2N/A char last_log_entry[MAXNAMELEN]; /* Last entry read, passed in/out */
2N/A int number_log_entries; /* num of log entries read, passed back */
2N/A int size_of_log_entries; /* Total size of all logs read passed back */
2N/A nvlist_t *log_data; /* Log data being returned, passed back */
2N/A} ses_log_call_t;
2N/A
2N/A/*
2N/A * Basic library functions
2N/A */
2N/Aextern int access_ses_log(struct ses_log_call_struct *);
2N/A
2N/A
2N/A#ifdef __cplusplus
2N/A}
2N/A#endif
2N/A
2N/A#endif /* _LIBSESLOG_H */