1 | /** $Id: counters.h 106061 2024-09-16 14:03:52Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * Counters macro invocation template.
|
---|
4 | *
|
---|
5 | * This is included with different PROFILE_COUNTER and COUNTING_COUNTER
|
---|
6 | * implementations to instantiate data members, create function prototypes and
|
---|
7 | * implement these prototypes.
|
---|
8 | */
|
---|
9 |
|
---|
10 | /*
|
---|
11 | * Copyright (C) 2007-2024 Oracle and/or its affiliates.
|
---|
12 | *
|
---|
13 | * This file is part of VirtualBox base platform packages, as
|
---|
14 | * available from https://www.virtualbox.org.
|
---|
15 | *
|
---|
16 | * This program is free software; you can redistribute it and/or
|
---|
17 | * modify it under the terms of the GNU General Public License
|
---|
18 | * as published by the Free Software Foundation, in version 3 of the
|
---|
19 | * License.
|
---|
20 | *
|
---|
21 | * This program is distributed in the hope that it will be useful, but
|
---|
22 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
23 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
24 | * General Public License for more details.
|
---|
25 | *
|
---|
26 | * You should have received a copy of the GNU General Public License
|
---|
27 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
28 | *
|
---|
29 | * SPDX-License-Identifier: GPL-3.0-only
|
---|
30 | */
|
---|
31 |
|
---|
32 | /*
|
---|
33 | * COUNTERS_INIT is used before using counters.h to declare helping macro
|
---|
34 | * definitions for (de-)registering counters
|
---|
35 | */
|
---|
36 | #ifndef COUNTERS_H
|
---|
37 | # define COUNTERS_H
|
---|
38 | # if defined(VBOX_WITH_STATISTICS)
|
---|
39 | # define REGISTER_COUNTER(name, storage, type, units, dsc) \
|
---|
40 | do { \
|
---|
41 | PDMDrvHlpSTAMRegisterF(pDrvIns, \
|
---|
42 | &(storage)->Stat ## name, \
|
---|
43 | type, \
|
---|
44 | STAMVISIBILITY_ALWAYS, \
|
---|
45 | units, \
|
---|
46 | dsc, \
|
---|
47 | "/Drivers/NAT%u/" #name, \
|
---|
48 | pDrvIns->iInstance); \
|
---|
49 | } while (0)
|
---|
50 | # define DEREGISTER_COUNTER(name, storage) PDMDrvHlpSTAMDeregister(pDrvIns, &(storage)->Stat ## name)
|
---|
51 | # else
|
---|
52 | # define REGISTER_COUNTER(name, storage, type, units, dsc) do {} while (0)
|
---|
53 | # define DEREGISTER_COUNTER(name, storage) do {} while (0)
|
---|
54 | # endif
|
---|
55 | #else
|
---|
56 | # undef COUNTERS_INIT
|
---|
57 | #endif
|
---|
58 |
|
---|
59 | #ifndef COUNTERS_INIT
|
---|
60 | # if !defined(PROFILE_COUNTER) && !defined(DRV_PROFILE_COUNTER)
|
---|
61 | # error (DRV_)PROFILE_COUNTER is not defied
|
---|
62 | # endif
|
---|
63 | # if !defined(COUNTING_COUNTER) && !defined(DRV_COUNTING_COUNTER)
|
---|
64 | # error (DRV_)COUNTING_COUNTER is not defined
|
---|
65 | # endif
|
---|
66 |
|
---|
67 | /*
|
---|
68 | * DRV_ prefixed are counters used in DrvNAT the rest are used in Slirp
|
---|
69 | */
|
---|
70 |
|
---|
71 | # if defined(PROFILE_COUNTER) || defined(COUNTING_COUNTER)
|
---|
72 | PROFILE_COUNTER(Fill, "Profiling slirp fills");
|
---|
73 | PROFILE_COUNTER(Poll, "Profiling slirp polls");
|
---|
74 | PROFILE_COUNTER(FastTimer, "Profiling slirp fast timer");
|
---|
75 | PROFILE_COUNTER(SlowTimer, "Profiling slirp slow timer");
|
---|
76 | PROFILE_COUNTER(IOwrite, "Profiling IO sowrite");
|
---|
77 | PROFILE_COUNTER(IOread, "Profiling IO soread");
|
---|
78 |
|
---|
79 | COUNTING_COUNTER(TCP, "TCP sockets");
|
---|
80 | COUNTING_COUNTER(TCPHot, "TCP sockets active");
|
---|
81 | COUNTING_COUNTER(UDP, "UDP sockets");
|
---|
82 | COUNTING_COUNTER(UDPHot, "UDP sockets active");
|
---|
83 |
|
---|
84 | COUNTING_COUNTER(IORead_in_1, "SB IORead_in_1");
|
---|
85 | COUNTING_COUNTER(IORead_in_1_bytes, "SB IORead_in_1_bytes");
|
---|
86 | COUNTING_COUNTER(IORead_in_2, "SB IORead_in_2");
|
---|
87 | COUNTING_COUNTER(IORead_in_2_1st_bytes, "SB IORead_in_2_1st_bytes");
|
---|
88 | COUNTING_COUNTER(IORead_in_2_2nd_bytes, "SB IORead_in_2_2nd_bytes");
|
---|
89 | COUNTING_COUNTER(IOWrite_in_1, "SB IOWrite_in_1");
|
---|
90 | COUNTING_COUNTER(IOWrite_in_1_bytes, "SB IOWrite_in_1_bytes");
|
---|
91 | COUNTING_COUNTER(IOWrite_in_2, "SB IOWrite_in_2");
|
---|
92 | COUNTING_COUNTER(IOWrite_in_2_1st_bytes, "SB IOWrite_in_2_1st_bytes");
|
---|
93 | COUNTING_COUNTER(IOWrite_in_2_2nd_bytes, "SB IOWrite_in_2_2nd_bytes");
|
---|
94 | COUNTING_COUNTER(IOWrite_no_w, "SB IOWrite_no_w");
|
---|
95 | COUNTING_COUNTER(IOWrite_rest, "SB IOWrite_rest");
|
---|
96 | COUNTING_COUNTER(IOWrite_rest_bytes, "SB IOWrite_rest_bytes");
|
---|
97 |
|
---|
98 | PROFILE_COUNTER(IOSBAppend_pf, "Profiling sbuf::append common");
|
---|
99 | PROFILE_COUNTER(IOSBAppend_pf_wa, "Profiling sbuf::append all writen in network");
|
---|
100 | PROFILE_COUNTER(IOSBAppend_pf_wf, "Profiling sbuf::append writen fault");
|
---|
101 | PROFILE_COUNTER(IOSBAppend_pf_wp, "Profiling sbuf::append writen partly");
|
---|
102 | COUNTING_COUNTER(IOSBAppend, "SB: Append total");
|
---|
103 | COUNTING_COUNTER(IOSBAppend_wa, "SB: Append all is written to network ");
|
---|
104 | COUNTING_COUNTER(IOSBAppend_wf, "SB: Append nothing is written");
|
---|
105 | COUNTING_COUNTER(IOSBAppend_wp, "SB: Append is written partly");
|
---|
106 | COUNTING_COUNTER(IOSBAppend_zm, "SB: Append mbuf is zerro or less");
|
---|
107 |
|
---|
108 | COUNTING_COUNTER(IOSBAppendSB, "SB: AppendSB total");
|
---|
109 | COUNTING_COUNTER(IOSBAppendSB_w_l_r, "SB: AppendSB (sb_wptr < sb_rptr)");
|
---|
110 | COUNTING_COUNTER(IOSBAppendSB_w_ge_r, "SB: AppendSB (sb_wptr >= sb_rptr)");
|
---|
111 | COUNTING_COUNTER(IOSBAppendSB_w_alter, "SB: AppendSB (altering of sb_wptr)");
|
---|
112 | COUNTING_COUNTER(MBufAllocation,"MBUF::shows number of mbufs in used list");
|
---|
113 |
|
---|
114 | COUNTING_COUNTER(TCP_retransmit, "TCP::retransmit");
|
---|
115 |
|
---|
116 | PROFILE_COUNTER(TCP_reassamble, "TCP::reasamble");
|
---|
117 | PROFILE_COUNTER(TCP_input, "TCP::input");
|
---|
118 | PROFILE_COUNTER(IP_input, "IP::input");
|
---|
119 | PROFILE_COUNTER(IP_output, "IP::output");
|
---|
120 | PROFILE_COUNTER(IF_encap, "IF::encap");
|
---|
121 | PROFILE_COUNTER(ALIAS_input, "ALIAS::input");
|
---|
122 | PROFILE_COUNTER(ALIAS_output, "ALIAS::output");
|
---|
123 |
|
---|
124 | # else
|
---|
125 | /*DrvNAT.cpp*/
|
---|
126 | DRV_COUNTING_COUNTER(NATRecvWakeups, "counting wakeups of NAT RX thread");
|
---|
127 | DRV_PROFILE_COUNTER(NATRecv,"Time spent in NATRecv worker");
|
---|
128 | DRV_PROFILE_COUNTER(NATRecvWait,"Time spent in NATRecv worker in waiting of free RX buffers");
|
---|
129 | DRV_COUNTING_COUNTER(QueuePktSent, "counting packet sent via PDM Queue");
|
---|
130 | DRV_COUNTING_COUNTER(QueuePktDropped, "counting packet drops by PDM Queue");
|
---|
131 | DRV_COUNTING_COUNTER(ConsumerFalse, "counting consumer's reject number to process the queue's item");
|
---|
132 | # endif
|
---|
133 | #endif /*!COUNTERS_INIT*/
|
---|
134 |
|
---|
135 | #ifdef DRV_COUNTING_COUNTER
|
---|
136 | # undef DRV_COUNTING_COUNTER
|
---|
137 | #endif
|
---|
138 |
|
---|
139 | #ifdef DRV_PROFILE_COUNTER
|
---|
140 | # undef DRV_PROFILE_COUNTER
|
---|
141 | #endif
|
---|
142 |
|
---|
143 | #ifdef COUNTING_COUNTER
|
---|
144 | # undef COUNTING_COUNTER
|
---|
145 | #endif
|
---|
146 |
|
---|
147 | #ifdef PROFILE_COUNTER
|
---|
148 | # undef PROFILE_COUNTER
|
---|
149 | #endif
|
---|