From patchwork Wed Aug 14 18:20:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Spewock X-Patchwork-Id: 143182 X-Patchwork-Delegate: juraj.linkes@pantheon.tech 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 92104457C6; Wed, 14 Aug 2024 20:20:27 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8F64A41141; Wed, 14 Aug 2024 20:20:25 +0200 (CEST) Received: from mail-pf1-f225.google.com (mail-pf1-f225.google.com [209.85.210.225]) by mails.dpdk.org (Postfix) with ESMTP id 9B06A41141 for ; Wed, 14 Aug 2024 20:20:23 +0200 (CEST) Received: by mail-pf1-f225.google.com with SMTP id d2e1a72fcca58-710ec581999so76006b3a.2 for ; Wed, 14 Aug 2024 11:20:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iol.unh.edu; s=unh-iol; t=1723659622; x=1724264422; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ZwEUmCel0LWyCNHWUliGIgsth9jaZXmaMCwq6q66mYc=; b=XDL8RtbyLqtfBwmQLE9Yech5mdqZShteGiHlCE0eKWKDgRm6IxXo3oY9+qgit2l842 q2NBIj2gZMMJGR+f9ogHAR6kUc7puRY0vQomQWHLjfHf3orc+FbVS46kQ+LsmaST7BEA eh+DVgIL/6Zd8UU0/xm8hUL4fFljdEnNTIOBU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723659622; x=1724264422; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZwEUmCel0LWyCNHWUliGIgsth9jaZXmaMCwq6q66mYc=; b=rEnGJzXBcElQMERS8LBxLPuObXOxD/CflBj3Q+D0iIKIeWnVAyOoqQAyDZ3soMXAbQ 2rpAqghZ2g7R9Fsu723yVzwimAslZrZLHMwPYrCJjlJmWg0plfIKw1te2WtiF4/rMHDv SgGopi0NNOvxgBUye5ft33LT4OVp2KhkflNYs5bcMyfAKLB8cHg/7nlSlAvzW9r/cBMH wsa1esff0AhcSoQl5iz/Z2VfJCDGvlztrAznzQWySNwfSaL1LZixuY9V6K60gYmsaSdH bVMgAHS9kav9CtXz+awro8tbCklP0lVgG9oxCu4Fh3C00Ui0qM3EmT6rk3LTVsLwc5Yo 7ATw== X-Gm-Message-State: AOJu0Yz7DqHIrbJkyUt35uSJAZLnxdJbS/gL+EHyjPVk0ZPciUViMA31 ar8bBt1Ug26D7t1wsE6wkZdXr0JGwivANZ81RlNZlt+i8zRzDVq0Rxiw7ZBaXoppTzJi0gHjYUn 63dE5+oP0jMUAHuEVJ1QUL+QUrieVWYcKtXjTrEpWh1ZHAkyC X-Google-Smtp-Source: AGHT+IEp946Udd7zjV05nINj2tzAkhUpYlqDUiRU6wyma7o7WvKG3ZVD9seMtJPBu3Dw3mhI1Uu1mTV6J6TN X-Received: by 2002:a05:6a00:23d3:b0:710:591e:b52f with SMTP id d2e1a72fcca58-712670e7ac3mr5615385b3a.5.1723659622510; Wed, 14 Aug 2024 11:20:22 -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 41be03b00d2f7-7c697a674dfsm266682a12.25.2024.08.14.11.20.22 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Aug 2024 11:20:22 -0700 (PDT) X-Relaying-Domain: iol.unh.edu Received: from iol.unh.edu (unknown [IPv6:2606:4100:3880:1257::1083]) by postal.iol.unh.edu (Postfix) with ESMTP id CF040605C351; Wed, 14 Aug 2024 14:20:20 -0400 (EDT) From: jspewock@iol.unh.edu To: wathsala.vithanage@arm.com, thomas@monjalon.net, probb@iol.unh.edu, juraj.linkes@pantheon.tech, paul.szczepanek@arm.com, yoan.picchi@foss.arm.com, Honnappa.Nagarahalli@arm.com, npratte@iol.unh.edu, alex.chapman@arm.com, Luca.Vizzarro@arm.com Cc: dev@dpdk.org, Jeremy Spewock Subject: [PATCH v1 1/2] dts: add methods for closing ports to testpmd Date: Wed, 14 Aug 2024 14:20:04 -0400 Message-ID: <20240814182005.12251-2-jspewock@iol.unh.edu> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240814182005.12251-1-jspewock@iol.unh.edu> References: <20240814182005.12251-1-jspewock@iol.unh.edu> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Jeremy Spewock Closing ports is a standard configuration feature that is available in testpmd but the framework lacks the ability to access this command through the Testpmd API. This patch adds a method that performs this action and verifies the results of sending the command to allow developers to have more control over the state of the ports that testpmd is aware of. Depends-on: patch-142952 ("dts: add ability to start/stop testpmd ports") Signed-off-by: Jeremy Spewock --- dts/framework/remote_session/testpmd_shell.py | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/dts/framework/remote_session/testpmd_shell.py b/dts/framework/remote_session/testpmd_shell.py index ca24b28070..51593c61f5 100644 --- a/dts/framework/remote_session/testpmd_shell.py +++ b/dts/framework/remote_session/testpmd_shell.py @@ -805,6 +805,27 @@ def start_all_ports(self, verify: bool = True) -> None: self.ports_started = True + @requires_stopped_ports + def close_all_ports(self, verify: bool = True) -> None: + """Close all ports. + + Args: + verify: If :data:`True` the output of the close command will be scanned in an attempt + to verify that all ports were stopped successfully. Defaults to :data:`True`. + + Raises: + InteractiveCommandExecutionError: If `verify` is :data:`True` and at lease one port + failed to close. + """ + port_close_output = self.send_command("port close all") + if verify: + if type(self._app_params.ports) is list: + num_ports = len(self._app_params.ports) + if not all( + f"Port {p_id} is closed" in port_close_output for p_id in range(num_ports) + ): + raise InteractiveCommandExecutionError("Ports were not closed successfully.") + def show_port_info_all(self) -> list[TestPmdPort]: """Returns the information of all the ports. From patchwork Wed Aug 14 18:20:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Spewock X-Patchwork-Id: 143183 X-Patchwork-Delegate: juraj.linkes@pantheon.tech 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 DF560457C6; Wed, 14 Aug 2024 20:20:36 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C6AAB42794; Wed, 14 Aug 2024 20:20:36 +0200 (CEST) Received: from mail-oo1-f99.google.com (mail-oo1-f99.google.com [209.85.161.99]) by mails.dpdk.org (Postfix) with ESMTP id BB1A34278D for ; Wed, 14 Aug 2024 20:20:34 +0200 (CEST) Received: by mail-oo1-f99.google.com with SMTP id 006d021491bc7-5cdf7edddc5so129144eaf.0 for ; Wed, 14 Aug 2024 11:20:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iol.unh.edu; s=unh-iol; t=1723659634; x=1724264434; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ctz5qQwM0U8tljLJOl+waDjSUDyym1B7fu4DdyEBfZc=; b=F1rCD79oawL0vfqIk+AXAwUup6w65nbqAbJ9GTUgfqKAFHu8NL0ft6yLyFuqSY/c8e UwxycqDjM8lsj5RTQt3hP/WK1RjYULZRXQVeNFznni4JztPHr4zwt1M35/DUWFJRy6tB 8oxAc/rM+/n/F3jIvmQ8+utgvcDwme6V48GNg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723659634; x=1724264434; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ctz5qQwM0U8tljLJOl+waDjSUDyym1B7fu4DdyEBfZc=; b=hJpHIvgd+f77G8W80XWeNMAxrMmj9JAIgrL77B7qCdQOxnrIu4u5DLn/7EcOklbzXC BxXwq4yO2ao1J4RcDk8qmfQ2dkrCnYRXh9gWcxh5vp9vhn8ciPSkWQEcj2fY51CsxtX2 vHO6LD4Vmf1vWO2c+ni7SjtmV9iUyaa6HnwJEGrqnh4wuFtF0uuBINyUCIzK2aKREJFU hNbbN2jvE7FtMnLbokndfL3/j+fQ3NRu2s2ciJ+zLLg5oswws9XNRdTQqrnEZnJldY21 M6y3scedfRjNIBDSIc1AwOboAOAuJK5PdyHTLVE8qUzjp1ERTgjCJEg2VQrfhXdEagi1 PDGg== X-Gm-Message-State: AOJu0Yz/4Kme1rkVStpVECFsO6rye+jM8DmPYTc0NX/pXE6vE4uLQKHG ZIZsmigy0KyUuTWGkRyf8pG66J6lwB7eBLxt7BxKpofnJqPDWNpY5xoHOBaMpBkJCudlgNwtTtA rbCqOmCZgB2MdMGoM9tmRwp+oKTjmqG11s3rxLDIrj3+5Auj6 X-Google-Smtp-Source: AGHT+IGM9T409Zb4owvhHsX3T7rL3yLLg1Hdk/U7iUKizUZf51DZvAaKF0a3Jaor/0VUlp2wXJNyj4q49Uo6 X-Received: by 2002:a05:6871:28f:b0:26c:67fc:2987 with SMTP id 586e51a60fabf-26fe5be0661mr4187055fac.38.1723659624401; Wed, 14 Aug 2024 11:20:24 -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 586e51a60fabf-26c720ffb16sm673125fac.22.2024.08.14.11.20.23 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Aug 2024 11:20:24 -0700 (PDT) X-Relaying-Domain: iol.unh.edu Received: from iol.unh.edu (unknown [IPv6:2606:4100:3880:1257::1083]) by postal.iol.unh.edu (Postfix) with ESMTP id 07EC6605C351; Wed, 14 Aug 2024 14:20:23 -0400 (EDT) From: jspewock@iol.unh.edu To: wathsala.vithanage@arm.com, thomas@monjalon.net, probb@iol.unh.edu, juraj.linkes@pantheon.tech, paul.szczepanek@arm.com, yoan.picchi@foss.arm.com, Honnappa.Nagarahalli@arm.com, npratte@iol.unh.edu, alex.chapman@arm.com, Luca.Vizzarro@arm.com Cc: dev@dpdk.org, Jeremy Spewock Subject: [PATCH v1 2/2] dts: add port control testing suite Date: Wed, 14 Aug 2024 14:20:05 -0400 Message-ID: <20240814182005.12251-3-jspewock@iol.unh.edu> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240814182005.12251-1-jspewock@iol.unh.edu> References: <20240814182005.12251-1-jspewock@iol.unh.edu> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Jeremy Spewock This patch ports over the port_control test suite from the Old DTS framework and adapts the functionality to fit with the current testing framework. The test suite provides validation of basic port control functions such as starting, stopping, and closing ports. It should be noted that this test suite is not completely 1-to-1 with the one from Old DTS as it does exclude test cases that use QEMU for testing as this is not something we are looking to add to the framework in the near future. It also excludes test cases for resetting ports as this feature is something that is not supported by all devices and does not expose a capability regarding if it is through testpmd. Depends-on: patch-142949 ("dts: add ability to send/receive multiple packets") Signed-off-by: Jeremy Spewock --- dts/framework/config/conf_yaml_schema.json | 3 +- dts/tests/TestSuite_port_control.py | 80 ++++++++++++++++++++++ 2 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 dts/tests/TestSuite_port_control.py diff --git a/dts/framework/config/conf_yaml_schema.json b/dts/framework/config/conf_yaml_schema.json index f02a310bb5..78cbd17dad 100644 --- a/dts/framework/config/conf_yaml_schema.json +++ b/dts/framework/config/conf_yaml_schema.json @@ -187,7 +187,8 @@ "enum": [ "hello_world", "os_udp", - "pmd_buffer_scatter" + "pmd_buffer_scatter", + "port_control" ] }, "test_target": { diff --git a/dts/tests/TestSuite_port_control.py b/dts/tests/TestSuite_port_control.py new file mode 100644 index 0000000000..9e843512ab --- /dev/null +++ b/dts/tests/TestSuite_port_control.py @@ -0,0 +1,80 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2024 University of New Hampshire +"""Port Control Testing Suite. + +This test suite serves to show that ports within testpmd support basic configuration functions. +Things such as starting a port, stopping a port, and closing a port should all be supported by the +device. Additionally, after each of these configuration steps (outside of closing the port) it +should still be possible to start the port again and verify that the port is able to forward a +large amount of packets (1000 are sent in the test cases). +""" +from scapy.layers.l2 import Ether # type: ignore[import-untyped] +from scapy.packet import Packet, Raw # type: ignore[import-untyped] + +from framework.params.testpmd import SimpleForwardingModes +from framework.remote_session.testpmd_shell import TestPmdShell +from framework.test_suite import TestSuite + + +class TestPortControl(TestSuite): + """DPDK Port Control Testing Suite.""" + + def send_packets_and_verify(self) -> None: + """Send 1000 packets and verify that all packets were forwarded back. + + Packets sent are identical and are all ethernet frames with a payload of 30 "X" characters. + This payload is used to differentiate noise on the wire from packets sent by this + framework. + """ + payload = "X" * 30 + num_pakts = 1000 + send_p = Ether() / Raw(payload) + recv_pakts: list[Packet] = [] + # The scapy sniffer can only handle a little under 200 packets per 1000 at a time, so this + # is limited to 100 per burst. + for _ in range(int(num_pakts / 100)): + recv_pakts += self.send_packets_and_capture([send_p] * 100) + recv_pakts += self.send_packets_and_capture([send_p] * (num_pakts % 100)) + recv_pakts = [ + p + for p in recv_pakts + if ( + # Remove padding from the bytes. + hasattr(p, "load") + and p.load.decode("utf-8").replace("\x00", "") == payload + ) + ] + self.verify( + len(recv_pakts) == num_pakts, + f"Received {len(recv_pakts)} packets when {num_pakts} were expected.", + ) + + def test_start_ports(self) -> None: + """Ensure that the port can receive traffic after explicitly being started.""" + with TestPmdShell(self.sut_node, forward_mode=SimpleForwardingModes.mac) as testpmd: + testpmd.start_all_ports() + testpmd.start() + self.send_packets_and_verify() + + def test_stop_ports(self) -> None: + """Verify that the link goes down after stopping ports. + + This case also verifies that the port can be started again and properly forward traffic + after being stopped. + """ + with TestPmdShell(self.sut_node, forward_mode=SimpleForwardingModes.mac) as testpmd: + testpmd.stop_all_ports() + self.verify( + all(not p.is_link_up for p in testpmd.show_port_info_all()), + "Failed to stop all ports.", + ) + testpmd.start() + self.send_packets_and_verify() + + def test_close_ports(self) -> None: + """Verify that ports can be closed and no longer appear in testpmd when they are.""" + with TestPmdShell(self.sut_node) as testpmd: + testpmd.close_all_ports() + self.verify( + len(testpmd.show_port_info_all()) == 0, "Failed to close all ports in testpmd." + )