From 828387c5120094230411b17e3d044e8b9b0eb966 Mon Sep 17 00:00:00 2001 From: Sagar Parsawar Date: Thu, 17 Mar 2022 15:11:47 +0100 Subject: [PATCH] OAI UE: Added prs measurements in structure --- openair1/PHY/INIT/nr_init_ue.c | 8 +++-- .../nr_dl_channel_estimation.c | 27 +++++++++++---- openair1/PHY/defs_nr_UE.h | 9 ++--- openair1/PHY/defs_nr_common.h | 33 +++++++++++++------ 4 files changed, 54 insertions(+), 23 deletions(-) diff --git a/openair1/PHY/INIT/nr_init_ue.c b/openair1/PHY/INIT/nr_init_ue.c index 6ab53be0c9..2ef13d3c60 100644 --- a/openair1/PHY/INIT/nr_init_ue.c +++ b/openair1/PHY/INIT/nr_init_ue.c @@ -332,12 +332,16 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue, // PRS channel estimates prs_vars[idx]->prs_ch_estimates = (int32_t **)malloc16_clear( fp->nb_antennas_rx*sizeof(int32_t *) ); prs_vars[idx]->prs_ch_estimates_time = (int32_t **)malloc16_clear( fp->nb_antennas_rx*sizeof(int32_t *) ); - AssertFatal(((prs_vars[idx]->prs_ch_estimates!=NULL) || (prs_vars[idx]->prs_ch_estimates_time!=NULL)), "NR UE init: PRS channel estimates malloc failed\n"); + AssertFatal(((prs_vars[idx]->prs_ch_estimates!=NULL) || (prs_vars[idx]->prs_ch_estimates_time!=NULL)), "NR UE init: PRS channel estimates malloc failed for gNB_id %d\n", idx); + prs_vars[idx]->prs_meas = (prs_meas_t **)malloc16_clear( fp->nb_antennas_rx*sizeof(prs_meas_t *) ); + AssertFatal((prs_vars[idx]->prs_meas!=NULL), "NR UE init: PRS measurements malloc failed for gNB_id %d\n", idx); for (i=0; inb_antennas_rx; i++) { prs_vars[idx]->prs_ch_estimates[i] = (int32_t *)malloc16_clear(fp->ofdm_symbol_size*NR_SYMBOLS_PER_SLOT*sizeof(int32_t)); prs_vars[idx]->prs_ch_estimates_time[i] = (int32_t *)malloc16_clear(fp->ofdm_symbol_size*NR_SYMBOLS_PER_SLOT*sizeof(int32_t)); - AssertFatal(((prs_vars[idx]->prs_ch_estimates[i]!=NULL) || (prs_vars[idx]->prs_ch_estimates_time[i]!=NULL)), "NR UE init: PRS channel estimates malloc failed %d\n", i); + AssertFatal(((prs_vars[idx]->prs_ch_estimates[i]!=NULL) || (prs_vars[idx]->prs_ch_estimates_time[i]!=NULL)), "NR UE init: PRS channel estimates malloc failed for rx_ant %d\n", i); + prs_vars[idx]->prs_meas[i] = (prs_meas_t *)malloc16_clear(NR_SYMBOLS_PER_SLOT*sizeof(prs_meas_t) ); + AssertFatal((prs_vars[idx]->prs_meas[i]!=NULL), "NR UE init: PRS measurements malloc failed for rx_ant %d\n", i); } } // DLSCH diff --git a/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c b/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c index a2d571bf3a..22b3cc043f 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c +++ b/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c @@ -54,6 +54,7 @@ int nr_prs_channel_estimation(uint8_t gNB_id, int32_t **rxdataF = ue->common_vars.common_vars_rx_data_per_thread[proc->thread_id].rxdataF; uint32_t **nr_gold_prs = ue->nr_gold_prs[proc->nr_slot_rx]; prs_data_t *prs_cfg = &ue->prs_vars[gNB_id]->prs_cfg; + prs_meas_t **prs_meas = ue->prs_vars[gNB_id]->prs_meas; int32_t **prs_chestF = ue->prs_vars[gNB_id]->prs_ch_estimates; int32_t **prs_chestT = ue->prs_vars[gNB_id]->prs_ch_estimates_time; @@ -64,9 +65,7 @@ int nr_prs_channel_estimation(uint8_t gNB_id, int32_t *ch_time = (int32_t *)malloc16_clear(frame_params->ofdm_symbol_size*sizeof(int32_t)); AssertFatal(((ch_freq != NULL) || (ch_time != NULL)), "nr_prs_channel_estimation: channel estimate buffer initialization failed!!"); int16_t *ch_init = ch_freq; - - int32_t tdoa[NR_MAX_NUM_PRS_SYMB] = {0}; - int32_t ch_pwr[NR_MAX_NUM_PRS_SYMB] = {0}; + int32_t ch_pwr= 0; #ifdef DEBUG_PRS_CHEST char filename[128] = {0}, varname[128] = {0}; #endif @@ -409,13 +408,23 @@ int nr_prs_channel_estimation(uint8_t gNB_id, // rearrange impulse response memcpy((int16_t *)&prs_chestT[rxAnt][l*frame_params->ofdm_symbol_size], &ch_time[frame_params->ofdm_symbol_size>>1], (frame_params->ofdm_symbol_size>>1)*sizeof(int32_t)); memcpy((int16_t *)&prs_chestT[rxAnt][l*frame_params->ofdm_symbol_size + (frame_params->ofdm_symbol_size>>1)], &ch_time[0], (frame_params->ofdm_symbol_size>>1)*sizeof(int32_t)); - + // peak estimator peak_estimator(&prs_chestT[rxAnt][l*frame_params->ofdm_symbol_size], frame_params->ofdm_symbol_size, - &tdoa[l], - &ch_pwr[l]); - LOG_I(PHY, "[gNB %d][Rx %d] TDoA for PRS symbol %2d ==> %d / %d samples, peak channel power %.1f dB\n", gNB_id, rxAnt, l, tdoa[l]-(frame_params->ofdm_symbol_size>>1), frame_params->ofdm_symbol_size, 10*log10(ch_pwr[l])); + &prs_meas[rxAnt][l].dl_toa, + &ch_pwr); + LOG_I(PHY, "[gNB %d][Rx %d][sfn %d][slot %d] ToA for PRS symbol %2d ==> %d / %d samples, peak channel power %.1f dB\n", gNB_id, rxAnt, proc->frame_rx, proc->nr_slot_rx, l, prs_meas[rxAnt][l].dl_toa-(frame_params->ofdm_symbol_size>>1), frame_params->ofdm_symbol_size, 10*log10(ch_pwr)); + + //prs measurements + prs_meas[rxAnt][l].gNB_id = 0; + prs_meas[rxAnt][l].timestamp = 0; + prs_meas[rxAnt][l].sfn = proc->frame_rx; + prs_meas[rxAnt][l].slot = proc->nr_slot_rx; + prs_meas[rxAnt][l].symbol = l; + prs_meas[rxAnt][l].rxAnt_idx = rxAnt; + prs_meas[rxAnt][l].snr = 0; + prs_meas[rxAnt][l].dl_aoa = 0; } // for rxAnt } //for l @@ -436,6 +445,10 @@ int nr_prs_channel_estimation(uint8_t gNB_id, #endif // T tracer dump + T(T_UE_PHY_INPUT_SIGNAL, T_INT(gNB_id), + T_INT(proc->frame_rx), T_INT(proc->nr_slot_rx), + T_INT(rxAnt), T_BUFFER(&rxdataF[rxAnt][0], frame_params->samples_per_slot_wCP*sizeof(int32_t))); + T(T_UE_PHY_DL_CHANNEL_ESTIMATE_FREQ, T_INT(gNB_id), T_INT(proc->frame_rx), T_INT(proc->nr_slot_rx), T_INT(rxAnt), T_BUFFER(&prs_chestF[rxAnt][prs_cfg->SymbolStart*frame_params->ofdm_symbol_size], prs_cfg->NumPRSSymbols*frame_params->ofdm_symbol_size*sizeof(int32_t))); diff --git a/openair1/PHY/defs_nr_UE.h b/openair1/PHY/defs_nr_UE.h index 3acad7f96f..a8082ee147 100644 --- a/openair1/PHY/defs_nr_UE.h +++ b/openair1/PHY/defs_nr_UE.h @@ -387,7 +387,8 @@ typedef struct { prs_data_t prs_cfg; int32_t **prs_ch_estimates; int32_t **prs_ch_estimates_time; - int64_t reserved; + int32_t reserved; + prs_meas_t **prs_meas; } NR_UE_PRS; #define NR_PDCCH_DEFS_NR_UE @@ -831,9 +832,9 @@ typedef struct { NR_UE_DLSCH_t *dlsch_p[NUMBER_OF_CONNECTED_gNB_MAX]; NR_UE_DLSCH_t *dlsch_MCH[NUMBER_OF_CONNECTED_gNB_MAX]; NR_UE_PRS *prs_vars[NR_MAX_PRS_COMB_SIZE]; - uint16_t prs_active_gNBs; - uint8_t prs_start_symb; - uint8_t prs_end_symb; + uint16_t prs_active_gNBs; + uint8_t prs_start_symb; + uint8_t prs_end_symb; //Paging parameters uint32_t IMSImod1024; diff --git a/openair1/PHY/defs_nr_common.h b/openair1/PHY/defs_nr_common.h index aba8f93ba1..b86811a4c3 100644 --- a/openair1/PHY/defs_nr_common.h +++ b/openair1/PHY/defs_nr_common.h @@ -377,21 +377,34 @@ struct NR_DL_FRAME_PARMS { // PRS structures prototype typedef struct { uint16_t PRSResourceSetPeriod[2]; //[slot period, slot offset] - uint8_t PRSResourceOffset; // array if more than one resource sets.slot offset (0...511) (default 0) - uint8_t PRSResourceRepetition;// slot offset (1 (default), 2, 4, 6, 8, 16, 32) - uint8_t PRSResourceTimeGap; // slot offset (1 (default), 2, 4, 6, 8, 16, 32) - uint8_t NumRB; //number of RBs in freq domain a scalar =< 275 RB - uint8_t NumPRSSymbols; //number of PRS symbols in time domain - uint8_t SymbolStart; //starting OFDM symbol of PRS resource in time domain - uint8_t RBOffset; //Starting PRB index of all PRS resources in a PRS resource set. - uint8_t CombSize; //RE density of all PRS resources in a PRS resource set. i∈{2,4,6,12} - uint8_t REOffset; //Starting RE offset in the first OFDM symbol of each PRS resource in a PRS resource set. + uint8_t PRSResourceOffset; // array if more than one resource sets.slot offset (0...511) (default 0) + uint8_t PRSResourceRepetition;// slot offset (1 (default), 2, 4, 6, 8, 16, 32) + uint8_t PRSResourceTimeGap; // slot offset (1 (default), 2, 4, 6, 8, 16, 32) + uint8_t NumRB; //number of RBs in freq domain a scalar =< 275 RB + uint8_t NumPRSSymbols; //number of PRS symbols in time domain + uint8_t SymbolStart; //starting OFDM symbol of PRS resource in time domain + uint8_t RBOffset; //Starting PRB index of all PRS resources in a PRS resource set. + uint8_t CombSize; //RE density of all PRS resources in a PRS resource set. i∈{2,4,6,12} + uint8_t REOffset; //Starting RE offset in the first OFDM symbol of each PRS resource in a PRS resource set. uint32_t MutingPattern1[2]; //Muting bit pattern option-1, specified as [] or a binary-valued vector of length 2, 4, 6, 8, 16, or 32. uint32_t MutingPattern2[2]; - uint8_t MutingBitRepetition; + uint8_t MutingBitRepetition; uint16_t NPRSID; } prs_data_t; //32bytes +typedef struct { + int8_t gNB_id; + int32_t timestamp; + int32_t sfn; + int8_t slot; + int8_t symbol; + int8_t rxAnt_idx; + int32_t dl_toa; + int32_t dl_aoa; + int32_t snr; + int32_t reserved; +} prs_meas_t; + #define KHz (1000UL) #define MHz (1000*KHz)