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 8ACDE45FE6; Tue, 28 Jan 2025 23:59:07 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3096040275; Tue, 28 Jan 2025 23:59:07 +0100 (CET) Received: from mail-qk1-f169.google.com (mail-qk1-f169.google.com [209.85.222.169]) by mails.dpdk.org (Postfix) with ESMTP id 6F03F40261 for ; Tue, 28 Jan 2025 23:59:05 +0100 (CET) Received: by mail-qk1-f169.google.com with SMTP id af79cd13be357-7b98a2e3b3eso334860185a.2 for ; Tue, 28 Jan 2025 14:59:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iol.unh.edu; s=unh-iol; t=1738105145; x=1738709945; 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=yTMFsAmr5+2VtDCo5U5UA+YIXeb1kY0Sp1xleO90og4=; b=fHq1/C39/+1Nl0Oma8k5N0DfMKyCluaZVAPHTW4GNQa4rD9l1rgbFkTCoiM7KunSoT FdJes5XFEtILG3K4UsC9wCgbi2mCzzJjX2lXpWWhbNqRhIVSZqNdooiw/8v7E3N/UnVE Hfuj8yK6fcci9XMHIZen4f5EwaKyN5s87DSC4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738105145; x=1738709945; 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=yTMFsAmr5+2VtDCo5U5UA+YIXeb1kY0Sp1xleO90og4=; b=TmTp7syUyLV4Fqca1TvNyUaqJL/OxktMDHJErgtOY2xVocVqdHWt0noab8s2BqaIW8 YhoZwZx26wOT/wA2nQCw8iFbQLsN0malWdTbWtdBTauZ4riM8ZsxENKrEYYII9xHQBMT es6j2eb4v1l0iAqYlUm4Dy6q47F25u7CcRtwiYtDN9fHBdYyTTjopFlwBp6KYJhNZOVX +x7HWxhawo7X/wPhKGnbcdxnZTb21ZxI2GEidj8dpUPrp70vL8GS6WGN/5imdVfij1yF YtgOl9Wwj7EHPWTMs96T+V3+JG/T6HyEEMHz0UJdrhmnfA6IXYsIGIaVmolQOmPhuJwF xO2Q== X-Gm-Message-State: AOJu0YywE8d8KLl/8r5NbxDpE6hiWMYgc/w4uKjJoeAxsvRvHUtKLRJZ YTAWnZwtVciSgH49XN8lfKriL5Hd/teSUyhMm47QXwaEzDDeaDdhwmbdegzoulI= X-Gm-Gg: ASbGncv4hgug/2Rqe1yL66NySc4XxT4xc023iZAUOgcETy2YLLPVOpaYmOCrUoSJLeV Q0i8t+Z2y1pg709ef+nN9Gim6Pb9XNGcp0TYnvxtDkx268KwpIVRhLH8F1JjSMiEMi4POE/HJce lfhiApv5s+3gLvT+sL7cTRYsGzbLP74iWzh4sUdbQU/9C12LHHUvAKjMgUzyv93UJAHqDViF4tx aQRUwuY5pMrNHkj9UQhdnYgR7X+PWQqQICRM6mnwioa5cimZyhXnob5i0IPRR+8umN95BDCm6FM 5TfpngWYTwPQsSRukMY+nQPZkb21+7hVsBW8BuRHb9/t+gb8sTSWiJrKwEXMfMBkag== X-Google-Smtp-Source: AGHT+IHOmiSYmF6vPTFF3XZcs8DOMIy4yh69/2dbDdsopRvBNJQ+kXeOe+ypc3PIiLGqHJcKWe4v7Q== X-Received: by 2002:a05:620a:454b:b0:7a9:ad65:f4a1 with SMTP id af79cd13be357-7bffcd0c20amr100100885a.26.1738105144610; Tue, 28 Jan 2025 14:59:04 -0800 (PST) Received: from fedora.iol.unh.edu ([2606:4100:3880:1271:cf73:250f:b43e:342b]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7be9ae7dc98sm559708385a.15.2025.01.28.14.59.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jan 2025 14:59:04 -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 v7 1/2] dts: add flow rule dataclass to testpmd shell Date: Tue, 28 Jan 2025 17:59:01 -0500 Message-ID: <20250128225902.20709-1-dmarx@iol.unh.edu> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250121204135.28944-1-dmarx@iol.unh.edu> References: <20250121204135.28944-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 | 52 ++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/dts/framework/remote_session/testpmd_shell.py b/dts/framework/remote_session/testpmd_shell.py index 72f81e2c99..3e86f52a7e 100644 --- a/dts/framework/remote_session/testpmd_shell.py +++ b/dts/framework/remote_session/testpmd_shell.py @@ -22,7 +22,15 @@ 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 +713,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"] + #: + 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.47.0