Elliott Hughes | 180edef | 2023-11-02 00:08:05 +0000 | [diff] [blame^] | 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 | */ |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 7 | #ifndef _LINUX_VIRTIO_BLK_H |
| 8 | #define _LINUX_VIRTIO_BLK_H |
| 9 | #include <linux/types.h> |
| 10 | #include <linux/virtio_ids.h> |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 11 | #include <linux/virtio_config.h> |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 12 | #include <linux/virtio_types.h> |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 13 | #define VIRTIO_BLK_F_SIZE_MAX 1 |
| 14 | #define VIRTIO_BLK_F_SEG_MAX 2 |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 15 | #define VIRTIO_BLK_F_GEOMETRY 4 |
| 16 | #define VIRTIO_BLK_F_RO 5 |
| 17 | #define VIRTIO_BLK_F_BLK_SIZE 6 |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 18 | #define VIRTIO_BLK_F_TOPOLOGY 10 |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 19 | #define VIRTIO_BLK_F_MQ 12 |
Christopher Ferris | d842e43 | 2019-03-07 10:21:59 -0800 | [diff] [blame] | 20 | #define VIRTIO_BLK_F_DISCARD 13 |
| 21 | #define VIRTIO_BLK_F_WRITE_ZEROES 14 |
Christopher Ferris | 6cd53a5 | 2022-12-12 23:39:16 +0000 | [diff] [blame] | 22 | #define VIRTIO_BLK_F_SECURE_ERASE 16 |
Christopher Ferris | b7cef6d | 2023-05-09 19:04:15 +0000 | [diff] [blame] | 23 | #define VIRTIO_BLK_F_ZONED 17 |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 24 | #ifndef VIRTIO_BLK_NO_LEGACY |
| 25 | #define VIRTIO_BLK_F_BARRIER 0 |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 26 | #define VIRTIO_BLK_F_SCSI 7 |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 27 | #define VIRTIO_BLK_F_FLUSH 9 |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 28 | #define VIRTIO_BLK_F_CONFIG_WCE 11 |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 29 | #define VIRTIO_BLK_F_WCE VIRTIO_BLK_F_FLUSH |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 30 | #endif |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 31 | #define VIRTIO_BLK_ID_BYTES 20 |
| 32 | struct virtio_blk_config { |
Christopher Ferris | 25c18d4 | 2020-10-14 17:42:58 -0700 | [diff] [blame] | 33 | __virtio64 capacity; |
| 34 | __virtio32 size_max; |
| 35 | __virtio32 seg_max; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 36 | struct virtio_blk_geometry { |
Christopher Ferris | 25c18d4 | 2020-10-14 17:42:58 -0700 | [diff] [blame] | 37 | __virtio16 cylinders; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 38 | __u8 heads; |
| 39 | __u8 sectors; |
| 40 | } geometry; |
Christopher Ferris | 25c18d4 | 2020-10-14 17:42:58 -0700 | [diff] [blame] | 41 | __virtio32 blk_size; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 42 | __u8 physical_block_exp; |
| 43 | __u8 alignment_offset; |
Christopher Ferris | 25c18d4 | 2020-10-14 17:42:58 -0700 | [diff] [blame] | 44 | __virtio16 min_io_size; |
| 45 | __virtio32 opt_io_size; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 46 | __u8 wce; |
| 47 | __u8 unused; |
Christopher Ferris | 25c18d4 | 2020-10-14 17:42:58 -0700 | [diff] [blame] | 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; |
Christopher Ferris | d842e43 | 2019-03-07 10:21:59 -0800 | [diff] [blame] | 54 | __u8 write_zeroes_may_unmap; |
| 55 | __u8 unused1[3]; |
Christopher Ferris | 6cd53a5 | 2022-12-12 23:39:16 +0000 | [diff] [blame] | 56 | __virtio32 max_secure_erase_sectors; |
| 57 | __virtio32 max_secure_erase_seg; |
| 58 | __virtio32 secure_erase_sector_alignment; |
Christopher Ferris | b7cef6d | 2023-05-09 19:04:15 +0000 | [diff] [blame] | 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; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 68 | } __attribute__((packed)); |
| 69 | #define VIRTIO_BLK_T_IN 0 |
| 70 | #define VIRTIO_BLK_T_OUT 1 |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 71 | #ifndef VIRTIO_BLK_NO_LEGACY |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 72 | #define VIRTIO_BLK_T_SCSI_CMD 2 |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 73 | #endif |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 74 | #define VIRTIO_BLK_T_FLUSH 4 |
| 75 | #define VIRTIO_BLK_T_GET_ID 8 |
Christopher Ferris | d842e43 | 2019-03-07 10:21:59 -0800 | [diff] [blame] | 76 | #define VIRTIO_BLK_T_DISCARD 11 |
| 77 | #define VIRTIO_BLK_T_WRITE_ZEROES 13 |
Christopher Ferris | 6cd53a5 | 2022-12-12 23:39:16 +0000 | [diff] [blame] | 78 | #define VIRTIO_BLK_T_SECURE_ERASE 14 |
Christopher Ferris | b7cef6d | 2023-05-09 19:04:15 +0000 | [diff] [blame] | 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 |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 86 | #ifndef VIRTIO_BLK_NO_LEGACY |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 87 | #define VIRTIO_BLK_T_BARRIER 0x80000000 |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 88 | #endif |
| 89 | struct virtio_blk_outhdr { |
| 90 | __virtio32 type; |
| 91 | __virtio32 ioprio; |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 92 | __virtio64 sector; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 93 | }; |
Christopher Ferris | b7cef6d | 2023-05-09 19:04:15 +0000 | [diff] [blame] | 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 |
Christopher Ferris | d842e43 | 2019-03-07 10:21:59 -0800 | [diff] [blame] | 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 | }; |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 127 | #ifndef VIRTIO_BLK_NO_LEGACY |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 128 | struct virtio_scsi_inhdr { |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 129 | __virtio32 errors; |
| 130 | __virtio32 data_len; |
| 131 | __virtio32 sense_len; |
| 132 | __virtio32 residual; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 133 | }; |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 134 | #endif |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 135 | #define VIRTIO_BLK_S_OK 0 |
| 136 | #define VIRTIO_BLK_S_IOERR 1 |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 137 | #define VIRTIO_BLK_S_UNSUPP 2 |
Christopher Ferris | b7cef6d | 2023-05-09 19:04:15 +0000 | [diff] [blame] | 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 |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 142 | #endif |