From 9091b004c31cb03b46cb7bc0b65d481a43bcd9ff Mon Sep 17 00:00:00 2001
From: Raymond Knopp <raymond.knopp@eurecom.fr>
Date: Mon, 13 Feb 2017 15:47:44 -0800
Subject: [PATCH] check for pdcch_order rballoc in eNB and allow special DCI
 instead of aborting.

---
 openair1/PHY/LTE_TRANSPORT/dci_tools.c    | 14 +++++++++++++-
 openair1/PHY/LTE_TRANSPORT/dlsch_coding.c |  3 ++-
 targets/RT/USER/lte-enb.c                 |  9 ++++++---
 3 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/openair1/PHY/LTE_TRANSPORT/dci_tools.c b/openair1/PHY/LTE_TRANSPORT/dci_tools.c
index b262dbccf90..82322bbf6cc 100644
--- a/openair1/PHY/LTE_TRANSPORT/dci_tools.c
+++ b/openair1/PHY/LTE_TRANSPORT/dci_tools.c
@@ -882,6 +882,7 @@ int generate_eNB_dlsch_params_from_dci(int frame,
   uint8_t rah=0;
   uint8_t TPC=0;
   LTE_DL_eNB_HARQ_t *dlsch0_harq=NULL,*dlsch1_harq=NULL;
+  int pdcch_order=0;
 
   //   printf("Generate eNB DCI, format %d, rnti %x (pdu %p)\n",dci_format,rnti,dci_pdu);
 
@@ -933,6 +934,7 @@ int generate_eNB_dlsch_params_from_dci(int frame,
       dlsch0_harq->nb_rb          = RIV2nb_rb_LUT6[rballoc];//NPRB;
       RIV_max = RIV_max6;
 
+      pdcch_order=31;
 
       break;
 
@@ -970,6 +972,9 @@ int generate_eNB_dlsch_params_from_dci(int frame,
       dlsch0_harq->vrb_type       = vrb_type;
       dlsch0_harq->nb_rb          = RIV2nb_rb_LUT25[rballoc];//NPRB;
       RIV_max                     = RIV_max25;
+
+      pdcch_order=511;
+
       break;
 
     case 50:
@@ -1006,6 +1011,9 @@ int generate_eNB_dlsch_params_from_dci(int frame,
       dlsch0_harq->vrb_type        = vrb_type;
       dlsch0_harq->nb_rb                               = RIV2nb_rb_LUT50[rballoc];//NPRB;
       RIV_max = RIV_max50;
+
+      pdcch_order=2047;
+
       break;
 
     case 100:
@@ -1045,6 +1053,9 @@ int generate_eNB_dlsch_params_from_dci(int frame,
 
       dlsch0_harq->nb_rb                               = RIV2nb_rb_LUT100[rballoc];//NPRB;
       RIV_max = RIV_max100;
+
+      pdcch_order=8191;
+
       break;
 
     default:
@@ -1066,7 +1077,8 @@ int generate_eNB_dlsch_params_from_dci(int frame,
         return(-1);
       }
 
-      if (rballoc>RIV_max) {
+      if ((rballoc>RIV_max)&&
+	  (rballoc!=pdcch_order))
         LOG_E(PHY,"ERROR: Format 1A: rb_alloc (%x) > RIV_max (%x)\n",rballoc,RIV_max);
         return(-1);
       }
diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c
index 8ec2a40d8de..22b4d66e1d1 100644
--- a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c
+++ b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c
@@ -506,6 +506,7 @@ int dlsch_encoding_2threads(PHY_VARS_eNB *eNB,
     }
   }
 
+
   // Fill in the "e"-sequence from 36-212, V8.6 2009-03, p. 16-17 (for each "e") and concatenate the
   // outputs for each code segment, see Section 5.1.5 p.20
 
@@ -543,10 +544,10 @@ int dlsch_encoding_2threads(PHY_VARS_eNB *eNB,
     }
   }
 
+
   // wait for worker to finish
 
   wait_on_busy_condition(&proc->mutex_te,&proc->cond_te,&proc->instance_cnt_te,"te thread");  
-
   
   VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ENCODING, VCD_FUNCTION_OUT);
 
diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c
index fd67ec1ee3b..5f321fb9af6 100644
--- a/targets/RT/USER/lte-enb.c
+++ b/targets/RT/USER/lte-enb.c
@@ -1743,12 +1743,15 @@ void init_eNB_proc(int inst) {
     }
     else {
       pthread_create(&proc->pthread_single, attr_single, eNB_thread_single, &eNB->proc);
-      init_fep_thread(eNB,attr_fep);
+      /*      init_fep_thread(eNB,attr_fep);
       init_td_thread(eNB,attr_td);
-      init_te_thread(eNB,attr_te);
+      init_te_thread(eNB,attr_te);*/
     }
     pthread_create( &proc->pthread_prach, attr_prach, eNB_thread_prach, &eNB->proc );
-    pthread_create( &proc->pthread_synch, attr_synch, eNB_thread_synch, eNB);
+    if ((eNB->is_slave) &&
+	((eNB->node_function >= NGFI_RRU_IF5)))
+	pthread_create( &proc->pthread_synch, attr_synch, eNB_thread_synch, eNB);
+
     if ((eNB->node_timing == synch_to_other) ||
 	(eNB->node_function == NGFI_RRU_IF5) ||
 	(eNB->node_function == NGFI_RRU_IF4p5))
-- 
GitLab