Commit | Line | Data |
---|---|---|
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 | ||
8 | /* The ID for virtio_block */ | |
9 | #define VIRTIO_ID_BLOCK 2 | |
10 | ||
11 | /* Feature bits */ | |
a586d4f6 RR |
12 | #define VIRTIO_BLK_F_BARRIER 0 /* Does host support barriers? */ |
13 | #define VIRTIO_BLK_F_SIZE_MAX 1 /* Indicates maximum segment size */ | |
14 | #define VIRTIO_BLK_F_SEG_MAX 2 /* Indicates maximum # of segments */ | |
48e4043d | 15 | #define VIRTIO_BLK_F_GEOMETRY 4 /* Legacy geometry available */ |
3ef53609 | 16 | #define VIRTIO_BLK_F_RO 5 /* Disk is read-only */ |
066f4d82 | 17 | #define VIRTIO_BLK_F_BLK_SIZE 6 /* Block size of disk is available*/ |
1cde26f9 | 18 | #define VIRTIO_BLK_F_SCSI 7 /* Supports scsi command passthru */ |
1d589bb1 | 19 | #define VIRTIO_BLK_F_IDENTIFY 8 /* ATA IDENTIFY supported */ |
20 | ||
21 | #define VIRTIO_BLK_ID_BYTES (sizeof(__u16[256])) /* IDENTIFY DATA */ | |
a586d4f6 RR |
22 | |
23 | struct virtio_blk_config | |
24 | { | |
25 | /* The capacity (in 512-byte sectors). */ | |
7757f09c | 26 | __u64 capacity; |
a586d4f6 | 27 | /* The maximum segment size (if VIRTIO_BLK_F_SIZE_MAX) */ |
7757f09c | 28 | __u32 size_max; |
a586d4f6 | 29 | /* The maximum number of segments (if VIRTIO_BLK_F_SEG_MAX) */ |
7757f09c | 30 | __u32 seg_max; |
48e4043d RH |
31 | /* geometry the device (if VIRTIO_BLK_F_GEOMETRY) */ |
32 | struct virtio_blk_geometry { | |
7757f09c | 33 | __u16 cylinders; |
48e4043d RH |
34 | __u8 heads; |
35 | __u8 sectors; | |
36 | } geometry; | |
066f4d82 CB |
37 | /* block size of device (if VIRTIO_BLK_F_BLK_SIZE) */ |
38 | __u32 blk_size; | |
1d589bb1 | 39 | __u8 identify[VIRTIO_BLK_ID_BYTES]; |
a586d4f6 | 40 | } __attribute__((packed)); |
e467cde2 RR |
41 | |
42 | /* These two define direction. */ | |
43 | #define VIRTIO_BLK_T_IN 0 | |
44 | #define VIRTIO_BLK_T_OUT 1 | |
45 | ||
46 | /* This bit says it's a scsi command, not an actual read or write. */ | |
47 | #define VIRTIO_BLK_T_SCSI_CMD 2 | |
48 | ||
49 | /* Barrier before this op. */ | |
50 | #define VIRTIO_BLK_T_BARRIER 0x80000000 | |
51 | ||
52 | /* This is the first element of the read scatter-gather list. */ | |
53 | struct virtio_blk_outhdr | |
54 | { | |
55 | /* VIRTIO_BLK_T* */ | |
56 | __u32 type; | |
57 | /* io priority. */ | |
58 | __u32 ioprio; | |
59 | /* Sector (ie. 512 byte offset) */ | |
60 | __u64 sector; | |
e467cde2 RR |
61 | }; |
62 | ||
1cde26f9 HR |
63 | struct virtio_scsi_inhdr { |
64 | __u32 errors; | |
65 | __u32 data_len; | |
66 | __u32 sense_len; | |
67 | __u32 residual; | |
68 | }; | |
69 | ||
cb38fa23 | 70 | /* And this is the final byte of the write scatter-gather list. */ |
e467cde2 RR |
71 | #define VIRTIO_BLK_S_OK 0 |
72 | #define VIRTIO_BLK_S_IOERR 1 | |
73 | #define VIRTIO_BLK_S_UNSUPP 2 | |
e467cde2 | 74 | #endif /* _LINUX_VIRTIO_BLK_H */ |