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 14B8F45837; Wed, 21 Aug 2024 21:22:35 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 786DA42D9D; Wed, 21 Aug 2024 21:22:27 +0200 (CEST) Received: from mail-vk1-f232.google.com (mail-vk1-f232.google.com [209.85.221.232]) by mails.dpdk.org (Postfix) with ESMTP id A724242D7D for ; Wed, 21 Aug 2024 21:22:25 +0200 (CEST) Received: by mail-vk1-f232.google.com with SMTP id 71dfb90a1353d-4fcec06ce09so16453e0c.3 for ; Wed, 21 Aug 2024 12:22:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iol.unh.edu; s=unh-iol; t=1724268145; x=1724872945; 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=A+9zcXpg/2QHGkJLjR/A+1+/N3BxZyenHkH1FYo71rU=; b=OxpcOfl2sOqYDMBs0FCThnQSWtf9bI4HTVfUNHxZvslgXFd0o7eXuY60BDAk0V2bam k9b6JcMMr6oakU5TSV+YsMHpf7TmWLWUUlT6iUXQ4ElW2wkLS0GA4ufYaUQP0w+RwvgM dNUB2PmZrRwkhxvRN92LTGri6QhhWffLHd0u0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724268145; x=1724872945; 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=A+9zcXpg/2QHGkJLjR/A+1+/N3BxZyenHkH1FYo71rU=; b=cyUDPo7CpZy590TKXsW56TtFrYeIattJ9cTzgxrp4x1IfQETDuO9sBuqJDKO3kJS5f HGLKa4a3sRJW+G8QdwNwxYmTeI2vGbdGP5qcZdXcbX00GVKWyfu80XGMzR/QEp9kBp94 SvWSvJubDZPVNlvrUD3kuJcH8gufm3kYwcmnGaiJHc5DhncdfJfBd0v/moQHWwp2XQ+z yFmlxhI21RDRzuANPzwQUIcZzIQEnophw2WWdF6oULTCYwrctWJVZc4NA0sSlrlrcgkP BHJGMYUbnWS6PY4sxJo66/QHJbKLFPceGxWERle0MFdX5758Yy60/5F3M0dujg35Ivua yd4g== X-Gm-Message-State: AOJu0Ywotw+y8jj0qdrIma5y3Mmg4pX9oaGo/kZytyqqNw97tecqSsAA qa4URII8HWcn209otz4w2dacAPYavrTwwg4/VYccDC44sjVpemtM01njsgcH0qs2ra4H/ypd0hW zwiCfjZ+logMifOPDdRZUzLAVS5NsAdl7 X-Google-Smtp-Source: AGHT+IFV/qi/Jg1Ks/UsoZweNsoeRx82OWGIOV9Hupx+MVNEK/ZcZeWoMlswxLlEM+HesWfu89kLB1Ol/8Z1 X-Received: by 2002:a05:6122:3111:b0:4f5:cd00:e492 with SMTP id 71dfb90a1353d-4fcf1b2331bmr4676016e0c.7.1724268144912; Wed, 21 Aug 2024 12:22:24 -0700 (PDT) Received: from postal.iol.unh.edu (postal.iol.unh.edu. [132.177.123.84]) by smtp-relay.gmail.com with ESMTPS id 71dfb90a1353d-4fd045d671asm19298e0c.0.2024.08.21.12.22.24 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Aug 2024 12:22:24 -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 02156605C351; Wed, 21 Aug 2024 15:22:23 -0400 (EDT) From: jspewock@iol.unh.edu To: wathsala.vithanage@arm.com, npratte@iol.unh.edu, thomas@monjalon.net, Honnappa.Nagarahalli@arm.com, Luca.Vizzarro@arm.com, probb@iol.unh.edu, yoan.picchi@foss.arm.com, alex.chapman@arm.com, juraj.linkes@pantheon.tech, paul.szczepanek@arm.com Cc: dev@dpdk.org, Jeremy Spewock Subject: [RFC PATCH v2 2/5] dts: parameterize what ports the TG sends packets to Date: Wed, 21 Aug 2024 15:21:49 -0400 Message-ID: <20240821192151.20874-4-jspewock@iol.unh.edu> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240821191557.18744-1-jspewock@iol.unh.edu> References: <20240821191557.18744-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 Previously in the DTS framework the helper methods in the TestSutie class designated ports as either ingress or egress ports and would wrap the methods of the traffic generator to allow packets to only flow to those designated ingress or egress ports. This is undesirable in some cases, such as when you have virtual functions on top of your port, where the TG ports can send to more than one SUT port since the framework limits where the TG is allowed to send packets. This patch solves this problem by creating optional parameters that allow the user to specify which port to gather the MAC addresses from when sending and receiving packets. Signed-off-by: Jeremy Spewock --- dts/framework/test_suite.py | 38 ++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/dts/framework/test_suite.py b/dts/framework/test_suite.py index 694b2eba65..d5c0021503 100644 --- a/dts/framework/test_suite.py +++ b/dts/framework/test_suite.py @@ -185,6 +185,8 @@ def send_packet_and_capture( packet: Packet, filter_config: PacketFilteringConfig = PacketFilteringConfig(), duration: float = 1, + sut_ingress: Port | None = None, + sut_egress: Port | None = None, ) -> list[Packet]: """Send and receive `packet` using the associated TG. @@ -195,11 +197,19 @@ def send_packet_and_capture( packet: The packet to send. filter_config: The filter to use when capturing packets. duration: Capture traffic for this amount of time after sending `packet`. + sut_ingress: Optional port to use as the SUT ingress port. Defaults to + `self._sut_port_ingress`. + sut_egress: Optional port to use as the SUT egress port. Defaults to + `self._sut_port_egress` Returns: A list of received packets. """ - packet = self._adjust_addresses(packet) + if sut_ingress is None: + sut_ingress = self._sut_port_ingress + if sut_egress is None: + sut_egress = self._sut_port_egress + packet = self._adjust_addresses(packet, sut_ingress, sut_egress) return self.tg_node.send_packet_and_capture( packet, self._tg_port_egress, @@ -208,18 +218,30 @@ def send_packet_and_capture( duration, ) - def get_expected_packet(self, packet: Packet) -> Packet: + def get_expected_packet( + self, packet: Packet, sut_ingress: Port | None = None, sut_egress: Port | None = None + ) -> Packet: """Inject the proper L2/L3 addresses into `packet`. Args: packet: The packet to modify. + sut_ingress: Optional port to use as the SUT ingress port. Defaults to + `self._sut_port_ingress`. + sut_egress: Optional port to use as the SUT egress port. Defaults to + `self._sut_port_egress`. Returns: `packet` with injected L2/L3 addresses. """ - return self._adjust_addresses(packet, expected=True) - - def _adjust_addresses(self, packet: Packet, expected: bool = False) -> Packet: + if sut_ingress is None: + sut_ingress = self._sut_port_ingress + if sut_egress is None: + sut_egress = self._sut_port_egress + return self._adjust_addresses(packet, sut_ingress, sut_egress, expected=True) + + def _adjust_addresses( + self, packet: Packet, sut_ingress_port: Port, sut_egress_port: Port, expected: bool = False + ) -> Packet: """L2 and L3 address additions in both directions. Assumptions: @@ -229,11 +251,13 @@ def _adjust_addresses(self, packet: Packet, expected: bool = False) -> Packet: packet: The packet to modify. expected: If :data:`True`, the direction is SUT -> TG, otherwise the direction is TG -> SUT. + sut_ingress_port: The port to use as the Rx port on the SUT. + sut_egress_port: The port to use as the Tx port on the SUT. """ if expected: # The packet enters the TG from SUT # update l2 addresses - packet.src = self._sut_port_egress.mac_address + packet.src = sut_egress_port.mac_address packet.dst = self._tg_port_ingress.mac_address # The packet is routed from TG egress to TG ingress @@ -244,7 +268,7 @@ def _adjust_addresses(self, packet: Packet, expected: bool = False) -> Packet: # 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 + packet.dst = sut_ingress_port.mac_address # The packet is routed from TG egress to TG ingress # update l3 addresses -- 2.46.0