blob: d4695a3356d018f4198df0d5813070cc4b5cf5ad [file] [log] [blame]
Rusty Russelle467cde2007-10-22 11:03:38 +10001#ifndef _LINUX_VIRTIO_BLK_H
2#define _LINUX_VIRTIO_BLK_H
3#include <linux/virtio_config.h>
4
5/* The ID for virtio_block */
6#define VIRTIO_ID_BLOCK 2
7
8/* Feature bits */
Rusty Russella586d4f2008-02-04 23:49:56 -05009#define VIRTIO_BLK_F_BARRIER 0 /* Does host support barriers? */
10#define VIRTIO_BLK_F_SIZE_MAX 1 /* Indicates maximum segment size */
11#define VIRTIO_BLK_F_SEG_MAX 2 /* Indicates maximum # of segments */
Ryan Harper48e40432008-04-16 13:56:37 -050012#define VIRTIO_BLK_F_GEOMETRY 4 /* Legacy geometry available */
Rusty Russelle467cde2007-10-22 11:03:38 +100013
Rusty Russella586d4f2008-02-04 23:49:56 -050014struct virtio_blk_config
15{
16 /* The capacity (in 512-byte sectors). */
17 __le64 capacity;
18 /* The maximum segment size (if VIRTIO_BLK_F_SIZE_MAX) */
19 __le32 size_max;
20 /* The maximum number of segments (if VIRTIO_BLK_F_SEG_MAX) */
21 __le32 seg_max;
Ryan Harper48e40432008-04-16 13:56:37 -050022 /* geometry the device (if VIRTIO_BLK_F_GEOMETRY) */
23 struct virtio_blk_geometry {
24 __le16 cylinders;
25 __u8 heads;
26 __u8 sectors;
27 } geometry;
Rusty Russella586d4f2008-02-04 23:49:56 -050028} __attribute__((packed));
Rusty Russelle467cde2007-10-22 11:03:38 +100029
30/* These two define direction. */
31#define VIRTIO_BLK_T_IN 0
32#define VIRTIO_BLK_T_OUT 1
33
34/* This bit says it's a scsi command, not an actual read or write. */
35#define VIRTIO_BLK_T_SCSI_CMD 2
36
37/* Barrier before this op. */
38#define VIRTIO_BLK_T_BARRIER 0x80000000
39
40/* This is the first element of the read scatter-gather list. */
41struct virtio_blk_outhdr
42{
43 /* VIRTIO_BLK_T* */
44 __u32 type;
45 /* io priority. */
46 __u32 ioprio;
47 /* Sector (ie. 512 byte offset) */
48 __u64 sector;
Rusty Russelle467cde2007-10-22 11:03:38 +100049};
50
Rusty Russellcb38fa22008-05-02 21:50:45 -050051/* And this is the final byte of the write scatter-gather list. */
Rusty Russelle467cde2007-10-22 11:03:38 +100052#define VIRTIO_BLK_S_OK 0
53#define VIRTIO_BLK_S_IOERR 1
54#define VIRTIO_BLK_S_UNSUPP 2
Rusty Russelle467cde2007-10-22 11:03:38 +100055#endif /* _LINUX_VIRTIO_BLK_H */