Rusty Russell | e467cde | 2007-10-22 11:03:38 +1000 | [diff] [blame] | 1 | #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 Russell | a586d4f | 2008-02-04 23:49:56 -0500 | [diff] [blame] | 9 | #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 Harper | 48e4043 | 2008-04-16 13:56:37 -0500 | [diff] [blame] | 12 | #define VIRTIO_BLK_F_GEOMETRY 4 /* Legacy geometry available */ |
Christian Borntraeger | 3ef5360 | 2008-05-16 11:17:03 +0200 | [diff] [blame^] | 13 | #define VIRTIO_BLK_F_RO 5 /* Disk is read-only */ |
Rusty Russell | e467cde | 2007-10-22 11:03:38 +1000 | [diff] [blame] | 14 | |
Rusty Russell | a586d4f | 2008-02-04 23:49:56 -0500 | [diff] [blame] | 15 | struct virtio_blk_config |
| 16 | { |
| 17 | /* The capacity (in 512-byte sectors). */ |
| 18 | __le64 capacity; |
| 19 | /* The maximum segment size (if VIRTIO_BLK_F_SIZE_MAX) */ |
| 20 | __le32 size_max; |
| 21 | /* The maximum number of segments (if VIRTIO_BLK_F_SEG_MAX) */ |
| 22 | __le32 seg_max; |
Ryan Harper | 48e4043 | 2008-04-16 13:56:37 -0500 | [diff] [blame] | 23 | /* geometry the device (if VIRTIO_BLK_F_GEOMETRY) */ |
| 24 | struct virtio_blk_geometry { |
| 25 | __le16 cylinders; |
| 26 | __u8 heads; |
| 27 | __u8 sectors; |
| 28 | } geometry; |
Rusty Russell | a586d4f | 2008-02-04 23:49:56 -0500 | [diff] [blame] | 29 | } __attribute__((packed)); |
Rusty Russell | e467cde | 2007-10-22 11:03:38 +1000 | [diff] [blame] | 30 | |
| 31 | /* These two define direction. */ |
| 32 | #define VIRTIO_BLK_T_IN 0 |
| 33 | #define VIRTIO_BLK_T_OUT 1 |
| 34 | |
| 35 | /* This bit says it's a scsi command, not an actual read or write. */ |
| 36 | #define VIRTIO_BLK_T_SCSI_CMD 2 |
| 37 | |
| 38 | /* Barrier before this op. */ |
| 39 | #define VIRTIO_BLK_T_BARRIER 0x80000000 |
| 40 | |
| 41 | /* This is the first element of the read scatter-gather list. */ |
| 42 | struct virtio_blk_outhdr |
| 43 | { |
| 44 | /* VIRTIO_BLK_T* */ |
| 45 | __u32 type; |
| 46 | /* io priority. */ |
| 47 | __u32 ioprio; |
| 48 | /* Sector (ie. 512 byte offset) */ |
| 49 | __u64 sector; |
Rusty Russell | e467cde | 2007-10-22 11:03:38 +1000 | [diff] [blame] | 50 | }; |
| 51 | |
Rusty Russell | cb38fa2 | 2008-05-02 21:50:45 -0500 | [diff] [blame] | 52 | /* And this is the final byte of the write scatter-gather list. */ |
Rusty Russell | e467cde | 2007-10-22 11:03:38 +1000 | [diff] [blame] | 53 | #define VIRTIO_BLK_S_OK 0 |
| 54 | #define VIRTIO_BLK_S_IOERR 1 |
| 55 | #define VIRTIO_BLK_S_UNSUPP 2 |
Rusty Russell | e467cde | 2007-10-22 11:03:38 +1000 | [diff] [blame] | 56 | #endif /* _LINUX_VIRTIO_BLK_H */ |