diff --git a/common/utils/T/T_messages.txt b/common/utils/T/T_messages.txt index 8dd5052714..2f17b62ea5 100644 --- a/common/utils/T/T_messages.txt +++ b/common/utils/T/T_messages.txt @@ -143,6 +143,10 @@ ID = GNB_PHY_UL_TIME_CHANNEL_ESTIMATE DESC = gNodeB channel estimation in the time domain GROUP = ALL:PHY:GRAPHIC:HEAVY:GNB FORMAT = int,gNB_ID : int,rnti : int,frame : int,subframe : int,antenna : buffer,chest_t +ID = GNB_PHY_UL_SNR_ESTIMATE + DESC = gNodeB SNR estimation based on SRS + GROUP = ALL:PHY:GRAPHIC:HEAVY:GNB + FORMAT = int,gNB_ID : int,rnti : int,frame : int,subframe : int,antenna : buffer,snr ID = GNB_PHY_PRACH_INPUT_SIGNAL DESC = gNodeB input data in the time domain for slots with PRACH detection GROUP = ALL:PHY:GRAPHIC:HEAVY:GNB diff --git a/common/utils/T/tracer/gnb.c b/common/utils/T/tracer/gnb.c index 22567492f8..d47f627341 100644 --- a/common/utils/T/tracer/gnb.c +++ b/common/utils/T/tracer/gnb.c @@ -19,6 +19,7 @@ typedef struct { widget *pucch_pusch_iq_plot; widget *ul_freq_estimate_ue_xy_plot; widget *ul_time_estimate_ue_xy_plot; + widget *ul_snr_estimate_ue_xy_plot; widget *current_ue_label; widget *current_ue_button; widget *prev_ue_button; @@ -26,6 +27,7 @@ typedef struct { logger *pucch_pusch_iq_logger; logger *ul_freq_estimate_ue_logger; logger *ul_time_estimate_ue_logger; + logger *ul_snr_ue_logger; } gnb_gui; typedef struct { @@ -98,6 +100,9 @@ static void set_current_ue(gui *g, gnb_data *e, int ue) sprintf(s, "UL channel estimation in time domain [UE %d]", ue); xy_plot_set_title(g, e->e->ul_time_estimate_ue_xy_plot, s); + + sprintf(s, "UL SNR per RB based on SRS [UE %d]", ue); + xy_plot_set_title(g, e->e->ul_snr_estimate_ue_xy_plot, s); } void reset_ue_ids(void) @@ -146,12 +151,13 @@ static void gnb_main_gui(gnb_gui *e, gui *g, event_handler *h, void *database, g logger *l; view *v; - main_window = new_toplevel_window(g, 1500, 230, "gNB tracer"); + main_window = new_toplevel_window(g, 1500, 460, "gNB tracer"); top_container = new_container(g, VERTICAL); widget_add_child(g, main_window, top_container, -1); line = new_container(g, HORIZONTAL); widget_add_child(g, top_container, line, -1); + logo = new_image(g, openair_logo_png, openair_logo_png_len); /* logo + prev/next UE buttons */ @@ -206,6 +212,21 @@ static void gnb_main_gui(gnb_gui *e, gui *g, event_handler *h, void *database, g logger_add_view(l, v); e->ul_time_estimate_ue_logger = l; + line = new_container(g, HORIZONTAL); + widget_add_child(g, top_container, line, -1); + + /* UL SNR based on SRS */ + w = new_xy_plot(g, 1280, 200, "", 190); + e->ul_snr_estimate_ue_xy_plot = w; + widget_add_child(g, line, w, -1); + xy_plot_set_range(g, w, 0, 273, -10, 65); + l = new_framelog(h, database, "GNB_PHY_UL_SNR_ESTIMATE", "subframe", "snr"); + framelog_set_update_only_at_sf9(l, 0); + framelog_set_type_buffer_db(l); + v = new_view_xy(273, 10, g, w, new_color(g, "#0c0c72"), XY_LOOP_MODE); + logger_add_view(l, v); + e->ul_snr_ue_logger = l; + set_current_ue(g, ed, ed->ue); register_notifier(g, "click", e->current_ue_button, click, ed); register_notifier(g, "click", e->prev_ue_button, click, ed); @@ -251,6 +272,7 @@ int main(int n, char **v) on_off(database, "GNB_PHY_PUCCH_PUSCH_IQ", is_on, 1); on_off(database, "GNB_PHY_UL_FREQ_CHANNEL_ESTIMATE", is_on, 1); on_off(database, "GNB_PHY_UL_TIME_CHANNEL_ESTIMATE", is_on, 1); + on_off(database, "GNB_PHY_UL_SNR_ESTIMATE", is_on, 1); gnb_data.ue = 0; gnb_data.e = ⪚ diff --git a/common/utils/T/tracer/logger/framelog.c b/common/utils/T/tracer/logger/framelog.c index 45ae3e399f..040482278f 100644 --- a/common/utils/T/tracer/logger/framelog.c +++ b/common/utils/T/tracer/logger/framelog.c @@ -8,6 +8,11 @@ #include #include +typedef enum { + FRAMELOG_BUFFER, + FRAMELOG_BUFFER_dB, +} framelog_buffer_type_t; + struct framelog { struct logger common; void *database; @@ -22,6 +27,7 @@ struct framelog { int skip_current; /* internal data for the skip mechanism */ int skip_on; /* internal data for the skip mechanism */ int update_only_at_sf9; + framelog_buffer_type_t type; }; static void _event(void *p, event e) @@ -52,7 +58,10 @@ static void _event(void *p, event e) } if (l->skip_on) return; - nsamples = bsize / (2*sizeof(int16_t)); + if (l->type == FRAMELOG_BUFFER) + nsamples = bsize / (2 * sizeof(int16_t)); + else + nsamples = bsize / sizeof(int16_t); if (l->blength != nsamples * 10) { l->blength = nsamples * 10; @@ -71,10 +80,15 @@ static void _event(void *p, event e) } /* TODO: compute the LOGs in the plotter (too much useless computations) */ - for (i = 0; i < nsamples; i++) { - int I = ((int16_t *)buffer)[i*2]; - int Q = ((int16_t *)buffer)[i*2+1]; - l->buffer[subframe * nsamples + i] = 10*log10(1.0+(float)(I*I+Q*Q)); + if (l->type == FRAMELOG_BUFFER_dB) { + for (i = 0; i < nsamples; i++) + l->buffer[subframe * nsamples + i] = ((int16_t *)buffer)[i]; + } else { + for (i = 0; i < nsamples; i++) { + int I = ((int16_t *)buffer)[i * 2]; + int Q = ((int16_t *)buffer)[i * 2 + 1]; + l->buffer[subframe * nsamples + i] = 10 * log10(1.0 + (float)(I * I + Q * Q)); + } } if (l->update_only_at_sf9 == 0 || subframe == 9) @@ -132,6 +146,8 @@ logger *new_framelog(event_handler *h, void *database, abort(); } + ret->type = FRAMELOG_BUFFER; + return ret; } @@ -153,3 +169,9 @@ void framelog_set_update_only_at_sf9(logger *_this, int update_only_at_sf9) struct framelog *l = _this; l->update_only_at_sf9 = update_only_at_sf9; } + +void framelog_set_type_buffer_db(logger *_this) +{ + struct framelog *l = _this; + l->type = FRAMELOG_BUFFER_dB; +} diff --git a/common/utils/T/tracer/logger/logger.h b/common/utils/T/tracer/logger/logger.h index b78fa1b359..d8458ef104 100644 --- a/common/utils/T/tracer/logger/logger.h +++ b/common/utils/T/tracer/logger/logger.h @@ -30,6 +30,7 @@ logger *new_iqdotlog(void *event_handler, void *database, void framelog_set_skip(logger *_this, int skip_delay); void framelog_set_update_only_at_sf9(logger *_this, int update_only_at_sf9); +void framelog_set_type_buffer_db(logger *_this); void textlog_dump_buffer(logger *_this, int dump_buffer); void textlog_raw_time(logger *_this, int raw_time); diff --git a/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c b/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c index 77c6429b5c..93d7feebe0 100644 --- a/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c +++ b/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c @@ -782,7 +782,7 @@ int nr_srs_channel_estimation( [gNB->frame_parms.ofdm_symbol_size * (1 << srs_pdu->num_symbols)], c16_t srs_estimated_channel_time[][1 << srs_pdu->num_ant_ports][gNB->frame_parms.ofdm_symbol_size], c16_t srs_estimated_channel_time_shifted[][1 << srs_pdu->num_ant_ports][gNB->frame_parms.ofdm_symbol_size], - int8_t *snr_per_rb, + int16_t *snr_per_rb, int8_t *snr) { #ifdef SRS_DEBUG diff --git a/openair1/PHY/NR_ESTIMATION/nr_ul_estimation.h b/openair1/PHY/NR_ESTIMATION/nr_ul_estimation.h index 6451de12dd..04377db1b8 100644 --- a/openair1/PHY/NR_ESTIMATION/nr_ul_estimation.h +++ b/openair1/PHY/NR_ESTIMATION/nr_ul_estimation.h @@ -89,7 +89,7 @@ int nr_srs_channel_estimation( [gNB->frame_parms.ofdm_symbol_size * (1 << srs_pdu->num_symbols)], c16_t srs_estimated_channel_time[][1 << srs_pdu->num_ant_ports][gNB->frame_parms.ofdm_symbol_size], c16_t srs_estimated_channel_time_shifted[][1 << srs_pdu->num_ant_ports][gNB->frame_parms.ofdm_symbol_size], - int8_t *snr_per_rb, + int16_t *snr_per_rb, int8_t *snr); void nr_freq_equalization(NR_DL_FRAME_PARMS *frame_parms, diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index 0cb9d8d4fd..51e8c771e5 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -710,7 +710,7 @@ static void fill_ul_rb_mask(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, uint32 int fill_srs_reported_symbol(nfapi_nr_srs_reported_symbol_t *reported_symbol, const nfapi_nr_srs_pdu_t *srs_pdu, const int N_RB_UL, - const int8_t *snr_per_rb, + const int16_t *snr_per_rb, const int srs_est) { reported_symbol->num_prgs = srs_pdu->beamforming.num_prgs; for (int prg_idx = 0; prg_idx < reported_symbol->num_prgs; prg_idx++) { @@ -1052,7 +1052,7 @@ int phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, N __attribute__((aligned(32))); c16_t srs_estimated_channel_time_shifted[frame_parms->nb_antennas_rx][1 << srs_pdu->num_ant_ports] [frame_parms->ofdm_symbol_size]; - int8_t snr_per_rb[srs_pdu->bwp_size]; + int16_t snr_per_rb[srs_pdu->bwp_size]; start_meas(&gNB->generate_srs_stats); @@ -1110,6 +1110,14 @@ int phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, N T_INT(0), T_BUFFER(srs_estimated_channel_time_shifted[0][0], frame_parms->ofdm_symbol_size * sizeof(int32_t))); + T(T_GNB_PHY_UL_SNR_ESTIMATE, + T_INT(0), + T_INT(srs_pdu->rnti), + T_INT(frame_rx), + T_INT(0), + T_INT(0), + T_BUFFER(snr_per_rb, srs_pdu->bwp_size * sizeof(int16_t))); + UL_INFO->srs_ind.sfn = frame_rx; UL_INFO->srs_ind.slot = slot_rx;