Zephyr API Documentation  3.6.0
A Scalable Open Source RTOS
3.6.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
net_stats.h
Go to the documentation of this file.
1
8/*
9 * Copyright (c) 2016 Intel Corporation
10 *
11 * SPDX-License-Identifier: Apache-2.0
12 */
13
14#ifndef ZEPHYR_INCLUDE_NET_NET_STATS_H_
15#define ZEPHYR_INCLUDE_NET_NET_STATS_H_
16
17#include <zephyr/types.h>
18#include <zephyr/net/net_core.h>
19#include <zephyr/net/net_mgmt.h>
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
37
46};
47
56};
57
64
67
70
73};
74
83
86
89
92
95
100};
101
108
111
114
117
120};
121
128
131
134
137
140
143
146
149
152
155
158
163
166};
167
174
177
180
183};
184
192};
193
200
203
206};
207
214
217
220};
221
228};
229
236};
237
238#if NET_TC_TX_COUNT == 0
239#define NET_TC_TX_STATS_COUNT 1
240#else
241#define NET_TC_TX_STATS_COUNT NET_TC_TX_COUNT
242#endif
243
244#if NET_TC_RX_COUNT == 0
245#define NET_TC_RX_STATS_COUNT 1
246#else
247#define NET_TC_RX_STATS_COUNT NET_TC_RX_COUNT
248#endif
249
254 struct {
256#if defined(CONFIG_NET_PKT_TXTIME_STATS_DETAIL)
257 struct net_stats_tx_time
258 tx_time_detail[NET_PKT_DETAIL_STATS_COUNT];
259#endif
264
265 struct {
266 struct net_stats_rx_time rx_time;
267#if defined(CONFIG_NET_PKT_RXTIME_STATS_DETAIL)
268 struct net_stats_rx_time
269 rx_time_detail[NET_PKT_DETAIL_STATS_COUNT];
270#endif
271 net_stats_t pkts;
272 net_stats_t bytes;
273 uint8_t priority;
275};
276
277
286};
287
288
292struct net_stats {
295
301
304
305#if defined(CONFIG_NET_STATISTICS_IPV6)
307 struct net_stats_ip ipv6;
308#endif
309
310#if defined(CONFIG_NET_STATISTICS_IPV4)
312 struct net_stats_ip ipv4;
313#endif
314
315#if defined(CONFIG_NET_STATISTICS_ICMP)
317 struct net_stats_icmp icmp;
318#endif
319
320#if defined(CONFIG_NET_STATISTICS_TCP)
322 struct net_stats_tcp tcp;
323#endif
324
325#if defined(CONFIG_NET_STATISTICS_UDP)
327 struct net_stats_udp udp;
328#endif
329
330#if defined(CONFIG_NET_STATISTICS_IPV6_ND)
332 struct net_stats_ipv6_nd ipv6_nd;
333#endif
334
335#if defined(CONFIG_NET_STATISTICS_MLD)
337 struct net_stats_ipv6_mld ipv6_mld;
338#endif
339
340#if defined(CONFIG_NET_STATISTICS_IGMP)
342 struct net_stats_ipv4_igmp ipv4_igmp;
343#endif
344
345#if NET_TC_COUNT > 1
347 struct net_stats_tc tc;
348#endif
349
350#if defined(CONFIG_NET_PKT_TXTIME_STATS)
352 struct net_stats_tx_time tx_time;
353#endif
354
355#if defined(CONFIG_NET_PKT_RXTIME_STATS)
357 struct net_stats_rx_time rx_time;
358#endif
359
360#if defined(CONFIG_NET_PKT_TXTIME_STATS_DETAIL)
362 struct net_stats_tx_time tx_time_detail[NET_PKT_DETAIL_STATS_COUNT];
363#endif
364#if defined(CONFIG_NET_PKT_RXTIME_STATS_DETAIL)
366 struct net_stats_rx_time rx_time_detail[NET_PKT_DETAIL_STATS_COUNT];
367#endif
368
369#if defined(CONFIG_NET_STATISTICS_POWER_MANAGEMENT)
370 struct net_stats_pm pm;
371#endif
372};
373
389
396
399};
400
409};
410
417};
418
426};
427
428#ifdef CONFIG_NET_STATISTICS_ETHERNET_VENDOR
432struct net_stats_eth_vendor {
433 const char * const key;
434 uint32_t value;
435};
436#endif
437
456#ifdef CONFIG_NET_STATISTICS_ETHERNET_VENDOR
458 struct net_stats_eth_vendor *vendor;
459#endif
460};
461
468
471
474};
475
482
485};
486
497};
498
499#if defined(CONFIG_NET_STATISTICS_USER_API)
500/* Management part definitions */
501
502#define _NET_STATS_LAYER NET_MGMT_LAYER_L3
503#define _NET_STATS_CODE 0x101
504#define _NET_STATS_BASE (NET_MGMT_LAYER(_NET_STATS_LAYER) | \
505 NET_MGMT_LAYER_CODE(_NET_STATS_CODE))
506
507enum net_request_stats_cmd {
508 NET_REQUEST_STATS_CMD_GET_ALL = 1,
509 NET_REQUEST_STATS_CMD_GET_PROCESSING_ERROR,
510 NET_REQUEST_STATS_CMD_GET_BYTES,
511 NET_REQUEST_STATS_CMD_GET_IP_ERRORS,
512 NET_REQUEST_STATS_CMD_GET_IPV4,
513 NET_REQUEST_STATS_CMD_GET_IPV6,
514 NET_REQUEST_STATS_CMD_GET_IPV6_ND,
515 NET_REQUEST_STATS_CMD_GET_ICMP,
516 NET_REQUEST_STATS_CMD_GET_UDP,
517 NET_REQUEST_STATS_CMD_GET_TCP,
518 NET_REQUEST_STATS_CMD_GET_ETHERNET,
519 NET_REQUEST_STATS_CMD_GET_PPP,
520 NET_REQUEST_STATS_CMD_GET_PM,
521 NET_REQUEST_STATS_CMD_GET_WIFI,
522};
523
524#define NET_REQUEST_STATS_GET_ALL \
525 (_NET_STATS_BASE | NET_REQUEST_STATS_CMD_GET_ALL)
526
527NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_STATS_GET_ALL);
528
529#define NET_REQUEST_STATS_GET_PROCESSING_ERROR \
530 (_NET_STATS_BASE | NET_REQUEST_STATS_CMD_GET_PROCESSING_ERROR)
531
532NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_STATS_GET_PROCESSING_ERROR);
533
534#define NET_REQUEST_STATS_GET_BYTES \
535 (_NET_STATS_BASE | NET_REQUEST_STATS_CMD_GET_BYTES)
536
537NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_STATS_GET_BYTES);
538
539#define NET_REQUEST_STATS_GET_IP_ERRORS \
540 (_NET_STATS_BASE | NET_REQUEST_STATS_CMD_GET_IP_ERRORS)
541
542NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_STATS_GET_IP_ERRORS);
543
544#if defined(CONFIG_NET_STATISTICS_IPV4)
545#define NET_REQUEST_STATS_GET_IPV4 \
546 (_NET_STATS_BASE | NET_REQUEST_STATS_CMD_GET_IPV4)
547
548NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_STATS_GET_IPV4);
549#endif /* CONFIG_NET_STATISTICS_IPV4 */
550
551#if defined(CONFIG_NET_STATISTICS_IPV6)
552#define NET_REQUEST_STATS_GET_IPV6 \
553 (_NET_STATS_BASE | NET_REQUEST_STATS_CMD_GET_IPV6)
554
555NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_STATS_GET_IPV6);
556#endif /* CONFIG_NET_STATISTICS_IPV6 */
557
558#if defined(CONFIG_NET_STATISTICS_IPV6_ND)
559#define NET_REQUEST_STATS_GET_IPV6_ND \
560 (_NET_STATS_BASE | NET_REQUEST_STATS_CMD_GET_IPV6_ND)
561
562NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_STATS_GET_IPV6_ND);
563#endif /* CONFIG_NET_STATISTICS_IPV6_ND */
564
565#if defined(CONFIG_NET_STATISTICS_ICMP)
566#define NET_REQUEST_STATS_GET_ICMP \
567 (_NET_STATS_BASE | NET_REQUEST_STATS_CMD_GET_ICMP)
568
569NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_STATS_GET_ICMP);
570#endif /* CONFIG_NET_STATISTICS_ICMP */
571
572#if defined(CONFIG_NET_STATISTICS_UDP)
573#define NET_REQUEST_STATS_GET_UDP \
574 (_NET_STATS_BASE | NET_REQUEST_STATS_CMD_GET_UDP)
575
576NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_STATS_GET_UDP);
577#endif /* CONFIG_NET_STATISTICS_UDP */
578
579#if defined(CONFIG_NET_STATISTICS_TCP)
580#define NET_REQUEST_STATS_GET_TCP \
581 (_NET_STATS_BASE | NET_REQUEST_STATS_CMD_GET_TCP)
582
583NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_STATS_GET_TCP);
584#endif /* CONFIG_NET_STATISTICS_TCP */
585
586#if defined(CONFIG_NET_STATISTICS_ETHERNET)
587#define NET_REQUEST_STATS_GET_ETHERNET \
588 (_NET_STATS_BASE | NET_REQUEST_STATS_CMD_GET_ETHERNET)
589
590NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_STATS_GET_ETHERNET);
591#endif /* CONFIG_NET_STATISTICS_ETHERNET */
592
593#if defined(CONFIG_NET_STATISTICS_PPP)
594#define NET_REQUEST_STATS_GET_PPP \
595 (_NET_STATS_BASE | NET_REQUEST_STATS_CMD_GET_PPP)
596
597NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_STATS_GET_PPP);
598#endif /* CONFIG_NET_STATISTICS_PPP */
599
600#endif /* CONFIG_NET_STATISTICS_USER_API */
601
602#if defined(CONFIG_NET_STATISTICS_POWER_MANAGEMENT)
603#define NET_REQUEST_STATS_GET_PM \
604 (_NET_STATS_BASE | NET_REQUEST_STATS_CMD_GET_PM)
605
606NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_STATS_GET_PM);
607#endif /* CONFIG_NET_STATISTICS_POWER_MANAGEMENT */
608
609#if defined(CONFIG_NET_STATISTICS_WIFI)
610#define NET_REQUEST_STATS_GET_WIFI \
611 (_NET_STATS_BASE | NET_REQUEST_STATS_CMD_GET_WIFI)
612
613NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_STATS_GET_WIFI);
614#endif /* CONFIG_NET_STATISTICS_WIFI */
615
620#ifdef __cplusplus
621}
622#endif
623
624#endif /* ZEPHYR_INCLUDE_NET_NET_STATS_H_ */
#define NET_MGMT_DEFINE_REQUEST_HANDLER(_mgmt_request)
Definition: net_mgmt.h:96
#define NET_TC_RX_STATS_COUNT
Definition: net_stats.h:245
uint32_t net_stats_t
Network statistics counter.
Definition: net_stats.h:36
#define NET_TC_TX_STATS_COUNT
Definition: net_stats.h:239
Network core definitions.
Network Management API public header.
__UINT32_TYPE__ uint32_t
Definition: stdint.h:90
__UINT64_TYPE__ uint64_t
Definition: stdint.h:91
__UINT8_TYPE__ uint8_t
Definition: stdint.h:88
Number of bytes sent and received.
Definition: net_stats.h:41
net_stats_t sent
Number of bytes sent.
Definition: net_stats.h:43
net_stats_t received
Number of bytes received.
Definition: net_stats.h:45
Ethernet checksum statistics.
Definition: net_stats.h:414
net_stats_t rx_csum_offload_good
Definition: net_stats.h:415
net_stats_t rx_csum_offload_errors
Definition: net_stats.h:416
Ethernet error statistics.
Definition: net_stats.h:377
net_stats_t tx_carrier_errors
Definition: net_stats.h:391
net_stats_t uncorr_ecc_errors
Definition: net_stats.h:397
net_stats_t rx_long_length_errors
Definition: net_stats.h:384
net_stats_t tx_window_errors
Definition: net_stats.h:394
net_stats_t corr_ecc_errors
Definition: net_stats.h:398
net_stats_t rx_missed_errors
Definition: net_stats.h:383
net_stats_t rx_crc_errors
Definition: net_stats.h:380
net_stats_t rx_short_length_errors
Definition: net_stats.h:385
net_stats_t rx_align_errors
Definition: net_stats.h:386
net_stats_t rx_dma_failed
Definition: net_stats.h:387
net_stats_t rx_no_buffer_count
Definition: net_stats.h:382
net_stats_t tx_fifo_errors
Definition: net_stats.h:392
net_stats_t rx_frame_errors
Definition: net_stats.h:381
net_stats_t rx_over_errors
Definition: net_stats.h:379
net_stats_t tx_dma_failed
Definition: net_stats.h:395
net_stats_t rx_length_errors
Definition: net_stats.h:378
net_stats_t rx_buf_alloc_failed
Definition: net_stats.h:388
net_stats_t tx_heartbeat_errors
Definition: net_stats.h:393
net_stats_t tx_aborted_errors
Definition: net_stats.h:390
Ethernet flow control statistics.
Definition: net_stats.h:404
net_stats_t rx_flow_control_xon
Definition: net_stats.h:405
net_stats_t tx_flow_control_xon
Definition: net_stats.h:407
net_stats_t rx_flow_control_xoff
Definition: net_stats.h:406
net_stats_t tx_flow_control_xoff
Definition: net_stats.h:408
Ethernet hardware timestamp statistics.
Definition: net_stats.h:422
net_stats_t tx_hwtstamp_timeouts
Definition: net_stats.h:424
net_stats_t rx_hwtstamp_cleared
Definition: net_stats.h:423
net_stats_t tx_hwtstamp_skipped
Definition: net_stats.h:425
All Ethernet specific statistics.
Definition: net_stats.h:441
struct net_stats_pkts broadcast
Definition: net_stats.h:444
struct net_stats_eth_csum csum
Definition: net_stats.h:449
net_stats_t tx_dropped
Definition: net_stats.h:452
struct net_stats_eth_hw_timestamp hw_timestamp
Definition: net_stats.h:450
struct net_stats_pkts multicast
Definition: net_stats.h:445
struct net_stats_eth_flow flow_control
Definition: net_stats.h:448
net_stats_t tx_restart_queue
Definition: net_stats.h:454
net_stats_t collisions
Definition: net_stats.h:451
struct net_stats_bytes bytes
Definition: net_stats.h:442
struct net_stats_eth_errors error_details
Definition: net_stats.h:447
struct net_stats_pkts pkts
Definition: net_stats.h:443
struct net_stats_pkts errors
Definition: net_stats.h:446
net_stats_t tx_timeout_count
Definition: net_stats.h:453
net_stats_t unknown_protocol
Definition: net_stats.h:455
ICMP statistics.
Definition: net_stats.h:105
net_stats_t sent
Number of sent ICMP packets.
Definition: net_stats.h:110
net_stats_t chkerr
Number of ICMP packets with a bad checksum.
Definition: net_stats.h:119
net_stats_t drop
Number of dropped ICMP packets.
Definition: net_stats.h:113
net_stats_t typeerr
Number of ICMP packets with a wrong type.
Definition: net_stats.h:116
net_stats_t recv
Number of received ICMP packets.
Definition: net_stats.h:107
IP layer error statistics.
Definition: net_stats.h:78
net_stats_t hblenerr
Number of packets dropped due to wrong IP length, high byte.
Definition: net_stats.h:85
net_stats_t vhlerr
Number of packets dropped due to wrong IP version or header length.
Definition: net_stats.h:82
net_stats_t chkerr
Number of packets dropped due to IP checksum errors.
Definition: net_stats.h:94
net_stats_t protoerr
Number of packets dropped because they were neither ICMP, UDP nor TCP.
Definition: net_stats.h:99
net_stats_t lblenerr
Number of packets dropped due to wrong IP length, low byte.
Definition: net_stats.h:88
net_stats_t fragerr
Number of packets dropped because they were IP fragments.
Definition: net_stats.h:91
IP layer statistics.
Definition: net_stats.h:61
net_stats_t forwarded
Number of forwarded packets at the IP layer.
Definition: net_stats.h:69
net_stats_t recv
Number of received packets at the IP layer.
Definition: net_stats.h:63
net_stats_t sent
Number of sent packets at the IP layer.
Definition: net_stats.h:66
net_stats_t drop
Number of dropped packets at the IP layer.
Definition: net_stats.h:72
IPv4 IGMP daemon statistics.
Definition: net_stats.h:211
net_stats_t drop
Number of dropped IPv4 IGMP packets.
Definition: net_stats.h:219
net_stats_t recv
Number of received IPv4 IGMP queries.
Definition: net_stats.h:213
net_stats_t sent
Number of sent IPv4 IGMP reports.
Definition: net_stats.h:216
IPv6 multicast listener daemon statistics.
Definition: net_stats.h:197
net_stats_t recv
Number of received IPv6 MLD queries.
Definition: net_stats.h:199
net_stats_t sent
Number of sent IPv6 MLD reports.
Definition: net_stats.h:202
net_stats_t drop
Number of dropped IPv6 MLD packets.
Definition: net_stats.h:205
IPv6 neighbor discovery statistics.
Definition: net_stats.h:188
net_stats_t sent
Definition: net_stats.h:191
net_stats_t recv
Definition: net_stats.h:190
net_stats_t drop
Definition: net_stats.h:189
Number of network packets sent and received.
Definition: net_stats.h:51
net_stats_t rx
Number of packets received.
Definition: net_stats.h:55
net_stats_t tx
Number of packets sent.
Definition: net_stats.h:53
Power management statistics.
Definition: net_stats.h:281
uint32_t last_suspend_time
Definition: net_stats.h:284
uint32_t start_time
Definition: net_stats.h:285
uint64_t overall_suspend_time
Definition: net_stats.h:282
net_stats_t suspend_count
Definition: net_stats.h:283
All PPP specific statistics.
Definition: net_stats.h:465
net_stats_t chkerr
Number of received PPP frames with a bad checksum.
Definition: net_stats.h:473
struct net_stats_pkts pkts
Definition: net_stats.h:467
struct net_stats_bytes bytes
Definition: net_stats.h:466
net_stats_t drop
Number of received and dropped PPP frames.
Definition: net_stats.h:470
Network packet receive times for calculating average RX time.
Definition: net_stats.h:233
uint64_t sum
Definition: net_stats.h:234
net_stats_t count
Definition: net_stats.h:235
All Wi-Fi management statistics.
Definition: net_stats.h:479
net_stats_t beacons_miss
Number of missed beacons.
Definition: net_stats.h:484
net_stats_t beacons_rx
Number of received beacons.
Definition: net_stats.h:481
Traffic class statistics.
Definition: net_stats.h:253
net_stats_t bytes
Definition: net_stats.h:261
struct net_stats_tx_time tx_time
Definition: net_stats.h:255
struct net_stats_tc::@335 sent[1]
struct net_stats_tc::@336 recv[1]
net_stats_t pkts
Definition: net_stats.h:260
uint8_t priority
Definition: net_stats.h:262
TCP statistics.
Definition: net_stats.h:125
net_stats_t ackerr
Number of received TCP segments with a bad ACK number.
Definition: net_stats.h:148
net_stats_t rsterr
Number of received bad TCP RST (reset) segments.
Definition: net_stats.h:151
net_stats_t rexmit
Number of retransmitted TCP segments.
Definition: net_stats.h:157
net_stats_t chkerr
Number of TCP segments with a bad checksum.
Definition: net_stats.h:145
net_stats_t seg_drop
Number of dropped TCP segments.
Definition: net_stats.h:142
net_stats_t connrst
Number of connection attempts for closed ports, triggering a RST.
Definition: net_stats.h:165
net_stats_t drop
Number of dropped packets at the TCP layer.
Definition: net_stats.h:133
net_stats_t rst
Number of received TCP RST (reset) segments.
Definition: net_stats.h:154
net_stats_t sent
Number of sent TCP segments.
Definition: net_stats.h:139
net_stats_t resent
Amount of retransmitted data.
Definition: net_stats.h:130
net_stats_t conndrop
Number of dropped connection attempts because too few connections were available.
Definition: net_stats.h:162
net_stats_t recv
Number of received TCP segments.
Definition: net_stats.h:136
struct net_stats_bytes bytes
Amount of received and sent TCP application data.
Definition: net_stats.h:127
Network packet transfer times for calculating average TX time.
Definition: net_stats.h:225
net_stats_t count
Definition: net_stats.h:227
uint64_t sum
Definition: net_stats.h:226
UDP statistics.
Definition: net_stats.h:171
net_stats_t recv
Number of received UDP segments.
Definition: net_stats.h:176
net_stats_t drop
Number of dropped UDP segments.
Definition: net_stats.h:173
net_stats_t chkerr
Number of UDP segments with a bad checksum.
Definition: net_stats.h:182
net_stats_t sent
Number of sent UDP segments.
Definition: net_stats.h:179
All Wi-Fi specific statistics.
Definition: net_stats.h:490
struct net_stats_pkts broadcast
Definition: net_stats.h:494
struct net_stats_pkts multicast
Definition: net_stats.h:495
struct net_stats_sta_mgmt sta_mgmt
Definition: net_stats.h:491
struct net_stats_bytes bytes
Definition: net_stats.h:492
struct net_stats_pkts pkts
Definition: net_stats.h:493
struct net_stats_pkts errors
Definition: net_stats.h:496
All network statistics in one struct.
Definition: net_stats.h:292
net_stats_t processing_error
Count of malformed packets or packets we do not have handler for.
Definition: net_stats.h:294
struct net_stats_bytes bytes
This calculates amount of data transferred through all the network interfaces.
Definition: net_stats.h:300
struct net_stats_ip_errors ip_errors
IP layer errors.
Definition: net_stats.h:303