[dpdk-dev,v3] examples/flow_filtering: add delay during updating link status

Message ID 1516788934-66399-1-git-send-email-beilei.xing@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers

Checks

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

Commit Message

Xing, Beilei Jan. 24, 2018, 10:15 a.m. UTC
  Add up to 9s delay for getting link status to make sure NIC updates
link status successfully, just like other applications such as
testpmd and l2fwd.

Signed-off-by: Beilei Xing <beilei.xing@intel.com>
---
v3 changes:
 - Modify MAX_REPEAT_TIME with MAX_REPEAT_TIMES
v2 changes:
 - Add rte_delay_ms(CHECK_INTERVAL) which is missed in v1.

 examples/flow_filtering/main.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
  

Comments

Ori Kam Jan. 24, 2018, 11:42 a.m. UTC | #1
> -----Original Message-----
> From: Beilei Xing [mailto:beilei.xing@intel.com]
> Sent: Wednesday, January 24, 2018 12:16 PM
> To: Ori Kam <orika@mellanox.com>
> Cc: dev@dpdk.org
> Subject: [PATCH v3] examples/flow_filtering: add delay during updating link
> status
> 
> Add up to 9s delay for getting link status to make sure NIC updates
> link status successfully, just like other applications such as
> testpmd and l2fwd.
> 
> Signed-off-by: Beilei Xing <beilei.xing@intel.com>
> ---
> v3 changes:
>  - Modify MAX_REPEAT_TIME with MAX_REPEAT_TIMES
> v2 changes:
>  - Add rte_delay_ms(CHECK_INTERVAL) which is missed in v1.
> 
>  examples/flow_filtering/main.c | 13 ++++++++++++-
>  1 file changed, 12 insertions(+), 1 deletion(-)
> 
> diff --git a/examples/flow_filtering/main.c b/examples/flow_filtering/main.c
> index 4a07b63..d16a0a5 100644
> --- a/examples/flow_filtering/main.c
> +++ b/examples/flow_filtering/main.c
> @@ -55,6 +55,7 @@
>  #include <rte_mbuf.h>
>  #include <rte_net.h>
>  #include <rte_flow.h>
> +#include <rte_cycles.h>
> 
>  static volatile bool force_quit;
> 
> @@ -119,13 +120,23 @@ main_loop(void)
>  	rte_eth_dev_close(port_id);
>  }
> 
> +#define CHECK_INTERVAL 1000  /* 100ms */
> +#define MAX_REPEAT_TIMES 90  /* 9s (90 * 100ms) in total */
> +
>  static void
>  assert_link_status(void)
>  {
>  	struct rte_eth_link link;
> +	uint8_t rep_cnt = MAX_REPEAT_TIMES;
> 
>  	memset(&link, 0, sizeof(link));
> -	rte_eth_link_get(port_id, &link);
> +	do {
> +		rte_eth_link_get(port_id, &link);
> +		if (link.link_status == ETH_LINK_UP)
> +			break;
> +		rte_delay_ms(CHECK_INTERVAL);
> +	} while (--rep_cnt);
> +
>  	if (link.link_status == ETH_LINK_DOWN)
>  		rte_exit(EXIT_FAILURE, ":: error: link is still down\n");
>  }
> --
> 2.5.5

Acked-by: Ori Kam <orika@mellanox.com>

Thanks,
Ori
  
Thomas Monjalon Feb. 1, 2018, 12:27 a.m. UTC | #2
> > Add up to 9s delay for getting link status to make sure NIC updates
> > link status successfully, just like other applications such as
> > testpmd and l2fwd.
> > 
> > Signed-off-by: Beilei Xing <beilei.xing@intel.com>
> 
> Acked-by: Ori Kam <orika@mellanox.com>

Applied, thanks
  

Patch

diff --git a/examples/flow_filtering/main.c b/examples/flow_filtering/main.c
index 4a07b63..d16a0a5 100644
--- a/examples/flow_filtering/main.c
+++ b/examples/flow_filtering/main.c
@@ -55,6 +55,7 @@ 
 #include <rte_mbuf.h>
 #include <rte_net.h>
 #include <rte_flow.h>
+#include <rte_cycles.h>
 
 static volatile bool force_quit;
 
@@ -119,13 +120,23 @@  main_loop(void)
 	rte_eth_dev_close(port_id);
 }
 
+#define CHECK_INTERVAL 1000  /* 100ms */
+#define MAX_REPEAT_TIMES 90  /* 9s (90 * 100ms) in total */
+
 static void
 assert_link_status(void)
 {
 	struct rte_eth_link link;
+	uint8_t rep_cnt = MAX_REPEAT_TIMES;
 
 	memset(&link, 0, sizeof(link));
-	rte_eth_link_get(port_id, &link);
+	do {
+		rte_eth_link_get(port_id, &link);
+		if (link.link_status == ETH_LINK_UP)
+			break;
+		rte_delay_ms(CHECK_INTERVAL);
+	} while (--rep_cnt);
+
 	if (link.link_status == ETH_LINK_DOWN)
 		rte_exit(EXIT_FAILURE, ":: error: link is still down\n");
 }