Commit 7fad4560 authored by Raymond Knopp's avatar Raymond Knopp

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@6612 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent 14f403e4
...@@ -277,7 +277,7 @@ static void *UE_thread_synch(void *arg) { ...@@ -277,7 +277,7 @@ static void *UE_thread_synch(void *arg) {
#endif #endif
} }
#ifdef EXMIMO #ifdef EXMIMO
openair0_config(&openair0_cfg[card],1); //openair0_config(&openair0_cfg[card],1);
#endif #endif
} }
#ifdef USRP #ifdef USRP
...@@ -357,7 +357,7 @@ static void *UE_thread_synch(void *arg) { ...@@ -357,7 +357,7 @@ static void *UE_thread_synch(void *arg) {
} }
#ifdef EXMIMO #ifdef EXMIMO
openair0_config(&openair0_cfg[card],1); //openair0_config(&openair0_cfg[card],1);
#endif #endif
} }
#ifdef USRP #ifdef USRP
...@@ -368,7 +368,7 @@ static void *UE_thread_synch(void *arg) { ...@@ -368,7 +368,7 @@ static void *UE_thread_synch(void *arg) {
#endif #endif
break; break;
case pbch: case pbch:
printf("Running initial sync\n"); // printf("synch: Running initial sync\n");
// This is a hack to fix a bug when using USRP // This is a hack to fix a bug when using USRP
memset(PHY_vars_UE_g[0][0]->lte_ue_common_vars.rxdata[0],0,1024); memset(PHY_vars_UE_g[0][0]->lte_ue_common_vars.rxdata[0],0,1024);
if (initial_sync(UE,UE->mode)==0) { if (initial_sync(UE,UE->mode)==0) {
...@@ -399,7 +399,7 @@ static void *UE_thread_synch(void *arg) { ...@@ -399,7 +399,7 @@ static void *UE_thread_synch(void *arg) {
LOG_I(HW,"Got synch: hw_slot_offset %d\n",hw_slot_offset); LOG_I(HW,"Got synch: hw_slot_offset %d\n",hw_slot_offset);
} }
else { else { // intial_synch
if (openair_daq_vars.freq_offset >= 0) { if (openair_daq_vars.freq_offset >= 0) {
openair_daq_vars.freq_offset += 100; openair_daq_vars.freq_offset += 100;
...@@ -408,6 +408,7 @@ static void *UE_thread_synch(void *arg) { ...@@ -408,6 +408,7 @@ static void *UE_thread_synch(void *arg) {
else { else {
openair_daq_vars.freq_offset *= -1; openair_daq_vars.freq_offset *= -1;
} }
if (abs(openair_daq_vars.freq_offset) > 7500) { if (abs(openair_daq_vars.freq_offset) > 7500) {
LOG_I(PHY,"[initial_sync] No cell synchronization found, abandoning\n"); LOG_I(PHY,"[initial_sync] No cell synchronization found, abandoning\n");
mac_xface->macphy_exit("No cell synchronization found, abandoning"); mac_xface->macphy_exit("No cell synchronization found, abandoning");
...@@ -421,8 +422,9 @@ static void *UE_thread_synch(void *arg) { ...@@ -421,8 +422,9 @@ static void *UE_thread_synch(void *arg) {
for (i=0; i<openair0_cfg[card].rx_num_channels; i++) { for (i=0; i<openair0_cfg[card].rx_num_channels; i++) {
openair0_cfg[card].rx_freq[i] = downlink_frequency[card][i]+openair_daq_vars.freq_offset; openair0_cfg[card].rx_freq[i] = downlink_frequency[card][i]+openair_daq_vars.freq_offset;
openair0_cfg[card].tx_freq[i] = downlink_frequency[card][i]+uplink_frequency_offset[card][i]+openair_daq_vars.freq_offset; openair0_cfg[card].tx_freq[i] = downlink_frequency[card][i]+uplink_frequency_offset[card][i]+openair_daq_vars.freq_offset;
openair0_cfg[card].rx_gain[i] = UE->rx_total_gain_dB-USRP_GAIN_OFFSET; // 65 calibrated for USRP B210 @ 2.6 GHz
#ifdef USRP #ifdef USRP
openair0_cfg[card].rx_gain[i] = UE->rx_total_gain_dB-USRP_GAIN_OFFSET; // 65 calibrated for USRP B210 @ 2.6 GHz
switch(UE->lte_frame_parms.N_RB_DL) { switch(UE->lte_frame_parms.N_RB_DL) {
case 6: case 6:
openair0_cfg[card].rx_gain[i] -= 12; openair0_cfg[card].rx_gain[i] -= 12;
...@@ -437,37 +439,37 @@ static void *UE_thread_synch(void *arg) { ...@@ -437,37 +439,37 @@ static void *UE_thread_synch(void *arg) {
printf("Unknown number of RBs %d\n",UE->lte_frame_parms.N_RB_DL); printf("Unknown number of RBs %d\n",UE->lte_frame_parms.N_RB_DL);
break; break;
} }
printf("UE synch: setting RX gain (%d,%d) to %d\n",card,i,openair0_cfg[card].rx_gain[i]); // printf("UE synch: setting RX gain (%d,%d) to %d\n",card,i,openair0_cfg[card].rx_gain[i]);
#endif #endif
} }
#ifdef EXMIMO #ifdef EXMIMO
openair0_config(&openair0_cfg[card],1); //openair0_config(&openair0_cfg[card],1);
//rt_sleep_ns(FRAME_PERIOD);
#endif #endif
} }
#ifdef USRP #ifdef USRP
#ifndef USRP_DEBUG #ifndef USRP_DEBUG
openair0_set_frequencies(&openair0,&openair0_cfg[0]); openair0_set_frequencies(&openair0,&openair0_cfg[0]);
// openair0_set_gains(&openair0,&openair0_cfg[0]); // openair0_set_gains(&openair0,&openair0_cfg[0]);
#endif #endif
#else
#endif #endif
// openair0_dump_config(&openair0_cfg[0],UE_flag);
// openair0_dump_config(&openair0_cfg[0],UE_flag); // rt_sleep_ns(FRAME_PERIOD);
// rt_sleep_ns(FRAME_PERIOD); } // freq_offset
} // freq_offset } // initial_sync=0
} // initial_sync=0
break; break;
case si: case si:
default: default:
break; break;
} }
vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SYNCH,0); vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SYNCH,0);
printf("Finished synch : Locking synch mutex (thread_sync)\n");
if (pthread_mutex_lock(&UE->mutex_synch) != 0) { if (pthread_mutex_lock(&UE->mutex_synch) != 0) {
printf("[openair][SCHED][eNB] error locking mutex for UE synch\n"); printf("[openair][SCHED][eNB] error locking mutex for UE synch\n");
} }
...@@ -653,7 +655,7 @@ static void *UE_thread_rx(void *arg) { ...@@ -653,7 +655,7 @@ static void *UE_thread_rx(void *arg) {
// This creates a 1ms reservation every 10ms period // This creates a 1ms reservation every 10ms period
attr.sched_policy = SCHED_DEADLINE; attr.sched_policy = SCHED_DEADLINE;
attr.sched_runtime = 1 * 800000; // each rx thread requires 1ms to finish its job attr.sched_runtime = 1 * 500000; // each rx thread requires 1ms to finish its job
attr.sched_deadline =1 * 1000000; // each rx thread will finish within 1ms attr.sched_deadline =1 * 1000000; // each rx thread will finish within 1ms
attr.sched_period = 1 * 1000000; // each rx thread has a period of 1ms from the starting point attr.sched_period = 1 * 1000000; // each rx thread has a period of 1ms from the starting point
...@@ -1111,7 +1113,7 @@ void *UE_thread(void *arg) { ...@@ -1111,7 +1113,7 @@ void *UE_thread(void *arg) {
// This creates a .25 ms reservation // This creates a .25 ms reservation
attr.sched_policy = SCHED_DEADLINE; attr.sched_policy = SCHED_DEADLINE;
attr.sched_runtime = 0.25 * 1000000; attr.sched_runtime = 0.1 * 1000000;
attr.sched_deadline = 0.25 * 1000000; attr.sched_deadline = 0.25 * 1000000;
attr.sched_period = 0.5 * 1000000; attr.sched_period = 0.5 * 1000000;
...@@ -1119,7 +1121,7 @@ void *UE_thread(void *arg) { ...@@ -1119,7 +1121,7 @@ void *UE_thread(void *arg) {
// if (pthread_setaffinity_np(pthread_self(), sizeof(mask),&mask) <0) { // if (pthread_setaffinity_np(pthread_self(), sizeof(mask),&mask) <0) {
// perror("[MAIN_ENB_THREAD] pthread_setaffinity_np failed\n"); // perror("[MAIN_ENB_THREAD] pthread_setaffinity_np failed\n");
// } // }
if (sched_setattr(0, &attr, flags) < 0 ){ if (sched_setattr(0, &attr, flags) < 0 ){
perror("[SCHED] main UE thread: sched_setattr failed\n"); perror("[SCHED] main UE thread: sched_setattr failed\n");
exit_fun("Nothing to add"); exit_fun("Nothing to add");
...@@ -1339,15 +1341,19 @@ void *UE_thread(void *arg) { ...@@ -1339,15 +1341,19 @@ void *UE_thread(void *arg) {
// wait until we can lock mutex_synch // wait until we can lock mutex_synch
printf("Locking mutex_synch (UE_thread)\n");
if (pthread_mutex_lock(&UE->mutex_synch) != 0) { if (pthread_mutex_lock(&UE->mutex_synch) != 0) {
LOG_E(PHY,"[SCHED][UE] error locking mutex for UE initial synch thread\n"); LOG_E(PHY,"[SCHED][UE] error locking mutex for UE initial synch thread\n");
exit_fun("noting to add"); exit_fun("noting to add");
} }
else { else {
printf("Before getting frame IC %d (UE_thread)\n",UE->instance_cnt_synch);
if (UE->instance_cnt_synch < 0) { if (UE->instance_cnt_synch < 0) {
wait_sync_cnt=0; wait_sync_cnt=0;
openair0_get_frame(0); openair0_get_frame(0);
rt_sleep_ns(FRAME_PERIOD);
// increment instance count for sync thread // increment instance count for sync thread
UE->instance_cnt_synch++; UE->instance_cnt_synch++;
pthread_mutex_unlock(&UE->mutex_synch); pthread_mutex_unlock(&UE->mutex_synch);
...@@ -1359,6 +1365,7 @@ void *UE_thread(void *arg) { ...@@ -1359,6 +1365,7 @@ void *UE_thread(void *arg) {
else { else {
wait_sync_cnt++; wait_sync_cnt++;
pthread_mutex_unlock(&UE->mutex_synch); pthread_mutex_unlock(&UE->mutex_synch);
if (wait_sync_cnt>1000) if (wait_sync_cnt>1000)
exit_fun("waiting to long for synch thread"); exit_fun("waiting to long for synch thread");
else else
......
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