dts: add l2fwd test suite
PATCH 1/1 dts: add l2fwd test suite
Add a basic L2 forwarding test suite which tests the correct functionality of the forwarding facility built-in in the DPDK.
The tests are performed with different queues numbers per port.
Bugzilla ID: 1481
---
Depends-on: series-32714 ("dts: add pktgen and testpmd changes")
--- dts/framework/config/conf_yaml_schema.json | 3 +- dts/tests/TestSuite_l2fwd.py | 58 ++++++++++++++++++++++ 2 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 dts/tests/TestSuite_l2fwd.py
dts/framework/config/conf_yaml_schema.json +2 -1
@@ -187,7 +187,8 @@ "enum": [ "hello_world", "os_udp", - "pmd_buffer_scatter" + "pmd_buffer_scatter", + "l2fwd" ] }, "test_target": {
dts/tests/TestSuite_l2fwd.py new file +58 -0
58 lines not on this page · raw message
Signature · 1 line
2.34.1
Hey Luca,
Thanks for the patch! Just a few pretty minor comments below.
Quoted 4 lines · Luca Vizzarro
Add a basic L2 forwarding test suite which tests the correct functionality of the forwarding facility built-in in the DPDK.
Quoted 8 lines
The tests are performed with different queues numbers per port.
Bugzilla ID: 1481
Signed-off-by Luca Vizzarro <[email protected]>Reviewed-by Paul Szczepanek <[email protected]>---
Depends-on: series-32714 ("dts: add pktgen and testpmd changes")
Out of my own curiosity, are depends on supposed to be outside of the commit body? I don't think it really matters for automation or anything regardless, but I just didn't know if there was a rule about it.
dts/tests/TestSuite_l2fwd.py
Quoted 26 lines
--- dts/framework/config/conf_yaml_schema.json | 3 +- dts/tests/TestSuite_l2fwd.py | 58 ++++++++++++++++++++++ 2 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 dts/tests/TestSuite_l2fwd.pydts/framework/config/conf_yaml_schema.json +2
-1@@ -187,7 +187,8 @@ "enum": [ "hello_world", "os_udp", - "pmd_buffer_scatter" + "pmd_buffer_scatter", + "l2fwd" ] }, "test_target": {dts/tests/TestSuite_l2fwd.py new file +0
-0@@ -0,0 +1,58 @@
This file looks like it is missing the copyright information at the top.
dts/tests/TestSuite_l2fwd.py line 3
Quoted 3 lines
dts/tests/TestSuite_l2fwd.py new file +3
-0+"""Basic L2 forwarding test suite. + +This testing suites runs basic L2 forwarding on testpmd with different queue sizes per port.
The phrasing of "different queue sizes per port" makes me initially think that like, port 0 will have 2 queues and port 1 will have 4. Maybe something like "This testing suites runs basic L2 forwarding on testpmd across multiple different queue sizes" would make this more clear.
Quoted 14 lines
dts/tests/TestSuite_l2fwd.py new file +14
-0+The forwarding test is performed with several packets being sent at once. +""" + +from framework.params.testpmd import EthPeer, SimpleForwardingModes +from framework.remote_session.testpmd_shell import TestPmdShell +from framework.test_suite import TestSuite +from framework.testbed_model.cpu import LogicalCoreCount +from framework.utils import generate_random_packets + + +class TestL2fwd(TestSuite): + """L2 forwarding test suite.""" + + #: The total number of packets to generate and send for forwarding.
dts/tests/TestSuite_l2fwd.py line 27
Quoted 10 lines
dts/tests/TestSuite_l2fwd.py new file +10
-0+ NUMBER_OF_PACKETS_TO_SEND = 50 + #: The payload size to use for the generated packets in bytes. + PAYLOAD_SIZE = 100 + + def set_up_suite(self) -> None: + """Set up the test suite. + + Setup: + Verify that we have at least 2 ports in the current test. Generate the random packets + that will be sent and spawn a reusable testpmd shell.
Seems like this method is no longer spawning a testpmd shell, so this part of the doc-string is no longer relevant.
dts/tests/TestSuite_l2fwd.py line 36
Quoted 9 lines
dts/tests/TestSuite_l2fwd.py new file +9
-0+ """ + self.verify(len(self.sut_node.ports) >= 2, "At least 2 ports are required for this test.") + self.packets = generate_random_packets(self.NUMBER_OF_PACKETS_TO_SEND, self.PAYLOAD_SIZE) + + def test_l2fwd_integrity(self) -> None: + """Test the L2 forwarding integrity. + + Test: + Configure a testpmd shell with a different numbers of queues per run. Start up L2
It might make sense to name the numbers of queues in the doc-string just so that the rst for the suite is more clear.
Quoted 9 lines
dts/tests/TestSuite_l2fwd.py new file +9
-0+ forwarding, send random packets from the TG and verify they were all received back. + """ + queues = [1, 2, 4, 8] + + with TestPmdShell( + self.sut_node, + lcore_filter_specifier=LogicalCoreCount(cores_per_socket=4), + forward_mode=SimpleForwardingModes.mac, + eth_peer=[EthPeer(1, self.tg_node.ports[1].mac_address)],
dts/tests/TestSuite_l2fwd.py line 55
Quoted 10 lines
dts/tests/TestSuite_l2fwd.py new file +10
-0+ disable_device_start=True, + ) as shell: + for queues_num in queues: + self._logger.info(f"Testing L2 forwarding with {queues_num} queue(s)") + shell.set_ports_queues(queues_num) + shell.start() + + received_packets = self.send_packets_and_capture(self.packets) + + expected_packets = [self.get_expected_packet(packet) for packet in self.packets]
Ahh, the get_expected_packet method also sheds some light on how the match_all_packets could be useful.
Quoted 6 lines
dts/tests/TestSuite_l2fwd.py new file +3
-1+ self.match_all_packets(expected_packets, received_packets) + + shell.stop() --2.34.1
Quoted 9 lines · Jeremy Spewock
Quoted 4 lines
Signed-off-by Luca Vizzarro <[email protected]>Reviewed-by Paul Szczepanek <[email protected]>---
Depends-on: series-32714 ("dts: add pktgen and testpmd changes")Out of my own curiosity, are depends on supposed to be outside of the commit body? I don't think it really matters for automation or anything regardless, but I just didn't know if there was a rule about it.
Depends-on tags are metadata for Patchwork, they don't belong in the repository. So there shouldn't be any depends-on committed as it wouldn't make any sense in Git. My reply aside, the contributing guidelines also specify how to do it[1].
Quoted 7 lines
dts/tests/TestSuite_l2fwd.py
Quoted 5 lines
new file mode 100644
index 0000000000..46f07b78ebdts/tests/TestSuite_l2fwd.py new file +0
-0@@ -0,0 +1,58 @@This file looks like it is missing the copyright information at the top.
Argh! Good catch, thank you!
Quoted 10 lines
dts/tests/TestSuite_l2fwd.py line 3
Quoted 3 lines
dts/tests/TestSuite_l2fwd.py new file +3
-0+"""Basic L2 forwarding test suite. + +This testing suites runs basic L2 forwarding on testpmd with different queue sizes per port.The phrasing of "different queue sizes per port" makes me initially think that like, port 0 will have 2 queues and port 1 will have 4. Maybe something like "This testing suites runs basic L2 forwarding on testpmd across multiple different queue sizes" would make this more clear.
Ack.
Quoted 9 lines
dts/tests/TestSuite_l2fwd.py line 27
Quoted 6 lines
dts/tests/TestSuite_l2fwd.py new file +6
-0+ def set_up_suite(self) -> None: + """Set up the test suite. + + Setup: + Verify that we have at least 2 ports in the current test. Generate the random packets + that will be sent and spawn a reusable testpmd shell.Seems like this method is no longer spawning a testpmd shell, so this part of the doc-string is no longer relevant.
Ack. Remnants of an earlier version... :')
Quoted 8 lines
dts/tests/TestSuite_l2fwd.py line 36
Quoted 5 lines
dts/tests/TestSuite_l2fwd.py new file +5
-0+ def test_l2fwd_integrity(self) -> None: + """Test the L2 forwarding integrity. + + Test: + Configure a testpmd shell with a different numbers of queues per run. Start up L2It might make sense to name the numbers of queues in the doc-string just so that the rst for the suite is more clear.
Ack.
Quoted 5 lines
dts/tests/TestSuite_l2fwd.py line 55
Quoted 1 line
dts/tests/TestSuite_l2fwd.py new file +1
-0+ expected_packets = [self.get_expected_packet(packet) for packet in self.packets]Ahh, the
get_expected_packetmethod also sheds some light on how thematch_all_packetscould be useful.
:)
[1] https://doc.dpdk.org/guides/contributing/patches.html#patch-dependencies
Quoted 12 lines · Luca Vizzarro
Add a basic L2 forwarding test suite which tests the correct functionality of the forwarding facility built-in in the DPDK.
The tests are performed with different queues numbers per port.
Bugzilla ID: 1481
Signed-off-by Luca Vizzarro <[email protected]>Reviewed-by Paul Szczepanek <[email protected]>---
Depends-on: series-32714 ("dts: add pktgen and testpmd changes")
Jeremy already mentioned this but the suite is missing the copyright and license header, otherwise:
Ran on a Broadcom 57414 2x25G NIC on an Intel x86 server.
I'll follow up with a review on the pktgen and testpmd changes series as obviously we want to move that to next-dts. Thanks!
dts/tests/TestSuite_l2fwd.py line 39
Quoted 8 lines · Luca Vizzarro
dts/tests/TestSuite_l2fwd.py new file +8
-0+ def test_l2fwd_integrity(self) -> None: + """Test the L2 forwarding integrity. + + Test: + Configure a testpmd shell with a different numbers of queues per run. Start up L2 + forwarding, send random packets from the TG and verify they were all received back. + """ + queues = [1, 2, 4, 8]
The only question I had was whether we need a show port info capability check to verify the max queues per port is at least 8, but I think that 8 is so low that we will not realistically run into this problem, after a quick 60 second check on a couple NICs.
Just a few clarifying questions below. Otherwise,
(Test cases was run on Connect_x5 and Broadcom P225p devices).
<snip>
dts/tests/TestSuite_l2fwd.py line 46
Quoted 7 lines
dts/tests/TestSuite_l2fwd.py new file +7
-0+ + with TestPmdShell( + self.sut_node, + lcore_filter_specifier=LogicalCoreCount(cores_per_socket=4), + forward_mode=SimpleForwardingModes.mac, + eth_peer=[EthPeer(1, self.tg_node.ports[1].mac_address)], + disable_device_start=True,
Would you be able to elaborate on the explicit lcore definition and the eth_peer defined in the testpmd parameters above? I tried doing some digging to understand the existence of these parameters, but couldn't find anything insightful. Were these parameters basically just copied over from old DTS?
PATCH v2 1/1 dts: add l2fwd test suite
In reply to Luca VizzarroAdd a basic L2 forwarding test suite which tests the correct functionality of the forwarding facility built-in in the DPDK.
The tests are performed with different queues numbers per port.
Bugzilla ID: 1481
--- dts/tests/TestSuite_l2fwd.py | 62 ++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 dts/tests/TestSuite_l2fwd.py
dts/tests/TestSuite_l2fwd.py new file +62 -0
@@ -0,0 +1,62 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2024 Arm Limited + +"""Basic L2 forwarding test suite. + +This testing suites runs basic L2 forwarding on testpmd with different queue sizes per port. +The forwarding test is performed with several packets being sent at once. +""" + +from framework.params.testpmd import EthPeer, SimpleForwardingModes +from framework.remote_session.testpmd_shell import TestPmdShell +from framework.test_suite import TestSuite, func_test +from framework.testbed_model.cpu import LogicalCoreCount +from framework.utils import generate_random_packets + + +class TestL2fwd(TestSuite): + """L2 forwarding test suite.""" + + #: The total number of packets to generate and send for forwarding. + NUMBER_OF_PACKETS_TO_SEND = 50 + #: The payload size to use for the generated packets in bytes. + PAYLOAD_SIZE = 100 + + def set_up_suite(self) -> None: + """Set up the test suite. + + Setup: + Verify that we have at least 2 ports in the current test. Generate the random packets + that will be sent and spawn a reusable testpmd shell. + """ + self.verify(len(self.sut_node.ports) >= 2, "At least 2 ports are required for this test.") + self.packets = generate_random_packets(self.NUMBER_OF_PACKETS_TO_SEND, self.PAYLOAD_SIZE) + + @func_test + def test_l2fwd_integrity(self) -> None: + """Test the L2 forwarding integrity. + + Test: + Configure a testpmd shell with a different numbers of queues per run. Start up L2 + forwarding, send random packets from the TG and verify they were all received back. + """ + queues = [1, 2, 4, 8] + + with TestPmdShell( + self.sut_node, + lcore_filter_specifier=LogicalCoreCount(cores_per_socket=4), + forward_mode=SimpleForwardingModes.mac, + eth_peer=[EthPeer(1, self.tg_node.ports[1].mac_address)], + disable_device_start=True, + ) as shell: + for queues_num in queues: + self._logger.info(f"Testing L2 forwarding with {queues_num} queue(s)") + shell.set_ports_queues(queues_num) + shell.start() + + received_packets = self.send_packets_and_capture(self.packets) + + expected_packets = [self.get_expected_packet(packet) for packet in self.packets] + self.match_all_packets(expected_packets, received_packets) + + shell.stop()
Signature · 1 line
2.43.0
v3 cover dts: add l2fwd test suite
In reply to Luca VizzarroHi there,
sending in a v3 for l2fwd.
v3:
- addressed comments for docstrings
- make use of @requires
- add a get_expected_packet version for multiple packets
- fix an inconsistency bug with _adjust_addresses
- rebased
v2:
- added copyright
- rebased
Best,
Luca
Depends-on: series-33871 ("dts: Pydantic configuration")
Luca Vizzarro (3):
dts: fix adjust L2/L3 addresses behavior
dts: allow to get multiple expected packets
dts: add l2fwd test suite
dts/framework/test_suite.py | 24 +++++++++++--- dts/tests/TestSuite_l2fwd.py | 63 ++++++++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+), 4 deletions(-) create mode 100644 dts/tests/TestSuite_l2fwd.py
Signature · 1 line
2.43.0
PATCH v3 1/3 dts: fix adjust L2/L3 addresses behavior
The _adjust_addresses function has been updated to both modify the original packets and return new updated copies of them. Having a double behavior even if documented is not intuitive and can lead to bugs.
This changes the behavior to solely act on copies, leaving the original packet untouched.
--- dts/framework/test_suite.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
dts/framework/test_suite.py +4 -3
@@ -324,8 +324,7 @@ def get_expected_packet(self, packet: Packet) -> Packet: def _adjust_addresses(self, packets: list[Packet], expected: bool = False) -> list[Packet]: """L2 and L3 address additions in both directions. - Packets in `packets` will be directly modified in this method. The returned list of packets - however will be copies of the modified packets. + Copies of `packets` will be made, modified and returned in this method. Only missing addresses are added to packets, existing addresses will not be overridden. If any packet in `packets` has multiple IP layers (using GRE, for example) only the inner-most
@@ -343,7 +342,9 @@ def _adjust_addresses(self, packets: list[Packet], expected: bool = False) -> li A list containing copies of all packets in `packets` after modification. """ ret_packets = [] - for packet in packets: + for original_packet in packets: + packet = original_packet.copy() + # update l2 addresses # If `expected` is :data:`True`, the packet enters the TG from SUT, otherwise the # packet leaves the TG towards the SUT.
Signature · 1 line
2.43.0
Re: [PATCH v3 1/3] dts: fix adjust L2/L3 addresses behavior
Re: [PATCH v3 1/3] dts: fix adjust L2/L3 addresses behavior
In reply to Luca VizzarroPATCH v3 2/3 dts: allow to get multiple expected packets
In reply to Luca VizzarroAt the moment there is only one facility that allows to prepare a packet as it is expected to be received on the traffic generator end. Extend this to allow to prepare multiple packets at the same time.
--- dts/framework/test_suite.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)
dts/framework/test_suite.py +16 -1
@@ -310,16 +310,31 @@ def send_packets( packets = self._adjust_addresses(packets) self.tg_node.send_packets(packets, self._tg_port_egress) + def get_expected_packets(self, packets: list[Packet]) -> list[Packet]: + """Inject the proper L2/L3 addresses into `packets`. + + Inject the L2/L3 addresses expected at the receiving end of the traffic generator. + + Args: + packets: The packets to modify. + + Returns: + `packets` with injected L2/L3 addresses. + """ + return self._adjust_addresses(packets, expected=True) + def get_expected_packet(self, packet: Packet) -> Packet: """Inject the proper L2/L3 addresses into `packet`. + Inject the L2/L3 addresses expected at the receiving end of the traffic generator. + Args: packet: The packet to modify. Returns: `packet` with injected L2/L3 addresses. """ - return self._adjust_addresses([packet], expected=True)[0] + return self.get_expected_packet([packet])[0] def _adjust_addresses(self, packets: list[Packet], expected: bool = False) -> list[Packet]: """L2 and L3 address additions in both directions.
Signature · 1 line
2.43.0
Re: [PATCH v3 2/3] dts: allow to get multiple expected packets
Re: [PATCH v3 2/3] dts: allow to get multiple expected packets
In reply to Luca VizzarroPATCH v3 3/3 dts: add l2fwd test suite
In reply to Luca VizzarroAdd a basic L2 forwarding test suite which tests the correct functionality of the forwarding facility built-in in the DPDK.
The tests are performed with different queues numbers per port.
--- dts/tests/TestSuite_l2fwd.py | 63 ++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 dts/tests/TestSuite_l2fwd.py
dts/tests/TestSuite_l2fwd.py new file +63 -0
@@ -0,0 +1,63 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2024 Arm Limited + +"""Basic L2 forwarding test suite. + +This testing suites runs basic L2 forwarding on testpmd across multiple different queue sizes. +The forwarding test is performed with several packets being sent at once. +""" + +from framework.params.testpmd import EthPeer, SimpleForwardingModes +from framework.remote_session.testpmd_shell import TestPmdShell +from framework.test_suite import TestSuite, func_test +from framework.testbed_model.capability import requires +from framework.testbed_model.cpu import LogicalCoreCount +from framework.testbed_model.topology import TopologyType +from framework.utils import generate_random_packets + + +@requires(topology_type=TopologyType.two_links) +class TestL2fwd(TestSuite): + """L2 forwarding test suite.""" + + #: The total number of packets to generate and send for forwarding. + NUMBER_OF_PACKETS_TO_SEND = 50 + #: The payload size to use for the generated packets in bytes. + PAYLOAD_SIZE = 100 + + def set_up_suite(self) -> None: + """Set up the test suite. + + Setup: + Generate the random packets that will be sent. + """ + self.packets = generate_random_packets(self.NUMBER_OF_PACKETS_TO_SEND, self.PAYLOAD_SIZE) + + @func_test + def l2fwd_integrity(self) -> None: + """Test the L2 forwarding integrity. + + Test: + Configure a testpmd shell with a different numbers of queues (1, 2, 4 and 8) per run. + Start up L2 forwarding, send random packets from the TG and verify they were all + received back. + """ + queues = [1, 2, 4, 8] + + with TestPmdShell( + self.sut_node, + lcore_filter_specifier=LogicalCoreCount(cores_per_socket=4), + forward_mode=SimpleForwardingModes.mac, + eth_peer=[EthPeer(1, self.tg_node.ports[1].mac_address)], + disable_device_start=True, + ) as shell: + for queues_num in queues: + self._logger.info(f"Testing L2 forwarding with {queues_num} queue(s)") + shell.set_ports_queues(queues_num) + shell.start() + + received_packets = self.send_packets_and_capture(self.packets) + expected_packets = self.get_expected_packets(self.packets) + self.match_all_packets(expected_packets, received_packets) + + shell.stop()
Signature · 1 line
2.43.0
Quoted 95 lines · Luca Vizzarro
Add a basic L2 forwarding test suite which tests the correct functionality of the forwarding facility built-in in the DPDK.
The tests are performed with different queues numbers per port.
Signed-off-by Luca Vizzarro <[email protected]>Signed-off-by Thomas Wilks <[email protected]>Reviewed-by Paul Szczepanek <[email protected]>Reviewed-by Dean Marx <[email protected]>Reviewed-by Patrick Robb <[email protected]>Tested-by Patrick Robb <[email protected]>--- dts/tests/TestSuite_l2fwd.py | 63 ++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 dts/tests/TestSuite_l2fwd.pydts/tests/TestSuite_l2fwd.py new file +6
-0@@ -0,0 +1,63 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2024 Arm Limited + +"""Basic L2 forwarding test suite. + +This testing suites runs basic L2 forwarding on testpmd across multipledifferent queue sizes.
dts/tests/TestSuite_l2fwd.py new file +28
-0+The forwarding test is performed with several packets being sent at once. +""" + +from framework.params.testpmd import EthPeer, SimpleForwardingModes +from framework.remote_session.testpmd_shell import TestPmdShell +from framework.test_suite import TestSuite, func_test +from framework.testbed_model.capability import requires +from framework.testbed_model.cpu import LogicalCoreCount +from framework.testbed_model.topology import TopologyType +from framework.utils import generate_random_packets + + +@requires(topology_type=TopologyType.two_links) +class TestL2fwd(TestSuite): + """L2 forwarding test suite.""" + + #: The total number of packets to generate and send for forwarding. + NUMBER_OF_PACKETS_TO_SEND = 50 + #: The payload size to use for the generated packets in bytes. + PAYLOAD_SIZE = 100 + + def set_up_suite(self) -> None: + """Set up the test suite. + + Setup: + Generate the random packets that will be sent. + """ + self.packets =
generate_random_packets(self.NUMBER_OF_PACKETS_TO_SEND, self.PAYLOAD_SIZE)dts/tests/TestSuite_l2fwd.py new file +7
-0+ + @func_test + def l2fwd_integrity(self) -> None: + """Test the L2 forwarding integrity. + + Test: + Configure a testpmd shell with a different numbers of queues(1, 2, 4 and 8) per run.
+ Start up L2 forwarding, send random packets from the TG and
verify they were alldts/tests/TestSuite_l2fwd.py new file +13
-0+ received back. + """ + queues = [1, 2, 4, 8] + + with TestPmdShell( + self.sut_node, + lcore_filter_specifier=LogicalCoreCount(cores_per_socket=4), + forward_mode=SimpleForwardingModes.mac, + eth_peer=[EthPeer(1, self.tg_node.ports[1].mac_address)], + disable_device_start=True, + ) as shell: + for queues_num in queues: + self._logger.info(f"Testing L2 forwarding with{
queues_num} queue(s)")dts/tests/TestSuite_l2fwd.py new file +4
-0+ shell.set_ports_queues(queues_num) + shell.start() + + received_packets =
self.send_packets_and_capture(self.packets)dts/tests/TestSuite_l2fwd.py new file +4
-1+ expected_packets = self.get_expected_packets(self.packets) + self.match_all_packets(expected_packets, received_packets) + + shell.stop() --2.43.0
v4 cover dts: add l2fwd test suite
In reply to Luca VizzarroHi there,
sending in a v4 for l2fwd.
v4:
- fixed bug introduced in get_expected_packet v3:
- addressed comments for docstrings
- make use of @requires
- add a get_expected_packet version for multiple packets
- fix an inconsistency bug with _adjust_addresses
- rebased
v2:
- added copyright
- rebased
Best,
Luca
Luca Vizzarro (3):
dts: fix adjust L2/L3 addresses behavior
dts: allow to get multiple expected packets
dts: add l2fwd test suite
dts/framework/test_suite.py | 24 +++++++++++--- dts/tests/TestSuite_l2fwd.py | 63 ++++++++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+), 4 deletions(-) create mode 100644 dts/tests/TestSuite_l2fwd.py
Signature · 1 line
2.43.0
PATCH v4 1/3 dts: allow to get multiple expected packets
At the moment there is only one facility that allows to prepare a packet as it is expected to be received on the traffic generator end. Extend this to allow to prepare multiple packets at the same time.
--- dts/framework/test_suite.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)
dts/framework/test_suite.py +16 -1
@@ -310,16 +310,31 @@ def send_packets( packets = self._adjust_addresses(packets) self.tg_node.send_packets(packets, self._tg_port_egress) + def get_expected_packets(self, packets: list[Packet]) -> list[Packet]: + """Inject the proper L2/L3 addresses into `packets`. + + Inject the L2/L3 addresses expected at the receiving end of the traffic generator. + + Args: + packets: The packets to modify. + + Returns: + `packets` with injected L2/L3 addresses. + """ + return self._adjust_addresses(packets, expected=True) + def get_expected_packet(self, packet: Packet) -> Packet: """Inject the proper L2/L3 addresses into `packet`. + Inject the L2/L3 addresses expected at the receiving end of the traffic generator. + Args: packet: The packet to modify. Returns: `packet` with injected L2/L3 addresses. """ - return self._adjust_addresses([packet], expected=True)[0] + return self.get_expected_packet([packet])[0] def _adjust_addresses(self, packets: list[Packet], expected: bool = False) -> list[Packet]: """L2 and L3 address additions in both directions.
Signature · 1 line
2.43.0
PATCH v4 1/3 dts: fix adjust L2/L3 addresses behavior
In reply to Luca VizzarroThe _adjust_addresses function has been updated to both modify the original packets and return new updated copies of them. Having a double behavior even if documented is not intuitive and can lead to bugs.
This changes the behavior to solely act on copies, leaving the original packet untouched.
--- dts/framework/test_suite.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
dts/framework/test_suite.py +4 -3
@@ -324,8 +324,7 @@ def get_expected_packet(self, packet: Packet) -> Packet: def _adjust_addresses(self, packets: list[Packet], expected: bool = False) -> list[Packet]: """L2 and L3 address additions in both directions. - Packets in `packets` will be directly modified in this method. The returned list of packets - however will be copies of the modified packets. + Copies of `packets` will be made, modified and returned in this method. Only missing addresses are added to packets, existing addresses will not be overridden. If any packet in `packets` has multiple IP layers (using GRE, for example) only the inner-most
@@ -343,7 +342,9 @@ def _adjust_addresses(self, packets: list[Packet], expected: bool = False) -> li A list containing copies of all packets in `packets` after modification. """ ret_packets = [] - for packet in packets: + for original_packet in packets: + packet = original_packet.copy() + # update l2 addresses # If `expected` is :data:`True`, the packet enters the TG from SUT, otherwise the # packet leaves the TG towards the SUT.
Signature · 1 line
2.43.0
PATCH v4 2/3 dts: add l2fwd test suite
In reply to Luca VizzarroAdd a basic L2 forwarding test suite which tests the correct functionality of the forwarding facility built-in in the DPDK.
The tests are performed with different queues numbers per port.
--- dts/tests/TestSuite_l2fwd.py | 63 ++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 dts/tests/TestSuite_l2fwd.py
dts/tests/TestSuite_l2fwd.py new file +63 -0
@@ -0,0 +1,63 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2024 Arm Limited + +"""Basic L2 forwarding test suite. + +This testing suites runs basic L2 forwarding on testpmd across multiple different queue sizes. +The forwarding test is performed with several packets being sent at once. +""" + +from framework.params.testpmd import EthPeer, SimpleForwardingModes +from framework.remote_session.testpmd_shell import TestPmdShell +from framework.test_suite import TestSuite, func_test +from framework.testbed_model.capability import requires +from framework.testbed_model.cpu import LogicalCoreCount +from framework.testbed_model.topology import TopologyType +from framework.utils import generate_random_packets + + +@requires(topology_type=TopologyType.two_links) +class TestL2fwd(TestSuite): + """L2 forwarding test suite.""" + + #: The total number of packets to generate and send for forwarding. + NUMBER_OF_PACKETS_TO_SEND = 50 + #: The payload size to use for the generated packets in bytes. + PAYLOAD_SIZE = 100 + + def set_up_suite(self) -> None: + """Set up the test suite. + + Setup: + Generate the random packets that will be sent. + """ + self.packets = generate_random_packets(self.NUMBER_OF_PACKETS_TO_SEND, self.PAYLOAD_SIZE) + + @func_test + def l2fwd_integrity(self) -> None: + """Test the L2 forwarding integrity. + + Test: + Configure a testpmd shell with a different numbers of queues (1, 2, 4 and 8) per run. + Start up L2 forwarding, send random packets from the TG and verify they were all + received back. + """ + queues = [1, 2, 4, 8] + + with TestPmdShell( + self.sut_node, + lcore_filter_specifier=LogicalCoreCount(cores_per_socket=4), + forward_mode=SimpleForwardingModes.mac, + eth_peer=[EthPeer(1, self.tg_node.ports[1].mac_address)], + disable_device_start=True, + ) as shell: + for queues_num in queues: + self._logger.info(f"Testing L2 forwarding with {queues_num} queue(s)") + shell.set_ports_queues(queues_num) + shell.start() + + received_packets = self.send_packets_and_capture(self.packets) + expected_packets = self.get_expected_packets(self.packets) + self.match_all_packets(expected_packets, received_packets) + + shell.stop()
Signature · 1 line
2.43.0
PATCH v4 2/3 dts: allow to get multiple expected packets
In reply to Luca VizzarroAt the moment there is only one facility that allows to prepare a packet as it is expected to be received on the traffic generator end. Extend this to allow to prepare multiple packets at the same time.
--- dts/framework/test_suite.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)
dts/framework/test_suite.py +16 -1
@@ -310,16 +310,31 @@ def send_packets( packets = self._adjust_addresses(packets) self.tg_node.send_packets(packets, self._tg_port_egress) + def get_expected_packets(self, packets: list[Packet]) -> list[Packet]: + """Inject the proper L2/L3 addresses into `packets`. + + Inject the L2/L3 addresses expected at the receiving end of the traffic generator. + + Args: + packets: The packets to modify. + + Returns: + `packets` with injected L2/L3 addresses. + """ + return self._adjust_addresses(packets, expected=True) + def get_expected_packet(self, packet: Packet) -> Packet: """Inject the proper L2/L3 addresses into `packet`. + Inject the L2/L3 addresses expected at the receiving end of the traffic generator. + Args: packet: The packet to modify. Returns: `packet` with injected L2/L3 addresses. """ - return self._adjust_addresses([packet], expected=True)[0] + return self.get_expected_packets([packet])[0] def _adjust_addresses(self, packets: list[Packet], expected: bool = False) -> list[Packet]: """L2 and L3 address additions in both directions.
Signature · 1 line
2.43.0
PATCH v4 3/3 dts: add l2fwd test suite
In reply to Luca VizzarroAdd a basic L2 forwarding test suite which tests the correct functionality of the forwarding facility built-in in the DPDK.
The tests are performed with different queues numbers per port.
--- dts/tests/TestSuite_l2fwd.py | 63 ++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 dts/tests/TestSuite_l2fwd.py
dts/tests/TestSuite_l2fwd.py new file +63 -0
@@ -0,0 +1,63 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2024 Arm Limited + +"""Basic L2 forwarding test suite. + +This testing suites runs basic L2 forwarding on testpmd across multiple different queue sizes. +The forwarding test is performed with several packets being sent at once. +""" + +from framework.params.testpmd import EthPeer, SimpleForwardingModes +from framework.remote_session.testpmd_shell import TestPmdShell +from framework.test_suite import TestSuite, func_test +from framework.testbed_model.capability import requires +from framework.testbed_model.cpu import LogicalCoreCount +from framework.testbed_model.topology import TopologyType +from framework.utils import generate_random_packets + + +@requires(topology_type=TopologyType.two_links) +class TestL2fwd(TestSuite): + """L2 forwarding test suite.""" + + #: The total number of packets to generate and send for forwarding. + NUMBER_OF_PACKETS_TO_SEND = 50 + #: The payload size to use for the generated packets in bytes. + PAYLOAD_SIZE = 100 + + def set_up_suite(self) -> None: + """Set up the test suite. + + Setup: + Generate the random packets that will be sent. + """ + self.packets = generate_random_packets(self.NUMBER_OF_PACKETS_TO_SEND, self.PAYLOAD_SIZE) + + @func_test + def l2fwd_integrity(self) -> None: + """Test the L2 forwarding integrity. + + Test: + Configure a testpmd shell with a different numbers of queues (1, 2, 4 and 8) per run. + Start up L2 forwarding, send random packets from the TG and verify they were all + received back. + """ + queues = [1, 2, 4, 8] + + with TestPmdShell( + self.sut_node, + lcore_filter_specifier=LogicalCoreCount(cores_per_socket=4), + forward_mode=SimpleForwardingModes.mac, + eth_peer=[EthPeer(1, self.tg_node.ports[1].mac_address)], + disable_device_start=True, + ) as shell: + for queues_num in queues: + self._logger.info(f"Testing L2 forwarding with {queues_num} queue(s)") + shell.set_ports_queues(queues_num) + shell.start() + + received_packets = self.send_packets_and_capture(self.packets) + expected_packets = self.get_expected_packets(self.packets) + self.match_all_packets(expected_packets, received_packets) + + shell.stop()
Signature · 1 line
2.43.0
PATCH v4 3/3 fixup! dts: allow to get multiple expected packets
In reply to Luca Vizzarro--- dts/framework/test_suite.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
dts/framework/test_suite.py +1 -1
@@ -334,7 +334,7 @@ def get_expected_packet(self, packet: Packet) -> Packet: Returns: `packet` with injected L2/L3 addresses. """ - return self.get_expected_packet([packet])[0] + return self.get_expected_packets([packet])[0] def _adjust_addresses(self, packets: list[Packet], expected: bool = False) -> list[Packet]: """L2 and L3 address additions in both directions.
Signature · 1 line
2.43.0
v5 cover dts: add l2fwd test suite
In reply to Luca VizzarroHi there,
sending in a v5 for l2fwd.
v5:
- re-sent after error in sending v4
v4:
- fixed bug introduced in get_expected_packet v3:
- addressed comments for docstrings
- make use of @requires
- add a get_expected_packet version for multiple packets
- fix an inconsistency bug with _adjust_addresses
- rebased
v2:
- added copyright
- rebased
Best,
Luca
Luca Vizzarro (3):
dts: fix adjust L2/L3 addresses behavior
dts: allow to get multiple expected packets
dts: add l2fwd test suite
dts/framework/test_suite.py | 24 +++++++++++--- dts/tests/TestSuite_l2fwd.py | 63 ++++++++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+), 4 deletions(-) create mode 100644 dts/tests/TestSuite_l2fwd.py
Signature · 1 line
2.43.0
PATCH v5 1/3 dts: fix adjust L2/L3 addresses behavior
The _adjust_addresses function has been updated to both modify the original packets and return new updated copies of them. Having a double behavior even if documented is not intuitive and can lead to bugs.
This changes the behavior to solely act on copies, leaving the original packet untouched.
--- dts/framework/test_suite.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
dts/framework/test_suite.py +4 -3
@@ -324,8 +324,7 @@ def get_expected_packet(self, packet: Packet) -> Packet: def _adjust_addresses(self, packets: list[Packet], expected: bool = False) -> list[Packet]: """L2 and L3 address additions in both directions. - Packets in `packets` will be directly modified in this method. The returned list of packets - however will be copies of the modified packets. + Copies of `packets` will be made, modified and returned in this method. Only missing addresses are added to packets, existing addresses will not be overridden. If any packet in `packets` has multiple IP layers (using GRE, for example) only the inner-most
@@ -343,7 +342,9 @@ def _adjust_addresses(self, packets: list[Packet], expected: bool = False) -> li A list containing copies of all packets in `packets` after modification. """ ret_packets = [] - for packet in packets: + for original_packet in packets: + packet = original_packet.copy() + # update l2 addresses # If `expected` is :data:`True`, the packet enters the TG from SUT, otherwise the # packet leaves the TG towards the SUT.
Signature · 1 line
2.43.0
PATCH v5 2/3 dts: allow to get multiple expected packets
In reply to Luca VizzarroAt the moment there is only one facility that allows to prepare a packet as it is expected to be received on the traffic generator end. Extend this to allow to prepare multiple packets at the same time.
--- dts/framework/test_suite.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)
dts/framework/test_suite.py +16 -1
@@ -310,16 +310,31 @@ def send_packets( packets = self._adjust_addresses(packets) self.tg_node.send_packets(packets, self._tg_port_egress) + def get_expected_packets(self, packets: list[Packet]) -> list[Packet]: + """Inject the proper L2/L3 addresses into `packets`. + + Inject the L2/L3 addresses expected at the receiving end of the traffic generator. + + Args: + packets: The packets to modify. + + Returns: + `packets` with injected L2/L3 addresses. + """ + return self._adjust_addresses(packets, expected=True) + def get_expected_packet(self, packet: Packet) -> Packet: """Inject the proper L2/L3 addresses into `packet`. + Inject the L2/L3 addresses expected at the receiving end of the traffic generator. + Args: packet: The packet to modify. Returns: `packet` with injected L2/L3 addresses. """ - return self._adjust_addresses([packet], expected=True)[0] + return self.get_expected_packets([packet])[0] def _adjust_addresses(self, packets: list[Packet], expected: bool = False) -> list[Packet]: """L2 and L3 address additions in both directions.
Signature · 1 line
2.43.0
PATCH v5 3/3 dts: add l2fwd test suite
In reply to Luca VizzarroAdd a basic L2 forwarding test suite which tests the correct functionality of the forwarding facility built-in in the DPDK.
The tests are performed with different queues numbers per port.
--- dts/tests/TestSuite_l2fwd.py | 63 ++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 dts/tests/TestSuite_l2fwd.py
dts/tests/TestSuite_l2fwd.py new file +63 -0
@@ -0,0 +1,63 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2024 Arm Limited + +"""Basic L2 forwarding test suite. + +This testing suites runs basic L2 forwarding on testpmd across multiple different queue sizes. +The forwarding test is performed with several packets being sent at once. +""" + +from framework.params.testpmd import EthPeer, SimpleForwardingModes +from framework.remote_session.testpmd_shell import TestPmdShell +from framework.test_suite import TestSuite, func_test +from framework.testbed_model.capability import requires +from framework.testbed_model.cpu import LogicalCoreCount +from framework.testbed_model.topology import TopologyType +from framework.utils import generate_random_packets + + +@requires(topology_type=TopologyType.two_links) +class TestL2fwd(TestSuite): + """L2 forwarding test suite.""" + + #: The total number of packets to generate and send for forwarding. + NUMBER_OF_PACKETS_TO_SEND = 50 + #: The payload size to use for the generated packets in bytes. + PAYLOAD_SIZE = 100 + + def set_up_suite(self) -> None: + """Set up the test suite. + + Setup: + Generate the random packets that will be sent. + """ + self.packets = generate_random_packets(self.NUMBER_OF_PACKETS_TO_SEND, self.PAYLOAD_SIZE) + + @func_test + def l2fwd_integrity(self) -> None: + """Test the L2 forwarding integrity. + + Test: + Configure a testpmd shell with a different numbers of queues (1, 2, 4 and 8) per run. + Start up L2 forwarding, send random packets from the TG and verify they were all + received back. + """ + queues = [1, 2, 4, 8] + + with TestPmdShell( + self.sut_node, + lcore_filter_specifier=LogicalCoreCount(cores_per_socket=4), + forward_mode=SimpleForwardingModes.mac, + eth_peer=[EthPeer(1, self.tg_node.ports[1].mac_address)], + disable_device_start=True, + ) as shell: + for queues_num in queues: + self._logger.info(f"Testing L2 forwarding with {queues_num} queue(s)") + shell.set_ports_queues(queues_num) + shell.start() + + received_packets = self.send_packets_and_capture(self.packets) + expected_packets = self.get_expected_packets(self.packets) + self.match_all_packets(expected_packets, received_packets) + + shell.stop()
Signature · 1 line
2.43.0
Series applied to next-dts, thanks!