From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id BDC7C459FE; Mon, 23 Sep 2024 18:45:16 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1071040395; Mon, 23 Sep 2024 18:45:11 +0200 (CEST) Received: from mail-il1-f225.google.com (mail-il1-f225.google.com [209.85.166.225]) by mails.dpdk.org (Postfix) with ESMTP id C8105402E2 for ; Mon, 23 Sep 2024 18:45:07 +0200 (CEST) Received: by mail-il1-f225.google.com with SMTP id e9e14a558f8ab-3a0ca7cfeb4so9579055ab.2 for ; Mon, 23 Sep 2024 09:45:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iol.unh.edu; s=unh-iol; t=1727109907; x=1727714707; 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=/ckM5mKQiLeas/402lfh1fxPoB5KxYvnLbKrn6UjnJk=; b=G2atx6dWuO2nMQ5SlOKItClB0SjadhqC2rDowOODEsB13yOUIQ37wR9NkpxfWwqpVp 1FBonM8dM71sifuxz5WKabYZd1Ktdpwvs2AX1+jMn1oj2JoKIExfjLTJlD8oLoqq+C1W RoE8TPBqAQ05DeO00K4LiyD/JQOsw68ilXW18= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727109907; x=1727714707; 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=/ckM5mKQiLeas/402lfh1fxPoB5KxYvnLbKrn6UjnJk=; b=c02PzBVuH2DgodUauMX6+3iB5voQuaz4/ek+tqf6pM5ZSI25v4llQIXaDPgOIjxFlh t4/1cVChDrU5jmDzP+VNM4aAKq7WrX4W+kwq7x8lVxODj1EeeP0H1S2trJgjxLysLgC3 GUG8EyqaefpWcdAggzBjj8NRxHGfjxHhD6S0FGui08MbBMCgYeFExpVsCB5vp5LKT1gy u+lb4dnB01qcdPN8mSboWCcYrdNhouBgmrWN3rkHFHMRNtMairkmJyWG9C0wPCzPxZkd X/XhudVNccI+jMm0kM4q0Q5n2ZrLPASsXE0Lr0VMt23EU3C1I9wKgeaXv69ZAlhJP1W0 Tgtw== X-Gm-Message-State: AOJu0YzWgmtUR7Y5tvNlb4Ff/uJiVP3Dd7NA0wViItKfCo5Hm3OD3sJB fFUgyNzqG467SBB/NzvC+0+z8F7zEp4DPB588ankTQ0GY4Ra2TLlFYAgfTj/SP70UJk1ByyEFtJ r5tfSwG89BvC0uSScv1BFpLL0MjK78Qwn X-Google-Smtp-Source: AGHT+IF6edwmeNZ7AhsPlImzFdHQe0y/IYJcgfCW7/1XASDmKuwoTJHlFoYsD+J/Nw2FcaqyUqBLLZjoAXyF X-Received: by 2002:a05:6e02:1d0e:b0:3a0:a2c9:5bd1 with SMTP id e9e14a558f8ab-3a0c8c5d2a5mr104585405ab.3.1727109906896; Mon, 23 Sep 2024 09:45:06 -0700 (PDT) Received: from postal.iol.unh.edu (postal.iol.unh.edu. [132.177.123.84]) by smtp-relay.gmail.com with ESMTPS id e9e14a558f8ab-3a092dfdc0dsm8018285ab.12.2024.09.23.09.45.06 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Sep 2024 09:45:06 -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 DB6C8605C352; Mon, 23 Sep 2024 12:45:05 -0400 (EDT) From: jspewock@iol.unh.edu To: wathsala.vithanage@arm.com, paul.szczepanek@arm.com, juraj.linkes@pantheon.tech, thomas@monjalon.net, Luca.Vizzarro@arm.com, alex.chapman@arm.com, probb@iol.unh.edu, yoan.picchi@foss.arm.com, Honnappa.Nagarahalli@arm.com, npratte@iol.unh.edu Cc: dev@dpdk.org, Jeremy Spewock Subject: [PATCH v2 2/2] dts: add port control testing suite Date: Mon, 23 Sep 2024 12:44:53 -0400 Message-ID: <20240923164453.17904-3-jspewock@iol.unh.edu> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240923164453.17904-1-jspewock@iol.unh.edu> References: <20240814182005.12251-1-jspewock@iol.unh.edu> <20240923164453.17904-1-jspewock@iol.unh.edu> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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. Signed-off-by: Jeremy Spewock --- It should also be noted that this suite has issues running in some mlx5 NICs. This is due to the fact that ports are validated as "stopped" using their link status which does not update upon stopping ports of an mlx5 NIC. I am not sure at this time if this is intentional or just a bug, but it doesn't seem there is a consistent way to check if a port is stopped other than link status. 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 df390e8ae2..b0d8e1f6a6 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." + ) -- 2.46.0