VirtualBox

Changeset 23141 in vbox


Ignore:
Timestamp:
Sep 18, 2009 3:31:10 PM (15 years ago)
Author:
vboxsync
Message:

NAT: clean non-SLIRP_SPLIT_CAN_OUTPUT code

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

Legend:

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

    r23137 r23141  
    5959*   Defined Constants And Macros                                               *
    6060*******************************************************************************/
    61 #define SLIRP_SPLIT_CAN_OUTPUT 1
    62 
    6361#define GET_EXTRADATA(pthis, node, name, rc, type, type_name, var)                                  \
    6462do {                                                                                                \
     
    114112        x.s_addr = def;                                 \
    115113} while (0)
    116 
    117 /** Queue depth (!SLIRP_SPLIT_CAN_OUTPUT). */
    118 #define QUEUE_SIZE 50
    119 
    120114
    121115/*******************************************************************************
     
    149143    /** Queue for NAT-thread-external events. */
    150144    PRTREQQUEUE             pSlirpReqQueue;
    151 #ifndef SLIRP_SPLIT_CAN_OUTPUT
    152     /* Receive PDM queue (deliver packets to the guest) */
    153     PPDMQUEUE               pRecvQueue;
    154 #endif
    155145
    156146#ifdef VBOX_WITH_SLIRP_MT
     
    174164#define DRV_COUNTING_COUNTER(name, dsc)    STAMCOUNTER Stat ## name
    175165#include "counters.h"
    176 #ifdef SLIRP_SPLIT_CAN_OUTPUT
    177166    /** thread delivering packets for receiving by the guest */
    178167    PPDMTHREAD              pRecvThread;
     
    181170    /** Receive Req queue (deliver packets to the guest) */
    182171    PRTREQQUEUE             pRecvReqQueue;
    183 #endif
    184172} DRVNAT;
    185173AssertCompileMemberAlignment(DRVNAT, StatNATRecvWakeups, 8);
     
    211199
    212200
    213 #ifdef SLIRP_SPLIT_CAN_OUTPUT
    214201
    215202static DECLCALLBACK(int) drvNATRecv(PPDMDRVINS pDrvIns, PPDMTHREAD pThread)
     
    256243    STAM_PROFILE_STOP(&pThis->StatNATRecv, a);
    257244}
    258 
    259 #endif /* SLIRP_SPLIT_CAN_OUTPUT */
    260245
    261246/**
     
    622607    Log2(("slirp_output: pu8Buf=%p cb=%#x (pThis=%p)\n%.*Rhxd\n", pu8Buf, cb, pThis, cb, pu8Buf));
    623608
    624 #ifndef SLIRP_SPLIT_CAN_OUTPUT
    625     PDRVNATQUEUITEM pItem = (PDRVNATQUEUITEM)PDMQueueAlloc(pThis->pRecvQueue);
    626     if (pItem)
    627     {
    628         pItem->pu8Buf = pu8Buf;
    629         pItem->cb = cb;
    630         pItem->mbuf = pvArg;
    631         Log2(("pItem:%p %.Rhxd\n", pItem, pItem->pu8Buf));
    632         PDMQueueInsert(pThis->pRecvQueue, &pItem->Core);
    633         STAM_COUNTER_INC(&pThis->StatQueuePktSent);
    634         return;
    635     }
    636     static unsigned s_cDroppedPackets;
    637     if (s_cDroppedPackets < 64)
    638         s_cDroppedPackets++;
    639     else
    640     {
    641         LogRel(("NAT: %d messages suppressed about dropping packet (couldn't allocate queue item)\n", s_cDroppedPackets));
    642         s_cDroppedPackets = 0;
    643     }
    644     STAM_COUNTER_INC(&pThis->StatQueuePktDropped);
    645     RTMemFree((void *)pu8Buf);
    646 #else
    647609    PRTREQ pReq = NULL;
    648610
     
    663625    drvNATRecvWakeup(pThis->pDrvIns, pThis->pRecvThread);
    664626    STAM_COUNTER_INC(&pThis->StatQueuePktSent);
    665 #endif
    666 }
    667 
    668 
    669 #ifndef SLIRP_SPLIT_CAN_OUTPUT
    670 /**
    671  * Queue callback for processing a queued item.
    672  *
    673  * @returns Success indicator.
    674  *          If false the item will not be removed and the flushing will stop.
    675  * @param   pDrvIns         The driver instance.
    676  * @param   pItemCore       Pointer to the queue item to process.
    677  */
    678 static DECLCALLBACK(bool) drvNATQueueConsumer(PPDMDRVINS pDrvIns, PPDMQUEUEITEMCORE pItemCore)
    679 {
    680     int rc;
    681     PDRVNAT pThis = PDMINS_2_DATA(pDrvIns, PDRVNAT);
    682     PDRVNATQUEUITEM pItem = (PDRVNATQUEUITEM)pItemCore;
    683     PRTREQ pReq = NULL;
    684     Log(("drvNATQueueConsumer(pItem:%p, pu8Buf:%p, cb:%d)\n", pItem, pItem->pu8Buf, pItem->cb));
    685     Log2(("drvNATQueueConsumer: pu8Buf:\n%.Rhxd\n", pItem->pu8Buf));
    686     if (RT_FAILURE(pThis->pPort->pfnWaitReceiveAvail(pThis->pPort, 0)))
    687     {
    688         STAM_COUNTER_INC(&pThis->StatConsumerFalse);
    689         return false;
    690     }
    691     rc = pThis->pPort->pfnReceive(pThis->pPort, pItem->pu8Buf, pItem->cb);
    692     RTMemFree((void *)pItem->pu8Buf);
    693     return true;
    694 
    695     AssertRelease(pItem->mbuf == NULL);
    696     return RT_SUCCESS(rc);
    697 }
    698 #endif
     627}
    699628
    700629
     
    1004933
    1005934
    1006 #ifndef SLIRP_SPLIT_CAN_OUTPUT
    1007             rc = PDMDrvHlpPDMQueueCreate(pDrvIns, sizeof(DRVNATQUEUITEM), QUEUE_SIZE, 0,
    1008                                          drvNATQueueConsumer, "NAT", &pThis->pRecvQueue);
    1009             if (RT_FAILURE(rc))
    1010             {
    1011                 LogRel(("NAT: Can't create send queue\n"));
    1012                 return rc;
    1013             }
    1014 #else
    1015935            rc = RTReqCreateQueue(&pThis->pRecvReqQueue);
    1016936            if (RT_FAILURE(rc))
     
    1023943            AssertReleaseRC(rc);
    1024944            rc = RTSemEventCreate(&pThis->EventRecv);
    1025 #endif
    1026945
    1027946#ifndef RT_OS_WINDOWS
  • trunk/src/VBox/Devices/Network/slirp/counters.h

    r22458 r23141  
    117117# else
    118118/*DrvNAT.cpp*/
    119 #  ifdef SLIRP_SPLIT_CAN_OUTPUT
    120119DRV_COUNTING_COUNTER(NATRecvWakeups, "counting wakeups of NAT RX thread");
    121120DRV_PROFILE_COUNTER(NATRecv,"Time spent in NATRecv worker");
    122121DRV_PROFILE_COUNTER(NATRecvWait,"Time spent in NATRecv worker in waiting of free RX buffers");
    123 #  endif
    124122DRV_COUNTING_COUNTER(QueuePktSent, "counting packet sent via PDM Queue");
    125123DRV_COUNTING_COUNTER(QueuePktDropped, "counting packet drops by PDM Queue");
Note: See TracChangeset for help on using the changeset viewer.

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