[v5,1/7] net/mlx5: remove useless driver name comparison

Message ID 20181014204747.26621-2-thomas@monjalon.net (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series [v5,1/7] net/mlx5: remove useless driver name comparison |

Checks

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

Commit Message

Thomas Monjalon Oct. 14, 2018, 8:47 p.m. UTC
  The function mlx5_dev_to_port_id() is returning all the ports
associated to a rte_device.
It was comparing driver names while already comparing rte_device pointers.
If two devices are the same, they will have the same driver.
So the useless driver name comparison is removed.

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
 drivers/net/mlx5/mlx5_ethdev.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
  

Comments

Thomas Monjalon Oct. 14, 2018, 8:49 p.m. UTC | #1
+Cc Yongseok and Shahaf

14/10/2018 22:47, Thomas Monjalon:
> The function mlx5_dev_to_port_id() is returning all the ports
> associated to a rte_device.
> It was comparing driver names while already comparing rte_device pointers.
> If two devices are the same, they will have the same driver.
> So the useless driver name comparison is removed.
> 
> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> ---
>  drivers/net/mlx5/mlx5_ethdev.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c
> index 61eda537b..cacdf8e18 100644
> --- a/drivers/net/mlx5/mlx5_ethdev.c
> +++ b/drivers/net/mlx5/mlx5_ethdev.c
> @@ -1305,10 +1305,7 @@ mlx5_dev_to_port_id(const struct rte_device *dev, uint16_t *port_list,
>  	RTE_ETH_FOREACH_DEV(id) {
>  		struct rte_eth_dev *ldev = &rte_eth_devices[id];
>  
> -		if (!ldev->device ||
> -		    !ldev->device->driver ||
> -		    strcmp(ldev->device->driver->name, MLX5_DRIVER_NAME) ||
> -		    ldev->device != dev)
> +		if (ldev->device != dev)
>  			continue;
>  		if (n < port_list_n)
>  			port_list[n] = id;
>
  
Shahaf Shuler Oct. 15, 2018, 5:53 a.m. UTC | #2
Sunday, October 14, 2018 11:49 PM, Thomas Monjalon:
> 14/10/2018 22:47, Thomas Monjalon:
> > The function mlx5_dev_to_port_id() is returning all the ports
> > associated to a rte_device.
> > It was comparing driver names while already comparing rte_device
> pointers.
> > If two devices are the same, they will have the same driver.
> > So the useless driver name comparison is removed.
> >
> > Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> > ---
> >  drivers/net/mlx5/mlx5_ethdev.c | 5 +----
> >  1 file changed, 1 insertion(+), 4 deletions(-)
> >
> > diff --git a/drivers/net/mlx5/mlx5_ethdev.c
> > b/drivers/net/mlx5/mlx5_ethdev.c index 61eda537b..cacdf8e18 100644
> > --- a/drivers/net/mlx5/mlx5_ethdev.c
> > +++ b/drivers/net/mlx5/mlx5_ethdev.c
> > @@ -1305,10 +1305,7 @@ mlx5_dev_to_port_id(const struct rte_device
> *dev, uint16_t *port_list,
> >  	RTE_ETH_FOREACH_DEV(id) {
> >  		struct rte_eth_dev *ldev = &rte_eth_devices[id];
> >
> > -		if (!ldev->device ||
> > -		    !ldev->device->driver ||
> > -		    strcmp(ldev->device->driver->name,
> MLX5_DRIVER_NAME) ||
> > -		    ldev->device != dev)
> > +		if (ldev->device != dev)
> >  			continue;
> >  		if (n < port_list_n)
> >  			port_list[n] = id;
> >

Acked-By: Shahaf Shuler <shahafs@mellanox.com>
  

Patch

diff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c
index 61eda537b..cacdf8e18 100644
--- a/drivers/net/mlx5/mlx5_ethdev.c
+++ b/drivers/net/mlx5/mlx5_ethdev.c
@@ -1305,10 +1305,7 @@  mlx5_dev_to_port_id(const struct rte_device *dev, uint16_t *port_list,
 	RTE_ETH_FOREACH_DEV(id) {
 		struct rte_eth_dev *ldev = &rte_eth_devices[id];
 
-		if (!ldev->device ||
-		    !ldev->device->driver ||
-		    strcmp(ldev->device->driver->name, MLX5_DRIVER_NAME) ||
-		    ldev->device != dev)
+		if (ldev->device != dev)
 			continue;
 		if (n < port_list_n)
 			port_list[n] = id;