From c0ae14326401bbf5dbaadf9d40431dc4b03b525c Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Wed, 21 Apr 2021 08:22:57 +0200 Subject: [PATCH 1/2] extra logging for PUCCH power control, DL NAS debugging. Fixed issue with power control configuration parameterss (pucchSNRx10,puschSNRx10) which were not read in properly. Consequence of moving them from the RRC setion to MAC section. --- openair1/PHY/NR_TRANSPORT/pucch_rx.c | 22 +++++++++---------- openair2/GNB_APP/MACRLC_nr_paramdef.h | 12 +++++----- openair2/GNB_APP/gnb_config.c | 5 ++--- .../LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 5 +++-- .../NR_MAC_gNB/gNB_scheduler_primitives.c | 1 + .../LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c | 2 +- openair2/RRC/NR/MESSAGES/asn1_msg.c | 3 ++- 7 files changed, 26 insertions(+), 24 deletions(-) diff --git a/openair1/PHY/NR_TRANSPORT/pucch_rx.c b/openair1/PHY/NR_TRANSPORT/pucch_rx.c index 99bc5b5774..b6c20a1b47 100644 --- a/openair1/PHY/NR_TRANSPORT/pucch_rx.c +++ b/openair1/PHY/NR_TRANSPORT/pucch_rx.c @@ -237,7 +237,7 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB, } AssertFatal(pucch_pdu->nr_of_symbols < 3,"nr_of_symbols %d not allowed\n",pucch_pdu->nr_of_symbols); - uint32_t re_offset=0; + uint32_t re_offset[2]={0,0}; uint8_t l2; const int16_t *x_re[2],*x_im[2]; @@ -255,20 +255,20 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB, int n2; for (l=0; lnr_of_symbols; l++) { l2 = l+pucch_pdu->start_symbol_index; - re_offset = (12*prb_offset[l]) + frame_parms->first_carrier_offset; - if (re_offset>= frame_parms->ofdm_symbol_size) - re_offset-=frame_parms->ofdm_symbol_size; + re_offset[l] = (12*prb_offset[l]) + frame_parms->first_carrier_offset; + if (re_offset[l]>= frame_parms->ofdm_symbol_size) + re_offset[l]-=frame_parms->ofdm_symbol_size; - AssertFatal(re_offset+12 < frame_parms->ofdm_symbol_size,"pucch straddles DC carrier, handle this!\n"); + AssertFatal(re_offset[l]+12 < frame_parms->ofdm_symbol_size,"pucch straddles DC carrier, handle this!\n"); - int16_t *r=(int16_t*)&rxdataF[0][(l2*frame_parms->ofdm_symbol_size)+re_offset]; + int16_t *r=(int16_t*)&rxdataF[0][(l2*frame_parms->ofdm_symbol_size)+re_offset[l]]; n2=0; for (n=0;n<12;n++,n2+=2) { xr[l][n2] =(int16_t)(((int32_t)x_re[l][n]*r[n2]+(int32_t)x_im[l][n]*r[n2+1])>>15); xr[l][n2+1]=(int16_t)(((int32_t)x_re[l][n]*r[n2+1]-(int32_t)x_im[l][n]*r[n2])>>15); #ifdef DEBUG_NR_PUCCH_RX printf("x (%d,%d), r%d.%d (%d,%d), xr (%d,%d)\n", - x_re[l][n],x_im[l][n],l2,re_offset,r[n2],r[n2+1],xr[l][n2],xr[l][n2+1]); + x_re[l][n],x_im[l][n],l2,re_offset[l],r[n2],r[n2+1],xr[l][n2],xr[l][n2+1]); #endif } } @@ -328,7 +328,7 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB, // estimate CQI for MAC (from antenna port 0 only) - int SNRtimes10 = dB_fixed_times10(signal_energy_nodc(&rxdataF[0][pucch_pdu->start_symbol_index*frame_parms->ofdm_symbol_size+re_offset],12)) - (10*gNB->measurements.n0_power_tot_dB); + int SNRtimes10 = dB_fixed_times10(signal_energy_nodc(&rxdataF[0][pucch_pdu->start_symbol_index*frame_parms->ofdm_symbol_size+re_offset[0]],12)) - (10*gNB->measurements.n0_power_tot_dB); int cqi; if (SNRtimes10 < -640) cqi=0; else if (SNRtimes10 > 635) cqi=255; @@ -346,7 +346,7 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB, uci_pdu->rnti = pucch_pdu->rnti; uci_pdu->ul_cqi = cqi; uci_pdu->timing_advance = 0xffff; // currently not valid - uci_pdu->rssi = 1280 - (10*dB_fixed(32767*32767)-dB_fixed_times10(signal_energy_nodc(&rxdataF[0][pucch_pdu->start_symbol_index*frame_parms->ofdm_symbol_size+re_offset],12))); + uci_pdu->rssi = 1280 - (10*dB_fixed(32767*32767)-dB_fixed_times10(signal_energy_nodc(&rxdataF[0][pucch_pdu->start_symbol_index*frame_parms->ofdm_symbol_size+re_offset[0]],12))); if (pucch_pdu->bit_len_harq==0) { uci_pdu->harq = NULL; uci_pdu->sr = calloc(1,sizeof(*uci_pdu->sr)); @@ -363,8 +363,8 @@ 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, "Slot %d HARQ value %d with confidence level (0 is good, 1 is bad) %d xrt_mag %d\n", - slot,uci_pdu->harq->harq_list[0].harq_value,uci_pdu->harq->harq_confidence_level,xrtmag_dB); + LOG_I(PHY, "Slot %d HARQ value %d with confidence level (0 is good, 1 is bad) %d xrt_mag %d n0 %d\n", + slot,uci_pdu->harq->harq_list[0].harq_value,uci_pdu->harq->harq_confidence_level,xrtmag_dB,gNB->measurements.n0_power_tot_dB); if (pucch_pdu->sr_flag == 1) { uci_pdu->sr = calloc(1,sizeof(*uci_pdu->sr)); uci_pdu->sr->sr_indication = (index>1) ? 1 : 0; diff --git a/openair2/GNB_APP/MACRLC_nr_paramdef.h b/openair2/GNB_APP/MACRLC_nr_paramdef.h index bf568457e6..88c99a90c3 100644 --- a/openair2/GNB_APP/MACRLC_nr_paramdef.h +++ b/openair2/GNB_APP/MACRLC_nr_paramdef.h @@ -55,8 +55,8 @@ #define CONFIG_STRING_MACRLC_REMOTE_S_PORTC "remote_s_portc" #define CONFIG_STRING_MACRLC_LOCAL_S_PORTD "local_s_portd" #define CONFIG_STRING_MACRLC_REMOTE_S_PORTD "remote_s_portd" -#define CONFIG_STRING_MACRLC_PUSCHTARGETPOWX10 "pusch_TargetSNRx10" -#define CONFIG_STRING_MACRLC_PUCCHTARGETPOWX10 "pucch_TargetSNRx10" +#define CONFIG_STRING_MACRLC_PUSCHTARGETSNRX10 "pusch_TargetSNRx10" +#define CONFIG_STRING_MACRLC_PUCCHTARGETSNRX10 "pucch_TargetSNRx10" /*-------------------------------------------------------------------------------------------------------------------------------------------------------*/ @@ -81,8 +81,8 @@ {CONFIG_STRING_MACRLC_REMOTE_S_PORTC, NULL, 0, uptr:NULL, defintval:50020, TYPE_UINT, 0}, \ {CONFIG_STRING_MACRLC_LOCAL_S_PORTD, NULL, 0, uptr:NULL, defintval:50021, TYPE_UINT, 0}, \ {CONFIG_STRING_MACRLC_REMOTE_S_PORTD, NULL, 0, uptr:NULL, defintval:50021, TYPE_UINT, 0}, \ -{CONFIG_STRING_MACRLC_PUSCHTARGETPOWX10, NULL, 0, iptr:NULL, defintval:200, TYPE_INT, 0}, \ -{CONFIG_STRING_MACRLC_PUCCHTARGETPOWX10, NULL, 0, iptr:NULL, defintval:200, TYPE_INT, 0}, \ +{CONFIG_STRING_MACRLC_PUSCHTARGETSNRX10, NULL, 0, iptr:NULL, defintval:200, TYPE_INT, 0}, \ +{CONFIG_STRING_MACRLC_PUCCHTARGETSNRX10, NULL, 0, iptr:NULL, defintval:150, TYPE_INT, 0}, \ } #define MACRLC_CC_IDX 0 #define MACRLC_TRANSPORT_N_PREFERENCE_IDX 1 @@ -101,7 +101,7 @@ #define MACRLC_REMOTE_S_PORTC_IDX 14 #define MACRLC_LOCAL_S_PORTD_IDX 15 #define MACRLC_REMOTE_S_PORTD_IDX 16 -#define MACRLC_PUSCHTARGETPOWX1_IDX 17 -#define MACRLC_PUCCHTARGETPOWX1_IDX 18 +#define MACRLC_PUSCHTARGETSNRX10_IDX 17 +#define MACRLC_PUCCHTARGETSNRX10_IDX 18 /*---------------------------------------------------------------------------------------------------------------------------------------------------------*/ #endif diff --git a/openair2/GNB_APP/gnb_config.c b/openair2/GNB_APP/gnb_config.c index d014aa9bd2..cf51662c5c 100644 --- a/openair2/GNB_APP/gnb_config.c +++ b/openair2/GNB_APP/gnb_config.c @@ -640,6 +640,8 @@ void RCconfig_nr_macrlc() { for (j=0;jpusch_target_snrx10 = *(MacRLC_ParamList.paramarray[j][MACRLC_PUSCHTARGETSNRX10_IDX].iptr); + RC.nrmac[j]->pucch_target_snrx10 = *(MacRLC_ParamList.paramarray[j][MACRLC_PUCCHTARGETSNRX10_IDX].iptr); if (strcmp(*(MacRLC_ParamList.paramarray[j][MACRLC_TRANSPORT_N_PREFERENCE_IDX].strptr), "local_RRC") == 0) { // check number of instances is same as RRC/PDCP @@ -679,9 +681,6 @@ void RCconfig_nr_macrlc() { RC.nrmac[j]->eth_params_s.my_portd = *(MacRLC_ParamList.paramarray[j][MACRLC_LOCAL_S_PORTD_IDX].iptr); RC.nrmac[j]->eth_params_s.remote_portd = *(MacRLC_ParamList.paramarray[j][MACRLC_REMOTE_S_PORTD_IDX].iptr); RC.nrmac[j]->eth_params_s.transp_preference = ETH_UDP_MODE; - RC.nrmac[j]->pusch_target_snrx10 = *(MacRLC_ParamList.paramarray[j][MACRLC_PUSCHTARGETPOWX1_IDX].iptr); - RC.nrmac[j]->pucch_target_snrx10 = *(MacRLC_ParamList.paramarray[j][MACRLC_PUCCHTARGETPOWX1_IDX].iptr); - //sf_ahead = 2; // Cannot cope with 4 subframes between RX and TX - set it to 2 printf("**************** vnf_port:%d\n", RC.nrmac[j]->eth_params_s.my_portc); configure_nr_nfapi_vnf(RC.nrmac[j]->eth_params_s.my_addr, RC.nrmac[j]->eth_params_s.my_portc); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index dd30ca721b..1f3e10222b 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -959,7 +959,7 @@ void nr_schedule_ue_spec(module_id_t module_id, dci_payload.dmrs_sequence_initialization.val = pdsch_pdu->SCID; LOG_I(NR_MAC, "%4d.%2d 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", + "time_alloc %d, vrb to prb %d, mcs %d tb_scaling %d ndi %d rv %d tpc %d\n", frame, slot, dci_payload.frequency_domain_assignment.val, @@ -971,7 +971,8 @@ void nr_schedule_ue_spec(module_id_t module_id, dci_payload.mcs, dci_payload.tb_scaling, dci_payload.ndi, - dci_payload.rv); + dci_payload.rv, + dci_payload.tpc); const long f = sched_ctrl->search_space->searchSpaceType->choice.ue_Specific->dci_Formats; const int dci_format = bwp ? (f ? NR_DL_DCI_FORMAT_1_1 : NR_DL_DCI_FORMAT_1_0) : NR_DL_DCI_FORMAT_1_0; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index f50dc17e65..8de3c02d08 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -1854,6 +1854,7 @@ uint8_t nr_get_tpc(int target, uint8_t cqi, int incr) { // al values passed to this function are x10 int snrx10 = (cqi*5) - 640; + LOG_I(NR_MAC,"tpc : target %d, snrx10 %d\n",target,snrx10); if (snrx10 > target + incr) return 0; // decrease 1dB if (snrx10 < target - incr) return 2; // increase 1dB if (snrx10 < target - (3*incr)) return 3; // increase 3dB diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c index 17e972284f..f28b5f7bf8 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c @@ -972,7 +972,7 @@ void handle_nr_uci_pucch_0_1(module_id_t mod_id, sched_ctrl->tpc1 = nr_get_tpc(RC.nrmac[mod_id]->pucch_target_snrx10, uci_01->ul_cqi, 30); - + LOG_I(NR_MAC,"pucch tpc %d\n",sched_ctrl->tpc1); NR_ServingCellConfigCommon_t *scc = RC.nrmac[mod_id]->common_channels->ServingCellConfigCommon; const int num_slots = nr_slots_per_frame[*scc->ssbSubcarrierSpacing]; if (((uci_01->pduBitmap >> 1) & 0x01)) { diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index c8b719cfc9..c2cfe4e933 100644 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -1707,7 +1707,8 @@ do_NR_DLInformationTransfer( encoded = uper_encode_to_new_buffer (&asn_DEF_NR_DL_DCCH_Message, NULL, (void *) &dl_dcch_msg, (void **)buffer); AssertFatal(encoded > 0,"ASN1 message encoding failed (%s, %ld)!\n", "DLInformationTransfer", encoded); - LOG_D(NR_RRC,"DLInformationTransfer Encoded %zd bytes\n", encoded); + LOG_I(NR_RRC,"DLInformationTransfer Encoded %zd bytes\n", encoded); + for (int i=0;i Date: Thu, 22 Apr 2021 09:32:06 +0200 Subject: [PATCH 2/2] added n1L1_stats.log. improvements to noise level (PUCCH/PUSCH) and signal level (PUCCH) computations. added DTX detection parameters for PUCCH/PUSCH/PRACH in L1 section of configuration file. hotfix from C. Roux for SRB PDCP integrity. extra logging to debug missing PUSCH/DCI at UE. --- executables/nr-gnb.c | 23 ++++- .../PHY/NR_ESTIMATION/nr_measurements_gNB.c | 90 +++++++++++++------ openair1/PHY/NR_ESTIMATION/nr_ul_estimation.h | 2 +- .../PHY/NR_TRANSPORT/nr_transport_proto.h | 1 + openair1/PHY/NR_TRANSPORT/nr_ulsch.c | 17 +++- openair1/PHY/NR_TRANSPORT/nr_ulsch.h | 2 +- .../PHY/NR_TRANSPORT/nr_ulsch_demodulation.c | 8 +- openair1/PHY/NR_TRANSPORT/pucch_rx.c | 78 +++++++++++++--- openair1/PHY/defs_gNB.h | 36 +++++++- openair1/SCHED_NR/nr_prach_procedures.c | 2 +- openair1/SCHED_NR/phy_procedures_nr_gNB.c | 26 +++--- openair2/COMMON/platform_constants.h | 1 + openair2/GNB_APP/L1_nr_paramdef.h | 9 +- openair2/GNB_APP/gnb_config.c | 5 +- .../NR_MAC_gNB/gNB_scheduler_primitives.c | 4 +- .../LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c | 7 +- .../LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c | 7 +- openair2/LAYER2/nr_pdcp/nr_pdcp_entity.c | 12 ++- openair2/RRC/NR/MESSAGES/asn1_msg.c | 2 +- 19 files changed, 254 insertions(+), 78 deletions(-) diff --git a/executables/nr-gnb.c b/executables/nr-gnb.c index a92f433560..a0fd033e16 100644 --- a/executables/nr-gnb.c +++ b/executables/nr-gnb.c @@ -339,6 +339,22 @@ static void *process_stats_thread(void *param) { return(NULL); } +void *nrL1_stats_thread(void *param) { + PHY_VARS_gNB *gNB = (PHY_VARS_gNB *)param; + wait_sync("L1_stats_thread"); + FILE *fd; + while (!oai_exit) { + sleep(1); + fd=fopen("nrL1_stats.log","w"); + AssertFatal(fd!=NULL,"Cannot open ngL1_stats.log\n"); + dump_nr_I0_stats(fd,gNB); + dump_pusch_stats(fd,gNB); + // dump_uci_stats(fd,eNB,eNB->proc.L1_proc_tx.frame_tx); + fclose(fd); + } + return(NULL); +} + void init_gNB_Tpool(int inst) { PHY_VARS_gNB *gNB; gNB = RC.gNB[inst]; @@ -373,7 +389,10 @@ void init_gNB_Tpool(int inst) { initNotifiedFIFO(gNB->resp_RU_tx); // Stats measurement thread - if(opp_enabled == 1) threadCreate(&proc->L1_stats_thread, process_stats_thread,(void *)gNB, "time_meas", -1, OAI_PRIORITY_RT_LOW); + if(opp_enabled == 1) threadCreate(&proc->process_stats_thread, process_stats_thread,(void *)gNB, "time_meas", -1, OAI_PRIORITY_RT_LOW); + threadCreate(&proc->L1_stats_thread,nrL1_stats_thread,(void*)gNB,"L1_stats",-1,OAI_PRIORITY_RT_LOW); + + } @@ -462,6 +481,8 @@ printf("after %p\n", gNB->common_vars.rxdataF[aa]); } + + void init_gNB(int single_thread_flag,int wait_for_sync) { int inst; diff --git a/openair1/PHY/NR_ESTIMATION/nr_measurements_gNB.c b/openair1/PHY/NR_ESTIMATION/nr_measurements_gNB.c index d3e33a91a8..4a95eec0a0 100644 --- a/openair1/PHY/NR_ESTIMATION/nr_measurements_gNB.c +++ b/openair1/PHY/NR_ESTIMATION/nr_measurements_gNB.c @@ -70,7 +70,34 @@ int nr_est_timing_advance_pusch(PHY_VARS_gNB* gNB, int UE_id) } -void gNB_I0_measurements(PHY_VARS_gNB *gNB) { +void dump_nr_I0_stats(FILE *fd,PHY_VARS_gNB *gNB) { + + + int min_I0=1000,max_I0=0; + int amin=0,amax=0; + for (int i=0; iframe_parms.N_RB_UL; i++) { + if (i==(gNB->frame_parms.N_RB_UL>>1) - 1) i+=2; + + if (gNB->measurements.n0_subband_power_tot_dB[i]measurements.n0_subband_power_tot_dB[i]; amin=i;} + + if (gNB->measurements.n0_subband_power_tot_dB[i]>max_I0) {max_I0 = gNB->measurements.n0_subband_power_tot_dB[i]; amax=i;} + } + + for (int i=0; iframe_parms.N_RB_UL; i++) { + fprintf(fd,"%2d.",gNB->measurements.n0_subband_power_tot_dB[i]-gNB->measurements.n0_subband_power_avg_dB); + if (i%25 == 24) fprintf(fd,"\n"); + } + + fprintf(fd,"\nmax_I0 %d (rb %d), min_I0 %d (rb %d), avg I0 %d\n", max_I0, amax, min_I0, amin, gNB->measurements.n0_subband_power_avg_dB); + + fprintf(fd,"prach_I0 = %d.%d dB\n",gNB->measurements.prach_I0/10,gNB->measurements.prach_I0%10); + + +} + + + +void gNB_I0_measurements(PHY_VARS_gNB *gNB,int first_symb,int num_symb) { NR_DL_FRAME_PARMS *frame_parms = &gNB->frame_parms; NR_gNB_COMMON *common_vars = &gNB->common_vars; @@ -79,42 +106,51 @@ void gNB_I0_measurements(PHY_VARS_gNB *gNB) { double rx_gain = openair0_cfg[0].rx_gain[0]; double rx_gain_offset = openair0_cfg[0].rx_gain_offset[0]; uint32_t *rb_mask = gNB->rb_mask_ul; - int symbol = gNB->ulmask_symb; - int rb, offset, nb_rb; + int rb, offset, offset0, nb_rb, len; uint32_t n0_subband_power_temp = 0; int32_t *ul_ch; + int32_t n0_power_tot; + int64_t n0_power_tot2; - if (symbol>-1) { - measurements->n0_power_tot = 0; - for (int aarx=0; aarxnb_antennas_rx; aarx++) { - nb_rb = 0; - for (rb=0; rbN_RB_UL; rb++) { - if ((rb_mask[rb>>5]&(1<<(rb&31))) == 0) { // check that rb was not used in this subframe - nb_rb++; - offset = (frame_parms->first_carrier_offset + (rb*12))%frame_parms->ofdm_symbol_size; - offset += (symbol*frame_parms->ofdm_symbol_size); - ul_ch = &common_vars->rxdataF[aarx][offset]; - //TODO what about DC? - n0_subband_power_temp += signal_energy_nodc(ul_ch,12); - } - } + nb_rb = 0; + n0_power_tot2=0; - if (nb_rb != 0) { - measurements->n0_power[aarx] = n0_subband_power_temp/nb_rb; - measurements->n0_power_dB[aarx] = dB_fixed(measurements->n0_power[aarx]); - measurements->n0_power_tot += measurements->n0_power[aarx]; - } + for (rb=0; rbN_RB_UL; rb++) { + n0_power_tot=0; + offset0 = (frame_parms->first_carrier_offset + (rb*12))%frame_parms->ofdm_symbol_size; + if ((rb_mask[rb>>5]&(1<<(rb&31))) == 0) { // check that rb was not used in this subframe + nb_rb++; + for (int aarx=0; aarxnb_antennas_rx; aarx++) { + measurements->n0_subband_power[aarx][rb]=0; + for (int s=first_symb;s<(first_symb+num_symb);s++) { + offset = offset0 + (s*frame_parms->ofdm_symbol_size); + ul_ch = &common_vars->rxdataF[aarx][offset]; + len = 12; + if (((frame_parms->N_RB_UL&1) == 1) && + (rb==(frame_parms->N_RB_UL>>1))) { + len=6; + } + AssertFatal(ul_ch, "RX signal buffer (freq) problem\n"); + measurements->n0_subband_power[aarx][rb] += signal_energy_nodc(ul_ch,len); + } // symbol + measurements->n0_subband_power[aarx][rb]/=num_symb; + measurements->n0_subband_power_dB[aarx][rb] = dB_fixed(measurements->n0_subband_power[aarx][rb]); + n0_power_tot += measurements->n0_subband_power[aarx][rb]; + + } //antenna + n0_power_tot/=frame_parms->nb_antennas_rx; + n0_power_tot2 += n0_power_tot; + measurements->n0_subband_power_tot_dB[rb] = dB_fixed(n0_power_tot); + measurements->n0_subband_power_tot_dBm[rb] = measurements->n0_subband_power_tot_dB[rb] - gNB->rx_total_gain_dB - dB_fixed(frame_parms->N_RB_UL); } + } //rb - measurements->n0_power_tot_dB = dB_fixed(measurements->n0_power_tot); - measurements->n0_power_tot_dBm = measurements->n0_power_tot_dB + 30 - 10 * log10(pow(2, 30)) - (rx_gain - rx_gain_offset) - dB_fixed(fp->ofdm_symbol_size); + if (nb_rb>0) measurements->n0_subband_power_avg_dB = dB_fixed(n0_power_tot2/nb_rb); - LOG_D(PHY, "In %s: tot n0 power %d dBm for %d RBs (tot N0 power = %d)\n", __FUNCTION__, measurements->n0_power_tot_dBm, nb_rb, measurements->n0_power_tot); - - } } + // Scope: This function computes the UL SNR from the UL channel estimates // // Todo: diff --git a/openair1/PHY/NR_ESTIMATION/nr_ul_estimation.h b/openair1/PHY/NR_ESTIMATION/nr_ul_estimation.h index 7bd004a4d4..7ecaa97f6a 100644 --- a/openair1/PHY/NR_ESTIMATION/nr_ul_estimation.h +++ b/openair1/PHY/NR_ESTIMATION/nr_ul_estimation.h @@ -47,7 +47,7 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB, unsigned short bwp_start_subcarrier, nfapi_nr_pusch_pdu_t *pusch_pdu); -void gNB_I0_measurements(PHY_VARS_gNB *gNB); +void gNB_I0_measurements(PHY_VARS_gNB *gNB,int first_symb,int num_symb); void nr_gnb_measurements(PHY_VARS_gNB *gNB, uint8_t ulsch_id, unsigned char harq_pid, unsigned char symbol); diff --git a/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h b/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h index e5e81109e4..5e6011c437 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h +++ b/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h @@ -357,6 +357,7 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB, nfapi_nr_pucch_pdu_t* pucch_pdu); void nr_decode_pucch0(PHY_VARS_gNB *gNB, + int frame, int slot, nfapi_nr_uci_pucch_pdu_format_0_1_t* uci_pdu, nfapi_nr_pucch_pdu_t* pucch_pdu); diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch.c b/openair1/PHY/NR_TRANSPORT/nr_ulsch.c index 0040f01544..4d0522bff5 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_ulsch.c +++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch.c @@ -137,11 +137,20 @@ void nr_ulsch_unscrambling_optim(int16_t* llr, #endif } -void dump_pusch_stats(PHY_VARS_gNB *gNB) { +#define STATSTRLEN 16384 +void dump_pusch_stats(FILE *fd,PHY_VARS_gNB *gNB) { + + char output[16384]; + int stroff=0; + + for (int i=0;iframe_parms.nb_antennas_rx;aa++) + stroff+=sprintf(output+stroff,"ULSCH RNTI %x: ulsch_power[%d] %d, ulsch_noise_power[%d] %d\n", + gNB->ulsch_stats[i].rnti, aa,gNB->ulsch_stats[i].power[aa],aa,gNB->ulsch_stats[i].noise_power[aa]); + AssertFatal(stroff<(STATSTRLEN-1000),"Increase STATSTRLEN\n"); - for (int i=0;iulsch_stats[i].rnti>0) - LOG_I(PHY,"ULSCH RNTI %x: round_trials %d(%1.1e):%d(%1.1e):%d(%1.1e):%d, current_Qm %d, current_RI %d, total_bytes RX/SCHED %d/%d\n", + stroff+=sprintf(output+stroff,"ULSCH RNTI %x: round_trials %d(%1.1e):%d(%1.1e):%d(%1.1e):%d, current_Qm %d, current_RI %d, total_bytes RX/SCHED %d/%d\n", gNB->ulsch_stats[i].rnti, gNB->ulsch_stats[i].round_trials[0], (double)gNB->ulsch_stats[i].round_trials[1]/gNB->ulsch_stats[i].round_trials[0], @@ -154,7 +163,7 @@ void dump_pusch_stats(PHY_VARS_gNB *gNB) { gNB->ulsch_stats[i].current_RI, gNB->ulsch_stats[i].total_bytes_rx, gNB->ulsch_stats[i].total_bytes_tx); - + } } void clear_pusch_stats(PHY_VARS_gNB *gNB) { diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch.h b/openair1/PHY/NR_TRANSPORT/nr_ulsch.h index de9b5f48c3..22264d7897 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_ulsch.h +++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch.h @@ -89,6 +89,6 @@ void nr_ulsch_procedures(PHY_VARS_gNB *gNB, uint8_t harq_pid); 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 dump_pusch_stats(FILE *fd,PHY_VARS_gNB *gNB); void clear_pusch_stats(PHY_VARS_gNB *gNB); diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch_demodulation.c b/openair1/PHY/NR_TRANSPORT/nr_ulsch_demodulation.c index 2a05477380..735972f427 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_ulsch_demodulation.c +++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch_demodulation.c @@ -1222,11 +1222,13 @@ int nr_rx_pusch(PHY_VARS_gNB *gNB, for (aarx = 0; aarx < frame_parms->nb_antennas_rx; aarx++) { gNB->pusch_vars[ulsch_id]->ulsch_power[aarx] = signal_energy_nodc(&gNB->pusch_vars[ulsch_id]->ul_ch_estimates[aarx][symbol*frame_parms->ofdm_symbol_size], rel15_ul->rb_size*12); - LOG_D(PHY,"ulsch_power[%d] symbol %d %f (%p)\n",aarx,symbol,dB_fixed_times10( gNB->pusch_vars[ulsch_id]->ulsch_power[aarx])/10.0, + LOG_D(PHY,"ulsch_power[%d] symbol %d %f (%p)\n",aarx,symbol,dB_fixed_x10( gNB->pusch_vars[ulsch_id]->ulsch_power[aarx])/10.0, &gNB->pusch_vars[ulsch_id]->ul_ch_estimates[aarx][symbol*frame_parms->ofdm_symbol_size]); if (gNB->pusch_vars[ulsch_id]->ulsch_power[aarx]==1) return (1); - } - + gNB->pusch_vars[ulsch_id]->ulsch_noise_power[aarx]=0; + for (int rb=0;rbrb_size;rb++) + gNB->pusch_vars[ulsch_id]->ulsch_noise_power[aarx]+=gNB->measurements.n0_subband_power[aarx][rel15_ul->bwp_start+rel15_ul->rb_start+rb]/rel15_ul->rb_size; + } } stop_meas(&gNB->ulsch_channel_estimation_stats); //---------------------------------------------------------- diff --git a/openair1/PHY/NR_TRANSPORT/pucch_rx.c b/openair1/PHY/NR_TRANSPORT/pucch_rx.c index b6c20a1b47..494e2cd057 100644 --- a/openair1/PHY/NR_TRANSPORT/pucch_rx.c +++ b/openair1/PHY/NR_TRANSPORT/pucch_rx.c @@ -161,6 +161,7 @@ int16_t idft12_im[12][12] = { void nr_decode_pucch0(PHY_VARS_gNB *gNB, + int frame, int slot, nfapi_nr_uci_pucch_pdu_format_0_1_t* uci_pdu, nfapi_nr_pucch_pdu_t* pucch_pdu) { @@ -178,6 +179,19 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB, "Either bit_len_harq (%d) or sr_flag (%d) must be > 0\n", pucch_pdu->bit_len_harq,pucch_pdu->sr_flag); + NR_gNB_UCI_STATS_t *uci_stats=NULL; + NR_gNB_UCI_STATS_t *first_uci_stats=NULL; + for (int i=0;iuci_stats[i].rnti == pucch_pdu->rnti) { + uci_stats = &gNB->uci_stats[i]; + break; + } else if (first_uci_stats == NULL && gNB->uci_stats[i].rnti == 0) first_uci_stats = &gNB->uci_stats[i]; + + if (uci_stats == NULL) { uci_stats=first_uci_stats; uci_stats->rnti = pucch_pdu->rnti;} + + AssertFatal(uci_stats!=NULL,"No stat index found\n"); + uci_stats->frame = frame; + if(pucch_pdu->bit_len_harq==0){ mcs=table1_mcs; nr_sequences=1; @@ -253,6 +267,7 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB, memset((void*)xr[0],0,24*sizeof(int16_t)); memset((void*)xr[1],0,24*sizeof(int16_t)); int n2; + for (l=0; lnr_of_symbols; l++) { l2 = l+pucch_pdu->start_symbol_index; re_offset[l] = (12*prb_offset[l]) + frame_parms->first_carrier_offset; @@ -286,8 +301,8 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB, #endif n2=0; for (n=0;n<12;n++,n2+=2) { - corr_re[l]+=(xr[l][n2]*idft12_re[seq_index][n]+xr[l][n2+1]*idft12_im[seq_index][n])>>15; - corr_im[l]+=(xr[l][n2]*idft12_im[seq_index][n]-xr[l][n2+1]*idft12_re[seq_index][n])>>15; + corr_re[l]+=(xr[l][n2]*idft12_re[seq_index][n]+xr[l][n2+1]*idft12_im[seq_index][n])>>15; + corr_im[l]+=(xr[l][n2]*idft12_im[seq_index][n]-xr[l][n2+1]*idft12_re[seq_index][n])>>15; } } @@ -312,6 +327,8 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB, if (temp>xrtmag) { xrtmag=temp; maxpos=i; + uci_stats->current_pucch0_stat0 = dB_fixed64((int64_t)corr_re[0]*corr_re[0] + (int64_t)corr_im[0]*corr_im[0]); + if (l==2) uci_stats->current_pucch0_stat1 = dB_fixed64((int64_t)corr_re[1]*corr_re[1] + (int64_t)corr_im[1]*corr_im[1]); } } if(nr_sequences>1) @@ -328,18 +345,19 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB, // estimate CQI for MAC (from antenna port 0 only) - int SNRtimes10 = dB_fixed_times10(signal_energy_nodc(&rxdataF[0][pucch_pdu->start_symbol_index*frame_parms->ofdm_symbol_size+re_offset[0]],12)) - (10*gNB->measurements.n0_power_tot_dB); + int max_n0 = uci_stats->pucch0_n00>uci_stats->pucch0_n01 ? uci_stats->pucch0_n00:uci_stats->pucch0_n01; + int SNRtimes10 = dB_fixed_times10(signal_energy_nodc(&rxdataF[0][pucch_pdu->start_symbol_index*frame_parms->ofdm_symbol_size+re_offset[0]],12)) - (10*max_n0); int cqi; if (SNRtimes10 < -640) cqi=0; else if (SNRtimes10 > 635) cqi=255; else cqi=(640+SNRtimes10)/5; + uci_stats->pucch0_thres = gNB->pucch0_thres + (10*max_n0); bool no_conf=false; if (nr_sequences>1) { - if ((xrtmag_dB<(11+dB_fixed(no_corr))) || (dB_fixed(av_corr)<(13+gNB->measurements.n0_power_tot_dB))) //TODO these are temporary threshold based on measurments with the phone + if (10*xrtmag_dB < uci_stats->pucch0_thres) no_conf=true; } - gNB->bad_pucch += no_conf; // first bit of bitmap for sr presence and second bit for acknack presence uci_pdu->pduBitmap = pucch_pdu->sr_flag | ((pucch_pdu->bit_len_harq>0)<<1); uci_pdu->pucch_format = 0; // format 0 @@ -347,12 +365,17 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB, uci_pdu->ul_cqi = cqi; uci_pdu->timing_advance = 0xffff; // currently not valid uci_pdu->rssi = 1280 - (10*dB_fixed(32767*32767)-dB_fixed_times10(signal_energy_nodc(&rxdataF[0][pucch_pdu->start_symbol_index*frame_parms->ofdm_symbol_size+re_offset[0]],12))); + + uci_stats->pucch0_n00 = gNB->measurements.n0_subband_power_tot_dB[prb_offset[0]]; + uci_stats->pucch0_n01 = gNB->measurements.n0_subband_power_tot_dB[prb_offset[1]]; if (pucch_pdu->bit_len_harq==0) { uci_pdu->harq = NULL; uci_pdu->sr = calloc(1,sizeof(*uci_pdu->sr)); - uci_pdu->sr->sr_confidence_level = (xrtmag_dB<(13+gNB->measurements.n0_power_tot_dB)) ? 1 : 0; + uci_pdu->sr->sr_confidence_level = no_conf ? 1 : 0; + uci_stats->pucch0_sr_trials++; if (xrtmag_dB>(gNB->measurements.n0_power_tot_dB)) { uci_pdu->sr->sr_indication = 1; + uci_stats->pucch0_positive_SR++; } else { uci_pdu->sr->sr_indication = 0; } @@ -360,16 +383,19 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB, else if (pucch_pdu->bit_len_harq==1) { uci_pdu->harq = calloc(1,sizeof(*uci_pdu->harq)); uci_pdu->harq->num_harq = 1; - uci_pdu->harq->harq_confidence_level = (no_conf) ? 1 : 0; + 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, "Slot %d HARQ value %d with confidence level (0 is good, 1 is bad) %d xrt_mag %d n0 %d\n", - slot,uci_pdu->harq->harq_list[0].harq_value,uci_pdu->harq->harq_confidence_level,xrtmag_dB,gNB->measurements.n0_power_tot_dB); + LOG_I(PHY, "Slot %d HARQ value %d with confidence level (0 is good, 1 is bad) %d xrt_mag %d n0 %d pucch0_thres %d\n", + slot,uci_pdu->harq->harq_list[0].harq_value,uci_pdu->harq->harq_confidence_level,xrtmag_dB,max_n0,uci_stats->pucch0_thres); if (pucch_pdu->sr_flag == 1) { uci_pdu->sr = calloc(1,sizeof(*uci_pdu->sr)); uci_pdu->sr->sr_indication = (index>1) ? 1 : 0; - uci_pdu->sr->sr_confidence_level = (no_conf) ? 1 : 0; + uci_pdu->sr->sr_confidence_level = no_conf ? 1 : 0; + uci_stats->pucch0_positive_SR++; } + uci_stats->pucch01_trials++; + } else { uci_pdu->harq = calloc(1,sizeof(*uci_pdu->harq)); @@ -1612,4 +1638,34 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB, uci_pdu->pduBitmap|=8; } } - + + +void dump_uci_stats(FILE *fd,PHY_VARS_gNB *gNB,int frame) { + + int strpos=0; + char output[16384]; + + for (int i=0;iuci_stats[i].rnti>0) { + NR_gNB_UCI_STATS_t *uci_stats = &gNB->uci_stats[i]; + if (uci_stats->pucch0_sr_trials > 0) + strpos+=sprintf(output+strpos,"UCI %d RNTI %x: pucch0_sr_trials %d, pucch0_n00 %d dB, pucch0_n01 %d dB, pucch0_sr_thres %d dB, current pucch1_stat0 %d dB, current pucch1_stat1 %d dB, positive SR count %d\n", + i,uci_stats->rnti,uci_stats->pucch0_sr_trials,uci_stats->pucch0_n00,uci_stats->pucch0_n01,uci_stats->pucch0_sr_thres,dB_fixed(uci_stats->current_pucch0_sr_stat0),dB_fixed(uci_stats->current_pucch0_sr_stat1),uci_stats->pucch0_positive_SR); + if (uci_stats->pucch01_trials > 0) + strpos+=sprintf(output+strpos,"UCI %d RNTI %x: pucch01_trials %d, pucch0_n00 %d dB, pucch0_n01 %d dB, pucch0_thres %d dB, current pucch0_stat0 %d dB, current pucch1_stat1 %d dB, pucch01_DTX %d\n", + i,uci_stats->rnti,uci_stats->pucch01_trials,uci_stats->pucch0_n01,uci_stats->pucch0_n01,uci_stats->pucch0_thres,dB_fixed(uci_stats->current_pucch0_stat0),dB_fixed(uci_stats->current_pucch0_stat1),uci_stats->pucch01_DTX); + + if (uci_stats->pucch02_trials > 0) + strpos+=sprintf(output+strpos,"UCI %d RNTI %x: pucch01_trials %d, pucch0_n00 %d dB, pucch0_n01 %d dB, pucch0_thres %d dB, current pucch0_stat0 %d dB, current pucch0_stat1 %d dB, pucch01_DTX %d\n", + i,uci_stats->rnti,uci_stats->pucch02_trials,uci_stats->pucch0_n00,uci_stats->pucch0_n01,uci_stats->pucch0_thres,dB_fixed(uci_stats->current_pucch0_stat0),dB_fixed(uci_stats->current_pucch0_stat1),uci_stats->pucch02_DTX); + + if (uci_stats->pucch2_trials > 0) + strpos+=sprintf(output+strpos,"UCI %d RNTI %x: pucch2_trials %d, pucch2_DTX %d\n", + i,uci_stats->rnti, + uci_stats->pucch2_trials, + uci_stats->pucch2_DTX); + } + } + if (fd) fprintf(fd,"%s",output); + else printf("%s",output); +} diff --git a/openair1/PHY/defs_gNB.h b/openair1/PHY/defs_gNB.h index a165aa1984..78a945f6e2 100644 --- a/openair1/PHY/defs_gNB.h +++ b/openair1/PHY/defs_gNB.h @@ -133,8 +133,31 @@ typedef struct { int total_bytes_rx; int current_Qm; int current_RI; + int power[NB_ANTENNAS_RX]; + int noise_power[NB_ANTENNAS_RX]; } NR_gNB_SCH_STATS_t; +typedef struct { + int frame; + uint16_t rnti; + int pucch0_sr_trials; + int pucch0_sr_thres; + int current_pucch0_sr_stat0; + int current_pucch0_sr_stat1; + int pucch0_positive_SR; + int pucch01_trials; + int pucch0_n00; + int pucch0_n01; + int pucch0_thres; + int current_pucch0_stat0; + int current_pucch0_stat1; + int pucch01_DTX; + int pucch02_trials; + int pucch02_DTX; + int pucch2_trials; + int pucch2_DTX; +} NR_gNB_UCI_STATS_t; + typedef struct { /// Pointers to variables related to DLSCH harq process NR_DL_gNB_HARQ_t harq_process; @@ -465,7 +488,9 @@ typedef struct { /// - second index: ? [0..168*N_RB_UL[ int32_t **ul_ch_magb1[8][8]; /// measured RX power based on DRS - int ulsch_power[2]; + int ulsch_power[8]; + /// measured RX noise power + int ulsch_noise_power[8]; /// \brief llr values. /// - first index: ? [0..1179743] (hard coded) int16_t *llr; @@ -562,8 +587,10 @@ typedef struct gNB_L1_proc_t_s { pthread_t pthread_single; /// pthread structure for asychronous RX/TX processing thread pthread_t pthread_asynch_rxtx; - /// pthread structure for printing time meas + /// pthread structure for dumping L1 stats pthread_t L1_stats_thread; + /// pthread structure for printing time meas + pthread_t process_stats_thread; /// flag to indicate first RX acquisition int first_rx; /// flag to indicate first TX transmission @@ -629,6 +656,8 @@ typedef struct { unsigned short n0_subband_power[MAX_NUM_RU_PER_gNB][275]; //! estimated avg noise power per RB per RX ant (dB) unsigned short n0_subband_power_dB[MAX_NUM_RU_PER_gNB][275]; + //! estimated avg subband noise power (dB) + unsigned short n0_subband_power_avg_dB; //! estimated avg noise power per RB (dB) short n0_subband_power_tot_dB[275]; //! estimated avg noise power per RB (dBm) @@ -734,7 +763,7 @@ typedef struct PHY_VARS_gNB_s { NR_gNB_SCH_STATS_t dlsch_stats[NUMBER_OF_NR_SCH_STATS_MAX]; /// statistics for ULSCH measurement collection NR_gNB_SCH_STATS_t ulsch_stats[NUMBER_OF_NR_SCH_STATS_MAX]; - + NR_gNB_UCI_STATS_t uci_stats[NUMBER_OF_NR_UCI_STATS_MAX]; t_nrPolar_params *uci_polarParams; uint8_t pbch_configured; @@ -801,6 +830,7 @@ typedef struct PHY_VARS_gNB_s { int prach_energy_counter; int pucch0_thres; + int prach_thres; uint64_t bad_pucch; /* time_stats_t phy_proc; diff --git a/openair1/SCHED_NR/nr_prach_procedures.c b/openair1/SCHED_NR/nr_prach_procedures.c index 5a98b17cea..533dbb8e1a 100644 --- a/openair1/SCHED_NR/nr_prach_procedures.c +++ b/openair1/SCHED_NR/nr_prach_procedures.c @@ -122,7 +122,7 @@ void L1_nr_prach_procedures(PHY_VARS_gNB *gNB,int frame,int slot) { gNB->prach_energy_counter); if ((gNB->prach_energy_counter == 100) && - (max_preamble_energy[0] > gNB->measurements.prach_I0+100)) { + (max_preamble_energy[0] > gNB->measurements.prach_I0+gNB->prach_thres)) { LOG_I(PHY,"[gNB %d][RAPROC] Frame %d, slot %d Initiating RA procedure with preamble %d, energy %d.%d dB, delay %d start symbol %u freq index %u\n", gNB->Mod_id, diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index 9110e04331..313ea25a2e 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -378,12 +378,12 @@ void nr_fill_indication(PHY_VARS_gNB *gNB, int frame, int slot_rx, int ULSCH_id, if (timing_advance_update < 0) timing_advance_update = 0; if (timing_advance_update > 63) timing_advance_update = 63; - LOG_D(PHY, "Estimated timing advance PUSCH is = %d, timing_advance_update is %d \n", sync_pos,timing_advance_update); + LOG_I(PHY, "Estimated timing advance PUSCH is = %d, timing_advance_update is %d \n", sync_pos,timing_advance_update); // estimate UL_CQI for MAC (from antenna port 0 only) - int SNRtimes10 = dB_fixed_times10(gNB->pusch_vars[ULSCH_id]->ulsch_power[0]) - (10*gNB->measurements.n0_power_dB[0]); + int SNRtimes10 = dB_fixed_x10(gNB->pusch_vars[ULSCH_id]->ulsch_power[0]) - dB_fixed_x10(gNB->pusch_vars[ULSCH_id]->ulsch_noise_power[0]); - LOG_D(PHY, "Estimated SNR for PUSCH is = %f dB (ulsch_power %f)\n", SNRtimes10/10,dB_fixed_times10(gNB->pusch_vars[ULSCH_id]->ulsch_power[0])/10.0); + LOG_I(PHY, "Estimated SNR for PUSCH is = %f dB (ulsch_power %f, noise %f)\n", SNRtimes10/10.0,dB_fixed_x10(gNB->pusch_vars[ULSCH_id]->ulsch_power[0])/10.0,dB_fixed_x10(gNB->pusch_vars[ULSCH_id]->ulsch_noise_power[0])/10.0); if (SNRtimes10 < -640) cqi=0; else if (SNRtimes10 > 635) cqi=255; @@ -533,7 +533,17 @@ void phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) if (gNB->frame_parms.frame_type == TDD) fill_ul_rb_mask(gNB, frame_rx, slot_rx); - gNB_I0_measurements(gNB); + int first_symb=0,num_symb=0; + if (gNB->frame_parms.frame_type == TDD) + for(int symbol_count=0; symbol_countgNB_config.tdd_table.max_tdd_periodicity_list[slot_rx].max_num_of_symbol_per_slot_list[symbol_count].slot_config.value==1) { + if (num_symb==0) first_symb=symbol_count; + num_symb++; + } + } + else num_symb=14; + + gNB_I0_measurements(gNB,first_symb,num_symb); int offset = 10*gNB->frame_parms.ofdm_symbol_size + gNB->frame_parms.first_carrier_offset; int power_rxF = signal_energy_nodc(&gNB->common_vars.rxdataF[0][offset+(47*12)],12*18); @@ -561,7 +571,8 @@ void phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) nfapi_nr_uci_pucch_pdu_format_0_1_t *uci_pdu_format0 = &gNB->uci_pdu_list[num_ucis].pucch_pdu_format_0_1; nr_decode_pucch0(gNB, - slot_rx, + frame_rx, + slot_rx, uci_pdu_format0, pucch_pdu); @@ -663,11 +674,6 @@ void phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) } } // figure out a better way to choose slot_rx, 19 is ok for a particular TDD configuration with 30kHz SCS - if ((frame_rx&127) == 0 && slot_rx==19) { - dump_pusch_stats(gNB); - LOG_I(PHY, "Number of bad PUCCH received: %lu\n", gNB->bad_pucch); - } - if (pucch_decode_done || pusch_decode_done) { T(T_GNB_PHY_PUCCH_PUSCH_IQ, T_INT(frame_rx), T_INT(slot_rx), T_BUFFER(&gNB->common_vars.rxdataF[0][0], gNB->frame_parms.symbols_per_slot * gNB->frame_parms.ofdm_symbol_size * 4)); } diff --git a/openair2/COMMON/platform_constants.h b/openair2/COMMON/platform_constants.h index 3915f12bb9..be6927ec37 100644 --- a/openair2/COMMON/platform_constants.h +++ b/openair2/COMMON/platform_constants.h @@ -90,6 +90,7 @@ #define NUMBER_OF_NR_DLSCH_MAX 2//16 #define NUMBER_OF_NR_ULSCH_MAX 2//16 #define NUMBER_OF_NR_SCH_STATS_MAX 16 +#define NUMBER_OF_NR_UCI_STATS_MAX 16 #define NUMBER_OF_NR_PUCCH_MAX 16 #define NUMBER_OF_NR_SR_MAX 16 #define NUMBER_OF_NR_PDCCH_MAX 16 diff --git a/openair2/GNB_APP/L1_nr_paramdef.h b/openair2/GNB_APP/L1_nr_paramdef.h index 67be560778..4bcc9928ed 100644 --- a/openair2/GNB_APP/L1_nr_paramdef.h +++ b/openair2/GNB_APP/L1_nr_paramdef.h @@ -47,7 +47,8 @@ #define CONFIG_STRING_L1_REMOTE_N_PORTD "remote_n_portd" #define CONFIG_STRING_L1_TRANSPORT_N_PREFERENCE "tr_n_preference" #define CONFIG_STRING_L1_PUSCH_PROC_THREADS "pusch_proc_threads" - +#define CONFIG_STRING_L1_PUCCH0_DTX_THRESHOLD "pucch0_dtx_threshold" +#define CONFIG_STRING_L1_PRACH_DTX_THRESHOLD "prach_dtx_threshold" /*----------------------------------------------------------------------------------------------------------------------------------------------------*/ /* L1 configuration parameters */ /* optname helpstr paramflags XXXptr defXXXval type numelt */ @@ -62,7 +63,9 @@ {CONFIG_STRING_L1_REMOTE_N_PORTC, NULL, 0, uptr:NULL, defintval:50030, TYPE_UINT, 0}, \ {CONFIG_STRING_L1_LOCAL_N_PORTD, NULL, 0, uptr:NULL, defintval:50031, TYPE_UINT, 0}, \ {CONFIG_STRING_L1_REMOTE_N_PORTD, NULL, 0, uptr:NULL, defintval:50031, TYPE_UINT, 0}, \ -{CONFIG_STRING_L1_PUSCH_PROC_THREADS, NULL, 0, uptr:NULL, defintval:1, TYPE_UINT, 0} \ +{CONFIG_STRING_L1_PUSCH_PROC_THREADS, NULL, 0, uptr:NULL, defintval:1, TYPE_UINT, 0}, \ +{CONFIG_STRING_L1_PUCCH0_DTX_THRESHOLD, NULL, 0, uptr:NULL, defintval:100, TYPE_UINT, 0}, \ +{CONFIG_STRING_L1_PRACH_DTX_THRESHOLD, NULL, 0, uptr:NULL, defintval:200, TYPE_UINT, 0} \ } #define L1_CC_IDX 0 #define L1_TRANSPORT_N_PREFERENCE_IDX 1 @@ -74,6 +77,8 @@ #define L1_LOCAL_N_PORTD_IDX 7 #define L1_REMOTE_N_PORTD_IDX 8 #define L1_PUSCH_PROC_THREADS 9 +#define L1_PUCCH0_DTX_THRESHOLD 10 +#define L1_PRACH_DTX_THRESHOLD 11 /*----------------------------------------------------------------------------------------------------------------------------------------------------*/ #endif diff --git a/openair2/GNB_APP/gnb_config.c b/openair2/GNB_APP/gnb_config.c index cf51662c5c..272579fd62 100644 --- a/openair2/GNB_APP/gnb_config.c +++ b/openair2/GNB_APP/gnb_config.c @@ -566,11 +566,12 @@ void RCconfig_NR_L1(void) { RC.gNB[j] = (PHY_VARS_gNB *)malloc(sizeof(PHY_VARS_gNB)); LOG_I(NR_PHY,"RC.gNB[%d] = %p\n",j,RC.gNB[j]); memset(RC.gNB[j],0,sizeof(PHY_VARS_gNB)); - RC.gNB[j]->Mod_id = j; + RC.gNB[j]->Mod_id = j; } RC.gNB[j]->pusch_proc_threads = *(L1_ParamList.paramarray[j][L1_PUSCH_PROC_THREADS].uptr); - + RC.gNB[j]->pucch0_thres = *(L1_ParamList.paramarray[j][L1_PUCCH0_DTX_THRESHOLD].uptr); + RC.gNB[j]->prach_thres = *(L1_ParamList.paramarray[j][L1_PRACH_DTX_THRESHOLD].uptr); if(strcmp(*(L1_ParamList.paramarray[j][L1_TRANSPORT_N_PREFERENCE_IDX].strptr), "local_mac") == 0) { //sf_ahead = 2; // Need 4 subframe gap between RX and TX }else if (strcmp(*(L1_ParamList.paramarray[j][L1_TRANSPORT_N_PREFERENCE_IDX].strptr), "nfapi") == 0) { diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index 8de3c02d08..622a46b766 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -1247,9 +1247,9 @@ void fill_dci_pdu_rel15(const NR_ServingCellConfigCommon_t *scc, case NR_UL_DCI_FORMAT_0_0: switch (rnti_type) { case NR_RNTI_C: - // indicating a DL DCI format 1bit + // indicating a UL DCI format 1bit pos=1; - *dci_pdu |= ((uint64_t)dci_pdu_rel15->format_indicator & 1) << (dci_size - pos); + //*dci_pdu |= ((uint64_t)dci_pdu_rel15->format_indicator & 1) << (dci_size - pos); // Freq domain assignment max 16 bit fsize = (int)ceil(log2((N_RB * (N_RB + 1)) >> 1)); pos+=fsize; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c index f28b5f7bf8..19f4c58d33 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c @@ -969,9 +969,10 @@ void handle_nr_uci_pucch_0_1(module_id_t mod_id, NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; // tpc (power control) - sched_ctrl->tpc1 = nr_get_tpc(RC.nrmac[mod_id]->pucch_target_snrx10, - uci_01->ul_cqi, - 30); + if (uci_01->harq->harq_confidence_level == 0) + sched_ctrl->tpc1 = nr_get_tpc(RC.nrmac[mod_id]->pucch_target_snrx10, + uci_01->ul_cqi, + 30); LOG_I(NR_MAC,"pucch tpc %d\n",sched_ctrl->tpc1); NR_ServingCellConfigCommon_t *scc = RC.nrmac[mod_id]->common_channels->ServingCellConfigCommon; const int num_slots = nr_slots_per_frame[*scc->ssbSubcarrierSpacing]; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c index 294133ed8e..58b01d68b9 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c @@ -452,7 +452,7 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP, T_BUFFER(sduP, sdu_lenP)); UE_info->mac_stats[UE_id].ulsch_total_bytes_rx += sdu_lenP; - LOG_D(NR_MAC, "[gNB %d][PUSCH %d] CC_id %d %d.%d Received ULSCH sdu from PHY (rnti %x, UE_id %d) ul_cqi %d sduP %p\n", + LOG_I(NR_MAC, "[gNB %d][PUSCH %d] CC_id %d %d.%d Received ULSCH sdu from PHY (rnti %x, UE_id %d) ul_cqi %d TA %d sduP %p\n", gnb_mod_idP, harq_pid, CC_idP, @@ -461,6 +461,7 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP, current_rnti, UE_id, ul_cqi, + timing_advance, sduP); // if not missed detection (10dB threshold for now) @@ -1081,7 +1082,7 @@ void nr_schedule_ulsch(module_id_t module_id, } UE_info->mac_stats[UE_id].ulsch_current_bytes = sched_pusch->tb_size; - LOG_D(NR_MAC, + LOG_I(NR_MAC, "%4d.%2d RNTI %04x UL sched %4d.%2d start %d RBS %d MCS %d TBS %d HARQ PID %d round %d NDI %d\n", frame, slot, @@ -1239,7 +1240,7 @@ void nr_schedule_ulsch(module_id_t module_id, pdcch_pdu_bwp_coreset[bwpid][coresetid] = pdcch_pdu; } - LOG_D(NR_MAC,"Configuring ULDCI/PDCCH in %d.%d\n", frame,slot); + LOG_I(NR_MAC,"Configuring ULDCI/PDCCH in %d.%d\n", frame,slot); /* Fill PDCCH DL DCI PDU */ nfapi_nr_dl_dci_pdu_t *dci_pdu = &pdcch_pdu->dci_pdu[pdcch_pdu->numDlDci]; diff --git a/openair2/LAYER2/nr_pdcp/nr_pdcp_entity.c b/openair2/LAYER2/nr_pdcp/nr_pdcp_entity.c index d6b0980753..d09a1cbb5e 100644 --- a/openair2/LAYER2/nr_pdcp/nr_pdcp_entity.c +++ b/openair2/LAYER2/nr_pdcp/nr_pdcp_entity.c @@ -65,8 +65,9 @@ static void nr_pdcp_entity_recv_pdu(nr_pdcp_entity_t *entity, buffer[2]; header_size = 3; } - - if (entity->has_integrity) { + /* SRBs always have MAC-I, even if integrity is not active */ + if (entity->has_integrity + || entity->type == NR_PDCP_SRB) { integrity_size = 4; } else { integrity_size = 0; @@ -181,7 +182,9 @@ static void nr_pdcp_entity_recv_sdu(nr_pdcp_entity_t *entity, header_size = 3; } - if (entity->has_integrity) { +/* SRBs always have MAC-I, even if integrity is not active */ + if (entity->has_integrity + || entity->type == NR_PDCP_SRB) { integrity_size = 4; } else { integrity_size = 0; @@ -194,6 +197,9 @@ static void nr_pdcp_entity_recv_sdu(nr_pdcp_entity_t *entity, (unsigned char *)buf + header_size + size, (unsigned char *)buf, header_size + size, entity->rb_id, count, entity->is_gnb ? 1 : 0); + else if (integrity_size == 4) + /* set MAC-I to 0 for SRBs with integrity not active */ + memset(buf + header_size + size, 0, 4); if (entity->has_ciphering) entity->cipher(entity->security_context, diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index c2cfe4e933..6dca7405b6 100644 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -1151,7 +1151,7 @@ void fill_initial_cellGroupConfig(rnti_t rnti, physicalCellGroupConfig = calloc(1,sizeof(*physicalCellGroupConfig)); physicalCellGroupConfig->p_NR_FR1 = calloc(1,sizeof(*physicalCellGroupConfig->p_NR_FR1)); - *physicalCellGroupConfig->p_NR_FR1 = 0; + *physicalCellGroupConfig->p_NR_FR1 = 20; physicalCellGroupConfig->pdsch_HARQ_ACK_Codebook = NR_PhysicalCellGroupConfig__pdsch_HARQ_ACK_Codebook_dynamic; cellGroupConfig->physicalCellGroupConfig = physicalCellGroupConfig;