Commit 9293f65b authored by Siddharth Rana's avatar Siddharth Rana

Additional changes to RAN/executables directory

parent 0f2a2698
...@@ -111,6 +111,8 @@ extern int transmission_mode; ...@@ -111,6 +111,8 @@ extern int transmission_mode;
extern int oaisim_flag; extern int oaisim_flag;
//uint16_t sf_ahead=4;
extern uint16_t sf_ahead;
#include "executables/thread-common.h" #include "executables/thread-common.h"
//extern PARALLEL_CONF_t get_thread_parallel_conf(void); //extern PARALLEL_CONF_t get_thread_parallel_conf(void);
//extern WORKER_CONF_t get_thread_worker_conf(void); //extern WORKER_CONF_t get_thread_worker_conf(void);
...@@ -255,7 +257,67 @@ static inline int rxtx(PHY_VARS_eNB *eNB, ...@@ -255,7 +257,67 @@ static inline int rxtx(PHY_VARS_eNB *eNB,
eNB->UL_INFO.subframe = proc->subframe_rx; eNB->UL_INFO.subframe = proc->subframe_rx;
eNB->UL_INFO.module_id = eNB->Mod_id; eNB->UL_INFO.module_id = eNB->Mod_id;
eNB->UL_INFO.CC_id = eNB->CC_id; eNB->UL_INFO.CC_id = eNB->CC_id;
eNB->if_inst->UL_indication(&eNB->UL_INFO, (void*)proc);
//#ifdef ENB_SS
if (RC.ss.mode >= SS_SOFTMODEM)
{
MessageDef *message_p = itti_alloc_new_message(TASK_ENB_APP, 0, SS_UPD_TIM_INFO);
if (message_p)
{
SS_UPD_TIM_INFO(message_p).sf = eNB->UL_INFO.subframe;
SS_UPD_TIM_INFO(message_p).sfn = eNB->UL_INFO.frame;
int send_res = itti_send_msg_to_task(TASK_SYS, 0, message_p);
if (send_res < 0)
{
printf("Error in itti_send_msg_to_task");
// LOG_E( PHY, "[SS] Error in L1_Thread itti_send_msg_to_task"); /** TODO: Need separate logging for SS */
}
LOG_D(PHY, "[SS] SS_UPD_TIM_INFO from L1_Thread to SYS task itti_send_msg_to_task sfn %d sf %d",
eNB->UL_INFO.subframe, eNB->UL_INFO.frame); /** TODO: Need separate logging for SS */
}
MessageDef *message_p_vtp = itti_alloc_new_message(TASK_ENB_APP, 0, SS_UPD_TIM_INFO);
if (message_p_vtp && RC.ss.vtp_ready)
{
SS_UPD_TIM_INFO(message_p_vtp).sf = eNB->UL_INFO.subframe;
SS_UPD_TIM_INFO(message_p_vtp).sfn = eNB->UL_INFO.frame;
SS_UPD_TIM_INFO(message_p).physCellId = RC.rrc[eNB->UL_INFO.module_id]->carrier[eNB->UL_INFO.CC_id].physCellId;
int send_res = itti_send_msg_to_task(TASK_VTP, 0, message_p_vtp);
if (send_res < 0)
{
printf("Error in itti_send_msg_to_task");
// LOG_E( PHY, "[SS] Error in L1_Thread itti_send_msg_to_task"); /** TODO: Need separate logging for SS */
}
LOG_D(PHY, "[SS] SS_UPD_TIM_INFO from L1_Thread to VTP task itti_send_msg_to_task sfn %d sf %d",
eNB->UL_INFO.subframe, eNB->UL_INFO.frame); /** TODO: Need separate logging for SS */
}
MessageDef *message_p_vt_timer = itti_alloc_new_message(TASK_ENB_APP, 0, SS_UPD_TIM_INFO);
if (message_p_vt_timer)
{
SS_UPD_TIM_INFO(message_p_vt_timer).sf = eNB->UL_INFO.subframe;
SS_UPD_TIM_INFO(message_p_vt_timer).sfn = eNB->UL_INFO.frame;
int send_res = itti_send_msg_to_task(TASK_VT_TIMER, 0, message_p_vt_timer);
if (send_res < 0)
{
printf("Error in itti_send_msg_to_task");
// LOG_E( PHY, "[SS] Error in L1_Thread itti_send_msg_to_task"); /** TODO: Need separate logging for SS */
}
LOG_D(PHY, "[SS] SS_UPD_TIM_INFO from L1_Thread to TASK_VT_TIMER task itti_send_msg_to_task sfn %d sf %d",
eNB->UL_INFO.subframe, eNB->UL_INFO.frame); /** TODO: Need separate logging for SS */
}
}
int tem_proc_ccid = proc->CC_id;
/* MultiCell: Function modify for Multiple CC */
for (int CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
eNB->UL_INFO.CC_id = CC_id;
proc->CC_id = CC_id;//Temp solution need to be fixed later
eNB->if_inst->UL_indication(&eNB->UL_INFO, proc);
}
proc->CC_id = tem_proc_ccid;
//#endif /** ENB_SS */
AssertFatal((ret= pthread_mutex_unlock(&eNB->UL_INFO_mutex))==0,"error unlocking UL_INFO_mutex, return %d\n",ret); AssertFatal((ret= pthread_mutex_unlock(&eNB->UL_INFO_mutex))==0,"error unlocking UL_INFO_mutex, return %d\n",ret);
/* this conflict resolution may be totally wrong, to be tested */ /* this conflict resolution may be totally wrong, to be tested */
/* CONFLICT RESOLUTION: BEGIN */ /* CONFLICT RESOLUTION: BEGIN */
...@@ -325,6 +387,7 @@ static void *L1_thread_tx(void *param) { ...@@ -325,6 +387,7 @@ static void *L1_thread_tx(void *param) {
//wait_sync("tx_thread"); //wait_sync("tx_thread");
proc->respEncode = eNB->proc.L1_proc.respEncode;
while (!oai_exit) { while (!oai_exit) {
LOG_D(PHY,"Waiting for TX (IC %d)\n",proc->instance_cnt); LOG_D(PHY,"Waiting for TX (IC %d)\n",proc->instance_cnt);
...@@ -386,8 +449,10 @@ static void *L1_thread( void *param ) { ...@@ -386,8 +449,10 @@ static void *L1_thread( void *param ) {
char thread_name[100]; char thread_name[100];
#if 0 /* MultiCell: Not Required for MultiCell case */
cpu_set_t cpuset; cpu_set_t cpuset;
CPU_ZERO(&cpuset); CPU_ZERO(&cpuset);
#endif
// set default return value // set default return value
eNB_thread_rxtx_status = 0; eNB_thread_rxtx_status = 0;
sprintf(thread_name,"RXn_TXnp4_%d\n",&eNB->proc.L1_proc == proc ? 0 : 1); sprintf(thread_name,"RXn_TXnp4_%d\n",&eNB->proc.L1_proc == proc ? 0 : 1);
...@@ -424,9 +489,9 @@ static void *L1_thread( void *param ) { ...@@ -424,9 +489,9 @@ static void *L1_thread( void *param ) {
if (oai_exit) break; if (oai_exit) break;
if (eNB->CC_id==0) { /* MultiCell: Condition modified for MultiCell case */
if (rxtx(eNB,proc,thread_name) < 0) break; /* This thread can only be wakeup for one cell SUBFRAME Ind under VNF as proxy would only send one SUBFRAME Ind for all cells. */
} if (rxtx(eNB,proc,thread_name) < 0) break;
LOG_D(PHY,"L1 RX %d.%d done\n",proc->frame_rx,proc->subframe_rx); LOG_D(PHY,"L1 RX %d.%d done\n",proc->frame_rx,proc->subframe_rx);
...@@ -462,11 +527,11 @@ void eNB_top(PHY_VARS_eNB *eNB, ...@@ -462,11 +527,11 @@ void eNB_top(PHY_VARS_eNB *eNB,
if (!oai_exit) { if (!oai_exit) {
T(T_ENB_MASTER_TICK, T_INT(0), T_INT(ru_proc->frame_rx), T_INT(ru_proc->tti_rx)); T(T_ENB_MASTER_TICK, T_INT(0), T_INT(ru_proc->frame_rx), T_INT(ru_proc->tti_rx));
L1_proc->timestamp_tx = ru_proc->timestamp_rx + (ru->sf_ahead*fp->samples_per_tti); L1_proc->timestamp_tx = ru_proc->timestamp_rx + (sf_ahead*fp->samples_per_tti);
L1_proc->frame_rx = ru_proc->frame_rx; L1_proc->frame_rx = ru_proc->frame_rx;
L1_proc->subframe_rx = ru_proc->tti_rx; L1_proc->subframe_rx = ru_proc->tti_rx;
L1_proc->frame_tx = (L1_proc->subframe_rx > (9-ru->sf_ahead)) ? (L1_proc->frame_rx+1)&1023 : L1_proc->frame_rx; L1_proc->frame_tx = (L1_proc->subframe_rx > (9-sf_ahead)) ? (L1_proc->frame_rx+1)&1023 : L1_proc->frame_rx;
L1_proc->subframe_tx = (L1_proc->subframe_rx + ru->sf_ahead)%10; L1_proc->subframe_tx = (L1_proc->subframe_rx + sf_ahead)%10;
if (rxtx(eNB,L1_proc,string) < 0) if (rxtx(eNB,L1_proc,string) < 0)
LOG_E(PHY,"eNB %d CC_id %d failed during execution\n",eNB->Mod_id,eNB->CC_id); LOG_E(PHY,"eNB %d CC_id %d failed during execution\n",eNB->Mod_id,eNB->CC_id);
...@@ -610,11 +675,11 @@ int wakeup_rxtx(PHY_VARS_eNB *eNB, ...@@ -610,11 +675,11 @@ int wakeup_rxtx(PHY_VARS_eNB *eNB,
// The last (TS_rx mod samples_per_frame) was n*samples_per_tti, // The last (TS_rx mod samples_per_frame) was n*samples_per_tti,
// we want to generate subframe (n+sf_ahead), so TS_tx = TX_rx+sf_ahead*samples_per_tti, // we want to generate subframe (n+sf_ahead), so TS_tx = TX_rx+sf_ahead*samples_per_tti,
// and proc->subframe_tx = proc->subframe_rx+sf_ahead // and proc->subframe_tx = proc->subframe_rx+sf_ahead
L1_proc->timestamp_tx = ru_proc->timestamp_rx + (ru->sf_ahead*fp->samples_per_tti); L1_proc->timestamp_tx = ru_proc->timestamp_rx + (sf_ahead*fp->samples_per_tti);
L1_proc->frame_rx = ru_proc->frame_rx; L1_proc->frame_rx = ru_proc->frame_rx;
L1_proc->subframe_rx = ru_proc->tti_rx; L1_proc->subframe_rx = ru_proc->tti_rx;
L1_proc->frame_tx = (L1_proc->subframe_rx > (9-ru->sf_ahead)) ? (L1_proc->frame_rx+1)&1023 : L1_proc->frame_rx; L1_proc->frame_tx = (L1_proc->subframe_rx > (9-sf_ahead)) ? (L1_proc->frame_rx+1)&1023 : L1_proc->frame_rx;
L1_proc->subframe_tx = (L1_proc->subframe_rx + ru->sf_ahead)%10; L1_proc->subframe_tx = (L1_proc->subframe_rx + sf_ahead)%10;
LOG_D(PHY,"wakeup_rxtx: L1_proc->subframe_rx %d, L1_proc->subframe_tx %d, RU %d\n",L1_proc->subframe_rx,L1_proc->subframe_tx,ru->idx); LOG_D(PHY,"wakeup_rxtx: L1_proc->subframe_rx %d, L1_proc->subframe_tx %d, RU %d\n",L1_proc->subframe_rx,L1_proc->subframe_tx,ru->idx);
VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_WAKEUP_RXTX_RX_RU+ru->idx, L1_proc->frame_rx); VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_WAKEUP_RXTX_RX_RU+ru->idx, L1_proc->frame_rx);
VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_WAKEUP_RXTX_RX_RU+ru->idx, L1_proc->subframe_rx); VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_WAKEUP_RXTX_RX_RU+ru->idx, L1_proc->subframe_rx);
...@@ -833,9 +898,14 @@ static void *process_stats_thread(void *param) { ...@@ -833,9 +898,14 @@ static void *process_stats_thread(void *param) {
print_meas(&eNB->dlsch_turbo_encoding_preperation_stats,"dlsch_coding_crc",NULL,NULL); print_meas(&eNB->dlsch_turbo_encoding_preperation_stats,"dlsch_coding_crc",NULL,NULL);
print_meas(&eNB->dlsch_turbo_encoding_segmentation_stats,"dlsch_segmentation",NULL,NULL); print_meas(&eNB->dlsch_turbo_encoding_segmentation_stats,"dlsch_segmentation",NULL,NULL);
print_meas(&eNB->dlsch_encoding_stats,"dlsch_encoding",NULL,NULL); print_meas(&eNB->dlsch_encoding_stats,"dlsch_encoding",NULL,NULL);
print_meas(&eNB->dlsch_turbo_encoding_signal_stats,"coding_signal",NULL,NULL);
print_meas(&eNB->dlsch_turbo_encoding_main_stats,"coding_main",NULL,NULL);
print_meas(&eNB->dlsch_turbo_encoding_stats,"turbo_encoding",NULL,NULL); print_meas(&eNB->dlsch_turbo_encoding_stats,"turbo_encoding",NULL,NULL);
print_meas(&eNB->dlsch_interleaving_stats,"turbo_interleaving",NULL,NULL); print_meas(&eNB->dlsch_interleaving_stats,"turbo_interleaving",NULL,NULL);
print_meas(&eNB->dlsch_rate_matching_stats,"turbo_rate_matching",NULL,NULL); print_meas(&eNB->dlsch_rate_matching_stats,"turbo_rate_matching",NULL,NULL);
print_meas(&eNB->dlsch_turbo_encoding_waiting_stats,"coding_wait",NULL,NULL);
print_meas(&eNB->dlsch_turbo_encoding_wakeup_stats0,"coding_worker_0",NULL,NULL);
print_meas(&eNB->dlsch_turbo_encoding_wakeup_stats1,"coding_worker_1",NULL,NULL);
} }
print_meas(&eNB->dlsch_modulation_stats,"dlsch_modulation",NULL,NULL); print_meas(&eNB->dlsch_modulation_stats,"dlsch_modulation",NULL,NULL);
...@@ -886,6 +956,8 @@ void init_eNB_proc(int inst) { ...@@ -886,6 +956,8 @@ void init_eNB_proc(int inst) {
proc->instance_cnt_asynch_rxtx = -1; proc->instance_cnt_asynch_rxtx = -1;
proc->instance_cnt_synch = -1; proc->instance_cnt_synch = -1;
proc->CC_id = CC_id; proc->CC_id = CC_id;
L1_proc->CC_id = CC_id; /* MultiCell: Added for Multiple CC */
L1_proc_tx->CC_id = CC_id; /* MultiCell: Added for Multiple CC */
proc->first_rx =1; proc->first_rx =1;
proc->first_tx =1; proc->first_tx =1;
proc->RU_mask_tx = (1<<eNB->num_RU)-1; proc->RU_mask_tx = (1<<eNB->num_RU)-1;
...@@ -917,6 +989,14 @@ void init_eNB_proc(int inst) { ...@@ -917,6 +989,14 @@ void init_eNB_proc(int inst) {
pthread_mutex_init( &proc->mutex_RU_PRACH_br,NULL); pthread_mutex_init( &proc->mutex_RU_PRACH_br,NULL);
pthread_cond_init( &proc->cond_prach_br, NULL); pthread_cond_init( &proc->cond_prach_br, NULL);
pthread_attr_init( &proc->attr_prach_br); pthread_attr_init( &proc->attr_prach_br);
#ifndef DEADLINE_SCHEDULER
attr0 = &L1_proc->attr;
attr1 = &L1_proc_tx->attr;
attr_prach = &proc->attr_prach;
attr_prach_br = &proc->attr_prach_br;
// attr_td = &proc->attr_td;
// attr_te = &proc->attr_te;
#endif
if(get_thread_worker_conf() == WORKER_ENABLE) { if(get_thread_worker_conf() == WORKER_ENABLE) {
init_te_thread(eNB); init_te_thread(eNB);
...@@ -1120,7 +1200,7 @@ void init_transport(PHY_VARS_eNB *eNB) { ...@@ -1120,7 +1200,7 @@ void init_transport(PHY_VARS_eNB *eNB) {
} }
for (int i=0;i<NUMBER_OF_ULSCH_MAX; i++) { for (int i=0;i<NUMBER_OF_ULSCH_MAX; i++) {
LOG_I(PHY,"Allocating Transport Channel Buffers for ULSCH %d/%d\n",i,NUMBER_OF_ULSCH_MAX); LOG_I(PHY,"Allocating Transport Channel Buffer for ULSCH %d/%d\n",i,NUMBER_OF_ULSCH_MAX);
eNB->ulsch[i] = new_eNB_ulsch(MAX_TURBO_ITERATIONS,fp->N_RB_UL, 0); eNB->ulsch[i] = new_eNB_ulsch(MAX_TURBO_ITERATIONS,fp->N_RB_UL, 0);
if (!eNB->ulsch[i]) { if (!eNB->ulsch[i]) {
......
...@@ -96,6 +96,7 @@ pthread_cond_t nfapi_sync_cond; ...@@ -96,6 +96,7 @@ pthread_cond_t nfapi_sync_cond;
pthread_mutex_t nfapi_sync_mutex; pthread_mutex_t nfapi_sync_mutex;
int nfapi_sync_var=-1; //!< protected by mutex \ref nfapi_sync_mutex int nfapi_sync_var=-1; //!< protected by mutex \ref nfapi_sync_mutex
uint16_t sf_ahead=4;
pthread_cond_t sync_cond; pthread_cond_t sync_cond;
pthread_mutex_t sync_mutex; pthread_mutex_t sync_mutex;
...@@ -105,6 +106,10 @@ int config_sync_var=-1; ...@@ -105,6 +106,10 @@ int config_sync_var=-1;
uint16_t runtime_phy_rx[29][6]; // SISO [MCS 0-28][RBs 0-5 : 6, 15, 25, 50, 75, 100] uint16_t runtime_phy_rx[29][6]; // SISO [MCS 0-28][RBs 0-5 : 6, 15, 25, 50, 75, 100]
uint16_t runtime_phy_tx[29][6]; // SISO [MCS 0-28][RBs 0-5 : 6, 15, 25, 50, 75, 100] uint16_t runtime_phy_tx[29][6]; // SISO [MCS 0-28][RBs 0-5 : 6, 15, 25, 50, 75, 100]
/** FC Cell config */
pthread_cond_t cell_config_done_cond;
pthread_mutex_t cell_config_done_mutex;
int cell_config_done=-1;
int oai_exit = 0; int oai_exit = 0;
...@@ -388,6 +393,92 @@ void terminate_task(module_id_t mod_id, task_id_t from, task_id_t to) { ...@@ -388,6 +393,92 @@ void terminate_task(module_id_t mod_id, task_id_t from, task_id_t to) {
extern void free_transport(PHY_VARS_eNB *); extern void free_transport(PHY_VARS_eNB *);
extern void phy_free_RU(RU_t *); extern void phy_free_RU(RU_t *);
int stop_L1L2(module_id_t enb_id) {
LOG_W(ENB_APP, "stopping lte-softmodem\n");
if (!RC.ru) {
LOG_UI(ENB_APP, "no RU configured\n");
return -1;
}
/* these tasks need to pick up new configuration */
terminate_task(enb_id, TASK_ENB_APP, TASK_RRC_ENB);
oai_exit = 1;
LOG_I(ENB_APP, "calling kill_RU_proc() for instance %d\n", enb_id);
kill_RU_proc(RC.ru[enb_id]);
LOG_I(ENB_APP, "calling kill_eNB_proc() for instance %d\n", enb_id);
kill_eNB_proc(enb_id);
oai_exit = 0;
for (int cc_id = 0; cc_id < RC.nb_CC[enb_id]; cc_id++) {
free_transport(RC.eNB[enb_id][cc_id]);
phy_free_lte_eNB(RC.eNB[enb_id][cc_id]);
}
phy_free_RU(RC.ru[enb_id]);
free_lte_top();
return 0;
}
/*
* Restart the lte-softmodem after it has been soft-stopped with stop_L1L2()
*/
int restart_L1L2(module_id_t enb_id) {
int cc_id;
MessageDef *msg_p = NULL;
LOG_W(ENB_APP, "restarting lte-softmodem\n");
/* block threads */
pthread_mutex_lock(&sync_mutex);
sync_var = -1;
pthread_mutex_unlock(&sync_mutex);
for (cc_id = 0; cc_id < RC.nb_L1_CC[enb_id]; cc_id++) {
RC.eNB[enb_id][cc_id]->configured = 0;
for (int ru_id=0;ru_id<RC.eNB[enb_id][cc_id]->num_RU;ru_id++) {
int ru_idx = RC.eNB[enb_id][cc_id]->RU_list[ru_id]->idx;
RC.ru_mask |= (1 << ru_idx);
set_function_spec_param(RC.ru[ru_idx]);
}
}
/* reset the list of connected UEs in the MAC, since in this process with
* loose all UEs (have to reconnect) */
init_UE_info(&RC.mac[enb_id]->UE_info);
LOG_I(ENB_APP, "attempting to create ITTI tasks\n");
if (itti_create_task (TASK_RRC_ENB, rrc_enb_task, NULL) < 0) {
LOG_E(RRC, "Create task for RRC eNB failed\n");
return -1;
} else {
LOG_I(RRC, "Re-created task for RRC eNB successfully\n");
}
/* pass a reconfiguration request which will configure everything down to
* RC.eNB[i][j]->frame_parms, too */
msg_p = itti_alloc_new_message(TASK_ENB_APP, 0, RRC_CONFIGURATION_REQ);
RRC_CONFIGURATION_REQ(msg_p) = RC.rrc[enb_id]->configuration;
itti_send_msg_to_task(TASK_RRC_ENB, ENB_MODULE_ID_TO_INSTANCE(enb_id), msg_p);
/* TODO XForms might need to be restarted, but it is currently (09/02/18)
* broken, so we cannot test it */
wait_eNBs();
for (int cc_id=0;cc_id<RC.nb_L1_CC[enb_id]; cc_id++) {
for (int ru_id=0;ru_id<RC.eNB[enb_id][cc_id]->num_RU;ru_id++) {
int ru_idx = RC.eNB[enb_id][cc_id]->RU_list[ru_id]->idx;
init_RU_proc(RC.ru[ru_idx]);
RC.ru[ru_idx]->rf_map.card = 0;
RC.ru[ru_idx]->rf_map.chain = 0; /* CC_id + chain_offset;*/
}
}
wait_RUs();
init_eNB_afterRU();
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);
return 0;
}
static void init_pdcp(void) { static void init_pdcp(void) {
if (!NODE_IS_DU(RC.rrc[0]->node_type)) { if (!NODE_IS_DU(RC.rrc[0]->node_type)) {
pdcp_layer_init(); pdcp_layer_init();
...@@ -410,6 +501,17 @@ static void init_pdcp(void) { ...@@ -410,6 +501,17 @@ static void init_pdcp(void) {
} }
} }
static void wait_cell_config(char *thread_name) {
printf( "waiting for [SYS] CELL CONFIG Indication (%s)\n",thread_name);
pthread_mutex_lock( &cell_config_done_mutex );
while ( cell_config_done < 0 )
pthread_cond_wait( &cell_config_done_cond, &cell_config_done_mutex );
pthread_mutex_unlock(&cell_config_done_mutex );
printf( "SYS: got cell config (%s)\n", thread_name);
}
static void wait_nfapi_init(char *thread_name) { static void wait_nfapi_init(char *thread_name) {
printf( "waiting for NFAPI PNF connection and population of global structure (%s)\n",thread_name); printf( "waiting for NFAPI PNF connection and population of global structure (%s)\n",thread_name);
pthread_mutex_lock( &nfapi_sync_mutex ); pthread_mutex_lock( &nfapi_sync_mutex );
...@@ -423,6 +525,7 @@ static void wait_nfapi_init(char *thread_name) { ...@@ -423,6 +525,7 @@ static void wait_nfapi_init(char *thread_name) {
int main ( int argc, char **argv ) int main ( int argc, char **argv )
{ {
int i;
int CC_id = 0; int CC_id = 0;
int ru_id; int ru_id;
int node_type = ngran_eNB; int node_type = ngran_eNB;
...@@ -477,7 +580,22 @@ int main ( int argc, char **argv ) ...@@ -477,7 +580,22 @@ int main ( int argc, char **argv )
RCconfig_L1(); RCconfig_L1();
} }
/* We need to read RU configuration before FlexRAN starts so it knows what
* splits to report. Actual RU start comes later. */
if (RC.nb_RU > 0 && NFAPI_MODE != NFAPI_MODE_VNF) {
RC.ru = RCconfig_RU(RC.nb_RU,RC.nb_L1_inst,RC.eNB,&RC.ru_mask,&RC.ru_mutex,&RC.ru_cond);
LOG_I(PHY,
"number of L1 instances %d, number of RU %d, number of CPU cores %d\n",
RC.nb_L1_inst, RC.nb_RU, get_nprocs());
}
if (RC.nb_inst > 0) { if (RC.nb_inst > 0) {
/* Start the agent. If it is turned off in the configuration, it won't start */
for (i = 0; i < RC.nb_inst; i++) {
if(NFAPI_MODE != NFAPI_MODE_PNF)
flexran_agent_start(i);
}
/* initializes PDCP and sets correct RLC Request/PDCP Indication callbacks /* initializes PDCP and sets correct RLC Request/PDCP Indication callbacks
* for monolithic/F1 modes */ * for monolithic/F1 modes */
init_pdcp(); init_pdcp();
...@@ -487,10 +605,19 @@ int main ( int argc, char **argv ) ...@@ -487,10 +605,19 @@ int main ( int argc, char **argv )
exit(-1); exit(-1);
} }
for (int enb_id = 0; enb_id < RC.nb_inst; enb_id++) { /** TODO FC: Wait for Cell config, if SS RRC_CONFIGURATION_REQ will be triggered by TASK_SYS */
MessageDef *msg_p = itti_alloc_new_message (TASK_ENB_APP, 0, RRC_CONFIGURATION_REQ);
RRC_CONFIGURATION_REQ(msg_p) = RC.rrc[enb_id]->configuration; if (RC.ss.mode == SS_SOFTMODEM) {
itti_send_msg_to_task (TASK_RRC_ENB, ENB_MODULE_ID_TO_INSTANCE(enb_id), msg_p); /** wait for signal */
wait_cell_config("TASK_SYS");
} else
{
for (int enb_id = 0; enb_id < RC.nb_inst; enb_id++) {
MessageDef *msg_p = itti_alloc_new_message (TASK_ENB_APP, 0, RRC_CONFIGURATION_REQ);
RRC_CONFIGURATION_REQ(msg_p) = RC.rrc[enb_id]->configuration;
itti_send_msg_to_task (TASK_RRC_ENB, ENB_MODULE_ID_TO_INSTANCE(enb_id), msg_p);
}
} }
node_type = RC.rrc[0]->node_type; node_type = RC.rrc[0]->node_type;
} }
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "PHY/types.h" #include "PHY/types.h"
#include "PHY/defs_eNB.h" #include "PHY/defs_eNB.h"
#include "PHY/defs_UE.h" #include "PHY/defs_UE.h"
#include "flexran_agent.h"
#include "s1ap_eNB.h" #include "s1ap_eNB.h"
#include "SIMULATION/ETH_TRANSPORT/proto.h" #include "SIMULATION/ETH_TRANSPORT/proto.h"
#include "executables/softmodem-common.h" #include "executables/softmodem-common.h"
...@@ -47,6 +48,7 @@ ...@@ -47,6 +48,7 @@
{"debug-ue-prach", CONFIG_HLP_DBGUEPR, PARAMFLAG_BOOL, uptr:NULL, defuintval:1, TYPE_INT, 0}, \ {"debug-ue-prach", CONFIG_HLP_DBGUEPR, PARAMFLAG_BOOL, uptr:NULL, defuintval:1, TYPE_INT, 0}, \
{"no-L2-connect", CONFIG_HLP_NOL2CN, PARAMFLAG_BOOL, uptr:NULL, defuintval:1, TYPE_INT, 0}, \ {"no-L2-connect", CONFIG_HLP_NOL2CN, PARAMFLAG_BOOL, uptr:NULL, defuintval:1, TYPE_INT, 0}, \
{"calib-prach-tx", CONFIG_HLP_CALPRACH, PARAMFLAG_BOOL, uptr:NULL, defuintval:1, TYPE_INT, 0}, \ {"calib-prach-tx", CONFIG_HLP_CALPRACH, PARAMFLAG_BOOL, uptr:NULL, defuintval:1, TYPE_INT, 0}, \
{"loop-memory", CONFIG_HLP_UELOOP, 0, strptr:&loopfile, defstrval:"iqs.in", TYPE_STRING,0}, \
{"ue-dump-frame", CONFIG_HLP_DUMPFRAME, PARAMFLAG_BOOL, iptr:&dumpframe, defintval:0, TYPE_INT, 0}, \ {"ue-dump-frame", CONFIG_HLP_DUMPFRAME, PARAMFLAG_BOOL, iptr:&dumpframe, defintval:0, TYPE_INT, 0}, \
} }
#define CMDLINE_CALIBUERX_IDX 0 #define CMDLINE_CALIBUERX_IDX 0
...@@ -115,6 +117,15 @@ ...@@ -115,6 +117,15 @@
/*-----------------------------------------------------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------------------------------------------------*/
/* command line parameters specific to UE threads */ /* command line parameters specific to UE threads */
/* optname helpstr paramflags XXXptr defXXXval type numelt */ /* optname helpstr paramflags XXXptr defXXXval type numelt */
/*-----------------------------------------------------------------------------------------------------------------------------*/
#define CMDLINE_UETHREADSPARAMS_DESC { \
{"threadOneSubframe", NULL, 0, iptr:&(threads.one), defintval:1, TYPE_INT, 0}, \
{"threadTwoSubframe", NULL, 0, iptr:&(threads.two), defintval:1, TYPE_INT, 0}, \
{"threadThreeSubframe", NULL, 0, iptr:&(threads.three), defintval:1, TYPE_INT, 0}, \
{"threadSlot1ProcOne", NULL, 0, iptr:&(threads.slot1_proc_one), defintval:1, TYPE_INT, 0}, \
{"threadSlot1ProcTwo", NULL, 0, iptr:&(threads.slot1_proc_two), defintval:1, TYPE_INT, 0}, \
}
// {"threadIQ", NULL, 0, iptr:&(threads.iq), defintval:1, TYPE_INT, 0},
#define DEFAULT_DLF 2680000000 #define DEFAULT_DLF 2680000000
...@@ -193,6 +204,8 @@ extern void init_ue_devices(PHY_VARS_UE *); ...@@ -193,6 +204,8 @@ 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); PHY_VARS_UE *init_ue_vars(LTE_DL_FRAME_PARMS *frame_parms, uint8_t UE_id, uint8_t abstraction_flag);
void init_eNB_afterRU(void); 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 void init_UE_stub_single_thread(int nb_inst, int eMBMS_active, int uecap_xer_in, char *emul_iface);
extern void init_UE_standalone_thread(int ue_idx); extern void init_UE_standalone_thread(int ue_idx);
......
...@@ -86,13 +86,16 @@ extern void multicast_link_start(void (*rx_handlerP) (unsigned int, char *), ...@@ -86,13 +86,16 @@ extern void multicast_link_start(void (*rx_handlerP) (unsigned int, char *),
char *multicast_ifname); char *multicast_ifname);
extern int multicast_link_write_sock(int groupP, char *dataP, uint32_t sizeP); extern int multicast_link_write_sock(int groupP, char *dataP, uint32_t sizeP);
uint16_t processingDelay = 1; /** 1 ms */
int tx_req_num_elems; int tx_req_num_elems;
extern uint16_t sf_ahead; extern uint16_t sf_ahead;
//extern int tx_req_UE_MAC1(); //extern int tx_req_UE_MAC1();
void ue_stub_rx_handler(unsigned int, char *); void ue_stub_rx_handler(unsigned int, char *);
int32_t **rxdata;
int32_t **txdata;
int timer_subframe = 0; int timer_subframe = 0;
int timer_frame = 0; int timer_frame = 0;
SF_ticking *phy_stub_ticking = NULL; SF_ticking *phy_stub_ticking = NULL;
...@@ -108,7 +111,7 @@ typedef struct eutra_band_s { ...@@ -108,7 +111,7 @@ typedef struct eutra_band_s {
uint32_t ul_max; uint32_t ul_max;
uint32_t dl_min; uint32_t dl_min;
uint32_t dl_max; uint32_t dl_max;
frame_type_t frame_type; lte_frame_type_t frame_type;
} eutra_band_t; } eutra_band_t;
typedef struct band_info_s { typedef struct band_info_s {
...@@ -151,10 +154,19 @@ static const eutra_band_t eutra_bands[] = { ...@@ -151,10 +154,19 @@ static const eutra_band_t eutra_bands[] = {
}; };
threads_t threads= {-1,-1,-1,-1,-1,-1,-1,-1};
pthread_t main_ue_thread; pthread_t main_ue_thread;
pthread_attr_t attr_UE_thread; pthread_attr_t attr_UE_thread;
struct sched_param sched_param_UE_thread; struct sched_param sched_param_UE_thread;
void get_uethreads_params(void) {
paramdef_t cmdline_threadsparams[] =CMDLINE_UETHREADSPARAMS_DESC;
config_process_cmdline( cmdline_threadsparams,sizeof(cmdline_threadsparams)/sizeof(paramdef_t),NULL);
}
void phy_init_lte_ue_transport(PHY_VARS_UE *ue,int absraction_flag); void phy_init_lte_ue_transport(PHY_VARS_UE *ue,int absraction_flag);
PHY_VARS_UE *init_ue_vars(LTE_DL_FRAME_PARMS *frame_parms, PHY_VARS_UE *init_ue_vars(LTE_DL_FRAME_PARMS *frame_parms,
...@@ -193,7 +205,24 @@ void init_thread(int sched_runtime, ...@@ -193,7 +205,24 @@ void init_thread(int sched_runtime,
int sched_deadline, int sched_deadline,
int sched_fifo, int sched_fifo,
cpu_set_t *cpuset, cpu_set_t *cpuset,
char *name) { char *name)
{
#ifdef DEADLINE_SCHEDULER
if (sched_runtime!=0) {
struct sched_attr attr= {0};
attr.size = sizeof(attr);
attr.sched_policy = SCHED_DEADLINE;
attr.sched_runtime = sched_runtime;
attr.sched_deadline = sched_deadline;
attr.sched_period = 0;
AssertFatal(sched_setattr(0, &attr, 0) == 0,
"[SCHED] %s thread: sched_setattr failed %s \n", name, strerror(errno));
LOG_I(HW,"[SCHED][eNB] %s deadline thread %lu started on CPU %d\n",
name, (unsigned long)gettid(), sched_getcpu());
}
#else
int settingPriority = 1; int settingPriority = 1;
if (checkIfFedoraDistribution()) if (checkIfFedoraDistribution())
...@@ -225,6 +254,7 @@ void init_thread(int sched_runtime, ...@@ -225,6 +254,7 @@ void init_thread(int sched_runtime,
} }
CPU_FREE(cset); CPU_FREE(cset);
#endif
} }
void init_UE(int nb_inst, void init_UE(int nb_inst,
...@@ -237,7 +267,8 @@ void init_UE(int nb_inst, ...@@ -237,7 +267,8 @@ void init_UE(int nb_inst,
runmode_t mode, runmode_t mode,
int rxgain, int rxgain,
int txpowermax, int txpowermax,
LTE_DL_FRAME_PARMS *fp0) { LTE_DL_FRAME_PARMS *fp0)
{
PHY_VARS_UE *UE; PHY_VARS_UE *UE;
int inst; int inst;
int ret; int ret;
...@@ -253,7 +284,9 @@ void init_UE(int nb_inst, ...@@ -253,7 +284,9 @@ void init_UE(int nb_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 *)); 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,"Allocating UE context %d\n",inst);
PHY_vars_UE_g[inst][0] = init_ue_vars(fp0,inst,0); PHY_vars_UE_g[inst][0] = init_ue_vars(fp0,inst,0);
// turn off timing control loop in UE // turn off timing control loop in UE
PHY_vars_UE_g[inst][0]->no_timing_correction = timing_correction; PHY_vars_UE_g[inst][0]->no_timing_correction = timing_correction;
UE = PHY_vars_UE_g[inst][0]; UE = PHY_vars_UE_g[inst][0];
...@@ -328,8 +361,15 @@ void init_UE(int nb_inst, ...@@ -328,8 +361,15 @@ void init_UE(int nb_inst,
} }
} else UE->N_TA_offset = 0; } else UE->N_TA_offset = 0;
if( IS_SOFTMODEM_BASICSIM)
/* this is required for the basic simulator in TDD mode
* TODO: find a proper cleaner solution
*/
UE->N_TA_offset = 0;
LOG_I(PHY,"Intializing UE Threads for instance %d (%p,%p)...\n",inst,PHY_vars_UE_g[inst],PHY_vars_UE_g[inst][0]); 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); init_UE_threads(inst);
ret = openair0_device_load(&(UE->rfdevice), &openair0_cfg[0]); ret = openair0_device_load(&(UE->rfdevice), &openair0_cfg[0]);
if (ret !=0) { if (ret !=0) {
...@@ -352,7 +392,8 @@ void init_UE(int nb_inst, ...@@ -352,7 +392,8 @@ void init_UE(int nb_inst,
void init_UE_stub_single_thread(int nb_inst, void init_UE_stub_single_thread(int nb_inst,
int eMBMS_active, int eMBMS_active,
int uecap_xer_in, int uecap_xer_in,
char *emul_iface) { char *emul_iface)
{
int inst; int inst;
LOG_I(PHY,"UE : Calling Layer 2 for initialization, nb_inst: %d \n", nb_inst); LOG_I(PHY,"UE : Calling Layer 2 for initialization, nb_inst: %d \n", nb_inst);
l2_init_ue(eMBMS_active,(uecap_xer_in==1)?uecap_xer:NULL, l2_init_ue(eMBMS_active,(uecap_xer_in==1)?uecap_xer:NULL,
...@@ -377,10 +418,12 @@ void init_UE_stub_single_thread(int nb_inst, ...@@ -377,10 +418,12 @@ void init_UE_stub_single_thread(int nb_inst,
} }
} }
void init_UE_standalone_thread(int ue_idx) { void init_UE_standalone_thread(int ue_idx)
{
int standalone_tx_port = 3211 + ue_idx * 2; int standalone_tx_port = 3211 + ue_idx * 2;
int standalone_rx_port = 3212 + ue_idx * 2; int standalone_rx_port = 3212 + ue_idx * 2;
ue_init_standalone_socket(standalone_tx_port, standalone_rx_port); ue_init_standalone_socket(standalone_tx_port, standalone_rx_port);
pthread_t thread; pthread_t thread;
if (pthread_create(&thread, NULL, ue_standalone_pnf_task, NULL) != 0) { if (pthread_create(&thread, NULL, ue_standalone_pnf_task, NULL) != 0) {
...@@ -393,7 +436,8 @@ void init_UE_standalone_thread(int ue_idx) { ...@@ -393,7 +436,8 @@ void init_UE_standalone_thread(int ue_idx) {
void init_UE_stub(int nb_inst, void init_UE_stub(int nb_inst,
int eMBMS_active, int eMBMS_active,
int uecap_xer_in, int uecap_xer_in,
char *emul_iface) { char *emul_iface)
{
int inst; int inst;
LOG_I(PHY,"UE : Calling Layer 2 for initialization\n"); LOG_I(PHY,"UE : Calling Layer 2 for initialization\n");
l2_init_ue(eMBMS_active,(uecap_xer_in==1)?uecap_xer:NULL, l2_init_ue(eMBMS_active,(uecap_xer_in==1)?uecap_xer:NULL,
...@@ -427,7 +471,8 @@ void init_UE_stub(int nb_inst, ...@@ -427,7 +471,8 @@ void init_UE_stub(int nb_inst,
* \returns a pointer to an int. The storage is not on the heap and must not be freed. * \returns a pointer to an int. The storage is not on the heap and must not be freed.
*/ */
static void *UE_thread_synch(void *arg) { static void *UE_thread_synch(void *arg)
{
static int UE_thread_synch_retval; static int UE_thread_synch_retval;
int i ; int i ;
PHY_VARS_UE *UE = (PHY_VARS_UE *) arg; PHY_VARS_UE *UE = (PHY_VARS_UE *) arg;
...@@ -442,6 +487,8 @@ static void *UE_thread_synch(void *arg) { ...@@ -442,6 +487,8 @@ static void *UE_thread_synch(void *arg) {
printf("UE_thread_sync in with PHY_vars_UE %p\n",arg); printf("UE_thread_sync in with PHY_vars_UE %p\n",arg);
cpu_set_t cpuset; cpu_set_t cpuset;
CPU_ZERO(&cpuset); CPU_ZERO(&cpuset);
if ( threads.sync != -1 )
CPU_SET(threads.sync, &cpuset);
// this thread priority must be lower that the main acquisition thread // this thread priority must be lower that the main acquisition thread
sprintf(threadname, "sync UE %d\n", UE->Mod_id); sprintf(threadname, "sync UE %d\n", UE->Mod_id);
...@@ -608,7 +655,7 @@ static void *UE_thread_synch(void *arg) { ...@@ -608,7 +655,7 @@ static void *UE_thread_synch(void *arg) {
break; break;
} }
UE->rfdevice.trx_set_freq_func(&UE->rfdevice,&openair0_cfg[0]); UE->rfdevice.trx_set_freq_func(&UE->rfdevice,&openair0_cfg[0],0);
//UE->rfdevice.trx_set_gains_func(&openair0,&openair0_cfg[0]); //UE->rfdevice.trx_set_gains_func(&openair0,&openair0_cfg[0]);
//UE->rfdevice.trx_stop_func(&UE->rfdevice); //UE->rfdevice.trx_stop_func(&UE->rfdevice);
sleep(1); sleep(1);
...@@ -692,7 +739,7 @@ static void *UE_thread_synch(void *arg) { ...@@ -692,7 +739,7 @@ static void *UE_thread_synch(void *arg) {
openair0_cfg[UE->rf_map.card].autocal[UE->rf_map.chain+i] = 1; openair0_cfg[UE->rf_map.card].autocal[UE->rf_map.chain+i] = 1;
} }
UE->rfdevice.trx_set_freq_func(&UE->rfdevice,&openair0_cfg[0]); UE->rfdevice.trx_set_freq_func(&UE->rfdevice,&openair0_cfg[0],0);
}// initial_sync=0 }// initial_sync=0
break; break;
...@@ -719,7 +766,8 @@ static void *UE_thread_synch(void *arg) { ...@@ -719,7 +766,8 @@ static void *UE_thread_synch(void *arg) {
* \param arg is a pointer to a \ref PHY_VARS_UE structure. * \param arg is a pointer to a \ref PHY_VARS_UE structure.
* \returns a pointer to an int. The storage is not on the heap and must not be freed. * \returns a pointer to an int. The storage is not on the heap and must not be freed.
*/ */
const char *get_connectionloss_errstr(int errcode) { const char *get_connectionloss_errstr(int errcode)
{
switch (errcode) { switch (errcode) {
case CONNECTION_LOST: case CONNECTION_LOST:
return "RRC Connection lost, returning to PRACH"; return "RRC Connection lost, returning to PRACH";
...@@ -734,7 +782,8 @@ const char *get_connectionloss_errstr(int errcode) { ...@@ -734,7 +782,8 @@ const char *get_connectionloss_errstr(int errcode) {
return "UNKNOWN RETURN CODE"; return "UNKNOWN RETURN CODE";
} }
static void *UE_thread_rxn_txnp4(void *arg) { static void *UE_thread_rxn_txnp4(void *arg)
{
static __thread int UE_thread_rxtx_retval; static __thread int UE_thread_rxtx_retval;
struct rx_tx_thread_data *rtd = arg; struct rx_tx_thread_data *rtd = arg;
UE_rxtx_proc_t *proc = rtd->proc; UE_rxtx_proc_t *proc = rtd->proc;
...@@ -745,6 +794,15 @@ static void *UE_thread_rxn_txnp4(void *arg) { ...@@ -745,6 +794,15 @@ static void *UE_thread_rxn_txnp4(void *arg) {
cpu_set_t cpuset; cpu_set_t cpuset;
CPU_ZERO(&cpuset); CPU_ZERO(&cpuset);
if ( (proc->sub_frame_start+1)%RX_NB_TH == 0 && threads.one != -1 )
CPU_SET(threads.one, &cpuset);
if ( RX_NB_TH > 1 && (proc->sub_frame_start+1)%RX_NB_TH == 1 && threads.two != -1 )
CPU_SET(threads.two, &cpuset);
if ( RX_NB_TH > 2 && (proc->sub_frame_start+1)%RX_NB_TH == 2 && threads.three != -1 )
CPU_SET(threads.three, &cpuset);
//CPU_SET(threads.three, &cpuset); //CPU_SET(threads.three, &cpuset);
init_thread(900000,1000000, FIFO_PRIORITY-1, &cpuset, init_thread(900000,1000000, FIFO_PRIORITY-1, &cpuset,
threadname); threadname);
...@@ -818,11 +876,17 @@ static void *UE_thread_rxn_txnp4(void *arg) { ...@@ -818,11 +876,17 @@ static void *UE_thread_rxn_txnp4(void *arg) {
if ((subframe_select( &UE->frame_parms, proc->subframe_tx) == SF_UL) || if ((subframe_select( &UE->frame_parms, proc->subframe_tx) == SF_UL) ||
(UE->frame_parms.frame_type == FDD) ) (UE->frame_parms.frame_type == FDD) )
phy_procedures_UE_TX(UE,proc,0,0,UE->mode); if (UE->mode != loop_through_memory)
phy_procedures_UE_TX(UE,proc,0,0,UE->mode);
if ((subframe_select( &UE->frame_parms, proc->subframe_tx) == SF_S) &&
(UE->frame_parms.frame_type == TDD))
if (UE->mode != loop_through_memory)
phy_procedures_UE_S_TX(UE,0,0);
proc->instance_cnt_rxtx--; proc->instance_cnt_rxtx--;
if (IS_SOFTMODEM_RFSIM) { if ( IS_SOFTMODEM_BASICSIM || IS_SOFTMODEM_RFSIM ) {
if (pthread_cond_signal(&proc->cond_rxtx) != 0) abort(); if (pthread_cond_signal(&proc->cond_rxtx) != 0) abort();
} }
...@@ -840,7 +904,8 @@ static void *UE_thread_rxn_txnp4(void *arg) { ...@@ -840,7 +904,8 @@ static void *UE_thread_rxn_txnp4(void *arg) {
unsigned int emulator_absSF; unsigned int emulator_absSF;
void ue_stub_rx_handler(unsigned int num_bytes, void ue_stub_rx_handler(unsigned int num_bytes,
char *rx_buffer) { char *rx_buffer)
{
PHY_VARS_UE *UE; PHY_VARS_UE *UE;
UE = PHY_vars_UE_g[0][0]; UE = PHY_vars_UE_g[0][0];
UE_tport_t *pdu = (UE_tport_t *)rx_buffer; UE_tport_t *pdu = (UE_tport_t *)rx_buffer;
...@@ -895,14 +960,14 @@ void ue_stub_rx_handler(unsigned int num_bytes, ...@@ -895,14 +960,14 @@ void ue_stub_rx_handler(unsigned int num_bytes,
} }
} }
uint64_t clock_usec(void) { uint64_t clock_usec(void)
struct timespec t; {
struct timespec t;
if (clock_gettime(CLOCK_MONOTONIC, &t) == -1) { if (clock_gettime(CLOCK_MONOTONIC, &t) == -1)
abort(); {
} abort();
}
return (uint64_t)t.tv_sec * 1000000 + (t.tv_nsec / 1000); return (uint64_t)t.tv_sec * 1000000 + (t.tv_nsec / 1000);
} }
/*! /*!
* \brief This is the UE thread for RX subframe n and TX subframe n+4. * \brief This is the UE thread for RX subframe n and TX subframe n+4.
...@@ -912,21 +977,23 @@ uint64_t clock_usec(void) { ...@@ -912,21 +977,23 @@ uint64_t clock_usec(void) {
* \returns a pointer to an int. The storage is not on the heap and must not be freed. * \returns a pointer to an int. The storage is not on the heap and must not be freed.
*/ */
static void *UE_phy_stub_standalone_pnf_task(void *arg) { static void *UE_phy_stub_standalone_pnf_task(void *arg)
{
#if 1 #if 1
{ {
struct sched_param sparam = struct sched_param sparam =
{ {
.sched_priority = 79, .sched_priority = 79,
}; };
if (pthread_setschedparam(pthread_self(), SCHED_RR, &sparam) != 0)
if (pthread_setschedparam(pthread_self(), SCHED_RR, &sparam) != 0) { {
LOG_E(PHY,"pthread_setschedparam: %s\n", strerror(errno)); LOG_E(PHY,"pthread_setschedparam: %s\n", strerror(errno));
} }
} }
#else #else
thread_top_init("UE_phy_stub_thread_rxn_txnp4", 1, 870000L, 1000000L, 1000000L); thread_top_init("UE_phy_stub_thread_rxn_txnp4", 1, 870000L, 1000000L, 1000000L);
#endif #endif
// for multipule UE's L2-emulator // for multipule UE's L2-emulator
//module_id_t Mod_id = 0; //module_id_t Mod_id = 0;
//int init_ra_UE = -1; // This counter is used to initiate the RA of each UE in different SFrames //int init_ra_UE = -1; // This counter is used to initiate the RA of each UE in different SFrames
...@@ -946,7 +1013,9 @@ static void *UE_phy_stub_standalone_pnf_task(void *arg) { ...@@ -946,7 +1013,9 @@ static void *UE_phy_stub_standalone_pnf_task(void *arg) {
PHY_VARS_UE *UE = NULL; PHY_VARS_UE *UE = NULL;
int ret; int ret;
proc = &PHY_vars_UE_g[0][0]->proc.proc_rxtx[0]; proc = &PHY_vars_UE_g[0][0]->proc.proc_rxtx[0];
UE = rtd->UE; UE = rtd->UE;
UL_INFO = (UL_IND_t *)calloc(1, sizeof(UL_IND_t)); UL_INFO = (UL_IND_t *)calloc(1, sizeof(UL_IND_t));
UL_INFO->rx_ind.rx_indication_body.rx_pdu_list = calloc(NFAPI_RX_IND_MAX_PDU, sizeof(nfapi_rx_indication_pdu_t)); UL_INFO->rx_ind.rx_indication_body.rx_pdu_list = calloc(NFAPI_RX_IND_MAX_PDU, sizeof(nfapi_rx_indication_pdu_t));
UL_INFO->rx_ind.rx_indication_body.number_of_pdus = 0; UL_INFO->rx_ind.rx_indication_body.number_of_pdus = 0;
...@@ -959,15 +1028,19 @@ static void *UE_phy_stub_standalone_pnf_task(void *arg) { ...@@ -959,15 +1028,19 @@ static void *UE_phy_stub_standalone_pnf_task(void *arg) {
UL_INFO->cqi_ind.cqi_indication_body.cqi_pdu_list = calloc(NFAPI_CQI_IND_MAX_PDU, sizeof(nfapi_cqi_indication_pdu_t)); UL_INFO->cqi_ind.cqi_indication_body.cqi_pdu_list = calloc(NFAPI_CQI_IND_MAX_PDU, sizeof(nfapi_cqi_indication_pdu_t));
UL_INFO->cqi_ind.cqi_indication_body.cqi_raw_pdu_list = calloc(NFAPI_CQI_IND_MAX_PDU, sizeof(nfapi_cqi_indication_raw_pdu_t)); UL_INFO->cqi_ind.cqi_indication_body.cqi_raw_pdu_list = calloc(NFAPI_CQI_IND_MAX_PDU, sizeof(nfapi_cqi_indication_raw_pdu_t));
UL_INFO->cqi_ind.cqi_indication_body.number_of_cqis = 0; UL_INFO->cqi_ind.cqi_indication_body.number_of_cqis = 0;
proc->subframe_rx = proc->sub_frame_start; proc->subframe_rx = proc->sub_frame_start;
proc->subframe_tx = -1; proc->subframe_tx = -1;
proc->frame_rx = -1; proc->frame_rx = -1;
proc->frame_tx = -1; proc->frame_tx = -1;
// Initializations for nfapi-L2-emulator mode // Initializations for nfapi-L2-emulator mode
sync_var = 0; sync_var = 0;
//PANOS: CAREFUL HERE! //PANOS: CAREFUL HERE!
wait_sync("UE_phy_stub_standalone_pnf_task"); wait_sync("UE_phy_stub_standalone_pnf_task");
int last_sfn_sf = -1; int last_sfn_sf = -1;
LOG_I(MAC, "Clearing Queues\n"); LOG_I(MAC, "Clearing Queues\n");
reset_queue(&dl_config_req_tx_req_queue); reset_queue(&dl_config_req_tx_req_queue);
reset_queue(&ul_config_req_queue); reset_queue(&ul_config_req_queue);
...@@ -982,20 +1055,31 @@ static void *UE_phy_stub_standalone_pnf_task(void *arg) { ...@@ -982,20 +1055,31 @@ static void *UE_phy_stub_standalone_pnf_task(void *arg) {
} }
int sfn_sf = current_sfn_sf; int sfn_sf = current_sfn_sf;
if (sfn_sf == last_sfn_sf)
if (sfn_sf == last_sfn_sf) { {
LOG_W(MAC, "repeated sfn_sf = %d.%d\n", LOG_W(MAC, "repeated sfn_sf = %d.%d\n",
sfn_sf >> 4, sfn_sf & 15); sfn_sf >> 4, sfn_sf & 15);
continue; continue;
} }
last_sfn_sf = sfn_sf;
last_sfn_sf = sfn_sf; last_sfn_sf = sfn_sf;
nfapi_dl_config_req_tx_req_t *dl_config_req_tx_req = get_queue(&dl_config_req_tx_req_queue); nfapi_dl_config_req_tx_req_t *dl_config_req_tx_req = get_queue(&dl_config_req_tx_req_queue);
nfapi_ul_config_request_t *ul_config_req = get_queue(&ul_config_req_queue); nfapi_ul_config_request_t *ul_config_req = get_queue(&ul_config_req_queue);
nfapi_hi_dci0_request_t *hi_dci0_req = get_queue(&hi_dci0_req_queue); nfapi_hi_dci0_request_t *hi_dci0_req = get_queue(&hi_dci0_req_queue);
LOG_I(MAC, "received from proxy frame %d subframe %d\n", LOG_I(MAC, "received from proxy frame %d subframe %d\n",
NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf)); NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf));
#if 1 /** Processing delay */
if (processingDelay > 0) {
struct timespec rqtp, rmtp;
rqtp.tv_sec = processingDelay / 1000;
rqtp.tv_nsec = 1e6 * (processingDelay % 1000);
nanosleep(&rqtp, &rmtp);
}
#endif
if (ul_config_req != NULL) { if (ul_config_req != NULL) {
uint8_t ul_num_pdus = ul_config_req->ul_config_request_body.number_of_pdus; uint8_t ul_num_pdus = ul_config_req->ul_config_request_body.number_of_pdus;
...@@ -1008,13 +1092,15 @@ static void *UE_phy_stub_standalone_pnf_task(void *arg) { ...@@ -1008,13 +1092,15 @@ static void *UE_phy_stub_standalone_pnf_task(void *arg) {
if (hi_dci0_req != NULL) { if (hi_dci0_req != NULL) {
LOG_D(MAC, "hi_dci0_req pdus: %u Frame: %d Subframe: %d\n", LOG_D(MAC, "hi_dci0_req pdus: %u Frame: %d Subframe: %d\n",
hi_dci0_req->hi_dci0_request_body.number_of_dci, hi_dci0_req->hi_dci0_request_body.number_of_dci,
NFAPI_SFNSF2SFN(hi_dci0_req->sfn_sf), NFAPI_SFNSF2SF(hi_dci0_req->sfn_sf)); NFAPI_SFNSF2SFN(hi_dci0_req->sfn_sf), NFAPI_SFNSF2SF(hi_dci0_req->sfn_sf));
} }
if (dl_config_req_tx_req != NULL) { if (dl_config_req_tx_req != NULL) {
nfapi_tx_req_pdu_list_t *tx_req_pdu_list = dl_config_req_tx_req->tx_req_pdu_list; nfapi_tx_req_pdu_list_t *tx_req_pdu_list = dl_config_req_tx_req->tx_req_pdu_list;
nfapi_dl_config_request_t *dl_config_req = dl_config_req_tx_req->dl_config_req; nfapi_dl_config_request_t *dl_config_req = dl_config_req_tx_req->dl_config_req;
uint16_t dl_num_pdus = dl_config_req->dl_config_request_body.number_pdu; uint16_t dl_num_pdus = dl_config_req->dl_config_request_body.number_pdu;
LOG_I(MAC, "(OAI UE) Received dl_config_req from proxy at Frame: %d, Subframe: %d," LOG_I(MAC, "(OAI UE) Received dl_config_req from proxy at Frame: %d, Subframe: %d,"
" with number of PDUs: %u\n", " with number of PDUs: %u\n",
...@@ -1026,6 +1112,7 @@ static void *UE_phy_stub_standalone_pnf_task(void *arg) { ...@@ -1026,6 +1112,7 @@ static void *UE_phy_stub_standalone_pnf_task(void *arg) {
LOG_I(MAC, "dl_config_req: %s\n", dl_str); LOG_I(MAC, "dl_config_req: %s\n", dl_str);
free(dl_str); free(dl_str);
} }
LOG_D(MAC, "tx_req pdus: %d\n", tx_req_pdu_list->num_pdus);
LOG_D(MAC, "tx_req pdus: %d\n", tx_req_pdu_list->num_pdus); LOG_D(MAC, "tx_req pdus: %d\n", tx_req_pdu_list->num_pdus);
// Handling dl_config_req and tx_req: // Handling dl_config_req and tx_req:
...@@ -1082,6 +1169,7 @@ static void *UE_phy_stub_standalone_pnf_task(void *arg) { ...@@ -1082,6 +1169,7 @@ static void *UE_phy_stub_standalone_pnf_task(void *arg) {
for (ue_index = 0; ue_index < ue_num; ue_index++) { for (ue_index = 0; ue_index < ue_num; ue_index++) {
ue_Mod_id = ue_thread_id + NB_THREAD_INST * ue_index; // Always 0 in standalone pnf mode ue_Mod_id = ue_thread_id + NB_THREAD_INST * ue_index; // Always 0 in standalone pnf mode
UE = PHY_vars_UE_g[ue_Mod_id][0]; UE = PHY_vars_UE_g[ue_Mod_id][0];
#if UE_TIMING_TRACE #if UE_TIMING_TRACE
start_meas(&UE->generic_stat); start_meas(&UE->generic_stat);
#endif #endif
...@@ -1111,62 +1199,74 @@ static void *UE_phy_stub_standalone_pnf_task(void *arg) { ...@@ -1111,62 +1199,74 @@ static void *UE_phy_stub_standalone_pnf_task(void *arg) {
// Prepare the future Tx data // Prepare the future Tx data
if ((subframe_select(&UE->frame_parms, NFAPI_SFNSF2SF(sfn_sf)) == SF_UL) || if ((subframe_select(&UE->frame_parms, NFAPI_SFNSF2SF(sfn_sf)) == SF_UL) ||
(UE->frame_parms.frame_type == FDD)) { (UE->frame_parms.frame_type == FDD))
// We make the start of RA between consecutive UEs differ by 20 frames {
//if ((UE_mac_inst[Mod_id].UE_mode[0] == PRACH && Mod_id == 0) || (UE_mac_inst[Mod_id].UE_mode[0] == PRACH && Mod_id>0 && rx_frame >= UE_mac_inst[Mod_id-1].ra_frame + 20) ) { if (UE->mode != loop_through_memory)
if (UE_mac_inst[ue_Mod_id].UE_mode[0] == RA_RESPONSE && {
is_prach_subframe(&UE->frame_parms, NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf))) { // We make the start of RA between consecutive UEs differ by 20 frames
UE_mac_inst[ue_Mod_id].UE_mode[0] = PRACH; //if ((UE_mac_inst[Mod_id].UE_mode[0] == PRACH && Mod_id == 0) || (UE_mac_inst[Mod_id].UE_mode[0] == PRACH && Mod_id>0 && rx_frame >= UE_mac_inst[Mod_id-1].ra_frame + 20) ) {
} if (UE_mac_inst[ue_Mod_id].UE_mode[0] == RA_RESPONSE &&
is_prach_subframe(&UE->frame_parms, NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf)))
LOG_D(MAC, "UE_mode: %d\n", UE_mac_inst[ue_Mod_id].UE_mode[0]); {
UE_mac_inst[ue_Mod_id].UE_mode[0] = PRACH;
if (UE_mac_inst[ue_Mod_id].UE_mode[0] == PRACH) { }
//&& ue_Mod_id == next_Mod_id) { LOG_D(MAC, "UE_mode: %d\n", UE_mac_inst[ue_Mod_id].UE_mode[0]);
next_ra_frame++; if (UE_mac_inst[ue_Mod_id].UE_mode[0] == PRACH)
{ //&& ue_Mod_id == next_Mod_id) {
if (next_ra_frame > 500) { next_ra_frame++;
// check if we have PRACH opportunity if (next_ra_frame > 500)
if (is_prach_subframe(&UE->frame_parms, NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf)) && UE_mac_inst[ue_Mod_id].SI_Decoded == 1) { {
// The one working strangely... // check if we have PRACH opportunity
//if (is_prach_subframe(&UE->frame_parms,NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf) && Mod_id == (module_id_t) init_ra_UE) ) { if (is_prach_subframe(&UE->frame_parms, NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf)) && UE_mac_inst[ue_Mod_id].SI_Decoded == 1)
PRACH_RESOURCES_t *prach_resources = ue_get_rach(ue_Mod_id, 0, NFAPI_SFNSF2SFN(sfn_sf), 0, NFAPI_SFNSF2SF(sfn_sf)); {
// The one working strangely...
if (prach_resources != NULL) { //if (is_prach_subframe(&UE->frame_parms,NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf) && Mod_id == (module_id_t) init_ra_UE) ) {
LOG_I(MAC, "preamble_received_tar_power: %d\n", PRACH_RESOURCES_t *prach_resources = ue_get_rach(ue_Mod_id, 0, NFAPI_SFNSF2SFN(sfn_sf), 0, NFAPI_SFNSF2SF(sfn_sf));
prach_resources->ra_PREAMBLE_RECEIVED_TARGET_POWER); if (prach_resources != NULL)
UE_mac_inst[ue_Mod_id].ra_frame = NFAPI_SFNSF2SFN(sfn_sf); {
LOG_D(MAC, "UE_phy_stub_thread_rxn_txnp4 before RACH, Mod_id: %d frame %d subframe %d\n", ue_Mod_id, NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf)); LOG_I(MAC, "preamble_received_tar_power: %d\n",
fill_rach_indication_UE_MAC(ue_Mod_id, NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf), UL_INFO, prach_resources->ra_PreambleIndex, prach_resources->ra_RNTI); prach_resources->ra_PREAMBLE_RECEIVED_TARGET_POWER);
sent_any = true; UE_mac_inst[ue_Mod_id].ra_frame = NFAPI_SFNSF2SFN(sfn_sf);
Msg1_transmitted(ue_Mod_id, 0, NFAPI_SFNSF2SFN(sfn_sf), 0); LOG_D(MAC, "UE_phy_stub_thread_rxn_txnp4 before RACH, Mod_id: %d frame %d subframe %d\n", ue_Mod_id, NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf));
UE_mac_inst[ue_Mod_id].UE_mode[0] = RA_RESPONSE; fill_rach_indication_UE_MAC(ue_Mod_id, NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf), UL_INFO, prach_resources->ra_PreambleIndex, prach_resources->ra_RNTI);
next_Mod_id = ue_Mod_id + 1; sent_any = true;
//next_ra_frame = (rx_frame + 20)%1000; Msg1_transmitted(ue_Mod_id, 0, NFAPI_SFNSF2SFN(sfn_sf), 0);
next_ra_frame = 0; UE_mac_inst[ue_Mod_id].UE_mode[0] = RA_RESPONSE;
next_Mod_id = ue_Mod_id + 1;
//next_ra_frame = (rx_frame + 20)%1000;
next_ra_frame = 0;
}
//ue_prach_procedures(ue,proc,eNB_id,abstraction_flag,mode);
} }
//ue_prach_procedures(ue,proc,eNB_id,abstraction_flag,mode);
} }
} // mode is PRACH
// 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){
ul_config_req_UE_MAC(ul_config_req, NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf), ue_Mod_id);
} }
} // mode is PRACH
// 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){
ul_config_req_UE_MAC(ul_config_req, NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf), ue_Mod_id);
} }
} else {
LOG_I(MAC, "Skipping subframe select statement proxy SFN.SF: %d.%d\n",
NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf));
if (ul_config_req != NULL) { phy_procedures_UE_SL_RX(UE, proc);
}
else
{
LOG_I(MAC, "Skipping subframe select statement proxy SFN.SF: %d.%d\n",
NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf));
if (ul_config_req != NULL)
{
LOG_I(MAC, "Skipping subframe select statement ul_config_req SFN.SF: %d.%d\n", LOG_I(MAC, "Skipping subframe select statement ul_config_req SFN.SF: %d.%d\n",
NFAPI_SFNSF2SFN(ul_config_req->sfn_sf), NFAPI_SFNSF2SF(ul_config_req->sfn_sf)); NFAPI_SFNSF2SFN(ul_config_req->sfn_sf), NFAPI_SFNSF2SF(ul_config_req->sfn_sf));
} }
} }
/** TODO: FC */
if (1 /** UE is L2 Sim mode */) {
fill_ue_slot_indication_UE_MAC(ue_Mod_id, NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf), sfn_sf, UL_INFO);
}
} //for (Mod_id=0; Mod_id<NB_UE_INST; Mod_id++) } //for (Mod_id=0; Mod_id<NB_UE_INST; Mod_id++)
if (UL_INFO->crc_ind.crc_indication_body.number_of_crcs > 0) { if (UL_INFO->crc_ind.crc_indication_body.number_of_crcs > 0) {
...@@ -1179,10 +1279,12 @@ static void *UE_phy_stub_standalone_pnf_task(void *arg) { ...@@ -1179,10 +1279,12 @@ static void *UE_phy_stub_standalone_pnf_task(void *arg) {
} }
if (UL_INFO->rx_ind.rx_indication_body.number_of_pdus > 0) { if (UL_INFO->rx_ind.rx_indication_body.number_of_pdus > 0) {
//LOG_D(PHY,"UL_info->rx_ind.number_of_pdus:%d RX_IND:SFN/SF:%d\n", UL_info->rx_ind.rx_indication_body.number_of_pdus, NFAPI_SFNSF2DEC(UL_info->rx_ind.sfn_sf)); //LOG_D(PHY,"UL_info->rx_ind.number_of_pdus:%d RX_IND:SFN/SF:%d\n", UL_info->rx_ind.rx_indication_body.number_of_pdus, NFAPI_SFNSF2DEC(UL_info->rx_ind.sfn_sf));
//LOG_I(MAC, "ul_config_req_UE_MAC 2.3, SFN/SF of PNF counter:%d.%d, number_of_pdus: %d \n", timer_frame, timer_subframe, UL_INFO->rx_ind.rx_indication_body.number_of_pdus); //LOG_I(MAC, "ul_config_req_UE_MAC 2.3, SFN/SF of PNF counter:%d.%d, number_of_pdus: %d \n", timer_frame, timer_subframe, UL_INFO->rx_ind.rx_indication_body.number_of_pdus);
send_standalone_msg(UL_INFO, UL_INFO->rx_ind.header.message_id); send_standalone_msg(UL_INFO, UL_INFO->rx_ind.header.message_id);
sent_any = true; sent_any = true;
//LOG_I(MAC, "ul_config_req_UE_MAC 2.31 \n"); //LOG_I(MAC, "ul_config_req_UE_MAC 2.31 \n");
UL_INFO->rx_ind.rx_indication_body.number_of_pdus = 0; UL_INFO->rx_ind.rx_indication_body.number_of_pdus = 0;
} }
...@@ -1195,20 +1297,32 @@ static void *UE_phy_stub_standalone_pnf_task(void *arg) { ...@@ -1195,20 +1297,32 @@ static void *UE_phy_stub_standalone_pnf_task(void *arg) {
if (UL_INFO->harq_ind.harq_indication_body.number_of_harqs > 0) { if (UL_INFO->harq_ind.harq_indication_body.number_of_harqs > 0) {
//LOG_D(MAC, "ul_config_req_UE_MAC 2.4, SFN/SF of PNF counter:%d.%d, number_of_harqs: %d \n", timer_frame, timer_subframe, UL_INFO->harq_ind.harq_indication_body.number_of_harqs); //LOG_D(MAC, "ul_config_req_UE_MAC 2.4, SFN/SF of PNF counter:%d.%d, number_of_harqs: %d \n", timer_frame, timer_subframe, UL_INFO->harq_ind.harq_indication_body.number_of_harqs);
send_standalone_msg(UL_INFO, UL_INFO->harq_ind.header.message_id); send_standalone_msg(UL_INFO, UL_INFO->harq_ind.header.message_id);
sent_any = true; sent_any = true;
//LOG_I(MAC, "ul_config_req_UE_MAC 2.41 \n"); //LOG_I(MAC, "ul_config_req_UE_MAC 2.41 \n");
UL_INFO->harq_ind.harq_indication_body.number_of_harqs = 0; UL_INFO->harq_ind.harq_indication_body.number_of_harqs = 0;
} }
if (UL_INFO->sr_ind.sr_indication_body.number_of_srs > 0) { if (UL_INFO->sr_ind.sr_indication_body.number_of_srs > 0) {
//LOG_I(MAC, "ul_config_req_UE_MAC 2.5, SFN/SF of PNF counter:%d.%d, number_of_srs: %d \n", timer_frame, timer_subframe, UL_INFO->sr_ind.sr_indication_body.number_of_srs); //LOG_I(MAC, "ul_config_req_UE_MAC 2.5, SFN/SF of PNF counter:%d.%d, number_of_srs: %d \n", timer_frame, timer_subframe, UL_INFO->sr_ind.sr_indication_body.number_of_srs);
send_standalone_msg(UL_INFO, UL_INFO->sr_ind.header.message_id); send_standalone_msg(UL_INFO, UL_INFO->sr_ind.header.message_id);
sent_any = true; sent_any = true;
//LOG_I(MAC, "ul_config_req_UE_MAC 2.51 \n"); //LOG_I(MAC, "ul_config_req_UE_MAC 2.51 \n");
UL_INFO->sr_ind.sr_indication_body.number_of_srs = 0; UL_INFO->sr_ind.sr_indication_body.number_of_srs = 0;
} }
/** TODO: FC Send UE_SLOT.indication here after processing everything */
if ( 1 /** UE is SS mode */ && UL_INFO->vt_ue_sf_ind.sfn_sf >= 0)
{
LOG_D(MAC, "Sending UE_SLOT.indication at SFN: %d SF: %d for Ack'ing sfn: %d sf: %d \n",
NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf),
NFAPI_SFNSF2SFN(UL_INFO->vt_ue_sf_ind.sfn_sf),
NFAPI_SFNSF2SF(UL_INFO->vt_ue_sf_ind.sfn_sf));
send_standalone_msg(UL_INFO, UL_INFO->vt_ue_sf_ind.header.message_id);
sent_any = true;
UL_INFO->vt_ue_sf_ind.sfn_sf = 0;
}
// De-allocate memory of nfapi requests copies before next subframe round // De-allocate memory of nfapi requests copies before next subframe round
if (dl_config_req_tx_req != NULL) { if (dl_config_req_tx_req != NULL) {
if (dl_config_req_tx_req->dl_config_req->vendor_extension != NULL) { if (dl_config_req_tx_req->dl_config_req->vendor_extension != NULL) {
...@@ -1223,8 +1337,10 @@ static void *UE_phy_stub_standalone_pnf_task(void *arg) { ...@@ -1223,8 +1337,10 @@ static void *UE_phy_stub_standalone_pnf_task(void *arg) {
nfapi_free_tx_req_pdu_list(dl_config_req_tx_req->tx_req_pdu_list); nfapi_free_tx_req_pdu_list(dl_config_req_tx_req->tx_req_pdu_list);
dl_config_req_tx_req->tx_req_pdu_list = NULL; dl_config_req_tx_req->tx_req_pdu_list = NULL;
free(dl_config_req_tx_req->dl_config_req); free(dl_config_req_tx_req->dl_config_req);
dl_config_req_tx_req->dl_config_req = NULL; dl_config_req_tx_req->dl_config_req = NULL;
free(dl_config_req_tx_req); free(dl_config_req_tx_req);
dl_config_req_tx_req = NULL; dl_config_req_tx_req = NULL;
} }
...@@ -1248,9 +1364,9 @@ static void *UE_phy_stub_standalone_pnf_task(void *arg) { ...@@ -1248,9 +1364,9 @@ static void *UE_phy_stub_standalone_pnf_task(void *arg) {
free(hi_dci0_req); free(hi_dci0_req);
hi_dci0_req = NULL; hi_dci0_req = NULL;
} }
if (!sent_any)
if (!sent_any) { {
send_standalone_dummy(); send_standalone_dummy();
} }
} }
...@@ -1269,6 +1385,7 @@ static void *UE_phy_stub_standalone_pnf_task(void *arg) { ...@@ -1269,6 +1385,7 @@ static void *UE_phy_stub_standalone_pnf_task(void *arg) {
UL_INFO->rx_ind.rx_indication_body.rx_pdu_list = NULL; UL_INFO->rx_ind.rx_indication_body.rx_pdu_list = NULL;
free(UL_INFO); free(UL_INFO);
UL_INFO = NULL; UL_INFO = NULL;
// thread finished // thread finished
free(arg); free(arg);
return NULL; return NULL;
...@@ -1282,7 +1399,8 @@ static void *UE_phy_stub_standalone_pnf_task(void *arg) { ...@@ -1282,7 +1399,8 @@ static void *UE_phy_stub_standalone_pnf_task(void *arg) {
* \returns a pointer to an int. The storage is not on the heap and must not be freed. * \returns a pointer to an int. The storage is not on the heap and must not be freed.
*/ */
static void *UE_phy_stub_single_thread_rxn_txnp4(void *arg) { static void *UE_phy_stub_single_thread_rxn_txnp4(void *arg)
{
#if 0 // TODO: doesn't currently compile, obviated by multi-ue proxy #if 0 // TODO: doesn't currently compile, obviated by multi-ue proxy
thread_top_init("UE_phy_stub_thread_rxn_txnp4",1,870000L,1000000L,1000000L); thread_top_init("UE_phy_stub_thread_rxn_txnp4",1,870000L,1000000L,1000000L);
// for multipule UE's L2-emulator // for multipule UE's L2-emulator
...@@ -1308,6 +1426,7 @@ static void *UE_phy_stub_single_thread_rxn_txnp4(void *arg) { ...@@ -1308,6 +1426,7 @@ static void *UE_phy_stub_single_thread_rxn_txnp4(void *arg) {
proc = &PHY_vars_UE_g[0][0]->proc.proc_rxtx[0]; proc = &PHY_vars_UE_g[0][0]->proc.proc_rxtx[0];
phy_stub_ticking->num_single_thread[ue_thread_id] = -1; phy_stub_ticking->num_single_thread[ue_thread_id] = -1;
UE = rtd->UE; UE = rtd->UE;
UL_INFO = (UL_IND_t *)malloc(sizeof(UL_IND_t)); UL_INFO = (UL_IND_t *)malloc(sizeof(UL_IND_t));
UL_INFO->rx_ind.rx_indication_body.rx_pdu_list = calloc(NB_UE_INST, sizeof(nfapi_rx_indication_pdu_t)); UL_INFO->rx_ind.rx_indication_body.rx_pdu_list = calloc(NB_UE_INST, sizeof(nfapi_rx_indication_pdu_t));
UL_INFO->rx_ind.rx_indication_body.number_of_pdus = 0; UL_INFO->rx_ind.rx_indication_body.number_of_pdus = 0;
...@@ -1527,6 +1646,11 @@ static void *UE_phy_stub_single_thread_rxn_txnp4(void *arg) { ...@@ -1527,6 +1646,11 @@ static void *UE_phy_stub_single_thread_rxn_txnp4(void *arg) {
if ((subframe_select( &UE->frame_parms, proc->subframe_tx) == SF_UL) || if ((subframe_select( &UE->frame_parms, proc->subframe_tx) == SF_UL) ||
(UE->frame_parms.frame_type == FDD) ) (UE->frame_parms.frame_type == FDD) )
if (UE->mode != loop_through_memory) {
// We make the start of RA between consecutive UEs differ by 20 frames
//if ((UE_mac_inst[Mod_id].UE_mode[0] == PRACH && Mod_id == 0) || (UE_mac_inst[Mod_id].UE_mode[0] == PRACH && Mod_id>0 && proc->frame_rx >= UE_mac_inst[Mod_id-1].ra_frame + 20) ) {
if (UE_mac_inst[ue_Mod_id].UE_mode[0] == PRACH && ue_Mod_id == next_Mod_id) {
next_ra_frame++;
// We make the start of RA between consecutive UEs differ by 20 frames // We make the start of RA between consecutive UEs differ by 20 frames
//if ((UE_mac_inst[Mod_id].UE_mode[0] == PRACH && Mod_id == 0) || (UE_mac_inst[Mod_id].UE_mode[0] == PRACH && Mod_id>0 && proc->frame_rx >= UE_mac_inst[Mod_id-1].ra_frame + 20) ) { //if ((UE_mac_inst[Mod_id].UE_mode[0] == PRACH && Mod_id == 0) || (UE_mac_inst[Mod_id].UE_mode[0] == PRACH && Mod_id>0 && proc->frame_rx >= UE_mac_inst[Mod_id-1].ra_frame + 20) ) {
...@@ -1893,6 +2017,9 @@ void *UE_thread(void *arg) { ...@@ -1893,6 +2017,9 @@ void *UE_thread(void *arg) {
int ret; int ret;
cpu_set_t cpuset; cpu_set_t cpuset;
CPU_ZERO(&cpuset); CPU_ZERO(&cpuset);
if ( threads.main != -1 )
CPU_SET(threads.main, &cpuset);
init_thread(100000, 500000, FIFO_PRIORITY, &cpuset, "UHD Threads");
init_thread(100000, 500000, FIFO_PRIORITY, &cpuset, "UHD Threads"); init_thread(100000, 500000, FIFO_PRIORITY, &cpuset, "UHD Threads");
/* /*
...@@ -1917,6 +2044,12 @@ void *UE_thread(void *arg) { ...@@ -1917,6 +2044,12 @@ void *UE_thread(void *arg) {
log_scheduler(__func__); log_scheduler(__func__);
while (!oai_exit) { while (!oai_exit) {
if (IS_SOFTMODEM_BASICSIM)
while (!(UE->proc.instance_cnt_synch < 0)) {
printf("ue sync not ready\n");
usleep(500*1000);
}
AssertFatal ( 0== pthread_mutex_lock(&UE->proc.mutex_synch), ""); AssertFatal ( 0== pthread_mutex_lock(&UE->proc.mutex_synch), "");
int instance_cnt_synch = UE->proc.instance_cnt_synch; int instance_cnt_synch = UE->proc.instance_cnt_synch;
int is_synchronized = UE->is_synchronized; int is_synchronized = UE->is_synchronized;
...@@ -1973,6 +2106,10 @@ void *UE_thread(void *arg) { ...@@ -1973,6 +2106,10 @@ void *UE_thread(void *arg) {
AssertFatal ( 0== pthread_mutex_unlock(&UE->proc.mutex_synch), ""); AssertFatal ( 0== pthread_mutex_unlock(&UE->proc.mutex_synch), "");
} else { } else {
#if OAISIM
(void)dummy_rx; /* avoid gcc warnings */
usleep(500);
#else
// grab 10 ms of signal into dummy buffer // grab 10 ms of signal into dummy buffer
for (int i=0; i<UE->frame_parms.nb_antennas_rx; i++) for (int i=0; i<UE->frame_parms.nb_antennas_rx; i++)
rxp[i] = (void *)&dummy_rx[i][0]; rxp[i] = (void *)&dummy_rx[i][0];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment