From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id CFC974608B;
	Wed, 15 Jan 2025 15:19:52 +0100 (CET)
Received: from mails.dpdk.org (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id 3C418402F2;
	Wed, 15 Jan 2025 15:19:39 +0100 (CET)
Received: from foss.arm.com (foss.arm.com [217.140.110.172])
 by mails.dpdk.org (Postfix) with ESMTP id CAFB8402DD
 for <dev@dpdk.org>; Wed, 15 Jan 2025 15:19:35 +0100 (CET)
Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14])
 by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B11B112FC;
 Wed, 15 Jan 2025 06:20:03 -0800 (PST)
Received: from localhost.localdomain (JR4XG4HTQC.cambridge.arm.com
 [10.1.39.16])
 by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 90F813F63F;
 Wed, 15 Jan 2025 06:19:34 -0800 (PST)
From: Luca Vizzarro <luca.vizzarro@arm.com>
To: dev@dpdk.org
Cc: Nicholas Pratte <npratte@iol.unh.edu>,
 Luca Vizzarro <luca.vizzarro@arm.com>,
 Paul Szczepanek <paul.szczepanek@arm.com>, Patrick Robb <probb@iol.unh.edu>
Subject: [PATCH v3 3/7] dts: infer use first core without config
Date: Wed, 15 Jan 2025 14:18:05 +0000
Message-ID: <20250115141809.3898708-4-luca.vizzarro@arm.com>
X-Mailer: git-send-email 2.43.0
In-Reply-To: <20250115141809.3898708-1-luca.vizzarro@arm.com>
References: <20240705171341.23894-2-npratte@iol.unh.edu>
 <20250115141809.3898708-1-luca.vizzarro@arm.com>
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 <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org

From: Nicholas Pratte <npratte@iol.unh.edu>

To further the simplification of the user configuration, use_first_core
can be inferred from the lcores. If the user explicitly includes the
core 0 in the lcores range, it will only then be used.

Bugzilla ID: 1360

Signed-off-by: Nicholas Pratte <npratte@iol.unh.edu>
Signed-off-by: Luca Vizzarro <luca.vizzarro@arm.com>
Reviewed-by: Paul Szczepanek <paul.szczepanek@arm.com>
---
 dts/conf.yaml                       |  3 +--
 dts/framework/config/__init__.py    | 19 ++++++++++++-------
 dts/framework/testbed_model/node.py |  9 +++++++++
 3 files changed, 22 insertions(+), 9 deletions(-)

diff --git a/dts/conf.yaml b/dts/conf.yaml
index 4b6965b3d7..c93eedbc94 100644
--- a/dts/conf.yaml
+++ b/dts/conf.yaml
@@ -40,8 +40,7 @@ nodes:
     hostname: sut1.change.me.localhost
     user: dtsuser
     os: linux
-    lcores: "" # use all the available logical cores
-    use_first_core: false # tells DPDK to use any physical core
+    lcores: "" # use all available logical cores (Skips first core)
     memory_channels: 4 # tells DPDK to use 4 memory channels
     hugepages_2mb: # optional; if removed, will use system hugepage configuration
         number_of: 256
diff --git a/dts/framework/config/__init__.py b/dts/framework/config/__init__.py
index 3fa8f4fa8f..5dfa0cf0d4 100644
--- a/dts/framework/config/__init__.py
+++ b/dts/framework/config/__init__.py
@@ -138,12 +138,12 @@ class ScapyTrafficGeneratorConfig(TrafficGeneratorConfig):
 #: A union type discriminating traffic generators by the `type` field.
 TrafficGeneratorConfigTypes = Annotated[ScapyTrafficGeneratorConfig, Field(discriminator="type")]
 
-#: Comma-separated list of logical cores to use. An empty string means use all lcores.
+#: Comma-separated list of logical cores to use. An empty string or ```any``` means use all lcores.
 LogicalCores = Annotated[
     str,
     Field(
-        examples=["1,2,3,4,5,18-22", "10-15"],
-        pattern=r"^(([0-9]+|([0-9]+-[0-9]+))(,([0-9]+|([0-9]+-[0-9]+)))*)?$",
+        examples=["1,2,3,4,5,18-22", "10-15", "any"],
+        pattern=r"^(([0-9]+|([0-9]+-[0-9]+))(,([0-9]+|([0-9]+-[0-9]+)))*)?$|any",
     ),
 ]
 
@@ -161,15 +161,20 @@ class NodeConfiguration(FrozenModel):
     password: str | None = None
     #: The operating system of the :class:`~framework.testbed_model.node.Node`.
     os: OS
-    #: A comma delimited list of logical cores to use when running DPDK.
-    lcores: LogicalCores = "1"
-    #: If :data:`True`, the first logical core won't be used.
-    use_first_core: bool = False
+    #: A comma delimited list of logical cores to use when running DPDK. ```any```, an empty
+    #: string or omitting this field means use any core except for the first one. The first core
+    #: will only be used if explicitly set.
+    lcores: LogicalCores = ""
     #: An optional hugepage configuration.
     hugepages: HugepageConfiguration | None = Field(None, alias="hugepages_2mb")
     #: The ports that can be used in testing.
     ports: list[PortConfig] = Field(min_length=1)
 
+    @property
+    def use_first_core(self) -> bool:
+        """Returns :data:`True` if `lcores` explicitly selects the first core."""
+        return "0" in self.lcores
+
 
 class SutNodeConfiguration(NodeConfiguration):
     """:class:`~framework.testbed_model.sut_node.SutNode` specific configuration."""
diff --git a/dts/framework/testbed_model/node.py b/dts/framework/testbed_model/node.py
index 08328ee482..b08b1cf14d 100644
--- a/dts/framework/testbed_model/node.py
+++ b/dts/framework/testbed_model/node.py
@@ -91,6 +91,15 @@ def __init__(self, node_config: NodeConfiguration):
             self.lcores, LogicalCoreList(self.config.lcores)
         ).filter()
 
+        if LogicalCore(lcore=0, core=0, socket=0, node=0) in self.lcores:
+            self._logger.info(
+                """
+                WARNING: First core being used;
+                using the first core is considered risky and should only
+                be done by advanced users.
+                """
+            )
+
         self._other_sessions = []
         self._init_ports()
 
-- 
2.43.0