vmbus_reg.h revision 302170
11541Srgrimes/*-
21541Srgrimes * Copyright (c) 2016 Microsoft Corp.
31541Srgrimes * All rights reserved.
41541Srgrimes *
51541Srgrimes * Redistribution and use in source and binary forms, with or without
61541Srgrimes * modification, are permitted provided that the following conditions
71541Srgrimes * are met:
81541Srgrimes * 1. Redistributions of source code must retain the above copyright
91541Srgrimes *    notice unmodified, this list of conditions, and the following
101541Srgrimes *    disclaimer.
111541Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
121541Srgrimes *    notice, this list of conditions and the following disclaimer in the
131541Srgrimes *    documentation and/or other materials provided with the distribution.
141541Srgrimes *
151541Srgrimes * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
161541Srgrimes * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
171541Srgrimes * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
181541Srgrimes * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
191541Srgrimes * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
201541Srgrimes * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
211541Srgrimes * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
221541Srgrimes * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
231541Srgrimes * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
241541Srgrimes * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
251541Srgrimes *
261541Srgrimes * $FreeBSD: stable/10/sys/dev/hyperv/vmbus/vmbus_reg.h 302170 2016-06-24 02:30:14Z sephe $
271541Srgrimes */
281541Srgrimes
291541Srgrimes#ifndef _VMBUS_REG_H_
301541Srgrimes#define _VMBUS_REG_H_
311541Srgrimes
321541Srgrimes#include <sys/param.h>
331541Srgrimes
3450477Speter/*
351541Srgrimes * Hyper-V SynIC message format.
361541Srgrimes */
3713203Swollman
381541Srgrimes#define VMBUS_MSG_DSIZE_MAX		240
391541Srgrimes#define VMBUS_MSG_SIZE			256
402112Swollman
4176166Smarkmstruct vmbus_message {
4276166Smarkm	uint32_t	msg_type;	/* VMBUS_MSGTYPE_ */
4312221Sbde	uint8_t		msg_dsize;	/* data size */
4441059Speter	uint8_t		msg_flags;	/* VMBUS_MSGFLAG_ */
451541Srgrimes	uint16_t	msg_rsvd;
4624131Sbde	uint64_t	msg_id;
471541Srgrimes	uint8_t		msg_data[VMBUS_MSG_DSIZE_MAX];
481541Srgrimes} __packed;
491541SrgrimesCTASSERT(sizeof(struct vmbus_message) == VMBUS_MSG_SIZE);
501541Srgrimes
5174927Sjhb#define VMBUS_MSGTYPE_NONE		0
521541Srgrimes#define VMBUS_MSGTYPE_CHANNEL		1
5372786Srwatson#define VMBUS_MSGTYPE_TIMER_EXPIRED	0x80000010
541541Srgrimes
5530354Sphk#define VMBUS_MSGFLAG_PENDING		0x01
5630309Sphk
5713203Swollman/*
5812819Sphk * Hyper-V SynIC event flags
5962378Sgreen */
6012819Sphk
6112819Sphk#ifdef __LP64__
6212819Sphk#define VMBUS_EVTFLAGS_MAX	32
6312577Sbde#define VMBUS_EVTFLAG_SHIFT	6
6412819Sphk#else
6512819Sphk#define VMBUS_EVTFLAGS_MAX	64
661541Srgrimes#define VMBUS_EVTFLAG_SHIFT	5
671541Srgrimes#endif
681541Srgrimes#define VMBUS_EVTFLAG_LEN	(1 << VMBUS_EVTFLAG_SHIFT)
691541Srgrimes#define VMBUS_EVTFLAG_MASK	(VMBUS_EVTFLAG_LEN - 1)
701541Srgrimes#define VMBUS_EVTFLAGS_SIZE	256
711541Srgrimes
728876Srgrimesstruct vmbus_evtflags {
7317429Sphk	u_long		evt_flags[VMBUS_EVTFLAGS_MAX];
741541Srgrimes} __packed;
751541SrgrimesCTASSERT(sizeof(struct vmbus_evtflags) == VMBUS_EVTFLAGS_SIZE);
761541Srgrimes
7751484Smarcel/*
781541Srgrimes * Channel
791541Srgrimes */
801541Srgrimes
8182585Sdillon#define VMBUS_CHAN_MAX_COMPAT	256
8282585Sdillon#define VMBUS_CHAN_MAX		(VMBUS_EVTFLAG_LEN * VMBUS_EVTFLAGS_MAX)
8382585Sdillon
841549Srgrimes#endif	/* !_VMBUS_REG_H_ */
851541Srgrimes