Elliott Hughes | 180edef | 2023-11-02 00:08:05 +0000 | [diff] [blame] | 1 | /* |
| 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 Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 7 | #ifndef _LINUX_VIRTIO_PCI_H |
| 8 | #define _LINUX_VIRTIO_PCI_H |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 9 | #include <linux/types.h> |
| 10 | #ifndef VIRTIO_PCI_NO_LEGACY |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 11 | #define VIRTIO_PCI_HOST_FEATURES 0 |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 12 | #define VIRTIO_PCI_GUEST_FEATURES 4 |
| 13 | #define VIRTIO_PCI_QUEUE_PFN 8 |
| 14 | #define VIRTIO_PCI_QUEUE_NUM 12 |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 15 | #define VIRTIO_PCI_QUEUE_SEL 14 |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 16 | #define VIRTIO_PCI_QUEUE_NOTIFY 16 |
| 17 | #define VIRTIO_PCI_STATUS 18 |
| 18 | #define VIRTIO_PCI_ISR 19 |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 19 | #define VIRTIO_MSI_CONFIG_VECTOR 20 |
| 20 | #define VIRTIO_MSI_QUEUE_VECTOR 22 |
Christopher Ferris | 38062f9 | 2014-07-09 15:33:25 -0700 | [diff] [blame] | 21 | #define VIRTIO_PCI_CONFIG_OFF(msix_enabled) ((msix_enabled) ? 24 : 20) |
Christopher Ferris | 38062f9 | 2014-07-09 15:33:25 -0700 | [diff] [blame] | 22 | #define VIRTIO_PCI_CONFIG(dev) VIRTIO_PCI_CONFIG_OFF((dev)->msix_enabled) |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 23 | #define VIRTIO_PCI_ABI_VERSION 0 |
| 24 | #define VIRTIO_PCI_QUEUE_ADDR_SHIFT 12 |
| 25 | #define VIRTIO_PCI_VRING_ALIGN 4096 |
Christopher Ferris | 38062f9 | 2014-07-09 15:33:25 -0700 | [diff] [blame] | 26 | #endif |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 27 | #define VIRTIO_PCI_ISR_CONFIG 0x2 |
| 28 | #define VIRTIO_MSI_NO_VECTOR 0xffff |
| 29 | #ifndef VIRTIO_PCI_NO_MODERN |
| 30 | #define VIRTIO_PCI_CAP_COMMON_CFG 1 |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 31 | #define VIRTIO_PCI_CAP_NOTIFY_CFG 2 |
| 32 | #define VIRTIO_PCI_CAP_ISR_CFG 3 |
| 33 | #define VIRTIO_PCI_CAP_DEVICE_CFG 4 |
| 34 | #define VIRTIO_PCI_CAP_PCI_CFG 5 |
Christopher Ferris | 32ff3f8 | 2020-12-14 13:10:04 -0800 | [diff] [blame] | 35 | #define VIRTIO_PCI_CAP_SHARED_MEMORY_CFG 8 |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 36 | struct virtio_pci_cap { |
| 37 | __u8 cap_vndr; |
| 38 | __u8 cap_next; |
| 39 | __u8 cap_len; |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 40 | __u8 cfg_type; |
| 41 | __u8 bar; |
Christopher Ferris | 32ff3f8 | 2020-12-14 13:10:04 -0800 | [diff] [blame] | 42 | __u8 id; |
| 43 | __u8 padding[2]; |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 44 | __le32 offset; |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 45 | __le32 length; |
| 46 | }; |
Christopher Ferris | 32ff3f8 | 2020-12-14 13:10:04 -0800 | [diff] [blame] | 47 | struct virtio_pci_cap64 { |
| 48 | struct virtio_pci_cap cap; |
| 49 | __le32 offset_hi; |
| 50 | __le32 length_hi; |
| 51 | }; |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 52 | struct virtio_pci_notify_cap { |
| 53 | struct virtio_pci_cap cap; |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 54 | __le32 notify_off_multiplier; |
| 55 | }; |
| 56 | struct virtio_pci_common_cfg { |
| 57 | __le32 device_feature_select; |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 58 | __le32 device_feature; |
| 59 | __le32 guest_feature_select; |
| 60 | __le32 guest_feature; |
| 61 | __le16 msix_config; |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 62 | __le16 num_queues; |
| 63 | __u8 device_status; |
| 64 | __u8 config_generation; |
| 65 | __le16 queue_select; |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 66 | __le16 queue_size; |
| 67 | __le16 queue_msix_vector; |
| 68 | __le16 queue_enable; |
| 69 | __le16 queue_notify_off; |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 70 | __le32 queue_desc_lo; |
| 71 | __le32 queue_desc_hi; |
| 72 | __le32 queue_avail_lo; |
| 73 | __le32 queue_avail_hi; |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 74 | __le32 queue_used_lo; |
| 75 | __le32 queue_used_hi; |
| 76 | }; |
Christopher Ferris | 0f79521 | 2024-01-17 14:17:28 -0800 | [diff] [blame] | 77 | struct virtio_pci_modern_common_cfg { |
| 78 | struct virtio_pci_common_cfg cfg; |
| 79 | __le16 queue_notify_data; |
| 80 | __le16 queue_reset; |
Christopher Ferris | b830ddf | 2024-03-28 11:48:08 -0700 | [diff] [blame^] | 81 | __le16 admin_queue_index; |
| 82 | __le16 admin_queue_num; |
Christopher Ferris | 0f79521 | 2024-01-17 14:17:28 -0800 | [diff] [blame] | 83 | }; |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 84 | struct virtio_pci_cfg_cap { |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 85 | struct virtio_pci_cap cap; |
| 86 | __u8 pci_cfg_data[4]; |
| 87 | }; |
| 88 | #define VIRTIO_PCI_CAP_VNDR 0 |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 89 | #define VIRTIO_PCI_CAP_NEXT 1 |
| 90 | #define VIRTIO_PCI_CAP_LEN 2 |
| 91 | #define VIRTIO_PCI_CAP_CFG_TYPE 3 |
| 92 | #define VIRTIO_PCI_CAP_BAR 4 |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 93 | #define VIRTIO_PCI_CAP_OFFSET 8 |
| 94 | #define VIRTIO_PCI_CAP_LENGTH 12 |
| 95 | #define VIRTIO_PCI_NOTIFY_CAP_MULT 16 |
| 96 | #define VIRTIO_PCI_COMMON_DFSELECT 0 |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 97 | #define VIRTIO_PCI_COMMON_DF 4 |
| 98 | #define VIRTIO_PCI_COMMON_GFSELECT 8 |
| 99 | #define VIRTIO_PCI_COMMON_GF 12 |
| 100 | #define VIRTIO_PCI_COMMON_MSIX 16 |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 101 | #define VIRTIO_PCI_COMMON_NUMQ 18 |
| 102 | #define VIRTIO_PCI_COMMON_STATUS 20 |
| 103 | #define VIRTIO_PCI_COMMON_CFGGENERATION 21 |
| 104 | #define VIRTIO_PCI_COMMON_Q_SELECT 22 |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 105 | #define VIRTIO_PCI_COMMON_Q_SIZE 24 |
| 106 | #define VIRTIO_PCI_COMMON_Q_MSIX 26 |
| 107 | #define VIRTIO_PCI_COMMON_Q_ENABLE 28 |
| 108 | #define VIRTIO_PCI_COMMON_Q_NOFF 30 |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 109 | #define VIRTIO_PCI_COMMON_Q_DESCLO 32 |
| 110 | #define VIRTIO_PCI_COMMON_Q_DESCHI 36 |
| 111 | #define VIRTIO_PCI_COMMON_Q_AVAILLO 40 |
| 112 | #define VIRTIO_PCI_COMMON_Q_AVAILHI 44 |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 113 | #define VIRTIO_PCI_COMMON_Q_USEDLO 48 |
| 114 | #define VIRTIO_PCI_COMMON_Q_USEDHI 52 |
Christopher Ferris | 7447a1c | 2022-10-04 18:24:44 -0700 | [diff] [blame] | 115 | #define VIRTIO_PCI_COMMON_Q_NDATA 56 |
| 116 | #define VIRTIO_PCI_COMMON_Q_RESET 58 |
Christopher Ferris | b830ddf | 2024-03-28 11:48:08 -0700 | [diff] [blame^] | 117 | #define VIRTIO_PCI_COMMON_ADM_Q_IDX 60 |
| 118 | #define VIRTIO_PCI_COMMON_ADM_Q_NUM 62 |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 119 | #endif |
Christopher Ferris | b830ddf | 2024-03-28 11:48:08 -0700 | [diff] [blame^] | 120 | #define VIRTIO_ADMIN_STATUS_OK 0 |
| 121 | #define VIRTIO_ADMIN_CMD_LIST_QUERY 0x0 |
| 122 | #define VIRTIO_ADMIN_CMD_LIST_USE 0x1 |
| 123 | #define VIRTIO_ADMIN_GROUP_TYPE_SRIOV 0x1 |
| 124 | #define VIRTIO_ADMIN_CMD_LEGACY_COMMON_CFG_WRITE 0x2 |
| 125 | #define VIRTIO_ADMIN_CMD_LEGACY_COMMON_CFG_READ 0x3 |
| 126 | #define VIRTIO_ADMIN_CMD_LEGACY_DEV_CFG_WRITE 0x4 |
| 127 | #define VIRTIO_ADMIN_CMD_LEGACY_DEV_CFG_READ 0x5 |
| 128 | #define VIRTIO_ADMIN_CMD_LEGACY_NOTIFY_INFO 0x6 |
| 129 | struct __attribute__((__packed__)) virtio_admin_cmd_hdr { |
| 130 | __le16 opcode; |
| 131 | __le16 group_type; |
| 132 | __u8 reserved1[12]; |
| 133 | __le64 group_member_id; |
| 134 | }; |
| 135 | struct __attribute__((__packed__)) virtio_admin_cmd_status { |
| 136 | __le16 status; |
| 137 | __le16 status_qualifier; |
| 138 | __u8 reserved2[4]; |
| 139 | }; |
| 140 | struct __attribute__((__packed__)) virtio_admin_cmd_legacy_wr_data { |
| 141 | __u8 offset; |
| 142 | __u8 reserved[7]; |
| 143 | __u8 registers[]; |
| 144 | }; |
| 145 | struct __attribute__((__packed__)) virtio_admin_cmd_legacy_rd_data { |
| 146 | __u8 offset; |
| 147 | }; |
| 148 | #define VIRTIO_ADMIN_CMD_NOTIFY_INFO_FLAGS_END 0 |
| 149 | #define VIRTIO_ADMIN_CMD_NOTIFY_INFO_FLAGS_OWNER_DEV 0x1 |
| 150 | #define VIRTIO_ADMIN_CMD_NOTIFY_INFO_FLAGS_OWNER_MEM 0x2 |
| 151 | #define VIRTIO_ADMIN_CMD_MAX_NOTIFY_INFO 4 |
| 152 | struct __attribute__((__packed__)) virtio_admin_cmd_notify_info_data { |
| 153 | __u8 flags; |
| 154 | __u8 bar; |
| 155 | __u8 padding[6]; |
| 156 | __le64 offset; |
| 157 | }; |
| 158 | struct virtio_admin_cmd_notify_info_result { |
| 159 | struct virtio_admin_cmd_notify_info_data entries[VIRTIO_ADMIN_CMD_MAX_NOTIFY_INFO]; |
| 160 | }; |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 161 | #endif |