From: Beilei Xing Date: Wed, 24 Jan 2018 10:15:34 +0000 (+0800) Subject: examples/flow_filtering: add delay to wait link update X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=429cede188dd0dae78097309695ba4316908b143;p=dpdk.git 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 Acked-by: Ori Kam --- diff --git a/examples/flow_filtering/main.c b/examples/flow_filtering/main.c index cc955cd909..0bb81a8dd4 100644 --- a/examples/flow_filtering/main.c +++ b/examples/flow_filtering/main.c @@ -55,6 +55,7 @@ #include #include #include +#include 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"); }