net/mlx5: fix link speed info when link is down

Message ID 4b0167f58ced8ae76262b0accbf14a4653b29283.1564991888.git.jackmin@mellanox.com (mailing list archive)
State Accepted, archived
Delegated to: Raslan Darawsheh
Headers
Series net/mlx5: fix link speed info when link is down |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-Compile-Testing success Compile Testing PASS
ci/intel-Performance-Testing success Performance Testing PASS
ci/Intel-compilation success Compilation OK
ci/mellanox-Performance-Testing success Performance Testing PASS

Commit Message

Xiaoyu Min Aug. 5, 2019, 8:02 a.m. UTC
  When the link is down, the link speed returned by ethtool is
UINT32_MAX and the link status is 0.

In this case, the DPDK ethdev link speed should be set to
ETH_SPEED_NUM_NONE.
Otherwise since link speed is non-zero but link status is zero, this
is an inconsistent situation and -EAGAIN is returned, which is not right.

Fixes: 188408719888 ("net/mlx5: fix support for newer link speeds")
Cc: stable@dpdk.org

Signed-off-by: Xiaoyu Min <jackmin@mellanox.com>
---
 drivers/net/mlx5/mlx5_ethdev.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
  

Comments

Slava Ovsiienko Aug. 5, 2019, 1:39 p.m. UTC | #1
> -----Original Message-----
> From: Xiaoyu Min <jackmin@mellanox.com>
> Sent: Monday, August 5, 2019 11:02
> To: Shahaf Shuler <shahafs@mellanox.com>; Yongseok Koh
> <yskoh@mellanox.com>; Slava Ovsiienko <viacheslavo@mellanox.com>
> Cc: dev@dpdk.org; stable@dpdk.org
> Subject: [PATCH] net/mlx5: fix link speed info when link is down
> 
> When the link is down, the link speed returned by ethtool is UINT32_MAX
> and the link status is 0.
> 
> In this case, the DPDK ethdev link speed should be set to
> ETH_SPEED_NUM_NONE.
> Otherwise since link speed is non-zero but link status is zero, this is an
> inconsistent situation and -EAGAIN is returned, which is not right.
> 
> Fixes: 188408719888 ("net/mlx5: fix support for newer link speeds")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Xiaoyu Min <jackmin@mellanox.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@mellanox.com>

> ---
>  drivers/net/mlx5/mlx5_ethdev.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/mlx5/mlx5_ethdev.c
> b/drivers/net/mlx5/mlx5_ethdev.c index 9629cfb333..33a32fc2fa 100644
> --- a/drivers/net/mlx5/mlx5_ethdev.c
> +++ b/drivers/net/mlx5/mlx5_ethdev.c
> @@ -908,7 +908,8 @@ mlx5_link_update_unlocked_gs(struct rte_eth_dev
> *dev,
>  			dev->data->port_id, strerror(rte_errno));
>  		return ret;
>  	}
> -	dev_link.link_speed = ecmd->speed;
> +	dev_link.link_speed = (ecmd->speed == UINT32_MAX) ?
> ETH_SPEED_NUM_NONE :
> +							    ecmd->speed;
>  	sc = ecmd->link_mode_masks[0] |
>  		((uint64_t)ecmd->link_mode_masks[1] << 32);
>  	priv->link_speed_capa = 0;
> --
> 2.21.0
  
Raslan Darawsheh Aug. 5, 2019, 3:16 p.m. UTC | #2
Hi,

> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Xiaoyu Min
> Sent: Monday, August 5, 2019 11:02 AM
> To: Shahaf Shuler <shahafs@mellanox.com>; Yongseok Koh
> <yskoh@mellanox.com>; Slava Ovsiienko <viacheslavo@mellanox.com>
> Cc: dev@dpdk.org; stable@dpdk.org
> Subject: [dpdk-dev] [PATCH] net/mlx5: fix link speed info when link is down
> 
> When the link is down, the link speed returned by ethtool is
> UINT32_MAX and the link status is 0.
> 
> In this case, the DPDK ethdev link speed should be set to
> ETH_SPEED_NUM_NONE.
> Otherwise since link speed is non-zero but link status is zero, this
> is an inconsistent situation and -EAGAIN is returned, which is not right.
> 
> Fixes: 188408719888 ("net/mlx5: fix support for newer link speeds")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Xiaoyu Min <jackmin@mellanox.com>
> ---
>  drivers/net/mlx5/mlx5_ethdev.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/mlx5/mlx5_ethdev.c
> b/drivers/net/mlx5/mlx5_ethdev.c
> index 9629cfb333..33a32fc2fa 100644
> --- a/drivers/net/mlx5/mlx5_ethdev.c
> +++ b/drivers/net/mlx5/mlx5_ethdev.c
> @@ -908,7 +908,8 @@ mlx5_link_update_unlocked_gs(struct rte_eth_dev
> *dev,
>  			dev->data->port_id, strerror(rte_errno));
>  		return ret;
>  	}
> -	dev_link.link_speed = ecmd->speed;
> +	dev_link.link_speed = (ecmd->speed == UINT32_MAX) ?
> ETH_SPEED_NUM_NONE :
> +							    ecmd->speed;
>  	sc = ecmd->link_mode_masks[0] |
>  		((uint64_t)ecmd->link_mode_masks[1] << 32);
>  	priv->link_speed_capa = 0;
> --
> 2.21.0

Patch applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh
  

Patch

diff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c
index 9629cfb333..33a32fc2fa 100644
--- a/drivers/net/mlx5/mlx5_ethdev.c
+++ b/drivers/net/mlx5/mlx5_ethdev.c
@@ -908,7 +908,8 @@  mlx5_link_update_unlocked_gs(struct rte_eth_dev *dev,
 			dev->data->port_id, strerror(rte_errno));
 		return ret;
 	}
-	dev_link.link_speed = ecmd->speed;
+	dev_link.link_speed = (ecmd->speed == UINT32_MAX) ? ETH_SPEED_NUM_NONE :
+							    ecmd->speed;
 	sc = ecmd->link_mode_masks[0] |
 		((uint64_t)ecmd->link_mode_masks[1] << 32);
 	priv->link_speed_capa = 0;