dpdk: print debug xstats counters of all DPDK ports on shutdown

pull/8430/head
Lukas Sismis 2 years ago committed by Victor Julien
parent cb6fa894ef
commit 79130103c2

@ -526,6 +526,48 @@ fail:
SCReturnInt(TM_ECODE_FAILED);
}
static void PrintDPDKPortXstats(uint32_t port_id, const char *port_name)
{
struct rte_eth_xstat *xstats;
struct rte_eth_xstat_name *xstats_names;
int32_t len = rte_eth_xstats_get(port_id, NULL, 0);
if (len < 0)
FatalError("Error (%s) getting count of rte_eth_xstats failed on port %s",
rte_strerror(-len), port_name);
xstats = SCCalloc(len, sizeof(*xstats));
if (xstats == NULL)
FatalError("Failed to allocate memory for the rte_eth_xstat structure");
int32_t ret = rte_eth_xstats_get(port_id, xstats, len);
if (ret < 0 || ret > len) {
SCFree(xstats);
FatalError("Error (%s) getting rte_eth_xstats failed on port %s", rte_strerror(-ret),
port_name);
}
xstats_names = SCCalloc(len, sizeof(*xstats_names));
if (xstats_names == NULL) {
SCFree(xstats);
FatalError("Failed to allocate memory for the rte_eth_xstat_name array");
}
ret = rte_eth_xstats_get_names(port_id, xstats_names, len);
if (ret < 0 || ret > len) {
SCFree(xstats);
SCFree(xstats_names);
FatalError("Error (%s) getting names of rte_eth_xstats failed on port %s",
rte_strerror(-ret), port_name);
}
for (int32_t i = 0; i < len; i++) {
if (xstats[i].value > 0)
SCLogPerf("Port %u (%s) - %s: %" PRIu64, port_id, port_name, xstats_names[i].name,
xstats[i].value);
}
SCFree(xstats);
SCFree(xstats_names);
}
/**
* \brief This function prints stats to the screen at exit.
* \param tv pointer to ThreadVars
@ -547,6 +589,9 @@ static void ReceiveDPDKThreadExitStats(ThreadVars *tv, void *data)
strerror(-retval));
SCReturn;
}
PrintDPDKPortXstats(ptv->port_id, port_name);
retval = rte_eth_stats_get(ptv->port_id, &eth_stats);
if (unlikely(retval != 0)) {
SCLogError("Failed to get stats for interface %s: %s", port_name, strerror(-retval));

Loading…
Cancel
Save