summaryrefslogtreecommitdiff
path: root/examples/flow_filtering
diff options
context:
space:
mode:
authorBeilei Xing <beilei.xing@intel.com>2018-01-24 18:15:34 +0800
committerThomas Monjalon <thomas@monjalon.net>2018-02-01 01:23:15 +0100
commit429cede188dd0dae78097309695ba4316908b143 (patch)
treee85fa7867c42af80f045e69f632c54a01dcf5a77 /examples/flow_filtering
parent0bb76fc945e626941de2c6e881b69f4e4ef61478 (diff)
downloaddpdk-429cede188dd0dae78097309695ba4316908b143.zip
dpdk-429cede188dd0dae78097309695ba4316908b143.tar.gz
dpdk-429cede188dd0dae78097309695ba4316908b143.tar.xz
examples/flow_filtering: add delay to wait link update
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>
Diffstat (limited to 'examples/flow_filtering')
-rw-r--r--examples/flow_filtering/main.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/examples/flow_filtering/main.c b/examples/flow_filtering/main.c
index cc955cd..0bb81a8 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");
}