[dpdk-dev] [PATCH v4 05/11] event/octeontx: add event timer stats get and reset

Pavan Nikhilesh pbhagavatula at caviumnetworks.com
Mon Apr 9 23:00:29 CEST 2018


Add functions to get and reset event timer adapter stats.

Signed-off-by: Pavan Nikhilesh <pbhagavatula at caviumnetworks.com>
---
 drivers/event/octeontx/ssovf_evdev.c | 14 ++++++++++++-
 drivers/event/octeontx/timvf_evdev.c | 30 +++++++++++++++++++++++++++-
 drivers/event/octeontx/timvf_evdev.h |  3 +++
 3 files changed, 45 insertions(+), 2 deletions(-)

diff --git a/drivers/event/octeontx/ssovf_evdev.c b/drivers/event/octeontx/ssovf_evdev.c
index 34496f114..2df70b52a 100644
--- a/drivers/event/octeontx/ssovf_evdev.c
+++ b/drivers/event/octeontx/ssovf_evdev.c
@@ -21,6 +21,7 @@
 #include "timvf_evdev.h"
 
 int otx_logtype_ssovf;
+static uint8_t timvf_enable_stats;
 
 RTE_INIT(otx_ssovf_init_log);
 static void
@@ -606,7 +607,8 @@ static int
 ssovf_timvf_caps_get(const struct rte_eventdev *dev, uint64_t flags,
 		uint32_t *caps, const struct rte_event_timer_adapter_ops **ops)
 {
-	return timvf_timer_adapter_caps_get(dev, flags, caps, ops, 0);
+	return timvf_timer_adapter_caps_get(dev, flags, caps, ops,
+			timvf_enable_stats);
 }
 
 /* Initialize and register event driver with DPDK Application */
@@ -654,6 +656,7 @@ ssovf_vdev_probe(struct rte_vdev_device *vdev)
 
 	static const char *const args[] = {
 		SSOVF_SELFTEST_ARG,
+		TIMVF_ENABLE_STATS_ARG,
 		NULL
 	};
 
@@ -681,6 +684,15 @@ ssovf_vdev_probe(struct rte_vdev_device *vdev)
 				rte_kvargs_free(kvlist);
 				return ret;
 			}
+
+			ret = rte_kvargs_process(kvlist,
+					TIMVF_ENABLE_STATS_ARG,
+					ssovf_selftest, &timvf_enable_stats);
+			if (ret != 0) {
+				ssovf_log_err("%s: Error in timvf stats", name);
+				rte_kvargs_free(kvlist);
+				return ret;
+			}
 		}
 
 		rte_kvargs_free(kvlist);
diff --git a/drivers/event/octeontx/timvf_evdev.c b/drivers/event/octeontx/timvf_evdev.c
index 84c6a511e..c66db437e 100644
--- a/drivers/event/octeontx/timvf_evdev.c
+++ b/drivers/event/octeontx/timvf_evdev.c
@@ -268,6 +268,29 @@ 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->ring_start_cyc;
+
+	stats->evtim_exp_count = timr->tim_arm_cnt;
+	stats->ev_enq_count = timr->tim_arm_cnt;
+	stats->adapter_tick_count = rte_reciprocal_divide_u64(bkt_cyc,
+				&timr->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->tim_arm_cnt = 0;
+	return 0;
+}
+
 static struct rte_event_timer_adapter_ops timvf_ops = {
 	.init		= timvf_ring_create,
 	.uninit		= timvf_ring_free,
@@ -283,7 +306,12 @@ timvf_timer_adapter_caps_get(const struct rte_eventdev *dev, uint64_t flags,
 {
 	RTE_SET_USED(dev);
 	RTE_SET_USED(flags);
-	RTE_SET_USED(enable_stats);
+
+	if (enable_stats) {
+		timvf_ops.stats_get   = timvf_stats_get;
+		timvf_ops.stats_reset = timvf_stats_reset;
+	}
+
 	*caps = RTE_EVENT_TIMER_ADAPTER_CAP_INTERNAL_PORT;
 	*ops = &timvf_ops;
 	return -EINVAL;
diff --git a/drivers/event/octeontx/timvf_evdev.h b/drivers/event/octeontx/timvf_evdev.h
index 7663dc375..e89a43531 100644
--- a/drivers/event/octeontx/timvf_evdev.h
+++ b/drivers/event/octeontx/timvf_evdev.h
@@ -83,6 +83,8 @@
 #define timvf_read64 rte_read64_relaxed
 #define timvf_write64 rte_write64_relaxed
 
+#define TIMVF_ENABLE_STATS_ARG               ("timvf_stats")
+
 extern int otx_logtype_timvf;
 static const uint16_t nb_chunk_slots = (TIM_CHUNK_SIZE / 16) - 1;
 
@@ -145,6 +147,7 @@ struct timvf_ring {
 	struct tim_mem_bucket *bkt;
 	void *chunk_pool;
 	uint64_t tck_int;
+	volatile uint64_t tim_arm_cnt;
 	uint64_t tck_nsec;
 	void  *vbar0;
 	void *bkt_pos;
-- 
2.17.0



More information about the dev mailing list