1 /* 2 * This file is auto-generated. Modifications will be lost. 3 * 4 * See https://android.googlesource.com/platform/bionic/+/master/libc/kernel/ 5 * for more information. 6 */ 7 #ifndef _LINUX_VIRTIO_BLK_H 8 #define _LINUX_VIRTIO_BLK_H 9 #include <linux/types.h> 10 #include <linux/virtio_ids.h> 11 #include <linux/virtio_config.h> 12 #include <linux/virtio_types.h> 13 #define VIRTIO_BLK_F_SIZE_MAX 1 14 #define VIRTIO_BLK_F_SEG_MAX 2 15 #define VIRTIO_BLK_F_GEOMETRY 4 16 #define VIRTIO_BLK_F_RO 5 17 #define VIRTIO_BLK_F_BLK_SIZE 6 18 #define VIRTIO_BLK_F_TOPOLOGY 10 19 #define VIRTIO_BLK_F_MQ 12 20 #define VIRTIO_BLK_F_DISCARD 13 21 #define VIRTIO_BLK_F_WRITE_ZEROES 14 22 #define VIRTIO_BLK_F_SECURE_ERASE 16 23 #define VIRTIO_BLK_F_ZONED 17 24 #ifndef VIRTIO_BLK_NO_LEGACY 25 #define VIRTIO_BLK_F_BARRIER 0 26 #define VIRTIO_BLK_F_SCSI 7 27 #define VIRTIO_BLK_F_FLUSH 9 28 #define VIRTIO_BLK_F_CONFIG_WCE 11 29 #define VIRTIO_BLK_F_WCE VIRTIO_BLK_F_FLUSH 30 #endif 31 #define VIRTIO_BLK_ID_BYTES 20 32 struct virtio_blk_config { 33 __virtio64 capacity; 34 __virtio32 size_max; 35 __virtio32 seg_max; 36 struct virtio_blk_geometry { 37 __virtio16 cylinders; 38 __u8 heads; 39 __u8 sectors; 40 } geometry; 41 __virtio32 blk_size; 42 __u8 physical_block_exp; 43 __u8 alignment_offset; 44 __virtio16 min_io_size; 45 __virtio32 opt_io_size; 46 __u8 wce; 47 __u8 unused; 48 __virtio16 num_queues; 49 __virtio32 max_discard_sectors; 50 __virtio32 max_discard_seg; 51 __virtio32 discard_sector_alignment; 52 __virtio32 max_write_zeroes_sectors; 53 __virtio32 max_write_zeroes_seg; 54 __u8 write_zeroes_may_unmap; 55 __u8 unused1[3]; 56 __virtio32 max_secure_erase_sectors; 57 __virtio32 max_secure_erase_seg; 58 __virtio32 secure_erase_sector_alignment; 59 struct virtio_blk_zoned_characteristics { 60 __virtio32 zone_sectors; 61 __virtio32 max_open_zones; 62 __virtio32 max_active_zones; 63 __virtio32 max_append_sectors; 64 __virtio32 write_granularity; 65 __u8 model; 66 __u8 unused2[3]; 67 } zoned; 68 } __attribute__((packed)); 69 #define VIRTIO_BLK_T_IN 0 70 #define VIRTIO_BLK_T_OUT 1 71 #ifndef VIRTIO_BLK_NO_LEGACY 72 #define VIRTIO_BLK_T_SCSI_CMD 2 73 #endif 74 #define VIRTIO_BLK_T_FLUSH 4 75 #define VIRTIO_BLK_T_GET_ID 8 76 #define VIRTIO_BLK_T_DISCARD 11 77 #define VIRTIO_BLK_T_WRITE_ZEROES 13 78 #define VIRTIO_BLK_T_SECURE_ERASE 14 79 #define VIRTIO_BLK_T_ZONE_APPEND 15 80 #define VIRTIO_BLK_T_ZONE_REPORT 16 81 #define VIRTIO_BLK_T_ZONE_OPEN 18 82 #define VIRTIO_BLK_T_ZONE_CLOSE 20 83 #define VIRTIO_BLK_T_ZONE_FINISH 22 84 #define VIRTIO_BLK_T_ZONE_RESET 24 85 #define VIRTIO_BLK_T_ZONE_RESET_ALL 26 86 #ifndef VIRTIO_BLK_NO_LEGACY 87 #define VIRTIO_BLK_T_BARRIER 0x80000000 88 #endif 89 struct virtio_blk_outhdr { 90 __virtio32 type; 91 __virtio32 ioprio; 92 __virtio64 sector; 93 }; 94 #define VIRTIO_BLK_Z_NONE 0 95 #define VIRTIO_BLK_Z_HM 1 96 #define VIRTIO_BLK_Z_HA 2 97 struct virtio_blk_zone_descriptor { 98 __virtio64 z_cap; 99 __virtio64 z_start; 100 __virtio64 z_wp; 101 __u8 z_type; 102 __u8 z_state; 103 __u8 reserved[38]; 104 }; 105 struct virtio_blk_zone_report { 106 __virtio64 nr_zones; 107 __u8 reserved[56]; 108 struct virtio_blk_zone_descriptor zones[]; 109 }; 110 #define VIRTIO_BLK_ZT_CONV 1 111 #define VIRTIO_BLK_ZT_SWR 2 112 #define VIRTIO_BLK_ZT_SWP 3 113 #define VIRTIO_BLK_ZS_NOT_WP 0 114 #define VIRTIO_BLK_ZS_EMPTY 1 115 #define VIRTIO_BLK_ZS_IOPEN 2 116 #define VIRTIO_BLK_ZS_EOPEN 3 117 #define VIRTIO_BLK_ZS_CLOSED 4 118 #define VIRTIO_BLK_ZS_RDONLY 13 119 #define VIRTIO_BLK_ZS_FULL 14 120 #define VIRTIO_BLK_ZS_OFFLINE 15 121 #define VIRTIO_BLK_WRITE_ZEROES_FLAG_UNMAP 0x00000001 122 struct virtio_blk_discard_write_zeroes { 123 __le64 sector; 124 __le32 num_sectors; 125 __le32 flags; 126 }; 127 #ifndef VIRTIO_BLK_NO_LEGACY 128 struct virtio_scsi_inhdr { 129 __virtio32 errors; 130 __virtio32 data_len; 131 __virtio32 sense_len; 132 __virtio32 residual; 133 }; 134 #endif 135 #define VIRTIO_BLK_S_OK 0 136 #define VIRTIO_BLK_S_IOERR 1 137 #define VIRTIO_BLK_S_UNSUPP 2 138 #define VIRTIO_BLK_S_ZONE_INVALID_CMD 3 139 #define VIRTIO_BLK_S_ZONE_UNALIGNED_WP 4 140 #define VIRTIO_BLK_S_ZONE_OPEN_RESOURCE 5 141 #define VIRTIO_BLK_S_ZONE_ACTIVE_RESOURCE 6 142 #endif 143