From patchwork Wed Jan 13 06:26:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Chen, BoX C" X-Patchwork-Id: 86451 Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 095A8A09EF; Wed, 13 Jan 2021 07:27:59 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F1A37140E62; Wed, 13 Jan 2021 07:27:58 +0100 (CET) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mails.dpdk.org (Postfix) with ESMTP id 142CF140E40 for ; Wed, 13 Jan 2021 07:27:56 +0100 (CET) IronPort-SDR: Zjj15jefTsSXu/uDe8q/NQJ+r9LpCp6p2/tfKZVc5vRuIagMWRKicrMdH1zshgABFW93qKtBDi TxOIzXRy0bmg== X-IronPort-AV: E=McAfee;i="6000,8403,9862"; a="242230829" X-IronPort-AV: E=Sophos;i="5.79,343,1602572400"; d="scan'208";a="242230829" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jan 2021 22:27:56 -0800 IronPort-SDR: WkcrhIGuJcEP60dJcd5ArLq4xwz+19V5ZV8WctBxHarSazPL0/YP6jkvDPzsUP8gGDx/7dvhLU CIQwxfIPnfaw== X-IronPort-AV: E=Sophos;i="5.79,343,1602572400"; d="scan'208";a="424447853" Received: from unknown (HELO localhost.localdomain) ([10.240.183.58]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jan 2021 22:27:55 -0800 From: ChenBo To: dts@dpdk.org Cc: ChenBo Date: Wed, 13 Jan 2021 14:26:27 +0800 Message-Id: <20210113062628.4526-2-box.c.chen@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210113062628.4526-1-box.c.chen@intel.com> References: <20210113062628.4526-1-box.c.chen@intel.com> Subject: [dts] [PATCH V1 1/2] add smoke test plan of nic part X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: test suite reviews and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dts-bounces@dpdk.org Sender: "dts" Add smoke test case plan. case list: jumbo frame, rss, tx and rx queue Signed-off-by: ChenBo --- test_plans/pf_smoke_test.rst | 163 ++++++++++++++++++++++++++++++++ test_plans/vf_smoke_test.rst | 176 +++++++++++++++++++++++++++++++++++ 2 files changed, 339 insertions(+) create mode 100644 test_plans/pf_smoke_test.rst create mode 100644 test_plans/vf_smoke_test.rst diff --git a/test_plans/pf_smoke_test.rst b/test_plans/pf_smoke_test.rst new file mode 100644 index 00000000..d2e9d9a0 --- /dev/null +++ b/test_plans/pf_smoke_test.rst @@ -0,0 +1,163 @@ +.. Copyright (c) <2020>, Intel Corporation + 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. + +================== +NIC PF Smoke Test +================== + +Description +=========== +Test the basic functions of dpdk. +1. Port connection status. +2. Launch testpmd normally. +3. Basic rx and tx. + +Prerequisites +============= + +1. Hardware: + + niantic/fortville/columbiaville + +2. Software: + + dpdk: http://dpdk.org/git/dpdk + scapy: http://www.secdev.org/projects/scapy/ + +3. Compile DPDK:: + + CC=gcc meson -Denable_kmods=True -Dlibdir=lib --default-library=static x86_64-native-linuxapp-gcc + ninja -C x86_64-native-linuxapp-gcc + +4. Get the pci device id of DUT, for example:: + + ./usertools/dpdk-devbind.py -s + + 0000:86:00.0 'Device 1593' if=enp134s0f0 drv=ice unused=vfio-pci + +7. Bind PF to dpdk driver:: + + modprobe vfio-pci + ./usertools/dpdk-devbind.py -b vfio-pci 0000:86:00.0 + +8. Launch dpdk on PF:: + + ./x86_64-native-linuxapp-gcc/app/dpdk-testpmd -c 0xf -n 4 -a 0000:86:00.0 --file-prefix=pf -- -i --max-pkt-len=9600 --tx-offloads=0x00008000 --rxq=4 --txq=4 + testpmd> set fwd mac + testpmd> set verbose 3 + testpmd> start + testpmd> show port info all + +Test Case 1: test enable and disable jumbo frame +==================================================== +1. set fwd mode is mac:: + + testpmd> set fwd mac + testpmd> set verbose 3 + testpmd> start + +2. Send a packet with size 9601 bytes :: + + testpmd> show port stats 0 + + ######################## NIC statistics for port 0 ######################## + RX-packets: 0 RX-errors: 1 RX-bytes: 0 + TX-packets: 0 TX-errors: 0 TX-bytes: 0 + ############################################################################ + +Verify that TX-bytes on port 0 and RX-bytes on port 0 are 0. + +3. Send a packet with size 9600 bytes :: + + testpmd> show port stats 0 + + ######################## NIC statistics for port 0 ######################## + RX-packets: 1 RX-errors: 0 RX-bytes: 9600 + TX-packets: 1 TX-errors: 0 TX-bytes: 9600 + ############################################################################ + +Verify that TX-bytes on port 0 and RX-bytes on port 0 are 9600. + +4. Set mtu is 1500 :: + + testpmd> port config mtu 1500 + +5. Send a packet with size 1518 bytes :: + + testpmd> show port stats 0 + + ######################## NIC statistics for port 0 ######################## + RX-packets: 1 RX-errors: 0 RX-bytes: 1518 + TX-packets: 1 TX-errors: 0 TX-bytes: 1518 + ############################################################################ + +Verify that TX-bytes on port 0 and RX-bytes on port 0 are 1518 + +7. Send a packet with size 1519 bytes :: + + testpmd> show port stats 0 + + ######################## NIC statistics for port 0 ######################## + RX-packets: 0 RX-errors: 1 RX-bytes: 0 + TX-packets: 0 TX-errors: 0 TX-bytes: 0 + ############################################################################ + +Verify that TX-bytes on port 0 and RX-bytes on port 1 are 0 + +Test Case 2: test RSS +==================================================== +1. set fwd mode is rxonly:: + + testpmd> set fwd rxonly + testpmd> set verbose 1 + testpmd> start + +4. Send different hash types' packets with different keywords, then check rx port + could receive packets by different queues:: + + sendp([Ether(dst="00:01:23:45:67:89")/IP(src="192.168.0.4", dst=RandIP())], iface="eth3") + +Test Case 3: test reset RX/TX queues +==================================================== +1. Run ``port stop all`` to stop all ports. + +2. Run ``port config all rxq 2`` to change the number of receiving queues to two. + +3. Run ``port config all txq 2`` to change the number of transmitting queues to two. + +4. Run ``port start all`` to restart all ports. + +5. Check with ``show config rxtx`` that the configuration for these parameters changed. + +6. Run ``start`` again to restart the forwarding, then start packet generator to transmit + and receive packets, and check if testpmd is able to receive and forward packets + successfully. diff --git a/test_plans/vf_smoke_test.rst b/test_plans/vf_smoke_test.rst new file mode 100644 index 00000000..35c60256 --- /dev/null +++ b/test_plans/vf_smoke_test.rst @@ -0,0 +1,176 @@ +.. Copyright (c) <2020>, Intel Corporation + 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. + +================== +NIC VF Smoke Test +================== + +Description +=========== +Test the basic functions of dpdk. +1. Port connection status. +2. Launch testpmd normally. +3. Basic rx and tx. + +Prerequisites +============= + +1. Hardware: + + niantic/fortville/columbiaville + +2. Software: + + dpdk: http://dpdk.org/git/dpdk + scapy: http://www.secdev.org/projects/scapy/ + +3. Compile DPDK:: + + CC=gcc meson -Denable_kmods=True -Dlibdir=lib --default-library=static x86_64-native-linuxapp-gcc + ninja -C x86_64-native-linuxapp-gcc + +4. Get the pci device id of DUT, for example:: + + ./usertools/dpdk-devbind.py -s + + 0000:86:01.0 'Device 1593' if=enp134s0f0 drv=ice unused=vfio-pci + +5. Generate 1 VFs on PF:: + + echo 1 > /sys/bus/pci/devices/0000:86:01.0/sriov_numvfs + + ./usertools/dpdk-devbind.py -s + 0000:86:01.0 'Ethernet Adaptive Virtual Function 1889' if=enp134s1 drv=iavf unused=vfio-pci + +6. Set VF MAC address:: + + ip link set enp134s0f0 vf 0 mac 00:01:23:45:67:89 + +7. Bind VF to dpdk driver:: + + modprobe vfio-pci + ./usertools/dpdk-devbind.py -b vfio-pci 0000:86:01.0 + +8. Launch dpdk on VF:: + + ./x86_64-native-linuxapp-gcc/app/dpdk-testpmd -c 0xf -n 4 -a 0000:86:01.0 --file-prefix=pf -- -i --max-pkt-len=9600 --tx-offloads=0x00008000 --rxq=4 --txq=4 + testpmd> set fwd mac + testpmd> set verbose 3 + testpmd> start + testpmd> show port info all + + +Test Case 1: test enable and disable jumbo frame +==================================================== + +1. set fwd mode is mac:: + + testpmd> set fwd mac + testpmd> set verbose 3 + testpmd> start + +2. Send a packet with size 9601 bytes :: + + testpmd> show port stats 0 + + ######################## NIC statistics for port 0 ######################## + RX-packets: 0 RX-errors: 1 RX-bytes: 0 + TX-packets: 0 TX-errors: 0 TX-bytes: 0 + ############################################################################ + +Verify that TX-bytes on port 0 and RX-bytes on port 0 are 0. + +3. Send a packet with size 9600 bytes :: + + testpmd> show port stats 0 + + ######################## NIC statistics for port 0 ######################## + RX-packets: 1 RX-errors: 0 RX-bytes: 9600 + TX-packets: 1 TX-errors: 0 TX-bytes: 9600 + ############################################################################ + +Verify that TX-bytes on port 0 and RX-bytes on port 0 are 9600. + +4. Set mtu is 1500 :: + + testpmd> port config mtu 1500 + +5. Send a packet with size 1518 bytes :: + + testpmd> show port stats 0 + + ######################## NIC statistics for port 0 ######################## + RX-packets: 1 RX-errors: 0 RX-bytes: 1518 + TX-packets: 1 TX-errors: 0 TX-bytes: 1518 + ############################################################################ + +Verify that TX-bytes on port 0 and RX-bytes on port 0 are 1518 + +7. Send a packet with size 1519 bytes :: + + testpmd> show port stats 0 + + ######################## NIC statistics for port 0 ######################## + RX-packets: 0 RX-errors: 1 RX-bytes: 0 + TX-packets: 0 TX-errors: 0 TX-bytes: 0 + ############################################################################ + +Verify that TX-bytes on port 0 and RX-bytes on port 1 are 0 + +Test Case 2: test RSS +==================================================== +1. set fwd mode is rxonly:: + + testpmd> set fwd rxonly + testpmd> set verbose 1 + testpmd> start + +4. Send different hash types' packets with different keywords, then check rx port + could receive packets by different queues:: + + sendp([Ether(dst="00:01:23:45:67:89")/IP(src="192.168.0.4", dst=RandIP())], iface="eth3") + +Test Case 3: test reset RX/TX queues +==================================================== +1. Run ``port stop all`` to stop all ports. + +2. Run ``port config all rxq 2`` to change the number of receiving queues to two. + +3. Run ``port config all txq 2`` to change the number of transmitting queues to two. + +4. Run ``port start all`` to restart all ports. + +5. Check with ``show config rxtx`` that the configuration for these parameters changed. + +6. Run ``start`` again to restart the forwarding, then start packet generator to transmit + and receive packets, and check if testpmd is able to receive and forward packets + successfully. From patchwork Wed Jan 13 06:26:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Chen, BoX C" X-Patchwork-Id: 86452 Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2CB79A04B5; Wed, 13 Jan 2021 07:28:00 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 267F6140E61; Wed, 13 Jan 2021 07:28:00 +0100 (CET) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mails.dpdk.org (Postfix) with ESMTP id 9B31E140E5B for ; Wed, 13 Jan 2021 07:27:58 +0100 (CET) IronPort-SDR: +Z3242nPiFxN55+UdZZSzz+50MJU7sdWC0UevBSJEpNyM+oHyK/u9ZfOK5DjcerYHhc0O+7/jI v//J/DiPyduw== X-IronPort-AV: E=McAfee;i="6000,8403,9862"; a="242230833" X-IronPort-AV: E=Sophos;i="5.79,343,1602572400"; d="scan'208";a="242230833" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jan 2021 22:27:58 -0800 IronPort-SDR: J+qGdL0rpWgptaPeI2OBjJiqW8Fl2GPM6CgevthQnVwQlKu1skvcg50KSXN/8s18Ve/v97Wh6E wddmnJYZDkCg== X-IronPort-AV: E=Sophos;i="5.79,343,1602572400"; d="scan'208";a="424447871" Received: from unknown (HELO localhost.localdomain) ([10.240.183.58]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jan 2021 22:27:56 -0800 From: ChenBo To: dts@dpdk.org Cc: ChenBo Date: Wed, 13 Jan 2021 14:26:28 +0800 Message-Id: <20210113062628.4526-3-box.c.chen@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210113062628.4526-1-box.c.chen@intel.com> References: <20210113062628.4526-1-box.c.chen@intel.com> Subject: [dts] [PATCH V1 2/2] add smoke test scripts of nic part X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: test suite reviews and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dts-bounces@dpdk.org Sender: "dts" according to testplan, update test scripts. Signed-off-by: ChenBo --- tests/TestSuite_pf_smoke.py | 151 ++++++++++++++++++++++++++++++ tests/TestSuite_vf_smoke.py | 171 ++++++++++++++++++++++++++++++++++ tests/smoke_base.py | 177 ++++++++++++++++++++++++++++++++++++ 3 files changed, 499 insertions(+) create mode 100644 tests/TestSuite_pf_smoke.py create mode 100644 tests/TestSuite_vf_smoke.py create mode 100644 tests/smoke_base.py diff --git a/tests/TestSuite_pf_smoke.py b/tests/TestSuite_pf_smoke.py new file mode 100644 index 00000000..19a6afa9 --- /dev/null +++ b/tests/TestSuite_pf_smoke.py @@ -0,0 +1,151 @@ +# BSD LICENSE +# +# Copyright(c)2020 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. + +from packet import Packet +from pmd_output import PmdOutput +from test_case import TestCase +from smoke_base import SmokeTest +from smoke_base import JUMBO_FRAME_LENGTH +from smoke_base import JUMBO_FRAME_MTU +from smoke_base import DEFAULT_MTU_VALUE +from smoke_base import LAUNCH_QUEUE + + +class TestPfSmoke(TestCase): + + def set_up_all(self): + """ + Run at the start of each test suite. + + + Smoke Prerequisites + """ + + # Based on h/w type, choose how many ports to use + self.smoke_dut_ports = self.dut.get_ports(self.nic) + + # Verify that enough ports are available + self.verify(len(self.smoke_dut_ports) >= 1, "Insufficient ports") + self.smoke_tester_port = self.tester.get_local_port(self.smoke_dut_ports[0]) + self.smoke_tester_nic = self.tester.get_interface(self.smoke_tester_port) + self.smoke_tester_mac = self.tester.get_mac(self.smoke_dut_ports[0]) + self.smoke_dut_mac = self.dut.get_mac_address(self.smoke_dut_ports[0]) + + # Verify that enough core + self.cores = self.dut.get_core_list("1S/4C/1T") + self.verify(self.cores is not None, "Insufficient cores for speed testing") + + # init pkt + self.pkt = Packet() + + # set default app parameter + self.pmd_out = PmdOutput(self.dut) + self.ports = [self.dut.ports_info[self.smoke_dut_ports[0]]['pci']] + self.param = '--max-pkt-len={} --tx-offloads=0x8000 --rxq={} --txq={}'.format(JUMBO_FRAME_LENGTH, + LAUNCH_QUEUE, + LAUNCH_QUEUE) + self.test_func = SmokeTest(self) + self.check_session = self.dut.new_session(suite="pf_smoke_test") + + def set_up(self): + """ + Run before each test case. + """ + # verify app launch state. + out = self.check_session.send_expect("ls -l /var/run/dpdk |awk '/^d/ {print $NF}'", '# ', 1) + if out == '' or 'No such file or directory' in out: + self.pf_launch_dpdk_app() + + # set tester mtu + if self._suite_result.test_case == "test_pf_jumbo_frames": + self.tester.send_expect("ifconfig {} mtu {}".format(self.smoke_tester_nic, JUMBO_FRAME_MTU), '# ') + + def pf_launch_dpdk_app(self): + self.pmd_out.start_testpmd(cores=self.cores, ports=self.ports, param=self.param) + + # set default param + self.dut.send_expect("set promisc all off", "testpmd> ") + self.pmd_out.wait_link_status_up(self.smoke_dut_ports[0]) + + def test_pf_jumbo_frames(self): + """ + This case aims to test transmitting jumbo frame packet on testpmd with + jumbo frame support. + """ + self.dut.send_expect("set fwd mac", "testpmd> ") + self.dut.send_expect("set verbose 3", "testpmd> ") + self.dut.send_expect("start", "testpmd> ") + self.pmd_out.wait_link_status_up(self.smoke_dut_ports[0]) + result = self.test_func.check_jumbo_frames() + self.verify(result, "enable disable jumbo frames failed") + + def test_pf_rss(self): + """ + Check default rss function. + """ + self.dut.send_expect("set fwd rxonly", "testpmd> ") + self.dut.send_expect("set verbose 1", "testpmd> ") + self.dut.send_expect("start", "testpmd> ") + self.pmd_out.wait_link_status_up(self.smoke_dut_ports[0]) + result = self.test_func.check_rss() + self.verify(result, "enable disable rss failed") + + def test_pf_tx_rx_queue(self): + """ + Check dpdk queue configure. + """ + self.dut.send_expect("set verbose 1", "testpmd> ") + self.dut.send_expect("set fwd rxonly", "testpmd> ") + self.dut.send_expect("start", "testpmd> ") + self.pmd_out.wait_link_status_up(self.smoke_dut_ports[0]) + result = self.test_func.check_tx_rx_queue() + self.verify(result, "check tx rx queue failed") + + def tear_down(self): + self.pmd_out.execute_cmd("stop") + + # set tester mtu to default value + if self._suite_result.test_case == "test_pf_jumbo_frames": + self.tester.send_expect("ifconfig {} mtu {}".format(self.smoke_tester_nic, DEFAULT_MTU_VALUE), '# ') + + # set dpdk queues to launch value + if self._suite_result.test_case == "test_pf_tx_rx_queue": + self.dut.send_expect("stop", "testpmd> ") + self.dut.send_expect("port stop all", "testpmd> ") + self.dut.send_expect("port config all rxq {}".format(LAUNCH_QUEUE), "testpmd> ") + self.dut.send_expect("port config all txq {}".format(LAUNCH_QUEUE), "testpmd> ") + self.dut.send_expect("port start all", "testpmd> ") + + def tear_down_all(self): + if self.check_session: + self.dut.close_session(self.check_session) + self.check_session = None + self.dut.kill_all() diff --git a/tests/TestSuite_vf_smoke.py b/tests/TestSuite_vf_smoke.py new file mode 100644 index 00000000..0493ea20 --- /dev/null +++ b/tests/TestSuite_vf_smoke.py @@ -0,0 +1,171 @@ +# BSD LICENSE +# +# Copyright(c)2020 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. + +from packet import Packet +from pmd_output import PmdOutput +from test_case import TestCase +from smoke_base import SmokeTest +from smoke_base import JUMBO_FRAME_LENGTH +from smoke_base import JUMBO_FRAME_MTU +from smoke_base import DEFAULT_MTU_VALUE +from smoke_base import LAUNCH_QUEUE + +VF_MAC_ADDR = '00:11:22:33:44:55' + + +class TestVfSmoke(TestCase): + + def set_up_all(self): + """ + Run at the start of each test suite. + + + Smoke Prerequisites + """ + + # Based on h/w type, choose how many ports to use + self.smoke_dut_ports = self.dut.get_ports(self.nic) + self.check_session = None + + # Verify that enough ports are available + self.verify(len(self.smoke_dut_ports) >= 1, "Insufficient ports") + self.pf_interface = self.dut.ports_info[self.smoke_dut_ports[0]]['intf'] + self.smoke_tester_port = self.tester.get_local_port(self.smoke_dut_ports[0]) + self.smoke_tester_nic = self.tester.get_interface(self.smoke_tester_port) + self.smoke_tester_mac = self.tester.get_mac(self.smoke_dut_ports[0]) + self.smoke_dut_mac = VF_MAC_ADDR + + # Verify that enough core + self.cores = self.dut.get_core_list("1S/4C/1T") + self.verify(self.cores is not None, "Insufficient cores for speed testing") + + # init pkt + self.pkt = Packet() + + # generate vf + self.dut.bind_interfaces_linux(self.kdriver) + self.dut.generate_sriov_vfs_by_port(self.smoke_dut_ports[0], 1, self.kdriver) + self.vf_ports = self.dut.ports_info[self.smoke_dut_ports[0]]['vfs_port'] + self.verify(len(self.vf_ports) != 0, "VF create failed") + for port in self.vf_ports: + port.bind_driver(self.drivername) + self.vf0_prop = {'opt_host': self.vf_ports[0].pci} + self.dut.send_expect("ifconfig %s up" % self.pf_interface, "# ") + self.tester.send_expect("ifconfig %s up" % self.smoke_tester_nic, "# ") + + # set vf mac address + self.dut.send_expect("ip link set %s vf 0 mac %s" % (self.pf_interface, self.smoke_dut_mac), "# ") + + # set default app parameter + if self.vf0_prop is not None: + self.ports = [self.vf0_prop['opt_host']] + + self.pmd_out = PmdOutput(self.dut) + self.param = '--max-pkt-len={} --tx-offloads=0x8000 --rxq={} --txq={}'.format(JUMBO_FRAME_LENGTH, + LAUNCH_QUEUE, + LAUNCH_QUEUE) + self.test_func = SmokeTest(self) + self.check_session = self.dut.new_session(suite="vf_smoke_test") + + def set_up(self): + """ + Run before each test case. + """ + # verify app launch state. + out = self.check_session.send_expect("ls -l /var/run/dpdk |awk '/^d/ {print $NF}'", '# ', 1) + if out == '' or 'No such file or directory' in out: + self.vf_launch_dpdk_app() + + if self._suite_result.test_case == "test_vf_jumbo_frames": + self.tester.send_expect("ifconfig {} mtu {}".format(self.smoke_tester_nic, JUMBO_FRAME_MTU), '# ') + + def vf_launch_dpdk_app(self): + self.pmd_out.start_testpmd(cores=self.cores, ports=self.ports, param=self.param) + + # set default param + self.dut.send_expect("set promisc all off", "testpmd> ") + self.pmd_out.wait_link_status_up(self.smoke_dut_ports[0]) + + def test_vf_jumbo_frames(self): + """ + This case aims to test transmitting jumbo frame packet on testpmd with + jumbo frame support. + """ + self.dut.send_expect("set verbose 3", "testpmd> ") + self.dut.send_expect("set fwd mac", "testpmd> ") + self.dut.send_expect("start", "testpmd> ") + self.pmd_out.wait_link_status_up(self.smoke_dut_ports[0]) + result = self.test_func.check_jumbo_frames() + self.verify(result, "enable disable jumbo frames failed") + + def test_vf_rss(self): + """ + Check default rss function. + """ + self.dut.send_expect("set verbose 1", "testpmd> ") + self.dut.send_expect("set fwd rxonly", "testpmd> ") + self.dut.send_expect("start", "testpmd> ") + self.pmd_out.wait_link_status_up(self.smoke_dut_ports[0]) + result = self.test_func.check_rss() + self.verify(result, "enable disable rss failed") + + def test_vf_tx_rx_queue(self): + """ + Check dpdk queue configure. + """ + self.dut.send_expect("set fwd rxonly", "testpmd> ") + self.dut.send_expect("set verbose 1", "testpmd> ") + self.dut.send_expect("start", "testpmd> ") + self.pmd_out.wait_link_status_up(self.smoke_dut_ports[0]) + result = self.test_func.check_tx_rx_queue() + self.verify(result, "check tx rx queue failed") + + def tear_down(self): + # set tester mtu to default value + self.pmd_out.execute_cmd("stop") + if self._suite_result.test_case == "test_vf_jumbo_frames": + self.tester.send_expect("ifconfig {} mtu {}".format(self.smoke_tester_nic, DEFAULT_PKG_LEN), '# ') + + # set dpdk queues to launch value + if self._suite_result.test_case == "test_vf_tx_rx_queue": + self.dut.send_expect("port stop all", "testpmd> ") + self.dut.send_expect("port config all rxq {}".format(LAUNCH_QUEUE), "testpmd> ") + self.dut.send_expect("port config all txq {}".format(LAUNCH_QUEUE), "testpmd> ") + self.dut.send_expect("port start all", "testpmd> ") + + def tear_down_all(self): + if self.check_session: + self.dut.close_session(self.check_session) + self.check_session = None + self.dut.kill_all() + if self.vf0_prop: + self.dut.destroy_sriov_vfs_by_port(self.smoke_dut_ports[0]) + self.dut.bind_interfaces_linux(self.drivername) diff --git a/tests/smoke_base.py b/tests/smoke_base.py new file mode 100644 index 00000000..fe719f91 --- /dev/null +++ b/tests/smoke_base.py @@ -0,0 +1,177 @@ +# BSD LICENSE +# +# Copyright(c)2020 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. + +import re +import time +from settings import HEADER_SIZE + +JUMBO_FRAME_MTU = 9600 +DEFAULT_MTU_VALUE = 1500 +COMMON_PKT_LEN = 64 +JUMBO_FRAME_LENGTH = 9000 +IPV4_SRC = '192.168.0.11' +IPV4_DST = '192.168.0.12' +LAUNCH_QUEUE = 4 +PACKAGE_COUNT = 32 + + +class SmokeTest(object): + def __init__(self, test_case, **kwargs): + self.test_case = test_case + for name in kwargs: + setattr(self, name, kwargs[name]) + + def send_pkg_return_stats(self, pkt_size=COMMON_PKT_LEN, l3_src=IPV4_SRC, l3_dst=IPV4_DST, rss=False): + self.test_case.dut.send_expect("clear port stats all", "testpmd> ") + l3_len = pkt_size - HEADER_SIZE['eth'] + payload = pkt_size - HEADER_SIZE['eth'] - HEADER_SIZE['ip'] + hash_flag = False + if rss: + pkt = [] + # generate PACKAGE_COUNT count package, the IP dst is random. + for i in range(0, PACKAGE_COUNT): + p = "Ether(dst='{}',src='{}')/IP(src='{}',dst=RandIP(),len={})/Raw(load='X'*{})".format( + self.test_case.smoke_dut_mac, + self.test_case.smoke_tester_mac, + l3_src, + l3_len, + payload) + pkt.append(p) + else: + pkt = ["Ether(dst='{}',src='{}')/IP(src='{}',dst='{}',len={})/Raw(load='X'*{})".format( + self.test_case.smoke_dut_mac, + self.test_case.smoke_tester_mac, + l3_src, + l3_dst, + l3_len, + payload)] + + self.test_case.pkt.update_pkt(pkt) + + # wait package update + time.sleep(1) + self.test_case.pkt.send_pkt(crb=self.test_case.tester, tx_port=self.test_case.smoke_tester_nic) + time.sleep(.5) + out = self.test_case.pmd_out.get_output(timeout=1) + queue_pattern = re.compile(r'Receive\squeue=(\w+)') + # collect all queues + queues = queue_pattern.findall(out) + # get dpdk statistical information + stats = self.test_case.pmd_out.get_pmd_stats(self.test_case.smoke_dut_ports[0]) + if 'PKT_RX_RSS_HASH' in out: + hash_flag = True + + if rss: + rss_pattern = re.compile(r'-\sRSS\shash=(\w+)') + # collect all hash value + rss_hash = rss_pattern.findall(out) + if 0 != len(rss_hash): + return hash_flag, queues, rss_hash + else: + if 0 != len(queues): + return hash_flag, queues, None + else: + return hash_flag, None, None + if 0 != len(queues): + return queues[0], stats + return None, stats + + def check_jumbo_frames(self): + """ + The packet total size include ethernet header, ip header, and payload. + ethernet header length is 18 bytes, ip standard header length is 20 bytes. + The packet forwarded failed. + """ + pkg_size = JUMBO_FRAME_LENGTH + 1 + queues, stats = self.send_pkg_return_stats(pkg_size) + if 1 != stats['RX-errors'] and 0 != stats['TX-packets']: + self.test_case.logger.info("jumbo frame: The RX[{}] or TX[{}] packet error".format(stats['RX-errors'], + stats['TX-packets'])) + return False + + # The packet can be forwarded successfully. + pkg_size = JUMBO_FRAME_LENGTH + queues, stats = self.send_pkg_return_stats(pkg_size) + if 1 != stats['TX-packets']: + self.test_case.logger.info("jumbo frame: The TX[{}] packet error".format(stats['TX-packets'])) + return False + + return True + + def check_rss(self): + """ + Test the basic functions of RSS, every queue can receive packets. + """ + hash_flag, queues, hash_values = self.send_pkg_return_stats(rss=True) + if queues is None or hash_values is None: + return False + queues = list(set(queues)) + hash_values = list(set(hash_values)) + + # verify that each queue has packets, verify hash value are not equal, and hash flag exists. + if LAUNCH_QUEUE != len(queues) or 1 == hash_values or hash_flag is False: + self.test_case.logger.info("rss the hash flag [{}] [{}] error".format(queues, hash_values)) + return False + + return True + + def check_tx_rx_queue(self): + """ + Test configuration queue function can work. + """ + # verify default configure can work + queues, stats = self.send_pkg_return_stats() + if queues is None: + self.test_case.logger.info("txq rxq the queues[{}] error".format(queues)) + return False + + self.test_case.dut.send_expect("stop", "testpmd> ") + self.test_case.dut.send_expect("port stop all", "testpmd> ") + self.test_case.dut.send_expect("port config all rxq 1", "testpmd> ") + self.test_case.dut.send_expect("port config all txq 1", "testpmd> ") + out = self.test_case.dut.send_expect("show config rxtx", "testpmd> ") + if 'RX queue number: 1' not in out: + self.test_case.logger.info("RX queue number 1 no display") + return False + if 'Tx queue number: 1' not in out: + self.test_case.logger.info("Tx queue number 1 no display") + return False + + self.test_case.dut.send_expect("port start all", "testpmd> ") + self.test_case.dut.send_expect("start", "testpmd> ") + self.test_case.pmd_out.wait_link_status_up(self.test_case.smoke_dut_ports[0]) + queue_after, stats = self.send_pkg_return_stats() + + if queue_after is None: + self.test_case.logger.info("after txq rxq the queue [{}] error".format(queue_after)) + return False + + return True