Commit 393fe865 authored by Cedric Roux's avatar Cedric Roux

fix: pass UE parameter to UE threads

oaisim is not functional with several UEs.
This fixes one issue. (It's still not functional for other reasons.)
parent 157707b0
...@@ -150,6 +150,7 @@ void *nas_ue_task(void *args_p) ...@@ -150,6 +150,7 @@ void *nas_ue_task(void *args_p)
msg_name = ITTI_MSG_NAME (msg_p); msg_name = ITTI_MSG_NAME (msg_p);
instance = ITTI_MSG_INSTANCE (msg_p); instance = ITTI_MSG_INSTANCE (msg_p);
Mod_id = instance - NB_eNB_INST; Mod_id = instance - NB_eNB_INST;
if (instance == INSTANCE_DEFAULT) abort();
nas_user_t *user = &users->item[Mod_id]; nas_user_t *user = &users->item[Mod_id];
switch (ITTI_MSG_ID(msg_p)) { switch (ITTI_MSG_ID(msg_p)) {
......
...@@ -186,7 +186,7 @@ void init_UE(int nb_inst) { ...@@ -186,7 +186,7 @@ void init_UE(int nb_inst) {
} }
UE->rfdevice.host_type = BBU_HOST; UE->rfdevice.host_type = BBU_HOST;
// UE->rfdevice.type = NONE_DEV; // UE->rfdevice.type = NONE_DEV;
error_code = pthread_create(&UE->proc.pthread_ue, &UE->proc.attr_ue, UE_thread, NULL); error_code = pthread_create(&UE->proc.pthread_ue, &UE->proc.attr_ue, UE_thread, UE);
if (error_code!= 0) { if (error_code!= 0) {
LOG_D(HW,"[lte-softmodem.c] Could not allocate UE_thread, error %d\n",error_code); LOG_D(HW,"[lte-softmodem.c] Could not allocate UE_thread, error %d\n",error_code);
...@@ -599,6 +599,14 @@ static void *UE_thread_synch(void *arg) ...@@ -599,6 +599,14 @@ static void *UE_thread_synch(void *arg)
} }
/* this structure is used to pass both UE phy vars and
* proc to the function UE_thread_rxn_txnp4
*/
struct rx_tx_thread_data {
PHY_VARS_UE *UE;
UE_rxtx_proc_t *proc;
};
/*! /*!
* \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.
...@@ -611,9 +619,10 @@ static void *UE_thread_synch(void *arg) ...@@ -611,9 +619,10 @@ static void *UE_thread_synch(void *arg)
static void *UE_thread_rxn_txnp4(void *arg) static void *UE_thread_rxn_txnp4(void *arg)
{ {
static int UE_thread_rxtx_retval; static int UE_thread_rxtx_retval;
UE_rxtx_proc_t *proc = (UE_rxtx_proc_t *)arg; struct rx_tx_thread_data *rtd = arg;
UE_rxtx_proc_t *proc = rtd->proc;
PHY_VARS_UE *UE = rtd->UE;
int ret; int ret;
PHY_VARS_UE *UE=PHY_vars_UE_g[0][proc->CC_id];
proc->instance_cnt_rxtx=-1; proc->instance_cnt_rxtx=-1;
...@@ -849,6 +858,7 @@ static void *UE_thread_rxn_txnp4(void *arg) ...@@ -849,6 +858,7 @@ static void *UE_thread_rxn_txnp4(void *arg)
} }
// thread finished // thread finished
free(arg);
return &UE_thread_rxtx_retval; return &UE_thread_rxtx_retval;
} }
...@@ -873,7 +883,7 @@ static void *UE_thread_rxn_txnp4(void *arg) ...@@ -873,7 +883,7 @@ static void *UE_thread_rxn_txnp4(void *arg)
void *UE_thread(void *arg) { void *UE_thread(void *arg) {
static int UE_thread_retval; static int UE_thread_retval;
PHY_VARS_UE *UE = PHY_vars_UE_g[0][0]; PHY_VARS_UE *UE = arg; //PHY_vars_UE_g[0][0];
// int tx_enabled = 0; // int tx_enabled = 0;
uint32_t rxs=0,txs=0; uint32_t rxs=0,txs=0;
int dummy_rx[UE->frame_parms.nb_antennas_rx][UE->frame_parms.samples_per_tti] __attribute__((aligned(32))); int dummy_rx[UE->frame_parms.nb_antennas_rx][UE->frame_parms.samples_per_tti] __attribute__((aligned(32)));
...@@ -936,7 +946,7 @@ void *UE_thread(void *arg) { ...@@ -936,7 +946,7 @@ void *UE_thread(void *arg) {
#ifdef NAS_UE #ifdef NAS_UE
message_p = itti_alloc_new_message(TASK_NAS_UE, INITIALIZE_MESSAGE); message_p = itti_alloc_new_message(TASK_NAS_UE, INITIALIZE_MESSAGE);
itti_send_msg_to_task (TASK_NAS_UE, INSTANCE_DEFAULT, message_p); itti_send_msg_to_task (TASK_NAS_UE, UE->Mod_id + NB_eNB_INST, message_p);
#endif #endif
while (!oai_exit) { while (!oai_exit) {
...@@ -1650,8 +1660,9 @@ void *UE_thread_old(void *arg) ...@@ -1650,8 +1660,9 @@ void *UE_thread_old(void *arg)
*/ */
void init_UE_threads(int inst) void init_UE_threads(int inst)
{ {
struct rx_tx_thread_data *rtd;
PHY_VARS_UE *UE; PHY_VARS_UE *UE;
UE = PHY_vars_UE_g[inst][0]; UE = PHY_vars_UE_g[inst][0];
pthread_attr_init (&UE->proc.attr_ue); pthread_attr_init (&UE->proc.attr_ue);
...@@ -1674,9 +1685,17 @@ void init_UE_threads(int inst) ...@@ -1674,9 +1685,17 @@ void init_UE_threads(int inst)
pthread_cond_init(&UE->proc.proc_rxtx[0].cond_rxtx,NULL); pthread_cond_init(&UE->proc.proc_rxtx[0].cond_rxtx,NULL);
pthread_cond_init(&UE->proc.proc_rxtx[1].cond_rxtx,NULL); pthread_cond_init(&UE->proc.proc_rxtx[1].cond_rxtx,NULL);
pthread_cond_init(&UE->proc.cond_synch,NULL); pthread_cond_init(&UE->proc.cond_synch,NULL);
pthread_create(&UE->proc.proc_rxtx[0].pthread_rxtx,NULL,UE_thread_rxn_txnp4,(void*)&UE->proc.proc_rxtx[0]); rtd = calloc(1, sizeof(struct rx_tx_thread_data));
if (rtd == NULL) abort();
rtd->UE = PHY_vars_UE_g[inst][UE->proc.proc_rxtx[0].CC_id];
rtd->proc = &UE->proc.proc_rxtx[0];
pthread_create(&UE->proc.proc_rxtx[0].pthread_rxtx,NULL,UE_thread_rxn_txnp4,rtd);//(void*)&UE->proc.proc_rxtx[0]);
pthread_setname_np( UE->proc.proc_rxtx[0].pthread_rxtx, "rxn_txnp4_even" ); pthread_setname_np( UE->proc.proc_rxtx[0].pthread_rxtx, "rxn_txnp4_even" );
pthread_create(&UE->proc.proc_rxtx[1].pthread_rxtx,NULL,UE_thread_rxn_txnp4,(void*)&UE->proc.proc_rxtx[1]); rtd = calloc(1, sizeof(struct rx_tx_thread_data));
if (rtd == NULL) abort();
rtd->UE = PHY_vars_UE_g[inst][UE->proc.proc_rxtx[1].CC_id];
rtd->proc = &UE->proc.proc_rxtx[1];
pthread_create(&UE->proc.proc_rxtx[1].pthread_rxtx,NULL,UE_thread_rxn_txnp4,rtd);//(void*)&UE->proc.proc_rxtx[1]);
pthread_setname_np( UE->proc.proc_rxtx[1].pthread_rxtx, "rxn_txnp4_odd" ); pthread_setname_np( UE->proc.proc_rxtx[1].pthread_rxtx, "rxn_txnp4_odd" );
pthread_create(&UE->proc.pthread_synch,NULL,UE_thread_synch,(void*)UE); pthread_create(&UE->proc.pthread_synch,NULL,UE_thread_synch,(void*)UE);
pthread_setname_np( UE->proc.pthread_synch, "UE_thread_synch" ); pthread_setname_np( UE->proc.pthread_synch, "UE_thread_synch" );
......
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