Commit 45d4cec2 authored by Laurent THOMAS's avatar Laurent THOMAS

fix regressions for large physical cell id values

parent 9055fabe
......@@ -1126,21 +1126,23 @@ int get_scan_ssb_first_sc(const double fc, const int nbRB, const int nrBand, con
const double startFreq = get_start_freq(fc, nbRB, mu);
const double stopFreq = get_stop_freq(fc, nbRB, mu);
int scanGscnStart = -1;
int scanGscnStop = -1;
sync_raster_t tmpRaster = {0};
for (const sync_raster_t *r = sync_raster; r < r + (sizeof(sync_raster) / sizeof(sync_raster_t)); r++) {
if (r->band == nrBand && r->scs_index == mu) {
tmpRaster = *r;
break;
}
int scanGscnStart = 0;
int scanGscnStop = 0;
const sync_raster_t *tmpRaster = sync_raster;
const sync_raster_t * end=sync_raster + sizeofArray(sync_raster);
while (tmpRaster < end && (tmpRaster->band != nrBand || tmpRaster->scs_index != mu))
tmpRaster++;
if (tmpRaster >= end) {
LOG_E(PHY, "raster not found nrband=%d, mu=%d\n", nrBand, mu);
return 0;
}
find_gscn_to_scan(startFreq, stopFreq, tmpRaster, &scanGscnStart, &scanGscnStop);
find_gscn_to_scan(startFreq, stopFreq, *tmpRaster, &scanGscnStart, &scanGscnStop);
const double scs = MU_SCS(mu) * 1e3;
const double pointA = fc - (nbRB / 2 * scs * NR_NB_SC_PER_RB);
int numGscn = 0;
for (int g = scanGscnStart; (g <= scanGscnStop) && (numGscn < MAX_GSCN_BAND); g += tmpRaster.step_gscn) {
for (int g = scanGscnStart; (g <= scanGscnStop) && (numGscn < MAX_GSCN_BAND); g += tmpRaster->step_gscn) {
ssbInfo[numGscn].ssRef = get_ssref_from_gscn(g);
ssbInfo[numGscn].ssbFirstSC = get_ssb_first_sc(pointA, ssbInfo[numGscn].ssRef, mu);
ssbInfo[numGscn].gscn = g;
......
......@@ -735,6 +735,7 @@ void *UE_thread(void *arg)
readFrame(UE, &sync_timestamp, false);
notifiedFIFO_elt_t *Msg = newNotifiedFIFO_elt(sizeof(syncData_t), 0, &nf, UE_synch);
syncData_t *syncMsg = (syncData_t *)NotifiedFifoData(Msg);
*syncMsg = (syncData_t){0};
NR_DL_FRAME_PARMS *fp = &UE->frame_parms;
if (UE->UE_scan_carrier) {
// Get list of GSCN in this band for UE's bandwidth and center frequency.
......@@ -743,10 +744,7 @@ void *UE_thread(void *arg)
get_scan_ssb_first_sc(fp->dl_CarrierFreq, fp->N_RB_DL, fp->nr_band, fp->numerology_index, syncMsg->gscnInfo);
} else {
LOG_W(PHY, "SSB position provided\n");
nr_gscn_info_t *g = syncMsg->gscnInfo;
g->ssbFirstSC = fp->ssb_start_subcarrier;
g->gscn = 0;
g->ssRef = 0;
syncMsg->gscnInfo[0] = (nr_gscn_info_t){.ssbFirstSC = fp->ssb_start_subcarrier};
syncMsg->numGscn = 1;
}
syncMsg->UE = UE;
......
......@@ -1147,7 +1147,11 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB,
uint32_t x1 = 0, x2 = 0, sGold = 0;
uint8_t *sGold8 = (uint8_t *)&sGold;
x2 = (((1<<17)*((14*slot) + (pucch_pdu->start_symbol_index+symb) + 1)*((2*pucch_pdu->dmrs_scrambling_id) + 1)) + (2*pucch_pdu->dmrs_scrambling_id))%(1U<<31); // c_init calculation according to TS38.211 subclause
const int scramble = pucch_pdu->dmrs_scrambling_id * 2;
// fixme: when MR2754 will be merged, use the gold sequence cache instead of regenerate each time
x2 = ((1ULL << 17) * ((NR_NUMBER_OF_SYMBOLS_PER_SLOT * slot + pucch_pdu->start_symbol_index + symb + 1) * (scramble + 1))
+ scramble)
% (1U << 31); // c_init calculation according to TS38.211 subclause
#ifdef DEBUG_NR_PUCCH_RX
printf("slot %d, start_symbol_index %d, symbol %d, dmrs_scrambling_id %d\n",
slot,pucch_pdu->start_symbol_index,symb,pucch_pdu->dmrs_scrambling_id);
......
......@@ -651,12 +651,12 @@ int nr_pbch_channel_estimation(const NR_DL_FRAME_PARMS *fp,
const UE_nr_rxtx_proc_t *proc,
unsigned char symbol,
int dmrss,
uint8_t ssb_index,
uint8_t n_hf,
uint ssb_index,
uint n_hf,
int ssb_start_subcarrier,
const c16_t rxdataF[][fp->samples_per_slot_wCP],
bool sidelink,
uint16_t Nid)
uint Nid)
{
int Ns = proc->nr_slot_rx;
c16_t pilot[200] __attribute__((aligned(16)));
......
......@@ -75,12 +75,12 @@ int nr_pbch_channel_estimation(const NR_DL_FRAME_PARMS *fp,
const UE_nr_rxtx_proc_t *proc,
unsigned char symbol,
int dmrss,
uint8_t ssb_index,
uint8_t n_hf,
uint ssb_index,
uint n_hf,
int ssb_start_subcarrier,
const c16_t rxdataF[][fp->samples_per_slot_wCP],
bool sidelink,
uint16_t Nid);
uint Nid);
int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue,
const UE_nr_rxtx_proc_t *proc,
......
......@@ -47,9 +47,7 @@
#include "PHY/TOOLS/tools_defs.h"
#include "nr-uesoftmodem.h"
//static nfapi_nr_config_request_t config_t;
//static nfapi_nr_config_request_t* config =&config_t;
// #define DEBUG_INITIAL_SYNCH
//#define DEBUG_INITIAL_SYNCH
#define DUMP_PBCH_CH_ESTIMATES 0
// structure used for multiple SSB detection
......@@ -223,8 +221,7 @@ void nr_scan_ssb(void *arg)
ssbInfo->ssbOffset = sync_pos - fp->nb_prefix_samples;
#ifdef DEBUG_INITIAL_SYNCH
LOG_I(PHY, "[UE%d] Initial sync : Estimated PSS position %d, Nid2 %d\n", ue->Mod_id, sync_pos, ue->common_vars.nid2);
LOG_I(PHY, "sync_pos %d ssb_offset %d \n", sync_pos, ue->ssb_offset);
LOG_I(PHY, "Initial sync : Estimated PSS position %d, Nid2 %d, ssb offset %d\n", sync_pos, nid2, ssbInfo->ssbOffset);
#endif
/* check that SSS/PBCH block is continuous inside the received buffer */
if (ssbInfo->ssbOffset + NR_N_SYMBOLS_SSB * (fp->ofdm_symbol_size + fp->nb_prefix_samples) >= fp->samples_per_frame) {
......@@ -256,10 +253,6 @@ void nr_scan_ssb(void *arg)
rxdataF,
link_type_dl);
#ifdef DEBUG_INITIAL_SYNCH
LOG_I(PHY, "Calling sss detection (normal CP)\n");
#endif
int freq_offset_sss = 0;
int32_t metric_tdd_ncp = 0;
uint8_t phase_tdd_ncp;
......@@ -273,7 +266,15 @@ void nr_scan_ssb(void *arg)
&phase_tdd_ncp,
&freq_offset_sss,
rxdataF);
#ifdef DEBUG_INITIAL_SYNCH
LOG_I(PHY,
"TDD Normal prefix: sss detection result; %d, CellId %d metric %d, phase %d, measured offset %d\n",
ssbInfo->syncRes.cell_detected,
ssbInfo->nidCell,
metric_tdd_ncp,
phase_tdd_ncp,
ssbInfo->syncRes.rx_offset);
#endif
ssbInfo->freqOffset = freq_offset_pss + freq_offset_sss;
uint32_t nr_gold_pbch_ref[2][64][NR_PBCH_DMRS_LENGTH_DWORD];
......@@ -315,23 +316,24 @@ nr_initial_sync_t nr_initial_sync(UE_nr_rxtx_proc_t *proc,
for (int s = 0; s < numGscn; s++) {
notifiedFIFO_elt_t *req = newNotifiedFIFO_elt(sizeof(nr_ue_ssb_scan_t), gscnInfo[s].gscn, &nf, &nr_scan_ssb);
nr_ue_ssb_scan_t *ssbInfo = (nr_ue_ssb_scan_t *)NotifiedFifoData(req);
ssbInfo->gscnInfo = gscnInfo[s];
*ssbInfo = (nr_ue_ssb_scan_t){.gscnInfo = gscnInfo[s],
.fp = &ue->frame_parms,
.proc = proc,
.syncRes.cell_detected = false,
.nFrames = n_frames,
.foFlag = ue->UE_fo_compensation,
.targetNidCell = ue->target_Nid_cell};
ssbInfo->rxdata = malloc16_clear(fp->nb_antennas_rx * sizeof(c16_t *));
for (int ant = 0; ant < fp->nb_antennas_rx; ant++) {
ssbInfo->rxdata[ant] = malloc16_clear((fp->samples_per_frame * 2 + fp->ofdm_symbol_size) * sizeof(c16_t));
ssbInfo->rxdata[ant] = malloc16(sizeof(c16_t) * (fp->samples_per_frame * 2 + fp->ofdm_symbol_size));
memcpy(ssbInfo->rxdata[ant], ue->common_vars.rxdata[ant], sizeof(c16_t) * fp->samples_per_frame * 2);
memset(ssbInfo->rxdata[ant] + fp->samples_per_frame * 2, 0, fp->ofdm_symbol_size * sizeof(c16_t));
}
LOG_I(NR_PHY,
"Scanning GSCN: %d, with SSB offset: %d, SSB Freq: %lf\n",
ssbInfo->gscnInfo.gscn,
ssbInfo->gscnInfo.ssbFirstSC,
ssbInfo->gscnInfo.ssRef);
ssbInfo->fp = &ue->frame_parms;
ssbInfo->proc = proc;
ssbInfo->syncRes.cell_detected = false;
ssbInfo->nFrames = n_frames;
ssbInfo->foFlag = ue->UE_fo_compensation;
ssbInfo->targetNidCell = ue->target_Nid_cell;
pushTpool(&get_nrUE_params()->Tpool, req);
}
......@@ -437,16 +439,6 @@ nr_initial_sync_t nr_initial_sync(UE_nr_rxtx_proc_t *proc,
res.syncRes.rx_offset = res.ssbOffset - sync_pos_frame;
}
#ifdef DEBUG_INITIAL_SYNCH
LOG_I(PHY,
"TDD Normal prefix: CellId %d metric %d, phase %d, pbch detected %d, measured offset %d\n",
fp->Nid_cell,
metric_tdd_ncp,
phase_tdd_ncp,
ret.cell_detected,
ret.rx_offset);
#endif
if (res.syncRes.cell_detected) {
LOG_I(PHY, "[UE%d] In synch, rx_offset %d samples\n", ue->Mod_id, res.syncRes.rx_offset);
LOG_I(PHY, "[UE %d] Measured Carrier Frequency offset %d Hz\n", ue->Mod_id, res.freqOffset);
......@@ -455,7 +447,7 @@ nr_initial_sync_t nr_initial_sync(UE_nr_rxtx_proc_t *proc,
LOG_I(PHY,"[UE%d] Initial sync : PBCH not ok\n",ue->Mod_id);
LOG_I(PHY, "[UE%d] Initial sync : Estimated PSS position %d, Nid2 %d\n", ue->Mod_id, sync_pos, ue->common_vars.nid2);
LOG_I(PHY,"[UE%d] Initial sync : Estimated Nid_cell %d, Frame_type %d\n",ue->Mod_id,
frame_parms->Nid_cell,frame_parms->frame_type);
fp->Nid_cell,fp->frame_type);
#endif
}
......@@ -481,10 +473,10 @@ nr_initial_sync_t nr_initial_sync(UE_nr_rxtx_proc_t *proc,
ue->measurements.rx_power_avg_dB[0] = dB_fixed(ue->measurements.rx_power_avg[0]);
#ifdef DEBUG_INITIAL_SYNCH
LOG_I(PHY, "[UE%d] Initial sync : Estimated power: %d dB\n", ue->Mod_id, ue->measurements.rx_power_avg_dB[0]);
LOG_I(PHY, "[UE%d] Initial sync failed : Estimated power: %d dB\n", ue->Mod_id, ue->measurements.rx_power_avg_dB[0]);
#endif
} else {
LOG_A(PHY, "Initial sync successful\n");
LOG_A(PHY, "Initial sync successful, PCI: %d\n",fp->Nid_cell);
}
// exit_fun("debug exit");
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_NR_INITIAL_UE_SYNC, VCD_FUNCTION_OUT);
......
......@@ -55,11 +55,12 @@ static uint16_t nr_pbch_extract(uint32_t rxdataF_sz,
uint32_t symbol,
uint32_t s_offset,
int ssb_start_subcarrier,
const NR_DL_FRAME_PARMS *frame_parms)
const NR_DL_FRAME_PARMS *frame_parms,
int nid)
{
uint16_t rb;
uint8_t i, j, aarx;
int nushiftmod4 = frame_parms->Nid_cell % 4;
int nushiftmod4 = nid % 4;
AssertFatal(symbol>=1 && symbol<5,
"symbol %d illegal for PBCH extraction\n",
symbol);
......@@ -418,7 +419,8 @@ int nr_rx_pbch(PHY_VARS_NR_UE *ue,
symbol,
symbol_offset,
ssb_start_subcarrier,
frame_parms);
frame_parms,
Nid_cell);
#ifdef DEBUG_PBCH
LOG_I(PHY,"[PHY] PBCH Symbol %d ofdm size %d\n",symbol, frame_parms->ofdm_symbol_size);
LOG_I(PHY,"[PHY] PBCH starting channel_level\n");
......
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