[dpdk-dev,v4] eventdev: add errno-style return values

Message ID 1489762288-4710-1-git-send-email-gage.eads@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Jerin Jacob
Headers

Checks

Context Check Description
ci/Intel-compilation success Compilation OK
ci/checkpatch success coding style OK

Commit Message

Eads, Gage March 17, 2017, 2:51 p.m. UTC
  From: "Eads, Gage" <gage.eads@intel.com>

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.

Signed-off-by: Gage Eads <gage.eads@intel.com>
---
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(-)
  

Comments

Jerin Jacob March 21, 2017, 11:06 a.m. UTC | #1
On Fri, Mar 17, 2017 at 09:51:28AM -0500, Gage Eads wrote:
> From: "Eads, Gage" <gage.eads@intel.com>
> 
> 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.
> 
> Signed-off-by: Gage Eads <gage.eads@intel.com>
> ---
> 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(-)
> 
> diff --git a/lib/librte_eventdev/rte_eventdev.h b/lib/librte_eventdev/rte_eventdev.h
> index 2b30a35..a45c81a 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 */
>  
> @@ -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.

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


>   * @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


> +	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
> -- 
> 2.7.4
>
  
Eads, Gage March 21, 2017, 8:38 p.m. UTC | #2
>  -----Original Message-----
>  From: Jerin Jacob [mailto:jerin.jacob@caviumnetworks.com]
>  Sent: Tuesday, March 21, 2017 6:06 AM
>  To: Eads, Gage <gage.eads@intel.com>
>  Cc: dev@dpdk.org; Richardson, Bruce <bruce.richardson@intel.com>;
>  hemant.agrawal@nxp.com; Van Haaren, Harry <harry.van.haaren@intel.com>;
>  nipun.gupta@nxp.com
>  Subject: Re: [PATCH v4] eventdev: add errno-style return values
>  
>  On Fri, Mar 17, 2017 at 09:51:28AM -0500, Gage Eads wrote:
>  > From: "Eads, Gage" <gage.eads@intel.com>
>  >
>  > 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.
>  >
>  > Signed-off-by: Gage Eads <gage.eads@intel.com>
>  > ---
>  > 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(-)
>  >
>  > diff --git a/lib/librte_eventdev/rte_eventdev.h
>  > b/lib/librte_eventdev/rte_eventdev.h
>  > index 2b30a35..a45c81a 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 */
>  >
>  > @@ -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.
>  
>  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.

>  
>  >   * @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
>  

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?
  
Jerin Jacob March 22, 2017, 6:53 a.m. UTC | #3
On Tue, Mar 21, 2017 at 08:38:25PM +0000, Eads, Gage wrote:
> 
> 
> >  -----Original Message-----
> >  From: Jerin Jacob [mailto:jerin.jacob@caviumnetworks.com]
> >  Sent: Tuesday, March 21, 2017 6:06 AM
> >  To: Eads, Gage <gage.eads@intel.com>
> >  Cc: dev@dpdk.org; Richardson, Bruce <bruce.richardson@intel.com>;
> >  hemant.agrawal@nxp.com; Van Haaren, Harry <harry.van.haaren@intel.com>;
> >  nipun.gupta@nxp.com
> >  Subject: Re: [PATCH v4] eventdev: add errno-style return values
> >  
> >  On Fri, Mar 17, 2017 at 09:51:28AM -0500, Gage Eads wrote:
> >  > From: "Eads, Gage" <gage.eads@intel.com>
> >  >
> >  > 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.
> >  >
> >  > Signed-off-by: Gage Eads <gage.eads@intel.com>
> >  > ---
> >  > 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(-)
> >  >
> >  > diff --git a/lib/librte_eventdev/rte_eventdev.h
> >  > b/lib/librte_eventdev/rte_eventdev.h
> >  > index 2b30a35..a45c81a 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 */
> >  >
> >  > @@ -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.
> >  
> >  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.
> 
> >  
> >  >   * @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
> >  
> 
> 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?

Looks good to me.
  

Patch

diff --git a/lib/librte_eventdev/rte_eventdev.h b/lib/librte_eventdev/rte_eventdev.h
index 2b30a35..a45c81a 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 */
 
@@ -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