VirtualBox

Changeset 81708 in vbox


Ignore:
Timestamp:
Nov 6, 2019 2:25:11 PM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
134470
Message:

DevVirtioNet: Replaced the CanRxQueue and hEventMoreRxDescAvail semaphore with a SUPSEMEVENT semaphore. bugref:9218

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Network/DevVirtioNet.cpp

    r81703 r81708  
    131131    R3PTRTYPE(PPDMINETWORKUP) pDrv;    /**< Connector of attached network driver. */
    132132
    133     R3PTRTYPE(PPDMQUEUE)    pCanRxQueueR3;           /**< Rx wakeup signaller - R3. */
    134     R0PTRTYPE(PPDMQUEUE)    pCanRxQueueR0;           /**< Rx wakeup signaller - R0. */
    135     RCPTRTYPE(PPDMQUEUE)    pCanRxQueueRC;           /**< Rx wakeup signaller - RC. */
    136 # if HC_ARCH_BITS == 64
    137     uint32_t                padding;
    138 # endif
    139 
    140133    /**< Link Up(/Restore) Timer. */
    141134    PTMTIMERR3              pLinkUpTimer;
     
    203196
    204197    /** EMT: Gets signalled when more RX descriptors become available. */
    205     RTSEMEVENT              hEventMoreRxDescAvail;
     198    SUPSEMEVENT             hEventMoreRxDescAvail;
    206199
    207200    /** @name Statistic
     
    529522}
    530523
    531 #ifdef IN_RING3
    532524
    533525/**
    534526 * Wakeup the RX thread.
    535527 */
    536 static void vnetR3WakeupReceive(PPDMDEVINS pDevIns)
     528static void vnetWakeupReceive(PPDMDEVINS pDevIns)
    537529{
    538530    PVNETSTATE pThis = PDMDEVINS_2_DATA(pDevIns, PVNETSTATE);
    539531    if (    pThis->fMaybeOutOfSpace
    540         &&  pThis->hEventMoreRxDescAvail != NIL_RTSEMEVENT)
     532        &&  pThis->hEventMoreRxDescAvail != NIL_SUPSEMEVENT)
    541533    {
    542534        STAM_COUNTER_INC(&pThis->StatRxOverflowWakeup);
    543535        Log(("%s Waking up Out-of-RX-space semaphore\n",  INSTANCE(pThis)));
    544 /**
    545  * @todo r=bird: We can wake stuff up from ring-0 too, see vmsvga, nvme,
    546  *        buslogic, lsilogic, ata, ahci, xhci.  Also, please address similar
    547  *        TODO in E1000.
    548  *
    549  *        The API Is SUPSem*, btw.
    550  */
    551         RTSemEventSignal(pThis->hEventMoreRxDescAvail);
    552     }
    553 }
    554 
     536        int rc = PDMDevHlpSUPSemEventSignal(pDevIns, pThis->hEventMoreRxDescAvail);
     537        AssertRC(rc);
     538    }
     539}
     540
     541#ifdef IN_RING3
    555542
    556543/**
     
    603590    STATUS |= VNET_S_LINK_UP;
    604591    vnetR3RaiseInterrupt(pThis, VERR_SEM_BUSY, VPCI_ISR_CONFIG);
    605     vnetR3WakeupReceive(pDevIns);
     592    vnetWakeupReceive(pDevIns);
    606593    vnetR3CsLeave(pThis);
    607594    Log(("%s vnetR3LinkUpTimer: Link is up\n", INSTANCE(pThis)));
     
    617604{
    618605    RT_NOREF(pItem);
    619     vnetR3WakeupReceive(pDevIns);
     606    vnetWakeupReceive(pDevIns);
    620607    return true;
    621608}
     
    632619    PVNETSTATE pThis = RT_FROM_MEMBER(pVPciState, VNETSTATE, VPCI);
    633620    Log(("%s Driver became ready, waking up RX thread...\n", INSTANCE(pThis)));
    634 /**
    635  * @todo r=bird: We can wake stuff up from ring-0 too, see vmsvga, nvme,
    636  *        buslogic, lsilogic, ata, ahci, xhci.  Also, please address similar
    637  *        TODO in E1000.
    638  *
    639  *        The API Is SUPSem*, btw.
    640  */
    641 #ifdef IN_RING3
    642     vnetR3WakeupReceive(pThis->VPCI.CTX_SUFF(pDevIns));
    643 #else
    644     PPDMQUEUEITEMCORE pItem = PDMQueueAlloc(pThis->CTX_SUFF(pCanRxQueue));
    645     if (pItem)
    646         PDMQueueInsert(pThis->CTX_SUFF(pCanRxQueue), pItem);
    647 #endif
     621    vnetWakeupReceive(pThis->VPCI.CTX_SUFF(pDevIns));
    648622}
    649623
     
    732706{
    733707    PVNETSTATE pThis = RT_FROM_MEMBER(pInterface, VNETSTATE, INetworkDown);
     708    PPDMDEVINS pDevIns = pThis->VPCI.pDevInsR3;
    734709    LogFlow(("%s vnetR3NetworkDown_WaitReceiveAvail(cMillies=%u)\n", INSTANCE(pThis), cMillies));
     710
    735711    int rc = vnetR3CanReceive(pThis);
    736 
    737712    if (RT_SUCCESS(rc))
    738713        return VINF_SUCCESS;
    739     if (RT_UNLIKELY(cMillies == 0))
     714
     715    if (cMillies == 0)
    740716        return VERR_NET_NO_BUFFER_SPACE;
    741717
     
    755731        }
    756732        Log(("%s vnetR3NetworkDown_WaitReceiveAvail: waiting cMillies=%u...\n", INSTANCE(pThis), cMillies));
    757         RTSemEventWait(pThis->hEventMoreRxDescAvail, cMillies);
     733        rc2 = PDMDevHlpSUPSemEventWaitNoResume(pDevIns, pThis->hEventMoreRxDescAvail, cMillies);
     734        if (RT_FAILURE(rc2) && rc2 != VERR_TIMEOUT && rc2 != VERR_INTERRUPTED)
     735            RTThreadSleep(1);
    758736    }
    759737    STAM_PROFILE_STOP(&pThis->StatRxOverflow, a);
     
    11411119    RT_NOREF(pThis, pQueue);
    11421120    Log(("%s Receive buffers has been added, waking up receive thread.\n", INSTANCE(pThis)));
    1143     vnetR3WakeupReceive(pDevIns);
     1121    vnetWakeupReceive(pDevIns);
    11441122}
    11451123
     
    21002078{
    21012079    /* Poke thread waiting for buffer space. */
    2102     vnetR3WakeupReceive(pDevIns);
     2080    vnetWakeupReceive(pDevIns);
    21032081}
    21042082
     
    21102088{
    21112089    /* Poke thread waiting for buffer space. */
    2112     vnetR3WakeupReceive(pDevIns);
     2090    vnetWakeupReceive(pDevIns);
    21132091}
    21142092
     
    21192097static DECLCALLBACK(void) vnetR3Relocate(PPDMDEVINS pDevIns, RTGCINTPTR offDelta)
    21202098{
     2099    vpciRelocate(pDevIns, offDelta);
     2100#ifdef VNET_TX_DELAY
    21212101    PVNETSTATE pThis = PDMDEVINS_2_DATA(pDevIns, PVNETSTATE);
    2122     vpciRelocate(pDevIns, offDelta);
    2123     pThis->pCanRxQueueRC = PDMQueueRCPtr(pThis->pCanRxQueueR3);
    2124 #ifdef VNET_TX_DELAY
    2125     pThis->pTxTimerRC    = TMTimerRCPtr(pThis->pTxTimerR3);
    2126 #endif /* VNET_TX_DELAY */
    2127     // TBD
     2102    pThis->pTxTimerRC = TMTimerRCPtr(pThis->pTxTimerR3);
     2103#endif
    21282104}
    21292105
     
    21422118
    21432119    Log(("%s Destroying instance\n", INSTANCE(pThis)));
    2144     if (pThis->hEventMoreRxDescAvail != NIL_RTSEMEVENT)
    2145     {
    2146         RTSemEventSignal(pThis->hEventMoreRxDescAvail);
    2147         RTSemEventDestroy(pThis->hEventMoreRxDescAvail);
    2148         pThis->hEventMoreRxDescAvail = NIL_RTSEMEVENT;
     2120    if (pThis->hEventMoreRxDescAvail != NIL_SUPSEMEVENT)
     2121    {
     2122        PDMDevHlpSUPSemEventSignal(pDevIns, pThis->hEventMoreRxDescAvail);
     2123        PDMDevHlpSUPSemEventClose(pDevIns, pThis->hEventMoreRxDescAvail);
     2124        pThis->hEventMoreRxDescAvail = NIL_SUPSEMEVENT;
    21492125    }
    21502126
     
    21692145     * Initialize the instance data suffiencently for the destructor not to blow up.
    21702146     */
    2171     pThis->hEventMoreRxDescAvail = NIL_RTSEMEVENT;
     2147    pThis->hEventMoreRxDescAvail = NIL_SUPSEMEVENT;
    21722148#ifndef VNET_TX_DELAY
    21732149    pThis->hTxEvent              = NIL_SUPSEMEVENT;
     
    22482224    AssertRCReturn(rc, rc);
    22492225
    2250     /* Create the RX notifier signaller. */
    2251     rc = PDMDevHlpQueueCreate(pDevIns, sizeof(PDMQUEUEITEMCORE), 1, 0,
    2252                               vnetR3CanRxQueueConsumer, true, "VNet-Rcv", &pThis->pCanRxQueueR3);
    2253     AssertRCReturn(rc, rc);
    2254     pThis->pCanRxQueueR0 = PDMQueueR0Ptr(pThis->pCanRxQueueR3);
    2255     pThis->pCanRxQueueRC = PDMQueueRCPtr(pThis->pCanRxQueueR3);
    2256 
    22572226    /* Create Link Up Timer */
    22582227    rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL, vnetR3LinkUpTimer, pThis, TMTIMER_FLAGS_NO_CRIT_SECT,
     
    22952264        return PDMDEV_SET_ERROR(pDevIns, rc, N_("Failed to attach the network LUN"));
    22962265
    2297     rc = RTSemEventCreate(&pThis->hEventMoreRxDescAvail);
     2266    rc = PDMDevHlpSUPSemEventCreate(pDevIns, &pThis->hEventMoreRxDescAvail);
    22982267    AssertRCReturn(rc, rc);
    22992268
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