#ifndef _DEV_SCSIPI_SCSI_SPC_H_
#define _DEV_SCSIPI_SCSI_SPC_H_
#define SCSI_MODE_SELECT_6 0x15
struct scsi_mode_select_6 {
uint8_t opcode;
uint8_t byte2;
#define SMS_SP 0x01
#define SMS_PF 0x10
uint8_t reserved[2];
uint8_t length;
uint8_t control;
};
#define SCSI_MODE_SELECT_10 0x55
struct scsi_mode_select_10 {
uint8_t opcode;
uint8_t byte2;
uint8_t reserved[5];
uint8_t length[2];
uint8_t control;
};
#define SCSI_MODE_SENSE_6 0x1a
struct scsi_mode_sense_6 {
uint8_t opcode;
uint8_t byte2;
#define SMS_DBD 0x08
uint8_t page;
#define SMS_PAGE_MASK 0x3f
#define SMS_PCTRL_MASK 0xc0
#define SMS_PCTRL_CURRENT 0x00
#define SMS_PCTRL_CHANGEABLE 0x40
#define SMS_PCTRL_DEFAULT 0x80
#define SMS_PCTRL_SAVED 0xc0
uint8_t reserved;
uint8_t length;
uint8_t control;
};
#define SCSI_MODE_SENSE_10 0x5a
struct scsi_mode_sense_10 {
uint8_t opcode;
uint8_t byte2;
#define SMS_LLBAA 0x10
uint8_t page;
uint8_t reserved[4];
uint8_t length[2];
uint8_t control;
};
#define SMS_PAGE_ALL_PAGES 0x3f
struct scsi_mode_parameter_header_6 {
uint8_t data_length;
uint8_t medium_type;
uint8_t dev_spec;
uint8_t blk_desc_len;
};
struct scsi_mode_parameter_header_10 {
uint8_t data_length[2];
uint8_t medium_type;
uint8_t dev_spec;
uint8_t byte5;
#define SMPH_LONGLBA 0x01
uint8_t reserved;
uint8_t blk_desc_len[2];
};
struct scsi_general_block_descriptor {
uint8_t density;
uint8_t nblocks[3];
uint8_t reserved;
uint8_t blklen[3];
};
struct scsi_da_block_descriptor {
uint8_t nblocks[4];
uint8_t density;
uint8_t blklen[3];
};
struct scsi_longlba_block_descriptor {
uint8_t nblocks[8];
uint8_t density;
uint8_t reserved[3];
uint8_t blklen[4];
};
struct scsi_mode_page_header {
uint8_t pg_code;
#define PGCODE_MASK 0x3f
#define PGCODE_PS 0x80
uint8_t pg_length;
};
#define SCSI_CONTROL_MODE_PAGE 0x0a
struct scsi_control_mode_page {
uint8_t pg_code;
uint8_t pg_length;
uint8_t byte3;
#define SCMP_RLEC 0x01
#define SCMP_GLTSD 0x02
#define SCMP_TST_mask 0x7
#define SCMP_TST_shift 5
#define SCMP_TST_ALL_INIT 0
#define SCMP_TST_PER_INIT 1
uint8_t queue_params;
#define SCMP_DQue 0x01
#define SCMP_QErr_mask 0x3
#define SCMP_QErr_shift 1
#define SCMP_QAM_mask 0xf
#define SCMP_QAM_shift 4
#define SCMP_QAM_RESTRICTED 0x0
#define SCMP_QAM_UNRESTRICTED 0x1
uint8_t byte5;
#define SCMP_EAERP 0x01
#define SCMP_UAAERP 0x02
#define SCMP_RAERP 0x04
#define SCMP_SWP 0x08
#define SCMP_RAC 0x40
#define SCMP_TAS 0x80
uint8_t byte6;
#define SCMP_AM_mask 0x7
#define SCMP_AM_FULL 0
#define SCMP_AM_AUXMEM 1
#define SCMP_AM_NOLOAD 2
uint8_t rahp[2];
uint8_t btp[2];
uint8_t estct[2];
};
#define SCSI_DISCONNECT_RECONNECT_PAGE 0x02
struct scsi_disconnect_reconnect_page {
uint8_t pg_code;
uint8_t pg_length;
uint8_t buffer_full_ratio;
uint8_t buffer_empty_ratio;
uint8_t bus_inactivity_limit[2];
uint8_t disconnect_time_limit[2];
uint8_t connect_time_limit[2];
uint8_t maximum_burst_size[2];
uint8_t flags;
#define SDRP_DTDC_mask 0x7
#define SDRP_DImm 0x08
#define SDRP_FA_mask 0x7
#define SDRP_FA_shift 4
#define SDRP_EMDP 0x80
uint8_t reserved;
uint8_t first_burst_size[2];
};
#define SCSI_INFORMATIONAL_EXCEPTIONS_CONTROL_PAGE 0x1c
struct scsi_informational_exceptions_control_page {
uint8_t pg_code;
uint8_t pg_length;
uint8_t byte3;
#define SIECP_LogErr 0x01
#define SIECP_TEST 0x04
#define SIECP_DExcpt 0x08
#define SIECP_EWasc 0x10
#define SIECP_EBF 0x20
#define SIECP_PERF 0x80
uint8_t byte4;
#define SIECP_MRIE_mask 0xf
#define SIECP_MRIE_NO_REPORTING 0x00
#define SIECP_MRIE_ASYNC_EVENT 0x01
#define SIECP_MRIE_UNIT_ATN 0x02
#define SIECP_MRIE_COND_RECOV_ERR 0x03
#define SIECP_MRIE_UNCOND_RECOV_ERR 0x04
#define SIECP_MRIE_NO_SENSE 0x05
#define SIECP_MRIE_ON_REQUEST 0x06
uint8_t interval_timer[2];
uint8_t report_count[2];
};
#define SCSI_POWER_CONDITION_PAGE 0x1a
struct scsi_power_condition_page {
uint8_t pg_code;
uint8_t pg_length;
uint8_t reserved;
uint8_t byte4;
#define SPCP_STANDBY 0x01
#define SPCP_IDLE 0x02
uint8_t idle_timer[2];
uint8_t standby_timer[2];
};
#define SCSI_PROTOCOL_SPECIFIC_LUN_PAGE 0x18
struct scsi_protocol_specific_lun_page {
uint8_t pg_code;
uint8_t pg_length;
uint8_t byte3;
#define SPSLP_PROTOCOL_mask 0xf
#define SPSLP_PROTOCOL_FCP 0x00
#define SPSLP_PROTOCOL_SPI 0x01
#define SPSLP_PROTOCOL_SSA 0x02
#define SPSLP_PROTOCOL_SBP2 0x03
#define SPSLP_PROTOCOL_SRP 0x04
#define SPSLP_PROTOCOL_ISCSI 0x05
};
#define SCSI_PROTOCOL_SPECIFIC_PORT_PAGE 0x19
struct scsi_protocol_specific_port_page {
uint8_t pg_code;
uint8_t pg_length;
uint8_t byte3;
};
#define SCSI_PREVENT_ALLOW_MEDIUM_REMOVAL 0x1e
struct scsi_prevent_allow_medium_removal {
uint8_t opcode;
uint8_t byte2;
uint8_t reserved[2];
uint8_t how;
#define SPAMR_ALLOW 0x00
#define SPAMR_PREVENT_DT 0x01
#define SPAMR_PREVENT_MC 0x02
#define SPAMR_PREVENT_ALL 0x03
uint8_t control;
};
#define SCSI_RESERVE_6 0x16
#define SCSI_RELEASE_6 0x17
struct scsi_reserve_release_6 {
uint8_t opcode;
uint8_t byte2;
uint8_t obsolete;
uint8_t reserved[2];
uint8_t control;
};
#define SCSI_RESERVE_10 0x56
#define SCSI_RELEASE_10 0x57
struct scsi_reserve_release_10 {
uint8_t opcode;
uint8_t byte2;
#define SR_LongID 0x02
#define SR_3rdPty 0x10
uint8_t obsolete;
uint8_t thirdpartyid;
uint8_t reserved[3];
uint8_t paramlen[2];
uint8_t control;
};
struct scsi_reserve_release_10_idparam {
uint8_t thirdpartyid[8];
};
#define SCSI_REPORT_LUNS 0xa0
struct scsi_report_luns {
uint8_t opcode;
uint8_t reserved1;
uint8_t selectreport;
#define SELECTREPORT_NORMAL 0x00
#define SELECTREPORT_WELLKNOWN 0x01
#define SELECTREPORT_ALL 0x02
uint8_t reserved3[3];
uint8_t alloclen[4];
uint8_t reserved10;
uint8_t control;
};
struct scsi_report_luns_header {
uint8_t length[4];
uint8_t _res4[4];
};
struct scsi_report_luns_lun {
uint8_t lun[8];
};
#define SCSI_MAINTENANCE_IN 0xA3
struct scsi_repsuppopcode {
u_int8_t opcode;
u_int8_t svcaction;
#define RSOC_REPORT_SUPPORTED_OPCODES 0x0C
u_int8_t repoption;
#define RSOC_ALL 0x00
#define RSOC_ONE 0x01
#define RSOC_ONESACD 0x02
#define RSOC_ONESA 0x03
#define RSOC_RCTD 0x80
u_int8_t reqopcode;
u_int8_t reqsvcaction[2];
u_int8_t alloclen[4];
u_int8_t _res0;
u_int8_t control;
};
struct scsi_repsupopcode_all_commands_descriptor {
u_int8_t opcode;
u_int8_t _res0;
u_int8_t serviceaction[2];
u_int8_t _res1;
u_int8_t flags;
#define RSOC_ACD_CTDP 0x02
#define RSOC_ACD_SERVACTV 0x01
u_int8_t cdblen[2];
};
struct scsi_repsupopcode_one_command_descriptor {
u_int8_t _res0;
u_int8_t support;
#define RSOC_OCD_CTDP 0x80
#define RSOC_OCD_SUP_NOT_AVAIL 0x00
#define RSOC_OCD_SUP_NOT_SUPP 0x01
#define RSOC_OCD_SUP_SUPP_STD 0x03
#define RSOC_OCD_SUP_SUPP_VENDOR 0x05
#define RSOC_OCD_SUP 0x07
u_int8_t cdblen[2];
};
struct scsi_repsupopcode_timeouts_descriptor {
u_int8_t descriptor_length[2];
u_int8_t _res0;
u_int8_t cmd_specific;
u_int8_t nom_process_timeout[4];
u_int8_t cmd_process_timeout[4];
};
#define SCSI_REQUEST_SENSE 0x03
struct scsi_request_sense {
uint8_t opcode;
uint8_t byte2;
uint8_t reserved[2];
uint8_t length;
uint8_t control;
};
struct scsi_sense_data {
uint8_t response_code;
#define SSD_RCODE(x) ((x) & 0x7f)
#define SSD_RCODE_CURRENT 0x70
#define SSD_RCODE_DEFERRED 0x71
#define SSD_RCODE_VALID 0x80
uint8_t segment;
uint8_t flags;
#define SSD_SENSE_KEY(x) ((x) & 0x0f)
#define SSD_ILI 0x20
#define SSD_EOM 0x40
#define SSD_FILEMARK 0x80
uint8_t info[4];
uint8_t extra_len;
uint8_t csi[4];
uint8_t asc;
uint8_t ascq;
uint8_t fru;
union {
uint8_t sks_bytes[3];
struct {
uint8_t byte0;
#define SSD_SKS_FP_BIT(x) ((x) & 0x7)
#define SSD_SKS_FP_BPV 0x08
#define SSK_SKS_FP_CD 0x40
uint8_t val[2];
} field_pointer;
struct {
uint8_t byte0;
uint8_t val[2];
} actual_retry_count;
struct {
uint8_t byte0;
uint8_t val[2];
} progress_indication;
struct {
uint8_t byte0;
#define SSD_SKS_SP_BIT(x) ((x) & 0x7)
#define SSD_SKS_SP_BPV 0x08
#define SSD_SKS_SP_SD 0x20
uint8_t val[2];
} segment_pointer;
} sks;
#define SSD_SKSV 0x80
uint8_t extra_bytes[14];
};
#define SSD_ADD_BYTES_LIM(sp) \
((((int)(sp)->extra_len) < (int)sizeof(struct scsi_sense_data) - 8) ? \
(sp)->extra_len : sizeof(struct scsi_sense_data) - 8)
#define SKEY_NO_SENSE 0x00
#define SKEY_RECOVERED_ERROR 0x01
#define SKEY_NOT_READY 0x02
#define SKEY_MEDIUM_ERROR 0x03
#define SKEY_HARDWARE_ERROR 0x04
#define SKEY_ILLEGAL_REQUEST 0x05
#define SKEY_UNIT_ATTENTION 0x06
#define SKEY_DATA_PROTECT 0x07
#define SKEY_BLANK_CHECK 0x08
#define SKEY_VENDOR_SPECIFIC 0x09
#define SKEY_COPY_ABORTED 0x0a
#define SKEY_ABORTED_COMMAND 0x0b
#define SKEY_EQUAL 0x0c
#define SKEY_VOLUME_OVERFLOW 0x0d
#define SKEY_MISCOMPARE 0x0e
struct scsi_sense_data_unextended {
uint8_t response_code;
uint8_t block[3];
};
#define SCSI_SEND_DIAGNOSTIC 0x1d
struct scsi_send_diagnostic {
uint8_t opcode;
uint8_t byte2;
#define SSD_UnitOffL 0x01
#define SSD_DevOffL 0x02
#define SSD_SelfTest 0x04
#define SSD_PF 0x10
#define SSD_CODE(x) ((x) << 5)
uint8_t reserved;
uint8_t paramlen[2];
uint8_t control;
};
#define SCSI_TEST_UNIT_READY 0x00
struct scsi_test_unit_ready {
uint8_t opcode;
uint8_t byte2;
uint8_t reserved[3];
uint8_t control;
};
#endif