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;
    27         write_reg_fn_t write_reg_fn,
    28         read_reg_fn_t read_reg_fn)
    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);
    67     write_reg_fn_t _write_reg_fn;
    68     read_reg_fn_t _read_reg_fn;
 
Definition: property_tree.hpp:199
 
Definition: traffic_counter.hpp:18
 
boost::shared_ptr< property_tree > sptr
Definition: property_tree.hpp:217
 
std::function< uint64_t(const uint32_t addr)> read_reg_fn_t
Definition: traffic_counter.hpp:23
 
Definition: build_info.hpp:13
 
std::shared_ptr< traffic_counter > sptr
Definition: traffic_counter.hpp:21
 
std::function< void(const uint32_t addr, const uint32_t data)> write_reg_fn_t
Definition: traffic_counter.hpp:22
 
traffic_counter(uhd::property_tree::sptr tree, uhd::fs_path root_path, write_reg_fn_t write_reg_fn, read_reg_fn_t read_reg_fn)
Definition: traffic_counter.hpp:25