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 9A8F146053; Fri, 17 Jan 2025 15:58:58 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 199E140B9F; Fri, 17 Jan 2025 15:58:50 +0100 (CET) Received: from mail-qt1-f178.google.com (mail-qt1-f178.google.com [209.85.160.178]) by mails.dpdk.org (Postfix) with ESMTP id 1F66B4028F for ; Fri, 17 Jan 2025 15:58:49 +0100 (CET) Received: by mail-qt1-f178.google.com with SMTP id d75a77b69052e-46787dc1621so2512971cf.0 for ; Fri, 17 Jan 2025 06:58:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iol.unh.edu; s=unh-iol; t=1737125928; x=1737730728; 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=bnmd078BJd7qWtF/awGBZpAcTmvvFO4xDzZXPZUi17M=; b=CUm/kMc0dHWhzSFSV/Fv11p6aWUQCZPxm7QDBqiP+jSUNiTgF31PK4WuEO0yqLOYnf Gkap07pB3nUCrjDnEruBp8ssbNa95gwxvR1IbUTbWszwKHj0hzAGX1IQ1fDqh8bja9dq npJQGDCqycWLZPb3w6BVEjs5AQ2L2hz05qtKg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737125928; x=1737730728; 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=bnmd078BJd7qWtF/awGBZpAcTmvvFO4xDzZXPZUi17M=; b=cYk/GOjg+kyuD89czS5lvyxJF4XOX9DGKSjMtclPn6g7lBuGV2Vq/2QWLSQoFruLqV RJl/KemdAfVoajiWEtAgUGXdzLBDrK72GXFC0W5PL8kJOpm8mAtiysquq7rIRGmo5A+Y YN1oLDiNK+6m6EnT4N/kE8lFK64+nKw6WdgG4eZ5BMTjuWZFAafdISdhtZj4v62mbPkg 28Qo7A3ikHJwhMjh9yWqTQVUctEKdgcoUdhqIZLO029ZZ928rFJLynoSB2hdvaOIbb3S vgOhc/22vm35LVFBj+j1XbxUHCq8wrirZWmnd3G7JK7lvdbMPyahkoO0zXcWB/vyDYmR eVqw== X-Gm-Message-State: AOJu0Yx20CZM0wCzAi3tJJZIX6CeRI35C5PppPL83Km29P9kEBghQCNx bbU01UnUib7zBUuWVky+lmkzAL3MOVffwk6TnY//CiSnBpg3WBYlmGc8YxIe9AU= X-Gm-Gg: ASbGncuy9dTv1hEnvAo4Gr6ZO93o+FTycVlCsJqWyqcJnUEPc0pbOWktd3EViLVh7b5 StKlYK7TfOlxNLk1gE1Od8BgtIwzASKjmwWrTpxUK2BJVjs3F3QWoip933SG3JIjYPoZzWmGx/s Hhh/+HWoZH4Mi5rzq58cUO6oYFyoIciBXokNLDlwbtD9SEwpn/ycsuqrm29Rd8pld9zKKKLiFkK YxNlfqsPhtCMzZIYgw2hypP4fhxkchHN8/bGbmgOpZyaL13DgdmXNJSO804fonz1biO X-Google-Smtp-Source: AGHT+IEgywtH4mD9i3lKkqI2DovF3f2qCybxt72G3CyNj6DS2wVLDBlKZpdBrmZiQ330otqclsO6Gw== X-Received: by 2002:a05:622a:ca:b0:467:885e:2c6e with SMTP id d75a77b69052e-46e12a1c44amr18023801cf.1.1737125928372; Fri, 17 Jan 2025 06:58:48 -0800 (PST) Received: from localhost.unh.edu ([2606:4100:3880:1271:e2f8:4ec3:8bf3:864c]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-46e104027d5sm11798291cf.58.2025.01.17.06.58.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jan 2025 06:58:47 -0800 (PST) From: Nicholas Pratte To: yoan.picchi@foss.arm.com, ian.stokes@intel.com, probb@iol.unh.edu, stephen@networkplumber.org, Honnappa.Nagarahalli@arm.com, luca.vizzarro@arm.com, thomas@monjalon.net, thomas.wilks@arm.com, dmarx@iol.unh.edu, paul.szczepanek@arm.com Cc: dev@dpdk.org, Nicholas Pratte , Alex Chapman Subject: [PATCH v1 2/2] dts: add mtu update and jumbo frames test suite Date: Fri, 17 Jan 2025 09:58:38 -0500 Message-ID: <20250117145838.40206-3-npratte@iol.unh.edu> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250117145838.40206-1-npratte@iol.unh.edu> References: <20250117145838.40206-1-npratte@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 A functional test suite that assesses MTU updating and forwarding within a DPDK application. This suite consolidates the previous 'mtu_update' and 'jumbo_frames' test suites from the old dts framework into a single, comprehensive test suite, and it covers all of mtu the adjustment options within the ethdev api. Bugzilla ID: 1421 Signed-off-by: Nicholas Pratte Signed-off-by: Alex Chapman --- dts/tests/TestSuite_mtu_update_fwding.py | 278 +++++++++++++++++++++++ 1 file changed, 278 insertions(+) create mode 100644 dts/tests/TestSuite_mtu_update_fwding.py diff --git a/dts/tests/TestSuite_mtu_update_fwding.py b/dts/tests/TestSuite_mtu_update_fwding.py new file mode 100644 index 0000000000..caafc41576 --- /dev/null +++ b/dts/tests/TestSuite_mtu_update_fwding.py @@ -0,0 +1,278 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2024 Arm Limited +# Copyright(c) 2023-2024 University of New Hampshire +"""MTU update and jumbo frame forwarding test suite. + +A suite of tests to ensures the consistency of jumbo and standard frame transmission within a DPDK +application. If a NIC receives a packet that is greater than its assigned MTU length, then that +packet should be dropped. Likewise, if a NIC receives a packet that is less than or equal to a +designated MTU length, the packet should be accepted. + +The definition of MTU between individual vendors varies with a +/- difference of 9 bytes, at most. +To universally test MTU functionality, and not concern over individual vendor behavior, this test +suite compensates using a 9 byte upper and lower bound when testing a set MTU boundary. +""" + +from scapy.layers.inet import IP +from scapy.layers.l2 import Ether +from scapy.packet import Raw + +from framework.remote_session.testpmd_shell import TestPmdShell +from framework.test_suite import TestSuite, func_test + +STANDARD_FRAME = 1518 # --max-pkt-len will subtract l2 information at a minimum of 18 bytes. +JUMBO_FRAME = 9018 + +STANDARD_MTU = 1500 +JUMBO_MTU = 9000 + +IP_HEADER_LEN = 20 +VENDOR_AGNOSTIC_PADDING = 9 # Used as a work around for varying MTU definitions between vendors. + + +class TestMtuUpdateFwding(TestSuite): + """DPDK PMD jumbo frames and MTU update test suite. + + Assess the expected behavior of frames greater than, less then, or equal to a designated MTU + size in a DPDK application. + + Verify the behavior of both runtime MTU and pre-runtime MTU adjustments within DPDK + applications. (TestPMD's CLI and runtime MTU adjustment options leverage different logical + in components within ethdev to set a value). + + Test cases will verify that any frame greater than an assigned MTU are dropped and packets + less than or equal to a designated MTU are forwarded and fully intact. + """ + + def set_up_suite(self) -> None: + """Set up the test suite. + + Setup: + Set traffic generator MTU lengths to a size greater than scope of all + test cases. + """ + self.tg_node.main_session.configure_port_mtu(JUMBO_MTU + 200, self._tg_port_egress) + self.tg_node.main_session.configure_port_mtu(JUMBO_MTU + 200, self._tg_port_ingress) + + def send_packet_and_verify(self, pkt_size: int, should_receive: bool) -> None: + """Generate, send a packet, and assess its behavior based on a given packet size. + + Generates a packet based on a specified size and sends it to the SUT. The desired packet's + payload size is calculated, and a string of arbrity size, containing a single character, + is placed in the packet as payload. This method assesses whether or not it was forwarded, + depending on the test case, and does so via a check of the previously-inserted packet + payload. + + Args: + pkt_size: Size of packet to be generated and sent. + should_receive: Indicate whether the test case expects to receive the packet or not. + """ + padding = pkt_size - IP_HEADER_LEN + # Insert ' ' as placeholder 'CRC' error correction. + packet = Ether() / Raw(load=" ") / IP(len=pkt_size) / Raw(load="X" * padding) + received_packets = self.send_packet_and_capture(packet) + found = any( + ("X" * padding) in str(packets.load) + for packets in received_packets + if hasattr(packets, "load") + ) + + if should_receive: + self.verify(found, "Did not receive packet.") + else: + self.verify(not found, "Received packet.") + + def assess_mtu_boundary(self, testpmd_shell: TestPmdShell, mtu: int) -> None: + """Sets the new MTU and verifies packets at the set boundary. + + Ensure that packets smaller than or equal to a set MTU will be received and packets larger + will not. + + First, start testpmd and update the MTU. Then ensure the new value appears + on port info for all ports. + Next, start packet capturing and send 3 different lengths of packet and verify + they are handled correctly. + # 1. VENDOR_AGNOSTIC_PADDING units smaller than the MTU specified. + # 2. Equal to the MTU specified. + # 3. VENDOR_AGNOSTIC_PADDING units larger than the MTU specified (should be fragmented). + Finally, stop packet capturing. + + Args: + testpmd_shell: Active testpmd shell of a given test case. + mtu: New Maximum Transmission Unit to be tested. + """ + # Send 3 packets of different sizes (accounting for vendor inconsistencies). + # 1. VENDOR_AGNOSTIC_PADDING units smaller than the MTU specified. + # 2. Equal to the MTU specified. + # 3. VENDOR_AGNOSTIC_PADDING units larger than the MTU specified. + smaller_frame_size: int = mtu - VENDOR_AGNOSTIC_PADDING + equal_frame_size: int = mtu + larger_frame_size: int = mtu + VENDOR_AGNOSTIC_PADDING + + self.send_packet_and_verify(pkt_size=smaller_frame_size, should_receive=True) + self.send_packet_and_verify(pkt_size=equal_frame_size, should_receive=True) + + current_mtu = testpmd_shell.show_port_info(0).mtu + self.verify(current_mtu is not None, "Error grabbing testpmd MTU value.") + if current_mtu and ( + current_mtu >= STANDARD_MTU + VENDOR_AGNOSTIC_PADDING and mtu == STANDARD_MTU + ): + self.send_packet_and_verify(pkt_size=larger_frame_size, should_receive=True) + else: + self.send_packet_and_verify(pkt_size=larger_frame_size, should_receive=False) + + @func_test + def test_runtime_mtu_updating_and_forwarding(self) -> None: + """Verify runtime MTU adjustments and assess packet forwarding behavior. + + Test: + Start TestPMD in a paired topology. + Set port MTU to 1500. + Send packets of 1493, 1500 and 1509 bytes. + Verify the first two packets are forwarded and the last is dropped. + + Set port MTU to 2400. + Send packets of 1493, 1500 and 1509 bytes. + Verify all three packets are forwarded. + Send packets of 2393, 2400 and 2409 bytes. + Verify the first two packets are forwarded and the last is dropped. + + Set port MTU to 4800. + Send packets of 1493, 1500 and 1509 bytes. + Verify all three packets are forwarded. + Send packets of 4793, 4800 and 4809 bytes. + Verify the first two packets are forwarded and the last is dropped. + + Set port MTU to 9000. + Send packets of 1493, 1500 and 1509 bytes. + Verify all three packets are forwarded. + Send packets of 8993, 9000 and 9009 bytes. + Verify the first two packets are forwarded and the last is dropped. + Verify: + Verifies the successful forwarding of packets via a search for an inserted payload. + If the payload is found, the packet was transmitted successfully. Otherwise, the packet + is considered dropped. + + Verify that standard MTU packets forward, in addition to packets within the limits of + an MTU size set during runtime. + """ + with TestPmdShell( + self.sut_node, + tx_offloads=0x8000, + mbuf_size=[JUMBO_MTU + 200], + ) as testpmd: + # Configure the new MTU. + + # Start packet capturing. + testpmd.start() + + testpmd.set_port_mtu_all(1500, verify=True) + self.assess_mtu_boundary(testpmd, 1500) + + testpmd.set_port_mtu_all(2400, verify=True) + self.assess_mtu_boundary(testpmd, 1500) + self.assess_mtu_boundary(testpmd, 2400) + + testpmd.set_port_mtu_all(4800, verify=True) + self.assess_mtu_boundary(testpmd, 1500) + self.assess_mtu_boundary(testpmd, 4800) + + testpmd.set_port_mtu_all(9000, verify=True) + self.assess_mtu_boundary(testpmd, 1500) + self.assess_mtu_boundary(testpmd, 9000) + + @func_test + def test_cli_mtu_forwarding_for_std_packets(self) -> None: + """Assesses packet forwarding of standard MTU packets after pre-runtime MTU adjustments. + + Test: + Start TestPMD with MTU size of 1518 bytes, set pre-runtime. + Send packets of size 1493, 1500 and 1509 bytes. + Verify the first two packets are forwarded and the last is dropped. + Verify: + Verifies the successful forwarding of packets via a search for an inserted payload. + If the payload is found, the packet was transmitted successfully. Otherwise, the packet + is considered dropped. + + Verify the first two packets are forwarded and the last is dropped after pre-runtime + MTU modification. + """ + with TestPmdShell( + self.sut_node, + tx_offloads=0x8000, + mbuf_size=[JUMBO_MTU + 200], + mbcache=200, + max_pkt_len=STANDARD_FRAME, + ) as testpmd: + testpmd.start() + + self.send_packet_and_verify(STANDARD_MTU - VENDOR_AGNOSTIC_PADDING, should_receive=True) + self.send_packet_and_verify(STANDARD_MTU, should_receive=True) + self.send_packet_and_verify( + STANDARD_MTU + VENDOR_AGNOSTIC_PADDING, should_receive=False + ) + + @func_test + def test_cli_jumbo_forwarding_for_jumbo_mtu(self) -> None: + """Assess packet forwarding of packets within the bounds of a pre-runtime MTU adjustment. + + Test: + Start TestPMD with MTU size of 9018 bytes, set pre-runtime. + Send packets of size 8993, 9000 and 1509 bytes. + Verify: + Verifies the successful forwarding of packets via a search for an inserted payload. + If the payload is found, the packet was transmitted successfully. Otherwise, the packet + is considered dropped. + + Verify that all packets are forwarded after pre-runtime MTU modification. + """ + with TestPmdShell( + self.sut_node, + tx_offloads=0x8000, + mbuf_size=[JUMBO_MTU + 200], + mbcache=200, + max_pkt_len=JUMBO_FRAME, + ) as testpmd: + testpmd.start() + + self.send_packet_and_verify(JUMBO_MTU - VENDOR_AGNOSTIC_PADDING, should_receive=True) + self.send_packet_and_verify(JUMBO_MTU, should_receive=True) + self.send_packet_and_verify(STANDARD_MTU + VENDOR_AGNOSTIC_PADDING, should_receive=True) + + @func_test + def test_cli_mtu_std_packets_for_jumbo_mtu(self) -> None: + """Assess boundary of jumbo MTU value set pre-runtime. + + Test: + Start TestPMD with MTU size of 9018 bytes, set pre-runtime. + Send a packets of size 8993, 9000 and 9009 bytes. + Verify the first two packets are forwarded and the last is dropped. + Verify: + Verifies the successful forwarding of packets via a search for an inserted payload. + If the payload is found, the packet was transmitted successfully. Otherwise, the packet + is considered dropped. + + Verify the first two packets are forwarded and the last is dropped after pre-runtime + MTU modification. + """ + with TestPmdShell( + self.sut_node, + tx_offloads=0x8000, + mbuf_size=[JUMBO_MTU + 200], + mbcache=200, + max_pkt_len=JUMBO_FRAME, + ) as testpmd: + testpmd.start() + + self.send_packet_and_verify(JUMBO_MTU - VENDOR_AGNOSTIC_PADDING, should_receive=True) + self.send_packet_and_verify(JUMBO_MTU, should_receive=True) + self.send_packet_and_verify(JUMBO_MTU + VENDOR_AGNOSTIC_PADDING, should_receive=False) + + def tear_down_suite(self) -> None: + """Tear down the test suite. + + Teardown: + Set the MTU size of the traffic generator back to the standard 1518 byte size. + """ + self.tg_node.main_session.configure_port_mtu(STANDARD_MTU, self._tg_port_egress) + self.tg_node.main_session.configure_port_mtu(STANDARD_MTU, self._tg_port_ingress) -- 2.47.1