]> git.proxmox.com Git - qemu.git/blame - hw/virtio-blk.h
USB: add usb network redirection support
[qemu.git] / hw / virtio-blk.h
CommitLineData
6e02c38d
AL
1/*
2 * Virtio Block Device
3 *
4 * Copyright IBM, Corp. 2007
5 *
6 * Authors:
7 * Anthony Liguori <aliguori@us.ibm.com>
8 *
9 * This work is licensed under the terms of the GNU GPL, version 2. See
10 * the COPYING file in the top-level directory.
11 *
12 */
13
14#ifndef _QEMU_VIRTIO_BLK_H
15#define _QEMU_VIRTIO_BLK_H
16
17#include "virtio.h"
18#include "block.h"
6e02c38d
AL
19
20/* from Linux's linux/virtio_blk.h */
21
22/* The ID for virtio_block */
23#define VIRTIO_ID_BLOCK 2
24
25/* Feature bits */
26#define VIRTIO_BLK_F_BARRIER 0 /* Does host support barriers? */
27#define VIRTIO_BLK_F_SIZE_MAX 1 /* Indicates maximum segment size */
28#define VIRTIO_BLK_F_SEG_MAX 2 /* Indicates maximum # of segments */
29#define VIRTIO_BLK_F_GEOMETRY 4 /* Indicates support of legacy geometry */
1063b8b1
CH
30#define VIRTIO_BLK_F_RO 5 /* Disk is read-only */
31#define VIRTIO_BLK_F_BLK_SIZE 6 /* Block size of disk is available*/
32#define VIRTIO_BLK_F_SCSI 7 /* Supports scsi command passthru */
37d5ddd6 33/* #define VIRTIO_BLK_F_IDENTIFY 8 ATA IDENTIFY supported, DEPRECATED */
aa659be3 34#define VIRTIO_BLK_F_WCACHE 9 /* write cache enabled */
9752c371 35#define VIRTIO_BLK_F_TOPOLOGY 10 /* Topology information is available */
bf011293 36
a8686a9b
MA
37#define VIRTIO_BLK_ID_BYTES 20 /* ID string length */
38
6e02c38d
AL
39struct virtio_blk_config
40{
41 uint64_t capacity;
42 uint32_t size_max;
43 uint32_t seg_max;
44 uint16_t cylinders;
45 uint8_t heads;
46 uint8_t sectors;
8cfacf07 47 uint32_t blk_size;
9752c371
CH
48 uint8_t physical_block_exp;
49 uint8_t alignment_offset;
50 uint16_t min_io_size;
51 uint32_t opt_io_size;
6e02c38d
AL
52} __attribute__((packed));
53
54/* These two define direction. */
55#define VIRTIO_BLK_T_IN 0
56#define VIRTIO_BLK_T_OUT 1
57
58/* This bit says it's a scsi command, not an actual read or write. */
59#define VIRTIO_BLK_T_SCSI_CMD 2
60
aa659be3
CH
61/* Flush the volatile write cache */
62#define VIRTIO_BLK_T_FLUSH 4
63
2930b313 64/* return the device ID string */
65#define VIRTIO_BLK_T_GET_ID 8
66
6e02c38d
AL
67/* Barrier before this op. */
68#define VIRTIO_BLK_T_BARRIER 0x80000000
69
70/* This is the first element of the read scatter-gather list. */
71struct virtio_blk_outhdr
72{
73 /* VIRTIO_BLK_T* */
74 uint32_t type;
75 /* io priority. */
76 uint32_t ioprio;
77 /* Sector (ie. 512 byte offset) */
78 uint64_t sector;
79};
80
81#define VIRTIO_BLK_S_OK 0
82#define VIRTIO_BLK_S_IOERR 1
83#define VIRTIO_BLK_S_UNSUPP 2
84
8b91408b 85/* This is the last element of the write scatter-gather list */
6e02c38d
AL
86struct virtio_blk_inhdr
87{
88 unsigned char status;
89};
90
1063b8b1
CH
91/* SCSI pass-through header */
92struct virtio_scsi_inhdr
93{
94 uint32_t errors;
95 uint32_t data_len;
96 uint32_t sense_len;
97 uint32_t residual;
98};
99
8172539d
MT
100#ifdef __linux__
101#define DEFINE_VIRTIO_BLK_FEATURES(_state, _field) \
102 DEFINE_VIRTIO_COMMON_FEATURES(_state, _field), \
103 DEFINE_PROP_BIT("scsi", _state, _field, VIRTIO_BLK_F_SCSI, true)
104#else
105#define DEFINE_VIRTIO_BLK_FEATURES(_state, _field) \
106 DEFINE_VIRTIO_COMMON_FEATURES(_state, _field)
107#endif
6e02c38d 108#endif