vioscsireg.h revision 1.1.10.2 1 /* $OpenBSD: vioscsireg.h,v 1.1 2013/12/20 21:50:49 matthew Exp $ */
2 /*
3 * Copyright (c) 2013 Google Inc.
4 *
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 */
17
18 /* Configuration registers */
19 #define VIRTIO_SCSI_CONFIG_NUM_QUEUES 0 /* 32bit */
20 #define VIRTIO_SCSI_CONFIG_SEG_MAX 4 /* 32bit */
21 #define VIRTIO_SCSI_CONFIG_MAX_SECTORS 8 /* 32bit */
22 #define VIRTIO_SCSI_CONFIG_CMD_PER_LUN 12 /* 32bit */
23 #define VIRTIO_SCSI_CONFIG_EVENT_INFO_SIZE 16 /* 32bit */
24 #define VIRTIO_SCSI_CONFIG_SENSE_SIZE 20 /* 32bit */
25 #define VIRTIO_SCSI_CONFIG_CDB_SIZE 24 /* 32bit */
26 #define VIRTIO_SCSI_CONFIG_MAX_CHANNEL 28 /* 16bit */
27 #define VIRTIO_SCSI_CONFIG_MAX_TARGET 30 /* 16bit */
28 #define VIRTIO_SCSI_CONFIG_MAX_LUN 32 /* 32bit */
29
30 /* Feature bits */
31 #define VIRTIO_SCSI_F_INOUT (1<<0)
32 #define VIRTIO_SCSI_F_HOTPLUG (1<<1)
33
34 /* Response status values */
35 #define VIRTIO_SCSI_S_OK 0
36 #define VIRTIO_SCSI_S_OVERRUN 1
37 #define VIRTIO_SCSI_S_ABORTED 2
38 #define VIRTIO_SCSI_S_BAD_TARGET 3
39 #define VIRTIO_SCSI_S_RESET 4
40 #define VIRTIO_SCSI_S_BUSY 5
41 #define VIRTIO_SCSI_S_TRANSPORT_FAILURE 6
42 #define VIRTIO_SCSI_S_TARGET_FAILURE 7
43 #define VIRTIO_SCSI_S_NEXUS_FAILURE 8
44 #define VIRTIO_SCSI_S_FAILURE 9
45
46 /* Task attributes */
47 #define VIRTIO_SCSI_S_SIMPLE 0
48 #define VIRTIO_SCSI_S_ORDERED 1
49 #define VIRTIO_SCSI_S_HEAD 2
50 #define VIRTIO_SCSI_S_ACA 3
51
52 /* Request header structure */
53 struct virtio_scsi_req_hdr {
54 uint8_t lun[8];
55 uint64_t id;
56 uint8_t task_attr;
57 uint8_t prio;
58 uint8_t crn;
59 uint8_t cdb[32];
60 } __packed;
61 /* Followed by data-out. */
62
63 /* Response header structure */
64 struct virtio_scsi_res_hdr {
65 uint32_t sense_len;
66 uint32_t residual;
67 uint16_t status_qualifier;
68 uint8_t status;
69 uint8_t response;
70 uint8_t sense[96];
71 } __packed;
72 /* Followed by data-in. */
73