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

« back to all changes in this revision

Viewing changes to modules/linux/shared/vmci_kernel_if.h

  • Committer: Package Import Robot
  • Author(s): Nate Muench
  • Date: 2012-01-23 16:09:45 UTC
  • mfrom: (1.4.6) (2.4.26 sid)
  • Revision ID: package-import@ubuntu.com-20120123160945-b6s0r1vkcovucpf3
Tags: 2011.12.20-562307-0ubuntu1
* Merge latest upstream git tag. Fixes building on Precise
  (LP: #898289, LP: #905612)

* Items merged from Debian unstable:
  - debian/control:
    + open-vm-tools recommends open-vm-dkms. (LP: #598933)
    + open-vm-tools now suggests open-vm-toolbox. (LP: #604998)
  (From 2011.08.21-471295-1 release)
  - Updating maintainer and uploaders fields.
  - Removing vcs fields.
  - Removing references to Daniel's old email address.
  - Updating years in copyright file.
  - Updating to standards version 3.9.2.
  - Updating to debhelper version 8.
  - Switching to source format 3.0 (quilt).
  - Removing manual chrpath setting.
  - Removing exclusion from plugins from debhelper shlibs.
  - Rediffing kvers.patch.
  (From 2011.09.23-491607-1 release)
  - Marking binary architecture-dependend packages as linux and kfreebsd
  only.
  - Removing liburiparser-dev from build-depends as upstream dropped
  unity support.
  - Building with libproc-dev on amd64 again.
  - Dropping disabling of dnet support.
  (From 2011.09.23-491607-2 release)
  - Adding doxygen to build-depends for api documentation.
  - Adding libcunit1-dev to build-depends for test suites.
  - Minimizing rules file.
  - Adding open-vm-tools-dev package, containing only the api
    documentation for now.
  (From 2011.09.23-491607-3 release)
  - Sorting overrides in rules alphabetically.
  - Compacting copyright file.
  - Adding udev rule to set timeout for vmware scsi devices
  (From 2011.12.20-562307-1 release)
  - Adding patch to correct typo in upstreams dkms configuration

* Remaining Changes:
  - Remove Stable part of version numbering.
  - debian folder:
    + Re-added open-vm-dkms.postinst & open-vm-dkms.prerm.
      * Allows dkms modules to compile upon installation.
  - debian/control:
    + Re-add open-vm-source and make into a transitional package
      for open-vm-toolbox.
    + Return dependancies that were moved to open-vm-tools back to
      open-vm-toolbox.
  - debian/rules and debian/open-vm-toolbox.lintian-overrides:
    + Make vmware-user-suid-wrapper suid-root
  - debian/rules:
    + Added CFLAGS field with -Wno-deprecated-declarations
      * Will suppress issues with glib 2.31 or later.
    + Add line to copy vmware-xdg-detect-de into place.
    + Install vmware-user.desktop through toolbox package.
  - debian/open-vm-tools.init:
    + Re-add 'modprobe [-r] vmblock'.
    + Add 'modprobe [-r] vmxnet'.
      * Incase it's not loaded during boot.
    + Remove and re-add pcnet32 module
      * Will be done before (remove) and after (readd) vmxnet module
        is added.
      * If vmxnet doesn't exist (aka modules fail to build), pcnet32 can be
        still used for network connectivity.
      * Workaround until a better fix can be done.
  - Re-add gnome-session to debian/local/xautostart.conf
  - Manpages removed (from debian/manpages):
    + vmmemctl.9
    + vmxnet3.9
    + Remove references to manpages that have been removed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*********************************************************
2
 
 * Copyright (C) 2006 VMware, Inc. All rights reserved.
 
2
 * Copyright (C) 2006-2011 VMware, Inc. All rights reserved.
3
3
 *
4
4
 * This program is free software; you can redistribute it and/or modify it
5
5
 * under the terms of the GNU General Public License as published by the
57
57
#  include "splock.h"
58
58
#  include "semaphore_ext.h"
59
59
#  include "vmkapi.h"
 
60
#  include "world_dist.h"
60
61
#endif
61
62
 
62
63
#ifdef SOLARIS
102
103
  typedef Semaphore VMCIMutex;
103
104
  typedef World_ID VMCIHostVmID;
104
105
  typedef uint32 VMCIHostUser;
 
106
  typedef PPN *VMCIQPGuestMem;
105
107
#elif defined(linux)
106
108
  typedef spinlock_t VMCILock;
107
109
  typedef unsigned long VMCILockFlags;
109
111
  typedef struct semaphore VMCIMutex;
110
112
  typedef PPN *VMCIPpnList; /* List of PPNs in produce/consume queue. */
111
113
  typedef uid_t VMCIHostUser;
 
114
  typedef VA64 VMCIQPGuestMem;
112
115
#elif defined(__APPLE__)
113
116
  typedef IOLock *VMCILock;
114
117
  typedef unsigned long VMCILockFlags;
120
123
  typedef IOLock *VMCIMutex;
121
124
  typedef void *VMCIPpnList; /* Actually a pointer to the C++ Object IOMemoryDescriptor */
122
125
  typedef uid_t VMCIHostUser;
 
126
  typedef VA64 *VMCIQPGuestMem;
123
127
#elif defined(_WIN32)
124
128
  typedef KSPIN_LOCK VMCILock;
125
129
  typedef KIRQL VMCILockFlags;
127
131
  typedef FAST_MUTEX VMCIMutex;
128
132
  typedef PMDL VMCIPpnList; /* MDL to map the produce/consume queue. */
129
133
  typedef PSID VMCIHostUser;
 
134
  typedef VA64 *VMCIQPGuestMem;
130
135
#elif defined(SOLARIS)
131
136
  typedef kmutex_t VMCILock;
132
137
  typedef unsigned long VMCILockFlags;
134
139
  typedef kmutex_t VMCIMutex;
135
140
  typedef PPN *VMCIPpnList; /* List of PPNs in produce/consume queue. */
136
141
  typedef uid_t VMCIHostUser;
 
142
  typedef VA64 VMCIQPGuestMem;
137
143
#endif // VMKERNEL
138
144
 
139
145
/* Callback needed for correctly waiting on events. */
140
146
typedef int (*VMCIEventReleaseCB)(void *clientData);
141
147
 
142
148
/*
143
 
 * The VMCI locks use a ranking scheme similar to the one used by
144
 
 * vmkernel. While holding a lock L1 with rank R1, only locks with
145
 
 * rank higher than R1 may be grabbed. The available ranks for VMCI
146
 
 * locks are (in descending order):
147
 
 * - VMCI_LOCK_RANK_HIGH_BH : to be used for locks grabbed while executing
148
 
 *   in a bottom half and not held while grabbing other locks.
149
 
 * - VMCI_LOCK_RANK_MIDDLE_BH : to be for locks grabbed while executing in a
150
 
 *   bottom half and held while grabbing locks of rank VMCI_LOCK_RANK_HIGH_BH.
151
 
 * - VMCI_LOCK_RANK_LOW_BH : to be for locks grabbed while executing in a
152
 
 *   bottom half and held while grabbing locks of rank
153
 
 *   VMCI_LOCK_RANK_MIDDLE_BH.
154
 
 * - VMCI_LOCK_RANK_HIGHEST : to be used for locks that are not held while
155
 
 *   grabbing other locks except system locks with higher ranks and bottom
156
 
 *   half locks.
157
 
 * - VMCI_LOCK_RANK_HIGHER : to be used for locks that are held while
158
 
 *   grabbing locks of rank VMCI_LOCK_RANK_HIGHEST or higher.
159
 
 * - VMCI_LOCK_RANK_HIGH : to be used for locks that are held while
160
 
 *   grabbing locks of rank VMCI_LOCK_RANK_HIGHER or higher. This is
161
 
 *   the highest lock rank used by core VMCI services
162
 
 * - VMCI_LOCK_RANK_MIDDLE : to be used for locks that are held while
163
 
 *   grabbing locks of rank VMCI_LOCK_RANK_HIGH or higher.
164
 
 * - VMCI_LOCK_RANK_LOW : to be used for locks that are held while
165
 
 *   grabbing locks of rank VMCI_LOCK_RANK_MIDDLE or higher.
166
 
 * - VMCI_LOCK_RANK_LOWEST : to be used for locks that are held while
167
 
 *   grabbing locks of rank VMCI_LOCK_RANK_LOW or higher.
 
149
 * Internal locking dependencies within VMCI:
 
150
 * * CONTEXTFIRE < CONTEXT, CONTEXTLIST, EVENT, HASHTABLE
 
151
 * * DOORBELL < HASHTABLE
 
152
 * * QPHIBERNATE < EVENT
168
153
 */
 
154
 
169
155
#ifdef VMKERNEL
170
 
  typedef SP_Rank VMCILockRank;
171
 
 
172
 
  #define VMCI_LOCK_RANK_HIGH_BH        SP_RANK_IRQ_LEAF
173
 
  #define VMCI_LOCK_RANK_MIDDLE_BH      (SP_RANK_IRQ_LEAF-1)
174
 
  #define VMCI_LOCK_RANK_LOW_BH         SP_RANK_IRQ_LOWEST
175
 
  #define VMCI_LOCK_RANK_HIGHEST        SP_RANK_SHM_MGR-1
 
156
  typedef Lock_Rank VMCILockRank;
 
157
  typedef SemaRank VMCISemaRank;
 
158
 
 
159
  #define VMCI_SEMA_RANK_QPHEADER       (SEMA_RANK_FS - 1)
 
160
 
 
161
  #define VMCI_LOCK_RANK_MAX            (MIN(SP_RANK_WAIT, \
 
162
                                             SP_RANK_HEAPLOCK_DYNAMIC) - 1)
176
163
#else
177
164
  typedef unsigned long VMCILockRank;
178
 
 
179
 
  #define VMCI_LOCK_RANK_HIGHER_BH      0x8000
180
 
  #define VMCI_LOCK_RANK_HIGH_BH        0x4000
181
 
  #define VMCI_LOCK_RANK_MIDDLE_BH      0x2000
182
 
  #define VMCI_LOCK_RANK_LOW_BH         0x1000
183
 
  #define VMCI_LOCK_RANK_HIGHEST        0x0fff
 
165
  typedef unsigned long VMCISemaRank;
 
166
 
 
167
  #define VMCI_LOCK_RANK_MAX            0x0fff
 
168
 
 
169
  #define VMCI_SEMA_RANK_QPHEADER       0x0fff
184
170
#endif // VMKERNEL
185
 
#define VMCI_LOCK_RANK_HIGHER      (VMCI_LOCK_RANK_HIGHEST-1)
186
 
#define VMCI_LOCK_RANK_HIGH        (VMCI_LOCK_RANK_HIGHER-1)
187
 
#define VMCI_LOCK_RANK_MIDDLE_HIGH (VMCI_LOCK_RANK_HIGH-1)
188
 
#define VMCI_LOCK_RANK_MIDDLE      (VMCI_LOCK_RANK_MIDDLE_HIGH-1)
189
 
#define VMCI_LOCK_RANK_MIDDLE_LOW  (VMCI_LOCK_RANK_MIDDLE-1)
190
 
#define VMCI_LOCK_RANK_LOW         (VMCI_LOCK_RANK_MIDDLE_LOW-1)
191
 
#define VMCI_LOCK_RANK_LOWEST      (VMCI_LOCK_RANK_LOW-1)
 
171
#define VMCI_LOCK_RANK_CONTEXT          VMCI_LOCK_RANK_MAX
 
172
#define VMCI_LOCK_RANK_CONTEXTLIST      VMCI_LOCK_RANK_MAX
 
173
#define VMCI_LOCK_RANK_DATAGRAMVMK      VMCI_LOCK_RANK_MAX
 
174
#define VMCI_LOCK_RANK_EVENT            VMCI_LOCK_RANK_MAX
 
175
#define VMCI_LOCK_RANK_HASHTABLE        VMCI_LOCK_RANK_MAX
 
176
#define VMCI_LOCK_RANK_RESOURCE         VMCI_LOCK_RANK_MAX
 
177
#define VMCI_LOCK_RANK_QPHEADER         VMCI_LOCK_RANK_MAX
 
178
#define VMCI_LOCK_RANK_DOORBELL         (VMCI_LOCK_RANK_HASHTABLE - 1)
 
179
#define VMCI_LOCK_RANK_CONTEXTFIRE      (MIN(VMCI_LOCK_RANK_CONTEXT, \
 
180
                                         MIN(VMCI_LOCK_RANK_CONTEXTLIST, \
 
181
                                         MIN(VMCI_LOCK_RANK_EVENT, \
 
182
                                             VMCI_LOCK_RANK_HASHTABLE))) - 1)
 
183
#define VMCI_LOCK_RANK_QPHIBERNATE      (VMCI_LOCK_RANK_EVENT - 1)
 
184
#define VMCI_LOCK_RANK_PACKET_QP        (VMCI_LOCK_RANK_QPHEADER - 1)
 
185
//#define VMCI_LOCK_RANK_PACKET_QP        0xffd /* For vVol */
 
186
 
 
187
#define VMCI_SEMA_RANK_QUEUEPAIRLIST    (VMCI_SEMA_RANK_QPHEADER - 1)
 
188
#define VMCI_SEMA_RANK_GUESTMEM         (VMCI_SEMA_RANK_QUEUEPAIRLIST - 1)
 
189
#define VMCI_SEMA_RANK_PACKET_QP        (VMCI_SEMA_RANK_QPHEADER - 1)
 
190
//#define VMCI_SEMA_RANK_PACKET_QP        0xffd /* For vVol */
192
191
 
193
192
/*
194
193
 * Host specific struct used for signalling.
306
305
Bool VMCI_CanScheduleDelayedWork(void);
307
306
int VMCI_ScheduleDelayedWork(VMCIWorkFn *workFn, void *data);
308
307
 
309
 
int VMCIMutex_Init(VMCIMutex *mutex);
 
308
int VMCIMutex_Init(VMCIMutex *mutex, char *name, VMCILockRank rank);
310
309
void VMCIMutex_Destroy(VMCIMutex *mutex);
311
310
void VMCIMutex_Acquire(VMCIMutex *mutex);
312
311
void VMCIMutex_Release(VMCIMutex *mutex);
321
320
 
322
321
#if !defined(VMKERNEL) && (defined(__linux__) || defined(_WIN32) || \
323
322
                           defined(SOLARIS) || defined(__APPLE__))
324
 
void *VMCI_AllocQueue(uint64 size);
 
323
void *VMCI_AllocQueue(uint64 size, uint32 flags);
325
324
void VMCI_FreeQueue(void *q, uint64 size);
326
325
typedef struct PPNSet {
327
326
  uint64      numProducePages;
338
337
 
339
338
struct VMCIQueue;
340
339
 
341
 
#if !defined(VMKERNEL)
342
340
struct PageStoreAttachInfo;
343
341
struct VMCIQueue *VMCIHost_AllocQueue(uint64 queueSize);
344
342
void VMCIHost_FreeQueue(struct VMCIQueue *queue, uint64 queueSize);
345
343
 
346
 
int VMCIHost_GetUserMemory(struct PageStoreAttachInfo *attach,
347
 
                           struct VMCIQueue *produceQ,
348
 
                           struct VMCIQueue *detachQ);
349
 
void VMCIHost_ReleaseUserMemory(struct PageStoreAttachInfo *attach,
350
 
                                struct VMCIQueue *produceQ,
351
 
                                struct VMCIQueue *detachQ);
352
 
#endif // VMKERNEL
353
 
 
354
 
#ifdef _WIN32
355
 
/*
356
 
 * Special routine used on the Windows platform to save a queue when
357
 
 * its backing memory goes away.
358
 
 */
359
 
 
360
 
void VMCIHost_SaveProduceQ(struct PageStoreAttachInfo *attach,
361
 
                           struct VMCIQueue *produceQ,
362
 
                           struct VMCIQueue *detachQ,
363
 
                           const uint64 produceQSize);
364
 
#endif // _WIN32
365
 
 
366
 
#ifdef _WIN32
367
 
void VMCI_InitQueueMutex(struct VMCIQueue *produceQ,
368
 
                             struct VMCIQueue *consumeQ);
369
 
void VMCI_AcquireQueueMutex(struct VMCIQueue *queue);
370
 
void VMCI_ReleaseQueueMutex(struct VMCIQueue *queue);
371
 
Bool VMCI_EnqueueToDevNull(struct VMCIQueue *queue);
372
 
int VMCI_ConvertToLocalQueue(struct VMCIQueue *queueInfo,
373
 
                             struct VMCIQueue *otherQueueInfo,
374
 
                             uint64 size, Bool keepContent,
375
 
                             void **oldQueue);
376
 
void VMCI_RevertToNonLocalQueue(struct VMCIQueue *queueInfo,
377
 
                                void *nonLocalQueue, uint64 size);
378
 
void VMCI_FreeQueueBuffer(void *queue, uint64 size);
379
 
Bool VMCI_CanCreate(void);
380
 
#else // _WIN32
 
344
#if defined(VMKERNEL)
 
345
typedef World_Handle *VMCIGuestMemID;
 
346
#define INVALID_VMCI_GUEST_MEM_ID  NULL
 
347
#else
 
348
typedef uint32 VMCIGuestMemID;
 
349
#define INVALID_VMCI_GUEST_MEM_ID  0
 
350
#endif
 
351
 
 
352
#if defined(VMKERNEL) || defined(__linux__)  || defined(_WIN32) || \
 
353
    defined(__APPLE__)
 
354
  struct QueuePairPageStore;
 
355
  int VMCIHost_RegisterUserMemory(struct QueuePairPageStore *pageStore,
 
356
                                  struct VMCIQueue *produceQ,
 
357
                                  struct VMCIQueue *consumeQ);
 
358
  void VMCIHost_UnregisterUserMemory(struct VMCIQueue *produceQ,
 
359
                                     struct VMCIQueue *consumeQ);
 
360
  int VMCIHost_MapQueues(struct VMCIQueue *produceQ,
 
361
                         struct VMCIQueue *consumeQ,
 
362
                         uint32 flags);
 
363
  int VMCIHost_UnmapQueues(VMCIGuestMemID gid,
 
364
                           struct VMCIQueue *produceQ,
 
365
                           struct VMCIQueue *consumeQ);
 
366
  void VMCI_InitQueueMutex(struct VMCIQueue *produceQ,
 
367
                           struct VMCIQueue *consumeQ);
 
368
  void VMCI_CleanupQueueMutex(struct VMCIQueue *produceQ,
 
369
                              struct VMCIQueue *consumeQ);
 
370
  int VMCI_AcquireQueueMutex(struct VMCIQueue *queue, Bool canBlock);
 
371
  void VMCI_ReleaseQueueMutex(struct VMCIQueue *queue);
 
372
#else // Below are the guest OS'es without host side support.
381
373
#  define VMCI_InitQueueMutex(_pq, _cq)
382
 
#  define VMCI_AcquireQueueMutex(_q)
 
374
#  define VMCI_CleanupQueueMutex(_pq, _cq)
 
375
#  define VMCI_AcquireQueueMutex(_q, _cb) VMCI_SUCCESS
383
376
#  define VMCI_ReleaseQueueMutex(_q)
 
377
#  define VMCIHost_RegisterUserMemory(_ps, _pq, _cq) VMCI_ERROR_UNAVAILABLE
 
378
#  define VMCIHost_UnregisterUserMemory(_pq, _cq)
 
379
#  define VMCIHost_MapQueues(_pq, _cq, _f) VMCI_SUCCESS
 
380
#  define VMCIHost_UnmapQueues(_gid, _pq, _cq) VMCI_SUCCESS
 
381
#endif
 
382
 
 
383
#if defined(VMKERNEL)
 
384
  void VMCIHost_MarkQueuesAvailable(struct VMCIQueue *produceQ,
 
385
                                    struct VMCIQueue *consumeQ);
 
386
  void VMCIHost_MarkQueuesUnavailable(struct VMCIQueue *produceQ,
 
387
                                      struct VMCIQueue *consumeQ);
 
388
#else
 
389
#  define VMCIHost_MarkQueuesAvailable(_q, _p) while(0) { }
 
390
#  define VMCIHost_MarkQueuesUnavailable(_q, _p) while(0) { }
 
391
#endif
 
392
 
 
393
#if defined(VMKERNEL) || defined(__linux__)
 
394
   void VMCI_LockQueueHeader(struct VMCIQueue *queue);
 
395
   void VMCI_UnlockQueueHeader(struct VMCIQueue *queue);
 
396
#else
 
397
#  define VMCI_LockQueueHeader(_q) ASSERT_NOT_IMPLEMENTED(FALSE)
 
398
#  define VMCI_UnlockQueueHeader(_q) ASSERT_NOT_IMPLEMENTED(FALSE)
 
399
#endif
 
400
 
 
401
#if (!defined(VMKERNEL) && defined(__linux__)) || defined(_WIN32) ||  \
 
402
   defined(__APPLE__) || defined(SOLARIS)
 
403
  int VMCIHost_GetUserMemory(VA64 produceUVA, VA64 consumeUVA,
 
404
                             struct VMCIQueue *produceQ,
 
405
                             struct VMCIQueue *consumeQ);
 
406
  void VMCIHost_ReleaseUserMemory(struct VMCIQueue *produceQ,
 
407
                                  struct VMCIQueue *consumeQ);
 
408
#else
 
409
#  define VMCIHost_GetUserMemory(_puva, _cuva, _pq, _cq) VMCI_ERROR_UNAVAILABLE
 
410
#  define VMCIHost_ReleaseUserMemory(_pq, _cq) ASSERT_NOT_IMPLEMENTED(FALSE)
 
411
#endif
 
412
 
 
413
#if defined(_WIN32)
 
414
    Bool VMCI_EnqueueToDevNull(struct VMCIQueue *queue);
 
415
    int VMCI_ConvertToLocalQueue(struct VMCIQueue *queueInfo,
 
416
                                 struct VMCIQueue *otherQueueInfo,
 
417
                                 uint64 size, Bool keepContent,
 
418
                                 void **oldQueue);
 
419
    void VMCI_RevertToNonLocalQueue(struct VMCIQueue *queueInfo,
 
420
                                    void *nonLocalQueue, uint64 size);
 
421
    void VMCI_FreeQueueBuffer(void *queue, uint64 size);
 
422
    Bool VMCI_CanCreate(void);
 
423
#else // _WIN32
384
424
#  define VMCI_EnqueueToDevNull(_q) FALSE
385
425
#  define VMCI_ConvertToLocalQueue(_pq, _cq, _s, _oq, _kc) VMCI_ERROR_UNAVAILABLE
386
426
#  define VMCI_RevertToNonLocalQueue(_q, _nlq, _s)