CU is exectuable

This commit is contained in:
Raymond Knopp
2018-09-06 09:24:10 +02:00
parent 32a39e9a67
commit b2583c6f23
+114 -75
View File
@@ -986,13 +986,15 @@ int main( int argc, char **argv )
LOG_E(OPT,"failed to run OPT \n"); LOG_E(OPT,"failed to run OPT \n");
} }
if (RC.rrc[0]->node_type != ngran_eNB_DU) {
#ifdef PDCP_USE_NETLINK #ifdef PDCP_USE_NETLINK
printf("PDCP netlink\n"); printf("PDCP netlink\n");
netlink_init(); netlink_init();
#if defined(PDCP_USE_NETLINK_QUEUES) #if defined(PDCP_USE_NETLINK_QUEUES)
pdcp_netlink_init(); pdcp_netlink_init();
#endif #endif
#endif #endif
}
#if !defined(ENABLE_ITTI) #if !defined(ENABLE_ITTI)
// to make a graceful exit when ctrl-c is pressed // to make a graceful exit when ctrl-c is pressed
@@ -1059,21 +1061,23 @@ int main( int argc, char **argv )
#if defined(ENABLE_ITTI) int have_rrc=0;
if (RC.nb_inst > 0) { if (RC.nb_inst > 0) {
// don't create if node doesn't connect to RRC/S1/F1/GTP // don't create if node doesn't connect to RRC/S1/F1/GTP
if (create_tasks(1) < 0) { if (create_tasks(1) < 0) {
printf("cannot create ITTI tasks\n"); printf("cannot create ITTI tasks\n");
exit(-1); // need a softer mode exit(-1); // need a softer mode
} }
printf("ITTI tasks created\n"); printf("ITTI tasks created\n");
have_rrc=1;
} }
else { else {
printf("No ITTI, Initializing L1\n"); printf("No ITTI, Initializing L1\n");
RCconfig_L1(); RCconfig_L1();
} }
#endif
/* Start the agent. If it is turned off in the configuration, it won't start */ /* Start the agent. If it is turned off in the configuration, it won't start */
RCconfig_flexran(); RCconfig_flexran();
@@ -1081,22 +1085,48 @@ int main( int argc, char **argv )
flexran_agent_start(i); flexran_agent_start(i);
} }
// init UE_PF_PO and mutex lock int cu_flag =0;
pthread_mutex_init(&ue_pf_po_mutex, NULL);
memset (&UE_PF_PO[0][0], 0, sizeof(UE_PF_PO_t)*MAX_MOBILES_PER_ENB*MAX_NUM_CCs);
mlockall(MCL_CURRENT | MCL_FUTURE); if (have_rrc == 1) {
pthread_cond_init(&sync_cond,NULL); // wait for RRC to be initialized
pthread_mutex_init(&sync_mutex, NULL);
int rrc_allocated;
do {
rrc_allocated=1;
for (int i=0;i<RC.nb_inst;i++)
if (RC.rrc == NULL || RC.rrc[i]==NULL) rrc_allocated=0;
if (rrc_allocated==0) { printf("Waiting for RRC allocation ...\n"); usleep(10000); }
} while (rrc_allocated==0);
int cell_info_configured;
do {
pthread_mutex_lock(&RC.rrc[0]->cell_info_mutex);
cell_info_configured = RC.rrc[0]->cell_info_configured;
pthread_mutex_unlock(&RC.rrc[0]->cell_info_mutex);
if (cell_info_configured == 0) {printf ("Waiting for RRC cell configuration\n"); usleep(10000);}
} while(cell_info_configured == 0);
if (RC.rrc[0]->node_type == ngran_eNB_CU || RC.rrc[0]->node_type == ngran_ng_eNB_CU) cu_flag=1;
}
if (cu_flag == 0) {
// 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)*MAX_MOBILES_PER_ENB*MAX_NUM_CCs);
mlockall(MCL_CURRENT | MCL_FUTURE);
pthread_cond_init(&sync_cond,NULL);
pthread_mutex_init(&sync_mutex, NULL);
#ifdef XFORMS #ifdef XFORMS
int UE_id; int UE_id;
printf("XFORMS\n"); printf("XFORMS\n");
if (do_forms==1) { if (do_forms==1) {
fl_initialize (&argc, argv, NULL, 0, 0); fl_initialize (&argc, argv, NULL, 0, 0);
form_stats_l2 = create_form_stats_form(); form_stats_l2 = create_form_stats_form();
fl_show_form (form_stats_l2->stats_form, FL_PLACE_HOTSPOT, FL_FULLBORDER, "l2 stats"); fl_show_form (form_stats_l2->stats_form, FL_PLACE_HOTSPOT, FL_FULLBORDER, "l2 stats");
@@ -1119,28 +1149,28 @@ int main( int argc, char **argv )
} // CC_id } // CC_id
} // UE_id } // UE_id
ret = pthread_create(&forms_thread, NULL, scope_thread, NULL); ret = pthread_create(&forms_thread, NULL, scope_thread, NULL);
if (ret == 0) if (ret == 0)
pthread_setname_np( forms_thread, "xforms" ); pthread_setname_np( forms_thread, "xforms" );
printf("Scope thread created, ret=%d\n",ret); printf("Scope thread created, ret=%d\n",ret);
} }
#endif #endif
rt_sleep_ns(10*100000000ULL); rt_sleep_ns(10*100000000ULL);
if (nfapi_mode) if (nfapi_mode)
{ {
printf("NFAPI*** - mutex and cond created - will block shortly for completion of PNF connection\n"); printf("NFAPI*** - mutex and cond created - will block shortly for completion of PNF connection\n");
pthread_cond_init(&sync_cond,NULL); pthread_cond_init(&sync_cond,NULL);
pthread_mutex_init(&sync_mutex, NULL); pthread_mutex_init(&sync_mutex, NULL);
} }
const char *nfapi_mode_str = "<UNKNOWN>"; const char *nfapi_mode_str = "<UNKNOWN>";
switch(nfapi_mode) { switch(nfapi_mode) {
case 0: case 0:
nfapi_mode_str = "MONOLITHIC"; nfapi_mode_str = "MONOLITHIC";
break; break;
@@ -1153,15 +1183,16 @@ int main( int argc, char **argv )
default: default:
nfapi_mode_str = "<UNKNOWN NFAPI MODE>"; nfapi_mode_str = "<UNKNOWN NFAPI MODE>";
break; break;
} }
printf("NFAPI MODE:%s\n", nfapi_mode_str); printf("NFAPI MODE:%s\n", nfapi_mode_str);
if (nfapi_mode==2) // VNF if (nfapi_mode==2) // VNF
wait_nfapi_init("main?"); wait_nfapi_init("main?");
printf("START MAIN THREADS\n");
// start the main threads printf("START MAIN THREADS\n");
// start the main threads
number_of_cards = 1; number_of_cards = 1;
printf("RC.nb_L1_inst:%d\n", RC.nb_L1_inst); printf("RC.nb_L1_inst:%d\n", RC.nb_L1_inst);
@@ -1199,30 +1230,31 @@ int main( int argc, char **argv )
printf("ALL RUs ready - init eNBs\n"); printf("ALL RUs ready - init eNBs\n");
if (nfapi_mode != 1 && nfapi_mode != 2) if (nfapi_mode != 1 && nfapi_mode != 2)
{ {
printf("Not NFAPI mode - call init_eNB_afterRU()\n"); printf("Not NFAPI mode - call init_eNB_afterRU()\n");
init_eNB_afterRU(); init_eNB_afterRU();
} }
else else
{ {
printf("NFAPI mode - DO NOT call init_eNB_afterRU()\n"); printf("NFAPI mode - DO NOT call init_eNB_afterRU()\n");
} }
printf("ALL RUs ready - ALL eNBs ready\n"); printf("ALL RUs ready - ALL eNBs ready\n");
// connect the TX/RX buffers // connect the TX/RX buffers
sleep(1); /* wait for thread activation */ sleep(1); /* wait for thread activation */
printf("Sending sync to all threads\n"); printf("Sending sync to all threads\n");
pthread_mutex_lock(&sync_mutex); pthread_mutex_lock(&sync_mutex);
sync_var=0; sync_var=0;
pthread_cond_broadcast(&sync_cond); pthread_cond_broadcast(&sync_cond);
pthread_mutex_unlock(&sync_mutex); pthread_mutex_unlock(&sync_mutex);
}
// wait for end of program // wait for end of program
printf("TYPE <CTRL-C> TO TERMINATE\n"); printf("TYPE <CTRL-C> TO TERMINATE\n");
//getchar(); //getchar();
@@ -1241,13 +1273,17 @@ int main( int argc, char **argv )
#endif #endif
// stop threads // stop threads
#ifdef XFORMS
printf("waiting for XFORMS thread\n");
if (do_forms==1) {
pthread_join(forms_thread,&status); if (cu_flag == 0) {
fl_hide_form(form_stats->stats_form); int UE_id;
fl_free_form(form_stats->stats_form); #ifdef XFORMS
printf("waiting for XFORMS thread\n");
if (do_forms==1) {
pthread_join(forms_thread,&status);
fl_hide_form(form_stats->stats_form);
fl_free_form(form_stats->stats_form);
fl_hide_form(form_stats_l2->stats_form); fl_hide_form(form_stats_l2->stats_form);
fl_free_form(form_stats_l2->stats_form); fl_free_form(form_stats_l2->stats_form);
@@ -1258,16 +1294,16 @@ int main( int argc, char **argv )
fl_free_form(form_enb[CC_id][UE_id]->lte_phy_scope_enb); fl_free_form(form_enb[CC_id][UE_id]->lte_phy_scope_enb);
} }
} }
} }
#endif #endif
printf("stopping MODEM threads\n"); printf("stopping MODEM threads\n");
// cleanup // cleanup
for (ru_id=0;ru_id<RC.nb_RU;ru_id++) { for (ru_id=0;ru_id<RC.nb_RU;ru_id++) {
stop_ru(RC.ru[ru_id]); stop_ru(RC.ru[ru_id]);
} }
stop_eNB(NB_eNB_INST); stop_eNB(NB_eNB_INST);
stop_RU(RC.nb_RU); stop_RU(RC.nb_RU);
@@ -1284,19 +1320,16 @@ int main( int argc, char **argv )
} }
free_lte_top(); free_lte_top();
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__);
pthread_cond_destroy(&sync_cond); pthread_cond_destroy(&sync_cond);
pthread_mutex_destroy(&sync_mutex); pthread_mutex_destroy(&sync_mutex);
pthread_cond_destroy(&nfapi_sync_cond); pthread_cond_destroy(&nfapi_sync_cond);
pthread_mutex_destroy(&nfapi_sync_mutex); pthread_mutex_destroy(&nfapi_sync_mutex);
pthread_mutex_destroy(&ue_pf_po_mutex); pthread_mutex_destroy(&ue_pf_po_mutex);
// *** Handle per CC_id openair0 // *** Handle per CC_id openair0
for(ru_id=0; ru_id<RC.nb_RU; ru_id++) { for(ru_id=0; ru_id<RC.nb_RU; ru_id++) {
@@ -1309,6 +1342,12 @@ int main( int argc, char **argv )
RC.ru[ru_id]->ifdevice.trx_end_func = NULL; RC.ru[ru_id]->ifdevice.trx_end_func = NULL;
} }
} }
}
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__);
if (opt_enabled == 1) if (opt_enabled == 1)
terminate_opt(); terminate_opt();