DSW keeps an internal port load estimate, used by the load balancing mechanism. As a side effect, it keeps track of the total number of busy cycles since startup. This metric is indirectly exposed in the form of DSW xstats' "port_<n>_event_proc_latency", which is the total number of busy cycles divided by the total number of events processed on a particular port.
An external application can take (event_latency * dequeued) to go back to busy_cycles. One reason for doing this is to measure the port's load during a longer time period, without resorting to sampling "port_<n>_load". However, as the number dequeued events grows, a rounding error in event_latency renders the application-calculated busy_cycles inaccurate. Thus, it makes sense to directly expose the number of busy cycles as a DSW xstats, even though it might seem redundant. Signed-off-by: Mattias Rönnblom <mattias.ronnb...@ericsson.com> --- drivers/event/dsw/dsw_xstats.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/event/dsw/dsw_xstats.c b/drivers/event/dsw/dsw_xstats.c index d332a57b6..e8e92183e 100644 --- a/drivers/event/dsw/dsw_xstats.c +++ b/drivers/event/dsw/dsw_xstats.c @@ -109,6 +109,13 @@ dsw_xstats_port_get_event_proc_latency(struct dsw_evdev *dsw, uint8_t port_id, return dequeued > 0 ? total_busy_cycles / dequeued : 0; } +static uint64_t +dsw_xstats_port_get_busy_cycles(struct dsw_evdev *dsw, uint8_t port_id, + uint8_t queue_id __rte_unused) +{ + return dsw->ports[port_id].total_busy_cycles; +} + DSW_GEN_PORT_ACCESS_FN(inflight_credits) DSW_GEN_PORT_ACCESS_FN(pending_releases) @@ -147,6 +154,8 @@ static struct dsw_xstats_port dsw_port_xstats[] = { false }, { "port_%u_event_proc_latency", dsw_xstats_port_get_event_proc_latency, false }, + { "port_%u_busy_cycles", dsw_xstats_port_get_busy_cycles, + false }, { "port_%u_inflight_credits", dsw_xstats_port_get_inflight_credits, false }, { "port_%u_pending_releases", dsw_xstats_port_get_pending_releases, -- 2.17.1