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
*********************************************************/
22
* VMCI QueuePair API implementation in the host driver.
25
#ifndef _VMCI_QUEUE_PAIR_H_
26
#define _VMCI_QUEUE_PAIR_H_
28
#define INCLUDE_ALLOW_MODULE
29
#define INCLUDE_ALLOW_VMMON
30
#define INCLUDE_ALLOW_VMCORE
31
#define INCLUDE_ALLOW_VMKERNEL
32
#include "includeCheck.h"
34
#include "vmci_defs.h"
35
#include "vmciContext.h"
36
#include "vmci_iocontrols.h"
37
#include "vmciQueue.h"
39
#include "vm_atomic.h"
40
#include "util_copy_dist.h"
44
* On vmkernel, the queue pairs are either backed by shared memory or
45
* kernel memory allocated on the VMCI heap. Shared memory is used for
46
* guest to guest and guest to host queue pairs, whereas the heap
47
* allocated queue pairs are used for host local queue pairs.
50
typedef struct QueuePairPageStore {
51
Bool shared; // Indicates whether the pages are stored in shared memory
60
typedef struct QueuePairPageStore {
61
Bool user; // Whether the page file strings are userspace pointers
62
VA64 producePageFile; // Name of the file
63
VA64 consumePageFile; // Name of the file
64
uint64 producePageFileSize; // Size of the string
65
uint64 consumePageFileSize; // Size of the string
66
VA64 producePageUVA; // User space VA of the mapped file in VMX
67
VA64 consumePageUVA; // User space VA of the mapped file in VMX
72
#if (defined(__linux__) || defined(_WIN32) || defined(__APPLE__) || \
73
defined(SOLARIS)) && !defined(VMKERNEL)
76
typedef struct PageStoreAttachInfo {
77
char producePageFile[VMCI_PATH_MAX];
78
char consumePageFile[VMCI_PATH_MAX];
79
uint64 numProducePages;
80
uint64 numConsumePages;
82
/* User VAs in the VMX task */
87
* Platform-specific references to the physical pages backing the
88
* queue. These include a page for the header.
90
* PR361589 tracks this, too.
93
#if defined(__linux__)
94
struct page **producePages;
95
struct page **consumePages;
101
#elif defined(__APPLE__)
103
* All the Mac OS X fields are members of the VMCIQueue
106
} PageStoreAttachInfo;
108
#endif // (__linux__ || _WIN32 || __APPLE__) && !VMKERNEL
112
*------------------------------------------------------------------------------
114
* VMCI_QP_PAGESTORE_IS_WELLFORMED --
116
* Utility function that checks whether the fields of the page
117
* store contain valid values.
120
* TRUE if the page store is wellformed. FALSE otherwise.
125
*------------------------------------------------------------------------------
129
VMCI_QP_PAGESTORE_IS_WELLFORMED(QueuePairPageStore *pageStore) // IN
132
return (pageStore->shared && pageStore->store.shmID != SHM_INVALID_ID) ||
133
(!pageStore->shared && pageStore->store.ptr != NULL);
135
return pageStore->producePageFile && pageStore->consumePageFile &&
136
pageStore->producePageFileSize && pageStore->consumePageFileSize;
140
int VMCIQPBroker_Init(void);
141
void VMCIQPBroker_Exit(void);
142
void VMCIQPBroker_Lock(void);
143
void VMCIQPBroker_Unlock(void);
144
int VMCIQPBroker_Alloc(VMCIHandle handle, VMCIId peer, uint32 flags,
145
VMCIPrivilegeFlags privFlags,
146
uint64 produceSize, uint64 consumeSize,
147
QueuePairPageStore *pageStore,
148
VMCIContext *context);
149
int VMCIQPBroker_SetPageStore(VMCIHandle handle,
150
QueuePairPageStore *pageStore,
151
VMCIContext *context);
152
int VMCIQPBroker_Detach(VMCIHandle handle, VMCIContext *context, Bool detach);
154
void VMCIQPGuestEndpoints_Init(void);
155
void VMCIQPGuestEndpoints_Exit(void);
156
void VMCIQPGuestEndpoints_Sync(void);
157
void VMCIQPGuestEndpoints_Convert(Bool toLocal, Bool deviceReset);
159
int VMCIQueuePair_Alloc(VMCIHandle *handle, VMCIQueue **produceQ,
160
uint64 produceSize, VMCIQueue **consumeQ,
161
uint64 consumeSize, VMCIId peer, uint32 flags,
162
VMCIPrivilegeFlags privFlags, Bool guestEndpoint);
163
int VMCIQueuePair_Detach(VMCIHandle handle, Bool guestEndpoint);
166
#endif /* !_VMCI_QUEUE_PAIR_H_ */