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 F23DB45A28; Wed, 25 Sep 2024 10:17:52 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7ADC94025D; Wed, 25 Sep 2024 10:17:52 +0200 (CEST) Received: from mail-lj1-f171.google.com (mail-lj1-f171.google.com [209.85.208.171]) by mails.dpdk.org (Postfix) with ESMTP id 94AF2400EF for ; Wed, 25 Sep 2024 10:17:49 +0200 (CEST) Received: by mail-lj1-f171.google.com with SMTP id 38308e7fff4ca-2f752d9ab62so66609611fa.3 for ; Wed, 25 Sep 2024 01:17:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pantheon.tech; s=google; t=1727252269; x=1727857069; darn=dpdk.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=HtTO69i43H+R0Vvkk1NcT8oRP0+PSfxtcv1OH694pqo=; b=ehqjs6TGZm2mUCAkV17cmVS5JPw66BVWUEdCizy7cMOqYGCypKowbt8LAZ5OO0PdWf VLr2Hxzmfyp79GT2XNlGYnWe776jj94jjleYmqp6oW7/aGHjGt0jqZGMN1YpmNmNKneN /8xnzXoInBnkc10ZuhDwnOZjnOwBdkyLm83HOYQIinVIAa4zU2DAKm/uQLD8Ylxt0fWq 0WoRbdSk7fCfUP550fWjSp8ESpz8zzQr5tb9xvFW6TTv05Sj8ipVaunFWyy8LB+1FdXY iPw1XRJlIffxAPZxWCyLZ0+MvBavOedQktlJ0GeHzbwRbBpdfUCrV48loLRvTL9lhFIn t6sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727252269; x=1727857069; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=HtTO69i43H+R0Vvkk1NcT8oRP0+PSfxtcv1OH694pqo=; b=n+qOloKxHrXg/PXbDVzn6VlK/UN290Ip9/3XCFMuBK98Ob27Jf3RGhUOQUid9DCipw ckN+jTtvkHxSYNhDrTjPvJhO1y0yGS1fJcdmCKj1qrijznx6kF5B2AcD3Hb5dOLMY43T 51l8hRAvYcyukqVHkgzA59jiTyehRz9F0ANGrabrd5mwamKt3kBKa9Ankt96WD7aydVv j+nVyGUVVqycGPMNGV8HcTj4l06P4cZVL4BxaPhuGuOv1Hey5dOdAMVPxm21h5yJ/8Es Vvq+gvmuVQ5+PE/8oL+56arbPIymUdgHMQtBjQumRfbvvJX0ahqGsY9oEIh8qcGAgvKV r8cw== X-Gm-Message-State: AOJu0YwATvpTmKlBT6y5hfmqanKsqtiCtpDrdxoOLHO+0gK/TaGAjrBl S98gylQAEDuvOQmU9lgS0eXTHf2S3xbNecMJm1XA82h8uEDwkVI6v//jJ7kIj/w= X-Google-Smtp-Source: AGHT+IFxkY+1QKVtC3oLexuaepM4zeSSyl2ewqzoIqT/5StlI1RHcY60KYr0/AHze1W/Y7tHtdKAeg== X-Received: by 2002:a05:6512:400c:b0:533:d3e:16fe with SMTP id 2adb3069b0e04-5387755cb91mr1012196e87.38.1727252268796; Wed, 25 Sep 2024 01:17:48 -0700 (PDT) Received: from [192.168.200.22] ([84.245.121.62]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5c5cf4c5002sm1592301a12.65.2024.09.25.01.17.47 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 25 Sep 2024 01:17:48 -0700 (PDT) Message-ID: Date: Wed, 25 Sep 2024 10:17:47 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3] dts: add flow rule dataclass to testpmd shell To: Dean Marx , probb@iol.unh.edu, npratte@iol.unh.edu, jspewock@iol.unh.edu, luca.vizzarro@arm.com, yoan.picchi@foss.arm.com, Honnappa.Nagarahalli@arm.com, paul.szczepanek@arm.com Cc: dev@dpdk.org References: <20240806164208.3351-1-dmarx@iol.unh.edu> <20240813144107.6195-1-dmarx@iol.unh.edu> Content-Language: en-US From: =?UTF-8?Q?Juraj_Linke=C5=A1?= In-Reply-To: <20240813144107.6195-1-dmarx@iol.unh.edu> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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 On 13. 8. 2024 16:41, Dean Marx wrote: > add dataclass for passing in flow rule creation arguments, as well as a Capitalize please. > __str__ method for converting to a sendable testpmd command. Add > flow_create method to TestPmdShell class for initializing flow rules. > > Signed-off-by: Dean Marx > --- > dts/framework/remote_session/testpmd_shell.py | 57 +++++++++++++++++++ > 1 file changed, 57 insertions(+) > > diff --git a/dts/framework/remote_session/testpmd_shell.py b/dts/framework/remote_session/testpmd_shell.py > index 43e9f56517..17b9c7811d 100644 > --- a/dts/framework/remote_session/testpmd_shell.py > +++ b/dts/framework/remote_session/testpmd_shell.py > @@ -577,6 +577,44 @@ class TestPmdPortStats(TextParser): > tx_bps: int = field(metadata=TextParser.find_int(r"Tx-bps:\s+(\d+)")) > > > +@dataclass > +class FlowRule: > + """Dataclass for setting flow rule parameters.""" > + > + #: > + port_id: int > + #: > + ingress: bool > + #: > + pattern: str > + #: > + actions: str > + > + #: > + group_id: int | None = None > + #: > + priority_level: int | None = None > + #: > + user_id: int | None = None > + > + def __str__(self) -> str: > + """Returns the string representation of a flow_func instance. > + > + In this case, a properly formatted flow create command that can be sent to testpmd. I think it would be beneficial for a complicated command like this to add the actual format of the command as returned by testpmd, which should be (according to app/test-pmd/cmdline.c): flow create {port_id} [group {group_id}] [priority {level}] [ingress] [egress] pattern {item} [/ {item} [...]] / end actions {action} [/ {action} [...]] / end Looking at this, there could be multiple patterns and actions. Maybe we should add classes for these two as well - what do the patterns and actions look like? > + """ > + ret = f"flow create {self.port_id} " > + 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 += "ingress " if self.ingress else "egress " > + if self.user_id is not None: > + ret += f"user_id {self.user_id} " > + ret += f"pattern {self.pattern} / end " > + ret += f"actions {self.actions} / end" > + return ret > + > + > class TestPmdShell(DPDKShell): > """Testpmd interactive shell. > > @@ -806,6 +844,25 @@ def show_port_stats(self, port_id: int) -> TestPmdPortStats: > > return TestPmdPortStats.parse(output) > > + def flow_create(self, cmd: FlowRule, verify: bool = True) -> None: Do we also need to add a method for deleting (I guess it would be called destroying per the command) the rule? Or any other flow rule commands? We could expand the test suite (I assume we're adding this because of a test suite) if such tests make sense. > + """Creates a flow rule in the testpmd session. > + > + Args: > + cmd: String from flow_func instance to send as a flow rule. The cmd docstring has not been updated. I'd also rename cmd to 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. > + """ > + flow_output = self.send_command(str(cmd)) > + 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}" > + ) > + > def _close(self) -> None: > """Overrides :meth:`~.interactive_shell.close`.""" > self.stop()