xref: /xnu-8796.121.2/bsd/skywalk/os_stats_private.h (revision c54f35ca767986246321eb901baf8f5ff7923f6a)
1 /*
2  * Copyright (c) 2015-2021 Apple Inc. All rights reserved.
3  *
4  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5  *
6  * This file contains Original Code and/or Modifications of Original Code
7  * as defined in and that are subject to the Apple Public Source License
8  * Version 2.0 (the 'License'). You may not use this file except in
9  * compliance with the License. The rights granted to you under the License
10  * may not be used to create, or enable the creation or redistribution of,
11  * unlawful or unlicensed copies of an Apple operating system, or to
12  * circumvent, violate, or enable the circumvention or violation of, any
13  * terms of an Apple operating system software license agreement.
14  *
15  * Please obtain a copy of the License at
16  * http://www.opensource.apple.com/apsl/ and read it before using this file.
17  *
18  * The Original Code and all software distributed under the License are
19  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22  * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23  * Please see the License for the specific language governing rights and
24  * limitations under the License.
25  *
26  * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27  */
28 
29 #ifndef _SKYWALK_OS_STATS_H_
30 #define _SKYWALK_OS_STATS_H_
31 
32 #if defined(PRIVATE) || defined(BSD_KERNEL_PRIVATE)
33 #include <skywalk/os_channel.h>
34 #include <skywalk/os_nexus_private.h>
35 #include <skywalk/os_packet.h>
36 #include <netinet/in.h>
37 #include <netinet/in_stat.h>
38 #include <net/if.h>
39 #include <net/ethernet.h>
40 
41 /*
42  * [Intro]
43  * This file defines new statistics infrastructure using enum and uin64_t array
44  * for skywalk. BSD network stack statistics definition would be kept for
45  * backward compatibility.
46  *
47  * This new scheme has several advantages over legacy statistics definition.
48  *  1. Using array based data structure allows efficient folding with vector
49  *     instructions.
50  *  2. It also allows simple indexing of statistics field using enum value
51  *     rather than struct field name.
52  *  3. Coupled with descriptive string per statistics enum, it allows convenient
53  *     printing.
54  *
55  * The new statistics enum and data structure follows naming convention as:
56  *  1. It should resemble legacy names to make transition easy.
57  *  2. It should be easily distinguishable from legacy data structure.
58  *
59  *
60  * [Naming]
61  * The new data structures are named with suffix _stats (plural) v.s legacy stat
62  * and are always in snake case, e.g.
63  *          New                      |   Legacy
64  *          -------------------------+--------------------------
65  *          ip_stats                 |   ipstat
66  *          ip6_stats                |   ip6stat
67  *          tcp_stats                |   tcpstat
68  *          if_tcp_ecn_stats         |   if_tcp_ecn_stat
69  *          if_tcp_ecn_perf_stats    |   if_tcp_ecn_perf_stat
70  *          udp_stats                |   udpstat
71  *
72  *
73  * Enums are named as <stats_family>_<type>, e.g.
74  *          New                      |   Legacy
75  *          -------------------------+--------------------------
76  *          IP_STATS_TOTAL           |   ipstat.ips_total
77  *          TCP_STATS_CONNATTEMPT    |   tcpstat.tcps_connattempt
78  *
79  *
80  * [Usage]
81  * Declare a statistics data structure:
82  *
83  *     struct ip_stats sample_ip_stats;
84  *
85  * To increment a statistics value by one:
86  *
87  *     STATS_INC(&sample_ip_stats, IP_STATS_TOTAL);
88  *
89  * To add to a statistics value by a certain value:
90  *
91  *     STATS_ADD(&sample_ip_stats, IP_STATS_TOTAL, n_pkts);
92  *
93  * To fold one statistics data structure into another one:
94  *
95  *     ip_stats_fold(&sample_ip_stats, &another_ip_stats);
96  *
97  * To reset statistics:
98  *
99  *     ip_stats_reset(&sample_ip_stats);
100  *
101  *
102  * [Note]
103  * Some legacy stats member has been removed for convenience reason, e.g.
104  *
105  *     ip6stat.ip6s_nxthist[256]
106  *     ip6stat.ip6s_sources_sameif[SCOPE6_ID_MAX];
107  *
108  * are removed, as they don't have easy mapping into array based statistics
109  * scheme and doesn't have explicit usage within the kernel.
110  * That's been said, those are treated as exceptions and could be reconsidered
111  * if they are needed in the future.
112  *
113  *
114  * [Adding Stats]
115  * To add new stats definition, a X-Macro table and STATS_REGISTER is needed.
116  *
117  *     #define NEW_STATS_TABLE(X)\
118  *         X(sub_type_1, "sub_type_1_short_name", "sub_type_1_fmt_string")\
119  *         X(sub_type_2, "sub_type_2_short_name", "sub_type_2_fmt_string")\
120  *         X(__NEW_STATS_MAX, "", "")
121  *
122  *     STATS_REGISTER(new_stats, NEW_STATS);
123  *
124  *  where new_stats is the lower case name, and NEW_STATS is its upper case.
125  *  The following would be generated by STATS_REGISTER Macro:
126  *
127  *     enum _new_stats {
128  *         sub_type_1,
129  *         sub_type_2,
130  *         __NEW_STATS_MAX,
131  *     };
132  *
133  *     struct new_stats {
134  *         uint64_t _arr[__NEW_STATS_NEW];
135  *     }
136  *
137  *     static inline const char* new_stats_str(enum _new_stats);
138  *     static inline const char* new_stats_fmt(enum _new_stats);
139  *
140  *     static inline void __attribute__((always_inline))
141  *         new_stats_fold(struct new_stats *dst, struct new_stats *src);
142  *
143  *     static inline void __attribute__((always_inline))
144  *         new_stats_reset(struct new_stats *s);
145  *
146  * The fmt_string should conform to printf convention. Note here as uint64_t is
147  * used to store stats value, `%llu` is used to format the print value (PRIu64
148  * could be used but since long long is guaranteed to be 64bit long, casting
149  * to llu should work well without introducing definitions from `inttypes.h`.
150  */
151 
152 /* BEGIN CSTYLED */
153 
154 /* ip stats definitions */
155 #define IP_STATS_TABLE(X)       \
156 	/* Input stats */      \
157 	X(IP_STATS_TOTAL,		"TotalRcvd",	"\t%llu total packet received\n")       \
158 	X(IP_STATS_BADSUM,		"BadCsum",	"\t\t%llu bad header checksum\n")       \
159 	X(IP_STATS_RCV_SWCSUM,		"RcvSWCsumPkt",	"\t\t%llu header checksummed in software")      \
160 	X(IP_STATS_RCV_SWCSUM_BYTES,	"RcvSWCsumByte"," (%llu byte)\n")       \
161 	X(IP_STATS_TOOSMALL,		"DataTooSmall",	"\t\t%llu with size smaller than minimum\n")\
162 	X(IP_STATS_TOOSHORT,		"PktTooShort",	"\t\t%llu with data size < data length\n")      \
163 	X(IP_STATS_ADJ,			"TotalAdj",	"\t\t%llu with data size > data length\n")      \
164 	X(IP_STATS_ADJ_HWCSUM_CLR,	"HWCsumDisc",	"\t\t\t%llu packet forced to software checksum\n")      \
165 	X(IP_STATS_TOOLONG,		"TooLong",	"\t\t%llu with ip length > max ip packet size\n")       \
166 	X(IP_STATS_BADHLEN,		"BadHdrLen",	"\t\t%llu with header length < data size\n")    \
167 	X(IP_STATS_BADLEN,		"BadLen",	"\t\t%llu with data length < header length\n")  \
168 	X(IP_STATS_BADOPTIONS,		"BadOptions",	"\t\t%llu with bad options\n")  \
169 	X(IP_STATS_BADVERS,		"BadVer",	"\t\t%llu with incorrect version number\n")     \
170 	X(IP_STATS_FRAGMENTS,		"FragRcvd",	"\t\t%llu fragment received\n") \
171 	X(IP_STATS_FRAGDROPPED,		"FragDrop",	"\t\t\t%llu dropped (dup or out of space)\n")   \
172 	X(IP_STATS_FRAGTIMEOUT,		"FragTimeO",	"\t\t\t%llu dropped after timeout\n")   \
173 	X(IP_STATS_REASSEMBLED,		"Reassembled",	"\t\t\t%llu reassembled ok\n")  \
174 	X(IP_STATS_DELIVERED,		"Delivered",	"\t\t%llu packet for this host\n")      \
175 	X(IP_STATS_NOPROTO,		"UnkwnProto",	"\t\t%llu packet for unknown/unsupported protocol\n")   \
176 	X(IP_STATS_FORWARD,		"Fwd",		"\t\t%llu packet forwarded")    \
177 	X(IP_STATS_FASTFORWARD,		"FastFwd",	" (%llu packet fast forwarded)\n")      \
178 	X(IP_STATS_CANTFORWARD,		"CantFwd",	"\t\t%llu packet not forwardable\n")    \
179 	X(IP_STATS_NOTMEMBER,		"UnRegGroup",	"\t\t%llu packet received for unknown multicast group\n")       \
180 	X(IP_STATS_REDIRECTSENT,	"FwdSameNet",	"\t\t%llu redirect sent\n")     \
181 	X(IP_STATS_RXC_COLLISIONS,	"RxChnColl",	"\t\t%llu input packet not chained due to collision\n") \
182 	X(IP_STATS_RXC_CHAINED,		"RxChn",	"\t\t%llu input packet processed in a chain\n") \
183 	X(IP_STATS_RXC_NOTCHAIN,	"RxBypChn",	"\t\t%llu input packet unable to chain\n")      \
184 	X(IP_STATS_RXC_CHAINSZ_GT2,	"RxChnGT2",	"\t\t%llu input packet chain processed with length greater than 2\n")   \
185 	X(IP_STATS_RXC_CHAINSZ_GT4,	"RxChnGT4",	"\t\t%llu input packet chain processed with length greater than 4\n")   \
186         \
187 	/* Output stats */      \
188 	X(IP_STATS_LOCALOUT,		"LocalOut",	"\t%llu packet sent from this host\n")  \
189 	X(IP_STATS_RAWOUT,		"RawPktOut",	"\t\t%llu packet sent with fabricated ip header\n")     \
190 	X(IP_STATS_ODROPPED,		"DropNoBuf",	"\t\t%llu output packet dropped due to no bufs, etc.\n")        \
191 	X(IP_STATS_NOROUTE,		"NoRoute",	"\t\t%llu output packet discarded due to no route\n")   \
192 	X(IP_STATS_FRAGMENTED,		"Fragmented",	"\t\t%llu output datagram fragmented\n")        \
193 	X(IP_STATS_OFRAGMENTS,		"OutFraged",	"\t\t%llu fragment created\n")  \
194 	X(IP_STATS_CANTFRAG,		"CantFrag",	"\t\t%llu datagram that can't be fragmented\n") \
195 	X(IP_STATS_NOGIF,		"NoGif",	"\t\t%llu tunneling packet that can't find gif\n")      \
196 	X(IP_STATS_BADADDR,		"BadAddr",	"\t\t%llu datagram with bad address in header\n")       \
197 	X(IP_STATS_PKTDROPCNTRL,	"DropNoCtl",	"\t\t%llu packet dropped due to no bufs for control data\n")    \
198 	X(IP_STATS_SND_SWCSUM,		"SndSWCsumPkt",	"\t\t%llu header checksummed in software")      \
199 	X(IP_STATS_SND_SWCSUM_BYTES,	"SndSWCsumByte"," (%llu byte)\n")       \
200 	X(IP_STATS_RXC_NOTLIST,		"IPInPkt",	"\t\t%llu input packet did not go through list processing path\n")      \
201 	X(__IP_STATS_MAX,		"",		"end of ip stats")
202 
203 /* ipv6 stats definitions */
204 #define IP6_STATS_TABLE(X)      \
205 	/* Input Stats */       \
206 	X(IP6_STATS_TOTAL,		"TotalRcvd",	"\t%llu total packet received\n")       \
207 	X(IP6_STATS_TOOSMALL,		"DataTooSmall",	"\t\t%llu with size smaller than minimum\n")    \
208 	X(IP6_STATS_TOOSHORT,		"PktTooShort",	"\t\t%llu with data size < data length\n")      \
209 	X(IP6_STATS_ADJ,		"TotalAdj",	"\t\t%llu with data size > data length\n")      \
210 	X(IP6_STATS_ADJ_HWCSUM_CLR,	"HWCsumDisc",	"\t\t\t%llu packet forced to software checksum\n")      \
211 	X(IP6_STATS_BADOPTIONS,		"BadOptions",	"\t\t%llu with bad options\n")  \
212 	X(IP6_STATS_BADVERS,		"BadVer",	"\t\t%llu with incorrect version number\n")     \
213 	X(IP6_STATS_FRAGMENTS,		"FrafRcvd",	"\t\t%llu fragment received\n") \
214 	X(IP6_STATS_FRAGDROPPED,	"FragDrop",	"\t\t\t%llu dropped (dup or out of space)\n")   \
215 	X(IP6_STATS_FRAGTIMEOUT,	"FragTimeO",	"\t\t\t%llu dropped after timeout\n")   \
216 	X(IP6_STATS_FRAGOVERFLOW,	"FragOverFlow",	"\t\t\t%llu exceeded limit\n")  \
217 	X(IP6_STATS_REASSEMBLED,	"FragReassembled","\t\t\t%llu reassembled ok\n")                \
218 	X(IP6_STATS_ATMFRAG_RCVD,	"RAtomicFrag",	"\t\t\t%llu atomic fragments received\n")               \
219 	X(IP6_STATS_DELIVERED,		"Delivered",	"\t\t%llu packet for this host\n")      \
220 	X(IP6_STATS_FORWARD,		"Fwd",		"\t\t%llu packet forwarded\n")  \
221 	X(IP6_STATS_CANTFORWARD,	"CantFwd",	"\t\t%llu packet not forwardable\n")    \
222 	X(IP6_STATS_REDIRECTSENT,	"RedirectSent",	"\t\t%llu redirect sent\n")     \
223 	X(IP6_STATS_NOTMEMBER,		"NoMCGrp",	"\t\t%llu multicast packet which we don't join\n")      \
224 	X(IP6_STATS_EXTHDRTOOLONG,	"ExtHdrNotCont","\t\t\t%llu packet whose headers are not continuous\n") \
225 	X(IP6_STATS_NOGIF,		"NoGif",	"\t\t%llu tunneling packet that can't find gif\n")      \
226 	X(IP6_STATS_TOOMANYHDR,		"TooManyHdr",	"\t\t%llu packet discarded due to too may headers\n")   \
227 	X(IP6_STATS_FORWARD_CACHEHIT,	"FwdCacheHit",	"\t\t%llu forward cache hit\n") \
228 	X(IP6_STATS_FORWARD_CACHEMISS,	"FwdCacheMiss",	"\t\t%llu forward cache miss\n")        \
229 	X(IP6_STATS_PKTDROPCNTRL,	"DropNoCtl",	"\t\t%llu packet dropped due to no bufs for control data\n")    \
230 	/* Output stats */      \
231 	X(IP6_STATS_LOCALOUT,		"LocalOut",	"\t%llu packet sent from this host\n")  \
232 	X(IP6_STATS_RAWOUT,		"RawPktOut",	"\t\t%llu packet sent with fabricated ip header\n")     \
233 	X(IP6_STATS_ODROPPED,		"DropNoBuf",	"\t\t%llu output packet dropped due to no bufs, etc.\n")        \
234 	X(IP6_STATS_NOROUTE,		"NoRoute",	"\t\t%llu output packet discarded due to no route\n")   \
235 	X(IP6_STATS_FRAGMENTED,		"Fragmented",	"\t\t%llu output datagram fragmented\n")        \
236 	X(IP6_STATS_OFRAGMENTS,		"OutFraged",	"\t\t%llu fragment created\n")  \
237 	X(IP6_STATS_CANTFRAG,		"CantFrag",	"\t\t%llu datagram that can't be fragmented\n")\
238 	X(IP6_STATS_BADSCOPE,		"BadScope",	"\t\t%llu packet that violated scope rules\n")  \
239 	X(IP6_STATS_SOURCES_NONE,	"AddrSelFail",	"\t\t%llu failure of source address selection\n")       \
240 	X(IP6_STATS_DAD_COLLIDE,	"DADColl",	"\t\t%llu duplicate address detection collision\n")     \
241 	X(IP6_STATS_DAD_LOOPCOUNT,	"DADLoop",	"\t\t%llu duplicate address detection NS loop\n")       \
242 	X(IP6_STATS_SOURCES_SKIP6_EXPENSIVE_SECONDARY_IF,"Ign2ndIf",	"\t\t%llu time ignored source on secondary expensive I/F\n")    \
243 	X(__IP6_STATS_MAX,		"",		"end of ipv6 stats")
244 
245 /* tcp stats definitions */
246 #define TCP_STATS_TABLE(X)      \
247 	/* Output stats */      \
248 	X(TCP_STATS_SNDTOTAL,		"SndTotalPkt",	"\t%llu packet sent\n") \
249 	X(TCP_STATS_SNDPACK,		"SndTotalDP",	"\t\t%llu data packet") \
250 	X(TCP_STATS_SNDBYTE,		"SndDataByte",	" (%llu byte)\n")       \
251 	X(TCP_STATS_SNDREXMITPACK,	"SndDPktReXmt",	"\t\t%llu data packet retransmitted")   \
252 	X(TCP_STATS_SNDREXMITBYTE,	"SndDByteReXmt"," (%llu byte)\n")       \
253 	X(TCP_STATS_MTURESENT,		"MTUReSnd",	"\t\t%llu resend initiated by MTU discovery\n") \
254 	X(TCP_STATS_SNDACKS,		"SndAck",	"\t\t%llu ack-only packet")     \
255 	X(TCP_STATS_DELACK,		"DelayAck",	" (%llu delayed)\n")    \
256 	X(TCP_STATS_SNDURG,		"SndURG",	"\t\t%llu URG only packet\n")   \
257 	X(TCP_STATS_SNDPROBE,		"SndWinProb",	"\t\t%llu window probe packet\n")       \
258 	X(TCP_STATS_SNDWINUP,		"SndWinUpd",	"\t\t%llu window update packet\n")      \
259 	X(TCP_STATS_SNDCTRL,		"SndCtlPkt",	"\t\t%llu control packet\n")    \
260 	X(TCP_STATS_FCHOLDPACKET,	"FlowCtlWh",	"\t\t%llu data packet sent after flow control\n")       \
261 	X(TCP_STATS_SYNCHALLENGE,	"SYNChallenge",	"\t\t%llu challenge ACK sent due to unexpected SYN\n")  \
262 	X(TCP_STATS_RSTCHALLENGE,	"RSTChallenge",	"\t\t%llu challenge ACK sent due to unexpected RST\n")  \
263 	X(TCP_STATS_SND_SWCSUM,		"SndSWCsumPkt",	"\t\t%llu checksummed in software")     \
264 	X(TCP_STATS_SND_SWCSUM_BYTES,	"SndSWCsumByte"," (%llu byte) over IPv4\n")     \
265 	X(TCP_STATS_SND6_SWCSUM,	"SndSWCsumPkt6","\t\t%llu checksummed in software")     \
266 	X(TCP_STATS_SND6_SWCSUM_BYTES,	"SndSWCsumByte6"," (%llu byte) over IPv6\n")    \
267         \
268 	/* Input stats */       \
269 	X(TCP_STATS_RCVTOTAL,		"RcvTotalPkt",	"\t%llu packet received\n")     \
270 	X(TCP_STATS_RCVACKPACK,		"RcvAckPkt",	"\t\t%llu ack") \
271 	X(TCP_STATS_RCVACKBYTE,		"RcvAckByte",	" (for %llu byte)\n")   \
272 	X(TCP_STATS_RCVDUPACK,		"RcvDupAck",	"\t\t%llu duplicate ack\n")     \
273 	X(TCP_STATS_RCVACKTOOMUCH,	"RcvAckUnSnd",	"\t\t%llu ack for unsent data\n")       \
274 	X(TCP_STATS_RCVPACK,		"RcvPktInSeq",	"\t\t%llu packet received in-sequence") \
275 	X(TCP_STATS_RCVBYTE,		"RcvBInSeq",	" (%llu byte)\n")       \
276 	X(TCP_STATS_RCVDUPPACK,		"RcvDupPkt",	"\t\t%llu completely duplicate packet") \
277 	X(TCP_STATS_RCVDUPBYTE,		"RcvDupByte",	" (%llu byte)\n")       \
278 	X(TCP_STATS_PAWSDROP,		"PAWSDrop",	"\t\t%llu old duplicate packet\n")      \
279 	X(TCP_STATS_RCVMEMDROP,		"RcvMemDrop",	"\t\t%llu received packet dropped due to low memory\n") \
280 	X(TCP_STATS_RCVPARTDUPPACK,	"RcvDupData",	"\t\t%llu packet with some dup. data")  \
281 	X(TCP_STATS_RCVPARTDUPBYTE,	"RcvPDupByte",	" (%llu byte duped)\n") \
282 	X(TCP_STATS_RCVOOPACK,		"RcvOOPkt",	"\t\t%llu out-of-order packet") \
283 	X(TCP_STATS_RCVOOBYTE,		"RcvOOByte",	" (%llu byte)\n")               \
284 	X(TCP_STATS_RCVPACKAFTERWIN,	"RcvAftWinPkt",	"\t\t%llu packet of data after window") \
285 	X(TCP_STATS_RCVBYTEAFTERWIN,	"RcvAftWinByte"," (%llu byte)\n")               \
286 	X(TCP_STATS_RCVWINPROBE,	"RcvWinProbPkt","\t\t%llu window probe\n")              \
287 	X(TCP_STATS_RCVWINUPD,		"RcvWinUpdPkt",	"\t\t%llu window update packet\n")              \
288 	X(TCP_STATS_RCVAFTERCLOSE,	"RcvAftCloPkt",	"\t\t%llu packet received after close\n")       \
289 	X(TCP_STATS_BADRST,		"BadRST",	"\t\t%llu bad reset\n") \
290 	X(TCP_STATS_RCVBADSUM,		"RcvBadCsum",	"\t\t%llu discarded for bad checksum\n")        \
291 	X(TCP_STATS_RCV_SWCSUM,		"RcvSWCsumPkt",	"\t\t%llu checksummed in software")     \
292 	X(TCP_STATS_RCV_SWCSUM_BYTES,	"RcvSWCsumByte"," (%llu byte) over IPv4\n")     \
293 	X(TCP_STATS_RCV6_SWCSUM,	"RcvSWCsumPkt6","\t\t%llu checksummed in software")     \
294 	X(TCP_STATS_RCV6_SWCSUM_BYTES,	"RcvSWCsumByte6"," (%llu byte) over IPv6\n")    \
295 	X(TCP_STATS_RCVBADOFF,		"RcvBadOff",	"\t\t%llu discarded for bad header offset field\n")     \
296 	X(TCP_STATS_RCVSHORT,		"RcvTooShort",	"\t\t%llu discarded because packet too short\n")        \
297 	X(TCP_STATS_CONNATTEMPT,	"ConnInit",	"\t\t%llu discarded because packet too short\n")        \
298         \
299 	/* Connection stats */  \
300 	X(TCP_STATS_ACCEPTS,		"ConnAcpt",	"\t%llu connection accept\n")   \
301 	X(TCP_STATS_BADSYN,		"BadSYN",	"\t%llu bad connection attempt\n")      \
302 	X(TCP_STATS_LISTENDROP,		"ListenDrop",	"\t%llu listen queue overflow\n")               \
303 	X(TCP_STATS_CONNECTS,		"ConnEst",	"\t%llu connection established (including accepts)\n")  \
304 	X(TCP_STATS_CLOSED,		"ConnClosed",	"\t%llu connection closed")     \
305 	X(TCP_STATS_DROPS,		"ConnDrop",	" (including %llu drop)\n")     \
306 	X(TCP_STATS_CACHEDRTT,		"RTTCacheUpd",	"\t\t%llu connection updated cached RTT on close\n")    \
307 	X(TCP_STATS_CACHEDRTTVAR,	"RTTVarCacheUpd","\t\t%llu connection updated cached RTT variance on close\n")  \
308 	X(TCP_STATS_CACHEDSSTHRESH,	"SSTholdCacheUpd","\t\t%llu connection updated cached ssthresh on close\n")     \
309 	X(TCP_STATS_CONNDROPS,		"EConnDrop",	"\t%llu embryonic connection dropped\n")        \
310 	X(TCP_STATS_RTTUPDATED,		"RTTUpdated",	"\t%llu segment updated rtt")   \
311 	X(TCP_STATS_SEGSTIMED,		"RTTTimed",	" (of %llu attempt)\n") \
312 	X(TCP_STATS_REXMTTIMEO,		"ReXmtTO",	"\t%llu retransmit timeout\n")  \
313 	X(TCP_STATS_TIMEOUTDROP,	"DropTO",	"\t\t%llu connection dropped by rexmit timeout\n")      \
314 	X(TCP_STATS_RXTFINDROP,		"ReXmtFINDrop",	"\t\t%llu connection dropped after retransmitting FIN\n")       \
315 	X(TCP_STATS_PERSISTTIMEO,	"PersistTO",	"\t%llu persist timeout\n")                     \
316 	X(TCP_STATS_PERSISTDROP,	"PersisStateTO","\t\t%llu connection dropped by persist timeout\n")     \
317 	X(TCP_STATS_KEEPTIMEO,		"KATO",		"\t%llu keepalive timeout\n")   \
318 	X(TCP_STATS_KEEPPROBE,		"KAProbe",	"\t\t%llu keepalive probe sent\n")      \
319 	X(TCP_STATS_KEEPDROPS,		"KADrop",	"\t\t%llu connection dropped by keepalive\n")   \
320 	X(TCP_STATS_PREDACK,		"PredAck",	"\t%llu correct ACK header prediction\n")       \
321 	X(TCP_STATS_PREDDAT,		"PredData",	"\t%llu correct data packet header prediction\n")       \
322 	X(TCP_STATS_PCBCACHEMISS,	"Pcb$Miss",	"\t%llu times pcb cahce miss")  \
323         \
324 	/* SACK related stats */        \
325 	X(TCP_STATS_SACK_RECOVERY_EPISODE,	"SACKRecEpi",	"\t%llu SACK recovery episode\n")       \
326 	X(TCP_STATS_SACK_REXMITS,	        "SACKReXmt",	"\t%llu segment rexmit in SACK recovery episodes\n")    \
327 	X(TCP_STATS_SACK_REXMIT_BYTES,		"SACKReXmtB",	"\t%llu byte rexmit in SACK recovery episodes\n")       \
328 	X(TCP_STATS_SACK_RCV_BLOCKS,		"SACKRcvBlk",	"\t%llu SACK option (SACK blocks) received\n")  \
329 	X(TCP_STATS_SACK_SEND_BLOCKS,		"SACKSntBlk",	"\t%llu SACK option (SACK blocks) sent\n")      \
330 	X(TCP_STATS_SACK_SBOVERFLOW,		"SACKSndBlkOF",	"\t%llu SACK scoreboard overflow\n")    \
331         \
332 	/* LRO related stats */ \
333 	X(TCP_STATS_COALESCED_PACK,		"CoalPkt",	"\t%llu LRO coalesced packet\n")        \
334 	X(TCP_STATS_FLOWTBL_FULL,		"FlowTblFull",	"\t\t%llu time LRO flow table was full\n")      \
335 	X(TCP_STATS_FLOWTBL_COLLISION,		"FlowTblColl",	"\t\t%llu collision in LRO flow table\n")               \
336 	X(TCP_STATS_LRO_TWOPACK,		"LRO2Pkt",	"\t\t%llu time LRO coalesced 2 packets\n")              \
337 	X(TCP_STATS_LRO_MULTPACK,		"LROMultiPkt",	"\t\t%llu time LRO coalesced 3 or 4 packets\n") \
338 	X(TCP_STATS_LRO_LARGEPACK,		"LROLargePkt",	"\t\t%llu time LRO coalesced 5 or more packets\n")      \
339         \
340 	X(TCP_STATS_LIMITED_TXT,		"LimitedXmt",	"\t%llu limited transmit done\n")               \
341 	X(TCP_STATS_EARLY_REXMT,		"EarlyReXmt",	"\t%llu early retransmit done\n")               \
342 	X(TCP_STATS_SACK_ACKADV,		"SACKAdvAck",	"\t%llu time cumulative ack advanced along with SACK\n")        \
343 	X(TCP_STATS_PTO,			"ProbTO",	"\t%llu probe timeout\n")               \
344 	X(TCP_STATS_RTO_AFTER_PTO,		"RTOAfProb",	"\t\t%llu time retransmit timeout triggered after probe\n")     \
345 	X(TCP_STATS_PROBE_IF,			"ProbeIF",	"\t\t%llu time probe packets were sent for an interface\n")     \
346 	X(TCP_STATS_PROBE_IF_CONFLICT,		"ProbeIFConfl",	"\t\t%llu time couldn't send probe packets for an interface\n") \
347 	X(TCP_STATS_TLP_RECOVERY,		"TLPFastRecvr", "\t\t%llu time fast recovery after tail loss\n")        \
348 	X(TCP_STATS_TLP_RECOVERLASTPKT,		"TLPRecvrLPkt",	"\t\t%llu time recovered last packet \n")       \
349 	X(TCP_STATS_PTO_IN_RECOVERY,		"PTOInRecvr",	"\t\t%llu SACK based rescue retransmit\n")      \
350         \
351 	/* ECN related stats */ \
352 	X(TCP_STATS_ECN_CLIENT_SETUP,		"ECNCliSetup",	"\t%llu client connection attempted to negotiate ECN\n")        \
353 	X(TCP_STATS_ECN_CLIENT_SUCCESS,		"ECNNegoSucc",	"\t\t%llu client connection successfully negotiated ECN\n")     \
354 	X(TCP_STATS_ECN_NOT_SUPPORTED,		"ECNSvrNoSupt", "\t\t%llu time graceful fallback to Non-ECN connection\n")      \
355 	X(TCP_STATS_ECN_LOST_SYN,		"ECNLOSSSYN",	"\t\t%llu time lost ECN negotiating SYN, followed by retransmission\n") \
356 	X(TCP_STATS_ECN_SERVER_SETUP,		"ECNSvrSetup",	"\t\t%llu server connection attempted to negotiate ECN\n")      \
357 	X(TCP_STATS_ECN_SERVER_SUCCESS,		"ECNSvrSucc",	"\t\t%llu server connection successfully negotiate ECN\n")      \
358 	X(TCP_STATS_ECN_ACE_SYN_NOT_ECT,	"ACESynNotECT",	"\t\t%llu received AccECN SYN packet with Not-ECT\n")           \
359 	X(TCP_STATS_ECN_ACE_SYN_ECT1,		"ACESynECT1",	"\t\t%llu received AccECN SYN packet with ECT1\n")              \
360 	X(TCP_STATS_ECN_ACE_SYN_ECT0,		"ACESynECT0",	"\t\t%llu received AccECN SYN packet with ECT0\n")              \
361 	X(TCP_STATS_ECN_ACE_SYN_CE,		"ACESynCE",	"\t\t%llu received AccECN SYN packet with CE\n")                \
362 	X(TCP_STATS_ECN_LOST_SYNACK,		"ECNLossSYNACK","\t\t%llu time lost ECN negotiating SYN-ACK, followed by retransmission\n")     \
363 	X(TCP_STATS_ECN_RECV_CE,		"ECNRcv",	"\t\t%llu time received congestion experienced (CE) notification\n")    \
364 	X(TCP_STATS_ECN_RECV_ECE,		"ECNRcvECE",	"\t\t%llu time CWR was sent in response to ECE\n")      \
365 	X(TCP_STATS_ECN_SENT_ECE,		"ECNSndECE",	"\t\t%llu time sent ECE notification\n")        \
366 	X(TCP_STATS_ECN_ACE_RECV_CE,            "ACERcvECE",    "\t\t%llu CE count received in ACE field\n")      \
367 	X(TCP_STATS_ECN_CONN_RECV_CE,		"ECNConnRcvCE",	"\t\t%llu connection received CE atleast once\n")       \
368 	X(TCP_STATS_ECN_CONN_RECV_ECE,		"ECNConnRcvECE","\t\t%llu connection received ECE atleast once\n")      \
369 	X(TCP_STATS_ECN_CONN_PLNOCE,		"ECNConnPLNoCE","\t\t%llu connection using ECN have seen packet loss but no CE\n")      \
370 	X(TCP_STATS_ECN_CONN_PL_CE,		"ECNConnPLCE",	"\t\t%llu connection using ECN have seen packet loss and CE\n")         \
371 	X(TCP_STATS_ECN_CONN_NOPL_CE,		"ECNConnNoPLCE","\t\t%llu connection using ECN received CE but no packet loss\n")               \
372 	X(TCP_STATS_ECN_FALLBACK_SYNLOSS,	"ECNFbSYNLoss",	"\t\t%llu connection fell back to non-ECN due to SYN-loss\n")   \
373 	X(TCP_STATS_ECN_FALLBACK_REORDER,	"ECNFbReOrd",	"\t\t%llu connection fell back to non-ECN due to reordering\n") \
374 	X(TCP_STATS_ECN_FALLBACK_CE,		"ECNFbCE",	"\t\t%llu connection fell back to non-ECN due to excessive CE-markings\n")      \
375 	X(TCP_STATS_ECN_FALLBACK_DROPRST,	"ECNFbDrpRST",	"\t\t%llu ECN fallback caused by connection drop due to RST\n") \
376 	X(TCP_STATS_ECN_FALLBACK_DROPRXMT,	"ECNFbDrpReXmt","\t\t%llu ECN fallback due to drop after multiple retransmits\n")       \
377 	X(TCP_STATS_DETECT_REORDERING,		"ReOrdDetect",	"\t%llu time packet reordering was detected on a connection\n") \
378 	X(TCP_STATS_REORDERED_PKTS,		"ReOrdPkt",	"\t\t%llu time transmitted packets were reordered\n")   \
379 	X(TCP_STATS_DELAY_RECOVERY,		"DlyFastRecvr",	"\t\t%llu time fast recovery was delayed to handle reordering\n")               \
380 	X(TCP_STATS_AVOID_RXMT,			"AvoidReXmt",	"\t\t%llu time retransmission was avoided by delaying recovery\n")      \
381 	X(TCP_STATS_UNNECESSARY_RXMT,		"UnNeedReXmt",	"\t\t%llu retransmission not needed\n")\
382         \
383 	/* DSACK related statistics */  \
384 	X(TCP_STATS_DSACK_SENT,			"DSACKSnd",	"\t%llu time DSACK option was sent\n")  \
385 	X(TCP_STATS_DSACK_RECVD,		"DSACKRcv",	"\t\t%llu time DSACK option was received\n")    \
386 	X(TCP_STATS_DSACK_DISABLE,		"DSACKDisable",	"\t\t%llu time DSACK was disabled on a connection\n")   \
387 	X(TCP_STATS_DSACK_BADREXMT,		"DSACKBadReXmt","\t\t%llu time recovered from bad retransmission using DSACK\n")        \
388 	X(TCP_STATS_DSACK_ACKLOSS,		"DSACKAckLoss",	"\t\t%llu time ignored DSACK due to ack loss\n")        \
389 	X(TCP_STATS_DSACK_RECVD_OLD,		"DSACKRcvOld",	"\t\t%llu time ignored old DSACK options\n")    \
390 	X(TCP_STATS_PMTUDBH_REVERTED,		"PMTUDBHRevert","\t%llu time PMTU Blackhole detection, size reverted\n")        \
391 	X(TCP_STATS_DROP_AFTER_SLEEP,		"DropAPSleep",	"\t%llu connection were dropped after long sleep\n")    \
392         \
393 	/* TFO-related statistics */    \
394 	X(TCP_STATS_TFO_COOKIE_SENT,		"TFOCkSnd",	"\t%llu time a TFO-cookie has been announced\n")        \
395 	X(TCP_STATS_TFO_SYN_DATA_RCV,		"TFOSYNDataRcv","\t%llu SYN with data and a valid TFO-cookie have been received\n")     \
396 	X(TCP_STATS_TFO_COOKIE_REQ_RCV,		"TFOCkReqRcv",	"\t%llu SYN with TFO-cookie-request received\n")        \
397 	X(TCP_STATS_TFO_COOKIE_INVALID,		"TFOCkInv",	"\t%llu time an invalid TFO-cookie has been received\n")        \
398 	X(TCP_STATS_TFO_COOKIE_REQ,		"TFOCkReq",	"\t%llu time we requested a TFO-cookie\n")      \
399 	X(TCP_STATS_TFO_COOKIE_RCV,		"TFOCkRcv",	"\t\t%llu time the peer announced a TFO-cookie\n")      \
400 	X(TCP_STATS_TFO_SYN_DATA_SENT,		"TFOSYNDataSnd","\t%llu time we combined SYN with data and a TFO-cookie\n")     \
401 	X(TCP_STATS_TFO_SYN_DATA_ACKED,		"TDOSYNDataAck","\t\t%llu time our SYN with data has been acknowledged\n")      \
402 	X(TCP_STATS_TFO_SYN_LOSS,		"TFOSYNLoss",	"\t%llu time a connection-attempt with TFO fell back to regular TCP\n") \
403 	X(TCP_STATS_TFO_BLACKHOLE,		"TFOBlackhole",	"\t%llu time a TFO-connection blackhole'd\n")   \
404 	X(TCP_STATS_TFO_COOKIE_WRONG,		"TFOCkWrong",	"\t%llu time TFO-cookie we sent was wrong\n")   \
405 	X(TCP_STATS_TFO_NO_COOKIE_RCV,		"TFONoCkRcv",	"\t%llu time ee asked for a cookie but didn't get one\n")       \
406 	X(TCP_STATS_TFO_HEURISTICS_DISABLE,	"TFOHeuDisable","\t%llu time TFO got disabled due to heuristics\n")     \
407 	X(TCP_STATS_TFO_SNDBLACKHOLE,		"TFOSndBH",	"\t%llu time TFO got blackholed in the sending direction\n")    \
408 	X(TCP_STATS_MSS_TO_DEFAULT,		"MSSToDefault",	"\t%llu time maximum segment size was changed to default\n")    \
409 	X(TCP_STATS_MSS_TO_MEDIUM,		"MSSToMedium",	"\t%llu time maximum segment size was changed to medium\n")     \
410 	X(TCP_STATS_MSS_TO_LOW,			"MSSToLow",	"\t%llu time maximum segment size was changed to low\n")        \
411         \
412 	/* TCP timer statistics */      \
413 	X(TCP_STATS_TIMER_DRIFT_LE_1_MS,	"TmrDriftLE1Ms",	"\t%llu timer drift less or equal to 1 ms\n")   \
414 	X(TCP_STATS_TIMER_DRIFT_LE_10_MS,	"TmrDriftLE10Ms",	"\t%llu timer drift less or equal to 10 ms\n")  \
415 	X(TCP_STATS_TIMER_DRIFT_LE_20_MS,	"TmrDriftLE20Ms",	"\t%llu timer drift less or equal to 20 ms\n")  \
416 	X(TCP_STATS_TIMER_DRIFT_LE_50_MS,	"TmrDriftLE50Ms",	"\t%llu timer drift less or equal to 50 ms\n")  \
417 	X(TCP_STATS_TIMER_DRIFT_LE_100_MS,	"TmrDriftLE100Ms",	"\t%llu timer drift less or equal to 100 ms\n") \
418 	X(TCP_STATS_TIMER_DRIFT_LE_200_MS,	"TmrDriftLE200Ms",	"\t%llu timer drift less or equal to 200 ms\n") \
419 	X(TCP_STATS_TIMER_DRIFT_LE_500_MS,	"TmrDriftLE500Ms",	"\t%llu timer drift less or equal to 500 ms\n") \
420 	X(TCP_STATS_TIMER_DRIFT_LE_1000_MS,	"TmrDriftLE1000Ms",	"\t%llu timer drift less or equal to 1000 ms\n")        \
421 	X(TCP_STATS_TIMER_DRIFT_GT_1000_MS,	"TmrDriftGT1000Ms",	"\t%llu timer drift greater than 1000 ms\n")    \
422 	X(TCP_STATS_USEDRTT,			"RTTUsed",	"\t%llu times RTT initialized from route\n")    \
423 	X(TCP_STATS_USEDRTTVAR,			"RTTVarUsed",	"\t%llu times RTTVAR initialized from rt\n")    \
424 	X(TCP_STATS_USEDSSTHRESH,		"SSTholdUsed",	"\t%llu times ssthresh initialized from rt\n")  \
425 	X(TCP_STATS_MINMSSDROPS,		"MinMssDrop",	"\t%llu average minmss too low drops\n")        \
426 	X(TCP_STATS_SNDREXMITBAD,		"BadReXmt",	"\t%llu unnecessary packet retransmissions\n")  \
427         \
428 	/* SYN Cache relaetd stats */   \
429 	X(TCP_STATS_SC_ADDED,			"SCAdded",	"\t%llu entry added to syncache\n")     \
430 	X(TCP_STATS_SC_RETRANSMITTED,		"SCReXmt",	"\t%llu syncache entry was retransmitted\n")    \
431 	X(TCP_STATS_SC_DUPSYN,			"SCDupSYN",	"\t%llu duplicate SYN packet\n")        \
432 	X(TCP_STATS_SC_DROPPED,			"SCDrop",	"\t%llu could not reply to packet\n")   \
433 	X(TCP_STATS_SC_COMPLETED,		"SCCompl",	"\t%llu successful extraction of entry\n")      \
434 	X(TCP_STATS_SC_BUCKETOVERFLOW,		"SCBktOF",	"\t%llu syncache per-bucket limit hit\n")       \
435 	X(TCP_STATS_SC_CACHEOVERFLOW,		"SCOF",		"\t%llu syncache cache limit hit\n")    \
436 	X(TCP_STATS_SC_RESET,			"SCReset",	"\t%llu RST removed entry from syncache\n")     \
437 	X(TCP_STATS_SC_STALE,			"SCStale",	"\t%llu timed out or listen socket gone\n")     \
438 	X(TCP_STATS_SC_ABORTED,			"SCAbrt",	"\t%llu syncache entry aborted\n")      \
439 	X(TCP_STATS_SC_BADACK,			"SCBadAck",	"\t%llu removed due to bad ACK\n")      \
440 	X(TCP_STATS_SC_UNREACH,			"SCUnReach",	"\t%llu ICMP unreachable received\n")   \
441 	X(TCP_STATS_SC_ZONEFAIL,		"SCZoneFail",	"\t%llu zalloc() failed\n")     \
442 	X(TCP_STATS_SC_SENDCOOKIE,		"SCSndCookie",	"\t%llu SYN cookie sent\n")     \
443 	X(TCP_STATS_SC_RECVCOOKIE,		"SCRvcCookie",	"\t%llu SYN cookie received\n") \
444         \
445 	/* Host Cache related stats */  \
446 	X(TCP_STATS_HC_ADDED,			"HCAdd",	"\t%llu entry added to hostcache\n")            \
447 	X(TCP_STATS_HC_BUCKETOVERFLOW,		"HCBktOF",	"\t%llu hostcache per bucket limit hit\n")      \
448         \
449 	/* Misc. */     \
450 	X(TCP_STATS_BG_RCVTOTAL,		"RcvBkgrdPkt",	"\t%llu total background packets received\n")   \
451 	X(TCP_STATS_MSG_UNOPKTS,		"MsgUnOrdPkt",	"\t%llu unordered packet on TCP msg stream\n")  \
452 	X(TCP_STATS_MSG_UNOAPPENDFAIL,		"MsgUnOrdFail",	"\t%llu failed to append unordered pkt\n")      \
453 	X(TCP_STATS_MSG_SNDWAITHIPRI,		"MsgSndW8HPrio","\t%llu send waiting for high priority data\n") \
454         \
455 	/* MPTCP Related stats */       \
456 	X(TCP_STATS_MP_SNDPACKS,		"MPSndPkt",	"\t%llu data packet sent\n")    \
457 	X(TCP_STATS_MP_SNDBYTES,		"MPSndByte",	"\t%llu data byte sent\n")      \
458 	X(TCP_STATS_MP_RCVTOTAL,		"MPRcvTotal",	"\t%llu data packet received\n")        \
459 	X(TCP_STATS_MP_RCVBYTES,		"MPRcvByte",	"\t%llu data byte received\n")  \
460 	X(TCP_STATS_INVALID_MPCAP,		"InvMPCap",	"\t%llu packet with an invalid MPCAP option\n") \
461 	X(TCP_STATS_INVALID_JOINS,		"InvMPJoin",	"\t%llu packet with an invalid MPJOIN option\n")        \
462 	X(TCP_STATS_MPCAP_FALLBACK,		"MPCapFail",	"\t%llu time primary subflow fell back to TCP\n")       \
463 	X(TCP_STATS_JOIN_FALLBACK,		"MPJoinFallBk",	"\t%llu time secondary subflow fell back to TCP\n")     \
464 	X(TCP_STATS_ESTAB_FALLBACK,		"EstFallBk",	"\t%llu DSS option drop\n")     \
465 	X(TCP_STATS_INVALID_OPT,		"InvOpt",	"\t%llu other invalid MPTCP option\n")  \
466 	X(TCP_STATS_MP_REDUCEDWIN,		"MPReducedWin",	"\t%llu time the MPTCP subflow window was reduced\n")   \
467 	X(TCP_STATS_MP_BADCSUM,			"MPBadCSum",	"\t%llu bad DSS checksum\n")    \
468 	X(TCP_STATS_MP_OODATA,			"MPOOData",	"\t%llu time received out of order data\n")     \
469 	X(TCP_STATS_MP_OUTOFWIN,		"MPOutOfWin",	"\t%llu Packet lies outside the shared recv window\n")  \
470 	X(TCP_STATS_JOIN_RXMTS,			"JoinAckReXmt",	"\t%llu join ack retransmits\n")        \
471 	X(TCP_STATS_TAILLOSS_RTO,		"TailLossTRO",	"\t%llu RTO due to tail loss\n")        \
472 	X(TCP_STATS_RECOVERED_PKTS,		"RecoveryPkt",	"\t%llu recovered after loss\n")        \
473 	X(TCP_STATS_NOSTRETCHACK,		"NoStrechAck",	"\t%llu disabled stretch ack algorithm on a connection\n")      \
474 	X(TCP_STATS_RESCUE_RXMT,		"SACKRsqReXmt", "\t%llu SACK rescue retransmit\n")      \
475         \
476 	/* MPTCP Subflow selection stats */     \
477 	X(TCP_STATS_MP_SWITCHES,		"MPSwitches",	"\t%llu subflow switch\n")      \
478 	X(TCP_STATS_MP_SEL_SYMTOMSD,		"MPSelSymp",	"\t%llu subflow switch due to advisory\n")      \
479 	X(TCP_STATS_MP_SEL_RTT,			"MPSelRTT",	"\t%llu subflow switch due to rtt\n")   \
480 	X(TCP_STATS_MP_SEL_RTO,			"MPSelRTO",	"\t%llu subflow switch due to rto\n")   \
481 	X(TCP_STATS_MP_SEL_PEER,		"MPSelPeer",	"\t%llu subflow switch due to peer\n")  \
482 	X(TCP_STATS_MP_NUM_PROBES,		"MPProbe",	"\t%llu number of subflow probe\n")     \
483 	X(TCP_STATS_MP_VERDOWNGRADE,		"MPVerDowngrd",	"\t%llu times MPTCP version downgrade\n")       \
484         \
485 	/* Miscellaneous statistics */  \
486 	X(TCP_STATS_TW_PCBCOUNT,		"TWPcbCount",	"\t%llu pcbs in time-wait state\n")     \
487         \
488 	X(__TCP_STATS_MAX,			"",		"end of tcp stats")
489 
490 #define UDP_STATS_TABLE(X)                                              \
491 	/* Input stats */       \
492 	X(UDP_STATS_IPACKETS,			"RcvPkt",		"\t%llu datagram received\n")   \
493 	X(UDP_STATS_HDROPS,			"HdrDrop",		"\t\t%llu with incomplete header\n")    \
494 	X(UDP_STATS_BADSUM,			"BadCsum",		"\t\t%llu with bad data length field\n")        \
495 	X(UDP_STATS_BADLEN,			"BadLen",		"\t\t%llu with bad checksum\n") \
496 	X(UDP_STATS_NOSUM,			"NoCsum",		"\t\t%llu with no checksum\n")  \
497 	X(UDP_STATS_RCV_SWCSUM,			"RcvSWCsum",		"\t\t%llu checksummed in software")     \
498 	X(UDP_STATS_RCV_SWCSUM_BYTES,		"RcvSWCsumBytes",	" (%llu bytes) over IPv4\n")    \
499 	X(UDP_STATS_RCV6_SWCSUM,		"RcvSWCsum",		"\t\t%llu checksummed in software")     \
500 	X(UDP_STATS_RCV6_SWCSUM_BYTES,		"RcvSWCsumBytes",	" (%llu bytes) over IPv6\n")    \
501 	X(UDP_STATS_NOPORT,			"NoPort",		"\t\t%llu dropped due to no socket\n")  \
502 	X(UDP_STATS_NOPORTBCAST,		"NoPortBCast",		"\t\t%llu broadcast/multicast datagram undelivered\n")  \
503 	X(UDP_STATS_FILTERMCAST,		"FilterMCast",		"\t\t%llu time multicast source filter matched\n")      \
504 	X(UDP_STATS_FULLSOCK,			"FullSock",		"\t\t%llu dropped due to full socket buffers\n")        \
505 	X(UDP_STATS_PCBCACHEMISS,		"PCBCacheMiss",		"\t\t%llu not for hashed pcb\n")        \
506 	X(UDP_STATS_PCBHASHMISS,		"PCBHashMiss",		"\t\t%llu input packets not for hashed pcb")    \
507         \
508 	/* Output stats */      \
509 	X(UDP_STATS_OPACKETS,			"SndPkt",		"\t%llu datagram output\n")     \
510 	X(UDP_STATS_SND_SWCSUM,			"SndSWCsum",		"\t\t%llu checksummed in software")     \
511 	X(UDP_STATS_SND_SWCSUM_BYTES,		"SndSWCsumBytes",	" (%llu bytes) over IPv4\n")    \
512 	X(UDP_STATS_SND6_SWCSUM,		"SndSWCsum6",		"\t\t%llu checksummed in software")     \
513 	X(UDP_STATS_SND6_SWCSUM_BYTES,		"SndSWCsumBytes6",	" (%llu bytes) over IPv6\n")    \
514 	X(UDP_STATS_FASTOUT,			"SndFastPath",		"\t\t%llu output packets on fast path\n")       \
515 	X(UDP_STATS_NOPORTMCAST,		"SndNoPortMCast",	"\t\t%llu output no socket on port, multicast\n")       \
516         \
517 	X(__UDP_STATS_MAX,			"",			"end of UDP stats")
518 
519 #define QUIC_STATS_TABLE(X)                                      \
520 	/* Tx */        \
521 	X(QUIC_STATS_SNDPKT,			"SndTotalPkt",		"\t%llu packets sent")  \
522 	X(QUIC_STATS_SNDBYTE,			"SndTotalByte",		" (%llu bytes)\n")      \
523 	/* Tx Stream */ \
524 	X(QUIC_STATS_SNDSTREAMFRAME,		"SndStreamFrame",	"\t\tSTREAM\n\t\t\t%llu stream frames sent")    \
525 	X(QUIC_STATS_SNDSTREAMBYTE,		"SndStreamByte",	" (%llu bytes)\n")      \
526 	X(QUIC_STATS_SNDSTREAMRESET,		"SndStreamReset",	"\t\t\t%llu RESET_STREAM frames sent\n")        \
527 	X(QUIC_STATS_SNDSTOPSENDING,		"SndStopSending",	"\t\t\t%llu STOP_SENDING frames sent\n")        \
528 	X(QUIC_STATS_SNDSTREAMBLKFRAME,		"SndStreamBlockedFrame","\t\t\t%llu STREAM_BLOCKED frames sent\n")      \
529 	X(QUIC_STATS_SNDSTMDATABLKFRAME,	"SndStreamDataBlocked",	"\t\t\t%llu STREAM_DATA_BLOCKED frames sent\n") \
530 	/* Tx CRYPTO */ \
531 	X(QUIC_STATS_SNDINITCRYPTOFRAME,	"SndInitCryptoFrame",	"\t\tCRYPTO\n\t\t\t%llu initial CRYPTO frames sent")    \
532 	X(QUIC_STATS_SNDINITCRYPTOBYTE,		"SndInitCryptoByte",	" (%llu bytes)\n")      \
533 	X(QUIC_STATS_SNDHDSHKCRYPTOFRAME,	"SndHdShkCryptoFrame",	"\t\t\t%llu handshake CRYPTO frames sent")      \
534 	X(QUIC_STATS_SNDHDSHKCRYPTOBYTE,	"SndHdShkCryptoByte",	" (%llu bytes)\n")      \
535 	X(QUIC_STATS_SND1RTTCRYPTOFRAME,	"Snd1RttCryptoFrame",	"\t\t\t%llu 1-RTT CRYPTO frames sent")  \
536 	X(QUIC_STATS_SND1RTTCRYPTOBYTE,		"Snd1RttCryptoByte",	" (%llu bytes)\n")      \
537 	X(QUIC_STATS_SND0RTTCRYPTOFRAME,	"Snd1RttCryptoFrame",	"\t\t\t%llu 0-RTT CRYPTO frames sent")  \
538 	X(QUIC_STATS_SND0RTTCRYPTOBYTE,		"Snd1RttCryptoByte",	" (%llu bytes)\n")      \
539 	X(QUIC_STATS_SNDCRYPTOREXMTFRAME,	"SndReXmtCryptoFrame",	"\t\t\t%llu CRYPTO frames retransmitted")       \
540 	X(QUIC_STATS_SNDCRYPTOREXMTBYTE,	"SndReXmtCryptoByte",	" (%llu bytes)\n")      \
541 	X(QUIC_STATS_SNDDATABLKFRAME,		"SndDataBlockedFrame",	"\t\t%llu DATA_BLOCKED frames sent\n")  \
542 	X(QUIC_STATS_SNDREXMTPKT,		"SndReXmtPkt",		"\t\t%llu packets retransmitted")       \
543 	X(QUIC_STATS_SNDREXMTBYTE,		"SndReXmtByte",		" (%llu bytes)\n")      \
544 	X(QUIC_STATS_SNDLOSTPKT,		"SndLostPkt",		"\t\t%llu packets lost")        \
545 	X(QUIC_STATS_SNDLOSTBYTE,		"SndLostByte",		" (%llu bytes)\n")      \
546 	/* End of Tx */ \
547 	/* Rx */        \
548 	X(QUIC_STATS_RCVPKT,			"RcvTotalPkt",		"\t%llu packets received")      \
549 	X(QUIC_STATS_RECVBYTE,			"RcvTotalByte",		" (%llu bytes)\n")      \
550 	/* Rx Stream */ \
551 	X(QUIC_STATS_RCVSTREAMFRAME,		"RcvStreamFrame",	"\t\tSTREAM\n\t\t\t%llu stream frames received")        \
552 	X(QUIC_STATS_RCVSTREAMBYTE,		"RcvStreamByte",	" (%llu bytes)\n")      \
553 	X(QUIC_STATS_RCVSTREAMRESET,		"RcvStreamReset",	"\t\t\t%llu RESET_STREAM frames received\n")    \
554 	X(QUIC_STATS_RCVSTOPSENDING,		"RcvStopSending",	"\t\t\t%llu STOP_SENDING frames received\n")    \
555 	X(QUIC_STATS_RCVSTREAMBLKFRAME,		"RcvStreamBlockedFrame","\t\t\t%llu STREAM_BLOCKED frames received\n")  \
556 	X(QUIC_STATS_RCVSTMDATABLKFRAME,	"RcvStreamDataBlocked",	"\t\t\t%llu STREAM_DATA_BLOCKED frames received\n")     \
557 	/* Rx CRYPTO */ \
558 	X(QUIC_STATS_RCVINITCRYPTOFRAME,	"RcvInitCryptoFrame",	"\t\tCRYPTO\n\t\t\t%llu initial CRYPTO frames received")        \
559 	X(QUIC_STATS_RCVINITCRYPTOBYTE,		"RcvInitCryptoByte",	" (%llu bytes)\n")      \
560 	X(QUIC_STATS_RCVHDSHKCRYPTOFRAME,	"RcvHdShkCryptoFrame",	"\t\t\t%llu handshake CRYPTO frames received")  \
561 	X(QUIC_STATS_RCVHDSHKCRYPTOBYTE,	"RcvHdShkCryptoByte",	" (%llu bytes)\n")      \
562 	X(QUIC_STATS_RCV1RTTCRYPTOFRAME,	"Rcv1RttCryptoFrame",	"\t\t\t%llu 1-RTT CRYPTO frames received")      \
563 	X(QUIC_STATS_RCV1RTTCRYPTOBYTE,		"Rcv1RttCryptoByte",	" (%llu bytes)\n")      \
564 	X(QUIC_STATS_RCV0RTTCRYPTOFRAME,	"Rcv0RttCryptoFrame",	"\t\t\t%llu 0-RTT CRYPTO frames received")      \
565 	X(QUIC_STATS_RCV0RTTCRYPTOBYTE,		"Rcv0RttCryptoByte",	" (%llu bytes)\n")      \
566 	X(QUIC_STATS_RCVDATABLKFRAME,		"RcvDataBlockedFrame",	"\t\t%llu DATA_BLOCKED frames received\n")      \
567 	X(QUIC_STATS_RCVREORDERPKT,		"RcvReorderedPkt",	"\t\t%llu packets received reordered")  \
568 	X(QUIC_STATS_RCVREORDERBYTE,		"RcvReorderedByte",	" (%llu bytes)\n")      \
569 	/* Connections */       \
570 	X(QUIC_STATS_CONNECTS,			"ConnEst",		"\t%llu connections established\n")     \
571 	X(QUIC_STATS_SNDCCR,			"SndCCR",		"\t\t%llu connection close reasons sent\n")     \
572 	X(QUIC_STATS_SNDCCRINTERROR,		"SndCCRInternalError",	"\t\t\t%llu INTERNAL_ERROR sent\n")     \
573 	X(QUIC_STATS_SNDCCRSVRBUSY,		"SndCCRSererBusy",	"\t\t\t%llu SERVER_BUSY sent\n")        \
574 	X(QUIC_STATS_SNDCCRFLOWCTLERR,		"SndCCRFlowCtl",	"\t\t\t%llu FLOW_CONTROL_ERROR sent\n") \
575 	X(QUIC_STATS_SNDCCRSTREAMLIMIT,		"SndCCRStreamLimit",	"\t\t\t%llu STREAM_LIMIT_ERROR sent\n") \
576 	X(QUIC_STATS_SNDCCRSTREAMSTATE,		"SndCCRStreamState",	"\t\t\t%llu STREAM_STATE_ERROR sent\n") \
577 	X(QUIC_STATS_SNDCCRFINALOFFSET,		"SndCCRFinalOffset",	"\t\t\t%llu FINAL_SIZE_ERROR sent\n")   \
578 	X(QUIC_STATS_SNDCCRFRAMEENCODING,	"SndCCRFrameEncoding",	"\t\t\t%llu FRAME_ENCODING_ERROR sent\n")       \
579 	X(QUIC_STATS_SNDCCRTRNASPARAMS,		"SndCCRTransportParams","\t\t\t%llu TRANSPORT_PARAMETER_ERROR sent\n")  \
580 	X(QUIC_STATS_SNDCCRVERSIONNEGO,		"SndCCRVersionNego",	"\t\t\t%llu VERSION_NEGOTIATION_ERROR sent\n")  \
581 	X(QUIC_STATS_SNDCCRPROTOVIOLATION,	"SndCCRProtoViolation",	"\t\t\t%llu PROTOCOL_VIOLATION sent\n") \
582 	X(QUIC_STATS_SNDCCRINVALMIGRATION,	"SndCCRInvalMigration",	"\t\t\t%llu INVALID_MIGRATION sent\n")  \
583 	X(QUIC_STATS_SNDCCRCRYPTO,		"SndCCRCryptoError",	"\t\t\t%llu CRYPTO_ERROR sent\n")       \
584 	X(QUIC_STATS_RCVCCR,			"RcvCCR",		"\t\t%llu connection close reasons received\n") \
585 	X(QUIC_STATS_RCVCCRINTERROR,		"RcvCCRInternalError",	"\t\t\t%llu INTERNAL_ERROR received\n") \
586 	X(QUIC_STATS_RCVCCRSVRBUSY,		"RcvCCRSererBusy",	"\t\t\t%llu SERVER_BUSY received\n")    \
587 	X(QUIC_STATS_RCVCCRFLOWCTLERR,		"RcvCCRFlowCtl",	"\t\t\t%llu FLOW_CONTROL_ERROR received\n")     \
588 	X(QUIC_STATS_RCVCCRSTREAMLIMIT,		"RcvCCRStreamLimit",	"\t\t\t%llu STREAM_LIMIT_ERROR received\n")     \
589 	X(QUIC_STATS_RCVCCRSTREAMSTATE,		"RcvCCRStreamState",	"\t\t\t%llu STREAM_STATE_ERROR received\n")     \
590 	X(QUIC_STATS_RCVCCRFINALOFFSET,		"RcvCCRFinalOffset",	"\t\t\t%llu FINAL_SIZE_ERROR received\n")       \
591 	X(QUIC_STATS_RCVCCRFRAMEENCODING,	"RcvCCRFrameEncoding",	"\t\t\t%llu FRAME_ENCODING_ERROR received\n")   \
592 	X(QUIC_STATS_RCVCCRTRNASPARAMS,		"RcvCCRTransportParams","\t\t\t%llu TRANSPORT_PARAMETER_ERROR received\n")      \
593 	X(QUIC_STATS_RCVCCRVERSIONNEGO,		"RcvCCRVersionNego",	"\t\t\t%llu VERSION_NEGOTIATION_ERROR received\n")      \
594 	X(QUIC_STATS_RCVCCRPROTOVIOLATION,	"RcvCCRProtoViolation",	"\t\t\t%llu PROTOCOL_VIOLATION received\n")     \
595 	X(QUIC_STATS_RCVCCRINVALMIGRATION,	"RcvCCRInvalMigration",	"\t\t\t%llu INVALID_MIGRATION received\n")      \
596 	X(QUIC_STATS_RCVCCRCRYPTO,		"RcvCCRCryptoError",	"\t\t\t%llu CRYPTO_ERROR received\n")   \
597 	X(QUIC_STATS_SNDECT0,			"SndECT0",		"\t%llu ECT0 sent\n")   \
598 	X(QUIC_STATS_RCVECT0,			"RcvECT0",		"\t%llu ECT0 received\n")       \
599 	X(QUIC_STATS_SNDECT1,			"SndECT1",		"\t%llu ECT1 sent\n")   \
600 	X(QUIC_STATS_RCVECT1,			"RcvECT1",		"\t%llu ECT1 received\n")       \
601 	X(QUIC_STATS_SNDECTCE,			"SndECTCE",		"\t%llu ECT-CE sent\n") \
602 	X(QUIC_STATS_RCVECTCE,			"RcvECTCE",		"\t%llu ECT-CE received\n")     \
603 	X(QUIC_STATS_REXMTTIMEOUT,		"ReXmtTimeOut",		"\t%llu retransmit timeout\n")  \
604 	X(QUIC_STATS_KEEPALIVETTIMEOUT,		"KeepAliveTimeOut",	"\t%llu keepalive timeout\n")   \
605 	X(QUIC_STATS_PTO,			"ProbeTimeOut",		"\t%llu probe timeout\n")       \
606         \
607 	X(__QUIC_STATS_MAX,			"",			"end of quic stats\n")
608 
609 #define NETIF_STATS_TABLE(X)                                            \
610 	/* Rx stats */  \
611 	X(NETIF_STATS_RX_PACKETS,		"RxPackets",		"\t%llu total Rx packets\n")    \
612 	X(NETIF_STATS_RX_IRQ,			"RxIRQ",		"\t\t%llu interrupts\n")        \
613 	X(NETIF_STATS_RX_IRQ_MIT,		"RxIRQMIT",		"\t\t\t%llu interrupt mitigation thread wakeup\n")      \
614 	X(NETIF_STATS_RX_IRQ_BUSY,		"RxIRQBusy",		"\t\t\t%llu interrupt notify return busy\n")    \
615 	X(NETIF_STATS_RX_IRQ_AGAIN,		"RxIRQAgain",		"\t\t\t%llu interrupt notify return retry again\n")     \
616 	X(NETIF_STATS_RX_IRQ_ERR,		"RxIRQErr",		"\t\t\t%llu interrupt notify return error\n")   \
617 	X(NETIF_STATS_RX_COPY_SUM,		"RxCopySum",		"\t\t%llu copy+checksumed\n")   \
618 	X(NETIF_STATS_RX_COPY_DIRECT,		"RxCopyDirect",         "\t\t%llu copy from pkt\n")     \
619 	X(NETIF_STATS_RX_COPY_MBUF,		"RxCopyMbuf",		"\t\t%llu copy from mbuf\n")    \
620 	X(NETIF_STATS_RX_COPY_ATTACH,		"RxCopyAttach",         "\t\t%llu copy by attaching mbuf under pkt\n")  \
621 	X(NETIF_STATS_RX_SYNC,			"RxSYNC",		"\t\t%llu sync\n")      \
622         \
623 	/* Tx stats */  \
624 	X(NETIF_STATS_TX_PACKETS,		"TxPkt",		"\t%llu total Tx packets\n")    \
625 	X(NETIF_STATS_TX_IRQ,			"TxIRQ",		"\t\t%llu interupts\n") \
626 	X(NETIF_STATS_TX_IRQ_MIT,		"TxIRQMIT",		"\t\t\t%llu interrupt mitigation thread wakeup\n")      \
627 	X(NETIF_STATS_TX_IRQ_BUSY,		"TxIRQBusy",		"\t\t\t%llu interrupt notify return busy\n")    \
628 	X(NETIF_STATS_TX_IRQ_AGAIN,		"TxIRQAgain",		"\t\t\t%llu interrupt notify return retry again\n")     \
629 	X(NETIF_STATS_TX_IRQ_ERR,		"TxIRQErr",		"\t\t\t%llu interrupt notify return error\n")   \
630 	X(NETIF_STATS_TX_COPY_SUM,		"TxCopySum",		"\t\t%llu copy+checksumed\n")   \
631 	X(NETIF_STATS_TX_COPY_DIRECT,		"TxCopyDirect",		"\t\t%llu copy from pkt\n")     \
632 	X(NETIF_STATS_TX_COPY_MBUF,		"TxCopyMbuf",		"\t\t%llu copy from mbuf\n")    \
633 	X(NETIF_STATS_TX_SYNC,			"TxSYNC",		"\t\t%llu sync\n")      \
634 	X(NETIF_STATS_TX_REPL,			"TxRepl",		"\t\t%llu pool replenished\n")  \
635 	X(NETIF_STATS_TX_DROP_ENQ_AQM,		"TxDropEnqueueAQM",     "\t\t%llu dropped due to AQM enqueue failure\n")        \
636 	X(NETIF_STATS_GSO_SEG,			"GSOSegments",          "\t\t%llu GSO segments created\n") \
637 	X(NETIF_STATS_GSO_PKT,			"GSOPackets",           "\t\t%llu GSO packets \n") \
638 	X(NETIF_STATS_GSO_PKT_DROP_NOMEM,	"GSODropNoMem",         "\t\t%llu GSO packet dropped due to allocation failure\n") \
639 	X(NETIF_STATS_GSO_PKT_DROP_NA_INACTIVE,	"GSODropNaInactive",    "\t\t%llu GSO packet dropped due to inactive netif\n") \
640 	X(NETIF_STATS_GSO_PKT_DROP_BADLEN,	"GSODropBadLen",        "\t\t%llu GSO packet dropped due to bad packet length\n") \
641 	X(NETIF_STATS_GSO_PKT_DROP_NONTCP,	"GSODropNonTcp",        "\t\t%llu GSO packet dropped as it is not a TCP packet\n") \
642         \
643 	X(NETIF_STATS_DROP,			"Drop",			"\t%llu dropped\n")     \
644 	X(NETIF_STATS_DROP_NOMEM_BUF,		"DropNoMemBuf",		"\t\t%llu dropped due to packet alloc failure\n")       \
645 	X(NETIF_STATS_DROP_NOMEM_PKT,		"DropNoMemPkt",		"\t\t%llu dropped due to buflet alloc failure\n")       \
646 	X(NETIF_STATS_DROP_NOMEM_MBUF,		"DropNoMemMbuf",	"\t\t%llu dropped due to mbuf alloc failure\n") \
647 	X(NETIF_STATS_DROP_BADLEN,		"DropBadLen",		"\t\t%llu dropped due to bad packet length\n")  \
648 	X(NETIF_STATS_DROP_NA_INACTIVE,		"DropNaInactive",	"\t\t%llu dropped due to dst na inactive\n")    \
649 	X(NETIF_STATS_DROP_KRDROP_MODE,		"DropKrDropMode",	"\t\t%llu dropped due to dst kring in drop mode\n")     \
650 	X(NETIF_STATS_DROP_RXQ_OVFL,		"DropRxqOverflow",	"\t\t%llu dropped due to RX Queue overflow\n")     \
651 	X(NETIF_STATS_DROP_NO_RX_CB,		"DropNoRxCallback",	"\t\t%llu dropped due to missing RX callback\n") \
652         \
653 	/* Channel event stats */  \
654 	X(NETIF_STATS_EV_SENT,			"EvSent",		"\t%llu channel event delivered\n")     \
655 	X(NETIF_STATS_EV_DROP,			"EvDrop",		"\t%llu channel event dropped\n")     \
656 	X(NETIF_STATS_EV_DROP_NOMEM_PKT,	"EvDropNoMemPkt",	"\t%llu channel event dropped due to packet alloc failure\n")     \
657 	X(NETIF_STATS_EV_DROP_NA_INACTIVE,	"EvDropNaInactive",	"\t%llu channel event dropped due to na inactive\n")     \
658 	X(NETIF_STATS_EV_DROP_NA_DEFUNCT,	"EvDropNaDefunct",	"\t%llu channel event dropped due to na defunct\n")     \
659 	X(NETIF_STATS_EV_DROP_KRDROP_MODE,	"EvDropKrDropMode",	"\t%llu channel event dropped due to dst kring in drop mode\n")     \
660 	X(NETIF_STATS_EV_DROP_KEVENT_INACTIVE,	"EvDropKevInactive",	"\t%llu channel event dropped due to kevent not registered on channel\n")     \
661 	X(NETIF_STATS_EV_DROP_KRSPACE,		"EvDropKrSpaceDrop",	"\t%llu channel event dropped due to lack of space in user channel ring\n") \
662 	X(NETIF_STATS_EV_DROP_DEMUX_ERR,	"EvDropDemuxErr",	"\t%llu channel event dropped due to demux error\n") \
663 	X(NETIF_STATS_EV_DROP_EV_VPNA_NOTSUP,	"EvDropVpnaEvNotSup",	"\t%llu channel event dropped due to vpna not having event ring\n") \
664 	X(NETIF_STATS_EV_DROP_NO_VPNA,		"EvDropNoVpna",		"\t%llu channel event dropped due to no vpna ports\n") \
665         \
666 	/* Interface advisory update stats */  \
667 	X(NETIF_STATS_IF_ADV_UPD_RECV,		"IfAdvUpdRecv",		"\t%llu interface advisory update received\n") \
668 	X(NETIF_STATS_IF_ADV_UPD_SENT,		"IfAdvUpdSent",		"\t%llu interface advisory update event sent\n") \
669 	X(NETIF_STATS_IF_ADV_UPD_DROP,		"IfAdvUpdDrop",		"\t%llu interface advisory update event dropped\n") \
670         \
671 	/* Interface filter stats */ \
672 	X(NETIF_STATS_FILTER_DROP_NO_RX_CB,	"FilterDropNoRxCB",	"\t%llu dropped due to missing RX callback\n") \
673 	X(NETIF_STATS_FILTER_DROP_DISABLED,	"FilterDropDisabled",	"\t%llu dropped due to disabled filter\n") \
674 	X(NETIF_STATS_FILTER_DROP_REMOVED,	"FilterDropRemoved",	"\t%llu dropped due to removed filter\n") \
675 	X(NETIF_STATS_FILTER_DROP_PKTQ_FULL,	"FilterDropPktqFull",	"\t%llu dropped due to packet queue full\n") \
676 	X(NETIF_STATS_FILTER_DROP_MBQ_FULL,	"FilterDropMbqFull",	"\t%llu dropped due to mbuf queue full\n") \
677 	X(NETIF_STATS_FILTER_DROP_DISABLED_RING,"FilterDropDisabledRing","\t%llu dropped due to disabled ring\n") \
678 	X(NETIF_STATS_FILTER_DROP_NO_SPACE,	"FilterDropNoSpace",	"\t%llu dropped due to lack of space in RX ring\n") \
679 	X(NETIF_STATS_FILTER_DROP_INTERNALIZE,	"FilterDropInternalize","\t%llu dropped due to internalize failure\n") \
680 	X(NETIF_STATS_FILTER_DROP_PKT_ALLOC_FAIL,"FilterDropPktAllocFail","\t%llu dropped due to packet allocation failure\n") \
681 	X(NETIF_STATS_FILTER_DROP_DEFAULT,	"FilterDropDefault",	"\t%llu dropped due to default drop policy\n") \
682 	X(NETIF_STATS_FILTER_PKT_TRUNCATED,	"FilterPktTruncated",	"\t%llu inbound packets truncated\n") \
683 	X(NETIF_STATS_FILTER_TX_DELIVER,	"FilterTxDeliver",	"\t%llu outbound packets delivered to filter\n") \
684 	X(NETIF_STATS_FILTER_RX_DELIVER,	"FilterRxDeliver",	"\t%llu inbound packets delivered to filter\n") \
685 	X(NETIF_STATS_FILTER_TX_INJECT,		"FilterTxInject",	"\t%llu outbound packets injected by filter\n") \
686 	X(NETIF_STATS_FILTER_RX_INJECT,		"FilterRxInject",	"\t%llu inbound packets injected by filter\n") \
687 	X(NETIF_STATS_FILTER_TX_ENTER,		"FilterTxEnter",	"\t%llu outbound packets entered the filter chain\n") \
688 	X(NETIF_STATS_FILTER_RX_ENTER,		"FilterRxEnter",	"\t%llu inbound packets entered the filter chain\n") \
689 	X(NETIF_STATS_FILTER_TX_EXIT,		"FilterTxExit",		"\t%llu outbound packets exited the filter chain\n") \
690 	X(NETIF_STATS_FILTER_RX_EXIT,		"FilterRxExit",		"\t%llu inbound packets exited the filter chain\n") \
691 	X(NETIF_STATS_FILTER_SYNC_NO_PKTS,	"FilterSyncNoPkts",	"\t%llu filter syncs called with an empty ring\n") \
692 	X(NETIF_STATS_FILTER_ADD,		"FilterAdd",		"\t%llu filters added\n") \
693 	X(NETIF_STATS_FILTER_REMOVE,		"FilterRemove",		"\t%llu filters removed\n") \
694 	X(NETIF_STATS_FILTER_TX_FLUSH,		"FilterTxFlush",	"\t%llu TX packets flushed due to closing filters\n") \
695 	X(NETIF_STATS_FILTER_RX_NOT_FILTERABLE,	"FilterRxNotFilterable","\t%llu RX packets not filterable\n") \
696 	X(NETIF_STATS_FILTER_BAD_PKT_LEN,	"FilterBadPktLen",	"\t%llu invalid packet length\n") \
697         \
698 	/* Custom ether and sidecar stats */ \
699 	X(NETIF_STATS_VP_DROP_USER_RING_DISABLED,"VPDropUserRingDisabled","\t%llu dropped due to disabled user ring\n") \
700 	X(NETIF_STATS_VP_DROP_DEV_RING_DISABLED,"VPDropDevRingDisabled","\t%llu dropped due to disabled device ring\n") \
701 	X(NETIF_STATS_VP_DROP_USER_RING_NO_SPACE,"VPDropUserRingNoSpace","\t%llu dropped due to lack of user ring space\n") \
702 	X(NETIF_STATS_VP_DROP_DEV_RING_NO_SPACE,"VPDropDevRingNoSpace",	"\t%llu dropped due to lack of device ring space\n") \
703 	X(NETIF_STATS_VP_DROP_RX_ALLOC_FAIL,	"VPDropRxAllocFail",	"\t%llu dropped due to RX allocation failure\n") \
704 	X(NETIF_STATS_VP_DROP_TX_ALLOC_FAIL,	"VPDropTxAllocFail",	"\t%llu dropped due to TX allocation failure\n") \
705 	X(NETIF_STATS_VP_DROP_PKT_TOO_BIG,	"VPDropPktTooBig",	"\t%llu dropped due to packet being too big\n") \
706 	X(NETIF_STATS_VP_DROP_INTERNALIZE_FAIL,	"VPDropInternalizeFail","\t%llu dropped due to internalize failure\n") \
707 	X(NETIF_STATS_VP_DROP_UNEXPECTED_ERR,	"VPDropUnexpectedErr",	"\t%llu dropped due to unexpected TX sync error\n") \
708 	X(NETIF_STATS_VP_BAD_MADDR_LEN,		"VPBadMaddrLen",	"\t%llu packets with invalid mac address length\n") \
709 	X(NETIF_STATS_VP_BAD_MADDR,		"VPBadMaddr",		"\t%llu packets with invalid mac address\n") \
710 	X(NETIF_STATS_VP_BAD_PKT_LEN,		"VPBadPktLen",		"\t%llu packets invalid packet length\n") \
711 	X(NETIF_STATS_VP_FLOW_INFO_ERR,		"VPFlowInfoErr",	"\t%llu packets cannot be classified due to flow info error\n") \
712 	X(NETIF_STATS_VP_FLOW_NOT_MATCH,	"VPFlowNotMatch",	"\t%llu packets not matching flow description\n") \
713 	X(NETIF_STATS_VP_KR_ENTER_FAIL,		"VPKrEnterFail",	"\t%llu failed attempts to acquire RX ring lock\n") \
714 	X(NETIF_STATS_VP_DEV_RING_DISABLED,	"VPDevRingDisabled",	"\t%llu failed attempts to get packets due to disabled dev ring\n") \
715 	X(NETIF_STATS_VP_SYNC_UNKNOWN_ERR,	"VPSyncUnknownErr",	"\t%llu unknown errors returned by RX sync\n") \
716 	X(NETIF_STATS_VP_SYNC_NO_PKTS,		"VPSyncNoPkts",		"\t%llu syncs called with an empty ring\n") \
717 	X(NETIF_STATS_VP_SPURIOUS_NOTIFY,	"VPSpuriousNotify",	"\t%llu spurious notifies delivered\n") \
718 	X(NETIF_STATS_VP_ENQUEUE_FAILED,	"VPEnqueueFailed",	"\t%llu packets failed to enqueue\n") \
719 	X(NETIF_STATS_VP_ENQUEUED,		"VPEnqueued",		"\t%llu packets enqueued\n") \
720 	X(NETIF_STATS_VP_LL_ENQUEUED,		"VPLLEnqueued",		"\t%llu low latency packets enqueued\n") \
721 	X(NETIF_STATS_VP_LL_SENT,		"VPLLSent",		"\t%llu low latency packets sent\n") \
722 	X(NETIF_STATS_VP_LL_DELIVERED,		"VPLLDelivered",	"\t%llu low latency packets delivered\n") \
723 	X(NETIF_STATS_VP_DELIVERED,		"VPDelivered",		"\t%llu packets delivered\n") \
724 	X(NETIF_STATS_VP_FLOW_FOUND,		"VPFlowFound",		"\t%llu packets found a matching flow\n") \
725 	X(NETIF_STATS_VP_FLOW_NOT_FOUND,	"VPFlowNotFound",	"\t%llu packets found no matching flow\n") \
726 	X(NETIF_STATS_VP_FLOW_DISABLED,		"VPFlowDisabled",	"\t%llu lookup failures due to disabled flow\n") \
727 	X(NETIF_STATS_VP_FLOW_EMPTY_TABLE,	"VPFlowEmptyTable",	"\t%llu lookup failures due to empty flow table\n") \
728 	X(NETIF_STATS_VP_FLOW_TABLE_INIT_FAIL,	"VPFlowTableInitFail",	"\t%llu failed attempts to initialize flow table\n") \
729 	X(NETIF_STATS_VP_FLOW_INSERT_FAIL,	"VPFlowInsertFail",	"\t%llu failed attempts to insert flow\n") \
730 	X(NETIF_STATS_VP_FLOW_ADD,		"VPFlowAdd",		"\t%llu flows added\n") \
731 	X(NETIF_STATS_VP_FLOW_REMOVE,		"VPFlowRemove",		"\t%llu flows removed\n") \
732         \
733 	/* Netif agent stats */ \
734 	X(NETIF_STATS_AGENT_BAD_ETHERTYPE,	"AgentBadEthertype",	"\t%llu flow add failures due to invalid ethertype\n") \
735 	X(NETIF_STATS_AGENT_BAD_IPV6_ADDR,	"AgentBadIPv6Addr",	"\t%llu flow add failures due to invalid IPv6 address\n") \
736 	X(NETIF_STATS_AGENT_DUP_FLOW,		"AgentDupFlow",		"\t%llu duplicate flows added\n") \
737         \
738 	/* Netif llink stats */ \
739 	X(NETIF_STATS_LLINK_ADD,		"LLinkAdd",		"\t%llu logical links added\n") \
740 	X(NETIF_STATS_LLINK_REMOVE,		"LLinkRemove",		"\t%llu logical links removed\n") \
741 	X(NETIF_STATS_LLINK_DEF_QSET_USED,	"LLinkDefQSetUsed",	"\t%llu uses of the default qset\n") \
742 	X(NETIF_STATS_LLINK_NONDEF_QSET_USED,	"LLinkNonDefQSetUsed",	"\t%llu uses of a non-default qset\n") \
743 	X(NETIF_STATS_LLINK_HINT_NOT_USEFUL,	"LLinkHintNotUseful",	"\t%llu hints specified but qset not found\n") \
744 	X(NETIF_STATS_LLINK_DUP_INT_ID_GENERATED, "LLinkDupIntIDGenerated", "\t%llu duplicate internal llink IDs generated\n") \
745 	X(NETIF_STATS_LLINK_DUP_ID_GIVEN,	"LLinkDupIDGiven",	"\t%llu duplicate llink IDs given by the provider\n") \
746 	X(NETIF_STATS_LLINK_QSET_INIT_FAIL,	"LLinkQSetInitFail",	"\t%llu queue set initialization failures\n") \
747 	X(NETIF_STATS_LLINK_RXQ_INIT_FAIL,	"LLinkRXQInitFail",	"\t%llu RX queue initialization failures\n") \
748 	X(NETIF_STATS_LLINK_TXQ_INIT_FAIL,	"LLinkTXQInitFail",	"\t%llu TX queue initialization failures\n") \
749 	X(NETIF_STATS_LLINK_NOT_FOUND_REMOVE,	"LLinkNotFoundRemove",	"\t%llu not found during remove\n") \
750 	X(NETIF_STATS_LLINK_TX_DROP_BAD_STATE,	"LLinkTxDroppedBadState", "\t%llu TX packets dropped due to bad llink state\n") \
751 	X(NETIF_STATS_LLINK_RX_DROP_BAD_STATE,	"LLinkRxDroppedBadState", "\t%llu RX packets dropped due to bad llink state\n") \
752 	X(NETIF_STATS_LLINK_AQM_QFULL,		"LLinkAQMQFull",	"\t%llu occurances of the queue full condition\n") \
753 	X(NETIF_STATS_LLINK_AQM_DROPPED,	"LLinkAQMDropped",	"\t%llu packets dropped due to AQM\n") \
754 	X(NETIF_STATS_LLINK_AQM_DEQ_BAD_STATE,	"LLinkAQMDeqBadState",	"\t%llu dequeues occurred while llink is in a bad state\n") \
755 	X(NETIF_STATS_LLINK_QSET_BAD_STATE,	"LLinkQSetAccessBadState", "\t%llu attempts to access a queue set while in bad llink state\n") \
756 	X(NETIF_STATS_LLINK_ADD_BAD_PARAMS,	"LLinkAddBadParams",	"\t%llu attempts to add an llink with bad parameters\n") \
757         \
758 	X(__NETIF_STATS_MAX,			"",			"end of netif stats")
759 
760 #define FSW_FPD_STATS(X)        \
761 	X(FSW_STATS_FPD_0,			"",	"\t%llu")       \
762 	X(FSW_STATS_FPD_1,			"",	"\t%llu")       \
763 	X(FSW_STATS_FPD_2,			"",	"\t%llu")       \
764 	X(FSW_STATS_FPD_3,			"",	"\t%llu")       \
765 	X(FSW_STATS_FPD_4,			"",	"\t%llu")       \
766 	X(FSW_STATS_FPD_5,			"",	"\t%llu")       \
767 	X(FSW_STATS_FPD_6,			"",	"\t%llu")       \
768 	X(FSW_STATS_FPD_7,			"",	"\t%llu")       \
769 	X(FSW_STATS_FPD_8,			"",	"\t%llu")       \
770 	X(FSW_STATS_FPD_9,			"",	"\t%llu")       \
771 	X(FSW_STATS_FPD_10,		        "",	"\t%llu")       \
772 	X(FSW_STATS_FPD_11,			"",	"\t%llu")
773 
774 #define FSW_STATS_TABLE(X)                                      \
775 	/* Rx stats */  \
776 	X(FSW_STATS_RX_PACKETS,			"RxPackets",		"\t%llu total Rx packet\n")     \
777 	X(FSW_STATS_RX_DEMUX_ERR,		"RxDemuxErr",		"\t\t%llu demux error (passed to BSD)\n")       \
778 	X(FSW_STATS_RX_DEMUX_UNSPEC,		"RxDemuxUnspec",	"\t\t%llu demux AF unkown (passed to BSD)\n")       \
779 	X(FSW_STATS_RX_DEMUX_PROMISC,		"RxDemuxPromisc",	"\t\t%llu promiscuous packets (passed to BSD)\n")  \
780 	X(FSW_STATS_RX_FLOW_EXTRACT_ERR,	"RxFlowExtractErr",	"\t\t%llu flow extract error (passed to BSD)\n")       \
781 	X(FSW_STATS_RX_PKT_NOT_FINALIZED,	"RxPktNotFinalized",	"\t\t%llu packet not finalized\n")  \
782 	X(FSW_STATS_RX_FLOW_NOT_FOUND,		"RxFlowNotFound",	"\t\t%llu dropped, flow lookup failure\n")        \
783 	X(FSW_STATS_RX_FLOW_TRACK_ERR,		"RxFlowTrackErr",	"\t\t%llu dropped, flow tracker error\n") \
784 	X(FSW_STATS_RX_FLOW_NONVIABLE,		"RxFlowNonviable",	"\t\t%llu dropped, flow already nonviable\n") \
785 	X(FSW_STATS_RX_FLOW_TORNDOWN,		"RxFlowTornDown",	"\t\t%llu dropped, flow already torndown\n")      \
786 	X(FSW_STATS_RX_DST_RING_FULL,		"RxDstRingFull",	"\t\t%llu dropped, destination ring full\n") \
787 	X(FSW_STATS_RX_COPY_PKT2PKT,		"RxCopyPktToPkt",	"\t\t%llu copied pkt  -> pkt\n")        \
788 	X(FSW_STATS_RX_COPY_PKT2MBUF,		"RxCopyPktToMbuf",	"\t\t%llu copied pkt  -> mbuf\n")       \
789 	X(FSW_STATS_RX_COPY_MBUF2PKT,		"RxCopyMbufToPkt",	"\t\t%llu copied mbuf -> pkt\n")        \
790 	X(FSW_STATS_RX_COPY_SUM,		"RxCopySum",		"\t\t%llu copy+checksumed\n")   \
791 	X(FSW_STATS_RX_COPY_BAD_LEN,		"RxCopyBadLen",		"\t\t%llu dropped, bad packet length\n")  \
792 	X(FSW_STATS_RX_DROP_NOMEM_BUF,		"RxDropNoMemBuf",	"\t\t%llu dropped due to mbuf alloc failure\n") \
793 	X(FSW_STATS_RX_DEMUX_SHORT_ERR,		"RxDemuxShortErr",	"\t\t%llu demux failed, classify length short\n") \
794 	X(FSW_STATS_RX_WASTED_16KMBUF,		 "RxWasted16KMbuf",	"\t\t%llu wasted an entire pre-allocated 16K mbuf\n") \
795 	/* Rx frag stats (fsw doesn't manage fragments on Tx) */        \
796 	X(FSW_STATS_RX_FRAG_V4,			"RxFragV4",		"\t\t%llu total received ipv4 fragments\n")     \
797 	X(FSW_STATS_RX_FRAG_V6,			"RxFragV6",		"\t\t%llu total received ipv6 fragments\n")     \
798 	X(FSW_STATS_RX_FRAG_REASSED,		"RxFragReassed",	"\t\t\t%llu frag successfully reassembled\n")   \
799 	X(FSW_STATS_RX_FRAG_DROP_NOSLOT,	"RxFragDropNoSlot",	"\t\t\t%llu dropped no slot in dring\n")        \
800 	X(FSW_STATS_RX_FRAG_BAD,		"RxFragBad",		"\t\t\t%llu dropped due to bad fragments\n")    \
801 	X(FSW_STATS_RX_FRAG_DROP_BAD_LEN,	"RxFragBadLen",		"\t\t\t%llu dropped due to bad fragment length\n")      \
802 	X(FSW_STATS_RX_FRAG_DROP_NOMEM,		"RxFragNoMem",		"\t\t\t%llu dropped due to no memory\n")        \
803 	X(FSW_STATS_RX_FRAG_DROP_TIMEOUT,	"RxFragTimeOut",	"\t\t\t%llu dropped due to time out\n") \
804 	X(FSW_STATS_RX_FRAG_DROP_FRAG_LIMIT,	"RxFragHitFragLimit",	"\t\t\t%llu dropped due to ipf max limit\n")    \
805 	X(FSW_STATS_RX_FRAG_DROP_REAPED,	"RxFragDrained",	"\t\t\t%llu dropped due to draining\n") \
806 	X(FSW_STATS_RX_FRAG_DROP_PER_QUEUE_LIMIT,"RxFragHitPerQueueLimit","\t\t\t%llu dropped due to ipf max per queue limit\n")        \
807 	/* Rx aggregation stats */                                      \
808 	X(FSW_STATS_RX_AGG_PKT2PKT,             "RxAggPktToPkt",        "\t\t%llu aggregated pkt  -> super pkt\n")             \
809 	X(FSW_STATS_RX_AGG_PKT2MBUF,            "RxAggPktToMbuf",       "\t\t%llu aggregated pkt  -> super mbuf\n")          \
810 	X(FSW_STATS_RX_AGG_MBUF2PKT,            "RxAggMbufToPkt",       "\t\t%llu aggregated mbuf  -> super pkt\n")          \
811 	X(FSW_STATS_RX_AGG_MBUF2MBUF,           "RxAggMbufToMbuf",      "\t\t%llu aggregated mbuf  -> super mbuf\n")       \
812 	X(FSW_STATS_RX_AGG_LIMIT,               "RxAggHitAggLimit",     "\t\t%llu reached aggregation limit\n") \
813 	X(FSW_STATS_RX_AGG_NO_HLEN_IP,          "RxAggNoHdrLenIP",      "\t\t%llu IP header length compare mismatch\n") \
814 	X(FSW_STATS_RX_AGG_NO_TTL_IP,           "RxAggNoTTLIP",         "\t\t%llu IP TTL compare mismatch\n") \
815 	X(FSW_STATS_RX_AGG_NO_TOS_IP,           "RxAggNoTOSIP",         "\t\t%llu IP TOS compare mismatch\n") \
816 	X(FSW_STATS_RX_AGG_NO_OFF_IP,           "RxAggNoOffsetIP",      "\t\t%llu IP offset compare mismatch\n") \
817 	X(FSW_STATS_RX_AGG_NO_OPT_IP,           "RxAggNoOptionIP",      "\t\t%llu IP option compare mismatch\n") \
818 	X(FSW_STATS_RX_AGG_MERGE_FASTPATH_IP,   "RxAggMergeFastpathIP", "\t\t%llu IP header merge via fastpath\n") \
819 	X(FSW_STATS_RX_AGG_MERGE_SLOWPATH_IP,   "RxAggMergeSlowpathIP", "\t\t%llu IP header merge via slowpath\n") \
820 	X(FSW_STATS_RX_AGG_MERGE_FASTPATH_TCP,  "RxAggMergeFastpathTCP", "\t\t%llu TCP header merge via fastpath\n") \
821 	X(FSW_STATS_RX_AGG_MERGE_SLOWPATH_TCP,  "RxAggMergeSlowpathTCP", "\t\t%llu TCP header merge via slowpath\n") \
822 	X(FSW_STATS_RX_AGG_OK_FASTPATH_TCP,     "RxAggFastpathTCP",     "\t\t%llu TCP aggregation via fastpath\n") \
823 	X(FSW_STATS_RX_AGG_OK_SLOWPATH_TCP,     "RxAggSlowpathTCP",     "\t\t%llu TCP aggregation via slowpath\n") \
824 	X(FSW_STATS_RX_AGG_NO_SHORT_TCP,        "RxAggNoShortTCP",      "\t\t%llu TCP packet too short for mask compare\n") \
825 	X(FSW_STATS_RX_AGG_NO_MASK_TCP,         "RxAggNoMaskTCP",       "\t\t%llu TCP mask compare mismatch\n") \
826 	X(FSW_STATS_RX_AGG_NO_HLEN_TCP,         "RxAggNoHdrLenTCP",     "\t\t%llu TCP header length compare mismatch\n") \
827 	X(FSW_STATS_RX_AGG_NO_ULEN_TCP,         "RxAggNoULenTCP",       "\t\t%llu TCP ulength compare mismatch\n") \
828 	X(FSW_STATS_RX_AGG_NO_SEQN_TCP,         "RxAggNoSeqNTCP",       "\t\t%llu TCP sequence number compare mismatch\n") \
829 	X(FSW_STATS_RX_AGG_NO_ACKWIN_TCP,       "RxAggNoAckWinTCP",     "\t\t%llu TCP ACK or window compare mismatch\n") \
830 	X(FSW_STATS_RX_AGG_NO_FLAGS_TCP,        "RxAggNoFlagsTCP",      "\t\t%llu TCP flags compare mismatch\n") \
831 	X(FSW_STATS_RX_AGG_NO_EXOPT_TCP,        "RxAggNoExtraOptionTCP",  "\t\t%llu TCP extra option compare mismatch\n") \
832 	X(FSW_STATS_RX_AGG_NO_OPTTS_TCP,        "RxAggNoOptionTStampTCP", "\t\t%llu TCP timestamp option compare mismatch\n") \
833 	X(FSW_STATS_RX_AGG_BAD_CSUM,            "RxAggIncorrectChecksum", "\t\t%llu Incorrect TCP/IP checksum\n") \
834 	X(FSW_STATS_RX_AGG_NO_SHORT_MBUF,       "RxAggNoShortMbuf",      "\t\t%llu mbuf too short for mask compare\n") \
835         \
836 	/* Tx stats */  \
837 	X(FSW_STATS_TX_PACKETS,			"TXPackets",		"\t%llu total Tx packets\n")    \
838 	X(FSW_STATS_TX_DEMUX_ERR,		"TxDemuxErr",		"\t\t%llu dropped, demux error\n")        \
839 	X(FSW_STATS_TX_FLOW_EXTRACT_ERR,	"TxFlowExtractErr",	"\t\t%llu dropped, flow extract error\n") \
840 	X(FSW_STATS_TX_FRAG_BAD_ID,		"TxFragID",		"\t\t%llu dropped, invalid fragment ID\n")    \
841 	X(FSW_STATS_TX_FRAG_BAD_CONT,		"TxContFrag",		"\t\t%llu dropped, invalid continuation fragment\n")    \
842 	X(FSW_STATS_TX_FLOW_NOT_FOUND,		"TxFlowNotFound",	"\t\t%llu dropped, flow lookup failure\n")        \
843 	X(FSW_STATS_TX_FLOW_TRACK_ERR,		"TxFlowTrackErr",	"\t\t%llu dropped, flow tracker error\n") \
844 	X(FSW_STATS_TX_FLOW_BAD_ID,		"TxFLowBadID",		"\t\t%llu dropped, flow id invalid\n") \
845 	X(FSW_STATS_TX_FLOW_NONVIABLE,		"TxFlowNonviable",	"\t\t%llu dropped, flow already nonviable\n") \
846 	X(FSW_STATS_TX_FLOW_TORNDOWN,		"TxFlowTornDown",	"\t\t%llu dropped, flow already torndown\n") \
847 	X(FSW_STATS_TX_BAD_LISTENER,		"TxBadListener",	"\t\t%llu dropped, flow as listener only\n")      \
848 	X(FSW_STATS_TX_AQM_DROP,		"TxAQMDrop",		"\t\t%llu dropped, AQM enqueue failure\n")        \
849 	X(FSW_STATS_TX_RESOLV_PENDING,		"TxResolvePending",	"\t\t%llu pending resolve\n")   \
850 	X(FSW_STATS_TX_RESOLV_FAIL,		"TxResolveFail",	"\t\t%llu dropped due to resolution failure\n") \
851 	X(FSW_STATS_TX_RESOLV_STALE,		"TxResolveStale",	"\t\t%llu resolved using existing info\n")      \
852 	X(FSW_STATS_TX_COPY_PKT2PKT,		"TxCopyPktToPkt",	"\t\t%llu copied pkt  ->  pkt\n")       \
853 	X(FSW_STATS_TX_COPY_PKT2MBUF,		"TxCopyPktToMbuf",	"\t\t%llu copied pkt  ->  mbuf\n")      \
854 	X(FSW_STATS_TX_COPY_SUM,		"TxCopySum",		"\t\t%llu copy+checksumed\n")   \
855 	X(FSW_STATS_TX_COPY_BAD_LEN,		"TxCopyBadLen",		"\t\t%llu dropped, bad packet length\n")  \
856         \
857 	/* Drop stats (generic bidirectional) */ \
858 	X(FSW_STATS_DROP,			"Drop",			"\t%llu total dropped\n")       \
859 	X(FSW_STATS_DROP_NOMEM_PKT,		"DropNoMemPkt",		"\t\t%llu dropped, packet alloc failure\n")       \
860 	X(FSW_STATS_DROP_NOMEM_MBUF,		"DropNoMemMbuf",	"\t\t%llu dropped, mbuf alloc failure\n") \
861         \
862 	/* Channel event stats */  \
863 	X(FSW_STATS_EV_SENT,			"EvSent",		"\t%llu channel event delivered\n")     \
864 	X(FSW_STATS_EV_DROP,			"EvDrop",		"\t%llu channel event dropped\n")     \
865 	X(FSW_STATS_EV_DROP_NOMEM_PKT,	"EvDropNoMemPkt",	"\t%llu channel event dropped due to packet alloc failure\n")     \
866 	X(FSW_STATS_EV_DROP_NA_INACTIVE,	"EvDropNaInactive",	"\t%llu channel event dropped due to na inactive\n")     \
867 	X(FSW_STATS_EV_DROP_NA_DEFUNCT,	"EvDropNaDefunct",	"\t%llu channel event dropped due to na defunct\n")     \
868 	X(FSW_STATS_EV_DROP_KRDROP_MODE,	"EvDropKrDropMode",	"\t%llu channel event dropped due to dst kring in drop mode\n")     \
869 	X(FSW_STATS_EV_DROP_KEVENT_INACTIVE,	"EvDropKevInactive",	"\t%llu channel event dropped due to kevent not registered on channel\n")     \
870 	X(FSW_STATS_EV_DROP_KRSPACE,		"EvDropKrSpaceDrop",	"\t%llu channel event dropped due to lack of space in user channel ring\n") \
871 	X(FSW_STATS_EV_DROP_DEMUX_ERR,	"EvDropDemuxErr",	"\t%llu channel event dropped due to demux error\n") \
872 	X(FSW_STATS_EV_DROP_EV_VPNA_NOTSUP,	"EvDropVpnaEvNotSup",	"\t%llu channel event dropped due to vpna not having event ring\n") \
873 	/* Misc. stats */ \
874 	X(FSW_STATS_FLOWS_ABORTED,		"FlowsAborted",		"\t%llu flow aborted\n")        \
875 	X(FSW_STATS_DST_NXPORT_INVALID,		"DestNexusPortInvalid", "\t%llu times dst nexus port invalid\n")        \
876 	X(FSW_STATS_DST_NXPORT_INACTIVE,	"DestNexusPortInactive","\t%llu times dst nexus port inactive\n")       \
877 	X(FSW_STATS_DST_NXPORT_DEFUNCT,		"DestNexusPortDefunct", "\t%llu times dst nexus port defunct\n")        \
878 	X(FSW_STATS_DST_RING_DROPMODE,		"DestRingDropMode",	"\t\t%llu dropped, dst kring in drop mode\n")     \
879 	X(FSW_STATS_CHAN_ERR_UPP_ALLOC,		"ChanErrUppAlloc",	"\t%llu user packet pool alloc failure\n")      \
880 	X(FSW_STATS_CHAN_DEFUNCT_SKIP,		"ChanDefunctSkipped",	"\t%llu defunct skipped due to outstanding packets\n")  \
881         \
882 	X(_FSW_STATS_ERROR_INJECTIONS,		"_ErrorInjections",	"(\t%llu errors injected)\n")  \
883 	X(FSW_STATS_IF_ADV_UPD_SENT,		"IfAdvUpdSent",		"\t%llu interface advisory update event sent\n") \
884         \
885 	X(FSW_STATS_IF_ADV_UPD_DROP,		"IfAdvUpdDrop",		"\t%llu interface advisory update event dropped\n") \
886         \
887 	/* FPD stats */ \
888 	FSW_FPD_STATS(X)        \
889         \
890 	X(__FSW_STATS_MAX,			"",			"end of flowswitch stats")
891 
892 /* END CSTYLED */
893 
894 /*
895  * Common stats operation and macro
896  */
897 #define EXPAND_TO_ENUMERATION(a, b, c) a,
898 #define EXPAND_TO_STRING(a, b, c) b,
899 #define EXPAND_TO_FORMAT(a, b, c) c,
900 
901 #define DEFINE_STATS_STR_FUNC(type, table)                      \
902 __attribute__((always_inline))                                  \
903 static inline const char *                                      \
904 type##_str(enum _##type value)                                  \
905 {                                                               \
906 	static const char *table[] = {                          \
907 	    table(EXPAND_TO_STRING)                             \
908 	};                                                      \
909 	return (table[value]);                                  \
910 }
911 
912 #define DEFINE_STATS_FMT_FUNC(type, table)                      \
913 __attribute__((always_inline))                                  \
914 static inline const char *                                      \
915 type##_fmt(enum _##type value)                                  \
916 {                                                               \
917 	static const char *table[] = {                          \
918 	    table(EXPAND_TO_FORMAT)                             \
919 	};                                                      \
920 	return (table[value]);                                  \
921 }
922 
923 #define STATS_VAL(s_ptr, t) ((s_ptr)->_arr[(t)])
924 #define STATS_INC(s_ptr, t) ((s_ptr)->_arr[(t)]++)
925 #define STATS_DEC(s_ptr, t) ((s_ptr)->_arr[(t)]--)
926 #define STATS_ADD(s_ptr, t, v) ((s_ptr)->_arr[(t)] += (v))
927 
928 static inline void __attribute__((always_inline))
__stats_fold(uint64_t * dst,uint64_t * src,size_t len)929 __stats_fold(uint64_t *dst, uint64_t *src, size_t len)
930 {
931 	// TODO replace with vector instruction once veclib is ready for xnu
932 	size_t i;
933 	for (i = 0; i < len; i++) {
934 		dst[i] += src[i];
935 	}
936 }
937 
938 #define DEFINE_STATS_FOLD_FUNC(type, len)               \
939 static inline void __attribute__((always_inline))       \
940 type##_fold(struct type *dst, struct type *src)         \
941 {                                                       \
942 	__stats_fold(dst->_arr, src->_arr, len);        \
943 }
944 
945 static inline void __attribute__((always_inline))
__stats_reset(uint64_t * _arr,size_t len)946 __stats_reset(uint64_t *_arr, size_t len)
947 {
948 	// TODO replace with vector instruction once veclib is ready for xnu
949 	size_t i;
950 	for (i = 0; i < len; i++) {
951 		_arr[i] = 0;
952 	}
953 }
954 
955 #define DEFINE_STATS_RESET_FUNC(type, len)              \
956 static inline void __attribute__((always_inline))       \
957 type##_reset(struct type *s)                            \
958 {                                                       \
959 	__stats_reset(s->_arr, len);                    \
960 }
961 
962 #define STATS_ALIGN 16  /* align for vector instruction */
963 
964 #define STATS_REGISTER(name, NAME)                      \
965 enum _##name { NAME##_TABLE(EXPAND_TO_ENUMERATION) };   \
966 struct name {                                           \
967 	uint64_t	_arr[__##NAME##_MAX];           \
968 } __attribute__((aligned(STATS_ALIGN)));                \
969 DEFINE_STATS_STR_FUNC(name, NAME##_TABLE)               \
970 DEFINE_STATS_FMT_FUNC(name, NAME##_TABLE)               \
971 DEFINE_STATS_FOLD_FUNC(name, __##NAME##_MAX)            \
972 DEFINE_STATS_RESET_FUNC(name, __##NAME##_MAX)
973 
974 /* Stats registration stub */
975 STATS_REGISTER(ip_stats, IP_STATS);
976 STATS_REGISTER(ip6_stats, IP6_STATS);
977 STATS_REGISTER(tcp_stats, TCP_STATS);
978 STATS_REGISTER(udp_stats, UDP_STATS);
979 STATS_REGISTER(quic_stats, QUIC_STATS);
980 
981 STATS_REGISTER(fsw_stats, FSW_STATS);
982 STATS_REGISTER(netif_stats, NETIF_STATS);
983 
984 #undef  STATS_REGISTER
985 #undef  DEFINE_STATS_RESET_FUNC
986 #undef  DEFINE_STATS_FOLD_FUNC
987 #undef  DEFINE_STATS_RESET_FUNC
988 #undef  DEFINE_STATS_FOLD_FUNC
989 #undef  DEFINE_STATS_STR_FUNC
990 #undef  DEFINE_STATS_STR_FUNC
991 #undef  EXPAND_TO_STRING
992 #undef  EXPAND_TO_ENUMERATION
993 
994 /*
995  * Channel/Ring stats
996  */
997 typedef struct {
998 	uint32_t        cres_pkt_alloc_failures;
999 	uint32_t        __cres_reserved[1];
1000 } channel_ring_error_stats, *channel_ring_error_stats_t;
1001 
1002 typedef struct {
1003 	uint64_t        crsu_total_slots_transferred;
1004 	uint64_t        crsu_total_bytes_transferred;
1005 	uint64_t        crsu_number_of_syncs;
1006 	uint32_t        crsu_min_slots_transferred;
1007 	uint32_t        crsu_max_slots_transferred;
1008 	uint32_t        crsu_slots_per_sync;
1009 	uint32_t        crsu_slots_per_sync_ma;
1010 	uint64_t        crsu_bytes_per_sync;
1011 	uint64_t        crsu_bytes_per_sync_ma;
1012 	uint32_t        __crsu_reserved[2];
1013 } channel_ring_user_stats, *channel_ring_user_stats_t;
1014 
1015 typedef struct {
1016 	uint64_t        crs_total_slots_transferred;
1017 	uint64_t        crs_total_bytes_transferred;
1018 	uint64_t        crs_number_of_transfers;
1019 	uint32_t        crs_min_slots_transferred;
1020 	uint32_t        crs_max_slots_transferred;
1021 	uint32_t        crs_slots_per_second;
1022 	uint32_t        crs_slots_per_second_ma;
1023 	uint64_t        crs_bytes_per_second;
1024 	uint64_t        crs_bytes_per_second_ma;
1025 	uint32_t        __crs_reserved[2];
1026 } channel_ring_stats, *channel_ring_stats_t;
1027 
1028 struct netif_qstats {
1029 	uint64_t        nq_total_pkts;  /* total pkts transferred */
1030 	uint64_t        nq_total_bytes; /* total bytes transferred */
1031 	uint64_t        nq_num_xfers;   /* number of transfers */
1032 	uint32_t        nq_min_pkts;    /* min pkts transferred */
1033 	uint32_t        nq_max_pkts;    /* max pkts transferred */
1034 	uint32_t        nq_pkts_ps;     /* pkts transferred per second */
1035 	uint32_t        nq_pkts_ps_ma;  /* moving avg of pkts transferred per second */
1036 	uint64_t        nq_bytes_ps;    /* bytes transferred per second */
1037 	uint64_t        nq_bytes_ps_ma; /* moving avg of bytes transferred per second */
1038 };
1039 
1040 /*
1041  * Netif queue set queue stats
1042  * Output: An array of netif_qstats_info struct
1043  */
1044 #define SK_STATS_NETIF_QUEUE_SYSCTL             "kern.skywalk.stats.netif_queue"
1045 
1046 /* Valid value for nqi_queue_flag */
1047 #define NQI_QUEUE_FLAG_IS_RX            0x00000001
1048 struct netif_qstats_info {
1049 	uint64_t                            nqi_qset_id;
1050 	uint16_t                            nqi_queue_flag;
1051 	uint16_t                            nqi_queue_idx;
1052 	packet_svc_class_t                  nqi_svc;
1053 	struct netif_qstats                 nqi_stats;
1054 };
1055 
1056 /*
1057  * Nexus provider information.
1058  * Provides information about the provider including any registered instances.
1059  * Used with "kern.skywalk.nexus_provider_list" sysctl.
1060  */
1061 #define NEXUS_PROVIDER_LIST_SYSCTL      "kern.skywalk.nexus_provider_list"
1062 
1063 typedef struct {
1064 	uuid_t          npi_prov_uuid;          /* nexus provider UUID */
1065 	struct nxprov_params npi_prov_params;   /* nexus provider parameters */
1066 	uint32_t        npi_instance_uuids_count;
1067 	uint32_t        __npi_align_reserved;
1068 	uuid_t          npi_instance_uuids[0];  /* nexus instance UUIDs */
1069 } nexus_provider_info, *nexus_provider_info_t;
1070 
1071 #define NEXUS_PROVIDER_INFO_SIZE(a) \
1072 	offsetof(nexus_provider_info, npi_instance_uuids[a])
1073 
1074 /*
1075  * Nexus channel information.
1076  * Provides information about every channel in the system.
1077  * Used with "kern.skywalk.nexus_channel_list" sysctl.
1078  */
1079 #define NEXUS_CHANNEL_LIST_SYSCTL       "kern.skywalk.nexus_channel_list"
1080 
1081 /* Enable/Disable channel ring stats collection */
1082 #define NEXUS_CHANNEL_RING_STAT_ENABLE_SYSCTL   "kern.skywalk.ring_stat_enable"
1083 
1084 typedef struct {
1085 	ring_id_t               ncre_ring_id;
1086 	uint32_t                __ncre_align_reserved;
1087 	channel_ring_stats              ncre_stats;
1088 	channel_ring_user_stats         ncre_user_stats;
1089 	channel_ring_error_stats        ncre_error_stats;
1090 } nexus_channel_ring_entry, *nexus_channel_ring_entry_t;
1091 
1092 typedef struct {
1093 	uuid_t          nce_uuid;       /* channel uuid */
1094 	uint32_t        nce_flags;      /* SCHF_* */
1095 	pid_t           nce_pid;        /* channel owner pid */
1096 	int             nce_fd;         /* channel pid */
1097 	nexus_port_t    nce_port;       /* connected nexus port */
1098 	uint32_t        nce_tx_rings;   /* num of tx rings */
1099 	uint32_t        nce_rx_rings;   /* num of rx rings */
1100 	uint32_t        __nce_align_reserved;
1101 	nexus_channel_ring_entry nce_ring_entries[0]; /* tx followed by rx */
1102 } nexus_channel_entry, *nexus_channel_entry_t;
1103 
1104 #define SCHF_MONITOR_TX         0x00000001
1105 #define SCHF_MONITOR_RX         0x00000002
1106 #define SCHF_MONITOR_NO_COPY    0x00000004
1107 #define SCHF_USER_PACKET_POOL   0x00000008
1108 #define SCHF_DEFUNCT_OK         0x00000010
1109 #define SCHF_EXCLUSIVE          0x00000020
1110 #define SCHF_FILTER             0x00000040
1111 #define SCHF_EVENT_RING         0x00000080
1112 #define SCHF_IF_ADV             0x00000100
1113 #define SCHF_DEFUNCT_SKIP       0x00000200
1114 #define SCHF_LOW_LATENCY        0x00000400
1115 #define SCHF_CLOSING            0x40000000
1116 #define SCHF_DEFUNCT            0x80000000
1117 
1118 #define SCHF_BITS                                                          \
1119 	"\020\01MON_TX\02MON_RX\03NO_COPY\04USER_PACKET_POOL\05DEFUNCT_OK" \
1120 	"\06EXCLUSIVE\07FILTER\010EVENT_RING\011IF_ADV\012DEFUNCT_SKIP"    \
1121 	"\013LOW_LATENCY\037CLOSING\040DEFUNCT"
1122 
1123 #define NEXUS_CHANNEL_ENTRY_SIZE(n_rings)               \
1124 	offsetof(nexus_channel_entry, nce_ring_entries[n_rings])
1125 
1126 typedef struct {
1127 	uuid_t          nci_instance_uuid;      /* nexus instance UUID */
1128 	uint32_t        nci_channel_entries_count;
1129 	uint32_t        __nci_align_reserved;
1130 	nexus_channel_entry     nci_channel_entries[0]; /* variable length */
1131 } nexus_channel_info, *nexus_channel_info_t;
1132 
1133 /*
1134  * Nexus statistics types.
1135  */
1136 typedef enum {
1137 	NEXUS_STATS_TYPE_INVALID = 0,   /* invalid type */
1138 	NEXUS_STATS_TYPE_FSW,           /* flowswitch */
1139 	NEXUS_STATS_TYPE_CHAN_ERRORS,   /* Channel error stats */
1140 } nexus_stats_type_t;
1141 
1142 /*
1143  * Flowswitch statistics (NEXUS_STATS_TYPE_FSW).
1144  */
1145 struct __nx_stats_fsw {
1146 	struct ip_stats                 nxs_ipstat;
1147 	struct ip6_stats                nxs_ip6stat;
1148 	struct tcp_stats                nxs_tcpstat;
1149 	struct udp_stats                nxs_udpstat;
1150 	struct quic_stats               nxs_quicstat;
1151 };
1152 
1153 /*
1154  * Channel error statistics
1155  */
1156 struct __nx_stats_channel_errors {
1157 	channel_ring_error_stats_t      nxs_cres;
1158 };
1159 
1160 /*
1161  * Nexus advisories.
1162  */
1163 #define NX_INTF_ADV_SIZE (sizeof(uint64_t) + sizeof(struct ifnet_interface_advisory))
1164 
1165 #if defined(LIBSYSCALL_INTERFACE) || defined(BSD_KERNEL_PRIVATE)
1166 /*
1167  * Nexus advisory region types.
1168  */
1169 typedef enum {
1170 #if defined(BSD_KERNEL_PRIVATE)
1171 	NEXUS_ADVISORY_TYPE_INVALID = 0,
1172 #endif /* BSD_KERNEL_PRIVATE */
1173 	NEXUS_ADVISORY_TYPE_FLOWSWITCH = 1,   /* struct sk_nexusadv */
1174 	NEXUS_ADVISORY_TYPE_NETIF,   /* struct netif_nexus_advisory */
1175 } nexus_advisory_type_t;
1176 
1177 /*
1178  * The metadata object is placed at the begining of nexus advisory region.
1179  */
1180 struct __kern_nexus_adv_metadata {
1181 	uint16_t                 knam_version;
1182 	uint16_t                 __reserved;
1183 	nexus_advisory_type_t    knam_type;
1184 };
1185 #define NX_ADVISORY_MD_VERSION            1
1186 #define NX_ADVISORY_MD_CURRENT_VERSION    NX_ADVISORY_MD_VERSION
1187 
1188 struct __kern_netif_intf_advisory {
1189 	uint32_t                           cksum;
1190 	uint32_t                           _reserved;
1191 	struct ifnet_interface_advisory    adv;
1192 } __attribute__((aligned(sizeof(uint64_t))));
1193 
1194 /*
1195  * Netif nexus advisory.
1196  * currently this structure is not exposed to the user, but in future we
1197  * can expose it via os_channel_get_advisory_region() API.
1198  */
1199 struct netif_nexus_advisory {
1200 	uint64_t nna_version;
1201 	/*
1202 	 * __nna_intf_adv has been defined as an opaque blob here as the
1203 	 * atomicity of the data can be guaranteed only if accessed using
1204 	 * the os_channel_get_interface_advisory() API.
1205 	 */
1206 	union {
1207 #if defined(LIBSYSCALL_INTERFACE) || defined(BSD_KERNEL_PRIVATE)
1208 		struct __kern_netif_intf_advisory __kern_intf_adv;
1209 #endif /* LIBSYSCALL_INTERFACE || BSD_KERNEL_PRIVATE */
1210 		uint8_t __nna_intf_adv[NX_INTF_ADV_SIZE];
1211 	};
1212 } __attribute__((aligned(sizeof(uint64_t))));
1213 
1214 /* Netif nexus advisory version */
1215 #define NX_NETIF_ADVISORY_VERSION            1
1216 #define NX_NETIF_ADVISORY_CURRENT_VERSION    NX_NETIF_ADVISORY_VERSION
1217 #endif /* LIBSYSCALL_INTERFACE || BSD_KERNEL_PRIVATE */
1218 
1219 /*
1220  * Flowswitch nexus advisory.
1221  *
1222  * Note: add new field members at the bottom; if layout changes in the
1223  * middle, bump up NX_ADVISORY_VERSION and recompile userland clients
1224  * accessing this structure.
1225  *
1226  * Timestamps are stored in nanoseconds, based on microuptime().
1227  * Use mach_timebase_info() to acquire numerator and denominator,
1228  * and then compute current time using the following:
1229  *
1230  * uint64_t now = (mach_absolute_time() * tb_info.numer) / tb_info.denom;
1231  *
1232  * Comparisons can then be done against that current time.
1233  */
1234 struct sk_nexusadv {
1235 	uint64_t nxadv_ver;             /* see NX_ADVISORY_VERSION */
1236 	uint64_t nxadv_fg_sendts;       /* foreground traffic timestamp */
1237 	uint64_t nxadv_rt_sendts;       /* realtime traffic timestamp */
1238 	union {
1239 #if defined(LIBSYSCALL_INTERFACE) || defined(BSD_KERNEL_PRIVATE)
1240 		struct __kern_netif_intf_advisory _nxadv_intf_adv;
1241 #endif /* LIBSYSCALL_INTERFACE || BSD_KERNEL_PRIVATE */
1242 		uint8_t _nxadv_reserved[NX_INTF_ADV_SIZE];
1243 	};
1244 } __attribute__((aligned(sizeof(uint64_t))));
1245 
1246 /* Flowswitch nexus advisory version */
1247 #define NX_ADVISORY_VERSION     1
1248 #define NX_ADVISORY_VERSION_2   2
1249 #define NX_ADVISORY_CURRENT_VERSION     NX_ADVISORY_VERSION_2
1250 #define NX_FLOWSWITCH_ADVISORY_CURRENT_VERSION    NX_ADVISORY_CURRENT_VERSION
1251 
1252 typedef enum {
1253 	/*
1254 	 * TCP states.
1255 	 */
1256 	SFT_STATE_CLOSED = 0,           /* closed */
1257 	SFT_STATE_LISTEN,               /* listening for connection */
1258 	SFT_STATE_SYN_SENT,             /* active, have sent SYN */
1259 	SFT_STATE_SYN_RECEIVED,         /* have sent and rcvd SYN */
1260 	SFT_STATE_ESTABLISHED,          /* established */
1261 	SFT_STATE_CLOSE_WAIT,           /* rcvd FIN, waiting close */
1262 	SFT_STATE_FIN_WAIT_1,           /* have sent FIN */
1263 	SFT_STATE_CLOSING,              /* exchanged FINs, waiting FIN|ACK */
1264 	SFT_STATE_LAST_ACK,             /* rcvd FIN, closed, waiting FIN|ACK */
1265 	SFT_STATE_FIN_WAIT_2,           /* closed, FIN is ACK'd */
1266 	SFT_STATE_TIME_WAIT,            /* quiet wait after close */
1267 
1268 	/*
1269 	 * UDP states.
1270 	 */
1271 	SFT_STATE_NO_TRAFFIC = 20,      /* no packet observed */
1272 	SFT_STATE_SINGLE,               /* single packet */
1273 	SFT_STATE_MULTIPLE,             /* multiple packets */
1274 
1275 	SFT_STATE_MAX = 255
1276 } sk_stats_flow_track_state_t;
1277 
1278 struct sk_stats_flow_track {
1279 	uint64_t        sft_bytes;      /* bytes */
1280 	uint64_t        sft_packets;    /* packets */
1281 	uint64_t        sft_spackets;   /* super packets */
1282 	sk_stats_flow_track_state_t sft_state;  /* SFT_STATE_* */
1283 	uint32_t        sft_rtt;        /* avg ack rtt at flowswith */
1284 	uint32_t        sft_seq;        /* max sequence number sent */
1285 	uint16_t        sft_max_win;    /* largest window (pre scaling) */
1286 	uint8_t         sft_wscale;     /* window scaling factor */
1287 };
1288 
1289 #define FLOW_STATS_IN_ADD(fe, stat, cnt) { \
1290 	volatile struct sk_stats_flow_track *fst; \
1291 	fst = &(fe)->fe_stats->fs_rtrack; \
1292 	fst->sft_##stat += (cnt); \
1293 }
1294 
1295 #define FLOW_STATS_OUT_ADD(fe, stat, cnt) { \
1296 	volatile struct sk_stats_flow_track *fst; \
1297 	fst = &(fe)->fe_stats->fs_ltrack; \
1298 	fst->sft_##stat += (cnt); \
1299 }
1300 
1301 /*
1302  * Skywalk flow (in kernel), equivalent of "net.inet.*.pcblist_n".
1303  * Output: Array of struct sk_stats_flow (per flow).
1304  */
1305 #define SK_STATS_FLOW   "kern.skywalk.stats.flow"
1306 struct sk_stats_flow {
1307 	uuid_t          sf_nx_uuid;             /* nexus instance uuid */
1308 	char            sf_if_name[IFNAMSIZ];   /* interface name */
1309 	uint32_t        sf_if_index;            /* interface index */
1310 	uint32_t        sf_bucket_idx;          /* flow bucket index */
1311 
1312 	pid_t           sf_pid;                 /* flow pid */
1313 	pid_t           sf_epid;                /* flow effective pid */
1314 	char            sf_proc_name[32];       /* flow proc name */
1315 	char            sf_eproc_name[32];      /* flow effecitve proc name */
1316 
1317 	uint32_t        sf_flags;               /* SFLOWF_* */
1318 	nexus_port_t    sf_nx_port;             /* nexus port */
1319 
1320 	uint8_t         sf_protocol;            /* effective protocol */
1321 	packet_svc_class_t sf_svc_class;        /* service class */
1322 	flowadv_idx_t   sf_adv_idx;             /* flow advistory table index */
1323 	struct flow_key sf_key __attribute__((__aligned__(16)));
1324 
1325 	volatile struct sk_stats_flow_track sf_ltrack; /* local states */
1326 	volatile struct sk_stats_flow_track sf_rtrack; /* remote states */
1327 #define sf_obytes       sf_ltrack.sft_bytes
1328 #define sf_opackets     sf_ltrack.sft_packets
1329 #define sf_ospackets    sf_ltrack.sft_spackets
1330 #define sf_ibytes       sf_rtrack.sft_bytes
1331 #define sf_ipackets     sf_rtrack.sft_packets
1332 #define sf_ispackets    sf_rtrack.sft_spackets
1333 #define sf_lrtt         sf_ltrack.sft_rtt
1334 #define sf_rrtt         sf_rtrack.sft_rtt
1335 #define sf_lseq         sf_ltrack.sft_seq
1336 #define sf_rseq         sf_rtrack.sft_seq
1337 #define sf_lmax_win     sf_ltrack.sft_max_win
1338 #define sf_rmax_win     sf_rtrack.sft_max_win
1339 #define sf_lwscale      sf_ltrack.sft_wscale
1340 #define sf_rwscale      sf_rtrack.sft_wscale
1341 
1342 	activity_bitmap_t sf_activity;          /* flow activity bitmap */
1343 };
1344 
1345 /* valid values for sf_flags */
1346 #define SFLOWF_TRACK            0x00000010      /* flow is tracked */
1347 #define SFLOWF_CONNECTED        0x00000020      /* connected mode */
1348 #define SFLOWF_LISTENER         0x00000040      /* listener mode */
1349 #define SFLOWF_QOS_MARKING      0x00000100      /* flow can have qos marking */
1350 #define SFLOWF_BOUND_IP         0x00000200      /* src addr explicity bound */
1351 #define SFLOWF_ONLINK           0x00000400      /* dst directly on the link */
1352 #define SFLOWF_LOW_LATENCY      0x00000800      /* low latency flow */
1353 #define SFLOWF_WAIT_CLOSE       0x00001000      /* defer free after close */
1354 #define SFLOWF_CLOSE_NOTIFY     0x00002000      /* notify NECP upon tear down */
1355 #define SFLOWF_ABORTED          0x01000000      /* has sent RST to peer */
1356 #define SFLOWF_NONVIABLE        0x02000000      /* disabled; to be torn down */
1357 #define SFLOWF_WITHDRAWN        0x04000000      /* flow has been withdrawn */
1358 #define SFLOWF_TORN_DOWN        0x08000000      /* torn down, to be destroyed */
1359 #define SFLOWF_PARENT           0x10000000      /* parent flow */
1360 #define SFLOWF_CHILD            0x20000000      /* child flow */
1361 #define SFLOWF_DESTROYED        0x40000000      /* not in RB trees anymore */
1362 #define SFLOWF_LINGERING        0x80000000      /* destroyed and lingering */
1363 
1364 #define SFLOW_BUCKET_NONE       ((uint32_t)-1)
1365 
1366 #if defined(BSD_KERNEL_PRIVATE)
1367 #include <os/refcnt.h>
1368 
1369 /*
1370  * flow_stats is the kernel stats object that serves as efficient conduit
1371  * between stats producer (the Skywalk flowswitch) and consumers
1372  * (e.g. necp_client/ntstat). It embeds the sk_stats_flow along with a
1373  * reference count. The flow_stats object would be freed when released and
1374  * refcnt reaches 0. There must be only one producer and/or multiple consumers.
1375  * There is no lock protecting the stats object as inconsistent intermediate
1376  * state data is tolerable for stats consumers and most fields, e.g. integer
1377  * counters, are updated atomically. Synchronization of producer/consumer
1378  * should be done via other means, e.g. necp/ntstat events, rather than on the
1379  * flow_stats itself.
1380  *
1381  * Fields in flow_stats.fs_stats are published in different phases:
1382  *     - Descriptor fields
1383  *         ID, names, address, etc. which are immutable during flow lifetime,
1384  *         which are initialized during creation time.
1385  *     - State fields
1386  *         Flow state, track state, etc. which are mutable. They are
1387  *         initialized during flow creation time, but lazily updated during
1388  *         runtime and upon synchronous retrieval.
1389  *     - Runtime fields
1390  *         Counters (packets in/out, bytes in/out, rtt, etc.), which are
1391  *         mutable and updated in real-time.
1392  *
1393  * Note the reduced alignment for sk_stats_flow and sk_stats_flow_track to
1394  * reduce the allocation size.
1395  */
1396 struct flow_stats {
1397 	struct sk_stats_flow    fs_stats;
1398 #define fs_ltrack       fs_stats.sf_ltrack
1399 #define fs_rtrack       fs_stats.sf_rtrack
1400 #define fs_activity     fs_stats.sf_activity
1401 #define fs_lrtt         fs_stats.sf_lrtt
1402 #define fs_rrtt         fs_stats.sf_rrtt
1403 
1404 	os_refcnt_t             fs_refcnt;
1405 };
1406 
1407 extern void flow_stats_free(struct flow_stats *fs);
1408 
1409 __attribute__((always_inline))
1410 static inline void
flow_stats_retain(struct flow_stats * fs)1411 flow_stats_retain(struct flow_stats *fs)
1412 {
1413 	os_ref_retain(&fs->fs_refcnt);
1414 }
1415 
1416 __attribute__((always_inline))
1417 static inline void
flow_stats_release(struct flow_stats * fs)1418 flow_stats_release(struct flow_stats *fs)
1419 {
1420 	if (__improbable(os_ref_release(&fs->fs_refcnt) == 0)) {
1421 		flow_stats_free(fs);
1422 	}
1423 }
1424 
1425 __attribute__((always_inline))
1426 static inline os_ref_count_t
flow_stats_refcnt(struct flow_stats * fs)1427 flow_stats_refcnt(struct flow_stats *fs)
1428 {
1429 	return os_ref_get_count(&fs->fs_refcnt);
1430 }
1431 #endif /* BSD_KERNEL_PRIVATE */
1432 
1433 #define SK_STATS_FLOW_OWNER     "kern.skywalk.stats.flow_owner"
1434 struct sk_stats_flow_owner {
1435 	uuid_t          sfo_nx_uuid;            /* nexus instance uuid */
1436 	char            sfo_if_name[IFNAMSIZ];  /* attached interface name */
1437 	uint32_t        sfo_bucket_idx;         /* flow owner bucket index */
1438 
1439 	char            sfo_name[32];           /* flow owner name */
1440 	pid_t           sfo_pid;                /* flow owner pid */
1441 
1442 	nexus_port_t    sfo_nx_port;            /* flow owner nexus port */
1443 	boolean_t       sfo_nx_port_pid_bound;  /* flow owner port pid bound */
1444 	boolean_t       sfo_nx_port_destroyed;  /* flow owner port destroyed */
1445 } __attribute__((aligned(64)));
1446 
1447 #define SK_STATS_FLOW_ROUTE     "kern.skywalk.stats.flow_route"
1448 struct sk_stats_flow_route {
1449 	uuid_t          sfr_nx_uuid;            /* nexus instance UUID */
1450 	uuid_t          sfr_uuid;               /* flow route UUID */
1451 	char            sfr_if_name[IFNAMSIZ];  /* interface name */
1452 
1453 	uint32_t        sfr_bucket_idx;         /* flow route bucket index */
1454 	uint32_t        sfr_id_bucket_idx;      /* flow route id bucket index */
1455 
1456 	uint32_t        sfr_flags;              /* SFLOWRTF_* */
1457 	uint32_t        sfr_usecnt;             /* flow route usecnt */
1458 	int64_t         sfr_expire;             /* seconds left to expire */
1459 
1460 	union sockaddr_in_4_6 sfr_laddr;        /* local address */
1461 	union sockaddr_in_4_6 sfr_faddr;        /* foreign address */
1462 	union sockaddr_in_4_6 sfr_gaddr;        /* gateway address */
1463 
1464 	uint8_t         sfr_ether_dhost[ETHER_ADDR_LEN]
1465 	__attribute__((aligned(64)));
1466 };
1467 
1468 /* valid values for sfr_flags */
1469 #define SFLOWRTF_ATTACHED       0x00000001 /* attached to RB trees */
1470 #define SFLOWRTF_ONLINK         0x00000010 /* dst directly on the link */
1471 #define SFLOWRTF_GATEWAY        0x00000020 /* gw IP address is valid */
1472 #define SFLOWRTF_RESOLVED       0x00000040 /* flow route is resolved */
1473 #define SFLOWRTF_HAS_LLINFO     0x00000080 /* has dst link-layer address */
1474 #define SFLOWRTF_DELETED        0x00000100 /* route has been deleted */
1475 #define SFLOWRTF_DST_LL_MCAST   0x00000200 /* dst is link layer multicast */
1476 #define SFLOWRTF_DST_LL_BCAST   0x00000400 /* dst is link layer broadcast */
1477 
1478 /*
1479  * Skywalk netif stats
1480  * Output: Array of struct sk_stats_net_if entry (per netif nexus instance).
1481  */
1482 #define SK_STATS_NET_IF         "kern.skywalk.stats.net_if"
1483 struct sk_stats_net_if {
1484 	uuid_t          sns_nx_uuid;            /* nexus netif instance uuid */
1485 	char            sns_if_name[IFNAMSIZ];  /* attached interface name */
1486 
1487 	struct netif_stats      sns_nifs;       /* netif stats */
1488 } __attribute__((aligned(64)));
1489 
1490 /*
1491  * Skywalk flowswitch stats
1492  * Output: Array of struct sk_stats_flow_switch entry (per fsw nexus instance).
1493  */
1494 #define SK_STATS_FLOW_SWITCH    "kern.skywalk.stats.flow_switch"
1495 struct sk_stats_flow_switch {
1496 	uuid_t          sfs_nx_uuid;            /* nexus fsw instance uuid */
1497 	char            sfs_if_name[IFNAMSIZ];  /* attached interface name */
1498 
1499 	struct fsw_stats        sfs_fsws;       /* flowswitch stats */
1500 } __attribute__((aligned(64)));
1501 
1502 /*
1503  * Skywalkuserstack stats
1504  *
1505  * With Skywalk, traditional kernel space stacks like tcp/udp/ip/ip6 are now
1506  * moved to userspace process. Together with this, stack statistics are now kept
1507  * per process via shared memory described by skywalk channel, which is in a
1508  * memory mapped region from a kernel nexus to a userspace process.
1509  *
1510  * Output: Array of struct sk_stats_userstack (per process, per nexus
1511  *         instance) Entries with nts_owner_pid == 0 are reserved for nexus
1512  *         stats collected from closed nexus ports.
1513  */
1514 #define SK_STATS_USERSTACK      "kern.skywalk.stats.userstack"
1515 struct sk_stats_userstack {
1516 	uuid_t                  sus_nx_uuid;    /* nexus instance uuid */
1517 	char            sus_if_name[IFNAMSIZ];  /* attached interface name */
1518 	pid_t                   sus_owner_pid;  /* owner process */
1519 
1520 	struct ip_stats         sus_ip;         /* process ip stats */
1521 	struct ip6_stats        sus_ip6;        /* process ip6 stats */
1522 	struct tcp_stats        sus_tcp;        /* process tcp stats */
1523 	struct udp_stats        sus_udp;        /* process udp stats */
1524 	struct quic_stats       sus_quic;       /* process quic stats */
1525 } __attribute__((aligned(64)));
1526 
1527 /*
1528  * Skywalk flow advisory table dump
1529  */
1530 struct sk_stats_flow_adv_ent {
1531 	uuid_t          sfae_flow_id;           /* flow ID */
1532 	uint32_t        sfae_flags;             /* flags, FLOWADVF_* */
1533 };
1534 
1535 #define SK_STATS_FLOW_ADV       "kern.skywalk.stats.flow_adv"
1536 struct sk_stats_flow_adv {
1537 	uuid_t          sfa_nx_uuid;            /* nexus instance uuid */
1538 	char            sfa_if_name[IFNAMSIZ];  /* attached interface name */
1539 	pid_t           sfa_owner_pid;          /* owner process */
1540 
1541 	uint32_t        sfa_entries_count;      /* number of flow adv entries */
1542 	struct sk_stats_flow_adv_ent    sfa_entries[0]; /* flow adv entries */
1543 };
1544 
1545 /*
1546  * struct netns_ctl_dump_header is used for sysctl 'kern.skywalk.stats.netns'
1547  * which returns a buffer containing the contents of every netns namespace.
1548  * The buffer is formatted as a series headers, each immediately followed by
1549  * some number of records:
1550  *    { struct netns_ctl_dump_header h,
1551  *      struct netns_ctl_dump_record r[h->ncdh_n_records] } * total_namespaces
1552  */
1553 #define SK_STATS_NETNS          "kern.skywalk.stats.netns"
1554 struct netns_ctl_dump_header {
1555 	union {
1556 		uint32_t        ncdh_addr[4];
1557 		struct in_addr  ncdh_inaddr;
1558 		struct in6_addr ncdh_in6addr;
1559 	};
1560 	uint8_t         ncdh_addr_len;
1561 	uint8_t         ncdh_proto;
1562 	uint32_t        ncdh_n_records;
1563 	/*
1564 	 * In a 'kern.skywalk.stats.netns' response, followed by
1565 	 * {ncdh_n_records} struct netns_ctl_dump_records
1566 	 */
1567 } __attribute__((aligned(32)));
1568 
1569 struct netns_ctl_dump_record {
1570 	in_port_t ncdr_port;
1571 	in_port_t ncdr_port_end;
1572 	uint32_t  ncdr_skywalk_refs;
1573 	uint32_t  ncdr_bsd_refs;
1574 	uint32_t  ncdr_pf_refs;
1575 	uint32_t  ncdr_listener_refs;
1576 } __attribute__((aligned(32)));
1577 
1578 #define NS_DUMP_SIZE(records)   (sizeof (struct netns_ctl_dump_header) + \
1579 	records * sizeof (struct netns_ctl_dump_record))
1580 
1581 #define SK_STATS_PROTONS        "kern.skywalk.stats.protons"
1582 struct sk_stats_protons_token {
1583 	uint8_t                 spt_protocol;
1584 	uint32_t                spt_refcnt;
1585 	pid_t                   spt_pid;
1586 	pid_t                   spt_epid;
1587 };
1588 
1589 /*
1590  * struct sk_stats_flowidns_header is used for
1591  * sysctl 'kern.skywalk.stats.flowidns' * which returns a buffer containing
1592  * the contents of every flowid.
1593  * The buffer is formatted as a series headers, each immediately followed by
1594  * some number of records:
1595  * { struct sk_stats_flowidns_header h,
1596  *   struct sk_stats_flowidns_record r[h->sfh_nrecords] } * num_flow_domains
1597  */
1598 #define SK_STATS_FLOWIDNS    "kern.skywalk.stats.flowidns"
1599 struct sk_stats_flowidns_header {
1600 	uint64_t sfh_nallocs;
1601 	uint64_t sfh_nreleases;
1602 	uint64_t sfh_ncollisions;
1603 	uint32_t sfh_domain;
1604 	uint32_t sfh_nrecords;
1605 	/*
1606 	 * In a 'kern.skywalk.stats.flowidns' response, followed by
1607 	 * {sfh_n_records} struct sk_stats_flowidns_record
1608 	 */
1609 } __attribute__((aligned(32)));
1610 
1611 /* valid values for sfh_domain */
1612 #define SFH_DOMAIN_IPSEC         0
1613 #define SFH_DOMAIN_FLOWSWITCH    1
1614 #define SFH_DOMAIN_INPCB         2
1615 #define SFH_DOMAIN_PF            3
1616 
1617 
1618 struct sk_stats_flowidns_record {
1619 	union {
1620 		uint32_t        _addr[4];
1621 		struct in_addr  _v4;
1622 		struct in6_addr _v6;
1623 	} sfr_laddr;
1624 	union {
1625 		uint32_t        _addr[4];
1626 		struct in_addr  _v4;
1627 		struct in6_addr _v6;
1628 	} sfr_raddr;
1629 	union {
1630 		struct {
1631 			uint16_t _lport;
1632 			uint16_t _rport;
1633 		} sfr_ports;
1634 		uint32_t sfr_spi;
1635 		uint32_t sfr_protoid;
1636 	};
1637 	uint32_t sfr_flowid;
1638 	uint8_t  sfr_ipproto;
1639 	uint8_t  sfr_af;
1640 } __attribute__((aligned(32)));
1641 
1642 #define sfr_laddr_v4    sfr_laddr._v4
1643 #define sfr_laddr_v6    sfr_laddr._v6
1644 #define sfr_raddr_v4    sfr_raddr._v4
1645 #define sfr_raddr_v6    sfr_raddr._v6
1646 #define sfr_lport       sfr_ports._lport
1647 #define sfr_rport       sfr_ports._rport
1648 
1649 
1650 #define FLOWIDNS_BUFFER_SIZE(_records)                       \
1651 	(sizeof (struct sk_stats_flowidns_header) +          \
1652 	_records * sizeof (struct sk_stats_flowidns_record))
1653 
1654 typedef enum {
1655 	/*
1656 	 * The following are user task mappable.
1657 	 */
1658 	SREG_GUARD_HEAD = 0,    /* leading guard page(s) */
1659 	SREG_SCHEMA,            /* channel layout */
1660 	SREG_RING,              /* rings */
1661 	SREG_BUF_DEF,           /* Default rx/tx buffers */
1662 	SREG_BUF_LARGE,         /* Large rx/tx buffers */
1663 	SREG_RXBUF_DEF,         /* Default rx only buffers */
1664 	SREG_RXBUF_LARGE,       /* Large rx only buffers */
1665 	SREG_TXBUF_DEF,         /* Default tx only buffers */
1666 	SREG_TXBUF_LARGE,       /* Large tx only buffers */
1667 	SREG_UMD,               /* userland metadata */
1668 	SREG_TXAUSD,            /* tx/alloc user slot descriptors */
1669 	SREG_RXFUSD,            /* rx/free user slot descriptors */
1670 	SREG_UBFT,              /* userland buflet metadata */
1671 	SREG_USTATS,            /* statistics */
1672 	SREG_FLOWADV,           /* flow advisories */
1673 	SREG_NEXUSADV,          /* nexus advisories */
1674 	SREG_SYSCTLS,           /* sysctl */
1675 	SREG_GUARD_TAIL,        /* trailing guard page(s) */
1676 
1677 	/*
1678 	 * The following are NOT user task mappable.
1679 	 */
1680 	SREG_KMD,               /* rx/tx kernel metadata */
1681 	SREG_RXKMD,             /* rx only kernel metadata */
1682 	SREG_TXKMD,             /* tx only kernel metadata */
1683 	SREG_KBFT,              /* rx/tx kernel buflet metadata */
1684 	SREG_RXKBFT,            /* rx only kernel buflet metadata */
1685 	SREG_TXKBFT,            /* tx only kernel buflet metadata */
1686 	SREG_TXAKSD,            /* tx/alloc kernel slot descriptors */
1687 	SREG_RXFKSD,            /* rx/free kernel slot descriptors */
1688 	SREG_KSTATS,            /* kernel statistics snapshot */
1689 	SREG_INSTRINSIC,        /* intrinsic objects */
1690 
1691 	SREG_MAX                /* max */
1692 } sk_stats_region_id_t;
1693 
1694 #define SK_STATS_REGION         "kern.skywalk.stats.region"
1695 struct sk_stats_region {
1696 	/*
1697 	 * Region properties.
1698 	 */
1699 	char            sreg_name[64];          /* region name */
1700 	uuid_t          sreg_uuid;              /* region uuid */
1701 	sk_stats_region_id_t sreg_id;           /* region ID */
1702 	uint32_t        sreg_mode;              /* region mode flags */
1703 
1704 	/*
1705 	 * Region parameters.
1706 	 */
1707 	uint64_t        sreg_r_seg_size;        /* requested seg size */
1708 	uint64_t        sreg_c_seg_size;        /* configured seg size */
1709 	uint64_t        sreg_seg_cnt;           /* number of segments */
1710 	uint64_t        sreg_seg_objs;          /* # of objects per segment */
1711 	uint64_t        sreg_r_obj_size;        /* requested obj size */
1712 	uint64_t        sreg_r_obj_cnt;         /* requested obj count */
1713 	uint64_t        sreg_c_obj_size;        /* configured obj size */
1714 	uint64_t        sreg_c_obj_cnt;         /* configured obj count */
1715 	uint64_t        sreg_align;             /* object alignment */
1716 	uint64_t        sreg_max_frags;         /* max number of buflets */
1717 
1718 	/*
1719 	 * Region statistics.
1720 	 */
1721 	uint64_t        sreg_meminuse;          /* memory in use */
1722 	uint64_t        sreg_w_meminuse;        /* wired memory in use */
1723 	uint64_t        sreg_memtotal;          /* total memory in region */
1724 	uint64_t        sreg_seginuse;          /* total unfreed segments */
1725 	uint64_t        sreg_rescale;           /* # of hash table rescales */
1726 	uint64_t        sreg_hash_size;         /* size of hash table */
1727 	uint64_t        sreg_alloc;             /* number of allocations */
1728 	uint64_t        sreg_free;              /* number of frees */
1729 };
1730 
1731 /* valid values for sreg_mode */
1732 #define SREG_MODE_NOREDIRECT    0x1     /* unaffected by defunct */
1733 #define SREG_MODE_MMAPOK        0x2     /* can be mapped to user task */
1734 #define SREG_MODE_KREADONLY     0x4     /* kernel read-only */
1735 #define SREG_MODE_UREADONLY     0x8     /* if user map, map it read-only */
1736 #define SREG_MODE_PERSISTENT    0x10    /* memory stays non-volatile */
1737 #define SREG_MODE_MONOLITHIC    0x20    /* monolithic region */
1738 #define SREG_MODE_NOMAGAZINES   0x40    /* disable magazines layer */
1739 #define SREG_MODE_NOCACHE       0x80    /* caching-inhibited */
1740 #define SREG_MODE_SEGPHYSCONTIG 0x100   /* phys. contiguous segment */
1741 #define SREG_MODE_SHAREOK       0x200   /* allow object sharing */
1742 #define SREG_MODE_IODIR_IN      0x400   /* I/O direction In */
1743 #define SREG_MODE_IODIR_OUT     0x800   /* I/O direction Out */
1744 #define SREG_MODE_GUARD         0x1000  /* guard pages region */
1745 #define SREG_MODE_PUREDATA      0x2000  /* purely data; no pointers */
1746 #define SREG_MODE_PSEUDO        0x4000  /* external backing store */
1747 #define SREG_MODE_THREADSAFE    0x8000  /* external backing store */
1748 #define SREG_MODE_SLAB          (1U << 30) /* backend for slab layer */
1749 #define SREG_MODE_MIRRORED      (1U << 31) /* controlled by another region */
1750 
1751 #define SREG_MODE_BITS                                                  \
1752 	"\020\01NOREDIRECT\02MMAPOK\03KREADONLY\04UREADONLY"            \
1753 	"\05PERSISTENT\06MONOLITHIC\07NOMAGAZINES\10NOCACHE"            \
1754 	"\11SEGPHYSCONTIG\012SHAREOK\013IODIR_IN\014IODIR_OUT"          \
1755 	"\015GUARD\016PUREDATA\017PSEUDO\020THREADSAFE\037SLAB"         \
1756 	"\040MIRRORED"
1757 
1758 typedef enum {
1759 	SAR_TYPE_NEXUS,
1760 	SAR_TYPE_NECP,
1761 	SAR_TYPE_SYSTEM,
1762 } sk_stats_arena_type_t;
1763 
1764 #define SK_STATS_ARENA          "kern.skywalk.stats.arena"
1765 struct sk_stats_arena {
1766 	char                    sar_name[64];
1767 	sk_stats_arena_type_t   sar_type;
1768 	uint64_t                sar_mapsize;
1769 	uuid_t                  sar_regions_uuid[SREG_MAX];
1770 #define SK_STATS_ARENA_MAPPED_PID_MAX   8
1771 	pid_t                   sar_mapped_pids[SK_STATS_ARENA_MAPPED_PID_MAX];
1772 };
1773 
1774 #define SK_STATS_CACHE          "kern.skywalk.stats.cache"
1775 struct sk_stats_cache {
1776 	/*
1777 	 * Cache parameters.
1778 	 */
1779 	char            sca_name[64];           /* cache name */
1780 	uuid_t          sca_uuid;               /* cache uuid */
1781 	uuid_t          sca_ruuid;              /* backing region uuid */
1782 	uint32_t        sca_mode;               /* cache mode flags */
1783 	uint64_t        sca_bufsize;            /* object size */
1784 	uint64_t        sca_objsize;            /* actual obj size in slab */
1785 	uint64_t        sca_chunksize;          /* bufsize + alignment */
1786 	uint64_t        sca_slabsize;           /* size of a slab */
1787 	uint64_t        sca_bufalign;           /* buffer alignment */
1788 	uint64_t        sca_objalign;           /* object alignment */
1789 
1790 	/*
1791 	 * Per-CPU caches statistics.
1792 	 */
1793 	uint64_t        sca_cpu_mag_size;       /* current magazine size */
1794 	uint64_t        sca_cpu_mag_resize;     /* # of magazine resizes */
1795 	uint64_t        sca_cpu_mag_purge;      /* # of magazine purges */
1796 	uint64_t        sca_cpu_mag_reap;       /* # of magazine reaps */
1797 	uint64_t        sca_depot_full;         /* # of full magazines */
1798 	uint64_t        sca_depot_empty;        /* # of empty magazines */
1799 	uint64_t        sca_depot_ws_zero;      /* # of working set flushes */
1800 	uint64_t        sca_depot_contention_factor; /* contention factor */
1801 
1802 	/*
1803 	 * Slab statistics.
1804 	 */
1805 	uint64_t        sca_sl_create;          /* slab creates */
1806 	uint64_t        sca_sl_destroy;         /* slab destroys */
1807 	uint64_t        sca_sl_alloc;           /* slab layer allocations */
1808 	uint64_t        sca_sl_free;            /* slab layer frees */
1809 	uint64_t        sca_sl_alloc_fail;      /* total failed allocations */
1810 	uint64_t        sca_sl_partial;         /* # of partial slabs */
1811 	uint64_t        sca_sl_empty;           /* # of empty slabs */
1812 	uint64_t        sca_sl_bufinuse;        /* total unfreed buffers */
1813 	uint64_t        sca_sl_rescale;         /* # of hash table rescales */
1814 	uint64_t        sca_sl_hash_size;       /* size of hash table */
1815 };
1816 
1817 /* valid values for sca_mode */
1818 #define SCA_MODE_NOMAGAZINES    0x00000001      /* disable magazines layer */
1819 #define SCA_MODE_AUDIT          0x00000002      /* audit transactions */
1820 #define SCA_MODE_NOREDIRECT     0x00000004      /* unaffected by defunct */
1821 #define SCA_MODE_BATCH          0x00000008      /* supports batch alloc/free */
1822 #define SCA_MODE_DYNAMIC        0x00000010      /* enable magazine resizing */
1823 #define SCA_MODE_CLEARONFREE    0x00000020      /* zero-out upon slab free */
1824 #define SCA_MODE_PSEUDO         0x00000040      /* external backing store */
1825 
1826 #define SCA_MODE_BITS \
1827 	"\020\01NOMAGAZINES\02AUDIT\03NOREDIRECT\04BATCH\05DYNAMIC"     \
1828 	"\06CLEARONFREE\07PSEUDO"
1829 
1830 #endif /* PRIVATE || BSD_KERNEL_PRIVATE */
1831 #endif /* !_SKYWALK_OS_STATS_H_ */
1832