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 DB982456B8; Fri, 26 Jul 2024 16:38:13 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6F1B643278; Fri, 26 Jul 2024 16:38:13 +0200 (CEST) Received: from mail-lf1-f50.google.com (mail-lf1-f50.google.com [209.85.167.50]) by mails.dpdk.org (Postfix) with ESMTP id 4A0334281D for ; Fri, 26 Jul 2024 16:38:12 +0200 (CEST) Received: by mail-lf1-f50.google.com with SMTP id 2adb3069b0e04-52ef9bc3a64so196778e87.3 for ; Fri, 26 Jul 2024 07:38:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iol.unh.edu; s=unh-iol; t=1722004691; x=1722609491; darn=dpdk.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=88mMMOsW4PeqS0KyooL0Wu77obx/jVDbUflRercsnEA=; b=fK1aneH9RDPX+TSWf+8To2VbZCgdbxk6mgC6bDHWFBqdJyeby+7OHJz3uXxFtibOsU gGP4DEbMvuKFneN9zFfKI8/ieeOG6YIMFxuIcT2vDA4YR8ja/8Rd/Ac7Nr1idMCMbFoJ lvgkammqhMSpTsB+xC1GCmUfBI9bDVfcadxgE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722004691; x=1722609491; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=88mMMOsW4PeqS0KyooL0Wu77obx/jVDbUflRercsnEA=; b=G13VfIK8YIl5F4aO4jj61B6ghkOovd06XFAf3qG+TWTCZvb6NzlkORJVq+wpjXq774 HnFVCKO8uhWUi+kRu6Nk8KxNvX9HQkxNjbym2+pDroidyX3q4GgLVHiHgzJtBdsZd2jk zTQl/gDcm0QZ4wkkgKIzNiiO3L+PDfxEymoOo80R7eAvVYUg54ctZDTbi4pLJOdAQSE/ nnpYqF+Sritd8Ec5D+LEGcsIZ0JengbE4Vd1KzttmRy0SmDlkYejXTEcuGZdgw2ur7QF InxAUItoDiugboq3ourkVV9oq0IvHriIhncFkdMsjwflc82eIkclPuodBgqDBoQRokar e4/g== X-Forwarded-Encrypted: i=1; AJvYcCVrn1UuYt+lsPju/xr3u01Ro2o8d5dU5uhSZ32RdrYQiyTD5B/3xfYAO4XNDS2uvlUT7MBN+oWeTuaekW4= X-Gm-Message-State: AOJu0YxpfQHUcQWwS0WO7vy3pfNjboEsg424KFT6/ycJSjM9ygAUxTWN +nlrPUhSR+wk8odT4HBIRozKCOJT5Wi7us3w04H8wNH+IFuA3qMXsOZ2CLFduDnLFEl8s7xWyWs l9snTlZ9sYVzWuFLO/sNh93qlHPZdIvPstdnleg== X-Google-Smtp-Source: AGHT+IGMKhnnqVjC8uK7lzYhJnUTJ1Z0kiE+fLVIMj5srwT9Dp/0ROW+28bT+qapywikkhC+9YIZUkuPFyDUJvd6BDg= X-Received: by 2002:a2e:2a03:0:b0:2ef:27fa:1fbe with SMTP id 38308e7fff4ca-2f03c6f4ef9mr23844541fa.2.1722004691363; Fri, 26 Jul 2024 07:38:11 -0700 (PDT) MIME-Version: 1.0 References: <20240625155332.2400-1-jspewock@iol.unh.edu> <20240724150714.226970-1-jspewock@iol.unh.edu> <20240724150714.226970-2-jspewock@iol.unh.edu> In-Reply-To: <20240724150714.226970-2-jspewock@iol.unh.edu> From: Nicholas Pratte Date: Fri, 26 Jul 2024 10:37:59 -0400 Message-ID: Subject: Re: [PATCH v3 1/4] dts: add send_packets to test suites and rework packet addressing To: jspewock@iol.unh.edu Cc: thomas@monjalon.net, Luca.Vizzarro@arm.com, Honnappa.Nagarahalli@arm.com, probb@iol.unh.edu, yoan.picchi@foss.arm.com, wathsala.vithanage@arm.com, juraj.linkes@pantheon.tech, paul.szczepanek@arm.com, dev@dpdk.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 This is great, I'll be using this in-favor of the boolean solution that I implemented! Just to bring this to your attention. I am currently working on some Generic Routing Encapsulation suites the require multiple IP layers at packet creation; they look something like: Ether() / IP() / GRE() / IP() / UDP() / Raw(load=3D'x'*80) I have to take a deeper look to see how multiple IP layers affect the declaration of src and dst variables, I'll let you know what I find as some changes might be needed on this implementation to avoid future bugs. Once I figure it out, I'll leave a review tag for you. On Wed, Jul 24, 2024 at 11:07=E2=80=AFAM wrote: > > From: Jeremy Spewock > > Currently the only method provided in the test suite class for sending > packets sends a single packet and then captures the results. There is, > in some cases, a need to send multiple packets at once while not really > needing to capture any traffic received back. The method to do this > exists in the traffic generator already, but this patch exposes the > method to test suites. > > This patch also updates the _adjust_addresses method of test suites so > that addresses of packets are only modified if the developer did not > configure them beforehand. This allows for developers to have more > control over the content of their packets when sending them through the > framework. > > Signed-off-by: Jeremy Spewock > --- > dts/framework/test_suite.py | 74 ++++++++++++++++++-------- > dts/framework/testbed_model/tg_node.py | 9 ++++ > 2 files changed, 62 insertions(+), 21 deletions(-) > > diff --git a/dts/framework/test_suite.py b/dts/framework/test_suite.py > index 694b2eba65..0b678ed62d 100644 > --- a/dts/framework/test_suite.py > +++ b/dts/framework/test_suite.py > @@ -199,7 +199,7 @@ def send_packet_and_capture( > Returns: > A list of received packets. > """ > - packet =3D self._adjust_addresses(packet) > + packet =3D self._adjust_addresses([packet])[0] > return self.tg_node.send_packet_and_capture( > packet, > self._tg_port_egress, > @@ -208,6 +208,18 @@ def send_packet_and_capture( > duration, > ) > > + def send_packets( > + self, > + packets: list[Packet], > + ) -> None: > + """Send packets using the traffic generator and do not capture r= eceived traffic. > + > + Args: > + packets: Packets to send. > + """ > + packets =3D self._adjust_addresses(packets) > + self.tg_node.send_packets(packets, self._tg_port_egress) > + > def get_expected_packet(self, packet: Packet) -> Packet: > """Inject the proper L2/L3 addresses into `packet`. > > @@ -219,39 +231,59 @@ def get_expected_packet(self, packet: Packet) -> Pa= cket: > """ > return self._adjust_addresses(packet, expected=3DTrue) > > - def _adjust_addresses(self, packet: Packet, expected: bool =3D False= ) -> Packet: > + def _adjust_addresses(self, packets: list[Packet], expected: bool = =3D False) -> list[Packet]: > """L2 and L3 address additions in both directions. > > + Only missing addresses are added to packets, existing addressed = will not be overridden. > + > Assumptions: > Two links between SUT and TG, one link is TG -> SUT, the oth= er SUT -> TG. > > Args: > - packet: The packet to modify. > + packets: The packets to modify. > expected: If :data:`True`, the direction is SUT -> TG, > otherwise the direction is TG -> SUT. > """ > - if expected: > - # The packet enters the TG from SUT > - # update l2 addresses > - packet.src =3D self._sut_port_egress.mac_address > - packet.dst =3D self._tg_port_ingress.mac_address > + ret_packets =3D [] > + for packet in packets: > + default_pkt_src =3D type(packet)().src > + default_pkt_dst =3D type(packet)().dst > + default_pkt_payload_src =3D IP().src if hasattr(packet.paylo= ad, "src") else None > + default_pkt_payload_dst =3D IP().dst if hasattr(packet.paylo= ad, "dst") else None > + # If `expected` is :data:`True`, the packet enters the TG fr= om SUT, otherwise the > + # packet leaves the TG towards the SUT > > - # The packet is routed from TG egress to TG ingress > - # update l3 addresses > - packet.payload.src =3D self._tg_ip_address_egress.ip.explode= d > - packet.payload.dst =3D self._tg_ip_address_ingress.ip.explod= ed > - else: > - # The packet leaves TG towards SUT > # update l2 addresses > - packet.src =3D self._tg_port_egress.mac_address > - packet.dst =3D self._sut_port_ingress.mac_address > + if packet.src =3D=3D default_pkt_src: > + packet.src =3D ( > + self._sut_port_egress.mac_address > + if expected > + else self._tg_port_egress.mac_address > + ) > + if packet.dst =3D=3D default_pkt_dst: > + packet.dst =3D ( > + self._tg_port_ingress.mac_address > + if expected > + else self._sut_port_ingress.mac_address > + ) > + > + # The packet is routed from TG egress to TG ingress regardle= ss of if it is expected or > + # not. > > - # The packet is routed from TG egress to TG ingress > # update l3 addresses > - packet.payload.src =3D self._tg_ip_address_egress.ip.explode= d > - packet.payload.dst =3D self._tg_ip_address_ingress.ip.explod= ed > - > - return Ether(packet.build()) > + if ( > + default_pkt_payload_src is not None > + and packet.payload.src =3D=3D default_pkt_payload_src > + ): > + packet.payload.src =3D self._tg_ip_address_egress.ip.exp= loded > + if ( > + default_pkt_payload_dst is not None > + and packet.payload.dst =3D=3D default_pkt_payload_dst > + ): > + packet.payload.dst =3D self._tg_ip_address_ingress.ip.ex= ploded > + ret_packets.append(Ether(packet.build())) > + > + return ret_packets > > def verify(self, condition: bool, failure_description: str) -> None: > """Verify `condition` and handle failures. > diff --git a/dts/framework/testbed_model/tg_node.py b/dts/framework/testb= ed_model/tg_node.py > index 4ee326e99c..758b676258 100644 > --- a/dts/framework/testbed_model/tg_node.py > +++ b/dts/framework/testbed_model/tg_node.py > @@ -83,6 +83,15 @@ def send_packet_and_capture( > duration, > ) > > + def send_packets(self, packets: list[Packet], port: Port): > + """Send packets without capturing resulting received packets. > + > + Args: > + packets: Packets to send. > + port: Port to send the packets on. > + """ > + self.traffic_generator.send_packets(packets, port) > + > def close(self) -> None: > """Free all resources used by the node. > > -- > 2.45.2 >