From patchwork Wed Jul 19 14:12:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Juraj_Linke=C5=A1?= X-Patchwork-Id: 129642 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 1EBFD42EB9; Wed, 19 Jul 2023 16:13:19 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BA18042B8E; Wed, 19 Jul 2023 16:13:09 +0200 (CEST) Received: from mail-ed1-f46.google.com (mail-ed1-f46.google.com [209.85.208.46]) by mails.dpdk.org (Postfix) with ESMTP id 7F91740F16 for ; Wed, 19 Jul 2023 16:13:07 +0200 (CEST) Received: by mail-ed1-f46.google.com with SMTP id 4fb4d7f45d1cf-51f90f713b2so10425118a12.1 for ; Wed, 19 Jul 2023 07:13:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pantheon.tech; s=google; t=1689775987; x=1690380787; 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=0HoQxKjOSEmlpyi5I7Z/o2GdsKqCSB/veXBPkZGCVSI=; b=PS8B7wNfpnu9ZNb8PZOWKVXscNVdLbJxKWbuecBVoeJKspM4KAJzfsrz6H37rd61Li OJYUIYC+xUeZ4hrMvV2yMMw0j4/WaRKlzcwDCy5ZGgYEqVfXMxjXZUW7Cs651EhxR05R Ofmv1Qzfo0vvSnDXtMTlUxidLp4kj5rIH3lZRs6edonFSIqTSn19exmfao214WkN2yy2 YzvVPImNca4HEVOjLtzUAGRLHqTVruaAg2ydYrXKCqKkrcjNY4lszgxJuAY7hfGbxIJ1 VfTaMR3npyO+dSUOFDwyfPbrdMv6hv0S4EviPIAW4wU8Nkawk16o+Y9PRx9SysHT6C/C ZM3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689775987; x=1690380787; 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=0HoQxKjOSEmlpyi5I7Z/o2GdsKqCSB/veXBPkZGCVSI=; b=iKHv7cN8c85LnMRQqNRC3osf/DELE84INnnVHL5VYPhu/+GtnBV0G/F+T3Vzm+jIpl WVwM3Ck5T/iljpFx7N+tJI79WQEUasrSfFhNIQKCVf22NiF/2zv2kqNvpQAVbJV4n+op HczKV0JXusB88hcJoYNvz9XYEQqCJamkgj3zRpBJZfTFnbbsDFX8jBcKKxtaVJOZvF/k gaFn7AHAfgRNJkXk8xB1Nuy2dgNMgaoEePwHrWfKrF/BLgJsI665G8Bf4NPEvfLv0/Qu nXfF8Yd4z5nFHeWICcKMVSa1rcp+BDrE9Dck2bQFDQaxJdZtw5bWCpCl91X/HldGjTyh obLg== X-Gm-Message-State: ABy/qLa54BT8UgZAQdmCH+Vj3JnWng0ob6D+ZxBFzPWPiH7GwYIoeRoH XoKJILabVP0HzwF6/xLjt3qK3A== X-Google-Smtp-Source: APBJJlEbXv5seKxF6mIN5LUNu6CIGUjhErb60lo9I8fyeR4QKqSJtHznd2dPmbV8LnpBmnEn+UOZjQ== X-Received: by 2002:a05:6402:1b19:b0:51e:253e:1e0c with SMTP id by25-20020a0564021b1900b0051e253e1e0cmr2656819edb.25.1689775986935; Wed, 19 Jul 2023 07:13:06 -0700 (PDT) Received: from jlinkes-PT-Latitude-5530.. (ip-46.34.247.144.o2inet.sk. [46.34.247.144]) by smtp.gmail.com with ESMTPSA id q8-20020a056402040800b0051e2809395bsm2721979edv.63.2023.07.19.07.13.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Jul 2023 07:13:06 -0700 (PDT) From: =?utf-8?q?Juraj_Linke=C5=A1?= To: thomas@monjalon.net, Honnappa.Nagarahalli@arm.com, lijuan.tu@intel.com, bruce.richardson@intel.com, jspewock@iol.unh.edu, probb@iol.unh.edu Cc: dev@dpdk.org, =?utf-8?q?Juraj_Linke=C5=A1?= Subject: [PATCH v3 2/6] dts: add traffic generator config Date: Wed, 19 Jul 2023 16:12:59 +0200 Message-Id: <20230719141303.33284-3-juraj.linkes@pantheon.tech> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230719141303.33284-1-juraj.linkes@pantheon.tech> References: <20230717110709.39220-1-juraj.linkes@pantheon.tech> <20230719141303.33284-1-juraj.linkes@pantheon.tech> MIME-Version: 1.0 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 Node configuration - where to connect, what ports to use and what TG to use. Signed-off-by: Juraj Linkeš --- dts/conf.yaml | 26 ++++++- dts/framework/config/__init__.py | 84 +++++++++++++++++++--- dts/framework/config/conf_yaml_schema.json | 29 +++++++- dts/framework/dts.py | 12 ++-- dts/framework/testbed_model/sut_node.py | 5 +- 5 files changed, 135 insertions(+), 21 deletions(-) diff --git a/dts/conf.yaml b/dts/conf.yaml index 0825d958a6..0440d1d20a 100644 --- a/dts/conf.yaml +++ b/dts/conf.yaml @@ -13,10 +13,11 @@ executions: skip_smoke_tests: false # optional flag that allows you to skip smoke tests test_suites: - hello_world - system_under_test: + system_under_test_node: node_name: "SUT 1" vdevs: # optional; if removed, vdevs won't be used in the execution - "crypto_openssl" + traffic_generator_node: "TG 1" nodes: - name: "SUT 1" hostname: sut1.change.me.localhost @@ -40,3 +41,26 @@ nodes: os_driver: i40e peer_node: "TG 1" peer_pci: "0000:00:08.1" + - name: "TG 1" + hostname: tg1.change.me.localhost + user: dtsuser + arch: x86_64 + os: linux + lcores: "" + ports: + - pci: "0000:00:08.0" + os_driver_for_dpdk: rdma + os_driver: rdma + peer_node: "SUT 1" + peer_pci: "0000:00:08.0" + - pci: "0000:00:08.1" + os_driver_for_dpdk: rdma + os_driver: rdma + peer_node: "SUT 1" + peer_pci: "0000:00:08.1" + use_first_core: false + hugepages: # optional; if removed, will use system hugepage configuration + amount: 256 + force_first_numa: false + traffic_generator: + type: SCAPY diff --git a/dts/framework/config/__init__.py b/dts/framework/config/__init__.py index aa7ff358a2..9b5aff8509 100644 --- a/dts/framework/config/__init__.py +++ b/dts/framework/config/__init__.py @@ -12,7 +12,7 @@ import pathlib from dataclasses import dataclass from enum import auto, unique -from typing import Any, TypedDict +from typing import Any, TypedDict, Union import warlock # type: ignore import yaml @@ -54,6 +54,11 @@ class Compiler(StrEnum): msvc = auto() +@unique +class TrafficGeneratorType(StrEnum): + SCAPY = auto() + + # Slots enables some optimizations, by pre-allocating space for the defined # attributes in the underlying data structure. # @@ -79,6 +84,26 @@ def from_dict(node: str, d: dict) -> "PortConfig": return PortConfig(node=node, **d) +@dataclass(slots=True, frozen=True) +class TrafficGeneratorConfig: + traffic_generator_type: TrafficGeneratorType + + @staticmethod + def from_dict(d: dict): + # This looks useless now, but is designed to allow expansion to traffic + # generators that require more configuration later. + match TrafficGeneratorType(d["type"]): + case TrafficGeneratorType.SCAPY: + return ScapyTrafficGeneratorConfig( + traffic_generator_type=TrafficGeneratorType.SCAPY + ) + + +@dataclass(slots=True, frozen=True) +class ScapyTrafficGeneratorConfig(TrafficGeneratorConfig): + pass + + @dataclass(slots=True, frozen=True) class NodeConfiguration: name: str @@ -89,17 +114,17 @@ class NodeConfiguration: os: OS lcores: str use_first_core: bool - memory_channels: int hugepages: HugepageConfiguration | None ports: list[PortConfig] @staticmethod - def from_dict(d: dict) -> "NodeConfiguration": + def from_dict(d: dict) -> Union["SutNodeConfiguration", "TGNodeConfiguration"]: hugepage_config = d.get("hugepages") if hugepage_config: if "force_first_numa" not in hugepage_config: hugepage_config["force_first_numa"] = False hugepage_config = HugepageConfiguration(**hugepage_config) + common_config = { "name": d["name"], "hostname": d["hostname"], @@ -109,12 +134,31 @@ def from_dict(d: dict) -> "NodeConfiguration": "os": OS(d["os"]), "lcores": d.get("lcores", "1"), "use_first_core": d.get("use_first_core", False), - "memory_channels": d.get("memory_channels", 1), "hugepages": hugepage_config, "ports": [PortConfig.from_dict(d["name"], port) for port in d["ports"]], } - return NodeConfiguration(**common_config) + if "traffic_generator" in d: + return TGNodeConfiguration( + traffic_generator=TrafficGeneratorConfig.from_dict( + d["traffic_generator"] + ), + **common_config, + ) + else: + return SutNodeConfiguration( + memory_channels=d.get("memory_channels", 1), **common_config + ) + + +@dataclass(slots=True, frozen=True) +class SutNodeConfiguration(NodeConfiguration): + memory_channels: int + + +@dataclass(slots=True, frozen=True) +class TGNodeConfiguration(NodeConfiguration): + traffic_generator: ScapyTrafficGeneratorConfig @dataclass(slots=True, frozen=True) @@ -193,23 +237,40 @@ class ExecutionConfiguration: perf: bool func: bool test_suites: list[TestSuiteConfig] - system_under_test: NodeConfiguration + system_under_test_node: SutNodeConfiguration + traffic_generator_node: TGNodeConfiguration vdevs: list[str] skip_smoke_tests: bool @staticmethod - def from_dict(d: dict, node_map: dict) -> "ExecutionConfiguration": + def from_dict( + d: dict, node_map: dict[str, Union[SutNodeConfiguration | TGNodeConfiguration]] + ) -> "ExecutionConfiguration": build_targets: list[BuildTargetConfiguration] = list( map(BuildTargetConfiguration.from_dict, d["build_targets"]) ) test_suites: list[TestSuiteConfig] = list( map(TestSuiteConfig.from_dict, d["test_suites"]) ) - sut_name = d["system_under_test"]["node_name"] + sut_name = d["system_under_test_node"]["node_name"] skip_smoke_tests = d.get("skip_smoke_tests", False) assert sut_name in node_map, f"Unknown SUT {sut_name} in execution {d}" + system_under_test_node = node_map[sut_name] + assert isinstance( + system_under_test_node, SutNodeConfiguration + ), f"Invalid SUT configuration {system_under_test_node}" + + tg_name = d["traffic_generator_node"] + assert tg_name in node_map, f"Unknown TG {tg_name} in execution {d}" + traffic_generator_node = node_map[tg_name] + assert isinstance( + traffic_generator_node, TGNodeConfiguration + ), f"Invalid TG configuration {traffic_generator_node}" + vdevs = ( - d["system_under_test"]["vdevs"] if "vdevs" in d["system_under_test"] else [] + d["system_under_test_node"]["vdevs"] + if "vdevs" in d["system_under_test_node"] + else [] ) return ExecutionConfiguration( build_targets=build_targets, @@ -217,7 +278,8 @@ def from_dict(d: dict, node_map: dict) -> "ExecutionConfiguration": func=d["func"], skip_smoke_tests=skip_smoke_tests, test_suites=test_suites, - system_under_test=node_map[sut_name], + system_under_test_node=system_under_test_node, + traffic_generator_node=traffic_generator_node, vdevs=vdevs, ) @@ -228,7 +290,7 @@ class Configuration: @staticmethod def from_dict(d: dict) -> "Configuration": - nodes: list[NodeConfiguration] = list( + nodes: list[Union[SutNodeConfiguration | TGNodeConfiguration]] = list( map(NodeConfiguration.from_dict, d["nodes"]) ) assert len(nodes) > 0, "There must be a node to test" diff --git a/dts/framework/config/conf_yaml_schema.json b/dts/framework/config/conf_yaml_schema.json index 67722213dd..936a4bac5b 100644 --- a/dts/framework/config/conf_yaml_schema.json +++ b/dts/framework/config/conf_yaml_schema.json @@ -164,6 +164,11 @@ "amount" ] }, + "mac_address": { + "type": "string", + "description": "A MAC address", + "pattern": "^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$" + }, "pci_address": { "type": "string", "pattern": "^[\\da-fA-F]{4}:[\\da-fA-F]{2}:[\\da-fA-F]{2}.\\d:?\\w*$" @@ -286,6 +291,22 @@ ] }, "minimum": 1 + }, + "traffic_generator": { + "oneOf": [ + { + "type": "object", + "description": "Scapy traffic generator. Used for functional testing.", + "properties": { + "type": { + "type": "string", + "enum": [ + "SCAPY" + ] + } + } + } + ] } }, "additionalProperties": false, @@ -336,7 +357,7 @@ "description": "Optional field that allows you to skip smoke testing", "type": "boolean" }, - "system_under_test": { + "system_under_test_node": { "type":"object", "properties": { "node_name": { @@ -353,6 +374,9 @@ "required": [ "node_name" ] + }, + "traffic_generator_node": { + "$ref": "#/definitions/node_name" } }, "additionalProperties": false, @@ -361,7 +385,8 @@ "perf", "func", "test_suites", - "system_under_test" + "system_under_test_node", + "traffic_generator_node" ] }, "minimum": 1 diff --git a/dts/framework/dts.py b/dts/framework/dts.py index 3ba7fd2478..1c4a637fbd 100644 --- a/dts/framework/dts.py +++ b/dts/framework/dts.py @@ -38,17 +38,17 @@ def run_all() -> None: # for all Execution sections for execution in CONFIGURATION.executions: sut_node = None - if execution.system_under_test.name in nodes: + if execution.system_under_test_node.name in nodes: # a Node with the same name already exists - sut_node = nodes[execution.system_under_test.name] + sut_node = nodes[execution.system_under_test_node.name] else: # the SUT has not been initialized yet try: - sut_node = SutNode(execution.system_under_test) + sut_node = SutNode(execution.system_under_test_node) result.update_setup(Result.PASS) except Exception as e: dts_logger.exception( - f"Connection to node {execution.system_under_test} failed." + f"Connection to node {execution.system_under_test_node} failed." ) result.update_setup(Result.FAIL, e) else: @@ -87,7 +87,9 @@ def _run_execution( Run the given execution. This involves running the execution setup as well as running all build targets in the given execution. """ - dts_logger.info(f"Running execution with SUT '{execution.system_under_test.name}'.") + dts_logger.info( + f"Running execution with SUT '{execution.system_under_test_node.name}'." + ) execution_result = result.add_execution(sut_node.config) execution_result.add_sut_info(sut_node.node_info) diff --git a/dts/framework/testbed_model/sut_node.py b/dts/framework/testbed_model/sut_node.py index e3227d9bc2..ad3bffd9d3 100644 --- a/dts/framework/testbed_model/sut_node.py +++ b/dts/framework/testbed_model/sut_node.py @@ -12,8 +12,8 @@ from framework.config import ( BuildTargetConfiguration, BuildTargetInfo, - NodeConfiguration, NodeInfo, + SutNodeConfiguration, ) from framework.remote_session import CommandResult, InteractiveShellType, OSSession from framework.settings import SETTINGS @@ -77,6 +77,7 @@ class SutNode(Node): Another key capability is building DPDK according to given build target. """ + config: SutNodeConfiguration _dpdk_prefix_list: list[str] _dpdk_timestamp: str _build_target_config: BuildTargetConfiguration | None @@ -89,7 +90,7 @@ class SutNode(Node): _node_info: NodeInfo | None _compiler_version: str | None - def __init__(self, node_config: NodeConfiguration): + def __init__(self, node_config: SutNodeConfiguration): super(SutNode, self).__init__(node_config) self._dpdk_prefix_list = [] self._build_target_config = None