1
/*********************************************************
2
* Copyright (C) 2010 VMware, Inc. All rights reserved.
4
* This program is free software; you can redistribute it and/or modify it
5
* under the terms of the GNU General Public License as published by the
6
* Free Software Foundation version 2 and no later version.
8
* This program is distributed in the hope that it will be useful, but
9
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13
* You should have received a copy of the GNU General Public License along
14
* with this program; if not, write to the Free Software Foundation, Inc.,
15
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17
*********************************************************/
19
#ifndef _VMCI_QUEUE_H_
20
#define _VMCI_QUEUE_H_
26
* Defines the queue structure, and helper functions to enqueue and dequeue
27
* items. XXX needs checksumming?
30
#define INCLUDE_ALLOW_MODULE
31
#define INCLUDE_ALLOW_VMX
32
#define INCLUDE_ALLOW_VMK_MODULE
33
#define INCLUDE_ALLOW_VMKERNEL
34
#include "includeCheck.h"
36
#if defined(SOLARIS) || defined(__APPLE__)
41
# include "vm_atomic.h"
42
# include "return_status.h"
43
# include "util_copy_dist.h"
50
* This data type contains the information about a queue.
52
* There are two queues (hence, queue pairs) per transaction model between a
53
* pair of end points, A & B. One queue is used by end point A to transmit
54
* commands and responses to B. The other queue is used by B to transmit
55
* commands and responses.
57
* VMCIQueueKernelIf is a per-OS defined Queue structure. It contains either a
58
* direct pointer to the linear address of the buffer contents or a pointer to
59
* structures which help the OS locate those data pages. See vmciKernelIf.c
60
* for each platform for its definition.
63
typedef struct VMCIQueueKernelIf VMCIQueueKernelIf;
65
typedef struct VMCIQueue {
66
VMCIQueueHeader *qHeader;
67
VMCIQueueKernelIf *kernelIf;
72
* ESX uses a buffer type for the memcpy functions. Currently, none
73
* of the hosted products use such a field. And, to keep the function
74
* definitions simple, we use a define to declare the type parameter.
78
#define BUF_TYPE Util_BufferType
84
*-----------------------------------------------------------------------------
86
* VMCIMemcpy{To,From}QueueFunc() prototypes. Functions of these
87
* types are passed around to enqueue and dequeue routines. Note that
88
* often the functions passed are simply wrappers around memcpy
91
* Note: In order for the memcpy typedefs to be compatible with the VMKernel,
92
* there's an unused last parameter for the hosted side. In
93
* ESX, that parameter holds a buffer type.
95
*-----------------------------------------------------------------------------
97
typedef int VMCIMemcpyToQueueFunc(VMCIQueue *queue, uint64 queueOffset,
98
const void *src, size_t srcOffset,
99
size_t size, BUF_TYPE bufType);
100
typedef int VMCIMemcpyFromQueueFunc(void *dest, size_t destOffset,
101
const VMCIQueue *queue, uint64 queueOffset,
102
size_t size, BUF_TYPE bufType);
105
#if defined(_WIN32) && defined(WINNT_DDK)
107
* Windows needs iovec for the V functions. We use an MDL for the actual
108
* buffers, but we also have an offset that comes from WSK_BUF.
110
typedef struct iovec {
111
PMDL mdl; // List of memory descriptors.
112
ULONG offset; // Base offset.
114
#endif // _WIN32 && WINNT_DDK
118
*-----------------------------------------------------------------------------
120
* VMCIMemcpy{To,From}Queue[v]() prototypes
122
* Note that these routines are NOT SAFE to call on a host end-point
123
* until the guest end of the queue pair has attached -AND-
124
* SetPageStore(). The VMX crosstalk device will issue the
125
* SetPageStore() on behalf of the guest when the guest creates a
126
* QueuePair or attaches to one created by the host. So, if the guest
127
* notifies the host that it's attached then the queue is safe to use.
128
* Also, if the host registers notification of the connection of the
129
* guest, then it will only receive that notification when the guest
130
* has issued the SetPageStore() call and not before (when the guest
133
*-----------------------------------------------------------------------------
136
int VMCIMemcpyToQueue(VMCIQueue *queue, uint64 queueOffset, const void *src,
137
size_t srcOffset, size_t size, BUF_TYPE bufType);
138
int VMCIMemcpyFromQueue(void *dest, size_t destOffset, const VMCIQueue *queue,
139
uint64 queueOffset, size_t size, BUF_TYPE bufType);
141
#if defined VMKERNEL || defined (SOLARIS) || \
142
(defined(__APPLE__) && !defined (VMX86_TOOLS)) || \
143
(defined(__linux__) && defined(__KERNEL__)) || \
144
(defined(_WIN32) && defined(WINNT_DDK))
145
int VMCIMemcpyToQueueV(VMCIQueue *queue, uint64 queueOffset, const void *src,
146
size_t srcOffset, size_t size, BUF_TYPE bufType);
147
int VMCIMemcpyFromQueueV(void *dest, size_t destOffset, const VMCIQueue *queue,
148
uint64 queueOffset, size_t size, BUF_TYPE bufType);
149
#endif /* Does the O/S support iovec? */
152
#endif /* !_VMCI_QUEUE_H_ */