DrvTAP.cpp revision 7ee572798212239fde73e8ef306779d2b64d9a6d
/** $Id$ */
/** @file
* Universial TAP network transport driver.
*/
/*
* Copyright (C) 2006-2007 innotek GmbH
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License as published by the Free Software Foundation,
* in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
* distribution. VirtualBox OSE is distributed in the hope that it will
* be useful, but WITHOUT ANY WARRANTY of any kind.
*/
#define ASYNC_NET
/*******************************************************************************
* Header Files *
*******************************************************************************/
#define LOG_GROUP LOG_GROUP_DRV_TUN
#ifdef ASYNC_NET
# include <iprt/semaphore.h>
#endif
#ifdef RT_OS_SOLARIS
# include <sys/ethernet.h>
# include <netinet/in_systm.h>
# include <stropts.h>
# include <fcntl.h>
# include <ctype.h>
# include <stdlib.h>
# ifdef VBOX_WITH_CROSSBOW
# include <limits.h>
# include <libdlpi.h>
# include <libdlvnic.h>
# endif
#else
#endif
#include <errno.h>
#ifdef ASYNC_NET
# include <unistd.h>
#endif
#ifdef RT_OS_L4
#endif
#include "Builtins.h"
/*******************************************************************************
* Structures and Typedefs *
*******************************************************************************/
typedef enum ASYNCSTATE
{
//ASYNCSTATE_SUSPENDED = 1,
} ASYNCSTATE;
/**
* Block driver instance data.
*/
typedef struct DRVTAP
{
/** The network interface. */
/** The network interface. */
/** Pointer to the driver instance. */
/** TAP device file handle. */
/** The configured TAP device name. */
char *pszDeviceName;
#ifdef RT_OS_SOLARIS
char *pszDeviceNameActual;
# ifdef VBOX_WITH_CROSSBOW
/** Crossbow: MAC address of the device. */
char *pszMACAddress;
/** Crossbow: Handle of the NIC. */
# else
# endif
#endif
/** TAP setup application. */
char *pszSetupApplication;
/** TAP terminate application. */
char *pszTerminateApplication;
#ifdef ASYNC_NET
/** The write end of the control pipe. */
/** The read end of the control pipe. */
/** The thread state. */
ASYNCSTATE volatile enmState;
/** Reader thread. */
/** We are waiting for more receive buffers. */
uint32_t volatile fOutOfSpace;
/** Event semaphore for blocking on receive. */
#endif
#ifdef VBOX_WITH_STATISTICS
/** Number of sent packets. */
/** Number of sent bytes. */
/** Number of received packets. */
/** Number of received bytes. */
/** Profiling packet transmit runs. */
/** Profiling packet receive runs. */
#ifdef ASYNC_NET
#endif
#endif /* VBOX_WITH_STATISTICS */
#ifdef LOG_ENABLED
/** The nano ts of the last transfer. */
/** The nano ts of the last receive. */
#endif
/** Converts a pointer to TAP::INetworkConnector to a PRDVTAP. */
#define PDMINETWORKCONNECTOR_2_DRVTAP(pInterface) ( (PDRVTAP)((uintptr_t)pInterface - RT_OFFSETOF(DRVTAP, INetworkConnector)) )
/*******************************************************************************
* Internal Functions *
*******************************************************************************/
#ifdef RT_OS_SOLARIS
# ifdef VBOX_WITH_CROSSBOW
# else
# endif
#endif
/**
* Send data to the network.
*
* @returns VBox status code.
* @param pInterface Pointer to the interface structure containing the called function pointer.
* @param pvBuf Data to send.
* @param cb Number of bytes to send.
* @thread EMT
*/
{
#ifdef LOG_ENABLED
LogFlow(("drvTAPSend: %-4d bytes at %llu ns deltas: r=%llu t=%llu\n",
#endif
Log2(("drvTAPSend: pvBuf=%p cb=%#x\n"
"%.*Vhxd\n",
return rc;
}
/**
* Set promiscuous mode.
*
* This is called when the promiscuous mode is set. This means that there doesn't have
* to be a mode change when it's called.
*
* @param pInterface Pointer to the interface structure containing the called function pointer.
* @param fPromiscuous Set if the adaptor is now in promiscuous mode. Clear if it is not.
* @thread EMT
*/
static DECLCALLBACK(void) drvTAPSetPromiscuousMode(PPDMINETWORKCONNECTOR pInterface, bool fPromiscuous)
{
/* nothing to do */
}
/**
* Notification on link status changes.
*
* @param pInterface Pointer to the interface structure containing the called function pointer.
* @param enmLinkState The new link state.
* @thread EMT
*/
static DECLCALLBACK(void) drvTAPNotifyLinkChanged(PPDMINETWORKCONNECTOR pInterface, PDMNETWORKLINKSTATE enmLinkState)
{
/** @todo take action on link down and up. Stop the polling and such like. */
}
/**
* More receive buffer has become available.
*
* This is called when the NIC frees up receive buffers.
*
* @param pInterface Pointer to the interface structure containing the called function pointer.
* @thread EMT
*/
{
LogFlow(("drvTAPNotifyCanReceive:\n"));
/** @todo r=bird: With a bit unfavorable scheduling it's possible to get here
* before fOutOfSpace is set by the overflow code. This will mean that, unless
* more receive descriptors become available, the receive thread will be stuck
* until it times out and cause a hickup in the network traffic.
* There is a simple, but not perfect, workaround for this problem in DrvTAPOs2.cpp.
*
* A better solution would be to ditch the NotifyCanReceive callback and instead
* change the CanReceive to do all the work. This will reduce the amount of code
* duplication, and would permit pcnet to avoid queuing unnecessary ring-3 tasks.
*/
/* ensure we wake up only once */
}
#ifdef ASYNC_NET
/**
* Asynchronous I/O thread for handling receive.
*
* @returns VINF_SUCCESS (ignored).
* @param Thread Thread handle.
* @param pvUser Pointer to a DRVTAP structure.
*/
{
/*
* Polling loop.
*/
for (;;)
{
/*
* Wait for something to become available.
*/
errno=0;
if ( rc > 0
{
/*
* Read the frame.
*/
char achBuf[4096];
#ifdef VBOX_WITH_CROSSBOW
rc = VINF_SUCCESS;
rc = VERR_GENERAL_FAILURE; /** @todo find a better return code. */ /** r=bird: just make a conversion function. */
#else
#endif
if (VBOX_SUCCESS(rc))
{
/*
* Wait for the device to have space for this frame.
* Most guests use frame-sized receive buffers, hence non-zero cbMax
* automatically means there is enough room for entire frame. Some
* guests (eg. Solaris) use large chains of small receive buffers
* (each 128 or so bytes large). We will still start receiving as soon
* as cbMax is non-zero because:
* - it would be quite expensive for pfnCanReceive to accurately
* determine free receive buffer space
* - if we were waiting for enough free buffers, there is a risk
* of deadlocking because the guest could be waiting for a receive
* overflow error to allocate more receive buffers
*/
if (cbMax == 0)
{
/** @todo receive overflow handling needs serious improving! */
while ( cbMax == 0
{
#if 1
/* We get signalled by the network driver. 50ms is just for sanity */
#else
RTThreadSleep(1);
#endif
}
break;
}
/*
* Pass the data up.
*/
#ifdef LOG_ENABLED
LogFlow(("drvTAPAsyncIoThread: %-4d bytes at %llu ns deltas: r=%llu t=%llu\n",
#endif
Log2(("drvTAPAsyncIoThread: cbRead=%#x\n"
"%.*Vhxd\n",
}
else
{
if (rc == VERR_INVALID_HANDLE)
break;
}
}
else if ( rc > 0
{
LogFlow(("drvTAPAsyncIoThread: Control message: enmState=%d revents=%#x\n", pData->enmState, aFDs[1].revents));
break;
break;
/* drain the pipe */
char ch;
}
else
{
/*
* poll() failed for some reason. Yield to avoid eating too much CPU.
*
* EINTR errors have been seen frequently. They should be harmless, even
* if they are not supposed to occur in our setup.
*/
Log(("rc=%d revents=%#x,%#x errno=%p %s\n", rc, aFDs[0].revents, aFDs[1].revents, errno, strerror(errno)));
else
AssertMsgFailed(("rc=%d revents=%#x,%#x errno=%p %s\n", rc, aFDs[0].revents, aFDs[1].revents, errno, strerror(errno)));
}
}
return VINF_SUCCESS;
}
#else
/**
* Poller callback.
*/
{
while (cbMax > 0)
{
/* check for data to read */
{
{
/* data waiting, read it. */
char achBuf[4096];
#ifdef VBOX_WITH_CROSSBOW
int rc = VINF_SUCCESS;
#else
#endif
if (VBOX_SUCCESS(rc))
{
/* push it up to guy over us. */
Log2(("drvTAPPoller: cbRead=%#x\n"
"%.*Vhxd\n",
}
else
break;
}
else
break;
}
else
break;
}
}
#endif
#if defined(RT_OS_SOLARIS)
/**
* Calls OS-specific TAP setup application/script.
*
* @returns VBox error code.
* @param pData The instance data.
*/
{
char *pszArgs[3];
/** @todo use RTProcCreate */
Log2(("Starting TAP setup application: %s %s\n", pData->pszSetupApplication, pData->pszDeviceNameActual));
if (pid < 0)
{
/* Bad. fork() failed! */
LogRel(("TAP#%d: Failed to fork() process for running TAP setup application: %s\n", pData->pDrvIns->iInstance,
return VERR_HOSTIF_INIT_FAILED;
}
if (pid == 0)
{
/* Child process. */
_exit(1);
}
/* Parent process. */
int result;
;
{
LogRel(("TAP#%d: Failed to run TAP setup application: %s\n", pData->pDrvIns->iInstance, pData->pszSetupApplication));
return VERR_HOSTIF_INIT_FAILED;
}
return VINF_SUCCESS;
}
/**
* Calls OS-specific TAP terminate application/script.
*
* @returns VBox error code.
* @param pData The instance data.
*/
{
char *pszArgs[3];
/** @todo use RTProcCreate */
Log2(("Starting TAP terminate application: %s %s\n", pData->pszTerminateApplication, pData->pszDeviceNameActual));
if (pid < 0)
{
/* Bad. fork() failed! */
LogRel(("TAP#%d: Failed to fork() process for running TAP terminate application: %s\n", pData->pDrvIns->iInstance,
return VERR_HOSTIF_TERM_FAILED;
}
if (pid == 0)
{
/* Child process. */
_exit(1);
}
/* Parent process. */
int result;
;
{
LogRel(("TAP#%d: Failed to run TAP terminate application: %s\n", pData->pDrvIns->iInstance, pData->pszSetupApplication));
return VERR_HOSTIF_TERM_FAILED;
}
return VINF_SUCCESS;
}
#endif /* RT_OS_SOLARIS */
#ifdef RT_OS_SOLARIS
# ifdef VBOX_WITH_CROSSBOW
/**
* Crossbow: create a virtual NIC.
*
* @returns VBox error code.
* @param pData The instance data.
*/
{
/*
* Get a physical NIC.
*/
/** @todo r=bird: I'm I right in thinking that this just gets the name of the
* last ethernet NIC and binds us to that? If so, this really needs to be
* a user option. On OS/2 this is passed in as 'ConnectTo', using the same name
* is possibly a good idea even if the type is different (we need string not integer). */
char szNICName[_LIFNAMSIZ];
if (VBOX_FAILURE(ret))
return VERR_HOSTIF_INIT_FAILED;
/*
* Get the MAC address with ':' seperators as ether_aton() needs those
*/
/** @todo r=bird: ether_addr is just a byte array, just pass the PDMMAC
* structure around and memcpy it, this is too much work. */
{
pData->pszMACAddress[8], pData->pszMACAddress[9], pData->pszMACAddress[10], pData->pszMACAddress[11]);
}
if (!pEtherAddr)
/*
* Setup VNIC parameters.
*/
strncpy(VNICAttr.va_dev_name, szNICName, sizeof(VNICAttr.va_dev_name) - 1); /** @todo r=bird: don't ever use strncpy! Esp. not with an uninitialized structure. */
bool fAutoID = true;
#if 0
/* Disabled for now, since Crossbow does not entirely respect our own VNIC ID.*/
if (pData->pszDeviceName)
{
{
fAutoID = false;
}
}
#endif
/*
* Create a VNIC if it doesn't already exist.
* XXX: Perhaps VMs should not use existing VNICs???
*/
/** r=bird: The users should be able to create the vnic himself and pass it down. This would be the
* same as the tapN interface name. */
if (rc == DLADM_STATUS_OK)
{
if (fAutoID)
if (rc != DLADM_STATUS_OK)
}
else
/** r=bird: This can't possibly fail in any way, or what? */
if (VBOX_FAILURE(ret))
return ret;
return VINF_SUCCESS;
}
/**
* Crossbow: Obtain a physical NIC for binding the virtual NIC.
*
* @returns VBox error code.
* @param pszNICName Where to store the NIC name.
* @param cchNICName The size of the buffer buffer pszNICName points to.
*/
{
/*
* Try and obtain the a physical NIC to bind the VNIC to.
*/
{
LogRel(("SolarisGetNIC: Socket creation for AF_INET family failed.\n"));
return VERR_HOSTIF_INIT_FAILED;
}
int rc;
{
if (pszBuffer)
{
{
/*
* Loop through all NICs on the machine. We'll use the first ethernet NIC
* that is not a loopback interface for binding the VNIC.
*/
while (iIf-- > 0)
{
{
if ( rc2 == DLPI_SUCCESS
{
if (cch < cchNICName)
{
rc = VINF_SUCCESS;
}
else
break;
}
}
}
}
else
{
LogRel(("SolarisGetNIC: SIOCGLIFCONF failed\n"));
}
}
else
rc = VERR_NO_MEMORY;
}
else
{
LogRel(("SolarisGetNIC: SIOCGLIFNUM failed\n"));
}
return rc;
}
/**
* Crossbow: Open & configure the physical NIC.
*
* @returns VBox error code.
* @param pData The instance data.
* @param pszNICName Name of the physical NIC.
* @param pEtherAddr Ethernet address to use for the VNIC.
*/
{
/*
* Open & bind the NIC using the datalink provider routine.
*/
if (rc != DLPI_SUCCESS)
N_("Failed to open VNIC in raw mode."));
/*
* need to checks here to make sure the NIC has a ethernet address.
*/
if (rc == DLPI_SUCCESS)
{
rc = dlpi_set_physaddr(pData->pDeviceHandle, DL_CURR_PHYS_ADDR, pEtherAddr->ether_addr_octet, ETHERADDRL);
if (rc == DLPI_SUCCESS)
{
if (rc == DLPI_SUCCESS)
{
/* Need to use DL_PROMIS_PHYS (not multicast) as we cannot be sure what the guest needs. */
if (rc == DLPI_SUCCESS)
{
if (pData->FileDevice >= 0)
{
return VINF_SUCCESS;
}
N_("Failed to obtain file descriptor for VNIC."));
}
else
N_("Failed to set appropriate promiscous mode."));
}
else
N_("Failed to activate promiscous mode for VNIC."));
}
else
N_("Failed to set physical address for VNIC."));
}
else
N_("Failed to bind VNIC."));
return rc;
}
/**
* Crossbow: delete a virtual NIC.
*
* @returns VBox error code.
* @param pData The instance data.
*/
{
/*
* Extract the VNIC ID from the name. e.g.: "vnic900" we need "900".
*/
pszVNICName++;
if (pszVNICName)
{
/** @todo r=bird: what about just remembering the VNIC ID? (assuming it's the same as during creation.) */
if (rc == DLADM_STATUS_OK)
return VINF_SUCCESS;
}
return VERR_HOSTIF_TERM_FAILED;
}
/**
* Crossbow: VNIC comparison hook function.
*
* @returns VBox error code.
* @param pvArg Opaque pointer to a VNIC.
* @param pVNICAttr Pointer to another VNIC to compare with the first.
*/
{
return DLADM_STATUS_OK;
return DLADM_STATUS_EXIST;
}
# else /* VBOX_WITH_CROSSBOW */
/** Whether to enable ARP for TAP. */
# define VBOX_SOLARIS_TAP_ARP 1
/**
*
* @returns VBox error code.
* @param pDrvIns The driver instance data.
* @param pszDevName Pointer to device name.
*/
{
if (IPFileDes < 0)
if (TapFileDes < 0)
/* Use the PPA from the ifname if possible (e.g "tap2", then use 2 as PPA) */
int iPPA = -1;
if (pData->pszDeviceName)
{
}
if (iPPA < 0)
{
}
if (!InterfaceFD)
{
}
char szTmp[16];
{
pszDevName = szTmp;
}
LogRel(("TAP#%d: Failed to get interface flags after setting PPA. errno=%d\n", pDrvIns->iInstance, errno));
#ifdef VBOX_SOLARIS_TAP_ARP
/* Interface */
/* IP */
/* ARP */
if (ARPFileDes < 0)
#endif
/* We must use I_LINK and not I_PLINK as I_PLINK makes the link persistent.
* Then we would not be able unlink the interface if we reuse it.
* Even 'unplumb' won't work after that.
*/
if (IPMuxID == -1)
{
#ifdef VBOX_SOLARIS_TAP_ARP
#endif
}
#ifdef VBOX_SOLARIS_TAP_ARP
if (ARPMuxID == -1)
#endif
/* Reuse ifReq */
#ifdef VBOX_SOLARIS_TAP_ARP
#endif
{
#ifdef VBOX_SOLARIS_TAP_ARP
#endif
}
return VINF_SUCCESS;
}
# endif /* VBOX_WITH_CROSSBOW */
#endif /* RT_OS_SOLARIS */
/**
* Queries an interface to the driver.
*
* @returns Pointer to interface.
* @returns NULL if the interface was not supported by the driver.
* @param pInterface Pointer to this interface structure.
* @param enmInterface The requested interface identification.
* @thread Any thread.
*/
{
switch (enmInterface)
{
case PDMINTERFACE_BASE:
return &pData->INetworkConnector;
default:
return NULL;
}
}
/**
* Destruct a driver instance.
*
* Most VM resources are freed by the VM. This callback is provided so that any non-VM
* resources can be freed correctly.
*
* @param pDrvIns The driver instance data.
*/
{
LogFlow(("drvTAPDestruct\n"));
#ifdef ASYNC_NET
/*
* Terminate the Async I/O Thread.
*/
{
/* Ensure that it does not spin in the CanReceive loop */
}
/*
* Terminate the control pipe.
*/
{
}
{
}
#endif
#ifdef RT_OS_SOLARIS
/** @todo r=bird: exactly where and when this is closed depends on how it was created, see ConsoleImpl.cpp. It's a bit complicated, I know :-/ */
{
}
# ifndef VBOX_WITH_CROSSBOW
{
}
# endif
/*
* Call TerminateApplication after closing the device otherwise
* TerminateApplication would not be able to unplumb it.
*/
if (pData->pszTerminateApplication)
# ifdef VBOX_WITH_CROSSBOW
/* Finally unregister the VNIC */
# endif
#endif /* RT_OS_SOLARIS */
}
/**
* Construct a TAP network transport driver instance.
*
* @returns VBox status.
* @param pDrvIns The driver instance data.
* If the registration structure is needed, pDrvIns->pDrvReg points to it.
* @param pCfgHandle Configuration node handle for the driver. Use this to obtain the configuration
* of the driver instance. It's also found in pDrvIns->pCfgHandle, but like
* iInstance it's expected to be used a bit in this function.
*/
{
/*
* Init the static parts.
*/
#ifdef RT_OS_SOLARIS
# ifdef VBOX_WITH_CROSSBOW
# else
# endif
#endif
#ifdef ASYNC_NET
#endif
/* IBase */
/* INetwork */
/*
* Validate the config.
*/
if (!CFGMR3AreValuesValid(pCfgHandle, "Device\0InitProg\0TermProg\0FileHandle\0TAPSetupApplication\0TAPTerminateApplication\0MACAddress"))
/*
* Check that no-one is attached to us.
*/
if (rc != VERR_PDM_NO_ATTACHED_DRIVER)
N_("Configuration error: Cannot attach drivers to the TAP driver!"));
/*
* Query the network port interface.
*/
pData->pPort = (PPDMINETWORKPORT)pDrvIns->pUpBase->pfnQueryInterface(pDrvIns->pUpBase, PDMINTERFACE_NETWORK_PORT);
/*
* Read the configuration.
*/
#if defined(RT_OS_SOLARIS) /** @todo Other platforms' TAP code should be moved here from ConsoleImpl & VBoxBFE. */
if (VBOX_SUCCESS(rc))
{
}
else if (rc != VERR_CFGM_VALUE_NOT_FOUND)
return PDMDRV_SET_ERROR(pDrvIns, rc, N_("Configuration error: failed to query \"TAPTerminateApplication\""));
rc = CFGMR3QueryStringAlloc(pCfgHandle, "TAPTerminateApplication", &pData->pszTerminateApplication);
if (VBOX_SUCCESS(rc))
{
}
else if (rc != VERR_CFGM_VALUE_NOT_FOUND)
return PDMDRV_SET_ERROR(pDrvIns, rc, N_("Configuration error: failed to query \"TAPTerminateApplication\""));
# ifdef VBOX_WITH_CROSSBOW
rc = CFGMR3QueryStringAlloc(pCfgHandle, "MACAddress", &pData->pszMACAddress); /** @todo r=bird: MACAddress -> MAC; pass bytes like for pcnet. See VBoxBFE and ConsoleImpl.cpp comments. */
if (VBOX_FAILURE(rc))
N_("Failed to query \"MACAddress\""));
# endif
if (VBOX_FAILURE(rc))
N_("Configuration error: Query for \"Device\" string failed!"));
/*
* Do the setup.
*/
# ifdef VBOX_WITH_CROSSBOW
# else
# endif
if (VBOX_FAILURE(rc))
return rc;
if (pData->pszSetupApplication)
{
if (VBOX_FAILURE(rc))
}
#else /* !RT_OS_SOLARIS */
if (VBOX_FAILURE(rc))
N_("Configuration error: Query for \"FileHandle\" 32-bit signed integer failed!"));
#endif /* !RT_OS_SOLARIS */
/*
* Make sure the descriptor is non-blocking and valid.
*
* We should actually query if it's a TAP device, but I haven't
* found any way to do that.
*/
/** @todo determine device name. This can be done by reading the link /proc/<pid>/fd/<fd> */
rc = VINF_SUCCESS;
#ifdef ASYNC_NET
/*
* Create the control pipe.
*/
int fds[2];
#ifdef RT_OS_L4
/* XXX We need to tell the library which interface we are using */
#endif
{
return rc;
}
/*
* Create the async I/O thread.
*/
rc = RTThreadCreate(&pData->Thread, drvTAPAsyncIoThread, pData, 128*_1K, RTTHREADTYPE_IO, RTTHREADFLAGS_WAITABLE, "TAP");
#else
/*
* Register poller
*/
#endif
#ifdef VBOX_WITH_STATISTICS
/*
* Statistics.
*/
PDMDrvHlpSTAMRegisterF(pDrvIns, &pData->StatPktSent, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, "Number of sent packets.", "/Drivers/TAP%d/Packets/Sent", pDrvIns->iInstance);
PDMDrvHlpSTAMRegisterF(pDrvIns, &pData->StatPktSentBytes, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_BYTES, "Number of sent bytes.", "/Drivers/TAP%d/Bytes/Sent", pDrvIns->iInstance);
PDMDrvHlpSTAMRegisterF(pDrvIns, &pData->StatPktRecv, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, "Number of received packets.", "/Drivers/TAP%d/Packets/Received", pDrvIns->iInstance);
PDMDrvHlpSTAMRegisterF(pDrvIns, &pData->StatPktRecvBytes, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_BYTES, "Number of received bytes.", "/Drivers/TAP%d/Bytes/Received", pDrvIns->iInstance);
PDMDrvHlpSTAMRegisterF(pDrvIns, &pData->StatTransmit, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_TICKS_PER_CALL, "Profiling packet transmit runs.", "/Drivers/TAP%d/Transmit", pDrvIns->iInstance);
PDMDrvHlpSTAMRegisterF(pDrvIns, &pData->StatReceive, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_TICKS_PER_CALL, "Profiling packet receive runs.", "/Drivers/TAP%d/Receive", pDrvIns->iInstance);
# ifdef ASYNC_NET
PDMDrvHlpSTAMRegisterF(pDrvIns, &pData->StatRecvOverflows, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_TICKS_PER_OCCURENCE, "Profiling packet receive overflows.", "/Drivers/TAP%d/RecvOverflows", pDrvIns->iInstance);
# endif
#endif /* VBOX_WITH_STATISTICS */
return rc;
}
/**
* TAP network transport driver registration record.
*/
const PDMDRVREG g_DrvHostInterface =
{
/* u32Version */
/* szDriverName */
"HostInterface",
/* pszDescription */
"TAP Network Transport Driver",
/* fFlags */
/* fClass. */
/* cMaxInstances */
~0,
/* cbInstance */
sizeof(DRVTAP),
/* pfnConstruct */
/* pfnDestruct */
/* pfnIOCtl */
NULL,
/* pfnPowerOn */
NULL,
/* pfnReset */
NULL,
/* pfnSuspend */
NULL, /** @todo Do power on, suspend and resume handlers! */
/* pfnResume */
NULL,
/* pfnDetach */
NULL,
/* pfnPowerOff */
};