.. | .. |
---|
38 | 38 | #define VIRTIO_BLK_F_BLK_SIZE 6 /* Block size of disk is available*/ |
---|
39 | 39 | #define VIRTIO_BLK_F_TOPOLOGY 10 /* Topology information is available */ |
---|
40 | 40 | #define VIRTIO_BLK_F_MQ 12 /* support more than one vq */ |
---|
| 41 | +#define VIRTIO_BLK_F_DISCARD 13 /* DISCARD is supported */ |
---|
| 42 | +#define VIRTIO_BLK_F_WRITE_ZEROES 14 /* WRITE ZEROES is supported */ |
---|
41 | 43 | |
---|
42 | 44 | /* Legacy feature bits */ |
---|
43 | 45 | #ifndef VIRTIO_BLK_NO_LEGACY |
---|
.. | .. |
---|
55 | 57 | |
---|
56 | 58 | struct virtio_blk_config { |
---|
57 | 59 | /* The capacity (in 512-byte sectors). */ |
---|
58 | | - __u64 capacity; |
---|
| 60 | + __virtio64 capacity; |
---|
59 | 61 | /* The maximum segment size (if VIRTIO_BLK_F_SIZE_MAX) */ |
---|
60 | | - __u32 size_max; |
---|
| 62 | + __virtio32 size_max; |
---|
61 | 63 | /* The maximum number of segments (if VIRTIO_BLK_F_SEG_MAX) */ |
---|
62 | | - __u32 seg_max; |
---|
| 64 | + __virtio32 seg_max; |
---|
63 | 65 | /* geometry of the device (if VIRTIO_BLK_F_GEOMETRY) */ |
---|
64 | 66 | struct virtio_blk_geometry { |
---|
65 | | - __u16 cylinders; |
---|
| 67 | + __virtio16 cylinders; |
---|
66 | 68 | __u8 heads; |
---|
67 | 69 | __u8 sectors; |
---|
68 | 70 | } geometry; |
---|
69 | 71 | |
---|
70 | 72 | /* block size of device (if VIRTIO_BLK_F_BLK_SIZE) */ |
---|
71 | | - __u32 blk_size; |
---|
| 73 | + __virtio32 blk_size; |
---|
72 | 74 | |
---|
73 | 75 | /* the next 4 entries are guarded by VIRTIO_BLK_F_TOPOLOGY */ |
---|
74 | 76 | /* exponent for physical block per logical block. */ |
---|
.. | .. |
---|
76 | 78 | /* alignment offset in logical blocks. */ |
---|
77 | 79 | __u8 alignment_offset; |
---|
78 | 80 | /* minimum I/O size without performance penalty in logical blocks. */ |
---|
79 | | - __u16 min_io_size; |
---|
| 81 | + __virtio16 min_io_size; |
---|
80 | 82 | /* optimal sustained I/O size in logical blocks. */ |
---|
81 | | - __u32 opt_io_size; |
---|
| 83 | + __virtio32 opt_io_size; |
---|
82 | 84 | |
---|
83 | 85 | /* writeback mode (if VIRTIO_BLK_F_CONFIG_WCE) */ |
---|
84 | 86 | __u8 wce; |
---|
85 | 87 | __u8 unused; |
---|
86 | 88 | |
---|
87 | 89 | /* number of vqs, only available when VIRTIO_BLK_F_MQ is set */ |
---|
88 | | - __u16 num_queues; |
---|
| 90 | + __virtio16 num_queues; |
---|
| 91 | + |
---|
| 92 | + /* the next 3 entries are guarded by VIRTIO_BLK_F_DISCARD */ |
---|
| 93 | + /* |
---|
| 94 | + * The maximum discard sectors (in 512-byte sectors) for |
---|
| 95 | + * one segment. |
---|
| 96 | + */ |
---|
| 97 | + __virtio32 max_discard_sectors; |
---|
| 98 | + /* |
---|
| 99 | + * The maximum number of discard segments in a |
---|
| 100 | + * discard command. |
---|
| 101 | + */ |
---|
| 102 | + __virtio32 max_discard_seg; |
---|
| 103 | + /* Discard commands must be aligned to this number of sectors. */ |
---|
| 104 | + __virtio32 discard_sector_alignment; |
---|
| 105 | + |
---|
| 106 | + /* the next 3 entries are guarded by VIRTIO_BLK_F_WRITE_ZEROES */ |
---|
| 107 | + /* |
---|
| 108 | + * The maximum number of write zeroes sectors (in 512-byte sectors) in |
---|
| 109 | + * one segment. |
---|
| 110 | + */ |
---|
| 111 | + __virtio32 max_write_zeroes_sectors; |
---|
| 112 | + /* |
---|
| 113 | + * The maximum number of segments in a write zeroes |
---|
| 114 | + * command. |
---|
| 115 | + */ |
---|
| 116 | + __virtio32 max_write_zeroes_seg; |
---|
| 117 | + /* |
---|
| 118 | + * Set if a VIRTIO_BLK_T_WRITE_ZEROES request may result in the |
---|
| 119 | + * deallocation of one or more of the sectors. |
---|
| 120 | + */ |
---|
| 121 | + __u8 write_zeroes_may_unmap; |
---|
| 122 | + |
---|
| 123 | + __u8 unused1[3]; |
---|
89 | 124 | } __attribute__((packed)); |
---|
90 | 125 | |
---|
91 | 126 | /* |
---|
.. | .. |
---|
114 | 149 | /* Get device ID command */ |
---|
115 | 150 | #define VIRTIO_BLK_T_GET_ID 8 |
---|
116 | 151 | |
---|
| 152 | +/* Discard command */ |
---|
| 153 | +#define VIRTIO_BLK_T_DISCARD 11 |
---|
| 154 | + |
---|
| 155 | +/* Write zeroes command */ |
---|
| 156 | +#define VIRTIO_BLK_T_WRITE_ZEROES 13 |
---|
| 157 | + |
---|
117 | 158 | #ifndef VIRTIO_BLK_NO_LEGACY |
---|
118 | 159 | /* Barrier before this op. */ |
---|
119 | 160 | #define VIRTIO_BLK_T_BARRIER 0x80000000 |
---|
.. | .. |
---|
133 | 174 | __virtio64 sector; |
---|
134 | 175 | }; |
---|
135 | 176 | |
---|
| 177 | +/* Unmap this range (only valid for write zeroes command) */ |
---|
| 178 | +#define VIRTIO_BLK_WRITE_ZEROES_FLAG_UNMAP 0x00000001 |
---|
| 179 | + |
---|
| 180 | +/* Discard/write zeroes range for each request. */ |
---|
| 181 | +struct virtio_blk_discard_write_zeroes { |
---|
| 182 | + /* discard/write zeroes start sector */ |
---|
| 183 | + __le64 sector; |
---|
| 184 | + /* number of discard/write zeroes sectors */ |
---|
| 185 | + __le32 num_sectors; |
---|
| 186 | + /* flags for this range */ |
---|
| 187 | + __le32 flags; |
---|
| 188 | +}; |
---|
| 189 | + |
---|
136 | 190 | #ifndef VIRTIO_BLK_NO_LEGACY |
---|
137 | 191 | struct virtio_scsi_inhdr { |
---|
138 | 192 | __virtio32 errors; |
---|