[dpdk-dev] [PATCH v6 18/23] eventtimer: add non-blocking mode for event timer operations

Erik Gabriel Carrillo erik.g.carrillo at intel.com
Thu Jan 11 01:21:09 CET 2018


Add a mode to the event timer adapter that allows the event timer arm
and cancel APIs to return immediately, rather than waiting for the service
to update the state of each timer.

Signed-off-by: Erik Gabriel Carrillo <erik.g.carrillo at intel.com>
---
 lib/librte_eventdev/rte_event_timer_adapter.c | 69 ++++++++++++++-------------
 lib/librte_eventdev/rte_event_timer_adapter.h |  6 +++
 2 files changed, 43 insertions(+), 32 deletions(-)

diff --git a/lib/librte_eventdev/rte_event_timer_adapter.c b/lib/librte_eventdev/rte_event_timer_adapter.c
index 0af68b2..624cc36 100644
--- a/lib/librte_eventdev/rte_event_timer_adapter.c
+++ b/lib/librte_eventdev/rte_event_timer_adapter.c
@@ -1022,28 +1022,31 @@ __sw_event_timer_arm_burst(const struct rte_event_timer_adapter *adapter,
 				     nb_evtims - n);
 	}
 
-	for (i = 0; i < n; i++) {
-		/* Wait until state is updated */
-		while (evtims[i]->state == RTE_EVENT_TIMER_NOT_ARMED ||
-		       evtims[i]->state == RTE_EVENT_TIMER_CANCELED)
-			;
-
-		/* Note any failures */
-		if (evtims[i]->state != RTE_EVENT_TIMER_ARMED) {
-			fails[nb_fails++] = i;
-			rte_errno = EINVAL;
-		}
+	if (!(adapter->data->conf.flags & RTE_EVENT_TIMER_ADAPTER_F_NB_ARM)) {
+		for (i = 0; i < n; i++) {
+			/* Wait until state is updated */
+			while (evtims[i]->state == RTE_EVENT_TIMER_NOT_ARMED ||
+			       evtims[i]->state == RTE_EVENT_TIMER_CANCELED)
+				;
+
+			/* Note any failures */
+			if (evtims[i]->state != RTE_EVENT_TIMER_ARMED) {
+				fails[nb_fails++] = i;
+				rte_errno = EINVAL;
+			}
 
-		/* TODO: handle the case of consecutive arm requests;  the
-		 * second request can erroneously see success from the first
-		 */
-	}
+			/* TODO: handle the case of consecutive arm requests;
+			 * the second request can erroneously see success from
+			 * the first
+			 */
+		}
 
-	/* Move the failures to the end of the array */
-	for (i = 0, mark = n - 1; i < nb_fails; i++, mark--)
-		swap(evtims, fails[i], mark);
+		/* Move the failures to the end of the array */
+		for (i = 0, mark = n - 1; i < nb_fails; i++, mark--)
+			swap(evtims, fails[i], mark);
 
-	n = mark + 1;
+		n = mark + 1;
+	}
 
 	return n;
 }
@@ -1093,23 +1096,25 @@ sw_event_timer_cancel_burst(const struct rte_event_timer_adapter *adapter,
 		rte_mempool_put_bulk(sw_data->msg_pool, (void **)&msgs[n],
 				     nb_evtims - n);
 
-	for (i = 0; i < n; i++) {
-		/* Wait until state is updated */
-		while (evtims[i]->state == RTE_EVENT_TIMER_ARMED)
-			;
+	if (!(adapter->data->conf.flags & RTE_EVENT_TIMER_ADAPTER_F_NB_ARM)) {
+		for (i = 0; i < n; i++) {
+			/* Wait until state is updated */
+			while (evtims[i]->state == RTE_EVENT_TIMER_ARMED)
+				;
 
-		/* Note any failures */
-		if (evtims[i]->state != RTE_EVENT_TIMER_CANCELED) {
-			fails[nb_fails++] = i;
-			rte_errno = EINVAL;
+			/* Note any failures */
+			if (evtims[i]->state != RTE_EVENT_TIMER_CANCELED) {
+				fails[nb_fails++] = i;
+				rte_errno = EINVAL;
+			}
 		}
-	}
 
-	/* Move the failures to the end of the array */
-	for (i = 0, mark = n - 1; i < nb_fails; i++, mark--)
-		swap(evtims, fails[i], mark);
+		/* Move the failures to the end of the array */
+		for (i = 0, mark = n - 1; i < nb_fails; i++, mark--)
+			swap(evtims, fails[i], mark);
 
-	n = mark + 1;
+		n = mark + 1;
+	}
 
 	return n;
 }
diff --git a/lib/librte_eventdev/rte_event_timer_adapter.h b/lib/librte_eventdev/rte_event_timer_adapter.h
index a4b16a7..2a69455 100644
--- a/lib/librte_eventdev/rte_event_timer_adapter.h
+++ b/lib/librte_eventdev/rte_event_timer_adapter.h
@@ -175,6 +175,12 @@ enum rte_event_timer_adapter_clk_src {
  *
  * @see struct rte_event_timer_adapter_conf::flags
  */
+#define RTE_EVENT_TIMER_ADAPTER_F_NB_ARM	(1ULL << 2)
+/**< ``rte_event_timer_arm_burst()`` API to be used in non-blocking/
+ * asynchronous mode
+ *
+ * @see struct rte_event_timer_adapter_conf::flags
+ */
 
 /**
  * @warning
-- 
2.6.4



More information about the dev mailing list