[dpdk-dev] eventdev: use links_map to unlink queues

Message ID 20171211150528.13236-1-pbhagavatula@caviumnetworks.com (mailing list archive)
State Superseded, archived
Headers

Checks

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

Commit Message

Pavan Nikhilesh Dec. 11, 2017, 3:05 p.m. UTC
  The octeontx event device doesn't store the queues to port mapping as a result
it cannot return the exact number of queues unlinked from a port when
application wants to unlink all the queues mapped (supplies queues param as
NULL).

Using links_map we can determine the exact queues mapped to a specific port and
unlink them.

Signed-off-by: Pavan Nikhilesh <pbhagavatula@caviumnetworks.com>
---
 lib/librte_eventdev/rte_eventdev.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
  

Comments

Eads, Gage Dec. 11, 2017, 5:24 p.m. UTC | #1
> -----Original Message-----
> From: Pavan Nikhilesh [mailto:pbhagavatula@caviumnetworks.com]
> Sent: Monday, December 11, 2017 9:05 AM
> To: Eads, Gage <gage.eads@intel.com>; jerin.jacob@caviumnetworks.com;
> Richardson, Bruce <bruce.richardson@intel.com>; nipun.gupta@nxp.com;
> santosh.shukla@caviumnetworks.com; Van Haaren, Harry
> <harry.van.haaren@intel.com>; hemant.agrawal@nxp.com
> Cc: dev@dpdk.org; Pavan Nikhilesh <pbhagavatula@caviumnetworks.com>
> Subject: [dpdk-dev] [PATCH] eventdev: use links_map to unlink queues
> 
> The octeontx event device doesn't store the queues to port mapping as a result
> it cannot return the exact number of queues unlinked from a port when
> application wants to unlink all the queues mapped (supplies queues param as
> NULL).
> 
> Using links_map we can determine the exact queues mapped to a specific port
> and unlink them.
> 
> Signed-off-by: Pavan Nikhilesh <pbhagavatula@caviumnetworks.com>
> ---
>  lib/librte_eventdev/rte_eventdev.c | 15 ++++++++++++++-
>  1 file changed, 14 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/librte_eventdev/rte_eventdev.c
> b/lib/librte_eventdev/rte_eventdev.c
> index e0c2a78..e17f8fc 100644
> --- a/lib/librte_eventdev/rte_eventdev.c
> +++ b/lib/librte_eventdev/rte_eventdev.c
> @@ -888,7 +888,8 @@ rte_event_port_unlink(uint8_t dev_id, uint8_t port_id,  {
>  	struct rte_eventdev *dev;
>  	uint8_t all_queues[RTE_EVENT_MAX_QUEUES_PER_DEV];
> -	int i, diag;
> +	uint8_t linked_queues[RTE_EVENT_MAX_QUEUES_PER_DEV];
> +	int i, diag, j;
>  	uint16_t *links_map;
> 
>  	RTE_EVENTDEV_VALID_DEVID_OR_ERRNO_RET(dev_id, -EINVAL, 0);
> @@ -918,6 +919,18 @@ rte_event_port_unlink(uint8_t dev_id, uint8_t port_id,
>  			rte_errno = -EINVAL;
>  			return 0;
>  		}
> +	j = 0;
> +	links_map = dev->data->links_map;
> +	links_map += (port_id * RTE_EVENT_MAX_QUEUES_PER_DEV);
> +	for (i = 0; i < nb_unlinks; i++) {
> +		if (links_map[queues[i]] !=
> +				EVENT_QUEUE_SERVICE_PRIORITY_INVALID) {
> +			linked_queues[j] = queues[i];
> +			j++;
> +		}
> +	}
> +	queues = linked_queues;
> +	nb_unlinks = j;

Consider the following case where queues is non-NULL: nb_unlinks = 3, queues = [0, 5, 2], and queue 5 is not linked to the port.

This new code block will unlink queues 0 and 2, and the function will return 2. However the documentation states that "if the return value is less than *nb_unlinks*, the remaining queues at the end of queues[] are not established", so a return value of 2 would imply that queues 0 and 5 were unlinked, but queue 2 was not.

Perhaps this code could be moved to the "if (queues == NULL)" block, and in its place you can update nb_unlinks like so to handle the non-NULL queues case:

	links_map = dev->data->links_map;
	links_map += (port_id * RTE_EVENT_MAX_QUEUES_PER_DEV);
	for (i = 0; i < nb_unlinks; i++) {
		if (links_map[queues[i]] !=
				EVENT_QUEUE_SERVICE_PRIORITY_INVALID)
			break;
	}
	nb_unlinks = i;

Thanks,
Gage
  
Pavan Nikhilesh Dec. 12, 2017, 7:23 a.m. UTC | #2
On Mon, Dec 11, 2017 at 05:24:57PM +0000, Eads, Gage wrote:
>
> > -----Original Message-----
> > From: Pavan Nikhilesh [mailto:pbhagavatula@caviumnetworks.com]
> > Sent: Monday, December 11, 2017 9:05 AM
> > To: Eads, Gage <gage.eads@intel.com>; jerin.jacob@caviumnetworks.com;
> > Richardson, Bruce <bruce.richardson@intel.com>; nipun.gupta@nxp.com;
> > santosh.shukla@caviumnetworks.com; Van Haaren, Harry
> > <harry.van.haaren@intel.com>; hemant.agrawal@nxp.com
> > Cc: dev@dpdk.org; Pavan Nikhilesh <pbhagavatula@caviumnetworks.com>
> > Subject: [dpdk-dev] [PATCH] eventdev: use links_map to unlink queues
> >
> > The octeontx event device doesn't store the queues to port mapping as a result
> > it cannot return the exact number of queues unlinked from a port when
> > application wants to unlink all the queues mapped (supplies queues param as
> > NULL).
> >
> > Using links_map we can determine the exact queues mapped to a specific port
> > and unlink them.
> >
> > Signed-off-by: Pavan Nikhilesh <pbhagavatula@caviumnetworks.com>
> > ---
> >  lib/librte_eventdev/rte_eventdev.c | 15 ++++++++++++++-
> >  1 file changed, 14 insertions(+), 1 deletion(-)
> >
> > diff --git a/lib/librte_eventdev/rte_eventdev.c
> > b/lib/librte_eventdev/rte_eventdev.c
> > index e0c2a78..e17f8fc 100644
> > --- a/lib/librte_eventdev/rte_eventdev.c
> > +++ b/lib/librte_eventdev/rte_eventdev.c
> > @@ -888,7 +888,8 @@ rte_event_port_unlink(uint8_t dev_id, uint8_t port_id,  {
> >  	struct rte_eventdev *dev;
> >  	uint8_t all_queues[RTE_EVENT_MAX_QUEUES_PER_DEV];
> > -	int i, diag;
> > +	uint8_t linked_queues[RTE_EVENT_MAX_QUEUES_PER_DEV];
> > +	int i, diag, j;
> >  	uint16_t *links_map;
> >
> >  	RTE_EVENTDEV_VALID_DEVID_OR_ERRNO_RET(dev_id, -EINVAL, 0);
> > @@ -918,6 +919,18 @@ rte_event_port_unlink(uint8_t dev_id, uint8_t port_id,
> >  			rte_errno = -EINVAL;
> >  			return 0;
> >  		}
> > +	j = 0;
> > +	links_map = dev->data->links_map;
> > +	links_map += (port_id * RTE_EVENT_MAX_QUEUES_PER_DEV);
> > +	for (i = 0; i < nb_unlinks; i++) {
> > +		if (links_map[queues[i]] !=
> > +				EVENT_QUEUE_SERVICE_PRIORITY_INVALID) {
> > +			linked_queues[j] = queues[i];
> > +			j++;
> > +		}
> > +	}
> > +	queues = linked_queues;
> > +	nb_unlinks = j;
>
> Consider the following case where queues is non-NULL: nb_unlinks = 3, queues = [0, 5, 2], and queue 5 is not linked to the port.
>
> This new code block will unlink queues 0 and 2, and the function will return 2. However the documentation states that "if the return value is less than *nb_unlinks*, the remaining queues at the end of queues[] are not established", so a return value of 2 would imply that queues 0 and 5 were unlinked, but queue 2 was not.
>
> Perhaps this code could be moved to the "if (queues == NULL)" block, and in its place you can update nb_unlinks like so to handle the non-NULL queues case:
>
> 	links_map = dev->data->links_map;
> 	links_map += (port_id * RTE_EVENT_MAX_QUEUES_PER_DEV);
> 	for (i = 0; i < nb_unlinks; i++) {
> 		if (links_map[queues[i]] !=
> 				EVENT_QUEUE_SERVICE_PRIORITY_INVALID)
> 			break;
> 	}
> 	nb_unlinks = i;
>
> Thanks,
> Gage

Agreed, will send out a cleaned up v2 addressing both the cases.

Thanks,
Pavan.
  

Patch

diff --git a/lib/librte_eventdev/rte_eventdev.c b/lib/librte_eventdev/rte_eventdev.c
index e0c2a78..e17f8fc 100644
--- a/lib/librte_eventdev/rte_eventdev.c
+++ b/lib/librte_eventdev/rte_eventdev.c
@@ -888,7 +888,8 @@  rte_event_port_unlink(uint8_t dev_id, uint8_t port_id,
 {
 	struct rte_eventdev *dev;
 	uint8_t all_queues[RTE_EVENT_MAX_QUEUES_PER_DEV];
-	int i, diag;
+	uint8_t linked_queues[RTE_EVENT_MAX_QUEUES_PER_DEV];
+	int i, diag, j;
 	uint16_t *links_map;
 
 	RTE_EVENTDEV_VALID_DEVID_OR_ERRNO_RET(dev_id, -EINVAL, 0);
@@ -918,6 +919,18 @@  rte_event_port_unlink(uint8_t dev_id, uint8_t port_id,
 			rte_errno = -EINVAL;
 			return 0;
 		}
+	j = 0;
+	links_map = dev->data->links_map;
+	links_map += (port_id * RTE_EVENT_MAX_QUEUES_PER_DEV);
+	for (i = 0; i < nb_unlinks; i++) {
+		if (links_map[queues[i]] !=
+				EVENT_QUEUE_SERVICE_PRIORITY_INVALID) {
+			linked_queues[j] = queues[i];
+			j++;
+		}
+	}
+	queues = linked_queues;
+	nb_unlinks = j;
 
 	diag = (*dev->dev_ops->port_unlink)(dev, dev->data->ports[port_id],
 					queues, nb_unlinks);