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 AA249458AF; Sat, 31 Aug 2024 02:04:23 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B295B42FC1; Sat, 31 Aug 2024 02:04:08 +0200 (CEST) Received: from mail-io1-f98.google.com (mail-io1-f98.google.com [209.85.166.98]) by mails.dpdk.org (Postfix) with ESMTP id 1A16242F8B for ; Sat, 31 Aug 2024 02:04:05 +0200 (CEST) Received: by mail-io1-f98.google.com with SMTP id ca18e2360f4ac-82a151ac935so102738239f.3 for ; Fri, 30 Aug 2024 17:04:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iol.unh.edu; s=unh-iol; t=1725062644; x=1725667444; 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=qWeybgLWz0R8/VX1A1VFgC7QY+bL/R+PipVzKch3lsw=; b=SEbPLBSRQxSIWxVSdKIMqtqkAFe2OFy5ypwHgsT1ZlLMwQ/8rHqa5/O91cKlA0tXVG pnJ9mMtZL5otTkTmLQ5FVLAdRPIEyi3qTXU6yr0wbDDyVrY603jFPvqSSOhzTmPb+yG/ 7/di8GGm1u5oED2NXrpAZCkcl8TXG3rKRAOB8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725062644; x=1725667444; 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=qWeybgLWz0R8/VX1A1VFgC7QY+bL/R+PipVzKch3lsw=; b=sfSa3a7WmPIyJorgONN/s3/QudjcIYmXyMYVOcxtHC4lnterzB4k03JKau0QyfFn6J HvFm++fMNvaaS9Gx4wrvnQGF7TLEEfe3SH1itBtdWrrKdUa4Ug+RkfD+RqpbD7AAsfgx zgW5XtJn2UUujC/2S3SGeElrLEm8Nda38FUWvo6ma6Ra4wxCNuxeiV9QIc2UWFDlZ/Go qPKxxn1WPcLnfu+g/CvAqOkNFVmHdH0YCnEJPBysFD8vi9874gspsr6NCpPjngCovyHh 7LTsRcvbZOZJsS8TTRnLG7HiQ6cbQr3nBkAYlbloH+kDmUO97azeI9+z4YoYiY2PgDl/ vSZQ== X-Gm-Message-State: AOJu0YxprNsql6sPSvxuCRJQr9liXAQFKuVUvZAehwKRDkCsugZdEhsT ROsamyani7EwC0RbrAxajWVeT3JWGz1XWK4b+CLoDa/BelmBtIshx35Bx8ec4eqeQ4RgzO4fEWW vaRPF9sZipnlSYqEQs5Jg9aw+/YMhg9bSHrZJ3MHNz+vnRr2o X-Google-Smtp-Source: AGHT+IF8Q4lCIhTiIwLxQJQJn0IWkVVtfqratahzXJ9OtDLZBy+O9zKJqck5uWyaM0HDIgGUfAaLfaWfUhhZ X-Received: by 2002:a05:6602:6b07:b0:824:d9c0:3fc6 with SMTP id ca18e2360f4ac-82a3730aecfmr37463439f.3.1725062644343; Fri, 30 Aug 2024 17:04:04 -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 8926c6da1cb9f-4ced2e9cebdsm181648173.68.2024.08.30.17.04.04 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Aug 2024 17:04:04 -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 5CB53605C380; Fri, 30 Aug 2024 20:04:03 -0400 (EDT) From: jspewock@iol.unh.edu To: Honnappa.Nagarahalli@arm.com, probb@iol.unh.edu, paul.szczepanek@arm.com, juraj.linkes@pantheon.tech, yoan.picchi@foss.arm.com, npratte@iol.unh.edu, wathsala.vithanage@arm.com, Luca.Vizzarro@arm.com, alex.chapman@arm.com, thomas@monjalon.net Cc: dev@dpdk.org, Jeremy Spewock Subject: [RFC PATCH v1 3/5] dts: add offload configuration querying to testpmd Date: Fri, 30 Aug 2024 20:00:11 -0400 Message-ID: <20240831000058.23009-4-jspewock@iol.unh.edu> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240831000058.23009-1-jspewock@iol.unh.edu> References: <20240831000058.23009-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 | 84 ++++++++++++++++++- 1 file changed, 81 insertions(+), 3 deletions(-) diff --git a/dts/framework/remote_session/testpmd_shell.py b/dts/framework/remote_session/testpmd_shell.py index cfb51e3acb..58b8995d21 100644 --- a/dts/framework/remote_session/testpmd_shell.py +++ b/dts/framework/remote_session/testpmd_shell.py @@ -680,21 +680,41 @@ 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 = TextParser.find_all if find_multiple else TextParser.find + instance_func = 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, ) @@ -824,6 +844,38 @@ 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] @@ -1592,6 +1644,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