reset for remerging

This commit is contained in:
Wang Tsu-Han
2018-07-30 11:24:08 +02:00
parent 0b405e3d2b
commit aa00a4734a
516 changed files with 11979 additions and 768789 deletions
+23 -39
View File
@@ -216,7 +216,9 @@ static inline int rxtx(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, char *thread_nam
wakeup_prach_eNB_br(eNB,NULL,proc->frame_rx,proc->subframe_rx);
#endif
}
//LOG_I(PHY,"eNB_uespec_RX proc RX %d.%d TX %d.%d \n", proc->frame_rx, proc->subframe_rx, proc->frame_tx, proc->subframe_tx);/////////////*********added
release_UE_in_freeList(eNB->Mod_id);
// UE-specific RX processing for subframe n
if (nfapi_mode == 0 || nfapi_mode == 1) {
phy_procedures_eNB_uespec_RX(eNB, proc);
@@ -237,31 +239,35 @@ static inline int rxtx(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, char *thread_nam
eNB->UL_INFO.subframe = proc->subframe_rx;
eNB->UL_INFO.module_id = eNB->Mod_id;
eNB->UL_INFO.CC_id = eNB->CC_id;
//LOG_I(PHY,"UL_INFO %d.%d \n", eNB->UL_INFO.frame, eNB->UL_INFO.subframe);/////////////*********added
eNB->if_inst->UL_indication(&eNB->UL_INFO);
pthread_mutex_unlock(&eNB->UL_INFO_mutex);
/* this conflict resolution may be totally wrong, to be tested */
/* CONFLICT RESOLUTION: BEGIN */
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ULSCH_SCHEDULER , 0 );
if(oai_exit) return(-1);
if(eNB->single_thread_flag || get_nprocs() <= 4){
#ifndef PHY_TX_THREAD
phy_procedures_eNB_TX(eNB, proc, 1);
#endif
}
/* CONFLICT RESOLUTION: what about this release_thread call, has it to be done? if yes, where? */
//if (release_thread(&proc->mutex_rxtx,&proc->instance_cnt_rxtx,thread_name)<0) return(-1);
/* CONFLICT RESOLUTION: END */
stop_meas( &softmodem_stats_rxtx_sf );
LOG_D(PHY,"%s() Exit proc[rx:%d%d tx:%d%d]\n", __FUNCTION__, proc->frame_rx, proc->subframe_rx, proc->frame_tx, proc->subframe_tx);
#if 0
LOG_D(PHY, "rxtx:%lld nfapi:%lld phy:%lld tx:%lld rx:%lld prach:%lld ofdm:%lld ",
softmodem_stats_rxtx_sf.diff_now, nfapi_meas.diff_now,
TICK_TO_US(eNB->phy_proc),
TICK_TO_US(eNB->phy_proc_tx),
TICK_TO_US(eNB->phy_proc_rx),
TICK_TO_US(eNB->rx_prach),
TICK_TO_US(eNB->ofdm_mod_stats),
softmodem_stats_rxtx_sf.diff_now, nfapi_meas.diff_now);
TICK_TO_US(eNB->ofdm_mod_stats)
);
LOG_D(PHY,
"dlsch[enc:%lld mod:%lld scr:%lld rm:%lld t:%lld i:%lld] rx_dft:%lld ",
TICK_TO_US(eNB->dlsch_encoding_stats),
@@ -293,7 +299,6 @@ static inline int rxtx(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, char *thread_nam
TICK_TO_US(eNB->ulsch_tc_intl1_stats),
TICK_TO_US(eNB->ulsch_tc_intl2_stats)
);
#endif
return(0);
}
@@ -417,11 +422,13 @@ static void* eNB_thread_rxtx( void* param ) {
exit_fun( "ERROR pthread_cond_signal" );
}
pthread_mutex_unlock( &proc->mutex_rxtx );
if(get_nprocs() >= 8) wakeup_tx(eNB,eNB->proc.ru_proc);
else if(get_nprocs() > 4)
{
phy_procedures_eNB_TX(eNB, proc, 1);
wakeup_txfh(proc,eNB->proc.ru_proc);
if (nfapi_mode!=2){
if(get_nprocs() >= 8) wakeup_tx(eNB,eNB->proc.ru_proc);
else
{
phy_procedures_eNB_TX(eNB, proc, 1);
wakeup_txfh(proc,eNB->proc.ru_proc);
}
}
} // while !oai_exit
@@ -434,30 +441,6 @@ static void* eNB_thread_rxtx( void* param ) {
return &eNB_thread_rxtx_status;
}
#if 0 //defined(ENABLE_ITTI) && defined(ENABLE_USE_MME)
// Wait for eNB application initialization to be complete (eNB registration to MME)
static void wait_system_ready (char *message, volatile int *start_flag) {
static char *indicator[] = {". ", ".. ", "... ", ".... ", ".....",
" ....", " ...", " ..", " .", " "};
int i = 0;
while ((!oai_exit) && (*start_flag == 0)) {
LOG_N(EMU, message, indicator[i]);
fflush(stdout);
i = (i + 1) % (sizeof(indicator) / sizeof(indicator[0]));
usleep(200000);
}
LOG_D(EMU,"\n");
}
#endif
void eNB_top(PHY_VARS_eNB *eNB, int frame_rx, int subframe_rx, char *string,RU_t *ru)
{
eNB_proc_t *proc = &eNB->proc;
@@ -778,6 +761,7 @@ void wakeup_prach_eNB_br(PHY_VARS_eNB *eNB,RU_t *ru,int frame,int subframe) {
}
#endif
/*!
* \brief The prach receive thread of eNB.
* \param param is a \ref eNB_proc_t structure which contains the info what to process.
@@ -1075,7 +1059,7 @@ void kill_eNB_proc(int inst) {
pthread_join( proc->pthread_prach_br, (void**)&status );
pthread_mutex_destroy( &proc->mutex_prach_br );
pthread_cond_destroy( &proc->cond_prach_br );
#endif
#endif
LOG_I(PHY, "Destroying UL_INFO mutex\n");
pthread_mutex_destroy(&eNB->UL_INFO_mutex);
for (i=0;i<2;i++) {
@@ -1140,7 +1124,7 @@ void init_transport(PHY_VARS_eNB *eNB) {
LOG_I(PHY, "Initialise transport\n");
for (i=0; i<NUMBER_OF_UE_MAX; i++) {
LOG_I(PHY,"Allocating Transport Channel Buffers for DLSCH, UE %d\n",i);
LOG_D(PHY,"Allocating Transport Channel Buffers for DLSCH, UE %d\n",i);
for (j=0; j<2; j++) {
eNB->dlsch[i][j] = new_eNB_dlsch(1,8,NSOFT,fp->N_RB_DL,0,fp);
if (!eNB->dlsch[i][j]) {
@@ -1152,7 +1136,7 @@ void init_transport(PHY_VARS_eNB *eNB) {
}
}
LOG_I(PHY,"Allocating Transport Channel Buffer for ULSCH, UE %d\n",i);
LOG_D(PHY,"Allocating Transport Channel Buffer for ULSCH, UE %d\n",i);
eNB->ulsch[1+i] = new_eNB_ulsch(MAX_TURBO_ITERATIONS,fp->N_RB_UL, 0);
if (!eNB->ulsch[1+i]) {
+394 -38
View File
@@ -114,6 +114,7 @@ static int DEFENBS[] = {0};
#include "T.h"
#include "pdcp.h"
extern volatile int oai_exit;
extern int emulate_rf;
@@ -681,6 +682,19 @@ void fh_if4p5_north_out(RU_t *ru) {
}
/* add fail safe for late command */
typedef enum {
STATE_BURST_NORMAL = 0,
STATE_BURST_TERMINATE = 1,
STATE_BURST_STOP_1 = 2,
STATE_BURST_STOP_2 = 3,
STATE_BURST_RESTART = 4,
} late_control_e;
volatile late_control_e late_control=STATE_BURST_NORMAL;
/* add fail safe for late command end */
static void* emulatedRF_thread(void* param) {
RU_proc_t *proc = (RU_proc_t *) param;
int microsec = 500; // length of time to sleep, in miliseconds
@@ -746,9 +760,12 @@ void rx_rf(RU_t *ru,int *frame,int *subframe) {
proc->timestamp_rx = ts-ru->ts_offset;
//AssertFatal(rxs == fp->samples_per_tti,
//"rx_rf: Asked for %d samples, got %d from USRP\n",fp->samples_per_tti,rxs);
if (rxs != fp->samples_per_tti) LOG_E(PHY, "rx_rf: Asked for %d samples, got %d from USRP\n",fp->samples_per_tti,rxs);
// AssertFatal(rxs == fp->samples_per_tti,
// "rx_rf: Asked for %d samples, got %d from USRP\n",fp->samples_per_tti,rxs);
if(rxs != fp->samples_per_tti){
LOG_E(PHY,"rx_rf: Asked for %d samples, got %d from USRP\n",fp->samples_per_tti,rxs);
late_control=STATE_BURST_TERMINATE;
}
if (proc->first_rx == 1) {
ru->ts_offset = proc->timestamp_rx;
@@ -766,6 +783,16 @@ void rx_rf(RU_t *ru,int *frame,int *subframe) {
proc->subframe_rx = (proc->timestamp_rx / fp->samples_per_tti)%10;
// synchronize first reception to frame 0 subframe 0
#ifdef PHY_TX_THREAD
proc->timestamp_phy_tx = proc->timestamp_rx+((sf_ahead-1)*fp->samples_per_tti);
proc->subframe_phy_tx = (proc->subframe_rx+(sf_ahead-1))%10;
proc->frame_phy_tx = (proc->subframe_rx>(9-(sf_ahead-1))) ? (proc->frame_rx+1)&1023 : proc->frame_rx;
#else
proc->timestamp_tx = proc->timestamp_rx+(sf_ahead*fp->samples_per_tti);
proc->subframe_tx = (proc->subframe_rx+sf_ahead)%10;
proc->frame_tx = (proc->subframe_rx>(9-sf_ahead)) ? (proc->frame_rx+1)&1023 : proc->frame_rx;
#endif
//proc->timestamp_tx = proc->timestamp_rx+(sf_ahead*fp->samples_per_tti);
//proc->subframe_tx = (proc->subframe_rx+sf_ahead)%10;
//proc->frame_tx = (proc->subframe_rx>(9-sf_ahead)) ? (proc->frame_rx+1)&1023 : proc->frame_rx;
@@ -804,8 +831,12 @@ void rx_rf(RU_t *ru,int *frame,int *subframe) {
if (rxs != fp->samples_per_tti)
{
#if defined(USRP_REC_PLAY)
exit_fun("Exiting IQ record/playback");
#else
//exit_fun( "problem receiving samples" );
LOG_E(PHY, "problem receiving samples");
#endif
}
}
@@ -840,7 +871,7 @@ void tx_rf(RU_t *ru) {
(prevSF_type == SF_UL) &&
(nextSF_type == SF_DL)) {
flags = 2; // start of burst
sf_extension = ru->N_TA_offset<<1;
sf_extension = ru->N_TA_offset;
}
if ((fp->frame_type == TDD) &&
@@ -848,15 +879,55 @@ void tx_rf(RU_t *ru) {
(prevSF_type == SF_UL) &&
(nextSF_type == SF_UL)) {
flags = 4; // start of burst and end of burst (only one DL SF between two UL)
sf_extension = ru->N_TA_offset<<1;
sf_extension = ru->N_TA_offset;
}
#if defined(__x86_64) || defined(__i386__)
#ifdef __AVX2__
sf_extension = (sf_extension)&0xfffffff8;
#else
sf_extension = (sf_extension)&0xfffffffc;
#endif
#elif defined(__arm__)
sf_extension = (sf_extension)&0xfffffffc;
#endif
for (i=0; i<ru->nb_tx; i++)
txp[i] = (void*)&ru->common.txdata[i][(proc->subframe_tx*fp->samples_per_tti)-sf_extension];
/* add fail safe for late command */
if(late_control!=STATE_BURST_NORMAL){//stop burst
switch (late_control) {
case STATE_BURST_TERMINATE:
flags=10; // end of burst and no time spec
late_control=STATE_BURST_STOP_1;
break;
case STATE_BURST_STOP_1:
flags=0; // no send
late_control=STATE_BURST_STOP_2;
return;//no send
break;
case STATE_BURST_STOP_2:
flags=0; // no send
late_control=STATE_BURST_RESTART;
return;//no send
break;
case STATE_BURST_RESTART:
flags=2; // start burst
late_control=STATE_BURST_NORMAL;
break;
default:
LOG_D(PHY,"[TXPATH] RU %d late_control %d not implemented\n",ru->idx, late_control);
break;
}
}
/* add fail safe for late command end */
VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_TX0_RU, proc->frame_tx );
VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_TX0_RU, proc->subframe_tx );
VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TST, (proc->timestamp_tx-ru->openair0_cfg.tx_sample_advance)&0xffffffff );
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE, 1 );
// prepare tx buffer pointers
@@ -873,8 +944,11 @@ void tx_rf(RU_t *ru) {
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE, 0 );
AssertFatal(txs == siglen+sf_extension,"TX : Timeout (sent %d/%d)\n",txs, siglen);
// AssertFatal(txs == siglen+sf_extension,"TX : Timeout (sent %d/%d)\n",txs, siglen);
if( (txs != siglen+sf_extension) && (late_control==STATE_BURST_NORMAL) ){ /* add fail safe for late command */
late_control=STATE_BURST_TERMINATE;
LOG_E(PHY,"TX : Timeout (sent %d/%d) state =%d\n",txs, siglen,late_control);
}
}
}
@@ -1183,13 +1257,14 @@ void wakeup_eNBs(RU_t *ru) {
LOG_D(PHY,"wakeup_eNBs (num %d) for RU %d ru->eNB_top:%p\n",ru->num_eNB,ru->idx, ru->eNB_top);
if (ru->num_eNB==1 && ru->eNB_top!=0 && get_nprocs() <= 4) {
if ((ru->num_eNB==1 && ru->eNB_top!=0 && get_nprocs() <= 4) || single_thread_flag) {
// call eNB function directly
char string[20];
sprintf(string,"Incoming RU %d",ru->idx);
LOG_D(PHY,"RU %d Call eNB_top\n",ru->idx);
ru->eNB_top(eNB_list[0],ru->proc.frame_rx,ru->proc.subframe_rx,string,ru);
ru->proc.emulate_rf_busy = 0;
}
else {
@@ -1203,9 +1278,7 @@ void wakeup_eNBs(RU_t *ru) {
{
LOG_E(PHY,"could not wakeup eNB rxtx process for subframe %d\n", ru->proc.subframe_rx);
}
if(!eNB_list[i]->single_thread_flag){
ru->proc.emulate_rf_busy = 0;
}
ru->proc.emulate_rf_busy = 0;
}
}
}
@@ -1344,8 +1417,8 @@ void fill_rf_config(RU_t *ru, char *rf_config_file) {
cfg->tx_freq[i] = (double)fp->dl_CarrierFreq;
cfg->rx_freq[i] = (double)fp->ul_CarrierFreq;
cfg->tx_gain[i] = ru->att_tx;
cfg->rx_gain[i] = ru->max_rxgain-ru->att_rx;
cfg->tx_gain[i] = (double)ru->att_tx;
cfg->rx_gain[i] = ru->max_rxgain-(double)ru->att_rx;
cfg->configFilename = rf_config_file;
printf("channel %d, Setting tx_gain offset %f, rx_gain offset %f, tx_freq %f, rx_freq %f\n",
@@ -1442,6 +1515,12 @@ static void* ru_stats_thread(void* param) {
return(NULL);
}
#ifdef PHY_TX_THREAD
int first_phy_tx = 1;
volatile int16_t phy_tx_txdataF_end;
volatile int16_t phy_tx_end;
#endif
static void* ru_thread_tx( void* param ) {
RU_t *ru = (RU_t*)param;
RU_proc_t *proc = &ru->proc;
@@ -1456,6 +1535,7 @@ static void* ru_thread_tx( void* param ) {
//wait_sync("ru_thread_tx");
wait_on_condition(&proc->mutex_FH1,&proc->cond_FH1,&proc->instance_cnt_FH1,"ru_thread_tx");
printf( "ru_thread_tx ready\n");
while (!oai_exit) {
@@ -1511,6 +1591,9 @@ static void* ru_thread( void* param ) {
// set default return value
ru_thread_status = 0;
#if defined(PRE_SCD_THREAD)
dlsch_ue_select_tbl_in_use = 1;
#endif
// set default return value
@@ -1615,20 +1698,38 @@ static void* ru_thread( void* param ) {
if (ru->fh_south_in) ru->fh_south_in(ru,&frame,&subframe);
else AssertFatal(1==0, "No fronthaul interface at south port");
/*
LOG_D(PHY,"AFTER fh_south_in - SFN/SF:%d%d RU->proc[RX:%d%d TX:%d%d] RC.eNB[0][0]:[RX:%d%d TX(SFN):%d]\n",
frame,subframe,
proc->frame_rx,proc->subframe_rx,
proc->frame_tx,proc->subframe_tx,
RC.eNB[0][0]->proc.frame_rx,RC.eNB[0][0]->proc.subframe_rx,
RC.eNB[0][0]->proc.frame_tx);
#ifdef PHY_TX_THREAD
if(first_phy_tx == 0)
{
phy_tx_end = 0;
phy_tx_txdataF_end = 0;
if(pthread_mutex_lock(&ru->proc.mutex_phy_tx) != 0){
LOG_E( PHY, "[RU] ERROR pthread_mutex_lock for phy tx thread (IC %d)\n", ru->proc.instance_cnt_phy_tx);
exit_fun( "error locking mutex_rxtx" );
}
if (ru->proc.instance_cnt_phy_tx==-1) {
++ru->proc.instance_cnt_phy_tx;
// the thread can now be woken up
AssertFatal(pthread_cond_signal(&ru->proc.cond_phy_tx) == 0, "ERROR pthread_cond_signal for phy_tx thread\n");
}else{
LOG_E(PHY,"phy tx thread busy, skipping\n");
++ru->proc.instance_cnt_phy_tx;
}
pthread_mutex_unlock( &ru->proc.mutex_phy_tx );
} else {
phy_tx_end = 1;
phy_tx_txdataF_end = 1;
}
first_phy_tx = 0;
#endif
LOG_D(PHY,"RU thread (do_prach %d, is_prach_subframe %d), received frame %d, subframe %d\n",
ru->do_prach,
is_prach_subframe(fp, proc->frame_rx, proc->subframe_rx),
proc->frame_rx,proc->subframe_rx);
*/
if (oai_exit) break;
if ((ru->do_prach>0) && (is_prach_subframe(fp, proc->frame_rx, proc->subframe_rx)==1)) {
wakeup_prach_ru(ru);
}
@@ -1649,10 +1750,39 @@ static void* ru_thread( void* param ) {
// If this proc is to provide synchronization, do so
wakeup_slaves(proc);
#if defined(PRE_SCD_THREAD)
new_dlsch_ue_select_tbl_in_use = dlsch_ue_select_tbl_in_use;
dlsch_ue_select_tbl_in_use = !dlsch_ue_select_tbl_in_use;
memcpy(&pre_scd_eNB_UE_stats,&RC.mac[ru->eNB_list[0]->Mod_id]->UE_list.eNB_UE_stats, sizeof(eNB_UE_STATS)*MAX_NUM_CCs*NUMBER_OF_UE_MAX);
memcpy(&pre_scd_activeUE, &RC.mac[ru->eNB_list[0]->Mod_id]->UE_list.active, sizeof(boolean_t)*NUMBER_OF_UE_MAX);
if (pthread_mutex_lock(&ru->proc.mutex_pre_scd)!= 0) {
LOG_E( PHY, "[eNB] error locking proc mutex for eNB pre scd\n");
exit_fun("error locking mutex_time");
}
ru->proc.instance_pre_scd++;
if (ru->proc.instance_pre_scd == 0) {
if (pthread_cond_signal(&ru->proc.cond_pre_scd) != 0) {
LOG_E( PHY, "[eNB] ERROR pthread_cond_signal for eNB pre scd\n" );
exit_fun( "ERROR pthread_cond_signal cond_pre_scd" );
}
}else{
LOG_E( PHY, "[eNB] frame %d subframe %d rxtx busy instance_pre_scd %d\n",
frame,subframe,ru->proc.instance_pre_scd );
}
if (pthread_mutex_unlock(&ru->proc.mutex_pre_scd)!= 0) {
LOG_E( PHY, "[eNB] error unlocking mutex_pre_scd mutex for eNB pre scd\n");
exit_fun("error unlocking mutex_pre_scd");
}
#endif
// wakeup all eNB processes waiting for this RU
if (ru->num_eNB>0) wakeup_eNBs(ru);
if(get_nprocs() <= 4 || single_thread_flag){
#ifndef PHY_TX_THREAD
if(get_nprocs() <= 4 || ru->num_eNB==0 || single_thread_flag){
// do TX front-end processing if needed (precoding and/or IDFTs)
if (ru->feptx_prec) ru->feptx_prec(ru);
@@ -1666,7 +1796,16 @@ static void* ru_thread( void* param ) {
}
proc->emulate_rf_busy = 0;
}
#else
struct timespec time_req, time_rem;
time_req.tv_sec = 0;
time_req.tv_nsec = 10000;
while((!oai_exit)&&(phy_tx_end == 0)){
nanosleep(&time_req,&time_rem);
continue;
}
#endif
}
@@ -1746,8 +1885,8 @@ void *ru_thread_synch(void *arg) {
/*
if ((peak_val > 300000) && (sync_pos > 0)) {
// if (sync_pos++ > 3) {
write_output("ru_sync.m","sync",(void*)&sync_corr[0],fp->samples_per_tti*5,1,2);
write_output("ru_rx.m","rxs",(void*)ru->ru_time.rxdata[0][0],fp->samples_per_tti*10,1,1);
LOG_M("ru_sync.m","sync",(void*)&sync_corr[0],fp->samples_per_tti*5,1,2);
LOG_M("ru_rx.m","rxs",(void*)ru->ru_time.rxdata[0][0],fp->samples_per_tti*10,1,1);
exit(-1);
}
*/
@@ -1763,6 +1902,168 @@ void *ru_thread_synch(void *arg) {
}
#if defined(PRE_SCD_THREAD)
void* pre_scd_thread( void* param ){
static int eNB_pre_scd_status;
protocol_ctxt_t ctxt;
int frame;
int subframe;
int min_rb_unit[MAX_NUM_CCs];
int CC_id;
int Mod_id;
RU_t *ru = (RU_t*)param;
Mod_id = ru->eNB_list[0]->Mod_id;
frame = 0;
subframe = 4;
thread_top_init("pre_scd_thread",0,870000,1000000,1000000);
while (!oai_exit) {
if(oai_exit){
break;
}
pthread_mutex_lock(&ru->proc.mutex_pre_scd );
if (ru->proc.instance_pre_scd < 0) {
pthread_cond_wait(&ru->proc.cond_pre_scd, &ru->proc.mutex_pre_scd);
}
pthread_mutex_unlock(&ru->proc.mutex_pre_scd);
PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, Mod_id, ENB_FLAG_YES,
NOT_A_RNTI, frame, subframe,Mod_id);
pdcp_run(&ctxt);
for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) {
rrc_rx_tx(&ctxt, CC_id);
min_rb_unit[CC_id] = get_min_rb_unit(Mod_id, CC_id);
}
pre_scd_nb_rbs_required(Mod_id, frame, subframe,min_rb_unit,pre_nb_rbs_required[new_dlsch_ue_select_tbl_in_use]);
if (subframe==9) {
subframe=0;
frame++;
frame&=1023;
} else {
subframe++;
}
pthread_mutex_lock(&ru->proc.mutex_pre_scd );
ru->proc.instance_pre_scd--;
pthread_mutex_unlock(&ru->proc.mutex_pre_scd);
}
eNB_pre_scd_status = 0;
return &eNB_pre_scd_status;
}
#endif
#ifdef PHY_TX_THREAD
/*!
* \brief The phy tx thread of eNB.
* \param param is a \ref eNB_proc_t structure which contains the info what to process.
* \returns a pointer to an int. The storage is not on the heap and must not be freed.
*/
static void* eNB_thread_phy_tx( void* param ) {
static int eNB_thread_phy_tx_status;
RU_t *ru = (RU_t*)param;
RU_proc_t *proc = &ru->proc;
PHY_VARS_eNB **eNB_list = ru->eNB_list;
eNB_rxtx_proc_t proc_rxtx;
// set default return value
eNB_thread_phy_tx_status = 0;
thread_top_init("eNB_thread_phy_tx",1,500000L,1000000L,20000000L);
while (!oai_exit) {
if (oai_exit) break;
if (wait_on_condition(&proc->mutex_phy_tx,&proc->cond_phy_tx,&proc->instance_cnt_phy_tx,"eNB_phy_tx_thread") < 0) break;
LOG_D(PHY,"Running eNB phy tx procedures\n");
if(ru->num_eNB == 1){
proc_rxtx.subframe_tx = proc->subframe_phy_tx;
proc_rxtx.frame_tx = proc->frame_phy_tx;
phy_procedures_eNB_TX(eNB_list[0], &proc_rxtx, 1);
phy_tx_txdataF_end = 1;
if(pthread_mutex_lock(&ru->proc.mutex_rf_tx) != 0){
LOG_E( PHY, "[RU] ERROR pthread_mutex_lock for rf tx thread (IC %d)\n", ru->proc.instance_cnt_rf_tx);
exit_fun( "error locking mutex_rf_tx" );
}
if (ru->proc.instance_cnt_rf_tx==-1) {
++ru->proc.instance_cnt_rf_tx;
ru->proc.frame_tx = proc->frame_phy_tx;
ru->proc.subframe_tx = proc->subframe_phy_tx;
ru->proc.timestamp_tx = proc->timestamp_phy_tx;
// the thread can now be woken up
AssertFatal(pthread_cond_signal(&ru->proc.cond_rf_tx) == 0, "ERROR pthread_cond_signal for rf_tx thread\n");
}else{
LOG_E(PHY,"rf tx thread busy, skipping\n");
late_control=STATE_BURST_TERMINATE;
}
pthread_mutex_unlock( &ru->proc.mutex_rf_tx );
}
if (release_thread(&proc->mutex_phy_tx,&proc->instance_cnt_phy_tx,"eNB_thread_phy_tx") < 0) break;
phy_tx_end = 1;
}
LOG_I(PHY, "Exiting eNB thread PHY TX\n");
eNB_thread_phy_tx_status = 0;
return &eNB_thread_phy_tx_status;
}
static void* rf_tx( void* param ) {
static int rf_tx_status;
RU_t *ru = (RU_t*)param;
RU_proc_t *proc = &ru->proc;
// set default return value
rf_tx_status = 0;
thread_top_init("rf_tx",1,500000L,1000000L,20000000L);
while (!oai_exit) {
if (oai_exit) break;
if (wait_on_condition(&proc->mutex_rf_tx,&proc->cond_rf_tx,&proc->instance_cnt_rf_tx,"rf_tx_thread") < 0) break;
LOG_D(PHY,"Running eNB rf tx procedures\n");
if(ru->num_eNB == 1){
// do TX front-end processing if needed (precoding and/or IDFTs)
if (ru->feptx_prec) ru->feptx_prec(ru);
// do OFDM if needed
if ((ru->fh_north_asynch_in == NULL) && (ru->feptx_ofdm)) ru->feptx_ofdm(ru);
if(!emulate_rf){
// do outgoing fronthaul (south) if needed
if ((ru->fh_north_asynch_in == NULL) && (ru->fh_south_out)) ru->fh_south_out(ru);
if (ru->fh_north_out) ru->fh_north_out(ru);
}
}
if (release_thread(&proc->mutex_rf_tx,&proc->instance_cnt_rf_tx,"rf_tx") < 0) break;
if(proc->instance_cnt_rf_tx >= 0){
late_control=STATE_BURST_TERMINATE;
LOG_E(PHY,"detect rf tx busy change mode TX failsafe\n");
}
}
LOG_I(PHY, "Exiting rf TX\n");
rf_tx_status = 0;
return &rf_tx_status;
}
#endif
int start_if(struct RU_t_s *ru,struct PHY_VARS_eNB_s *eNB) {
@@ -1854,6 +2155,15 @@ void init_RU_proc(RU_t *ru) {
pthread_cond_init( &proc->cond_prach_br, NULL);
pthread_attr_init( &proc->attr_prach_br);
#endif
#ifdef PHY_TX_THREAD
proc->instance_cnt_phy_tx = -1;
pthread_mutex_init( &proc->mutex_phy_tx, NULL);
pthread_cond_init( &proc->cond_phy_tx, NULL);
proc->instance_cnt_rf_tx = -1;
pthread_mutex_init( &proc->mutex_rf_tx, NULL);
pthread_cond_init( &proc->cond_rf_tx, NULL);
#endif
#ifndef DEADLINE_SCHEDULER
attr_FH = &proc->attr_FH;
@@ -1868,6 +2178,21 @@ void init_RU_proc(RU_t *ru) {
#endif
pthread_create( &proc->pthread_FH, attr_FH, ru_thread, (void*)ru );
#if defined(PRE_SCD_THREAD)
proc->instance_pre_scd = -1;
pthread_mutex_init( &proc->mutex_pre_scd, NULL);
pthread_cond_init( &proc->cond_pre_scd, NULL);
pthread_create(&proc->pthread_pre_scd, NULL, pre_scd_thread, (void*)ru);
pthread_setname_np(proc->pthread_pre_scd, "pre_scd_thread");
#endif
#ifdef PHY_TX_THREAD
pthread_create( &proc->pthread_phy_tx, NULL, eNB_thread_phy_tx, (void*)ru );
pthread_setname_np( proc->pthread_phy_tx, "phy_tx_thread" );
pthread_create( &proc->pthread_rf_tx, NULL, rf_tx, (void*)ru );
#endif
if(emulate_rf)
pthread_create( &proc->pthread_emulateRF, attr_emulateRF, emulatedRF_thread, (void*)proc );
@@ -1956,10 +2281,10 @@ void kill_RU_proc(int inst)
pthread_cond_signal(&proc->cond_asynch_rxtx);
pthread_mutex_unlock(&proc->mutex_asynch_rxtx);
LOG_D(PHY, "Joining pthread_FH\n");
/*LOG_D(PHY, "Joining pthread_FH\n");
pthread_join(proc->pthread_FH, NULL);
LOG_D(PHY, "Joining pthread_FHTX\n");
pthread_join(proc->pthread_FH1, NULL);
pthread_join(proc->pthread_FH1, NULL);*/
if (ru->function == NGFI_RRU_IF4p5) {
LOG_D(PHY, "Joining pthread_prach\n");
pthread_join(proc->pthread_prach, NULL);
@@ -2125,12 +2450,12 @@ void configure_rru(int idx,
ru->frame_parms.dl_CarrierFreq = config->tx_freq[0];
ru->frame_parms.ul_CarrierFreq = config->rx_freq[0];
if (ru->frame_parms.dl_CarrierFreq == ru->frame_parms.ul_CarrierFreq) {
ru->frame_parms.frame_type = TDD;
ru->frame_parms.tdd_config = config->tdd_config[0];
ru->frame_parms.tdd_config_S = config->tdd_config_S[0];
LOG_I(PHY,"Setting RRU to TDD frame type\n");
ru->frame_parms.frame_type = TDD;
ru->frame_parms.tdd_config = config->tdd_config[0];
ru->frame_parms.tdd_config_S = config->tdd_config_S[0];
}
else
ru->frame_parms.frame_type = FDD;
else ru->frame_parms.frame_type = FDD;
ru->att_tx = config->att_tx[0];
ru->att_rx = config->att_rx[0];
ru->frame_parms.N_RB_DL = config->N_RB_DL[0];
@@ -2138,9 +2463,9 @@ void configure_rru(int idx,
ru->frame_parms.threequarter_fs = config->threequarter_fs[0];
ru->frame_parms.pdsch_config_common.referenceSignalPower = ru->max_pdschReferenceSignalPower-config->att_tx[0];
if (ru->function==NGFI_RRU_IF4p5) {
ru->frame_parms.att_rx = ru->att_rx;
ru->frame_parms.att_tx = ru->att_tx;
ru->frame_parms.att_rx = ru->att_rx;
ru->frame_parms.att_tx = ru->att_tx;
LOG_I(PHY,"Setting ru->function to NGFI_RRU_IF4p5, prach_FrequOffset %d, prach_ConfigIndex %d, att (%d,%d)\n",
config->prach_FreqOffset[0],config->prach_ConfigIndex[0],ru->att_tx,ru->att_rx);
ru->frame_parms.prach_config_common.prach_ConfigInfo.prach_FreqOffset = config->prach_FreqOffset[0];
@@ -2434,6 +2759,37 @@ void init_RU(char *rf_config_file) {
void stop_ru(RU_t *ru) {
#if defined(PRE_SCD_THREAD) || defined(PHY_TX_THREAD)
int *status;
#endif
printf("Stopping RU %p processing threads\n",(void*)ru);
#if defined(PRE_SCD_THREAD)
if(ru){
ru->proc.instance_pre_scd = 0;
pthread_cond_signal( &ru->proc.cond_pre_scd );
pthread_join(ru->proc.pthread_pre_scd, (void**)&status );
pthread_mutex_destroy(&ru->proc.mutex_pre_scd );
pthread_cond_destroy(&ru->proc.cond_pre_scd );
}
#endif
#ifdef PHY_TX_THREAD
if(ru){
ru->proc.instance_cnt_phy_tx = 0;
pthread_cond_signal(&ru->proc.cond_phy_tx);
pthread_join( ru->proc.pthread_phy_tx, (void**)&status );
pthread_mutex_destroy( &ru->proc.mutex_phy_tx );
pthread_cond_destroy( &ru->proc.cond_phy_tx );
ru->proc.instance_cnt_rf_tx = 0;
pthread_cond_signal(&ru->proc.cond_rf_tx);
pthread_join( ru->proc.pthread_rf_tx, (void**)&status );
pthread_mutex_destroy( &ru->proc.mutex_rf_tx );
pthread_cond_destroy( &ru->proc.cond_rf_tx );
}
#endif
}
void stop_RU(int nb_ru)
{
for (int inst = 0; inst < nb_ru; inst++) {
@@ -2465,7 +2821,7 @@ void RCconfig_RU(void) {
RC.ru_mask=(1<<NB_RU) - 1;
RC.ru_mask=(1<<RC.nb_RU) - 1;
printf("Set RU mask to %lx\n",RC.ru_mask);
for (j = 0; j < RC.nb_RU; j++) {
+40 -42
View File
@@ -144,17 +144,16 @@ static int8_t threequarter_fs=0;
uint32_t downlink_frequency[MAX_NUM_CCs][4];
int32_t uplink_frequency_offset[MAX_NUM_CCs][4];
char logmem_filename[1024] = {0};
// This is a dummy declaration (dlsch_demodulation.c is no longer compiled for eNodeB)
int16_t dlsch_demod_shift = 0;
#if defined(ENABLE_ITTI)
static char *itti_dump_file = NULL;
#endif
int UE_scan = 1;
int UE_scan_carrier = 0;
runmode_t mode = normal_txrx;
int simL1flag;
int snr_dB;
FILE *input_fd=NULL;
@@ -340,10 +339,14 @@ void exit_fun(const char* s)
if (RC.ru == NULL)
exit(-1); // likely init not completed, prevent crash or hang, exit now...
for (ru_id=0; ru_id<RC.nb_RU;ru_id++) {
if (RC.ru[ru_id] && RC.ru[ru_id]->rfdevice.trx_end_func)
if (RC.ru[ru_id] && RC.ru[ru_id]->rfdevice.trx_end_func) {
RC.ru[ru_id]->rfdevice.trx_end_func(&RC.ru[ru_id]->rfdevice);
if (RC.ru[ru_id] && RC.ru[ru_id]->ifdevice.trx_end_func)
RC.ru[ru_id]->rfdevice.trx_end_func = NULL;
}
if (RC.ru[ru_id] && RC.ru[ru_id]->ifdevice.trx_end_func) {
RC.ru[ru_id]->ifdevice.trx_end_func(&RC.ru[ru_id]->ifdevice);
RC.ru[ru_id]->ifdevice.trx_end_func = NULL;
}
}
@@ -459,7 +462,7 @@ void *l2l1_task(void *arg) {
switch (ITTI_MSG_ID(message_p)) {
case INITIALIZE_MESSAGE:
/* Start eNB thread */
LOG_D(EMU, "L2L1 TASK received %s\n", ITTI_MSG_NAME(message_p));
printf("L2L1 TASK received %s\n", ITTI_MSG_NAME(message_p));
start_eNB = 1;
break;
@@ -471,7 +474,7 @@ void *l2l1_task(void *arg) {
break;
default:
LOG_E(EMU, "Received unexpected message %s\n", ITTI_MSG_NAME(message_p));
printf("Received unexpected message %s\n", ITTI_MSG_NAME(message_p));
break;
}
} while (ITTI_MSG_ID(message_p) != INITIALIZE_MESSAGE);
@@ -498,11 +501,11 @@ void *l2l1_task(void *arg) {
break;
case MESSAGE_TEST:
LOG_I(EMU, "Received %s\n", ITTI_MSG_NAME(message_p));
printf("Received %s\n", ITTI_MSG_NAME(message_p));
break;
default:
LOG_E(EMU, "Received unexpected message %s\n", ITTI_MSG_NAME(message_p));
printf("Received unexpected message %s\n", ITTI_MSG_NAME(message_p));
break;
}
@@ -553,19 +556,21 @@ static void get_options(void) {
if (start_telnetsrv) {
load_module_shlib("telnetsrv",NULL,0);
}
if (strlen(logmem_filename) > 0) {
log_mem_filename = &logmem_filename[0];
log_mem_flag = 1;
printf("Enabling OPT for log save at memory %s\n",log_mem_filename);
logInit_log_mem();
}
#if T_TRACER
paramdef_t cmdline_ttraceparams[] =CMDLINE_TTRACEPARAMS_DESC ;
config_process_cmdline( cmdline_ttraceparams,sizeof(cmdline_ttraceparams)/sizeof(paramdef_t),NULL);
#endif
if ( !(CONFIG_ISFLAGSET(CONFIG_ABORT)) ) {
memset((void*)&RC,0,sizeof(RC));
/* Read RC configuration file */
RCConfig();
NB_eNB_INST = RC.nb_inst;
NB_RU = RC.nb_RU;
printf("Configuration: nb_rrc_inst %d, nb_L1_inst %d, nb_ru %d\n",NB_eNB_INST,RC.nb_L1_inst,NB_RU);
printf("Configuration: nb_rrc_inst %d, nb_L1_inst %d, nb_ru %d\n",NB_eNB_INST,RC.nb_L1_inst,RC.nb_RU);
if (nonbiotflag <= 0) {
load_NB_IoT();
printf(" nb_nbiot_rrc_inst %d, nb_nbiot_L1_inst %d, nb_nbiot_macrlc_inst %d\n",
@@ -578,11 +583,6 @@ static void get_options(void) {
}
#if T_TRACER
int T_nowait = 0; /* by default we wait for the tracer */
int T_port = 2021; /* default port to listen to to wait for the tracer */
int T_dont_fork = 0; /* default is to fork, see 'T_init' to understand */
#endif
@@ -933,10 +933,6 @@ int main( int argc, char **argv )
exit_fun("[SOFTMODEM] Error, configuration module init failed\n");
}
#ifdef DEBUG_CONSOLE
setvbuf(stdout, NULL, _IONBF, 0);
setvbuf(stderr, NULL, _IONBF, 0);
#endif
mode = normal_txrx;
memset(&openair0_cfg[0],0,sizeof(openair0_config_t)*MAX_CARDS);
@@ -957,7 +953,7 @@ int main( int argc, char **argv )
#if T_TRACER
T_init(T_port, 1-T_nowait, T_dont_fork);
T_Config_Init();
#endif
@@ -967,11 +963,6 @@ int main( int argc, char **argv )
printf("configuring for RAU/RRU\n");
if (ouput_vcd) {
VCD_SIGNAL_DUMPER_INIT("/tmp/openair_dump_eNB.vcd");
}
if (opp_enabled ==1) {
reset_opp_meas();
}
@@ -981,7 +972,7 @@ int main( int argc, char **argv )
log_set_instance_type (LOG_INSTANCE_ENB);
printf("ITTI init\n");
itti_init(TASK_MAX, THREAD_MAX, MESSAGES_ID_MAX, tasks_info, messages_info, messages_definition_xml, itti_dump_file);
itti_init(TASK_MAX, THREAD_MAX, MESSAGES_ID_MAX, tasks_info, messages_info);
// initialize mscgen log after ITTI
MSC_INIT(MSC_E_UTRAN, THREAD_MAX+TASK_MAX);
@@ -1233,6 +1224,7 @@ int main( int argc, char **argv )
// connect the TX/RX buffers
sleep(1); /* wait for thread activation */
printf("Sending sync to all threads\n");
@@ -1284,8 +1276,12 @@ int main( int argc, char **argv )
printf("stopping MODEM threads\n");
// cleanup
for (ru_id=0;ru_id<RC.nb_RU;ru_id++) {
stop_ru(RC.ru[ru_id]);
}
stop_eNB(NB_eNB_INST);
stop_RU(NB_RU);
stop_RU(RC.nb_RU);
/* release memory used by the RU/eNB threads (incomplete), after all
* threads have been stopped (they partially use the same memory) */
for (int inst = 0; inst < NB_eNB_INST; inst++) {
@@ -1294,7 +1290,7 @@ int main( int argc, char **argv )
phy_free_lte_eNB(RC.eNB[inst][cc_id]);
}
}
for (int inst = 0; inst < NB_RU; inst++) {
for (int inst = 0; inst < RC.nb_RU; inst++) {
phy_free_RU(RC.ru[inst]);
}
free_lte_top();
@@ -1313,15 +1309,17 @@ int main( int argc, char **argv )
// *** Handle per CC_id openair0
for(ru_id=0; ru_id<NB_RU; ru_id++) {
if (RC.ru[ru_id]->rfdevice.trx_end_func)
RC.ru[ru_id]->rfdevice.trx_end_func(&RC.ru[ru_id]->rfdevice);
if (RC.ru[ru_id]->ifdevice.trx_end_func)
RC.ru[ru_id]->ifdevice.trx_end_func(&RC.ru[ru_id]->ifdevice);
for(ru_id=0; ru_id<RC.nb_RU; ru_id++) {
if (RC.ru[ru_id]->rfdevice.trx_end_func) {
RC.ru[ru_id]->rfdevice.trx_end_func(&RC.ru[ru_id]->rfdevice);
RC.ru[ru_id]->rfdevice.trx_end_func = NULL;
}
if (RC.ru[ru_id]->ifdevice.trx_end_func) {
RC.ru[ru_id]->ifdevice.trx_end_func(&RC.ru[ru_id]->ifdevice);
RC.ru[ru_id]->ifdevice.trx_end_func = NULL;
}
}
if (ouput_vcd)
VCD_SIGNAL_DUMPER_CLOSE();
if (opt_enabled == 1)
terminate_opt();
+25 -24
View File
@@ -24,7 +24,7 @@
#include <sys/sysinfo.h>
#include "rt_wrapper.h"
#include "../../ARCH/COMMON/common_lib.h"
#undef MALLOC
//#undef MALLOC
#include "assertions.h"
#include "msc.h"
#include "PHY/types.h"
@@ -52,6 +52,8 @@
#define CONFIG_HLP_DBGUEPR "UE run normal prach power ramping, but don't continue random-access\n"
#define CONFIG_HLP_CALPRACH "UE run normal prach with maximum power, but don't continue random-access\n"
#define CONFIG_HLP_NOL2CN "bypass L2 and upper layers\n"
#define CONFIG_HLP_SIML1 "activate RF simulator instead of HW\n"
#define CONFIG_HLP_NUMUE "number of UE instances\n"
#define CONFIG_HLP_UERXG "set UE RX gain\n"
#define CONFIG_HLP_UERXGOFF "external UE amplifier offset\n"
#define CONFIG_HLP_UETXG "set UE TX gain\n"
@@ -80,10 +82,10 @@
#define CONFIG_HLP_MSLOTS "Skip the missed slots/subframes \n"
#define CONFIG_HLP_ULMCS "Set the maximum uplink MCS\n"
#define CONFIG_HLP_TDD "Set hardware to TDD mode (default: FDD). Used only with -U (otherwise set in config file).\n"
#define CONFIG_HLP_SNR "Set average SNR in dB (for --siml1 option)\n"
#define CONFIG_HLP_UE "Set the lte softmodem as a UE\n"
#define CONFIG_HLP_L2MONW "Enable L2 wireshark messages on localhost \n"
#define CONFIG_HLP_L2MONP "Enable L2 pcap messages on localhost \n"
#define CONFIG_HLP_VCD "Enable VCD (generated file will is named openair_dump_eNB.vcd, read it with target/RT/USER/eNB.gtkw\n"
#define CONFIG_HLP_TQFS "Apply three-quarter of sampling frequency, 23.04 Msps to reduce the data rate on USB/PCIe transfers (only valid for 20 MHz)\n"
#define CONFIG_HLP_TPORT "tracer port\n"
#define CONFIG_HLP_NOTWAIT "don't wait for tracer, start immediately\n"
@@ -131,15 +133,17 @@
/* optname helpstr paramflags XXXptr defXXXval type numelt */
/*--------------------------------------------------------------------------------------------------------------------------------------------------*/
#define CMDLINE_UEPARAMS_DESC { \
{"ue-rxgain", CONFIG_HLP_UERXG, 0, dblptr:&(rx_gain[0][0]), defdblval:0, TYPE_DOUBLE, 0}, \
{"siml1", CONFIG_HLP_SIML1, PARAMFLAG_BOOL, iptr:&simL1flag, defintval:0, TYPE_INT, 0}, \
{"U", CONFIG_HLP_NUMUE, 0, u8ptr:&NB_UE_INST, defuintval:1, TYPE_UINT, 0}, \
{"ue-rxgain", CONFIG_HLP_UERXG, 0, dblptr:&(rx_gain[0][0]), defdblval:130, TYPE_DOUBLE, 0}, \
{"ue-rxgain-off", CONFIG_HLP_UERXGOFF, 0, dblptr:&rx_gain_off, defdblval:0, TYPE_DOUBLE, 0}, \
{"ue-txgain", CONFIG_HLP_UETXG, 0, dblptr:&(tx_gain[0][0]), defdblval:0, TYPE_DOUBLE, 0}, \
{"ue-nb-ant-rx", CONFIG_HLP_UENANTR, 0, u8ptr:&nb_antenna_rx, defuintval:1, TYPE_UINT8, 0}, \
{"ue-nb-ant-tx", CONFIG_HLP_UENANTT, 0, u8ptr:&nb_antenna_tx, defuintval:1, TYPE_UINT8, 0}, \
{"ue-scan-carrier", CONFIG_HLP_UESCAN, PARAMFLAG_BOOL, iptr:&UE_scan_carrier, defintval:0, TYPE_INT, 0}, \
{"ue-max-power", NULL, 0, iptr:&(tx_max_power[0]), defintval:90, TYPE_INT, 0}, \
{"emul-iface", CONFIG_HLP_EMULIFACE, 0, strptr:&emul_iface, defstrval:"lo", TYPE_STRING, 100}, \
{"L2-emul", NULL, 0, u8ptr:&nfapi_mode, defuintval:3, TYPE_UINT8, 0}, \
{"ue-max-power", NULL, 0, iptr:&(tx_max_power[0]), defintval:23, TYPE_INT, 0}, \
{"emul-iface", CONFIG_HLP_EMULIFACE, 0, strptr:&emul_iface, defstrval:"lo", TYPE_STRING, 100}, \
{"L2-emul", NULL, 0, u8ptr:&nfapi_mode, defuintval:3, TYPE_UINT8, 0}, \
{"num-ues", NULL, 0, u8ptr:&(NB_UE_INST), defuintval:1, TYPE_UINT8, 0}, \
{"r" , CONFIG_HLP_PRB, 0, u8ptr:&(frame_parms[0]->N_RB_DL), defintval:25, TYPE_UINT8, 0}, \
{"dlsch-demod-shift", CONFIG_HLP_DLSHIFT, 0, iptr:(int32_t *)&dlsch_demod_shift, defintval:0, TYPE_INT, 0}, \
@@ -172,15 +176,14 @@
{"a" , CONFIG_HLP_CHOFF, 0, iptr:&chain_offset, defintval:0, TYPE_INT, 0}, \
{"d" , CONFIG_HLP_SOFTS, PARAMFLAG_BOOL, uptr:(uint32_t *)&do_forms, defintval:0, TYPE_INT8, 0}, \
{"E" , CONFIG_HLP_TQFS, PARAMFLAG_BOOL, i8ptr:&threequarter_fs, defintval:0, TYPE_INT8, 0}, \
{"K" , CONFIG_HLP_ITTIL, PARAMFLAG_NOFREE, strptr:&itti_dump_file, defstrval:"/tmp/itti.dump", TYPE_STRING, 0}, \
{"m" , CONFIG_HLP_DLMCS, 0, uptr:&target_dl_mcs, defintval:0, TYPE_UINT, 0}, \
{"t" , CONFIG_HLP_ULMCS, 0, uptr:&target_ul_mcs, defintval:0, TYPE_UINT, 0}, \
{"W" , CONFIG_HLP_L2MONW, 0, strptr:(char **)&in_ip, defstrval:"127.0.0.1", TYPE_STRING, sizeof(in_ip)}, \
{"P" , CONFIG_HLP_L2MONP, 0, strptr:(char **)&in_path, defstrval:"/tmp/oai_opt.pcap", TYPE_STRING, sizeof(in_path)}, \
{"V" , CONFIG_HLP_VCD, PARAMFLAG_BOOL, iptr:&ouput_vcd, defintval:0, TYPE_INT, 0}, \
{"q" , CONFIG_HLP_STMON, PARAMFLAG_BOOL, iptr:&opp_enabled, defintval:0, TYPE_INT, 0}, \
{"S" , CONFIG_HLP_MSLOTS, PARAMFLAG_BOOL, u8ptr:&exit_missed_slots, defintval:1, TYPE_UINT8, 0}, \
{"T" , CONFIG_HLP_TDD, PARAMFLAG_BOOL, iptr:&tddflag, defintval:0, TYPE_INT, 0}, \
{"s" , CONFIG_HLP_SNR, 0, iptr:&snr_dB, defintval:25, TYPE_INT, 0}, \
{"numerology" , CONFIG_HLP_NUMEROLOGY, PARAMFLAG_BOOL, iptr:&numerology, defintval:0, TYPE_INT, 0}, \
{"emulate-rf" , CONFIG_HLP_EMULATE_RF, PARAMFLAG_BOOL, iptr:&emulate_rf, defintval:0, TYPE_INT, 0}, \
{"codingw" , CONFIG_HLP_CODINGW, PARAMFLAG_BOOL, iptr:&codingw, defintval:0, TYPE_INT, 0}, \
@@ -201,6 +204,7 @@
{"g" , CONFIG_HLP_LOGL, 0, uptr:&glog_level, defintval:0, TYPE_UINT, 0}, \
{"G" , CONFIG_HLP_LOGV, 0, uptr:&glog_verbosity, defintval:0, TYPE_UINT16, 0}, \
{"telnetsrv", CONFIG_HLP_TELN, PARAMFLAG_BOOL, uptr:&start_telnetsrv, defintval:0, TYPE_UINT, 0}, \
{"log-mem", NULL, 0, strptr:(char **)&logmem_filename, defstrval:"./logmem.log", TYPE_STRING, sizeof(logmem_filename)}, \
}
#define CMDLINE_ONLINELOG_IDX 0
#define CMDLINE_GLOGLEVEL_IDX 1
@@ -208,21 +212,6 @@
#define CMDLINE_STARTTELN_IDX 3
extern int T_port;
extern int T_nowait;
extern int T_dont_fork;
/*------------------------------------------------------------------------------------------------------------------------------------------*/
/* command line parameters for TTRACE utility */
/* optname helpstr paramflags XXXptr defXXXval type numelt */
/*------------------------------------------------------------------------------------------------------------------------------------------*/
#define CMDLINE_TTRACEPARAMS_DESC { \
{"T_port", CONFIG_HLP_TPORT, 0, iptr:&T_port, defintval:0, TYPE_INT, 0}, \
{"T_nowait", CONFIG_HLP_NOTWAIT, PARAMFLAG_BOOL, iptr:&T_nowait, defintval:0, TYPE_INT, 0}, \
{"T_dont_fork", CONFIG_HLP_TNOFORK, PARAMFLAG_BOOL, iptr:&T_dont_fork, defintval:1, TYPE_INT, 0}, \
}
/***************************************************************************************************************************************/
/* */
extern pthread_cond_t sync_cond;
@@ -263,6 +252,7 @@ extern void kill_eNB_proc(int inst);
// In lte-ru.c
extern void init_RU(const char*);
extern void stop_ru(RU_t *ru);
extern void init_RU_proc(RU_t *ru);
extern void stop_RU(int nb_ru);
extern void kill_RU_proc(int inst);
@@ -272,7 +262,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);
extern void init_UE(int nb_inst,int eMBMS_active, int uecap_xer_in, int timing_correction, int phy_test, int UE_scan, int UE_scan_carrier, runmode_t mode,int rxgain,int txpowermax, LTE_DL_FRAME_PARMS *fp);
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);
@@ -284,6 +274,10 @@ extern void init_te_thread(PHY_VARS_eNB *);
extern void kill_td_thread(PHY_VARS_eNB *);
extern void kill_te_thread(PHY_VARS_eNB *);
extern void RCConfig_sim(void);
extern void init_ocm(double,double);
extern void init_ue_devices(PHY_VARS_UE *);
PHY_VARS_UE* init_ue_vars(LTE_DL_FRAME_PARMS *frame_parms,
uint8_t UE_id,
uint8_t abstraction_flag);
@@ -292,4 +286,11 @@ void init_eNB_afterRU(void);
extern int stop_L1L2(module_id_t enb_id);
extern int restart_L1L2(module_id_t enb_id);
extern void init_UE_stub_single_thread(int nb_inst,int eMBMS_active, int uecap_xer_in, char *emul_iface);
extern PHY_VARS_UE* init_ue_vars(LTE_DL_FRAME_PARMS *frame_parms,
uint8_t UE_id,
uint8_t abstraction_flag);
#endif
+112 -345
View File
@@ -79,7 +79,7 @@ void init_UE_threads(int);
void init_UE_threads_stub(int);
void init_UE_single_thread_stub(int);
void *UE_thread(void *arg);
void init_UE(int nb_inst,int,int,int);
void init_UE(int nb_inst,int eMBMS_active, int uecap_xer_in, int timing_correction, int phy_test, int UE_scan, int UE_scan_carrier, runmode_t mode,int rxgain,int txpowermax,LTE_DL_FRAME_PARMS *fp);
void init_UE_stub(int nb_inst,int,int,char*);
void init_UE_stub_single_thread(int nb_inst,int,int,char*);
int init_timer_thread(void);
@@ -93,6 +93,8 @@ extern int oai_nfapi_sr_indication(nfapi_sr_indication_t *ind);
extern int oai_nfapi_rx_ind(nfapi_rx_indication_t *ind);
extern int multicast_link_write_sock(int groupP, char *dataP, uint32_t sizeP);
extern int simL1flag;
//extern int tx_req_UE_MAC1();
void ue_stub_rx_handler(unsigned int, char *);
@@ -170,20 +172,18 @@ PHY_VARS_UE* init_ue_vars(LTE_DL_FRAME_PARMS *frame_parms,
{
PHY_VARS_UE* ue;
PHY_VARS_UE* ue = (PHY_VARS_UE *)malloc(sizeof(PHY_VARS_UE));
memset(ue,0,sizeof(PHY_VARS_UE));
if (frame_parms!=(LTE_DL_FRAME_PARMS *)NULL) { // if we want to give initial frame parms, allocate the PHY_VARS_UE structure and put them in
ue = (PHY_VARS_UE *)malloc(sizeof(PHY_VARS_UE));
memset(ue,0,sizeof(PHY_VARS_UE));
memcpy(&(ue->frame_parms), frame_parms, sizeof(LTE_DL_FRAME_PARMS));
}
else ue = PHY_vars_UE_g[UE_id][0];
ue->Mod_id = UE_id;
ue->mac_enabled = 1;
// Panos: In phy_stub_UE (MAC-to-MAC) mode these init functions don't need to get called. Is this correct?
// In phy_stub_UE (MAC-to-MAC) mode these init functions don't need to get called. Is this correct?
if (nfapi_mode!=3)
{
// initialize all signal buffers
@@ -236,11 +236,12 @@ 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) {
void init_UE(int nb_inst,int eMBMS_active, int uecap_xer_in, int timing_correction, int phy_test, int UE_scan, int UE_scan_carrier, runmode_t mode,int rxgain,int txpowermax,LTE_DL_FRAME_PARMS *fp0) {
PHY_VARS_UE *UE;
int inst;
int ret;
LTE_DL_FRAME_PARMS *fp;
LOG_I(PHY,"UE : Calling Layer 2 for initialization\n");
@@ -248,18 +249,95 @@ void init_UE(int nb_inst,int eMBMS_active, int uecap_xer_in, int timing_correcti
0,// cba_group_active
0); // HO flag
if (PHY_vars_UE_g==NULL) PHY_vars_UE_g = (PHY_VARS_UE***)calloc(1+nb_inst,sizeof(PHY_VARS_UE**));
for (inst=0;inst<nb_inst;inst++) {
if (PHY_vars_UE_g[inst]==NULL) PHY_vars_UE_g[inst] = (PHY_VARS_UE**)calloc(1+MAX_NUM_CCs,sizeof(PHY_VARS_UE*));
LOG_I(PHY,"Allocating UE context %d\n",inst);
LOG_I(PHY,"Initializing memory for UE instance %d (%p)\n",inst,PHY_vars_UE_g[inst]);
PHY_vars_UE_g[inst][0] = init_ue_vars(NULL,inst,0);
if (simL1flag == 0) PHY_vars_UE_g[inst][0] = init_ue_vars(fp0,inst,0);
else {
// needed for memcopy below. these are not used in the RU, but needed for UE
RC.ru[0]->frame_parms.nb_antennas_rx = fp0->nb_antennas_rx;
RC.ru[0]->frame_parms.nb_antennas_tx = fp0->nb_antennas_tx;
PHY_vars_UE_g[inst][0] = init_ue_vars(&RC.ru[0]->frame_parms,inst,0);
}
// turn off timing control loop in UE
PHY_vars_UE_g[inst][0]->no_timing_correction = timing_correction;
UE = PHY_vars_UE_g[inst][0];
fp = &UE->frame_parms;
printf("PHY_vars_UE_g[0][0] = %p\n",UE);
if (phy_test==1)
UE->mac_enabled = 0;
else
UE->mac_enabled = 1;
if (UE->mac_enabled == 0) { //set default UL parameters for testing mode
for (int i=0; i<NUMBER_OF_CONNECTED_eNB_MAX; i++) {
UE->pusch_config_dedicated[i].betaOffset_ACK_Index = 0;
UE->pusch_config_dedicated[i].betaOffset_RI_Index = 0;
UE->pusch_config_dedicated[i].betaOffset_CQI_Index = 2;
UE->scheduling_request_config[i].sr_PUCCH_ResourceIndex = 0;
UE->scheduling_request_config[i].sr_ConfigIndex = 7+(0%3);
UE->scheduling_request_config[i].dsr_TransMax = sr_n4;
}
}
UE->UE_scan = UE_scan;
UE->UE_scan_carrier = UE_scan_carrier;
UE->mode = mode;
printf("UE->mode = %d\n",mode);
if (UE->mac_enabled == 1) {
UE->pdcch_vars[0][0]->crnti = 0x1234;
UE->pdcch_vars[1][0]->crnti = 0x1234;
}else {
UE->pdcch_vars[0][0]->crnti = 0x1235;
UE->pdcch_vars[1][0]->crnti = 0x1235;
}
UE->rx_total_gain_dB = rxgain;
UE->tx_power_max_dBm = txpowermax;
UE->frame_parms.nb_antennas_tx = fp0->nb_antennas_tx;
UE->frame_parms.nb_antennas_rx = fp0->nb_antennas_rx;
if (fp->frame_type == TDD) {
switch (fp->N_RB_DL) {
case 100:
if (fp->threequarter_fs) UE->N_TA_offset = (624*3)/4;
else UE->N_TA_offset = 624;
break;
case 75:
UE->N_TA_offset = (624*3)/4;
break;
case 50:
UE->N_TA_offset = 624/2;
break;
case 25:
UE->N_TA_offset = 624/4;
break;
case 15:
UE->N_TA_offset = 624/8;
break;
case 6:
UE->N_TA_offset = 624/16;
break;
default:
AssertFatal(1==0,"illegal N_RB_DL %d\n",fp->N_RB_DL);
break;
}
}
else UE->N_TA_offset = 0;
if (simL1flag == 1) init_ue_devices(UE);
LOG_I(PHY,"Intializing UE Threads for instance %d (%p,%p)...\n",inst,PHY_vars_UE_g[inst],PHY_vars_UE_g[inst][0]);
init_UE_threads(inst);
UE = PHY_vars_UE_g[inst][0];
if (oaisim_flag == 0) {
if (simL1flag == 0) {
ret = openair0_device_load(&(UE->rfdevice), &openair0_cfg[0]);
if (ret !=0){
exit_fun("Error loading device library");
@@ -267,7 +345,7 @@ void init_UE(int nb_inst,int eMBMS_active, int uecap_xer_in, int timing_correcti
}
UE->rfdevice.host_type = RAU_HOST;
// UE->rfdevice.type = NONE_DEV;
PHY_VARS_UE *UE = PHY_vars_UE_g[inst][0];
AssertFatal(0 == pthread_create(&UE->proc.pthread_ue,
&UE->proc.attr_ue,
UE_thread,
@@ -275,17 +353,9 @@ void init_UE(int nb_inst,int eMBMS_active, int uecap_xer_in, int timing_correcti
}
printf("UE threads created by %ld\n", gettid());
#if 0
#if defined(ENABLE_USE_MME)
extern volatile int start_UE;
while (start_UE == 0) {
sleep(1);
}
#endif
#endif
}
// Panos: Initiating all UEs within a single set of threads for PHY_STUB. Future extensions -> multiple
// Initiating all UEs within a single set of threads for PHY_STUB. Future extensions -> multiple
// set of threads for multiple UEs.
void init_UE_stub_single_thread(int nb_inst,int eMBMS_active, int uecap_xer_in, char *emul_iface) {
@@ -443,9 +513,12 @@ static void *UE_thread_synch(void *arg)
}
}
/*
while (sync_var<0)
pthread_cond_wait(&sync_cond, &sync_mutex);
pthread_mutex_unlock(&sync_mutex);
*/
wait_sync("UE_thread_sync");
printf("Started device, unlocked sync_mutex (UE_sync_thread)\n");
@@ -931,8 +1004,6 @@ static void *UE_phy_stub_single_thread_rxn_txnp4(void *arg) {
LOG_E( MAC, "[SCHED][UE] error unlocking mutex for UE RXn_TXnp4\n" );
exit_fun("nothing to add");
}
LOG_D(MAC," Panos-D [UE_phy_stub_thread_rxn_txnp4 1] Frame: %d, Subframe: %d \n" "\n" "\n", timer_frame, timer_subframe);
proc->subframe_rx=timer_subframe;
proc->frame_rx = timer_frame;
@@ -943,14 +1014,14 @@ static void *UE_phy_stub_single_thread_rxn_txnp4(void *arg) {
oai_subframe_ind(timer_frame, timer_subframe);
// Panos: Guessing that the next 4 lines are not needed for the phy_stub mode.
//Guessing that the next 4 lines are not needed for the phy_stub mode.
/*initRefTimes(t2);
initRefTimes(t3);
pickTime(current);
updateTimes(proc->gotIQs, &t2, 10000, "Delay to wake up UE_Thread_Rx (case 2)");*/
//Panos: Not sure whether we should put the memory allocation here and not sure how much memory
// Not sure whether we should put the memory allocation here and not sure how much memory
//we should allocate for each subframe cycle.
UL_INFO = (UL_IND_t*)malloc(sizeof(UL_IND_t));
@@ -1082,7 +1153,7 @@ static void *UE_phy_stub_single_thread_rxn_txnp4(void *arg) {
//ue_prach_procedures(ue,proc,eNB_id,abstraction_flag,mode);
}
} // mode is PRACH
// Panos: Substitute call to phy_procedures Tx with call to phy_stub functions in order to trigger
// Substitute call to phy_procedures Tx with call to phy_stub functions in order to trigger
// UE Tx procedures directly at the MAC layer, based on the received ul_config requests from the vnf (eNB).
// Generate UL_indications which correspond to UL traffic.
if(ul_config_req!=NULL){ //&& UE_mac_inst[Mod_id].ul_config_req->ul_config_request_body.ul_config_pdu_list != NULL){
@@ -1222,7 +1293,7 @@ static void *UE_phy_stub_thread_rxn_txnp4(void *arg) {
phy_stub_ticking->ticking_var = -1;
proc->subframe_rx=proc->sub_frame_start;
//PANOS: CAREFUL HERE!
// CAREFUL HERE!
wait_sync("UE_phy_stub_thread_rxn_txnp4");
while (!oai_exit) {
@@ -1242,8 +1313,6 @@ static void *UE_phy_stub_thread_rxn_txnp4(void *arg) {
LOG_E( MAC, "[SCHED][UE] error unlocking mutex for UE RXn_TXnp4\n" );
exit_fun("nothing to add");
}
LOG_D(MAC," Panos-D [UE_phy_stub_thread_rxn_txnp4 1] Frame: %d, Subframe: %d \n" "\n" "\n", timer_frame, timer_subframe);
proc->subframe_rx=timer_subframe;
proc->frame_rx = timer_frame;
@@ -1286,7 +1355,6 @@ static void *UE_phy_stub_thread_rxn_txnp4(void *arg) {
}
//if(UE_mac_inst[Mod_id].hi_dci0_req!= NULL){
if (hi_dci0_req!=NULL && hi_dci0_req->hi_dci0_request_body.hi_dci0_pdu_list!=NULL){
LOG_I( MAC, "Panos-D: UE_phy_stub_thread_rxn_txnp4 after oai_subframe_ind 4 \n");
hi_dci0_req_UE_MAC(hi_dci0_req, Mod_id);
//if(UE_mac_inst[Mod_id].hi_dci0_req->hi_dci0_request_body.hi_dci0_pdu_list!=NULL){
free(hi_dci0_req->hi_dci0_request_body.hi_dci0_pdu_list);
@@ -1350,7 +1418,6 @@ static void *UE_phy_stub_thread_rxn_txnp4(void *arg) {
if (UE->mode != loop_through_memory){
if ((UE_mac_inst[Mod_id].UE_mode[0] == PRACH) ) {
//LOG_D(MAC, "Panos-D: UE_phy_stub_thread_rxn_txnp4 before RACH \n");
// check if we have PRACH opportunity
@@ -1365,7 +1432,7 @@ static void *UE_phy_stub_thread_rxn_txnp4(void *arg) {
//ue_prach_procedures(ue,proc,eNB_id,abstraction_flag,mode);
}
} // mode is PRACH
// Panos: Substitute call to phy_procedures Tx with call to phy_stub functions in order to trigger
// Substitute call to phy_procedures Tx with call to phy_stub functions in order to trigger
// UE Tx procedures directly at the MAC layer, based on the received ul_config requests from the vnf (eNB).
// Generate UL_indications which correspond to UL traffic.
if(ul_config_req!= NULL && ul_config_req->ul_config_request_body.ul_config_pdu_list != NULL){
@@ -1425,6 +1492,13 @@ void *UE_thread(void *arg) {
init_thread(100000, 500000, FIFO_PRIORITY, &cpuset,
"UHD Threads");
/*
while (sync_var<0)
pthread_cond_wait(&sync_cond, &sync_mutex);
pthread_mutex_unlock(&sync_mutex);
*/
wait_sync("UE thread");
#ifdef NAS_UE
MessageDef *message_p;
message_p = itti_alloc_new_message(TASK_NAS_UE, INITIALIZE_MESSAGE);
@@ -1751,12 +1825,12 @@ void init_UE_single_thread_stub(int nb_inst) {
pthread_attr_init (&UE->proc.attr_ue);
pthread_attr_setstacksize(&UE->proc.attr_ue,8192);//5*PTHREAD_STACK_MIN);
// Panos: Don't need synch for phy_stub mode
// Don't need synch for phy_stub mode
//pthread_mutex_init(&UE->proc.mutex_synch,NULL);
//pthread_cond_init(&UE->proc.cond_synch,NULL);
// the threads are not yet active, therefore access is allowed without locking
// Panos: In phy_stub_UE mode due to less heavy processing operations we don't need two threads
// In phy_stub_UE mode due to less heavy processing operations we don't need two threads
//int nb_threads=RX_NB_TH;
int nb_threads=1;
for (int i=0; i<nb_threads; i++) {
@@ -1773,7 +1847,7 @@ void init_UE_single_thread_stub(int nb_inst) {
pthread_create(&UE->proc.proc_rxtx[i].pthread_rxtx, NULL, UE_phy_stub_single_thread_rxn_txnp4, rtd);
}
// Panos: Remove thread for UE_sync in phy_stub_UE mode.
// Remove thread for UE_sync in phy_stub_UE mode.
//pthread_create(&UE->proc.pthread_synch,NULL,UE_thread_synch,(void*)UE);
}
@@ -1803,12 +1877,12 @@ void init_UE_threads_stub(int inst) {
pthread_attr_init (&UE->proc.attr_ue);
pthread_attr_setstacksize(&UE->proc.attr_ue,8192);//5*PTHREAD_STACK_MIN);
// Panos: Don't need synch for phy_stub mode
// Don't need synch for phy_stub mode
//pthread_mutex_init(&UE->proc.mutex_synch,NULL);
//pthread_cond_init(&UE->proc.cond_synch,NULL);
// the threads are not yet active, therefore access is allowed without locking
// Panos: In phy_stub_UE mode due to less heavy processing operations we don't need two threads
// In phy_stub_UE mode due to less heavy processing operations we don't need two threads
//int nb_threads=RX_NB_TH;
int nb_threads=1;
for (int i=0; i<nb_threads; i++) {
@@ -1826,7 +1900,7 @@ void init_UE_threads_stub(int inst) {
}
// Panos: Remove thread for UE_sync in phy_stub_UE mode.
// Remove thread for UE_sync in phy_stub_UE mode.
//pthread_create(&UE->proc.pthread_synch,NULL,UE_thread_synch,(void*)UE);
}
@@ -1906,168 +1980,6 @@ int setup_ue_buffers(PHY_VARS_UE **phy_vars_ue, openair0_config_t *openair0_cfg)
/*static void* timer_thread( void* param ) {
thread_top_init("timer_thread",1,870000L,1000000L,1000000L);
timer_subframe =9;
timer_frame =1023;
//phy_stub_ticking = (SF_ticking*)malloc(sizeof(SF_ticking));
phy_stub_ticking->ticking_var = -1;
PHY_VARS_UE *UE;
UE = PHY_vars_UE_g[0][0];
double t_diff;
int external_timer = 0;
//struct timespec pselect_start;
//struct timespec sf_duration;
//sf_duration.tv_sec = 0;
//sf_duration.tv_nsec = 1e6;
wait_sync("timer_thread");
//pthread_mutex_init(&phy_stub_ticking->mutex_ticking,NULL);
//pthread_cond_init(&phy_stub_ticking->cond_ticking,NULL);
// struct timespec start = {0};
// struct timespec end = {0};
//sleepValue.tv_nsec = 1000000;
opp_enabled = 1;
// first check if we are receiving timing indications
if(nfapi_mode==4) {
usleep(10000);
if (UE->instance_cnt_timer > 0) {
external_timer = 1;
int absSFm1 = ((emulator_absSF+10239)%10240);
timer_frame = absSFm1/10;
timer_subframe = absSFm1%10;
pthread_mutex_lock(&UE->timer_mutex);
UE->instance_cnt_timer = -1;
pthread_mutex_unlock(&UE->timer_mutex);
LOG_I(PHY,"Running with external timer\n");
}
else LOG_I(PHY,"Running with internal timer\n");
}
struct timespec t_start;
struct timespec t_now;
struct timespec t_sleep;
uint64_t T_0;
uint64_t T_now;
uint64_t T_next_SF;
uint64_t T_sleep;
uint64_t sf_cnt = 0; //Total Subframe counter
clock_gettime(CLOCK_MONOTONIC, &t_start);
T_0 = (uint64_t) t_start.tv_sec*1000000000 + t_start.tv_nsec;
LOG_I(MAC, "Panos-D: timer_thread(), T_0 value: %" PRId64 "\n", T_0);
//printf("%" PRId64 "\n", t);
while (!oai_exit) {
// these are local subframe/frame counters to check that we are in synch with the fronthaul timing.
// They are set on the first rx/tx in the underly FH routines.
if (timer_subframe==9) {
timer_subframe=0;
timer_frame++;
timer_frame&=1023;
} else {
timer_subframe++;
}
//printf("[timer_thread] Frame: %d, Subframe: %d \n", timer_frame, timer_subframe);
//LOG_I(MAC," Panos-D [timer_thread] Frame: %d, Subframe: %d \n", timer_frame, timer_subframe);
//AssertFatal( 0 == pthread_cond_signal(&phy_stub_ticking->cond_ticking), "");
AssertFatal(pthread_mutex_lock(&phy_stub_ticking->mutex_ticking) ==0,"");
phy_stub_ticking->ticking_var++;
// This should probably be a call to pthread_cond_broadcast when we introduce support for multiple UEs (threads)
if(phy_stub_ticking->ticking_var == 0){
//AssertFatal(phy_stub_ticking->ticking_var == 0,"phy_stub_ticking->ticking_var = %d",
//phy_stub_ticking->ticking_var);
if (pthread_cond_signal(&phy_stub_ticking->cond_ticking) != 0) {
//LOG_E( PHY, "[SCHED][UE %d] ERROR pthread_cond_signal for UE RX thread\n", UE->Mod_id);
LOG_E( PHY, "timer_thread ERROR pthread_cond_signal for UE_thread\n");
exit_fun("nothing to add");
}
}
else
LOG_I(MAC, "Panos-D: timer_thread() Timing problem! \n");
AssertFatal(pthread_mutex_unlock(&phy_stub_ticking->mutex_ticking) ==0,"");
start_meas(&UE->timer_stats);
//clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &start); // get initial time-stamp
if (external_timer == 0) {
sf_cnt++;
T_next_SF = T_0 + sf_cnt*1000000;
do{
clock_gettime(CLOCK_MONOTONIC, &t_now);
T_now =(uint64_t) t_now.tv_sec*1000000000 + t_now.tv_nsec;
}while(T_now < T_next_SF);
//usleep(1000);
UE_tport_t pdu;
pdu.header.packet_type = TTI_SYNC;
pdu.header.absSF = (timer_frame*10)+timer_subframe;
if (nfapi_mode!=3){
multicast_link_write_sock(0,
&pdu,
sizeof(UE_tport_header_t));
}
}
else {
wait_on_condition(&UE->timer_mutex,&UE->timer_cond,&UE->instance_cnt_timer,"timer_thread");
release_thread(&UE->timer_mutex,&UE->instance_cnt_timer,"timer_thread");
}
//clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &end); // get final time-stamp
//double t_ns = (double)(end.tv_sec - start.tv_sec) * 1.0e9 +
// (double)(end.tv_nsec - start.tv_nsec);
//printf("Panos-D: [timer_thread] REAL TIME difference: %f", t_ns);
stop_meas(&UE->timer_stats);
t_diff = get_time_meas_us(&UE->timer_stats);
//printf("Panos-D: Absolute time: %lld, diff: %lld, diff_now: %lld \n",UE->timer_stats.p_time, UE->timer_stats.diff, UE->timer_stats.diff_now);
//LOG_I(MAC,"[UE%d] Applying default macMainConfig\n",module_idP);
//if (t_diff > 1100)
// LOG_E(MAC," Panos-D Absolute time: %f\n", t_diff);
//LOG_E(MAC," Panos-D Absolute time: %f\n", t_diff);
//printf("Panos-D: Absolute time: %f", t_diff);
stop_meas(&UE->timer_stats);
t_diff = get_time_meas_us(&UE->timer_stats);
//printf("Panos-D: Absolute time: %lld, diff: %lld, diff_now: %lld \n",UE->timer_stats.p_time, UE->timer_stats.diff, UE->timer_stats.diff_now);
//LOG_I(MAC,"[UE%d] Applying default macMainConfig\n",module_idP);
//if (t_diff > 1100) LOG_E(MAC," Panos-D Absolute time: %f\n", t_diff);
//printf("Panos-D: Absolute time: %f", t_diff);
//UE->proc.ticking_var++;
// pthread_cond_signal() //Send signal to ue_thread()?
// We also need to somehow pass the information of SFN/SF
}
free(phy_stub_ticking);
pthread_cond_destroy(&phy_stub_ticking->cond_ticking);
pthread_mutex_destroy(&phy_stub_ticking->mutex_ticking);
return 0;
}*/
// Panos: This timer thread is used only in the phy_stub mode as an independent timer
// which will be ticking and provide the SFN/SF values that will be used from the UE threads
@@ -2198,151 +2110,6 @@ static void* timer_thread( void* param ) {
/*static void* timer_thread( void* param ) {
thread_top_init("timer_thread",1,870000L,1000000L,1000000L);
timer_subframe =9;
timer_frame =1023;
//phy_stub_ticking = (SF_ticking*)malloc(sizeof(SF_ticking));
phy_stub_ticking->ticking_var = -1;
PHY_VARS_UE *UE;
UE = PHY_vars_UE_g[0][0];
double t_diff;
int external_timer = 0;
wait_sync("timer_thread");
//pthread_mutex_init(&phy_stub_ticking->mutex_ticking,NULL);
//pthread_cond_init(&phy_stub_ticking->cond_ticking,NULL);
// struct timespec start = {0};
// struct timespec end = {0};
//sleepValue.tv_nsec = 1000000;
opp_enabled = 1;
// first check if we are receiving timing indications
if(nfapi_mode==4) {
usleep(10000);
if (UE->instance_cnt_timer > 0) {
external_timer = 1;
int absSFm1 = ((emulator_absSF+10239)%10240);
timer_frame = absSFm1/10;
timer_subframe = absSFm1%10;
pthread_mutex_lock(&UE->timer_mutex);
UE->instance_cnt_timer = -1;
pthread_mutex_unlock(&UE->timer_mutex);
LOG_I(PHY,"Running with external timer\n");
}
else LOG_I(PHY,"Running with internal timer\n");
}
while (!oai_exit) {
// these are local subframe/frame counters to check that we are in synch with the fronthaul timing.
// They are set on the first rx/tx in the underly FH routines.
if (timer_subframe==9) {
timer_subframe=0;
timer_frame++;
timer_frame&=1023;
} else {
timer_subframe++;
}
//printf("[timer_thread] Frame: %d, Subframe: %d \n", timer_frame, timer_subframe);
//LOG_I(MAC," Panos-D [timer_thread] Frame: %d, Subframe: %d \n", timer_frame, timer_subframe);
//AssertFatal( 0 == pthread_cond_signal(&phy_stub_ticking->cond_ticking), "");
AssertFatal(pthread_mutex_lock(&phy_stub_ticking->mutex_ticking) ==0,"");
phy_stub_ticking->ticking_var++;
// This should probably be a call to pthread_cond_broadcast when we introduce support for multiple UEs (threads)
if(phy_stub_ticking->ticking_var == 0){
//AssertFatal(phy_stub_ticking->ticking_var == 0,"phy_stub_ticking->ticking_var = %d",
// phy_stub_ticking->ticking_var);
if (pthread_cond_signal(&phy_stub_ticking->cond_ticking) != 0) {
//LOG_E( PHY, "[SCHED][UE %d] ERROR pthread_cond_signal for UE RX thread\n", UE->Mod_id);
LOG_E( PHY, "timer_thread ERROR pthread_cond_signal for UE_thread\n");
exit_fun("nothing to add");
}
}
AssertFatal(pthread_mutex_unlock(&phy_stub_ticking->mutex_ticking) ==0,"");
start_meas(&UE->timer_stats);
//clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &start); // get initial time-stamp
if (external_timer == 0) {
usleep(1000);
UE_tport_t pdu;
pdu.header.packet_type = TTI_SYNC;
pdu.header.absSF = (timer_frame*10)+timer_subframe;
multicast_link_write_sock(0,
&pdu,
sizeof(UE_tport_header_t));
}
else {
wait_on_condition(&UE->timer_mutex,&UE->timer_cond,&UE->instance_cnt_timer,"timer_thread");
release_thread(&UE->timer_mutex,&UE->instance_cnt_timer,"timer_thread");
}
//clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &end); // get final time-stamp
//double t_ns = (double)(end.tv_sec - start.tv_sec) * 1.0e9 +
// (double)(end.tv_nsec - start.tv_nsec);
//printf("Panos-D: [timer_thread] REAL TIME difference: %f", t_ns);
stop_meas(&UE->timer_stats);
t_diff = get_time_meas_us(&UE->timer_stats);
//printf("Panos-D: Absolute time: %lld, diff: %lld, diff_now: %lld \n",UE->timer_stats.p_time, UE->timer_stats.diff, UE->timer_stats.diff_now);
//LOG_I(MAC,"[UE%d] Applying default macMainConfig\n",module_idP);
//if (t_diff > 1100)
// LOG_E(MAC," Panos-D Absolute time: %f\n", t_diff);
//LOG_E(MAC," Panos-D Absolute time: %f\n", t_diff);
//printf("Panos-D: Absolute time: %f", t_diff);
stop_meas(&UE->timer_stats);
t_diff = get_time_meas_us(&UE->timer_stats);
//printf("Panos-D: Absolute time: %lld, diff: %lld, diff_now: %lld \n",UE->timer_stats.p_time, UE->timer_stats.diff, UE->timer_stats.diff_now);
//LOG_I(MAC,"[UE%d] Applying default macMainConfig\n",module_idP);
//if (t_diff > 1100) LOG_E(MAC," Panos-D Absolute time: %f\n", t_diff);
//printf("Panos-D: Absolute time: %f", t_diff);
//UE->proc.ticking_var++;
// pthread_cond_signal() //Send signal to ue_thread()?
// We also need to somehow pass the information of SFN/SF
}
free(phy_stub_ticking);
pthread_cond_destroy(&phy_stub_ticking->cond_ticking);
pthread_mutex_destroy(&phy_stub_ticking->mutex_ticking);
return 0;
}*/
int init_timer_thread(void) {
//PHY_VARS_UE *UE=PHY_vars_UE_g[0];
PHY_VARS_UE *UE=PHY_vars_UE_g[0][0];
+147 -251
View File
@@ -63,7 +63,6 @@
#include "PHY/LTE_TRANSPORT/transport_vars.h"
#include "SCHED/sched_common_vars.h"
#include "PHY/MODULATION/modulation_vars.h"
#include "../../SIMU/USER/init_lte.h"
#include "LAYER2/MAC/mac.h"
#include "LAYER2/MAC/mac_vars.h"
@@ -150,12 +149,11 @@ int32_t uplink_frequency_offset[MAX_NUM_CCs][4];
#if defined(ENABLE_ITTI)
static char *itti_dump_file = NULL;
#endif
int UE_scan = 1;
int UE_scan_carrier = 0;
int simL1flag = 0;
int snr_dB=25;
runmode_t mode = normal_txrx;
FILE *input_fd=NULL;
@@ -164,11 +162,11 @@ FILE *input_fd=NULL;
#if MAX_NUM_CCs == 1
rx_gain_t rx_gain_mode[MAX_NUM_CCs][4] = {{max_gain,max_gain,max_gain,max_gain}};
double tx_gain[MAX_NUM_CCs][4] = {{20,0,0,0}};
double rx_gain[MAX_NUM_CCs][4] = {{110,0,0,0}};
double rx_gain[MAX_NUM_CCs][4] = {{130,0,0,0}};
#else
rx_gain_t rx_gain_mode[MAX_NUM_CCs][4] = {{max_gain,max_gain,max_gain,max_gain},{max_gain,max_gain,max_gain,max_gain}};
double tx_gain[MAX_NUM_CCs][4] = {{20,0,0,0},{20,0,0,0}};
double rx_gain[MAX_NUM_CCs][4] = {{110,0,0,0},{20,0,0,0}};
double rx_gain[MAX_NUM_CCs][4] = {{130,0,0,0},{20,0,0,0}};
#endif
double rx_gain_off = 0.0;
@@ -212,8 +210,6 @@ uint8_t exit_missed_slots=1;
uint64_t num_missed_slots=0; // counter for the number of missed slots
extern void reset_opp_meas(void);
extern void print_opp_meas(void);
extern void init_UE_stub_single_thread(int nb_inst,int eMBMS_active, int uecap_xer_in, char *emul_iface);
extern PHY_VARS_UE* init_ue_vars(LTE_DL_FRAME_PARMS *frame_parms,
@@ -452,11 +448,11 @@ void *l2l1_task(void *arg) {
break;
case MESSAGE_TEST:
LOG_I(EMU, "Received %s\n", ITTI_MSG_NAME(message_p));
LOG_I(SIM, "Received %s\n", ITTI_MSG_NAME(message_p));
break;
default:
LOG_E(EMU, "Received unexpected message %s\n", ITTI_MSG_NAME(message_p));
LOG_E(SIM, "Received unexpected message %s\n", ITTI_MSG_NAME(message_p));
break;
}
@@ -471,6 +467,7 @@ void *l2l1_task(void *arg) {
extern int16_t dlsch_demod_shift;
static void get_options(void) {
char logmem_filename[1024] = {0};
int CC_id;
int tddflag, nonbiotflag;
char *loopfile=NULL;
@@ -539,8 +536,7 @@ static void get_options(void) {
}
UE_scan=0;
if (tddflag > 0) {
if (tddflag > 0) {
for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++)
frame_parms[CC_id]->frame_type = TDD;
}
@@ -572,16 +568,11 @@ static void get_options(void) {
for (CC_id=1;CC_id<MAX_NUM_CCs;CC_id++) {
tx_max_power[CC_id]=tx_max_power[0];
rx_gain[0][CC_id] = rx_gain[0][0];
tx_gain[0][CC_id] = tx_gain[0][0];
}
#if T_TRACER
paramdef_t cmdline_ttraceparams[] =CMDLINE_TTRACEPARAMS_DESC ;
config_process_cmdline( cmdline_ttraceparams,sizeof(cmdline_ttraceparams)/sizeof(paramdef_t),NULL);
#endif
/*
if ( !(CONFIG_ISFLAGSET(CONFIG_ABORT)) && (!(CONFIG_ISFLAGSET(CONFIG_NOOOPT))) ) {
// Here the configuration file is the XER encoded UE capabilities
// Read it in and store in asn1c data structures
@@ -589,18 +580,10 @@ static void get_options(void) {
printf("%s\n",uecap_xer);
if(nfapi_mode!=3)
uecap_xer_in=1;
} /* UE with config file */
} *//* UE with config file */
}
#if T_TRACER
int T_nowait = 0; /* by default we wait for the tracer */
int T_port = 2021; /* default port to listen to to wait for the tracer */
int T_dont_fork = 0; /* default is to fork, see 'T_init' to understand */
#endif
void set_default_frame_parms(LTE_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]) {
int CC_id;
@@ -648,7 +631,7 @@ void set_default_frame_parms(LTE_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]) {
}
void init_openair0(void) {
void init_openair0(LTE_DL_FRAME_PARMS *frame_parms,int rxgain) {
int card;
int i;
@@ -658,8 +641,8 @@ void init_openair0(void) {
openair0_cfg[card].mmapped_dma=mmapped_dma;
openair0_cfg[card].configFilename = NULL;
if(frame_parms[0]->N_RB_DL == 100) {
if (frame_parms[0]->threequarter_fs) {
if(frame_parms->N_RB_DL == 100) {
if (frame_parms->threequarter_fs) {
openair0_cfg[card].sample_rate=23.04e6;
openair0_cfg[card].samples_per_frame = 230400;
openair0_cfg[card].tx_bw = 10e6;
@@ -670,17 +653,17 @@ void init_openair0(void) {
openair0_cfg[card].tx_bw = 10e6;
openair0_cfg[card].rx_bw = 10e6;
}
} else if(frame_parms[0]->N_RB_DL == 50) {
} else if(frame_parms->N_RB_DL == 50) {
openair0_cfg[card].sample_rate=15.36e6;
openair0_cfg[card].samples_per_frame = 153600;
openair0_cfg[card].tx_bw = 5e6;
openair0_cfg[card].rx_bw = 5e6;
} else if (frame_parms[0]->N_RB_DL == 25) {
} else if (frame_parms->N_RB_DL == 25) {
openair0_cfg[card].sample_rate=7.68e6;
openair0_cfg[card].samples_per_frame = 76800;
openair0_cfg[card].tx_bw = 2.5e6;
openair0_cfg[card].rx_bw = 2.5e6;
} else if (frame_parms[0]->N_RB_DL == 6) {
} else if (frame_parms->N_RB_DL == 6) {
openair0_cfg[card].sample_rate=1.92e6;
openair0_cfg[card].samples_per_frame = 19200;
openair0_cfg[card].tx_bw = 1.5e6;
@@ -690,23 +673,20 @@ void init_openair0(void) {
if (frame_parms[0]->frame_type==TDD)
if (frame_parms->frame_type==TDD)
openair0_cfg[card].duplex_mode = duplex_mode_TDD;
else //FDD
openair0_cfg[card].duplex_mode = duplex_mode_FDD;
printf("HW: Configuring card %d, nb_antennas_tx/rx %d/%d\n",card,
PHY_vars_UE_g[0][0]->frame_parms.nb_antennas_tx,
PHY_vars_UE_g[0][0]->frame_parms.nb_antennas_rx);
openair0_cfg[card].Mod_id = 0;
openair0_cfg[card].num_rb_dl=frame_parms[0]->N_RB_DL;
openair0_cfg[card].num_rb_dl=frame_parms->N_RB_DL;
openair0_cfg[card].clock_source = clock_source;
openair0_cfg[card].tx_num_channels=min(2,PHY_vars_UE_g[0][0]->frame_parms.nb_antennas_tx);
openair0_cfg[card].rx_num_channels=min(2,PHY_vars_UE_g[0][0]->frame_parms.nb_antennas_rx);
openair0_cfg[card].tx_num_channels=min(2,frame_parms->nb_antennas_tx);
openair0_cfg[card].rx_num_channels=min(2,frame_parms->nb_antennas_rx);
for (i=0; i<4; i++) {
@@ -722,7 +702,7 @@ void init_openair0(void) {
openair0_cfg[card].autocal[i] = 1;
openair0_cfg[card].tx_gain[i] = tx_gain[0][i];
openair0_cfg[card].rx_gain[i] = PHY_vars_UE_g[0][0]->rx_total_gain_dB - rx_gain_off;
openair0_cfg[card].rx_gain[i] = rxgain - rx_gain_off;
openair0_cfg[card].configFilename = rf_config_file;
@@ -782,14 +762,12 @@ int restart_L1L2(module_id_t enb_id)
int main( int argc, char **argv )
{
int i;
#if defined (XFORMS)
void *status;
#endif
int CC_id;
uint8_t abstraction_flag=0;
uint8_t beta_ACK=0,beta_RI=0,beta_CQI=2;
// Default value for the number of UEs. It will hold,
// if not changed from the command line option --num-ues
@@ -804,17 +782,11 @@ int main( int argc, char **argv )
exit_fun("[SOFTMODEM] Error, configuration module init failed\n");
}
#ifdef DEBUG_CONSOLE
setvbuf(stdout, NULL, _IONBF, 0);
setvbuf(stderr, NULL, _IONBF, 0);
#endif
PHY_VARS_UE *UE[MAX_NUM_CCs];
mode = normal_txrx;
memset(&openair0_cfg[0],0,sizeof(openair0_config_t)*MAX_CARDS);
memset(tx_max_power,0,sizeof(int)*MAX_NUM_CCs);
set_latency_target();
@@ -822,11 +794,19 @@ int main( int argc, char **argv )
printf("Reading in command-line options\n");
for (int i=0;i<MAX_NUM_CCs;i++) tx_max_power[i]=23;
get_options ();
printf("Running with %d UE instances\n",NB_UE_INST);
if (NB_UE_INST > 1 && simL1flag != 1) {
printf("Running with more than 1 UE instance and simL1 is not active, this will result in undefined behaviour for now, exiting.\n");
abort();
}
printf("NFAPI_MODE value: %d \n", nfapi_mode);
// Panos: Not sure if the following is needed here
// Not sure if the following is needed here
/*if (CONFIG_ISFLAGSET(CONFIG_ABORT)) {
if (UE_flag == 0) {
fprintf(stderr,"Getting configuration failed\n");
@@ -840,7 +820,7 @@ int main( int argc, char **argv )
#if T_TRACER
T_init(T_port, 1-T_nowait, T_dont_fork);
T_Config_Init();
#endif
@@ -857,26 +837,25 @@ int main( int argc, char **argv )
set_comp_log(OTG, LOG_INFO, LOG_HIGH, 1);
set_comp_log(RRC, LOG_INFO, LOG_HIGH, 1);
#if defined(ENABLE_ITTI)
set_comp_log(EMU, LOG_INFO, LOG_MED, 1);
set_comp_log(SIM, LOG_INFO, LOG_MED, 1);
# if defined(ENABLE_USE_MME)
set_comp_log(NAS, LOG_INFO, LOG_HIGH, 1);
# endif
#endif
if (ouput_vcd) {
VCD_SIGNAL_DUMPER_INIT("/tmp/openair_dump_UE.vcd");
}
cpuf=get_cpu_freq_GHz();
pthread_cond_init(&sync_cond,NULL);
pthread_mutex_init(&sync_mutex, NULL);
#if defined(ENABLE_ITTI)
log_set_instance_type (LOG_INSTANCE_UE);
printf("ITTI init\n");
itti_init(TASK_MAX, THREAD_MAX, MESSAGES_ID_MAX, tasks_info, messages_info, messages_definition_xml, itti_dump_file);
itti_init(TASK_MAX, THREAD_MAX, MESSAGES_ID_MAX, tasks_info, messages_info);
// initialize mscgen log after ITTI
MSC_INIT(MSC_E_UTRAN, THREAD_MAX+TASK_MAX);
@@ -903,7 +882,7 @@ int main( int argc, char **argv )
#endif
//TTN for D2D
#ifdef Rel14
#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0))
printf ("RRC control socket\n");
rrc_control_socket_init();
printf ("PDCP PC5S socket\n");
@@ -934,33 +913,6 @@ int main( int argc, char **argv )
printf("Before CC \n");
// Panos: From old version
/*if (UE_flag==1) {
PHY_vars_UE_g = malloc(sizeof(PHY_VARS_UE**)*NB_UE_INST);
for (int i=0; i<NB_UE_INST; i++) {
for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
PHY_vars_UE_g[i] = malloc(sizeof(PHY_VARS_UE*)*MAX_NUM_CCs);
PHY_vars_UE_g[i][CC_id] = init_ue_vars(frame_parms[CC_id], i,abstraction_flag);
UE[CC_id] = PHY_vars_UE_g[i][CC_id];
printf("PHY_vars_UE_g[inst][%d] = %p\n",CC_id,UE[CC_id]);
if (phy_test==1)
UE[CC_id]->mac_enabled = 0;
else
UE[CC_id]->mac_enabled = 1;
}
}
}*/
//NB_UE_INST=1;
NB_INST=1;
if(nfapi_mode == 3){
PHY_vars_UE_g = malloc(sizeof(PHY_VARS_UE**)*NB_UE_INST);
@@ -969,80 +921,57 @@ int main( int argc, char **argv )
PHY_vars_UE_g[i] = malloc(sizeof(PHY_VARS_UE*)*MAX_NUM_CCs);
PHY_vars_UE_g[i][CC_id] = init_ue_vars(frame_parms[CC_id], i,abstraction_flag);
UE[CC_id] = PHY_vars_UE_g[i][CC_id];
printf("PHY_vars_UE_g[inst][%d] = %p\n",CC_id,UE[CC_id]);
if (phy_test==1)
UE[CC_id]->mac_enabled = 0;
PHY_vars_UE_g[i][CC_id]->mac_enabled = 0;
else
UE[CC_id]->mac_enabled = 1;
PHY_vars_UE_g[i][CC_id]->mac_enabled = 1;
}
}
}
else{
else init_openair0(frame_parms[0],(int)rx_gain[0][0]);
for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
//NB_UE_INST=1;
NB_INST=1;
PHY_vars_UE_g = malloc(sizeof(PHY_VARS_UE**));
PHY_vars_UE_g[0] = malloc(sizeof(PHY_VARS_UE*)*MAX_NUM_CCs);
PHY_vars_UE_g[0][CC_id] = init_ue_vars(frame_parms[CC_id], 0,abstraction_flag);
UE[CC_id] = PHY_vars_UE_g[0][CC_id];
printf("PHY_vars_UE_g[0][%d] = %p\n",CC_id,UE[CC_id]);
if (simL1flag==1) {
AssertFatal(NULL!=load_configmodule(argc,argv),
"[SOFTMODEM] Error, configuration module init failed\n");
if (phy_test==1)
UE[CC_id]->mac_enabled = 0;
else
UE[CC_id]->mac_enabled = 1;
RCConfig_sim();
}
if (UE[CC_id]->mac_enabled == 0) { //set default UL parameters for testing mode
for (i=0; i<NUMBER_OF_CONNECTED_eNB_MAX; i++) {
UE[CC_id]->pusch_config_dedicated[i].betaOffset_ACK_Index = beta_ACK;
UE[CC_id]->pusch_config_dedicated[i].betaOffset_RI_Index = beta_RI;
UE[CC_id]->pusch_config_dedicated[i].betaOffset_CQI_Index = beta_CQI;
UE[CC_id]->scheduling_request_config[i].sr_PUCCH_ResourceIndex = 0;
UE[CC_id]->scheduling_request_config[i].sr_ConfigIndex = 7+(0%3);
UE[CC_id]->scheduling_request_config[i].dsr_TransMax = sr_n4;
}
}
// start the main UE threads
int eMBMS_active = 0;
UE[CC_id]->UE_scan = UE_scan;
UE[CC_id]->UE_scan_carrier = UE_scan_carrier;
UE[CC_id]->mode = mode;
printf("UE[%d]->mode = %d\n",CC_id,mode);
if (UE[CC_id]->mac_enabled == 1) {
UE[CC_id]->pdcch_vars[0][0]->crnti = 0x1234;
UE[CC_id]->pdcch_vars[1][0]->crnti = 0x1234;
}else {
UE[CC_id]->pdcch_vars[0][0]->crnti = 0x1235;
UE[CC_id]->pdcch_vars[1][0]->crnti = 0x1235;
}
UE[CC_id]->rx_total_gain_dB = (int)rx_gain[CC_id][0] + rx_gain_off;
UE[CC_id]->tx_power_max_dBm = tx_max_power[CC_id];
if (frame_parms[CC_id]->frame_type==FDD) {
UE[CC_id]->N_TA_offset = 0;
}
else {
if (frame_parms[CC_id]->N_RB_DL == 100)
UE[CC_id]->N_TA_offset = 624;
else if (frame_parms[CC_id]->N_RB_DL == 50)
UE[CC_id]->N_TA_offset = 624/2;
else if (frame_parms[CC_id]->N_RB_DL == 25)
UE[CC_id]->N_TA_offset = 624/4;
}
init_openair0();
if (nfapi_mode==3) // UE-STUB-PNF
{
config_sync_var=0;
wait_nfapi_init("main?");
//Panos: Temporarily we will be using single set of threads for multiple UEs.
//init_UE_stub(1,eMBMS_active,uecap_xer_in,emul_iface);
init_UE_stub_single_thread(NB_UE_INST,eMBMS_active,uecap_xer_in,emul_iface);
}
else {
init_UE(NB_UE_INST,eMBMS_active,uecap_xer_in,0,phy_test,UE_scan,UE_scan_carrier,mode,(int)rx_gain[0][0],tx_max_power[0],
frame_parms[0]);
}
printf("Runtime table\n");
fill_modeled_runtime_table(runtime_phy_rx,runtime_phy_tx);
if (phy_test==0) {
printf("Filling UE band info\n");
fill_ue_band_info();
dl_phy_sync_success (0, 0, 0, 1);
}
if (nfapi_mode!=3){
number_of_cards = 1;
for(CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
PHY_vars_UE_g[0][CC_id]->rf_map.card=0;
PHY_vars_UE_g[0][CC_id]->rf_map.chain=CC_id+chain_offset;
}
}
cpuf=get_cpu_freq_GHz();
}
@@ -1092,21 +1021,76 @@ int main( int argc, char **argv )
printf("cannot create ITTI tasks\n");
exit(-1); // need a softer mode
}
if(nfapi_mode==3){ //Panos: Here we should add another nfapi_mode for the case of Supervised LTE-D2D
if(nfapi_mode==3){ // Here we should add another nfapi_mode for the case of Supervised LTE-D2D
UE_config_stub_pnf();
}
printf("ITTI tasks created\n");
#endif
// init UE_PF_PO and mutex lock
pthread_mutex_init(&ue_pf_po_mutex, NULL);
memset (&UE_PF_PO[0][0], 0, sizeof(UE_PF_PO_t)*NUMBER_OF_UE_MAX*MAX_NUM_CCs);
mlockall(MCL_CURRENT | MCL_FUTURE);
pthread_cond_init(&sync_cond,NULL);
pthread_mutex_init(&sync_mutex, NULL);
rt_sleep_ns(10*100000000ULL);
const char *nfapi_mode_str = "<UNKNOWN>";
switch(nfapi_mode)
{
case 0:
nfapi_mode_str = "MONOLITHIC";
break;
case 1:
nfapi_mode_str = "PNF";
break;
case 2:
nfapi_mode_str = "VNF";
break;
case 3:
nfapi_mode_str = "UE_STUB_PNF";
break;
case 4:
nfapi_mode_str = "UE_STUB_OFFNET";
break;
default:
nfapi_mode_str = "<UNKNOWN NFAPI MODE>";
break;
}
printf("NFAPI MODE:%s\n", nfapi_mode_str);
// connect the TX/RX buffers
/*
if(nfapi_mode!=3) {
if (setup_ue_buffers(PHY_vars_UE_g[0],&openair0_cfg[0])!=0) {
printf("Error setting up eNB buffer\n");
exit(-1);
}
}
*/
if (input_fd) {
printf("Reading in from file to antenna buffer %d\n",0);
if (fread(PHY_vars_UE_g[0][0]->common_vars.rxdata[0],
sizeof(int32_t),
frame_parms[0]->samples_per_tti*10,
input_fd) != frame_parms[0]->samples_per_tti*10)
printf("error reading from file\n");
}
//p_exmimo_config->framing.tdd_config = TXRXSWITCH_TESTRX;
if (simL1flag==1) {
init_ocm((double)snr_dB,0);
PHY_vars_UE_g[0][0]->no_timing_correction = 1;
}
#ifdef XFORMS
int UE_id;
@@ -1142,110 +1126,25 @@ int main( int argc, char **argv )
#endif
rt_sleep_ns(10*100000000ULL);
printf("Sending sync to all threads (%p,%p,%p)\n",&sync_var,&sync_cond,&sync_mutex);
const char *nfapi_mode_str = "<UNKNOWN>";
switch(nfapi_mode)
{
case 0:
nfapi_mode_str = "MONOLITHIC";
break;
case 1:
nfapi_mode_str = "PNF";
break;
case 2:
nfapi_mode_str = "VNF";
break;
case 3:
nfapi_mode_str = "UE_STUB_PNF";
break;
case 4:
nfapi_mode_str = "UE_STUB_OFFNET";
break;
default:
nfapi_mode_str = "<UNKNOWN NFAPI MODE>";
break;
}
printf("NFAPI MODE:%s\n", nfapi_mode_str);
// start the main threads
int eMBMS_active = 0;
if (nfapi_mode==3) // UE-STUB-PNF
{
config_sync_var=0;
wait_nfapi_init("main?");
//Panos: Temporarily we will be using single set of threads for multiple UEs.
//init_UE_stub(1,eMBMS_active,uecap_xer_in,emul_iface);
init_UE_stub_single_thread(NB_UE_INST,eMBMS_active,uecap_xer_in,emul_iface);
}
else {
init_UE(1,eMBMS_active,uecap_xer_in,0);
}
if (phy_test==0) {
printf("Filling UE band info\n");
fill_ue_band_info();
dl_phy_sync_success (0, 0, 0, 1);
}
if (nfapi_mode!=3){
number_of_cards = 1;
for(CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
PHY_vars_UE_g[0][CC_id]->rf_map.card=0;
PHY_vars_UE_g[0][CC_id]->rf_map.chain=CC_id+chain_offset;
}
}
// connect the TX/RX buffers
for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
#ifdef OAI_USRP
UE[CC_id]->hw_timing_advance = timing_advance;
#else
UE[CC_id]->hw_timing_advance = 160;
#endif
}
if(nfapi_mode!=3) {
if (setup_ue_buffers(UE,&openair0_cfg[0])!=0) {
printf("Error setting up eNB buffer\n");
exit(-1);
}
}
if (input_fd) {
printf("Reading in from file to antenna buffer %d\n",0);
if (fread(UE[0]->common_vars.rxdata[0],
sizeof(int32_t),
frame_parms[0]->samples_per_tti*10,
input_fd) != frame_parms[0]->samples_per_tti*10)
printf("error reading from file\n");
}
//p_exmimo_config->framing.tdd_config = TXRXSWITCH_TESTRX;
printf("Sending sync to all threads\n");
pthread_mutex_lock(&sync_mutex);
sync_var=0;
pthread_cond_broadcast(&sync_cond);
pthread_mutex_unlock(&sync_mutex);
printf("sync sent\n");
/*
printf("About to call end_configmodule() from %s() %s:%d\n", __FUNCTION__, __FILE__, __LINE__);
end_configmodule();
printf("Called end_configmodule() from %s() %s:%d\n", __FUNCTION__, __FILE__, __LINE__);
*/
// wait for end of program
printf("TYPE <CTRL-C> TO TERMINATE\n");
//getchar();
#if defined(ENABLE_ITTI)
printf("Entering ITTI signals handler\n");
itti_wait_tasks_end();
@@ -1254,9 +1153,9 @@ int main( int argc, char **argv )
printf("oai_exit=%d\n",oai_exit);
#else
while (oai_exit==0)
rt_sleep_ns(100000000ULL);
printf("Terminating application - oai_exit=%d\n",oai_exit);
while (oai_exit==0)
rt_sleep_ns(100000000ULL);
printf("Terminating application - oai_exit=%d\n",oai_exit);
#endif
@@ -1279,15 +1178,12 @@ int main( int argc, char **argv )
pthread_cond_destroy(&sync_cond);
pthread_mutex_destroy(&sync_mutex);
pthread_mutex_destroy(&ue_pf_po_mutex);
// pthread_mutex_destroy(&ue_pf_po_mutex);
// *** Handle per CC_id openair0
if (PHY_vars_UE_g[0][0]->rfdevice.trx_end_func)
PHY_vars_UE_g[0][0]->rfdevice.trx_end_func(&PHY_vars_UE_g[0][0]->rfdevice);
if (ouput_vcd)
VCD_SIGNAL_DUMPER_CLOSE();
if (opt_enabled == 1)
terminate_opt();
+13 -26
View File
@@ -1,23 +1,23 @@
[*]
[*] GTKWave Analyzer v3.3.58 (w)1999-2014 BSI
[*] Sun Jan 15 07:26:50 2017
[*] Tue Jun 5 09:36:17 2018
[*]
[dumpfile] "/tmp/openair_dump_eNB.vcd"
[dumpfile_mtime] "Sun Jan 15 07:04:19 2017"
[dumpfile_size] 18140627
[savefile] "/home/uprru1/oai/openairinterface5g/targets/RT/USER/rru_if4p5_usrp.gtkw"
[timestart] 29977510000
[dumpfile] "/tmp/openair_dump_UE.vcd"
[dumpfile_mtime] "Tue Jun 5 09:22:52 2018"
[dumpfile_size] 23057775
[savefile] "/home/knopp/oai/openairinterface5g/targets/RT/USER/rru_if4p5_usrp.gtkw"
[timestart] 25050480000
[size] 1301 716
[pos] 309 0
*-21.793451 29983948856 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
[sst_width] 284
[sst_width] 312
[signals_width] 262
[sst_expanded] 1
[sst_vpaned_height] 294
@28
functions.trx_read
functions.trx_write
@25
@24
variables.trx_write_flags[63:0]
@28
functions.trx_write_if
@@ -27,23 +27,10 @@ functions.recv_if4
@24
variables.trx_ts[63:0]
variables.trx_tst[63:0]
@28
functions.eNB_thread_rxtx0
@24
variables.frame_number_RX0_eNB[63:0]
variables.subframe_number_RX0_eNB[63:0]
variables.frame_number_TX0_eNB[63:0]
variables.subframe_number_TX0_eNB[63:0]
@28
functions.eNB_thread_rxtx1
@24
variables.frame_number_RX1_eNB[63:0]
variables.subframe_number_RX1_eNB[63:0]
variables.frame_number_TX1_eNB[63:0]
variables.subframe_number_TX1_eNB[63:0]
@28
functions.phy_eNB_ofdm_mod_l
functions.phy_eNB_slot_fep
functions.phy_enb_prach_rx
variables.frame_number_RX0_RU[63:0]
variables.subframe_number_RX0_RU[63:0]
variables.frame_number_TX0_RU[63:0]
@25
variables.subframe_number_TX0_RU[63:0]
[pattern_trace] 1
[pattern_trace] 0