oom: kill duplicate OOM_DISABLE check
[linux-2.6/cjktty.git] / include / linux / virtio_blk.h
blob167720d695ed00bb94b9174381de80f13fd6d009
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 #define VIRTIO_BLK_ID_BYTES 20 /* ID string length */
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;
36 /* block size of device (if VIRTIO_BLK_F_BLK_SIZE) */
37 __u32 blk_size;
39 /* the next 4 entries are guarded by VIRTIO_BLK_F_TOPOLOGY */
40 /* exponent for physical block per logical block. */
41 __u8 physical_block_exp;
42 /* alignment offset in logical blocks. */
43 __u8 alignment_offset;
44 /* minimum I/O size without performance penalty in logical blocks. */
45 __u16 min_io_size;
46 /* optimal sustained I/O size in logical blocks. */
47 __u32 opt_io_size;
49 } __attribute__((packed));
52 * Command types
54 * Usage is a bit tricky as some bits are used as flags and some are not.
56 * Rules:
57 * VIRTIO_BLK_T_OUT may be combined with VIRTIO_BLK_T_SCSI_CMD or
58 * VIRTIO_BLK_T_BARRIER. VIRTIO_BLK_T_FLUSH is a command of its own
59 * and may not be combined with any of the other flags.
62 /* These two define direction. */
63 #define VIRTIO_BLK_T_IN 0
64 #define VIRTIO_BLK_T_OUT 1
66 /* This bit says it's a scsi command, not an actual read or write. */
67 #define VIRTIO_BLK_T_SCSI_CMD 2
69 /* Cache flush command */
70 #define VIRTIO_BLK_T_FLUSH 4
72 /* Get device ID command */
73 #define VIRTIO_BLK_T_GET_ID 8
75 /* Barrier before this op. */
76 #define VIRTIO_BLK_T_BARRIER 0x80000000
78 /* This is the first element of the read scatter-gather list. */
79 struct virtio_blk_outhdr {
80 /* VIRTIO_BLK_T* */
81 __u32 type;
82 /* io priority. */
83 __u32 ioprio;
84 /* Sector (ie. 512 byte offset) */
85 __u64 sector;
88 struct virtio_scsi_inhdr {
89 __u32 errors;
90 __u32 data_len;
91 __u32 sense_len;
92 __u32 residual;
95 /* And this is the final byte of the write scatter-gather list. */
96 #define VIRTIO_BLK_S_OK 0
97 #define VIRTIO_BLK_S_IOERR 1
98 #define VIRTIO_BLK_S_UNSUPP 2
99 #endif /* _LINUX_VIRTIO_BLK_H */