fed up with those stupid warnings
[mmotm.git] / include / linux / virtio_blk.h
blob1e19470d2da21185272f40ab506b2c38c0558677
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_ids.h>
7 #include <linux/virtio_config.h>
9 /* Feature bits */
10 #define VIRTIO_BLK_F_BARRIER 0 /* Does host support barriers? */
11 #define VIRTIO_BLK_F_SIZE_MAX 1 /* Indicates maximum segment size */
12 #define VIRTIO_BLK_F_SEG_MAX 2 /* Indicates maximum # of segments */
13 #define VIRTIO_BLK_F_GEOMETRY 4 /* Legacy geometry available */
14 #define VIRTIO_BLK_F_RO 5 /* Disk is read-only */
15 #define VIRTIO_BLK_F_BLK_SIZE 6 /* Block size of disk is available*/
16 #define VIRTIO_BLK_F_SCSI 7 /* Supports scsi command passthru */
17 #define VIRTIO_BLK_F_IDENTIFY 8 /* ATA IDENTIFY supported */
18 #define VIRTIO_BLK_F_FLUSH 9 /* Cache flush command support */
20 #define VIRTIO_BLK_ID_BYTES (sizeof(__u16[256])) /* IDENTIFY DATA */
22 struct virtio_blk_config {
23 /* The capacity (in 512-byte sectors). */
24 __u64 capacity;
25 /* The maximum segment size (if VIRTIO_BLK_F_SIZE_MAX) */
26 __u32 size_max;
27 /* The maximum number of segments (if VIRTIO_BLK_F_SEG_MAX) */
28 __u32 seg_max;
29 /* geometry the device (if VIRTIO_BLK_F_GEOMETRY) */
30 struct virtio_blk_geometry {
31 __u16 cylinders;
32 __u8 heads;
33 __u8 sectors;
34 } geometry;
35 /* block size of device (if VIRTIO_BLK_F_BLK_SIZE) */
36 __u32 blk_size;
37 __u8 identify[VIRTIO_BLK_ID_BYTES];
38 } __attribute__((packed));
41 * Command types
43 * Usage is a bit tricky as some bits are used as flags and some are not.
45 * Rules:
46 * VIRTIO_BLK_T_OUT may be combined with VIRTIO_BLK_T_SCSI_CMD or
47 * VIRTIO_BLK_T_BARRIER. VIRTIO_BLK_T_FLUSH is a command of its own
48 * and may not be combined with any of the other flags.
51 /* These two define direction. */
52 #define VIRTIO_BLK_T_IN 0
53 #define VIRTIO_BLK_T_OUT 1
55 /* This bit says it's a scsi command, not an actual read or write. */
56 #define VIRTIO_BLK_T_SCSI_CMD 2
58 /* Cache flush command */
59 #define VIRTIO_BLK_T_FLUSH 4
61 /* Barrier before this op. */
62 #define VIRTIO_BLK_T_BARRIER 0x80000000
64 /* This is the first element of the read scatter-gather list. */
65 struct virtio_blk_outhdr {
66 /* VIRTIO_BLK_T* */
67 __u32 type;
68 /* io priority. */
69 __u32 ioprio;
70 /* Sector (ie. 512 byte offset) */
71 __u64 sector;
74 struct virtio_scsi_inhdr {
75 __u32 errors;
76 __u32 data_len;
77 __u32 sense_len;
78 __u32 residual;
81 /* And this is the final byte of the write scatter-gather list. */
82 #define VIRTIO_BLK_S_OK 0
83 #define VIRTIO_BLK_S_IOERR 1
84 #define VIRTIO_BLK_S_UNSUPP 2
85 #endif /* _LINUX_VIRTIO_BLK_H */