diff options
author | Martin K. Petersen <martin.petersen@oracle.com> | 2008-07-17 04:28:31 -0400 |
---|---|---|
committer | James Bottomley <James.Bottomley@HansenPartnership.com> | 2008-07-26 15:14:54 -0400 |
commit | db007fc5e20c00b356e9ffe2d0e007398c65c837 (patch) | |
tree | ab0483beff7abaddb9648bc0b2ef1ceacfeb02a9 /include/scsi/scsi_cmnd.h | |
parent | 4469f9878059f1707f021512e6b34252c4096ee7 (diff) | |
download | linux-3.10-db007fc5e20c00b356e9ffe2d0e007398c65c837.tar.gz linux-3.10-db007fc5e20c00b356e9ffe2d0e007398c65c837.tar.bz2 linux-3.10-db007fc5e20c00b356e9ffe2d0e007398c65c837.zip |
[SCSI] Command protection operation
Controllers that support DMA of protection information must be told
explicitly how to handle the I/O. The controller has no knowledge of
the protection capabilities of the target device so this information
must be passed in the scsi_cmnd.
- The protection operation tells the HBA whether to generate, strip or
verify protection information.
- The protection type tells the HBA which layout the target is
formatted with. This is necessary because the controller must be
able to correctly interpret the included protection information in
order to verify it.
- When a scsi_cmnd is reused for error handling the protection
operation must be cleared and saved while error handling is in
progress.
- prot_op and prot_type are placed in an existing hole in scsi_cmnd
and don't cause the structure to grow.
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Diffstat (limited to 'include/scsi/scsi_cmnd.h')
-rw-r--r-- | include/scsi/scsi_cmnd.h | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h index 66c944849d6..402c1078d01 100644 --- a/include/scsi/scsi_cmnd.h +++ b/include/scsi/scsi_cmnd.h @@ -77,6 +77,9 @@ struct scsi_cmnd { int allowed; int timeout_per_command; + unsigned char prot_op; + unsigned char prot_type; + unsigned short cmd_len; enum dma_data_direction sc_data_direction; @@ -208,4 +211,67 @@ static inline int scsi_sg_copy_to_buffer(struct scsi_cmnd *cmd, buf, buflen); } +/* + * The operations below are hints that tell the controller driver how + * to handle I/Os with DIF or similar types of protection information. + */ +enum scsi_prot_operations { + /* Normal I/O */ + SCSI_PROT_NORMAL = 0, + + /* OS-HBA: Protected, HBA-Target: Unprotected */ + SCSI_PROT_READ_INSERT, + SCSI_PROT_WRITE_STRIP, + + /* OS-HBA: Unprotected, HBA-Target: Protected */ + SCSI_PROT_READ_STRIP, + SCSI_PROT_WRITE_INSERT, + + /* OS-HBA: Protected, HBA-Target: Protected */ + SCSI_PROT_READ_PASS, + SCSI_PROT_WRITE_PASS, + + /* OS-HBA: Protected, HBA-Target: Protected, checksum conversion */ + SCSI_PROT_READ_CONVERT, + SCSI_PROT_WRITE_CONVERT, +}; + +static inline void scsi_set_prot_op(struct scsi_cmnd *scmd, unsigned char op) +{ + scmd->prot_op = op; +} + +static inline unsigned char scsi_get_prot_op(struct scsi_cmnd *scmd) +{ + return scmd->prot_op; +} + +/* + * The controller usually does not know anything about the target it + * is communicating with. However, when DIX is enabled the controller + * must be know target type so it can verify the protection + * information passed along with the I/O. + */ +enum scsi_prot_target_type { + SCSI_PROT_DIF_TYPE0 = 0, + SCSI_PROT_DIF_TYPE1, + SCSI_PROT_DIF_TYPE2, + SCSI_PROT_DIF_TYPE3, +}; + +static inline void scsi_set_prot_type(struct scsi_cmnd *scmd, unsigned char type) +{ + scmd->prot_type = type; +} + +static inline unsigned char scsi_get_prot_type(struct scsi_cmnd *scmd) +{ + return scmd->prot_type; +} + +static inline sector_t scsi_get_lba(struct scsi_cmnd *scmd) +{ + return scmd->request->sector; +} + #endif /* _SCSI_SCSI_CMND_H */ |