~ubuntu-branches/ubuntu/quantal/open-vm-tools/quantal-201210021442

« back to all changes in this revision

Viewing changes to modules/linux/vmci/shared/vmciQueue.h

  • Committer: Bazaar Package Importer
  • Author(s): Serge Hallyn
  • Date: 2011-03-31 14:20:05 UTC
  • mfrom: (1.4.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20110331142005-3n9red91p7ogkweo
Tags: 2011.03.28-387002-0ubuntu1
* Merge latest upstream git tag.  This has the unlocked_ioctl change
  needed to fix dkms build failures (LP: #727342)
* Changes in debian/rules:
  - work around a bug in toolbox/Makefile, where install-exec-hook is
    not happening.  This needs to get fixed the right way.
  - don't install 'vmware-user' which seems to no longer exist
  - move /etc/xdg into open-vm-toolbox (which should be done using .install)
* debian/open-vm-tools.init: add 'modprobe [-r] vmblock'. (LP: #332323)
* debian/rules and debian/open-vm-toolbox.lintian-overrides:
  - Make vmware-user-suid-wrapper suid-root (LP: #332323)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*********************************************************
 
2
 * Copyright (C) 2010 VMware, Inc. All rights reserved.
 
3
 *
 
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.
 
7
 *
 
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
 
11
 * for more details.
 
12
 *
 
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
 
16
 *
 
17
 *********************************************************/
 
18
 
 
19
#ifndef _VMCI_QUEUE_H_
 
20
#define _VMCI_QUEUE_H_
 
21
 
 
22
/*
 
23
 *
 
24
 * vmciQueue.h --
 
25
 *
 
26
 *    Defines the queue structure, and helper functions to enqueue and dequeue
 
27
 *    items.  XXX needs checksumming?
 
28
 */
 
29
 
 
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"
 
35
 
 
36
#if defined(SOLARIS) || defined(__APPLE__)
 
37
#  include <sys/uio.h>
 
38
#endif
 
39
 
 
40
#if defined VMKERNEL
 
41
#  include "vm_atomic.h"
 
42
#  include "return_status.h"
 
43
#  include "util_copy_dist.h"
 
44
#endif
 
45
 
 
46
 
 
47
/*
 
48
 * VMCIQueue
 
49
 *
 
50
 * This data type contains the information about a queue.
 
51
 *
 
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.
 
56
 *
 
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.
 
61
 */
 
62
 
 
63
typedef struct VMCIQueueKernelIf VMCIQueueKernelIf;
 
64
 
 
65
typedef struct VMCIQueue {
 
66
   VMCIQueueHeader *qHeader;
 
67
   VMCIQueueKernelIf *kernelIf;
 
68
} VMCIQueue;
 
69
 
 
70
 
 
71
/*
 
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.
 
75
 */
 
76
 
 
77
#ifdef VMKERNEL
 
78
#define BUF_TYPE        Util_BufferType
 
79
#else
 
80
#define BUF_TYPE        int
 
81
#endif
 
82
 
 
83
/*
 
84
 *-----------------------------------------------------------------------------
 
85
 *
 
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
 
89
 * itself.
 
90
 *
 
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.
 
94
 *
 
95
 *-----------------------------------------------------------------------------
 
96
 */
 
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);
 
103
 
 
104
 
 
105
#if defined(_WIN32) && defined(WINNT_DDK)
 
106
/*
 
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.
 
109
 */
 
110
typedef struct iovec {
 
111
   PMDL mdl;     // List of memory descriptors.
 
112
   ULONG offset; // Base offset.
 
113
};
 
114
#endif // _WIN32 && WINNT_DDK
 
115
 
 
116
 
 
117
/*
 
118
 *-----------------------------------------------------------------------------
 
119
 *
 
120
 * VMCIMemcpy{To,From}Queue[v]() prototypes
 
121
 *
 
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
 
131
 * had attached).
 
132
 *
 
133
 *-----------------------------------------------------------------------------
 
134
 */
 
135
 
 
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);
 
140
 
 
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? */
 
150
 
 
151
 
 
152
#endif /* !_VMCI_QUEUE_H_ */
 
153