blob: d6b4440387b70a336d9da8af35e1224a20af04ba [file] [log] [blame]
Paolo Bonzini4fe74b12012-02-05 12:16:00 +01001#ifndef _LINUX_VIRTIO_SCSI_H
2#define _LINUX_VIRTIO_SCSI_H
3/* This header is BSD licensed so anyone can use the definitions to implement
4 * compatible drivers/servers. */
5
6#define VIRTIO_SCSI_CDB_SIZE 32
7#define VIRTIO_SCSI_SENSE_SIZE 96
8
9/* SCSI command request, followed by data-out */
10struct virtio_scsi_cmd_req {
11 u8 lun[8]; /* Logical Unit Number */
12 u64 tag; /* Command identifier */
13 u8 task_attr; /* Task attribute */
14 u8 prio;
15 u8 crn;
16 u8 cdb[VIRTIO_SCSI_CDB_SIZE];
17} __packed;
18
19/* Response, followed by sense data and data-in */
20struct virtio_scsi_cmd_resp {
21 u32 sense_len; /* Sense data length */
22 u32 resid; /* Residual bytes in data buffer */
23 u16 status_qualifier; /* Status qualifier */
24 u8 status; /* Command completion status */
25 u8 response; /* Response values */
26 u8 sense[VIRTIO_SCSI_SENSE_SIZE];
27} __packed;
28
29/* Task Management Request */
30struct virtio_scsi_ctrl_tmf_req {
31 u32 type;
32 u32 subtype;
33 u8 lun[8];
34 u64 tag;
35} __packed;
36
37struct virtio_scsi_ctrl_tmf_resp {
38 u8 response;
39} __packed;
40
41/* Asynchronous notification query/subscription */
42struct virtio_scsi_ctrl_an_req {
43 u32 type;
44 u8 lun[8];
45 u32 event_requested;
46} __packed;
47
48struct virtio_scsi_ctrl_an_resp {
49 u32 event_actual;
50 u8 response;
51} __packed;
52
53struct virtio_scsi_event {
54 u32 event;
55 u8 lun[8];
56 u32 reason;
57} __packed;
58
59struct virtio_scsi_config {
60 u32 num_queues;
61 u32 seg_max;
62 u32 max_sectors;
63 u32 cmd_per_lun;
64 u32 event_info_size;
65 u32 sense_size;
66 u32 cdb_size;
67 u16 max_channel;
68 u16 max_target;
69 u32 max_lun;
70} __packed;
71
Cong Meng365a7152012-07-05 17:06:43 +080072/* Feature Bits */
73#define VIRTIO_SCSI_F_INOUT 0
74#define VIRTIO_SCSI_F_HOTPLUG 1
Paolo Bonzini865b58c2012-10-02 17:25:48 +020075#define VIRTIO_SCSI_F_CHANGE 2
Cong Meng365a7152012-07-05 17:06:43 +080076
Paolo Bonzini4fe74b12012-02-05 12:16:00 +010077/* Response codes */
78#define VIRTIO_SCSI_S_OK 0
79#define VIRTIO_SCSI_S_OVERRUN 1
80#define VIRTIO_SCSI_S_ABORTED 2
81#define VIRTIO_SCSI_S_BAD_TARGET 3
82#define VIRTIO_SCSI_S_RESET 4
83#define VIRTIO_SCSI_S_BUSY 5
84#define VIRTIO_SCSI_S_TRANSPORT_FAILURE 6
85#define VIRTIO_SCSI_S_TARGET_FAILURE 7
86#define VIRTIO_SCSI_S_NEXUS_FAILURE 8
87#define VIRTIO_SCSI_S_FAILURE 9
88#define VIRTIO_SCSI_S_FUNCTION_SUCCEEDED 10
89#define VIRTIO_SCSI_S_FUNCTION_REJECTED 11
90#define VIRTIO_SCSI_S_INCORRECT_LUN 12
91
92/* Controlq type codes. */
93#define VIRTIO_SCSI_T_TMF 0
94#define VIRTIO_SCSI_T_AN_QUERY 1
95#define VIRTIO_SCSI_T_AN_SUBSCRIBE 2
96
97/* Valid TMF subtypes. */
98#define VIRTIO_SCSI_T_TMF_ABORT_TASK 0
99#define VIRTIO_SCSI_T_TMF_ABORT_TASK_SET 1
100#define VIRTIO_SCSI_T_TMF_CLEAR_ACA 2
101#define VIRTIO_SCSI_T_TMF_CLEAR_TASK_SET 3
102#define VIRTIO_SCSI_T_TMF_I_T_NEXUS_RESET 4
103#define VIRTIO_SCSI_T_TMF_LOGICAL_UNIT_RESET 5
104#define VIRTIO_SCSI_T_TMF_QUERY_TASK 6
105#define VIRTIO_SCSI_T_TMF_QUERY_TASK_SET 7
106
107/* Events. */
108#define VIRTIO_SCSI_T_EVENTS_MISSED 0x80000000
109#define VIRTIO_SCSI_T_NO_EVENT 0
110#define VIRTIO_SCSI_T_TRANSPORT_RESET 1
111#define VIRTIO_SCSI_T_ASYNC_NOTIFY 2
Paolo Bonzini865b58c2012-10-02 17:25:48 +0200112#define VIRTIO_SCSI_T_PARAM_CHANGE 3
Paolo Bonzini4fe74b12012-02-05 12:16:00 +0100113
Cong Meng365a7152012-07-05 17:06:43 +0800114/* Reasons of transport reset event */
115#define VIRTIO_SCSI_EVT_RESET_HARD 0
116#define VIRTIO_SCSI_EVT_RESET_RESCAN 1
117#define VIRTIO_SCSI_EVT_RESET_REMOVED 2
118
Paolo Bonzini4fe74b12012-02-05 12:16:00 +0100119#define VIRTIO_SCSI_S_SIMPLE 0
120#define VIRTIO_SCSI_S_ORDERED 1
121#define VIRTIO_SCSI_S_HEAD 2
122#define VIRTIO_SCSI_S_ACA 3
123
124
125#endif /* _LINUX_VIRTIO_SCSI_H */