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 354BA454F4; Tue, 25 Jun 2024 17:34:08 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 255DD40677; Tue, 25 Jun 2024 17:34:08 +0200 (CEST) Received: from mail-qv1-f46.google.com (mail-qv1-f46.google.com [209.85.219.46]) by mails.dpdk.org (Postfix) with ESMTP id 83F0840274 for ; Tue, 25 Jun 2024 17:34:07 +0200 (CEST) Received: by mail-qv1-f46.google.com with SMTP id 6a1803df08f44-6b556d6689dso5271826d6.1 for ; Tue, 25 Jun 2024 08:34:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iol.unh.edu; s=unh-iol; t=1719329647; x=1719934447; 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=ZsgCu1p68vdK0CCd+mJiJR202qEtb3qAILai2D4jGgM=; b=jhqJZjGs/63fnBWTjQWdD9KkLDpNH4u5WDjqwWyqmvRMZcZW2TeW5OKs+/lt0mTu1I yHbs8KXhRqzVocfQjllDIegce4sQ3KFB1g00A51Pwr7R3MtYMuruBespJt2jOqAoUGMg mpXvnGAPLCwNF0wgCjVSrMuIgRPxPQ4z3TCD4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719329647; x=1719934447; 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=ZsgCu1p68vdK0CCd+mJiJR202qEtb3qAILai2D4jGgM=; b=MuQwLwuzlI0JTN7xKCNNNmW8UbAanOG484OJThbOqcQSSEEaa1gOPBqqNOGBpYXV5w 0MuJMvsHICzVSXeLpqJ+kFfVg7ulnSZHiWXZIo8asxi8gbHupqp+rnrDpXomWN5gM7Wl fTe7zXixFyWMP+Y0s2IzRxgMYDkW2C4/n6R3TG0959iOWAgkXYalESmxh/Eli/kYO/Na vt0SoVod00NDh+EbNdrCXQsADUr8V13OQwiKyV7/NZ7JwGrHRdSeKetrZHTwdTpGYzw6 nEM1FZ1/pxlS/mNVQSkYIWexpOMDmEOXXcBE2dtPuh273wUaqJAmEJSPDEkhjNPy7C++ eBnA== X-Gm-Message-State: AOJu0YwQ6OKTS86qoOGdTY3MYG7FDPrdW3QgVzbxDnyICA1VZ1Nd7kau LtsH2W6nPLrFo1+5VXsMjzH5NYnRbzqbc2SwZnxVzFlx45u+RJjHRl1JV5E7OH4= X-Google-Smtp-Source: AGHT+IGDUXAYssa7w0eFcfNgiGHfhCh87uJuEkTXrD/lUj12txssVFM7hJvTDgXYay2NrUFOI6BpAQ== X-Received: by 2002:a0c:dd8e:0:b0:6b0:7e89:f4e1 with SMTP id 6a1803df08f44-6b5409e09c3mr82568286d6.25.1719329646776; Tue, 25 Jun 2024 08:34:06 -0700 (PDT) Received: from dean-laptop.iol.unh.edu ([2606:4100:3880:1210:52ef:3eaf:5f1e:6f6a]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6b534b6fb20sm31570396d6.58.2024.06.25.08.34.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jun 2024 08:34:03 -0700 (PDT) From: Dean Marx To: Honnappa.Nagarahalli@arm.com, juraj.linkes@pantheon.tech, probb@iol.unh.edu, paul.szczepanek@arm.com, yoan.picchi@foss.arm.com, jspewock@iol.unh.edu, bruce.richardson@intel.com, luca.vizzarro@arm.com Cc: dev@dpdk.org, Dean Marx Subject: [PATCH v7 1/3] dts: VLAN test suite implementation Date: Tue, 25 Jun 2024 11:33:22 -0400 Message-ID: <20240625153324.27257-1-dmarx@iol.unh.edu> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240614150238.26374-1-dmarx@iol.unh.edu> References: <20240614150238.26374-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. Signed-off-by: Dean Marx --- dts/tests/TestSuite_vlan.py | 172 ++++++++++++++++++++++++++++++++++++ 1 file changed, 172 insertions(+) create mode 100644 dts/tests/TestSuite_vlan.py diff --git a/dts/tests/TestSuite_vlan.py b/dts/tests/TestSuite_vlan.py new file mode 100644 index 0000000000..e3c9d8dcf4 --- /dev/null +++ b/dts/tests/TestSuite_vlan.py @@ -0,0 +1,172 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2024 University of New Hampshire + +"""Test the support of VLAN Offload Features by Poll Mode Drivers. + +The test suite ensures that with the correct configuration, a port +will not drop a VLAN tagged packet. In order for this to be successful, +packet header stripping and packet receipts must be enabled on the Poll Mode Driver. +The test suite checks that when these conditions are met, the packet is received without issue. +The suite also checks to ensure that when these conditions are not met, as in the cases where +stripping is disabled, or VLAN packet receipts are disabled, the packet is not received. +Additionally, it checks the case where VLAN header insertion is enabled in transmitted packets, +which should be successful if the previous cases pass. + +""" + +from time import sleep +from scapy.layers.l2 import Dot1Q, Ether # type: ignore[import] +from scapy.packet import Raw # type: ignore[import] + +from framework.remote_session.testpmd_shell import TestPmdShell, SimpleForwardingModes +from framework.test_suite import TestSuite + + +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 set_up_suite(self) -> None: + """Set up the test suite. + + Setup: + Verify that at least two ports are open for session. + """ + self.verify(len(self._port_links) > 1, "Not enough ports") + + def send_vlan_packet_and_verify( + self, should_receive: bool, strip: bool, vlan_id: int + ) -> None: + """Generate a vlan packet, send and verify a packet with + the same payload is received on the dut. + + Args: + should_receive: Indicate whether the packet should be successfully received. + vlan_id: Expected vlan ID. + strip: Indicates whether stripping is on or off, and when the vlan tag is + checked for a match. + """ + 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 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 strip: + self.verify(Dot1Q not in test_packet, "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. + should_receive: Indicate whether the packet should be successfully received. + """ + packet = Ether() / Raw(load='xxxxx') + received_packets = self.send_packet_and_capture(packet) + test_packet = None + for packet in received_packets: + if 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" + ) + self.verify(Dot1Q in test_packet, "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 test_vlan_receipt_no_stripping(self) -> None: + """Ensure vlan packet is dropped when receipts are enabled and header stripping is disabled. + + Test: + Create an interactive testpmd shell and verify a vlan packet. + """ + testpmd = TestPmdShell(node=self.sut_node) + testpmd.set_forward_mode(SimpleForwardingModes.mac) + testpmd.set_verbose(1) + testpmd.set_promisc(0, False) + testpmd.vlan_filter_set_on(0) + filtered_vlan = 1 + testpmd.rx_vlan_add(filtered_vlan, 0) + testpmd.start() + + self.send_vlan_packet_and_verify(True, strip=False, vlan_id=filtered_vlan) + testpmd.close() + 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. + """ + testpmd = TestPmdShell(node=self.sut_node) + testpmd.set_forward_mode(SimpleForwardingModes.mac) + testpmd.set_verbose(1) + testpmd.set_promisc(0, False) + testpmd.vlan_filter_set_on(0) + testpmd.rx_vlan_add(1, 0) + testpmd.vlan_strip_set_on(0) + testpmd.start() + + self.send_vlan_packet_and_verify(should_receive=True, strip=True, vlan_id=1) + testpmd.close() + 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. + """ + testpmd = TestPmdShell(node=self.sut_node) + testpmd.set_forward_mode(SimpleForwardingModes.mac) + testpmd.set_verbose(1) + testpmd.set_promisc(0, False) + testpmd.vlan_filter_set_on(0) + filtered_vlan = 1 + testpmd.rx_vlan_add(filtered_vlan, 0) + testpmd.start() + + self.send_vlan_packet_and_verify(should_receive=False, strip=False, vlan_id=filtered_vlan + 1) + testpmd.close() + + 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. + """ + testpmd = TestPmdShell(node=self.sut_node) + testpmd.set_forward_mode(SimpleForwardingModes.mac) + testpmd.set_verbose(1) + testpmd.set_promisc(0, False) + testpmd.port_stop_all() + testpmd.tx_vlan_set(1, 51) + testpmd.port_start_all() + testpmd.start() + + self.send_packet_and_verify_insertion(expected_id=51) + testpmd.close() -- 2.44.0