Commit 34f26076 authored by Laurent THOMAS's avatar Laurent THOMAS

make better log text for ue synchronization, make better sync code, no functional change

parent 883724b9
...@@ -45,7 +45,6 @@ ...@@ -45,7 +45,6 @@
#include "PHY/NR_REFSIG/sss_nr.h" #include "PHY/NR_REFSIG/sss_nr.h"
#include "PHY/NR_REFSIG/refsig_defs_ue.h" #include "PHY/NR_REFSIG/refsig_defs_ue.h"
extern openair0_config_t openair0_cfg[];
//static nfapi_nr_config_request_t config_t; //static nfapi_nr_config_request_t config_t;
//static nfapi_nr_config_request_t* config =&config_t; //static nfapi_nr_config_request_t* config =&config_t;
int cnt=0; int cnt=0;
...@@ -53,94 +52,36 @@ int cnt=0; ...@@ -53,94 +52,36 @@ int cnt=0;
// #define DEBUG_INITIAL_SYNCH // #define DEBUG_INITIAL_SYNCH
#define DUMP_PBCH_CH_ESTIMATES 0 #define DUMP_PBCH_CH_ESTIMATES 0
// create a new node of SSB structure
NR_UE_SSB* create_ssb_node(uint8_t i, uint8_t h) {
NR_UE_SSB *new_node = (NR_UE_SSB*)malloc(sizeof(NR_UE_SSB)); int nr_pbch_detection(const UE_nr_rxtx_proc_t *proc,
new_node->i_ssb = i; PHY_VARS_NR_UE *ue,
new_node->n_hf = h; int pbch_initial_symbol,
new_node->c_re = 0; c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP])
new_node->c_im = 0;
new_node->metric = 0;
new_node->next_ssb = NULL;
return new_node;
}
// insertion of the structure in the ordered list (highest metric first)
NR_UE_SSB* insert_into_list(NR_UE_SSB *head, NR_UE_SSB *node) {
if (node->metric > head->metric) {
node->next_ssb = head;
head = node;
return head;
}
NR_UE_SSB *current = head;
while (current->next_ssb !=NULL) {
NR_UE_SSB *temp=current->next_ssb;
if(node->metric > temp->metric) {
node->next_ssb = temp;
current->next_ssb = node;
return head;
}
else
current = temp;
}
current->next_ssb = node;
return head;
}
void free_list(NR_UE_SSB *node) {
if (node->next_ssb != NULL)
free_list(node->next_ssb);
free(node);
}
static bool nr_pbch_detection(const UE_nr_rxtx_proc_t *proc,
PHY_VARS_NR_UE *ue,
int pbch_initial_symbol,
c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP])
{ {
NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms;
NR_UE_SSB *best_ssb = NULL; const int N_L = (frame_parms->Lmax == 4) ? 4 : 8;
NR_UE_SSB *current_ssb; const int N_hf = (frame_parms->Lmax == 4) ? 2 : 1;
NR_UE_SSB best_ssb[N_L * N_hf];
uint8_t N_L = (frame_parms->Lmax == 4)? 4:8; NR_UE_SSB *current_ssb = best_ssb;
uint8_t N_hf = (frame_parms->Lmax == 4)? 2:1;
// loops over possible pbch dmrs cases to retrive best estimated i_ssb (and n_hf for Lmax=4) for multiple ssb detection // loops over possible pbch dmrs cases to retrive best estimated i_ssb (and n_hf for Lmax=4) for multiple ssb detection
for (int hf = 0; hf < N_hf; hf++) { for (int hf = 0; hf < N_hf; hf++) {
for (int l = 0; l < N_L ; l++) { for (int l = 0; l < N_L ; l++) {
// initialization of structure // initialization of structure
current_ssb = create_ssb_node(l,hf); *current_ssb = (NR_UE_SSB){.i_ssb = l, .n_hf = hf};
start_meas(&ue->dlsch_channel_estimation_stats); start_meas(&ue->dlsch_channel_estimation_stats);
// computing correlation between received DMRS symbols and transmitted sequence for current i_ssb and n_hf // computing correlation between received DMRS symbols and transmitted sequence for current i_ssb and n_hf
for(int i=pbch_initial_symbol; i<pbch_initial_symbol+3;i++) for(int i=pbch_initial_symbol; i<pbch_initial_symbol+3;i++)
nr_pbch_dmrs_correlation(ue, proc, i, i - pbch_initial_symbol, current_ssb, rxdataF); nr_pbch_dmrs_correlation(ue, proc, i, i - pbch_initial_symbol, current_ssb, rxdataF);
stop_meas(&ue->dlsch_channel_estimation_stats); stop_meas(&ue->dlsch_channel_estimation_stats);
current_ssb->metric = current_ssb->c_re*current_ssb->c_re + current_ssb->c_im*current_ssb->c_im;
// generate a list of SSB structures
if (best_ssb == NULL)
best_ssb = current_ssb;
else
best_ssb = insert_into_list(best_ssb,current_ssb);
current_ssb->metric = current_ssb->c_re * current_ssb->c_re + current_ssb->c_im * current_ssb->c_im;
current_ssb++;
} }
} }
NR_UE_SSB *temp_ptr = best_ssb; NR_UE_SSB *temp_ptr=best_ssb;
bool ret = false; while (ret!=0 && temp_ptr != NULL) {
while (!ret && temp_ptr != NULL) {
start_meas(&ue->dlsch_channel_estimation_stats); start_meas(&ue->dlsch_channel_estimation_stats);
// computing channel estimation for selected best ssb // computing channel estimation for selected best ssb
const int estimateSz = frame_parms->symbols_per_slot * frame_parms->ofdm_symbol_size; const int estimateSz = frame_parms->symbols_per_slot * frame_parms->ofdm_symbol_size;
...@@ -167,14 +108,13 @@ static bool nr_pbch_detection(const UE_nr_rxtx_proc_t *proc, ...@@ -167,14 +108,13 @@ static bool nr_pbch_detection(const UE_nr_rxtx_proc_t *proc,
1); 1);
} }
temp_ptr=temp_ptr->next_ssb; temp_ptr++;
} }
free_list(best_ssb); if (ret == 0) {
if (ret) {
frame_parms->nb_antenna_ports_gNB = 1; // pbch_tx_ant;
LOG_I(PHY, "[UE%d] Initial sync: pbch decoded sucessfully, ssb index %d\n", ue->Mod_id, frame_parms->ssb_index); LOG_I(PHY, "[UE%d] Initial sync: pbch decoded sucessfully, ssb index %d\n", ue->Mod_id, frame_parms->ssb_index);
} else {
LOG_W(PHY, "[UE%d] Initial sync: pbch not decoded, ssb index %d\n", ue->Mod_id, frame_parms->ssb_index);
} }
return ret; return ret;
} }
...@@ -394,11 +334,7 @@ nr_initial_sync_t nr_initial_sync(UE_nr_rxtx_proc_t *proc, PHY_VARS_NR_UE *ue, i ...@@ -394,11 +334,7 @@ nr_initial_sync_t nr_initial_sync(UE_nr_rxtx_proc_t *proc, PHY_VARS_NR_UE *ue, i
// send sync status to higher layers later when timing offset converge to target timing // send sync status to higher layers later when timing offset converge to target timing
} }
LOG_I(PHY, LOG_I(PHY, "[UE %d] Measured Carrier Frequency offset %d Hz\n", ue->Mod_id, ue->common_vars.freq_offset);
"[UE %d] Measured Carrier Frequency %.0f Hz (offset %d Hz)\n",
ue->Mod_id,
openair0_cfg[0].rx_freq[0] + ue->common_vars.freq_offset,
ue->common_vars.freq_offset);
} else { } else {
#ifdef DEBUG_INITIAL_SYNC #ifdef DEBUG_INITIAL_SYNC
LOG_I(PHY,"[UE%d] Initial sync : PBCH not ok\n",ue->Mod_id); LOG_I(PHY,"[UE%d] Initial sync : PBCH not ok\n",ue->Mod_id);
......
...@@ -672,7 +672,15 @@ static int pss_search_time_nr(c16_t **rxdata, PHY_VARS_NR_UE *ue, int fo_flag, i ...@@ -672,7 +672,15 @@ static int pss_search_time_nr(c16_t **rxdata, PHY_VARS_NR_UE *ue, int fo_flag, i
*nid2 = pss_source; *nid2 = pss_source;
LOG_I(PHY,"[UE] nr_synchro_time: Sync source = %d, Peak found at pos %d, val = %llu (%d dB) avg %d dB, ffo %lf\n", pss_source, peak_position, (unsigned long long)peak_value, dB_fixed64(peak_value),dB_fixed64(avg[pss_source]),ffo_est); LOG_I(PHY,
"[UE] nr_synchro_time: Sync source (nid2) = %d, Peak found at pos %d, val = %ld (%d dB power over signal avg %d dB), ffo "
"%lf\n",
pss_source,
peak_position,
peak_value,
dB_fixed64(peak_value),
dB_fixed64(avg[pss_source]),
ffo_est);
if (peak_value < 5*avg[pss_source]) if (peak_value < 5*avg[pss_source])
return(-1); return(-1);
......
...@@ -503,15 +503,15 @@ bool rx_sss_nr(PHY_VARS_NR_UE *ue, ...@@ -503,15 +503,15 @@ bool rx_sss_nr(PHY_VARS_NR_UE *ue,
Nid1 = GET_NID1(frame_parms->Nid_cell); Nid1 = GET_NID1(frame_parms->Nid_cell);
LOG_D(PHY,"Nid2 %d Nid1 %d tot_metric %d, phase_max %d \n", Nid2, Nid1, *tot_metric, *phase_max); LOG_D(PHY,"Nid2 %d Nid1 %d tot_metric %d, phase_max %d \n", Nid2, Nid1, *tot_metric, *phase_max);
} }
//#endif // #endif
if (Nid1==N_ID_1_NUMBER)
return false;
int re = 0; int re = 0;
int im = 0; int im = 0;
if (Nid1 == N_ID_1_NUMBER) { if (Nid1 == N_ID_1_NUMBER) {
LOG_I(PHY,"Failed to detect SSS after PSS\n"); LOG_W(PHY,
"Failed to detect SSS after PSS, metric of SSS %d, threshold to consider SSS valid %d, detected PCI: %d\n",
*tot_metric,
SSS_METRIC_FLOOR_NR,
frame_parms->Nid_cell);
return false; return false;
} }
d = (int16_t *)&d_sss[Nid2][Nid1]; d = (int16_t *)&d_sss[Nid2][Nid1];
...@@ -524,7 +524,8 @@ bool rx_sss_nr(PHY_VARS_NR_UE *ue, ...@@ -524,7 +524,8 @@ bool rx_sss_nr(PHY_VARS_NR_UE *ue,
double ffo_pss = ((double)ue->common_vars.freq_offset)/frame_parms->subcarrier_spacing; double ffo_pss = ((double)ue->common_vars.freq_offset)/frame_parms->subcarrier_spacing;
LOG_W(NR_PHY, LOG_W(NR_PHY,
"ffo_pss %f (%i Hz), ffo_sss %f (%i Hz), ffo_pss+ffo_sss %f (%i Hz), nid1: %d, nid2: %d\n", "SSS detected, PCI: %d, ffo_pss %f (%i Hz), ffo_sss %f (%i Hz), ffo_pss+ffo_sss %f (%i Hz), nid1: %d, nid2: %d\n",
frame_parms->Nid_cell,
ffo_pss, ffo_pss,
(int)(ffo_pss * frame_parms->subcarrier_spacing), (int)(ffo_pss * frame_parms->subcarrier_spacing),
ffo_sss, ffo_sss,
......
...@@ -314,7 +314,6 @@ typedef struct NR_UE_SSB { ...@@ -314,7 +314,6 @@ typedef struct NR_UE_SSB {
uint32_t metric; // metric to order SSB hypothesis uint32_t metric; // metric to order SSB hypothesis
uint32_t c_re; uint32_t c_re;
uint32_t c_im; uint32_t c_im;
struct NR_UE_SSB *next_ssb;
} NR_UE_SSB; } NR_UE_SSB;
typedef struct UE_NR_SCAN_INFO_s { typedef struct UE_NR_SCAN_INFO_s {
......
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