VirtualBox

Changeset 25993 in vbox for trunk/src/VBox/Devices


Ignore:
Timestamp:
Jan 25, 2010 11:04:09 AM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
56864
Message:

DrvIntNet.cpp: Preparing for R0/RC.

Location:
trunk/src/VBox/Devices
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Makefile.kmk

    r25946 r25993  
    509509        Network/DevPCNet.cpp \
    510510        Serial/DevSerial.cpp \
    511         Parallel/DevParallel.cpp
     511        Parallel/DevParallel.cpp \
     512        \
     513        Network/DrvIntNet.cpp
    512514
    513515 ifdef VBOX_DYNAMIC_NET_ATTACH
     
    608610        Network/DevPCNet.cpp \
    609611        Serial/DevSerial.cpp \
    610         Parallel/DevParallel.cpp
     612        Parallel/DevParallel.cpp \
     613        \
     614        Network/DrvIntNet.cpp
    611615
    612616ifdef VBOX_DYNAMIC_NET_ATTACH
  • trunk/src/VBox/Devices/Network/DrvIntNet.cpp

    r25985 r25993  
    55
    66/*
    7  * Copyright (C) 2006-2007 Sun Microsystems, Inc.
     7 * Copyright (C) 2006-2010 Sun Microsystems, Inc.
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    6363
    6464/**
    65  * Block driver instance data.
     65 * Internal networking driver instance data.
    6666 *
    6767 * @implements  PDMINETWORKCONNECTOR
     
    7070{
    7171    /** The network interface. */
    72     PDMINETWORKCONNECTOR    INetworkConnector;
     72    PDMINETWORKCONNECTOR            INetworkConnectorR3;
    7373    /** The network interface. */
    74     PPDMINETWORKPORT        pPort;
     74    R3PTRTYPE(PPDMINETWORKPORT)     pIPortR3;
    7575    /** The network config interface.
    7676     * Can (in theory at least) be NULL. */
    77     PPDMINETWORKCONFIG      pConfigIf;
     77    R3PTRTYPE(PPDMINETWORKCONFIG)   pIConfigIfR3;
    7878    /** Pointer to the driver instance. */
    79     PPDMDRVINS              pDrvIns;
     79    PPDMDRVINSR3                    pDrvInsR3;
     80    /** Pointer to the communication buffer. */
     81    R3PTRTYPE(PINTNETBUF)           pBufR3;
    8082    /** Interface handle. */
    81     INTNETIFHANDLE          hIf;
    82     /** Pointer to the communication buffer. */
    83     PINTNETBUF              pBuf;
     83    INTNETIFHANDLE                  hIf;
     84
    8485    /** The thread state. */
    85     ASYNCSTATE volatile     enmState;
     86    ASYNCSTATE volatile             enmState;
    8687    /** Reader thread. */
    87     RTTHREAD                Thread;
     88    RTTHREAD                        Thread;
    8889    /** Event semaphore the Thread waits on while the VM is suspended. */
    89     RTSEMEVENT              EventSuspended;
     90    RTSEMEVENT                      EventSuspended;
    9091    /** Set if the link is down.
    9192     * When the link is down all incoming packets will be dropped. */
    92     bool volatile           fLinkDown;
     93    bool volatile                   fLinkDown;
    9394    /** Set if data transmission should start immediately and deactivate
    9495     * as late as possible. */
    95     bool                    fActivateEarlyDeactivateLate;
     96    bool                            fActivateEarlyDeactivateLate;
     97    /** Padding. */
     98    bool                            afReserved[2];
     99    /** The network name. */
     100    char                            szNetwork[INTNET_MAX_NETWORK_NAME];
    96101
    97102#ifdef LOG_ENABLED
    98103    /** The nano ts of the last transfer. */
    99     uint64_t                u64LastTransferTS;
     104    uint64_t                        u64LastTransferTS;
    100105    /** The nano ts of the last receive. */
    101     uint64_t                u64LastReceiveTS;
     106    uint64_t                        u64LastReceiveTS;
    102107#endif
    103 
    104108#ifdef VBOX_WITH_STATISTICS
    105109    /** Profiling packet transmit runs. */
    106     STAMPROFILE             StatTransmit;
     110    STAMPROFILE                     StatTransmit;
    107111    /** Profiling packet receive runs. */
    108     STAMPROFILEADV          StatReceive;
     112    STAMPROFILEADV                  StatReceive;
    109113#endif /* VBOX_WITH_STATISTICS */
    110 
    111     /** The network name. */
    112     char                    szNetwork[INTNET_MAX_NETWORK_NAME];
    113 } DRVINTNET, *PDRVINTNET;
    114 
    115 
    116 /** Converts a pointer to DRVINTNET::INetworkConnector to a PDRVINTNET. */
    117 #define PDMINETWORKCONNECTOR_2_DRVINTNET(pInterface) ( (PDRVINTNET)((uintptr_t)pInterface - RT_OFFSETOF(DRVINTNET, INetworkConnector)) )
    118 
     114} DRVINTNET;
     115/** Pointer to instance data of the internal networking driver. */
     116typedef DRVINTNET *PDRVINTNET;
     117
     118
     119#ifdef IN_RING3
     120
     121/* -=-=-=-=- PDMINETWORKCONNECTOR -=-=-=-=- */
     122
     123/** Converts a pointer to DRVINTNET::INetworkConnectorR3 to a PDRVINTNET. */
     124#define PDMINETWORKCONNECTOR_2_DRVINTNET(pInterface) \
     125    RT_FROM_MEMBER(pInterface, DRVINTNET, INetworkConnectorR3)
    119126
    120127/**
     
    124131 * @param   pThis       The driver instance.
    125132 */
    126 static int drvIntNetUpdateMacAddress(PDRVINTNET pThis)
    127 {
    128     if (!pThis->pConfigIf)
     133static int drvR3IntNetUpdateMacAddress(PDRVINTNET pThis)
     134{
     135    if (!pThis->pIConfigIfR3)
    129136        return VINF_SUCCESS;
    130137
     
    134141    SetMacAddressReq.pSession = NIL_RTR0PTR;
    135142    SetMacAddressReq.hIf = pThis->hIf;
    136     int rc = pThis->pConfigIf->pfnGetMac(pThis->pConfigIf, &SetMacAddressReq.Mac);
     143    int rc = pThis->pIConfigIfR3->pfnGetMac(pThis->pIConfigIfR3, &SetMacAddressReq.Mac);
    137144    if (RT_SUCCESS(rc))
    138         rc = PDMDrvHlpSUPCallVMMR0Ex(pThis->pDrvIns, VMMR0_DO_INTNET_IF_SET_MAC_ADDRESS,
     145        rc = PDMDrvHlpSUPCallVMMR0Ex(pThis->pDrvInsR3, VMMR0_DO_INTNET_IF_SET_MAC_ADDRESS,
    139146                                     &SetMacAddressReq, sizeof(SetMacAddressReq));
    140147
    141     Log(("drvIntNetUpdateMacAddress: %.*Rhxs rc=%Rrc\n", sizeof(SetMacAddressReq.Mac), &SetMacAddressReq.Mac, rc));
     148    Log(("drvR3IntNetUpdateMacAddress: %.*Rhxs rc=%Rrc\n", sizeof(SetMacAddressReq.Mac), &SetMacAddressReq.Mac, rc));
    142149    return rc;
    143150}
     
    153160 * @param   fActive     The new state.
    154161 */
    155 static int drvIntNetSetActive(PDRVINTNET pThis, bool fActive)
    156 {
    157     if (!pThis->pConfigIf)
     162static int drvR3IntNetSetActive(PDRVINTNET pThis, bool fActive)
     163{
     164    if (!pThis->pIConfigIfR3)
    158165        return VINF_SUCCESS;
    159166
     
    164171    SetActiveReq.hIf = pThis->hIf;
    165172    SetActiveReq.fActive = fActive;
    166     int rc = PDMDrvHlpSUPCallVMMR0Ex(pThis->pDrvIns, VMMR0_DO_INTNET_IF_SET_ACTIVE,
     173    int rc = PDMDrvHlpSUPCallVMMR0Ex(pThis->pDrvInsR3, VMMR0_DO_INTNET_IF_SET_ACTIVE,
    167174                                     &SetActiveReq, sizeof(SetActiveReq));
    168175
    169     Log(("drvIntNetUpdateMacAddress: fActive=%d rc=%Rrc\n", fActive, rc));
     176    Log(("drvR3IntNetSetActive: fActive=%d rc=%Rrc\n", fActive, rc));
    170177    AssertRC(rc);
    171178    return rc;
     
    183190 * @remark  This is the same as INTNETRingWriteFrame
    184191 */
    185 static int drvIntNetRingWriteFrame(PINTNETBUF pBuf, PINTNETRINGBUF pRingBuf, const void *pvFrame, uint32_t cbFrame)
     192static int drvR3IntNetRingWriteFrame(PINTNETBUF pBuf, PINTNETRINGBUF pRingBuf, const void *pvFrame, uint32_t cbFrame)
    186193{
    187194    /*
     
    275282 * @thread  EMT
    276283 */
    277 static DECLCALLBACK(int) drvIntNetSend(PPDMINETWORKCONNECTOR pInterface, const void *pvBuf, size_t cb)
     284static DECLCALLBACK(int) drvR3IntNetSend(PPDMINETWORKCONNECTOR pInterface, const void *pvBuf, size_t cb)
    278285{
    279286    PDRVINTNET pThis = PDMINETWORKCONNECTOR_2_DRVINTNET(pInterface);
     
    282289#ifdef LOG_ENABLED
    283290    uint64_t u64Now = RTTimeProgramNanoTS();
    284     LogFlow(("drvIntNetSend: %-4d bytes at %llu ns  deltas: r=%llu t=%llu\n",
     291    LogFlow(("drvR3IntNetSend: %-4d bytes at %llu ns  deltas: r=%llu t=%llu\n",
    285292             cb, u64Now, u64Now - pThis->u64LastReceiveTS, u64Now - pThis->u64LastTransferTS));
    286293    pThis->u64LastTransferTS = u64Now;
    287     Log2(("drvIntNetSend: pvBuf=%p cb=%#x\n"
     294    Log2(("drvR3IntNetSend: pvBuf=%p cb=%#x\n"
    288295          "%.*Rhxd\n",
    289296          pvBuf, cb, cb, pvBuf));
     
    293300     * Add the frame to the send buffer and push it onto the network.
    294301     */
    295     int rc = drvIntNetRingWriteFrame(pThis->pBuf, &pThis->pBuf->Send, pvBuf, (uint32_t)cb);
     302    int rc = drvR3IntNetRingWriteFrame(pThis->pBufR3, &pThis->pBufR3->Send, pvBuf, (uint32_t)cb);
    296303    if (    rc == VERR_BUFFER_OVERFLOW
    297         &&  pThis->pBuf->cbSend < cb)
     304        &&  pThis->pBufR3->cbSend < cb)
    298305    {
    299306        INTNETIFSENDREQ SendReq;
     
    302309        SendReq.pSession = NIL_RTR0PTR;
    303310        SendReq.hIf = pThis->hIf;
    304         PDMDrvHlpSUPCallVMMR0Ex(pThis->pDrvIns, VMMR0_DO_INTNET_IF_SEND, &SendReq, sizeof(SendReq));
    305 
    306         rc = drvIntNetRingWriteFrame(pThis->pBuf, &pThis->pBuf->Send, pvBuf, (uint32_t)cb);
     311        PDMDrvHlpSUPCallVMMR0Ex(pThis->pDrvInsR3, VMMR0_DO_INTNET_IF_SEND, &SendReq, sizeof(SendReq));
     312
     313        rc = drvR3IntNetRingWriteFrame(pThis->pBufR3, &pThis->pBufR3->Send, pvBuf, (uint32_t)cb);
    307314    }
    308315
     
    314321        SendReq.pSession = NIL_RTR0PTR;
    315322        SendReq.hIf = pThis->hIf;
    316         rc = PDMDrvHlpSUPCallVMMR0Ex(pThis->pDrvIns, VMMR0_DO_INTNET_IF_SEND, &SendReq, sizeof(SendReq));
     323        rc = PDMDrvHlpSUPCallVMMR0Ex(pThis->pDrvInsR3, VMMR0_DO_INTNET_IF_SEND, &SendReq, sizeof(SendReq));
    317324    }
    318325
     
    333340 * @thread  EMT
    334341 */
    335 static DECLCALLBACK(void) drvIntNetSetPromiscuousMode(PPDMINETWORKCONNECTOR pInterface, bool fPromiscuous)
     342static DECLCALLBACK(void) drvR3IntNetSetPromiscuousMode(PPDMINETWORKCONNECTOR pInterface, bool fPromiscuous)
    336343{
    337344    PDRVINTNET pThis = PDMINETWORKCONNECTOR_2_DRVINTNET(pInterface);
     
    342349    Req.hIf             = pThis->hIf;
    343350    Req.fPromiscuous    = fPromiscuous;
    344     int rc = PDMDrvHlpSUPCallVMMR0Ex(pThis->pDrvIns, VMMR0_DO_INTNET_IF_SET_PROMISCUOUS_MODE, &Req, sizeof(Req));
    345     LogFlow(("drvIntNetSetPromiscuousMode: fPromiscuous=%RTbool\n", fPromiscuous));
     351    int rc = PDMDrvHlpSUPCallVMMR0Ex(pThis->pDrvInsR3, VMMR0_DO_INTNET_IF_SET_PROMISCUOUS_MODE, &Req, sizeof(Req));
     352    LogFlow(("drvR3IntNetSetPromiscuousMode: fPromiscuous=%RTbool\n", fPromiscuous));
    346353    AssertRC(rc);
    347354}
     
    355362 * @thread  EMT
    356363 */
    357 static DECLCALLBACK(void) drvIntNetNotifyLinkChanged(PPDMINETWORKCONNECTOR pInterface, PDMNETWORKLINKSTATE enmLinkState)
     364static DECLCALLBACK(void) drvR3IntNetNotifyLinkChanged(PPDMINETWORKCONNECTOR pInterface, PDMNETWORKLINKSTATE enmLinkState)
    358365{
    359366    PDRVINTNET pThis = PDMINETWORKCONNECTOR_2_DRVINTNET(pInterface);
     
    371378            break;
    372379    }
    373     LogFlow(("drvIntNetNotifyLinkChanged: enmLinkState=%d %d->%d\n", enmLinkState, pThis->fLinkDown, fLinkDown));
     380    LogFlow(("drvR3IntNetNotifyLinkChanged: enmLinkState=%d %d->%d\n", enmLinkState, pThis->fLinkDown, fLinkDown));
    374381    ASMAtomicXchgSize(&pThis->fLinkDown, fLinkDown);
    375382}
     
    384391 * @param   pThis       Pointer to the instance data.
    385392 */
    386 static int drvIntNetAsyncIoWaitForSpace(PDRVINTNET pThis)
    387 {
    388     LogFlow(("drvIntNetAsyncIoWaitForSpace:\n"));
     393static int drvR3IntNetAsyncIoWaitForSpace(PDRVINTNET pThis)
     394{
     395    LogFlow(("drvR3IntNetAsyncIoWaitForSpace:\n"));
    389396    STAM_PROFILE_ADV_STOP(&pThis->StatReceive, a);
    390     int rc = pThis->pPort->pfnWaitReceiveAvail(pThis->pPort, RT_INDEFINITE_WAIT);
     397    int rc = pThis->pIPortR3->pfnWaitReceiveAvail(pThis->pIPortR3, RT_INDEFINITE_WAIT);
    391398    STAM_PROFILE_ADV_START(&pThis->StatReceive, a);
    392     LogFlow(("drvIntNetAsyncIoWaitForSpace: returns %Rrc\n", rc));
     399    LogFlow(("drvR3IntNetAsyncIoWaitForSpace: returns %Rrc\n", rc));
    393400    return rc;
    394401}
     
    402409 * @param   pThis       The driver instance data.
    403410 */
    404 static int drvIntNetAsyncIoRun(PDRVINTNET pThis)
    405 {
    406     PPDMDRVINS pDrvIns = pThis->pDrvIns;
    407     LogFlow(("drvIntNetAsyncIoRun: pThis=%p\n", pThis));
     411static int drvR3IntNetAsyncIoRun(PDRVINTNET pThis)
     412{
     413    PPDMDRVINS pDrvIns = pThis->pDrvInsR3;
     414    LogFlow(("drvR3IntNetAsyncIoRun: pThis=%p\n", pThis));
    408415
    409416    /*
     
    411418     */
    412419    STAM_PROFILE_ADV_START(&pThis->StatReceive, a);
    413     PINTNETBUF      pBuf     = pThis->pBuf;
    414     PINTNETRINGBUF  pRingBuf = &pThis->pBuf->Recv;
     420    PINTNETBUF      pBuf     = pThis->pBufR3;
     421    PINTNETRINGBUF  pRingBuf = &pBuf->Recv;
    415422    for (;;)
    416423    {
     
    426433            {
    427434                STAM_PROFILE_ADV_STOP(&pThis->StatReceive, a);
    428                 LogFlow(("drvIntNetAsyncIoRun: returns VERR_STATE_CHANGED (state changed - #0)\n"));
     435                LogFlow(("drvR3IntNetAsyncIoRun: returns VERR_STATE_CHANGED (state changed - #0)\n"));
    429436                return VERR_STATE_CHANGED;
    430437            }
     
    439446                 */
    440447                size_t cbFrame = pHdr->cbFrame;
    441                 int rc = pThis->pPort->pfnWaitReceiveAvail(pThis->pPort, 0);
     448                int rc = pThis->pIPortR3->pfnWaitReceiveAvail(pThis->pIPortR3, 0);
    442449                if (rc == VINF_SUCCESS)
    443450                {
    444451#ifdef LOG_ENABLED
    445452                    uint64_t u64Now = RTTimeProgramNanoTS();
    446                     LogFlow(("drvIntNetAsyncIoRun: %-4d bytes at %llu ns  deltas: r=%llu t=%llu\n",
     453                    LogFlow(("drvR3IntNetAsyncIoRun: %-4d bytes at %llu ns  deltas: r=%llu t=%llu\n",
    447454                             cbFrame, u64Now, u64Now - pThis->u64LastReceiveTS, u64Now - pThis->u64LastTransferTS));
    448455                    pThis->u64LastReceiveTS = u64Now;
    449                     Log2(("drvIntNetAsyncIoRun: cbFrame=%#x\n"
     456                    Log2(("drvR3IntNetAsyncIoRun: cbFrame=%#x\n"
    450457                          "%.*Rhxd\n",
    451458                          cbFrame, cbFrame, INTNETHdrGetFramePtr(pHdr, pBuf)));
    452459#endif
    453                     rc = pThis->pPort->pfnReceive(pThis->pPort, INTNETHdrGetFramePtr(pHdr, pBuf), cbFrame);
     460                    rc = pThis->pIPortR3->pfnReceive(pThis->pIPortR3, INTNETHdrGetFramePtr(pHdr, pBuf), cbFrame);
    454461                    AssertRC(rc);
    455462
     
    462469                     * Wait for sufficient space to become available and then retry.
    463470                     */
    464                     rc = drvIntNetAsyncIoWaitForSpace(pThis);
     471                    rc = drvR3IntNetAsyncIoWaitForSpace(pThis);
    465472                    if (RT_FAILURE(rc))
    466473                    {
     
    477484                        {
    478485                            STAM_PROFILE_ADV_STOP(&pThis->StatReceive, a);
    479                             LogFlow(("drvIntNetAsyncIoRun: returns %Rrc (wait-for-space)\n", rc));
     486                            LogFlow(("drvR3IntNetAsyncIoRun: returns %Rrc (wait-for-space)\n", rc));
    480487                            return rc;
    481488                        }
     
    500507        {
    501508            STAM_PROFILE_ADV_STOP(&pThis->StatReceive, a);
    502             LogFlow(("drvIntNetAsyncIoRun: returns VINF_SUCCESS (state changed - #1)\n"));
     509            LogFlow(("drvR3IntNetAsyncIoRun: returns VINF_SUCCESS (state changed - #1)\n"));
    503510            return VERR_STATE_CHANGED;
    504511        }
     
    515522            &&  rc != VERR_INTERRUPTED)
    516523        {
    517             LogFlow(("drvIntNetAsyncIoRun: returns %Rrc\n", rc));
     524            LogFlow(("drvR3IntNetAsyncIoRun: returns %Rrc\n", rc));
    518525            return rc;
    519526        }
     
    530537 * @param   pvUser          Pointer to a DRVINTNET structure.
    531538 */
    532 static DECLCALLBACK(int) drvIntNetAsyncIoThread(RTTHREAD ThreadSelf, void *pvUser)
     539static DECLCALLBACK(int) drvR3IntNetAsyncIoThread(RTTHREAD ThreadSelf, void *pvUser)
    533540{
    534541    PDRVINTNET pThis = (PDRVINTNET)pvUser;
    535     LogFlow(("drvIntNetAsyncIoThread: pThis=%p\n", pThis));
     542    LogFlow(("drvR3IntNetAsyncIoThread: pThis=%p\n", pThis));
    536543    STAM_PROFILE_ADV_START(&pThis->StatReceive, a);
    537544
     
    550557                    &&  rc != VERR_TIMEOUT)
    551558                {
    552                     LogFlow(("drvIntNetAsyncIoThread: returns %Rrc\n", rc));
     559                    LogFlow(("drvR3IntNetAsyncIoThread: returns %Rrc\n", rc));
    553560                    return rc;
    554561                }
     
    558565            case ASYNCSTATE_RUNNING:
    559566            {
    560                 int rc = drvIntNetAsyncIoRun(pThis);
     567                int rc = drvR3IntNetAsyncIoRun(pThis);
    561568                if (    rc != VERR_STATE_CHANGED
    562569                    &&  RT_FAILURE(rc))
    563570                {
    564                     LogFlow(("drvIntNetAsyncIoThread: returns %Rrc\n", rc));
     571                    LogFlow(("drvR3IntNetAsyncIoThread: returns %Rrc\n", rc));
    565572                    return rc;
    566573                }
     
    571578                AssertMsgFailed(("Invalid state %d\n", enmState));
    572579            case ASYNCSTATE_TERMINATE:
    573                 LogFlow(("drvIntNetAsyncIoThread: returns VINF_SUCCESS\n"));
     580                LogFlow(("drvR3IntNetAsyncIoThread: returns VINF_SUCCESS\n"));
    574581                return VINF_SUCCESS;
    575582        }
     
    577584}
    578585
     586/* -=-=-=-=- PDMINETWORKCONNECTOR -=-=-=-=- */
    579587
    580588/**
    581589 * @interface_method_impl{PDMIBASE,pfnQueryInterface}
    582590 */
    583 static DECLCALLBACK(void *) drvIntNetQueryInterface(PPDMIBASE pInterface, const char *pszIID)
     591static DECLCALLBACK(void *) drvR3IntNetQueryInterface(PPDMIBASE pInterface, const char *pszIID)
    584592{
    585593    PPDMDRVINS pDrvIns = PDMIBASE_2_PDMDRV(pInterface);
     
    587595
    588596    PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pDrvIns->IBase);
    589     PDMIBASE_RETURN_INTERFACE(pszIID, PDMINETWORKCONNECTOR, &pThis->INetworkConnector);
     597    PDMIBASE_RETURN_INTERFACE(pszIID, PDMINETWORKCONNECTOR, &pThis->INetworkConnectorR3);
    590598    return NULL;
    591599}
    592600
     601/* -=-=-=-=- PDMDRVREG -=-=-=-=- */
    593602
    594603/**
     
    597606 * @param   pDrvIns     The driver instance.
    598607 */
    599 static DECLCALLBACK(void) drvIntNetPowerOff(PPDMDRVINS pDrvIns)
    600 {
    601     LogFlow(("drvIntNetPowerOff\n"));
     608static DECLCALLBACK(void) drvR3IntNetPowerOff(PPDMDRVINS pDrvIns)
     609{
     610    LogFlow(("drvR3IntNetPowerOff\n"));
    602611    PDRVINTNET pThis = PDMINS_2_DATA(pDrvIns, PDRVINTNET);
    603612    if (!pThis->fActivateEarlyDeactivateLate)
    604613    {
    605614        ASMAtomicXchgSize(&pThis->enmState, ASYNCSTATE_SUSPENDED);
    606         drvIntNetSetActive(pThis, false /* fActive */);
     615        drvR3IntNetSetActive(pThis, false /* fActive */);
    607616    }
    608617}
     
    614623 * @param   pDrvIns     The driver instance.
    615624 */
    616 static DECLCALLBACK(void) drvIntNetResume(PPDMDRVINS pDrvIns)
    617 {
    618     LogFlow(("drvIntNetPowerResume\n"));
     625static DECLCALLBACK(void) drvR3IntNetResume(PPDMDRVINS pDrvIns)
     626{
     627    LogFlow(("drvR3IntNetPowerResume\n"));
    619628    PDRVINTNET pThis = PDMINS_2_DATA(pDrvIns, PDRVINTNET);
    620629    if (!pThis->fActivateEarlyDeactivateLate)
     
    622631        ASMAtomicXchgSize(&pThis->enmState, ASYNCSTATE_RUNNING);
    623632        RTSemEventSignal(pThis->EventSuspended);
    624         drvIntNetUpdateMacAddress(pThis); /* (could be a state restore) */
    625         drvIntNetSetActive(pThis, true /* fActive */);
     633        drvR3IntNetUpdateMacAddress(pThis); /* (could be a state restore) */
     634        drvR3IntNetSetActive(pThis, true /* fActive */);
    626635    }
    627636    if (   PDMDrvHlpVMTeleportedAndNotFullyResumedYet(pDrvIns)
    628         && pThis->pConfigIf)
     637        && pThis->pIConfigIfR3)
    629638    {
    630639        /*
     
    645654        Frame.Hdr.DstMac.au16[2] = 0xffff;
    646655        Frame.Hdr.EtherType      = RT_H2BE_U16(0x801e);
    647         int rc = pThis->pConfigIf->pfnGetMac(pThis->pConfigIf, &Frame.Hdr.SrcMac);
     656        int rc = pThis->pIConfigIfR3->pfnGetMac(pThis->pIConfigIfR3, &Frame.Hdr.SrcMac);
    648657        if (RT_SUCCESS(rc))
    649             rc = drvIntNetSend(&pThis->INetworkConnector, &Frame, sizeof(Frame));
     658            rc = drvR3IntNetSend(&pThis->INetworkConnectorR3, &Frame, sizeof(Frame));
    650659        if (RT_FAILURE(rc))
    651660            LogRel(("IntNet#%u: Sending dummy frame failed: %Rrc\n", pDrvIns->iInstance, rc));
     
    659668 * @param   pDrvIns     The driver instance.
    660669 */
    661 static DECLCALLBACK(void) drvIntNetSuspend(PPDMDRVINS pDrvIns)
    662 {
    663     LogFlow(("drvIntNetPowerSuspend\n"));
     670static DECLCALLBACK(void) drvR3IntNetSuspend(PPDMDRVINS pDrvIns)
     671{
     672    LogFlow(("drvR3IntNetPowerSuspend\n"));
    664673    PDRVINTNET pThis = PDMINS_2_DATA(pDrvIns, PDRVINTNET);
    665674    if (!pThis->fActivateEarlyDeactivateLate)
    666675    {
    667676        ASMAtomicXchgSize(&pThis->enmState, ASYNCSTATE_SUSPENDED);
    668         drvIntNetSetActive(pThis, false /* fActive */);
     677        drvR3IntNetSetActive(pThis, false /* fActive */);
    669678    }
    670679}
     
    676685 * @param   pDrvIns     The driver instance.
    677686 */
    678 static DECLCALLBACK(void) drvIntNetPowerOn(PPDMDRVINS pDrvIns)
    679 {
    680     LogFlow(("drvIntNetPowerOn\n"));
     687static DECLCALLBACK(void) drvR3IntNetPowerOn(PPDMDRVINS pDrvIns)
     688{
     689    LogFlow(("drvR3IntNetPowerOn\n"));
    681690    PDRVINTNET pThis = PDMINS_2_DATA(pDrvIns, PDRVINTNET);
    682691    if (!pThis->fActivateEarlyDeactivateLate)
     
    684693        ASMAtomicXchgSize(&pThis->enmState, ASYNCSTATE_RUNNING);
    685694        RTSemEventSignal(pThis->EventSuspended);
    686         drvIntNetUpdateMacAddress(pThis);
    687         drvIntNetSetActive(pThis, true /* fActive */);
     695        drvR3IntNetUpdateMacAddress(pThis);
     696        drvR3IntNetSetActive(pThis, true /* fActive */);
    688697    }
    689698}
     
    698707 * @param   pDrvIns     The driver instance data.
    699708 */
    700 static DECLCALLBACK(void) drvIntNetDestruct(PPDMDRVINS pDrvIns)
    701 {
    702     LogFlow(("drvIntNetDestruct\n"));
     709static DECLCALLBACK(void) drvR3IntNetDestruct(PPDMDRVINS pDrvIns)
     710{
     711    LogFlow(("drvR3IntNetDestruct\n"));
    703712    PDRVINTNET pThis = PDMINS_2_DATA(pDrvIns, PDRVINTNET);
    704713
     
    747756     * Deregister statistics in case we're being detached.
    748757     */
    749     PDMDrvHlpSTAMDeregister(pDrvIns, &pThis->pBuf->cbStatRecv);
    750     PDMDrvHlpSTAMDeregister(pDrvIns, &pThis->pBuf->cbStatSend);
    751     PDMDrvHlpSTAMDeregister(pDrvIns, &pThis->pBuf->cStatRecvs);
    752     PDMDrvHlpSTAMDeregister(pDrvIns, &pThis->pBuf->cStatSends);
    753     PDMDrvHlpSTAMDeregister(pDrvIns, &pThis->pBuf->cStatLost);
    754     PDMDrvHlpSTAMDeregister(pDrvIns, &pThis->pBuf->cStatYieldsNok);
     758    PDMDrvHlpSTAMDeregister(pDrvIns, &pThis->pBufR3->cbStatRecv);
     759    PDMDrvHlpSTAMDeregister(pDrvIns, &pThis->pBufR3->cbStatSend);
     760    PDMDrvHlpSTAMDeregister(pDrvIns, &pThis->pBufR3->cStatRecvs);
     761    PDMDrvHlpSTAMDeregister(pDrvIns, &pThis->pBufR3->cStatSends);
     762    PDMDrvHlpSTAMDeregister(pDrvIns, &pThis->pBufR3->cStatLost);
     763    PDMDrvHlpSTAMDeregister(pDrvIns, &pThis->pBufR3->cStatYieldsNok);
    755764#ifdef VBOX_WITH_STATISTICS
    756765    PDMDrvHlpSTAMDeregister(pDrvIns, &pThis->StatReceive);
     
    765774 * @copydoc FNPDMDRVCONSTRUCT
    766775 */
    767 static DECLCALLBACK(int) drvIntNetConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfgHandle, uint32_t fFlags)
     776static DECLCALLBACK(int) drvR3IntNetConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfgHandle, uint32_t fFlags)
    768777{
    769778    PDRVINTNET pThis = PDMINS_2_DATA(pDrvIns, PDRVINTNET);
     
    773782     * Init the static parts.
    774783     */
    775     pThis->pDrvIns                      = pDrvIns;
    776     pThis->hIf                          = INTNET_HANDLE_INVALID;
    777     pThis->Thread                       = NIL_RTTHREAD;
    778     pThis->EventSuspended               = NIL_RTSEMEVENT;
    779     pThis->enmState                     = ASYNCSTATE_SUSPENDED;
    780     pThis->fActivateEarlyDeactivateLate = false;
     784    pThis->pDrvInsR3                                = pDrvIns;
     785    pThis->hIf                                      = INTNET_HANDLE_INVALID;
     786    pThis->Thread                                   = NIL_RTTHREAD;
     787    pThis->EventSuspended                           = NIL_RTSEMEVENT;
     788    pThis->enmState                                 = ASYNCSTATE_SUSPENDED;
     789    pThis->fActivateEarlyDeactivateLate             = false;
    781790    /* IBase */
    782     pDrvIns->IBase.pfnQueryInterface    = drvIntNetQueryInterface;
     791    pDrvIns->IBase.pfnQueryInterface                = drvR3IntNetQueryInterface;
    783792    /* INetwork */
    784     pThis->INetworkConnector.pfnSend                = drvIntNetSend;
    785     pThis->INetworkConnector.pfnSetPromiscuousMode  = drvIntNetSetPromiscuousMode;
    786     pThis->INetworkConnector.pfnNotifyLinkChanged   = drvIntNetNotifyLinkChanged;
     793    pThis->INetworkConnectorR3.pfnSend              = drvR3IntNetSend;
     794    pThis->INetworkConnectorR3.pfnSetPromiscuousMode= drvR3IntNetSetPromiscuousMode;
     795    pThis->INetworkConnectorR3.pfnNotifyLinkChanged = drvR3IntNetNotifyLinkChanged;
    787796
    788797    /*
     
    818827     * Query the network port interface.
    819828     */
    820     pThis->pPort = PDMIBASE_QUERY_INTERFACE(pDrvIns->pUpBase, PDMINETWORKPORT);
    821     if (!pThis->pPort)
     829    pThis->pIPortR3 = PDMIBASE_QUERY_INTERFACE(pDrvIns->pUpBase, PDMINETWORKPORT);
     830    if (!pThis->pIPortR3)
    822831    {
    823832        AssertMsgFailed(("Configuration error: the above device/driver didn't export the network port interface!\n"));
    824833        return VERR_PDM_MISSING_INTERFACE_ABOVE;
    825834    }
    826     pThis->pConfigIf = PDMIBASE_QUERY_INTERFACE(pDrvIns->pUpBase, PDMINETWORKCONFIG);
     835    pThis->pIConfigIfR3 = PDMIBASE_QUERY_INTERFACE(pDrvIns->pUpBase, PDMINETWORKCONFIG);
    827836
    828837    /*
     
    10811090                                   N_("Failed to get ring-3 buffer for the newly created interface to '%s'"), pThis->szNetwork);
    10821091    AssertRelease(VALID_PTR(GetRing3BufferReq.pRing3Buf));
    1083     pThis->pBuf = GetRing3BufferReq.pRing3Buf;
     1092    pThis->pBufR3 = GetRing3BufferReq.pRing3Buf;
    10841093
    10851094    /*
     
    10871096     * Note! Using a PDM thread here doesn't fit with the IsService=true operation.
    10881097     */
    1089     rc = RTThreadCreate(&pThis->Thread, drvIntNetAsyncIoThread, pThis, _128K, RTTHREADTYPE_IO, RTTHREADFLAGS_WAITABLE, "INTNET");
     1098    rc = RTThreadCreate(&pThis->Thread, drvR3IntNetAsyncIoThread, pThis, _128K, RTTHREADTYPE_IO, RTTHREADFLAGS_WAITABLE, "INTNET");
    10901099    if (RT_FAILURE(rc))
    10911100    {
     
    10941103    }
    10951104
    1096     PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->pBuf->cbStatRecv,       STAMTYPE_COUNTER,   STAMVISIBILITY_ALWAYS,  STAMUNIT_BYTES, "Number of received bytes.",    "/Net/IntNet%d/Bytes/Received", pDrvIns->iInstance);
    1097     PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->pBuf->cbStatSend,       STAMTYPE_COUNTER,   STAMVISIBILITY_ALWAYS,  STAMUNIT_BYTES, "Number of sent bytes.",        "/Net/IntNet%d/Bytes/Sent", pDrvIns->iInstance);
    1098     PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->pBuf->cStatRecvs,       STAMTYPE_COUNTER,   STAMVISIBILITY_ALWAYS,  STAMUNIT_COUNT, "Number of received packets.",  "/Net/IntNet%d/Packets/Received", pDrvIns->iInstance);
    1099     PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->pBuf->cStatSends,       STAMTYPE_COUNTER,   STAMVISIBILITY_ALWAYS,  STAMUNIT_COUNT, "Number of sent packets.",      "/Net/IntNet%d/Packets/Sent", pDrvIns->iInstance);
    1100     PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->pBuf->cStatLost,        STAMTYPE_COUNTER,   STAMVISIBILITY_ALWAYS,  STAMUNIT_COUNT, "Number of sent packets.",      "/Net/IntNet%d/Packets/Lost", pDrvIns->iInstance);
    1101     PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->pBuf->cStatYieldsNok,  STAMTYPE_COUNTER,   STAMVISIBILITY_ALWAYS,  STAMUNIT_COUNT, "Number of times yielding didn't help fix an overflow.",  "/Net/IntNet%d/YieldNok", pDrvIns->iInstance);
     1105    PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->pBufR3->cbStatRecv,     STAMTYPE_COUNTER,   STAMVISIBILITY_ALWAYS,  STAMUNIT_BYTES, "Number of received bytes.",    "/Net/IntNet%d/Bytes/Received", pDrvIns->iInstance);
     1106    PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->pBufR3->cbStatSend,     STAMTYPE_COUNTER,   STAMVISIBILITY_ALWAYS,  STAMUNIT_BYTES, "Number of sent bytes.",        "/Net/IntNet%d/Bytes/Sent", pDrvIns->iInstance);
     1107    PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->pBufR3->cStatRecvs,     STAMTYPE_COUNTER,   STAMVISIBILITY_ALWAYS,  STAMUNIT_COUNT, "Number of received packets.",  "/Net/IntNet%d/Packets/Received", pDrvIns->iInstance);
     1108    PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->pBufR3->cStatSends,     STAMTYPE_COUNTER,   STAMVISIBILITY_ALWAYS,  STAMUNIT_COUNT, "Number of sent packets.",      "/Net/IntNet%d/Packets/Sent", pDrvIns->iInstance);
     1109    PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->pBufR3->cStatLost,      STAMTYPE_COUNTER,   STAMVISIBILITY_ALWAYS,  STAMUNIT_COUNT, "Number of sent packets.",      "/Net/IntNet%d/Packets/Lost", pDrvIns->iInstance);
     1110    PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->pBufR3->cStatYieldsNok, STAMTYPE_COUNTER,   STAMVISIBILITY_ALWAYS,  STAMUNIT_COUNT, "Number of times yielding didn't help fix an overflow.",  "/Net/IntNet%d/YieldNok", pDrvIns->iInstance);
    11021111#ifdef VBOX_WITH_STATISTICS
    11031112    PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->StatReceive,            STAMTYPE_PROFILE,   STAMVISIBILITY_ALWAYS,  STAMUNIT_TICKS_PER_CALL, "Profiling packet receive runs.",  "/Net/IntNet%d/Receive", pDrvIns->iInstance);
     
    11121121        ASMAtomicXchgSize(&pThis->enmState, ASYNCSTATE_RUNNING);
    11131122        RTSemEventSignal(pThis->EventSuspended);
    1114         drvIntNetUpdateMacAddress(pThis);
    1115         drvIntNetSetActive(pThis, true /* fActive */);
     1123        drvR3IntNetUpdateMacAddress(pThis);
     1124        drvR3IntNetSetActive(pThis, true /* fActive */);
    11161125    }
    11171126
     
    11301139    "IntNet",
    11311140    /* szRCMod */
    1132     "",
     1141    "VBoxDD",
    11331142    /* szR0Mod */
    1134     "",
     1143    "VBoxDD",
    11351144    /* pszDescription */
    11361145    "Internal Networking Transport Driver",
    11371146    /* fFlags */
     1147#ifdef VBOX_WITH_R0_AND_RC_DRIVERS
     1148    PDM_DRVREG_FLAGS_HOST_BITS_DEFAULT | PDM_DRVREG_FLAGS_R0 | PDM_DRVREG_FLAGS_RC,
     1149#else
    11381150    PDM_DRVREG_FLAGS_HOST_BITS_DEFAULT,
     1151#endif
    11391152    /* fClass. */
    11401153    PDM_DRVREG_CLASS_NETWORK,
     
    11441157    sizeof(DRVINTNET),
    11451158    /* pfnConstruct */
    1146     drvIntNetConstruct,
     1159    drvR3IntNetConstruct,
    11471160    /* pfnDestruct */
    1148     drvIntNetDestruct,
     1161    drvR3IntNetDestruct,
    11491162    /* pfnRelocate */
    11501163    NULL,
     
    11521165    NULL,
    11531166    /* pfnPowerOn */
    1154     drvIntNetPowerOn,
     1167    drvR3IntNetPowerOn,
    11551168    /* pfnReset */
    11561169    NULL,
    11571170    /* pfnSuspend */
    1158     drvIntNetSuspend,
     1171    drvR3IntNetSuspend,
    11591172    /* pfnResume */
    1160     drvIntNetResume,
     1173    drvR3IntNetResume,
    11611174    /* pfnAttach */
    11621175    NULL,
     
    11641177    NULL,
    11651178    /* pfnPowerOff */
    1166     drvIntNetPowerOff,
     1179    drvR3IntNetPowerOff,
    11671180    /* pfnSoftReset */
    11681181    NULL,
     
    11711184};
    11721185
     1186#endif /* IN_RING3 */
     1187
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette