Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
[deliverable/linux.git] / include / linux / virtio_blk.h
CommitLineData
e467cde2
RR
1#ifndef _LINUX_VIRTIO_BLK_H
2#define _LINUX_VIRTIO_BLK_H
674bfc23
RR
3/* This header is BSD licensed so anyone can use the definitions to implement
4 * compatible drivers/servers. */
982f8184 5#include <linux/types.h>
e467cde2
RR
6#include <linux/virtio_config.h>
7
e467cde2 8/* Feature bits */
a586d4f6
RR
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 */
48e4043d 12#define VIRTIO_BLK_F_GEOMETRY 4 /* Legacy geometry available */
3ef53609 13#define VIRTIO_BLK_F_RO 5 /* Disk is read-only */
066f4d82 14#define VIRTIO_BLK_F_BLK_SIZE 6 /* Block size of disk is available*/
1cde26f9 15#define VIRTIO_BLK_F_SCSI 7 /* Supports scsi command passthru */
1d589bb1 16#define VIRTIO_BLK_F_IDENTIFY 8 /* ATA IDENTIFY supported */
f1b0ef06 17#define VIRTIO_BLK_F_FLUSH 9 /* Cache flush command support */
1d589bb1 18
19#define VIRTIO_BLK_ID_BYTES (sizeof(__u16[256])) /* IDENTIFY DATA */
a586d4f6 20
1842f23c 21struct virtio_blk_config {
a586d4f6 22 /* The capacity (in 512-byte sectors). */
7757f09c 23 __u64 capacity;
a586d4f6 24 /* The maximum segment size (if VIRTIO_BLK_F_SIZE_MAX) */
7757f09c 25 __u32 size_max;
a586d4f6 26 /* The maximum number of segments (if VIRTIO_BLK_F_SEG_MAX) */
7757f09c 27 __u32 seg_max;
48e4043d
RH
28 /* geometry the device (if VIRTIO_BLK_F_GEOMETRY) */
29 struct virtio_blk_geometry {
7757f09c 30 __u16 cylinders;
48e4043d
RH
31 __u8 heads;
32 __u8 sectors;
33 } geometry;
066f4d82
CB
34 /* block size of device (if VIRTIO_BLK_F_BLK_SIZE) */
35 __u32 blk_size;
1d589bb1 36 __u8 identify[VIRTIO_BLK_ID_BYTES];
a586d4f6 37} __attribute__((packed));
e467cde2 38
f1b0ef06
CH
39/*
40 * Command types
41 *
42 * Usage is a bit tricky as some bits are used as flags and some are not.
43 *
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.
48 */
49
e467cde2
RR
50/* These two define direction. */
51#define VIRTIO_BLK_T_IN 0
52#define VIRTIO_BLK_T_OUT 1
53
54/* This bit says it's a scsi command, not an actual read or write. */
55#define VIRTIO_BLK_T_SCSI_CMD 2
56
f1b0ef06
CH
57/* Cache flush command */
58#define VIRTIO_BLK_T_FLUSH 4
59
e467cde2
RR
60/* Barrier before this op. */
61#define VIRTIO_BLK_T_BARRIER 0x80000000
62
63/* This is the first element of the read scatter-gather list. */
1842f23c 64struct virtio_blk_outhdr {
e467cde2
RR
65 /* VIRTIO_BLK_T* */
66 __u32 type;
67 /* io priority. */
68 __u32 ioprio;
69 /* Sector (ie. 512 byte offset) */
70 __u64 sector;
e467cde2
RR
71};
72
1cde26f9
HR
73struct virtio_scsi_inhdr {
74 __u32 errors;
75 __u32 data_len;
76 __u32 sense_len;
77 __u32 residual;
78};
79
cb38fa23 80/* And this is the final byte of the write scatter-gather list. */
e467cde2
RR
81#define VIRTIO_BLK_S_OK 0
82#define VIRTIO_BLK_S_IOERR 1
83#define VIRTIO_BLK_S_UNSUPP 2
e467cde2 84#endif /* _LINUX_VIRTIO_BLK_H */
This page took 0.357701 seconds and 5 git commands to generate.