Commit d58d29f0 authored by Xu Bo's avatar Xu Bo

fix TBS calculation error and add rf_tx thread for send TX data to device

parent 17ab8472
...@@ -435,6 +435,12 @@ typedef struct RU_proc_t_s { ...@@ -435,6 +435,12 @@ typedef struct RU_proc_t_s {
int subframe_phy_tx; int subframe_phy_tx;
/// timestamp to send to "slave rru" /// timestamp to send to "slave rru"
openair0_timestamp timestamp_phy_tx; openair0_timestamp timestamp_phy_tx;
/// pthread structure for RF TX thread
pthread_t pthread_rf_tx;
pthread_mutex_t mutex_rf_tx;
pthread_cond_t cond_rf_tx;
/// \internal This variable is protected by \ref mutex_rf_tx.
int instance_cnt_rf_tx;
#endif #endif
#if defined(UE_EXPANSION) || defined(UE_EXPANSION_SIM2) #if defined(UE_EXPANSION) || defined(UE_EXPANSION_SIM2)
pthread_t pthread_pre_scd; pthread_t pthread_pre_scd;
......
...@@ -552,7 +552,7 @@ inline uint16_t search_rbs_required(uint16_t mcs, uint16_t TBS,uint16_t NB_RB, u ...@@ -552,7 +552,7 @@ inline uint16_t search_rbs_required(uint16_t mcs, uint16_t TBS,uint16_t NB_RB, u
uint16_t nb_rb,i_TBS,tmp_TBS; uint16_t nb_rb,i_TBS,tmp_TBS;
i_TBS=get_I_TBS(mcs); i_TBS=get_I_TBS(mcs);
for(nb_rb=step_size;nb_rb<NB_RB;nb_rb+=step_size){ for(nb_rb=step_size;nb_rb<NB_RB;nb_rb+=step_size){
tmp_TBS = TBStable[i_TBS][nb_rb-1]; tmp_TBS = TBStable[i_TBS][nb_rb-1]>>3;
if(TBS<tmp_TBS)return(nb_rb); if(TBS<tmp_TBS)return(nb_rb);
} }
return NB_RB; return NB_RB;
......
...@@ -1784,10 +1784,52 @@ static void* eNB_thread_phy_tx( void* param ) { ...@@ -1784,10 +1784,52 @@ static void* eNB_thread_phy_tx( void* param ) {
ru->proc.subframe_tx = proc->subframe_phy_tx; ru->proc.subframe_tx = proc->subframe_phy_tx;
ru->proc.timestamp_tx = proc->timestamp_phy_tx; ru->proc.timestamp_tx = proc->timestamp_phy_tx;
phy_tx_txdataF_end = 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;
// 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_W(PHY,"rf tx thread busy, skipping\n");
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) // do TX front-end processing if needed (precoding and/or IDFTs)
if (ru->feptx_prec) ru->feptx_prec(ru); if (ru->feptx_prec) ru->feptx_prec(ru);
// do OFDM if needed // do OFDM if needed
if ((ru->fh_north_asynch_in == NULL) && (ru->feptx_ofdm)) ru->feptx_ofdm(ru); if ((ru->fh_north_asynch_in == NULL) && (ru->feptx_ofdm)) ru->feptx_ofdm(ru);
// do outgoing fronthaul (south) if needed // do outgoing fronthaul (south) if needed
...@@ -1795,14 +1837,13 @@ static void* eNB_thread_phy_tx( void* param ) { ...@@ -1795,14 +1837,13 @@ static void* eNB_thread_phy_tx( void* param ) {
if (ru->fh_north_out) ru->fh_north_out(ru); if (ru->fh_north_out) ru->fh_north_out(ru);
} }
if (release_thread(&proc->mutex_phy_tx,&proc->instance_cnt_phy_tx,"eNB_thread_phy_tx") < 0) break; if (release_thread(&proc->mutex_rf_tx,&proc->instance_cnt_rf_tx,"rf_tx") < 0) break;
phy_tx_end = 1;
} }
LOG_I(PHY, "Exiting eNB thread PHY TX\n"); LOG_I(PHY, "Exiting rf TX\n");
eNB_thread_phy_tx_status = 0; rf_tx_status = 0;
return &eNB_thread_phy_tx_status; return &rf_tx_status;
} }
#endif #endif
...@@ -1881,6 +1922,9 @@ void init_RU_proc(RU_t *ru) { ...@@ -1881,6 +1922,9 @@ void init_RU_proc(RU_t *ru) {
proc->instance_cnt_phy_tx = -1; proc->instance_cnt_phy_tx = -1;
pthread_mutex_init( &proc->mutex_phy_tx, NULL); pthread_mutex_init( &proc->mutex_phy_tx, NULL);
pthread_cond_init( &proc->cond_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 #endif
#ifndef DEADLINE_SCHEDULER #ifndef DEADLINE_SCHEDULER
...@@ -1905,6 +1949,7 @@ void init_RU_proc(RU_t *ru) { ...@@ -1905,6 +1949,7 @@ void init_RU_proc(RU_t *ru) {
#ifdef UE_EXPANSION #ifdef UE_EXPANSION
pthread_create( &proc->pthread_phy_tx, NULL, eNB_thread_phy_tx, (void*)ru ); pthread_create( &proc->pthread_phy_tx, NULL, eNB_thread_phy_tx, (void*)ru );
pthread_setname_np( proc->pthread_phy_tx, "phy_tx_thread" ); pthread_setname_np( proc->pthread_phy_tx, "phy_tx_thread" );
pthread_create( &proc->pthread_rf_tx, NULL, rf_tx, (void*)ru );
#endif #endif
if (ru->function == NGFI_RRU_IF4p5) { if (ru->function == NGFI_RRU_IF4p5) {
...@@ -2342,6 +2387,11 @@ void stop_ru(RU_t *ru) { ...@@ -2342,6 +2387,11 @@ void stop_ru(RU_t *ru) {
pthread_join( ru->proc.pthread_phy_tx, (void**)&status ); pthread_join( ru->proc.pthread_phy_tx, (void**)&status );
pthread_mutex_destroy( &ru->proc.mutex_phy_tx ); pthread_mutex_destroy( &ru->proc.mutex_phy_tx );
pthread_cond_destroy( &ru->proc.cond_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 #endif
} }
......
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