From 7d9945e88463fbfb43fd9a9346ea4c9695d69153 Mon Sep 17 00:00:00 2001
From: Cedric Roux <cedric.roux@eurecom.fr>
Date: Wed, 15 Feb 2017 17:21:02 +0100
Subject: [PATCH] bugfix: fix PDCP inst

This commit is a continuation of 614d6bbe2af5c34f3bace7a8cb5003f07a8931b2
(ue_ip: use correct instance).

Now in openair2/NETWORK_DRIVER/UE_IP/common.c the 'inst' is not
forced to 1 anymore, we take the value 'pdcph_p->inst'.

It turns out that 'pdcph_p->inst' is 0 instead of 1 when we
run lte-softmodem as an UE.

So let's modify PDCP to set 'inst' to 1 where it was set to 0 for
the UE softmodem case, and skip the places where it is reset to 0,
still for the UE softmodem case.

This may break things, I am not sure.
---
 openair2/LAYER2/PDCP_v10.1.0/pdcp.c      | 3 +++
 openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c | 6 ++++--
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c
index 4c67f80e20..2ebdb839de 100644
--- a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c
+++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c
@@ -816,6 +816,9 @@ pdcp_data_ind(
         ((pdcp_data_ind_header_t *) new_sdu_p->data)->rb_id = rb_id;
 #if defined(OAI_EMU)
         ((pdcp_data_ind_header_t*) new_sdu_p->data)->inst  = ctxt_pP->module_id + oai_emulation.info.nb_enb_local - oai_emulation.info.first_ue_local;
+#else
+        /* TODO: inst is 1 for the UE or do we keep 0? Seems to be 1 but not sure */
+        ((pdcp_data_ind_header_t*) new_sdu_p->data)->inst  = 1;
 #endif
       } else {
         ((pdcp_data_ind_header_t*) new_sdu_p->data)->rb_id = rb_id + (ctxt_pP->module_id * maxDRB);
diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c
index e380bc6098..37b38121b9 100644
--- a/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c
+++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c
@@ -167,7 +167,8 @@ int pdcp_fifo_flush_sdus(const protocol_ctxt_t* const  ctxt_pP)
         ((pdcp_data_ind_header_t *) sdu_p->data)->data_size);
 #else
 #if ! defined(OAI_EMU)
-    ((pdcp_data_ind_header_t *)(sdu_p->data))->inst = 0;
+    /* TODO: do we have to reset to 0 or not? not for a scenario with 1 UE at least */
+//    ((pdcp_data_ind_header_t *)(sdu_p->data))->inst = 0;
 #endif
 #endif
 
@@ -571,7 +572,8 @@ int pdcp_fifo_read_input_sdus (const protocol_ctxt_t* const  ctxt_pP)
                   pdcp_read_header_g.inst - oai_emulation.info.nb_enb_local+ NB_eNB_INST + oai_emulation.info.first_ue_local :
                   pdcp_read_header_g.inst +  oai_emulation.info.first_enb_local;*/
 #else // OAI_EMU
-          pdcp_read_header_g.inst = 0;
+          /* TODO: do we have to reset to 0 or not? not for a scenario with 1 UE at least */
+//          pdcp_read_header_g.inst = 0;
 //#warning "TO DO CORRCT VALUES FOR ue mod id, enb mod id"
           ctxt.frame         = ctxt_cpy.frame;
           ctxt.enb_flag      = ctxt_cpy.enb_flag;
-- 
2.26.2