From b32b9e836f9ecbbfc6e3dc892433f7e975dd0b7b Mon Sep 17 00:00:00 2001
From: Robert Schmidt <robert.schmidt@openairinterface.org>
Date: Fri, 9 Feb 2024 12:42:19 +0100
Subject: [PATCH] O-RAN 7.2: make DPDK system core configurable

system_core is the core reserved for DPDK control threads. It was
hardcoded to 0, but it seems that one some systems, CPU 0 cannot be
reasonably isolated from kernel threads. Make it therefore configurable
(default: 0)

Closes: #732 (suggestion 1)
Suggested-by: Andrew Sergeev <andrew.sergeev@adtran.com>
---
 doc/ORAN_FHI7.2_Tutorial.md                                     | 2 ++
 radio/fhi_72/oran-config.c                                      | 2 +-
 radio/fhi_72/oran-params.h                                      | 2 ++
 .../CONF/gnb.sa.band77.273prb.fhi72.4x4-vvdn.conf               | 1 +
 .../CONF/gnb.sa.band78.273prb.fhi72.4x2-benetel650.conf         | 1 +
 .../CONF/gnb.sa.band78.273prb.fhi72.4x4-liteon.conf             | 1 +
 6 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/doc/ORAN_FHI7.2_Tutorial.md b/doc/ORAN_FHI7.2_Tutorial.md
index 77e3ae69f33..175123ea62c 100644
--- a/doc/ORAN_FHI7.2_Tutorial.md
+++ b/doc/ORAN_FHI7.2_Tutorial.md
@@ -601,6 +601,8 @@ Edit the sample OAI gNB configuration file and check following parameters:
   that is employed by the xRAN library (`xran_fh_init` and `xran_fh_config`
   structs in the code):
   * `dpdk_devices`: PCI addresses of NIC VFs binded to the DPDK
+  * `system_core`: absolute CPU core ID for DPDK control threads
+    (`rte_mp_handle`, `eal-intr-thread`, `iavf-event-thread`)
   * `io_core`: absolute CPU core ID for XRAN library
   * `worker_cores`: array of absolute CPU core IDs for XRAN library
   * `du_addr`: DU C- and U-plane MAC-addresses (format `UU:VV:WW:XX:YY:ZZ`,
diff --git a/radio/fhi_72/oran-config.c b/radio/fhi_72/oran-config.c
index 50a44c221c9..ec7eabc4593 100644
--- a/radio/fhi_72/oran-config.c
+++ b/radio/fhi_72/oran-config.c
@@ -500,7 +500,7 @@ static bool set_fh_io_cfg(struct xran_io_cfg *io_cfg, const paramdef_t *fhip, in
   io_cfg->dpdkIoVaMode = 0; /* IOVA mode */
   io_cfg->dpdkMemorySize = 0; /* DPDK memory size */
   io_cfg->core = *gpd(fhip, nump, ORAN_CONFIG_IO_CORE)->iptr;
-  io_cfg->system_core = 0; /* TODO how called in sample app? */
+  io_cfg->system_core = *gpd(fhip, nump, ORAN_CONFIG_SYSTEM_CORE)->iptr;
   io_cfg->pkt_proc_core = get_u64_mask(gpd(fhip, nump, ORAN_CONFIG_WORKER_CORES));
   io_cfg->pkt_proc_core_64_127 = 0x0; // bitmap 0 -> no core
   io_cfg->pkt_aux_core = 0; /* sapmle app says 0 = "do not start" */
diff --git a/radio/fhi_72/oran-params.h b/radio/fhi_72/oran-params.h
index 55157ec94e4..a3fb22267bc 100644
--- a/radio/fhi_72/oran-params.h
+++ b/radio/fhi_72/oran-params.h
@@ -28,6 +28,7 @@
 #define CONFIG_STRING_ORAN "fhi_72"
 
 #define ORAN_CONFIG_DPDK_DEVICES "dpdk_devices"
+#define ORAN_CONFIG_SYSTEM_CORE "system_core"
 #define ORAN_CONFIG_IO_CORE "io_core"
 #define ORAN_CONFIG_WORKER_CORES "worker_cores"
 #define ORAN_CONFIG_DU_ADDR "du_addr"
@@ -42,6 +43,7 @@
 // TODO: ethernet addr check
 #define ORAN_GLOBALPARAMS_DESC { \
   {ORAN_CONFIG_DPDK_DEVICES,    "PCI addr of devices for DPDK\n",           PARAMFLAG_MANDATORY, .strlistptr=NULL, .defstrlistval=NULL, TYPE_STRINGLIST, 0}, \
+  {ORAN_CONFIG_SYSTEM_CORE,     "DPDK control threads core\n",              PARAMFLAG_MANDATORY, .iptr=NULL,       .defintval=0,        TYPE_INT,        0}, \
   {ORAN_CONFIG_IO_CORE,         "DPDK Core used for IO\n",                  PARAMFLAG_MANDATORY, .iptr=NULL,       .defintval=4,        TYPE_INT,        0}, \
   {ORAN_CONFIG_WORKER_CORES,    "CPU Cores to use for workers\n",           PARAMFLAG_MANDATORY, .uptr=NULL,       .defintarrayval=NULL,TYPE_UINTARRAY,  0}, \
   {ORAN_CONFIG_DU_ADDR,         "Ether addr of DU\n",                       PARAMFLAG_MANDATORY, .strlistptr=NULL, .defstrlistval=NULL, TYPE_STRINGLIST, 0}, \
diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band77.273prb.fhi72.4x4-vvdn.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band77.273prb.fhi72.4x4-vvdn.conf
index 1e377e5664b..567637fb17d 100644
--- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band77.273prb.fhi72.4x4-vvdn.conf
+++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band77.273prb.fhi72.4x4-vvdn.conf
@@ -284,6 +284,7 @@ log_config : {
 
 fhi_72 = {
   dpdk_devices = ("0000:31:06.0", "0000:31:06.1");
+  system_core = 0;
   io_core = 4;
   worker_cores = (2);
   du_addr = ("76:76:64:6e:00:01", "76:76:64:6e:00:01");
diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.273prb.fhi72.4x2-benetel650.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.273prb.fhi72.4x2-benetel650.conf
index c362f05ac15..69625e0c40e 100644
--- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.273prb.fhi72.4x2-benetel650.conf
+++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.273prb.fhi72.4x2-benetel650.conf
@@ -272,6 +272,7 @@ log_config :
 
 fhi_72 = {
   dpdk_devices = ("0000:31:06.0", "0000:31:06.1");
+  system_core = 0;
   io_core = 4;
   worker_cores = (2);
   du_addr = ("00:11:22:33:44:66", "00:11:22:33:44:67");
diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.273prb.fhi72.4x4-liteon.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.273prb.fhi72.4x4-liteon.conf
index 5de3d3a4b52..59d85536a7d 100644
--- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.273prb.fhi72.4x4-liteon.conf
+++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.273prb.fhi72.4x4-liteon.conf
@@ -275,6 +275,7 @@ log_config :
 
 fhi_72 = {
   dpdk_devices = ("0000:31:06.0", "0000:31:06.1");
+  system_core = 0;
   io_core = 4;
   worker_cores = (2);
   du_addr = ("00:11:22:33:44:99", "00:11:22:33:44:99");
-- 
GitLab