Commit cf552b7b authored by Hongzhi Wang's avatar Hongzhi Wang

adding rsrp measurement

parent 5a5f5039
......@@ -86,6 +86,10 @@ void nr_ue_measurements(PHY_VARS_NR_UE *ue,
unsigned char rank_adaptation,
uint8_t subframe);
void nr_ue_rrc_measurements(PHY_VARS_NR_UE *ue,
uint8_t slot,
uint8_t abstraction_flag);
void phy_adjust_gain_nr(PHY_VARS_NR_UE *ue,
uint32_t rx_power_fil_dB,
uint8_t eNB_id);
......
......@@ -23,6 +23,7 @@
#include "PHY/phy_extern_nr_ue.h"
#include "common/utils/LOG/log.h"
#include "PHY/sse_intrin.h"
#include "openair2/LAYER2/NR_MAC_UE/mac_proto.h"
//#define k1 1000
#define k1 ((long long int) 1000)
......@@ -75,7 +76,33 @@ int16_t get_nr_PL(PHY_VARS_NR_UE *ue,uint8_t gNB_index)
//(ue->frame_parms.pdsch_config_common.referenceSignalPower*10))/10));
}
uint32_t get_nr_rx_total_gain_dB (module_id_t Mod_id,uint8_t CC_id)
{
PHY_VARS_NR_UE *ue = PHY_vars_UE_g[Mod_id][CC_id];
if (ue)
return ue->rx_total_gain_dB;
return 0xFFFFFFFF;
}
double get_nr_RSRP(module_id_t Mod_id,uint8_t CC_id,uint8_t gNB_index)
{
AssertFatal(PHY_vars_UE_g!=NULL,"PHY_vars_UE_g is null\n");
AssertFatal(PHY_vars_UE_g[Mod_id]!=NULL,"PHY_vars_UE_g[%d] is null\n",Mod_id);
AssertFatal(PHY_vars_UE_g[Mod_id][CC_id]!=NULL,"PHY_vars_UE_g[%d][%d] is null\n",Mod_id,CC_id);
PHY_VARS_NR_UE *ue = PHY_vars_UE_g[Mod_id][CC_id];
if (ue)
return ((dB_fixed_times10(ue->measurements.rsrp[gNB_index]))/10.0-
get_nr_rx_total_gain_dB(Mod_id,0) -
10*log10(20*12));
return -140.0;
}
void nr_ue_measurements(PHY_VARS_NR_UE *ue,
......@@ -193,4 +220,75 @@ void nr_ue_measurements(PHY_VARS_NR_UE *ue,
_mm_empty();
_m_empty();
#endif
}
\ No newline at end of file
}
void nr_ue_rrc_measurements(PHY_VARS_NR_UE *ue,
uint8_t slot,
uint8_t abstraction_flag)
{
int aarx,rb;
int16_t *rxF;
uint16_t Nid_cell = ue->frame_parms.Nid_cell;
uint8_t eNB_offset=0,l,nushift;
uint16_t off,nb_rb;
NR_UE_MAC_INST_t *mac = get_mac_inst(0);
nushift = ue->frame_parms.Nid_cell%4;
ue->frame_parms.nushift = nushift;
unsigned int ssb_offset = ue->frame_parms.first_carrier_offset + ue->frame_parms.ssb_start_subcarrier;
if (ssb_offset>= ue->frame_parms.ofdm_symbol_size) ssb_offset-=ue->frame_parms.ofdm_symbol_size;
ue->measurements.rsrp[eNB_offset] = 0;
if (mac->csirc->reportQuantity.choice.ssb_Index_RSRP){
nb_rb = 60;
} else{
LOG_E(PHY,"report quantity not supported \n");
}
if (abstraction_flag == 0) {
for (l=0; l<1; l++) {
LOG_D(PHY,"[UE %d] slot %d Doing ue_rrc_measurements rsrp/rssi (Nid_cell %d, nushift %d, eNB_offset %d, l %d)\n",ue->Mod_id,slot,Nid_cell,nushift,
eNB_offset,l);
for (aarx=0; aarx<ue->frame_parms.nb_antennas_rx; aarx++) {
rxF = (int16_t *)&ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[slot]].rxdataF[aarx][(l*ue->frame_parms.ofdm_symbol_size)];
off = ssb_offset+nushift;
if (l==0) {
for (rb=0; rb<nb_rb; rb++) {
ue->measurements.rsrp[eNB_offset] += (((int32_t)(rxF[off])*rxF[off])+((int32_t)(rxF[off+1])*rxF[off+1]));
// printf("rb %d, off %d : %d\n",rb,off,((((int32_t)rxF[off])*rxF[off])+((int32_t)(rxF[off+1])*rxF[off+1])));
off = (off+4) % ue->frame_parms.ofdm_symbol_size;
}
}
}
}
ue->measurements.rsrp[eNB_offset]/=nb_rb;
LOG_I(PHY,"eNB: %d, RSRP: %d \n",eNB_offset,ue->measurements.rsrp[eNB_offset]);
} else {
ue->measurements.rsrp[eNB_offset] = -93 ;
}
if (eNB_offset == 0)
LOG_I(PHY,"[UE %d] slot %d RRC Measurements (idx %d, Cell id %d) => rsrp: %3.1f dBm/RE (%d), rsrq: %3.1f dB\n",
ue->Mod_id,
slot,eNB_offset,
(eNB_offset>0) ? ue->measurements.adj_cell_id[eNB_offset-1] : ue->frame_parms.Nid_cell,
10*log10(ue->measurements.rsrp[eNB_offset])-ue->rx_total_gain_dB,
ue->measurements.rsrp[eNB_offset],
(10*log10(ue->measurements.rsrq[eNB_offset])));
}
......@@ -53,6 +53,7 @@
#ifdef EMOS
#include "SCHED/phy_procedures_emos.h"
#endif
#include "openair2/LAYER2/NR_MAC_UE/mac_proto.h"
//#define DEBUG_PHY_PROC
......@@ -4208,6 +4209,8 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,
uint8_t nb_symb_pdcch = pdcch_vars->nb_search_space > 0 ? pdcch_vars->pdcch_config[0].coreset.duration : 0;
uint8_t dci_cnt = 0;
NR_DL_FRAME_PARMS *fp = &ue->frame_parms;
NR_UE_MAC_INST_t *mac = get_mac_inst(0);
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_RX, VCD_FUNCTION_IN);
......@@ -4248,7 +4251,16 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,
#endif
}
nr_ue_pbch_procedures(eNB_id,ue,proc,0);
if (mac->csirc->reportQuantity.choice.ssb_Index_RSRP){
printf("first measurement ue->symbol_offset %d \n", ue->symbol_offset);
nr_ue_rrc_measurements(ue,nr_tti_rx,0);
}
nr_ue_pbch_procedures(eNB_id,ue,proc,0);
if (ue->no_timing_correction==0) {
LOG_I(PHY,"start adjust sync slot = %d no timing %d\n", nr_tti_rx, ue->no_timing_correction);
......
......@@ -48,6 +48,7 @@
#include "NR_PhysicalCellGroupConfig.h"
#include "NR_CellGroupConfig.h"
#include "NR_ServingCellConfig.h"
#include "NR_MeasConfig.h"
#include "fapi_nr_ue_interface.h"
#include "NR_IF_Module.h"
#include "../NR_MAC_gNB/nr_mac_common.h"
......@@ -143,6 +144,7 @@ typedef struct {
NR_ServingCellConfigCommon_t *scc;
NR_CellGroupConfig_t *scg;
int servCellIndex;
NR_CSI_ReportConfig_t *csirc;
//// MAC config
NR_DRX_Config_t *drx_Config;
NR_SchedulingRequestConfig_t *schedulingRequestConfig;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment