Add functions to get and reset event timer adapter stats.

Signed-off-by: Pavan Nikhilesh <pbhagavat...@caviumnetworks.com>
---
 drivers/event/octeontx/timvf_evdev.c | 26 ++++++++++++++++++++++++++
 drivers/event/octeontx/timvf_evdev.h |  1 +
 2 files changed, 27 insertions(+)

diff --git a/drivers/event/octeontx/timvf_evdev.c 
b/drivers/event/octeontx/timvf_evdev.c
index ccf724115..4db10cdd0 100644
--- a/drivers/event/octeontx/timvf_evdev.c
+++ b/drivers/event/octeontx/timvf_evdev.c
@@ -281,12 +281,38 @@ timvf_ring_free(struct rte_event_timer_adapter *adptr)
        return 0;
 }
 
+
+static int
+timvf_stats_get(const struct rte_event_timer_adapter *adapter,
+               struct rte_event_timer_adapter_stats *stats)
+{
+       struct timvf_ring *timr = adapter->data->adapter_priv;
+       uint64_t bkt_cyc = rte_rdtsc() - timr->meta.ring_start_cyc;
+
+       stats->evtim_exp_count = timr->meta.tim_arm_cnt;
+       stats->ev_enq_count = timr->meta.tim_arm_cnt;
+       stats->adapter_tick_count = rte_reciprocal_divide_u64(bkt_cyc,
+                               &timr->meta.fast_div);
+       return 0;
+}
+
+static int
+timvf_stats_reset(const struct rte_event_timer_adapter *adapter)
+{
+       struct timvf_ring *timr = adapter->data->adapter_priv;
+
+       timr->meta.tim_arm_cnt = 0;
+       return 0;
+}
+
 static struct rte_event_timer_adapter_ops timvf_ops = {
                .init           = timvf_ring_create,
                .uninit         = timvf_ring_free,
                .start          = timvf_ring_start,
                .stop           = timvf_ring_stop,
                .get_info       = timvf_ring_info_get,
+               .stats_get      = timvf_stats_get,
+               .stats_reset    = timvf_stats_reset,
 };
 
 int
diff --git a/drivers/event/octeontx/timvf_evdev.h 
b/drivers/event/octeontx/timvf_evdev.h
index e155b6ce2..e98ab631a 100644
--- a/drivers/event/octeontx/timvf_evdev.h
+++ b/drivers/event/octeontx/timvf_evdev.h
@@ -145,6 +145,7 @@ struct timvf_meta {
        struct tim_mem_bucket *bkt;
        void *chunk_pool;
        uint64_t tck_int;
+       volatile uint64_t tim_arm_cnt;
 };
 
 struct timvf_ring {
-- 
2.16.3

Reply via email to