make better log text for ue synchronization, make better sync code, no functional change
This commit is contained in:
@@ -45,7 +45,6 @@
|
||||
#include "PHY/NR_REFSIG/sss_nr.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 =&config_t;
|
||||
int cnt=0;
|
||||
@@ -53,94 +52,36 @@ int cnt=0;
|
||||
// #define DEBUG_INITIAL_SYNCH
|
||||
#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));
|
||||
new_node->i_ssb = i;
|
||||
new_node->n_hf = h;
|
||||
new_node->c_re = 0;
|
||||
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])
|
||||
int 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_UE_SSB *best_ssb = NULL;
|
||||
NR_UE_SSB *current_ssb;
|
||||
|
||||
uint8_t N_L = (frame_parms->Lmax == 4)? 4:8;
|
||||
uint8_t N_hf = (frame_parms->Lmax == 4)? 2:1;
|
||||
|
||||
const int N_L = (frame_parms->Lmax == 4) ? 4 : 8;
|
||||
const int N_hf = (frame_parms->Lmax == 4) ? 2 : 1;
|
||||
NR_UE_SSB best_ssb[N_L * N_hf];
|
||||
NR_UE_SSB *current_ssb = best_ssb;
|
||||
// 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 l = 0; l < N_L ; l++) {
|
||||
|
||||
// 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);
|
||||
// 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++)
|
||||
nr_pbch_dmrs_correlation(ue, proc, i, i - pbch_initial_symbol, current_ssb, rxdataF);
|
||||
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;
|
||||
bool ret = false;
|
||||
while (!ret && temp_ptr != NULL) {
|
||||
|
||||
NR_UE_SSB *temp_ptr=best_ssb;
|
||||
while (ret!=0 && temp_ptr != NULL) {
|
||||
start_meas(&ue->dlsch_channel_estimation_stats);
|
||||
// computing channel estimation for selected best ssb
|
||||
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,
|
||||
1);
|
||||
}
|
||||
|
||||
temp_ptr=temp_ptr->next_ssb;
|
||||
temp_ptr++;
|
||||
}
|
||||
|
||||
free_list(best_ssb);
|
||||
|
||||
if (ret) {
|
||||
frame_parms->nb_antenna_ports_gNB = 1; // pbch_tx_ant;
|
||||
if (ret == 0) {
|
||||
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;
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
|
||||
LOG_I(PHY,
|
||||
"[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);
|
||||
LOG_I(PHY, "[UE %d] Measured Carrier Frequency offset %d Hz\n", ue->Mod_id, ue->common_vars.freq_offset);
|
||||
} else {
|
||||
#ifdef DEBUG_INITIAL_SYNC
|
||||
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
|
||||
|
||||
*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])
|
||||
return(-1);
|
||||
|
||||
@@ -503,15 +503,15 @@ bool rx_sss_nr(PHY_VARS_NR_UE *ue,
|
||||
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);
|
||||
}
|
||||
//#endif
|
||||
|
||||
if (Nid1==N_ID_1_NUMBER)
|
||||
return false;
|
||||
|
||||
// #endif
|
||||
int re = 0;
|
||||
int im = 0;
|
||||
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;
|
||||
}
|
||||
d = (int16_t *)&d_sss[Nid2][Nid1];
|
||||
@@ -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;
|
||||
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,
|
||||
(int)(ffo_pss * frame_parms->subcarrier_spacing),
|
||||
ffo_sss,
|
||||
|
||||
@@ -314,7 +314,6 @@ typedef struct NR_UE_SSB {
|
||||
uint32_t metric; // metric to order SSB hypothesis
|
||||
uint32_t c_re;
|
||||
uint32_t c_im;
|
||||
struct NR_UE_SSB *next_ssb;
|
||||
} NR_UE_SSB;
|
||||
|
||||
typedef struct UE_NR_SCAN_INFO_s {
|
||||
|
||||
Reference in New Issue
Block a user