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 37B3B45E33; Wed, 4 Dec 2024 23:21:53 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0B1BD410F1; Wed, 4 Dec 2024 23:21:50 +0100 (CET) Received: from mail-qv1-f44.google.com (mail-qv1-f44.google.com [209.85.219.44]) by mails.dpdk.org (Postfix) with ESMTP id AD63B410E8 for ; Wed, 4 Dec 2024 23:21:48 +0100 (CET) Received: by mail-qv1-f44.google.com with SMTP id 6a1803df08f44-6d896be3992so2109986d6.1 for ; Wed, 04 Dec 2024 14:21:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iol.unh.edu; s=unh-iol; t=1733350908; x=1733955708; 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=4oPatsAQGBMi+/dMM/WQ4BMbJShgXFJyvsn1+BSwpkM=; b=C4RDp8wRd1WQArLQdv7LF1Y4eaev+RNbhukRD+p7HaI9ajn66M+gat8y86wp6Lu370 3JS1Nicg1b1fcVNh55Ke9jy96lJPSV/Vg0Ng86PW1yPEZ/LU2lM2+GivpqyJliv7zOMB jq0JE5VA2DgHRXvFVUv7zxXqzuNcr9bltic5E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733350908; x=1733955708; 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=4oPatsAQGBMi+/dMM/WQ4BMbJShgXFJyvsn1+BSwpkM=; b=ut3KTf3cS8bprU+rUQhbMi8g40gV9Q8xf8H4T7Lm2/6MVXdJr5gIoWv1z6auFUmiKz u+DME8xPHSDcjW7cnkJYzhBl154If1iXWioPh7X8dfasI+6WYsUpQfxdW0As8ShbjNdv 6Xf4ak8cfFNS0yjgI76Ddi42pjTktG7Z6S8IYrKNQnm/nac987+wVPBaA4f9TVChzO7j Jh64m1+IcDLjzvy0O+6ZOSMFRXUo7RCo8VIg7OXdC584loY6iNAHk1HW3Pr47Cww66Yd ZpFDZs+1mvGcK9i0xyUOVxhMD+MHowPb4edLd2izyote/Xpkj3M/jOcrkYej1QEclX+4 Nizg== X-Gm-Message-State: AOJu0Yy3lbwgi4zy4Yj9Pa6iQb4Pdta1Uu6WgmhwVld/RnvOOtWbWK04 w/oTzhk6JCpM8kbE8Nxnw/uBJlL7hvRvoZe0JL1gT68FB/HoONn9COCehRABpYU= X-Gm-Gg: ASbGncs6g/NJdRpeHedn5Tl29BvmoSIwLTqIdyQmSoeiOXm0f4FTFJkgbdnR4PfdZbP crmzfl43zdM5aHqD23kePu7sG3gpJTIDXl5qZXQwpsRzOFqA7Qr5KVuiY71LiHtGllviY6avbWD BHccLehtzOCViE6YrYNhCQCVk0exoWT4pTenIi+rFvldeUbcAvV+Z+wk3XvH/QVN7zysowMtxAW WC++ZWa8P/BZMD1KYJLLrPJmpAnhtGDZqg1366LdQGL2nBfzPZ0azLVQSX3pYY4YvuuXIT9jHlk Ec1jrDmC X-Google-Smtp-Source: AGHT+IEkXwEa3Yc+NLx+18L/wADyuiHXWU2ji2wb+o3zpaMjxTta1r3ESN3G8D29uHHmVVD5Atjm/A== X-Received: by 2002:a05:6214:2405:b0:6d8:9e16:d08e with SMTP id 6a1803df08f44-6d8b73b78f5mr155616976d6.26.1733350907924; Wed, 04 Dec 2024 14:21:47 -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.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Dec 2024 14:21:47 -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 2/2] dts: add flow create/delete to testpmd shell Date: Wed, 4 Dec 2024 18:22:46 -0500 Message-ID: <20241204232246.30339-2-dmarx@iol.unh.edu> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20241204232246.30339-1-dmarx@iol.unh.edu> References: <20241010210631.705-1-dmarx@iol.unh.edu> <20241204232246.30339-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 flow create/delete methods to TestPmdShell class for initializing flow rules. Signed-off-by: Dean Marx --- dts/framework/remote_session/testpmd_shell.py | 59 ++++++++++++++++++- 1 file changed, 58 insertions(+), 1 deletion(-) diff --git a/dts/framework/remote_session/testpmd_shell.py b/dts/framework/remote_session/testpmd_shell.py index 177fcf2e81..bdb0e760b9 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, Literal, 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 @@ -1878,6 +1886,55 @@ def csum_set_hw( {port_id}:\n{csum_output}""" ) + def flow_create(self, flow_rule: FlowRule, port_id: int, verify: bool = True) -> int: + """Creates a flow rule in the testpmd session. + + Args: + flow_rule: :class:`FlowRule` object used for creating testpmd flow rule. + verify: If :data:`True`, the output of the command is scanned + to ensure the flow rule was created successfully. + + Raises: + InteractiveCommandExecutionError: If flow rule is invalid. + + Returns: + Id of created flow rule as an integer. + """ + flow_output = self.send_command(f"flow create {port_id} {flow_rule}") + if verify: + if "created" not in flow_output: + self._logger.debug(f"Failed to create flow rule:\n{flow_output}") + raise InteractiveCommandExecutionError( + f"Failed to create flow rule:\n{flow_output}" + ) + match = re.search(r"#(\d+)", flow_output) + if match is not None: + match_str = match.group(1) + flow_id = int(match_str) + return flow_id + else: + self._logger.debug(f"Failed to create flow rule:\n{flow_output}") + raise InteractiveCommandExecutionError(f"Failed to create flow rule:\n{flow_output}") + + def flow_delete(self, flow_id: int, port_id: int, verify: bool = True) -> None: + """Deletes the specified flow rule from the testpmd session. + + Args: + flow_id: :class:`FlowRule` id used for deleting testpmd flow rule. + verify: If :data:`True`, the output of the command is scanned + to ensure the flow rule was deleted successfully. + + Raises: + InteractiveCommandExectuionError: If flow rule is invalid. + """ + flow_output = self.send_command(f"flow destroy {port_id} rule {flow_id}") + if verify: + if "destroyed" not in flow_output: + self._logger.debug(f"Failed to delete flow rule:\n{flow_output}") + raise InteractiveCommandExecutionError( + f"Failed to delete flow rule:\n{flow_output}" + ) + @requires_stopped_ports def set_port_mtu(self, port_id: int, mtu: int, verify: bool = True) -> None: """Change the MTU of a port using testpmd. -- 2.44.0