VirtualBox

Changeset 22406 in vbox


Ignore:
Timestamp:
Aug 24, 2009 9:03:22 AM (15 years ago)
Author:
vboxsync
Message:

NAT: DrvNAT and Slirp use the same macroces for (de-)registering counters

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

Legend:

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

    r22380 r22406  
    166166    HANDLE                  hWakeupEvent;
    167167#endif
    168     STAMCOUNTER             StatQueuePktSent;       /**< counting packet sent via PDM queue */
    169     STAMCOUNTER             StatQueuePktDropped;    /**< counting packet drops by PDM queue */
    170     STAMCOUNTER             StatConsumerFalse;      /**< how often to wait for guest RX buffers */
     168   
     169#define DRV_PROFILE_COUNTER(name, dsc)     STAMPROFILE Stat ## name
     170#define DRV_COUNTING_COUNTER(name, dsc)    STAMCOUNTER Stat ## name
     171#include "counters.h"
    171172#ifdef SLIRP_SPLIT_CAN_OUTPUT
    172173    /** thread delivering packets for receiving by the guest */
     
    176177    /** Receive Req queue (deliver packets to the guest) */
    177178    PRTREQQUEUE             pRecvReqQueue;
    178     STAMCOUNTER             StatNATRecvWakeups;     /**< how often to wakeup the guest RX thread */
    179179#endif
    180180} DRVNAT;
     
    237237    if (RT_FAILURE(pThis->pPort->pfnWaitReceiveAvail(pThis->pPort, RT_INDEFINITE_WAIT)))
    238238    {
    239         AssertMsgFailed(("No RX available even on indefinite wait"));
     239        AssertMsgFailed(("NAT: No RX available even on indefinite wait"));
    240240    }
    241241    int rc = pThis->pPort->pfnReceive(pThis->pPort, pu8Buf, cb);
     
    839839    pThis->pNATState = NULL;
    840840#ifdef VBOX_WITH_STATISTICS
    841     PDMDrvHlpSTAMDeregister(pDrvIns, &pThis->StatQueuePktSent);
    842     PDMDrvHlpSTAMDeregister(pDrvIns, &pThis->StatQueuePktDropped);
    843     PDMDrvHlpSTAMDeregister(pDrvIns, &pThis->StatConsumerFalse);
     841# define DRV_PROFILE_COUNTER(name, dsc)     DEREGISTER_COUNTER(name, pThis)
     842# define DRV_COUNTING_COUNTER(name, dsc)    DEREGISTER_COUNTER(name, pThis)
     843# include "counters.h"
    844844#endif
    845845}
     
    968968        slirp_register_statistics(pThis->pNATState, pDrvIns);
    969969#ifdef VBOX_WITH_STATISTICS
    970         PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->StatQueuePktSent,    STAMTYPE_COUNTER,
    971                                STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT, "counting packet sent viai "
    972                                "PDM queue", "/Drivers/NAT%u/QueuePacketSent", pDrvIns->iInstance);
    973         PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->StatQueuePktDropped, STAMTYPE_COUNTER,
    974                                STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT, "counting packet sent via PDM"
    975                                " queue", "/Drivers/NAT%u/QueuePacketDropped", pDrvIns->iInstance);
    976         PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->StatConsumerFalse, STAMTYPE_COUNTER,
    977                                STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT, "counting PDM consumer false"
    978                                " queue", "/Drivers/NAT%u/PDMConsumerFalse", pDrvIns->iInstance);
    979 # ifdef SLIRP_SPLIT_CAN_OUTPUT
    980         PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->StatNATRecvWakeups, STAMTYPE_COUNTER,
    981                                STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT, "counting wakeups of NATRX"
    982                                " thread", "/Drivers/NAT%u/NATRecvWakeups", pDrvIns->iInstance);
    983 # endif
     970# define DRV_PROFILE_COUNTER(name, dsc)     REGISTER_COUNTER(name, pThis, STAMTYPE_PROFILE, STAMUNIT_TICKS_PER_CALL, dsc)
     971# define DRV_COUNTING_COUNTER(name, dsc)    REGISTER_COUNTER(name, pThis, STAMTYPE_COUNTER, STAMUNIT_COUNT,          dsc)
     972# include "counters.h"
    984973#endif
    985974
  • trunk/src/VBox/Devices/Network/slirp/counters.h

    r22404 r22406  
    3131# define COUNTERS_H
    3232# if defined(VBOX_WITH_STATISTICS)
    33 #  define REGISTER_COUNTER(name, type, units, dsc)                  \
     33#  define REGISTER_COUNTER(name, storage, type, units, dsc)         \
    3434    do {                                                            \
    3535        PDMDrvHlpSTAMRegisterF(pDrvIns,                             \
    36                                &pData->Stat ## name,                \
     36                               &(storage)->Stat ## name,            \
    3737                               type,                                \
    3838                               STAMVISIBILITY_ALWAYS,               \
     
    4242                               pDrvIns->iInstance);                 \
    4343    } while (0)
    44 #  define DEREGISTER_COUNTER(name) PDMDrvHlpSTAMDeregister(pDrvIns, &pData->Stat ## name)
     44#  define DEREGISTER_COUNTER(name, storage) PDMDrvHlpSTAMDeregister(pDrvIns, &(storage)->Stat ## name)
    4545# else
    46 #  define REGISTER_COUNTER(name, type, units, dsc) do {} while (0)
    47 #  define DEREGISTER_COUNTER(name) do {} while (0)
     46#  define REGISTER_COUNTER(name, storage, type, units, dsc) do {} while (0)
     47#  define DEREGISTER_COUNTER(name, storage) do {} while (0)
    4848# endif
    4949# undef COUNTERS_INIT
     
    6161 * DRV_ prefixed are counters used in DrvNAT the rest are used in Slirp
    6262 */
    63 # ifdef DRV_PROFILE_COUNTER
    64 #  define PROFILE_COUNTER(name, dsc) do {} while (0)
    65 # endif
    66 # ifdef DRV_COUNTING_COUNTER
    67 #  define COUNTING_COUNTER(name, dsc) do {} while (0)
    68 # endif
    6963
    70 # ifdef PROFILE_COUNTER
    71 #  define DRV_PROFILE_COUNTER(name, dsc) do {} while (0)
    72 # endif
    73 # ifdef COUNTING_COUNTER
    74 #  define DRV_COUNTING_COUNTER(name, dsc) do {} while (0)
    75 # endif
    76 
     64# if defined(PROFILE_COUNTER) || defined(COUNTING_COUNTER)
    7765PROFILE_COUNTER(Fill, "Profiling slirp fills");
    7866PROFILE_COUNTER(Poll, "Profiling slirp polls");
     
    125113PROFILE_COUNTER(ALIAS_input, "ALIAS::input");
    126114PROFILE_COUNTER(ALIAS_output, "ALIAS::output");
     115
     116# else
     117/*DrvNAT.cpp*/
     118#  ifdef SLIRP_SPLIT_CAN_OUTPUT
     119DRV_COUNTING_COUNTER(NATRecvWakeups, "counting wakeups of NAT RX thread");
     120#  endif
     121DRV_COUNTING_COUNTER(QueuePktSent, "counting packet sent via PDM Queue");       /**< counting packet sent via PDM queue */
     122DRV_COUNTING_COUNTER(QueuePktDropped, "counting packet drops by PDM Queue");    /**< counting packet drops by PDM queue */
     123DRV_COUNTING_COUNTER(ConsumerFalse, "counting consumer's reject number to process the queue's item");      /**< how often to wait for guest RX buffers */
     124# endif
    127125#endif /*!COUNTERS_INIT*/
    128126
  • trunk/src/VBox/Devices/Network/slirp/slirp.c

    r22404 r22406  
    568568{
    569569#ifdef VBOX_WITH_STATISTICS
    570 # define PROFILE_COUNTER(name, dsc)     REGISTER_COUNTER(name, STAMTYPE_PROFILE, STAMUNIT_TICKS_PER_CALL, dsc)
    571 # define COUNTING_COUNTER(name, dsc)    REGISTER_COUNTER(name, STAMTYPE_COUNTER, STAMUNIT_COUNT,          dsc)
     570# define PROFILE_COUNTER(name, dsc)     REGISTER_COUNTER(name, pData, STAMTYPE_PROFILE, STAMUNIT_TICKS_PER_CALL, dsc)
     571# define COUNTING_COUNTER(name, dsc)    REGISTER_COUNTER(name, pData, STAMTYPE_COUNTER, STAMUNIT_COUNT,          dsc)
    572572
    573573# include "counters.h"
     
    586586{
    587587#ifdef VBOX_WITH_STATISTICS
    588 # define PROFILE_COUNTER(name, dsc)     DEREGISTER_COUNTER(name)
    589 # define COUNTING_COUNTER(name, dsc)    DEREGISTER_COUNTER(name)
     588# define PROFILE_COUNTER(name, dsc)     DEREGISTER_COUNTER(name, pData)
     589# define COUNTING_COUNTER(name, dsc)    DEREGISTER_COUNTER(name, pData)
    590590
    591591# include "counters.h"
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