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 3B055C4CE for ; Thu, 16 Jun 2016 10:18:13 +0200 (CEST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga102.fm.intel.com with ESMTP; 16 Jun 2016 01:18:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,478,1459839600"; d="scan'208";a="998772351" Received: from unknown (HELO dpdk-fedora20.icx.intel.com) ([10.238.55.12]) by orsmga002.jf.intel.com with ESMTP; 16 Jun 2016 01:18:11 -0700 From: Lijuan Tu To: dts@dpdk.org, qian.q.xu@intel.com Cc: Lijuan Tu Date: Thu, 16 Jun 2016 16:13:48 +0800 Message-Id: <1466064828-15998-1-git-send-email-lijuanx.a.tu@intel.com> X-Mailer: git-send-email 1.9.3 Subject: [dts] [PATCH]tests sriov_kvm: test vlan mirror with random vlan id. 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 Jun 2016 08:18:13 -0000 vlan 0 is not a validated vlan id. validated vlan id is between 1 to 4095 Signed-off-by: Lijuan Tu --- tests/TestSuite_sriov_kvm.py | 57 +++++++++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 25 deletions(-) diff --git a/tests/TestSuite_sriov_kvm.py b/tests/TestSuite_sriov_kvm.py index cc63804..b27ad48 100644 --- a/tests/TestSuite_sriov_kvm.py +++ b/tests/TestSuite_sriov_kvm.py @@ -11,6 +11,7 @@ Test userland 10Gb PMD. import re import time from functools import wraps +import random import dts from qemu_kvm import QEMUKvm @@ -19,6 +20,7 @@ from test_case import TestCase from pmd_output import PmdOutput FRAME_SIZE_64 = 64 VM_CORES_MASK = 'all' +MAX_VLAN = 4095 class TestSriovKvm(TestCase): @@ -628,6 +630,8 @@ class TestSriovKvm(TestCase): self.reset_port_mirror_rule(port, rule_id) def setup_two_vm_common_prerequisite(self): + self.host_testpmd.execute_cmd('port stop all') + self.host_testpmd.execute_cmd('port start all') self.vm0_dut_ports = self.vm_dut_0.get_ports('any') self.vm0_testpmd = PmdOutput(self.vm_dut_0) self.vm0_testpmd.start_testpmd(VM_CORES_MASK) @@ -821,36 +825,39 @@ class TestSriovKvm(TestCase): vlan_id = 0 vf_mask = '0x1' packet_num = 10 + random_vlan = random.randint(1, MAX_VLAN - 1) + vlan_ids = [0, 1, random_vlan, MAX_VLAN] - if self.nic.startswith('fortville'): - vm_testpmd = self.get_vm_testpmd_by_mask(vf_mask) - vm_testpmd.execute_cmd('rx_vlan add %d %d' % (vlan_id, port_id_0)) - else: - self.host_testpmd.execute_cmd( - 'rx_vlan add %d port %d vf %s' % (vlan_id, port_id_0, vf_mask)) - rule_id = self.set_port_vlan_mirror(port_id_0, '0 dst-pool 1 on') + for vlan_id in vlan_ids: + if self.nic.startswith('fortville'): + vm_testpmd = self.get_vm_testpmd_by_mask(vf_mask) + vm_testpmd.execute_cmd('rx_vlan add %d %d' % (vlan_id, port_id_0)) + else: + self.host_testpmd.execute_cmd( + 'rx_vlan add %d port %d vf %s' % (vlan_id, port_id_0, vf_mask)) + rule_id = self.set_port_vlan_mirror(port_id_0, '%d dst-pool 1 on' % vlan_id) - vm0_start_stats = self.vm0_testpmd.get_pmd_stats(port_id_0) - vm1_start_stats = self.vm1_testpmd.get_pmd_stats(port_id_0) - ether_ip = {} - ether_ip['dot1q'] = {'vlan': '%d' % vlan_id} - self.send_packet( - self.vm_dut_0, - self.vm0_dut_ports, - port_id_0, - count=packet_num, - **ether_ip) - vm1_end_stats = self.vm1_testpmd.get_pmd_stats(port_id_0) - vm0_end_stats = self.vm0_testpmd.get_pmd_stats(port_id_0) + vm0_start_stats = self.vm0_testpmd.get_pmd_stats(port_id_0) + vm1_start_stats = self.vm1_testpmd.get_pmd_stats(port_id_0) + ether_ip = {} + ether_ip['dot1q'] = {'vlan': '%d' % vlan_id} + self.send_packet( + self.vm_dut_0, + self.vm0_dut_ports, + port_id_0, + count=packet_num, + **ether_ip) + vm1_end_stats = self.vm1_testpmd.get_pmd_stats(port_id_0) + vm0_end_stats = self.vm0_testpmd.get_pmd_stats(port_id_0) - vm1_ret_stats = self.calculate_stats(vm1_start_stats, vm1_end_stats) - vm0_ret_stats = self.calculate_stats(vm0_start_stats, vm0_end_stats) + vm1_ret_stats = self.calculate_stats(vm1_start_stats, vm1_end_stats) + vm0_ret_stats = self.calculate_stats(vm0_start_stats, vm0_end_stats) - self.verify(vm1_ret_stats['RX-packets'] == packet_num and - vm1_ret_stats['TX-packets'] == packet_num, - "Vlan mirror failed between VM0 and VM1!") + self.verify(vm1_ret_stats['RX-packets'] == packet_num and + vm1_ret_stats['TX-packets'] == packet_num, + "Vlan mirror failed between VM0 and VM1!") - self.reset_port_mirror_rule(port_id_0, rule_id) + self.reset_port_mirror_rule(port_id_0, rule_id) def test_two_vms_vlan_and_pool_mirror(self): self.setup_2vm_2vf_env() -- 1.9.3