DrvIntNet.cpp revision 4fcfe0bd966753617b7ab5fb81fb24709914fc1c
/* $Id$ */
/** @file
* DrvIntNet - Internal network transport driver.
*/
/*
* Copyright (C) 2006-2010 Sun Microsystems, Inc.
*
* 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 (GPL) 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.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 USA or visit http://www.sun.com if you need
* additional information or have any questions.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#define LOG_GROUP LOG_GROUP_DRV_INTNET
#include <VBox/pdmnetinline.h>
#include <VBox/pdmnetifs.h>
#include <VBox/intnetinline.h>
#include <iprt/memcache.h>
#include <iprt/semaphore.h>
#include "../Builtins.h"
/*******************************************************************************
* Structures and Typedefs *
*******************************************************************************/
/**
* The state of the asynchronous thread.
*/
typedef enum ASYNCSTATE
{
/** The thread is suspended. */
ASYNCSTATE_SUSPENDED = 1,
/** The thread is running. */
/** The thread must (/has) terminate. */
/** The usual 32-bit type blowup. */
ASYNCSTATE_32BIT_HACK = 0x7fffffff
} ASYNCSTATE;
/**
* Internal networking driver instance data.
*
* @implements PDMINETWORKUP
*/
typedef struct DRVINTNET
{
/** The network interface. */
/** The network interface. */
/** The network config interface.
* Can (in theory at least) be NULL. */
/** Pointer to the driver instance. */
/** Pointer to the communication buffer. */
/** Interface handle. */
/** The thread state. */
ASYNCSTATE volatile enmState;
/** Reader thread. */
/** Event semaphore the Thread waits on while the VM is suspended. */
/** Set if the link is down.
* When the link is down all incoming packets will be dropped. */
bool volatile fLinkDown;
/** Set if data transmission should start immediately and deactivate
* as late as possible. */
/** Padding. */
bool afReserved[2];
/** The network name. */
char szNetwork[INTNET_MAX_NETWORK_NAME];
/** Base interface for ring-0. */
/** Base interface for ring-0. */
#ifdef LOG_ENABLED
/** The nano ts of the last transfer. */
/** The nano ts of the last receive. */
#endif
#ifdef VBOX_WITH_STATISTICS
/** Profiling packet transmit runs. */
/** Profiling packet receive runs. */
#endif /* VBOX_WITH_STATISTICS */
/** Number of GSO packets sent. */
/** Number of GSO packets recevied. */
} DRVINTNET;
/** Pointer to instance data of the internal networking driver. */
typedef DRVINTNET *PDRVINTNET;
#ifdef IN_RING3
/**
* Updates the MAC address on the kernel side.
*
* @returns VBox status code.
* @param pThis The driver instance.
*/
{
if (!pThis->pIAboveConfigR3)
return VINF_SUCCESS;
if (RT_SUCCESS(rc))
&SetMacAddressReq, sizeof(SetMacAddressReq));
Log(("drvR3IntNetUpdateMacAddress: %.*Rhxs rc=%Rrc\n", sizeof(SetMacAddressReq.Mac), &SetMacAddressReq.Mac, rc));
return rc;
}
/**
* Sets the kernel interface active or inactive.
*
* Worker for poweron, poweroff, suspend and resume.
*
* @returns VBox status code.
* @param pThis The driver instance.
* @param fActive The new state.
*/
{
if (!pThis->pIAboveConfigR3)
return VINF_SUCCESS;
&SetActiveReq, sizeof(SetActiveReq));
return rc;
}
/* -=-=-=-=- PDMINETWORKUP -=-=-=-=- */
/**
* @interface_method_impl{PDMINETWORKUP,pfnAllocBuf}
*/
{
int rc = VINF_SUCCESS;
/*
* Allocate a S/G buffer.
*/
if (pSgBuf)
{
if (pGso)
else
#if 1 /** @todo implement VERR_TRY_AGAIN once this moves to EMT. */
if ( RT_FAILURE(rc)
{
if (pGso)
else
}
#endif
if (RT_SUCCESS(rc))
{
return VINF_SUCCESS;
}
/*
* Arm the try again stuff.
*/
/** @todo if (pThis->pBufR3->cbSend >= cbMin * 2 + sizeof(INTNETHDR))
rc = VERR_TRY_AGAIN;
else */
rc = VERR_NO_MEMORY;
}
else
rc = VERR_NO_MEMORY;
/** @todo implement VERR_TRY_AGAIN */
return rc;
}
/**
* @interface_method_impl{PDMINETWORKUP,pfnFreeBuf}
*/
{
/** @todo LATER: try unalloc the frame. */
return VINF_SUCCESS;
}
/**
* @interface_method_impl{PDMINETWORKUP,pfnSendBuf}
*/
static DECLCALLBACK(int) drvR3IntNetUp_SendBuf(PPDMINETWORKUP pInterface, PPDMSCATTERGATHER pSgBuf, bool fOnWorkerThread)
{
/*
* Commit the frame and push it thru the switch.
*/
return VINF_SUCCESS;
}
/**
* @interface_method_impl{PDMINETWORKUP,pfnSetPromiscuousMode}
*/
static DECLCALLBACK(void) drvR3IntNetUp_SetPromiscuousMode(PPDMINETWORKUP pInterface, bool fPromiscuous)
{
int rc = PDMDrvHlpSUPCallVMMR0Ex(pThis->pDrvInsR3, VMMR0_DO_INTNET_IF_SET_PROMISCUOUS_MODE, &Req, sizeof(Req));
}
/**
* @interface_method_impl{PDMINETWORKUP,pfnNotifyLinkChanged}
*/
static DECLCALLBACK(void) drvR3IntNetUp_NotifyLinkChanged(PPDMINETWORKUP pInterface, PDMNETWORKLINKSTATE enmLinkState)
{
bool fLinkDown;
switch (enmLinkState)
{
case PDMNETWORKLINKSTATE_DOWN:
fLinkDown = true;
break;
default:
case PDMNETWORKLINKSTATE_UP:
fLinkDown = false;
break;
}
LogFlow(("drvR3IntNetUp_NotifyLinkChanged: enmLinkState=%d %d->%d\n", enmLinkState, pThis->fLinkDown, fLinkDown));
}
/**
*
* @returns VINF_SUCCESS if space is available.
* @returns VERR_STATE_CHANGED if the state changed.
* @returns VBox status code on other errors.
* @param pThis Pointer to the instance data.
*/
{
LogFlow(("drvR3IntNetAsyncIoWaitForSpace:\n"));
return rc;
}
/**
* Executes async I/O (RUNNING mode).
*
* @returns VERR_STATE_CHANGED if the state changed.
* @returns Appropriate VBox status code (error) on fatal error.
* @param pThis The driver instance data.
*/
{
/*
* The running loop - processing received data and waiting for more to arrive.
*/
for (;;)
{
/*
* Process the receive buffer.
*/
{
/*
* Check the state and then inspect the packet.
*/
{
LogFlow(("drvR3IntNetAsyncIoRun: returns VERR_STATE_CHANGED (state changed - #0)\n"));
return VERR_STATE_CHANGED;
}
if ( ( u16Type == INTNETHDR_TYPE_FRAME
|| u16Type == INTNETHDR_TYPE_GSO)
{
/*
* Check if there is room for the frame and pass it up.
*/
if (rc == VINF_SUCCESS)
{
if (u16Type == INTNETHDR_TYPE_FRAME)
{
/*
* Normal frame.
*/
#ifdef LOG_ENABLED
if (LogIsEnabled())
{
LogFlow(("drvR3IntNetAsyncIoRun: %-4d bytes at %llu ns deltas: r=%llu t=%llu\n",
Log2(("drvR3IntNetAsyncIoRun: cbFrame=%#x\n"
"%.*Rhxd\n",
}
#endif
/* skip to the next frame. */
}
else
{
/*
* Generic segment offload frame (INTNETHDR_TYPE_GSO).
*
* This is where we do the offloading since we don't
* emulate any NICs with large receive offload (LRO).
*/
{
cbFrame -= sizeof(PDMNETWORKGSO);
#ifdef LOG_ENABLED
if (LogIsEnabled())
{
LogFlow(("drvR3IntNetAsyncIoRun: %-4d bytes at %llu ns deltas: r=%llu t=%llu; GSO - %u segs\n",
Log2(("drvR3IntNetAsyncIoRun: cbFrame=%#x type=%d cbHdrs=%#x Hdr1=%#x Hdr2=%#x MMS=%#x\n"
"%.*Rhxd\n",
}
#endif
{
if (RT_FAILURE(rc))
{
Log(("drvR3IntNetAsyncIoRun: drvR3IntNetAsyncIoWaitForSpace -> %Rrc; iSeg=%u cSegs=%u\n", iSeg, cSegs));
break; /* we drop the rest. */
}
}
}
else
{
AssertMsgFailed(("cbFrame=%#x type=%d cbHdrs=%#x Hdr1=%#x Hdr2=%#x MMS=%#x\n",
}
}
}
else
{
/*
* Wait for sufficient space to become available and then retry.
*/
if (RT_FAILURE(rc))
{
if (rc == VERR_INTERRUPTED)
{
/*
* NIC is going down, likely because the VM is being reset. Skip the frame.
*/
AssertMsg(INETNETIsValidFrameType(pHdr->u16Type), ("Unknown frame type %RX16! offRead=%#x\n", pHdr->u16Type, pRingBuf->offReadX));
}
else
{
return rc;
}
}
}
}
else
{
/*
* Link down or unknown frame - skip to the next frame.
*/
AssertMsg(INETNETIsValidFrameType(pHdr->u16Type), ("Unknown frame type %RX16! offRead=%#x\n", pHdr->u16Type, pRingBuf->offReadX));
}
} /* while more received data */
/*
* Wait for data, checking the state before we block.
*/
{
LogFlow(("drvR3IntNetAsyncIoRun: returns VINF_SUCCESS (state changed - #1)\n"));
return VERR_STATE_CHANGED;
}
if ( RT_FAILURE(rc)
&& rc != VERR_TIMEOUT
&& rc != VERR_INTERRUPTED)
{
return rc;
}
}
}
/**
* Asynchronous I/O thread for handling receive.
*
* @returns VINF_SUCCESS (ignored).
* @param ThreadSelf Thread handle.
* @param pvUser Pointer to a DRVINTNET structure.
*/
{
/*
* The main loop - acting on state.
*/
for (;;)
{
switch (enmState)
{
case ASYNCSTATE_SUSPENDED:
{
if ( RT_FAILURE(rc)
&& rc != VERR_TIMEOUT)
{
return rc;
}
break;
}
case ASYNCSTATE_RUNNING:
{
if ( rc != VERR_STATE_CHANGED
&& RT_FAILURE(rc))
{
return rc;
}
break;
}
default:
case ASYNCSTATE_TERMINATE:
LogFlow(("drvR3IntNetAsyncIoThread: returns VINF_SUCCESS\n"));
return VINF_SUCCESS;
}
}
}
/* -=-=-=-=- PDMIBASERC -=-=-=-=- */
/**
* @interface_method_impl{PDMIBASERC,pfnQueryInterface}
*/
static DECLCALLBACK(RTRCPTR) drvR3IntNetIBaseRC_QueryInterface(PPDMIBASERC pInterface, const char *pszIID)
{
return NIL_RTRCPTR;
}
/* -=-=-=-=- PDMIBASER0 -=-=-=-=- */
/**
* @interface_method_impl{PDMIBASER0,pfnQueryInterface}
*/
static DECLCALLBACK(RTR0PTR) drvR3IntNetIBaseR0_QueryInterface(PPDMIBASER0 pInterface, const char *pszIID)
{
return NIL_RTR0PTR;
}
/* -=-=-=-=- PDMIBASE -=-=-=-=- */
/**
* @interface_method_impl{PDMIBASE,pfnQueryInterface}
*/
static DECLCALLBACK(void *) drvR3IntNetIBase_QueryInterface(PPDMIBASE pInterface, const char *pszIID)
{
return NULL;
}
/* -=-=-=-=- PDMDRVREG -=-=-=-=- */
/**
* Power Off notification.
*
* @param pDrvIns The driver instance.
*/
{
LogFlow(("drvR3IntNetPowerOff\n"));
{
}
}
/**
* drvR3IntNetResume helper.
*/
{
/*
* Add the frame to the send buffer and push it onto the network.
*/
if ( rc == VERR_BUFFER_OVERFLOW
{
}
if (RT_SUCCESS(rc))
{
}
return rc;
}
/**
* Resume notification.
*
* @param pDrvIns The driver instance.
*/
{
LogFlow(("drvR3IntNetPowerResume\n"));
{
}
&& pThis->pIAboveConfigR3)
{
/*
* We've just been teleported and need to drop a hint to the switch
* since we're likely to have changed to a different port. We just
* push out some ethernet frame that doesn't mean anything to anyone.
* For this purpose ethertype 0x801e was chosen since it was registered
*/
union
{
} Frame;
if (RT_SUCCESS(rc))
if (RT_FAILURE(rc))
}
}
/**
* Suspend notification.
*
* @param pDrvIns The driver instance.
*/
{
LogFlow(("drvR3IntNetPowerSuspend\n"));
{
}
}
/**
* Power On notification.
*
* @param pDrvIns The driver instance.
*/
{
LogFlow(("drvR3IntNetPowerOn\n"));
{
}
}
/**
* 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(("drvR3IntNetDestruct\n"));
/*
* Indicate to the thread that it's time to quit.
*/
/*
* Close the interface
*/
{
}
/*
* Wait for the thread to terminate.
*/
{
if (hEvtSuspended != NIL_RTSEMEVENT)
}
/*
* Destroy the semaphore and S/G cache.
*/
if (hEvtSuspended != NIL_RTSEMEVENT)
{
/*
* Deregister statistics in case we're being detached.
*/
#ifdef VBOX_WITH_STATISTICS
#endif
}
}
/**
* Construct a TAP network transport driver instance.
*
* @copydoc FNPDMDRVCONSTRUCT
*/
{
bool f;
/*
* Init the static parts.
*/
pThis->fActivateEarlyDeactivateLate = false;
/* IBase* */
/* INetworkUp */
/*
* Validate the config.
*/
if (!CFGMR3AreValuesValid(pCfg,
"Network\0"
"Trunk\0"
"TrunkType\0"
"ReceiveBufferSize\0"
"SendBufferSize\0"
"RestrictAccess\0"
"SharedMacOnWire\0"
"IgnoreAllPromisc\0"
"QuietlyIgnoreAllPromisc\0"
"IgnoreClientPromisc\0"
"QuietlyIgnoreClientPromisc\0"
"IgnoreTrunkWirePromisc\0"
"QuietlyIgnoreTrunkWirePromisc\0"
"IgnoreTrunkHostPromisc\0"
"QuietlyIgnoreTrunkHostPromisc\0"
"IsService\0"))
/*
* Check that no-one is attached to us.
*/
("Configuration error: Not possible to attach anything to this driver!\n"),
/*
* Query the network port interface.
*/
if (!pThis->pIAboveNet)
{
AssertMsgFailed(("Configuration error: the above device/driver didn't export the network port interface!\n"));
return VERR_PDM_MISSING_INTERFACE_ABOVE;
}
/*
* Read the configuration.
*/
/** @cfgm{Network, string}
* The name of the internal network to connect to.
*/
if (RT_FAILURE(rc))
N_("Configuration error: Failed to get the \"Network\" value"));
/** @cfgm{TrunkType, uint32_t, kIntNetTrunkType_None}
* The trunk connection type see INTNETTRUNKTYPE.
*/
if (rc == VERR_CFGM_VALUE_NOT_FOUND)
else if (RT_FAILURE(rc))
N_("Configuration error: Failed to get the \"TrunkType\" value"));
/** @cfgm{Trunk, string, ""}
* The name of the trunk connection.
*/
if (rc == VERR_CFGM_VALUE_NOT_FOUND)
else if (RT_FAILURE(rc))
N_("Configuration error: Failed to get the \"Trunk\" value"));
/** @cfgm{RestrictAccess, boolean, true}
* Whether to restrict the access to the network or if it should be public. Everyone on
* the computer can connect to a public network. Don't change this.
*/
bool fRestrictAccess;
if (rc == VERR_CFGM_VALUE_NOT_FOUND)
fRestrictAccess = true;
else if (RT_FAILURE(rc))
N_("Configuration error: Failed to get the \"RestrictAccess\" value"));
/** @cfgm{IgnoreAllPromisc, boolean, false}
* When set all request for operating any interface or trunk in promiscuous
* mode will be ignored. */
if (RT_FAILURE(rc))
N_("Configuration error: Failed to get the \"IgnoreAllPromisc\" value"));
if (f)
/** @cfgm{QuietlyIgnoreAllPromisc, boolean, false}
* When set all request for operating any interface or trunk in promiscuous
* mode will be ignored. This differs from IgnoreAllPromisc in that clients
* won't get VERR_INTNET_INCOMPATIBLE_FLAGS. */
if (RT_FAILURE(rc))
N_("Configuration error: Failed to get the \"QuietlyIgnoreAllPromisc\" value"));
if (f)
/** @cfgm{IgnoreClientPromisc, boolean, false}
* When set all request for operating any non-trunk interface in promiscuous
* mode will be ignored. */
if (RT_FAILURE(rc))
N_("Configuration error: Failed to get the \"IgnoreClientPromisc\" value"));
if (f)
/** @cfgm{QuietlyIgnoreClientPromisc, boolean, false}
* When set all request for operating any non-trunk interface promiscuous mode
* will be ignored. This differs from IgnoreClientPromisc in that clients won't
* get VERR_INTNET_INCOMPATIBLE_FLAGS. */
if (RT_FAILURE(rc))
N_("Configuration error: Failed to get the \"QuietlyIgnoreClientPromisc\" value"));
if (f)
/** @cfgm{IgnoreTrunkWirePromisc, boolean, false}
* When set all request for operating the trunk-wire connection in promiscuous
* mode will be ignored. */
if (RT_FAILURE(rc))
N_("Configuration error: Failed to get the \"IgnoreTrunkWirePromisc\" value"));
if (f)
/** @cfgm{QuietlyIgnoreTrunkWirePromisc, boolean, false}
* When set all request for operating any trunk-wire connection promiscuous mode
* will be ignored. This differs from IgnoreTrunkWirePromisc in that clients
* won't get VERR_INTNET_INCOMPATIBLE_FLAGS. */
if (RT_FAILURE(rc))
N_("Configuration error: Failed to get the \"QuietlyIgnoreTrunkWirePromisc\" value"));
if (f)
/** @cfgm{IgnoreTrunkHostPromisc, boolean, false}
* When set all request for operating the trunk-host connection in promiscuous
* mode will be ignored. */
if (RT_FAILURE(rc))
N_("Configuration error: Failed to get the \"IgnoreTrunkHostPromisc\" value"));
if (f)
/** @cfgm{QuietlyIgnoreTrunkHostPromisc, boolean, false}
* When set all request for operating any trunk-host connection promiscuous mode
* will be ignored. This differs from IgnoreTrunkHostPromisc in that clients
* won't get VERR_INTNET_INCOMPATIBLE_FLAGS. */
if (RT_FAILURE(rc))
N_("Configuration error: Failed to get the \"QuietlyIgnoreTrunkHostPromisc\" value"));
if (f)
/** @todo flags for not sending to the host and for setting the trunk-wire
* connection in promiscuous mode. */
/** @cfgm{SharedMacOnWire, boolean, false}
* Whether to shared the MAC address of the host interface when using the wire. When
* attaching to a wireless NIC this option is usally a requirement.
*/
bool fSharedMacOnWire;
if (RT_FAILURE(rc))
N_("Configuration error: Failed to get the \"SharedMacOnWire\" value"));
if (fSharedMacOnWire)
/** @cfgm{ReceiveBufferSize, uint32_t, 318 KB}
* The size of the receive buffer.
*/
if (rc == VERR_CFGM_VALUE_NOT_FOUND)
else if (RT_FAILURE(rc))
N_("Configuration error: Failed to get the \"ReceiveBufferSize\" value"));
/** @cfgm{SendBufferSize, uint32_t, 196 KB}
* The size of the send (transmit) buffer.
* This should be more than twice the size of the larges frame size because
* the ring buffer is very simple and doesn't support splitting up frames
* nor inserting padding. So, if this is too close to the frame size the
* header will fragment the buffer such that the frame won't fit on either
* side of it and the code will get very upset about it all.
*/
if (rc == VERR_CFGM_VALUE_NOT_FOUND)
else if (RT_FAILURE(rc))
N_("Configuration error: Failed to get the \"SendBufferSize\" value"));
N_("Configuration error: The \"SendBufferSize\" value is too small"));
LogRel(("DrvIntNet: Warning! SendBufferSize=%u, Recommended minimum size %u butes.\n", OpenReq.cbSend, VBOX_MAX_GSO_SIZE * 4));
/** @cfgm{IsService, boolean, true}
* This alterns the way the thread is suspended and resumed. When it's being used by
*/
if (rc == VERR_CFGM_VALUE_NOT_FOUND)
pThis->fActivateEarlyDeactivateLate = false;
else if (RT_FAILURE(rc))
N_("Configuration error: Failed to get the \"IsService\" value"));
LogRel(("IntNet#%u: szNetwork={%s} enmTrunkType=%d szTrunk={%s} fFlags=%#x cbRecv=%u cbSend=%u\n",
#ifdef RT_OS_DARWIN
/* Temporary hack: attach to a network with the name 'if=en0' and you're hitting the wire. */
{
}
/* Temporary hack: attach to a network with the name 'wif=en0' and you're on the air. */
{
}
#endif /* DARWIN */
/*
* Create the event semaphore and S/G cache.
*/
if (RT_FAILURE(rc))
return rc;
rc = RTMemCacheCreate(&pThis->hSgCache, sizeof(PDMSCATTERGATHER), 0, UINT32_MAX, NULL, NULL, pThis, 0);
if (RT_FAILURE(rc))
return rc;
/*
* Create the interface.
*/
if (RT_FAILURE(rc))
/*
* Get default buffer.
*/
rc = PDMDrvHlpSUPCallVMMR0Ex(pDrvIns, VMMR0_DO_INTNET_IF_GET_RING3_BUFFER, &GetRing3BufferReq, sizeof(GetRing3BufferReq));
if (RT_FAILURE(rc))
/*
* Create the async I/O thread.
* Note! Using a PDM thread here doesn't fit with the IsService=true operation.
*/
rc = RTThreadCreate(&pThis->Thread, drvR3IntNetAsyncIoThread, pThis, _128K, RTTHREADTYPE_IO, RTTHREADFLAGS_WAITABLE, "INTNET");
if (RT_FAILURE(rc))
{
return rc;
}
PDMDrvHlpSTAMRegCounter(pDrvIns, &pThis->pBufR3->Recv.cbStatWritten, "Bytes/Received", STAMUNIT_BYTES, "Number of received bytes.");
PDMDrvHlpSTAMRegCounter(pDrvIns, &pThis->pBufR3->Send.cbStatWritten, "Bytes/Sent", STAMUNIT_BYTES, "Number of sent bytes.");
PDMDrvHlpSTAMRegCounter(pDrvIns, &pThis->pBufR3->Recv.cOverflows, "Overflows/Recv", STAMUNIT_COUNT, "Number overflows.");
PDMDrvHlpSTAMRegCounter(pDrvIns, &pThis->pBufR3->Send.cOverflows, "Overflows/Sent", STAMUNIT_COUNT, "Number overflows.");
PDMDrvHlpSTAMRegCounter(pDrvIns, &pThis->pBufR3->Recv.cStatFrames, "Packets/Received", STAMUNIT_COUNT, "Number of received packets.");
PDMDrvHlpSTAMRegCounter(pDrvIns, &pThis->pBufR3->Send.cStatFrames, "Packets/Sent", STAMUNIT_COUNT, "Number of sent packets.");
PDMDrvHlpSTAMRegCounter(pDrvIns, &pThis->StatReceivedGso, "Packets/Received-Gso", STAMUNIT_COUNT, "The GSO portion of the received packets.");
PDMDrvHlpSTAMRegCounter(pDrvIns, &pThis->StatSentGso, "Packets/Sent-Gso", STAMUNIT_COUNT, "The GSO portion of the sent packets.");
PDMDrvHlpSTAMRegCounter(pDrvIns, &pThis->pBufR3->cStatLost, "Packets/Lost", STAMUNIT_COUNT, "Number of lost packets.");
PDMDrvHlpSTAMRegCounter(pDrvIns, &pThis->pBufR3->cStatYieldsNok, "YieldOk", STAMUNIT_COUNT, "Number of times yielding helped fix an overflow.");
PDMDrvHlpSTAMRegCounter(pDrvIns, &pThis->pBufR3->cStatYieldsOk, "YieldNok", STAMUNIT_COUNT, "Number of times yielding didn't help fix an overflow.");
PDMDrvHlpSTAMRegCounter(pDrvIns, &pThis->pBufR3->cStatBadFrames, "BadFrames", STAMUNIT_COUNT, "Number of bad frames seed by the consumers.");
#ifdef VBOX_WITH_STATISTICS
PDMDrvHlpSTAMRegProfileAdv(pDrvIns, &pThis->StatReceive, "Receive", STAMUNIT_TICKS_PER_CALL, "Profiling packet receive runs.");
PDMDrvHlpSTAMRegProfile(pDrvIns, &pThis->StatTransmit, "Transmit", STAMUNIT_TICKS_PER_CALL, "Profiling packet transmit runs.");
#endif
/*
* Activate data transmission as early as possible
*/
{
}
return rc;
}
/**
* Internal networking transport driver registration record.
*/
const PDMDRVREG g_DrvIntNet =
{
/* u32Version */
/* szName */
"IntNet",
/* szRCMod */
"VBoxDD",
/* szR0Mod */
"VBoxDD",
/* pszDescription */
"Internal Networking Transport Driver",
/* fFlags */
#ifdef VBOX_WITH_R0_AND_RC_DRIVERS
#else
#endif
/* fClass. */
/* cMaxInstances */
~0,
/* cbInstance */
sizeof(DRVINTNET),
/* pfnConstruct */
/* pfnDestruct */
/* pfnRelocate */
NULL,
/* pfnIOCtl */
NULL,
/* pfnPowerOn */
/* pfnReset */
NULL,
/* pfnSuspend */
/* pfnResume */
/* pfnAttach */
NULL,
/* pfnDetach */
NULL,
/* pfnPowerOff */
/* pfnSoftReset */
NULL,
/* u32EndVersion */
};
#endif /* IN_RING3 */