22#define SCSICMDS_H_CVSID "$Id: scsicmds.h 5435 2023-01-12 04:51:49Z dpgilbert $\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
150#define SCSI_IECMP_RAW_LEN 64
198#define SCSI_PT_DIRECT_ACCESS 0x0
199#define SCSI_PT_SEQUENTIAL_ACCESS 0x1
200#define SCSI_PT_WO 0x4
201#define SCSI_PT_CDROM 0x5
202#define SCSI_PT_OPTICAL 0x7
203#define SCSI_PT_MEDIUM_CHANGER 0x8
204#define SCSI_PT_ENCLOSURE 0xd
205#define SCSI_PT_RBC 0xe
206#define SCSI_PT_HOST_MANAGED 0x14
209#define SCSI_TPROTO_FCP 0
210#define SCSI_TPROTO_SPI 1
211#define SCSI_TPROTO_SSA 2
212#define SCSI_TPROTO_1394 3
213#define SCSI_TPROTO_SRP 4
214#define SCSI_TPROTO_ISCSI 5
215#define SCSI_TPROTO_SAS 6
216#define SCSI_TPROTO_ADT 7
217#define SCSI_TPROTO_ATA 8
218#define SCSI_TPROTO_UAS 9
219#define SCSI_TPROTO_SOP 0xa
220#define SCSI_TPROTO_PCIE 0xb
221#define SCSI_TPROTO_NONE 0xf
225#define SUPPORTED_LPAGES 0x00
226#define BUFFER_OVERRUN_LPAGE 0x01
227#define WRITE_ERROR_COUNTER_LPAGE 0x02
228#define READ_ERROR_COUNTER_LPAGE 0x03
229#define READ_REVERSE_ERROR_COUNTER_LPAGE 0x04
230#define VERIFY_ERROR_COUNTER_LPAGE 0x05
231#define NON_MEDIUM_ERROR_LPAGE 0x06
232#define LAST_N_ERROR_EVENTS_LPAGE 0x07
233#define FORMAT_STATUS_LPAGE 0x08
234#define LAST_N_DEFERRED_LPAGE 0x0b
235#define LB_PROV_LPAGE 0x0c
236#define TEMPERATURE_LPAGE 0x0d
237#define STARTSTOP_CYCLE_COUNTER_LPAGE 0x0e
238#define APPLICATION_CLIENT_LPAGE 0x0f
239#define SELFTEST_RESULTS_LPAGE 0x10
240#define SS_MEDIA_LPAGE 0x11
241#define DEVICE_STATS_LPAGE 0x14
242#define BACKGROUND_RESULTS_LPAGE 0x15
243#define ATA_PT_RESULTS_LPAGE 0x16
244#define NONVOL_CACHE_LPAGE 0x17
245#define PROTOCOL_SPECIFIC_LPAGE 0x18
246#define GEN_STATS_PERF_LPAGE 0x19
247#define POWER_COND_TRANS_LPAGE 0x1a
251#define NO_SUBPAGE_L_SPAGE 0x0
252#define LAST_N_INQ_DAT_L_SPAGE 0x1
253#define LAST_N_MODE_PG_L_SPAGE 0x2
254#define ENVIRO_REP_L_SPAGE 0x1
255#define ENVIRO_LIMITS_L_SPAGE 0x2
256#define UTILIZATION_L_SPAGE 0x1
257#define ZB_DEV_STATS_L_SPAGE 0x1
258#define PEND_DEFECTS_L_SPAGE 0x1
259#define BACKGROUND_OP_L_SPAGE 0x2
260#define LPS_MISALIGN_L_SPAGE 0x3
261#define SUPP_SPAGE_L_SPAGE 0xff
264#define SEAGATE_CACHE_LPAGE 0x37
265#define SEAGATE_FACTORY_LPAGE 0x3e
268#define LOG_RESP_SELF_TEST_LEN 0x194
272#define TAPE_ALERTS_LPAGE 0x2e
275#define VENDOR_UNIQUE_PAGE 0x00
276#define READ_WRITE_ERROR_RECOVERY_PAGE 0x01
277#define DISCONNECT_RECONNECT_PAGE 0x02
278#define FORMAT_DEVICE_PAGE 0x03
279#define RIGID_DISK_DRIVE_GEOMETRY_PAGE 0x04
280#define FLEXIBLE_DISK_PAGE 0x05
281#define VERIFY_ERROR_RECOVERY_PAGE 0x07
282#define CACHING_PAGE 0x08
283#define PERIPHERAL_DEVICE_PAGE 0x09
284#define XOR_CONTROL_MODE_PAGE 0x10
285#define CONTROL_MODE_PAGE 0x0a
286#define MEDIUM_TYPES_SUPPORTED_PAGE 0x0b
287#define NOTCH_PAGE 0x0c
288#define CD_DEVICE_PAGE 0x0d
289#define CD_AUDIO_CONTROL_PAGE 0x0e
290#define DATA_COMPRESSION_PAGE 0x0f
291#define ENCLOSURE_SERVICES_MANAGEMENT_PAGE 0x14
292#define PROTOCOL_SPECIFIC_LUN_PAGE 0x18
293#define PROTOCOL_SPECIFIC_PORT_PAGE 0x19
294#define POWER_CONDITION_PAGE 0x1a
295#define INFORMATIONAL_EXCEPTIONS_CONTROL_PAGE 0x1c
296#define FAULT_FAILURE_REPORTING_PAGE 0x1c
299#define BACKGROUND_CONTROL_M_SUBPAGE 0x1
301#define ALL_MODE_PAGES 0x3f
304#define MPAGE_CONTROL_CURRENT 0
305#define MPAGE_CONTROL_CHANGEABLE 1
306#define MPAGE_CONTROL_DEFAULT 2
307#define MPAGE_CONTROL_SAVED 3
310#define SCSI_VPD_SUPPORTED_VPD_PAGES 0x0
311#define SCSI_VPD_UNIT_SERIAL_NUMBER 0x80
312#define SCSI_VPD_DEVICE_IDENTIFICATION 0x83
313#define SCSI_VPD_EXTENDED_INQUIRY_DATA 0x86
314#define SCSI_VPD_ATA_INFORMATION 0x89
315#define SCSI_VPD_POWER_CONDITION 0x8a
316#define SCSI_VPD_POWER_CONSUMPTION 0x8d
317#define SCSI_VPD_BLOCK_LIMITS 0xb0
318#define SCSI_VPD_BLOCK_DEVICE_CHARACTERISTICS 0xb1
319#define SCSI_VPD_LOGICAL_BLOCK_PROVISIONING 0xb2
320#define SCSI_VPD_ZONED_BLOCK_DEV_CHAR 0xb6
323#define SCSI_STATUS_CHECK_CONDITION 0x2
326#define SCSI_SK_NO_SENSE 0x0
327#define SCSI_SK_RECOVERED_ERR 0x1
328#define SCSI_SK_NOT_READY 0x2
329#define SCSI_SK_MEDIUM_ERROR 0x3
330#define SCSI_SK_HARDWARE_ERROR 0x4
331#define SCSI_SK_ILLEGAL_REQUEST 0x5
332#define SCSI_SK_UNIT_ATTENTION 0x6
333#define SCSI_SK_DATA_PROTECT 0x7
334#define SCSI_SK_ABORTED_COMMAND 0xb
335#define SCSI_SK_MISCOMPARE 0xe
336#define SCSI_SK_COMPLETED 0xf
339#define SCSI_ASC_NOT_READY 0x4
340#define SCSI_ASC_NO_MEDIUM 0x3a
341#define SCSI_ASC_UNKNOWN_OPCODE 0x20
342#define SCSI_ASC_INVALID_FIELD 0x24
343#define SCSI_ASC_UNKNOWN_PARAM 0x26
344#define SCSI_ASC_WARNING 0xb
345#define SCSI_ASC_IMPENDING_FAILURE 0x5d
347#define SCSI_ASCQ_ATA_PASS_THROUGH 0x1d
350#define SIMPLE_NO_ERROR 0
351#define SIMPLE_ERR_NOT_READY 1
352#define SIMPLE_ERR_BAD_OPCODE 2
353#define SIMPLE_ERR_BAD_FIELD 3
354#define SIMPLE_ERR_BAD_PARAM 4
355#define SIMPLE_ERR_BAD_RESP 5
356#define SIMPLE_ERR_NO_MEDIUM 6
357#define SIMPLE_ERR_BECOMING_READY 7
358#define SIMPLE_ERR_TRY_AGAIN 8
359#define SIMPLE_ERR_MEDIUM_HARDWARE 9
360#define SIMPLE_ERR_UNKNOWN 10
361#define SIMPLE_ERR_ABORTED_COMMAND 11
362#define SIMPLE_ERR_PROTECTION 12
363#define SIMPLE_ERR_MISCOMPARE 13
367#define SCSI_DIAG_NO_SELF_TEST 0x00
368#define SCSI_DIAG_DEF_SELF_TEST 0xff
369#define SCSI_DIAG_BG_SHORT_SELF_TEST 0x01
370#define SCSI_DIAG_BG_EXTENDED_SELF_TEST 0x02
371#define SCSI_DIAG_FG_SHORT_SELF_TEST 0x05
372#define SCSI_DIAG_FG_EXTENDED_SELF_TEST 0x06
373#define SCSI_DIAG_ABORT_SELF_TEST 0x04
376#define SCSI_POW_COND_ACTIVE 0x1
377#define SCSI_POW_COND_IDLE 0x2
378#define SCSI_POW_COND_STANDBY 0x3
382#define SCSI_TIMEOUT_DEFAULT 60
385#define SCSI_TIMEOUT_SELF_TEST (5 * 60 * 60)
388#define LOGPAGEHDRSIZE 4
439 int page_len,
int * off,
int m_assoc,
440 int m_desig_type,
int m_code_set);
443 int slen,
int * transport);
455 uint8_t *pBuf,
int bufLen,
int known_resp_len);
458 int subpagenum, uint8_t *pBuf,
int bufLen);
461 uint8_t *pBuf,
int bufLen);
466 uint8_t *pBuf,
int bufLen);
476 int pcond_modifier = 0);
485 int dl_format, uint8_t *pBuf,
int bufLen);
488 int dl_format,
int addrDescIndex, uint8_t *pBuf,
492 unsigned int * lb_sizep);
500 uint8_t *asc, uint8_t *ascq, uint8_t *currenttemp,
555void dStrHex(
const uint8_t * up,
int len,
int no_ascii);
561void 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)
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 scsiRSOCcmd(scsi_device *device, uint8_t *pBuf, int bufLen, int &rspLen)
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