mirror of
https://github.com/opnsense/src.git
synced 2026-05-04 17:05:14 -04:00
In a virtual machine, VMCI is exposed as a regular PCI device. The primary communication mechanisms supported are a point-to-point bidirectional transport based on a pair of memory-mapped queues, and asynchronous notifications in the form of datagrams and doorbells. These features are available to kernel level components such as vSockets through the VMCI kernel API. In addition to this, the VMCI kernel API provides support for receiving events related to the state of the VMCI communication channels, and the virtual machine itself. Submitted by: Vishnu Dasa <vdasa@vmware.com> Reviewed by: bcr, imp Obtained from: VMware Differential Revision: https://reviews.freebsd.org/D14289
43 lines
931 B
C
43 lines
931 B
C
/*-
|
|
* Copyright (c) 2018 VMware, Inc. All Rights Reserved.
|
|
*
|
|
* SPDX-License-Identifier: (BSD-2-Clause AND GPL-2.0)
|
|
*
|
|
* $FreeBSD$
|
|
*/
|
|
|
|
/* Some common utilities used by the VMCI kernel module. */
|
|
|
|
#ifndef _VMCI_UTILS_H_
|
|
#define _VMCI_UTILS_H_
|
|
|
|
/*
|
|
*------------------------------------------------------------------------------
|
|
*
|
|
* vmci_hash_id --
|
|
*
|
|
* Hash function used by the Simple Datagram API. Hashes only a VMCI ID (not
|
|
* the full VMCI handle). Based on the djb2 hash function by Dan Bernstein.
|
|
*
|
|
* Result:
|
|
* Returns guest call size.
|
|
*
|
|
* Side effects:
|
|
* None.
|
|
*
|
|
*------------------------------------------------------------------------------
|
|
*/
|
|
|
|
static inline int
|
|
vmci_hash_id(vmci_id id, unsigned size)
|
|
{
|
|
unsigned i;
|
|
int hash = 5381;
|
|
|
|
for (i = 0; i < sizeof(id); i++)
|
|
hash = ((hash << 5) + hash) + (uint8_t)(id >> (i * 8));
|
|
|
|
return (hash & (size - 1));
|
|
}
|
|
|
|
#endif /* !_VMCI_UTILS_H_ */
|