From patchwork Tue Aug 6 18:56:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Spewock X-Patchwork-Id: 142970 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 C43FC45752; Tue, 6 Aug 2024 20:57:03 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D9C4240DCE; Tue, 6 Aug 2024 20:56:54 +0200 (CEST) Received: from mail-il1-f231.google.com (mail-il1-f231.google.com [209.85.166.231]) by mails.dpdk.org (Postfix) with ESMTP id 4469040685 for ; Tue, 6 Aug 2024 20:56:53 +0200 (CEST) Received: by mail-il1-f231.google.com with SMTP id e9e14a558f8ab-39b3e127748so3756305ab.0 for ; Tue, 06 Aug 2024 11:56:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iol.unh.edu; s=unh-iol; t=1722970612; x=1723575412; 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=mb0tstBqECCKkh2Ewhjzs5mBpr4A82jLnfPgsXqxj+k=; b=KC8d9T14x3NvONFdXExyEknwjdacyJJGF9FyFpOlAqXIcW9wQxPGT1inAUS4IiDz8F vx2Z5IEG2Ez+T8jKTuWqbe5192KAIhAxJ65BKkncIxr9ARr2qVr6jNas8mk0TIW6dmJR M0QNtMgYLuljQYMHC7Lv2N07dNP7k3lJZyGTo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722970612; x=1723575412; 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=mb0tstBqECCKkh2Ewhjzs5mBpr4A82jLnfPgsXqxj+k=; b=NaUdHkeTVtAwuxzENX3/HvYnvi2eQLY5OA7rGqbJ7qZ1W86xWJ+h7HON7G+eT/9KAQ 4WrEPJeBV8ZQh/TPUc5kTtyoIj5J0t1nlDL2fO+iEeMIJDPflSm5sF65wHjqJaPWMsso PwIdl2fkDf/Ton5e097p73mw0xJtIgyn7tYOKTctXQ0ZwWCgrSqj5m1B/Tv6wtHxFdlM IPuEOAMzq1eqf0IEKrBmhAwIsSIUjBT6qFwlGIatCZl5j3ZaMEpnzoT5Poczyixq34dv n9+Q3I3vaNp3I/KXq4p+got3pGZeZNDY6J3d25sASHWAmDJbB6c73TBAwatWjCmI3pxG jpmg== X-Gm-Message-State: AOJu0Yxq3aMJ2Za3Ne1Q33QP1/mOi54/9d1PNqCO48RC5Qy84QEzbybG 4BNdSLeQOqSe9fJrUmtE+ch3vwjyDIZlW/7JTzVf9p3HN/C6vgpmnCDlPC8z1q7sLvVoPlk+IGE fWwjLCLVq6mf3wSNxpgl+rAEhNPvfvSdGu/N3cvXzwwP5q/YT X-Google-Smtp-Source: AGHT+IEw6+oU9cdJTToeHFrdGDQBvThBs84qzMJ+SjVLhHAFJGAljx97Z0cYdDdDDEOO/bo8lJ8yXVw2MATW X-Received: by 2002:a05:6e02:1a82:b0:396:bfa6:6f30 with SMTP id e9e14a558f8ab-39b1fb6bc91mr248377225ab.6.1722970612384; Tue, 06 Aug 2024 11:56:52 -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 8926c6da1cb9f-4c8d6a4632fsm367164173.58.2024.08.06.11.56.52 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Aug 2024 11:56:52 -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 614A5605C351; Tue, 6 Aug 2024 14:56:51 -0400 (EDT) From: jspewock@iol.unh.edu To: alex.chapman@arm.com, Luca.Vizzarro@arm.com, Honnappa.Nagarahalli@arm.com, juraj.linkes@pantheon.tech, paul.szczepanek@arm.com, npratte@iol.unh.edu, probb@iol.unh.edu, yoan.picchi@foss.arm.com, wathsala.vithanage@arm.com, thomas@monjalon.net Cc: dev@dpdk.org, Jeremy Spewock Subject: [RFC PATCH v1 2/3] dts: add pf smoke testing suite Date: Tue, 6 Aug 2024 14:56:30 -0400 Message-ID: <20240806185631.335737-3-jspewock@iol.unh.edu> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240806185631.335737-1-jspewock@iol.unh.edu> References: <20240806185631.335737-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 adds a smoke testing suite for Physical Function features. The goal of this suite is to test some of the most basic features of DPDK on a physical function and bail out early if any of these features aren't supported as expected. Unlike DTS smoke tests, these ones are not included as a switch in the config file and thus are an additional test suite that developers can include alongside others at their own discretion. Depends-on: patch-142691 ("dts: add send_packets to test suites and rework packet addressing") Signed-off-by: Jeremy Spewock --- dts/tests/TestSuite_pf_smoke_tests.py | 129 ++++++++++++++++++++++++++ 1 file changed, 129 insertions(+) create mode 100644 dts/tests/TestSuite_pf_smoke_tests.py diff --git a/dts/tests/TestSuite_pf_smoke_tests.py b/dts/tests/TestSuite_pf_smoke_tests.py new file mode 100644 index 0000000000..82c84c7c8d --- /dev/null +++ b/dts/tests/TestSuite_pf_smoke_tests.py @@ -0,0 +1,129 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2024 University of New Hampshire +"""Physical Function (PF) smoke testing suite. + +This test suite tests some of the more common DPDK functionality on a PF. Things such as +jumbroframes, Receive Side Scaling (RSS) functions, and being able to modify the number of queues +at runtime should all be supported by PMDs that are capable of running DPDK. Since this is a smoke +testing suite, it is considered a blocking suite that will stop following ones from running. +""" + +from typing import ClassVar + +from scapy.layers.inet import IP # type: ignore[import-untyped] +from scapy.layers.l2 import Ether # type: ignore[import-untyped] +from scapy.packet import Raw # type: ignore[import-untyped] + +from framework.exception import InteractiveCommandExecutionError, TestCaseVerifyError +from framework.params.testpmd import SimpleForwardingModes +from framework.remote_session.testpmd_shell import TestPmdShell, VerboseOLFlag +from framework.test_suite import TestSuite + + +class TestPfSmokeTests(TestSuite): + """DPDK Physical Function Testing Suite. + + This test suite is designed to verify the basic functions of DPDK on a PF. The MTU of the ports + on the traffic generator are increased to 9000 to support jumboframes for one of the test + cases, and then reverted back to 1500 once the test suite is complete. Some functionality in + this test suite also relies on the ability of testpmd to recognize and flag invalid checksum + values in its verbose output. + + Attributes: + is_blocking: This test suite will block the execution of all other test suites + in the build target after it. + """ + + is_blocking: ClassVar[bool] = True + jumbo_frame_len: ClassVar[int] = 9000 + num_queues: int = 4 + rx_port: int = 0 + + def set_up_suite(self) -> None: + """Increase the MTU of the traffic generator to support jumboframes.""" + for port_link in self._port_links: + self.tg_node.main_session.configure_port_mtu(self.jumbo_frame_len, port_link.tg_port) + + def test_jumbo_frame_support(self) -> None: + """Verify that the PF is able to send and receive jumboframes.""" + with TestPmdShell( + self.sut_node, + max_pkt_len=self.jumbo_frame_len, + mbuf_size=[self.jumbo_frame_len + 128], + forward_mode=SimpleForwardingModes.mac, + ) as testpmd: + testpmd.start() + # Take 26 bytes off the MTU size to account for Ethernet headers + payload_len = self.jumbo_frame_len - 26 + packet = Ether() / Raw("X" * payload_len) + recv = self.send_packet_and_capture(packet) + self.verify( + any(hasattr(p, "load") and "X" * 20 in str(p.load) for p in recv), + f"Jumboframe was not received even when MTU was set to {self.jumbo_frame_len}.", + ) + + def test_rss_functionality(self) -> None: + """Test that Receive Side Scaling functions are working as intended. + + The primary things to test in this case are that packets that are sent with different + destination IP addresses are handled by different queues and that the RSS hash of every + packet is unique. Verification of these functionalities is done by sending packets with + invalid checksums so that the packets sent by this test suite can be differentiated from + other packets sent to the same port. This makes the assumption that other packets sent to + the port will all have valid checksums. + """ + with TestPmdShell( + self.sut_node, + forward_mode=SimpleForwardingModes.rxonly, + rx_queues=self.num_queues, + tx_queues=self.num_queues, + ) as testpmd: + testpmd.set_verbose(1) + send_pkts = [ + Ether() / IP(dst=f"192.168.0.{i+1}", chksum=0x0) for i in range(self.num_queues * 4) + ] + testpmd.start() + self.send_packets(send_pkts) + verbose_stats = TestPmdShell.extract_verbose_output(testpmd.stop()) + # Filter down the packets to only the ones with back checksums + for block in verbose_stats: + block.packets = list( + filter( + lambda x: VerboseOLFlag.RTE_MBUF_F_RX_IP_CKSUM_BAD in x.ol_flags, + block.packets, + ) + ) + # Remove any output blocks that don't have any packets left after filtering + verbose_stats = list(filter(lambda x: len(x.packets) > 0, verbose_stats)) + rss_hashes = [p.rss_hash for block in verbose_stats for p in block.packets] + self.verify( + all(rss_h is not None for rss_h in rss_hashes), + "At least one packet did not have an RSS hash.", + ) + self.verify( + len(set(rss_hashes)) == len(rss_hashes), + "RSS hashes were not unique.", + ) + self.verify( + all(any(q == b.queue_id for b in verbose_stats) for q in range(self.num_queues)), + "Not all ports were used when packets were sent with different source addresses.", + ) + + def test_runtime_modify_num_queues(self) -> None: + """Ensure that the number of queues on a port can be changed at runtime.""" + with TestPmdShell( + self.sut_node, rx_queues=self.num_queues, tx_queues=self.num_queues + ) as testpmd: + testpmd.port_stop_all() + try: + testpmd.set_num_queues_all(2, True, verify=True) + testpmd.set_num_queues_all(2, False, verify=True) + except InteractiveCommandExecutionError as e: + raise TestCaseVerifyError( + "Failed to change the number of queues on a port at runtime." + ) from e + + def tear_down_suite(self) -> None: + """Revert MTU back to a standard value of 1500.""" + for port_link in self._port_links: + self.tg_node.main_session.configure_port_mtu(1500, port_link.tg_port)