2 * Copyright (c) 2016 Microsoft Corp.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice unmodified, this list of conditions, and the following
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 #ifndef _VMBUS_ICREG_H_
30 #define _VMBUS_ICREG_H_
32 #define VMBUS_ICMSG_TYPE_NEGOTIATE 0
33 #define VMBUS_ICMSG_TYPE_HEARTBEAT 1
34 #define VMBUS_ICMSG_TYPE_KVP 2
35 #define VMBUS_ICMSG_TYPE_SHUTDOWN 3
36 #define VMBUS_ICMSG_TYPE_TIMESYNC 4
37 #define VMBUS_ICMSG_TYPE_VSS 5
39 #define VMBUS_ICMSG_STATUS_OK 0x00000000
40 #define VMBUS_ICMSG_STATUS_FAIL 0x80004005
42 #define VMBUS_IC_VERSION(major, minor) ((major) | (((uint32_t)(minor)) << 16))
43 #define VMBUS_ICVER_MAJOR(ver) ((ver) & 0xffff)
44 #define VMBUS_ICVER_MINOR(ver) (((ver) & 0xffff0000) >> 16)
45 #define VMBUS_ICVER_SWAP(ver) \
46 ((VMBUS_ICVER_MAJOR((ver)) << 16) | VMBUS_ICVER_MINOR((ver)))
47 #define VMBUS_ICVER_LE(v1, v2) \
48 (VMBUS_ICVER_SWAP((v1)) <= VMBUS_ICVER_SWAP((v2)))
49 #define VMBUS_ICVER_GT(v1, v2) \
50 (VMBUS_ICVER_SWAP((v1)) > VMBUS_ICVER_SWAP((v2)))
52 struct vmbus_pipe_hdr {
57 struct vmbus_icmsg_hdr {
58 struct vmbus_pipe_hdr ic_pipe;
59 uint32_t ic_fwver; /* framework version */
61 uint32_t ic_msgver; /* message version */
62 uint16_t ic_dsize; /* data size */
63 uint32_t ic_status; /* VMBUS_ICMSG_STATUS_ */
65 uint8_t ic_flags; /* VMBUS_ICMSG_FLAG_ */
69 #define VMBUS_ICMSG_FLAG_XACT 0x0001
70 #define VMBUS_ICMSG_FLAG_REQ 0x0002
71 #define VMBUS_ICMSG_FLAG_RESP 0x0004
73 /* VMBUS_ICMSG_TYPE_NEGOTIATE */
74 struct vmbus_icmsg_negotiate {
75 struct vmbus_icmsg_hdr ic_hdr;
76 uint16_t ic_fwver_cnt;
77 uint16_t ic_msgver_cnt;
80 * This version array contains two set of supported
82 * - The first set consists of #ic_fwver_cnt supported framework
84 * - The second set consists of #ic_msgver_cnt supported message
90 /* VMBUS_ICMSG_TYPE_HEARTBEAT */
91 struct vmbus_icmsg_heartbeat {
92 struct vmbus_icmsg_hdr ic_hdr;
97 #define VMBUS_ICMSG_HEARTBEAT_SIZE_MIN \
98 __offsetof(struct vmbus_icmsg_heartbeat, ic_rsvd[0])
100 /* VMBUS_ICMSG_TYPE_SHUTDOWN */
101 struct vmbus_icmsg_shutdown {
102 struct vmbus_icmsg_hdr ic_hdr;
105 uint32_t ic_haltflags;
106 uint8_t ic_msg[2048];
109 #define VMBUS_ICMSG_SHUTDOWN_SIZE_MIN \
110 __offsetof(struct vmbus_icmsg_shutdown, ic_msg[0])
112 /* VMBUS_ICMSG_TYPE_TIMESYNC */
113 struct vmbus_icmsg_timesync {
114 struct vmbus_icmsg_hdr ic_hdr;
118 uint8_t ic_tsflags; /* VMBUS_ICMSG_TS_FLAG_ */
121 /* VMBUS_ICMSG_TYPE_TIMESYNC, MSGVER4 */
122 struct vmbus_icmsg_timesync4 {
123 struct vmbus_icmsg_hdr ic_hdr;
126 uint8_t ic_tsflags; /* VMBUS_ICMSG_TS_FLAG_ */
130 #define VMBUS_ICMSG_TS_FLAG_SYNC 0x01
131 #define VMBUS_ICMSG_TS_FLAG_SAMPLE 0x02
133 #define VMBUS_ICMSG_TS_BASE 116444736000000000ULL
135 #endif /* !_VMBUS_ICREG_H_ */