From patchwork Thu Nov 7 13:56:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Vizzarro X-Patchwork-Id: 148068 X-Patchwork-Delegate: paul.szczepanek@arm.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 4095645C9F; Thu, 7 Nov 2024 15:00:10 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C2DC642F8F; Thu, 7 Nov 2024 15:00:06 +0100 (CET) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mails.dpdk.org (Postfix) with ESMTP id E53E942F49 for ; Thu, 7 Nov 2024 15:00:05 +0100 (CET) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 14A4E1063; Thu, 7 Nov 2024 06:00:35 -0800 (PST) Received: from localhost.localdomain (JR4XG4HTQC.cambridge.arm.com [10.1.25.56]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 8E69C3F6A8; Thu, 7 Nov 2024 06:00:04 -0800 (PST) From: Luca Vizzarro To: dev@dpdk.org Cc: Paul Szczepanek , Patrick Robb , Luca Vizzarro Subject: [PATCH v2 1/2] dts: add blocked ports to EalParams Date: Thu, 7 Nov 2024 13:56:53 +0000 Message-ID: <20241107135654.4121761-2-luca.vizzarro@arm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241107135654.4121761-1-luca.vizzarro@arm.com> References: <20240625123611.1474204-1-luca.vizzarro@arm.com> <20241107135654.4121761-1-luca.vizzarro@arm.com> MIME-Version: 1.0 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 Make the "ports" attribute of EalParams as it actually is to "allowed_ports", and add "blocked_ports". Signed-off-by: Luca Vizzarro Reviewed-by: Paul Szczepanek Reviewed-by: Nicholas Pratte --- dts/framework/params/eal.py | 6 +++++- dts/framework/params/types.py | 3 ++- dts/framework/remote_session/dpdk_shell.py | 4 ++-- dts/framework/remote_session/testpmd_shell.py | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/dts/framework/params/eal.py b/dts/framework/params/eal.py index cf1594353a..71bc781eab 100644 --- a/dts/framework/params/eal.py +++ b/dts/framework/params/eal.py @@ -45,9 +45,13 @@ class EalParams(Params): vdevs: list[VirtualDevice] | None = field( default=None, metadata=Params.multiple() | Params.long("vdev") ) - ports: list[Port] | None = field( + allowed_ports: list[Port] | None = field( default=None, metadata=Params.convert_value(_port_to_pci) | Params.multiple() | Params.short("a"), ) + blocked_ports: list[Port] | None = field( + default=None, + metadata=Params.convert_value(_port_to_pci) | Params.multiple() | Params.short("b"), + ) other_eal_param: Params | None = None _separator: Literal[True] = field(default=True, init=False, metadata=Params.short("-")) diff --git a/dts/framework/params/types.py b/dts/framework/params/types.py index d77c4625fb..87d11502e8 100644 --- a/dts/framework/params/types.py +++ b/dts/framework/params/types.py @@ -50,7 +50,8 @@ class EalParamsDict(TypedDict, total=False): prefix: str no_pci: Switch vdevs: list[VirtualDevice] | None - ports: list[Port] | None + allowed_ports: list[Port] | None + blocked_ports: list[Port] | None other_eal_param: Params | None diff --git a/dts/framework/remote_session/dpdk_shell.py b/dts/framework/remote_session/dpdk_shell.py index b39132cc42..82fa4755f0 100644 --- a/dts/framework/remote_session/dpdk_shell.py +++ b/dts/framework/remote_session/dpdk_shell.py @@ -56,8 +56,8 @@ def compute_eal_params( sut_node.dpdk_prefix_list.append(prefix) params.prefix = prefix - if params.ports is None: - params.ports = sut_node.ports + if params.allowed_ports is None: + params.allowed_ports = sut_node.ports return params diff --git a/dts/framework/remote_session/testpmd_shell.py b/dts/framework/remote_session/testpmd_shell.py index 8a45a5231b..221465f6fb 100644 --- a/dts/framework/remote_session/testpmd_shell.py +++ b/dts/framework/remote_session/testpmd_shell.py @@ -1465,7 +1465,7 @@ def start(self, verify: bool = True) -> None: self._logger.debug(f"Failed to start packet forwarding: \n{start_cmd_output}") raise InteractiveCommandExecutionError("Testpmd failed to start packet forwarding.") - number_of_ports = len(self._app_params.ports or []) + number_of_ports = len(self._app_params.allowed_ports or []) for port_id in range(number_of_ports): if not self.wait_link_status_up(port_id): raise InteractiveCommandExecutionError( From patchwork Thu Nov 7 13:56:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Vizzarro X-Patchwork-Id: 148069 X-Patchwork-Delegate: probb@iol.unh.edu Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id B7C2C45C9F; Thu, 7 Nov 2024 15:00:15 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D47B942FB5; Thu, 7 Nov 2024 15:00:07 +0100 (CET) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mails.dpdk.org (Postfix) with ESMTP id B33E442F83 for ; Thu, 7 Nov 2024 15:00:06 +0100 (CET) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0443B497; Thu, 7 Nov 2024 06:00:36 -0800 (PST) Received: from localhost.localdomain (JR4XG4HTQC.cambridge.arm.com [10.1.25.56]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 7DF6D3F6A8; Thu, 7 Nov 2024 06:00:05 -0800 (PST) From: Luca Vizzarro To: dev@dpdk.org Cc: Paul Szczepanek , Patrick Robb , Luca Vizzarro Subject: [PATCH v2 2/2] dts: add blocklist test suite Date: Thu, 7 Nov 2024 13:56:54 +0000 Message-ID: <20241107135654.4121761-3-luca.vizzarro@arm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241107135654.4121761-1-luca.vizzarro@arm.com> References: <20240625123611.1474204-1-luca.vizzarro@arm.com> <20241107135654.4121761-1-luca.vizzarro@arm.com> MIME-Version: 1.0 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 This test suite tests the port blocklisting functionality built in testpmd. Signed-off-by: Luca Vizzarro Reviewed-by: Paul Szczepanek --- dts/framework/config/conf_yaml_schema.json | 3 +- dts/tests/TestSuite_blocklist.py | 63 ++++++++++++++++++++++ 2 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 dts/tests/TestSuite_blocklist.py diff --git a/dts/framework/config/conf_yaml_schema.json b/dts/framework/config/conf_yaml_schema.json index cc3e78cef5..65d0991686 100644 --- a/dts/framework/config/conf_yaml_schema.json +++ b/dts/framework/config/conf_yaml_schema.json @@ -244,7 +244,8 @@ "hello_world", "os_udp", "pmd_buffer_scatter", - "vlan" + "vlan", + "blocklist" ] }, "test_target": { diff --git a/dts/tests/TestSuite_blocklist.py b/dts/tests/TestSuite_blocklist.py new file mode 100644 index 0000000000..b9e9cd1d1a --- /dev/null +++ b/dts/tests/TestSuite_blocklist.py @@ -0,0 +1,63 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2024 Arm Limited + +"""The DPDK device blocklisting test suite. + +This testing suite ensures tests the port blocklisting functionality of testpmd. +""" + +from framework.remote_session.testpmd_shell import TestPmdShell +from framework.test_suite import TestSuite, func_test +from framework.testbed_model.capability import TopologyType, requires +from framework.testbed_model.port import Port + + +@requires(topology_type=TopologyType.two_links) +class TestBlocklist(TestSuite): + """DPDK device blocklisting test suite.""" + + def verify_blocklisted_ports(self, ports_to_block: list[Port]): + """Runs testpmd with the given ports blocklisted and verifies the ports.""" + with TestPmdShell(self.sut_node, allowed_ports=[], blocked_ports=ports_to_block) as testpmd: + allowlisted_ports = {port.device_name for port in testpmd.show_port_info_all()} + blocklisted_ports = {port.pci for port in ports_to_block} + + # sanity check + allowed_len = len(allowlisted_ports - blocklisted_ports) + self.verify(allowed_len > 0, "At least one port should have been allowed") + + blocked = not allowlisted_ports & blocklisted_ports + self.verify(blocked, "At least one port was not blocklisted") + + @func_test + def no_blocklisted(self): + """Run testpmd with no blocklisted device. + + Steps: + Run testpmd without specifying allowed or blocked ports. + Verify: + That no ports were blocked. + """ + self.verify_blocklisted_ports([]) + + @func_test + def one_port_blocklisted(self): + """Run testpmd with one blocklisted port. + + Steps: + Run testpmd with one only one blocklisted port and allowing all the other ones. + Verify: + That the port was successfully blocklisted. + """ + self.verify_blocklisted_ports(self.sut_node.ports[:1]) + + @func_test + def all_but_one_port_blocklisted(self): + """Run testpmd with all but one blocklisted port. + + Steps: + Run testpmd with only one allowed port, blocking all the other ones. + Verify: + That all specified ports were successfully blocklisted. + """ + self.verify_blocklisted_ports(self.sut_node.ports[:-1])