All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] eventdev: Add rte_errno return values to the enqueue and dequeue functions
@ 2017-02-10 21:02 Gage Eads
  2017-02-13 10:38 ` Bruce Richardson
                   ` (2 more replies)
  0 siblings, 3 replies; 22+ messages in thread
From: Gage Eads @ 2017-02-10 21:02 UTC (permalink / raw)
  To: dev
  Cc: jerin.jacob, bruce.richardson, hemant.agrawal, harry.van.haaren,
	nipun.gupta

This change allows user software to differentiate between an invalid argument
(such as an invalid queue_id or sched_type in an enqueued event) and
backpressure from the event device.

The port and device ID checks are placed in RTE_LIBRTE_EVENTDEV_DEBUG header
guards to avoid the performance hit in non-debug execution.

Signed-off-by: Gage Eads <gage.eads@intel.com>
---
 lib/librte_eventdev/rte_eventdev.h | 42 +++++++++++++++++++++++++++++++++++---
 1 file changed, 39 insertions(+), 3 deletions(-)

diff --git a/lib/librte_eventdev/rte_eventdev.h b/lib/librte_eventdev/rte_eventdev.h
index c2f9310..ef21205 100644
--- a/lib/librte_eventdev/rte_eventdev.h
+++ b/lib/librte_eventdev/rte_eventdev.h
@@ -245,6 +245,7 @@ extern "C" {
 
 #include <rte_common.h>
 #include <rte_memory.h>
+#include <rte_errno.h>
 
 struct rte_mbuf; /* we just use mbuf pointers; no need to include rte_mbuf.h */
 
@@ -1116,9 +1117,14 @@ rte_event_schedule(uint8_t dev_id)
  *   The number of event objects actually enqueued on the event device. The
  *   return value can be less than the value of the *nb_events* parameter when
  *   the event devices queue is full or if invalid parameters are specified in a
- *   *rte_event*. If return value is less than *nb_events*, the remaining events
- *   at the end of ev[] are not consumed,and the caller has to take care of them
- *
+ *   *rte_event*. If the return value is less than *nb_events*, the remaining
+ *   events at the end of ev[] are not consumed and the caller has to take care
+ *   of them, and rte_errno is set accordingly. Possible errno values include:
+ *   -(-EINVAL) The port ID is invalid, device ID is invalid, an event's queue
+ *              ID is invalid, or an event's sched type doesn't match the
+ *              capabilities of the destination queue.
+ *   -(-ENOSPC) The event port was backpressured and unable to enqueue
+ *              one or more events.
  * @see rte_event_port_enqueue_depth()
  */
 static inline uint16_t
@@ -1127,6 +1133,21 @@ rte_event_enqueue_burst(uint8_t dev_id, uint8_t port_id,
 {
 	struct rte_eventdev *dev = &rte_eventdevs[dev_id];
 
+	rte_errno = 0;
+#ifdef RTE_LIBRTE_EVENTDEV_DEBUG
+	if (rte_eventdevs[dev_id].attached == RTE_EVENTDEV_DETACHED) {
+		RTE_EDEV_LOG_DEBUG("Invalid dev_id=%d\n", dev_id);
+		rte_errno = -EINVAL;
+		return 0;
+	}
+
+	if (port_id >= dev->data->nb_ports) {
+		RTE_EDEV_LOG_DEBUG("Invalid port_id=%d\n", port_id);
+		rte_errno = -EINVAL;
+		return 0;
+	}
+#endif
+
 	/*
 	 * Allow zero cost non burst mode routine invocation if application
 	 * requests nb_events as const one
@@ -1235,6 +1256,21 @@ rte_event_dequeue_burst(uint8_t dev_id, uint8_t port_id, struct rte_event ev[],
 {
 	struct rte_eventdev *dev = &rte_eventdevs[dev_id];
 
+#ifdef RTE_LIBRTE_EVENTDEV_DEBUG
+	rte_errno = 0;
+	if (rte_eventdevs[dev_id].attached == RTE_EVENTDEV_DETACHED) {
+		RTE_EDEV_LOG_DEBUG("Invalid dev_id=%d\n", dev_id);
+		rte_errno = -EINVAL;
+		return 0;
+	}
+
+	if (port_id >= dev->data->nb_ports) {
+		RTE_EDEV_LOG_DEBUG("Invalid port_id=%d\n", port_id);
+		rte_errno = -EINVAL;
+		return 0;
+	}
+#endif
+
 	/*
 	 * Allow zero cost non burst mode routine invocation if application
 	 * requests nb_events as const one
-- 
2.7.4

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

end of thread, other threads:[~2017-03-25  5:11 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-10 21:02 [PATCH] eventdev: Add rte_errno return values to the enqueue and dequeue functions Gage Eads
2017-02-13 10:38 ` Bruce Richardson
2017-02-13 11:48   ` Jerin Jacob
2017-02-13 12:08     ` Bruce Richardson
2017-02-13 16:05       ` Eads, Gage
2017-02-14  4:10 ` Jerin Jacob
2017-02-15  0:14   ` Eads, Gage
2017-02-15 17:09 ` [PATCH v2] " Gage Eads
2017-03-16 10:28   ` Jerin Jacob
2017-03-16 20:12   ` [PATCH v3] eventdev: add errno-style return values Gage Eads
2017-03-17  3:10     ` Jerin Jacob
2017-03-17 14:34       ` Eads, Gage
2017-03-17 14:51     ` [PATCH v4] " Gage Eads
2017-03-21 11:06       ` Jerin Jacob
2017-03-21 20:38         ` Eads, Gage
2017-03-22  6:53           ` Jerin Jacob
2017-03-22 14:58       ` [PATCH v5] " Gage Eads
2017-03-22 17:17         ` Jerin Jacob
2017-03-23 22:32           ` Eads, Gage
2017-03-23 22:30         ` [PATCH v6] " Gage Eads
2017-03-24  2:38           ` Jerin Jacob
2017-03-25  5:11             ` Jerin Jacob

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.