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 0403B45838; Wed, 21 Aug 2024 23:31:16 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6655342E24; Wed, 21 Aug 2024 23:31:09 +0200 (CEST) Received: from mail-oo1-f102.google.com (mail-oo1-f102.google.com [209.85.161.102]) by mails.dpdk.org (Postfix) with ESMTP id 9951642E00 for ; Wed, 21 Aug 2024 23:31:08 +0200 (CEST) Received: by mail-oo1-f102.google.com with SMTP id 006d021491bc7-5dcad9845b4so121269eaf.2 for ; Wed, 21 Aug 2024 14:31:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iol.unh.edu; s=unh-iol; t=1724275867; x=1724880667; 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=Gxn4uuaeME3t8qCz27QNM/axE9O5WkSYMD1mq30g4qs=; b=BDlPH9IUEC922spPCAFBoA21JEK1KxB1HV9QaCWffUhO43AspEyr+w/gR+/RCuBr55 MUZhYmkB2nM8msKnnaKEdxkZHufgb2eEZbQqjrpdDrIHxNg4J8YWIqn89DRxxOexjBUL 29aaI0GSbnWd0XWOK+ou60pWuJbg45GrP3cug= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724275867; x=1724880667; 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=Gxn4uuaeME3t8qCz27QNM/axE9O5WkSYMD1mq30g4qs=; b=uRkbqSJAgvpfnJd0dmouanTV84FSV+jHdozM6sYJvSs0ARDyEmTC6+KiSxP5gWEdCF kdzsgW1094jb349ds7Jt9YEHl0EayvN8MuEELCN7AxJh9sH5sgcSskKn0cotn9sU8zcY ZLZFvVIn7VO3Ui8566askq/rfIOMN0Y2hxMC3ujmblmPp92ZbNR1q3YC31DQPlSMr+5L 561MwkwzANL+W4TRb0ovdHWd8fJi1aaZCZkLnainuV+Kgo7YhPfaIWz3WEXrtmV8nJQj 4ciykAD2OU+I5/AbJx33SPCwkvP9iANU7lOLobWtOQj1Atf+q3i1H5B/euvPkrwQ7IXA r0kg== X-Gm-Message-State: AOJu0YzniSCxUU88hZTU0XAdu4I8qFk5SxyOZPi839Z3PxSPEy8m6aXc +7aEKaI65Ap0/84QexxxiGoVu+OMZBRQAw52G2AiQTTPVsJRr4R4O+OlF/Q27wnVjQSKrHBjGRO lqWCphzGKPdVFAymWe11le470SvwOC4Ticyh8na3EK5MMO2SG X-Google-Smtp-Source: AGHT+IGAafWPX5hzrN3kPU3WKpk7wqU8LfRyE2LxI03a8rd/5je4aLdH6K286/0BL5vgXXYqFUomO8KCOK9J X-Received: by 2002:a05:6871:8a5:b0:270:129f:8e65 with SMTP id 586e51a60fabf-2738be52917mr4158091fac.34.1724275867603; Wed, 21 Aug 2024 14:31:07 -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 586e51a60fabf-273ceb45cf7sm3094fac.31.2024.08.21.14.31.07 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Aug 2024 14:31:07 -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 5C657605C351; Wed, 21 Aug 2024 17:31:06 -0400 (EDT) From: jspewock@iol.unh.edu To: Luca.Vizzarro@arm.com, thomas@monjalon.net, paul.szczepanek@arm.com, wathsala.vithanage@arm.com, probb@iol.unh.edu, yoan.picchi@foss.arm.com, juraj.linkes@pantheon.tech, Honnappa.Nagarahalli@arm.com, npratte@iol.unh.edu, alex.chapman@arm.com Cc: dev@dpdk.org, Jeremy Spewock Subject: [RFC PATCH v3 2/5] dts: parameterize what ports the TG sends packets to Date: Wed, 21 Aug 2024 17:30:39 -0400 Message-ID: <20240821213042.24814-3-jspewock@iol.unh.edu> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240821213042.24814-1-jspewock@iol.unh.edu> References: <20240821191557.18744-1-jspewock@iol.unh.edu> <20240821213042.24814-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 TestSuite 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. 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