summaryrefslogtreecommitdiff
path: root/include/scsi
diff options
context:
space:
mode:
authorHannes Reinecke <hare@suse.de>2021-04-27 11:30:23 +0300
committerMartin K. Petersen <martin.petersen@oracle.com>2021-06-01 05:48:22 +0300
commit735b830c6104af6f4ec0e9a22822cd4067ac0bf5 (patch)
tree943423e2fd22d0a9863eff80cd2e3090ca5be75e /include/scsi
parentf6b5a697064900c207876c12af55e176ec83f49e (diff)
downloadlinux-735b830c6104af6f4ec0e9a22822cd4067ac0bf5.tar.xz
scsi: core: Add scsi_msg_to_host_byte()
Add helper to convert message byte into a host byte code. Link: https://lore.kernel.org/r/20210427083046.31620-18-hare@suse.de Reviewed-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Hannes Reinecke <hare@suse.de> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Diffstat (limited to 'include/scsi')
-rw-r--r--include/scsi/scsi_cmnd.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h
index 760990116024..efcf33c29efa 100644
--- a/include/scsi/scsi_cmnd.h
+++ b/include/scsi/scsi_cmnd.h
@@ -335,6 +335,32 @@ static inline u8 get_host_byte(struct scsi_cmnd *cmd)
return (cmd->result >> 16) & 0xff;
}
+/**
+ * scsi_msg_to_host_byte() - translate message byte
+ *
+ * Translate the SCSI parallel message byte to a matching
+ * host byte setting. A message of COMMAND_COMPLETE indicates
+ * a successful command execution, any other message indicate
+ * an error. As the messages themselves only have a meaning
+ * for the SCSI parallel protocol this function translates
+ * them into a matching host byte value for SCSI EH.
+ */
+static inline void scsi_msg_to_host_byte(struct scsi_cmnd *cmd, u8 msg)
+{
+ switch (msg) {
+ case COMMAND_COMPLETE:
+ break;
+ case ABORT_TASK_SET:
+ set_host_byte(cmd, DID_ABORT);
+ break;
+ case TARGET_RESET:
+ set_host_byte(cmd, DID_RESET);
+ break;
+ default:
+ set_host_byte(cmd, DID_ERROR);
+ break;
+ }
+}
static inline unsigned scsi_transfer_length(struct scsi_cmnd *scmd)
{