VirtualBox

Changeset 20350 in vbox


Ignore:
Timestamp:
Jun 6, 2009 8:25:47 AM (16 years ago)
Author:
vboxsync
Message:

NAT: make counters registration easier

Location:
trunk/src/VBox/Devices/Network/slirp
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Network/slirp/slirp.c

    r20296 r20350  
    711711{
    712712#ifdef VBOX_WITH_STATISTICS
    713     PDMDrvHlpSTAMRegisterF(pDrvIns, &pData->StatFill, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS,
    714                            STAMUNIT_TICKS_PER_CALL, "Profiling slirp fills", "/Drivers/NAT%d/Fill", pDrvIns->iInstance);
    715     PDMDrvHlpSTAMRegisterF(pDrvIns, &pData->StatPoll, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS,
    716                            STAMUNIT_TICKS_PER_CALL, "Profiling slirp polls", "/Drivers/NAT%d/Poll", pDrvIns->iInstance);
    717     PDMDrvHlpSTAMRegisterF(pDrvIns, &pData->StatFastTimer, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS,
    718                            STAMUNIT_TICKS_PER_CALL, "Profiling slirp fast timer", "/Drivers/NAT%d/TimerFast", pDrvIns->iInstance);
    719     PDMDrvHlpSTAMRegisterF(pDrvIns, &pData->StatSlowTimer, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS,
    720                            STAMUNIT_TICKS_PER_CALL, "Profiling slirp slow timer", "/Drivers/NAT%d/TimerSlow", pDrvIns->iInstance);
    721     PDMDrvHlpSTAMRegisterF(pDrvIns, &pData->StatTCP, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS,
    722                            STAMUNIT_COUNT, "TCP sockets", "/Drivers/NAT%d/SockTCP", pDrvIns->iInstance);
    723     PDMDrvHlpSTAMRegisterF(pDrvIns, &pData->StatTCPHot, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS,
    724                            STAMUNIT_COUNT, "TCP sockets active", "/Drivers/NAT%d/SockTCPHot", pDrvIns->iInstance);
    725     PDMDrvHlpSTAMRegisterF(pDrvIns, &pData->StatUDP, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS,
    726                            STAMUNIT_COUNT, "UDP sockets", "/Drivers/NAT%d/SockUDP", pDrvIns->iInstance);
    727     PDMDrvHlpSTAMRegisterF(pDrvIns, &pData->StatUDPHot, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS,
    728                            STAMUNIT_COUNT, "UDP sockets active", "/Drivers/NAT%d/SockUDPHot", pDrvIns->iInstance);
     713# define COUNTER(name, type, units, dsc)                            \
     714do{                                                                 \
     715    PDMDrvHlpSTAMRegisterF(pDrvIns,                                 \
     716                    &pData->Stat ## name,                           \
     717                    type,                                           \
     718                    STAMVISIBILITY_ALWAYS,                          \
     719                    units,                                          \
     720                    dsc,                                            \
     721                    "/Drivers/NAT%d/Stat" #name, pDrvIns->iInstance);   \
     722}while(0)
     723
     724# define PROFILE_COUNTER(name, dsc) \
     725    COUNTER(name, STAMTYPE_PROFILE, STAMUNIT_TICKS_PER_CALL, dsc)
     726# define COUNTING_COUTER(name, dsc) \
     727    COUNTER(name, STAMTYPE_COUNTER, STAMUNIT_COUNT, dsc)
     728
     729#include "counters.h"
     730
     731#undef COUNTER
     732#undef PROFILE_COUNTER
     733#undef COUNTING_COUTER
     734
    729735#endif /* VBOX_WITH_STATISTICS */
    730736}
     
    11611167            ret = soread(pData, so);
    11621168            /* Output it if we read something */
    1163             if (ret > 0)
     1169            if (RT_LIKELY(ret > 0))
    11641170                TCP_OUTPUT(pData, sototcpcb(so));
    11651171        }
     
    17531759    {
    17541760        if (time_fasttimo)
    1755             return 2;
     1761            return 2; 
    17561762        if (do_slowtimo)
    17571763            return 500; /* see PR_SLOWHZ */
  • trunk/src/VBox/Devices/Network/slirp/slirp_state.h

    r20302 r20350  
    230230    struct libalias *proxy_alias;
    231231#endif
    232     STAMPROFILE StatFill;
    233     STAMPROFILE StatPoll;
    234     STAMPROFILE StatFastTimer;
    235     STAMPROFILE StatSlowTimer;
    236     STAMCOUNTER StatTCP;
    237     STAMCOUNTER StatUDP;
    238     STAMCOUNTER StatTCPHot;
    239     STAMCOUNTER StatUDPHot;
     232
     233#ifdef VBOX_WITH_STATISTICS
     234# define PROFILE_COUNTER(name, dsc) STAMPROFILE Stat ## name
     235# define COUNTING_COUTER(name, dsc) STAMCOUNTER Stat ## name
     236
     237
     238#include "counters.h"
     239
     240
     241#undef PROFILE_COUNTER
     242#undef COUNTING_COUTER
     243#endif
     244
    240245} NATState;
    241246
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