code style scripts/checkpatch.pl (linux-3.9-rc1) formatting
[linux-2.6.34.14-moxart.git] / include / linux / virtio_blk.h
blobe52029e98919bb38401dd1848de418277ba271a9
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_FLUSH 9 /* Cache flush command support */
18 #define VIRTIO_BLK_F_TOPOLOGY 10 /* Topology information is available */
20 struct virtio_blk_config {
21 /* The capacity (in 512-byte sectors). */
22 __u64 capacity;
23 /* The maximum segment size (if VIRTIO_BLK_F_SIZE_MAX) */
24 __u32 size_max;
25 /* The maximum number of segments (if VIRTIO_BLK_F_SEG_MAX) */
26 __u32 seg_max;
27 /* geometry the device (if VIRTIO_BLK_F_GEOMETRY) */
28 struct virtio_blk_geometry {
29 __u16 cylinders;
30 __u8 heads;
31 __u8 sectors;
32 } geometry;
34 /* block size of device (if VIRTIO_BLK_F_BLK_SIZE) */
35 __u32 blk_size;
37 /* the next 4 entries are guarded by VIRTIO_BLK_F_TOPOLOGY */
38 /* exponent for physical block per logical block. */
39 __u8 physical_block_exp;
40 /* alignment offset in logical blocks. */
41 __u8 alignment_offset;
42 /* minimum I/O size without performance penalty in logical blocks. */
43 __u16 min_io_size;
44 /* optimal sustained I/O size in logical blocks. */
45 __u32 opt_io_size;
47 } __attribute__((packed));
50 * Command types
52 * Usage is a bit tricky as some bits are used as flags and some are not.
54 * Rules:
55 * VIRTIO_BLK_T_OUT may be combined with VIRTIO_BLK_T_SCSI_CMD or
56 * VIRTIO_BLK_T_BARRIER. VIRTIO_BLK_T_FLUSH is a command of its own
57 * and may not be combined with any of the other flags.
60 /* These two define direction. */
61 #define VIRTIO_BLK_T_IN 0
62 #define VIRTIO_BLK_T_OUT 1
64 /* This bit says it's a scsi command, not an actual read or write. */
65 #define VIRTIO_BLK_T_SCSI_CMD 2
67 /* Cache flush command */
68 #define VIRTIO_BLK_T_FLUSH 4
70 /* Barrier before this op. */
71 #define VIRTIO_BLK_T_BARRIER 0x80000000
73 /* This is the first element of the read scatter-gather list. */
74 struct virtio_blk_outhdr {
75 /* VIRTIO_BLK_T* */
76 __u32 type;
77 /* io priority. */
78 __u32 ioprio;
79 /* Sector (ie. 512 byte offset) */
80 __u64 sector;
83 struct virtio_scsi_inhdr {
84 __u32 errors;
85 __u32 data_len;
86 __u32 sense_len;
87 __u32 residual;
90 /* And this is the final byte of the write scatter-gather list. */
91 #define VIRTIO_BLK_S_OK 0
92 #define VIRTIO_BLK_S_IOERR 1
93 #define VIRTIO_BLK_S_UNSUPP 2
94 #endif /* _LINUX_VIRTIO_BLK_H */