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 C6A4C45837; Wed, 21 Aug 2024 21:16:24 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DC82A42D3F; Wed, 21 Aug 2024 21:16:19 +0200 (CEST) Received: from mail-oo1-f104.google.com (mail-oo1-f104.google.com [209.85.161.104]) by mails.dpdk.org (Postfix) with ESMTP id DDDCF4281D for ; Wed, 21 Aug 2024 21:16:17 +0200 (CEST) Received: by mail-oo1-f104.google.com with SMTP id 006d021491bc7-5d5b22f97b7so68679eaf.2 for ; Wed, 21 Aug 2024 12:16:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iol.unh.edu; s=unh-iol; t=1724267777; x=1724872577; 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=dmy/kIoOL9jpjTnPMPkpu7pw/CKStA1nazmjICKQB9Fe8ExqurHittR5+AFHgcD+PR g25pQM3ri1r1NSe5+p0neFtxu3Xy/cVKyAhqe9tLHKWpMDn1TBfK9zC6VLXpT9C36PZT CLhy+tBNRp/sb/3yV51Df+0geXODVpMmdJsdg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724267777; x=1724872577; 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=NlDQvdPegKTveqUBEeL51xUniW18qyNpcQ70U8DCAb6hXAsDp21JgwNcMoJCVE6CG6 i+oG5s9IDpZ+KEUhohe0Nau9iCWz4fdiLU4zVrQfpUjpyuzS7HI6xDZf5/A5eLPJCpN8 hlVTtvDzTiozJJ5qMHwA/2QMXjbmVeWhLaAqrVSUsCtvJQNlK2hRDDJWjMpQtahtTCq1 cWTRSTefOj0cGSdOtlLU6tlWuxX88OZVm8AvET9nhDy8u6ghVTOcnFvGvUecD4P0KTdM r/ktJ9c0CWR25g16Eau1iJewxTAp62eYsAABgt9aw8LB87dZIH4zAHVD9gT2ZWCEl6CJ Ci3w== X-Gm-Message-State: AOJu0YxAwn4WFcEntu2Drjsix+cgy1wP7Pvv4GGXl73YPH3g034oZSa9 uTo5LnNt2UF+/dz8Il/nCPdo4NIKIgfC/2wDnE0Wj91GJnalJVBmPdPR66vGW/tGbXoa27lp2Az Ow3wpyQvKmDEjpgYks/E+SWjEw+hOvF3R X-Google-Smtp-Source: AGHT+IHCZ92qniSsywGljMefAYrTN7/raQDHOb7En1NfPbSHRuysuS5jU64pKRDgzPNCgo+gTNIcIt4ZO41z X-Received: by 2002:a05:6820:602:b0:5c6:5f2d:8430 with SMTP id 006d021491bc7-5dca05097f7mr4117453eaf.2.1724267776949; Wed, 21 Aug 2024 12:16:16 -0700 (PDT) Received: from postal.iol.unh.edu (postal.iol.unh.edu. [132.177.123.84]) by smtp-relay.gmail.com with ESMTPS id 006d021491bc7-5dc93a69052sm326910eaf.5.2024.08.21.12.16.16 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Aug 2024 12:16:16 -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 E9D85605C352; Wed, 21 Aug 2024 15:16:15 -0400 (EDT) From: jspewock@iol.unh.edu To: npratte@iol.unh.edu, thomas@monjalon.net, Luca.Vizzarro@arm.com, yoan.picchi@foss.arm.com, alex.chapman@arm.com, juraj.linkes@pantheon.tech, probb@iol.unh.edu, wathsala.vithanage@arm.com, paul.szczepanek@arm.com, Honnappa.Nagarahalli@arm.com Cc: dev@dpdk.org, Jeremy Spewock Subject: [RFC PATCH v1 2/5] dts: parameterize what ports the TG sends packets to Date: Wed, 21 Aug 2024 15:15:54 -0400 Message-ID: <20240821191557.18744-3-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