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 D9BC345BB8; Thu, 24 Oct 2024 00:03:47 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9A57740294; Thu, 24 Oct 2024 00:03:47 +0200 (CEST) Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) by mails.dpdk.org (Postfix) with ESMTP id 15D09402C5 for ; Thu, 24 Oct 2024 00:03:47 +0200 (CEST) Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-71e953f4e7cso205611b3a.3 for ; Wed, 23 Oct 2024 15:03:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iol.unh.edu; s=unh-iol; t=1729721026; x=1730325826; darn=dpdk.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=XTeZCc1HtzDbcIDoxm0cZvVwGm/fOSfhyUlnwjUJKts=; b=W4NgdOxN866HHwxWtNeAY/zAv3lRLa8OmkDDpmVDy9qMTUctcERL7cwtQxRvyoJWG8 QwrWhpeQA+bX6JumgwekhjL8JTF+ZZfzClqXZzW338GmE1qx0u6iUDjrCDoh2P5Ms4r1 nF1KO3bc+YOMXdMNbMadR/4OgebD2GyzMyu8w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729721026; x=1730325826; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XTeZCc1HtzDbcIDoxm0cZvVwGm/fOSfhyUlnwjUJKts=; b=HqeKjw/Co/6/VW5Vr2zzu95VQVaQTi+A90ZLbRBZu26smtUyUrva7fHeAiQS6HYxDq SGkcu/PGyIXH3h+D/fPfCz55k1RN9CHFeu97Owt++1yMwiz/GCFEiagvvubb8zZSKm8I qIhoqhpQrzcM9K3K7sNsojnvaMMfLo6/7WJaofGYdXeqbvT1dOBgyNrUwbNag3hjdGwf HCn3mMHryHK/9kI0+Y6ES/bWKD3EqT+dB+XGPw0AmSt/UJLe/HtkB5Gxh0Yp3N5MCMHV 3yyXcGRKv0Ae9KQtBmjgP+jx7PH+DQidXo0r6G5SxJ4uLdL2S+moVCkFDyTHEHL5ZlqE wNtw== X-Forwarded-Encrypted: i=1; AJvYcCW8CS7u0vH4b8tnfMGv0qHv0tjaN8rJMsf0IL3Fbi1PRo/mohDqTVk+SWKWLF9WK1ATYpw=@dpdk.org X-Gm-Message-State: AOJu0YzIcmLBrIArgloDSNBILxZyvqZAD4Ku1jworklddTxPZWZlD2t9 TqJosh28/jmTOj0j5Addi82O2IIoTjhrG7I8B5bHIKsDwx7rqCXIg9PFQjyGeG/glq5jxADOKpz wMrYu/etocGZFH4gwP6pjWbLbRG0cymqEf4VqWw== X-Google-Smtp-Source: AGHT+IFxKmHLZq83fb9HLCPbw6hXFIqYKnySf7TSrvj7X/s+vXesGO/e7XX3n5sso0vI6Tos3zyWKNlY3xYo4tBgUqw= X-Received: by 2002:a05:6a00:acf:b0:71e:4a51:2007 with SMTP id d2e1a72fcca58-72030b7169fmr6259013b3a.4.1729721026010; Wed, 23 Oct 2024 15:03:46 -0700 (PDT) MIME-Version: 1.0 References: <20241008172007.8634-2-dmarx@iol.unh.edu> <20241008191835.20210-1-dmarx@iol.unh.edu> <20241008191835.20210-2-dmarx@iol.unh.edu> In-Reply-To: <20241008191835.20210-2-dmarx@iol.unh.edu> From: Patrick Robb Date: Wed, 23 Oct 2024 18:02:11 -0400 Message-ID: Subject: Re: [PATCH v17 1/1] dts: VLAN test suite implementation To: Dean Marx Cc: npratte@iol.unh.edu, luca.vizzarro@arm.com, yoan.picchi@foss.arm.com, Honnappa.Nagarahalli@arm.com, paul.szczepanek@arm.com, dev@dpdk.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 On Tue, Oct 8, 2024 at 3:18=E2=80=AFPM Dean Marx wrote: > > Test suite for verifying VLAN filtering, stripping, and insertion > functionality on Poll Mode Driver. > > Depends-on: Patch-145500 ("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/c= onfig/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 inse= rtion 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 forwa= rded. > +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, TopologyTy= pe, requires > + > + > +@requires(NicCapability.RX_OFFLOAD_VLAN_FILTER) > +@requires(topology_type=3DTopologyType.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 tes= t cases: > + > + 1. VLAN reception no stripping - verifies that a vlan packet with a = tag > + within the filter list is received. I think that vlan should be capitalized to VLAN in all docstrings > + 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 wi= thin > + 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: b= ool, vlan_id: int) -> None: > + """Generate a vlan packet, send and verify packet with same payl= oad is received on the dut. > + > + Args: > + should_receive: Indicate whether the packet should be succes= sfully 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 =3D Ether() / Dot1Q(vlan=3Dvlan_id) / Raw(load=3D"xxxxx") > + received_packets =3D self.send_packet_and_capture(packet) > + test_packet =3D None > + for packet in received_packets: > + if hasattr(packet, "load") and b"xxxxx" in packet.load: > + test_packet =3D packet > + break > + if should_receive: > + self.verify( > + test_packet is not None, "Packet was dropped when it sho= uld have been received" > + ) > + if test_packet is not None: > + if strip: > + self.verify( > + not test_packet.haslayer(Dot1Q), "Vlan tag was n= ot stripped successfully" > + ) > + else: > + self.verify( > + test_packet.vlan =3D=3D 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 du= t. > + > + Args: > + expected_id: The vlan id that is being inserted through tx_o= ffload configuration. > + """ > + packet =3D Ether() / Raw(load=3D"xxxxx") > + received_packets =3D self.send_packet_and_capture(packet) > + test_packet =3D None > + for packet in received_packets: > + if hasattr(packet, "load") and b"xxxxx" in packet.load: > + test_packet =3D 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 packe= t did not have a vlan tag") > + self.verify( > + test_packet.vlan =3D=3D expected_id, "The received tag d= id not match the expected tag" > + ) > + > + def vlan_setup(self, testpmd: TestPmdShell, port_id: int, filtered_i= d: 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=3Dport_id, enable=3DTrue) > + testpmd.rx_vlan(vlan=3Dfiltered_id, port=3Dport_id, add=3DTrue) > + return testpmd > + > + @func_test > + def test_vlan_receipt_no_stripping(self) -> None: > + """Verify packets are received with their VLAN IDs when strippin= g is disabled. > + > + Test: > + Create an interactive testpmd shell and verify a vlan packet= . > + """ > + with TestPmdShell(node=3Dself.sut_node) as testpmd: > + testpmd =3D self.vlan_setup(testpmd=3Dtestpmd, port_id=3D0, = filtered_id=3D1) We don't need to return the TestPmdShell instance from the vlan_setup method. Instead, that method can return None, and we can skip setting testpmd to that return. So, this line becomes simply: self.vlan_setup(testpmd=3Dtestpmd, port_id=3D0, filtered_id=3D1) > + testpmd.start() > + self.send_vlan_packet_and_verify(True, strip=3DFalse, vlan_i= d=3D1) > + > + @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 hea= der stripping are enabled. > + > + Test: > + Create an interactive testpmd shell and verify a vlan packet= . > + """ > + with TestPmdShell(node=3Dself.sut_node) as testpmd: > + testpmd =3D self.vlan_setup(testpmd=3Dtestpmd, port_id=3D0, = filtered_id=3D1) > + testpmd.set_vlan_strip(port=3D0, enable=3DTrue) > + testpmd.start() > + self.send_vlan_packet_and_verify(should_receive=3DTrue, stri= p=3DTrue, vlan_id=3D1) > + > + @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=3Dself.sut_node) as testpmd: > + testpmd =3D self.vlan_setup(testpmd=3Dtestpmd, port_id=3D0, = filtered_id=3D1) Same as above > + testpmd.start() > + self.send_vlan_packet_and_verify(should_receive=3DFalse, str= ip=3DFalse, vlan_id=3D2) > + > + @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 pa= cket. > + """ > + with TestPmdShell(node=3Dself.sut_node) as testpmd: > + testpmd.set_forward_mode(SimpleForwardingModes.mac) > + testpmd.set_promisc(port=3D0, enable=3DFalse) > + testpmd.stop_all_ports() > + testpmd.tx_vlan_set(port=3D1, enable=3DTrue, vlan=3D51) > + testpmd.start_all_ports() > + testpmd.start() > + self.send_packet_and_verify_insertion(expected_id=3D51) > -- > 2.44.0 > These changes are very minimal so I may just make them locally and push to next-dts as opposed to waiting for your next lab shift. Reviewed-by: Patrick Robb