Commit 89df5c91 authored by winckel's avatar winckel

Modified eNB app to be compatible with lte-softmodem build.

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@4581 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent 68909776
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
Address : EURECOM, Campus SophiaTech, 450 Route des Chappes Address : EURECOM, Campus SophiaTech, 450 Route des Chappes
06410 Biot FRANCE 06410 Biot FRANCE
*******************************************************************************/ *******************************************************************************/
#include <string.h> #include <string.h>
...@@ -51,22 +51,40 @@ ...@@ -51,22 +51,40 @@
#if defined(ENABLE_ITTI) #if defined(ENABLE_ITTI)
# if defined(ENABLE_USE_MME) # if defined(ENABLE_USE_MME)
/*------------------------------------------------------------------------------*/
#define ENB_REGISTER_RETRY_DELAY 10 #define ENB_REGISTER_RETRY_DELAY 10
/*------------------------------------------------------------------------------*/
static uint32_t enb_nb = 1;
/*------------------------------------------------------------------------------*/
static uint32_t eNB_app_register() static uint32_t eNB_app_register()
{ {
uint32_t eNB_id_start = 0;
uint32_t eNB_id_end = 1;
uint32_t eNB_id; uint32_t eNB_id;
MessageDef *msg_p; MessageDef *msg_p;
uint32_t register_enb_pending = 0; uint32_t register_enb_pending = 0;
for (eNB_id = oai_emulation.info.first_enb_local; # if defined(OAI_EMU)
(eNB_id < (oai_emulation.info.first_enb_local + oai_emulation.info.nb_enb_local)) && (oai_emulation.info.cli_start_enb[eNB_id] == 1); eNB_id_start = oai_emulation.info.first_enb_local;
eNB_id++) { eNB_id_end = oai_emulation.info.first_enb_local + oai_emulation.info.nb_enb_local;
# endif
for (eNB_id = eNB_id_start; (eNB_id < eNB_id_end)
# if defined(OAI_EMU)
&& (oai_emulation.info.cli_start_enb[eNB_id] == 1)
# endif
; eNB_id++)
{
char *mme_address_v4; char *mme_address_v4;
if (EPC_MODE_ENABLED){ if (EPC_MODE_ENABLED)
{
mme_address_v4 = EPC_MODE_MME_ADDRESS; mme_address_v4 = EPC_MODE_MME_ADDRESS;
} else { }
else
{
mme_address_v4 = "192.168.12.87"; mme_address_v4 = "192.168.12.87";
} }
char *mme_address_v6 = "2001:660:5502:12:30da:829a:2343:b6cf"; char *mme_address_v6 = "2001:660:5502:12:30da:829a:2343:b6cf";
...@@ -74,11 +92,11 @@ static uint32_t eNB_app_register() ...@@ -74,11 +92,11 @@ static uint32_t eNB_app_register()
uint32_t hash; uint32_t hash;
//note: there is an implicit relationship between the data struct and the message name //note: there is an implicit relationship between the data struct and the message name
msg_p = itti_alloc_new_message(TASK_ENB_APP, S1AP_REGISTER_ENB_REQ); msg_p = itti_alloc_new_message (TASK_ENB_APP, S1AP_REGISTER_ENB_REQ);
s1ap_register_eNB = &S1AP_REGISTER_ENB_REQ(msg_p); s1ap_register_eNB = &S1AP_REGISTER_ENB_REQ(msg_p);
hash = s1ap_generate_eNB_id(); hash = s1ap_generate_eNB_id ();
/* Some default/random parameters */ /* Some default/random parameters */
s1ap_register_eNB->eNB_id = eNB_id + (hash & 0xFFFF8); s1ap_register_eNB->eNB_id = eNB_id + (hash & 0xFFFF8);
...@@ -91,8 +109,8 @@ static uint32_t eNB_app_register() ...@@ -91,8 +109,8 @@ static uint32_t eNB_app_register()
s1ap_register_eNB->nb_mme = 1; s1ap_register_eNB->nb_mme = 1;
s1ap_register_eNB->mme_ip_address[0].ipv4 = 1; s1ap_register_eNB->mme_ip_address[0].ipv4 = 1;
s1ap_register_eNB->mme_ip_address[0].ipv6 = 0; s1ap_register_eNB->mme_ip_address[0].ipv6 = 0;
memcpy(s1ap_register_eNB->mme_ip_address[0].ipv4_address, mme_address_v4, strlen(mme_address_v4)); memcpy (s1ap_register_eNB->mme_ip_address[0].ipv4_address, mme_address_v4, strlen (mme_address_v4));
memcpy(s1ap_register_eNB->mme_ip_address[0].ipv6_address, mme_address_v6, strlen(mme_address_v6)); memcpy (s1ap_register_eNB->mme_ip_address[0].ipv6_address, mme_address_v6, strlen (mme_address_v6));
# if defined ENB_APP_ENB_REGISTER_2_MME # if defined ENB_APP_ENB_REGISTER_2_MME
s1ap_register_eNB->nb_mme = 2; s1ap_register_eNB->nb_mme = 2;
...@@ -103,9 +121,9 @@ static uint32_t eNB_app_register() ...@@ -103,9 +121,9 @@ static uint32_t eNB_app_register()
memcpy(s1ap_register_eNB->mme_ip_address[1].ipv6_address, mme_address_v6, strlen(mme_address_v6)); memcpy(s1ap_register_eNB->mme_ip_address[1].ipv6_address, mme_address_v6, strlen(mme_address_v6));
# endif # endif
itti_send_msg_to_task(TASK_S1AP, eNB_id, msg_p); itti_send_msg_to_task (TASK_S1AP, eNB_id, msg_p);
register_enb_pending ++; register_enb_pending++;
} }
return register_enb_pending; return register_enb_pending;
...@@ -113,7 +131,9 @@ static uint32_t eNB_app_register() ...@@ -113,7 +131,9 @@ static uint32_t eNB_app_register()
# endif # endif
#endif #endif
void *eNB_app_task(void *args_p) { /*------------------------------------------------------------------------------*/
void *eNB_app_task(void *args_p)
{
#if defined(ENABLE_ITTI) #if defined(ENABLE_ITTI)
# if defined(ENABLE_USE_MME) # if defined(ENABLE_USE_MME)
static uint32_t register_enb_pending; static uint32_t register_enb_pending;
...@@ -125,23 +145,30 @@ void *eNB_app_task(void *args_p) { ...@@ -125,23 +145,30 @@ void *eNB_app_task(void *args_p) {
instance_t instance; instance_t instance;
itti_mark_task_ready (TASK_ENB_APP); itti_mark_task_ready (TASK_ENB_APP);
# if defined(OAI_EMU)
enb_nb = oai_emulation.info.nb_enb_local;
# endif
# if defined(ENABLE_USE_MME) # if defined(ENABLE_USE_MME)
/* Try to register each eNB */ /* Try to register each eNB */
registered_enb = 0; registered_enb = 0;
register_enb_pending = eNB_app_register(); register_enb_pending = eNB_app_register ();
# else # else
/* Start L2L1 task */
msg_p = itti_alloc_new_message(TASK_ENB_APP, INITIALIZE_MESSAGE); msg_p = itti_alloc_new_message(TASK_ENB_APP, INITIALIZE_MESSAGE);
itti_send_msg_to_task(TASK_L2L1, INSTANCE_DEFAULT, msg_p); itti_send_msg_to_task(TASK_L2L1, INSTANCE_DEFAULT, msg_p);
# endif # endif
do { do
{
// Wait for a message // Wait for a message
itti_receive_msg (TASK_ENB_APP, &msg_p); itti_receive_msg (TASK_ENB_APP, &msg_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);
switch (ITTI_MSG_ID(msg_p)) { switch (ITTI_MSG_ID(msg_p))
{
case TERMINATE_MESSAGE: case TERMINATE_MESSAGE:
itti_exit_task (); itti_exit_task ();
break; break;
...@@ -152,33 +179,40 @@ void *eNB_app_task(void *args_p) { ...@@ -152,33 +179,40 @@ void *eNB_app_task(void *args_p) {
# if defined(ENABLE_USE_MME) # if defined(ENABLE_USE_MME)
case S1AP_REGISTER_ENB_CNF: case S1AP_REGISTER_ENB_CNF:
LOG_I(EMU, "[eNB %d] Received %s: associated MME %d\n", instance, msg_name, S1AP_REGISTER_ENB_CNF(msg_p).nb_mme); LOG_I(EMU,
"[eNB %d] Received %s: associated MME %d\n", instance, msg_name, S1AP_REGISTER_ENB_CNF(msg_p).nb_mme);
DevAssert(register_enb_pending > 0); DevAssert(register_enb_pending > 0);
register_enb_pending--; register_enb_pending--;
/* Check if at least eNB is registered with one MME */ /* Check if at least eNB is registered with one MME */
if (S1AP_REGISTER_ENB_CNF(msg_p).nb_mme > 0) { if (S1AP_REGISTER_ENB_CNF(msg_p).nb_mme > 0)
registered_enb ++; {
registered_enb++;
} }
/* Check if all register eNB requests have been processed */ /* Check if all register eNB requests have been processed */
if (register_enb_pending == 0) { if (register_enb_pending == 0)
if (registered_enb == oai_emulation.info.nb_enb_local) { {
if (registered_enb == enb_nb)
{
/* If all eNB are registered, start L2L1 task */ /* If all eNB are registered, start L2L1 task */
MessageDef *msg_init_p; MessageDef *msg_init_p;
msg_init_p = itti_alloc_new_message (TASK_ENB_APP, INITIALIZE_MESSAGE); msg_init_p = itti_alloc_new_message (TASK_ENB_APP, INITIALIZE_MESSAGE);
itti_send_msg_to_task (TASK_L2L1, INSTANCE_DEFAULT, msg_init_p); itti_send_msg_to_task (TASK_L2L1, INSTANCE_DEFAULT, msg_init_p);
} }
else { else
uint32_t not_associated = oai_emulation.info.nb_enb_local - registered_enb; {
uint32_t not_associated = enb_nb - registered_enb;
LOG_W(EMU, " %d eNB %s not associated with a MME, retrying registration in %d seconds ...\n", LOG_W(EMU, " %d eNB %s not associated with a MME, retrying registration in %d seconds ...\n",
not_associated, not_associated > 1 ? "are" : "is", ENB_REGISTER_RETRY_DELAY); not_associated, not_associated > 1 ? "are" : "is", ENB_REGISTER_RETRY_DELAY);
/* Restart the eNB registration process in ENB_REGISTER_RETRY_DELAY seconds */ /* Restart the eNB registration process in ENB_REGISTER_RETRY_DELAY seconds */
if (timer_setup (ENB_REGISTER_RETRY_DELAY, 0, TASK_ENB_APP, INSTANCE_DEFAULT, TIMER_ONE_SHOT, NULL, &enb_register_retry_timer_id) < 0) { if (timer_setup (ENB_REGISTER_RETRY_DELAY, 0, TASK_ENB_APP, INSTANCE_DEFAULT, TIMER_ONE_SHOT,
NULL, &enb_register_retry_timer_id) < 0)
{
LOG_E(EMU, " Can not start eNB register retry timer!\n"); LOG_E(EMU, " Can not start eNB register retry timer!\n");
} }
} }
...@@ -188,10 +222,11 @@ void *eNB_app_task(void *args_p) { ...@@ -188,10 +222,11 @@ void *eNB_app_task(void *args_p) {
case TIMER_HAS_EXPIRED: case TIMER_HAS_EXPIRED:
LOG_I(EMU, " Received %s: timer_id %d\n", msg_name, TIMER_HAS_EXPIRED(msg_p).timer_id); LOG_I(EMU, " Received %s: timer_id %d\n", msg_name, TIMER_HAS_EXPIRED(msg_p).timer_id);
if (TIMER_HAS_EXPIRED(msg_p).timer_id == enb_register_retry_timer_id) { if (TIMER_HAS_EXPIRED (msg_p).timer_id == enb_register_retry_timer_id)
{
/* Restart the registration process */ /* Restart the registration process */
registered_enb = 0; registered_enb = 0;
register_enb_pending = eNB_app_register(); register_enb_pending = eNB_app_register ();
} }
break; break;
# endif # endif
...@@ -202,7 +237,7 @@ void *eNB_app_task(void *args_p) { ...@@ -202,7 +237,7 @@ void *eNB_app_task(void *args_p) {
} }
free (msg_p); free (msg_p);
} while(1); } while (1);
#endif #endif
return NULL; return NULL;
......
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