]> git.proxmox.com Git - qemu.git/blame - hw/virtio-blk.h
virtio-blk: support VIRTIO_BLK_F_CONFIG_WCE
[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"
31e404f4 18#include "hw/block-common.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 */
13e3dce0 34#define VIRTIO_BLK_F_WCE 9 /* write cache enabled */
9752c371 35#define VIRTIO_BLK_F_TOPOLOGY 10 /* Topology information is available */
13e3dce0 36#define VIRTIO_BLK_F_CONFIG_WCE 11 /* write cache configurable */
bf011293 37
a8686a9b
MA
38#define VIRTIO_BLK_ID_BYTES 20 /* ID string length */
39
6e02c38d
AL
40struct virtio_blk_config
41{
42 uint64_t capacity;
43 uint32_t size_max;
44 uint32_t seg_max;
45 uint16_t cylinders;
46 uint8_t heads;
47 uint8_t sectors;
8cfacf07 48 uint32_t blk_size;
9752c371
CH
49 uint8_t physical_block_exp;
50 uint8_t alignment_offset;
51 uint16_t min_io_size;
52 uint32_t opt_io_size;
13e3dce0 53 uint8_t wce;
541dc0d4 54} QEMU_PACKED;
6e02c38d
AL
55
56/* These two define direction. */
57#define VIRTIO_BLK_T_IN 0
58#define VIRTIO_BLK_T_OUT 1
59
60/* This bit says it's a scsi command, not an actual read or write. */
61#define VIRTIO_BLK_T_SCSI_CMD 2
62
aa659be3
CH
63/* Flush the volatile write cache */
64#define VIRTIO_BLK_T_FLUSH 4
65
2930b313 66/* return the device ID string */
67#define VIRTIO_BLK_T_GET_ID 8
68
6e02c38d
AL
69/* Barrier before this op. */
70#define VIRTIO_BLK_T_BARRIER 0x80000000
71
72/* This is the first element of the read scatter-gather list. */
73struct virtio_blk_outhdr
74{
75 /* VIRTIO_BLK_T* */
76 uint32_t type;
77 /* io priority. */
78 uint32_t ioprio;
79 /* Sector (ie. 512 byte offset) */
80 uint64_t sector;
81};
82
83#define VIRTIO_BLK_S_OK 0
84#define VIRTIO_BLK_S_IOERR 1
85#define VIRTIO_BLK_S_UNSUPP 2
86
8b91408b 87/* This is the last element of the write scatter-gather list */
6e02c38d
AL
88struct virtio_blk_inhdr
89{
90 unsigned char status;
91};
92
1063b8b1
CH
93/* SCSI pass-through header */
94struct virtio_scsi_inhdr
95{
96 uint32_t errors;
97 uint32_t data_len;
98 uint32_t sense_len;
99 uint32_t residual;
100};
101
12c5674b
PB
102struct VirtIOBlkConf
103{
104 BlockConf conf;
105 char *serial;
a6c5c84a 106 uint32_t scsi;
12c5674b
PB
107};
108
8172539d
MT
109#define DEFINE_VIRTIO_BLK_FEATURES(_state, _field) \
110 DEFINE_VIRTIO_COMMON_FEATURES(_state, _field)
12c5674b 111
6e02c38d 112#endif