Commit 47ca7e89 authored by winckel's avatar winckel

Reorganized eNB configuration code.

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@5012 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent 7d154e4c
......@@ -60,44 +60,40 @@ extern char *g_conf_config_file_name;
# endif
/*------------------------------------------------------------------------------*/
static Enb_properties_t *enb_properties[MAX_ENB];
static int enb_nb_properties;
/*------------------------------------------------------------------------------*/
static void configure_phy(uint32_t enb_id)
static void configure_phy(uint32_t enb_id, const Enb_properties_array_t *enb_properties)
{
MessageDef *msg_p;
msg_p = itti_alloc_new_message (TASK_ENB_APP, PHY_CONFIGURATION_REQ);
PHY_CONFIGURATION_REQ (msg_p).frame_type = enb_properties[enb_id]->frame_type;
PHY_CONFIGURATION_REQ (msg_p).prefix_type = enb_properties[enb_id]->prefix_type;
PHY_CONFIGURATION_REQ (msg_p).downlink_frequency = enb_properties[enb_id]->downlink_frequency;
PHY_CONFIGURATION_REQ (msg_p).uplink_frequency_offset = enb_properties[enb_id]->uplink_frequency_offset;
PHY_CONFIGURATION_REQ (msg_p).frame_type = enb_properties->properties[enb_id]->frame_type;
PHY_CONFIGURATION_REQ (msg_p).prefix_type = enb_properties->properties[enb_id]->prefix_type;
PHY_CONFIGURATION_REQ (msg_p).downlink_frequency = enb_properties->properties[enb_id]->downlink_frequency;
PHY_CONFIGURATION_REQ (msg_p).uplink_frequency_offset = enb_properties->properties[enb_id]->uplink_frequency_offset;
itti_send_msg_to_task (TASK_PHY_ENB, enb_id, msg_p);
}
/*------------------------------------------------------------------------------*/
static void configure_rrc(uint32_t enb_id)
static void configure_rrc(uint32_t enb_id, const Enb_properties_array_t *enb_properties)
{
MessageDef *msg_p;
msg_p = itti_alloc_new_message (TASK_ENB_APP, RRC_CONFIGURATION_REQ);
RRC_CONFIGURATION_REQ (msg_p).cell_identity = enb_properties[enb_id]->eNB_id;
RRC_CONFIGURATION_REQ (msg_p).tac = enb_properties[enb_id]->tac;
RRC_CONFIGURATION_REQ (msg_p).mcc = enb_properties[enb_id]->mcc;
RRC_CONFIGURATION_REQ (msg_p).mnc = enb_properties[enb_id]->mnc;
RRC_CONFIGURATION_REQ (msg_p).default_drx = enb_properties[enb_id]->default_drx;
RRC_CONFIGURATION_REQ (msg_p).frame_type = enb_properties[enb_id]->frame_type;
RRC_CONFIGURATION_REQ (msg_p).cell_identity = enb_properties->properties[enb_id]->eNB_id;
RRC_CONFIGURATION_REQ (msg_p).tac = enb_properties->properties[enb_id]->tac;
RRC_CONFIGURATION_REQ (msg_p).mcc = enb_properties->properties[enb_id]->mcc;
RRC_CONFIGURATION_REQ (msg_p).mnc = enb_properties->properties[enb_id]->mnc;
RRC_CONFIGURATION_REQ (msg_p).default_drx = enb_properties->properties[enb_id]->default_drx;
RRC_CONFIGURATION_REQ (msg_p).frame_type = enb_properties->properties[enb_id]->frame_type;
itti_send_msg_to_task (TASK_RRC_ENB, enb_id, msg_p);
}
/*------------------------------------------------------------------------------*/
# if defined(ENABLE_USE_MME)
static uint32_t eNB_app_register(uint32_t enb_id_start, uint32_t enb_id_end)
static uint32_t eNB_app_register(uint32_t enb_id_start, uint32_t enb_id_end, const Enb_properties_array_t *enb_properties)
{
uint32_t enb_id;
uint32_t mme_id;
......@@ -122,26 +118,26 @@ static uint32_t eNB_app_register(uint32_t enb_id_start, uint32_t enb_id_end)
s1ap_register_eNB = &S1AP_REGISTER_ENB_REQ(msg_p);
/* Some default/random parameters */
s1ap_register_eNB->eNB_id = enb_properties[enb_id]->eNB_id;
s1ap_register_eNB->cell_type = enb_properties[enb_id]->cell_type;
s1ap_register_eNB->eNB_name = enb_properties[enb_id]->eNB_name;
s1ap_register_eNB->tac = enb_properties[enb_id]->tac;
s1ap_register_eNB->mcc = enb_properties[enb_id]->mcc;
s1ap_register_eNB->mnc = enb_properties[enb_id]->mnc;
s1ap_register_eNB->default_drx = enb_properties[enb_id]->default_drx;
s1ap_register_eNB->nb_mme = enb_properties[enb_id]->nb_mme;
s1ap_register_eNB->eNB_id = enb_properties->properties[enb_id]->eNB_id;
s1ap_register_eNB->cell_type = enb_properties->properties[enb_id]->cell_type;
s1ap_register_eNB->eNB_name = enb_properties->properties[enb_id]->eNB_name;
s1ap_register_eNB->tac = enb_properties->properties[enb_id]->tac;
s1ap_register_eNB->mcc = enb_properties->properties[enb_id]->mcc;
s1ap_register_eNB->mnc = enb_properties->properties[enb_id]->mnc;
s1ap_register_eNB->default_drx = enb_properties->properties[enb_id]->default_drx;
s1ap_register_eNB->nb_mme = enb_properties->properties[enb_id]->nb_mme;
AssertFatal (s1ap_register_eNB->nb_mme <= S1AP_MAX_NB_MME_IP_ADDRESS, "Too many MME for eNB %d (%d/%d)!", enb_id, s1ap_register_eNB->nb_mme, S1AP_MAX_NB_MME_IP_ADDRESS);
for (mme_id = 0; mme_id < s1ap_register_eNB->nb_mme; mme_id++)
{
s1ap_register_eNB->mme_ip_address[mme_id].ipv4 = enb_properties[enb_id]->mme_ip_address[mme_id].ipv4;
s1ap_register_eNB->mme_ip_address[mme_id].ipv6 = enb_properties[enb_id]->mme_ip_address[mme_id].ipv6;
s1ap_register_eNB->mme_ip_address[mme_id].ipv4 = enb_properties->properties[enb_id]->mme_ip_address[mme_id].ipv4;
s1ap_register_eNB->mme_ip_address[mme_id].ipv6 = enb_properties->properties[enb_id]->mme_ip_address[mme_id].ipv6;
strncpy (s1ap_register_eNB->mme_ip_address[mme_id].ipv4_address,
enb_properties[enb_id]->mme_ip_address[mme_id].ipv4_address,
enb_properties->properties[enb_id]->mme_ip_address[mme_id].ipv4_address,
sizeof(s1ap_register_eNB->mme_ip_address[0].ipv4_address));
strncpy (s1ap_register_eNB->mme_ip_address[mme_id].ipv6_address,
enb_properties[enb_id]->mme_ip_address[mme_id].ipv6_address,
enb_properties->properties[enb_id]->mme_ip_address[mme_id].ipv6_address,
sizeof(s1ap_register_eNB->mme_ip_address[0].ipv6_address));
}
......@@ -159,20 +155,21 @@ static uint32_t eNB_app_register(uint32_t enb_id_start, uint32_t enb_id_end)
/*------------------------------------------------------------------------------*/
void *eNB_app_task(void *args_p)
{
const Enb_properties_array_t *enb_properties;
#if defined(ENABLE_ITTI)
uint32_t enb_nb = 1; /* Default number of eNB is 1 */
uint32_t enb_id_start = 0;
uint32_t enb_id_end = enb_id_start + enb_nb;
uint32_t enb_nb = 1; /* Default number of eNB is 1 */
uint32_t enb_id_start = 0;
uint32_t enb_id_end = enb_id_start + enb_nb;
# if defined(ENABLE_USE_MME)
uint32_t register_enb_pending;
uint32_t registered_enb;
long enb_register_retry_timer_id;
uint32_t register_enb_pending;
uint32_t registered_enb;
long enb_register_retry_timer_id;
# endif
uint32_t enb_id;
MessageDef *msg_p;
const char *msg_name;
instance_t instance;
int result;
uint32_t enb_id;
MessageDef *msg_p;
const char *msg_name;
instance_t instance;
int result;
itti_mark_task_ready (TASK_ENB_APP);
......@@ -188,22 +185,22 @@ void *eNB_app_task(void *args_p)
# endif
# endif
enb_nb_properties = enb_config_init(g_conf_config_file_name, enb_properties);
enb_properties = enb_config_init(g_conf_config_file_name);
AssertFatal (enb_nb <= enb_nb_properties,
AssertFatal (enb_nb <= enb_properties->number,
"Number of eNB is greater than eNB defined in configuration file %s (%d/%d)!",
g_conf_config_file_name, enb_nb, enb_nb_properties);
g_conf_config_file_name, enb_nb, enb_properties->number);
for (enb_id = enb_id_start; (enb_id < enb_id_end) ; enb_id++)
{
configure_phy(enb_id);
configure_rrc(enb_id);
configure_phy(enb_id, enb_properties);
configure_rrc(enb_id, enb_properties);
}
# if defined(ENABLE_USE_MME)
/* Try to register each eNB */
registered_enb = 0;
register_enb_pending = eNB_app_register (enb_id_start, enb_id_end);
register_enb_pending = eNB_app_register (enb_id_start, enb_id_end, enb_properties);
# else
/* Start L2L1 task */
msg_p = itti_alloc_new_message(TASK_ENB_APP, INITIALIZE_MESSAGE);
......@@ -279,7 +276,7 @@ void *eNB_app_task(void *args_p)
sleep(ENB_REGISTER_RETRY_DELAY);
/* Restart the registration process */
registered_enb = 0;
register_enb_pending = eNB_app_register (enb_id_start, enb_id_end);
register_enb_pending = eNB_app_register (enb_id_start, enb_id_end, enb_properties);
}
}
}
......@@ -299,7 +296,7 @@ void *eNB_app_task(void *args_p)
{
/* Restart the registration process */
registered_enb = 0;
register_enb_pending = eNB_app_register (enb_id_start, enb_id_end);
register_enb_pending = eNB_app_register (enb_id_start, enb_id_end, enb_properties);
}
break;
# endif
......
......@@ -48,8 +48,9 @@
#include "LAYER2/MAC/extern.h"
int enb_config_init(char* lib_config_file_name_pP, Enb_properties_t **enb_properties) {
static Enb_properties_array_t enb_properties;
const Enb_properties_array_t *enb_config_init(char* lib_config_file_name_pP) {
config_t cfg;
config_setting_t *setting;
config_setting_t *setting_mme_addresses;
......@@ -79,7 +80,7 @@ int enb_config_init(char* lib_config_file_name_pP, Enb_properties_t **enb_proper
char* preference;
const char* active_enb[MAX_ENB];
memset((char*)enb_properties, 0 , MAX_ENB * sizeof(Enb_properties_t*));
memset((char*) (enb_properties.properties), 0 , MAX_ENB * sizeof(Enb_properties_t *));
memset((char*)active_enb, 0 , MAX_ENB * sizeof(char*));
config_init(&cfg);
......@@ -154,31 +155,31 @@ int enb_config_init(char* lib_config_file_name_pP, Enb_properties_t **enb_proper
// search if in active list
for (j=0; j < num_enb_properties; j++) {
if (strcmp(active_enb[j], enb_name) == 0) {
enb_properties[enb_properties_index] = calloc(1, sizeof(Enb_properties_t));
enb_properties.properties[enb_properties_index] = calloc(1, sizeof(Enb_properties_t));
enb_properties[enb_properties_index]->eNB_id = enb_id;
enb_properties.properties[enb_properties_index]->eNB_id = enb_id;
if (strcmp(cell_type, "CELL_MACRO_ENB") == 0) {
enb_properties[enb_properties_index]->cell_type = CELL_MACRO_ENB;
enb_properties.properties[enb_properties_index]->cell_type = CELL_MACRO_ENB;
} else if (strcmp(cell_type, "CELL_HOME_ENB") == 0) {
enb_properties[enb_properties_index]->cell_type = CELL_HOME_ENB;
enb_properties.properties[enb_properties_index]->cell_type = CELL_HOME_ENB;
} else {
AssertError (0, parse_error ++,
"Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for cell_type choice: CELL_MACRO_ENB or CELL_HOME_ENB !\n",
lib_config_file_name_pP, i, cell_type);
}
enb_properties[enb_properties_index]->eNB_name = strdup(enb_name);
enb_properties[enb_properties_index]->tac = (uint16_t)tac;
enb_properties[enb_properties_index]->mcc = (uint16_t)mcc;
enb_properties[enb_properties_index]->mnc = (uint16_t)mnc;
enb_properties.properties[enb_properties_index]->eNB_name = strdup(enb_name);
enb_properties.properties[enb_properties_index]->tac = (uint16_t)tac;
enb_properties.properties[enb_properties_index]->mcc = (uint16_t)mcc;
enb_properties.properties[enb_properties_index]->mnc = (uint16_t)mnc;
if (strcmp(default_drx, "PAGING_DRX_32") == 0) {
enb_properties[enb_properties_index]->default_drx = PAGING_DRX_32;
enb_properties.properties[enb_properties_index]->default_drx = PAGING_DRX_32;
} else if (strcmp(default_drx, "PAGING_DRX_64") == 0) {
enb_properties[enb_properties_index]->default_drx = PAGING_DRX_64;
enb_properties.properties[enb_properties_index]->default_drx = PAGING_DRX_64;
} else if (strcmp(default_drx, "PAGING_DRX_128") == 0) {
enb_properties[enb_properties_index]->default_drx = PAGING_DRX_128;
enb_properties.properties[enb_properties_index]->default_drx = PAGING_DRX_128;
} else if (strcmp(default_drx, "PAGING_DRX_256") == 0) {
enb_properties[enb_properties_index]->default_drx = PAGING_DRX_256;
enb_properties.properties[enb_properties_index]->default_drx = PAGING_DRX_256;
} else {
AssertError (0, parse_error ++,
"Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for default_drx choice: PAGING_DRX_32..PAGING_DRX_256 !\n",
......@@ -188,47 +189,47 @@ int enb_config_init(char* lib_config_file_name_pP, Enb_properties_t **enb_proper
// Parse optional physical parameters
if(config_setting_lookup_string(setting_enb, ENB_CONFIG_STRING_FRAME_TYPE, &frame_type)) {
if (strcmp(frame_type, "FDD") == 0) {
enb_properties[enb_properties_index]->frame_type = FDD;
enb_properties.properties[enb_properties_index]->frame_type = FDD;
} else if (strcmp(frame_type, "TDD") == 0) {
enb_properties[enb_properties_index]->frame_type = TDD;
enb_properties.properties[enb_properties_index]->frame_type = TDD;
} else {
AssertError (0, parse_error ++,
"Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for frame_type choice: FDD or TDD !\n",
lib_config_file_name_pP, i, frame_type);
}
} else {
enb_properties[enb_properties_index]->frame_type = FDD; // Default frame type
enb_properties.properties[enb_properties_index]->frame_type = FDD; // Default frame type
}
if(config_setting_lookup_string(setting_enb, ENB_CONFIG_STRING_PREFIX_TYPE, &prefix_type)) {
if (strcmp(prefix_type, "NORMAL") == 0) {
enb_properties[enb_properties_index]->prefix_type = NORMAL;
enb_properties.properties[enb_properties_index]->prefix_type = NORMAL;
} else if (strcmp(prefix_type, "EXTENDED") == 0) {
enb_properties[enb_properties_index]->prefix_type = EXTENDED;
enb_properties.properties[enb_properties_index]->prefix_type = EXTENDED;
} else {
AssertError (0, parse_error ++,
"Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for prefix_type choice: NORMAL or EXTENDED !\n",
lib_config_file_name_pP, i, prefix_type);
}
} else {
enb_properties[enb_properties_index]->prefix_type = NORMAL; // Default prefix type
enb_properties.properties[enb_properties_index]->prefix_type = NORMAL; // Default prefix type
}
if(config_setting_lookup_int64(setting_enb, ENB_CONFIG_STRING_DOWNLINK_FREQUENCY, &downlink_frequency)) {
enb_properties[enb_properties_index]->downlink_frequency = downlink_frequency;
enb_properties.properties[enb_properties_index]->downlink_frequency = downlink_frequency;
} else {
enb_properties[enb_properties_index]->downlink_frequency = 2680000000UL; // Default downlink frequency
enb_properties.properties[enb_properties_index]->downlink_frequency = 2680000000UL; // Default downlink frequency
}
if(config_setting_lookup_int(setting_enb, ENB_CONFIG_STRING_UPLINK_FREQUENCY_OFFSET, &uplink_frequency_offset)) {
enb_properties[enb_properties_index]->uplink_frequency_offset = uplink_frequency_offset;
enb_properties.properties[enb_properties_index]->uplink_frequency_offset = uplink_frequency_offset;
} else {
enb_properties[enb_properties_index]->uplink_frequency_offset = -120000000; // Default uplink frequency offset
enb_properties.properties[enb_properties_index]->uplink_frequency_offset = -120000000; // Default uplink frequency offset
}
setting_mme_addresses = config_setting_get_member (setting_enb, ENB_CONFIG_STRING_MME_IP_ADDRESS);
num_mme_address = config_setting_length(setting_mme_addresses);
enb_properties[enb_properties_index]->nb_mme = 0;
enb_properties.properties[enb_properties_index]->nb_mme = 0;
for (j = 0; j < num_mme_address; j++) {
setting_mme_address = config_setting_get_elem(setting_mme_addresses, j);
if( !(
......@@ -242,24 +243,24 @@ int enb_config_init(char* lib_config_file_name_pP, Enb_properties_t **enb_proper
"Failed to parse eNB configuration file %s, %u th enb %u th mme address !\n",
lib_config_file_name_pP, i, j);
}
enb_properties[enb_properties_index]->nb_mme += 1;
enb_properties.properties[enb_properties_index]->nb_mme += 1;
enb_properties[enb_properties_index]->mme_ip_address[j].ipv4_address = strdup(ipv4);
enb_properties[enb_properties_index]->mme_ip_address[j].ipv6_address = strdup(ipv6);
enb_properties.properties[enb_properties_index]->mme_ip_address[j].ipv4_address = strdup(ipv4);
enb_properties.properties[enb_properties_index]->mme_ip_address[j].ipv6_address = strdup(ipv6);
if (strcmp(active, "yes") == 0) {
enb_properties[enb_properties_index]->mme_ip_address[j].active = 1;
enb_properties.properties[enb_properties_index]->mme_ip_address[j].active = 1;
#if defined(ENABLE_USE_MME)
EPC_MODE_ENABLED = 1;
#endif
} // else { (calloc)
if (strcmp(preference, "ipv4") == 0) {
enb_properties[enb_properties_index]->mme_ip_address[j].ipv4 = 1;
enb_properties.properties[enb_properties_index]->mme_ip_address[j].ipv4 = 1;
} else if (strcmp(preference, "ipv6") == 0) {
enb_properties[enb_properties_index]->mme_ip_address[j].ipv6 = 1;
enb_properties.properties[enb_properties_index]->mme_ip_address[j].ipv6 = 1;
} else if (strcmp(preference, "no") == 0) {
enb_properties[enb_properties_index]->mme_ip_address[j].ipv4 = 1;
enb_properties[enb_properties_index]->mme_ip_address[j].ipv6 = 1;
enb_properties.properties[enb_properties_index]->mme_ip_address[j].ipv4 = 1;
enb_properties.properties[enb_properties_index]->mme_ip_address[j].ipv6 = 1;
}
}
enb_properties_index += 1;
......@@ -268,6 +269,8 @@ int enb_config_init(char* lib_config_file_name_pP, Enb_properties_t **enb_proper
}
}
}
enb_properties.number = num_enb_properties;
AssertError (enb_properties_index == num_enb_properties, parse_error ++,
"Failed to parse eNB configuration file %s, mismatch between %u active eNBs and %u corresponding defined eNBs !\n",
lib_config_file_name_pP, num_enb_properties, enb_properties_index);
......@@ -275,5 +278,10 @@ int enb_config_init(char* lib_config_file_name_pP, Enb_properties_t **enb_proper
AssertFatal (parse_error == 0,
"Failed to parse eNB configuration file %s, found %d error%s !\n",
lib_config_file_name_pP, parse_error, parse_error > 1 ? "s" : "");
return num_enb_properties;
return &enb_properties;
}
const Enb_properties_array_t *enb_config_get(void) {
return &enb_properties;
}
......@@ -132,6 +132,13 @@ typedef struct Enb_properties_s {
} Enb_properties_t;
int enb_config_init(char* lib_config_file_name_pP, Enb_properties_t **enb_properties);
typedef struct Enb_properties_array_s {
int number;
Enb_properties_t *properties[MAX_ENB];
} Enb_properties_array_t;
const Enb_properties_array_t *enb_config_init(char* lib_config_file_name_pP);
const Enb_properties_array_t *enb_config_get(void);
#endif /* ENB_CONFIG_H_ */
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