/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
*/
#ifndef _disklog_H
#define _disklog_H
#ifdef __cplusplus
extern "c" {
#endif
#include <stdio.h>
#include <sys/types.h>
#include <scsi/libscsi.h>
#include <sys/scsi/impl/spc3_types.h>
#define DL_ROOT "/"
#define DL_SD_DRIVER "sd"
#define DL_SSD_DRIVER "ssd"
#define DL_DEVICES "/devices"
#define DL_DEV "/dev"
#define DL_DISKWD ":wd,raw"
#define DL_DISKS2 ":c,raw"
#define DL_FILENAME_SUF ".disklog"
#define DL_SEAGATE "SEAGATE"
#define DL_HITACHI "HITACHI"
#define DL_FILEMODE "w"
#define DL_DIRMODE 0755
#define DL_SUCCESS 0
#define DL_FAILURE 1
#define DL_INQ_DATALEN 0xff
#define DL_PAGELEN 0xff
#define DL_DATALEN 0xffff
#define DL_THREADS_NUM 50
#define DL_HITACHI_LOGDUMP_OFFSET 0
#define DL_HITACHI_LOGDUMP_OFFSET_INC 0xffff
#define DL_HITACHI_LOGDUMP_DATALEN 0xffff
#define DL_HITACHI_LOGDUMP_LOGNAME_SUF ".hitachi.dumplog"
#define DL_SEAGATE_LOGDUMP_FIXED 0xfe
#define DL_SEAGATE_LOGDUMP_OFFSET 0
#define DL_SEAGATE_LOGDUMP_OFFSET_INC 0x200
#define DL_SEAGATE_LOGDUMP_XFER_MSB 0x200
#define DL_SEAGATE_LOGDUMP_DATALEN 0x80000
#define DL_SEAGATE_LOGDUMP_LOGNAME_SUF ".seagate.dumplog"
#define DL_DEFAULT_SAS_PHY_LOG_DESC_LEN 48
#define DL_BACK_SCAN_PROGRESS_PERCENT(i) (double)(i * 100.0 / 65536.0)
#define SPC3_CMD_HITACHI_LOG_DUMP SPC3_CMD_VENDOR_E6
#define SPC3_CMD_SEAGATE_LOG_DUMP SPC3_CMD_VENDOR_F7
#pragma pack(1)
typedef enum dl_log_page_code {
DL_LOG_PC_BACK_SCAN = 0x15,
DL_LOG_PC_SEAGATE_CACHE = 0x37,
DL_LOG_PC_SEAGATE_FACTORY = 0x3e
} dl_log_page_code_t;
typedef enum dl_log_param_code {
DL_LOG_PC_ERR_HITACHI_TR = 0x8009,
DL_LOG_PC_ERR_HITACHI_POS = 0x8015,
DL_LOG_PC_BACK_SCAN_STATUS = 0,
DL_LOG_PC_BACK_SCAN_END = 0X800,
DL_LOG_PC_SEAGATE_CACHE_BLKSENT = 0x0,
DL_LOG_PC_SEAGATE_CACHE_BLKRECV = 0x1,
DL_LOG_PC_SEAGATE_CACHE_BLKREAD = 0x2,
DL_LOG_PC_SEAGATE_CACHE_SMALLSZ = 0x3,
DL_LOG_PC_SEAGATE_CACHE_BIGSZ = 0x4,
DL_LOG_PC_SEAGATE_FACTORY_HOURS = 0x0,
DL_LOG_PC_SEAGATE_FACTORY_MINUTES = 0x8
} dl_log_param_code_t;
typedef enum dl_mode_sub_page_code {
DL_MODE_SPC_NONE = 0x0,
DL_MODE_SPC_SPECIAL = 0xffff
} dl_mode_sub_page_code_t;
typedef enum dl_log_params_back_scan_status_code {
DL_LPBS_SC_NONE = 0x0,
DL_LPBS_SC_MEDIUM = 0x1,
DL_LPBS_SC_PRESCAN = 0x2,
DL_LPBS_SC_FATAL = 0x3,
DL_LPBS_SC_VENDOR_ERR = 0x4,
DL_LPBS_SC_NO_PLIST = 0x5,
DL_LPBS_SC_VENDOR_CAUSE = 0x6,
DL_LPBS_SC_HIGH_TEMP = 0x7,
DL_LPBS_SC_INACTIVE = 0x8
} dl_log_params_back_scan_status_code_t;
typedef struct dl_log_params_back_scan_status {
spc3_log_params_header_t lpbss_prh;
uint8_t lpbss_apom[4];
uint8_t _reserved1;
uint8_t lpbss_status;
uint16_t lpbss_number_of_bsp;
uint16_t lpbss_progress;
uint16_t lpbss_number_of_bmsp;
} dl_log_params_back_scan_status_t;
typedef struct dl_log_params_medium_scan {
spc3_log_params_header_t lpms_prh;
uint8_t lpms_apom[4];
DECL_BITFIELD2(
lpms_sense_key :4,
lpms_reassign_status :4);
uint8_t lpms_asc;
uint8_t lpms_ascq;
char lpms_vendor[5];
uint8_t lpms_lba[8];
} dl_log_params_medium_scan_t;
typedef enum dl_log_protocol_port_id {
DL_LOG_PP_ID_SAS = 0x06
} dl_log_protocol_port_id_t;
typedef struct dl_log_params_protocol_port_header {
spc3_log_params_header_t lppph_prh;
DECL_BITFIELD2(
lppph_id :4,
_reserved1 :4);
uint8_t _reserved2;
uint8_t lppph_generation_code;
uint8_t lppph_number_of_phys;
} dl_log_params_protocol_port_header_t;
typedef enum dl_log_protocol_dev_type {
DL_LOG_PD_TYPE_NONE = 0,
DL_LOG_PD_TYPE_END_DEV = 1,
DL_LOG_PD_TYPE_EXPANDER = 2,
DL_LOG_PD_TYPE_EXPANDER_COMPLIANT = 3
} dl_log_params_protocol_dev_type_t;
typedef enum dl_log_protocol_reason {
DL_LOG_P_REASON_UNKOWN = 0,
DL_LOG_P_REASON_POWERON = 1,
DL_LOG_P_REASON_HARDRESET = 2,
DL_LOG_P_REASON_SMP = 3,
DL_LOG_P_REASON_LOSS_OF_DWORD = 4,
DL_LOG_P_REASON_MUX = 5,
DL_LOG_P_REASON_IT = 6,
DL_LOG_P_REASON_TIMEOUT = 7,
DL_LOG_P_REASON_STOP = 8,
DL_LOG_P_REASON_EXP = 9
} dl_log_protocol_reason_t;
typedef enum dl_log_protocol_link_rate {
DL_LOG_PL_RATE_UNKOWN = 0,
DL_LOG_PL_RATE_DISABLED = 1,
DL_LOG_PL_RATE_PHY_RESET = 2,
DL_LOG_PL_RATE_SPINUP_HOLD = 3,
DL_LOG_PL_RATE_PORT_SELECTOR = 4,
DL_LOG_PL_RATE_RESET = 5,
DL_LOG_PL_RATE_UNSUPPORTED_PHY = 6,
DL_LOG_PL_RESERVED = 7,
DL_LOG_PL_RATE_G1 = 8,
DL_LOG_PL_RATE_G2 = 9,
DL_LOG_PL_RATE_G3 = 0xa
} dl_log_protocol_link_rate_t;
/*
* SAS-2 10.2.8.1 Table 232 SAS phy log descriptor
*/
typedef struct dl_log_params_protocol_spld_header {
uint8_t _reserved1;
uint8_t lppsh_phy_id;
uint8_t _reserved2;
uint8_t lppsh_spld_len;
DECL_BITFIELD3(
lppsh_attached_reason :4,
lppsh_attached_dev_type :3,
_reserved3 :1);
DECL_BITFIELD2(
lppsh_link_rate :4,
lppsh_reason :4);
DECL_BITFIELD5(
_reserved4 :1,
lppsh_attached_smpi :1,
lppsh_attached_stpi :1,
lppsh_attached_sspi :1,
_reserved5 :4);
DECL_BITFIELD5(
_reserved6 :1,
lppsh_attached_smpt :1,
lppsh_attached_stpt :1,
lppsh_attached_sspt :1,
_reserved7 :4);
uint8_t lppsh_sas_addr[8];
uint8_t lppsh_attached_sas_addr[8];
uint8_t lppsh_attached_phy_id;
uint8_t _reserved8[7];
uint32_t lppsh_invalid_dword_cnt;
uint32_t lppsh_disparity_err_cnt;
uint32_t lppsh_loss_of_dword_sync;
uint32_t lppsh_phy_reset_problem;
uint8_t _reserved9[2];
uint8_t lppsh_phy_event_descriptor_len;
uint8_t lppsh_number_of_phy_event;
} dl_log_params_protocol_spld_header_t;
typedef enum dl_log_protocol_phy_event_name {
DL_LOG_PPEN_NO_EVENT = 0,
DL_LOG_PPEN_INVALID_DWORD_CNT = 1,
DL_LOG_PPEN_DISPARITY_ERR_CNT = 2,
DL_LOG_PPEN_LOSS_OF_DWORD = 3,
DL_LOG_PPEN_PHY_RESET_CNT = 4,
DL_LOG_PPEN_BUF_OVERFLOW_CNT = 5,
DL_LOG_PPEN_RECEIVED_ERR_CNT = 6,
DL_LOG_PPEN_ADDR_ERR_CNT = 0x20,
DL_LOG_PPEN_TRANSMITTED_ABANDON_CNT = 0x21,
DL_LOG_PPEN_RECEIVED_ABANDON_CNT = 0x22,
DL_LOG_PPEN_TRANSMITTED_RETRY_CNT = 0x23,
DL_LOG_PPEN_RECEIVED_RETRY_CNT = 0x24,
DL_LOG_PPEN_RECEIVED_AIP_PART_CNT = 0x25,
DL_LOG_PPEN_RECEIVED_AIP_CONN_CNT = 0x26,
DL_LOG_PPEN_TRANSMITTED_BREAK_CNT = 0x27,
DL_LOG_PPEN_RECEIVED_BREAK_CNT = 0x28,
DL_LOG_PPEN_BREAK_TIMEOUT_CNT = 0x29,
DL_LOG_PPEN_CONN_CNT = 0x2a,
DL_LOG_PPEN_PEAK_BLOCKED_CNT = 0x2b,
DL_LOG_PPEN_PEAK_WAIT_TIME = 0x2c,
DL_LOG_PPEN_PEAK_ARBI_TIME = 0x2d,
DL_LOG_PPEN_PEAK_CONN_TIME = 0x2e,
DL_LOG_PPEN_TRANSMITTED_SSP_CNT = 0x40,
DL_LOG_PPEN_RECEIVED_SSP_CNT = 0x41,
DL_LOG_PPEN_TRANSMITTED_SSP_ERR_CNT = 0x42,
DL_LOG_PPEN_RECEIVED_SSP_ERR_CNT = 0x43,
DL_LOG_PPEN_TRANSMITTED_CB_CNT = 0x44,
DL_LOG_PPEN_RECEIVED_CB_CNT = 0x45,
DL_LOG_PPEN_TRANSMITTED_SATA_CNT = 0x50,
DL_LOG_PPEN_RECEIVED_SATA_CNT = 0x51,
DL_LOG_PPEN_SATA_BUF_CNT = 0x52,
DL_LOG_PPEN_TRANSMITTED_SMP_CNT = 0x60,
DL_LOG_PPEN_RECEIVED_SMP_CNT = 0x61,
DL_LOG_PPEN_RECEIVED_SMP_ERR_CNT = 0x63
} dl_log_protocol_phy_event_name_t;
/*
* SAS-2 10.4.3.14.4 Table 297 Phy event descriptor
*/
typedef struct dl_log_params_protocol_ped {
uint8_t reserved1[3];
uint8_t lppp_phy_event_source;
uint32_t lppp_phy_event;
uint32_t lppp_peak_val;
} dl_log_params_protocol_ped_t;
/* HITACHI Log Dump Command(E6) */
typedef struct dl_hitachi_logdump_cdb {
uint8_t hlc_opcode;
uint8_t _reserved1;
DECL_BITFIELD2(
hlc_mode :4,
_reserved2 :4);
uint8_t hlc_offset[3];
uint8_t hlc_allocation_length[3];
DECL_BITFIELD4(
hlc_link :1,
hlc_flag :1,
_reserved3 :4,
hlc_vu :2);
} dl_hitachi_logdump_cdb_t;
/* SEAGATE Log Dump Command(F7) */
typedef struct dl_seagate_logdump_cdb {
uint8_t slc_opcode;
DECL_BITFIELD5(
_reserved1 :1,
slc_clear :1,
slc_dump :1,
slc_read :1,
_reserved2 :4);
uint8_t _reserved3[2];
uint16_t slc_start_offset;
uint8_t slc_fixed;
uint16_t slc_xfer_length;
uint8_t _reserved4;
} dl_seagate_logdump_cdb_t;
#pragma pack()
#ifdef __cplusplus
}
#endif
#endif /* _disklog_H */