VirtualBox

Changeset 575 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Feb 2, 2007 6:29:46 PM (18 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
18195
Message:

Enabled delayed transmit interrupts + added async sending of packets (disabled)

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

Legend:

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

    r573 r575  
    6969#ifdef IN_RING3
    7070#include <iprt/mem.h>
     71#include <iprt/semaphore.h>
    7172#endif
    7273
     
    8586/* Enable to delay setting the TX interrupt until packets have been sent. */
    8687/** @note currently not technically correct (own bit) */
    87 /* #define PCNET_DELAY_INT */
     88#define PCNET_DELAY_INT
     89
     90/* Enable to send packets in a seperate thread. */
     91/* #define PCNET_ASYNC_SEND */
    8892
    8993#ifdef __GNUC__
     
    227231    /** Partner of ILeds. */
    228232    HCPTRTYPE(PPDMILEDCONNECTORS)       pLedsConnector;
     233
     234#ifdef PCNET_ASYNC_SEND
     235    /** Async send thread */
     236    RTSEMEVENT                          hEventSemSend;
     237    RTTHREAD                            hSendThread;
     238#endif
    229239
    230240    /** Access critical section. */
     
    289299    STAMCOUNTER                         StatRingWriteOutsideRangeR0;
    290300    STAMCOUNTER                         StatRingWriteOutsideRangeGC;
     301# endif
     302# ifdef PCNET_ASYNC_SEND
     303    STAMCOUNTER                         StatSyncSend;
     304    STAMCOUNTER                         StatAsyncSend;
    291305# endif
    292306#endif /* VBOX_WITH_STATISTICS */
     
    17901804    int         rc;
    17911805
     1806#ifdef PCNET_ASYNC_SEND
     1807    /* If the calling threads isn't the async send thread and our queue isn't yet full, then kick off async sending. */
     1808    if (    pData->iFrame  != ELEMENTS(pData->aFrames)
     1809        &&  RTThreadSelf() != pData->hSendThread)
     1810    {
     1811        STAM_COUNTER_INC(&pData->StatAsyncSend);
     1812        rc = RTSemEventSignal(pData->hEventSemSend);
     1813        AssertRC(rc);
     1814        return VINF_SUCCESS;
     1815    }
     1816    if (RTThreadSelf() != pData->hSendThread)
     1817        STAM_COUNTER_INC(&pData->StatSyncSend);
     1818#endif /* PCNET_ASYNC_SEND */
     1819
    17921820    STAM_PROFILE_START(&pData->StatXmitQueue, a);
    17931821    STAM_COUNTER_INC(&pData->aStatFlushCounts[pData->iFrame]);
     
    18901918    return true;
    18911919}
     1920
     1921#ifdef PCNET_ASYNC_SEND
     1922/**
     1923 * Async I/O thread for delayed sending of packets.
     1924 */
     1925static DECLCALLBACK(int) pcnetAsyncSend(RTTHREAD ThreadSelf, void *pvUser)
     1926{
     1927    PCNetState *pData = (PCNetState *)pvUser;
     1928    RTSEMEVENT  hEventSemSend = pData->hEventSemSend;
     1929
     1930    while(1)
     1931    {
     1932        int rc = RTSemEventWait(pData->hEventSemSend, RT_INDEFINITE_WAIT);
     1933        if (VBOX_FAILURE(rc))
     1934            break;
     1935
     1936        pcnetXmitQueueConsumer(PCNETSTATE_2_DEVINS(pData), NULL);
     1937    }
     1938    return VINF_SUCCESS;
     1939}
     1940#endif /* PCNET_ASYNC_SEND */
     1941
    18921942#endif /* IN_RING3 */
    18931943
     
    19101960#endif
    19111961    }
     1962#ifndef PCNET_ASYNC_SEND
    19121963    pData->aFrames[0].off  = 0;
    19131964    pData->aFrames[0].cb   = -1;
    19141965    pData->aFrames[0].pvR3 = NIL_RTR3PTR;
    19151966    pData->iFrame = 0;
     1967#endif
    19161968}
    19171969
     
    42084260    pcnetHardReset(pData);
    42094261
     4262#ifdef PCNET_ASYNC_SEND
     4263    /* Create event semaphore for the async send thread. */
     4264    rc = RTSemEventCreate(&pData->hEventSemSend);
     4265    AssertRC(rc);
     4266
     4267    /* Create asynchronous thread */
     4268    rc = RTThreadCreate(&pData->hSendThread, pcnetAsyncSend, (void *)pData, 128*1024, RTTHREADTYPE_IO, 0, "PCNET_SEND");
     4269    AssertRC(rc);
     4270
     4271    Assert(pData->hSendThread != NIL_RTTHREAD && pData->hEventSemSend != NIL_RTSEMEVENT);
     4272
     4273    PDMDevHlpSTAMRegisterF(pDevIns, &pData->StatAsyncSend,          STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES,     "Nr of async send operations",        "/Devices/PCNet%d/Send/Async", iInstance);
     4274    PDMDevHlpSTAMRegisterF(pDevIns, &pData->StatSyncSend,           STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES,     "Nr of sync send operations",         "/Devices/PCNet%d/Send/Sync", iInstance);
     4275#endif
     4276
    42104277#ifdef VBOX_WITH_STATISTICS
    42114278    PDMDevHlpSTAMRegisterF(pDevIns, &pData->StatMMIOReadGC,         STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_TICKS_PER_CALL, "Profiling MMIO reads in GC",         "/Devices/PCNet%d/MMIO/ReadGC", iInstance);
  • trunk/src/VBox/Devices/Network/DrvTAPWin32.cpp

    r562 r575  
    613613
    614614#ifdef ASYNC_NETIO
     615    pData->hHaltAsyncEventSem = CreateEvent(NULL, FALSE, FALSE, NULL);
     616
    615617    /* Create asynchronous thread */
    616618    rc = RTThreadCreate(&pData->hThread, drvTAPW32AsyncIo, (void *)pData, 128*1024, RTTHREADTYPE_IO, 0, "TAPWIN32");
    617619    AssertRC(rc);
    618 
    619     pData->hHaltAsyncEventSem = CreateEvent(NULL, FALSE, FALSE, NULL);
    620620
    621621    Assert(pData->hThread != NIL_RTTHREAD && pData->hHaltAsyncEventSem != NULL);
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