VirtualBox

Changeset 592 in vbox


Ignore:
Timestamp:
Feb 4, 2007 2:38:52 PM (18 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
18218
Message:

Async send update

File:
1 edited

Legend:

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

    r587 r592  
    6969#ifdef IN_RING3
    7070#include <iprt/mem.h>
    71 #include <iprt/semaphore.h>
     71#include <iprt/req.h>
    7272#endif
    7373
     
    231231#ifdef PCNET_ASYNC_SEND
    232232    /** Async send thread */
    233     RTSEMEVENT                          hEventSemSend;
     233    PRTREQQUEUE                         pSendQueue;
    234234    RTTHREAD                            hSendThread;
    235235#endif
     
    296296    STAMCOUNTER                         StatRingWriteOutsideRangeR0;
    297297    STAMCOUNTER                         StatRingWriteOutsideRangeGC;
    298 # endif
    299 # ifdef PCNET_ASYNC_SEND
    300     STAMCOUNTER                         StatSyncSend;
    301     STAMCOUNTER                         StatAsyncSend;
    302298# endif
    303299#endif /* VBOX_WITH_STATISTICS */
     
    17871783
    17881784#ifdef IN_RING3
     1785
     1786# ifdef PCNET_ASYNC_SEND
     1787/**
     1788 *  Send packet to the network driver.
     1789 */
     1790DECLCALLBACK(void) pcnetSendAsyncPacket(PCNetState *pData, const void *pvBuf, unsigned cb)
     1791{
     1792    Assert(pData && pData->pDrv && pData->pDrv->pfnSend);
     1793
     1794    pData->pDrv->pfnSend(pData->pDrv, pvBuf, cb);
     1795}
     1796# endif
     1797
    17891798/**
    17901799 * Transmit queue consumer
     
    18011810    int         rc;
    18021811
    1803 #ifdef PCNET_ASYNC_SEND
    1804     /* If the calling threads isn't the async send thread and our queue isn't yet full, then kick off async sending. */
    1805     if (    pData->iFrame  != ELEMENTS(pData->aFrames)
    1806         &&  RTThreadSelf() != pData->hSendThread)
    1807     {
    1808         STAM_COUNTER_INC(&pData->StatAsyncSend);
    1809         rc = RTSemEventSignal(pData->hEventSemSend);
    1810         AssertRC(rc);
    1811         return VINF_SUCCESS;
    1812     }
    1813     if (RTThreadSelf() != pData->hSendThread)
    1814         STAM_COUNTER_INC(&pData->StatSyncSend);
    1815 #endif /* PCNET_ASYNC_SEND */
    1816 
    18171812    STAM_PROFILE_START(&pData->StatXmitQueue, a);
    18181813    STAM_COUNTER_INC(&pData->aStatFlushCounts[pData->iFrame]);
     
    18321827        if (pcnetIsLinkUp(pData))
    18331828        {
     1829#ifdef PCNET_ASYNC_SEND
     1830
     1831            /** @note we make a copy here as we don't wish to have to enter the critical section in the async send thread during the lengthy send process. */
     1832            uint8_t *pPacket = RTMemTmpAlloc(pData->aFrames[i].cb);
     1833            memcpy(pPacket, pv, pData->aFrames[i].cb);
     1834            rc = RTReqCallEx(pData->pSendQueue, NULL, 0, RTREQFLAGS_NO_WAIT, pcnetSendAsyncPacket, pData, pPacket, (unsigned)pData->aFrames[i].cb);
     1835            AssertRC(rc);
     1836#else
    18341837            pData->pDrv->pfnSend(pData->pDrv, pv, pData->aFrames[i].cb);
     1838#endif /* PCNET_ASYNC_SEND */
    18351839            LOG_PACKET("xmit", pv, pData->aFrames[i].cb);
    18361840        }
     
    18681872{
    18691873    PCNetState *pData = (PCNetState *)pvUser;
    1870     RTSEMEVENT  hEventSemSend = pData->hEventSemSend;
    18711874
    18721875    while(1)
    18731876    {
    1874         int rc = RTSemEventWait(pData->hEventSemSend, RT_INDEFINITE_WAIT);
     1877        int rc = RTReqProcess(pQueue);
    18751878        if (VBOX_FAILURE(rc))
    18761879            break;
    1877 
    1878         pcnetXmitQueueConsumer(PCNETSTATE_2_DEVINS(pData), NULL);
    18791880    }
    18801881    return VINF_SUCCESS;
     
    39443945{
    39453946    PCNetState *pData = PDMINS2DATA(pDevIns, PCNetState *);
     3947#ifdef PCNET_ASYNC_SEND
     3948    if (pData->pSendQueue)
     3949        RTReqDestroyQueue(pData->pSendQueue);
     3950#endif
    39463951    PDMR3CritSectDelete(&pData->CritSect);
    39473952    return VINF_SUCCESS;
     
    42034208
    42044209#ifdef PCNET_ASYNC_SEND
    4205     /* Create event semaphore for the async send thread. */
    4206     rc = RTSemEventCreate(&pData->hEventSemSend);
     4210    /* Create send queue for the async send thread. */
     4211    rc = RTReqCreateQueue(&pData->pSendQueue);
    42074212    AssertRC(rc);
    42084213
     
    42114216    AssertRC(rc);
    42124217
    4213     Assert(pData->hSendThread != NIL_RTTHREAD && pData->hEventSemSend != NIL_RTSEMEVENT);
    4214 
    4215     PDMDevHlpSTAMRegisterF(pDevIns, &pData->StatAsyncSend,          STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES,     "Nr of async send operations",        "/Devices/PCNet%d/Send/Async", iInstance);
    4216     PDMDevHlpSTAMRegisterF(pDevIns, &pData->StatSyncSend,           STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES,     "Nr of sync send operations",         "/Devices/PCNet%d/Send/Sync", iInstance);
     4218    Assert(pData->hSendThread != NIL_RTTHREAD && pData->pSendQueue);
    42174219#endif
    42184220
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