Commit e4526a8f authored by Raymond Knopp's avatar Raymond Knopp

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@5776 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent e1e8a6fd
......@@ -167,30 +167,37 @@ unsigned char scope_enb_num_ue = 1;
static SEM *mutex;
//static CND *cond;
static int thread0;
static int thread1;
static int main_eNB_thread;
static int main_ue_thread;
#ifdef USRP
static SEM *sync_sem; // to sync rx & tx streaming
#endif
//static int sync_thread;
#else
pthread_t thread0;
pthread_t thread1;
pthread_t main_eNB_thread;
pthread_t main_ue_thread;
pthread_attr_t attr_dlsch_threads;
struct sched_param sched_param_dlsch;
#ifdef USRP
pthread_cond_t sync_cond;
pthread_mutex_t sync_mutex;
#endif
#endif
pthread_attr_t attr_UE_init_synch;
pthread_attr_t attr_UE_thread_tx;
pthread_attr_t attr_UE_thread_rx;
pthread_attr_t attr_eNB_proc_tx[MAX_NUM_CCs][10];
pthread_attr_t attr_eNB_proc_rx[MAX_NUM_CCs][10];
struct sched_param sched_param_UE_init_synch;
struct sched_param sched_param_UE_thread_tx;
struct sched_param sched_param_UE_thread_rx;
struct sched_param sched_param_eNB_proc_tx[MAX_NUM_CCs][10];
struct sched_param sched_param_eNB_proc_rx[MAX_NUM_CCs][10];
#ifdef XFORMS
static pthread_t thread2; //xforms
static pthread_t forms_thread; //xforms
#endif
#ifdef EMOS
static pthread_t thread3; //emos
......@@ -841,6 +848,7 @@ static void * eNB_thread_tx(void *param) {
if (pthread_mutex_lock(&proc->mutex_tx) != 0) {
LOG_E(PHY,"[SCHED][eNB] error locking mutex for eNB TX proc %d\n",proc->subframe);
oai_exit=1;
}
else {
......@@ -853,6 +861,7 @@ static void * eNB_thread_tx(void *param) {
// LOG_I(PHY,"Waking up and unlocking mutex for eNB proc %d\n",proc->subframe);
if (pthread_mutex_unlock(&proc->mutex_tx) != 0) {
LOG_E(PHY,"[SCHED][eNB] error unlocking mutex for eNB TX proc %d\n",proc->subframe);
oai_exit=1;
}
}
vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_eNB_PROC_TX0+(2*proc->subframe),1);
......@@ -1028,6 +1037,7 @@ static void * eNB_thread_rx(void *param) {
void init_eNB_proc(void) {
int i;
......@@ -1475,6 +1485,301 @@ static void *eNB_thread(void *arg)
return 0;
}
int is_synchronized=0;
static void *UE_thread_synch(void *arg) {
int i,hw_slot_offset;
PHY_VARS_UE *UE = arg;
#ifdef USRP
printf("waiting for USRP sync \n");
#ifdef RTAI
rt_sem_wait(sync_sem);
#else
//pthread_mutex_lock(&sync_mutex);
pthread_cond_wait(&sync_cond, &sync_mutex);
//pthread_mutex_unlock(&sync_mutex);
#endif
// printf("starting eNB thread @ %llu\n",get_usrp_time(&openair0));
#endif
while (!oai_exit) {
if (pthread_mutex_lock(&UE->mutex_synch) != 0) {
LOG_E(PHY,"[SCHED][eNB] error locking mutex for UE initial synch thread\n");
oai_exit=1;
}
else {
while (UE->instance_cnt_synch < 0) {
pthread_cond_wait(&UE->cond_synch,&UE->mutex_synch);
}
if (pthread_mutex_unlock(&UE->mutex_synch) != 0) {
LOG_E(PHY,"[SCHED][eNB] error unlocking mutex for UE Initial Synch thread\n");
oai_exit=1;
}
if (initial_sync(PHY_vars_UE_g[0][0],mode)==0) {
/*
lte_adjust_synch(&PHY_vars_UE_g[0]->lte_frame_parms,
PHY_vars_UE_g[0],
0,
1,
16384);
*/
//for better visualization afterwards
/*
for (aa=0; aa<PHY_vars_UE_g[0]->lte_frame_parms.nb_antennas_rx; aa++)
memset(PHY_vars_UE_g[0]->lte_ue_common_vars.rxdata[aa],0,
PHY_vars_UE_g[0]->lte_frame_parms.samples_per_tti*LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*sizeof(int));
*/
if (mode == rx_calib_ue) {
exit_fun("[HW][UE] UE in RX calibration mode");
}
else {
is_synchronized = 1;
oai_exit=1;
//start the DMA transfers
//LOG_D(HW,"Before openair0_start_rt_acquisition \n");
//openair0_start_rt_acquisition(0);
hw_slot_offset = (PHY_vars_UE_g[0][0]->rx_offset<<1) / PHY_vars_UE_g[0][0]->lte_frame_parms.samples_per_tti;
LOG_D(HW,"Got synch: hw_slot_offset %d\n",hw_slot_offset);
}
}
else {
if (openair_daq_vars.freq_offset >= 0) {
openair_daq_vars.freq_offset += 100;
openair_daq_vars.freq_offset *= -1;
}
else {
openair_daq_vars.freq_offset *= -1;
}
if (abs(openair_daq_vars.freq_offset) > 7500) {
LOG_I(PHY,"[initial_sync] No cell synchronization found, abondoning\n");
mac_xface->macphy_exit("No cell synchronization found, abondoning");
}
else {
LOG_I(PHY,"[initial_sync] trying carrier off %d Hz\n",openair_daq_vars.freq_offset);
for (card=0;card<MAX_CARDS;card++) {
for (i=0; i<openair0_cfg[card].rx_num_channels; i++) {
openair0_cfg[card].rx_freq[i] = carrier_freq[card][i]+openair_daq_vars.freq_offset;
openair0_cfg[card].tx_freq[i] = carrier_freq[card][i]+openair_daq_vars.freq_offset;
}
}
// openair0_dump_config(&openair0_cfg[0],UE_flag);
// rt_sleep_ns(FRAME_PERIOD);
} // freq_offset
} // initial_sync=0
} // mutex_lock
} // while !oai_exit
return(0);
}
static void *UE_thread_tx(void *arg) {
PHY_VARS_UE *UE = (PHY_VARS_UE*)arg;
#ifndef OPENAIR2
UE->UE_mode[eNB_id]=PUSCH;
UE->prach_resources[eNB_id] = &prach_resources_local;
prach_resources_local.ra_RNTI = 0xbeef;
prach_resources_local.ra_PreambleIndex = 0;
#endif
UE->instance_cnt_tx=-1;
mlockall(MCL_CURRENT | MCL_FUTURE);
while (!oai_exit) {
if (pthread_mutex_lock(&UE->mutex_tx) != 0) {
LOG_E(PHY,"[SCHED][eNB] error locking mutex for UE TX\n");
oai_exit=1;
}
else {
while (UE->instance_cnt_tx < 0) {
pthread_cond_wait(&UE->cond_tx,&UE->mutex_tx);
}
if (pthread_mutex_unlock(&UE->mutex_tx) != 0) {
LOG_E(PHY,"[SCHED][eNB] error unlocking mutex for UE TX\n");
oai_exit=1;
}
}
if ((subframe_select(&UE->lte_frame_parms,UE->slot_tx>>1)==SF_UL)||
(UE->lte_frame_parms.frame_type == FDD)){
phy_procedures_UE_TX(UE,eNB_id,0,mode,no_relay);
}
if ((subframe_select(&UE->lte_frame_parms,UE->slot_tx>>1)==SF_S) &&
((UE->slot_tx&1)==1)) {
phy_procedures_UE_S_TX(UE,eNB_id,0,no_relay);
}
if (pthread_mutex_lock(&UE->mutex_tx) != 0) {
printf("[openair][SCHED][eNB] error locking mutex for UE TX thread\n");
}
else {
UE->instance_cnt_tx--;
if (pthread_mutex_unlock(&UE->mutex_tx) != 0) {
printf("[openair][SCHED][eNB] error unlocking mutex for UE\n");
}
}
UE->slot_tx++;
if (UE->slot_tx==20) {
UE->slot_tx=0;
UE->frame_tx++;
}
}
return(0);
}
static void *UE_thread_rx(void *arg) {
PHY_VARS_UE *UE = (PHY_VARS_UE*)arg;
UE->instance_cnt_rx=-1;
mlockall(MCL_CURRENT | MCL_FUTURE);
while (!oai_exit) {
if (pthread_mutex_lock(&UE->mutex_rx) != 0) {
LOG_E(PHY,"[SCHED][eNB] error locking mutex for UE RX\n");
oai_exit=1;
}
else {
while (UE->instance_cnt_rx < 0) {
pthread_cond_wait(&UE->cond_rx,&UE->mutex_rx);
}
if (pthread_mutex_unlock(&UE->mutex_rx) != 0) {
LOG_E(PHY,"[SCHED][eNB] error unlocking mutex for UE RX\n");
oai_exit=1;
}
if ((subframe_select(&UE->lte_frame_parms,UE->slot_rx>>1)==SF_DL) ||
(UE->lte_frame_parms.frame_type == FDD)){
phy_procedures_UE_RX(UE,eNB_id,0,mode,no_relay,NULL);
}
if ((subframe_select(&UE->lte_frame_parms,UE->slot_rx>>1)==SF_S) &&
((UE->slot_rx&1)==0)) {
phy_procedures_UE_RX(UE,eNB_id,0,mode,no_relay,NULL);
}
UE->slot_rx++;
if (UE->slot_rx==20) {
UE->slot_rx=0;
UE->frame_rx++;
}
}
}
return(0);
}
static void *UE_thread_new(void *arg) {
int slot=0,frame=0,hw_slot,last_slot, next_slot,hw_subframe;
// unsigned int aa;
static int is_synchronized = 0;
#ifndef USRP
// volatile unsigned int *DAQ_MBOX = openair0_daq_cnt();
//exmimo_config_t *p_exmimo_config = openair0_exmimo_pci[card].exmimo_config_ptr;;
#endif
#ifdef USRP
printf("waiting for USRP sync \n");
#ifdef RTAI
rt_sem_wait(sync_sem);
#else
//pthread_mutex_lock(&sync_mutex);
pthread_cond_wait(&sync_cond, &sync_mutex);
//pthread_mutex_unlock(&sync_mutex);
#endif
// printf("starting eNB thread @ %llu\n",get_usrp_time(&openair0));
#endif
while (!oai_exit) {
#ifdef USRP
vcd_signal_dumper_dump_variable_by_name(VCD_SIGNAL_DUMPER_VARIABLES_HW_SUBFRAME, hw_subframe);
vcd_signal_dumper_dump_variable_by_name(VCD_SIGNAL_DUMPER_VARIABLES_HW_FRAME, frame);
while (rx_cnt < sf_bounds[hw_subframe]) {
openair0_timestamp time0,time1;
unsigned int rxs;
vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_READ,1);
rxs = openair0.trx_read_func(&openair0,
&timestamp,
&rxdata[rx_cnt*samples_per_packets],
samples_per_packets);
if (rxs != samples_per_packets)
oai_exit=1;
vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_READ,0);
// Transmit TX buffer based on timestamp from RX
if (is_synchronized) {
vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE,1);
openair0.trx_write_func(&openair0,
(timestamp+samples_per_packets*tx_delay-tx_forward_nsamps),
&txdata[tx_cnt*samples_per_packets],
samples_per_packets,
1);
vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE,0);
}
rx_cnt++;
tx_cnt++;
if(tx_cnt == max_cnt)
tx_cnt = 0;
}
if(rx_cnt == max_cnt)
rx_cnt = 0;
#endif
if (is_synchronized) {
// phy_procedures_UE_lte (last_slot, next_slot, PHY_vars_UE_g[0][0], 0, 0,mode,0,NULL);
}
else { // we are not yet synchronized
if (slot == 18) {
// Wake up initial synch thread
}
}
/*
if ((slot%2000)<10)
LOG_D(HW,"fun0: doing very hard work\n");
*/
hw_subframe++;
slot+=2;
if(hw_subframe==10) {
hw_subframe = 0;
frame++;
slot = 1;
}
#if defined(ENABLE_ITTI)
itti_update_lte_time(frame, slot);
#endif
}
}
#ifndef USRP
......@@ -1484,7 +1789,7 @@ static void *UE_thread(void *arg) {
RT_TASK *task;
#endif
// RTIME in, out, diff;
int slot=0,frame=0,hw_slot,last_slot, next_slot;
int slot=0,frame=0,hw_slot,last_slot,next_slot;
// unsigned int aa;
static int is_synchronized = 0;
int delay_cnt;
......@@ -1526,9 +1831,13 @@ static void *UE_thread(void *arg) {
}
*/
while (!oai_exit) {
hw_slot = (((((volatile unsigned int *)DAQ_MBOX)[0]+1)%150)<<1)/15; //the slot the hw is about to store
if (is_synchronized) {
//this is the mbox counter that indicates the start of the frame
rx_offset_mbox = (PHY_vars_UE_g[0][0]->rx_offset * 150) / (10*PHY_vars_UE_g[0][0]->lte_frame_parms.samples_per_tti);
//this is the mbox counter where we should be
......@@ -1606,7 +1915,7 @@ static void *UE_thread(void *arg) {
next_slot = (slot+3)%LTE_SLOTS_PER_FRAME;
if (is_synchronized) {
phy_procedures_UE_lte (last_slot, next_slot, PHY_vars_UE_g[0][0], 0, 0,mode,0,NULL);
//phy_procedures_UE_lte (last_slot, next_slot, PHY_vars_UE_g[0][0], 0, 0,mode,0,NULL);
}
else { // we are not yet synchronized
......@@ -1705,6 +2014,51 @@ static void *UE_thread(void *arg) {
#endif
void init_UE_threads(void) {
PHY_VARS_UE *UE=PHY_vars_UE_g[0][0];
pthread_attr_init(&attr_UE_thread_tx);
pthread_attr_setstacksize(&attr_UE_thread_tx,OPENAIR_THREAD_STACK_SIZE);
sched_param_UE_thread_tx.sched_priority = sched_get_priority_max(SCHED_FIFO)-1;
pthread_attr_setschedparam (&attr_UE_thread_tx, &sched_param_UE_thread_tx);
pthread_attr_setschedpolicy (&attr_UE_thread_tx, SCHED_FIFO);
pthread_attr_init(&attr_UE_thread_rx);
pthread_attr_setstacksize(&attr_UE_thread_rx,OPENAIR_THREAD_STACK_SIZE);
sched_param_UE_thread_rx.sched_priority = sched_get_priority_max(SCHED_FIFO)-1;
pthread_attr_setschedparam (&attr_UE_thread_rx, &sched_param_UE_thread_rx);
pthread_attr_setschedpolicy (&attr_UE_thread_rx, SCHED_FIFO);
UE->instance_cnt_tx=-1;
UE->instance_cnt_rx=-1;
UE->instance_cnt_synch=-1;
pthread_mutex_init(&UE->mutex_tx,NULL);
pthread_mutex_init(&UE->mutex_rx,NULL);
pthread_mutex_init(&UE->mutex_synch,NULL);
pthread_cond_init(&UE->cond_tx,NULL);
pthread_cond_init(&UE->cond_rx,NULL);
pthread_cond_init(&UE->cond_synch,NULL);
pthread_create(&UE->thread_tx,NULL,UE_thread_tx,(void*)UE);
pthread_create(&UE->thread_rx,NULL,UE_thread_rx,(void*)UE);
pthread_create(&UE->thread_rx,NULL,UE_thread_synch,(void*)UE);
UE->frame_tx = 0;
#ifdef USRP
UE->slot_tx = 2;
UE->slot_rx = 0;
UE->frame_rx = 0;
#else
UE->slot_tx = 1;
UE->slot_rx = 19;
UE->frame_rx = 0;
#endif
}
static void get_options (int argc, char **argv) {
int c;
// char line[1000];
......@@ -2505,7 +2859,7 @@ int main(int argc, char **argv) {
}
}
ret = pthread_create(&thread2, NULL, scope_thread, NULL);
ret = pthread_create(&forms_thread, NULL, scope_thread, NULL);
printf("Scope thread created, ret=%d\n",ret);
}
#endif
......@@ -2520,19 +2874,25 @@ int main(int argc, char **argv) {
#ifndef RTAI
pthread_attr_init (&attr_dlsch_threads);
pthread_attr_setstacksize(&attr_dlsch_threads,OPENAIR_THREAD_STACK_SIZE);
//attr_dlsch_threads.priority = 1;
sched_param_dlsch.sched_priority = 90;//sched_get_priority_max(SCHED_FIFO); //OPENAIR_THREAD_PRIORITY;
pthread_attr_setschedparam (&attr_dlsch_threads, &sched_param_dlsch);
pthread_attr_setschedpolicy (&attr_dlsch_threads, SCHED_FIFO);
pthread_attr_init (&attr_UE_init_synch);
pthread_attr_setstacksize(&attr_UE_init_synch,OPENAIR_THREAD_STACK_SIZE);
sched_param_UE_init_synch.sched_priority = 90;//sched_get_priority_max(SCHED_FIFO); //OPENAIR_THREAD_PRIORITY;
pthread_attr_setschedparam (&attr_UE_init_synch, &sched_param_UE_init_synch);
pthread_attr_setschedpolicy (&attr_UE_init_synch, SCHED_FIFO);
#endif
// start the main thread
if (UE_flag == 1) {
#ifndef USRP
#ifdef RTAI
thread1 = rt_thread_create(UE_thread, NULL, 100000000);
main_ue_thread = rt_thread_create(UE_thread_new, NULL, 100000000);
#else
error_code = pthread_create(&thread1, &attr_dlsch_threads, UE_thread, NULL);
error_code = pthread_create(&main_ue_thread, &attr_dlsch_threads, UE_thread_new, NULL);
if (error_code!= 0) {
LOG_D(HW,"[lte-softmodem.c] Could not allocate UE_thread, error %d\n",error_code);
return(error_code);
......@@ -2559,9 +2919,9 @@ int main(int argc, char **argv) {
}
printf("Creating eNB_thread \n");
#ifdef RTAI
thread0 = rt_thread_create(eNB_thread, NULL, OPENAIR_THREAD_STACK_SIZE);
main_eNB_thread = rt_thread_create(eNB_thread, NULL, OPENAIR_THREAD_STACK_SIZE);
#else
error_code = pthread_create(&thread0, &attr_dlsch_threads, eNB_thread, NULL);
error_code = pthread_create(&main_eNB_thread, &attr_dlsch_threads, eNB_thread, NULL);
if (error_code!= 0) {
LOG_D(HW,"[lte-softmodem.c] Could not allocate eNB_thread, error %d\n",error_code);
return(error_code);
......@@ -2603,7 +2963,7 @@ int main(int argc, char **argv) {
printf("waiting for XFORMS thread\n");
if (do_forms==1)
{
pthread_join(thread2,&status);
pthread_join(forms_thread,&status);
fl_hide_form(form_stats->stats_form);
fl_free_form(form_stats->stats_form);
if (UE_flag==1) {
......@@ -2623,9 +2983,9 @@ int main(int argc, char **argv) {
if (UE_flag == 1) {
#ifndef USRP
#ifdef RTAI
rt_thread_join(thread1);
rt_thread_join(main_ue_thread);
#else
pthread_join(thread1,&status);
pthread_join(main_ue_thread,&status);
#endif
#ifdef DLSCH_THREAD
cleanup_dlsch_threads();
......@@ -2635,12 +2995,12 @@ int main(int argc, char **argv) {
}
else {
#ifdef RTAI
rt_thread_join(thread0);
rt_thread_join(main_eNB_thread);
#else
#ifdef DEBUG_THREADS
printf("Joining eNB_thread ...");
#endif
pthread_join(thread0,(void**)&eNB_thread_status_p);
pthread_join(main_eNB_thread,(void**)&eNB_thread_status_p);
#ifdef DEBUG_THREADS
printf("status %d\n",*eNB_thread_status_p);
#endif
......
......@@ -157,11 +157,11 @@ static void * dlsch_thread(void *param) {
vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_THREAD0+dlsch_thread_index,1);
if (oai_exit) break;
LOG_I(PHY,"[SCHED][DLSCH] Frame %d: Calling dlsch_decoding with dlsch_thread_index = %d\n",phy_vars_ue->frame,dlsch_thread_index);
LOG_I(PHY,"[SCHED][DLSCH] Frame %d: Calling dlsch_decoding with dlsch_thread_index = %d\n",phy_vars_ue->frame_rx,dlsch_thread_index);
time_in = rt_get_time_ns();
if (phy_vars_ue->frame < phy_vars_ue->dlsch_errors[eNB_id]) {
if (phy_vars_ue->frame_rx < phy_vars_ue->dlsch_errors[eNB_id]) {
phy_vars_ue->dlsch_errors[eNB_id]=0;
phy_vars_ue->dlsch_received[eNB_id] = 0;
}
......@@ -197,7 +197,7 @@ static void * dlsch_thread(void *param) {
LOG_D(PHY,"[UE %d][PDSCH %x/%d] Frame %d subframe %d: PDSCH/DLSCH decoding iter %d (mcs %d, rv %d, TBS %d)\n",
phy_vars_ue->Mod_id,
phy_vars_ue->dlsch_ue[eNB_id][0]->rnti,harq_pid,
phy_vars_ue->frame,dlsch_subframe[dlsch_thread_index],ret,
phy_vars_ue->frame_rx,dlsch_subframe[dlsch_thread_index],ret,
phy_vars_ue->dlsch_ue[eNB_id][0]->harq_processes[harq_pid]->mcs,
phy_vars_ue->dlsch_ue[eNB_id][0]->harq_processes[harq_pid]->rvidx,
phy_vars_ue->dlsch_ue[eNB_id][0]->harq_processes[harq_pid]->TBS);
......@@ -209,7 +209,7 @@ static void * dlsch_thread(void *param) {
#ifdef DEBUG_PHY
LOG_I(PHY,"[UE %d][PDSCH %x/%d] Frame %d subframe %d DLSCH in error (rv %d,mcs %d)\n",
phy_vars_ue->Mod_id,phy_vars_ue->dlsch_ue[eNB_id][0]->rnti,
harq_pid,phy_vars_ue->frame,dlsch_subframe[dlsch_thread_index],
harq_pid,phy_vars_ue->frame_rx,dlsch_subframe[dlsch_thread_index],
phy_vars_ue->dlsch_ue[eNB_id][0]->harq_processes[harq_pid]->rvidx,
phy_vars_ue->dlsch_ue[eNB_id][0]->harq_processes[harq_pid]->mcs);
#endif
......@@ -217,14 +217,14 @@ static void * dlsch_thread(void *param) {
else {
LOG_I(PHY,"[UE %d][PDSCH %x/%d] Frame %d subframe %d: Received DLSCH (rv %d,mcs %d)\n",
phy_vars_ue->Mod_id,phy_vars_ue->dlsch_ue[eNB_id][0]->rnti,
harq_pid,phy_vars_ue->frame,dlsch_subframe[dlsch_thread_index],
harq_pid,phy_vars_ue->frame_rx,dlsch_subframe[dlsch_thread_index],
phy_vars_ue->dlsch_ue[eNB_id][0]->harq_processes[harq_pid]->rvidx,
phy_vars_ue->dlsch_ue[eNB_id][0]->harq_processes[harq_pid]->mcs);
#ifdef OPENAIR2
mac_xface->ue_send_sdu(phy_vars_ue->Mod_id,
0, // CC_id
phy_vars_ue->frame,
phy_vars_ue->frame_rx,
phy_vars_ue->dlsch_ue[eNB_id][0]->harq_processes[harq_pid]->b,
phy_vars_ue->dlsch_ue[eNB_id][0]->harq_processes[harq_pid]->TBS>>3,
eNB_id);
......@@ -250,14 +250,14 @@ static void * dlsch_thread(void *param) {
LOG_I(PHY,"[UE %d][PDSCH %x/%d] Frame %d subframe %d: PDSCH/DLSCH decoding iter %d (mcs %d, rv %d, TBS %d)\n",
phy_vars_ue->Mod_id,
phy_vars_ue->dlsch_ue[eNB_id][0]->rnti,harq_pid,
phy_vars_ue->frame,dlsch_subframe[dlsch_thread_index],ret,
phy_vars_ue->frame_rx,dlsch_subframe[dlsch_thread_index],ret,
phy_vars_ue->dlsch_ue[eNB_id][0]->harq_processes[harq_pid]->mcs,
phy_vars_ue->dlsch_ue[eNB_id][0]->harq_processes[harq_pid]->rvidx,
phy_vars_ue->dlsch_ue[eNB_id][0]->harq_processes[harq_pid]->TBS);
if (phy_vars_ue->frame%100==0) {
if (phy_vars_ue->frame_rx%100==0) {
LOG_D(PHY,"[UE %d][PDSCH %x] Frame %d subframe %d dlsch_errors %d, dlsch_received %d, dlsch_fer %d, current_dlsch_cqi %d\n",
phy_vars_ue->Mod_id,phy_vars_ue->dlsch_ue[eNB_id][0]->rnti,
phy_vars_ue->frame,dlsch_subframe[dlsch_thread_index],
phy_vars_ue->frame_rx,dlsch_subframe[dlsch_thread_index],
phy_vars_ue->dlsch_errors[eNB_id],
phy_vars_ue->dlsch_received[eNB_id],
phy_vars_ue->dlsch_fer[eNB_id],
......
......@@ -93,7 +93,7 @@ static void * rx_pdsch_thread(void *param) {
uint8_t rx_pdsch_thread_index = 0;
uint8_t dlsch_thread_index = 0;
uint8_t pilot1,pilot2,pilot3,harq_pid,subframe;
uint8_t last_slot;
// uint8_t last_slot;
uint8_t dual_stream_UE = 0;
uint8_t i_mod = 0;
......@@ -105,7 +105,7 @@ static void * rx_pdsch_thread(void *param) {
int m,eNB_id = 0;
int eNB_id_i = 1;
PHY_VARS_UE *phy_vars_ue = PHY_vars_UE_g[0];
PHY_VARS_UE *UE = PHY_vars_UE_g[0];
#ifdef RTAI
task = rt_task_init_schmod(nam2num("RX_PDSCH_THREAD"), 0, 0, 0, SCHED_FIFO, 0xF);
......@@ -128,7 +128,7 @@ static void * rx_pdsch_thread(void *param) {
rt_make_hard_real_time();
#endif
if (phy_vars_ue->lte_frame_parms.Ncp == 0) { // normal prefix
if (UE->lte_frame_parms.Ncp == 0) { // normal prefix
pilot1 = 4;
pilot2 = 7;
pilot3 = 11;
......@@ -157,27 +157,27 @@ static void * rx_pdsch_thread(void *param) {
vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_THREAD, 1);
last_slot = rx_pdsch_slot;
subframe = last_slot>>1;
// last_slot = rx_pdsch_slot;
subframe = UE->slot_rx>>1;
// Important! assumption that PDCCH procedure of next SF is not called yet
harq_pid = phy_vars_ue->dlsch_ue[eNB_id][0]->current_harq_pid;
phy_vars_ue->dlsch_ue[eNB_id][0]->harq_processes[harq_pid]->G = get_G(&phy_vars_ue->lte_frame_parms,
phy_vars_ue->dlsch_ue[eNB_id][0]->harq_processes[harq_pid]->nb_rb,
phy_vars_ue->dlsch_ue[eNB_id][0]->harq_processes[harq_pid]->rb_alloc,
get_Qm(phy_vars_ue->dlsch_ue[eNB_id][0]->harq_processes[harq_pid]->mcs),
phy_vars_ue->dlsch_ue[eNB_id][0]->harq_processes[harq_pid]->Nl,
phy_vars_ue->lte_ue_pdcch_vars[eNB_id]->num_pdcch_symbols,
phy_vars_ue->frame,subframe);
if ((phy_vars_ue->transmission_mode[eNB_id] == 5) &&
(phy_vars_ue->dlsch_ue[eNB_id][0]->harq_processes[harq_pid]->dl_power_off==0) &&
harq_pid = UE->dlsch_ue[eNB_id][0]->current_harq_pid;
UE->dlsch_ue[eNB_id][0]->harq_processes[harq_pid]->G = get_G(&UE->lte_frame_parms,
UE->dlsch_ue[eNB_id][0]->harq_processes[harq_pid]->nb_rb,
UE->dlsch_ue[eNB_id][0]->harq_processes[harq_pid]->rb_alloc,
get_Qm(UE->dlsch_ue[eNB_id][0]->harq_processes[harq_pid]->mcs),
UE->dlsch_ue[eNB_id][0]->harq_processes[harq_pid]->Nl,
UE->lte_ue_pdcch_vars[eNB_id]->num_pdcch_symbols,
UE->frame_rx,subframe);
if ((UE->transmission_mode[eNB_id] == 5) &&
(UE->dlsch_ue[eNB_id][0]->harq_processes[harq_pid]->dl_power_off==0) &&
(openair_daq_vars.use_ia_receiver > 0)) {
dual_stream_UE = 1;
eNB_id_i = phy_vars_ue->n_connected_eNB;
eNB_id_i = UE->n_connected_eNB;
if (openair_daq_vars.use_ia_receiver == 2) {
i_mod = get_Qm(((phy_vars_ue->frame%1024)/3)%28);
i_mod = get_Qm(((UE->frame_rx%1024)/3)%28);
} else {
i_mod = get_Qm(phy_vars_ue->dlsch_ue[eNB_id][0]->harq_processes[harq_pid]->mcs);
i_mod = get_Qm(UE->dlsch_ue[eNB_id][0]->harq_processes[harq_pid]->mcs);
}
}
else {
......@@ -188,19 +188,19 @@ static void * rx_pdsch_thread(void *param) {
if (oai_exit) break;
LOG_D(PHY,"[SCHED][RX_PDSCH] Frame %d, slot %d: Calling rx_pdsch_decoding with harq_pid %d\n",phy_vars_ue->frame,last_slot,harq_pid);
LOG_D(PHY,"[SCHED][RX_PDSCH] Frame %d, slot %d: Calling rx_pdsch_decoding with harq_pid %d\n",UE->frame_rx,UE->slot_rx,harq_pid);
time_in = rt_get_time_ns();
// Check if we are in even or odd slot
if (last_slot%2) { // odd slots
if (UE->slot_rx%2) { // odd slots
// measure time
//time0 = rt_get_time_ns();
// rt_printk("[SCHED][RX_PDSCH][before rx_pdsch] Frame %d, slot %d, time %llu\n",phy_vars_ue->frame,last_slot,rt_get_time_ns());
for (m=pilot2;m<phy_vars_ue->lte_frame_parms.symbols_per_tti;m++) {
// rt_printk("[SCHED][RX_PDSCH][before rx_pdsch] Frame %d, slot %d, time %llu\n",UE->frame,last_slot,rt_get_time_ns());
for (m=pilot2;m<UE->lte_frame_parms.symbols_per_tti;m++) {
rx_pdsch(phy_vars_ue,
rx_pdsch(UE,
PDSCH,
eNB_id,
eNB_id_i,
......@@ -213,12 +213,12 @@ static void * rx_pdsch_thread(void *param) {
}
// time1 = rt_get_time_ns();
// rt_printk("[SCHED][RX_PDSCH] Frame %d, slot %d, start %llu, end %llu, proc time: %llu ns\n",phy_vars_ue->frame,last_slot,time0,time1,(time1-time0));
// rt_printk("[SCHED][RX_PDSCH] Frame %d, slot %d, start %llu, end %llu, proc time: %llu ns\n",UE->frame_rx,last_slot,time0,time1,(time1-time0));
dlsch_thread_index = harq_pid;
if (pthread_mutex_lock (&dlsch_mutex[dlsch_thread_index]) != 0) { // Signal MAC_PHY Scheduler
LOG_E(PHY,"[UE %d] ERROR pthread_mutex_lock\n",phy_vars_ue->Mod_id); // lock before accessing shared resource
LOG_E(PHY,"[UE %d] ERROR pthread_mutex_lock\n",UE->Mod_id); // lock before accessing shared resource
// vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_RX, VCD_FUNCTION_OUT);
//return(-1);
}
......@@ -228,28 +228,28 @@ static void * rx_pdsch_thread(void *param) {
if (dlsch_instance_cnt[dlsch_thread_index] == 0) {
if (pthread_cond_signal(&dlsch_cond[dlsch_thread_index]) != 0) {
LOG_E(PHY,"[UE %d] ERROR pthread_cond_signal for dlsch_cond[%d]\n",phy_vars_ue->Mod_id,dlsch_thread_index);
LOG_E(PHY,"[UE %d] ERROR pthread_cond_signal for dlsch_cond[%d]\n",UE->Mod_id,dlsch_thread_index);
// vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_RX, VCD_FUNCTION_OUT);
//return(-1);
}
}
else {
LOG_W(PHY,"[UE %d] DLSCH thread for dlsch_thread_index %d busy!!!\n",phy_vars_ue->Mod_id,dlsch_thread_index);
LOG_W(PHY,"[UE %d] DLSCH thread for dlsch_thread_index %d busy!!!\n",UE->Mod_id,dlsch_thread_index);
// vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_RX, VCD_FUNCTION_OUT);
//return(-1);
}
} else { // even slots
for (m=phy_vars_ue->lte_ue_pdcch_vars[eNB_id]->num_pdcch_symbols;m<pilot2;m++) {
for (m=UE->lte_ue_pdcch_vars[eNB_id]->num_pdcch_symbols;m<pilot2;m++) {
rx_pdsch(phy_vars_ue,
rx_pdsch(UE,
PDSCH,
eNB_id,
eNB_id_i,
subframe,
m,
(m==phy_vars_ue->lte_ue_pdcch_vars[eNB_id]->num_pdcch_symbols)?1:0, // first_symbol_flag
(m==UE->lte_ue_pdcch_vars[eNB_id]->num_pdcch_symbols)?1:0, // first_symbol_flag
dual_stream_UE,
i_mod,
harq_pid);
......
......@@ -771,8 +771,13 @@ void *l2l1_task(void *args_p) {
if (PHY_vars_UE_g[UE_inst][0]->UE_mode[0] != NOT_SYNCHED) {
if (frame > 0) {
PHY_vars_UE_g[UE_inst][0]->frame = frame;
PHY_vars_UE_g[UE_inst][0]->frame_rx = frame;
PHY_vars_UE_g[UE_inst][0]->slot_rx = last_slot;
PHY_vars_UE_g[UE_inst][0]->slot_tx = next_slot;
if (next_slot > 1)
PHY_vars_UE_g[UE_inst][0]->frame_tx = frame;
else
PHY_vars_UE_g[UE_inst][0]->frame_tx = frame+1;
#ifdef OPENAIR2
//Application
update_otg_UE (UE_inst, oai_emulation.info.time_ms);
......@@ -781,7 +786,7 @@ void *l2l1_task(void *args_p) {
pdcp_run (frame, 0, UE_inst, 0);
#endif
for (CC_id=0;CC_id<MAX_NUM_CCs;CC_id++) {
phy_procedures_UE_lte (last_slot, next_slot, PHY_vars_UE_g[UE_inst][CC_id], 0, abstraction_flag, normal_txrx,
phy_procedures_UE_lte (PHY_vars_UE_g[UE_inst][CC_id], 0, abstraction_flag, normal_txrx,
no_relay, NULL);
}
ue_data[UE_inst]->tx_power_dBm = PHY_vars_UE_g[UE_inst][0]->tx_power_dBm;
......@@ -852,8 +857,12 @@ void *l2l1_task(void *args_p) {
if (PHY_vars_UE_g[UE_inst][0]->UE_mode[0] != NOT_SYNCHED) {
LOG_D(EMU,"[RN %d] PHY procedures UE %d for frame %d, slot %d (subframe TX %d, RX %d)\n",
RN_id, UE_inst, frame, slot, next_slot >> 1,last_slot>>1);
PHY_vars_UE_g[UE_inst][0]->frame = frame;
phy_procedures_UE_lte (last_slot, next_slot, PHY_vars_UE_g[UE_inst][0], 0, abstraction_flag,normal_txrx,
PHY_vars_UE_g[UE_inst][0]->frame_rx = frame;
PHY_vars_UE_g[UE_inst][0]->slot_rx = last_slot;
PHY_vars_UE_g[UE_inst][0]->slot_tx = next_slot;
if (next_slot>1) PHY_vars_UE_g[UE_inst][0]->frame_tx = frame;
else PHY_vars_UE_g[UE_inst][0]->frame_tx = frame+1;
phy_procedures_UE_lte (PHY_vars_UE_g[UE_inst][0], 0, abstraction_flag,normal_txrx,
r_type, PHY_vars_RN_g[RN_id]);
}
else if (last_slot == (LTE_SLOTS_PER_FRAME-2)) {
......@@ -873,7 +882,7 @@ void *l2l1_task(void *args_p) {
}
#endif
emu_transport (frame, last_slot, next_slot, direction, oai_emulation.info.frame_type[0], ethernet_flag);
if ((direction == SF_DL) || (frame_parms[0]->frame_type == 0)) {
if ((direction == SF_DL) || (frame_parms[0]->frame_type == FDD)) {
// consider only sec id 0
/* for (eNB_id=0;eNB_id<NB_eNB_INST;eNB_id++) {
if (abstraction_flag == 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