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 94CE445AE3; Tue, 8 Oct 2024 19:19:49 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E7D4B40A72; Tue, 8 Oct 2024 19:19:46 +0200 (CEST) Received: from mail-qv1-f44.google.com (mail-qv1-f44.google.com [209.85.219.44]) by mails.dpdk.org (Postfix) with ESMTP id 22538406B6 for ; Tue, 8 Oct 2024 19:19:44 +0200 (CEST) Received: by mail-qv1-f44.google.com with SMTP id 6a1803df08f44-6cbbf32bb32so279586d6.1 for ; Tue, 08 Oct 2024 10:19:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iol.unh.edu; s=unh-iol; t=1728407983; x=1729012783; 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=48C4GRYJny0j9iFDxLvq0zMfAXDE23rv7stDzc3/NM4=; b=AMbQozNtAzcd/a9DF2Q1en8LzAU3pr+pvMyi+RnSD6/KcaJvBtVqFSRxnIysFOug0B sQLT5IFFLQzFRtsK9rAMs44UB1Z2NCdS5iLs8pfisaWDEUnj/+RZHLeG5SBsMTtF6A6N 45Mbl/ITRAhvJ9/4O0CjpCvvgF/bmJasg8Qy8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728407983; x=1729012783; 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=48C4GRYJny0j9iFDxLvq0zMfAXDE23rv7stDzc3/NM4=; b=cbK/xIBdrVxNpZs1ma2gF8P2cFSgKhXY8g7OKgFBEI4HqY+8e+56Krb4sCJsEoySpk jJoyg8dKsELSxny9a4RXHb8Wni0bnWaZu3ku07/z/CWXUzQ0ATGh33D1nDayLstA/JrQ o56Vaksz3ZKl30ahIuIyG3OpLiwAn1bxqPgeTrOlWHfJHtGlUs280/1qEhg97/Dkx5KW Y1nzT5+fCu1/R3sPYq+2wXOIxAB50ENxn2Yww17I+cMMzCMAqigm+XUJki7ppHPceZqM KyfLr8Gko+eCYSI+I+75fJNTC6knAnnHWzsWe0s4yRROh9jNanr12XmD+HbyOWf6/e+7 TsFQ== X-Gm-Message-State: AOJu0YzxuV9hApexTZIjNzo0VdZla9nMYcsmagcmg3EH07oNl1NeyXxd 0La0B4YwPJN57pEwZJAhoRCEEUKyU6C9I8NjWLWyrCAB+MmLX7uTE4uE3UjuQq0= X-Google-Smtp-Source: AGHT+IH33ZQMXPNoyERBQIOL4fDbfQYMyzYJWyLWoqFYtdc4AaRZ/byePw3YZ7oEfjftNAyeBFT55Q== X-Received: by 2002:a05:6214:260c:b0:6cb:38c0:24d5 with SMTP id 6a1803df08f44-6cbba99c2a1mr52510006d6.25.1728407983329; Tue, 08 Oct 2024 10:19:43 -0700 (PDT) Received: from dean-laptop.iol.unh.edu ([2606:4100:3880:1210::208]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6cbc7fb0aafsm1250826d6.82.2024.10.08.10.19.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 10:19:42 -0700 (PDT) From: Dean Marx To: probb@iol.unh.edu, npratte@iol.unh.edu, jspewock@iol.unh.edu, luca.vizzarro@arm.com, yoan.picchi@foss.arm.com, Honnappa.Nagarahalli@arm.com, paul.szczepanek@arm.com, juraj.linkes@pantheon.tech Cc: dev@dpdk.org, Dean Marx Subject: [PATCH v16] dts: VLAN test suite implementation Date: Tue, 8 Oct 2024 13:20:07 -0400 Message-ID: <20241008172007.8634-2-dmarx@iol.unh.edu> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20241008172007.8634-1-dmarx@iol.unh.edu> References: <20240918204905.7616-2-dmarx@iol.unh.edu> <20241008172007.8634-1-dmarx@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 Test suite for verifying VLAN filtering, stripping, and insertion functionality on Poll Mode Driver. Depends-on: Patch-145473 ("dts: add VLAN methods to testpmd shell") Signed-off-by: Dean Marx Reviewed-by: Jeremy Spewock --- dts/framework/config/conf_yaml_schema.json | 3 +- dts/tests/TestSuite_vlan.py | 167 +++++++++++++++++++++ 2 files changed, 169 insertions(+), 1 deletion(-) create mode 100644 dts/tests/TestSuite_vlan.py diff --git a/dts/framework/config/conf_yaml_schema.json b/dts/framework/config/conf_yaml_schema.json index df390e8ae2..d437f4db36 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", + "vlan" ] }, "test_target": { diff --git a/dts/tests/TestSuite_vlan.py b/dts/tests/TestSuite_vlan.py new file mode 100644 index 0000000000..19714769f4 --- /dev/null +++ b/dts/tests/TestSuite_vlan.py @@ -0,0 +1,167 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2024 University of New Hampshire + +"""Test the support of VLAN Offload Features by Poll Mode Drivers. + +This test suite verifies that VLAN filtering, stripping, and header insertion all +function as expected. When a VLAN ID is in the filter list, all packets with that +ID should be forwarded and all others should be dropped. While stripping is enabled, +packets sent with a VLAN ID should have the ID removed and then be forwarded. +Additionally, when header insertion is enabled packets without a +VLAN ID should have a specified ID inserted and then be forwarded. + +""" + +from scapy.layers.l2 import Dot1Q, Ether # type: ignore[import-untyped] +from scapy.packet import Raw # type: ignore[import-untyped] + +from framework.remote_session.testpmd_shell import SimpleForwardingModes, TestPmdShell +from framework.test_suite import TestSuite, func_test +from framework.testbed_model.capability import NicCapability, TopologyType, requires + + +@requires(NicCapability.RX_OFFLOAD_VLAN_FILTER) +@requires(topology_type=TopologyType.two_links) +class TestVlan(TestSuite): + """DPDK VLAN test suite. + + Ensures VLAN packet reception, stripping, and insertion on the Poll Mode Driver + when the appropriate conditions are met. The suite contains four test cases: + + 1. VLAN reception no stripping - verifies that a vlan packet with a tag + within the filter list is received. + 2. VLAN reception stripping - verifies that a vlan packet with a tag + within the filter list is received without the vlan tag. + 3. VLAN no reception - verifies that a vlan packet with a tag not within + the filter list is dropped. + 4. VLAN insertion - verifies that a non vlan packet is received with a vlan + tag when insertion is enabled. + """ + + def send_vlan_packet_and_verify(self, should_receive: bool, strip: bool, vlan_id: int) -> None: + """Generate a vlan packet, send and verify packet with same payload is received on the dut. + + Args: + should_receive: Indicate whether the packet should be successfully received. + strip: If :data:`False`, will verify received packets match the given VLAN ID, + otherwise verifies that the received packet has no VLAN ID + (as it has been stripped off.) + vlan_id: Expected vlan ID. + """ + packet = Ether() / Dot1Q(vlan=vlan_id) / Raw(load="xxxxx") + received_packets = self.send_packet_and_capture(packet) + test_packet = None + for packet in received_packets: + if hasattr(packet, "load") and b"xxxxx" in packet.load: + test_packet = packet + break + if should_receive: + self.verify( + test_packet is not None, "Packet was dropped when it should have been received" + ) + if test_packet is not None: + if strip: + self.verify( + not test_packet.haslayer(Dot1Q), "Vlan tag was not stripped successfully" + ) + else: + self.verify( + test_packet.vlan == vlan_id, + "The received tag did not match the expected tag", + ) + else: + self.verify( + test_packet is None, + "Packet was received when it should have been dropped", + ) + + def send_packet_and_verify_insertion(self, expected_id: int) -> None: + """Generate a packet with no vlan tag, send and verify on the dut. + + Args: + expected_id: The vlan id that is being inserted through tx_offload configuration. + """ + packet = Ether() / Raw(load="xxxxx") + received_packets = self.send_packet_and_capture(packet) + test_packet = None + for packet in received_packets: + if hasattr(packet, "load") and b"xxxxx" in packet.load: + test_packet = packet + break + self.verify(test_packet is not None, "Packet was dropped when it should have been received") + if test_packet is not None: + self.verify(test_packet.haslayer(Dot1Q), "The received packet did not have a vlan tag") + self.verify( + test_packet.vlan == expected_id, "The received tag did not match the expected tag" + ) + + def vlan_setup(self, testpmd: TestPmdShell, port_id: int, filtered_id: int) -> TestPmdShell: + """Setup method for all test cases. + + Args: + testpmd: Testpmd shell session to send commands to. + port_id: Number of port to use for setup. + filtered_id: ID to be added to the vlan filter list. + + Returns: + TestPmdShell: Testpmd session being configured. + """ + testpmd.set_forward_mode(SimpleForwardingModes.mac) + testpmd.set_promisc(port_id, False) + testpmd.set_vlan_filter(port=port_id, enable=True) + testpmd.rx_vlan(vlan=filtered_id, port=port_id, add=True) + return testpmd + + @func_test + def test_vlan_receipt_no_stripping(self) -> None: + """Verify packets are received with their VLAN IDs when stripping is disabled. + + Test: + Create an interactive testpmd shell and verify a vlan packet. + """ + with TestPmdShell(node=self.sut_node) as testpmd: + testpmd = self.vlan_setup(testpmd=testpmd, port_id=0, filtered_id=1) + testpmd.start() + self.send_vlan_packet_and_verify(True, strip=False, vlan_id=1) + + @requires(NicCapability.RX_OFFLOAD_VLAN_STRIP) + @func_test + def test_vlan_receipt_stripping(self) -> None: + """Ensure vlan packet received with no tag when receipts and header stripping are enabled. + + Test: + Create an interactive testpmd shell and verify a vlan packet. + """ + with TestPmdShell(node=self.sut_node) as testpmd: + testpmd = self.vlan_setup(testpmd=testpmd, port_id=0, filtered_id=1) + testpmd.set_vlan_strip(port=0, enable=True) + testpmd.start() + self.send_vlan_packet_and_verify(should_receive=True, strip=True, vlan_id=1) + + @func_test + def test_vlan_no_receipt(self) -> None: + """Ensure vlan packet dropped when filter is on and sent tag not in the filter list. + + Test: + Create an interactive testpmd shell and verify a vlan packet. + """ + with TestPmdShell(node=self.sut_node) as testpmd: + testpmd = self.vlan_setup(testpmd=testpmd, port_id=0, filtered_id=1) + testpmd.start() + self.send_vlan_packet_and_verify(should_receive=False, strip=False, vlan_id=2) + + @func_test + def test_vlan_header_insertion(self) -> None: + """Ensure that vlan packet is received with the correct inserted vlan tag. + + Test: + Create an interactive testpmd shell and verify a non-vlan packet. + """ + with TestPmdShell(node=self.sut_node) as testpmd: + testpmd.set_forward_mode(SimpleForwardingModes.mac) + testpmd.set_promisc(port=0, enable=False) + testpmd.stop_all_ports() + testpmd.tx_vlan_set(port=1, enable=True, vlan=51) + testpmd.start_all_ports() + testpmd.start() + self.send_packet_and_verify_insertion(expected_id=51) -- 2.44.0