22#define SCSICMDS_H_CVSID "$Id: scsicmds.h 5462 2023-03-13 10:45:06Z chrfranke $\n"
33#ifndef TEST_UNIT_READY
34#define TEST_UNIT_READY 0x0
37#define LOG_SELECT 0x4c
43#define MODE_SENSE_6 0x1a
46#define MODE_SENSE_10 0x5a
49#define MODE_SELECT_6 0x15
52#define MODE_SELECT_10 0x55
58#define REQUEST_SENSE 0x03
60#ifndef RECEIVE_DIAGNOSTIC
61#define RECEIVE_DIAGNOSTIC 0x1c
63#ifndef SEND_DIAGNOSTIC
64#define SEND_DIAGNOSTIC 0x1d
67#define READ_DEFECT_10 0x37
70#define READ_DEFECT_12 0xb7
72#ifndef START_STOP_UNIT
73#define START_STOP_UNIT 0x1b
76#define REPORT_LUNS 0xa0
78#ifndef READ_CAPACITY_10
79#define READ_CAPACITY_10 0x25
81#ifndef SERVICE_ACTION_IN_16
82#define SERVICE_ACTION_IN_16 0x9e
84#ifndef SAI_READ_CAPACITY_16
85#define SAI_READ_CAPACITY_16 0x10
87#ifndef SAI_GET_PHY_ELEM_STATUS
88#define SAI_GET_PHY_ELEM_STATUS 0x17
90#ifndef SAI_REPORT_SUPPORTED_OPCODES
91#define SAI_REPORT_SUPPORTED_OPCODES 0xc
93#ifndef MAINTENANCE_IN_12
94#define MAINTENANCE_IN_12 0xa3
96#ifndef MI_REP_SUP_OPCODES
97#define MI_REP_SUP_OPCODES 0xc
100#ifndef SAT_ATA_PASSTHROUGH_12
101#define SAT_ATA_PASSTHROUGH_12 0xa1
103#ifndef SAT_ATA_PASSTHROUGH_16
104#define SAT_ATA_PASSTHROUGH_16 0x85
109#define DXFER_FROM_DEVICE 1
110#define DXFER_TO_DEVICE 2
143#define SCSI_IECMP_RAW_LEN 64
191#define SCSI_PT_DIRECT_ACCESS 0x0
192#define SCSI_PT_SEQUENTIAL_ACCESS 0x1
193#define SCSI_PT_WO 0x4
194#define SCSI_PT_CDROM 0x5
195#define SCSI_PT_OPTICAL 0x7
196#define SCSI_PT_MEDIUM_CHANGER 0x8
197#define SCSI_PT_ENCLOSURE 0xd
198#define SCSI_PT_RBC 0xe
199#define SCSI_PT_HOST_MANAGED 0x14
202#define SCSI_TPROTO_FCP 0
203#define SCSI_TPROTO_SPI 1
204#define SCSI_TPROTO_SSA 2
205#define SCSI_TPROTO_1394 3
206#define SCSI_TPROTO_SRP 4
207#define SCSI_TPROTO_ISCSI 5
208#define SCSI_TPROTO_SAS 6
209#define SCSI_TPROTO_ADT 7
210#define SCSI_TPROTO_ATA 8
211#define SCSI_TPROTO_UAS 9
212#define SCSI_TPROTO_SOP 0xa
213#define SCSI_TPROTO_PCIE 0xb
214#define SCSI_TPROTO_NONE 0xf
218#define SUPPORTED_LPAGES 0x00
219#define BUFFER_OVERRUN_LPAGE 0x01
220#define WRITE_ERROR_COUNTER_LPAGE 0x02
221#define READ_ERROR_COUNTER_LPAGE 0x03
222#define READ_REVERSE_ERROR_COUNTER_LPAGE 0x04
223#define VERIFY_ERROR_COUNTER_LPAGE 0x05
224#define NON_MEDIUM_ERROR_LPAGE 0x06
225#define LAST_N_ERROR_EVENTS_LPAGE 0x07
226#define FORMAT_STATUS_LPAGE 0x08
227#define LAST_N_DEFERRED_LPAGE 0x0b
228#define LB_PROV_LPAGE 0x0c
229#define TEMPERATURE_LPAGE 0x0d
230#define STARTSTOP_CYCLE_COUNTER_LPAGE 0x0e
231#define APPLICATION_CLIENT_LPAGE 0x0f
232#define SELFTEST_RESULTS_LPAGE 0x10
233#define SS_MEDIA_LPAGE 0x11
234#define DEVICE_STATS_LPAGE 0x14
235#define BACKGROUND_RESULTS_LPAGE 0x15
236#define ATA_PT_RESULTS_LPAGE 0x16
237#define NONVOL_CACHE_LPAGE 0x17
238#define PROTOCOL_SPECIFIC_LPAGE 0x18
239#define GEN_STATS_PERF_LPAGE 0x19
240#define POWER_COND_TRANS_LPAGE 0x1a
244#define NO_SUBPAGE_L_SPAGE 0x0
245#define LAST_N_INQ_DAT_L_SPAGE 0x1
246#define LAST_N_MODE_PG_L_SPAGE 0x2
247#define ENVIRO_REP_L_SPAGE 0x1
248#define ENVIRO_LIMITS_L_SPAGE 0x2
249#define UTILIZATION_L_SPAGE 0x1
250#define ZB_DEV_STATS_L_SPAGE 0x1
251#define PEND_DEFECTS_L_SPAGE 0x1
252#define BACKGROUND_OP_L_SPAGE 0x2
253#define LPS_MISALIGN_L_SPAGE 0x3
254#define SUPP_SPAGE_L_SPAGE 0xff
257#define SEAGATE_CACHE_LPAGE 0x37
258#define SEAGATE_FARM_LPAGE 0x3d
259#define SEAGATE_FACTORY_LPAGE 0x3e
262#define SEAGATE_FARM_CURRENT_L_SPAGE 0x3
265#define LOG_RESP_SELF_TEST_LEN 0x194
269#define TAPE_ALERTS_LPAGE 0x2e
272#define VENDOR_UNIQUE_PAGE 0x00
273#define READ_WRITE_ERROR_RECOVERY_PAGE 0x01
274#define DISCONNECT_RECONNECT_PAGE 0x02
275#define FORMAT_DEVICE_PAGE 0x03
276#define RIGID_DISK_DRIVE_GEOMETRY_PAGE 0x04
277#define FLEXIBLE_DISK_PAGE 0x05
278#define VERIFY_ERROR_RECOVERY_PAGE 0x07
279#define CACHING_PAGE 0x08
280#define PERIPHERAL_DEVICE_PAGE 0x09
281#define XOR_CONTROL_MODE_PAGE 0x10
282#define CONTROL_MODE_PAGE 0x0a
283#define MEDIUM_TYPES_SUPPORTED_PAGE 0x0b
284#define NOTCH_PAGE 0x0c
285#define CD_DEVICE_PAGE 0x0d
286#define CD_AUDIO_CONTROL_PAGE 0x0e
287#define DATA_COMPRESSION_PAGE 0x0f
288#define ENCLOSURE_SERVICES_MANAGEMENT_PAGE 0x14
289#define PROTOCOL_SPECIFIC_LUN_PAGE 0x18
290#define PROTOCOL_SPECIFIC_PORT_PAGE 0x19
291#define POWER_CONDITION_PAGE 0x1a
292#define INFORMATIONAL_EXCEPTIONS_CONTROL_PAGE 0x1c
293#define FAULT_FAILURE_REPORTING_PAGE 0x1c
296#define BACKGROUND_CONTROL_M_SUBPAGE 0x1
298#define ALL_MODE_PAGES 0x3f
301#define MPAGE_CONTROL_CURRENT 0
302#define MPAGE_CONTROL_CHANGEABLE 1
303#define MPAGE_CONTROL_DEFAULT 2
304#define MPAGE_CONTROL_SAVED 3
307#define SCSI_VPD_SUPPORTED_VPD_PAGES 0x0
308#define SCSI_VPD_UNIT_SERIAL_NUMBER 0x80
309#define SCSI_VPD_DEVICE_IDENTIFICATION 0x83
310#define SCSI_VPD_EXTENDED_INQUIRY_DATA 0x86
311#define SCSI_VPD_ATA_INFORMATION 0x89
312#define SCSI_VPD_POWER_CONDITION 0x8a
313#define SCSI_VPD_POWER_CONSUMPTION 0x8d
314#define SCSI_VPD_BLOCK_LIMITS 0xb0
315#define SCSI_VPD_BLOCK_DEVICE_CHARACTERISTICS 0xb1
316#define SCSI_VPD_LOGICAL_BLOCK_PROVISIONING 0xb2
317#define SCSI_VPD_ZONED_BLOCK_DEV_CHAR 0xb6
320#define SCSI_STATUS_CHECK_CONDITION 0x2
323#define SCSI_SK_NO_SENSE 0x0
324#define SCSI_SK_RECOVERED_ERR 0x1
325#define SCSI_SK_NOT_READY 0x2
326#define SCSI_SK_MEDIUM_ERROR 0x3
327#define SCSI_SK_HARDWARE_ERROR 0x4
328#define SCSI_SK_ILLEGAL_REQUEST 0x5
329#define SCSI_SK_UNIT_ATTENTION 0x6
330#define SCSI_SK_DATA_PROTECT 0x7
331#define SCSI_SK_ABORTED_COMMAND 0xb
332#define SCSI_SK_MISCOMPARE 0xe
333#define SCSI_SK_COMPLETED 0xf
336#define SCSI_ASC_NOT_READY 0x4
337#define SCSI_ASC_NO_MEDIUM 0x3a
338#define SCSI_ASC_UNKNOWN_OPCODE 0x20
339#define SCSI_ASC_INVALID_FIELD 0x24
340#define SCSI_ASC_UNKNOWN_PARAM 0x26
341#define SCSI_ASC_WARNING 0xb
342#define SCSI_ASC_IMPENDING_FAILURE 0x5d
344#define SCSI_ASCQ_ATA_PASS_THROUGH 0x1d
347#define SIMPLE_NO_ERROR 0
348#define SIMPLE_ERR_NOT_READY 1
349#define SIMPLE_ERR_BAD_OPCODE 2
350#define SIMPLE_ERR_BAD_FIELD 3
351#define SIMPLE_ERR_BAD_PARAM 4
352#define SIMPLE_ERR_BAD_RESP 5
353#define SIMPLE_ERR_NO_MEDIUM 6
354#define SIMPLE_ERR_BECOMING_READY 7
355#define SIMPLE_ERR_TRY_AGAIN 8
356#define SIMPLE_ERR_MEDIUM_HARDWARE 9
357#define SIMPLE_ERR_UNKNOWN 10
358#define SIMPLE_ERR_ABORTED_COMMAND 11
359#define SIMPLE_ERR_PROTECTION 12
360#define SIMPLE_ERR_MISCOMPARE 13
364#define SCSI_DIAG_NO_SELF_TEST 0x00
365#define SCSI_DIAG_DEF_SELF_TEST 0xff
366#define SCSI_DIAG_BG_SHORT_SELF_TEST 0x01
367#define SCSI_DIAG_BG_EXTENDED_SELF_TEST 0x02
368#define SCSI_DIAG_FG_SHORT_SELF_TEST 0x05
369#define SCSI_DIAG_FG_EXTENDED_SELF_TEST 0x06
370#define SCSI_DIAG_ABORT_SELF_TEST 0x04
373#define SCSI_POW_COND_ACTIVE 0x1
374#define SCSI_POW_COND_IDLE 0x2
375#define SCSI_POW_COND_STANDBY 0x3
379#define SCSI_TIMEOUT_DEFAULT 60
382#define SCSI_TIMEOUT_SELF_TEST (5 * 60 * 60)
385#define LOGPAGEHDRSIZE 4
436 int page_len,
int * off,
int m_assoc,
437 int m_desig_type,
int m_code_set);
440 int slen,
int * transport);
452 uint8_t *pBuf,
int bufLen,
int known_resp_len);
455 int subpagenum, uint8_t *pBuf,
int bufLen);
458 uint8_t *pBuf,
int bufLen);
463 uint8_t *pBuf,
int bufLen);
473 int pcond_modifier = 0);
482 int dl_format, uint8_t *pBuf,
int bufLen);
485 int dl_format,
int addrDescIndex, uint8_t *pBuf,
489 unsigned int * lb_sizep);
494 uint8_t
opcode, uint16_t serv_act, uint8_t *pBuf,
int bufLen,
499 uint8_t *asc, uint8_t *ascq, uint8_t *currenttemp,
554void dStrHex(
const uint8_t * up,
int len,
int no_ascii);
560void dStrHexFp(
const uint8_t * up,
int len,
int no_ascii, FILE * fp);
bool is_supported(int vpd_page_num) const
int scsiReadDefect12(scsi_device *device, int req_plist, int req_glist, int dl_format, int addrDescIndex, uint8_t *pBuf, int bufLen)
int scsiFetchExtendedSelfTestTime(scsi_device *device, int *durationSec, int modese_len)
void scsiDecodeErrCounterPage(unsigned char *resp, struct scsiErrorCounter *ecp, int allocLen)
int scsiModeSelect(scsi_device *device, int sp, uint8_t *pBuf, int bufLen)
int scsiSimpleSenseFilter(const struct scsi_sense_disect *sinfo)
int scsiSetExceptionControlAndWarning(scsi_device *device, int enabled, const struct scsi_iec_mode_page *iecp)
int scsiSmartExtendCapSelfTest(scsi_device *device)
int scsiFetchIECmpage(scsi_device *device, struct scsi_iec_mode_page *iecp, int modese_len)
int scsiGetTemp(scsi_device *device, uint8_t *currenttemp, uint8_t *triptemp)
int scsiSmartShortCapSelfTest(scsi_device *device)
int scsiSmartSelfTestAbort(scsi_device *device)
char * scsi_get_sense_key_str(int sense_key, int buff_len, char *buff)
int scsiGetSetCache(scsi_device *device, int modese_len, short int *wce, short int *rcd)
const char * scsiTapeAlertsTapeDevice(unsigned short code)
int scsiReadCapacity10(scsi_device *device, unsigned int *last_lbp, unsigned int *lb_sizep)
int scsiFetchTransportProtocol(scsi_device *device, int modese_len)
int scsi_decode_lu_dev_id(const unsigned char *b, int blen, char *s, int slen, int *transport)
bool is_scsi_cdb(const uint8_t *cdbp, int clen)
void dStrHexFp(const uint8_t *up, int len, int no_ascii, FILE *fp)
void scsi_do_sense_disect(const struct scsi_cmnd_io *in, struct scsi_sense_disect *out)
int scsiTestUnitReady(scsi_device *device)
int scsiCountFailedSelfTests(scsi_device *device, int noisy)
int scsiModeSense10(scsi_device *device, int pagenum, int subpagenum, int pc, uint8_t *pBuf, int bufLen)
int scsiModePageOffset(const uint8_t *resp, int len, int modese_len)
int scsiInquiryVpd(scsi_device *device, int vpd_page, uint8_t *pBuf, int bufLen)
int scsiSelfTestInProgress(scsi_device *device, int *inProgress)
int scsiSetPowerCondition(scsi_device *device, int power_cond, int pcond_modifier=0)
int scsiSmartExtendSelfTest(scsi_device *device)
#define SCSI_IECMP_RAW_LEN
void scsiDecodeNonMediumErrPage(unsigned char *resp, struct scsiNonMediumError *nmep, int allocLen)
int scsiRequestSense(scsi_device *device, struct scsi_sense_disect *sense_info)
int scsiCheckIE(scsi_device *device, int hasIELogPage, int hasTempLogPage, uint8_t *asc, uint8_t *ascq, uint8_t *currenttemp, uint8_t *triptemp)
uint64_t scsiGetSize(scsi_device *device, bool avoid_rcap16, struct scsi_readcap_resp *srrp)
char * scsiGetIEString(uint8_t asc, uint8_t ascq, char *b, int blen)
int scsiRSOCcmd(scsi_device *device, bool rctd, uint8_t rep_opt, uint8_t opcode, uint16_t serv_act, uint8_t *pBuf, int bufLen, int &rspLen)
supported_vpd_pages * supported_vpd_pages_p
int scsiGetRPM(scsi_device *device, int modese_len, int *form_factorp, int *haw_zbcp)
void scsi_format_id_string(char *out, const uint8_t *in, int n)
bool scsi_pass_through_yield_sense(scsi_device *device, scsi_cmnd_io *iop, struct scsi_sense_disect &sinfo)
int scsiReadCapacity16(scsi_device *device, uint8_t *pBuf, int bufLen)
int scsiStdInquiry(scsi_device *device, uint8_t *pBuf, int bufLen)
int scsiModeSelect10(scsi_device *device, int sp, uint8_t *pBuf, int bufLen)
const unsigned char * sg_scsi_sense_desc_find(const unsigned char *sensep, int sense_len, int desc_type)
int scsiSmartDefaultSelfTest(scsi_device *device)
void dStrHex(const uint8_t *up, int len, int no_ascii)
int scsiSendDiagnostic(scsi_device *device, int functioncode, uint8_t *pBuf, int bufLen)
const char * scsiErrString(int scsiErr)
const char * scsiTapeAlertsChangerDevice(unsigned short code)
int scsiFetchControlGLTSD(scsi_device *device, int modese_len, int current)
int scsiModeSense(scsi_device *device, int pagenum, int subpagenum, int pc, uint8_t *pBuf, int bufLen)
int scsi_IsWarningEnabled(const struct scsi_iec_mode_page *iecp)
int scsiSetControlGLTSD(scsi_device *device, int enabled, int modese_len)
int scsi_IsExceptionControlEnabled(const struct scsi_iec_mode_page *iecp)
int scsiSmartShortSelfTest(scsi_device *device)
int scsiLogSense(scsi_device *device, int pagenum, int subpagenum, uint8_t *pBuf, int bufLen, int known_resp_len)
unsigned char scsi_debugmode
const char * scsi_get_opcode_name(const uint8_t *cdbp)
int scsiLogSelect(scsi_device *device, int pcr, int sp, int pc, int pagenum, int subpagenum, uint8_t *pBuf, int bufLen)
int scsiReadDefect10(scsi_device *device, int req_plist, int req_glist, int dl_format, uint8_t *pBuf, int bufLen)
int scsi_vpd_dev_id_iter(const unsigned char *initial_desig_desc, int page_len, int *off, int m_assoc, int m_desig_type, int m_code_set)
uint8_t raw_curr[SCSI_IECMP_RAW_LEN]
uint8_t raw_chg[SCSI_IECMP_RAW_LEN]
uint8_t requestedChangeable