blob: 8ddeafdc05465da35e0530cd928992cc85b0ea5d [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
72/* Response codes */
73#define VIRTIO_SCSI_S_OK 0
74#define VIRTIO_SCSI_S_OVERRUN 1
75#define VIRTIO_SCSI_S_ABORTED 2
76#define VIRTIO_SCSI_S_BAD_TARGET 3
77#define VIRTIO_SCSI_S_RESET 4
78#define VIRTIO_SCSI_S_BUSY 5
79#define VIRTIO_SCSI_S_TRANSPORT_FAILURE 6
80#define VIRTIO_SCSI_S_TARGET_FAILURE 7
81#define VIRTIO_SCSI_S_NEXUS_FAILURE 8
82#define VIRTIO_SCSI_S_FAILURE 9
83#define VIRTIO_SCSI_S_FUNCTION_SUCCEEDED 10
84#define VIRTIO_SCSI_S_FUNCTION_REJECTED 11
85#define VIRTIO_SCSI_S_INCORRECT_LUN 12
86
87/* Controlq type codes. */
88#define VIRTIO_SCSI_T_TMF 0
89#define VIRTIO_SCSI_T_AN_QUERY 1
90#define VIRTIO_SCSI_T_AN_SUBSCRIBE 2
91
92/* Valid TMF subtypes. */
93#define VIRTIO_SCSI_T_TMF_ABORT_TASK 0
94#define VIRTIO_SCSI_T_TMF_ABORT_TASK_SET 1
95#define VIRTIO_SCSI_T_TMF_CLEAR_ACA 2
96#define VIRTIO_SCSI_T_TMF_CLEAR_TASK_SET 3
97#define VIRTIO_SCSI_T_TMF_I_T_NEXUS_RESET 4
98#define VIRTIO_SCSI_T_TMF_LOGICAL_UNIT_RESET 5
99#define VIRTIO_SCSI_T_TMF_QUERY_TASK 6
100#define VIRTIO_SCSI_T_TMF_QUERY_TASK_SET 7
101
102/* Events. */
103#define VIRTIO_SCSI_T_EVENTS_MISSED 0x80000000
104#define VIRTIO_SCSI_T_NO_EVENT 0
105#define VIRTIO_SCSI_T_TRANSPORT_RESET 1
106#define VIRTIO_SCSI_T_ASYNC_NOTIFY 2
107
108#define VIRTIO_SCSI_S_SIMPLE 0
109#define VIRTIO_SCSI_S_ORDERED 1
110#define VIRTIO_SCSI_S_HEAD 2
111#define VIRTIO_SCSI_S_ACA 3
112
113
114#endif /* _LINUX_VIRTIO_SCSI_H */