[dpdk-dev,2/2] net/thunderx: wait to complete during link update

Message ID 1490968669-9161-2-git-send-email-Andriy.Berestovskyy@caviumnetworks.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers

Checks

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

Commit Message

Andriy Berestovskyy March 31, 2017, 1:57 p.m. UTC
  Some DPDK applications/examples check link status on their
start. NICVF does not wait for the link, so those apps fail.

Wait up to 9 seconds for the link as other PMDs do in order
to fix those apps/examples.

Signed-off-by: Andriy Berestovskyy <Andriy.Berestovskyy@caviumnetworks.com>
---
 drivers/net/thunderx/nicvf_ethdev.c | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)
  

Comments

Jerin Jacob April 3, 2017, 2:55 p.m. UTC | #1
On Fri, Mar 31, 2017 at 03:57:49PM +0200, Andriy Berestovskyy wrote:
> Some DPDK applications/examples check link status on their
> start. NICVF does not wait for the link, so those apps fail.
> 
> Wait up to 9 seconds for the link as other PMDs do in order
> to fix those apps/examples.
> 
> Signed-off-by: Andriy Berestovskyy <Andriy.Berestovskyy@caviumnetworks.com>

Acked-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>

> ---
>  drivers/net/thunderx/nicvf_ethdev.c | 21 +++++++++++++++++----
>  1 file changed, 17 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/thunderx/nicvf_ethdev.c b/drivers/net/thunderx/nicvf_ethdev.c
> index 984c218..2fe653a 100644
> --- a/drivers/net/thunderx/nicvf_ethdev.c
> +++ b/drivers/net/thunderx/nicvf_ethdev.c
> @@ -145,16 +145,29 @@ nicvf_periodic_alarm_stop(void (fn)(void *), void *arg)
>   * Return 0 means link status changed, -1 means not changed
>   */
>  static int
> -nicvf_dev_link_update(struct rte_eth_dev *dev,
> -		      int wait_to_complete __rte_unused)
> +nicvf_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete)
>  {
> +#define CHECK_INTERVAL 100  /* 100ms */
> +#define MAX_CHECK_TIME 90   /* 9s (90 * 100ms) in total */
>  	struct rte_eth_link link;
>  	struct nicvf *nic = nicvf_pmd_priv(dev);
> +	int i;
>  
>  	PMD_INIT_FUNC_TRACE();
>  
> -	memset(&link, 0, sizeof(link));
> -	nicvf_set_eth_link_status(nic, &link);
> +	if (wait_to_complete) {
> +		/* rte_eth_link_get() might need to wait up to 9 seconds */
> +		for (i = 0; i < MAX_CHECK_TIME; i++) {
> +			memset(&link, 0, sizeof(link));
> +			nicvf_set_eth_link_status(nic, &link);
> +			if (link.link_status)
> +				break;
> +			rte_delay_ms(CHECK_INTERVAL);
> +		}
> +	} else {
> +		memset(&link, 0, sizeof(link));
> +		nicvf_set_eth_link_status(nic, &link);
> +	}
>  	return nicvf_atomic_write_link_status(dev, &link);
>  }
>  
> -- 
> 2.7.4
>
  
Ferruh Yigit April 3, 2017, 3:35 p.m. UTC | #2
On 4/3/2017 3:55 PM, Jerin Jacob wrote:
> On Fri, Mar 31, 2017 at 03:57:49PM +0200, Andriy Berestovskyy wrote:
>> Some DPDK applications/examples check link status on their
>> start. NICVF does not wait for the link, so those apps fail.
>>
>> Wait up to 9 seconds for the link as other PMDs do in order
>> to fix those apps/examples.
>>
>> Signed-off-by: Andriy Berestovskyy <Andriy.Berestovskyy@caviumnetworks.com>
> 
> Acked-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>

Applied to dpdk-next-net/master, thanks.

(not patchset, only this patch applied.)
  

Patch

diff --git a/drivers/net/thunderx/nicvf_ethdev.c b/drivers/net/thunderx/nicvf_ethdev.c
index 984c218..2fe653a 100644
--- a/drivers/net/thunderx/nicvf_ethdev.c
+++ b/drivers/net/thunderx/nicvf_ethdev.c
@@ -145,16 +145,29 @@  nicvf_periodic_alarm_stop(void (fn)(void *), void *arg)
  * Return 0 means link status changed, -1 means not changed
  */
 static int
-nicvf_dev_link_update(struct rte_eth_dev *dev,
-		      int wait_to_complete __rte_unused)
+nicvf_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete)
 {
+#define CHECK_INTERVAL 100  /* 100ms */
+#define MAX_CHECK_TIME 90   /* 9s (90 * 100ms) in total */
 	struct rte_eth_link link;
 	struct nicvf *nic = nicvf_pmd_priv(dev);
+	int i;
 
 	PMD_INIT_FUNC_TRACE();
 
-	memset(&link, 0, sizeof(link));
-	nicvf_set_eth_link_status(nic, &link);
+	if (wait_to_complete) {
+		/* rte_eth_link_get() might need to wait up to 9 seconds */
+		for (i = 0; i < MAX_CHECK_TIME; i++) {
+			memset(&link, 0, sizeof(link));
+			nicvf_set_eth_link_status(nic, &link);
+			if (link.link_status)
+				break;
+			rte_delay_ms(CHECK_INTERVAL);
+		}
+	} else {
+		memset(&link, 0, sizeof(link));
+		nicvf_set_eth_link_status(nic, &link);
+	}
 	return nicvf_atomic_write_link_status(dev, &link);
 }