1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright (c) 2018, Microsoft Corporation.
10 * Hyper-V SynIC message format.
12 #define VMBUS_MSG_DSIZE_MAX 240
13 #define VMBUS_MSG_SIZE 256
15 struct vmbus_message {
16 uint32_t type; /* HYPERV_MSGTYPE_ */
17 uint8_t dsize; /* data size */
18 uint8_t flags; /* VMBUS_MSGFLAG_ */
21 uint8_t data[VMBUS_MSG_DSIZE_MAX];
24 #define VMBUS_MSGFLAG_PENDING 0x01
27 * Hyper-V Monitor Notification Facility
30 struct vmbus_mon_trig {
35 #define VMBUS_MONTRIGS_MAX 4
36 #define VMBUS_MONTRIG_LEN 32
39 * Hyper-V Monitor Notification Facility
41 struct hyperv_mon_param {
47 struct vmbus_mon_page {
51 struct vmbus_mon_trig trigs[VMBUS_MONTRIGS_MAX];
54 uint16_t lat[VMBUS_MONTRIGS_MAX][VMBUS_MONTRIG_LEN];
57 struct hyperv_mon_param
58 param[VMBUS_MONTRIGS_MAX][VMBUS_MONTRIG_LEN];
66 struct vmbus_bufring {
67 volatile uint32_t windex;
68 volatile uint32_t rindex;
71 * Interrupt mask {0,1}
73 * For TX bufring, host set this to 1, when it is processing
74 * the TX bufring, so that we can safely skip the TX event
75 * notification to host.
77 * For RX bufring, once this is set to 1 by us, host will not
78 * further dispatch interrupts to us, even if there are data
79 * pending on the RX bufring. This effectively disables the
80 * interrupt of the channel to which this RX bufring is attached.
82 volatile uint32_t imask;
85 * Win8 uses some of the reserved bits to implement
86 * interrupt driven flow management. On the send side
87 * we can request that the receiver interrupt the sender
88 * when the ring transitions from being full to being able
89 * to handle a message of size "pending_send_sz".
91 * Add necessary state for this enhancement.
93 volatile uint32_t pending_send;
94 uint32_t reserved1[12];
98 uint32_t feat_pending_send_sz:1;
103 /* Pad it to rte_mem_page_size() so that data starts on page boundary */
104 uint8_t reserved2[4028];
107 * Ring data starts here + RingDataStartOffset
108 * !!! DO NOT place any fields below this !!!
117 /* Channel packet flags */
118 #define VMBUS_CHANPKT_TYPE_INBAND 0x0006
119 #define VMBUS_CHANPKT_TYPE_RXBUF 0x0007
120 #define VMBUS_CHANPKT_TYPE_GPA 0x0009
121 #define VMBUS_CHANPKT_TYPE_COMP 0x000b
123 #define VMBUS_CHANPKT_FLAG_NONE 0
124 #define VMBUS_CHANPKT_FLAG_RC 0x0001 /* report completion */
126 #define VMBUS_CHANPKT_SIZE_SHIFT 3
127 #define VMBUS_CHANPKT_SIZE_ALIGN (1 << VMBUS_CHANPKT_SIZE_SHIFT)
128 #define VMBUS_CHANPKT_HLEN_MIN \
129 (sizeof(struct vmbus_chanpkt_hdr) >> VMBUS_CHANPKT_SIZE_SHIFT)
131 static inline uint32_t
132 vmbus_chanpkt_getlen(uint16_t pktlen)
134 return (uint32_t)pktlen << VMBUS_CHANPKT_SIZE_SHIFT;
140 struct vmbus_gpa_range {
146 /* This is actually vmbus_gpa_range.gpa_page[1] */
153 struct vmbus_chanpkt_hdr {
154 uint16_t type; /* VMBUS_CHANPKT_TYPE_ */
155 uint16_t hlen; /* header len, in 8 bytes */
156 uint16_t tlen; /* total len, in 8 bytes */
157 uint16_t flags; /* VMBUS_CHANPKT_FLAG_ */
161 static inline uint32_t
162 vmbus_chanpkt_datalen(const struct vmbus_chanpkt_hdr *pkt)
164 return vmbus_chanpkt_getlen(pkt->tlen)
165 - vmbus_chanpkt_getlen(pkt->hlen);
168 struct vmbus_chanpkt {
169 struct vmbus_chanpkt_hdr hdr;
172 struct vmbus_rxbuf_desc {
177 struct vmbus_chanpkt_rxbuf {
178 struct vmbus_chanpkt_hdr hdr;
182 struct vmbus_rxbuf_desc rxbuf[];
185 struct vmbus_chanpkt_sglist {
186 struct vmbus_chanpkt_hdr hdr;
189 struct vmbus_gpa gpa[];
194 * - Embedded in vmbus_message.msg_data, e.g. response and notification.
195 * - Embedded in hypercall_postmsg_in.hc_data, e.g. request.
198 #define VMBUS_CHANMSG_TYPE_CHOFFER 1 /* NOTE */
199 #define VMBUS_CHANMSG_TYPE_CHRESCIND 2 /* NOTE */
200 #define VMBUS_CHANMSG_TYPE_CHREQUEST 3 /* REQ */
201 #define VMBUS_CHANMSG_TYPE_CHOFFER_DONE 4 /* NOTE */
202 #define VMBUS_CHANMSG_TYPE_CHOPEN 5 /* REQ */
203 #define VMBUS_CHANMSG_TYPE_CHOPEN_RESP 6 /* RESP */
204 #define VMBUS_CHANMSG_TYPE_CHCLOSE 7 /* REQ */
205 #define VMBUS_CHANMSG_TYPE_GPADL_CONN 8 /* REQ */
206 #define VMBUS_CHANMSG_TYPE_GPADL_SUBCONN 9 /* REQ */
207 #define VMBUS_CHANMSG_TYPE_GPADL_CONNRESP 10 /* RESP */
208 #define VMBUS_CHANMSG_TYPE_GPADL_DISCONN 11 /* REQ */
209 #define VMBUS_CHANMSG_TYPE_GPADL_DISCONNRESP 12 /* RESP */
210 #define VMBUS_CHANMSG_TYPE_CHFREE 13 /* REQ */
211 #define VMBUS_CHANMSG_TYPE_CONNECT 14 /* REQ */
212 #define VMBUS_CHANMSG_TYPE_CONNECT_RESP 15 /* RESP */
213 #define VMBUS_CHANMSG_TYPE_DISCONNECT 16 /* REQ */
214 #define VMBUS_CHANMSG_TYPE_MAX 22
216 struct vmbus_chanmsg_hdr {
217 uint32_t type; /* VMBUS_CHANMSG_TYPE_ */
221 /* VMBUS_CHANMSG_TYPE_CONNECT */
222 struct vmbus_chanmsg_connect {
223 struct vmbus_chanmsg_hdr hdr;
231 /* VMBUS_CHANMSG_TYPE_CONNECT_RESP */
232 struct vmbus_chanmsg_connect_resp {
233 struct vmbus_chanmsg_hdr hdr;
237 /* VMBUS_CHANMSG_TYPE_CHREQUEST */
238 struct vmbus_chanmsg_chrequest {
239 struct vmbus_chanmsg_hdr hdr;
242 /* VMBUS_CHANMSG_TYPE_DISCONNECT */
243 struct vmbus_chanmsg_disconnect {
244 struct vmbus_chanmsg_hdr hdr;
247 /* VMBUS_CHANMSG_TYPE_CHOPEN */
248 struct vmbus_chanmsg_chopen {
249 struct vmbus_chanmsg_hdr hdr;
255 #define VMBUS_CHANMSG_CHOPEN_UDATA_SIZE 120
256 uint8_t udata[VMBUS_CHANMSG_CHOPEN_UDATA_SIZE];
259 /* VMBUS_CHANMSG_TYPE_CHOPEN_RESP */
260 struct vmbus_chanmsg_chopen_resp {
261 struct vmbus_chanmsg_hdr hdr;
267 /* VMBUS_CHANMSG_TYPE_GPADL_CONN */
268 struct vmbus_chanmsg_gpadl_conn {
269 struct vmbus_chanmsg_hdr hdr;
274 struct vmbus_gpa_range range;
277 #define VMBUS_CHANMSG_GPADL_CONN_PGMAX 26
279 /* VMBUS_CHANMSG_TYPE_GPADL_SUBCONN */
280 struct vmbus_chanmsg_gpadl_subconn {
281 struct vmbus_chanmsg_hdr hdr;
287 #define VMBUS_CHANMSG_GPADL_SUBCONN_PGMAX 28
289 /* VMBUS_CHANMSG_TYPE_GPADL_CONNRESP */
290 struct vmbus_chanmsg_gpadl_connresp {
291 struct vmbus_chanmsg_hdr hdr;
297 /* VMBUS_CHANMSG_TYPE_CHCLOSE */
298 struct vmbus_chanmsg_chclose {
299 struct vmbus_chanmsg_hdr hdr;
303 /* VMBUS_CHANMSG_TYPE_GPADL_DISCONN */
304 struct vmbus_chanmsg_gpadl_disconn {
305 struct vmbus_chanmsg_hdr hdr;
310 /* VMBUS_CHANMSG_TYPE_CHFREE */
311 struct vmbus_chanmsg_chfree {
312 struct vmbus_chanmsg_hdr hdr;
316 /* VMBUS_CHANMSG_TYPE_CHRESCIND */
317 struct vmbus_chanmsg_chrescind {
318 struct vmbus_chanmsg_hdr hdr;
322 /* VMBUS_CHANMSG_TYPE_CHOFFER */
323 struct vmbus_chanmsg_choffer {
324 struct vmbus_chanmsg_hdr hdr;
327 uint64_t chlat; /* unit: 100ns */
331 uint16_t mmio_sz; /* unit: MB */
337 uint8_t flags1; /* VMBUS_CHOFFER_FLAG1_ */
342 #define VMBUS_CHOFFER_FLAG1_HASMNF 0x01
344 #endif /* !_VMBUS_REG_H_ */