From b4be5a4460ba40828ed7bab393023715344a070b Mon Sep 17 00:00:00 2001
From: Raymond Knopp <raymond.knopp@eurecom.fr>
Date: Thu, 5 Jul 2018 23:09:30 +0200
Subject: [PATCH] fixed ulsim for testcases

---
 cmake_targets/autotests/test_case_list.xml    | 12 +++++------
 .../CODING/3gpplte_turbo_decoder_sse_8bit.c   |  3 +--
 openair1/PHY/LTE_TRANSPORT/dci_tools.c        |  5 +++--
 openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c   |  5 +++--
 openair1/SCHED/phy_procedures_lte_eNb.c       |  6 +++---
 openair1/SIMULATION/LTE_PHY/ulsim.c           | 21 ++++++++++---------
 6 files changed, 27 insertions(+), 25 deletions(-)

diff --git a/cmake_targets/autotests/test_case_list.xml b/cmake_targets/autotests/test_case_list.xml
index 66c201119c..f0b3256015 100644
--- a/cmake_targets/autotests/test_case_list.xml
+++ b/cmake_targets/autotests/test_case_list.xml
@@ -990,12 +990,12 @@
       <pre_exec>$OPENAIR_DIR/cmake_targets/autotests/tools/free_mem.bash</pre_exec>
       <pre_exec_args></pre_exec_args>
       <main_exec> $OPENAIR_DIR/targets/bin/ulsim.Rel14</main_exec>
-      <main_exec_args> -B25 -m5 -y1 -gN -x1 -s6 -w1.0 -e.1 -P -n500 -O70 -L
-                       -B25 -m16 -y1 -gN -x1 -s12 -w1.0 -e.1 -P -n500 -O70 -L
-                        -B50 -m5 -y1 -gN -x1 -s6 -w1.0 -e.1 -P -n500 -O70 -L 
-                       -B50 -m16 -y1 -gN -x1 -s12 -w1.0 -e.1 -P -n500 -O70 -L
-                        -B100 -m5 -y1 -gN -x1 -s6 -w1.0 -e.1 -P -n500 -O70 -L
-                       -B100 -m16 -y1 -gN -x1 -s12 -w1.0 -e.1 -P -n500 -O70 -L</main_exec_args>
+      <main_exec_args> -B25 -m5 -y1 -gN -x1 -s6 -w1.0 -e.1 -P -n500 -O70 
+                       -B25 -m16 -y1 -gN -x1 -s12 -w1.0 -e.1 -P -n500 -O70 
+                        -B50 -m5 -y1 -gN -x1 -s6 -w1.0 -e.1 -P -n500 -O70  
+                       -B50 -m16 -y1 -gN -x1 -s12 -w1.0 -e.1 -P -n500 -O70 
+                        -B100 -m5 -y1 -gN -x1 -s6 -w1.0 -e.1 -P -n500 -O70 
+                       -B100 -m16 -y1 -gN -x1 -s12 -w1.0 -e.1 -P -n500 -O70 </main_exec_args>
      <tags>ulsim.test1 ulsim.test2 ulsim.test3 ulsim.test4 ulsim.test5 ulsim.test6</tags>
       <search_expr_true>"passed"</search_expr_true>
       <search_expr_false>segmentation fault|assertion|exiting|fatal</search_expr_false>
diff --git a/openair1/PHY/CODING/3gpplte_turbo_decoder_sse_8bit.c b/openair1/PHY/CODING/3gpplte_turbo_decoder_sse_8bit.c
index f22ec21ff0..3a836cfcb2 100644
--- a/openair1/PHY/CODING/3gpplte_turbo_decoder_sse_8bit.c
+++ b/openair1/PHY/CODING/3gpplte_turbo_decoder_sse_8bit.c
@@ -1337,9 +1337,8 @@ unsigned char phy_threegpplte_turbo_decoder8(short *y,
   if (init_stats) stop_meas(init_stats);
 
   // do log_map from first parity bit
-
+ 
   log_map8(systematic0,yparity1,m11,m10,alpha,beta,ext,n2,0,F,offset8_flag,alpha_stats,beta_stats,gamma_stats,ext_stats);
-
   while (iteration_cnt++ < max_iterations) {
 
 #ifdef DEBUG_LOGMAP
diff --git a/openair1/PHY/LTE_TRANSPORT/dci_tools.c b/openair1/PHY/LTE_TRANSPORT/dci_tools.c
index 47ad00f099..c3a309a424 100644
--- a/openair1/PHY/LTE_TRANSPORT/dci_tools.c
+++ b/openair1/PHY/LTE_TRANSPORT/dci_tools.c
@@ -1998,12 +1998,13 @@ void fill_ulsch(PHY_VARS_eNB *eNB,int UE_id,nfapi_ul_config_ulsch_pdu *ulsch_pdu
   else if(ulsch->harq_processes[harq_pid]->n_DMRS == 7)
     ulsch->harq_processes[harq_pid]->n_DMRS2 = 9;
   
-  LOG_D(PHY,"[eNB %d][PUSCH %d] Frame %d, Subframe %d Programming PUSCH with n_DMRS2 %d (cshift %d) ulsch:ndi:%d ulsch_pdu:ndi:%d new_ulsch:%d status:%d ulsch_pdu:rvidx:%d\n",
+  LOG_D(PHY,"[eNB %d][PUSCH %d] Frame %d, Subframe %d Programming PUSCH with n_DMRS2 %d (cshift %d) ulsch:ndi:%d ulsch_pdu:ndi:%d new_ulsch:%d status:%d ulsch_pdu:rvidx:%d ulsch_pdu->ulsch_pdu_rel8.size %d\n",
 	eNB->Mod_id,harq_pid,frame,subframe,
         ulsch->harq_processes[harq_pid]->n_DMRS2,
         ulsch->harq_processes[harq_pid]->n_DMRS,
 	ulsch->harq_processes[harq_pid]->ndi, ulsch_pdu->ulsch_pdu_rel8.new_data_indication, new_ulsch, ulsch->harq_processes[harq_pid]->status,
-	ulsch_pdu->ulsch_pdu_rel8.redundancy_version);
+	ulsch_pdu->ulsch_pdu_rel8.redundancy_version,
+        ulsch_pdu->ulsch_pdu_rel8.size);
   
   ulsch->harq_processes[harq_pid]->rvidx = ulsch_pdu->ulsch_pdu_rel8.redundancy_version;
   if(ulsch_pdu->ulsch_pdu_rel8.modulation_type!=0)
diff --git a/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c b/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c
index 2083d16309..6a9742fb9e 100644
--- a/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c
+++ b/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c
@@ -366,7 +366,7 @@ int ulsch_decoding_data_2thread0(td_params* tdp) {
     else
       crc_type = CRC24_B;
     
-    
+   
     ret = tc(&ulsch_harq->d[r][96],
              NULL,
 	     ulsch_harq->c[r],
@@ -734,7 +734,8 @@ int ulsch_decoding_data(PHY_VARS_eNB *eNB,int UE_id,int harq_pid,int llr8_flag)
       crc_type = CRC24_A;
     else
       crc_type = CRC24_B;
-   
+  
+ 
     start_meas(&eNB->ulsch_turbo_decoding_stats);
     
     ret = tc(&ulsch_harq->d[r][96],
diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c
index bf8116c760..e2198b2f45 100644
--- a/openair1/SCHED/phy_procedures_lte_eNb.c
+++ b/openair1/SCHED/phy_procedures_lte_eNb.c
@@ -1270,7 +1270,7 @@ void pusch_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc)
   for (i=0; i<NUMBER_OF_UE_MAX; i++) {
     ulsch = eNB->ulsch[i];
     ulsch_harq = ulsch->harq_processes[harq_pid];
-    if (ulsch->rnti>0) LOG_D(PHY,"eNB->ulsch[%d]->harq_processes[harq_pid:%d] SFN/SF:%04d%d: PUSCH procedures, UE %d/%x ulsch_harq[status:%d SFN/SF:%04d%d handled:%d]\n",
+    if (ulsch->rnti>0) LOG_I(PHY,"eNB->ulsch[%d]->harq_processes[harq_pid:%d] SFN/SF:%04d%d: PUSCH procedures, UE %d/%x ulsch_harq[status:%d SFN/SF:%04d%d handled:%d]\n",
 			     i, harq_pid, frame,subframe,i,ulsch->rnti,
                              ulsch_harq->status, ulsch_harq->frame, ulsch_harq->subframe, ulsch_harq->handled);
     
@@ -1296,8 +1296,8 @@ void pusch_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc)
       ulsch->cyclicShift = (ulsch_harq->n_DMRS2 +
 			    fp->pusch_config_common.ul_ReferenceSignalsPUSCH.cyclicShift +
 			    nPRS)%12;
-      
-      LOG_D(PHY,
+      AssertFatal(ulsch_harq->TBS>0,"illegal TBS %d\n",ulsch_harq->TBS); 
+      LOG_I(PHY,
 	    "[eNB %d][PUSCH %d] Frame %d Subframe %d Demodulating PUSCH: dci_alloc %d, rar_alloc %d, round %d, first_rb %d, nb_rb %d, Qm %d, TBS %d, rv %d, cyclic_shift %d (n_DMRS2 %d, cyclicShift_common %d, ), O_ACK %d, beta_cqi %d \n",
 	    eNB->Mod_id,harq_pid,frame,subframe,
 	    ulsch_harq->dci_alloc,
diff --git a/openair1/SIMULATION/LTE_PHY/ulsim.c b/openair1/SIMULATION/LTE_PHY/ulsim.c
index 636a48e746..3d18543f2c 100644
--- a/openair1/SIMULATION/LTE_PHY/ulsim.c
+++ b/openair1/SIMULATION/LTE_PHY/ulsim.c
@@ -126,7 +126,6 @@ fill_nfapi_ulsch_config_request(nfapi_ul_config_request_pdu_t *ul_config_pdu,
 {
   memset((void *) ul_config_pdu, 0, sizeof(nfapi_ul_config_request_pdu_t));
 
-  //  printf("filling ul_config_pdu: modulation type %d, rvidx %d\n",modulation_type,redundancy_version);
 
   ul_config_pdu->pdu_type                                                    = NFAPI_UL_CONFIG_ULSCH_PDU_TYPE;
   ul_config_pdu->pdu_size                                                    = (uint8_t) (2 + sizeof(nfapi_ul_config_ulsch_pdu));
@@ -147,6 +146,8 @@ fill_nfapi_ulsch_config_request(nfapi_ul_config_request_pdu_t *ul_config_pdu,
   ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.n_srs                              = n_srs;
   ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.size                               = size;
 
+  //printf("Filling ul_config_pdu : Q %d, TBS %d, rv %d, ndi %d\n", modulation_type,size,redundancy_version,new_data_indication);
+
   if (cqi_req == 1) {
     // Add CQI portion
     ul_config_pdu->pdu_type = NFAPI_UL_CONFIG_ULSCH_CQI_RI_PDU_TYPE;
@@ -183,6 +184,7 @@ void fill_ulsch_dci(PHY_VARS_eNB *eNB,
 		    int mcs,
 		    int modulation_type,
 		    int ndi,
+                    int TBS,
 		    int cqi_flag,
 		    uint8_t beta_CQI,
 		    uint8_t beta_RI,
@@ -191,7 +193,7 @@ void fill_ulsch_dci(PHY_VARS_eNB *eNB,
   nfapi_ul_config_request_body_t *ul_req=&sched_resp->UL_req->ul_config_request_body;
   int harq_pid = ((frame*10)+subframe)&7;
 
-  //  printf("ulsch in frame %d, subframe %d => harq_pid %d, mcs %d, ndi %d\n",frame,subframe,harq_pid,mcs,ndi);
+  //printf("ulsch in frame %d, subframe %d => harq_pid %d, mcs %d, ndi %d\n",frame,subframe,harq_pid,mcs,ndi);
 
   switch (eNB->frame_parms.N_RB_UL) {
   case 6:
@@ -297,7 +299,7 @@ void fill_ulsch_dci(PHY_VARS_eNB *eNB,
 				  0,	// ul_tx_mode
 				  0,	// current_tx_nb
 				  0,	// n_srs
-				  get_TBS_UL(mcs,nb_rb));
+				  TBS);
 
   sched_resp->UL_req->header.message_id = NFAPI_UL_CONFIG_REQUEST;
   ul_req->number_of_pdus=1;
@@ -446,14 +448,14 @@ int main(int argc, char **argv)
 	      "cannot load configuration module, exiting\n");
 
   logInit();
-  /*
+  
   // enable these lines if you need debug info
   // however itti will catch all signals, so ctrl-c won't work anymore
   // alternatively you can disable ITTI completely in CMakeLists.txt
-  itti_init(TASK_MAX, THREAD_MAX, MESSAGES_ID_MAX, tasks_info, messages_info, messages_definition_xml, NULL);
-  set_comp_log(PHY,LOG_DEBUG,LOG_MED,1);
-  set_glog(LOG_DEBUG,LOG_MED);
-  */
+  //itti_init(TASK_MAX, THREAD_MAX, MESSAGES_ID_MAX, tasks_info, messages_info, messages_definition_xml, NULL);
+  //set_comp_log(PHY,LOG_DEBUG,LOG_MED,1);
+  //set_glog(LOG_DEBUG,LOG_MED);
+  
 
   while ((c = getopt (argc, argv, "hapZEbm:n:Y:X:x:s:w:e:q:d:D:O:c:r:i:f:y:c:oA:C:R:g:N:l:S:T:QB:PI:LF")) != -1) {
     switch (c) {
@@ -1142,7 +1144,7 @@ int main(int argc, char **argv)
 	  else if (mcs < 21) modulation_type = 4;
 	  else if (mcs < 29) modulation_type = 6;
 
-	  fill_ulsch_dci(eNB,proc_rxtx->frame_rx,subframe,&sched_resp,14,(void*)&UL_alloc_pdu,first_rb,nb_rb,(round==0)?mcs:(28+rvidx[round]),modulation_type,ndi,cqi_flag,beta_CQI,beta_RI,cqi_size);
+	  fill_ulsch_dci(eNB,proc_rxtx->frame_rx,subframe,&sched_resp,14,(void*)&UL_alloc_pdu,first_rb,nb_rb,(round==0)?mcs:(28+rvidx[round]),modulation_type,ndi,get_TBS_UL(mcs,nb_rb),cqi_flag,beta_CQI,beta_RI,cqi_size);
 
 	  UE->ulsch_Msg3_active[eNB_id] = 0;
 	  UE->ul_power_control_dedicated[eNB_id].accumulationEnabled=1;
@@ -1324,7 +1326,6 @@ int main(int argc, char **argv)
 	  ru->feprx(ru);
 	  phy_procedures_eNB_uespec_RX(eNB,proc_rxtx);
 
-
           if (cqi_flag > 0) {
             cqi_error = 0;
 
-- 
GitLab