From 0eeb174253f93847e5990adf2ea210345ec28eed Mon Sep 17 00:00:00 2001 From: Roberto Louro Magueta Date: Mon, 23 May 2022 11:43:32 +0100 Subject: [PATCH] Add wideband SNR based on SRS in MAC stats --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c | 15 +++++++++++++-- openair2/LAYER2/NR_MAC_gNB/main.c | 5 +++-- openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h | 1 + 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c index 7c61eb3b5a..38e6ca0d6f 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c @@ -907,8 +907,19 @@ void handle_nr_srs_measurements(const module_id_t module_id, } #endif - int ul_prbblack_SNR_threshold = RC.nrmac[module_id]->ul_prbblack_SNR_threshold; - uint16_t *ulprbbl = RC.nrmac[module_id]->ulprbbl; + const int UE_id = find_nr_UE_id(module_id,rnti); + if (UE_id < 0) { + LOG_W(NR_MAC, "Could not find UE for RNTI 0x%04x\n", rnti); + return; + } + + gNB_MAC_INST *nr_mac = RC.nrmac[module_id]; + NR_UE_info_t *UE_info = &nr_mac->UE_info; + NR_mac_stats_t *stats = &UE_info->mac_stats[UE_id]; + stats->srs_wide_band_snr = (wide_band_snr>>1)-64; + + int ul_prbblack_SNR_threshold = nr_mac->ul_prbblack_SNR_threshold; + uint16_t *ulprbbl = nr_mac->ulprbbl; memset(ulprbbl, 0, reported_symbol_list[0].num_rbs*sizeof(uint16_t)); for (int rb = 0; rb < reported_symbol_list[0].num_rbs; rb++) { diff --git a/openair2/LAYER2/NR_MAC_gNB/main.c b/openair2/LAYER2/NR_MAC_gNB/main.c index e047494b52..b7bf30f056 100644 --- a/openair2/LAYER2/NR_MAC_gNB/main.c +++ b/openair2/LAYER2/NR_MAC_gNB/main.c @@ -84,7 +84,7 @@ void dump_mac_stats(gNB_MAC_INST *gNB, char *output, int strlen, bool reset_rsrp const NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; NR_mac_stats_t *stats = &UE_info->mac_stats[UE_id]; const int avg_rsrp = stats->num_rsrp_meas > 0 ? stats->cumul_rsrp / stats->num_rsrp_meas : 0; - stroff+=sprintf(output+stroff,"UE ID %d RNTI %04x (%d/%d) PH %d dB PCMAX %d dBm, average RSRP %d (%d meas)\n", + stroff+=sprintf(output+stroff,"UE ID %d RNTI %04x (%d/%d) PH %d dB PCMAX %d dBm, average RSRP %d (%d meas), UL-SNR %d dB\n", UE_id, UE_info->rnti[UE_id], num++, @@ -92,7 +92,8 @@ void dump_mac_stats(gNB_MAC_INST *gNB, char *output, int strlen, bool reset_rsrp sched_ctrl->ph, sched_ctrl->pcmax, avg_rsrp, - stats->num_rsrp_meas); + stats->num_rsrp_meas, + stats->srs_wide_band_snr); stroff+=sprintf(output+stroff,"UE %d: CQI %d, RI %d, PMI (%d,%d)\n", UE_id, UE_info->UE_sched_ctrl[UE_id].CSI_report.cri_ri_li_pmi_cqi_report.wb_cqi_1tb, diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index b2b6d3d516..4e896c2f49 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -690,6 +690,7 @@ typedef struct { uint32_t pucch0_DTX; int cumul_rsrp; uint8_t num_rsrp_meas; + int8_t srs_wide_band_snr; } NR_mac_stats_t;