blob: 1b7c7e9114c1347e2dae4fa35408bda76e0cf94e [file] [log] [blame]
Ben Cheng655a7c02013-10-16 16:09:24 -07001/****************************************************************************
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 Cheng655a7c02013-10-16 16:09:24 -070023#include <linux/virtio_config.h>
Christopher Ferris05d08e92016-02-04 13:16:38 -080024#include <linux/virtio_types.h>
Ben Cheng655a7c02013-10-16 16:09:24 -070025#define VIRTIO_BLK_F_SIZE_MAX 1
26#define VIRTIO_BLK_F_SEG_MAX 2
Ben Cheng655a7c02013-10-16 16:09:24 -070027#define VIRTIO_BLK_F_GEOMETRY 4
28#define VIRTIO_BLK_F_RO 5
29#define VIRTIO_BLK_F_BLK_SIZE 6
Christopher Ferris05d08e92016-02-04 13:16:38 -080030#define VIRTIO_BLK_F_TOPOLOGY 10
Christopher Ferris05d08e92016-02-04 13:16:38 -080031#define VIRTIO_BLK_F_MQ 12
Christopher Ferrisd842e432019-03-07 10:21:59 -080032#define VIRTIO_BLK_F_DISCARD 13
33#define VIRTIO_BLK_F_WRITE_ZEROES 14
Christopher Ferris6cd53a52022-12-12 23:39:16 +000034#define VIRTIO_BLK_F_SECURE_ERASE 16
Christopher Ferrisb7cef6d2023-05-09 19:04:15 +000035#define VIRTIO_BLK_F_ZONED 17
Christopher Ferris05d08e92016-02-04 13:16:38 -080036#ifndef VIRTIO_BLK_NO_LEGACY
37#define VIRTIO_BLK_F_BARRIER 0
Ben Cheng655a7c02013-10-16 16:09:24 -070038#define VIRTIO_BLK_F_SCSI 7
Christopher Ferris106b3a82016-08-24 12:15:38 -070039#define VIRTIO_BLK_F_FLUSH 9
Ben Cheng655a7c02013-10-16 16:09:24 -070040#define VIRTIO_BLK_F_CONFIG_WCE 11
Christopher Ferris106b3a82016-08-24 12:15:38 -070041#define VIRTIO_BLK_F_WCE VIRTIO_BLK_F_FLUSH
Christopher Ferris05d08e92016-02-04 13:16:38 -080042#endif
Ben Cheng655a7c02013-10-16 16:09:24 -070043#define VIRTIO_BLK_ID_BYTES 20
44struct virtio_blk_config {
Christopher Ferris25c18d42020-10-14 17:42:58 -070045 __virtio64 capacity;
46 __virtio32 size_max;
47 __virtio32 seg_max;
Tao Baod7db5942015-01-28 10:07:51 -080048 struct virtio_blk_geometry {
Christopher Ferris25c18d42020-10-14 17:42:58 -070049 __virtio16 cylinders;
Tao Baod7db5942015-01-28 10:07:51 -080050 __u8 heads;
51 __u8 sectors;
52 } geometry;
Christopher Ferris25c18d42020-10-14 17:42:58 -070053 __virtio32 blk_size;
Tao Baod7db5942015-01-28 10:07:51 -080054 __u8 physical_block_exp;
55 __u8 alignment_offset;
Christopher Ferris25c18d42020-10-14 17:42:58 -070056 __virtio16 min_io_size;
57 __virtio32 opt_io_size;
Tao Baod7db5942015-01-28 10:07:51 -080058 __u8 wce;
59 __u8 unused;
Christopher Ferris25c18d42020-10-14 17:42:58 -070060 __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 Ferrisd842e432019-03-07 10:21:59 -080066 __u8 write_zeroes_may_unmap;
67 __u8 unused1[3];
Christopher Ferris6cd53a52022-12-12 23:39:16 +000068 __virtio32 max_secure_erase_sectors;
69 __virtio32 max_secure_erase_seg;
70 __virtio32 secure_erase_sector_alignment;
Christopher Ferrisb7cef6d2023-05-09 19:04:15 +000071 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 Cheng655a7c02013-10-16 16:09:24 -070080} __attribute__((packed));
81#define VIRTIO_BLK_T_IN 0
82#define VIRTIO_BLK_T_OUT 1
Christopher Ferris05d08e92016-02-04 13:16:38 -080083#ifndef VIRTIO_BLK_NO_LEGACY
Ben Cheng655a7c02013-10-16 16:09:24 -070084#define VIRTIO_BLK_T_SCSI_CMD 2
Christopher Ferris05d08e92016-02-04 13:16:38 -080085#endif
Ben Cheng655a7c02013-10-16 16:09:24 -070086#define VIRTIO_BLK_T_FLUSH 4
87#define VIRTIO_BLK_T_GET_ID 8
Christopher Ferrisd842e432019-03-07 10:21:59 -080088#define VIRTIO_BLK_T_DISCARD 11
89#define VIRTIO_BLK_T_WRITE_ZEROES 13
Christopher Ferris6cd53a52022-12-12 23:39:16 +000090#define VIRTIO_BLK_T_SECURE_ERASE 14
Christopher Ferrisb7cef6d2023-05-09 19:04:15 +000091#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 Ferris05d08e92016-02-04 13:16:38 -080098#ifndef VIRTIO_BLK_NO_LEGACY
Ben Cheng655a7c02013-10-16 16:09:24 -070099#define VIRTIO_BLK_T_BARRIER 0x80000000
Christopher Ferris05d08e92016-02-04 13:16:38 -0800100#endif
101struct virtio_blk_outhdr {
102 __virtio32 type;
103 __virtio32 ioprio;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800104 __virtio64 sector;
Ben Cheng655a7c02013-10-16 16:09:24 -0700105};
Christopher Ferrisb7cef6d2023-05-09 19:04:15 +0000106#define VIRTIO_BLK_Z_NONE 0
107#define VIRTIO_BLK_Z_HM 1
108#define VIRTIO_BLK_Z_HA 2
109struct 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};
117struct 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 Ferrisd842e432019-03-07 10:21:59 -0800133#define VIRTIO_BLK_WRITE_ZEROES_FLAG_UNMAP 0x00000001
134struct virtio_blk_discard_write_zeroes {
135 __le64 sector;
136 __le32 num_sectors;
137 __le32 flags;
138};
Christopher Ferris05d08e92016-02-04 13:16:38 -0800139#ifndef VIRTIO_BLK_NO_LEGACY
Ben Cheng655a7c02013-10-16 16:09:24 -0700140struct virtio_scsi_inhdr {
Christopher Ferris05d08e92016-02-04 13:16:38 -0800141 __virtio32 errors;
142 __virtio32 data_len;
143 __virtio32 sense_len;
144 __virtio32 residual;
Ben Cheng655a7c02013-10-16 16:09:24 -0700145};
Christopher Ferris05d08e92016-02-04 13:16:38 -0800146#endif
Ben Cheng655a7c02013-10-16 16:09:24 -0700147#define VIRTIO_BLK_S_OK 0
148#define VIRTIO_BLK_S_IOERR 1
Christopher Ferris05d08e92016-02-04 13:16:38 -0800149#define VIRTIO_BLK_S_UNSUPP 2
Christopher Ferrisb7cef6d2023-05-09 19:04:15 +0000150#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 Cheng655a7c02013-10-16 16:09:24 -0700154#endif