blob: 7cc513982342de162dee52ba8c1fa4663e419b8a [file] [log] [blame]
Elliott Hughes180edef2023-11-02 00:08:05 +00001/*
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 Cheng655a7c02013-10-16 16:09:24 -07007#ifndef _LINUX_VIRTIO_BLK_H
8#define _LINUX_VIRTIO_BLK_H
9#include <linux/types.h>
10#include <linux/virtio_ids.h>
Ben Cheng655a7c02013-10-16 16:09:24 -070011#include <linux/virtio_config.h>
Christopher Ferris05d08e92016-02-04 13:16:38 -080012#include <linux/virtio_types.h>
Ben Cheng655a7c02013-10-16 16:09:24 -070013#define VIRTIO_BLK_F_SIZE_MAX 1
14#define VIRTIO_BLK_F_SEG_MAX 2
Ben Cheng655a7c02013-10-16 16:09:24 -070015#define VIRTIO_BLK_F_GEOMETRY 4
16#define VIRTIO_BLK_F_RO 5
17#define VIRTIO_BLK_F_BLK_SIZE 6
Christopher Ferris05d08e92016-02-04 13:16:38 -080018#define VIRTIO_BLK_F_TOPOLOGY 10
Christopher Ferris05d08e92016-02-04 13:16:38 -080019#define VIRTIO_BLK_F_MQ 12
Christopher Ferrisd842e432019-03-07 10:21:59 -080020#define VIRTIO_BLK_F_DISCARD 13
21#define VIRTIO_BLK_F_WRITE_ZEROES 14
Christopher Ferris6cd53a52022-12-12 23:39:16 +000022#define VIRTIO_BLK_F_SECURE_ERASE 16
Christopher Ferrisb7cef6d2023-05-09 19:04:15 +000023#define VIRTIO_BLK_F_ZONED 17
Christopher Ferris05d08e92016-02-04 13:16:38 -080024#ifndef VIRTIO_BLK_NO_LEGACY
25#define VIRTIO_BLK_F_BARRIER 0
Ben Cheng655a7c02013-10-16 16:09:24 -070026#define VIRTIO_BLK_F_SCSI 7
Christopher Ferris106b3a82016-08-24 12:15:38 -070027#define VIRTIO_BLK_F_FLUSH 9
Ben Cheng655a7c02013-10-16 16:09:24 -070028#define VIRTIO_BLK_F_CONFIG_WCE 11
Christopher Ferris106b3a82016-08-24 12:15:38 -070029#define VIRTIO_BLK_F_WCE VIRTIO_BLK_F_FLUSH
Christopher Ferris05d08e92016-02-04 13:16:38 -080030#endif
Ben Cheng655a7c02013-10-16 16:09:24 -070031#define VIRTIO_BLK_ID_BYTES 20
32struct virtio_blk_config {
Christopher Ferris25c18d42020-10-14 17:42:58 -070033 __virtio64 capacity;
34 __virtio32 size_max;
35 __virtio32 seg_max;
Tao Baod7db5942015-01-28 10:07:51 -080036 struct virtio_blk_geometry {
Christopher Ferris25c18d42020-10-14 17:42:58 -070037 __virtio16 cylinders;
Tao Baod7db5942015-01-28 10:07:51 -080038 __u8 heads;
39 __u8 sectors;
40 } geometry;
Christopher Ferris25c18d42020-10-14 17:42:58 -070041 __virtio32 blk_size;
Tao Baod7db5942015-01-28 10:07:51 -080042 __u8 physical_block_exp;
43 __u8 alignment_offset;
Christopher Ferris25c18d42020-10-14 17:42:58 -070044 __virtio16 min_io_size;
45 __virtio32 opt_io_size;
Tao Baod7db5942015-01-28 10:07:51 -080046 __u8 wce;
47 __u8 unused;
Christopher Ferris25c18d42020-10-14 17:42:58 -070048 __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 Ferrisd842e432019-03-07 10:21:59 -080054 __u8 write_zeroes_may_unmap;
55 __u8 unused1[3];
Christopher Ferris6cd53a52022-12-12 23:39:16 +000056 __virtio32 max_secure_erase_sectors;
57 __virtio32 max_secure_erase_seg;
58 __virtio32 secure_erase_sector_alignment;
Christopher Ferrisb7cef6d2023-05-09 19:04:15 +000059 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 Cheng655a7c02013-10-16 16:09:24 -070068} __attribute__((packed));
69#define VIRTIO_BLK_T_IN 0
70#define VIRTIO_BLK_T_OUT 1
Christopher Ferris05d08e92016-02-04 13:16:38 -080071#ifndef VIRTIO_BLK_NO_LEGACY
Ben Cheng655a7c02013-10-16 16:09:24 -070072#define VIRTIO_BLK_T_SCSI_CMD 2
Christopher Ferris05d08e92016-02-04 13:16:38 -080073#endif
Ben Cheng655a7c02013-10-16 16:09:24 -070074#define VIRTIO_BLK_T_FLUSH 4
75#define VIRTIO_BLK_T_GET_ID 8
Christopher Ferrisd842e432019-03-07 10:21:59 -080076#define VIRTIO_BLK_T_DISCARD 11
77#define VIRTIO_BLK_T_WRITE_ZEROES 13
Christopher Ferris6cd53a52022-12-12 23:39:16 +000078#define VIRTIO_BLK_T_SECURE_ERASE 14
Christopher Ferrisb7cef6d2023-05-09 19:04:15 +000079#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 Ferris05d08e92016-02-04 13:16:38 -080086#ifndef VIRTIO_BLK_NO_LEGACY
Ben Cheng655a7c02013-10-16 16:09:24 -070087#define VIRTIO_BLK_T_BARRIER 0x80000000
Christopher Ferris05d08e92016-02-04 13:16:38 -080088#endif
89struct virtio_blk_outhdr {
90 __virtio32 type;
91 __virtio32 ioprio;
Christopher Ferris05d08e92016-02-04 13:16:38 -080092 __virtio64 sector;
Ben Cheng655a7c02013-10-16 16:09:24 -070093};
Christopher Ferrisb7cef6d2023-05-09 19:04:15 +000094#define VIRTIO_BLK_Z_NONE 0
95#define VIRTIO_BLK_Z_HM 1
96#define VIRTIO_BLK_Z_HA 2
97struct 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};
105struct 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 Ferrisd842e432019-03-07 10:21:59 -0800121#define VIRTIO_BLK_WRITE_ZEROES_FLAG_UNMAP 0x00000001
122struct virtio_blk_discard_write_zeroes {
123 __le64 sector;
124 __le32 num_sectors;
125 __le32 flags;
126};
Christopher Ferris05d08e92016-02-04 13:16:38 -0800127#ifndef VIRTIO_BLK_NO_LEGACY
Ben Cheng655a7c02013-10-16 16:09:24 -0700128struct virtio_scsi_inhdr {
Christopher Ferris05d08e92016-02-04 13:16:38 -0800129 __virtio32 errors;
130 __virtio32 data_len;
131 __virtio32 sense_len;
132 __virtio32 residual;
Ben Cheng655a7c02013-10-16 16:09:24 -0700133};
Christopher Ferris05d08e92016-02-04 13:16:38 -0800134#endif
Ben Cheng655a7c02013-10-16 16:09:24 -0700135#define VIRTIO_BLK_S_OK 0
136#define VIRTIO_BLK_S_IOERR 1
Christopher Ferris05d08e92016-02-04 13:16:38 -0800137#define VIRTIO_BLK_S_UNSUPP 2
Christopher Ferrisb7cef6d2023-05-09 19:04:15 +0000138#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 Cheng655a7c02013-10-16 16:09:24 -0700142#endif