[dts] [PATCH] tests: add TestSuite_ixgbe_vf_get_extra_queue_information.py
Peng Yuan
yuan.peng at intel.com
Fri Dec 29 09:14:24 CET 2017
Signed-off-by: Peng Yuan <yuan.peng at intel.com>
diff --git a/tests/TestSuite_ixgbe_vf_get_extra_queue_information.py b/tests/TestSuite_ixgbe_vf_get_extra_queue_information.py
new file mode 100644
index 0000000..5ddeb29
--- /dev/null
+++ b/tests/TestSuite_ixgbe_vf_get_extra_queue_information.py
@@ -0,0 +1,309 @@
+# BSD LICENSE
+#
+# Copyright(c) 2010-2017 Intel Corporation. All rights reserved.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in
+# the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Intel Corporation nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# 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.
+
+
+"""
+DPDK Test suite.
+Test VF kernel
+"""
+
+import utils
+import time
+import datetime
+import re
+import random
+import threading
+from test_case import TestCase
+from qemu_kvm import QEMUKvm
+from pmd_output import PmdOutput
+from packet import Packet
+import random
+from utils import GREEN, RED
+
+
+class TestVfKernel(TestCase):
+
+ def set_up_all(self):
+ """
+ Run at the start of each test suite.
+ """
+ self.dut.send_expect("service network-manager stop", "#", 60)
+ self.dut_ports = self.dut.get_ports(self.nic)
+ self.verify(len(self.dut_ports) >= 1, "Insufficient ports")
+ self.cores = self.dut.get_core_list("1S/4C/1T")
+ self.coremask = utils.create_mask(self.cores)
+
+ self.dmac = self.dut.get_mac_address(self.dut_ports[0])
+ txport = self.tester.get_local_port(self.dut_ports[0])
+ self.tester_intf = self.tester.get_interface(txport)
+ self.tester_mac = self.tester.get_mac(txport)
+
+ self.intf = self.dut.ports_info[self.dut_ports[0]]['intf']
+ self.pci = self.dut.ports_info[self.dut_ports[0]]['pci'].split(':')
+
+ self.src_logo = '12:34:56:78:90:10'
+ self.setup_vm_env()
+
+ def set_up(self):
+ """
+ Run before each test case.
+ """
+ self.start_pf_vf()
+ self.verify(self.check_pf_vf_link_status(
+ self.vm0_dut, self.vm0_intf0), "vf link down")
+
+ pass
+
+ def setup_vm_env(self):
+ """
+ 1pf -> 1vf , vf->vm0
+ """
+ self.used_dut_port = self.dut_ports[0]
+ self.dut.generate_sriov_vfs_by_port(
+ self.used_dut_port, 1, driver='igb_uio')
+ self.sriov_vfs_port = self.dut.ports_info[
+ self.used_dut_port]['vfs_port']
+ for port in self.sriov_vfs_port:
+ port.bind_driver('pci-stub')
+ time.sleep(1)
+
+ self.dut_testpmd = PmdOutput(self.dut)
+ self.dut.send_expect("./%s/app/testpmd -c 1f -n 4 -- -i --rxq=4 --txq=4 --nb-cores=4" % self.target, "testpmd> ", 120)
+ # dpdk-2208
+ # since there is no forward engine on DPDK PF to forward or drop packet in packet pool,
+ # so finally the pool will be full, then no more packet will be
+ # received by VF
+ self.dut_testpmd.execute_cmd("start")
+
+ vf0_prop_1 = {'opt_host': self.sriov_vfs_port[0].pci}
+
+ self.vm0 = QEMUKvm(self.dut, 'vm0', 'vf_kernel')
+ self.vm0.set_vm_device(driver='pci-assign', **vf0_prop_1)
+ try:
+ self.vm0_dut = self.vm0.start()
+ if self.vm0_dut is None:
+ raise Exception("Set up VM ENV failed")
+ else:
+ self.verify(self.vm0_dut.ports_info[0][
+ 'intf'] != 'N/A', "Not interface")
+ except Exception as e:
+ self.destroy_vm_env()
+ raise Exception(e)
+
+ self.vm0_testpmd = PmdOutput(self.vm0_dut)
+
+ self.vm0_intf0 = self.vm0_dut.ports_info[0]['intf']
+ self.vm0_dut.restore_interfaces_linux()
+
+ # stop NetworkManager, this if for centos7
+ # you may change it when the os no support
+ self.vm0_dut.send_expect("systemctl stop NetworkManager", "# ", 60)
+
+ self.dut_testpmd.quit()
+
+ def destroy_vm_env(self):
+ """
+ destroy vm environment
+ """
+ if getattr(self, 'vm0', None):
+ self.vm0_dut.kill_all()
+ self.vm0_dut_ports = None
+ # destroy vm0
+ self.vm0.stop()
+ self.vm0 = None
+ self.dut.virt_exit()
+
+ if getattr(self, 'used_dut_port', None) is not None:
+ self.dut.destroy_sriov_vfs_by_port(self.used_dut_port)
+ port = self.dut.ports_info[self.used_dut_port]['port']
+ self.used_dut_port = None
+
+ def start_pf_vf(self):
+ """
+ know issue DPDK-2208. dpdk-2849
+ """
+ self.dut.send_expect("./%s/app/testpmd -c 1f -n 4 -- -i --rxq=4 --txq=4 --nb-cores=4" % self.target, "testpmd> ", 120)
+ self.dut_testpmd.execute_cmd('set fwd rxonly')
+ self.dut_testpmd.execute_cmd('set verbose 1')
+ self.dut_testpmd.execute_cmd("start")
+ time.sleep(10)
+ self.vm0_dut.send_expect("rmmod %svf" % self.kdriver, "#")
+ self.vm0_dut.send_expect("modprobe %svf" % self.kdriver, "#")
+
+ def check_pf_vf_link_status(self, session, intf):
+ """
+ sometimes pf/vf will up abnormal, retry 5 times
+ """
+ for i in range(5):
+ # down-up get new mac form pf.
+ # because dpdk pf will give an random mac when dpdk pf restart.
+ session.send_expect("ifconfig %s down" % intf, "#")
+ out = session.send_expect("ifconfig %s up" % intf, "#")
+ # SIOCSIFFLAGS: Network is down
+ # i think the pf link abnormal
+ if "Network is down" in out:
+ print GREEN(out)
+ print GREEN("Try again")
+ self.dut_testpmd.quit()
+ self.vm0_dut.restore_interfaces_linux()
+ self.start_pf_vf()
+ else:
+ out = session.send_expect("ethtool %s" % intf, "#")
+ if "Link detected: yes" in out:
+ return True
+ time.sleep(1)
+ return False
+
+ def send_packet_UP(self, mac, pkt_lens=64, num=1, prio=0):
+ """
+ send different User Priority packets.
+ """
+ pkt = Packet(pkt_type='VLAN_UDP', pkt_len=pkt_lens)
+ pkt.config_layer('ether', {'dst': mac, 'src': self.tester_mac})
+ pkt.config_layer('vlan', {'vlan': 0, 'prio': prio})
+ pkt.send_pkt(tx_port=self.tester_intf, count=num)
+
+ def send_packet(self, mac, pkt_type, pkt_lens=64, num=100):
+ """
+ send packets with different PCtype.
+ """
+ if (pkt_type == "udp"):
+ pkt = Packet(pkt_type='UDP', pkt_len=pkt_lens)
+ pkt.config_layer('ether', {'dst': mac, 'src': self.tester_mac})
+ pkt.config_layer('ipv4', {'src': '192.168.0.1', 'dst': '192.168.0.2'})
+ pkt.config_layer('udp', {'src': 22, 'dst': 23})
+ pkt.send_pkt(tx_port=self.tester_intf, count=num)
+ elif (pkt_type == "ipv4"):
+ pkt = Packet(pkt_type='IP_RAW', pkt_len=pkt_lens)
+ pkt.config_layer('ether', {'dst': mac, 'src': self.tester_mac})
+ pkt.send_pkt(tx_port=self.tester_intf, count=num)
+
+ def verify_result(self, prio, pkt_num):
+ """
+ verify if the packets with different User Priority
+ enter to the expected TC queue.
+ """
+ out = self.vm0_dut.send_expect(
+ "ethtool -S %s |grep rx_.*packets" % self.vm0_intf0, "#")
+ rx_queue_packet = re.findall("rx_.*packets:\s*(\d*)", out)
+ self.verify(int(rx_queue_packet[prio + 1]) == pkt_num,
+ "the packet didn't enter expected queue.")
+
+ def test_DCB_TC4(self):
+ """
+ DPDK PF, kernel VF, enable DCB mode with TC=4
+ """
+ self.dut_testpmd.execute_cmd("stop")
+ self.dut_testpmd.execute_cmd("port stop 0")
+ self.dut_testpmd.execute_cmd("port config 0 dcb vt on 4 pfc off")
+ self.dut_testpmd.execute_cmd("port start 0")
+ time.sleep(10)
+ self.vm0_dut.send_expect("rmmod %svf" % self.kdriver, "#")
+ self.vm0_dut.send_expect("modprobe %svf" % self.kdriver, "#")
+ self.verify(self.check_pf_vf_link_status(
+ self.vm0_dut, self.vm0_intf0), "vf link down")
+ # get the vf's mac address after vf reset.
+ vf_out = self.vm0_dut.send_expect("ifconfig %s" % self.vm0_intf0, "#")
+ vf_mac = re.findall("ether\s(\S*)\s*", vf_out)
+ # verify the rx_queue number equals to TC number.
+ out = self.vm0_dut.send_expect(
+ "ethtool -S %s" % self.vm0_intf0, "#")
+ rx_queue_num = re.findall("rx_.*misses:\s*(\d*)", out)
+ self.verify(len(rx_queue_num) == 4, "the queues count error")
+ # verify the packet with prio 0-3 enter to queue 0-3
+ # verify the packet with prio 4-7 enter to queue 0
+ self.send_packet_UP(mac=vf_mac[0], prio=0)
+ self.verify_result(prio=0, pkt_num=1)
+ self.send_packet_UP(mac=vf_mac[0], prio=1)
+ self.verify_result(prio=1, pkt_num=1)
+ self.send_packet_UP(mac=vf_mac[0], prio=2)
+ self.verify_result(prio=2, pkt_num=1)
+ self.send_packet_UP(mac=vf_mac[0], prio=3)
+ self.verify_result(prio=3, pkt_num=1)
+ self.send_packet_UP(mac=vf_mac[0], prio=4)
+ self.verify_result(prio=0, pkt_num=2)
+ self.send_packet_UP(mac=vf_mac[0], prio=5)
+ self.verify_result(prio=0, pkt_num=3)
+ self.send_packet_UP(mac=vf_mac[0], prio=6)
+ self.verify_result(prio=0, pkt_num=4)
+ self.send_packet_UP(mac=vf_mac[0], prio=7)
+ self.verify_result(prio=0, pkt_num=5)
+
+ def test_disable_DCB(self):
+ """
+ DPDK PF, kernel VF, disable DCB mode
+ """
+ self.dut_testpmd.execute_cmd("set vf vlan insert 0 0 1")
+ # verify the rx_queue number is the default number.
+ out = self.vm0_dut.send_expect(
+ "ethtool -S %s" % self.vm0_intf0, "#")
+ rx_queue_num = re.findall("rx_.*misses:\s*(\d*)", out)
+ self.verify(len(rx_queue_num) == 2, "the queues count error")
+ # get the vf's mac address after vf reset.
+ vf_out = self.vm0_dut.send_expect("ifconfig %s" % self.vm0_intf0, "#")
+ vf_mac = re.findall("ether\s(\S*)\s*", vf_out)
+ # verify different packet enter different queues with RSS.
+ self.send_packet(mac=vf_mac[0], pkt_type="ipv4")
+ out = self.vm0_dut.send_expect(
+ "ethtool -S %s |grep rx_.*packets" % self.vm0_intf0, "#")
+ rx_queue_packet = re.findall("rx_.*packets:\s*(\d*)", out)
+ self.verify(int(rx_queue_packet[1]) == 100,
+ "the packet didn't enter expected queue.")
+ self.verify(int(rx_queue_packet[2]) == 0,
+ "the packet didn't enter expected queue.")
+ self.send_packet(mac=vf_mac[0], pkt_type="udp")
+ out = self.vm0_dut.send_expect(
+ "ethtool -S %s |grep rx_.*packets" % self.vm0_intf0, "#")
+ rx_queue_packet = re.findall("rx_.*packets:\s*(\d*)", out)
+ self.verify(int(rx_queue_packet[2]) == 100,
+ "the packet didn't enter expected queue.")
+
+ def tear_down(self):
+ """
+ Run after each test case.
+ """
+ self.vm0_testpmd.quit()
+ self.vm0_dut.restore_interfaces_linux()
+ self.dut_testpmd.quit()
+
+ # Sometime test failed ,we still need clear ip.
+ self.vm0_dut.send_expect(
+ "ifconfig %s 0.0.0.0" % self.vm0_intf0, "#")
+ self.tester.send_expect("ifconfig %s 0.0.0.0" %
+ self.tester_intf, "#")
+
+ def tear_down_all(self):
+ """
+ Run after each test suite.
+ """
+ self.destroy_vm_env()
+ self.dut.kill_all()
+ time.sleep(2)
--
2.5.0
More information about the dts
mailing list