blob: 5197434309dd5497932dd8c88e78526931ac8c08 [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 Ferris05d08e92016-02-04 13:16:38 -080034#ifndef VIRTIO_BLK_NO_LEGACY
35#define VIRTIO_BLK_F_BARRIER 0
Ben Cheng655a7c02013-10-16 16:09:24 -070036#define VIRTIO_BLK_F_SCSI 7
Christopher Ferris106b3a82016-08-24 12:15:38 -070037#define VIRTIO_BLK_F_FLUSH 9
Ben Cheng655a7c02013-10-16 16:09:24 -070038#define VIRTIO_BLK_F_CONFIG_WCE 11
Christopher Ferris106b3a82016-08-24 12:15:38 -070039#define VIRTIO_BLK_F_WCE VIRTIO_BLK_F_FLUSH
Christopher Ferris05d08e92016-02-04 13:16:38 -080040#endif
Ben Cheng655a7c02013-10-16 16:09:24 -070041#define VIRTIO_BLK_ID_BYTES 20
42struct virtio_blk_config {
Tao Baod7db5942015-01-28 10:07:51 -080043 __u64 capacity;
Tao Baod7db5942015-01-28 10:07:51 -080044 __u32 size_max;
45 __u32 seg_max;
46 struct virtio_blk_geometry {
47 __u16 cylinders;
Tao Baod7db5942015-01-28 10:07:51 -080048 __u8 heads;
49 __u8 sectors;
50 } geometry;
51 __u32 blk_size;
Tao Baod7db5942015-01-28 10:07:51 -080052 __u8 physical_block_exp;
53 __u8 alignment_offset;
54 __u16 min_io_size;
55 __u32 opt_io_size;
Tao Baod7db5942015-01-28 10:07:51 -080056 __u8 wce;
57 __u8 unused;
58 __u16 num_queues;
Christopher Ferrisd842e432019-03-07 10:21:59 -080059 __u32 max_discard_sectors;
60 __u32 max_discard_seg;
61 __u32 discard_sector_alignment;
62 __u32 max_write_zeroes_sectors;
63 __u32 max_write_zeroes_seg;
64 __u8 write_zeroes_may_unmap;
65 __u8 unused1[3];
Ben Cheng655a7c02013-10-16 16:09:24 -070066} __attribute__((packed));
67#define VIRTIO_BLK_T_IN 0
68#define VIRTIO_BLK_T_OUT 1
Christopher Ferris05d08e92016-02-04 13:16:38 -080069#ifndef VIRTIO_BLK_NO_LEGACY
Ben Cheng655a7c02013-10-16 16:09:24 -070070#define VIRTIO_BLK_T_SCSI_CMD 2
Christopher Ferris05d08e92016-02-04 13:16:38 -080071#endif
Ben Cheng655a7c02013-10-16 16:09:24 -070072#define VIRTIO_BLK_T_FLUSH 4
73#define VIRTIO_BLK_T_GET_ID 8
Christopher Ferrisd842e432019-03-07 10:21:59 -080074#define VIRTIO_BLK_T_DISCARD 11
75#define VIRTIO_BLK_T_WRITE_ZEROES 13
Christopher Ferris05d08e92016-02-04 13:16:38 -080076#ifndef VIRTIO_BLK_NO_LEGACY
Ben Cheng655a7c02013-10-16 16:09:24 -070077#define VIRTIO_BLK_T_BARRIER 0x80000000
Christopher Ferris05d08e92016-02-04 13:16:38 -080078#endif
79struct virtio_blk_outhdr {
80 __virtio32 type;
81 __virtio32 ioprio;
Christopher Ferris05d08e92016-02-04 13:16:38 -080082 __virtio64 sector;
Ben Cheng655a7c02013-10-16 16:09:24 -070083};
Christopher Ferrisd842e432019-03-07 10:21:59 -080084#define VIRTIO_BLK_WRITE_ZEROES_FLAG_UNMAP 0x00000001
85struct virtio_blk_discard_write_zeroes {
86 __le64 sector;
87 __le32 num_sectors;
88 __le32 flags;
89};
Christopher Ferris05d08e92016-02-04 13:16:38 -080090#ifndef VIRTIO_BLK_NO_LEGACY
Ben Cheng655a7c02013-10-16 16:09:24 -070091struct virtio_scsi_inhdr {
Christopher Ferris05d08e92016-02-04 13:16:38 -080092 __virtio32 errors;
93 __virtio32 data_len;
94 __virtio32 sense_len;
95 __virtio32 residual;
Ben Cheng655a7c02013-10-16 16:09:24 -070096};
Christopher Ferris05d08e92016-02-04 13:16:38 -080097#endif
Ben Cheng655a7c02013-10-16 16:09:24 -070098#define VIRTIO_BLK_S_OK 0
99#define VIRTIO_BLK_S_IOERR 1
Christopher Ferris05d08e92016-02-04 13:16:38 -0800100#define VIRTIO_BLK_S_UNSUPP 2
Ben Cheng655a7c02013-10-16 16:09:24 -0700101#endif