# error "Platform not support by VMCI datagram API."
#endif // linux
+#define LGPFX "VMCIDatagram: "
+
#include "vmci_kernel_if.h"
#include "vm_basic_types.h"
#include "vm_assert.h"
wkMsg.wellKnownID = resourceID;
result = VMCI_SendDatagram((VMCIDatagram *)&wkMsg);
if (result < VMCI_SUCCESS) {
- VMCI_LOG(("Failed to reserve wellknown id %d, error %d.\n",
- resourceID, result));
+ VMCI_DEBUG_LOG(4, (LGPFX"Failed to reserve wellknown id %d, "
+ "error %d.\n", resourceID, result));
return result;
}
result = DatagramHashAddEntry(entry, contextID);
if (result != VMCI_SUCCESS) {
- VMCI_LOG(("Failed to add new entry, err 0x%x.\n", result));
+ VMCI_DEBUG_LOG(4, (LGPFX"Failed to add new entry, err 0x%x.\n", result));
VMCI_DestroyEvent(&entry->destroyEvent);
VMCI_FreeKernelMem(entry, sizeof *entry);
return result;
wkMsg.wellKnownID = entry->handle.resource;
result = VMCI_SendDatagram((VMCIDatagram *)&wkMsg);
if (result < VMCI_SUCCESS) {
- VMCI_LOG(("Failed to remove well-known mapping for resource %d.\n",
- entry->handle.resource));
+ VMCI_WARNING((LGPFX"Failed to remove well-known mapping for "
+ "resource %d.\n", entry->handle.resource));
}
}
VMCIId contextId;
if (msg == NULL) {
- VMCI_LOG(("Invalid datagram.\n"));
+ VMCI_DEBUG_LOG(4, (LGPFX"Invalid datagram.\n"));
return VMCI_ERROR_INVALID_ARGS;
}
if (VMCI_DG_SIZE(msg) > VMCI_MAX_DG_SIZE) {
- VMCI_LOG(("Payload size %"FMT64"u too big to send.\n", msg->payloadSize));
+ VMCI_DEBUG_LOG(4, (LGPFX"Payload size %"FMT64"u too big to send.\n",
+ msg->payloadSize));
return VMCI_ERROR_INVALID_ARGS;
}
/* Check srcHandle exists otherwise fail. */
entry = DatagramHashGetEntry(msg->src);
if (entry == NULL) {
- VMCI_LOG(("Couldn't find handle 0x%x:0x%x.\n",
- msg->src.context, msg->src.resource));
+ VMCI_DEBUG_LOG(4, (LGPFX"Couldn't find handle 0x%x:0x%x.\n",
+ msg->src.context, msg->src.resource));
return VMCI_ERROR_INVALID_ARGS;
}
entry = DatagramHashGetEntryAnyCid(msg->dst);
if (entry == NULL) {
- VMCI_LOG(("destination handle 0x%x:0x%x doesn't exist.\n",
- msg->dst.context, msg->dst.resource));
+ VMCI_DEBUG_LOG(4, (LGPFX"destination handle 0x%x:0x%x doesn't exist.\n",
+ msg->dst.context, msg->dst.resource));
return VMCI_ERROR_NO_HANDLE;
}
if (!entry->recvCB) {
- VMCI_LOG(("no handle callback for handle 0x%x:0x%x payload of "
- "size %"FMT64"d.\n",
- msg->dst.context, msg->dst.resource, msg->payloadSize));
+ VMCI_WARNING((LGPFX"no handle callback for handle 0x%x:0x%x payload of "
+ "size %"FMT64"d.\n", msg->dst.context, msg->dst.resource,
+ msg->payloadSize));
goto out;
}
dgm = VMCI_AllocKernelMem(dgmSize,
VMCI_MEMORY_NONPAGED | VMCI_MEMORY_ATOMIC);
if (!dgm) {
- VMCI_LOG(("VMCI: Failed to allocate datagram of size %d bytes.\n",
- (uint32)dgmSize));
+ VMCI_WARNING((LGPFX"Failed to allocate datagram of size %d bytes.\n",
+ (uint32)dgmSize));
return VMCI_ERROR_NO_MEM;
}
memcpy(dgm, msg, dgmSize);
VMCI_MEMORY_NONPAGED | VMCI_MEMORY_ATOMIC);
if (dqEntry == NULL) {
VMCI_FreeKernelMem(dgm, dgmSize);
- VMCI_LOG(("VMCI: Failed to allocate memory for process datagram.\n"));
+ VMCI_WARNING((LGPFX"Failed to allocate memory for process datagram.\n"));
return VMCI_ERROR_NO_MEM;
}
dqEntry->dg = dgm;
VMCI_ReleaseLock_BH(&dgmProc->datagramQueueLock, flags);
VMCI_FreeKernelMem(dgm, dgmSize);
VMCI_FreeKernelMem(dqEntry, sizeof *dqEntry);
- VMCI_LOG(("VMCI: Datagram process receive queue is full.\n"));
+ VMCI_LOG((LGPFX"Datagram process receive queue is full.\n"));
return VMCI_ERROR_NO_RESOURCES;
}
VMCI_ReleaseLock_BH(&dgmProc->datagramQueueLock, flags);
#endif
- DEBUG_ONLY(VMCI_LOG(("VMCI: Sent datagram with resource id %d and size %u.\n",
- msg->dst.resource, (uint32)dgmSize));)
+ VMCI_DEBUG_LOG(10, (LGPFX"Sent datagram with resource id %d and size %u.\n",
+ msg->dst.resource, (uint32)dgmSize));
/* dqEntry and dgm are freed when user reads call.. */
return VMCI_SUCCESS;
if (dgmProc->pendingDatagrams == 0) {
VMCIHost_ClearCall(&dgmProc->host);
VMCI_ReleaseLock_BH(&dgmProc->datagramQueueLock, flags);
- VMCI_LOG(("VMCI: No datagrams pending.\n"));
+ VMCI_DEBUG_LOG(4, (LGPFX"No datagrams pending.\n"));
return VMCI_ERROR_NO_MORE_DATAGRAMS;
}
#else
while (dgmProc->pendingDatagrams == 0) {
VMCIHost_ClearCall(&dgmProc->host);
- if (!VMCIHost_WaitForCallLocked(&dgmProc->host, &dgmProc->datagramQueueLock,
+ if (!VMCIHost_WaitForCallLocked(&dgmProc->host,
+ &dgmProc->datagramQueueLock,
&flags, TRUE)) {
VMCI_ReleaseLock_BH(&dgmProc->datagramQueueLock, flags);
- VMCI_LOG(("VMCI: Blocking read of datagram interrupted.\n"));
+ VMCI_DEBUG_LOG(4, (LGPFX"Blocking read of datagram interrupted.\n"));
return VMCI_ERROR_NO_MORE_DATAGRAMS;
}
}
/* Check the size of the userland buffer. */
if (maxSize < VMCI_DG_SIZE(dqEntry->dg)) {
VMCI_ReleaseLock_BH(&dgmProc->datagramQueueLock, flags);
- VMCI_LOG(("VMCI: Caller's buffer is too small.\n"));
+ VMCI_DEBUG_LOG(4, (LGPFX"Caller's buffer is too small.\n"));
return VMCI_ERROR_NO_MEM;
}
#endif
#include "circList.h" /* Must come after vmciVmkInt.h. */
-#define EVENT_MAGIC 0xEABE0000
+#define LGPFX "VMCIEvent: "
+#define EVENT_MAGIC 0xEABE0000
typedef struct VMCISubscription {
VMCIId id;
ASSERT(sub);
if (!VMCI_EVENT_VALID(event) || callback == NULL) {
- VMCILOG(("VMCIEvent: Failed to subscribe to event %d cb %p data %p.\n",
- event, callback, callbackData));
+ VMCI_DEBUG_LOG(4, (LGPFX"Failed to subscribe to event %d cb %p data %p.\n",
+ event, callback, callbackData));
return VMCI_ERROR_INVALID_ARGS;
}
VMCISubscription *s = NULL;
if (subscriptionID == NULL) {
- VMCILOG(("VMCIEvent: Invalid arguments.\n"));
+ VMCI_DEBUG_LOG(4, (LGPFX"Invalid arguments.\n"));
return VMCI_ERROR_INVALID_ARGS;
}
#include "vmci_call_defs.h"
#include "vmciProcess.h"
+#define DODEBUGLOG(...) printk(KERN_DEBUG __VA_ARGS__)
#define DOLOG(...) printk(KERN_INFO __VA_ARGS__)
+#define DOWARNING(...) printk(KERN_WARNING __VA_ARGS__)
+
+#ifdef VMCI_DEBUG
+# define VMCI_DEBUG_LOG(_level, _args) DODEBUGLOG _args
+#else
+# define VMCI_DEBUG_LOG(_level, _args)
+#endif // VMCI_DEBUG
#define VMCI_LOG(_args) DOLOG _args
-/* XXX We need to make this consistant between the guest and the host. */
-#define VMCILOG(_args) DOLOG _args
+#define VMCI_WARNING(_args) DOWARNING _args
-/*
- * Called by common code, hence the different naming convention.
+/*
+ * Called by common code, hence the different naming convention.
* XXX Should be in vmci.h.
*/
int VMCI_SendDatagram(VMCIDatagram *dg);
#include "vmciUtil.h"
#include "circList.h"
+#define LGPFX "VMCINotifications: "
+
#if !defined(SOLARIS) && !defined(__APPLE__)
/*
cur = LIST_CONTAINER(iter, VMCINotifyHashEntry, idxListItem);
result = LinkNotificationHypercall(cur->handle, cur->doorbell, cur->idx);
if (result != VMCI_SUCCESS && result != VMCI_ERROR_DUPLICATE_ENTRY) {
- VMCI_LOG(("Failed to reregister doorbell handle 0x%x:0x%x of "
- "resource %s to index (error: %d).\n",
- cur->handle.context, cur->handle.resource,
- cur->doorbell ? "doorbell" : "queue pair", result));
+ VMCI_WARNING((LGPFX"Failed to reregister doorbell handle 0x%x:0x%x "
+ "of resource %s to index (error: %d).\n",
+ cur->handle.context, cur->handle.resource,
+ cur->doorbell ? "doorbell" : "queue pair", result));
}
}
}
result = LinkNotificationHypercall(entry->handle, doorbell, entry->idx);
if (result != VMCI_SUCCESS) {
- VMCI_LOG(("Failed to link handle 0x%x:0x%x of resource %s to index "
- "(error: %d).\n", entry->handle.context, entry->handle.resource,
- entry->doorbell ? "doorbell" : "queue pair", result));
+ VMCI_DEBUG_LOG(4, (LGPFX"Failed to link handle 0x%x:0x%x of resource %s "
+ "to index (error: %d).\n",
+ entry->handle.context, entry->handle.resource,
+ entry->doorbell ? "doorbell" : "queue pair", result));
VMCINotifyHashRemoveEntry(entry->handle, entry->doorbell);
VMCI_DestroyEvent(&entry->destroyEvent);
VMCI_FreeKernelMem(entry, sizeof *entry);
* just print a warning and return success.
*/
- VMCI_LOG(("Unlink of %s handle 0x%x:0x%x unknown by hypervisor "
- "(error: %d).\n", doorbell ? "doorbell" : "queuepair",
- handle.context, handle.resource, result));
+ VMCI_DEBUG_LOG(4, (LGPFX"Unlink of %s handle 0x%x:0x%x unknown by "
+ "hypervisor (error: %d).\n",
+ doorbell ? "doorbell" : "queuepair",
+ handle.context, handle.resource, result));
}
return VMCI_SUCCESS;
}
result = VMCI_SendDatagram((VMCIDatagram *)&bitmapSetMsg);
if (result != VMCI_SUCCESS) {
- VMCI_LOG(("VMCINotifications: Failed to register PPN %u as notification "
- "bitmap (error: %d).\n", bitmapPPN, result));
+ VMCI_DEBUG_LOG(4, (LGPFX"VMCINotifications: Failed to register PPN %u as "
+ "notification bitmap (error: %d).\n",
+ bitmapPPN, result));
return FALSE;
}
return TRUE;
if (queuePairEntry->flags & VMCI_QPFLAG_LOCAL) {
/* Local attach case. */
if (queuePairEntry->refCount > 1) {
- VMCI_LOG((LGPFX "Error attempting to attach more than once.\n"));
+ VMCI_DEBUG_LOG(4, (LGPFX"Error attempting to attach more than "
+ "once.\n"));
result = VMCI_ERROR_UNAVAILABLE;
goto errorKeepEntry;
}
if (queuePairEntry->produceSize != consumeSize ||
queuePairEntry->consumeSize != produceSize ||
queuePairEntry->flags != (flags & ~VMCI_QPFLAG_ATTACH_ONLY)) {
- VMCI_LOG((LGPFX "Error mismatched queue pair in local attach.\n"));
+ VMCI_DEBUG_LOG(4, (LGPFX"Error mismatched queue pair in local "
+ "attach.\n"));
result = VMCI_ERROR_QUEUEPAIR_MISMATCH;
goto errorKeepEntry;
}
myProduceQ = VMCI_AllocQueue(produceSize);
if (!myProduceQ) {
- VMCI_LOG((LGPFX "Error allocating pages for produce queue.\n"));
+ VMCI_WARNING((LGPFX"Error allocating pages for produce queue.\n"));
result = VMCI_ERROR_NO_MEM;
goto error;
}
myConsumeQ = VMCI_AllocQueue(consumeSize);
if (!myConsumeQ) {
- VMCI_LOG((LGPFX "Error allocating pages for consume queue.\n"));
+ VMCI_WARNING((LGPFX"Error allocating pages for consume queue.\n"));
result = VMCI_ERROR_NO_MEM;
goto error;
}
produceSize, consumeSize,
myProduceQ, myConsumeQ);
if (!queuePairEntry) {
- VMCI_LOG((LGPFX "Error allocating memory in %s.\n", __FUNCTION__));
+ VMCI_WARNING((LGPFX"Error allocating memory in %s.\n", __FUNCTION__));
result = VMCI_ERROR_NO_MEM;
goto error;
}
result = VMCI_AllocPPNSet(myProduceQ, numProducePages, myConsumeQ,
numConsumePages, &queuePairEntry->ppnSet);
if (result < VMCI_SUCCESS) {
- VMCI_LOG((LGPFX "VMCI_AllocPPNSet failed.\n"));
+ VMCI_WARNING((LGPFX"VMCI_AllocPPNSet failed.\n"));
goto error;
}
} else {
result = VMCIQueuePairAlloc_HyperCall(queuePairEntry);
if (result < VMCI_SUCCESS) {
- VMCI_LOG((LGPFX "VMCIQueuePairAlloc_HyperCall result = %d.\n",
- result));
+ VMCI_WARNING((LGPFX"VMCIQueuePairAlloc_HyperCall result = %d.\n",
+ result));
goto error;
}
}
result = VMCI_ConvertToLocalQueue(consQ, prodQ, entry->consumeSize,
TRUE, &oldConsQ);
if (result != VMCI_SUCCESS) {
- VMCI_LOG((LGPFX "Hibernate failed to create local consume queue "
- "from handle %x:%x (error: %d)\n",
- entry->handle.context, entry->handle.resource, result));
+ VMCI_WARNING((LGPFX"Hibernate failed to create local consume "
+ "queue from handle %x:%x (error: %d)\n",
+ entry->handle.context, entry->handle.resource,
+ result));
VMCI_ReleaseQueueMutex(prodQ);
continue;
}
result = VMCI_ConvertToLocalQueue(prodQ, consQ, entry->produceSize,
FALSE, &oldProdQ);
if (result != VMCI_SUCCESS) {
- VMCI_LOG((LGPFX "Hibernate failed to create local produce queue "
- "from handle %x:%x (error: %d)\n",
- entry->handle.context, entry->handle.resource, result));
+ VMCI_WARNING((LGPFX"Hibernate failed to create local produce "
+ "queue from handle %x:%x (error: %d)\n",
+ entry->handle.context, entry->handle.resource,
+ result));
VMCI_RevertToNonLocalQueue(consQ, oldConsQ, entry->consumeSize);
VMCI_ReleaseQueueMutex(prodQ);
continue;
result = VMCIQueuePairDetachHyperCall(entry->handle);
if (result < VMCI_SUCCESS) {
- VMCI_LOG((LGPFX "Hibernate failed to detach from handle %x:%x\n",
- entry->handle.context, entry->handle.resource));
+ VMCI_WARNING((LGPFX"Hibernate failed to detach from handle "
+ "%x:%x\n",
+ entry->handle.context, entry->handle.resource));
VMCI_RevertToNonLocalQueue(consQ, oldConsQ, entry->consumeSize);
VMCI_RevertToNonLocalQueue(prodQ, oldProdQ, entry->produceSize);
VMCI_ReleaseQueueMutex(prodQ);
if (VMCIEvent_Subscribe(VMCI_EVENT_CTX_ID_UPDATE, VMCI_FLAG_EVENT_NONE,
VMCIUtilCidUpdate, NULL,
&ctxUpdateSubID) < VMCI_SUCCESS) {
- VMCI_LOG(("VMCIUtil: Failed to subscribe to event %d.\n",
- VMCI_EVENT_CTX_ID_UPDATE));
+ VMCI_WARNING((LGPFX"Failed to subscribe to event %d.\n",
+ VMCI_EVENT_CTX_ID_UPDATE));
}
}
VMCIUtil_Exit(void)
{
if (VMCIEvent_Unsubscribe(ctxUpdateSubID) < VMCI_SUCCESS) {
- VMCI_LOG(("VMCIUtil: Failed to unsubscribe to event %d with subscriber "
- "id %d.\n", VMCI_EVENT_CTX_ID_UPDATE, ctxUpdateSubID));
+ VMCI_WARNING((LGPFX"Failed to unsubscribe to event %d with "
+ "subscriber id %d.\n", VMCI_EVENT_CTX_ID_UPDATE,
+ ctxUpdateSubID));
}
}
VMCIEventPayload_Context *evPayload = VMCIEventDataPayload(eventData);
if (subID != ctxUpdateSubID) {
- VMCI_LOG(("VMCIUtil: Invalid subscriber id. %d.\n", subID));
+ VMCI_WARNING((LGPFX"Invalid subscriber id. %d.\n", subID));
return;
}
if (eventData == NULL || evPayload->contextID == VMCI_INVALID_ID) {
- VMCI_LOG(("VMCIUtil: Invalid event data.\n"));
+ VMCI_WARNING((LGPFX"Invalid event data.\n"));
return;
}
- VMCI_LOG(("VMCIUtil: Updating context id from 0x%x to 0x%x on event %d.\n",
+ VMCI_LOG((LGPFX"Updating context id from 0x%x to 0x%x on event %d.\n",
Atomic_Read(&vmContextID),
evPayload->contextID,
eventData->event));
VMCIDatagram *checkMsg = VMCI_AllocKernelMem(msgSize, VMCI_MEMORY_NONPAGED);
if (checkMsg == NULL) {
- VMCI_LOG((LGPFX"Check host: Insufficient memory.\n"));
+ VMCI_WARNING((LGPFX"Check host: Insufficient memory.\n"));
return FALSE;
}
result = VMCIDatagram_Dispatch(dg->src.context, dg);
}
if (result < VMCI_SUCCESS) {
- VMCI_LOG(("Datagram with resource %d failed with err %x.\n",
- dg->dst.resource, result));
+ VMCI_DEBUG_LOG(4, (LGPFX"Datagram with resource %d failed with "
+ "err %x.\n", dg->dst.resource, result));
}
/* On to the next datagram. */
* Datagram doesn't fit in datagram buffer of maximal size. We drop it.
*/
- VMCI_LOG(("Failed to receive datagram of size %u.\n",
- dgInSize));
+ VMCI_DEBUG_LOG(4, (LGPFX"Failed to receive datagram of size %u.\n",
+ dgInSize));
bytesToSkip = dgInSize - remainingBytes;
if (currentDgInBufferSize != dgInBufferSize) {
#ifndef _VMCI_VERSION_H_
#define _VMCI_VERSION_H_
-#define VMCI_DRIVER_VERSION 1.0.24.0
-#define VMCI_DRIVER_VERSION_COMMAS 1,0,24,0
-#define VMCI_DRIVER_VERSION_STRING "1.0.24.0"
+#define VMCI_DRIVER_VERSION 1.0.25.0
+#define VMCI_DRIVER_VERSION_COMMAS 1,0,25,0
+#define VMCI_DRIVER_VERSION_STRING "1.0.25.0"
#endif /* _VMCI_VERSION_H_ */