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 203D145FE6; Tue, 28 Jan 2025 23:59:12 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3B0A2402C9; Tue, 28 Jan 2025 23:59:10 +0100 (CET) Received: from mail-qk1-f177.google.com (mail-qk1-f177.google.com [209.85.222.177]) by mails.dpdk.org (Postfix) with ESMTP id 1D5D540261 for ; Tue, 28 Jan 2025 23:59:07 +0100 (CET) Received: by mail-qk1-f177.google.com with SMTP id af79cd13be357-7b98a2e3b3eso334861585a.2 for ; Tue, 28 Jan 2025 14:59:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iol.unh.edu; s=unh-iol; t=1738105146; x=1738709946; 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=beB7bCfE76ALJHsARwXnCYQSV13uDsOdzge0F5vvC6E=; b=HVJB4WR1FjWpuaEjf3eWfCO6ce5j7pGy9d5TyfVgy8yQ87ibM8gmDucy2X9ZtyxpOC IAsprutR4iDRuMU2QpV9A36laYTUwY6TpqVvQjuOIZ98O/tq6sNvq7+iH0HHkpib+b1c PWHbmfoEX6ApP65GeCmcFGUfEfb0oTChG5+W8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738105146; x=1738709946; 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=beB7bCfE76ALJHsARwXnCYQSV13uDsOdzge0F5vvC6E=; b=m+HnDSHPOwmivynoSyM+TDvUaxqJeuFG6+y7fPByeGBCk30bEzUfXDOi0oV9gvaein BqzSpNMhDDGFBhQiFPGOVMzJ4YU6E8Bkvtxoa0OsbLbETwAMvMNFgvF7iwR9h9SBS6Yp L72tWKuB+fG2EtbkP8hHq12QahtEI+xOnJvCj05FII9ENDuriM0pzv1MDXO2Wiyxo+84 p4gOkruPJ0GQ72/hCbcubYZCKuVg3LQrS9np31gGowkV2TBHJQIRzdIe+qAyZOmjXxPW rTWby9ZvdZcRTdtnJGJ7fV59IR6o4KFx/lrB/7PJyDeb9IWGXJlUoXS4WZGLAYjW5z6z +KhQ== X-Gm-Message-State: AOJu0Yxb0khqqi9GcQAn8/Ev+2/q6E3+lFnm8YpYdOmSpLfc0kyf3fss lHT+L7wCZ5IHaQ2IELP4hw7uKjMYYHkm5buzPzr5xYYTYFHab6/mB0ZI+9rMK7U= X-Gm-Gg: ASbGnct2uGXUjIzBtP75CMlIU5Sj5CmW2eybOH6Rkdx2zOwfhaHwqBfUtp+JNqhXWmX uzEIzohuBvuy7fHMB0Egx/rUrafh4SUfTzsTK0wrrsHY0e5CzyrT2M9CtmaI78cjeVdz4Zp1qG1 Hp5Id1Zd+AT1Eewd6147N+WKlCUjSXwEtCfgPiHLMtUP8E+pftOXaPb0oc01O9I4XMJ3sTQDkBe R0uQ70VkOD890HEnH6jzWkyrcNnCfQGi1SdTjLhaNHpYoNBMl4lYd4PzLBKDCQ6DkJrPpuT0cnc W/67TmCZRsMA8ooZw1aOpq48TeSPOzTtPEjUXesJvQNWOE6cDGoT988= X-Google-Smtp-Source: AGHT+IHRhxFpwN5mvbNUzRinqXBDqGoviAOtL9q8/z1V5w4Yc+OEo0cD7fHx6H2OMQuVDAs/ujV4tA== X-Received: by 2002:a05:620a:2588:b0:7b6:d754:207f with SMTP id af79cd13be357-7bffcd9d91fmr106315585a.50.1738105146459; Tue, 28 Jan 2025 14:59:06 -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.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jan 2025 14:59:05 -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 2/2] dts: add flow create/delete to testpmd shell Date: Tue, 28 Jan 2025 17:59:02 -0500 Message-ID: <20250128225902.20709-2-dmarx@iol.unh.edu> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250128225902.20709-1-dmarx@iol.unh.edu> References: <20250121204135.28944-1-dmarx@iol.unh.edu> <20250128225902.20709-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 | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/dts/framework/remote_session/testpmd_shell.py b/dts/framework/remote_session/testpmd_shell.py index 3e86f52a7e..d58e4891b0 100644 --- a/dts/framework/remote_session/testpmd_shell.py +++ b/dts/framework/remote_session/testpmd_shell.py @@ -1910,6 +1910,51 @@ def csum_set_hw( {port_id}:\n{csum_output}""" ) + def flow_create(self, flow_rule: FlowRule, port_id: int) -> int: + """Creates a flow rule in the testpmd session. + + Args: + flow_rule: :class:`FlowRule` object used for creating testpmd flow rule. + port_id: Integer representing the port to use. + 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. Acts as implicit verification. + """ + flow_output = self.send_command(f"flow create {port_id} {flow_rule}") + 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: ID of the flow to remove. + port_id: Integer representing the port to use. + verify: If :data:`True`, the output of the command is scanned + to ensure the flow rule was deleted successfully. + + Raises: + InteractiveCommandExecutionError: 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_started_ports @requires_stopped_ports def set_port_mtu(self, port_id: int, mtu: int, verify: bool = True) -> None: -- 2.47.0