blob: 6a66c7f30bcb52c0fa4f73a466f55d996818dd31 [file] [log] [blame]
Rusty Russelle467cde2007-10-22 11:03:38 +10001#ifndef _LINUX_VIRTIO_BLK_H
2#define _LINUX_VIRTIO_BLK_H
Rusty Russell674bfc22008-07-25 12:06:03 -05003/* This header is BSD licensed so anyone can use the definitions to implement
4 * compatible drivers/servers. */
Rusty Russelle467cde2007-10-22 11:03:38 +10005#include <linux/virtio_config.h>
6
7/* The ID for virtio_block */
8#define VIRTIO_ID_BLOCK 2
9
10/* Feature bits */
Rusty Russella586d4f2008-02-04 23:49:56 -050011#define VIRTIO_BLK_F_BARRIER 0 /* Does host support barriers? */
12#define VIRTIO_BLK_F_SIZE_MAX 1 /* Indicates maximum segment size */
13#define VIRTIO_BLK_F_SEG_MAX 2 /* Indicates maximum # of segments */
Ryan Harper48e40432008-04-16 13:56:37 -050014#define VIRTIO_BLK_F_GEOMETRY 4 /* Legacy geometry available */
Christian Borntraeger3ef53602008-05-16 11:17:03 +020015#define VIRTIO_BLK_F_RO 5 /* Disk is read-only */
Rusty Russelle467cde2007-10-22 11:03:38 +100016
Rusty Russella586d4f2008-02-04 23:49:56 -050017struct virtio_blk_config
18{
19 /* The capacity (in 512-byte sectors). */
Christian Borntraeger7757f092008-05-29 11:10:01 +020020 __u64 capacity;
Rusty Russella586d4f2008-02-04 23:49:56 -050021 /* The maximum segment size (if VIRTIO_BLK_F_SIZE_MAX) */
Christian Borntraeger7757f092008-05-29 11:10:01 +020022 __u32 size_max;
Rusty Russella586d4f2008-02-04 23:49:56 -050023 /* The maximum number of segments (if VIRTIO_BLK_F_SEG_MAX) */
Christian Borntraeger7757f092008-05-29 11:10:01 +020024 __u32 seg_max;
Ryan Harper48e40432008-04-16 13:56:37 -050025 /* geometry the device (if VIRTIO_BLK_F_GEOMETRY) */
26 struct virtio_blk_geometry {
Christian Borntraeger7757f092008-05-29 11:10:01 +020027 __u16 cylinders;
Ryan Harper48e40432008-04-16 13:56:37 -050028 __u8 heads;
29 __u8 sectors;
30 } geometry;
Rusty Russella586d4f2008-02-04 23:49:56 -050031} __attribute__((packed));
Rusty Russelle467cde2007-10-22 11:03:38 +100032
33/* These two define direction. */
34#define VIRTIO_BLK_T_IN 0
35#define VIRTIO_BLK_T_OUT 1
36
37/* This bit says it's a scsi command, not an actual read or write. */
38#define VIRTIO_BLK_T_SCSI_CMD 2
39
40/* Barrier before this op. */
41#define VIRTIO_BLK_T_BARRIER 0x80000000
42
43/* This is the first element of the read scatter-gather list. */
44struct virtio_blk_outhdr
45{
46 /* VIRTIO_BLK_T* */
47 __u32 type;
48 /* io priority. */
49 __u32 ioprio;
50 /* Sector (ie. 512 byte offset) */
51 __u64 sector;
Rusty Russelle467cde2007-10-22 11:03:38 +100052};
53
Rusty Russellcb38fa22008-05-02 21:50:45 -050054/* And this is the final byte of the write scatter-gather list. */
Rusty Russelle467cde2007-10-22 11:03:38 +100055#define VIRTIO_BLK_S_OK 0
56#define VIRTIO_BLK_S_IOERR 1
57#define VIRTIO_BLK_S_UNSUPP 2
Rusty Russelle467cde2007-10-22 11:03:38 +100058#endif /* _LINUX_VIRTIO_BLK_H */