Commit 3f6ed8d1 authored by Sagar Parsawar's avatar Sagar Parsawar Committed by francescomani

Fix for multiple gNB SSB decode in UE phy-test mode

parent 537605a6
...@@ -88,6 +88,8 @@ ...@@ -88,6 +88,8 @@
#define CONFIG_HLP_DISABLNBIOT "disable nb-iot, even if defined in config\n" #define CONFIG_HLP_DISABLNBIOT "disable nb-iot, even if defined in config\n"
#define CONFIG_HLP_DISABLETIMECORR "disable UE timing correction\n" #define CONFIG_HLP_DISABLETIMECORR "disable UE timing correction\n"
#define CONFIG_HLP_RRC_CFG_PATH "path for RRC configuration\n" #define CONFIG_HLP_RRC_CFG_PATH "path for RRC configuration\n"
#define CONFIG_HLP_RE_CFG_FILE "filename for reconfig.raw in phy-test mode\n"
#define CONFIG_HLP_RB_CFG_FILE "filename for rbconfig.raw in phy-test mode\n"
#define CONFIG_HLP_UECAP_FILE "path for UE Capabilities file\n" #define CONFIG_HLP_UECAP_FILE "path for UE Capabilities file\n"
#define CONFIG_HLP_NUMEROLOGY "adding numerology for 5G\n" #define CONFIG_HLP_NUMEROLOGY "adding numerology for 5G\n"
......
...@@ -946,13 +946,15 @@ void *UE_thread(void *arg) ...@@ -946,13 +946,15 @@ void *UE_thread(void *arg)
void init_NR_UE(int nb_inst, void init_NR_UE(int nb_inst,
char* uecap_file, char* uecap_file,
char* rrc_config_path) { char* rrc_config_path,
char* reconfig_file,
char* rbconfig_file) {
int inst; int inst;
NR_UE_MAC_INST_t *mac_inst; NR_UE_MAC_INST_t *mac_inst;
NR_UE_RRC_INST_t* rrc_inst; NR_UE_RRC_INST_t* rrc_inst;
for (inst=0; inst < nb_inst; inst++) { for (inst=0; inst < nb_inst; inst++) {
AssertFatal((rrc_inst = nr_l3_init_ue(uecap_file,rrc_config_path)) != NULL, "can not initialize RRC module\n"); AssertFatal((rrc_inst = nr_l3_init_ue(uecap_file,rrc_config_path, reconfig_file, rbconfig_file)) != NULL, "can not initialize RRC module\n");
AssertFatal((mac_inst = nr_l2_init_ue(rrc_inst)) != NULL, "can not initialize L2 module\n"); AssertFatal((mac_inst = nr_l2_init_ue(rrc_inst)) != NULL, "can not initialize L2 module\n");
AssertFatal((mac_inst->if_module = nr_ue_if_module_init(inst)) != NULL, "can not initialize IF module\n"); AssertFatal((mac_inst->if_module = nr_ue_if_module_init(inst)) != NULL, "can not initialize IF module\n");
} }
......
...@@ -123,6 +123,8 @@ char *usrp_args = NULL; ...@@ -123,6 +123,8 @@ char *usrp_args = NULL;
char *tx_subdev = NULL; char *tx_subdev = NULL;
char *rx_subdev = NULL; char *rx_subdev = NULL;
char *rrc_config_path = NULL; char *rrc_config_path = NULL;
char *reconfig_file = NULL;
char *rbconfig_file = NULL;
char *uecap_file = NULL; char *uecap_file = NULL;
int dumpframe = 0; int dumpframe = 0;
...@@ -472,7 +474,7 @@ int main( int argc, char **argv ) { ...@@ -472,7 +474,7 @@ int main( int argc, char **argv ) {
#endif #endif
LOG_I(HW, "Version: %s\n", PACKAGE_VERSION); LOG_I(HW, "Version: %s\n", PACKAGE_VERSION);
init_NR_UE(1,uecap_file,rrc_config_path); init_NR_UE(1,uecap_file,rrc_config_path,reconfig_file,rbconfig_file);
int mode_offset = get_softmodem_params()->nsa ? NUMBER_OF_UE_MAX : 1; int mode_offset = get_softmodem_params()->nsa ? NUMBER_OF_UE_MAX : 1;
uint16_t node_number = get_softmodem_params()->node_number; uint16_t node_number = get_softmodem_params()->node_number;
......
...@@ -41,6 +41,8 @@ ...@@ -41,6 +41,8 @@
{"V" , CONFIG_HLP_VCD, PARAMFLAG_BOOL, .iptr=&vcdflag, .defintval=0, TYPE_INT, 0}, \ {"V" , CONFIG_HLP_VCD, PARAMFLAG_BOOL, .iptr=&vcdflag, .defintval=0, TYPE_INT, 0}, \
{"uecap_file", CONFIG_HLP_UECAP_FILE, 0, .strptr=&uecap_file, .defstrval="./uecap_ports1.xml", TYPE_STRING, 0}, \ {"uecap_file", CONFIG_HLP_UECAP_FILE, 0, .strptr=&uecap_file, .defstrval="./uecap_ports1.xml", TYPE_STRING, 0}, \
{"rrc_config_path", CONFIG_HLP_RRC_CFG_PATH, 0, .strptr=&rrc_config_path, .defstrval="./", TYPE_STRING, 0}, \ {"rrc_config_path", CONFIG_HLP_RRC_CFG_PATH, 0, .strptr=&rrc_config_path, .defstrval="./", TYPE_STRING, 0}, \
{"reconfig_file", CONFIG_HLP_RE_CFG_FILE, 0, .strptr=&reconfig_file, .defstrval="reconfig.raw", TYPE_STRING, 0}, \
{"rbconfig_file", CONFIG_HLP_RB_CFG_FILE, 0, .strptr=&rbconfig_file, .defstrval="rbconfig.raw", TYPE_STRING, 0}, \
{"ue-idx-standalone", NULL, 0, .u16ptr=&ue_idx_standalone, .defuintval=0xFFFF, TYPE_UINT16, 0}, \ {"ue-idx-standalone", NULL, 0, .u16ptr=&ue_idx_standalone, .defuintval=0xFFFF, TYPE_UINT16, 0}, \
{"ue-rxgain", CONFIG_HLP_UERXG, 0, .dblptr=&(rx_gain[0][0]), .defdblval=110, TYPE_DOUBLE, 0}, \ {"ue-rxgain", CONFIG_HLP_UERXG, 0, .dblptr=&(rx_gain[0][0]), .defdblval=110, TYPE_DOUBLE, 0}, \
{"ue-rxgain-off", CONFIG_HLP_UERXGOFF, 0, .dblptr=&rx_gain_off, .defdblval=0, TYPE_DOUBLE, 0}, \ {"ue-rxgain-off", CONFIG_HLP_UERXGOFF, 0, .dblptr=&rx_gain_off, .defdblval=0, TYPE_DOUBLE, 0}, \
...@@ -91,7 +93,7 @@ extern nrUE_params_t *get_nrUE_params(void); ...@@ -91,7 +93,7 @@ extern nrUE_params_t *get_nrUE_params(void);
// In nr-ue.c // In nr-ue.c
extern int setup_nr_ue_buffers(PHY_VARS_NR_UE **phy_vars_ue, openair0_config_t *openair0_cfg); extern int setup_nr_ue_buffers(PHY_VARS_NR_UE **phy_vars_ue, openair0_config_t *openair0_cfg);
extern void fill_ue_band_info(void); extern void fill_ue_band_info(void);
extern void init_NR_UE(int, char*, char*); extern void init_NR_UE(int, char*, char*, char*, char*);
extern void init_NR_UE_threads(int); extern void init_NR_UE_threads(int);
extern void reset_opp_meas(void); extern void reset_opp_meas(void);
extern void print_opp_meas(void); extern void print_opp_meas(void);
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include "filt16a_32.h" #include "filt16a_32.h"
#include "T.h" #include "T.h"
#include <openair1/PHY/TOOLS/phy_scope_interface.h> #include <openair1/PHY/TOOLS/phy_scope_interface.h>
extern openair0_config_t openair0_cfg[];
//#define DEBUG_PDSCH //#define DEBUG_PDSCH
//#define DEBUG_PDCCH //#define DEBUG_PDCCH
...@@ -45,7 +46,7 @@ ...@@ -45,7 +46,7 @@
#define NO_INTERP 1 #define NO_INTERP 1
/* Generic function to find the peak of channel estimation buffer */ /* Generic function to find the peak of channel estimation buffer */
void peak_estimator(int32_t *buffer, int32_t buf_len, int32_t *peak_idx, int32_t *peak_val) void peak_estimator(int32_t *buffer, int32_t buf_len, int32_t *peak_idx, int32_t *peak_val, int32_t mean_val)
{ {
int32_t max_val = 0, max_idx = 0, abs_val = 0; int32_t max_val = 0, max_idx = 0, abs_val = 0;
for(int k = 0; k < buf_len; k++) for(int k = 0; k < buf_len; k++)
...@@ -57,18 +58,29 @@ void peak_estimator(int32_t *buffer, int32_t buf_len, int32_t *peak_idx, int32_t ...@@ -57,18 +58,29 @@ void peak_estimator(int32_t *buffer, int32_t buf_len, int32_t *peak_idx, int32_t
max_idx = k; max_idx = k;
} }
} }
// Check for detection threshold
LOG_D(PHY,"PRS ToA estimator: max_val %d, mean_val %d, max_idx %d\n", max_val, mean_val, max_idx);
if((mean_val !=0) && (max_val/mean_val > 10))
{
*peak_val = max_val; *peak_val = max_val;
*peak_idx = max_idx; *peak_idx = max_idx;
}
else
{
*peak_val = 0;
*peak_idx = 0;
}
} }
int nr_prs_channel_estimation(uint8_t rsc_id, int nr_prs_channel_estimation(uint8_t gNB_id,
uint8_t rsc_id,
uint8_t rep_num, uint8_t rep_num,
PHY_VARS_NR_UE *ue, PHY_VARS_NR_UE *ue,
UE_nr_rxtx_proc_t *proc, UE_nr_rxtx_proc_t *proc,
NR_DL_FRAME_PARMS *frame_params, NR_DL_FRAME_PARMS *frame_params,
c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]) c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP])
{ {
int gNB_id = proc->gNB_id;
uint8_t rxAnt = 0, idx = 0; uint8_t rxAnt = 0, idx = 0;
prs_config_t *prs_cfg = &ue->prs_vars[gNB_id]->prs_resource[rsc_id].prs_cfg; prs_config_t *prs_cfg = &ue->prs_vars[gNB_id]->prs_resource[rsc_id].prs_cfg;
prs_meas_t **prs_meas = ue->prs_vars[gNB_id]->prs_resource[rsc_id].prs_meas; prs_meas_t **prs_meas = ue->prs_vars[gNB_id]->prs_resource[rsc_id].prs_meas;
...@@ -84,9 +96,10 @@ int nr_prs_channel_estimation(uint8_t rsc_id, ...@@ -84,9 +96,10 @@ int nr_prs_channel_estimation(uint8_t rsc_id,
int16_t *rxF, *pil, mod_prs[NR_MAX_PRS_LENGTH << 1]; int16_t *rxF, *pil, mod_prs[NR_MAX_PRS_LENGTH << 1];
const int16_t *fl, *fm, *fmm, *fml, *fmr, *fr; const int16_t *fl, *fm, *fmm, *fml, *fmr, *fr;
int16_t ch[2] = {0}, noiseFig[2] = {0}; int16_t ch[2] = {0};
int16_t k_prime = 0, k = 0, re_offset = 0, first_half = 0, second_half = 0; int16_t k_prime = 0, k = 0, re_offset = 0, first_half = 0, second_half = 0;
int32_t ch_pwr = 0, snr = 0; int32_t ch_pwr = 0, snr = 0, noiseFig[2] = {0}, mean_val = 0;
double ch_pwr_dbm = 0.0f;
#ifdef DEBUG_PRS_CHEST #ifdef DEBUG_PRS_CHEST
char filename[64] = {0}, varname[64] = {0}; char filename[64] = {0}, varname[64] = {0};
#endif #endif
...@@ -527,10 +540,17 @@ int nr_prs_channel_estimation(uint8_t rsc_id, ...@@ -527,10 +540,17 @@ int nr_prs_channel_estimation(uint8_t rsc_id,
(int16_t *)&chT_interpol[rxAnt][0],1); (int16_t *)&chT_interpol[rxAnt][0],1);
// peak estimator // peak estimator
mean_val = abs32((int32_t)ch_tmp[(prs_cfg->NumRB*12)]);
peak_estimator(&chT_interpol[rxAnt][start_offset], peak_estimator(&chT_interpol[rxAnt][start_offset],
frame_params->ofdm_symbol_size, frame_params->ofdm_symbol_size,
&prs_meas[rxAnt]->dl_toa, &prs_meas[rxAnt]->dl_toa,
&ch_pwr); &ch_pwr,
mean_val);
// adjusting the rx_gains for channel peak power
ch_pwr_dbm = 10*log10(ch_pwr)+30
- 10*log10(pow(2,30)) - ((int)openair0_cfg[0].rx_gain[0]
- (int)openair0_cfg[0].rx_gain_offset[0]) - dB_fixed(frame_params->ofdm_symbol_size);
//prs measurements //prs measurements
prs_meas[rxAnt]->gNB_id = gNB_id; prs_meas[rxAnt]->gNB_id = gNB_id;
...@@ -538,7 +558,7 @@ int nr_prs_channel_estimation(uint8_t rsc_id, ...@@ -538,7 +558,7 @@ int nr_prs_channel_estimation(uint8_t rsc_id,
prs_meas[rxAnt]->slot = proc->nr_slot_rx; prs_meas[rxAnt]->slot = proc->nr_slot_rx;
prs_meas[rxAnt]->rxAnt_idx = rxAnt; prs_meas[rxAnt]->rxAnt_idx = rxAnt;
prs_meas[rxAnt]->dl_aoa = rsc_id; prs_meas[rxAnt]->dl_aoa = rsc_id;
LOG_I(PHY, "[gNB %d][rsc %d][Rx %d][sfn %d][slot %d] DL PRS ToA ==> %d / %d samples, peak channel power %.1f dBm, SNR %+2d dB\n", gNB_id, rsc_id, rxAnt, proc->frame_rx, proc->nr_slot_rx, prs_meas[rxAnt]->dl_toa, frame_params->ofdm_symbol_size, 10*log10(ch_pwr/frame_params->ofdm_symbol_size)-30, prs_meas[rxAnt]->snr); LOG_I(PHY, "[gNB %d][rsc %d][Rx %d][sfn %d][slot %d] DL PRS ToA ==> %d / %d samples, peak channel power %.1f dBm, SNR %+2d dB\n", gNB_id, rsc_id, rxAnt, proc->frame_rx, proc->nr_slot_rx, prs_meas[rxAnt]->dl_toa, frame_params->ofdm_symbol_size, ch_pwr_dbm, prs_meas[rxAnt]->snr);
#ifdef DEBUG_PRS_CHEST #ifdef DEBUG_PRS_CHEST
sprintf(filename, "%s%i%s", "PRSpilot_", rxAnt, ".m"); sprintf(filename, "%s%i%s", "PRSpilot_", rxAnt, ".m");
......
...@@ -33,7 +33,8 @@ ...@@ -33,7 +33,8 @@
#define SYNCH_HYST 2 #define SYNCH_HYST 2
/* A function to perform the channel estimation of DL PRS signal */ /* A function to perform the channel estimation of DL PRS signal */
int nr_prs_channel_estimation(uint8_t rsc_id, int nr_prs_channel_estimation(uint8_t gNB_id,
uint8_t rsc_id,
uint8_t rep_num, uint8_t rep_num,
PHY_VARS_NR_UE *ue, PHY_VARS_NR_UE *ue,
UE_nr_rxtx_proc_t *proc, UE_nr_rxtx_proc_t *proc,
...@@ -41,7 +42,7 @@ int nr_prs_channel_estimation(uint8_t rsc_id, ...@@ -41,7 +42,7 @@ int nr_prs_channel_estimation(uint8_t rsc_id,
c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]); c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]);
/* Generic function to find the peak of channel estimation buffer */ /* Generic function to find the peak of channel estimation buffer */
void peak_estimator(int32_t *buffer, int32_t buf_len, int32_t *peak_idx, int32_t *peak_val); void peak_estimator(int32_t *buffer, int32_t buf_len, int32_t *peak_idx, int32_t *peak_val, int32_t mean_val);
/*! /*!
\brief This function performs channel estimation including frequency and temporal interpolation \brief This function performs channel estimation including frequency and temporal interpolation
......
...@@ -187,7 +187,7 @@ int nr_pbch_detection(UE_nr_rxtx_proc_t * proc, PHY_VARS_NR_UE *ue, int pbch_ini ...@@ -187,7 +187,7 @@ int nr_pbch_detection(UE_nr_rxtx_proc_t * proc, PHY_VARS_NR_UE *ue, int pbch_ini
#ifdef DEBUG_INITIAL_SYNCH #ifdef DEBUG_INITIAL_SYNCH
LOG_I(PHY,"[UE%d] Initial sync: pbch decoded sucessfully\n",ue->Mod_id); LOG_I(PHY,"[UE%d] Initial sync: pbch decoded sucessfully, ssb index %d\n",ue->Mod_id, frame_parms->ssb_index);
#endif #endif
return(0); return(0);
} else { } else {
......
...@@ -943,7 +943,8 @@ void pbch_pdcch_processing(PHY_VARS_NR_UE *ue, ...@@ -943,7 +943,8 @@ void pbch_pdcch_processing(PHY_VARS_NR_UE *ue,
(j%fp->symbols_per_slot), (j%fp->symbols_per_slot),
rxdataF); rxdataF);
} }
nr_prs_channel_estimation(rsc_id, nr_prs_channel_estimation(gNB_id,
rsc_id,
i, i,
ue, ue,
proc, proc,
......
...@@ -34,8 +34,8 @@ ...@@ -34,8 +34,8 @@
#include "rrc_proto.h" #include "rrc_proto.h"
#include "common/utils/LOG/log.h" #include "common/utils/LOG/log.h"
NR_UE_RRC_INST_t* nr_l3_init_ue(char* uecap, char* rrc_config_path){ NR_UE_RRC_INST_t* nr_l3_init_ue(char* uecap, char* rrc_config_path, char* reconfig_file, char* rbconfig_file){
//LOG_I(RRC, "[MAIN] NR UE MAC initialization...\n"); //LOG_I(RRC, "[MAIN] NR UE MAC initialization...\n");
return openair_rrc_top_init_ue_nr(uecap,rrc_config_path); return openair_rrc_top_init_ue_nr(uecap,rrc_config_path,reconfig_file,rbconfig_file);
} }
...@@ -345,7 +345,7 @@ void process_nsa_message(NR_UE_RRC_INST_t *rrc, nsa_message_t nsa_message_type, ...@@ -345,7 +345,7 @@ void process_nsa_message(NR_UE_RRC_INST_t *rrc, nsa_message_t nsa_message_type,
} }
NR_UE_RRC_INST_t* openair_rrc_top_init_ue_nr(char* uecap_file, char* rrc_config_path) NR_UE_RRC_INST_t* openair_rrc_top_init_ue_nr(char* uecap_file, char* rrc_config_path, char* reconfig_file, char* rbconfig_file)
{ {
if(NB_NR_UE_INST > 0) { if(NB_NR_UE_INST > 0) {
NR_UE_rrc_inst = (NR_UE_RRC_INST_t *)calloc(NB_NR_UE_INST , sizeof(NR_UE_RRC_INST_t)); NR_UE_rrc_inst = (NR_UE_RRC_INST_t *)calloc(NB_NR_UE_INST , sizeof(NR_UE_RRC_INST_t));
...@@ -370,10 +370,12 @@ NR_UE_RRC_INST_t* openair_rrc_top_init_ue_nr(char* uecap_file, char* rrc_config_ ...@@ -370,10 +370,12 @@ NR_UE_RRC_INST_t* openair_rrc_top_init_ue_nr(char* uecap_file, char* rrc_config_
// read in files for RRCReconfiguration and RBconfig // read in files for RRCReconfiguration and RBconfig
FILE *fd; FILE *fd;
char filename[1024]; char filename[1024];
if (rrc_config_path) if (rrc_config_path && reconfig_file)
sprintf(filename,"%s/reconfig.raw",rrc_config_path); sprintf(filename,"%s/%s",rrc_config_path,reconfig_file);
else else
sprintf(filename,"reconfig.raw"); sprintf(filename,"reconfig.raw");
LOG_I(NR_RRC, "using %s for rrc init[1/2]\n",filename);
fd = fopen(filename,"r"); fd = fopen(filename,"r");
char buffer[1024]; char buffer[1024];
AssertFatal(fd, AssertFatal(fd,
...@@ -384,10 +386,12 @@ NR_UE_RRC_INST_t* openair_rrc_top_init_ue_nr(char* uecap_file, char* rrc_config_ ...@@ -384,10 +386,12 @@ NR_UE_RRC_INST_t* openair_rrc_top_init_ue_nr(char* uecap_file, char* rrc_config_
int msg_len=fread(buffer,1,1024,fd); int msg_len=fread(buffer,1,1024,fd);
fclose(fd); fclose(fd);
process_nsa_message(NR_UE_rrc_inst, nr_SecondaryCellGroupConfig_r15, buffer,msg_len); process_nsa_message(NR_UE_rrc_inst, nr_SecondaryCellGroupConfig_r15, buffer,msg_len);
if (rrc_config_path) if (rrc_config_path && rbconfig_file)
sprintf(filename,"%s/rbconfig.raw",rrc_config_path); sprintf(filename,"%s/%s",rrc_config_path,rbconfig_file);
else else
sprintf(filename,"rbconfig.raw"); sprintf(filename,"rbconfig.raw");
LOG_I(NR_RRC, "using %s for rrc init[2/2]\n",filename);
fd = fopen(filename,"r"); fd = fopen(filename,"r");
AssertFatal(fd, AssertFatal(fd,
"cannot read file %s: errno %d, %s\n", "cannot read file %s: errno %d, %s\n",
......
...@@ -56,14 +56,14 @@ extern queue_t nr_ul_tti_req_queue; ...@@ -56,14 +56,14 @@ extern queue_t nr_ul_tti_req_queue;
// main_rrc.c // main_rrc.c
// //
/**\brief Layer 3 initialization*/ /**\brief Layer 3 initialization*/
NR_UE_RRC_INST_t* nr_l3_init_ue(char*,char*); NR_UE_RRC_INST_t* nr_l3_init_ue(char*,char*,char*,char*);
// //
// UE_rrc.c // UE_rrc.c
// //
/**\brief Initial the top level RRC structure instance*/ /**\brief Initial the top level RRC structure instance*/
NR_UE_RRC_INST_t* openair_rrc_top_init_ue_nr(char*,char*); NR_UE_RRC_INST_t* openair_rrc_top_init_ue_nr(char*,char*,char*,char*);
......
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