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 E4968432EC; Fri, 10 Nov 2023 00:17:30 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D14FF41151; Fri, 10 Nov 2023 00:17:30 +0100 (CET) Received: from mail-pj1-f98.google.com (mail-pj1-f98.google.com [209.85.216.98]) by mails.dpdk.org (Postfix) with ESMTP id 558FF41143 for ; Fri, 10 Nov 2023 00:17:29 +0100 (CET) Received: by mail-pj1-f98.google.com with SMTP id 98e67ed59e1d1-2802e5ae23bso1334203a91.2 for ; Thu, 09 Nov 2023 15:17:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iol.unh.edu; s=unh-iol; t=1699571848; x=1700176648; 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=BEIVF8pHcyq4mSj1WpBnzLc7iFFhA5bQ+GGIyzZff2E=; b=NkNoS97VP9Bn7SlrYxt2voCX7nJAMf8bT/cj+pbyA1a0jHLE3OHMzZjh5B0brHs4bq X/AX9VW4WNO6Y/a3dwTtS/xfM1vtROXZhvG3SIuPAqHSE1iehojMbu/tFiXUEJg0y35O 8d8OEiwWey1daj8Vrvyu0Ob27YdUXlYJRvrIw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699571848; x=1700176648; 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=BEIVF8pHcyq4mSj1WpBnzLc7iFFhA5bQ+GGIyzZff2E=; b=RhxHPE2DKr88pDJlcKmiKGrbO7aM2f7gojoIP9WhD3K0tGRK/UHDB1IoAAz2TW67Gg PffKPJM665DY/+aFWJ8+8io2qIoxhGN3gMwxJLekHL9yKat6BZUF51FbaJDwf0zLIJgr 4+104vxAexwolSUt3OiJLY2hig7yW9dnNww6+T0kyEUYN7b0K1ACqs7in5rm5TC6ucET bDF7fW7N8YaKoPscSPtRkimcOjuLLH8lgi3Ti1py3IKvD0oGcSC9P3PzX+A1y6xxupjh mz1nwZ7+0PNW8d/dO57HDw31rfIx/zvU9gpvZ1QkCg7fw2wFZSXZyluiAXpCjuNxq13a UXqQ== X-Gm-Message-State: AOJu0Yw271JjQpxnYoHkgdxjDxs8E+jX6Bj6/EZukizqCG5Fp/Oa8PN+ Y+oRfQFHxtJD7/OjGkOG3Rl63h3D5KPa1Z0KemV3gXtckuDpVfTQdKbL+gS/+JGdHw== X-Google-Smtp-Source: AGHT+IGFO4rTBsffxwz2RqKrQPsczZ71V9fPV4bnjXkYIlBn5dH32mflF1/1TOsZv3OOJdLSgUsjWAPLltsO X-Received: by 2002:a17:90b:38c4:b0:27c:fc2a:a178 with SMTP id nn4-20020a17090b38c400b0027cfc2aa178mr3413456pjb.9.1699571848537; Thu, 09 Nov 2023 15:17:28 -0800 (PST) Received: from postal.iol.unh.edu (postal.iol.unh.edu. [2606:4100:3880:1234::84]) by smtp-relay.gmail.com with ESMTPS id rj12-20020a17090b3e8c00b00281085914cfsm543395pjb.16.2023.11.09.15.17.28 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Nov 2023 15:17:28 -0800 (PST) X-Relaying-Domain: iol.unh.edu Received: from iol.unh.edu (unknown [IPv6:2606:4100:3880:1271:90f9:1b64:f6e6:867f]) by postal.iol.unh.edu (Postfix) with ESMTP id DD214605C318; Thu, 9 Nov 2023 18:17:27 -0500 (EST) From: jspewock@iol.unh.edu To: Honnappa.Nagarahalli@arm.com, juraj.linkes@pantheon.tech, thomas@monjalon.net, wathsala.vithanage@arm.com, probb@iol.unh.edu, paul.szczepanek@arm.com, yoan.picchi@foss.arm.com Cc: dev@dpdk.org, Jeremy Spewock Subject: [PATCH v3 1/1] dts: bind to DPDK driver before running test suites Date: Thu, 9 Nov 2023 18:16:14 -0500 Message-ID: <20231109231707.25400-2-jspewock@iol.unh.edu> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231109231707.25400-1-jspewock@iol.unh.edu> References: <20231109231707.25400-1-jspewock@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 From: Jeremy Spewock Modifies the current process so that we bind to os_driver_for_dpdk from the configuration file before running test suites and bind back to the os_driver afterwards. This allows test suites to assume that the ports are bound to a DPDK supported driver or bind to either driver as needed. Signed-off-by: Jeremy Spewock --- dts/framework/testbed_model/sut_node.py | 33 +++++++++++++++++++++++++ dts/tests/TestSuite_os_udp.py | 4 +++ dts/tests/TestSuite_smoke_tests.py | 6 ++--- 3 files changed, 39 insertions(+), 4 deletions(-) diff --git a/dts/framework/testbed_model/sut_node.py b/dts/framework/testbed_model/sut_node.py index 202aebfd06..4161d3a4d5 100644 --- a/dts/framework/testbed_model/sut_node.py +++ b/dts/framework/testbed_model/sut_node.py @@ -89,6 +89,7 @@ class SutNode(Node): _dpdk_version: str | None _node_info: NodeInfo | None _compiler_version: str | None + _path_to_devbind_script: PurePath | None def __init__(self, node_config: SutNodeConfiguration): super(SutNode, self).__init__(node_config) @@ -105,6 +106,7 @@ def __init__(self, node_config: SutNodeConfiguration): self._dpdk_version = None self._node_info = None self._compiler_version = None + self._path_to_devbind_script = None self._logger.info(f"Created node: {self.name}") @property @@ -155,6 +157,14 @@ def compiler_version(self) -> str: return "" return self._compiler_version + @property + def path_to_devbind_script(self) -> PurePath: + if self._path_to_devbind_script is None: + self._path_to_devbind_script = self.main_session.join_remote_path( + self._remote_dpdk_dir, "usertools", "dpdk-devbind.py" + ) + return self._path_to_devbind_script + def get_build_target_info(self) -> BuildTargetInfo: return BuildTargetInfo( dpdk_version=self.dpdk_version, compiler_version=self.compiler_version @@ -176,6 +186,14 @@ def _set_up_build_target( self._configure_build_target(build_target_config) self._copy_dpdk_tarball() self._build_dpdk() + self.bind_ports_to_driver() + + def _tear_down_build_target(self) -> None: + """ + This method exists to be optionally overwritten by derived classes and + is not decorated so that the derived class doesn't have to use the decorator. + """ + self.bind_ports_to_driver(for_dpdk=False) def _configure_build_target( self, build_target_config: BuildTargetConfiguration @@ -389,3 +407,18 @@ def create_interactive_shell( return super().create_interactive_shell( shell_cls, timeout, privileged, str(eal_parameters) ) + + def bind_ports_to_driver(self, for_dpdk: bool = True) -> None: + """Bind all ports on the SUT to a driver. + + Args: + for_dpdk: Boolean that, when True, binds ports to os_driver_for_dpdk + or, when False, binds to os_driver. Defaults to True. + """ + for port in self.ports: + driver = port.os_driver_for_dpdk if for_dpdk else port.os_driver + self.main_session.send_command( + f"{self.path_to_devbind_script} -b {driver} --force {port.pci}", + privileged=True, + verify=True, + ) diff --git a/dts/tests/TestSuite_os_udp.py b/dts/tests/TestSuite_os_udp.py index 9b5f39711d..bf6b93deb5 100644 --- a/dts/tests/TestSuite_os_udp.py +++ b/dts/tests/TestSuite_os_udp.py @@ -19,6 +19,8 @@ def set_up_suite(self) -> None: Configure SUT ports and SUT to route traffic from if1 to if2. """ + # This test uses kernel drivers + self.sut_node.bind_ports_to_driver(for_dpdk=False) self.configure_testbed_ipv4() def test_os_udp(self) -> None: @@ -43,3 +45,5 @@ def tear_down_suite(self) -> None: Remove the SUT port configuration configured in setup. """ self.configure_testbed_ipv4(restore=True) + # Assume other suites will likely need dpdk driver + self.sut_node.bind_ports_to_driver(for_dpdk=True) diff --git a/dts/tests/TestSuite_smoke_tests.py b/dts/tests/TestSuite_smoke_tests.py index 4a269df75b..e8016d1b54 100644 --- a/dts/tests/TestSuite_smoke_tests.py +++ b/dts/tests/TestSuite_smoke_tests.py @@ -84,9 +84,7 @@ def test_device_bound_to_driver(self) -> None: Ensure that all drivers listed in the config are bound to the correct driver. """ - path_to_devbind = self.sut_node.main_session.join_remote_path( - self.sut_node._remote_dpdk_dir, "usertools", "dpdk-devbind.py" - ) + path_to_devbind = self.sut_node.path_to_devbind_script all_nics_in_dpdk_devbind = self.sut_node.main_session.send_command( f"{path_to_devbind} --status | awk '{REGEX_FOR_PCI_ADDRESS}'", @@ -108,7 +106,7 @@ def test_device_bound_to_driver(self) -> None: # We know this isn't None, but mypy doesn't assert devbind_info_for_nic is not None self.verify( - devbind_info_for_nic.group(1) == nic.os_driver, + devbind_info_for_nic.group(1) == nic.os_driver_for_dpdk, f"Driver for device {nic.pci} does not match driver listed in " f"configuration (bound to {devbind_info_for_nic.group(1)})", ) -- 2.42.0