xref: /freebsd/sys/dev/hyperv/utilities/vmbus_icreg.h (revision 8f555c7d0aede12bd1768b0c77c9d321f5f7d06b)
1*8f555c7dSSepherosa Ziehau /*-
2*8f555c7dSSepherosa Ziehau  * Copyright (c) 2016 Microsoft Corp.
3*8f555c7dSSepherosa Ziehau  * All rights reserved.
4*8f555c7dSSepherosa Ziehau  *
5*8f555c7dSSepherosa Ziehau  * Redistribution and use in source and binary forms, with or without
6*8f555c7dSSepherosa Ziehau  * modification, are permitted provided that the following conditions
7*8f555c7dSSepherosa Ziehau  * are met:
8*8f555c7dSSepherosa Ziehau  * 1. Redistributions of source code must retain the above copyright
9*8f555c7dSSepherosa Ziehau  *    notice unmodified, this list of conditions, and the following
10*8f555c7dSSepherosa Ziehau  *    disclaimer.
11*8f555c7dSSepherosa Ziehau  * 2. Redistributions in binary form must reproduce the above copyright
12*8f555c7dSSepherosa Ziehau  *    notice, this list of conditions and the following disclaimer in the
13*8f555c7dSSepherosa Ziehau  *    documentation and/or other materials provided with the distribution.
14*8f555c7dSSepherosa Ziehau  *
15*8f555c7dSSepherosa Ziehau  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16*8f555c7dSSepherosa Ziehau  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17*8f555c7dSSepherosa Ziehau  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18*8f555c7dSSepherosa Ziehau  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19*8f555c7dSSepherosa Ziehau  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20*8f555c7dSSepherosa Ziehau  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21*8f555c7dSSepherosa Ziehau  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22*8f555c7dSSepherosa Ziehau  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23*8f555c7dSSepherosa Ziehau  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24*8f555c7dSSepherosa Ziehau  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25*8f555c7dSSepherosa Ziehau  *
26*8f555c7dSSepherosa Ziehau  * $FreeBSD$
27*8f555c7dSSepherosa Ziehau  */
28*8f555c7dSSepherosa Ziehau 
29*8f555c7dSSepherosa Ziehau #ifndef _VMBUS_ICREG_H_
30*8f555c7dSSepherosa Ziehau #define _VMBUS_ICREG_H_
31*8f555c7dSSepherosa Ziehau 
32*8f555c7dSSepherosa Ziehau #define VMBUS_ICMSG_TYPE_NEGOTIATE	0
33*8f555c7dSSepherosa Ziehau #define VMBUS_ICMSG_TYPE_HEARTBEAT	1
34*8f555c7dSSepherosa Ziehau #define VMBUS_ICMSG_TYPE_KVP		2
35*8f555c7dSSepherosa Ziehau #define VMBUS_ICMSG_TYPE_SHUTDOWN	3
36*8f555c7dSSepherosa Ziehau #define VMBUS_ICMSG_TYPE_TIMESYNC	4
37*8f555c7dSSepherosa Ziehau #define VMBUS_ICMSG_TYPE_VSS		5
38*8f555c7dSSepherosa Ziehau 
39*8f555c7dSSepherosa Ziehau #define VMBUS_ICMSG_STATUS_OK		0x00000000
40*8f555c7dSSepherosa Ziehau #define VMBUS_ICMSG_STATUS_FAIL		0x80004005
41*8f555c7dSSepherosa Ziehau 
42*8f555c7dSSepherosa Ziehau #define VMBUS_IC_VERSION(major, minor)	((major) | (((uint32_t)(minor)) << 16))
43*8f555c7dSSepherosa Ziehau #define VMBUS_ICVER_MAJOR(ver)		((ver) & 0xffff)
44*8f555c7dSSepherosa Ziehau #define VMBUS_ICVER_MINOR(ver)		(((ver) & 0xffff0000) >> 16)
45*8f555c7dSSepherosa Ziehau 
46*8f555c7dSSepherosa Ziehau struct vmbus_pipe_hdr {
47*8f555c7dSSepherosa Ziehau 	uint32_t		ph_flags;
48*8f555c7dSSepherosa Ziehau 	uint32_t		ph_msgsz;
49*8f555c7dSSepherosa Ziehau } __packed;
50*8f555c7dSSepherosa Ziehau 
51*8f555c7dSSepherosa Ziehau struct vmbus_icmsg_hdr {
52*8f555c7dSSepherosa Ziehau 	struct vmbus_pipe_hdr	ic_pipe;
53*8f555c7dSSepherosa Ziehau 	uint32_t		ic_fwver;	/* framework version */
54*8f555c7dSSepherosa Ziehau 	uint16_t		ic_type;
55*8f555c7dSSepherosa Ziehau 	uint32_t		ic_msgver;	/* message version */
56*8f555c7dSSepherosa Ziehau 	uint16_t		ic_dsize;	/* data size */
57*8f555c7dSSepherosa Ziehau 	uint32_t		ic_status;	/* VMBUS_ICMSG_STATUS_ */
58*8f555c7dSSepherosa Ziehau 	uint8_t			ic_xactid;
59*8f555c7dSSepherosa Ziehau 	uint8_t			ic_flags;	/* VMBUS_ICMSG_FLAG_ */
60*8f555c7dSSepherosa Ziehau 	uint8_t			ic_rsvd[2];
61*8f555c7dSSepherosa Ziehau } __packed;
62*8f555c7dSSepherosa Ziehau 
63*8f555c7dSSepherosa Ziehau #define VMBUS_ICMSG_FLAG_XACT		0x0001
64*8f555c7dSSepherosa Ziehau #define VMBUS_ICMSG_FLAG_REQ		0x0002
65*8f555c7dSSepherosa Ziehau #define VMBUS_ICMSG_FLAG_RESP		0x0004
66*8f555c7dSSepherosa Ziehau 
67*8f555c7dSSepherosa Ziehau /* VMBUS_ICMSG_TYPE_NEGOTIATE */
68*8f555c7dSSepherosa Ziehau struct vmbus_icmsg_negotiate {
69*8f555c7dSSepherosa Ziehau 	struct vmbus_icmsg_hdr	ic_hdr;
70*8f555c7dSSepherosa Ziehau 	uint16_t		ic_fwver_cnt;
71*8f555c7dSSepherosa Ziehau 	uint16_t		ic_msgver_cnt;
72*8f555c7dSSepherosa Ziehau 	uint32_t		ic_rsvd;
73*8f555c7dSSepherosa Ziehau 	/*
74*8f555c7dSSepherosa Ziehau 	 * This version array contains two set of supported
75*8f555c7dSSepherosa Ziehau 	 * versions:
76*8f555c7dSSepherosa Ziehau 	 * - The first set consists of #ic_fwver_cnt supported framework
77*8f555c7dSSepherosa Ziehau 	 *   versions.
78*8f555c7dSSepherosa Ziehau 	 * - The second set consists of #ic_msgver_cnt supported message
79*8f555c7dSSepherosa Ziehau 	 *   versions.
80*8f555c7dSSepherosa Ziehau 	 */
81*8f555c7dSSepherosa Ziehau 	uint32_t		ic_ver[];
82*8f555c7dSSepherosa Ziehau } __packed;
83*8f555c7dSSepherosa Ziehau 
84*8f555c7dSSepherosa Ziehau #endif	/* !_VMBUS_ICREG_H_ */
85