Merge branch 'cfq-2.6.33' into for-2.6.33
[linux-2.6/next.git] / include / linux / virtio_blk.h
blob15cb666581d7cbdb42cd7d39f4d309ac59399fb0
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>
8 /* Feature bits */
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 */
17 #define VIRTIO_BLK_F_FLUSH 9 /* Cache flush command support */
19 #define VIRTIO_BLK_ID_BYTES (sizeof(__u16[256])) /* IDENTIFY DATA */
21 struct virtio_blk_config {
22 /* The capacity (in 512-byte sectors). */
23 __u64 capacity;
24 /* The maximum segment size (if VIRTIO_BLK_F_SIZE_MAX) */
25 __u32 size_max;
26 /* The maximum number of segments (if VIRTIO_BLK_F_SEG_MAX) */
27 __u32 seg_max;
28 /* geometry the device (if VIRTIO_BLK_F_GEOMETRY) */
29 struct virtio_blk_geometry {
30 __u16 cylinders;
31 __u8 heads;
32 __u8 sectors;
33 } geometry;
34 /* block size of device (if VIRTIO_BLK_F_BLK_SIZE) */
35 __u32 blk_size;
36 __u8 identify[VIRTIO_BLK_ID_BYTES];
37 } __attribute__((packed));
40 * Command types
42 * Usage is a bit tricky as some bits are used as flags and some are not.
44 * Rules:
45 * VIRTIO_BLK_T_OUT may be combined with VIRTIO_BLK_T_SCSI_CMD or
46 * VIRTIO_BLK_T_BARRIER. VIRTIO_BLK_T_FLUSH is a command of its own
47 * and may not be combined with any of the other flags.
50 /* These two define direction. */
51 #define VIRTIO_BLK_T_IN 0
52 #define VIRTIO_BLK_T_OUT 1
54 /* This bit says it's a scsi command, not an actual read or write. */
55 #define VIRTIO_BLK_T_SCSI_CMD 2
57 /* Cache flush command */
58 #define VIRTIO_BLK_T_FLUSH 4
60 /* Barrier before this op. */
61 #define VIRTIO_BLK_T_BARRIER 0x80000000
63 /* This is the first element of the read scatter-gather list. */
64 struct virtio_blk_outhdr {
65 /* VIRTIO_BLK_T* */
66 __u32 type;
67 /* io priority. */
68 __u32 ioprio;
69 /* Sector (ie. 512 byte offset) */
70 __u64 sector;
73 struct virtio_scsi_inhdr {
74 __u32 errors;
75 __u32 data_len;
76 __u32 sense_len;
77 __u32 residual;
80 /* And this is the final byte of the write scatter-gather list. */
81 #define VIRTIO_BLK_S_OK 0
82 #define VIRTIO_BLK_S_IOERR 1
83 #define VIRTIO_BLK_S_UNSUPP 2
84 #endif /* _LINUX_VIRTIO_BLK_H */