From e6804be968bed72cc056adc797d3cd4a10efe87f Mon Sep 17 00:00:00 2001 From: Sakthivel Velumani Date: Wed, 26 Aug 2020 18:01:38 +0200 Subject: [PATCH 01/96] created worker threads --- openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c | 420 +++++++++--------- openair1/PHY/defs_gNB.h | 35 ++ openair1/SCHED_NR/phy_procedures_nr_gNB.c | 34 +- 3 files changed, 273 insertions(+), 216 deletions(-) diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c index 89711050e2..2d84d5a520 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c +++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c @@ -289,6 +289,196 @@ void clean_gNB_ulsch(NR_gNB_ULSCH_t *ulsch) static uint32_t prnt_crc_cnt = 0; #endif +uint32_t nr_processULSegment(void* arg) { + ldpcDecode_t *rdata = (ldpcDecode_t*) arg; + PHY_VARS_gNB *phy_vars_gNB = rdata->gNB; + NR_UL_gNB_HARQ_t *ulsch_harq = rdata->ulsch_harq; + t_nrLDPC_dec_params *p_decoderParms = rdata->p_decoderParms; + int length_dec; + int Kr; + int Kr_bytes; + uint8_t crc_type; + int i; + int j; + int r = rdata->segment_r; + int A = rdata->A; + int E = rdata->E; + int Qm = rdata->Qm; + int rv_index = rdata->rv_index; + int r_offset = rdata->r_offset; + uint8_t kc = rdata->Kc; + uint32_t Tbslbrm = rdata->Tbslbm; + short* ulsch_llr = rdata->ulsch_llr; + int max_ldpc_iterations = rdata->p_decParams->numMaxIter; + int8_t llrProcBuf[OAI_UL_LDPC_MAX_NUM_LLR] __attribute__ ((aligned(32))); + + int16_t z [68*384]; + int8_t l [68*384]; + uint8_t Ilbrm = 0; + + Kr = ulsch_harq->K; + Kr_bytes = Kr>>3; + + K_bytes_F = Kr_bytes-(ulsch_harq->F>>3); + + start_meas(&phy_vars_gNB->ulsch_deinterleaving_stats); + + //////////////////////////////////////////////////////////////////////////////////////////// + ///////////////////////////////// nr_deinterleaving_ldpc /////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////////////////// + + //////////////////////////// ulsch_llr =====> ulsch_harq->e ////////////////////////////// + + nr_deinterleaving_ldpc(E, + Qm, + ulsch_harq->e[r], + ulsch_llr+r_offset); + + //for (int i =0; i<16; i++) + // printf("rx output deinterleaving w[%d]= %d r_offset %d\n", i,ulsch_harq->w[r][i], r_offset); + + stop_meas(&phy_vars_gNB->ulsch_deinterleaving_stats); + + + /*LOG_D(PHY,"HARQ_PID %d Rate Matching Segment %d (coded bits %d,unpunctured/repeated bits %d, TBS %d, mod_order %d, nb_rb %d, Nl %d, rv %d, round %d)...\n", + harq_pid,r, G, + Kr*3, + ulsch_harq->TBS, + Qm, + nb_rb, + n_layers, + pusch_pdu->pusch_data.rv_index, + ulsch_harq->round);*/ + ////////////////////////////////////////////////////////////////////////////////////////// + + + ////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////// nr_rate_matching_ldpc_rx //////////////////////////////// + ////////////////////////////////////////////////////////////////////////////////////////// + + ///////////////////////// ulsch_harq->e =====> ulsch_harq->d ///////////////////////// + + start_meas(&phy_vars_gNB->ulsch_rate_unmatching_stats); + + if (nr_rate_matching_ldpc_rx(Ilbrm, + Tbslbrm, + p_decParams->BG, + p_decParams->Z, + ulsch_harq->d[r], + ulsch_harq->e[r], + ulsch_harq->C, + rv_index, + (ulsch_harq->round==0)?1:0, + E, + ulsch_harq->F, + Kr-ulsch_harq->F-2*(p_decParams->Z))==-1) { + + stop_meas(&phy_vars_gNB->ulsch_rate_unmatching_stats); + + LOG_E(PHY,"ulsch_decoding.c: Problem in rate_matching\n"); + rdata->decodeIterations = max_ldpc_iterations + 1; + return; + } else { + stop_meas(&phy_vars_gNB->ulsch_rate_unmatching_stats); + } + +#ifdef DEBUG_ULSCH_DECODING + if (r==0) { + write_output("decoder_llr.m","decllr",ulsch_llr,G,1,0); + write_output("decoder_in.m","dec",&ulsch_harq->d[0][0],E,1,0); + } + + printf("decoder input(segment %u) :", r); + int i; + for (i=0;i<(3*8*Kr_bytes)+12;i++) + printf("%d : %d\n",i,ulsch_harq->d[r][i]); + printf("\n"); +#endif + + + // printf("Clearing c, %p\n",ulsch_harq->c[r]); + memset(ulsch_harq->c[r],0,Kr_bytes); + + // printf("done\n"); + if (ulsch_harq->C == 1) { + if (A > 3824) + crc_type = CRC24_A; + else + crc_type = CRC16; + + length_dec = ulsch_harq->B; + } + else { + crc_type = CRC24_B; + length_dec = (ulsch_harq->B+24*ulsch_harq->C)/ulsch_harq->C; + } + + start_meas(&phy_vars_gNB->ulsch_ldpc_decoding_stats); + + //LOG_E(PHY,"AbsSubframe %d.%d Start LDPC segment %d/%d A %d ",frame%1024,nr_tti_rx,r,ulsch_harq->C-1, A); + + + memset(pv,0,2*ulsch_harq->Z*sizeof(int16_t)); + memset((pv+K_bytes_F),127,ulsch_harq->F*sizeof(int16_t)); + + for (i=((2*p_decParams->Z)>>3), j = 0; i < K_bytes_F; i++, j++) { + pv[i]= _mm_loadu_si128((__m128i*)(&ulsch_harq->d[r][8*j])); + } + + AssertFatal(kc!=255,""); + j+=(ulsch_harq->F>>3); + for (i=Kr_bytes; i < ((kc*p_decParams->Z)>>3); i++, j++) { + pv[i]= _mm_loadu_si128((__m128i*)(&ulsch_harq->d[r][8*j])); + } + + for (i=0, j=0; j < ((kc*p_decParams->Z)>>4); i+=2, j++) { + pl[j] = _mm_packs_epi16(pv[i],pv[i+1]); + } + + ////////////////////////////////////////////////////////////////////////////////////////// + + + ////////////////////////////////////////////////////////////////////////////////////////// + ///////////////////////////////////// nrLDPC_decoder ///////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////////////////// + + ////////////////////////////////// pl =====> llrProcBuf ////////////////////////////////// + + no_iteration_ldpc = nrLDPC_decoder(p_decParams, + (int8_t*)&pl[0], + llrProcBuf, + ulsch_harq->p_nrLDPC_procBuf[r], + p_procTime); + + if (check_crc((uint8_t*)llrProcBuf,length_dec,ulsch_harq->F,crc_type)) { +#ifdef PRINT_CRC_CHECK + //if (prnt_crc_cnt % 10 == 0) + LOG_I(PHY, "Segment %d CRC OK\n",r); +#endif + rdata->decodeIterations = no_iteration_ldpc; + } else { +#ifdef PRINT_CRC_CHECK + //if (prnt_crc_cnt%10 == 0) + LOG_I(PHY, "CRC NOK\n"); +#endif + rdata->decodeIterations = max_ldpc_iterations + 1; + } + + for (int m=0; m < Kr>>3; m ++) { + ulsch_harq->c[r][m]= (uint8_t) llrProcBuf[m]; + } + +#ifdef DEBUG_ULSCH_DECODING + //printf("output decoder %d %d %d %d %d \n", ulsch_harq->c[r][0], ulsch_harq->c[r][1], ulsch_harq->c[r][2],ulsch_harq->c[r][3], ulsch_harq->c[r][4]); + for (int k=0;k>3;k++) + printf("output decoder [%d] = 0x%02x \n", k, ulsch_harq->c[r][k]); + printf("no_iterations_ldpc %d (ret %u)\n",no_iteration_ldpc,ret); + //write_output("dec_output.m","dec0",ulsch_harq->c[0],Kr_bytes,1,4); +#endif + + stop_meas(&phy_vars_gNB->ulsch_ldpc_decoding_stats); +} + uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, uint8_t UE_id, short *ulsch_llr, @@ -299,12 +489,9 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, uint8_t harq_pid, uint32_t G) { - uint32_t A,E; - uint32_t ret, offset; - int32_t no_iteration_ldpc, length_dec; - uint32_t r,r_offset=0,Kr=8424,Kr_bytes,K_bytes_F,err_flag=0; - uint8_t crc_type; - int8_t llrProcBuf[OAI_UL_LDPC_MAX_NUM_LLR] __attribute__ ((aligned(32))); + uint32_t A; + uint32_t ret; + uint32_t r,r_offset=0; #ifdef PRINT_CRC_CHECK prnt_crc_cnt++; @@ -322,13 +509,7 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, printf("ulsch_decoding.c: NULL harq_process pointer\n"); return (ulsch->max_ldpc_iterations + 1); } - t_nrLDPC_procBuf** p_nrLDPC_procBuf = harq_process->p_nrLDPC_procBuf; - int16_t z [68*384]; - int8_t l [68*384]; - uint8_t kc = 255; - uint8_t Ilbrm = 0; - uint32_t Tbslbrm = 950984; double Coderate = 0.0; // ------------------------------------------------------------------ @@ -339,7 +520,7 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, uint8_t n_layers = pusch_pdu->nrOfLayers; // ------------------------------------------------------------------ - uint32_t i,j; + uint32_t i; __m128i *pv = (__m128i*)&z; __m128i *pl = (__m128i*)&l; @@ -350,11 +531,6 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, return (ulsch->max_ldpc_iterations + 1); } - if (!frame_parms) { - printf("ulsch_decoding.c: NULL frame_parms pointer\n"); - return (ulsch->max_ldpc_iterations + 1); - } - // harq_process->trials[nfapi_ulsch_pdu_rel15->round]++; VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_gNB_ULSCH_DECODING,1); @@ -362,7 +538,6 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, harq_process->round = nr_rv_round_map[pusch_pdu->pusch_data.rv_index]; A = (harq_process->TBS)<<3; - ret = ulsch->max_ldpc_iterations + 1; LOG_D(PHY,"ULSCH Decoding, harq_pid %d TBS %d G %d mcs %d Nl %d nb_rb %d, Qm %d, n_layers %d\n",harq_pid,A,G, mcs, n_layers, nb_rb, Qm, n_layers); @@ -419,6 +594,8 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, &harq_process->F, p_decParams->BG); + Tbslbrm = nr_compute_tbslbrm(0,nb_rb,n_layers,harq_process->C); + #ifdef DEBUG_ULSCH_DECODING printf("ulsch decoding nr segmentation Z %d\n", harq_process->Z); if (!frame%100) @@ -431,7 +608,6 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, p_decParams->numMaxIter = ulsch->max_ldpc_iterations; p_decParams->outMode= 0; - err_flag = 0; r_offset = 0; uint16_t a_segments = MAX_NUM_NR_ULSCH_SEGMENTS; //number of segments to be allocated @@ -449,200 +625,30 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, printf("Segmentation: C %d, K %d\n",harq_process->C,harq_process->K); #endif - //opp_enabled=1; - - Kr = harq_process->K; - Kr_bytes = Kr>>3; - - K_bytes_F = Kr_bytes-(harq_process->F>>3); - for (r=0; rC; r++) { E = nr_get_E(G, harq_process->C, Qm, n_layers, r); + union ldpcReqUnion id = {.s={ulsch->rnti,frame,slot,nr_tti_rx,0,0}}; + notifiedFIFO_elt_t *req=newNotifiedFIFO_elt(sizeof(ldpcDecode_t), id.p, phy_vars_gNB->respDecode, nr_processULSegment); + ldpcDecode_t * rdata=(ldpcDecode_t *) NotifiedFifoData(req); - start_meas(&phy_vars_gNB->ulsch_deinterleaving_stats); - - //////////////////////////////////////////////////////////////////////////////////////////// - ///////////////////////////////// nr_deinterleaving_ldpc /////////////////////////////////// - ////////////////////////////////////////////////////////////////////////////////////////// - - //////////////////////////// ulsch_llr =====> harq_process->e ////////////////////////////// - - nr_deinterleaving_ldpc(E, - Qm, - harq_process->e[r], - ulsch_llr+r_offset); - - //for (int i =0; i<16; i++) - // printf("rx output deinterleaving w[%d]= %d r_offset %d\n", i,harq_process->w[r][i], r_offset); - - stop_meas(&phy_vars_gNB->ulsch_deinterleaving_stats); - - - LOG_D(PHY,"HARQ_PID %d Rate Matching Segment %d (coded bits %d,unpunctured/repeated bits %d, TBS %d, mod_order %d, nb_rb %d, Nl %d, rv %d, round %d)...\n", - harq_pid,r, G, - Kr*3, - harq_process->TBS, - Qm, - nb_rb, - n_layers, - pusch_pdu->pusch_data.rv_index, - harq_process->round); - ////////////////////////////////////////////////////////////////////////////////////////// - - - ////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////// nr_rate_matching_ldpc_rx //////////////////////////////// - ////////////////////////////////////////////////////////////////////////////////////////// - - ///////////////////////// harq_process->e =====> harq_process->d ///////////////////////// - - start_meas(&phy_vars_gNB->ulsch_rate_unmatching_stats); - - Tbslbrm = nr_compute_tbslbrm(0,nb_rb,n_layers,harq_process->C); - - if (nr_rate_matching_ldpc_rx(Ilbrm, - Tbslbrm, - p_decParams->BG, - p_decParams->Z, - harq_process->d[r], - harq_process->e[r], - harq_process->C, - pusch_pdu->pusch_data.rv_index, - (harq_process->round==0)?1:0, - E, - harq_process->F, - Kr-harq_process->F-2*(p_decParams->Z))==-1) { - - stop_meas(&phy_vars_gNB->ulsch_rate_unmatching_stats); - - LOG_E(PHY,"ulsch_decoding.c: Problem in rate_matching\n"); - return (ulsch->max_ldpc_iterations + 1); - } else { - stop_meas(&phy_vars_gNB->ulsch_rate_unmatching_stats); - } - + rdata->gNB = phy_vars_gNB; + rdata->ulsch_harq = harq_process; + rdata->p_decoderParms = p_decParams; + rdata->ulsch_llr = ulsch_llr; + rdata->Kc = Kc; + rdata->segment_r = r; + rdata->nbSegments = harq_process->C; + rdata->E = E; + rdata->A = A; + rdata->Qm = Qm; + rdata->r_offset = r_offset; + rdata->rv_index = pusch_pdu->pusch_data.rv_index; + rdata->Tbslbrm = Tbslbrm; r_offset += E; - -#ifdef DEBUG_ULSCH_DECODING - if (r==0) { - write_output("decoder_llr.m","decllr",ulsch_llr,G,1,0); - write_output("decoder_in.m","dec",&harq_process->d[0][0],E,1,0); - } - - printf("decoder input(segment %u) :", r); - int i; - for (i=0;i<(3*8*Kr_bytes)+12;i++) - printf("%d : %d\n",i,harq_process->d[r][i]); - printf("\n"); -#endif - - - // printf("Clearing c, %p\n",harq_process->c[r]); - memset(harq_process->c[r],0,Kr_bytes); - - // printf("done\n"); - if (harq_process->C == 1) { - if (A > 3824) - crc_type = CRC24_A; - else - crc_type = CRC16; - - length_dec = harq_process->B; - } - else { - crc_type = CRC24_B; - length_dec = (harq_process->B+24*harq_process->C)/harq_process->C; - } - - if (err_flag == 0) { - - start_meas(&phy_vars_gNB->ulsch_ldpc_decoding_stats); - - //LOG_E(PHY,"AbsSubframe %d.%d Start LDPC segment %d/%d A %d ",frame%1024,nr_tti_rx,r,harq_process->C-1, A); - - - memset(pv,0,2*harq_process->Z*sizeof(int16_t)); - memset((pv+K_bytes_F),127,harq_process->F*sizeof(int16_t)); - - for (i=((2*p_decParams->Z)>>3), j = 0; i < K_bytes_F; i++, j++) { - pv[i]= _mm_loadu_si128((__m128i*)(&harq_process->d[r][8*j])); - } - - AssertFatal(kc!=255,""); - j+=(harq_process->F>>3); - for (i=Kr_bytes; i < ((kc*p_decParams->Z)>>3); i++, j++) { - pv[i]= _mm_loadu_si128((__m128i*)(&harq_process->d[r][8*j])); - } - - for (i=0, j=0; j < ((kc*p_decParams->Z)>>4); i+=2, j++) { - pl[j] = _mm_packs_epi16(pv[i],pv[i+1]); - } - - ////////////////////////////////////////////////////////////////////////////////////////// - - - ////////////////////////////////////////////////////////////////////////////////////////// - ///////////////////////////////////// nrLDPC_decoder ///////////////////////////////////// - ////////////////////////////////////////////////////////////////////////////////////////// - - ////////////////////////////////// pl =====> llrProcBuf ////////////////////////////////// - - no_iteration_ldpc = nrLDPC_decoder(p_decParams, - (int8_t*)&pl[0], - llrProcBuf, - p_nrLDPC_procBuf[r], - p_procTime); - - if (check_crc((uint8_t*)llrProcBuf,length_dec,harq_process->F,crc_type)) { - #ifdef PRINT_CRC_CHECK - //if (prnt_crc_cnt % 10 == 0) - LOG_I(PHY, "Segment %d CRC OK\n",r); - #endif - ret = no_iteration_ldpc; - } else { - #ifdef PRINT_CRC_CHECK - //if (prnt_crc_cnt%10 == 0) - LOG_I(PHY, "CRC NOK\n"); - #endif - ret = ulsch->max_ldpc_iterations + 1; - } - nb_total_decod++; - - if (no_iteration_ldpc > ulsch->max_ldpc_iterations){ - nb_error_decod++; - } - - for (int m=0; m < Kr>>3; m ++) { - harq_process->c[r][m]= (uint8_t) llrProcBuf[m]; - } - -#ifdef DEBUG_ULSCH_DECODING - //printf("output decoder %d %d %d %d %d \n", harq_process->c[r][0], harq_process->c[r][1], harq_process->c[r][2],harq_process->c[r][3], harq_process->c[r][4]); - for (int k=0;k>3;k++) - printf("output decoder [%d] = 0x%02x \n", k, harq_process->c[r][k]); - printf("no_iterations_ldpc %d (ret %u)\n",no_iteration_ldpc,ret); - //write_output("dec_output.m","dec0",harq_process->c[0],Kr_bytes,1,4); -#endif - - stop_meas(&phy_vars_gNB->ulsch_ldpc_decoding_stats); - } - - if ((err_flag == 0) && (ret >= (ulsch->max_ldpc_iterations + 1))) { - // a Code segment is in error so break; - LOG_D(PHY,"AbsSubframe %d.%d CRC failed, segment %d/%d \n",frame%1024,nr_tti_rx,r,harq_process->C-1); - err_flag = 1; - } ////////////////////////////////////////////////////////////////////////////////////////// } - - int32_t frame_rx_prev = frame; - int32_t tti_rx_prev = nr_tti_rx - 1; - if (tti_rx_prev < 0) { - frame_rx_prev--; - tti_rx_prev += frame_parms->slots_per_frame; - } - frame_rx_prev = frame_rx_prev%1024; + return ret; if (err_flag == 1) { diff --git a/openair1/PHY/defs_gNB.h b/openair1/PHY/defs_gNB.h index 5605a85287..90f26f8efe 100644 --- a/openair1/PHY/defs_gNB.h +++ b/openair1/PHY/defs_gNB.h @@ -252,6 +252,8 @@ typedef struct { int16_t e[MAX_NUM_NR_DLSCH_SEGMENTS][3*8448]; /// Number of bits in each code block after rate matching for LDPC code (38.212 V15.4.0 section 5.4.2.1) uint32_t E; + /// Number of segments processed so far + uint32_t processedSegments; ////////////////////////////////////////////////////////////// @@ -463,6 +465,36 @@ typedef struct { uint8_t cl_done; } NR_gNB_PUSCH; +typedef struct LDPCDecode_s { + PHY_BARS_gNB *gNB; + NR_UL_gNB_HARQ_t *ulsch_harq; + t_nrLDPC_dec_params *p_decoderParms; + short* ulsch_llr; + int harq_pid; + int rv_index; + int A; + int E; + int Kc; + int Qm; + int nbSegments; + int segment_r; + int r_offset; + int Tbslbrm; + int decodeIterations; +} ldpcDecode_t + +struct ldpcReqId { + uint16_t rnti; + uint16_t frame; + uint8_t subframe; + uint8_t codeblock; + uint16_t spare; +} __attribute__((packed)); + +union ldpcReqUnion { + struct ldpcReqId s; + uint64_t p; +}; /// Context data structure for RX/TX portion of slot processing typedef struct { @@ -802,6 +834,9 @@ typedef struct PHY_VARS_gNB_s { time_stats_t rx_dft_stats; time_stats_t ulsch_freq_offset_estimation_stats; */ + notifiedFIFO_t *respDecode; + tpool_t *threadPool; + int nbDecode; } PHY_VARS_gNB; diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index 901be25c65..b4dcc77eff 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -225,6 +225,17 @@ void phy_procedures_gNB_TX(PHY_VARS_gNB *gNB, */ +void nr_postDecode(PHY_VARS_gNB gNB, notifiedFIFO_elt_t *req) { + ldpcDecode_t *rdata = (ldpcDeocde_t*) NotifiedFifoData(req); + NR_UL_gNB_HARQ_t ulsch_harq = rdata->ulsch_harq; + + bool decodeSuccess = (rdata->deocdeIterations <= rdata->p_decoderParms->numMaxIter); + ulsch_harq->processedSegments++; + LOG_D(PHY, "processing result of segment: %d, processed %d/%d\n", + rdata->segment_r, ulsch_harq->processedSegments, rdata->nbSegments); + proc->nbDecode--; + LOG_D(PHY,"remain to decoded in subframe: %d\n", proc->nbDecode); + void nr_ulsch_procedures(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, int ULSCH_id, uint8_t harq_pid) { NR_DL_FRAME_PARMS *frame_parms = &gNB->frame_parms; @@ -282,17 +293,22 @@ void nr_ulsch_procedures(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, int ULSCH //---------------------------------------------------------- start_meas(&gNB->ulsch_decoding_stats); - ret = nr_ulsch_decoding(gNB, - ULSCH_id, - gNB->pusch_vars[ULSCH_id]->llr, - frame_parms, - pusch_pdu, - frame_rx, - slot_rx, - harq_pid, - G); + nr_ulsch_decoding(gNB, + ULSCH_id, + gNB->pusch_vars[ULSCH_id]->llr, + frame_parms, + pusch_pdu, + frame_rx, + slot_rx, + harq_pid, + G); stop_meas(&gNB->ulsch_decoding_stats); + while (gNB->nbDecode > 0) { + notifiedFIFO_elt_t *req=pullTpool(gNB->respDecode, gNB->threadPool); + nr_postDecode(gNB, req); + delNotifiedFIFO_elt(req); + } if (ret > gNB->ulsch[ULSCH_id][0]->max_ldpc_iterations){ LOG_D(PHY, "ULSCH %d in error\n",ULSCH_id); From 9dc149e0f0447dbe05e7eadf5846ac7ca7166c49 Mon Sep 17 00:00:00 2001 From: Sakthi Date: Thu, 27 Aug 2020 00:42:21 +0200 Subject: [PATCH 02/96] added postDecode; ulsim compiles --- openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c | 187 +++++------------- openair1/PHY/defs_gNB.h | 66 ++++--- openair1/SCHED_NR/phy_procedures_nr_gNB.c | 72 +++++-- 3 files changed, 142 insertions(+), 183 deletions(-) diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c index 2d84d5a520..a5c1d2842a 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c +++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c @@ -295,8 +295,10 @@ uint32_t nr_processULSegment(void* arg) { NR_UL_gNB_HARQ_t *ulsch_harq = rdata->ulsch_harq; t_nrLDPC_dec_params *p_decoderParms = rdata->p_decoderParms; int length_dec; + int no_iteration_ldpc; int Kr; int Kr_bytes; + int K_bytes_F; uint8_t crc_type; int i; int j; @@ -307,13 +309,17 @@ uint32_t nr_processULSegment(void* arg) { int rv_index = rdata->rv_index; int r_offset = rdata->r_offset; uint8_t kc = rdata->Kc; - uint32_t Tbslbrm = rdata->Tbslbm; + uint32_t Tbslbrm = rdata->Tbslbrm; short* ulsch_llr = rdata->ulsch_llr; - int max_ldpc_iterations = rdata->p_decParams->numMaxIter; + int max_ldpc_iterations = rdata->p_decoderParms->numMaxIter; int8_t llrProcBuf[OAI_UL_LDPC_MAX_NUM_LLR] __attribute__ ((aligned(32))); int16_t z [68*384]; int8_t l [68*384]; + + __m128i *pv = (__m128i*)&z; + __m128i *pl = (__m128i*)&l; + uint8_t Ilbrm = 0; Kr = ulsch_harq->K; @@ -321,6 +327,9 @@ uint32_t nr_processULSegment(void* arg) { K_bytes_F = Kr_bytes-(ulsch_harq->F>>3); + t_nrLDPC_time_stats procTime; + t_nrLDPC_time_stats* p_procTime = &procTime ; + start_meas(&phy_vars_gNB->ulsch_deinterleaving_stats); //////////////////////////////////////////////////////////////////////////////////////////// @@ -362,8 +371,8 @@ uint32_t nr_processULSegment(void* arg) { if (nr_rate_matching_ldpc_rx(Ilbrm, Tbslbrm, - p_decParams->BG, - p_decParams->Z, + p_decoderParms->BG, + p_decoderParms->Z, ulsch_harq->d[r], ulsch_harq->e[r], ulsch_harq->C, @@ -371,7 +380,7 @@ uint32_t nr_processULSegment(void* arg) { (ulsch_harq->round==0)?1:0, E, ulsch_harq->F, - Kr-ulsch_harq->F-2*(p_decParams->Z))==-1) { + Kr-ulsch_harq->F-2*(p_decoderParms->Z))==-1) { stop_meas(&phy_vars_gNB->ulsch_rate_unmatching_stats); @@ -382,24 +391,8 @@ uint32_t nr_processULSegment(void* arg) { stop_meas(&phy_vars_gNB->ulsch_rate_unmatching_stats); } -#ifdef DEBUG_ULSCH_DECODING - if (r==0) { - write_output("decoder_llr.m","decllr",ulsch_llr,G,1,0); - write_output("decoder_in.m","dec",&ulsch_harq->d[0][0],E,1,0); - } - - printf("decoder input(segment %u) :", r); - int i; - for (i=0;i<(3*8*Kr_bytes)+12;i++) - printf("%d : %d\n",i,ulsch_harq->d[r][i]); - printf("\n"); -#endif - - - // printf("Clearing c, %p\n",ulsch_harq->c[r]); memset(ulsch_harq->c[r],0,Kr_bytes); - // printf("done\n"); if (ulsch_harq->C == 1) { if (A > 3824) crc_type = CRC24_A; @@ -415,23 +408,20 @@ uint32_t nr_processULSegment(void* arg) { start_meas(&phy_vars_gNB->ulsch_ldpc_decoding_stats); - //LOG_E(PHY,"AbsSubframe %d.%d Start LDPC segment %d/%d A %d ",frame%1024,nr_tti_rx,r,ulsch_harq->C-1, A); - - memset(pv,0,2*ulsch_harq->Z*sizeof(int16_t)); memset((pv+K_bytes_F),127,ulsch_harq->F*sizeof(int16_t)); - for (i=((2*p_decParams->Z)>>3), j = 0; i < K_bytes_F; i++, j++) { + for (i=((2*p_decoderParms->Z)>>3), j = 0; i < K_bytes_F; i++, j++) { pv[i]= _mm_loadu_si128((__m128i*)(&ulsch_harq->d[r][8*j])); } AssertFatal(kc!=255,""); j+=(ulsch_harq->F>>3); - for (i=Kr_bytes; i < ((kc*p_decParams->Z)>>3); i++, j++) { + for (i=Kr_bytes; i < ((kc*p_decoderParms->Z)>>3); i++, j++) { pv[i]= _mm_loadu_si128((__m128i*)(&ulsch_harq->d[r][8*j])); } - for (i=0, j=0; j < ((kc*p_decParams->Z)>>4); i+=2, j++) { + for (i=0, j=0; j < ((kc*p_decoderParms->Z)>>4); i+=2, j++) { pl[j] = _mm_packs_epi16(pv[i],pv[i+1]); } @@ -444,7 +434,7 @@ uint32_t nr_processULSegment(void* arg) { ////////////////////////////////// pl =====> llrProcBuf ////////////////////////////////// - no_iteration_ldpc = nrLDPC_decoder(p_decParams, + no_iteration_ldpc = nrLDPC_decoder(p_decoderParms, (int8_t*)&pl[0], llrProcBuf, ulsch_harq->p_nrLDPC_procBuf[r], @@ -452,13 +442,11 @@ uint32_t nr_processULSegment(void* arg) { if (check_crc((uint8_t*)llrProcBuf,length_dec,ulsch_harq->F,crc_type)) { #ifdef PRINT_CRC_CHECK - //if (prnt_crc_cnt % 10 == 0) LOG_I(PHY, "Segment %d CRC OK\n",r); #endif rdata->decodeIterations = no_iteration_ldpc; } else { #ifdef PRINT_CRC_CHECK - //if (prnt_crc_cnt%10 == 0) LOG_I(PHY, "CRC NOK\n"); #endif rdata->decodeIterations = max_ldpc_iterations + 1; @@ -468,14 +456,6 @@ uint32_t nr_processULSegment(void* arg) { ulsch_harq->c[r][m]= (uint8_t) llrProcBuf[m]; } -#ifdef DEBUG_ULSCH_DECODING - //printf("output decoder %d %d %d %d %d \n", ulsch_harq->c[r][0], ulsch_harq->c[r][1], ulsch_harq->c[r][2],ulsch_harq->c[r][3], ulsch_harq->c[r][4]); - for (int k=0;k>3;k++) - printf("output decoder [%d] = 0x%02x \n", k, ulsch_harq->c[r][k]); - printf("no_iterations_ldpc %d (ret %u)\n",no_iteration_ldpc,ret); - //write_output("dec_output.m","dec0",ulsch_harq->c[0],Kr_bytes,1,4); -#endif - stop_meas(&phy_vars_gNB->ulsch_ldpc_decoding_stats); } @@ -491,7 +471,12 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, uint32_t A; uint32_t ret; - uint32_t r,r_offset=0; + uint32_t r; + uint32_t r_offset; + uint32_t offset; + int kc; + int Tbslbrm; + int E; #ifdef PRINT_CRC_CHECK prnt_crc_cnt++; @@ -503,11 +488,15 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, t_nrLDPC_dec_params decParams; t_nrLDPC_dec_params* p_decParams = &decParams; - t_nrLDPC_time_stats procTime; - t_nrLDPC_time_stats* p_procTime = &procTime ; + + int Kr = harq_process->K; + int Kr_bytes = Kr>>3; + + phy_vars_gNB->nbDecode = 0; + if (!harq_process) { - printf("ulsch_decoding.c: NULL harq_process pointer\n"); - return (ulsch->max_ldpc_iterations + 1); + LOG_E(PHY,"ulsch_decoding.c: NULL harq_process pointer\n"); + return; } double Coderate = 0.0; @@ -520,19 +509,11 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, uint8_t n_layers = pusch_pdu->nrOfLayers; // ------------------------------------------------------------------ - uint32_t i; - - __m128i *pv = (__m128i*)&z; - __m128i *pl = (__m128i*)&l; - - if (!ulsch_llr) { - printf("ulsch_decoding.c: NULL ulsch_llr pointer\n"); - return (ulsch->max_ldpc_iterations + 1); + LOG_E(PHY,"ulsch_decoding.c: NULL ulsch_llr pointer\n"); + return; } - // harq_process->trials[nfapi_ulsch_pdu_rel15->round]++; - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_gNB_ULSCH_DECODING,1); harq_process->TBS = pusch_pdu->pusch_data.tb_size; harq_process->round = nr_rv_round_map[pusch_pdu->pusch_data.rv_index]; @@ -594,14 +575,14 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, &harq_process->F, p_decParams->BG); - Tbslbrm = nr_compute_tbslbrm(0,nb_rb,n_layers,harq_process->C); - #ifdef DEBUG_ULSCH_DECODING printf("ulsch decoding nr segmentation Z %d\n", harq_process->Z); if (!frame%100) printf("K %d C %d Z %d \n", harq_process->K, harq_process->C, harq_process->Z); #endif } + Tbslbrm = nr_compute_tbslbrm(0,nb_rb,n_layers,harq_process->C); + p_decParams->Z = harq_process->Z; @@ -619,16 +600,17 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, if (harq_process->C > a_segments) { LOG_E(PHY,"Illegal harq_process->C %d > %d\n",harq_process->C,a_segments); - return (ulsch->max_ldpc_iterations + 1); + return; } #ifdef DEBUG_ULSCH_DECODING printf("Segmentation: C %d, K %d\n",harq_process->C,harq_process->K); #endif for (r=0; rC; r++) { + E = nr_get_E(G, harq_process->C, Qm, n_layers, r); - union ldpcReqUnion id = {.s={ulsch->rnti,frame,slot,nr_tti_rx,0,0}}; + union ldpcReqUnion id = {.s={ulsch->rnti,frame,nr_tti_rx,0,0}}; notifiedFIFO_elt_t *req=newNotifiedFIFO_elt(sizeof(ldpcDecode_t), id.p, phy_vars_gNB->respDecode, nr_processULSegment); ldpcDecode_t * rdata=(ldpcDecode_t *) NotifiedFifoData(req); @@ -636,96 +618,25 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, rdata->ulsch_harq = harq_process; rdata->p_decoderParms = p_decParams; rdata->ulsch_llr = ulsch_llr; - rdata->Kc = Kc; + rdata->Kc = kc; rdata->segment_r = r; rdata->nbSegments = harq_process->C; rdata->E = E; rdata->A = A; rdata->Qm = Qm; rdata->r_offset = r_offset; + rdata->Kr_bytes = Kr_bytes; rdata->rv_index = pusch_pdu->pusch_data.rv_index; rdata->Tbslbrm = Tbslbrm; + rdata->offset = offset; + rdata->ulsch = ulsch; + rdata->ulsch_id = UE_id; + pushTpool(phy_vars_gNB->threadPool,req); + phy_vars_gNB->nbDecode++; + LOG_D(PHY,"Added a block to decode, in pipe: %d\n",phy_vars_gNB->nbDecode); r_offset += E; + offset += (Kr_bytes - (harq_process->F>>3) - ((harq_process->C>1)?3:0)); ////////////////////////////////////////////////////////////////////////////////////////// } - return ret; - - if (err_flag == 1) { - -#ifdef gNB_DEBUG_TRACE - LOG_I(PHY,"[gNB %d] ULSCH: Setting NAK for SFN/SF %d/%d (pid %d, status %d, round %d, TBS %d) Kr %d r %d\n", - phy_vars_gNB->Mod_id, frame, nr_tti_rx, harq_pid,harq_process->status, harq_process->round,harq_process->TBS,Kr,r); -#endif - - // harq_process->harq_ack.ack = 0; - // harq_process->harq_ack.harq_id = harq_pid; - // harq_process->harq_ack.send_harq_status = 1; - // harq_process->errors[harq_process->round]++; - //harq_process->round++; - - if (harq_process->round >= ulsch->Mlimit) { - harq_process->status = SCH_IDLE; - harq_process->round = 0; - harq_process->handled = 0; - ulsch->harq_mask &= ~(1 << harq_pid); - } - - // LOG_D(PHY,"[gNB %d] ULSCH: Setting NACK for nr_tti_rx %d (pid %d, pid status %d, round %d/Max %d, TBS %d)\n", - // phy_vars_gNB->Mod_id,nr_tti_rx,harq_pid,harq_process->status,harq_process->round,ulsch->Mlimit,harq_process->TBS); - - harq_process->handled = 1; - ret = ulsch->max_ldpc_iterations + 1; - - } else { - -#ifdef gNB_DEBUG_TRACE - LOG_I(PHY,"[gNB %d] ULSCH: Setting ACK for nr_tti_rx %d TBS %d\n", - phy_vars_gNB->Mod_id,nr_tti_rx,harq_process->TBS); -#endif - - harq_process->status = SCH_IDLE; - harq_process->round = 0; - // harq_process->handled = 0; - ulsch->harq_mask &= ~(1 << harq_pid); - // harq_process->harq_ack.ack = 1; - // harq_process->harq_ack.harq_id = harq_pid; - // harq_process->harq_ack.send_harq_status = 1; - - // LOG_D(PHY,"[gNB %d] ULSCH: Setting ACK for nr_tti_rx %d (pid %d, round %d, TBS %d)\n",phy_vars_gNB->Mod_id,nr_tti_rx,harq_pid,harq_process->round,harq_process->TBS); - - - // Reassembly of Transport block here - offset = 0; - Kr = harq_process->K; - Kr_bytes = Kr>>3; - - for (r=0; rC; r++) { - - memcpy(harq_process->b+offset, - harq_process->c[r], - Kr_bytes- - (harq_process->F>>3) -((harq_process->C>1)?3:0)); - - offset += (Kr_bytes - (harq_process->F>>3) - ((harq_process->C>1)?3:0)); - -#ifdef DEBUG_ULSCH_DECODING - printf("Segment %u : Kr = %u bytes\n", r, Kr_bytes); - printf("copied %d bytes to b sequence (harq_pid %d)\n", (Kr_bytes - (harq_process->F>>3)-((harq_process->C>1)?3:0)), harq_pid); - printf("b[0] = %x, c[%d] = %x\n", harq_process->b[offset], harq_process->F>>3, harq_process->c[r]); -#endif - - } - } - -#ifdef DEBUG_ULSCH_DECODING - LOG_I(PHY, "Decoder output (payload, TBS: %d): \n", harq_process->TBS); - for (i = 0; i < harq_process->TBS; i++) { - //harq_process_ul_ue->a[i] = (unsigned char) rand(); - //printf("a[%d]=0x%02x\n",i,harq_process_ul_ue->a[i]); - printf("%02x",harq_process->b[i]); - } -#endif - - ulsch->last_iteration_cnt = ret; - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_gNB_ULSCH_DECODING,0); - return(ret); + return; } diff --git a/openair1/PHY/defs_gNB.h b/openair1/PHY/defs_gNB.h index 90f26f8efe..609161dd86 100644 --- a/openair1/PHY/defs_gNB.h +++ b/openair1/PHY/defs_gNB.h @@ -465,37 +465,6 @@ typedef struct { uint8_t cl_done; } NR_gNB_PUSCH; -typedef struct LDPCDecode_s { - PHY_BARS_gNB *gNB; - NR_UL_gNB_HARQ_t *ulsch_harq; - t_nrLDPC_dec_params *p_decoderParms; - short* ulsch_llr; - int harq_pid; - int rv_index; - int A; - int E; - int Kc; - int Qm; - int nbSegments; - int segment_r; - int r_offset; - int Tbslbrm; - int decodeIterations; -} ldpcDecode_t - -struct ldpcReqId { - uint16_t rnti; - uint16_t frame; - uint8_t subframe; - uint8_t codeblock; - uint16_t spare; -} __attribute__((packed)); - -union ldpcReqUnion { - struct ldpcReqId s; - uint64_t p; -}; - /// Context data structure for RX/TX portion of slot processing typedef struct { /// Component Carrier index @@ -840,4 +809,39 @@ typedef struct PHY_VARS_gNB_s { } PHY_VARS_gNB; +typedef struct LDPCDecode_s { + PHY_VARS_gNB *gNB; + NR_UL_gNB_HARQ_t *ulsch_harq; + t_nrLDPC_dec_params *p_decoderParms; + NR_gNB_ULSCH_t *ulsch; + short* ulsch_llr; + int ulsch_id; + int harq_pid; + int rv_index; + int A; + int E; + int Kc; + int Qm; + int Kr_bytes; + int nbSegments; + int segment_r; + int r_offset; + int offset; + int Tbslbrm; + int decodeIterations; +} ldpcDecode_t; + +struct ldpcReqId { + uint16_t rnti; + uint16_t frame; + uint8_t subframe; + uint8_t codeblock; + uint16_t spare; +} __attribute__((packed)); + +union ldpcReqUnion { + struct ldpcReqId s; + uint64_t p; +}; + #endif diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index b4dcc77eff..2c91f3b255 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -225,16 +225,68 @@ void phy_procedures_gNB_TX(PHY_VARS_gNB *gNB, */ -void nr_postDecode(PHY_VARS_gNB gNB, notifiedFIFO_elt_t *req) { - ldpcDecode_t *rdata = (ldpcDeocde_t*) NotifiedFifoData(req); - NR_UL_gNB_HARQ_t ulsch_harq = rdata->ulsch_harq; +void nr_postDecode(PHY_VARS_gNB *gNB, notifiedFIFO_elt_t *req) { + ldpcDecode_t *rdata = (ldpcDecode_t*) NotifiedFifoData(req); + NR_UL_gNB_HARQ_t *ulsch_harq = rdata->ulsch_harq; + NR_gNB_ULSCH_t *ulsch = rdata->ulsch; + int r = rdata->segment_r; - bool decodeSuccess = (rdata->deocdeIterations <= rdata->p_decoderParms->numMaxIter); + bool decodeSuccess = (rdata->decodeIterations <= rdata->p_decoderParms->numMaxIter); ulsch_harq->processedSegments++; LOG_D(PHY, "processing result of segment: %d, processed %d/%d\n", rdata->segment_r, ulsch_harq->processedSegments, rdata->nbSegments); - proc->nbDecode--; - LOG_D(PHY,"remain to decoded in subframe: %d\n", proc->nbDecode); + gNB->nbDecode--; + LOG_D(PHY,"remain to decoded in subframe: %d\n", gNB->nbDecode); + + if (decodeSuccess) { + memcpy(ulsch_harq->b+rdata->offset, + ulsch_harq->c[r], + rdata->Kr_bytes- - (ulsch_harq->F>>3) -((ulsch_harq->C>1)?3:0)); + + } else { + if ( rdata->nbSegments != ulsch_harq->processedSegments ) { + int nb=abortTpool(gNB->threadPool, req->key); + nb+=abortNotifiedFIFO(gNB->respDecode, req->key); + gNB->nbDecode-=nb; + LOG_D(PHY,"uplink segment error %d/%d, aborted %d segments\n",rdata->segment_r,rdata->nbSegments, nb); + LOG_D(PHY, "ULSCH %d in error\n",rdata->ulsch_id); + AssertFatal(ulsch_harq->processedSegments+nb == rdata->nbSegments,"processed: %d, aborted: %d, total %d\n", + ulsch_harq->processedSegments, nb, rdata->nbSegments); + ulsch_harq->processedSegments=rdata->nbSegments; + } + } + + // if all segments are done + if (rdata->nbSegments == ulsch_harq->processedSegments) { + if (decodeSuccess) { + LOG_I(PHY,"[gNB %d] ULSCH: Setting ACK for nr_tti_rx %d TBS %d\n", + gNB->Mod_id,ulsch_harq->slot,ulsch_harq->TBS); + ulsch_harq->status = SCH_IDLE; + ulsch_harq->round = 0; + ulsch->harq_mask &= ~(1 << rdata->harq_pid); + + LOG_D(PHY, "ULSCH received ok \n"); + nr_fill_indication(gNB,ulsch_harq->frame, ulsch_harq->slot, rdata->ulsch_id, rdata->harq_pid, 0); + } else { + LOG_D(PHY,"[gNB %d] ULSCH: Setting NAK for SFN/SF %d/%d (pid %d, status %d, round %d, TBS %d) r %d\n", + gNB->Mod_id, ulsch_harq->frame, ulsch_harq->slot, + rdata->harq_pid,ulsch_harq->status, ulsch_harq->round,ulsch_harq->TBS,r); + if (ulsch_harq->round >= ulsch->Mlimit) { + ulsch_harq->status = SCH_IDLE; + ulsch_harq->round = 0; + ulsch_harq->handled = 0; + ulsch->harq_mask &= ~(1 << rdata->harq_pid); + } + ulsch_harq->handled = 1; + + LOG_D(PHY, "ULSCH %d in error\n",rdata->ulsch_id); + nr_fill_indication(gNB,ulsch_harq->frame, ulsch_harq->slot, rdata->ulsch_id, rdata->harq_pid, 1); + } + ulsch->last_iteration_cnt = rdata->decodeIterations; + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_gNB_ULSCH_DECODING,0); + } +} + void nr_ulsch_procedures(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, int ULSCH_id, uint8_t harq_pid) { @@ -310,14 +362,6 @@ void nr_ulsch_procedures(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, int ULSCH delNotifiedFIFO_elt(req); } - if (ret > gNB->ulsch[ULSCH_id][0]->max_ldpc_iterations){ - LOG_D(PHY, "ULSCH %d in error\n",ULSCH_id); - nr_fill_indication(gNB,frame_rx, slot_rx, ULSCH_id, harq_pid, 1); - } - else if(gNB->ulsch[ULSCH_id][0]->harq_processes[harq_pid]->b!=NULL){ - LOG_D(PHY, "ULSCH received ok \n"); - nr_fill_indication(gNB,frame_rx, slot_rx, ULSCH_id, harq_pid, 0); - } } From 3e3af2c11bc2e2b85eacbbca95d4c43a533466e4 Mon Sep 17 00:00:00 2001 From: Sakthivel Velumani Date: Thu, 27 Aug 2020 12:42:25 +0200 Subject: [PATCH 03/96] bugfixes --- cmake_targets/CMakeLists.txt | 1 + executables/nr-gnb.c | 5 +++++ openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c | 10 ++++++---- openair1/SCHED_NR/phy_procedures_nr_gNB.c | 5 +++-- openair1/SIMULATION/NR_PHY/ulsim.c | 11 ++++++++--- 5 files changed, 23 insertions(+), 9 deletions(-) diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index 61665ae71e..6011e47aee 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -3022,6 +3022,7 @@ target_link_libraries(nr_ulschsim add_executable(nr_ulsim ${OPENAIR1_DIR}/SIMULATION/NR_PHY/ulsim.c + ${OPENAIR_DIR}/common/utils/threadPool/thread-pool.c ${OPENAIR_DIR}/common/utils/utils.c ${OPENAIR_DIR}/common/utils/system.c ${OPENAIR_DIR}/common/utils/nr/nr_common.c diff --git a/executables/nr-gnb.c b/executables/nr-gnb.c index 27b0ed08dd..b5c2e53a04 100644 --- a/executables/nr-gnb.c +++ b/executables/nr-gnb.c @@ -793,6 +793,11 @@ void init_gNB_proc(int inst) { pthread_mutex_init(&sync_phy_proc.mutex_phy_proc_tx, NULL); pthread_cond_init(&sync_phy_proc.cond_phy_proc_tx, NULL); sync_phy_proc.phy_proc_CC_id = 0; + + gNB->threadPool = (tpool_t*)malloc(sizeof(tpool_t)); + gNB->respDecode = (notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t)); + initTpool("n", gNB->threadPool, true); + initNotifiedFIFO(gNB->respDecode); } diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c index a5c1d2842a..082fbf0966 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c +++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c @@ -330,7 +330,7 @@ uint32_t nr_processULSegment(void* arg) { t_nrLDPC_time_stats procTime; t_nrLDPC_time_stats* p_procTime = &procTime ; - start_meas(&phy_vars_gNB->ulsch_deinterleaving_stats); + //start_meas(&phy_vars_gNB->ulsch_deinterleaving_stats); //////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////// nr_deinterleaving_ldpc /////////////////////////////////// @@ -367,7 +367,7 @@ uint32_t nr_processULSegment(void* arg) { ///////////////////////// ulsch_harq->e =====> ulsch_harq->d ///////////////////////// - start_meas(&phy_vars_gNB->ulsch_rate_unmatching_stats); + //start_meas(&phy_vars_gNB->ulsch_rate_unmatching_stats); if (nr_rate_matching_ldpc_rx(Ilbrm, Tbslbrm, @@ -406,7 +406,7 @@ uint32_t nr_processULSegment(void* arg) { length_dec = (ulsch_harq->B+24*ulsch_harq->C)/ulsch_harq->C; } - start_meas(&phy_vars_gNB->ulsch_ldpc_decoding_stats); + //start_meas(&phy_vars_gNB->ulsch_ldpc_decoding_stats); memset(pv,0,2*ulsch_harq->Z*sizeof(int16_t)); memset((pv+K_bytes_F),127,ulsch_harq->F*sizeof(int16_t)); @@ -456,7 +456,7 @@ uint32_t nr_processULSegment(void* arg) { ulsch_harq->c[r][m]= (uint8_t) llrProcBuf[m]; } - stop_meas(&phy_vars_gNB->ulsch_ldpc_decoding_stats); + //stop_meas(&phy_vars_gNB->ulsch_ldpc_decoding_stats); } uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, @@ -493,6 +493,7 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, int Kr_bytes = Kr>>3; phy_vars_gNB->nbDecode = 0; + harq_process->processedSegments = 0; if (!harq_process) { LOG_E(PHY,"ulsch_decoding.c: NULL harq_process pointer\n"); @@ -619,6 +620,7 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, rdata->p_decoderParms = p_decParams; rdata->ulsch_llr = ulsch_llr; rdata->Kc = kc; + rdata->harq_pid = harq_pid; rdata->segment_r = r; rdata->nbSegments = harq_process->C; rdata->E = E; diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index 2c91f3b255..8f75333690 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -268,7 +268,7 @@ void nr_postDecode(PHY_VARS_gNB *gNB, notifiedFIFO_elt_t *req) { LOG_D(PHY, "ULSCH received ok \n"); nr_fill_indication(gNB,ulsch_harq->frame, ulsch_harq->slot, rdata->ulsch_id, rdata->harq_pid, 0); } else { - LOG_D(PHY,"[gNB %d] ULSCH: Setting NAK for SFN/SF %d/%d (pid %d, status %d, round %d, TBS %d) r %d\n", + LOG_I(PHY,"[gNB %d] ULSCH: Setting NAK for SFN/SF %d/%d (pid %d, status %d, round %d, TBS %d) r %d\n", gNB->Mod_id, ulsch_harq->frame, ulsch_harq->slot, rdata->harq_pid,ulsch_harq->status, ulsch_harq->round,ulsch_harq->TBS,r); if (ulsch_harq->round >= ulsch->Mlimit) { @@ -354,13 +354,13 @@ void nr_ulsch_procedures(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, int ULSCH slot_rx, harq_pid, G); - stop_meas(&gNB->ulsch_decoding_stats); while (gNB->nbDecode > 0) { notifiedFIFO_elt_t *req=pullTpool(gNB->respDecode, gNB->threadPool); nr_postDecode(gNB, req); delNotifiedFIFO_elt(req); } + stop_meas(&gNB->ulsch_decoding_stats); } @@ -374,6 +374,7 @@ void nr_fill_indication(PHY_VARS_gNB *gNB, int frame, int slot_rx, int ULSCH_id, uint16_t mu = gNB->frame_parms.numerology_index; NR_gNB_ULSCH_t *ulsch = gNB->ulsch[ULSCH_id][0]; NR_UL_gNB_HARQ_t *harq_process = ulsch->harq_processes[harq_pid]; + printf("ulsch_id %d harq_pid %d\n",ULSCH_id,harq_pid); nfapi_nr_pusch_pdu_t *pusch_pdu = &harq_process->ulsch_pdu; diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c index 6c62e96130..35992e5131 100644 --- a/openair1/SIMULATION/NR_PHY/ulsim.c +++ b/openair1/SIMULATION/NR_PHY/ulsim.c @@ -56,6 +56,7 @@ //#include "openair1/SIMULATION/NR_PHY/nr_dummy_functions.c" #include "openair2/LAYER2/NR_MAC_UE/mac_proto.h" #include "openair2/LAYER2/NR_MAC_gNB/mac_proto.h" +#include "common/utils/threadPool/thread-pool.h" #define inMicroS(a) (((double)(a))/(cpu_freq_GHz*1000.0)) #include "SIMULATION/LTE_PHY/common_sim.h" @@ -470,6 +471,10 @@ int main(int argc, char **argv) RC.gNB = (PHY_VARS_gNB **) malloc(sizeof(PHY_VARS_gNB *)); RC.gNB[0] = malloc(sizeof(PHY_VARS_gNB)); gNB = RC.gNB[0]; + gNB->threadPool = (tpool_t*)malloc(sizeof(tpool_t)); + gNB->respDecode = (notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t)); + initTpool("n", gNB->threadPool, true); + initNotifiedFIFO(gNB->respDecode); //gNB_config = &gNB->gNB_config; //memset((void *)&gNB->UL_INFO,0,sizeof(gNB->UL_INFO)); @@ -1050,9 +1055,9 @@ int main(int argc, char **argv) printStatIndent2(&gNB->ulsch_llr_stats,"ULSCH llr computation"); printStatIndent(&gNB->ulsch_unscrambling_stats,"ULSCH unscrambling"); printStatIndent(&gNB->ulsch_decoding_stats,"ULSCH total decoding time"); - printStatIndent2(&gNB->ulsch_deinterleaving_stats,"ULSCH deinterleaving"); - printStatIndent2(&gNB->ulsch_rate_unmatching_stats,"ULSCH rate matching rx"); - printStatIndent2(&gNB->ulsch_ldpc_decoding_stats,"ULSCH ldpc decoding"); + //printStatIndent2(&gNB->ulsch_deinterleaving_stats,"ULSCH deinterleaving"); + //printStatIndent2(&gNB->ulsch_rate_unmatching_stats,"ULSCH rate matching rx"); + //printStatIndent2(&gNB->ulsch_ldpc_decoding_stats,"ULSCH ldpc decoding"); printf("\n"); } From 478c7352b3f32eb38a4886e55f7048dae851cb71 Mon Sep 17 00:00:00 2001 From: Sakthivel Velumani Date: Thu, 27 Aug 2020 13:06:48 +0200 Subject: [PATCH 04/96] fixes --- openair1/SCHED_NR/phy_procedures_nr_gNB.c | 5 ++--- openair1/SIMULATION/NR_PHY/ulsim.c | 22 +++++++++++----------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index 8f75333690..c746494a2b 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -259,7 +259,7 @@ void nr_postDecode(PHY_VARS_gNB *gNB, notifiedFIFO_elt_t *req) { // if all segments are done if (rdata->nbSegments == ulsch_harq->processedSegments) { if (decodeSuccess) { - LOG_I(PHY,"[gNB %d] ULSCH: Setting ACK for nr_tti_rx %d TBS %d\n", + LOG_D(PHY,"[gNB %d] ULSCH: Setting ACK for nr_tti_rx %d TBS %d\n", gNB->Mod_id,ulsch_harq->slot,ulsch_harq->TBS); ulsch_harq->status = SCH_IDLE; ulsch_harq->round = 0; @@ -268,7 +268,7 @@ void nr_postDecode(PHY_VARS_gNB *gNB, notifiedFIFO_elt_t *req) { LOG_D(PHY, "ULSCH received ok \n"); nr_fill_indication(gNB,ulsch_harq->frame, ulsch_harq->slot, rdata->ulsch_id, rdata->harq_pid, 0); } else { - LOG_I(PHY,"[gNB %d] ULSCH: Setting NAK for SFN/SF %d/%d (pid %d, status %d, round %d, TBS %d) r %d\n", + LOG_D(PHY,"[gNB %d] ULSCH: Setting NAK for SFN/SF %d/%d (pid %d, status %d, round %d, TBS %d) r %d\n", gNB->Mod_id, ulsch_harq->frame, ulsch_harq->slot, rdata->harq_pid,ulsch_harq->status, ulsch_harq->round,ulsch_harq->TBS,r); if (ulsch_harq->round >= ulsch->Mlimit) { @@ -374,7 +374,6 @@ void nr_fill_indication(PHY_VARS_gNB *gNB, int frame, int slot_rx, int ULSCH_id, uint16_t mu = gNB->frame_parms.numerology_index; NR_gNB_ULSCH_t *ulsch = gNB->ulsch[ULSCH_id][0]; NR_UL_gNB_HARQ_t *harq_process = ulsch->harq_processes[harq_pid]; - printf("ulsch_id %d harq_pid %d\n",ULSCH_id,harq_pid); nfapi_nr_pusch_pdu_t *pusch_pdu = &harq_process->ulsch_pdu; diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c index 35992e5131..635245b320 100644 --- a/openair1/SIMULATION/NR_PHY/ulsim.c +++ b/openair1/SIMULATION/NR_PHY/ulsim.c @@ -707,6 +707,17 @@ int main(int argc, char **argv) int n_errors[4] = {0,0,0,0};; int round_trials[4]={0,0,0,0}; uint32_t errors_scrambling[4] = {0,0,0,0}; + reset_meas(&gNB->phy_proc_rx); + reset_meas(&gNB->rx_pusch_stats); + reset_meas(&gNB->ulsch_decoding_stats); + reset_meas(&gNB->ulsch_deinterleaving_stats); + reset_meas(&gNB->ulsch_rate_unmatching_stats); + reset_meas(&gNB->ulsch_ldpc_decoding_stats); + reset_meas(&gNB->ulsch_unscrambling_stats); + reset_meas(&gNB->ulsch_channel_estimation_stats); + reset_meas(&gNB->ulsch_llr_stats); + reset_meas(&gNB->ulsch_channel_compensation_stats); + reset_meas(&gNB->ulsch_rbs_extraction_stats); for (trial = 0; trial < n_trials; trial++) { uint8_t round = 0; @@ -718,17 +729,6 @@ int main(int argc, char **argv) ulsch_ue[0]->harq_processes[harq_pid]->round = round; gNB->ulsch[0][0]->harq_processes[harq_pid]->round = round; rv_index = nr_rv_round_map[round]; - reset_meas(&gNB->phy_proc_rx); - reset_meas(&gNB->rx_pusch_stats); - reset_meas(&gNB->ulsch_decoding_stats); - reset_meas(&gNB->ulsch_deinterleaving_stats); - reset_meas(&gNB->ulsch_rate_unmatching_stats); - reset_meas(&gNB->ulsch_ldpc_decoding_stats); - reset_meas(&gNB->ulsch_unscrambling_stats); - reset_meas(&gNB->ulsch_channel_estimation_stats); - reset_meas(&gNB->ulsch_llr_stats); - reset_meas(&gNB->ulsch_channel_compensation_stats); - reset_meas(&gNB->ulsch_rbs_extraction_stats); UE_proc.nr_tti_tx = slot; UE_proc.frame_tx = frame; From 57dec19ac87f4952967a04e5970520123b8642a1 Mon Sep 17 00:00:00 2001 From: Sakthivel Velumani Date: Thu, 27 Aug 2020 18:23:29 +0200 Subject: [PATCH 05/96] fixed thread init; ulsim runs fine --- openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c | 6 +++--- openair1/PHY/defs_gNB.h | 2 +- openair1/SCHED_NR/phy_procedures_nr_gNB.c | 2 +- openair1/SIMULATION/NR_PHY/ulsim.c | 3 ++- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c index 082fbf0966..1731091659 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c +++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c @@ -293,7 +293,7 @@ uint32_t nr_processULSegment(void* arg) { ldpcDecode_t *rdata = (ldpcDecode_t*) arg; PHY_VARS_gNB *phy_vars_gNB = rdata->gNB; NR_UL_gNB_HARQ_t *ulsch_harq = rdata->ulsch_harq; - t_nrLDPC_dec_params *p_decoderParms = rdata->p_decoderParms; + t_nrLDPC_dec_params *p_decoderParms = &rdata->decoderParms; int length_dec; int no_iteration_ldpc; int Kr; @@ -311,7 +311,7 @@ uint32_t nr_processULSegment(void* arg) { uint8_t kc = rdata->Kc; uint32_t Tbslbrm = rdata->Tbslbrm; short* ulsch_llr = rdata->ulsch_llr; - int max_ldpc_iterations = rdata->p_decoderParms->numMaxIter; + int max_ldpc_iterations = p_decoderParms->numMaxIter; int8_t llrProcBuf[OAI_UL_LDPC_MAX_NUM_LLR] __attribute__ ((aligned(32))); int16_t z [68*384]; @@ -617,7 +617,7 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, rdata->gNB = phy_vars_gNB; rdata->ulsch_harq = harq_process; - rdata->p_decoderParms = p_decParams; + rdata->decoderParms = decParams; rdata->ulsch_llr = ulsch_llr; rdata->Kc = kc; rdata->harq_pid = harq_pid; diff --git a/openair1/PHY/defs_gNB.h b/openair1/PHY/defs_gNB.h index 609161dd86..7e185015a8 100644 --- a/openair1/PHY/defs_gNB.h +++ b/openair1/PHY/defs_gNB.h @@ -812,7 +812,7 @@ typedef struct PHY_VARS_gNB_s { typedef struct LDPCDecode_s { PHY_VARS_gNB *gNB; NR_UL_gNB_HARQ_t *ulsch_harq; - t_nrLDPC_dec_params *p_decoderParms; + t_nrLDPC_dec_params decoderParms; NR_gNB_ULSCH_t *ulsch; short* ulsch_llr; int ulsch_id; diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index c746494a2b..847731b89c 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -231,7 +231,7 @@ void nr_postDecode(PHY_VARS_gNB *gNB, notifiedFIFO_elt_t *req) { NR_gNB_ULSCH_t *ulsch = rdata->ulsch; int r = rdata->segment_r; - bool decodeSuccess = (rdata->decodeIterations <= rdata->p_decoderParms->numMaxIter); + bool decodeSuccess = (rdata->decodeIterations <= rdata->decoderParms.numMaxIter); ulsch_harq->processedSegments++; LOG_D(PHY, "processing result of segment: %d, processed %d/%d\n", rdata->segment_r, ulsch_harq->processedSegments, rdata->nbSegments); diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c index 635245b320..91daffb76b 100644 --- a/openair1/SIMULATION/NR_PHY/ulsim.c +++ b/openair1/SIMULATION/NR_PHY/ulsim.c @@ -473,7 +473,8 @@ int main(int argc, char **argv) gNB = RC.gNB[0]; gNB->threadPool = (tpool_t*)malloc(sizeof(tpool_t)); gNB->respDecode = (notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t)); - initTpool("n", gNB->threadPool, true); + char tp_param[] = "-1,-1,-1,-1,-1,-1"; + initTpool(tp_param, gNB->threadPool, false); initNotifiedFIFO(gNB->respDecode); //gNB_config = &gNB->gNB_config; From 1fc73ba77f6f929f64b9f792d55f2179fcdb37db Mon Sep 17 00:00:00 2001 From: Sakthi Date: Thu, 27 Aug 2020 21:50:35 +0200 Subject: [PATCH 06/96] fixing nr-softmodem --- cmake_targets/CMakeLists.txt | 1 + executables/nr-gnb.c | 3 ++- openair1/SIMULATION/NR_PHY/ulsim.c | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index 6011e47aee..3c91ddecfd 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -2753,6 +2753,7 @@ add_executable(nr-softmodem ${s1ap_h} # ${OPENAIR_BIN_DIR}/messages_xml.h ${OPENAIR_DIR}/executables/nr-gnb.c + ${OPENAIR_DIR}/common/utils/threadPool/thread-pool.c ${OPENAIR_DIR}/executables/nr-ru.c ${OPENAIR_DIR}/executables/nr-softmodem.c ${OPENAIR_DIR}/executables/softmodem-common.c diff --git a/executables/nr-gnb.c b/executables/nr-gnb.c index b5c2e53a04..35325668dc 100644 --- a/executables/nr-gnb.c +++ b/executables/nr-gnb.c @@ -796,7 +796,8 @@ void init_gNB_proc(int inst) { gNB->threadPool = (tpool_t*)malloc(sizeof(tpool_t)); gNB->respDecode = (notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t)); - initTpool("n", gNB->threadPool, true); + char ul_pool[] = "-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1"; + initTpool(ul_pool, gNB->threadPool, false); initNotifiedFIFO(gNB->respDecode); } diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c index 91daffb76b..e1697af44d 100644 --- a/openair1/SIMULATION/NR_PHY/ulsim.c +++ b/openair1/SIMULATION/NR_PHY/ulsim.c @@ -473,8 +473,8 @@ int main(int argc, char **argv) gNB = RC.gNB[0]; gNB->threadPool = (tpool_t*)malloc(sizeof(tpool_t)); gNB->respDecode = (notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t)); - char tp_param[] = "-1,-1,-1,-1,-1,-1"; - initTpool(tp_param, gNB->threadPool, false); + char tp_param[] = "n"; + initTpool(tp_param, gNB->threadPool, true); initNotifiedFIFO(gNB->respDecode); //gNB_config = &gNB->gNB_config; From a14dd04e1b708be9f014311d2dc9f03c6e6758e8 Mon Sep 17 00:00:00 2001 From: Thomas Schlichter Date: Fri, 28 Aug 2020 10:03:38 +0200 Subject: [PATCH 07/96] Fix memory allocation of gNB channel estimation arrays --- openair1/PHY/INIT/nr_init.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openair1/PHY/INIT/nr_init.c b/openair1/PHY/INIT/nr_init.c index 9e095d5ab5..3ff608f979 100644 --- a/openair1/PHY/INIT/nr_init.c +++ b/openair1/PHY/INIT/nr_init.c @@ -259,11 +259,11 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB, for (i=0; irxdataF_ext[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*N_RB_UL*12*fp->symbols_per_slot ); pusch_vars[ULSCH_id]->rxdataF_ext2[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*N_RB_UL*12*fp->symbols_per_slot ); - pusch_vars[ULSCH_id]->ul_ch_estimates[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*N_RB_UL*12*fp->symbols_per_slot ); + pusch_vars[ULSCH_id]->ul_ch_estimates[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*fp->ofdm_symbol_size*2*fp->symbols_per_slot ); pusch_vars[ULSCH_id]->ul_ch_estimates_ext[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*N_RB_UL*12*fp->symbols_per_slot ); pusch_vars[ULSCH_id]->ul_ch_estimates_time[i] = (int32_t *)malloc16_clear( 2*sizeof(int32_t)*fp->ofdm_symbol_size ); pusch_vars[ULSCH_id]->ul_ch_ptrs_estimates[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*fp->ofdm_symbol_size*2*fp->symbols_per_slot ); // max intensity in freq is 1 sc every 2 RBs - pusch_vars[ULSCH_id]->ul_ch_ptrs_estimates_ext[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*fp->ofdm_symbol_size*2*fp->symbols_per_slot ); + pusch_vars[ULSCH_id]->ul_ch_ptrs_estimates_ext[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*N_RB_UL*12*fp->symbols_per_slot ); pusch_vars[ULSCH_id]->rxdataF_comp[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*N_RB_UL*12*fp->symbols_per_slot ); pusch_vars[ULSCH_id]->ul_ch_mag0[i] = (int32_t *)malloc16_clear( fp->symbols_per_slot*sizeof(int32_t)*N_RB_UL*12 ); pusch_vars[ULSCH_id]->ul_ch_magb0[i] = (int32_t *)malloc16_clear( fp->symbols_per_slot*sizeof(int32_t)*N_RB_UL*12 ); From 8f09cc6c7515ee76c3b3a07bb417c9c756d5ffa1 Mon Sep 17 00:00:00 2001 From: Thomas Schlichter Date: Fri, 28 Aug 2020 14:27:20 +0200 Subject: [PATCH 08/96] fix UE UL DMRS generation if start_rb != 0 in nr_ue_ulsch_procedures() also do some code cleanup while at it... --- openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c | 130 +++++++++------------ 1 file changed, 58 insertions(+), 72 deletions(-) diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c index 6f607e05db..a63c33078b 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c @@ -101,41 +101,39 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, LOG_D(PHY,"nr_ue_ulsch_procedures hard_id %d %d.%d\n",harq_pid,frame,slot); uint32_t available_bits; - uint8_t mod_order, cwd_index, num_of_codewords, l; + uint8_t mod_order, cwd_index, l; uint32_t scrambled_output[NR_MAX_NB_CODEWORDS][NR_MAX_PDSCH_ENCODED_LENGTH>>5]; - uint32_t ***pusch_dmrs; int16_t **tx_layers; int32_t **txdataF; - uint16_t start_sc, start_rb; int8_t Wf[2], Wt[2], l_prime[2], delta; - uint16_t rnti, n_dmrs, code_rate, number_dmrs_symbols, nb_rb, k; - uint8_t dmrs_type, nb_dmrs_re_per_rb, number_of_symbols, mcs, Nl; - int ap, start_symbol, Nid_cell, i; - int sample_offsetF, N_RE_prime, N_PRB_oh; - uint16_t ul_dmrs_symb_pos; - uint8_t L_ptrs, K_ptrs; // PTRS parameters - uint16_t beta_ptrs; // PTRS parameter related to power control + uint16_t rnti, code_rate, nb_rb; + uint8_t nb_dmrs_re_per_rb,mcs, Nl; + int ap, i; + int sample_offsetF, N_RE_prime; - NR_UE_ULSCH_t *ulsch_ue; - NR_UL_UE_HARQ_t *harq_process_ul_ue=NULL; NR_DL_FRAME_PARMS *frame_parms = &UE->frame_parms; NR_UE_PUSCH *pusch_ue = UE->pusch_vars[thread_id][gNB_id]; // ptrs_UplinkConfig_t *ptrs_Uplink_Config = &UE->pusch_config.dmrs_UplinkConfig.ptrs_UplinkConfig; - num_of_codewords = 1; // tmp assumption - Nid_cell = 0; - N_PRB_oh = 0; // higher layer (RRC) parameter xOverhead in PUSCH-ServingCellConfig - number_dmrs_symbols = 0; + uint8_t num_of_codewords = 1; // tmp assumption + int Nid_cell = 0; + int N_PRB_oh = 0; // higher layer (RRC) parameter xOverhead in PUSCH-ServingCellConfig + uint16_t number_dmrs_symbols = 0; for (cwd_index = 0;cwd_index < num_of_codewords; cwd_index++) { - ulsch_ue = UE->ulsch[thread_id][gNB_id][cwd_index]; - harq_process_ul_ue = ulsch_ue->harq_processes[harq_pid]; + NR_UE_ULSCH_t *ulsch_ue = UE->ulsch[thread_id][gNB_id][cwd_index]; + NR_UL_UE_HARQ_t *harq_process_ul_ue = ulsch_ue->harq_processes[harq_pid]; - start_symbol = harq_process_ul_ue->pusch_pdu.start_symbol_index; - ul_dmrs_symb_pos = harq_process_ul_ue->pusch_pdu.ul_dmrs_symb_pos; - number_of_symbols = harq_process_ul_ue->pusch_pdu.nr_of_symbols; - dmrs_type = harq_process_ul_ue->pusch_pdu.dmrs_config_type; + int start_symbol = harq_process_ul_ue->pusch_pdu.start_symbol_index; + uint16_t ul_dmrs_symb_pos = harq_process_ul_ue->pusch_pdu.ul_dmrs_symb_pos; + uint8_t number_of_symbols = harq_process_ul_ue->pusch_pdu.nr_of_symbols; + uint8_t dmrs_type = harq_process_ul_ue->pusch_pdu.dmrs_config_type; + uint16_t start_rb = harq_process_ul_ue->pusch_pdu.rb_start; + uint16_t start_sc = frame_parms->first_carrier_offset + start_rb*NR_NB_SC_PER_RB; + + if (start_sc >= frame_parms->ofdm_symbol_size) + start_sc -= frame_parms->ofdm_symbol_size; for (i = start_symbol; i < start_symbol + number_of_symbols; i++) { @@ -210,14 +208,10 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, /////////// //////////////////////////////////////////////////////////////////////// - - //} - } - /////////////////////////DMRS Modulation///////////////////////// /////////// - pusch_dmrs = UE->nr_gold_pusch_dmrs[slot]; - n_dmrs = (nb_rb*((dmrs_type == pusch_dmrs_type1) ? 6:4)*number_dmrs_symbols); + uint32_t ***pusch_dmrs = UE->nr_gold_pusch_dmrs[slot]; + uint16_t n_dmrs = (start_rb+nb_rb)*((dmrs_type == pusch_dmrs_type1) ? 6:4); int16_t mod_dmrs[n_dmrs<<1]; /////////// //////////////////////////////////////////////////////////////////////// @@ -226,16 +220,15 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, /////////////////////////PTRS parameters' initialization///////////////////////// /////////// - int16_t mod_ptrs[(nb_rb/2)*(NR_SYMBOLS_PER_SLOT-1)*2]; // assume maximum number of PTRS per pusch allocation - K_ptrs = 0; // just to avoid a warning + int16_t mod_ptrs[nb_rb]; // assume maximum number of PTRS per pusch allocation + uint8_t L_ptrs, K_ptrs = 0; + uint16_t beta_ptrs = 1; // temp value until power control is implemented if (harq_process_ul_ue->pusch_pdu.pdu_bit_map & PUSCH_PDU_BITMAP_PUSCH_PTRS) { K_ptrs = (harq_process_ul_ue->pusch_pdu.pusch_ptrs.ptrs_freq_density)?4:2; L_ptrs = 1<pusch_pdu.pusch_ptrs.ptrs_time_density; - beta_ptrs = 1; // temp value until power control is implemented - ulsch_ue->ptrs_symbols = 0; set_ptrs_symb_idx(&ulsch_ue->ptrs_symbols, @@ -274,11 +267,6 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, for (l = start_symbol; l < start_symbol + number_of_symbols; l++) { if((ul_dmrs_symb_pos >> l) & 0x01) - is_dmrs = 1; - else - is_dmrs = 0; - - if (is_dmrs == 1) nb_re_dmrs_per_rb = nb_dmrs_re_per_rb; else nb_re_dmrs_per_rb = 0; @@ -303,47 +291,53 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, txdataF = UE->common_vars.txdataF; - start_rb = harq_process_ul_ue->pusch_pdu.rb_start; - start_sc = frame_parms->first_carrier_offset + start_rb*NR_NB_SC_PER_RB; - - if (start_sc >= frame_parms->ofdm_symbol_size) - start_sc -= frame_parms->ofdm_symbol_size; - for (ap=0; ap< Nl; ap++) { + uint8_t k_prime = 0; + uint16_t m = 0; + // DMRS params for this ap get_Wt(Wt, ap, dmrs_type); get_Wf(Wf, ap, dmrs_type); delta = get_delta(ap, dmrs_type); - - - uint8_t k_prime=0; - uint8_t is_dmrs, is_ptrs, is_dmrs_symbol; - uint16_t m=0, n=0, dmrs_idx=0, ptrs_idx = 0; for (l=start_symbol; l> l) & 0x01) { + is_dmrs_sym = 1; + + if (dmrs_type == pusch_dmrs_type1) + dmrs_idx = start_rb*6; + else + dmrs_idx = start_rb*4; + + nr_modulation(pusch_dmrs[l][0], n_dmrs*2, DMRS_MOD_ORDER, mod_dmrs); // currently only codeword 0 is modulated. Qm = 2 as DMRS is QPSK modulated + + } else if (harq_process_ul_ue->pusch_pdu.pdu_bit_map & PUSCH_PDU_BITMAP_PUSCH_PTRS) { + + if(is_ptrs_symbol(l, ulsch_ue->ptrs_symbols)) { + is_ptrs_sym = 1; + nr_modulation(pusch_dmrs[l][0], nb_rb, DMRS_MOD_ORDER, mod_ptrs); + } + } for (i=0; i< nb_rb*NR_NB_SC_PER_RB; i++) { + uint8_t is_dmrs = 0; + uint8_t is_ptrs = 0; + sample_offsetF = l*frame_parms->ofdm_symbol_size + k; - is_dmrs = 0; - is_ptrs = 0; - is_dmrs_symbol = 0; - - if((ul_dmrs_symb_pos >> l) & 0x01) { - is_dmrs_symbol = 1; + if (is_dmrs_sym) { if (k == ((start_sc+get_dmrs_freq_idx_ul(n, k_prime, delta, dmrs_type))%frame_parms->ofdm_symbol_size)) is_dmrs = 1; - } - - if (harq_process_ul_ue->pusch_pdu.pdu_bit_map & PUSCH_PDU_BITMAP_PUSCH_PTRS){ - - if(is_ptrs_symbol(l, ulsch_ue->ptrs_symbols)) + } else if (is_ptrs_sym) { is_ptrs = is_ptrs_subcarrier(k, rnti, ap, @@ -357,10 +351,6 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, if (is_dmrs == 1) { - if (k == start_sc){ - nr_modulation(pusch_dmrs[l][0], n_dmrs*2, DMRS_MOD_ORDER, mod_dmrs); // currently only codeword 0 is modulated. Qm = 2 as DMRS is QPSK modulated - } - ((int16_t*)txdataF[ap])[(sample_offsetF)<<1] = (Wt[l_prime[0]]*Wf[k_prime]*AMP*mod_dmrs[dmrs_idx<<1]) >> 15; ((int16_t*)txdataF[ap])[((sample_offsetF)<<1) + 1] = (Wt[l_prime[0]]*Wf[k_prime]*AMP*mod_dmrs[(dmrs_idx<<1) + 1]) >> 15; @@ -378,16 +368,12 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, } else if (is_ptrs == 1) { - if (k == start_sc){ - nr_modulation(pusch_dmrs[l][0], nb_rb, DMRS_MOD_ORDER, mod_ptrs); - } - ((int16_t*)txdataF[ap])[(sample_offsetF)<<1] = (beta_ptrs*AMP*mod_ptrs[ptrs_idx<<1]) >> 15; ((int16_t*)txdataF[ap])[((sample_offsetF)<<1) + 1] = (beta_ptrs*AMP*mod_ptrs[(ptrs_idx<<1) + 1]) >> 15; ptrs_idx++; - } else if (!is_dmrs_symbol || allowed_xlsch_re_in_dmrs_symbol(k,start_sc,harq_process_ul_ue->pusch_pdu.num_dmrs_cdm_grps_no_data,dmrs_type)) { + } else if (!is_dmrs_sym || allowed_xlsch_re_in_dmrs_symbol(k,start_sc,harq_process_ul_ue->pusch_pdu.num_dmrs_cdm_grps_no_data,dmrs_type)) { ((int16_t*)txdataF[ap])[(sample_offsetF)<<1] = ((int16_t *) ulsch_ue->y)[m<<1]; ((int16_t*)txdataF[ap])[((sample_offsetF)<<1) + 1] = ((int16_t *) ulsch_ue->y)[(m<<1) + 1]; @@ -412,8 +398,8 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, } } } + } - //} NR_UL_UE_HARQ_t *harq_process_ulsch=NULL; harq_process_ulsch = UE->ulsch[thread_id][gNB_id][0]->harq_processes[harq_pid]; harq_process_ulsch->status = SCH_IDLE; From 892dffec3b4b6c70ffcaea6823796531e27a468c Mon Sep 17 00:00:00 2001 From: Sakthivel Velumani Date: Tue, 1 Sep 2020 10:07:18 +0200 Subject: [PATCH 09/96] dlsim perf print fix --- openair1/SIMULATION/NR_PHY/dlsim.c | 33 +++++++++++++++--------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index f392696f28..b16015a77e 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -957,22 +957,6 @@ int main(int argc, char **argv) printf("SNR %f : n_errors (negative CRC) = %d/%d, Avg round %.2f, Channel BER %e, Eff Rate %.4f bits/slot, Eff Throughput %.2f, TBS %d bits/slot\n", SNR, n_errors, n_trials,roundStats[snrRun],(double)errors_scrambling/available_bits/n_trials,effRate,effRate/TBS*100,TBS); printf("\n"); - if (n_trials == 1) { - - LOG_M("rxsig0.m","rxs0", UE->common_vars.rxdata[0], frame_length_complex_samples, 1, 1); - if (UE->frame_parms.nb_antennas_rx>1) - LOG_M("rxsig1.m","rxs1", UE->common_vars.rxdata[1], frame_length_complex_samples, 1, 1); - LOG_M("chestF0.m","chF0",UE->pdsch_vars[0][0]->dl_ch_estimates_ext,N_RB_DL*12*14,1,1); - write_output("rxF_comp.m","rxFc",&UE->pdsch_vars[0][0]->rxdataF_comp0[0][0],N_RB_DL*12*14,1,1); - break; - } - - //if ((float)n_errors/(float)n_trials <= target_error_rate) { - if (effRate >= (eff_tp_check*TBS)) { - printf("PDSCH test OK\n"); - break; - } - if (print_perf==1) { printf("\ngNB TX function statistics (per %d us slot, NPRB %d, mcs %d, TBS %d, Kr %d (Zc %d))\n", 1000>>*scc->ssbSubcarrierSpacing,dlsch_config.rbSize,dlsch_config.mcsIndex[0], @@ -1023,6 +1007,23 @@ int main(int argc, char **argv) printStatIndent2(&UE->dlsch_tc_intl2_stats,"intl2+HardDecode+CRC"); */ } + + if (n_trials == 1) { + + LOG_M("rxsig0.m","rxs0", UE->common_vars.rxdata[0], frame_length_complex_samples, 1, 1); + if (UE->frame_parms.nb_antennas_rx>1) + LOG_M("rxsig1.m","rxs1", UE->common_vars.rxdata[1], frame_length_complex_samples, 1, 1); + LOG_M("chestF0.m","chF0",UE->pdsch_vars[0][0]->dl_ch_estimates_ext,N_RB_DL*12*14,1,1); + write_output("rxF_comp.m","rxFc",&UE->pdsch_vars[0][0]->rxdataF_comp0[0][0],N_RB_DL*12*14,1,1); + break; + } + + //if ((float)n_errors/(float)n_trials <= target_error_rate) { + if (effRate >= (eff_tp_check*TBS)) { + printf("PDSCH test OK\n"); + break; + } + snrRun++; } // NSR From 4715308bd2f4a8027f1cb8028923fc57cc8f2748 Mon Sep 17 00:00:00 2001 From: cig Date: Sat, 25 Jul 2020 11:41:20 +0200 Subject: [PATCH 10/96] Msg3 implementation - extraction of resource allocation from Msg2 - configuration of Msg3 PDU - Msg3 scheduling - MAC/PHY interface adaptations --- openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 34 +--- openair2/LAYER2/NR_MAC_UE/mac_defs.h | 4 + openair2/LAYER2/NR_MAC_UE/mac_proto.h | 12 ++ openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 112 +++++++++++- openair2/LAYER2/NR_MAC_UE/rar_tools_nrUE.c | 172 +++++++++++++++---- 5 files changed, 275 insertions(+), 59 deletions(-) diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index 9f0ac9ff20..b4b8b0fd71 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -2974,7 +2974,7 @@ void nr_ue_pdsch_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, int eNB void nr_process_rar(nr_downlink_indication_t *dl_info) { module_id_t module_id = dl_info->module_id; - int cc_id = dl_info->cc_id, frame_rx = dl_info->proc->frame_rx, nr_tti_rx = dl_info->proc->nr_tti_rx, ta_command, k2, delta; + int cc_id = dl_info->cc_id, frame_rx = dl_info->proc->frame_rx, nr_tti_rx = dl_info->proc->nr_tti_rx, ta_command, delta; uint8_t gNB_index = dl_info->gNB_index; // *rar; //fapi_nr_dci_indication_t *dci_ind = dl_info->dci_ind; PHY_VARS_NR_UE *ue = PHY_vars_UE_g[module_id][cc_id]; @@ -3015,6 +3015,7 @@ void nr_process_rar(nr_downlink_indication_t *dl_info) { ta_command = nr_ue_process_rar(ue->Mod_id, cc_id, frame_rx, + nr_tti_rx, dlsch0->harq_processes[0]->b, &ue->pdcch_vars[ue->current_thread_id[nr_tti_rx]][gNB_index]->pdcch_config[0].rnti, prach_resources->ra_PreambleIndex, @@ -3031,13 +3032,6 @@ void nr_process_rar(nr_downlink_indication_t *dl_info) { nr_process_timing_advance_rar(ue, dl_info->proc, ta_command); if (ue->mode != debug_prach) { - ue->ulsch_Msg3_active[gNB_index] = 1; - // TS 38.213 ch 8.3 Msg3 PUSCH - // PUSCH time domain resource allocation A for normal CP - // TS 38.214 ch 6.1.2.1.1 - k2 = table_6_1_2_1_1_2_time_dom_res_alloc_A[0][0]; - sliv_S = table_6_1_2_1_1_2_time_dom_res_alloc_A[0][1]; - sliv_L = table_6_1_2_1_1_2_time_dom_res_alloc_A[0][2]; switch (mu_pusch) { case 0: @@ -3054,28 +3048,10 @@ void nr_process_rar(nr_downlink_indication_t *dl_info) { break; } - ue->Msg3_startSymbol[gNB_index] = sliv_S; - ue->Msg3_Length[gNB_index] = sliv_L; - ue->ulsch_Msg3_subframe[gNB_index] = (nr_tti_rx + k2 + delta) % slots_per_frame; - if (nr_tti_rx + k2 + delta > slots_per_frame){ - ue->ulsch_Msg3_frame[gNB_index] = (frame_rx + 1) % 1024; - } else { - ue->ulsch_Msg3_frame[gNB_index] = frame_rx; - } + #ifdef DEBUG_RA + LOG_D(PHY,"[UE %d][RAPROC] Msg3 nr_tti_rx %d delta %d\n", ue->Mod_id, nr_tti_rx, delta); + #endif - LOG_D(PHY,"[UE %d][RAPROC] Got Msg3_alloc Frame %d subframe %d: Msg3_frame %d, Msg3_subframe %d\n", - ue->Mod_id, - frame_rx, - nr_tti_rx, - ue->ulsch_Msg3_frame[gNB_index], - ue->ulsch_Msg3_subframe[gNB_index]); - // harq_pid = subframe2harq_pid(&ue->frame_parms, - // ue->ulsch_Msg3_frame[gNB_index], - // ue->ulsch_Msg3_subframe[gNB_index]); - // ue->ulsch[gNB_index]->harq_processes[harq_pid]->round = 0; - // ue->Msg3_timer[gNB_index] = 10; - // ue->ulsch[gNB_index].power_offset = 6; - // ue->ulsch_no_allocation_counter[gNB_index] = 0; ue->UE_mode[gNB_index] = RA_RESPONSE; } } else { diff --git a/openair2/LAYER2/NR_MAC_UE/mac_defs.h b/openair2/LAYER2/NR_MAC_UE/mac_defs.h index e45f6a9b69..9b1b2835ce 100755 --- a/openair2/LAYER2/NR_MAC_UE/mac_defs.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_defs.h @@ -221,6 +221,10 @@ typedef struct { uint32_t RA_tx_frame; /// Random-access variable for window calculation (subframe of last change in window counter) uint8_t RA_tx_subframe; + /// Scheduled TX frame for RA Msg3 + frame_t msg3_frame; + /// Scheduled TX slot for RA Msg3 + slot_t msg3_slot; /// Random-access variable for backoff (frame of last change in backoff counter) uint32_t RA_backoff_frame; /// Random-access variable for backoff (subframe of last change in backoff counter) diff --git a/openair2/LAYER2/NR_MAC_UE/mac_proto.h b/openair2/LAYER2/NR_MAC_UE/mac_proto.h index e9d7a97a5d..4716c1b49d 100755 --- a/openair2/LAYER2/NR_MAC_UE/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_proto.h @@ -197,6 +197,17 @@ and fills the PRACH PDU per each FD occasion. */ void nr_ue_prach_scheduler(module_id_t module_idP, frame_t frameP, sub_frame_t slotP); +/* \brief This function schedules the Msg3 transmission +@param +@param +@param +@returns void +*/ +void nr_ue_msg3_scheduler(NR_UE_MAC_INST_t *mac, + frame_t current_frame, + sub_frame_t current_slot, + uint8_t Msg3_tda_id); + /* \brief Function called by PHY to process the received RAR and check that the preamble matches what was sent by the gNB. It provides the timing advance and t-CRNTI. @param Mod_id Index of UE instance @param CC_id Index to a component carrier @@ -212,6 +223,7 @@ random-access procedure uint16_t nr_ue_process_rar(module_id_t mod_id, int CC_id, frame_t frameP, + sub_frame_t slotP, uint8_t * dlsch_buffer, rnti_t * t_crnti, uint8_t preamble_index, diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index 60f331a086..0205b4e3f1 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -895,7 +895,6 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in scheduled_response.slot = rx_slot; scheduled_response.ul_config->slot = ul_info->slot_tx; - scheduled_response.ul_config->number_pdus = 1; scheduled_response.ul_config->ul_config_list[0].pdu_type = FAPI_NR_UL_CONFIG_TYPE_PUSCH; scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.rnti = rnti; scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.rb_size = rb_size; @@ -929,11 +928,122 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in // Note: Contention resolution is currently not active if (mac->RA_contention_resolution_timer_active == 1) ue_contention_resolution(mod_id, gNB_index, cc_id, ul_info->frame_tx); + + } else if (get_softmodem_params()->do_ra){ + + NR_UE_MAC_INST_t *mac = get_mac_inst(ul_info->module_id); + + if (ul_info->slot_tx == mac->msg3_slot && ul_info->frame_tx == mac->msg3_frame){ + + uint8_t ulsch_input_buffer[MAX_ULSCH_PAYLOAD_BYTES]; + nr_scheduled_response_t scheduled_response; + scheduled_response.ul_config = &mac->ul_config_request; + scheduled_response.dl_config = NULL; + scheduled_response.ul_config->number_pdus++; //TBR fix + fapi_nr_ul_config_request_pdu_t *ul_config_list = &scheduled_response.ul_config->ul_config_list[scheduled_response.ul_config->number_pdus - 1]; + fapi_nr_tx_request_t tx_req; + fapi_nr_tx_request_body_t tx_req_body; + + uint16_t TBS_bytes = scheduled_response.ul_config->ul_config_list[scheduled_response.ul_config->number_pdus - 1].pusch_config_pdu.pusch_data.tb_size; + + //if (IS_SOFTMODEM_NOS1){ + // // Getting IP traffic to be transmitted + // data_existing = nr_ue_get_sdu(mod_id, + // cc_id, + // frame_tx, + // slot_tx, + // 0, + // ulsch_input_buffer, + // TBS_bytes, + // &access_mode); + //} + + //Random traffic to be transmitted if there is no IP traffic available for this Tx opportunity + //if (!IS_SOFTMODEM_NOS1 || !data_existing) { + //Use zeros for the header bytes in noS1 mode, in order to make sure that the LCID is not valid + //and block this traffic from being forwarded to the upper layers at the gNB + printf("[DEBUG_MSG3] Random data to be tranmsitted (TBS_bytes %d, pdu_index %d ul_config (%p) list (%p): \n", TBS_bytes, scheduled_response.ul_config->number_pdus - 1, scheduled_response.ul_config, ul_config_list); + //Give the first byte a dummy value (a value not corresponding to any valid LCID based on 38.321, Table 6.2.1-2) + //in order to distinguish the PHY random packets at the MAC layer of the gNB receiver from the normal packets that should + //have a valid LCID (nr_process_mac_pdu function) + ulsch_input_buffer[0] = 0x31; + for (int i = 1; i < TBS_bytes; i++) { + ulsch_input_buffer[i] = (unsigned char) rand(); + //printf(" input encoder a[%d]=0x%02x\n",i,harq_process_ul_ue->a[i]); + } + //} + + LOG_D(MAC, "[UE %d] Frame %d, Subframe %d Adding Msg3 UL Config Request for rnti: %x\n", + ul_info->module_id, + ul_info->frame_tx, + ul_info->slot_tx, + mac->t_crnti); + + // Config UL TX PDU + tx_req.slot = ul_info->slot_tx; + tx_req.sfn = ul_info->frame_tx; + tx_req.number_of_pdus = 1; + tx_req_body.pdu_length = TBS_bytes; + tx_req_body.pdu_index = 0; + tx_req_body.pdu = ulsch_input_buffer; + ul_config_list->pdu_type = FAPI_NR_UL_CONFIG_TYPE_PUSCH; + scheduled_response.tx_request = &tx_req; + scheduled_response.tx_request->tx_request_body = &tx_req_body; + scheduled_response.module_id = ul_info->module_id; + scheduled_response.CC_id = ul_info->cc_id; + scheduled_response.frame = ul_info->frame_rx; + scheduled_response.slot = ul_info->slot_rx; + + if(mac->if_module != NULL && mac->if_module->scheduled_response != NULL){ + mac->if_module->scheduled_response(&scheduled_response); + } + } } } return UE_CONNECTION_OK; } +// Scheduling the Msg3 transmission according to according to TS 38.213 +// Note: Msg3 tx in the uplink symbols of mixed slot +void nr_ue_msg3_scheduler(NR_UE_MAC_INST_t *mac, + frame_t current_frame, + sub_frame_t current_slot, + uint8_t Msg3_tda_id){ + + int delta; + NR_BWP_Uplink_t *ubwp = mac->ULbwp[0]; + int mu = ubwp->bwp_Common->genericParameters.subcarrierSpacing; + struct NR_PUSCH_TimeDomainResourceAllocationList *pusch_TimeDomainAllocationList = ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; + // k2 as per 3GPP TS 38.214 version 15.9.0 Release 15 ch 6.1.2.1.1 + // PUSCH time domain resource allocation is higher layer configured from uschTimeDomainAllocationList in either pusch-ConfigCommon + uint8_t k2 = *pusch_TimeDomainAllocationList->list.array[Msg3_tda_id]->k2; + + switch (mu) { + case 0: + delta = 2; + break; + case 1: + delta = 3; + break; + case 2: + delta = 4; + break; + case 3: + delta = 6; + break; + } + + mac->msg3_slot = (current_slot + k2 + delta) % nr_slots_per_frame[mu]; + if (current_slot + k2 + delta > nr_slots_per_frame[mu]) + mac->msg3_frame = (current_frame + 1) % 1024; + else + mac->msg3_frame = current_frame; + + #ifdef DEBUG_MSG3 + LOG_D(MAC, "[DEBUG_MSG3] current_slot %d k2 %d delta %d temp_slot %d mac->msg3_frame %d mac->msg3_slot %d \n", current_slot, k2, delta, current_slot + k2 + delta, mac->msg3_frame, mac->msg3_slot); + #endif +} + // This function schedules the PRACH according to prach_ConfigurationIndex and TS 38.211, tables 6.3.3.2.x // It fills the PRACH PDU per each FD occasion. // PRACH formats 9, 10, 11 are corresponding to dual PRACH format configurations A1/B1, A2/B2, A3/B3. diff --git a/openair2/LAYER2/NR_MAC_UE/rar_tools_nrUE.c b/openair2/LAYER2/NR_MAC_UE/rar_tools_nrUE.c index 8d52db6747..d291e74e45 100644 --- a/openair2/LAYER2/NR_MAC_UE/rar_tools_nrUE.c +++ b/openair2/LAYER2/NR_MAC_UE/rar_tools_nrUE.c @@ -46,7 +46,8 @@ #include "NR_MAC_COMMON/nr_mac_extern.h" #include -#define DEBUG_RAR +// #define DEBUG_RAR +// #define DEBUG_MSG3 // table 7.2-1 TS 38.321 uint16_t table_7_2_1[16] = { @@ -66,6 +67,111 @@ uint16_t table_7_2_1[16] = { 1920, // row index 13 }; +void nr_config_Msg3_pdu(NR_UE_MAC_INST_t *mac, + int Msg3_f_alloc, + uint8_t Msg3_t_alloc, + uint8_t mcs, + uint8_t freq_hopping){ + + int f_alloc, mask, StartSymbolIndex, NrOfSymbols; + uint16_t TBS_bytes; + fapi_nr_ul_config_request_t *ul_config = &mac->ul_config_request; + ul_config->number_pdus++; + nfapi_nr_ue_pusch_pdu_t *pusch_config_pdu = &ul_config->ul_config_list[ul_config->number_pdus - 1].pusch_config_pdu; + NR_ServingCellConfigCommon_t *scc = mac->scc; + NR_BWP_Uplink_t *ubwp = mac->ULbwp[0]; + int startSymbolAndLength = ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[Msg3_t_alloc]->startSymbolAndLength; + + #ifdef DEBUG_MSG3 + printf("[DEBUG_MSG3] Configuring Msg3 PDU of %d UL pdus \n", ul_config->number_pdus); + #endif + + // active BWP start + int abwp_start = NRRIV2PRBOFFSET(ubwp->bwp_Common->genericParameters.locationAndBandwidth, 275); + int abwp_size = NRRIV2BW(ubwp->bwp_Common->genericParameters.locationAndBandwidth, 275); + + // initial BWP start + int ibwp_start = NRRIV2PRBOFFSET(scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, 275); + int ibwp_size = NRRIV2BW(scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, 275); + + //// Resource assignment from RAR + // Frequency domain allocation + if (abwp_size < 180) + mask = (1 << ((int) ceil(log2((abwp_size*(abwp_size+1))>>1)))) - 1; + else + mask = (1 << (28 - (int)(ceil(log2((abwp_size*(abwp_size+1))>>1))))) - 1; + f_alloc = Msg3_f_alloc & mask; + pusch_config_pdu->bwp_size = ibwp_size; + if ((ibwp_start < abwp_start) || (ibwp_size > abwp_size)) + pusch_config_pdu->bwp_start = abwp_start; + else + pusch_config_pdu->bwp_start = ibwp_start; + nr_ue_process_dci_freq_dom_resource_assignment(pusch_config_pdu, NULL, ibwp_size, 0, f_alloc); + // virtual resource block to physical resource mapping for Msg3 PUSCH (6.3.1.7 in 38.211) + pusch_config_pdu->rb_start += ibwp_start - abwp_start; + + // Time domain allocation + SLIV2SL(startSymbolAndLength, &StartSymbolIndex, &NrOfSymbols); + pusch_config_pdu->ul_dmrs_symb_pos = 1<start_symbol_index = StartSymbolIndex; + pusch_config_pdu->nr_of_symbols = NrOfSymbols; + + #ifdef DEBUG_MSG3 + printf("[DEBUG_MSG3] Freq assignment (RB start %d size %d) BWP (start %d, size %d), Time assignment (sliv_S %d sliv_L %d) \n", + pusch_config_pdu->rb_start, + pusch_config_pdu->rb_size, + pusch_config_pdu->bwp_start, + pusch_config_pdu->bwp_size, + StartSymbolIndex, + NrOfSymbols); + #endif + + // MCS + pusch_config_pdu->mcs_index = mcs; + // Frequency hopping + pusch_config_pdu->frequency_hopping = freq_hopping; + // TC-RNTI + pusch_config_pdu->rnti = mac->t_crnti; + + //// Completing PUSCH PDU + pusch_config_pdu->pdu_bit_map = PUSCH_PDU_BITMAP_PUSCH_DATA; + pusch_config_pdu->mcs_table = 0; + pusch_config_pdu->nrOfLayers = 0; + pusch_config_pdu->dmrs_config_type = 0; + // no data in dmrs symbols as in 6.2.2 in 38.214 + pusch_config_pdu->num_dmrs_cdm_grps_no_data = 2; // TBR + pusch_config_pdu->cyclic_prefix = 0; + pusch_config_pdu->target_code_rate = nr_get_code_rate_ul(pusch_config_pdu->mcs_index, pusch_config_pdu->mcs_table); + pusch_config_pdu->qam_mod_order = nr_get_Qm_ul(pusch_config_pdu->mcs_index, pusch_config_pdu->mcs_table); + if (scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->msg3_transformPrecoder == NULL) + pusch_config_pdu->transform_precoding = 1; + else + pusch_config_pdu->transform_precoding = 0; + pusch_config_pdu->data_scrambling_id = *scc->physCellId; + pusch_config_pdu->ul_dmrs_scrambling_id = *scc->physCellId; //If provided and the PUSCH is not a msg3 PUSCH, otherwise, L2 should set this to physical cell id. + pusch_config_pdu->scid = 0; //DMRS sequence initialization [TS38.211, sec 6.4.1.1.1]. Should match what is sent in DCI 0_1, otherwise set to 0. + pusch_config_pdu->dmrs_ports = 1; // 6.2.2 in 38.214 only port 0 to be used + pusch_config_pdu->resource_alloc = 1; //type 1 + pusch_config_pdu->subcarrier_spacing = ubwp->bwp_Common->genericParameters.subcarrierSpacing; + pusch_config_pdu->vrb_to_prb_mapping = 0; + pusch_config_pdu->uplink_frequency_shift_7p5khz = 0; + //Optional Data only included if indicated in pduBitmap + pusch_config_pdu->pusch_data.rv_index = 0; // 8.3 in 38.213 + pusch_config_pdu->pusch_data.harq_process_id = 0; + pusch_config_pdu->pusch_data.new_data_indicator = 1; // new data + pusch_config_pdu->pusch_data.num_cb = 0; + TBS_bytes = nr_compute_tbs(pusch_config_pdu->qam_mod_order, + pusch_config_pdu->target_code_rate, + pusch_config_pdu->rb_size, + pusch_config_pdu->nr_of_symbols, + 12, // TBR compute accordingly - nb dmrs set for no data in dmrs symbol + 0, // nb_rb_oh + 0, // to verify tb scaling + pusch_config_pdu->nrOfLayers = 1)/8; + pusch_config_pdu->pusch_data.tb_size = TBS_bytes; + +} + ///////////////////////////////////// // Random Access Response PDU // // TS 38.213 ch 8.2 // @@ -90,12 +196,13 @@ uint16_t table_7_2_1[16] = { //| F_alloc |Time allocation|// //| MCS | TPC |CSI|// ///////////////////////////////////// -// WIP todo: +// TbD WIP Msg3 development ongoing // - apply UL grant freq alloc & time alloc as per 8.2 TS 38.213 -// - apply tpc command, csi req, mcs +// - apply tpc command uint16_t nr_ue_process_rar(module_id_t mod_id, int CC_id, - frame_t frameP, + frame_t frame, + sub_frame_t slot, uint8_t * dlsch_buffer, rnti_t * t_crnti, uint8_t preamble_index, @@ -106,11 +213,7 @@ uint16_t nr_ue_process_rar(module_id_t mod_id, NR_MAC_RAR *rar = (NR_MAC_RAR *) (dlsch_buffer + 1); // RAR subPDU pointer uint8_t n_subPDUs = 0; // number of RAR payloads uint8_t n_subheaders = 0; // number of MAC RAR subheaders - //uint8_t best_rx_rapid = -1; // the closest RAPID receive from all RARs - //unsigned char freq_hopping, msg3_t_alloc, mcs, tpc_command, csi_req; // WIP - //uint16_t ta_command = 0, msg3_f_alloc, bwp_size; // WIP uint16_t ta_command = 0; - //int f_alloc, mask; // WIP AssertFatal(CC_id == 0, "RAR reception on secondary CCs is not supported yet\n"); @@ -139,17 +242,19 @@ uint16_t nr_ue_process_rar(module_id_t mod_id, } }; - LOG_D(MAC, "number of RAR subheader %d; number of RAR pyloads %d\n", n_subheaders, n_subPDUs); + #ifdef DEBUG_RAR + LOG_D(MAC, "[DEBUG_RAR] (%d,%d) number of RAR subheader %d; number of RAR pyloads %d\n", frame, slot, n_subheaders, n_subPDUs); + LOG_D(MAC, "[DEBUG_RAR] Received RAR (%02x|%02x.%02x.%02x.%02x.%02x.%02x) for preamble %d/%d\n", *(uint8_t *) rarh, rar[0], rar[1], rar[2], rar[3], rar[4], rar[5], rarh->RAPID, preamble_index); + #endif - // LOG_I(MAC, "[UE %d][RAPROC] Frame %d Received RAR (%02x|%02x.%02x.%02x.%02x.%02x.%02x) for preamble %d/%d\n", - // mod_id, frameP, *(uint8_t *) rarh, rar[0], rar[1], rar[2], rar[3], rar[4], rar[5], rarh->RAPID, preamble_index); - - #if 0 // TbD WIP Msg3 development ongoing if (ue_mac->RA_RAPID_found) { + + uint8_t freq_hopping, mcs, Msg3_t_alloc, Msg3_f_alloc; + unsigned char tpc_command, csi_req; + // TC-RNTI *t_crnti = rar->TCRNTI_2 + (rar->TCRNTI_1 << 8); ue_mac->t_crnti = *t_crnti; - ue_mac->rnti_type = NR_RNTI_TC; // TA command ta_command = rar->TA2 + (rar->TA1 << 5); // CSI @@ -182,27 +287,36 @@ uint16_t nr_ue_process_rar(module_id_t mod_id, ue_mac->Msg3_TPC = 8; break; } - //MCS + // MCS mcs = (unsigned char) (rar->UL_GRANT_4 >> 4); - // time and frequency alloc - bwp_size = NRRIV2BW(ue_mac->ULbwp[0]->bwp_Common->genericParameters.locationAndBandwidth,275); - msg3_t_alloc = (unsigned char) (rar->UL_GRANT_3 & 0x07); - msg3_f_alloc = (uint16_t) ((rar->UL_GRANT_3 >> 4) | (rar->UL_GRANT_2 << 4) | ((rar->UL_GRANT_1 & 0x03) << 12)); - - if (bwp_size < 180) - mask = (1 << ((int) ceil(log2((bwp_size*(bwp_size+1))>>1)))) - 1; - else - mask = (1 << (28 - (int)(ceil(log2((bwp_size*(bwp_size+1))>>1))))) - 1; - - f_alloc = msg3_f_alloc & mask; - - // frequency hopping flag + // time alloc + Msg3_t_alloc = (unsigned char) (rar->UL_GRANT_3 & 0x07); + // frequency alloc + Msg3_f_alloc = (uint16_t) ((rar->UL_GRANT_3 >> 4) | (rar->UL_GRANT_2 << 4) | ((rar->UL_GRANT_1 & 0x03) << 12)); + // frequency hopping freq_hopping = (unsigned char) (rar->UL_GRANT_1 >> 2); + + #ifdef DEBUG_RAR + LOG_D(MAC, "[DEBUG_RAR] Received RAR with t_alloc %d f_alloc %d ta_command %d mcs %d freq_hopping %d tpc_command %d csi_req %d t_crnti %x \n", + Msg3_t_alloc, + Msg3_f_alloc, + ta_command, + mcs, + freq_hopping, + tpc_command, + csi_req, + ue_mac->t_crnti); + #endif + + // Config Msg3 PDU + nr_config_Msg3_pdu(ue_mac, Msg3_f_alloc, Msg3_t_alloc, mcs, freq_hopping); + // Schedule Msg3 + nr_ue_msg3_scheduler(ue_mac, frame, slot, Msg3_t_alloc); + } else { ue_mac->t_crnti = 0; ta_command = (0xffff); } - #endif // move the selected RAR to the front of the RA_PDSCH buffer memcpy((void *) (selected_rar_buffer + 0), (void *) rarh, 1); From 0fafb2ba64c0f8dd0e7ed99c23f0604399d2b2e6 Mon Sep 17 00:00:00 2001 From: cig Date: Mon, 31 Aug 2020 10:03:55 +0200 Subject: [PATCH 11/96] Set DMRS offset to 0 when transform precoding is enabled --- openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c index a63c33078b..d8d932624a 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c @@ -312,10 +312,14 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, if ((ul_dmrs_symb_pos >> l) & 0x01) { is_dmrs_sym = 1; - if (dmrs_type == pusch_dmrs_type1) - dmrs_idx = start_rb*6; - else - dmrs_idx = start_rb*4; + if (harq_process_ul_ue->pusch_pdu.transform_precoding == 1){ // if transform precoding is disabled + if (dmrs_type == pusch_dmrs_type1) + dmrs_idx = start_rb*6; + else + dmrs_idx = start_rb*4; + } else { + dmrs_idx = 0; + } nr_modulation(pusch_dmrs[l][0], n_dmrs*2, DMRS_MOD_ORDER, mod_dmrs); // currently only codeword 0 is modulated. Qm = 2 as DMRS is QPSK modulated From 83979a8758c5981f1826e6f0c5ec88ebbe18cfad Mon Sep 17 00:00:00 2001 From: cig Date: Mon, 31 Aug 2020 10:06:54 +0200 Subject: [PATCH 12/96] Code cleanup, logging, formatting - removed superfluos code - formatting - fixed logging - removed redundant nr_get_dci_size (replaced by nr_dci_size) - removed unused and long-time commented out functions @ UE side --- openair1/PHY/NR_TRANSPORT/nr_dci.c | 89 - .../NR_UE_TRANSPORT/nr_dlsch_demodulation.c | 57 +- .../PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c | 17 +- openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 2167 +---------------- openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c | 2 - 5 files changed, 32 insertions(+), 2300 deletions(-) diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci.c b/openair1/PHY/NR_TRANSPORT/nr_dci.c index a29211b55b..188945f889 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci.c @@ -39,95 +39,6 @@ //#define DEBUG_DCI //#define DEBUG_CHANNEL_CODING - -uint16_t nr_get_dci_size(nfapi_nr_dci_format_e format, - nfapi_nr_rnti_type_e rnti_type, - uint16_t N_RB) { - uint16_t size = 0; - - switch(format) { - /*Only sizes for 0_0 and 1_0 are correct at the moment*/ - case NFAPI_NR_UL_DCI_FORMAT_0_0: - /// fixed: Format identifier 1, Hop flag 1, MCS 5, NDI 1, RV 2, HARQ PID 4, PUSCH TPC 2 Time Domain assgnmt 4 --20 - size += 20; - size += (uint8_t)ceil( log2( (N_RB*(N_RB+1))>>1 ) ); // Freq domain assignment -- hopping scenario to be updated - size += nr_get_dci_size(NFAPI_NR_DL_DCI_FORMAT_1_0, rnti_type, N_RB) - size; // Padding to match 1_0 size - // UL/SUL indicator assumed to be 0 - break; - - case NFAPI_NR_UL_DCI_FORMAT_0_1: - /// fixed: Format identifier 1, MCS 5, NDI 1, RV 2, HARQ PID 4, PUSCH TPC 2, SRS request 2 --17 - size += 17; - // Carrier indicator - // UL/SUL indicator - // BWP Indicator - // Freq domain assignment - // Time domain assignment - // VRB to PRB mapping - // Frequency Hopping flag - // 1st DAI - // 2nd DAI - // SRS resource indicator - // Precoding info and number of layers - // Antenna ports - // CSI request - // CBGTI - // PTRS - DMRS association - // beta offset indicator - // DMRS sequence init - break; - - case NFAPI_NR_DL_DCI_FORMAT_1_0: - /// fixed: Format identifier 1, VRB2PRB 1, MCS 5, NDI 1, RV 2, HARQ PID 4, DAI 2, PUCCH TPC 2, PUCCH RInd 3, PDSCH to HARQ TInd 3 Time Domain assgnmt 4 -- 28 - size += 28; - size += (uint8_t)ceil( log2( (N_RB*(N_RB+1))>>1 ) ); // Freq domain assignment - break; - - case NFAPI_NR_DL_DCI_FORMAT_1_1: - // Carrier indicator - size += 1; // Format identifier - // BWP Indicator - // Freq domain assignment - // Time domain assignment - // VRB to PRB mapping - // PRB bundling size indicator - // Rate matching indicator - // ZP CSI-RS trigger - /// TB1- MCS 5, NDI 1, RV 2 - size += 8; - // TB2 - size += 4 ; // HARQ PID - // DAI - size += 2; // TPC PUCCH - size += 3; // PUCCH resource indicator - size += 3; // PDSCH to HARQ timing indicator - // Antenna ports - // Tx Config Indication - size += 2; // SRS request - // CBGTI - // CBGFI - size += 1; // DMRS sequence init - break; - - case NFAPI_NR_DL_DCI_FORMAT_2_0: - break; - - case NFAPI_NR_DL_DCI_FORMAT_2_1: - break; - - case NFAPI_NR_DL_DCI_FORMAT_2_2: - break; - - case NFAPI_NR_DL_DCI_FORMAT_2_3: - break; - - default: - AssertFatal(1==0, "Invalid NR DCI format %d\n", format); - } - - return size; -} - void nr_pdcch_scrambling(uint32_t *in, uint32_t size, uint32_t Nid, diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c index f2dd5fb0d5..9f211296d0 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c @@ -53,11 +53,9 @@ int16_t nr_dlsch_demod_shift = 0; //int16_t interf_unaw_shift = 13; //#define DEBUG_HARQ - -//#define DEBUG_PHY 1 -//#define DEBUG_DLSCH_DEMOD 1 - - +//#define DEBUG_PHY +//#define DEBUG_DLSCH_DEMOD +//#define DEBUG_PDSCH_RX // [MCS][i_mod (0,1,2) = (2,4,6)] //unsigned char offset_mumimo_llr_drange_fix=0; @@ -188,7 +186,6 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, if (dlsch1_harq){ - //printf("status TB0 = %d, status TB1 = %d \n", dlsch[0]->harq_processes[harq_pid]->status, dlsch[1]->harq_processes[harq_pid]->status); LOG_D(PHY,"AbsSubframe %d.%d / Sym %d harq_pid %d, harq status %d.%d \n", frame, nr_tti_rx, symbol, harq_pid, dlsch0_harq->status, dlsch1_harq->status); if ((dlsch0_harq->status == ACTIVE) && (dlsch1_harq->status == ACTIVE)){ @@ -1043,42 +1040,30 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, LOG_I(PHY, "[AbsSFN %u.%d] Slot%d Symbol %d: LLR Computation %5.2f \n",frame,nr_tti_rx,slot,symbol,ue->generic_stat_bis[ue->current_thread_id[nr_tti_rx]][slot].p_time/(cpuf*1000.0)); #endif #endif + // Please keep it: useful for debugging -#if 0 - if( (symbol == 13) && (nr_tti_rx==0) && (dlsch0_harq->Qm == 6) /*&& (nb_rb==25)*/) - { - LOG_E(PHY,"Dump Phy Chan Est \n"); - if(1) - { -#if 1 - write_output("rxdataF0.m" , "rxdataF0", &common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[nr_tti_rx]].rxdataF[0][0],14*frame_parms->ofdm_symbol_size,1,1); - //write_output("rxdataF1.m" , "rxdataF1", &common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[nr_tti_rx]].rxdataF[0][0],14*frame_parms->ofdm_symbol_size,1,1); - write_output("dl_ch_estimates00.m", "dl_ch_estimates00", &common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[nr_tti_rx]].dl_ch_estimates[eNB_id][0][0],14*frame_parms->ofdm_symbol_size,1,1); - //write_output("dl_ch_estimates01.m", "dl_ch_estimates01", &common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[nr_tti_rx]].dl_ch_estimates[eNB_id][1][0],14*frame_parms->ofdm_symbol_size,1,1); - //write_output("dl_ch_estimates10.m", "dl_ch_estimates10", &common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[nr_tti_rx]].dl_ch_estimates[eNB_id][2][0],14*frame_parms->ofdm_symbol_size,1,1); - //write_output("dl_ch_estimates11.m", "dl_ch_estimates11", &common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[nr_tti_rx]].dl_ch_estimates[eNB_id][3][0],14*frame_parms->ofdm_symbol_size,1,1); +#ifdef DEBUG_PDSCH_RX + char filename[40]; + uint8_t aa = 0; + sprintf(filename,"rxdataF0_symb_%d_nr_tti_rx_%d.m", symbol, nr_tti_rx); + write_output(filename, "rxdataF0", &common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[nr_tti_rx]].rxdataF[0][0], NR_SYMBOLS_PER_SLOT*frame_parms->ofdm_symbol_size, 1, 1); - //write_output("rxdataF_ext00.m" , "rxdataF_ext00", &pdsch_vars[eNB_id]->rxdataF_ext[0][0],14*frame_parms->N_RB_DL*12,1,1); - //write_output("rxdataF_ext01.m" , "rxdataF_ext01", &pdsch_vars[eNB_id]->rxdataF_ext[1][0],14*frame_parms->N_RB_DL*12,1,1); - //write_output("rxdataF_ext10.m" , "rxdataF_ext10", &pdsch_vars[eNB_id]->rxdataF_ext[2][0],14*frame_parms->N_RB_DL*12,1,1); - //write_output("rxdataF_ext11.m" , "rxdataF_ext11", &pdsch_vars[eNB_id]->rxdataF_ext[3][0],14*frame_parms->N_RB_DL*12,1,1); - write_output("dl_ch_estimates_ext00.m", "dl_ch_estimates_ext00", &pdsch_vars[eNB_id]->dl_ch_estimates_ext[0][0],14*frame_parms->N_RB_DL*12,1,1); - //write_output("dl_ch_estimates_ext01.m", "dl_ch_estimates_ext01", &pdsch_vars[eNB_id]->dl_ch_estimates_ext[1][0],14*frame_parms->N_RB_DL*12,1,1); - //write_output("dl_ch_estimates_ext10.m", "dl_ch_estimates_ext10", &pdsch_vars[eNB_id]->dl_ch_estimates_ext[2][0],14*frame_parms->N_RB_DL*12,1,1); - //write_output("dl_ch_estimates_ext11.m", "dl_ch_estimates_ext11", &pdsch_vars[eNB_id]->dl_ch_estimates_ext[3][0],14*frame_parms->N_RB_DL*12,1,1); - write_output("rxdataF_comp00.m","rxdataF_comp00", &pdsch_vars[eNB_id]->rxdataF_comp0[0][0],14*frame_parms->N_RB_DL*12,1,1); - //write_output("rxdataF_comp01.m","rxdataF_comp01", &pdsch_vars[eNB_id]->rxdataF_comp0[1][0],14*frame_parms->N_RB_DL*12,1,1); - //write_output("rxdataF_comp10.m","rxdataF_comp10", &pdsch_vars[eNB_id]->rxdataF_comp1[harq_pid][round][0][0],14*frame_parms->N_RB_DL*12,1,1); - //write_output("rxdataF_comp11.m","rxdataF_comp11", &pdsch_vars[eNB_id]->rxdataF_comp1[harq_pid][round][1][0],14*frame_parms->N_RB_DL*12,1,1); -#endif - write_output("llr0.m","llr0", &pdsch_vars[eNB_id]->llr[0][0],(14*nb_rb*12*dlsch1_harq->Qm) - 4*(nb_rb*4*dlsch1_harq->Qm),1,0); - //write_output("llr1.m","llr1", &pdsch_vars[eNB_id]->llr[1][0],(14*nb_rb*12*dlsch1_harq->Qm) - 4*(nb_rb*4*dlsch1_harq->Qm),1,0); + sprintf(filename,"dl_ch_estimates0%d_symb_%d_nr_tti_rx_%d.m", aa, symbol, nr_tti_rx); + write_output(filename, "dl_ch_estimates", &pdsch_vars[eNB_id]->dl_ch_estimates[aa][0], NR_SYMBOLS_PER_SLOT*frame_parms->ofdm_symbol_size, 1, 1); + sprintf(filename,"rxdataF_ext0%d_symb_%d_nr_tti_rx_%d.m", aa, symbol, nr_tti_rx); + write_output(filename, "rxdataF_ext", &pdsch_vars[eNB_id]->rxdataF_ext[aa][0], NR_SYMBOLS_PER_SLOT*frame_parms->N_RB_DL*NR_NB_SC_PER_RB, 1, 1); - AssertFatal(0," "); - } + sprintf(filename,"dl_ch_estimates_ext0%d_symb_%d_nr_tti_rx_%d.m", aa, symbol, nr_tti_rx); + write_output(filename, "dl_ch_estimates_ext00", &pdsch_vars[eNB_id]->dl_ch_estimates_ext[aa][0], NR_SYMBOLS_PER_SLOT*frame_parms->N_RB_DL*NR_NB_SC_PER_RB, 1, 1); + sprintf(filename,"rxdataF_comp0%d_symb_%d_nr_tti_rx_%d.m", aa, symbol, nr_tti_rx); + write_output(filename, "rxdataF_comp00", &pdsch_vars[eNB_id]->rxdataF_comp0[aa][0], NR_SYMBOLS_PER_SLOT*frame_parms->N_RB_DL*NR_NB_SC_PER_RB, 1, 1); + + for (int i=0; i < 2; i++){ + sprintf(filename, "llr%d_symb_%d_nr_tti_rx_%d.m", i, symbol, nr_tti_rx); + write_output(filename,"llr", &pdsch_vars[eNB_id]->llr[i][0], (NR_SYMBOLS_PER_SLOT*nb_rb*NR_NB_SC_PER_RB*dlsch1_harq->Qm) - 4*(nb_rb*4*dlsch1_harq->Qm), 1, 0); } #endif diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c index 4b36f91e69..429e8a0aff 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c @@ -41,6 +41,7 @@ #include "common/utils/LOG/vcd_signal_dumper.h" #include "LAYER2/NR_MAC_gNB/mac_proto.h" +//#define DEBUG_ULSCH_CODING void free_nr_ue_ulsch(NR_UE_ULSCH_t **ulschptr,unsigned char N_RB_UL) @@ -269,7 +270,7 @@ int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch, // if (harq_process->Ndi == 1) { // this is a new packet if (harq_process->round == 0) { // this is a new packet -#ifdef DEBUG_DLSCH_CODING +#ifdef DEBUG_ULSCH_CODING printf("encoding thinks this is a new packet \n"); #endif @@ -343,7 +344,7 @@ int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch, F = harq_process->F; Kr = harq_process->K; -#ifdef DEBUG_DLSCH_CODING +#ifdef DEBUG_ULSCH_CODING uint16_t Kr_bytes; Kr_bytes = Kr>>3; #endif @@ -356,7 +357,7 @@ int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch, //start_meas(te_stats); for (r=0; rC; r++) { //channel_input[r] = &harq_process->d[r][0]; -#ifdef DEBUG_DLSCH_CODING +#ifdef DEBUG_ULSCH_CODING printf("Encoder: B %d F %d \n",harq_process->B, harq_process->F); printf("start ldpc encoder segment %d/%d\n",r,harq_process->C); printf("input %d %d %d %d %d \n", harq_process->c[r][0], harq_process->c[r][1], harq_process->c[r][2],harq_process->c[r][3], harq_process->c[r][4]); @@ -398,7 +399,7 @@ int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch, //stop_meas(te_stats); //printf("end ldpc encoder -- output\n"); -#ifdef DEBUG_DLSCH_CODING +#ifdef DEBUG_ULSCH_CODING write_output("ulsch_enc_input0.m","enc_in0",&harq_process->c[0][0],Kr_bytes,1,4); write_output("ulsch_enc_output0.m","enc0",&harq_process->d[0][0],(3*8*Kr_bytes)+12,1,4); #endif @@ -420,7 +421,7 @@ int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch, } } -#ifdef DEBUG_DLSCH_CODING +#ifdef DEBUG_ULSCH_CODING printf("Rate Matching, Code segment %d (coded bits (G) %u, unpunctured/repeated bits per code segment %d, mod_order %d, nb_rb %d)...\n", r, G, @@ -429,7 +430,7 @@ int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch, #endif //start_meas(rm_stats); -#ifdef DEBUG_DLSCH_CODING +#ifdef DEBUG_ULSCH_CODING printf("rvidx in encoding = %d\n", harq_process->pusch_pdu.pusch_data.rv_index); #endif @@ -456,7 +457,7 @@ int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch, -#ifdef DEBUG_DLSCH_CODING +#ifdef DEBUG_ULSCH_CODING for (int i =0; i<16; i++) printf("output ratematching e[%d]= %d r_offset %d\n", i,harq_process->e[i+r_offset], r_offset); #endif @@ -482,7 +483,7 @@ int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch, //stop_meas(i_stats); -#ifdef DEBUG_DLSCH_CODING +#ifdef DEBUG_ULSCH_CODING for (int i =0; i<16; i++) printf("output interleaving f[%d]= %d r_offset %d\n", i,harq_process->f[i+r_offset], r_offset); diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index b4b8b0fd71..7ded09dabf 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -34,28 +34,22 @@ #include "assertions.h" #include "defs.h" -//#include "PHY/defs.h" #include "PHY/defs_nr_UE.h" -//#include "PHY/phy_vars_nr_ue.h" #include "PHY/phy_extern_nr_ue.h" #include "PHY/MODULATION/modulation_UE.h" #include "PHY/NR_REFSIG/refsig_defs_ue.h" #include "PHY/NR_UE_TRANSPORT/nr_transport_ue.h" #include "PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h" -//#include "PHY/extern.h" #include "SCHED_NR_UE/defs.h" #include "SCHED_NR_UE/pucch_uci_ue_nr.h" #include "SCHED_NR/extern.h" #include "SCHED_NR_UE/phy_sch_processing_time.h" -//#include -//#include "targets/RT/USER/nr-softmodem.h" #include "PHY/NR_UE_ESTIMATION/nr_estimation.h" #include "PHY/NR_TRANSPORT/nr_dci.h" #ifdef EMOS #include "SCHED/phy_procedures_emos.h" #endif #include "executables/softmodem-common.h" -//#define DEBUG_PHY_PROC #define NR_PDCCH_SCHED //#define NR_PDCCH_SCHED_DEBUG @@ -88,112 +82,10 @@ char nr_mode_string[4][20] = {"NOT SYNCHED","PRACH","RAR","PUSCH"}; extern double cpuf; -/* -int nr_generate_ue_ul_dlsch_params_from_dci(PHY_VARS_NR_UE *ue, - uint8_t eNB_id, - int frame, - uint8_t nr_tti_rx, - uint64_t dci_pdu[2], - uint16_t rnti, - uint8_t dci_length, - NR_DCI_format_t dci_format, - NR_UE_PDCCH *pdcch_vars, - NR_UE_PDSCH *pdsch_vars, - NR_UE_DLSCH_t **dlsch, - NR_UE_ULSCH_t *ulsch, - NR_DL_FRAME_PARMS *frame_parms, - PDSCH_CONFIG_DEDICATED *pdsch_config_dedicated, - uint8_t beamforming_mode, - uint8_t dci_fields_sizes[NBR_NR_DCI_FIELDS][NBR_NR_FORMATS], - uint16_t n_RB_ULBWP, - uint16_t n_RB_DLBWP, - uint16_t crc_scrambled_values[TOTAL_NBR_SCRAMBLED_VALUES], - NR_DCI_INFO_EXTRACTED_t *nr_dci_info_extracted); -*/ - #if defined(EXMIMO) || defined(OAI_USRP) || defined(OAI_BLADERF) || defined(OAI_LMSSDR) || defined(OAI_ADRV9371_ZC706) extern uint64_t downlink_frequency[MAX_NUM_CCs][4]; #endif - -#if 0 -void nr_dump_dlsch(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t nr_tti_rx,uint8_t harq_pid) -{ - unsigned int coded_bits_per_codeword; - uint8_t nsymb = (ue->frame_parms.Ncp == 0) ? 14 : 12; - - coded_bits_per_codeword = get_G(&ue->frame_parms, - ue->dlsch[ue->current_thread_id[nr_tti_rx]][eNB_id][0]->harq_processes[harq_pid]->nb_rb, - ue->dlsch[ue->current_thread_id[nr_tti_rx]][eNB_id][0]->harq_processes[harq_pid]->rb_alloc_even, - ue->dlsch[ue->current_thread_id[nr_tti_rx]][eNB_id][0]->harq_processes[harq_pid]->Qm, - ue->dlsch[ue->current_thread_id[nr_tti_rx]][eNB_id][0]->harq_processes[harq_pid]->Nl, - ue->pdcch_vars[0%RX_NB_TH][eNB_id]->num_pdcch_symbols, - proc->frame_rx, - nr_tti_rx, - ue->transmission_mode[eNB_id]<7?0:ue->transmission_mode[eNB_id]); - - write_output("rxsigF0.m","rxsF0", ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[nr_tti_rx]].rxdataF[0],2*nsymb*ue->frame_parms.ofdm_symbol_size,2,1); - write_output("rxsigF0_ext.m","rxsF0_ext", ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][0]->rxdataF_ext[0],2*nsymb*ue->frame_parms.ofdm_symbol_size,1,1); - write_output("dlsch00_ch0_ext.m","dl00_ch0_ext", ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][0]->dl_ch_estimates_ext[0],300*nsymb,1,1); - /* - write_output("dlsch01_ch0_ext.m","dl01_ch0_ext",pdsch_vars[0]->dl_ch_estimates_ext[1],300*12,1,1); - write_output("dlsch10_ch0_ext.m","dl10_ch0_ext",pdsch_vars[0]->dl_ch_estimates_ext[2],300*12,1,1); - write_output("dlsch11_ch0_ext.m","dl11_ch0_ext",pdsch_vars[0]->dl_ch_estimates_ext[3],300*12,1,1); - write_output("dlsch_rho.m","dl_rho",pdsch_vars[0]->rho[0],300*12,1,1); - */ - write_output("dlsch_rxF_comp0.m","dlsch0_rxF_comp0", ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][0]->rxdataF_comp0[0],300*12,1,1); - write_output("dlsch_rxF_llr.m","dlsch_llr", ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][0]->llr[0],coded_bits_per_codeword,1,0); - - write_output("dlsch_mag1.m","dlschmag1",ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][0]->dl_ch_mag0,300*12,1,1); - write_output("dlsch_mag2.m","dlschmag2",ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][0]->dl_ch_magb0,300*12,1,1); -} - -void nr_dump_dlsch_SI(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t nr_tti_rx) -{ - unsigned int coded_bits_per_codeword; - uint8_t nsymb = ((ue->frame_parms.Ncp == 0) ? 14 : 12); - - coded_bits_per_codeword = get_G(&ue->frame_parms, - ue->dlsch_SI[eNB_id]->harq_processes[0]->nb_rb, - ue->dlsch_SI[eNB_id]->harq_processes[0]->rb_alloc_even, - 2, - 1, - ue->pdcch_vars[0%RX_NB_TH][eNB_id]->num_pdcch_symbols, - proc->frame_rx, - nr_tti_rx, - 0); - LOG_D(PHY,"[UE %d] Dumping dlsch_SI : ofdm_symbol_size %d, nsymb %d, nb_rb %d, mcs %d, nb_rb %d, num_pdcch_symbols %d,G %d\n", - ue->Mod_id, - ue->frame_parms.ofdm_symbol_size, - nsymb, - ue->dlsch_SI[eNB_id]->harq_processes[0]->nb_rb, - ue->dlsch_SI[eNB_id]->harq_processes[0]->mcs, - ue->dlsch_SI[eNB_id]->harq_processes[0]->nb_rb, - ue->pdcch_vars[0%RX_NB_TH][eNB_id]->num_pdcch_symbols, - coded_bits_per_codeword); - - write_output("rxsig0.m","rxs0", &ue->common_vars.rxdata[0][nr_tti_rx*ue->frame_parms.samples_per_tti],ue->frame_parms.samples_per_tti,1,1); - - write_output("rxsigF0.m","rxsF0", ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[nr_tti_rx]].rxdataF[0],nsymb*ue->frame_parms.ofdm_symbol_size,1,1); - write_output("rxsigF0_ext.m","rxsF0_ext", ue->pdsch_vars_SI[0]->rxdataF_ext[0],2*nsymb*ue->frame_parms.ofdm_symbol_size,1,1); - write_output("dlsch00_ch0_ext.m","dl00_ch0_ext", ue->pdsch_vars_SI[0]->dl_ch_estimates_ext[0],ue->frame_parms.N_RB_DL*12*nsymb,1,1); - /* - write_output("dlsch01_ch0_ext.m","dl01_ch0_ext",pdsch_vars[0]->dl_ch_estimates_ext[1],300*12,1,1); - write_output("dlsch10_ch0_ext.m","dl10_ch0_ext",pdsch_vars[0]->dl_ch_estimates_ext[2],300*12,1,1); - write_output("dlsch11_ch0_ext.m","dl11_ch0_ext",pdsch_vars[0]->dl_ch_estimates_ext[3],300*12,1,1); - write_output("dlsch_rho.m","dl_rho",pdsch_vars[0]->rho[0],300*12,1,1); - */ - write_output("dlsch_rxF_comp0.m","dlsch0_rxF_comp0", ue->pdsch_vars_SI[0]->rxdataF_comp0[0],ue->frame_parms.N_RB_DL*12*nsymb,1,1); - write_output("dlsch_rxF_llr.m","dlsch_llr", ue->pdsch_vars_SI[0]->llr[0],coded_bits_per_codeword,1,0); - - write_output("dlsch_mag1.m","dlschmag1",ue->pdsch_vars_SI[0]->dl_ch_mag0,300*nsymb,1,1); - write_output("dlsch_mag2.m","dlschmag2",ue->pdsch_vars_SI[0]->dl_ch_magb0,300*nsymb,1,1); - sleep(1); - exit(-1); -} - -#endif - unsigned int gain_table[31] = {100,112,126,141,158,178,200,224,251,282,316,359,398,447,501,562,631,708,794,891,1000,1122,1258,1412,1585,1778,1995,2239,2512,2818,3162}; int get_tx_amp_prach(int power_dBm, int power_max_dBm, int N_RB_UL){ @@ -234,873 +126,6 @@ int get_tx_amp_prach(int power_dBm, int power_max_dBm, int N_RB_UL){ return (amp_x_100); } -#if 0 - -void nr_dump_dlsch_ra(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t nr_tti_rx) -{ - unsigned int coded_bits_per_codeword; - uint8_t nsymb = ((ue->frame_parms.Ncp == 0) ? 14 : 12); - - coded_bits_per_codeword = get_G(&ue->frame_parms, - ue->dlsch_ra[eNB_id]->harq_processes[0]->nb_rb, - ue->dlsch_ra[eNB_id]->harq_processes[0]->rb_alloc_even, - 2, - 1, - ue->pdcch_vars[0%RX_NB_TH][eNB_id]->num_pdcch_symbols, - proc->frame_rx, - nr_tti_rx, - 0); - LOG_D(PHY,"[UE %d] Dumping dlsch_ra : nb_rb %d, mcs %d, nb_rb %d, num_pdcch_symbols %d,G %d\n", - ue->Mod_id, - ue->dlsch_ra[eNB_id]->harq_processes[0]->nb_rb, - ue->dlsch_ra[eNB_id]->harq_processes[0]->mcs, - ue->dlsch_ra[eNB_id]->harq_processes[0]->nb_rb, - ue->pdcch_vars[0%RX_NB_TH][eNB_id]->num_pdcch_symbols, - coded_bits_per_codeword); - - write_output("rxsigF0.m","rxsF0", ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[nr_tti_rx]].rxdataF[0],2*12*ue->frame_parms.ofdm_symbol_size,2,1); - write_output("rxsigF0_ext.m","rxsF0_ext", ue->pdsch_vars_ra[0]->rxdataF_ext[0],2*12*ue->frame_parms.ofdm_symbol_size,1,1); - write_output("dlsch00_ch0_ext.m","dl00_ch0_ext", ue->pdsch_vars_ra[0]->dl_ch_estimates_ext[0],300*nsymb,1,1); - /* - write_output("dlsch01_ch0_ext.m","dl01_ch0_ext",pdsch_vars[0]->dl_ch_estimates_ext[1],300*12,1,1); - write_output("dlsch10_ch0_ext.m","dl10_ch0_ext",pdsch_vars[0]->dl_ch_estimates_ext[2],300*12,1,1); - write_output("dlsch11_ch0_ext.m","dl11_ch0_ext",pdsch_vars[0]->dl_ch_estimates_ext[3],300*12,1,1); - write_output("dlsch_rho.m","dl_rho",pdsch_vars[0]->rho[0],300*12,1,1); - */ - write_output("dlsch_rxF_comp0.m","dlsch0_rxF_comp0", ue->pdsch_vars_ra[0]->rxdataF_comp0[0],300*nsymb,1,1); - write_output("dlsch_rxF_llr.m","dlsch_llr", ue->pdsch_vars_ra[0]->llr[0],coded_bits_per_codeword,1,0); - - write_output("dlsch_mag1.m","dlschmag1",ue->pdsch_vars_ra[0]->dl_ch_mag0,300*nsymb,1,1); - write_output("dlsch_mag2.m","dlschmag2",ue->pdsch_vars_ra[0]->dl_ch_magb0,300*nsymb,1,1); -} - -uint8_t nr_is_SR_TXOp(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eNB_id) -{ - - int nr_tti_tx=proc->nr_tti_tx; - - LOG_D(PHY,"[UE %d][SR %x] Frame %d nr_tti_tx %d Checking for SR TXOp (sr_ConfigIndex %d)\n", - ue->Mod_id,ue->pdcch_vars[ue->current_thread_id[proc->nr_tti_rx]][eNB_id]->crnti,proc->frame_tx,nr_tti_tx, - ue->scheduling_request_config[eNB_id].sr_ConfigIndex); - - if (ue->scheduling_request_config[eNB_id].sr_ConfigIndex <= 4) { // 5 ms SR period - if ((nr_tti_tx%5) == ue->scheduling_request_config[eNB_id].sr_ConfigIndex) - return(1); - } else if (ue->scheduling_request_config[eNB_id].sr_ConfigIndex <= 14) { // 10 ms SR period - if (nr_tti_tx==(ue->scheduling_request_config[eNB_id].sr_ConfigIndex-5)) - return(1); - } else if (ue->scheduling_request_config[eNB_id].sr_ConfigIndex <= 34) { // 20 ms SR period - if ((10*(proc->frame_tx&1)+nr_tti_tx) == (ue->scheduling_request_config[eNB_id].sr_ConfigIndex-15)) - return(1); - } else if (ue->scheduling_request_config[eNB_id].sr_ConfigIndex <= 74) { // 40 ms SR period - if ((10*(proc->frame_tx&3)+nr_tti_tx) == (ue->scheduling_request_config[eNB_id].sr_ConfigIndex-35)) - return(1); - } else if (ue->scheduling_request_config[eNB_id].sr_ConfigIndex <= 154) { // 80 ms SR period - if ((10*(proc->frame_tx&7)+nr_tti_tx) == (ue->scheduling_request_config[eNB_id].sr_ConfigIndex-75)) - return(1); - } - - return(0); -} - -uint8_t is_cqi_TXOp(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eNB_id) -{ - int nr_tti_tx = proc->nr_tti_tx; - int frame = proc->frame_tx; - CQI_REPORTPERIODIC *cqirep = &ue->cqi_report_config[eNB_id].CQI_ReportPeriodic; - - //LOG_I(PHY,"[UE %d][CRNTI %x] AbsSubFrame %d.%d Checking for CQI TXOp (cqi_ConfigIndex %d) isCQIOp %d\n", - // ue->Mod_id,ue->pdcch_vars[eNB_id]->crnti,frame,nr_tti_rx, - // cqirep->cqi_PMI_ConfigIndex, - // (((10*frame + nr_tti_tx) % cqirep->Npd) == cqirep->N_OFFSET_CQI)); - - if (cqirep->cqi_PMI_ConfigIndex==-1) - return(0); - else if (((10*frame + nr_tti_tx) % cqirep->Npd) == cqirep->N_OFFSET_CQI) - return(1); - else - return(0); -} -uint8_t is_ri_TXOp(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eNB_id) -{ - - - int nr_tti_tx = proc->nr_tti_tx; - int frame = proc->frame_tx; - CQI_REPORTPERIODIC *cqirep = &ue->cqi_report_config[eNB_id].CQI_ReportPeriodic; - int log2Mri = cqirep->ri_ConfigIndex/161; - int N_OFFSET_RI = cqirep->ri_ConfigIndex % 161; - - //LOG_I(PHY,"[UE %d][CRNTI %x] AbsSubFrame %d.%d Checking for RI TXOp (ri_ConfigIndex %d) isRIOp %d\n", - // ue->Mod_id,ue->pdcch_vars[eNB_id]->crnti,frame,nr_tti_tx, - // cqirep->ri_ConfigIndex, - // (((10*frame + nr_tti_tx + cqirep->N_OFFSET_CQI - N_OFFSET_RI) % (cqirep->Npd<ri_ConfigIndex==-1) - return(0); - else if (((10*frame + nr_tti_tx + cqirep->N_OFFSET_CQI - N_OFFSET_RI) % (cqirep->Npd<measurements; - //uint8_t transmission_mode = ue->transmission_mode[eNB_id]; - - - //LOG_I(PHY,"compute_cqi_ri_resources O_RI %d O %d uci format %d \n",ulsch->O_RI,ulsch->O,ulsch->uci_format); - if (cqi_status == 1 || ri_status == 1) - { - ulsch->O = 4; - } -} - -void ue_compute_srs_occasion(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t isSubframeSRS) -{ - - NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; - int frame_tx = proc->frame_tx; - int nr_tti_tx = proc->nr_tti_tx; - SOUNDINGRS_UL_CONFIG_DEDICATED *pSoundingrs_ul_config_dedicated=&ue->soundingrs_ul_config_dedicated[eNB_id]; - uint16_t srsPeriodicity; - uint16_t srsOffset; - uint8_t is_pucch2_subframe = 0; - uint8_t is_sr_an_subframe = 0; - - // check for SRS opportunity - pSoundingrs_ul_config_dedicated->srsUeSubframe = 0; - pSoundingrs_ul_config_dedicated->srsCellSubframe = isSubframeSRS; - - if (isSubframeSRS) { - LOG_D(PHY," SrsDedicatedSetup: %d \n",pSoundingrs_ul_config_dedicated->srsConfigDedicatedSetup); - if(pSoundingrs_ul_config_dedicated->srsConfigDedicatedSetup) - { - nr_compute_srs_pos(frame_parms->frame_type, pSoundingrs_ul_config_dedicated->srs_ConfigIndex, &srsPeriodicity, &srsOffset); - - LOG_D(PHY," srsPeriodicity: %d srsOffset: %d isSubframeSRS %d \n",srsPeriodicity,srsOffset,isSubframeSRS); - - // transmit SRS if the four following constraints are respected: - // - UE is configured to transmit SRS - // - SRS are configured in current nr_tti_rx - // - UE is configured to send SRS in this nr_tti_tx - - // 36.213 8.2 - // 1- A UE shall not transmit SRS whenever SRS and PUCCH format 2/2a/2b transmissions happen to coincide in the same nr_tti_rx - // 2- A UE shall not transmit SRS whenever SRS transmit - // on and PUCCH transmission carrying ACK/NACK and/or - // positive SR happen to coincide in the same nr_tti_rx if the parameter - // Simultaneous-AN-and-SRS is FALSE - - // check PUCCH format 2/2a/2b transmissions - is_pucch2_subframe = nr_is_cqi_TXOp(ue,proc,eNB_id) && (ue->cqi_report_config[eNB_id].CQI_ReportPeriodic.cqi_PMI_ConfigIndex>0); - is_pucch2_subframe = (nr_is_ri_TXOp(ue,proc,eNB_id) && (ue->cqi_report_config[eNB_id].CQI_ReportPeriodic.ri_ConfigIndex>0)) || is_pucch2_subframe; - - // check ACK/SR transmission - if(frame_parms->soundingrs_ul_config_common.ackNackSRS_SimultaneousTransmission == FALSE) - { - if(nr_is_SR_TXOp(ue,proc,eNB_id)) - { - uint32_t SR_payload = 0; - if (ue->mac_enabled==1) - { - int Mod_id = ue->Mod_id; - int CC_id = ue->CC_id; - SR_payload = mac_xface->ue_get_SR(Mod_id, - CC_id, - frame_tx, - eNB_id, - ue->pdcch_vars[ue->current_thread_id[proc->nr_tti_rx]][eNB_id]->crnti, - nr_tti_tx); // nr_tti_tx used for meas gap - - if (SR_payload > 0) - is_sr_an_subframe = 1; - } - } - - uint8_t pucch_ack_payload[2]; - if (nr_get_ack(&ue->frame_parms, - ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->harq_ack, - nr_tti_tx,proc->nr_tti_rx,pucch_ack_payload,0) > 0) - { - is_sr_an_subframe = 1; - } - } - - // check SRS UE opportunity - if( isSubframeSRS && - (((10*frame_tx+nr_tti_tx) % srsPeriodicity) == srsOffset) - ) - { - if ((is_pucch2_subframe == 0) && (is_sr_an_subframe == 0)) - { - pSoundingrs_ul_config_dedicated->srsUeSubframe = 1; - ue->ulsch[eNB_id]->srs_active = 1; - ue->ulsch[eNB_id]->Nsymb_pusch = 12-(frame_parms->Ncp<<1)- ue->ulsch[eNB_id]->srs_active; - } - else - { - LOG_I(PHY,"DROP UE-SRS-TX for this nr_tti_tx %d.%d: collision with PUCCH2 or SR/AN: PUCCH2-occasion: %d, SR-AN-occasion[simSRS-SR-AN %d]: %d \n", frame_tx, nr_tti_tx, is_pucch2_subframe, frame_parms->soundingrs_ul_config_common.ackNackSRS_SimultaneousTransmission, is_sr_an_subframe); - } - } - } - LOG_D(PHY," srsCellSubframe: %d, srsUeSubframe: %d, Nsymb-pusch: %d \n", pSoundingrs_ul_config_dedicated->srsCellSubframe, pSoundingrs_ul_config_dedicated->srsUeSubframe, ue->ulsch[eNB_id]->Nsymb_pusch); - } -} - - -void nr_get_cqipmiri_params(PHY_VARS_NR_UE *ue,uint8_t eNB_id) -{ - - CQI_REPORTPERIODIC *cqirep = &ue->cqi_report_config[eNB_id].CQI_ReportPeriodic; - int cqi_PMI_ConfigIndex = cqirep->cqi_PMI_ConfigIndex; - - if (ue->frame_parms.frame_type == FDD) { - if (cqi_PMI_ConfigIndex <= 1) { // 2 ms CQI_PMI period - cqirep->Npd = 2; - cqirep->N_OFFSET_CQI = cqi_PMI_ConfigIndex; - } else if (cqi_PMI_ConfigIndex <= 6) { // 5 ms CQI_PMI period - cqirep->Npd = 5; - cqirep->N_OFFSET_CQI = cqi_PMI_ConfigIndex-2; - } else if (cqi_PMI_ConfigIndex <=16) { // 10ms CQI_PMI period - cqirep->Npd = 10; - cqirep->N_OFFSET_CQI = cqi_PMI_ConfigIndex-7; - } else if (cqi_PMI_ConfigIndex <= 36) { // 20 ms CQI_PMI period - cqirep->Npd = 20; - cqirep->N_OFFSET_CQI = cqi_PMI_ConfigIndex-17; - } else if (cqi_PMI_ConfigIndex <= 76) { // 40 ms CQI_PMI period - cqirep->Npd = 40; - cqirep->N_OFFSET_CQI = cqi_PMI_ConfigIndex-37; - } else if (cqi_PMI_ConfigIndex <= 156) { // 80 ms CQI_PMI period - cqirep->Npd = 80; - cqirep->N_OFFSET_CQI = cqi_PMI_ConfigIndex-77; - } else if (cqi_PMI_ConfigIndex <= 316) { // 160 ms CQI_PMI period - cqirep->Npd = 160; - cqirep->N_OFFSET_CQI = cqi_PMI_ConfigIndex-157; - } - else if (cqi_PMI_ConfigIndex > 317) { - - if (cqi_PMI_ConfigIndex <= 349) { // 32 ms CQI_PMI period - cqirep->Npd = 32; - cqirep->N_OFFSET_CQI = cqi_PMI_ConfigIndex-318; - } - else if (cqi_PMI_ConfigIndex <= 413) { // 64 ms CQI_PMI period - cqirep->Npd = 64; - cqirep->N_OFFSET_CQI = cqi_PMI_ConfigIndex-350; - } - else if (cqi_PMI_ConfigIndex <= 541) { // 128 ms CQI_PMI period - cqirep->Npd = 128; - cqirep->N_OFFSET_CQI = cqi_PMI_ConfigIndex-414; - } - } - } - else { // TDD - if (cqi_PMI_ConfigIndex == 0) { // all UL subframes - cqirep->Npd = 1; - cqirep->N_OFFSET_CQI = 0; - } else if (cqi_PMI_ConfigIndex <= 6) { // 5 ms CQI_PMI period - cqirep->Npd = 5; - cqirep->N_OFFSET_CQI = cqi_PMI_ConfigIndex-1; - } else if (cqi_PMI_ConfigIndex <=16) { // 10ms CQI_PMI period - cqirep->Npd = 10; - cqirep->N_OFFSET_CQI = cqi_PMI_ConfigIndex-6; - } else if (cqi_PMI_ConfigIndex <= 36) { // 20 ms CQI_PMI period - cqirep->Npd = 20; - cqirep->N_OFFSET_CQI = cqi_PMI_ConfigIndex-16; - } else if (cqi_PMI_ConfigIndex <= 76) { // 40 ms CQI_PMI period - cqirep->Npd = 40; - cqirep->N_OFFSET_CQI = cqi_PMI_ConfigIndex-36; - } else if (cqi_PMI_ConfigIndex <= 156) { // 80 ms CQI_PMI period - cqirep->Npd = 80; - cqirep->N_OFFSET_CQI = cqi_PMI_ConfigIndex-76; - } else if (cqi_PMI_ConfigIndex <= 316) { // 160 ms CQI_PMI period - cqirep->Npd = 160; - cqirep->N_OFFSET_CQI = cqi_PMI_ConfigIndex-156; - } - } -} - -PUCCH_FMT_t get_pucch_format(lte_frame_type_t frame_type, - lte_prefix_type_t cyclic_prefix_type, - uint8_t SR_payload, - uint8_t nb_cw, - uint8_t cqi_status, - uint8_t ri_status, - uint8_t bundling_flag) -{ - if((cqi_status == 0) && (ri_status==0)) - { - // PUCCH Format 1 1a 1b - // 1- SR only ==> PUCCH format 1 - // 2- 1bit Ack/Nack with/without SR ==> PUCCH format 1a - // 3- 2bits Ack/Nack with/without SR ==> PUCCH format 1b - if((nb_cw == 1)&&(bundling_flag==bundling)) - { - return pucch_format1a; - } - if((nb_cw == 1)&&(bundling_flag==multiplexing)) - { - return pucch_format1b; - } - if(nb_cw == 2) - { - return pucch_format1b; - } - if(SR_payload == 1) - { - return pucch_format1; - /* - if (frame_type == FDD) { - return pucch_format1; - } else if (frame_type == TDD) { - return pucch_format1b; - } else { - AssertFatal(1==0,"Unknown frame_type"); - }*/ - } - } - else - { - // PUCCH Format 2 2a 2b - // 1- CQI only or RI only ==> PUCCH format 2 - // 2- CQI or RI + 1bit Ack/Nack for normal CP ==> PUCCH format 2a - // 3- CQI or RI + 2bits Ack/Nack for normal CP ==> PUCCH format 2b - // 4- CQI or RI + Ack/Nack for extended CP ==> PUCCH format 2 - if(nb_cw == 0) - { - return pucch_format2; - } - if(cyclic_prefix_type == NORMAL) - { - if(nb_cw == 1) - { - return pucch_format2a; - } - if(nb_cw == 2) - { - return pucch_format2b; - } - } - else - { - return pucch_format2; - } - } - return pucch_format1a; -} - -uint16_t nr_get_n1_pucch(PHY_VARS_NR_UE *ue, - UE_nr_rxtx_proc_t *proc, - nr_harq_status_t *harq_ack, - uint8_t eNB_id, - uint8_t *b, - uint8_t SR) -{ - - NR_DL_FRAME_PARMS *frame_parms=&ue->frame_parms; - uint8_t nCCE0,nCCE1,nCCE2,nCCE3,harq_ack1,harq_ack0,harq_ack3,harq_ack2; - ANFBmode_t bundling_flag; - uint16_t n1_pucch0=0,n1_pucch1=0,n1_pucch2=0,n1_pucch3=0,n1_pucch_inter; - static uint8_t candidate_dl[9]; // which downlink(s) the current ACK/NACK is associating to - uint8_t last_dl=0xff; // the last downlink with valid DL-DCI. for calculating the PUCCH resource index - int sf; - int M; - uint8_t ack_counter=0; - // clear this, important for case where n1_pucch selection is not used - int nr_tti_tx=proc->nr_tti_tx; - - ue->pucch_sel[nr_tti_tx] = 0; - - if (frame_parms->frame_type == FDD ) { // FDD - sf = (nr_tti_tx<4)? nr_tti_tx+6 : nr_tti_tx-4; - LOG_D(PHY,"n1_pucch_UE: nr_tti_tx %d, nCCE %d\n",sf,ue->pdcch_vars[ue->current_thread_id[proc->nr_tti_rx]][eNB_id]->nCCE[sf]); - - if (SR == 0) - return(frame_parms->pucch_config_common.n1PUCCH_AN + ue->pdcch_vars[ue->current_thread_id[proc->nr_tti_rx]][eNB_id]->nCCE[sf]); - else - return(ue->scheduling_request_config[eNB_id].sr_PUCCH_ResourceIndex); - } else { - - bundling_flag = ue->pucch_config_dedicated[eNB_id].tdd_AckNackFeedbackMode; -#ifdef DEBUG_PHY_PROC - - if (bundling_flag==bundling) { - LOG_D(PHY,"[UE%d] Frame %d nr_tti_tx %d : nr_get_n1_pucch, bundling, SR %d/%d\n",ue->Mod_id,proc->frame_tx,nr_tti_tx,SR, - ue->scheduling_request_config[eNB_id].sr_PUCCH_ResourceIndex); - } else { - LOG_D(PHY,"[UE%d] Frame %d nr_tti_tx %d : nr_get_n1_pucch, multiplexing, SR %d/%d\n",ue->Mod_id,proc->frame_tx,nr_tti_tx,SR, - ue->scheduling_request_config[eNB_id].sr_PUCCH_ResourceIndex); - } - -#endif - - switch (frame_parms->tdd_config) { - case 1: // DL:S:UL:UL:DL:DL:S:UL:UL:DL - - harq_ack0 = 2; // DTX - M=1; - - // This is the offset for a particular nr_tti_tx (2,3,4) => (0,2,4) - if (nr_tti_tx == 2) { // ACK nr_tti_txs 5,6 - candidate_dl[0] = 6; - candidate_dl[1] = 5; - M=2; - } else if (nr_tti_tx == 3) { // ACK nr_tti_tx 9 - candidate_dl[0] = 9; - } else if (nr_tti_tx == 7) { // ACK nr_tti_txs 0,1 - candidate_dl[0] = 1; - candidate_dl[1] = 0; - M=2; - } else if (nr_tti_tx == 8) { // ACK nr_tti_txs 4 - candidate_dl[0] = 4; - } else { - LOG_E(PHY,"[UE%d] : Frame %d phy_procedures_lte.c: get_n1pucch, illegal tx-nr_tti_tx %d for tdd_config %d\n", - ue->Mod_id,proc->frame_tx,nr_tti_tx,frame_parms->tdd_config); - return(0); - } - - // checking which downlink candidate is the last downlink with valid DL-DCI - int k; - for (k=0;k0) { - last_dl = candidate_dl[k]; - break; - } - } - if (last_dl >= 10) { - LOG_E(PHY,"[UE%d] : Frame %d phy_procedures_lte.c: get_n1pucch, illegal rx-nr_tti_tx %d (tx-nr_tti_tx %d) for tdd_config %d\n", - ue->Mod_id,proc->frame_tx,last_dl,nr_tti_tx,frame_parms->tdd_config); - return (0); - } - - LOG_D(PHY,"SFN/SF %d/%d calculating n1_pucch0 from last_dl=%d\n", - proc->frame_tx%1024, - proc->nr_tti_tx, - last_dl); - - // i=0 - nCCE0 = ue->pdcch_vars[ue->current_thread_id[proc->nr_tti_rx]][eNB_id]->nCCE[last_dl]; - n1_pucch0 = nr_get_Np(frame_parms->N_RB_DL,nCCE0,0) + nCCE0+ frame_parms->pucch_config_common.n1PUCCH_AN; - - harq_ack0 = b[0]; - - if (harq_ack0!=2) { // DTX - if (frame_parms->frame_type == FDD ) { - if (SR == 0) { // last paragraph pg 68 from 36.213 (v8.6), m=0 - b[0]=(M==2) ? 1-harq_ack0 : harq_ack0; - b[1]=harq_ack0; // in case we use pucch format 1b (subframes 2,7) - ue->pucch_sel[nr_tti_tx] = 0; - return(n1_pucch0); - } else { // SR and only 0 or 1 ACKs (first 2 entries in Table 7.3-1 of 36.213) - b[0]=harq_ack0; - return(ue->scheduling_request_config[eNB_id].sr_PUCCH_ResourceIndex); - } - } else { - if (SR == 0) { - b[0] = harq_ack0; - b[1] = harq_ack0; - ue->pucch_sel[nr_tti_tx] = 0; - return(n1_pucch0); - } else { - b[0] = harq_ack0; - b[1] = harq_ack0; - return(ue->scheduling_request_config[eNB_id].sr_PUCCH_ResourceIndex); - } - } - } - - - break; - - case 3: // DL:S:UL:UL:UL:DL:DL:DL:DL:DL - // in this configuration we have M=2 from pg 68 of 36.213 (v8.6) - // Note: this doesn't allow using nr_tti_tx 1 for PDSCH transmission!!! (i.e. SF 1 cannot be acked in SF 2) - // set ACK/NAKs to DTX - harq_ack1 = 2; // DTX - harq_ack0 = 2; // DTX - // This is the offset for a particular nr_tti_rx (2,3,4) => (0,2,4) - last_dl = (nr_tti_tx-2)<<1; - // i=0 - nCCE0 = ue->pdcch_vars[ue->current_thread_id[proc->nr_tti_rx]][eNB_id]->nCCE[5+last_dl]; - n1_pucch0 = nr_get_Np(frame_parms->N_RB_DL,nCCE0,0) + nCCE0+ frame_parms->pucch_config_common.n1PUCCH_AN; - // i=1 - nCCE1 = ue->pdcch_vars[ue->current_thread_id[proc->nr_tti_rx]][eNB_id]->nCCE[(6+last_dl)%10]; - n1_pucch1 = nr_get_Np(frame_parms->N_RB_DL,nCCE1,1) + nCCE1 + frame_parms->pucch_config_common.n1PUCCH_AN; - - // set ACK/NAK to values if not DTX - if (ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->harq_ack[(6+last_dl)%10].send_harq_status>0) // n-6 // nr_tti_tx 6 is to be ACK/NAKed - harq_ack1 = ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->harq_ack[(6+last_dl)%10].ack; - - if (ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->harq_ack[5+last_dl].send_harq_status>0) // n-6 // nr_tti_tx 5 is to be ACK/NAKed - harq_ack0 = ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->harq_ack[5+last_dl].ack; - - LOG_D(PHY,"SFN/SF %d/%d calculating n1_pucch cce0=%d n1_pucch0=%d cce1=%d n1_pucch1=%d\n", - proc->frame_tx%1024, - proc->nr_tti_tx, - nCCE0,n1_pucch0, - nCCE1,n1_pucch1); - - if (harq_ack1!=2) { // n-6 // nr_tti_tx 6,8,0 and maybe 5,7,9 is to be ACK/NAKed - - if ((bundling_flag==bundling)&&(SR == 0)) { // This is for bundling without SR, - // n1_pucch index takes value of smallest element in set {0,1} - // i.e. 0 if harq_ack0 is not DTX, otherwise 1 - b[0] = harq_ack1; - - if (harq_ack0!=2) - b[0]=b[0]&harq_ack0; - - ue->pucch_sel[nr_tti_tx] = 1; - return(n1_pucch1); - - } else if ((bundling_flag==multiplexing)&&(SR==0)) { // Table 10.1 - if (harq_ack0 == 2) - harq_ack0 = 0; - - b[1] = harq_ack0; - b[0] = (harq_ack0!=harq_ack1)?0:1; - - if ((harq_ack0 == 1) && (harq_ack1 == 0)) { - ue->pucch_sel[nr_tti_tx] = 0; - return(n1_pucch0); - } else { - ue->pucch_sel[nr_tti_tx] = 1; - return(n1_pucch1); - } - } else if (SR==1) { // SR and 0,1,or 2 ACKS, (first 3 entries in Table 7.3-1 of 36.213) - // this should be number of ACKs (including - if (harq_ack0 == 2) - harq_ack0 = 0; - - b[0]= harq_ack1 | harq_ack0; - b[1]= harq_ack1 ^ harq_ack0; - return(ue->scheduling_request_config[eNB_id].sr_PUCCH_ResourceIndex); - } - } else if (harq_ack0!=2) { // n-7 // nr_tti_tx 5,7,9 only is to be ACK/NAKed - if ((bundling_flag==bundling)&&(SR == 0)) { // last paragraph pg 68 from 36.213 (v8.6), m=0 - b[0]=harq_ack0; - ue->pucch_sel[nr_tti_tx] = 0; - return(n1_pucch0); - } else if ((bundling_flag==multiplexing)&&(SR==0)) { // Table 10.1 with i=1 set to DTX - b[0] = harq_ack0; - b[1] = 1-b[0]; - ue->pucch_sel[nr_tti_tx] = 0; - return(n1_pucch0); - } else if (SR==1) { // SR and only 0 or 1 ACKs (first 2 entries in Table 7.3-1 of 36.213) - b[0]=harq_ack0; - b[1]=b[0]; - return(ue->scheduling_request_config[eNB_id].sr_PUCCH_ResourceIndex); - } - } - - break; - - case 4: // DL:S:UL:UL:DL:DL:DL:DL:DL:DL - // in this configuration we have M=4 from pg 68 of 36.213 (v8.6) - // Note: this doesn't allow using nr_tti_tx 1 for PDSCH transmission!!! (i.e. SF 1 cannot be acked in SF 2) - // set ACK/NAKs to DTX - harq_ack3 = 2; // DTX - harq_ack2 = 2; // DTX - harq_ack1 = 2; // DTX - harq_ack0 = 2; // DTX - // This is the offset for a particular nr_tti_tx (2,3,4) => (0,2,4) - //last_dl = (nr_tti_tx-2)<<1; - if (nr_tti_tx == 2) { - // i=0 - //nCCE0 = ue->pdcch_vars[ue->current_thread_id[proc->nr_tti_rx]][eNB_id]->nCCE[2+nr_tti_tx]; - nCCE0 = ue->pdcch_vars[ue->current_thread_id[proc->nr_tti_rx]][eNB_id]->nCCE[(8+nr_tti_tx)%10]; - n1_pucch0 = 2*nr_get_Np(frame_parms->N_RB_DL,nCCE0,0) + nCCE0+ frame_parms->pucch_config_common.n1PUCCH_AN; - // i=1 - nCCE1 = ue->pdcch_vars[ue->current_thread_id[proc->nr_tti_rx]][eNB_id]->nCCE[2+nr_tti_tx]; - n1_pucch1 = nr_get_Np(frame_parms->N_RB_DL,nCCE1,0) + nr_get_Np(frame_parms->N_RB_DL,nCCE1,1) + nCCE1 + frame_parms->pucch_config_common.n1PUCCH_AN; - // i=2 - nCCE2 = ue->pdcch_vars[ue->current_thread_id[proc->nr_tti_rx]][eNB_id]->nCCE[(8+nr_tti_tx)%10]; - - n1_pucch2 = 2*nr_get_Np(frame_parms->N_RB_DL,nCCE2,1) + nCCE2+ frame_parms->pucch_config_common.n1PUCCH_AN; - // i=3 - //nCCE3 = ue->pdcch_vars[ue->current_thread_id[proc->nr_tti_rx]][eNB_id]->nCCE[(9+nr_tti_tx)%10]; - //n1_pucch3 = nr_get_Np(frame_parms->N_RB_DL,nCCE3,1) + nCCE3 + frame_parms->pucch_config_common.n1PUCCH_AN; - - // set ACK/NAK to values if not DTX - if (ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->harq_ack[(8+nr_tti_tx)%10].send_harq_status>0) // n-6 // nr_tti_tx 6 is to be ACK/NAKed - harq_ack0 = ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->harq_ack[(8+nr_tti_tx)%10].ack; - - if (ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->harq_ack[2+nr_tti_tx].send_harq_status>0) // n-6 // nr_tti_tx 5 is to be ACK/NAKed - harq_ack1 = ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->harq_ack[2+nr_tti_tx].ack; - - if (ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->harq_ack[3+nr_tti_tx].send_harq_status>0) // n-6 // nr_tti_tx 6 is to be ACK/NAKed - harq_ack2 = ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->harq_ack[3+nr_tti_tx].ack; - - //if (ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->harq_ack[(9+nr_tti_tx)%10].send_harq_status>0) // n-6 // nr_tti_tx 5 is to be ACK/NAKed - //harq_ack3 = ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->harq_ack[(9+nr_tti_tx)%10].ack; - //LOG_I(PHY,"SFN/SF %d/%d calculating n1_pucch cce0=%d n1_pucch0=%d cce1=%d n1_pucch1=%d cce2=%d n1_pucch2=%d\n", - // proc->frame_tx%1024, - // proc->nr_tti_tx_tx, - // nCCE0,n1_pucch0, - // nCCE1,n1_pucch1, nCCE2, n1_pucch2); - }else if (nr_tti_tx == 3) { - // i=0 - - nCCE0 = ue->pdcch_vars[ue->current_thread_id[proc->nr_tti_rx]][eNB_id]->nCCE[4+nr_tti_tx]; - n1_pucch0 = 3*nr_get_Np(frame_parms->N_RB_DL,nCCE0,0) + nCCE0+ frame_parms->pucch_config_common.n1PUCCH_AN; - // i=1 - nCCE1 = ue->pdcch_vars[ue->current_thread_id[proc->nr_tti_rx]][eNB_id]->nCCE[5+nr_tti_tx]; - n1_pucch1 = 2*nr_get_Np(frame_parms->N_RB_DL,nCCE1,0) + nr_get_Np(frame_parms->N_RB_DL,nCCE1,1) + nCCE1 + frame_parms->pucch_config_common.n1PUCCH_AN; - // i=2 - nCCE2 = ue->pdcch_vars[ue->current_thread_id[proc->nr_tti_rx]][eNB_id]->nCCE[(6+nr_tti_tx)]; - n1_pucch2 = nr_get_Np(frame_parms->N_RB_DL,nCCE2,0) + 2*nr_get_Np(frame_parms->N_RB_DL,nCCE2,1) + nCCE2+ frame_parms->pucch_config_common.n1PUCCH_AN; - // i=3 - nCCE3 = ue->pdcch_vars[ue->current_thread_id[proc->nr_tti_rx]][eNB_id]->nCCE[(3+nr_tti_tx)]; - n1_pucch3 = 3*nr_get_Np(frame_parms->N_RB_DL,nCCE3,1) + nCCE3 + frame_parms->pucch_config_common.n1PUCCH_AN; - - // set ACK/NAK to values if not DTX - if (ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->harq_ack[4+nr_tti_tx].send_harq_status>0) // n-6 // nr_tti_tx 6 is to be ACK/NAKed - harq_ack0 = ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->harq_ack[4+nr_tti_tx].ack; - - if (ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->harq_ack[5+nr_tti_tx].send_harq_status>0) // n-6 // nr_tti_tx 5 is to be ACK/NAKed - harq_ack1 = ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->harq_ack[5+nr_tti_tx].ack; - - if (ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->harq_ack[(6+nr_tti_tx)].send_harq_status>0) // n-6 // nr_tti_tx 6 is to be ACK/NAKed - harq_ack2 = ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->harq_ack[(6+nr_tti_tx)].ack; - - if (ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->harq_ack[(3+nr_tti_tx)].send_harq_status>0) // n-6 // nr_tti_tx 5 is to be ACK/NAKed - harq_ack3 = ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->harq_ack[(3+nr_tti_tx)].ack; - } - - //LOG_I(PHY,"SFN/SF %d/%d calculating n1_pucch cce0=%d n1_pucch0=%d harq_ack0=%d cce1=%d n1_pucch1=%d harq_ack1=%d cce2=%d n1_pucch2=%d harq_ack2=%d cce3=%d n1_pucch3=%d harq_ack3=%d bundling_flag=%d\n", - // proc->frame_tx%1024, - // proc->nr_tti_tx, - // nCCE0,n1_pucch0,harq_ack0, - // nCCE1,n1_pucch1,harq_ack1, nCCE2, n1_pucch2, harq_ack2, - // nCCE3, n1_pucch3, harq_ack3, bundling_flag); - - if ((bundling_flag==bundling)&&(SR == 0)) { // This is for bundling without SR, - b[0] = 1; - ack_counter = 0; - - if ((harq_ack3!=2) ) { - b[0] = b[0]&harq_ack3; - n1_pucch_inter = n1_pucch3; - ack_counter ++; - } - if ((harq_ack0!=2) ) { - b[0] = b[0]&harq_ack0; - n1_pucch_inter = n1_pucch0; - ack_counter ++; - } - if ((harq_ack1!=2) ) { - b[0] = b[0]&harq_ack1; - n1_pucch_inter = n1_pucch1; - ack_counter ++; - } - if ((harq_ack2!=2) ) { - b[0] = b[0]&harq_ack2; - n1_pucch_inter = n1_pucch2; - ack_counter ++; - } - - if (ack_counter == 0) - b[0] = 0; - - /*if (nr_tti_tx == 3) { - n1_pucch_inter = n1_pucch2; - } else if (nr_tti_tx == 2) { - n1_pucch_inter = n1_pucch1; - }*/ - - //LOG_I(PHY,"SFN/SF %d/%d calculating n1_pucch n1_pucch_inter=%d b[0]=%d b[1]=%d \n", - // proc->frame_tx%1024, - // proc->nr_tti_tx,n1_pucch_inter, - // b[0],b[1]); - - return(n1_pucch_inter); - - } else if ((bundling_flag==multiplexing)&&(SR==0)) { // Table 10.1 - - if (nr_tti_tx == 3) { - LOG_I(PHY, "sbuframe=%d \n",nr_tti_tx); - if ((harq_ack0 == 1) && (harq_ack1 == 1) && (harq_ack2 == 1) && (harq_ack3 == 1)) { - b[0] = 1; - b[1] = 1; - return(n1_pucch1); - } else if ((harq_ack0 == 1) && (harq_ack1 == 1) && (harq_ack2 == 1) && ((harq_ack3 == 2) || (harq_ack3 == 0))) { - b[0] = 1; - b[1] = 0; - return(n1_pucch1); - } else if (((harq_ack0 == 0) || (harq_ack0 == 2)) && ((harq_ack1 == 2) || (harq_ack1 == 0)) && (harq_ack2 == 0) && (harq_ack3 == 2)) { - b[0] = 1; - b[1] = 1; - return(n1_pucch2); - } else if ((harq_ack0 == 1) && (harq_ack1 == 1) && ((harq_ack2 == 2) || (harq_ack2 == 0)) && (harq_ack3 == 1)) { - b[0] = 1; - b[1] = 0; - return(n1_pucch1); - } else if ((harq_ack0 == 0) && (harq_ack1 == 2) && (harq_ack2 == 2) && (harq_ack3 == 2)) { - b[0] = 1; - b[1] = 0; - return(n1_pucch0); - } else if ((harq_ack0 == 1) && (harq_ack1 == 1) && ((harq_ack2 == 2) || (harq_ack2 == 0)) && ((harq_ack3 == 2) || (harq_ack3 == 0))) { - b[0] = 1; - b[1] = 0; - return(n1_pucch1); - } else if ((harq_ack0 == 1) && ((harq_ack1 == 2) || (harq_ack1 == 0)) && (harq_ack2 == 1) && (harq_ack3 == 1)) { - b[0] = 0; - b[1] = 1; - return(n1_pucch3); - } else if (((harq_ack0 == 0) || (harq_ack0 == 2)) && ((harq_ack1 == 2) || (harq_ack1 == 0)) && ((harq_ack2 == 2) || (harq_ack2 == 0)) && (harq_ack3 == 0)) { - b[0] = 1; - b[1] = 1; - return(n1_pucch3); - } else if ((harq_ack0 == 1) && ((harq_ack1 == 2) || (harq_ack1 == 0)) && (harq_ack2 == 1) && ((harq_ack3 == 2) || (harq_ack3 == 0))) { - b[0] = 0; - b[1] = 1; - return(n1_pucch2); - } else if ((harq_ack0 == 1) && ((harq_ack1 == 2) || (harq_ack1 == 0)) && ((harq_ack2 == 2) || (harq_ack2 == 0)) && (harq_ack3 == 1)) { - b[0] = 0; - b[1] = 1; - return(n1_pucch0); - } else if ((harq_ack0 == 1) && ((harq_ack1 == 2) || (harq_ack1 == 0)) && ((harq_ack2 == 2) || (harq_ack2 == 0)) && ((harq_ack3 == 2) || (harq_ack3 == 0))) { - b[0] = 0; - b[1] = 1; - return(n1_pucch0); - } else if (((harq_ack0 == 2) || (harq_ack0 == 0)) && (harq_ack1 == 1) && (harq_ack2 == 1) && (harq_ack3 == 1)) { - b[0] = 0; - b[1] = 1; - return(n1_pucch3); - } else if (((harq_ack0 == 2) || (harq_ack0 == 0)) && (harq_ack1 == 0) && (harq_ack2 == 2) && (harq_ack3 == 2)) { - b[0] = 0; - b[1] = 0; - return(n1_pucch1); - } else if (((harq_ack0 == 2) || (harq_ack0 == 0)) && (harq_ack1 == 1) && (harq_ack2 == 1) && ((harq_ack3 == 2) || (harq_ack3 == 0))) { - b[0] = 1; - b[1] = 0; - return(n1_pucch2); - } else if (((harq_ack0 == 2) || (harq_ack0 == 0)) && (harq_ack1 == 1) && ((harq_ack2 == 2) || (harq_ack2 == 0)) && (harq_ack3 == 1)) { - b[0] = 1; - b[1] = 0; - return(n1_pucch3); - } else if (((harq_ack0 == 2) || (harq_ack0 == 0)) && (harq_ack1 == 1) && ((harq_ack2 == 2) || (harq_ack2 == 0)) && ((harq_ack3 == 2) || (harq_ack3 == 0))) { - b[0] = 0; - b[1] = 1; - return(n1_pucch1); - } else if (((harq_ack0 == 2) || (harq_ack0 == 0)) && ((harq_ack1 == 2) || (harq_ack1 == 0)) && (harq_ack2 == 1) && (harq_ack3 == 1)) { - b[0] = 0; - b[1] = 1; - return(n1_pucch3); - } else if (((harq_ack0 == 2) || (harq_ack0 == 0)) && ((harq_ack1 == 2) || (harq_ack1 == 0)) && (harq_ack2 == 1) && ((harq_ack3 == 2) || (harq_ack3 == 0))) { - b[0] = 0; - b[1] = 0; - return(n1_pucch2); - } else if (((harq_ack0 == 2) || (harq_ack0 == 0)) && ((harq_ack1 == 2) || (harq_ack1 == 0)) && (harq_ack3 == 1) && ((harq_ack2 == 2) || (harq_ack2 == 0))) { - b[0] = 0; - b[1] = 0; - return(n1_pucch3); - } - } else if (nr_tti_tx == 2) { - if ((harq_ack0 == 1) && (harq_ack1 == 1) && (harq_ack2 == 1)) { - b[0] = 1; - b[1] = 1; - return(n1_pucch2); - } else if ((harq_ack0 == 1) && (harq_ack1 == 1) && ((harq_ack2 == 2) || (harq_ack2 == 0))) { - b[0] = 1; - b[1] = 1; - return(n1_pucch1); - } else if ((harq_ack0 == 1) && ((harq_ack1 == 2) || (harq_ack1 == 0)) && (harq_ack2 == 1)) { - b[0] = 1; - b[1] = 1; - return(n1_pucch0); - } else if ((harq_ack0 == 1) && ((harq_ack1 == 2) || (harq_ack1 == 0)) && ((harq_ack2 == 2) || (harq_ack2 == 0))) { - b[0] = 0; - b[1] = 1; - return(n1_pucch0); - } else if (((harq_ack0 == 2) || (harq_ack0 == 0)) && (harq_ack1 == 1) && (harq_ack2 == 1)) { - b[0] = 1; - b[1] = 0; - return(n1_pucch2); - } else if (((harq_ack0 == 2) || (harq_ack0 == 0)) && (harq_ack1 == 1) && ((harq_ack2 == 2) || (harq_ack2 == 0))) { - b[1] = 0; - b[0] = 0; - return(n1_pucch1); - } else if (((harq_ack0 == 2) || (harq_ack0 == 0)) && ((harq_ack1 == 2) || (harq_ack1 == 0)) && (harq_ack2 == 1)) { - b[0] = 0; - b[1] = 0; - return(n1_pucch2); - } else if ((harq_ack0 == 2) && (harq_ack1 == 2) && (harq_ack2 == 0)) { - b[0] = 0; - b[1] = 1; - return(n1_pucch2); - } else if ((harq_ack0 == 2) && (harq_ack1 == 0) && ((harq_ack2 == 2) || (harq_ack2 == 0))) { - b[0] = 1; - b[1] = 0; - return(n1_pucch1); - } else if ((harq_ack0 == 0) && ((harq_ack1 == 2) || (harq_ack1 == 0)) && ((harq_ack2 == 2) || (harq_ack2 == 0))) { - b[0] = 1; - b[1] = 0; - return(n1_pucch0); - } - - } - } else if (SR==1) { // SR and 0,1,or 2 ACKS, (first 3 entries in Table 7.3-1 of 36.213) - // this should be number of ACKs (including - ack_counter = 0; - if (harq_ack0==1) - ack_counter ++; - if (harq_ack1==1) - ack_counter ++; - if (harq_ack2==1) - ack_counter ++; - if (harq_ack3==1) - ack_counter ++; - - switch (ack_counter) { - case 0: - b[0] = 0; - b[1] = 0; - break; - - case 1: - b[0] = 1; - b[1] = 1; - break; - - case 2: - b[0] = 1; - b[1] = 0; - break; - - case 3: - b[0] = 0; - b[1] = 1; - break; - - case 4: - b[0] = 1; - b[1] = 1; - break; - } - - ack_counter = 0; - return(ue->scheduling_request_config[eNB_id].sr_PUCCH_ResourceIndex); - } - - break; - - } // switch tdd_config - } - - LOG_E(PHY,"[UE%d] : Frame %d phy_procedures_lte.c: get_n1pucch, exit without proper return\n", ue->Mod_id, proc->frame_tx); - return(-1); -} - -#endif - UE_MODE_t get_nrUE_mode(uint8_t Mod_id,uint8_t CC_id,uint8_t gNB_id){ return(PHY_vars_UE_g[Mod_id][CC_id]->UE_mode[gNB_id]); } @@ -1146,912 +171,6 @@ void nr_process_timing_advance_rar(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, LOG_D(PHY, "[UE %d] Frame %d Slot %d, Received (RAR) timing advance command %d new value is %u \n", ue->Mod_id, proc->frame_rx, proc->nr_tti_rx, ta_command, ue->timing_advance); } -#if 0 - -void ue_ulsch_uespec_procedures(PHY_VARS_NR_UE *ue, - UE_nr_rxtx_proc_t *proc, - uint8_t eNB_id, - uint8_t abstraction_flag) -{ - int nr_tti_tx=proc->nr_tti_tx; - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX_ULSCH_UESPEC,VCD_FUNCTION_IN); - - /* reset harq for tx of current rx slot because it is sure that transmission has already been achieved for this slot */ - set_tx_harq_id(ue->ulsch[ue->current_thread_id[nr_tti_tx]][eNB_id][0], NR_MAX_HARQ_PROCESSES, proc->nr_tti_rx); - -#if 0 - int frame_tx=proc->frame_tx; - int harq_pid; - /* get harq pid related to this next tx slot */ - harq_pid = get_tx_harq_id(ue->ulsch[ue->current_thread_id[nr_tti_tx]][eNB_id][0], nr_tti_tx); - - int tx_amp; - unsigned int input_buffer_length; - int Mod_id = ue->Mod_id; - int CC_id = ue->CC_id; - uint8_t Msg3_flag=0; - uint16_t first_rb, nb_rb; - uint8_t ulsch_input_buffer[5477] __attribute__ ((aligned(32))); - uint8_t access_mode; - uint8_t Nbundled=0; - uint8_t NbundledCw1=0; - uint8_t ack_status_cw0=0; - uint8_t ack_status_cw1=0; - uint8_t cqi_status = 0; - uint8_t ri_status = 0; - if (ue->mac_enabled == 1) { - if ((ue->ulsch_Msg3_active[eNB_id] == 1) && - (ue->ulsch_Msg3_frame[eNB_id] == frame_tx) && - (ue->ulsch_Msg3_subframe[eNB_id] == nr_tti_tx)) { // Initial Transmission of Msg3 - - ue->ulsch[eNB_id]->harq_processes[harq_pid]->subframe_scheduling_flag = 1; - - if (ue->ulsch[eNB_id]->harq_processes[harq_pid]->round==0) - generate_ue_ulsch_params_from_rar(ue, - proc, - eNB_id); - - ue->ulsch[eNB_id]->power_offset = 14; - LOG_D(PHY,"[UE %d][RAPROC] Frame %d: Setting Msg3_flag in nr_tti_rx %d, for harq_pid %d\n", - Mod_id, - frame_tx, - nr_tti_tx, - harq_pid); - Msg3_flag = 1; - } else { - - /* no pusch has been scheduled on this transmit slot */ - if (harq_pid == NR_MAX_HARQ_PROCESSES) { - LOG_E(PHY,"[UE%d] Frame %d nr_tti_rx %d ulsch_decoding.c: FATAL ERROR: illegal harq_pid, returning\n", - Mod_id,frame_tx, nr_tti_tx); - //mac_xface->macphy_exit("Error in ulsch_decoding"); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX, VCD_FUNCTION_OUT); -#if UE_TIMING_TRACE - stop_meas(&ue->phy_proc_tx); -#endif - return; - } - - Msg3_flag=0; - } - } - - if (ue->ulsch[eNB_id]->harq_processes[harq_pid]->subframe_scheduling_flag == 1) { - - uint8_t isBad = 0; - if (ue->frame_parms.N_RB_UL <= ue->ulsch[eNB_id]->harq_processes[harq_pid]->first_rb) { - LOG_D(PHY,"Invalid PUSCH first_RB=%d for N_RB_UL=%d\n", - ue->ulsch[eNB_id]->harq_processes[harq_pid]->first_rb, - ue->frame_parms.N_RB_UL); - isBad = 1; - } - if (ue->frame_parms.N_RB_UL < ue->ulsch[eNB_id]->harq_processes[harq_pid]->nb_rb) { - LOG_D(PHY,"Invalid PUSCH num_RB=%d for N_RB_UL=%d\n", - ue->ulsch[eNB_id]->harq_processes[harq_pid]->nb_rb, - ue->frame_parms.N_RB_UL); - isBad = 1; - } - if (0 > ue->ulsch[eNB_id]->harq_processes[harq_pid]->first_rb) { - LOG_D(PHY,"Invalid PUSCH first_RB=%d\n", - ue->ulsch[eNB_id]->harq_processes[harq_pid]->first_rb); - isBad = 1; - } - if (0 >= ue->ulsch[eNB_id]->harq_processes[harq_pid]->nb_rb) { - LOG_D(PHY,"Invalid PUSCH num_RB=%d\n", - ue->ulsch[eNB_id]->harq_processes[harq_pid]->nb_rb); - isBad = 1; - } - if (ue->frame_parms.N_RB_UL < (ue->ulsch[eNB_id]->harq_processes[harq_pid]->nb_rb + ue->ulsch[eNB_id]->harq_processes[harq_pid]->first_rb)) { - LOG_D(PHY,"Invalid PUSCH num_RB=%d + first_RB=%d for N_RB_UL=%d\n", - ue->ulsch[eNB_id]->harq_processes[harq_pid]->nb_rb, - ue->ulsch[eNB_id]->harq_processes[harq_pid]->first_rb, - ue->frame_parms.N_RB_UL); - isBad = 1; - } - if ((0 > ue->ulsch[eNB_id]->harq_processes[harq_pid]->rvidx) || - (3 < ue->ulsch[eNB_id]->harq_processes[harq_pid]->rvidx)) { - LOG_D(PHY,"Invalid PUSCH RV index=%d\n", ue->ulsch[eNB_id]->harq_processes[harq_pid]->rvidx); - isBad = 1; - } - - if (20 < ue->ulsch[eNB_id]->harq_processes[harq_pid]->mcs) { - LOG_D(PHY,"Not supported MCS in OAI mcs=%d\n", ue->ulsch[eNB_id]->harq_processes[harq_pid]->mcs); - isBad = 1; - } - - if (isBad) { - LOG_I(PHY,"Skip PUSCH generation!\n"); - ue->ulsch[eNB_id]->harq_processes[harq_pid]->subframe_scheduling_flag = 0; - } - } - if (ue->ulsch[eNB_id]->harq_processes[harq_pid]->subframe_scheduling_flag == 1) { - - ue->generate_ul_signal[eNB_id] = 1; - - // deactivate service request - // ue->ulsch[eNB_id]->harq_processes[harq_pid]->subframe_scheduling_flag = 0; - LOG_D(PHY,"Generating PUSCH (Abssubframe: %d.%d): harq-Id: %d, round: %d, MaxReTrans: %d \n",frame_tx,nr_tti_tx,harq_pid,ue->ulsch[eNB_id]->harq_processes[harq_pid]->round,ue->ulsch[eNB_id]->Mlimit); - if (ue->ulsch[eNB_id]->harq_processes[harq_pid]->round >= (ue->ulsch[eNB_id]->Mlimit - 1)) - { - LOG_D(PHY,"PUSCH MAX Retransmission achieved ==> send last pusch\n"); - ue->ulsch[eNB_id]->harq_processes[harq_pid]->subframe_scheduling_flag = 0; - ue->ulsch[eNB_id]->harq_processes[harq_pid]->round = 0; - } - - ack_status_cw0 = nr_reset_ack(&ue->frame_parms, - ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->harq_ack, - nr_tti_tx, - proc->nr_tti_rx, - ue->ulsch[eNB_id]->o_ACK, - &Nbundled, - 0); - ack_status_cw1 = nr_reset_ack(&ue->frame_parms, - ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][1]->harq_ack, - nr_tti_tx, - proc->nr_tti_rx, - ue->ulsch[eNB_id]->o_ACK, - &NbundledCw1, - 1); - - //Nbundled = ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->harq_ack; - //ue->ulsch[eNB_id]->bundling = Nbundled; - - first_rb = ue->ulsch[eNB_id]->harq_processes[harq_pid]->first_rb; - nb_rb = ue->ulsch[eNB_id]->harq_processes[harq_pid]->nb_rb; - - - // check Periodic CQI/RI reporting - cqi_status = ((ue->cqi_report_config[eNB_id].CQI_ReportPeriodic.cqi_PMI_ConfigIndex>0)&& - (nr_is_cqi_TXOp(ue,proc,eNB_id)==1)); - - ri_status = ((ue->cqi_report_config[eNB_id].CQI_ReportPeriodic.ri_ConfigIndex>0) && - (nr_is_ri_TXOp(ue,proc,eNB_id)==1)); - - // compute CQI/RI resources - compute_cqi_ri_resources(ue, ue->ulsch[eNB_id], eNB_id, ue->ulsch[eNB_id]->rnti, P_RNTI, CBA_RNTI, cqi_status, ri_status); - - if (ack_status_cw0 > 0) { - - // check if we received a PDSCH at nr_tti_tx - 4 - // ==> send ACK/NACK on PUSCH - if (ue->frame_parms.frame_type == FDD) - { - ue->ulsch[eNB_id]->harq_processes[harq_pid]->O_ACK = ack_status_cw0 + ack_status_cw1; - } - - -#if T_TRACER - if(ue->ulsch[eNB_id]->o_ACK[0]) - { - LOG_I(PHY,"PUSCH ACK\n"); - T(T_UE_PHY_DLSCH_UE_ACK, T_INT(eNB_id), T_INT(frame_tx%1024), T_INT(nr_tti_tx), T_INT(Mod_id), T_INT(ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->rnti), - T_INT(ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->current_harq_pid)); - } - else - { - LOG_I(PHY,"PUSCH NACK\n"); - T(T_UE_PHY_DLSCH_UE_NACK, T_INT(eNB_id), T_INT(frame_tx%1024), T_INT(nr_tti_tx), T_INT(Mod_id), T_INT(ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->rnti), - T_INT(ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->current_harq_pid)); - } -#endif -#ifdef UE_DEBUG_TRACE - LOG_I(PHY,"[UE %d][PDSCH %x] AbsSubFrame %d.%d Generating ACK (%d,%d) for %d bits on PUSCH\n", - Mod_id, - ue->ulsch[eNB_id]->rnti, - frame_tx%1024,nr_tti_tx, - ue->ulsch[eNB_id]->o_ACK[0],ue->ulsch[eNB_id]->o_ACK[1], - ue->ulsch[eNB_id]->harq_processes[harq_pid]->O_ACK); -#endif - } - - //#ifdef UE_DEBUG_TRACE - LOG_I(PHY, - "[UE %d][PUSCH %d] AbsSubframe %d.%d Generating PUSCH : first_rb %d, nb_rb %d, round %d, mcs %d, tbs %d, rv %d, " - "cyclic_shift %d (cyclic_shift_common %d,n_DMRS2 %d,n_PRS %d), ACK (%d,%d), O_ACK %d, ack_status_cw0 %d ack_status_cw1 %d bundling %d, Nbundled %d, CQI %d, RI %d\n", - Mod_id,harq_pid,frame_tx%1024,nr_tti_tx, - first_rb,nb_rb, - ue->ulsch[eNB_id]->harq_processes[harq_pid]->round, - ue->ulsch[eNB_id]->harq_processes[harq_pid]->mcs, - ue->ulsch[eNB_id]->harq_processes[harq_pid]->TBS, - ue->ulsch[eNB_id]->harq_processes[harq_pid]->rvidx, - (ue->frame_parms.pusch_config_common.ul_ReferenceSignalsPUSCH.cyclicShift+ - ue->ulsch[eNB_id]->harq_processes[harq_pid]->n_DMRS2+ - ue->frame_parms.pusch_config_common.ul_ReferenceSignalsPUSCH.nPRS[nr_tti_tx<<1])%12, - ue->frame_parms.pusch_config_common.ul_ReferenceSignalsPUSCH.cyclicShift, - ue->ulsch[eNB_id]->harq_processes[harq_pid]->n_DMRS2, - ue->frame_parms.pusch_config_common.ul_ReferenceSignalsPUSCH.nPRS[nr_tti_tx<<1], - ue->ulsch[eNB_id]->o_ACK[0],ue->ulsch[eNB_id]->o_ACK[1], - ue->ulsch[eNB_id]->harq_processes[harq_pid]->O_ACK, - ack_status_cw0, - ack_status_cw1, - ue->ulsch[eNB_id]->bundling, Nbundled, - cqi_status, - ri_status); - //#endif - - - - - - if (Msg3_flag == 1) { - LOG_I(PHY,"[UE %d][RAPROC] Frame %d, nr_tti_rx %d Generating (RRCConnectionRequest) Msg3 (nb_rb %d, first_rb %d, round %d, rvidx %d) Msg3: %x.%x.%x|%x.%x.%x.%x.%x.%x\n",Mod_id,frame_tx, - nr_tti_tx, - ue->ulsch[eNB_id]->harq_processes[harq_pid]->nb_rb, - ue->ulsch[eNB_id]->harq_processes[harq_pid]->first_rb, - ue->ulsch[eNB_id]->harq_processes[harq_pid]->round, - ue->ulsch[eNB_id]->harq_processes[harq_pid]->rvidx, - ue->prach_resources[eNB_id]->Msg3[0], - ue->prach_resources[eNB_id]->Msg3[1], - ue->prach_resources[eNB_id]->Msg3[2], - ue->prach_resources[eNB_id]->Msg3[3], - ue->prach_resources[eNB_id]->Msg3[4], - ue->prach_resources[eNB_id]->Msg3[5], - ue->prach_resources[eNB_id]->Msg3[6], - ue->prach_resources[eNB_id]->Msg3[7], - ue->prach_resources[eNB_id]->Msg3[8]); -#if UE_TIMING_TRACE - start_meas(&ue->ulsch_encoding_stats); -#endif - - if (abstraction_flag==0) { - if (ulsch_encoding(ue->prach_resources[eNB_id]->Msg3, - ue, - harq_pid, - eNB_id, - proc->nr_tti_rx, - ue->transmission_mode[eNB_id],0,0)!=0) { - LOG_E(PHY,"ulsch_coding.c: FATAL ERROR: returning\n"); - //mac_xface->macphy_exit("Error in ulsch_coding"); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX, VCD_FUNCTION_OUT); -#if UE_TIMING_TRACE - stop_meas(&ue->phy_proc_tx); - printf("------FULL TX PROC : %5.2f ------\n",ue->phy_proc_tx.p_time/(cpuf*1000.0)); -#endif - return; - } - } - -#ifdef PHY_ABSTRACTION - else { - ulsch_encoding_emul(ue->prach_resources[eNB_id]->Msg3,ue,eNB_id,proc->nr_tti_rx,harq_pid,0); - } - -#endif - -#if UE_TIMING_TRACE - stop_meas(&ue->ulsch_encoding_stats); -#endif - if (ue->mac_enabled == 1) { - // signal MAC that Msg3 was sent - //mac_xface->Msg3_transmitted(Mod_id, - CC_id, - frame_tx, - eNB_id); - } - } // Msg3_flag==1 - else { - input_buffer_length = ue->ulsch[eNB_id]->harq_processes[harq_pid]->TBS/8; - - if (ue->mac_enabled==1) { - // LOG_D(PHY,"[UE %d] ULSCH : Searching for MAC SDUs\n",Mod_id); - if (ue->ulsch[eNB_id]->harq_processes[harq_pid]->round==0) { - //if (ue->ulsch[eNB_id]->harq_processes[harq_pid]->calibration_flag == 0) { - access_mode=SCHEDULED_ACCESS; - //mac_xface->ue_get_sdu(Mod_id, - CC_id, - frame_tx, - proc->subframe_tx, - nr_tti_tx%(ue->frame_parms.ttis_per_subframe), - eNB_id, - ulsch_input_buffer, - input_buffer_length, - &access_mode); - } - -#ifdef DEBUG_PHY_PROC -#ifdef DEBUG_ULSCH - LOG_D(PHY,"[UE] Frame %d, nr_tti_rx %d : ULSCH SDU (TX harq_pid %d) (%d bytes) : \n",frame_tx,nr_tti_tx,harq_pid, ue->ulsch[eNB_id]->harq_processes[harq_pid]->TBS>>3); - - for (int i=0; iulsch[eNB_id]->harq_processes[harq_pid]->TBS>>3; i++) - LOG_T(PHY,"%x.",ulsch_input_buffer[i]); - - LOG_T(PHY,"\n"); -#endif -#endif - } - else { - unsigned int taus(void); - - for (int i=0; iulsch_encoding_stats); -#endif - if (abstraction_flag==0) { - - if (ulsch_encoding(ulsch_input_buffer, - ue, - harq_pid, - eNB_id, - proc->nr_tti_rx, - ue->transmission_mode[eNB_id],0, - Nbundled)!=0) { - LOG_E(PHY,"ulsch_coding.c: FATAL ERROR: returning\n"); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX, VCD_FUNCTION_OUT); -#if UE_TIMING_TRACE - stop_meas(&ue->phy_proc_tx); -#endif - return; - } - } - -#ifdef PHY_ABSTRACTION - else { - ulsch_encoding_emul(ulsch_input_buffer,ue,eNB_id,proc->nr_tti_rx,harq_pid,0); - } - -#endif -#if UE_TIMING_TRACE - stop_meas(&ue->ulsch_encoding_stats); -#endif -} - -if (abstraction_flag == 0) { - if (ue->mac_enabled==1) { - nr_pusch_power_cntl(ue,proc,eNB_id,1, abstraction_flag); - ue->tx_power_dBm[nr_tti_tx] = ue->ulsch[eNB_id]->Po_PUSCH; - } - else { - ue->tx_power_dBm[nr_tti_tx] = ue->tx_power_max_dBm; - } - ue->tx_total_RE[nr_tti_tx] = nb_rb*12; - -#if defined(EXMIMO) || defined(OAI_USRP) || defined(OAI_BLADERF) || defined(OAI_LMSSDR) || defined(OAI_ADRV9371_ZC706) - tx_amp = nr_get_tx_amp(ue->tx_power_dBm[nr_tti_tx], - ue->tx_power_max_dBm, - ue->frame_parms.N_RB_UL, - nb_rb); -#else - tx_amp = AMP; -#endif -#if T_TRACER - T(T_UE_PHY_PUSCH_TX_POWER, T_INT(eNB_id),T_INT(Mod_id), T_INT(frame_tx%1024), T_INT(nr_tti_tx),T_INT(ue->tx_power_dBm[nr_tti_tx]), - T_INT(tx_amp),T_INT(ue->ulsch[eNB_id]->f_pusch),T_INT(get_nr_PL(Mod_id,0,eNB_id)),T_INT(nb_rb)); -#endif - -#ifdef UE_DEBUG_TRACE - LOG_I(PHY,"[UE %d][PUSCH %d] AbsSubFrame %d.%d, generating PUSCH, Po_PUSCH: %d dBm (max %d dBm), amp %d\n", - Mod_id,harq_pid,frame_tx%1024,nr_tti_tx,ue->tx_power_dBm[nr_tti_tx],ue->tx_power_max_dBm, tx_amp); -#endif - - if (tx_amp>100) - tx_amp =100; - - //LOG_I(PHY,"[UE %d][PUSCH %d] after AbsSubFrame %d.%d, generating PUSCH, Po_PUSCH: %d dBm (max %d dBm), amp %d\n", - // Mod_id,harq_pid,frame_tx%1024,nr_tti_tx,ue->tx_power_dBm[nr_tti_tx],ue->tx_power_max_dBm, tx_amp); - - -#if UE_TIMING_TRACE - - start_meas(&ue->ulsch_modulation_stats); -#endif - ulsch_modulation(ue->common_vars.txdataF, - tx_amp, - frame_tx, - nr_tti_tx, - &ue->frame_parms, - ue->ulsch[eNB_id]); - for (int aa=0; aa<1/*frame_parms->nb_antennas_tx*/; aa++) - generate_drs_pusch(ue, - proc, - eNB_id, - tx_amp, - nr_tti_tx, - first_rb, - nb_rb, - aa); -#if UE_TIMING_TRACE - stop_meas(&ue->ulsch_modulation_stats); -#endif - } - -if (abstraction_flag==1) { - // clear SR - ue->sr[nr_tti_tx]=0; - } -} // subframe_scheduling_flag==1 - -VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX_ULSCH_UESPEC,VCD_FUNCTION_OUT); - -#endif - -} -#endif - -#if 0 - -void ue_srs_procedures(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t abstraction_flag) -{ - - //NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; - //int8_t frame_tx = proc->frame_tx; - int8_t nr_tti_tx = proc->nr_tti_tx; - int16_t tx_amp; - int16_t Po_SRS; - uint8_t nb_rb_srs; - - SOUNDINGRS_UL_CONFIG_DEDICATED *pSoundingrs_ul_config_dedicated=&ue->soundingrs_ul_config_dedicated[eNB_id]; - uint8_t isSrsTxOccasion = pSoundingrs_ul_config_dedicated->srsUeSubframe; - - if(isSrsTxOccasion) - { - ue->generate_ul_signal[eNB_id] = 1; - if (ue->mac_enabled==1) - { - srs_power_cntl(ue,proc,eNB_id, (uint8_t*)(&nb_rb_srs), abstraction_flag); - Po_SRS = ue->ulsch[eNB_id]->Po_SRS; - } - else - { - Po_SRS = ue->tx_power_max_dBm; - } - -#if defined(EXMIMO) || defined(OAI_USRP) || defined(OAI_BLADERF) || defined(OAI_LMSSDR) || defined(OAI_ADRV9371_ZC706) - if (ue->mac_enabled==1) - { - tx_amp = nr_get_tx_amp(Po_SRS, - ue->tx_power_max_dBm, - ue->frame_parms.N_RB_UL, - nb_rb_srs); - } - else - { - tx_amp = AMP; - } -#else - tx_amp = AMP; -#endif - LOG_D(PHY,"SRS PROC; TX_MAX_POWER %d, Po_SRS %d, NB_RB_UL %d, NB_RB_SRS %d TX_AMPL %d\n",ue->tx_power_max_dBm, - Po_SRS, - ue->frame_parms.N_RB_UL, - nb_rb_srs, - tx_amp); - - uint16_t nsymb = (ue->frame_parms.Ncp==0) ? 14:12; - uint16_t symbol_offset = (int)ue->frame_parms.ofdm_symbol_size*((nr_tti_tx*nsymb)+(nsymb-1)); - generate_srs(&ue->frame_parms, - &ue->soundingrs_ul_config_dedicated[eNB_id], - &ue->common_vars.txdataF[eNB_id][symbol_offset], - tx_amp, - nr_tti_tx); - } -} - -int16_t get_pucch2_cqi(PHY_VARS_NR_UE *ue,int eNB_id,int *len) { - - if ((ue->transmission_mode[eNB_id]<4)|| - (ue->transmission_mode[eNB_id]==7)) { // Mode 1-0 feedback - // 4-bit CQI message - /*LOG_I(PHY,"compute CQI value, TM %d, length 4, Cqi Avg %d, value %d \n", ue->transmission_mode[eNB_id], - ue->measurements.wideband_cqi_avg[eNB_id], - sinr2cqi((double)ue->measurements.wideband_cqi_avg[eNB_id], - ue->transmission_mode[eNB_id]));*/ - *len=4; - return(sinr2cqi((double)ue->measurements.wideband_cqi_avg[eNB_id], - ue->transmission_mode[eNB_id])); - } - else { // Mode 1-1 feedback, later - //LOG_I(PHY,"compute CQI value, TM %d, length 0, Cqi Avg 0 \n", ue->transmission_mode[eNB_id]); - *len=0; - // 2-antenna ports RI=1, 6 bits (2 PMI, 4 CQI) - - // 2-antenna ports RI=2, 8 bits (1 PMI, 7 CQI/DIFF CQI) - return(0); - } -} - - -int16_t get_pucch2_ri(PHY_VARS_NR_UE *ue,int eNB_id) { - - return(1); -} - - -void get_pucch_param(PHY_VARS_NR_UE *ue, - UE_nr_rxtx_proc_t *proc, - uint8_t *ack_payload, - PUCCH_FMT_t format, - uint8_t eNB_id, - uint8_t SR, - uint8_t cqi_report, - uint16_t *pucch_resource, - uint8_t *pucch_payload, - uint16_t *plength) -{ - - switch (format) { - case pucch_format1: - { - pucch_resource[0] = ue->scheduling_request_config[eNB_id].sr_PUCCH_ResourceIndex; - pucch_payload[0] = 0; // payload is ignored in case of format1 - pucch_payload[1] = 0; // payload is ignored in case of format1 - } - break; - - case pucch_format1a: - case pucch_format1b: - { - pucch_resource[0] = nr_get_n1_pucch(ue, - proc, - ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->harq_ack, - eNB_id, - ack_payload, - SR); - pucch_payload[0] = ack_payload[0]; - pucch_payload[1] = ack_payload[1]; - //pucch_payload[1] = 1; - } - break; - - case pucch_format2: - { - pucch_resource[0] = ue->cqi_report_config[eNB_id].CQI_ReportPeriodic.cqi_PUCCH_ResourceIndex; - if(cqi_report) - { - pucch_payload[0] = get_pucch2_cqi(ue,eNB_id,(int*)plength); - } - else - { - *plength = 1; - pucch_payload[0] = get_pucch2_ri(ue,eNB_id); - } - } - break; - - case pucch_format2a: - case pucch_format2b: - LOG_E(PHY,"NO Resource available for PUCCH 2a/2b \n"); - break; - - case pucch_format3: - fprintf(stderr, "PUCCH format 3 not handled\n"); - abort(); - } -} - -#ifdef NR_PUCCH_SCHED -void ue_nr_pucch_procedures(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t abstraction_flag) { -} -#endif - -void ue_pucch_procedures(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t abstraction_flag) { - - - uint8_t pucch_ack_payload[2]; - uint16_t pucch_resource; - ANFBmode_t bundling_flag; - PUCCH_FMT_t format; - - uint8_t SR_payload; - uint8_t pucch_payload[2]; - uint16_t len; - - NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; - int frame_tx=proc->frame_tx; - int nr_tti_tx=proc->nr_tti_tx; - int Mod_id = ue->Mod_id; - int CC_id = ue->CC_id; - int tx_amp; - int16_t Po_PUCCH; - uint8_t ack_status_cw0=0; - uint8_t ack_status_cw1=0; - uint8_t nb_cw=0; - uint8_t cqi_status=0; - uint8_t ri_status=0; - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX_PUCCH,VCD_FUNCTION_IN); - - SOUNDINGRS_UL_CONFIG_DEDICATED *pSoundingrs_ul_config_dedicated=&ue->soundingrs_ul_config_dedicated[eNB_id]; - - // 36.213 8.2 - /*if ackNackSRS_SimultaneousTransmission == TRUE and in the cell specific SRS subframes UE shall transmit - ACK/NACK and SR using the shortened PUCCH format. This shortened PUCCH format shall be used in a cell - specific SRS nr_tti_rx even if the UE does not transmit SRS in that nr_tti_rx - */ - - int harq_pid = nr_subframe2harq_pid(&ue->frame_parms, - frame_tx, - nr_tti_tx); - - if(ue->ulsch[eNB_id]->harq_processes[harq_pid]->subframe_scheduling_flag) - { - LOG_D(PHY,"PUSCH is programmed on this nr_tti_rx [pid %d] AbsSuframe %d.%d ==> Skip PUCCH transmission \n",harq_pid,frame_tx,nr_tti_tx); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX_PUCCH,VCD_FUNCTION_OUT); - return; - } - - uint8_t isShortenPucch = (pSoundingrs_ul_config_dedicated->srsCellSubframe && frame_parms->soundingrs_ul_config_common.ackNackSRS_SimultaneousTransmission); - - bundling_flag = ue->pucch_config_dedicated[eNB_id].tdd_AckNackFeedbackMode; - - if ((frame_parms->frame_type==FDD) || - (bundling_flag==bundling) || - ((frame_parms->frame_type==TDD)&&(frame_parms->tdd_config==1)&&((nr_tti_tx!=2)||(nr_tti_tx!=7)))) { - format = pucch_format1a; - LOG_D(PHY,"[UE] PUCCH 1a\n"); - } else { - format = pucch_format1b; - LOG_D(PHY,"[UE] PUCCH 1b\n"); - } - - // Part - I - // Collect feedback that should be transmitted at this nr_tti_rx - // - SR - // - ACK/NACK - // - CQI - // - RI - - SR_payload = 0; - if (nr_is_SR_TXOp(ue,proc,eNB_id)==1) - { - if (ue->mac_enabled==1) { - SR_payload = mac_xface->ue_get_SR(Mod_id, - CC_id, - frame_tx, - eNB_id, - ue->pdcch_vars[ue->current_thread_id[proc->nr_tti_rx]][eNB_id]->crnti, - nr_tti_tx); // nr_tti_rx used for meas gap - } - else { - SR_payload = 1; - } - } - - ack_status_cw0 = nr_get_ack(&ue->frame_parms, - ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->harq_ack, - nr_tti_tx, - proc->nr_tti_rx, - pucch_ack_payload, - 0); - - ack_status_cw1 = nr_get_ack(&ue->frame_parms, - ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][1]->harq_ack, - nr_tti_tx, - proc->nr_tti_rx, - pucch_ack_payload, - 1); - - nb_cw = ( (ack_status_cw0 != 0) ? 1:0) + ( (ack_status_cw1 != 0) ? 1:0); - - cqi_status = ((ue->cqi_report_config[eNB_id].CQI_ReportPeriodic.cqi_PMI_ConfigIndex>0)&& - (nr_is_cqi_TXOp(ue,proc,eNB_id)==1)); - - ri_status = ((ue->cqi_report_config[eNB_id].CQI_ReportPeriodic.ri_ConfigIndex>0) && - (nr_is_ri_TXOp(ue,proc,eNB_id)==1)); - - // Part - II - // if nothing to report ==> exit function - if( (nb_cw==0) && (SR_payload==0) && (cqi_status==0) && (ri_status==0) ) - { - LOG_D(PHY,"PUCCH No feedback AbsSubframe %d.%d SR_payload %d nb_cw %d pucch_ack_payload[0] %d pucch_ack_payload[1] %d cqi_status %d Return \n", - frame_tx%1024, nr_tti_tx, SR_payload, nb_cw, pucch_ack_payload[0], pucch_ack_payload[1], cqi_status); - return; - } - - // Part - III - // Decide which PUCCH format should be used if needed - format = get_pucch_format(frame_parms->frame_type, - frame_parms->Ncp, - SR_payload, - nb_cw, - cqi_status, - ri_status, - bundling_flag); - // Determine PUCCH resources and payload: mandatory for pucch encoding - get_pucch_param(ue, - proc, - pucch_ack_payload, - format, - eNB_id, - SR_payload, - cqi_status, - &pucch_resource, - (uint8_t *)&pucch_payload, - &len); - - - LOG_D(PHY,"PUCCH feedback AbsSubframe %d.%d SR %d NbCW %d (%d %d) AckNack %d.%d CQI %d RI %d format %d pucch_resource %d pucch_payload %d %d \n", - frame_tx%1024, nr_tti_tx, SR_payload, nb_cw, ack_status_cw0, ack_status_cw1, pucch_ack_payload[0], pucch_ack_payload[1], cqi_status, ri_status, format, pucch_resource,pucch_payload[0],pucch_payload[1]); - - // Part - IV - // Generate PUCCH signal - ue->generate_ul_signal[eNB_id] = 1; - - switch (format) { - case pucch_format1: - case pucch_format1a: - case pucch_format1b: - { - if (ue->mac_enabled == 1) { - Po_PUCCH = nr_pucch_power_cntl(ue,proc,nr_tti_tx,eNB_id,format); - } - else { - Po_PUCCH = ue->tx_power_max_dBm; - } - ue->tx_power_dBm[nr_tti_tx] = Po_PUCCH; - ue->tx_total_RE[nr_tti_tx] = 12; - -#if defined(EXMIMO) || defined(OAI_USRP) || defined(OAI_BLADERF) || defined(OAI_LMSSDR) || defined(OAI_ADRV9371_ZC706) - tx_amp = nr_get_tx_amp(Po_PUCCH, - ue->tx_power_max_dBm, - ue->frame_parms.N_RB_UL, - 1); -#else - tx_amp = AMP; -#endif -#if T_TRACER - T(T_UE_PHY_PUCCH_TX_POWER, T_INT(eNB_id),T_INT(Mod_id), T_INT(frame_tx%1024), T_INT(nr_tti_tx),T_INT(ue->tx_power_dBm[nr_tti_tx]), - T_INT(tx_amp),T_INT(ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->g_pucch),T_INT(get_nr_PL(ue->Mod_id,ue->CC_id,eNB_id))); -#endif - -#ifdef UE_DEBUG_TRACE - if(format == pucch_format1) - { - LOG_I(PHY,"[UE %d][SR %x] AbsSubframe %d.%d Generating PUCCH 1 (SR for PUSCH), an_srs_simultanous %d, shorten_pucch %d, n1_pucch %d, Po_PUCCH %d\n", - Mod_id, - ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->rnti, - frame_tx%1024, nr_tti_tx, - frame_parms->soundingrs_ul_config_common.ackNackSRS_SimultaneousTransmission, - isShortenPucch, - ue->scheduling_request_config[eNB_id].sr_PUCCH_ResourceIndex, - Po_PUCCH); - } - else - { - if (SR_payload>0) { - LOG_I(PHY,"[UE %d][SR %x] AbsSubFrame %d.%d Generating PUCCH %s payload %d,%d (with SR for PUSCH), an_srs_simultanous %d, shorten_pucch %d, n1_pucch %d, Po_PUCCH %d, amp %d\n", - Mod_id, - ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->rnti, - frame_tx % 1024, nr_tti_tx, - (format == pucch_format1a? "1a": ( - format == pucch_format1b? "1b" : "??")), - pucch_ack_payload[0],pucch_ack_payload[1], - frame_parms->soundingrs_ul_config_common.ackNackSRS_SimultaneousTransmission, - isShortenPucch, - pucch_resource, - Po_PUCCH, - tx_amp); - } else { - LOG_I(PHY,"[UE %d][PDSCH %x] AbsSubFrame %d.%d rx_offset_diff: %d, Generating PUCCH %s, an_srs_simultanous %d, shorten_pucch %d, n1_pucch %d, b[0]=%d,b[1]=%d (SR_Payload %d), Po_PUCCH %d, amp %d\n", - Mod_id, - ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->rnti, - frame_tx%1024, nr_tti_tx,ue->rx_offset_diff, - (format == pucch_format1a? "1a": ( - format == pucch_format1b? "1b" : "??")), - frame_parms->soundingrs_ul_config_common.ackNackSRS_SimultaneousTransmission, - isShortenPucch, - pucch_resource,pucch_payload[0],pucch_payload[1],SR_payload, - Po_PUCCH, - tx_amp); - } - } -#endif - -#if T_TRACER - if(pucch_payload[0]) - { - T(T_UE_PHY_DLSCH_UE_ACK, T_INT(eNB_id), T_INT(frame_tx%1024), T_INT(nr_tti_tx), T_INT(Mod_id), T_INT(ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->rnti), - T_INT(ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->current_harq_pid)); - } - else - { - T(T_UE_PHY_DLSCH_UE_NACK, T_INT(eNB_id), T_INT(frame_tx%1024), T_INT(nr_tti_tx), T_INT(Mod_id), T_INT(ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->rnti), - T_INT(ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->current_harq_pid)); - } -#endif - - if (abstraction_flag == 0) { - - generate_pucch1x(ue->common_vars.txdataF, - &ue->frame_parms, - ue->ncs_cell, - format, - &ue->pucch_config_dedicated[eNB_id], - pucch_resource, - isShortenPucch, // shortened format - pucch_payload, - tx_amp, - nr_tti_tx); - - } else { -#ifdef PHY_ABSTRACTION - LOG_D(PHY,"Calling generate_pucch_emul ... (ACK %d %d, SR %d)\n",pucch_ack_payload[0],pucch_ack_payload[1],SR_payload); - generate_pucch_emul(ue, - proc, - format, - ue->frame_parms.pucch_config_common.nCS_AN, - pucch_payload, - SR_payload); -#endif - } - } - break; - - - case pucch_format2: - { - if (ue->mac_enabled == 1) { - Po_PUCCH = nr_pucch_power_cntl(ue,proc,nr_tti_tx,eNB_id,format); - } - else { - Po_PUCCH = ue->tx_power_max_dBm; - } - ue->tx_power_dBm[nr_tti_tx] = Po_PUCCH; - ue->tx_total_RE[nr_tti_tx] = 12; - -#if defined(EXMIMO) || defined(OAI_USRP) || defined(OAI_BLADERF) || defined(OAI_LMSSDR) || defined(OAI_ADRV9371_ZC706) - tx_amp = nr_get_tx_amp(Po_PUCCH, - ue->tx_power_max_dBm, - ue->frame_parms.N_RB_UL, - 1); -#else - tx_amp = AMP; -#endif -#if T_TRACER - T(T_UE_PHY_PUCCH_TX_POWER, T_INT(eNB_id),T_INT(Mod_id), T_INT(frame_tx%1024), T_INT(nr_tti_tx),T_INT(ue->tx_power_dBm[nr_tti_tx]), - T_INT(tx_amp),T_INT(ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->g_pucch),T_INT(get_nr_PL(ue->Mod_id,ue->CC_id,eNB_id))); -#endif -#ifdef UE_DEBUG_TRACE - LOG_I(PHY,"[UE %d][RNTI %x] AbsSubFrame %d.%d Generating PUCCH 2 (RI or CQI), Po_PUCCH %d, isShortenPucch %d, amp %d\n", - Mod_id, - ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->rnti, - frame_tx%1024, nr_tti_tx, - Po_PUCCH, - isShortenPucch, - tx_amp); -#endif - generate_pucch2x(ue->common_vars.txdataF, - &ue->frame_parms, - ue->ncs_cell, - format, - &ue->pucch_config_dedicated[eNB_id], - pucch_resource, - pucch_payload, - len, // A - 0, // B2 not needed - tx_amp, - nr_tti_tx, - ue->pdcch_vars[ue->current_thread_id[proc->nr_tti_rx]][eNB_id]->crnti); - } - break; - - case pucch_format2a: - LOG_D(PHY,"[UE %d][RNTI %x] AbsSubFrame %d.%d Generating PUCCH 2a (RI or CQI) Ack/Nack 1bit \n", - Mod_id, - ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->rnti, - frame_tx%1024, nr_tti_tx); - break; - case pucch_format2b: - LOG_D(PHY,"[UE %d][RNTI %x] AbsSubFrame %d.%d Generating PUCCH 2b (RI or CQI) Ack/Nack 2bits\n", - Mod_id, - ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->rnti, - frame_tx%1024, nr_tti_tx); - break; - default: - break; - } - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX_PUCCH,VCD_FUNCTION_OUT); - -} - -#endif - - void phy_procedures_nrUE_TX(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t gNB_id, @@ -2073,18 +192,9 @@ void phy_procedures_nrUE_TX(PHY_VARS_NR_UE *ue, #endif if (ue->UE_mode[gNB_id] == PUSCH || get_softmodem_params()->phy_test == 1){ - if (ue->ulsch[thread_id][gNB_id][0]->harq_processes[harq_pid]->status == ACTIVE) - nr_ue_ulsch_procedures(ue, harq_pid, frame_tx, slot_tx, thread_id, gNB_id); - -/* - if (ue->UE_mode[eNB_id] == PUSCH) { - // check if we need to use PUCCH 1a/1b - ue_pucch_procedures(ue,proc,eNB_id,abstraction_flag); - // check if we need to use SRS - ue_srs_procedures(ue,proc,eNB_id,abstraction_flag); - } // UE_mode==PUSCH -*/ + if (ue->ulsch[thread_id][gNB_id][0]->harq_processes[harq_pid]->status == ACTIVE) + nr_ue_ulsch_procedures(ue, harq_pid, frame_tx, slot_tx, thread_id, gNB_id); if (get_softmodem_params()->usim_test==0) { LOG_D(PHY, "Sending PUCCH\n"); @@ -2119,32 +229,6 @@ void phy_procedures_nrUE_TX(PHY_VARS_NR_UE *ue, } -/* -void phy_procedures_UE_S_TX(PHY_VARS_NR_UE *ue,uint8_t eNB_id,uint8_t abstraction_flag,relaying_type_t r_type) -{ - int aa;//i,aa; - NR_DL_FRAME_PARMS *frame_parms=&ue->frame_parms; - - if (abstraction_flag==0) { - - for (aa=0; aanb_antennas_tx; aa++) { -#if defined(EXMIMO) //this is the EXPRESS MIMO case - int i; - // set the whole tx buffer to RX - for (i=0; isamples_per_subframe; i++) - ue->common_vars.txdata[aa][i] = 0x00010001; - -#else //this is the normal case - memset(&ue->common_vars.txdata[aa][0],0, - (LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*frame_parms->samples_per_subframe)*sizeof(int32_t)); -#endif //else EXMIMO - - } - } -} - -*/ - void nr_ue_measurement_procedures(uint16_t l, // symbol index of each slot [0..6] PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, @@ -2217,74 +301,6 @@ void nr_ue_measurement_procedures(uint16_t l, // symbol index of each slot [0 VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_MEASUREMENT_PROCEDURES, VCD_FUNCTION_OUT); } - - -#if 0 -void restart_phy(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc, uint8_t eNB_id,uint8_t abstraction_flag) -{ - - // uint8_t last_slot; - uint8_t i; - LOG_I(PHY,"[UE %d] frame %d, slot %d, restarting PHY!\n",ue->Mod_id,proc->frame_rx,proc->nr_tti_rx); - //mac_xface->macphy_exit("restart_phy called"); - // first_run = 1; - - if (abstraction_flag ==0 ) { - ue->UE_mode[eNB_id] = NOT_SYNCHED; - } else { - ue->UE_mode[eNB_id] = PRACH; - ue->prach_resources[eNB_id]=NULL; - } - - proc->frame_rx = -1; - proc->frame_tx = -1; - // ue->synch_wait_cnt=0; - // ue->sched_cnt=-1; - - ue->pbch_vars[eNB_id]->pdu_errors_conseq=0; - ue->pbch_vars[eNB_id]->pdu_errors=0; - - ue->pdcch_vars[0][eNB_id]->dci_errors = 0; - ue->pdcch_vars[0][eNB_id]->dci_missed = 0; - ue->pdcch_vars[0][eNB_id]->dci_false = 0; - ue->pdcch_vars[0][eNB_id]->dci_received = 0; - - ue->pdcch_vars[1][eNB_id]->dci_errors = 0; - ue->pdcch_vars[1][eNB_id]->dci_missed = 0; - ue->pdcch_vars[1][eNB_id]->dci_false = 0; - ue->pdcch_vars[1][eNB_id]->dci_received = 0; - - ue->dlsch_errors[eNB_id] = 0; - ue->dlsch_errors_last[eNB_id] = 0; - ue->dlsch_received[eNB_id] = 0; - ue->dlsch_received_last[eNB_id] = 0; - ue->dlsch_fer[eNB_id] = 0; - ue->dlsch_SI_received[eNB_id] = 0; - ue->dlsch_ra_received[eNB_id] = 0; - ue->dlsch_p_received[eNB_id] = 0; - ue->dlsch_SI_errors[eNB_id] = 0; - ue->dlsch_ra_errors[eNB_id] = 0; - ue->dlsch_p_errors[eNB_id] = 0; - - ue->dlsch_mch_received[eNB_id] = 0; - - for (i=0; i < MAX_MBSFN_AREA ; i ++) { - ue->dlsch_mch_received_sf[i][eNB_id] = 0; - ue->dlsch_mcch_received[i][eNB_id] = 0; - ue->dlsch_mtch_received[i][eNB_id] = 0; - ue->dlsch_mcch_errors[i][eNB_id] = 0; - ue->dlsch_mtch_errors[i][eNB_id] = 0; - ue->dlsch_mcch_trials[i][eNB_id] = 0; - ue->dlsch_mtch_trials[i][eNB_id] = 0; - } - - //ue->total_TBS[eNB_id] = 0; - //ue->total_TBS_last[eNB_id] = 0; - //ue->bitrate[eNB_id] = 0; - //ue->total_received_bits[eNB_id] = 0; -} -#endif //(0) - void nr_ue_pbch_procedures(uint8_t gNB_id, PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, @@ -2684,185 +700,6 @@ int nr_ue_pdcch_procedures(uint8_t gNB_id, } #endif // NR_PDCCH_SCHED - - - -#if 0 - - if (generate_ue_dlsch_params_from_dci(frame_rx, - nr_tti_rx, - (DCI1A_5MHz_TDD_1_6_t *)&dci_alloc_rx[i].dci_pdu, - ue->prach_resources[eNB_id]->ra_RNTI, - format1A, - ue->pdcch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id], - ue->pdsch_vars_ra[eNB_id], - &ue->dlsch_ra[eNB_id], - &ue->frame_parms, - ue->pdsch_config_dedicated, - SI_RNTI, - ue->prach_resources[eNB_id]->ra_RNTI, - P_RNTI, - ue->transmission_mode[eNB_id]<7?0:ue->transmission_mode[eNB_id], - 0)==0) { - - ue->dlsch_ra_received[eNB_id]++; - - #ifdef DEBUG_PHY_PROC - LOG_D(PHY,"[UE %d] Generate UE DLSCH RA_RNTI format 1A, rb_alloc %x, dlsch_ra[eNB_id] %p\n", - ue->Mod_id,ue->dlsch_ra[eNB_id]->harq_processes[0]->rb_alloc_even[0],ue->dlsch_ra[eNB_id]); - #endif - } - } else if( (dci_alloc_rx[i].rnti == ue->pdcch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id]->crnti) && - (dci_alloc_rx[i].format == format0)) { - - #ifdef DEBUG_PHY_PROC - LOG_D(PHY,"[UE %d][PUSCH] Frame %d nr_tti_rx %d: Found rnti %x, format 0, dci_cnt %d\n", - ue->Mod_id,frame_rx,nr_tti_rx,dci_alloc_rx[i].rnti,i); - #endif - - ue->ulsch_no_allocation_counter[eNB_id] = 0; - //dump_dci(&ue->frame_parms,&dci_alloc_rx[i]); - - if ((ue->UE_mode[eNB_id] > PRACH) && - (generate_ue_ulsch_params_from_dci((void *)&dci_alloc_rx[i].dci_pdu, - ue->pdcch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id]->crnti, - nr_tti_rx, - format0, - ue, - proc, - SI_RNTI, - 0, - P_RNTI, - CBA_RNTI, - eNB_id, - 0)==0)) { - #if T_TRACER - NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; - uint8_t harq_pid = subframe2harq_pid(frame_parms, - pdcch_alloc2ul_frame(frame_parms,proc->frame_rx,proc->nr_tti_rx), - pdcch_alloc2ul_subframe(frame_parms,proc->nr_tti_rx)); - - T(T_UE_PHY_ULSCH_UE_DCI, T_INT(eNB_id), T_INT(proc->frame_rx%1024), T_INT(proc->nr_tti_rx), T_INT(ue->Mod_id), - T_INT(dci_alloc_rx[i].rnti), T_INT(harq_pid), - T_INT(ue->ulsch[eNB_id]->harq_processes[harq_pid]->mcs), - T_INT(ue->ulsch[eNB_id]->harq_processes[harq_pid]->round), - T_INT(ue->ulsch[eNB_id]->harq_processes[harq_pid]->first_rb), - T_INT(ue->ulsch[eNB_id]->harq_processes[harq_pid]->nb_rb), - T_INT(ue->ulsch[eNB_id]->harq_processes[harq_pid]->TBS)); - #endif - #ifdef DEBUG_PHY_PROC - LOG_D(PHY,"[UE %d] Generate UE ULSCH C_RNTI format 0 (nr_tti_rx %d)\n",ue->Mod_id,nr_tti_rx); - #endif - - } - } else if( (dci_alloc_rx[i].rnti == ue->ulsch[eNB_id]->cba_rnti[0]) && - (dci_alloc_rx[i].format == format0)) { - // UE could belong to more than one CBA group - // ue->Mod_id%ue->ulsch[eNB_id]->num_active_cba_groups] - #ifdef DEBUG_PHY_PROC - LOG_D(PHY,"[UE %d][PUSCH] Frame %d nr_tti_rx %d: Found cba rnti %x, format 0, dci_cnt %d\n", - ue->Mod_id,frame_rx,nr_tti_rx,dci_alloc_rx[i].rnti,i); - - if (((frame_rx%100) == 0) || (frame_rx < 20)) - dump_dci(&ue->frame_parms, &dci_alloc_rx[i]); - - #endif - - ue->ulsch_no_allocation_counter[eNB_id] = 0; - //dump_dci(&ue->frame_parms,&dci_alloc_rx[i]); - - if ((ue->UE_mode[eNB_id] > PRACH) && - (generate_ue_ulsch_params_from_dci((void *)&dci_alloc_rx[i].dci_pdu, - ue->ulsch[eNB_id]->cba_rnti[0], - nr_tti_rx, - format0, - ue, - proc, - SI_RNTI, - 0, - P_RNTI, - CBA_RNTI, - eNB_id, - 0)==0)) { - - #ifdef DEBUG_PHY_PROC - LOG_D(PHY,"[UE %d] Generate UE ULSCH CBA_RNTI format 0 (nr_tti_rx %d)\n",ue->Mod_id,nr_tti_rx); - #endif - ue->ulsch[eNB_id]->num_cba_dci[(nr_tti_rx+4)%10]++; - } - } - - else { - #ifdef DEBUG_PHY_PROC - LOG_D(PHY,"[UE %d] frame %d, nr_tti_rx %d: received DCI %d with RNTI=%x (C-RNTI:%x, CBA_RNTI %x) and format %d!\n",ue->Mod_id,frame_rx,nr_tti_rx,i,dci_alloc_rx[i].rnti, - ue->pdcch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id]->crnti, - ue->ulsch[eNB_id]->cba_rnti[0], - dci_alloc_rx[i].format); - - // dump_dci(&ue->frame_parms, &dci_alloc_rx[i]); - #endif - }*/ - - } // end for loop dci_cnt -#if UE_TIMING_TRACE - stop_meas(&ue->dlsch_rx_pdcch_stats); -#endif - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_PDCCH_PROCEDURES, VCD_FUNCTION_OUT); - - // } // end if do_pdcch_monitoring_current_slot - } // end for loop nb_searchspace_active - return(0); -} - - - -#endif - - -#if 0 -void copy_harq_proc_struct(NR_DL_UE_HARQ_t *harq_processes_dest, NR_DL_UE_HARQ_t *current_harq_processes) -{ - - harq_processes_dest->B = current_harq_processes->B ; - harq_processes_dest->C = current_harq_processes->C ; - harq_processes_dest->DCINdi = current_harq_processes->DCINdi ; - harq_processes_dest->F = current_harq_processes->F ; - harq_processes_dest->G = current_harq_processes->G ; - harq_processes_dest->K = current_harq_processes->K ; - harq_processes_dest->Nl = current_harq_processes->Nl ; - harq_processes_dest->Qm = current_harq_processes->Qm ; - harq_processes_dest->TBS = current_harq_processes->TBS ; - harq_processes_dest->b = current_harq_processes->b ; - harq_processes_dest->codeword = current_harq_processes->codeword ; - harq_processes_dest->delta_PUCCH = current_harq_processes->delta_PUCCH ; - harq_processes_dest->dl_power_off = current_harq_processes->dl_power_off ; - harq_processes_dest->first_tx = current_harq_processes->first_tx ; - harq_processes_dest->mcs = current_harq_processes->mcs ; - harq_processes_dest->mcs_table = current_harq_processes->mcs_table ; - harq_processes_dest->mimo_mode = current_harq_processes->mimo_mode ; - harq_processes_dest->nb_rb = current_harq_processes->nb_rb ; - harq_processes_dest->pmi_alloc = current_harq_processes->pmi_alloc ; - harq_processes_dest->rb_alloc_even[0] = current_harq_processes->rb_alloc_even[0] ; - harq_processes_dest->rb_alloc_even[1] = current_harq_processes->rb_alloc_even[1] ; - harq_processes_dest->rb_alloc_even[2] = current_harq_processes->rb_alloc_even[2] ; - harq_processes_dest->rb_alloc_even[3] = current_harq_processes->rb_alloc_even[3] ; - harq_processes_dest->rb_alloc_odd[0] = current_harq_processes->rb_alloc_odd[0] ; - harq_processes_dest->rb_alloc_odd[1] = current_harq_processes->rb_alloc_odd[1] ; - harq_processes_dest->rb_alloc_odd[2] = current_harq_processes->rb_alloc_odd[2] ; - harq_processes_dest->rb_alloc_odd[3] = current_harq_processes->rb_alloc_odd[3] ; - harq_processes_dest->round = current_harq_processes->round ; - harq_processes_dest->rvidx = current_harq_processes->rvidx ; - harq_processes_dest->status = current_harq_processes->status ; - harq_processes_dest->vrb_type = current_harq_processes->vrb_type ; - -} -#endif - -/*void copy_ack_struct(nr_harq_status_t *harq_ack_dest, nr_harq_status_t *current_harq_ack) - { - memcpy(harq_ack_dest, current_harq_ack, sizeof(nr_harq_status_t)); - }*/ - void nr_ue_pdsch_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, int eNB_id, PDSCH_t pdsch, NR_UE_DLSCH_t *dlsch0, NR_UE_DLSCH_t *dlsch1) { int nr_tti_rx = proc->nr_tti_rx; diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c index e63f93b028..bfcfe88d62 100644 --- a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c +++ b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c @@ -276,8 +276,6 @@ int nr_ue_dcireq(nr_dcireq_t *dcireq) { dl_config->slot=UE_mac->dl_config_request.slot; dl_config->number_pdus=0; - //printf(" UE_mac->dl_config_request.slot %d VS dcireq->slot %d \n", UE_mac->dl_config_request.slot, dcireq->slot); - LOG_D(PHY, "Entering UE DCI configuration frame %d slot %d \n", dcireq->frame, dcireq->slot); ue_dci_configuration(UE_mac, dl_config, dcireq->frame, dcireq->slot); From 28eb83553323f08809d1e9e5d845d4af5e0714b0 Mon Sep 17 00:00:00 2001 From: cig Date: Mon, 31 Aug 2020 10:07:57 +0200 Subject: [PATCH 13/96] Enter ULSCH procedures for Msg3 transmission --- openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index 7ded09dabf..3d2b726a8a 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -191,7 +191,7 @@ void phy_procedures_nrUE_TX(PHY_VARS_NR_UE *ue, start_meas(&ue->phy_proc_tx); #endif - if (ue->UE_mode[gNB_id] == PUSCH || get_softmodem_params()->phy_test == 1){ + if (ue->UE_mode[gNB_id] <= PUSCH || get_softmodem_params()->phy_test == 1){ if (ue->ulsch[thread_id][gNB_id][0]->harq_processes[harq_pid]->status == ACTIVE) nr_ue_ulsch_procedures(ue, harq_pid, frame_tx, slot_tx, thread_id, gNB_id); From 539bc784b48b944c9945863173e4d2401b48fefa Mon Sep 17 00:00:00 2001 From: cig Date: Sat, 25 Jul 2020 11:40:31 +0200 Subject: [PATCH 14/96] Changes to number of PDUs logic @ UE - calling nr_ue_scheduled_response after pdu preparation - increasing the number_pdus before response scheduling - resetting after dl/ul config pdu handling --- openair1/SCHED_NR_UE/fapi_nr_ue_l1.c | 5 ++-- .../NR_MAC_UE/nr_ue_dci_configuration.c | 2 +- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 15 ++++++----- openair2/LAYER2/NR_MAC_UE/rar_tools_nrUE.c | 5 ++-- openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c | 26 +++++++------------ 5 files changed, 23 insertions(+), 30 deletions(-) diff --git a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c index ea73f2fecc..c3ccfcc829 100644 --- a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c +++ b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c @@ -120,6 +120,7 @@ int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response){ } } } + dl_config->number_pdus = 0; } else { pdcch_vars->nb_search_space = 0; } @@ -232,11 +233,9 @@ int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response){ break; } } - } else { + ul_config->number_pdus = 0; } - } - return 0; } diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c index 2285fc5999..a262f5b54c 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c @@ -177,7 +177,7 @@ void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t #endif // add DCI dl_config->dl_config_list[dl_config->number_pdus].pdu_type = FAPI_NR_DL_CONFIG_TYPE_DCI; - dl_config->number_pdus = dl_config->number_pdus + 1; + dl_config->number_pdus += 1; } void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl_config, frame_t frame, int slot) { diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index 0205b4e3f1..a70b74b5c7 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -728,9 +728,9 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in dcireq.cc_id = cc_id; dcireq.frame = rx_frame; dcireq.slot = rx_slot; + dcireq.dl_config_req.number_pdus = 0; nr_ue_dcireq(&dcireq); //to be replaced with function pointer later - // we should have received a DL DCI here, so configure DL accordingly scheduled_response.dl_config = &dcireq.dl_config_req; scheduled_response.ul_config = NULL; scheduled_response.tx_request = NULL; @@ -939,12 +939,13 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in nr_scheduled_response_t scheduled_response; scheduled_response.ul_config = &mac->ul_config_request; scheduled_response.dl_config = NULL; - scheduled_response.ul_config->number_pdus++; //TBR fix - fapi_nr_ul_config_request_pdu_t *ul_config_list = &scheduled_response.ul_config->ul_config_list[scheduled_response.ul_config->number_pdus - 1]; + scheduled_response.ul_config->number_pdus++; + uint8_t pdu_index = scheduled_response.ul_config->number_pdus - 1; + fapi_nr_ul_config_request_pdu_t *ul_config_list = &scheduled_response.ul_config->ul_config_list[pdu_index]; fapi_nr_tx_request_t tx_req; fapi_nr_tx_request_body_t tx_req_body; - uint16_t TBS_bytes = scheduled_response.ul_config->ul_config_list[scheduled_response.ul_config->number_pdus - 1].pusch_config_pdu.pusch_data.tb_size; + uint16_t TBS_bytes = scheduled_response.ul_config->ul_config_list[pdu_index].pusch_config_pdu.pusch_data.tb_size; //if (IS_SOFTMODEM_NOS1){ // // Getting IP traffic to be transmitted @@ -962,7 +963,7 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in //if (!IS_SOFTMODEM_NOS1 || !data_existing) { //Use zeros for the header bytes in noS1 mode, in order to make sure that the LCID is not valid //and block this traffic from being forwarded to the upper layers at the gNB - printf("[DEBUG_MSG3] Random data to be tranmsitted (TBS_bytes %d, pdu_index %d ul_config (%p) list (%p): \n", TBS_bytes, scheduled_response.ul_config->number_pdus - 1, scheduled_response.ul_config, ul_config_list); + printf("[DEBUG_MSG3] Random data to be tranmsitted (TBS_bytes %d, pdu_index %d ul_config (%p) list (%p): \n", TBS_bytes, pdu_index, scheduled_response.ul_config, ul_config_list); //Give the first byte a dummy value (a value not corresponding to any valid LCID based on 38.321, Table 6.2.1-2) //in order to distinguish the PHY random packets at the MAC layer of the gNB receiver from the normal packets that should //have a valid LCID (nr_process_mac_pdu function) @@ -984,7 +985,7 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in tx_req.sfn = ul_info->frame_tx; tx_req.number_of_pdus = 1; tx_req_body.pdu_length = TBS_bytes; - tx_req_body.pdu_index = 0; + tx_req_body.pdu_index = pdu_index; tx_req_body.pdu = ulsch_input_buffer; ul_config_list->pdu_type = FAPI_NR_UL_CONFIG_TYPE_PUSCH; scheduled_response.tx_request = &tx_req; @@ -1195,6 +1196,8 @@ void nr_ue_prach_scheduler(module_id_t module_idP, frame_t frameP, sub_frame_t s mac->generate_nr_prach = 2; } mac->scheduled_response.ul_config = ul_config; + if (mac->ul_config_request.number_pdus > 0) + mac->if_module->scheduled_response(&mac->scheduled_response); } } diff --git a/openair2/LAYER2/NR_MAC_UE/rar_tools_nrUE.c b/openair2/LAYER2/NR_MAC_UE/rar_tools_nrUE.c index d291e74e45..a4633d314c 100644 --- a/openair2/LAYER2/NR_MAC_UE/rar_tools_nrUE.c +++ b/openair2/LAYER2/NR_MAC_UE/rar_tools_nrUE.c @@ -76,14 +76,13 @@ void nr_config_Msg3_pdu(NR_UE_MAC_INST_t *mac, int f_alloc, mask, StartSymbolIndex, NrOfSymbols; uint16_t TBS_bytes; fapi_nr_ul_config_request_t *ul_config = &mac->ul_config_request; - ul_config->number_pdus++; - nfapi_nr_ue_pusch_pdu_t *pusch_config_pdu = &ul_config->ul_config_list[ul_config->number_pdus - 1].pusch_config_pdu; + nfapi_nr_ue_pusch_pdu_t *pusch_config_pdu = &ul_config->ul_config_list[ul_config->number_pdus].pusch_config_pdu; NR_ServingCellConfigCommon_t *scc = mac->scc; NR_BWP_Uplink_t *ubwp = mac->ULbwp[0]; int startSymbolAndLength = ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[Msg3_t_alloc]->startSymbolAndLength; #ifdef DEBUG_MSG3 - printf("[DEBUG_MSG3] Configuring Msg3 PDU of %d UL pdus \n", ul_config->number_pdus); + printf("[DEBUG_MSG3] Configuring 1 Msg3 PDU of %d UL pdus \n", ul_config->number_pdus); #endif // active BWP start diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c index bfcfe88d62..def7325fa7 100644 --- a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c +++ b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c @@ -107,17 +107,13 @@ int nr_ue_ul_indication(nr_uplink_indication_t *ul_info){ module_id_t module_id = ul_info->module_id; NR_UE_MAC_INST_t *mac = get_mac_inst(module_id); - // clean previous FAPI messages - mac->tx_request.number_of_pdus = 0; - mac->ul_config_request.number_pdus = 0; - mac->dl_config_request.number_pdus = 0; - // clean previous FAPI messages - ret = nr_ue_scheduler(NULL, ul_info); - if (is_nr_UL_slot(mac->scc, ul_info->slot_tx) && get_softmodem_params()->do_ra){ + // clean previous FAPI messages + mac->tx_request.number_of_pdus = 0; + + if (is_nr_UL_slot(mac->scc, ul_info->slot_tx) && get_softmodem_params()->do_ra) nr_ue_prach_scheduler(module_id, ul_info->frame_tx, ul_info->slot_tx); - } switch(ret){ case UE_CONNECTION_OK: @@ -132,8 +128,6 @@ int nr_ue_ul_indication(nr_uplink_indication_t *ul_info){ break; } - mac->if_module->scheduled_response(&mac->scheduled_response); - return 0; } @@ -146,13 +140,13 @@ int nr_ue_dl_indication(nr_downlink_indication_t *dl_info, NR_UL_TIME_ALIGNMENT_ fapi_nr_dl_config_request_t *dl_config = &mac->dl_config_request; fapi_nr_ul_config_request_t *ul_config = &mac->ul_config_request; + LOG_D(PHY,"DEBUG dl_config %d DL pdus\n",dl_config->number_pdus); + if (!dl_info->dci_ind && !dl_info->rx_ind) { // UL indication to schedule DCI reception nr_ue_scheduler(dl_info, NULL); } else { // UL indication after reception of DCI or DL PDU - dl_config->number_pdus = 0; - ul_config->number_pdus = 0; //hook up pointers mac->scheduled_response.dl_config = dl_config; mac->scheduled_response.ul_config = ul_config; @@ -269,12 +263,10 @@ int nr_ue_if_module_kill(uint32_t module_id) { int nr_ue_dcireq(nr_dcireq_t *dcireq) { - fapi_nr_dl_config_request_t *dl_config=&dcireq->dl_config_req; + fapi_nr_dl_config_request_t *dl_config = &dcireq->dl_config_req; NR_UE_MAC_INST_t *UE_mac = get_mac_inst(0); - - dl_config->sfn=UE_mac->dl_config_request.sfn; - dl_config->slot=UE_mac->dl_config_request.slot; - dl_config->number_pdus=0; + dl_config->sfn = UE_mac->dl_config_request.sfn; + dl_config->slot = UE_mac->dl_config_request.slot; LOG_D(PHY, "Entering UE DCI configuration frame %d slot %d \n", dcireq->frame, dcireq->slot); From ab4f9de25c8e9b98ad3b05f0689459182fcb6465 Mon Sep 17 00:00:00 2001 From: cig Date: Wed, 2 Sep 2020 10:10:41 +0200 Subject: [PATCH 15/96] Code cleanup UE --- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 2 +- openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index a70b74b5c7..d1593604bd 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -963,7 +963,7 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in //if (!IS_SOFTMODEM_NOS1 || !data_existing) { //Use zeros for the header bytes in noS1 mode, in order to make sure that the LCID is not valid //and block this traffic from being forwarded to the upper layers at the gNB - printf("[DEBUG_MSG3] Random data to be tranmsitted (TBS_bytes %d, pdu_index %d ul_config (%p) list (%p): \n", TBS_bytes, pdu_index, scheduled_response.ul_config, ul_config_list); + LOG_D(MAC, "Random data to be tranmsitted (TBS_bytes %d): \n", TBS_bytes); //Give the first byte a dummy value (a value not corresponding to any valid LCID based on 38.321, Table 6.2.1-2) //in order to distinguish the PHY random packets at the MAC layer of the gNB receiver from the normal packets that should //have a valid LCID (nr_process_mac_pdu function) diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c index def7325fa7..bb412752b6 100644 --- a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c +++ b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c @@ -257,12 +257,12 @@ int nr_ue_if_module_kill(uint32_t module_id) { if (nr_ue_if_module_inst[module_id] != NULL){ free(nr_ue_if_module_inst[module_id]); - } + } return 0; } int nr_ue_dcireq(nr_dcireq_t *dcireq) { - + fapi_nr_dl_config_request_t *dl_config = &dcireq->dl_config_req; NR_UE_MAC_INST_t *UE_mac = get_mac_inst(0); dl_config->sfn = UE_mac->dl_config_request.sfn; From 8694e5ee8073adffd6b2db5a52186c446685e865 Mon Sep 17 00:00:00 2001 From: cig Date: Wed, 2 Sep 2020 10:52:13 +0200 Subject: [PATCH 16/96] Removed tx_request from the NR_UE_MAC_INST struct - tx_request is filled in the nr_scheduled_response upon the presence tx data --- openair1/SCHED_NR_UE/fapi_nr_ue_l1.c | 4 +++- openair2/LAYER2/NR_MAC_UE/mac_defs.h | 1 - openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c | 4 ---- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c index c3ccfcc829..ea97767574 100644 --- a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c +++ b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c @@ -159,13 +159,15 @@ int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response){ ulsch0->f_pusch = pusch_config_pdu->absolute_delta_PUSCH; - if (scheduled_response->tx_request){ + if (scheduled_response->tx_request){ // TBR todo here it should loop through the number of tx pdus fapi_nr_tx_request_body_t *tx_req_body = scheduled_response->tx_request->tx_request_body; //harq_process_ul_ue->a = (unsigned char*)calloc(TBS/8, sizeof(unsigned char)); memcpy(harq_process_ul_ue->a, tx_req_body->pdu, tx_req_body->pdu_length); harq_process_ul_ue->status = ACTIVE; + + scheduled_response->tx_request->number_of_pdus = 0; } } else { diff --git a/openair2/LAYER2/NR_MAC_UE/mac_defs.h b/openair2/LAYER2/NR_MAC_UE/mac_defs.h index 9b1b2835ce..cc9e8a0ae4 100755 --- a/openair2/LAYER2/NR_MAC_UE/mac_defs.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_defs.h @@ -247,7 +247,6 @@ typedef struct { uint8_t generate_nr_prach; //// FAPI-like interface message - fapi_nr_tx_request_t tx_request; fapi_nr_ul_config_request_t ul_config_request; fapi_nr_dl_config_request_t dl_config_request; diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c index bb412752b6..789650c97a 100644 --- a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c +++ b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c @@ -109,9 +109,6 @@ int nr_ue_ul_indication(nr_uplink_indication_t *ul_info){ ret = nr_ue_scheduler(NULL, ul_info); - // clean previous FAPI messages - mac->tx_request.number_of_pdus = 0; - if (is_nr_UL_slot(mac->scc, ul_info->slot_tx) && get_softmodem_params()->do_ra) nr_ue_prach_scheduler(module_id, ul_info->frame_tx, ul_info->slot_tx); @@ -150,7 +147,6 @@ int nr_ue_dl_indication(nr_downlink_indication_t *dl_info, NR_UL_TIME_ALIGNMENT_ //hook up pointers mac->scheduled_response.dl_config = dl_config; mac->scheduled_response.ul_config = ul_config; - mac->scheduled_response.tx_request = &mac->tx_request; mac->scheduled_response.module_id = dl_info->module_id; mac->scheduled_response.CC_id = dl_info->cc_id; mac->scheduled_response.frame = dl_info->frame; From 1f684f79c1eb1bb2cc8e40b1eed4322118c7b91c Mon Sep 17 00:00:00 2001 From: cig Date: Wed, 2 Sep 2020 15:36:09 +0200 Subject: [PATCH 17/96] Introduced a function to fill the scheduled_response - redundant code for the configuration of the scheduled_response was removed - scheduled response is not needed to be stored in the NR_UE_MAC_INST struct as it passed to the function right away --- openair2/LAYER2/NR_MAC_UE/mac_defs.h | 1 - openair2/LAYER2/NR_MAC_UE/mac_proto.h | 18 +++ openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 122 ++++++++++--------- openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c | 18 +-- 4 files changed, 86 insertions(+), 73 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_UE/mac_defs.h b/openair2/LAYER2/NR_MAC_UE/mac_defs.h index cc9e8a0ae4..97c99b6050 100755 --- a/openair2/LAYER2/NR_MAC_UE/mac_defs.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_defs.h @@ -252,7 +252,6 @@ typedef struct { /// Interface module instances nr_ue_if_module_t *if_module; - nr_scheduled_response_t scheduled_response; nr_phy_config_t phy_config; /// BSR report flag management diff --git a/openair2/LAYER2/NR_MAC_UE/mac_proto.h b/openair2/LAYER2/NR_MAC_UE/mac_proto.h index 4716c1b49d..0b34c86aa8 100755 --- a/openair2/LAYER2/NR_MAC_UE/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_proto.h @@ -88,6 +88,24 @@ NR_UE_MAC_INST_t *get_mac_inst( \param ul_info UL indication*/ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_indication_t *ul_info); +/**\brief fill nr_scheduled_response struct instance + @param nr_scheduled_response_t * pointer to scheduled_response instance to fill + @param fapi_nr_dl_config_request_t* pointer to dl_config, + @param fapi_nr_ul_config_request_t* pointer to ul_config, + @param fapi_nr_tx_request_t* pointer to tx_request; + @param module_id_t mod_id module ID + @param int cc_id CC ID + @param frame_t frame frame number + @param int slot reference number */ +void fill_scheduled_response(nr_scheduled_response_t *scheduled_response, + fapi_nr_dl_config_request_t *dl_config, + fapi_nr_ul_config_request_t *ul_config, + fapi_nr_tx_request_t *tx_request, + module_id_t mod_id, + int cc_id, + frame_t frame, + int slot); + /* \brief Get SR payload (0,1) from UE MAC @param Mod_id Instance id of UE in machine @param CC_id Component Carrier index diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index d1593604bd..860de5248d 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -91,6 +91,24 @@ extern void mac_rlc_data_ind ( num_tb_t num_tbP, crc_t *crcs_pP); +void fill_scheduled_response(nr_scheduled_response_t *scheduled_response, + fapi_nr_dl_config_request_t *dl_config, + fapi_nr_ul_config_request_t *ul_config, + fapi_nr_tx_request_t *tx_request, + module_id_t mod_id, + int cc_id, + frame_t frame, + int slot){ + + scheduled_response->dl_config = dl_config; + scheduled_response->ul_config = ul_config; + scheduled_response->tx_request = tx_request; + scheduled_response->module_id = mod_id; + scheduled_response->CC_id = cc_id; + scheduled_response->frame = frame; + scheduled_response->slot = slot; + +} uint32_t get_ssb_slot(uint32_t ssb_index){ // this function now only support f <= 3GHz @@ -118,7 +136,7 @@ uint8_t table_9_2_2_1[16][8]={ {1,0, 14,26,0,3,0,0} }; - +#if 0 // Not in use. In case of use, please adapt the schedule_response (no longer in MAC) int8_t nr_ue_process_dlsch(module_id_t module_id, int cc_id, uint8_t gNB_index, @@ -252,6 +270,7 @@ int8_t nr_ue_process_dlsch(module_id_t module_id, } return 0; } +#endif int8_t nr_ue_decode_mib(module_id_t module_id, int cc_id, @@ -719,7 +738,10 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in dl_config->dl_config_list[dl_config->number_pdus].dci_config_pdu.dci_config_rel15.N_RB_BWP); */ dl_config->number_pdus = dl_config->number_pdus + 1; - mac->scheduled_response.dl_config = dl_config; + + fill_scheduled_response(&scheduled_response, dl_config, NULL, NULL, mod_id, cc_id, rx_frame, rx_slot); + if(mac->if_module != NULL && mac->if_module->scheduled_response != NULL) + mac->if_module->scheduled_response(&scheduled_response); } } else { // we have an scg @@ -731,14 +753,7 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in dcireq.dl_config_req.number_pdus = 0; nr_ue_dcireq(&dcireq); //to be replaced with function pointer later - scheduled_response.dl_config = &dcireq.dl_config_req; - scheduled_response.ul_config = NULL; - scheduled_response.tx_request = NULL; - scheduled_response.module_id = mod_id; - scheduled_response.CC_id = cc_id; - scheduled_response.frame = rx_frame; - scheduled_response.slot = rx_slot; - + fill_scheduled_response(&scheduled_response, &dcireq.dl_config_req, NULL, NULL, mod_id, cc_id, rx_frame, rx_slot); if(mac->if_module != NULL && mac->if_module->scheduled_response != NULL){ mac->if_module->scheduled_response(&scheduled_response); } @@ -783,6 +798,7 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in nr_scheduled_response_t scheduled_response; fapi_nr_tx_request_t tx_req; fapi_nr_tx_request_body_t tx_req_body; + fapi_nr_ul_config_request_t *ul_config = &dcireq.ul_config_req; //--------------------------Temporary configuration-----------------------------// uint16_t rnti = 0x1234; @@ -876,8 +892,6 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in dcireq.frame = rx_frame; dcireq.slot = rx_slot; - scheduled_response.dl_config = NULL; - scheduled_response.ul_config = &dcireq.ul_config_req; // Config UL TX PDU tx_req.slot = slot_tx; tx_req.sfn = frame_tx; @@ -886,40 +900,35 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in tx_req_body.pdu_length = TBS_bytes; tx_req_body.pdu_index = 0; tx_req_body.pdu = ulsch_input_buffer; + tx_req.tx_request_body = &tx_req_body; - scheduled_response.tx_request = &tx_req; - scheduled_response.tx_request->tx_request_body = &tx_req_body; - scheduled_response.module_id = mod_id; - scheduled_response.CC_id = cc_id; - scheduled_response.frame = rx_frame; - scheduled_response.slot = rx_slot; - - scheduled_response.ul_config->slot = ul_info->slot_tx; - scheduled_response.ul_config->ul_config_list[0].pdu_type = FAPI_NR_UL_CONFIG_TYPE_PUSCH; - scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.rnti = rnti; - scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.rb_size = rb_size; - scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.rb_start = rb_start; - scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.nr_of_symbols = nr_of_symbols; - scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.start_symbol_index = start_symbol_index; - scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.ul_dmrs_symb_pos = ul_dmrs_symb_pos; - scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.dmrs_config_type = dmrs_config_type; - scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.mcs_index = mcs_index; - scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.mcs_table = mcs_table; - scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.num_dmrs_cdm_grps_no_data = 1; - scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.pusch_data.new_data_indicator = 0; - scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.pusch_data.rv_index = rv_index; - scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.nrOfLayers = nrOfLayers; - scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.pusch_data.harq_process_id = harq_process_id; - scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.pdu_bit_map = pdu_bit_map; - scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.pusch_ptrs.ptrs_time_density = ptrs_time_density; - scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.pusch_ptrs.ptrs_freq_density = ptrs_freq_density; - scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.pusch_ptrs.ptrs_ports_list = (nfapi_nr_ue_ptrs_ports_t *) malloc(2*sizeof(nfapi_nr_ue_ptrs_ports_t)); - scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.pusch_ptrs.ptrs_ports_list[0].ptrs_re_offset = 0; + ul_config->slot = ul_info->slot_tx; + ul_config->ul_config_list[0].pdu_type = FAPI_NR_UL_CONFIG_TYPE_PUSCH; + ul_config->ul_config_list[0].pusch_config_pdu.rnti = rnti; + ul_config->ul_config_list[0].pusch_config_pdu.rb_size = rb_size; + ul_config->ul_config_list[0].pusch_config_pdu.rb_start = rb_start; + ul_config->ul_config_list[0].pusch_config_pdu.nr_of_symbols = nr_of_symbols; + ul_config->ul_config_list[0].pusch_config_pdu.start_symbol_index = start_symbol_index; + ul_config->ul_config_list[0].pusch_config_pdu.ul_dmrs_symb_pos = ul_dmrs_symb_pos; + ul_config->ul_config_list[0].pusch_config_pdu.dmrs_config_type = dmrs_config_type; + ul_config->ul_config_list[0].pusch_config_pdu.mcs_index = mcs_index; + ul_config->ul_config_list[0].pusch_config_pdu.mcs_table = mcs_table; + ul_config->ul_config_list[0].pusch_config_pdu.num_dmrs_cdm_grps_no_data = 1; + ul_config->ul_config_list[0].pusch_config_pdu.pusch_data.new_data_indicator = 0; + ul_config->ul_config_list[0].pusch_config_pdu.pusch_data.rv_index = rv_index; + ul_config->ul_config_list[0].pusch_config_pdu.nrOfLayers = nrOfLayers; + ul_config->ul_config_list[0].pusch_config_pdu.pusch_data.harq_process_id = harq_process_id; + ul_config->ul_config_list[0].pusch_config_pdu.pdu_bit_map = pdu_bit_map; + ul_config->ul_config_list[0].pusch_config_pdu.pusch_ptrs.ptrs_time_density = ptrs_time_density; + ul_config->ul_config_list[0].pusch_config_pdu.pusch_ptrs.ptrs_freq_density = ptrs_freq_density; + ul_config->ul_config_list[0].pusch_config_pdu.pusch_ptrs.ptrs_ports_list = (nfapi_nr_ue_ptrs_ports_t *) malloc(2*sizeof(nfapi_nr_ue_ptrs_ports_t)); // TBR fix this! + ul_config->ul_config_list[0].pusch_config_pdu.pusch_ptrs.ptrs_ports_list[0].ptrs_re_offset = 0; if (1 << ptrs_time_density >= nr_of_symbols) { - scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.pdu_bit_map &= ~PUSCH_PDU_BITMAP_PUSCH_PTRS; // disable PUSCH PTRS + ul_config->ul_config_list[0].pusch_config_pdu.pdu_bit_map &= ~PUSCH_PDU_BITMAP_PUSCH_PTRS; // disable PUSCH PTRS } + fill_scheduled_response(&scheduled_response, NULL, ul_config, &tx_req, mod_id, cc_id, rx_frame, rx_slot); if(mac->if_module != NULL && mac->if_module->scheduled_response != NULL){ mac->if_module->scheduled_response(&scheduled_response); } @@ -937,15 +946,11 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in uint8_t ulsch_input_buffer[MAX_ULSCH_PAYLOAD_BYTES]; nr_scheduled_response_t scheduled_response; - scheduled_response.ul_config = &mac->ul_config_request; - scheduled_response.dl_config = NULL; - scheduled_response.ul_config->number_pdus++; - uint8_t pdu_index = scheduled_response.ul_config->number_pdus - 1; - fapi_nr_ul_config_request_pdu_t *ul_config_list = &scheduled_response.ul_config->ul_config_list[pdu_index]; fapi_nr_tx_request_t tx_req; fapi_nr_tx_request_body_t tx_req_body; - - uint16_t TBS_bytes = scheduled_response.ul_config->ul_config_list[pdu_index].pusch_config_pdu.pusch_data.tb_size; + fapi_nr_ul_config_request_t *ul_config = &mac->ul_config_request; + fapi_nr_ul_config_request_pdu_t *ul_config_list = &ul_config->ul_config_list[ul_config->number_pdus]; + uint16_t TBS_bytes = ul_config_list->pusch_config_pdu.pusch_data.tb_size; //if (IS_SOFTMODEM_NOS1){ // // Getting IP traffic to be transmitted @@ -985,16 +990,13 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in tx_req.sfn = ul_info->frame_tx; tx_req.number_of_pdus = 1; tx_req_body.pdu_length = TBS_bytes; - tx_req_body.pdu_index = pdu_index; + tx_req_body.pdu_index = 0; tx_req_body.pdu = ulsch_input_buffer; + tx_req.tx_request_body = &tx_req_body; ul_config_list->pdu_type = FAPI_NR_UL_CONFIG_TYPE_PUSCH; - scheduled_response.tx_request = &tx_req; - scheduled_response.tx_request->tx_request_body = &tx_req_body; - scheduled_response.module_id = ul_info->module_id; - scheduled_response.CC_id = ul_info->cc_id; - scheduled_response.frame = ul_info->frame_rx; - scheduled_response.slot = ul_info->slot_rx; - + ul_config->number_pdus++; + // scheduled_response + fill_scheduled_response(&scheduled_response, NULL, ul_config, &tx_req, ul_info->module_id, ul_info->cc_id, ul_info->frame_rx, ul_info->slot_rx); if(mac->if_module != NULL && mac->if_module->scheduled_response != NULL){ mac->if_module->scheduled_response(&scheduled_response); } @@ -1062,6 +1064,7 @@ void nr_ue_prach_scheduler(module_id_t module_idP, frame_t frameP, sub_frame_t s fapi_nr_ul_config_prach_pdu *prach_config_pdu; fapi_nr_config_request_t *cfg = &mac->phy_config.config_req; fapi_nr_prach_config_t *prach_config = &cfg->prach_config; + nr_scheduled_response_t scheduled_response; NR_ServingCellConfigCommon_t *scc = mac->scc; NR_RACH_ConfigCommon_t *setup = scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup; @@ -1195,9 +1198,10 @@ void nr_ue_prach_scheduler(module_id_t module_idP, frame_t frameP, sub_frame_t s } else if (mac->ra_state == RA_SUCCEEDED){ mac->generate_nr_prach = 2; } - mac->scheduled_response.ul_config = ul_config; - if (mac->ul_config_request.number_pdus > 0) - mac->if_module->scheduled_response(&mac->scheduled_response); + + fill_scheduled_response(&scheduled_response, NULL, ul_config, NULL, module_idP, 0 /*TBR fix*/, frameP, slotP); + if(mac->if_module != NULL && mac->if_module->scheduled_response != NULL) + mac->if_module->scheduled_response(&scheduled_response); } } diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c index 789650c97a..77eb6e813c 100644 --- a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c +++ b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c @@ -137,33 +137,25 @@ int nr_ue_dl_indication(nr_downlink_indication_t *dl_info, NR_UL_TIME_ALIGNMENT_ fapi_nr_dl_config_request_t *dl_config = &mac->dl_config_request; fapi_nr_ul_config_request_t *ul_config = &mac->ul_config_request; - LOG_D(PHY,"DEBUG dl_config %d DL pdus\n",dl_config->number_pdus); - if (!dl_info->dci_ind && !dl_info->rx_ind) { // UL indication to schedule DCI reception nr_ue_scheduler(dl_info, NULL); } else { // UL indication after reception of DCI or DL PDU - //hook up pointers - mac->scheduled_response.dl_config = dl_config; - mac->scheduled_response.ul_config = ul_config; - mac->scheduled_response.module_id = dl_info->module_id; - mac->scheduled_response.CC_id = dl_info->cc_id; - mac->scheduled_response.frame = dl_info->frame; - mac->scheduled_response.slot = dl_info->slot; - if(dl_info->dci_ind != NULL){ LOG_D(MAC,"[L2][IF MODULE][DL INDICATION][DCI_IND]\n"); for(i=0; idci_ind->number_of_dcis; ++i){ LOG_D(MAC,">>>NR_IF_Module i=%d, dl_info->dci_ind->number_of_dcis=%d\n",i,dl_info->dci_ind->number_of_dcis); - + nr_scheduled_response_t scheduled_response; ret_mask |= (handle_dci(dl_info->module_id, dl_info->cc_id, dl_info->gNB_index, dl_info->dci_ind->dci_list+i)<< FAPI_NR_DCI_IND); - AssertFatal( nr_ue_if_module_inst[module_id] != NULL, "IF module is void!\n" ); - nr_ue_if_module_inst[module_id]->scheduled_response(&mac->scheduled_response); + AssertFatal( nr_ue_if_module_inst[module_id] != NULL, "IF module is NULL!\n" ); + AssertFatal( nr_ue_if_module_inst[module_id]->scheduled_response != NULL, "scheduled_response is NULL!\n" ); + fill_scheduled_response(&scheduled_response, dl_config, ul_config, NULL, dl_info->module_id, dl_info->cc_id, dl_info->frame, dl_info->slot); + nr_ue_if_module_inst[module_id]->scheduled_response(&scheduled_response); } } From e81b195917fcd311ea622cb83f636238c6d85a7d Mon Sep 17 00:00:00 2001 From: cig Date: Wed, 2 Sep 2020 17:49:29 +0200 Subject: [PATCH 18/96] Replaced malloc with local variable for ptrs_ports_list --- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index 860de5248d..23328842f2 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -799,6 +799,7 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in fapi_nr_tx_request_t tx_req; fapi_nr_tx_request_body_t tx_req_body; fapi_nr_ul_config_request_t *ul_config = &dcireq.ul_config_req; + nfapi_nr_ue_ptrs_ports_t ptrs_ports_list; //--------------------------Temporary configuration-----------------------------// uint16_t rnti = 0x1234; @@ -825,6 +826,10 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in uint16_t number_dmrs_symbols = 0; uint16_t ul_dmrs_symb_pos = l_prime_mask << start_symbol_index; //------------------------------------------------------------------------------// + // PTRS ports configuration + // TbD: ptrs_dmrs_port and ptrs_port_index are not initialised! + ptrs_ports_list.ptrs_re_offset = 0; + for (i = start_symbol_index; i < start_symbol_index + nr_of_symbols; i++) { if((ul_dmrs_symb_pos >> i) & 0x01) @@ -921,8 +926,7 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in ul_config->ul_config_list[0].pusch_config_pdu.pdu_bit_map = pdu_bit_map; ul_config->ul_config_list[0].pusch_config_pdu.pusch_ptrs.ptrs_time_density = ptrs_time_density; ul_config->ul_config_list[0].pusch_config_pdu.pusch_ptrs.ptrs_freq_density = ptrs_freq_density; - ul_config->ul_config_list[0].pusch_config_pdu.pusch_ptrs.ptrs_ports_list = (nfapi_nr_ue_ptrs_ports_t *) malloc(2*sizeof(nfapi_nr_ue_ptrs_ports_t)); // TBR fix this! - ul_config->ul_config_list[0].pusch_config_pdu.pusch_ptrs.ptrs_ports_list[0].ptrs_re_offset = 0; + ul_config->ul_config_list[0].pusch_config_pdu.pusch_ptrs.ptrs_ports_list = &ptrs_ports_list; if (1 << ptrs_time_density >= nr_of_symbols) { ul_config->ul_config_list[0].pusch_config_pdu.pdu_bit_map &= ~PUSCH_PDU_BITMAP_PUSCH_PTRS; // disable PUSCH PTRS From 88e6fb9d36cc7d8eb7182a18f1b6af7ca410e5e4 Mon Sep 17 00:00:00 2001 From: cig Date: Wed, 2 Sep 2020 18:10:17 +0200 Subject: [PATCH 19/96] Fixed warnings --- openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 50 ++----------------- openair2/LAYER2/NR_MAC_UE/mac_proto.h | 6 +++ .../NR_MAC_UE/nr_ue_dci_configuration.c | 5 +- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 2 +- 4 files changed, 12 insertions(+), 51 deletions(-) diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index 3d2b726a8a..7281aef3f3 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -811,36 +811,12 @@ void nr_ue_pdsch_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, int eNB void nr_process_rar(nr_downlink_indication_t *dl_info) { module_id_t module_id = dl_info->module_id; - int cc_id = dl_info->cc_id, frame_rx = dl_info->proc->frame_rx, nr_tti_rx = dl_info->proc->nr_tti_rx, ta_command, delta; + int cc_id = dl_info->cc_id, frame_rx = dl_info->proc->frame_rx, nr_tti_rx = dl_info->proc->nr_tti_rx, ta_command; uint8_t gNB_index = dl_info->gNB_index; // *rar; - //fapi_nr_dci_indication_t *dci_ind = dl_info->dci_ind; PHY_VARS_NR_UE *ue = PHY_vars_UE_g[module_id][cc_id]; NR_UE_DLSCH_t *dlsch0 = ue->dlsch_ra[gNB_index]; UE_MODE_t UE_mode = ue->UE_mode[gNB_index]; NR_PRACH_RESOURCES_t *prach_resources = ue->prach_resources[gNB_index]; - uint16_t slots_per_frame = ue->frame_parms.slots_per_frame; - - uint8_t mu_pusch = 1, sliv_S, sliv_L; - // definition table j Table 6.1.2.1.1-4 - uint8_t j = (mu_pusch==3)?3:(mu_pusch==2)?2:1; - uint8_t table_6_1_2_1_1_2_time_dom_res_alloc_A[16][3]={ // for PUSCH from TS 38.214 subclause 6.1.2.1.1 - {j, 0,14}, // row index 1 - {j, 0,12}, // row index 2 - {j, 0,10}, // row index 3 - {j, 2,10}, // row index 4 - {j, 4,10}, // row index 5 - {j, 4,8}, // row index 6 - {j, 4,6}, // row index 7 - {j+1,0,14}, // row index 8 - {j+1,0,12}, // row index 9 - {j+1,0,10}, // row index 10 - {j+2,0,14}, // row index 11 - {j+2,0,12}, // row index 12 - {j+2,0,10}, // row index 13 - {j, 8,6}, // row index 14 - {j+3,0,14}, // row index 15 - {j+3,0,10} // row index 16 - }; LOG_D(PHY,"[UE %d][RAPROC] Frame %d subframe %d Received RAR mode %d\n", module_id, frame_rx, nr_tti_rx, UE_mode); @@ -868,29 +844,9 @@ void nr_process_rar(nr_downlink_indication_t *dl_info) { nr_process_timing_advance_rar(ue, dl_info->proc, ta_command); - if (ue->mode != debug_prach) { - - switch (mu_pusch) { - case 0: - delta = 2; - break; - case 1: - delta = 3; - break; - case 2: - delta = 4; - break; - case 3: - delta = 6; - break; - } - - #ifdef DEBUG_RA - LOG_D(PHY,"[UE %d][RAPROC] Msg3 nr_tti_rx %d delta %d\n", ue->Mod_id, nr_tti_rx, delta); - #endif - + if (ue->mode != debug_prach) ue->UE_mode[gNB_index] = RA_RESPONSE; - } + } else { LOG_W(PHY,"[UE %d][RAPROC] Received RAR preamble (%d) doesn't match !!!\n", ue->Mod_id, prach_resources->ra_PreambleIndex); } diff --git a/openair2/LAYER2/NR_MAC_UE/mac_proto.h b/openair2/LAYER2/NR_MAC_UE/mac_proto.h index 0b34c86aa8..6ef7c622a6 100755 --- a/openair2/LAYER2/NR_MAC_UE/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_proto.h @@ -294,5 +294,11 @@ void nr_Msg1_transmitted(module_id_t mod_id, uint8_t CC_id, frame_t frameP, uint void nr_Msg3_transmitted(module_id_t mod_id, uint8_t CC_id, frame_t frameP, uint8_t gNB_id); void nr_ue_msg2_scheduler(module_id_t mod_id, uint16_t rach_frame, uint16_t rach_slot, uint16_t *msg2_frame, uint16_t *msg2_slot); + +int8_t nr_ue_process_dci_freq_dom_resource_assignment(nfapi_nr_ue_pusch_pdu_t *pusch_config_pdu, + fapi_nr_dl_config_dlsch_pdu_rel15_t *dlsch_config_pdu, + uint16_t n_RB_ULBWP, + uint16_t n_RB_DLBWP, + uint16_t riv); #endif /** @}*/ diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c index a262f5b54c..26ee2e7de5 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c @@ -66,9 +66,9 @@ void fill_dci_search_candidates(NR_SearchSpace_t *ss,fapi_nr_dl_config_dci_dl_pd void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15, fapi_nr_dl_config_request_t *dl_config, int rnti_type, int ss_id, uint8_t dci_format){ - uint16_t monitoringSymbolsWithinSlot; + uint16_t monitoringSymbolsWithinSlot = 0; uint8_t bwp_id = 1, coreset_id = 1; - int sps; + int sps = 0; def_dci_pdu_rel15 = calloc(1,sizeof(dci_pdu_rel15_t)); AssertFatal(mac->scc != NULL, "scc is null\n"); NR_ServingCellConfigCommon_t *scc = mac->scc; @@ -184,7 +184,6 @@ void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl int ss_id; uint8_t bwp_id = 1, coreset_id = 1; - NR_ServingCellConfig_t *scd = mac->scg->spCellConfig->spCellConfigDedicated; NR_BWP_Downlink_t *bwp = mac->DLbwp[bwp_id - 1]; #ifdef DEBUG_DCI diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index 23328842f2..e7115c39c0 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -1017,7 +1017,7 @@ void nr_ue_msg3_scheduler(NR_UE_MAC_INST_t *mac, sub_frame_t current_slot, uint8_t Msg3_tda_id){ - int delta; + int delta = 0; NR_BWP_Uplink_t *ubwp = mac->ULbwp[0]; int mu = ubwp->bwp_Common->genericParameters.subcarrierSpacing; struct NR_PUSCH_TimeDomainResourceAllocationList *pusch_TimeDomainAllocationList = ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; From e837c3b1b556465c49aa5fe9780c76effadbe700 Mon Sep 17 00:00:00 2001 From: cig Date: Thu, 3 Sep 2020 10:50:23 +0200 Subject: [PATCH 20/96] Msg3 PDU configuration cleanup - fetching resource allocation from higher layer - sorting out config for the remaining parameters --- openair2/LAYER2/NR_MAC_UE/rar_tools_nrUE.c | 37 ++++++++++++++-------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_UE/rar_tools_nrUE.c b/openair2/LAYER2/NR_MAC_UE/rar_tools_nrUE.c index a4633d314c..f223dfab77 100644 --- a/openair2/LAYER2/NR_MAC_UE/rar_tools_nrUE.c +++ b/openair2/LAYER2/NR_MAC_UE/rar_tools_nrUE.c @@ -79,6 +79,8 @@ void nr_config_Msg3_pdu(NR_UE_MAC_INST_t *mac, nfapi_nr_ue_pusch_pdu_t *pusch_config_pdu = &ul_config->ul_config_list[ul_config->number_pdus].pusch_config_pdu; NR_ServingCellConfigCommon_t *scc = mac->scc; NR_BWP_Uplink_t *ubwp = mac->ULbwp[0]; + NR_BWP_UplinkDedicated_t *ibwp = mac->scg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP; + NR_PUSCH_Config_t *pusch_Config = ibwp->pusch_Config->choice.setup; int startSymbolAndLength = ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[Msg3_t_alloc]->startSymbolAndLength; #ifdef DEBUG_MSG3 @@ -132,25 +134,32 @@ void nr_config_Msg3_pdu(NR_UE_MAC_INST_t *mac, // TC-RNTI pusch_config_pdu->rnti = mac->t_crnti; - //// Completing PUSCH PDU - pusch_config_pdu->pdu_bit_map = PUSCH_PDU_BITMAP_PUSCH_DATA; - pusch_config_pdu->mcs_table = 0; - pusch_config_pdu->nrOfLayers = 0; - pusch_config_pdu->dmrs_config_type = 0; - // no data in dmrs symbols as in 6.2.2 in 38.214 - pusch_config_pdu->num_dmrs_cdm_grps_no_data = 2; // TBR - pusch_config_pdu->cyclic_prefix = 0; - pusch_config_pdu->target_code_rate = nr_get_code_rate_ul(pusch_config_pdu->mcs_index, pusch_config_pdu->mcs_table); - pusch_config_pdu->qam_mod_order = nr_get_Qm_ul(pusch_config_pdu->mcs_index, pusch_config_pdu->mcs_table); + // DM-RS configuration according to 6.2.2 UE DM-RS transmission procedure in 38.214 + pusch_config_pdu->dmrs_config_type = pusch_dmrs_type1; + pusch_config_pdu->num_dmrs_cdm_grps_no_data = 2; + pusch_config_pdu->dmrs_ports = 1; + // DMRS sequence initialization [TS 38.211, sec 6.4.1.1.1]. + // Should match what is sent in DCI 0_1, otherwise set to 0. + pusch_config_pdu->scid = 0; + + // Transform precoding according to 6.1.3 UE procedure for applying transform precoding on PUSCH in 38.214 if (scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->msg3_transformPrecoder == NULL) pusch_config_pdu->transform_precoding = 1; else pusch_config_pdu->transform_precoding = 0; + + // Resource allocation in frequency domain according to 6.1.2.2 in TS 38.214 + pusch_config_pdu->resource_alloc = pusch_Config->resourceAllocation; + + //// Completing PUSCH PDU + pusch_config_pdu->pdu_bit_map = PUSCH_PDU_BITMAP_PUSCH_DATA; + pusch_config_pdu->mcs_table = 0; + pusch_config_pdu->nrOfLayers = 1; + pusch_config_pdu->cyclic_prefix = 0; + pusch_config_pdu->target_code_rate = nr_get_code_rate_ul(pusch_config_pdu->mcs_index, pusch_config_pdu->mcs_table); + pusch_config_pdu->qam_mod_order = nr_get_Qm_ul(pusch_config_pdu->mcs_index, pusch_config_pdu->mcs_table); pusch_config_pdu->data_scrambling_id = *scc->physCellId; - pusch_config_pdu->ul_dmrs_scrambling_id = *scc->physCellId; //If provided and the PUSCH is not a msg3 PUSCH, otherwise, L2 should set this to physical cell id. - pusch_config_pdu->scid = 0; //DMRS sequence initialization [TS38.211, sec 6.4.1.1.1]. Should match what is sent in DCI 0_1, otherwise set to 0. - pusch_config_pdu->dmrs_ports = 1; // 6.2.2 in 38.214 only port 0 to be used - pusch_config_pdu->resource_alloc = 1; //type 1 + pusch_config_pdu->ul_dmrs_scrambling_id = *scc->physCellId; pusch_config_pdu->subcarrier_spacing = ubwp->bwp_Common->genericParameters.subcarrierSpacing; pusch_config_pdu->vrb_to_prb_mapping = 0; pusch_config_pdu->uplink_frequency_shift_7p5khz = 0; From 915854447b99260278848a00e48893a7ecf7afbd Mon Sep 17 00:00:00 2001 From: Sakthivel Velumani Date: Mon, 7 Sep 2020 16:10:15 +0200 Subject: [PATCH 21/96] fixed merge --- openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c index 2931cb1368..ceb8c4f719 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c +++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c @@ -480,7 +480,7 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, #endif - NR_gNB_ULSCH_t *ulsch = gNB->ulsch[UE_id][0]; + NR_gNB_ULSCH_t *ulsch = phy_vars_gNB->ulsch[UE_id][0]; NR_UL_gNB_HARQ_t *harq_process = ulsch->harq_processes[harq_pid]; t_nrLDPC_dec_params decParams; @@ -558,12 +558,12 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, NR_gNB_SCH_STATS_t *stats=NULL; int first_free=-1; for (int i=0;iulsch_stats[i].rnti == 0 && first_free == -1) { + if (phy_vars_gNB->ulsch_stats[i].rnti == 0 && first_free == -1) { first_free = i; - stats=&gNB->ulsch_stats[i]; + stats=&phy_vars_gNB->ulsch_stats[i]; } - if (gNB->ulsch_stats[i].rnti == ulsch->rnti) { - stats=&gNB->ulsch_stats[i]; + if (phy_vars_gNB->ulsch_stats[i].rnti == ulsch->rnti) { + stats=&phy_vars_gNB->ulsch_stats[i]; break; } } From be522f5c448555ed1553c6b789a63b462722f39c Mon Sep 17 00:00:00 2001 From: Sakthivel Velumani Date: Mon, 7 Sep 2020 16:31:38 +0200 Subject: [PATCH 22/96] changed ul resources to full bwp --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c index f786db8ba9..179face3aa 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c @@ -909,7 +909,7 @@ void schedule_fapi_ul_pdu(int Mod_idP, if (get_softmodem_params()->phy_test==1) pusch_pdu->rb_size = 50; else - pusch_pdu->rb_size = 5; + pusch_pdu->rb_size = pusch_pdu->bwp_size; } else AssertFatal(1==0,"Only frequency resource allocation type 1 is currently supported\n"); From 9751fa052b65cd61cdca9198a411f3ebfae6dead Mon Sep 17 00:00:00 2001 From: Sakthivel Velumani Date: Tue, 8 Sep 2020 10:52:15 +0200 Subject: [PATCH 23/96] bugfix in tx rate matching --- openair1/PHY/CODING/nr_rate_matching.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair1/PHY/CODING/nr_rate_matching.c b/openair1/PHY/CODING/nr_rate_matching.c index f315365127..ba097a83c8 100644 --- a/openair1/PHY/CODING/nr_rate_matching.c +++ b/openair1/PHY/CODING/nr_rate_matching.c @@ -427,7 +427,7 @@ int nr_rate_matching_ldpc(uint8_t Ilbrm, } } else { - if (E + F <= Ncb-ind) { //E+F doesn't contain all coded bits + if (E <= Ncb-ind) { //E+F doesn't contain all coded bits memcpy((void*)(e),(void*)(w+ind),E); k=E; } From 66b117dcd55d6771817c499d0b339f491117226f Mon Sep 17 00:00:00 2001 From: cig Date: Thu, 3 Sep 2020 13:35:23 +0200 Subject: [PATCH 24/96] NR UE PUSCH procedures fixes - moved remaining PUSCH PDU configuration from ULSCH procedures entirely to MAC - introduced a function for DMRS RE configuration - cleaned up redundant code in ULSCH procedures - fixed TBS computation for Msg3 --- openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c | 65 ++++++--------- openair2/LAYER2/NR_MAC_UE/mac_proto.h | 5 ++ openair2/LAYER2/NR_MAC_UE/nr_l1_helpers.c | 22 +++++- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 83 ++++++++++---------- openair2/LAYER2/NR_MAC_UE/rar_tools_nrUE.c | 27 ++++--- 5 files changed, 106 insertions(+), 96 deletions(-) diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c index d8d932624a..f1ae5de7ff 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c @@ -101,13 +101,12 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, LOG_D(PHY,"nr_ue_ulsch_procedures hard_id %d %d.%d\n",harq_pid,frame,slot); uint32_t available_bits; - uint8_t mod_order, cwd_index, l; + uint8_t cwd_index, l; uint32_t scrambled_output[NR_MAX_NB_CODEWORDS][NR_MAX_PDSCH_ENCODED_LENGTH>>5]; int16_t **tx_layers; int32_t **txdataF; int8_t Wf[2], Wt[2], l_prime[2], delta; - uint16_t rnti, code_rate, nb_rb; - uint8_t nb_dmrs_re_per_rb,mcs, Nl; + uint8_t nb_dmrs_re_per_rb; int ap, i; int sample_offsetF, N_RE_prime; @@ -124,49 +123,31 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, NR_UE_ULSCH_t *ulsch_ue = UE->ulsch[thread_id][gNB_id][cwd_index]; NR_UL_UE_HARQ_t *harq_process_ul_ue = ulsch_ue->harq_processes[harq_pid]; + nfapi_nr_ue_pusch_pdu_t *pusch_pdu = &harq_process_ul_ue->pusch_pdu; - int start_symbol = harq_process_ul_ue->pusch_pdu.start_symbol_index; - uint16_t ul_dmrs_symb_pos = harq_process_ul_ue->pusch_pdu.ul_dmrs_symb_pos; - uint8_t number_of_symbols = harq_process_ul_ue->pusch_pdu.nr_of_symbols; - uint8_t dmrs_type = harq_process_ul_ue->pusch_pdu.dmrs_config_type; - uint16_t start_rb = harq_process_ul_ue->pusch_pdu.rb_start; - uint16_t start_sc = frame_parms->first_carrier_offset + start_rb*NR_NB_SC_PER_RB; + int start_symbol = pusch_pdu->start_symbol_index; + uint16_t ul_dmrs_symb_pos = pusch_pdu->ul_dmrs_symb_pos; + uint8_t number_of_symbols = pusch_pdu->nr_of_symbols; + uint8_t dmrs_type = pusch_pdu->dmrs_config_type; + uint16_t start_rb = pusch_pdu->rb_start; + uint16_t nb_rb = pusch_pdu->rb_size; + uint8_t Nl = pusch_pdu->nrOfLayers; + uint8_t mod_order = pusch_pdu->qam_mod_order; + uint16_t rnti = pusch_pdu->rnti; + uint8_t cdm_grps_no_data = pusch_pdu->num_dmrs_cdm_grps_no_data; + uint16_t start_sc = frame_parms->first_carrier_offset + start_rb*NR_NB_SC_PER_RB; if (start_sc >= frame_parms->ofdm_symbol_size) start_sc -= frame_parms->ofdm_symbol_size; - for (i = start_symbol; i < start_symbol + number_of_symbols; i++) { - - if((ul_dmrs_symb_pos >> i) & 0x01) - number_dmrs_symbols += 1; - - } - - rnti = harq_process_ul_ue->pusch_pdu.rnti; ulsch_ue->Nid_cell = Nid_cell; - nb_dmrs_re_per_rb = ((dmrs_type == pusch_dmrs_type1) ? 6:4)*harq_process_ul_ue->pusch_pdu.num_dmrs_cdm_grps_no_data; + get_num_re_dmrs(pusch_pdu, &nb_dmrs_re_per_rb, &number_dmrs_symbols); + // TbD num_of_mod_symbols is set but never used N_RE_prime = NR_NB_SC_PER_RB*number_of_symbols - nb_dmrs_re_per_rb*number_dmrs_symbols - N_PRB_oh; - - nb_rb = harq_process_ul_ue->pusch_pdu.rb_size; - harq_process_ul_ue->num_of_mod_symbols = N_RE_prime*nb_rb*num_of_codewords; - mcs = harq_process_ul_ue->pusch_pdu.mcs_index; - Nl = harq_process_ul_ue->pusch_pdu.nrOfLayers; - mod_order = nr_get_Qm_ul(mcs, 0); - code_rate = nr_get_code_rate_ul(mcs, 0); - - harq_process_ul_ue->pusch_pdu.pusch_data.tb_size = nr_compute_tbs(mod_order, - code_rate, - nb_rb, - number_of_symbols, - nb_dmrs_re_per_rb*number_dmrs_symbols, - 0, - 0, - harq_process_ul_ue->pusch_pdu.nrOfLayers); - /////////////////////////ULSCH coding///////////////////////// /////////// @@ -224,10 +205,10 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, uint8_t L_ptrs, K_ptrs = 0; uint16_t beta_ptrs = 1; // temp value until power control is implemented - if (harq_process_ul_ue->pusch_pdu.pdu_bit_map & PUSCH_PDU_BITMAP_PUSCH_PTRS) { + if (pusch_pdu->pdu_bit_map & PUSCH_PDU_BITMAP_PUSCH_PTRS) { - K_ptrs = (harq_process_ul_ue->pusch_pdu.pusch_ptrs.ptrs_freq_density)?4:2; - L_ptrs = 1<pusch_pdu.pusch_ptrs.ptrs_time_density; + K_ptrs = (pusch_pdu->pusch_ptrs.ptrs_freq_density)?4:2; + L_ptrs = 1<pusch_ptrs.ptrs_time_density; ulsch_ue->ptrs_symbols = 0; @@ -312,7 +293,7 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, if ((ul_dmrs_symb_pos >> l) & 0x01) { is_dmrs_sym = 1; - if (harq_process_ul_ue->pusch_pdu.transform_precoding == 1){ // if transform precoding is disabled + if (pusch_pdu->transform_precoding == 1){ // if transform precoding is disabled if (dmrs_type == pusch_dmrs_type1) dmrs_idx = start_rb*6; else @@ -323,7 +304,7 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, nr_modulation(pusch_dmrs[l][0], n_dmrs*2, DMRS_MOD_ORDER, mod_dmrs); // currently only codeword 0 is modulated. Qm = 2 as DMRS is QPSK modulated - } else if (harq_process_ul_ue->pusch_pdu.pdu_bit_map & PUSCH_PDU_BITMAP_PUSCH_PTRS) { + } else if (pusch_pdu->pdu_bit_map & PUSCH_PDU_BITMAP_PUSCH_PTRS) { if(is_ptrs_symbol(l, ulsch_ue->ptrs_symbols)) { is_ptrs_sym = 1; @@ -348,7 +329,7 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, dmrs_type, K_ptrs, nb_rb, - harq_process_ul_ue->pusch_pdu.pusch_ptrs.ptrs_ports_list[0].ptrs_re_offset, + pusch_pdu->pusch_ptrs.ptrs_ports_list[0].ptrs_re_offset, start_sc, frame_parms->ofdm_symbol_size); } @@ -377,7 +358,7 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, ptrs_idx++; - } else if (!is_dmrs_sym || allowed_xlsch_re_in_dmrs_symbol(k,start_sc,harq_process_ul_ue->pusch_pdu.num_dmrs_cdm_grps_no_data,dmrs_type)) { + } else if (!is_dmrs_sym || allowed_xlsch_re_in_dmrs_symbol(k, start_sc, cdm_grps_no_data, dmrs_type)) { ((int16_t*)txdataF[ap])[(sample_offsetF)<<1] = ((int16_t *) ulsch_ue->y)[m<<1]; ((int16_t*)txdataF[ap])[((sample_offsetF)<<1) + 1] = ((int16_t *) ulsch_ue->y)[(m<<1) + 1]; diff --git a/openair2/LAYER2/NR_MAC_UE/mac_proto.h b/openair2/LAYER2/NR_MAC_UE/mac_proto.h index 6ef7c622a6..10c0967e0f 100755 --- a/openair2/LAYER2/NR_MAC_UE/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_proto.h @@ -300,5 +300,10 @@ int8_t nr_ue_process_dci_freq_dom_resource_assignment(nfapi_nr_ue_pusch_pdu_t *p uint16_t n_RB_ULBWP, uint16_t n_RB_DLBWP, uint16_t riv); + +void get_num_re_dmrs(nfapi_nr_ue_pusch_pdu_t *pusch_pdu, + uint8_t *nb_dmrs_re_per_rb, + uint16_t *number_dmrs_symbols); + #endif /** @}*/ diff --git a/openair2/LAYER2/NR_MAC_UE/nr_l1_helpers.c b/openair2/LAYER2/NR_MAC_UE/nr_l1_helpers.c index f8bb1e5f8e..30e4acaf49 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_l1_helpers.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_l1_helpers.c @@ -20,7 +20,7 @@ */ /*! \file nr_l1_helper.c -* \brief PHY helper functions for PRACH adapted to NR +* \brief PHY/MAC helper functions * \author Guido Casati * \date 2019 * \version 2.0 @@ -151,3 +151,23 @@ int nr_get_Po_NOMINAL_PUSCH(NR_PRACH_RESOURCES_t *prach_resources, module_id_t m return receivedTargerPower; } + +void get_num_re_dmrs(nfapi_nr_ue_pusch_pdu_t *pusch_pdu, + uint8_t *nb_dmrs_re_per_rb, + uint16_t *number_dmrs_symbols){ + + int start_symbol = pusch_pdu->start_symbol_index; + uint8_t number_of_symbols = pusch_pdu->nr_of_symbols; + uint16_t ul_dmrs_symb_pos = pusch_pdu->ul_dmrs_symb_pos; + uint8_t dmrs_type = pusch_pdu->dmrs_config_type; + uint8_t cdm_grps_no_data = pusch_pdu->num_dmrs_cdm_grps_no_data; + + *number_dmrs_symbols = 0; + for (int i = start_symbol; i < start_symbol + number_of_symbols; i++) { + if((ul_dmrs_symb_pos >> i) & 0x01) + *number_dmrs_symbols += 1; + } + + *nb_dmrs_re_per_rb = ((dmrs_type == pusch_dmrs_type1) ? 6:4)*cdm_grps_no_data; + +} diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index e7115c39c0..888617e5f6 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -822,34 +822,56 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in uint16_t pdu_bit_map = PUSCH_PDU_BITMAP_PUSCH_DATA; uint8_t ptrs_time_density = get_L_ptrs(ptrs_mcs1, ptrs_mcs2, ptrs_mcs3, mcs_index, mcs_table); uint8_t ptrs_freq_density = get_K_ptrs(n_rb0, n_rb1, rb_size); - uint8_t no_data_in_dmrs = 1; uint16_t number_dmrs_symbols = 0; uint16_t ul_dmrs_symb_pos = l_prime_mask << start_symbol_index; + int N_PRB_oh = 0; // TBR higher layer (RRC) parameter xOverhead in PUSCH-ServingCellConfig //------------------------------------------------------------------------------// // PTRS ports configuration // TbD: ptrs_dmrs_port and ptrs_port_index are not initialised! ptrs_ports_list.ptrs_re_offset = 0; + ul_config->slot = ul_info->slot_tx; + ul_config->number_pdus = 1; + ul_config->ul_config_list[0].pdu_type = FAPI_NR_UL_CONFIG_TYPE_PUSCH; + ul_config->ul_config_list[0].pusch_config_pdu.rnti = rnti; + ul_config->ul_config_list[0].pusch_config_pdu.rb_size = rb_size; + ul_config->ul_config_list[0].pusch_config_pdu.rb_start = rb_start; + ul_config->ul_config_list[0].pusch_config_pdu.nr_of_symbols = nr_of_symbols; + ul_config->ul_config_list[0].pusch_config_pdu.start_symbol_index = start_symbol_index; + ul_config->ul_config_list[0].pusch_config_pdu.ul_dmrs_symb_pos = ul_dmrs_symb_pos; + ul_config->ul_config_list[0].pusch_config_pdu.dmrs_config_type = dmrs_config_type; + ul_config->ul_config_list[0].pusch_config_pdu.mcs_index = mcs_index; + ul_config->ul_config_list[0].pusch_config_pdu.mcs_table = mcs_table; + ul_config->ul_config_list[0].pusch_config_pdu.num_dmrs_cdm_grps_no_data = 1; + ul_config->ul_config_list[0].pusch_config_pdu.pusch_data.new_data_indicator = 0; + ul_config->ul_config_list[0].pusch_config_pdu.pusch_data.rv_index = rv_index; + ul_config->ul_config_list[0].pusch_config_pdu.nrOfLayers = nrOfLayers; + ul_config->ul_config_list[0].pusch_config_pdu.pusch_data.harq_process_id = harq_process_id; + ul_config->ul_config_list[0].pusch_config_pdu.pdu_bit_map = pdu_bit_map; + ul_config->ul_config_list[0].pusch_config_pdu.pusch_ptrs.ptrs_time_density = ptrs_time_density; + ul_config->ul_config_list[0].pusch_config_pdu.pusch_ptrs.ptrs_freq_density = ptrs_freq_density; + ul_config->ul_config_list[0].pusch_config_pdu.pusch_ptrs.ptrs_ports_list = &ptrs_ports_list; + ul_config->ul_config_list[0].pusch_config_pdu.target_code_rate = nr_get_code_rate_ul(mcs_index, mcs_table); + ul_config->ul_config_list[0].pusch_config_pdu.qam_mod_order = nr_get_Qm_ul(mcs_index, mcs_table); - for (i = start_symbol_index; i < start_symbol_index + nr_of_symbols; i++) { - if((ul_dmrs_symb_pos >> i) & 0x01) - number_dmrs_symbols += 1; - } + if (1 << ptrs_time_density >= nr_of_symbols) { + ul_config->ul_config_list[0].pusch_config_pdu.pdu_bit_map &= ~PUSCH_PDU_BITMAP_PUSCH_PTRS; // disable PUSCH PTRS + } - if(no_data_in_dmrs) - nb_dmrs_re_per_rb = 12; - else - nb_dmrs_re_per_rb = ((dmrs_config_type == pusch_dmrs_type1) ? 6:4); + get_num_re_dmrs(&ul_config->ul_config_list[0].pusch_config_pdu, + &nb_dmrs_re_per_rb, + &number_dmrs_symbols); - TBS = nr_compute_tbs(nr_get_Qm_ul(mcs_index, 0), - nr_get_code_rate_ul(mcs_index, 0), - rb_size, - nr_of_symbols, - nb_dmrs_re_per_rb*number_dmrs_symbols, - 0, - 0, - nrOfLayers); - TBS_bytes = TBS/8; + TBS = nr_compute_tbs(ul_config->ul_config_list[0].pusch_config_pdu.qam_mod_order, + ul_config->ul_config_list[0].pusch_config_pdu.target_code_rate, + rb_size, + nr_of_symbols, + nb_dmrs_re_per_rb*number_dmrs_symbols, + N_PRB_oh, + 0, + nrOfLayers); + TBS_bytes = TBS/8; + ul_config->ul_config_list[0].pusch_config_pdu.pusch_data.tb_size = TBS_bytes; if (IS_SOFTMODEM_NOS1){ // Getting IP traffic to be transmitted @@ -907,31 +929,6 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in tx_req_body.pdu = ulsch_input_buffer; tx_req.tx_request_body = &tx_req_body; - ul_config->slot = ul_info->slot_tx; - ul_config->ul_config_list[0].pdu_type = FAPI_NR_UL_CONFIG_TYPE_PUSCH; - ul_config->ul_config_list[0].pusch_config_pdu.rnti = rnti; - ul_config->ul_config_list[0].pusch_config_pdu.rb_size = rb_size; - ul_config->ul_config_list[0].pusch_config_pdu.rb_start = rb_start; - ul_config->ul_config_list[0].pusch_config_pdu.nr_of_symbols = nr_of_symbols; - ul_config->ul_config_list[0].pusch_config_pdu.start_symbol_index = start_symbol_index; - ul_config->ul_config_list[0].pusch_config_pdu.ul_dmrs_symb_pos = ul_dmrs_symb_pos; - ul_config->ul_config_list[0].pusch_config_pdu.dmrs_config_type = dmrs_config_type; - ul_config->ul_config_list[0].pusch_config_pdu.mcs_index = mcs_index; - ul_config->ul_config_list[0].pusch_config_pdu.mcs_table = mcs_table; - ul_config->ul_config_list[0].pusch_config_pdu.num_dmrs_cdm_grps_no_data = 1; - ul_config->ul_config_list[0].pusch_config_pdu.pusch_data.new_data_indicator = 0; - ul_config->ul_config_list[0].pusch_config_pdu.pusch_data.rv_index = rv_index; - ul_config->ul_config_list[0].pusch_config_pdu.nrOfLayers = nrOfLayers; - ul_config->ul_config_list[0].pusch_config_pdu.pusch_data.harq_process_id = harq_process_id; - ul_config->ul_config_list[0].pusch_config_pdu.pdu_bit_map = pdu_bit_map; - ul_config->ul_config_list[0].pusch_config_pdu.pusch_ptrs.ptrs_time_density = ptrs_time_density; - ul_config->ul_config_list[0].pusch_config_pdu.pusch_ptrs.ptrs_freq_density = ptrs_freq_density; - ul_config->ul_config_list[0].pusch_config_pdu.pusch_ptrs.ptrs_ports_list = &ptrs_ports_list; - - if (1 << ptrs_time_density >= nr_of_symbols) { - ul_config->ul_config_list[0].pusch_config_pdu.pdu_bit_map &= ~PUSCH_PDU_BITMAP_PUSCH_PTRS; // disable PUSCH PTRS - } - fill_scheduled_response(&scheduled_response, NULL, ul_config, &tx_req, mod_id, cc_id, rx_frame, rx_slot); if(mac->if_module != NULL && mac->if_module->scheduled_response != NULL){ mac->if_module->scheduled_response(&scheduled_response); diff --git a/openair2/LAYER2/NR_MAC_UE/rar_tools_nrUE.c b/openair2/LAYER2/NR_MAC_UE/rar_tools_nrUE.c index f223dfab77..e3134285cd 100644 --- a/openair2/LAYER2/NR_MAC_UE/rar_tools_nrUE.c +++ b/openair2/LAYER2/NR_MAC_UE/rar_tools_nrUE.c @@ -74,7 +74,9 @@ void nr_config_Msg3_pdu(NR_UE_MAC_INST_t *mac, uint8_t freq_hopping){ int f_alloc, mask, StartSymbolIndex, NrOfSymbols; - uint16_t TBS_bytes; + uint8_t nb_dmrs_re_per_rb; + uint16_t number_dmrs_symbols = 0; + int N_PRB_oh = 0; // TBR higher layer (RRC) parameter xOverhead in PUSCH-ServingCellConfig fapi_nr_ul_config_request_t *ul_config = &mac->ul_config_request; nfapi_nr_ue_pusch_pdu_t *pusch_config_pdu = &ul_config->ul_config_list[ul_config->number_pdus].pusch_config_pdu; NR_ServingCellConfigCommon_t *scc = mac->scc; @@ -138,6 +140,10 @@ void nr_config_Msg3_pdu(NR_UE_MAC_INST_t *mac, pusch_config_pdu->dmrs_config_type = pusch_dmrs_type1; pusch_config_pdu->num_dmrs_cdm_grps_no_data = 2; pusch_config_pdu->dmrs_ports = 1; + get_num_re_dmrs(pusch_config_pdu, + &nb_dmrs_re_per_rb, + &number_dmrs_symbols); + // DMRS sequence initialization [TS 38.211, sec 6.4.1.1.1]. // Should match what is sent in DCI 0_1, otherwise set to 0. pusch_config_pdu->scid = 0; @@ -168,15 +174,16 @@ void nr_config_Msg3_pdu(NR_UE_MAC_INST_t *mac, pusch_config_pdu->pusch_data.harq_process_id = 0; pusch_config_pdu->pusch_data.new_data_indicator = 1; // new data pusch_config_pdu->pusch_data.num_cb = 0; - TBS_bytes = nr_compute_tbs(pusch_config_pdu->qam_mod_order, - pusch_config_pdu->target_code_rate, - pusch_config_pdu->rb_size, - pusch_config_pdu->nr_of_symbols, - 12, // TBR compute accordingly - nb dmrs set for no data in dmrs symbol - 0, // nb_rb_oh - 0, // to verify tb scaling - pusch_config_pdu->nrOfLayers = 1)/8; - pusch_config_pdu->pusch_data.tb_size = TBS_bytes; + + // Compute TBS + pusch_config_pdu->pusch_data.tb_size = nr_compute_tbs(pusch_config_pdu->qam_mod_order, + pusch_config_pdu->target_code_rate, + pusch_config_pdu->rb_size, + pusch_config_pdu->nr_of_symbols, + nb_dmrs_re_per_rb*number_dmrs_symbols, + N_PRB_oh, + 0, // TBR to verify tb scaling + pusch_config_pdu->nrOfLayers); } From e72ef27e660b62bd9cc49b5acf803675795d10c4 Mon Sep 17 00:00:00 2001 From: cig Date: Thu, 3 Sep 2020 14:33:57 +0200 Subject: [PATCH 25/96] Moved nr_compute_tbs_common file to common MAC folder - updated cmakelists file - fixed formatting, tabs and white spaces in the function --- cmake_targets/CMakeLists.txt | 2 +- .../nr_compute_tbs_common.c | 142 ++++++++---------- 2 files changed, 65 insertions(+), 79 deletions(-) rename openair2/LAYER2/{NR_MAC_gNB => NR_MAC_COMMON}/nr_compute_tbs_common.c (52%) diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index 9fcb586e09..eb88881548 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -1933,7 +1933,7 @@ add_dependencies(L2_UE rrc_flag s1ap_flag x2_flag) add_library( NR_L2_UE ${NR_L2_SRC_UE} ${MAC_NR_SRC_UE} ) -add_library( MAC_NR_COMMON ${OPENAIR2_DIR}/LAYER2/NR_MAC_COMMON/nr_mac_common.c ${OPENAIR2_DIR}/LAYER2/NR_MAC_gNB/nr_compute_tbs_common.c) +add_library( MAC_NR_COMMON ${OPENAIR2_DIR}/LAYER2/NR_MAC_COMMON/nr_mac_common.c ${OPENAIR2_DIR}/LAYER2/NR_MAC_COMMON/nr_compute_tbs_common.c) include_directories("${OPENAIR2_DIR}/NR_UE_PHY_INTERFACE") include_directories("${OPENAIR2_DIR}/LAYER2") diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_compute_tbs_common.c b/openair2/LAYER2/NR_MAC_COMMON/nr_compute_tbs_common.c similarity index 52% rename from openair2/LAYER2/NR_MAC_gNB/nr_compute_tbs_common.c rename to openair2/LAYER2/NR_MAC_COMMON/nr_compute_tbs_common.c index df23b64e07..9c775286a3 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_compute_tbs_common.c +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_compute_tbs_common.c @@ -35,67 +35,59 @@ uint16_t NPRB_LBRM[7] = {32,66,107,135,162,217,273}; uint32_t nr_compute_tbs(uint16_t Qm, uint16_t R, - uint16_t nb_rb, - uint16_t nb_symb_sch, - uint16_t nb_dmrs_prb, + uint16_t nb_rb, + uint16_t nb_symb_sch, + uint16_t nb_dmrs_prb, uint16_t nb_rb_oh, uint8_t tb_scaling, - uint8_t Nl) + uint8_t Nl) { - uint16_t nbp_re, nb_re; - uint32_t nr_tbs=0; - uint32_t Ninfo, Np_info, C; - uint8_t n, scale; + uint16_t nbp_re, nb_re; + uint32_t nr_tbs=0; + uint32_t Ninfo, Np_info, C; + uint8_t n, scale; - nbp_re = 12 * nb_symb_sch - nb_dmrs_prb - nb_rb_oh; + nbp_re = 12 * nb_symb_sch - nb_dmrs_prb - nb_rb_oh; + nb_re = min(156, nbp_re) * nb_rb; + scale = (R>1024)?11:10; + // Intermediate number of information bits + Ninfo = ((nb_re * R * Qm * Nl)>>scale)>>tb_scaling; - nb_re = min(156, nbp_re) * nb_rb; - - scale = (R>1024)?11:10; - - // Intermediate number of information bits - Ninfo = ((nb_re * R * Qm * Nl)>>scale)>>tb_scaling; - - if (Ninfo <=3824) { - n = max(3, floor(log2(Ninfo)) - 6); - Np_info = max(24, (Ninfo>>n)<= Np_info){ - nr_tbs = Tbstable_nr[i]; - break; - } + if (Ninfo <=3824) { + n = max(3, floor(log2(Ninfo)) - 6); + Np_info = max(24, (Ninfo>>n)<= Np_info){ + nr_tbs = Tbstable_nr[i]; + break; } + } + } else { + n = log2(Ninfo-24)-5; + Np_info = max(3840, (ROUNDIDIV((Ninfo-24),(1< 8424){ + C = CEILIDIV((Np_info+24),8424); + nr_tbs = (C<<3)*CEILIDIV((Np_info+24),(C<<3)) - 24; + } else { + nr_tbs = ((CEILIDIV((Np_info+24),8))<<3) - 24; + } } - else { - n = log2(Ninfo-24)-5; - Np_info = max(3840, (ROUNDIDIV((Ninfo-24),(1< 8424){ - C = CEILIDIV((Np_info+24),8424); - nr_tbs = (C<<3)*CEILIDIV((Np_info+24),(C<<3)) - 24; - } - else { - nr_tbs = ((CEILIDIV((Np_info+24),8))<<3) - 24; - } - - } - - } - //printf("Ninfo %d nbp_re %d nb_re %d Qm %d, R %d, tbs %d\n", Ninfo, nbp_re, nb_re, Qm, R, nr_tbs); - return nr_tbs; + } + //printf("Ninfo %d nbp_re %d nb_re %d Qm %d, R %d, tbs %d\n", Ninfo, nbp_re, nb_re, Qm, R, nr_tbs); + return nr_tbs; } //tbslbrm calculation according to 5.4.2.1 of 38.212 uint32_t nr_compute_tbslbrm(uint16_t table, - uint16_t nb_rb, - uint8_t Nl, + uint16_t nb_rb, + uint8_t Nl, uint8_t C) { @@ -108,10 +100,10 @@ uint32_t nr_compute_tbslbrm(uint16_t table, uint8_t n; for (i=0; i<7; i++) { - if (NPRB_LBRM[i] >= nb_rb){ - nb_rb_lbrm = NPRB_LBRM[i]; - break; - } + if (NPRB_LBRM[i] >= nb_rb){ + nb_rb_lbrm = NPRB_LBRM[i]; + break; + } } Qm = ((table == 1)? 8 : 6); @@ -122,33 +114,27 @@ uint32_t nr_compute_tbslbrm(uint16_t table, Ninfo = (nb_re * R * Qm * Nl)>>10; if (Ninfo <=3824) { - n = max(3, floor(log2(Ninfo)) - 6); - Np_info = max(24, (Ninfo>>n)<= Np_info){ - nr_tbs = Tbstable_nr[i]; - break; - } - } - } - else { - n = log2(Ninfo-24)-5; - Np_info = max(3840, (ROUNDIDIV((Ninfo-24),(1< 8424){ - nr_tbs = (C<<3)*CEILIDIV((Np_info+24),(C<<3)) - 24; - } - else { - nr_tbs = ((CEILIDIV((Np_info+24),8))<<3) - 24; - } - - } + n = max(3, floor(log2(Ninfo)) - 6); + Np_info = max(24, (Ninfo>>n)<= Np_info){ + nr_tbs = Tbstable_nr[i]; + break; + } + } + } else { + n = log2(Ninfo-24)-5; + Np_info = max(3840, (ROUNDIDIV((Ninfo-24),(1< 8424){ + nr_tbs = (C<<3)*CEILIDIV((Np_info+24),(C<<3)) - 24; + } else { + nr_tbs = ((CEILIDIV((Np_info+24),8))<<3) - 24; + } + } } return nr_tbs; - } From 7ab4abacb1fc14b4c900d2e5858fee69ec43e0aa Mon Sep 17 00:00:00 2001 From: cig Date: Thu, 3 Sep 2020 16:20:02 +0200 Subject: [PATCH 26/96] Retrieve N_PRB Overhead from PUSCH-ServingCellConfig --- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 9 +++++++-- openair2/LAYER2/NR_MAC_UE/rar_tools_nrUE.c | 8 +++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index 888617e5f6..7195b611f1 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -781,7 +781,7 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in uint8_t data_existing = 0; uint16_t TBS_bytes; uint32_t TBS; - int i; + int i, N_PRB_oh; module_id_t mod_id = ul_info->module_id; uint32_t gNB_index = ul_info->gNB_index; @@ -824,12 +824,17 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in uint8_t ptrs_freq_density = get_K_ptrs(n_rb0, n_rb1, rb_size); uint16_t number_dmrs_symbols = 0; uint16_t ul_dmrs_symb_pos = l_prime_mask << start_symbol_index; - int N_PRB_oh = 0; // TBR higher layer (RRC) parameter xOverhead in PUSCH-ServingCellConfig //------------------------------------------------------------------------------// // PTRS ports configuration // TbD: ptrs_dmrs_port and ptrs_port_index are not initialised! ptrs_ports_list.ptrs_re_offset = 0; + // Num PRB Overhead from PUSCH-ServingCellConfig + if (mac->scg->spCellConfig->spCellConfigDedicated->uplinkConfig->pusch_ServingCellConfig->choice.setup->xOverhead == NULL) + N_PRB_oh = 0; + else + N_PRB_oh = *mac->scg->spCellConfig->spCellConfigDedicated->uplinkConfig->pusch_ServingCellConfig->choice.setup->xOverhead; + ul_config->slot = ul_info->slot_tx; ul_config->number_pdus = 1; ul_config->ul_config_list[0].pdu_type = FAPI_NR_UL_CONFIG_TYPE_PUSCH; diff --git a/openair2/LAYER2/NR_MAC_UE/rar_tools_nrUE.c b/openair2/LAYER2/NR_MAC_UE/rar_tools_nrUE.c index e3134285cd..13d471f691 100644 --- a/openair2/LAYER2/NR_MAC_UE/rar_tools_nrUE.c +++ b/openair2/LAYER2/NR_MAC_UE/rar_tools_nrUE.c @@ -76,7 +76,7 @@ void nr_config_Msg3_pdu(NR_UE_MAC_INST_t *mac, int f_alloc, mask, StartSymbolIndex, NrOfSymbols; uint8_t nb_dmrs_re_per_rb; uint16_t number_dmrs_symbols = 0; - int N_PRB_oh = 0; // TBR higher layer (RRC) parameter xOverhead in PUSCH-ServingCellConfig + int N_PRB_oh; fapi_nr_ul_config_request_t *ul_config = &mac->ul_config_request; nfapi_nr_ue_pusch_pdu_t *pusch_config_pdu = &ul_config->ul_config_list[ul_config->number_pdus].pusch_config_pdu; NR_ServingCellConfigCommon_t *scc = mac->scc; @@ -89,6 +89,12 @@ void nr_config_Msg3_pdu(NR_UE_MAC_INST_t *mac, printf("[DEBUG_MSG3] Configuring 1 Msg3 PDU of %d UL pdus \n", ul_config->number_pdus); #endif + // Num PRB Overhead from PUSCH-ServingCellConfig + if (mac->scg->spCellConfig->spCellConfigDedicated->uplinkConfig->pusch_ServingCellConfig->choice.setup->xOverhead == NULL) + N_PRB_oh = 0; + else + N_PRB_oh = *mac->scg->spCellConfig->spCellConfigDedicated->uplinkConfig->pusch_ServingCellConfig->choice.setup->xOverhead; + // active BWP start int abwp_start = NRRIV2PRBOFFSET(ubwp->bwp_Common->genericParameters.locationAndBandwidth, 275); int abwp_size = NRRIV2BW(ubwp->bwp_Common->genericParameters.locationAndBandwidth, 275); From 9ac6dfee094c269c79eaad5ec4a87c24bd0ab984 Mon Sep 17 00:00:00 2001 From: cig Date: Thu, 3 Sep 2020 16:20:38 +0200 Subject: [PATCH 27/96] Minor fixes UE - added some descriptions to the code - fixed hardcoded factors - removed commented out and unused code - phy_procedures_nrUE_RX: removed unused do_pdcch_flag - updated LTE naming to 5G --- executables/nr-ue.c | 2 +- openair1/PHY/CODING/coding_defs.h | 3 + openair1/PHY/defs_nr_UE.h | 4 - openair1/SCHED_NR_UE/defs.h | 19 +-- openair1/SCHED_NR_UE/fapi_nr_ue_l1.c | 9 -- openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 149 +++++++++--------- openair1/SIMULATION/NR_PHY/dlsim.c | 2 - .../NR_MAC_COMMON/nr_compute_tbs_common.c | 5 +- 8 files changed, 92 insertions(+), 101 deletions(-) diff --git a/executables/nr-ue.c b/executables/nr-ue.c index 1489f3cec2..0de82e7a8b 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -422,7 +422,7 @@ void processSlotRX( PHY_VARS_NR_UE *UE, UE_nr_rxtx_proc_t *proc) { phy_procedures_slot_parallelization_nrUE_RX( UE, proc, 0, 0, 1, UE->mode, no_relay, NULL ); #else uint64_t a=rdtsc(); - phy_procedures_nrUE_RX( UE, proc, 0, 1, UE->mode); + phy_procedures_nrUE_RX( UE, proc, 0, UE->mode); LOG_D(PHY,"phy_procedures_nrUE_RX: slot:%d, time %lu\n", proc->nr_tti_rx, (rdtsc()-a)/3500); //printf(">>> nr_ue_pdcch_procedures ended\n"); #endif diff --git a/openair1/PHY/CODING/coding_defs.h b/openair1/PHY/CODING/coding_defs.h index 7f466c7097..328aeda769 100644 --- a/openair1/PHY/CODING/coding_defs.h +++ b/openair1/PHY/CODING/coding_defs.h @@ -469,6 +469,9 @@ int32_t nr_segmentation(unsigned char *input_buffer, unsigned int *F, uint8_t BG); +/*!\fn uint32_t nr_compute_tbs +\brief This function returns the TBS in bits as per 6.1.4.2 of TS 38.214 +*/ uint32_t nr_compute_tbs(uint16_t Qm, uint16_t R, uint16_t nb_rb, diff --git a/openair1/PHY/defs_nr_UE.h b/openair1/PHY/defs_nr_UE.h index 62ffeaaea8..fff6a82047 100644 --- a/openair1/PHY/defs_nr_UE.h +++ b/openair1/PHY/defs_nr_UE.h @@ -912,10 +912,6 @@ typedef struct { char ulsch_no_allocation_counter[NUMBER_OF_CONNECTED_eNB_MAX]; unsigned char ulsch_Msg3_active[NUMBER_OF_CONNECTED_gNB_MAX]; - uint32_t ulsch_Msg3_frame[NUMBER_OF_CONNECTED_gNB_MAX]; - unsigned char ulsch_Msg3_subframe[NUMBER_OF_CONNECTED_gNB_MAX]; - uint8_t Msg3_startSymbol[NUMBER_OF_CONNECTED_gNB_MAX]; - uint8_t Msg3_Length[NUMBER_OF_CONNECTED_gNB_MAX]; NR_PRACH_RESOURCES_t *prach_resources[NUMBER_OF_CONNECTED_gNB_MAX]; int turbo_iterations, turbo_cntl_iterations; diff --git a/openair1/SCHED_NR_UE/defs.h b/openair1/SCHED_NR_UE/defs.h index c6aea2ec08..3b60186fdb 100644 --- a/openair1/SCHED_NR_UE/defs.h +++ b/openair1/SCHED_NR_UE/defs.h @@ -111,17 +111,18 @@ int phy_procedures_RN_UE_RX(unsigned char last_slot, unsigned char next_slot, re @param r_type indicates the relaying operation: 0: no_relaying, 1: unicast relaying type 1, 2: unicast relaying type 2, 3: multicast relaying */ void phy_procedures_nrUE_TX(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eNB_id, uint8_t thread_id); + /*! \brief Scheduling for UE RX procedures in normal subframes. - @param last_slot Index of last slot (0-19) - @param phy_vars_ue Pointer to UE variables on which to act - @param proc Pointer to RXn_TXnp4 proc information - @param eNB_id Local id of eNB on which to act - @param abstraction_flag Indicator of PHY abstraction - @param mode calibration/debug mode - @param r_type indicates the relaying operation: 0: no_relaying, 1: unicast relaying type 1, 2: unicast relaying type 2, 3: multicast relaying - @param phy_vars_rn pointer to RN variables + @param ue Pointer to UE variables on which to act + @param proc Pointer to proc information + @param gNB_id Local id of eNB on which to act + @param mode calibration/debug mode */ -int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t do_pdcch_flag,runmode_t mode); +int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, + UE_nr_rxtx_proc_t *proc, + uint8_t gNB_id, + runmode_t mode); + int phy_procedures_slot_parallelization_nrUE_RX(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t abstraction_flag,uint8_t do_pdcch_flag,runmode_t mode,relaying_type_t r_type); diff --git a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c index ea97767574..19fca75a76 100644 --- a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c +++ b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c @@ -57,10 +57,6 @@ int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response){ NR_UE_PDCCH *pdcch_vars = PHY_vars_UE_g[module_id][cc_id]->pdcch_vars[thread_id][0]; NR_UE_ULSCH_t *ulsch0 = PHY_vars_UE_g[module_id][cc_id]->ulsch[thread_id][0][0]; NR_DL_FRAME_PARMS frame_parms = PHY_vars_UE_g[module_id][cc_id]->frame_parms; - //PRACH_RESOURCES_t *prach_resources = PHY_vars_UE_g[module_id][cc_id]->prach_resources[0]; - - // PUCCH_ConfigCommon_nr_t *pucch_config_common = PHY_vars_UE_g[module_id][cc_id]->pucch_config_common_nr[0]; - // PUCCH_Config_t *pucch_config_dedicated = PHY_vars_UE_g[module_id][cc_id]->pucch_config_dedicated_nr[0]; if(scheduled_response->dl_config != NULL){ fapi_nr_dl_config_request_t *dl_config = scheduled_response->dl_config; @@ -93,7 +89,6 @@ int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response){ dlsch0->current_harq_pid = current_harq_pid; dlsch0->active = 1; dlsch0->rnti = dl_config->dl_config_list[i].dlsch_config_pdu.rnti; - //dlsch0->harq_processes[0]->mcs = &dlsch_config_pdu->mcs; dlsch0_harq = dlsch0->harq_processes[current_harq_pid]; if (dlsch0_harq){ @@ -121,8 +116,6 @@ int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response){ } } dl_config->number_pdus = 0; - } else { - pdcch_vars->nb_search_space = 0; } if (scheduled_response->ul_config != NULL){ @@ -162,7 +155,6 @@ int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response){ if (scheduled_response->tx_request){ // TBR todo here it should loop through the number of tx pdus fapi_nr_tx_request_body_t *tx_req_body = scheduled_response->tx_request->tx_request_body; - //harq_process_ul_ue->a = (unsigned char*)calloc(TBS/8, sizeof(unsigned char)); memcpy(harq_process_ul_ue->a, tx_req_body->pdu, tx_req_body->pdu_length); harq_process_ul_ue->status = ACTIVE; @@ -225,7 +217,6 @@ int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response){ case (FAPI_NR_UL_CONFIG_TYPE_PRACH): // prach config pdu - //prach_resources = PHY_vars_UE_g[module_id][cc_id]->prach_resources[gNB_id]; prach_config_pdu = &ul_config->ul_config_list[i].prach_config_pdu; memcpy((void*)&(PHY_vars_UE_g[module_id][cc_id]->prach_vars[gNB_id]->prach_pdu), (void*)prach_config_pdu, sizeof(fapi_nr_ul_config_prach_pdu)); PHY_vars_UE_g[module_id][cc_id]->prach_vars[gNB_id]->prach_Config_enabled = 1; diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index 7281aef3f3..95ff7aa758 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -1627,8 +1627,7 @@ int is_pbch_in_slot(fapi_nr_config_request_t *config, int frame, int slot, NR_DL int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, - uint8_t eNB_id, - uint8_t do_pdcch_flag, + uint8_t gNB_id, runmode_t mode) { int frame_rx = proc->frame_rx; @@ -1679,13 +1678,13 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, #endif } - nr_ue_pbch_procedures(eNB_id,ue,proc,0); + nr_ue_pbch_procedures(gNB_id, ue, proc, 0); if (ue->no_timing_correction==0) { LOG_I(PHY,"start adjust sync slot = %d no timing %d\n", nr_tti_rx, ue->no_timing_correction); nr_adjust_synch_ue(fp, ue, - eNB_id, + gNB_id, frame_rx, nr_tti_rx, 0, @@ -1726,19 +1725,19 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, #endif //printf("phy procedure pdcch start measurement l =%d\n",l); - //nr_ue_measurement_procedures(l,ue,proc,eNB_id,(nr_tti_rx),mode); + //nr_ue_measurement_procedures(l,ue,proc,gNB_id,(nr_tti_rx),mode); } - dci_cnt = nr_ue_pdcch_procedures(eNB_id, ue, proc); + dci_cnt = nr_ue_pdcch_procedures(gNB_id, ue, proc); if (dci_cnt > 0) { LOG_D(PHY,"[UE %d] Frame %d, nr_tti_rx %d: found %d DCIs\n", ue->Mod_id, frame_rx, nr_tti_rx, dci_cnt); NR_UE_DLSCH_t *dlsch = NULL; - if (ue->dlsch[ue->current_thread_id[nr_tti_rx]][eNB_id][0]->active == 1){ - dlsch = ue->dlsch[ue->current_thread_id[nr_tti_rx]][eNB_id][0]; + if (ue->dlsch[ue->current_thread_id[nr_tti_rx]][gNB_id][0]->active == 1){ + dlsch = ue->dlsch[ue->current_thread_id[nr_tti_rx]][gNB_id][0]; } else if (ue->dlsch_ra[0]->active == 1){ dlsch = ue->dlsch_ra[0]; } @@ -1774,64 +1773,64 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, start_meas(&ue->generic_stat); #endif // do procedures for C-RNTI - if (ue->dlsch[ue->current_thread_id[nr_tti_rx]][eNB_id][0]->active == 1) { + if (ue->dlsch[ue->current_thread_id[nr_tti_rx]][gNB_id][0]->active == 1) { //VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC, VCD_FUNCTION_IN); nr_ue_pdsch_procedures(ue, proc, - eNB_id, + gNB_id, PDSCH, - ue->dlsch[ue->current_thread_id[nr_tti_rx]][eNB_id][0], + ue->dlsch[ue->current_thread_id[nr_tti_rx]][gNB_id][0], NULL); //printf("phy procedure pdsch start measurement\n"); - nr_ue_measurement_procedures(2,ue,proc,eNB_id,nr_tti_rx,mode); + nr_ue_measurement_procedures(2,ue,proc,gNB_id,nr_tti_rx,mode); /* write_output("rxF.m","rxF",&ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[nr_tti_rx]].rxdataF[0][0],fp->ofdm_symbol_size*14,1,1); - write_output("rxF_ch.m","rxFch",&ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id]->dl_ch_estimates[0][0],fp->ofdm_symbol_size*14,1,1); - write_output("rxF_ch_ext.m","rxFche",&ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id]->dl_ch_estimates_ext[0][2*50*12],50*12,1,1); - write_output("rxF_ext.m","rxFe",&ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id]->rxdataF_ext[0][0],50*12*14,1,1); - write_output("rxF_comp.m","rxFc",&ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id]->rxdataF_comp0[0][0],fp->N_RB_DL*12*14,1,1); - write_output("rxF_llr.m","rxFllr",ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id]->llr[0],(nb_symb_sch-1)*50*12+50*6,1,0); + write_output("rxF_ch.m","rxFch",&ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][gNB_id]->dl_ch_estimates[0][0],fp->ofdm_symbol_size*14,1,1); + write_output("rxF_ch_ext.m","rxFche",&ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][gNB_id]->dl_ch_estimates_ext[0][2*50*12],50*12,1,1); + write_output("rxF_ext.m","rxFe",&ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][gNB_id]->rxdataF_ext[0][0],50*12*14,1,1); + write_output("rxF_comp.m","rxFc",&ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][gNB_id]->rxdataF_comp0[0][0],fp->N_RB_DL*12*14,1,1); + write_output("rxF_llr.m","rxFllr",ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][gNB_id]->llr[0],(nb_symb_sch-1)*50*12+50*6,1,0); */ //VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC, VCD_FUNCTION_OUT); } // do procedures for SI-RNTI - if ((ue->dlsch_SI[eNB_id]) && (ue->dlsch_SI[eNB_id]->active == 1)) { + if ((ue->dlsch_SI[gNB_id]) && (ue->dlsch_SI[gNB_id]->active == 1)) { VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC_SI, VCD_FUNCTION_IN); nr_ue_pdsch_procedures(ue, proc, - eNB_id, + gNB_id, SI_PDSCH, - ue->dlsch_SI[eNB_id], + ue->dlsch_SI[gNB_id], NULL); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC_SI, VCD_FUNCTION_OUT); } // do procedures for SI-RNTI - if ((ue->dlsch_p[eNB_id]) && (ue->dlsch_p[eNB_id]->active == 1)) { + if ((ue->dlsch_p[gNB_id]) && (ue->dlsch_p[gNB_id]->active == 1)) { VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC_P, VCD_FUNCTION_IN); nr_ue_pdsch_procedures(ue, proc, - eNB_id, + gNB_id, P_PDSCH, - ue->dlsch_p[eNB_id], + ue->dlsch_p[gNB_id], NULL); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC_P, VCD_FUNCTION_OUT); } // do procedures for RA-RNTI - if ((ue->dlsch_ra[eNB_id]) && (ue->dlsch_ra[eNB_id]->active == 1)) { + if ((ue->dlsch_ra[gNB_id]) && (ue->dlsch_ra[gNB_id]->active == 1)) { VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC_RA, VCD_FUNCTION_IN); nr_ue_pdsch_procedures(ue, proc, - eNB_id, + gNB_id, RA_PDSCH, - ue->dlsch_ra[eNB_id], + ue->dlsch_ra[gNB_id], NULL); // #if UE_TIMING_TRACE @@ -1840,11 +1839,11 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, nr_ue_dlsch_procedures(ue, proc, - eNB_id, + gNB_id, RA_PDSCH, - ue->dlsch_ra[eNB_id], + ue->dlsch_ra[gNB_id], NULL, - &ue->dlsch_ra_errors[eNB_id], + &ue->dlsch_ra_errors[gNB_id], mode); // #if UE_TIMING_TRACE @@ -1862,7 +1861,7 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, } // do procedures for C-RNTI - if (ue->dlsch[ue->current_thread_id[nr_tti_rx]][eNB_id][0]->active == 1) { + if (ue->dlsch[ue->current_thread_id[nr_tti_rx]][gNB_id][0]->active == 1) { LOG_D(PHY, "DLSCH data reception at nr_tti_rx: %d \n \n", nr_tti_rx); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC, VCD_FUNCTION_IN); @@ -1873,11 +1872,11 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, nr_ue_dlsch_procedures(ue, proc, - eNB_id, + gNB_id, PDSCH, - ue->dlsch[ue->current_thread_id[nr_tti_rx]][eNB_id][0], - ue->dlsch[ue->current_thread_id[nr_tti_rx]][eNB_id][1], - &ue->dlsch_errors[eNB_id], + ue->dlsch[ue->current_thread_id[nr_tti_rx]][gNB_id][0], + ue->dlsch[ue->current_thread_id[nr_tti_rx]][gNB_id][1], + &ue->dlsch_errors[gNB_id], mode); @@ -1894,7 +1893,7 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, #endif // deactivate dlsch once dlsch proc is done - ue->dlsch[ue->current_thread_id[nr_tti_rx]][eNB_id][0]->active = 0; + ue->dlsch[ue->current_thread_id[nr_tti_rx]][gNB_id][0]->active = 0; VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC, VCD_FUNCTION_OUT); @@ -1905,9 +1904,9 @@ start_meas(&ue->generic_stat); #if 0 - if(nr_tti_rx==5 && ue->dlsch[ue->current_thread_id[nr_tti_rx]][eNB_id][0]->harq_processes[ue->dlsch[ue->current_thread_id[nr_tti_rx]][eNB_id][0]->current_harq_pid]->nb_rb > 20){ + if(nr_tti_rx==5 && ue->dlsch[ue->current_thread_id[nr_tti_rx]][gNB_id][0]->harq_processes[ue->dlsch[ue->current_thread_id[nr_tti_rx]][gNB_id][0]->current_harq_pid]->nb_rb > 20){ //write_output("decoder_llr.m","decllr",dlsch_llr,G,1,0); - //write_output("llr.m","llr", &ue->pdsch_vars[eNB_id]->llr[0][0],(14*nb_rb*12*dlsch1_harq->Qm) - 4*(nb_rb*4*dlsch1_harq->Qm),1,0); + //write_output("llr.m","llr", &ue->pdsch_vars[gNB_id]->llr[0][0],(14*nb_rb*12*dlsch1_harq->Qm) - 4*(nb_rb*4*dlsch1_harq->Qm),1,0); write_output("rxdataF0_current.m" , "rxdataF0", &ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[nr_tti_rx]].rxdataF[0][0],14*fp->ofdm_symbol_size,1,1); //write_output("rxdataF0_previous.m" , "rxdataF0_prev_sss", &ue->common_vars.common_vars_rx_data_per_thread[next_thread_id].rxdataF[0][0],14*fp->ofdm_symbol_size,1,1); @@ -1925,78 +1924,78 @@ start_meas(&ue->generic_stat); #endif // do procedures for SI-RNTI - if ((ue->dlsch_SI[eNB_id]) && (ue->dlsch_SI[eNB_id]->active == 1)) { + if ((ue->dlsch_SI[gNB_id]) && (ue->dlsch_SI[gNB_id]->active == 1)) { nr_ue_pdsch_procedures(ue, proc, - eNB_id, + gNB_id, SI_PDSCH, - ue->dlsch_SI[eNB_id], + ue->dlsch_SI[gNB_id], NULL); /*ue_dlsch_procedures(ue, proc, - eNB_id, + gNB_id, SI_PDSCH, - ue->dlsch_SI[eNB_id], + ue->dlsch_SI[gNB_id], NULL, - &ue->dlsch_SI_errors[eNB_id], + &ue->dlsch_SI_errors[gNB_id], mode, abstraction_flag); - ue->dlsch_SI[eNB_id]->active = 0;*/ + ue->dlsch_SI[gNB_id]->active = 0;*/ } // do procedures for P-RNTI - if ((ue->dlsch_p[eNB_id]) && (ue->dlsch_p[eNB_id]->active == 1)) { + if ((ue->dlsch_p[gNB_id]) && (ue->dlsch_p[gNB_id]->active == 1)) { nr_ue_pdsch_procedures(ue, proc, - eNB_id, + gNB_id, P_PDSCH, - ue->dlsch_p[eNB_id], + ue->dlsch_p[gNB_id], NULL); /*ue_dlsch_procedures(ue, proc, - eNB_id, + gNB_id, P_PDSCH, - ue->dlsch_p[eNB_id], + ue->dlsch_p[gNB_id], NULL, - &ue->dlsch_p_errors[eNB_id], + &ue->dlsch_p_errors[gNB_id], mode, abstraction_flag);*/ - ue->dlsch_p[eNB_id]->active = 0; + ue->dlsch_p[gNB_id]->active = 0; } // do procedures for RA-RNTI - if ((ue->dlsch_ra[eNB_id]) && (ue->dlsch_ra[eNB_id]->active == 1)) { + if ((ue->dlsch_ra[gNB_id]) && (ue->dlsch_ra[gNB_id]->active == 1)) { nr_ue_pdsch_procedures(ue, proc, - eNB_id, + gNB_id, RA_PDSCH, - ue->dlsch_ra[eNB_id], + ue->dlsch_ra[gNB_id], NULL); /*ue_dlsch_procedures(ue, proc, - eNB_id, + gNB_id, RA_PDSCH, - ue->dlsch_ra[eNB_id], + ue->dlsch_ra[gNB_id], NULL, - &ue->dlsch_ra_errors[eNB_id], + &ue->dlsch_ra_errors[gNB_id], mode, abstraction_flag);*/ - ue->dlsch_ra[eNB_id]->active = 0; + ue->dlsch_ra[gNB_id]->active = 0; } // duplicate harq structure /* - uint8_t current_harq_pid = ue->dlsch[ue->current_thread_id[nr_tti_rx]][eNB_id][0]->current_harq_pid; - NR_DL_UE_HARQ_t *current_harq_processes = ue->dlsch[ue->current_thread_id[nr_tti_rx]][eNB_id][0]->harq_processes[current_harq_pid]; - NR_DL_UE_HARQ_t *harq_processes_dest = ue->dlsch[next1_thread_id][eNB_id][0]->harq_processes[current_harq_pid]; - NR_DL_UE_HARQ_t *harq_processes_dest1 = ue->dlsch[next2_thread_id][eNB_id][0]->harq_processes[current_harq_pid]; + uint8_t current_harq_pid = ue->dlsch[ue->current_thread_id[nr_tti_rx]][gNB_id][0]->current_harq_pid; + NR_DL_UE_HARQ_t *current_harq_processes = ue->dlsch[ue->current_thread_id[nr_tti_rx]][gNB_id][0]->harq_processes[current_harq_pid]; + NR_DL_UE_HARQ_t *harq_processes_dest = ue->dlsch[next1_thread_id][gNB_id][0]->harq_processes[current_harq_pid]; + NR_DL_UE_HARQ_t *harq_processes_dest1 = ue->dlsch[next2_thread_id][gNB_id][0]->harq_processes[current_harq_pid]; */ - /*nr_harq_status_t *current_harq_ack = &ue->dlsch[ue->current_thread_id[nr_tti_rx]][eNB_id][0]->harq_ack[nr_tti_rx]; - nr_harq_status_t *harq_ack_dest = &ue->dlsch[next1_thread_id][eNB_id][0]->harq_ack[nr_tti_rx]; - nr_harq_status_t *harq_ack_dest1 = &ue->dlsch[next2_thread_id][eNB_id][0]->harq_ack[nr_tti_rx]; + /*nr_harq_status_t *current_harq_ack = &ue->dlsch[ue->current_thread_id[nr_tti_rx]][gNB_id][0]->harq_ack[nr_tti_rx]; + nr_harq_status_t *harq_ack_dest = &ue->dlsch[next1_thread_id][gNB_id][0]->harq_ack[nr_tti_rx]; + nr_harq_status_t *harq_ack_dest1 = &ue->dlsch[next2_thread_id][gNB_id][0]->harq_ack[nr_tti_rx]; */ //copy_harq_proc_struct(harq_processes_dest, current_harq_processes); @@ -2007,23 +2006,23 @@ start_meas(&ue->generic_stat); if (nr_tti_rx==9) { if (frame_rx % 10 == 0) { - if ((ue->dlsch_received[eNB_id] - ue->dlsch_received_last[eNB_id]) != 0) - ue->dlsch_fer[eNB_id] = (100*(ue->dlsch_errors[eNB_id] - ue->dlsch_errors_last[eNB_id]))/(ue->dlsch_received[eNB_id] - ue->dlsch_received_last[eNB_id]); + if ((ue->dlsch_received[gNB_id] - ue->dlsch_received_last[gNB_id]) != 0) + ue->dlsch_fer[gNB_id] = (100*(ue->dlsch_errors[gNB_id] - ue->dlsch_errors_last[gNB_id]))/(ue->dlsch_received[gNB_id] - ue->dlsch_received_last[gNB_id]); - ue->dlsch_errors_last[eNB_id] = ue->dlsch_errors[eNB_id]; - ue->dlsch_received_last[eNB_id] = ue->dlsch_received[eNB_id]; + ue->dlsch_errors_last[gNB_id] = ue->dlsch_errors[gNB_id]; + ue->dlsch_received_last[gNB_id] = ue->dlsch_received[gNB_id]; } - ue->bitrate[eNB_id] = (ue->total_TBS[eNB_id] - ue->total_TBS_last[eNB_id])*100; - ue->total_TBS_last[eNB_id] = ue->total_TBS[eNB_id]; + ue->bitrate[gNB_id] = (ue->total_TBS[gNB_id] - ue->total_TBS_last[gNB_id])*100; + ue->total_TBS_last[gNB_id] = ue->total_TBS[gNB_id]; LOG_D(PHY,"[UE %d] Calculating bitrate Frame %d: total_TBS = %d, total_TBS_last = %d, bitrate %f kbits\n", - ue->Mod_id,frame_rx,ue->total_TBS[eNB_id], - ue->total_TBS_last[eNB_id],(float) ue->bitrate[eNB_id]/1000.0); + ue->Mod_id,frame_rx,ue->total_TBS[gNB_id], + ue->total_TBS_last[gNB_id],(float) ue->bitrate[gNB_id]/1000.0); #if UE_AUTOTEST_TRACE if ((frame_rx % 100 == 0)) { - LOG_I(PHY,"[UE %d] AUTOTEST Metric : UE_DLSCH_BITRATE = %5.2f kbps (frame = %d) \n", ue->Mod_id, (float) ue->bitrate[eNB_id]/1000.0, frame_rx); + LOG_I(PHY,"[UE %d] AUTOTEST Metric : UE_DLSCH_BITRATE = %5.2f kbps (frame = %d) \n", ue->Mod_id, (float) ue->bitrate[gNB_id]/1000.0, frame_rx); } #endif @@ -2035,7 +2034,7 @@ printf("after tubo until end of Rx %5.2f \n",ue->generic_stat.p_time/(cpuf*1000. #endif #ifdef EMOS -phy_procedures_emos_UE_RX(ue,slot,eNB_id); +phy_procedures_emos_UE_RX(ue,slot,gNB_id); #endif diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index 137c358d7f..6471a46537 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -191,7 +191,6 @@ int main(int argc, char **argv) NR_UE_MAC_INST_t *UE_mac; int cyclic_prefix_type = NFAPI_CP_NORMAL; int run_initial_sync=0; - int do_pdcch_flag=1; int loglvl=OAILOG_INFO; @@ -848,7 +847,6 @@ int main(int argc, char **argv) phy_procedures_nrUE_RX(UE, &UE_proc, 0, - do_pdcch_flag, normal_txrx); //printf("dlsim round %d ends\n",round); diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_compute_tbs_common.c b/openair2/LAYER2/NR_MAC_COMMON/nr_compute_tbs_common.c index 9c775286a3..c2c3398a84 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_compute_tbs_common.c +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_compute_tbs_common.c @@ -27,12 +27,15 @@ #include "common/utils/nr/nr_common.h" #include +#include "PHY/defs_nr_common.h" //Table 5.1.2.2-2 uint16_t Tbstable_nr[INDEX_MAX_TBS_TABLE] = {24,32,40,48,56,64,72,80,88,96,104,112,120,128,136,144,152,160,168,176,184,192,208,224,240,256,272,288,304,320,336,352,368,384,408,432,456,480,504,528,552,576,608,640,672,704,736,768,808,848,888,928,984,1032,1064,1128,1160,1192,1224,1256,1288,1320,1352,1416,1480,1544,1608,1672,1736,1800,1864,1928,2024,2088,2152,2216,2280,2408,2472,2536,2600,2664,2728,2792,2856,2976,3104,3240,3368,3496,3624,3752,3824}; uint16_t NPRB_LBRM[7] = {32,66,107,135,162,217,273}; +// Transport block size determination according to 6.1.4.2 of TS 38.214 +// returns the TBS in bits uint32_t nr_compute_tbs(uint16_t Qm, uint16_t R, uint16_t nb_rb, @@ -48,7 +51,7 @@ uint32_t nr_compute_tbs(uint16_t Qm, uint32_t Ninfo, Np_info, C; uint8_t n, scale; - nbp_re = 12 * nb_symb_sch - nb_dmrs_prb - nb_rb_oh; + nbp_re = NR_NB_SC_PER_RB * nb_symb_sch - nb_dmrs_prb - nb_rb_oh; nb_re = min(156, nbp_re) * nb_rb; scale = (R>1024)?11:10; // Intermediate number of information bits From 81398971ff4751db7036b7f94c7991c58b22f245 Mon Sep 17 00:00:00 2001 From: cig Date: Thu, 3 Sep 2020 22:34:30 +0200 Subject: [PATCH 28/96] Set tb_size in bytes and A in bits @ UE - now is consistent for both UE and gNB --- openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c | 2 +- openair1/SIMULATION/NR_PHY/ulschsim.c | 4 ++-- openair1/SIMULATION/NR_PHY/ulsim.c | 6 +++--- openair2/LAYER2/NR_MAC_UE/rar_tools_nrUE.c | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c index 429e8a0aff..fdc8bb21f8 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c @@ -248,7 +248,7 @@ int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch, crc = 1; harq_process = ulsch->harq_processes[harq_pid]; nb_rb = harq_process->pusch_pdu.rb_size; - A = harq_process->pusch_pdu.pusch_data.tb_size; + A = harq_process->pusch_pdu.pusch_data.tb_size*8; pz = &Z; mod_order = nr_get_Qm_ul(harq_process->pusch_pdu.mcs_index, harq_process->pusch_pdu.mcs_table); R = nr_get_code_rate_ul(harq_process->pusch_pdu.mcs_index, harq_process->pusch_pdu.mcs_table); diff --git a/openair1/SIMULATION/NR_PHY/ulschsim.c b/openair1/SIMULATION/NR_PHY/ulschsim.c index b0557ef1b4..99e15fec0f 100644 --- a/openair1/SIMULATION/NR_PHY/ulschsim.c +++ b/openair1/SIMULATION/NR_PHY/ulschsim.c @@ -405,7 +405,7 @@ int main(int argc, char **argv) rel15_ul->pusch_data.rv_index = rvidx; rel15_ul->nrOfLayers = Nl; rel15_ul->target_code_rate = code_rate; - rel15_ul->pusch_data.tb_size = TBS>>3; + rel15_ul->pusch_data.tb_size = TBS/8; /////////////////////////////////////////////////// double *modulated_input = malloc16(sizeof(double) * 16 * 68 * 384); // [hna] 16 segments, 68*Zc @@ -441,7 +441,7 @@ int main(int argc, char **argv) harq_process_ul_ue->pusch_pdu.nr_of_symbols = nb_symb_sch; harq_process_ul_ue->num_of_mod_symbols = N_RE_prime*nb_rb*nb_codewords; harq_process_ul_ue->pusch_pdu.pusch_data.rv_index = rvidx; - harq_process_ul_ue->pusch_pdu.pusch_data.tb_size = TBS; + harq_process_ul_ue->pusch_pdu.pusch_data.tb_size = TBS/8; harq_process_ul_ue->a = &test_input[0]; } diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c index 8ffdd98970..4a27924227 100644 --- a/openair1/SIMULATION/NR_PHY/ulsim.c +++ b/openair1/SIMULATION/NR_PHY/ulsim.c @@ -710,14 +710,14 @@ int main(int argc, char **argv) available_bits = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, number_dmrs_symbols, mod_order, 1); TBS = nr_compute_tbs(mod_order, code_rate, nb_rb, nb_symb_sch, nb_re_dmrs * number_dmrs_symbols, 0, 0, precod_nbr_layers); - pusch_pdu->pusch_data.tb_size = TBS>>3; - ul_config.ul_config_list[0].pusch_config_pdu.pusch_data.tb_size = TBS; + pusch_pdu->pusch_data.tb_size = TBS/8; + ul_config.ul_config_list[0].pusch_config_pdu.pusch_data.tb_size = TBS/8; nr_fill_ulsch(gNB,frame,slot,pusch_pdu); int slot_offset = frame_parms->get_samples_slot_timestamp(slot,frame_parms,0);// - (int)(800*factor); int slot_length = slot_offset - frame_parms->get_samples_slot_timestamp(slot-1,frame_parms,0); - for (int i=0;i<(TBS>>3);i++) ulsch_ue[0]->harq_processes[harq_pid]->a[i]=i&0xff; + for (int i=0;i<(TBS/8);i++) ulsch_ue[0]->harq_processes[harq_pid]->a[i]=i&0xff; double scale = 1; if (input_fd == NULL) { diff --git a/openair2/LAYER2/NR_MAC_UE/rar_tools_nrUE.c b/openair2/LAYER2/NR_MAC_UE/rar_tools_nrUE.c index 13d471f691..2e5d1b405b 100644 --- a/openair2/LAYER2/NR_MAC_UE/rar_tools_nrUE.c +++ b/openair2/LAYER2/NR_MAC_UE/rar_tools_nrUE.c @@ -189,7 +189,7 @@ void nr_config_Msg3_pdu(NR_UE_MAC_INST_t *mac, nb_dmrs_re_per_rb*number_dmrs_symbols, N_PRB_oh, 0, // TBR to verify tb scaling - pusch_config_pdu->nrOfLayers); + pusch_config_pdu->nrOfLayers)/8; } From 7c3377d51552f248859d972f8d8efb118872a9a4 Mon Sep 17 00:00:00 2001 From: cig Date: Fri, 4 Sep 2020 13:38:52 +0200 Subject: [PATCH 29/96] Minor fixes to RA procedures - added some text descriptions - replaced active BWP with initial BWP in Msg3 scheduling (8.3 TS 38.213) - fixed logging - disabled Msg3 repetitions after first transmission (disabled RA @ MAC) --- openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c | 8 ++++++-- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 6 ++---- openair2/LAYER2/NR_MAC_UE/rar_tools_nrUE.c | 19 +++++++++++-------- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c index 351bcc292f..117e5d2970 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c @@ -493,9 +493,13 @@ uint8_t nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources, if (mac->RA_window_cnt >= 0 && mac->RA_RAPID_found == 1) { + // Reset RA_active flag: it disables Msg3 retransmission (8.3 of TS 38.213) + // TbD Msg3 Retransmissions to be scheduled by DCI 0_0 + mac->RA_active = 0; mac->RA_window_cnt = -1; mac->ra_state = RA_SUCCEEDED; - LOG_I(MAC, "[MAC][UE %d][RAPROC] Frame %d: nr_tti_tx %d: RAR successfully received \n", mod_id, frame, nr_tti_tx); + mac->generate_nr_prach = 2; + LOG_I(MAC, "[MAC][UE %d][RAPROC]: RAR successfully received \n", mod_id); } else if (mac->RA_window_cnt == 0 && !mac->RA_RAPID_found) { @@ -578,7 +582,7 @@ uint8_t nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources, mac->RA_window_cnt--; - LOG_I(MAC, "[MAC][UE %d][RAPROC] Frame %d: nr_tti_tx %d: RAR reception not successful, (RA window count %d) \n", + LOG_D(MAC, "[MAC][UE %d][RAPROC][%d.%d]: RAR not received yet (RA window count %d) \n", mod_id, frame, nr_tti_tx, diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index 7195b611f1..f5bd5ea95d 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -948,7 +948,7 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in NR_UE_MAC_INST_t *mac = get_mac_inst(ul_info->module_id); - if (ul_info->slot_tx == mac->msg3_slot && ul_info->frame_tx == mac->msg3_frame){ + if (mac->RA_active && ul_info->slot_tx == mac->msg3_slot && ul_info->frame_tx == mac->msg3_frame){ uint8_t ulsch_input_buffer[MAX_ULSCH_PAYLOAD_BYTES]; nr_scheduled_response_t scheduled_response; @@ -1012,7 +1012,7 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in return UE_CONNECTION_OK; } -// Scheduling the Msg3 transmission according to according to TS 38.213 +// PUSCH Msg3 scheduled by RAR UL grant according to 8.3 of TS 38.213 // Note: Msg3 tx in the uplink symbols of mixed slot void nr_ue_msg3_scheduler(NR_UE_MAC_INST_t *mac, frame_t current_frame, @@ -1201,8 +1201,6 @@ void nr_ue_prach_scheduler(module_id_t module_idP, frame_t frameP, sub_frame_t s } } } - } else if (mac->ra_state == RA_SUCCEEDED){ - mac->generate_nr_prach = 2; } fill_scheduled_response(&scheduled_response, NULL, ul_config, NULL, module_idP, 0 /*TBR fix*/, frameP, slotP); diff --git a/openair2/LAYER2/NR_MAC_UE/rar_tools_nrUE.c b/openair2/LAYER2/NR_MAC_UE/rar_tools_nrUE.c index 2e5d1b405b..06db41df9c 100644 --- a/openair2/LAYER2/NR_MAC_UE/rar_tools_nrUE.c +++ b/openair2/LAYER2/NR_MAC_UE/rar_tools_nrUE.c @@ -103,19 +103,22 @@ void nr_config_Msg3_pdu(NR_UE_MAC_INST_t *mac, int ibwp_start = NRRIV2PRBOFFSET(scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, 275); int ibwp_size = NRRIV2BW(scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, 275); - //// Resource assignment from RAR - // Frequency domain allocation - if (abwp_size < 180) - mask = (1 << ((int) ceil(log2((abwp_size*(abwp_size+1))>>1)))) - 1; - else - mask = (1 << (28 - (int)(ceil(log2((abwp_size*(abwp_size+1))>>1))))) - 1; - f_alloc = Msg3_f_alloc & mask; + // BWP start selection according to 8.3 of TS 38.213 pusch_config_pdu->bwp_size = ibwp_size; if ((ibwp_start < abwp_start) || (ibwp_size > abwp_size)) pusch_config_pdu->bwp_start = abwp_start; else pusch_config_pdu->bwp_start = ibwp_start; + + //// Resource assignment from RAR + // Frequency domain allocation according to 8.3 of TS 38.213 + if (ibwp_size < 180) + mask = (1 << ((int) ceil(log2((ibwp_size*(ibwp_size+1))>>1)))) - 1; + else + mask = (1 << (28 - (int)(ceil(log2((ibwp_size*(ibwp_size+1))>>1))))) - 1; + f_alloc = Msg3_f_alloc & mask; nr_ue_process_dci_freq_dom_resource_assignment(pusch_config_pdu, NULL, ibwp_size, 0, f_alloc); + // virtual resource block to physical resource mapping for Msg3 PUSCH (6.3.1.7 in 38.211) pusch_config_pdu->rb_start += ibwp_start - abwp_start; @@ -250,7 +253,7 @@ uint16_t nr_ue_process_rar(module_id_t mod_id, LOG_D(MAC, "[UE %d][RAPROC] Got BI RAR subPDU %d\n", mod_id, ue_mac->RA_backoff_indicator); } if (rarh->RAPID == preamble_index) { - LOG_D(PHY, "[UE %d][RAPROC] Found RAR with the intended RAPID %d\n", mod_id, rarh->RAPID); + LOG_I(PHY, "[UE %d][RAPROC][%d.%d] Found RAR with the intended RAPID %d\n", mod_id, frame, slot, rarh->RAPID); rar = (NR_MAC_RAR *) (dlsch_buffer + n_subheaders + (n_subPDUs - 1) * sizeof(NR_MAC_RAR)); ue_mac->RA_RAPID_found = 1; break; From 6ac5a6e74af26904a33fcfb11bc46561e250b649 Mon Sep 17 00:00:00 2001 From: cig Date: Fri, 4 Sep 2020 17:33:05 +0200 Subject: [PATCH 30/96] N_RB configuration for DCI extraction according to 7.3.1.0 of TS 38.212 - replacing ambiguous configuration of N_RB for extraction of DCI 1_0 --- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 31 +++++++++++++++++--- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index f5bd5ea95d..3799b0ab51 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -3223,6 +3223,32 @@ void nr_ue_send_sdu(module_id_t module_idP, } +// N_RB configuration according to 7.3.1.0 (DCI size alignment) of TS 38.212 +int get_n_rb(NR_UE_MAC_INST_t *mac, int rnti_type){ + + int N_RB, start_RB; + switch(rnti_type) { + case NR_RNTI_RA: + case NR_RNTI_TC: + case NR_RNTI_P: + case NR_RNTI_SI: + if (mac->DLbwp[0]->bwp_Common->pdcch_ConfigCommon->choice.setup->controlResourceSetZero) { + uint8_t bwp_id = 1; + uint8_t coreset_id = 0; // assuming controlResourceSetId is 0 for controlResourceSetZero + NR_ControlResourceSet_t *coreset = mac->coreset[bwp_id - 1][coreset_id]; + get_coreset_rballoc(coreset->frequencyDomainResources.buf,&N_RB,&start_RB); + } else { + N_RB = NRRIV2BW(mac->scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth, 275); + } + break; + case NR_RNTI_C: + N_RB = NRRIV2BW(mac->DLbwp[0]->bwp_Common->genericParameters.locationAndBandwidth, 275); + break; + } + return N_RB; + +} + void nr_extract_dci_info(NR_UE_MAC_INST_t *mac, int dci_format, uint8_t dci_size, @@ -3240,9 +3266,7 @@ void nr_extract_dci_info(NR_UE_MAC_INST_t *mac, AssertFatal(rnti_type!=-1,"no identified/handled rnti\n"); AssertFatal(mac->DLbwp[0] != NULL, "DLbwp[0] shouldn't be null here!\n"); AssertFatal(mac->ULbwp[0] != NULL, "ULbwp[0] shouldn't be null here!\n"); - int N_RB = (mac->scg != NULL) ? - NRRIV2BW(mac->DLbwp[0]->bwp_Common->genericParameters.locationAndBandwidth,275) : - NRRIV2BW(mac->scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth,275); + int N_RB = get_n_rb(mac, rnti_type); int N_RB_UL = (mac->scg != NULL) ? NRRIV2BW(mac->ULbwp[0]->bwp_Common->genericParameters.locationAndBandwidth,275) : NRRIV2BW(mac->scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth,275); @@ -3254,7 +3278,6 @@ void nr_extract_dci_info(NR_UE_MAC_INST_t *mac, case NR_DL_DCI_FORMAT_1_0: switch(rnti_type) { case NR_RNTI_RA: - N_RB = NRRIV2BW(mac->scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth, 275); // TBR hotfix // Freq domain assignment fsize = (int)ceil( log2( (N_RB*(N_RB+1))>>1 ) ); pos=fsize; From e686da4e48c641472facf0377bec7bfe56bce039 Mon Sep 17 00:00:00 2001 From: Sakthivel Velumani Date: Tue, 8 Sep 2020 16:08:30 +0200 Subject: [PATCH 31/96] fixed tbslbrm --- openair1/PHY/CODING/coding_defs.h | 3 +-- openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c | 2 +- openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c | 2 +- openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c | 10 +++++----- openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c | 2 +- openair2/LAYER2/NR_MAC_gNB/nr_compute_tbs_common.c | 7 ++++--- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/openair1/PHY/CODING/coding_defs.h b/openair1/PHY/CODING/coding_defs.h index 7f466c7097..00f0a8c0c9 100644 --- a/openair1/PHY/CODING/coding_defs.h +++ b/openair1/PHY/CODING/coding_defs.h @@ -480,8 +480,7 @@ uint32_t nr_compute_tbs(uint16_t Qm, uint32_t nr_compute_tbslbrm(uint16_t table, uint16_t nb_rb, - uint8_t Nl, - uint8_t C); + uint8_t Nl); void nr_interleaving_ldpc(uint32_t E, uint8_t Qm, uint8_t *e,uint8_t *f); diff --git a/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c b/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c index e5841d3262..a4a684c4e4 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c @@ -527,7 +527,7 @@ int nr_dlsch_encoding(PHY_VARS_gNB *gNB, if (rel15->nrOfLayers < Nl) Nl = rel15->nrOfLayers; - Tbslbrm = nr_compute_tbslbrm(rel15->mcsTable[0],nb_rb,Nl,dlsch->harq_processes[harq_pid]->C); + Tbslbrm = nr_compute_tbslbrm(rel15->mcsTable[0],nb_rb,Nl); start_meas(dlsch_rate_matching_stats); nr_rate_matching_ldpc(Ilbrm, diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c index ceb8c4f719..6f9849a89f 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c +++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c @@ -599,7 +599,7 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, printf("K %d C %d Z %d \n", harq_process->K, harq_process->C, harq_process->Z); #endif } - Tbslbrm = nr_compute_tbslbrm(0,nb_rb,n_layers,harq_process->C); + Tbslbrm = nr_compute_tbslbrm(0,nb_rb,n_layers); p_decParams->Z = harq_process->Z; diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c index 36bcb2f379..7378f69c27 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c @@ -478,9 +478,9 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_RATE_MATCHING, VCD_FUNCTION_IN); if ((harq_process->Nl)<4) - Tbslbrm = nr_compute_tbslbrm(harq_process->mcs_table,nb_rb,harq_process->Nl,harq_process->C); + Tbslbrm = nr_compute_tbslbrm(harq_process->mcs_table,nb_rb,harq_process->Nl); else - Tbslbrm = nr_compute_tbslbrm(harq_process->mcs_table,nb_rb,4,harq_process->C); + Tbslbrm = nr_compute_tbslbrm(harq_process->mcs_table,nb_rb,4); if (nr_rate_matching_ldpc_rx(Ilbrm, @@ -1069,7 +1069,7 @@ uint32_t nr_dlsch_decoding_mthread(PHY_VARS_NR_UE *phy_vars_ue, if (harq_process->Nl < Nl) Nl = harq_process->Nl; - Tbslbrm = nr_compute_tbslbrm(harq_process->mcs_table,nb_rb,harq_process->Nl,harq_process->C); + Tbslbrm = nr_compute_tbslbrm(harq_process->mcs_table,nb_rb,harq_process->Nl); if (nr_rate_matching_ldpc_rx(Ilbrm, Tbslbrm, @@ -1610,9 +1610,9 @@ void nr_dlsch_decoding_process(void *arg) #endif if (Nl<4) - Tbslbrm = nr_compute_tbslbrm(harq_process->mcs_table,nb_rb,Nl,harq_process->C); + Tbslbrm = nr_compute_tbslbrm(harq_process->mcs_table,nb_rb,Nl); else - Tbslbrm = nr_compute_tbslbrm(harq_process->mcs_table,nb_rb,4,harq_process->C); + Tbslbrm = nr_compute_tbslbrm(harq_process->mcs_table,nb_rb,4); if (nr_rate_matching_ldpc_rx(Ilbrm, Tbslbrm, diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c index 6f5fba7812..ac4877d00f 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c @@ -438,7 +438,7 @@ int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch, E = nr_get_E(G, harq_process->C, mod_order, harq_process->pusch_pdu.nrOfLayers, r); - Tbslbrm = nr_compute_tbslbrm(0,nb_rb,harq_process->pusch_pdu.nrOfLayers,harq_process->C); + Tbslbrm = nr_compute_tbslbrm(0,nb_rb,harq_process->pusch_pdu.nrOfLayers); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_NR_RATE_MATCHING_LDPC, VCD_FUNCTION_IN); nr_rate_matching_ldpc(Ilbrm, diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_compute_tbs_common.c b/openair2/LAYER2/NR_MAC_gNB/nr_compute_tbs_common.c index df23b64e07..336fa1d68d 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_compute_tbs_common.c +++ b/openair2/LAYER2/NR_MAC_gNB/nr_compute_tbs_common.c @@ -95,8 +95,7 @@ uint32_t nr_compute_tbs(uint16_t Qm, //tbslbrm calculation according to 5.4.2.1 of 38.212 uint32_t nr_compute_tbslbrm(uint16_t table, uint16_t nb_rb, - uint8_t Nl, - uint8_t C) + uint8_t Nl) { uint16_t R, nb_re; @@ -104,7 +103,7 @@ uint32_t nr_compute_tbslbrm(uint16_t table, uint8_t Qm; int i; uint32_t nr_tbs=0; - uint32_t Ninfo, Np_info; + uint32_t Ninfo, Np_info, C; uint8_t n; for (i=0; i<7; i++) { @@ -136,10 +135,12 @@ uint32_t nr_compute_tbslbrm(uint16_t table, Np_info = max(3840, (ROUNDIDIV((Ninfo-24),(1< 8424){ + C = CEILIDIV((Np_info+24),8424); nr_tbs = (C<<3)*CEILIDIV((Np_info+24),(C<<3)) - 24; } else { From 77dc7daf0a95cda3afac0c1c62514bb4bd318f22 Mon Sep 17 00:00:00 2001 From: Sakthivel Velumani Date: Thu, 10 Sep 2020 20:28:38 +0200 Subject: [PATCH 32/96] fixed bugs --- openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c index 6f9849a89f..37c619a230 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c +++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c @@ -486,8 +486,8 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, t_nrLDPC_dec_params decParams; t_nrLDPC_dec_params* p_decParams = &decParams; - int Kr = harq_process->K; - int Kr_bytes = Kr>>3; + int Kr; + int Kr_bytes; phy_vars_gNB->nbDecode = 0; harq_process->processedSegments = 0; @@ -623,6 +623,9 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, #ifdef DEBUG_ULSCH_DECODING printf("Segmentation: C %d, K %d\n",harq_process->C,harq_process->K); #endif + Kr = harq_process->K; + Kr_bytes = Kr>>3; + offset = 0; for (r=0; rC; r++) { From b95ea5942192c7a618b5eca38f2c8e23a08d4fbc Mon Sep 17 00:00:00 2001 From: Guido Casati Date: Fri, 11 Sep 2020 11:43:57 +0200 Subject: [PATCH 33/96] ulsim fix: missing qam_mod_order in UL PUSCH PDU --- openair1/SIMULATION/NR_PHY/ulsim.c | 1 + 1 file changed, 1 insertion(+) diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c index d7665368cd..fafd1fd22c 100644 --- a/openair1/SIMULATION/NR_PHY/ulsim.c +++ b/openair1/SIMULATION/NR_PHY/ulsim.c @@ -881,6 +881,7 @@ int main(int argc, char **argv) ul_config.ul_config_list[0].pdu_type = FAPI_NR_UL_CONFIG_TYPE_PUSCH; ul_config.ul_config_list[0].pusch_config_pdu.rnti = n_rnti; ul_config.ul_config_list[0].pusch_config_pdu.pdu_bit_map = pdu_bit_map; + ul_config.ul_config_list[0].pusch_config_pdu.qam_mod_order = mod_order; ul_config.ul_config_list[0].pusch_config_pdu.rb_size = nb_rb; ul_config.ul_config_list[0].pusch_config_pdu.rb_start = start_rb; ul_config.ul_config_list[0].pusch_config_pdu.nr_of_symbols = nb_symb_sch; From 30f1f947c67bdebc9ebe741de310bacdded2e8c1 Mon Sep 17 00:00:00 2001 From: Thomas Schlichter Date: Wed, 16 Sep 2020 10:08:10 +0200 Subject: [PATCH 34/96] fix some CPPCHECK errors and compile warnings use snprintf() instead of sprintf() to avoid writes outside buffer limits --- .../NR_UE_TRANSPORT/nr_dlsch_demodulation.c | 76 +++++++++---------- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 5 +- 2 files changed, 41 insertions(+), 40 deletions(-) diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c index 6477dbd4f4..e8204ad0b5 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c @@ -1045,23 +1045,23 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, char filename[40]; uint8_t aa = 0; - sprintf(filename,"rxdataF0_symb_%d_nr_tti_rx_%d.m", symbol, nr_tti_rx); + snprintf(filename, 40, "rxdataF0_symb_%d_nr_tti_rx_%d.m", symbol, nr_tti_rx); write_output(filename, "rxdataF0", &common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[nr_tti_rx]].rxdataF[0][0], NR_SYMBOLS_PER_SLOT*frame_parms->ofdm_symbol_size, 1, 1); - sprintf(filename,"dl_ch_estimates0%d_symb_%d_nr_tti_rx_%d.m", aa, symbol, nr_tti_rx); + snprintf(filename, 40, "dl_ch_estimates0%d_symb_%d_nr_tti_rx_%d.m", aa, symbol, nr_tti_rx); write_output(filename, "dl_ch_estimates", &pdsch_vars[eNB_id]->dl_ch_estimates[aa][0], NR_SYMBOLS_PER_SLOT*frame_parms->ofdm_symbol_size, 1, 1); - sprintf(filename,"rxdataF_ext0%d_symb_%d_nr_tti_rx_%d.m", aa, symbol, nr_tti_rx); + snprintf(filename, 40, "rxdataF_ext0%d_symb_%d_nr_tti_rx_%d.m", aa, symbol, nr_tti_rx); write_output(filename, "rxdataF_ext", &pdsch_vars[eNB_id]->rxdataF_ext[aa][0], NR_SYMBOLS_PER_SLOT*frame_parms->N_RB_DL*NR_NB_SC_PER_RB, 1, 1); - sprintf(filename,"dl_ch_estimates_ext0%d_symb_%d_nr_tti_rx_%d.m", aa, symbol, nr_tti_rx); + snprintf(filename, 40, "dl_ch_estimates_ext0%d_symb_%d_nr_tti_rx_%d.m", aa, symbol, nr_tti_rx); write_output(filename, "dl_ch_estimates_ext00", &pdsch_vars[eNB_id]->dl_ch_estimates_ext[aa][0], NR_SYMBOLS_PER_SLOT*frame_parms->N_RB_DL*NR_NB_SC_PER_RB, 1, 1); - sprintf(filename,"rxdataF_comp0%d_symb_%d_nr_tti_rx_%d.m", aa, symbol, nr_tti_rx); + snprintf(filename, 40, "rxdataF_comp0%d_symb_%d_nr_tti_rx_%d.m", aa, symbol, nr_tti_rx); write_output(filename, "rxdataF_comp00", &pdsch_vars[eNB_id]->rxdataF_comp0[aa][0], NR_SYMBOLS_PER_SLOT*frame_parms->N_RB_DL*NR_NB_SC_PER_RB, 1, 1); for (int i=0; i < 2; i++){ - sprintf(filename, "llr%d_symb_%d_nr_tti_rx_%d.m", i, symbol, nr_tti_rx); + snprintf(filename, 40, "llr%d_symb_%d_nr_tti_rx_%d.m", i, symbol, nr_tti_rx); write_output(filename,"llr", &pdsch_vars[eNB_id]->llr[i][0], (NR_SYMBOLS_PER_SLOT*nb_rb*NR_NB_SC_PER_RB*dlsch1_harq->Qm) - 4*(nb_rb*4*dlsch1_harq->Qm), 1, 0); } #endif @@ -2557,51 +2557,51 @@ void dump_dlsch2(PHY_VARS_UE *ue,uint8_t eNB_id,uint8_t nr_tti_rx,unsigned int * char fname[32],vname[32]; int N_RB_DL=ue->frame_parms.N_RB_DL; - sprintf(fname,"dlsch%d_rxF_r%d_ext0.m",eNB_id,round); - sprintf(vname,"dl%d_rxF_r%d_ext0",eNB_id,round); + snprintf(fname, 32, "dlsch%d_rxF_r%d_ext0.m",eNB_id,round); + snprintf(vname, 32, "dl%d_rxF_r%d_ext0",eNB_id,round); write_output(fname,vname,ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id]->rxdataF_ext[0],12*N_RB_DL*nsymb,1,1); if (ue->frame_parms.nb_antennas_rx >1) { - sprintf(fname,"dlsch%d_rxF_r%d_ext1.m",eNB_id,round); - sprintf(vname,"dl%d_rxF_r%d_ext1",eNB_id,round); + snprintf(fname, 32, "dlsch%d_rxF_r%d_ext1.m",eNB_id,round); + snprintf(vname, 32, "dl%d_rxF_r%d_ext1",eNB_id,round); write_output(fname,vname,ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id]->rxdataF_ext[1],12*N_RB_DL*nsymb,1,1); } - sprintf(fname,"dlsch%d_ch_r%d_ext00.m",eNB_id,round); - sprintf(vname,"dl%d_ch_r%d_ext00",eNB_id,round); + snprintf(fname, 32, "dlsch%d_ch_r%d_ext00.m",eNB_id,round); + snprintf(vname, 32, "dl%d_ch_r%d_ext00",eNB_id,round); write_output(fname,vname,ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id]->dl_ch_estimates_ext[0],12*N_RB_DL*nsymb,1,1); if (ue->transmission_mode[eNB_id]==7){ - sprintf(fname,"dlsch%d_bf_ch_r%d.m",eNB_id,round); - sprintf(vname,"dl%d_bf_ch_r%d",eNB_id,round); + snprintf(fname, 32, "dlsch%d_bf_ch_r%d.m",eNB_id,round); + snprintf(vname, 32, "dl%d_bf_ch_r%d",eNB_id,round); write_output(fname,vname,ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id]->dl_bf_ch_estimates[0],512*nsymb,1,1); //write_output(fname,vname,phy_vars_ue->lte_ue_pdsch_vars[eNB_id]->dl_bf_ch_estimates[0],512,1,1); - sprintf(fname,"dlsch%d_bf_ch_r%d_ext00.m",eNB_id,round); - sprintf(vname,"dl%d_bf_ch_r%d_ext00",eNB_id,round); + snprintf(fname, 32, "dlsch%d_bf_ch_r%d_ext00.m",eNB_id,round); + snprintf(vname, 32, "dl%d_bf_ch_r%d_ext00",eNB_id,round); write_output(fname,vname,ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id]->dl_bf_ch_estimates_ext[0],12*N_RB_DL*nsymb,1,1); } if (ue->frame_parms.nb_antennas_rx == 2) { - sprintf(fname,"dlsch%d_ch_r%d_ext01.m",eNB_id,round); - sprintf(vname,"dl%d_ch_r%d_ext01",eNB_id,round); + snprintf(fname, 32, "dlsch%d_ch_r%d_ext01.m",eNB_id,round); + snprintf(vname, 32, "dl%d_ch_r%d_ext01",eNB_id,round); write_output(fname,vname,ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id]->dl_ch_estimates_ext[1],12*N_RB_DL*nsymb,1,1); } if (ue->frame_parms.nb_antenna_ports_gNB == 2) { - sprintf(fname,"dlsch%d_ch_r%d_ext10.m",eNB_id,round); - sprintf(vname,"dl%d_ch_r%d_ext10",eNB_id,round); + snprintf(fname, 32, "dlsch%d_ch_r%d_ext10.m",eNB_id,round); + snprintf(vname, 32, "dl%d_ch_r%d_ext10",eNB_id,round); write_output(fname,vname,ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id]->dl_ch_estimates_ext[2],12*N_RB_DL*nsymb,1,1); if (ue->frame_parms.nb_antennas_rx == 2) { - sprintf(fname,"dlsch%d_ch_r%d_ext11.m",eNB_id,round); - sprintf(vname,"dl%d_ch_r%d_ext11",eNB_id,round); + snprintf(fname, 32, "dlsch%d_ch_r%d_ext11.m",eNB_id,round); + snprintf(vname, 32, "dl%d_ch_r%d_ext11",eNB_id,round); write_output(fname,vname,ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id]->dl_ch_estimates_ext[3],12*N_RB_DL*nsymb,1,1); } } - sprintf(fname,"dlsch%d_rxF_r%d_uespec0.m",eNB_id,round); - sprintf(vname,"dl%d_rxF_r%d_uespec0",eNB_id,round); + snprintf(fname, 32, "dlsch%d_rxF_r%d_uespec0.m",eNB_id,round); + snprintf(vname, 32, "dl%d_rxF_r%d_uespec0",eNB_id,round); write_output(fname,vname,ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id]->rxdataF_uespec_pilots[0],12*N_RB_DL,1,1); /* @@ -2609,33 +2609,33 @@ void dump_dlsch2(PHY_VARS_UE *ue,uint8_t eNB_id,uint8_t nr_tti_rx,unsigned int * write_output("dlsch%d_ch_ext10.m","dl10_ch0_ext",pdsch_vars[eNB_id]->dl_ch_estimates_ext[2],12*N_RB_DL*nsymb,1,1); write_output("dlsch%d_ch_ext11.m","dl11_ch0_ext",pdsch_vars[eNB_id]->dl_ch_estimates_ext[3],12*N_RB_DL*nsymb,1,1); */ - sprintf(fname,"dlsch%d_r%d_rho.m",eNB_id,round); - sprintf(vname,"dl_rho_r%d_%d",eNB_id,round); + snprintf(fname, 32, "dlsch%d_r%d_rho.m",eNB_id,round); + snprintf(vname, 32, "dl_rho_r%d_%d",eNB_id,round); write_output(fname,vname,ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id]->dl_ch_rho_ext[harq_pid][round][0],12*N_RB_DL*nsymb,1,1); - sprintf(fname,"dlsch%d_r%d_rho2.m",eNB_id,round); - sprintf(vname,"dl_rho2_r%d_%d",eNB_id,round); + snprintf(fname, 32, "dlsch%d_r%d_rho2.m",eNB_id,round); + snprintf(vname, 32, "dl_rho2_r%d_%d",eNB_id,round); write_output(fname,vname,ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id]->dl_ch_rho2_ext[0],12*N_RB_DL*nsymb,1,1); - sprintf(fname,"dlsch%d_rxF_r%d_comp0.m",eNB_id,round); - sprintf(vname,"dl%d_rxF_r%d_comp0",eNB_id,round); + snprintf(fname, 32, "dlsch%d_rxF_r%d_comp0.m",eNB_id,round); + snprintf(vname, 32, "dl%d_rxF_r%d_comp0",eNB_id,round); write_output(fname,vname,ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id]->rxdataF_comp0[0],12*N_RB_DL*nsymb,1,1); if (ue->frame_parms.nb_antenna_ports_gNB == 2) { - sprintf(fname,"dlsch%d_rxF_r%d_comp1.m",eNB_id,round); - sprintf(vname,"dl%d_rxF_r%d_comp1",eNB_id,round); + snprintf(fname, 32, "dlsch%d_rxF_r%d_comp1.m",eNB_id,round); + snprintf(vname, 32, "dl%d_rxF_r%d_comp1",eNB_id,round); write_output(fname,vname,ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id]->rxdataF_comp1[harq_pid][round][0],12*N_RB_DL*nsymb,1,1); } - sprintf(fname,"dlsch%d_rxF_r%d_llr.m",eNB_id,round); - sprintf(vname,"dl%d_r%d_llr",eNB_id,round); + snprintf(fname, 32, "dlsch%d_rxF_r%d_llr.m",eNB_id,round); + snprintf(vname, 32, "dl%d_r%d_llr",eNB_id,round); write_output(fname,vname, ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id]->llr[0],coded_bits_per_codeword[0],1,0); - sprintf(fname,"dlsch%d_r%d_mag1.m",eNB_id,round); - sprintf(vname,"dl%d_r%d_mag1",eNB_id,round); + snprintf(fname, 32, "dlsch%d_r%d_mag1.m",eNB_id,round); + snprintf(vname, 32, "dl%d_r%d_mag1",eNB_id,round); write_output(fname,vname,ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id]->dl_ch_mag0[0],12*N_RB_DL*nsymb,1,1); - sprintf(fname,"dlsch%d_r%d_mag2.m",eNB_id,round); - sprintf(vname,"dl%d_r%d_mag2",eNB_id,round); + snprintf(fname, 32, "dlsch%d_r%d_mag2.m",eNB_id,round); + snprintf(vname, 32, "dl%d_r%d_mag2",eNB_id,round); write_output(fname,vname,ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id]->dl_ch_magb0[0],12*N_RB_DL*nsymb,1,1); // printf("log2_maxh = %d\n",ue->pdsch_vars[eNB_id]->log2_maxh); diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index 469de18388..fab5e1db94 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -51,9 +51,10 @@ #include "NR_MAC_UE/mac_extern.h" #include "common/utils/nr/nr_common.h" -/* PHY UE */ +/* PHY */ #include "SCHED_NR_UE/defs.h" #include "PHY/defs_nr_UE.h" +#include "PHY/NR_TRANSPORT/nr_dci.h" /*Openair Packet Tracer */ #include "UTIL/OPT/opt.h" @@ -3226,7 +3227,7 @@ void nr_ue_send_sdu(module_id_t module_idP, // N_RB configuration according to 7.3.1.0 (DCI size alignment) of TS 38.212 int get_n_rb(NR_UE_MAC_INST_t *mac, int rnti_type){ - int N_RB, start_RB; + int N_RB = 0, start_RB; switch(rnti_type) { case NR_RNTI_RA: case NR_RNTI_TC: From 76d841ff89136347fad077f3f43f8a6b83fd4c59 Mon Sep 17 00:00:00 2001 From: Sakthivel Velumani Date: Wed, 16 Sep 2020 16:24:58 +0200 Subject: [PATCH 35/96] fixed ulschsim --- cmake_targets/CMakeLists.txt | 1 + openair1/PHY/NR_TRANSPORT/nr_ulsch.h | 3 +++ openair1/SCHED_NR/phy_procedures_nr_gNB.c | 7 +++++-- openair1/SIMULATION/NR_PHY/ulschsim.c | 15 +++++++++++++-- 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index 2b58d762b9..846f786d9b 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -3047,6 +3047,7 @@ target_link_libraries(nr_prachsim add_executable(nr_ulschsim ${OPENAIR1_DIR}/SIMULATION/NR_PHY/ulschsim.c + ${OPENAIR_DIR}/common/utils/threadPool/thread-pool.c ${OPENAIR_DIR}/common/utils/utils.c ${OPENAIR_DIR}/common/utils/system.c ${OPENAIR_DIR}/common/utils/nr/nr_common.c diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch.h b/openair1/PHY/NR_TRANSPORT/nr_ulsch.h index a9845b6bbb..992ea51076 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_ulsch.h +++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch.h @@ -31,6 +31,7 @@ */ #include "PHY/defs_gNB.h" +#include "common/utils/threadPool/thread-pool.h" void free_gNB_ulsch(NR_gNB_ULSCH_t **ulsch,uint8_t N_RB_UL); @@ -91,3 +92,5 @@ int16_t find_nr_ulsch(uint16_t rnti, PHY_VARS_gNB *gNB,find_type_t type); void dump_pusch_stats(PHY_VARS_gNB *gNB); void clear_pusch_stats(PHY_VARS_gNB *gNB); + +int nr_postDecode(PHY_VARS_gNB *gNB, notifiedFIFO_elt_t *req, bool do_fill_ind); diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index 5853b2d1dc..8ad2d23aae 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -213,7 +213,7 @@ void phy_procedures_gNB_TX(PHY_VARS_gNB *gNB, */ -void nr_postDecode(PHY_VARS_gNB *gNB, notifiedFIFO_elt_t *req) { +int nr_postDecode(PHY_VARS_gNB *gNB, notifiedFIFO_elt_t *req, bool do_fill_ind) { ldpcDecode_t *rdata = (ldpcDecode_t*) NotifiedFifoData(req); NR_UL_gNB_HARQ_t *ulsch_harq = rdata->ulsch_harq; NR_gNB_ULSCH_t *ulsch = rdata->ulsch; @@ -241,12 +241,14 @@ void nr_postDecode(PHY_VARS_gNB *gNB, notifiedFIFO_elt_t *req) { AssertFatal(ulsch_harq->processedSegments+nb == rdata->nbSegments,"processed: %d, aborted: %d, total %d\n", ulsch_harq->processedSegments, nb, rdata->nbSegments); ulsch_harq->processedSegments=rdata->nbSegments; + if (!do_fill_ind) return 1; } } // if all segments are done if (rdata->nbSegments == ulsch_harq->processedSegments) { if (decodeSuccess) { + if (!do_fill_ind) return 0; LOG_D(PHY,"[gNB %d] ULSCH: Setting ACK for nr_tti_rx %d TBS %d\n", gNB->Mod_id,ulsch_harq->slot,ulsch_harq->TBS); ulsch_harq->status = SCH_IDLE; @@ -256,6 +258,7 @@ void nr_postDecode(PHY_VARS_gNB *gNB, notifiedFIFO_elt_t *req) { LOG_D(PHY, "ULSCH received ok \n"); nr_fill_indication(gNB,ulsch_harq->frame, ulsch_harq->slot, rdata->ulsch_id, rdata->harq_pid, 0); } else { + if (!do_fill_ind) return 1; LOG_D(PHY,"[gNB %d] ULSCH: Setting NAK for SFN/SF %d/%d (pid %d, status %d, round %d, TBS %d) r %d\n", gNB->Mod_id, ulsch_harq->frame, ulsch_harq->slot, rdata->harq_pid,ulsch_harq->status, ulsch_harq->round,ulsch_harq->TBS,r); @@ -345,7 +348,7 @@ void nr_ulsch_procedures(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, int ULSCH while (gNB->nbDecode > 0) { notifiedFIFO_elt_t *req=pullTpool(gNB->respDecode, gNB->threadPool); - nr_postDecode(gNB, req); + nr_postDecode(gNB, req, 1); delNotifiedFIFO_elt(req); } stop_meas(&gNB->ulsch_decoding_stats); diff --git a/openair1/SIMULATION/NR_PHY/ulschsim.c b/openair1/SIMULATION/NR_PHY/ulschsim.c index f6d33c1d4b..ed65c18d9e 100644 --- a/openair1/SIMULATION/NR_PHY/ulschsim.c +++ b/openair1/SIMULATION/NR_PHY/ulschsim.c @@ -45,6 +45,7 @@ #include "openair1/SIMULATION/RF/rf.h" #include "openair1/SIMULATION/NR_PHY/nr_unitary_defs.h" #include "openair1/SIMULATION/NR_PHY/nr_dummy_functions.c" +#include "common/utils/threadPool/thread-pool.h" //#define DEBUG_NR_ULSCHSIM @@ -338,6 +339,11 @@ int main(int argc, char **argv) gNB = RC.gNB[0]; //gNB_config = &gNB->gNB_config; + gNB->threadPool = (tpool_t*)malloc(sizeof(tpool_t)); + gNB->respDecode = (notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t)); + char tp_param[] = "n"; + initTpool(tp_param, gNB->threadPool, true); + initNotifiedFIFO(gNB->respDecode); frame_parms = &gNB->frame_parms; //to be initialized I suppose (maybe not necessary for PBCH) frame_parms->nb_antennas_tx = n_tx; frame_parms->nb_antennas_rx = n_rx; @@ -531,10 +537,15 @@ int main(int argc, char **argv) rel15_ul->qam_mod_order, rel15_ul->nrOfLayers); - ret = nr_ulsch_decoding(gNB, UE_id, channel_output_fixed, frame_parms, rel15_ul, + nr_ulsch_decoding(gNB, UE_id, channel_output_fixed, frame_parms, rel15_ul, frame, subframe, harq_pid, G); + while (gNB->nbDecode > 0) { + notifiedFIFO_elt_t *req=pullTpool(gNB->respDecode, gNB->threadPool); + ret = nr_postDecode(gNB, req, 0); + delNotifiedFIFO_elt(req); + } - if (ret > ulsch_gNB->max_ldpc_iterations) + if (ret) n_errors++; //count errors From db5011922da58f314e3f16d01f32ebe62dd7bed9 Mon Sep 17 00:00:00 2001 From: Sakthivel Velumani Date: Wed, 16 Sep 2020 17:59:49 +0200 Subject: [PATCH 36/96] ulschsim works --- openair1/PHY/NR_TRANSPORT/nr_ulsch.h | 2 -- openair1/SCHED_NR/phy_procedures_nr_gNB.c | 7 ++-- openair1/SIMULATION/NR_PHY/ulschsim.c | 39 ++++++++++++++++++++++- 3 files changed, 40 insertions(+), 8 deletions(-) diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch.h b/openair1/PHY/NR_TRANSPORT/nr_ulsch.h index 992ea51076..de9b5f48c3 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_ulsch.h +++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch.h @@ -92,5 +92,3 @@ int16_t find_nr_ulsch(uint16_t rnti, PHY_VARS_gNB *gNB,find_type_t type); void dump_pusch_stats(PHY_VARS_gNB *gNB); void clear_pusch_stats(PHY_VARS_gNB *gNB); - -int nr_postDecode(PHY_VARS_gNB *gNB, notifiedFIFO_elt_t *req, bool do_fill_ind); diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index 8ad2d23aae..5853b2d1dc 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -213,7 +213,7 @@ void phy_procedures_gNB_TX(PHY_VARS_gNB *gNB, */ -int nr_postDecode(PHY_VARS_gNB *gNB, notifiedFIFO_elt_t *req, bool do_fill_ind) { +void nr_postDecode(PHY_VARS_gNB *gNB, notifiedFIFO_elt_t *req) { ldpcDecode_t *rdata = (ldpcDecode_t*) NotifiedFifoData(req); NR_UL_gNB_HARQ_t *ulsch_harq = rdata->ulsch_harq; NR_gNB_ULSCH_t *ulsch = rdata->ulsch; @@ -241,14 +241,12 @@ int nr_postDecode(PHY_VARS_gNB *gNB, notifiedFIFO_elt_t *req, bool do_fill_ind) AssertFatal(ulsch_harq->processedSegments+nb == rdata->nbSegments,"processed: %d, aborted: %d, total %d\n", ulsch_harq->processedSegments, nb, rdata->nbSegments); ulsch_harq->processedSegments=rdata->nbSegments; - if (!do_fill_ind) return 1; } } // if all segments are done if (rdata->nbSegments == ulsch_harq->processedSegments) { if (decodeSuccess) { - if (!do_fill_ind) return 0; LOG_D(PHY,"[gNB %d] ULSCH: Setting ACK for nr_tti_rx %d TBS %d\n", gNB->Mod_id,ulsch_harq->slot,ulsch_harq->TBS); ulsch_harq->status = SCH_IDLE; @@ -258,7 +256,6 @@ int nr_postDecode(PHY_VARS_gNB *gNB, notifiedFIFO_elt_t *req, bool do_fill_ind) LOG_D(PHY, "ULSCH received ok \n"); nr_fill_indication(gNB,ulsch_harq->frame, ulsch_harq->slot, rdata->ulsch_id, rdata->harq_pid, 0); } else { - if (!do_fill_ind) return 1; LOG_D(PHY,"[gNB %d] ULSCH: Setting NAK for SFN/SF %d/%d (pid %d, status %d, round %d, TBS %d) r %d\n", gNB->Mod_id, ulsch_harq->frame, ulsch_harq->slot, rdata->harq_pid,ulsch_harq->status, ulsch_harq->round,ulsch_harq->TBS,r); @@ -348,7 +345,7 @@ void nr_ulsch_procedures(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, int ULSCH while (gNB->nbDecode > 0) { notifiedFIFO_elt_t *req=pullTpool(gNB->respDecode, gNB->threadPool); - nr_postDecode(gNB, req, 1); + nr_postDecode(gNB, req); delNotifiedFIFO_elt(req); } stop_meas(&gNB->ulsch_decoding_stats); diff --git a/openair1/SIMULATION/NR_PHY/ulschsim.c b/openair1/SIMULATION/NR_PHY/ulschsim.c index ed65c18d9e..db18b1ebb7 100644 --- a/openair1/SIMULATION/NR_PHY/ulschsim.c +++ b/openair1/SIMULATION/NR_PHY/ulschsim.c @@ -68,6 +68,43 @@ PHY_VARS_NR_UE *PHY_vars_UE_g[1][1] = { { NULL } }; uint16_t n_rnti = 0x1234; openair0_config_t openair0_cfg[MAX_CARDS]; +int nr_postDecode_sim(PHY_VARS_gNB *gNB, notifiedFIFO_elt_t *req) { + ldpcDecode_t *rdata = (ldpcDecode_t*) NotifiedFifoData(req); + NR_UL_gNB_HARQ_t *ulsch_harq = rdata->ulsch_harq; + NR_gNB_ULSCH_t *ulsch = rdata->ulsch; + int r = rdata->segment_r; + + bool decodeSuccess = (rdata->decodeIterations <= rdata->decoderParms.numMaxIter); + ulsch_harq->processedSegments++; + gNB->nbDecode--; + + if (decodeSuccess) { + memcpy(ulsch_harq->b+rdata->offset, + ulsch_harq->c[r], + rdata->Kr_bytes- - (ulsch_harq->F>>3) -((ulsch_harq->C>1)?3:0)); + } else { + if ( rdata->nbSegments != ulsch_harq->processedSegments ) { + int nb=abortTpool(gNB->threadPool, req->key); + nb+=abortNotifiedFIFO(gNB->respDecode, req->key); + gNB->nbDecode-=nb; + AssertFatal(ulsch_harq->processedSegments+nb == rdata->nbSegments,"processed: %d, aborted: %d, total %d\n", + ulsch_harq->processedSegments, nb, rdata->nbSegments); + ulsch_harq->processedSegments=rdata->nbSegments; + return 1; + } + } + + // if all segments are done + if (rdata->nbSegments == ulsch_harq->processedSegments) { + if (decodeSuccess) { + return 0; + } else { + return 1; + } + + } + ulsch->last_iteration_cnt = rdata->decodeIterations; +} int main(int argc, char **argv) { char c; @@ -541,7 +578,7 @@ int main(int argc, char **argv) frame, subframe, harq_pid, G); while (gNB->nbDecode > 0) { notifiedFIFO_elt_t *req=pullTpool(gNB->respDecode, gNB->threadPool); - ret = nr_postDecode(gNB, req, 0); + ret = nr_postDecode_sim(gNB, req); delNotifiedFIFO_elt(req); } From 6ff951be08386238d838acf1d22c66cc8911e7ec Mon Sep 17 00:00:00 2001 From: Sakthivel Velumani Date: Thu, 17 Sep 2020 17:09:15 +0200 Subject: [PATCH 37/96] wait before abandoning next trx processing --- executables/nr-gnb.c | 44 ++++++++++++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 14 deletions(-) diff --git a/executables/nr-gnb.c b/executables/nr-gnb.c index 35325668dc..79c43671dd 100644 --- a/executables/nr-gnb.c +++ b/executables/nr-gnb.c @@ -545,6 +545,8 @@ int wakeup_rxtx(PHY_VARS_gNB *gNB,RU_t *ru) { int i; struct timespec abstime; int time_ns = 50000; + int wait_timer = 0; + bool do_last_check = 1; AssertFatal((ret=pthread_mutex_lock(&proc->mutex_RU))==0,"mutex_lock returns %d\n",ret); for (i=0; inum_RU; i++) { @@ -565,22 +567,36 @@ int wakeup_rxtx(PHY_VARS_gNB *gNB,RU_t *ru) { AssertFatal((ret=pthread_mutex_unlock(&proc->mutex_RU))==0,"muex_unlock returns %d\n",ret); } - clock_gettime(CLOCK_REALTIME, &abstime); - abstime.tv_nsec = abstime.tv_nsec + time_ns; - - if (abstime.tv_nsec >= 1000*1000*1000) { - abstime.tv_nsec -= 1000*1000*1000; - abstime.tv_sec += 1; - } - // wake up TX for subframe n+sf_ahead // lock the TX mutex and make sure the thread is ready - AssertFatal((ret=pthread_mutex_timedlock(&L1_proc->mutex, &abstime)) == 0,"mutex_lock returns %d\n", ret); + while (wait_timer < 200) { + clock_gettime(CLOCK_REALTIME, &abstime); + abstime.tv_nsec = abstime.tv_nsec + time_ns; - if (L1_proc->instance_cnt == 0) { // L1_thread is busy so abort the subframe - AssertFatal((ret=pthread_mutex_unlock( &L1_proc->mutex))==0,"muex_unlock return %d\n",ret); - LOG_W(PHY,"L1_thread isn't ready in %d.%d, aborting RX processing\n",ru_proc->frame_rx,ru_proc->tti_rx); - return(-1); + if (abstime.tv_nsec >= 1000*1000*1000) { + abstime.tv_nsec -= 1000*1000*1000; + abstime.tv_sec += 1; + } + + AssertFatal((ret=pthread_mutex_timedlock(&L1_proc->mutex, &abstime)) == 0,"mutex_lock returns %d\n", ret); + + if (L1_proc->instance_cnt == 0) { // L1_thread is busy so wait for a bit + AssertFatal((ret=pthread_mutex_unlock( &L1_proc->mutex))==0,"muex_unlock return %d\n",ret); + wait_timer += 50; + usleep(50); + } + else { + do_last_check = 0; + break; + } + } + if (do_last_check) { + AssertFatal((ret=pthread_mutex_timedlock(&L1_proc->mutex, &abstime)) == 0,"mutex_lock returns %d\n", ret); + if (L1_proc->instance_cnt == 0) { // L1_thread is busy so abort the subframe + AssertFatal((ret=pthread_mutex_unlock( &L1_proc->mutex))==0,"muex_unlock return %d\n",ret); + LOG_W(PHY,"L1_thread isn't ready in %d.%d, aborting RX processing\n",ru_proc->frame_rx,ru_proc->tti_rx); + return (-1); + } } ++L1_proc->instance_cnt; @@ -796,7 +812,7 @@ void init_gNB_proc(int inst) { gNB->threadPool = (tpool_t*)malloc(sizeof(tpool_t)); gNB->respDecode = (notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t)); - char ul_pool[] = "-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1"; + char ul_pool[] = "-1,-1,-1,-1,-1,-1,-1,-1"; initTpool(ul_pool, gNB->threadPool, false); initNotifiedFIFO(gNB->respDecode); } From c91d689d8c4a167233dcf8a982f41514c41cb31e Mon Sep 17 00:00:00 2001 From: Shweta Shrivastava Date: Thu, 17 Sep 2020 22:31:32 -0500 Subject: [PATCH 38/96] Imrpovements for extracting UL DCI, remove hardcoding, blind decoding of DCI --- .../nfapi/public_inc/fapi_nr_ue_interface.h | 10 +- openair1/PHY/NR_UE_TRANSPORT/dci_nr.c | 67 ++-- .../NR_MAC_UE/nr_ue_dci_configuration.c | 20 +- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 371 ++++++++++++------ openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c | 2 +- 5 files changed, 317 insertions(+), 153 deletions(-) diff --git a/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h b/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h index 246ab13e86..10058c441e 100644 --- a/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h +++ b/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h @@ -415,8 +415,14 @@ typedef struct { uint8_t number_of_candidates; uint16_t CCE[64]; uint8_t L[64]; - uint8_t dci_length; - uint8_t dci_format; + // 3GPP TS 38.212 Sec. 7.3.1.0, 3GPP TS 138.131 sec. 6.3.2 (SearchSpace) + // The maximum number of DCI lengths allowed by the spec are 4, with max 3 for C-RNTI. + // But a given search space may only support a maximum of 2 DCI formats at a time + // depending on its search space type configured by RRC. Hence for blind decoding, UE + // needs to monitor only upto 2 DCI lengths for a given search space. + uint8_t num_dci_options; // Num DCIs the UE actually needs to decode (1 or 2) + uint8_t dci_length_options[2]; + uint8_t dci_format_options[2]; } fapi_nr_dl_config_dci_dl_pdu_rel15_t; typedef struct { diff --git a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c index 7cde6e31c1..53456bb691 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c @@ -845,7 +845,6 @@ uint8_t nr_dci_decoding_procedure(PHY_VARS_NR_UE *ue, for (int i=0;inb_search_space;i++) { rel15 = &pdcch_vars->pdcch_config[i]; - int dci_length = rel15->dci_length; //int gNB_id = 0; int16_t tmp_e[16*108]; rnti_t n_rnti; @@ -853,41 +852,47 @@ uint8_t nr_dci_decoding_procedure(PHY_VARS_NR_UE *ue, for (int j=0;jnumber_of_candidates;j++) { int CCEind = rel15->CCE[j]; int L = rel15->L[j]; - uint64_t dci_estimation[2]= {0}; - const t_nrPolar_params *currentPtrDCI = nr_polar_params(NR_POLAR_DCI_MESSAGE_TYPE, dci_length, L, 1, &ue->polarList); - LOG_D(PHY, "Trying DCI candidate %d of %d number of candidates, CCE %d (%d), L %d\n", j, rel15->number_of_candidates, CCEind, CCEind*9*6*2, L); + // Loop over possible DCI lengths + for (int k = 0; k < rel15->num_dci_options; k++) { + int dci_length = rel15->dci_length_options[k]; + uint64_t dci_estimation[2]= {0}; + const t_nrPolar_params *currentPtrDCI = nr_polar_params(NR_POLAR_DCI_MESSAGE_TYPE, dci_length, L, 1, &ue->polarList); - nr_pdcch_unscrambling(&pdcch_vars->e_rx[CCEind*108], rel15->coreset.scrambling_rnti, L*108, rel15->coreset.pdcch_dmrs_scrambling_id, tmp_e); + LOG_D(PHY, "Trying DCI candidate %d of %d number of candidates, CCE %d (%d), L %d\n", j, rel15->number_of_candidates, CCEind, CCEind*9*6*2, L); - #ifdef DEBUG_DCI_DECODING - uint32_t * z = (uint32_t *) &pdcch_vars->e_rx[CCEind*108]; - for (int index_z = 0; index_z < 96; index_z++){ - for (int i=0; i<9; i++) { - LOG_D(PHY,"z[%d]=(%d,%d) \n", (9*index_z + i), *(int16_t *) &z[index_z + i],*(1 + (int16_t *) &z[index_z + i])); + nr_pdcch_unscrambling(&pdcch_vars->e_rx[CCEind*108], rel15->coreset.scrambling_rnti, L*108, rel15->coreset.pdcch_dmrs_scrambling_id, tmp_e); + + #ifdef DEBUG_DCI_DECODING + uint32_t * z = (uint32_t *) &pdcch_vars->e_rx[CCEind*108]; + for (int index_z = 0; index_z < 96; index_z++){ + for (int i=0; i<9; i++) { + LOG_D(PHY,"z[%d]=(%d,%d) \n", (9*index_z + i), *(int16_t *) &z[index_z + i],*(1 + (int16_t *) &z[index_z + i])); + } } + #endif + + uint16_t crc = polar_decoder_int16(tmp_e, + dci_estimation, + 1, + currentPtrDCI); + + n_rnti = rel15->rnti; + + if (crc == n_rnti) { + LOG_D(PHY,"Decoded crc %x matches rnti %x for DCI format %d\n", crc, n_rnti, rel15->dci_format_options[k]); + dci_ind->SFN = frame; + dci_ind->slot = slot; + dci_ind->dci_list[dci_ind->number_of_dcis].rnti = n_rnti; + dci_ind->dci_list[dci_ind->number_of_dcis].n_CCE = CCEind; + dci_ind->dci_list[dci_ind->number_of_dcis].dci_format = rel15->dci_format_options[k]; + dci_ind->dci_list[dci_ind->number_of_dcis].payloadSize = dci_length; + memcpy((void*)dci_ind->dci_list[dci_ind->number_of_dcis].payloadBits,(void*)dci_estimation,8); + dci_ind->number_of_dcis++; + break; // If DCI is found, no need to check for remaining DCI lengths + } else { + LOG_D(PHY,"Decoded crc %x does not match rnti %x for DCI format %d\n", crc, n_rnti, rel15->dci_format_options[k]); } - #endif - - uint16_t crc = polar_decoder_int16(tmp_e, - dci_estimation, - 1, - currentPtrDCI); - - n_rnti = rel15->rnti; - - if (crc == n_rnti) { - LOG_D(PHY,"Decoded crc %x matches rnti %x for DCI format %d\n", crc, n_rnti, rel15->dci_format); - dci_ind->SFN = frame; - dci_ind->slot = slot; - dci_ind->dci_list[dci_ind->number_of_dcis].rnti = n_rnti; - dci_ind->dci_list[dci_ind->number_of_dcis].n_CCE = CCEind; - dci_ind->dci_list[dci_ind->number_of_dcis].dci_format = rel15->dci_format; - dci_ind->dci_list[dci_ind->number_of_dcis].payloadSize = dci_length; - memcpy((void*)dci_ind->dci_list[dci_ind->number_of_dcis].payloadBits,(void*)dci_estimation,8); - dci_ind->number_of_dcis++; - } else { - LOG_D(PHY,"Decoded crc %x does not match rnti %x for DCI format %d\n", crc, n_rnti, rel15->dci_format); } } } diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c index 2285fc5999..afa4980c5c 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c @@ -64,7 +64,7 @@ void fill_dci_search_candidates(NR_SearchSpace_t *ss,fapi_nr_dl_config_dci_dl_pd } -void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15, fapi_nr_dl_config_request_t *dl_config, int rnti_type, int ss_id, uint8_t dci_format){ +void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15, fapi_nr_dl_config_request_t *dl_config, int rnti_type, int ss_id){ uint16_t monitoringSymbolsWithinSlot; uint8_t bwp_id = 1, coreset_id = 1; @@ -76,9 +76,6 @@ void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t NR_BWP_DownlinkCommon_t *initialDownlinkBWP = scc->downlinkConfigCommon->initialDownlinkBWP; NR_SearchSpace_t *ss = mac->SSpace[bwp_id - 1][coreset_id - 1][ss_id]; - // DCI format configuration - rel15->dci_format = dci_format; - // CORESET configuration NR_ControlResourceSet_t *coreset = mac->coreset[bwp_id - 1][coreset_id - 1]; rel15->coreset.duration = coreset->duration; @@ -123,7 +120,9 @@ void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t rel15->BWPSize = NRRIV2BW(bwp_Common->genericParameters.locationAndBandwidth, 275); rel15->BWPStart = NRRIV2PRBOFFSET(bwp_Common->genericParameters.locationAndBandwidth, 275); rel15->SubcarrierSpacing = bwp_Common->genericParameters.subcarrierSpacing; - rel15->dci_length = nr_dci_size(scc, mac->scg, def_dci_pdu_rel15, rel15->dci_format, NR_RNTI_C, rel15->BWPSize, bwp_id); + for (int i = 0; i < rel15->num_dci_options; i++) { + rel15->dci_length_options[i] = nr_dci_size(scc, mac->scg, def_dci_pdu_rel15, rel15->dci_format_options[i], NR_RNTI_C, rel15->BWPSize, bwp_id); + } break; case NR_RNTI_RA: // we use the initial DL BWP @@ -133,7 +132,7 @@ void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t rel15->BWPSize = NRRIV2BW(initialDownlinkBWP->genericParameters.locationAndBandwidth, 275); rel15->BWPStart = NRRIV2PRBOFFSET(bwp_Common->genericParameters.locationAndBandwidth, 275); //NRRIV2PRBOFFSET(initialDownlinkBWP->genericParameters.locationAndBandwidth, 275); rel15->SubcarrierSpacing = initialDownlinkBWP->genericParameters.subcarrierSpacing; - rel15->dci_length = nr_dci_size(scc, mac->scg, def_dci_pdu_rel15, rel15->dci_format, NR_RNTI_RA, rel15->BWPSize, bwp_id); + rel15->dci_length_options[0] = nr_dci_size(scc, mac->scg, def_dci_pdu_rel15, rel15->dci_format_options[0], NR_RNTI_RA, rel15->BWPSize, bwp_id); break; case NR_RNTI_P: break; @@ -215,7 +214,9 @@ void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl LOG_D(MAC, "[DCI_CONFIG] Configure monitoring of PDCCH candidates in Type1-PDCCH common random access search space\n"); switch(mac->ra_state){ case WAIT_RAR: - config_dci_pdu(mac, rel15, dl_config, NR_RNTI_RA, ss_id, NR_DL_DCI_FORMAT_1_0); + rel15->num_dci_options = 1; + rel15->dci_format_options[0] = NR_DL_DCI_FORMAT_1_0; + config_dci_pdu(mac, rel15, dl_config, NR_RNTI_RA, ss_id); fill_dci_search_candidates(ss, rel15); break; case WAIT_CONTENTION_RESOLUTION: @@ -286,7 +287,10 @@ void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl // Monitors DCI 01 and 11 scrambled with C-RNTI, or CS-RNTI(s), or SP-CSI-RNTI if (get_softmodem_params()->phy_test == 1 && mac->crnti > 0) { LOG_D(MAC, "[DCI_CONFIG] Configure monitoring of PDCCH candidates in the user specific search space\n"); - config_dci_pdu(mac, rel15, dl_config, NR_RNTI_C, ss_id, NR_DL_DCI_FORMAT_1_1); + rel15->num_dci_options = 2; + rel15->dci_format_options[0] = NR_DL_DCI_FORMAT_1_1; + rel15->dci_format_options[1] = NR_UL_DCI_FORMAT_0_1; + config_dci_pdu(mac, rel15, dl_config, NR_RNTI_C, ss_id); fill_dci_search_candidates(ss, rel15); #ifdef DEBUG_DCI diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index ab533af941..a14d17f920 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -778,25 +778,27 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id); uint8_t access_mode = SCHEDULED_ACCESS; - // program PUSCH. this should actually be done upon reception of an UL DCI + // program PUSCH with UL DCI parameters nr_dcireq_t dcireq; nr_scheduled_response_t scheduled_response; fapi_nr_tx_request_t tx_req; fapi_nr_tx_request_body_t tx_req_body; - //--------------------------Temporary configuration-----------------------------// - uint16_t rnti = 0x1234; - uint32_t rb_size = 50; - uint32_t rb_start = 0; - uint8_t nr_of_symbols = 11; - uint8_t start_symbol_index = 0; + fapi_nr_ul_config_request_pdu_t *ulcfg_pdu = &mac->ul_config_request.ul_config_list[0]; + + uint16_t rnti = ulcfg_pdu->pusch_config_pdu.rnti; + uint32_t rb_size = ulcfg_pdu->pusch_config_pdu.rb_size; + uint32_t rb_start = ulcfg_pdu->pusch_config_pdu.rb_start; + uint8_t nr_of_symbols = ulcfg_pdu->pusch_config_pdu.nr_of_symbols; + uint8_t start_symbol_index = ulcfg_pdu->pusch_config_pdu.start_symbol_index; uint8_t nrOfLayers = 1; - uint8_t mcs_index = 9; uint8_t mcs_table = 0; - uint8_t harq_process_id = 0; - uint8_t rv_index = 0; + uint8_t mcs_index = ulcfg_pdu->pusch_config_pdu.mcs_index; + uint8_t harq_process_id = ulcfg_pdu->pusch_config_pdu.pusch_data.harq_process_id; + uint8_t rv_index = ulcfg_pdu->pusch_config_pdu.pusch_data.rv_index; uint16_t l_prime_mask = get_l_prime(nr_of_symbols, typeB, pusch_dmrs_pos0, pusch_len1); uint8_t dmrs_config_type = 0; + // These should come from RRC config!!! uint8_t ptrs_mcs1 = 2; uint8_t ptrs_mcs2 = 4; uint8_t ptrs_mcs3 = 10; @@ -808,7 +810,15 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in uint8_t no_data_in_dmrs = 1; uint16_t number_dmrs_symbols = 0; uint16_t ul_dmrs_symb_pos = l_prime_mask << start_symbol_index; - //------------------------------------------------------------------------------// + +#ifdef DEBUG_DCI + LOG_I(MAC, " UL config params \n rnti: %x \n rb_size: %d \n", + rnti, rb_size); + LOG_I(MAC, "rb_start: %x \n nr_of_symbols: %d \n start_symbol_index: %d \n nrOfLayers: %d \n mcs_index: %d \n \ + mcs_table: %d \n harq_process_id: %d \n ndi: %d \n num_cb: %d \n rv_index: %d \n", + rb_start, nr_of_symbols, start_symbol_index, nrOfLayers, mcs_index, + mcs_table, harq_process_id, ndi, num_cb, rv_index); +#endif for (i = start_symbol_index; i < start_symbol_index + nr_of_symbols; i++) { if((ul_dmrs_symb_pos >> i) & 0x01) @@ -2261,13 +2271,22 @@ int8_t nr_ue_process_dci_time_dom_resource_assignment(NR_UE_MAC_INST_t *mac, */ if(pusch_config_pdu != NULL){ NR_PUSCH_TimeDomainResourceAllocationList_t *pusch_TimeDomainAllocationList = NULL; - if (mac->ULbwp[0]->bwp_Dedicated->pusch_Config) + if (mac->ULbwp[0]->bwp_Dedicated->pusch_Config->choice.setup->pusch_TimeDomainAllocationList) { pusch_TimeDomainAllocationList = mac->ULbwp[0]->bwp_Dedicated->pusch_Config->choice.setup->pusch_TimeDomainAllocationList->choice.setup; - + } + else if (mac->ULbwp[0]->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList) { + pusch_TimeDomainAllocationList = mac->ULbwp[0]->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; + } + if (pusch_TimeDomainAllocationList) { - AssertFatal(pusch_TimeDomainAllocationList->list.count > time_domain_ind, - "time_domain_ind %d >= pdsch->TimeDomainAllocationList->list.count %d\n", - time_domain_ind,pusch_TimeDomainAllocationList->list.count); + if (time_domain_ind >= pusch_TimeDomainAllocationList->list.count) { + LOG_E(MAC, "time_domain_ind %d >= pusch->TimeDomainAllocationList->list.count %d\n", + time_domain_ind, pusch_TimeDomainAllocationList->list.count); + pusch_config_pdu->start_symbol_index=0; + pusch_config_pdu->nr_of_symbols=0; + return -1; + } + int startSymbolAndLength = pusch_TimeDomainAllocationList->list.array[time_domain_ind]->startSymbolAndLength; int S,L; SLIV2SL(startSymbolAndLength,&S,&L); @@ -3128,6 +3147,33 @@ void nr_extract_dci_info(NR_UE_MAC_INST_t *mac, int pos=0; int fsize=0; + + if (rnti_type == NR_RNTI_C) { + // First find out the DCI format from the first bit (UE performed blind decoding) + pos++; + dci_pdu_rel15->format_indicator = (*dci_pdu>>(dci_size-pos))&1; +#ifdef DEBUG_EXTRACT_DCI + LOG_D(MAC,"Format indicator %d (%d bits) N_RB_BWP %d => %d (0x%lx)\n",dci_pdu_rel15->format_indicator,1,N_RB,dci_size-pos,*dci_pdu); +#endif + + if (dci_format == NR_UL_DCI_FORMAT_0_0 || dci_format == NR_DL_DCI_FORMAT_1_0) { + if (dci_pdu_rel15->format_indicator == 0) + dci_format = NR_UL_DCI_FORMAT_0_0; + else + dci_format = NR_DL_DCI_FORMAT_1_0; + } + else if (dci_format == NR_UL_DCI_FORMAT_0_1 || dci_format == NR_DL_DCI_FORMAT_1_1) { + // In case the sizes of formats 0_1 and 1_1 happen to be the same + if (dci_pdu_rel15->format_indicator == 0) + dci_format = NR_UL_DCI_FORMAT_0_1; + else + dci_format = NR_DL_DCI_FORMAT_1_1; + } + } +#ifdef DEBUG_EXTRACT_DCI + LOG_D(MAC, "DCI format is %d\n", dci_format); +#endif + switch(dci_format) { case NR_DL_DCI_FORMAT_1_0: @@ -3170,13 +3216,6 @@ void nr_extract_dci_info(NR_UE_MAC_INST_t *mac, case NR_RNTI_C: - // indicating a DL DCI format 1bit - pos++; - dci_pdu_rel15->format_indicator = (*dci_pdu>>(dci_size-pos))&1; -#ifdef DEBUG_EXTRACT_DCI - LOG_D(MAC,"Format indicator %d (%d bits) N_RB_BWP %d => %d (0x%lx)\n",dci_pdu_rel15->format_indicator,1,N_RB,dci_size-pos,*dci_pdu); -#endif - // Freq domain assignment (275rb >> fsize = 16) fsize = (int)ceil( log2( (N_RB*(N_RB+1))>>1 ) ); pos+=fsize; @@ -3377,18 +3416,16 @@ void nr_extract_dci_info(NR_UE_MAC_INST_t *mac, switch(rnti_type) { case NR_RNTI_C: - // indicating a DL DCI format 1bit - dci_pdu_rel15->format_indicator = (*dci_pdu>>(dci_size-pos))&1; - // Freq domain assignment max 16 bit fsize = (int)ceil( log2( (N_RB_UL*(N_RB_UL+1))>>1 ) ); pos+=fsize; dci_pdu_rel15->frequency_domain_assignment.val = (*dci_pdu>>(dci_size-pos))&((1<time_domain_assignment.val = (*dci_pdu>>(dci_size-pos))&0xf; - // Frequency hopping flag – 1 bit - pos++; - dci_pdu_rel15->frequency_hopping_flag.val= (*dci_pdu>>(dci_size-pos))&1; + // This is not supported yet - Skip for now + // Frequency hopping flag – 1 bit + //pos++; + //dci_pdu_rel15->frequency_hopping_flag.val= (*dci_pdu>>(dci_size-pos))&1; // MCS 5 bit pos+=5; dci_pdu_rel15->mcs= (*dci_pdu>>(dci_size-pos))&0x1f; @@ -3452,89 +3489,201 @@ void nr_extract_dci_info(NR_UE_MAC_INST_t *mac, break; case NR_DL_DCI_FORMAT_1_1: - // Format indicator - pos=1; - dci_pdu_rel15->format_indicator = (*dci_pdu>>(dci_size-pos))&1; - // Carrier indicator - pos+=dci_pdu_rel15->carrier_indicator.nbits; - dci_pdu_rel15->carrier_indicator.val = (*dci_pdu>>(dci_size-pos))&((1<carrier_indicator.nbits)-1); - // BWP Indicator - pos+=dci_pdu_rel15->bwp_indicator.nbits; - dci_pdu_rel15->bwp_indicator.val = (*dci_pdu>>(dci_size-pos))&((1<bwp_indicator.nbits)-1); - // Frequency domain resource assignment - pos+=dci_pdu_rel15->frequency_domain_assignment.nbits; - dci_pdu_rel15->frequency_domain_assignment.val = (*dci_pdu>>(dci_size-pos))&((1<frequency_domain_assignment.nbits)-1); - // Time domain resource assignment - pos+=dci_pdu_rel15->time_domain_assignment.nbits; - dci_pdu_rel15->time_domain_assignment.val = (*dci_pdu>>(dci_size-pos))&((1<time_domain_assignment.nbits)-1); - // VRB-to-PRB mapping - pos+=dci_pdu_rel15->vrb_to_prb_mapping.nbits; - dci_pdu_rel15->vrb_to_prb_mapping.val = (*dci_pdu>>(dci_size-pos))&((1<vrb_to_prb_mapping.nbits)-1); - // PRB bundling size indicator - pos+=dci_pdu_rel15->prb_bundling_size_indicator.nbits; - dci_pdu_rel15->prb_bundling_size_indicator.val = (*dci_pdu>>(dci_size-pos))&((1<prb_bundling_size_indicator.nbits)-1); - // Rate matching indicator - pos+=dci_pdu_rel15->rate_matching_indicator.nbits; - dci_pdu_rel15->rate_matching_indicator.val = (*dci_pdu>>(dci_size-pos))&((1<rate_matching_indicator.nbits)-1); - // ZP CSI-RS trigger - pos+=dci_pdu_rel15->zp_csi_rs_trigger.nbits; - dci_pdu_rel15->zp_csi_rs_trigger.val = (*dci_pdu>>(dci_size-pos))&((1<zp_csi_rs_trigger.nbits)-1); - //TB1 - // MCS 5bit - pos+=5; - dci_pdu_rel15->mcs = (*dci_pdu>>(dci_size-pos))&0x1f; - // New data indicator 1bit - pos+=1; - dci_pdu_rel15->ndi = (*dci_pdu>>(dci_size-pos))&0x1; - // Redundancy version 2bit - pos+=2; - dci_pdu_rel15->rv = (*dci_pdu>>(dci_size-pos))&0x3; - //TB2 - // MCS 5bit - pos+=dci_pdu_rel15->mcs2.nbits; - dci_pdu_rel15->mcs2.val = (*dci_pdu>>(dci_size-pos))&((1<mcs2.nbits)-1); - // New data indicator 1bit - pos+=dci_pdu_rel15->ndi2.nbits; - dci_pdu_rel15->ndi2.val = (*dci_pdu>>(dci_size-pos))&((1<ndi2.nbits)-1); - // Redundancy version 2bit - pos+=dci_pdu_rel15->rv2.nbits; - dci_pdu_rel15->rv2.val = (*dci_pdu>>(dci_size-pos))&((1<rv2.nbits)-1); - // HARQ process number 4bit - pos+=4; - dci_pdu_rel15->harq_pid = (*dci_pdu>>(dci_size-pos))&0xf; - // Downlink assignment index - pos+=dci_pdu_rel15->dai[0].nbits; - dci_pdu_rel15->dai[0].val = (*dci_pdu>>(dci_size-pos))&((1<dai[0].nbits)-1); - // TPC command for scheduled PUCCH 2bit - pos+=2; - dci_pdu_rel15->tpc = (*dci_pdu>>(dci_size-pos))&0x3; - // PUCCH resource indicator 3bit - pos+=3; - dci_pdu_rel15->pucch_resource_indicator = (*dci_pdu>>(dci_size-pos))&0x3; - // PDSCH-to-HARQ_feedback timing indicator - pos+=dci_pdu_rel15->pdsch_to_harq_feedback_timing_indicator.nbits; - dci_pdu_rel15->pdsch_to_harq_feedback_timing_indicator.val = (*dci_pdu>>(dci_size-pos))&((1<pdsch_to_harq_feedback_timing_indicator.nbits)-1); - // Antenna ports - pos+=dci_pdu_rel15->antenna_ports.nbits; - dci_pdu_rel15->antenna_ports.val = (*dci_pdu>>(dci_size-pos))&((1<antenna_ports.nbits)-1); - // TCI - pos+=dci_pdu_rel15->transmission_configuration_indication.nbits; - dci_pdu_rel15->transmission_configuration_indication.val = (*dci_pdu>>(dci_size-pos))&((1<transmission_configuration_indication.nbits)-1); - // SRS request - pos+=dci_pdu_rel15->srs_request.nbits; - dci_pdu_rel15->srs_request.val = (*dci_pdu>>(dci_size-pos))&((1<srs_request.nbits)-1); - // CBG transmission information - pos+=dci_pdu_rel15->cbgti.nbits; - dci_pdu_rel15->cbgti.val = (*dci_pdu>>(dci_size-pos))&((1<cbgti.nbits)-1); - // CBG flushing out information - pos+=dci_pdu_rel15->cbgfi.nbits; - dci_pdu_rel15->cbgfi.val = (*dci_pdu>>(dci_size-pos))&((1<cbgfi.nbits)-1); - // DMRS sequence init - pos+=1; - dci_pdu_rel15->dmrs_sequence_initialization.val = (*dci_pdu>>(dci_size-pos))&0x1; - break; + switch(rnti_type) + { + case NR_RNTI_C: + // Carrier indicator + pos+=dci_pdu_rel15->carrier_indicator.nbits; + dci_pdu_rel15->carrier_indicator.val = (*dci_pdu>>(dci_size-pos))&((1<carrier_indicator.nbits)-1); + // BWP Indicator + pos+=dci_pdu_rel15->bwp_indicator.nbits; + dci_pdu_rel15->bwp_indicator.val = (*dci_pdu>>(dci_size-pos))&((1<bwp_indicator.nbits)-1); + // Frequency domain resource assignment + pos+=dci_pdu_rel15->frequency_domain_assignment.nbits; + dci_pdu_rel15->frequency_domain_assignment.val = (*dci_pdu>>(dci_size-pos))&((1<frequency_domain_assignment.nbits)-1); + // Time domain resource assignment + pos+=dci_pdu_rel15->time_domain_assignment.nbits; + dci_pdu_rel15->time_domain_assignment.val = (*dci_pdu>>(dci_size-pos))&((1<time_domain_assignment.nbits)-1); + // VRB-to-PRB mapping + pos+=dci_pdu_rel15->vrb_to_prb_mapping.nbits; + dci_pdu_rel15->vrb_to_prb_mapping.val = (*dci_pdu>>(dci_size-pos))&((1<vrb_to_prb_mapping.nbits)-1); + // PRB bundling size indicator + pos+=dci_pdu_rel15->prb_bundling_size_indicator.nbits; + dci_pdu_rel15->prb_bundling_size_indicator.val = (*dci_pdu>>(dci_size-pos))&((1<prb_bundling_size_indicator.nbits)-1); + // Rate matching indicator + pos+=dci_pdu_rel15->rate_matching_indicator.nbits; + dci_pdu_rel15->rate_matching_indicator.val = (*dci_pdu>>(dci_size-pos))&((1<rate_matching_indicator.nbits)-1); + // ZP CSI-RS trigger + pos+=dci_pdu_rel15->zp_csi_rs_trigger.nbits; + dci_pdu_rel15->zp_csi_rs_trigger.val = (*dci_pdu>>(dci_size-pos))&((1<zp_csi_rs_trigger.nbits)-1); + //TB1 + // MCS 5bit + pos+=5; + dci_pdu_rel15->mcs = (*dci_pdu>>(dci_size-pos))&0x1f; + // New data indicator 1bit + pos+=1; + dci_pdu_rel15->ndi = (*dci_pdu>>(dci_size-pos))&0x1; + // Redundancy version 2bit + pos+=2; + dci_pdu_rel15->rv = (*dci_pdu>>(dci_size-pos))&0x3; + //TB2 + // MCS 5bit + pos+=dci_pdu_rel15->mcs2.nbits; + dci_pdu_rel15->mcs2.val = (*dci_pdu>>(dci_size-pos))&((1<mcs2.nbits)-1); + // New data indicator 1bit + pos+=dci_pdu_rel15->ndi2.nbits; + dci_pdu_rel15->ndi2.val = (*dci_pdu>>(dci_size-pos))&((1<ndi2.nbits)-1); + // Redundancy version 2bit + pos+=dci_pdu_rel15->rv2.nbits; + dci_pdu_rel15->rv2.val = (*dci_pdu>>(dci_size-pos))&((1<rv2.nbits)-1); + // HARQ process number 4bit + pos+=4; + dci_pdu_rel15->harq_pid = (*dci_pdu>>(dci_size-pos))&0xf; + // Downlink assignment index + pos+=dci_pdu_rel15->dai[0].nbits; + dci_pdu_rel15->dai[0].val = (*dci_pdu>>(dci_size-pos))&((1<dai[0].nbits)-1); + // TPC command for scheduled PUCCH 2bit + pos+=2; + dci_pdu_rel15->tpc = (*dci_pdu>>(dci_size-pos))&0x3; + // PUCCH resource indicator 3bit + pos+=3; + dci_pdu_rel15->pucch_resource_indicator = (*dci_pdu>>(dci_size-pos))&0x3; + // PDSCH-to-HARQ_feedback timing indicator + pos+=dci_pdu_rel15->pdsch_to_harq_feedback_timing_indicator.nbits; + dci_pdu_rel15->pdsch_to_harq_feedback_timing_indicator.val = (*dci_pdu>>(dci_size-pos))&((1<pdsch_to_harq_feedback_timing_indicator.nbits)-1); + // Antenna ports + pos+=dci_pdu_rel15->antenna_ports.nbits; + dci_pdu_rel15->antenna_ports.val = (*dci_pdu>>(dci_size-pos))&((1<antenna_ports.nbits)-1); + // TCI + pos+=dci_pdu_rel15->transmission_configuration_indication.nbits; + dci_pdu_rel15->transmission_configuration_indication.val = (*dci_pdu>>(dci_size-pos))&((1<transmission_configuration_indication.nbits)-1); + // SRS request + pos+=dci_pdu_rel15->srs_request.nbits; + dci_pdu_rel15->srs_request.val = (*dci_pdu>>(dci_size-pos))&((1<srs_request.nbits)-1); + // CBG transmission information + pos+=dci_pdu_rel15->cbgti.nbits; + dci_pdu_rel15->cbgti.val = (*dci_pdu>>(dci_size-pos))&((1<cbgti.nbits)-1); + // CBG flushing out information + pos+=dci_pdu_rel15->cbgfi.nbits; + dci_pdu_rel15->cbgfi.val = (*dci_pdu>>(dci_size-pos))&((1<cbgfi.nbits)-1); + // DMRS sequence init + pos+=1; + dci_pdu_rel15->dmrs_sequence_initialization.val = (*dci_pdu>>(dci_size-pos))&0x1; + break; + } + break; - } + case NR_UL_DCI_FORMAT_0_1: + switch(rnti_type) + { + case NR_RNTI_C: + // Carrier indicator + pos+=dci_pdu_rel15->carrier_indicator.nbits; + dci_pdu_rel15->carrier_indicator.val = (*dci_pdu>>(dci_size-pos))&((1<carrier_indicator.nbits)-1); + + // UL/SUL Indicator + pos+=dci_pdu_rel15->ul_sul_indicator.nbits; + dci_pdu_rel15->ul_sul_indicator.val = (*dci_pdu>>(dci_size-pos))&((1<ul_sul_indicator.nbits)-1); + + // BWP Indicator + pos+=dci_pdu_rel15->bwp_indicator.nbits; + dci_pdu_rel15->bwp_indicator.val = (*dci_pdu>>(dci_size-pos))&((1<bwp_indicator.nbits)-1); + + // Freq domain assignment max 16 bit + fsize = (int)ceil( log2( (N_RB_UL*(N_RB_UL+1))>>1 ) ); + //pos+=dci_pdu_rel15->frequency_domain_assignment.nbits; + pos+=fsize; + + //pos+=dci_pdu_rel15->frequency_domain_assignment.nbits; + dci_pdu_rel15->frequency_domain_assignment.val = (*dci_pdu>>(dci_size-pos))&((1<time_domain_assignment.nbits; + dci_pdu_rel15->time_domain_assignment.val = (*dci_pdu>>(dci_size-pos))&0x3; + + // Not supported yet - skip for now + // Frequency hopping flag – 1 bit + //pos++; + //dci_pdu_rel15->frequency_hopping_flag.val= (*dci_pdu>>(dci_size-pos))&1; + + // MCS 5 bit + pos+=5; + dci_pdu_rel15->mcs= (*dci_pdu>>(dci_size-pos))&0x1f; + + // New data indicator 1bit + pos++; + dci_pdu_rel15->ndi= (*dci_pdu>>(dci_size-pos))&1; + + // Redundancy version 2bit + pos+=2; + dci_pdu_rel15->rv= (*dci_pdu>>(dci_size-pos))&3; + + // HARQ process number 4bit + pos+=4; + dci_pdu_rel15->harq_pid = (*dci_pdu>>(dci_size-pos))&0xf; + + // 1st Downlink assignment index + pos+=dci_pdu_rel15->dai[0].nbits; + dci_pdu_rel15->dai[0].val = (*dci_pdu>>(dci_size-pos))&((1<dai[0].nbits)-1); + + // 2nd Downlink assignment index + pos+=dci_pdu_rel15->dai[1].nbits; + dci_pdu_rel15->dai[1].val = (*dci_pdu>>(dci_size-pos))&((1<dai[1].nbits)-1); + + // TPC command for scheduled PUSCH – 2 bits + pos+=2; + dci_pdu_rel15->tpc = (*dci_pdu>>(dci_size-pos))&3; + + // SRS resource indicator + pos+=dci_pdu_rel15->srs_resource_indicator.nbits; + dci_pdu_rel15->srs_resource_indicator.val = (*dci_pdu>>(dci_size-pos))&((1<srs_resource_indicator.nbits)-1); + + // Precoding info and n. of layers + pos+=dci_pdu_rel15->precoding_information.nbits; + dci_pdu_rel15->precoding_information.val = (*dci_pdu>>(dci_size-pos))&((1<precoding_information.nbits)-1); + + // Antenna ports + pos+=dci_pdu_rel15->antenna_ports.nbits; + dci_pdu_rel15->antenna_ports.val = (*dci_pdu>>(dci_size-pos))&((1<antenna_ports.nbits)-1); + + // SRS request + pos+=dci_pdu_rel15->srs_request.nbits; + dci_pdu_rel15->srs_request.val = (*dci_pdu>>(dci_size-pos))&((1<srs_request.nbits)-1); + + // CSI request + pos+=dci_pdu_rel15->csi_request.nbits; + dci_pdu_rel15->csi_request.val = (*dci_pdu>>(dci_size-pos))&((1<csi_request.nbits)-1); + + // CBG transmission information + pos+=dci_pdu_rel15->cbgti.nbits; + dci_pdu_rel15->cbgti.val = (*dci_pdu>>(dci_size-pos))&((1<cbgti.nbits)-1); + + // PTRS DMRS association + pos+=dci_pdu_rel15->ptrs_dmrs_association.nbits; + dci_pdu_rel15->ptrs_dmrs_association.val = (*dci_pdu>>(dci_size-pos))&((1<ptrs_dmrs_association.nbits)-1); + + // Beta offset indicator + pos+=dci_pdu_rel15->beta_offset_indicator.nbits; + dci_pdu_rel15->beta_offset_indicator.val = (*dci_pdu>>(dci_size-pos))&((1<beta_offset_indicator.nbits)-1); + + // DMRS sequence initialization + pos+=dci_pdu_rel15->dmrs_sequence_initialization.nbits; + dci_pdu_rel15->dmrs_sequence_initialization.val = (*dci_pdu>>(dci_size-pos))&((1<dmrs_sequence_initialization.nbits)-1); + + // UL-SCH indicator + pos+=1; + dci_pdu_rel15->ulsch_indicator = (*dci_pdu>>(dci_size-pos))&0x1; + + // UL/SUL indicator – 1 bit + /* commented for now (RK): need to get this from BWP descriptor + if (cfg->pucch_config.pucch_GroupHopping.value) + dci_pdu->= ((uint64_t)*dci_pdu>>(dci_size-pos)ul_sul_indicator&1)<<(dci_size-pos++); + */ + break; + } + break; + } } diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c index 91cc965473..75a84e90dd 100644 --- a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c +++ b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c @@ -155,7 +155,7 @@ int nr_ue_dl_indication(nr_downlink_indication_t *dl_info, NR_UL_TIME_ALIGNMENT_ ul_config->number_pdus = 0; //hook up pointers mac->scheduled_response.dl_config = dl_config; - mac->scheduled_response.ul_config = ul_config; + mac->scheduled_response.ul_config = NULL; mac->scheduled_response.tx_request = &mac->tx_request; mac->scheduled_response.module_id = dl_info->module_id; mac->scheduled_response.CC_id = dl_info->cc_id; From 590a9d41ea0886da53802f555f85f555a49ee26b Mon Sep 17 00:00:00 2001 From: Shweta Shrivastava Date: Mon, 21 Sep 2020 18:57:27 -0500 Subject: [PATCH 39/96] Fix for segfault in nrLDPC_encoder --- openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c index 6f5fba7812..a81e15ecda 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c @@ -391,6 +391,10 @@ int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch, encoder_implemparams_t impp; impp.n_segments=harq_process->C; impp.macro_num=0; + impp.tinput = NULL; + impp.tprep = NULL; + impp.tparity = NULL; + impp.toutput = NULL; VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_LDPC_ENCODER_OPTIM, VCD_FUNCTION_IN); From 8cd05eac174914b1ca2643c3128a3adf23ee9321 Mon Sep 17 00:00:00 2001 From: Shweta Shrivastava Date: Mon, 21 Sep 2020 22:06:55 -0500 Subject: [PATCH 40/96] Fix for handling same length DCIs --- openair2/LAYER2/NR_MAC_UE/mac_proto.h | 2 +- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_UE/mac_proto.h b/openair2/LAYER2/NR_MAC_UE/mac_proto.h index e9d7a97a5d..3652bee278 100755 --- a/openair2/LAYER2/NR_MAC_UE/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_proto.h @@ -156,7 +156,7 @@ int8_t nr_ue_process_dlsch(module_id_t module_id, int cc_id, uint8_t gNB_index, void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl_config, frame_t frame, int slot); -void nr_extract_dci_info(NR_UE_MAC_INST_t *mac, +int nr_extract_dci_info(NR_UE_MAC_INST_t *mac, int dci_format, uint8_t dci_length, uint16_t rnti, diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index a14d17f920..ab116ec01a 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -2314,8 +2314,8 @@ int nr_ue_process_dci_indication_pdu(module_id_t module_id,int cc_id, int gNB_in LOG_D(MAC,"Received dci indication (rnti %x,dci format %d,n_CCE %d,payloadSize %d,payload %llx)\n", dci->rnti,dci->dci_format,dci->n_CCE,dci->payloadSize,*(unsigned long long*)dci->payloadBits); - nr_extract_dci_info(mac,dci->dci_format,dci->payloadSize,dci->rnti,(uint64_t *)dci->payloadBits,def_dci_pdu_rel15); - return (nr_ue_process_dci(module_id, cc_id, gNB_index, def_dci_pdu_rel15, dci->rnti, dci->dci_format)); + int dci_format = nr_extract_dci_info(mac,dci->dci_format,dci->payloadSize,dci->rnti,(uint64_t *)dci->payloadBits,def_dci_pdu_rel15); + return (nr_ue_process_dci(module_id, cc_id, gNB_index, def_dci_pdu_rel15, dci->rnti, dci_format)); } int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, dci_pdu_rel15_t *dci, uint16_t rnti, uint32_t dci_format){ @@ -3121,7 +3121,7 @@ void nr_ue_send_sdu(module_id_t module_idP, } -void nr_extract_dci_info(NR_UE_MAC_INST_t *mac, +int nr_extract_dci_info(NR_UE_MAC_INST_t *mac, int dci_format, uint8_t dci_size, uint16_t rnti, @@ -3684,6 +3684,8 @@ void nr_extract_dci_info(NR_UE_MAC_INST_t *mac, } break; } + + return dci_format; } From 911092f574d850ce09eda9db6a7b5209afa031af Mon Sep 17 00:00:00 2001 From: Shweta Shrivastava Date: Thu, 24 Sep 2020 23:48:46 -0500 Subject: [PATCH 41/96] Fixed values of slot offset K2 in gNB config file --- ci-scripts/conf_files/gnb.band78.tm1.106PRB.usrpn300.conf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ci-scripts/conf_files/gnb.band78.tm1.106PRB.usrpn300.conf b/ci-scripts/conf_files/gnb.band78.tm1.106PRB.usrpn300.conf index 36e93ba14e..aa03e91fd0 100644 --- a/ci-scripts/conf_files/gnb.band78.tm1.106PRB.usrpn300.conf +++ b/ci-scripts/conf_files/gnb.band78.tm1.106PRB.usrpn300.conf @@ -131,12 +131,12 @@ gNBs = # 0=unrestricted, 1=restricted type A, 2=restricted type B restrictedSetConfig = 0, # pusch-ConfigCommon (up to 16 elements) - initialULBWPk2_0 = 2; + initialULBWPk2_0 = 6; initialULBWPmappingType_0 = 1 # this is SS=0 L=11 initialULBWPstartSymbolAndLength_0 = 55; - initialULBWPk2_1 = 2; + initialULBWPk2_1 = 6; initialULBWPmappingType_1 = 1; # this is SS=0 L=12 initialULBWPstartSymbolAndLength_1 = 69; From 06313dc616dbdaf4d55ba0d3b6cdecf0bdc784b4 Mon Sep 17 00:00:00 2001 From: Shweta Shrivastava Date: Thu, 24 Sep 2020 23:53:07 -0500 Subject: [PATCH 42/96] Introduced UE Assertion if value of K2 is less than DURATION_RX_TO_TX --- executables/nr-ue.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/executables/nr-ue.c b/executables/nr-ue.c index 1600d8add0..35aa4861b2 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -839,6 +839,23 @@ void init_NR_UE(int nb_inst, char* rrc_config_path) { AssertFatal((rrc_inst = nr_l3_init_ue(rrc_config_path)) != NULL, "can not initialize RRC module\n"); AssertFatal((mac_inst = nr_l2_init_ue(rrc_inst)) != NULL, "can not initialize L2 module\n"); AssertFatal((mac_inst->if_module = nr_ue_if_module_init(inst)) != NULL, "can not initialize IF module\n"); + + NR_PUSCH_TimeDomainResourceAllocationList_t *pusch_TimeDomainAllocationList = NULL; + if (mac_inst->ULbwp[0]->bwp_Dedicated->pusch_Config->choice.setup->pusch_TimeDomainAllocationList) { + pusch_TimeDomainAllocationList = mac_inst->ULbwp[0]->bwp_Dedicated->pusch_Config->choice.setup->pusch_TimeDomainAllocationList->choice.setup; + } + else if (mac_inst->ULbwp[0]->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList) { + pusch_TimeDomainAllocationList = mac_inst->ULbwp[0]->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; + } + + if (pusch_TimeDomainAllocationList) { + for(int i = 0; i < pusch_TimeDomainAllocationList->list.count; i++) { + AssertFatal(*pusch_TimeDomainAllocationList->list.array[i]->k2 >= DURATION_RX_TO_TX, + "Slot offset K2 (%ld) cannot be less than DURATION_RX_TO_TX (%d)\n", + *pusch_TimeDomainAllocationList->list.array[i]->k2, + DURATION_RX_TO_TX); + } + } } } From f8796fb71f41f6c9811293c04e128ac1ca90eaea Mon Sep 17 00:00:00 2001 From: Guido Casati Date: Fri, 25 Sep 2020 13:50:08 +0200 Subject: [PATCH 43/96] Update doc/RUNMODEM.md with the RA setup --- doc/RUNMODEM.md | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/doc/RUNMODEM.md b/doc/RUNMODEM.md index 37eadd92f3..5fb0824565 100644 --- a/doc/RUNMODEM.md +++ b/doc/RUNMODEM.md @@ -100,13 +100,37 @@ Some other useful paramters of the UE are - --clock-source: sets the clock-source (internal or external). - --time-source: sets the time-source (internal or external). - ## noS1 setup with OAI UE Instead of randomly generated payload, in the phy-test mode we can also inject/receive user-plane traffic over a TUN interface. This is the so-called noS1 mode. This setup is described in the [rfsimulator page](../targets/ARCH/rfsimulator/README.md#5g-case). In theory this should also work with the real hardware target although this has yet to be tested. +## do-ra setup with OAI + +The do-ra flag is used to ran the NR Random Access procedures in contention-free mode. Currently OAI implements the RACH process from Msg1 to Msg3. + +In order to run the RA, the following flag is needed for both the gNB and the UE: + +`--do-ra` + +### Run OAI in do-ra mode + +From the `cmake_targets/ran_build/build` folder: + +gNB on machine 1: + +`sudo ./nr-softmodem -O ../../../targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpn300.conf --do-ra` + +UE on machine 2: + +`sudo ./nr-uesoftmodem --do-ra` + +With the RF simulator (on the same machine): + +`sudo RFSIMULATOR=gnb ./nr-softmodem -O ../../../targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpn300.conf --do-ra --rfsim --parallel-config PARALLEL_SINGLE_THREAD` + +`sudo RFSIMULATOR=127.0.0.1 ./nr-uesoftmodem --do-ra --rfsim --parallel-config PARALLEL_SINGLE_THREAD` [oai wiki home](https://gitlab.eurecom.fr/oai/openairinterface5g/wikis/home) From 8676ceea7e66a94cd4a921542d6122fd2d9a3b8a Mon Sep 17 00:00:00 2001 From: Hongzhi Wang Date: Thu, 24 Sep 2020 09:27:32 +0200 Subject: [PATCH 44/96] initializing nr ue dlsch harq status --- openair1/SCHED_NR_UE/fapi_nr_ue_l1.c | 1 + 1 file changed, 1 insertion(+) diff --git a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c index 55c7cd0baf..4cdb70d79c 100644 --- a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c +++ b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c @@ -98,6 +98,7 @@ int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response){ if (dlsch0_harq){ + dlsch0_harq->status = ACTIVE; dlsch0_harq->BWPStart = dlsch_config_pdu->BWPStart; dlsch0_harq->BWPSize = dlsch_config_pdu->BWPSize; dlsch0_harq->nb_rb = dlsch_config_pdu->number_rbs; From 1340e00feca94796d33edc62c1b21228910c435e Mon Sep 17 00:00:00 2001 From: Francesco Mani Date: Fri, 25 Sep 2020 10:13:26 +0200 Subject: [PATCH 45/96] mcs table for pusch from rrc config --- openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c | 36 +++++++- openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h | 10 ++- .../LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c | 82 +++++++++++-------- 3 files changed, 91 insertions(+), 37 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c index bc105b9080..8fe83dd40d 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c @@ -1603,11 +1603,9 @@ uint16_t Table_51312[28][2] = {{2,120},{2,193},{2,308},{2,449},{2,602},{4,378},{ uint16_t Table_51313[29][2] = {{2,30},{2,40},{2,50},{2,64},{2,78},{2,99},{2,120},{2,157},{2,193},{2,251},{2,308},{2,379},{2,449},{2,526},{2,602},{4,340}, {4,378},{4,434},{4,490},{4,553},{4,616},{6,438},{6,466},{6,517},{6,567},{6,616},{6,666}, {6,719}, {6,772}}; -//Table 6.1.4.1-1 of 38.214 TODO fix for tp-pi2BPSK uint16_t Table_61411[28][2] = {{2,120},{2,157},{2,193},{2,251},{2,308},{2,379},{2,449},{2,526},{2,602},{2,679},{4,340},{4,378},{4,434},{4,490},{4,553},{4,616}, {4,658},{6,466},{6,517},{6,567},{6,616},{6,666},{6,719},{6,772},{6,822},{6,873}, {6,910}, {6,948}}; -//Table 6.1.4.1-2 of 38.214 TODO fix for tp-pi2BPSK uint16_t Table_61412[28][2] = {{2,30},{2,40},{2,50},{2,64},{2,78},{2,99},{2,120},{2,157},{2,193},{2,251},{2,308},{2,379},{2,449},{2,526},{2,602},{2,679}, {4,378},{4,434},{4,490},{4,553},{4,616},{4,658},{4,699},{4,772},{6,567},{6,616},{6,666}, {6,772}}; @@ -2471,6 +2469,40 @@ int16_t fill_dmrs_mask(NR_PDSCH_Config_t *pdsch_Config,int dmrs_TypeA_Position,i return(-1); } +uint8_t get_pusch_mcs_table(long *mcs_Table, + int is_tp, + int dci_format, + int rnti_type, + int target_ss, + bool config_grant) { + + // implementing 6.1.4.1 in 38.214 + if (mcs_Table != NULL) { + if (config_grant || (rnti_type == NR_RNTI_CS)) { + if (*mcs_Table == NR_PUSCH_Config__mcs_Table_qam256) + return 1; + else + return (2+(is_tp<<1)); + } + else { + if ((*mcs_Table == NR_PUSCH_Config__mcs_Table_qam256) && + (dci_format == NR_UL_DCI_FORMAT_0_1) && + ((rnti_type == NR_RNTI_C ) || (rnti_type == NR_RNTI_SP_CSI))) + return 1; + // TODO take into account UE configuration + if ((*mcs_Table == NR_PUSCH_Config__mcs_Table_qam64LowSE) && + (target_ss == NR_SearchSpace__searchSpaceType_PR_ue_Specific) && + ((rnti_type == NR_RNTI_C ) || (rnti_type == NR_RNTI_SP_CSI))) + return (2+(is_tp<<1)); + if (rnti_type == NR_RNTI_MCS_C) + return (2+(is_tp<<1)); + AssertFatal(1==0,"Invalid configuration to set MCS table"); + } + } + else + return (0+(is_tp*3)); +} + int binomial(int n, int k) { int c = 1, i; diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h index a5e38bf128..f19a46cb34 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h @@ -60,7 +60,8 @@ typedef enum { NR_RNTI_INT, NR_RNTI_TPC_PUSCH, NR_RNTI_TPC_PUCCH, - NR_RNTI_TPC_SRS + NR_RNTI_TPC_SRS, + NR_RNTI_MCS_C, } nr_rnti_type_t; uint16_t config_bandwidth(int mu, int nb_rb, int nr_band); @@ -100,6 +101,13 @@ int get_nr_prach_info_from_index(uint8_t index, uint8_t *N_t_slot, uint8_t *N_dur); +uint8_t get_pusch_mcs_table(long *mcs_Table, + int is_tp, + int dci_format, + int rnti_type, + int target_ss, + bool config_grant); + uint8_t compute_nr_root_seq(NR_RACH_ConfigCommon_t *rach_config, uint8_t nb_preambles, uint8_t unpaired); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c index f786db8ba9..137af84fc6 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c @@ -862,6 +862,36 @@ void schedule_fapi_ul_pdu(int Mod_idP, LOG_D(MAC, "Scheduling UE specific PUSCH\n"); //UL_tti_req = &nr_mac->UL_tti_req[CC_id]; + int dci_formats[2]; + int rnti_types[2]; + + NR_SearchSpace_t *ss; + int target_ss = NR_SearchSpace__searchSpaceType_PR_ue_Specific; + + AssertFatal(bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList!=NULL,"searchPsacesToAddModList is null\n"); + AssertFatal(bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList->list.count>0, + "searchPsacesToAddModList is empty\n"); + + int found=0; + + for (int i=0;ibwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList->list.count;i++) { + ss=bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList->list.array[i]; + AssertFatal(ss->controlResourceSetId != NULL,"ss->controlResourceSetId is null\n"); + AssertFatal(ss->searchSpaceType != NULL,"ss->searchSpaceType is null\n"); + if (ss->searchSpaceType->present == target_ss) { + found=1; + break; + } + } + AssertFatal(found==1,"Couldn't find an adequate searchspace\n"); + + if (ss->searchSpaceType->choice.ue_Specific->dci_Formats) + dci_formats[0] = NR_UL_DCI_FORMAT_0_1; + else + dci_formats[0] = NR_UL_DCI_FORMAT_0_0; + + rnti_types[0] = NR_RNTI_C; + //Resource Allocation in time domain int startSymbolAndLength=0; int StartSymbolIndex,NrOfSymbols,mapping_type; @@ -881,12 +911,7 @@ void schedule_fapi_ul_pdu(int Mod_idP, pusch_pdu->bwp_start = NRRIV2PRBOFFSET(ubwp->bwp_Common->genericParameters.locationAndBandwidth,275); pusch_pdu->subcarrier_spacing = ubwp->bwp_Common->genericParameters.subcarrierSpacing; pusch_pdu->cyclic_prefix = 0; - //pusch information always include - //this informantion seems to be redundant. with hthe mcs_index and the modulation table, the mod_order and target_code_rate can be determined. - pusch_pdu->mcs_index = 9; - pusch_pdu->mcs_table = 0; //0: notqam256 [TS38.214, table 5.1.3.1-1] - corresponds to nr_target_code_rate_table1 in PHY - pusch_pdu->target_code_rate = nr_get_code_rate_ul(pusch_pdu->mcs_index,pusch_pdu->mcs_table) ; - pusch_pdu->qam_mod_order = nr_get_Qm_ul(pusch_pdu->mcs_index,pusch_pdu->mcs_table) ; + if (pusch_Config->transformPrecoder == NULL) { if (scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->msg3_transformPrecoder == NULL) pusch_pdu->transform_precoding = 1; @@ -900,6 +925,23 @@ void schedule_fapi_ul_pdu(int Mod_idP, else pusch_pdu->data_scrambling_id = *scc->physCellId; + pusch_pdu->mcs_index = 9; + if (pusch_pdu->transform_precoding) + pusch_pdu->mcs_table = get_pusch_mcs_table(pusch_Config->mcs_Table, 0, + dci_formats[0], rnti_types[0], target_ss, false); + else + pusch_pdu->mcs_table = get_pusch_mcs_table(pusch_Config->mcs_TableTransformPrecoder, 1, + dci_formats[0], rnti_types[0], target_ss, false); + + pusch_pdu->target_code_rate = nr_get_code_rate_ul(pusch_pdu->mcs_index,pusch_pdu->mcs_table); + pusch_pdu->qam_mod_order = nr_get_Qm_ul(pusch_pdu->mcs_index,pusch_pdu->mcs_table); + if (pusch_Config->tp_pi2BPSK!=NULL) { + if(((pusch_pdu->mcs_table==3)&&(pusch_pdu->mcs_index<2)) || + ((pusch_pdu->mcs_table==4)&&(pusch_pdu->mcs_index<6))) { + pusch_pdu->target_code_rate = pusch_pdu->target_code_rate>>1; + pusch_pdu->qam_mod_order = pusch_pdu->qam_mod_order<<1; + } + } pusch_pdu->nrOfLayers = 1; //Pusch Allocation in frequency domain [TS38.214, sec 6.1.2.2] @@ -1053,35 +1095,7 @@ void schedule_fapi_ul_pdu(int Mod_idP, nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15 = &ul_dci_request_pdu->pdcch_pdu.pdcch_pdu_rel15; UL_dci_req->numPdus+=1; - int dci_formats[2]; - int rnti_types[2]; - NR_SearchSpace_t *ss; - int target_ss = NR_SearchSpace__searchSpaceType_PR_ue_Specific; - - AssertFatal(bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList!=NULL,"searchPsacesToAddModList is null\n"); - AssertFatal(bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList->list.count>0, - "searchPsacesToAddModList is empty\n"); - - int found=0; - - for (int i=0;ibwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList->list.count;i++) { - ss=bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList->list.array[i]; - AssertFatal(ss->controlResourceSetId != NULL,"ss->controlResourceSetId is null\n"); - AssertFatal(ss->searchSpaceType != NULL,"ss->searchSpaceType is null\n"); - if (ss->searchSpaceType->present == target_ss) { - found=1; - break; - } - } - AssertFatal(found==1,"Couldn't find an adequate searchspace\n"); - - if (ss->searchSpaceType->choice.ue_Specific->dci_Formats) - dci_formats[0] = NR_UL_DCI_FORMAT_0_1; - else - dci_formats[0] = NR_UL_DCI_FORMAT_0_0; - - rnti_types[0] = NR_RNTI_C; LOG_D(MAC,"Configuring ULDCI/PDCCH in %d.%d\n", frameP,slotP); int ret = nr_configure_pdcch(nr_mac, From 410c18ecd81160b110d97c6050435c8f145bf784 Mon Sep 17 00:00:00 2001 From: matzakos Date: Tue, 29 Sep 2020 19:49:18 +0200 Subject: [PATCH 46/96] Change log message --- openair3/S1AP/s1ap_eNB_handlers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair3/S1AP/s1ap_eNB_handlers.c b/openair3/S1AP/s1ap_eNB_handlers.c index 28ee11187e..79501a1a09 100644 --- a/openair3/S1AP/s1ap_eNB_handlers.c +++ b/openair3/S1AP/s1ap_eNB_handlers.c @@ -1736,7 +1736,7 @@ int s1ap_eNB_handle_s1_ENDC_e_rab_modification_confirm(uint32_t as uint32_t stream, S1AP_S1AP_PDU_t *pdu){ - LOG_W(S1AP, "Implementation of S1AP E-RAB Modification confirm handler is pending...\n"); + LOG_I(S1AP, "Received S1AP E-RAB Modification confirm message \n"); return 0; } From 659b8e32e4309c2d0acfc7831a5a68fc21035149 Mon Sep 17 00:00:00 2001 From: Shweta Shrivastava Date: Wed, 30 Sep 2020 01:05:29 -0500 Subject: [PATCH 47/96] Removed hard-coding for mcs_table --- openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c | 7 +++--- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 26 +++++++++++++++++--- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c index c85a7691f6..ec352b3ea2 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c @@ -109,7 +109,7 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, uint16_t start_sc, start_rb; int8_t Wf[2], Wt[2], l_prime[2], delta; uint16_t rnti, n_dmrs, code_rate, number_dmrs_symbols, nb_rb, k; - uint8_t dmrs_type, nb_dmrs_re_per_rb, number_of_symbols, mcs, Nl; + uint8_t dmrs_type, nb_dmrs_re_per_rb, number_of_symbols, mcs, Nl, mcs_table; int ap, start_symbol, Nid_cell, i; int sample_offsetF, N_RE_prime, N_PRB_oh; uint16_t ul_dmrs_symb_pos; @@ -156,9 +156,10 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, harq_process_ul_ue->num_of_mod_symbols = N_RE_prime*nb_rb*num_of_codewords; mcs = harq_process_ul_ue->pusch_pdu.mcs_index; + mcs_table = harq_process_ul_ue->pusch_pdu.mcs_table; Nl = harq_process_ul_ue->pusch_pdu.nrOfLayers; - mod_order = nr_get_Qm_ul(mcs, 0); - code_rate = nr_get_code_rate_ul(mcs, 0); + mod_order = nr_get_Qm_ul(mcs, mcs_table); + code_rate = nr_get_code_rate_ul(mcs, mcs_table); harq_process_ul_ue->pusch_pdu.pusch_data.tb_size = nr_compute_tbs(mod_order, code_rate, diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index ab116ec01a..91db35ebc2 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -792,19 +792,19 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in uint8_t nr_of_symbols = ulcfg_pdu->pusch_config_pdu.nr_of_symbols; uint8_t start_symbol_index = ulcfg_pdu->pusch_config_pdu.start_symbol_index; uint8_t nrOfLayers = 1; - uint8_t mcs_table = 0; uint8_t mcs_index = ulcfg_pdu->pusch_config_pdu.mcs_index; + uint8_t mcs_table = ulcfg_pdu->pusch_config_pdu.mcs_table; uint8_t harq_process_id = ulcfg_pdu->pusch_config_pdu.pusch_data.harq_process_id; uint8_t rv_index = ulcfg_pdu->pusch_config_pdu.pusch_data.rv_index; uint16_t l_prime_mask = get_l_prime(nr_of_symbols, typeB, pusch_dmrs_pos0, pusch_len1); uint8_t dmrs_config_type = 0; + uint16_t pdu_bit_map = PUSCH_PDU_BITMAP_PUSCH_DATA; // These should come from RRC config!!! uint8_t ptrs_mcs1 = 2; uint8_t ptrs_mcs2 = 4; uint8_t ptrs_mcs3 = 10; uint16_t n_rb0 = 25; uint16_t n_rb1 = 75; - uint16_t pdu_bit_map = PUSCH_PDU_BITMAP_PUSCH_DATA; uint8_t ptrs_time_density = get_L_ptrs(ptrs_mcs1, ptrs_mcs2, ptrs_mcs3, mcs_index, mcs_table); uint8_t ptrs_freq_density = get_K_ptrs(n_rb0, n_rb1, rb_size); uint8_t no_data_in_dmrs = 1; @@ -830,8 +830,8 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in else nb_dmrs_re_per_rb = ((dmrs_config_type == pusch_dmrs_type1) ? 6:4); - TBS = nr_compute_tbs(nr_get_Qm_ul(mcs_index, 0), - nr_get_code_rate_ul(mcs_index, 0), + TBS = nr_compute_tbs(nr_get_Qm_ul(mcs_index, mcs_table), + nr_get_code_rate_ul(mcs_index, mcs_table), rb_size, nr_of_symbols, nb_dmrs_re_per_rb*number_dmrs_symbols, @@ -2336,6 +2336,7 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, dc LOG_D(MAC,"nr_ue_process_dci at MAC layer with dci_format=%d (DL BWP %d, UL BWP %d)\n",dci_format,n_RB_DLBWP,n_RB_ULBWP); NR_PDSCH_Config_t *pdsch_config=mac->DLbwp[0]->bwp_Dedicated->pdsch_Config->choice.setup; + NR_PUSCH_Config_t *pusch_config=mac->ULbwp[0]->bwp_Dedicated->pusch_Config->choice.setup; switch(dci_format){ case NR_UL_DCI_FORMAT_0_0: @@ -2442,6 +2443,23 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, dc pusch_config_pdu_0_1->frequency_hopping = dci->frequency_hopping_flag.val; /* MCS */ pusch_config_pdu_0_1->mcs_index = dci->mcs; + /* MCS TABLE */ + if (pusch_config->transformPrecoder == NULL) { + if (mac->scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->msg3_transformPrecoder == NULL) + pusch_config_pdu_0_1->transform_precoding = 1; + else + pusch_config_pdu_0_1->transform_precoding = 0; + } + else + pusch_config_pdu_0_1->transform_precoding = *pusch_config->transformPrecoder; + + if (pusch_config_pdu_0_1->transform_precoding == transform_precoder_disabled) + pusch_config_pdu_0_1->mcs_table = get_pusch_mcs_table(pusch_config->mcs_Table, 0, + dci_format, NR_RNTI_C, NR_SearchSpace__searchSpaceType_PR_ue_Specific, false); + else + pusch_config_pdu_0_1->mcs_table = get_pusch_mcs_table(pusch_config->mcs_TableTransformPrecoder, 1, + dci_format, NR_RNTI_C, NR_SearchSpace__searchSpaceType_PR_ue_Specific, false); + /* NDI */ pusch_config_pdu_0_1->pusch_data.new_data_indicator = dci->ndi; /* RV */ From 5b9658f005b229fb6696c21256d6600dfa657cc7 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Fri, 4 Sep 2020 19:16:51 +0200 Subject: [PATCH 48/96] Reduce log nr-softmodem --- openair1/PHY/NR_TRANSPORT/pucch_rx.c | 4 ++-- openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 4 ++-- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c | 2 +- openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c | 14 +++++++------- openair2/RRC/NR_UE/rrc_UE.c | 6 +++--- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/openair1/PHY/NR_TRANSPORT/pucch_rx.c b/openair1/PHY/NR_TRANSPORT/pucch_rx.c index e99219d35c..bee868b5a5 100644 --- a/openair1/PHY/NR_TRANSPORT/pucch_rx.c +++ b/openair1/PHY/NR_TRANSPORT/pucch_rx.c @@ -414,7 +414,7 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB, uci_pdu->harq->harq_confidence_level = (no_conf) ? 1 : 0; uci_pdu->harq->harq_list = (nfapi_nr_harq_t*)malloc(1); uci_pdu->harq->harq_list[0].harq_value = index&0x01; - LOG_I(PHY, "HARQ value %d with confidence level (0 is good, 1 is bad) %d\n", + LOG_D(PHY, "HARQ value %d with confidence level (0 is good, 1 is bad) %d\n", uci_pdu->harq->harq_list[0].harq_value,uci_pdu->harq->harq_confidence_level); if (pucch_pdu->sr_flag == 1) { uci_pdu->sr = calloc(1,sizeof(*uci_pdu->sr)); @@ -429,7 +429,7 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB, uci_pdu->harq->harq_list = (nfapi_nr_harq_t*)malloc(2); uci_pdu->harq->harq_list[1].harq_value = index&0x01; uci_pdu->harq->harq_list[0].harq_value = (index>>1)&0x01; - LOG_I(PHY, "HARQ values %d and %d with confidence level (0 is good, 1 is bad) %d\n", + LOG_D(PHY, "HARQ values %d and %d with confidence level (0 is good, 1 is bad) %d\n", uci_pdu->harq->harq_list[1].harq_value,uci_pdu->harq->harq_list[0].harq_value,uci_pdu->harq->harq_confidence_level); if (pucch_pdu->sr_flag == 1) { uci_pdu->sr = calloc(1,sizeof(*uci_pdu->sr)); diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index 691a231aba..e0447a1a68 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -3901,7 +3901,7 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, // looking for pbch only in slot where it is supposed to be if ((ue->decode_MIB == 1) && slot_pbch) { - LOG_I(PHY," ------ PBCH ChannelComp/LLR: frame.slot %d.%d ------ \n", frame_rx%1024, nr_tti_rx); + LOG_D(PHY," ------ PBCH ChannelComp/LLR: frame.slot %d.%d ------ \n", frame_rx%1024, nr_tti_rx); for (int i=1; i<4; i++) { nr_slot_fep(ue, @@ -3922,7 +3922,7 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, nr_ue_pbch_procedures(eNB_id,ue,proc,0); if (ue->no_timing_correction==0) { - LOG_I(PHY,"start adjust sync slot = %d no timing %d\n", nr_tti_rx, ue->no_timing_correction); + LOG_D(PHY,"start adjust sync slot = %d no timing %d\n", nr_tti_rx, ue->no_timing_correction); nr_adjust_synch_ue(fp, ue, eNB_id, diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c index 5fa77c6ca7..0e8fb0aca2 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c @@ -82,7 +82,7 @@ void schedule_nr_mib(module_id_t module_idP, frame_t frameP, sub_frame_t slotP){ if (mib_sdu_length > 0) { - LOG_I(MAC, "Frame %d, slot %d: Adding BCH PDU in position %d (length %d)\n", frameP, slotP, dl_req->nPDUs, mib_sdu_length); + LOG_D(MAC, "Frame %d, slot %d: Adding BCH PDU in position %d (length %d)\n", frameP, slotP, dl_req->nPDUs, mib_sdu_length); if ((frameP & 1023) < 80){ LOG_I(MAC,"[gNB %d] Frame %d : MIB->BCH CC_id %d, Received %d bytes\n",module_idP, frameP, CC_id, mib_sdu_length); diff --git a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c index c8b385bbfc..44c85f5f6a 100644 --- a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c +++ b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c @@ -431,9 +431,9 @@ static void deliver_sdu_drb(void *_ue, nr_pdcp_entity_t *entity, GTPV1U_ENB_TUNNEL_DATA_REQ(message_p).offset = GTPU_HEADER_OVERHEAD_MAX; GTPV1U_ENB_TUNNEL_DATA_REQ(message_p).rnti = ue->rnti; GTPV1U_ENB_TUNNEL_DATA_REQ(message_p).rab_id = rb_id + 4; - printf("!!!!!!! deliver_sdu_drb (drb %d) sending message to gtp size %d: ", rb_id, size); - //for (i = 0; i < size; i++) printf(" %2.2x", (unsigned char)buf[i]); - printf("\n"); + LOG_D(PDCP, "%s() (drb %d) sending message to gtp size %d\n", __func__, rb_id, size); + //for (i = 0; i < size; i++) printf(" %2.2x", (unsigned char)buf[i]); + //printf("\n"); itti_send_msg_to_task(TASK_GTPV1_U, INSTANCE_DEFAULT, message_p); } @@ -474,9 +474,9 @@ rb_found: memblock = get_free_mem_block(size, __FUNCTION__); memcpy(memblock->data, buf, size); -printf("!!!!!!! deliver_pdu_drb (srb %d) calling rlc_data_req size %d: ", rb_id, size); -//for (i = 0; i < size; i++) printf(" %2.2x", (unsigned char)memblock->data[i]); -printf("\n"); + LOG_D(PDCP, "%s(): (srb %d) calling rlc_data_req size %d\n", __func__, rb_id, size); + //for (i = 0; i < size; i++) printf(" %2.2x", (unsigned char)memblock->data[i]); + //printf("\n"); enqueue_rlc_data_req(&ctxt, 0, MBMS_FLAG_NO, rb_id, sdu_id, 0, size, memblock, NULL, NULL); } @@ -872,7 +872,7 @@ static boolean_t pdcp_data_req_drb( const sdu_size_t sdu_buffer_size, unsigned char *const sdu_buffer) { -printf("pdcp_data_req called size %d\n", sdu_buffer_size); + LOG_D(PDCP, "%s() called, size %d\n", __func__, sdu_buffer_size); nr_pdcp_ue_t *ue; nr_pdcp_entity_t *rb; int rnti = ctxt_pP->rnti; diff --git a/openair2/RRC/NR_UE/rrc_UE.c b/openair2/RRC/NR_UE/rrc_UE.c index 44215df218..1e182eff8b 100755 --- a/openair2/RRC/NR_UE/rrc_UE.c +++ b/openair2/RRC/NR_UE/rrc_UE.c @@ -399,9 +399,9 @@ int8_t nr_rrc_ue_decode_NR_BCCH_BCH_Message( } - for(i=0; i Date: Fri, 4 Sep 2020 19:14:11 +0200 Subject: [PATCH 49/96] Create NR DLSCH nr_schedule_ue_spec() --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c | 7 +- .../LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 145 +++++++++++++++++- openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 5 +- 3 files changed, 151 insertions(+), 6 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c index 1c36c474d8..3e9e20659a 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c @@ -410,7 +410,6 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, int UE_id; uint64_t *dlsch_in_slot_bitmap=NULL; uint64_t *ulsch_in_slot_bitmap=NULL; - int pucch_sched; UE_id=0; int bwp_id = 1; @@ -540,8 +539,10 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, if (UE_list->fiveG_connected[UE_id] && (is_xlsch_in_slot(*dlsch_in_slot_bitmap,slot%num_slots_per_tdd))) { ue_sched_ctl->current_harq_pid = slot % num_slots_per_tdd; - nr_update_pucch_scheduling(module_idP, UE_id, frame, slot, num_slots_per_tdd,&pucch_sched); - nr_schedule_uss_dlsch_phytest(module_idP, frame, slot, &UE_list->UE_sched_ctrl[UE_id].sched_pucch[pucch_sched], NULL); + //int pucch_sched; + //nr_update_pucch_scheduling(module_idP, UE_id, frame, slot, num_slots_per_tdd,&pucch_sched); + //nr_schedule_uss_dlsch_phytest(module_idP, frame, slot, &UE_list->UE_sched_ctrl[UE_id].sched_pucch[pucch_sched], NULL); + nr_schedule_ue_spec(module_idP, frame, slot, num_slots_per_tdd); // resetting ta flag gNB->ta_len = 0; } diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index 495095ce9e..d341213506 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -412,6 +412,147 @@ void handle_nr_uci(NR_UL_IND_t *UL_info, NR_UE_sched_ctrl_t *sched_ctrl, NR_mac_ UL_info->uci_ind.num_ucis = 0; } -/* functionalities of this function have been moved to nr_schedule_uss_dlsch_phytest */ -void nr_schedule_ue_spec(module_id_t module_idP, frame_t frameP, sub_frame_t slotP) { +void nr_schedule_ue_spec(module_id_t module_id, + frame_t frame, + sub_frame_t slot, + int num_slots_per_tdd) { + gNB_MAC_INST *gNB_mac = RC.nrmac[module_id]; + const int ta_len = gNB_mac->ta_len; + const int UE_id = 0; + const int CC_id = 0; + + nfapi_nr_dl_tti_request_body_t *dl_req = &gNB_mac->DL_req[CC_id].dl_tti_request_body; + nfapi_nr_pdu_t *tx_req = &gNB_mac->TX_req[CC_id].pdu_list[gNB_mac->TX_req[CC_id].Number_of_PDUs]; + + NR_UE_list_t *UE_list = &gNB_mac->UE_list; + + if (UE_list->num_UEs ==0) return; + + unsigned char sdu_lcids[NB_RB_MAX] = {0}; + uint16_t sdu_lengths[NB_RB_MAX] = {0}; + const uint16_t rnti = UE_list->rnti[UE_id]; + + uint8_t mac_sdus[MAX_NR_DLSCH_PAYLOAD_BYTES]; + + LOG_D(MAC, "Scheduling UE specific search space DCI type 1\n"); + + int pucch_sched; + nr_update_pucch_scheduling(module_id, UE_id, frame, slot, num_slots_per_tdd, &pucch_sched); + NR_sched_pucch *pucch = &UE_list->UE_sched_ctrl[UE_id].sched_pucch[pucch_sched]; + const int TBS_bytes = configure_fapi_dl_pdu(module_id, dl_req, pucch, NULL, NULL, NULL); + + if (TBS_bytes == 0) + return; + + const int lcid = DL_SCH_LCID_DTCH; + int header_length_total = 0; + int header_length_last = 0; + int sdu_length_total = 0; + int num_sdus = 0; + LOG_D(MAC, "[gNB %d], Frame %d, DTCH%d->DLSCH, Checking RLC status (TBS %d bytes, len %d)\n", + module_id, frame, lcid, TBS_bytes, TBS_bytes - ta_len - header_length_total - sdu_length_total - 3); + + const mac_rlc_status_resp_t rlc_status = mac_rlc_status_ind(module_id, + rnti, + module_id, + frame, + slot, + ENB_FLAG_YES, + MBMS_FLAG_NO, + lcid, + 0, + 0); + + if (rlc_status.bytes_in_buffer > 0) { + + LOG_I(MAC, "configure fapi due to data availability \n"); + + LOG_I(MAC, "[gNB %d][USER-PLANE DEFAULT DRB] Frame %d : DTCH->DLSCH, Requesting %d bytes from RLC (lcid %d total hdr len %d), TBS_bytes: %d \n \n", + module_id, frame, TBS_bytes - ta_len - header_length_total - sdu_length_total - 3, + lcid, header_length_total, TBS_bytes); + + sdu_lengths[num_sdus] = mac_rlc_data_req(module_id, + rnti, + module_id, + frame, + ENB_FLAG_YES, + MBMS_FLAG_NO, + lcid, + TBS_bytes - ta_len - header_length_total - sdu_length_total - 3, + (char *)&mac_sdus[sdu_length_total], + 0, + 0); + + LOG_W(MAC, "[gNB %d][USER-PLANE DEFAULT DRB] Got %d bytes for DTCH %d \n", module_id, sdu_lengths[num_sdus], lcid); + + sdu_lcids[num_sdus] = lcid; + sdu_length_total += sdu_lengths[num_sdus]; + header_length_last = 1 + 1 + (sdu_lengths[num_sdus] >= 128); + header_length_total += header_length_last; + + num_sdus++; + + //ue_sched_ctl->uplane_inactivity_timer = 0; + } + else { + LOG_I(MAC, "Configuring DL_TX in %d.%d: random data\n", frame, slot); + // fill dlsch_buffer with random data + for (int i = 0; i < TBS_bytes; i++) + mac_sdus[i] = (unsigned char) (lrand48()&0xff); + sdu_lcids[0] = 0x3f; // DRB + sdu_lengths[0] = TBS_bytes - ta_len - 3; + header_length_total += 2 + (sdu_lengths[0] >= 128); + sdu_length_total += sdu_lengths[0]; + num_sdus +=1; + } + + // there is at least one SDU or TA command + // if (num_sdus > 0 ){ + if (ta_len + sdu_length_total + header_length_total == 0) { + // There is no data from RLC or MAC header, so don't schedule + return; + } + + // Check if there is data from RLC or CE + const int post_padding = TBS_bytes >= 2 + header_length_total + sdu_length_total + ta_len; + // padding param currently not in use + //padding = TBS_bytes - header_length_total - sdu_length_total - ta_len - 1; + + const int offset = nr_generate_dlsch_pdu( + module_id, + (unsigned char *)mac_sdus, + (unsigned char *)gNB_mac->UE_list.DLSCH_pdu[0][0].payload[0], + num_sdus, // num_sdus + sdu_lengths, + sdu_lcids, + 255, // no drx + NULL, // contention res id + post_padding); + + // Padding: fill remainder of DLSCH with 0 + if (post_padding > 0) { + for (int j = 0; j < TBS_bytes - offset; j++) + gNB_mac->UE_list.DLSCH_pdu[0][0].payload[0][offset + j] = 0; + } + + configure_fapi_dl_Tx(module_id, + frame, + slot, + dl_req, + tx_req, + TBS_bytes, + gNB_mac->pdu_index[CC_id]); + +#if defined(ENABLE_MAC_PAYLOAD_DEBUG) + if (frame%100 == 0){ + LOG_I(MAC, + "%d.%d, first 10 payload bytes, TBS size: %d \n", + frame, + slot, + TBS_bytes); + for(int i = 0; i < 10; i++) { + LOG_I(MAC, "byte %d : %x\n", i,((uint8_t *)gNB_mac->UE_list.DLSCH_pdu[0][0].payload[0])[i]); + } + } +#endif } diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index 7caf1baed5..3c51ea3a28 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -76,7 +76,10 @@ int nr_generate_dlsch_pdu(module_id_t Mod_idP, unsigned char *ue_cont_res_id, unsigned short post_padding); -void nr_schedule_ue_spec(module_id_t module_idP, frame_t frameP, sub_frame_t slotP); +void nr_schedule_ue_spec(module_id_t module_id, + frame_t frame, + sub_frame_t slot, + int num_slots_per_tdd); void schedule_nr_mib(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP); From 192da327340ed92a8558ea76e4263cbce7182557 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 7 Sep 2020 09:27:39 +0200 Subject: [PATCH 50/96] Create separate nr_fill_nfapi_dl_pdu() --- .../LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 2 +- .../LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c | 27 +- .../NR_MAC_gNB/gNB_scheduler_primitives.c | 230 ++++++++++++++++++ openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 9 +- 4 files changed, 252 insertions(+), 16 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index d341213506..bd2749c530 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -439,7 +439,7 @@ void nr_schedule_ue_spec(module_id_t module_id, int pucch_sched; nr_update_pucch_scheduling(module_id, UE_id, frame, slot, num_slots_per_tdd, &pucch_sched); NR_sched_pucch *pucch = &UE_list->UE_sched_ctrl[UE_id].sched_pucch[pucch_sched]; - const int TBS_bytes = configure_fapi_dl_pdu(module_id, dl_req, pucch, NULL, NULL, NULL); + const int TBS_bytes = nr_fill_nfapi_dl_pdu(module_id, dl_req, pucch, NULL, NULL, NULL); if (TBS_bytes == 0) return; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c index f786db8ba9..2a0367b68a 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c @@ -252,14 +252,12 @@ void nr_schedule_css_dlsch_phytest(module_id_t module_idP, } } - -int configure_fapi_dl_pdu(int Mod_idP, - nfapi_nr_dl_tti_request_body_t *dl_req, - NR_sched_pucch *pucch_sched, - uint8_t *mcsIndex, - uint16_t *rbSize, - uint16_t *rbStart) { - +int configure_fapi_dl_pdu_phytest(int Mod_idP, + nfapi_nr_dl_tti_request_body_t *dl_req, + NR_sched_pucch *pucch_sched, + uint8_t *mcsIndex, + uint16_t *rbSize, + uint16_t *rbStart) { gNB_MAC_INST *nr_mac = RC.nrmac[Mod_idP]; NR_COMMON_channels_t *cc = nr_mac->common_channels; NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon; @@ -622,12 +620,13 @@ void nr_schedule_uss_dlsch_phytest(module_id_t module_idP, ta_len = gNB_mac->ta_len; - TBS_bytes = configure_fapi_dl_pdu(module_idP, - dl_req, - pucch_sched, - dlsch_config!=NULL ? dlsch_config->mcsIndex : NULL, - dlsch_config!=NULL ? &dlsch_config->rbSize : NULL, - dlsch_config!=NULL ? &dlsch_config->rbStart : NULL); + TBS_bytes = configure_fapi_dl_pdu_phytest( + module_idP, + dl_req, + pucch_sched, + dlsch_config != NULL ? dlsch_config->mcsIndex : NULL, + dlsch_config != NULL ? &dlsch_config->rbSize : NULL, + dlsch_config != NULL ? &dlsch_config->rbStart : NULL); if (TBS_bytes == 0) return; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index f4ec142da1..4e82ca5e06 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -407,6 +407,236 @@ void nr_configure_css_dci_initial(nfapi_nr_dl_tti_pdcch_pdu_rel15_t* pdcch_pdu, } +int nr_fill_nfapi_dl_pdu(int Mod_idP, + nfapi_nr_dl_tti_request_body_t *dl_req, + NR_sched_pucch *pucch_sched, + uint8_t *mcsIndex, + uint16_t *rbSize, + uint16_t *rbStart) { + gNB_MAC_INST *nr_mac = RC.nrmac[Mod_idP]; + NR_COMMON_channels_t *cc = nr_mac->common_channels; + NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon; + + nfapi_nr_dl_tti_request_pdu_t *dl_tti_pdcch_pdu; + nfapi_nr_dl_tti_request_pdu_t *dl_tti_pdsch_pdu; + + int TBS; + int bwp_id=1; + int UE_id = 0; + + NR_UE_list_t *UE_list = &RC.nrmac[Mod_idP]->UE_list; + + NR_CellGroupConfig_t *secondaryCellGroup = UE_list->secondaryCellGroup[UE_id]; + AssertFatal(secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count == 1, + "downlinkBWP_ToAddModList has %d BWP!\n", + secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count); + NR_BWP_Downlink_t *bwp=secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[bwp_id-1]; + + AssertFatal(bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList!=NULL,"searchPsacesToAddModList is null\n"); + AssertFatal(bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList->list.count>0, + "searchPsacesToAddModList is empty\n"); + + dl_tti_pdcch_pdu = &dl_req->dl_tti_pdu_list[dl_req->nPDUs]; + memset((void*)dl_tti_pdcch_pdu,0,sizeof(nfapi_nr_dl_tti_request_pdu_t)); + dl_tti_pdcch_pdu->PDUType = NFAPI_NR_DL_TTI_PDCCH_PDU_TYPE; + dl_tti_pdcch_pdu->PDUSize = (uint8_t)(2+sizeof(nfapi_nr_dl_tti_pdcch_pdu)); + + dl_tti_pdsch_pdu = &dl_req->dl_tti_pdu_list[dl_req->nPDUs+1]; + memset((void*)dl_tti_pdsch_pdu,0,sizeof(nfapi_nr_dl_tti_request_pdu_t)); + dl_tti_pdsch_pdu->PDUType = NFAPI_NR_DL_TTI_PDSCH_PDU_TYPE; + dl_tti_pdsch_pdu->PDUSize = (uint8_t)(2+sizeof(nfapi_nr_dl_tti_pdsch_pdu)); + + nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15 = &dl_tti_pdcch_pdu->pdcch_pdu.pdcch_pdu_rel15; + nfapi_nr_dl_tti_pdsch_pdu_rel15_t *pdsch_pdu_rel15 = &dl_tti_pdsch_pdu->pdsch_pdu.pdsch_pdu_rel15; + + + pdsch_pdu_rel15->pduBitmap = 0; + pdsch_pdu_rel15->rnti = UE_list->rnti[UE_id]; + pdsch_pdu_rel15->pduIndex = 0; + + // BWP + pdsch_pdu_rel15->BWPSize = NRRIV2BW(bwp->bwp_Common->genericParameters.locationAndBandwidth,275); + pdsch_pdu_rel15->BWPStart = NRRIV2PRBOFFSET(bwp->bwp_Common->genericParameters.locationAndBandwidth,275); + pdsch_pdu_rel15->SubcarrierSpacing = bwp->bwp_Common->genericParameters.subcarrierSpacing; + if (bwp->bwp_Common->genericParameters.cyclicPrefix) + pdsch_pdu_rel15->CyclicPrefix = *bwp->bwp_Common->genericParameters.cyclicPrefix; + else + pdsch_pdu_rel15->CyclicPrefix = 0; + + pdsch_pdu_rel15->NrOfCodewords = 1; + int mcs = (mcsIndex!=NULL) ? *mcsIndex : 9; + int current_harq_pid = UE_list->UE_sched_ctrl[UE_id].current_harq_pid; + pdsch_pdu_rel15->targetCodeRate[0] = nr_get_code_rate_dl(mcs,0); + pdsch_pdu_rel15->qamModOrder[0] = 2; + pdsch_pdu_rel15->mcsIndex[0] = mcs; + pdsch_pdu_rel15->mcsTable[0] = 0; + pdsch_pdu_rel15->rvIndex[0] = nr_rv_round_map[UE_list->UE_sched_ctrl[UE_id].harq_processes[current_harq_pid].round]; + pdsch_pdu_rel15->dataScramblingId = *scc->physCellId; + pdsch_pdu_rel15->nrOfLayers = 1; + pdsch_pdu_rel15->transmissionScheme = 0; + pdsch_pdu_rel15->refPoint = 0; // Point A + UE_list->mac_stats[UE_id].dlsch_rounds[UE_list->UE_sched_ctrl[UE_id].harq_processes[current_harq_pid].round]++; + pdsch_pdu_rel15->dmrsConfigType = bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type == NULL ? 0 : 1; + pdsch_pdu_rel15->dlDmrsScramblingId = *scc->physCellId; + pdsch_pdu_rel15->SCID = 0; + pdsch_pdu_rel15->numDmrsCdmGrpsNoData = 1; + pdsch_pdu_rel15->dmrsPorts = 1; + pdsch_pdu_rel15->resourceAlloc = 1; + pdsch_pdu_rel15->rbStart = (rbStart!=NULL) ? *rbStart : 0; + pdsch_pdu_rel15->rbSize = (rbSize!=NULL) ? *rbSize : pdsch_pdu_rel15->BWPSize; + pdsch_pdu_rel15->VRBtoPRBMapping = 1; // non-interleaved, check if this is ok for initialBWP + + int startSymbolAndLength=0; + int time_domain_assignment=2; + int StartSymbolIndex,NrOfSymbols; + + AssertFatal(time_domain_assignmentbwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.count,"time_domain_assignment %d>=%d\n",time_domain_assignment,bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.count); + startSymbolAndLength = bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[time_domain_assignment]->startSymbolAndLength; + SLIV2SL(startSymbolAndLength,&StartSymbolIndex,&NrOfSymbols); + pdsch_pdu_rel15->StartSymbolIndex = StartSymbolIndex; + pdsch_pdu_rel15->NrOfSymbols = NrOfSymbols; + + // k0 = *bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[i]->k0; + pdsch_pdu_rel15->dlDmrsSymbPos = + fill_dmrs_mask(bwp->bwp_Dedicated->pdsch_Config->choice.setup, + scc->dmrs_TypeA_Position, + pdsch_pdu_rel15->NrOfSymbols); + + dci_pdu_rel15_t dci_pdu_rel15[MAX_DCI_CORESET]; + memset(dci_pdu_rel15, 0, sizeof(dci_pdu_rel15_t) * MAX_DCI_CORESET); + + // bwp indicator + int n_dl_bwp = secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count; + if (n_dl_bwp < 4) + dci_pdu_rel15[0].bwp_indicator.val = bwp_id; + else + dci_pdu_rel15[0].bwp_indicator.val = bwp_id - 1; // as per table 7.3.1.1.2-1 in 38.212 + // frequency domain assignment + if (bwp->bwp_Dedicated->pdsch_Config->choice.setup->resourceAllocation==NR_PDSCH_Config__resourceAllocation_resourceAllocationType1) + dci_pdu_rel15[0].frequency_domain_assignment.val = + PRBalloc_to_locationandbandwidth0( + pdsch_pdu_rel15->rbSize, + pdsch_pdu_rel15->rbStart, + NRRIV2BW(bwp->bwp_Common->genericParameters.locationAndBandwidth, + 275)); + else + AssertFatal(1==0,"Only frequency resource allocation type 1 is currently supported\n"); + // time domain assignment + dci_pdu_rel15[0].time_domain_assignment.val = time_domain_assignment; // row index used here instead of SLIV; + // mcs and rv + dci_pdu_rel15[0].mcs = pdsch_pdu_rel15->mcsIndex[0]; + dci_pdu_rel15[0].rv = pdsch_pdu_rel15->rvIndex[0]; + // harq pid and ndi + dci_pdu_rel15[0].harq_pid = current_harq_pid; + dci_pdu_rel15[0].ndi = UE_list->UE_sched_ctrl[UE_id].harq_processes[current_harq_pid].ndi; + // DAI + dci_pdu_rel15[0].dai[0].val = (pucch_sched->dai_c-1)&3; + + // TPC for PUCCH + dci_pdu_rel15[0].tpc = UE_list->UE_sched_ctrl[UE_id].tpc1; // table 7.2.1-1 in 38.213 + // PUCCH resource indicator + dci_pdu_rel15[0].pucch_resource_indicator = pucch_sched->resource_indicator; + // PDSCH to HARQ TI + dci_pdu_rel15[0].pdsch_to_harq_feedback_timing_indicator.val = pucch_sched->timing_indicator; + UE_list->UE_sched_ctrl[UE_id].harq_processes[current_harq_pid].feedback_slot = pucch_sched->ul_slot; + UE_list->UE_sched_ctrl[UE_id].harq_processes[current_harq_pid].is_waiting = 1; + // antenna ports + dci_pdu_rel15[0].antenna_ports.val = 0; // nb of cdm groups w/o data 1 and dmrs port 0 + // dmrs sequence initialization + dci_pdu_rel15[0].dmrs_sequence_initialization.val = pdsch_pdu_rel15->SCID; + LOG_D(MAC, + "[gNB scheduler phytest] DCI type 1 payload: freq_alloc %d (%d,%d,%d), " + "time_alloc %d, vrb to prb %d, mcs %d tb_scaling %d ndi %d rv %d\n", + dci_pdu_rel15[0].frequency_domain_assignment.val, + pdsch_pdu_rel15->rbStart, + pdsch_pdu_rel15->rbSize, + NRRIV2BW(bwp->bwp_Common->genericParameters.locationAndBandwidth, 275), + dci_pdu_rel15[0].time_domain_assignment.val, + dci_pdu_rel15[0].vrb_to_prb_mapping.val, + dci_pdu_rel15[0].mcs, + dci_pdu_rel15[0].tb_scaling, + dci_pdu_rel15[0].ndi, + dci_pdu_rel15[0].rv); + + NR_SearchSpace_t *ss; + int target_ss = NR_SearchSpace__searchSpaceType_PR_ue_Specific; + + AssertFatal(bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList!=NULL,"searchPsacesToAddModList is null\n"); + AssertFatal(bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList->list.count>0, + "searchPsacesToAddModList is empty\n"); + + int found=0; + + for (int i=0;ibwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList->list.count;i++) { + ss=bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList->list.array[i]; + AssertFatal(ss->controlResourceSetId != NULL,"ss->controlResourceSetId is null\n"); + AssertFatal(ss->searchSpaceType != NULL,"ss->searchSpaceType is null\n"); + if (ss->searchSpaceType->present == target_ss) { + found=1; + break; + } + } + AssertFatal(found==1,"Couldn't find an adequate searchspace\n"); + + int ret = nr_configure_pdcch(nr_mac, + pdcch_pdu_rel15, + UE_list->rnti[UE_id], + 1, // ue-specific + ss, + scc, + bwp); + if (ret < 0) { + LOG_I(MAC,"CCE list not empty, couldn't schedule PDSCH\n"); + return 0; + } + + int dci_formats[2]; + int rnti_types[2]; + + if (ss->searchSpaceType->choice.ue_Specific->dci_Formats) + dci_formats[0] = NR_DL_DCI_FORMAT_1_1; + else + dci_formats[0] = NR_DL_DCI_FORMAT_1_0; + + rnti_types[0] = NR_RNTI_C; + + fill_dci_pdu_rel15(scc,secondaryCellGroup,pdcch_pdu_rel15,dci_pdu_rel15,dci_formats,rnti_types,pdsch_pdu_rel15->BWPSize,bwp_id); + + LOG_D(MAC, + "DCI params: rnti %x, rnti_type %d, dci_format %d\n", + pdcch_pdu_rel15->dci_pdu.RNTI[0], + rnti_types[0], + dci_formats[0]); + LOG_D(MAC, + "coreset params: FreqDomainResource %llx, start_symbol %d n_symb %d\n", + (unsigned long long)pdcch_pdu_rel15->FreqDomainResource, + pdcch_pdu_rel15->StartSymbolIndex, + pdcch_pdu_rel15->DurationSymbols); + + int x_Overhead = 0; // should be 0 for initialBWP + nr_get_tbs_dl(&dl_tti_pdsch_pdu->pdsch_pdu,x_Overhead,pdsch_pdu_rel15->numDmrsCdmGrpsNoData,0); + + // Hardcode it for now + TBS = dl_tti_pdsch_pdu->pdsch_pdu.pdsch_pdu_rel15.TBSize[0]; + if (UE_list->UE_sched_ctrl[UE_id].harq_processes[current_harq_pid].round==0) + UE_list->mac_stats[UE_id].dlsch_total_bytes += TBS; + + LOG_D(MAC, + "DLSCH PDU: start PRB %d n_PRB %d startSymbolAndLength %d start symbol " + "%d nb_symbols %d nb_layers %d nb_codewords %d mcs %d TBS: %d\n", + pdsch_pdu_rel15->rbStart, + pdsch_pdu_rel15->rbSize, + startSymbolAndLength, + pdsch_pdu_rel15->StartSymbolIndex, + pdsch_pdu_rel15->NrOfSymbols, + pdsch_pdu_rel15->nrOfLayers, + pdsch_pdu_rel15->NrOfCodewords, + pdsch_pdu_rel15->mcsIndex[0], + TBS); + + return TBS; //Return TBS in bytes +} + int nr_configure_pdcch(gNB_MAC_INST *nr_mac, nfapi_nr_dl_tti_pdcch_pdu_rel15_t* pdcch_pdu, uint16_t rnti, diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index 3c51ea3a28..862b109a34 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -129,13 +129,20 @@ void nr_schedule_css_dlsch_phytest(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP); -int configure_fapi_dl_pdu(int Mod_id, +int nr_fill_nfapi_dl_pdu(int Mod_id, nfapi_nr_dl_tti_request_body_t *dl_req, NR_sched_pucch *pucch_sched, uint8_t *mcsIndex, uint16_t *rbSize, uint16_t *rbStart); +int configure_fapi_dl_pdu_phytest(int Mod_id, + nfapi_nr_dl_tti_request_body_t *dl_req, + NR_sched_pucch *pucch_sched, + uint8_t *mcsIndex, + uint16_t *rbSize, + uint16_t *rbStart); + void config_uldci(NR_BWP_Uplink_t *ubwp, nfapi_nr_pusch_pdu_t *pusch_pdu, nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15, From 9b2be0a1f693603a37b568c3eaf1e1f81c2ccfa2 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 7 Sep 2020 09:35:57 +0200 Subject: [PATCH 51/96] nr_fill_nfapi_dl_pdu(): Parameters by value, not pointers --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 14 +++++++++++++- .../LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c | 11 +++++------ openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 6 +++--- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index bd2749c530..ea6aff5578 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -420,6 +420,7 @@ void nr_schedule_ue_spec(module_id_t module_id, const int ta_len = gNB_mac->ta_len; const int UE_id = 0; const int CC_id = 0; + const int bwp_id = 1; nfapi_nr_dl_tti_request_body_t *dl_req = &gNB_mac->DL_req[CC_id].dl_tti_request_body; nfapi_nr_pdu_t *tx_req = &gNB_mac->TX_req[CC_id].pdu_list[gNB_mac->TX_req[CC_id].Number_of_PDUs]; @@ -427,6 +428,12 @@ void nr_schedule_ue_spec(module_id_t module_id, NR_UE_list_t *UE_list = &gNB_mac->UE_list; if (UE_list->num_UEs ==0) return; + NR_CellGroupConfig_t *secondaryCellGroup = UE_list->secondaryCellGroup[UE_id]; + AssertFatal(secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count == 1, + "downlinkBWP_ToAddModList has %d BWP!\n", + secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count); + NR_BWP_Downlink_t *bwp = secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[bwp_id - 1]; + const uint16_t bwpSize = NRRIV2BW(bwp->bwp_Common->genericParameters.locationAndBandwidth,275); unsigned char sdu_lcids[NB_RB_MAX] = {0}; uint16_t sdu_lengths[NB_RB_MAX] = {0}; @@ -439,7 +446,12 @@ void nr_schedule_ue_spec(module_id_t module_id, int pucch_sched; nr_update_pucch_scheduling(module_id, UE_id, frame, slot, num_slots_per_tdd, &pucch_sched); NR_sched_pucch *pucch = &UE_list->UE_sched_ctrl[UE_id].sched_pucch[pucch_sched]; - const int TBS_bytes = nr_fill_nfapi_dl_pdu(module_id, dl_req, pucch, NULL, NULL, NULL); + const int TBS_bytes = nr_fill_nfapi_dl_pdu(module_id, + dl_req, + pucch, + 9 /* mcs */, + bwpSize, + 0 /* bwpStart */); if (TBS_bytes == 0) return; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index 4e82ca5e06..bcdd1b131c 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -410,9 +410,9 @@ void nr_configure_css_dci_initial(nfapi_nr_dl_tti_pdcch_pdu_rel15_t* pdcch_pdu, int nr_fill_nfapi_dl_pdu(int Mod_idP, nfapi_nr_dl_tti_request_body_t *dl_req, NR_sched_pucch *pucch_sched, - uint8_t *mcsIndex, - uint16_t *rbSize, - uint16_t *rbStart) { + uint8_t mcs, + uint16_t rbSize, + uint16_t rbStart) { gNB_MAC_INST *nr_mac = RC.nrmac[Mod_idP]; NR_COMMON_channels_t *cc = nr_mac->common_channels; NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon; @@ -464,7 +464,6 @@ int nr_fill_nfapi_dl_pdu(int Mod_idP, pdsch_pdu_rel15->CyclicPrefix = 0; pdsch_pdu_rel15->NrOfCodewords = 1; - int mcs = (mcsIndex!=NULL) ? *mcsIndex : 9; int current_harq_pid = UE_list->UE_sched_ctrl[UE_id].current_harq_pid; pdsch_pdu_rel15->targetCodeRate[0] = nr_get_code_rate_dl(mcs,0); pdsch_pdu_rel15->qamModOrder[0] = 2; @@ -482,8 +481,8 @@ int nr_fill_nfapi_dl_pdu(int Mod_idP, pdsch_pdu_rel15->numDmrsCdmGrpsNoData = 1; pdsch_pdu_rel15->dmrsPorts = 1; pdsch_pdu_rel15->resourceAlloc = 1; - pdsch_pdu_rel15->rbStart = (rbStart!=NULL) ? *rbStart : 0; - pdsch_pdu_rel15->rbSize = (rbSize!=NULL) ? *rbSize : pdsch_pdu_rel15->BWPSize; + pdsch_pdu_rel15->rbStart = rbStart; + pdsch_pdu_rel15->rbSize = rbSize; pdsch_pdu_rel15->VRBtoPRBMapping = 1; // non-interleaved, check if this is ok for initialBWP int startSymbolAndLength=0; diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index 862b109a34..8d1daf6c46 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -132,9 +132,9 @@ void nr_schedule_css_dlsch_phytest(module_id_t module_idP, int nr_fill_nfapi_dl_pdu(int Mod_id, nfapi_nr_dl_tti_request_body_t *dl_req, NR_sched_pucch *pucch_sched, - uint8_t *mcsIndex, - uint16_t *rbSize, - uint16_t *rbStart); + uint8_t mcs, + uint16_t rbSize, + uint16_t rbStart); int configure_fapi_dl_pdu_phytest(int Mod_id, nfapi_nr_dl_tti_request_body_t *dl_req, From fc179f396c19d564073a7286d36f5e070083452b Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 7 Sep 2020 10:00:56 +0200 Subject: [PATCH 52/96] Inline nr_get_tbs_dl() --- .../NR_MAC_gNB/gNB_scheduler_primitives.c | 60 +++++++++++++++++-- 1 file changed, 54 insertions(+), 6 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index bcdd1b131c..1520cbe369 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -420,9 +420,9 @@ int nr_fill_nfapi_dl_pdu(int Mod_idP, nfapi_nr_dl_tti_request_pdu_t *dl_tti_pdcch_pdu; nfapi_nr_dl_tti_request_pdu_t *dl_tti_pdsch_pdu; - int TBS; int bwp_id=1; int UE_id = 0; + const int nrOfLayers = 1; NR_UE_list_t *UE_list = &RC.nrmac[Mod_idP]->UE_list; @@ -471,7 +471,7 @@ int nr_fill_nfapi_dl_pdu(int Mod_idP, pdsch_pdu_rel15->mcsTable[0] = 0; pdsch_pdu_rel15->rvIndex[0] = nr_rv_round_map[UE_list->UE_sched_ctrl[UE_id].harq_processes[current_harq_pid].round]; pdsch_pdu_rel15->dataScramblingId = *scc->physCellId; - pdsch_pdu_rel15->nrOfLayers = 1; + pdsch_pdu_rel15->nrOfLayers = nrOfLayers; pdsch_pdu_rel15->transmissionScheme = 0; pdsch_pdu_rel15->refPoint = 0; // Point A UE_list->mac_stats[UE_id].dlsch_rounds[UE_list->UE_sched_ctrl[UE_id].harq_processes[current_harq_pid].round]++; @@ -612,11 +612,59 @@ int nr_fill_nfapi_dl_pdu(int Mod_idP, pdcch_pdu_rel15->StartSymbolIndex, pdcch_pdu_rel15->DurationSymbols); - int x_Overhead = 0; // should be 0 for initialBWP - nr_get_tbs_dl(&dl_tti_pdsch_pdu->pdsch_pdu,x_Overhead,pdsch_pdu_rel15->numDmrsCdmGrpsNoData,0); + const uint16_t N_PRB_oh = 0; // overhead should be 0 for initialBWP + uint8_t N_PRB_DMRS; + if (pdsch_pdu_rel15->dmrsConfigType == NFAPI_NR_DMRS_TYPE1) { + // if no data in dmrs cdm group is 1 only even REs have no data + // if no data in dmrs cdm group is 2 both odd and even REs have no data + N_PRB_DMRS = pdsch_pdu_rel15->numDmrsCdmGrpsNoData * 6; + } else { + N_PRB_DMRS = pdsch_pdu_rel15->numDmrsCdmGrpsNoData * 4; + } + const uint8_t N_sh_symb = pdsch_pdu_rel15->NrOfSymbols; + + const uint8_t table_idx = 0; + const uint16_t R = nr_get_code_rate_dl(mcs, table_idx); + const uint8_t Qm = nr_get_Qm_dl(mcs, table_idx); + const uint32_t TBS = + nr_compute_tbs(Qm, + R, + rbSize, + N_sh_symb, + N_PRB_DMRS, // FIXME // This should be multiplied by the + // number of dmrs symbols + N_PRB_oh, + 0 /* tb_scaling */, + nrOfLayers) + >> 3; + + pdsch_pdu_rel15->targetCodeRate[0] = R; + pdsch_pdu_rel15->qamModOrder[0] = Qm; + pdsch_pdu_rel15->TBSize[0] = TBS; + // I don't know why the following is not needed, but in this case we don't + // need additional calculations: + const uint16_t N_RE_prime = NR_NB_SC_PER_RB * N_sh_symb - N_PRB_DMRS - N_PRB_oh; + LOG_D(MAC, + "N_RE_prime %d for %d symbols %d DMRS per PRB and %d overhead\n", + N_RE_prime, + N_sh_symb, + N_PRB_DMRS, + N_PRB_oh); + //pdsch_pdu_rel15->nb_mod_symbols = N_RE_prime*pdsch_pdu_rel15->n_prb*pdsch_pdu_rel15->nb_codewords; + pdsch_pdu_rel15->mcsTable[0] = table_idx; + + LOG_D(MAC, + "TBS %d bytes: N_PRB_DMRS %d N_sh_symb %d N_PRB_oh %d R %d Qm %d table " + "%d nb_symbols %d\n", + TBS, + N_PRB_DMRS, + N_sh_symb, + N_PRB_oh, + R, + Qm, + table_idx, + N_RE_prime * pdsch_pdu_rel15->rbSize * pdsch_pdu_rel15->NrOfCodewords); - // Hardcode it for now - TBS = dl_tti_pdsch_pdu->pdsch_pdu.pdsch_pdu_rel15.TBSize[0]; if (UE_list->UE_sched_ctrl[UE_id].harq_processes[current_harq_pid].round==0) UE_list->mac_stats[UE_id].dlsch_total_bytes += TBS; From 71bfadf192bb657326dfcf185aa43615e09aa3a7 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 7 Sep 2020 11:46:00 +0200 Subject: [PATCH 53/96] nr_fill_nfapi_dl_pdu(): MCS + other params configurable --- .../LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 15 +++++++++-- .../NR_MAC_gNB/gNB_scheduler_primitives.c | 25 ++++++++++--------- openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 7 +++++- 3 files changed, 32 insertions(+), 15 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index ea6aff5578..974998997f 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -446,12 +446,23 @@ void nr_schedule_ue_spec(module_id_t module_id, int pucch_sched; nr_update_pucch_scheduling(module_id, UE_id, frame, slot, num_slots_per_tdd, &pucch_sched); NR_sched_pucch *pucch = &UE_list->UE_sched_ctrl[UE_id].sched_pucch[pucch_sched]; + + const int nrOfLayers = 1; + const uint8_t mcs = 9; + const uint8_t numDmrsCdmGrpsNoData = 1; + const nfapi_nr_dmrs_type_e dmrsConfigType = bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type == NULL ? 0 : 1; + const int TBS_bytes = nr_fill_nfapi_dl_pdu(module_id, + UE_id, + bwp_id, dl_req, pucch, - 9 /* mcs */, + nrOfLayers, + mcs, bwpSize, - 0 /* bwpStart */); + 0 /* bwpStart */, + numDmrsCdmGrpsNoData, + dmrsConfigType); if (TBS_bytes == 0) return; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index 1520cbe369..6d030895f3 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -408,11 +408,16 @@ void nr_configure_css_dci_initial(nfapi_nr_dl_tti_pdcch_pdu_rel15_t* pdcch_pdu, } int nr_fill_nfapi_dl_pdu(int Mod_idP, + int UE_id, + int bwp_id, nfapi_nr_dl_tti_request_body_t *dl_req, NR_sched_pucch *pucch_sched, + int nrOfLayers, uint8_t mcs, uint16_t rbSize, - uint16_t rbStart) { + uint16_t rbStart, + uint8_t numDmrsCdmGrpsNoData, + nfapi_nr_dmrs_type_e dmrsConfigType) { gNB_MAC_INST *nr_mac = RC.nrmac[Mod_idP]; NR_COMMON_channels_t *cc = nr_mac->common_channels; NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon; @@ -420,10 +425,6 @@ int nr_fill_nfapi_dl_pdu(int Mod_idP, nfapi_nr_dl_tti_request_pdu_t *dl_tti_pdcch_pdu; nfapi_nr_dl_tti_request_pdu_t *dl_tti_pdsch_pdu; - int bwp_id=1; - int UE_id = 0; - const int nrOfLayers = 1; - NR_UE_list_t *UE_list = &RC.nrmac[Mod_idP]->UE_list; NR_CellGroupConfig_t *secondaryCellGroup = UE_list->secondaryCellGroup[UE_id]; @@ -475,10 +476,10 @@ int nr_fill_nfapi_dl_pdu(int Mod_idP, pdsch_pdu_rel15->transmissionScheme = 0; pdsch_pdu_rel15->refPoint = 0; // Point A UE_list->mac_stats[UE_id].dlsch_rounds[UE_list->UE_sched_ctrl[UE_id].harq_processes[current_harq_pid].round]++; - pdsch_pdu_rel15->dmrsConfigType = bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type == NULL ? 0 : 1; + pdsch_pdu_rel15->dmrsConfigType = dmrsConfigType; pdsch_pdu_rel15->dlDmrsScramblingId = *scc->physCellId; pdsch_pdu_rel15->SCID = 0; - pdsch_pdu_rel15->numDmrsCdmGrpsNoData = 1; + pdsch_pdu_rel15->numDmrsCdmGrpsNoData = numDmrsCdmGrpsNoData; pdsch_pdu_rel15->dmrsPorts = 1; pdsch_pdu_rel15->resourceAlloc = 1; pdsch_pdu_rel15->rbStart = rbStart; @@ -523,7 +524,7 @@ int nr_fill_nfapi_dl_pdu(int Mod_idP, // time domain assignment dci_pdu_rel15[0].time_domain_assignment.val = time_domain_assignment; // row index used here instead of SLIV; // mcs and rv - dci_pdu_rel15[0].mcs = pdsch_pdu_rel15->mcsIndex[0]; + dci_pdu_rel15[0].mcs = mcs; dci_pdu_rel15[0].rv = pdsch_pdu_rel15->rvIndex[0]; // harq pid and ndi dci_pdu_rel15[0].harq_pid = current_harq_pid; @@ -614,14 +615,14 @@ int nr_fill_nfapi_dl_pdu(int Mod_idP, const uint16_t N_PRB_oh = 0; // overhead should be 0 for initialBWP uint8_t N_PRB_DMRS; - if (pdsch_pdu_rel15->dmrsConfigType == NFAPI_NR_DMRS_TYPE1) { + if (dmrsConfigType == NFAPI_NR_DMRS_TYPE1) { // if no data in dmrs cdm group is 1 only even REs have no data // if no data in dmrs cdm group is 2 both odd and even REs have no data - N_PRB_DMRS = pdsch_pdu_rel15->numDmrsCdmGrpsNoData * 6; + N_PRB_DMRS = numDmrsCdmGrpsNoData * 6; } else { - N_PRB_DMRS = pdsch_pdu_rel15->numDmrsCdmGrpsNoData * 4; + N_PRB_DMRS = numDmrsCdmGrpsNoData * 4; } - const uint8_t N_sh_symb = pdsch_pdu_rel15->NrOfSymbols; + const uint8_t N_sh_symb = NrOfSymbols; const uint8_t table_idx = 0; const uint16_t R = nr_get_code_rate_dl(mcs, table_idx); diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index 8d1daf6c46..454424c1c7 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -130,11 +130,16 @@ void nr_schedule_css_dlsch_phytest(module_id_t module_idP, sub_frame_t subframeP); int nr_fill_nfapi_dl_pdu(int Mod_id, + int UE_id, + int bwp_id, nfapi_nr_dl_tti_request_body_t *dl_req, NR_sched_pucch *pucch_sched, + int nrOfLayers, uint8_t mcs, uint16_t rbSize, - uint16_t rbStart); + uint16_t rbStart, + uint8_t numDmrsCdmGrpsNoData, + nfapi_nr_dmrs_type_e dmrsConfigType); int configure_fapi_dl_pdu_phytest(int Mod_id, nfapi_nr_dl_tti_request_body_t *dl_req, From f0533b9ec40c7424bba4fe59957dc0c303883aed Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 7 Sep 2020 13:29:07 +0200 Subject: [PATCH 54/96] Move TBS calculation out of nr_fill_nfapi_dl_pdu --- .../LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 98 +++++++++++++---- .../NR_MAC_gNB/gNB_scheduler_primitives.c | 104 ++++++------------ openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 29 +++-- 3 files changed, 123 insertions(+), 108 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index 974998997f..9fa2a85011 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -32,6 +32,7 @@ /*PHY*/ #include "PHY/CODING/coding_defs.h" #include "PHY/defs_nr_common.h" +#include "common/utils/nr/nr_common.h" #include "PHY/NR_TRANSPORT/nr_transport_common_proto.h" /*MAC*/ #include "NR_MAC_COMMON/nr_mac.h" @@ -452,19 +453,68 @@ void nr_schedule_ue_spec(module_id_t module_id, const uint8_t numDmrsCdmGrpsNoData = 1; const nfapi_nr_dmrs_type_e dmrsConfigType = bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type == NULL ? 0 : 1; - const int TBS_bytes = nr_fill_nfapi_dl_pdu(module_id, - UE_id, - bwp_id, - dl_req, - pucch, - nrOfLayers, - mcs, - bwpSize, - 0 /* bwpStart */, - numDmrsCdmGrpsNoData, - dmrsConfigType); + const int time_domain_assignment = 2; + AssertFatal(time_domain_assignmentbwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.count,"time_domain_assignment %d>=%d\n",time_domain_assignment,bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.count); + const int startSymbolAndLength = bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[time_domain_assignment]->startSymbolAndLength; + int startSymbolIndex, nrOfSymbols; + SLIV2SL(startSymbolAndLength, &startSymbolIndex, &nrOfSymbols); - if (TBS_bytes == 0) + const uint16_t N_PRB_oh = 0; // overhead should be 0 for initialBWP + uint8_t N_PRB_DMRS; + if (dmrsConfigType == NFAPI_NR_DMRS_TYPE1) { + // if no data in dmrs cdm group is 1 only even REs have no data + // if no data in dmrs cdm group is 2 both odd and even REs have no data + N_PRB_DMRS = numDmrsCdmGrpsNoData * 6; + } else { + N_PRB_DMRS = numDmrsCdmGrpsNoData * 4; + } + const uint8_t N_sh_symb = nrOfSymbols; + + const uint16_t rbSize = bwpSize; + const uint8_t table_idx = 0; + const uint16_t R = nr_get_code_rate_dl(mcs, table_idx); + const uint8_t Qm = nr_get_Qm_dl(mcs, table_idx); + const uint32_t TBS = + nr_compute_tbs(Qm, + R, + rbSize, + N_sh_symb, + N_PRB_DMRS, // FIXME // This should be multiplied by the + // number of dmrs symbols + N_PRB_oh, + 0 /* tb_scaling */, + nrOfLayers) + >> 3; + LOG_D(MAC, + "TBS %d bytes: N_PRB_DMRS %d N_sh_symb %d N_PRB_oh %d R %d Qm %d table %d", + TBS, + N_PRB_DMRS, + N_sh_symb, + N_PRB_oh, + R, + Qm, + table_idx); + + nr_fill_nfapi_dl_pdu(module_id, + UE_id, + bwp_id, + dl_req, + pucch, + nrOfLayers, + mcs, + rbSize, + 0 /* bwpStart */, + numDmrsCdmGrpsNoData, + dmrsConfigType, + table_idx, + R, + Qm, + TBS, + time_domain_assignment, + startSymbolIndex, + nrOfSymbols); + + if (TBS == 0) return; const int lcid = DL_SCH_LCID_DTCH; @@ -473,7 +523,7 @@ void nr_schedule_ue_spec(module_id_t module_id, int sdu_length_total = 0; int num_sdus = 0; LOG_D(MAC, "[gNB %d], Frame %d, DTCH%d->DLSCH, Checking RLC status (TBS %d bytes, len %d)\n", - module_id, frame, lcid, TBS_bytes, TBS_bytes - ta_len - header_length_total - sdu_length_total - 3); + module_id, frame, lcid, TBS, TBS - ta_len - header_length_total - sdu_length_total - 3); const mac_rlc_status_resp_t rlc_status = mac_rlc_status_ind(module_id, rnti, @@ -490,9 +540,9 @@ void nr_schedule_ue_spec(module_id_t module_id, LOG_I(MAC, "configure fapi due to data availability \n"); - LOG_I(MAC, "[gNB %d][USER-PLANE DEFAULT DRB] Frame %d : DTCH->DLSCH, Requesting %d bytes from RLC (lcid %d total hdr len %d), TBS_bytes: %d \n \n", - module_id, frame, TBS_bytes - ta_len - header_length_total - sdu_length_total - 3, - lcid, header_length_total, TBS_bytes); + LOG_I(MAC, "[gNB %d][USER-PLANE DEFAULT DRB] Frame %d : DTCH->DLSCH, Requesting %d bytes from RLC (lcid %d total hdr len %d), TBS: %d \n \n", + module_id, frame, TBS - ta_len - header_length_total - sdu_length_total - 3, + lcid, header_length_total, TBS); sdu_lengths[num_sdus] = mac_rlc_data_req(module_id, rnti, @@ -501,7 +551,7 @@ void nr_schedule_ue_spec(module_id_t module_id, ENB_FLAG_YES, MBMS_FLAG_NO, lcid, - TBS_bytes - ta_len - header_length_total - sdu_length_total - 3, + TBS - ta_len - header_length_total - sdu_length_total - 3, (char *)&mac_sdus[sdu_length_total], 0, 0); @@ -520,10 +570,10 @@ void nr_schedule_ue_spec(module_id_t module_id, else { LOG_I(MAC, "Configuring DL_TX in %d.%d: random data\n", frame, slot); // fill dlsch_buffer with random data - for (int i = 0; i < TBS_bytes; i++) + for (int i = 0; i < TBS; i++) mac_sdus[i] = (unsigned char) (lrand48()&0xff); sdu_lcids[0] = 0x3f; // DRB - sdu_lengths[0] = TBS_bytes - ta_len - 3; + sdu_lengths[0] = TBS - ta_len - 3; header_length_total += 2 + (sdu_lengths[0] >= 128); sdu_length_total += sdu_lengths[0]; num_sdus +=1; @@ -537,9 +587,9 @@ void nr_schedule_ue_spec(module_id_t module_id, } // Check if there is data from RLC or CE - const int post_padding = TBS_bytes >= 2 + header_length_total + sdu_length_total + ta_len; + const int post_padding = TBS >= 2 + header_length_total + sdu_length_total + ta_len; // padding param currently not in use - //padding = TBS_bytes - header_length_total - sdu_length_total - ta_len - 1; + //padding = TBS - header_length_total - sdu_length_total - ta_len - 1; const int offset = nr_generate_dlsch_pdu( module_id, @@ -554,7 +604,7 @@ void nr_schedule_ue_spec(module_id_t module_id, // Padding: fill remainder of DLSCH with 0 if (post_padding > 0) { - for (int j = 0; j < TBS_bytes - offset; j++) + for (int j = 0; j < TBS - offset; j++) gNB_mac->UE_list.DLSCH_pdu[0][0].payload[0][offset + j] = 0; } @@ -563,7 +613,7 @@ void nr_schedule_ue_spec(module_id_t module_id, slot, dl_req, tx_req, - TBS_bytes, + TBS, gNB_mac->pdu_index[CC_id]); #if defined(ENABLE_MAC_PAYLOAD_DEBUG) @@ -572,7 +622,7 @@ void nr_schedule_ue_spec(module_id_t module_id, "%d.%d, first 10 payload bytes, TBS size: %d \n", frame, slot, - TBS_bytes); + TBS); for(int i = 0; i < 10; i++) { LOG_I(MAC, "byte %d : %x\n", i,((uint8_t *)gNB_mac->UE_list.DLSCH_pdu[0][0].payload[0])[i]); } diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index 6d030895f3..3a95ac0ac4 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -407,17 +407,24 @@ void nr_configure_css_dci_initial(nfapi_nr_dl_tti_pdcch_pdu_rel15_t* pdcch_pdu, } -int nr_fill_nfapi_dl_pdu(int Mod_idP, - int UE_id, - int bwp_id, - nfapi_nr_dl_tti_request_body_t *dl_req, - NR_sched_pucch *pucch_sched, - int nrOfLayers, - uint8_t mcs, - uint16_t rbSize, - uint16_t rbStart, - uint8_t numDmrsCdmGrpsNoData, - nfapi_nr_dmrs_type_e dmrsConfigType) { +void nr_fill_nfapi_dl_pdu(int Mod_idP, + int UE_id, + int bwp_id, + nfapi_nr_dl_tti_request_body_t *dl_req, + NR_sched_pucch *pucch_sched, + int nrOfLayers, + uint8_t mcs, + uint16_t rbSize, + uint16_t rbStart, + uint8_t numDmrsCdmGrpsNoData, + nfapi_nr_dmrs_type_e dmrsConfigType, + uint8_t table_idx, + uint16_t R, + uint8_t Qm, + uint32_t TBS, + int time_domain_assignment, + int StartSymbolIndex, + int NrOfSymbols) { gNB_MAC_INST *nr_mac = RC.nrmac[Mod_idP]; NR_COMMON_channels_t *cc = nr_mac->common_channels; NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon; @@ -485,14 +492,10 @@ int nr_fill_nfapi_dl_pdu(int Mod_idP, pdsch_pdu_rel15->rbStart = rbStart; pdsch_pdu_rel15->rbSize = rbSize; pdsch_pdu_rel15->VRBtoPRBMapping = 1; // non-interleaved, check if this is ok for initialBWP - - int startSymbolAndLength=0; - int time_domain_assignment=2; - int StartSymbolIndex,NrOfSymbols; - - AssertFatal(time_domain_assignmentbwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.count,"time_domain_assignment %d>=%d\n",time_domain_assignment,bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.count); - startSymbolAndLength = bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[time_domain_assignment]->startSymbolAndLength; - SLIV2SL(startSymbolAndLength,&StartSymbolIndex,&NrOfSymbols); + pdsch_pdu_rel15->targetCodeRate[0] = R; + pdsch_pdu_rel15->qamModOrder[0] = Qm; + pdsch_pdu_rel15->TBSize[0] = TBS; + pdsch_pdu_rel15->mcsTable[0] = table_idx; pdsch_pdu_rel15->StartSymbolIndex = StartSymbolIndex; pdsch_pdu_rel15->NrOfSymbols = NrOfSymbols; @@ -613,76 +616,31 @@ int nr_fill_nfapi_dl_pdu(int Mod_idP, pdcch_pdu_rel15->StartSymbolIndex, pdcch_pdu_rel15->DurationSymbols); - const uint16_t N_PRB_oh = 0; // overhead should be 0 for initialBWP - uint8_t N_PRB_DMRS; - if (dmrsConfigType == NFAPI_NR_DMRS_TYPE1) { - // if no data in dmrs cdm group is 1 only even REs have no data - // if no data in dmrs cdm group is 2 both odd and even REs have no data - N_PRB_DMRS = numDmrsCdmGrpsNoData * 6; - } else { - N_PRB_DMRS = numDmrsCdmGrpsNoData * 4; - } - const uint8_t N_sh_symb = NrOfSymbols; - - const uint8_t table_idx = 0; - const uint16_t R = nr_get_code_rate_dl(mcs, table_idx); - const uint8_t Qm = nr_get_Qm_dl(mcs, table_idx); - const uint32_t TBS = - nr_compute_tbs(Qm, - R, - rbSize, - N_sh_symb, - N_PRB_DMRS, // FIXME // This should be multiplied by the - // number of dmrs symbols - N_PRB_oh, - 0 /* tb_scaling */, - nrOfLayers) - >> 3; - - pdsch_pdu_rel15->targetCodeRate[0] = R; - pdsch_pdu_rel15->qamModOrder[0] = Qm; - pdsch_pdu_rel15->TBSize[0] = TBS; // I don't know why the following is not needed, but in this case we don't // need additional calculations: - const uint16_t N_RE_prime = NR_NB_SC_PER_RB * N_sh_symb - N_PRB_DMRS - N_PRB_oh; - LOG_D(MAC, - "N_RE_prime %d for %d symbols %d DMRS per PRB and %d overhead\n", - N_RE_prime, - N_sh_symb, - N_PRB_DMRS, - N_PRB_oh); + //const uint16_t N_RE_prime = NR_NB_SC_PER_RB * N_sh_symb - N_PRB_DMRS - N_PRB_oh; + //LOG_D(MAC, + // "N_RE_prime %d for %d symbols %d DMRS per PRB and %d overhead\n", + // N_RE_prime, + // N_sh_symb, + // N_PRB_DMRS, + // N_PRB_oh); //pdsch_pdu_rel15->nb_mod_symbols = N_RE_prime*pdsch_pdu_rel15->n_prb*pdsch_pdu_rel15->nb_codewords; - pdsch_pdu_rel15->mcsTable[0] = table_idx; - - LOG_D(MAC, - "TBS %d bytes: N_PRB_DMRS %d N_sh_symb %d N_PRB_oh %d R %d Qm %d table " - "%d nb_symbols %d\n", - TBS, - N_PRB_DMRS, - N_sh_symb, - N_PRB_oh, - R, - Qm, - table_idx, - N_RE_prime * pdsch_pdu_rel15->rbSize * pdsch_pdu_rel15->NrOfCodewords); if (UE_list->UE_sched_ctrl[UE_id].harq_processes[current_harq_pid].round==0) UE_list->mac_stats[UE_id].dlsch_total_bytes += TBS; LOG_D(MAC, - "DLSCH PDU: start PRB %d n_PRB %d startSymbolAndLength %d start symbol " - "%d nb_symbols %d nb_layers %d nb_codewords %d mcs %d TBS: %d\n", + "DLSCH PDU: start PRB %d n_PRB %d start symbol %d nb_symbols %d " + "nb_layers %d nb_codewords %d mcs %d TBS: %d\n", pdsch_pdu_rel15->rbStart, pdsch_pdu_rel15->rbSize, - startSymbolAndLength, pdsch_pdu_rel15->StartSymbolIndex, pdsch_pdu_rel15->NrOfSymbols, pdsch_pdu_rel15->nrOfLayers, pdsch_pdu_rel15->NrOfCodewords, pdsch_pdu_rel15->mcsIndex[0], TBS); - - return TBS; //Return TBS in bytes } int nr_configure_pdcch(gNB_MAC_INST *nr_mac, diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index 454424c1c7..c5b1e6ffc1 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -129,17 +129,24 @@ void nr_schedule_css_dlsch_phytest(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP); -int nr_fill_nfapi_dl_pdu(int Mod_id, - int UE_id, - int bwp_id, - nfapi_nr_dl_tti_request_body_t *dl_req, - NR_sched_pucch *pucch_sched, - int nrOfLayers, - uint8_t mcs, - uint16_t rbSize, - uint16_t rbStart, - uint8_t numDmrsCdmGrpsNoData, - nfapi_nr_dmrs_type_e dmrsConfigType); +void nr_fill_nfapi_dl_pdu(int Mod_id, + int UE_id, + int bwp_id, + nfapi_nr_dl_tti_request_body_t *dl_req, + NR_sched_pucch *pucch_sched, + int nrOfLayers, + uint8_t mcs, + uint16_t rbSize, + uint16_t rbStart, + uint8_t numDmrsCdmGrpsNoData, + nfapi_nr_dmrs_type_e dmrsConfigType, + uint8_t table_idx, + uint16_t R, + uint8_t Qm, + uint32_t tbs, + int time_domain_assignment, + int StartSymbolIndex, + int NrOfSymbols); int configure_fapi_dl_pdu_phytest(int Mod_id, nfapi_nr_dl_tti_request_body_t *dl_req, From 67a081772dbccf1005425ac0b9fd3d7f830c0ddc Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 7 Sep 2020 14:03:24 +0200 Subject: [PATCH 55/96] Restructure nr_schedule_ue_spec() --- .../LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 138 ++++++++++-------- 1 file changed, 74 insertions(+), 64 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index 9fa2a85011..44756c8f3f 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -418,17 +418,42 @@ void nr_schedule_ue_spec(module_id_t module_id, sub_frame_t slot, int num_slots_per_tdd) { gNB_MAC_INST *gNB_mac = RC.nrmac[module_id]; + NR_UE_list_t *UE_list = &gNB_mac->UE_list; + if (UE_list->num_UEs == 0) + return; + const int ta_len = gNB_mac->ta_len; const int UE_id = 0; const int CC_id = 0; + + /* Retrieve amount of data to send for this UE */ + const int lcid = DL_SCH_LCID_DTCH; + const uint16_t rnti = UE_list->rnti[UE_id]; + const mac_rlc_status_resp_t rlc_status = mac_rlc_status_ind(module_id, + rnti, + module_id, + frame, + slot, + ENB_FLAG_YES, + MBMS_FLAG_NO, + lcid, + 0, + 0); + LOG_D(MAC, + "%d.%d, DTCH%d->DLSCH, RLC status %d bytes\n", + frame, + slot, + lcid, + rlc_status.bytes_in_buffer); + + /* PREPROCESSOR */ + /* Find PUCCH occasion */ + int pucch_sched; + nr_update_pucch_scheduling(module_id, UE_id, frame, slot, num_slots_per_tdd, &pucch_sched); + NR_sched_pucch *pucch = &UE_list->UE_sched_ctrl[UE_id].sched_pucch[pucch_sched]; + + /* BWP and following: for MCS calculation, possibly based on CQI and RLC ind */ const int bwp_id = 1; - - nfapi_nr_dl_tti_request_body_t *dl_req = &gNB_mac->DL_req[CC_id].dl_tti_request_body; - nfapi_nr_pdu_t *tx_req = &gNB_mac->TX_req[CC_id].pdu_list[gNB_mac->TX_req[CC_id].Number_of_PDUs]; - - NR_UE_list_t *UE_list = &gNB_mac->UE_list; - - if (UE_list->num_UEs ==0) return; NR_CellGroupConfig_t *secondaryCellGroup = UE_list->secondaryCellGroup[UE_id]; AssertFatal(secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count == 1, "downlinkBWP_ToAddModList has %d BWP!\n", @@ -436,20 +461,8 @@ void nr_schedule_ue_spec(module_id_t module_id, NR_BWP_Downlink_t *bwp = secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[bwp_id - 1]; const uint16_t bwpSize = NRRIV2BW(bwp->bwp_Common->genericParameters.locationAndBandwidth,275); - unsigned char sdu_lcids[NB_RB_MAX] = {0}; - uint16_t sdu_lengths[NB_RB_MAX] = {0}; - const uint16_t rnti = UE_list->rnti[UE_id]; - - uint8_t mac_sdus[MAX_NR_DLSCH_PAYLOAD_BYTES]; - - LOG_D(MAC, "Scheduling UE specific search space DCI type 1\n"); - - int pucch_sched; - nr_update_pucch_scheduling(module_id, UE_id, frame, slot, num_slots_per_tdd, &pucch_sched); - NR_sched_pucch *pucch = &UE_list->UE_sched_ctrl[UE_id].sched_pucch[pucch_sched]; - - const int nrOfLayers = 1; const uint8_t mcs = 9; + const int nrOfLayers = 1; const uint8_t numDmrsCdmGrpsNoData = 1; const nfapi_nr_dmrs_type_e dmrsConfigType = bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type == NULL ? 0 : 1; @@ -485,6 +498,7 @@ void nr_schedule_ue_spec(module_id_t module_id, 0 /* tb_scaling */, nrOfLayers) >> 3; + AssertFatal(TBS != 0, "TBS is zero but requested %d RBs!\n", rbSize); LOG_D(MAC, "TBS %d bytes: N_PRB_DMRS %d N_sh_symb %d N_PRB_oh %d R %d Qm %d table %d", TBS, @@ -495,54 +509,25 @@ void nr_schedule_ue_spec(module_id_t module_id, Qm, table_idx); - nr_fill_nfapi_dl_pdu(module_id, - UE_id, - bwp_id, - dl_req, - pucch, - nrOfLayers, - mcs, - rbSize, - 0 /* bwpStart */, - numDmrsCdmGrpsNoData, - dmrsConfigType, - table_idx, - R, - Qm, - TBS, - time_domain_assignment, - startSymbolIndex, - nrOfSymbols); - - if (TBS == 0) - return; - - const int lcid = DL_SCH_LCID_DTCH; + /* POST processing */ + /* Get RLC data TODO: remove random data retrieval */ int header_length_total = 0; int header_length_last = 0; int sdu_length_total = 0; int num_sdus = 0; - LOG_D(MAC, "[gNB %d], Frame %d, DTCH%d->DLSCH, Checking RLC status (TBS %d bytes, len %d)\n", - module_id, frame, lcid, TBS, TBS - ta_len - header_length_total - sdu_length_total - 3); - - const mac_rlc_status_resp_t rlc_status = mac_rlc_status_ind(module_id, - rnti, - module_id, - frame, - slot, - ENB_FLAG_YES, - MBMS_FLAG_NO, - lcid, - 0, - 0); - + uint16_t sdu_lengths[NB_RB_MAX] = {0}; + uint8_t mac_sdus[MAX_NR_DLSCH_PAYLOAD_BYTES]; + unsigned char sdu_lcids[NB_RB_MAX] = {0}; if (rlc_status.bytes_in_buffer > 0) { - - LOG_I(MAC, "configure fapi due to data availability \n"); - - LOG_I(MAC, "[gNB %d][USER-PLANE DEFAULT DRB] Frame %d : DTCH->DLSCH, Requesting %d bytes from RLC (lcid %d total hdr len %d), TBS: %d \n \n", - module_id, frame, TBS - ta_len - header_length_total - sdu_length_total - 3, - lcid, header_length_total, TBS); + LOG_D(MAC, + "[gNB %d][USER-PLANE DEFAULT DRB] Frame %d : DTCH->DLSCH, Requesting " + "%d bytes from RLC (lcid %d total hdr len %d), TBS: %d \n \n", + module_id, + frame, + TBS - ta_len - header_length_total - sdu_length_total - 3, + lcid, + header_length_total, + TBS); sdu_lengths[num_sdus] = mac_rlc_data_req(module_id, rnti, @@ -556,7 +541,11 @@ void nr_schedule_ue_spec(module_id_t module_id, 0, 0); - LOG_W(MAC, "[gNB %d][USER-PLANE DEFAULT DRB] Got %d bytes for DTCH %d \n", module_id, sdu_lengths[num_sdus], lcid); + LOG_I(MAC, + "[gNB %d][USER-PLANE DEFAULT DRB] Got %d bytes for DTCH %d \n", + module_id, + sdu_lengths[num_sdus], + lcid); sdu_lcids[num_sdus] = lcid; sdu_length_total += sdu_lengths[num_sdus]; @@ -608,6 +597,27 @@ void nr_schedule_ue_spec(module_id_t module_id, gNB_mac->UE_list.DLSCH_pdu[0][0].payload[0][offset + j] = 0; } + nfapi_nr_dl_tti_request_body_t *dl_req = &gNB_mac->DL_req[CC_id].dl_tti_request_body; + nr_fill_nfapi_dl_pdu(module_id, + UE_id, + bwp_id, + dl_req, + pucch, + nrOfLayers, + mcs, + rbSize, + 0 /* bwpStart */, + numDmrsCdmGrpsNoData, + dmrsConfigType, + table_idx, + R, + Qm, + TBS, + time_domain_assignment, + startSymbolIndex, + nrOfSymbols); + + nfapi_nr_pdu_t *tx_req = &gNB_mac->TX_req[CC_id].pdu_list[gNB_mac->TX_req[CC_id].Number_of_PDUs]; configure_fapi_dl_Tx(module_id, frame, slot, From 5578aeb4a52248ce9da0e1ddfc24c1ad3361132f Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 7 Sep 2020 17:59:14 +0200 Subject: [PATCH 56/96] Do not allocate CCE in nr_configure_pdcch() nr_configure_pdcch() allocates the CCE, but this is not wanted, e.g., in multi-user scheduling, since it might not be possible to allocate the CCEs for these UEs. This commit makes the following changes: - remove CCE allocation in nr_configure_pdcch() - remove coreset search in nr_configure_pdcch() - add functions get_coreset() and get_searchspace() to retrieve coresets and search spaces easily - in nr_fill_nfapi_dl_pdu(), add extra parameters for aggregation level and CCE indices and the searchspace and coreset of a UE, which might be different for each UE - allocate CCEs manually in phytest, RA, and DLSCH schedulers --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c | 26 ++- .../LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 37 +++- .../LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c | 68 +++++-- .../NR_MAC_gNB/gNB_scheduler_primitives.c | 179 +++++++----------- openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 39 ++-- 5 files changed, 201 insertions(+), 148 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c index 4c17ee3a0f..7ada7fd537 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c @@ -681,7 +681,31 @@ void nr_generate_Msg2(module_id_t module_idP, dci_pdu_rel15[0].mcs, dci_pdu_rel15[0].tb_scaling); - nr_configure_pdcch(nr_mac, pdcch_pdu_rel15, RA_rnti, 0, ss, scc, bwp); + uint8_t nr_of_candidates, aggregation_level; + find_aggregation_candidates(&aggregation_level, &nr_of_candidates, ss); + NR_ControlResourceSet_t *coreset = get_coreset(bwp, ss, 0 /* common */); + int CCEIndex = allocate_nr_CCEs( + nr_mac, + bwp, + coreset, + aggregation_level, + ss->searchSpaceType->present - 1, // 0 common, 1 ue-specific + UE_id, + 0); // m + + if (CCEIndex < 0) { + LOG_E(MAC, "%s(): cannot find free CCE for UE %d!\n", __func__, UE_id); + return; + } + nr_configure_pdcch(nr_mac, + pdcch_pdu_rel15, + RA_rnti, + ss, + coreset, + scc, + bwp, + aggregation_level, + CCEIndex); LOG_I(MAC, "Frame %d: Subframe %d : Adding common DL DCI for RA_RNTI %x\n", frameP, slotP, RA_rnti); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index 44756c8f3f..9395670759 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -447,18 +447,37 @@ void nr_schedule_ue_spec(module_id_t module_id, rlc_status.bytes_in_buffer); /* PREPROCESSOR */ - /* Find PUCCH occasion */ - int pucch_sched; - nr_update_pucch_scheduling(module_id, UE_id, frame, slot, num_slots_per_tdd, &pucch_sched); - NR_sched_pucch *pucch = &UE_list->UE_sched_ctrl[UE_id].sched_pucch[pucch_sched]; - - /* BWP and following: for MCS calculation, possibly based on CQI and RLC ind */ + /* BWP */ const int bwp_id = 1; NR_CellGroupConfig_t *secondaryCellGroup = UE_list->secondaryCellGroup[UE_id]; AssertFatal(secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count == 1, "downlinkBWP_ToAddModList has %d BWP!\n", secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count); NR_BWP_Downlink_t *bwp = secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[bwp_id - 1]; + + const int target_ss = NR_SearchSpace__searchSpaceType_PR_ue_Specific; + NR_SearchSpace_t *ss = get_searchspace(bwp, target_ss); + + /* Find a free CCE */ + uint8_t nr_of_candidates, aggregation_level; + find_aggregation_candidates(&aggregation_level, &nr_of_candidates, ss); + NR_ControlResourceSet_t *coreset = get_coreset(bwp, ss, 1 /* dedicated */); + int CCEIndex = allocate_nr_CCEs(gNB_mac, + bwp, + coreset, + aggregation_level, + ss->searchSpaceType->present - 1, + UE_id, + 0); // m + if (CCEIndex < 0) { + LOG_E(MAC, "%s(): could not find CCE for UE %d\n", __func__, UE_id); + return; + } + /* Find PUCCH occasion */ + int pucch_sched; + nr_update_pucch_scheduling(module_id, UE_id, frame, slot, num_slots_per_tdd, &pucch_sched); + NR_sched_pucch *pucch = &UE_list->UE_sched_ctrl[UE_id].sched_pucch[pucch_sched]; + const uint16_t bwpSize = NRRIV2BW(bwp->bwp_Common->genericParameters.locationAndBandwidth,275); const uint8_t mcs = 9; @@ -601,6 +620,8 @@ void nr_schedule_ue_spec(module_id_t module_id, nr_fill_nfapi_dl_pdu(module_id, UE_id, bwp_id, + ss, + coreset, dl_req, pucch, nrOfLayers, @@ -615,7 +636,9 @@ void nr_schedule_ue_spec(module_id_t module_id, TBS, time_domain_assignment, startSymbolIndex, - nrOfSymbols); + nrOfSymbols, + aggregation_level, + CCEIndex); nfapi_nr_pdu_t *tx_req = &gNB_mac->TX_req[CC_id].pdu_list[gNB_mac->TX_req[CC_id].Number_of_PDUs]; configure_fapi_dl_Tx(module_id, diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c index 2a0367b68a..0f46831a1a 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c @@ -414,18 +414,31 @@ int configure_fapi_dl_pdu_phytest(int Mod_idP, } AssertFatal(found==1,"Couldn't find an adequate searchspace\n"); - int ret = nr_configure_pdcch(nr_mac, - pdcch_pdu_rel15, - UE_list->rnti[UE_id], - 1, // ue-specific - ss, - scc, - bwp); - if (ret < 0) { - LOG_I(MAC,"CCE list not empty, couldn't schedule PDSCH\n"); - free(dci_pdu_rel15); - return (0); + uint8_t nr_of_candidates, aggregation_level; + find_aggregation_candidates(&aggregation_level, &nr_of_candidates, ss); + NR_ControlResourceSet_t *coreset = get_coreset(bwp, ss, 1 /* dedicated */); + int CCEIndex = allocate_nr_CCEs( + nr_mac, + bwp, + coreset, + aggregation_level, + ss->searchSpaceType->present - 1, // 0 common, 1 ue-specific + UE_id, + 0); // m + if (CCEIndex < 0) { + LOG_E(MAC, "%s(): CCE list not empty, couldn't schedule PDSCH\n", __func__); + free(dci_pdu_rel15); + return 0; } + nr_configure_pdcch(nr_mac, + pdcch_pdu_rel15, + UE_list->rnti[UE_id], + ss, + coreset, + scc, + bwp, + aggregation_level, + CCEIndex); int dci_formats[2]; int rnti_types[2]; @@ -1083,20 +1096,33 @@ void schedule_fapi_ul_pdu(int Mod_idP, rnti_types[0] = NR_RNTI_C; LOG_D(MAC,"Configuring ULDCI/PDCCH in %d.%d\n", frameP,slotP); - int ret = nr_configure_pdcch(nr_mac, - pdcch_pdu_rel15, - UE_list->rnti[UE_id], - 1, // ue-specific, - ss, - scc, - bwp); - - if (ret < 0) { - LOG_I(MAC,"CCE list not empty, couldn't schedule PUSCH\n"); + uint8_t nr_of_candidates, aggregation_level; + find_aggregation_candidates(&aggregation_level, &nr_of_candidates, ss); + NR_ControlResourceSet_t *coreset = get_coreset(bwp, ss, 1 /* dedicated */); + int CCEIndex = allocate_nr_CCEs( + nr_mac, + bwp, + coreset, + aggregation_level, + ss->searchSpaceType->present - 1, // 0 common, 1 ue-specific + UE_id, + 0); // m + if (CCEIndex < 0) { + LOG_E(MAC, "%s(): CCE list not empty, couldn't schedule PUSCH\n", __func__); pusch_sched->active = false; return; } else { + nr_configure_pdcch(nr_mac, + pdcch_pdu_rel15, + UE_list->rnti[UE_id], + ss, + coreset, + scc, + bwp, + aggregation_level, + CCEIndex); + dci_pdu_rel15_t *dci_pdu_rel15 = calloc(MAX_DCI_CORESET,sizeof(dci_pdu_rel15_t)); config_uldci(ubwp,pusch_pdu,pdcch_pdu_rel15,&dci_pdu_rel15[0],dci_formats,rnti_types,time_domain_assignment,UE_list->UE_sched_ctrl[UE_id].tpc0,n_ubwp,bwp_id); fill_dci_pdu_rel15(scc,secondaryCellGroup,pdcch_pdu_rel15,dci_pdu_rel15,dci_formats,rnti_types,pusch_pdu->bwp_size,bwp_id); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index 3a95ac0ac4..4de05f72ba 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -127,37 +127,65 @@ static inline uint8_t get_max_cces(uint8_t scs) { return (nr_max_number_of_cces_per_slot[scs]); } +NR_ControlResourceSet_t *get_coreset(NR_BWP_Downlink_t *bwp, + NR_SearchSpace_t *ss, + int ss_type) { + NR_ControlResourceSetId_t coreset_id = *ss->controlResourceSetId; + if (ss_type == 0) { // common search space + AssertFatal(coreset_id != 0, "coreset0 currently not supported\n"); + NR_ControlResourceSet_t *coreset = bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonControlResourceSet; + AssertFatal(coreset_id == coreset->controlResourceSetId, + "ID of common ss coreset does not correspond to id set in the " + "search space\n"); + return coreset; + } else { + const int n = bwp->bwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList->list.count; + for (int i = 0; i < n; i++) { + NR_ControlResourceSet_t *coreset = + bwp->bwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList->list.array[i]; + if (coreset_id == coreset->controlResourceSetId) { + return coreset; + } + } + AssertFatal(0, "Couldn't find coreset with id %ld\n", coreset_id); + } +} + +NR_SearchSpace_t *get_searchspace( + NR_BWP_Downlink_t *bwp, + NR_SearchSpace__searchSpaceType_PR target_ss) { + DevAssert(bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList); + DevAssert(bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList->list.count > 0); + + const int n = bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList->list.count; + for (int i=0;ibwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList->list.array[i]; + AssertFatal(ss->controlResourceSetId != NULL, "ss->controlResourceSetId is null\n"); + AssertFatal(ss->searchSpaceType != NULL, "ss->searchSpaceType is null\n"); + if (ss->searchSpaceType->present == target_ss) { + return ss; + } + } + AssertFatal(0, "Couldn't find an adequate searchspace\n"); +} + int allocate_nr_CCEs(gNB_MAC_INST *nr_mac, - int bwp_id, - int list_id, - int aggregation, - int search_space, // 0 common, 1 ue-specific - int UE_id, - int m) { + NR_BWP_Downlink_t *bwp, + NR_ControlResourceSet_t *coreset, + int aggregation, + int search_space, // 0 common, 1 ue-specific + int UE_id, + int m) { // uncomment these when we allocate for common search space // NR_COMMON_channels_t *cc = nr_mac->common_channels; // NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon; NR_UE_list_t *UE_list = &nr_mac->UE_list; - NR_BWP_Downlink_t *bwp; - NR_CellGroupConfig_t *secondaryCellGroup; - - NR_ControlResourceSet_t *coreset; - AssertFatal(UE_list->active[UE_id] >=0,"UE_id %d is not active\n",UE_id); - secondaryCellGroup = UE_list->secondaryCellGroup[UE_id]; - bwp=secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[bwp_id-1]; - - if (search_space == 1) { - coreset = bwp->bwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList->list.array[list_id]; - } - else { - coreset = bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonControlResourceSet; - } int coreset_id = coreset->controlResourceSetId; - int *cce_list = nr_mac->cce_list[bwp_id][coreset_id]; + int *cce_list = nr_mac->cce_list[bwp->bwp_Id][coreset_id]; int n_rb=0; for (int i=0;i<6;i++) @@ -410,6 +438,8 @@ void nr_configure_css_dci_initial(nfapi_nr_dl_tti_pdcch_pdu_rel15_t* pdcch_pdu, void nr_fill_nfapi_dl_pdu(int Mod_idP, int UE_id, int bwp_id, + NR_SearchSpace_t *ss, + NR_ControlResourceSet_t *coreset, nfapi_nr_dl_tti_request_body_t *dl_req, NR_sched_pucch *pucch_sched, int nrOfLayers, @@ -424,7 +454,9 @@ void nr_fill_nfapi_dl_pdu(int Mod_idP, uint32_t TBS, int time_domain_assignment, int StartSymbolIndex, - int NrOfSymbols) { + int NrOfSymbols, + uint8_t aggregation_level, + int CCEIndex) { gNB_MAC_INST *nr_mac = RC.nrmac[Mod_idP]; NR_COMMON_channels_t *cc = nr_mac->common_channels; NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon; @@ -561,37 +593,15 @@ void nr_fill_nfapi_dl_pdu(int Mod_idP, dci_pdu_rel15[0].ndi, dci_pdu_rel15[0].rv); - NR_SearchSpace_t *ss; - int target_ss = NR_SearchSpace__searchSpaceType_PR_ue_Specific; - - AssertFatal(bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList!=NULL,"searchPsacesToAddModList is null\n"); - AssertFatal(bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList->list.count>0, - "searchPsacesToAddModList is empty\n"); - - int found=0; - - for (int i=0;ibwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList->list.count;i++) { - ss=bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList->list.array[i]; - AssertFatal(ss->controlResourceSetId != NULL,"ss->controlResourceSetId is null\n"); - AssertFatal(ss->searchSpaceType != NULL,"ss->searchSpaceType is null\n"); - if (ss->searchSpaceType->present == target_ss) { - found=1; - break; - } - } - AssertFatal(found==1,"Couldn't find an adequate searchspace\n"); - - int ret = nr_configure_pdcch(nr_mac, - pdcch_pdu_rel15, - UE_list->rnti[UE_id], - 1, // ue-specific - ss, - scc, - bwp); - if (ret < 0) { - LOG_I(MAC,"CCE list not empty, couldn't schedule PDSCH\n"); - return 0; - } + nr_configure_pdcch(nr_mac, + pdcch_pdu_rel15, + UE_list->rnti[UE_id], + ss, + coreset, + scc, + bwp, + aggregation_level, + CCEIndex); int dci_formats[2]; int rnti_types[2]; @@ -643,44 +653,16 @@ void nr_fill_nfapi_dl_pdu(int Mod_idP, TBS); } -int nr_configure_pdcch(gNB_MAC_INST *nr_mac, - nfapi_nr_dl_tti_pdcch_pdu_rel15_t* pdcch_pdu, - uint16_t rnti, - int ss_type, - NR_SearchSpace_t *ss, - NR_ServingCellConfigCommon_t *scc, - NR_BWP_Downlink_t *bwp){ - - int CCEIndex = -1; - int cid = 0; - NR_ControlResourceSet_t *coreset = NULL; - +void nr_configure_pdcch(gNB_MAC_INST *nr_mac, + nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu, + uint16_t rnti, + NR_SearchSpace_t *ss, + NR_ControlResourceSet_t *coreset, + NR_ServingCellConfigCommon_t *scc, + NR_BWP_Downlink_t *bwp, + uint8_t aggregation_level, + int CCEIndex) { if (bwp) { // This is not the InitialBWP - NR_ControlResourceSet_t *temp_coreset; - NR_ControlResourceSetId_t coresetid = *ss->controlResourceSetId; - if (ss_type == 0) { // common search space - if (coresetid == 0){ - AssertFatal(1==0,"coreset0 currently not supported\n"); - } - else { - coreset = bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonControlResourceSet; - AssertFatal(coresetid==coreset->controlResourceSetId,"ID of common ss coreset does not correspond to id set in the search space\n"); - } - } - else { - int n_list = bwp->bwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList->list.count; - for (int i=0; ibwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList->list.array[i]; - if (coresetid==temp_coreset->controlResourceSetId) { - coreset = temp_coreset; - cid = i; - break; - } - } - if(coreset==NULL) - AssertFatal(1==0,"Couldn't find coreset with id %ld\n",coresetid); - } - pdcch_pdu->BWPSize = NRRIV2BW(bwp->bwp_Common->genericParameters.locationAndBandwidth,275); pdcch_pdu->BWPStart = NRRIV2PRBOFFSET(bwp->bwp_Common->genericParameters.locationAndBandwidth,275); pdcch_pdu->SubcarrierSpacing = bwp->bwp_Common->genericParameters.subcarrierSpacing; @@ -743,22 +725,6 @@ int nr_configure_pdcch(gNB_MAC_INST *nr_mac, pdcch_pdu->dci_pdu.ScramblingRNTI[pdcch_pdu->numDlDci]=0; } - uint8_t nr_of_candidates,aggregation_level; - find_aggregation_candidates(&aggregation_level, - &nr_of_candidates, - ss); - - CCEIndex = allocate_nr_CCEs(nr_mac, - 1, // bwp_id - cid, - aggregation_level, - ss->searchSpaceType->present-1, // search_space, 0 common, 1 ue-specific - 0, // UE-id - 0); // m - - if (CCEIndex<0) - return (CCEIndex); - pdcch_pdu->dci_pdu.AggregationLevel[pdcch_pdu->numDlDci] = aggregation_level; pdcch_pdu->dci_pdu.CceIndex[pdcch_pdu->numDlDci] = CCEIndex; @@ -767,7 +733,6 @@ int nr_configure_pdcch(gNB_MAC_INST *nr_mac, pdcch_pdu->dci_pdu.powerControlOffsetSS[pdcch_pdu->numDlDci]=1; pdcch_pdu->numDlDci++; - return (0); } else { // this is for InitialBWP AssertFatal(1==0,"Fill in InitialBWP PDCCH configuration\n"); diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index c5b1e6ffc1..429a377f4a 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -132,6 +132,8 @@ void nr_schedule_css_dlsch_phytest(module_id_t module_idP, void nr_fill_nfapi_dl_pdu(int Mod_id, int UE_id, int bwp_id, + NR_SearchSpace_t *ss, + NR_ControlResourceSet_t *coreset, nfapi_nr_dl_tti_request_body_t *dl_req, NR_sched_pucch *pucch_sched, int nrOfLayers, @@ -146,7 +148,9 @@ void nr_fill_nfapi_dl_pdu(int Mod_id, uint32_t tbs, int time_domain_assignment, int StartSymbolIndex, - int NrOfSymbols); + int NrOfSymbols, + uint8_t aggregation_level, + int CCEIndex); int configure_fapi_dl_pdu_phytest(int Mod_id, nfapi_nr_dl_tti_request_body_t *dl_req, @@ -233,13 +237,15 @@ void find_search_space(int ss_type, NR_BWP_Downlink_t *bwp, NR_SearchSpace_t *ss); -int nr_configure_pdcch(gNB_MAC_INST *nr_mac, - nfapi_nr_dl_tti_pdcch_pdu_rel15_t* pdcch_pdu, - uint16_t rnti, - int ss_type, - NR_SearchSpace_t *ss, - NR_ServingCellConfigCommon_t *scc, - NR_BWP_Downlink_t *bwp); +void nr_configure_pdcch(gNB_MAC_INST *nr_mac, + nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu, + uint16_t rnti, + NR_SearchSpace_t *ss, + NR_ControlResourceSet_t *coreset, + NR_ServingCellConfigCommon_t *scc, + NR_BWP_Downlink_t *bwp, + uint8_t aggregation_level, + int CCEIndex); void fill_dci_pdu_rel15(NR_ServingCellConfigCommon_t *scc, NR_CellGroupConfig_t *secondaryCellGroup, @@ -255,6 +261,16 @@ void prepare_dci(NR_CellGroupConfig_t *secondaryCellGroup, nr_dci_format_t format, int bwp_id); +/* find coreset within the search space */ +NR_ControlResourceSet_t *get_coreset(NR_BWP_Downlink_t *bwp, + NR_SearchSpace_t *ss, + int ss_type); + +/* find a search space within a BWP */ +NR_SearchSpace_t *get_searchspace( + NR_BWP_Downlink_t *bwp, + NR_SearchSpace__searchSpaceType_PR target_ss); + void find_aggregation_candidates(uint8_t *aggregation_level, uint8_t *nr_of_candidates, NR_SearchSpace_t *ss); @@ -288,13 +304,12 @@ int find_nr_UE_id(module_id_t mod_idP, rnti_t rntiP); int add_new_nr_ue(module_id_t mod_idP, rnti_t rntiP); int allocate_nr_CCEs(gNB_MAC_INST *nr_mac, - int bwp_id, - int coreset_id, + NR_BWP_Downlink_t *bwp, + NR_ControlResourceSet_t *coreset, int aggregation, int search_space, // 0 common, 1 ue-specific int UE_id, - int m - ); + int m); int get_dlscs(nfapi_nr_config_request_t *cfg); From 4ffc4fdad8599eedab3d241b9af47f1546a58848 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 8 Sep 2020 17:51:09 +0200 Subject: [PATCH 57/96] clean up gNB_dlsch_ulsch_scheduler(), remove UE-specific DL bitmap --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c | 60 +++++----------------- openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h | 1 - 2 files changed, 14 insertions(+), 47 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c index 3e9e20659a..4cb4bbab22 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c @@ -388,42 +388,29 @@ void nr_schedule_pucch(int Mod_idP, } } - - -bool is_xlsch_in_slot(uint64_t bitmap, sub_frame_t slot){ - - if((bitmap>>slot)&0x01) - return true; - else - return false; +bool is_xlsch_in_slot(uint64_t bitmap, sub_frame_t slot) { + return (bitmap >> slot) & 0x01; } void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, frame_t frame, sub_frame_t slot){ - - protocol_ctxt_t ctxt; PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, module_idP, ENB_FLAG_YES, NOT_A_RNTI, frame, slot,module_idP); - int CC_id; - int UE_id; - uint64_t *dlsch_in_slot_bitmap=NULL; uint64_t *ulsch_in_slot_bitmap=NULL; - - UE_id=0; - int bwp_id = 1; + const int UE_id = 0; + const int bwp_id = 1; gNB_MAC_INST *gNB = RC.nrmac[module_idP]; NR_UE_list_t *UE_list = &gNB->UE_list; NR_UE_sched_ctrl_t *ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; NR_COMMON_channels_t *cc = gNB->common_channels; NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon; - int num_slots_per_tdd = (slots_per_frame[*scc->ssbSubcarrierSpacing])>>(7-scc->tdd_UL_DL_ConfigurationCommon->pattern1.dl_UL_TransmissionPeriodicity); - int nr_ulmix_slots = scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSlots; - if (scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSymbols!=0) - nr_ulmix_slots++; + NR_TDD_UL_DL_Pattern_t *tdd_pattern = &scc->tdd_UL_DL_ConfigurationCommon->pattern1; + const int num_slots_per_tdd = slots_per_frame[*scc->ssbSubcarrierSpacing] >> (7 - tdd_pattern->dl_UL_TransmissionPeriodicity); + const int nr_ulmix_slots = tdd_pattern->nrofUplinkSlots + (tdd_pattern->nrofUplinkSymbols!=0); if (slot== 0 && (UE_list->fiveG_connected[UE_id] || get_softmodem_params()->phy_test)) { for (int k=0; k> *scc->ssbSubcarrierSpacing); } - dlsch_in_slot_bitmap = &RC.nrmac[module_idP]->UE_list.UE_sched_ctrl[UE_id].dlsch_in_slot_bitmap; // static bitmap signaling which slot in a tdd period contains dlsch ulsch_in_slot_bitmap = &RC.nrmac[module_idP]->UE_list.UE_sched_ctrl[UE_id].ulsch_in_slot_bitmap; // static bitmap signaling which slot in a tdd period contains ulsch - // hardcoding dlsch to be in slot 1 if (!(slot%num_slots_per_tdd)) { if(slot==0) { - *dlsch_in_slot_bitmap = 0x02; *ulsch_in_slot_bitmap = 0x100; } else { - *dlsch_in_slot_bitmap = 0x00; *ulsch_in_slot_bitmap = 0x00; } } + const uint64_t dlsch_in_slot_bitmap = (1 << 1); memset(RC.nrmac[module_idP]->cce_list[bwp_id][0],0,MAX_NUM_CCE*sizeof(int)); // coreset0 memset(RC.nrmac[module_idP]->cce_list[bwp_id][1],0,MAX_NUM_CCE*sizeof(int)); // coresetid 1 - for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { + for (int CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { //mbsfn_status[CC_id] = 0; // clear vrb_maps @@ -474,20 +458,6 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, clear_nr_nfapi_information(RC.nrmac[module_idP], CC_id, frame, slot); } - // refresh UE list based on UEs dropped by PHY in previous subframe - /* - for (i = 0; i < MAX_MOBILES_PER_GNB; i++) { - if (UE_list->active[i]) { - - nfapi_nr_config_request_t *cfg = &RC.nrmac[module_idP]->config[CC_id]; - - rnti = 0;//UE_RNTI(module_idP, i); - CC_id = 0;//UE_PCCID(module_idP, i); - - } //END if (UE_list->active[i]) - } //END for (i = 0; i < MAX_MOBILES_PER_GNB; i++) - */ - if ((slot == 0) && (frame & 127) == 0) dump_mac_stats(RC.nrmac[module_idP]); // This schedules MIB @@ -531,13 +501,17 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, } // This schedules the DCI for Uplink and subsequently PUSCH + // The decision about whether to schedule is done for each UE independently + // inside if (UE_list->fiveG_connected[UE_id]) { int tda = 1; // time domain assignment hardcoded for now schedule_fapi_ul_pdu(module_idP, frame, slot, num_slots_per_tdd, nr_ulmix_slots, tda); nr_schedule_pusch(module_idP, UE_id, num_slots_per_tdd, nr_ulmix_slots, frame, slot); } - if (UE_list->fiveG_connected[UE_id] && (is_xlsch_in_slot(*dlsch_in_slot_bitmap,slot%num_slots_per_tdd))) { + if (UE_list->fiveG_connected[UE_id] + && (is_xlsch_in_slot(dlsch_in_slot_bitmap, slot % num_slots_per_tdd)) + && (!get_softmodem_params()->phy_test || slot == 1)) { ue_sched_ctl->current_harq_pid = slot % num_slots_per_tdd; //int pucch_sched; //nr_update_pucch_scheduling(module_idP, UE_id, frame, slot, num_slots_per_tdd,&pucch_sched); @@ -550,12 +524,6 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, if (UE_list->fiveG_connected[UE_id]) nr_schedule_pucch(module_idP, UE_id, nr_ulmix_slots, frame, slot); - /* - // Allocate CCEs for good after scheduling is done - for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) - allocate_CCEs(module_idP, CC_id, subframeP, 0); - */ - stop_meas(&RC.nrmac[module_idP]->eNB_scheduler); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_gNB_DLSCH_ULSCH_SCHEDULER,VCD_FUNCTION_OUT); diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index bd8f0208c6..6506ee53a3 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -283,7 +283,6 @@ typedef struct NR_UE_ul_harq { /*! \brief scheduling control information set through an API */ typedef struct { - uint64_t dlsch_in_slot_bitmap; // static bitmap signaling which slot in a tdd period contains dlsch uint64_t ulsch_in_slot_bitmap; // static bitmap signaling which slot in a tdd period contains ulsch NR_sched_pucch *sched_pucch; NR_sched_pusch *sched_pusch; From 439095bc84a8cf18dbb5643700dde5b52820a5b1 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 8 Sep 2020 18:07:20 +0200 Subject: [PATCH 58/96] Remove UE-specific ulsch bitmap, special phy test slot when in phy test, only schedule UE to be in slot 8 --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c | 14 ++------ .../LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c | 36 ++++++++++++------- openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 3 +- openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h | 1 - 4 files changed, 27 insertions(+), 27 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c index 4cb4bbab22..7f4e1df4ad 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c @@ -398,7 +398,6 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, protocol_ctxt_t ctxt; PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, module_idP, ENB_FLAG_YES, NOT_A_RNTI, frame, slot,module_idP); - uint64_t *ulsch_in_slot_bitmap=NULL; const int UE_id = 0; const int bwp_id = 1; @@ -434,17 +433,8 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, nr_rlc_tick(frame, slot >> *scc->ssbSubcarrierSpacing); } - ulsch_in_slot_bitmap = &RC.nrmac[module_idP]->UE_list.UE_sched_ctrl[UE_id].ulsch_in_slot_bitmap; // static bitmap signaling which slot in a tdd period contains ulsch - - if (!(slot%num_slots_per_tdd)) { - if(slot==0) { - *ulsch_in_slot_bitmap = 0x100; - } - else { - *ulsch_in_slot_bitmap = 0x00; - } - } const uint64_t dlsch_in_slot_bitmap = (1 << 1); + const uint64_t ulsch_in_slot_bitmap = (1 << 8); memset(RC.nrmac[module_idP]->cce_list[bwp_id][0],0,MAX_NUM_CCE*sizeof(int)); // coreset0 memset(RC.nrmac[module_idP]->cce_list[bwp_id][1],0,MAX_NUM_CCE*sizeof(int)); // coresetid 1 @@ -505,7 +495,7 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, // inside if (UE_list->fiveG_connected[UE_id]) { int tda = 1; // time domain assignment hardcoded for now - schedule_fapi_ul_pdu(module_idP, frame, slot, num_slots_per_tdd, nr_ulmix_slots, tda); + schedule_fapi_ul_pdu(module_idP, frame, slot, num_slots_per_tdd, nr_ulmix_slots, tda, ulsch_in_slot_bitmap); nr_schedule_pusch(module_idP, UE_id, num_slots_per_tdd, nr_ulmix_slots, frame, slot); } diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c index 0f46831a1a..1bc271db21 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c @@ -811,12 +811,26 @@ int8_t select_ul_harq_pid(NR_UE_sched_ctrl_t *sched_ctrl) { return -1; } +long get_K2(NR_BWP_Uplink_t *ubwp, int time_domain_assignment, int mu) { + DevAssert(ubwp); + const NR_PUSCH_TimeDomainResourceAllocation_t *tda_list = ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[time_domain_assignment]; + if (tda_list->k2) + return *tda_list->k2; + else if (mu < 2) + return 1; + else if (mu == 2) + return 2; + else + return 3; +} + void schedule_fapi_ul_pdu(int Mod_idP, frame_t frameP, sub_frame_t slotP, int num_slots_per_tdd, int ul_slots, - int time_domain_assignment) { + int time_domain_assignment, + uint64_t ulsch_in_slot_bitmap) { gNB_MAC_INST *nr_mac = RC.nrmac[Mod_idP]; NR_COMMON_channels_t *cc = nr_mac->common_channels; @@ -840,18 +854,14 @@ void schedule_fapi_ul_pdu(int Mod_idP, AssertFatal(time_domain_assignmentbwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.count, "time_domain_assignment %d>=%d\n",time_domain_assignment,ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.count); - int K2; - if (ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[time_domain_assignment]->k2 != NULL) - K2 = *ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[time_domain_assignment]->k2; - else { - if (mu<2) K2=1; - else if(mu==2) K2=2; - else K2=3; - } - - if (is_xlsch_in_slot(UE_list->UE_sched_ctrl[UE_id].ulsch_in_slot_bitmap,(slotP+K2)%num_slots_per_tdd)) { - - //nfapi_nr_ul_tti_request_t *UL_tti_req = &RC.nrmac[Mod_idP]->UL_tti_req[0]; + int K2 = get_K2(ubwp, time_domain_assignment,mu); + /* check if slot is UL, and for phy test verify that it is in first TDD + * period, slot 8 (for K2=2, this is at slot 6 in the gNB; because of UE + * limitations). Note that if K2 or the TDD configuration is changed, below + * conditions might exclude each other and never be true */ + const int slot_idx = (slotP + K2) % num_slots_per_tdd; + if (is_xlsch_in_slot(ulsch_in_slot_bitmap, slot_idx) + && (!get_softmodem_params()->phy_test || slotP == 6)) { nfapi_nr_ul_dci_request_t *UL_dci_req = &RC.nrmac[Mod_idP]->UL_dci_req[0]; UL_dci_req->SFN = frameP; UL_dci_req->Slot = slotP; diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index 429a377f4a..5ebc2143ea 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -342,7 +342,8 @@ void schedule_fapi_ul_pdu(int Mod_idP, sub_frame_t slotP, int num_slots_per_tdd, int ul_slots, - int time_domain_assignment); + int time_domain_assignment, + uint64_t ulsch_in_slot_bitmap); void nr_process_mac_pdu( module_id_t module_idP, diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index 6506ee53a3..a7d937c7ef 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -283,7 +283,6 @@ typedef struct NR_UE_ul_harq { /*! \brief scheduling control information set through an API */ typedef struct { - uint64_t ulsch_in_slot_bitmap; // static bitmap signaling which slot in a tdd period contains ulsch NR_sched_pucch *sched_pucch; NR_sched_pusch *sched_pusch; uint16_t ta_timer; From 8dd212c0d160a697b7a581baa1cb988370a1535e Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 17 Sep 2020 15:47:49 +0200 Subject: [PATCH 59/96] Only send random data if phytest --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index 9395670759..bc099d2474 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -46,6 +46,9 @@ /*TAG*/ #include "NR_TAG-Id.h" +/*Softmodem params*/ +#include "executables/softmodem-common.h" + //////////////////////////////////////////////////////// /////* DLSCH MAC PDU generation (6.1.2 TS 38.321) *///// //////////////////////////////////////////////////////// @@ -439,6 +442,8 @@ void nr_schedule_ue_spec(module_id_t module_id, lcid, 0, 0); + if (rlc_status.bytes_in_buffer == 0 && !get_softmodem_params()->phy_test) + return; LOG_D(MAC, "%d.%d, DTCH%d->DLSCH, RLC status %d bytes\n", frame, @@ -575,8 +580,8 @@ void nr_schedule_ue_spec(module_id_t module_id, //ue_sched_ctl->uplane_inactivity_timer = 0; } - else { - LOG_I(MAC, "Configuring DL_TX in %d.%d: random data\n", frame, slot); + else if (get_softmodem_params()->phy_test) { + LOG_D(MAC, "Configuring DL_TX in %d.%d: random data\n", frame, slot); // fill dlsch_buffer with random data for (int i = 0; i < TBS; i++) mac_sdus[i] = (unsigned char) (lrand48()&0xff); From b516e26a6619d73bc62b4b60387a855a393cab94 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 17 Sep 2020 16:29:38 +0200 Subject: [PATCH 60/96] Move HARQ calculations out of nr_fill_nfapi_dl_pdu() --- .../LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 14 +++++++++++++- .../NR_MAC_gNB/gNB_scheduler_primitives.c | 18 +++++++----------- openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 5 ++++- 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index bc099d2474..74d937583f 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -621,6 +621,15 @@ void nr_schedule_ue_spec(module_id_t module_id, gNB_mac->UE_list.DLSCH_pdu[0][0].payload[0][offset + j] = 0; } + NR_UE_sched_ctrl_t *sched_ctrl = &UE_list->UE_sched_ctrl[UE_id]; + const int current_harq_pid = sched_ctrl->current_harq_pid; + NR_UE_harq_t *harq = &sched_ctrl->harq_processes[current_harq_pid]; + harq->feedback_slot = pucch->ul_slot; + harq->is_waiting = 1; + UE_list->mac_stats[UE_id].dlsch_rounds[harq->round]++; + if (harq->round == 0) + UE_list->mac_stats[UE_id].dlsch_total_bytes += TBS; + nfapi_nr_dl_tti_request_body_t *dl_req = &gNB_mac->DL_req[CC_id].dl_tti_request_body; nr_fill_nfapi_dl_pdu(module_id, UE_id, @@ -643,7 +652,10 @@ void nr_schedule_ue_spec(module_id_t module_id, startSymbolIndex, nrOfSymbols, aggregation_level, - CCEIndex); + CCEIndex, + current_harq_pid, + harq->ndi, + harq->round); nfapi_nr_pdu_t *tx_req = &gNB_mac->TX_req[CC_id].pdu_list[gNB_mac->TX_req[CC_id].Number_of_PDUs]; configure_fapi_dl_Tx(module_id, diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index 4de05f72ba..8c7c6a8fe8 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -456,7 +456,10 @@ void nr_fill_nfapi_dl_pdu(int Mod_idP, int StartSymbolIndex, int NrOfSymbols, uint8_t aggregation_level, - int CCEIndex) { + int CCEIndex, + int harq_pid, + int ndi, + int round) { gNB_MAC_INST *nr_mac = RC.nrmac[Mod_idP]; NR_COMMON_channels_t *cc = nr_mac->common_channels; NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon; @@ -504,17 +507,15 @@ void nr_fill_nfapi_dl_pdu(int Mod_idP, pdsch_pdu_rel15->CyclicPrefix = 0; pdsch_pdu_rel15->NrOfCodewords = 1; - int current_harq_pid = UE_list->UE_sched_ctrl[UE_id].current_harq_pid; pdsch_pdu_rel15->targetCodeRate[0] = nr_get_code_rate_dl(mcs,0); pdsch_pdu_rel15->qamModOrder[0] = 2; pdsch_pdu_rel15->mcsIndex[0] = mcs; pdsch_pdu_rel15->mcsTable[0] = 0; - pdsch_pdu_rel15->rvIndex[0] = nr_rv_round_map[UE_list->UE_sched_ctrl[UE_id].harq_processes[current_harq_pid].round]; + pdsch_pdu_rel15->rvIndex[0] = nr_rv_round_map[round]; pdsch_pdu_rel15->dataScramblingId = *scc->physCellId; pdsch_pdu_rel15->nrOfLayers = nrOfLayers; pdsch_pdu_rel15->transmissionScheme = 0; pdsch_pdu_rel15->refPoint = 0; // Point A - UE_list->mac_stats[UE_id].dlsch_rounds[UE_list->UE_sched_ctrl[UE_id].harq_processes[current_harq_pid].round]++; pdsch_pdu_rel15->dmrsConfigType = dmrsConfigType; pdsch_pdu_rel15->dlDmrsScramblingId = *scc->physCellId; pdsch_pdu_rel15->SCID = 0; @@ -562,8 +563,8 @@ void nr_fill_nfapi_dl_pdu(int Mod_idP, dci_pdu_rel15[0].mcs = mcs; dci_pdu_rel15[0].rv = pdsch_pdu_rel15->rvIndex[0]; // harq pid and ndi - dci_pdu_rel15[0].harq_pid = current_harq_pid; - dci_pdu_rel15[0].ndi = UE_list->UE_sched_ctrl[UE_id].harq_processes[current_harq_pid].ndi; + dci_pdu_rel15[0].harq_pid = harq_pid; + dci_pdu_rel15[0].ndi = ndi; // DAI dci_pdu_rel15[0].dai[0].val = (pucch_sched->dai_c-1)&3; @@ -573,8 +574,6 @@ void nr_fill_nfapi_dl_pdu(int Mod_idP, dci_pdu_rel15[0].pucch_resource_indicator = pucch_sched->resource_indicator; // PDSCH to HARQ TI dci_pdu_rel15[0].pdsch_to_harq_feedback_timing_indicator.val = pucch_sched->timing_indicator; - UE_list->UE_sched_ctrl[UE_id].harq_processes[current_harq_pid].feedback_slot = pucch_sched->ul_slot; - UE_list->UE_sched_ctrl[UE_id].harq_processes[current_harq_pid].is_waiting = 1; // antenna ports dci_pdu_rel15[0].antenna_ports.val = 0; // nb of cdm groups w/o data 1 and dmrs port 0 // dmrs sequence initialization @@ -637,9 +636,6 @@ void nr_fill_nfapi_dl_pdu(int Mod_idP, // N_PRB_oh); //pdsch_pdu_rel15->nb_mod_symbols = N_RE_prime*pdsch_pdu_rel15->n_prb*pdsch_pdu_rel15->nb_codewords; - if (UE_list->UE_sched_ctrl[UE_id].harq_processes[current_harq_pid].round==0) - UE_list->mac_stats[UE_id].dlsch_total_bytes += TBS; - LOG_D(MAC, "DLSCH PDU: start PRB %d n_PRB %d start symbol %d nb_symbols %d " "nb_layers %d nb_codewords %d mcs %d TBS: %d\n", diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index 5ebc2143ea..6458fb0f79 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -150,7 +150,10 @@ void nr_fill_nfapi_dl_pdu(int Mod_id, int StartSymbolIndex, int NrOfSymbols, uint8_t aggregation_level, - int CCEIndex); + int CCEIndex, + int harq_pid, + int ndi, + int round); int configure_fapi_dl_pdu_phytest(int Mod_id, nfapi_nr_dl_tti_request_body_t *dl_req, From a403ca0398c422f51503faa444a48f4f30d0ec09 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 17 Sep 2020 17:38:28 +0200 Subject: [PATCH 61/96] Reduce log DLSCH scheduler --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index 74d937583f..a53c138000 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -565,7 +565,7 @@ void nr_schedule_ue_spec(module_id_t module_id, 0, 0); - LOG_I(MAC, + LOG_D(MAC, "[gNB %d][USER-PLANE DEFAULT DRB] Got %d bytes for DTCH %d \n", module_id, sdu_lengths[num_sdus], From 77a814fe27a2b09c67f594bb6926fed1e671ddf9 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Fri, 18 Sep 2020 13:30:08 +0200 Subject: [PATCH 62/96] Start PreProc interface, add UE active BWP --- openair2/LAYER2/NR_MAC_gNB/config.c | 7 +++ .../LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 53 ++++++++++++------- openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h | 6 +++ 3 files changed, 46 insertions(+), 20 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/config.c b/openair2/LAYER2/NR_MAC_gNB/config.c index 4e46603dc9..6b8082bd86 100644 --- a/openair2/LAYER2/NR_MAC_gNB/config.c +++ b/openair2/LAYER2/NR_MAC_gNB/config.c @@ -351,6 +351,13 @@ int rrc_mac_config_req_gNB(module_id_t Mod_idP, if (add_ue == 1) { UE_id = add_new_nr_ue(Mod_idP,rnti); UE_list->secondaryCellGroup[UE_id] = secondaryCellGroup; + struct NR_ServingCellConfig__downlinkBWP_ToAddModList *bwpList = + secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList; + AssertFatal(bwpList->list.count == 1, + "downlinkBWP_ToAddModList has %d BWP!\n", + bwpList->list.count); + const int bwp_id = 1; + UE_list->UE_sched_ctrl[UE_id].active_bwp = bwpList->list.array[bwp_id - 1]; uint8_t num_preamble = secondaryCellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink->cfra->resources.choice.ssb->ssb_ResourceList.list.count; UE_list->preambles[UE_id].num_preambles = num_preamble; UE_list->preambles[UE_id].preamble_list = (uint8_t *) malloc(num_preamble*sizeof(uint8_t)); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index a53c138000..199f603c06 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -416,6 +416,22 @@ void handle_nr_uci(NR_UL_IND_t *UL_info, NR_UE_sched_ctrl_t *sched_ctrl, NR_mac_ UL_info->uci_ind.num_ucis = 0; } +void nr_simple_dlsch_preprocessor(module_id_t module_id, + frame_t frame, + sub_frame_t slot, + int num_slots_per_tdd) { + NR_UE_list_t *UE_list = &RC.nrmac[module_id]->UE_list; + + const int UE_id = 0; + const int CC_id = 0; + NR_UE_sched_ctrl_t *sched_ctrl = &UE_list->UE_sched_ctrl[UE_id]; + // TODO: reset per UE-info + + + const int target_ss = NR_SearchSpace__searchSpaceType_PR_ue_Specific; + sched_ctrl->search_space = get_searchspace(sched_ctrl->active_bwp, target_ss); +} + void nr_schedule_ue_spec(module_id_t module_id, frame_t frame, sub_frame_t slot, @@ -452,26 +468,24 @@ void nr_schedule_ue_spec(module_id_t module_id, rlc_status.bytes_in_buffer); /* PREPROCESSOR */ - /* BWP */ - const int bwp_id = 1; - NR_CellGroupConfig_t *secondaryCellGroup = UE_list->secondaryCellGroup[UE_id]; - AssertFatal(secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count == 1, - "downlinkBWP_ToAddModList has %d BWP!\n", - secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count); - NR_BWP_Downlink_t *bwp = secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[bwp_id - 1]; + nr_simple_dlsch_preprocessor(module_id, frame, slot, num_slots_per_tdd); - const int target_ss = NR_SearchSpace__searchSpaceType_PR_ue_Specific; - NR_SearchSpace_t *ss = get_searchspace(bwp, target_ss); + NR_UE_sched_ctrl_t *sched_ctrl = &UE_list->UE_sched_ctrl[UE_id]; + //if (sched_ctrl->rbSize < 0 && !get_softmodem_params()->phy_test) + // return; /* Find a free CCE */ uint8_t nr_of_candidates, aggregation_level; - find_aggregation_candidates(&aggregation_level, &nr_of_candidates, ss); - NR_ControlResourceSet_t *coreset = get_coreset(bwp, ss, 1 /* dedicated */); + find_aggregation_candidates(&aggregation_level, + &nr_of_candidates, + sched_ctrl->search_space); + NR_ControlResourceSet_t *coreset = + get_coreset(sched_ctrl->active_bwp, sched_ctrl->search_space, 1 /* dedicated */); int CCEIndex = allocate_nr_CCEs(gNB_mac, - bwp, + sched_ctrl->active_bwp, coreset, aggregation_level, - ss->searchSpaceType->present - 1, + sched_ctrl->search_space->searchSpaceType->present - 1, UE_id, 0); // m if (CCEIndex < 0) { @@ -483,16 +497,16 @@ void nr_schedule_ue_spec(module_id_t module_id, nr_update_pucch_scheduling(module_id, UE_id, frame, slot, num_slots_per_tdd, &pucch_sched); NR_sched_pucch *pucch = &UE_list->UE_sched_ctrl[UE_id].sched_pucch[pucch_sched]; - const uint16_t bwpSize = NRRIV2BW(bwp->bwp_Common->genericParameters.locationAndBandwidth,275); + const uint16_t bwpSize = NRRIV2BW(sched_ctrl->active_bwp->bwp_Common->genericParameters.locationAndBandwidth,275); const uint8_t mcs = 9; const int nrOfLayers = 1; const uint8_t numDmrsCdmGrpsNoData = 1; - const nfapi_nr_dmrs_type_e dmrsConfigType = bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type == NULL ? 0 : 1; + const nfapi_nr_dmrs_type_e dmrsConfigType = sched_ctrl->active_bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type == NULL ? 0 : 1; const int time_domain_assignment = 2; - AssertFatal(time_domain_assignmentbwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.count,"time_domain_assignment %d>=%d\n",time_domain_assignment,bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.count); - const int startSymbolAndLength = bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[time_domain_assignment]->startSymbolAndLength; + AssertFatal(time_domain_assignmentactive_bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.count,"time_domain_assignment %d>=%d\n",time_domain_assignment,sched_ctrl->active_bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.count); + const int startSymbolAndLength = sched_ctrl->active_bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[time_domain_assignment]->startSymbolAndLength; int startSymbolIndex, nrOfSymbols; SLIV2SL(startSymbolAndLength, &startSymbolIndex, &nrOfSymbols); @@ -621,7 +635,6 @@ void nr_schedule_ue_spec(module_id_t module_id, gNB_mac->UE_list.DLSCH_pdu[0][0].payload[0][offset + j] = 0; } - NR_UE_sched_ctrl_t *sched_ctrl = &UE_list->UE_sched_ctrl[UE_id]; const int current_harq_pid = sched_ctrl->current_harq_pid; NR_UE_harq_t *harq = &sched_ctrl->harq_processes[current_harq_pid]; harq->feedback_slot = pucch->ul_slot; @@ -633,8 +646,8 @@ void nr_schedule_ue_spec(module_id_t module_id, nfapi_nr_dl_tti_request_body_t *dl_req = &gNB_mac->DL_req[CC_id].dl_tti_request_body; nr_fill_nfapi_dl_pdu(module_id, UE_id, - bwp_id, - ss, + sched_ctrl->active_bwp->bwp_Id, + sched_ctrl->search_space, coreset, dl_req, pucch, diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index a7d937c7ef..26c208daff 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -283,8 +283,14 @@ typedef struct NR_UE_ul_harq { /*! \brief scheduling control information set through an API */ typedef struct { + /// the currently active BWP in DL + NR_BWP_Downlink_t *active_bwp; NR_sched_pucch *sched_pucch; NR_sched_pusch *sched_pusch; + + /// CCE index and aggregation, should be coherent with cce_list + NR_SearchSpace_t *search_space; + uint16_t ta_timer; int16_t ta_update; uint8_t tpc0; From 5e5abe420e1b4bbded145e93614e08e32414f808 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Fri, 18 Sep 2020 13:30:33 +0200 Subject: [PATCH 63/96] PreProc IF: RLC status per UE --- .../LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 59 +++++++++++-------- openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h | 5 ++ 2 files changed, 38 insertions(+), 26 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index 199f603c06..f7248b9bfa 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -425,8 +425,32 @@ void nr_simple_dlsch_preprocessor(module_id_t module_id, const int UE_id = 0; const int CC_id = 0; NR_UE_sched_ctrl_t *sched_ctrl = &UE_list->UE_sched_ctrl[UE_id]; + // TODO: reset per UE-info + /* Retrieve amount of data to send for this UE */ + sched_ctrl->num_total_bytes = 0; + const int lcid = DL_SCH_LCID_DTCH; + const uint16_t rnti = UE_list->rnti[UE_id]; + sched_ctrl->rlc_status[lcid] = mac_rlc_status_ind(module_id, + rnti, + module_id, + frame, + slot, + ENB_FLAG_YES, + MBMS_FLAG_NO, + lcid, + 0, + 0); + sched_ctrl->num_total_bytes += sched_ctrl->rlc_status[lcid].bytes_in_buffer; + if (sched_ctrl->num_total_bytes == 0 && !get_softmodem_params()->phy_test) + return; + LOG_D(MAC, + "%d.%d, DTCH%d->DLSCH, RLC status %d bytes\n", + frame, + slot, + lcid, + sched_ctrl->rlc_status[lcid].bytes_in_buffer); const int target_ss = NR_SearchSpace__searchSpaceType_PR_ue_Specific; sched_ctrl->search_space = get_searchspace(sched_ctrl->active_bwp, target_ss); @@ -441,36 +465,17 @@ void nr_schedule_ue_spec(module_id_t module_id, if (UE_list->num_UEs == 0) return; + /* PREPROCESSOR */ + nr_simple_dlsch_preprocessor(module_id, frame, slot, num_slots_per_tdd); + const int ta_len = gNB_mac->ta_len; const int UE_id = 0; const int CC_id = 0; - /* Retrieve amount of data to send for this UE */ - const int lcid = DL_SCH_LCID_DTCH; - const uint16_t rnti = UE_list->rnti[UE_id]; - const mac_rlc_status_resp_t rlc_status = mac_rlc_status_ind(module_id, - rnti, - module_id, - frame, - slot, - ENB_FLAG_YES, - MBMS_FLAG_NO, - lcid, - 0, - 0); - if (rlc_status.bytes_in_buffer == 0 && !get_softmodem_params()->phy_test) - return; - LOG_D(MAC, - "%d.%d, DTCH%d->DLSCH, RLC status %d bytes\n", - frame, - slot, - lcid, - rlc_status.bytes_in_buffer); - - /* PREPROCESSOR */ - nr_simple_dlsch_preprocessor(module_id, frame, slot, num_slots_per_tdd); - NR_UE_sched_ctrl_t *sched_ctrl = &UE_list->UE_sched_ctrl[UE_id]; + if (sched_ctrl->num_total_bytes == 0 && !get_softmodem_params()->phy_test) + return; + //if (sched_ctrl->rbSize < 0 && !get_softmodem_params()->phy_test) // return; @@ -556,7 +561,9 @@ void nr_schedule_ue_spec(module_id_t module_id, uint16_t sdu_lengths[NB_RB_MAX] = {0}; uint8_t mac_sdus[MAX_NR_DLSCH_PAYLOAD_BYTES]; unsigned char sdu_lcids[NB_RB_MAX] = {0}; - if (rlc_status.bytes_in_buffer > 0) { + const rnti_t rnti = UE_list->rnti[UE_id]; + const int lcid = DL_SCH_LCID_DTCH; + if (sched_ctrl->num_total_bytes > 0) { LOG_D(MAC, "[gNB %d][USER-PLANE DEFAULT DRB] Frame %d : DTCH->DLSCH, Requesting " "%d bytes from RLC (lcid %d total hdr len %d), TBS: %d \n \n", diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index 26c208daff..eb2d3405d9 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -283,6 +283,11 @@ typedef struct NR_UE_ul_harq { /*! \brief scheduling control information set through an API */ typedef struct { + /// total amount of data awaiting for this UE + uint32_t num_total_bytes; + /// per-LC status data + mac_rlc_status_resp_t rlc_status[MAX_NUM_LCID]; + /// the currently active BWP in DL NR_BWP_Downlink_t *active_bwp; NR_sched_pucch *sched_pucch; From 020405686cb7de67641502fcc8d29cba4ecd3420 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Fri, 18 Sep 2020 13:33:30 +0200 Subject: [PATCH 64/96] PreProc IF: save CCE info per UE --- .../LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 42 +++++++++---------- openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h | 3 ++ 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index f7248b9bfa..e6dd29db6d 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -452,8 +452,26 @@ void nr_simple_dlsch_preprocessor(module_id_t module_id, lcid, sched_ctrl->rlc_status[lcid].bytes_in_buffer); + /* Find a free CCE */ const int target_ss = NR_SearchSpace__searchSpaceType_PR_ue_Specific; sched_ctrl->search_space = get_searchspace(sched_ctrl->active_bwp, target_ss); + uint8_t nr_of_candidates; + find_aggregation_candidates(&sched_ctrl->aggregation_level, + &nr_of_candidates, + sched_ctrl->search_space); + sched_ctrl->coreset = get_coreset( + sched_ctrl->active_bwp, sched_ctrl->search_space, 1 /* dedicated */); + sched_ctrl->cce_index = allocate_nr_CCEs(RC.nrmac[module_id], + sched_ctrl->active_bwp, + sched_ctrl->coreset, + sched_ctrl->aggregation_level, + sched_ctrl->search_space->searchSpaceType->present - 1, + UE_id, + 0); // m + if (sched_ctrl->cce_index < 0) { + LOG_E(MAC, "%s(): could not find CCE for UE %d\n", __func__, UE_id); + return; + } } void nr_schedule_ue_spec(module_id_t module_id, @@ -479,24 +497,6 @@ void nr_schedule_ue_spec(module_id_t module_id, //if (sched_ctrl->rbSize < 0 && !get_softmodem_params()->phy_test) // return; - /* Find a free CCE */ - uint8_t nr_of_candidates, aggregation_level; - find_aggregation_candidates(&aggregation_level, - &nr_of_candidates, - sched_ctrl->search_space); - NR_ControlResourceSet_t *coreset = - get_coreset(sched_ctrl->active_bwp, sched_ctrl->search_space, 1 /* dedicated */); - int CCEIndex = allocate_nr_CCEs(gNB_mac, - sched_ctrl->active_bwp, - coreset, - aggregation_level, - sched_ctrl->search_space->searchSpaceType->present - 1, - UE_id, - 0); // m - if (CCEIndex < 0) { - LOG_E(MAC, "%s(): could not find CCE for UE %d\n", __func__, UE_id); - return; - } /* Find PUCCH occasion */ int pucch_sched; nr_update_pucch_scheduling(module_id, UE_id, frame, slot, num_slots_per_tdd, &pucch_sched); @@ -655,7 +655,7 @@ void nr_schedule_ue_spec(module_id_t module_id, UE_id, sched_ctrl->active_bwp->bwp_Id, sched_ctrl->search_space, - coreset, + sched_ctrl->coreset, dl_req, pucch, nrOfLayers, @@ -671,8 +671,8 @@ void nr_schedule_ue_spec(module_id_t module_id, time_domain_assignment, startSymbolIndex, nrOfSymbols, - aggregation_level, - CCEIndex, + sched_ctrl->aggregation_level, + sched_ctrl->cce_index, current_harq_pid, harq->ndi, harq->round); diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index eb2d3405d9..80aecdb985 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -295,6 +295,9 @@ typedef struct { /// CCE index and aggregation, should be coherent with cce_list NR_SearchSpace_t *search_space; + NR_ControlResourceSet_t *coreset; + int cce_index; + uint8_t aggregation_level; uint16_t ta_timer; int16_t ta_update; From ad4da1b068ddc76ce6681e4045ad4f117ac2c633 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Fri, 18 Sep 2020 13:53:39 +0200 Subject: [PATCH 65/96] PreProc IF: save PUCCH info per UE --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 12 +++++++----- openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h | 2 ++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index e6dd29db6d..bbd2c18022 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -472,6 +472,12 @@ void nr_simple_dlsch_preprocessor(module_id_t module_id, LOG_E(MAC, "%s(): could not find CCE for UE %d\n", __func__, UE_id); return; } + + /* Find PUCCH occasion */ + nr_update_pucch_scheduling( + module_id, UE_id, frame, slot, num_slots_per_tdd, &sched_ctrl->pucch_sched_idx); + AssertFatal(sched_ctrl->pucch_sched_idx >= 0, "no uplink slot for PUCCH found!\n"); + } void nr_schedule_ue_spec(module_id_t module_id, @@ -497,11 +503,6 @@ void nr_schedule_ue_spec(module_id_t module_id, //if (sched_ctrl->rbSize < 0 && !get_softmodem_params()->phy_test) // return; - /* Find PUCCH occasion */ - int pucch_sched; - nr_update_pucch_scheduling(module_id, UE_id, frame, slot, num_slots_per_tdd, &pucch_sched); - NR_sched_pucch *pucch = &UE_list->UE_sched_ctrl[UE_id].sched_pucch[pucch_sched]; - const uint16_t bwpSize = NRRIV2BW(sched_ctrl->active_bwp->bwp_Common->genericParameters.locationAndBandwidth,275); const uint8_t mcs = 9; @@ -644,6 +645,7 @@ void nr_schedule_ue_spec(module_id_t module_id, const int current_harq_pid = sched_ctrl->current_harq_pid; NR_UE_harq_t *harq = &sched_ctrl->harq_processes[current_harq_pid]; + NR_sched_pucch *pucch = &sched_ctrl->sched_pucch[sched_ctrl->pucch_sched_idx]; harq->feedback_slot = pucch->ul_slot; harq->is_waiting = 1; UE_list->mac_stats[UE_id].dlsch_rounds[harq->round]++; diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index 80aecdb985..9fd3267f8c 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -291,6 +291,8 @@ typedef struct { /// the currently active BWP in DL NR_BWP_Downlink_t *active_bwp; NR_sched_pucch *sched_pucch; + /// selected PUCCH index, if scheduled + int pucch_sched_idx; NR_sched_pusch *sched_pusch; /// CCE index and aggregation, should be coherent with cce_list From 123a4e9adae6b90d6a358f0990510d8cfb31d821 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Fri, 18 Sep 2020 14:50:08 +0200 Subject: [PATCH 66/96] PreProc IF: save Time domain assignment info per UE --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 16 ++++++++++++---- openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h | 3 +++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index bbd2c18022..bf282bc445 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -478,6 +478,8 @@ void nr_simple_dlsch_preprocessor(module_id_t module_id, module_id, UE_id, frame, slot, num_slots_per_tdd, &sched_ctrl->pucch_sched_idx); AssertFatal(sched_ctrl->pucch_sched_idx >= 0, "no uplink slot for PUCCH found!\n"); + // Time-domain allocation + sched_ctrl->time_domain_allocation = 2; } void nr_schedule_ue_spec(module_id_t module_id, @@ -510,9 +512,15 @@ void nr_schedule_ue_spec(module_id_t module_id, const uint8_t numDmrsCdmGrpsNoData = 1; const nfapi_nr_dmrs_type_e dmrsConfigType = sched_ctrl->active_bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type == NULL ? 0 : 1; - const int time_domain_assignment = 2; - AssertFatal(time_domain_assignmentactive_bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.count,"time_domain_assignment %d>=%d\n",time_domain_assignment,sched_ctrl->active_bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.count); - const int startSymbolAndLength = sched_ctrl->active_bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[time_domain_assignment]->startSymbolAndLength; + struct NR_PDSCH_TimeDomainResourceAllocationList *tdaList = + sched_ctrl->active_bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; + AssertFatal(sched_ctrl->time_domain_allocation < tdaList->list.count, + "time_domain_allocation %d>=%d\n", + sched_ctrl->time_domain_allocation, + tdaList->list.count); + + const int startSymbolAndLength = + tdaList->list.array[sched_ctrl->time_domain_allocation]->startSymbolAndLength; int startSymbolIndex, nrOfSymbols; SLIV2SL(startSymbolAndLength, &startSymbolIndex, &nrOfSymbols); @@ -670,7 +678,7 @@ void nr_schedule_ue_spec(module_id_t module_id, R, Qm, TBS, - time_domain_assignment, + sched_ctrl->time_domain_allocation, startSymbolIndex, nrOfSymbols, sched_ctrl->aggregation_level, diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index 9fd3267f8c..0e6479fc73 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -301,6 +301,9 @@ typedef struct { int cce_index; uint8_t aggregation_level; + // time-domain allocation for scheduled RBs + int time_domain_allocation; + uint16_t ta_timer; int16_t ta_update; uint8_t tpc0; From 9ad94aad8281c6fdc5d1e9e49596df9cf0e33a70 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Fri, 18 Sep 2020 14:56:41 +0200 Subject: [PATCH 67/96] PreProc IF: Freq domain allocation per UE --- .../LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 22 +++++++++---------- openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h | 4 ++++ 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index bf282bc445..959b7ab2de 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -427,6 +427,7 @@ void nr_simple_dlsch_preprocessor(module_id_t module_id, NR_UE_sched_ctrl_t *sched_ctrl = &UE_list->UE_sched_ctrl[UE_id]; // TODO: reset per UE-info + sched_ctrl->rbSize = 0; /* Retrieve amount of data to send for this UE */ sched_ctrl->num_total_bytes = 0; @@ -480,6 +481,11 @@ void nr_simple_dlsch_preprocessor(module_id_t module_id, // Time-domain allocation sched_ctrl->time_domain_allocation = 2; + + // Freq-demain allocation + const uint16_t bwpSize = NRRIV2BW(sched_ctrl->active_bwp->bwp_Common->genericParameters.locationAndBandwidth, 275); + sched_ctrl->rbSize = bwpSize; + sched_ctrl->rbStart = 0; } void nr_schedule_ue_spec(module_id_t module_id, @@ -499,14 +505,9 @@ void nr_schedule_ue_spec(module_id_t module_id, const int CC_id = 0; NR_UE_sched_ctrl_t *sched_ctrl = &UE_list->UE_sched_ctrl[UE_id]; - if (sched_ctrl->num_total_bytes == 0 && !get_softmodem_params()->phy_test) + if (sched_ctrl->rbSize < 0 && !get_softmodem_params()->phy_test) return; - //if (sched_ctrl->rbSize < 0 && !get_softmodem_params()->phy_test) - // return; - - const uint16_t bwpSize = NRRIV2BW(sched_ctrl->active_bwp->bwp_Common->genericParameters.locationAndBandwidth,275); - const uint8_t mcs = 9; const int nrOfLayers = 1; const uint8_t numDmrsCdmGrpsNoData = 1; @@ -535,14 +536,13 @@ void nr_schedule_ue_spec(module_id_t module_id, } const uint8_t N_sh_symb = nrOfSymbols; - const uint16_t rbSize = bwpSize; const uint8_t table_idx = 0; const uint16_t R = nr_get_code_rate_dl(mcs, table_idx); const uint8_t Qm = nr_get_Qm_dl(mcs, table_idx); const uint32_t TBS = nr_compute_tbs(Qm, R, - rbSize, + sched_ctrl->rbSize, N_sh_symb, N_PRB_DMRS, // FIXME // This should be multiplied by the // number of dmrs symbols @@ -550,7 +550,7 @@ void nr_schedule_ue_spec(module_id_t module_id, 0 /* tb_scaling */, nrOfLayers) >> 3; - AssertFatal(TBS != 0, "TBS is zero but requested %d RBs!\n", rbSize); + AssertFatal(TBS != 0, "TBS is zero but requested %d RBs!\n", sched_ctrl->rbSize); LOG_D(MAC, "TBS %d bytes: N_PRB_DMRS %d N_sh_symb %d N_PRB_oh %d R %d Qm %d table %d", TBS, @@ -670,8 +670,8 @@ void nr_schedule_ue_spec(module_id_t module_id, pucch, nrOfLayers, mcs, - rbSize, - 0 /* bwpStart */, + sched_ctrl->rbSize, + sched_ctrl->rbStart, numDmrsCdmGrpsNoData, dmrsConfigType, table_idx, diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index 0e6479fc73..b2c9f123b6 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -301,6 +301,10 @@ typedef struct { int cce_index; uint8_t aggregation_level; + /// RB allocation within active BWP + uint16_t rbSize; + uint16_t rbStart; + // time-domain allocation for scheduled RBs int time_domain_allocation; From 476c7177f9a925f4fa0126b94245d5b875fa80f2 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Fri, 18 Sep 2020 17:04:49 +0200 Subject: [PATCH 68/96] PreProc IF: save MCS-info per UE --- .../LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 108 +++++++++++------- openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h | 5 + 2 files changed, 71 insertions(+), 42 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index 959b7ab2de..b180a05a8b 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -416,6 +416,35 @@ void handle_nr_uci(NR_UL_IND_t *UL_info, NR_UE_sched_ctrl_t *sched_ctrl, NR_mac_ UL_info->uci_ind.num_ucis = 0; } +int getNrOfSymbols(NR_BWP_Downlink_t *bwp, int tda) { + struct NR_PDSCH_TimeDomainResourceAllocationList *tdaList = + bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; + AssertFatal(tda < tdaList->list.count, + "time_domain_allocation %d>=%d\n", + tda, + tdaList->list.count); + + const int startSymbolAndLength = tdaList->list.array[tda]->startSymbolAndLength; + int startSymbolIndex, nrOfSymbols; + SLIV2SL(startSymbolAndLength, &startSymbolIndex, &nrOfSymbols); + return nrOfSymbols; +} + +nfapi_nr_dmrs_type_e getDmrsConfigType(NR_BWP_Downlink_t *bwp) { + return bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type == NULL ? 0 : 1; +} + +uint8_t getN_PRB_DMRS(NR_BWP_Downlink_t *bwp, int numDmrsCdmGrpsNoData) { + const nfapi_nr_dmrs_type_e dmrsConfigType = getDmrsConfigType(bwp); + if (dmrsConfigType == NFAPI_NR_DMRS_TYPE1) { + // if no data in dmrs cdm group is 1 only even REs have no data + // if no data in dmrs cdm group is 2 both odd and even REs have no data + return numDmrsCdmGrpsNoData * 6; + } else { + return numDmrsCdmGrpsNoData * 4; + } +} + void nr_simple_dlsch_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t slot, @@ -486,6 +515,28 @@ void nr_simple_dlsch_preprocessor(module_id_t module_id, const uint16_t bwpSize = NRRIV2BW(sched_ctrl->active_bwp->bwp_Common->genericParameters.locationAndBandwidth, 275); sched_ctrl->rbSize = bwpSize; sched_ctrl->rbStart = 0; + + // modulation scheme + sched_ctrl->mcsTableIdx = 0; + sched_ctrl->mcs = 9; + sched_ctrl->numDmrsCdmGrpsNoData = 1; + + uint8_t N_PRB_DMRS = + getN_PRB_DMRS(sched_ctrl->active_bwp, sched_ctrl->numDmrsCdmGrpsNoData); + int nrOfSymbols = getNrOfSymbols(sched_ctrl->active_bwp, + sched_ctrl->time_domain_allocation); + const uint32_t TBS = + nr_compute_tbs(nr_get_Qm_dl(sched_ctrl->mcs, sched_ctrl->mcsTableIdx), + nr_get_code_rate_dl(sched_ctrl->mcs, sched_ctrl->mcsTableIdx), + sched_ctrl->rbSize, + nrOfSymbols, + N_PRB_DMRS, // FIXME // This should be multiplied by the + // number of dmrs symbols + 0 /* N_PRB_oh, 0 for initialBWP */, + 0 /* tb_scaling */, + 1 /* nrOfLayers */) + >> 3; + AssertFatal(TBS != 0, "TBS is zero but requested %d RBs!\n", sched_ctrl->rbSize); } void nr_schedule_ue_spec(module_id_t module_id, @@ -508,11 +559,7 @@ void nr_schedule_ue_spec(module_id_t module_id, if (sched_ctrl->rbSize < 0 && !get_softmodem_params()->phy_test) return; - const uint8_t mcs = 9; - const int nrOfLayers = 1; - const uint8_t numDmrsCdmGrpsNoData = 1; - const nfapi_nr_dmrs_type_e dmrsConfigType = sched_ctrl->active_bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type == NULL ? 0 : 1; - + /* POST processing */ struct NR_PDSCH_TimeDomainResourceAllocationList *tdaList = sched_ctrl->active_bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; AssertFatal(sched_ctrl->time_domain_allocation < tdaList->list.count, @@ -525,43 +572,20 @@ void nr_schedule_ue_spec(module_id_t module_id, int startSymbolIndex, nrOfSymbols; SLIV2SL(startSymbolAndLength, &startSymbolIndex, &nrOfSymbols); - const uint16_t N_PRB_oh = 0; // overhead should be 0 for initialBWP - uint8_t N_PRB_DMRS; - if (dmrsConfigType == NFAPI_NR_DMRS_TYPE1) { - // if no data in dmrs cdm group is 1 only even REs have no data - // if no data in dmrs cdm group is 2 both odd and even REs have no data - N_PRB_DMRS = numDmrsCdmGrpsNoData * 6; - } else { - N_PRB_DMRS = numDmrsCdmGrpsNoData * 4; - } - const uint8_t N_sh_symb = nrOfSymbols; - - const uint8_t table_idx = 0; - const uint16_t R = nr_get_code_rate_dl(mcs, table_idx); - const uint8_t Qm = nr_get_Qm_dl(mcs, table_idx); + uint8_t N_PRB_DMRS = + getN_PRB_DMRS(sched_ctrl->active_bwp, sched_ctrl->numDmrsCdmGrpsNoData); const uint32_t TBS = - nr_compute_tbs(Qm, - R, + nr_compute_tbs(nr_get_Qm_dl(sched_ctrl->mcs, sched_ctrl->mcsTableIdx), + nr_get_code_rate_dl(sched_ctrl->mcs, sched_ctrl->mcsTableIdx), sched_ctrl->rbSize, - N_sh_symb, + nrOfSymbols, N_PRB_DMRS, // FIXME // This should be multiplied by the // number of dmrs symbols - N_PRB_oh, + 0 /* N_PRB_oh, 0 for initialBWP */, 0 /* tb_scaling */, - nrOfLayers) + 1 /* nrOfLayers */) >> 3; - AssertFatal(TBS != 0, "TBS is zero but requested %d RBs!\n", sched_ctrl->rbSize); - LOG_D(MAC, - "TBS %d bytes: N_PRB_DMRS %d N_sh_symb %d N_PRB_oh %d R %d Qm %d table %d", - TBS, - N_PRB_DMRS, - N_sh_symb, - N_PRB_oh, - R, - Qm, - table_idx); - /* POST processing */ /* Get RLC data TODO: remove random data retrieval */ int header_length_total = 0; int header_length_last = 0; @@ -668,15 +692,15 @@ void nr_schedule_ue_spec(module_id_t module_id, sched_ctrl->coreset, dl_req, pucch, - nrOfLayers, - mcs, + 1 /* nrOfLayers */, + sched_ctrl->mcs, sched_ctrl->rbSize, sched_ctrl->rbStart, - numDmrsCdmGrpsNoData, - dmrsConfigType, - table_idx, - R, - Qm, + sched_ctrl->numDmrsCdmGrpsNoData, + getDmrsConfigType(sched_ctrl->active_bwp), + sched_ctrl->mcsTableIdx, + nr_get_code_rate_dl(sched_ctrl->mcs, sched_ctrl->mcsTableIdx), + nr_get_Qm_dl(sched_ctrl->mcs, sched_ctrl->mcsTableIdx), TBS, sched_ctrl->time_domain_allocation, startSymbolIndex, diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index b2c9f123b6..bf09dfcc12 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -308,6 +308,11 @@ typedef struct { // time-domain allocation for scheduled RBs int time_domain_allocation; + /// MCS-related infos + uint8_t mcsTableIdx; + uint8_t mcs; + uint8_t numDmrsCdmGrpsNoData; + uint16_t ta_timer; int16_t ta_update; uint8_t tpc0; From adcd2949fe369645206ea45a63d7c6cc86da24c4 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 21 Sep 2020 11:09:46 +0200 Subject: [PATCH 69/96] Rename NR_UE_list_t to NR_UE_info_t The name NR_UE_list_t is misleading: beyond being a simple "list", this structure carries all/most UE-related MAC information. If at all, it is a container for multiple lists. The next commit introduces a NR_UE_list_t structure that organizes UEs in lists such that it is easier to go through the UEs. --- openair1/SIMULATION/NR_PHY/dlsim.c | 8 +- openair2/LAYER2/NR_MAC_gNB/config.c | 14 +-- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c | 86 +++++++++---------- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c | 22 ++--- .../LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 33 ++++--- .../LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c | 66 +++++++------- .../NR_MAC_gNB/gNB_scheduler_primitives.c | 75 ++++++++-------- .../LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c | 16 ++-- openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 2 +- openair2/LAYER2/NR_MAC_gNB/main.c | 36 ++++---- openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h | 4 +- openair2/NR_PHY_INTERFACE/NR_IF_Module.c | 4 +- 12 files changed, 181 insertions(+), 185 deletions(-) diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index 38400cab51..a2da10797e 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -698,7 +698,7 @@ int main(int argc, char **argv) nr_ue_phy_config_request(&UE_mac->phy_config); - NR_UE_list_t *UE_list = &RC.nrmac[0]->UE_list; + NR_UE_info_t *UE_info = &RC.nrmac[0]->UE_info; //NR_COMMON_channels_t *cc = RC.nrmac[0]->common_channels; snrRun = 0; @@ -759,11 +759,11 @@ int main(int argc, char **argv) memset(RC.nrmac[0]->cce_list[1][1],0,MAX_NUM_CCE*sizeof(int)); clear_nr_nfapi_information(RC.nrmac[0], 0, frame, slot); - UE_list->UE_sched_ctrl[0].harq_processes[harq_pid].ndi = !(trial&1); + UE_info->UE_sched_ctrl[0].harq_processes[harq_pid].ndi = !(trial&1); - UE_list->UE_sched_ctrl[0].harq_processes[harq_pid].round = round; - UE_list->UE_sched_ctrl[0].current_harq_pid = harq_pid; + UE_info->UE_sched_ctrl[0].harq_processes[harq_pid].round = round; + UE_info->UE_sched_ctrl[0].current_harq_pid = harq_pid; gNB->dlsch[0][0]->harq_processes[harq_pid]->round = round; if (css_flag == 0) nr_schedule_uss_dlsch_phytest(0,frame,slot,&pucch_sched,&dlsch_config); diff --git a/openair2/LAYER2/NR_MAC_gNB/config.c b/openair2/LAYER2/NR_MAC_gNB/config.c index 6b8082bd86..4f897322a3 100644 --- a/openair2/LAYER2/NR_MAC_gNB/config.c +++ b/openair2/LAYER2/NR_MAC_gNB/config.c @@ -346,29 +346,29 @@ int rrc_mac_config_req_gNB(module_id_t Mod_idP, if (secondaryCellGroup) { - NR_UE_list_t *UE_list = &RC.nrmac[Mod_idP]->UE_list; + NR_UE_info_t *UE_info = &RC.nrmac[Mod_idP]->UE_info; int UE_id; if (add_ue == 1) { UE_id = add_new_nr_ue(Mod_idP,rnti); - UE_list->secondaryCellGroup[UE_id] = secondaryCellGroup; + UE_info->secondaryCellGroup[UE_id] = secondaryCellGroup; struct NR_ServingCellConfig__downlinkBWP_ToAddModList *bwpList = secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList; AssertFatal(bwpList->list.count == 1, "downlinkBWP_ToAddModList has %d BWP!\n", bwpList->list.count); const int bwp_id = 1; - UE_list->UE_sched_ctrl[UE_id].active_bwp = bwpList->list.array[bwp_id - 1]; + UE_info->UE_sched_ctrl[UE_id].active_bwp = bwpList->list.array[bwp_id - 1]; uint8_t num_preamble = secondaryCellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink->cfra->resources.choice.ssb->ssb_ResourceList.list.count; - UE_list->preambles[UE_id].num_preambles = num_preamble; - UE_list->preambles[UE_id].preamble_list = (uint8_t *) malloc(num_preamble*sizeof(uint8_t)); + UE_info->preambles[UE_id].num_preambles = num_preamble; + UE_info->preambles[UE_id].preamble_list = (uint8_t *) malloc(num_preamble*sizeof(uint8_t)); for (int i=0; ipreambles[UE_id].preamble_list[i] = secondaryCellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink->cfra->resources.choice.ssb->ssb_ResourceList.list.array[i]->ra_PreambleIndex; + UE_info->preambles[UE_id].preamble_list[i] = secondaryCellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink->cfra->resources.choice.ssb->ssb_ResourceList.list.array[i]->ra_PreambleIndex; } LOG_I(PHY,"Added new UE_id %d/%x with initial secondaryCellGroup\n",UE_id,rnti); } else { // secondaryCellGroup has been updated UE_id = find_nr_UE_id(Mod_idP,rnti); - UE_list->secondaryCellGroup[UE_id] = secondaryCellGroup; + UE_info->secondaryCellGroup[UE_id] = secondaryCellGroup; LOG_I(PHY,"Modified UE_id %d/%x with secondaryCellGroup\n",UE_id,rnti); } } diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c index 7f4e1df4ad..eab8cb2e0b 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c @@ -63,19 +63,19 @@ const uint8_t slots_per_frame[5] = {10, 20, 40, 80, 160}; uint16_t nr_pdcch_order_table[6] = { 31, 31, 511, 2047, 2047, 8191 }; void clear_mac_stats(gNB_MAC_INST *gNB) { - memset((void*)gNB->UE_list.mac_stats,0,MAX_MOBILES_PER_GNB*sizeof(NR_mac_stats_t)); + memset((void*)gNB->UE_info.mac_stats,0,MAX_MOBILES_PER_GNB*sizeof(NR_mac_stats_t)); } void dump_mac_stats(gNB_MAC_INST *gNB) { - NR_UE_list_t *UE_list = &gNB->UE_list; + NR_UE_info_t *UE_info = &gNB->UE_info; NR_mac_stats_t *stats; int lc_id; for (int UE_id=0;UE_idactive[UE_id] == TRUE) { - LOG_I(MAC,"UE %x\n",UE_list->rnti[UE_id]); - stats = &UE_list->mac_stats[UE_id]; + if (UE_info->active[UE_id]) { + LOG_I(MAC, "UE %x\n", UE_info->rnti[UE_id]); + stats = &UE_info->mac_stats[UE_id]; LOG_I(MAC,"dlsch_rounds %d/%d/%d/%d, dlsch_errors %d\n",stats->dlsch_rounds[0],stats->dlsch_rounds[1],stats->dlsch_rounds[2],stats->dlsch_rounds[3],stats->dlsch_errors); LOG_I(MAC,"dlsch_total_bytes %d\n",stats->dlsch_total_bytes); LOG_I(MAC,"ulsch_rounds %d/%d/%d/%d, ulsch_errors %d\n",stats->ulsch_rounds[0],stats->ulsch_rounds[1],stats->ulsch_rounds[2],stats->ulsch_rounds[3],stats->ulsch_errors); @@ -130,18 +130,18 @@ void check_nr_ul_failure(module_id_t module_idP, frame_t frameP, sub_frame_t slotP) { - UE_list_t *UE_list = &RC.nrmac[module_idP]->UE_list; + NR_UE_info_t *UE_info = &RC.nrmac[module_idP]->UE_info; nfapi_nr_dl_dci_request_t *DL_req = &RC.nrmac[module_idP]->DL_req[0]; uint16_t rnti = UE_RNTI(module_idP, UE_id); NR_COMMON_channels_t *cc = RC.nrmac[module_idP]->common_channels; // check uplink failure - if ((UE_list->UE_sched_ctrl[UE_id].ul_failure_timer > 0) && - (UE_list->UE_sched_ctrl[UE_id].ul_out_of_sync == 0)) { + if ((UE_info->UE_sched_ctrl[UE_id].ul_failure_timer > 0) && + (UE_info->UE_sched_ctrl[UE_id].ul_out_of_sync == 0)) { LOG_I(MAC, "UE %d rnti %x: UL Failure timer %d \n", UE_id, rnti, - UE_list->UE_sched_ctrl[UE_id].ul_failure_timer); - if (UE_list->UE_sched_ctrl[UE_id].ra_pdcch_order_sent == 0) { - UE_list->UE_sched_ctrl[UE_id].ra_pdcch_order_sent = 1; + UE_info->UE_sched_ctrl[UE_id].ul_failure_timer); + if (UE_info->UE_sched_ctrl[UE_id].ra_pdcch_order_sent == 0) { + UE_info->UE_sched_ctrl[UE_id].ra_pdcch_order_sent = 1; // add a format 1A dci for this UE to request an RA procedure (only one UE per subframe) nfapi_nr_dl_dci_request_pdu_t *dl_config_pdu = &DL_req[CC_id].dl_tti_request_body.dl_config_pdu_list[DL_req[CC_id].dl_tti_request_body.number_pdu]; @@ -151,7 +151,7 @@ void check_nr_ul_failure(module_id_t module_idP, dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.tl.tag = NFAPI_DL_DCI_REQUEST_DCI_DL_PDU_REL8_TAG; dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.dci_format = NFAPI_DL_DCI_FORMAT_1A; dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level = get_aggregation(get_bw_index(module_idP, CC_id), - UE_list->UE_sched_ctrl[UE_id]. + UE_info->UE_sched_ctrl[UE_id]. dl_cqi[CC_id], format1A); dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti = rnti; dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti_type = 1; // CRNTI : see Table 4-10 from SCF082 - nFAPI specifications @@ -167,27 +167,27 @@ void check_nr_ul_failure(module_id_t module_idP, LOG_I(MAC, "UE %d rnti %x: sending PDCCH order for RAPROC (failure timer %d), resource_block_coding %d \n", UE_id, rnti, - UE_list->UE_sched_ctrl[UE_id].ul_failure_timer, + UE_info->UE_sched_ctrl[UE_id].ul_failure_timer, dl_config_pdu->dci_dl_pdu. dci_dl_pdu_rel8.resource_block_coding); } else { // ra_pdcch_sent==1 LOG_I(MAC, "UE %d rnti %x: sent PDCCH order for RAPROC waiting (failure timer %d) \n", UE_id, rnti, - UE_list->UE_sched_ctrl[UE_id].ul_failure_timer); - if ((UE_list->UE_sched_ctrl[UE_id].ul_failure_timer % 40) == 0) UE_list->UE_sched_ctrl[UE_id].ra_pdcch_order_sent = 0; // resend every 4 frames + UE_info->UE_sched_ctrl[UE_id].ul_failure_timer); + if ((UE_info->UE_sched_ctrl[UE_id].ul_failure_timer % 40) == 0) UE_info->UE_sched_ctrl[UE_id].ra_pdcch_order_sent = 0; // resend every 4 frames } - UE_list->UE_sched_ctrl[UE_id].ul_failure_timer++; + UE_info->UE_sched_ctrl[UE_id].ul_failure_timer++; // check threshold - if (UE_list->UE_sched_ctrl[UE_id].ul_failure_timer > 20000) { + if (UE_info->UE_sched_ctrl[UE_id].ul_failure_timer > 20000) { // inform RRC of failure and clear timer LOG_I(MAC, "UE %d rnti %x: UL Failure after repeated PDCCH orders: Triggering RRC \n", UE_id, rnti); mac_eNB_rrc_ul_failure(module_idP, CC_id, frameP, subframeP,rnti); - UE_list->UE_sched_ctrl[UE_id].ul_failure_timer = 0; - UE_list->UE_sched_ctrl[UE_id].ul_out_of_sync = 1; + UE_info->UE_sched_ctrl[UE_id].ul_failure_timer = 0; + UE_info->UE_sched_ctrl[UE_id].ul_out_of_sync = 1; //Inform the controller about the UE deactivation. Should be moved to RRC agent in the future if (rrc_agent_registered[module_idP]) { @@ -204,7 +204,7 @@ void check_nr_ul_failure(module_id_t module_idP, void schedule_nr_SRS(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP) { gNB_MAC_INST *gNB = RC.nrmac[module_idP]; - UE_list_t *UE_list = &gNB->UE_list; + NR_UE_info_t *UE_info = &gNB->UE_info; nfapi_ul_config_request_body_t *ul_req; int CC_id, UE_id; NR_COMMON_channels_t *cc = RC.nrmac[module_idP]->common_channels; @@ -238,16 +238,16 @@ void schedule_nr_SRS(module_id_t module_idP, frame_t frameP, sub_frame_t subfram if ((1 << tmp) & deltaTSFC) { // This is an SRS subframe, loop over UEs for (UE_id = 0; UE_id < MAX_MOBILES_PER_GNB; UE_id++) { - if (!RC.nrmac[module_idP]->UE_list.active[UE_id]) continue; + if (!RC.nrmac[module_idP]->UE_info.active[UE_id]) continue; ul_req = &RC.nrmac[module_idP]->UL_req[CC_id].ul_config_request_body; // drop the allocation if the UE hasn't send RRCConnectionSetupComplete yet if (mac_eNB_get_rrc_status(module_idP,UE_RNTI(module_idP, UE_id)) < RRC_CONNECTED) continue; - AssertFatal(UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated != NULL, + AssertFatal(UE_info->UE_template[CC_id][UE_id].physicalConfigDedicated != NULL, "physicalConfigDedicated is null for UE %d\n", UE_id); - if ((soundingRS_UL_ConfigDedicated = UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated->soundingRS_UL_ConfigDedicated) != NULL) { + if ((soundingRS_UL_ConfigDedicated = UE_info->UE_template[CC_id][UE_id].physicalConfigDedicated->soundingRS_UL_ConfigDedicated) != NULL) { if (soundingRS_UL_ConfigDedicated->present == SoundingRS_UL_ConfigDedicated_PR_setup) { get_srs_pos(&cc[CC_id], soundingRS_UL_ConfigDedicated->choice. @@ -262,7 +262,7 @@ void schedule_nr_SRS(module_id_t module_idP, frame_t frameP, sub_frame_t subfram ul_config_pdu->pdu_size = 2 + (uint8_t) (2 + sizeof(nfapi_ul_config_srs_pdu)); ul_config_pdu->srs_pdu.srs_pdu_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_SRS_PDU_REL8_TAG; ul_config_pdu->srs_pdu.srs_pdu_rel8.size = (uint8_t)sizeof(nfapi_ul_config_srs_pdu); - ul_config_pdu->srs_pdu.srs_pdu_rel8.rnti = UE_list->UE_template[CC_id][UE_id].rnti; + ul_config_pdu->srs_pdu.srs_pdu_rel8.rnti = UE_info->UE_template[CC_id][UE_id].rnti; ul_config_pdu->srs_pdu.srs_pdu_rel8.srs_bandwidth = soundingRS_UL_ConfigDedicated->choice.setup.srs_Bandwidth; ul_config_pdu->srs_pdu.srs_pdu_rel8.frequency_domain_position = soundingRS_UL_ConfigDedicated->choice.setup.freqDomainPosition; ul_config_pdu->srs_pdu.srs_pdu_rel8.srs_hopping_bandwidth = soundingRS_UL_ConfigDedicated->choice.setup.srs_HoppingBandwidth;; @@ -275,7 +275,7 @@ void schedule_nr_SRS(module_id_t module_idP, frame_t frameP, sub_frame_t subfram ul_req->number_of_pdus++; } // if (((10*frameP+subframeP) % srsPeriodicity) == srsOffset) } // if (soundingRS_UL_ConfigDedicated->present == SoundingRS_UL_ConfigDedicated_PR_setup) - } // if ((soundingRS_UL_ConfigDedicated = UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated->soundingRS_UL_ConfigDedicated)!=NULL) + } // if ((soundingRS_UL_ConfigDedicated = UE_info->UE_template[CC_id][UE_id].physicalConfigDedicated->soundingRS_UL_ConfigDedicated)!=NULL) } // for (UE_id ... } // if((1<UL_tti_req[0]; - NR_UE_list_t *UE_list = &RC.nrmac[Mod_idP]->UE_list; + NR_UE_info_t *UE_info = &RC.nrmac[Mod_idP]->UE_info; int k = slotP + ul_slots - num_slots_per_tdd; - NR_sched_pusch *pusch = &UE_list->UE_sched_ctrl[UE_id].sched_pusch[k]; + NR_sched_pusch *pusch = &UE_info->UE_sched_ctrl[UE_id].sched_pusch[k]; if ((pusch->active == true) && (frameP == pusch->frame) && (slotP == pusch->slot)) { UL_tti_req->SFN = pusch->frame; UL_tti_req->Slot = pusch->slot; @@ -332,7 +332,7 @@ void nr_schedule_pusch(int Mod_idP, UL_tti_req->pdus_list[UL_tti_req->n_pdus].pdu_size = sizeof(nfapi_nr_pusch_pdu_t); UL_tti_req->pdus_list[UL_tti_req->n_pdus].pusch_pdu = pusch->pusch_pdu; UL_tti_req->n_pdus+=1; - memset((void *) &UE_list->UE_sched_ctrl[UE_id].sched_pusch[k], + memset((void *) &UE_info->UE_sched_ctrl[UE_id].sched_pusch[k], 0, sizeof(NR_sched_pusch)); } } @@ -348,10 +348,10 @@ void nr_schedule_pucch(int Mod_idP, uint16_t O_ack; uint8_t SR_flag = 0; // no SR in PUCCH implemented for now NR_ServingCellConfigCommon_t *scc = RC.nrmac[Mod_idP]->common_channels->ServingCellConfigCommon; - NR_UE_list_t *UE_list = &RC.nrmac[Mod_idP]->UE_list; - AssertFatal(UE_list->active[UE_id] >=0,"Cannot find UE_id %d is not active\n",UE_id); + NR_UE_info_t *UE_info = &RC.nrmac[Mod_idP]->UE_info; + AssertFatal(UE_info->active[UE_id] >=0,"Cannot find UE_id %d is not active\n",UE_id); - NR_CellGroupConfig_t *secondaryCellGroup = UE_list->secondaryCellGroup[UE_id]; + NR_CellGroupConfig_t *secondaryCellGroup = UE_info->secondaryCellGroup[UE_id]; int bwp_id=1; NR_BWP_Uplink_t *ubwp=secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[bwp_id-1]; nfapi_nr_ul_tti_request_t *UL_tti_req = &RC.nrmac[Mod_idP]->UL_tti_req[0]; @@ -359,7 +359,7 @@ void nr_schedule_pucch(int Mod_idP, NR_sched_pucch *curr_pucch; for (int k=0; kUE_sched_ctrl[UE_id].sched_pucch[k]; + curr_pucch = &UE_info->UE_sched_ctrl[UE_id].sched_pucch[k]; if ((curr_pucch->dai_c > 0) && (frameP == curr_pucch->frame) && (slotP == curr_pucch->ul_slot)) { UL_tti_req->SFN = curr_pucch->frame; UL_tti_req->Slot = curr_pucch->ul_slot; @@ -381,7 +381,7 @@ void nr_schedule_pucch(int Mod_idP, O_ack, SR_flag); - memset((void *) &UE_list->UE_sched_ctrl[UE_id].sched_pucch[k], + memset((void *) &UE_info->UE_sched_ctrl[UE_id].sched_pucch[k], 0, sizeof(NR_sched_pucch)); } @@ -402,8 +402,8 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, const int bwp_id = 1; gNB_MAC_INST *gNB = RC.nrmac[module_idP]; - NR_UE_list_t *UE_list = &gNB->UE_list; - NR_UE_sched_ctrl_t *ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; + NR_UE_info_t *UE_info = &gNB->UE_info; + NR_UE_sched_ctrl_t *ue_sched_ctl = &UE_info->UE_sched_ctrl[UE_id]; NR_COMMON_channels_t *cc = gNB->common_channels; NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon; @@ -411,12 +411,12 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, const int num_slots_per_tdd = slots_per_frame[*scc->ssbSubcarrierSpacing] >> (7 - tdd_pattern->dl_UL_TransmissionPeriodicity); const int nr_ulmix_slots = tdd_pattern->nrofUplinkSlots + (tdd_pattern->nrofUplinkSymbols!=0); - if (slot== 0 && (UE_list->fiveG_connected[UE_id] || get_softmodem_params()->phy_test)) { + if (slot== 0 && (UE_info->fiveG_connected[UE_id] || get_softmodem_params()->phy_test)) { for (int k=0; kUE_sched_ctrl[UE_id].sched_pucch[k], + memset((void *) &UE_info->UE_sched_ctrl[UE_id].sched_pucch[k], 0, sizeof(NR_sched_pucch)); - memset((void *) &UE_list->UE_sched_ctrl[UE_id].sched_pusch[k], + memset((void *) &UE_info->UE_sched_ctrl[UE_id].sched_pusch[k], 0, sizeof(NR_sched_pusch)); } @@ -471,7 +471,7 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, nr_schedule_RA(module_idP, frame, slot); nr_schedule_reception_msg3(module_idP, 0, frame, slot); } else - UE_list->fiveG_connected[UE_id] = true; + UE_info->fiveG_connected[UE_id] = true; if (get_softmodem_params()->phy_test) { @@ -493,25 +493,25 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, // This schedules the DCI for Uplink and subsequently PUSCH // The decision about whether to schedule is done for each UE independently // inside - if (UE_list->fiveG_connected[UE_id]) { + if (UE_info->fiveG_connected[UE_id]) { int tda = 1; // time domain assignment hardcoded for now schedule_fapi_ul_pdu(module_idP, frame, slot, num_slots_per_tdd, nr_ulmix_slots, tda, ulsch_in_slot_bitmap); nr_schedule_pusch(module_idP, UE_id, num_slots_per_tdd, nr_ulmix_slots, frame, slot); } - if (UE_list->fiveG_connected[UE_id] + if (UE_info->fiveG_connected[UE_id] && (is_xlsch_in_slot(dlsch_in_slot_bitmap, slot % num_slots_per_tdd)) && (!get_softmodem_params()->phy_test || slot == 1)) { ue_sched_ctl->current_harq_pid = slot % num_slots_per_tdd; //int pucch_sched; //nr_update_pucch_scheduling(module_idP, UE_id, frame, slot, num_slots_per_tdd,&pucch_sched); - //nr_schedule_uss_dlsch_phytest(module_idP, frame, slot, &UE_list->UE_sched_ctrl[UE_id].sched_pucch[pucch_sched], NULL); + //nr_schedule_uss_dlsch_phytest(module_idP, frame, slot, &UE_info->UE_sched_ctrl[UE_id].sched_pucch[pucch_sched], NULL); nr_schedule_ue_spec(module_idP, frame, slot, num_slots_per_tdd); // resetting ta flag gNB->ta_len = 0; } - if (UE_list->fiveG_connected[UE_id]) + if (UE_info->fiveG_connected[UE_id]) nr_schedule_pucch(module_idP, UE_id, nr_ulmix_slots, frame, slot); stop_meas(&RC.nrmac[module_idP]->eNB_scheduler); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c index 7ada7fd537..8a32714c8a 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c @@ -253,8 +253,8 @@ void nr_initiate_ra_proc(module_id_t module_idP, uint16_t msg2_frame, msg2_slot,monitoring_slot_period,monitoring_offset; gNB_MAC_INST *nr_mac = RC.nrmac[module_idP]; - NR_UE_list_t *UE_list = &nr_mac->UE_list; - NR_CellGroupConfig_t *secondaryCellGroup = UE_list->secondaryCellGroup[UE_id]; + NR_UE_info_t *UE_info = &nr_mac->UE_info; + NR_CellGroupConfig_t *secondaryCellGroup = UE_info->secondaryCellGroup[UE_id]; NR_COMMON_channels_t *cc = &nr_mac->common_channels[CC_id]; NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon; NR_RA_t *ra = &cc->ra[0]; @@ -262,14 +262,14 @@ void nr_initiate_ra_proc(module_id_t module_idP, // if the preamble received correspond to one of the listed // the UE sent a RACH either for starting RA procedure or RA procedure failed and UE retries int pr_found=0; - for (int i=0;ipreambles[UE_id].num_preambles;i++) { - if (preamble_index == UE_list->preambles[UE_id].preamble_list[i]) { + for (int i=0;ipreambles[UE_id].num_preambles;i++) { + if (preamble_index == UE_info->preambles[UE_id].preamble_list[i]) { pr_found=1; break; } } if (pr_found) - UE_list->fiveG_connected[UE_id] = false; + UE_info->fiveG_connected[UE_id] = false; else { LOG_E(MAC, "[gNB %d][RAPROC] FAILURE: preamble %d does not correspond to any of the ones in rach_ConfigDedicated for UE_id %d\n", module_idP, preamble_index, UE_id); @@ -325,7 +325,7 @@ void nr_initiate_ra_proc(module_id_t module_idP, ra->RA_rnti = ra_rnti; ra->preamble_index = preamble_index; - UE_list->tc_rnti[UE_id] = ra->rnti; + UE_info->tc_rnti[UE_id] = ra->rnti; LOG_I(MAC,"[gNB %d][RAPROC] CC_id %d Frame %d Activating Msg2 generation in frame %d, slot %d using RA rnti %x\n", module_idP, @@ -434,7 +434,7 @@ void nr_add_msg3(module_id_t module_idP, int CC_id, frame_t frameP, sub_frame_t NR_COMMON_channels_t *cc = &mac->common_channels[CC_id]; NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon; NR_RA_t *ra = &cc->ra[0]; - NR_UE_list_t *UE_list = &mac->UE_list; + NR_UE_info_t *UE_info = &mac->UE_info; int UE_id = 0; if (ra->state == RA_IDLE) { @@ -448,9 +448,9 @@ void nr_add_msg3(module_id_t module_idP, int CC_id, frame_t frameP, sub_frame_t memset(pusch_pdu, 0, sizeof(nfapi_nr_pusch_pdu_t)); - AssertFatal(UE_list->active[UE_id] >=0,"Cannot find UE_id %d is not active\n", UE_id); + AssertFatal(UE_info->active[UE_id] >=0,"Cannot find UE_id %d is not active\n", UE_id); - NR_CellGroupConfig_t *secondaryCellGroup = UE_list->secondaryCellGroup[UE_id]; + NR_CellGroupConfig_t *secondaryCellGroup = UE_info->secondaryCellGroup[UE_id]; AssertFatal(secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count == 1, "downlinkBWP_ToAddModList has %d BWP!\n", secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count); NR_BWP_Uplink_t *ubwp=secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[ra->bwp_id-1]; @@ -547,7 +547,7 @@ void nr_generate_Msg2(module_id_t module_idP, gNB_MAC_INST *nr_mac = RC.nrmac[module_idP]; NR_COMMON_channels_t *cc = &nr_mac->common_channels[0]; NR_RA_t *ra = &cc->ra[0]; - NR_UE_list_t *UE_list = &nr_mac->UE_list; + NR_UE_info_t *UE_info = &nr_mac->UE_info; NR_SearchSpace_t *ss = ra->ra_ss; uint16_t RA_rnti = ra->RA_rnti; @@ -597,7 +597,7 @@ void nr_generate_Msg2(module_id_t module_idP, // This code from this point on will not work on initialBWP or CORESET0 AssertFatal(ra->bwp_id>0,"cannot work on initialBWP for now\n"); - NR_CellGroupConfig_t *secondaryCellGroup = UE_list->secondaryCellGroup[UE_id]; + NR_CellGroupConfig_t *secondaryCellGroup = UE_info->secondaryCellGroup[UE_id]; AssertFatal(secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count == 1, "downlinkBWP_ToAddModList has %d BWP!\n", secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count); NR_BWP_Downlink_t *bwp = secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[ra->bwp_id - 1]; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index b180a05a8b..6d0e4ad5b1 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -76,12 +76,12 @@ int nr_generate_dlsch_pdu(module_id_t module_idP, ce_ptr = &mac_header_control_elements[0]; uint16_t UE_id = 0; //TODO need to get as a function parameter or need to invoke api to UE_id using module Id and RNTI gNB_MAC_INST *gNB_mac = RC.nrmac[module_idP]; - NR_UE_list_t *UE_list = &gNB_mac->UE_list; + NR_UE_info_t *UE_info = &gNB_mac->UE_info; NR_UE_sched_ctrl_t *ue_sched_ctl = NULL; - //NR_CellGroupConfig_t *config = UE_list->secondaryCellGroup[UE_id]; - ue_sched_ctl = &(UE_list->UE_sched_ctrl[UE_id]); + //NR_CellGroupConfig_t *config = UE_info->secondaryCellGroup[UE_id]; + ue_sched_ctl = &(UE_info->UE_sched_ctrl[UE_id]); - NR_mac_stats_t *mac_stats = &(UE_list->mac_stats[UE_id]); + NR_mac_stats_t *mac_stats = &(UE_info->mac_stats[UE_id]); // 1) Compute MAC CE and related subheaders @@ -449,19 +449,18 @@ void nr_simple_dlsch_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t slot, int num_slots_per_tdd) { - NR_UE_list_t *UE_list = &RC.nrmac[module_id]->UE_list; + NR_UE_info_t *UE_info = &RC.nrmac[module_id]->UE_info; const int UE_id = 0; const int CC_id = 0; - NR_UE_sched_ctrl_t *sched_ctrl = &UE_list->UE_sched_ctrl[UE_id]; - // TODO: reset per UE-info + NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; sched_ctrl->rbSize = 0; /* Retrieve amount of data to send for this UE */ sched_ctrl->num_total_bytes = 0; const int lcid = DL_SCH_LCID_DTCH; - const uint16_t rnti = UE_list->rnti[UE_id]; + const uint16_t rnti = UE_info->rnti[UE_id]; sched_ctrl->rlc_status[lcid] = mac_rlc_status_ind(module_id, rnti, module_id, @@ -544,8 +543,8 @@ void nr_schedule_ue_spec(module_id_t module_id, sub_frame_t slot, int num_slots_per_tdd) { gNB_MAC_INST *gNB_mac = RC.nrmac[module_id]; - NR_UE_list_t *UE_list = &gNB_mac->UE_list; - if (UE_list->num_UEs == 0) + NR_UE_info_t *UE_info = &gNB_mac->UE_info; + if (UE_info->num_UEs == 0) return; /* PREPROCESSOR */ @@ -555,7 +554,7 @@ void nr_schedule_ue_spec(module_id_t module_id, const int UE_id = 0; const int CC_id = 0; - NR_UE_sched_ctrl_t *sched_ctrl = &UE_list->UE_sched_ctrl[UE_id]; + NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; if (sched_ctrl->rbSize < 0 && !get_softmodem_params()->phy_test) return; @@ -594,7 +593,7 @@ void nr_schedule_ue_spec(module_id_t module_id, uint16_t sdu_lengths[NB_RB_MAX] = {0}; uint8_t mac_sdus[MAX_NR_DLSCH_PAYLOAD_BYTES]; unsigned char sdu_lcids[NB_RB_MAX] = {0}; - const rnti_t rnti = UE_list->rnti[UE_id]; + const rnti_t rnti = UE_info->rnti[UE_id]; const int lcid = DL_SCH_LCID_DTCH; if (sched_ctrl->num_total_bytes > 0) { LOG_D(MAC, @@ -661,7 +660,7 @@ void nr_schedule_ue_spec(module_id_t module_id, const int offset = nr_generate_dlsch_pdu( module_id, (unsigned char *)mac_sdus, - (unsigned char *)gNB_mac->UE_list.DLSCH_pdu[0][0].payload[0], + (unsigned char *)gNB_mac->UE_info.DLSCH_pdu[0][0].payload[0], num_sdus, // num_sdus sdu_lengths, sdu_lcids, @@ -672,7 +671,7 @@ void nr_schedule_ue_spec(module_id_t module_id, // Padding: fill remainder of DLSCH with 0 if (post_padding > 0) { for (int j = 0; j < TBS - offset; j++) - gNB_mac->UE_list.DLSCH_pdu[0][0].payload[0][offset + j] = 0; + gNB_mac->UE_info.DLSCH_pdu[0][0].payload[0][offset + j] = 0; } const int current_harq_pid = sched_ctrl->current_harq_pid; @@ -680,9 +679,9 @@ void nr_schedule_ue_spec(module_id_t module_id, NR_sched_pucch *pucch = &sched_ctrl->sched_pucch[sched_ctrl->pucch_sched_idx]; harq->feedback_slot = pucch->ul_slot; harq->is_waiting = 1; - UE_list->mac_stats[UE_id].dlsch_rounds[harq->round]++; + UE_info->mac_stats[UE_id].dlsch_rounds[harq->round]++; if (harq->round == 0) - UE_list->mac_stats[UE_id].dlsch_total_bytes += TBS; + UE_info->mac_stats[UE_id].dlsch_total_bytes += TBS; nfapi_nr_dl_tti_request_body_t *dl_req = &gNB_mac->DL_req[CC_id].dl_tti_request_body; nr_fill_nfapi_dl_pdu(module_id, @@ -728,7 +727,7 @@ void nr_schedule_ue_spec(module_id_t module_id, slot, TBS); for(int i = 0; i < 10; i++) { - LOG_I(MAC, "byte %d : %x\n", i,((uint8_t *)gNB_mac->UE_list.DLSCH_pdu[0][0].payload[0])[i]); + LOG_I(MAC, "byte %d : %x\n", i,((uint8_t *)gNB_mac->UE_info.DLSCH_pdu[0][0].payload[0])[i]); } } #endif diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c index 1bc271db21..fb455131a1 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c @@ -269,9 +269,9 @@ int configure_fapi_dl_pdu_phytest(int Mod_idP, int bwp_id=1; int UE_id = 0; - NR_UE_list_t *UE_list = &RC.nrmac[Mod_idP]->UE_list; + NR_UE_info_t *UE_info = &RC.nrmac[Mod_idP]->UE_info; - NR_CellGroupConfig_t *secondaryCellGroup = UE_list->secondaryCellGroup[UE_id]; + NR_CellGroupConfig_t *secondaryCellGroup = UE_info->secondaryCellGroup[UE_id]; AssertFatal(secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count == 1, "downlinkBWP_ToAddModList has %d BWP!\n", secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count); @@ -296,7 +296,7 @@ int configure_fapi_dl_pdu_phytest(int Mod_idP, pdsch_pdu_rel15->pduBitmap = 0; - pdsch_pdu_rel15->rnti = UE_list->rnti[UE_id]; + pdsch_pdu_rel15->rnti = UE_info->rnti[UE_id]; pdsch_pdu_rel15->pduIndex = 0; // BWP @@ -308,17 +308,17 @@ int configure_fapi_dl_pdu_phytest(int Mod_idP, pdsch_pdu_rel15->NrOfCodewords = 1; int mcs = (mcsIndex!=NULL) ? *mcsIndex : 9; - int current_harq_pid = UE_list->UE_sched_ctrl[UE_id].current_harq_pid; + int current_harq_pid = UE_info->UE_sched_ctrl[UE_id].current_harq_pid; pdsch_pdu_rel15->targetCodeRate[0] = nr_get_code_rate_dl(mcs,0); pdsch_pdu_rel15->qamModOrder[0] = 2; pdsch_pdu_rel15->mcsIndex[0] = mcs; pdsch_pdu_rel15->mcsTable[0] = 0; - pdsch_pdu_rel15->rvIndex[0] = nr_rv_round_map[UE_list->UE_sched_ctrl[UE_id].harq_processes[current_harq_pid].round]; + pdsch_pdu_rel15->rvIndex[0] = nr_rv_round_map[UE_info->UE_sched_ctrl[UE_id].harq_processes[current_harq_pid].round]; pdsch_pdu_rel15->dataScramblingId = *scc->physCellId; pdsch_pdu_rel15->nrOfLayers = 1; pdsch_pdu_rel15->transmissionScheme = 0; pdsch_pdu_rel15->refPoint = 0; // Point A - UE_list->mac_stats[UE_id].dlsch_rounds[UE_list->UE_sched_ctrl[UE_id].harq_processes[current_harq_pid].round]++; + UE_info->mac_stats[UE_id].dlsch_rounds[UE_info->UE_sched_ctrl[UE_id].harq_processes[current_harq_pid].round]++; pdsch_pdu_rel15->dmrsConfigType = bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type == NULL ? 0 : 1; pdsch_pdu_rel15->dlDmrsScramblingId = *scc->physCellId; pdsch_pdu_rel15->SCID = 0; @@ -366,18 +366,18 @@ int configure_fapi_dl_pdu_phytest(int Mod_idP, dci_pdu_rel15[0].rv = pdsch_pdu_rel15->rvIndex[0]; // harq pid and ndi dci_pdu_rel15[0].harq_pid = current_harq_pid; - dci_pdu_rel15[0].ndi = UE_list->UE_sched_ctrl[UE_id].harq_processes[current_harq_pid].ndi; + dci_pdu_rel15[0].ndi = UE_info->UE_sched_ctrl[UE_id].harq_processes[current_harq_pid].ndi; // DAI dci_pdu_rel15[0].dai[0].val = (pucch_sched->dai_c-1)&3; // TPC for PUCCH - dci_pdu_rel15[0].tpc = UE_list->UE_sched_ctrl[UE_id].tpc1; // table 7.2.1-1 in 38.213 + dci_pdu_rel15[0].tpc = UE_info->UE_sched_ctrl[UE_id].tpc1; // table 7.2.1-1 in 38.213 // PUCCH resource indicator dci_pdu_rel15[0].pucch_resource_indicator = pucch_sched->resource_indicator; // PDSCH to HARQ TI dci_pdu_rel15[0].pdsch_to_harq_feedback_timing_indicator.val = pucch_sched->timing_indicator; - UE_list->UE_sched_ctrl[UE_id].harq_processes[current_harq_pid].feedback_slot = pucch_sched->ul_slot; - UE_list->UE_sched_ctrl[UE_id].harq_processes[current_harq_pid].is_waiting = 1; + UE_info->UE_sched_ctrl[UE_id].harq_processes[current_harq_pid].feedback_slot = pucch_sched->ul_slot; + UE_info->UE_sched_ctrl[UE_id].harq_processes[current_harq_pid].is_waiting = 1; // antenna ports dci_pdu_rel15[0].antenna_ports.val = 0; // nb of cdm groups w/o data 1 and dmrs port 0 // dmrs sequence initialization @@ -432,7 +432,7 @@ int configure_fapi_dl_pdu_phytest(int Mod_idP, } nr_configure_pdcch(nr_mac, pdcch_pdu_rel15, - UE_list->rnti[UE_id], + UE_info->rnti[UE_id], ss, coreset, scc, @@ -466,8 +466,8 @@ int configure_fapi_dl_pdu_phytest(int Mod_idP, // Hardcode it for now TBS = dl_tti_pdsch_pdu->pdsch_pdu.pdsch_pdu_rel15.TBSize[0]; - if (UE_list->UE_sched_ctrl[UE_id].harq_processes[current_harq_pid].round==0) - UE_list->mac_stats[UE_id].dlsch_total_bytes += TBS; + if (UE_info->UE_sched_ctrl[UE_id].harq_processes[current_harq_pid].round==0) + UE_info->mac_stats[UE_id].dlsch_total_bytes += TBS; LOG_D(MAC, "DLSCH PDU: start PRB %d n_PRB %d startSymbolAndLength %d start symbol %d nb_symbols %d nb_layers %d nb_codewords %d mcs %d TBS: %d\n", pdsch_pdu_rel15->rbStart, @@ -592,7 +592,7 @@ void configure_fapi_dl_Tx(module_id_t Mod_idP, tx_req->num_TLV = 1; tx_req->TLVs[0].length = tbs_bytes +2; - memcpy((void*)&tx_req->TLVs[0].value.direct[0], (void*)&nr_mac->UE_list.DLSCH_pdu[0][0].payload[0], tbs_bytes); + memcpy((void*)&tx_req->TLVs[0].value.direct[0], (void*)&nr_mac->UE_info.DLSCH_pdu[0][0].payload[0], tbs_bytes); nr_mac->TX_req[CC_id].Number_of_PDUs++; nr_mac->TX_req[CC_id].SFN = frameP; @@ -619,13 +619,13 @@ void nr_schedule_uss_dlsch_phytest(module_id_t module_idP, mac_rlc_status_resp_t rlc_status; - NR_UE_list_t *UE_list = &gNB_mac->UE_list; + NR_UE_info_t *UE_info = &gNB_mac->UE_info; - if (UE_list->num_UEs ==0) return; + if (UE_info->num_UEs ==0) return; unsigned char sdu_lcids[NB_RB_MAX] = {0}; uint16_t sdu_lengths[NB_RB_MAX] = {0}; - uint16_t rnti = UE_list->rnti[UE_id]; + uint16_t rnti = UE_info->rnti[UE_id]; uint8_t mac_sdus[MAX_NR_DLSCH_PAYLOAD_BYTES]; @@ -704,7 +704,7 @@ void nr_schedule_uss_dlsch_phytest(module_id_t module_idP, // fill dlsch_buffer with random data for (i = 0; i < TBS_bytes; i++){ mac_sdus[i] = (unsigned char) (lrand48()&0xff); - //((uint8_t *)gNB_mac->UE_list.DLSCH_pdu[0][0].payload[0])[i] = (unsigned char) (lrand48()&0xff); + //((uint8_t *)gNB_mac->UE_info.DLSCH_pdu[0][0].payload[0])[i] = (unsigned char) (lrand48()&0xff); } //Sending SDUs with size 1 //Initialize elements of sdu_lcids and sdu_lengths @@ -718,7 +718,7 @@ void nr_schedule_uss_dlsch_phytest(module_id_t module_idP, if (frameP%100 == 0){ LOG_I(MAC, "Printing first 10 payload bytes at the gNB side, Frame: %d, slot: %d, TBS size: %d \n", frameP, slotP, TBS_bytes); for(int i = 0; i < 10; i++) { - LOG_I(MAC, "%x. ", ((uint8_t *)gNB_mac->UE_list.DLSCH_pdu[CC_id][0][0].payload[0])[i]); + LOG_I(MAC, "%x. ", ((uint8_t *)gNB_mac->UE_info.DLSCH_pdu[CC_id][0][0].payload[0])[i]); } } #endif @@ -742,7 +742,7 @@ void nr_schedule_uss_dlsch_phytest(module_id_t module_idP, offset = nr_generate_dlsch_pdu(module_idP, (unsigned char *) mac_sdus, - (unsigned char *) gNB_mac->UE_list.DLSCH_pdu[0][0].payload[0], + (unsigned char *) gNB_mac->UE_info.DLSCH_pdu[0][0].payload[0], num_sdus, //num_sdus sdu_lengths, sdu_lcids, @@ -753,7 +753,7 @@ void nr_schedule_uss_dlsch_phytest(module_id_t module_idP, // Padding: fill remainder of DLSCH with 0 if (post_padding > 0){ for (int j = 0; j < (TBS_bytes - offset); j++) - gNB_mac->UE_list.DLSCH_pdu[0][0].payload[0][offset + j] = 0; // mac_pdu[offset + j] = 0; + gNB_mac->UE_info.DLSCH_pdu[0][0].payload[0][offset + j] = 0; // mac_pdu[offset + j] = 0; } configure_fapi_dl_Tx(module_idP, frameP, slotP, dl_req, tx_req, TBS_bytes, gNB_mac->pdu_index[CC_id]); @@ -770,7 +770,7 @@ void nr_schedule_uss_dlsch_phytest(module_id_t module_idP, if (frameP%100 == 0){ LOG_I(MAC, "Printing first 10 payload bytes at the gNB side, Frame: %d, slot: %d, TBS size: %d \n", frameP, slotP, TBS_bytes); for(int i = 0; i < 10; i++) { - LOG_I(MAC, "byte %d : %x\n", i,((uint8_t *)gNB_mac->UE_list.DLSCH_pdu[0][0].payload[0])[i]); //LOG_I(MAC, "%x. ", mac_payload[i]); + LOG_I(MAC, "byte %d : %x\n", i,((uint8_t *)gNB_mac->UE_info.DLSCH_pdu[0][0].payload[0])[i]); //LOG_I(MAC, "%x. ", mac_payload[i]); } } #endif @@ -839,10 +839,10 @@ void schedule_fapi_ul_pdu(int Mod_idP, int bwp_id=1; int mu = scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.subcarrierSpacing; int UE_id = 0; - NR_UE_list_t *UE_list = &RC.nrmac[Mod_idP]->UE_list; - AssertFatal(UE_list->active[UE_id] >=0,"Cannot find UE_id %d is not active\n",UE_id); + NR_UE_info_t *UE_info = &RC.nrmac[Mod_idP]->UE_info; + AssertFatal(UE_info->active[UE_id] >=0,"Cannot find UE_id %d is not active\n",UE_id); - NR_CellGroupConfig_t *secondaryCellGroup = UE_list->secondaryCellGroup[UE_id]; + NR_CellGroupConfig_t *secondaryCellGroup = UE_info->secondaryCellGroup[UE_id]; AssertFatal(secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count == 1, "downlinkBWP_ToAddModList has %d BWP!\n", secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count); @@ -871,10 +871,10 @@ void schedule_fapi_ul_pdu(int Mod_idP, AssertFatal(bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList->list.count>0, "searchPsacesToAddModList is empty\n"); - uint16_t rnti = UE_list->rnti[UE_id]; + uint16_t rnti = UE_info->rnti[UE_id]; int first_ul_slot = num_slots_per_tdd - ul_slots; - NR_sched_pusch *pusch_sched = &UE_list->UE_sched_ctrl[UE_id].sched_pusch[slotP+K2-first_ul_slot]; + NR_sched_pusch *pusch_sched = &UE_info->UE_sched_ctrl[UE_id].sched_pusch[slotP+K2-first_ul_slot]; pusch_sched->frame = frameP; pusch_sched->slot = slotP + K2; pusch_sched->active = true; @@ -1024,9 +1024,9 @@ void schedule_fapi_ul_pdu(int Mod_idP, //Pusch Allocation in frequency domain [TS38.214, sec 6.1.2.2] //Optional Data only included if indicated in pduBitmap - int8_t harq_id = select_ul_harq_pid(&UE_list->UE_sched_ctrl[UE_id]); + int8_t harq_id = select_ul_harq_pid(&UE_info->UE_sched_ctrl[UE_id]); if (harq_id < 0) return; - NR_UE_ul_harq_t *cur_harq = &UE_list->UE_sched_ctrl[UE_id].ul_harq_processes[harq_id]; + NR_UE_ul_harq_t *cur_harq = &UE_info->UE_sched_ctrl[UE_id].ul_harq_processes[harq_id]; pusch_pdu->pusch_data.harq_process_id = harq_id; pusch_pdu->pusch_data.new_data_indicator = cur_harq->ndi; pusch_pdu->pusch_data.rv_index = nr_rv_round_map[cur_harq->round]; @@ -1056,8 +1056,8 @@ void schedule_fapi_ul_pdu(int Mod_idP, 0, pusch_pdu->nrOfLayers)>>3; - UE_list->mac_stats[UE_id].ulsch_rounds[cur_harq->round]++; - if (cur_harq->round == 0) UE_list->mac_stats[UE_id].ulsch_total_bytes_scheduled+=pusch_pdu->pusch_data.tb_size; + UE_info->mac_stats[UE_id].ulsch_rounds[cur_harq->round]++; + if (cur_harq->round == 0) UE_info->mac_stats[UE_id].ulsch_total_bytes_scheduled+=pusch_pdu->pusch_data.tb_size; pusch_pdu->pusch_data.num_cb = 0; //CBG not supported //pusch_pdu->pusch_data.cb_present_and_position; @@ -1125,7 +1125,7 @@ void schedule_fapi_ul_pdu(int Mod_idP, else { nr_configure_pdcch(nr_mac, pdcch_pdu_rel15, - UE_list->rnti[UE_id], + UE_info->rnti[UE_id], ss, coreset, scc, @@ -1134,7 +1134,7 @@ void schedule_fapi_ul_pdu(int Mod_idP, CCEIndex); dci_pdu_rel15_t *dci_pdu_rel15 = calloc(MAX_DCI_CORESET,sizeof(dci_pdu_rel15_t)); - config_uldci(ubwp,pusch_pdu,pdcch_pdu_rel15,&dci_pdu_rel15[0],dci_formats,rnti_types,time_domain_assignment,UE_list->UE_sched_ctrl[UE_id].tpc0,n_ubwp,bwp_id); + config_uldci(ubwp,pusch_pdu,pdcch_pdu_rel15,&dci_pdu_rel15[0],dci_formats,rnti_types,time_domain_assignment,UE_info->UE_sched_ctrl[UE_id].tpc0,n_ubwp,bwp_id); fill_dci_pdu_rel15(scc,secondaryCellGroup,pdcch_pdu_rel15,dci_pdu_rel15,dci_formats,rnti_types,pusch_pdu->bwp_size,bwp_id); free(dci_pdu_rel15); } diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index 8c7c6a8fe8..24fbc97136 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -180,9 +180,9 @@ int allocate_nr_CCEs(gNB_MAC_INST *nr_mac, // NR_COMMON_channels_t *cc = nr_mac->common_channels; // NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon; - NR_UE_list_t *UE_list = &nr_mac->UE_list; + NR_UE_info_t *UE_info = &nr_mac->UE_info; - AssertFatal(UE_list->active[UE_id] >=0,"UE_id %d is not active\n",UE_id); + AssertFatal(UE_info->active[UE_id] >=0,"UE_id %d is not active\n",UE_id); int coreset_id = coreset->controlResourceSetId; int *cce_list = nr_mac->cce_list[bwp->bwp_Id][coreset_id]; @@ -196,7 +196,7 @@ int allocate_nr_CCEs(gNB_MAC_INST *nr_mac, uint16_t N_reg = n_rb * coreset->duration; uint16_t Y=0, N_cce, M_s_max, n_CI=0; - uint16_t n_RNTI = search_space == 1 ? UE_list->rnti[UE_id]:0; + uint16_t n_RNTI = search_space == 1 ? UE_info->rnti[UE_id]:0; uint32_t A[3]={39827,39829,39839}; N_cce = N_reg / NR_NB_REG_PER_CCE; @@ -464,12 +464,9 @@ void nr_fill_nfapi_dl_pdu(int Mod_idP, NR_COMMON_channels_t *cc = nr_mac->common_channels; NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon; - nfapi_nr_dl_tti_request_pdu_t *dl_tti_pdcch_pdu; - nfapi_nr_dl_tti_request_pdu_t *dl_tti_pdsch_pdu; + NR_UE_info_t *UE_info = &RC.nrmac[Mod_idP]->UE_info; - NR_UE_list_t *UE_list = &RC.nrmac[Mod_idP]->UE_list; - - NR_CellGroupConfig_t *secondaryCellGroup = UE_list->secondaryCellGroup[UE_id]; + NR_CellGroupConfig_t *secondaryCellGroup = UE_info->secondaryCellGroup[UE_id]; AssertFatal(secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count == 1, "downlinkBWP_ToAddModList has %d BWP!\n", secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count); @@ -479,12 +476,12 @@ void nr_fill_nfapi_dl_pdu(int Mod_idP, AssertFatal(bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList->list.count>0, "searchPsacesToAddModList is empty\n"); - dl_tti_pdcch_pdu = &dl_req->dl_tti_pdu_list[dl_req->nPDUs]; + nfapi_nr_dl_tti_request_pdu_t *dl_tti_pdcch_pdu = &dl_req->dl_tti_pdu_list[dl_req->nPDUs]; memset((void*)dl_tti_pdcch_pdu,0,sizeof(nfapi_nr_dl_tti_request_pdu_t)); dl_tti_pdcch_pdu->PDUType = NFAPI_NR_DL_TTI_PDCCH_PDU_TYPE; dl_tti_pdcch_pdu->PDUSize = (uint8_t)(2+sizeof(nfapi_nr_dl_tti_pdcch_pdu)); - dl_tti_pdsch_pdu = &dl_req->dl_tti_pdu_list[dl_req->nPDUs+1]; + nfapi_nr_dl_tti_request_pdu_t *dl_tti_pdsch_pdu = &dl_req->dl_tti_pdu_list[dl_req->nPDUs+1]; memset((void*)dl_tti_pdsch_pdu,0,sizeof(nfapi_nr_dl_tti_request_pdu_t)); dl_tti_pdsch_pdu->PDUType = NFAPI_NR_DL_TTI_PDSCH_PDU_TYPE; dl_tti_pdsch_pdu->PDUSize = (uint8_t)(2+sizeof(nfapi_nr_dl_tti_pdsch_pdu)); @@ -494,7 +491,7 @@ void nr_fill_nfapi_dl_pdu(int Mod_idP, pdsch_pdu_rel15->pduBitmap = 0; - pdsch_pdu_rel15->rnti = UE_list->rnti[UE_id]; + pdsch_pdu_rel15->rnti = UE_info->rnti[UE_id]; pdsch_pdu_rel15->pduIndex = 0; // BWP @@ -569,7 +566,7 @@ void nr_fill_nfapi_dl_pdu(int Mod_idP, dci_pdu_rel15[0].dai[0].val = (pucch_sched->dai_c-1)&3; // TPC for PUCCH - dci_pdu_rel15[0].tpc = UE_list->UE_sched_ctrl[UE_id].tpc1; // table 7.2.1-1 in 38.213 + dci_pdu_rel15[0].tpc = UE_info->UE_sched_ctrl[UE_id].tpc1; // table 7.2.1-1 in 38.213 // PUCCH resource indicator dci_pdu_rel15[0].pucch_resource_indicator = pucch_sched->resource_indicator; // PDSCH to HARQ TI @@ -594,7 +591,7 @@ void nr_fill_nfapi_dl_pdu(int Mod_idP, nr_configure_pdcch(nr_mac, pdcch_pdu_rel15, - UE_list->rnti[UE_id], + UE_info->rnti[UE_id], ss, coreset, scc, @@ -1593,10 +1590,10 @@ int extract_length(int startSymbolAndLength) { } /* - * Dump the UL or DL UE_list into LOG_T(MAC) + * Dump the UL or DL UE_info into LOG_T(MAC) */ void -dump_nr_ue_list(NR_UE_list_t *listP, +dump_nr_ue_list(NR_UE_info_t *listP, int ul_flag) //------------------------------------------------------------------------------ { @@ -1621,11 +1618,11 @@ int find_nr_UE_id(module_id_t mod_idP, rnti_t rntiP) //------------------------------------------------------------------------------ { int UE_id; - NR_UE_list_t *UE_list = &RC.nrmac[mod_idP]->UE_list; + NR_UE_info_t *UE_info = &RC.nrmac[mod_idP]->UE_info; for (UE_id = 0; UE_id < MAX_MOBILES_PER_GNB; UE_id++) { - if (UE_list->active[UE_id] == TRUE) { - if (UE_list->rnti[UE_id] == rntiP) { + if (UE_info->active[UE_id]) { + if (UE_info->rnti[UE_id] == rntiP) { return UE_id; } } @@ -1638,7 +1635,7 @@ int add_new_nr_ue(module_id_t mod_idP, rnti_t rntiP){ int UE_id; int i; - NR_UE_list_t *UE_list = &RC.nrmac[mod_idP]->UE_list; + NR_UE_info_t *UE_info = &RC.nrmac[mod_idP]->UE_info; NR_COMMON_channels_t *cc = RC.nrmac[mod_idP]->common_channels; NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon; int num_slots_ul = scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSlots; @@ -1647,29 +1644,29 @@ int add_new_nr_ue(module_id_t mod_idP, rnti_t rntiP){ LOG_I(MAC, "[gNB %d] Adding UE with rnti %x (next avail %d, num_UEs %d)\n", mod_idP, rntiP, - UE_list->avail, - UE_list->num_UEs); - dump_nr_ue_list(UE_list, 0); + UE_info->avail, + UE_info->num_UEs); + dump_nr_ue_list(UE_info, 0); for (i = 0; i < MAX_MOBILES_PER_ENB; i++) { - if (UE_list->active[i] == TRUE) + if (UE_info->active[i]) continue; UE_id = i; - UE_list->num_UEs++; - UE_list->active[UE_id] = TRUE; - UE_list->rnti[UE_id] = rntiP; - memset((void *) &UE_list->UE_sched_ctrl[UE_id], + UE_info->num_UEs++; + UE_info->active[UE_id] = TRUE; + UE_info->rnti[UE_id] = rntiP; + memset((void *) &UE_info->UE_sched_ctrl[UE_id], 0, sizeof(NR_UE_sched_ctrl_t)); - UE_list->UE_sched_ctrl[UE_id].ul_rssi = 0; - UE_list->UE_sched_ctrl[UE_id].sched_pucch = (NR_sched_pucch *)malloc(num_slots_ul*sizeof(NR_sched_pucch)); - UE_list->UE_sched_ctrl[UE_id].sched_pusch = (NR_sched_pusch *)malloc(num_slots_ul*sizeof(NR_sched_pusch)); + UE_info->UE_sched_ctrl[UE_id].ul_rssi = 0; + UE_info->UE_sched_ctrl[UE_id].sched_pucch = (NR_sched_pucch *)malloc(num_slots_ul*sizeof(NR_sched_pucch)); + UE_info->UE_sched_ctrl[UE_id].sched_pusch = (NR_sched_pusch *)malloc(num_slots_ul*sizeof(NR_sched_pusch)); for (int k=0; kUE_sched_ctrl[UE_id].sched_pucch[k], + memset((void *) &UE_info->UE_sched_ctrl[UE_id].sched_pucch[k], 0, sizeof(NR_sched_pucch)); - memset((void *) &UE_list->UE_sched_ctrl[UE_id].sched_pusch[k], + memset((void *) &UE_info->UE_sched_ctrl[UE_id].sched_pusch[k], 0, sizeof(NR_sched_pusch)); } @@ -1677,14 +1674,14 @@ int add_new_nr_ue(module_id_t mod_idP, rnti_t rntiP){ mod_idP, UE_id, rntiP); - dump_nr_ue_list(UE_list, + dump_nr_ue_list(UE_info, 0); return (UE_id); } // printf("MAC: cannot add new UE for rnti %x\n", rntiP); - LOG_E(MAC, "error in add_new_ue(), could not find space in UE_list, Dumping UE list\n"); - dump_nr_ue_list(UE_list, + LOG_E(MAC, "error in add_new_ue(), could not find space in UE_info, Dumping UE list\n"); + dump_nr_ue_list(UE_info, 0); return -1; } @@ -1707,8 +1704,8 @@ void get_pdsch_to_harq_feedback(int Mod_idP, uint8_t *pdsch_to_harq_feedback) { int bwp_id=1; - NR_UE_list_t *UE_list = &RC.nrmac[Mod_idP]->UE_list; - NR_CellGroupConfig_t *secondaryCellGroup = UE_list->secondaryCellGroup[UE_id]; + NR_UE_info_t *UE_info = &RC.nrmac[Mod_idP]->UE_info; + NR_CellGroupConfig_t *secondaryCellGroup = UE_info->secondaryCellGroup[UE_id]; NR_BWP_Downlink_t *bwp=secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[bwp_id-1]; NR_BWP_Uplink_t *ubwp=secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[bwp_id-1]; @@ -1760,7 +1757,7 @@ void nr_update_pucch_scheduling(int Mod_idP, int *pucch_id) { NR_ServingCellConfigCommon_t *scc = RC.nrmac[Mod_idP]->common_channels->ServingCellConfigCommon; - NR_UE_list_t *UE_list = &RC.nrmac[Mod_idP]->UE_list; + NR_UE_info_t *UE_info = &RC.nrmac[Mod_idP]->UE_info; NR_sched_pucch *curr_pucch; int first_ul_slot_tdd,k,i; uint8_t pdsch_to_harq_feedback[8]; @@ -1775,7 +1772,7 @@ void nr_update_pucch_scheduling(int Mod_idP, // for each possible ul or mixed slot for (k=0; kUE_sched_ctrl[UE_id].sched_pucch[k]; + curr_pucch = &UE_info->UE_sched_ctrl[UE_id].sched_pucch[k]; // if there is free room in current pucch structure if (curr_pucch->dai_cframe = frameP; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c index bb0dad7064..b68c452f16 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c @@ -212,7 +212,7 @@ void nr_process_mac_pdu( LOG_D(MAC, "[UE %d] Frame %d : ULSCH -> UL-DTCH %d (gNB %d, %d bytes)\n", module_idP, frameP, rx_lcid, module_idP, mac_sdu_len); int UE_id = find_nr_UE_id(module_idP, rnti); - RC.nrmac[module_idP]->UE_list.mac_stats[UE_id].lc_bytes_rx[rx_lcid] += mac_sdu_len; + RC.nrmac[module_idP]->UE_info.mac_stats[UE_id].lc_bytes_rx[rx_lcid] += mac_sdu_len; #if defined(ENABLE_MAC_PAYLOAD_DEBUG) LOG_T(MAC, "[UE %d] First 32 bytes of DLSCH : \n", module_idP); @@ -313,19 +313,19 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP, const uint16_t rssi){ int current_rnti = 0, UE_id = -1, harq_pid = 0; gNB_MAC_INST *gNB_mac = NULL; - NR_UE_list_t *UE_list = NULL; + NR_UE_info_t *UE_info = NULL; NR_UE_sched_ctrl_t *UE_scheduling_control = NULL; current_rnti = rntiP; UE_id = find_nr_UE_id(gnb_mod_idP, current_rnti); gNB_mac = RC.nrmac[gnb_mod_idP]; - UE_list = &gNB_mac->UE_list; + UE_info = &gNB_mac->UE_info; int target_snrx10 = gNB_mac->pusch_target_snrx10; if (UE_id != -1) { - UE_scheduling_control = &(UE_list->UE_sched_ctrl[UE_id]); + UE_scheduling_control = &(UE_info->UE_sched_ctrl[UE_id]); - UE_list->mac_stats[UE_id].ulsch_total_bytes_rx += sdu_lenP; + UE_info->mac_stats[UE_id].ulsch_total_bytes_rx += sdu_lenP; LOG_D(MAC, "[gNB %d][PUSCH %d] CC_id %d %d.%d Received ULSCH sdu from PHY (rnti %x, UE_id %d) ul_cqi %d\n", gnb_mod_idP, harq_pid, @@ -369,10 +369,10 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP, // random access pusch with TC-RNTI if (sduP != NULL) { // if the CRC passed for (int i = 0; i < MAX_MOBILES_PER_GNB; i++) { - if (UE_list->active[i] == TRUE) { - if (UE_list->tc_rnti[i] == current_rnti) { + if (UE_info->active[i]) { + if (UE_info->tc_rnti[i] == current_rnti) { // for now the only thing we are doing is set the UE as 5G connected - UE_list->fiveG_connected[i] = true; + UE_info->fiveG_connected[i] = true; LOG_I(MAC, "[gNB %d][RAPROC] PUSCH with TC_RNTI %x received correctly and UE_id %d is now 5G connected\n", gnb_mod_idP, current_rnti, i); } diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index 6458fb0f79..b4b8da852a 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -300,7 +300,7 @@ int NRRIV2BW(int locationAndBandwidth,int N_RB); int NRRIV2PRBOFFSET(int locationAndBandwidth,int N_RB); -void dump_nr_ue_list(NR_UE_list_t *listP, int ul_flag); +void dump_nr_ue_list(NR_UE_info_t *listP, int ul_flag); int find_nr_UE_id(module_id_t mod_idP, rnti_t rntiP); diff --git a/openair2/LAYER2/NR_MAC_gNB/main.c b/openair2/LAYER2/NR_MAC_gNB/main.c index bd0be8c409..72d139153a 100644 --- a/openair2/LAYER2/NR_MAC_gNB/main.c +++ b/openair2/LAYER2/NR_MAC_gNB/main.c @@ -50,7 +50,7 @@ void mac_top_init_gNB(void) { module_id_t i; int list_el; - NR_UE_list_t *UE_list; + NR_UE_info_t *UE_info; gNB_MAC_INST *nrmac; LOG_I(MAC, "[MAIN] Init function start:nb_nr_macrlc_inst=%d\n",RC.nb_nr_macrlc_inst); @@ -104,29 +104,29 @@ void mac_top_init_gNB(void) nrmac = RC.nrmac[i]; nrmac->if_inst = NR_IF_Module_init(i); - UE_list = &nrmac->UE_list; - UE_list->num_UEs = 0; - UE_list->head = -1; - UE_list->head_ul = -1; - UE_list->avail = 0; + UE_info = &nrmac->UE_info; + UE_info->num_UEs = 0; + UE_info->head = -1; + UE_info->head_ul = -1; + UE_info->avail = 0; for (list_el = 0; list_el < MAX_MOBILES_PER_GNB - 1; list_el++) { - UE_list->next[list_el] = list_el + 1; - UE_list->next_ul[list_el] = list_el + 1; - UE_list->active[list_el] = FALSE; + UE_info->next[list_el] = list_el + 1; + UE_info->next_ul[list_el] = list_el + 1; + UE_info->active[list_el] = FALSE; for (int list_harq = 0; list_harq < NR_MAX_NB_HARQ_PROCESSES; list_harq++) { - UE_list->UE_sched_ctrl[list_el].harq_processes[list_harq].round = 0; - UE_list->UE_sched_ctrl[list_el].harq_processes[list_harq].ndi = 0; - UE_list->UE_sched_ctrl[list_el].harq_processes[list_harq].is_waiting = 0; - UE_list->UE_sched_ctrl[list_el].ul_harq_processes[list_harq].round = 0; - UE_list->UE_sched_ctrl[list_el].ul_harq_processes[list_harq].ndi = 0; - UE_list->UE_sched_ctrl[list_el].ul_harq_processes[list_harq].state = 0; + UE_info->UE_sched_ctrl[list_el].harq_processes[list_harq].round = 0; + UE_info->UE_sched_ctrl[list_el].harq_processes[list_harq].ndi = 0; + UE_info->UE_sched_ctrl[list_el].harq_processes[list_harq].is_waiting = 0; + UE_info->UE_sched_ctrl[list_el].ul_harq_processes[list_harq].round = 0; + UE_info->UE_sched_ctrl[list_el].ul_harq_processes[list_harq].ndi = 0; + UE_info->UE_sched_ctrl[list_el].ul_harq_processes[list_harq].state = 0; } } - UE_list->next[list_el] = -1; - UE_list->next_ul[list_el] = -1; - UE_list->active[list_el] = FALSE; + UE_info->next[list_el] = -1; + UE_info->next_ul[list_el] = -1; + UE_info->active[list_el] = FALSE; } srand48(0); diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index bf09dfcc12..2459195548 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -361,7 +361,7 @@ typedef struct { rnti_t tc_rnti[MAX_MOBILES_PER_GNB]; NR_preamble_ue preambles[MAX_MOBILES_PER_GNB]; NR_CellGroupConfig_t *secondaryCellGroup[MAX_MOBILES_PER_GNB]; -} NR_UE_list_t; +} NR_UE_info_t; /*! \brief top level eNB MAC structure */ typedef struct gNB_MAC_INST_s { @@ -399,7 +399,7 @@ typedef struct gNB_MAC_INST_s { /// NFAPI DL PDU structure nfapi_nr_tx_data_request_t TX_req[NFAPI_CC_MAX]; - NR_UE_list_t UE_list; + NR_UE_info_t UE_info; /// UL handle uint32_t ul_handle; diff --git a/openair2/NR_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_PHY_INTERFACE/NR_IF_Module.c index c5b90cf028..22c48d11eb 100644 --- a/openair2/NR_PHY_INTERFACE/NR_IF_Module.c +++ b/openair2/NR_PHY_INTERFACE/NR_IF_Module.c @@ -181,10 +181,10 @@ void NR_UL_indication(NR_UL_IND_t *UL_info) { clear_nr_nfapi_information(mac,CC_id,UL_info->frame,UL_info->slot); handle_nr_rach(UL_info); - handle_nr_uci(UL_info,&mac->UE_list.UE_sched_ctrl[0],&mac->UE_list.mac_stats[0],mac->pucch_target_snrx10); + handle_nr_uci(UL_info,&mac->UE_info.UE_sched_ctrl[0],&mac->UE_info.mac_stats[0],mac->pucch_target_snrx10); // clear HI prior to handling ULSCH mac->UL_dci_req[CC_id].numPdus = 0; - handle_nr_ulsch(UL_info, &mac->UE_list.UE_sched_ctrl[0],&mac->UE_list.mac_stats[0]); + handle_nr_ulsch(UL_info, &mac->UE_info.UE_sched_ctrl[0],&mac->UE_info.mac_stats[0]); if (nfapi_mode != 1) { if (ifi->CC_mask == ((1< Date: Mon, 21 Sep 2020 13:46:14 +0200 Subject: [PATCH 70/96] Add NR_UE_list_t type --- .../NR_MAC_gNB/gNB_scheduler_primitives.c | 34 ++++--------------- openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 2 +- openair2/LAYER2/NR_MAC_gNB/main.c | 14 ++------ openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h | 14 +++++--- 4 files changed, 20 insertions(+), 44 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index 24fbc97136..720a3b863d 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -1592,26 +1592,9 @@ int extract_length(int startSymbolAndLength) { /* * Dump the UL or DL UE_info into LOG_T(MAC) */ -void -dump_nr_ue_list(NR_UE_info_t *listP, - int ul_flag) -//------------------------------------------------------------------------------ -{ - if (ul_flag == 0) { - for (int j = listP->head; j >= 0; j = listP->next[j]) { - LOG_T(MAC, "DL list node %d => %d\n", - j, - listP->next[j]); - } - } else { - for (int j = listP->head_ul; j >= 0; j = listP->next_ul[j]) { - LOG_T(MAC, "UL list node %d => %d\n", - j, - listP->next_ul[j]); - } - } - - return; +void dump_nr_ue_list(NR_UE_list_t *listP) { + for (int j = listP->head; j >= 0; j = listP->next[j]) + LOG_T(MAC, "DL list node %d => %d\n", j, listP->next[j]); } int find_nr_UE_id(module_id_t mod_idP, rnti_t rntiP) @@ -1641,12 +1624,11 @@ int add_new_nr_ue(module_id_t mod_idP, rnti_t rntiP){ int num_slots_ul = scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSlots; if (scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSymbols>0) num_slots_ul++; - LOG_I(MAC, "[gNB %d] Adding UE with rnti %x (next avail %d, num_UEs %d)\n", + LOG_I(MAC, "[gNB %d] Adding UE with rnti %x (num_UEs %d)\n", mod_idP, rntiP, - UE_info->avail, UE_info->num_UEs); - dump_nr_ue_list(UE_info, 0); + dump_nr_ue_list(&UE_info->list); for (i = 0; i < MAX_MOBILES_PER_ENB; i++) { if (UE_info->active[i]) @@ -1674,15 +1656,13 @@ int add_new_nr_ue(module_id_t mod_idP, rnti_t rntiP){ mod_idP, UE_id, rntiP); - dump_nr_ue_list(UE_info, - 0); + dump_nr_ue_list(&UE_info->list); return (UE_id); } // printf("MAC: cannot add new UE for rnti %x\n", rntiP); LOG_E(MAC, "error in add_new_ue(), could not find space in UE_info, Dumping UE list\n"); - dump_nr_ue_list(UE_info, - 0); + dump_nr_ue_list(&UE_info->list); return -1; } diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index b4b8da852a..df82232964 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -300,7 +300,7 @@ int NRRIV2BW(int locationAndBandwidth,int N_RB); int NRRIV2PRBOFFSET(int locationAndBandwidth,int N_RB); -void dump_nr_ue_list(NR_UE_info_t *listP, int ul_flag); +void dump_nr_ue_list(NR_UE_list_t *listP); int find_nr_UE_id(module_id_t mod_idP, rnti_t rntiP); diff --git a/openair2/LAYER2/NR_MAC_gNB/main.c b/openair2/LAYER2/NR_MAC_gNB/main.c index 72d139153a..a06bde869c 100644 --- a/openair2/LAYER2/NR_MAC_gNB/main.c +++ b/openair2/LAYER2/NR_MAC_gNB/main.c @@ -106,13 +106,9 @@ void mac_top_init_gNB(void) UE_info = &nrmac->UE_info; UE_info->num_UEs = 0; - UE_info->head = -1; - UE_info->head_ul = -1; - UE_info->avail = 0; - - for (list_el = 0; list_el < MAX_MOBILES_PER_GNB - 1; list_el++) { - UE_info->next[list_el] = list_el + 1; - UE_info->next_ul[list_el] = list_el + 1; + UE_info->list.head = -1; + for (list_el = 0; list_el < MAX_MOBILES_PER_GNB; list_el++) { + UE_info->list.next[list_el] = -1; UE_info->active[list_el] = FALSE; for (int list_harq = 0; list_harq < NR_MAX_NB_HARQ_PROCESSES; list_harq++) { UE_info->UE_sched_ctrl[list_el].harq_processes[list_harq].round = 0; @@ -123,10 +119,6 @@ void mac_top_init_gNB(void) UE_info->UE_sched_ctrl[list_el].ul_harq_processes[list_harq].state = 0; } } - - UE_info->next[list_el] = -1; - UE_info->next_ul[list_el] = -1; - UE_info->active[list_el] = FALSE; } srand48(0); diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index 2459195548..ba2ef0e7e3 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -343,17 +343,21 @@ typedef struct { int ulsch_total_bytes_rx; } NR_mac_stats_t; + +/*! \brief UNR_E_list_t is a "list" of users within UE_info_t. Especial useful in + * the scheduler and to keep "classes" of users. */ +typedef struct { + int head; + int next[MAX_MOBILES_PER_GNB]; +} NR_UE_list_t; + /*! \brief UE list used by gNB to order UEs/CC for scheduling*/ typedef struct { DLSCH_PDU DLSCH_pdu[4][MAX_MOBILES_PER_GNB]; /// scheduling control info NR_UE_sched_ctrl_t UE_sched_ctrl[MAX_MOBILES_PER_GNB]; NR_mac_stats_t mac_stats[MAX_MOBILES_PER_GNB]; - int next[MAX_MOBILES_PER_GNB]; - int head; - int next_ul[MAX_MOBILES_PER_GNB]; - int head_ul; - int avail; + NR_UE_list_t list; int num_UEs; boolean_t active[MAX_MOBILES_PER_GNB]; boolean_t fiveG_connected[MAX_MOBILES_PER_GNB]; From 34f61ce39616f1f77a3501ba34b685fc27150f7a Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 21 Sep 2020 13:59:46 +0200 Subject: [PATCH 71/96] add_nr_ue_list() --- .../NR_MAC_gNB/gNB_scheduler_primitives.c | 19 +++++++++++++++---- openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 1 + 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index 720a3b863d..f28c61d5a3 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -1597,6 +1597,18 @@ void dump_nr_ue_list(NR_UE_list_t *listP) { LOG_T(MAC, "DL list node %d => %d\n", j, listP->next[j]); } +/* + * Add a UE to NR_UE_list listP + */ +inline void add_nr_ue_list(NR_UE_list_t *listP, int UE_id) { + int *cur = &listP->head; + while (*cur >= 0) { + AssertFatal(*cur != UE_id, "UE_id %d already in NR_UE_list!\n", UE_id); + cur = &listP->next[*cur]; + } + *cur = UE_id; +} + int find_nr_UE_id(module_id_t mod_idP, rnti_t rntiP) //------------------------------------------------------------------------------ { @@ -1616,8 +1628,6 @@ int find_nr_UE_id(module_id_t mod_idP, rnti_t rntiP) int add_new_nr_ue(module_id_t mod_idP, rnti_t rntiP){ - int UE_id; - int i; NR_UE_info_t *UE_info = &RC.nrmac[mod_idP]->UE_info; NR_COMMON_channels_t *cc = RC.nrmac[mod_idP]->common_channels; NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon; @@ -1630,14 +1640,15 @@ int add_new_nr_ue(module_id_t mod_idP, rnti_t rntiP){ UE_info->num_UEs); dump_nr_ue_list(&UE_info->list); - for (i = 0; i < MAX_MOBILES_PER_ENB; i++) { + for (int i = 0; i < MAX_MOBILES_PER_ENB; i++) { if (UE_info->active[i]) continue; - UE_id = i; + int UE_id = i; UE_info->num_UEs++; UE_info->active[UE_id] = TRUE; UE_info->rnti[UE_id] = rntiP; + add_nr_ue_list(&UE_info->list, UE_id); memset((void *) &UE_info->UE_sched_ctrl[UE_id], 0, sizeof(NR_UE_sched_ctrl_t)); diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index df82232964..e8c4057978 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -301,6 +301,7 @@ int NRRIV2BW(int locationAndBandwidth,int N_RB); int NRRIV2PRBOFFSET(int locationAndBandwidth,int N_RB); void dump_nr_ue_list(NR_UE_list_t *listP); +void add_nr_ue_list(NR_UE_list_t *listP, int UE_id); int find_nr_UE_id(module_id_t mod_idP, rnti_t rntiP); From 5efe475120aa445adb5b899af551d21daa62152b Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 21 Sep 2020 14:05:39 +0200 Subject: [PATCH 72/96] Make UE_info.active C99 bool --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c | 2 +- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c | 2 +- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c | 2 +- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c | 4 ++-- openair2/LAYER2/NR_MAC_gNB/main.c | 2 +- openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c index eab8cb2e0b..0f39fb9302 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c @@ -349,7 +349,7 @@ void nr_schedule_pucch(int Mod_idP, uint8_t SR_flag = 0; // no SR in PUCCH implemented for now NR_ServingCellConfigCommon_t *scc = RC.nrmac[Mod_idP]->common_channels->ServingCellConfigCommon; NR_UE_info_t *UE_info = &RC.nrmac[Mod_idP]->UE_info; - AssertFatal(UE_info->active[UE_id] >=0,"Cannot find UE_id %d is not active\n",UE_id); + AssertFatal(UE_info->active[UE_id],"Cannot find UE_id %d is not active\n",UE_id); NR_CellGroupConfig_t *secondaryCellGroup = UE_info->secondaryCellGroup[UE_id]; int bwp_id=1; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c index 8a32714c8a..78a571ad3e 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c @@ -448,7 +448,7 @@ void nr_add_msg3(module_id_t module_idP, int CC_id, frame_t frameP, sub_frame_t memset(pusch_pdu, 0, sizeof(nfapi_nr_pusch_pdu_t)); - AssertFatal(UE_info->active[UE_id] >=0,"Cannot find UE_id %d is not active\n", UE_id); + AssertFatal(UE_info->active[UE_id],"Cannot find UE_id %d is not active\n", UE_id); NR_CellGroupConfig_t *secondaryCellGroup = UE_info->secondaryCellGroup[UE_id]; AssertFatal(secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count == 1, diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c index fb455131a1..94784755ae 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c @@ -840,7 +840,7 @@ void schedule_fapi_ul_pdu(int Mod_idP, int mu = scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.subcarrierSpacing; int UE_id = 0; NR_UE_info_t *UE_info = &RC.nrmac[Mod_idP]->UE_info; - AssertFatal(UE_info->active[UE_id] >=0,"Cannot find UE_id %d is not active\n",UE_id); + AssertFatal(UE_info->active[UE_id],"Cannot find UE_id %d is not active\n",UE_id); NR_CellGroupConfig_t *secondaryCellGroup = UE_info->secondaryCellGroup[UE_id]; AssertFatal(secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count == 1, diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index f28c61d5a3..095d76e4ff 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -182,7 +182,7 @@ int allocate_nr_CCEs(gNB_MAC_INST *nr_mac, NR_UE_info_t *UE_info = &nr_mac->UE_info; - AssertFatal(UE_info->active[UE_id] >=0,"UE_id %d is not active\n",UE_id); + AssertFatal(UE_info->active[UE_id],"UE_id %d is not active\n",UE_id); int coreset_id = coreset->controlResourceSetId; int *cce_list = nr_mac->cce_list[bwp->bwp_Id][coreset_id]; @@ -1646,7 +1646,7 @@ int add_new_nr_ue(module_id_t mod_idP, rnti_t rntiP){ int UE_id = i; UE_info->num_UEs++; - UE_info->active[UE_id] = TRUE; + UE_info->active[UE_id] = true; UE_info->rnti[UE_id] = rntiP; add_nr_ue_list(&UE_info->list, UE_id); memset((void *) &UE_info->UE_sched_ctrl[UE_id], diff --git a/openair2/LAYER2/NR_MAC_gNB/main.c b/openair2/LAYER2/NR_MAC_gNB/main.c index a06bde869c..7df00f15f1 100644 --- a/openair2/LAYER2/NR_MAC_gNB/main.c +++ b/openair2/LAYER2/NR_MAC_gNB/main.c @@ -109,7 +109,7 @@ void mac_top_init_gNB(void) UE_info->list.head = -1; for (list_el = 0; list_el < MAX_MOBILES_PER_GNB; list_el++) { UE_info->list.next[list_el] = -1; - UE_info->active[list_el] = FALSE; + UE_info->active[list_el] = false; for (int list_harq = 0; list_harq < NR_MAX_NB_HARQ_PROCESSES; list_harq++) { UE_info->UE_sched_ctrl[list_el].harq_processes[list_harq].round = 0; UE_info->UE_sched_ctrl[list_el].harq_processes[list_harq].ndi = 0; diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index ba2ef0e7e3..64117b4d9a 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -359,7 +359,7 @@ typedef struct { NR_mac_stats_t mac_stats[MAX_MOBILES_PER_GNB]; NR_UE_list_t list; int num_UEs; - boolean_t active[MAX_MOBILES_PER_GNB]; + bool active[MAX_MOBILES_PER_GNB]; boolean_t fiveG_connected[MAX_MOBILES_PER_GNB]; rnti_t rnti[MAX_MOBILES_PER_GNB]; rnti_t tc_rnti[MAX_MOBILES_PER_GNB]; From 77e2a5aab85ec491de8b9cd9036fd9d37ef329ca Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 21 Sep 2020 15:56:51 +0200 Subject: [PATCH 73/96] Simplify allocate_rn_CCEs() --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c | 3 +-- .../LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 3 +-- .../LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c | 6 ++--- .../NR_MAC_gNB/gNB_scheduler_primitives.c | 22 ++++++------------- openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 3 +-- 5 files changed, 12 insertions(+), 25 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c index 78a571ad3e..46a30ad0b6 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c @@ -689,8 +689,7 @@ void nr_generate_Msg2(module_id_t module_idP, bwp, coreset, aggregation_level, - ss->searchSpaceType->present - 1, // 0 common, 1 ue-specific - UE_id, + 0, /* n_RNTI 0: common search space */ 0); // m if (CCEIndex < 0) { diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index 6d0e4ad5b1..0fa0121169 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -494,8 +494,7 @@ void nr_simple_dlsch_preprocessor(module_id_t module_id, sched_ctrl->active_bwp, sched_ctrl->coreset, sched_ctrl->aggregation_level, - sched_ctrl->search_space->searchSpaceType->present - 1, - UE_id, + UE_info->rnti[UE_id], 0); // m if (sched_ctrl->cce_index < 0) { LOG_E(MAC, "%s(): could not find CCE for UE %d\n", __func__, UE_id); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c index 94784755ae..c7115dedce 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c @@ -422,8 +422,7 @@ int configure_fapi_dl_pdu_phytest(int Mod_idP, bwp, coreset, aggregation_level, - ss->searchSpaceType->present - 1, // 0 common, 1 ue-specific - UE_id, + UE_info->rnti[UE_id], 0); // m if (CCEIndex < 0) { LOG_E(MAC, "%s(): CCE list not empty, couldn't schedule PDSCH\n", __func__); @@ -1114,8 +1113,7 @@ void schedule_fapi_ul_pdu(int Mod_idP, bwp, coreset, aggregation_level, - ss->searchSpaceType->present - 1, // 0 common, 1 ue-specific - UE_id, + UE_info->rnti[UE_id], 0); // m if (CCEIndex < 0) { LOG_E(MAC, "%s(): CCE list not empty, couldn't schedule PUSCH\n", __func__); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index 095d76e4ff..bdaa402dad 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -173,17 +173,12 @@ int allocate_nr_CCEs(gNB_MAC_INST *nr_mac, NR_BWP_Downlink_t *bwp, NR_ControlResourceSet_t *coreset, int aggregation, - int search_space, // 0 common, 1 ue-specific - int UE_id, + uint16_t n_RNTI, int m) { // uncomment these when we allocate for common search space // NR_COMMON_channels_t *cc = nr_mac->common_channels; // NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon; - NR_UE_info_t *UE_info = &nr_mac->UE_info; - - AssertFatal(UE_info->active[UE_id],"UE_id %d is not active\n",UE_id); - int coreset_id = coreset->controlResourceSetId; int *cce_list = nr_mac->cce_list[bwp->bwp_Id][coreset_id]; @@ -195,17 +190,14 @@ int allocate_nr_CCEs(gNB_MAC_INST *nr_mac, n_rb*=6; uint16_t N_reg = n_rb * coreset->duration; - uint16_t Y=0, N_cce, M_s_max, n_CI=0; - uint16_t n_RNTI = search_space == 1 ? UE_info->rnti[UE_id]:0; - uint32_t A[3]={39827,39829,39839}; + uint16_t n_CI=0; + const uint32_t A[3]={39827,39829,39839}; + /* if n_RNTI is zero, this results in zero, too! */ + uint16_t Y = (A[0]*n_RNTI)%65537; // Candidate 0, antenna port 0 - N_cce = N_reg / NR_NB_REG_PER_CCE; + uint16_t N_cce = N_reg / NR_NB_REG_PER_CCE; - M_s_max = (aggregation==4)?4:(aggregation==8)?2:1; - - if (search_space == 1) { - Y = (A[0]*n_RNTI)%65537; // Candidate 0, antenna port 0 - } + uint16_t M_s_max = (aggregation==4)?4:(aggregation==8)?2:1; int first_cce = aggregation * (( Y + (m*N_cce)/(aggregation*M_s_max) + n_CI ) % CEILIDIV(N_cce,aggregation)); for (int i=0;i Date: Mon, 21 Sep 2020 16:08:24 +0200 Subject: [PATCH 74/96] Remove fiveG_connected and use active --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c | 21 ++++++++++--------- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c | 6 ++---- .../NR_MAC_gNB/gNB_scheduler_primitives.c | 4 ++-- .../LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c | 12 +++++------ openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h | 1 - 5 files changed, 20 insertions(+), 24 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c index 0f39fb9302..eacc8d14b8 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c @@ -411,14 +411,16 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, const int num_slots_per_tdd = slots_per_frame[*scc->ssbSubcarrierSpacing] >> (7 - tdd_pattern->dl_UL_TransmissionPeriodicity); const int nr_ulmix_slots = tdd_pattern->nrofUplinkSlots + (tdd_pattern->nrofUplinkSymbols!=0); - if (slot== 0 && (UE_info->fiveG_connected[UE_id] || get_softmodem_params()->phy_test)) { + if (slot == 0 && UE_info->active[UE_id]) { for (int k=0; kUE_sched_ctrl[UE_id].sched_pucch[k], + /* Seems to be covered 384? */ + /*memset((void *) &UE_info->UE_sched_ctrl[UE_id].sched_pucch[k], 0, - sizeof(NR_sched_pucch)); - memset((void *) &UE_info->UE_sched_ctrl[UE_id].sched_pusch[k], + sizeof(NR_sched_pucch));*/ + /* Seems to be covered in line 335? */ + /*memset((void *) &UE_info->UE_sched_ctrl[UE_id].sched_pusch[k], 0, - sizeof(NR_sched_pusch)); + sizeof(NR_sched_pusch));*/ } } @@ -470,8 +472,7 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, if (get_softmodem_params()->phy_test == 0) { nr_schedule_RA(module_idP, frame, slot); nr_schedule_reception_msg3(module_idP, 0, frame, slot); - } else - UE_info->fiveG_connected[UE_id] = true; + } if (get_softmodem_params()->phy_test) { @@ -493,13 +494,13 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, // This schedules the DCI for Uplink and subsequently PUSCH // The decision about whether to schedule is done for each UE independently // inside - if (UE_info->fiveG_connected[UE_id]) { + if (UE_info->active[UE_id]) { int tda = 1; // time domain assignment hardcoded for now schedule_fapi_ul_pdu(module_idP, frame, slot, num_slots_per_tdd, nr_ulmix_slots, tda, ulsch_in_slot_bitmap); nr_schedule_pusch(module_idP, UE_id, num_slots_per_tdd, nr_ulmix_slots, frame, slot); } - if (UE_info->fiveG_connected[UE_id] + if (UE_info->active[UE_id] && (is_xlsch_in_slot(dlsch_in_slot_bitmap, slot % num_slots_per_tdd)) && (!get_softmodem_params()->phy_test || slot == 1)) { ue_sched_ctl->current_harq_pid = slot % num_slots_per_tdd; @@ -511,7 +512,7 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, gNB->ta_len = 0; } - if (UE_info->fiveG_connected[UE_id]) + if (UE_info->active[UE_id]) nr_schedule_pucch(module_idP, UE_id, nr_ulmix_slots, frame, slot); stop_meas(&RC.nrmac[module_idP]->eNB_scheduler); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c index 46a30ad0b6..5f7ae0c7dd 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c @@ -268,9 +268,7 @@ void nr_initiate_ra_proc(module_id_t module_idP, break; } } - if (pr_found) - UE_info->fiveG_connected[UE_id] = false; - else { + if (!pr_found) { LOG_E(MAC, "[gNB %d][RAPROC] FAILURE: preamble %d does not correspond to any of the ones in rach_ConfigDedicated for UE_id %d\n", module_idP, preamble_index, UE_id); return; // if the PRACH preamble does not correspond to any of the ones sent through RRC abort RA proc @@ -448,7 +446,7 @@ void nr_add_msg3(module_id_t module_idP, int CC_id, frame_t frameP, sub_frame_t memset(pusch_pdu, 0, sizeof(nfapi_nr_pusch_pdu_t)); - AssertFatal(UE_info->active[UE_id],"Cannot find UE_id %d is not active\n", UE_id); + AssertFatal(!UE_info->active[UE_id], "UE_id %d is already active\n", UE_id); NR_CellGroupConfig_t *secondaryCellGroup = UE_info->secondaryCellGroup[UE_id]; AssertFatal(secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count == 1, diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index bdaa402dad..d325bf0c07 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -1626,7 +1626,7 @@ int add_new_nr_ue(module_id_t mod_idP, rnti_t rntiP){ int num_slots_ul = scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSlots; if (scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSymbols>0) num_slots_ul++; - LOG_I(MAC, "[gNB %d] Adding UE with rnti %x (num_UEs %d)\n", + LOG_W(MAC, "[gNB %d] Adding UE with rnti %x (num_UEs %d)\n", mod_idP, rntiP, UE_info->num_UEs); @@ -1638,7 +1638,7 @@ int add_new_nr_ue(module_id_t mod_idP, rnti_t rntiP){ int UE_id = i; UE_info->num_UEs++; - UE_info->active[UE_id] = true; + UE_info->active[UE_id] = false; /* not yet active, we wait for RA! */ UE_info->rnti[UE_id] = rntiP; add_nr_ue_list(&UE_info->list, UE_id); memset((void *) &UE_info->UE_sched_ctrl[UE_id], diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c index b68c452f16..0e977c5352 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c @@ -369,13 +369,11 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP, // random access pusch with TC-RNTI if (sduP != NULL) { // if the CRC passed for (int i = 0; i < MAX_MOBILES_PER_GNB; i++) { - if (UE_info->active[i]) { - if (UE_info->tc_rnti[i] == current_rnti) { - // for now the only thing we are doing is set the UE as 5G connected - UE_info->fiveG_connected[i] = true; - LOG_I(MAC, "[gNB %d][RAPROC] PUSCH with TC_RNTI %x received correctly and UE_id %d is now 5G connected\n", - gnb_mod_idP, current_rnti, i); - } + if (UE_info->tc_rnti[i] == current_rnti) { + // for now the only thing we are doing is set the UE as active + UE_info->active[i] = true; + LOG_W(MAC, "[gNB %d][RAPROC] PUSCH with TC_RNTI %x received correctly and UE_id %d is now 5G connected\n", + gnb_mod_idP, current_rnti, i); } } } diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index 64117b4d9a..4c1c440617 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -360,7 +360,6 @@ typedef struct { NR_UE_list_t list; int num_UEs; bool active[MAX_MOBILES_PER_GNB]; - boolean_t fiveG_connected[MAX_MOBILES_PER_GNB]; rnti_t rnti[MAX_MOBILES_PER_GNB]; rnti_t tc_rnti[MAX_MOBILES_PER_GNB]; NR_preamble_ue preambles[MAX_MOBILES_PER_GNB]; From f13c97db02f34a580f5f834bb5eacad9cebf5557 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 21 Sep 2020 16:59:52 +0200 Subject: [PATCH 75/96] Mark active in add_new_nr_ue() only if phytest --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index d325bf0c07..d19dc7b056 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -63,6 +63,8 @@ #define ENABLE_MAC_PAYLOAD_DEBUG #define DEBUG_gNB_SCHEDULER 1 +/*Softmodem params*/ +#include "executables/softmodem-common.h" #include "common/ran_context.h" @@ -1638,7 +1640,12 @@ int add_new_nr_ue(module_id_t mod_idP, rnti_t rntiP){ int UE_id = i; UE_info->num_UEs++; - UE_info->active[UE_id] = false; /* not yet active, we wait for RA! */ + /* if real softmodem: not yet active, we wait for RA! FIXME: This opens a + * data race: a UE should complete RA before adding the next, or by the + * above condition, we overwrite the current UE with the following one. + * + * if phytest: there is no RA, so enable directly */ + UE_info->active[UE_id] = get_softmodem_params()->phy_test; UE_info->rnti[UE_id] = rntiP; add_nr_ue_list(&UE_info->list, UE_id); memset((void *) &UE_info->UE_sched_ctrl[UE_id], From fdb4c69221d411cfca351a370cf2d3d069310a2b Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 22 Sep 2020 10:53:16 +0200 Subject: [PATCH 76/96] Preprocessor: check for number of UEs --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index 0fa0121169..757395ce70 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -451,6 +451,13 @@ void nr_simple_dlsch_preprocessor(module_id_t module_id, int num_slots_per_tdd) { NR_UE_info_t *UE_info = &RC.nrmac[module_id]->UE_info; + AssertFatal(UE_info->num_UEs <= 1, + "%s() cannot handle more than one UE, but found %d\n", + __func__, + UE_info->num_UEs); + if (UE_info->num_UEs == 0) + return; + const int UE_id = 0; const int CC_id = 0; From ce2dd17ed56a7626d2d608c4d06d623daaa60b2e Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 22 Sep 2020 10:57:25 +0200 Subject: [PATCH 77/96] Post-processor: enable multi-UE handling --- .../LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 332 +++++++++--------- 1 file changed, 166 insertions(+), 166 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index 757395ce70..c666cc66da 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -548,193 +548,193 @@ void nr_schedule_ue_spec(module_id_t module_id, frame_t frame, sub_frame_t slot, int num_slots_per_tdd) { - gNB_MAC_INST *gNB_mac = RC.nrmac[module_id]; - NR_UE_info_t *UE_info = &gNB_mac->UE_info; - if (UE_info->num_UEs == 0) - return; - /* PREPROCESSOR */ nr_simple_dlsch_preprocessor(module_id, frame, slot, num_slots_per_tdd); + gNB_MAC_INST *gNB_mac = RC.nrmac[module_id]; + NR_UE_info_t *UE_info = &gNB_mac->UE_info; + const int ta_len = gNB_mac->ta_len; - const int UE_id = 0; const int CC_id = 0; - NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; - if (sched_ctrl->rbSize < 0 && !get_softmodem_params()->phy_test) - return; + NR_UE_list_t *UE_list = &UE_info->list; + for (int UE_id = UE_list->head; UE_id >= 0; UE_id = UE_list->next[UE_id]) { + NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; + if (sched_ctrl->rbSize <= 0 && !get_softmodem_params()->phy_test) + continue; - /* POST processing */ - struct NR_PDSCH_TimeDomainResourceAllocationList *tdaList = - sched_ctrl->active_bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; - AssertFatal(sched_ctrl->time_domain_allocation < tdaList->list.count, - "time_domain_allocation %d>=%d\n", - sched_ctrl->time_domain_allocation, - tdaList->list.count); + /* POST processing */ + struct NR_PDSCH_TimeDomainResourceAllocationList *tdaList = + sched_ctrl->active_bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; + AssertFatal(sched_ctrl->time_domain_allocation < tdaList->list.count, + "time_domain_allocation %d>=%d\n", + sched_ctrl->time_domain_allocation, + tdaList->list.count); - const int startSymbolAndLength = - tdaList->list.array[sched_ctrl->time_domain_allocation]->startSymbolAndLength; - int startSymbolIndex, nrOfSymbols; - SLIV2SL(startSymbolAndLength, &startSymbolIndex, &nrOfSymbols); + const int startSymbolAndLength = + tdaList->list.array[sched_ctrl->time_domain_allocation]->startSymbolAndLength; + int startSymbolIndex, nrOfSymbols; + SLIV2SL(startSymbolAndLength, &startSymbolIndex, &nrOfSymbols); - uint8_t N_PRB_DMRS = - getN_PRB_DMRS(sched_ctrl->active_bwp, sched_ctrl->numDmrsCdmGrpsNoData); - const uint32_t TBS = - nr_compute_tbs(nr_get_Qm_dl(sched_ctrl->mcs, sched_ctrl->mcsTableIdx), - nr_get_code_rate_dl(sched_ctrl->mcs, sched_ctrl->mcsTableIdx), - sched_ctrl->rbSize, - nrOfSymbols, - N_PRB_DMRS, // FIXME // This should be multiplied by the - // number of dmrs symbols - 0 /* N_PRB_oh, 0 for initialBWP */, - 0 /* tb_scaling */, - 1 /* nrOfLayers */) - >> 3; + uint8_t N_PRB_DMRS = + getN_PRB_DMRS(sched_ctrl->active_bwp, sched_ctrl->numDmrsCdmGrpsNoData); + const uint32_t TBS = + nr_compute_tbs(nr_get_Qm_dl(sched_ctrl->mcs, sched_ctrl->mcsTableIdx), + nr_get_code_rate_dl(sched_ctrl->mcs, sched_ctrl->mcsTableIdx), + sched_ctrl->rbSize, + nrOfSymbols, + N_PRB_DMRS, // FIXME // This should be multiplied by the + // number of dmrs symbols + 0 /* N_PRB_oh, 0 for initialBWP */, + 0 /* tb_scaling */, + 1 /* nrOfLayers */) + >> 3; - /* Get RLC data TODO: remove random data retrieval */ - int header_length_total = 0; - int header_length_last = 0; - int sdu_length_total = 0; - int num_sdus = 0; - uint16_t sdu_lengths[NB_RB_MAX] = {0}; - uint8_t mac_sdus[MAX_NR_DLSCH_PAYLOAD_BYTES]; - unsigned char sdu_lcids[NB_RB_MAX] = {0}; - const rnti_t rnti = UE_info->rnti[UE_id]; - const int lcid = DL_SCH_LCID_DTCH; - if (sched_ctrl->num_total_bytes > 0) { - LOG_D(MAC, - "[gNB %d][USER-PLANE DEFAULT DRB] Frame %d : DTCH->DLSCH, Requesting " - "%d bytes from RLC (lcid %d total hdr len %d), TBS: %d \n \n", + /* Get RLC data TODO: remove random data retrieval */ + int header_length_total = 0; + int header_length_last = 0; + int sdu_length_total = 0; + int num_sdus = 0; + uint16_t sdu_lengths[NB_RB_MAX] = {0}; + uint8_t mac_sdus[MAX_NR_DLSCH_PAYLOAD_BYTES]; + unsigned char sdu_lcids[NB_RB_MAX] = {0}; + const rnti_t rnti = UE_info->rnti[UE_id]; + const int lcid = DL_SCH_LCID_DTCH; + if (sched_ctrl->num_total_bytes > 0) { + LOG_D(MAC, + "[gNB %d][USER-PLANE DEFAULT DRB] Frame %d : DTCH->DLSCH, Requesting " + "%d bytes from RLC (lcid %d total hdr len %d), TBS: %d \n \n", + module_id, + frame, + TBS - ta_len - header_length_total - sdu_length_total - 3, + lcid, + header_length_total, + TBS); + + sdu_lengths[num_sdus] = mac_rlc_data_req(module_id, + rnti, module_id, frame, - TBS - ta_len - header_length_total - sdu_length_total - 3, + ENB_FLAG_YES, + MBMS_FLAG_NO, lcid, - header_length_total, - TBS); + TBS - ta_len - header_length_total - sdu_length_total - 3, + (char *)&mac_sdus[sdu_length_total], + 0, + 0); - sdu_lengths[num_sdus] = mac_rlc_data_req(module_id, - rnti, + LOG_D(MAC, + "[gNB %d][USER-PLANE DEFAULT DRB] Got %d bytes for DTCH %d \n", + module_id, + sdu_lengths[num_sdus], + lcid); + + sdu_lcids[num_sdus] = lcid; + sdu_length_total += sdu_lengths[num_sdus]; + header_length_last = 1 + 1 + (sdu_lengths[num_sdus] >= 128); + header_length_total += header_length_last; + + num_sdus++; + + //ue_sched_ctl->uplane_inactivity_timer = 0; + } + else if (get_softmodem_params()->phy_test) { + LOG_D(MAC, "Configuring DL_TX in %d.%d: random data\n", frame, slot); + // fill dlsch_buffer with random data + for (int i = 0; i < TBS; i++) + mac_sdus[i] = (unsigned char) (lrand48()&0xff); + sdu_lcids[0] = 0x3f; // DRB + sdu_lengths[0] = TBS - ta_len - 3; + header_length_total += 2 + (sdu_lengths[0] >= 128); + sdu_length_total += sdu_lengths[0]; + num_sdus +=1; + } + + // there is at least one SDU or TA command + // if (num_sdus > 0 ){ + if (ta_len + sdu_length_total + header_length_total == 0) { + // There is no data from RLC or MAC header, so don't schedule + return; + } + + // Check if there is data from RLC or CE + const int post_padding = TBS >= 2 + header_length_total + sdu_length_total + ta_len; + // padding param currently not in use + //padding = TBS - header_length_total - sdu_length_total - ta_len - 1; + + const int offset = nr_generate_dlsch_pdu( module_id, - frame, - ENB_FLAG_YES, - MBMS_FLAG_NO, - lcid, - TBS - ta_len - header_length_total - sdu_length_total - 3, - (char *)&mac_sdus[sdu_length_total], - 0, - 0); + (unsigned char *)mac_sdus, + (unsigned char *)gNB_mac->UE_info.DLSCH_pdu[0][0].payload[0], + num_sdus, // num_sdus + sdu_lengths, + sdu_lcids, + 255, // no drx + NULL, // contention res id + post_padding); - LOG_D(MAC, - "[gNB %d][USER-PLANE DEFAULT DRB] Got %d bytes for DTCH %d \n", - module_id, - sdu_lengths[num_sdus], - lcid); + // Padding: fill remainder of DLSCH with 0 + if (post_padding > 0) { + for (int j = 0; j < TBS - offset; j++) + gNB_mac->UE_info.DLSCH_pdu[0][0].payload[0][offset + j] = 0; + } - sdu_lcids[num_sdus] = lcid; - sdu_length_total += sdu_lengths[num_sdus]; - header_length_last = 1 + 1 + (sdu_lengths[num_sdus] >= 128); - header_length_total += header_length_last; + const int current_harq_pid = sched_ctrl->current_harq_pid; + NR_UE_harq_t *harq = &sched_ctrl->harq_processes[current_harq_pid]; + NR_sched_pucch *pucch = &sched_ctrl->sched_pucch[sched_ctrl->pucch_sched_idx]; + harq->feedback_slot = pucch->ul_slot; + harq->is_waiting = 1; + UE_info->mac_stats[UE_id].dlsch_rounds[harq->round]++; + if (harq->round == 0) + UE_info->mac_stats[UE_id].dlsch_total_bytes += TBS; - num_sdus++; + nfapi_nr_dl_tti_request_body_t *dl_req = &gNB_mac->DL_req[CC_id].dl_tti_request_body; + nr_fill_nfapi_dl_pdu(module_id, + UE_id, + sched_ctrl->active_bwp->bwp_Id, + sched_ctrl->search_space, + sched_ctrl->coreset, + dl_req, + pucch, + 1 /* nrOfLayers */, + sched_ctrl->mcs, + sched_ctrl->rbSize, + sched_ctrl->rbStart, + sched_ctrl->numDmrsCdmGrpsNoData, + getDmrsConfigType(sched_ctrl->active_bwp), + sched_ctrl->mcsTableIdx, + nr_get_code_rate_dl(sched_ctrl->mcs, sched_ctrl->mcsTableIdx), + nr_get_Qm_dl(sched_ctrl->mcs, sched_ctrl->mcsTableIdx), + TBS, + sched_ctrl->time_domain_allocation, + startSymbolIndex, + nrOfSymbols, + sched_ctrl->aggregation_level, + sched_ctrl->cce_index, + current_harq_pid, + harq->ndi, + harq->round); - //ue_sched_ctl->uplane_inactivity_timer = 0; - } - else if (get_softmodem_params()->phy_test) { - LOG_D(MAC, "Configuring DL_TX in %d.%d: random data\n", frame, slot); - // fill dlsch_buffer with random data - for (int i = 0; i < TBS; i++) - mac_sdus[i] = (unsigned char) (lrand48()&0xff); - sdu_lcids[0] = 0x3f; // DRB - sdu_lengths[0] = TBS - ta_len - 3; - header_length_total += 2 + (sdu_lengths[0] >= 128); - sdu_length_total += sdu_lengths[0]; - num_sdus +=1; - } - - // there is at least one SDU or TA command - // if (num_sdus > 0 ){ - if (ta_len + sdu_length_total + header_length_total == 0) { - // There is no data from RLC or MAC header, so don't schedule - return; - } - - // Check if there is data from RLC or CE - const int post_padding = TBS >= 2 + header_length_total + sdu_length_total + ta_len; - // padding param currently not in use - //padding = TBS - header_length_total - sdu_length_total - ta_len - 1; - - const int offset = nr_generate_dlsch_pdu( - module_id, - (unsigned char *)mac_sdus, - (unsigned char *)gNB_mac->UE_info.DLSCH_pdu[0][0].payload[0], - num_sdus, // num_sdus - sdu_lengths, - sdu_lcids, - 255, // no drx - NULL, // contention res id - post_padding); - - // Padding: fill remainder of DLSCH with 0 - if (post_padding > 0) { - for (int j = 0; j < TBS - offset; j++) - gNB_mac->UE_info.DLSCH_pdu[0][0].payload[0][offset + j] = 0; - } - - const int current_harq_pid = sched_ctrl->current_harq_pid; - NR_UE_harq_t *harq = &sched_ctrl->harq_processes[current_harq_pid]; - NR_sched_pucch *pucch = &sched_ctrl->sched_pucch[sched_ctrl->pucch_sched_idx]; - harq->feedback_slot = pucch->ul_slot; - harq->is_waiting = 1; - UE_info->mac_stats[UE_id].dlsch_rounds[harq->round]++; - if (harq->round == 0) - UE_info->mac_stats[UE_id].dlsch_total_bytes += TBS; - - nfapi_nr_dl_tti_request_body_t *dl_req = &gNB_mac->DL_req[CC_id].dl_tti_request_body; - nr_fill_nfapi_dl_pdu(module_id, - UE_id, - sched_ctrl->active_bwp->bwp_Id, - sched_ctrl->search_space, - sched_ctrl->coreset, - dl_req, - pucch, - 1 /* nrOfLayers */, - sched_ctrl->mcs, - sched_ctrl->rbSize, - sched_ctrl->rbStart, - sched_ctrl->numDmrsCdmGrpsNoData, - getDmrsConfigType(sched_ctrl->active_bwp), - sched_ctrl->mcsTableIdx, - nr_get_code_rate_dl(sched_ctrl->mcs, sched_ctrl->mcsTableIdx), - nr_get_Qm_dl(sched_ctrl->mcs, sched_ctrl->mcsTableIdx), - TBS, - sched_ctrl->time_domain_allocation, - startSymbolIndex, - nrOfSymbols, - sched_ctrl->aggregation_level, - sched_ctrl->cce_index, - current_harq_pid, - harq->ndi, - harq->round); - - nfapi_nr_pdu_t *tx_req = &gNB_mac->TX_req[CC_id].pdu_list[gNB_mac->TX_req[CC_id].Number_of_PDUs]; - configure_fapi_dl_Tx(module_id, - frame, - slot, - dl_req, - tx_req, - TBS, - gNB_mac->pdu_index[CC_id]); + nfapi_nr_pdu_t *tx_req = &gNB_mac->TX_req[CC_id].pdu_list[gNB_mac->TX_req[CC_id].Number_of_PDUs]; + configure_fapi_dl_Tx(module_id, + frame, + slot, + dl_req, + tx_req, + TBS, + gNB_mac->pdu_index[CC_id]); #if defined(ENABLE_MAC_PAYLOAD_DEBUG) - if (frame%100 == 0){ - LOG_I(MAC, - "%d.%d, first 10 payload bytes, TBS size: %d \n", - frame, - slot, - TBS); - for(int i = 0; i < 10; i++) { - LOG_I(MAC, "byte %d : %x\n", i,((uint8_t *)gNB_mac->UE_info.DLSCH_pdu[0][0].payload[0])[i]); + if (frame%100 == 0){ + LOG_I(MAC, + "%d.%d, first 10 payload bytes, TBS size: %d \n", + frame, + slot, + TBS); + for(int i = 0; i < 10; i++) { + LOG_I(MAC, "byte %d : %x\n", i,((uint8_t *)gNB_mac->UE_info.DLSCH_pdu[0][0].payload[0])[i]); + } } - } #endif + } } From b9eb6c98438e5d79230f00d84262fc788dfe9827 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 22 Sep 2020 11:12:13 +0200 Subject: [PATCH 78/96] Use vrb_map in in DL for NSA mode --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c | 4 ++-- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c | 6 +++++- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c | 5 +++++ openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 14 ++++++++++++-- openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h | 4 ++-- 5 files changed, 26 insertions(+), 7 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c index eacc8d14b8..b7c6a6a561 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c @@ -444,8 +444,8 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, //mbsfn_status[CC_id] = 0; // clear vrb_maps - memset(cc[CC_id].vrb_map, 0, 100); - memset(cc[CC_id].vrb_map_UL, 0, 100); + memset(cc[CC_id].vrb_map, 0, 275); + memset(cc[CC_id].vrb_map_UL, 0, 275); clear_nr_nfapi_information(RC.nrmac[module_idP], CC_id, frame, slot); } diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c index 5f7ae0c7dd..b073029da0 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c @@ -550,7 +550,6 @@ void nr_generate_Msg2(module_id_t module_idP, uint16_t RA_rnti = ra->RA_rnti; long locationAndBandwidth; - // uint8_t *vrb_map = cc[CC_id].vrb_map, CC_id; // check if UE is doing RA on CORESET0 , InitialBWP or configured BWP from SCD // get the BW of the PDCCH for PDCCH size and RAR PDSCH size @@ -740,6 +739,11 @@ void nr_generate_Msg2(module_id_t module_idP, nr_mac->TX_req[CC_id].Number_of_PDUs++; nr_mac->TX_req[CC_id].Slot = slotP; memcpy((void*)&tx_req->TLVs[0].value.direct[0], (void*)&cc[CC_id].RAR_pdu.payload[0], tx_req->TLVs[0].length); + + /* mark the corresponding RBs as used */ + uint8_t *vrb_map = cc[CC_id].vrb_map; + for (int rb = 0; rb < pdsch_pdu_rel15->rbSize; rb++) + vrb_map[rb + pdsch_pdu_rel15->rbStart] = 1; } } diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c index 0e8fb0aca2..989d6fb952 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c @@ -137,6 +137,11 @@ void schedule_nr_mib(module_id_t module_idP, frame_t frameP, sub_frame_t slotP){ dl_config_pdu->ssb_pdu.ssb_pdu_rel15.bchPayloadFlag = 1; dl_config_pdu->ssb_pdu.ssb_pdu_rel15.bchPayload = (*(uint32_t*)cc->MIB_pdu.payload) & ((1<<24)-1); dl_req->nPDUs++; + + uint8_t *vrb_map = cc[CC_id].vrb_map; + const int rbStart = dl_config_pdu->ssb_pdu.ssb_pdu_rel15.ssbOffsetPointA; + for (int rb = 0; rb < 20; rb++) + vrb_map[rbStart + rb] = 1; } } } diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index c666cc66da..61015c27eb 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -517,9 +517,19 @@ void nr_simple_dlsch_preprocessor(module_id_t module_id, sched_ctrl->time_domain_allocation = 2; // Freq-demain allocation + uint8_t *vrb_map = RC.nrmac[module_id]->common_channels[CC_id].vrb_map; const uint16_t bwpSize = NRRIV2BW(sched_ctrl->active_bwp->bwp_Common->genericParameters.locationAndBandwidth, 275); - sched_ctrl->rbSize = bwpSize; - sched_ctrl->rbStart = 0; + int rbStart = NRRIV2PRBOFFSET(sched_ctrl->active_bwp->bwp_Common->genericParameters.locationAndBandwidth, 275); + while (rbStart < bwpSize && vrb_map[rbStart]) rbStart++; + int rbSize = 1; + while (rbStart + rbSize < bwpSize && !vrb_map[rbStart + rbSize]) rbSize++; + DevAssert(rbSize >= 3); /* just ensure we have at least 3 RBs */ + sched_ctrl->rbSize = rbSize; + sched_ctrl->rbStart = rbStart; + + /* mark the corresponding RBs as used */ + for (int rb = 0; rb < sched_ctrl->rbSize; rb++) + vrb_map[rb + sched_ctrl->rbStart] = 1; // modulation scheme sched_ctrl->mcsTableIdx = 0; diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index 4c1c440617..2bedb0750f 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -172,9 +172,9 @@ typedef struct { /// Template for RA computations NR_RA_t ra[NR_NB_RA_PROC_MAX]; /// VRB map for common channels - uint8_t vrb_map[100]; + uint8_t vrb_map[275]; /// VRB map for common channels and retransmissions by PHICH - uint8_t vrb_map_UL[100]; + uint8_t vrb_map_UL[275]; /// number of subframe allocation pattern available for MBSFN sync area uint8_t num_sf_allocation_pattern; } NR_COMMON_channels_t; From a2b1fa5d57567add7c9e4b2503086728bd594e26 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Fri, 25 Sep 2020 15:12:50 +0200 Subject: [PATCH 79/96] fixup: throughput correct only if first TDD slot --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c index b7c6a6a561..5a330daf14 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c @@ -494,7 +494,7 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, // This schedules the DCI for Uplink and subsequently PUSCH // The decision about whether to schedule is done for each UE independently // inside - if (UE_info->active[UE_id]) { + if (UE_info->active[UE_id] && slot < 10) { int tda = 1; // time domain assignment hardcoded for now schedule_fapi_ul_pdu(module_idP, frame, slot, num_slots_per_tdd, nr_ulmix_slots, tda, ulsch_in_slot_bitmap); nr_schedule_pusch(module_idP, UE_id, num_slots_per_tdd, nr_ulmix_slots, frame, slot); @@ -502,7 +502,8 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, if (UE_info->active[UE_id] && (is_xlsch_in_slot(dlsch_in_slot_bitmap, slot % num_slots_per_tdd)) - && (!get_softmodem_params()->phy_test || slot == 1)) { + && (!get_softmodem_params()->phy_test || slot == 1) + && slot < 10) { ue_sched_ctl->current_harq_pid = slot % num_slots_per_tdd; //int pucch_sched; //nr_update_pucch_scheduling(module_idP, UE_id, frame, slot, num_slots_per_tdd,&pucch_sched); From b4d8e41a00de3ed8271874464aa47f98f7d7845b Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 28 Sep 2020 10:28:41 +0200 Subject: [PATCH 80/96] Create UE MAC Context after successful RA --- openair2/LAYER2/NR_MAC_gNB/config.c | 32 +++++++----- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c | 49 ++++++++----------- .../NR_MAC_gNB/gNB_scheduler_primitives.c | 10 +--- .../LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c | 46 +++++++++++++---- openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h | 18 ++++--- 5 files changed, 89 insertions(+), 66 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/config.c b/openair2/LAYER2/NR_MAC_gNB/config.c index 4f897322a3..ad8409de69 100644 --- a/openair2/LAYER2/NR_MAC_gNB/config.c +++ b/openair2/LAYER2/NR_MAC_gNB/config.c @@ -46,6 +46,9 @@ #include "NR_MIB.h" #include "LAYER2/NR_MAC_COMMON/nr_mac_common.h" +/* Softmodem params */ +#include "executables/softmodem-common.h" + extern RAN_CONTEXT_t RC; //extern int l2_init_gNB(void); extern void mac_top_init_gNB(void); @@ -347,9 +350,8 @@ int rrc_mac_config_req_gNB(module_id_t Mod_idP, if (secondaryCellGroup) { NR_UE_info_t *UE_info = &RC.nrmac[Mod_idP]->UE_info; - int UE_id; - if (add_ue == 1) { - UE_id = add_new_nr_ue(Mod_idP,rnti); + if (add_ue == 1 && get_softmodem_params()->phy_test) { + const int UE_id = add_new_nr_ue(Mod_idP,rnti); UE_info->secondaryCellGroup[UE_id] = secondaryCellGroup; struct NR_ServingCellConfig__downlinkBWP_ToAddModList *bwpList = secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList; @@ -358,16 +360,22 @@ int rrc_mac_config_req_gNB(module_id_t Mod_idP, bwpList->list.count); const int bwp_id = 1; UE_info->UE_sched_ctrl[UE_id].active_bwp = bwpList->list.array[bwp_id - 1]; - uint8_t num_preamble = secondaryCellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink->cfra->resources.choice.ssb->ssb_ResourceList.list.count; - UE_info->preambles[UE_id].num_preambles = num_preamble; - UE_info->preambles[UE_id].preamble_list = (uint8_t *) malloc(num_preamble*sizeof(uint8_t)); - for (int i=0; ipreambles[UE_id].preamble_list[i] = secondaryCellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink->cfra->resources.choice.ssb->ssb_ResourceList.list.array[i]->ra_PreambleIndex; - } LOG_I(PHY,"Added new UE_id %d/%x with initial secondaryCellGroup\n",UE_id,rnti); - } - else { // secondaryCellGroup has been updated - UE_id = find_nr_UE_id(Mod_idP,rnti); + } else if (add_ue == 1 && !get_softmodem_params()->phy_test) { + /* TODO: should check for free RA process */ + const int CC_id = 0; + NR_RA_t *ra = &RC.nrmac[Mod_idP]->common_channels[CC_id].ra[0]; + ra->state = RA_IDLE; + ra->secondaryCellGroup = secondaryCellGroup; + ra->crnti = rnti; + uint8_t num_preamble = secondaryCellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink->cfra->resources.choice.ssb->ssb_ResourceList.list.count; + ra->preambles.num_preambles = num_preamble; + ra->preambles.preamble_list = (uint8_t *) malloc(num_preamble*sizeof(uint8_t)); + for (int i = 0; i < num_preamble; i++) + ra->preambles.preamble_list[i] = secondaryCellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink->cfra->resources.choice.ssb->ssb_ResourceList.list.array[i]->ra_PreambleIndex; + LOG_I(PHY,"Added new RA process for UE RNTI %04x with initial secondaryCellGroup\n", rnti); + } else { // secondaryCellGroup has been updated + const int UE_id = find_nr_UE_id(Mod_idP,rnti); UE_info->secondaryCellGroup[UE_id] = secondaryCellGroup; LOG_I(PHY,"Modified UE_id %d/%x with secondaryCellGroup\n",UE_id,rnti); } diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c index b073029da0..413727b9cb 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c @@ -247,14 +247,11 @@ void nr_initiate_ra_proc(module_id_t module_idP, uint8_t ul_carrier_id = 0; // 0 for NUL 1 for SUL NR_SearchSpace_t *ss; - int UE_id = 0; // ra_rnti from 5.1.3 in 38.321 uint16_t ra_rnti=1+symbol+(slotP*14)+(freq_index*14*80)+(ul_carrier_id*14*80*8); uint16_t msg2_frame, msg2_slot,monitoring_slot_period,monitoring_offset; gNB_MAC_INST *nr_mac = RC.nrmac[module_idP]; - NR_UE_info_t *UE_info = &nr_mac->UE_info; - NR_CellGroupConfig_t *secondaryCellGroup = UE_info->secondaryCellGroup[UE_id]; NR_COMMON_channels_t *cc = &nr_mac->common_channels[CC_id]; NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon; NR_RA_t *ra = &cc->ra[0]; @@ -262,21 +259,21 @@ void nr_initiate_ra_proc(module_id_t module_idP, // if the preamble received correspond to one of the listed // the UE sent a RACH either for starting RA procedure or RA procedure failed and UE retries int pr_found=0; - for (int i=0;ipreambles[UE_id].num_preambles;i++) { - if (preamble_index == UE_info->preambles[UE_id].preamble_list[i]) { + for (int i = 0; i < ra->preambles.num_preambles; i++) { + if (preamble_index == ra->preambles.preamble_list[i]) { pr_found=1; break; } } if (!pr_found) { - LOG_E(MAC, "[gNB %d][RAPROC] FAILURE: preamble %d does not correspond to any of the ones in rach_ConfigDedicated for UE_id %d\n", - module_idP, preamble_index, UE_id); + LOG_E(MAC, "[gNB %d][RAPROC] FAILURE: preamble %d does not correspond to any of the ones in rach_ConfigDedicated\n", + module_idP, preamble_index); return; // if the PRACH preamble does not correspond to any of the ones sent through RRC abort RA proc } // This should be handled differently when we use the initialBWP for RA ra->bwp_id=1; - NR_BWP_Downlink_t *bwp=secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[ra->bwp_id-1]; + NR_BWP_Downlink_t *bwp=ra->secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[ra->bwp_id-1]; VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_INITIATE_RA_PROC, 1); @@ -323,7 +320,6 @@ void nr_initiate_ra_proc(module_id_t module_idP, ra->RA_rnti = ra_rnti; ra->preamble_index = preamble_index; - UE_info->tc_rnti[UE_id] = ra->rnti; LOG_I(MAC,"[gNB %d][RAPROC] CC_id %d Frame %d Activating Msg2 generation in frame %d, slot %d using RA rnti %x\n", module_idP, @@ -421,7 +417,6 @@ void nr_schedule_reception_msg3(module_id_t module_idP, int CC_id, frame_t frame ul_req->pdus_list[ul_req->n_pdus].pdu_size = sizeof(nfapi_nr_pusch_pdu_t); ul_req->pdus_list[ul_req->n_pdus].pusch_pdu = ra->pusch_pdu; ul_req->n_pdus+=1; - ra->state = RA_IDLE; } } } @@ -432,8 +427,6 @@ void nr_add_msg3(module_id_t module_idP, int CC_id, frame_t frameP, sub_frame_t NR_COMMON_channels_t *cc = &mac->common_channels[CC_id]; NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon; NR_RA_t *ra = &cc->ra[0]; - NR_UE_info_t *UE_info = &mac->UE_info; - int UE_id = 0; if (ra->state == RA_IDLE) { LOG_W(MAC,"RA is not active for RA %X. skipping msg3 scheduling\n", ra->rnti); @@ -445,13 +438,12 @@ void nr_add_msg3(module_id_t module_idP, int CC_id, frame_t frameP, sub_frame_t nfapi_nr_pusch_pdu_t *pusch_pdu = &ra->pusch_pdu; memset(pusch_pdu, 0, sizeof(nfapi_nr_pusch_pdu_t)); - - AssertFatal(!UE_info->active[UE_id], "UE_id %d is already active\n", UE_id); - - NR_CellGroupConfig_t *secondaryCellGroup = UE_info->secondaryCellGroup[UE_id]; - AssertFatal(secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count == 1, - "downlinkBWP_ToAddModList has %d BWP!\n", secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count); - NR_BWP_Uplink_t *ubwp=secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[ra->bwp_id-1]; + AssertFatal(ra->secondaryCellGroup, + "no secondaryCellGroup for RNTI %04x\n", + ra->crnti); + AssertFatal(ra->secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count == 1, + "downlinkBWP_ToAddModList has %d BWP!\n", ra->secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count); + NR_BWP_Uplink_t *ubwp = ra->secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[ra->bwp_id - 1]; LOG_D(MAC, "Frame %d, Subframe %d Adding Msg3 UL Config Request for (%d,%d) : (%d,%d,%d) for rnti: %d\n", frameP, slotP, @@ -540,12 +532,11 @@ void nr_generate_Msg2(module_id_t module_idP, frame_t frameP, sub_frame_t slotP){ - int UE_id = 0, dci_formats[2], rnti_types[2], mcsIndex; + int dci_formats[2], rnti_types[2], mcsIndex; int startSymbolAndLength = 0, StartSymbolIndex = -1, NrOfSymbols = 14, StartSymbolIndex_tmp, NrOfSymbols_tmp, x_Overhead, time_domain_assignment = 0; gNB_MAC_INST *nr_mac = RC.nrmac[module_idP]; NR_COMMON_channels_t *cc = &nr_mac->common_channels[0]; NR_RA_t *ra = &cc->ra[0]; - NR_UE_info_t *UE_info = &nr_mac->UE_info; NR_SearchSpace_t *ss = ra->ra_ss; uint16_t RA_rnti = ra->RA_rnti; @@ -594,11 +585,13 @@ void nr_generate_Msg2(module_id_t module_idP, // This code from this point on will not work on initialBWP or CORESET0 AssertFatal(ra->bwp_id>0,"cannot work on initialBWP for now\n"); - NR_CellGroupConfig_t *secondaryCellGroup = UE_info->secondaryCellGroup[UE_id]; - AssertFatal(secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count == 1, - "downlinkBWP_ToAddModList has %d BWP!\n", secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count); - NR_BWP_Downlink_t *bwp = secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[ra->bwp_id - 1]; - NR_BWP_Uplink_t *ubwp=secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[ra->bwp_id-1]; + AssertFatal(ra->secondaryCellGroup, + "no secondaryCellGroup for RNTI %04x\n", + ra->crnti); + AssertFatal(ra->secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count == 1, + "downlinkBWP_ToAddModList has %d BWP!\n", ra->secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count); + NR_BWP_Downlink_t *bwp = ra->secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[ra->bwp_id - 1]; + NR_BWP_Uplink_t *ubwp=ra->secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[ra->bwp_id-1]; LOG_D(MAC, "[RAPROC] Scheduling common search space DCI type 1 dlBWP BW %d\n", dci10_bw); @@ -690,7 +683,7 @@ void nr_generate_Msg2(module_id_t module_idP, 0); // m if (CCEIndex < 0) { - LOG_E(MAC, "%s(): cannot find free CCE for UE %d!\n", __func__, UE_id); + LOG_E(MAC, "%s(): cannot find free CCE for RA RNTI %04x!\n", __func__, ra->rnti); return; } nr_configure_pdcch(nr_mac, @@ -716,7 +709,7 @@ void nr_generate_Msg2(module_id_t module_idP, pdcch_pdu_rel15->StartSymbolIndex, pdcch_pdu_rel15->DurationSymbols); - fill_dci_pdu_rel15(scc,secondaryCellGroup,pdcch_pdu_rel15, &dci_pdu_rel15[0], dci_formats, rnti_types,dci10_bw,ra->bwp_id); + fill_dci_pdu_rel15(scc,ra->secondaryCellGroup,pdcch_pdu_rel15, &dci_pdu_rel15[0], dci_formats, rnti_types,dci10_bw,ra->bwp_id); dl_req->nPDUs+=2; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index d19dc7b056..237ad37648 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -63,9 +63,6 @@ #define ENABLE_MAC_PAYLOAD_DEBUG #define DEBUG_gNB_SCHEDULER 1 -/*Softmodem params*/ -#include "executables/softmodem-common.h" - #include "common/ran_context.h" extern RAN_CONTEXT_t RC; @@ -1640,12 +1637,7 @@ int add_new_nr_ue(module_id_t mod_idP, rnti_t rntiP){ int UE_id = i; UE_info->num_UEs++; - /* if real softmodem: not yet active, we wait for RA! FIXME: This opens a - * data race: a UE should complete RA before adding the next, or by the - * above condition, we overwrite the current UE with the following one. - * - * if phytest: there is no RA, so enable directly */ - UE_info->active[UE_id] = get_softmodem_params()->phy_test; + UE_info->active[UE_id] = true; UE_info->rnti[UE_id] = rntiP; add_nr_ue_list(&UE_info->list, UE_id); memset((void *) &UE_info->UE_sched_ctrl[UE_id], diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c index 0e977c5352..b87d8787bf 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c @@ -365,18 +365,44 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP, } } - else { + else if (sduP != NULL) { // if the CRC passed // random access pusch with TC-RNTI - if (sduP != NULL) { // if the CRC passed - for (int i = 0; i < MAX_MOBILES_PER_GNB; i++) { - if (UE_info->tc_rnti[i] == current_rnti) { - // for now the only thing we are doing is set the UE as active - UE_info->active[i] = true; - LOG_W(MAC, "[gNB %d][RAPROC] PUSCH with TC_RNTI %x received correctly and UE_id %d is now 5G connected\n", - gnb_mod_idP, current_rnti, i); - } - } + NR_RA_t *ra = &gNB_mac->common_channels[CC_idP].ra[0]; + if (ra->state != WAIT_Msg3) { + LOG_E(MAC, + "expected RA state WAIT_Msg3/%d (but is %d) for RA-RNTI %04x\n", + WAIT_Msg3, + ra->state, + ra->rnti); + return; } + if (ra->rnti != current_rnti) { + LOG_E(MAC, + "expected RA-RNTI %04x (C-RNTI %04x) to match current RNTI %04x\n", + ra->rnti, + ra->crnti, + current_rnti); + return; + } + free(ra->preambles.preamble_list); + ra->state = RA_IDLE; + LOG_I(MAC, "reset RA state information for RA-RNTI %04x\n", ra->rnti); + const int UE_id = add_new_nr_ue(gnb_mod_idP, ra->crnti); + UE_info->secondaryCellGroup[UE_id] = ra->secondaryCellGroup; + struct NR_ServingCellConfig__downlinkBWP_ToAddModList *bwpList = + ra->secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList; + AssertFatal(bwpList->list.count == 1, + "downlinkBWP_ToAddModList has %d BWP!\n", + bwpList->list.count); + const int bwp_id = 1; + UE_info->UE_sched_ctrl[UE_id].active_bwp = bwpList->list.array[bwp_id - 1]; + LOG_W(MAC, + "[gNB %d][RAPROC] PUSCH with TC_RNTI %x received correctly, " + "adding UE MAC Context UE_id %d/RNTI %04x\n", + gnb_mod_idP, + current_rnti, + UE_id, + ra->crnti); } } diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index 2bedb0750f..f94bfc61aa 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -83,6 +83,11 @@ typedef enum { WAIT_Msg4_ACK = 4 } RA_gNB_state_t; +typedef struct NR_preamble_ue { + uint8_t num_preambles; + uint8_t *preamble_list; +} NR_preamble_ue_t; + /*! \brief gNB template for the Random access information */ typedef struct { /// Flag to indicate this process is active @@ -141,6 +146,12 @@ typedef struct { int msg4_mcs; /// RA search space NR_SearchSpace_t *ra_ss; + /// secondaryCellGroup for UE in NSA that is to come + NR_CellGroupConfig_t *secondaryCellGroup; + /// Preambles for contention-free access + NR_preamble_ue_t preambles; + /// NSA: the UEs C-RNTI to use + rnti_t crnti; } NR_RA_t; /*! \brief gNB common channels */ @@ -325,11 +336,6 @@ typedef struct { NR_UE_mac_ce_ctrl_t UE_mac_ce_ctrl;// MAC CE related information } NR_UE_sched_ctrl_t; -typedef struct NR_preamble_ue { - uint8_t num_preambles; - uint8_t *preamble_list; -} NR_preamble_ue; - typedef struct { int lc_bytes_tx[64]; @@ -361,8 +367,6 @@ typedef struct { int num_UEs; bool active[MAX_MOBILES_PER_GNB]; rnti_t rnti[MAX_MOBILES_PER_GNB]; - rnti_t tc_rnti[MAX_MOBILES_PER_GNB]; - NR_preamble_ue preambles[MAX_MOBILES_PER_GNB]; NR_CellGroupConfig_t *secondaryCellGroup[MAX_MOBILES_PER_GNB]; } NR_UE_info_t; From 09d85a052a8af134cfae05a1ee77f2ac13c6776d Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 28 Sep 2020 13:27:24 +0200 Subject: [PATCH 81/96] Store retx Info --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 7 +++++++ openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h | 11 +++++++++++ 2 files changed, 18 insertions(+) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index 61015c27eb..b90ffa0378 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -698,6 +698,13 @@ void nr_schedule_ue_spec(module_id_t module_id, if (harq->round == 0) UE_info->mac_stats[UE_id].dlsch_total_bytes += TBS; + NR_UE_ret_info_t *retInfo = &sched_ctrl->retInfo[current_harq_pid]; + retInfo->rbSize = sched_ctrl->rbSize; + retInfo->time_domain_allocation = sched_ctrl->time_domain_allocation; + retInfo->mcsTableIdx = sched_ctrl->mcsTableIdx; + retInfo->mcs = sched_ctrl->mcs; + retInfo->numDmrsCdmGrpsNoData = sched_ctrl->numDmrsCdmGrpsNoData; + nfapi_nr_dl_tti_request_body_t *dl_req = &gNB_mac->DL_req[CC_id].dl_tti_request_body; nr_fill_nfapi_dl_pdu(module_id, UE_id, diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index f94bfc61aa..e0a484abdb 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -279,6 +279,14 @@ typedef struct NR_UE_harq { uint16_t feedback_slot; } NR_UE_harq_t; +typedef struct NR_UE_old_sched { + uint16_t rbSize; + int time_domain_allocation; + uint8_t mcsTableIdx; + uint8_t mcs; + uint8_t numDmrsCdmGrpsNoData; +} NR_UE_ret_info_t; + typedef enum { INACTIVE = 0, ACTIVE_NOT_SCHED, @@ -324,6 +332,9 @@ typedef struct { uint8_t mcs; uint8_t numDmrsCdmGrpsNoData; + /// Retransmission-related information + NR_UE_ret_info_t retInfo[NR_MAX_NB_HARQ_PROCESSES]; + uint16_t ta_timer; int16_t ta_update; uint8_t tpc0; From 2209b999a01ee262b8a5cdbc2b39b7035a5e9be6 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 28 Sep 2020 16:46:06 +0200 Subject: [PATCH 82/96] DL Post processor: distinguish tx/retx --- .../LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 260 ++++++++++-------- 1 file changed, 145 insertions(+), 115 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index b90ffa0378..8090f00ae3 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -573,6 +573,8 @@ void nr_schedule_ue_spec(module_id_t module_id, if (sched_ctrl->rbSize <= 0 && !get_softmodem_params()->phy_test) continue; + const rnti_t rnti = UE_info->rnti[UE_id]; + /* POST processing */ struct NR_PDSCH_TimeDomainResourceAllocationList *tdaList = sched_ctrl->active_bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; @@ -600,110 +602,12 @@ void nr_schedule_ue_spec(module_id_t module_id, 1 /* nrOfLayers */) >> 3; - /* Get RLC data TODO: remove random data retrieval */ - int header_length_total = 0; - int header_length_last = 0; - int sdu_length_total = 0; - int num_sdus = 0; - uint16_t sdu_lengths[NB_RB_MAX] = {0}; - uint8_t mac_sdus[MAX_NR_DLSCH_PAYLOAD_BYTES]; - unsigned char sdu_lcids[NB_RB_MAX] = {0}; - const rnti_t rnti = UE_info->rnti[UE_id]; - const int lcid = DL_SCH_LCID_DTCH; - if (sched_ctrl->num_total_bytes > 0) { - LOG_D(MAC, - "[gNB %d][USER-PLANE DEFAULT DRB] Frame %d : DTCH->DLSCH, Requesting " - "%d bytes from RLC (lcid %d total hdr len %d), TBS: %d \n \n", - module_id, - frame, - TBS - ta_len - header_length_total - sdu_length_total - 3, - lcid, - header_length_total, - TBS); - - sdu_lengths[num_sdus] = mac_rlc_data_req(module_id, - rnti, - module_id, - frame, - ENB_FLAG_YES, - MBMS_FLAG_NO, - lcid, - TBS - ta_len - header_length_total - sdu_length_total - 3, - (char *)&mac_sdus[sdu_length_total], - 0, - 0); - - LOG_D(MAC, - "[gNB %d][USER-PLANE DEFAULT DRB] Got %d bytes for DTCH %d \n", - module_id, - sdu_lengths[num_sdus], - lcid); - - sdu_lcids[num_sdus] = lcid; - sdu_length_total += sdu_lengths[num_sdus]; - header_length_last = 1 + 1 + (sdu_lengths[num_sdus] >= 128); - header_length_total += header_length_last; - - num_sdus++; - - //ue_sched_ctl->uplane_inactivity_timer = 0; - } - else if (get_softmodem_params()->phy_test) { - LOG_D(MAC, "Configuring DL_TX in %d.%d: random data\n", frame, slot); - // fill dlsch_buffer with random data - for (int i = 0; i < TBS; i++) - mac_sdus[i] = (unsigned char) (lrand48()&0xff); - sdu_lcids[0] = 0x3f; // DRB - sdu_lengths[0] = TBS - ta_len - 3; - header_length_total += 2 + (sdu_lengths[0] >= 128); - sdu_length_total += sdu_lengths[0]; - num_sdus +=1; - } - - // there is at least one SDU or TA command - // if (num_sdus > 0 ){ - if (ta_len + sdu_length_total + header_length_total == 0) { - // There is no data from RLC or MAC header, so don't schedule - return; - } - - // Check if there is data from RLC or CE - const int post_padding = TBS >= 2 + header_length_total + sdu_length_total + ta_len; - // padding param currently not in use - //padding = TBS - header_length_total - sdu_length_total - ta_len - 1; - - const int offset = nr_generate_dlsch_pdu( - module_id, - (unsigned char *)mac_sdus, - (unsigned char *)gNB_mac->UE_info.DLSCH_pdu[0][0].payload[0], - num_sdus, // num_sdus - sdu_lengths, - sdu_lcids, - 255, // no drx - NULL, // contention res id - post_padding); - - // Padding: fill remainder of DLSCH with 0 - if (post_padding > 0) { - for (int j = 0; j < TBS - offset; j++) - gNB_mac->UE_info.DLSCH_pdu[0][0].payload[0][offset + j] = 0; - } - const int current_harq_pid = sched_ctrl->current_harq_pid; NR_UE_harq_t *harq = &sched_ctrl->harq_processes[current_harq_pid]; NR_sched_pucch *pucch = &sched_ctrl->sched_pucch[sched_ctrl->pucch_sched_idx]; harq->feedback_slot = pucch->ul_slot; harq->is_waiting = 1; UE_info->mac_stats[UE_id].dlsch_rounds[harq->round]++; - if (harq->round == 0) - UE_info->mac_stats[UE_id].dlsch_total_bytes += TBS; - - NR_UE_ret_info_t *retInfo = &sched_ctrl->retInfo[current_harq_pid]; - retInfo->rbSize = sched_ctrl->rbSize; - retInfo->time_domain_allocation = sched_ctrl->time_domain_allocation; - retInfo->mcsTableIdx = sched_ctrl->mcsTableIdx; - retInfo->mcs = sched_ctrl->mcs; - retInfo->numDmrsCdmGrpsNoData = sched_ctrl->numDmrsCdmGrpsNoData; nfapi_nr_dl_tti_request_body_t *dl_req = &gNB_mac->DL_req[CC_id].dl_tti_request_body; nr_fill_nfapi_dl_pdu(module_id, @@ -732,26 +636,152 @@ void nr_schedule_ue_spec(module_id_t module_id, harq->ndi, harq->round); - nfapi_nr_pdu_t *tx_req = &gNB_mac->TX_req[CC_id].pdu_list[gNB_mac->TX_req[CC_id].Number_of_PDUs]; - configure_fapi_dl_Tx(module_id, - frame, - slot, - dl_req, - tx_req, - TBS, - gNB_mac->pdu_index[CC_id]); + NR_UE_ret_info_t *retInfo = &sched_ctrl->retInfo[current_harq_pid]; + if (harq->round != 0) { /* retransmission */ + if (sched_ctrl->rbSize != retInfo->rbSize) + LOG_W(MAC, + "retransmission uses different rbSize (%d vs. orig %d)\n", + sched_ctrl->rbSize, + retInfo->rbSize); + if (sched_ctrl->time_domain_allocation != retInfo->time_domain_allocation) + LOG_W(MAC, + "retransmission uses different time_domain_allocation (%d vs. orig %d)\n", + sched_ctrl->time_domain_allocation, + retInfo->time_domain_allocation); + if (sched_ctrl->mcs != retInfo->mcs + || sched_ctrl->mcsTableIdx != retInfo->mcsTableIdx + || sched_ctrl->numDmrsCdmGrpsNoData != retInfo->numDmrsCdmGrpsNoData) + LOG_W(MAC, + "retransmission uses different table/MCS/numDmrsCdmGrpsNoData (%d/%d/%d vs. orig %d/%d/%d)\n", + sched_ctrl->mcsTableIdx, + sched_ctrl->mcs, + sched_ctrl->numDmrsCdmGrpsNoData, + retInfo->mcsTableIdx, + retInfo->mcs, + retInfo->numDmrsCdmGrpsNoData); + /* we do not have to do anything, since we do not require to get data + * from RLC, encode MAC CEs, or copy data to FAPI structures */ + LOG_W(MAC, "%d.%2d retransmission UE %d/RNTI %04x\n", frame, slot, UE_id, rnti); + } else { /* initial transmission */ + /* Get RLC data TODO: remove random data retrieval */ + int header_length_total = 0; + int header_length_last = 0; + int sdu_length_total = 0; + int num_sdus = 0; + uint16_t sdu_lengths[NB_RB_MAX] = {0}; + uint8_t mac_sdus[MAX_NR_DLSCH_PAYLOAD_BYTES]; + unsigned char sdu_lcids[NB_RB_MAX] = {0}; + const int lcid = DL_SCH_LCID_DTCH; + if (sched_ctrl->num_total_bytes > 0) { + LOG_D(MAC, + "[gNB %d][USER-PLANE DEFAULT DRB] Frame %d : DTCH->DLSCH, Requesting " + "%d bytes from RLC (lcid %d total hdr len %d), TBS: %d \n \n", + module_id, + frame, + TBS - ta_len - header_length_total - sdu_length_total - 3, + lcid, + header_length_total, + TBS); + + sdu_lengths[num_sdus] = mac_rlc_data_req(module_id, + rnti, + module_id, + frame, + ENB_FLAG_YES, + MBMS_FLAG_NO, + lcid, + TBS - ta_len - header_length_total - sdu_length_total - 3, + (char *)&mac_sdus[sdu_length_total], + 0, + 0); + + LOG_D(MAC, + "[gNB %d][USER-PLANE DEFAULT DRB] Got %d bytes for DTCH %d \n", + module_id, + sdu_lengths[num_sdus], + lcid); + + sdu_lcids[num_sdus] = lcid; + sdu_length_total += sdu_lengths[num_sdus]; + header_length_last = 1 + 1 + (sdu_lengths[num_sdus] >= 128); + header_length_total += header_length_last; + + num_sdus++; + + //ue_sched_ctl->uplane_inactivity_timer = 0; + } + else if (get_softmodem_params()->phy_test) { + LOG_D(MAC, "Configuring DL_TX in %d.%d: random data\n", frame, slot); + // fill dlsch_buffer with random data + for (int i = 0; i < TBS; i++) + mac_sdus[i] = (unsigned char) (lrand48()&0xff); + sdu_lcids[0] = 0x3f; // DRB + sdu_lengths[0] = TBS - ta_len - 3; + header_length_total += 2 + (sdu_lengths[0] >= 128); + sdu_length_total += sdu_lengths[0]; + num_sdus +=1; + } + + // there is at least one SDU or TA command + // if (num_sdus > 0 ){ + if (ta_len + sdu_length_total + header_length_total == 0) { + // There is no data from RLC or MAC header, so don't schedule + return; + } + + // Check if there is data from RLC or CE + const int post_padding = TBS >= 2 + header_length_total + sdu_length_total + ta_len; + // padding param currently not in use + //padding = TBS - header_length_total - sdu_length_total - ta_len - 1; + + const int offset = nr_generate_dlsch_pdu( + module_id, + (unsigned char *)mac_sdus, + (unsigned char *)gNB_mac->UE_info.DLSCH_pdu[0][0].payload[0], + num_sdus, // num_sdus + sdu_lengths, + sdu_lcids, + 255, // no drx + NULL, // contention res id + post_padding); + + // Padding: fill remainder of DLSCH with 0 + if (post_padding > 0) { + for (int j = 0; j < TBS - offset; j++) + gNB_mac->UE_info.DLSCH_pdu[0][0].payload[0][offset + j] = 0; + } + + UE_info->mac_stats[UE_id].dlsch_total_bytes += TBS; + + retInfo->rbSize = sched_ctrl->rbSize; + retInfo->time_domain_allocation = sched_ctrl->time_domain_allocation; + retInfo->mcsTableIdx = sched_ctrl->mcsTableIdx; + retInfo->mcs = sched_ctrl->mcs; + retInfo->numDmrsCdmGrpsNoData = sched_ctrl->numDmrsCdmGrpsNoData; + + nfapi_nr_pdu_t *tx_req = &gNB_mac->TX_req[CC_id].pdu_list[gNB_mac->TX_req[CC_id].Number_of_PDUs]; + configure_fapi_dl_Tx(module_id, + frame, + slot, + dl_req, + tx_req, + TBS, + gNB_mac->pdu_index[CC_id]); #if defined(ENABLE_MAC_PAYLOAD_DEBUG) - if (frame%100 == 0){ - LOG_I(MAC, - "%d.%d, first 10 payload bytes, TBS size: %d \n", - frame, - slot, - TBS); - for(int i = 0; i < 10; i++) { - LOG_I(MAC, "byte %d : %x\n", i,((uint8_t *)gNB_mac->UE_info.DLSCH_pdu[0][0].payload[0])[i]); + if (frame%100 == 0) { + LOG_I(MAC, + "%d.%d, first 10 payload bytes, TBS size: %d \n", + frame, + slot, + TBS); + for(int i = 0; i < 10; i++) + LOG_I(MAC, + "byte %d: %x\n", + i, + ((uint8_t *)gNB_mac->UE_info.DLSCH_pdu[0][0].payload[0])[i]); } - } #endif } + } } From 0c6198319682a4fe4e45a7ebb434673cef4d55df Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 28 Sep 2020 17:30:52 +0200 Subject: [PATCH 83/96] Consider retransmissions in the preprocessor --- .../LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 98 +++++++++++++------ 1 file changed, 66 insertions(+), 32 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index 8090f00ae3..dd36eb9baf 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -513,45 +513,79 @@ void nr_simple_dlsch_preprocessor(module_id_t module_id, module_id, UE_id, frame, slot, num_slots_per_tdd, &sched_ctrl->pucch_sched_idx); AssertFatal(sched_ctrl->pucch_sched_idx >= 0, "no uplink slot for PUCCH found!\n"); - // Time-domain allocation - sched_ctrl->time_domain_allocation = 2; - - // Freq-demain allocation uint8_t *vrb_map = RC.nrmac[module_id]->common_channels[CC_id].vrb_map; + const int current_harq_pid = sched_ctrl->current_harq_pid; + NR_UE_harq_t *harq = &sched_ctrl->harq_processes[current_harq_pid]; + NR_UE_ret_info_t *retInfo = &sched_ctrl->retInfo[current_harq_pid]; const uint16_t bwpSize = NRRIV2BW(sched_ctrl->active_bwp->bwp_Common->genericParameters.locationAndBandwidth, 275); int rbStart = NRRIV2PRBOFFSET(sched_ctrl->active_bwp->bwp_Common->genericParameters.locationAndBandwidth, 275); - while (rbStart < bwpSize && vrb_map[rbStart]) rbStart++; - int rbSize = 1; - while (rbStart + rbSize < bwpSize && !vrb_map[rbStart + rbSize]) rbSize++; - DevAssert(rbSize >= 3); /* just ensure we have at least 3 RBs */ - sched_ctrl->rbSize = rbSize; - sched_ctrl->rbStart = rbStart; + + if (harq->round != 0) { /* retransmission */ + sched_ctrl->time_domain_allocation = retInfo->time_domain_allocation; + + /* ensure that there is a free place for RB allocation */ + int rbSize = 0; + while (rbSize < retInfo->rbSize) { + rbStart += rbSize; /* last iteration rbSize was not enough, skip it */ + rbSize = 0; + while (rbStart < bwpSize && vrb_map[rbStart]) rbStart++; + if (rbStart >= bwpSize) { + LOG_E(MAC, + "cannot allocate retransmission for UE %d/RNTI %04x: no resources\n", + UE_id, + rnti); + return; + } + while (rbStart + rbSize < bwpSize + && !vrb_map[rbStart + rbSize] + && rbSize < retInfo->rbSize) + rbSize++; + } + sched_ctrl->rbSize = retInfo->rbSize; + sched_ctrl->rbStart = rbStart; + + /* MCS etc: just reuse from previous scheduling opportunity */ + sched_ctrl->mcsTableIdx = retInfo->mcsTableIdx; + sched_ctrl->mcs = retInfo->mcs; + sched_ctrl->numDmrsCdmGrpsNoData = retInfo->numDmrsCdmGrpsNoData; + } else { + // Time-domain allocation + sched_ctrl->time_domain_allocation = 2; + + // Freq-demain allocation + while (rbStart < bwpSize && vrb_map[rbStart]) rbStart++; + int rbSize = 1; + while (rbStart + rbSize < bwpSize && !vrb_map[rbStart + rbSize]) rbSize++; + DevAssert(rbSize >= 3); /* just ensure we have at least 3 RBs */ + sched_ctrl->rbSize = rbSize; + sched_ctrl->rbStart = rbStart; + + // modulation scheme + sched_ctrl->mcsTableIdx = 0; + sched_ctrl->mcs = 9; + sched_ctrl->numDmrsCdmGrpsNoData = 1; + + uint8_t N_PRB_DMRS = + getN_PRB_DMRS(sched_ctrl->active_bwp, sched_ctrl->numDmrsCdmGrpsNoData); + int nrOfSymbols = getNrOfSymbols(sched_ctrl->active_bwp, + sched_ctrl->time_domain_allocation); + const uint32_t TBS = + nr_compute_tbs(nr_get_Qm_dl(sched_ctrl->mcs, sched_ctrl->mcsTableIdx), + nr_get_code_rate_dl(sched_ctrl->mcs, sched_ctrl->mcsTableIdx), + sched_ctrl->rbSize, + nrOfSymbols, + N_PRB_DMRS, // FIXME // This should be multiplied by the + // number of dmrs symbols + 0 /* N_PRB_oh, 0 for initialBWP */, + 0 /* tb_scaling */, + 1 /* nrOfLayers */) + >> 3; + AssertFatal(TBS != 0, "TBS is zero but requested %d RBs!\n", sched_ctrl->rbSize); + } /* mark the corresponding RBs as used */ for (int rb = 0; rb < sched_ctrl->rbSize; rb++) vrb_map[rb + sched_ctrl->rbStart] = 1; - - // modulation scheme - sched_ctrl->mcsTableIdx = 0; - sched_ctrl->mcs = 9; - sched_ctrl->numDmrsCdmGrpsNoData = 1; - - uint8_t N_PRB_DMRS = - getN_PRB_DMRS(sched_ctrl->active_bwp, sched_ctrl->numDmrsCdmGrpsNoData); - int nrOfSymbols = getNrOfSymbols(sched_ctrl->active_bwp, - sched_ctrl->time_domain_allocation); - const uint32_t TBS = - nr_compute_tbs(nr_get_Qm_dl(sched_ctrl->mcs, sched_ctrl->mcsTableIdx), - nr_get_code_rate_dl(sched_ctrl->mcs, sched_ctrl->mcsTableIdx), - sched_ctrl->rbSize, - nrOfSymbols, - N_PRB_DMRS, // FIXME // This should be multiplied by the - // number of dmrs symbols - 0 /* N_PRB_oh, 0 for initialBWP */, - 0 /* tb_scaling */, - 1 /* nrOfLayers */) - >> 3; - AssertFatal(TBS != 0, "TBS is zero but requested %d RBs!\n", sched_ctrl->rbSize); } void nr_schedule_ue_spec(module_id_t module_id, From b7b32fbe77124eb2f299195b521fc5d96aa6fdce Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 29 Sep 2020 11:26:37 +0200 Subject: [PATCH 84/96] allocate only necessary amount of RBs --- .../LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 41 ++++++++++--------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index dd36eb9baf..566457abd5 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -552,35 +552,36 @@ void nr_simple_dlsch_preprocessor(module_id_t module_id, // Time-domain allocation sched_ctrl->time_domain_allocation = 2; - // Freq-demain allocation - while (rbStart < bwpSize && vrb_map[rbStart]) rbStart++; - int rbSize = 1; - while (rbStart + rbSize < bwpSize && !vrb_map[rbStart + rbSize]) rbSize++; - DevAssert(rbSize >= 3); /* just ensure we have at least 3 RBs */ - sched_ctrl->rbSize = rbSize; - sched_ctrl->rbStart = rbStart; - // modulation scheme sched_ctrl->mcsTableIdx = 0; sched_ctrl->mcs = 9; sched_ctrl->numDmrsCdmGrpsNoData = 1; + // Freq-demain allocation + while (rbStart < bwpSize && vrb_map[rbStart]) rbStart++; + uint8_t N_PRB_DMRS = getN_PRB_DMRS(sched_ctrl->active_bwp, sched_ctrl->numDmrsCdmGrpsNoData); int nrOfSymbols = getNrOfSymbols(sched_ctrl->active_bwp, sched_ctrl->time_domain_allocation); - const uint32_t TBS = - nr_compute_tbs(nr_get_Qm_dl(sched_ctrl->mcs, sched_ctrl->mcsTableIdx), - nr_get_code_rate_dl(sched_ctrl->mcs, sched_ctrl->mcsTableIdx), - sched_ctrl->rbSize, - nrOfSymbols, - N_PRB_DMRS, // FIXME // This should be multiplied by the - // number of dmrs symbols - 0 /* N_PRB_oh, 0 for initialBWP */, - 0 /* tb_scaling */, - 1 /* nrOfLayers */) - >> 3; - AssertFatal(TBS != 0, "TBS is zero but requested %d RBs!\n", sched_ctrl->rbSize); + + int rbSize = 0; + uint32_t TBS = 0; + do { + rbSize++; + TBS = nr_compute_tbs(nr_get_Qm_dl(sched_ctrl->mcs, sched_ctrl->mcsTableIdx), + nr_get_code_rate_dl(sched_ctrl->mcs, sched_ctrl->mcsTableIdx), + rbSize, + nrOfSymbols, + N_PRB_DMRS, // FIXME // This should be multiplied by the + // number of dmrs symbols + 0 /* N_PRB_oh, 0 for initialBWP */, + 0 /* tb_scaling */, + 1 /* nrOfLayers */) + >> 3; + } while (rbStart + rbSize < bwpSize && !vrb_map[rbStart + rbSize] && TBS < sched_ctrl->num_total_bytes); + sched_ctrl->rbSize = rbSize; + sched_ctrl->rbStart = rbStart; } /* mark the corresponding RBs as used */ From ea9aacd6649abbd8696c8b5929e72a8c3634e703 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 29 Sep 2020 17:55:17 +0200 Subject: [PATCH 85/96] Directly construct tx_req nFAPI message in DL postprocessor --- .../LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 33 ++++++++++--------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index 566457abd5..5659342674 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -769,10 +769,15 @@ void nr_schedule_ue_spec(module_id_t module_id, // padding param currently not in use //padding = TBS - header_length_total - sdu_length_total - ta_len - 1; + const int ntx_req = gNB_mac->TX_req[CC_id].Number_of_PDUs; + nfapi_nr_pdu_t *tx_req = &gNB_mac->TX_req[CC_id].pdu_list[ntx_req]; + /* pointer to directly generate the PDU into the nFAPI structure */ + uint32_t *buf = tx_req->TLVs[0].value.direct; + const int offset = nr_generate_dlsch_pdu( module_id, (unsigned char *)mac_sdus, - (unsigned char *)gNB_mac->UE_info.DLSCH_pdu[0][0].payload[0], + (unsigned char *)buf, num_sdus, // num_sdus sdu_lengths, sdu_lcids, @@ -783,9 +788,19 @@ void nr_schedule_ue_spec(module_id_t module_id, // Padding: fill remainder of DLSCH with 0 if (post_padding > 0) { for (int j = 0; j < TBS - offset; j++) - gNB_mac->UE_info.DLSCH_pdu[0][0].payload[0][offset + j] = 0; + buf[offset + j] = 0; } + /* the buffer has been filled by nr_generate_dlsch_pdu(), below we simply + * fill the remaining information */ + tx_req->PDU_length = TBS; + tx_req->PDU_index = gNB_mac->pdu_index[0]++; + tx_req->num_TLV = 1; + tx_req->TLVs[0].length = TBS + 2; + gNB_mac->TX_req[CC_id].Number_of_PDUs++; + gNB_mac->TX_req[CC_id].SFN = frame; + gNB_mac->TX_req[CC_id].Slot = slot; + UE_info->mac_stats[UE_id].dlsch_total_bytes += TBS; retInfo->rbSize = sched_ctrl->rbSize; @@ -794,15 +809,6 @@ void nr_schedule_ue_spec(module_id_t module_id, retInfo->mcs = sched_ctrl->mcs; retInfo->numDmrsCdmGrpsNoData = sched_ctrl->numDmrsCdmGrpsNoData; - nfapi_nr_pdu_t *tx_req = &gNB_mac->TX_req[CC_id].pdu_list[gNB_mac->TX_req[CC_id].Number_of_PDUs]; - configure_fapi_dl_Tx(module_id, - frame, - slot, - dl_req, - tx_req, - TBS, - gNB_mac->pdu_index[CC_id]); - #if defined(ENABLE_MAC_PAYLOAD_DEBUG) if (frame%100 == 0) { LOG_I(MAC, @@ -811,10 +817,7 @@ void nr_schedule_ue_spec(module_id_t module_id, slot, TBS); for(int i = 0; i < 10; i++) - LOG_I(MAC, - "byte %d: %x\n", - i, - ((uint8_t *)gNB_mac->UE_info.DLSCH_pdu[0][0].payload[0])[i]); + LOG_I(MAC, "byte %d: %x\n", i, ((uint8_t *) buf)[i]); } #endif } From 574f47d0149f8919a9b10e53a773b75786fce0b3 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 29 Sep 2020 17:55:49 +0200 Subject: [PATCH 86/96] nr_fill_nfapi_dl_pdu(): pdu index and nPDUs counting --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index 237ad37648..b13cd89a19 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -483,7 +483,7 @@ void nr_fill_nfapi_dl_pdu(int Mod_idP, pdsch_pdu_rel15->pduBitmap = 0; pdsch_pdu_rel15->rnti = UE_info->rnti[UE_id]; - pdsch_pdu_rel15->pduIndex = 0; + pdsch_pdu_rel15->pduIndex = nr_mac->pdu_index[0]++; // BWP pdsch_pdu_rel15->BWPSize = NRRIV2BW(bwp->bwp_Common->genericParameters.locationAndBandwidth,275); @@ -635,6 +635,8 @@ void nr_fill_nfapi_dl_pdu(int Mod_idP, pdsch_pdu_rel15->NrOfCodewords, pdsch_pdu_rel15->mcsIndex[0], TBS); + + dl_req->nPDUs += 2; } void nr_configure_pdcch(gNB_MAC_INST *nr_mac, From f97c4f8ae63f6b2b7d10aba2f293030381f778d1 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 29 Sep 2020 18:04:16 +0200 Subject: [PATCH 87/96] Remove statistics from nr_generate_dlsch_pdu() --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 14 ++------------ openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c | 2 ++ 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index 5659342674..85c5645615 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -81,8 +81,6 @@ int nr_generate_dlsch_pdu(module_id_t module_idP, //NR_CellGroupConfig_t *config = UE_info->secondaryCellGroup[UE_id]; ue_sched_ctl = &(UE_info->UE_sched_ctrl[UE_id]); - NR_mac_stats_t *mac_stats = &(UE_info->mac_stats[UE_id]); - // 1) Compute MAC CE and related subheaders // DRX command subheader (MAC CE size 0) @@ -333,8 +331,6 @@ int nr_generate_dlsch_pdu(module_id_t module_idP, memcpy((void *) mac_pdu_ptr, (void *) dlsch_buffer_ptr, sdu_lengths[i]); dlsch_buffer_ptr += sdu_lengths[i]; mac_pdu_ptr += sdu_lengths[i]; - - mac_stats->lc_bytes_tx[sdu_lcids[i]] += sdu_lengths[i]; } // 4) Compute final offset for padding @@ -757,12 +753,8 @@ void nr_schedule_ue_spec(module_id_t module_id, num_sdus +=1; } - // there is at least one SDU or TA command - // if (num_sdus > 0 ){ - if (ta_len + sdu_length_total + header_length_total == 0) { - // There is no data from RLC or MAC header, so don't schedule - return; - } + UE_info->mac_stats[UE_id].dlsch_total_bytes += TBS; + UE_info->mac_stats[UE_id].lc_bytes_tx[lcid] += sdu_length_total; // Check if there is data from RLC or CE const int post_padding = TBS >= 2 + header_length_total + sdu_length_total + ta_len; @@ -801,8 +793,6 @@ void nr_schedule_ue_spec(module_id_t module_id, gNB_mac->TX_req[CC_id].SFN = frame; gNB_mac->TX_req[CC_id].Slot = slot; - UE_info->mac_stats[UE_id].dlsch_total_bytes += TBS; - retInfo->rbSize = sched_ctrl->rbSize; retInfo->time_domain_allocation = sched_ctrl->time_domain_allocation; retInfo->mcsTableIdx = sched_ctrl->mcsTableIdx; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c index c7115dedce..9f69edcdfa 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c @@ -724,6 +724,8 @@ void nr_schedule_uss_dlsch_phytest(module_id_t module_idP, } + UE_info->mac_stats[UE_id].lc_bytes_tx[lcid] += sdu_length_total; + // there is at least one SDU or TA command // if (num_sdus > 0 ){ if (ta_len + sdu_length_total + header_length_total > 0) { From a2bf8f478ab2ee3a1eb9c30b26d73e56f24eace6 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 29 Sep 2020 18:06:43 +0200 Subject: [PATCH 88/96] Add configurable UE as param for nr_generate_dlsch_pdu() --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 8 ++------ openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c | 1 + openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 1 + 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index 85c5645615..93c9e32842 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -58,6 +58,7 @@ //#define SIZE_OF_POINTER sizeof (void *) int nr_generate_dlsch_pdu(module_id_t module_idP, + NR_UE_sched_ctrl_t *ue_sched_ctl, unsigned char *sdus_payload, unsigned char *mac_pdu, unsigned char num_sdus, @@ -74,12 +75,6 @@ int nr_generate_dlsch_pdu(module_id_t module_idP, // MAC CEs uint8_t mac_header_control_elements[16], *ce_ptr; ce_ptr = &mac_header_control_elements[0]; - uint16_t UE_id = 0; //TODO need to get as a function parameter or need to invoke api to UE_id using module Id and RNTI - gNB_MAC_INST *gNB_mac = RC.nrmac[module_idP]; - NR_UE_info_t *UE_info = &gNB_mac->UE_info; - NR_UE_sched_ctrl_t *ue_sched_ctl = NULL; - //NR_CellGroupConfig_t *config = UE_info->secondaryCellGroup[UE_id]; - ue_sched_ctl = &(UE_info->UE_sched_ctrl[UE_id]); // 1) Compute MAC CE and related subheaders @@ -768,6 +763,7 @@ void nr_schedule_ue_spec(module_id_t module_id, const int offset = nr_generate_dlsch_pdu( module_id, + sched_ctrl, (unsigned char *)mac_sdus, (unsigned char *)buf, num_sdus, // num_sdus diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c index 9f69edcdfa..450ffa2268 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c @@ -742,6 +742,7 @@ void nr_schedule_uss_dlsch_phytest(module_id_t module_idP, } offset = nr_generate_dlsch_pdu(module_idP, + &UE_info->UE_sched_ctrl[UE_id], (unsigned char *) mac_sdus, (unsigned char *) gNB_mac->UE_info.DLSCH_pdu[0][0].payload[0], num_sdus, //num_sdus diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index 420a37bd52..f636a27300 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -67,6 +67,7 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, frame_t frame_rxP, sub_frame_t slot_rxP); int nr_generate_dlsch_pdu(module_id_t Mod_idP, + NR_UE_sched_ctrl_t *ue_sched_ctl, unsigned char *sdus_payload, unsigned char *mac_pdu, unsigned char num_sdus, From 13b016de5317b505135fbcfbe4e4c05d69312bf6 Mon Sep 17 00:00:00 2001 From: Sakthivel Velumani Date: Wed, 30 Sep 2020 16:02:01 +0200 Subject: [PATCH 89/96] doing nr_segmentation in all rounds because round 0 could be skipped if no pusch signal detected --- openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c index 37c619a230..7aef5fca0a 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c +++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c @@ -577,13 +577,13 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, stats->current_RI = n_layers; stats->total_bytes_tx += harq_process->TBS; } - // This is a new packet, so compute quantities regarding segmentation - if (A > 3824) - harq_process->B = A+24; - else - harq_process->B = A+16; + } + if (A > 3824) + harq_process->B = A+24; + else + harq_process->B = A+16; - // [hna] Perform nr_segmenation with input and output set to NULL to calculate only (B, C, K, Z, F) +// [hna] Perform nr_segmenation with input and output set to NULL to calculate only (B, C, K, Z, F) nr_segmentation(NULL, NULL, harq_process->B, @@ -594,11 +594,10 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, p_decParams->BG); #ifdef DEBUG_ULSCH_DECODING - printf("ulsch decoding nr segmentation Z %d\n", harq_process->Z); - if (!frame%100) - printf("K %d C %d Z %d \n", harq_process->K, harq_process->C, harq_process->Z); + printf("ulsch decoding nr segmentation Z %d\n", harq_process->Z); + if (!frame%100) + printf("K %d C %d Z %d \n", harq_process->K, harq_process->C, harq_process->Z); #endif - } Tbslbrm = nr_compute_tbslbrm(0,nb_rb,n_layers); p_decParams->Z = harq_process->Z; From 3367b0f199c24a37c5006ee1e2178e4126d96545 Mon Sep 17 00:00:00 2001 From: Sakthivel Velumani Date: Fri, 2 Oct 2020 14:30:42 +0200 Subject: [PATCH 90/96] fixing compile warnings --- cmake_targets/phy_simulators/CMakeLists.txt | 3 ++- openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c | 17 +++++++---------- openair1/SCHED_NR/phy_procedures_nr_gNB.c | 1 - openair1/SIMULATION/NR_PHY/dlsim.c | 8 ++++---- openair1/SIMULATION/NR_PHY/ulschsim.c | 3 ++- openair2/LAYER2/MAC/eNB_scheduler_mch.c | 2 +- 6 files changed, 16 insertions(+), 18 deletions(-) diff --git a/cmake_targets/phy_simulators/CMakeLists.txt b/cmake_targets/phy_simulators/CMakeLists.txt index 5f2d34883e..cf68ca4a9d 100644 --- a/cmake_targets/phy_simulators/CMakeLists.txt +++ b/cmake_targets/phy_simulators/CMakeLists.txt @@ -1,11 +1,12 @@ cmake_minimum_required(VERSION 2.8) +project (OpenAirInterface) set ( CMAKE_BUILD_TYPE ) set ( CFLAGS_PROCESSOR_USER "" ) set ( UE_EXPANSION False ) set ( PRE_SCD_THREAD False ) set ( UESIM_EXPANSION False ) set ( ENABLE_VCD_FIFO False ) -set ( RF_BOARD "OAI_USRP") +set ( RF_BOARD "None") set ( TRANSP_PRO "None") set ( PACKAGE_NAME "") set ( DEADLINE_SCHEDULER "False" ) diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c index 7aef5fca0a..42f88d16f4 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c +++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c @@ -52,9 +52,6 @@ #define OAI_UL_LDPC_MAX_NUM_LLR 27000//26112 // NR_LDPC_NCOL_BG1*NR_LDPC_ZMAX = 68*384 //#define PRINT_CRC_CHECK -static uint64_t nb_total_decod =0; -static uint64_t nb_error_decod =0; - //extern double cpuf; void free_gNB_ulsch(NR_gNB_ULSCH_t **ulschptr,uint8_t N_RB_UL) @@ -286,7 +283,7 @@ void clean_gNB_ulsch(NR_gNB_ULSCH_t *ulsch) static uint32_t prnt_crc_cnt = 0; #endif -uint32_t nr_processULSegment(void* arg) { +void nr_processULSegment(void* arg) { ldpcDecode_t *rdata = (ldpcDecode_t*) arg; PHY_VARS_gNB *phy_vars_gNB = rdata->gNB; NR_UL_gNB_HARQ_t *ulsch_harq = rdata->ulsch_harq; @@ -467,7 +464,6 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, uint32_t G) { uint32_t A; - uint32_t ret; uint32_t r; uint32_t r_offset; uint32_t offset; @@ -494,7 +490,7 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, if (!harq_process) { LOG_E(PHY,"ulsch_decoding.c: NULL harq_process pointer\n"); - return; + return 1; } double Coderate = 0.0; @@ -509,7 +505,7 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, if (!ulsch_llr) { LOG_E(PHY,"ulsch_decoding.c: NULL ulsch_llr pointer\n"); - return; + return 1; } VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_gNB_ULSCH_DECODING,1); @@ -617,7 +613,7 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, if (harq_process->C > a_segments) { LOG_E(PHY,"Illegal harq_process->C %d > %d\n",harq_process->C,a_segments); - return; + return 1; } #ifdef DEBUG_ULSCH_DECODING printf("Segmentation: C %d, K %d\n",harq_process->C,harq_process->K); @@ -625,13 +621,14 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, Kr = harq_process->K; Kr_bytes = Kr>>3; offset = 0; + void (*nr_processULSegment_ptr)(void*) = &nr_processULSegment; for (r=0; rC; r++) { E = nr_get_E(G, harq_process->C, Qm, n_layers, r); union ldpcReqUnion id = {.s={ulsch->rnti,frame,nr_tti_rx,0,0}}; - notifiedFIFO_elt_t *req=newNotifiedFIFO_elt(sizeof(ldpcDecode_t), id.p, phy_vars_gNB->respDecode, nr_processULSegment); + notifiedFIFO_elt_t *req=newNotifiedFIFO_elt(sizeof(ldpcDecode_t), id.p, phy_vars_gNB->respDecode, nr_processULSegment_ptr); ldpcDecode_t * rdata=(ldpcDecode_t *) NotifiedFifoData(req); rdata->gNB = phy_vars_gNB; @@ -659,5 +656,5 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, offset += (Kr_bytes - (harq_process->F>>3) - ((harq_process->C>1)?3:0)); ////////////////////////////////////////////////////////////////////////////////////////// } - return; + return 1; } diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index 5853b2d1dc..1024db3791 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -281,7 +281,6 @@ void nr_ulsch_procedures(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, int ULSCH NR_DL_FRAME_PARMS *frame_parms = &gNB->frame_parms; nfapi_nr_pusch_pdu_t *pusch_pdu = &gNB->ulsch[ULSCH_id][0]->harq_processes[harq_pid]->ulsch_pdu; - uint8_t ret; uint8_t l, number_dmrs_symbols = 0; uint32_t G; uint16_t start_symbol, number_symbols, nb_re_dmrs; diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index 38400cab51..788b7324ba 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -184,7 +184,7 @@ int main(int argc, char **argv) int frame=1,slot=1; int frame_length_complex_samples; - int frame_length_complex_samples_no_prefix; + //int frame_length_complex_samples_no_prefix; NR_DL_FRAME_PARMS *frame_parms; UE_nr_rxtx_proc_t UE_proc; NR_Sched_Rsp_t Sched_INFO; @@ -197,7 +197,7 @@ int main(int argc, char **argv) int pucch_tgt_snrx10 = 200; int loglvl=OAILOG_INFO; - float target_error_rate = 0.01; + //float target_error_rate = 0.01; int css_flag=0; cpuf = get_cpu_freq_GHz(); @@ -359,7 +359,7 @@ int main(int argc, char **argv) case 'I': run_initial_sync=1; - target_error_rate=0.1; + //target_error_rate=0.1; slot = 0; break; @@ -585,7 +585,7 @@ int main(int argc, char **argv) } frame_length_complex_samples = frame_parms->samples_per_subframe*NR_NUMBER_OF_SUBFRAMES_PER_FRAME; - frame_length_complex_samples_no_prefix = frame_parms->samples_per_subframe_wCP*NR_NUMBER_OF_SUBFRAMES_PER_FRAME; + //frame_length_complex_samples_no_prefix = frame_parms->samples_per_subframe_wCP*NR_NUMBER_OF_SUBFRAMES_PER_FRAME; s_re = malloc(2*sizeof(double*)); s_im = malloc(2*sizeof(double*)); diff --git a/openair1/SIMULATION/NR_PHY/ulschsim.c b/openair1/SIMULATION/NR_PHY/ulschsim.c index db18b1ebb7..bf60e5a7cf 100644 --- a/openair1/SIMULATION/NR_PHY/ulschsim.c +++ b/openair1/SIMULATION/NR_PHY/ulschsim.c @@ -104,6 +104,7 @@ int nr_postDecode_sim(PHY_VARS_gNB *gNB, notifiedFIFO_elt_t *req) { } ulsch->last_iteration_cnt = rdata->decodeIterations; + return 0; } int main(int argc, char **argv) { @@ -130,7 +131,7 @@ int main(int argc, char **argv) NR_DL_FRAME_PARMS *frame_parms; double sigma; unsigned char qbits = 8; - int ret; + int ret=0; int loglvl = OAILOG_WARNING; uint64_t SSB_positions=0x01; uint16_t nb_symb_sch = 12; diff --git a/openair2/LAYER2/MAC/eNB_scheduler_mch.c b/openair2/LAYER2/MAC/eNB_scheduler_mch.c index 0c686a6475..f3a77ed703 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_mch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_mch.c @@ -211,7 +211,7 @@ schedule_MBMS_NFAPI(module_id_t module_idP, uint8_t CC_id, frame_t frameP, msi_pos++; while((non_mbsfn_SubframeConfig & (0x100 >> msi_pos)) == (0x100>>msi_pos)) msi_pos++; - mbms_mch_i=0; + mbms_mch_i=0; if((subframeP==0)){ x=0; From 53f3874032a7eaa37926306db6be51919b28c599 Mon Sep 17 00:00:00 2001 From: Sakthivel Velumani Date: Fri, 2 Oct 2020 15:11:28 +0200 Subject: [PATCH 91/96] updating ulsim to take samples from exernal source --- openair1/SIMULATION/NR_PHY/ulsim.c | 69 +++++++++++++++++------------- 1 file changed, 40 insertions(+), 29 deletions(-) diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c index b897be393b..a6c2b662f3 100644 --- a/openair1/SIMULATION/NR_PHY/ulsim.c +++ b/openair1/SIMULATION/NR_PHY/ulsim.c @@ -183,6 +183,7 @@ int main(int argc, char **argv) int pucch_tgt_snrx10 = 200; int ibwps=24; int ibwp_rboffset=41; + int params_from_file = 0; if ( load_configmodule(argc,argv,CONFIG_ENABLECMDLINEONLY) == 0 ) { exit_fun("[NR_ULSIM] Error, configuration module init failed\n"); } @@ -419,6 +420,10 @@ int main(int argc, char **argv) } break; + case 'Q': + params_from_file = 1; + break; + default: case 'h': printf("%s -h(elp) -p(extended_prefix) -N cell_id -f output_filename -F input_filename -g channel_model -n n_frames -t Delayspread -s snr0 -S snr1 -x transmission_mode -y TXant -z RXant -i Intefrence0 -j Interference1 -A interpolation_file -C(alibration offset dB) -N CellId\n", argv[0]); @@ -440,7 +445,7 @@ int main(int argc, char **argv) printf("-A Interpolation_filname Run with Abstraction to generate Scatter plot using interpolation polynomial in file\n"); //printf("-C Generate Calibration information for Abstraction (effective SNR adjustment to remove Pe bias w.r.t. AWGN)\n"); printf("-F Input filename (.txt format) for RX conformance testing\n"); - printf("-G raw file containing RRC configuration (generated by gNB)\n"); + printf("-G Offset of samples to read from file (0 default)\n"); printf("-M Multiple SSB positions in burst\n"); printf("-N Nid_cell\n"); printf("-O oversampling factor (1,2,4,8,16)\n"); @@ -450,6 +455,7 @@ int main(int argc, char **argv) printf("-P Print ULSCH performances\n"); printf("-T Enable PTRS, arguments list L_PTRS{0,1,2} K_PTRS{2,4}, e.g. -T 2 0 2 \n"); printf("-U Change DMRS Config, arguments list DMRS TYPE{0=A,1=B} DMRS AddPos{0:3}, e.g. -U 2 0 2 \n"); + printf("-Q If -F used, read parameters from file\n"); exit(-1); break; @@ -723,6 +729,7 @@ int main(int argc, char **argv) //for (int i=0;i<16;i++) printf("%f\n",gaussdouble(0.0,1.0)); snrRun = 0; int n_errs = 0; + int read_errors=0; int slot_offset = frame_parms->get_samples_slot_timestamp(slot,frame_parms,0); int slot_length = slot_offset - frame_parms->get_samples_slot_timestamp(slot-1,frame_parms,0); @@ -732,35 +739,39 @@ int main(int argc, char **argv) // 800 samples is N_TA_OFFSET for FR1 @ 30.72 Ms/s, AssertFatal(frame_parms->subcarrier_spacing==30000,"only 30 kHz for file input for now (%d)\n",frame_parms->subcarrier_spacing); - fseek(input_fd,file_offset*((slot_length<<2)+4000+16),SEEK_SET); - fread((void*)&n_rnti,sizeof(int16_t),1,input_fd); - printf("rnti %x\n",n_rnti); - fread((void*)&nb_rb,sizeof(int16_t),1,input_fd); - printf("nb_rb %d\n",nb_rb); - int16_t dummy; - fread((void*)&start_rb,sizeof(int16_t),1,input_fd); - //fread((void*)&dummy,sizeof(int16_t),1,input_fd); - printf("rb_start %d\n",start_rb); - fread((void*)&nb_symb_sch,sizeof(int16_t),1,input_fd); - //fread((void*)&dummy,sizeof(int16_t),1,input_fd); - printf("nb_symb_sch %d\n",nb_symb_sch); - fread((void*)&start_symbol,sizeof(int16_t),1,input_fd); - printf("start_symbol %d\n",start_symbol); - fread((void*)&Imcs,sizeof(int16_t),1,input_fd); - printf("mcs %d\n",Imcs); - fread((void*)&rv_index,sizeof(int16_t),1,input_fd); - printf("rv_index %d\n",rv_index); - // fread((void*)&harq_pid,sizeof(int16_t),1,input_fd); - fread((void*)&dummy,sizeof(int16_t),1,input_fd); - printf("harq_pid %d\n",harq_pid); - fread((void*)&gNB->common_vars.rxdata[0][slot_offset-delay], - sizeof(int16_t), - slot_length<<1, - input_fd); + if (params_from_file) { + fseek(input_fd,file_offset*((slot_length<<2)+4000+16),SEEK_SET); + read_errors+=fread((void*)&n_rnti,sizeof(int16_t),1,input_fd); + printf("rnti %x\n",n_rnti); + read_errors+=fread((void*)&nb_rb,sizeof(int16_t),1,input_fd); + printf("nb_rb %d\n",nb_rb); + int16_t dummy; + read_errors+=fread((void*)&start_rb,sizeof(int16_t),1,input_fd); + //fread((void*)&dummy,sizeof(int16_t),1,input_fd); + printf("rb_start %d\n",start_rb); + read_errors+=fread((void*)&nb_symb_sch,sizeof(int16_t),1,input_fd); + //fread((void*)&dummy,sizeof(int16_t),1,input_fd); + printf("nb_symb_sch %d\n",nb_symb_sch); + read_errors+=fread((void*)&start_symbol,sizeof(int16_t),1,input_fd); + printf("start_symbol %d\n",start_symbol); + read_errors+=fread((void*)&Imcs,sizeof(int16_t),1,input_fd); + printf("mcs %d\n",Imcs); + read_errors+=fread((void*)&rv_index,sizeof(int16_t),1,input_fd); + printf("rv_index %d\n",rv_index); + // fread((void*)&harq_pid,sizeof(int16_t),1,input_fd); + read_errors+=fread((void*)&dummy,sizeof(int16_t),1,input_fd); + printf("harq_pid %d\n",harq_pid); + } + fseek(input_fd,file_offset*sizeof(int16_t)*2,SEEK_SET); + read_errors+=fread((void*)&gNB->common_vars.rxdata[0][slot_offset-delay], + sizeof(int16_t), + slot_length<<1, + input_fd); + if (read_errors==0) exit(1); for (int i=0;i<16;i+=2) printf("slot_offset %d : %d,%d\n", - slot_offset, - ((int16_t*)&gNB->common_vars.rxdata[0][slot_offset])[i], - ((int16_t*)&gNB->common_vars.rxdata[0][slot_offset])[1+i]); + slot_offset, + ((int16_t*)&gNB->common_vars.rxdata[0][slot_offset])[i], + ((int16_t*)&gNB->common_vars.rxdata[0][slot_offset])[1+i]); } for (SNR = snr0; SNR < snr1; SNR += snr_step) { From eebc233abde8242ed776886a9822eaecb8e18856 Mon Sep 17 00:00:00 2001 From: Sakthivel Velumani Date: Fri, 2 Oct 2020 15:18:04 +0200 Subject: [PATCH 92/96] reducing ulsch decoding cores for CI segfault --- executables/nr-gnb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/executables/nr-gnb.c b/executables/nr-gnb.c index 79c43671dd..ad6e016fd4 100644 --- a/executables/nr-gnb.c +++ b/executables/nr-gnb.c @@ -812,7 +812,7 @@ void init_gNB_proc(int inst) { gNB->threadPool = (tpool_t*)malloc(sizeof(tpool_t)); gNB->respDecode = (notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t)); - char ul_pool[] = "-1,-1,-1,-1,-1,-1,-1,-1"; + char ul_pool[] = "-1,-1"; initTpool(ul_pool, gNB->threadPool, false); initNotifiedFIFO(gNB->respDecode); } From 51311c6c1c9e61a5050f8be806a846566d943a97 Mon Sep 17 00:00:00 2001 From: hardy Date: Mon, 5 Oct 2020 11:25:52 +0200 Subject: [PATCH 93/96] adding RA test to CI --- ci-scripts/reportTestLocally.sh | 53 +++++++++++++ ci-scripts/runTestOnVM.sh | 133 +++++++++++++++++++++++++------- 2 files changed, 157 insertions(+), 29 deletions(-) diff --git a/ci-scripts/reportTestLocally.sh b/ci-scripts/reportTestLocally.sh index b05ccf39db..5f5f5caa35 100755 --- a/ci-scripts/reportTestLocally.sh +++ b/ci-scripts/reportTestLocally.sh @@ -765,6 +765,59 @@ function report_test { echo " Test without EPC (aka noS1): ${TMODE} -- ${BW}PRB " >> ./test_simulator_results.html fi echo " " >> ./test_simulator_results.html + + #RA test (--do-ra option) + + #build log files names + RA_ENB_LOG=$ARCHIVES_LOC/ra_check_${TMODE}_${BW}prb_${CN_CONFIG}_gnb.log + RA_UE_LOG=$ARCHIVES_LOC/ra_check_${TMODE}_${BW}prb_${CN_CONFIG}_ue.log + if [ -f $RA_ENB_LOG ] && [ -f $RA_UE_LOG ] + then + #get rid of full path + NAME_ENB=`echo $RA_ENB_LOG | sed -e "s#$ARCHIVES_LOC/##"` + NAME_UE=`echo $RA_UE_LOG | sed -e "s#$ARCHIVES_LOC/##"` + echo " " >> ./test_simulator_results.html + echo " $NAME_ENB --- $NAME_UE" >> ./test_simulator_results.html + echo " Check if RA proc succeeded" >> ./test_simulator_results.html + + #gNB RA check + GNB_RECEIVED=`egrep -c "received correctly" $RA_ENB_LOG` + GNB_CONNECTED=`egrep -c "now 5G connected" $RA_ENB_LOG` + #UE RA check + UE_RA_PROC_OK=`egrep -c "RA procedure succeeded" $RA_UE_LOG` + + + if [ $GNB_RECEIVED -gt 0 ] && [ $GNB_CONNECTED -gt 0 ] && [ $UE_RA_PROC_OK -gt 0 ] + then + echo " OK" >> ./test_simulator_results.html + else + echo " KO" >> ./test_simulator_results.html + fi + + echo "
" >> ./test_simulator_results.html
+                    if [ $GNB_RECEIVED -gt 0 ]
+                    then
+                        echo "- gNB --> RA received" >> ./test_simulator_results.html
+                    else
+                        echo "- gNB RA NOT RECEIVED" >> ./test_simulator_results.html
+                    fi
+                    if [ $GNB_CONNECTED -gt 0 ]
+                    then
+                        echo "- gNB --> 5G connected" >> ./test_simulator_results.html
+                    else
+                        echo "- gNB NOT 5G CONNECTED" >> ./test_simulator_results.html
+                    fi
+                    if [ $UE_RA_PROC_OK -gt 0 ]
+                    then
+                        echo "- NR UE  --> RA procedure succeded" >> ./test_simulator_results.html
+                    else
+                        echo "- NR UE RA procedure failed" >> ./test_simulator_results.html
+                    fi
+                    echo "        
" >> ./test_simulator_results.html + echo " " >> ./test_simulator_results.html + fi + + #SYNC test ENB_LOG=$ARCHIVES_LOC/${TMODE}_${BW}prb_${CN_CONFIG}_gnb.log UE_LOG=`echo $ENB_LOG | sed -e "s#gnb#ue#"` if [ -f $ENB_LOG ] && [ -f $UE_LOG ] diff --git a/ci-scripts/runTestOnVM.sh b/ci-scripts/runTestOnVM.sh index b9b9a2bafa..7f2ce6279d 100755 --- a/ci-scripts/runTestOnVM.sh +++ b/ci-scripts/runTestOnVM.sh @@ -276,6 +276,22 @@ function check_ping_result { fi } + +function check_ra_result { + local LOC_GNB_LOG=$1 + local LOC_UE_LOG=$2 + + #gNB RA test + echo "Checking gNB Log for RA success" + egrep "received correctly" $1 + egrep "now 5G connected" $1 + + #UE RA test + echo 'Checking UE Log for RA success' + egrep "RA procedure succeeded" $2 + +} + # In DL: iperf server should be on UE side # -B oaitun_ue{j}-IP-Addr # iperf client should be on EPC (S1) or eNB (noS1) side @@ -1172,6 +1188,8 @@ function start_rf_sim_gnb { local LOC_CONF_FILE=$5 # 1 is with S1 and 0 without S1 aka noS1 local LOC_S1_CONFIGURATION=$6 + #LOC_RA_TEST=1 will run the RA test check + local LOC_RA_TEST=$7 if [ -e rbconfig.raw ]; then rm -f rbconfig.raw; fi if [ -e reconfig.raw ]; then rm -f reconfig.raw; fi @@ -1192,7 +1210,12 @@ function start_rf_sim_gnb { echo "sudo rm -f r*config.raw" >> $1 if [ $LOC_S1_CONFIGURATION -eq 0 ] then - echo "echo \"RFSIMULATOR=server ./nr-softmodem -O /home/ubuntu/tmp/ci-scripts/conf_files/ci-$LOC_CONF_FILE --log_config.global_log_options level,nocolor --parallel-config PARALLEL_SINGLE_THREAD --noS1 --nokrnmod 1 --rfsim --phy-test\" > ./my-nr-softmodem-run.sh " >> $1 + if [ $LOC_RA_TEST -eq 0 ] #no RA test => use --phy-test option + then + echo "echo \"RFSIMULATOR=server ./nr-softmodem -O /home/ubuntu/tmp/ci-scripts/conf_files/ci-$LOC_CONF_FILE --log_config.global_log_options level,nocolor --parallel-config PARALLEL_SINGLE_THREAD --noS1 --nokrnmod 1 --rfsim --phy-test\" > ./my-nr-softmodem-run.sh " >> $1 + else #RA test => use --do-ra option + echo "echo \"RFSIMULATOR=server ./nr-softmodem -O /home/ubuntu/tmp/ci-scripts/conf_files/ci-$LOC_CONF_FILE --log_config.global_log_options level,nocolor --parallel-config PARALLEL_SINGLE_THREAD --noS1 --nokrnmod 1 --rfsim --do-ra\" > ./my-nr-softmodem-run.sh " >> $1 + fi fi echo "chmod 775 ./my-nr-softmodem-run.sh" >> $1 echo "cat ./my-nr-softmodem-run.sh" >> $1 @@ -1249,6 +1272,8 @@ function start_rf_sim_gnb { echo "RF-SIM gNB oaitun_enb1 is UP and CONFIGURED" fi fi + + sleep 10 echo "echo \"free -m\"" > $1 echo "free -m" >> $1 @@ -1267,6 +1292,8 @@ function start_rf_sim_nr_ue { local LOC_FREQUENCY=$6 # 1 is with S1 and 0 without S1 aka noS1 local LOC_S1_CONFIGURATION=$7 + #LOC_RA_TEST=1 will run the RA test check + local LOC_RA_TEST=$8 # Copy the RAW files from the gNB run scp -o StrictHostKeyChecking=no rbconfig.raw ubuntu@$LOC_NR_UE_VM_IP_ADDR:/home/ubuntu/tmp @@ -1281,7 +1308,12 @@ function start_rf_sim_nr_ue { echo "cd /home/ubuntu/tmp/cmake_targets/ran_build/build/" >> $1 if [ $LOC_S1_CONFIGURATION -eq 0 ] then - echo "echo \"RFSIMULATOR=${LOC_GNB_VM_IP_ADDR} ./nr-uesoftmodem --nokrnmod 1 --rfsim --phy-test --rrc_config_path /home/ubuntu/tmp/cmake_targets/ran_build/build/ --log_config.global_log_options level,nocolor --noS1\" > ./my-nr-softmodem-run.sh " >> $1 + if [ $LOC_RA_TEST -eq 0 ] #no RA test => use --phy-test option + then + echo "echo \"RFSIMULATOR=${LOC_GNB_VM_IP_ADDR} ./nr-uesoftmodem --nokrnmod 1 --rfsim --phy-test --rrc_config_path /home/ubuntu/tmp/cmake_targets/ran_build/build/ --log_config.global_log_options level,nocolor --noS1\" > ./my-nr-softmodem-run.sh " >> $1 + else #RA test => use --do-ra option + echo "echo \"RFSIMULATOR=${LOC_GNB_VM_IP_ADDR} ./nr-uesoftmodem --nokrnmod 1 --rfsim --do-ra --rrc_config_path /home/ubuntu/tmp/cmake_targets/ran_build/build/ --log_config.global_log_options level,nocolor --noS1\" > ./my-nr-softmodem-run.sh " >> $1 + fi fi echo "chmod 775 ./my-nr-softmodem-run.sh" >> $1 echo "cat ./my-nr-softmodem-run.sh" >> $1 @@ -1340,6 +1372,8 @@ function start_rf_sim_nr_ue { echo "RF-SIM NR-UE oaitun_ue1 is UP and CONFIGURED" fi sleep 10 + + } @@ -2027,30 +2061,6 @@ function run_test_on_vm { done - full_l2_sim_destroy - - echo "############################################################" - echo "Checking run status" - echo "############################################################" - - if [ $PING_STATUS -ne 0 ]; then STATUS=-1; fi - if [ $IPERF_STATUS -ne 0 ]; then STATUS=-1; fi - if [ $MBMS_STATUS -eq 0 ] - then - echo "LTE MBMS RFSIM seems OK" - else - echo "LTE MBMS RFSIM seems to FAIL" - STATUS=-1 - fi - if [ $STATUS -eq 0 ] - then - echo "LTE RFSIM seems OK" - echo "LTE: TEST_OK" > $ARCHIVES_LOC/test_final_status.log - else - echo "LTE RFSIM seems to FAIL" - echo "LTE: TEST_KO" > $ARCHIVES_LOC/test_final_status.log - fi - #################### ## FeMBMS CASE noS1 ## #################### @@ -2123,6 +2133,13 @@ function run_test_on_vm { if [ $PING_STATUS -ne 0 ]; then STATUS=-1; fi if [ $IPERF_STATUS -ne 0 ]; then STATUS=-1; fi + if [ $MBMS_STATUS -eq 0 ] + then + echo "LTE MBMS RFSIM seems OK" + else + echo "LTE MBMS RFSIM seems to FAIL" + STATUS=-1 + fi if [ $FeMBMS_STATUS -eq 0 ] then echo "LTE FeMBMS RFSIM seems OK" @@ -2153,8 +2170,10 @@ function run_test_on_vm { NR_STATUS=0 ######### start of loop - while [ $try_cnt -lt 1 ] + while [ $try_cnt -lt 4 ] do + + #start RA test SYNC_STATUS=0 PING_STATUS=0 IPERF_STATUS=0 @@ -2163,13 +2182,69 @@ function run_test_on_vm { echo "${CN_CONFIG} : Starting the gNB" echo "############################################################" CURRENT_GNB_LOG_FILE=tdd_${PRB}prb_${CN_CONFIG}_gnb.log - start_rf_sim_gnb $GNB_VM_CMDS "$GNB_VM_IP_ADDR" $CURRENT_GNB_LOG_FILE $PRB $CONF_FILE $S1_NOS1_CFG + #last argument = 1 is to enable --do-ra for RA test + start_rf_sim_gnb $GNB_VM_CMDS "$GNB_VM_IP_ADDR" $CURRENT_GNB_LOG_FILE $PRB $CONF_FILE $S1_NOS1_CFG 1 echo "############################################################" echo "${CN_CONFIG} : Starting the NR-UE" echo "############################################################" CURRENT_NR_UE_LOG_FILE=tdd_${PRB}prb_${CN_CONFIG}_ue.log - start_rf_sim_nr_ue $NR_UE_VM_CMDS $NR_UE_VM_IP_ADDR $GNB_VM_IP_ADDR $CURRENT_NR_UE_LOG_FILE $PRB $FREQUENCY $S1_NOS1_CFG + #last argument = 1 is to enable --do-ra for RA test + start_rf_sim_nr_ue $NR_UE_VM_CMDS $NR_UE_VM_IP_ADDR $GNB_VM_IP_ADDR $CURRENT_NR_UE_LOG_FILE $PRB $FREQUENCY $S1_NOS1_CFG 1 + if [ $NR_UE_SYNC -eq 0 ] + then + echo "Problem w/ gNB and NR-UE not syncing" + terminate_enb_ue_basic_sim $NR_UE_VM_CMDS $NR_UE_VM_IP_ADDR 2 + terminate_enb_ue_basic_sim $GNB_VM_CMDS $GNB_VM_IP_ADDR 1 + scp -o StrictHostKeyChecking=no ubuntu@$GNB_VM_IP_ADDR:/home/ubuntu/tmp/cmake_targets/log/$CURRENT_GNB_LOG_FILE $ARCHIVES_LOC + scp -o StrictHostKeyChecking=no ubuntu@$NR_UE_VM_IP_ADDR:/home/ubuntu/tmp/cmake_targets/log/$CURRENT_NR_UE_LOG_FILE $ARCHIVES_LOC + SYNC_STATUS=-1 + try_cnt=$[$try_cnt+1] + continue + fi + + + echo "############################################################" + echo "${CN_CONFIG} : Terminate gNB/NR-UE simulators" + echo "############################################################" + sleep 20 + terminate_enb_ue_basic_sim $NR_UE_VM_CMDS $NR_UE_VM_IP_ADDR 2 + terminate_enb_ue_basic_sim $GNB_VM_CMDS $GNB_VM_IP_ADDR 1 + scp -o StrictHostKeyChecking=no ubuntu@$GNB_VM_IP_ADDR:/home/ubuntu/tmp/cmake_targets/log/$CURRENT_GNB_LOG_FILE $ARCHIVES_LOC + scp -o StrictHostKeyChecking=no ubuntu@$NR_UE_VM_IP_ADDR:/home/ubuntu/tmp/cmake_targets/log/$CURRENT_NR_UE_LOG_FILE $ARCHIVES_LOC + + + + #check RA markers in gNB and NR UE log files + echo "############################################################" + echo "${CN_CONFIG} : Checking RA on gNB / NR-UE" + echo "############################################################" + + mv $ARCHIVES_LOC/$CURRENT_GNB_LOG_FILE $ARCHIVES_LOC/ra_check_$CURRENT_GNB_LOG_FILE + mv $ARCHIVES_LOC/$CURRENT_NR_UE_LOG_FILE $ARCHIVES_LOC/ra_check_$CURRENT_NR_UE_LOG_FILE + check_ra_result $ARCHIVES_LOC/ra_check_$CURRENT_GNB_LOG_FILE $ARCHIVES_LOC/ra_check_$CURRENT_NR_UE_LOG_FILE + + + #end RA test + + + + + SYNC_STATUS=0 + PING_STATUS=0 + IPERF_STATUS=0 + + echo "############################################################" + echo "${CN_CONFIG} : Starting the gNB" + echo "############################################################" + CURRENT_GNB_LOG_FILE=tdd_${PRB}prb_${CN_CONFIG}_gnb.log + start_rf_sim_gnb $GNB_VM_CMDS "$GNB_VM_IP_ADDR" $CURRENT_GNB_LOG_FILE $PRB $CONF_FILE $S1_NOS1_CFG 0 + + echo "############################################################" + echo "${CN_CONFIG} : Starting the NR-UE" + echo "############################################################" + CURRENT_NR_UE_LOG_FILE=tdd_${PRB}prb_${CN_CONFIG}_ue.log + start_rf_sim_nr_ue $NR_UE_VM_CMDS $NR_UE_VM_IP_ADDR $GNB_VM_IP_ADDR $CURRENT_NR_UE_LOG_FILE $PRB $FREQUENCY $S1_NOS1_CFG 0 if [ $NR_UE_SYNC -eq 0 ] then echo "Problem w/ gNB and NR-UE not syncing" From 2305470a75513d05d2176bffa56bb6196ec47513 Mon Sep 17 00:00:00 2001 From: Shweta Shrivastava Date: Tue, 6 Oct 2020 13:26:45 -0500 Subject: [PATCH 94/96] Fix for using K2 offset other than 2 --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c index fa31c1596d..8cf48d9c34 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c @@ -863,7 +863,7 @@ void schedule_fapi_ul_pdu(int Mod_idP, * conditions might exclude each other and never be true */ const int slot_idx = (slotP + K2) % num_slots_per_tdd; if (is_xlsch_in_slot(ulsch_in_slot_bitmap, slot_idx) - && (!get_softmodem_params()->phy_test || slotP == 6)) { + && (!get_softmodem_params()->phy_test || slot_idx == 8)) { nfapi_nr_ul_dci_request_t *UL_dci_req = &RC.nrmac[Mod_idP]->UL_dci_req[0]; UL_dci_req->SFN = frameP; UL_dci_req->Slot = slotP; From a389e6f5e979f758e8c86647a49831846d57cb72 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 5 Oct 2020 10:43:20 +0200 Subject: [PATCH 95/96] Fixup: reserve space for TA command --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index 3898576204..ed142a42c8 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -590,7 +590,6 @@ void nr_schedule_ue_spec(module_id_t module_id, gNB_MAC_INST *gNB_mac = RC.nrmac[module_id]; NR_UE_info_t *UE_info = &gNB_mac->UE_info; - const int ta_len = gNB_mac->ta_len; const int CC_id = 0; NR_UE_list_t *UE_list = &UE_info->list; @@ -689,6 +688,11 @@ void nr_schedule_ue_spec(module_id_t module_id, * from RLC, encode MAC CEs, or copy data to FAPI structures */ LOG_W(MAC, "%d.%2d retransmission UE %d/RNTI %04x\n", frame, slot, UE_id, rnti); } else { /* initial transmission */ + + /* reserve space for timing advance of UE if necessary, + * nr_generate_dlsch_pdu() checks for ta_apply and add TA CE if necessary */ + const int ta_len = (sched_ctrl->ta_apply) ? 2 : 0; + /* Get RLC data TODO: remove random data retrieval */ int header_length_total = 0; int header_length_last = 0; From 2a4153eb290bae6294849ced1b9d7e57ca45e2aa Mon Sep 17 00:00:00 2001 From: Thomas Schlichter Date: Wed, 7 Oct 2020 16:26:40 +0200 Subject: [PATCH 96/96] fixup previous merge with develop branch --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c | 5 +-- .../LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c | 4 +-- .../NR_MAC_gNB/gNB_scheduler_primitives.c | 33 +++++++++---------- 3 files changed, 19 insertions(+), 23 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c index d84dd66ddc..58de000ac5 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c @@ -474,7 +474,7 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, nr_schedule_reception_msg3(module_idP, 0, frame, slot); } - if (UE_list->fiveG_connected[UE_id]) { + if (UE_info->active[UE_id]) { // TbD once RACH is available, start ta_timer when UE is connected if (ue_sched_ctl->ta_timer) ue_sched_ctl->ta_timer--; @@ -504,9 +504,6 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, //nr_update_pucch_scheduling(module_idP, UE_id, frame, slot, num_slots_per_tdd,&pucch_sched); //nr_schedule_uss_dlsch_phytest(module_idP, frame, slot, &UE_info->UE_sched_ctrl[UE_id].sched_pucch[pucch_sched], NULL); nr_schedule_ue_spec(module_idP, frame, slot, num_slots_per_tdd); - // resetting ta flag - gNB->ta_len = 0; - // TO BE CHECKED IF IT IS CORRECT TO KEEP THIS LINE! ue_sched_ctl->ta_apply = false; } diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c index 0579db5628..5f9d5d8a10 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c @@ -624,8 +624,8 @@ void nr_schedule_uss_dlsch_phytest(module_id_t module_idP, unsigned char sdu_lcids[NB_RB_MAX] = {0}; uint16_t sdu_lengths[NB_RB_MAX] = {0}; - uint16_t rnti = UE_list->rnti[UE_id]; - NR_UE_sched_ctrl_t *ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; + uint16_t rnti = UE_info->rnti[UE_id]; + NR_UE_sched_ctrl_t *ue_sched_ctl = &UE_info->UE_sched_ctrl[UE_id]; uint8_t mac_sdus[MAX_NR_DLSCH_PAYLOAD_BYTES]; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index f431994b77..a686215fd5 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -1633,8 +1633,8 @@ int add_new_nr_ue(module_id_t mod_idP, rnti_t rntiP){ UE_info->num_UEs); dump_nr_ue_list(&UE_info->list); - for (i = 0; i < MAX_MOBILES_PER_GNB; i++) { - if (UE_list->active[i] == TRUE) + for (int i = 0; i < MAX_MOBILES_PER_GNB; i++) { + if (UE_info->active[i]) continue; int UE_id = i; @@ -1645,11 +1645,11 @@ int add_new_nr_ue(module_id_t mod_idP, rnti_t rntiP){ memset((void *) &UE_info->UE_sched_ctrl[UE_id], 0, sizeof(NR_UE_sched_ctrl_t)); - UE_list->UE_sched_ctrl[UE_id].ta_timer = 100; - UE_list->UE_sched_ctrl[UE_id].ta_update = 31; - UE_list->UE_sched_ctrl[UE_id].ul_rssi = 0; - UE_list->UE_sched_ctrl[UE_id].sched_pucch = (NR_sched_pucch *)malloc(num_slots_ul*sizeof(NR_sched_pucch)); - UE_list->UE_sched_ctrl[UE_id].sched_pusch = (NR_sched_pusch *)malloc(num_slots_ul*sizeof(NR_sched_pusch)); + UE_info->UE_sched_ctrl[UE_id].ta_timer = 100; + UE_info->UE_sched_ctrl[UE_id].ta_update = 31; + UE_info->UE_sched_ctrl[UE_id].ul_rssi = 0; + UE_info->UE_sched_ctrl[UE_id].sched_pucch = (NR_sched_pucch *)malloc(num_slots_ul*sizeof(NR_sched_pucch)); + UE_info->UE_sched_ctrl[UE_id].sched_pusch = (NR_sched_pusch *)malloc(num_slots_ul*sizeof(NR_sched_pusch)); for (int k=0; kUE_sched_ctrl[UE_id].sched_pucch[k], 0, @@ -1681,23 +1681,22 @@ void mac_remove_nr_ue(module_id_t mod_id, rnti_t rnti) { int UE_id; int i; - NR_UE_list_t *UE_list = &RC.nrmac[mod_id]->UE_list; + NR_UE_info_t *UE_info = &RC.nrmac[mod_id]->UE_info; for (i = 0; i < MAX_MOBILES_PER_GNB; i++) { - if (UE_list->active[i] != TRUE) + if (UE_info->active[i] != TRUE) continue; - if (UE_list->rnti[i] != rnti) + if (UE_info->rnti[i] != rnti) continue; /* UE found, remove it */ UE_id = i; - UE_list->num_UEs--; - UE_list->fiveG_connected[UE_id] = FALSE; - UE_list->active[UE_id] = FALSE; - UE_list->rnti[UE_id] = 0; - free(UE_list->UE_sched_ctrl[UE_id].sched_pucch); - free(UE_list->UE_sched_ctrl[UE_id].sched_pusch); - memset((void *) &UE_list->UE_sched_ctrl[UE_id], + UE_info->num_UEs--; + UE_info->active[UE_id] = FALSE; + UE_info->rnti[UE_id] = 0; + free(UE_info->UE_sched_ctrl[UE_id].sched_pucch); + free(UE_info->UE_sched_ctrl[UE_id].sched_pusch); + memset((void *) &UE_info->UE_sched_ctrl[UE_id], 0, sizeof(NR_UE_sched_ctrl_t)); LOG_I(MAC, "[gNB %d] Remove NR UE_id %d : rnti %x\n",