DPDK patches and discussions
 help / color / mirror / Atom feed
From: Patrick Robb <probb@iol.unh.edu>
To: Dean Marx <dmarx@iol.unh.edu>
Cc: luca.vizzarro@arm.com, yoan.picchi@foss.arm.com,
	 Honnappa.Nagarahalli@arm.com, paul.szczepanek@arm.com,
	dev@dpdk.org
Subject: Re: [PATCH v2 1/3] dts: add rte flow test suite
Date: Wed, 25 Jun 2025 13:15:28 -0400	[thread overview]
Message-ID: <CAJvnSUANro_BV+VkrD5s_ArOEcC-0qN3qhWSBwT38ZuMrOMk_g@mail.gmail.com> (raw)
In-Reply-To: <20250521192629.294265-1-dmarx@iol.unh.edu>

[-- Attachment #1: Type: text/plain, Size: 7676 bytes --]

On Wed, May 21, 2025 at 3:26 PM Dean Marx <dmarx@iol.unh.edu> wrote:

> Add an RTE Flow API testing suite, which covers some basic
> synchronous Flow API rules that should be supported across PMDs.
> This suite will be added to over time, as the Flow API is too large
> to cover all in one suite, and sending one monolithic series
> would be impossible.
>
> Signed-off-by: Dean Marx <dmarx@iol.unh.edu>
> ---
>  dts/tests/TestSuite_flow.py | 585 ++++++++++++++++++++++++++++++++++++
>  1 file changed, 585 insertions(+)
>  create mode 100644 dts/tests/TestSuite_flow.py
>
> diff --git a/dts/tests/TestSuite_flow.py b/dts/tests/TestSuite_flow.py
> new file mode 100644
> index 0000000000..15566205c9
> --- /dev/null
> +++ b/dts/tests/TestSuite_flow.py
> @@ -0,0 +1,585 @@
> +# SPDX-License-Identifier: BSD-3-Clause
> +# Copyright(c) 2025 University of New Hampshire
> +
> +"""RTE Flow testing suite.
> +
> +This suite verifies a range of flow rules built using patterns
> +and actions from the RTE Flow API. It would be impossible to cover
> +every valid flow rule, but this suite aims to test the most
> +important and common functionalities across PMDs.
> +
> +"""
> +
> +from collections.abc import Callable
> +from itertools import zip_longest
> +from typing import Any, Iterator, cast
> +
> +from scapy.layers.inet import IP, TCP, UDP
> +from scapy.layers.inet6 import IPv6
> +from scapy.layers.l2 import Dot1Q, Ether
> +from scapy.packet import Packet, Raw
> +
> +from framework.remote_session.testpmd_shell import FlowRule, TestPmdShell
> +from framework.test_suite import TestSuite, func_test
> +from framework.testbed_model.capability import NicCapability,
> TopologyType, requires
> +
> +
> +@requires(topology_type=TopologyType.two_links)
>

I am thinking this testsuite might be valid for 1 link instead of requiring
2 links.


> +@requires(NicCapability.FLOW_CTRL)
> +class TestFlow(TestSuite):
> +    """RTE Flow test suite.
> +
> +    This suite consists of 10 test cases:
> +    1. Queue Action Ethernet: Verifies queue actions with ethernet
> patterns
> +    2. Queue Action IP: Verifies queue actions with IPv4 and IPv6 patterns
> +    3. Queue Action L4: Verifies queue actions with TCP and UDP patterns
> +    4. Queue Action VLAN: Verifies queue actions with VLAN patterns
> +    5. Drop Action Eth: Verifies drop action with ethernet patterns
>

You are using both Ethernet and Eth - choose 1


> +    6. Drop Action IP: Verifies drop actions with IPV4 and IPv6 patterns
> +    7. Drop Action L4: Verifies drop actions with TCP and UDP patterns
> +    8. Drop Action VLAN: Verifies drop actions with VLAN patterns
> +    9. Modify Field Action: Verifies packet modification patterns
> +    10. Egress Rules: Verifies previously covered rules are still valid
> as egress.
> +
> +    """
> +
> +    def runner(
> +        self,
> +        verification_method: Callable[..., Any],
> +        flows: list[FlowRule],
> +        packets: list[Packet],
> +        expected_packets: list[Packet] | None = None,
> +        *args: Any,
> +        **kwargs: Any,
> +    ) -> None:
> +        """Runner method that validates each flow using the corresponding
> verification method.
> +
> +        Args:
> +            verification_method: Callable that performs verification
> logic.
> +            flows: List of flow rules to create and test.
> +            packets: List of packets corresponding to each flow.
> +            expected_packets: List of packets to check sent packets
> against in modification cases.
> +            *args: Additional positional arguments to pass to the
> verification method.
> +            **kwargs: Additional keyword arguments to pass to the
> verification method.
> +        """
> +
> +        def zip_lists(
> +            rules: list[FlowRule],
> +            packets1: list[Packet],
> +            packets2: list[Packet] | None,
> +        ) -> Iterator[tuple[FlowRule, Packet, Packet | None]]:
> +            """Method that creates an iterable zip containing lists used
> in runner.
> +
> +            Args:
> +                rules: List of flow rules.
> +                packets1: List of packets.
> +                packets2: Optional list of packets, excluded from zip if
> not passed to runner.
> +            """
> +            return cast(
> +                Iterator[tuple[FlowRule, Packet, Packet | None]],
> +                zip_longest(rules, packets1, packets2 or [],
> fillvalue=None),
> +            )
> +
> +        with TestPmdShell(rx_queues=4, tx_queues=4) as testpmd:
> +            for flow, packet, expected_packet in zip_lists(flows,
> packets, expected_packets):
> +                flow_id = testpmd.flow_create(flow_rule=flow, port_id=0)
> +
> +                if verification_method == self.send_packet_and_verify:
> +                    verification_method(*args, **kwargs)
> +
> +                elif verification_method ==
> self.send_packet_and_verify_queue:
> +                    verification_method(
> +                        packet=packet, test_queue=kwargs["test_queue"],
> testpmd=testpmd
> +                    )
> +
> +                elif verification_method ==
> self.send_packet_and_verify_modification:
> +                    verification_method(packet=packet,
> expected_packet=expected_packet)
> +
> +                testpmd.flow_delete(flow_id, port_id=0)
> +
>
>

> +    @func_test
> +    def test_egress_rules(self) -> None:
> +        """Validate flow rules with egress directions.
> +
> +        Steps:
> +            Create a list of packets to test, with a corresponding flow
> list.
> +            Launch testpmd with the necessary configuration.
> +            Send each packet in the list, check reception status.
> +
> +        Verify:
> +            Check that each packet is dropped.
> +
> +        One packet will be sent as a confidence check, to ensure packets
> are being
> +        received under normal circumstances.
> +        """
> +        packet_list = [
> +            Ether(src="02:00:00:00:00:00"),
> +            IP(src="192.168.1.1"),
> +            TCP(sport=1234),
> +            UDP(sport=5000),
> +        ]
> +        flow_list = [
> +            FlowRule(
> +                direction="egress", pattern=["eth src is
> 02:00:00:00:00:00"], actions=["drop"]
> +            ),
> +            FlowRule(direction="egress", pattern=["ipv4 src is
> 192.168.1.1"], actions=["drop"]),
> +            FlowRule(direction="egress", pattern=["tcp src is 1234"],
> actions=["drop"]),
> +            FlowRule(direction="egress", pattern=["udp src is 5000"],
> actions=["drop"]),
> +        ]
> +        # Verify packet reception without flow rule
> +        self.send_packet_and_verify(packet=Raw(load="xxxxx"),
> should_receive=True)
> +        self.runner(
> +            verification_method=self.send_packet_and_verify,
> +            flows=flow_list,
> +            packets=packet_list,
> +            should_receive=False,
> +        )
>

It looks like for testing these egress rules you are adding the egress flow
rule on port 0, but we are actually egressing on port 1 (if 2 link topology
is enforced as you decorate this testsuite with). So, if my understanding
is correct, then you need to egress on port 1, or on ctx.topology egress
port (same thing).


> --
> 2.49.0
>
>
Remember to include a testsuite rst like
https://git.dpdk.org/dpdk/commit/?id=d23083df08114975987753a887f1d1deed387ce2


Reviewed-by: Patrick Robb <probb@iol.unh.edu>

[-- Attachment #2: Type: text/html, Size: 9908 bytes --]

      parent reply	other threads:[~2025-06-25 17:20 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-15 16:38 [RFC PATCH 0/1] " Dean Marx
2025-05-15 16:38 ` [RFC PATCH] dts: add " Dean Marx
2025-05-19 18:19   ` [PATCH v1 1/2] " Dean Marx
2025-05-19 18:19     ` [PATCH v1 2/2] dts: add jump and priority tests to flow suite Dean Marx
2025-05-21 19:26     ` [PATCH v2 1/3] dts: add rte flow test suite Dean Marx
2025-05-21 19:26       ` [PATCH v2 2/3] dts: add jump and priority tests to flow suite Dean Marx
2025-06-25 17:25         ` Patrick Robb
2025-05-21 19:26       ` [PATCH v2 3/3] dts: add flow validation Dean Marx
2025-06-25 17:38         ` Patrick Robb
2025-06-25 17:15       ` Patrick Robb [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAJvnSUANro_BV+VkrD5s_ArOEcC-0qN3qhWSBwT38ZuMrOMk_g@mail.gmail.com \
    --to=probb@iol.unh.edu \
    --cc=Honnappa.Nagarahalli@arm.com \
    --cc=dev@dpdk.org \
    --cc=dmarx@iol.unh.edu \
    --cc=luca.vizzarro@arm.com \
    --cc=paul.szczepanek@arm.com \
    --cc=yoan.picchi@foss.arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).