Commit cec42dc3 authored by Thomas Schlichter's avatar Thomas Schlichter

Some more UE timing fixes

- Check for timing_advance update _after_ RX (and TX) processing
- Update writeBlockSize when timing_advance value changes (for USRP)
- ignore timestamp when pre-reading the first OFDM symbol of a frame (for rfsimulator)
- do not busy wait for a finished RX-TX thread, use blocking wait instead
parent 4049eb4f
...@@ -473,21 +473,22 @@ void UE_processing(void *arg) { ...@@ -473,21 +473,22 @@ void UE_processing(void *arg) {
UE_nr_rxtx_proc_t *proc = &rxtxD->proc; UE_nr_rxtx_proc_t *proc = &rxtxD->proc;
PHY_VARS_NR_UE *UE = rxtxD->UE; PHY_VARS_NR_UE *UE = rxtxD->UE;
uint8_t gNB_id = 0; processSlotRX(UE, proc);
processSlotTX(UE, proc);
// params for UL time alignment procedure
NR_UL_TIME_ALIGNMENT_t *ul_time_alignment = &UE->ul_time_alignment[gNB_id];
uint8_t numerology = UE->frame_parms.numerology_index;
uint16_t bwp_ul_NB_RB = UE->frame_parms.N_RB_UL;
int slot_tx = proc->nr_tti_tx;
int frame_tx = proc->frame_tx;
/* UL time alignment /* UL time alignment
// If the current tx frame and slot match the TA configuration in ul_time_alignment // If the current tx frame and slot match the TA configuration in ul_time_alignment
// then timing advance is processed and set to be applied in the next UL transmission */ // then timing advance is processed and set to be applied in the next UL transmission */
if (UE->mac_enabled == 1) { if (UE->mac_enabled == 1) {
uint8_t gNB_id = 0;
NR_UL_TIME_ALIGNMENT_t *ul_time_alignment = &UE->ul_time_alignment[gNB_id];
int slot_tx = proc->nr_tti_tx;
int frame_tx = proc->frame_tx;
if (frame_tx == ul_time_alignment->ta_frame && slot_tx == ul_time_alignment->ta_slot) { if (frame_tx == ul_time_alignment->ta_frame && slot_tx == ul_time_alignment->ta_slot) {
uint8_t numerology = UE->frame_parms.numerology_index;
uint16_t bwp_ul_NB_RB = UE->frame_parms.N_RB_UL;
LOG_D(PHY,"Applying timing advance -- frame %d -- slot %d\n", frame_tx, slot_tx); LOG_D(PHY,"Applying timing advance -- frame %d -- slot %d\n", frame_tx, slot_tx);
//if (nfapi_mode!=3){ //if (nfapi_mode!=3){
...@@ -497,9 +498,6 @@ void UE_processing(void *arg) { ...@@ -497,9 +498,6 @@ void UE_processing(void *arg) {
//} //}
} }
} }
processSlotRX(UE, proc);
processSlotTX(UE, proc);
} }
void dummyWrite(PHY_VARS_NR_UE *UE,openair0_timestamp timestamp, int writeBlockSize) { void dummyWrite(PHY_VARS_NR_UE *UE,openair0_timestamp timestamp, int writeBlockSize) {
...@@ -624,6 +622,7 @@ void *UE_thread(void *arg) { ...@@ -624,6 +622,7 @@ void *UE_thread(void *arg) {
notifiedFIFO_t freeBlocks; notifiedFIFO_t freeBlocks;
initNotifiedFIFO_nothreadSafe(&freeBlocks); initNotifiedFIFO_nothreadSafe(&freeBlocks);
NR_UE_MAC_INST_t *mac = get_mac_inst(0); NR_UE_MAC_INST_t *mac = get_mac_inst(0);
int timing_advance = UE->timing_advance;
for (int i=0; i<RX_NB_TH+1; i++) // RX_NB_TH working + 1 we are making to be pushed for (int i=0; i<RX_NB_TH+1; i++) // RX_NB_TH working + 1 we are making to be pushed
pushNotifiedFIFO_nothreadSafe(&freeBlocks, pushNotifiedFIFO_nothreadSafe(&freeBlocks,
...@@ -728,21 +727,26 @@ void *UE_thread(void *arg) { ...@@ -728,21 +727,26 @@ void *UE_thread(void *arg) {
for (int i=0; i<UE->frame_parms.nb_antennas_tx; i++) for (int i=0; i<UE->frame_parms.nb_antennas_tx; i++)
txp[i] = (void *)&UE->common_vars.txdata[i][UE->frame_parms.get_samples_slot_timestamp( txp[i] = (void *)&UE->common_vars.txdata[i][UE->frame_parms.get_samples_slot_timestamp(
((curMsg->proc.nr_tti_rx + DURATION_RX_TO_TX - RX_NB_TH)%nb_slot_frame),&UE->frame_parms,0)]; ((slot_nr + DURATION_RX_TO_TX - RX_NB_TH)%nb_slot_frame),&UE->frame_parms,0)];
int readBlockSize, writeBlockSize; int readBlockSize, writeBlockSize;
if (slot_nr<(nb_slot_frame - 1)) { if (slot_nr<(nb_slot_frame - 1)) {
readBlockSize=get_readBlockSize(slot_nr, &UE->frame_parms); readBlockSize=get_readBlockSize(slot_nr, &UE->frame_parms);
writeBlockSize=UE->frame_parms.get_samples_per_slot(curMsg->proc.nr_tti_tx,&UE->frame_parms); writeBlockSize=UE->frame_parms.get_samples_per_slot((slot_nr + DURATION_RX_TO_TX - RX_NB_TH) % nb_slot_frame, &UE->frame_parms);
} else { } else {
UE->rx_offset_diff = computeSamplesShift(UE); UE->rx_offset_diff = computeSamplesShift(UE);
readBlockSize=get_readBlockSize(slot_nr, &UE->frame_parms) - readBlockSize=get_readBlockSize(slot_nr, &UE->frame_parms) -
UE->rx_offset_diff; UE->rx_offset_diff;
writeBlockSize=UE->frame_parms.get_samples_per_slot(curMsg->proc.nr_tti_tx,&UE->frame_parms) - writeBlockSize=UE->frame_parms.get_samples_per_slot((slot_nr + DURATION_RX_TO_TX - RX_NB_TH) % nb_slot_frame, &UE->frame_parms)-
UE->rx_offset_diff; UE->rx_offset_diff;
} }
if (UE->timing_advance != timing_advance) {
writeBlockSize -= UE->timing_advance - timing_advance;
timing_advance = UE->timing_advance;
}
AssertFatal(readBlockSize == AssertFatal(readBlockSize ==
UE->rfdevice.trx_read_func(&UE->rfdevice, UE->rfdevice.trx_read_func(&UE->rfdevice,
&timestamp, &timestamp,
...@@ -754,14 +758,15 @@ void *UE_thread(void *arg) { ...@@ -754,14 +758,15 @@ void *UE_thread(void *arg) {
// read in first symbol of next frame and adjust for timing drift // read in first symbol of next frame and adjust for timing drift
int first_symbols=UE->frame_parms.ofdm_symbol_size+UE->frame_parms.nb_prefix_samples0; // first symbol of every frames int first_symbols=UE->frame_parms.ofdm_symbol_size+UE->frame_parms.nb_prefix_samples0; // first symbol of every frames
if ( first_symbols > 0 ) if ( first_symbols > 0 ) {
openair0_timestamp ignore_timestamp;
AssertFatal(first_symbols == AssertFatal(first_symbols ==
UE->rfdevice.trx_read_func(&UE->rfdevice, UE->rfdevice.trx_read_func(&UE->rfdevice,
&timestamp, &ignore_timestamp,
(void **)UE->common_vars.rxdata, (void **)UE->common_vars.rxdata,
first_symbols, first_symbols,
UE->frame_parms.nb_antennas_rx),""); UE->frame_parms.nb_antennas_rx),"");
else } else
LOG_E(PHY,"can't compensate: diff =%d\n", first_symbols); LOG_E(PHY,"can't compensate: diff =%d\n", first_symbols);
} }
...@@ -772,18 +777,15 @@ void *UE_thread(void *arg) { ...@@ -772,18 +777,15 @@ void *UE_thread(void *arg) {
notifiedFIFO_elt_t *res; notifiedFIFO_elt_t *res;
while (nbSlotProcessing >= RX_NB_TH) { while (nbSlotProcessing >= RX_NB_TH) {
if ( (res=tryPullTpool(&nf, Tpool)) != NULL ) { res=pullTpool(&nf, Tpool);
nbSlotProcessing--; nbSlotProcessing--;
processingData_t *tmp=(processingData_t *)res->msgData; processingData_t *tmp=(processingData_t *)res->msgData;
if (tmp->proc.decoded_frame_rx != -1)
decoded_frame_rx=(((mac->mib->systemFrameNumber.buf[0] >> mac->mib->systemFrameNumber.bits_unused)<<4) | tmp->proc.decoded_frame_rx);
//decoded_frame_rx=tmp->proc.decoded_frame_rx;
pushNotifiedFIFO_nothreadSafe(&freeBlocks,res); if (tmp->proc.decoded_frame_rx != -1)
} decoded_frame_rx=(((mac->mib->systemFrameNumber.buf[0] >> mac->mib->systemFrameNumber.bits_unused)<<4) | tmp->proc.decoded_frame_rx);
//decoded_frame_rx=tmp->proc.decoded_frame_rx;
usleep(100); pushNotifiedFIFO_nothreadSafe(&freeBlocks,res);
} }
if ( (decoded_frame_rx != curMsg->proc.frame_rx) && if ( (decoded_frame_rx != curMsg->proc.frame_rx) &&
......
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