scsi: stop passing a gfp_mask argument down the command setup path
[deliverable/linux.git] / include / scsi / scsi_cmnd.h
index 73f3490449411af899d71d4be6e4ceb09277e57d..9fc1aecfc81369b9cfc694bece77b9bdfde131e5 100644 (file)
 #include <scsi/scsi_device.h>
 
 struct Scsi_Host;
-struct scsi_device;
 struct scsi_driver;
 
+#include <scsi/scsi_device.h>
+
 /*
  * MAX_COMMAND_SIZE is:
  * The longest fixed-length SCSI CDB as per the SCSI standard.
@@ -52,6 +53,9 @@ struct scsi_pointer {
        volatile int phase;
 };
 
+/* for scmd->flags */
+#define SCMD_TAGGED            (1 << 0)
+
 struct scsi_cmnd {
        struct scsi_device *device;
        struct list_head list;  /* scsi_cmnd participates in queue lists */
@@ -81,6 +85,7 @@ struct scsi_cmnd {
 
        unsigned char prot_op;
        unsigned char prot_type;
+       unsigned char prot_flags;
 
        unsigned short cmd_len;
        enum dma_data_direction sc_data_direction;
@@ -130,6 +135,7 @@ struct scsi_cmnd {
                                         * to be at an address < 16Mb). */
 
        int result;             /* Status code from lower level driver */
+       int flags;              /* Command flags */
 
        unsigned char tag;      /* SCSI-II queued command tag */
 };
@@ -157,7 +163,7 @@ extern void *scsi_kmap_atomic_sg(struct scatterlist *sg, int sg_count,
                                 size_t *offset, size_t *len);
 extern void scsi_kunmap_atomic_sg(void *virt);
 
-extern int scsi_init_io(struct scsi_cmnd *cmd, gfp_t gfp_mask);
+extern int scsi_init_io(struct scsi_cmnd *cmd);
 
 extern int scsi_dma_map(struct scsi_cmnd *cmd);
 extern void scsi_dma_unmap(struct scsi_cmnd *cmd);
@@ -252,6 +258,14 @@ static inline unsigned char scsi_get_prot_op(struct scsi_cmnd *scmd)
        return scmd->prot_op;
 }
 
+enum scsi_prot_flags {
+       SCSI_PROT_TRANSFER_PI           = 1 << 0,
+       SCSI_PROT_GUARD_CHECK           = 1 << 1,
+       SCSI_PROT_REF_CHECK             = 1 << 2,
+       SCSI_PROT_REF_INCREMENT         = 1 << 3,
+       SCSI_PROT_IP_CHECKSUM           = 1 << 4,
+};
+
 /*
  * The controller usually does not know anything about the target it
  * is communicating with.  However, when DIX is enabled the controller
@@ -280,6 +294,17 @@ static inline sector_t scsi_get_lba(struct scsi_cmnd *scmd)
        return blk_rq_pos(scmd->request);
 }
 
+static inline unsigned int scsi_prot_interval(struct scsi_cmnd *scmd)
+{
+       return scmd->device->sector_size;
+}
+
+static inline u32 scsi_prot_ref_tag(struct scsi_cmnd *scmd)
+{
+       return blk_rq_pos(scmd->request) >>
+               (ilog2(scsi_prot_interval(scmd)) - 9) & 0xffffffff;
+}
+
 static inline unsigned scsi_prot_sg_count(struct scsi_cmnd *cmd)
 {
        return cmd->prot_sdb ? cmd->prot_sdb->table.nents : 0;
@@ -316,17 +341,12 @@ static inline void set_driver_byte(struct scsi_cmnd *cmd, char status)
 static inline unsigned scsi_transfer_length(struct scsi_cmnd *scmd)
 {
        unsigned int xfer_len = scsi_out(scmd)->length;
-       unsigned int prot_op = scsi_get_prot_op(scmd);
-       unsigned int sector_size = scmd->device->sector_size;
+       unsigned int prot_interval = scsi_prot_interval(scmd);
 
-       switch (prot_op) {
-       case SCSI_PROT_NORMAL:
-       case SCSI_PROT_WRITE_STRIP:
-       case SCSI_PROT_READ_INSERT:
-               return xfer_len;
-       }
+       if (scmd->prot_flags & SCSI_PROT_TRANSFER_PI)
+               xfer_len += (xfer_len >> ilog2(prot_interval)) * 8;
 
-       return xfer_len + (xfer_len >> ilog2(sector_size)) * 8;
+       return xfer_len;
 }
 
 #endif /* _SCSI_SCSI_CMND_H */
This page took 0.027724 seconds and 5 git commands to generate.