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 5F657456A2; Wed, 24 Jul 2024 17:07:52 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 02AE34349B; Wed, 24 Jul 2024 17:07:48 +0200 (CEST) Received: from mail-il1-f232.google.com (mail-il1-f232.google.com [209.85.166.232]) by mails.dpdk.org (Postfix) with ESMTP id 1A65043497 for ; Wed, 24 Jul 2024 17:07:47 +0200 (CEST) Received: by mail-il1-f232.google.com with SMTP id e9e14a558f8ab-39626aee4easo31844765ab.3 for ; Wed, 24 Jul 2024 08:07:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iol.unh.edu; s=unh-iol; t=1721833666; x=1722438466; 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=m1mXm1hNYRl8aBZJIIaHZ3HCBzOzWo1ODYQwY+sFpo0=; b=Dbkz6KjxXNBz46uvMdF9p3Usm1O+W0AYdpKl9dwx30hMnMUNYbUyNTie5vzFauTQ/5 PJZk45A/qX4nsJRCXSFDvr0alxibIZ2M/26w8n9lBBEwS39LAY7Zomag33qXr+KZGN6G wHlHixNqJ4M8f+QpWz4HzZIlDxk/KpHOpAU8k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721833666; x=1722438466; 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=m1mXm1hNYRl8aBZJIIaHZ3HCBzOzWo1ODYQwY+sFpo0=; b=TY77TVQxuLkLJ9q3ZpOTvkjpMdEGm9PE3HeFFhmixCljP1aafqUwLceAHzMwMvwWIK SjjS9Vdn4SB69Xvbg1srsB+6EvUQoxDmXlgzCiN4xGF+KNtJXPkFuBOScegT+z8mffC9 AdiKlH/R5TmAA9QXZzST83nZlhsHNUENpuTxbZKh3PeGoJdPTWxNjPmn4N7PyXAbLy2i 6MAwIuzHnCYvDdOeTFxIHQHh/rdZL+12LhEvgiHm2Q/ClwS528nLYrs65WvRluYnPe8I mCgIvRY5dIO6FkPW5UXhkdFCwMLIAOGfTXuNkKc54wyZVGnyetQ0yhiiQGdGarsLfu/5 KAqQ== X-Gm-Message-State: AOJu0YxqnF+Hcime1+PgKwxXZEnS+QStE1Lz9ms00Fn58kgvEHu/m2Z8 IoVTios9wZvpkL+nHJMdbqePBSLsfBbrGjWKBfb9qS3Ud51edQ1zumlD84MVaOijfL1oiKaubaQ s2+IBfYXvrFdRUAbLAA+E9DaNK4+/Q0aUsnyj8U/WHV9QOuMe X-Google-Smtp-Source: AGHT+IFNCzn4fRLC6OoL4N2HbCu1gsKTybh+i1+WWi/+7sxsPoD/0xvOUORRkRS/+yMX9WpddAdxTCaqeTcr X-Received: by 2002:a92:c241:0:b0:383:5ada:7a65 with SMTP id e9e14a558f8ab-39a16d5dc55mr38923715ab.26.1721833666216; Wed, 24 Jul 2024 08:07:46 -0700 (PDT) Received: from postal.iol.unh.edu (postal.iol.unh.edu. [2606:4100:3880:1234::84]) by smtp-relay.gmail.com with ESMTPS id e9e14a558f8ab-39a1869f329sm699765ab.28.2024.07.24.08.07.46 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Jul 2024 08:07:46 -0700 (PDT) X-Relaying-Domain: iol.unh.edu Received: from iol.unh.edu (unknown [IPv6:2606:4100:3880:1257::1083]) by postal.iol.unh.edu (Postfix) with ESMTP id 636F86050A6F; Wed, 24 Jul 2024 11:07:45 -0400 (EDT) From: jspewock@iol.unh.edu To: thomas@monjalon.net, Luca.Vizzarro@arm.com, Honnappa.Nagarahalli@arm.com, probb@iol.unh.edu, yoan.picchi@foss.arm.com, npratte@iol.unh.edu, wathsala.vithanage@arm.com, juraj.linkes@pantheon.tech, paul.szczepanek@arm.com Cc: dev@dpdk.org, Jeremy Spewock Subject: [PATCH v3 1/4] dts: add send_packets to test suites and rework packet addressing Date: Wed, 24 Jul 2024 11:07:11 -0400 Message-ID: <20240724150714.226970-2-jspewock@iol.unh.edu> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240724150714.226970-1-jspewock@iol.unh.edu> References: <20240625155332.2400-1-jspewock@iol.unh.edu> <20240724150714.226970-1-jspewock@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 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 = self._adjust_addresses(packet) + packet = 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 received traffic. + + Args: + packets: Packets to send. + """ + packets = 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) -> Packet: """ return self._adjust_addresses(packet, expected=True) - def _adjust_addresses(self, packet: Packet, expected: bool = False) -> Packet: + def _adjust_addresses(self, packets: list[Packet], expected: bool = 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 other 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 = self._sut_port_egress.mac_address - packet.dst = self._tg_port_ingress.mac_address + ret_packets = [] + for packet in packets: + default_pkt_src = type(packet)().src + default_pkt_dst = type(packet)().dst + default_pkt_payload_src = IP().src if hasattr(packet.payload, "src") else None + default_pkt_payload_dst = IP().dst if hasattr(packet.payload, "dst") else None + # If `expected` is :data:`True`, the packet enters the TG from 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 = self._tg_ip_address_egress.ip.exploded - packet.payload.dst = self._tg_ip_address_ingress.ip.exploded - else: - # The packet leaves TG towards SUT # update l2 addresses - packet.src = self._tg_port_egress.mac_address - packet.dst = self._sut_port_ingress.mac_address + if packet.src == default_pkt_src: + packet.src = ( + self._sut_port_egress.mac_address + if expected + else self._tg_port_egress.mac_address + ) + if packet.dst == default_pkt_dst: + packet.dst = ( + 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 regardless of if it is expected or + # not. - # The packet is routed from TG egress to TG ingress # update l3 addresses - packet.payload.src = self._tg_ip_address_egress.ip.exploded - packet.payload.dst = self._tg_ip_address_ingress.ip.exploded - - return Ether(packet.build()) + if ( + default_pkt_payload_src is not None + and packet.payload.src == default_pkt_payload_src + ): + packet.payload.src = self._tg_ip_address_egress.ip.exploded + if ( + default_pkt_payload_dst is not None + and packet.payload.dst == default_pkt_payload_dst + ): + packet.payload.dst = self._tg_ip_address_ingress.ip.exploded + 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/testbed_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