From ee2ce7670d422338fdca313cfba602b6921fb825 Mon Sep 17 00:00:00 2001
From: Raymond Knopp <raymond.knopp@eurecom.fr>
Date: Wed, 6 Jan 2021 11:18:35 +0100
Subject: [PATCH] made L1 DLSCH encoding stateless. harq_pid/round information
 are not kept in PHY. Full channel encoding is performed for each transmission
 of a transport block. Still to be done: test, then cleanup data structures
 and fix unitary simulations.

---
 openair1/PHY/NR_TRANSPORT/nr_dci_tools.c    |  4 ++--
 openair1/PHY/NR_TRANSPORT/nr_dlsch.c        |  2 +-
 openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c | 14 +++++++-------
 openair1/PHY/NR_TRANSPORT/nr_dlsch_tools.c  |  4 ++--
 4 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c b/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c
index dc2a862dbde..ab16fe5265b 100644
--- a/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c
+++ b/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c
@@ -246,10 +246,10 @@ void nr_fill_dci(PHY_VARS_gNB *gNB,
     
     dlsch = gNB->dlsch[dlsch_id][0];
     int num_slots_tdd = (gNB->frame_parms.slots_per_frame)>>(7-gNB->gNB_config.tdd_table.tdd_period.value);
-    int harq_pid = slot % num_slots_tdd;
+    int harq_pid = 0;//slot % num_slots_tdd;
 
     dlsch->slot_tx[slot]             = 1;
-    dlsch->harq_ids[frame%2][slot]   = harq_pid;
+    dlsch->harq_ids[frame%2][slot]   = 0;//harq_pid;
     AssertFatal(harq_pid < 8 && harq_pid >= 0,
 		"illegal harq_pid %d\n",harq_pid);
     
diff --git a/openair1/PHY/NR_TRANSPORT/nr_dlsch.c b/openair1/PHY/NR_TRANSPORT/nr_dlsch.c
index e3627b93445..9b4c74a4165 100644
--- a/openair1/PHY/NR_TRANSPORT/nr_dlsch.c
+++ b/openair1/PHY/NR_TRANSPORT/nr_dlsch.c
@@ -136,7 +136,7 @@ uint8_t nr_generate_pdsch(PHY_VARS_gNB *gNB,
     dlsch = gNB->dlsch[dlsch_id][0];
     if (dlsch->slot_tx[slot] == 0) continue;
 
-    int harq_pid = dlsch->harq_ids[frame%2][slot];
+    int harq_pid = 0;//dlsch->harq_ids[frame%2][slot];
     NR_DL_gNB_HARQ_t *harq = dlsch->harq_processes[harq_pid];
     nfapi_nr_dl_tti_pdsch_pdu_rel15_t *rel15 = &harq->pdsch_pdu.pdsch_pdu_rel15;
     uint32_t scrambled_output[NR_MAX_NB_CODEWORDS][NR_MAX_PDSCH_ENCODED_LENGTH>>5];
diff --git a/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c b/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c
index cb395ff4aff..1a3116f3a05 100644
--- a/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c
+++ b/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c
@@ -322,7 +322,7 @@ int nr_dlsch_encoding(PHY_VARS_gNB *gNB,
 
   unsigned int G;
   unsigned int crc=1;
-  uint8_t harq_pid = dlsch->harq_ids[frame%2][slot];
+  uint8_t harq_pid = 0;//dlsch->harq_ids[frame%2][slot];
   AssertFatal(harq_pid<8 && harq_pid>=0,"illegal harq_pid %d\b",harq_pid);
   nfapi_nr_dl_tti_pdsch_pdu_rel15_t *rel15 = &dlsch->harq_processes[harq_pid]->pdsch_pdu.pdsch_pdu_rel15;
   uint16_t nb_rb = rel15->rbSize;
@@ -347,8 +347,8 @@ int nr_dlsch_encoding(PHY_VARS_gNB *gNB,
   float Coderate = 0.0;
   uint8_t Nl = 4;
 
-  dlsch->harq_processes[harq_pid]->round = nr_rv_round_map[rel15->rvIndex[0]];
-
+  dlsch->harq_processes[harq_pid]->round = 0;// regenerate all code segments every round. was nr_rv_round_map[rel15->rvIndex[0]];
+  
   VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_gNB_DLSCH_ENCODING, VCD_FUNCTION_IN);
 
   A = rel15->TBSize[0]<<3;
@@ -367,20 +367,20 @@ int nr_dlsch_encoding(PHY_VARS_gNB *gNB,
   }
 
   if (stats) {
-    stats->round_trials[dlsch->harq_processes[harq_pid]->round]++;
+    //    stats->round_trials[dlsch->harq_processes[harq_pid]->round]++;
     stats->rnti = dlsch->rnti;
-    if (dlsch->harq_processes[harq_pid]->round == 0){
+    //if (dlsch->harq_processes[harq_pid]->round == 0){
       stats->total_bytes_tx += rel15->TBSize[0];
       stats->current_RI   = rel15->nrOfLayers;
       stats->current_Qm   = rel15->qamModOrder[0];
-    }
+      //}
   }
   G = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, length_dmrs,mod_order,rel15->nrOfLayers);
 
   LOG_D(PHY,"dlsch coding A %d G %d mod_order %d\n", A,G, mod_order);
 
   //  if (dlsch->harq_processes[harq_pid]->Ndi == 1) {  // this is a new packet
-  if (dlsch->harq_processes[harq_pid]->round == 0) {  // this is a new packet
+  if (1) { //dlsch->harq_processes[harq_pid]->round == 0) {  // this is a new packet
 #ifdef DEBUG_DLSCH_CODING
   LOG_D(PHY,"encoding thinks this is a new packet \n");
 #endif
diff --git a/openair1/PHY/NR_TRANSPORT/nr_dlsch_tools.c b/openair1/PHY/NR_TRANSPORT/nr_dlsch_tools.c
index 5ce2c45a7dd..e6aae4e5f9e 100644
--- a/openair1/PHY/NR_TRANSPORT/nr_dlsch_tools.c
+++ b/openair1/PHY/NR_TRANSPORT/nr_dlsch_tools.c
@@ -291,10 +291,10 @@ void nr_fill_dlsch(PHY_VARS_gNB *gNB,
   NR_gNB_DLSCH_t  *dlsch = gNB->dlsch[dlsch_id][0];
   NR_DL_gNB_HARQ_t **harq  = dlsch->harq_processes;
   /// DLSCH struct
-  memcpy((void*)&harq[dlsch->harq_ids[frame%2][slot]]->pdsch_pdu, (void*)pdsch_pdu, sizeof(nfapi_nr_dl_tti_pdsch_pdu));
+  memcpy((void*)&harq[0/*dlsch->harq_ids[frame%2][slot]*/]->pdsch_pdu, (void*)pdsch_pdu, sizeof(nfapi_nr_dl_tti_pdsch_pdu));
   gNB->num_pdsch_rnti[slot]++;
   AssertFatal(sdu!=NULL,"sdu is null\n");
-  harq[dlsch->harq_ids[frame%2][slot]]->pdu = sdu;
+  harq[0/*dlsch->harq_ids[frame%2][slot]*/]->pdu = sdu;
 
 
 }
-- 
GitLab