^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) #ifndef _SCSI_SCSI_EH_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #define _SCSI_SCSI_EH_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) #include <linux/scatterlist.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #include <scsi/scsi_cmnd.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include <scsi/scsi_common.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) struct scsi_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) struct Scsi_Host;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) extern void scsi_eh_finish_cmd(struct scsi_cmnd *scmd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) struct list_head *done_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) extern void scsi_eh_flush_done_q(struct list_head *done_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) extern void scsi_report_bus_reset(struct Scsi_Host *, int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) extern void scsi_report_device_reset(struct Scsi_Host *, int, int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) extern int scsi_block_when_processing_errors(struct scsi_device *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) extern bool scsi_command_normalize_sense(const struct scsi_cmnd *cmd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) struct scsi_sense_hdr *sshdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) extern int scsi_check_sense(struct scsi_cmnd *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) static inline bool scsi_sense_is_deferred(const struct scsi_sense_hdr *sshdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) return ((sshdr->response_code >= 0x70) && (sshdr->response_code & 1));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) extern bool scsi_get_sense_info_fld(const u8 *sense_buffer, int sb_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) u64 *info_out);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) extern int scsi_ioctl_reset(struct scsi_device *, int __user *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) struct scsi_eh_save {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) /* saved state */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) int result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) unsigned int resid_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) int eh_eflags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) enum dma_data_direction data_direction;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) unsigned underflow;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) unsigned char cmd_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) unsigned char prot_op;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) unsigned char *cmnd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) struct scsi_data_buffer sdb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) /* new command support */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) unsigned char eh_cmnd[BLK_MAX_CDB];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) struct scatterlist sense_sgl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) extern void scsi_eh_prep_cmnd(struct scsi_cmnd *scmd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) struct scsi_eh_save *ses, unsigned char *cmnd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) int cmnd_size, unsigned sense_bytes);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) extern void scsi_eh_restore_cmnd(struct scsi_cmnd* scmd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) struct scsi_eh_save *ses);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) #endif /* _SCSI_SCSI_EH_H */