1 #ifndef _LINUX_VIRTIO_BLK_H
2 #define _LINUX_VIRTIO_BLK_H
3 /* This header is BSD licensed so anyone can use the definitions to implement
4 * compatible drivers/servers. */
5 #include <linux/types.h>
6 #include <linux/virtio_config.h>
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 */
12 #define VIRTIO_BLK_F_GEOMETRY 4 /* Legacy geometry available */
13 #define VIRTIO_BLK_F_RO 5 /* Disk is read-only */
14 #define VIRTIO_BLK_F_BLK_SIZE 6 /* Block size of disk is available*/
15 #define VIRTIO_BLK_F_SCSI 7 /* Supports scsi command passthru */
16 #define VIRTIO_BLK_F_IDENTIFY 8 /* ATA IDENTIFY supported */
18 #define VIRTIO_BLK_ID_BYTES (sizeof(__u16[256])) /* IDENTIFY DATA */
20 struct virtio_blk_config {
21 /* The capacity (in 512-byte sectors). */
23 /* The maximum segment size (if VIRTIO_BLK_F_SIZE_MAX) */
25 /* The maximum number of segments (if VIRTIO_BLK_F_SEG_MAX) */
27 /* geometry the device (if VIRTIO_BLK_F_GEOMETRY) */
28 struct virtio_blk_geometry {
33 /* block size of device (if VIRTIO_BLK_F_BLK_SIZE) */
35 __u8 identify[VIRTIO_BLK_ID_BYTES];
36 } __attribute__((packed));
38 /* These two define direction. */
39 #define VIRTIO_BLK_T_IN 0
40 #define VIRTIO_BLK_T_OUT 1
42 /* This bit says it's a scsi command, not an actual read or write. */
43 #define VIRTIO_BLK_T_SCSI_CMD 2
45 /* Barrier before this op. */
46 #define VIRTIO_BLK_T_BARRIER 0x80000000
48 /* This is the first element of the read scatter-gather list. */
49 struct virtio_blk_outhdr {
54 /* Sector (ie. 512 byte offset) */
58 struct virtio_scsi_inhdr {
65 /* And this is the final byte of the write scatter-gather list. */
66 #define VIRTIO_BLK_S_OK 0
67 #define VIRTIO_BLK_S_IOERR 1
68 #define VIRTIO_BLK_S_UNSUPP 2
69 #endif /* _LINUX_VIRTIO_BLK_H */