aboutsummaryrefslogtreecommitdiffstats
path: root/include/scsi/scsi_cmnd.h
diff options
context:
space:
mode:
authorMartin K. Petersen <martin.petersen@oracle.com>2008-07-17 04:28:31 -0400
committerJames Bottomley <James.Bottomley@HansenPartnership.com>2008-07-26 15:14:54 -0400
commitdb007fc5e20c00b356e9ffe2d0e007398c65c837 (patch)
treeab0483beff7abaddb9648bc0b2ef1ceacfeb02a9 /include/scsi/scsi_cmnd.h
parent4469f9878059f1707f021512e6b34252c4096ee7 (diff)
[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.h66
1 files changed, 66 insertions, 0 deletions
diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h
index 66c944849d6b..402c1078d01c 100644
--- a/include/scsi/scsi_cmnd.h
+++ b/include/scsi/scsi_cmnd.h
@@ -77,6 +77,9 @@ struct scsi_cmnd {
77 int allowed; 77 int allowed;
78 int timeout_per_command; 78 int timeout_per_command;
79 79
80 unsigned char prot_op;
81 unsigned char prot_type;
82
80 unsigned short cmd_len; 83 unsigned short cmd_len;
81 enum dma_data_direction sc_data_direction; 84 enum dma_data_direction sc_data_direction;
82 85
@@ -208,4 +211,67 @@ static inline int scsi_sg_copy_to_buffer(struct scsi_cmnd *cmd,
208 buf, buflen); 211 buf, buflen);
209} 212}
210 213
214/*
215 * The operations below are hints that tell the controller driver how
216 * to handle I/Os with DIF or similar types of protection information.
217 */
218enum scsi_prot_operations {
219 /* Normal I/O */
220 SCSI_PROT_NORMAL = 0,
221
222 /* OS-HBA: Protected, HBA-Target: Unprotected */
223 SCSI_PROT_READ_INSERT,
224 SCSI_PROT_WRITE_STRIP,
225
226 /* OS-HBA: Unprotected, HBA-Target: Protected */
227 SCSI_PROT_READ_STRIP,
228 SCSI_PROT_WRITE_INSERT,
229
230 /* OS-HBA: Protected, HBA-Target: Protected */
231 SCSI_PROT_READ_PASS,
232 SCSI_PROT_WRITE_PASS,
233
234 /* OS-HBA: Protected, HBA-Target: Protected, checksum conversion */
235 SCSI_PROT_READ_CONVERT,
236 SCSI_PROT_WRITE_CONVERT,
237};
238
239static inline void scsi_set_prot_op(struct scsi_cmnd *scmd, unsigned char op)
240{
241 scmd->prot_op = op;
242}
243
244static inline unsigned char scsi_get_prot_op(struct scsi_cmnd *scmd)
245{
246 return scmd->prot_op;
247}
248
249/*
250 * The controller usually does not know anything about the target it
251 * is communicating with. However, when DIX is enabled the controller
252 * must be know target type so it can verify the protection
253 * information passed along with the I/O.
254 */
255enum scsi_prot_target_type {
256 SCSI_PROT_DIF_TYPE0 = 0,
257 SCSI_PROT_DIF_TYPE1,
258 SCSI_PROT_DIF_TYPE2,
259 SCSI_PROT_DIF_TYPE3,
260};
261
262static inline void scsi_set_prot_type(struct scsi_cmnd *scmd, unsigned char type)
263{
264 scmd->prot_type = type;
265}
266
267static inline unsigned char scsi_get_prot_type(struct scsi_cmnd *scmd)
268{
269 return scmd->prot_type;
270}
271
272static inline sector_t scsi_get_lba(struct scsi_cmnd *scmd)
273{
274 return scmd->request->sector;
275}
276
211#endif /* _SCSI_SCSI_CMND_H */ 277#endif /* _SCSI_SCSI_CMND_H */