diff --git a/openair1/PHY/LTE_TRANSPORT/defs.h b/openair1/PHY/LTE_TRANSPORT/defs.h index 258d5449d9480ca3178e5ee77063680cc0e29649..87f52c962468b62940cd945f063f066960cb103b 100644 --- a/openair1/PHY/LTE_TRANSPORT/defs.h +++ b/openair1/PHY/LTE_TRANSPORT/defs.h @@ -568,6 +568,8 @@ typedef struct { uint16_t n_pucch_3[2]; /// TDD Bundling/multiplexing flag uint8_t tdd_bundling; + /// Received Energy + uint32_t stat; #ifdef Rel14 /// non BL/CE, CEmodeA, CEmodeB UE_type_t ue_type; diff --git a/openair1/PHY/LTE_TRANSPORT/pucch.c b/openair1/PHY/LTE_TRANSPORT/pucch.c index aec0c3fe6c8d445cb3fab273fd897c6a10fb83dc..c33d63bd18c0d085ef4988ac916ff028d22e1980 100644 --- a/openair1/PHY/LTE_TRANSPORT/pucch.c +++ b/openair1/PHY/LTE_TRANSPORT/pucch.c @@ -1790,12 +1790,9 @@ uint32_t rx_pucch(PHY_VARS_eNB *eNB, LTE_eNB_COMMON *common_vars = &eNB->common_vars; LTE_DL_FRAME_PARMS *frame_parms = &eNB->frame_parms; // PUCCH_CONFIG_DEDICATED *pucch_config_dedicated = &eNB->pucch_config_dedicated[UE_id]; - int8_t sigma2_dB = eNB->measurements.n0_subband_power_tot_dB[0]-10; - uint32_t *Po_PUCCH = &(eNB->UE_stats[UE_id].Po_PUCCH); - int32_t *Po_PUCCH_dBm = &(eNB->UE_stats[UE_id].Po_PUCCH_dBm); - uint32_t *Po_PUCCH1_below = &(eNB->UE_stats[UE_id].Po_PUCCH1_below); - uint32_t *Po_PUCCH1_above = &(eNB->UE_stats[UE_id].Po_PUCCH1_above); - int32_t *Po_PUCCH_update = &(eNB->UE_stats[UE_id].Po_PUCCH_update); + + int8_t sigma2_dB = 20;//eNB->measurements.n0_subband_power_tot_dB[0]-10; + uint32_t u,v,n,aa; uint32_t z[12*14]; int16_t *zptr; @@ -2154,6 +2151,7 @@ uint32_t rx_pucch(PHY_VARS_eNB *eNB, LOG_I(PHY,"[eNB] PUCCH fmt1: stat_max : %d, sigma2_dB %d (%d, %d), phase_max : %d\n",dB_fixed(stat_max),sigma2_dB,eNB->measurements.n0_subband_power_tot_dBm[6],pucch1_thres,phase_max); #endif + eNB->pucch1_stats[UE_id][(subframe<<10)+eNB->pucch1_stats_cnt[UE_id][subframe]] = stat_max; eNB->pucch1_stats_thres[UE_id][(subframe<<10)+eNB->pucch1_stats_cnt[UE_id][subframe]] = sigma2_dB+pucch1_thres; eNB->pucch1_stats_cnt[UE_id][subframe] = (eNB->pucch1_stats_cnt[UE_id][subframe]+1)&1023; @@ -2174,15 +2172,10 @@ uint32_t rx_pucch(PHY_VARS_eNB *eNB, // This is a moving average of the PUCCH1 statistics conditioned on being above or below the threshold if (sigma2_dB<(dB_fixed(stat_max)-pucch1_thres)) { *payload = 1; - *Po_PUCCH1_above = ((*Po_PUCCH1_above<<9) + (stat_max<<9)+1024)>>10; - //LOG_I(PHY,"[eNB] PUCCH fmt1: stat_max : %d, sigma2_dB %d (%d, %d), phase_max : %d\n",dB_fixed(stat_max),sigma2_dB,eNB->PHY_measurements_eNB[0].n0_power_tot_dBm,pucch1_thres,phase_max); } else { *payload = 0; - *Po_PUCCH1_below = ((*Po_PUCCH1_below<<9) + (stat_max<<9)+1024)>>10; } - //printf("[eNB] PUCCH fmt1: stat_max : %d, sigma2_dB %d (I0 %d dBm, thres %d), Po_PUCCH1_below/above : %d / %d\n",dB_fixed(stat_max),sigma2_dB,eNB->measurements[0].n0_subband_power_tot_dBm[6],pucch1_thres,dB_fixed(*Po_PUCCH1_below),dB_fixed(*Po_PUCCH1_above)); - *Po_PUCCH_update = 1; if (UE_id==0) { VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_UE0_SR_ENERGY,dB_fixed(stat_max)); VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_UE0_SR_THRES,sigma2_dB+pucch1_thres); @@ -2283,23 +2276,10 @@ uint32_t rx_pucch(PHY_VARS_eNB *eNB, stat_re=0; stat_im=0; - // printf("PUCCH1A : Po_PUCCH before %d dB (%d)\n",dB_fixed(*Po_PUCCH),*Po_PUCCH); - *Po_PUCCH = ((*Po_PUCCH>>1) + ((stat_max)>>1)); - *Po_PUCCH_dBm = dB_fixed(*Po_PUCCH/frame_parms->N_RB_UL) - eNB->rx_total_gain_dB; - *Po_PUCCH_update = 1; - /* - printf("PUCCH1A : stat_max %d (%d,%d,%d) => Po_PUCCH %d\n", - dB_fixed(stat_max), - pucch1_thres+sigma2_dB, - pucch1_thres, - sigma2_dB, - dB_fixed(*Po_PUCCH)); - */ + // Do detection now if (sigma2_dB<(dB_fixed(stat_max)-pucch1_thres)) {// - *Po_PUCCH = ((*Po_PUCCH*1023) + stat_max)>>10; - chL = (nsymb>>1)-4; chest_mag=0; cfo = (frame_parms->Ncp==0) ? &cfo_pucch_np[14*phase_max] : &cfo_pucch_ep[12*phase_max]; @@ -2534,45 +2514,3 @@ uint32_t rx_pucch(PHY_VARS_eNB *eNB, return((int32_t)stat_max); } - - -int32_t rx_pucch_emul(PHY_VARS_eNB *eNB, - eNB_rxtx_proc_t *proc, - uint8_t UE_index, - PUCCH_FMT_t fmt, - uint8_t n1_pucch_sel, - uint8_t *payload) - -{ - uint8_t UE_id; - uint16_t rnti; - int subframe = proc->subframe_rx; - uint8_t CC_id = eNB->CC_id; - - rnti = eNB->ulsch[UE_index]->rnti; - - for (UE_id=0; UE_id<NB_UE_INST; UE_id++) { - if (rnti == PHY_vars_UE_g[UE_id][CC_id]->pdcch_vars[PHY_vars_UE_g[UE_id][CC_id]->current_thread_id[subframe]][0]->crnti) - break; - } - - if (UE_id==NB_UE_INST) { - LOG_W(PHY,"rx_pucch_emul: Didn't find UE with rnti %x\n",rnti); - return(-1); - } - - if (fmt == pucch_format1) { - payload[0] = PHY_vars_UE_g[UE_id][CC_id]->sr[subframe]; - } else if (fmt == pucch_format1a) { - payload[0] = PHY_vars_UE_g[UE_id][CC_id]->pucch_payload[0]; - } else if (fmt == pucch_format1b) { - payload[0] = PHY_vars_UE_g[UE_id][CC_id]->pucch_payload[0]; - payload[1] = PHY_vars_UE_g[UE_id][CC_id]->pucch_payload[1]; - } else - LOG_E(PHY,"[eNB] Frame %d: Can't handle formats 2/2a/2b\n",proc->frame_rx); - - if (PHY_vars_UE_g[UE_id][CC_id]->pucch_sel[subframe] == n1_pucch_sel) - return(99); - else - return(0); -} diff --git a/openair1/SCHED/fapi_l1.h b/openair1/SCHED/fapi_l1.h index 62e427563043c540065069841cd4d909a228c7d9..cae9d271c3e51a656aaf8ab1f4f21c58b4dc1e1c 100644 --- a/openair1/SCHED/fapi_l1.h +++ b/openair1/SCHED/fapi_l1.h @@ -39,7 +39,7 @@ void fill_uci_harq_indication(PHY_VARS_eNB *eNB,LTE_eNB_UCI *uci,int frame,int subframe,uint8_t *harq_ack,uint8_t tdd_mapping_mode,uint16_t tdd_multiplexing_mask); void fill_ulsch_harq_indication(PHY_VARS_eNB *eNB,LTE_UL_eNB_HARQ_t *ulsch_harq,uint16_t rnti, int frame,int subframe,int bundling); void fill_ulsch_cqi_indication(PHY_VARS_eNB *eNB,uint16_t frame,uint8_t subframe,LTE_UL_eNB_HARQ_t *ulsch_harq,uint16_t rnti); -void fill_sr_indication(PHY_VARS_eNB *eNB,uint16_t rnti,int frame,int subframe); +void fill_sr_indication(PHY_VARS_eNB *eNB,uint16_t rnti,int frame,int subframe,uint32_t stat); void fill_rx_indication(PHY_VARS_eNB *eNB,int UE_id,int frame,int subframe); void fill_crc_indication(PHY_VARS_eNB *eNB,int UE_id,int frame,int subframe,uint8_t crc_flag); void handle_nfapi_dci_dl_pdu(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,nfapi_dl_config_request_pdu_t *dl_config_pdu); diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c index 92bbec96d7ba3e389a49dc513036987b8da27e45..2d91a04baf688161af2c385e7ab1624d7c33d4d0 100644 --- a/openair1/SCHED/phy_procedures_lte_eNb.c +++ b/openair1/SCHED/phy_procedures_lte_eNb.c @@ -752,8 +752,8 @@ void srs_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) { } } -void fill_sr_indication(PHY_VARS_eNB *eNB,uint16_t rnti,int frame,int subframe) { - +void fill_sr_indication(PHY_VARS_eNB *eNB,uint16_t rnti,int frame,int subframe,uint32_t stat) { + pthread_mutex_lock(&eNB->UL_INFO_mutex); nfapi_sr_indication_pdu_t *pdu = &eNB->UL_INFO.sr_ind.sr_pdu_list[eNB->UL_INFO.sr_ind.number_of_srs]; @@ -761,6 +761,14 @@ void fill_sr_indication(PHY_VARS_eNB *eNB,uint16_t rnti,int frame,int subframe) // pdu->rx_ue_information.handle = handle; pdu->rx_ue_information.rnti = rnti; + int SNRtimes10 = dB_fixed_times10(stat) - 200;//(10*eNB->measurements.n0_power_dB[0]); + + + if (SNRtimes10 < -640) pdu->ul_cqi_information.ul_cqi=0; + else if (SNRtimes10 > 635) pdu->ul_cqi_information.ul_cqi=255; + else pdu->ul_cqi_information.ul_cqi=(640+SNRtimes10)/5; + pdu->ul_cqi_information.channel = 0; + eNB->UL_INFO.sr_ind.number_of_srs++; pthread_mutex_unlock(&eNB->UL_INFO_mutex); } @@ -838,7 +846,7 @@ void uci_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) uci->n_pucch_1_0_sr[0]); if (uci->type == SR) { if (SR_payload == 1) { - fill_sr_indication(eNB,uci->rnti,frame,subframe); + fill_sr_indication(eNB,uci->rnti,frame,subframe,metric_SR); return; } else { @@ -867,7 +875,7 @@ void uci_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) /* cancel SR detection if reception on n1_pucch0 is better than on SR PUCCH resource index, otherwise send it up to MAC */ if (uci->type==HARQ_SR && metric[0] > metric_SR) SR_payload = 0; - else if (SR_payload == 1) fill_sr_indication(eNB,uci->rnti,frame,subframe); + else if (SR_payload == 1) fill_sr_indication(eNB,uci->rnti,frame,subframe,metric_SR); if (uci->type==HARQ_SR && metric[0] <= metric_SR) { /* when transmitting ACK/NACK on SR PUCCH resource index, SR payload is always 1 */ @@ -1740,7 +1748,13 @@ void fill_ulsch_harq_indication(PHY_VARS_eNB *eNB,LTE_UL_eNB_HARQ_t *ulsch_harq, } -void fill_uci_harq_indication(PHY_VARS_eNB *eNB,LTE_eNB_UCI *uci,int frame,int subframe,uint8_t *harq_ack,uint8_t tdd_mapping_mode,uint16_t tdd_multiplexing_mask) { +void fill_uci_harq_indication(PHY_VARS_eNB *eNB, + LTE_eNB_UCI *uci, + int frame, + int subframe, + uint8_t *harq_ack, + uint8_t tdd_mapping_mode, + uint16_t tdd_multiplexing_mask) { int UE_id=find_dlsch(uci->rnti,eNB,SEARCH_EXIST); @@ -1752,6 +1766,14 @@ void fill_uci_harq_indication(PHY_VARS_eNB *eNB,LTE_eNB_UCI *uci,int frame,int s // pdu->rx_ue_information.handle = handle; pdu->rx_ue_information.rnti = uci->rnti; + // estimate UL_CQI for MAC (from antenna port 0 only) + int SNRtimes10 = dB_fixed_times10(uci->stat) - 200;//(10*eNB->measurements.n0_power_dB[0]); + + + if (SNRtimes10 < -640) pdu->ul_cqi_information.ul_cqi=0; + else if (SNRtimes10 > 635) pdu->ul_cqi_information.ul_cqi=255; + else pdu->ul_cqi_information.ul_cqi=(640+SNRtimes10)/5; + pdu->ul_cqi_information.channel = 0; if (eNB->frame_parms.frame_type == FDD) { if (uci->pucch_fmt == pucch_format1a) { diff --git a/openair2/LAYER2/MAC/defs.h b/openair2/LAYER2/MAC/defs.h index 177a5190c4a1c0b031c100cb4317d1ba61e3d4b1..c2f70d94a3ae3d713963d5ed4a90d307f7be61d0 100644 --- a/openair2/LAYER2/MAC/defs.h +++ b/openair2/LAYER2/MAC/defs.h @@ -819,8 +819,11 @@ typedef struct { int32_t phr_received; uint8_t periodic_ri_received[NFAPI_CC_MAX]; uint8_t aperiodic_ri_received[NFAPI_CC_MAX]; + uint8_t pucch1_cqi_update[NFAPI_CC_MAX]; uint8_t pucch1_snr[NFAPI_CC_MAX]; + uint8_t pucch2_cqi_update[NFAPI_CC_MAX]; uint8_t pucch2_snr[NFAPI_CC_MAX]; + uint8_t pucch3_cqi_update[NFAPI_CC_MAX]; uint8_t pucch3_snr[NFAPI_CC_MAX]; uint8_t pusch_snr[NFAPI_CC_MAX]; uint16_t feedback_cnt[NFAPI_CC_MAX]; diff --git a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c index 93ef37fb358cdbbae2c985ab4e88a1a46b40b6f6..b1e3e53725a743be7e9f8dabcdf6c3ae783ec2d4 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c @@ -1165,16 +1165,17 @@ schedule_ue_spec( // do PUCCH power control // this is the normalized RX power eNB_UE_stats = &UE_list->eNB_UE_stats[CC_id][UE_id]; - normalized_rx_power = eNB_UE_stats->Po_PUCCH_dBm; - target_rx_power = cc[CC_id].radioResourceConfigCommon->uplinkPowerControlCommon.p0_NominalPUCCH + 20; + + normalized_rx_power = ue_sched_ctl->pucch1_snr[CC_id]; + target_rx_power = 20; // this assumes accumulated tpc // make sure that we are only sending a tpc update once a frame, otherwise the control loop will freak out int32_t framex10psubframe = UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_frame*10+UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_subframe; if (((framex10psubframe+10)<=(frameP*10+subframeP)) || //normal case ((framex10psubframe>(frameP*10+subframeP)) && (((10240-framex10psubframe+frameP*10+subframeP)>=10)))) //frame wrap-around - if (eNB_UE_stats->Po_PUCCH_update == 1) { - eNB_UE_stats->Po_PUCCH_update = 0; + if (ue_sched_ctl->pucch1_cqi_update[CC_id] == 1) { + ue_sched_ctl->pucch1_cqi_update[CC_id] = 0; UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_frame=frameP; UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_subframe=subframeP; @@ -1188,10 +1189,10 @@ schedule_ue_spec( } else { tpc = 1; //0 } - /* - LOG_I(MAC,"[eNB %d] DLSCH scheduler: frame %d, subframe %d, harq_pid %d, tpc %d, accumulated %d, normalized/target rx power %d/%d\n", + + LOG_D(MAC,"[eNB %d] DLSCH scheduler: frame %d, subframe %d, harq_pid %d, tpc %d, accumulated %d, normalized/target rx power %d/%d\n", module_idP,frameP, subframeP,harq_pid,tpc, - tpc_accumulated,normalized_rx_power,target_rx_power);*/ + tpc_accumulated,normalized_rx_power,target_rx_power); } // Po_PUCCH has been updated else { diff --git a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c index 7650372989151a1dc78e906afb42d2184ed8e143..04f0b476a7477b0e4b1b90c7690ff688ffbace6a 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c @@ -3626,6 +3626,12 @@ void SR_indication(module_id_t mod_idP, int cc_idP, frame_t frameP, sub_frame_t if (UE_id != -1) { if (mac_eNB_get_rrc_status(mod_idP,UE_RNTI(mod_idP,UE_id)) < RRC_CONNECTED) LOG_I(MAC,"[eNB %d][SR %x] Frame %d subframeP %d Signaling SR for UE %d on CC_id %d\n",mod_idP,rntiP,frameP,subframeP, UE_id,cc_idP); + + UE_sched_ctrl *sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; + + sched_ctl->pucch1_snr[cc_idP] = ul_cqi; + sched_ctl->pucch1_cqi_update[cc_idP] = 1; + UE_list->UE_template[cc_idP][UE_id].ul_SR = 1; UE_list->UE_template[cc_idP][UE_id].ul_active = TRUE; VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_SR_INDICATION,1); @@ -3667,9 +3673,11 @@ void harq_indication(module_id_t mod_idP, int CC_idP, frame_t frameP, sub_frame_ UE_sched_ctrl *sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; COMMON_channels_t *cc = &RC.mac[mod_idP]->common_channels[CC_idP]; // extract HARQ Information - LOG_D(MAC,"Frame %d, subframe %d: Received harq indication (%d) from UE %d/%x\n",frameP,subframeP,channel,UE_id,rnti); + LOG_D(MAC,"Frame %d, subframe %d: Received harq indication (%d) from UE %d/%x, ul_cqi %d\n",frameP,subframeP,channel,UE_id,rnti,ul_cqi); if (cc->tdd_Config) extract_harq(mod_idP,CC_idP,UE_id,frameP,subframeP,(void*)&harq_pdu->harq_indication_tdd_rel13,channel); else extract_harq(mod_idP,CC_idP,UE_id,frameP,subframeP,(void*)&harq_pdu->harq_indication_fdd_rel13,channel); - if (channel == 0) sched_ctl->pucch1_snr[CC_idP] = ul_cqi; - + if (channel == 0) { + sched_ctl->pucch1_snr[CC_idP] = ul_cqi; + sched_ctl->pucch1_cqi_update[CC_idP] = 1; + } } diff --git a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c index 499b7583fa8694350e9f0d4ac0f017e36e7441de..5266086f43b8fe6f82b85ccec067b3048e151851 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c @@ -994,8 +994,8 @@ abort(); //compute the expected ULSCH RX power (for the stats) // this is the normalized RX power and this should be constant (regardless of mcs - normalized_rx_power = eNB_UE_stats->UL_rssi; - target_rx_power = cc[CC_id].radioResourceConfigCommon->uplinkPowerControlCommon.p0_NominalPUSCH;//get_target_pusch_rx_power(module_idP,CC_id); + normalized_rx_power = UE_sched_ctrl->pusch_snr[CC_id]; + target_rx_power = 20; // this assumes accumulated tpc // make sure that we are only sending a tpc update once a frame, otherwise the control loop will freak out