VirtualBox

Changeset 20713 in vbox for trunk/src/VBox/Devices/Network


Ignore:
Timestamp:
Jun 19, 2009 11:43:01 AM (16 years ago)
Author:
vboxsync
Message:

DrvNAT,slirp: Even simpler.

Location:
trunk/src/VBox/Devices/Network
Files:
1 deleted
3 edited

Legend:

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

    r20712 r20713  
    3636#include <iprt/cidr.h>
    3737#include <iprt/stream.h>
    38 
    39 #include "slirp/statistics.h"
    4038
    4139#include "Builtins.h"
     
    115113    HANDLE                  hWakeupEvent;
    116114#endif
     115    STAMCOUNTER             StatQueuePktSent;       /**< counting packet sent via PDM queue */
     116    STAMCOUNTER             StatQueuePktDropped;    /**< counting packet drops by PDM queue */
    117117} DRVNAT;
    118118/** Pointer the NAT driver instance data. */
     
    497497    Log2(("slirp_output: pu8Buf=%p cb=%#x (pThis=%p)\n%.*Rhxd\n", pu8Buf, cb, pThis, cb, pu8Buf));
    498498
    499     STAM_COUNTER_RESET(DRVNAT_STAT(pThis, DrvNAT_package_drop, STAMCOUNTER));
    500     STAM_COUNTER_RESET(DRVNAT_STAT(pThis, DrvNAT_package_sent, STAMCOUNTER));
     499    STAM_COUNTER_RESET(&pThis->StatQueuePktDropped);
     500    STAM_COUNTER_RESET(&pThis->StatQueuePktSent);
    501501    Assert(pThis);
    502502
     
    509509        Log2(("pItem:%p %.Rhxd\n", pItem, pItem->pu8Buf));
    510510        PDMQueueInsert(pThis->pSendQueue, &pItem->Core);
    511         STAM_COUNTER_INC(DRVNAT_STAT(pThis, DrvNAT_package_sent, STAMCOUNTER));
     511        STAM_COUNTER_INC(&pThis->StatQueuePktSent);
    512512        return;
    513513    }
     
    517517    else
    518518    {
    519         LogRel(("NAT: %d messages suppressed about dropping package (couldn't allocate queue item)\n", s_cDroppedPackets));
     519        LogRel(("NAT: %d messages suppressed about dropping packet (couldn't allocate queue item)\n", s_cDroppedPackets));
    520520        s_cDroppedPackets = 0;
    521521    }
    522     STAM_COUNTER_INC(DRVNAT_STAT(pThis, DrvNAT_package_drop, STAMCOUNTER));
     522    STAM_COUNTER_INC(&pThis->StatQueuePktDropped);
    523523    RTMemFree((void *)pu8Buf);
    524524}
     
    603603    slirp_deregister_statistics(pThis->pNATState, pDrvIns);
    604604    pThis->pNATState = NULL;
     605#ifdef VBOX_WITH_STATISTICS
     606    PDMDrvHlpSTAMDeregister(pDrvIns, &pThis->StatQueuePktSent);
     607    PDMDrvHlpSTAMDeregister(pDrvIns, &pThis->StatQueuePktDropped);
     608#endif
    605609}
    606610
     
    833837#endif
    834838#define SLIRP_SET_TUNING_VALUE(name, setter)            \
    835     do                                                  \
    836     {                                                   \
    837         int len = 0;                                    \
    838         rc = CFGMR3QueryS32(pCfgHandle, name, &len);    \
    839         if (RT_SUCCESS(rc))                             \
    840             setter(pThis->pNATState, len);              \
    841     }while(0)
     839            do                                                  \
     840            {                                                   \
     841                int len = 0;                                    \
     842                rc = CFGMR3QueryS32(pCfgHandle, name, &len);    \
     843                if (RT_SUCCESS(rc))                             \
     844                    setter(pThis->pNATState, len);              \
     845            } while(0)
     846
    842847        SLIRP_SET_TUNING_VALUE("SocketRcvBuf", slirp_set_rcvbuf);
    843848        SLIRP_SET_TUNING_VALUE("SocketSndBuf", slirp_set_sndbuf);
     
    846851
    847852        slirp_register_statistics(pThis->pNATState, pDrvIns);
     853#ifdef VBOX_WITH_STATISTICS
     854        PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->StatQueuePktSent,    STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT, "counting packet sent via PDM queue", "/Drivers/NAT%u/QueuePacketSent", pDrvIns->iInstance);
     855        PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->StatQueuePktDropped, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT, "counting packet sent via PDM queue", "/Drivers/NAT%u/QueuePacketDropped", pDrvIns->iInstance);
     856#endif
     857
    848858        int rc2 = drvNATConstructRedir(pDrvIns->iInstance, pThis, pCfgHandle, Network);
    849859        if (RT_SUCCESS(rc2))
  • trunk/src/VBox/Devices/Network/slirp/counters.h

    r20712 r20713  
    7575PROFILE_COUNTER(TCP_input, "TCP::input");
    7676
    77 COUNTING_COUNTER(DrvNAT_package_sent, "counting package sent via PDM queue");
    78 COUNTING_COUNTER(DrvNAT_package_drop, "counting package drops by PDM queue");
    79 
  • trunk/src/VBox/Devices/Network/slirp/slirp.c

    r20712 r20713  
    2020#ifdef VBOX_WITH_SLIRP_ALIAS
    2121# include <alias.h>
    22 #endif
    23 
    24 #ifdef VBOX_WITH_STATISTICS
    25 # include "statistics.h"
    2622#endif
    2723
     
    715711}
    716712
    717 /* instantiate the variables. */
    718 #ifdef VBOX_WITH_STATISTICS
    719 # define COUNTING_COUNTER(name, desc)    DECLHIDDEN(uint32_t) g_offSlirpStat##name
    720 # define PROFILE_COUNTER(name, desc)     DECLHIDDEN(uint32_t) g_offSlirpStat##name
    721 # include "counters.h"
    722 # undef COUNTING_COUNTER
    723 # undef PROFILE_COUNTER
    724 #endif
    725 
    726713/**
    727714 * Register statistics.
     
    732719# define COUNTER(name, type, units, dsc)                            \
    733720    do {                                                            \
    734         ASMAtomicUoWriteU32(&g_offSlirpStat##name,                  \
    735                             RT_UOFFSETOF(NATState, Stat##name));    \
    736721        PDMDrvHlpSTAMRegisterF(pDrvIns,                             \
    737722                               &pData->Stat ## name,                \
     
    740725                               units,                               \
    741726                               dsc,                                 \
    742                                "/Drivers/NAT%u/Stat" #name,         \
     727                               "/Drivers/NAT%u/" #name,             \
    743728                               pDrvIns->iInstance);                 \
    744729    } while (0)
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