[v3] net/mlx5: allow unknown link speed
diff mbox series

Message ID 20201122100404.8612-1-rasland@nvidia.com
State Accepted, archived
Delegated to: Raslan Darawsheh
Headers show
Series
  • [v3] net/mlx5: allow unknown link speed
Related show

Checks

Context Check Description
ci/travis-robot success Travis build: passed
ci/iol-testing warning Testing issues
ci/Intel-compilation success Compilation OK
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/checkpatch warning coding style issues

Commit Message

Raslan Darawsheh Nov. 22, 2020, 10:04 a.m. UTC
From: Benoît Ganne <bganne@cisco.com>

mlx5 PMD refuses to update link state if link speed is defined but
status is down or if link speed is undefined but status is up, even if
the ioctl() succeeded.
This prevents application to detect link up/down event, especially when
the link speed is not correctly detected.

Commit [1] allowed returning unknown link speed, so now pmd allow
the return of unknown link speed in the above case.

Due to some old kernel driver bug, link speed wasn't detected properly.

[1] http://git.dpdk.org/dpdk/commit/?id=810b17d116f03

Signed-off-by: Benoît Ganne <bganne@cisco.co>
Signed-off-by: Raslan Darawsheh <rasland@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
---
v2: rebase the code and add doc update
v3: reword commit log, and return correct link speed
---
 doc/guides/rel_notes/release_20_11.rst  |  1 +
 drivers/net/mlx5/linux/mlx5_ethdev_os.c | 16 +++-------------
 2 files changed, 4 insertions(+), 13 deletions(-)

Comments

Raslan Darawsheh Nov. 22, 2020, 12:58 p.m. UTC | #1
Hi,

> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Raslan Darawsheh
> Sent: Sunday, November 22, 2020 12:04 PM
> To: dev@dpdk.org
> Cc: Matan Azrad <matan@nvidia.com>; Slava Ovsiienko
> <viacheslavo@nvidia.com>; NBU-Contact-Thomas Monjalon
> <thomas@monjalon.net>; Benoît Ganne <bganne@cisco.com>; Benoît
> Ganne <bganne@cisco.co>
> Subject: [dpdk-dev] [PATCH v3] net/mlx5: allow unknown link speed
> 
> From: Benoît Ganne <bganne@cisco.com>
> 
> mlx5 PMD refuses to update link state if link speed is defined but
> status is down or if link speed is undefined but status is up, even if
> the ioctl() succeeded.
> This prevents application to detect link up/down event, especially when
> the link speed is not correctly detected.
> 
> Commit [1] allowed returning unknown link speed, so now pmd allow
> the return of unknown link speed in the above case.
> 
> Due to some old kernel driver bug, link speed wasn't detected properly.
> 
> [1]
> https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fgit.dp
> dk.org%2Fdpdk%2Fcommit%2F%3Fid%3D810b17d116f03&amp;data=04%7C0
> 1%7Crasland%40nvidia.com%7C3965964e417641f146d008d88ece1678%7C430
> 83d15727340c1b7db39efd9ccc17a%7C0%7C0%7C637416363079871052%7CUn
> known%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6
> Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=t0Qj8hEjCBYi1bzy25lJAGTr
> bI0C4l6oImqAe174rNA%3D&amp;reserved=0
> 
> Signed-off-by: Benoît Ganne <bganne@cisco.co>
> Signed-off-by: Raslan Darawsheh <rasland@nvidia.com>
> Acked-by: Matan Azrad <matan@nvidia.com>
> ---
> v2: rebase the code and add doc update
> v3: reword commit log, and return correct link speed
> ---
>  doc/guides/rel_notes/release_20_11.rst  |  1 +
>  drivers/net/mlx5/linux/mlx5_ethdev_os.c | 16 +++-------------
>  2 files changed, 4 insertions(+), 13 deletions(-)

Reverted V2 and applied v3 to next-net-mlx,

Kindest regards,
Raslan Darawsheh

Patch
diff mbox series

diff --git a/doc/guides/rel_notes/release_20_11.rst b/doc/guides/rel_notes/release_20_11.rst
index 1c262d39a5..75b4ebc84b 100644
--- a/doc/guides/rel_notes/release_20_11.rst
+++ b/doc/guides/rel_notes/release_20_11.rst
@@ -207,6 +207,7 @@  New Features
     by rte_flow API.
   * Added support of Age action query.
   * Added support of multi-ports hairpin.
+  * Allow unknown link speed.
 
   Updated Mellanox mlx5 vDPA driver:
 
diff --git a/drivers/net/mlx5/linux/mlx5_ethdev_os.c b/drivers/net/mlx5/linux/mlx5_ethdev_os.c
index 19b281925f..8f9f14156b 100644
--- a/drivers/net/mlx5/linux/mlx5_ethdev_os.c
+++ b/drivers/net/mlx5/linux/mlx5_ethdev_os.c
@@ -405,7 +405,7 @@  mlx5_link_update_unlocked_gset(struct rte_eth_dev *dev,
 	}
 	link_speed = ethtool_cmd_speed(&edata);
 	if (link_speed == -1)
-		dev_link.link_speed = ETH_SPEED_NUM_NONE;
+		dev_link.link_speed = ETH_SPEED_NUM_UNKNOWN;
 	else
 		dev_link.link_speed = link_speed;
 	priv->link_speed_capa = 0;
@@ -425,11 +425,6 @@  mlx5_link_update_unlocked_gset(struct rte_eth_dev *dev,
 				ETH_LINK_HALF_DUPLEX : ETH_LINK_FULL_DUPLEX);
 	dev_link.link_autoneg = !(dev->data->dev_conf.link_speeds &
 			ETH_LINK_SPEED_FIXED);
-	if (((dev_link.link_speed && !dev_link.link_status) ||
-	     (!dev_link.link_speed && dev_link.link_status))) {
-		rte_errno = EAGAIN;
-		return -rte_errno;
-	}
 	*link = dev_link;
 	return 0;
 }
@@ -517,8 +512,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 == UINT32_MAX) ? ETH_SPEED_NUM_NONE :
-							    ecmd->speed;
+	dev_link.link_speed = (ecmd->speed == UINT32_MAX) ?
+				ETH_SPEED_NUM_UNKNOWN : ecmd->speed;
 	sc = ecmd->link_mode_masks[0] |
 		((uint64_t)ecmd->link_mode_masks[1] << 32);
 	priv->link_speed_capa = 0;
@@ -571,11 +566,6 @@  mlx5_link_update_unlocked_gs(struct rte_eth_dev *dev,
 				ETH_LINK_HALF_DUPLEX : ETH_LINK_FULL_DUPLEX);
 	dev_link.link_autoneg = !(dev->data->dev_conf.link_speeds &
 				  ETH_LINK_SPEED_FIXED);
-	if (((dev_link.link_speed && !dev_link.link_status) ||
-	     (!dev_link.link_speed && dev_link.link_status))) {
-		rte_errno = EAGAIN;
-		return -rte_errno;
-	}
 	*link = dev_link;
 	return 0;
 }