DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] examples/flow_filtering: add delay during updating link status
@ 2018-01-24  7:52 Beilei Xing
  2018-01-24  8:16 ` Ori Kam
  2018-01-24  8:34 ` [dpdk-dev] [PATCH v2] " Beilei Xing
  0 siblings, 2 replies; 9+ messages in thread
From: Beilei Xing @ 2018-01-24  7:52 UTC (permalink / raw)
  To: orika; +Cc: dev

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>
---
 examples/flow_filtering/main.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/examples/flow_filtering/main.c b/examples/flow_filtering/main.c
index 4a07b63..1788f24 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,22 @@ main_loop(void)
 	rte_eth_dev_close(port_id);
 }
 
+#define CHECK_INTERVAL 1000  /* 100ms */
+#define MAX_REPEAT_TIME 90   /* 9s (90 * 100ms) in total */
+
 static void
 assert_link_status(void)
 {
 	struct rte_eth_link link;
+	uint8_t rep_cnt = MAX_REPEAT_TIME;
 
 	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;
+	} while (--rep_cnt);
+
 	if (link.link_status == ETH_LINK_DOWN)
 		rte_exit(EXIT_FAILURE, ":: error: link is still down\n");
 }
-- 
2.5.5

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

end of thread, other threads:[~2018-02-01  0:28 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-24  7:52 [dpdk-dev] [PATCH] examples/flow_filtering: add delay during updating link status Beilei Xing
2018-01-24  8:16 ` Ori Kam
2018-01-24  8:19   ` Xing, Beilei
2018-01-24  8:34 ` [dpdk-dev] [PATCH v2] " Beilei Xing
2018-01-24  8:55   ` Ori Kam
2018-01-24 10:02     ` Xing, Beilei
2018-01-24 10:15   ` [dpdk-dev] [PATCH v3] " Beilei Xing
2018-01-24 11:42     ` Ori Kam
2018-02-01  0:27       ` Thomas Monjalon

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).