xref: /openbmc/qemu/include/hw/hyperv/vmbus-proto.h (revision a81df1b6)
1 /*
2  * QEMU Hyper-V VMBus support
3  *
4  * Copyright (c) 2017-2018 Virtuozzo International GmbH.
5  *
6  * This work is licensed under the terms of the GNU GPL, version 2 or later.
7  * See the COPYING file in the top-level directory.
8  */
9 
10 #ifndef HW_HYPERV_VMBUS_PROTO_H
11 #define HW_HYPERV_VMBUS_PROTO_H
12 
13 #define VMBUS_VERSION_WS2008                    ((0 << 16) | (13))
14 #define VMBUS_VERSION_WIN7                      ((1 << 16) | (1))
15 #define VMBUS_VERSION_WIN8                      ((2 << 16) | (4))
16 #define VMBUS_VERSION_WIN8_1                    ((3 << 16) | (0))
17 #define VMBUS_VERSION_WIN10                     ((4 << 16) | (0))
18 #define VMBUS_VERSION_INVAL                     -1
19 #define VMBUS_VERSION_CURRENT                   VMBUS_VERSION_WIN10
20 
21 #define VMBUS_MESSAGE_CONNECTION_ID             1
22 #define VMBUS_EVENT_CONNECTION_ID               2
23 #define VMBUS_MONITOR_CONNECTION_ID             3
24 #define VMBUS_SINT                              2
25 
26 #define VMBUS_MSG_INVALID               0
27 #define VMBUS_MSG_OFFERCHANNEL          1
28 #define VMBUS_MSG_RESCIND_CHANNELOFFER  2
29 #define VMBUS_MSG_REQUESTOFFERS         3
30 #define VMBUS_MSG_ALLOFFERS_DELIVERED   4
31 #define VMBUS_MSG_OPENCHANNEL           5
32 #define VMBUS_MSG_OPENCHANNEL_RESULT    6
33 #define VMBUS_MSG_CLOSECHANNEL          7
34 #define VMBUS_MSG_GPADL_HEADER          8
35 #define VMBUS_MSG_GPADL_BODY            9
36 #define VMBUS_MSG_GPADL_CREATED         10
37 #define VMBUS_MSG_GPADL_TEARDOWN        11
38 #define VMBUS_MSG_GPADL_TORNDOWN        12
39 #define VMBUS_MSG_RELID_RELEASED        13
40 #define VMBUS_MSG_INITIATE_CONTACT      14
41 #define VMBUS_MSG_VERSION_RESPONSE      15
42 #define VMBUS_MSG_UNLOAD                16
43 #define VMBUS_MSG_UNLOAD_RESPONSE       17
44 #define VMBUS_MSG_COUNT                 18
45 
46 #define VMBUS_MESSAGE_SIZE_ALIGN        sizeof(uint64_t)
47 
48 #define VMBUS_PACKET_INVALID                    0x0
49 #define VMBUS_PACKET_SYNCH                      0x1
50 #define VMBUS_PACKET_ADD_XFER_PAGESET           0x2
51 #define VMBUS_PACKET_RM_XFER_PAGESET            0x3
52 #define VMBUS_PACKET_ESTABLISH_GPADL            0x4
53 #define VMBUS_PACKET_TEARDOWN_GPADL             0x5
54 #define VMBUS_PACKET_DATA_INBAND                0x6
55 #define VMBUS_PACKET_DATA_USING_XFER_PAGES      0x7
56 #define VMBUS_PACKET_DATA_USING_GPADL           0x8
57 #define VMBUS_PACKET_DATA_USING_GPA_DIRECT      0x9
58 #define VMBUS_PACKET_CANCEL_REQUEST             0xa
59 #define VMBUS_PACKET_COMP                       0xb
60 #define VMBUS_PACKET_DATA_USING_ADDITIONAL_PKT  0xc
61 #define VMBUS_PACKET_ADDITIONAL_DATA            0xd
62 
63 #define VMBUS_CHANNEL_USER_DATA_SIZE            120
64 
65 #define VMBUS_OFFER_MONITOR_ALLOCATED           0x1
66 #define VMBUS_OFFER_INTERRUPT_DEDICATED         0x1
67 
68 #define VMBUS_RING_BUFFER_FEAT_PENDING_SZ       (1ul << 0)
69 
70 #define VMBUS_CHANNEL_ENUMERATE_DEVICE_INTERFACE      0x1
71 #define VMBUS_CHANNEL_SERVER_SUPPORTS_TRANSFER_PAGES  0x2
72 #define VMBUS_CHANNEL_SERVER_SUPPORTS_GPADLS          0x4
73 #define VMBUS_CHANNEL_NAMED_PIPE_MODE                 0x10
74 #define VMBUS_CHANNEL_LOOPBACK_OFFER                  0x100
75 #define VMBUS_CHANNEL_PARENT_OFFER                    0x200
76 #define VMBUS_CHANNEL_REQUEST_MONITORED_NOTIFICATION  0x400
77 #define VMBUS_CHANNEL_TLNPI_PROVIDER_OFFER            0x2000
78 
79 #define VMBUS_PACKET_FLAG_REQUEST_COMPLETION    1
80 
81 typedef struct vmbus_message_header {
82     uint32_t message_type;
83     uint32_t _padding;
84 } vmbus_message_header;
85 
86 typedef struct vmbus_message_initiate_contact {
87     vmbus_message_header header;
88     uint32_t version_requested;
89     uint32_t target_vcpu;
90     uint64_t interrupt_page;
91     uint64_t monitor_page1;
92     uint64_t monitor_page2;
93 } vmbus_message_initiate_contact;
94 
95 typedef struct vmbus_message_version_response {
96     vmbus_message_header header;
97     uint8_t version_supported;
98     uint8_t status;
99 } vmbus_message_version_response;
100 
101 typedef struct vmbus_message_offer_channel {
102     vmbus_message_header header;
103     uint8_t  type_uuid[16];
104     uint8_t  instance_uuid[16];
105     uint64_t _reserved1;
106     uint64_t _reserved2;
107     uint16_t channel_flags;
108     uint16_t mmio_size_mb;
109     uint8_t  user_data[VMBUS_CHANNEL_USER_DATA_SIZE];
110     uint16_t sub_channel_index;
111     uint16_t _reserved3;
112     uint32_t child_relid;
113     uint8_t  monitor_id;
114     uint8_t  monitor_flags;
115     uint16_t interrupt_flags;
116     uint32_t connection_id;
117 } vmbus_message_offer_channel;
118 
119 typedef struct vmbus_message_rescind_channel_offer {
120     vmbus_message_header header;
121     uint32_t child_relid;
122 } vmbus_message_rescind_channel_offer;
123 
124 typedef struct vmbus_gpa_range {
125     uint32_t byte_count;
126     uint32_t byte_offset;
127     uint64_t pfn_array[];
128 } vmbus_gpa_range;
129 
130 typedef struct vmbus_message_gpadl_header {
131     vmbus_message_header header;
132     uint32_t child_relid;
133     uint32_t gpadl_id;
134     uint16_t range_buflen;
135     uint16_t rangecount;
136     vmbus_gpa_range range[];
137 } QEMU_PACKED vmbus_message_gpadl_header;
138 
139 typedef struct vmbus_message_gpadl_body {
140     vmbus_message_header header;
141     uint32_t message_number;
142     uint32_t gpadl_id;
143     uint64_t pfn_array[];
144 } vmbus_message_gpadl_body;
145 
146 typedef struct vmbus_message_gpadl_created {
147     vmbus_message_header header;
148     uint32_t child_relid;
149     uint32_t gpadl_id;
150     uint32_t status;
151 } vmbus_message_gpadl_created;
152 
153 typedef struct vmbus_message_gpadl_teardown {
154     vmbus_message_header header;
155     uint32_t child_relid;
156     uint32_t gpadl_id;
157 } vmbus_message_gpadl_teardown;
158 
159 typedef struct vmbus_message_gpadl_torndown {
160     vmbus_message_header header;
161     uint32_t gpadl_id;
162 } vmbus_message_gpadl_torndown;
163 
164 typedef struct vmbus_message_open_channel {
165     vmbus_message_header header;
166     uint32_t child_relid;
167     uint32_t open_id;
168     uint32_t ring_buffer_gpadl_id;
169     uint32_t target_vp;
170     uint32_t ring_buffer_offset;
171     uint8_t  user_data[VMBUS_CHANNEL_USER_DATA_SIZE];
172 } vmbus_message_open_channel;
173 
174 typedef struct vmbus_message_open_result {
175     vmbus_message_header header;
176     uint32_t child_relid;
177     uint32_t open_id;
178     uint32_t status;
179 } vmbus_message_open_result;
180 
181 typedef struct vmbus_message_close_channel {
182     vmbus_message_header header;
183     uint32_t child_relid;
184 } vmbus_message_close_channel;
185 
186 typedef struct vmbus_ring_buffer {
187     uint32_t write_index;
188     uint32_t read_index;
189     uint32_t interrupt_mask;
190     uint32_t pending_send_sz;
191     uint32_t _reserved1[12];
192     uint32_t feature_bits;
193 } vmbus_ring_buffer;
194 
195 typedef struct vmbus_packet_hdr {
196     uint16_t type;
197     uint16_t offset_qwords;
198     uint16_t len_qwords;
199     uint16_t flags;
200     uint64_t transaction_id;
201 } vmbus_packet_hdr;
202 
203 typedef struct vmbus_pkt_gpa_direct {
204     uint32_t _reserved;
205     uint32_t rangecount;
206     vmbus_gpa_range range[];
207 } vmbus_pkt_gpa_direct;
208 
209 typedef struct vmbus_xferpg_range {
210     uint32_t byte_count;
211     uint32_t byte_offset;
212 } vmbus_xferpg_range;
213 
214 typedef struct vmbus_pkt_xferpg {
215     uint16_t buffer_id;
216     uint8_t sender_owns_set;
217     uint8_t _reserved;
218     uint32_t rangecount;
219     vmbus_xferpg_range range[];
220 } vmbus_pkt_xferpg;
221 
222 #endif
223