Commit 7c6c4fc7 authored by Robert Schmidt's avatar Robert Schmidt

Start E2 agent only if configuration present

This commit introduces an additional (implicit) option that signals if
the E2 agent is to be activated or not. When reading the configuration,
we now check if all fields are set, and activate the E2 agent only if
this is the case. If not, we only print a warning and start the gNB
without the agent.

Note that previously, if not all fields are set correctly, the gNB
stopped.

To implement this behavior, it is necessary to change the defaults of
the RIC IP and the directory for SMs to a (non-NULL) default value.
Otherwise, the configuration system would not consider the field to be
set to the default, and wrongly assumes the field is set, even though it
is not; at least, this change is necessary to make config_isparamset()
return NULL if the configuration is not set.
parent 79c920cd
......@@ -571,6 +571,50 @@ void init_pdcp(void) {
}
}
#ifdef E2_AGENT
static void initialize_agent(ngran_node_t node_type, e2_agent_args_t oai_args)
{
AssertFatal(oai_args.sm_dir != NULL , "Please, specify the directory where the SMs are located in the config file, i.e., add in config file the next line: e2_agent = {near_ric_ip_addr = \"127.0.0.1\"; sm_dir = \"/usr/local/lib/flexric/\");} ");
AssertFatal(oai_args.ip != NULL , "Please, specify the IP address of the nearRT-RIC in the config file, i.e., e2_agent = {near_ric_ip_addr = \"127.0.0.1\"; sm_dir = \"/usr/local/lib/flexric/\"");
printf("After RCconfig_NR_E2agent %s %s \n",oai_args.sm_dir, oai_args.ip );
fr_args_t args = { .ip = oai_args.ip }; // init_fr_args(0, NULL);
memcpy(args.libs_dir, oai_args.sm_dir, 128);
sleep(1);
const gNB_RRC_INST* rrc = RC.nrrrc[0];
assert(rrc != NULL && "rrc cannot be NULL");
const int mcc = rrc->configuration.mcc[0];
const int mnc = rrc->configuration.mnc[0];
const int mnc_digit_len = rrc->configuration.mnc_digit_length[0];
// const ngran_node_t node_type = rrc->node_type;
int nb_id = 0;
int cu_du_id = 0;
if (node_type == ngran_gNB) {
nb_id = rrc->nr_cellid;
} else if (node_type == ngran_gNB_DU) {
AssertFatal(rrc->node_id != 0, "cannot handle node ID 0, please change gNB_ID\n");
cu_du_id = rrc->node_id;
nb_id = rrc->nr_cellid;
} else if (node_type == ngran_gNB_CU) {
AssertFatal(rrc->node_id != 0, "cannot handle node ID 0, please change gNB_ID\n");
cu_du_id = rrc->node_id;
nb_id = rrc->nr_cellid;
} else {
LOG_E(NR_RRC, "not supported ran type detect\n");
}
printf("[E2 NODE]: mcc = %d mnc = %d mnc_digit = %d nb_id = %d \n", mcc, mnc, mnc_digit_len, nb_id);
printf("[E2 NODE]: Args %s %s \n", args.ip, args.libs_dir);
sm_io_ag_ran_t io = init_ran_func_ag();
init_agent_api(mcc, mnc, mnc_digit_len, nb_id, cu_du_id, node_type, io, &args);
}
#endif
configmodule_interface_t *uniqCfg = NULL;
int main( int argc, char **argv ) {
int ru_id, CC_id = 0;
......@@ -689,54 +733,18 @@ int main( int argc, char **argv ) {
config_sync_var=0;
#ifdef E2_AGENT
//////////////////////////////////
//////////////////////////////////
//// Init the E2 Agent
sm_io_ag_ran_t io = init_ran_func_ag();
// OAI Wrapper
e2_agent_args_t oai_args = RCconfig_NR_E2agent();
AssertFatal(oai_args.sm_dir != NULL , "Please, specify the directory where the SMs are located in the config file, i.e., add in config file the next line: e2_agent = {near_ric_ip_addr = \"127.0.0.1\"; sm_dir = \"/usr/local/lib/flexric/\");} ");
AssertFatal(oai_args.ip != NULL , "Please, specify the IP address of the nearRT-RIC in the config file, i.e., e2_agent = {near_ric_ip_addr = \"127.0.0.1\"; sm_dir = \"/usr/local/lib/flexric/\"");
printf("After RCconfig_NR_E2agent %s %s \n",oai_args.sm_dir, oai_args.ip );
fr_args_t args = { .ip = oai_args.ip }; // init_fr_args(0, NULL);
memcpy(args.libs_dir, oai_args.sm_dir, 128);
sleep(1);
const gNB_RRC_INST* rrc = RC.nrrrc[0];
assert(rrc != NULL && "rrc cannot be NULL");
const int mcc = rrc->configuration.mcc[0];
const int mnc = rrc->configuration.mnc[0];
const int mnc_digit_len = rrc->configuration.mnc_digit_length[0];
// const ngran_node_t node_type = rrc->node_type;
int nb_id = 0;
int cu_du_id = 0;
if (node_type == ngran_gNB) {
nb_id = rrc->configuration.cell_identity;
} else if (node_type == ngran_gNB_DU) {
cu_du_id = rrc->node_id + 1; // Hack to avoid been 0
nb_id = rrc->configuration.cell_identity;
} else if (node_type == ngran_gNB_CU) {
cu_du_id = rrc->node_id + 1;
nb_id = rrc->configuration.cell_identity;
} else {
LOG_E(NR_RRC, "not supported ran type detect\n");
if (oai_args.enabled) {
initialize_agent(node_type, oai_args);
}
printf("[E2 NODE]: mcc = %d mnc = %d mnc_digit = %d nb_id = %d \n", mcc, mnc, mnc_digit_len, nb_id);
printf("[E2 NODE]: Args %s %s \n", args.ip, args.libs_dir);
init_agent_api(mcc, mnc, mnc_digit_len, nb_id, cu_du_id, node_type, io, &args);
// }
#endif // E2_AGENT
......
......@@ -28,6 +28,7 @@
typedef struct{
const char *ip;
const char *sm_dir;
const bool enabled;
} e2_agent_args_t;
#endif
......
......@@ -2942,7 +2942,18 @@ e2_agent_args_t RCconfig_E2agent(void)
LOG_W(GNB_APP, "configuration file does not contain a \"%s\" section, applying default parameters\n", CONFIG_STRING_E2AGENT);
return (e2_agent_args_t) {0};
}
bool enabled = config_isparamset(e2agent_params, E2AGENT_CONFIG_SMDIR_IDX)
&& config_isparamset(e2agent_params, E2AGENT_CONFIG_IP_IDX);
if (!enabled) {
LOG_W(GNB_APP, "E2 agent is DISABLED (for activation, define .%s.{%s,%s} parameters)\n", CONFIG_STRING_E2AGENT, E2AGENT_CONFIG_IP, E2AGENT_CONFIG_SMDIR);
return (e2_agent_args_t) {
.enabled = false,
};
}
return (e2_agent_args_t) {
.enabled = true,
.ip = *e2agent_params[E2AGENT_CONFIG_IP_IDX].strptr,
.sm_dir = *e2agent_params[E2AGENT_CONFIG_SMDIR_IDX].strptr,
};
......
......@@ -1330,9 +1330,8 @@ typedef struct srb1_params_s {
//#define E2AGENT_CONFIG_PORT "port"
#define E2AGENT_CONFIG_SMDIR "sm_dir"
static const char* const e2agent_config_ip_default = NULL;
static const char* const e2agent_config_smdir_default = NULL;
//static const uint16_t e2agent_config_port_default = 36421;
static const char* const e2agent_config_ip_default = "127.0.0.1";
static const char* const e2agent_config_smdir_default = ".";
#define E2AGENT_PARAMS_DESC { \
{E2AGENT_CONFIG_IP, "RIC IP address", 0, strptr:NULL, defstrval:(char*)e2agent_config_ip_default, TYPE_STRING, 0}, \
......
......@@ -2281,7 +2281,14 @@ e2_agent_args_t RCconfig_NR_E2agent(void)
LOG_W(GNB_APP, "configuration file does not contain a \"%s\" section, applying default parameters from FlexRIC\n", CONFIG_STRING_E2AGENT);
return (e2_agent_args_t) { 0 };
}
e2_agent_args_t dst = {0};
bool enabled = config_isparamset(e2agent_params, E2AGENT_CONFIG_SMDIR_IDX)
&& config_isparamset(e2agent_params, E2AGENT_CONFIG_IP_IDX);
e2_agent_args_t dst = {.enabled = enabled};
if (!enabled) {
LOG_W(GNB_APP, "E2 agent is DISABLED (for activation, define .%s.{%s,%s} parameters)\n", CONFIG_STRING_E2AGENT, E2AGENT_CONFIG_IP, E2AGENT_CONFIG_SMDIR);
return dst;
}
if (e2agent_params[E2AGENT_CONFIG_SMDIR_IDX].strptr != NULL)
dst.sm_dir = *e2agent_params[E2AGENT_CONFIG_SMDIR_IDX].strptr;
......
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