From patchwork Mon Dec 18 18:12:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Spewock X-Patchwork-Id: 135295 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 C454D4373D; Mon, 18 Dec 2023 19:13:09 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0ECB540E64; Mon, 18 Dec 2023 19:13:04 +0100 (CET) Received: from mail-pl1-f227.google.com (mail-pl1-f227.google.com [209.85.214.227]) by mails.dpdk.org (Postfix) with ESMTP id 1FC734021D for ; Mon, 18 Dec 2023 19:13:01 +0100 (CET) Received: by mail-pl1-f227.google.com with SMTP id d9443c01a7336-1d3c394c1f4so6064245ad.2 for ; Mon, 18 Dec 2023 10:13:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iol.unh.edu; s=unh-iol; t=1702923180; x=1703527980; 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=88XdtApir5U8j5YeQD5l7pC22oM/mR+hQkO3JnGHsXY=; b=ZrpsXqw4CfPCTx6qkffLUTqWDgvYcgSWQwbdsBsqAMBn3SkymRxdrq1Htp7gvcsEWo ClTXwt1CSCP/DcbeHaxSOjVZfDcZtk9FrniI8Cb1++Yn7bqRrjf5HBZictjV1ZqhAhod tk39U4lL/8NgcpCmjVtayi6RFjiCj91jUhM8E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702923180; x=1703527980; 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=88XdtApir5U8j5YeQD5l7pC22oM/mR+hQkO3JnGHsXY=; b=YXxi68Blixy/Zzp9Q8YiwLrDCCE2PqhBRDwi5hBbI+uM66iVXxIzQi9ePZJ14lmgoS rrieius4PiVuSRAn45SE50cArqCDDvkNUMCXfAF62E5rqGRUqGYXb9FupcCbjhxM83RL TX/Fsvqzqk4LDd8LPAQY1B772VCguXiHmm++/GuNHBN+GdcBz+3wELyU88+y2xyxmqeE hWwC0rccYRFzlByF2ilg16FUg6Y1a7kPHDhB5EdougYceNpbv+bNwAWhrjjd4l0KmP0Q aK0RHHm8p0gFR9xIJVxJYD1OfN14EKeQZsCRwGUqRsQV1HYfQ3ANeO9g6+wNgBQ6fq6N K1eQ== X-Gm-Message-State: AOJu0YyAxeyPvWIaYNtFAEhVMvmUJTvSFfZ/o4QVHp58uc3+5PV6i/mL ygwUft2xGJBDQzjJW+4pE4Os1ZrFTANcEGOxek7+ojHP1fSzw+N6HFd5Q7TGj6xgwA== X-Google-Smtp-Source: AGHT+IGfVVTQQKRjTDsSbbK2Z1CB0oc9HcwvpVSFjjQUBANoJRa15HaMFM/QMCyhwQEdm5hmPSRLcA2UFzzZ X-Received: by 2002:a17:902:d58a:b0:1d3:917f:e12f with SMTP id k10-20020a170902d58a00b001d3917fe12fmr3840746plh.36.1702923180211; Mon, 18 Dec 2023 10:13:00 -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 bg1-20020a1709028e8100b001c74d16646asm1105380plb.28.2023.12.18.10.12.59 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Dec 2023 10:13:00 -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 77FB2605C311; Mon, 18 Dec 2023 13:12:59 -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, ferruh.yigit@amd.com, andrew.rybchenko@oktetlabs.ru Cc: dev@dpdk.org, Jeremy Spewock Subject: [PATCH v4 1/7] dts: add required methods to testpmd_shell Date: Mon, 18 Dec 2023 13:12:15 -0500 Message-ID: <20231218181221.10057-2-jspewock@iol.unh.edu> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231218181221.10057-1-jspewock@iol.unh.edu> References: <20231218181221.10057-1-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 Added a method within the testpmd interactive shell that polls the status of ports and verifies that the link status on a given port is "up." Polling will continue until either the link comes up, or the timeout is reached. Also added methods for starting and stopping packet forwarding in testpmd and a method for setting the forwarding mode on testpmd. The method for starting packet forwarding will also attempt to verify that forwarding did indeed start by default. Signed-off-by: Jeremy Spewock --- dts/framework/exception.py | 4 + .../remote_session/remote/testpmd_shell.py | 92 +++++++++++++++++++ 2 files changed, 96 insertions(+) diff --git a/dts/framework/exception.py b/dts/framework/exception.py index b362e42924..e36db20e32 100644 --- a/dts/framework/exception.py +++ b/dts/framework/exception.py @@ -119,6 +119,10 @@ def __str__(self) -> str: return f"Command {self.command} returned a non-zero exit code: {self.command_return_code}" +class InteractiveCommandExecutionError(DTSError): + severity: ClassVar[ErrorSeverity] = ErrorSeverity.REMOTE_CMD_EXEC_ERR + + class RemoteDirectoryExistsError(DTSError): """ Raised when a remote directory to be created already exists. diff --git a/dts/framework/remote_session/remote/testpmd_shell.py b/dts/framework/remote_session/remote/testpmd_shell.py index 08ac311016..b5e4cba9b3 100644 --- a/dts/framework/remote_session/remote/testpmd_shell.py +++ b/dts/framework/remote_session/remote/testpmd_shell.py @@ -1,9 +1,15 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2023 University of New Hampshire +import time +from enum import auto from pathlib import PurePath from typing import Callable +from framework.exception import InteractiveCommandExecutionError +from framework.settings import SETTINGS +from framework.utils import StrEnum + from .interactive_shell import InteractiveShell @@ -17,6 +23,37 @@ def __str__(self) -> str: return self.pci_address +class TestPmdForwardingModes(StrEnum): + r"""The supported packet forwarding modes for :class:`~TestPmdShell`\s""" + + #: + io = auto() + #: + mac = auto() + #: + macswap = auto() + #: + flowgen = auto() + #: + rxonly = auto() + #: + txonly = auto() + #: + csum = auto() + #: + icmpecho = auto() + #: + ieee1588 = auto() + #: + noisy = auto() + #: + fivetswap = "5tswap" + #: + shared_rxq = "shared-rxq" + #: + recycle_mbufs = auto() + + class TestPmdShell(InteractiveShell): path: PurePath = PurePath("app", "dpdk-testpmd") dpdk_app: bool = True @@ -28,6 +65,27 @@ def _start_application(self, get_privileged_command: Callable[[str], str] | None self._app_args += " -- -i" super()._start_application(get_privileged_command) + def start(self, verify: bool = True) -> None: + """Start packet forwarding with the current configuration. + + Args: + verify: If :data:`True` , a second start command will be sent in an attempt to verify + packet forwarding started as expected. + + Raises: + InteractiveCommandExecutionError: If `verify` is :data:`True` and forwarding fails to + start. + """ + self.send_command("start") + if verify: + # If forwarding was already started, sending "start" again should tell us + if "Packet forwarding already started" not in self.send_command("start"): + raise InteractiveCommandExecutionError("Testpmd failed to start packet forwarding.") + + def stop(self) -> None: + """Stop packet forwarding.""" + self.send_command("stop") + def get_devices(self) -> list[TestPmdDevice]: """Get a list of device names that are known to testpmd @@ -43,3 +101,37 @@ def get_devices(self) -> list[TestPmdDevice]: if "device name:" in line.lower(): dev_list.append(TestPmdDevice(line)) return dev_list + + def wait_link_status_up(self, port_id: int, timeout=SETTINGS.timeout) -> bool: + """Wait until the link status on the given port is "up". + + Arguments: + port_id: Port to check the link status on. + timeout: Time to wait for the link to come up. The default value for this + argument is set using the :option:`-t, --timeout` command-line argument + or the :envvar:`DTS_TIMEOUT` environment variable. + + Returns: + If the link came up in time or not. + """ + time_to_stop = time.time() + timeout + while time.time() < time_to_stop: + port_info = self.send_command(f"show port info {port_id}") + if "Link status: up" in port_info: + break + time.sleep(0.5) + else: + self._logger.error(f"The link for port {port_id} did not come up in the given timeout.") + return "Link status: up" in port_info + + def set_forward_mode(self, mode: TestPmdForwardingModes): + """Set packet forwarding mode. + + Args: + mode: The forwarding mode to use. + """ + self.send_command(f"set fwd {mode.value}") + + def close(self) -> None: + self.send_command("exit", "") + return super().close() From patchwork Mon Dec 18 18:12:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Spewock X-Patchwork-Id: 135296 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 201804373D; Mon, 18 Dec 2023 19:13:17 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 30E4C42DA3; Mon, 18 Dec 2023 19:13:05 +0100 (CET) Received: from mail-io1-f99.google.com (mail-io1-f99.google.com [209.85.166.99]) by mails.dpdk.org (Postfix) with ESMTP id E7E71406BC for ; Mon, 18 Dec 2023 19:13:01 +0100 (CET) Received: by mail-io1-f99.google.com with SMTP id ca18e2360f4ac-7b771176f80so305520639f.2 for ; Mon, 18 Dec 2023 10:13:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iol.unh.edu; s=unh-iol; t=1702923181; x=1703527981; 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=8PkZFNIb4FYyzi/xXyZ+4+3TKRrd7iSse1Ifxnl7lPQ=; b=ibySEqR8NVgD4NZnHiW5Tk1C7Z2Ui4tS6uCZgGiv5tN1FWajTeA7+o8yyFytBbWaiu TCpZpQ7YN0+MHdfqBUTZIFuG+kprinmE9aQGnqoGEHLvMWWVy1/1MwBjKqZkxVBpaOmL i526plSH485ZpEowkOPUYIDgqRfiI3eXXcIKA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702923181; x=1703527981; 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=8PkZFNIb4FYyzi/xXyZ+4+3TKRrd7iSse1Ifxnl7lPQ=; b=EOXe/EWBH+WlAx9+6Rm+oyfitedtoSCWB8CIbCJtqisGuxDnNXQFmxIYoBIE37lEY0 CCWlR+MnAVE/HtBrIRxxjsEbX3FHARCalBR9UJJpqLRDATpOXKKc5/SpCfb+esSBIUvH 4srQlwtU+n8MkVgQKh/LOPRPAuHJVylOBjw43XHUwdmQQbVxtmHJcZtRt13yabu8v5e9 8xysP6DcgTW3CA3RsbSB5KkCLiv1izjt8LhPjYRZLQZ/NsP75g2r17Uhj9OivF7QMv9x xKosZ6I1RwybkQbPR0VNJR/hR7AigUoMbTaBwit2ZQFCS/ockeIxsYjKYP75p7tScpPq 63Hw== X-Gm-Message-State: AOJu0YwzG7eMYAOwIQbczCwE4YtuWZIwHak6dVjwCG8Cq6OZQVC4RUB/ 5paS3L4bL/TNaJy0y4Xk/SL+iJeZbZ3q2GN8ZTlAiBsAD5GvmA== X-Google-Smtp-Source: AGHT+IFV7VP5qe0whBTtNzopai3tuSf6B2RSWXxyk/pqD3bcE/shh5szqljsQBqaplA/uU5mr2EfLgEupgzk X-Received: by 2002:a05:6602:1a8f:b0:7b7:1298:eb36 with SMTP id bn15-20020a0566021a8f00b007b71298eb36mr23500590iob.33.1702923181326; Mon, 18 Dec 2023 10:13:01 -0800 (PST) Received: from postal.iol.unh.edu (postal.iol.unh.edu. [132.177.123.84]) by smtp-relay.gmail.com with ESMTPS id j11-20020a0566022ccb00b007a2ad2f0ba0sm1254756iow.21.2023.12.18.10.13.01 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Dec 2023 10:13:01 -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 C65D8605C311; Mon, 18 Dec 2023 13:13:00 -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, ferruh.yigit@amd.com, andrew.rybchenko@oktetlabs.ru Cc: dev@dpdk.org, Jeremy Spewock Subject: [PATCH v4 2/7] dts: allow passing parameters into interactive apps Date: Mon, 18 Dec 2023 13:12:16 -0500 Message-ID: <20231218181221.10057-3-jspewock@iol.unh.edu> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231218181221.10057-1-jspewock@iol.unh.edu> References: <20231218181221.10057-1-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 Modified interactive applications to allow for the ability to pass parameters into the app on start up. Also modified the way EAL parameters are handled so that the trailing "--" separator is added be default after all EAL parameters. Signed-off-by: Jeremy Spewock --- .../remote_session/remote/testpmd_shell.py | 2 +- dts/framework/testbed_model/sut_node.py | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/dts/framework/remote_session/remote/testpmd_shell.py b/dts/framework/remote_session/remote/testpmd_shell.py index b5e4cba9b3..369807a33e 100644 --- a/dts/framework/remote_session/remote/testpmd_shell.py +++ b/dts/framework/remote_session/remote/testpmd_shell.py @@ -62,7 +62,7 @@ class TestPmdShell(InteractiveShell): def _start_application(self, get_privileged_command: Callable[[str], str] | None) -> None: """See "_start_application" in InteractiveShell.""" - self._app_args += " -- -i" + self._app_args += " -i" super()._start_application(get_privileged_command) def start(self, verify: bool = True) -> None: diff --git a/dts/framework/testbed_model/sut_node.py b/dts/framework/testbed_model/sut_node.py index 7f75043bd3..9c92232d9e 100644 --- a/dts/framework/testbed_model/sut_node.py +++ b/dts/framework/testbed_model/sut_node.py @@ -361,7 +361,8 @@ def create_interactive_shell( shell_cls: Type[InteractiveShellType], timeout: float = SETTINGS.timeout, privileged: bool = False, - eal_parameters: EalParameters | str | None = None, + eal_parameters: EalParameters | None = None, + app_parameters: str = "", ) -> InteractiveShellType: """Factory method for creating a handler for an interactive session. @@ -376,19 +377,22 @@ def create_interactive_shell( eal_parameters: List of EAL parameters to use to launch the app. If this isn't provided or an empty string is passed, it will default to calling create_eal_parameters(). + app_parameters: Additional arguments to pass into the application on the + command-line. Returns: Instance of the desired interactive application. """ - if not eal_parameters: - eal_parameters = self.create_eal_parameters() - - # We need to append the build directory for DPDK apps + # We need to append the build directory and add EAL parameters for DPDK apps if shell_cls.dpdk_app: + if not eal_parameters: + eal_parameters = self.create_eal_parameters() + app_parameters = f"{eal_parameters} -- {app_parameters}" + shell_cls.path = self.main_session.join_remote_path( self.remote_dpdk_build_dir, shell_cls.path ) - return super().create_interactive_shell(shell_cls, timeout, privileged, str(eal_parameters)) + return super().create_interactive_shell(shell_cls, timeout, privileged, app_parameters) def bind_ports_to_driver(self, for_dpdk: bool = True) -> None: """Bind all ports on the SUT to a driver. From patchwork Mon Dec 18 18:12:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jeremy Spewock X-Patchwork-Id: 135297 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 55EC34373D; Mon, 18 Dec 2023 19:13:24 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6387C42DB0; Mon, 18 Dec 2023 19:13:06 +0100 (CET) Received: from mail-ot1-f99.google.com (mail-ot1-f99.google.com [209.85.210.99]) by mails.dpdk.org (Postfix) with ESMTP id AE84140E64 for ; Mon, 18 Dec 2023 19:13:03 +0100 (CET) Received: by mail-ot1-f99.google.com with SMTP id 46e09a7af769-6da53d97777so955610a34.3 for ; Mon, 18 Dec 2023 10:13:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iol.unh.edu; s=unh-iol; t=1702923183; x=1703527983; 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=giA95QdZIp5kv7JDJIqN6lm5NqseqZ941YBXykN+cJE=; b=YeFUBr+zbUwTx60ri5oIlTn4rVWzZTo3igf7tk0VvWHSg/1w4LSX0wSt28JGQgTtF0 2iDaXmtDWKouRBS7nqj2nq12HEXQg3slYe4cjAWEaHIYE1jqSkvUiIc4SlYisJ4ZDy9f REoalkDrB4E2aFpqPqPAgHgwojakEcyXpoUH0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702923183; x=1703527983; 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=giA95QdZIp5kv7JDJIqN6lm5NqseqZ941YBXykN+cJE=; b=n8C/KmwEBAXuvFS6d04YvDdfb8O2W9jT/3I1Y0mWZPaBEepbcQNlWoppIKz8S5QQul D0rMp+wTFNzl+c5/0W8f6L536y6uPZ910tFWamTv544zBUh8AXfM3+7IJBh6mDJGCyU6 xRNoBP/o8DosQIev+c59XVoHMdinGtqG3PY72dcZRrZ+JJuRqOUZ8AIdcvxitNbj96ol uqoC3pkv1MHiJR0JxiNwv3u6nhChIt+WLBLB3YzvQtDWMR3hf8Et0SWVlDihw7CJXtFL LlUTdc/Ooefahx9F26WoO2DoW8eVWsQrfIiXrQ5GBzBbSBuhHtFCvXomJv5txHMSv9kE XhiQ== X-Gm-Message-State: AOJu0Yy2MaQJ6CwRQeqx0Xi/RLCRBaoOxCR5LB2TPSz85Q31eKMZWegs as2rdcZyn6lTCxqCKxzxixtj1kHf1PG/zf7qGsNpoQl9c1JBPQ== X-Google-Smtp-Source: AGHT+IH6dUw5zAN3/a83gBc8dSqKBgRRLOVzF8jxz569htvv1yXDqwSvgwo40xqwn+fHscPa4Gcq0kSEtth6 X-Received: by 2002:a9d:6751:0:b0:6c6:4843:2abb with SMTP id w17-20020a9d6751000000b006c648432abbmr9583258otm.12.1702923183006; Mon, 18 Dec 2023 10:13:03 -0800 (PST) Received: from postal.iol.unh.edu (postal.iol.unh.edu. [132.177.123.84]) by smtp-relay.gmail.com with ESMTPS id c19-20020a9d7853000000b006d9a27c86d3sm1465691otm.8.2023.12.18.10.13.02 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Dec 2023 10:13:02 -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 0530D605C311; Mon, 18 Dec 2023 13:13:02 -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, ferruh.yigit@amd.com, andrew.rybchenko@oktetlabs.ru Cc: dev@dpdk.org, Jeremy Spewock Subject: [PATCH v4 3/7] dts: add optional packet filtering to scapy sniffer Date: Mon, 18 Dec 2023 13:12:17 -0500 Message-ID: <20231218181221.10057-4-jspewock@iol.unh.edu> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231218181221.10057-1-jspewock@iol.unh.edu> References: <20231218181221.10057-1-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 Added the options to filter out LLDP and ARP packets when sniffing for packets with scapy. This was done using BPF filters to ensure that the noise these packets provide does not interfere with test cases. Signed-off-by: Jeremy Spewock Reviewed-by: Juraj Linkeš --- dts/framework/test_suite.py | 14 ++++++++-- .../capturing_traffic_generator.py | 22 ++++++++++++++- dts/framework/testbed_model/scapy.py | 28 ++++++++++++++++++- dts/framework/testbed_model/tg_node.py | 12 ++++++-- 4 files changed, 70 insertions(+), 6 deletions(-) diff --git a/dts/framework/test_suite.py b/dts/framework/test_suite.py index 4a7907ec33..6dfa570041 100644 --- a/dts/framework/test_suite.py +++ b/dts/framework/test_suite.py @@ -27,6 +27,7 @@ from .settings import SETTINGS from .test_result import BuildTargetResult, Result, TestCaseResult, TestSuiteResult from .testbed_model import SutNode, TGNode +from .testbed_model.capturing_traffic_generator import PacketFilteringConfig from .testbed_model.hw.port import Port, PortLink from .utils import get_packet_summaries @@ -149,7 +150,12 @@ def configure_testbed_ipv4(self, restore: bool = False) -> None: def _configure_ipv4_forwarding(self, enable: bool) -> None: self.sut_node.configure_ipv4_forwarding(enable) - def send_packet_and_capture(self, packet: Packet, duration: float = 1) -> list[Packet]: + def send_packet_and_capture( + self, + packet: Packet, + filter_config: PacketFilteringConfig = PacketFilteringConfig(), + duration: float = 1, + ) -> list[Packet]: """ Send a packet through the appropriate interface and receive on the appropriate interface. @@ -158,7 +164,11 @@ def send_packet_and_capture(self, packet: Packet, duration: float = 1) -> list[P """ packet = self._adjust_addresses(packet) return self.tg_node.send_packet_and_capture( - packet, self._tg_port_egress, self._tg_port_ingress, duration + packet, + self._tg_port_egress, + self._tg_port_ingress, + filter_config, + duration, ) def get_expected_packet(self, packet: Packet) -> Packet: diff --git a/dts/framework/testbed_model/capturing_traffic_generator.py b/dts/framework/testbed_model/capturing_traffic_generator.py index e6512061d7..c40b030fe4 100644 --- a/dts/framework/testbed_model/capturing_traffic_generator.py +++ b/dts/framework/testbed_model/capturing_traffic_generator.py @@ -11,6 +11,7 @@ import uuid from abc import abstractmethod +from dataclasses import dataclass import scapy.utils # type: ignore[import] from scapy.packet import Packet # type: ignore[import] @@ -29,6 +30,19 @@ def _get_default_capture_name() -> str: return str(uuid.uuid4()) +@dataclass(slots=True) +class PacketFilteringConfig: + """The supported filtering options for :class:`CapturingTrafficGenerator`. + + Attributes: + no_lldp: If :data:`True`, LLDP packets will be filtered out when capturing. + no_arp: If :data:`True`, ARP packets will be filtered out when capturing. + """ + + no_lldp: bool = True + no_arp: bool = True + + class CapturingTrafficGenerator(TrafficGenerator): """Capture packets after sending traffic. @@ -51,6 +65,7 @@ def send_packet_and_capture( packet: Packet, send_port: Port, receive_port: Port, + filter_config: PacketFilteringConfig, duration: float, capture_name: str = _get_default_capture_name(), ) -> list[Packet]: @@ -64,6 +79,7 @@ def send_packet_and_capture( packet: The packet to send. send_port: The egress port on the TG node. receive_port: The ingress port in the TG node. + filter_config: Filters to apply when capturing packets. duration: Capture traffic for this amount of time after sending the packet. capture_name: The name of the .pcap file where to store the capture. @@ -71,7 +87,7 @@ def send_packet_and_capture( A list of received packets. May be empty if no packets are captured. """ return self.send_packets_and_capture( - [packet], send_port, receive_port, duration, capture_name + [packet], send_port, receive_port, filter_config, duration, capture_name ) def send_packets_and_capture( @@ -79,6 +95,7 @@ def send_packets_and_capture( packets: list[Packet], send_port: Port, receive_port: Port, + filter_config: PacketFilteringConfig, duration: float, capture_name: str = _get_default_capture_name(), ) -> list[Packet]: @@ -92,6 +109,7 @@ def send_packets_and_capture( packets: The packets to send. send_port: The egress port on the TG node. receive_port: The ingress port in the TG node. + filter_config: Filters to apply when capturing packets. duration: Capture traffic for this amount of time after sending the packets. capture_name: The name of the .pcap file where to store the capture. @@ -106,6 +124,7 @@ def send_packets_and_capture( packets, send_port, receive_port, + filter_config, duration, ) @@ -119,6 +138,7 @@ def _send_packets_and_capture( packets: list[Packet], send_port: Port, receive_port: Port, + filter_config: PacketFilteringConfig, duration: float, ) -> list[Packet]: """ diff --git a/dts/framework/testbed_model/scapy.py b/dts/framework/testbed_model/scapy.py index 9083e92b3d..94b0af7c6f 100644 --- a/dts/framework/testbed_model/scapy.py +++ b/dts/framework/testbed_model/scapy.py @@ -30,6 +30,7 @@ from .capturing_traffic_generator import ( CapturingTrafficGenerator, + PacketFilteringConfig, _get_default_capture_name, ) from .hw.port import Port @@ -69,6 +70,7 @@ def scapy_send_packets_and_capture( send_iface: str, recv_iface: str, duration: float, + sniff_filter: str, ) -> list[bytes]: """RPC function to send and capture packets. @@ -90,6 +92,7 @@ def scapy_send_packets_and_capture( iface=recv_iface, store=True, started_callback=lambda *args: scapy.all.sendp(scapy_packets, iface=send_iface), + filter=sniff_filter, ) sniffer.start() time.sleep(duration) @@ -249,16 +252,38 @@ def _send_packets(self, packets: list[Packet], port: Port) -> None: packets = [packet.build() for packet in packets] self.rpc_server_proxy.scapy_send_packets(packets, port.logical_name) + def _create_packet_filter(self, filter_config: PacketFilteringConfig) -> str: + """Combines filter settings from `filter_config` into a BPF that scapy can use. + + Scapy allows for the use of Berkeley Packet Filters (BPFs) to filter what packets are + collected based on various attributes of the packet. + + Args: + filter_config: Config class that specifies which filters should be applied. + + Returns: + A string representing the combination of BPF filters to be passed to scapy. For + example: + + "ether[12:2] != 0x88cc && ether[12:2] != 0x0806" + """ + bpf_filter: list[str] = [] + if filter_config.no_arp: + bpf_filter.append("ether[12:2] != 0x0806") + if filter_config.no_lldp: + bpf_filter.append("ether[12:2] != 0x88cc") + return " && ".join(bpf_filter) + def _send_packets_and_capture( self, packets: list[Packet], send_port: Port, receive_port: Port, + filter_config: PacketFilteringConfig, duration: float, capture_name: str = _get_default_capture_name(), ) -> list[Packet]: binary_packets = [packet.build() for packet in packets] - xmlrpc_packets: list[ xmlrpc.client.Binary ] = self.rpc_server_proxy.scapy_send_packets_and_capture( @@ -266,6 +291,7 @@ def _send_packets_and_capture( send_port.logical_name, receive_port.logical_name, duration, + self._create_packet_filter(filter_config), ) # type: ignore[assignment] scapy_packets = [Ether(packet.data) for packet in xmlrpc_packets] diff --git a/dts/framework/testbed_model/tg_node.py b/dts/framework/testbed_model/tg_node.py index 79a55663b5..475dc2968d 100644 --- a/dts/framework/testbed_model/tg_node.py +++ b/dts/framework/testbed_model/tg_node.py @@ -23,7 +23,10 @@ ) from framework.exception import ConfigurationError -from .capturing_traffic_generator import CapturingTrafficGenerator +from .capturing_traffic_generator import ( + CapturingTrafficGenerator, + PacketFilteringConfig, +) from .hw.port import Port from .node import Node @@ -53,6 +56,7 @@ def send_packet_and_capture( packet: Packet, send_port: Port, receive_port: Port, + filter_config: PacketFilteringConfig = PacketFilteringConfig(), duration: float = 1, ) -> list[Packet]: """Send a packet, return received traffic. @@ -71,7 +75,11 @@ def send_packet_and_capture( A list of received packets. May be empty if no packets are captured. """ return self.traffic_generator.send_packet_and_capture( - packet, send_port, receive_port, duration + packet, + send_port, + receive_port, + filter_config, + duration, ) def close(self) -> None: From patchwork Mon Dec 18 18:12:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jeremy Spewock X-Patchwork-Id: 135298 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 7F6B44373D; Mon, 18 Dec 2023 19:13:32 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 84CBC42DC1; Mon, 18 Dec 2023 19:13:07 +0100 (CET) Received: from mail-pl1-f228.google.com (mail-pl1-f228.google.com [209.85.214.228]) by mails.dpdk.org (Postfix) with ESMTP id A4F2D410D0 for ; Mon, 18 Dec 2023 19:13:04 +0100 (CET) Received: by mail-pl1-f228.google.com with SMTP id d9443c01a7336-1d32c5ce32eso32224475ad.0 for ; Mon, 18 Dec 2023 10:13:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iol.unh.edu; s=unh-iol; t=1702923184; x=1703527984; 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=MgS8k8OADUeMeErqqsCQEs6yw8FVHzxDoNQ5Ppxx2DY=; b=QlO6eIsoTZcC12Gh8TRmztz334VhygZsr00XekKU+dUA6JO9pv0JKExpH0+xIUqAFm UrvbTtt1daUJsF7eTqlgcGVDIoazUdpG79NTrGjTo/1zl9l2cOp89GletjpRtUmqt+g8 yMjERNzCPq3hOjJJcQIceI0xchxiz8a2PgoHY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702923184; x=1703527984; 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=MgS8k8OADUeMeErqqsCQEs6yw8FVHzxDoNQ5Ppxx2DY=; b=cPDKTjEH26nsaOlLTLLJKrqHjVNq35og6tyaloPicrGjrPfwfqgNkazse1TJ1mSX3R +UpAjiG/RdJepGHvMg+bF592+gg062gVx+X4omUBpWDE6ooIaenlxJMFFK0cQvW75sWd d4oy8gpMLXqOwwsYnEEYwq1Z3Hj9xlDeH0vFJJr5Exx0usL6nXm35uZdiu3GbFKbKD06 8+ABUVvTQgqPRORrNATbQ2uxNPN0BohVAwxs5MKJQRef10vqthuV4RSYgE9o8PHSwuUK rd8+huC2TGD3riBLTEFiDlRGkSLpr5gxPjSrSPuNySr7BDo8TCpJ+6Ee2D+jJUSDz1je B/gA== X-Gm-Message-State: AOJu0YxDUCB7Hty8c3e5d9R4G5gQNtvx4sbcRijxCwVGmIjO5VYlPzJN hR1U4caCDHsho46af2xUEX5PJaFzjQIsz8JhXOi3h4IAkTPZhQ== X-Google-Smtp-Source: AGHT+IG8WDPCWvhty8YOfZqqbyODGZZH/pL9JxtXXi3j9p1/yOLCX4p4eaPAyhkIcjdRjIBuu6RoPKN39JjG X-Received: by 2002:a17:902:8b83:b0:1d3:485a:833d with SMTP id ay3-20020a1709028b8300b001d3485a833dmr11044465plb.39.1702923183923; Mon, 18 Dec 2023 10:13:03 -0800 (PST) Received: from postal.iol.unh.edu (postal.iol.unh.edu. [132.177.123.84]) by smtp-relay.gmail.com with ESMTPS id q11-20020a17090311cb00b001d3ad38d2fesm88522plh.48.2023.12.18.10.13.03 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Dec 2023 10:13:03 -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 E14A1605C312; Mon, 18 Dec 2023 13:13:02 -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, ferruh.yigit@amd.com, andrew.rybchenko@oktetlabs.ru Cc: dev@dpdk.org, Jeremy Spewock Subject: [PATCH v4 4/7] dts: add pci addresses to EAL parameters Date: Mon, 18 Dec 2023 13:12:18 -0500 Message-ID: <20231218181221.10057-5-jspewock@iol.unh.edu> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231218181221.10057-1-jspewock@iol.unh.edu> References: <20231218181221.10057-1-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 Added allow list to the EAL parameters created in DTS to ensure that only the relevant PCI devices are considered when launching DPDK applications. Signed-off-by: Jeremy Spewock Reviewed-by: Juraj Linkeš --- dts/framework/testbed_model/sut_node.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/dts/framework/testbed_model/sut_node.py b/dts/framework/testbed_model/sut_node.py index 9c92232d9e..77caea2fc9 100644 --- a/dts/framework/testbed_model/sut_node.py +++ b/dts/framework/testbed_model/sut_node.py @@ -20,6 +20,7 @@ from framework.utils import MesonArgs from .hw import LogicalCoreCount, LogicalCoreList, VirtualDevice +from .hw.port import Port from .node import Node @@ -31,6 +32,7 @@ def __init__( prefix: str, no_pci: bool, vdevs: list[VirtualDevice], + ports: list[Port], other_eal_param: str, ): """ @@ -46,6 +48,7 @@ def __init__( VirtualDevice('net_ring0'), VirtualDevice('net_ring1') ] + :param ports: the list of ports to allow. :param other_eal_param: user defined DPDK eal parameters, eg: other_eal_param='--single-file-segments' """ @@ -56,6 +59,7 @@ def __init__( self._prefix = f"--file-prefix={prefix}" self._no_pci = "--no-pci" if no_pci else "" self._vdevs = " ".join(f"--vdev {vdev}" for vdev in vdevs) + self._ports = " ".join(f"-a {port.pci}" for port in ports) self._other_eal_param = other_eal_param def __str__(self) -> str: @@ -65,6 +69,7 @@ def __str__(self) -> str: f"{self._prefix} " f"{self._no_pci} " f"{self._vdevs} " + f"{self._ports} " f"{self._other_eal_param}" ) @@ -294,6 +299,7 @@ def create_eal_parameters( append_prefix_timestamp: bool = True, no_pci: bool = False, vdevs: list[VirtualDevice] = None, + ports: list[Port] | None = None, other_eal_param: str = "", ) -> "EalParameters": """ @@ -317,6 +323,7 @@ def create_eal_parameters( VirtualDevice('net_ring0'), VirtualDevice('net_ring1') ] + :param ports: the list of ports to allow. :param other_eal_param: user defined DPDK eal parameters, eg: other_eal_param='--single-file-segments' :return: eal param string, eg: @@ -334,12 +341,16 @@ def create_eal_parameters( if vdevs is None: vdevs = [] + if ports is None: + ports = self.ports + return EalParameters( lcore_list=lcore_list, memory_channels=self.config.memory_channels, prefix=prefix, no_pci=no_pci, vdevs=vdevs, + ports=ports, other_eal_param=other_eal_param, ) From patchwork Mon Dec 18 18:12:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Spewock X-Patchwork-Id: 135299 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 E07254373D; Mon, 18 Dec 2023 19:13:39 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BDD6C42DC9; Mon, 18 Dec 2023 19:13:08 +0100 (CET) Received: from mail-ot1-f97.google.com (mail-ot1-f97.google.com [209.85.210.97]) by mails.dpdk.org (Postfix) with ESMTP id 1DE9742D92 for ; Mon, 18 Dec 2023 19:13:05 +0100 (CET) Received: by mail-ot1-f97.google.com with SMTP id 46e09a7af769-6d9f4eed60eso2908102a34.1 for ; Mon, 18 Dec 2023 10:13:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iol.unh.edu; s=unh-iol; t=1702923184; x=1703527984; 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=LWy5yLdKpzUDzJB70ubur9uEm4/JCOHh/XV+76RBED4=; b=bMn4BlqKAbqY0EFHdXM6c/Z6KMiArs6R91FssVblyL5R2jfCi5gi0pQNUTK8fjgWj4 bADlUy+B9U6GxVQ+lpvzeJ0IVHYFIQATmX+JZ3of6vwn5i72jKZa6q68lAxw/pa2W+5p upliq+ayjMRGcGiLlSF9e2aawnCCph3dmBwUc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702923184; x=1703527984; 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=LWy5yLdKpzUDzJB70ubur9uEm4/JCOHh/XV+76RBED4=; b=IZLSXaGHv2u7Luob+iEqCoNsgffDl0KcjRlZ+UfSZvdq0iJnnBpXuXPDy3T+nnEvHm tvyBvgGXGQE9UpjuluwUuElzrF2UujNRZ3PPiDHQRi57zC/TnMTkDPPovD0TzzQzss6m X8E0sHNa7EtgRT1mSPSaL/EzFEHwlUT9aGUEz7Plpw7pwzQVvcFeOuSC9PMc3tXtesXV U8hk5MuXB+wUFu3iLtKcuBmAw7ZO/wEFFZ0euW54Q0hM+uAOtwIlk8LVkMOItKZmXJSa hOLwvZZkxY/zrQMs0oScDNlC8bkH6dbwL6heYAcECjtEPvXnnlE/sluzfD3diOvbp2QO jomw== X-Gm-Message-State: AOJu0YxUDk3kZWWkZRN/85YiQK5+EUEAhDkmsoS+7DJT14y4zxUuHQES AkV/9OELbNVukOmsY99yMfUmb7fhCesQfpudacAetuUtw6bCRO6UIMi4cYUc9PNNyg== X-Google-Smtp-Source: AGHT+IF5RRQlpqqOA7wHG+uUMQwnlhbjRgKegkkhW9ZkpZRl+DO9j+19e0SCrS/6/JSNiJuiRXfDNqQm2kLU X-Received: by 2002:a05:6830:32a6:b0:6d9:a1c1:3ac6 with SMTP id m38-20020a05683032a600b006d9a1c13ac6mr15653336ott.58.1702923184539; Mon, 18 Dec 2023 10:13:04 -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 v36-20020a056830092400b006bb1331b18esm1338026ott.6.2023.12.18.10.13.04 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Dec 2023 10:13:04 -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 CFF8C605C311; Mon, 18 Dec 2023 13:13:03 -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, ferruh.yigit@amd.com, andrew.rybchenko@oktetlabs.ru Cc: dev@dpdk.org, Jeremy Spewock Subject: [PATCH v4 5/7] dts: allow configuring MTU of ports Date: Mon, 18 Dec 2023 13:12:19 -0500 Message-ID: <20231218181221.10057-6-jspewock@iol.unh.edu> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231218181221.10057-1-jspewock@iol.unh.edu> References: <20231218181221.10057-1-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 Adds methods in both os_session and linux session to allow for setting MTU of port interfaces in an OS agnostic way. Signed-off-by: Jeremy Spewock --- dts/framework/remote_session/linux_session.py | 8 ++++++++ dts/framework/remote_session/os_session.py | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/dts/framework/remote_session/linux_session.py b/dts/framework/remote_session/linux_session.py index fd877fbfae..aaa4d57a36 100644 --- a/dts/framework/remote_session/linux_session.py +++ b/dts/framework/remote_session/linux_session.py @@ -177,6 +177,14 @@ def configure_port_ip_address( verify=True, ) + def configure_port_mtu(self, mtu: int, port: Port) -> None: + """Overrides :meth:`~.os_session.OSSession.configure_port_mtu`.""" + self.send_command( + f"ip link set dev {port.logical_name} mtu {mtu}", + privileged=True, + verify=True, + ) + 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) diff --git a/dts/framework/remote_session/os_session.py b/dts/framework/remote_session/os_session.py index 8a709eac1c..cd073f5774 100644 --- a/dts/framework/remote_session/os_session.py +++ b/dts/framework/remote_session/os_session.py @@ -277,6 +277,15 @@ def configure_port_ip_address( Configure (add or delete) an IP address of the input port. """ + @abstractmethod + def configure_port_mtu(self, mtu: int, port: Port) -> None: + """Configure `mtu` on `port`. + + Args: + mtu: Desired MTU value. + port: Port to set `mtu` on. + """ + @abstractmethod def configure_ipv4_forwarding(self, enable: bool) -> None: """ From patchwork Mon Dec 18 18:12:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jeremy Spewock X-Patchwork-Id: 135300 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 C7D464373D; Mon, 18 Dec 2023 19:13:49 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6097042DE2; Mon, 18 Dec 2023 19:13:10 +0100 (CET) Received: from mail-pl1-f228.google.com (mail-pl1-f228.google.com [209.85.214.228]) by mails.dpdk.org (Postfix) with ESMTP id BAC6542DAC for ; Mon, 18 Dec 2023 19:13:06 +0100 (CET) Received: by mail-pl1-f228.google.com with SMTP id d9443c01a7336-1d3d0faf262so4983095ad.3 for ; Mon, 18 Dec 2023 10:13:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iol.unh.edu; s=unh-iol; t=1702923186; x=1703527986; 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=mUwABtraKUQVk1+KNd+OixqPQgpIFoZLK6tAOpcjy5Y=; b=i+u0kW1ZdMWDwfxosWZatnkY7peAfr71XljAhrhAmtNUfrrjougj9bG8WEUrHSIlNG JeFwGZZuCGNIGcdoir96YHEHf9LV6KgKJuZ2YksAFlYtUM47uycjk+CVVhCV5XnWwITF dV4kq7zxp9GfhuAVnGG3/hZSPMsDzqdJA7ANM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702923186; x=1703527986; 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=mUwABtraKUQVk1+KNd+OixqPQgpIFoZLK6tAOpcjy5Y=; b=w3RD4HKW8E/l7KITrH0cpDVNSREFqfgqinVlQ2qPXMugsnjLbZrlox+h0LNl1NX7v7 yFkVGmjbOUYWm3MEM2X1ljacHe0GtanjrONc5ST111HAiV2qczQzmYj+RySUIe3rHPgE d9N3fHWG3ekASzVyAsSQg9Cpf4m2KqhEyGOYB7SLxfWgUOKTUzjM7mSAA4KTcC4UY6mR jJb7wECtN/YKjqvfWWCctxRXzFIiwJdZ1yg13874EeeeOpog8YE8NYCG+Cn8cwwlmXP1 JuKLwG93U3RAR34E/E7ZAY5BFQgQYkRyEswMqtDzdVgiqvdr33u90TEo9nnBi/5Fc7fC cVig== X-Gm-Message-State: AOJu0YzM7CP8N2X/Jflrg6rXkpd0OTRJdXl9nfo6rGVv8mvQFjweSUCr CowNOdkx/JiZZnZpPwqbGhZkS84IzsVD+ifrJWUTdGJxFeWjf4Ky1MwbEe/+1n686w== X-Google-Smtp-Source: AGHT+IG5sxhF/yxEPQ3QJNhF16QIRsUdDLyI274RNf6XnIe4fyHykkNZj1uLuojynqcidaRV9H+YKfwYE1yE X-Received: by 2002:a17:903:2793:b0:1d3:92db:24fa with SMTP id jw19-20020a170903279300b001d392db24famr5597711plb.1.1702923186085; Mon, 18 Dec 2023 10:13:06 -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 jh7-20020a170903328700b001d3ab452162sm106005plb.113.2023.12.18.10.13.05 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Dec 2023 10:13:06 -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 A04EC605C311; Mon, 18 Dec 2023 13:13:04 -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, ferruh.yigit@amd.com, andrew.rybchenko@oktetlabs.ru Cc: dev@dpdk.org, Jeremy Spewock Subject: [PATCH v4 6/7] dts: add scatter to the yaml schema Date: Mon, 18 Dec 2023 13:12:20 -0500 Message-ID: <20231218181221.10057-7-jspewock@iol.unh.edu> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231218181221.10057-1-jspewock@iol.unh.edu> References: <20231218181221.10057-1-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 Allow for scatter to be specified in the configuration file. Signed-off-by: Jeremy Spewock Reviewed-by: Juraj Linkeš --- dts/framework/config/conf_yaml_schema.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dts/framework/config/conf_yaml_schema.json b/dts/framework/config/conf_yaml_schema.json index 84e45fe3c2..e6dc50ca7f 100644 --- a/dts/framework/config/conf_yaml_schema.json +++ b/dts/framework/config/conf_yaml_schema.json @@ -186,7 +186,8 @@ "type": "string", "enum": [ "hello_world", - "os_udp" + "os_udp", + "pmd_buffer_scatter" ] }, "test_target": { From patchwork Mon Dec 18 18:12:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Spewock X-Patchwork-Id: 135301 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 230634373D; Mon, 18 Dec 2023 19:13:57 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6CA2742DE4; Mon, 18 Dec 2023 19:13:11 +0100 (CET) Received: from mail-pj1-f99.google.com (mail-pj1-f99.google.com [209.85.216.99]) by mails.dpdk.org (Postfix) with ESMTP id 7F3A942DBD for ; Mon, 18 Dec 2023 19:13:07 +0100 (CET) Received: by mail-pj1-f99.google.com with SMTP id 98e67ed59e1d1-28ba05b28adso559405a91.3 for ; Mon, 18 Dec 2023 10:13:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iol.unh.edu; s=unh-iol; t=1702923187; x=1703527987; 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=pevtUiibpYkj+q7d6fx0I7sMOIG/sZC5tn+zdVPUPY8=; b=hRQRnHmXbXcxe+xWqfuEhJV0Dq2fjnj7YLTFZPCvuJmX0VgdhNBhsbrFJAxnY9db0G acURakP0aHTICYRxR+TU0LCoQn3Rf3hlQyrg2PqIBgmEO0Ir7+974QzKj5phoYh2SKTn 1vSlNUBzF4mz4/R19N/xAIH+HQwEEH1l5xkLs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702923187; x=1703527987; 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=pevtUiibpYkj+q7d6fx0I7sMOIG/sZC5tn+zdVPUPY8=; b=bgxSJO7gCl2+m9ZGOW5iulfGnUExO2YCuVriLLfeKT7Ng3flkZrMSovVw4kniYIJ/a d4OUjvS7vM2Jt2O5KwqJnjK+QEdareLyZ3A+MqHcfS8wGIjX0tbjPhV9nJzBd8D9JwGn fgzXasuo6uRcOBsJoLLayOxSLaSAb4YnyALcYDMgHJ9mbH/gXpizN1BJYbAEniopKUCu Z4f/qmF442PVy30nc1a2UUV9YYzQi3K6bxLoTxAFyEFzIbNSLxeGKzz6fObnRSChXGAt Mk+F5nLAKiTq+kWwnKohXRdPFCCI5GT+dZj5UJYUlmzM4G9qXKxRsS+0kYznQSzyhHJ2 2SCA== X-Gm-Message-State: AOJu0YzVodF1vWevMDXglRuqAXXQ4O2k73SCdkVeBfUJL2jOc7au487l /H4dHdXYIknBizvc2FuJSwGmX0V39JAsQ0Dl6Y86YxPKLgS3NQ== X-Google-Smtp-Source: AGHT+IH8iJL0wGbutiWnVJkQnhaC23DFtkmzYG2QppjU9+97qa7wA+ZHuSSM9vUV59thqtPyCR2vzDUnyDEX X-Received: by 2002:a17:90b:354b:b0:28b:8e37:4e62 with SMTP id lt11-20020a17090b354b00b0028b8e374e62mr832983pjb.10.1702923186678; Mon, 18 Dec 2023 10:13:06 -0800 (PST) Received: from postal.iol.unh.edu (postal.iol.unh.edu. [132.177.123.84]) by smtp-relay.gmail.com with ESMTPS id oe4-20020a17090b394400b0028b736f8790sm264665pjb.4.2023.12.18.10.13.06 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Dec 2023 10:13:06 -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 A4885605C312; Mon, 18 Dec 2023 13:13:05 -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, ferruh.yigit@amd.com, andrew.rybchenko@oktetlabs.ru Cc: dev@dpdk.org, Jeremy Spewock Subject: [PATCH v4 7/7] dts: add scatter test suite Date: Mon, 18 Dec 2023 13:12:21 -0500 Message-ID: <20231218181221.10057-8-jspewock@iol.unh.edu> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231218181221.10057-1-jspewock@iol.unh.edu> References: <20231218181221.10057-1-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 This test suite provides testing the support of scattered packets by Poll Mode Drivers using testpmd. It incorporates 5 different test cases which test the sending and receiving of packets with lengths that are less than the mbuf data buffer size, the same as the mbuf data buffer size, and the mbuf data buffer size plus 1, 4, and 5. The goal of this test suite is to align with the existing dts test plan for scattered packets within DTS. Signed-off-by: Jeremy Spewock --- dts/tests/TestSuite_pmd_buffer_scatter.py | 105 ++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 dts/tests/TestSuite_pmd_buffer_scatter.py diff --git a/dts/tests/TestSuite_pmd_buffer_scatter.py b/dts/tests/TestSuite_pmd_buffer_scatter.py new file mode 100644 index 0000000000..8e2a32a1aa --- /dev/null +++ b/dts/tests/TestSuite_pmd_buffer_scatter.py @@ -0,0 +1,105 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2023 University of New Hampshire + +"""Multi-segment packet scattering testing suite. + +Configure the Rx queues to have mbuf data buffers whose sizes are smaller than the maximum packet +size (currently set to 2048 to fit a full 1512-byte ethernet frame) and send a total of 5 packets +with lengths less than, equal to, and greater than the mbuf size (CRC included). +""" +import struct + +from scapy.layers.inet import IP # type: ignore[import] +from scapy.layers.l2 import Ether # type: ignore[import] +from scapy.packet import Raw # type: ignore[import] +from scapy.utils import hexstr # type: ignore[import] + +from framework.remote_session.remote.testpmd_shell import ( + TestPmdForwardingModes, + TestPmdShell, +) +from framework.test_suite import TestSuite + + +class PmdBufferScatter(TestSuite): + """DPDK packet scattering test suite. + + Attributes: + mbsize: The size to se the mbuf to be. + """ + + mbsize: int + + def set_up_suite(self) -> None: + self.verify( + len(self._port_links) > 1, + "Must have at least two port links to run scatter", + ) + + self.tg_node.main_session.configure_port_mtu(9000, self._tg_port_egress) + self.tg_node.main_session.configure_port_mtu(9000, self._tg_port_ingress) + + def scatter_pktgen_send_packet(self, pktsize: int) -> str: + """Generate and send packet to the SUT. + + Functional test for scatter packets. + + Args: + pktsize: Size of the packet to generate and send. + """ + packet = Ether() / IP() / Raw() + packet.getlayer(2).load = "" + payload_len = pktsize - len(packet) - 4 + payload = ["58"] * payload_len + # pack the payload + for X_in_hex in payload: + packet.load += struct.pack("=B", int("%s%s" % (X_in_hex[0], X_in_hex[1]), 16)) + load = hexstr(packet.getlayer(2), onlyhex=1) + received_packets = self.send_packet_and_capture(packet) + self.verify(len(received_packets) > 0, "Did not receive any packets.") + load = hexstr(received_packets[0].getlayer(2), onlyhex=1) + + return load + + def pmd_scatter(self) -> None: + """Testpmd support of receiving and sending scattered multi-segment packets. + + Support for scattered packets is shown by sending 5 packets of differing length + where the length of the packet is calculated by taking mbuf-size + an offset. The + offsets used in the test case are -1, 0, 1, 4, 5 respectively. + + Test: + Start testpmd and run functional test with preset mbsize. + """ + testpmd = self.sut_node.create_interactive_shell( + TestPmdShell, + app_parameters=( + "--mbcache=200 " + f"--mbuf-size={self.mbsize} " + "--max-pkt-len=9000 " + "--port-topology=paired " + "--tx-offloads=0x00008000" + ), + privileged=True, + ) + testpmd.set_forward_mode(TestPmdForwardingModes.mac) + testpmd.start() + link_is_up = testpmd.wait_link_status_up(0) and testpmd.wait_link_status_up(1) + self.verify(link_is_up, "Links never came up in TestPMD.") + + for offset in [-1, 0, 1, 4, 5]: + recv_payload = self.scatter_pktgen_send_packet(self.mbsize + offset) + self.verify( + ("58 " * 8).strip() in recv_payload, + "Received packet had incorrect payload", + ) + testpmd.stop() + + def test_scatter_mbuf_2048(self) -> None: + """Run :func:`~PmdBufferScatter.pmd_scatter` function after setting the `mbsize` to 2048.""" + self.mbsize = 2048 + self.pmd_scatter() + + def tear_down_suite(self) -> None: + self.tg_node.main_session.configure_port_mtu(1500, self._tg_port_egress) + self.tg_node.main_session.configure_port_mtu(1500, self._tg_port_ingress)