Skip to contentSkip to conversation

eventdev: Add rte_errno return values to the enqueue and dequeue functions

PATCH Superseded Gage Eads 3 participants 22 messages Feb 10, 2017 – Mar 25, 2017

lore
Share & tools
lore

Gage Eads

author
#0 lore raw

PATCH 1/1 eventdev: Add rte_errno return values to the enqueue and dequeue functions

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.

---
 lib/librte_eventdev/rte_eventdev.h | 42 +++++++++++++++++++++++++++++++++++---
 1 file changed, 39 insertions(+), 3 deletions(-)
lib/librte_eventdev/rte_eventdev.h +39 -3
index c2f9310..ef21205 100644
@@ -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
Signature · 1 line
2.7.4
#1 lore raw
Quoted 9 lines · Gage Eads

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.

---

Do we have some idea of the performance hit from these? It may be too soon to know, given we don't have many drivers to test with, but if there is no perf hit seen with the SW driver, I think we should look to just always do this, rather than having it compile-time off. If it does prove to be a performance problem we can look to #ifdef it out later.

/Bruce

#2 lore raw
Quoted 8 lines · Bruce Richardson
Quoted 7 lines · Gage Eads

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.

Quoted 7 lines
Quoted 2 lines

---

Do we have some idea of the performance hit from these? It may be too soon to know, given we don't have many drivers to test with, but if there is no perf hit seen with the SW driver, I think we should look to just always do this, rather than having it compile-time off. If it does

IMO, It is better put to under compile-time like ethdev. It is difficult predict the performance regression on wide range of cores that DPDK runs now. I think we need to add following additional checks based on Gage header file change

1) Per event queue ID is valid or not?
2) Per event's sched type doesn't match the capabilities of the destination queue.

Quoted 3 lines

prove to be a performance problem we can look to #ifdef it out later.

/Bruce

#3 lore raw
Quoted 17 lines · Jerin Jacob
Quoted 8 lines · Bruce Richardson
Quoted 7 lines · Gage Eads

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.

Quoted 7 lines
Quoted 2 lines

---

Do we have some idea of the performance hit from these? It may be too soon to know, given we don't have many drivers to test with, but if there is no perf hit seen with the SW driver, I think we should look to just always do this, rather than having it compile-time off. If it does

Quoted 8 lines

IMO, It is better put to under compile-time like ethdev. It is difficult predict the performance regression on wide range of cores that DPDK runs now. I think we need to add following additional checks based on Gage header file change

1) Per event queue ID is valid or not?
2) Per event's sched type doesn't match the capabilities of the destination queue.

Ok, if we are expanding the number of checks then I definitely think it needs to be compile-time selected.

/Bruce

Quoted 4 lines
Quoted 4 lines

prove to be a performance problem we can look to #ifdef it out later.

/Bruce

author
#4 lore raw
Quoted 37 lines

-----Original Message-----
From: Richardson, Bruce
Sent: Monday, February 13, 2017 6:08 AM
To: Jerin Jacob <[email protected]>
Cc: Eads, Gage <[email protected]>; [email protected]; [email protected]; Van Haaren, Harry <[email protected]>; [email protected]
Subject: Re: [PATCH] eventdev: Add rte_errno return values to the enqueue and dequeue functions

Quoted 8 lines · Jerin Jacob
Quoted 7 lines · Bruce Richardson
Quoted 6 lines · Gage Eads

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.

Quoted 15 lines
Quoted 9 lines
Quoted 3 lines

---

Do we have some idea of the performance hit from these? It may be too soon to know, given we don't have many drivers to test with, but if there is no perf hit seen with the SW driver, I think we should look to just always do this, rather than having it compile-time off. If it does

IMO, It is better put to under compile-time like ethdev. It is difficult predict the performance regression on wide range of cores that DPDK runs now. I think we need to add following additional checks based on Gage header file change

Quoted 7 lines
Quoted 2 lines

1) Per event queue ID is valid or not?
2) Per event's sched type doesn't match the capabilities of the destination

queue.

Quoted 1 line

Ok, if we are expanding the number of checks then I definitely think it needs to be compile-time selected.

My thinking is that, unlike checking the dev ID or port ID, per-event checks should be in the PMD itself since (presumably) it will loop over the events anyway. I also think it makes sense for the per-event error checking not to be compile-time selectable because a PMD needs to handle the invalid queue ID or sched_type case anyway.

Quoted 6 lines

/Bruce

Quoted 4 lines
Quoted 4 lines

prove to be a performance problem we can look to #ifdef it out later.

/Bruce

#5 lore raw
In reply to Gage Eads
Quoted 11 lines · Gage Eads

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.

---
static inline uint16_t

lib/librte_eventdev/rte_eventdev.h rte_event_enqueue_burst(uint8_t dev_id, uint8_t port_id, · line 1136

Quoted 4 lines
lib/librte_eventdev/rte_eventdev.h +1 -0
@@ -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;

I don't think it is required. If at all required, move this under RTE_LIBRTE_EVENTDEV_DEBUG to save store to rte_errno cycles on fastpath

Quoted 42 lines
lib/librte_eventdev/rte_eventdev.h +29 -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
Signature · 1 line
2.7.4
author
#6 lore raw
Quoted 27 lines

-----Original Message-----
From: Jerin Jacob [mailto:[email protected]]
Sent: Monday, February 13, 2017 10:10 PM
To: Eads, Gage <[email protected]>
Cc: [email protected]; Richardson, Bruce <[email protected]>; [email protected]; Van Haaren, Harry <[email protected]>; [email protected]
Subject: Re: [PATCH] eventdev: Add rte_errno return values to the enqueue and dequeue functions

Quoted 14 lines · Gage Eads

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.

---
static inline uint16_t

lib/librte_eventdev/rte_eventdev.h +0 -0
@@ -1127,6 +1133,21 @@ rte_event_enqueue_burst(uint8_t dev_id, uint8_t
 port_id,  {
 	struct rte_eventdev *dev = &rte_eventdevs[dev_id];
 
Quoted 4 lines

Review rte_event_enqueue_burst(uint8_t dev_id, uint8_t · line 1136

Quoted 1 line
(quoted diff) +1 -0
+	rte_errno = 0;

I don't think it is required. If at all required, move this under RTE_LIBRTE_EVENTDEV_DEBUG to save store to rte_errno cycles on fastpath

Agreed -- if we encounter an error we should set rte_errno, otherwise the return value will equal nb_events and the user shouldn't check it.

Will fix in v2.

Quoted 43 lines
Quoted 43 lines
lib/librte_eventdev/rte_eventdev.h +29 -1
+#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

author
#7 lore raw

PATCH v2 1/1 eventdev: Add rte_errno return values to the enqueue and dequeue functions

In reply to Gage Eads

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.

---
Changes for v2:
- Remove rte_errno initialization

 lib/librte_eventdev/rte_eventdev.h | 40 +++++++++++++++++++++++++++++++++++---
 1 file changed, 37 insertions(+), 3 deletions(-)
lib/librte_eventdev/rte_eventdev.h +37 -3
index c2f9310..31d1e31 100644
@@ -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,20 @@ rte_event_enqueue_burst(uint8_t dev_id, uint8_t port_id,
 {
 	struct rte_eventdev *dev = &rte_eventdevs[dev_id];
 
+#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 +1255,20 @@ 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
+	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
Signature · 1 line
2.7.4
#8 lore raw
Quoted 6 lines · Gage Eads

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.

Please fix the checkpatch error.
http://dpdk.org/ml/archives/test-report/2017-February/010896.html

Quoted 26 lines

---
Changes for v2:
- Remove rte_errno initialization

 lib/librte_eventdev/rte_eventdev.h | 40 +++++++++++++++++++++++++++++++++++---
 1 file changed, 37 insertions(+), 3 deletions(-)
lib/librte_eventdev/rte_eventdev.h +1 -1
index c2f9310..31d1e31 100644
@@ -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

lib/librte_eventdev/rte_eventdev.h rte_event_schedule(uint8_t dev_id) · line 1127

Quoted 10 lines
lib/librte_eventdev/rte_eventdev.h +8 -2
- *   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.

If I understand it correctly, -ENOSPC comes only for closed systems not for open systems. IMO, It is worth to mention that -ENOSPC is valid only of closed systems.

lib/librte_eventdev/rte_eventdev.h rte_event_enqueue_burst(uint8_t dev_id, uint8_t port_id, · line 1136

Quoted 8 lines
lib/librte_eventdev/rte_eventdev.h +1 -0
  * @see rte_event_port_enqueue_depth()
  */
 static inline uint16_t
@@ -1127,6 +1133,20 @@ rte_event_enqueue_burst(uint8_t dev_id, uint8_t port_id,
 {
 	struct rte_eventdev *dev = &rte_eventdevs[dev_id];
 
+#ifdef RTE_LIBRTE_EVENTDEV_DEBUG

Please check with enabling RTE_LIBRTE_EVENTDEV_DEBUG. It has compilation errors.

In file included from /export/dpdk-next-eventdev/lib/librte_eventdev/rte_eventdev.c:61:0:
/export/dpdk-next-eventdev/lib/librte_eventdev/rte_eventdev.h: In function ‘rte_event_enqueue_burst’:
/export/dpdk-next-eventdev/lib/librte_eventdev/rte_eventdev.h:1139:40:
error: ‘RTE_EVENTDEV_DETACHED’ undeclared (first use in this function)

  if (rte_eventdevs[dev_id].attached == RTE_EVENTDEV_DETACHED) {
                                        ^

/export/dpdk-next-eventdev/lib/librte_eventdev/rte_eventdev.h:1139:40:
note: each undeclared identifier is reported only once for each function it appears in /export/dpdk-next-eventdev/lib/librte_eventdev/rte_eventdev.h:1140:3:
error: implicit declaration of function ‘RTE_EDEV_LOG_DEBUG’ [-Werror=implicit-function-declaration]
RTE_EDEV_LOG_DEBUG("Invalid dev_id=%d\n", dev_id);
^
/export/dpdk-next-eventdev/lib/librte_eventdev/rte_eventdev.h:1140:3:
error: nested extern declaration of ‘RTE_EDEV_LOG_DEBUG’ [-Werror=nested-externs]
In file included from /export/dpdk-next-eventdev/lib/librte_eventdev/rte_eventdev.c:61:0:
/export/dpdk-next-eventdev/lib/librte_eventdev/rte_eventdev.h: In function ‘rte_event_dequeue_burst’:
/export/dpdk-next-eventdev/lib/librte_eventdev/rte_eventdev.h:1263:40:
error: ‘RTE_EVENTDEV_DETACHED’ undeclared (first use in this function)
if (rte_eventdevs[dev_id].attached == RTE_EVENTDEV_DETACHED) {

Quoted 40 lines
lib/librte_eventdev/rte_eventdev.h +27 -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
@@ -1235,6 +1255,20 @@ 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
+	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
Signature · 1 line
2.7.4
author
#9 lore raw

PATCH v3 1/1 eventdev: add errno-style return values

In reply to Gage Eads

This commit adds rte_errno return values to rte_event_enqueue_burst() and rte_event_dequeue_burst().

These return values 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.

---
Changes for v2:
- Remove rte_errno initialization
Changes for v3:
- Fix checkpatch and check-git-log.sh errors

 lib/librte_eventdev/rte_eventdev.h | 42 +++++++++++++++++++++++++++++++++++---
 1 file changed, 39 insertions(+), 3 deletions(-)
lib/librte_eventdev/rte_eventdev.h +39 -3
index 2b30a35..3e54b27 100644
@@ -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 */
 
@@ -1118,9 +1119,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
@@ -1129,6 +1135,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
@@ -1239,6 +1260,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
Signature · 1 line
2.7.4
#10 lore raw

Re: [PATCH v3] eventdev: add errno-style return values

Quoted 37 lines · Gage Eads

This commit adds rte_errno return values to rte_event_enqueue_burst() and rte_event_dequeue_burst().

These return values 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.

---
Changes for v2:
- Remove rte_errno initialization
Changes for v3:
- Fix checkpatch and check-git-log.sh errors

 lib/librte_eventdev/rte_eventdev.h | 42 +++++++++++++++++++++++++++++++++++---
 1 file changed, 39 insertions(+), 3 deletions(-)
lib/librte_eventdev/rte_eventdev.h +1 -1
index 2b30a35..3e54b27 100644
@@ -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 */
 
@@ -1118,9 +1119,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

lib/librte_eventdev/rte_eventdev.h rte_event_schedule(uint8_t dev_id) · line 1129

Quoted 10 lines
lib/librte_eventdev/rte_eventdev.h +8 -2
- *   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.

Please check the review comments of v2
http://dpdk.org/ml/archives/dev/2017-March/060352.html

lib/librte_eventdev/rte_eventdev.h rte_event_enqueue_burst(uint8_t dev_id, uint8_t port_id, · line 1138

Quoted 8 lines
lib/librte_eventdev/rte_eventdev.h +1 -0
  * @see rte_event_port_enqueue_depth()
  */
 static inline uint16_t
@@ -1129,6 +1135,21 @@ rte_event_enqueue_burst(uint8_t dev_id, uint8_t port_id,
 {
 	struct rte_eventdev *dev = &rte_eventdevs[dev_id];
 
+	rte_errno = 0;

Why rte_errno = 0 is not in RTE_LIBRTE_EVENTDEV_DEBUG now in v3?

lib/librte_eventdev/rte_eventdev.h rte_event_enqueue_burst(uint8_t dev_id, uint8_t port_id, · line 1139

Quoted 1 line
lib/librte_eventdev/rte_eventdev.h +1 -0
+#ifdef RTE_LIBRTE_EVENTDEV_DEBUG

Please check the review comments of v2
http://dpdk.org/ml/archives/dev/2017-March/060352.html

It still fails.

n file included from /export/dpdk-next-eventdev/lib/librte_eventdev/rte_eventdev.c:61:0:
/export/dpdk-next-eventdev/lib/librte_eventdev/rte_eventdev.h: In function ‘rte_event_enqueue_burst’:
/export/dpdk-next-eventdev/lib/librte_eventdev/rte_eventdev.h:1140:40:
error: ‘RTE_EVENTDEV_DETACHED’ undeclared (first use in this function)

  if (rte_eventdevs[dev_id].attached == RTE_EVENTDEV_DETACHED) {
                                        ^

/export/dpdk-next-eventdev/lib/librte_eventdev/rte_eventdev.h:1140:40:
note: each undeclared identifier is reported only once for each function it appears in /export/dpdk-next-eventdev/lib/librte_eventdev/rte_eventdev.h:1141:3:
error: implicit declaration of function ‘RTE_EDEV_LOG_DEBUG’ [-Werror=implicit-function-declaration]
RTE_EDEV_LOG_DEBUG("Invalid dev_id=%d\n", dev_id);
^

Quoted 41 lines
lib/librte_eventdev/rte_eventdev.h +28 -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
@@ -1239,6 +1260,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
Signature · 1 line
2.7.4
author
#11 lore raw

Re: [PATCH v3] eventdev: add errno-style return values

Ah, sorry about that! I revised the v1 patch, not the v2 patch. I'll fix and resubmit.

Quoted 145 lines

-----Original Message-----
From: Jerin Jacob [mailto:[email protected]]
Sent: Thursday, March 16, 2017 10:11 PM
To: Eads, Gage <[email protected]>
Cc: [email protected]; Richardson, Bruce <[email protected]>; [email protected]; Van Haaren, Harry <[email protected]>; [email protected]
Subject: Re: [PATCH v3] eventdev: add errno-style return values

Quoted 37 lines · Gage Eads

This commit adds rte_errno return values to rte_event_enqueue_burst() and rte_event_dequeue_burst().

These return values 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.

---
Changes for v2:
- Remove rte_errno initialization
Changes for v3:
- Fix checkpatch and check-git-log.sh errors

 lib/librte_eventdev/rte_eventdev.h | 42
+++++++++++++++++++++++++++++++++++---
 1 file changed, 39 insertions(+), 3 deletions(-)
lib/librte_eventdev/rte_eventdev.h +1 -0
index 2b30a35..3e54b27 100644
@@ -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 */

lib/librte_eventdev/rte_eventdev.h rte_event_schedule(uint8_t dev_id) · line 1120

Quoted 2 lines
lib/librte_eventdev/rte_eventdev.h +0 -0
@@ -1118,9 +1119,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

lib/librte_eventdev/rte_eventdev.h rte_event_schedule(uint8_t dev_id) · line 1121

Quoted 2 lines
lib/librte_eventdev/rte_eventdev.h +0 -1
  *   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

lib/librte_eventdev/rte_eventdev.h rte_event_schedule(uint8_t dev_id) · line 1122

Quoted 1 line
lib/librte_eventdev/rte_eventdev.h +0 -1
- *   at the end of ev[] are not consumed,and the caller has to take care of

them

lib/librte_eventdev/rte_eventdev.h rte_event_schedule(uint8_t dev_id)

Quoted 3 lines
lib/librte_eventdev/rte_eventdev.h +2 -1
- *
+ *   *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

lib/librte_eventdev/rte_eventdev.h rte_event_schedule(uint8_t dev_id) · line 1129

Quoted 6 lines
lib/librte_eventdev/rte_eventdev.h +6 -0
+ *   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.

Please check the review comments of v2
http://dpdk.org/ml/archives/dev/2017-March/060352.html

lib/librte_eventdev/rte_eventdev.h rte_event_enqueue_burst(uint8_t dev_id, uint8_t · line 1138

Quoted 8 lines
lib/librte_eventdev/rte_eventdev.h +1 -0
  * @see rte_event_port_enqueue_depth()
  */
 static inline uint16_t
@@ -1129,6 +1135,21 @@ rte_event_enqueue_burst(uint8_t dev_id, uint8_t
 port_id,  {
 	struct rte_eventdev *dev = &rte_eventdevs[dev_id];
 
+	rte_errno = 0;

Why rte_errno = 0 is not in RTE_LIBRTE_EVENTDEV_DEBUG now in v3?

lib/librte_eventdev/rte_eventdev.h rte_event_enqueue_burst(uint8_t dev_id, uint8_t · line 1139

Quoted 1 line
lib/librte_eventdev/rte_eventdev.h +1 -0
+#ifdef RTE_LIBRTE_EVENTDEV_DEBUG

Please check the review comments of v2
http://dpdk.org/ml/archives/dev/2017-March/060352.html

It still fails.

n file included from /export/dpdk-next-eventdev/lib/librte_eventdev/rte_eventdev.c:61:0:
/export/dpdk-next-eventdev/lib/librte_eventdev/rte_eventdev.h: In function ‘rte_event_enqueue_burst’:
/export/dpdk-next-eventdev/lib/librte_eventdev/rte_eventdev.h:1140:40:
error: ‘RTE_EVENTDEV_DETACHED’ undeclared (first use in this function)

   if (rte_eventdevs[dev_id].attached == RTE_EVENTDEV_DETACHED) {
                                         ^
 /export/dpdk-next-eventdev/lib/librte_eventdev/rte_eventdev.h:1140:40:
 note: each undeclared identifier is reported only once for each function it
 appears in
 /export/dpdk-next-eventdev/lib/librte_eventdev/rte_eventdev.h:1141:3:
 error: implicit declaration of function ‘RTE_EDEV_LOG_DEBUG’
 [-Werror=implicit-function-declaration]
    RTE_EDEV_LOG_DEBUG("Invalid dev_id=%d\n", dev_id);
    ^
Quoted 41 lines
lib/librte_eventdev/rte_eventdev.h +28 -1
+	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
@@ -1239,6 +1260,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

author
#12 lore raw

PATCH v4 1/1 eventdev: add errno-style return values

In reply to Gage Eads

From: "Eads, Gage" <[email protected]>

This commit adds rte_errno return values to rte_event_enqueue_burst() and rte_event_dequeue_burst().

These return values 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.

---
Changes for v2:
- Remove rte_errno initialization
Changes for v3:
- Fix checkpatch and check-git-log.sh errors
Changes for v4:
- v3 was incorrectly based on v1, v4 is instead based on v2's changes

 lib/librte_eventdev/rte_eventdev.h | 40 +++++++++++++++++++++++++++++++++++---
 1 file changed, 37 insertions(+), 3 deletions(-)
lib/librte_eventdev/rte_eventdev.h +37 -3
index 2b30a35..a45c81a 100644
@@ -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 */
 
@@ -1118,9 +1119,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
@@ -1129,6 +1135,20 @@ rte_event_enqueue_burst(uint8_t dev_id, uint8_t port_id,
 {
 	struct rte_eventdev *dev = &rte_eventdevs[dev_id];
 
+#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
@@ -1239,6 +1259,20 @@ 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
+	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
Signature · 1 line
2.7.4
#13 lore raw

Re: [PATCH v4] eventdev: add errno-style return values

Quoted 41 lines · Gage Eads

From: "Eads, Gage" <[email protected]>

This commit adds rte_errno return values to rte_event_enqueue_burst() and rte_event_dequeue_burst().

These return values 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.

---
Changes for v2:
- Remove rte_errno initialization
Changes for v3:
- Fix checkpatch and check-git-log.sh errors
Changes for v4:
- v3 was incorrectly based on v1, v4 is instead based on v2's changes

 lib/librte_eventdev/rte_eventdev.h | 40 +++++++++++++++++++++++++++++++++++---
 1 file changed, 37 insertions(+), 3 deletions(-)
lib/librte_eventdev/rte_eventdev.h +1 -1
index 2b30a35..a45c81a 100644
@@ -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 */
 
@@ -1118,9 +1119,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

lib/librte_eventdev/rte_eventdev.h rte_event_schedule(uint8_t dev_id) · line 1129

Quoted 10 lines
lib/librte_eventdev/rte_eventdev.h +8 -2
- *   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.

Some reason you haven't addressed the comments in v2.i.e add a note that -ENOSPC applicable only for *closed system*

http://dpdk.org/ml/archives/dev/2017-March/060352.html

lib/librte_eventdev/rte_eventdev.h rte_event_enqueue_burst(uint8_t dev_id, uint8_t port_id, · line 1138

Quoted 8 lines
lib/librte_eventdev/rte_eventdev.h +1 -0
  * @see rte_event_port_enqueue_depth()
  */
 static inline uint16_t
@@ -1129,6 +1135,20 @@ rte_event_enqueue_burst(uint8_t dev_id, uint8_t port_id,
 {
 	struct rte_eventdev *dev = &rte_eventdevs[dev_id];
 
+#ifdef RTE_LIBRTE_EVENTDEV_DEBUG

Some reason you haven't addressed the comments in v2.i.e Not fixed the build issue.
http://dpdk.org/ml/archives/dev/2017-March/060352.html

You can reproduce it by setting CONFIG_RTE_LIBRTE_EVENTDEV_DEBUG=y in common config.

We have two approaches to fix it
1/ Pollute lib/librte_eventdev/rte_eventdev.h header with implementation specific header files

Or

2/ Have neat pmd debug common function in rte_eventdev_pmd.h.Let all PMD driver call it by including rte_eventdev_pmd.h

Quoted 40 lines
lib/librte_eventdev/rte_eventdev.h +27 -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
@@ -1239,6 +1259,20 @@ 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
+	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
Signature · 1 line
2.7.4
author
#14 lore raw

Re: [PATCH v4] eventdev: add errno-style return values

Quoted 72 lines

-----Original Message-----
From: Jerin Jacob [mailto:[email protected]]
Sent: Tuesday, March 21, 2017 6:06 AM
To: Eads, Gage <[email protected]>
Cc: [email protected]; Richardson, Bruce <[email protected]>; [email protected]; Van Haaren, Harry <[email protected]>; [email protected]
Subject: Re: [PATCH v4] eventdev: add errno-style return values

Quoted 41 lines · Gage Eads

From: "Eads, Gage" <[email protected]>

This commit adds rte_errno return values to rte_event_enqueue_burst() and rte_event_dequeue_burst().

These return values 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.

---
Changes for v2:
- Remove rte_errno initialization
Changes for v3:
- Fix checkpatch and check-git-log.sh errors Changes for v4:
- v3 was incorrectly based on v1, v4 is instead based on v2's
changes

 lib/librte_eventdev/rte_eventdev.h | 40
+++++++++++++++++++++++++++++++++++---
 1 file changed, 37 insertions(+), 3 deletions(-)
lib/librte_eventdev/rte_eventdev.h +1 -0
index 2b30a35..a45c81a 100644
@@ -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 */

lib/librte_eventdev/rte_eventdev.h rte_event_schedule(uint8_t dev_id) · line 1120

Quoted 2 lines
lib/librte_eventdev/rte_eventdev.h +0 -0
@@ -1118,9 +1119,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

lib/librte_eventdev/rte_eventdev.h rte_event_schedule(uint8_t dev_id) · line 1121

Quoted 2 lines
lib/librte_eventdev/rte_eventdev.h +0 -1
  *   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

lib/librte_eventdev/rte_eventdev.h rte_event_schedule(uint8_t dev_id) · line 1122

Quoted 1 line
lib/librte_eventdev/rte_eventdev.h +0 -1
- *   at the end of ev[] are not consumed,and the caller has to take care of

them

lib/librte_eventdev/rte_eventdev.h rte_event_schedule(uint8_t dev_id)

Quoted 3 lines
lib/librte_eventdev/rte_eventdev.h +2 -1
- *
+ *   *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

lib/librte_eventdev/rte_eventdev.h rte_event_schedule(uint8_t dev_id) · line 1129

Quoted 6 lines
lib/librte_eventdev/rte_eventdev.h +6 -0
+ *   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.
Quoted 5 lines

Some reason you haven't addressed the comments in v2.i.e add a note that - ENOSPC applicable only for *closed system*

http://dpdk.org/ml/archives/dev/2017-March/060352.html

Will fix.

Quoted 17 lines

lib/librte_eventdev/rte_eventdev.h rte_event_enqueue_burst(uint8_t dev_id, uint8_t · line 1138

Quoted 9 lines
lib/librte_eventdev/rte_eventdev.h +1 -0
  * @see rte_event_port_enqueue_depth()
  */
 static inline uint16_t
@@ -1129,6 +1135,20 @@ rte_event_enqueue_burst(uint8_t dev_id, uint8_t
 port_id,  {
 	struct rte_eventdev *dev = &rte_eventdevs[dev_id];
 
+#ifdef RTE_LIBRTE_EVENTDEV_DEBUG

Some reason you haven't addressed the comments in v2.i.e Not fixed the build issue.
http://dpdk.org/ml/archives/dev/2017-March/060352.html

You can reproduce it by setting CONFIG_RTE_LIBRTE_EVENTDEV_DEBUG=y in common config.

Quoted 9 lines

We have two approaches to fix it
1/ Pollute lib/librte_eventdev/rte_eventdev.h header with implementation specific header files

Or

2/ Have neat pmd debug common function in rte_eventdev_pmd.h.Let all PMD driver call it by including rte_eventdev_pmd.h

I'd prefer to avoid the issue by dropping the debug message and RTE_EVENTDEV_DETACHED, like so:

#ifdef RTE_LIBRTE_EVENTDEV_DEBUG
        if (dev_id >= RTE_EVENT_MAX_DEVS || !rte_eventdevs[dev_id].attached) {
                rte_errno = -EINVAL;
                return 0;
        }

        if (port_id >= dev->data->nb_ports) {
                rte_errno = -EINVAL;
                return 0;
        }

#endif

What do you think?

#15 lore raw

Re: [PATCH v4] eventdev: add errno-style return values

Quoted 119 lines · Gage
Quoted 72 lines

-----Original Message-----
From: Jerin Jacob [mailto:[email protected]]
Sent: Tuesday, March 21, 2017 6:06 AM
To: Eads, Gage <[email protected]>
Cc: [email protected]; Richardson, Bruce <[email protected]>; [email protected]; Van Haaren, Harry <[email protected]>; [email protected]
Subject: Re: [PATCH v4] eventdev: add errno-style return values

Quoted 41 lines · Gage Eads

From: "Eads, Gage" <[email protected]>

This commit adds rte_errno return values to rte_event_enqueue_burst() and rte_event_dequeue_burst().

These return values 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.

---
Changes for v2:
- Remove rte_errno initialization
Changes for v3:
- Fix checkpatch and check-git-log.sh errors Changes for v4:
- v3 was incorrectly based on v1, v4 is instead based on v2's
changes

 lib/librte_eventdev/rte_eventdev.h | 40
+++++++++++++++++++++++++++++++++++---
 1 file changed, 37 insertions(+), 3 deletions(-)
lib/librte_eventdev/rte_eventdev.h +1 -0
index 2b30a35..a45c81a 100644
@@ -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 */

lib/librte_eventdev/rte_eventdev.h rte_event_schedule(uint8_t dev_id) · line 1120

Quoted 2 lines
lib/librte_eventdev/rte_eventdev.h +0 -0
@@ -1118,9 +1119,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

lib/librte_eventdev/rte_eventdev.h rte_event_schedule(uint8_t dev_id) · line 1121

Quoted 2 lines
lib/librte_eventdev/rte_eventdev.h +0 -1
  *   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

lib/librte_eventdev/rte_eventdev.h rte_event_schedule(uint8_t dev_id) · line 1122

Quoted 1 line
lib/librte_eventdev/rte_eventdev.h +0 -1
- *   at the end of ev[] are not consumed,and the caller has to take care of

them

lib/librte_eventdev/rte_eventdev.h rte_event_schedule(uint8_t dev_id)

Quoted 3 lines
lib/librte_eventdev/rte_eventdev.h +2 -1
- *
+ *   *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

lib/librte_eventdev/rte_eventdev.h rte_event_schedule(uint8_t dev_id) · line 1129

Quoted 6 lines
lib/librte_eventdev/rte_eventdev.h +6 -0
+ *   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.
Quoted 5 lines

Some reason you haven't addressed the comments in v2.i.e add a note that - ENOSPC applicable only for *closed system*

http://dpdk.org/ml/archives/dev/2017-March/060352.html

Will fix.

Quoted 17 lines

lib/librte_eventdev/rte_eventdev.h rte_event_enqueue_burst(uint8_t dev_id, uint8_t · line 1138

Quoted 9 lines
lib/librte_eventdev/rte_eventdev.h +1 -0
  * @see rte_event_port_enqueue_depth()
  */
 static inline uint16_t
@@ -1129,6 +1135,20 @@ rte_event_enqueue_burst(uint8_t dev_id, uint8_t
 port_id,  {
 	struct rte_eventdev *dev = &rte_eventdevs[dev_id];
 
+#ifdef RTE_LIBRTE_EVENTDEV_DEBUG

Some reason you haven't addressed the comments in v2.i.e Not fixed the build issue.
http://dpdk.org/ml/archives/dev/2017-March/060352.html

You can reproduce it by setting CONFIG_RTE_LIBRTE_EVENTDEV_DEBUG=y in common config.

Quoted 9 lines

We have two approaches to fix it
1/ Pollute lib/librte_eventdev/rte_eventdev.h header with implementation specific header files

Or

2/ Have neat pmd debug common function in rte_eventdev_pmd.h.Let all PMD driver call it by including rte_eventdev_pmd.h

I'd prefer to avoid the issue by dropping the debug message and RTE_EVENTDEV_DETACHED, like so:

#ifdef RTE_LIBRTE_EVENTDEV_DEBUG
        if (dev_id >= RTE_EVENT_MAX_DEVS || !rte_eventdevs[dev_id].attached) {
                rte_errno = -EINVAL;
                return 0;
        }

        if (port_id >= dev->data->nb_ports) {
                rte_errno = -EINVAL;
                return 0;
        }
Quoted 3 lines

#endif

What do you think?

Looks good to me.

author
#16 lore raw

PATCH v5 1/1 eventdev: add errno-style return values

In reply to Gage Eads

From: "Eads, Gage" <[email protected]>

This commit adds rte_errno return values to rte_event_enqueue_burst() and rte_event_dequeue_burst().

These return values 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.

---
Changes for v2:
- Remove rte_errno initialization
Changes for v3:
- Fix checkpatch and check-git-log.sh errors
Changes for v4:
- v3 was incorrectly based on v1, v4 is instead based on v2's changes
Changes for v5:
- Clarify -ENOSPC description and fix compilation errors

 lib/librte_eventdev/rte_eventdev.h | 37 ++++++++++++++++++++++++++++++++++---
 1 file changed, 34 insertions(+), 3 deletions(-)
lib/librte_eventdev/rte_eventdev.h +34 -3
index 2b30a35..b450622 100644
@@ -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 */
 
@@ -1118,9 +1119,15 @@ 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. This error code is only applicable to
+ *              closed systems.
  * @see rte_event_port_enqueue_depth()
  */
 static inline uint16_t
@@ -1129,6 +1136,18 @@ rte_event_enqueue_burst(uint8_t dev_id, uint8_t port_id,
 {
 	struct rte_eventdev *dev = &rte_eventdevs[dev_id];
 
+#ifdef RTE_LIBRTE_EVENTDEV_DEBUG
+	if (dev_id >= RTE_EVENT_MAX_DEVS || !rte_eventdevs[dev_id].attached) {
+		rte_errno = -EINVAL;
+		return 0;
+	}
+
+	if (port_id >= dev->data->nb_ports) {
+		rte_errno = -EINVAL;
+		return 0;
+	}
+#endif
+
 	/*
 	 * Allow zero cost non burst mode routine invocation if application
 	 * requests nb_events as const one
@@ -1239,6 +1258,18 @@ 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
+	if (dev_id >= RTE_EVENT_MAX_DEVS || !rte_eventdevs[dev_id].attached) {
+		rte_errno = -EINVAL;
+		return 0;
+	}
+
+	if (port_id >= dev->data->nb_ports) {
+		rte_errno = -EINVAL;
+		return 0;
+	}
+#endif
+
 	/*
 	 * Allow zero cost non burst mode routine invocation if application
 	 * requests nb_events as const one
Signature · 1 line
2.7.4
Acked-by on v5 1/1
#17 lore raw

Re: [PATCH v5] eventdev: add errno-style return values

Quoted 44 lines · Gage Eads

From: "Eads, Gage" <[email protected]>

This commit adds rte_errno return values to rte_event_enqueue_burst() and rte_event_dequeue_burst().

These return values 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.

---
Changes for v2:
- Remove rte_errno initialization
Changes for v3:
- Fix checkpatch and check-git-log.sh errors
Changes for v4:
- v3 was incorrectly based on v1, v4 is instead based on v2's changes
Changes for v5:
- Clarify -ENOSPC description and fix compilation errors

 lib/librte_eventdev/rte_eventdev.h | 37 ++++++++++++++++++++++++++++++++++---
 1 file changed, 34 insertions(+), 3 deletions(-)
lib/librte_eventdev/rte_eventdev.h +1 -2
index 2b30a35..b450622 100644
@@ -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 */
 
@@ -1118,9 +1119,15 @@ 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

lib/librte_eventdev/rte_eventdev.h rte_event_schedule(uint8_t dev_id) · line 1130

Quoted 10 lines
lib/librte_eventdev/rte_eventdev.h +9 -1
- *
+ *   *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. This error code is only applicable to
+ *              closed systems.

EINVAL and ENOSPC section is not rendering correctly in HTML doc. Please find below the fix.

You can use "make doc-api-html" command to verify the HTML rendering.

- *   -(-EINVAL) The port ID is invalid, device ID is invalid, an event's queue
+ *   - -EINVAL The port ID is invalid, device ID is invalid, an event's queue
- *   -(-ENOSPC) The event port was backpressured and unable to enqueue
+ *   - -ENOSPC The event port was backpressured and unable to enqueue

lib/librte_eventdev/rte_eventdev.h rte_event_enqueue_burst(uint8_t dev_id, uint8_t port_id, · line 1140

Quoted 9 lines
lib/librte_eventdev/rte_eventdev.h +2 -0
  * @see rte_event_port_enqueue_depth()
  */
 static inline uint16_t
@@ -1129,6 +1136,18 @@ rte_event_enqueue_burst(uint8_t dev_id, uint8_t port_id,
 {
 	struct rte_eventdev *dev = &rte_eventdevs[dev_id];
 
+#ifdef RTE_LIBRTE_EVENTDEV_DEBUG
+	if (dev_id >= RTE_EVENT_MAX_DEVS || !rte_eventdevs[dev_id].attached) {

Just to make .attached in sync with implementation, may we can we move RTE_EVENTDEV_DETACHED and RTE_EVENTDEV_ATTACHED to rte_eventdev.h.

No strong opinion on this.

(quoted diff) +0 -0

b/lib/librte_eventdev/rte_eventdev.h
index b450622..a6ba89b 100644

lib/librte_eventdev/rte_eventdev.h +2 -0
@@ -1066,6 +1066,8 @@ struct rte_eventdev {
        /**< Driver for this device */
 
        RTE_STD_C11
+#define RTE_EVENTDEV_DETACHED  (0)
+#define RTE_EVENTDEV_ATTACHED  (1)
        uint8_t attached : 1;
 
 

With proposed documentation changes,

Quoted 34 lines
lib/librte_eventdev/rte_eventdev.h +21 -0
+		return 0;
+	}
+
+	if (port_id >= dev->data->nb_ports) {
+		rte_errno = -EINVAL;
+		return 0;
+	}
+#endif
+
 	/*
 	 * Allow zero cost non burst mode routine invocation if application
 	 * requests nb_events as const one
@@ -1239,6 +1258,18 @@ 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
+	if (dev_id >= RTE_EVENT_MAX_DEVS || !rte_eventdevs[dev_id].attached) {
+		rte_errno = -EINVAL;
+		return 0;
+	}
+
+	if (port_id >= dev->data->nb_ports) {
+		rte_errno = -EINVAL;
+		return 0;
+	}
+#endif
+
 	/*
 	 * Allow zero cost non burst mode routine invocation if application
 	 * requests nb_events as const one
Signature · 1 line
2.7.4
author
#18 lore raw

Re: [PATCH v5] eventdev: add errno-style return values

Thanks! Good catch on the html guide. I submitted v6, leaving the "attached" code as is.

Thanks,
Gage

author
#19 lore raw

PATCH v6 1/1 eventdev: add errno-style return values

In reply to Gage Eads

From: "Eads, Gage" <[email protected]>

This commit adds rte_errno return values to rte_event_enqueue_burst() and rte_event_dequeue_burst().

These return values 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.

---
Changes for v2:
- Remove rte_errno initialization
Changes for v3:
- Fix checkpatch and check-git-log.sh errors
Changes for v4:
- v3 was incorrectly based on v1, v4 is instead based on v2's changes
Changes for v5:
- Clarify -ENOSPC description and fix compilation errors
Changes for v6:
- Fixed html doc rendering of bullet points for errno values

 lib/librte_eventdev/rte_eventdev.h | 37 ++++++++++++++++++++++++++++++++++---
 1 file changed, 34 insertions(+), 3 deletions(-)
lib/librte_eventdev/rte_eventdev.h +34 -3
index 5ce2f33..9971937 100644
@@ -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 */
 
@@ -1119,9 +1120,15 @@ 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. This error code is only applicable to
+ *              closed systems.
  * @see rte_event_port_enqueue_depth()
  */
 static inline uint16_t
@@ -1130,6 +1137,18 @@ rte_event_enqueue_burst(uint8_t dev_id, uint8_t port_id,
 {
 	struct rte_eventdev *dev = &rte_eventdevs[dev_id];
 
+#ifdef RTE_LIBRTE_EVENTDEV_DEBUG
+	if (dev_id >= RTE_EVENT_MAX_DEVS || !rte_eventdevs[dev_id].attached) {
+		rte_errno = -EINVAL;
+		return 0;
+	}
+
+	if (port_id >= dev->data->nb_ports) {
+		rte_errno = -EINVAL;
+		return 0;
+	}
+#endif
+
 	/*
 	 * Allow zero cost non burst mode routine invocation if application
 	 * requests nb_events as const one
@@ -1240,6 +1259,18 @@ 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
+	if (dev_id >= RTE_EVENT_MAX_DEVS || !rte_eventdevs[dev_id].attached) {
+		rte_errno = -EINVAL;
+		return 0;
+	}
+
+	if (port_id >= dev->data->nb_ports) {
+		rte_errno = -EINVAL;
+		return 0;
+	}
+#endif
+
 	/*
 	 * Allow zero cost non burst mode routine invocation if application
 	 * requests nb_events as const one
Signature · 1 line
2.7.4
Acked-by on v6 1/1
#20 lore raw

Re: [PATCH v6] eventdev: add errno-style return values

Quoted 5 lines · Gage Eads

From: "Eads, Gage" <[email protected]>

This commit adds rte_errno return values to rte_event_enqueue_burst() and rte_event_dequeue_burst().

Quoted 8 lines

These return values 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.

Quoted 87 lines

---
Changes for v2:
- Remove rte_errno initialization
Changes for v3:
- Fix checkpatch and check-git-log.sh errors
Changes for v4:
- v3 was incorrectly based on v1, v4 is instead based on v2's changes
Changes for v5:
- Clarify -ENOSPC description and fix compilation errors
Changes for v6:
- Fixed html doc rendering of bullet points for errno values

 lib/librte_eventdev/rte_eventdev.h | 37 ++++++++++++++++++++++++++++++++++---
 1 file changed, 34 insertions(+), 3 deletions(-)
lib/librte_eventdev/rte_eventdev.h +34 -3
index 5ce2f33..9971937 100644
@@ -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 */
 
@@ -1119,9 +1120,15 @@ 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. This error code is only applicable to
+ *              closed systems.
  * @see rte_event_port_enqueue_depth()
  */
 static inline uint16_t
@@ -1130,6 +1137,18 @@ rte_event_enqueue_burst(uint8_t dev_id, uint8_t port_id,
 {
 	struct rte_eventdev *dev = &rte_eventdevs[dev_id];
 
+#ifdef RTE_LIBRTE_EVENTDEV_DEBUG
+	if (dev_id >= RTE_EVENT_MAX_DEVS || !rte_eventdevs[dev_id].attached) {
+		rte_errno = -EINVAL;
+		return 0;
+	}
+
+	if (port_id >= dev->data->nb_ports) {
+		rte_errno = -EINVAL;
+		return 0;
+	}
+#endif
+
 	/*
 	 * Allow zero cost non burst mode routine invocation if application
 	 * requests nb_events as const one
@@ -1240,6 +1259,18 @@ 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
+	if (dev_id >= RTE_EVENT_MAX_DEVS || !rte_eventdevs[dev_id].attached) {
+		rte_errno = -EINVAL;
+		return 0;
+	}
+
+	if (port_id >= dev->data->nb_ports) {
+		rte_errno = -EINVAL;
+		return 0;
+	}
+#endif
+
 	/*
 	 * Allow zero cost non burst mode routine invocation if application
 	 * requests nb_events as const one
Signature · 1 line
2.7.4
Applied
#21 lore raw

Re: [PATCH v6] eventdev: add errno-style return values

Quoted 10 lines · Jerin Jacob
Quoted 9 lines · Gage Eads

From: "Eads, Gage" <[email protected]>

This commit adds rte_errno return values to rte_event_enqueue_burst() and rte_event_dequeue_burst().

These return values 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.

Quoted 6 lines
Quoted 4 lines

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

Applied to dpdk-next-eventdev/master. Thanks.

Quoted 88 lines
Quoted 88 lines

---
Changes for v2:
- Remove rte_errno initialization
Changes for v3:
- Fix checkpatch and check-git-log.sh errors
Changes for v4:
- v3 was incorrectly based on v1, v4 is instead based on v2's changes
Changes for v5:
- Clarify -ENOSPC description and fix compilation errors
Changes for v6:
- Fixed html doc rendering of bullet points for errno values

 lib/librte_eventdev/rte_eventdev.h | 37 ++++++++++++++++++++++++++++++++++---
 1 file changed, 34 insertions(+), 3 deletions(-)
lib/librte_eventdev/rte_eventdev.h +34 -3
index 5ce2f33..9971937 100644
@@ -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 */
 
@@ -1119,9 +1120,15 @@ 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. This error code is only applicable to
+ *              closed systems.
  * @see rte_event_port_enqueue_depth()
  */
 static inline uint16_t
@@ -1130,6 +1137,18 @@ rte_event_enqueue_burst(uint8_t dev_id, uint8_t port_id,
 {
 	struct rte_eventdev *dev = &rte_eventdevs[dev_id];
 
+#ifdef RTE_LIBRTE_EVENTDEV_DEBUG
+	if (dev_id >= RTE_EVENT_MAX_DEVS || !rte_eventdevs[dev_id].attached) {
+		rte_errno = -EINVAL;
+		return 0;
+	}
+
+	if (port_id >= dev->data->nb_ports) {
+		rte_errno = -EINVAL;
+		return 0;
+	}
+#endif
+
 	/*
 	 * Allow zero cost non burst mode routine invocation if application
 	 * requests nb_events as const one
@@ -1240,6 +1259,18 @@ 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
+	if (dev_id >= RTE_EVENT_MAX_DEVS || !rte_eventdevs[dev_id].attached) {
+		rte_errno = -EINVAL;
+		return 0;
+	}
+
+	if (port_id >= dev->data->nb_ports) {
+		rte_errno = -EINVAL;
+		return 0;
+	}
+#endif
+
 	/*
 	 * Allow zero cost non burst mode routine invocation if application
 	 * requests nb_events as const one
Signature · 1 line
2.7.4