11590Srgrimes/* SPDX-License-Identifier: GPL-2.0-only */
21590Srgrimes/*
31590Srgrimes * VMware VMCI Driver
41590Srgrimes *
51590Srgrimes * Copyright (C) 2012 VMware, Inc. All rights reserved.
61590Srgrimes */
71590Srgrimes
81590Srgrimes#ifndef _VMCI_DATAGRAM_H_
91590Srgrimes#define _VMCI_DATAGRAM_H_
101590Srgrimes
111590Srgrimes#include <linux/types.h>
121590Srgrimes#include <linux/list.h>
131590Srgrimes
141590Srgrimes#include "vmci_context.h"
151590Srgrimes
161590Srgrimes#define VMCI_MAX_DELAYED_DG_HOST_QUEUE_SIZE 256
171590Srgrimes
181590Srgrimes/*
191590Srgrimes * The struct vmci_datagram_queue_entry is a queue header for the in-kernel VMCI
201590Srgrimes * datagram queues. It is allocated in non-paged memory, as the
211590Srgrimes * content is accessed while holding a spinlock. The pending datagram
221590Srgrimes * itself may be allocated from paged memory. We shadow the size of
231590Srgrimes * the datagram in the non-paged queue entry as this size is used
241590Srgrimes * while holding the same spinlock as above.
251590Srgrimes */
261590Srgrimesstruct vmci_datagram_queue_entry {
271590Srgrimes	struct list_head list_item;	/* For queuing. */
281590Srgrimes	size_t dg_size;		/* Size of datagram. */
291590Srgrimes	struct vmci_datagram *dg;	/* Pending datagram. */
3087710Smarkm};
3187710Smarkm
3287710Smarkm/* VMCIDatagramSendRecvInfo */
3387710Smarkmstruct vmci_datagram_snd_rcv_info {
341590Srgrimes	u64 addr;
3587710Smarkm	u32 len;
3632503Scharnier	s32 result;
371590Srgrimes};
3832503Scharnier
3932503Scharnier/* Datagram API for non-public use. */
4014443Sjoergint vmci_datagram_dispatch(u32 context_id, struct vmci_datagram *dg,
41200418Sdelphij			   bool from_guest);
4287710Smarkmint vmci_datagram_invoke_guest_handler(struct vmci_datagram *dg);
4314443Sjoerg
441590Srgrimes#endif /* _VMCI_DATAGRAM_H_ */
451590Srgrimes