Commit 0ec09ea9 authored by General ABS's avatar General ABS Committed by rmagueta

Move nr_ue_meas_neighboring_cell() function to a new thread

parent baba58df
......@@ -60,6 +60,14 @@ int nr_slot_fep_init_sync(PHY_VARS_NR_UE *ue,
bool pbch_decoded,
c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]);
int nr_slot_fep_meas(PHY_VARS_NR_UE *ue,
int Ns,
unsigned char symbol,
int sample_offset,
uint32_t rxdata_size,
int rxdata[][rxdata_size],
c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]);
int slot_fep_mbsfn(PHY_VARS_UE *phy_vars_ue,
unsigned char l,
int subframe,
......
......@@ -250,6 +250,63 @@ int nr_slot_fep_init_sync(PHY_VARS_NR_UE *ue,
return 0;
}
int nr_slot_fep_meas(PHY_VARS_NR_UE *ue,
int Ns,
unsigned char symbol,
int sample_offset,
uint32_t rxdata_size,
int rxdata[][rxdata_size],
c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP])
{
NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms;
AssertFatal(symbol < frame_parms->symbols_per_slot, "slot_fep: symbol must be between 0 and %d\n", frame_parms->symbols_per_slot - 1);
AssertFatal(Ns < frame_parms->slots_per_frame, "slot_fep: Ns must be between 0 and %d\n", frame_parms->slots_per_frame - 1);
unsigned int nb_prefix_samples = frame_parms->nb_prefix_samples;
unsigned int nb_prefix_samples0 = frame_parms->nb_prefix_samples;
unsigned int frame_length_samples = frame_parms->samples_per_frame;
dft_size_idx_t dftsize = get_dft(frame_parms->ofdm_symbol_size);
unsigned int slot_offset = frame_parms->get_samples_slot_timestamp(Ns, frame_parms, 0);
unsigned int abs_symbol = Ns * frame_parms->symbols_per_slot + symbol;
unsigned int rx_offset = sample_offset + slot_offset;
for (int idx_symb = Ns * frame_parms->symbols_per_slot; idx_symb <= abs_symbol; idx_symb++) {
rx_offset += (abs_symbol % (0x7 << frame_parms->numerology_index)) ? nb_prefix_samples : nb_prefix_samples0;
}
rx_offset += frame_parms->ofdm_symbol_size * symbol;
int32_t tmp_dft_in[8192] __attribute__((aligned(32)));
for (unsigned char aa = 0; aa < frame_parms->nb_antennas_rx; aa++) {
int16_t *rxdata_ptr;
rx_offset %= frame_length_samples * 2;
if (rx_offset + frame_parms->ofdm_symbol_size > frame_length_samples * 2) {
memcpy((void *)&tmp_dft_in[0], (void *)&rxdata[aa][rx_offset], (frame_length_samples * 2 - rx_offset) * sizeof(int32_t));
memcpy((void *)&tmp_dft_in[frame_length_samples * 2 - rx_offset], (void *)&rxdata[aa][0], (frame_parms->ofdm_symbol_size - (frame_length_samples * 2 - rx_offset)) * sizeof(int32_t));
rxdata_ptr = (int16_t *)tmp_dft_in;
} else if ((rx_offset & 7) != 0) {
// if input to dft is not 256-bit aligned
memcpy((void *)&tmp_dft_in[0], (void *)&rxdata[aa][rx_offset], frame_parms->ofdm_symbol_size * sizeof(int32_t));
rxdata_ptr = (int16_t *)tmp_dft_in;
} else {
// use dft input from RX buffer directly
rxdata_ptr = (int16_t *)&rxdata[aa][rx_offset];
}
start_meas(&ue->rx_dft_stats);
dft(dftsize, rxdata_ptr, (int16_t *)&rxdataF[aa][frame_parms->ofdm_symbol_size * symbol], 1);
stop_meas(&ue->rx_dft_stats);
int symb_offset = (Ns % frame_parms->slots_per_subframe) * frame_parms->symbols_per_slot;
c16_t rot2 = frame_parms->symbol_rotation[0][symbol + symb_offset];
rot2.i = -rot2.i;
c16_t *this_symbol = &rxdataF[aa][frame_parms->ofdm_symbol_size * symbol];
rotate_cpx_vector(this_symbol, &rot2, this_symbol, frame_parms->ofdm_symbol_size, 15);
}
return 0;
}
int nr_slot_fep_ul(NR_DL_FRAME_PARMS *frame_parms,
int32_t *rxdata,
......
......@@ -115,7 +115,7 @@ void nr_ue_ssb_rsrp_measurements(PHY_VARS_NR_UE *ue,
UE_nr_rxtx_proc_t *proc,
c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]);
void nr_ue_meas_neighboring_cell(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc);
void *nr_ue_meas_neighboring_cell(void *param);
void nr_ue_rrc_measurements(PHY_VARS_NR_UE *ue,
UE_nr_rxtx_proc_t *proc,
......
......@@ -263,11 +263,20 @@ void nr_ue_ssb_rsrp_measurements(PHY_VARS_NR_UE *ue,
}
}
void nr_ue_meas_neighboring_cell(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc)
void *nr_ue_meas_neighboring_cell(void *param)
{
PHY_VARS_NR_UE *ue = (PHY_VARS_NR_UE *)param;
UE_nr_rxtx_proc_t *proc = ue->measurements.meas_proc;
NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms;
int **rxdata = ue->common_vars.rxdata;
// Copy rxdata, because this function is running in a separate thread, and rxdata will be changed in another thread, before this function finishes measuring.
uint32_t rxdata_size = (2 * (frame_parms->samples_per_frame) + frame_parms->ofdm_symbol_size);
int rxdata[frame_parms->nb_antennas_rx][rxdata_size];
for (int i = 0; i < frame_parms->nb_antennas_rx; i++) {
memcpy(rxdata[i], ue->common_vars.rxdata[i], rxdata_size * sizeof(int32_t));
}
const uint32_t rxdataF_sz = ue->frame_parms.samples_per_slot_wCP;
for (int cell_idx = 0; cell_idx < NUMBER_OF_NEIGHBORING_CELLs_MAX; cell_idx++) {
......@@ -276,6 +285,7 @@ void nr_ue_meas_neighboring_cell(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc)
if (nr_neighboring_cell->active == 0) {
continue;
}
ue->measurements.meas_running = true;
__attribute__((aligned(32))) c16_t rxdataF[ue->frame_parms.nb_antennas_rx][rxdataF_sz];
neighboring_cell_info_t *neighboring_cell_info = &ue->measurements.neighboring_cell_info[cell_idx];
......@@ -333,7 +343,7 @@ void nr_ue_meas_neighboring_cell(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc)
unsigned int k = 0;
uint8_t sss_symbol = SSS_SYMBOL_NB - PSS_SYMBOL_NB;
nr_slot_fep_init_sync(ue, proc, sss_symbol, ssb_offset, false, rxdataF);
nr_slot_fep_meas(ue, 0, sss_symbol, ssb_offset, rxdata_size, rxdata, rxdataF);
c16_t *sss_rx = &rxdataF[0][frame_parms->ofdm_symbol_size * sss_symbol];
if (nr_neighboring_cell->perform_validation == 1) {
......@@ -438,6 +448,9 @@ void nr_ue_meas_neighboring_cell(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc)
free(rx_ind);
}
}
ue->measurements.meas_running = false;
pthread_detach(ue->measurements.meas_thread);
return NULL;
}
// This function computes the received noise power
......
......@@ -217,8 +217,11 @@ typedef struct {
unsigned char nb_antennas_rx;
/// DLSCH error counter
// short dlsch_errors;
/// Info about neighboring cells to permorme the measurements
/// Info about neighboring cells to perform the measurements
neighboring_cell_info_t neighboring_cell_info[NUMBER_OF_NEIGHBORING_CELLs_MAX];
UE_nr_rxtx_proc_t *meas_proc;
pthread_t meas_thread;
bool meas_running;
} PHY_NR_MEASUREMENTS;
typedef struct {
......
......@@ -858,6 +858,26 @@ bool nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue,
return dec;
}
bool check_meas_to_perform(PHY_VARS_NR_UE *ue, int nr_slot_rx)
{
if (nr_slot_rx != 0) {
return false;
}
if (ue->measurements.meas_running == true) {
return false;
}
for (int cell_idx = 0; cell_idx < NUMBER_OF_NEIGHBORING_CELLs_MAX; cell_idx++) {
fapi_nr_neighboring_cell_t *nr_neighboring_cell = &PHY_vars_UE_g[ue->Mod_id][ue->CC_id]->nrUE_config.meas_config.nr_neighboring_cell[cell_idx];
if (nr_neighboring_cell->active == 1) {
return true;
}
}
return false;
}
void pbch_pdcch_processing(PHY_VARS_NR_UE *ue,
UE_nr_rxtx_proc_t *proc,
nr_phy_data_t *phy_data) {
......@@ -982,8 +1002,11 @@ void pbch_pdcch_processing(PHY_VARS_NR_UE *ue,
} // for rsc_id
} // for gNB_id
if (nr_slot_rx == 0) {
nr_ue_meas_neighboring_cell(ue, proc);
PHY_NR_MEASUREMENTS *measurements = &ue->measurements;
if (check_meas_to_perform(ue, nr_slot_rx) == true) {
measurements->meas_proc = proc;
int ret = pthread_create(&measurements->meas_thread, NULL, nr_ue_meas_neighboring_cell, (void *)ue);
AssertFatal(ret == 0, "%s: Thread for neighboring measurements was not created, errno: %d\n", __FUNCTION__, errno);
}
if ((frame_rx%64 == 0) && (nr_slot_rx==0)) {
......
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