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 E507F460D3; Tue, 21 Jan 2025 21:41:29 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 818DD402D8; Tue, 21 Jan 2025 21:41:29 +0100 (CET) Received: from mail-qt1-f178.google.com (mail-qt1-f178.google.com [209.85.160.178]) by mails.dpdk.org (Postfix) with ESMTP id 20B254026C for ; Tue, 21 Jan 2025 21:41:28 +0100 (CET) Received: by mail-qt1-f178.google.com with SMTP id d75a77b69052e-467725245a2so10174021cf.3 for ; Tue, 21 Jan 2025 12:41:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iol.unh.edu; s=unh-iol; t=1737492087; x=1738096887; 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=MtuzrhogmgpWZ/LdbUVbzqJ+/YxrFQrqHkiE2S2HWhA=; b=fjbPTI62n3I5f4G7/KVYVF/fnW4xY9T3V/zffPTsE+C1+aFq3VJBthG8bIIADXcXU9 ub5I5quzow+fx2J0i8+1LHDG2a9CZbrth4dUJd5WCjnT5NjNFCiH43qhqwsJyU/aRM0y WqnXg0NDQIIFS4EGjc/FMXXuA3fTRJoOePqLM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737492087; x=1738096887; 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=MtuzrhogmgpWZ/LdbUVbzqJ+/YxrFQrqHkiE2S2HWhA=; b=JCFmXecBSAWjCHDI5KJe5Zo3a0oZKAlxS2bf0MuiJBYEAw0IxAQ+hqNbEUI82ieAkd k12bantoc+mEmhnxOtpeRuNxYWaHC3QcKqlFR2ic83TE4Ge4Pxl6w2lU0Xbpv+4LsZXF 96EACch9ujcUfKyZQxnRyHIbgt6BJFD4n30pA2GKsvXAmnpQbj2RbrpKU/Q0PoiRInZs IUHlBEI5pD5epqlnwI5VGIleKxg1/I4batC7j+pXn6R60w5Aw2tF8/d6QXjAbo+N+Ggi +CtfQWufjE8EChEza0f+Pii94AH/NWkYFFdwe31olGPbiQSYhU5ziH5tlOXFw9gIOMNu R05w== X-Gm-Message-State: AOJu0YyBTT2gFMlIpjsVM0vL0GY1696SwK6VAo6Mf2EW6Y2shRdfWuTu SXw5BpuflZ1qBGvxxTUMaBnxq52q96mqvA++EXKi5CKT31LutsSVG/yu+6LlyY0= X-Gm-Gg: ASbGncvqJOSQElNUtclk0HF4ZZgEA+xdq2GAdGMAWC7R37IZ51ROnFz7/MeaucGTzms bMCPFxbgm1dUkKjNTVFE7kWEjbi0dvDME5IpYSKj6W9rAo7RL/tR5acn1ZN63Po3EZqohUxylK8 cuAjcyeNuuZQxH0HGF4Pi5g3EaouBUgdFvPILnzT0+sQXGWslLHKRBICpwHGL/ZSsDpuXf7t+1D aRQg91SYUfegqrFtN5qDR8Qm38/N6/YD1B6QcrzxSK8nCLcX1Iw+5Qsg3ZrOxkf2UxWcezAS1wH 4VnDdnXH70owYMqRAzbNp87sKsSjCuSYV+6jC/Mn X-Google-Smtp-Source: AGHT+IHYLQ83as0mew42N80vxm2BFogFsJGfXVwKaWRphUmGI5HclEJL6kmNoyIOwTC+ODCXGmnh5Q== X-Received: by 2002:a05:622a:1a81:b0:467:84df:92ee with SMTP id d75a77b69052e-46e12b76460mr236846111cf.40.1737492087267; Tue, 21 Jan 2025 12:41:27 -0800 (PST) Received: from dean-laptop.iol.unh.edu ([2606:4100:3880:1271:f9bd:24da:464d:6294]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-46e102ec4acsm56504841cf.13.2025.01.21.12.41.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jan 2025 12:41:26 -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 v6 1/2] dts: add flow rule dataclass to testpmd shell Date: Tue, 21 Jan 2025 15:41:34 -0500 Message-ID: <20250121204135.28944-1-dmarx@iol.unh.edu> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20241204232246.30339-2-dmarx@iol.unh.edu> References: <20241204232246.30339-2-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.44.0