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 1A2468D9B for ; Sun, 13 Dec 2015 05:58:02 +0100 (CET) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga101.jf.intel.com with ESMTP; 12 Dec 2015 20:58:02 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,420,1444719600"; d="scan'208";a="859642984" Received: from shilc102.sh.intel.com ([10.239.39.44]) by fmsmga001.fm.intel.com with ESMTP; 12 Dec 2015 20:58:01 -0800 Received: from shecgisg003.sh.intel.com (shecgisg003.sh.intel.com [10.239.29.90]) by shilc102.sh.intel.com with ESMTP id tBD4vxqi003202; Sun, 13 Dec 2015 12:57:59 +0800 Received: from shecgisg003.sh.intel.com (localhost [127.0.0.1]) by shecgisg003.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id tBD4vujW004433; Sun, 13 Dec 2015 12:57:58 +0800 Received: (from yliu84x@localhost) by shecgisg003.sh.intel.com (8.13.6/8.13.6/Submit) id tBD4vuuT004429; Sun, 13 Dec 2015 12:57:56 +0800 From: Yong Liu To: dts@dpdk.org Date: Sun, 13 Dec 2015 12:57:41 +0800 Message-Id: <1449982664-4362-6-git-send-email-yong.liu@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1449982664-4362-1-git-send-email-yong.liu@intel.com> References: <1449982664-4362-1-git-send-email-yong.liu@intel.com> Subject: [dts] [PATCH 5/8] framework: net device object get from net_device module 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: Sun, 13 Dec 2015 04:58:03 -0000 From: Marvin Liu All net device object will be retrieved from net_device module. If there has been the object for required nic, net_device module will just return it without re-initialized it. Signed-off-by: Marvin Liu diff --git a/framework/dut.py b/framework/dut.py index 2101fc8..fde5071 100644 --- a/framework/dut.py +++ b/framework/dut.py @@ -38,7 +38,7 @@ from config import PortConf from settings import NICS, LOG_NAME_SEP from ssh_connection import SSHConnection from crb import Crb -from net_device import NetDevice +from net_device import GetNicObj from virt_resource import VirtResource from utils import RED from uuid import uuid4 @@ -240,7 +240,7 @@ class Dut(Crb): bus_id = addr_array[0] devfun_id = addr_array[1] - port = NetDevice(self, bus_id, devfun_id) + port = GetNicObj(self, bus_id, devfun_id) self.send_expect('echo 0000:%s > /sys/bus/pci/devices/0000\:%s\:%s/driver/unbind' % (pci_bus, bus_id, devfun_id), '# ') @@ -476,14 +476,6 @@ class Dut(Crb): return self.ports_info[port_num]['numa'] - def get_port_info(self, pci): - """ - return port info by pci id - """ - for port_info in self.ports_info: - if port_info['pci'] == pci: - return port_info - def lcore_table_print(self, horizontal=False): if not horizontal: dts.results_table_add_header(['Socket', 'Core', 'Thread']) @@ -631,7 +623,7 @@ class Dut(Crb): return for port_info in self.ports_info: - port = NetDevice(self, port_info['pci'], port_info['type']) + port = GetNicObj(self, port_info['pci'], port_info['type']) intf = port.get_interface_name() self.logger.info("DUT cached: [000:%s %s] %s" % (port_info['pci'], @@ -665,7 +657,7 @@ class Dut(Crb): bus_id = addr_array[0] devfun_id = addr_array[1] - port = NetDevice(self, bus_id, devfun_id) + port = GetNicObj(self, bus_id, devfun_id) numa = port.socket # store the port info to port mapping self.ports_info.append( @@ -686,7 +678,7 @@ class Dut(Crb): skipped)) continue - port = NetDevice(self, pci_bus, '') + port = GetNicObj(self, pci_bus, '') intf = port.get_interface_name() macaddr = port.get_mac_addr() @@ -734,13 +726,13 @@ class Dut(Crb): sriov_vfs_pci = port.get_sriov_vfs_pci() self.ports_info[port_id]['sriov_vfs_pci'] = sriov_vfs_pci - # instantiate the VF with NetDevice + # instantiate the VF vfs_port = [] for vf_pci in sriov_vfs_pci: addr_array = vf_pci.split(':') bus_id = addr_array[0] devfun_id = addr_array[1] - vf_port = NetDevice(self, bus_id, devfun_id) + vf_port = GetNicObj(self, bus_id, devfun_id) vfs_port.append(vf_port) self.ports_info[port_id]['vfs_port'] = vfs_port diff --git a/framework/virt_dut.py b/framework/virt_dut.py index 8d0c5d9..1292d08 100644 --- a/framework/virt_dut.py +++ b/framework/virt_dut.py @@ -38,7 +38,7 @@ from config import PortConf from settings import NICS, LOG_NAME_SEP, get_netdev from project_dpdk import DPDKdut from dut import Dut -from net_device import NetDevice +from net_device import GetNicObj class VirtDut(DPDKdut): @@ -252,7 +252,7 @@ class VirtDut(DPDKdut): addr_array = pci_bus.split(':') bus_id = addr_array[0] devfun_id = addr_array[1] - port = NetDevice(self, bus_id, devfun_id) + port = GetNicObj(self, bus_id, devfun_id) itf = port.get_interface_name() self.send_expect("ifconfig %s up" % itf, "# ") time.sleep(30) -- 1.9.3