DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] net/mlx5: retry when link update fails
@ 2019-09-04  9:16 Moti Haimovsky
  2019-10-16  7:34 ` [dpdk-dev] [PATCH v2] " Moti Haimovsky
  0 siblings, 1 reply; 4+ messages in thread
From: Moti Haimovsky @ 2019-09-04  9:16 UTC (permalink / raw)
  To: viacheslavo, rasland; +Cc: dev

mlx5_link_update immediately returns when called with no-wait parameter
and its call for retrieving the link status returns with EAGAIN error.
This is too harsh on busy systems where a first call fails with EAGAIN
from time to time.
This patch adds a (very limited) retry on such cases in order to allow
retrieving the link status.

Signed-off-by: Moti Haimovsky <motih@mellanox.com>
---
 drivers/net/mlx5/mlx5_defs.h   | 3 +++
 drivers/net/mlx5/mlx5_ethdev.c | 5 +++--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_defs.h b/drivers/net/mlx5/mlx5_defs.h
index d7440fd..06eb192 100644
--- a/drivers/net/mlx5/mlx5_defs.h
+++ b/drivers/net/mlx5/mlx5_defs.h
@@ -101,6 +101,9 @@
 /* Timeout in seconds to get a valid link status. */
 #define MLX5_LINK_STATUS_TIMEOUT 10
 
+/* Number of times to retry retrieving the physical link information. */
+#define MLX5_GET_LINK_STATUS_RETRY_COUNT 3
+
 /* Maximum number of UAR pages used by a port,
  * These are the size and mask for an array of mutexes used to synchronize
  * the access to port's UARs on platforms that do not support 64 bit writes.
diff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c
index 33a32fc..aace211 100644
--- a/drivers/net/mlx5/mlx5_ethdev.c
+++ b/drivers/net/mlx5/mlx5_ethdev.c
@@ -978,6 +978,7 @@ int mlx5_fw_version_get(struct rte_eth_dev *dev, char *fw_ver, size_t fw_size)
 	int ret;
 	struct rte_eth_link dev_link;
 	time_t start_time = time(NULL);
+	int retry = MLX5_GET_LINK_STATUS_RETRY_COUNT;
 
 	do {
 		ret = mlx5_link_update_unlocked_gs(dev, &dev_link);
@@ -986,7 +987,7 @@ int mlx5_fw_version_get(struct rte_eth_dev *dev, char *fw_ver, size_t fw_size)
 		if (ret == 0)
 			break;
 		/* Handle wait to complete situation. */
-		if (wait_to_complete && ret == -EAGAIN) {
+		if ((wait_to_complete || retry) && ret == -EAGAIN) {
 			if (abs((int)difftime(time(NULL), start_time)) <
 			    MLX5_LINK_STATUS_TIMEOUT) {
 				usleep(0);
@@ -998,7 +999,7 @@ int mlx5_fw_version_get(struct rte_eth_dev *dev, char *fw_ver, size_t fw_size)
 		} else if (ret < 0) {
 			return ret;
 		}
-	} while (wait_to_complete);
+	} while (wait_to_complete || retry-- > 0);
 	ret = !!memcmp(&dev->data->dev_link, &dev_link,
 		       sizeof(struct rte_eth_link));
 	dev->data->dev_link = dev_link;
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [dpdk-dev] [PATCH v2] net/mlx5: retry when link update fails
  2019-09-04  9:16 [dpdk-dev] [PATCH] net/mlx5: retry when link update fails Moti Haimovsky
@ 2019-10-16  7:34 ` Moti Haimovsky
  2019-10-16  7:42   ` Slava Ovsiienko
  2019-10-20 10:07   ` Raslan Darawsheh
  0 siblings, 2 replies; 4+ messages in thread
From: Moti Haimovsky @ 2019-10-16  7:34 UTC (permalink / raw)
  To: viacheslavo, rasland; +Cc: dev

mlx5_link_update immediately returns when called with no-wait parameter
and its call for retrieving the link status returns with EAGAIN error.
This is too harsh on busy systems where a first call fails with EAGAIN
from time to time.
This patch adds a (very limited) retry on such cases in order to allow
retrieving the link status.

Signed-off-by: Moti Haimovsky <motih@mellanox.com>
---
V2:
* Code rebase
---
 drivers/net/mlx5/mlx5_defs.h   | 3 +++
 drivers/net/mlx5/mlx5_ethdev.c | 5 +++--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_defs.h b/drivers/net/mlx5/mlx5_defs.h
index 180122d..248ef3c 100644
--- a/drivers/net/mlx5/mlx5_defs.h
+++ b/drivers/net/mlx5/mlx5_defs.h
@@ -105,6 +105,9 @@
 /* Timeout in seconds to get a valid link status. */
 #define MLX5_LINK_STATUS_TIMEOUT 10
 
+/* Number of times to retry retrieving the physical link information. */
+#define MLX5_GET_LINK_STATUS_RETRY_COUNT 3
+
 /* Maximum number of UAR pages used by a port,
  * These are the size and mask for an array of mutexes used to synchronize
  * the access to port's UARs on platforms that do not support 64 bit writes.
diff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c
index f2b1752..5f05b2b 100644
--- a/drivers/net/mlx5/mlx5_ethdev.c
+++ b/drivers/net/mlx5/mlx5_ethdev.c
@@ -999,6 +999,7 @@ int mlx5_fw_version_get(struct rte_eth_dev *dev, char *fw_ver, size_t fw_size)
 	int ret;
 	struct rte_eth_link dev_link;
 	time_t start_time = time(NULL);
+	int retry = MLX5_GET_LINK_STATUS_RETRY_COUNT;
 
 	do {
 		ret = mlx5_link_update_unlocked_gs(dev, &dev_link);
@@ -1007,7 +1008,7 @@ int mlx5_fw_version_get(struct rte_eth_dev *dev, char *fw_ver, size_t fw_size)
 		if (ret == 0)
 			break;
 		/* Handle wait to complete situation. */
-		if (wait_to_complete && ret == -EAGAIN) {
+		if ((wait_to_complete || retry) && ret == -EAGAIN) {
 			if (abs((int)difftime(time(NULL), start_time)) <
 			    MLX5_LINK_STATUS_TIMEOUT) {
 				usleep(0);
@@ -1019,7 +1020,7 @@ int mlx5_fw_version_get(struct rte_eth_dev *dev, char *fw_ver, size_t fw_size)
 		} else if (ret < 0) {
 			return ret;
 		}
-	} while (wait_to_complete);
+	} while (wait_to_complete || retry-- > 0);
 	ret = !!memcmp(&dev->data->dev_link, &dev_link,
 		       sizeof(struct rte_eth_link));
 	dev->data->dev_link = dev_link;
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-dev] [PATCH v2] net/mlx5: retry when link update fails
  2019-10-16  7:34 ` [dpdk-dev] [PATCH v2] " Moti Haimovsky
@ 2019-10-16  7:42   ` Slava Ovsiienko
  2019-10-20 10:07   ` Raslan Darawsheh
  1 sibling, 0 replies; 4+ messages in thread
From: Slava Ovsiienko @ 2019-10-16  7:42 UTC (permalink / raw)
  To: Moti Haimovsky, Raslan Darawsheh; +Cc: dev

> -----Original Message-----
> From: Moti Haimovsky <motih@mellanox.com>
> Sent: Wednesday, October 16, 2019 10:34
> To: Slava Ovsiienko <viacheslavo@mellanox.com>; Raslan Darawsheh
> <rasland@mellanox.com>
> Cc: dev@dpdk.org
> Subject: [PATCH v2] net/mlx5: retry when link update fails
> 
> mlx5_link_update immediately returns when called with no-wait parameter
> and its call for retrieving the link status returns with EAGAIN error.
> This is too harsh on busy systems where a first call fails with EAGAIN from
> time to time.
> This patch adds a (very limited) retry on such cases in order to allow
> retrieving the link status.
> 
> Signed-off-by: Moti Haimovsky <motih@mellanox.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@mellanox.com>

> ---
> V2:
> * Code rebase
> ---
>  drivers/net/mlx5/mlx5_defs.h   | 3 +++
>  drivers/net/mlx5/mlx5_ethdev.c | 5 +++--
>  2 files changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/mlx5/mlx5_defs.h b/drivers/net/mlx5/mlx5_defs.h
> index 180122d..248ef3c 100644
> --- a/drivers/net/mlx5/mlx5_defs.h
> +++ b/drivers/net/mlx5/mlx5_defs.h
> @@ -105,6 +105,9 @@
>  /* Timeout in seconds to get a valid link status. */  #define
> MLX5_LINK_STATUS_TIMEOUT 10
> 
> +/* Number of times to retry retrieving the physical link information.
> +*/ #define MLX5_GET_LINK_STATUS_RETRY_COUNT 3
> +
>  /* Maximum number of UAR pages used by a port,
>   * These are the size and mask for an array of mutexes used to synchronize
>   * the access to port's UARs on platforms that do not support 64 bit writes.
> diff --git a/drivers/net/mlx5/mlx5_ethdev.c
> b/drivers/net/mlx5/mlx5_ethdev.c index f2b1752..5f05b2b 100644
> --- a/drivers/net/mlx5/mlx5_ethdev.c
> +++ b/drivers/net/mlx5/mlx5_ethdev.c
> @@ -999,6 +999,7 @@ int mlx5_fw_version_get(struct rte_eth_dev *dev,
> char *fw_ver, size_t fw_size)
>  	int ret;
>  	struct rte_eth_link dev_link;
>  	time_t start_time = time(NULL);
> +	int retry = MLX5_GET_LINK_STATUS_RETRY_COUNT;
> 
>  	do {
>  		ret = mlx5_link_update_unlocked_gs(dev, &dev_link); @@ -
> 1007,7 +1008,7 @@ int mlx5_fw_version_get(struct rte_eth_dev *dev, char
> *fw_ver, size_t fw_size)
>  		if (ret == 0)
>  			break;
>  		/* Handle wait to complete situation. */
> -		if (wait_to_complete && ret == -EAGAIN) {
> +		if ((wait_to_complete || retry) && ret == -EAGAIN) {
>  			if (abs((int)difftime(time(NULL), start_time)) <
>  			    MLX5_LINK_STATUS_TIMEOUT) {
>  				usleep(0);
> @@ -1019,7 +1020,7 @@ int mlx5_fw_version_get(struct rte_eth_dev *dev,
> char *fw_ver, size_t fw_size)
>  		} else if (ret < 0) {
>  			return ret;
>  		}
> -	} while (wait_to_complete);
> +	} while (wait_to_complete || retry-- > 0);
>  	ret = !!memcmp(&dev->data->dev_link, &dev_link,
>  		       sizeof(struct rte_eth_link));
>  	dev->data->dev_link = dev_link;
> --
> 1.8.3.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-dev] [PATCH v2] net/mlx5: retry when link update fails
  2019-10-16  7:34 ` [dpdk-dev] [PATCH v2] " Moti Haimovsky
  2019-10-16  7:42   ` Slava Ovsiienko
@ 2019-10-20 10:07   ` Raslan Darawsheh
  1 sibling, 0 replies; 4+ messages in thread
From: Raslan Darawsheh @ 2019-10-20 10:07 UTC (permalink / raw)
  To: Moti Haimovsky, Slava Ovsiienko; +Cc: dev

Hi,
> -----Original Message-----
> From: Moti Haimovsky <motih@mellanox.com>
> Sent: Wednesday, October 16, 2019 10:34 AM
> To: Slava Ovsiienko <viacheslavo@mellanox.com>; Raslan Darawsheh
> <rasland@mellanox.com>
> Cc: dev@dpdk.org
> Subject: [PATCH v2] net/mlx5: retry when link update fails
> 
> mlx5_link_update immediately returns when called with no-wait parameter
> and its call for retrieving the link status returns with EAGAIN error.
> This is too harsh on busy systems where a first call fails with EAGAIN from
> time to time.
> This patch adds a (very limited) retry on such cases in order to allow
> retrieving the link status.
> 
> Signed-off-by: Moti Haimovsky <motih@mellanox.com>
> ---
> V2:
> * Code rebase

Patch applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-10-20 10:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-04  9:16 [dpdk-dev] [PATCH] net/mlx5: retry when link update fails Moti Haimovsky
2019-10-16  7:34 ` [dpdk-dev] [PATCH v2] " Moti Haimovsky
2019-10-16  7:42   ` Slava Ovsiienko
2019-10-20 10:07   ` Raslan Darawsheh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).