From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id D466337B0 for ; Tue, 12 Mar 2019 09:52:40 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Mar 2019 01:52:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,470,1544515200"; d="scan'208";a="124725469" Received: from nfvihost.sh.intel.com ([10.239.183.73]) by orsmga008.jf.intel.com with ESMTP; 12 Mar 2019 01:52:39 -0700 From: michael.luo@intel.com To: dts@dpdk.org Date: Tue, 12 Mar 2019 16:49:26 +0800 Message-Id: <1552380566-30145-1-git-send-email-michael.luo@intel.com> X-Mailer: git-send-email 2.7.4 Subject: [dts] [PATCH] framework/dut.py: pull the name after bound the interface to kernel driver X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: test suite reviews and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Mar 2019 08:52:41 -0000 From: Luo Gaoliang When restoring the interface, it will do unbinding, then bind the interface with the kernel driver, it's better to pull the interface name with 1s interval. Because on some system, especially on VMs, if try to get the name immediately after bind the interface with the driver, it may not be ready in its sysfs. Signed-off-by: Luo Gaoliang --- framework/dut.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/framework/dut.py b/framework/dut.py index ab0eb32..541ab7b 100644 --- a/framework/dut.py +++ b/framework/dut.py @@ -281,8 +281,18 @@ class Dut(Crb): self.send_expect('modprobe %s' % driver, '# ') self.send_expect('echo %s > /sys/bus/pci/drivers/%s/bind' % (pci_bus, driver), '# ') - itf = port.get_interface_name() - self.send_expect("ifconfig %s up" % itf, "# ") + pull_retries = 5 + while pull_retries > 0: + itf = port.get_interface_name() + if itf == 'N/A': + time.sleep(1) + pull_retries -= 1 + else: + break + if itf == 'N/A': + self.logger.warning("Fail to bind the device with the linux driver") + else: + self.send_expect("ifconfig %s up" % itf, "# ") else: self.logger.info("NOT FOUND DRIVER FOR PORT (%s|%s)!!!" % (pci_bus, pci_id)) -- 2.7.4