DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH 0/3] periodic mode for event timer adapter
@ 2021-03-08 20:45 Shijith Thotton
  2021-03-08 20:45 ` [dpdk-dev] [PATCH 1/3] eventdev: introduce adapter flags for periodic mode Shijith Thotton
                   ` (3 more replies)
  0 siblings, 4 replies; 23+ messages in thread
From: Shijith Thotton @ 2021-03-08 20:45 UTC (permalink / raw)
  To: Erik Gabriel Carrillo; +Cc: Shijith Thotton, Pavan Nikhilesh, Jerin Jacob, dev

Arming periodic timers are not supported by the event timer adapter
right now. This series adds that support. A timer adapter configured in
periodic mode can be used to arm periodic timers. 

First patch adds a flag to expose periodic mode capability of an adapter
and flag to configure the adapter in periodic mode. Second one adds unit
tests for periodic mode. Third one is a hardware implementation of the
feature.

Shijith Thotton (3):
  eventdev: introduce adapter flags for periodic mode
  test/event: add unit tests for periodic timer
  event/octeontx2: add timer periodic mode support

 app/test/test_event_timer_adapter.c           | 136 ++++++++++++++++--
 doc/guides/prog_guide/event_timer_adapter.rst |  33 +++++
 drivers/event/octeontx2/otx2_tim_evdev.c      |  29 +++-
 drivers/event/octeontx2/otx2_tim_evdev.h      |   1 +
 lib/librte_eventdev/rte_event_timer_adapter.h |   6 +
 lib/librte_eventdev/rte_eventdev.h            |   3 +
 6 files changed, 190 insertions(+), 18 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 23+ messages in thread

* [dpdk-dev] [PATCH 1/3] eventdev: introduce adapter flags for periodic mode
  2021-03-08 20:45 [dpdk-dev] [PATCH 0/3] periodic mode for event timer adapter Shijith Thotton
@ 2021-03-08 20:45 ` Shijith Thotton
  2021-03-09 20:04   ` Carrillo, Erik G
  2021-03-12 15:30   ` Carrillo, Erik G
  2021-03-08 20:45 ` [dpdk-dev] [PATCH 2/3] test/event: add unit tests for periodic timer Shijith Thotton
                   ` (2 subsequent siblings)
  3 siblings, 2 replies; 23+ messages in thread
From: Shijith Thotton @ 2021-03-08 20:45 UTC (permalink / raw)
  To: Erik Gabriel Carrillo; +Cc: Shijith Thotton, Pavan Nikhilesh, Jerin Jacob, dev

A timer adapter in periodic mode can be used to arm periodic timers.
This patch adds flags used to advertise capability and configure timer
adapter in periodic mode. Capability flag should be set for adapters
which support periodic mode.

Below is a programming sequence on the usage:
	/* check for periodic mode support by reading capability. */
	rte_event_timer_adapter_caps_get(...);

	/* create adapter in periodic mode by setting periodic flag
	   (RTE_EVENT_TIMER_ADAPTER_F_PERIODIC) and resolution. */
	rte_event_timer_adapter_create_ext(...);

	/* arm periodic timer of configured resolution */
	rte_event_timer_arm_burst(...);

	/* timer event will be periodically generated at configured
	   resolution till cancel is called. */
	while (running) { rte_event_dequeue_burst(...); }

	/* cancel periodic timer which stops generating events */
	rte_event_timer_cancel_burst(...);

Signed-off-by: Shijith Thotton <sthotton@marvell.com>
---
 doc/guides/prog_guide/event_timer_adapter.rst | 33 +++++++++++++++++++
 lib/librte_eventdev/rte_event_timer_adapter.h |  6 ++++
 lib/librte_eventdev/rte_eventdev.h            |  3 ++
 3 files changed, 42 insertions(+)

diff --git a/doc/guides/prog_guide/event_timer_adapter.rst b/doc/guides/prog_guide/event_timer_adapter.rst
index a95efbe0d..fcdecdb3b 100644
--- a/doc/guides/prog_guide/event_timer_adapter.rst
+++ b/doc/guides/prog_guide/event_timer_adapter.rst
@@ -252,6 +252,39 @@ be canceled by calling ``rte_event_timer_cancel_burst()``:
          */
 	rte_event_timer_cancel_burst(adapter, &conn->timer, 1);
 
+Timer adapter in periodic mode
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+A periodic timer is a timer, which expires at fixed time intervals continuously
+till it is cancelled.  A timer adapter can be configured to arm such timers by
+configuring it in periodic mode.  Capability flag
+``RTE_EVENT_TIMER_ADAPTER_CAP_PERIODIC`` can be used to check if an adapter
+supports periodic mode. An adapter in periodic mode can only be used to arm
+periodic timers.
+
+Example config to create an adapter in periodic mode with 100ms resolution:
+
+.. code-block:: c
+
+	#define NSECPERSEC 1E9 // No of ns in 1 sec
+	const struct rte_event_timer_adapter_conf adapter_config = {
+                .event_dev_id = event_dev_id,
+                .timer_adapter_id = 0,
+                .clk_src = RTE_EVENT_TIMER_ADAPTER_CPU_CLK,
+                .timer_tick_ns = NSECPERSEC / 10, // 100 milliseconds
+                .nb_timers = 100,
+                .timer_adapter_flags = RTE_EVENT_TIMER_ADAPTER_F_PERIODIC,
+	};
+
+``timer_adapter_flags`` is set to include periodic flag
+``RTE_EVENT_TIMER_ADAPTER_F_PERIODIC`` and ``timer_tick_ns`` to resolution.
+Maximum timeout (``max_tmo_nsec``) does not apply for periodic mode.
+
+After starting the adapter, event timer arm APIs can be used to arm periodic
+timers.  Timer events will be generated at configured ``timer_tick_ns``
+intervals.  Event generation can be stopped using cancel API
+``rte_event_timer_cancel_burst``.
+
 Processing Timer Expiry Events
 ------------------------------
 
diff --git a/lib/librte_eventdev/rte_event_timer_adapter.h b/lib/librte_eventdev/rte_event_timer_adapter.h
index d2ebcb090..f9fc95711 100644
--- a/lib/librte_eventdev/rte_event_timer_adapter.h
+++ b/lib/librte_eventdev/rte_event_timer_adapter.h
@@ -151,6 +151,12 @@ enum rte_event_timer_adapter_clk_src {
  * @see struct rte_event_timer_adapter_conf::flags
  */
 
+#define RTE_EVENT_TIMER_ADAPTER_F_PERIODIC	(1ULL << 2)
+/**< Flag to configure event timer adapter in periodic mode.
+ *
+ * @see struct rte_event_timer_adapter_conf::flags
+ */
+
 /**
  * Timer adapter configuration structure
  */
diff --git a/lib/librte_eventdev/rte_eventdev.h b/lib/librte_eventdev/rte_eventdev.h
index ce1fc2ce0..9fc39e9ca 100644
--- a/lib/librte_eventdev/rte_eventdev.h
+++ b/lib/librte_eventdev/rte_eventdev.h
@@ -1154,6 +1154,9 @@ rte_event_eth_rx_adapter_caps_get(uint8_t dev_id, uint16_t eth_port_id,
 #define RTE_EVENT_TIMER_ADAPTER_CAP_INTERNAL_PORT (1ULL << 0)
 /**< This flag is set when the timer mechanism is in HW. */
 
+#define RTE_EVENT_TIMER_ADAPTER_CAP_PERIODIC      (1ULL << 1)
+/**< This flag is set if periodic mode is supported. */
+
 /**
  * Retrieve the event device's timer adapter capabilities.
  *
-- 
2.25.1


^ permalink raw reply	[flat|nested] 23+ messages in thread

* [dpdk-dev] [PATCH 2/3] test/event: add unit tests for periodic timer
  2021-03-08 20:45 [dpdk-dev] [PATCH 0/3] periodic mode for event timer adapter Shijith Thotton
  2021-03-08 20:45 ` [dpdk-dev] [PATCH 1/3] eventdev: introduce adapter flags for periodic mode Shijith Thotton
@ 2021-03-08 20:45 ` Shijith Thotton
  2021-03-08 20:45 ` [dpdk-dev] [PATCH 3/3] event/octeontx2: add timer periodic mode support Shijith Thotton
  2021-03-14 16:45 ` [dpdk-dev] [PATCH v2 0/3] periodic mode for event timer adapter Shijith Thotton
  3 siblings, 0 replies; 23+ messages in thread
From: Shijith Thotton @ 2021-03-08 20:45 UTC (permalink / raw)
  To: Erik Gabriel Carrillo; +Cc: Shijith Thotton, Pavan Nikhilesh, Jerin Jacob, dev

Add tests to arm and cancel periodic timer.

Signed-off-by: Shijith Thotton <sthotton@marvell.com>
---
 app/test/test_event_timer_adapter.c | 136 +++++++++++++++++++++++++---
 1 file changed, 123 insertions(+), 13 deletions(-)

diff --git a/app/test/test_event_timer_adapter.c b/app/test/test_event_timer_adapter.c
index b536ddef4..20be46da3 100644
--- a/app/test/test_event_timer_adapter.c
+++ b/app/test/test_event_timer_adapter.c
@@ -283,7 +283,7 @@ test_port_conf_cb(uint16_t id, uint8_t event_dev_id, uint8_t *event_port_id,
 }
 
 static int
-_timdev_setup(uint64_t max_tmo_ns, uint64_t bkt_tck_ns)
+_timdev_setup(uint64_t max_tmo_ns, uint64_t bkt_tck_ns, uint64_t flags)
 {
 	struct rte_event_timer_adapter_info info;
 	struct rte_event_timer_adapter_conf config = {
@@ -292,7 +292,7 @@ _timdev_setup(uint64_t max_tmo_ns, uint64_t bkt_tck_ns)
 		.timer_tick_ns = bkt_tck_ns,
 		.max_tmo_ns = max_tmo_ns,
 		.nb_timers = MAX_TIMERS * 10,
-		.flags = RTE_EVENT_TIMER_ADAPTER_F_ADJUST_RES,
+		.flags = flags,
 	};
 	uint32_t caps = 0;
 	const char *pool_name = "timdev_test_pool";
@@ -301,6 +301,13 @@ _timdev_setup(uint64_t max_tmo_ns, uint64_t bkt_tck_ns)
 
 	TEST_ASSERT_SUCCESS(rte_event_timer_adapter_caps_get(evdev, &caps),
 				"failed to get adapter capabilities");
+
+	if (flags & RTE_EVENT_TIMER_ADAPTER_F_PERIODIC &&
+	    !(caps & RTE_EVENT_TIMER_ADAPTER_CAP_PERIODIC)) {
+		printf("Adapter does not support periodic timers\n");
+		return TEST_SKIPPED;
+	}
+
 	if (!(caps & RTE_EVENT_TIMER_ADAPTER_CAP_INTERNAL_PORT)) {
 		timdev = rte_event_timer_adapter_create_ext(&config,
 							    test_port_conf_cb,
@@ -338,42 +345,72 @@ _timdev_setup(uint64_t max_tmo_ns, uint64_t bkt_tck_ns)
 static int
 timdev_setup_usec(void)
 {
+	uint64_t flags = RTE_EVENT_TIMER_ADAPTER_F_ADJUST_RES;
+
 	return using_services ?
 		/* Max timeout is 10,000us and bucket interval is 100us */
-		_timdev_setup(1E7, 1E5) :
+		_timdev_setup(1E7, 1E5, flags) :
 		/* Max timeout is 100us and bucket interval is 1us */
-		_timdev_setup(1E5, 1E3);
+		_timdev_setup(1E5, 1E3, flags);
 }
 
 static int
 timdev_setup_usec_multicore(void)
 {
+	uint64_t flags = RTE_EVENT_TIMER_ADAPTER_F_ADJUST_RES;
+
 	return using_services ?
 		/* Max timeout is 10,000us and bucket interval is 100us */
-		_timdev_setup(1E7, 1E5) :
+		_timdev_setup(1E7, 1E5, flags) :
 		/* Max timeout is 100us and bucket interval is 1us */
-		_timdev_setup(1E5, 1E3);
+		_timdev_setup(1E5, 1E3, flags);
 }
 
 static int
 timdev_setup_msec(void)
 {
-	/* Max timeout is 2 mins, and bucket interval is 100 ms */
-	return _timdev_setup(180 * NSECPERSEC, NSECPERSEC / 10);
+	uint64_t flags = RTE_EVENT_TIMER_ADAPTER_F_ADJUST_RES;
+
+	/* Max timeout is 3 mins, and bucket interval is 100 ms */
+	return _timdev_setup(180 * NSECPERSEC, NSECPERSEC / 10, flags);
+}
+
+static int
+timdev_setup_msec_periodic(void)
+{
+	uint64_t flags = RTE_EVENT_TIMER_ADAPTER_F_ADJUST_RES |
+			 RTE_EVENT_TIMER_ADAPTER_F_PERIODIC;
+
+	/* Periodic mode with 100 ms resolution */
+	return _timdev_setup(0, NSECPERSEC / 10, flags);
 }
 
 static int
 timdev_setup_sec(void)
 {
+	uint64_t flags = RTE_EVENT_TIMER_ADAPTER_F_ADJUST_RES;
+
 	/* Max timeout is 100sec and bucket interval is 1sec */
-	return _timdev_setup(1E11, 1E9);
+	return _timdev_setup(1E11, 1E9, flags);
+}
+
+static int
+timdev_setup_sec_periodic(void)
+{
+	uint64_t flags = RTE_EVENT_TIMER_ADAPTER_F_ADJUST_RES |
+			 RTE_EVENT_TIMER_ADAPTER_F_PERIODIC;
+
+	/* Periodic mode with 1 sec resolution */
+	return _timdev_setup(0, NSECPERSEC, flags);
 }
 
 static int
 timdev_setup_sec_multicore(void)
 {
+	uint64_t flags = RTE_EVENT_TIMER_ADAPTER_F_ADJUST_RES;
+
 	/* Max timeout is 100sec and bucket interval is 1sec */
-	return _timdev_setup(1E11, 1E9);
+	return _timdev_setup(1E11, 1E9, flags);
 }
 
 static void
@@ -513,6 +550,18 @@ test_timer_arm(void)
 	return TEST_SUCCESS;
 }
 
+static inline int
+test_timer_arm_periodic(void)
+{
+	TEST_ASSERT_SUCCESS(_arm_timers(1, MAX_TIMERS),
+			    "Failed to arm timers");
+	/* With a resolution of 100ms and wait time of 1sec,
+	 * there will be 10 * MAX_TIMERS periodic timer triggers */
+	TEST_ASSERT_SUCCESS(_wait_timer_triggers(1, 10 * MAX_TIMERS, 0),
+			    "Timer triggered count doesn't match arm count");
+	return TEST_SUCCESS;
+}
+
 static int
 _arm_wrapper(void *arg)
 {
@@ -588,6 +637,19 @@ test_timer_arm_burst(void)
 	return TEST_SUCCESS;
 }
 
+static inline int
+test_timer_arm_burst_periodic(void)
+{
+	TEST_ASSERT_SUCCESS(_arm_timers_burst(1, MAX_TIMERS),
+			    "Failed to arm timers");
+	/* With a resolution of 100ms and wait time of 1sec,
+	 * there will be 10 * MAX_TIMERS periodic timer triggers */
+	TEST_ASSERT_SUCCESS(_wait_timer_triggers(1, 10 * MAX_TIMERS, 0),
+			    "Timer triggered count doesn't match arm count");
+
+	return TEST_SUCCESS;
+}
+
 static int
 _arm_wrapper_burst(void *arg)
 {
@@ -612,6 +674,48 @@ test_timer_arm_burst_multicore(void)
 	return TEST_SUCCESS;
 }
 
+static inline int
+test_timer_cancel_periodic(void)
+{
+	uint64_t i;
+	struct rte_event_timer *ev_tim;
+	const struct rte_event_timer tim = {
+		.ev.op = RTE_EVENT_OP_NEW,
+		.ev.queue_id = 0,
+		.ev.sched_type = RTE_SCHED_TYPE_ATOMIC,
+		.ev.priority = RTE_EVENT_DEV_PRIORITY_NORMAL,
+		.ev.event_type =  RTE_EVENT_TYPE_TIMER,
+		.state = RTE_EVENT_TIMER_NOT_ARMED,
+		.timeout_ticks = CALC_TICKS(1),
+	};
+
+	for (i = 0; i < MAX_TIMERS; i++) {
+		TEST_ASSERT_SUCCESS(rte_mempool_get(eventdev_test_mempool,
+					(void **)&ev_tim),
+				"mempool alloc failed");
+		*ev_tim = tim;
+		ev_tim->ev.event_ptr = ev_tim;
+
+		TEST_ASSERT_EQUAL(rte_event_timer_arm_burst(timdev, &ev_tim,
+					1), 1, "Failed to arm timer %d",
+				rte_errno);
+
+		rte_delay_us(100 + (i % 5000));
+
+		TEST_ASSERT_EQUAL(rte_event_timer_cancel_burst(timdev,
+					&ev_tim, 1), 1,
+				"Failed to cancel event timer %d", rte_errno);
+		rte_mempool_put(eventdev_test_mempool, ev_tim);
+	}
+
+
+	TEST_ASSERT_SUCCESS(_wait_timer_triggers(30, MAX_TIMERS,
+				MAX_TIMERS),
+		"Timer triggered count doesn't match arm, cancel count");
+
+	return TEST_SUCCESS;
+}
+
 static inline int
 test_timer_cancel(void)
 {
@@ -1028,9 +1132,9 @@ adapter_lookup(void)
 static int
 adapter_start(void)
 {
-	TEST_ASSERT_SUCCESS(_timdev_setup(180 * NSECPERSEC,
-			NSECPERSEC / 10),
-			"Failed to start adapter");
+	TEST_ASSERT_SUCCESS(_timdev_setup(180 * NSECPERSEC, NSECPERSEC / 10,
+					  RTE_EVENT_TIMER_ADAPTER_F_ADJUST_RES),
+			    "Failed to start adapter");
 	TEST_ASSERT_EQUAL(rte_event_timer_adapter_start(timdev), -EALREADY,
 			"Timer adapter started without call to stop.");
 
@@ -1786,10 +1890,16 @@ static struct unit_test_suite event_timer_adptr_functional_testsuite  = {
 				test_timer_state),
 		TEST_CASE_ST(timdev_setup_usec, timdev_teardown,
 				test_timer_arm),
+		TEST_CASE_ST(timdev_setup_msec_periodic, timdev_teardown,
+				test_timer_arm_periodic),
 		TEST_CASE_ST(timdev_setup_usec, timdev_teardown,
 				test_timer_arm_burst),
+		TEST_CASE_ST(timdev_setup_msec_periodic, timdev_teardown,
+				test_timer_arm_burst_periodic),
 		TEST_CASE_ST(timdev_setup_sec, timdev_teardown,
 				test_timer_cancel),
+		TEST_CASE_ST(timdev_setup_sec_periodic, timdev_teardown,
+				test_timer_cancel_periodic),
 		TEST_CASE_ST(timdev_setup_sec, timdev_teardown,
 				test_timer_cancel_random),
 		TEST_CASE_ST(timdev_setup_usec_multicore, timdev_teardown,
-- 
2.25.1


^ permalink raw reply	[flat|nested] 23+ messages in thread

* [dpdk-dev] [PATCH 3/3] event/octeontx2: add timer periodic mode support
  2021-03-08 20:45 [dpdk-dev] [PATCH 0/3] periodic mode for event timer adapter Shijith Thotton
  2021-03-08 20:45 ` [dpdk-dev] [PATCH 1/3] eventdev: introduce adapter flags for periodic mode Shijith Thotton
  2021-03-08 20:45 ` [dpdk-dev] [PATCH 2/3] test/event: add unit tests for periodic timer Shijith Thotton
@ 2021-03-08 20:45 ` Shijith Thotton
  2021-03-14 16:45 ` [dpdk-dev] [PATCH v2 0/3] periodic mode for event timer adapter Shijith Thotton
  3 siblings, 0 replies; 23+ messages in thread
From: Shijith Thotton @ 2021-03-08 20:45 UTC (permalink / raw)
  To: Erik Gabriel Carrillo; +Cc: Shijith Thotton, Pavan Nikhilesh, Jerin Jacob, dev

Add support for periodic mode in event timer adapter.

Signed-off-by: Shijith Thotton <sthotton@marvell.com>
---
 drivers/event/octeontx2/otx2_tim_evdev.c | 29 ++++++++++++++++++++----
 drivers/event/octeontx2/otx2_tim_evdev.h |  1 +
 2 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/drivers/event/octeontx2/otx2_tim_evdev.c b/drivers/event/octeontx2/otx2_tim_evdev.c
index 4c24cc8a6..39a29f17f 100644
--- a/drivers/event/octeontx2/otx2_tim_evdev.c
+++ b/drivers/event/octeontx2/otx2_tim_evdev.c
@@ -65,7 +65,8 @@ otx2_tim_ring_info_get(const struct rte_event_timer_adapter *adptr,
 	struct otx2_tim_ring *tim_ring = adptr->data->adapter_priv;
 
 	adptr_info->max_tmo_ns = tim_ring->max_tout;
-	adptr_info->min_resolution_ns = tim_ring->tck_nsec;
+	adptr_info->min_resolution_ns = tim_ring->ena_periodic ?
+		tim_ring->max_tout : tim_ring->tck_nsec;
 	rte_memcpy(&adptr_info->conf, &adptr->data->conf,
 		   sizeof(struct rte_event_timer_adapter_conf));
 }
@@ -163,7 +164,7 @@ tim_chnk_pool_create(struct otx2_tim_ring *tim_ring,
 		}
 		tim_ring->aura = npa_lf_aura_handle_to_aura(
 				tim_ring->chunk_pool->pool_id);
-		tim_ring->ena_dfb = 0;
+		tim_ring->ena_dfb = tim_ring->ena_periodic ? 1 : 0;
 	} else {
 		tim_ring->chunk_pool = rte_mempool_create(pool_name,
 				tim_ring->nb_chunks, tim_ring->chunk_sz,
@@ -254,6 +255,7 @@ otx2_tim_ring_create(struct rte_event_timer_adapter *adptr)
 	struct tim_ring_req *free_req;
 	struct tim_lf_alloc_req *req;
 	struct tim_lf_alloc_rsp *rsp;
+	uint8_t is_periodic;
 	int i, rc;
 
 	if (dev == NULL)
@@ -284,6 +286,20 @@ otx2_tim_ring_create(struct rte_event_timer_adapter *adptr)
 		}
 	}
 
+	is_periodic = 0;
+	if (rcfg->flags & RTE_EVENT_TIMER_ADAPTER_F_PERIODIC) {
+		if (rcfg->max_tmo_ns &&
+		    rcfg->max_tmo_ns != rcfg->timer_tick_ns) {
+			rc = -ERANGE;
+			goto rng_mem_err;
+		}
+
+		/* Use 2 buckets to avoid contention */
+		rcfg->max_tmo_ns = rcfg->timer_tick_ns;
+		rcfg->timer_tick_ns /= 2;
+		is_periodic = 1;
+	}
+
 	tim_ring = rte_zmalloc("otx2_tim_prv", sizeof(struct otx2_tim_ring), 0);
 	if (tim_ring == NULL) {
 		rc =  -ENOMEM;
@@ -296,11 +312,13 @@ otx2_tim_ring_create(struct rte_event_timer_adapter *adptr)
 	tim_ring->clk_src = (int)rcfg->clk_src;
 	tim_ring->ring_id = adptr->data->id;
 	tim_ring->tck_nsec = RTE_ALIGN_MUL_CEIL(rcfg->timer_tick_ns, 10);
-	tim_ring->max_tout = rcfg->max_tmo_ns;
+	tim_ring->max_tout = is_periodic ?
+		rcfg->timer_tick_ns * 2 : rcfg->max_tmo_ns;
 	tim_ring->nb_bkts = (tim_ring->max_tout / tim_ring->tck_nsec);
 	tim_ring->chunk_sz = dev->chunk_sz;
 	tim_ring->nb_timers = rcfg->nb_timers;
 	tim_ring->disable_npa = dev->disable_npa;
+	tim_ring->ena_periodic = is_periodic;
 	tim_ring->enable_stats = dev->enable_stats;
 
 	for (i = 0; i < dev->ring_ctl_cnt ; i++) {
@@ -348,7 +366,7 @@ otx2_tim_ring_create(struct rte_event_timer_adapter *adptr)
 	cfg_req->ring = tim_ring->ring_id;
 	cfg_req->bigendian = false;
 	cfg_req->clocksource = tim_ring->clk_src;
-	cfg_req->enableperiodic = false;
+	cfg_req->enableperiodic = tim_ring->ena_periodic;
 	cfg_req->enabledontfreebuffer = tim_ring->ena_dfb;
 	cfg_req->bucketsize = tim_ring->nb_bkts;
 	cfg_req->chunksize = tim_ring->chunk_sz;
@@ -568,7 +586,8 @@ otx2_tim_caps_get(const struct rte_eventdev *evdev, uint64_t flags,
 
 	/* Store evdev pointer for later use. */
 	dev->event_dev = (struct rte_eventdev *)(uintptr_t)evdev;
-	*caps = RTE_EVENT_TIMER_ADAPTER_CAP_INTERNAL_PORT;
+	*caps = RTE_EVENT_TIMER_ADAPTER_CAP_INTERNAL_PORT |
+		RTE_EVENT_TIMER_ADAPTER_CAP_PERIODIC;
 	*ops = &otx2_tim_ops;
 
 	return 0;
diff --git a/drivers/event/octeontx2/otx2_tim_evdev.h b/drivers/event/octeontx2/otx2_tim_evdev.h
index 44e3c7b51..82d116c09 100644
--- a/drivers/event/octeontx2/otx2_tim_evdev.h
+++ b/drivers/event/octeontx2/otx2_tim_evdev.h
@@ -155,6 +155,7 @@ struct otx2_tim_ring {
 	uint8_t disable_npa;
 	uint8_t optimized;
 	uint8_t ena_dfb;
+	uint8_t ena_periodic;
 	uint16_t ring_id;
 	uint32_t aura;
 	uint64_t nb_timers;
-- 
2.25.1


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [dpdk-dev] [PATCH 1/3] eventdev: introduce adapter flags for periodic mode
  2021-03-08 20:45 ` [dpdk-dev] [PATCH 1/3] eventdev: introduce adapter flags for periodic mode Shijith Thotton
@ 2021-03-09 20:04   ` Carrillo, Erik G
  2021-03-10  9:14     ` Shijith Thotton
  2021-03-12 15:30   ` Carrillo, Erik G
  1 sibling, 1 reply; 23+ messages in thread
From: Carrillo, Erik G @ 2021-03-09 20:04 UTC (permalink / raw)
  To: Shijith Thotton; +Cc: Pavan Nikhilesh, Jerin Jacob, dev

Hi Shijith,

Please see a question in-line:

> -----Original Message-----
> From: Shijith Thotton <sthotton@marvell.com>
> Sent: Monday, March 8, 2021 2:46 PM
> To: Carrillo, Erik G <erik.g.carrillo@intel.com>
> Cc: Shijith Thotton <sthotton@marvell.com>; Pavan Nikhilesh
> <pbhagavatula@marvell.com>; Jerin Jacob <jerinj@marvell.com>;
> dev@dpdk.org
> Subject: [PATCH 1/3] eventdev: introduce adapter flags for periodic mode
> 
> A timer adapter in periodic mode can be used to arm periodic timers.
> This patch adds flags used to advertise capability and configure timer adapter
> in periodic mode. Capability flag should be set for adapters which support
> periodic mode.
> 
> Below is a programming sequence on the usage:
> 	/* check for periodic mode support by reading capability. */
> 	rte_event_timer_adapter_caps_get(...);
> 
> 	/* create adapter in periodic mode by setting periodic flag
> 	   (RTE_EVENT_TIMER_ADAPTER_F_PERIODIC) and resolution. */
> 	rte_event_timer_adapter_create_ext(...);

It looks like periodic support is an operating mode of the adapter itself, and that all timers created with a periodic adapter instance will be periodic timers.

Is it possible to instead have "periodic/single-shot" be an attribute of an event timer itself, such that a single adapter instance could support either type of timer?

Thanks,
Erik

> 
> 	/* arm periodic timer of configured resolution */
> 	rte_event_timer_arm_burst(...);
> 
> 	/* timer event will be periodically generated at configured
> 	   resolution till cancel is called. */
> 	while (running) { rte_event_dequeue_burst(...); }
> 
> 	/* cancel periodic timer which stops generating events */
> 	rte_event_timer_cancel_burst(...);
> 
> Signed-off-by: Shijith Thotton <sthotton@marvell.com>
> ---


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [dpdk-dev] [PATCH 1/3] eventdev: introduce adapter flags for periodic mode
  2021-03-09 20:04   ` Carrillo, Erik G
@ 2021-03-10  9:14     ` Shijith Thotton
  2021-03-11 20:47       ` Carrillo, Erik G
  0 siblings, 1 reply; 23+ messages in thread
From: Shijith Thotton @ 2021-03-10  9:14 UTC (permalink / raw)
  To: Carrillo, Erik G; +Cc: Shijith Thotton, Pavan Nikhilesh, Jerin Jacob, dev

Hi Erik,

On Tue, Mar 09, 2021 at 08:04:32PM +0000, Carrillo, Erik G wrote:
> > A timer adapter in periodic mode can be used to arm periodic timers.
> > This patch adds flags used to advertise capability and configure timer adapter
> > in periodic mode. Capability flag should be set for adapters which support
> > periodic mode.
> > 
> > Below is a programming sequence on the usage:
> > 	/* check for periodic mode support by reading capability. */
> > 	rte_event_timer_adapter_caps_get(...);
> > 
> > 	/* create adapter in periodic mode by setting periodic flag
> > 	   (RTE_EVENT_TIMER_ADAPTER_F_PERIODIC) and resolution. */
> > 	rte_event_timer_adapter_create_ext(...);
> 
> It looks like periodic support is an operating mode of the adapter itself, and
> that all timers created with a periodic adapter instance will be periodic
> timers.
> 
> Is it possible to instead have "periodic/single-shot" be an attribute of an
> event timer itself, such that a single adapter instance could support either
> type of timer?
> 

With single type of timer per adapter, application can decide to create multiple
adapters of required type/mode and use as needed.

For an adapter to support both type of timers, driver ops implementation has to
follow different paths based on timer type and new capability flag should be
introduced to expose this feature. Our HW only supports single type of timer per
adapter.

Please let me know the approach you are aligned with.

Thanks,
Shijith

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [dpdk-dev] [PATCH 1/3] eventdev: introduce adapter flags for periodic mode
  2021-03-10  9:14     ` Shijith Thotton
@ 2021-03-11 20:47       ` Carrillo, Erik G
  0 siblings, 0 replies; 23+ messages in thread
From: Carrillo, Erik G @ 2021-03-11 20:47 UTC (permalink / raw)
  To: Shijith Thotton; +Cc: Shijith Thotton, Pavan Nikhilesh, Jerin Jacob, dev

Hi Shijith,

> -----Original Message-----
> From: Shijith Thotton <shijith.thotton@gmail.com>
> Sent: Wednesday, March 10, 2021 3:15 AM
> To: Carrillo, Erik G <erik.g.carrillo@intel.com>
> Cc: Shijith Thotton <sthotton@marvell.com>; Pavan Nikhilesh
> <pbhagavatula@marvell.com>; Jerin Jacob <jerinj@marvell.com>;
> dev@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH 1/3] eventdev: introduce adapter flags for
> periodic mode
> 
> Hi Erik,
> 
> On Tue, Mar 09, 2021 at 08:04:32PM +0000, Carrillo, Erik G wrote:
> > > A timer adapter in periodic mode can be used to arm periodic timers.
> > > This patch adds flags used to advertise capability and configure
> > > timer adapter in periodic mode. Capability flag should be set for
> > > adapters which support periodic mode.
> > >
> > > Below is a programming sequence on the usage:
> > > 	/* check for periodic mode support by reading capability. */
> > > 	rte_event_timer_adapter_caps_get(...);
> > >
> > > 	/* create adapter in periodic mode by setting periodic flag
> > > 	   (RTE_EVENT_TIMER_ADAPTER_F_PERIODIC) and resolution. */
> > > 	rte_event_timer_adapter_create_ext(...);
> >
> > It looks like periodic support is an operating mode of the adapter
> > itself, and that all timers created with a periodic adapter instance
> > will be periodic timers.
> >
> > Is it possible to instead have "periodic/single-shot" be an attribute
> > of an event timer itself, such that a single adapter instance could
> > support either type of timer?
> >
> 
> With single type of timer per adapter, application can decide to create
> multiple adapters of required type/mode and use as needed.
> 
> For an adapter to support both type of timers, driver ops implementation has
> to follow different paths based on timer type and new capability flag should
> be introduced to expose this feature. Our HW only supports single type of
> timer per adapter.
> 
> Please let me know the approach you are aligned with.

Having a single type of timer per adapter is surprising initially, in my opinion,
but I think it does make using periodic timers simple.  Unless there are any
other comments to the contrary, I think we can proceed with this approach.

I'll respond in a separate post with comments on the patches.

Thanks,
Erik

> 
> Thanks,
> Shijith

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [dpdk-dev] [PATCH 1/3] eventdev: introduce adapter flags for periodic mode
  2021-03-08 20:45 ` [dpdk-dev] [PATCH 1/3] eventdev: introduce adapter flags for periodic mode Shijith Thotton
  2021-03-09 20:04   ` Carrillo, Erik G
@ 2021-03-12 15:30   ` Carrillo, Erik G
  2021-03-14 16:49     ` Shijith Thotton
  1 sibling, 1 reply; 23+ messages in thread
From: Carrillo, Erik G @ 2021-03-12 15:30 UTC (permalink / raw)
  To: Shijith Thotton; +Cc: Pavan Nikhilesh, Jerin Jacob, dev

Hi Shijith,

Some comments in-line:

> -----Original Message-----
> From: Shijith Thotton <sthotton@marvell.com>
> Sent: Monday, March 8, 2021 2:46 PM
> To: Carrillo, Erik G <erik.g.carrillo@intel.com>
> Cc: Shijith Thotton <sthotton@marvell.com>; Pavan Nikhilesh
> <pbhagavatula@marvell.com>; Jerin Jacob <jerinj@marvell.com>;
> dev@dpdk.org
> Subject: [PATCH 1/3] eventdev: introduce adapter flags for periodic mode
> 
> A timer adapter in periodic mode can be used to arm periodic timers.
> This patch adds flags used to advertise capability and configure timer adapter
> in periodic mode. Capability flag should be set for adapters which support
> periodic mode.
> 
> Below is a programming sequence on the usage:
> 	/* check for periodic mode support by reading capability. */
> 	rte_event_timer_adapter_caps_get(...);
> 
> 	/* create adapter in periodic mode by setting periodic flag
> 	   (RTE_EVENT_TIMER_ADAPTER_F_PERIODIC) and resolution. */
> 	rte_event_timer_adapter_create_ext(...);
> 
> 	/* arm periodic timer of configured resolution */
> 	rte_event_timer_arm_burst(...);
> 
> 	/* timer event will be periodically generated at configured
> 	   resolution till cancel is called. */
> 	while (running) { rte_event_dequeue_burst(...); }
> 
> 	/* cancel periodic timer which stops generating events */
> 	rte_event_timer_cancel_burst(...);
> 
> Signed-off-by: Shijith Thotton <sthotton@marvell.com>
> ---
>  doc/guides/prog_guide/event_timer_adapter.rst | 33
> +++++++++++++++++++  lib/librte_eventdev/rte_event_timer_adapter.h |
> 6 ++++
>  lib/librte_eventdev/rte_eventdev.h            |  3 ++
>  3 files changed, 42 insertions(+)
> 
> diff --git a/doc/guides/prog_guide/event_timer_adapter.rst
> b/doc/guides/prog_guide/event_timer_adapter.rst
> index a95efbe0d..fcdecdb3b 100644
> --- a/doc/guides/prog_guide/event_timer_adapter.rst
> +++ b/doc/guides/prog_guide/event_timer_adapter.rst
> @@ -252,6 +252,39 @@ be canceled by calling
> ``rte_event_timer_cancel_burst()``:
>           */
>  	rte_event_timer_cancel_burst(adapter, &conn->timer, 1);
> 
> +Timer adapter in periodic mode
> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> +
> +A periodic timer is a timer, which expires at fixed time intervals
> +continuously till it is cancelled.  A timer adapter can be configured
> +to arm such timers by configuring it in periodic mode.  Capability flag
> +``RTE_EVENT_TIMER_ADAPTER_CAP_PERIODIC`` can be used to check if an
> +adapter supports periodic mode. An adapter in periodic mode can only be
> +used to arm periodic timers.
> +
> +Example config to create an adapter in periodic mode with 100ms
> resolution:
> +
> +.. code-block:: c
> +
> +	#define NSECPERSEC 1E9 // No of ns in 1 sec
> +	const struct rte_event_timer_adapter_conf adapter_config = {
> +                .event_dev_id = event_dev_id,
> +                .timer_adapter_id = 0,
> +                .clk_src = RTE_EVENT_TIMER_ADAPTER_CPU_CLK,
> +                .timer_tick_ns = NSECPERSEC / 10, // 100 milliseconds
> +                .nb_timers = 100,
> +                .timer_adapter_flags = RTE_EVENT_TIMER_ADAPTER_F_PERIODIC,
> +	};
> +
> +``timer_adapter_flags`` is set to include periodic flag
> +``RTE_EVENT_TIMER_ADAPTER_F_PERIODIC`` and ``timer_tick_ns`` to
> resolution.
> +Maximum timeout (``max_tmo_nsec``) does not apply for periodic mode.

This content can be reworked slightly and moved into the "Create and Configure an Adapter Instance" section, perhaps as a subsection describing the two adapter modes.

> +
> +After starting the adapter, event timer arm APIs can be used to arm
> +periodic timers.  Timer events will be generated at configured
> +``timer_tick_ns`` intervals.  Event generation can be stopped using
> +cancel API ``rte_event_timer_cancel_burst``.
> +

I think this content should be worked into the "Arming Event Timers" section, indicating how the timer behavior depends on the mode of the adapter that specified in the arm call.

>  Processing Timer Expiry Events
>  ------------------------------
> 
> diff --git a/lib/librte_eventdev/rte_event_timer_adapter.h
> b/lib/librte_eventdev/rte_event_timer_adapter.h
> index d2ebcb090..f9fc95711 100644
> --- a/lib/librte_eventdev/rte_event_timer_adapter.h
> +++ b/lib/librte_eventdev/rte_event_timer_adapter.h

I think we should also update the doxygen documentation for the rte_event_timer_arm_burst to indicate that timer expiry events will be generated once or periodically until the timer is stopped based on the mode of the adapter that is specified.  We can have a "see also" for the RTE_EVENT_TIMER_ADAPTER_F_PERIODIC flag.

Thanks,
Erik

> @@ -151,6 +151,12 @@ enum rte_event_timer_adapter_clk_src {
>   * @see struct rte_event_timer_adapter_conf::flags
>   */
> 
> +#define RTE_EVENT_TIMER_ADAPTER_F_PERIODIC	(1ULL << 2)
> +/**< Flag to configure event timer adapter in periodic mode.
> + *
> + * @see struct rte_event_timer_adapter_conf::flags
> + */
> +
>  /**
>   * Timer adapter configuration structure
>   */


^ permalink raw reply	[flat|nested] 23+ messages in thread

* [dpdk-dev] [PATCH v2 0/3] periodic mode for event timer adapter
  2021-03-08 20:45 [dpdk-dev] [PATCH 0/3] periodic mode for event timer adapter Shijith Thotton
                   ` (2 preceding siblings ...)
  2021-03-08 20:45 ` [dpdk-dev] [PATCH 3/3] event/octeontx2: add timer periodic mode support Shijith Thotton
@ 2021-03-14 16:45 ` Shijith Thotton
  2021-03-14 16:45   ` [dpdk-dev] [PATCH v2 1/3] eventdev: introduce adapter flags for periodic mode Shijith Thotton
                     ` (3 more replies)
  3 siblings, 4 replies; 23+ messages in thread
From: Shijith Thotton @ 2021-03-14 16:45 UTC (permalink / raw)
  To: Erik Gabriel Carrillo; +Cc: Shijith Thotton, Pavan Nikhilesh, Jerin Jacob, dev

Arming periodic timers are not supported by the event timer adapter
right now. This series adds that support. A timer adapter configured in
periodic mode can be used to arm periodic timers. 

First patch adds a flag to expose periodic mode capability of an adapter
and flag to configure the adapter in periodic mode. Second one adds unit
tests for periodic mode. Third one is a hardware implementation of the
feature.

Shijith Thotton (3):
  eventdev: introduce adapter flags for periodic mode
  test/event: add unit tests for periodic timer
  event/octeontx2: add timer periodic mode support

---
v2: Updated rst and doxygen documentation.

 app/test/test_event_timer_adapter.c           | 136 ++++++++++++++++--
 doc/guides/prog_guide/event_timer_adapter.rst |  15 +-
 drivers/event/octeontx2/otx2_tim_evdev.c      |  29 +++-
 drivers/event/octeontx2/otx2_tim_evdev.h      |   1 +
 lib/librte_eventdev/rte_event_timer_adapter.h |  11 ++
 lib/librte_eventdev/rte_eventdev.h            |   3 +
 6 files changed, 176 insertions(+), 19 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 23+ messages in thread

* [dpdk-dev] [PATCH v2 1/3] eventdev: introduce adapter flags for periodic mode
  2021-03-14 16:45 ` [dpdk-dev] [PATCH v2 0/3] periodic mode for event timer adapter Shijith Thotton
@ 2021-03-14 16:45   ` Shijith Thotton
  2021-03-16 19:04     ` Carrillo, Erik G
  2021-03-14 16:45   ` [dpdk-dev] [PATCH v2 2/3] test/event: add unit tests for periodic timer Shijith Thotton
                     ` (2 subsequent siblings)
  3 siblings, 1 reply; 23+ messages in thread
From: Shijith Thotton @ 2021-03-14 16:45 UTC (permalink / raw)
  To: Erik Gabriel Carrillo; +Cc: Shijith Thotton, Pavan Nikhilesh, Jerin Jacob, dev

A timer adapter in periodic mode can be used to arm periodic timers.
This patch adds flags used to advertise capability and configure timer
adapter in periodic mode. Capability flag should be set for adapters
which support periodic mode.

Below is a programming sequence on the usage:
	/* check for periodic mode support by reading capability. */
	rte_event_timer_adapter_caps_get(...);

	/* create adapter in periodic mode by setting periodic flag
	   (RTE_EVENT_TIMER_ADAPTER_F_PERIODIC) and resolution. */
	rte_event_timer_adapter_create_ext(...);

	/* arm periodic timer of configured resolution */
	rte_event_timer_arm_burst(...);

	/* timer event will be periodically generated at configured
	   resolution till cancel is called. */
	while (running) { rte_event_dequeue_burst(...); }

	/* cancel periodic timer which stops generating events */
	rte_event_timer_cancel_burst(...);

Signed-off-by: Shijith Thotton <sthotton@marvell.com>
---
 doc/guides/prog_guide/event_timer_adapter.rst | 15 ++++++++++++++-
 lib/librte_eventdev/rte_event_timer_adapter.h | 11 +++++++++++
 lib/librte_eventdev/rte_eventdev.h            |  3 +++
 3 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/doc/guides/prog_guide/event_timer_adapter.rst b/doc/guides/prog_guide/event_timer_adapter.rst
index a95efbe0d..0b2add6f7 100644
--- a/doc/guides/prog_guide/event_timer_adapter.rst
+++ b/doc/guides/prog_guide/event_timer_adapter.rst
@@ -138,6 +138,17 @@ This function is passed a callback function that will be invoked if the
 adapter needs to create an event port, giving the application the opportunity
 to control how it is done.
 
+Adapter modes
+^^^^^^^^^^^^^
+An event timer adapter can be configured in either periodic or non-periodic mode
+to support timers of respective type. A periodic timer expires at a fixed time
+interval repeatedly till it is cancelled. A non-periodic timer expires only
+once. Periodic capability flag ``RTE_EVENT_TIMER_ADAPTER_CAP_PERIODIC`` is set
+for adapters which support periodic mode. To configure an adapter in periodic
+mode, ``timer_adapter_flags`` of ``rte_event_timer_adapter_conf`` is set to
+include periodic flag ``RTE_EVENT_TIMER_ADAPTER_F_PERIODIC``. Maximum timeout
+(``max_tmo_nsec``) does not apply for periodic mode.
+
 Retrieve Event Timer Adapter Contextual Information
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 The event timer adapter implementation may have constraints on tick resolution
@@ -229,7 +240,9 @@ Now we can arm the event timer with ``rte_event_timer_arm_burst()``:
 
 Once an event timer expires, the application may free it or rearm it as
 necessary.  If the application will rearm the timer, the state should be reset
-to RTE_EVENT_TIMER_NOT_ARMED by the application before rearming it.
+to RTE_EVENT_TIMER_NOT_ARMED by the application before rearming it. Timer expiry
+events will be generated once or periodically until the timer is cancelled based
+on adapter mode.
 
 Multiple Event Timers with Same Expiry Value
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/lib/librte_eventdev/rte_event_timer_adapter.h b/lib/librte_eventdev/rte_event_timer_adapter.h
index d2ebcb090..b34dc1385 100644
--- a/lib/librte_eventdev/rte_event_timer_adapter.h
+++ b/lib/librte_eventdev/rte_event_timer_adapter.h
@@ -151,6 +151,12 @@ enum rte_event_timer_adapter_clk_src {
  * @see struct rte_event_timer_adapter_conf::flags
  */
 
+#define RTE_EVENT_TIMER_ADAPTER_F_PERIODIC	(1ULL << 2)
+/**< Flag to configure event timer adapter in periodic mode.
+ *
+ * @see struct rte_event_timer_adapter_conf::flags
+ */
+
 /**
  * Timer adapter configuration structure
  */
@@ -551,6 +557,8 @@ struct rte_event_timer_adapter {
  * expiry event attributes, timeout ticks from now.
  * This function submits the event timer arm requests to the event timer adapter
  * and on expiry, the events will be injected to designated event queue.
+ * Timer expiry events will be generated once or periodically until cancellation
+ * based on the adapter mode.
  *
  * @param adapter
  *   A pointer to an event timer adapter structure.
@@ -570,6 +578,9 @@ struct rte_event_timer_adapter {
  *   destination event queue.
  *   - EAGAIN Specified timer adapter is not running
  *   - EALREADY A timer was encountered that was already armed
+ *
+ * @see RTE_EVENT_TIMER_ADAPTER_F_PERIODIC
+ *
  */
 static inline uint16_t
 rte_event_timer_arm_burst(const struct rte_event_timer_adapter *adapter,
diff --git a/lib/librte_eventdev/rte_eventdev.h b/lib/librte_eventdev/rte_eventdev.h
index ce1fc2ce0..9fc39e9ca 100644
--- a/lib/librte_eventdev/rte_eventdev.h
+++ b/lib/librte_eventdev/rte_eventdev.h
@@ -1154,6 +1154,9 @@ rte_event_eth_rx_adapter_caps_get(uint8_t dev_id, uint16_t eth_port_id,
 #define RTE_EVENT_TIMER_ADAPTER_CAP_INTERNAL_PORT (1ULL << 0)
 /**< This flag is set when the timer mechanism is in HW. */
 
+#define RTE_EVENT_TIMER_ADAPTER_CAP_PERIODIC      (1ULL << 1)
+/**< This flag is set if periodic mode is supported. */
+
 /**
  * Retrieve the event device's timer adapter capabilities.
  *
-- 
2.25.1


^ permalink raw reply	[flat|nested] 23+ messages in thread

* [dpdk-dev] [PATCH v2 2/3] test/event: add unit tests for periodic timer
  2021-03-14 16:45 ` [dpdk-dev] [PATCH v2 0/3] periodic mode for event timer adapter Shijith Thotton
  2021-03-14 16:45   ` [dpdk-dev] [PATCH v2 1/3] eventdev: introduce adapter flags for periodic mode Shijith Thotton
@ 2021-03-14 16:45   ` Shijith Thotton
  2021-03-14 16:45   ` [dpdk-dev] [PATCH v2 3/3] event/octeontx2: add timer periodic mode support Shijith Thotton
  2021-03-17  8:04   ` [dpdk-dev] [PATCH v3 0/3] periodic mode for event timer adapter Shijith Thotton
  3 siblings, 0 replies; 23+ messages in thread
From: Shijith Thotton @ 2021-03-14 16:45 UTC (permalink / raw)
  To: Erik Gabriel Carrillo; +Cc: Shijith Thotton, Pavan Nikhilesh, Jerin Jacob, dev

Add tests to arm and cancel periodic timer.

Signed-off-by: Shijith Thotton <sthotton@marvell.com>
---
 app/test/test_event_timer_adapter.c | 136 +++++++++++++++++++++++++---
 1 file changed, 123 insertions(+), 13 deletions(-)

diff --git a/app/test/test_event_timer_adapter.c b/app/test/test_event_timer_adapter.c
index b536ddef4..20be46da3 100644
--- a/app/test/test_event_timer_adapter.c
+++ b/app/test/test_event_timer_adapter.c
@@ -283,7 +283,7 @@ test_port_conf_cb(uint16_t id, uint8_t event_dev_id, uint8_t *event_port_id,
 }
 
 static int
-_timdev_setup(uint64_t max_tmo_ns, uint64_t bkt_tck_ns)
+_timdev_setup(uint64_t max_tmo_ns, uint64_t bkt_tck_ns, uint64_t flags)
 {
 	struct rte_event_timer_adapter_info info;
 	struct rte_event_timer_adapter_conf config = {
@@ -292,7 +292,7 @@ _timdev_setup(uint64_t max_tmo_ns, uint64_t bkt_tck_ns)
 		.timer_tick_ns = bkt_tck_ns,
 		.max_tmo_ns = max_tmo_ns,
 		.nb_timers = MAX_TIMERS * 10,
-		.flags = RTE_EVENT_TIMER_ADAPTER_F_ADJUST_RES,
+		.flags = flags,
 	};
 	uint32_t caps = 0;
 	const char *pool_name = "timdev_test_pool";
@@ -301,6 +301,13 @@ _timdev_setup(uint64_t max_tmo_ns, uint64_t bkt_tck_ns)
 
 	TEST_ASSERT_SUCCESS(rte_event_timer_adapter_caps_get(evdev, &caps),
 				"failed to get adapter capabilities");
+
+	if (flags & RTE_EVENT_TIMER_ADAPTER_F_PERIODIC &&
+	    !(caps & RTE_EVENT_TIMER_ADAPTER_CAP_PERIODIC)) {
+		printf("Adapter does not support periodic timers\n");
+		return TEST_SKIPPED;
+	}
+
 	if (!(caps & RTE_EVENT_TIMER_ADAPTER_CAP_INTERNAL_PORT)) {
 		timdev = rte_event_timer_adapter_create_ext(&config,
 							    test_port_conf_cb,
@@ -338,42 +345,72 @@ _timdev_setup(uint64_t max_tmo_ns, uint64_t bkt_tck_ns)
 static int
 timdev_setup_usec(void)
 {
+	uint64_t flags = RTE_EVENT_TIMER_ADAPTER_F_ADJUST_RES;
+
 	return using_services ?
 		/* Max timeout is 10,000us and bucket interval is 100us */
-		_timdev_setup(1E7, 1E5) :
+		_timdev_setup(1E7, 1E5, flags) :
 		/* Max timeout is 100us and bucket interval is 1us */
-		_timdev_setup(1E5, 1E3);
+		_timdev_setup(1E5, 1E3, flags);
 }
 
 static int
 timdev_setup_usec_multicore(void)
 {
+	uint64_t flags = RTE_EVENT_TIMER_ADAPTER_F_ADJUST_RES;
+
 	return using_services ?
 		/* Max timeout is 10,000us and bucket interval is 100us */
-		_timdev_setup(1E7, 1E5) :
+		_timdev_setup(1E7, 1E5, flags) :
 		/* Max timeout is 100us and bucket interval is 1us */
-		_timdev_setup(1E5, 1E3);
+		_timdev_setup(1E5, 1E3, flags);
 }
 
 static int
 timdev_setup_msec(void)
 {
-	/* Max timeout is 2 mins, and bucket interval is 100 ms */
-	return _timdev_setup(180 * NSECPERSEC, NSECPERSEC / 10);
+	uint64_t flags = RTE_EVENT_TIMER_ADAPTER_F_ADJUST_RES;
+
+	/* Max timeout is 3 mins, and bucket interval is 100 ms */
+	return _timdev_setup(180 * NSECPERSEC, NSECPERSEC / 10, flags);
+}
+
+static int
+timdev_setup_msec_periodic(void)
+{
+	uint64_t flags = RTE_EVENT_TIMER_ADAPTER_F_ADJUST_RES |
+			 RTE_EVENT_TIMER_ADAPTER_F_PERIODIC;
+
+	/* Periodic mode with 100 ms resolution */
+	return _timdev_setup(0, NSECPERSEC / 10, flags);
 }
 
 static int
 timdev_setup_sec(void)
 {
+	uint64_t flags = RTE_EVENT_TIMER_ADAPTER_F_ADJUST_RES;
+
 	/* Max timeout is 100sec and bucket interval is 1sec */
-	return _timdev_setup(1E11, 1E9);
+	return _timdev_setup(1E11, 1E9, flags);
+}
+
+static int
+timdev_setup_sec_periodic(void)
+{
+	uint64_t flags = RTE_EVENT_TIMER_ADAPTER_F_ADJUST_RES |
+			 RTE_EVENT_TIMER_ADAPTER_F_PERIODIC;
+
+	/* Periodic mode with 1 sec resolution */
+	return _timdev_setup(0, NSECPERSEC, flags);
 }
 
 static int
 timdev_setup_sec_multicore(void)
 {
+	uint64_t flags = RTE_EVENT_TIMER_ADAPTER_F_ADJUST_RES;
+
 	/* Max timeout is 100sec and bucket interval is 1sec */
-	return _timdev_setup(1E11, 1E9);
+	return _timdev_setup(1E11, 1E9, flags);
 }
 
 static void
@@ -513,6 +550,18 @@ test_timer_arm(void)
 	return TEST_SUCCESS;
 }
 
+static inline int
+test_timer_arm_periodic(void)
+{
+	TEST_ASSERT_SUCCESS(_arm_timers(1, MAX_TIMERS),
+			    "Failed to arm timers");
+	/* With a resolution of 100ms and wait time of 1sec,
+	 * there will be 10 * MAX_TIMERS periodic timer triggers */
+	TEST_ASSERT_SUCCESS(_wait_timer_triggers(1, 10 * MAX_TIMERS, 0),
+			    "Timer triggered count doesn't match arm count");
+	return TEST_SUCCESS;
+}
+
 static int
 _arm_wrapper(void *arg)
 {
@@ -588,6 +637,19 @@ test_timer_arm_burst(void)
 	return TEST_SUCCESS;
 }
 
+static inline int
+test_timer_arm_burst_periodic(void)
+{
+	TEST_ASSERT_SUCCESS(_arm_timers_burst(1, MAX_TIMERS),
+			    "Failed to arm timers");
+	/* With a resolution of 100ms and wait time of 1sec,
+	 * there will be 10 * MAX_TIMERS periodic timer triggers */
+	TEST_ASSERT_SUCCESS(_wait_timer_triggers(1, 10 * MAX_TIMERS, 0),
+			    "Timer triggered count doesn't match arm count");
+
+	return TEST_SUCCESS;
+}
+
 static int
 _arm_wrapper_burst(void *arg)
 {
@@ -612,6 +674,48 @@ test_timer_arm_burst_multicore(void)
 	return TEST_SUCCESS;
 }
 
+static inline int
+test_timer_cancel_periodic(void)
+{
+	uint64_t i;
+	struct rte_event_timer *ev_tim;
+	const struct rte_event_timer tim = {
+		.ev.op = RTE_EVENT_OP_NEW,
+		.ev.queue_id = 0,
+		.ev.sched_type = RTE_SCHED_TYPE_ATOMIC,
+		.ev.priority = RTE_EVENT_DEV_PRIORITY_NORMAL,
+		.ev.event_type =  RTE_EVENT_TYPE_TIMER,
+		.state = RTE_EVENT_TIMER_NOT_ARMED,
+		.timeout_ticks = CALC_TICKS(1),
+	};
+
+	for (i = 0; i < MAX_TIMERS; i++) {
+		TEST_ASSERT_SUCCESS(rte_mempool_get(eventdev_test_mempool,
+					(void **)&ev_tim),
+				"mempool alloc failed");
+		*ev_tim = tim;
+		ev_tim->ev.event_ptr = ev_tim;
+
+		TEST_ASSERT_EQUAL(rte_event_timer_arm_burst(timdev, &ev_tim,
+					1), 1, "Failed to arm timer %d",
+				rte_errno);
+
+		rte_delay_us(100 + (i % 5000));
+
+		TEST_ASSERT_EQUAL(rte_event_timer_cancel_burst(timdev,
+					&ev_tim, 1), 1,
+				"Failed to cancel event timer %d", rte_errno);
+		rte_mempool_put(eventdev_test_mempool, ev_tim);
+	}
+
+
+	TEST_ASSERT_SUCCESS(_wait_timer_triggers(30, MAX_TIMERS,
+				MAX_TIMERS),
+		"Timer triggered count doesn't match arm, cancel count");
+
+	return TEST_SUCCESS;
+}
+
 static inline int
 test_timer_cancel(void)
 {
@@ -1028,9 +1132,9 @@ adapter_lookup(void)
 static int
 adapter_start(void)
 {
-	TEST_ASSERT_SUCCESS(_timdev_setup(180 * NSECPERSEC,
-			NSECPERSEC / 10),
-			"Failed to start adapter");
+	TEST_ASSERT_SUCCESS(_timdev_setup(180 * NSECPERSEC, NSECPERSEC / 10,
+					  RTE_EVENT_TIMER_ADAPTER_F_ADJUST_RES),
+			    "Failed to start adapter");
 	TEST_ASSERT_EQUAL(rte_event_timer_adapter_start(timdev), -EALREADY,
 			"Timer adapter started without call to stop.");
 
@@ -1786,10 +1890,16 @@ static struct unit_test_suite event_timer_adptr_functional_testsuite  = {
 				test_timer_state),
 		TEST_CASE_ST(timdev_setup_usec, timdev_teardown,
 				test_timer_arm),
+		TEST_CASE_ST(timdev_setup_msec_periodic, timdev_teardown,
+				test_timer_arm_periodic),
 		TEST_CASE_ST(timdev_setup_usec, timdev_teardown,
 				test_timer_arm_burst),
+		TEST_CASE_ST(timdev_setup_msec_periodic, timdev_teardown,
+				test_timer_arm_burst_periodic),
 		TEST_CASE_ST(timdev_setup_sec, timdev_teardown,
 				test_timer_cancel),
+		TEST_CASE_ST(timdev_setup_sec_periodic, timdev_teardown,
+				test_timer_cancel_periodic),
 		TEST_CASE_ST(timdev_setup_sec, timdev_teardown,
 				test_timer_cancel_random),
 		TEST_CASE_ST(timdev_setup_usec_multicore, timdev_teardown,
-- 
2.25.1


^ permalink raw reply	[flat|nested] 23+ messages in thread

* [dpdk-dev] [PATCH v2 3/3] event/octeontx2: add timer periodic mode support
  2021-03-14 16:45 ` [dpdk-dev] [PATCH v2 0/3] periodic mode for event timer adapter Shijith Thotton
  2021-03-14 16:45   ` [dpdk-dev] [PATCH v2 1/3] eventdev: introduce adapter flags for periodic mode Shijith Thotton
  2021-03-14 16:45   ` [dpdk-dev] [PATCH v2 2/3] test/event: add unit tests for periodic timer Shijith Thotton
@ 2021-03-14 16:45   ` Shijith Thotton
  2021-03-17  8:04   ` [dpdk-dev] [PATCH v3 0/3] periodic mode for event timer adapter Shijith Thotton
  3 siblings, 0 replies; 23+ messages in thread
From: Shijith Thotton @ 2021-03-14 16:45 UTC (permalink / raw)
  To: Erik Gabriel Carrillo; +Cc: Shijith Thotton, Pavan Nikhilesh, Jerin Jacob, dev

Add support for periodic mode in event timer adapter.

Signed-off-by: Shijith Thotton <sthotton@marvell.com>
---
 drivers/event/octeontx2/otx2_tim_evdev.c | 29 ++++++++++++++++++++----
 drivers/event/octeontx2/otx2_tim_evdev.h |  1 +
 2 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/drivers/event/octeontx2/otx2_tim_evdev.c b/drivers/event/octeontx2/otx2_tim_evdev.c
index 4c24cc8a6..39a29f17f 100644
--- a/drivers/event/octeontx2/otx2_tim_evdev.c
+++ b/drivers/event/octeontx2/otx2_tim_evdev.c
@@ -65,7 +65,8 @@ otx2_tim_ring_info_get(const struct rte_event_timer_adapter *adptr,
 	struct otx2_tim_ring *tim_ring = adptr->data->adapter_priv;
 
 	adptr_info->max_tmo_ns = tim_ring->max_tout;
-	adptr_info->min_resolution_ns = tim_ring->tck_nsec;
+	adptr_info->min_resolution_ns = tim_ring->ena_periodic ?
+		tim_ring->max_tout : tim_ring->tck_nsec;
 	rte_memcpy(&adptr_info->conf, &adptr->data->conf,
 		   sizeof(struct rte_event_timer_adapter_conf));
 }
@@ -163,7 +164,7 @@ tim_chnk_pool_create(struct otx2_tim_ring *tim_ring,
 		}
 		tim_ring->aura = npa_lf_aura_handle_to_aura(
 				tim_ring->chunk_pool->pool_id);
-		tim_ring->ena_dfb = 0;
+		tim_ring->ena_dfb = tim_ring->ena_periodic ? 1 : 0;
 	} else {
 		tim_ring->chunk_pool = rte_mempool_create(pool_name,
 				tim_ring->nb_chunks, tim_ring->chunk_sz,
@@ -254,6 +255,7 @@ otx2_tim_ring_create(struct rte_event_timer_adapter *adptr)
 	struct tim_ring_req *free_req;
 	struct tim_lf_alloc_req *req;
 	struct tim_lf_alloc_rsp *rsp;
+	uint8_t is_periodic;
 	int i, rc;
 
 	if (dev == NULL)
@@ -284,6 +286,20 @@ otx2_tim_ring_create(struct rte_event_timer_adapter *adptr)
 		}
 	}
 
+	is_periodic = 0;
+	if (rcfg->flags & RTE_EVENT_TIMER_ADAPTER_F_PERIODIC) {
+		if (rcfg->max_tmo_ns &&
+		    rcfg->max_tmo_ns != rcfg->timer_tick_ns) {
+			rc = -ERANGE;
+			goto rng_mem_err;
+		}
+
+		/* Use 2 buckets to avoid contention */
+		rcfg->max_tmo_ns = rcfg->timer_tick_ns;
+		rcfg->timer_tick_ns /= 2;
+		is_periodic = 1;
+	}
+
 	tim_ring = rte_zmalloc("otx2_tim_prv", sizeof(struct otx2_tim_ring), 0);
 	if (tim_ring == NULL) {
 		rc =  -ENOMEM;
@@ -296,11 +312,13 @@ otx2_tim_ring_create(struct rte_event_timer_adapter *adptr)
 	tim_ring->clk_src = (int)rcfg->clk_src;
 	tim_ring->ring_id = adptr->data->id;
 	tim_ring->tck_nsec = RTE_ALIGN_MUL_CEIL(rcfg->timer_tick_ns, 10);
-	tim_ring->max_tout = rcfg->max_tmo_ns;
+	tim_ring->max_tout = is_periodic ?
+		rcfg->timer_tick_ns * 2 : rcfg->max_tmo_ns;
 	tim_ring->nb_bkts = (tim_ring->max_tout / tim_ring->tck_nsec);
 	tim_ring->chunk_sz = dev->chunk_sz;
 	tim_ring->nb_timers = rcfg->nb_timers;
 	tim_ring->disable_npa = dev->disable_npa;
+	tim_ring->ena_periodic = is_periodic;
 	tim_ring->enable_stats = dev->enable_stats;
 
 	for (i = 0; i < dev->ring_ctl_cnt ; i++) {
@@ -348,7 +366,7 @@ otx2_tim_ring_create(struct rte_event_timer_adapter *adptr)
 	cfg_req->ring = tim_ring->ring_id;
 	cfg_req->bigendian = false;
 	cfg_req->clocksource = tim_ring->clk_src;
-	cfg_req->enableperiodic = false;
+	cfg_req->enableperiodic = tim_ring->ena_periodic;
 	cfg_req->enabledontfreebuffer = tim_ring->ena_dfb;
 	cfg_req->bucketsize = tim_ring->nb_bkts;
 	cfg_req->chunksize = tim_ring->chunk_sz;
@@ -568,7 +586,8 @@ otx2_tim_caps_get(const struct rte_eventdev *evdev, uint64_t flags,
 
 	/* Store evdev pointer for later use. */
 	dev->event_dev = (struct rte_eventdev *)(uintptr_t)evdev;
-	*caps = RTE_EVENT_TIMER_ADAPTER_CAP_INTERNAL_PORT;
+	*caps = RTE_EVENT_TIMER_ADAPTER_CAP_INTERNAL_PORT |
+		RTE_EVENT_TIMER_ADAPTER_CAP_PERIODIC;
 	*ops = &otx2_tim_ops;
 
 	return 0;
diff --git a/drivers/event/octeontx2/otx2_tim_evdev.h b/drivers/event/octeontx2/otx2_tim_evdev.h
index 44e3c7b51..82d116c09 100644
--- a/drivers/event/octeontx2/otx2_tim_evdev.h
+++ b/drivers/event/octeontx2/otx2_tim_evdev.h
@@ -155,6 +155,7 @@ struct otx2_tim_ring {
 	uint8_t disable_npa;
 	uint8_t optimized;
 	uint8_t ena_dfb;
+	uint8_t ena_periodic;
 	uint16_t ring_id;
 	uint32_t aura;
 	uint64_t nb_timers;
-- 
2.25.1


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [dpdk-dev] [PATCH 1/3] eventdev: introduce adapter flags for periodic mode
  2021-03-12 15:30   ` Carrillo, Erik G
@ 2021-03-14 16:49     ` Shijith Thotton
  0 siblings, 0 replies; 23+ messages in thread
From: Shijith Thotton @ 2021-03-14 16:49 UTC (permalink / raw)
  To: Carrillo, Erik G; +Cc: Shijith Thotton, Pavan Nikhilesh, Jerin Jacob, dev

On Fri, Mar 12, 2021 at 03:30:11PM +0000, Carrillo, Erik G wrote:
> Hi Shijith,
> 
> Some comments in-line:
> 
> > -----Original Message-----
> > From: Shijith Thotton <sthotton@marvell.com>
> > Sent: Monday, March 8, 2021 2:46 PM
> > To: Carrillo, Erik G <erik.g.carrillo@intel.com>
> > Cc: Shijith Thotton <sthotton@marvell.com>; Pavan Nikhilesh
> > <pbhagavatula@marvell.com>; Jerin Jacob <jerinj@marvell.com>;
> > dev@dpdk.org
> > Subject: [PATCH 1/3] eventdev: introduce adapter flags for periodic mode
> > 
> > A timer adapter in periodic mode can be used to arm periodic timers.
> > This patch adds flags used to advertise capability and configure timer adapter
> > in periodic mode. Capability flag should be set for adapters which support
> > periodic mode.
> > 
> > Below is a programming sequence on the usage:
> > 	/* check for periodic mode support by reading capability. */
> > 	rte_event_timer_adapter_caps_get(...);
> > 
> > 	/* create adapter in periodic mode by setting periodic flag
> > 	   (RTE_EVENT_TIMER_ADAPTER_F_PERIODIC) and resolution. */
> > 	rte_event_timer_adapter_create_ext(...);
> > 
> > 	/* arm periodic timer of configured resolution */
> > 	rte_event_timer_arm_burst(...);
> > 
> > 	/* timer event will be periodically generated at configured
> > 	   resolution till cancel is called. */
> > 	while (running) { rte_event_dequeue_burst(...); }
> > 
> > 	/* cancel periodic timer which stops generating events */
> > 	rte_event_timer_cancel_burst(...);
> > 
> > Signed-off-by: Shijith Thotton <sthotton@marvell.com>
> > ---
> >  doc/guides/prog_guide/event_timer_adapter.rst | 33
> > +++++++++++++++++++  lib/librte_eventdev/rte_event_timer_adapter.h |
> > 6 ++++
> >  lib/librte_eventdev/rte_eventdev.h            |  3 ++
> >  3 files changed, 42 insertions(+)
> > 
> > diff --git a/doc/guides/prog_guide/event_timer_adapter.rst
> > b/doc/guides/prog_guide/event_timer_adapter.rst
> > index a95efbe0d..fcdecdb3b 100644
> > --- a/doc/guides/prog_guide/event_timer_adapter.rst
> > +++ b/doc/guides/prog_guide/event_timer_adapter.rst
> > @@ -252,6 +252,39 @@ be canceled by calling
> > ``rte_event_timer_cancel_burst()``:
> >           */
> >  	rte_event_timer_cancel_burst(adapter, &conn->timer, 1);
> > 
> > +Timer adapter in periodic mode
> > +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > +
> > +A periodic timer is a timer, which expires at fixed time intervals
> > +continuously till it is cancelled.  A timer adapter can be configured
> > +to arm such timers by configuring it in periodic mode.  Capability flag
> > +``RTE_EVENT_TIMER_ADAPTER_CAP_PERIODIC`` can be used to check if an
> > +adapter supports periodic mode. An adapter in periodic mode can only be
> > +used to arm periodic timers.
> > +
> > +Example config to create an adapter in periodic mode with 100ms
> > resolution:
> > +
> > +.. code-block:: c
> > +
> > +	#define NSECPERSEC 1E9 // No of ns in 1 sec
> > +	const struct rte_event_timer_adapter_conf adapter_config = {
> > +                .event_dev_id = event_dev_id,
> > +                .timer_adapter_id = 0,
> > +                .clk_src = RTE_EVENT_TIMER_ADAPTER_CPU_CLK,
> > +                .timer_tick_ns = NSECPERSEC / 10, // 100 milliseconds
> > +                .nb_timers = 100,
> > +                .timer_adapter_flags = RTE_EVENT_TIMER_ADAPTER_F_PERIODIC,
> > +	};
> > +
> > +``timer_adapter_flags`` is set to include periodic flag
> > +``RTE_EVENT_TIMER_ADAPTER_F_PERIODIC`` and ``timer_tick_ns`` to
> > resolution.
> > +Maximum timeout (``max_tmo_nsec``) does not apply for periodic mode.
> 
> This content can be reworked slightly and moved into the "Create and Configure an Adapter Instance" section, perhaps as a subsection describing the two adapter modes.
> 

Reworked as suggested in v2.

> > +
> > +After starting the adapter, event timer arm APIs can be used to arm
> > +periodic timers.  Timer events will be generated at configured
> > +``timer_tick_ns`` intervals.  Event generation can be stopped using
> > +cancel API ``rte_event_timer_cancel_burst``.
> > +
> 
> I think this content should be worked into the "Arming Event Timers" section, indicating how the timer behavior depends on the mode of the adapter that specified in the arm call.
> 

Reworked as suggested in v2.

> >  Processing Timer Expiry Events
> >  ------------------------------
> > 
> > diff --git a/lib/librte_eventdev/rte_event_timer_adapter.h
> > b/lib/librte_eventdev/rte_event_timer_adapter.h
> > index d2ebcb090..f9fc95711 100644
> > --- a/lib/librte_eventdev/rte_event_timer_adapter.h
> > +++ b/lib/librte_eventdev/rte_event_timer_adapter.h
> 
> I think we should also update the doxygen documentation for the rte_event_timer_arm_burst to indicate that timer expiry events will be generated once or periodically until the timer is stopped based on the mode of the adapter that is specified.  We can have a "see also" for the RTE_EVENT_TIMER_ADAPTER_F_PERIODIC flag.
> 

Updated comments in v2.

> > @@ -151,6 +151,12 @@ enum rte_event_timer_adapter_clk_src {
> >   * @see struct rte_event_timer_adapter_conf::flags
> >   */
> > 
> > +#define RTE_EVENT_TIMER_ADAPTER_F_PERIODIC	(1ULL << 2)
> > +/**< Flag to configure event timer adapter in periodic mode.
> > + *
> > + * @see struct rte_event_timer_adapter_conf::flags
> > + */
> > +
> >  /**
> >   * Timer adapter configuration structure
> >   */
> 

Thanks,
Shijith

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [dpdk-dev] [PATCH v2 1/3] eventdev: introduce adapter flags for periodic mode
  2021-03-14 16:45   ` [dpdk-dev] [PATCH v2 1/3] eventdev: introduce adapter flags for periodic mode Shijith Thotton
@ 2021-03-16 19:04     ` Carrillo, Erik G
  2021-03-17  6:10       ` Shijith Thotton
  0 siblings, 1 reply; 23+ messages in thread
From: Carrillo, Erik G @ 2021-03-16 19:04 UTC (permalink / raw)
  To: Shijith Thotton; +Cc: Pavan Nikhilesh, Jerin Jacob, dev

Thanks, Shijith.  I'm posting a couple of follow-up comments in-line:

> -----Original Message-----
> From: Shijith Thotton <sthotton@marvell.com>
> Sent: Sunday, March 14, 2021 11:46 AM
> To: Carrillo, Erik G <erik.g.carrillo@intel.com>
> Cc: Shijith Thotton <sthotton@marvell.com>; Pavan Nikhilesh
> <pbhagavatula@marvell.com>; Jerin Jacob <jerinj@marvell.com>;
> dev@dpdk.org
> Subject: [PATCH v2 1/3] eventdev: introduce adapter flags for periodic mode
> 
> A timer adapter in periodic mode can be used to arm periodic timers.
> This patch adds flags used to advertise capability and configure timer adapter
> in periodic mode. Capability flag should be set for adapters which support
> periodic mode.
> 
> Below is a programming sequence on the usage:
> 	/* check for periodic mode support by reading capability. */
> 	rte_event_timer_adapter_caps_get(...);
> 
> 	/* create adapter in periodic mode by setting periodic flag
> 	   (RTE_EVENT_TIMER_ADAPTER_F_PERIODIC) and resolution. */
> 	rte_event_timer_adapter_create_ext(...);
> 
> 	/* arm periodic timer of configured resolution */
> 	rte_event_timer_arm_burst(...);
> 
> 	/* timer event will be periodically generated at configured
> 	   resolution till cancel is called. */
> 	while (running) { rte_event_dequeue_burst(...); }
> 
> 	/* cancel periodic timer which stops generating events */
> 	rte_event_timer_cancel_burst(...);
> 
> Signed-off-by: Shijith Thotton <sthotton@marvell.com>
> ---
>  doc/guides/prog_guide/event_timer_adapter.rst | 15 ++++++++++++++-
> lib/librte_eventdev/rte_event_timer_adapter.h | 11 +++++++++++
>  lib/librte_eventdev/rte_eventdev.h            |  3 +++
>  3 files changed, 28 insertions(+), 1 deletion(-)
> 
> diff --git a/doc/guides/prog_guide/event_timer_adapter.rst
> b/doc/guides/prog_guide/event_timer_adapter.rst
> index a95efbe0d..0b2add6f7 100644
> --- a/doc/guides/prog_guide/event_timer_adapter.rst
> +++ b/doc/guides/prog_guide/event_timer_adapter.rst
> @@ -138,6 +138,17 @@ This function is passed a callback function that will be
> invoked if the  adapter needs to create an event port, giving the application
> the opportunity  to control how it is done.
> 
> +Adapter modes
> +^^^^^^^^^^^^^
> +An event timer adapter can be configured in either periodic or
> +non-periodic mode to support timers of respective type. A periodic

"...timers of the respective type..."

> +timer expires at a fixed time interval repeatedly till it is cancelled.
> +A non-periodic timer expires only once. Periodic capability flag
> +``RTE_EVENT_TIMER_ADAPTER_CAP_PERIODIC`` is set for adapters which
> +support periodic mode. To configure an adapter in periodic mode,

"The periodic capability flag, ``RTE_EVENT_TIMER_ADAPTER_CAP_PERIODIC``, can be set for implementations that support periodic mode if desired."

> +``timer_adapter_flags`` of ``rte_event_timer_adapter_conf`` is set to
> +include periodic flag ``RTE_EVENT_TIMER_ADAPTER_F_PERIODIC``.

"...include the periodic flag..."

> Maximum
> +timeout
> +(``max_tmo_nsec``) does not apply for periodic mode.
> +
>  Retrieve Event Timer Adapter Contextual Information
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>  The event timer adapter implementation may have constraints on tick
> resolution @@ -229,7 +240,9 @@ Now we can arm the event timer with
> ``rte_event_timer_arm_burst()``:
> 
>  Once an event timer expires, the application may free it or rearm it as
> necessary.  If the application will rearm the timer, the state should be reset -
> to RTE_EVENT_TIMER_NOT_ARMED by the application before rearming it.
> +to RTE_EVENT_TIMER_NOT_ARMED by the application before rearming it.
> +Timer expiry events will be generated once or periodically until the
> +timer is cancelled based on adapter mode.
> 
>  Multiple Event Timers with Same Expiry Value
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> diff --git a/lib/librte_eventdev/rte_event_timer_adapter.h
> b/lib/librte_eventdev/rte_event_timer_adapter.h
> index d2ebcb090..b34dc1385 100644
> --- a/lib/librte_eventdev/rte_event_timer_adapter.h
> +++ b/lib/librte_eventdev/rte_event_timer_adapter.h
> @@ -151,6 +151,12 @@ enum rte_event_timer_adapter_clk_src {
>   * @see struct rte_event_timer_adapter_conf::flags
>   */
> 
> +#define RTE_EVENT_TIMER_ADAPTER_F_PERIODIC	(1ULL << 2)
> +/**< Flag to configure event timer adapter in periodic mode.

I think this could be elaborated on, perhaps like:

"Flag to configure an event timer adapter in periodic mode; non-periodic mode is the default.  A timer will fire once or periodically until the timer is cancelled based on the adapter mode."

> + *
> + * @see struct rte_event_timer_adapter_conf::flags
> + */
> +
>  /**
>   * Timer adapter configuration structure
>   */

<... snipped ...>

You should also be able to mark old versions of the series as superseded.  Also, there were a couple of coding style warnings on the second patch in the series regarding block comment syntax.

Thanks,
Erik

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [dpdk-dev] [PATCH v2 1/3] eventdev: introduce adapter flags for periodic mode
  2021-03-16 19:04     ` Carrillo, Erik G
@ 2021-03-17  6:10       ` Shijith Thotton
  0 siblings, 0 replies; 23+ messages in thread
From: Shijith Thotton @ 2021-03-17  6:10 UTC (permalink / raw)
  To: Carrillo, Erik G; +Cc: Shijith Thotton, Pavan Nikhilesh, Jerin Jacob, dev

On Tue, Mar 16, 2021 at 07:04:16PM +0000, Carrillo, Erik G wrote:
> Thanks, Shijith.  I'm posting a couple of follow-up comments in-line:
> 
> > -----Original Message-----
> > From: Shijith Thotton <sthotton@marvell.com>
> > Sent: Sunday, March 14, 2021 11:46 AM
> > To: Carrillo, Erik G <erik.g.carrillo@intel.com>
> > Cc: Shijith Thotton <sthotton@marvell.com>; Pavan Nikhilesh
> > <pbhagavatula@marvell.com>; Jerin Jacob <jerinj@marvell.com>;
> > dev@dpdk.org
> > Subject: [PATCH v2 1/3] eventdev: introduce adapter flags for periodic mode
> > 
> > A timer adapter in periodic mode can be used to arm periodic timers.
> > This patch adds flags used to advertise capability and configure timer adapter
> > in periodic mode. Capability flag should be set for adapters which support
> > periodic mode.
> > 
> > Below is a programming sequence on the usage:
> > 	/* check for periodic mode support by reading capability. */
> > 	rte_event_timer_adapter_caps_get(...);
> > 
> > 	/* create adapter in periodic mode by setting periodic flag
> > 	   (RTE_EVENT_TIMER_ADAPTER_F_PERIODIC) and resolution. */
> > 	rte_event_timer_adapter_create_ext(...);
> > 
> > 	/* arm periodic timer of configured resolution */
> > 	rte_event_timer_arm_burst(...);
> > 
> > 	/* timer event will be periodically generated at configured
> > 	   resolution till cancel is called. */
> > 	while (running) { rte_event_dequeue_burst(...); }
> > 
> > 	/* cancel periodic timer which stops generating events */
> > 	rte_event_timer_cancel_burst(...);
> > 
> > Signed-off-by: Shijith Thotton <sthotton@marvell.com>
> > ---
> >  doc/guides/prog_guide/event_timer_adapter.rst | 15 ++++++++++++++-
> > lib/librte_eventdev/rte_event_timer_adapter.h | 11 +++++++++++
> >  lib/librte_eventdev/rte_eventdev.h            |  3 +++
> >  3 files changed, 28 insertions(+), 1 deletion(-)
> > 
> > diff --git a/doc/guides/prog_guide/event_timer_adapter.rst
> > b/doc/guides/prog_guide/event_timer_adapter.rst
> > index a95efbe0d..0b2add6f7 100644
> > --- a/doc/guides/prog_guide/event_timer_adapter.rst
> > +++ b/doc/guides/prog_guide/event_timer_adapter.rst
> > @@ -138,6 +138,17 @@ This function is passed a callback function that will be
> > invoked if the  adapter needs to create an event port, giving the application
> > the opportunity  to control how it is done.
> > 
> > +Adapter modes
> > +^^^^^^^^^^^^^
> > +An event timer adapter can be configured in either periodic or
> > +non-periodic mode to support timers of respective type. A periodic
> 
> "...timers of the respective type..."
> 

Will change in v3.

> > +timer expires at a fixed time interval repeatedly till it is cancelled.
> > +A non-periodic timer expires only once. Periodic capability flag
> > +``RTE_EVENT_TIMER_ADAPTER_CAP_PERIODIC`` is set for adapters which
> > +support periodic mode. To configure an adapter in periodic mode,
> 
> "The periodic capability flag, ``RTE_EVENT_TIMER_ADAPTER_CAP_PERIODIC``, can be set for implementations that support periodic mode if desired."

Will change in v3.

> 
> > +``timer_adapter_flags`` of ``rte_event_timer_adapter_conf`` is set to
> > +include periodic flag ``RTE_EVENT_TIMER_ADAPTER_F_PERIODIC``.
> 
> "...include the periodic flag..."
> 

Will change in v3.

> > Maximum
> > +timeout
> > +(``max_tmo_nsec``) does not apply for periodic mode.
> > +
> >  Retrieve Event Timer Adapter Contextual Information
> > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >  The event timer adapter implementation may have constraints on tick
> > resolution @@ -229,7 +240,9 @@ Now we can arm the event timer with
> > ``rte_event_timer_arm_burst()``:
> > 
> >  Once an event timer expires, the application may free it or rearm it as
> > necessary.  If the application will rearm the timer, the state should be reset -
> > to RTE_EVENT_TIMER_NOT_ARMED by the application before rearming it.
> > +to RTE_EVENT_TIMER_NOT_ARMED by the application before rearming it.
> > +Timer expiry events will be generated once or periodically until the
> > +timer is cancelled based on adapter mode.
> > 
> >  Multiple Event Timers with Same Expiry Value
> > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> > diff --git a/lib/librte_eventdev/rte_event_timer_adapter.h
> > b/lib/librte_eventdev/rte_event_timer_adapter.h
> > index d2ebcb090..b34dc1385 100644
> > --- a/lib/librte_eventdev/rte_event_timer_adapter.h
> > +++ b/lib/librte_eventdev/rte_event_timer_adapter.h
> > @@ -151,6 +151,12 @@ enum rte_event_timer_adapter_clk_src {
> >   * @see struct rte_event_timer_adapter_conf::flags
> >   */
> > 
> > +#define RTE_EVENT_TIMER_ADAPTER_F_PERIODIC	(1ULL << 2)
> > +/**< Flag to configure event timer adapter in periodic mode.
> 
> I think this could be elaborated on, perhaps like:
> 
> "Flag to configure an event timer adapter in periodic mode; non-periodic mode is the default.  A timer will fire once or periodically until the timer is cancelled based on the adapter mode."
> 

Sounds good. Will change in v3.

> > + *
> > + * @see struct rte_event_timer_adapter_conf::flags
> > + */
> > +
> >  /**
> >   * Timer adapter configuration structure
> >   */
> 
> <... snipped ...>
> 
> You should also be able to mark old versions of the series as superseded.  Also, there were a couple of coding style warnings on the second patch in the series regarding block comment syntax.
> 

Will do.

Thanks,
Shijith

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [dpdk-dev] [PATCH v3 0/3] periodic mode for event timer adapter
  2021-03-14 16:45 ` [dpdk-dev] [PATCH v2 0/3] periodic mode for event timer adapter Shijith Thotton
                     ` (2 preceding siblings ...)
  2021-03-14 16:45   ` [dpdk-dev] [PATCH v2 3/3] event/octeontx2: add timer periodic mode support Shijith Thotton
@ 2021-03-17  8:04   ` Shijith Thotton
  2021-03-17  8:04     ` [dpdk-dev] [PATCH v3 1/3] eventdev: introduce adapter flags for periodic mode Shijith Thotton
                       ` (2 more replies)
  3 siblings, 3 replies; 23+ messages in thread
From: Shijith Thotton @ 2021-03-17  8:04 UTC (permalink / raw)
  To: Erik Gabriel Carrillo; +Cc: Shijith Thotton, Pavan Nikhilesh, Jerin Jacob, dev

Arming periodic timers are not supported by the event timer adapter
right now. This series adds that support. A timer adapter configured in
periodic mode can be used to arm periodic timers. 

First patch adds a flag to expose periodic mode capability of an adapter
and flag to configure the adapter in periodic mode. Second one adds unit
tests for periodic mode. Third one is a hardware implementation of the
feature.

v3:
 - Text and checkpatch related corrections.

v2:
 - Updated rst and doxygen documentation.

Shijith Thotton (3):
  eventdev: introduce adapter flags for periodic mode
  test/event: add unit tests for periodic timer
  event/octeontx2: add timer periodic mode support

 app/test/test_event_timer_adapter.c           | 138 ++++++++++++++++--
 doc/guides/prog_guide/event_timer_adapter.rst |  16 +-
 drivers/event/octeontx2/otx2_tim_evdev.c      |  29 +++-
 drivers/event/octeontx2/otx2_tim_evdev.h      |   1 +
 lib/librte_eventdev/rte_event_timer_adapter.h |  13 ++
 lib/librte_eventdev/rte_eventdev.h            |   3 +
 6 files changed, 181 insertions(+), 19 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 23+ messages in thread

* [dpdk-dev] [PATCH v3 1/3] eventdev: introduce adapter flags for periodic mode
  2021-03-17  8:04   ` [dpdk-dev] [PATCH v3 0/3] periodic mode for event timer adapter Shijith Thotton
@ 2021-03-17  8:04     ` Shijith Thotton
  2021-03-17 18:07       ` Carrillo, Erik G
  2021-03-17  8:04     ` [dpdk-dev] [PATCH v3 2/3] test/event: add unit tests for periodic timer Shijith Thotton
  2021-03-17  8:04     ` [dpdk-dev] [PATCH v3 3/3] event/octeontx2: add timer periodic mode support Shijith Thotton
  2 siblings, 1 reply; 23+ messages in thread
From: Shijith Thotton @ 2021-03-17  8:04 UTC (permalink / raw)
  To: Erik Gabriel Carrillo; +Cc: Shijith Thotton, Pavan Nikhilesh, Jerin Jacob, dev

A timer adapter in periodic mode can be used to arm periodic timers.
This patch adds flags used to advertise capability and configure timer
adapter in periodic mode. Capability flag should be set for adapters
which support periodic mode.

Below is a programming sequence on the usage:
	/* check for periodic mode support by reading capability. */
	rte_event_timer_adapter_caps_get(...);

	/* create adapter in periodic mode by setting periodic flag
	   (RTE_EVENT_TIMER_ADAPTER_F_PERIODIC) and resolution. */
	rte_event_timer_adapter_create_ext(...);

	/* arm periodic timer of configured resolution */
	rte_event_timer_arm_burst(...);

	/* timer event will be periodically generated at configured
	   resolution till cancel is called. */
	while (running) { rte_event_dequeue_burst(...); }

	/* cancel periodic timer which stops generating events */
	rte_event_timer_cancel_burst(...);

Signed-off-by: Shijith Thotton <sthotton@marvell.com>
---
 doc/guides/prog_guide/event_timer_adapter.rst | 16 +++++++++++++++-
 lib/librte_eventdev/rte_event_timer_adapter.h | 13 +++++++++++++
 lib/librte_eventdev/rte_eventdev.h            |  3 +++
 3 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/doc/guides/prog_guide/event_timer_adapter.rst b/doc/guides/prog_guide/event_timer_adapter.rst
index a95efbe0d..8b18cd169 100644
--- a/doc/guides/prog_guide/event_timer_adapter.rst
+++ b/doc/guides/prog_guide/event_timer_adapter.rst
@@ -138,6 +138,18 @@ This function is passed a callback function that will be invoked if the
 adapter needs to create an event port, giving the application the opportunity
 to control how it is done.
 
+Adapter modes
+^^^^^^^^^^^^^
+An event timer adapter can be configured in either periodic or non-periodic mode
+to support timers of the respective type. A periodic timer expires at a fixed
+time interval repeatedly till it is cancelled. A non-periodic timer expires only
+once. The periodic capability flag, ``RTE_EVENT_TIMER_ADAPTER_CAP_PERIODIC``,
+can be set for implementations that support periodic mode if desired. To
+configure an adapter in periodic mode, ``timer_adapter_flags`` of
+``rte_event_timer_adapter_conf`` is set to include the periodic flag
+``RTE_EVENT_TIMER_ADAPTER_F_PERIODIC``. Maximum timeout (``max_tmo_nsec``) does
+not apply to periodic mode.
+
 Retrieve Event Timer Adapter Contextual Information
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 The event timer adapter implementation may have constraints on tick resolution
@@ -229,7 +241,9 @@ Now we can arm the event timer with ``rte_event_timer_arm_burst()``:
 
 Once an event timer expires, the application may free it or rearm it as
 necessary.  If the application will rearm the timer, the state should be reset
-to RTE_EVENT_TIMER_NOT_ARMED by the application before rearming it.
+to RTE_EVENT_TIMER_NOT_ARMED by the application before rearming it. Timer expiry
+events will be generated once or periodically until the timer is cancelled based
+on adapter mode.
 
 Multiple Event Timers with Same Expiry Value
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/lib/librte_eventdev/rte_event_timer_adapter.h b/lib/librte_eventdev/rte_event_timer_adapter.h
index d2ebcb090..4e0d2a819 100644
--- a/lib/librte_eventdev/rte_event_timer_adapter.h
+++ b/lib/librte_eventdev/rte_event_timer_adapter.h
@@ -151,6 +151,14 @@ enum rte_event_timer_adapter_clk_src {
  * @see struct rte_event_timer_adapter_conf::flags
  */
 
+#define RTE_EVENT_TIMER_ADAPTER_F_PERIODIC	(1ULL << 2)
+/**< Flag to configure an event timer adapter in periodic mode; non-periodic
+ * mode is the default. A timer will fire once or periodically until the timer
+ * is cancelled based on the adapter mode.
+ *
+ * @see struct rte_event_timer_adapter_conf::flags
+ */
+
 /**
  * Timer adapter configuration structure
  */
@@ -551,6 +559,8 @@ struct rte_event_timer_adapter {
  * expiry event attributes, timeout ticks from now.
  * This function submits the event timer arm requests to the event timer adapter
  * and on expiry, the events will be injected to designated event queue.
+ * Timer expiry events will be generated once or periodically until cancellation
+ * based on the adapter mode.
  *
  * @param adapter
  *   A pointer to an event timer adapter structure.
@@ -570,6 +580,9 @@ struct rte_event_timer_adapter {
  *   destination event queue.
  *   - EAGAIN Specified timer adapter is not running
  *   - EALREADY A timer was encountered that was already armed
+ *
+ * @see RTE_EVENT_TIMER_ADAPTER_F_PERIODIC
+ *
  */
 static inline uint16_t
 rte_event_timer_arm_burst(const struct rte_event_timer_adapter *adapter,
diff --git a/lib/librte_eventdev/rte_eventdev.h b/lib/librte_eventdev/rte_eventdev.h
index ce1fc2ce0..9fc39e9ca 100644
--- a/lib/librte_eventdev/rte_eventdev.h
+++ b/lib/librte_eventdev/rte_eventdev.h
@@ -1154,6 +1154,9 @@ rte_event_eth_rx_adapter_caps_get(uint8_t dev_id, uint16_t eth_port_id,
 #define RTE_EVENT_TIMER_ADAPTER_CAP_INTERNAL_PORT (1ULL << 0)
 /**< This flag is set when the timer mechanism is in HW. */
 
+#define RTE_EVENT_TIMER_ADAPTER_CAP_PERIODIC      (1ULL << 1)
+/**< This flag is set if periodic mode is supported. */
+
 /**
  * Retrieve the event device's timer adapter capabilities.
  *
-- 
2.25.1


^ permalink raw reply	[flat|nested] 23+ messages in thread

* [dpdk-dev] [PATCH v3 2/3] test/event: add unit tests for periodic timer
  2021-03-17  8:04   ` [dpdk-dev] [PATCH v3 0/3] periodic mode for event timer adapter Shijith Thotton
  2021-03-17  8:04     ` [dpdk-dev] [PATCH v3 1/3] eventdev: introduce adapter flags for periodic mode Shijith Thotton
@ 2021-03-17  8:04     ` Shijith Thotton
  2021-03-17 18:11       ` Carrillo, Erik G
  2021-03-17  8:04     ` [dpdk-dev] [PATCH v3 3/3] event/octeontx2: add timer periodic mode support Shijith Thotton
  2 siblings, 1 reply; 23+ messages in thread
From: Shijith Thotton @ 2021-03-17  8:04 UTC (permalink / raw)
  To: Erik Gabriel Carrillo; +Cc: Shijith Thotton, Pavan Nikhilesh, Jerin Jacob, dev

Add tests to arm and cancel periodic timer.

Signed-off-by: Shijith Thotton <sthotton@marvell.com>
---
 app/test/test_event_timer_adapter.c | 138 +++++++++++++++++++++++++---
 1 file changed, 125 insertions(+), 13 deletions(-)

diff --git a/app/test/test_event_timer_adapter.c b/app/test/test_event_timer_adapter.c
index b536ddef4..c36ab32ac 100644
--- a/app/test/test_event_timer_adapter.c
+++ b/app/test/test_event_timer_adapter.c
@@ -283,7 +283,7 @@ test_port_conf_cb(uint16_t id, uint8_t event_dev_id, uint8_t *event_port_id,
 }
 
 static int
-_timdev_setup(uint64_t max_tmo_ns, uint64_t bkt_tck_ns)
+_timdev_setup(uint64_t max_tmo_ns, uint64_t bkt_tck_ns, uint64_t flags)
 {
 	struct rte_event_timer_adapter_info info;
 	struct rte_event_timer_adapter_conf config = {
@@ -292,7 +292,7 @@ _timdev_setup(uint64_t max_tmo_ns, uint64_t bkt_tck_ns)
 		.timer_tick_ns = bkt_tck_ns,
 		.max_tmo_ns = max_tmo_ns,
 		.nb_timers = MAX_TIMERS * 10,
-		.flags = RTE_EVENT_TIMER_ADAPTER_F_ADJUST_RES,
+		.flags = flags,
 	};
 	uint32_t caps = 0;
 	const char *pool_name = "timdev_test_pool";
@@ -301,6 +301,13 @@ _timdev_setup(uint64_t max_tmo_ns, uint64_t bkt_tck_ns)
 
 	TEST_ASSERT_SUCCESS(rte_event_timer_adapter_caps_get(evdev, &caps),
 				"failed to get adapter capabilities");
+
+	if (flags & RTE_EVENT_TIMER_ADAPTER_F_PERIODIC &&
+	    !(caps & RTE_EVENT_TIMER_ADAPTER_CAP_PERIODIC)) {
+		printf("Adapter does not support periodic timers\n");
+		return TEST_SKIPPED;
+	}
+
 	if (!(caps & RTE_EVENT_TIMER_ADAPTER_CAP_INTERNAL_PORT)) {
 		timdev = rte_event_timer_adapter_create_ext(&config,
 							    test_port_conf_cb,
@@ -338,42 +345,72 @@ _timdev_setup(uint64_t max_tmo_ns, uint64_t bkt_tck_ns)
 static int
 timdev_setup_usec(void)
 {
+	uint64_t flags = RTE_EVENT_TIMER_ADAPTER_F_ADJUST_RES;
+
 	return using_services ?
 		/* Max timeout is 10,000us and bucket interval is 100us */
-		_timdev_setup(1E7, 1E5) :
+		_timdev_setup(1E7, 1E5, flags) :
 		/* Max timeout is 100us and bucket interval is 1us */
-		_timdev_setup(1E5, 1E3);
+		_timdev_setup(1E5, 1E3, flags);
 }
 
 static int
 timdev_setup_usec_multicore(void)
 {
+	uint64_t flags = RTE_EVENT_TIMER_ADAPTER_F_ADJUST_RES;
+
 	return using_services ?
 		/* Max timeout is 10,000us and bucket interval is 100us */
-		_timdev_setup(1E7, 1E5) :
+		_timdev_setup(1E7, 1E5, flags) :
 		/* Max timeout is 100us and bucket interval is 1us */
-		_timdev_setup(1E5, 1E3);
+		_timdev_setup(1E5, 1E3, flags);
 }
 
 static int
 timdev_setup_msec(void)
 {
-	/* Max timeout is 2 mins, and bucket interval is 100 ms */
-	return _timdev_setup(180 * NSECPERSEC, NSECPERSEC / 10);
+	uint64_t flags = RTE_EVENT_TIMER_ADAPTER_F_ADJUST_RES;
+
+	/* Max timeout is 3 mins, and bucket interval is 100 ms */
+	return _timdev_setup(180 * NSECPERSEC, NSECPERSEC / 10, flags);
+}
+
+static int
+timdev_setup_msec_periodic(void)
+{
+	uint64_t flags = RTE_EVENT_TIMER_ADAPTER_F_ADJUST_RES |
+			 RTE_EVENT_TIMER_ADAPTER_F_PERIODIC;
+
+	/* Periodic mode with 100 ms resolution */
+	return _timdev_setup(0, NSECPERSEC / 10, flags);
 }
 
 static int
 timdev_setup_sec(void)
 {
+	uint64_t flags = RTE_EVENT_TIMER_ADAPTER_F_ADJUST_RES;
+
 	/* Max timeout is 100sec and bucket interval is 1sec */
-	return _timdev_setup(1E11, 1E9);
+	return _timdev_setup(1E11, 1E9, flags);
+}
+
+static int
+timdev_setup_sec_periodic(void)
+{
+	uint64_t flags = RTE_EVENT_TIMER_ADAPTER_F_ADJUST_RES |
+			 RTE_EVENT_TIMER_ADAPTER_F_PERIODIC;
+
+	/* Periodic mode with 1 sec resolution */
+	return _timdev_setup(0, NSECPERSEC, flags);
 }
 
 static int
 timdev_setup_sec_multicore(void)
 {
+	uint64_t flags = RTE_EVENT_TIMER_ADAPTER_F_ADJUST_RES;
+
 	/* Max timeout is 100sec and bucket interval is 1sec */
-	return _timdev_setup(1E11, 1E9);
+	return _timdev_setup(1E11, 1E9, flags);
 }
 
 static void
@@ -513,6 +550,19 @@ test_timer_arm(void)
 	return TEST_SUCCESS;
 }
 
+static inline int
+test_timer_arm_periodic(void)
+{
+	TEST_ASSERT_SUCCESS(_arm_timers(1, MAX_TIMERS),
+			    "Failed to arm timers");
+	/* With a resolution of 100ms and wait time of 1sec,
+	 * there will be 10 * MAX_TIMERS periodic timer triggers.
+	 */
+	TEST_ASSERT_SUCCESS(_wait_timer_triggers(1, 10 * MAX_TIMERS, 0),
+			    "Timer triggered count doesn't match arm count");
+	return TEST_SUCCESS;
+}
+
 static int
 _arm_wrapper(void *arg)
 {
@@ -588,6 +638,20 @@ test_timer_arm_burst(void)
 	return TEST_SUCCESS;
 }
 
+static inline int
+test_timer_arm_burst_periodic(void)
+{
+	TEST_ASSERT_SUCCESS(_arm_timers_burst(1, MAX_TIMERS),
+			    "Failed to arm timers");
+	/* With a resolution of 100ms and wait time of 1sec,
+	 * there will be 10 * MAX_TIMERS periodic timer triggers.
+	 */
+	TEST_ASSERT_SUCCESS(_wait_timer_triggers(1, 10 * MAX_TIMERS, 0),
+			    "Timer triggered count doesn't match arm count");
+
+	return TEST_SUCCESS;
+}
+
 static int
 _arm_wrapper_burst(void *arg)
 {
@@ -612,6 +676,48 @@ test_timer_arm_burst_multicore(void)
 	return TEST_SUCCESS;
 }
 
+static inline int
+test_timer_cancel_periodic(void)
+{
+	uint64_t i;
+	struct rte_event_timer *ev_tim;
+	const struct rte_event_timer tim = {
+		.ev.op = RTE_EVENT_OP_NEW,
+		.ev.queue_id = 0,
+		.ev.sched_type = RTE_SCHED_TYPE_ATOMIC,
+		.ev.priority = RTE_EVENT_DEV_PRIORITY_NORMAL,
+		.ev.event_type =  RTE_EVENT_TYPE_TIMER,
+		.state = RTE_EVENT_TIMER_NOT_ARMED,
+		.timeout_ticks = CALC_TICKS(1),
+	};
+
+	for (i = 0; i < MAX_TIMERS; i++) {
+		TEST_ASSERT_SUCCESS(rte_mempool_get(eventdev_test_mempool,
+					(void **)&ev_tim),
+				"mempool alloc failed");
+		*ev_tim = tim;
+		ev_tim->ev.event_ptr = ev_tim;
+
+		TEST_ASSERT_EQUAL(rte_event_timer_arm_burst(timdev, &ev_tim,
+					1), 1, "Failed to arm timer %d",
+				rte_errno);
+
+		rte_delay_us(100 + (i % 5000));
+
+		TEST_ASSERT_EQUAL(rte_event_timer_cancel_burst(timdev,
+					&ev_tim, 1), 1,
+				"Failed to cancel event timer %d", rte_errno);
+		rte_mempool_put(eventdev_test_mempool, ev_tim);
+	}
+
+
+	TEST_ASSERT_SUCCESS(_wait_timer_triggers(30, MAX_TIMERS,
+				MAX_TIMERS),
+		"Timer triggered count doesn't match arm, cancel count");
+
+	return TEST_SUCCESS;
+}
+
 static inline int
 test_timer_cancel(void)
 {
@@ -1028,9 +1134,9 @@ adapter_lookup(void)
 static int
 adapter_start(void)
 {
-	TEST_ASSERT_SUCCESS(_timdev_setup(180 * NSECPERSEC,
-			NSECPERSEC / 10),
-			"Failed to start adapter");
+	TEST_ASSERT_SUCCESS(_timdev_setup(180 * NSECPERSEC, NSECPERSEC / 10,
+					  RTE_EVENT_TIMER_ADAPTER_F_ADJUST_RES),
+			    "Failed to start adapter");
 	TEST_ASSERT_EQUAL(rte_event_timer_adapter_start(timdev), -EALREADY,
 			"Timer adapter started without call to stop.");
 
@@ -1786,10 +1892,16 @@ static struct unit_test_suite event_timer_adptr_functional_testsuite  = {
 				test_timer_state),
 		TEST_CASE_ST(timdev_setup_usec, timdev_teardown,
 				test_timer_arm),
+		TEST_CASE_ST(timdev_setup_msec_periodic, timdev_teardown,
+				test_timer_arm_periodic),
 		TEST_CASE_ST(timdev_setup_usec, timdev_teardown,
 				test_timer_arm_burst),
+		TEST_CASE_ST(timdev_setup_msec_periodic, timdev_teardown,
+				test_timer_arm_burst_periodic),
 		TEST_CASE_ST(timdev_setup_sec, timdev_teardown,
 				test_timer_cancel),
+		TEST_CASE_ST(timdev_setup_sec_periodic, timdev_teardown,
+				test_timer_cancel_periodic),
 		TEST_CASE_ST(timdev_setup_sec, timdev_teardown,
 				test_timer_cancel_random),
 		TEST_CASE_ST(timdev_setup_usec_multicore, timdev_teardown,
-- 
2.25.1


^ permalink raw reply	[flat|nested] 23+ messages in thread

* [dpdk-dev] [PATCH v3 3/3] event/octeontx2: add timer periodic mode support
  2021-03-17  8:04   ` [dpdk-dev] [PATCH v3 0/3] periodic mode for event timer adapter Shijith Thotton
  2021-03-17  8:04     ` [dpdk-dev] [PATCH v3 1/3] eventdev: introduce adapter flags for periodic mode Shijith Thotton
  2021-03-17  8:04     ` [dpdk-dev] [PATCH v3 2/3] test/event: add unit tests for periodic timer Shijith Thotton
@ 2021-03-17  8:04     ` Shijith Thotton
  2021-03-21 14:43       ` Pavan Nikhilesh Bhagavatula
  2 siblings, 1 reply; 23+ messages in thread
From: Shijith Thotton @ 2021-03-17  8:04 UTC (permalink / raw)
  To: Erik Gabriel Carrillo; +Cc: Shijith Thotton, Pavan Nikhilesh, Jerin Jacob, dev

Add support for periodic mode in event timer adapter.

Signed-off-by: Shijith Thotton <sthotton@marvell.com>
---
 drivers/event/octeontx2/otx2_tim_evdev.c | 29 ++++++++++++++++++++----
 drivers/event/octeontx2/otx2_tim_evdev.h |  1 +
 2 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/drivers/event/octeontx2/otx2_tim_evdev.c b/drivers/event/octeontx2/otx2_tim_evdev.c
index 4c24cc8a6..39a29f17f 100644
--- a/drivers/event/octeontx2/otx2_tim_evdev.c
+++ b/drivers/event/octeontx2/otx2_tim_evdev.c
@@ -65,7 +65,8 @@ otx2_tim_ring_info_get(const struct rte_event_timer_adapter *adptr,
 	struct otx2_tim_ring *tim_ring = adptr->data->adapter_priv;
 
 	adptr_info->max_tmo_ns = tim_ring->max_tout;
-	adptr_info->min_resolution_ns = tim_ring->tck_nsec;
+	adptr_info->min_resolution_ns = tim_ring->ena_periodic ?
+		tim_ring->max_tout : tim_ring->tck_nsec;
 	rte_memcpy(&adptr_info->conf, &adptr->data->conf,
 		   sizeof(struct rte_event_timer_adapter_conf));
 }
@@ -163,7 +164,7 @@ tim_chnk_pool_create(struct otx2_tim_ring *tim_ring,
 		}
 		tim_ring->aura = npa_lf_aura_handle_to_aura(
 				tim_ring->chunk_pool->pool_id);
-		tim_ring->ena_dfb = 0;
+		tim_ring->ena_dfb = tim_ring->ena_periodic ? 1 : 0;
 	} else {
 		tim_ring->chunk_pool = rte_mempool_create(pool_name,
 				tim_ring->nb_chunks, tim_ring->chunk_sz,
@@ -254,6 +255,7 @@ otx2_tim_ring_create(struct rte_event_timer_adapter *adptr)
 	struct tim_ring_req *free_req;
 	struct tim_lf_alloc_req *req;
 	struct tim_lf_alloc_rsp *rsp;
+	uint8_t is_periodic;
 	int i, rc;
 
 	if (dev == NULL)
@@ -284,6 +286,20 @@ otx2_tim_ring_create(struct rte_event_timer_adapter *adptr)
 		}
 	}
 
+	is_periodic = 0;
+	if (rcfg->flags & RTE_EVENT_TIMER_ADAPTER_F_PERIODIC) {
+		if (rcfg->max_tmo_ns &&
+		    rcfg->max_tmo_ns != rcfg->timer_tick_ns) {
+			rc = -ERANGE;
+			goto rng_mem_err;
+		}
+
+		/* Use 2 buckets to avoid contention */
+		rcfg->max_tmo_ns = rcfg->timer_tick_ns;
+		rcfg->timer_tick_ns /= 2;
+		is_periodic = 1;
+	}
+
 	tim_ring = rte_zmalloc("otx2_tim_prv", sizeof(struct otx2_tim_ring), 0);
 	if (tim_ring == NULL) {
 		rc =  -ENOMEM;
@@ -296,11 +312,13 @@ otx2_tim_ring_create(struct rte_event_timer_adapter *adptr)
 	tim_ring->clk_src = (int)rcfg->clk_src;
 	tim_ring->ring_id = adptr->data->id;
 	tim_ring->tck_nsec = RTE_ALIGN_MUL_CEIL(rcfg->timer_tick_ns, 10);
-	tim_ring->max_tout = rcfg->max_tmo_ns;
+	tim_ring->max_tout = is_periodic ?
+		rcfg->timer_tick_ns * 2 : rcfg->max_tmo_ns;
 	tim_ring->nb_bkts = (tim_ring->max_tout / tim_ring->tck_nsec);
 	tim_ring->chunk_sz = dev->chunk_sz;
 	tim_ring->nb_timers = rcfg->nb_timers;
 	tim_ring->disable_npa = dev->disable_npa;
+	tim_ring->ena_periodic = is_periodic;
 	tim_ring->enable_stats = dev->enable_stats;
 
 	for (i = 0; i < dev->ring_ctl_cnt ; i++) {
@@ -348,7 +366,7 @@ otx2_tim_ring_create(struct rte_event_timer_adapter *adptr)
 	cfg_req->ring = tim_ring->ring_id;
 	cfg_req->bigendian = false;
 	cfg_req->clocksource = tim_ring->clk_src;
-	cfg_req->enableperiodic = false;
+	cfg_req->enableperiodic = tim_ring->ena_periodic;
 	cfg_req->enabledontfreebuffer = tim_ring->ena_dfb;
 	cfg_req->bucketsize = tim_ring->nb_bkts;
 	cfg_req->chunksize = tim_ring->chunk_sz;
@@ -568,7 +586,8 @@ otx2_tim_caps_get(const struct rte_eventdev *evdev, uint64_t flags,
 
 	/* Store evdev pointer for later use. */
 	dev->event_dev = (struct rte_eventdev *)(uintptr_t)evdev;
-	*caps = RTE_EVENT_TIMER_ADAPTER_CAP_INTERNAL_PORT;
+	*caps = RTE_EVENT_TIMER_ADAPTER_CAP_INTERNAL_PORT |
+		RTE_EVENT_TIMER_ADAPTER_CAP_PERIODIC;
 	*ops = &otx2_tim_ops;
 
 	return 0;
diff --git a/drivers/event/octeontx2/otx2_tim_evdev.h b/drivers/event/octeontx2/otx2_tim_evdev.h
index 44e3c7b51..82d116c09 100644
--- a/drivers/event/octeontx2/otx2_tim_evdev.h
+++ b/drivers/event/octeontx2/otx2_tim_evdev.h
@@ -155,6 +155,7 @@ struct otx2_tim_ring {
 	uint8_t disable_npa;
 	uint8_t optimized;
 	uint8_t ena_dfb;
+	uint8_t ena_periodic;
 	uint16_t ring_id;
 	uint32_t aura;
 	uint64_t nb_timers;
-- 
2.25.1


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [dpdk-dev] [PATCH v3 1/3] eventdev: introduce adapter flags for periodic mode
  2021-03-17  8:04     ` [dpdk-dev] [PATCH v3 1/3] eventdev: introduce adapter flags for periodic mode Shijith Thotton
@ 2021-03-17 18:07       ` Carrillo, Erik G
  2021-03-22  9:50         ` Jerin Jacob
  0 siblings, 1 reply; 23+ messages in thread
From: Carrillo, Erik G @ 2021-03-17 18:07 UTC (permalink / raw)
  To: Shijith Thotton; +Cc: Pavan Nikhilesh, Jerin Jacob, dev

> -----Original Message-----
> From: Shijith Thotton <sthotton@marvell.com>
> Sent: Wednesday, March 17, 2021 3:04 AM
> To: Carrillo, Erik G <erik.g.carrillo@intel.com>
> Cc: Shijith Thotton <sthotton@marvell.com>; Pavan Nikhilesh
> <pbhagavatula@marvell.com>; Jerin Jacob <jerinj@marvell.com>;
> dev@dpdk.org
> Subject: [PATCH v3 1/3] eventdev: introduce adapter flags for periodic mode
> 
> A timer adapter in periodic mode can be used to arm periodic timers.
> This patch adds flags used to advertise capability and configure timer adapter
> in periodic mode. Capability flag should be set for adapters which support
> periodic mode.
> 
> Below is a programming sequence on the usage:
> 	/* check for periodic mode support by reading capability. */
> 	rte_event_timer_adapter_caps_get(...);
> 
> 	/* create adapter in periodic mode by setting periodic flag
> 	   (RTE_EVENT_TIMER_ADAPTER_F_PERIODIC) and resolution. */
> 	rte_event_timer_adapter_create_ext(...);
> 
> 	/* arm periodic timer of configured resolution */
> 	rte_event_timer_arm_burst(...);
> 
> 	/* timer event will be periodically generated at configured
> 	   resolution till cancel is called. */
> 	while (running) { rte_event_dequeue_burst(...); }
> 
> 	/* cancel periodic timer which stops generating events */
> 	rte_event_timer_cancel_burst(...);
> 
> Signed-off-by: Shijith Thotton <sthotton@marvell.com>

Thanks, Shijith:

Acked-by: Erik Gabriel Carrillo <erik.g.carrillo@intel.com>

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [dpdk-dev] [PATCH v3 2/3] test/event: add unit tests for periodic timer
  2021-03-17  8:04     ` [dpdk-dev] [PATCH v3 2/3] test/event: add unit tests for periodic timer Shijith Thotton
@ 2021-03-17 18:11       ` Carrillo, Erik G
  0 siblings, 0 replies; 23+ messages in thread
From: Carrillo, Erik G @ 2021-03-17 18:11 UTC (permalink / raw)
  To: Shijith Thotton; +Cc: Pavan Nikhilesh, Jerin Jacob, dev

> -----Original Message-----
> From: Shijith Thotton <sthotton@marvell.com>
> Sent: Wednesday, March 17, 2021 3:04 AM
> To: Carrillo, Erik G <erik.g.carrillo@intel.com>
> Cc: Shijith Thotton <sthotton@marvell.com>; Pavan Nikhilesh
> <pbhagavatula@marvell.com>; Jerin Jacob <jerinj@marvell.com>;
> dev@dpdk.org
> Subject: [PATCH v3 2/3] test/event: add unit tests for periodic timer
> 
> Add tests to arm and cancel periodic timer.
> 
> Signed-off-by: Shijith Thotton <sthotton@marvell.com>

Thanks, Shijith:

Acked-by: Erik Gabriel Carrillo <erik.g.carrillo@intel.com>

BTW, the third patch looked good to me as well, but I'm not the maintainer for drivers/event/octeontx2/ so I'll refrain from acking there.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [dpdk-dev] [PATCH v3 3/3] event/octeontx2: add timer periodic mode support
  2021-03-17  8:04     ` [dpdk-dev] [PATCH v3 3/3] event/octeontx2: add timer periodic mode support Shijith Thotton
@ 2021-03-21 14:43       ` Pavan Nikhilesh Bhagavatula
  0 siblings, 0 replies; 23+ messages in thread
From: Pavan Nikhilesh Bhagavatula @ 2021-03-21 14:43 UTC (permalink / raw)
  To: Shijith Thotton, Erik Gabriel Carrillo; +Cc: Jerin Jacob Kollanukkaran, dev



>-----Original Message-----
>From: Shijith Thotton <sthotton@marvell.com>
>Sent: Wednesday, March 17, 2021 1:34 PM
>To: Erik Gabriel Carrillo <erik.g.carrillo@intel.com>
>Cc: Shijith Thotton <sthotton@marvell.com>; Pavan Nikhilesh
>Bhagavatula <pbhagavatula@marvell.com>; Jerin Jacob Kollanukkaran
><jerinj@marvell.com>; dev@dpdk.org
>Subject: [PATCH v3 3/3] event/octeontx2: add timer periodic mode
>support
>
>Add support for periodic mode in event timer adapter.
>
>Signed-off-by: Shijith Thotton <sthotton@marvell.com>

Acked-by: Pavan Nikhilesh <pbhagavatula@marvell.com>

>---
> drivers/event/octeontx2/otx2_tim_evdev.c | 29
>++++++++++++++++++++----
> drivers/event/octeontx2/otx2_tim_evdev.h |  1 +
> 2 files changed, 25 insertions(+), 5 deletions(-)
>
>diff --git a/drivers/event/octeontx2/otx2_tim_evdev.c
>b/drivers/event/octeontx2/otx2_tim_evdev.c
>index 4c24cc8a6..39a29f17f 100644
>--- a/drivers/event/octeontx2/otx2_tim_evdev.c
>+++ b/drivers/event/octeontx2/otx2_tim_evdev.c
>@@ -65,7 +65,8 @@ otx2_tim_ring_info_get(const struct
>rte_event_timer_adapter *adptr,
> 	struct otx2_tim_ring *tim_ring = adptr->data->adapter_priv;
>
> 	adptr_info->max_tmo_ns = tim_ring->max_tout;
>-	adptr_info->min_resolution_ns = tim_ring->tck_nsec;
>+	adptr_info->min_resolution_ns = tim_ring->ena_periodic ?
>+		tim_ring->max_tout : tim_ring->tck_nsec;
> 	rte_memcpy(&adptr_info->conf, &adptr->data->conf,
> 		   sizeof(struct rte_event_timer_adapter_conf));
> }
>@@ -163,7 +164,7 @@ tim_chnk_pool_create(struct otx2_tim_ring
>*tim_ring,
> 		}
> 		tim_ring->aura = npa_lf_aura_handle_to_aura(
> 				tim_ring->chunk_pool->pool_id);
>-		tim_ring->ena_dfb = 0;
>+		tim_ring->ena_dfb = tim_ring->ena_periodic ? 1 : 0;
> 	} else {
> 		tim_ring->chunk_pool =
>rte_mempool_create(pool_name,
> 				tim_ring->nb_chunks, tim_ring-
>>chunk_sz,
>@@ -254,6 +255,7 @@ otx2_tim_ring_create(struct
>rte_event_timer_adapter *adptr)
> 	struct tim_ring_req *free_req;
> 	struct tim_lf_alloc_req *req;
> 	struct tim_lf_alloc_rsp *rsp;
>+	uint8_t is_periodic;
> 	int i, rc;
>
> 	if (dev == NULL)
>@@ -284,6 +286,20 @@ otx2_tim_ring_create(struct
>rte_event_timer_adapter *adptr)
> 		}
> 	}
>
>+	is_periodic = 0;
>+	if (rcfg->flags & RTE_EVENT_TIMER_ADAPTER_F_PERIODIC) {
>+		if (rcfg->max_tmo_ns &&
>+		    rcfg->max_tmo_ns != rcfg->timer_tick_ns) {
>+			rc = -ERANGE;
>+			goto rng_mem_err;
>+		}
>+
>+		/* Use 2 buckets to avoid contention */
>+		rcfg->max_tmo_ns = rcfg->timer_tick_ns;
>+		rcfg->timer_tick_ns /= 2;
>+		is_periodic = 1;
>+	}
>+
> 	tim_ring = rte_zmalloc("otx2_tim_prv", sizeof(struct
>otx2_tim_ring), 0);
> 	if (tim_ring == NULL) {
> 		rc =  -ENOMEM;
>@@ -296,11 +312,13 @@ otx2_tim_ring_create(struct
>rte_event_timer_adapter *adptr)
> 	tim_ring->clk_src = (int)rcfg->clk_src;
> 	tim_ring->ring_id = adptr->data->id;
> 	tim_ring->tck_nsec = RTE_ALIGN_MUL_CEIL(rcfg-
>>timer_tick_ns, 10);
>-	tim_ring->max_tout = rcfg->max_tmo_ns;
>+	tim_ring->max_tout = is_periodic ?
>+		rcfg->timer_tick_ns * 2 : rcfg->max_tmo_ns;
> 	tim_ring->nb_bkts = (tim_ring->max_tout / tim_ring->tck_nsec);
> 	tim_ring->chunk_sz = dev->chunk_sz;
> 	tim_ring->nb_timers = rcfg->nb_timers;
> 	tim_ring->disable_npa = dev->disable_npa;
>+	tim_ring->ena_periodic = is_periodic;
> 	tim_ring->enable_stats = dev->enable_stats;
>
> 	for (i = 0; i < dev->ring_ctl_cnt ; i++) {
>@@ -348,7 +366,7 @@ otx2_tim_ring_create(struct
>rte_event_timer_adapter *adptr)
> 	cfg_req->ring = tim_ring->ring_id;
> 	cfg_req->bigendian = false;
> 	cfg_req->clocksource = tim_ring->clk_src;
>-	cfg_req->enableperiodic = false;
>+	cfg_req->enableperiodic = tim_ring->ena_periodic;
> 	cfg_req->enabledontfreebuffer = tim_ring->ena_dfb;
> 	cfg_req->bucketsize = tim_ring->nb_bkts;
> 	cfg_req->chunksize = tim_ring->chunk_sz;
>@@ -568,7 +586,8 @@ otx2_tim_caps_get(const struct rte_eventdev
>*evdev, uint64_t flags,
>
> 	/* Store evdev pointer for later use. */
> 	dev->event_dev = (struct rte_eventdev *)(uintptr_t)evdev;
>-	*caps = RTE_EVENT_TIMER_ADAPTER_CAP_INTERNAL_PORT;
>+	*caps = RTE_EVENT_TIMER_ADAPTER_CAP_INTERNAL_PORT |
>+		RTE_EVENT_TIMER_ADAPTER_CAP_PERIODIC;
> 	*ops = &otx2_tim_ops;
>
> 	return 0;
>diff --git a/drivers/event/octeontx2/otx2_tim_evdev.h
>b/drivers/event/octeontx2/otx2_tim_evdev.h
>index 44e3c7b51..82d116c09 100644
>--- a/drivers/event/octeontx2/otx2_tim_evdev.h
>+++ b/drivers/event/octeontx2/otx2_tim_evdev.h
>@@ -155,6 +155,7 @@ struct otx2_tim_ring {
> 	uint8_t disable_npa;
> 	uint8_t optimized;
> 	uint8_t ena_dfb;
>+	uint8_t ena_periodic;
> 	uint16_t ring_id;
> 	uint32_t aura;
> 	uint64_t nb_timers;
>--
>2.25.1


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [dpdk-dev] [PATCH v3 1/3] eventdev: introduce adapter flags for periodic mode
  2021-03-17 18:07       ` Carrillo, Erik G
@ 2021-03-22  9:50         ` Jerin Jacob
  0 siblings, 0 replies; 23+ messages in thread
From: Jerin Jacob @ 2021-03-22  9:50 UTC (permalink / raw)
  To: Carrillo, Erik G; +Cc: Shijith Thotton, Pavan Nikhilesh, Jerin Jacob, dev

On Wed, Mar 17, 2021 at 11:37 PM Carrillo, Erik G
<erik.g.carrillo@intel.com> wrote:
>
> > -----Original Message-----
> > From: Shijith Thotton <sthotton@marvell.com>
> > Sent: Wednesday, March 17, 2021 3:04 AM
> > To: Carrillo, Erik G <erik.g.carrillo@intel.com>
> > Cc: Shijith Thotton <sthotton@marvell.com>; Pavan Nikhilesh
> > <pbhagavatula@marvell.com>; Jerin Jacob <jerinj@marvell.com>;
> > dev@dpdk.org
> > Subject: [PATCH v3 1/3] eventdev: introduce adapter flags for periodic mode
> >
> > A timer adapter in periodic mode can be used to arm periodic timers.
> > This patch adds flags used to advertise capability and configure timer adapter
> > in periodic mode. Capability flag should be set for adapters which support
> > periodic mode.
> >
> > Below is a programming sequence on the usage:
> >       /* check for periodic mode support by reading capability. */
> >       rte_event_timer_adapter_caps_get(...);
> >
> >       /* create adapter in periodic mode by setting periodic flag
> >          (RTE_EVENT_TIMER_ADAPTER_F_PERIODIC) and resolution. */
> >       rte_event_timer_adapter_create_ext(...);
> >
> >       /* arm periodic timer of configured resolution */
> >       rte_event_timer_arm_burst(...);
> >
> >       /* timer event will be periodically generated at configured
> >          resolution till cancel is called. */
> >       while (running) { rte_event_dequeue_burst(...); }
> >
> >       /* cancel periodic timer which stops generating events */
> >       rte_event_timer_cancel_burst(...);
> >
> > Signed-off-by: Shijith Thotton <sthotton@marvell.com>
>
> Thanks, Shijith:
>
> Acked-by: Erik Gabriel Carrillo <erik.g.carrillo@intel.com>

Added following text in release notes in respective patches.

--
* **Introduced period timer mode in eventdev timer adapter.**

  * Added support for periodic timer mode in eventdev timer adapter.
  * Added support for periodic timer mode in octeontx2 event device driver.
--

Series Acked-by: Jerin Jacob <jerinj@marvell.com>
Applied to dpdk-next-net-eventdev/for-main. Thanks

^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2021-03-22  9:50 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-08 20:45 [dpdk-dev] [PATCH 0/3] periodic mode for event timer adapter Shijith Thotton
2021-03-08 20:45 ` [dpdk-dev] [PATCH 1/3] eventdev: introduce adapter flags for periodic mode Shijith Thotton
2021-03-09 20:04   ` Carrillo, Erik G
2021-03-10  9:14     ` Shijith Thotton
2021-03-11 20:47       ` Carrillo, Erik G
2021-03-12 15:30   ` Carrillo, Erik G
2021-03-14 16:49     ` Shijith Thotton
2021-03-08 20:45 ` [dpdk-dev] [PATCH 2/3] test/event: add unit tests for periodic timer Shijith Thotton
2021-03-08 20:45 ` [dpdk-dev] [PATCH 3/3] event/octeontx2: add timer periodic mode support Shijith Thotton
2021-03-14 16:45 ` [dpdk-dev] [PATCH v2 0/3] periodic mode for event timer adapter Shijith Thotton
2021-03-14 16:45   ` [dpdk-dev] [PATCH v2 1/3] eventdev: introduce adapter flags for periodic mode Shijith Thotton
2021-03-16 19:04     ` Carrillo, Erik G
2021-03-17  6:10       ` Shijith Thotton
2021-03-14 16:45   ` [dpdk-dev] [PATCH v2 2/3] test/event: add unit tests for periodic timer Shijith Thotton
2021-03-14 16:45   ` [dpdk-dev] [PATCH v2 3/3] event/octeontx2: add timer periodic mode support Shijith Thotton
2021-03-17  8:04   ` [dpdk-dev] [PATCH v3 0/3] periodic mode for event timer adapter Shijith Thotton
2021-03-17  8:04     ` [dpdk-dev] [PATCH v3 1/3] eventdev: introduce adapter flags for periodic mode Shijith Thotton
2021-03-17 18:07       ` Carrillo, Erik G
2021-03-22  9:50         ` Jerin Jacob
2021-03-17  8:04     ` [dpdk-dev] [PATCH v3 2/3] test/event: add unit tests for periodic timer Shijith Thotton
2021-03-17 18:11       ` Carrillo, Erik G
2021-03-17  8:04     ` [dpdk-dev] [PATCH v3 3/3] event/octeontx2: add timer periodic mode support Shijith Thotton
2021-03-21 14:43       ` Pavan Nikhilesh Bhagavatula

DPDK patches and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ https://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git