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 63F12458F4; Tue, 3 Sep 2024 21:47:41 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C507341148; Tue, 3 Sep 2024 21:47:26 +0200 (CEST) Received: from mail-il1-f228.google.com (mail-il1-f228.google.com [209.85.166.228]) by mails.dpdk.org (Postfix) with ESMTP id 3F1F7410F1 for ; Tue, 3 Sep 2024 21:47:24 +0200 (CEST) Received: by mail-il1-f228.google.com with SMTP id e9e14a558f8ab-39f4ec52c5fso13741205ab.2 for ; Tue, 03 Sep 2024 12:47:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iol.unh.edu; s=unh-iol; t=1725392843; x=1725997643; 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=YCUMYDQj1AHeCuQWEQbgc8rLUZNamzndptquhhcUAGY=; b=WTiCOtvpCa0ezy91mhqmKdW79jyRuhCW08incXoI+AhEHc5rFdSiZ1XfFUaxHxZgKf dFlsqgr0TmhnnvKfRTUXBztH8sL384w7Mpc7LvSiHiQsSvIb6HblJjBK26N9DP8aK9TF IdfvY9cdweL/jk1pNSXvbUZRv5rUv1uBZk984= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725392843; x=1725997643; 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=YCUMYDQj1AHeCuQWEQbgc8rLUZNamzndptquhhcUAGY=; b=Sm+slNac3y7JgGdYeQ7gN9+ux4IE7zoa/ReM678O2Bg3fo6a1kHYKIHCOQSjZU0HsQ S/GnO9+1XSGWjfZMJG6qQQTVCFZk+dJlkPM3ICXWsSBC+eiJPGIkDEpAavxEmDVQnBaV AXnX/zzPnm/cRCaRq6uEX45I9JjB5n3fachpY9EDT097eb1fzbvgFQkyEK2fgWRBAlgR a1rUNzlkx+MltKnM6mAdfzJ+JIkS3F7O5d4yi4DvUHxY4IETIxlM5qCd/r4xppA5OhFr uQ93OtouGHsQFQbiE1+avX/+m085TehYJ/J9o/yynZD/jjVgjPCBDtBrSvS+RX5oH01S Vl0Q== X-Gm-Message-State: AOJu0YxLOf97GJlWN3AYooAEVCJBAsFmnEjTMsriH18xF1YnNwbL3bgj 0JFadlSjUii2TO/siR0m1lrCN4S2JY+e+rABEWnMIUsWrjhgXq3kq8cFoi8+ROneW0T1zcS125W VbsWn8Xwrkfd87pat860wJj7d5Y1gQaaZ X-Google-Smtp-Source: AGHT+IGvzfpadbD72OvJRlJzrXTkepaiAbDOURHv5OkeLaov4tfnDvVN/ZuA1AYYDW4yeJIcvH+vicbspFg1 X-Received: by 2002:a05:6e02:2145:b0:397:351b:2c0c with SMTP id e9e14a558f8ab-39f4f6c1792mr113832895ab.17.1725392843494; Tue, 03 Sep 2024 12:47:23 -0700 (PDT) Received: from postal.iol.unh.edu (postal.iol.unh.edu. [132.177.123.84]) by smtp-relay.gmail.com with ESMTPS id e9e14a558f8ab-39f3b0787c2sm4477085ab.62.2024.09.03.12.47.23 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 Sep 2024 12:47:23 -0700 (PDT) X-Relaying-Domain: iol.unh.edu Received: from iol.unh.edu (unknown [IPv6:2606:4100:3880:1257::1083]) by postal.iol.unh.edu (Postfix) with ESMTP id 60288605C381; Tue, 3 Sep 2024 15:47:22 -0400 (EDT) From: jspewock@iol.unh.edu To: yoan.picchi@foss.arm.com, npratte@iol.unh.edu, juraj.linkes@pantheon.tech, probb@iol.unh.edu, thomas@monjalon.net, paul.szczepanek@arm.com, wathsala.vithanage@arm.com, alex.chapman@arm.com, Luca.Vizzarro@arm.com, Honnappa.Nagarahalli@arm.com Cc: dev@dpdk.org, Jeremy Spewock Subject: [PATCH v2 4/5] dts: add methods for configuring offloads on a device in testpmd Date: Tue, 3 Sep 2024 15:46:27 -0400 Message-ID: <20240903194642.24458-5-jspewock@iol.unh.edu> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240903194642.24458-1-jspewock@iol.unh.edu> References: <20240831000058.23009-1-jspewock@iol.unh.edu> <20240903194642.24458-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 Testpmd offers methods to add and remove offloads from both ports and queues on ports, but there are not yet method bindings in the Testpmd API that the framework provides to reach them. This patch adds these bindings for future test cases/suites that require certain functionalities to be offloaded on the device. Signed-off-by: Jeremy Spewock --- dts/framework/remote_session/testpmd_shell.py | 142 +++++++++++++++++- 1 file changed, 141 insertions(+), 1 deletion(-) diff --git a/dts/framework/remote_session/testpmd_shell.py b/dts/framework/remote_session/testpmd_shell.py index 71859c63da..447d6a617d 100644 --- a/dts/framework/remote_session/testpmd_shell.py +++ b/dts/framework/remote_session/testpmd_shell.py @@ -32,7 +32,7 @@ from typing_extensions import TypeVarTuple -from framework.exception import InteractiveCommandExecutionError +from framework.exception import InteractiveCommandExecutionError, InternalError from framework.params.testpmd import SimpleForwardingModes, TestPmdParams from framework.params.types import TestPmdParamsDict from framework.parser import ParserFn, TextParser @@ -2002,6 +2002,146 @@ def set_verbose(self, level: int, verify: bool = True) -> None: f"Testpmd failed to set verbose level to {level}." ) + @stop_then_start_port() + def _set_offload( + self, + port_id: int, + is_rx: bool, + offloads: OffloadCapability, + on: bool, + queue_id: int | None = None, + verify: bool = True, + ) -> None: + """Base method for configuring offloads on ports and queues. + + If `queue_id` is not specified then it is assumed that you want to set the offloads on the + port rather than a queue. + """ + for offload in type(offloads): + if offload not in offloads or offload.name is None: + continue + port_type = "rx" if is_rx else "tx" + command = [ + "port", + f"{port_id}", + f"{port_type}_offload", + f"{offload.name.lower()}", + f"{'on' if on else 'off'}", + ] + if queue_id is not None: + # If modifying queues the command is "port rxq ..." + command.insert(2, f"{port_type}q {queue_id}") + else: + # If modifying a port the command is "port config ..." + command.insert(1, "config") + + self.send_command(" ".join(command)) + if verify: + # verification of ports has to be done based on if it was applied to all queues or + # not because the "Per Port" line doesn't get modified until the port is started. + current_offload_conf: OffloadConfiguration = ( + self.show_port_rx_offload_configuration(port_id) + if is_rx + else self.show_port_tx_offload_configuration(port_id) + ) + # Casting to the generic type is required for mypy + queues_capabilities = cast(list[OffloadCapability], current_offload_conf.queues) + if queue_id is not None and len(current_offload_conf.queues) < queue_id + 1: + raise InternalError(f"Queue {queue_id} does not exist in testpmd") + capability_is_set = ( + len(current_offload_conf.queues) > 0 + and (queue_id is not None and offload in queues_capabilities[queue_id]) + or all(offload in conf for conf in queues_capabilities) + ) + if capability_is_set != on: + self._logger.debug( + f"Test pmd failed to modify capabilities on port {port_id}:\n" + f"{current_offload_conf.queues}" + ) + raise InteractiveCommandExecutionError( + f"Test pmd failed to {'add' if on else 'remove'} capability {offload.name} " + f"{'to' if on else 'from'} port {port_id}." + ) + + def set_port_offload( + self, + port_id: int, + is_rx: bool, + offload: OffloadCapability, + on: bool, + verify: bool = True, + ) -> None: + """Configure Rx/Tx offload on a port. + + Args: + port_id: The ID of the port to set configure the offload on. + is_rx: A flag that signifies which type of offload to set. If :data:`True` an Rx + offload will be set, otherwise a Tx offload will be set. + offload: The offload to set on the port. + on: If :data:`True` the specified offload will be set turned on, otherwise the offload + will be turned off. + verify: If :data:`True` an additional command will be sent to check the configuration + of offloads on the port to verify `offload` was set properly. Defaults to + :data:`True`. + + Raises: + InteractiveCommandExecutionError: If `verify` is :data:`True` and testpmd failed to + set the offload on the port. + """ + self._set_offload(port_id, is_rx, offload, on, None, verify) + + def set_queue_offload( + self, + port_id: int, + queue_id: int, + is_rx: bool, + offload: OffloadCapability, + on: bool, + verify: bool = True, + ) -> None: + """Configure Rx/Tx offload on a queue that resides on a specified port. + + Args: + port_id: The ID of the port where the queue resides. + queue_id: The ID of the queue on the port. + is_rx: A flag that signifies which type of offload to set. If :data:`True` an Rx + offload will be set, otherwise a Tx offload will be set. + offload: The offload to set on a port. + on: If :data:`True` the offload will be turned on, otherwise the offload will be turned + off. + verify: If :data:`True` an additional command will be sent to check the configuration + of the queue to validate that the offload was configured properly. Defaults to + :data:`True`. + + Raises: + InteractiveCommandExecutionError: If `verify` is :data:`True` and testpmd failed to + set the offload on the queue. + """ + self._set_offload(port_id, is_rx, offload, on, queue_id, verify) + + def is_port_offload_configured( + self, port_id: int, is_rx: bool, offload: OffloadCapability + ) -> bool: + """Verify whether or not an Rx/Tx offload is currently configured on a port. + + Args: + port_id: The ID of the port to check the configuration of. + is_rx: If :data:`True` the Rx offloads of the port will be checked, otherwise the Tx + offloads will be checked. + offload: The offload to search for on the port. + + Returns: + :data:`True` if the offload is configured on the port, :data:`False` otherwise. + """ + offload_config: OffloadConfiguration = ( + self.show_port_rx_offload_configuration(port_id) + if is_rx + else self.show_port_tx_offload_configuration(port_id) + ) + # Cast to the generic type for mypy + port_capabilities = cast(OffloadCapability, offload_config.port) + return offload in port_capabilities + def flow_create(self, cmd: FlowRule, verify: bool = True) -> None: """Creates a flow rule in the testpmd session. -- 2.46.0