[dts] [PATCH V1] framework/dut: optimize scripts
Jiale Song
songx.jiale at intel.com
Fri Jul 14 17:23:04 CEST 2023
1. delete unnecessary waiting time. the iavf driver does not need to
execute a separate wait, which is invalid and only increases the invalid
waiting time.
2. when the NIC name is N/A or empty, the name cannot be changed no
matter how long it is waiting. after obtaining N/A, it is necessary to
rebind the driver of the NIC.
Signed-off-by: Jiale Song <songx.jiale at intel.com>
---
framework/dut.py | 48 +++++++++++++++---------------------------------
1 file changed, 15 insertions(+), 33 deletions(-)
diff --git a/framework/dut.py b/framework/dut.py
index 0adb2786..61ef2839 100644
--- a/framework/dut.py
+++ b/framework/dut.py
@@ -416,50 +416,32 @@ class Dut(Crb):
port = GetNicObj(self, domain_id, bus_id, devfun_id)
- self.send_expect(
- "echo %s > /sys/bus/pci/devices/%s\:%s\:%s/driver/unbind"
- % (pci_bus, domain_id, bus_id, devfun_id),
- "# ",
- timeout=30,
- )
- # bind to linux kernel driver
- if not self.is_container:
- self.send_expect("modprobe %s" % driver, "# ", timeout=30)
- self.send_expect(
- "echo %s > /sys/bus/pci/drivers/%s/bind" % (pci_bus, driver),
- "# ",
- timeout=30,
- )
pull_retries = 5
itf = "N/A"
while pull_retries > 0:
+ self.send_expect(
+ "echo %s > /sys/bus/pci/devices/%s\:%s\:%s/driver/unbind"
+ % (pci_bus, domain_id, bus_id, devfun_id),
+ "# ",
+ timeout=30,
+ )
+ # bind to linux kernel driver
+ if not self.is_container:
+ self.send_expect("modprobe %s" % driver, "# ", timeout=30)
+ self.send_expect(
+ "echo %s > /sys/bus/pci/drivers/%s/bind" % (pci_bus, driver),
+ "# ",
+ timeout=30,
+ )
+ time.sleep(1)
if port_info["port_id"] == 1:
itf = port.get_interface_name()
else:
itf = port.get_interface2_name()
if not itf or itf == "N/A":
- time.sleep(1)
pull_retries -= 1
else:
break
- else:
- # try to bind nic with iavf
- if driver == "iavf":
- self.send_expect("modprobe %s" % driver, "# ")
- self.send_expect(
- "echo %s > /sys/bus/pci/drivers/%s/bind"
- % (pci_bus, driver),
- "# ",
- )
- pull_retries = 5
- itf = "N/A"
- while pull_retries > 0:
- itf = port.get_interface_name()
- if not itf or 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:
--
2.25.1
More information about the dts
mailing list