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 F0CC2458F4; Tue, 3 Sep 2024 21:47:29 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 030C041109; Tue, 3 Sep 2024 21:47:25 +0200 (CEST) Received: from mail-oa1-f98.google.com (mail-oa1-f98.google.com [209.85.160.98]) by mails.dpdk.org (Postfix) with ESMTP id 5260C41104 for ; Tue, 3 Sep 2024 21:47:23 +0200 (CEST) Received: by mail-oa1-f98.google.com with SMTP id 586e51a60fabf-277e6be2ef6so1371836fac.0 for ; Tue, 03 Sep 2024 12:47:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iol.unh.edu; s=unh-iol; t=1725392842; x=1725997642; 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=fOxSaaN8pkSFtnECdzM/kjwL3ccA7MJgQ6hCr9W45tg=; b=OreT63vT+PuUaNf5RXqVqlNij7Fr+R0z7MXH+6x2MdiPXgIDlITzWVpMqc4Tl5OJRn KkThq2ud+HzDxqk3qfvk1k6Su0j8xWrij6jpaHbMtJHEi8hQhpcdhP6l/58yD7/FJ4OQ JFrGY+F8/oXa/LvpSVcETJLTUfM9lj3OQM6vA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725392842; x=1725997642; 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=fOxSaaN8pkSFtnECdzM/kjwL3ccA7MJgQ6hCr9W45tg=; b=XrZ6Z/xfMT/ZzJc8l9wLX0il7lG3qaO84RYDnVMP41Mi1XJ6LUBHxOjGw46gNOdjPI ZSjFmofBQgAGJEvb7OvqDlIMfZ0/nxYeXzvpB+qtEwaiP0WP+cYt0JApcAuhfvuO4DdW 98jsSTGCQtAM3W0m7TW+QcGG2Ny46TWNLzKKK4dxPadFaVqO48lolitdqsBL+IHB5Vft lafJS96OjX3bLTefBRIvMr4i+gY4ZL57v+tfE95NNQQ5UjiqvZglIFa/yjcLHc2PZm2P xY2PFWWdW9AMIKMflJZ8NAb2WiaMoZmHtyGPtmU0SoVr49H1E9+eQC6ppTUAVCl3x9ZT 52Ug== X-Gm-Message-State: AOJu0YzQl6Ns+ICC2GnAkBNcddxsnm1bp6BASRLn4sW4tDpVTbnBHGGZ TWvb4KxXM+kKcTZPFYHNvYp5oRuX4+jTgE2+SQWYr2GUDePRnscKhNXGVGAe4aLwLABWqQdfUWj y3aQhzoYzmHD5VQT1N79FmoQjWIeerUyEDeroY9E+Vasyl4+E X-Google-Smtp-Source: AGHT+IG6e3QzaKb4NfUgvkNUY9BYM9D+9tIZZZ1VnRzLdPBlbVaH+maQJSAzX7DUw8DbSVlfro3i6SGLTbRt X-Received: by 2002:a05:6870:158f:b0:270:25e:b341 with SMTP id 586e51a60fabf-2780050e057mr7618619fac.36.1725392842328; Tue, 03 Sep 2024 12:47:22 -0700 (PDT) Received: from postal.iol.unh.edu (postal.iol.unh.edu. [2606:4100:3880:1234::84]) by smtp-relay.gmail.com with ESMTPS id 586e51a60fabf-277abd199f7sm351366fac.36.2024.09.03.12.47.22 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 Sep 2024 12:47:22 -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 47C40605C380; Tue, 3 Sep 2024 15:47:21 -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 3/5] dts: add offload configuration querying to testpmd Date: Tue, 3 Sep 2024 15:46:26 -0400 Message-ID: <20240903194642.24458-4-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 for querying the runtime configuration of offloads on a device that are useful for verification, but bindings to reach these methods do not exist in the Testpmd API offered in the framework. This patch creates methods that can query this configuration and also generalizes the OffloadCapability class to allow it to account for parsing the configuration output as well since the flag values will be the same. Signed-off-by: Jeremy Spewock --- dts/framework/remote_session/testpmd_shell.py | 92 ++++++++++++++++++- 1 file changed, 89 insertions(+), 3 deletions(-) diff --git a/dts/framework/remote_session/testpmd_shell.py b/dts/framework/remote_session/testpmd_shell.py index df4ed7ce5c..71859c63da 100644 --- a/dts/framework/remote_session/testpmd_shell.py +++ b/dts/framework/remote_session/testpmd_shell.py @@ -680,21 +680,45 @@ def from_string(cls, line: str) -> Self: return flag @classmethod - def make_parser(cls, per_port: bool) -> ParserFn: + def from_list(cls, lines: list[str]) -> list[Self]: + """Make a list of instances from a list of strings that contain flag names. + + The strings are expected to separate the flag names by whitespace. + + Args: + lines: The list of strings to parse. + + Returns: + A list of instances parsed from each string in `lines`. + """ + return [cls.from_string(line) for line in lines] + + @classmethod + def make_parser(cls, per_port: bool, find_multiple: bool = False) -> ParserFn: """Make a parser function. Args: per_port: If :data:`True`, will return capabilities per port. If :data:`False`, will return capabilities per queue. + find_multiple: If :data:`True`, will use :func:`TextParser.find_all` to find all + matches for the regex query and return a list of instances based on those matches. + If :data:`False`, will return a single instance of the flag based off a single + match. Returns: ParserFn: A dictionary for the `dataclasses.field` metadata argument containing a parser function that makes an instance of this flag from text. """ granularity = "Port" if per_port else "Queue" + parser_func: Callable[..., ParserFn] | Callable[..., ParserFn] = ( + TextParser.find_all if find_multiple else TextParser.find + ) + instance_func: Callable[..., list[OffloadCapability]] | Callable[..., OffloadCapability] = ( + cls.from_list if find_multiple else cls.from_string + ) return TextParser.wrap( - TextParser.find(rf"Per {granularity}\s+:(.*)$", re.MULTILINE), - cls.from_string, + parser_func(rf"{granularity}[\s\[\]\d]+:(.*)$", re.MULTILINE), + instance_func, ) @@ -822,6 +846,42 @@ class TxOffloadCapabilities(OffloadCapabilities): per_port: TxOffloadCapability = field(metadata=TxOffloadCapability.make_parser(True)) +@dataclass +class OffloadConfiguration(TextParser): + """The result of testpmd's ``show port rx/tx_offload configuration`` command.""" + + #: + port_id: int = field(metadata=TextParser.find_int(r"Offloading Configuration of port (\d+) :")) + #: Queue offload configurations. + queues: list[RxOffloadCapability] | list[TxOffloadCapability] + #: Port offload configuration. + port: RxOffloadCapability | TxOffloadCapability + + +@dataclass +class RxOffloadConfiguration(OffloadConfiguration): + """Extends :class:`OffloadingConfiguration` with Rx specific functionality.""" + + #: + queues: list[RxOffloadCapability] = field( + metadata=RxOffloadCapability.make_parser(False, find_multiple=True) + ) + #: + port: RxOffloadCapability = field(metadata=RxOffloadCapability.make_parser(True)) + + +@dataclass +class TxOffloadConfiguration(OffloadConfiguration): + """Extends :class:`OffloadingConfiguration` with Tx specific functionality.""" + + #: + queues: list[TxOffloadCapability] = field( + metadata=TxOffloadCapability.make_parser(False, find_multiple=True) + ) + #: + port: TxOffloadCapability = field(metadata=TxOffloadCapability.make_parser(True)) + + T = TypeVarTuple("T") # type: ignore[misc] @@ -1590,6 +1650,32 @@ def show_port_tx_offload_capabilities(self, port_id: int) -> TxOffloadCapabiliti offload_capabilities_out = self.send_command(command) return TxOffloadCapabilities.parse(offload_capabilities_out) + def show_port_rx_offload_configuration(self, port_id: int) -> RxOffloadConfiguration: + """Get the Rx offload configuration on a given port. + + Args: + port_id: The ID of the port to query the configuration of. + + Returns: + An instance of :class:`RxOffloadConfiguration` containing the offload configuration of + the port. + """ + output = self.send_command(f"show port {port_id} rx_offload configuration") + return RxOffloadConfiguration.parse(output) + + def show_port_tx_offload_configuration(self, port_id: int) -> TxOffloadConfiguration: + """Get the Tx offload configuration on a given port. + + Args: + port_id: The ID of the port to query the configuration of. + + Returns: + An instance of :class:`TxOffloadConfiguration` containing the offload configuration of + the port. + """ + output = self.send_command(f"show port {port_id} tx_offload configuration") + return TxOffloadConfiguration.parse(output) + def _stop_port(self, port_id: int, verify: bool = True) -> None: """Stop port with `port_id` in testpmd. -- 2.46.0