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 D494E45E33; Wed, 4 Dec 2024 23:21:47 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BBD1F410E4; Wed, 4 Dec 2024 23:21:47 +0100 (CET) Received: from mail-yb1-f182.google.com (mail-yb1-f182.google.com [209.85.219.182]) by mails.dpdk.org (Postfix) with ESMTP id EBD79410E3 for ; Wed, 4 Dec 2024 23:21:46 +0100 (CET) Received: by mail-yb1-f182.google.com with SMTP id 3f1490d57ef6-e38df4166c7so473657276.0 for ; Wed, 04 Dec 2024 14:21:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iol.unh.edu; s=unh-iol; t=1733350906; x=1733955706; 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=2VvGzhMCxxlnsXXakCsXRh0L0W3mcT4YN6S5/L0Ptv0=; b=LBCNfOtJLWnuuZaB+EMTYKXYucwIQrfizWBM4dSZDtLVEV0IpE4ZnmVTN+Acgxjcqq Sdlit1RTCVlvmHm2IpxhQTh5BCzqnwyRgcfAS/IBCWG2+CribzWQzuUS+xs2gBTmCGlT ZcLtILzZBaaJ6OsgJ42lFIHPbIJ2t9jeF/EI0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733350906; x=1733955706; 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=2VvGzhMCxxlnsXXakCsXRh0L0W3mcT4YN6S5/L0Ptv0=; b=cGNvJtJijb7s9bLHr6zx/odJpVu1R3QZXjn+m1GwXKKgn/LRFJ02dwSrAl/9r95xAU kJ4fV96L/tfnUiEICr7ZDhw3jNDnLcosFt3jhkZbexbxUgETxk7y9vzcxa94NLHbRyYK 9zK+BdspS+WY0Sdg/442Wy5MmkXSZ3mzdQeItUncdcIgFKJHkmrbk+PV4yfzMcQF8ZKL HB0lVIXeM/XZAyszss8BY7z8gf+oqMETQBYg5m6rMtBif26PlYWu7Pr7fycGQsJYvV0Z kQkKNrglv4nYPpq8B7FvoNUU0408zItOVvkAg8F8dXyEY0SerZn7bXMB1mYqq43xR8XN YYiA== X-Gm-Message-State: AOJu0YzJrllloMFlszGgSPqet5WGmSrJCett+mXDww1+DfLUxOvUBWOS ufPD7F0d74Z7Vg2X6NGPlgpnhJ0iW8aaR9mrYdUvMUUM5EgoPV+vhE9P1CXQmk0Jyjnl0qPcsDx o X-Gm-Gg: ASbGncs0BVgoiT4mO4YPTa2vGwHX9jPVD2mLRF3XpmVvKUoOFVQvqf/MxZV7XLR+Tuu geKRUQuGMpJcvsb0G7+7Un1rrQZE43fLOvfvdKD4O8DjvJKWzwnKqYiTXhP0x9BVieG2LPuGZDR ZInAZf2KY5PqGuABntw4adXitAL+RJ1Q5nMIZGfHDwTPfQah7IWxcZCZ0GlH/tdB1NhwqRJIh+U udmpPF8wwjcMLRoDsmvJ4U2JidOrwXt+uC6FqZFmZZwPyPfSol6xOG2e4Hx4+nIYjOEKbNa3Y1O f8C29264 X-Google-Smtp-Source: AGHT+IFEKVnGy9szAv9UgrcSJDZIMc7GKWUdKED4ULadf/LhnEl2j0nNISoWbu/HhUuQngXp46UQiQ== X-Received: by 2002:a05:690c:45c4:b0:6ef:aae1:ac51 with SMTP id 00721157ae682-6efad2e7e5dmr103599247b3.27.1733350906299; Wed, 04 Dec 2024 14:21:46 -0800 (PST) Received: from dean-laptop.iol.unh.edu ([2606:4100:3880:1271:f9bd:24da:464d:6294]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6d89ae5a767sm52333626d6.38.2024.12.04.14.21.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Dec 2024 14:21:45 -0800 (PST) From: Dean Marx To: probb@iol.unh.edu, npratte@iol.unh.edu, luca.vizzarro@arm.com, yoan.picchi@foss.arm.com, Honnappa.Nagarahalli@arm.com, paul.szczepanek@arm.com Cc: dev@dpdk.org, Dean Marx Subject: [PATCH v5 1/2] dts: add flow rule dataclass to testpmd shell Date: Wed, 4 Dec 2024 18:22:45 -0500 Message-ID: <20241204232246.30339-1-dmarx@iol.unh.edu> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20241010210631.705-1-dmarx@iol.unh.edu> References: <20241010210631.705-1-dmarx@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 Add dataclass for passing in flow rule creation arguments, as well as a __str__ method for converting to a sendable testpmd command. Signed-off-by: Dean Marx --- dts/framework/remote_session/testpmd_shell.py | 44 ++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/dts/framework/remote_session/testpmd_shell.py b/dts/framework/remote_session/testpmd_shell.py index d187eaea94..177fcf2e81 100644 --- a/dts/framework/remote_session/testpmd_shell.py +++ b/dts/framework/remote_session/testpmd_shell.py @@ -22,7 +22,7 @@ from enum import Flag, auto from os import environ from pathlib import PurePath -from typing import TYPE_CHECKING, Any, ClassVar, Concatenate, ParamSpec, TypeAlias +from typing import TYPE_CHECKING, Any, ClassVar, Concatenate, Literal, ParamSpec, TypeAlias if TYPE_CHECKING or environ.get("DTS_DOC_BUILD"): from enum import Enum as NoAliasEnum @@ -705,6 +705,48 @@ class TestPmdPortStats(TextParser): tx_bps: int = field(metadata=TextParser.find_int(r"Tx-bps:\s+(\d+)")) +@dataclass(kw_only=True) +class FlowRule: + """Class representation of flow rule parameters. + + This class represents the parameters of any flow rule as per the + following pattern: + + [group {group_id}] [priority {level}] [ingress] [egress] + [user_id {user_id}] pattern {item} [/ {item} [...]] / end + actions {action} [/ {action} [...]] / end + """ + + #: + group_id: int | None = None + #: + priority_level: int | None = None + #: + direction: Literal["ingress", "egress", "both"] + #: + user_id: int | None = None + #: + pattern: list[str] + #: + actions: list[str] + + def __str__(self) -> str: + """Returns the string representation of this instance.""" + ret = "" + pattern = " / ".join(self.pattern) + action = " / ".join(self.actions) + if self.group_id is not None: + ret += f"group {self.group_id} " + if self.priority_level is not None: + ret += f"priority {self.priority_level} " + ret += f"{self.direction} " + if self.user_id is not None: + ret += f"user_id {self.user_id} " + ret += f"pattern {pattern} / end " + ret += f"actions {action} / end" + return ret + + class PacketOffloadFlag(Flag): """Flag representing the Packet Offload Features Flags in DPDK. -- 2.44.0