aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/linux/virtio_scsi.h15
-rw-r--r--include/scsi/scsi_cmnd.h17
-rw-r--r--include/target/iscsi/iscsi_transport.h3
-rw-r--r--include/target/target_core_backend.h1
4 files changed, 34 insertions, 2 deletions
diff --git a/include/linux/virtio_scsi.h b/include/linux/virtio_scsi.h
index 4195b97a3def..de429d1f4357 100644
--- a/include/linux/virtio_scsi.h
+++ b/include/linux/virtio_scsi.h
@@ -35,11 +35,23 @@ struct virtio_scsi_cmd_req {
35 u8 lun[8]; /* Logical Unit Number */ 35 u8 lun[8]; /* Logical Unit Number */
36 u64 tag; /* Command identifier */ 36 u64 tag; /* Command identifier */
37 u8 task_attr; /* Task attribute */ 37 u8 task_attr; /* Task attribute */
38 u8 prio; 38 u8 prio; /* SAM command priority field */
39 u8 crn; 39 u8 crn;
40 u8 cdb[VIRTIO_SCSI_CDB_SIZE]; 40 u8 cdb[VIRTIO_SCSI_CDB_SIZE];
41} __packed; 41} __packed;
42 42
43/* SCSI command request, followed by protection information */
44struct virtio_scsi_cmd_req_pi {
45 u8 lun[8]; /* Logical Unit Number */
46 u64 tag; /* Command identifier */
47 u8 task_attr; /* Task attribute */
48 u8 prio; /* SAM command priority field */
49 u8 crn;
50 u32 pi_bytesout; /* DataOUT PI Number of bytes */
51 u32 pi_bytesin; /* DataIN PI Number of bytes */
52 u8 cdb[VIRTIO_SCSI_CDB_SIZE];
53} __packed;
54
43/* Response, followed by sense data and data-in */ 55/* Response, followed by sense data and data-in */
44struct virtio_scsi_cmd_resp { 56struct virtio_scsi_cmd_resp {
45 u32 sense_len; /* Sense data length */ 57 u32 sense_len; /* Sense data length */
@@ -97,6 +109,7 @@ struct virtio_scsi_config {
97#define VIRTIO_SCSI_F_INOUT 0 109#define VIRTIO_SCSI_F_INOUT 0
98#define VIRTIO_SCSI_F_HOTPLUG 1 110#define VIRTIO_SCSI_F_HOTPLUG 1
99#define VIRTIO_SCSI_F_CHANGE 2 111#define VIRTIO_SCSI_F_CHANGE 2
112#define VIRTIO_SCSI_F_T10_PI 3
100 113
101/* Response codes */ 114/* Response codes */
102#define VIRTIO_SCSI_S_OK 0 115#define VIRTIO_SCSI_S_OK 0
diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h
index e016e2ac38df..42ed789ebafc 100644
--- a/include/scsi/scsi_cmnd.h
+++ b/include/scsi/scsi_cmnd.h
@@ -7,6 +7,7 @@
7#include <linux/types.h> 7#include <linux/types.h>
8#include <linux/timer.h> 8#include <linux/timer.h>
9#include <linux/scatterlist.h> 9#include <linux/scatterlist.h>
10#include <scsi/scsi_device.h>
10 11
11struct Scsi_Host; 12struct Scsi_Host;
12struct scsi_device; 13struct scsi_device;
@@ -315,4 +316,20 @@ static inline void set_driver_byte(struct scsi_cmnd *cmd, char status)
315 cmd->result = (cmd->result & 0x00ffffff) | (status << 24); 316 cmd->result = (cmd->result & 0x00ffffff) | (status << 24);
316} 317}
317 318
319static inline unsigned scsi_transfer_length(struct scsi_cmnd *scmd)
320{
321 unsigned int xfer_len = blk_rq_bytes(scmd->request);
322 unsigned int prot_op = scsi_get_prot_op(scmd);
323 unsigned int sector_size = scmd->device->sector_size;
324
325 switch (prot_op) {
326 case SCSI_PROT_NORMAL:
327 case SCSI_PROT_WRITE_STRIP:
328 case SCSI_PROT_READ_INSERT:
329 return xfer_len;
330 }
331
332 return xfer_len + (xfer_len >> ilog2(sector_size)) * 8;
333}
334
318#endif /* _SCSI_SCSI_CMND_H */ 335#endif /* _SCSI_SCSI_CMND_H */
diff --git a/include/target/iscsi/iscsi_transport.h b/include/target/iscsi/iscsi_transport.h
index 33b487b5da92..daef9daa500c 100644
--- a/include/target/iscsi/iscsi_transport.h
+++ b/include/target/iscsi/iscsi_transport.h
@@ -70,7 +70,8 @@ extern void iscsit_build_nopin_rsp(struct iscsi_cmd *, struct iscsi_conn *,
70extern void iscsit_build_task_mgt_rsp(struct iscsi_cmd *, struct iscsi_conn *, 70extern void iscsit_build_task_mgt_rsp(struct iscsi_cmd *, struct iscsi_conn *,
71 struct iscsi_tm_rsp *); 71 struct iscsi_tm_rsp *);
72extern int iscsit_build_text_rsp(struct iscsi_cmd *, struct iscsi_conn *, 72extern int iscsit_build_text_rsp(struct iscsi_cmd *, struct iscsi_conn *,
73 struct iscsi_text_rsp *); 73 struct iscsi_text_rsp *,
74 enum iscsit_transport_type);
74extern void iscsit_build_reject(struct iscsi_cmd *, struct iscsi_conn *, 75extern void iscsit_build_reject(struct iscsi_cmd *, struct iscsi_conn *,
75 struct iscsi_reject *); 76 struct iscsi_reject *);
76extern int iscsit_build_logout_rsp(struct iscsi_cmd *, struct iscsi_conn *, 77extern int iscsit_build_logout_rsp(struct iscsi_cmd *, struct iscsi_conn *,
diff --git a/include/target/target_core_backend.h b/include/target/target_core_backend.h
index 3a1c1eea1fff..9adc1bca1178 100644
--- a/include/target/target_core_backend.h
+++ b/include/target/target_core_backend.h
@@ -59,6 +59,7 @@ int transport_subsystem_register(struct se_subsystem_api *);
59void transport_subsystem_release(struct se_subsystem_api *); 59void transport_subsystem_release(struct se_subsystem_api *);
60 60
61void target_complete_cmd(struct se_cmd *, u8); 61void target_complete_cmd(struct se_cmd *, u8);
62void target_complete_cmd_with_length(struct se_cmd *, u8, int);
62 63
63sense_reason_t spc_parse_cdb(struct se_cmd *cmd, unsigned int *size); 64sense_reason_t spc_parse_cdb(struct se_cmd *cmd, unsigned int *size);
64sense_reason_t spc_emulate_report_luns(struct se_cmd *cmd); 65sense_reason_t spc_emulate_report_luns(struct se_cmd *cmd);