1
/*********************************************************
2
* Copyright (C) 2007 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
*********************************************************/
20
* vmciHostKernelAPI.h --
22
* Kernel API exported from the VMCI host driver.
25
#ifndef __VMCI_HOSTKERNELAPI_H__
26
#define __VMCI_HOSTKERNELAPI_H__
28
#define INCLUDE_ALLOW_MODULE
29
#define INCLUDE_ALLOW_VMMON
30
#define INCLUDE_ALLOW_VMCORE
31
#define INCLUDE_ALLOW_VMK_MODULE
32
#define INCLUDE_ALLOW_VMKERNEL
33
#define INCLUDE_ALLOW_DISTRIBUTE
34
#include "includeCheck.h"
37
/* VMCI host kernel API version number. */
38
#define VMCI_HOST_KERNEL_API_VERSION 1
40
/* Macros to operate on the driver version number. */
41
#define VMCI_MAJOR_VERSION(v) (((v) >> 16) & 0xffff)
42
#define VMCI_MINOR_VERSION(v) ((v) & 0xffff)
44
#include "vmci_defs.h"
46
#include "vm_atomic.h"
47
#include "return_status.h"
48
#include "util_copy_dist.h"
50
#include "vmci_call_defs.h"
52
#if !defined(VMKERNEL)
53
#include "vmci_queue_pair.h"
57
/* VMCI Datagram API. */
59
int VMCIHost_DatagramCreateHnd(VMCIId resourceID, uint32 flags,
60
VMCIDatagramRecvCB recvCB, void *clientData,
61
VMCIHandle *outHandle);
62
int VMCIDatagram_CreateHnd(VMCIId resourceID, uint32 flags,
63
VMCIDatagramRecvCB recvCB, void *clientData,
64
VMCIHandle *outHandle);
65
int VMCIDatagram_CreateHndPriv(VMCIId resourceID, uint32 flags,
66
VMCIPrivilegeFlags privFlags,
67
VMCIDatagramRecvCB recvCB, void *clientData,
68
VMCIHandle *outHandle);
69
int VMCIDatagram_DestroyHnd(VMCIHandle handle);
70
int VMCIDatagram_Send(VMCIDatagram *msg);
72
/* VMCI Utility API. */
75
int VMCI_ContextID2HostVmID(VMCIId contextID, void *hostVmID,
81
typedef void (*VMCI_EventCB)(VMCIId subID, VMCI_EventData *ed,
84
int VMCIEvent_Subscribe(VMCI_Event event, VMCI_EventCB callback,
85
void *callbackData, VMCIId *subID);
86
int VMCIEvent_Unsubscribe(VMCIId subID);
88
/* VMCI Context API */
90
VMCIPrivilegeFlags VMCIContext_GetPrivFlags(VMCIId contextID);
93
* Queue pair operations for manipulating the content of a queue
94
* pair are defined in vmci_queue_pair.h for non-vmkernel hosts.
95
* Here we define the API for allocating and detaching from queue
96
* pairs for all hosts, and content manipulation functions for
100
#if defined(VMKERNEL)
103
* For guest kernels, the VMCIQueue is directly mapped onto the
104
* metadata page of the queue. In vmkernel, we use the VMCIQueue
105
* structure to store the information necessary to retrieve the MPNs
106
* of the queue. By redefining the structure, queue pair code using
107
* the API below will be portable between guests and host kernels.
110
typedef struct VMCIQueue {
111
uint32 offset; // Start page of queue in backing store
112
uint32 len; // Number of pages in the queue
113
struct QueuePairEntry *entry; // Endpoint state for the queue pair
116
/* VMCI Queuepair API */
117
void VMCIQueue_Init(const VMCIHandle handle, VMCIQueue *queue);
118
void VMCIQueue_GetPointers(const VMCIQueue *produceQ, const VMCIQueue *consumeQ,
119
uint64 *producerTail, uint64 *consumerHead);
120
int64 VMCIQueue_FreeSpace(const VMCIQueue *produceQueue,
121
const VMCIQueue *consumeQueue,
122
const uint64 produceQSize);
123
int64 VMCIQueue_BufReady(const VMCIQueue *consumeQueue,
124
const VMCIQueue *produceQueue,
125
const uint64 consumeQSize);
126
ssize_t VMCIQueue_Enqueue(VMCIQueue *produceQueue, const VMCIQueue *consumeQueue,
127
const uint64 produceQSize, const void *buf,
128
size_t bufSize, Util_BufferType bufType);
129
ssize_t VMCIQueue_Peek(VMCIQueue *produceQueue, const VMCIQueue *consumeQueue,
130
const uint64 consumeQSize, void *buf,
131
size_t bufSize, Util_BufferType bufType);
132
ssize_t VMCIQueue_PeekV(VMCIQueue *produceQueue, const VMCIQueue *consumeQueue,
133
const uint64 consumeQSize, void *buf,
134
size_t bufSize, Util_BufferType bufType);
135
ssize_t VMCIQueue_Discard(VMCIQueue *produceQueue, const VMCIQueue *consumeQueue,
136
const uint64 consumeQSize, size_t bufSize);
137
ssize_t VMCIQueue_Dequeue(VMCIQueue *produceQueue, const VMCIQueue *consumeQueue,
138
const uint64 consumeQSize, void *buf,
139
size_t bufSize, Util_BufferType bufType);
140
ssize_t VMCIQueue_EnqueueV(VMCIQueue *produceQueue, const VMCIQueue *consumeQueue,
141
const uint64 produceQSize, const void *buf,
142
size_t bufSize, Util_BufferType bufType);
143
ssize_t VMCIQueue_DequeueV(VMCIQueue *produceQueue, const VMCIQueue *consumeQueue,
144
const uint64 consumeQSize, void *buf,
145
size_t bufSize, Util_BufferType bufType);
146
#endif /* VMKERNEL */
148
int VMCIQueuePair_Alloc(VMCIHandle *handle, VMCIQueue **produceQ,
149
uint64 produceSize, VMCIQueue **consumeQ,
150
uint64 consumeSize, VMCIId peer, uint32 flags);
151
int VMCIQueuePair_AllocPriv(VMCIHandle *handle, VMCIQueue **produceQ,
152
uint64 produceSize, VMCIQueue **consumeQ,
153
uint64 consumeSize, VMCIId peer, uint32 flags,
154
VMCIPrivilegeFlags privFlags);
155
int VMCIQueuePair_Detach(VMCIHandle handle);
157
#endif /* !__VMCI_HOSTKERNELAPI_H__ */