Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | #ifndef _SCSI_SCSI_EH_H |
| 3 | #define _SCSI_SCSI_EH_H |
| 4 | |
James Bottomley | 645a0c6 | 2007-10-15 21:07:17 -0400 | [diff] [blame] | 5 | #include <linux/scatterlist.h> |
| 6 | |
Boaz Harrosh | e1c2346 | 2007-10-08 16:36:45 +0200 | [diff] [blame] | 7 | #include <scsi/scsi_cmnd.h> |
Sagi Grimberg | 7708c16 | 2015-07-08 17:58:52 +0300 | [diff] [blame] | 8 | #include <scsi/scsi_common.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | struct scsi_device; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | struct Scsi_Host; |
| 11 | |
Tejun Heo | 041c5fc | 2006-01-23 13:09:36 +0900 | [diff] [blame] | 12 | extern void scsi_eh_finish_cmd(struct scsi_cmnd *scmd, |
| 13 | struct list_head *done_q); |
| 14 | extern void scsi_eh_flush_done_q(struct list_head *done_q); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | extern void scsi_report_bus_reset(struct Scsi_Host *, int); |
| 16 | extern void scsi_report_device_reset(struct Scsi_Host *, int, int); |
| 17 | extern int scsi_block_when_processing_errors(struct scsi_device *); |
Hannes Reinecke | 4753cbc | 2014-10-24 14:26:52 +0200 | [diff] [blame] | 18 | extern bool scsi_command_normalize_sense(const struct scsi_cmnd *cmd, |
| 19 | struct scsi_sense_hdr *sshdr); |
Bart Van Assche | b8e162f | 2021-04-15 15:08:11 -0700 | [diff] [blame] | 20 | extern enum scsi_disposition scsi_check_sense(struct scsi_cmnd *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | |
Hannes Reinecke | 4753cbc | 2014-10-24 14:26:52 +0200 | [diff] [blame] | 22 | static inline bool scsi_sense_is_deferred(const struct scsi_sense_hdr *sshdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | { |
| 24 | return ((sshdr->response_code >= 0x70) && (sshdr->response_code & 1)); |
| 25 | } |
| 26 | |
Damien Le Moal | 2908769 | 2017-04-24 16:51:12 +0900 | [diff] [blame] | 27 | extern bool scsi_get_sense_info_fld(const u8 *sense_buffer, int sb_len, |
| 28 | u64 *info_out); |
FUJITA Tomonori | 3bc6a26 | 2008-03-25 09:26:49 +0900 | [diff] [blame] | 29 | |
Christoph Hellwig | 176aa9d | 2014-10-11 12:06:47 +0200 | [diff] [blame] | 30 | extern int scsi_ioctl_reset(struct scsi_device *, int __user *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | |
Boaz Harrosh | e1c2346 | 2007-10-08 16:36:45 +0200 | [diff] [blame] | 32 | struct scsi_eh_save { |
Boaz Harrosh | 30b0c37 | 2007-12-13 13:47:40 +0200 | [diff] [blame] | 33 | /* saved state */ |
Boaz Harrosh | e1c2346 | 2007-10-08 16:36:45 +0200 | [diff] [blame] | 34 | int result; |
Damien Le Moal | 8f8fed0 | 2019-10-01 16:48:39 +0900 | [diff] [blame] | 35 | unsigned int resid_len; |
Hannes Reinecke | 8e8c9d0 | 2017-04-06 15:36:33 +0200 | [diff] [blame] | 36 | int eh_eflags; |
Boaz Harrosh | e1c2346 | 2007-10-08 16:36:45 +0200 | [diff] [blame] | 37 | enum dma_data_direction data_direction; |
Alan Stern | 1226570 | 2008-07-21 10:25:52 -0400 | [diff] [blame] | 38 | unsigned underflow; |
Boaz Harrosh | e1c2346 | 2007-10-08 16:36:45 +0200 | [diff] [blame] | 39 | unsigned char cmd_len; |
Martin K. Petersen | db007fc | 2008-07-17 04:28:31 -0400 | [diff] [blame] | 40 | unsigned char prot_op; |
Boaz Harrosh | 64a87b2 | 2008-04-30 11:19:47 +0300 | [diff] [blame] | 41 | unsigned char *cmnd; |
Boaz Harrosh | 30b0c37 | 2007-12-13 13:47:40 +0200 | [diff] [blame] | 42 | struct scsi_data_buffer sdb; |
Boaz Harrosh | 30b0c37 | 2007-12-13 13:47:40 +0200 | [diff] [blame] | 43 | /* new command support */ |
Boaz Harrosh | 64a87b2 | 2008-04-30 11:19:47 +0300 | [diff] [blame] | 44 | unsigned char eh_cmnd[BLK_MAX_CDB]; |
Boaz Harrosh | e1c2346 | 2007-10-08 16:36:45 +0200 | [diff] [blame] | 45 | struct scatterlist sense_sgl; |
| 46 | }; |
| 47 | |
| 48 | extern void scsi_eh_prep_cmnd(struct scsi_cmnd *scmd, |
| 49 | struct scsi_eh_save *ses, unsigned char *cmnd, |
| 50 | int cmnd_size, unsigned sense_bytes); |
| 51 | |
| 52 | extern void scsi_eh_restore_cmnd(struct scsi_cmnd* scmd, |
| 53 | struct scsi_eh_save *ses); |
| 54 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | #endif /* _SCSI_SCSI_EH_H */ |