Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 1 | /**************************************************************************** |
| 2 | **************************************************************************** |
| 3 | *** |
| 4 | *** This header was automatically generated from a Linux kernel header |
| 5 | *** of the same name, to make information necessary for userspace to |
| 6 | *** call into the kernel available to libc. It contains only constants, |
| 7 | *** structures, and macros generated from the original header, and thus, |
| 8 | *** contains no copyrightable information. |
| 9 | *** |
| 10 | *** To edit the content of this header, modify the corresponding |
| 11 | *** source file (e.g. under external/kernel-headers/original/) then |
| 12 | *** run bionic/libc/kernel/tools/update_all.py |
| 13 | *** |
| 14 | *** Any manual change here will be lost the next time this script will |
| 15 | *** be run. You've been warned! |
| 16 | *** |
| 17 | **************************************************************************** |
| 18 | ****************************************************************************/ |
| 19 | #ifndef _LINUX_VIRTIO_BLK_H |
| 20 | #define _LINUX_VIRTIO_BLK_H |
| 21 | #include <linux/types.h> |
| 22 | #include <linux/virtio_ids.h> |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 23 | #include <linux/virtio_config.h> |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 24 | #include <linux/virtio_types.h> |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 25 | #define VIRTIO_BLK_F_SIZE_MAX 1 |
| 26 | #define VIRTIO_BLK_F_SEG_MAX 2 |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 27 | #define VIRTIO_BLK_F_GEOMETRY 4 |
| 28 | #define VIRTIO_BLK_F_RO 5 |
| 29 | #define VIRTIO_BLK_F_BLK_SIZE 6 |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 30 | #define VIRTIO_BLK_F_TOPOLOGY 10 |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 31 | #define VIRTIO_BLK_F_MQ 12 |
Christopher Ferris | d842e43 | 2019-03-07 10:21:59 -0800 | [diff] [blame] | 32 | #define VIRTIO_BLK_F_DISCARD 13 |
| 33 | #define VIRTIO_BLK_F_WRITE_ZEROES 14 |
Christopher Ferris | 6cd53a5 | 2022-12-12 23:39:16 +0000 | [diff] [blame] | 34 | #define VIRTIO_BLK_F_SECURE_ERASE 16 |
Christopher Ferris | b7cef6d | 2023-05-09 19:04:15 +0000 | [diff] [blame] | 35 | #define VIRTIO_BLK_F_ZONED 17 |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 36 | #ifndef VIRTIO_BLK_NO_LEGACY |
| 37 | #define VIRTIO_BLK_F_BARRIER 0 |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 38 | #define VIRTIO_BLK_F_SCSI 7 |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 39 | #define VIRTIO_BLK_F_FLUSH 9 |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 40 | #define VIRTIO_BLK_F_CONFIG_WCE 11 |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 41 | #define VIRTIO_BLK_F_WCE VIRTIO_BLK_F_FLUSH |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 42 | #endif |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 43 | #define VIRTIO_BLK_ID_BYTES 20 |
| 44 | struct virtio_blk_config { |
Christopher Ferris | 25c18d4 | 2020-10-14 17:42:58 -0700 | [diff] [blame] | 45 | __virtio64 capacity; |
| 46 | __virtio32 size_max; |
| 47 | __virtio32 seg_max; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 48 | struct virtio_blk_geometry { |
Christopher Ferris | 25c18d4 | 2020-10-14 17:42:58 -0700 | [diff] [blame] | 49 | __virtio16 cylinders; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 50 | __u8 heads; |
| 51 | __u8 sectors; |
| 52 | } geometry; |
Christopher Ferris | 25c18d4 | 2020-10-14 17:42:58 -0700 | [diff] [blame] | 53 | __virtio32 blk_size; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 54 | __u8 physical_block_exp; |
| 55 | __u8 alignment_offset; |
Christopher Ferris | 25c18d4 | 2020-10-14 17:42:58 -0700 | [diff] [blame] | 56 | __virtio16 min_io_size; |
| 57 | __virtio32 opt_io_size; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 58 | __u8 wce; |
| 59 | __u8 unused; |
Christopher Ferris | 25c18d4 | 2020-10-14 17:42:58 -0700 | [diff] [blame] | 60 | __virtio16 num_queues; |
| 61 | __virtio32 max_discard_sectors; |
| 62 | __virtio32 max_discard_seg; |
| 63 | __virtio32 discard_sector_alignment; |
| 64 | __virtio32 max_write_zeroes_sectors; |
| 65 | __virtio32 max_write_zeroes_seg; |
Christopher Ferris | d842e43 | 2019-03-07 10:21:59 -0800 | [diff] [blame] | 66 | __u8 write_zeroes_may_unmap; |
| 67 | __u8 unused1[3]; |
Christopher Ferris | 6cd53a5 | 2022-12-12 23:39:16 +0000 | [diff] [blame] | 68 | __virtio32 max_secure_erase_sectors; |
| 69 | __virtio32 max_secure_erase_seg; |
| 70 | __virtio32 secure_erase_sector_alignment; |
Christopher Ferris | b7cef6d | 2023-05-09 19:04:15 +0000 | [diff] [blame] | 71 | struct virtio_blk_zoned_characteristics { |
| 72 | __virtio32 zone_sectors; |
| 73 | __virtio32 max_open_zones; |
| 74 | __virtio32 max_active_zones; |
| 75 | __virtio32 max_append_sectors; |
| 76 | __virtio32 write_granularity; |
| 77 | __u8 model; |
| 78 | __u8 unused2[3]; |
| 79 | } zoned; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 80 | } __attribute__((packed)); |
| 81 | #define VIRTIO_BLK_T_IN 0 |
| 82 | #define VIRTIO_BLK_T_OUT 1 |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 83 | #ifndef VIRTIO_BLK_NO_LEGACY |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 84 | #define VIRTIO_BLK_T_SCSI_CMD 2 |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 85 | #endif |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 86 | #define VIRTIO_BLK_T_FLUSH 4 |
| 87 | #define VIRTIO_BLK_T_GET_ID 8 |
Christopher Ferris | d842e43 | 2019-03-07 10:21:59 -0800 | [diff] [blame] | 88 | #define VIRTIO_BLK_T_DISCARD 11 |
| 89 | #define VIRTIO_BLK_T_WRITE_ZEROES 13 |
Christopher Ferris | 6cd53a5 | 2022-12-12 23:39:16 +0000 | [diff] [blame] | 90 | #define VIRTIO_BLK_T_SECURE_ERASE 14 |
Christopher Ferris | b7cef6d | 2023-05-09 19:04:15 +0000 | [diff] [blame] | 91 | #define VIRTIO_BLK_T_ZONE_APPEND 15 |
| 92 | #define VIRTIO_BLK_T_ZONE_REPORT 16 |
| 93 | #define VIRTIO_BLK_T_ZONE_OPEN 18 |
| 94 | #define VIRTIO_BLK_T_ZONE_CLOSE 20 |
| 95 | #define VIRTIO_BLK_T_ZONE_FINISH 22 |
| 96 | #define VIRTIO_BLK_T_ZONE_RESET 24 |
| 97 | #define VIRTIO_BLK_T_ZONE_RESET_ALL 26 |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 98 | #ifndef VIRTIO_BLK_NO_LEGACY |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 99 | #define VIRTIO_BLK_T_BARRIER 0x80000000 |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 100 | #endif |
| 101 | struct virtio_blk_outhdr { |
| 102 | __virtio32 type; |
| 103 | __virtio32 ioprio; |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 104 | __virtio64 sector; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 105 | }; |
Christopher Ferris | b7cef6d | 2023-05-09 19:04:15 +0000 | [diff] [blame] | 106 | #define VIRTIO_BLK_Z_NONE 0 |
| 107 | #define VIRTIO_BLK_Z_HM 1 |
| 108 | #define VIRTIO_BLK_Z_HA 2 |
| 109 | struct virtio_blk_zone_descriptor { |
| 110 | __virtio64 z_cap; |
| 111 | __virtio64 z_start; |
| 112 | __virtio64 z_wp; |
| 113 | __u8 z_type; |
| 114 | __u8 z_state; |
| 115 | __u8 reserved[38]; |
| 116 | }; |
| 117 | struct virtio_blk_zone_report { |
| 118 | __virtio64 nr_zones; |
| 119 | __u8 reserved[56]; |
| 120 | struct virtio_blk_zone_descriptor zones[]; |
| 121 | }; |
| 122 | #define VIRTIO_BLK_ZT_CONV 1 |
| 123 | #define VIRTIO_BLK_ZT_SWR 2 |
| 124 | #define VIRTIO_BLK_ZT_SWP 3 |
| 125 | #define VIRTIO_BLK_ZS_NOT_WP 0 |
| 126 | #define VIRTIO_BLK_ZS_EMPTY 1 |
| 127 | #define VIRTIO_BLK_ZS_IOPEN 2 |
| 128 | #define VIRTIO_BLK_ZS_EOPEN 3 |
| 129 | #define VIRTIO_BLK_ZS_CLOSED 4 |
| 130 | #define VIRTIO_BLK_ZS_RDONLY 13 |
| 131 | #define VIRTIO_BLK_ZS_FULL 14 |
| 132 | #define VIRTIO_BLK_ZS_OFFLINE 15 |
Christopher Ferris | d842e43 | 2019-03-07 10:21:59 -0800 | [diff] [blame] | 133 | #define VIRTIO_BLK_WRITE_ZEROES_FLAG_UNMAP 0x00000001 |
| 134 | struct virtio_blk_discard_write_zeroes { |
| 135 | __le64 sector; |
| 136 | __le32 num_sectors; |
| 137 | __le32 flags; |
| 138 | }; |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 139 | #ifndef VIRTIO_BLK_NO_LEGACY |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 140 | struct virtio_scsi_inhdr { |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 141 | __virtio32 errors; |
| 142 | __virtio32 data_len; |
| 143 | __virtio32 sense_len; |
| 144 | __virtio32 residual; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 145 | }; |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 146 | #endif |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 147 | #define VIRTIO_BLK_S_OK 0 |
| 148 | #define VIRTIO_BLK_S_IOERR 1 |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 149 | #define VIRTIO_BLK_S_UNSUPP 2 |
Christopher Ferris | b7cef6d | 2023-05-09 19:04:15 +0000 | [diff] [blame] | 150 | #define VIRTIO_BLK_S_ZONE_INVALID_CMD 3 |
| 151 | #define VIRTIO_BLK_S_ZONE_UNALIGNED_WP 4 |
| 152 | #define VIRTIO_BLK_S_ZONE_OPEN_RESOURCE 5 |
| 153 | #define VIRTIO_BLK_S_ZONE_ACTIVE_RESOURCE 6 |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 154 | #endif |