2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
4 * This header is BSD licensed so anyone can use the definitions to implement
5 * compatible drivers/servers.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 #ifndef _VIRTIO_SCSI_H
32 #define _VIRTIO_SCSI_H
35 #define VIRTIO_SCSI_F_INOUT 0x0001 /* Single request can contain both
36 * read and write buffers */
37 #define VIRTIO_SCSI_F_HOTPLUG 0x0002 /* Host should enable hot plug/unplug
38 * of new LUNs and targets.
41 #define VIRTIO_SCSI_CDB_SIZE 32
42 #define VIRTIO_SCSI_SENSE_SIZE 96
44 /* SCSI command request, followed by data-out */
45 struct virtio_scsi_cmd_req {
46 uint8_t lun[8]; /* Logical Unit Number */
47 uint64_t tag; /* Command identifier */
48 uint8_t task_attr; /* Task attribute */
51 uint8_t cdb[VIRTIO_SCSI_CDB_SIZE];
54 /* Response, followed by sense data and data-in */
55 struct virtio_scsi_cmd_resp {
56 uint32_t sense_len; /* Sense data length */
57 uint32_t resid; /* Residual bytes in data buffer */
58 uint16_t status_qualifier; /* Status qualifier */
59 uint8_t status; /* Command completion status */
60 uint8_t response; /* Response values */
61 uint8_t sense[VIRTIO_SCSI_SENSE_SIZE];
64 /* Task Management Request */
65 struct virtio_scsi_ctrl_tmf_req {
72 struct virtio_scsi_ctrl_tmf_resp {
76 /* Asynchronous notification query/subscription */
77 struct virtio_scsi_ctrl_an_req {
80 uint32_t event_requested;
83 struct virtio_scsi_ctrl_an_resp {
84 uint32_t event_actual;
88 struct virtio_scsi_event {
94 struct virtio_scsi_config {
99 uint32_t event_info_size;
102 uint16_t max_channel;
108 #define VIRTIO_SCSI_S_OK 0
109 #define VIRTIO_SCSI_S_FUNCTION_COMPLETE 0
110 #define VIRTIO_SCSI_S_OVERRUN 1
111 #define VIRTIO_SCSI_S_ABORTED 2
112 #define VIRTIO_SCSI_S_BAD_TARGET 3
113 #define VIRTIO_SCSI_S_RESET 4
114 #define VIRTIO_SCSI_S_BUSY 5
115 #define VIRTIO_SCSI_S_TRANSPORT_FAILURE 6
116 #define VIRTIO_SCSI_S_TARGET_FAILURE 7
117 #define VIRTIO_SCSI_S_NEXUS_FAILURE 8
118 #define VIRTIO_SCSI_S_FAILURE 9
119 #define VIRTIO_SCSI_S_FUNCTION_SUCCEEDED 10
120 #define VIRTIO_SCSI_S_FUNCTION_REJECTED 11
121 #define VIRTIO_SCSI_S_INCORRECT_LUN 12
123 /* Controlq type codes. */
124 #define VIRTIO_SCSI_T_TMF 0
125 #define VIRTIO_SCSI_T_AN_QUERY 1
126 #define VIRTIO_SCSI_T_AN_SUBSCRIBE 2
128 /* Valid TMF subtypes. */
129 #define VIRTIO_SCSI_T_TMF_ABORT_TASK 0
130 #define VIRTIO_SCSI_T_TMF_ABORT_TASK_SET 1
131 #define VIRTIO_SCSI_T_TMF_CLEAR_ACA 2
132 #define VIRTIO_SCSI_T_TMF_CLEAR_TASK_SET 3
133 #define VIRTIO_SCSI_T_TMF_I_T_NEXUS_RESET 4
134 #define VIRTIO_SCSI_T_TMF_LOGICAL_UNIT_RESET 5
135 #define VIRTIO_SCSI_T_TMF_QUERY_TASK 6
136 #define VIRTIO_SCSI_T_TMF_QUERY_TASK_SET 7
139 #define VIRTIO_SCSI_T_EVENTS_MISSED 0x80000000
140 #define VIRTIO_SCSI_T_NO_EVENT 0
141 #define VIRTIO_SCSI_T_TRANSPORT_RESET 1
142 #define VIRTIO_SCSI_T_ASYNC_NOTIFY 2
144 /* Reasons of transport reset event */
145 #define VIRTIO_SCSI_EVT_RESET_HARD 0
146 #define VIRTIO_SCSI_EVT_RESET_RESCAN 1
147 #define VIRTIO_SCSI_EVT_RESET_REMOVED 2
149 #define VIRTIO_SCSI_S_SIMPLE 0
150 #define VIRTIO_SCSI_S_ORDERED 1
151 #define VIRTIO_SCSI_S_HEAD 2
152 #define VIRTIO_SCSI_S_ACA 3
154 #endif /* _VIRTIO_SCSI_H */