stream_statistics.h Source File

Reference Documentation

Platform
Napatech SmartNIC
Content Type
Reference Information
Capture Software Version
Link™ Capture Software 12.15
Napatech Software Suite: include/ntapi/stream_statistics.h Source File
stream_statistics.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright (C) 2025 Napatech A/S.
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are met:
8  * * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * * Neither the name of the Napatech A/S nor the
14  * names of its contributors may be used to endorse or promote products
15  * derived from this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20  * DISCLAIMED. IN NO EVENT SHALL NAPATECH A/S BE LIABLE FOR ANY
21  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  *
28  *
29 
30  */
31 
32 /**
33  * @file
34  *
35  * This is the header file of the statistics stream interface
36  */
37 #ifndef __STREAM_STATISTICS_H__
38 #define __STREAM_STATISTICS_H__
39 
40 #if !defined(__NT_H__)
41  #error: My interface file is 'nt.h'. Please include that via #include "nt.h" directly.
42 #endif
43 
44 /** @addtogroup StatStream
45  * @{
46  *
47  * The statistics stream is used to access statistics from the
48  * system. The statistics stream is read only.
49  *
50  * Statistical information is retrieved using the @ref
51  * NtStatisticsCmd_e::NT_STATISTICS_READ_CMD_QUERY_V3
52  * "NT_STATISTICS_READ_CMD_QUERY_V3" command in a call to @ref NT_StatRead
53  * on an open statistics stream. This command will fill out the
54  * supplied @ref NtStatistics_t structure with port and color based
55  * statistics for all adapters in the system. The @ref
56  * NtPortStatistics_v1_s::NtPortStatisticsValid_v1_s "NtPortStatisticsValid_v1_s" structure can
57  * be used to check which returned part of the @ref NtPortStatistics_v1_s
58  * structure is valid. This is useful since not all adapters support
59  * all types of statistical information.
60  *
61  * @par
62  * @note
63  * Be aware that statistics from multiple adapters are only
64  * synchronized if the time is synchronized.
65  *
66  * For an example on how to use the statistics stream see @ref
67  * stat/stat_example.c "stat/stat_example.c".
68  *
69  * @section ColorStatistics Color Statistics
70  * The color statistics for each color are found by counting the number of
71  * packets getting that specific color.\n
72  * The colors are specified in some assign commands using either the 'Color' or
73  * 'ColorMask' options. By default all packets will get color 0. It is totally
74  * up to the application what meaning that should be put into a given color.
75  * The color statistics work probably best with the prioritized 'Color' option
76  * where the packet gets its color from one unique source. If you use the 'ColorMask'
77  * option, you can easily have a situation where one packet increments more than
78  * one color counter.
79  *
80  * Color counters are never reset. It is the responsibility of the application to
81  * handle this.
82  *
83  * It can be achieved by remembering the counter values for a given color
84  * when it was first configured and then subsequently only showing the
85  * delta compared to this initial value.
86  * Another option is to set the clear flag in @ref NtStatisticsQuery_v2_s::clear
87  * on the first call to @ref NT_StatRead. This will make the subsequent calls
88  * to @ref NT_StatRead return only the delta compared to the first call.
89  *
90  * Be aware that setting this clear flag will clear all statistics counters.
91  * If this is not desirable the application will have to handle it by itself.
92  *
93  * @par
94  * @note
95  * The color statistics only supports counters for colors 0-63 which could give rise
96  * to confusion as you can use 32 bits in the 'ColorMask' option. Only the lower 6 bits
97  * in the color field are considered when updating the color counters.
98  *
99  * @par
100  * @note
101  * Color statistics are only updated by packets that are assigned to a stream (including
102  * StreamId=drop). Packets that are not matched by any NTPL filter, or are matched by a
103  * filter that does not assign a StreamId (or inherit a StreamId from a previous filter),
104  * will not contribute to color statistics.
105  *
106  * @par
107  * @note The statistic stream is not thread-safe. If the same stream handle is to be used by multiple threads,
108  * it must be mutex protected in the application.
109  *
110  */
111 #include "ntapi/commontypes.h"
112 
113 /**
114  * Possible statistics read commands
115  */
117  NT_STATISTICS_READ_CMD_UNKNOWN=0, //!< Unknown read command
118  NT_STATISTICS_READ_CMD_COMPAT_0, //!< Command for backward compatibility - defined in stream_statistics_compat.h
119  NT_STATISTICS_READ_CMD_COMPAT_1, //!< Command for backward compatibility - defined in stream_statistics_compat.h
120  NT_STATISTICS_READ_CMD_COMPAT_2, //!< Command for backward compatibility - defined in stream_statistics_compat.h
121  NT_STATISTICS_READ_CMD_COMPAT_3, //!< Command for backward compatibility - defined in stream_statistics_compat.h
122  NT_STATISTICS_READ_CMD_USAGE_DATA_V0, //!< Reads hostbuffer, streamid and SDRAM usage data
123  NT_STATISTICS_READ_CMD_FLOW_V0, //!< Reads flow matcher statistics
124  NT_STATISTICS_READ_CMD_FLOW_V1, //!< Reads flow matcher statistics
125  NT_STATISTICS_READ_CMD_FLOW_V2, //!< Reads flow matcher statistics
126  NT_STATISTICS_READ_CMD_QUERY_V4, //!< Reads all the statistical information version 4
127 };
128 
129 /**
130  * RMON1 counters as defined in RFC 2819
131  */
133  uint64_t dropEvents; //!< Number of events where packet(s) are dropped by the MAC because they are too small or the MAC has bandwidth issues
134  uint64_t octets; //!< Number of octets received by the port (good and bad)
135  uint64_t pkts; //!< Number of packets received by the port (good and bad)
136  uint64_t broadcastPkts; //!< Number of broadcast packets including MAC control packets
137  uint64_t multicastPkts; //!< Number of multicast packets including MAC pause and MAC control packets
138  uint64_t crcAlignErrors; //!< Number of packets with CRC/Align errors
139  uint64_t undersizePkts; //!< Number of packets < 64 octets.\n<b>Note:</b> 100G products with Xilinx FPGA drop packets smaller than 64 bytes. Packets < 64 octets are instead counted as dropEvents. The counter undersizePkts is always 0 on these products.\n <b>Note:</b> When packets with a size in the range [17..63] are transmitted on the following 1G adapters: NT4E2-4-PTP, NT4E2-4T-BP, NT4E and NT4E-STD using the segment interface, the packets will silently be padded to a size of 64 bytes, which is the size reported by @ref NtLinkCapabilities_s::minTxPktSize. For this reason they will be registered as 64 octet packets and not as an undersize packets.
140  uint64_t oversizePkts; //!< Number of packets > 1518 octets (and for NT adapters, packets > MAX and packets < 10000) If packets count here they do not count in the packet and octet counters.\n<b>Note:</b> This counter doesn't count in the TX direction for the following products: NT4E CAPTURE, NT4E-STD CAPTURE, NT20E CAPTURE.
141  uint64_t fragments; //!< Number of packets < 64 octets with errors.\n<b>Note:</b> 100G products with Xilinx FPGA drop packets smaller than 64 bytes. Packets < 64 octets are instead counted as dropEvents. The counter fragments is always 0 on these products.\n
142  uint64_t jabbers; //!< Number of packets > MAX with errors - if packets count here they do not count in the packets and octets counters
143  uint64_t collisions; //!< Number of collisions detected
144  uint64_t pkts64Octets; //!< Number of packets = 64 octets
145  uint64_t pkts65to127Octets; //!< Number of packets in the range 65 to 127 octets
146  uint64_t pkts128to255Octets; //!< Number of packets in the range 128 to 255 octets
147  uint64_t pkts256to511Octets; //!< Number of packets in the range 256 to 511 octets
148  uint64_t pkts512to1023Octets; //!< Number of packets in the range 512 to 1023 octets
149  uint64_t pkts1024to1518Octets; //!< Number of packets in the range 1024 to 1518 octets
150 };
151 
152 /**
153  * Extended RMON - these counters are used to categorize packets not handled by RMON1
154  */
156  uint64_t pkts1519to2047Octets; //!< Number of packets in the range 1519 to 2047 octets
157  uint64_t pkts2048to4095Octets; //!< Number of packets in the range 2048 to 4095 octets
158  uint64_t pkts4096to8191Octets; //!< Number of packets in the range 4096 to 8191 octets
159  uint64_t pkts8192toMaxOctets; //!< Number of packets in the range 8192 to MAX octets
160  uint64_t pktsHardSlice; //!< Number of packets in the range 10001 to 16383 octets
161  uint64_t pktsHardSliceJabber; //!< Number of bad packets in the range 10001 to 16383 octets and packets > 16383 octets
162  uint64_t unicastPkts; //!< Number of Unicast packets including MAC control packets
163  // The following counters are also counted as a sum in @ref NtRMON1Counters_s::crcAlignErrors.
164  uint64_t pktsCrc; //!< Number of packets with CRC errors
165  uint64_t pktsAlignment; //!< Number of packets with alignment errors
166  uint64_t pktsCodeViolation; //!< Number of packets with code violation errors
167  uint64_t pktsRetransmit;
168 };
169 
170 /**
171  * Checksum counters - these counters count packets with IP/TCP/UDP errors
172  */
174  uint64_t pktsIpChkSumError; //!< Number of packets with IP checksum errors
175  uint64_t pktsUdpChkSumError; //!< Number of packets with UDP checksum errors
176  uint64_t pktsTcpChkSumError; //!< Number of packets with TCP checksum errors
177 } ;
178 
179 /**
180  * Packet decoding counters - these counters are available on adapters with a packet decoder
181  */
183  uint64_t pktsGiantUndersize; //!< Number of packets > 63 bytes including tags and =< 63 excluding tags
184  uint64_t pktsBabyGiant; //!< Number of packets > MAX including tags and =< MAX excluding tags
185  uint64_t pktsNotIslVlanMpls; //!< Number of packets without ISL, VLAN and MPLS
186  uint64_t pktsIsl; //!< Number of packets with ISL
187  uint64_t pktsVlan; //!< Number of packets with VLAN
188  uint64_t pktsIslVlan; //!< Number of packets with ISL and VLAN
189  uint64_t pktsMpls; //!< Number of packets with MPLS
190  uint64_t pktsIslMpls; //!< Number of packets with ISL and MPLS
191  uint64_t pktsVlanMpls; //!< Number of packets with VLAN and MPLS
192  uint64_t pktsIslVlanMpls; //!< Number of packets with ISL, VLAN and MPLS
193  uint64_t pktsDuplicate; //!< Number of packets marked as duplicates
194 };
195 
196 /**
197  * Extended drop counters - these counters will count the packets
198  * dropped for various reasons
199  */
201  uint64_t pktsMacBandwidth; //!< Number of packets dropped by the MAC because of bandwidth issues and number of packets < 17 octets. This counter is also available in @ref NtRMON1Counters_s::dropEvents.
202 
203  uint64_t pktsOverflow; //!< Number of packets dropped because the associated SDRAM and host buffers are full
204  uint64_t octetsOverflow; //!< Number of octets dropped because the associated SDRAM and host buffers are full
205 
206  uint64_t pktsDedup; //!< Number of packets dropped because of deduplication
207  uint64_t octetsDedup; //!< Number of octets dropped because of deduplication
208 
209  uint64_t pktsNoFilter; //!< Number of packets dropped because they do not match a filter
210  uint64_t octetsNoFilter; //!< Number of octets dropped because they do not match a filter
211 
212  uint64_t pktsFilterDrop; //!< Number of packets dropped because they are explicitly dropped
213  uint64_t octetsFilterDrop; //!< Number of octets dropped because they are explicitly dropped
214 };
215 
216 
217 /**
218  * Color counters
219  */
221  uint64_t pkts; //!< Number of packets
222  uint64_t octets; //!< Number of octets
223 //
224 
225 };
226 
227 /**
228  * Statistics info group for color statistics
229  */
231  int supported; //!< Set if color statistics is supported
232 //
233 
234  struct NtColorStatistics_s aColor[64]; //!< The color statistics
235 //
236 
237  uint64_t ts; //!< Color counter sample time stamp. The format of the timestamp is specified by @ref tsType.
238  enum NtTimestampType_e tsType; //!< Time stamp type - For a description of the time stamp type see "DN-0384 3GD Time-Stamping and Time Synchronization User Guide"
239 };
240 
241 /**
242  * Statistics info group for adapter statistics
243  */
245  struct NtStatGroupColor_s color;
246 };
247 
248 
249 /**
250  * Statistics info for FEC
251  */
253  uint64_t fecCorrCW; //!< Corrected FEC code words
254  uint64_t fecUncorrCW; //!< Uncorrected FEC code words
255  uint64_t fecCorrCWbins[16]; //!< FEC code words with [0..15] corrections
256 };
257 
258 /**
259  * FEC lane status
260  */
262  uint8_t hiSer; //!< High symbol error rate detected.
263  uint8_t mapping; //!< Virtual lane number. Shows the virtual lane seen at the receiver.
264  uint16_t skew; //!< Virtual lane skew in bits. Notice the resolution is 40bits.
265 };
266 
267 /**
268  * PCS lane status
269  */
271  uint32_t bip; //!< BIP count: This counts the number of alignment markers seen which contain BIP errors.
272  uint8_t mapping; //!< Virtual lane number. Shows the virtual lane seen at the receiver.
273 };
274 
275 
276 /**
277  * Detailed link status
278  */
280  uint8_t cdrLock; //!< CDR lock
281  uint8_t blockLock; //!< Block lock
282  uint8_t amLock; //!< AM lock
283  uint8_t hiBer; //!< Hi ber
284  uint8_t localFault; //!< Local fault
285  uint8_t remoteFault; //!< Remote fault
286 
287  struct NtFecLaneStatus_s fecLaneStatus[16]; //!< FEC lane status
288  struct NtPcsLaneStatus_s pcsLaneStatus[20]; //!< PCS lane status
289 
290 };
291 
292 /**
293  * Statistics info for IPF (IP Fragment matching table)
294  */
296  uint64_t ipFragTableFirstHit; //!< Counts all IPv4/IPv6 first-fragment hits in FPGA IPF-table
297  uint64_t ipFragTableFirstNoHit; //!< Counts all IPv4/IPv6 first-fragment misses in FPGA IPF-table (first fragment not received)
298  uint64_t ipFragTableMidHit; //!< Counts all IPv4/IPv6 mid-fragment hits in FPGA IPF-table
299  uint64_t ipFragTableMidNoHit; //!< Counts all IPv4/IPv6 mid-fragment misses in FPGA IPF-table (middle fragment not received)
300  uint64_t ipFragTableLastHit; //!< Counts all IPv4/IPv6 last-fragment hits in FPGA IPF-table
301  uint64_t ipFragTableLastNoHit; //!< Counts all IPv4/IPv6 last-fragment misses in FPGA IPF-table (last fragment not received - e.g. before timeout)
302 };
303 
304 /**
305  * Statistics for each port
306  */
308  /**
309  * Valid indicators - these indicate which counters are supported by the port
310  */
312  int RMON1; //!< Is set if RMON1 counters are supported
313  int extRMON; //!< Is set if extended RMON counters are supported
314  int chksum; //!< Is set if IP/TCP/UDP checksum counters are supported
315  int decode; //!< Is set if packet decode counters are supported
316  int extDrop; //!< Is set if extended drop counters are supported
317  int ipf; //!< Is set if IP fragment table counters are supported
318  int fec; //!< Is set if FEC counters are supported
319  int linkDetails; //!< Is set if link details are supported
320  } valid;
321 
322  struct NtRMON1Counters_s RMON1; //!< RMON1 counters
323  struct NtExtendedRMONCounters_v1_s extRMON; //!< Extended RMON counters
324  struct NtCheckSumCounters_s chksum; //!< Checksum error counters
325  struct NtDecodeCounters_v1_s decode; //!< Packets decoded by onboard packet decoder
326  struct NtExtendedDropCounters_v1_s extDrop; //!< Extended drop counters
327  struct NtIpFragTableCounters_s ipf; //!< IP fragment table counters (when using IPFMode)
328  struct NtFecCounters_s fec; //!< FEC counters
329  struct NtLinkDetails_s linkDetails; //!< Link details
330 };
331 
332 /**
333  * Statistics info group for port statistics
334  */
336  struct NtPortStatistics_v3_s rx; //!< Counters based on RX ports
337  struct NtPortStatistics_v3_s tx; //!< Counters based on TX ports
338  uint64_t linkDownCounter; //!< Counts number of link downs
339  uint64_t ts; //!< Port counter sample time stamp. The format of the timestamp is specified by @ref tsType.
340  enum NtTimestampType_e tsType; //!< Time stamp type - For a description of the time stamp type see "DN-0384 3GD Time-Stamping and Time Synchronization User Guide"
341 };
342 
343 /**
344  * Statistics info group for stream statistics
345  */
347  struct {
348  struct NtColorStatistics_s forward; //!< Number of forwarded packets/bytes
349  struct NtColorStatistics_s flush; //!< Number of flushed packets/bytes. Received while the stream-id is inactive
350  struct NtColorStatistics_s drop; //!< Number of dropped packets/bytes
351  } streamid[256]; //!< Statistic for an assigned stream-id. // HB256: TODO:
352  struct {
353  struct NtColorStatistics_s forward; //!< Number of forwarded packets/bytes
354  struct NtColorStatistics_s flush; //!< Number of flushed packets/bytes. Received while the stream-id is inactive
355  struct NtColorStatistics_s drop; //!< Number of dropped packets/bytes
356  } Unassigned; //!< Statistic for traffic received in a host buffer before it has been assigned to a stream-id.
357  uint64_t ts; //!< Stream statistic sample time stamp. The format of the timestamp is specified by the timestamp setting @ref TimestampFormat in the ini-file.
358 };
359 
361  int poll; //!< Gets the current statistical information or waits for a new update
362  int clear; //!< Clears the statistical information after it has been read. All statistics counters for the current stream will be cleared. Other statistics streams will remain untouched.
363  /**
364  * Data section holding the statistic counters
365  */
367  /**
368  * Port specific statistics
369  */
371  uint8_t numPorts; //!< Number of ports in @ref aPorts
372  uint8_t Reserved1[3];
373 //
374 
375  struct NtStatGroupport_v3_s aPorts[64]; //!< Array of port statistic structures in the system
376 //
377 
378  } port;
379  /**
380  * Adapter specific statistics
381  */
383  uint8_t numAdapters; //!< Number of adapters in @ref aAdapters
384  uint8_t Reserved1[3];
385  struct NtStatGroupAdapter_s aAdapters[10]; //!< Array of adapter statistic structures
386  } adapter;
387  /**
388  * Stream specific statistics
389  */
390  struct NtStatGroupStream_s stream;
391  } data; //!< Structure for statistic results
392 };
393 
395  uint8_t streamid; //!< The streamid to get the usage data for.
396 
398  uint32_t numHostBufferUsed; //!< Number of hostbuffers used by this stream ID
400  uint64_t deQueued; //!< Bytes available or in use by the streams
401  uint64_t enQueued; //!< Bytes available to the host buffer handler
402  uint64_t enQueuedAdapter; //!< Bytes currently in the adapter
403  //!
404  uint8_t adapterNo; //!< The adapter owning the host buffer
405  uint8_t numaNode; //!< The numanode on which the hostbuffer is located
406  uint64_t hostBufferSize; //!< The host buffer size.
407  uint32_t numStreams; //!< Number of streams using the host buffers
408 
410  uint64_t used; //!< Onboard adapter buffering
411  uint64_t size; //!< Onboard adapter buffering size
412  uint32_t crcErrors; //!< The number of CRC errors detected in the onboard buffer
413  } onboardBuffering;
414 
415  struct NtStatUsage_s {
417  uint64_t bytes; //!< Bytes received
418  uint64_t frames; //!< Frames received
419  } rx;
421  uint64_t bytes; //!< Bytes dropped
422  uint64_t frames; //!< Frames dropped
423  } drop;
424  uint64_t ts; //!< Time stamp of gathered statistics
425  } stat;
426  } hb[256];
427  } data;
428 };
429 
430 /**
431  * Flow matcher statistics version 0
432  */
434  int clear; //!< Clears the statistical information after it has been read.
435  uint8_t adapterNo; //!< Adapter to receive the flow statistics from
436  uint8_t reserved[3];
437  uint64_t learnDone; //!< Total number of flows programmed
438  uint64_t learnFail; //!< Number of flows that couldn't be programmed
439  uint64_t learnIgnore;
440  uint64_t unlearnDone;
441  uint64_t unlearnIgnore;
446  uint64_t dmaWriteRecords;
451 };
452 
453 /**
454  * Flow matcher statistics version 1
455  */
457  int clear; //!< Clears the statistical information after it has been read.
458  uint8_t adapterNo; //!< Adapter to receive the flow statistics from
459  uint8_t reserved[3];
460  uint64_t learnDone; //!< Total number of flows programmed
461  uint64_t learnFail; //!< Number of flows that couldn't be programmed
462  uint64_t learnIgnore;
463  uint64_t unlearnDone;
464  uint64_t unlearnIgnore;
470  uint64_t dmaWriteRecords;
475 };
476 
477 /**
478  * Flow matcher statistics version 2
479  */
481  int clear; //!< Clears the statistical information after it has been read.
482  uint8_t adapterNo; //!< Adapter to receive the flow statistics from
483  uint8_t reserved[3];
484  uint64_t learnDone; //!< Total number of flows programmed
485  uint64_t learnFail; //!< Number of flows that couldn't be programmed
486  uint64_t learnIgnore;
487  uint64_t unlearnDone;
488  uint64_t unlearnIgnore;
493  uint64_t relearnDone;
494  uint64_t relearnIgnore;
495  uint64_t probeDone;
496  uint64_t probeIgnore;
499  uint64_t infoRecordDone;
500  uint64_t infoRecordSkip;
501  uint64_t packetHitCount;
502  uint64_t packetMissCount;
505  uint64_t cacheHitCount;
506  uint64_t cacheMissCount;
508  uint64_t cuckooStart;
509  uint64_t cuckooMove;
510  uint64_t dmaWriteRecords;
515 };
516 
517 /* Include commands for backwards compatibility */
518 #if !defined(_NT_NTAPI_NO_COMPAT)
520 #endif
521 
522 /**
523  * Statistics
524  */
525 typedef struct NtStatistics_s {
526  enum NtStatisticsCmd_e cmd; //!< Statistics command
527  /**
528  * Statistics data
529  */
531  struct NtStatisticsQuery_v4_s query_v4; //!< The structure to use for @ref NtStatistics_s::cmd==NT_STATISTICS_READ_CMD_QUERY_V4
532  struct NtStatisticsUsageData_v0_s usageData_v0; //!< The structure to use for @ref NtStatistics_s::cmd==NT_STATISTICS_READ_CMD_USAGE_DATA
533  struct NtStatisticsFlowData_v0_s flowData_v0; //!< The structure to use for @ref NtStatistics_s::cmd==NT_STATISTICS_READ_CMD_FLOW_V0
534  struct NtStatisticsFlowData_v1_s flowData_v1; //!< The structure to use for @ref NtStatistics_s::cmd==NT_STATISTICS_READ_CMD_FLOW_V1
535  struct NtStatisticsFlowData_v2_s flowData_v2; //!< The structure to use for @ref NtStatistics_s::cmd==NT_STATISTICS_READ_CMD_FLOW_V2
536 #if !defined(_NT_NTAPI_NO_COMPAT)
537  /* Commands for backwards compatibility */
538  struct NtStatisticsQuery_v3_s query_v3; //!< The structure to use for @ref NtStatistics_s::cmd==NT_STATISTICS_READ_CMD_QUERY_V3
539  struct NtStatisticsQuery_v2_s query_v2; //!< The structure to use for @ref NtStatistics_s::cmd==NT_STATISTICS_READ_CMD_QUERY_V2
540  struct NtStatisticsQuery_v1_s query_v1; //!< The structure to use for @ref NtStatistics_s::cmd==NT_STATISTICS_READ_CMD_QUERY_V1
541  struct NtStatisticsQuery_s query; //!< The structure to use for @ref NtStatistics_s::cmd==NT_STATISTICS_READ_CMD_QUERY
542 #endif
543  }u; //!< Union for statistic structures
545 
546 /**
547  * Statistics stream handle
548  */
549 typedef struct NtStatStream_s* NtStatStream_t;
550 
551 /**
552  * @brief Opens a statistics stream
553  *
554  * This function is called to retrieve a handle to a statistics stream
555  *
556  * @param[out] hStatStream Reference to a NtStatStream_t stream pointer
557  * @param[in] name Stream friendly name - used in, for example, logging statements
558  *
559  * @retval 0 Success
560  * @retval !=0 Error
561  */
562 int NT_StatOpen(NtStatStream_t *hStatStream, const char *name);
563 
564 /**
565  * @brief Reads statistics
566  *
567  * Returns statistical information from the system
568  *
569  * @param[in] hStatStream NtStatStream_t handle
570  * @param[in] stat Return buffer for statistics
571  *
572  * @retval 0 Success
573  * @retval NT_STATUS_TIMEOUT No data has been returned and a timeout has occured
574  * @retval NT_STATUS_TRYAGAIN The resource is temporarily unavailable because of reconfiguration - call NT_StatRead() again
575  * @retval !=0 Error
576  */
577 int NT_StatRead(NtStatStream_t hStatStream, NtStatistics_t *stat);
578 
579 /**
580  * @brief Closes a statistics stream
581  *
582  * This function is called to close a statistics stream
583  *
584  * @param[in] hStatStream Reference to a NtStatStream_t stream pointer
585  *
586  * @retval 0 Success
587  * @retval !=0 Error
588  */
589 int NT_StatClose(NtStatStream_t hStatStream);
590 
591 /** @} */
592 
593 #endif // __STREAM_STATISTICS_H__