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 18CDF460D3; Tue, 21 Jan 2025 21:41:35 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6F39340395; Tue, 21 Jan 2025 21:41:30 +0100 (CET) Received: from mail-qt1-f174.google.com (mail-qt1-f174.google.com [209.85.160.174]) by mails.dpdk.org (Postfix) with ESMTP id 516C74026C for ; Tue, 21 Jan 2025 21:41:29 +0100 (CET) Received: by mail-qt1-f174.google.com with SMTP id d75a77b69052e-4679eacf25cso36544431cf.3 for ; Tue, 21 Jan 2025 12:41:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iol.unh.edu; s=unh-iol; t=1737492089; x=1738096889; 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=3rQmv7H5FW8AajN+c8CDv25bBn+c36jT16dffYADxME=; b=HM/cPHM0mocI0KW+Ma7AEvXfq1SXvsJ2bmZCwS1K2A9u9G+x0JKoEUFZK7X8lgqnxo wDz0VB+7KqHkhp5cQJkGsM/9VH2D98PClYJA64cmDyj8BgoyoFgTLWZU7dqqqt4EW+vF x5MTq9ggfQsznF1K/WvbfiSZ8m90edmyDcW78= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737492089; x=1738096889; 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=3rQmv7H5FW8AajN+c8CDv25bBn+c36jT16dffYADxME=; b=hsZdzlC81eQ6S3afR+x8sa6wWAqwPdJ+ptR+CZ3T08G0HPJms+vD5xwRKO5cfM61K0 omOOlzh4pc27Uq4FhIJmeoWTnOB6kx3kHXrZlRF2YFYrf+f0rjoVAwkrhg4T487iNZ1s hFPy4BnMrp7UN5rC7vbJzc3ETeQO9hSvu+T/n7Yoe41dEtj6CrzzG54g9YTikzVOLho9 Rc1ycvhOHpCDi0BR/o8IYdA7gdNzpsmVBkIxaHssR+EgdkSwraYfWdhZ6mvu6XSdl28N 9O6uN3LkQmBSK8LAdt6o+oE6f+K0HGqmzt5esVUYRmrehA3TKQC0mr7uUFFCI7jj0XK2 Do2Q== X-Gm-Message-State: AOJu0YyZdIijXMoxDHyfeE+NOxdeOCl6QDlkufAjYlI/IOFCBVh0AbmN jGdylfEEhfUPieol++GO8Jy6yxKPabm29eqiSEy9gNFfZfpR5k++q6sFpRz24Qg= X-Gm-Gg: ASbGnctiv6ATbzPrT4lE8wg2uLuMLe3CEQX8ncYHbwcNRATkUMXjoqLjvLr2aec00FJ I2qagg9D6HFFnzqq5Ajz4+3VS/XcTtt0Wn+n7zV1+VHqM2/UK3Ie9TOUqbB2QjbTFClfFcc6iSn 89HKuFHHr6BGDuRUAgghSzLlOvZTy/J5h4YceHs95ijIcCNxdYsFicMzNoiG/64AJ9Qb4od480c +iN+m3cnrKmWl0KN/ZJpCO5+N5aZgcsc46aTFpbl69/fCL02AppeRh+2sZx0+R2nAHuNXIpR6eC +Ihx/Tq/tRonKlDx0WXQiQV/7GrpcPRKJnMAIZjc X-Google-Smtp-Source: AGHT+IF69IBsFjIwargARlqAsnkSQ/5xwnScnWSwc8r35GEe2LndHuzAVAGivz8elokW9JZdvEYOLQ== X-Received: by 2002:ac8:580b:0:b0:467:54e5:ceaa with SMTP id d75a77b69052e-46e12a1e327mr225754091cf.9.1737492088720; Tue, 21 Jan 2025 12:41:28 -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.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jan 2025 12:41:28 -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 2/2] dts: add flow create/delete to testpmd shell Date: Tue, 21 Jan 2025 15:41:35 -0500 Message-ID: <20250121204135.28944-2-dmarx@iol.unh.edu> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20250121204135.28944-1-dmarx@iol.unh.edu> References: <20241204232246.30339-2-dmarx@iol.unh.edu> <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 flow create/delete methods to TestPmdShell class for initializing flow rules. Signed-off-by: Dean Marx --- dts/framework/remote_session/testpmd_shell.py | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/dts/framework/remote_session/testpmd_shell.py b/dts/framework/remote_session/testpmd_shell.py index 3e86f52a7e..01c05bceda 100644 --- a/dts/framework/remote_session/testpmd_shell.py +++ b/dts/framework/remote_session/testpmd_shell.py @@ -1910,6 +1910,57 @@ 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. + 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 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. + 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.44.0