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 D3AE745A12; Mon, 23 Sep 2024 20:43:05 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B37DC402EA; Mon, 23 Sep 2024 20:42:55 +0200 (CEST) Received: from mail-pj1-f102.google.com (mail-pj1-f102.google.com [209.85.216.102]) by mails.dpdk.org (Postfix) with ESMTP id E35C9402CA for ; Mon, 23 Sep 2024 20:42:52 +0200 (CEST) Received: by mail-pj1-f102.google.com with SMTP id 98e67ed59e1d1-2d87196ec9fso3184246a91.1 for ; Mon, 23 Sep 2024 11:42:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iol.unh.edu; s=unh-iol; t=1727116972; x=1727721772; 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=BbMwwmdIa+dHbnaWZJNHsdx1Y4VrdlWIzalDi9CBwjg=; b=aPtJAzxIhNt6Wvg8JmpPW963cVleLa/HWF9sIuyXHBouoCi1pjFVo9IvdI72fgs4xM tNEglLv+x8GZ4n17Iye0dUfnPO3y3hcPgfOxNn551xnmL/4m5h5KRMiawTuDIsCK7914 743xm3TZApl3l5r52ZQrh1luK2pe3si0TTPCM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727116972; x=1727721772; 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=BbMwwmdIa+dHbnaWZJNHsdx1Y4VrdlWIzalDi9CBwjg=; b=Dgl4OjXkMUCepdhk0f/1SDKsqcWxbBL40HEuFjTP5kaAwvhFGHWbxbnzgQXgzAgzGT IeSM1L3EgK1/wLwqDGXkG2T29ONeIO7uI/eDeDFbyTgcc0r9mjqUBWniTwrKNL8XsDDh 92fd/lNQvpkYCFD+fnErTpDdMLcpjj1SDHjw37Tqe8Q1ee5p45jD3R80yk6JNKHoyQQd G6NhE4Q+fE57TLTnnJhkwGZfC3l/yfgS/pILSwbGYPgZ9tI8CYBU9AUAe0tNGipe2PL8 dHwGsWlAqAebylG38+slXuNWc0isPwwhmTIzThxoNnvAdL57H6462rP85rI8d5tFqK8e +IJw== X-Gm-Message-State: AOJu0Yy7nNJ2baUsSBo9Z/L3whBByda9TkvMSXDD8tUusLM5H0DHJFXy +G475kJPt+V5Hnbm2gxEFmAuC4NPMZ+1crzLPYKQglLpXiXKJgs42ks2ZRmnbroMaZDCc2OUw+j KzMiRUmpv06GrQLZ5PlT51adWGgCx4gKC12iTBbs33RWyp/hn X-Google-Smtp-Source: AGHT+IEKn4+dQB74jmJ44E/F68sTWhZ7+a6Qi4B8j4sxne0OAlLmsLpGV4/h1jYkpkdAqp7PD7ZMRkJgekyc X-Received: by 2002:a17:90b:4b83:b0:2d3:d68e:e8d8 with SMTP id 98e67ed59e1d1-2dd7f752757mr12444210a91.40.1727116971829; Mon, 23 Sep 2024 11:42:51 -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 98e67ed59e1d1-2dd7f7d960esm482396a91.8.2024.09.23.11.42.51 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Sep 2024 11:42:51 -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 D99BA605C351; Mon, 23 Sep 2024 14:42:50 -0400 (EDT) From: jspewock@iol.unh.edu To: npratte@iol.unh.edu, juraj.linkes@pantheon.tech, yoan.picchi@foss.arm.com, thomas@monjalon.net, Honnappa.Nagarahalli@arm.com, probb@iol.unh.edu, wathsala.vithanage@arm.com, paul.szczepanek@arm.com, Luca.Vizzarro@arm.com, alex.chapman@arm.com Cc: dev@dpdk.org, Jeremy Spewock Subject: [PATCH v4 2/5] dts: parameterize what ports the TG sends packets to Date: Mon, 23 Sep 2024 14:42:32 -0400 Message-ID: <20240923184235.22582-3-jspewock@iol.unh.edu> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240923184235.22582-1-jspewock@iol.unh.edu> References: <20240821191557.18744-1-jspewock@iol.unh.edu> <20240923184235.22582-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 | 48 +++++++++++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 10 deletions(-) diff --git a/dts/framework/test_suite.py b/dts/framework/test_suite.py index 051509fb86..9b707ca46d 100644 --- a/dts/framework/test_suite.py +++ b/dts/framework/test_suite.py @@ -186,6 +186,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. @@ -196,14 +198,16 @@ 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. """ return self.send_packets_and_capture( - [packet], - filter_config, - duration, + [packet], filter_config, duration, sut_ingress, sut_egress ) def send_packets_and_capture( @@ -211,6 +215,8 @@ def send_packets_and_capture( packets: list[Packet], filter_config: PacketFilteringConfig = PacketFilteringConfig(), duration: float = 1, + sut_ingress: Port | None = None, + sut_egress: Port | None = None, ) -> list[Packet]: """Send and receive `packets` using the associated TG. @@ -221,11 +227,19 @@ def send_packets_and_capture( packets: The packets 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. """ - packets = [self._adjust_addresses(packet) for packet in packets] + if sut_ingress is None: + sut_ingress = self._sut_port_ingress + if sut_egress is None: + sut_egress = self._sut_port_egress + packets = [self._adjust_addresses(packet, sut_ingress, sut_egress) for packet in packets] return self.tg_node.send_packets_and_capture( packets, self._tg_port_egress, @@ -234,18 +248,30 @@ def send_packets_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: @@ -255,11 +281,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 @@ -270,7 +298,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