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 6D61B45760; Wed, 7 Aug 2024 21:18:22 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EA4B140E4D; Wed, 7 Aug 2024 21:18:12 +0200 (CEST) Received: from mail-qv1-f43.google.com (mail-qv1-f43.google.com [209.85.219.43]) by mails.dpdk.org (Postfix) with ESMTP id 3100340E38 for ; Wed, 7 Aug 2024 21:18:12 +0200 (CEST) Received: by mail-qv1-f43.google.com with SMTP id 6a1803df08f44-6b79c27dd01so1487196d6.3 for ; Wed, 07 Aug 2024 12:18:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iol.unh.edu; s=unh-iol; t=1723058291; x=1723663091; 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=OtTXr7vMVw533/3sl4MM7Jo8GGrtKvZAoNMNOdgI/ms=; b=WtXvgEyI/l2QarlOU62PE5Vdq2hWHRcfyYsGelGhlNXYVwSLAHt0WpFThF9u9qWJGi GnAQyZlp/4zXL2+6mybT6gnlCBshbZ2pxkTs/V7DL4xlBpjXevF9F0x3s6vfMgWvTwKq gQfNc6BMhs7bsDgb1E5Hq/3MntoL4EGDzTEn8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723058291; x=1723663091; 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=OtTXr7vMVw533/3sl4MM7Jo8GGrtKvZAoNMNOdgI/ms=; b=obM9Ek2wbiTOZqV/CoqIVWlZhNVb01Go/7nHO/IoT2Z3ICwG+LBp1ouCDLFjwdOxRz /yY1XtO140bKckhuFWcgjJ0GDNfxErZAbOtKVNQXPUtQJQNyvaD/yjGkeq3lVEV2ocKo UwInUR/KxzWxzSWnXAnp8EwZAHbQiIDtKRdV50bz1eJYTzicWfBadigJOvy2ippPCpmH jX9b08pWv1Umtlfkah6ZAXk9fxXgSLVnTsaK5QPFEp/aAa7S5Xq2O+I3mlJx0nipxyyM nGJCXPpVreTmjHQ/v1DcuTQTjY6BpHFHVTK23c/9TyaQmffUrW+8yZj6JQoVOmwmn8YY weiw== X-Gm-Message-State: AOJu0YwhWC/P2qR0wMrRyJXC6Bfu52qMNX3kJpYrlWkXh+s22O4b3FPc bc69YZ5n7ph83PkZrszwYN44VAjyHvfNV0k0WYCHA2NMc/zBWo+fiH3WzowgyPg= X-Google-Smtp-Source: AGHT+IH7z+B4Tpp0nG3E8vZSkx2ZoCr+IKt8ivwCgri0xaulU1FxCqIlTYce10hWJHLK22H5mpEOcQ== X-Received: by 2002:a05:6214:5988:b0:6b7:9401:bb7d with SMTP id 6a1803df08f44-6bb98406be8mr227272886d6.37.1723058291358; Wed, 07 Aug 2024 12:18:11 -0700 (PDT) Received: from dean-laptop.iol.unh.edu ([2606:4100:3880:1271:f9bd:24da:464d:6294]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6bb9c79744esm58839396d6.40.2024.08.07.12.18.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Aug 2024 12:18:10 -0700 (PDT) From: Dean Marx To: probb@iol.unh.edu, npratte@iol.unh.edu, jspewock@iol.unh.edu, luca.vizzarro@arm.com, yoan.picchi@foss.arm.com, Honnappa.Nagarahalli@arm.com, paul.szczepanek@arm.com, juraj.linkes@pantheon.tech Cc: dev@dpdk.org, Dean Marx Subject: [PATCH v6 2/2] dts: dynamic config test suite Date: Wed, 7 Aug 2024 15:18:18 -0400 Message-ID: <20240807191818.15978-3-dmarx@iol.unh.edu> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240807191818.15978-1-dmarx@iol.unh.edu> References: <20240724192129.29721-1-dmarx@iol.unh.edu> <20240807191818.15978-1-dmarx@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 Suite for testing ability of Poll Mode Driver to turn promiscuous mode on/off, allmulticast mode on/off, and show expected behavior when sending packets with known, unknown, broadcast, and multicast destination MAC addresses. Depends-on: patch-1142113 ("add send_packets to test suites and rework packet addressing") Signed-off-by: Dean Marx --- dts/framework/config/conf_yaml_schema.json | 3 +- dts/tests/TestSuite_dynamic_config.py | 145 +++++++++++++++++++++ 2 files changed, 147 insertions(+), 1 deletion(-) create mode 100644 dts/tests/TestSuite_dynamic_config.py diff --git a/dts/framework/config/conf_yaml_schema.json b/dts/framework/config/conf_yaml_schema.json index f02a310bb5..d7b4afed7d 100644 --- a/dts/framework/config/conf_yaml_schema.json +++ b/dts/framework/config/conf_yaml_schema.json @@ -187,7 +187,8 @@ "enum": [ "hello_world", "os_udp", - "pmd_buffer_scatter" + "pmd_buffer_scatter", + "dynamic_config" ] }, "test_target": { diff --git a/dts/tests/TestSuite_dynamic_config.py b/dts/tests/TestSuite_dynamic_config.py new file mode 100644 index 0000000000..55e2a2ba12 --- /dev/null +++ b/dts/tests/TestSuite_dynamic_config.py @@ -0,0 +1,145 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2024 University of New Hampshire + +"""Dynamic configuration capabilities test suite. + +This suite checks that it is possible to change the configuration of a port +dynamically. The Poll Mode Driver should be able to enable and disable +promiscuous mode on each port, as well as check the Rx and Tx packets of +each port. Promiscuous mode in networking passes all traffic a NIC receives +to the CPU, rather than just frames with matching MAC addresses. Each test +case sends a packet with a matching address, and one with an unknown address, +to ensure this behavior is shown. + +If packets should be received and forwarded, or received and not forwarded, +depending on the configuration, the port info should match the expected behavior. +""" + +from scapy.layers.inet import IP # type: ignore[import-untyped] +from scapy.layers.l2 import Ether # type: ignore[import-untyped] +from scapy.packet import Raw # type: ignore[import-untyped] + +from framework.params.testpmd import SimpleForwardingModes +from framework.remote_session.testpmd_shell import TestPmdShell +from framework.test_suite import TestSuite + + +class TestDynamicConfig(TestSuite): + """Dynamic config suite. + + Use the show port commands to see the MAC address and promisc mode status + of the Rx port on the DUT. The suite will check the Rx and Tx packets + of each port after configuring promiscuous, multicast, and default mode + on the DUT to verify the expected behavior. It consists of four test cases: + + 1. Default mode: verify packets are received and forwarded. + 2. Disable promiscuous mode: verify that packets are received + only for the packet with destination address matching the port address. + 3. Disable promiscuous mode broadcast: verify that packets with destination + MAC address not matching the port are received and not forwarded, and verify + that broadcast packets are received and forwarded. + 4. Disable promiscuous mode multicast: verify that packets with destination + MAC address not matching the port are received and not forwarded, and verify + that multicast packets are received and forwarded. + """ + + def set_up_suite(self) -> None: + """Set up the test suite. + + Setup: + Verify that at least two ports are open for session. + """ + self.verify(len(self._port_links) > 1, "Not enough ports") + + def send_packet_and_verify(self, should_receive: bool, mac_address: str) -> None: + """Generate, send and verify packets. + + Generate a packet and send to the DUT, verify that packet is forwarded from DUT to + traffic generator if that behavior is expected. + + Args: + should_receive: Indicate whether the packet should be received. + mac_address: Destination MAC address to generate in packet. + """ + packet = Ether(dst=mac_address) / IP() / Raw(load="xxxxx") + received = self.send_packet_and_capture(packet) + contains_packet = any( + packet.haslayer(Raw) and b"xxxxx" in packet.load for packet in received + ) + self.verify( + should_receive == contains_packet, + f"Packet was {'dropped' if should_receive else 'received'}", + ) + + def disable_promisc_setup(self, testpmd: TestPmdShell, port_id: int) -> TestPmdShell: + """Sets up testpmd shell config for cases where promisc mode is disabled. + + Args: + testpmd: Testpmd session that is being configured. + port_id: Port number to disable promisc mode on. + + Returns: + TestPmdShell: interactive testpmd shell object. + """ + testpmd.start() + testpmd.set_promisc(port=port_id, on=False) + testpmd.set_forward_mode(SimpleForwardingModes.io) + return testpmd + + def test_default_mode(self) -> None: + """Tests default configuration. + + Creates a testpmd shell, verifies that promiscuous mode is enabled by default, + and sends two packets; one matching source MAC address and one unknown. + Verifies that both are received. + """ + with TestPmdShell(node=self.sut_node) as testpmd: + isPromisc = testpmd.show_port_info(0).is_promiscuous_mode_enabled + self.verify(isPromisc, "Promiscuous mode was not enabled by default.") + testpmd.start() + mac = testpmd.show_port_info(0).mac_address + # send a packet with Rx port mac address + self.send_packet_and_verify(should_receive=True, mac_address=str(mac)) + # send a packet with mismatched mac address + self.send_packet_and_verify(should_receive=True, mac_address="00:00:00:00:00:01") + + def test_disable_promisc(self) -> None: + """Tests disabled promiscuous mode configuration. + + Creates an interactive testpmd shell, disables promiscuous mode, + and sends two packets; one matching source MAC address and one unknown. + Verifies that only the matching address packet is received. + """ + with TestPmdShell(node=self.sut_node) as testpmd: + testpmd = self.disable_promisc_setup(testpmd=testpmd, port_id=0) + mac = testpmd.show_port_info(0).mac_address + self.send_packet_and_verify(should_receive=True, mac_address=str(mac)) + self.send_packet_and_verify(should_receive=False, mac_address="00:00:00:00:00:01") + + def test_disable_promisc_broadcast(self) -> None: + """Tests broadcast reception with disabled promisc mode config. + + Creates an interactive testpmd shell, disables promiscuous mode, + and sends two packets; one matching source MAC address and one broadcast. + Verifies that both packets are received. + """ + with TestPmdShell(node=self.sut_node) as testpmd: + testpmd = self.disable_promisc_setup(testpmd=testpmd, port_id=0) + mac = testpmd.show_port_info(0).mac_address + self.send_packet_and_verify(should_receive=True, mac_address=str(mac)) + self.send_packet_and_verify(should_receive=True, mac_address="ff:ff:ff:ff:ff:ff") + + def test_disable_promisc_multicast(self) -> None: + """Tests allmulticast mode with disabled promisc config. + + Creates an interactive testpmd shell, disables promiscuous mode, + and sends two packets; one matching source MAC address and one multicast. + Verifies that the multicast packet is only received once allmulticast mode is enabled. + """ + with TestPmdShell(node=self.sut_node) as testpmd: + testpmd = self.disable_promisc_setup(testpmd=testpmd, port_id=0) + testpmd.set_multicast_all(on=False) + # 01:00:5E:00:00:01 is the first of the multicast MAC range of addresses + self.send_packet_and_verify(should_receive=False, mac_address="01:00:5E:00:00:01") + testpmd.set_multicast_all(on=True) + self.send_packet_and_verify(should_receive=True, mac_address="01:00:05E:00:00:01") -- 2.44.0