From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 7777D1E20 for ; Wed, 24 Jan 2018 11:14:57 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Jan 2018 02:14:56 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,406,1511856000"; d="scan'208";a="195869164" Received: from unknown (HELO dpdk9.sh.intel.com) ([10.67.118.52]) by orsmga005.jf.intel.com with ESMTP; 24 Jan 2018 02:14:55 -0800 From: Beilei Xing To: orika@mellanox.com Cc: dev@dpdk.org Date: Wed, 24 Jan 2018 18:15:34 +0800 Message-Id: <1516788934-66399-1-git-send-email-beilei.xing@intel.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1516782880-59883-1-git-send-email-beilei.xing@intel.com> References: <1516782880-59883-1-git-send-email-beilei.xing@intel.com> Subject: [dpdk-dev] [PATCH v3] examples/flow_filtering: add delay during updating link status X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 24 Jan 2018 10:14:57 -0000 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 --- 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 #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"); } -- 2.5.5