From patchwork Thu Oct 26 21:58:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Spewock X-Patchwork-Id: 133441 X-Patchwork-Delegate: thomas@monjalon.net 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 4F8DB4320D; Fri, 27 Oct 2023 00:03:33 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F326A40A8A; Fri, 27 Oct 2023 00:03:32 +0200 (CEST) Received: from mail-yb1-f226.google.com (mail-yb1-f226.google.com [209.85.219.226]) by mails.dpdk.org (Postfix) with ESMTP id 8741140A76 for ; Fri, 27 Oct 2023 00:03:31 +0200 (CEST) Received: by mail-yb1-f226.google.com with SMTP id 3f1490d57ef6-d9beb865a40so1055296276.1 for ; Thu, 26 Oct 2023 15:03:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iol.unh.edu; s=unh-iol; t=1698357811; x=1698962611; 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=ESYGbricLvHiIxgZDr+CtzbqZFV22+xMaPFF+6YOJso=; b=iK5l0oqoTawplZQqx0lhFZA6Ua55y7HWzHhq6pCFojFTWYhZ+cv1HtL5CwnwkKzxRh hwYcbPxA65fZxAaJP+zsYJuzYuevQouIPr/z3JIuuav0vvfsMhRvrXtdIMUyd8ncNnMe K0IYH31Db+goLnI94LrdymrWwx+PW+SNrAiCs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698357811; x=1698962611; 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=ESYGbricLvHiIxgZDr+CtzbqZFV22+xMaPFF+6YOJso=; b=PPzZwt0o5VWu8q6IMFVCsaFOAnmwnRGBbincnyJspm0hmsLx7H94DNOwtVXl1Gu/0U UC1uazSnEXQjxtuf/b0qwWO5RtisIlu+Lx2YrPZxnpiFSfrfYAlRsLwt5Lgz81l4a0VG gSxsdyRf14MYZG6IRJozmPd/jFHG7L/r7l0g34aIyO8oFYjljdFvtqnmw0tKAoqlWgbs jcQ/74NOiQzLv5F1JwiOaO10tg2wQh5Z3aPJMgGLqw2zUNNpuZmsOi68zwGry32hIEae LwJSry5PCtZvBbHBSjKiZ1os7PwwdBG7T7AFqtwibcE3SMHNMcrUh1F8YkiGhVc7Uyb/ BYoA== X-Gm-Message-State: AOJu0YwZASszqAncrVUeAX7Qr2hXwoNMsgNEe4QjYgADpa3mJUXaL/jq 4cSQ1mc+1G0MJnRZECgbSQxCjbv8qQ2itZY2ZttRops8OJ3ybQ== X-Google-Smtp-Source: AGHT+IHXOuUsdtEC2f43KTw4OKFlUgxBCJrqcG5iQvOvs38seHkKJXD2Os5ZT5honnrL7X9ckmICD9nJOFYN X-Received: by 2002:a25:2d4:0:b0:da0:4d0:3e2a with SMTP id 203-20020a2502d4000000b00da004d03e2amr766237ybc.0.1698357810909; Thu, 26 Oct 2023 15:03:30 -0700 (PDT) Received: from postal.iol.unh.edu (postal.iol.unh.edu. [132.177.123.84]) by smtp-relay.gmail.com with ESMTPS id r141-20020a257693000000b00da14ad2f5a2sm20681ybc.31.2023.10.26.15.03.30 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Oct 2023 15:03:30 -0700 (PDT) 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 749C3602A042; Thu, 26 Oct 2023 18:03:30 -0400 (EDT) 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 Cc: dev@dpdk.org, Jeremy Spewock Subject: [PATCH v1 1/1] dts: bind to DPDK driver before running test suites Date: Thu, 26 Oct 2023 17:58:58 -0400 Message-ID: <20231026220059.10685-3-jspewock@iol.unh.edu> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231026220059.10685-2-jspewock@iol.unh.edu> References: <20231026220059.10685-2-jspewock@iol.unh.edu> 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 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/remote_session/linux_session.py | 3 ++ dts/framework/remote_session/os_session.py | 6 ++++ dts/framework/testbed_model/sut_node.py | 34 +++++++++++++++++++ dts/tests/TestSuite_os_udp.py | 4 +++ dts/tests/TestSuite_smoke_tests.py | 6 ++-- 5 files changed, 49 insertions(+), 4 deletions(-) diff --git a/dts/framework/remote_session/linux_session.py b/dts/framework/remote_session/linux_session.py index a3f1a6bf3b..7f2453c44c 100644 --- a/dts/framework/remote_session/linux_session.py +++ b/dts/framework/remote_session/linux_session.py @@ -199,3 +199,6 @@ def configure_port_ip_address( def configure_ipv4_forwarding(self, enable: bool) -> None: state = 1 if enable else 0 self.send_command(f"sysctl -w net.ipv4.ip_forward={state}", privileged=True) + + def probe_driver(self, driver_name: str) -> None: + self.send_command(f"modprobe {driver_name}", verify=True) diff --git a/dts/framework/remote_session/os_session.py b/dts/framework/remote_session/os_session.py index 8a709eac1c..719e815ac8 100644 --- a/dts/framework/remote_session/os_session.py +++ b/dts/framework/remote_session/os_session.py @@ -282,3 +282,9 @@ def configure_ipv4_forwarding(self, enable: bool) -> None: """ Enable IPv4 forwarding in the underlying OS. """ + + @abstractmethod + def probe_driver(self, driver_name: str) -> None: + """ + Load the module for the driver. + """ diff --git a/dts/framework/testbed_model/sut_node.py b/dts/framework/testbed_model/sut_node.py index 202aebfd06..5a7dd91cac 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: 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 = 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(self) -> PurePath: + if self._path_to_devbind is None: + self._path_to_devbind = self.main_session.join_remote_path( + self._remote_dpdk_dir, "usertools", "dpdk-devbind.py" + ) + return self._path_to_devbind + 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,19 @@ 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.probe_driver(driver) + self.main_session.send_command( + f"{self.path_to_devbind} -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..0b839cba4e 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 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)})", )