Commit d563dfd1 authored by gauthier's avatar gauthier

SPGW config files optional enties: default values

parent 1bacf6bc
......@@ -113,8 +113,8 @@ int pgw_config::load_thread_sched_params(const Setting& thread_sched_params_cfg,
} catch(const SettingNotFoundException &nfex) {
Logger::pgwc_app().info("%s : %s, using defaults", nfex.what(), nfex.getPath());
}
try {
try {
thread_sched_params_cfg.lookupValue(PGW_CONFIG_STRING_THREAD_RD_SCHED_PRIORITY, cfg.sched_priority);
if ((cfg.sched_priority > 99) || (cfg.sched_priority < 1)) {
Logger::pgwc_app().error("thread_rd_sched_priority: %d, must be in interval [1..99] in config file", cfg.sched_priority);
......@@ -203,7 +203,7 @@ int pgw_config::load_interface(const Setting& if_cfg, interface_cfg_t & cfg)
load_thread_sched_params(sched_params_cfg, cfg.thread_rd_sched_params);
} catch(const SettingNotFoundException &nfex) {
Logger::pgwc_app().info("%s : %s, using defaults", nfex.what(), nfex.getPath());
}
}
}
return RETURNok;
}
......@@ -234,15 +234,34 @@ int pgw_config::load(const string& config_file)
try
{
string astring;
const Setting &pgw_cfg = root[PGW_CONFIG_STRING_PGW_CONFIG];
const Setting& pgw_cfg = root[PGW_CONFIG_STRING_PGW_CONFIG];
} catch(const SettingNotFoundException &nfex) {
Logger::pgwc_app().error("%s : %s", nfex.what(), nfex.getPath());
return RETURNerror;
}
const Setting &pgw_cfg = root[PGW_CONFIG_STRING_PGW_CONFIG];
try {
pgw_cfg.lookupValue(PGW_CONFIG_STRING_INSTANCE, instance);
} catch(const SettingNotFoundException &nfex) {
Logger::pgwc_app().info("%s : %s, using defaults", nfex.what(), nfex.getPath());
}
try {
pgw_cfg.lookupValue(PGW_CONFIG_STRING_PID_DIRECTORY, pid_dir);
} catch(const SettingNotFoundException &nfex) {
Logger::pgwc_app().info("%s : %s, using defaults", nfex.what(), nfex.getPath());
}
try {
const Setting& itti_cfg = pgw_cfg[PGW_CONFIG_STRING_ITTI_TASKS];
load_itti(itti_cfg, itti);
} catch(const SettingNotFoundException &nfex) {
Logger::pgwc_app().info("%s : %s, using defaults", nfex.what(), nfex.getPath());
}
try {
const Setting &nw_if_cfg = pgw_cfg[PGW_CONFIG_STRING_INTERFACES];
const Setting& s5s8_cp_cfg = nw_if_cfg[PGW_CONFIG_STRING_INTERFACE_S5_S8_CP];
......@@ -250,7 +269,13 @@ int pgw_config::load(const string& config_file)
const Setting& sx_cfg = nw_if_cfg[PGW_CONFIG_STRING_INTERFACE_SX];
load_interface(sx_cfg, sx);
} catch(const SettingNotFoundException &nfex) {
Logger::pgwc_app().error("%s : %s", nfex.what(), nfex.getPath());
return RETURNerror;
}
try {
string astring;
const Setting &pool_cfg = pgw_cfg[PGW_CONFIG_STRING_IP_ADDRESS_POOL];
......
......@@ -66,7 +66,7 @@ int sgwc_config::load_thread_sched_params(const Setting& thread_sched_params_cfg
try {
thread_sched_params_cfg.lookupValue(SGWC_CONFIG_STRING_THREAD_RD_CPU_ID, cfg.cpu_id);
} catch(const SettingNotFoundException &nfex) {
Logger::spgwu_app().info("%s : %s, using defaults", nfex.what(), nfex.getPath());
Logger::sgwc_app().info("%s : %s, using defaults", nfex.what(), nfex.getPath());
}
try {
std::string thread_rd_sched_policy;
......@@ -83,23 +83,23 @@ int sgwc_config::load_thread_sched_params(const Setting& thread_sched_params_cfg
} else if (boost::iequals(thread_rd_sched_policy, "SCHED_RR")) {
cfg.sched_policy = SCHED_RR;
} else {
Logger::spgwu_app().error("thread_rd_sched_policy: %s, unknown in config file", thread_rd_sched_policy.c_str());
Logger::sgwc_app().error("thread_rd_sched_policy: %s, unknown in config file", thread_rd_sched_policy.c_str());
return RETURNerror;
}
} catch(const SettingNotFoundException &nfex) {
Logger::spgwu_app().info("%s : %s, using defaults", nfex.what(), nfex.getPath());
Logger::sgwc_app().info("%s : %s, using defaults", nfex.what(), nfex.getPath());
}
try {
try {
thread_sched_params_cfg.lookupValue(SGWC_CONFIG_STRING_THREAD_RD_SCHED_PRIORITY, cfg.sched_priority);
if ((cfg.sched_priority > 99) || (cfg.sched_priority < 1)) {
Logger::spgwu_app().error("thread_rd_sched_priority: %d, must be in interval [1..99] in config file", cfg.sched_priority);
Logger::sgwc_app().error("thread_rd_sched_priority: %d, must be in interval [1..99] in config file", cfg.sched_priority);
return RETURNerror;
}
} catch(const SettingNotFoundException &nfex) {
Logger::spgwu_app().info("%s : %s, using defaults", nfex.what(), nfex.getPath());
Logger::sgwc_app().info("%s : %s, using defaults", nfex.what(), nfex.getPath());
}
return RETURNok;
}
//------------------------------------------------------------------------------
......@@ -109,42 +109,42 @@ int sgwc_config::load_itti(const Setting& itti_cfg, itti_cfg_t& cfg)
const Setting& sched_params_cfg = itti_cfg[SGWC_CONFIG_STRING_ITTI_TIMER_SCHED_PARAMS];
load_thread_sched_params(sched_params_cfg, cfg.itti_timer_sched_params);
} catch(const SettingNotFoundException &nfex) {
Logger::spgwu_app().info("%s : %s, using defaults", nfex.what(), nfex.getPath());
Logger::sgwc_app().info("%s : %s, using defaults", nfex.what(), nfex.getPath());
}
try {
const Setting& s11_sched_params_cfg = itti_cfg[SGWC_CONFIG_STRING_S11_SCHED_PARAMS];
load_thread_sched_params(s11_sched_params_cfg, cfg.s11_sched_params);
} catch(const SettingNotFoundException &nfex) {
Logger::spgwu_app().info("%s : %s, using defaults", nfex.what(), nfex.getPath());
Logger::sgwc_app().info("%s : %s, using defaults", nfex.what(), nfex.getPath());
}
try {
const Setting& s5s8_sched_params_cfg = itti_cfg[SGWC_CONFIG_STRING_S5S8_SCHED_PARAMS];
load_thread_sched_params(s5s8_sched_params_cfg, cfg.s5s8_sched_params);
} catch(const SettingNotFoundException &nfex) {
Logger::spgwu_app().info("%s : %s, using defaults", nfex.what(), nfex.getPath());
Logger::sgwc_app().info("%s : %s, using defaults", nfex.what(), nfex.getPath());
}
try {
const Setting& sx_sched_params_cfg = itti_cfg[SGWC_CONFIG_STRING_SX_SCHED_PARAMS];
load_thread_sched_params(sx_sched_params_cfg, cfg.sx_sched_params);
} catch(const SettingNotFoundException &nfex) {
Logger::spgwu_app().info("%s : %s, using defaults", nfex.what(), nfex.getPath());
}
//try {
// const Setting& sx_sched_params_cfg = itti_cfg[SGWC_CONFIG_STRING_SX_SCHED_PARAMS];
// load_thread_sched_params(sx_sched_params_cfg, cfg.sx_sched_params);
//} catch(const SettingNotFoundException &nfex) {
// Logger::sgwc_app().info("%s : %s, using defaults", nfex.what(), nfex.getPath());
//}
try {
const Setting& sgw_app_sched_params_cfg = itti_cfg[SGWC_CONFIG_STRING_SGW_APP_SCHED_PARAMS];
load_thread_sched_params(sgw_app_sched_params_cfg, cfg.sgw_app_sched_params);
} catch(const SettingNotFoundException &nfex) {
Logger::spgwu_app().info("%s : %s, using defaults", nfex.what(), nfex.getPath());
Logger::sgwc_app().info("%s : %s, using defaults", nfex.what(), nfex.getPath());
}
try {
const Setting& async_cmd_sched_params_cfg = itti_cfg[SGWC_CONFIG_STRING_ASYNC_CMD_SCHED_PARAMS];
load_thread_sched_params(async_cmd_sched_params_cfg, cfg.async_cmd_sched_params);
} catch(const SettingNotFoundException &nfex) {
Logger::spgwu_app().info("%s : %s, using defaults", nfex.what(), nfex.getPath());
Logger::sgwc_app().info("%s : %s, using defaults", nfex.what(), nfex.getPath());
}
return RETURNok;
......@@ -186,7 +186,7 @@ int sgwc_config::load_interface(const Setting& if_cfg, interface_cfg_t& cfg)
load_thread_sched_params(sched_params_cfg, cfg.thread_rd_sched_params);
} catch(const SettingNotFoundException &nfex) {
Logger::sgwc_app().info("%s : %s, using defaults", nfex.what(), nfex.getPath());
}
}
}
return RETURNok;
}
......@@ -223,13 +223,13 @@ int sgwc_config::load(const string& config_file)
}
const Setting& sgw_cfg = root[SGWC_CONFIG_STRING_SGW_CONFIG];
try {
sgw_cfg.lookupValue(SGWC_CONFIG_STRING_INSTANCE, instance);
} catch(const SettingNotFoundException &nfex) {
Logger::sgwc_app().info("%s : %s, using defaults", nfex.what(), nfex.getPath());
}
try {
sgw_cfg.lookupValue(SGWC_CONFIG_STRING_PID_DIRECTORY, pid_dir);
util::trim(pid_dir);
......@@ -291,10 +291,10 @@ void sgwc_config::display ()
Logger::sgwc_app().info( " CPU id............: %d", itti.s5s8_sched_params.cpu_id);
Logger::sgwc_app().info( " Scheduling policy : %d", itti.s5s8_sched_params.sched_policy);
Logger::sgwc_app().info( " Scheduling prio .: %d", itti.s5s8_sched_params.sched_priority);
Logger::sgwc_app().info( "- ITTI Sx Task Threading:");
Logger::sgwc_app().info( " CPU id............: %d", itti.sx_sched_params.cpu_id);
Logger::sgwc_app().info( " Scheduling policy : %d", itti.sx_sched_params.sched_policy);
Logger::sgwc_app().info( " Scheduling prio .: %d", itti.sx_sched_params.sched_priority);
//Logger::sgwc_app().info( "- ITTI Sx Task Threading:");
//Logger::sgwc_app().info( " CPU id............: %d", itti.sx_sched_params.cpu_id);
//Logger::sgwc_app().info( " Scheduling policy : %d", itti.sx_sched_params.sched_policy);
//Logger::sgwc_app().info( " Scheduling prio .: %d", itti.sx_sched_params.sched_priority);
Logger::sgwc_app().info( "- ITTI SGW_APP task Threading:");
Logger::sgwc_app().info( " CPU id............: %d", itti.sgw_app_sched_params.cpu_id);
Logger::sgwc_app().info( " Scheduling policy : %d", itti.sgw_app_sched_params.sched_policy);
......
......@@ -81,7 +81,7 @@ typedef struct itti_cfg_s {
util::thread_sched_params itti_timer_sched_params;
util::thread_sched_params s11_sched_params;
util::thread_sched_params s5s8_sched_params;
util::thread_sched_params sx_sched_params;
//util::thread_sched_params sx_sched_params;
util::thread_sched_params sgw_app_sched_params;
util::thread_sched_params async_cmd_sched_params;
} itti_cfg_t;
......@@ -104,22 +104,21 @@ public:
interface_cfg_t s11_up;
interface_cfg_t s5s8_cp;
//interface_cfg_t sxa;
bool local_to_eNB;
itti_cfg_t itti;
sgwc_config() : m_rw_lock(), pid_dir(), instance(0), s11_cp(), s11_up(), s5s8_cp(), local_to_eNB(false)
sgwc_config() : m_rw_lock(), pid_dir(), instance(0), s11_cp(), s11_up(), s5s8_cp()
{
itti.itti_timer_sched_params.sched_priority = 85;
itti.s11_sched_params.sched_priority = 84;
itti.s5s8_sched_params.sched_priority = 84;
itti.sgw_app_sched_params.sched_priority = 84;
itti.async_cmd_sched_params.sched_priority = 84;
s11_cp.thread_rd_sched_params.sched_priority = 95;
s11_cp.port = gtpv2c::default_port;
s11_up.thread_rd_sched_params.sched_priority = 95;
s5s8_cp.thread_rd_sched_params.sched_priority = 95;
s5s8_cp.port = gtpv2c::default_port;
};
......
......@@ -99,49 +99,82 @@ int spgwu_config::get_pfcp_fseid(pfcp::fseid_t& fseid)
//------------------------------------------------------------------------------
int spgwu_config::load_thread_sched_params(const Setting& thread_sched_params_cfg, util::thread_sched_params& cfg)
{
thread_sched_params_cfg.lookupValue(SPGWU_CONFIG_STRING_THREAD_RD_CPU_ID, cfg.cpu_id);
std::string thread_rd_sched_policy;
thread_sched_params_cfg.lookupValue(SPGWU_CONFIG_STRING_THREAD_RD_SCHED_POLICY, thread_rd_sched_policy);
util::trim(thread_rd_sched_policy);
if (boost::iequals(thread_rd_sched_policy, "SCHED_OTHER")) {
cfg.sched_policy = SCHED_OTHER;
} else if (boost::iequals(thread_rd_sched_policy, "SCHED_IDLE")) {
cfg.sched_policy = SCHED_IDLE;
} else if (boost::iequals(thread_rd_sched_policy, "SCHED_BATCH")) {
cfg.sched_policy = SCHED_BATCH;
} else if (boost::iequals(thread_rd_sched_policy, "SCHED_FIFO")) {
cfg.sched_policy = SCHED_FIFO;
} else if (boost::iequals(thread_rd_sched_policy, "SCHED_RR")) {
cfg.sched_policy = SCHED_RR;
} else {
Logger::spgwu_app().error("thread_rd_sched_policy: %s, unknown in config file", thread_rd_sched_policy.c_str());
return RETURNerror;
try {
thread_sched_params_cfg.lookupValue(SPGWU_CONFIG_STRING_THREAD_RD_CPU_ID, cfg.cpu_id);
} catch(const SettingNotFoundException &nfex) {
Logger::spgwu_app().info("%s : %s, using defaults", nfex.what(), nfex.getPath());
}
thread_sched_params_cfg.lookupValue(SPGWU_CONFIG_STRING_THREAD_RD_SCHED_PRIORITY, cfg.sched_priority);
if ((cfg.sched_priority > 99) || (cfg.sched_priority < 1)) {
Logger::spgwu_app().error("thread_rd_sched_priority: %d, must be in interval [1..99] in config file", cfg.sched_priority);
return RETURNerror;
try {
std::string thread_rd_sched_policy;
thread_sched_params_cfg.lookupValue(SPGWU_CONFIG_STRING_THREAD_RD_SCHED_POLICY, thread_rd_sched_policy);
util::trim(thread_rd_sched_policy);
if (boost::iequals(thread_rd_sched_policy, "SCHED_OTHER")) {
cfg.sched_policy = SCHED_OTHER;
} else if (boost::iequals(thread_rd_sched_policy, "SCHED_IDLE")) {
cfg.sched_policy = SCHED_IDLE;
} else if (boost::iequals(thread_rd_sched_policy, "SCHED_BATCH")) {
cfg.sched_policy = SCHED_BATCH;
} else if (boost::iequals(thread_rd_sched_policy, "SCHED_FIFO")) {
cfg.sched_policy = SCHED_FIFO;
} else if (boost::iequals(thread_rd_sched_policy, "SCHED_RR")) {
cfg.sched_policy = SCHED_RR;
} else {
Logger::spgwu_app().error("thread_rd_sched_policy: %s, unknown in config file", thread_rd_sched_policy.c_str());
return RETURNerror;
}
} catch(const SettingNotFoundException &nfex) {
Logger::spgwu_app().info("%s : %s, using defaults", nfex.what(), nfex.getPath());
}
try {
thread_sched_params_cfg.lookupValue(SPGWU_CONFIG_STRING_THREAD_RD_SCHED_PRIORITY, cfg.sched_priority);
if ((cfg.sched_priority > 99) || (cfg.sched_priority < 1)) {
Logger::spgwu_app().error("thread_rd_sched_priority: %d, must be in interval [1..99] in config file", cfg.sched_priority);
return RETURNerror;
}
} catch(const SettingNotFoundException &nfex) {
Logger::spgwu_app().info("%s : %s, using defaults", nfex.what(), nfex.getPath());
}
return RETURNok;
}
//------------------------------------------------------------------------------
int spgwu_config::load_itti(const Setting& itti_cfg, itti_cfg_t& cfg)
{
const Setting& sched_params_cfg = itti_cfg[SPGWU_CONFIG_STRING_ITTI_TIMER_SCHED_PARAMS];
load_thread_sched_params(sched_params_cfg, cfg.itti_timer_sched_params);
try {
const Setting& sched_params_cfg = itti_cfg[SPGWU_CONFIG_STRING_ITTI_TIMER_SCHED_PARAMS];
load_thread_sched_params(sched_params_cfg, cfg.itti_timer_sched_params);
} catch(const SettingNotFoundException &nfex) {
Logger::spgwu_app().info("%s : %s, using defaults", nfex.what(), nfex.getPath());
}
const Setting& s1u_sched_params_cfg = itti_cfg[SPGWU_CONFIG_STRING_S1U_SCHED_PARAMS];
load_thread_sched_params(s1u_sched_params_cfg, cfg.s1u_sched_params);
try {
const Setting& s1u_sched_params_cfg = itti_cfg[SPGWU_CONFIG_STRING_S1U_SCHED_PARAMS];
load_thread_sched_params(s1u_sched_params_cfg, cfg.s1u_sched_params);
} catch(const SettingNotFoundException &nfex) {
Logger::spgwu_app().info("%s : %s, using defaults", nfex.what(), nfex.getPath());
}
const Setting& sx_sched_params_cfg = itti_cfg[SPGWU_CONFIG_STRING_SX_SCHED_PARAMS];
load_thread_sched_params(sx_sched_params_cfg, cfg.sx_sched_params);
try {
const Setting& sx_sched_params_cfg = itti_cfg[SPGWU_CONFIG_STRING_SX_SCHED_PARAMS];
load_thread_sched_params(sx_sched_params_cfg, cfg.sx_sched_params);
} catch(const SettingNotFoundException &nfex) {
Logger::spgwu_app().info("%s : %s, using defaults", nfex.what(), nfex.getPath());
}
const Setting& spgwu_app_sched_params_cfg = itti_cfg[SPGWU_CONFIG_STRING_SX_SCHED_PARAMS];
load_thread_sched_params(spgwu_app_sched_params_cfg, cfg.spgwu_app_sched_params);
try {
const Setting& spgwu_app_sched_params_cfg = itti_cfg[SPGWU_CONFIG_STRING_SX_SCHED_PARAMS];
load_thread_sched_params(spgwu_app_sched_params_cfg, cfg.spgwu_app_sched_params);
} catch(const SettingNotFoundException &nfex) {
Logger::spgwu_app().info("%s : %s, using defaults", nfex.what(), nfex.getPath());
}
const Setting& async_cmd_sched_params_cfg = itti_cfg[SPGWU_CONFIG_STRING_ASYNC_CMD_SCHED_PARAMS];
load_thread_sched_params(async_cmd_sched_params_cfg, cfg.async_cmd_sched_params);
try {
const Setting& async_cmd_sched_params_cfg = itti_cfg[SPGWU_CONFIG_STRING_ASYNC_CMD_SCHED_PARAMS];
load_thread_sched_params(async_cmd_sched_params_cfg, cfg.async_cmd_sched_params);
} catch(const SettingNotFoundException &nfex) {
Logger::spgwu_app().info("%s : %s, using defaults", nfex.what(), nfex.getPath());
}
return RETURNok;
}
......@@ -177,8 +210,12 @@ int spgwu_config::load_interface(const Setting& if_cfg, interface_cfg_t& cfg)
cfg.network4.s_addr = htons(ntohs(cfg.addr4.s_addr) & 0xFFFFFFFF << (32 - std::stoi (util::trim(words.at(1)))));
}
if_cfg.lookupValue(SPGWU_CONFIG_STRING_PORT, cfg.port);
const Setting& sched_params_cfg = if_cfg[SPGWU_CONFIG_STRING_SCHED_PARAMS];
load_thread_sched_params(sched_params_cfg, cfg.thread_rd_sched_params);
try {
const Setting& sched_params_cfg = if_cfg[SPGWU_CONFIG_STRING_SCHED_PARAMS];
load_thread_sched_params(sched_params_cfg, cfg.thread_rd_sched_params);
} catch(const SettingNotFoundException &nfex) {
Logger::spgwu_app().info("%s : %s, using defaults", nfex.what(), nfex.getPath());
}
}
return RETURNok;
}
......@@ -208,17 +245,37 @@ int spgwu_config::load(const string& config_file)
const Setting& root = cfg.getRoot();
try
{
try {
const Setting& spgwu_cfg = root[SPGWU_CONFIG_STRING_SPGWU_CONFIG];
} catch(const SettingNotFoundException &nfex) {
Logger::spgwu_app().error("%s : %s", nfex.what(), nfex.getPath());
return RETURNerror;
}
spgwu_cfg.lookupValue(SPGWU_CONFIG_STRING_INSTANCE, instance);
const Setting& spgwu_cfg = root[SPGWU_CONFIG_STRING_SPGWU_CONFIG];
try {
spgwu_cfg.lookupValue(SPGWU_CONFIG_STRING_INSTANCE, instance);
} catch(const SettingNotFoundException &nfex) {
Logger::spgwu_app().info("%s : %s, using defaults", nfex.what(), nfex.getPath());
}
try {
spgwu_cfg.lookupValue(SPGWU_CONFIG_STRING_PID_DIRECTORY, pid_dir);
util::trim(pid_dir);
} catch(const SettingNotFoundException &nfex) {
Logger::spgwu_app().info("%s : %s, using defaults", nfex.what(), nfex.getPath());
}
try {
const Setting& itti_cfg = spgwu_cfg[SPGWU_CONFIG_STRING_ITTI_TASKS];
load_itti(itti_cfg, itti);
} catch(const SettingNotFoundException &nfex) {
Logger::spgwu_app().info("%s : %s, using defaults", nfex.what(), nfex.getPath());
}
try {
const Setting& nw_if_cfg = spgwu_cfg[SPGWU_CONFIG_STRING_INTERFACES];
const Setting& s1_up_cfg = nw_if_cfg[SPGWU_CONFIG_STRING_INTERFACE_S1U_S12_S4_UP];
......
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