From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 208A75A87 for ; Thu, 16 Jul 2015 15:55:00 +0200 (CEST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga103.fm.intel.com with ESMTP; 16 Jul 2015 06:55:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,488,1432623600"; d="scan'208";a="765660224" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by orsmga002.jf.intel.com with ESMTP; 16 Jul 2015 06:54:59 -0700 Received: from shecgisg003.sh.intel.com (shecgisg003.sh.intel.com [10.239.29.90]) by shvmail01.sh.intel.com with ESMTP id t6GDsvdl006810; Thu, 16 Jul 2015 21:54:57 +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 t6GDssFo027064; Thu, 16 Jul 2015 21:54:57 +0800 Received: (from yliu84x@localhost) by shecgisg003.sh.intel.com (8.13.6/8.13.6/Submit) id t6GDssg9027060; Thu, 16 Jul 2015 21:54:54 +0800 From: Yong Liu To: dts@dpdk.org Date: Thu, 16 Jul 2015 21:54:44 +0800 Message-Id: <1437054888-27021-2-git-send-email-yong.liu@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1437054888-27021-1-git-send-email-yong.liu@intel.com> References: <1437054888-27021-1-git-send-email-yong.liu@intel.com> Subject: [dts] [PATCH 1/5] Support virtualization scenario that use dpdk as host PF 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: Thu, 16 Jul 2015 13:55:01 -0000 From: Marvin Liu With 'host' option in scenario configuration file, virtual scene module will setup scenario that host pf drived by dpdk. First bind host pf devices to igb_uio driver. Then generate vf devices by max_vfs attribute. Before start VM, start dpdk application as host pf driver. Signed-off-by: Marvin Liu diff --git a/framework/virt_scene.py b/framework/virt_scene.py index 73d2cdf..cf4a416 100644 --- a/framework/virt_scene.py +++ b/framework/virt_scene.py @@ -29,6 +29,7 @@ # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +import time import dts from settings import CONFIG_ROOT_PATH, get_netdev @@ -36,6 +37,7 @@ from config import VirtConf from config import VIRTCONF from exception import * from qemu_kvm import QEMUKvm +from pmd_output import PmdOutput # scenario module for handling scenario # 1. load configurations @@ -65,6 +67,8 @@ class VirtScene(object): self.vm_dut_enable = False self.auto_portmap = True self.vm_type = 'kvm' + self.def_target = "x86_64-native-linuxapp-gcc" + self.host_bound = False # for vm dut init_log self.host_dut.test_classname = 'dts' @@ -82,10 +86,15 @@ class VirtScene(object): raise VirtConfigParseException def prepare_vm(self): + host_cfg = None for conf in self.vm_confs.keys(): if conf == 'scene': - suite_cfg = self.vm_confs['scene'][0] - self.prepare_suite(suite_cfg) + for cfg in self.vm_confs['scene']: + if 'suite' in cfg.keys(): + self.prepare_suite(cfg['suite']) + if 'host' in cfg.keys(): + self.host_bound = True + host_cfg = cfg['host'][0] self.vm_confs.pop('scene') else: vm_name = conf @@ -94,6 +103,10 @@ class VirtScene(object): self.prepare_devices(vm_conf) self.prepare_vmdevice(vm_conf) + # dpdk should start after vf devices created + if host_cfg: + self.prepare_host(**host_cfg) + def cleanup_vm(self): # reload config for has been changed when handle config self.load_config() @@ -104,23 +117,45 @@ class VirtScene(object): self.cleanup_devices(vm_conf) def prepare_suite(self, conf): - if 'suite' in conf.keys(): - for param in conf['suite']: - if 'dut' in param.keys(): - if param['dut'] == 'vm_dut': - self.vm_dut_enable = True - if 'type' in param.keys(): - if param['type'] == 'xen': - self.vm_type = 'xen' - # not implement yet - if param['type'] == 'vmware': - self.vm_type = 'vmware' - # not implement yet - if param['type'] == 'container': - self.vm_type = 'container' - if 'portmap' in param.keys(): - if param['portmap'] == 'cfg': - self.auto_portmap = False + for param in conf: + if 'dut' in param.keys(): + if param['dut'] == 'vm_dut': + self.vm_dut_enable = True + if 'type' in param.keys(): + if param['type'] == 'xen': + self.vm_type = 'xen' + # not implement yet + if param['type'] == 'vmware': + self.vm_type = 'vmware' + # not implement yet + if param['type'] == 'container': + self.vm_type = 'container' + if 'portmap' in param.keys(): + if param['portmap'] == 'cfg': + self.auto_portmap = False + + def prepare_host(self, **opts): + if 'dpdk' not in opts.keys(): + print dts.RED("Scenario host parameter request dpdk option!!!") + raise VirtConfigParamException('host') + + if 'cores' not in opts.keys(): + print dts.RED("Scenario host parameter request cores option!!!") + raise VirtConfigParamException('host') + + if 'target' in opts.keys(): + target = opts['target'] + else: + target = self.def_target + + self.host_dut.set_target(target, bind_dev=True) + + if opts['dpdk'] == 'testpmd': + self.pmdout = PmdOutput(self.host_dut) + cores = opts['cores'].split() + out = self.pmdout.start_testpmd(cores) + if 'Error' in out: + raise VirtHostPrepareException() def prepare_cpu(self, vm_name, conf): cpu_param = {} @@ -241,9 +276,10 @@ class VirtScene(object): def reset_pf_cmds(self, port): command = {} command['type'] = 'host' - intf = self.host_dut.ports_info[port]['intf'] - command['command'] = 'ifconfig %s up' % intf - self.reg_postvm_cmds(command) + if not self.host_bound: + intf = self.host_dut.ports_info[port]['intf'] + command['command'] = 'ifconfig %s up' % intf + self.reg_postvm_cmds(command) def handle_dev_gen(self, **opts): if 'pf_idx' in opts.keys(): -- 1.9.3