[dpdk-dev,2/2] vdev: directly use rte_bus reference

Message ID 20170711185649.43620-3-jblunck@infradead.org (mailing list archive)
State Superseded, archived
Headers

Checks

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

Commit Message

Jan Blunck July 11, 2017, 6:56 p.m. UTC
  It isn't necessary to use rte_bus_find_by_name() to find a reference to
our own bus.

Signed-off-by: Jan Blunck <jblunck@infradead.org>
---
 lib/librte_eal/common/eal_common_vdev.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
  

Comments

Gaëtan Rivet July 11, 2017, 7:09 p.m. UTC | #1
Hi Jan,

On Tue, Jul 11, 2017 at 02:56:49PM -0400, Jan Blunck wrote:
> It isn't necessary to use rte_bus_find_by_name() to find a reference to
> our own bus.
> 
> Signed-off-by: Jan Blunck <jblunck@infradead.org>
> ---
>  lib/librte_eal/common/eal_common_vdev.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/lib/librte_eal/common/eal_common_vdev.c b/lib/librte_eal/common/eal_common_vdev.c
> index 2ca0cdb0f..db69d18c6 100644
> --- a/lib/librte_eal/common/eal_common_vdev.c
> +++ b/lib/librte_eal/common/eal_common_vdev.c
> @@ -47,6 +47,9 @@
>  #include <rte_memory.h>
>  #include <rte_errno.h>
>  
> +/* Forward declare to access virtual bus name */
> +static struct rte_bus rte_vdev_bus;
> +
>  /** Double linked list of virtual device drivers. */
>  TAILQ_HEAD(vdev_device_list, rte_vdev_device);
>  
> @@ -138,7 +141,7 @@ alloc_devargs(const char *name, const char *args)
>  	if (!devargs)
>  		return NULL;
>  
> -	devargs->bus = rte_bus_find_by_name("vdev");
> +	devargs->bus = rte_bus_find_by_name(rte_vdev_bus.name);

Why not directly &rte_vdev_bus here?

>  	if (args)
>  		devargs->args = strdup(args);
>  
> @@ -250,13 +253,11 @@ vdev_scan(void)
>  {
>  	struct rte_vdev_device *dev;
>  	struct rte_devargs *devargs;
> -	struct rte_bus *vbus;
>  
>  	/* for virtual devices we scan the devargs_list populated via cmdline */
> -	vbus = rte_bus_find_by_name("vdev");
>  	TAILQ_FOREACH(devargs, &devargs_list, next) {
>  
> -		if (devargs->bus != vbus)
> +		if (devargs->bus != &rte_vdev_bus)
>  			continue;
>  
>  		dev = find_vdev(devargs->name);
> -- 
> 2.13.2
>
  
Jan Blunck July 11, 2017, 7:43 p.m. UTC | #2
On Tue, Jul 11, 2017 at 3:09 PM, Gaëtan Rivet <gaetan.rivet@6wind.com> wrote:
> Hi Jan,
>
> On Tue, Jul 11, 2017 at 02:56:49PM -0400, Jan Blunck wrote:
>> It isn't necessary to use rte_bus_find_by_name() to find a reference to
>> our own bus.
>>
>> Signed-off-by: Jan Blunck <jblunck@infradead.org>
>> ---
>>  lib/librte_eal/common/eal_common_vdev.c | 9 +++++----
>>  1 file changed, 5 insertions(+), 4 deletions(-)
>>
>> diff --git a/lib/librte_eal/common/eal_common_vdev.c b/lib/librte_eal/common/eal_common_vdev.c
>> index 2ca0cdb0f..db69d18c6 100644
>> --- a/lib/librte_eal/common/eal_common_vdev.c
>> +++ b/lib/librte_eal/common/eal_common_vdev.c
>> @@ -47,6 +47,9 @@
>>  #include <rte_memory.h>
>>  #include <rte_errno.h>
>>
>> +/* Forward declare to access virtual bus name */
>> +static struct rte_bus rte_vdev_bus;
>> +
>>  /** Double linked list of virtual device drivers. */
>>  TAILQ_HEAD(vdev_device_list, rte_vdev_device);
>>
>> @@ -138,7 +141,7 @@ alloc_devargs(const char *name, const char *args)
>>       if (!devargs)
>>               return NULL;
>>
>> -     devargs->bus = rte_bus_find_by_name("vdev");
>> +     devargs->bus = rte_bus_find_by_name(rte_vdev_bus.name);
>
> Why not directly &rte_vdev_bus here?
>

Thanks, will fix.

>>       if (args)
>>               devargs->args = strdup(args);
>>
>> @@ -250,13 +253,11 @@ vdev_scan(void)
>>  {
>>       struct rte_vdev_device *dev;
>>       struct rte_devargs *devargs;
>> -     struct rte_bus *vbus;
>>
>>       /* for virtual devices we scan the devargs_list populated via cmdline */
>> -     vbus = rte_bus_find_by_name("vdev");
>>       TAILQ_FOREACH(devargs, &devargs_list, next) {
>>
>> -             if (devargs->bus != vbus)
>> +             if (devargs->bus != &rte_vdev_bus)
>>                       continue;
>>
>>               dev = find_vdev(devargs->name);
>> --
>> 2.13.2
>>
>
> --
> Gaėtan Rivet
> 6WIND
  

Patch

diff --git a/lib/librte_eal/common/eal_common_vdev.c b/lib/librte_eal/common/eal_common_vdev.c
index 2ca0cdb0f..db69d18c6 100644
--- a/lib/librte_eal/common/eal_common_vdev.c
+++ b/lib/librte_eal/common/eal_common_vdev.c
@@ -47,6 +47,9 @@ 
 #include <rte_memory.h>
 #include <rte_errno.h>
 
+/* Forward declare to access virtual bus name */
+static struct rte_bus rte_vdev_bus;
+
 /** Double linked list of virtual device drivers. */
 TAILQ_HEAD(vdev_device_list, rte_vdev_device);
 
@@ -138,7 +141,7 @@  alloc_devargs(const char *name, const char *args)
 	if (!devargs)
 		return NULL;
 
-	devargs->bus = rte_bus_find_by_name("vdev");
+	devargs->bus = rte_bus_find_by_name(rte_vdev_bus.name);
 	if (args)
 		devargs->args = strdup(args);
 
@@ -250,13 +253,11 @@  vdev_scan(void)
 {
 	struct rte_vdev_device *dev;
 	struct rte_devargs *devargs;
-	struct rte_bus *vbus;
 
 	/* for virtual devices we scan the devargs_list populated via cmdline */
-	vbus = rte_bus_find_by_name("vdev");
 	TAILQ_FOREACH(devargs, &devargs_list, next) {
 
-		if (devargs->bus != vbus)
+		if (devargs->bus != &rte_vdev_bus)
 			continue;
 
 		dev = find_vdev(devargs->name);