7 #ifndef INCLUDED_LIBUHD_TRAFFIC_COUNTER_HPP
8 #define INCLUDED_LIBUHD_TRAFFIC_COUNTER_HPP
12 #include <type_traits>
16 namespace uhd {
namespace rfnoc {
21 typedef std::shared_ptr<traffic_counter>
sptr;
22 typedef std::function<void(
const uint32_t addr,
const uint32_t data)>
write_reg_fn_t;
29 : _write_reg_fn(write_reg_fn), _read_reg_fn(read_reg_fn)
31 const uint32_t id_reg_offset = 0;
32 const uint32_t first_counter_offset = 1;
33 const uint64_t traffic_counter_id = 0x712AFF1C00000000ULL;
36 const uint64_t
id = _read_reg_fn(id_reg_offset);
39 if (
id == traffic_counter_id) {
40 tree->create<
bool>(root_path /
"traffic_counter/enable")
41 .add_coerced_subscriber([
this](
const bool enable) {
42 uint32_t val = enable ? 1 : 0;
43 return _write_reg_fn(0, val);
47 const char* counters[] = {
"bus_clock_ticks",
48 "xbar_to_shell_xfer_count",
49 "xbar_to_shell_pkt_count",
50 "shell_to_xbar_xfer_count",
51 "shell_to_xbar_pkt_count",
52 "shell_to_ce_xfer_count",
53 "shell_to_ce_pkt_count",
54 "ce_to_shell_xfer_count",
55 "ce_to_shell_pkt_count"};
57 for (
size_t i = 0; i < std::extent<decltype(counters)>::value; i++) {
58 tree->create<uint64_t>(root_path /
"traffic_counter" / counters[i])
59 .set_publisher([
this, i, first_counter_offset]() {
60 return _read_reg_fn(i + first_counter_offset);