| 1 | /* SPDX-License-Identifier: BSD-2-Clause */cxx . . $ `<file>/src/stat.h`/ |
| 2 | /* |
| 3 | * Copyright (C) 2021-2025 Linutronix GmbH |
| 4 | * Author Kurt Kanzenbach <[email protected]> |
| 5 | */ |
| 6 | |
| 7 | #ifndef _STAT_H_ |
| 8 | #define _STAT_H_cxx . . $ `src/stat.h:8:9`! |
| 9 | |
| 10 | #include <signal.h> |
| 11 | #include <stdbool.h> |
| 12 | #include <stddef.h> |
| 13 | #include <stdint.h> |
| 14 | |
| 15 | enum log_stat_optionscxx . . $ log_stat_options# { |
| 16 | LOG_REFERENCEcxx . . $ LOG_REFERENCE. = 0, |
| 17 | LOG_MIRRORcxx . . $ LOG_MIRROR., |
| 18 | /* Mirror mode with TX timestamping enabled */ |
| 19 | LOG_TX_TIMESTAMPScxx . . $ LOG_TX_TIMESTAMPS., |
| 20 | LOG_NUM_OPTIONScxx . . $ LOG_NUM_OPTIONS. |
| 21 | }; |
| 22 | |
| 23 | enum stat_frame_typecxx . . $ stat_frame_type# { |
| 24 | TSN_HIGH_FRAME_TYPEcxx . . $ TSN_HIGH_FRAME_TYPE. = 0, |
| 25 | TSN_LOW_FRAME_TYPEcxx . . $ TSN_LOW_FRAME_TYPE., |
| 26 | RTC_FRAME_TYPEcxx . . $ RTC_FRAME_TYPE., |
| 27 | RTA_FRAME_TYPEcxx . . $ RTA_FRAME_TYPE., |
| 28 | DCP_FRAME_TYPEcxx . . $ DCP_FRAME_TYPE., |
| 29 | LLDP_FRAME_TYPEcxx . . $ LLDP_FRAME_TYPE., |
| 30 | UDP_HIGH_FRAME_TYPEcxx . . $ UDP_HIGH_FRAME_TYPE., |
| 31 | UDP_LOW_FRAME_TYPEcxx . . $ UDP_LOW_FRAME_TYPE., |
| 32 | GENERICL2_FRAME_TYPEcxx . . $ GENERICL2_FRAME_TYPE., |
| 33 | NUM_FRAME_TYPEScxx . . $ NUM_FRAME_TYPES., |
| 34 | }; |
| 35 | |
| 36 | static inline boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! stat_frame_type_is_real_timecxx . . $ stat_frame_type_is_real_time(e6c3649086ff187f).(enum stat_frame_typecxx . . $ stat_frame_type# frame_type) |
| 37 | { |
| 38 | switch (frame_type) { |
| 39 | case TSN_HIGH_FRAME_TYPEcxx . . $ TSN_HIGH_FRAME_TYPE.: |
| 40 | case TSN_LOW_FRAME_TYPEcxx . . $ TSN_LOW_FRAME_TYPE.: |
| 41 | case RTC_FRAME_TYPEcxx . . $ RTC_FRAME_TYPE.: |
| 42 | case GENERICL2_FRAME_TYPEcxx . . $ GENERICL2_FRAME_TYPE.: |
| 43 | return truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 44 | default: |
| 45 | return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | extern const char *stat_frame_type_namescxx . . $ stat_frame_type_names.[NUM_FRAME_TYPEScxx . . $ NUM_FRAME_TYPES.]; |
| 50 | |
| 51 | static inline const char *stat_frame_type_to_stringcxx . . $ stat_frame_type_to_string(413bfe925ee921da).(enum stat_frame_typecxx . . $ stat_frame_type# frame_type) |
| 52 | { |
| 53 | return stat_frame_type_namescxx . . $ stat_frame_type_names.[frame_type]; |
| 54 | } |
| 55 | |
| 56 | struct statisticscxx . . $ statistics# { |
| 57 | uint64_tcxx . . $ uint64_t# time_stampcxx . . $ statistics#time_stamp.; |
| 58 | uint64_tcxx . . $ uint64_t# frames_sentcxx . . $ statistics#frames_sent.; |
| 59 | uint64_tcxx . . $ uint64_t# frames_receivedcxx . . $ statistics#frames_received.; |
| 60 | uint64_tcxx . . $ uint64_t# out_of_order_errorscxx . . $ statistics#out_of_order_errors.; |
| 61 | uint64_tcxx . . $ uint64_t# frame_id_errorscxx . . $ statistics#frame_id_errors.; |
| 62 | uint64_tcxx . . $ uint64_t# payload_errorscxx . . $ statistics#payload_errors.; |
| 63 | uint64_tcxx . . $ uint64_t# round_trip_mincxx . . $ statistics#round_trip_min.; |
| 64 | uint64_tcxx . . $ uint64_t# round_trip_maxcxx . . $ statistics#round_trip_max.; |
| 65 | uint64_tcxx . . $ uint64_t# round_trip_countcxx . . $ statistics#round_trip_count.; |
| 66 | uint64_tcxx . . $ uint64_t# round_trip_outlierscxx . . $ statistics#round_trip_outliers.; |
| 67 | double round_trip_sumcxx . . $ statistics#round_trip_sum.; |
| 68 | double round_trip_avgcxx . . $ statistics#round_trip_avg.; |
| 69 | uint64_tcxx . . $ uint64_t# oneway_mincxx . . $ statistics#oneway_min.; |
| 70 | uint64_tcxx . . $ uint64_t# oneway_maxcxx . . $ statistics#oneway_max.; |
| 71 | uint64_tcxx . . $ uint64_t# oneway_countcxx . . $ statistics#oneway_count.; |
| 72 | uint64_tcxx . . $ uint64_t# oneway_outlierscxx . . $ statistics#oneway_outliers.; |
| 73 | double oneway_sumcxx . . $ statistics#oneway_sum.; |
| 74 | double oneway_avgcxx . . $ statistics#oneway_avg.; |
| 75 | /* First-frame processing latency at Mirror (1st Rx HW to 1st Tx HW timestamp) */ |
| 76 | uint64_tcxx . . $ uint64_t# proc_first_mincxx . . $ statistics#proc_first_min.; |
| 77 | uint64_tcxx . . $ uint64_t# proc_first_maxcxx . . $ statistics#proc_first_max.; |
| 78 | uint64_tcxx . . $ uint64_t# proc_first_countcxx . . $ statistics#proc_first_count.; |
| 79 | double proc_first_sumcxx . . $ statistics#proc_first_sum.; |
| 80 | double proc_first_avgcxx . . $ statistics#proc_first_avg.; |
| 81 | /* Batch processing latency at Mirror (1st Rx HW to Last Tx HW timestamp) */ |
| 82 | uint64_tcxx . . $ uint64_t# proc_batch_mincxx . . $ statistics#proc_batch_min.; |
| 83 | uint64_tcxx . . $ uint64_t# proc_batch_maxcxx . . $ statistics#proc_batch_max.; |
| 84 | uint64_tcxx . . $ uint64_t# proc_batch_countcxx . . $ statistics#proc_batch_count.; |
| 85 | double proc_batch_sumcxx . . $ statistics#proc_batch_sum.; |
| 86 | double proc_batch_avgcxx . . $ statistics#proc_batch_avg.; |
| 87 | /* Rx latency from NIC Rx Hw timestamp to user space timestamp */ |
| 88 | uint64_tcxx . . $ uint64_t# rx_mincxx . . $ statistics#rx_min.; |
| 89 | uint64_tcxx . . $ uint64_t# rx_maxcxx . . $ statistics#rx_max.; |
| 90 | double rx_sumcxx . . $ statistics#rx_sum.; |
| 91 | double rx_avgcxx . . $ statistics#rx_avg.; |
| 92 | /* Rx latency from NIC Rx Hw timestamp to Xdp prog timestamp */ |
| 93 | uint64_tcxx . . $ uint64_t# rx_hw2xdp_mincxx . . $ statistics#rx_hw2xdp_min.; |
| 94 | uint64_tcxx . . $ uint64_t# rx_hw2xdp_maxcxx . . $ statistics#rx_hw2xdp_max.; |
| 95 | double rx_hw2xdp_sumcxx . . $ statistics#rx_hw2xdp_sum.; |
| 96 | double rx_hw2xdp_avgcxx . . $ statistics#rx_hw2xdp_avg.; |
| 97 | /* Rx latency from Xdp prog timestamp to user space timestamp */ |
| 98 | uint64_tcxx . . $ uint64_t# rx_xdp2app_mincxx . . $ statistics#rx_xdp2app_min.; |
| 99 | uint64_tcxx . . $ uint64_t# rx_xdp2app_maxcxx . . $ statistics#rx_xdp2app_max.; |
| 100 | double rx_xdp2app_sumcxx . . $ statistics#rx_xdp2app_sum.; |
| 101 | double rx_xdp2app_avgcxx . . $ statistics#rx_xdp2app_avg.; |
| 102 | /* Workload statistics */ |
| 103 | uint64_tcxx . . $ uint64_t# rx_workload_mincxx . . $ statistics#rx_workload_min.; |
| 104 | uint64_tcxx . . $ uint64_t# rx_workload_maxcxx . . $ statistics#rx_workload_max.; |
| 105 | uint64_tcxx . . $ uint64_t# rx_workload_countcxx . . $ statistics#rx_workload_count.; |
| 106 | double rx_workload_sumcxx . . $ statistics#rx_workload_sum.; |
| 107 | double rx_workload_avgcxx . . $ statistics#rx_workload_avg.; |
| 108 | uint64_tcxx . . $ uint64_t# rx_workload_outlierscxx . . $ statistics#rx_workload_outliers.; |
| 109 | /* Tx latency from user space (at send) to NIC Tx HW timestamp */ |
| 110 | uint64_tcxx . . $ uint64_t# tx_mincxx . . $ statistics#tx_min.; |
| 111 | uint64_tcxx . . $ uint64_t# tx_maxcxx . . $ statistics#tx_max.; |
| 112 | uint64_tcxx . . $ uint64_t# tx_countcxx . . $ statistics#tx_count.; |
| 113 | uint64_tcxx . . $ uint64_t# tx_hw_timestamp_missingcxx . . $ statistics#tx_hw_timestamp_missing.; |
| 114 | double tx_sumcxx . . $ statistics#tx_sum.; |
| 115 | double tx_avgcxx . . $ statistics#tx_avg.; |
| 116 | }; |
| 117 | |
| 118 | struct rtt_entrycxx . . $ rtt_entry# { |
| 119 | uint64_tcxx . . $ uint64_t# sw_tscxx . . $ rtt_entry#sw_ts.; |
| 120 | uint64_tcxx . . $ uint64_t# hw_tscxx . . $ rtt_entry#hw_ts.; |
| 121 | uint64_tcxx . . $ uint64_t# rx_hw_tscxx . . $ rtt_entry#rx_hw_ts.; |
| 122 | }; |
| 123 | |
| 124 | struct round_trip_contextcxx . . $ round_trip_context# { |
| 125 | struct rtt_entrycxx . . $ rtt_entry# *backlogcxx . . $ round_trip_context#backlog.; |
| 126 | size_tcxx . . $ size_t# backlog_lencxx . . $ round_trip_context#backlog_len.; |
| 127 | }; |
| 128 | |
| 129 | int stat_initcxx . . $ stat_init(227e9c8ece8b273d).(enum log_stat_optionscxx . . $ log_stat_options# log_selection); |
| 130 | void stat_freecxx . . $ stat_free(49f6e7a06ebc5aa8).(void); |
| 131 | const char *stat_frame_type_to_stringcxx . . $ stat_frame_type_to_string(413bfe925ee921da).(enum stat_frame_typecxx . . $ stat_frame_type# frame_type); |
| 132 | void stat_frame_sentcxx . . $ stat_frame_sent(ca48c151307d73b6).(enum stat_frame_typecxx . . $ stat_frame_type# frame_type, uint64_tcxx . . $ uint64_t# cycle_number); |
| 133 | void stat_frames_sent_batchcxx . . $ stat_frames_sent_batch(1b9110cae93061b5).(enum stat_frame_typecxx . . $ stat_frame_type# frame_type, uint64_tcxx . . $ uint64_t# cycle_number, |
| 134 | uint64_tcxx . . $ uint64_t# frame_count); |
| 135 | void stat_frame_receivedcxx . . $ stat_frame_received(5534a29e0120fff).(enum stat_frame_typecxx . . $ stat_frame_type# frame_type, uint64_tcxx . . $ uint64_t# cycle_number, boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! out_of_order, |
| 136 | boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! payload_mismatch, boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! frame_id_mismatch, uint64_tcxx . . $ uint64_t# tx_timestamp, |
| 137 | uint64_tcxx . . $ uint64_t# rx_hw_timestamp, uint64_tcxx . . $ uint64_t# rx_sw_timestamp); |
| 138 | void stat_updatecxx . . $ stat_update(49f6e7a06ebc5aa8).(void); |
| 139 | void stat_get_global_statscxx . . $ stat_get_global_stats(36543745c1651445).(struct statisticscxx . . $ statistics# *stats, size_tcxx . . $ size_t# len); |
| 140 | void stat_get_stats_per_periodcxx . . $ stat_get_stats_per_period(36543745c1651445).(struct statisticscxx . . $ statistics# *stats, size_tcxx . . $ size_t# len); |
| 141 | void stat_frame_workloadcxx . . $ stat_frame_workload(de8748302dcb85c).(enum stat_frame_typecxx . . $ stat_frame_type#, uint64_tcxx . . $ uint64_t# cycle_number, struct timespeccxx . . $ timespec# start_ts); |
| 142 | void stat_inc_workload_outliercxx . . $ stat_inc_workload_outlier(163d8b1aefebb495).(enum stat_frame_typecxx . . $ stat_frame_type# frame_type); |
| 143 | void stat_frame_sent_latencycxx . . $ stat_frame_sent_latency(ca48c151307d73b6).(enum stat_frame_typecxx . . $ stat_frame_type# frame_type, uint64_tcxx . . $ uint64_t# seq); |
| 144 | void stat_proc_first_latencycxx . . $ stat_proc_first_latency(1b9110cae93061b5).(enum stat_frame_typecxx . . $ stat_frame_type# frame_type, uint64_tcxx . . $ uint64_t# cycle_number, |
| 145 | uint64_tcxx . . $ uint64_t# tx_hw_timestamp); |
| 146 | void stat_proc_batch_latencycxx . . $ stat_proc_batch_latency(1b9110cae93061b5).(enum stat_frame_typecxx . . $ stat_frame_type# frame_type, uint64_tcxx . . $ uint64_t# cycle_number, |
| 147 | uint64_tcxx . . $ uint64_t# last_tx_hw_timestamp); |
| 148 | int stat_to_jsoncxx . . $ stat_to_json(fc2a9ca47478af75).(char *json, size_tcxx . . $ size_t# len, const struct statisticscxx . . $ statistics# *stat, const char *tc, |
| 149 | const char *measurement); |
| 150 | |
| 151 | extern volatile sig_atomic_tcxx . . $ sig_atomic_t# reset_statscxx . . $ reset_stats.; |
| 152 | extern struct round_trip_contextcxx . . $ round_trip_context# round_trip_contextscxx . . $ round_trip_contexts.[NUM_FRAME_TYPEScxx . . $ NUM_FRAME_TYPES.]; |
| 153 | extern int log_stat_user_selectedcxx . . $ log_stat_user_selected.; |
| 154 | |
| 155 | #endif /* _STAT_H_ */ |