From patchwork Tue Jul 7 13:40:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Daniel Kirichok X-Patchwork-Id: 73429 X-Patchwork-Delegate: ci@dpdk.org Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 7AA00A00BE; Tue, 7 Jul 2020 15:41:40 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3406D1D9FC; Tue, 7 Jul 2020 15:41:39 +0200 (CEST) Received: from mail-ot1-f98.google.com (mail-ot1-f98.google.com [209.85.210.98]) by dpdk.org (Postfix) with ESMTP id 955FC1D931 for ; Tue, 7 Jul 2020 15:41:37 +0200 (CEST) Received: by mail-ot1-f98.google.com with SMTP id n24so32105931otr.13 for ; Tue, 07 Jul 2020 06:41:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iol.unh.edu; s=unh-iol; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=5cpjn7qJamP9Q090c7TJYI+Vw68G90ZOrPyptrZutA0=; b=HaTy0Vxz9n2+AvQMrYZv4RaPNEbZXv0apVdzklPRN5rfBA3EYZAaBSKOLWjiVBSjVN QnphXGoYkNunChIgWAhWeJ+4kFeBvxhngyrenPkbL+3zO8BviSuBjljJ1aZ+iJXmWmhm n6X3QHsZXroWnW1WW7lQnVqbh2/pNlBRMkIyM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=5cpjn7qJamP9Q090c7TJYI+Vw68G90ZOrPyptrZutA0=; b=lpKGD2QMqgOVxmC4bGiXaMfXdXiHaVCeAGEZUrSSrWl/7dztwZMPr/hSFMx74FGkMp JmwblFF0URXZPjPmDmUvdIZcr2PPUh/I+eU+5c4OH5C6ETUgAnHGNeteo+voeZWGaWnv j0hd+jG/S4DNL/nopIvy+EsKli3hztAAIvSjnchjX/c8D+sq49EzdDw1Efkt4CQh7AjN F+g6s4qSFWZoZUXJMaC78O/Zd+gwiS/Q/WmAIv4Xn60C1oHyQ+HBb0DwC/FGoxs5xYS2 7AGWmoVcnOEK2yQ5VDRaM2Ttzax0UvBaJBPrU9KRPswNES6rov9RGfPoJz/3CCnGonQD XA+w== X-Gm-Message-State: AOAM5313ygZ6sLW7ACHU/GJ+Q0DHlgloYvPirLx0t0Ma5UoISwnOpSVV f8twbgsaw5OwVb391joGcOR7c4iARySKRNPRRIduHb/5QBFvW/bswpJtOBrNKPcz6rkm8c8PTuG G7l+LAH2lo1W5gT7h7jYYESnLcUSml7WU7toncNsewkXoRNvZ6etf/QZ/oZeM9W552Hofw3LAL/ MCqFOU79jRkI9SkQ== X-Google-Smtp-Source: ABdhPJxOS599mXKB3ATvtsRdf9njWBa/qWruhKYnTNKd6AT0dQ5Z8dV0NNhrnLCw6/A5lXDi+mt57nC5Faan X-Received: by 2002:a9d:3ea:: with SMTP id f97mr2552830otf.300.1594129295883; Tue, 07 Jul 2020 06:41:35 -0700 (PDT) Received: from postal.iol.unh.edu (postal.iol.unh.edu. [2606:4100:3880:1234::84]) by smtp-relay.gmail.com with ESMTPS id r2sm54186oof.2.2020.07.07.06.41.35 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Jul 2020 06:41:35 -0700 (PDT) X-Relaying-Domain: iol.unh.edu Received: from localhost.localdomain (unknown [10.31.0.117]) by postal.iol.unh.edu (Postfix) with ESMTP id 7AC606052500; Tue, 7 Jul 2020 09:41:34 -0400 (EDT) From: dkirichok@iol.unh.edu To: dts@dpdk.org Cc: mb@smartsharesystems.com, lylavoie@iol.unh.edu, thomas@monjalon.net, dev@dpdk.org, david.marchand@redhat.com, ferruh.yigit@intel.com, arybchenko@solarflare.com, i.dyukov@samsung.com, rasland@mellanox.com, j.hendergart@f5.com, dliu@iol.unh.edu, ohilyard@iol.unh.edu, Daniel Kirichok Date: Tue, 7 Jul 2020 09:40:39 -0400 Message-Id: <20200707134039.13165-1-dkirichok@iol.unh.edu> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH] speed-capabilities: added Speed Capabilities test case X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Daniel Kirichok Added test case for checking speed capabilities. Signed-off-by: Daniel Kirichok --- conf/speed_capabilities.cfg | 4 + test_plans/speed_capabilities_test_plan.rst | 84 ++++++++++++++ tests/TestSuite_speed_capabilities.py | 120 ++++++++++++++++++++ 3 files changed, 208 insertions(+) create mode 100644 conf/speed_capabilities.cfg create mode 100644 test_plans/speed_capabilities_test_plan.rst create mode 100644 tests/TestSuite_speed_capabilities.py diff --git a/conf/speed_capabilities.cfg b/conf/speed_capabilities.cfg new file mode 100644 index 0000000..c22f531 --- /dev/null +++ b/conf/speed_capabilities.cfg @@ -0,0 +1,4 @@ +[suite] +# The format for entering expected speeds is {'':'',...} +# Unit for speed must be in G or M +expected_speeds={'interface1': '10G', 'interface2': '100M'} diff --git a/test_plans/speed_capabilities_test_plan.rst b/test_plans/speed_capabilities_test_plan.rst new file mode 100644 index 0000000..2821612 --- /dev/null +++ b/test_plans/speed_capabilities_test_plan.rst @@ -0,0 +1,84 @@ +.. # BSD LICENSE + # + # Copyright(c) 2010-2014 Intel Corporation. All rights reserved. + # Copyright © 2018[, 2019] The University of New Hampshire. 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. + +======================= +Speed Capabilities Test +======================= + +The Speed Capabilities Test checks the speeds that the device lists and compares +it to a user-defined set of expected speeds set in the ``speed_capabilities.cfg``. + +Prerequisites +============= + +If using vfio the kernel must be >= 3.6+ and VT-d must be enabled in bios.When +using vfio, use the following commands to load the vfio driver and bind it +to the device under test:: + + modprobe vfio + modprobe vfio-pci + usertools/dpdk-devbind.py --bind=vfio-pci device_bus_id + +Assuming that ports ``0`` and ``1`` of the test target are directly connected +to the traffic generator, launch the ``testpmd`` application with the following +arguments:: + + ./build/app/testpmd -- -i --portmask=0x3 + +Start packet forwarding in the ``testpmd`` application with the ``start`` +command. Then, for each port on the target make the Traffic Generator +transmit a packet to the port of arbitrary size less than the MTU of +the target port, checking that the same amount of frames and bytes +are received back by the Traffic Generator from the port. + +Ensure that the ``speed_capabilities.cfg`` file correctly reflects the speeds +the device is expected to run at. + + +Test Case : Speed Capabilities Test +=================================== + +1. Use testpmd to retrieve the speed information that the interface is linked at:: + + testpmd> show port info + +2. Compares the speed value against the rate in the speed_capabilities.cfg file. + The supported options for expected speeds are 1G, 10G, 25G, 40G, and 100G. Each interface must have an expected speed associated with it. + Example file below:: + + [suite] + expected_speeds={'interface1': '10G', 'interface2': '100M'} + + +3. Verifies that the speeds matches accordingly. + +4. Repeats the verification for each NIC and interface found on the system. diff --git a/tests/TestSuite_speed_capabilities.py b/tests/TestSuite_speed_capabilities.py new file mode 100644 index 0000000..25c45e4 --- /dev/null +++ b/tests/TestSuite_speed_capabilities.py @@ -0,0 +1,120 @@ +# BSD LICENSE +# +# Copyright(c) 2010-2014 Intel Corporation. All rights reserved. +# Copyright © 2018[, 2019] The University of New Hampshire. 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. +""" +import utils +from pmd_output import PmdOutput +from test_case import TestCase + + +class TestSpeedCapabilities(TestCase): + def set_up_all(self): + """ + Run at the start of each test suite. + """ + self.ports = self.dut.get_ports() + self.ports_socket = self.dut.get_numa_id(self.ports[0]) + + for port in self.ports: + self.tester.send_expect(f"ifconfig {self.tester.get_interface(self.tester.get_local_port(port))} mtu 5000" + , "# ") + + self.pmdout = PmdOutput(self.dut) + self.vm_env_done = False + + def test_speed_capabilities(self): + self.pmdout.start_testpmd("Default") + + cfg_content = self.get_suite_cfg() + expected_speeds = cfg_content.get('expected_speeds') + + detected_interfaces = [] + + for port in self.ports: + interface_name = self.tester.get_interface(self.tester.get_local_port(port)) + + # Gives the speed in Mb/s + interface_speed = self.pmdout.get_port_link_speed(port) + + self.verify(interface_name in expected_speeds, f"The interface {interface_name} does not have an expected " + f"speed associated with it.") + + detected_interfaces.append(interface_name) + + expected_speed = expected_speeds[interface_name] + + # Isolates the unit (Either M or G) + expected_speed_unit = ''.join(i for i in expected_speed if not i.isdigit()) + + # Removes the unit from the speed + expected_speed = ''.join(i for i in expected_speed if i.isdigit()) + + self.verify(len(interface_speed) > 0, + f"A valid speed could not be read for the interface {interface_name}.") + + # Converts Gb/s to Mb/s for consistent comparison + if expected_speed_unit == "G": + expected_speed += "000" + + self.verify(interface_speed == expected_speed, + f"Detected speed: {interface_speed} Mb/s for the interface {interface_name}, " + f"but expected speed: {expected_speed} Mb/s") + + for key, value in expected_speeds.items(): + self.verify(key in detected_interfaces, f"The interface {key} expected the speed {value} in " + "speed_capabilities.cfg file, but it did not detect that interface.") + + def tear_down(self): + """ + Run after each test case. + """ + self.dut.kill_all() + self.pmdout.start_testpmd("Default", "--portmask=%s --port-topology=loop" % utils.create_mask(self.ports), + socket=self.ports_socket) + ports_num = len(self.ports) + # link up test, to avoid failing further tests if link was down + for i in range(ports_num): + # sometimes output text messing up testpmd prompt so trimmed prompt + self.dut.send_expect("set link-up port %d" % i, ">") + # start ports, to avoid failing further tests if ports are stopped + self.dut.send_expect("port start all", "testpmd> ", 100) + self.dut.send_expect("quit", "# ") + + def tear_down_all(self): + """ + Run after each test suite. + """ + if self.vm_env_done: + self.destroy_vm_env() + self.dut.kill_all()