mac: update CQI in MAC with CSI reports from PHY

Signed-off-by: Carlo Galiotto <carlo@srs.io>
master
Carlo Galiotto 3 years ago committed by carlo-gal
parent 781ae4abfb
commit dc3e3a89f8

@ -31,19 +31,19 @@ private:
pthread_rwlock_t* rwlock; pthread_rwlock_t* rwlock;
}; };
// Shared lock guard that automatically unlocks rwlock on exit // Shared lock guard that automatically unlocks rwmutex on exit
class rwlock_read_guard class rwlock_read_guard
{ {
public: public:
rwlock_read_guard(pthread_rwlock_t& rwlock_) : rwlock(&rwlock_) { pthread_rwlock_rdlock(rwlock); } rwlock_read_guard(pthread_rwlock_t& rwlock_) : rwmutex(&rwlock_) { pthread_rwlock_rdlock(rwmutex); }
rwlock_read_guard(const rwlock_read_guard&) = delete; rwlock_read_guard(const rwlock_read_guard&) = delete;
rwlock_read_guard(rwlock_read_guard&&) = delete; rwlock_read_guard(rwlock_read_guard&&) = delete;
rwlock_read_guard& operator=(const rwlock_read_guard&) = delete; rwlock_read_guard& operator=(const rwlock_read_guard&) = delete;
rwlock_read_guard& operator=(rwlock_read_guard&&) = delete; rwlock_read_guard& operator=(rwlock_read_guard&&) = delete;
~rwlock_read_guard() { pthread_rwlock_unlock(rwlock); } ~rwlock_read_guard() { pthread_rwlock_unlock(rwmutex); }
private: private:
pthread_rwlock_t* rwlock; pthread_rwlock_t* rwmutex;
}; };
} // namespace srsran } // namespace srsran

@ -112,7 +112,7 @@ private:
srslog::basic_logger& logger; srslog::basic_logger& logger;
// We use a rwlock in MAC to allow multiple workers to access MAC simultaneously. No conflicts will happen since // We use a rwmutex in MAC to allow multiple workers to access MAC simultaneously. No conflicts will happen since
// access for different TTIs // access for different TTIs
pthread_rwlock_t rwlock = {}; pthread_rwlock_t rwlock = {};

@ -59,7 +59,7 @@ public:
void metrics_phr(float phr); void metrics_phr(float phr);
void metrics_dl_ri(uint32_t dl_cqi); void metrics_dl_ri(uint32_t dl_cqi);
void metrics_dl_pmi(uint32_t dl_cqi); void metrics_dl_pmi(uint32_t dl_cqi);
void metrics_dl_cqi(uint32_t dl_cqi); void metrics_dl_cqi(const srsran_uci_cfg_nr_t& cfg_, uint32_t dl_cqi, bool valid_cqi);
void metrics_dl_mcs(uint32_t mcs); void metrics_dl_mcs(uint32_t mcs);
void metrics_ul_mcs(uint32_t mcs); void metrics_ul_mcs(uint32_t mcs);
void metrics_cnt(); void metrics_cnt();
@ -85,6 +85,7 @@ private:
uint32_t phr_counter = 0; uint32_t phr_counter = 0;
uint32_t dl_cqi_counter = 0; uint32_t dl_cqi_counter = 0;
uint32_t dl_cqi_valid_counter = 0;
uint32_t dl_ri_counter = 0; uint32_t dl_ri_counter = 0;
uint32_t dl_pmi_counter = 0; uint32_t dl_pmi_counter = 0;
mac_ue_metrics_t ue_metrics = {}; mac_ue_metrics_t ue_metrics = {};

@ -996,7 +996,7 @@ void mac::write_mcch(const srsran::sib2_mbms_t* sib2_,
rrc_h->add_user(SRSRAN_MRNTI, {}); rrc_h->add_user(SRSRAN_MRNTI, {});
} }
// Internal helper function, caller must hold UE DB rwlock // Internal helper function, caller must hold UE DB rwmutex
bool mac::check_ue_active(uint16_t rnti) bool mac::check_ue_active(uint16_t rnti)
{ {
if (not ue_db.contains(rnti)) { if (not ue_db.contains(rnti)) {

@ -365,6 +365,11 @@ bool mac_nr::handle_uci_data(const uint16_t rnti, const srsran_uci_cfg_nr_t& cfg
if (value.valid and value.sr > 0) { if (value.valid and value.sr > 0) {
sched.ul_sr_info(cfg_.pucch.rnti); sched.ul_sr_info(cfg_.pucch.rnti);
} }
// Process CQI
srsran::rwlock_read_guard rw_lock(rwlock);
ue_db[rnti]->metrics_dl_cqi(cfg_, value.csi->wideband_cri_ri_pmi_cqi.cqi, value.valid);
return true; return true;
} }
@ -401,7 +406,6 @@ int mac_nr::pusch_info(const srsran_slot_cfg_t& slot_cfg, mac_interface_phy_nr::
srsran::rwlock_read_guard rw_lock(rwlock); srsran::rwlock_read_guard rw_lock(rwlock);
if (ue_db.contains(rnti)) { if (ue_db.contains(rnti)) {
ue_db[rnti]->metrics_rx(pusch_info.pusch_data.tb[0].crc, nof_bytes); ue_db[rnti]->metrics_rx(pusch_info.pusch_data.tb[0].crc, nof_bytes);
ue_db[rnti]->metrics_dl_cqi(15); // TODO extract correct CQI measurments
} }
return SRSRAN_SUCCESS; return SRSRAN_SUCCESS;
} }

@ -194,11 +194,26 @@ void ue_nr::metrics_read(mac_ue_metrics_t* metrics_)
ue_metrics = {}; ue_metrics = {};
} }
void ue_nr::metrics_dl_cqi(uint32_t dl_cqi) void ue_nr::metrics_dl_cqi(const srsran_uci_cfg_nr_t& cfg_, uint32_t dl_cqi, bool valid_cqi)
{ {
std::lock_guard<std::mutex> lock(metrics_mutex); // I think this is not necessary, as we locked from the calling function
ue_metrics.dl_cqi = SRSRAN_VEC_CMA((float)dl_cqi, ue_metrics.dl_cqi, dl_cqi_counter); // std::lock_guard<std::mutex> lock(metrics_mutex);
// Process CQI
for (uint32_t i = 0; i < cfg_.nof_csi; i++) {
// Increment CQI opportunity
dl_cqi_counter++; dl_cqi_counter++;
// Skip if invalid or not supported CSI report
if (not valid_cqi or cfg_.csi[i].cfg.quantity != SRSRAN_CSI_REPORT_QUANTITY_CRI_RI_PMI_CQI or
cfg_.csi[i].cfg.freq_cfg != SRSRAN_CSI_REPORT_FREQ_WIDEBAND) {
continue;
}
// Add statistics
ue_metrics.dl_cqi = SRSRAN_VEC_SAFE_CMA(dl_cqi, ue_metrics.dl_cqi, dl_cqi_counter);
dl_cqi_valid_counter++;
}
} }
void ue_nr::metrics_rx(bool crc, uint32_t tbs) void ue_nr::metrics_rx(bool crc, uint32_t tbs)

Loading…
Cancel
Save