From 2f28687d9e8c3dee9768c6077703e447717d2bb2 Mon Sep 17 00:00:00 2001
From: Romain Beurdouche <romain.beurdouche@eurecom.fr>
Date: Mon, 8 Jan 2024 11:47:08 +0100
Subject: [PATCH] feat(ldpc-offload-xdma): transport block decoding with XDMA
 enabled in nr-softmodem, tested with rfsim on experimental testbench

---
 executables/nr-gnb.c           |  2 ++
 executables/softmodem-common.h | 10 ++++++++++
 2 files changed, 12 insertions(+)

diff --git a/executables/nr-gnb.c b/executables/nr-gnb.c
index 35dcbde525..7ce307ea08 100644
--- a/executables/nr-gnb.c
+++ b/executables/nr-gnb.c
@@ -601,6 +601,8 @@ void init_eNB_afterRU(void) {
 
     gNB = RC.gNB[inst];
     gNB->ldpc_offload_flag = get_softmodem_params()->ldpc_offload_flag;
+    gNB->ldpc_xdma_flag = get_softmodem_params()->ldpc_xdma_flag;
+    gNB->ldpc_xdma_number_threads_predecoding = get_softmodem_params()->ldpc_xdma_num_thr;
     gNB->reorder_thread_disable = get_softmodem_params()->reorder_thread_disable;
 
     phy_init_nr_gNB(gNB);
diff --git a/executables/softmodem-common.h b/executables/softmodem-common.h
index b856bf252c..8d5f3e138c 100644
--- a/executables/softmodem-common.h
+++ b/executables/softmodem-common.h
@@ -111,6 +111,8 @@ extern "C"
 #define CONFIG_HLP_NID2          "Set NID2 value in Sidelink\n"
 #define CONFIG_HLP_NOITTI        "Do not start itti threads, call queue processing in place, inside the caller thread"
 #define CONFIG_HLP_LDPC_OFFLOAD  "Enable LDPC offload to AMD Xilinx T2 telco card\n"
+#define CONFIG_HLP_LDPC_XDMA_E   "Enable LDPC offload to Xilinx FPGA with XDMA driver\n"
+#define CONFIG_HLP_LDPC_XDMA_NT  "Number of threads for deinterleaving and rate dematching with decoding on Xilinx FPGA with XDMA driver\n"
 
 /*-----------------------------------------------------------------------------------------------------------------------------------------------------*/
 /*                                            command line parameters common to eNodeB and UE                                                          */
@@ -146,6 +148,8 @@ extern "C"
 #define NID1                softmodem_params.nid1
 #define NID2                softmodem_params.nid2
 #define LDPC_OFFLOAD_FLAG   softmodem_params.ldpc_offload_flag
+#define LDPC_XDMA_FLAG      softmodem_params.ldpc_xdma_flag
+#define LDPC_XDMA_NUM_THR   softmodem_params.ldpc_xdma_num_thr
 
 #define REORDER_THREAD_DISABLE    softmodem_params.reorder_thread_disable
 #define DEFAULT_RFCONFIG_FILE    "/usr/local/etc/syriq/ue.band7.tm1.PRB100.NR40.dat";
@@ -195,6 +199,8 @@ extern int usrp_tx_thread;
   {"nid2",                  CONFIG_HLP_NID2,          0,              .iptr=&NID2,                            .defintval=1,             TYPE_INT,    0},  \
   {"no-itti-threads",       CONFIG_HLP_NOITTI,        PARAMFLAG_BOOL, .iptr=&softmodem_params.no_itti,        .defintval=0,             TYPE_INT,    0},  \
   {"ldpc-offload-enable",   CONFIG_HLP_LDPC_OFFLOAD,  PARAMFLAG_BOOL, .iptr=&LDPC_OFFLOAD_FLAG,               .defstrval=0,             TYPE_INT,    0},  \
+  {"ldpc-xdma-enable",      CONFIG_HLP_LDPC_XDMA_E,   PARAMFLAG_BOOL, .iptr=&LDPC_XDMA_FLAG,                  .defintval=0,             TYPE_INT,    0},  \
+  {"ldpc-xdma-num-thr",     CONFIG_HLP_LDPC_XDMA_NT,  0,              .iptr=&LDPC_XDMA_NUM_THR,               .defintval=1,             TYPE_INT,    0},  \
 }
 // clang-format on
 
@@ -245,6 +251,8 @@ extern int usrp_tx_thread;
     { .s5 = { NULL } },                     \
     { .s5 = { NULL } },                     \
     { .s5 = { NULL } },                     \
+    { .s5 = { NULL } },                     \
+    { .s5 = { NULL } },                     \
 }
 // clang-format on
 
@@ -358,6 +366,8 @@ typedef struct {
   int            nid2;
   int no_itti;
   int ldpc_offload_flag;
+  int ldpc_xdma_flag;
+  int ldpc_xdma_num_thr;
 } softmodem_params_t;
 
 extern uint64_t get_softmodem_optmask(void);
-- 
2.26.2