counters.h revision 3fa88ed5980bc097e9f97063a9965d2cf771c5f3
d981a844e64c196b4c96be1a52ddc42e23337138vboxsync/** $Id$ */
d981a844e64c196b4c96be1a52ddc42e23337138vboxsync/** @file
eb6509c759a277527b791759757d9d9a5b1c5e32vboxsync * Counters macro invocation template.
eb6509c759a277527b791759757d9d9a5b1c5e32vboxsync *
eb6509c759a277527b791759757d9d9a5b1c5e32vboxsync * This is included with different PROFILE_COUNTER and COUNTING_COUNTER
eb6509c759a277527b791759757d9d9a5b1c5e32vboxsync * implementations to instantiate data members, create function prototypes and
eb6509c759a277527b791759757d9d9a5b1c5e32vboxsync * implement these prototypes.
d981a844e64c196b4c96be1a52ddc42e23337138vboxsync */
d981a844e64c196b4c96be1a52ddc42e23337138vboxsync
d981a844e64c196b4c96be1a52ddc42e23337138vboxsync/*
eb6509c759a277527b791759757d9d9a5b1c5e32vboxsync * Copyright (C) 2007-2009 Sun Microsystems, Inc.
d981a844e64c196b4c96be1a52ddc42e23337138vboxsync *
d981a844e64c196b4c96be1a52ddc42e23337138vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
d981a844e64c196b4c96be1a52ddc42e23337138vboxsync * available from http://www.virtualbox.org. This file is free software;
d981a844e64c196b4c96be1a52ddc42e23337138vboxsync * you can redistribute it and/or modify it under the terms of the GNU
d981a844e64c196b4c96be1a52ddc42e23337138vboxsync * General Public License (GPL) as published by the Free Software
d981a844e64c196b4c96be1a52ddc42e23337138vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
d981a844e64c196b4c96be1a52ddc42e23337138vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
d981a844e64c196b4c96be1a52ddc42e23337138vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
d981a844e64c196b4c96be1a52ddc42e23337138vboxsync *
d981a844e64c196b4c96be1a52ddc42e23337138vboxsync * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
d981a844e64c196b4c96be1a52ddc42e23337138vboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
d981a844e64c196b4c96be1a52ddc42e23337138vboxsync * additional information or have any questions.
d981a844e64c196b4c96be1a52ddc42e23337138vboxsync */
eb6509c759a277527b791759757d9d9a5b1c5e32vboxsync
d981a844e64c196b4c96be1a52ddc42e23337138vboxsync/*
640c5443600563afd4f0759c0f0ad4249f065577vboxsync * COUNTERS_INIT is used before using counters.h to declare helping macro
d981a844e64c196b4c96be1a52ddc42e23337138vboxsync * definitions for (de-)registering counters
640c5443600563afd4f0759c0f0ad4249f065577vboxsync */
eb6509c759a277527b791759757d9d9a5b1c5e32vboxsync#ifndef COUNTERS_H
d981a844e64c196b4c96be1a52ddc42e23337138vboxsync# define COUNTERS_H
d981a844e64c196b4c96be1a52ddc42e23337138vboxsync# if defined(VBOX_WITH_STATISTICS)
eb6509c759a277527b791759757d9d9a5b1c5e32vboxsync# define REGISTER_COUNTER(name, type, units, dsc) \
eb6509c759a277527b791759757d9d9a5b1c5e32vboxsync do { \
eb6509c759a277527b791759757d9d9a5b1c5e32vboxsync PDMDrvHlpSTAMRegisterF(pDrvIns, \
eb6509c759a277527b791759757d9d9a5b1c5e32vboxsync &pData->Stat ## name, \
eb6509c759a277527b791759757d9d9a5b1c5e32vboxsync type, \
eb6509c759a277527b791759757d9d9a5b1c5e32vboxsync STAMVISIBILITY_ALWAYS, \
d981a844e64c196b4c96be1a52ddc42e23337138vboxsync units, \
eb6509c759a277527b791759757d9d9a5b1c5e32vboxsync dsc, \
eb6509c759a277527b791759757d9d9a5b1c5e32vboxsync "/Drivers/NAT%u/" #name, \
eb6509c759a277527b791759757d9d9a5b1c5e32vboxsync pDrvIns->iInstance); \
eb6509c759a277527b791759757d9d9a5b1c5e32vboxsync } while (0)
169154fcc4bae3ca771f32a6c11cc0a06f04d505vboxsync# define DEREGISTER_COUNTER(name) PDMDrvHlpSTAMDeregister(pDrvIns, &pData->Stat ## name)
eb6509c759a277527b791759757d9d9a5b1c5e32vboxsync# else
eb6509c759a277527b791759757d9d9a5b1c5e32vboxsync# define REGISTER_COUNTER(name, type, units, dsc) do {} while (0)
eb6509c759a277527b791759757d9d9a5b1c5e32vboxsync# define DEREGISTER_COUNTER(name) do {} while (0)
eb6509c759a277527b791759757d9d9a5b1c5e32vboxsync# endif
eb6509c759a277527b791759757d9d9a5b1c5e32vboxsync# undef COUNTERS_INIT
eb6509c759a277527b791759757d9d9a5b1c5e32vboxsync#endif
eb6509c759a277527b791759757d9d9a5b1c5e32vboxsync
eb6509c759a277527b791759757d9d9a5b1c5e32vboxsync#ifndef COUNTERS_INIT
eb6509c759a277527b791759757d9d9a5b1c5e32vboxsync# if !defined(PROFILE_COUNTER) && !defined(DRV_PROFILE_COUNTER)
eb6509c759a277527b791759757d9d9a5b1c5e32vboxsync# error (DRV_)PROFILE_COUNTER is not defied
eb6509c759a277527b791759757d9d9a5b1c5e32vboxsync# endif
eb6509c759a277527b791759757d9d9a5b1c5e32vboxsync# if !defined(COUNTING_COUNTER) && !defined(DRV_COUNTING_COUNTER)
eb6509c759a277527b791759757d9d9a5b1c5e32vboxsync# error (DRV_)COUNTING_COUNTER is not defined
169154fcc4bae3ca771f32a6c11cc0a06f04d505vboxsync# endif
eb6509c759a277527b791759757d9d9a5b1c5e32vboxsync
eb6509c759a277527b791759757d9d9a5b1c5e32vboxsync/*
eb6509c759a277527b791759757d9d9a5b1c5e32vboxsync * DRV_ prefixed are counters used in DrvNAT the rest are used in Slirp
eb6509c759a277527b791759757d9d9a5b1c5e32vboxsync */
eb6509c759a277527b791759757d9d9a5b1c5e32vboxsync# ifdef DRV_PROFILE_COUNTER
eb6509c759a277527b791759757d9d9a5b1c5e32vboxsync# define PROFILE_COUNTER(name, dsc) do {} while (0)
eb6509c759a277527b791759757d9d9a5b1c5e32vboxsync# endif
eb6509c759a277527b791759757d9d9a5b1c5e32vboxsync# ifdef DRV_COUNTING_COUNTER
eb6509c759a277527b791759757d9d9a5b1c5e32vboxsync# define COUNTING_COUNTER(name, dsc) do {} while (0)
e94d561018bd5f9e7a92dea86468500774b2d8ffvboxsync# endif
eb6509c759a277527b791759757d9d9a5b1c5e32vboxsync
eb6509c759a277527b791759757d9d9a5b1c5e32vboxsync# ifdef PROFILE_COUNTER
eb6509c759a277527b791759757d9d9a5b1c5e32vboxsync# define DRV_PROFILE_COUNTER(name, dsc) do {} while (0)
eb6509c759a277527b791759757d9d9a5b1c5e32vboxsync# endif
e94d561018bd5f9e7a92dea86468500774b2d8ffvboxsync# ifdef COUNTING_COUNTER
95ff7c92406f8e3cc892ec0ed9be7d06c49e302cvboxsync# define DRV_COUNTING_COUNTER(name, dsc) do {} while (0)
95ff7c92406f8e3cc892ec0ed9be7d06c49e302cvboxsync# endif
eb6509c759a277527b791759757d9d9a5b1c5e32vboxsync
eb6509c759a277527b791759757d9d9a5b1c5e32vboxsyncPROFILE_COUNTER(Fill, "Profiling slirp fills");
caff8bc1842e1ba69d4115103177264909cbb97bvboxsyncPROFILE_COUNTER(Poll, "Profiling slirp polls");
caff8bc1842e1ba69d4115103177264909cbb97bvboxsyncPROFILE_COUNTER(FastTimer, "Profiling slirp fast timer");
eeea67e86500e2fe13ace42b86653498e3d656aavboxsyncPROFILE_COUNTER(SlowTimer, "Profiling slirp slow timer");
caff8bc1842e1ba69d4115103177264909cbb97bvboxsyncPROFILE_COUNTER(IOwrite, "Profiling IO sowrite");
caff8bc1842e1ba69d4115103177264909cbb97bvboxsyncPROFILE_COUNTER(IOread, "Profiling IO soread");
4003a16c61cdf61979273c73fc02805967e57683vboxsync
COUNTING_COUNTER(TCP, "TCP sockets");
COUNTING_COUNTER(TCPHot, "TCP sockets active");
COUNTING_COUNTER(UDP, "UDP sockets");
COUNTING_COUNTER(UDPHot, "UDP sockets active");
COUNTING_COUNTER(IORead_in_1, "SB IORead_in_1");
COUNTING_COUNTER(IORead_in_1_bytes, "SB IORead_in_1_bytes");
COUNTING_COUNTER(IORead_in_2, "SB IORead_in_2");
COUNTING_COUNTER(IORead_in_2_1st_bytes, "SB IORead_in_2_1st_bytes");
COUNTING_COUNTER(IORead_in_2_2nd_bytes, "SB IORead_in_2_2nd_bytes");
COUNTING_COUNTER(IOWrite_in_1, "SB IOWrite_in_1");
COUNTING_COUNTER(IOWrite_in_1_bytes, "SB IOWrite_in_1_bytes");
COUNTING_COUNTER(IOWrite_in_2, "SB IOWrite_in_2");
COUNTING_COUNTER(IOWrite_in_2_1st_bytes, "SB IOWrite_in_2_1st_bytes");
COUNTING_COUNTER(IOWrite_in_2_2nd_bytes, "SB IOWrite_in_2_2nd_bytes");
COUNTING_COUNTER(IOWrite_no_w, "SB IOWrite_no_w");
COUNTING_COUNTER(IOWrite_rest, "SB IOWrite_rest");
COUNTING_COUNTER(IOWrite_rest_bytes, "SB IOWrite_rest_bytes");
PROFILE_COUNTER(IOSBAppend_pf, "Profiling sbuf::append common");
PROFILE_COUNTER(IOSBAppend_pf_wa, "Profiling sbuf::append all writen in network");
PROFILE_COUNTER(IOSBAppend_pf_wf, "Profiling sbuf::append writen fault");
PROFILE_COUNTER(IOSBAppend_pf_wp, "Profiling sbuf::append writen partly");
COUNTING_COUNTER(IOSBAppend, "SB: Append total");
COUNTING_COUNTER(IOSBAppend_wa, "SB: Append all is written to network ");
COUNTING_COUNTER(IOSBAppend_wf, "SB: Append nothing is written");
COUNTING_COUNTER(IOSBAppend_wp, "SB: Append is written partly");
COUNTING_COUNTER(IOSBAppend_zm, "SB: Append mbuf is zerro or less");
COUNTING_COUNTER(IOSBAppendSB, "SB: AppendSB total");
COUNTING_COUNTER(IOSBAppendSB_w_l_r, "SB: AppendSB (sb_wptr < sb_rptr)");
COUNTING_COUNTER(IOSBAppendSB_w_ge_r, "SB: AppendSB (sb_wptr >= sb_rptr)");
COUNTING_COUNTER(IOSBAppendSB_w_alter, "SB: AppendSB (altering of sb_wptr)");
COUNTING_COUNTER(TCP_retransmit, "TCP::retransmit");
PROFILE_COUNTER(TCP_reassamble, "TCP::reasamble");
PROFILE_COUNTER(TCP_input, "TCP::input");
PROFILE_COUNTER(IP_input, "IP::input");
PROFILE_COUNTER(IP_output, "IP::output");
PROFILE_COUNTER(IF_encap, "IF::encap");
PROFILE_COUNTER(ALIAS_input, "ALIAS::input");
PROFILE_COUNTER(ALIAS_output, "ALIAS::output");
#endif /*!COUNTERS_INIT*/
#ifdef DRV_COUNTING_COUNTER
# undef DRV_COUNTING_COUNTER
#endif
#ifdef DRV_PROFILE_COUNTER
# undef DRV_PROFILE_COUNTER
#endif
#ifdef COUNTING_COUNTER
# undef COUNTING_COUNTER
#endif
#ifdef PROFILE_COUNTER
# undef PROFILE_COUNTER
#endif