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