Move code that is used both by initiator and target drivers
[linux-block.git] / include / scsi / scsi_eh.h
CommitLineData
1da177e4
LT
1#ifndef _SCSI_SCSI_EH_H
2#define _SCSI_SCSI_EH_H
3
645a0c6c
JB
4#include <linux/scatterlist.h>
5
e1c23468 6#include <scsi/scsi_cmnd.h>
1da177e4 7struct scsi_device;
1da177e4
LT
8struct Scsi_Host;
9
041c5fc3
TH
10extern void scsi_eh_finish_cmd(struct scsi_cmnd *scmd,
11 struct list_head *done_q);
12extern void scsi_eh_flush_done_q(struct list_head *done_q);
1da177e4
LT
13extern void scsi_report_bus_reset(struct Scsi_Host *, int);
14extern void scsi_report_device_reset(struct Scsi_Host *, int, int);
15extern int scsi_block_when_processing_errors(struct scsi_device *);
4753cbc0
HR
16extern bool scsi_command_normalize_sense(const struct scsi_cmnd *cmd,
17 struct scsi_sense_hdr *sshdr);
1da177e4 18
4753cbc0 19static inline bool scsi_sense_is_deferred(const struct scsi_sense_hdr *sshdr)
1da177e4
LT
20{
21 return ((sshdr->response_code >= 0x70) && (sshdr->response_code & 1));
22}
23
24extern const u8 * scsi_sense_desc_find(const u8 * sense_buffer, int sb_len,
25 int desc_type);
26
27extern int scsi_get_sense_info_fld(const u8 * sense_buffer, int sb_len,
28 u64 * info_out);
3bc6a261
FT
29
30extern void scsi_build_sense_buffer(int desc, u8 *buf, u8 key, u8 asc, u8 ascq);
a1524f22 31extern void scsi_set_sense_information(u8 *buf, u64 info);
3bc6a261 32
176aa9d6 33extern int scsi_ioctl_reset(struct scsi_device *, int __user *);
1da177e4 34
e1c23468 35struct scsi_eh_save {
30b0c37b 36 /* saved state */
e1c23468
BH
37 int result;
38 enum dma_data_direction data_direction;
12265709 39 unsigned underflow;
e1c23468 40 unsigned char cmd_len;
db007fc5 41 unsigned char prot_op;
64a87b24 42 unsigned char *cmnd;
30b0c37b 43 struct scsi_data_buffer sdb;
6f9a35e2 44 struct request *next_rq;
30b0c37b 45 /* new command support */
64a87b24 46 unsigned char eh_cmnd[BLK_MAX_CDB];
e1c23468
BH
47 struct scatterlist sense_sgl;
48};
49
50extern void scsi_eh_prep_cmnd(struct scsi_cmnd *scmd,
51 struct scsi_eh_save *ses, unsigned char *cmnd,
52 int cmnd_size, unsigned sense_bytes);
53
54extern void scsi_eh_restore_cmnd(struct scsi_cmnd* scmd,
55 struct scsi_eh_save *ses);
56
1da177e4 57#endif /* _SCSI_SCSI_EH_H */