DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] eventdev: set rte errno in port link/unlink functions
@ 2017-11-14 22:44 Gage Eads
  2017-12-04  3:06 ` Jerin Jacob
  0 siblings, 1 reply; 3+ messages in thread
From: Gage Eads @ 2017-11-14 22:44 UTC (permalink / raw)
  To: dev
  Cc: jerin.jacob, harry.van.haaren, bruce.richardson, hemant.agrawal,
	nipun.gupta, santosh.shukla, pbhagavatula

The return value for rte_event_port_{link, unlink}() is defined as the
"number of {links, unlinks} actually established." However, the eventdev
layer's error checking returns negative error values. This commit aligns
the eventdev code with the API definition by having it set rte_errno and
return 0 if it detects an error.

Fixes: 4f0804bbdfb9 ("eventdev: implement the northbound APIs")

Signed-off-by: Gage Eads <gage.eads@intel.com>
---
 lib/librte_eventdev/rte_eventdev.c     | 36 ++++++++++++++++++++++++----------
 lib/librte_eventdev/rte_eventdev_pmd.h |  8 ++++++++
 2 files changed, 34 insertions(+), 10 deletions(-)

diff --git a/lib/librte_eventdev/rte_eventdev.c b/lib/librte_eventdev/rte_eventdev.c
index 378ccb5..f000b80 100644
--- a/lib/librte_eventdev/rte_eventdev.c
+++ b/lib/librte_eventdev/rte_eventdev.c
@@ -830,13 +830,19 @@ rte_event_port_link(uint8_t dev_id, uint8_t port_id,
 	uint16_t *links_map;
 	int i, diag;
 
-	RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
+	RTE_EVENTDEV_VALID_DEVID_OR_ERRNO_RET(dev_id, -EINVAL, 0);
 	dev = &rte_eventdevs[dev_id];
-	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->port_link, -ENOTSUP);
+
+	if (*dev->dev_ops->port_link == NULL) {
+		RTE_PMD_DEBUG_TRACE("Function not supported\n");
+		rte_errno = -ENOTSUP;
+		return 0;
+	}
 
 	if (!is_valid_port(dev, port_id)) {
 		RTE_EDEV_LOG_ERR("Invalid port_id=%" PRIu8, port_id);
-		return -EINVAL;
+		rte_errno = -EINVAL;
+		return 0;
 	}
 
 	if (queues == NULL) {
@@ -855,8 +861,10 @@ rte_event_port_link(uint8_t dev_id, uint8_t port_id,
 	}
 
 	for (i = 0; i < nb_links; i++)
-		if (queues[i] >= dev->data->nb_queues)
-			return -EINVAL;
+		if (queues[i] >= dev->data->nb_queues) {
+			rte_errno = -EINVAL;
+			return 0;
+		}
 
 	diag = (*dev->dev_ops->port_link)(dev, dev->data->ports[port_id],
 						queues, priorities, nb_links);
@@ -881,13 +889,19 @@ rte_event_port_unlink(uint8_t dev_id, uint8_t port_id,
 	int i, diag;
 	uint16_t *links_map;
 
-	RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
+	RTE_EVENTDEV_VALID_DEVID_OR_ERRNO_RET(dev_id, -EINVAL, 0);
 	dev = &rte_eventdevs[dev_id];
-	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->port_unlink, -ENOTSUP);
+
+	if (*dev->dev_ops->port_unlink == NULL) {
+		RTE_PMD_DEBUG_TRACE("Function not supported\n");
+		rte_errno = -ENOTSUP;
+		return 0;
+	}
 
 	if (!is_valid_port(dev, port_id)) {
 		RTE_EDEV_LOG_ERR("Invalid port_id=%" PRIu8, port_id);
-		return -EINVAL;
+		rte_errno = -EINVAL;
+		return 0;
 	}
 
 	if (queues == NULL) {
@@ -898,8 +912,10 @@ rte_event_port_unlink(uint8_t dev_id, uint8_t port_id,
 	}
 
 	for (i = 0; i < nb_unlinks; i++)
-		if (queues[i] >= dev->data->nb_queues)
-			return -EINVAL;
+		if (queues[i] >= dev->data->nb_queues) {
+			rte_errno = -EINVAL;
+			return 0;
+		}
 
 	diag = (*dev->dev_ops->port_unlink)(dev, dev->data->ports[port_id],
 					queues, nb_unlinks);
diff --git a/lib/librte_eventdev/rte_eventdev_pmd.h b/lib/librte_eventdev/rte_eventdev_pmd.h
index 4369d9b..4016fef 100644
--- a/lib/librte_eventdev/rte_eventdev_pmd.h
+++ b/lib/librte_eventdev/rte_eventdev_pmd.h
@@ -76,6 +76,14 @@ extern "C" {
 	} \
 } while (0)
 
+#define RTE_EVENTDEV_VALID_DEVID_OR_ERRNO_RET(dev_id, errno, retval) do { \
+	if (!rte_event_pmd_is_valid_dev((dev_id))) { \
+		RTE_EDEV_LOG_ERR("Invalid dev_id=%d\n", dev_id); \
+		rte_errno = errno; \
+		return retval; \
+	} \
+} while (0)
+
 #define RTE_EVENTDEV_VALID_DEVID_OR_RET(dev_id) do { \
 	if (!rte_event_pmd_is_valid_dev((dev_id))) { \
 		RTE_EDEV_LOG_ERR("Invalid dev_id=%d\n", dev_id); \
-- 
2.7.4

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

* Re: [dpdk-dev] [PATCH] eventdev: set rte errno in port link/unlink functions
  2017-11-14 22:44 [dpdk-dev] [PATCH] eventdev: set rte errno in port link/unlink functions Gage Eads
@ 2017-12-04  3:06 ` Jerin Jacob
  2017-12-04  5:12   ` Jerin Jacob
  0 siblings, 1 reply; 3+ messages in thread
From: Jerin Jacob @ 2017-12-04  3:06 UTC (permalink / raw)
  To: Gage Eads
  Cc: dev, harry.van.haaren, bruce.richardson, hemant.agrawal,
	nipun.gupta, santosh.shukla, pbhagavatula

-----Original Message-----
> Date: Tue, 14 Nov 2017 16:44:10 -0600
> From: Gage Eads <gage.eads@intel.com>
> To: dev@dpdk.org
> CC: jerin.jacob@caviumnetworks.com, harry.van.haaren@intel.com,
>  bruce.richardson@intel.com, hemant.agrawal@nxp.com, nipun.gupta@nxp.com,
>  santosh.shukla@caviumnetworks.com, pbhagavatula@caviumnetworks.com
> Subject: [PATCH] eventdev: set rte errno in port link/unlink functions
> X-Mailer: git-send-email 2.7.4
> 
> The return value for rte_event_port_{link, unlink}() is defined as the
> "number of {links, unlinks} actually established." However, the eventdev
> layer's error checking returns negative error values. This commit aligns
> the eventdev code with the API definition by having it set rte_errno and
> return 0 if it detects an error.
> 
> Fixes: 4f0804bbdfb9 ("eventdev: implement the northbound APIs")
> 
> Signed-off-by: Gage Eads <gage.eads@intel.com>

Acked-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>

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

* Re: [dpdk-dev] [PATCH] eventdev: set rte errno in port link/unlink functions
  2017-12-04  3:06 ` Jerin Jacob
@ 2017-12-04  5:12   ` Jerin Jacob
  0 siblings, 0 replies; 3+ messages in thread
From: Jerin Jacob @ 2017-12-04  5:12 UTC (permalink / raw)
  To: Gage Eads
  Cc: dev, harry.van.haaren, bruce.richardson, hemant.agrawal,
	nipun.gupta, santosh.shukla, pbhagavatula

-----Original Message-----
> Date: Mon, 4 Dec 2017 08:36:20 +0530
> From: Jerin Jacob <jerin.jacob@caviumnetworks.com>
> To: Gage Eads <gage.eads@intel.com>
> CC: dev@dpdk.org, harry.van.haaren@intel.com, bruce.richardson@intel.com,
>  hemant.agrawal@nxp.com, nipun.gupta@nxp.com,
>  santosh.shukla@caviumnetworks.com, pbhagavatula@caviumnetworks.com
> Subject: Re: [dpdk-dev] [PATCH] eventdev: set rte errno in port link/unlink
>  functions
> User-Agent: Mutt/1.9.1 (2017-09-22)
> 
> -----Original Message-----
> > Date: Tue, 14 Nov 2017 16:44:10 -0600
> > From: Gage Eads <gage.eads@intel.com>
> > To: dev@dpdk.org
> > CC: jerin.jacob@caviumnetworks.com, harry.van.haaren@intel.com,
> >  bruce.richardson@intel.com, hemant.agrawal@nxp.com, nipun.gupta@nxp.com,
> >  santosh.shukla@caviumnetworks.com, pbhagavatula@caviumnetworks.com
> > Subject: [PATCH] eventdev: set rte errno in port link/unlink functions
> > X-Mailer: git-send-email 2.7.4
> > 
> > The return value for rte_event_port_{link, unlink}() is defined as the
> > "number of {links, unlinks} actually established." However, the eventdev
> > layer's error checking returns negative error values. This commit aligns
> > the eventdev code with the API definition by having it set rte_errno and
> > return 0 if it detects an error.
> > 
> > Fixes: 4f0804bbdfb9 ("eventdev: implement the northbound APIs")
> > 
> > Signed-off-by: Gage Eads <gage.eads@intel.com>
> 
> Acked-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>

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

> 

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

end of thread, other threads:[~2017-12-04  5:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-14 22:44 [dpdk-dev] [PATCH] eventdev: set rte errno in port link/unlink functions Gage Eads
2017-12-04  3:06 ` Jerin Jacob
2017-12-04  5:12   ` Jerin Jacob

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).