From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id B8C215A93 for ; Tue, 13 Jan 2015 14:42:47 +0100 (CET) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP; 13 Jan 2015 05:42:46 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.07,750,1413270000"; d="scan'208";a="636605690" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by orsmga001.jf.intel.com with ESMTP; 13 Jan 2015 05:42:46 -0800 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id t0DDgiRG012874; Tue, 13 Jan 2015 21:42:44 +0800 Received: from shecgisg004.sh.intel.com (localhost [127.0.0.1]) by shecgisg004.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id t0DDggt2025886; Tue, 13 Jan 2015 21:42:44 +0800 Received: (from dayuqiu@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id t0DDgg9g025882; Tue, 13 Jan 2015 21:42:42 +0800 From: Michael Qiu To: dts@dpdk.org Date: Tue, 13 Jan 2015 21:42:20 +0800 Message-Id: <1421156540-25810-7-git-send-email-michael.qiu@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1421156540-25810-1-git-send-email-michael.qiu@intel.com> References: <1421156540-25810-1-git-send-email-michael.qiu@intel.com> Cc: yong.liu@intel.com Subject: [dts] [PATCH 6/6] framework/crb: rework restore_interfaces() 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, 13 Jan 2015 13:42:48 -0000 Currently restore_interfaces() is very ugly, and hard to add new device's support. Just make it more flexible to support other new device. Signed-off-by: Michael Qiu --- framework/crb.py | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/framework/crb.py b/framework/crb.py index ee005c4..a08db46 100644 --- a/framework/crb.py +++ b/framework/crb.py @@ -139,30 +139,33 @@ class Crb(object): """ Restore Linux interfaces. """ + # ToDo: put to cfg file later + driver_list = ["igb", "ixgbe", "e1000e", "e1000", "virtio_net", "i40e"] if dts.drivername == "vfio-pci": self.send_expect("rmmod vfio_iommu_type1", "# ", 10) self.send_expect("rmmod vfio_pci", "# ", 10) self.send_expect("rmmod vfio", "# ", 10) else: self.send_expect("rmmod igb_uio", "# ", 10) - self.send_expect("modprobe igb", "# ", 20) - self.send_expect("modprobe ixgbe", "# ", 20) - self.send_expect("modprobe e1000e", "# ", 20) - self.send_expect("modprobe e1000", "# ", 20) - self.send_expect("modprobe virtio_net", "# ", 20) + for driver in driver_list: + # Need remove check after i40e driver in upstream linux kernel + if driver != "i40e": + self.send_expect("modprobe %s"%driver, "# ", 20) + else: + self.send_expect("insmod /root/i40e.ko", "# ", 30) try: for (pci_bus, pci_id) in self.pci_devices_info: - if pci_id in ('8086:10fb', '8086:151c', '8086:1528', '8086:1512', '8086:154a'): - self.send_expect("echo 0000:%s > /sys/bus/pci/drivers/ixgbe/bind" % pci_bus, "# ") - elif pci_id in ('8086:10e8', '8086:150e', '8086:1521', '8086:10c9', '8086:1526', '8086:1533'): - self.send_expect("echo 0000:%s > /sys/bus/pci/drivers/igb/bind" % pci_bus, "# ") - elif pci_id in('8086:10d3', '8086:10b9'): - self.send_expect("echo 0000:%s > /sys/bus/pci/drivers/e1000e/bind" % pci_bus, "# ") - elif pci_id in ('8086:100f', '8086:100e'): - self.send_expect("echo 0000:%s > /sys/bus/pci/drivers/e1000/bind" % pci_bus, "# ") - elif pci_id in ('1af4:1000'): - self.send_expect("echo 0000%s > /sys/bus/pci/drivers/virtio-pci/bind" % pci_bus, "# ") + full_bus = "0000:%s"% pci_bus + driver_path = "/sys/bus/pci/devices/%s/driver"%full_bus + # Get the abs path of the driver + driver_path = self.send_expect("cd %s && pwd -P" % + driver_path, "# ", + verify = True) + if driver_path != -1 and \ + driver_path.split('/')[-1] in driver_list: + self.send_expect("echo %s > %s/bind" % + (full_bus, driver_path), "# ") else: continue -- 1.9.3