xref: /openbsd-src/sys/dev/pv/hypervreg.h (revision f2da64fbbbf1b03f09f390ab01267c93dfd77c4c)
1 /*-
2  * Copyright (c) 2009-2012,2016 Microsoft Corp.
3  * Copyright (c) 2012 NetApp Inc.
4  * Copyright (c) 2012 Citrix Inc.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice unmodified, this list of conditions, and the following
12  *    disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 #ifndef _DEV_PV_HYPERVREG_H_
30 #define _DEV_PV_HYPERVREG_H_
31 
32 struct hv_guid {
33 	 unsigned char			data[16];
34 } __packed;
35 
36 #define VMBUS_CONNID_MESSAGE		1
37 #define VMBUS_CONNID_EVENT		2
38 #define VMBUS_SINT_MESSAGE		2
39 
40 #define VMBUS_GPADL_START		0xffff /* 0x10000 effectively */
41 
42 /*
43  * ============================================================================
44  * hyperv_reg.h
45  * ============================================================================
46  */
47 
48 /*
49  * Hyper-V Synthetic MSRs
50  */
51 
52 #define MSR_HV_GUEST_OS_ID		0x40000000
53 #define MSR_HV_GUESTID_BUILD_MASK	0xffffULL
54 #define MSR_HV_GUESTID_VERSION_MASK	0x0000ffffffff0000ULL
55 #define MSR_HV_GUESTID_VERSION_SHIFT	16
56 #define MSR_HV_GUESTID_OSID_MASK	0x00ff000000000000ULL
57 #define MSR_HV_GUESTID_OSID_SHIFT	48
58 #define MSR_HV_GUESTID_OSTYPE_MASK	0x7f00000000000000ULL
59 #define MSR_HV_GUESTID_OSTYPE_SHIFT	56
60 #define MSR_HV_GUESTID_OPENSRC		0x8000000000000000ULL
61 #define MSR_HV_GUESTID_OSTYPE_LINUX	\
62 	((0x01ULL << MSR_HV_GUESTID_OSTYPE_SHIFT) | MSR_HV_GUESTID_OPENSRC)
63 #define MSR_HV_GUESTID_OSTYPE_FREEBSD	\
64 	((0x02ULL << MSR_HV_GUESTID_OSTYPE_SHIFT) | MSR_HV_GUESTID_OPENSRC)
65 
66 #define MSR_HV_HYPERCALL		0x40000001
67 #define MSR_HV_HYPERCALL_ENABLE		0x0001ULL
68 #define MSR_HV_HYPERCALL_RSVD_MASK	0x0ffeULL
69 #define MSR_HV_HYPERCALL_PGSHIFT	12
70 
71 #define MSR_HV_VP_INDEX			0x40000002
72 
73 #define MSR_HV_TIME_REF_COUNT		0x40000020
74 
75 #define MSR_HV_SCONTROL			0x40000080
76 #define MSR_HV_SCTRL_ENABLE		0x0001ULL
77 #define MSR_HV_SCTRL_RSVD_MASK		0xfffffffffffffffeULL
78 
79 #define MSR_HV_SIEFP			0x40000082
80 #define MSR_HV_SIEFP_ENABLE		0x0001ULL
81 #define MSR_HV_SIEFP_RSVD_MASK		0x0ffeULL
82 #define MSR_HV_SIEFP_PGSHIFT		12
83 
84 #define MSR_HV_SIMP			0x40000083
85 #define MSR_HV_SIMP_ENABLE		0x0001ULL
86 #define MSR_HV_SIMP_RSVD_MASK		0x0ffeULL
87 #define MSR_HV_SIMP_PGSHIFT		12
88 
89 #define MSR_HV_EOM			0x40000084
90 
91 #define MSR_HV_SINT0			0x40000090
92 #define MSR_HV_SINT_VECTOR_MASK		0x00ffULL
93 #define MSR_HV_SINT_RSVD1_MASK		0xff00ULL
94 #define MSR_HV_SINT_MASKED		0x00010000ULL
95 #define MSR_HV_SINT_AUTOEOI		0x00020000ULL
96 #define MSR_HV_SINT_RSVD2_MASK		0xfffffffffffc0000ULL
97 #define MSR_HV_SINT_RSVD_MASK		(MSR_HV_SINT_RSVD1_MASK |	\
98 					 MSR_HV_SINT_RSVD2_MASK)
99 
100 #define MSR_HV_STIMER0_CONFIG		0x400000b0
101 #define MSR_HV_STIMER_CFG_ENABLE	0x0001ULL
102 #define MSR_HV_STIMER_CFG_PERIODIC	0x0002ULL
103 #define MSR_HV_STIMER_CFG_LAZY		0x0004ULL
104 #define MSR_HV_STIMER_CFG_AUTOEN	0x0008ULL
105 #define MSR_HV_STIMER_CFG_SINT_MASK	0x000f0000ULL
106 #define MSR_HV_STIMER_CFG_SINT_SHIFT	16
107 
108 #define MSR_HV_STIMER0_COUNT		0x400000b1
109 
110 /*
111  * CPUID leaves
112  */
113 
114 #define CPUID_LEAF_HV_MAXLEAF		0x40000000
115 
116 #define CPUID_LEAF_HV_INTERFACE		0x40000001
117 #define CPUID_HV_IFACE_HYPERV		0x31237648	/* HV#1 */
118 
119 #define CPUID_LEAF_HV_IDENTITY		0x40000002
120 
121 #define CPUID_LEAF_HV_FEATURES		0x40000003
122 /* EAX: features */
123 #define CPUID_HV_MSR_TIME_REFCNT	0x0002	/* MSR_HV_TIME_REF_COUNT */
124 #define CPUID_HV_MSR_SYNIC		0x0004	/* MSRs for SynIC */
125 #define CPUID_HV_MSR_SYNTIMER		0x0008	/* MSRs for SynTimer */
126 #define CPUID_HV_MSR_APIC		0x0010	/* MSR_HV_{EOI,ICR,TPR} */
127 #define CPUID_HV_MSR_HYPERCALL		0x0020	/* MSR_HV_GUEST_OS_ID
128 						 * MSR_HV_HYPERCALL */
129 #define CPUID_HV_MSR_VP_INDEX		0x0040	/* MSR_HV_VP_INDEX */
130 #define CPUID_HV_MSR_GUEST_IDLE		0x0400	/* MSR_HV_GUEST_IDLE */
131 /* ECX: power management features */
132 #define CPUPM_HV_CSTATE_MASK		0x000f	/* deepest C-state */
133 #define CPUPM_HV_C3_HPET		0x0010	/* C3 requires HPET */
134 #define CPUPM_HV_CSTATE(f)		((f) & CPUPM_HV_CSTATE_MASK)
135 /* EDX: features3 */
136 #define CPUID3_HV_MWAIT			0x0001	/* MWAIT */
137 #define CPUID3_HV_XMM_HYPERCALL		0x0010	/* Hypercall input through
138 						 * XMM regs */
139 #define CPUID3_HV_GUEST_IDLE		0x0020	/* guest idle */
140 #define CPUID3_HV_NUMA			0x0080	/* NUMA distance query */
141 #define CPUID3_HV_TIME_FREQ		0x0100	/* timer frequency query
142 						 * (TSC, LAPIC) */
143 #define CPUID3_HV_MSR_CRASH		0x0400	/* MSRs for guest crash */
144 
145 #define CPUID_LEAF_HV_RECOMMENDS	0x40000004
146 #define CPUID_LEAF_HV_LIMITS		0x40000005
147 #define CPUID_LEAF_HV_HWFEATURES	0x40000006
148 
149 /*
150  * Hyper-V Monitor Notification Facility
151  */
152 struct hv_mon_param {
153 	uint32_t	mp_connid;
154 	uint16_t	mp_evtflag_ofs;
155 	uint16_t	mp_rsvd;
156 } __packed;
157 
158 /*
159  * Hyper-V message types
160  */
161 #define VMBUS_MSGTYPE_NONE		0
162 #define VMBUS_MSGTYPE_CHANNEL		1
163 #define VMBUS_MSGTYPE_TIMER_EXPIRED	0x80000010
164 
165 /*
166  * Hypercall status codes
167  */
168 #define HYPERCALL_STATUS_SUCCESS	0x0000
169 
170 /*
171  * Hypercall input values
172  */
173 #define HYPERCALL_POST_MESSAGE		0x005c
174 #define HYPERCALL_SIGNAL_EVENT		0x005d
175 
176 /*
177  * Hypercall input parameters
178  */
179 #define HYPERCALL_PARAM_ALIGN		8
180 #if 0
181 /*
182  * XXX
183  * <<Hypervisor Top Level Functional Specification 4.0b>> requires
184  * input parameters size to be multiple of 8, however, many post
185  * message input parameters do _not_ meet this requirement.
186  */
187 #define HYPERCALL_PARAM_SIZE_ALIGN	8
188 #endif
189 
190 /*
191  * HYPERCALL_POST_MESSAGE
192  */
193 #define HYPERCALL_POSTMSGIN_DSIZE_MAX	240
194 #define HYPERCALL_POSTMSGIN_SIZE	256
195 
196 struct hypercall_postmsg_in {
197 	uint32_t	hc_connid;
198 	uint32_t	hc_rsvd;
199 	uint32_t	hc_msgtype;	/* VMBUS_MSGTYPE_ */
200 	uint32_t	hc_dsize;
201 	uint8_t		hc_data[HYPERCALL_POSTMSGIN_DSIZE_MAX];
202 } __packed;
203 
204 /*
205  * ============================================================================
206  * vmbus.h
207  * ============================================================================
208  */
209 
210 /*
211  * VMBUS version is 32 bit, upper 16 bit for major_number and lower
212  * 16 bit for minor_number.
213  *
214  * 0.13  --  Windows Server 2008
215  * 1.1   --  Windows 7
216  * 2.4   --  Windows 8
217  * 3.0   --  Windows 8.1
218  */
219 #define VMBUS_VERSION_WS2008		((0 << 16) | (13))
220 #define VMBUS_VERSION_WIN7		((1 << 16) | (1))
221 #define VMBUS_VERSION_WIN8		((2 << 16) | (4))
222 #define VMBUS_VERSION_WIN8_1		((3 << 16) | (0))
223 
224 #define VMBUS_VERSION_MAJOR(ver)	(((uint32_t)(ver)) >> 16)
225 #define VMBUS_VERSION_MINOR(ver)	(((uint32_t)(ver)) & 0xffff)
226 
227 /*
228  * GPA stuffs.
229  */
230 struct vmbus_gpa_range {
231 	uint32_t	gpa_len;
232 	uint32_t	gpa_ofs;
233 	uint64_t	gpa_page[0];
234 } __packed;
235 
236 /* This is actually vmbus_gpa_range.gpa_page[1] */
237 struct vmbus_gpa {
238 	uint32_t	gpa_len;
239 	uint32_t	gpa_ofs;
240 	uint64_t	gpa_page;
241 } __packed;
242 
243 #define VMBUS_CHANPKT_SIZE_SHIFT	3
244 
245 #define VMBUS_CHANPKT_GETLEN(pktlen)	\
246 	(((int)(pktlen)) << VMBUS_CHANPKT_SIZE_SHIFT)
247 
248 struct vmbus_chanpkt_hdr {
249 	uint16_t	cph_type;	/* VMBUS_CHANPKT_TYPE_ */
250 	uint16_t	cph_hlen;	/* header len, in 8 bytes */
251 	uint16_t	cph_tlen;	/* total len, in 8 bytes */
252 	uint16_t	cph_flags;	/* VMBUS_CHANPKT_FLAG_ */
253 	uint64_t	cph_tid;
254 } __packed;
255 
256 #define VMBUS_CHANPKT_TYPE_INBAND	0x0006
257 #define VMBUS_CHANPKT_TYPE_RXBUF	0x0007
258 #define VMBUS_CHANPKT_TYPE_GPA		0x0009
259 #define VMBUS_CHANPKT_TYPE_COMP		0x000b
260 
261 #define VMBUS_CHANPKT_FLAG_RC		0x0001	/* report completion */
262 
263 #define VMBUS_CHANPKT_CONST_DATA(pkt)			\
264 	((const void *)((const uint8_t *)(pkt) +	\
265 	    VMBUS_CHANPKT_GETLEN((pkt)->cph_hlen)))
266 
267 /*
268  * ============================================================================
269  * vmbus_reg.h
270  * ============================================================================
271  */
272 
273 /*
274  * Hyper-V SynIC message format.
275  */
276 
277 #define VMBUS_MSG_DSIZE_MAX		240
278 #define VMBUS_MSG_SIZE			256
279 
280 struct vmbus_message {
281 	uint32_t	msg_type;	/* VMBUS_MSGTYPE_ */
282 	uint8_t		msg_dsize;	/* data size */
283 	uint8_t		msg_flags;	/* VMBUS_MSGFLAG_ */
284 	uint16_t	msg_rsvd;
285 	uint64_t	msg_id;
286 	uint8_t		msg_data[VMBUS_MSG_DSIZE_MAX];
287 } __packed;
288 
289 #define VMBUS_MSGFLAG_PENDING		0x01
290 
291 /*
292  * Hyper-V SynIC event flags
293  */
294 
295 #define VMBUS_EVTFLAGS_SIZE	256
296 #define VMBUS_EVTFLAGS_MAX	((VMBUS_EVTFLAGS_SIZE / LONG_BIT) * 8)
297 #define VMBUS_EVTFLAG_LEN	LONG_BIT
298 #define VMBUS_EVTFLAG_MASK	(LONG_BIT - 1)
299 
300 struct vmbus_evtflags {
301 	ulong		evt_flags[VMBUS_EVTFLAGS_MAX];
302 } __packed;
303 
304 /*
305  * Hyper-V Monitor Notification Facility
306  */
307 
308 struct vmbus_mon_trig {
309 	uint32_t	mt_pending;
310 	uint32_t	mt_armed;
311 } __packed;
312 
313 #define VMBUS_MONTRIGS_MAX	4
314 #define VMBUS_MONTRIG_LEN	32
315 
316 struct vmbus_mnf {
317 	uint32_t	mnf_state;
318 	uint32_t	mnf_rsvd1;
319 
320 	struct vmbus_mon_trig
321 			mnf_trigs[VMBUS_MONTRIGS_MAX];
322 	uint8_t		mnf_rsvd2[536];
323 
324 	uint16_t	mnf_lat[VMBUS_MONTRIGS_MAX][VMBUS_MONTRIG_LEN];
325 	uint8_t		mnf_rsvd3[256];
326 
327 	struct hv_mon_param
328 			mnf_param[VMBUS_MONTRIGS_MAX][VMBUS_MONTRIG_LEN];
329 	uint8_t		mnf_rsvd4[1984];
330 } __packed;
331 
332 /*
333  * Buffer ring
334  */
335 struct vmbus_bufring {
336 	/*
337 	 * If br_windex == br_rindex, this bufring is empty; this
338 	 * means we can _not_ write data to the bufring, if the
339 	 * write is going to make br_windex same as br_rindex.
340 	 */
341 	volatile uint32_t	br_windex;
342 	volatile uint32_t	br_rindex;
343 
344 	/*
345 	 * Interrupt mask {0,1}
346 	 *
347 	 * For TX bufring, host set this to 1, when it is processing
348 	 * the TX bufring, so that we can safely skip the TX event
349 	 * notification to host.
350 	 *
351 	 * For RX bufring, once this is set to 1 by us, host will not
352 	 * further dispatch interrupts to us, even if there are data
353 	 * pending on the RX bufring.  This effectively disables the
354 	 * interrupt of the channel to which this RX bufring is attached.
355 	 */
356 	volatile uint32_t	br_imask;
357 
358 	uint8_t			br_rsvd[4084];
359 	uint8_t			br_data[0];
360 } __packed;
361 
362 /*
363  * Channel
364  */
365 
366 #define VMBUS_CHAN_MAX_COMPAT	256
367 #define VMBUS_CHAN_MAX		(VMBUS_EVTFLAG_LEN * VMBUS_EVTFLAGS_MAX)
368 
369 /*
370  * Channel packets
371  */
372 
373 #define VMBUS_CHANPKT_SIZE_ALIGN	(1 << VMBUS_CHANPKT_SIZE_SHIFT)
374 
375 #define VMBUS_CHANPKT_SETLEN(pktlen, len)		\
376 do {							\
377 	(pktlen) = (len) >> VMBUS_CHANPKT_SIZE_SHIFT;	\
378 } while (0)
379 
380 struct vmbus_chanpkt {
381 	struct vmbus_chanpkt_hdr cp_hdr;
382 } __packed;
383 
384 struct vmbus_chanpkt_sglist {
385 	struct vmbus_chanpkt_hdr cp_hdr;
386 	uint32_t	cp_rsvd;
387 	uint32_t	cp_gpa_cnt;
388 	struct vmbus_gpa cp_gpa[0];
389 } __packed;
390 
391 struct vmbus_chanpkt_prplist {
392 	struct vmbus_chanpkt_hdr cp_hdr;
393 	uint32_t	cp_rsvd;
394 	uint32_t	cp_range_cnt;
395 	struct vmbus_gpa_range cp_range[0];
396 } __packed;
397 
398 /*
399  * Channel messages
400  * - Embedded in vmbus_message.msg_data, e.g. response and notification.
401  * - Embedded in hypercall_postmsg_in.hc_data, e.g. request.
402  */
403 
404 #define VMBUS_CHANMSG_CHOFFER			1	/* NOTE */
405 #define VMBUS_CHANMSG_CHRESCIND			2	/* NOTE */
406 #define VMBUS_CHANMSG_CHREQUEST			3	/* REQ */
407 #define VMBUS_CHANMSG_CHOFFER_DONE		4	/* NOTE */
408 #define VMBUS_CHANMSG_CHOPEN			5	/* REQ */
409 #define VMBUS_CHANMSG_CHOPEN_RESP		6	/* RESP */
410 #define VMBUS_CHANMSG_CHCLOSE			7	/* REQ */
411 #define VMBUS_CHANMSG_GPADL_CONN		8	/* REQ */
412 #define VMBUS_CHANMSG_GPADL_SUBCONN		9	/* REQ */
413 #define VMBUS_CHANMSG_GPADL_CONNRESP		10	/* RESP */
414 #define VMBUS_CHANMSG_GPADL_DISCONN		11	/* REQ */
415 #define VMBUS_CHANMSG_GPADL_DISCONNRESP		12	/* RESP */
416 #define VMBUS_CHANMSG_CHFREE			13	/* REQ */
417 #define VMBUS_CHANMSG_CONNECT			14	/* REQ */
418 #define VMBUS_CHANMSG_CONNECT_RESP		15	/* RESP */
419 #define VMBUS_CHANMSG_DISCONNECT		16	/* REQ */
420 #define VMBUS_CHANMSG_COUNT			17
421 #define VMBUS_CHANMSG_MAX			22
422 
423 struct vmbus_chanmsg_hdr {
424 	uint32_t	chm_type;	/* VMBUS_CHANMSG_* */
425 	uint32_t	chm_rsvd;
426 } __packed;
427 
428 /* VMBUS_CHANMSG_CONNECT */
429 struct vmbus_chanmsg_connect {
430 	struct vmbus_chanmsg_hdr chm_hdr;
431 	uint32_t	chm_ver;
432 	uint32_t	chm_rsvd;
433 	uint64_t	chm_evtflags;
434 	uint64_t	chm_mnf1;
435 	uint64_t	chm_mnf2;
436 } __packed;
437 
438 /* VMBUS_CHANMSG_CONNECT_RESP */
439 struct vmbus_chanmsg_connect_resp {
440 	struct vmbus_chanmsg_hdr chm_hdr;
441 	uint8_t		chm_done;
442 } __packed;
443 
444 /* VMBUS_CHANMSG_CHREQUEST */
445 struct vmbus_chanmsg_chrequest {
446 	struct vmbus_chanmsg_hdr chm_hdr;
447 } __packed;
448 
449 /* VMBUS_CHANMSG_DISCONNECT */
450 struct vmbus_chanmsg_disconnect {
451 	struct vmbus_chanmsg_hdr chm_hdr;
452 } __packed;
453 
454 /* VMBUS_CHANMSG_CHOPEN */
455 struct vmbus_chanmsg_chopen {
456 	struct vmbus_chanmsg_hdr chm_hdr;
457 	uint32_t	chm_chanid;
458 	uint32_t	chm_openid;
459 	uint32_t	chm_gpadl;
460 	uint32_t	chm_vcpuid;
461 	uint32_t	chm_txbr_pgcnt;
462 #define VMBUS_CHANMSG_CHOPEN_UDATA_SIZE	120
463 	uint8_t		chm_udata[VMBUS_CHANMSG_CHOPEN_UDATA_SIZE];
464 } __packed;
465 
466 /* VMBUS_CHANMSG_CHOPEN_RESP */
467 struct vmbus_chanmsg_chopen_resp {
468 	struct vmbus_chanmsg_hdr chm_hdr;
469 	uint32_t	chm_chanid;
470 	uint32_t	chm_openid;
471 	uint32_t	chm_status;
472 } __packed;
473 
474 /* VMBUS_CHANMSG_GPADL_CONN */
475 struct vmbus_chanmsg_gpadl_conn {
476 	struct vmbus_chanmsg_hdr chm_hdr;
477 	uint32_t	chm_chanid;
478 	uint32_t	chm_gpadl;
479 	uint16_t	chm_range_len;
480 	uint16_t	chm_range_cnt;
481 	struct vmbus_gpa_range chm_range;
482 } __packed;
483 
484 #define VMBUS_CHANMSG_GPADL_CONN_PGMAX		26
485 
486 /* VMBUS_CHANMSG_GPADL_SUBCONN */
487 struct vmbus_chanmsg_gpadl_subconn {
488 	struct vmbus_chanmsg_hdr chm_hdr;
489 	uint32_t	chm_msgno;
490 	uint32_t	chm_gpadl;
491 	uint64_t	chm_gpa_page[0];
492 } __packed;
493 
494 #define VMBUS_CHANMSG_GPADL_SUBCONN_PGMAX	28
495 
496 /* VMBUS_CHANMSG_GPADL_CONNRESP */
497 struct vmbus_chanmsg_gpadl_connresp {
498 	struct vmbus_chanmsg_hdr chm_hdr;
499 	uint32_t	chm_chanid;
500 	uint32_t	chm_gpadl;
501 	uint32_t	chm_status;
502 } __packed;
503 
504 /* VMBUS_CHANMSG_CHCLOSE */
505 struct vmbus_chanmsg_chclose {
506 	struct vmbus_chanmsg_hdr chm_hdr;
507 	uint32_t	chm_chanid;
508 } __packed;
509 
510 /* VMBUS_CHANMSG_GPADL_DISCONN */
511 struct vmbus_chanmsg_gpadl_disconn {
512 	struct vmbus_chanmsg_hdr chm_hdr;
513 	uint32_t	chm_chanid;
514 	uint32_t	chm_gpadl;
515 } __packed;
516 
517 /* VMBUS_CHANMSG_CHFREE */
518 struct vmbus_chanmsg_chfree {
519 	struct vmbus_chanmsg_hdr chm_hdr;
520 	uint32_t	chm_chanid;
521 } __packed;
522 
523 /* VMBUS_CHANMSG_CHRESCIND */
524 struct vmbus_chanmsg_chrescind {
525 	struct vmbus_chanmsg_hdr chm_hdr;
526 	uint32_t	chm_chanid;
527 } __packed;
528 
529 /* VMBUS_CHANMSG_CHOFFER */
530 struct vmbus_chanmsg_choffer {
531 	struct vmbus_chanmsg_hdr chm_hdr;
532 	struct hv_guid	chm_chtype;
533 	struct hv_guid	chm_chinst;
534 	uint64_t	chm_chlat;	/* unit: 100ns */
535 	uint32_t	chm_chrev;
536 	uint32_t	chm_svrctx_sz;
537 	uint16_t	chm_chflags;
538 	uint16_t	chm_mmio_sz;	/* unit: MB */
539 	uint8_t		chm_udata[120];
540 	uint16_t	chm_subidx;
541 	uint16_t	chm_rsvd;
542 	uint32_t	chm_chanid;
543 	uint8_t		chm_montrig;
544 	uint8_t		chm_flags1;	/* VMBUS_CHOFFER_FLAG1_ */
545 	uint16_t	chm_flags2;
546 	uint32_t	chm_connid;
547 } __packed;
548 
549 #define VMBUS_CHOFFER_FLAG1_HASMNF	0x01
550 
551 /*
552  * ============================================================================
553  * Integrated services
554  * ============================================================================
555  */
556 
557  /*
558   * Common defines for Hyper-V ICs
559   */
560 #define HV_ICMSGTYPE_NEGOTIATE		0
561 #define HV_ICMSGTYPE_HEARTBEAT		1
562 #define HV_ICMSGTYPE_KVPEXCHANGE	2
563 #define HV_ICMSGTYPE_SHUTDOWN		3
564 #define HV_ICMSGTYPE_TIMESYNC		4
565 #define HV_ICMSGTYPE_VSS		5
566 
567 #define HV_ICMSGHDRFLAG_TRANSACTION	1
568 #define HV_ICMSGHDRFLAG_REQUEST		2
569 #define HV_ICMSGHDRFLAG_RESPONSE	4
570 
571 struct hv_pipe_hdr {
572 	uint32_t	flags;
573 	uint32_t	msgsize;
574 } __packed;
575 
576 struct hv_ic_version {
577 	uint16_t	major;
578 	uint16_t	minor;
579 } __packed;
580 
581 struct hv_icmsg_hdr {
582 	struct hv_ic_version icverframe;
583 	uint16_t	icmsgtype;
584 	struct hv_ic_version icvermsg;
585 	uint16_t	icmsgsize;
586 	uint32_t	status;
587 	uint8_t		ictransaction_id;
588 	uint8_t		icflags;
589 	uint8_t		reserved[2];
590 } __packed;
591 
592 #define HV_ICMSG_STATUS_OK		0x00000000
593 #define HV_ICMSG_STATUS_FAIL		0x80004005
594 
595 struct hv_icmsg_negotiate {
596 	uint16_t	icframe_vercnt;
597 	uint16_t	icmsg_vercnt;
598 	uint32_t	reserved;
599 	struct hv_ic_version icversion_data[1]; /* any size array */
600 } __packed;
601 
602 struct hv_shutdown_msg {
603 	uint32_t	reason_code;
604 	uint32_t	timeout_seconds;
605 	uint32_t 	flags;
606 	uint8_t		display_message[2048];
607 } __packed;
608 
609 struct hv_timesync_msg {
610 	uint64_t	parent_time;
611 	uint64_t	child_time;
612 	uint64_t	round_trip_time;
613 	uint8_t		flags;
614 #define  HV_TIMESYNC_PROBE		 0
615 #define  HV_TIMESYNC_SYNC		 1
616 #define  HV_TIMESYNC_SAMPLE		 2
617 } __packed;
618 
619 struct hv_heartbeat_msg {
620 	uint64_t 	seq_num;
621 	uint32_t 	reserved[8];
622 } __packed;
623 
624 /*
625  * ============================================================================
626  * Helper macros
627  * ============================================================================
628  */
629 
630 /* How many PFNs can be referenced by the header */
631 #define HV_NPFNHDR	((VMBUS_MSG_DSIZE_MAX -	\
632 	  sizeof(struct vmbus_chanmsg_gpadl_conn)) / sizeof(uint64_t))
633 
634 /* How many PFNs can be referenced by the body */
635 #define HV_NPFNBODY	((VMBUS_MSG_DSIZE_MAX -	\
636 	  sizeof(struct vmbus_chanmsg_gpadl_subconn)) / sizeof(uint64_t))
637 
638 #endif	/* _DEV_PV_HYPERVREG_H_ */
639