Commit 203ff5a7 authored by Wang Tsu-Han's avatar Wang Tsu-Han

seperating pdsch to different thread

parent 80c40c36
......@@ -722,6 +722,7 @@ void init_gNB_proc(int inst) {
PHY_VARS_gNB *gNB;
gNB_L1_proc_t *proc;
gNB_L1_rxtx_proc_t *L1_proc,*L1_proc_tx;
LOG_I(PHY,"%s(inst:%d) RC.nb_nr_CC[inst]:%d \n",__FUNCTION__,inst,RC.nb_nr_CC[inst]);
for (CC_id=0; CC_id<RC.nb_nr_CC[inst]; CC_id++) {
......@@ -743,7 +744,7 @@ void init_gNB_proc(int inst) {
proc->first_tx =1;
proc->RU_mask =0;
proc->RU_mask_tx = (1<<gNB->num_RU)-1;
proc->RU_mask_prach =0;
proc->RU_mask_prach =0;
pthread_mutex_init( &gNB->UL_INFO_mutex, NULL);
pthread_mutex_init( &L1_proc->mutex, NULL);
pthread_mutex_init( &L1_proc_tx->mutex, NULL);
......@@ -759,8 +760,9 @@ void init_gNB_proc(int inst) {
LOG_I(PHY,"gNB->single_thread_flag:%d\n", gNB->single_thread_flag);
if (get_thread_parallel_conf() == PARALLEL_RU_L1_SPLIT || get_thread_parallel_conf() == PARALLEL_RU_L1_TRX_SPLIT) {
threadCreate( &L1_proc->pthread, gNB_L1_thread, gNB, "L1_proc", -1, OAI_PRIORITY_RT );
threadCreate( &L1_proc_tx->pthread, gNB_L1_thread_tx, gNB,"L1_proc_tx", -1, OAI_PRIORITY_RT);
threadCreate( &L1_proc->pthread, gNB_L1_thread, (void*)gNB, "L1_proc", -1, OAI_PRIORITY_RT );
threadCreate( &L1_proc_tx->pthread, gNB_L1_thread_tx, (void*)gNB, "L1_proc_tx", -1, OAI_PRIORITY_RT);
nr_init_pdsch_thread(gNB);
}
if(opp_enabled == 1) threadCreate(&proc->L1_stats_thread, process_stats_thread,(void *)gNB, "time_meas", -1, OAI_PRIORITY_RT_LOW);
......@@ -810,6 +812,7 @@ void kill_gNB_proc(int inst) {
L1_proc_tx->instance_cnt = 0;
pthread_cond_signal(&L1_proc_tx->cond);
pthread_mutex_unlock(&L1_proc_tx->mutex);
nr_kill_pdsch_thread(gNB);
}
proc->instance_cnt_prach = 0;
......
......@@ -1704,7 +1704,7 @@ void init_RU_proc(RU_t *ru) {
threadCreate( &proc->pthread_FH, ru_thread, (void *)ru, "thread_FH", -1, OAI_PRIORITY_RT_MAX );
if (get_thread_parallel_conf() == PARALLEL_RU_L1_SPLIT || get_thread_parallel_conf() == PARALLEL_RU_L1_TRX_SPLIT)
threadCreate( &proc->pthread_FH1, ru_thread_tx, (void *)ru, "thread_FH1", -1, OAI_PRIORITY_RT );
threadCreate( &proc->pthread_FH1, ru_thread_tx, (void *)ru, "thread_FH_TX", -1, OAI_PRIORITY_RT );
if(emulate_rf)
threadCreate( &proc->pthread_emulateRF, emulatedRF_thread, (void *)proc, "emulateRF", -1, OAI_PRIORITY_RT );
......
......@@ -125,6 +125,22 @@ typedef struct {
uint32_t F;
} NR_DL_gNB_HARQ_t;
typedef struct NR_gNB_DLSCH_thread_t_s{
/// \internal This variable is protected by \ref mutex_feptx_prec
int instance_cnt_dlsch;
/// pthread struct for RU TX FEP PREC worker thread
pthread_t pthread_dlsch;
/// pthread attributes for worker feptx prec thread
pthread_attr_t attr_dlsch;
/// condition varible for RU TX FEP PREC thread
pthread_cond_t cond_dlsch;
/// mutex for fep PREC TX worker thread
pthread_mutex_t mutex_dlsch;
/// current frame
int frame;
/// current slot
int slot;
}NR_gNB_DLSCH_thread_t;
typedef struct {
......@@ -647,6 +663,7 @@ typedef struct PHY_VARS_gNB_s {
// LTE_eNB_ULSCH_t *ulsch[NUMBER_OF_UE_MAX+1]; // Nusers + number of RA
NR_gNB_DLSCH_t *dlsch_SI,*dlsch_ra,*dlsch_p;
NR_gNB_DLSCH_t *dlsch_PCH;
NR_gNB_DLSCH_thread_t dlsch_thread; //dlsch thread structure;
/*
LTE_eNB_UE_stats UE_stats[NUMBER_OF_UE_MAX];
LTE_eNB_UE_stats *UE_stats_ptr[NUMBER_OF_UE_MAX];
......
......@@ -323,6 +323,7 @@ void nr_init_feptx_thread(RU_t *ru) {
RU_proc_t *proc = &ru->proc;
RU_feptx_t *feptx = proc->feptx;
int i = 0;
char name[40];
for(i=0; i<16; i++){
feptx[i].instance_cnt_feptx = -1;
......@@ -330,7 +331,8 @@ void nr_init_feptx_thread(RU_t *ru) {
pthread_mutex_init( &feptx[i].mutex_feptx, NULL);
pthread_cond_init( &feptx[i].cond_feptx, NULL);
threadCreate(&feptx[i].pthread_feptx, nr_feptx_thread, (void*)&feptx[i], "feptx", -1, OAI_PRIORITY_RT);
snprintf( name, sizeof(name)/sizeof(name[0]), "feptx_%d", i );
threadCreate(&feptx[i].pthread_feptx, nr_feptx_thread, (void*)&feptx[i], name, -1, OAI_PRIORITY_RT);
LOG_I(PHY,"init feptx thread %d\n", i);
}
......
......@@ -39,6 +39,8 @@
#include "PHY/MODULATION/nr_modulation.h"
#include "T.h"
#include <common/utils/system.h>
#include "assertions.h"
#include "msc.h"
......@@ -48,6 +50,7 @@
#include "intertask_interface.h"
#endif
extern int oai_exit;
extern uint8_t nfapi_mode;
/*
int return_ssb_type(nfapi_config_request_t *cfg)
......@@ -154,13 +157,16 @@ void phy_procedures_gNB_TX(PHY_VARS_gNB *gNB,
uint8_t num_dci=0,num_pdsch_rnti;
NR_DL_FRAME_PARMS *fp=&gNB->frame_parms;
nfapi_nr_config_request_t *cfg = &gNB->gNB_config;
NR_gNB_DLSCH_thread_t *dlsch_thread = &gNB->dlsch_thread;
int offset = gNB->CC_id;
uint8_t ssb_frame_periodicity; // every how many frames SSB are generated
int txdataF_offset = (slot%2)*fp->samples_per_slot_wCP;
int ret = 0;
num_dci = gNB->pdcch_vars.num_dci;
num_pdsch_rnti = gNB->pdcch_vars.num_pdsch_rnti;
if (cfg->sch_config.ssb_periodicity.value < 20)
ssb_frame_periodicity = 1;
else
......@@ -177,6 +183,19 @@ void phy_procedures_gNB_TX(PHY_VARS_gNB *gNB,
memset(&gNB->common_vars.txdataF[p][txdataF_offset],0,fp->samples_per_slot_wCP*sizeof(int32_t));
}
if (num_dci && (nfapi_mode == 0 || nfapi_mode == 1) && num_pdsch_rnti) {
LOG_D(PHY, "PDSCH generation started (%d)\n", num_pdsch_rnti);
ret = pthread_mutex_lock(&dlsch_thread->mutex_dlsch);
AssertFatal(ret==0,"mutex_lock return %d\n",ret);
dlsch_thread->instance_cnt_dlsch = 0;
dlsch_thread->frame = frame;
dlsch_thread->slot = slot;
ret = pthread_cond_signal(&dlsch_thread->cond_dlsch);
AssertFatal(ret==0,"ERROR pthread_cond_signal for nr_pdsch_thread\n");
ret = pthread_mutex_unlock(&dlsch_thread->mutex_dlsch);
AssertFatal(ret==0,"mutex_unlock return %d\n",ret);
}
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_ENB_COMMON_TX,1);
if (nfapi_mode == 0 || nfapi_mode == 1) {
if (!(frame%ssb_frame_periodicity)) // generate SSB only for given frames according to SSB periodicity
......@@ -195,8 +214,8 @@ void phy_procedures_gNB_TX(PHY_VARS_gNB *gNB,
gNB->nr_gold_pdcch_dmrs[slot],
&gNB->common_vars.txdataF[0][txdataF_offset], // hardcoded to beam 0
AMP, *fp, *cfg);
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_ENB_PDCCH_TX,0);
if (num_pdsch_rnti) {
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_ENB_PDCCH_TX,0);
/*if (num_pdsch_rnti) {
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_GENERATE_DLSCH,1);
LOG_D(PHY, "PDSCH generation started (%d)\n", num_pdsch_rnti);
nr_generate_pdsch(gNB->dlsch[0][0],
......@@ -209,13 +228,89 @@ void phy_procedures_gNB_TX(PHY_VARS_gNB *gNB,
&gNB->dlsch_modulation_stats);
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_GENERATE_DLSCH,0);
}
}*/
}
}
// wait pdsch thread to finish
if (wait_on_busy_condition(&dlsch_thread->mutex_dlsch,&dlsch_thread->cond_dlsch,&dlsch_thread->instance_cnt_dlsch,"NR pdsch thread")<0) return;
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_ENB_TX+offset,0);
}
static void *nr_pdsch_thread(void *param) {
PHY_VARS_gNB *gNB = (PHY_VARS_gNB *)param;
NR_gNB_DLSCH_thread_t *dlsch;
NR_DL_FRAME_PARMS *fp;
nfapi_nr_config_request_t *cfg;
int frame, slot;
int ret = 0;
while(!oai_exit)
{
dlsch = &gNB->dlsch_thread;
fp = &gNB->frame_parms;
cfg = &gNB->gNB_config;
frame = dlsch->frame;
slot = dlsch->slot;
if (wait_on_condition(&dlsch->mutex_dlsch,&dlsch->cond_dlsch,&dlsch->instance_cnt_dlsch,"NR pdsch thread")<0) break;
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_GENERATE_DLSCH,1);
nr_generate_pdsch(gNB->dlsch[0][0],
&gNB->pdcch_vars.dci_alloc[0],
gNB->nr_gold_pdsch_dmrs[slot],
gNB->common_vars.txdataF,
AMP, frame, slot, fp, cfg,
&gNB->dlsch_encoding_stats,
&gNB->dlsch_scrambling_stats,
&gNB->dlsch_modulation_stats);
ret = pthread_mutex_lock(&dlsch->mutex_dlsch);
AssertFatal(ret==0,"mutex_lock return %d\n",ret);
dlsch->instance_cnt_dlsch = -1;
ret = pthread_cond_broadcast(&dlsch->cond_dlsch);
AssertFatal(ret==0,"ERROR pthread_cond_signal for nr_pdsch_thread\n");
ret = pthread_mutex_unlock(&dlsch->mutex_dlsch);
AssertFatal(ret==0,"mutex_unlock return %d\n",ret);
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_GENERATE_DLSCH,0);
}
return (NULL);
}
void nr_init_pdsch_thread(PHY_VARS_gNB *gNB) {
printf("init pdsch thread start\n");
NR_gNB_DLSCH_thread_t *dlsch = &gNB->dlsch_thread;
dlsch->instance_cnt_dlsch = -1;
pthread_mutex_init( &dlsch->mutex_dlsch, NULL);
pthread_cond_init( &dlsch->cond_dlsch, NULL);
printf("create pdsch thread start\n");
threadCreate(&dlsch->pthread_dlsch, nr_pdsch_thread, (void*)gNB, "pdsch", -1, OAI_PRIORITY_RT);
LOG_I(PHY,"init pdsch thread\n");
}
void nr_kill_pdsch_thread(PHY_VARS_gNB *gNB) {
NR_gNB_DLSCH_thread_t *dlsch = &gNB->dlsch_thread;
pthread_mutex_lock(&dlsch->mutex_dlsch);
dlsch->instance_cnt_dlsch = 0;
pthread_cond_signal(&dlsch->cond_dlsch);
pthread_mutex_unlock(&dlsch->mutex_dlsch);
pthread_mutex_destroy( &dlsch->mutex_dlsch);
pthread_cond_destroy( &dlsch->cond_dlsch);
LOG_I(PHY,"Destroying dlsch mutex/cond\n");
}
void nr_ulsch_procedures(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, int UE_id, uint8_t harq_pid)
{
......
......@@ -53,6 +53,8 @@ void nr_fep_full(RU_t *ru, int slot);
void nr_fep_full_2thread(RU_t *ru, int slot);
void feptx_prec(RU_t *ru,int frame_tx,int tti_tx);
int nr_phy_init_RU(RU_t *ru);
void nr_init_pdsch_thread(PHY_VARS_gNB *gNB);
void nr_kill_pdsch_thread(PHY_VARS_gNB *gNB);
void nr_configure_css_dci_initial(nfapi_nr_dl_config_pdcch_parameters_rel15_t* pdcch_params,
nr_scs_e scs_common,
......
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