Commit 06ff737c authored by Raymond Knopp's avatar Raymond Knopp

testing of SynchRef UE TX

parent ddb1e737
......@@ -97,8 +97,8 @@ int generate_drs_pusch(PHY_VARS_UE *ue,
break;
case PSSCH_12:
u0=ue->gh[ue->slsch->group_destination_id][ljmod10<<1];
u1=ue->gh[ue->slsch->group_destination_id][1+(ljmod10<<1)];
u0=ue->gh[1+ue->slsch->group_destination_id][ljmod10<<1];
u1=ue->gh[1+ue->slsch->group_destination_id][1+(ljmod10<<1)];
v0=0;//frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.seqhop[subframe<<1];
v1=0;//frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.seqhop[1+(subframe<<1)];
cyclic_shift0 = (ue->slsch->group_destination_id>>1)&7;
......@@ -120,8 +120,8 @@ int generate_drs_pusch(PHY_VARS_UE *ue,
linc = (7 - frame_parms->Ncp);
break;
case PSBCH:
u0=ue->gh[ue->slsch->group_destination_id][ljmod10<<1];
u1=ue->gh[ue->slsch->group_destination_id][1+(ljmod10<<1)];
u0=ue->gh[0][ljmod10<<1];
u1=ue->gh[0][1+(ljmod10<<1)];
v0=0;//frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.seqhop[subframe<<1];
v1=0;//frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.seqhop[1+(subframe<<1)];
cyclic_shift0 = (ue->frame_parms.Nid_SL>>1)&7;
......
......@@ -44,7 +44,8 @@ void check_and_generate_slss(PHY_VARS_UE *ue,int frame_tx,int subframe_tx) {
int tx_amp;
LOG_I(PHY,"check_and_generate_slss: frame_tx %d, subframe_tx %d : slss->SL_offsetIndicator %d, slss->slmib_length %d\n",
frame_tx,subframe_tx,slss->SL_OffsetIndicator, slss->slmib_length);
if ((((10*frame_tx) + subframe_tx)%40) != slss->SL_OffsetIndicator) return;
if (slss->slmib_length == 0) return;
......
......@@ -2347,7 +2347,10 @@ void phy_procedures_UE_SL_TX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc) {
SLDCH_t *sldch;
SLSCH_t *slsch;
LOG_D(PHY,"****** start Sidelink TX-Chain for AbsSubframe %d.%d ******\n", frame_tx, subframe_tx);
AssertFatal(frame_tx>=0 && frame_tx < 1024, "frame_tx %d is not in 0...1023\n");
AssertFatal(subframe_tx>=0 && subframe_tx < 10, "frame_tx %d is not in 0...1023\n");
LOG_I(PHY,"****** start Sidelink TX-Chain for AbsSubframe %d.%d ******\n", frame_tx, subframe_tx);
// check for SLBCH/SLSS
if ((ue->slss = ue_get_slss(ue->Mod_id,ue->CC_id,frame_tx,subframe_tx)) != NULL) check_and_generate_slss(ue,frame_tx,subframe_tx);
......
......@@ -3141,16 +3141,18 @@ int get_db_dl_PathlossChange(uint8_t dl_PathlossChange)
SLSS_t *ue_get_slss(module_id_t Mod_id,int CC_id,frame_t frame_tx,sub_frame_t subframe_tx) {
UE_MAC_INST *ue = &UE_mac_inst[Mod_id];
SLSS_t *slss = &UE_mac_inst[Mod_id].slss;
// call RRC get check for SL-MIB
slss->slmib_length = mac_rrc_data_req_ue(Mod_id,
CC_id,
(frame_tx*10)+subframe_tx,
MIBCH, 1,
slss->slmib,
0,
0);
LOG_D(MAC,"frame_tx %d, subframe %d,slss->SL_OffsetIndicator %d\n",
frame_tx,subframe_tx,slss->SL_OffsetIndicator);
if ((((10*frame_tx) + subframe_tx)%40) != slss->SL_OffsetIndicator) slss->slmib_length=0;
else slss->slmib_length = mac_rrc_data_req_ue(Mod_id,
CC_id,
(frame_tx*10)+subframe_tx,
MIBCH, 1,
slss->slmib,
0,
0); // call RRC get check for SL-MIB
return(slss);
}
......@@ -3159,6 +3161,7 @@ SLDCH_t *ue_get_sldch(module_id_t Mod_id,int CC_id,frame_t frame_tx,sub_frame_t
UE_MAC_INST *ue = &UE_mac_inst[Mod_id];
SLDCH_t *sldch = &UE_mac_inst[Mod_id].sldch;
sldch->payload_length = mac_rrc_data_req_ue(Mod_id,
CC_id,
frame_tx,
......
......@@ -78,8 +78,8 @@ mac_rrc_data_req_ue(
LOG_D(RRC,"[UE %d] Frame %d Filling CCCH SRB_ID %d\n",Mod_idP,frameP,Srb_idP);
LOG_D(RRC,"[UE %d] Frame %d buffer_pP status %d,\n",Mod_idP,frameP, UE_rrc_inst[Mod_idP].Srb0[eNB_indexP].Tx_buffer.payload_size);
AssertFatal(Srb_idP==MIBCH || Srb_idP==CCCH,"SRB_id %d is not possible should be (MIBCH %d or CCCH %d)\n",
Srb_idP,MIBCH,CCCH);
AssertFatal(Srb_idP==MIBCH || Srb_idP==CCCH || Srb_idP==SL_DISCOVERY,"SRB_id %d is not possible should be (MIBCH %d or CCCH %d or SL_DISCOVERY %d)\n",
Srb_idP,MIBCH,CCCH,SL_DISCOVERY);
if( Srb_idP == CCCH && UE_rrc_inst[Mod_idP].Srb0[eNB_indexP].Tx_buffer.payload_size > 0 ) {
......@@ -120,8 +120,22 @@ mac_rrc_data_req_ue(
memcpy((void*)buffer_pP,(void*)UE_rrc_inst[Mod_idP].SL_MIB,Ret_size);
return(Ret_size);
}
#ifdef Rel14
AssertFatal(1==0,"Should never be here!\n");
//TTN (for D2D)
else if (Srb_idP == SL_DISCOVERY && UE_rrc_inst[Mod_idP].SL_Discovery[eNB_indexP].Tx_buffer.payload_size > 0){
LOG_D(RRC,"[UE %d] Frame %d Filling SL DISCOVERY SRB_ID %d\n",Mod_idP,frameP,Srb_idP);
LOG_D(RRC,"[UE %d] Frame %d buffer_pP status %d,\n",Mod_idP,frameP, UE_rrc_inst[Mod_idP].SL_Discovery[eNB_indexP].Tx_buffer.payload_size);
memcpy(&buffer_pP[0],&UE_rrc_inst[Mod_idP].SL_Discovery[eNB_indexP].Tx_buffer.Payload[0],UE_rrc_inst[Mod_idP].SL_Discovery[eNB_indexP].Tx_buffer.payload_size);
uint8_t Ret_size=UE_rrc_inst[Mod_idP].SL_Discovery[eNB_indexP].Tx_buffer.payload_size;
LOG_D(RRC,"[UE %d] Sending SL_Discovery, size %d bytes\n",Mod_idP,Ret_size);
UE_rrc_inst[Mod_idP].SL_Discovery[eNB_indexP].Tx_buffer.payload_size = 0;
return(Ret_size);
}
#endif
return(0);
}
......
......@@ -324,8 +324,8 @@ uint8_t do_MIB_SL(const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_index,
//set FrameNumber, subFrameNumber
sl_mib->message.directFrameNumber_r12.buf = &frame;
sl_mib->message.directFrameNumber_r12.size = 1;
sl_mib->message.directFrameNumber_r12.bits_unused=0;
sl_mib->message.directFrameNumber_r12.size = 2;
sl_mib->message.directFrameNumber_r12.bits_unused=6;
sl_mib->message.directSubframeNumber_r12 = subframe;
......@@ -335,7 +335,7 @@ uint8_t do_MIB_SL(const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_index,
enc_rval = uper_encode_to_buffer(&asn_DEF_SBCCH_SL_BCH_Message,
(void*)sl_mib,
UE->SL_MIB,
24);
40);
AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n",
enc_rval.failed_type->name, enc_rval.encoded);
......
......@@ -528,10 +528,10 @@ static int trx_usrp_read(openair0_device *device, openair0_timestamp *ptimestamp
if (u_sf_mode != 2) { // not replay mode
#endif
#if defined(__x86_64) || defined(__i386__)
#ifdef __AVX2__
#ifdef __AVX2__
nsamps2 = (nsamps+7)>>3;
__m256i buff_tmp[2][nsamps2];
#else
#else
nsamps2 = (nsamps+3)>>2;
__m128i buff_tmp[2][nsamps2];
#endif
......@@ -563,12 +563,12 @@ static int trx_usrp_read(openair0_device *device, openair0_timestamp *ptimestamp
for (int j=0; j<nsamps2; j++) {
#if defined(__x86_64__) || defined(__i386__)
#ifdef __AVX2__
((__m256i *)buff[i])[j] = _mm256_srai_epi16(buff_tmp[i][j],4);
((__m256i *)buff[i])[j] = _mm256_srai_epi16(buff_tmp[i][j],4);
#else
((__m128i *)buff[i])[j] = _mm_srai_epi16(buff_tmp[i][j],4);
((__m128i *)buff[i])[j] = _mm_srai_epi16(buff_tmp[i][j],4);
#endif
#elif defined(__arm__)
((int16x8_t*)buff[i])[j] = vshrq_n_s16(buff_tmp[i][j],4);
((int16x8_t*)buff[i])[j] = vshrq_n_s16(buff_tmp[i][j],4);
#endif
}
}
......
......@@ -265,7 +265,7 @@ extern void set_function_spec_param(RU_t *ru);
extern int setup_ue_buffers(PHY_VARS_UE **phy_vars_ue, openair0_config_t *openair0_cfg);
extern void fill_ue_band_info(void);
extern void init_UE(int,int,int,int,int,int);
extern void init_UE(int,int,int,int,int,int,int);
extern void init_thread(int sched_runtime, int sched_deadline, int sched_fifo, cpu_set_t *cpuset, char * name);
extern void reset_opp_meas(void);
......
......@@ -80,7 +80,7 @@ void *UE_thread(void *arg);
void *UE_threadSL(void *arg);
void init_UE_stub(int nb_inst,int,int,char*,int);
void ue_stub_rx_handler(unsigned int, char *);
void init_UE(int nb_inst,int,int,int,int,int);
void init_UE(int nb_inst,int,int,int,int,int,int);
int32_t **rxdata;
int32_t **txdata;
......@@ -221,7 +221,7 @@ void init_thread(int sched_runtime, int sched_deadline, int sched_fifo, cpu_set_
}
void init_UE(int nb_inst,int eMBMS_active, int uecap_xer_in, int timing_correction,int sidelink_active,int SLonly) {
void init_UE(int nb_inst,int eMBMS_active, int uecap_xer_in, int timing_correction,int sidelink_active,int SLonly,int isSynchRef) {
PHY_VARS_UE *UE;
int inst;
......@@ -241,6 +241,8 @@ void init_UE(int nb_inst,int eMBMS_active, int uecap_xer_in, int timing_correcti
PHY_vars_UE_g[inst][0]->no_timing_correction = timing_correction;
PHY_vars_UE_g[inst][0]->SLonly = SLonly;
PHY_vars_UE_g[inst][0]->is_SynchRef = isSynchRef;
if (SLonly==1) PHY_vars_UE_g[inst][0]->sidelink_active = 1;
else PHY_vars_UE_g[inst][0]->sidelink_active = sidelink_active;
LOG_I(PHY,"Intializing UE Threads for instance %d (%p,%p)...\n",inst,PHY_vars_UE_g[inst],PHY_vars_UE_g[inst][0]);
......@@ -689,9 +691,8 @@ static void *UE_thread_synchSL(void *arg)
pthread_cond_wait(&sync_cond, &sync_mutex);
pthread_mutex_unlock(&sync_mutex);
printf("Started device, unlocked sync_mutex (UE_sync_thread)\n");
AssertFatal(UE->rfdevice.trx_start_func(&UE->rfdevice) == 0,"Could not start the device");
while (oai_exit==0) {
AssertFatal ( 0== pthread_mutex_lock(&UE->proc.mutex_synchSL), "");
......@@ -743,6 +744,7 @@ static void *UE_thread_rxn_txnp4(void *arg) {
LOG_E( PHY, "[SCHED][UE] error locking mutex for UE RXTX\n" );
exit_fun("nothing to add");
}
LOG_I(PHY,"before pthread_cond_wait : instance_cnt_rxtx %d\n",proc->instance_cnt_rxtx);
while (proc->instance_cnt_rxtx < 0) {
// most of the time, the thread is waiting here
pthread_cond_wait( &proc->cond_rxtx, &proc->mutex_rxtx );
......@@ -840,15 +842,7 @@ static void *UE_thread_rxn_txnp4(void *arg) {
phy_procedures_UE_S_TX(UE,0,0,no_relay);
updateTimes(current, &t3, 10000, "Delay to process sub-frame (case 3)");
if (pthread_mutex_lock(&proc->mutex_rxtx) != 0) {
LOG_E( PHY, "[SCHED][UE] error locking mutex for UE RXTX\n" );
exit_fun("noting to add");
}
proc->instance_cnt_rxtx--;
if (pthread_mutex_unlock(&proc->mutex_rxtx) != 0) {
LOG_E( PHY, "[SCHED][UE] error unlocking mutex for UE RXTX\n" );
exit_fun("noting to add");
}
}
// This is for Sidelink
......@@ -859,6 +853,16 @@ static void *UE_thread_rxn_txnp4(void *arg) {
phy_procedures_UE_SL_TX(UE,proc);
}
if (pthread_mutex_lock(&proc->mutex_rxtx) != 0) {
LOG_E( PHY, "[SCHED][UE] error locking mutex for UE RXTX\n" );
exit_fun("noting to add");
}
proc->instance_cnt_rxtx--;
if (pthread_mutex_unlock(&proc->mutex_rxtx) != 0) {
LOG_E( PHY, "[SCHED][UE] error unlocking mutex for UE RXTX\n" );
exit_fun("noting to add");
}
}
// thread finished
free(arg);
......@@ -1015,7 +1019,7 @@ static void *UE_phy_stub_thread_rxn_txnp4(void *arg) {
proc->subframe_rx=timer_subframe;
proc->frame_rx = timer_frame;
proc->subframe_tx=(timer_subframe+4)%10;
proc->frame_tx = proc->frame_rx + (proc->subframe_rx>5?1:0);
proc->frame_tx = (proc->frame_rx + (proc->subframe_rx>5?1:0))&1023;
//oai_subframe_ind(proc->frame_rx, proc->subframe_rx);
......@@ -1439,7 +1443,7 @@ void *UE_thread(void *arg) {
}
proc->subframe_rx=sub_frame;
proc->subframe_tx=(sub_frame+4)%10;
proc->frame_tx = proc->frame_rx + (proc->subframe_rx>5?1:0);
proc->frame_tx = (proc->frame_rx + (proc->subframe_rx>5?1:0))&1023;
proc->timestamp_tx = timestamp+
(4*UE->frame_parms.samples_per_tti)-
UE->frame_parms.ofdm_symbol_size-UE->frame_parms.nb_prefix_samples0;
......@@ -1641,12 +1645,23 @@ void *UE_threadSL(void *arg) {
int sub_frame=-1;
//int cumulated_shift=0;
UE->proc.instance_cnt_synchSL=-1;
while (sync_var<0)
pthread_cond_wait(&sync_cond, &sync_mutex);
pthread_mutex_unlock(&sync_mutex);
AssertFatal(UE->rfdevice.trx_start_func(&UE->rfdevice) == 0,"Could not start the device");
while (!oai_exit) {
AssertFatal ( 0== pthread_mutex_lock(&UE->proc.mutex_synch), "");
int instance_cnt_synch = UE->proc.instance_cnt_synchSL;
int is_synchronized = UE->is_synchronizedSL;
AssertFatal ( 0== pthread_mutex_unlock(&UE->proc.mutex_synch), "");
LOG_I(PHY,"UHD Thread SL (is_synchronized %d, is_SynchRef %d\n",
is_synchronized,UE->is_SynchRef);
if (is_synchronized == 0 && UE->is_SynchRef == 0) {
if (instance_cnt_synch < 0) { // we can invoke the synch
// grab 10 ms of signal and wakeup synch thread
......@@ -1710,7 +1725,7 @@ void *UE_threadSL(void *arg) {
// update thread index for received subframe
UE->current_thread_id[sub_frame] = thread_idx;
LOG_D(PHY,"Process Subframe %d thread Idx %d \n", sub_frame, UE->current_thread_id[sub_frame]);
LOG_I(PHY,"Process SL Subframe %d thread Idx %d \n", sub_frame, UE->current_thread_id[sub_frame]);
thread_idx++;
if(thread_idx>=RX_NB_TH)
......@@ -1756,13 +1771,17 @@ void *UE_threadSL(void *arg) {
readBlockSize=UE->frame_parms.samples_per_tti - UE->rx_offset_diff;
writeBlockSize=UE->frame_parms.samples_per_tti -UE->rx_offset_diff;
}
LOG_D(PHY,"reading rxp[0] %p (%p)\n",
rxp[0],UE->common_vars.rxdata[0]);
AssertFatal(readBlockSize ==
UE->rfdevice.trx_read_func(&UE->rfdevice,
&timestamp,
rxp,
readBlockSize,
UE->frame_parms.nb_antennas_rx),"");
LOG_D(PHY,"writing txp[0] %p (%p)\n",txp[0],UE->common_vars.txdata[0]);
AssertFatal( writeBlockSize ==
UE->rfdevice.trx_write_func(&UE->rfdevice,
timestamp+
......@@ -1792,11 +1811,11 @@ void *UE_threadSL(void *arg) {
}
proc->subframe_rx=sub_frame;
proc->subframe_tx=(sub_frame+4)%10;
proc->frame_tx = proc->frame_rx + (proc->subframe_rx>5?1:0);
proc->frame_tx = (proc->frame_rx + (proc->subframe_rx>5?1:0))&1023;
proc->timestamp_tx = timestamp+(4*UE->frame_parms.samples_per_tti);
proc->instance_cnt_rxtx++;
LOG_D( PHY, "[SCHED][UE %d] UE RX instance_cnt_rxtx %d subframe %d !!\n", UE->Mod_id, proc->instance_cnt_rxtx,proc->subframe_rx);
LOG_I( PHY, "[SCHED][UE %d] UE RX instance_cnt_rxtx %d subframe %d !!\n", UE->Mod_id, proc->instance_cnt_rxtx,proc->subframe_rx);
if (proc->instance_cnt_rxtx == 0) {
if (pthread_cond_signal(&proc->cond_rxtx) != 0) {
LOG_E( PHY, "[SCHED][UE %d] ERROR pthread_cond_signal for UE RX thread\n", UE->Mod_id);
......@@ -1814,6 +1833,7 @@ void *UE_threadSL(void *arg) {
initStaticTime(lastTime);
updateTimes(lastTime, &t1, 20000, "Delay between two IQ acquisitions (case 1)");
pickStaticTime(lastTime);
} // UE->is_synchronized==0
} // start_rx_stream==1
} // UE->is_synchronized==0 && UE->is_SynchRef==0
......
......@@ -1038,7 +1038,7 @@ int main( int argc, char **argv )
// start the main threads
int eMBMS_active = 0;
init_UE(1,eMBMS_active,uecap_xer_in,0,sidelink_active,SLonly);
init_UE(1,eMBMS_active,uecap_xer_in,0,sidelink_active,SLonly,synchRef);
if (phy_test==0) {
printf("Filling UE band info\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