DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
dunedaq::dpdklibs::IfaceXstats Struct Reference

#include <XstatsHelper.hpp>

Public Member Functions

 IfaceXstats ()
 ~IfaceXstats ()
void clear ()
void setup (int iface)
void reset_counters ()
void poll ()
void stop ()

Public Attributes

int m_iface_id
bool m_enabled = false
struct rte_eth_stats m_eth_stats
struct rte_eth_xstat_name * m_xstats_names
uint64_t * m_xstats_ids
uint64_t * m_xstats_values
int m_len

Detailed Description

Definition at line 8 of file XstatsHelper.hpp.

Constructor & Destructor Documentation

◆ IfaceXstats()

dunedaq::dpdklibs::IfaceXstats::IfaceXstats ( )
inline

Definition at line 9 of file XstatsHelper.hpp.

9{}

◆ ~IfaceXstats()

dunedaq::dpdklibs::IfaceXstats::~IfaceXstats ( )
inline

Definition at line 10 of file XstatsHelper.hpp.

11 {
12 clear();
13 }

Member Function Documentation

◆ clear()

void dunedaq::dpdklibs::IfaceXstats::clear ( )
inline

Definition at line 15 of file XstatsHelper.hpp.

15 {
16 if (m_xstats_values != nullptr) {
17 free(m_xstats_values);
18 }
19 if (m_xstats_ids != nullptr) {
20 free(m_xstats_ids);
21 }
22 if (m_xstats_names != nullptr) {
23 free(m_xstats_names);
24 }
25 m_len = 0;
26 }
struct rte_eth_xstat_name * m_xstats_names

◆ poll()

void dunedaq::dpdklibs::IfaceXstats::poll ( )
inline

Definition at line 79 of file XstatsHelper.hpp.

79 {
80 if (m_enabled) {
81 if (m_len != rte_eth_xstats_get_by_id(m_iface_id, nullptr, m_xstats_values, m_len)) {
82 TLOG() << "Cannot get xstat values!";
83 //} else {
84 }
85
86 rte_eth_stats_get(m_iface_id, &m_eth_stats);
87 }
88 }
#define TLOG(...)
Definition macro.hpp:22
struct rte_eth_stats m_eth_stats

◆ reset_counters()

void dunedaq::dpdklibs::IfaceXstats::reset_counters ( )
inline

Definition at line 70 of file XstatsHelper.hpp.

70 {
71 if (m_enabled) {
72 rte_eth_xstats_reset(m_iface_id); //{
73 // TLOG() << "Cannot reset xstat values!";
74 //} else {
75 //}
76 }
77 }

◆ setup()

void dunedaq::dpdklibs::IfaceXstats::setup ( int iface)
inline

Definition at line 28 of file XstatsHelper.hpp.

28 {
30 rte_eth_stats_reset(m_iface_id);
31 rte_eth_xstats_reset(m_iface_id);
32
33 // Get number of stats
34 m_len = rte_eth_xstats_get_names_by_id(m_iface_id, NULL, 0, NULL);
35 if (m_len < 0) {
36 printf("Cannot get xstats count\n");
37 }
38
39 // Get names of HW registered stat fields
40 m_xstats_names = (rte_eth_xstat_name*)(malloc(sizeof(struct rte_eth_xstat_name) * m_len));
41 if (m_xstats_names == nullptr) {
42 printf("Cannot allocate memory for xstat names\n");
43 }
44
45 // Retrieve xstats names, passing NULL for IDs to return all statistics
46 if (m_len != rte_eth_xstats_get_names(m_iface_id, m_xstats_names, m_len)) {
47 printf("Cannot get xstat names\n");
48 }
49
50 // Allocate value fields
51 m_xstats_values = (uint64_t*)(malloc(sizeof(m_xstats_values) * m_len));
52 if (m_xstats_values == nullptr) {
53 printf("Cannot allocate memory for xstats\n");
54 }
55
56 // Getting xstats values (this is that we call in a loop/get_info
57 if (m_len != rte_eth_xstats_get_by_id(m_iface_id, nullptr, m_xstats_values, m_len)) {
58 printf("Cannot get xstat values\n");
59 }
60
61 // Print all xstats names and values to be amazed (WOW!)
62 TLOG() << "Registered HW based metrics: ";
63 for (int i = 0; i < m_len; i++) {
64 TLOG() << " XName: " << m_xstats_names[i].name;
65 }
66
67 m_enabled = true;
68 };

◆ stop()

void dunedaq::dpdklibs::IfaceXstats::stop ( )
inline

Definition at line 90 of file XstatsHelper.hpp.

90 {
91 m_enabled = false;
92 clear();
93 TLOG() << "XstatsHelper disabled.";
94 }

Member Data Documentation

◆ m_enabled

bool dunedaq::dpdklibs::IfaceXstats::m_enabled = false

Definition at line 97 of file XstatsHelper.hpp.

◆ m_eth_stats

struct rte_eth_stats dunedaq::dpdklibs::IfaceXstats::m_eth_stats

Definition at line 98 of file XstatsHelper.hpp.

◆ m_iface_id

int dunedaq::dpdklibs::IfaceXstats::m_iface_id

Definition at line 96 of file XstatsHelper.hpp.

◆ m_len

int dunedaq::dpdklibs::IfaceXstats::m_len

Definition at line 102 of file XstatsHelper.hpp.

◆ m_xstats_ids

uint64_t* dunedaq::dpdklibs::IfaceXstats::m_xstats_ids

Definition at line 100 of file XstatsHelper.hpp.

◆ m_xstats_names

struct rte_eth_xstat_name* dunedaq::dpdklibs::IfaceXstats::m_xstats_names

Definition at line 99 of file XstatsHelper.hpp.

◆ m_xstats_values

uint64_t* dunedaq::dpdklibs::IfaceXstats::m_xstats_values

Definition at line 101 of file XstatsHelper.hpp.


The documentation for this struct was generated from the following file: