Add qemu 2.4.0
[kvmfornfv.git] / qemu / roms / SLOF / lib / libvirtio / virtio-scsi.h
1 /******************************************************************************
2  * Copyright (c) 2012 IBM Corporation
3  * All rights reserved.
4  * This program and the accompanying materials
5  * are made available under the terms of the BSD License
6  * which accompanies this distribution, and is available at
7  * http://www.opensource.org/licenses/bsd-license.php
8  *
9  * Contributors:
10  *     IBM Corporation - initial implementation
11  *****************************************************************************/
12
13 /*
14  * Virtio SCSI Host device definitions.
15  * See Virtio Spec, Appendix I, for details
16  */
17
18 #ifndef _VIRTIO_SCSI_H
19 #define _VIRTIO_SCSI_H
20
21 #define VIRTIO_SCSI_CDB_SIZE      32
22 #define VIRTIO_SCSI_SENSE_SIZE    96
23
24 #define VIRTIO_SCSI_CONTROL_VQ     0
25 #define VIRTIO_SCSI_EVENT_VQ       1
26 #define VIRTIO_SCSI_REQUEST_VQ     2
27
28 struct virtio_scsi_config
29 {
30     uint32_t num_queues;
31     uint32_t seg_max;
32     uint32_t max_sectors;
33     uint32_t cmd_per_lun;
34     uint32_t event_info_size;
35     uint32_t sense_size;
36     uint32_t cdb_size;
37     uint16_t max_channel;
38     uint16_t max_target;
39     uint32_t max_lun;
40 } __attribute__((packed));
41
42 /* This is the first element of the "out" scatter-gather list. */
43 struct virtio_scsi_req_cmd {
44     uint8_t lun[8];
45     uint64_t tag;
46     uint8_t task_attr;
47     uint8_t prio;
48     uint8_t crn;
49     char cdb[VIRTIO_SCSI_CDB_SIZE];
50 };
51
52 /* This is the first element of the "in" scatter-gather list. */
53 struct virtio_scsi_resp_cmd {
54     uint32_t sense_len;
55     uint32_t residual;
56     uint16_t status_qualifier;
57     uint8_t status;
58     uint8_t response;
59     uint8_t sense[VIRTIO_SCSI_SENSE_SIZE];
60 };
61
62 extern int virtioscsi_init(struct virtio_device *dev);
63 extern void virtioscsi_shutdown(struct virtio_device *dev);
64 extern int virtioscsi_send(struct virtio_device *dev,
65                            struct virtio_scsi_req_cmd *req,
66                            struct virtio_scsi_resp_cmd *resp,
67                            int is_read, void *buf, uint64_t buf_len);
68
69 #endif /*  _VIRTIO_SCSI_H */