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
*********************************************************/
22
* Kernel API (v1) exported from the VMCI host and guest drivers.
25
#ifndef __VMCI_KERNELAPI_1_H__
26
#define __VMCI_KERNELAPI_1_H__
28
#define INCLUDE_ALLOW_MODULE
29
#define INCLUDE_ALLOW_VMK_MODULE
30
#define INCLUDE_ALLOW_VMKERNEL
31
#include "includeCheck.h"
33
#include "vmci_defs.h"
34
#include "vmci_call_defs.h"
37
/* VMCI module namespace on vmkernel. */
39
#define MOD_VMCI_NAMESPACE "com.vmware.vmci"
41
/* Define version 1. */
43
#undef VMCI_KERNEL_API_VERSION
44
#define VMCI_KERNEL_API_VERSION_1 1
45
#define VMCI_KERNEL_API_VERSION VMCI_KERNEL_API_VERSION_1
47
/* Macros to operate on the driver version number. */
49
#define VMCI_MAJOR_VERSION(v) (((v) >> 16) & 0xffff)
50
#define VMCI_MINOR_VERSION(v) ((v) & 0xffff)
52
/* VMCI Device Usage API. */
54
Bool VMCI_DeviceGet(uint32 *apiVersion);
55
void VMCI_DeviceRelease(void);
57
/* VMCI Datagram API. */
59
int VMCIDatagram_CreateHnd(VMCIId resourceID, uint32 flags,
60
VMCIDatagramRecvCB recvCB, void *clientData,
61
VMCIHandle *outHandle);
62
int VMCIDatagram_CreateHndPriv(VMCIId resourceID, uint32 flags,
63
VMCIPrivilegeFlags privFlags,
64
VMCIDatagramRecvCB recvCB, void *clientData,
65
VMCIHandle *outHandle);
66
int VMCIDatagram_DestroyHnd(VMCIHandle handle);
67
int VMCIDatagram_Send(VMCIDatagram *msg);
69
/* VMCI Utility API. */
71
VMCIId VMCI_GetContextID(void);
72
uint32 VMCI_Version(void);
73
int VMCI_ContextID2HostVmID(VMCIId contextID, void *hostVmID,
75
int VMCI_IsContextOwner(VMCIId contextID, void *hostUser);
79
typedef void (*VMCI_EventCB)(VMCIId subID, VMCI_EventData *ed,
82
int VMCIEvent_Subscribe(VMCI_Event event, uint32 flags, VMCI_EventCB callback,
83
void *callbackData, VMCIId *subID);
84
int VMCIEvent_Unsubscribe(VMCIId subID);
86
/* VMCI Context API */
88
VMCIPrivilegeFlags VMCIContext_GetPrivFlags(VMCIId contextID);
90
/* VMCI Queue Pair API. */
92
typedef struct VMCIQPair VMCIQPair;
94
int VMCIQPair_Alloc(VMCIQPair **qpair,
100
VMCIPrivilegeFlags privFlags);
102
int VMCIQPair_Detach(VMCIQPair **qpair);
104
int VMCIQPair_GetProduceIndexes(const VMCIQPair *qpair,
105
uint64 *producerTail,
106
uint64 *consumerHead);
107
int VMCIQPair_GetConsumeIndexes(const VMCIQPair *qpair,
108
uint64 *consumerTail,
109
uint64 *producerHead);
110
int64 VMCIQPair_ProduceFreeSpace(const VMCIQPair *qpair);
111
int64 VMCIQPair_ProduceBufReady(const VMCIQPair *qpair);
112
int64 VMCIQPair_ConsumeFreeSpace(const VMCIQPair *qpair);
113
int64 VMCIQPair_ConsumeBufReady(const VMCIQPair *qpair);
114
ssize_t VMCIQPair_Enqueue(VMCIQPair *qpair,
118
ssize_t VMCIQPair_Dequeue(VMCIQPair *qpair,
122
ssize_t VMCIQPair_Peek(VMCIQPair *qpair,
127
#if defined (SOLARIS) || (defined(__APPLE__) && !defined (VMX86_TOOLS)) || \
128
(defined(__linux__) && defined(__KERNEL__)) || \
129
(defined(_WIN32) && defined(WINNT_DDK))
131
* Environments that support struct iovec
134
ssize_t VMCIQPair_EnqueueV(VMCIQPair *qpair,
138
ssize_t VMCIQPair_DequeueV(VMCIQPair *qpair,
142
ssize_t VMCIQPair_PeekV(VMCIQPair *qpair,
146
#endif /* Systems that support struct iovec */
149
/* Typedefs for all of the above, used by the IOCTLs and the kernel library. */
151
typedef void (VMCI_DeviceReleaseFct)(void);
152
typedef int (VMCIDatagram_CreateHndFct)(VMCIId, uint32, VMCIDatagramRecvCB,
153
void *, VMCIHandle *);
154
typedef int (VMCIDatagram_CreateHndPrivFct)(VMCIId, uint32, VMCIPrivilegeFlags,
155
VMCIDatagramRecvCB, void *,
157
typedef int (VMCIDatagram_DestroyHndFct)(VMCIHandle);
158
typedef int (VMCIDatagram_SendFct)(VMCIDatagram *);
159
typedef VMCIId (VMCI_GetContextIDFct)(void);
160
typedef uint32 (VMCI_VersionFct)(void);
161
typedef int (VMCIEvent_SubscribeFct)(VMCI_Event, uint32, VMCI_EventCB, void *,
163
typedef int (VMCIEvent_UnsubscribeFct)(VMCIId);
164
typedef int (VMCIQPair_AllocFct)(VMCIQPair **, VMCIHandle *, uint64, uint64,
165
VMCIId, uint32, VMCIPrivilegeFlags);
166
typedef int (VMCIQPair_DetachFct)(VMCIQPair **);
167
typedef int (VMCIQPair_GetProduceIndexesFct)(const VMCIQPair *, uint64 *,
169
typedef int (VMCIQPair_GetConsumeIndexesFct)(const VMCIQPair *, uint64 *,
171
typedef int64 (VMCIQPair_ProduceFreeSpaceFct)(const VMCIQPair *);
172
typedef int64 (VMCIQPair_ProduceBufReadyFct)(const VMCIQPair *);
173
typedef int64 (VMCIQPair_ConsumeFreeSpaceFct)(const VMCIQPair *);
174
typedef int64 (VMCIQPair_ConsumeBufReadyFct)(const VMCIQPair *);
175
typedef ssize_t (VMCIQPair_EnqueueFct)(VMCIQPair *, const void *, size_t, int);
176
typedef ssize_t (VMCIQPair_DequeueFct)(VMCIQPair *, void *, size_t, int);
177
typedef ssize_t (VMCIQPair_PeekFct)(VMCIQPair *, void *, size_t, int);
178
typedef ssize_t (VMCIQPair_EnqueueVFct)(VMCIQPair *qpair, void *, size_t, int);
179
typedef ssize_t (VMCIQPair_DequeueVFct)(VMCIQPair *qpair, void *, size_t, int);
180
typedef ssize_t (VMCIQPair_PeekVFct)(VMCIQPair *qpair, void *, size_t, int);
183
#endif /* !__VMCI_KERNELAPI_1_H__ */