xref: /freebsd/sys/dev/hyperv/utilities/vmbus_icreg.h (revision 02d99265593c8c13ae08eaa7a962531bcd9889a0)
18f555c7dSSepherosa Ziehau /*-
28f555c7dSSepherosa Ziehau  * Copyright (c) 2016 Microsoft Corp.
38f555c7dSSepherosa Ziehau  * All rights reserved.
48f555c7dSSepherosa Ziehau  *
58f555c7dSSepherosa Ziehau  * Redistribution and use in source and binary forms, with or without
68f555c7dSSepherosa Ziehau  * modification, are permitted provided that the following conditions
78f555c7dSSepherosa Ziehau  * are met:
88f555c7dSSepherosa Ziehau  * 1. Redistributions of source code must retain the above copyright
98f555c7dSSepherosa Ziehau  *    notice unmodified, this list of conditions, and the following
108f555c7dSSepherosa Ziehau  *    disclaimer.
118f555c7dSSepherosa Ziehau  * 2. Redistributions in binary form must reproduce the above copyright
128f555c7dSSepherosa Ziehau  *    notice, this list of conditions and the following disclaimer in the
138f555c7dSSepherosa Ziehau  *    documentation and/or other materials provided with the distribution.
148f555c7dSSepherosa Ziehau  *
158f555c7dSSepherosa Ziehau  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
168f555c7dSSepherosa Ziehau  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
178f555c7dSSepherosa Ziehau  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
188f555c7dSSepherosa Ziehau  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
198f555c7dSSepherosa Ziehau  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
208f555c7dSSepherosa Ziehau  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
218f555c7dSSepherosa Ziehau  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
228f555c7dSSepherosa Ziehau  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
238f555c7dSSepherosa Ziehau  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
248f555c7dSSepherosa Ziehau  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
258f555c7dSSepherosa Ziehau  *
268f555c7dSSepherosa Ziehau  * $FreeBSD$
278f555c7dSSepherosa Ziehau  */
288f555c7dSSepherosa Ziehau 
298f555c7dSSepherosa Ziehau #ifndef _VMBUS_ICREG_H_
308f555c7dSSepherosa Ziehau #define _VMBUS_ICREG_H_
318f555c7dSSepherosa Ziehau 
328f555c7dSSepherosa Ziehau #define VMBUS_ICMSG_TYPE_NEGOTIATE	0
338f555c7dSSepherosa Ziehau #define VMBUS_ICMSG_TYPE_HEARTBEAT	1
348f555c7dSSepherosa Ziehau #define VMBUS_ICMSG_TYPE_KVP		2
358f555c7dSSepherosa Ziehau #define VMBUS_ICMSG_TYPE_SHUTDOWN	3
368f555c7dSSepherosa Ziehau #define VMBUS_ICMSG_TYPE_TIMESYNC	4
378f555c7dSSepherosa Ziehau #define VMBUS_ICMSG_TYPE_VSS		5
388f555c7dSSepherosa Ziehau 
398f555c7dSSepherosa Ziehau #define VMBUS_ICMSG_STATUS_OK		0x00000000
408f555c7dSSepherosa Ziehau #define VMBUS_ICMSG_STATUS_FAIL		0x80004005
418f555c7dSSepherosa Ziehau 
428f555c7dSSepherosa Ziehau #define VMBUS_IC_VERSION(major, minor)	((major) | (((uint32_t)(minor)) << 16))
438f555c7dSSepherosa Ziehau #define VMBUS_ICVER_MAJOR(ver)		((ver) & 0xffff)
448f555c7dSSepherosa Ziehau #define VMBUS_ICVER_MINOR(ver)		(((ver) & 0xffff0000) >> 16)
458f555c7dSSepherosa Ziehau 
468f555c7dSSepherosa Ziehau struct vmbus_pipe_hdr {
478f555c7dSSepherosa Ziehau 	uint32_t		ph_flags;
488f555c7dSSepherosa Ziehau 	uint32_t		ph_msgsz;
498f555c7dSSepherosa Ziehau } __packed;
508f555c7dSSepherosa Ziehau 
518f555c7dSSepherosa Ziehau struct vmbus_icmsg_hdr {
528f555c7dSSepherosa Ziehau 	struct vmbus_pipe_hdr	ic_pipe;
538f555c7dSSepherosa Ziehau 	uint32_t		ic_fwver;	/* framework version */
548f555c7dSSepherosa Ziehau 	uint16_t		ic_type;
558f555c7dSSepherosa Ziehau 	uint32_t		ic_msgver;	/* message version */
568f555c7dSSepherosa Ziehau 	uint16_t		ic_dsize;	/* data size */
578f555c7dSSepherosa Ziehau 	uint32_t		ic_status;	/* VMBUS_ICMSG_STATUS_ */
588f555c7dSSepherosa Ziehau 	uint8_t			ic_xactid;
598f555c7dSSepherosa Ziehau 	uint8_t			ic_flags;	/* VMBUS_ICMSG_FLAG_ */
608f555c7dSSepherosa Ziehau 	uint8_t			ic_rsvd[2];
618f555c7dSSepherosa Ziehau } __packed;
628f555c7dSSepherosa Ziehau 
638f555c7dSSepherosa Ziehau #define VMBUS_ICMSG_FLAG_XACT		0x0001
648f555c7dSSepherosa Ziehau #define VMBUS_ICMSG_FLAG_REQ		0x0002
658f555c7dSSepherosa Ziehau #define VMBUS_ICMSG_FLAG_RESP		0x0004
668f555c7dSSepherosa Ziehau 
678f555c7dSSepherosa Ziehau /* VMBUS_ICMSG_TYPE_NEGOTIATE */
688f555c7dSSepherosa Ziehau struct vmbus_icmsg_negotiate {
698f555c7dSSepherosa Ziehau 	struct vmbus_icmsg_hdr	ic_hdr;
708f555c7dSSepherosa Ziehau 	uint16_t		ic_fwver_cnt;
718f555c7dSSepherosa Ziehau 	uint16_t		ic_msgver_cnt;
728f555c7dSSepherosa Ziehau 	uint32_t		ic_rsvd;
738f555c7dSSepherosa Ziehau 	/*
748f555c7dSSepherosa Ziehau 	 * This version array contains two set of supported
758f555c7dSSepherosa Ziehau 	 * versions:
768f555c7dSSepherosa Ziehau 	 * - The first set consists of #ic_fwver_cnt supported framework
778f555c7dSSepherosa Ziehau 	 *   versions.
788f555c7dSSepherosa Ziehau 	 * - The second set consists of #ic_msgver_cnt supported message
798f555c7dSSepherosa Ziehau 	 *   versions.
808f555c7dSSepherosa Ziehau 	 */
818f555c7dSSepherosa Ziehau 	uint32_t		ic_ver[];
828f555c7dSSepherosa Ziehau } __packed;
838f555c7dSSepherosa Ziehau 
84*02d99265SSepherosa Ziehau /* VMBUS_ICMSG_TYPE_HEARTBEAT */
85*02d99265SSepherosa Ziehau struct vmbus_icmsg_heartbeat {
86*02d99265SSepherosa Ziehau 	struct vmbus_icmsg_hdr	ic_hdr;
87*02d99265SSepherosa Ziehau 	uint64_t		ic_seq;
88*02d99265SSepherosa Ziehau 	uint32_t		ic_rsvd[8];
89*02d99265SSepherosa Ziehau } __packed;
90*02d99265SSepherosa Ziehau 
91*02d99265SSepherosa Ziehau #define VMBUS_ICMSG_HEARTBEAT_SIZE_MIN	\
92*02d99265SSepherosa Ziehau 	__offsetof(struct vmbus_icmsg_heartbeat, ic_rsvd[0])
93*02d99265SSepherosa Ziehau 
948f555c7dSSepherosa Ziehau #endif	/* !_VMBUS_ICREG_H_ */
95