From 2ac2a7f0745f59dafe695dd215a9fa3939168f4e Mon Sep 17 00:00:00 2001
From: Robert Schmidt <robert.schmidt@openairinterface.org>
Date: Sat, 18 Mar 2023 16:50:32 +0100
Subject: [PATCH] Make separate header for nr_pdcp instead of using 4G pdcp

Creates function that have nr_pdcp_ prepended to their name, and change
the signature of some functions for the 5G PDCP:

- nr_pdcp_layer_init()
- nr_pdcp_data_req()
- nr_pdcp_remove_UE()
- nr_pdcp_config_set_security()
- nr_pdcp_remove_UE()
- Make separate functions for nr_pdcp_data_req_srb/drb()
---
 doc/Doxyfile                                  |   1 +
 doc/SW_archi.md                               |  19 +--
 executables/lte-softmodem.c                   |  15 +++
 executables/nr-cuup.c                         |   4 +-
 executables/nr-softmodem.c                    |  11 +-
 executables/nr-ue.c                           |   6 +-
 executables/nr-uesoftmodem.c                  |   4 +-
 openair2/F1AP/f1ap_cu_rrc_message_transfer.c  |   2 +-
 openair2/F1AP/f1ap_cu_ue_context_management.c |   4 +-
 openair2/GNB_APP/gnb_app.c                    |   2 +-
 openair2/GNB_APP/gnb_config.c                 |   4 +-
 openair2/LAYER2/MAC/eNB_scheduler.c           |   2 +-
 openair2/LAYER2/NR_MAC_UE/main_ue_nr.c        |   4 +-
 openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c    |   5 +-
 .../LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c     |   2 -
 openair2/LAYER2/NR_MAC_gNB/main.c             |   5 +-
 openair2/LAYER2/PDCP_v10.1.0/pdcp.h           |   2 -
 openair2/LAYER2/nr_pdcp/asn1_utils.c          |   2 +-
 openair2/LAYER2/nr_pdcp/nr_pdcp_e1_api.h      |   2 +-
 openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c     | 127 +++++++++---------
 openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.h     | 103 ++++++++++++++
 openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c       |   2 +-
 openair2/LAYER2/openair2_proc.c               |   2 +-
 openair2/RRC/NR/L2_nr_interface.c             |   4 +-
 openair2/RRC/NR/nr_rrc_common.c               |   1 -
 openair2/RRC/NR/rrc_gNB.c                     |  32 ++---
 openair2/RRC/NR/rrc_gNB_NGAP.c                |  13 +-
 openair2/RRC/NR/rrc_gNB_nsa.c                 |   4 +-
 openair2/RRC/NR_UE/rrc_UE.c                   |  20 +--
 openair2/SDAP/nr_sdap/nr_sdap_entity.c        |  44 +++---
 openair3/ocp-gtpu/gtp_itf.cpp                 |   3 +-
 31 files changed, 269 insertions(+), 182 deletions(-)
 create mode 100644 openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.h

diff --git a/doc/Doxyfile b/doc/Doxyfile
index 6a4dd850a3f..afb89b43efe 100644
--- a/doc/Doxyfile
+++ b/doc/Doxyfile
@@ -1340,6 +1340,7 @@ INPUT                  = \
 @CMAKE_CURRENT_SOURCE_DIR@/../openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c \
 @CMAKE_CURRENT_SOURCE_DIR@/../openair2/LAYER2/NR_MAC_UE/mac_extern.h \
 @CMAKE_CURRENT_SOURCE_DIR@/../openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c \
+@CMAKE_CURRENT_SOURCE_DIR@/../openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.h \
 @CMAKE_CURRENT_SOURCE_DIR@/../openair2/LAYER2/nr_pdcp/nr_pdcp_entity.h \
 @CMAKE_CURRENT_SOURCE_DIR@/../openair2/LAYER2/nr_pdcp/nr_pdcp_timer_thread.h \
 @CMAKE_CURRENT_SOURCE_DIR@/../openair2/LAYER2/nr_pdcp/nr_pdcp_integrity_nia2.h \
diff --git a/doc/SW_archi.md b/doc/SW_archi.md
index 7f16edab116..1e8e5cd0110 100644
--- a/doc/SW_archi.md
+++ b/doc/SW_archi.md
@@ -327,25 +327,26 @@ successful_delivery() and max_retx_reached(): in ??? trigger, the RLC sends a it
 The PDCP implementation is also protected through a general mutex.  
 The design is very similar to rlc layer. The pdcp data is isolated and encapsulated.
 
-pdcp_layer_init(): same as rlc init  
+nr_pdcp_layer_init(): same as rlc init
 we have to call a second init function: pdcp_module_init() 
 
-At Tx side (DL in gNB), pdcp_data_req() is the entry function that the upper layer calls.  
+At Tx side (DL in gNB), `pdcp_data_req_drb()` and `pdcp_data_req_srb()` are the entry functions that the upper layer calls.
 The upper layer can be GTP or a PDCP internal thread enb_tun_read_thread() that read directly from Linux socket in case we skip 3GPP core implementation.
-PDCP internals for  pdcp_data_req() is thread safe: inside pdcp_data_req_drb(), the pdcp manager protects with the mutex the access to the SDU receiving function of PDCP (recv_sdu() callback, corresponding to nr_pdcp_entity_drb_am_recv_sdu() for DRBs). When it needs, the pdcp layer push this data to rlc by calling : rlc_data_req()  
+PDCP internals for  nr_pdcp_data_req_srb()/nr_pdcp_data_req_drb() are thread safe: inside them, the pdcp manager protects with the mutex the access to the SDU receiving function of PDCP (recv_sdu() callback, corresponding to nr_pdcp_entity_drb_am_recv_sdu() for DRBs). When it needs, the pdcp layer push this data to rlc by calling : rlc_data_req()
 
-Also, incoming downlink sdu can comme from internal RRC: in this case, pdcp_run() reads a itti queue, for message RRC_DCCH_DATA_REQ, to0 only call 'pdcp_data_req()'
+Also, incoming downlink sdu can comme from internal RRC: in this case, nr
+nr_pdcp_run() reads a itti queue, for message RRC_DCCH_DATA_REQ, to0 only call 'nr_pdcp_data_req_srb()'
 
 At Rx side, pdcp_data_ind() is the entry point that receives the data from RLC.
 - Inside pdcp_data_ind(), the pdcp manager mutex protects the access to the PDU receiving function of PDCP (recv_pdu() callback corresponding to nr_pdcp_entity_drb_am_recv_pdu() for DRBs)
 - Then deliver_sdu_drb() function sends the received data to GTP thread through an ITTI message (GTPV1U_TUNNEL_DATA_REQ).
 
-pdcp_config_set_security(): not yet developped
+nr_pdcp_config_set_security(): sets the keys for AS security of a UE
 
-nr_DRB_preconfiguration(): the mac layer calls this for ???
+nr_DRB_preconfiguration(): the mac layer calls this for configuration in phy-test/do-ra mode
 
-nr_pdcp_add_srbs() adds UE SRBs in pdcp, pdcp_remove_UE() removes it
-nr_pdcp_add_drbs() adds UE DRBs in pdcp, pdcp_remove_UE() removes it
+nr_pdcp_add_srbs() adds UE SRBs in pdcp, nr_pdcp_remove_UE() removes it
+nr_pdcp_add_drbs() adds UE DRBs in pdcp, nr_pdcp_remove_UE() removes it
 
 # GTP
 Gtp + UDP are two twin threads performing the data plane interface to the core network
@@ -357,7 +358,7 @@ PDCP layer push to the GTP queue (outside UDP thread that do almost nothing and
 
 
 ## GTP thread running code from other layers
-gtp thread calls directly pdcp_data_req(), so it runs inside it's context internal pdcp structures updates
+gtp thread calls directly nr_pdcp_data_req_drb(), so it runs inside it's context internal pdcp structures updates
 
 ## inside other threads
 gtpv1u_create_s1u_tunnel(), delete tunnel, ... functions are called inside the other threads, without mutex.
diff --git a/executables/lte-softmodem.c b/executables/lte-softmodem.c
index 6d75f0acbd7..0c04456e272 100644
--- a/executables/lte-softmodem.c
+++ b/executables/lte-softmodem.c
@@ -181,6 +181,21 @@ bool sdap_data_req(protocol_ctxt_t *ctxt_p,
   abort();
 }
 
+/* hack: gtp_itf.cpp requires this empty function to be defined here */
+bool nr_pdcp_data_req_drb(protocol_ctxt_t *ctxt_pP,
+                          const srb_flag_t srb_flagP,
+                          const rb_id_t rb_id,
+                          const mui_t muiP,
+                          const confirm_t confirmP,
+                          const sdu_size_t sdu_buffer_size,
+                          unsigned char *const sdu_buffer,
+                          const pdcp_transmission_mode_t mode,
+                          const uint32_t *const sourceL2Id,
+                          const uint32_t *const destinationL2Id)
+{
+  abort();
+}
+
 /* forward declarations */
 void set_default_frame_parms(LTE_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]);
 
diff --git a/executables/nr-cuup.c b/executables/nr-cuup.c
index 25ebe6df135..34eae858107 100644
--- a/executables/nr-cuup.c
+++ b/executables/nr-cuup.c
@@ -28,7 +28,7 @@
 #include "nfapi/oai_integration/vendor_ext.h"
 #include "openair2/F1AP/f1ap_common.h"
 #include "openair2/GNB_APP/gnb_config.h"
-#include "pdcp.h"
+#include "nr_pdcp/nr_pdcp_oai_api.h"
 
 RAN_CONTEXT_t RC;
 THREAD_STRUCT thread_struct;
@@ -147,7 +147,7 @@ int main(int argc, char **argv)
   AssertFatal(rc >= 0, "Create task for GTPV1U failed\n");
   rc = itti_create_task(TASK_CUUP_E1, E1AP_CUUP_task, NULL);
   AssertFatal(rc >= 0, "Create task for CUUP E1 failed\n");
-  pdcp_layer_init();
+  nr_pdcp_layer_init();
   MessageDef *msg = RCconfig_NR_CU_E1(true);
   AssertFatal(msg != NULL, "Send init to task for E1AP UP failed\n");
   itti_send_msg_to_task(TASK_CUUP_E1, 0, msg);
diff --git a/executables/nr-softmodem.c b/executables/nr-softmodem.c
index 120a7c0e65d..455bf839045 100644
--- a/executables/nr-softmodem.c
+++ b/executables/nr-softmodem.c
@@ -59,7 +59,7 @@ unsigned short config_frames[4] = {2,9,11,13};
 #include "common/utils/LOG/log.h"
 #include "common/utils/LOG/vcd_signal_dumper.h"
 #include "UTIL/OPT/opt.h"
-#include "pdcp.h"
+#include "LAYER2/nr_pdcp/nr_pdcp_oai_api.h"
 
 #include "intertask_interface.h"
 
@@ -556,13 +556,8 @@ void init_pdcp(void) {
     PDCP_USE_NETLINK_BIT | LINK_ENB_PDCP_TO_IP_DRIVER_BIT | ENB_NAS_USE_TUN_BIT | SOFTMODEM_NOKRNMOD_BIT:
     LINK_ENB_PDCP_TO_GTPV1U_BIT;
   
-  if (!get_softmodem_params()->nsa) {
-    if (!NODE_IS_DU(get_node_type())) {
-      pdcp_layer_init();
-      nr_pdcp_module_init(pdcp_initmask, 0);
-    }
-  } else {
-    pdcp_layer_init();
+  if (!NODE_IS_DU(get_node_type())) {
+    nr_pdcp_layer_init();
     nr_pdcp_module_init(pdcp_initmask, 0);
   }
 }
diff --git a/executables/nr-ue.c b/executables/nr-ue.c
index 075789e12b1..a1ec29a42a0 100644
--- a/executables/nr-ue.c
+++ b/executables/nr-ue.c
@@ -33,7 +33,7 @@
 #include "executables/softmodem-common.h"
 #include "PHY/NR_REFSIG/refsig_defs_ue.h"
 #include "radio/COMMON/common_lib.h"
-#include "pdcp.h"
+#include "LAYER2/nr_pdcp/nr_pdcp_oai_api.h"
 
 /*
  *  NR SLOT PROCESSING SEQUENCE
@@ -359,7 +359,7 @@ static void *NRUE_phy_stub_standalone_pnf_task(void *arg)
       NR_UE_MAC_INST_t *mac = get_mac_inst(0);
       protocol_ctxt_t ctxt;
       PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, 0, ENB_FLAG_NO, mac->crnti, frame, slot, 0);
-      pdcp_run(&ctxt);
+      nr_pdcp_run(&ctxt);
     }
     process_queued_nr_nfapi_msgs(mac, sfn_slot);
   }
@@ -627,7 +627,7 @@ void UE_processing(nr_rxtx_thread_data_t *rxtxD) {
       NR_UE_MAC_INST_t *mac = get_mac_inst(0);
       protocol_ctxt_t ctxt;
       PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, UE->Mod_id, ENB_FLAG_NO, mac->crnti, proc->frame_rx, proc->nr_slot_rx, 0);
-      pdcp_run(&ctxt);
+      nr_pdcp_run(&ctxt);
     }
   }
 
diff --git a/executables/nr-uesoftmodem.c b/executables/nr-uesoftmodem.c
index eb6e160ec33..7169881ed05 100644
--- a/executables/nr-uesoftmodem.c
+++ b/executables/nr-uesoftmodem.c
@@ -59,7 +59,7 @@ unsigned short config_frames[4] = {2,9,11,13};
 
 #include "UTIL/OPT/opt.h"
 #include "enb_config.h"
-#include "pdcp.h"
+#include "LAYER2/nr_pdcp/nr_pdcp_oai_api.h"
 
 #include "intertask_interface.h"
 
@@ -386,7 +386,7 @@ static void init_pdcp(int ue_id) {
   if (get_softmodem_params()->nsa && rlc_module_init(0) != 0) {
     LOG_I(RLC, "Problem at RLC initiation \n");
   }
-  pdcp_layer_init();
+  nr_pdcp_layer_init();
   nr_pdcp_module_init(pdcp_initmask, ue_id);
   pdcp_set_rlc_data_req_func((send_rlc_data_req_func_t) rlc_data_req);
   pdcp_set_pdcp_data_ind_func((pdcp_data_ind_func_t) pdcp_data_ind);
diff --git a/openair2/F1AP/f1ap_cu_rrc_message_transfer.c b/openair2/F1AP/f1ap_cu_rrc_message_transfer.c
index f1e0a7ade15..7fc30967de8 100644
--- a/openair2/F1AP/f1ap_cu_rrc_message_transfer.c
+++ b/openair2/F1AP/f1ap_cu_rrc_message_transfer.c
@@ -37,7 +37,7 @@
 #include "f1ap_cu_rrc_message_transfer.h"
 #include "common/ran_context.h"
 #include "openair3/UTILS/conversions.h"
-#include "pdcp.h"
+#include "LAYER2/nr_pdcp/nr_pdcp_oai_api.h"
 
 /*
     Initial UL RRC Message Transfer
diff --git a/openair2/F1AP/f1ap_cu_ue_context_management.c b/openair2/F1AP/f1ap_cu_ue_context_management.c
index 0cb476b2d7c..bfa48a4f880 100644
--- a/openair2/F1AP/f1ap_cu_ue_context_management.c
+++ b/openair2/F1AP/f1ap_cu_ue_context_management.c
@@ -40,7 +40,7 @@
 #include "rrc_extern.h"
 #include "openair2/RRC/NR/rrc_gNB_NGAP.h"
 #include <openair3/ocp-gtpu/gtp_itf.h>
-#include "pdcp.h"
+#include "LAYER2/nr_pdcp/nr_pdcp_oai_api.h"
 
 static void setQos(F1AP_NonDynamic5QIDescriptor_t *toFill) {
   asn1cCalloc(toFill, tmp);
@@ -958,7 +958,7 @@ int CU_handle_UE_CONTEXT_RELEASE_COMPLETE(instance_t       instance,
     LOG_E(F1AP, "could not find ue_context of UE RNTI %x\n", rnti);
   }
 
-  pdcp_remove_UE(&ctxt);
+  nr_pdcp_remove_UE(ctxt.rntiMaybeUEid);
 
   LOG_I(F1AP, "Received UE CONTEXT RELEASE COMPLETE: Removing CU UE entry for RNTI %x\n", rnti);
   f1ap_remove_ue(CUtype, instance, rnti);
diff --git a/openair2/GNB_APP/gnb_app.c b/openair2/GNB_APP/gnb_app.c
index 6404b264180..84cbf0d424d 100644
--- a/openair2/GNB_APP/gnb_app.c
+++ b/openair2/GNB_APP/gnb_app.c
@@ -49,7 +49,7 @@
 #include "f1ap_du_task.h"
 #include "nfapi/oai_integration/vendor_ext.h"
 #include <openair2/LAYER2/nr_pdcp/nr_pdcp.h>
-#include "openair2/LAYER2/PDCP_v10.1.0/pdcp.h"
+#include "openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.h"
 #include "openair2/E1AP/e1ap.h"
 #include "gnb_config.h"
 extern unsigned char NB_gNB_INST;
diff --git a/openair2/GNB_APP/gnb_config.c b/openair2/GNB_APP/gnb_config.c
index 46044ca6df0..97eae398429 100644
--- a/openair2/GNB_APP/gnb_config.c
+++ b/openair2/GNB_APP/gnb_config.c
@@ -54,7 +54,7 @@
 #include "radio/ETHERNET/USERSPACE/LIB/ethernet_lib.h"
 #include "nfapi_vnf.h"
 #include "nfapi_pnf.h"
-#include "pdcp.h"
+#include "nr_pdcp/nr_pdcp_oai_api.h"
 
 //#include "L1_paramdef.h"
 #include "prs_nr_paramdef.h"
@@ -2244,6 +2244,6 @@ void nr_read_config_and_init(void) {
   }
 
   if (NODE_IS_CU(RC.nrrrc[0]->node_type) && RC.nrrrc[0]->node_type != ngran_gNB_CUCP) {
-    pdcp_layer_init();
+    nr_pdcp_layer_init();
   }
 }
diff --git a/openair2/LAYER2/MAC/eNB_scheduler.c b/openair2/LAYER2/MAC/eNB_scheduler.c
index badcd36cc64..e56b3d4f6f1 100644
--- a/openair2/LAYER2/MAC/eNB_scheduler.c
+++ b/openair2/LAYER2/MAC/eNB_scheduler.c
@@ -958,7 +958,7 @@ eNB_dlsch_ulsch_scheduler(module_id_t module_idP,
   void rlc_tick(int, int);
   PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, module_idP, ENB_FLAG_YES, NOT_A_RNTI, frameP, subframeP, module_idP);
   rlc_tick(frameP, subframeP);
-  pdcp_run(&ctxt);
+  //pdcp_run(&ctxt);
   pdcp_mbms_run(&ctxt);
   rrc_rx_tx(&ctxt, CC_id);
 #endif
diff --git a/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c b/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c
index 7fb2295f2da..2babe56ec84 100644
--- a/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c
+++ b/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c
@@ -38,7 +38,7 @@
 #include "openair2/LAYER2/nr_pdcp/nr_pdcp_entity.h"
 #include "executables/softmodem-common.h"
 #include "openair2/LAYER2/nr_pdcp/nr_pdcp.h"
-#include "openair2/LAYER2/PDCP_v10.1.0/pdcp.h"
+#include "openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.h"
 #include <pthread.h>
 
 static NR_UE_MAC_INST_t *nr_ue_mac_inst; 
@@ -65,7 +65,7 @@ NR_UE_MAC_INST_t * nr_l2_init_ue(NR_UE_RRC_INST_t* rrc_inst) {
       nr_rrc_mac_config_req_ue(0,0,0,NULL,NULL,NULL,rrc_inst->scell_group_config);
       AssertFatal(rlc_module_init(0) == 0, "%s: Could not initialize RLC layer\n", __FUNCTION__);
       if (IS_SOFTMODEM_NOS1){
-        pdcp_layer_init();
+        nr_pdcp_layer_init();
         nr_DRB_preconfiguration(nr_ue_mac_inst->crnti);
         nr_ue_mac_inst->logicalChannelBearer_exist[0] = true;
       }
diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c
index c641bf4d15e..4a5b4cc6264 100644
--- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c
+++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c
@@ -42,8 +42,7 @@
 
 #include "RRC/NR/nr_rrc_extern.h"
 
-//#include "LAYER2/MAC/pre_processor.c"
-#include "pdcp.h"
+#include "nr_pdcp/nr_pdcp_oai_api.h"
 
 #include "intertask_interface.h"
 
@@ -137,7 +136,7 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP,
   start_meas(&gNB->eNB_scheduler);
   VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_gNB_DLSCH_ULSCH_SCHEDULER,VCD_FUNCTION_IN);
 
-  pdcp_run(&ctxt);
+  nr_pdcp_run(&ctxt);
   /* send tick to RLC and RRC every ms */
   if ((slot & ((1 << *scc->ssbSubcarrierSpacing) - 1)) == 0) {
     void nr_rlc_tick(int frame, int subframe);
diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c
index 32242236317..121ad179cc4 100644
--- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c
+++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c
@@ -42,8 +42,6 @@
 #include "common/utils/nr/nr_common.h"
 
 
-#include "pdcp.h"
-
 #define ENABLE_MAC_PAYLOAD_DEBUG
 #define DEBUG_eNB_SCHEDULER 1
 
diff --git a/openair2/LAYER2/NR_MAC_gNB/main.c b/openair2/LAYER2/NR_MAC_gNB/main.c
index f78e7f224f6..5dcaffce94b 100644
--- a/openair2/LAYER2/NR_MAC_gNB/main.c
+++ b/openair2/LAYER2/NR_MAC_gNB/main.c
@@ -33,9 +33,8 @@
 #include "NR_MAC_gNB/mac_proto.h"
 #include "NR_MAC_COMMON/nr_mac_extern.h"
 #include "assertions.h"
-#include "pdcp.h"
+#include "nr_pdcp/nr_pdcp_oai_api.h"
 
-#include "LAYER2/nr_pdcp/nr_pdcp_entity.h"
 #include "RRC/NR/nr_rrc_defs.h"
 #include "common/utils/LOG/log.h"
 //#include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h"
@@ -250,7 +249,7 @@ void mac_top_init_gNB(ngran_node_t node_type)
     AssertFatal(rlc_module_init(1) == 0,"Could not initialize RLC layer\n");
 
     // These should be out of here later
-    if (get_softmodem_params()->usim_test == 0 ) pdcp_layer_init();
+    if (get_softmodem_params()->usim_test == 0 ) nr_pdcp_layer_init();
 
     if(IS_SOFTMODEM_NOS1 && get_softmodem_params()->phy_test)
       nr_DRB_preconfiguration(0x1234);
diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp.h b/openair2/LAYER2/PDCP_v10.1.0/pdcp.h
index b4303d1fdd8..043ac7fb4a5 100644
--- a/openair2/LAYER2/PDCP_v10.1.0/pdcp.h
+++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp.h
@@ -402,9 +402,7 @@ void pdcp_mbms_run            (
 void pdcp_run            (
   const protocol_ctxt_t *const  ctxt_pP);
 uint64_t pdcp_module_init (uint64_t pdcp_optmask, int ue_id);
-uint64_t nr_pdcp_module_init(uint64_t _pdcp_optmask, int id);
 void pdcp_module_cleanup (void);
-void nr_ip_over_LTE_DRB_preconfiguration (void);
 void pdcp_layer_init     (void);
 void pdcp_layer_cleanup  (void);
 #define PDCP2NW_DRIVER_FIFO 21
diff --git a/openair2/LAYER2/nr_pdcp/asn1_utils.c b/openair2/LAYER2/nr_pdcp/asn1_utils.c
index 264a2815bb2..ab0cdf48fd5 100644
--- a/openair2/LAYER2/nr_pdcp/asn1_utils.c
+++ b/openair2/LAYER2/nr_pdcp/asn1_utils.c
@@ -19,7 +19,7 @@
  *      contact@openairinterface.org
  */
 
-#include "pdcp.h"
+#include "common/utils/LOG/log.h"
 
 int decode_t_reordering(int v)
 {
diff --git a/openair2/LAYER2/nr_pdcp/nr_pdcp_e1_api.h b/openair2/LAYER2/nr_pdcp/nr_pdcp_e1_api.h
index 68b146efeba..f45f3f04588 100644
--- a/openair2/LAYER2/nr_pdcp/nr_pdcp_e1_api.h
+++ b/openair2/LAYER2/nr_pdcp/nr_pdcp_e1_api.h
@@ -25,7 +25,7 @@
 #include "common/utils/oai_asn1.h"
 #include "NR_RadioBearerConfig.h"
 
-#include "pdcp.h"
+#include "nr_pdcp_oai_api.h"
 #include "LAYER2/nr_rlc/nr_rlc_oai_api.h"
 #include <openair3/ocp-gtpu/gtp_itf.h>
 #include "openair2/SDAP/nr_sdap/nr_sdap.h"
diff --git a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c
index 702aabd528c..3b198ff17c1 100644
--- a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c
+++ b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c
@@ -34,7 +34,7 @@
 
 /* from OAI */
 #include "oai_asn1.h"
-#include "pdcp.h"
+#include "nr_pdcp_oai_api.h"
 #include "LAYER2/nr_rlc/nr_rlc_oai_api.h"
 #include <openair3/ocp-gtpu/gtp_itf.h>
 #include "openair2/SDAP/nr_sdap/nr_sdap.h"
@@ -73,7 +73,7 @@ static ngran_node_t node_type;
 /* NR PDCP and RLC both use "big locks". In some cases a thread may do
  * lock(rlc) followed by lock(pdcp) (typically when running 'rx_sdu').
  * Another thread may first do lock(pdcp) and then lock(rlc) (typically
- * the GTP module calls 'pdcp_data_req' that, in a previous implementation
+ * the GTP module calls 'nr_pdcp_data_req' that, in a previous implementation
  * was indirectly calling 'rlc_data_req' which does lock(rlc)).
  * To avoid the resulting deadlock it is enough to ensure that a call
  * to lock(pdcp) will never be followed by a call to lock(rlc). So,
@@ -531,7 +531,13 @@ static void set_node_type() {
   node_type = get_node_type();
 }
 
+/* hack: dummy function needed due to LTE dependencies */
 void pdcp_layer_init(void)
+{
+  abort();
+}
+
+void nr_pdcp_layer_init(void)
 {
   /* hack: be sure to initialize only once */
   static pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER;
@@ -789,7 +795,7 @@ srb_found:
   }
 }
 
-void pdcp_run(const protocol_ctxt_t *const  ctxt_pP)
+void nr_pdcp_run(const protocol_ctxt_t *const  ctxt_pP)
 {
   MessageDef      *msg_p;
   int             result;
@@ -811,15 +817,11 @@ void pdcp_run(const protocol_ctxt_t *const  ctxt_pP)
           RRC_DCCH_DATA_REQ(msg_p).frame,
           0,
           RRC_DCCH_DATA_REQ(msg_p).eNB_index);
-      result = pdcp_data_req(&ctxt,
-                             SRB_FLAG_YES,
-                             RRC_DCCH_DATA_REQ(msg_p).rb_id,
-                             RRC_DCCH_DATA_REQ(msg_p).muip,
-                             RRC_DCCH_DATA_REQ(msg_p).confirmp,
-                             RRC_DCCH_DATA_REQ(msg_p).sdu_size,
-                             RRC_DCCH_DATA_REQ(msg_p).sdu_p,
-                             RRC_DCCH_DATA_REQ(msg_p).mode,
-                             NULL, NULL);
+      result = nr_pdcp_data_req_srb(ctxt.rntiMaybeUEid,
+                                    RRC_DCCH_DATA_REQ(msg_p).rb_id,
+                                    RRC_DCCH_DATA_REQ(msg_p).muip,
+                                    RRC_DCCH_DATA_REQ(msg_p).sdu_size,
+                                    RRC_DCCH_DATA_REQ(msg_p).sdu_p);
 
       if (result != true)
         LOG_E(PDCP, "PDCP data request failed!\n");
@@ -1118,30 +1120,43 @@ uint64_t get_pdcp_optmask(void)
   return pdcp_optmask;
 }
 
+/* hack: dummy function needed due to LTE dependencies */
 bool pdcp_remove_UE(const protocol_ctxt_t *const ctxt_pP)
 {
-  ue_id_t rntiMaybeUEid = ctxt_pP->rntiMaybeUEid;
+  abort();
+}
 
+bool nr_pdcp_remove_UE(ue_id_t ue_id)
+{
   nr_pdcp_manager_lock(nr_pdcp_ue_manager);
-  nr_pdcp_manager_remove_ue(nr_pdcp_ue_manager, rntiMaybeUEid);
+  nr_pdcp_manager_remove_ue(nr_pdcp_ue_manager, ue_id);
   nr_pdcp_manager_unlock(nr_pdcp_ue_manager);
 
   return 1;
 }
 
-void pdcp_config_set_security(
-        const protocol_ctxt_t* const  ctxt_pP,
-        pdcp_t *const pdcp_pP,
-        const rb_id_t rb_id,
-        const uint16_t lc_idP,
-        const uint8_t security_modeP,
-        uint8_t *const kRRCenc_pP,
-        uint8_t *const kRRCint_pP,
-        uint8_t *const kUPenc_pP)
+/* hack: dummy function needed due to LTE dependencies */
+void pdcp_config_set_security(const protocol_ctxt_t *const ctxt_pP,
+                                 pdcp_t *const pdcp_pP,
+                                 const rb_id_t rb_id,
+                                 const uint16_t lc_idP,
+                                 const uint8_t security_modeP,
+                                 uint8_t *const kRRCenc_pP,
+                                 uint8_t *const kRRCint_pP,
+                                 uint8_t *const kUPenc_pP)
+{
+  abort();
+}
+
+void nr_pdcp_config_set_security(ue_id_t ue_id,
+                                 const rb_id_t rb_id,
+                                 const uint8_t security_modeP,
+                                 uint8_t *const kRRCenc_pP,
+                                 uint8_t *const kRRCint_pP,
+                                 uint8_t *const kUPenc_pP)
 {
   nr_pdcp_ue_t *ue;
   nr_pdcp_entity_t *rb;
-  ue_id_t ue_id = ctxt_pP->rntiMaybeUEid;
   int integrity_algorithm;
   int ciphering_algorithm;
 
@@ -1173,27 +1188,15 @@ void pdcp_config_set_security(
   nr_pdcp_manager_unlock(nr_pdcp_ue_manager);
 }
 
-static bool pdcp_data_req_srb(protocol_ctxt_t  *ctxt_pP,
-                              const rb_id_t rb_id,
-                              const mui_t muiP,
-                              const confirm_t confirmP,
-                              const sdu_size_t sdu_buffer_size,
-                              unsigned char *const sdu_buffer)
+bool nr_pdcp_data_req_srb(ue_id_t ue_id,
+                          const rb_id_t rb_id,
+                          const mui_t muiP,
+                          const sdu_size_t sdu_buffer_size,
+                          unsigned char *const sdu_buffer)
 {
   LOG_D(PDCP, "%s() called, size %d\n", __func__, sdu_buffer_size);
   nr_pdcp_ue_t *ue;
   nr_pdcp_entity_t *rb;
-  ue_id_t ue_id = ctxt_pP->rntiMaybeUEid;
-
-  if (ctxt_pP->module_id != 0 ||
-      //ctxt_pP->enb_flag != 1 ||
-      ctxt_pP->instance != 0 ||
-      ctxt_pP->eNB_index != 0 /*||
-      ctxt_pP->configured != 1 ||
-      ctxt_pP->brOption != 0*/) {
-    LOG_E(PDCP, "%s:%d:%s: fatal\n", __FILE__, __LINE__, __FUNCTION__);
-    exit(1);
-  }
 
   nr_pdcp_manager_lock(nr_pdcp_ue_manager);
 
@@ -1217,14 +1220,19 @@ static bool pdcp_data_req_srb(protocol_ctxt_t  *ctxt_pP,
   return 1;
 }
 
-
-static bool pdcp_data_req_drb(protocol_ctxt_t  *ctxt_pP,
-                              const rb_id_t rb_id,
-                              const mui_t muiP,
-                              const confirm_t confirmP,
-                              const sdu_size_t sdu_buffer_size,
-                              unsigned char *const sdu_buffer)
+bool nr_pdcp_data_req_drb(protocol_ctxt_t *ctxt_pP,
+                          const srb_flag_t srb_flagP,
+                          const rb_id_t rb_id,
+                          const mui_t muiP,
+                          const confirm_t confirmP,
+                          const sdu_size_t sdu_buffer_size,
+                          unsigned char *const sdu_buffer,
+                          const pdcp_transmission_mode_t mode,
+                          const uint32_t *const sourceL2Id,
+                          const uint32_t *const destinationL2Id)
 {
+  DevAssert(srb_flagP == SRB_FLAG_NO);
+
   LOG_D(PDCP, "%s() called, size %d\n", __func__, sdu_buffer_size);
   nr_pdcp_ue_t *ue;
   nr_pdcp_entity_t *rb;
@@ -1288,23 +1296,20 @@ bool cu_f1u_data_req(protocol_ctxt_t  *ctxt_pP,
   return ret;
 }
 
+/* hack: dummy function needed due to LTE dependencies */
 bool pdcp_data_req(protocol_ctxt_t  *ctxt_pP,
-                   const srb_flag_t srb_flagP,
-                   const rb_id_t rb_id,
-                   const mui_t muiP,
-                   const confirm_t confirmP,
-                   const sdu_size_t sdu_buffer_size,
-                   unsigned char *const sdu_buffer,
-                   const pdcp_transmission_mode_t mode,
+                   const srb_flag_t     srb_flagP,
+                   const rb_id_t        rb_idP,
+                   const mui_t          muiP,
+                   const confirm_t      confirmP,
+                   const sdu_size_t     sdu_buffer_sizeP,
+                   unsigned char *const sdu_buffer_pP,
+                   const pdcp_transmission_mode_t modeP,
                    const uint32_t *const sourceL2Id,
                    const uint32_t *const destinationL2Id)
 {
-  if (srb_flagP) {
-   return pdcp_data_req_srb(ctxt_pP, rb_id, muiP, confirmP, sdu_buffer_size, sdu_buffer);
-  }
-  else{
-    return pdcp_data_req_drb(ctxt_pP, rb_id, muiP, confirmP, sdu_buffer_size, sdu_buffer);
-  }
+  abort();
+  return false;
 }
 
 void pdcp_set_pdcp_data_ind_func(pdcp_data_ind_func_t pdcp_data_ind)
diff --git a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.h b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.h
new file mode 100644
index 00000000000..56462297c13
--- /dev/null
+++ b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.h
@@ -0,0 +1,103 @@
+/*
+ * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The OpenAirInterface Software Alliance licenses this file to You under
+ * the OAI Public License, Version 1.1  (the "License"); you may not use this file
+ * except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.openairinterface.org/?page_id=698
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *-------------------------------------------------------------------------------
+ * For more information about the OpenAirInterface (OAI) Software Alliance:
+ *      contact@openairinterface.org
+ */
+
+#ifndef NR_PDCP_OAI_API_H
+#define NR_PDCP_OAI_API_H
+
+#include "pdcp.h"
+#include "nr_pdcp_ue_manager.h"
+
+void nr_pdcp_layer_init(void);
+uint64_t nr_pdcp_module_init(uint64_t _pdcp_optmask, int id);
+
+void du_rlc_data_req(const protocol_ctxt_t *const ctxt_pP,
+                     const srb_flag_t   srb_flagP,
+                     const MBMS_flag_t  MBMS_flagP,
+                     const rb_id_t      rb_idP,
+                     const mui_t        muiP,
+                     confirm_t    confirmP,
+                     sdu_size_t   sdu_sizeP,
+                     mem_block_t *sdu_pP);
+
+bool pdcp_data_ind(const protocol_ctxt_t *const  ctxt_pP,
+                   const srb_flag_t srb_flagP,
+                   const MBMS_flag_t MBMS_flagP,
+                   const rb_id_t rb_id,
+                   const sdu_size_t sdu_buffer_size,
+                   mem_block_t *const sdu_buffer,
+                   const uint32_t *const srcID,
+                   const uint32_t *const dstID);
+
+void nr_pdcp_add_drbs(eNB_flag_t enb_flag,
+                      ue_id_t rntiMaybeUEid,
+                      ue_id_t reestablish_ue_id,
+                      NR_DRB_ToAddModList_t *const drb2add_list,
+                      const uint8_t security_modeP,
+                      uint8_t *const kUPenc,
+                      uint8_t *const kUPint,
+                      struct NR_CellGroupConfig__rlc_BearerToAddModList *rlc_bearer2add_list);
+
+void nr_DRB_preconfiguration(ue_id_t crntiMaybeUEid);
+
+bool nr_pdcp_remove_UE(ue_id_t ue_id);
+
+void nr_pdcp_config_set_security(ue_id_t ue_id,
+                                 const rb_id_t rb_id,
+                                 const uint8_t security_modeP,
+                                 uint8_t *const kRRCenc_pP,
+                                 uint8_t *const kRRCint_pP,
+                                 uint8_t *const kUPenc_pP);
+
+bool cu_f1u_data_req(protocol_ctxt_t  *ctxt_pP,
+                     const srb_flag_t srb_flagP,
+                     const rb_id_t rb_id,
+                     const mui_t muiP,
+                     const confirm_t confirmP,
+                     const sdu_size_t sdu_buffer_size,
+                     unsigned char *const sdu_buffer,
+                     const pdcp_transmission_mode_t mode,
+                     const uint32_t *const sourceL2Id,
+                     const uint32_t *const destinationL2Id);
+
+bool nr_pdcp_data_req_srb(ue_id_t ue_id,
+                          const rb_id_t rb_id,
+                          const mui_t muiP,
+                          const sdu_size_t sdu_buffer_size,
+                          unsigned char *const sdu_buffer);
+bool nr_pdcp_data_req_drb(protocol_ctxt_t *ctxt_pP,
+                          const srb_flag_t srb_flagP,
+                          const rb_id_t rb_id,
+                          const mui_t muiP,
+                          const confirm_t confirmP,
+                          const sdu_size_t sdu_buffer_size,
+                          unsigned char *const sdu_buffer,
+                          const pdcp_transmission_mode_t mode,
+                          const uint32_t *const sourceL2Id,
+                          const uint32_t *const destinationL2Id);
+
+void nr_pdcp_run(const protocol_ctxt_t *const ctxt_pP);
+void nr_pdcp_tick(int frame, int subframe);
+
+nr_pdcp_ue_manager_t *nr_pdcp_sdap_get_ue_manager();
+
+const bool nr_pdcp_get_statistics(ue_id_t ue_id, int srb_flag, int rb_id, nr_pdcp_statistics_t *out);
+
+#endif /* NR_PDCP_OAI_API_H */
diff --git a/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c b/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c
index dab6f9fe581..103044f1bc7 100644
--- a/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c
+++ b/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c
@@ -21,7 +21,7 @@
 
 /* from openair */
 #include "rlc.h"
-#include "pdcp.h"
+#include "LAYER2/nr_pdcp/nr_pdcp_oai_api.h"
 
 /* from nr rlc module */
 #include "nr_rlc_asn1_utils.h"
diff --git a/openair2/LAYER2/openair2_proc.c b/openair2/LAYER2/openair2_proc.c
index 6ef447df5f8..d68232b2e2d 100644
--- a/openair2/LAYER2/openair2_proc.c
+++ b/openair2/LAYER2/openair2_proc.c
@@ -34,7 +34,7 @@
 #include "LAYER2/RLC/rlc.h"
 #include "LAYER2/MAC/mac.h"
 #include "LAYER2/MAC/mac_extern.h"
-#include "LAYER2/PDCP_v10.1.0/pdcp.h"
+#include "LAYER2/nr_pdcp/nr_pdcp_oai_api.h"
 #include "common/utils/LOG/log.h"
 #include "common/ran_context.h"
 
diff --git a/openair2/RRC/NR/L2_nr_interface.c b/openair2/RRC/NR/L2_nr_interface.c
index 4a88b153bdc..3554cb37158 100644
--- a/openair2/RRC/NR/L2_nr_interface.c
+++ b/openair2/RRC/NR/L2_nr_interface.c
@@ -32,7 +32,6 @@
 #include "nr_rrc_defs.h"
 #include "nr_rrc_extern.h"
 #include "common/utils/LOG/log.h"
-#include "pdcp.h"
 #include "common/ran_context.h"
 #include "LAYER2/NR_MAC_COMMON/nr_mac_common.h"
 #include "LAYER2/NR_MAC_COMMON/nr_mac_extern.h"
@@ -43,6 +42,7 @@
 #include "NR_BCCH-BCH-Message.h"
 #include "rrc_gNB_UE_context.h"
 #include <openair2/RRC/NR/MESSAGES/asn1_msg.h>
+#include "nr_pdcp/nr_pdcp_oai_api.h"
 
 
 extern RAN_CONTEXT_t RC;
@@ -100,7 +100,7 @@ nr_rrc_data_req(
    * Ideally, PDCP would not neet to be triggered like this but react to ITTI
    * messages automatically */
   if (ctxt_pP->enb_flag)
-    pdcp_run(ctxt_pP);
+    nr_pdcp_run(ctxt_pP);
 
   return true; // TODO should be changed to a CNF message later, currently RRC lite does not used the returned value anyway.
 }
diff --git a/openair2/RRC/NR/nr_rrc_common.c b/openair2/RRC/NR/nr_rrc_common.c
index 1d231f20bfd..c6f27c73256 100644
--- a/openair2/RRC/NR/nr_rrc_common.c
+++ b/openair2/RRC/NR/nr_rrc_common.c
@@ -37,7 +37,6 @@
 #include "COMMON/mac_rrc_primitives.h"
 #include "common/utils/LOG/log.h"
 #include "asn1_msg.h"
-#include "pdcp.h"
 #include "common/utils/LOG/vcd_signal_dumper.h"
 #include "common/ran_context.h"
 
diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c
index a4f57b0faed..c3afed5f6b9 100644
--- a/openair2/RRC/NR/rrc_gNB.c
+++ b/openair2/RRC/NR/rrc_gNB.c
@@ -82,7 +82,7 @@
 #include "rrc_gNB_GTPV1U.h"
 
 #include "nr_pdcp/nr_pdcp_entity.h"
-#include "pdcp.h"
+#include "nr_pdcp/nr_pdcp_oai_api.h"
 
 #include "intertask_interface.h"
 #include "SIMULATION/TOOLS/sim.h" // for taus
@@ -105,15 +105,6 @@
 
 extern RAN_CONTEXT_t RC;
 
-extern void pdcp_config_set_security(const protocol_ctxt_t *const ctxt_pP,
-                                     pdcp_t *const pdcp_pP,
-                                     const rb_id_t rb_idP,
-                                     const uint16_t lc_idP,
-                                     const uint8_t security_modeP,
-                                     uint8_t *const kRRCenc,
-                                     uint8_t *const kRRCint,
-                                     uint8_t *const  kUPenc);
-
 static inline uint64_t bitStr_to_uint64(BIT_STRING_t *asn);
 
 mui_t                               rrc_gNB_mui = 0;
@@ -1289,14 +1280,15 @@ void rrc_gNB_generate_RRCReestablishment(const protocol_ctxt_t *ctxt_pP,
   } // if (*SRB_configList != NULL)
 
   LOG_I(NR_RRC, "Set PDCP security RNTI %04lx nca %ld nia %d in RRCReestablishment\n", ctxt_pP->rntiMaybeUEid, ue_p->ciphering_algorithm, ue_p->integrity_algorithm);
-  pdcp_config_set_security(ctxt_pP,
-                           NULL, /* pdcp_pP not used anymore in NR */
-                           DCCH,
-                           DCCH + 2,
-                           enable_ciphering ? ue_p->ciphering_algorithm | (ue_p->integrity_algorithm << 4) : 0 | (ue_p->integrity_algorithm << 4),
-                           kRRCenc,
-                           kRRCint,
-                           kUPenc);
+  uint8_t security_mode =
+      enable_ciphering ? ue_p->ciphering_algorithm | (ue_p->integrity_algorithm << 4) : 0 | (ue_p->integrity_algorithm << 4);
+
+  nr_pdcp_config_set_security(ctxt_pP->rntiMaybeUEid,
+                              DCCH,
+                              security_mode,
+                              kRRCenc,
+                              kRRCint,
+                              kUPenc);
 
   if (!NODE_IS_CU(rrc->node_type)) {
     apply_macrlc_config_reest(rrc, ue_context_pP, ctxt_pP, ctxt_pP->rntiMaybeUEid);
@@ -3225,7 +3217,7 @@ void nr_rrc_subframe_process(protocol_ctxt_t *const ctxt_pP, const int CC_id) {
             gNB_MAC_INST *nrmac = RC.nrmac[ctxt_pP->module_id]; // WHAT A BEAUTIFULL RACE CONDITION !!!
             mac_remove_nr_ue(nrmac, UE->rnti);
             rrc_rlc_remove_ue(ctxt_pP);
-            pdcp_remove_UE(ctxt_pP);
+            nr_pdcp_remove_UE(ctxt_pP->rntiMaybeUEid);
 
             /* remove RRC UE Context */
             ue_context_p = rrc_gNB_get_ue_context_by_rnti(rrc, UE->rnti);
@@ -3262,7 +3254,7 @@ void nr_rrc_subframe_process(protocol_ctxt_t *const ctxt_pP, const int CC_id) {
           mac_remove_nr_ue(nrmac, UE->rnti);
         }
         rrc_rlc_remove_ue(ctxt_pP);
-        pdcp_remove_UE(ctxt_pP);
+        nr_pdcp_remove_UE(ctxt_pP->rntiMaybeUEid);
         newGtpuDeleteAllTunnels(ctxt_pP->instance, UE->rnti);
 
         /* remove RRC UE Context */
diff --git a/openair2/RRC/NR/rrc_gNB_NGAP.c b/openair2/RRC/NR/rrc_gNB_NGAP.c
index d3efb4b4974..f9d7a492f5a 100644
--- a/openair2/RRC/NR/rrc_gNB_NGAP.c
+++ b/openair2/RRC/NR/rrc_gNB_NGAP.c
@@ -36,7 +36,7 @@
 
 #include "oai_asn1.h"
 #include "intertask_interface.h"
-#include "pdcp.h"
+#include "nr_pdcp/nr_pdcp_oai_api.h"
 #include "pdcp_primitives.h"
 
 #include "openair3/ocp-gtpu/gtp_itf.h"
@@ -153,14 +153,9 @@ nr_rrc_pdcp_config_security(
     }
   }
 
-  pdcp_config_set_security(ctxt_pP,
-                           NULL, /* pdcp_pP not used anymore in NR */
-                           DCCH,
-                           DCCH + 2,
-                           enable_ciphering ? UE->ciphering_algorithm | (UE->integrity_algorithm << 4) : 0 | (UE->integrity_algorithm << 4),
-                           kRRCenc,
-                           kRRCint,
-                           kUPenc);
+  uint8_t security_mode =
+      enable_ciphering ? UE->ciphering_algorithm | (UE->integrity_algorithm << 4) : 0 | (UE->integrity_algorithm << 4);
+  nr_pdcp_config_set_security(ctxt_pP->rntiMaybeUEid, DCCH, security_mode, kRRCenc, kRRCint, kUPenc);
 }
 
 //------------------------------------------------------------------------------
diff --git a/openair2/RRC/NR/rrc_gNB_nsa.c b/openair2/RRC/NR/rrc_gNB_nsa.c
index 0a6eb050e52..989c754c20f 100644
--- a/openair2/RRC/NR/rrc_gNB_nsa.c
+++ b/openair2/RRC/NR/rrc_gNB_nsa.c
@@ -45,7 +45,7 @@
 #include <openair3/ocp-gtpu/gtp_itf.h>
 #include "UTIL/OSA/osa_defs.h"
 #include <openair2/RRC/NR/nr_rrc_proto.h>
-#include "pdcp.h"
+#include "nr_pdcp/nr_pdcp_oai_api.h"
 
 void rrc_parse_ue_capabilities(gNB_RRC_INST *rrc, NR_UE_CapabilityRAT_ContainerList_t *UE_CapabilityRAT_ContainerList, x2ap_ENDC_sgnb_addition_req_t *m, NR_CG_ConfigInfo_IEs_t *cg_config_info)
 {
@@ -391,7 +391,7 @@ void rrc_remove_nsa_user(gNB_RRC_INST *rrc, int rnti) {
     return;
   }
 
-  pdcp_remove_UE(&ctxt);
+  nr_pdcp_remove_UE(ctxt.rntiMaybeUEid);
 
   rrc_rlc_remove_ue(&ctxt);
 
diff --git a/openair2/RRC/NR_UE/rrc_UE.c b/openair2/RRC/NR_UE/rrc_UE.c
index ecbaeea17e7..3cff4e8c17a 100644
--- a/openair2/RRC/NR_UE/rrc_UE.c
+++ b/openair2/RRC/NR_UE/rrc_UE.c
@@ -58,7 +58,7 @@
 #include "nr-uesoftmodem.h"
 #include "executables/softmodem-common.h"
 #include "plmn_data.h"
-#include "pdcp.h"
+#include "nr_pdcp/nr_pdcp_oai_api.h"
 #include "UTIL/OSA/osa_defs.h"
 #include "common/utils/LOG/log.h"
 #include "common/utils/LOG/vcd_signal_dumper.h"
@@ -90,17 +90,6 @@ static const char  nr_nas_attach_req_imsi[] = {
   0x01, 0x27, 0x11,
 };
 
-extern void pdcp_config_set_security(
-  const protocol_ctxt_t *const  ctxt_pP,
-  pdcp_t          *const pdcp_pP,
-  const rb_id_t         rb_idP,
-  const uint16_t        lc_idP,
-  const uint8_t         security_modeP,
-  uint8_t         *const kRRCenc,
-  uint8_t         *const kRRCint,
-  uint8_t         *const  kUPenc
-);
-
 void
 nr_rrc_ue_process_ueCapabilityEnquiry(
   const protocol_ctxt_t *const ctxt_pP,
@@ -1675,10 +1664,9 @@ int8_t nr_rrc_ue_decode_ccch( const protocol_ctxt_t *const ctxt_pP, const NR_SRB
    NR_UE_rrc_inst[ctxt_pP->module_id].kgnb[28], NR_UE_rrc_inst[ctxt_pP->module_id].kgnb[29], NR_UE_rrc_inst[ctxt_pP->module_id].kgnb[30], NR_UE_rrc_inst[ctxt_pP->module_id].kgnb[31]);
 
    if (securityMode != 0xff) {
-     pdcp_config_set_security(ctxt_pP, NULL, DCCH, DCCH+2,
-                              NR_UE_rrc_inst[ctxt_pP->module_id].cipheringAlgorithm
-                              | (NR_UE_rrc_inst[ctxt_pP->module_id].integrityProtAlgorithm << 4),
-                              kRRCenc, kRRCint, kUPenc);
+     uint8_t security_mode =
+         NR_UE_rrc_inst[ctxt_pP->module_id].cipheringAlgorithm | (NR_UE_rrc_inst[ctxt_pP->module_id].integrityProtAlgorithm << 4);
+     nr_pdcp_config_set_security(ctxt_pP->rntiMaybeUEid, DCCH, security_mode, kRRCenc, kRRCint, kUPenc);
    } else {
      LOG_I(NR_RRC, "skipped pdcp_config_set_security() as securityMode == 0x%02x", securityMode);
    }
diff --git a/openair2/SDAP/nr_sdap/nr_sdap_entity.c b/openair2/SDAP/nr_sdap/nr_sdap_entity.c
index 280663e2b09..357bec24ada 100644
--- a/openair2/SDAP/nr_sdap/nr_sdap_entity.c
+++ b/openair2/SDAP/nr_sdap/nr_sdap_entity.c
@@ -21,7 +21,7 @@
 
 #include "nr_sdap_entity.h"
 #include "common/utils/LOG/log.h"
-#include <openair2/LAYER2/PDCP_v10.1.0/pdcp.h>
+#include <openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.h>
 #include <openair3/ocp-gtpu/gtp_itf.h>
 #include "openair2/LAYER2/nr_pdcp/nr_pdcp_ue_manager.h"
 
@@ -37,8 +37,6 @@ static nr_sdap_entity_info sdap_info;
 
 instance_t *N3GTPUInst = NULL;
 
-nr_pdcp_ue_manager_t *nr_pdcp_sdap_get_ue_manager(void);
-
 void nr_pdcp_submit_sdap_ctrl_pdu(ue_id_t ue_id, rb_id_t sdap_ctrl_pdu_drb, nr_sdap_ul_hdr_t ctrl_pdu)
 {
   nr_pdcp_ue_t *ue;
@@ -87,16 +85,16 @@ static bool nr_sdap_tx_entity(nr_sdap_entity_t *entity,
 
   if(!pdcp_ent_has_sdap){
     LOG_D(SDAP, "TX - DRB ID: %ld does not have SDAP\n", entity->qfi2drb_table[qfi].drb_id);
-    ret = pdcp_data_req(ctxt_p,
-                        srb_flag,
-                        sdap_drb_id,
-                        mui,
-                        confirm,
-                        sdu_buffer_size,
-                        sdu_buffer,
-                        pt_mode,
-                        sourceL2Id,
-                        destinationL2Id);
+    ret = nr_pdcp_data_req_drb(ctxt_p,
+                               srb_flag,
+                               sdap_drb_id,
+                               mui,
+                               confirm,
+                               sdu_buffer_size,
+                               sdu_buffer,
+                               pt_mode,
+                               sourceL2Id,
+                               destinationL2Id);
 
     if(!ret)
       LOG_E(SDAP, "%s:%d:%s: PDCP refused PDU\n", __FILE__, __LINE__, __FUNCTION__);
@@ -155,16 +153,16 @@ static bool nr_sdap_tx_entity(nr_sdap_entity_t *entity,
    *
    * Downlink gNB side
    */
-  ret = pdcp_data_req(ctxt_p,
-                      srb_flag,
-                      sdap_drb_id,
-                      mui,
-                      confirm,
-                      sdu_buffer_size+offset,
-                      sdap_buf,
-                      pt_mode,
-                      sourceL2Id,
-                      destinationL2Id);
+  ret = nr_pdcp_data_req_drb(ctxt_p,
+                             srb_flag,
+                             sdap_drb_id,
+                             mui,
+                             confirm,
+                             sdu_buffer_size + offset,
+                             sdap_buf,
+                             pt_mode,
+                             sourceL2Id,
+                             destinationL2Id);
 
   if(!ret)
     LOG_E(SDAP, "%s:%d:%s: PDCP refused PDU\n", __FILE__, __LINE__, __FUNCTION__);
diff --git a/openair3/ocp-gtpu/gtp_itf.cpp b/openair3/ocp-gtpu/gtp_itf.cpp
index 2f60d5238c2..f6255fb0560 100644
--- a/openair3/ocp-gtpu/gtp_itf.cpp
+++ b/openair3/ocp-gtpu/gtp_itf.cpp
@@ -17,6 +17,7 @@ extern "C" {
 #include <openair2/COMMON/gtpv1_u_messages_types.h>
 #include <openair3/ocp-gtpu/gtp_itf.h>
 #include <openair2/LAYER2/PDCP_v10.1.0/pdcp.h>
+#include <openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.h>
 #include <openair2/LAYER2/nr_rlc/nr_rlc_oai_api.h>
 #include "openair2/SDAP/nr_sdap/nr_sdap.h"
 #include "sim.h"
@@ -748,7 +749,7 @@ int gtpv1u_create_ngu_tunnel(  const instance_t instance,
                                       create_tunnel_req->outgoing_qfi[i],
                                       create_tunnel_req->dst_addr[i],
                                       dstport,
-                                      pdcp_data_req,
+                                      nr_pdcp_data_req_drb,
                                       sdap_data_req);
     create_tunnel_resp->status=0;
     create_tunnel_resp->ue_id=create_tunnel_req->ue_id;
-- 
GitLab