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 | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 35 | #ifndef VIRTIO_BLK_NO_LEGACY |
| 36 | #define VIRTIO_BLK_F_BARRIER 0 |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 37 | #define VIRTIO_BLK_F_SCSI 7 |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 38 | #define VIRTIO_BLK_F_FLUSH 9 |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 39 | #define VIRTIO_BLK_F_CONFIG_WCE 11 |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 40 | #define VIRTIO_BLK_F_WCE VIRTIO_BLK_F_FLUSH |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 41 | #endif |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 42 | #define VIRTIO_BLK_ID_BYTES 20 |
| 43 | struct virtio_blk_config { |
Christopher Ferris | 25c18d4 | 2020-10-14 17:42:58 -0700 | [diff] [blame] | 44 | __virtio64 capacity; |
| 45 | __virtio32 size_max; |
| 46 | __virtio32 seg_max; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 47 | struct virtio_blk_geometry { |
Christopher Ferris | 25c18d4 | 2020-10-14 17:42:58 -0700 | [diff] [blame] | 48 | __virtio16 cylinders; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 49 | __u8 heads; |
| 50 | __u8 sectors; |
| 51 | } geometry; |
Christopher Ferris | 25c18d4 | 2020-10-14 17:42:58 -0700 | [diff] [blame] | 52 | __virtio32 blk_size; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 53 | __u8 physical_block_exp; |
| 54 | __u8 alignment_offset; |
Christopher Ferris | 25c18d4 | 2020-10-14 17:42:58 -0700 | [diff] [blame] | 55 | __virtio16 min_io_size; |
| 56 | __virtio32 opt_io_size; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 57 | __u8 wce; |
| 58 | __u8 unused; |
Christopher Ferris | 25c18d4 | 2020-10-14 17:42:58 -0700 | [diff] [blame] | 59 | __virtio16 num_queues; |
| 60 | __virtio32 max_discard_sectors; |
| 61 | __virtio32 max_discard_seg; |
| 62 | __virtio32 discard_sector_alignment; |
| 63 | __virtio32 max_write_zeroes_sectors; |
| 64 | __virtio32 max_write_zeroes_seg; |
Christopher Ferris | d842e43 | 2019-03-07 10:21:59 -0800 | [diff] [blame] | 65 | __u8 write_zeroes_may_unmap; |
| 66 | __u8 unused1[3]; |
Christopher Ferris | 6cd53a5 | 2022-12-12 23:39:16 +0000 | [diff] [blame] | 67 | __virtio32 max_secure_erase_sectors; |
| 68 | __virtio32 max_secure_erase_seg; |
| 69 | __virtio32 secure_erase_sector_alignment; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 70 | } __attribute__((packed)); |
| 71 | #define VIRTIO_BLK_T_IN 0 |
| 72 | #define VIRTIO_BLK_T_OUT 1 |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 73 | #ifndef VIRTIO_BLK_NO_LEGACY |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 74 | #define VIRTIO_BLK_T_SCSI_CMD 2 |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 75 | #endif |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 76 | #define VIRTIO_BLK_T_FLUSH 4 |
| 77 | #define VIRTIO_BLK_T_GET_ID 8 |
Christopher Ferris | d842e43 | 2019-03-07 10:21:59 -0800 | [diff] [blame] | 78 | #define VIRTIO_BLK_T_DISCARD 11 |
| 79 | #define VIRTIO_BLK_T_WRITE_ZEROES 13 |
Christopher Ferris | 6cd53a5 | 2022-12-12 23:39:16 +0000 | [diff] [blame] | 80 | #define VIRTIO_BLK_T_SECURE_ERASE 14 |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 81 | #ifndef VIRTIO_BLK_NO_LEGACY |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 82 | #define VIRTIO_BLK_T_BARRIER 0x80000000 |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 83 | #endif |
| 84 | struct virtio_blk_outhdr { |
| 85 | __virtio32 type; |
| 86 | __virtio32 ioprio; |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 87 | __virtio64 sector; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 88 | }; |
Christopher Ferris | d842e43 | 2019-03-07 10:21:59 -0800 | [diff] [blame] | 89 | #define VIRTIO_BLK_WRITE_ZEROES_FLAG_UNMAP 0x00000001 |
| 90 | struct virtio_blk_discard_write_zeroes { |
| 91 | __le64 sector; |
| 92 | __le32 num_sectors; |
| 93 | __le32 flags; |
| 94 | }; |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 95 | #ifndef VIRTIO_BLK_NO_LEGACY |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 96 | struct virtio_scsi_inhdr { |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 97 | __virtio32 errors; |
| 98 | __virtio32 data_len; |
| 99 | __virtio32 sense_len; |
| 100 | __virtio32 residual; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 101 | }; |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 102 | #endif |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 103 | #define VIRTIO_BLK_S_OK 0 |
| 104 | #define VIRTIO_BLK_S_IOERR 1 |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 105 | #define VIRTIO_BLK_S_UNSUPP 2 |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 106 | #endif |