From 3321a3510100fbf51de5f1ed1887cad478aa799e Mon Sep 17 00:00:00 2001 From: laurent Date: Wed, 2 Oct 2019 16:22:47 +0200 Subject: [PATCH] add DL packet compression --- executables/main-fs6.c | 68 +++++++++++++++++---- executables/split_headers.h | 8 +-- openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c | 4 +- openair1/SCHED_UE/phy_procedures_lte_ue.c | 1 - openair2/LAYER2/MAC/pre_processor.c | 11 +++- openair2/UTIL/OPT/probe.c | 8 ++- 6 files changed, 76 insertions(+), 24 deletions(-) diff --git a/executables/main-fs6.c b/executables/main-fs6.c index 2b724ea163..1b060d3eef 100644 --- a/executables/main-fs6.c +++ b/executables/main-fs6.c @@ -17,17 +17,54 @@ #include #include #include +#include #define FS6_BUF_SIZE 100*1000 static UDPsock_t sockFS6; -int sum(uint8_t * b, int s) { +int sum(uint8_t *b, int s) { int sum=0; + for (int i=0; i < s; i++) sum+=b[i]; + return sum; } +#define ceil16_bytes(a) ((((a+15)/16)*16)/8) +static void fs6Dlunpack(void *out, void *in, int szUnpacked) { + static uint64_t *lut=NULL; + + if (!lut) { + lut=(uint64_t *) malloc(sizeof(*lut)*256); + + for (int i=0; i <256; i++) + for (int j=0; j<8; j++) + ((uint8_t *)(lut+i))[7-j]=(i>>j)&1; + } + + int64_t *out_64 = (int64_t *)out; + int sz=ceil16_bytes(szUnpacked); + + for (int i=0; ipusch_vars[hULUE(bufPtr)->UE_id]->ulsch_power, hULUE(bufPtr)->ulsch_power, sizeof(int)*2); - LOG_I(PHY,"Received ulsch data for: rnti:%d, fsf: %d/%d\n", + LOG_I(PHY,"Received ulsch data for: rnti:%d, fsf: %d/%d\n", ulsch->rnti, eNB->proc.frame_rx, eNB->proc.subframe_rx); } else if ( type == fs6ULcch ) { int nb_uci=hULUEuci(bufPtr)->nb_active_ue; @@ -722,16 +759,16 @@ void rcvFs6DL(uint8_t *bufferZone, int nbBlocks, PHY_VARS_eNB *eNB, int frame, i dlsch_harq->Nl=hDLUE(bufPtr)->Nl; dlsch_harq->pdsch_start=hDLUE(bufPtr)->pdsch_start; #ifdef PHY_TX_THREAD - dlsch_harq->CEmode = hDLUE(bufPtr)->CEmode; + dlsch_harq->CEmode = hDLUE(bufPtr)->CEmode; dlsch_harq->i0=hDLUE(bufPtr)->i0; dlsch_harq->sib1_br_flag=hDLUE(bufPtr)->sib1_br_flag; #else dlsch0->i0=hDLUE(bufPtr)->i0; dlsch0->sib1_br_flag=hDLUE(bufPtr)->sib1_br_flag; #endif - memcpy(dlsch_harq->e, - hDLUE(bufPtr)+1, hDLUE(bufPtr)->dataLen); - LOG_D(PHY,"received %d bits, in harq id: %di fsf: %d.%d, sum %d\n", + fs6Dlunpack(dlsch_harq->e, + hDLUE(bufPtr)+1, hDLUE(bufPtr)->dataLen); + LOG_D(PHY,"received %d bits, in harq id: %di fsf: %d.%d, sum %d\n", hDLUE(bufPtr)->dataLen, hDLUE(bufPtr)->harq_pid, frame, subframe, sum(dlsch_harq->e, hDLUE(bufPtr)->dataLen)); } else if (type == fs6UlConfig) { int nbUE=(((commonUDP_t *)bufPtr)->contentBytes - sizeof(fs6_dl_t)) / sizeof( fs6_dl_ulsched_t ) ; @@ -769,7 +806,7 @@ void rcvFs6DL(uint8_t *bufferZone, int nbBlocks, PHY_VARS_eNB *eNB, int frame, i ulsch_harq->srs_active=hTxULUE(bufPtr)->srs_active; ulsch_harq->TBS=hTxULUE(bufPtr)->TBS; ulsch_harq->Nsymb_pusch=hTxULUE(bufPtr)->Nsymb_pusch; - LOG_I(PHY,"Received request to perform ulsch for: rnti:%d, fsf: %d/%d\n", + LOG_I(PHY,"Received request to perform ulsch for: rnti:%d, fsf: %d/%d\n", ulsch->rnti, frame, subframe); } } else if ( type == fs6ULConfigCCH ) { @@ -971,11 +1008,11 @@ void appendFs6DLUE(uint8_t *bufferZone, LTE_DL_FRAME_PARMS *fp, int UE_id, int8_ harqData->pdsch_start, frame,subframe, 0); - AssertFatal(firstFreeByte+UEdataLen+sizeof(fs6_dl_t) <= bufferZone+FS6_BUF_SIZE, ""); + AssertFatal(firstFreeByte+ceil16_bytes(UEdataLen)+sizeof(fs6_dl_t) <= bufferZone+FS6_BUF_SIZE, ""); commonUDP_t *newUDPheader=(commonUDP_t *) firstFreeByte; FirstUDPheader->nbBlocks++; newUDPheader->blockID=curBlock; - newUDPheader->contentBytes=sizeof(fs6_dl_t)+sizeof(fs6_dl_uespec_t) + UEdataLen; + newUDPheader->contentBytes=sizeof(fs6_dl_t)+sizeof(fs6_dl_uespec_t) + ceil16_bytes(UEdataLen); // We skip the fs6 DL header, that is populated by caller // This header will be duplicated during sending hDLUE(newUDPheader)->type=fs6DlConfig; @@ -998,10 +1035,9 @@ void appendFs6DLUE(uint8_t *bufferZone, LTE_DL_FRAME_PARMS *fp, int UE_id, int8_ hDLUE(newUDPheader)->sib1_br_flag=dlsch0->sib1_br_flag; #endif hDLUE(newUDPheader)->dataLen=UEdataLen; - memcpy(hDLUE(newUDPheader)+1, harqData->e, UEdataLen); + fs6Dlpack(hDLUE(newUDPheader)+1, harqData->e, UEdataLen); LOG_D(PHY,"sending %d bits, in harq id: %di fsf: %d.%d, sum %d\n", - UEdataLen , harq_pid, frame, subframe, sum(harqData->e, UEdataLen)); - + UEdataLen, harq_pid, frame, subframe, sum(harqData->e, UEdataLen)); //for (int i=0; i < UEdataLen; i++) //LOG_D(PHY,"buffer ei[%d]:%hhx\n", i, ( (uint8_t *)(hDLUE(newUDPheader)+1) )[i]); } @@ -1112,7 +1148,13 @@ void phy_procedures_eNB_TX_tosplit(uint8_t *bufferZone, PHY_VARS_eNB *eNB, L1_rx uint8_t num_dci = eNB->pdcch_vars[subframe&1].num_dci; uint8_t num_mdci = eNB->mpdcch_vars[subframe&1].num_dci; memcpy(hDL(bufferZone)->pbch_pdu,eNB->pbch_pdu,4); - LOG_D(PHY,"num_pdcch_symbols %"PRIu8",number dci %"PRIu8"\n",num_pdcch_symbols, num_dci); + + if ( num_dci <= 8 ) + LOG_D(PHY,"num_pdcch_symbols %"PRIu8",number dci %"PRIu8"\n",num_pdcch_symbols, num_dci); + else { + LOG_E(PHY, "Num dci too large for current FS6 implementation, reducing to 8 dci (was %d)\n", num_dci); + num_dci=8; + } if (NFAPI_MODE==NFAPI_MONOLITHIC || NFAPI_MODE==NFAPI_MODE_PNF) { hDL(bufferZone)->num_pdcch_symbols=num_pdcch_symbols; diff --git a/executables/split_headers.h b/executables/split_headers.h index 9b67cadd91..12dd08beb4 100644 --- a/executables/split_headers.h +++ b/executables/split_headers.h @@ -55,7 +55,7 @@ typedef struct { uint8_t pbch_pdu[4]; int num_pdcch_symbols; int num_dci; - DCI_ALLOC_t dci_alloc[32]; + DCI_ALLOC_t dci_alloc[8]; int num_mdci; int amp; LTE_eNB_PHICH phich_vars; @@ -133,9 +133,9 @@ typedef struct { typedef struct { enum pckType type:8; short UE_id; - short harq_id; - short segment; - short segLen; + uint8_t harq_id; + uint8_t segment; + int segLen; int ulsch_power[2]; } fs6_ul_uespec_t; diff --git a/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c b/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c index c59e71607e..f51fc3035b 100644 --- a/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c +++ b/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c @@ -666,9 +666,9 @@ int ulsch_decoding_data(PHY_VARS_eNB *eNB,int UE_id,int harq_pid,int llr8_flag) &eNB->ulsch_tc_intl1_stats, &eNB->ulsch_tc_intl2_stats); LOG_D(PHY, "Cu should decode in %d iter\n",iter); - if ( iter == 5 ) { + if ( 1) { //iter == 5 ) { for (int i=0; i < Kr; i++ ) - printf("%hx:", ulsch_harq->d[r][96+i]); + printf("%hhx:", ulsch_harq->d[r][96+i]); printf("\n"); } */ diff --git a/openair1/SCHED_UE/phy_procedures_lte_ue.c b/openair1/SCHED_UE/phy_procedures_lte_ue.c index cbcd72a9c1..9e6644def9 100644 --- a/openair1/SCHED_UE/phy_procedures_lte_ue.c +++ b/openair1/SCHED_UE/phy_procedures_lte_ue.c @@ -3328,7 +3328,6 @@ void ue_dlsch_procedures(PHY_VARS_UE *ue, pdsch==PDSCH?1:0, dlsch0->harq_processes[harq_pid]->TBS>256?1:0); - LOG_D(PHY,"dlsch turbo decode in %d iter\n", ret); if (LOG_DEBUGFLAG(UE_TIMING)) { stop_meas(&ue->dlsch_decoding_stats[ue->current_thread_id[subframe_rx]]); LOG_I(PHY, " --> Unscrambling for CW0 %5.3f\n", diff --git a/openair2/LAYER2/MAC/pre_processor.c b/openair2/LAYER2/MAC/pre_processor.c index 1e6b0148a8..991c459c24 100644 --- a/openair2/LAYER2/MAC/pre_processor.c +++ b/openair2/LAYER2/MAC/pre_processor.c @@ -1799,7 +1799,7 @@ void ulsch_scheduler_pre_processor(module_id_t module_idP, } total_allocated_rbs[CC_id] += nb_allocated_rbs[CC_id][UE_id]; - LOG_D(MAC, "In ulsch_preprocessor: assigning %d RBs for UE %d/%x CCid %d, harq_pid %d, nb_rb_ul %d, %d ,%d\n", + LOG_D(MAC, "In ulsch_preprocessor: assigning %d RBs for UE %d/%x CCid %d, harq_pid %d, nb_rb_ul %d, %d ,%d, slice %d, round ul %d\n", nb_allocated_rbs[CC_id][UE_id], UE_id, rntiTable[UE_id], @@ -1807,7 +1807,9 @@ void ulsch_scheduler_pre_processor(module_id_t module_idP, harq_pid, UE_list->UE_template[CC_id][UE_id].nb_rb_ul[harq_pid], UE_list->UE_template[CC_id][UE_id].pre_allocated_nb_rb_ul[slice_idx], - average_rbs_per_user[CC_id]); + average_rbs_per_user[CC_id], + slice_idx, + UE_list->UE_sched_ctrl[UE_id].round_UL[CC_id][harq_pid]); } } @@ -1833,6 +1835,10 @@ void ulsch_scheduler_pre_processor(module_id_t module_idP, while (UE_template->pre_allocated_nb_rb_ul[slice_idx] > 0 && nb_allocated_rbs[CC_id][UE_id] < UE_template->pre_allocated_nb_rb_ul[slice_idx] && total_remaining_rbs[CC_id] > 0) { + LOG_D(PHY,"in ulsch alloc: prealloc: %d, nb_allocated %d, total remain%d\n", + UE_template->pre_allocated_nb_rb_ul[slice_idx], + nb_allocated_rbs[CC_id][UE_id], + total_remaining_rbs[CC_id]); nb_allocated_rbs[CC_id][UE_id] = cmin(nb_allocated_rbs[CC_id][UE_id] + 1, UE_template->pre_allocated_nb_rb_ul[slice_idx]); total_remaining_rbs[CC_id]--; total_allocated_rbs[CC_id]++; @@ -1902,6 +1908,7 @@ assign_max_mcs_min_rb(module_id_t module_idP, ue_sched_ctl->max_rbs_allowed_slice_uplink[CC_id][slice_idx] = nb_rbs_allowed_slice(sli->ul[slice_idx].pct, N_RB_UL); int bytes_to_schedule = UE_template->estimated_ul_buffer - UE_template->scheduled_ul_bytes; + LOG_D(MAC,"ul bytes to schedule: %d-%d\n",UE_template->estimated_ul_buffer, UE_template->scheduled_ul_bytes); if (bytes_to_schedule < 0) bytes_to_schedule = 0; int bits_to_schedule = bytes_to_schedule * 8; diff --git a/openair2/UTIL/OPT/probe.c b/openair2/UTIL/OPT/probe.c index b032784028..32facd6889 100644 --- a/openair2/UTIL/OPT/probe.c +++ b/openair2/UTIL/OPT/probe.c @@ -396,11 +396,15 @@ void trace_pdu(int direction, uint8_t *pdu_buffer, unsigned int pdu_buffer_size, MAC_Context_Info_t pdu_context; int radioType=FDD_RADIO; - if (RC.eNB[0][0]!=NULL) + if (RC.eNB && RC.eNB[0][0]!=NULL) radioType=RC.eNB[0][0]->frame_parms.frame_type== FDD ? FDD_RADIO:TDD_RADIO; - if (PHY_vars_UE_g[0][0] != NULL) + else if (PHY_vars_UE_g && PHY_vars_UE_g[0][0] != NULL) radioType=PHY_vars_UE_g[0][0]->frame_parms.frame_type== FDD ? FDD_RADIO:TDD_RADIO; + else { + LOG_E(OPT,"not a eNB neither a UE!!! \n"); + return; + } switch (opt_type) { case OPT_WIRESHARK :