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 243DD45837; Wed, 21 Aug 2024 21:39:51 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1312742DCD; Wed, 21 Aug 2024 21:39:51 +0200 (CEST) Received: from mail-qk1-f229.google.com (mail-qk1-f229.google.com [209.85.222.229]) by mails.dpdk.org (Postfix) with ESMTP id EF44942DCE for ; Wed, 21 Aug 2024 21:39:49 +0200 (CEST) Received: by mail-qk1-f229.google.com with SMTP id af79cd13be357-7a1d7bc07b7so6587885a.0 for ; Wed, 21 Aug 2024 12:39:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iol.unh.edu; s=unh-iol; t=1724269189; x=1724873989; 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=fH2H7opNMEkyvmJbhIbtGI7dmGKnN9m1j7o2liHO/Sx+iJ1ZoBT72b2+0w14GO3dlh a/qCHMPQVxpJZon3m6L2M4jLDDOonvmTZGa/z94469cE2nosA48od7qbbsFq57u2dFge lcCuAbie9Y6IrVDUPCrWEhvo6JiA84HR2+KKU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724269189; x=1724873989; 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=kDZGgFU7F/9xPmIWDbIlDA/7N2/jxNCA3bYLESYdyOXSkxhosglueriYzokXbJxkUu 2QnZNMvbz18vKgahxijp/KQ/w8DK9WfLTZDVuyWg9g5upstTC1JZfdrfOZepNIjwDrb9 u58Cw+raWvr+NldzraFhs1Dpn33vjpxNgcWqi5njKqt+RzatGlAOAaU5u7KVNCaYIhlm LAAziEr65RmSsFdM9pBonwGW5B1iiyIJonCX0JE6lfHNY7Q3jpQd/MLDL+G53EBjEFjF tKGsG3Cuhf1U/pzQpQRGbkAKXRmrR4BamQgXSOsB6QYinPV8TQGzfxYj7HUTXZnfH0n+ oyZg== X-Gm-Message-State: AOJu0YxnXqsX5Ul4OQFJNQ5LzWubG6MKN4uGLJWiwugArV10+hTbM6ht Viy3dN1bx8LPKzwwt6S2cNOajh5vHuIvuidsk1Y6rXubH1YjYLKEKA6zNtbcXc+PjYZH7Nh3SfH peGby0A/jtRVyW8/vRUIcAIYwDCGSOTjv X-Google-Smtp-Source: AGHT+IH11Mbt7gLUX3WO002HEbRfJ1vSpwNr1Uun+B3kOUOHyN4eggi/IdYXfmGIUtLrdyqay/tEMvvpq4Vd X-Received: by 2002:a05:620a:1a9e:b0:7a1:c431:3587 with SMTP id af79cd13be357-7a67404bcdamr420003385a.32.1724269189127; Wed, 21 Aug 2024 12:39:49 -0700 (PDT) Received: from postal.iol.unh.edu (postal.iol.unh.edu. [132.177.123.84]) by smtp-relay.gmail.com with ESMTPS id af79cd13be357-7a4ff0fa9f0sm38755985a.8.2024.08.21.12.39.48 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Aug 2024 12:39:49 -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 51108605C351; Wed, 21 Aug 2024 15:39:48 -0400 (EDT) From: jspewock@iol.unh.edu To: npratte@iol.unh.edu, paul.szczepanek@arm.com, thomas@monjalon.net, probb@iol.unh.edu, yoan.picchi@foss.arm.com, juraj.linkes@pantheon.tech, wathsala.vithanage@arm.com, Luca.Vizzarro@arm.com, alex.chapman@arm.com, Honnappa.Nagarahalli@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:38:38 -0400 Message-ID: <20240821193841.21033-3-jspewock@iol.unh.edu> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240821193841.21033-1-jspewock@iol.unh.edu> References: <20240821191557.18744-1-jspewock@iol.unh.edu> <20240821193841.21033-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