From mboxrd@z Thu Jan 1 00:00:00 1970 From: Beilei Xing Subject: [PATCH] examples/flow_filtering: add delay during updating link status Date: Wed, 24 Jan 2018 15:52:39 +0800 Message-ID: <1516780359-57421-1-git-send-email-beilei.xing@intel.com> Cc: dev@dpdk.org To: orika@mellanox.com Return-path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id E30EE728E for ; Wed, 24 Jan 2018 08:52:02 +0100 (CET) List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "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 --- 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 #include #include +#include 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