diff --git a/srsenb/hdr/phy/phch_common.h b/srsenb/hdr/phy/phch_common.h index d3cdf1aa0..06b6ca354 100644 --- a/srsenb/hdr/phy/phch_common.h +++ b/srsenb/hdr/phy/phch_common.h @@ -87,14 +87,29 @@ public: bool is_pending[TTIMOD_SZ][SRSLTE_MAX_TB]; uint16_t n_pdcch[TTIMOD_SZ]; } pending_ack_t; - std::map pending_ack; + + class common_ue { + public: + pending_ack_t pending_ack; + uint8_t ri; + int last_ul_tbs[2*HARQ_DELAY_MS]; + srslte_mod_t last_ul_mod[2*HARQ_DELAY_MS]; + }; + + std::map common_ue_db; - void ack_add_rnti(uint16_t rnti); - void ack_rem_rnti(uint16_t rnti); - void ack_clear(uint32_t sf_idx); - void ack_set_pending(uint32_t sf_idx, uint16_t rnti, uint32_t tb_idx, uint32_t n_pdcch); - bool ack_is_pending(uint32_t sf_idx, uint16_t rnti, uint32_t tb_idx, uint32_t *last_n_pdcch = NULL); - + void ue_db_add_rnti(uint16_t rnti); + void ue_db_rem_rnti(uint16_t rnti); + void ue_db_clear(uint32_t sf_idx); + void ue_db_set_ack_pending(uint32_t sf_idx, uint16_t rnti, uint32_t tb_idx, uint32_t n_pdcch); + bool ue_db_is_ack_pending(uint32_t sf_idx, uint16_t rnti, uint32_t tb_idx, uint32_t *last_n_pdcch = NULL); + void ue_db_set_ri(uint16_t rnti, uint8_t ri); + uint8_t ue_db_get_ri(uint16_t rnti); + void ue_db_set_last_ul_mod(uint16_t rnti, uint32_t tti, srslte_mod_t mcs); + srslte_mod_t ue_db_get_last_ul_mod(uint16_t rnti, uint32_t tti); + void ue_db_set_last_ul_tbs(uint16_t rnti, uint32_t tti, int tbs); + int ue_db_get_last_ul_tbs(uint16_t rnti, uint32_t tti); + private: std::vector tx_mutex; bool is_first_tx; diff --git a/srsenb/hdr/phy/phch_worker.h b/srsenb/hdr/phy/phch_worker.h index c02b4607b..6557a8e68 100644 --- a/srsenb/hdr/phy/phch_worker.h +++ b/srsenb/hdr/phy/phch_worker.h @@ -121,8 +121,6 @@ private: void metrics_ul(uint32_t mcs, float rssi, float sinr, uint32_t turbo_iters); int last_dl_tbs[2*HARQ_DELAY_MS][SRSLTE_MAX_CODEWORDS]; - int last_ul_tbs[2*HARQ_DELAY_MS]; - srslte_mod_t last_ul_mod[2*HARQ_DELAY_MS]; private: phy_metrics_t metrics; diff --git a/srsenb/src/mac/ue.cc b/srsenb/src/mac/ue.cc index 03bf13e33..07cb8d70d 100644 --- a/srsenb/src/mac/ue.cc +++ b/srsenb/src/mac/ue.cc @@ -408,7 +408,11 @@ void ue::metrics_phr(float phr) { } void ue::metrics_dl_ri(uint32_t dl_ri) { - metrics.dl_ri = SRSLTE_VEC_EMA((float) dl_ri, metrics.dl_ri, 0.5f); + if (metrics.dl_ri == 0.0f) { + metrics.dl_ri = (float) dl_ri + 1.0f; + } else { + metrics.dl_ri = SRSLTE_VEC_EMA((float) dl_ri + 1.0f, metrics.dl_ri, 0.5f); + } dl_ri_counter++; } diff --git a/srsenb/src/metrics_stdout.cc b/srsenb/src/metrics_stdout.cc index efea243f1..10ab47f4c 100644 --- a/srsenb/src/metrics_stdout.cc +++ b/srsenb/src/metrics_stdout.cc @@ -123,7 +123,7 @@ void metrics_stdout::print_metrics() cout << std::hex << metrics.mac[i].rnti << " "; cout << float_to_string(metrics.mac[i].dl_cqi, 2); - cout << float_to_string(metrics.mac[i].dl_ri + 1, 3); + cout << float_to_string(metrics.mac[i].dl_ri, 3); cout << float_to_string(metrics.phy[i].dl.mcs, 2); if (metrics.mac[i].tx_brate > 0 && metrics_report_period) { cout << float_to_eng_string((float) metrics.mac[i].tx_brate/metrics_report_period, 2); diff --git a/srsenb/src/phy/phch_common.cc b/srsenb/src/phy/phch_common.cc index c732f76dc..8a428d909 100644 --- a/srsenb/src/phy/phch_common.cc +++ b/srsenb/src/phy/phch_common.cc @@ -93,45 +93,45 @@ void phch_common::worker_end(uint32_t tx_mutex_cnt, cf_t* buffer[SRSLTE_MAX_PORT mac->tti_clock(); } -void phch_common::ack_clear(uint32_t sf_idx) +void phch_common::ue_db_clear(uint32_t sf_idx) { - for(std::map::iterator iter=pending_ack.begin(); iter!=pending_ack.end(); ++iter) { - pending_ack_t *p = (pending_ack_t*) &iter->second; + for(std::map::iterator iter=common_ue_db.begin(); iter!=common_ue_db.end(); ++iter) { + pending_ack_t *p = &((common_ue*)&iter->second)->pending_ack; for (uint32_t tb_idx = 0; tb_idx < SRSLTE_MAX_TB; tb_idx++) { p->is_pending[sf_idx][tb_idx] = false; } } } -void phch_common::ack_add_rnti(uint16_t rnti) +void phch_common::ue_db_add_rnti(uint16_t rnti) { for (int sf_idx=0;sf_idxack_clear(TTIMOD(TTI_TX(t_tx_dl))); + phy->ue_db_clear(TTIMOD(TTI_TX(t_tx_dl))); for (uint32_t i=0;iack_set_pending(TTIMOD(TTI_TX(t_tx_dl)), rnti, tb_idx, dl_grants[t_tx_dl].sched_grants[i].location.ncce); + phy->ue_db_set_ack_pending(TTIMOD(TTI_TX(t_tx_dl)), + rnti, + tb_idx, + dl_grants[t_tx_dl].sched_grants[i].location.ncce); } } } @@ -463,7 +466,7 @@ int phch_worker::decode_pusch(srslte_enb_ul_pusch_t *grants, uint32_t nof_pusch) // Get pending ACKs with an associated PUSCH transmission for (uint32_t tb = 0; tb < SRSLTE_MAX_TB; tb++) { - acks_pending[tb] = phy->ack_is_pending(t_rx, rnti, tb); + acks_pending[tb] = phy->ue_db_is_ack_pending(t_rx, rnti, tb); if (acks_pending[tb]) { uci_data.uci_ack_len++; } @@ -481,6 +484,7 @@ int phch_worker::decode_pusch(srslte_enb_ul_pusch_t *grants, uint32_t nof_pusch) cqi_enabled = true; if (ue_db[rnti].dedicated.antenna_info_explicit_value.tx_mode == LIBLTE_RRC_TRANSMISSION_MODE_4) { cqi_value.wideband.pmi_present = true; + cqi_value.wideband.rank_is_not_one = phy->ue_db_get_ri(rnti) > 0; } } else if (grants[i].grant.cqi_request) { cqi_value.type = SRSLTE_CQI_TYPE_SUBBAND_HL; @@ -493,6 +497,7 @@ int phch_worker::decode_pusch(srslte_enb_ul_pusch_t *grants, uint32_t nof_pusch) cqi_value.subband_hl.N = (phy->cell.nof_prb > 7) ? srslte_cqi_hl_get_no_subbands(phy->cell.nof_prb) : 0; cqi_value.subband_hl.four_antenna_ports = (phy->cell.nof_ports == 4); cqi_value.subband_hl.pmi_present = (ue_db[rnti].dedicated.cqi_report_cnfg.report_mode_aperiodic == LIBLTE_RRC_CQI_REPORT_MODE_APERIODIC_RM31); + cqi_value.subband_hl.rank_is_not_one = phy->ue_db_get_ri(rnti) > 0; cqi_enabled = true; } @@ -506,16 +511,16 @@ int phch_worker::decode_pusch(srslte_enb_ul_pusch_t *grants, uint32_t nof_pusch) // Handle Format0 adaptive retx // Use last TBS for this TB in case of mcs>28 if (phy_grant.mcs.idx > 28) { - phy_grant.mcs.tbs = ue_db[rnti].last_ul_tbs[TTI_RX(tti_rx)%(2*HARQ_DELAY_MS)]; + phy_grant.mcs.tbs = phy->ue_db_get_last_ul_tbs(rnti, tti_rx); Info("RETX: mcs=%d, old_tbs=%d pid=%d\n", phy_grant.mcs.idx, phy_grant.mcs.tbs, TTI_TX(tti_rx)%(2*HARQ_DELAY_MS)); } - ue_db[rnti].last_ul_tbs[TTI_RX(tti_rx)%(2*HARQ_DELAY_MS)] = phy_grant.mcs.tbs; + phy->ue_db_set_last_ul_tbs(rnti, tti_rx, phy_grant.mcs.tbs); if (phy_grant.mcs.mod == SRSLTE_MOD_LAST) { - phy_grant.mcs.mod = ue_db[rnti].last_ul_mod[TTI_RX(tti_rx)%(2*HARQ_DELAY_MS)]; + phy_grant.mcs.mod = phy->ue_db_get_last_ul_mod(rnti, tti_rx); phy_grant.Qm = srslte_mod_bits_x_symbol(phy_grant.mcs.mod); } - ue_db[rnti].last_ul_mod[TTI_RX(tti_rx)%(2*HARQ_DELAY_MS)] = phy_grant.mcs.mod; + phy->ue_db_set_last_ul_mod(rnti, tti_rx, phy_grant.mcs.mod); if (phy_grant.mcs.mod == SRSLTE_MOD_64QAM) { @@ -636,11 +641,12 @@ int phch_worker::decode_pusch(srslte_enb_ul_pusch_t *grants, uint32_t nof_pusch) } if (uci_data.uci_ri_len > 0 && crc_res) { phy->mac->ri_info(tti_rx, rnti, uci_data.uci_ri); + phy->ue_db_set_ri(rnti, uci_data.uci_ri); } if (wideband_pmi_present && crc_res) { phy->mac->pmi_info(tti_rx, rnti, wideband_pmi); } - ue_db[rnti]. + // Save metrics stats ue_db[rnti].metrics_ul(phy_grant.mcs.idx, 0, snr_db, srslte_pusch_last_noi(&enb_ul.pusch)); } @@ -671,7 +677,7 @@ int phch_worker::decode_pucch() } for (uint32_t tb = 0; tb < SRSLTE_MAX_TB; tb++) { - needs_ack[tb] = phy->ack_is_pending(t_rx, rnti, tb, &last_n_pdcch); + needs_ack[tb] = phy->ue_db_is_ack_pending(t_rx, rnti, tb, &last_n_pdcch); if (needs_ack[tb]) { needs_pucch = true; uci_data.uci_ack_len++; @@ -692,6 +698,7 @@ int phch_worker::decode_pucch() cqi_value.type = SRSLTE_CQI_TYPE_WIDEBAND; if (tx_mode == LIBLTE_RRC_TRANSMISSION_MODE_4) { cqi_value.wideband.pmi_present = true; + cqi_value.wideband.rank_is_not_one = phy->ue_db_get_ri(rnti) > 0; } uci_data.uci_cqi_len = (uint32_t) srslte_cqi_size(&cqi_value); } @@ -719,6 +726,7 @@ int phch_worker::decode_pucch() if (srslte_pucch_get_last_corr(&enb_ul.pucch) > PUCCH_RL_CORR_TH) { if (uci_data.ri_periodic_report) { phy->mac->ri_info(tti_rx, rnti, uci_data.uci_ri); + phy->ue_db_set_ri(rnti, uci_data.uci_ri); sprintf(cqi_ri_str, ", ri=%d", uci_data.uci_ri); } else if (uci_data.uci_cqi_len && needs_cqi) { srslte_cqi_value_unpack(uci_data.uci_cqi, &cqi_value); diff --git a/srsenb/src/phy/phy.cc b/srsenb/src/phy/phy.cc index 2d6eee4b8..1da25abeb 100644 --- a/srsenb/src/phy/phy.cc +++ b/srsenb/src/phy/phy.cc @@ -156,7 +156,7 @@ uint32_t phy::tti_to_subf(uint32_t tti) { int phy::add_rnti(uint16_t rnti) { if (rnti >= SRSLTE_CRNTI_START && rnti <= SRSLTE_CRNTI_END) { - workers_common.ack_add_rnti(rnti); + workers_common.ue_db_add_rnti(rnti); } for (uint32_t i=0;i= SRSLTE_CRNTI_START && rnti <= SRSLTE_CRNTI_END) { - workers_common.ack_rem_rnti(rnti); + workers_common.ue_db_rem_rnti(rnti); } for (uint32_t i=0;i