Commit ccd880dc authored by gauthier's avatar gauthier

SPGWU thread scheduler and priority in config file (still boost asio to be removed)

parent fd99e0f5
......@@ -23,9 +23,9 @@ SPGW-U =
INSTANCE = @INSTANCE@; # 0 is the default
PID_DIRECTORY = "@PID_DIRECTORY@"; # /var/run is the default
ITTI :
ITTI_TASKS :
{
SCHED_PARAMS :
ITTI_TIMER_SCHED_PARAMS :
{
CPU_ID = 1;
SCHED_POLICY = "SCHED_FIFO"; # Values in { SCHED_OTHER, SCHED_IDLE, SCHED_BATCH, SCHED_FIFO, SCHED_RR }
......@@ -43,6 +43,12 @@ SPGW-U =
SCHED_POLICY = "SCHED_FIFO"; # Values in { SCHED_OTHER, SCHED_IDLE, SCHED_BATCH, SCHED_FIFO, SCHED_RR }
SCHED_PRIORITY = 84;
};
ASYNC_CMD_SCHED_PARAMS :
{
CPU_ID = 1;
SCHED_POLICY = "SCHED_FIFO"; # Values in { SCHED_OTHER, SCHED_IDLE, SCHED_BATCH, SCHED_FIFO, SCHED_RR }
SCHED_PRIORITY = 84;
};
};
INTERFACES :
......
......@@ -34,6 +34,7 @@ set(CN_UTILS_SRC STATIC
#${CMAKE_CURRENT_SOURCE_DIR}/mcc_mnc_itu.c
${CMAKE_CURRENT_SOURCE_DIR}/pid_file.cpp
${CMAKE_CURRENT_SOURCE_DIR}/string.cpp
${CMAKE_CURRENT_SOURCE_DIR}/thread_sched.cpp
)
......
......@@ -53,9 +53,13 @@ extern itti_mw *itti_inst;
void async_cmd_task (void*);
//------------------------------------------------------------------------------
void async_cmd_task (void*)
void async_cmd_task (void* args_p)
{
const task_id_t task_id = TASK_ASYNC_SHELL_CMD;
const thread_sched_params* const sched_params = (const oai::cn::util::thread_sched_params* const)args_p;
sched_params->apply(task_id, Logger::async_cmd());
itti_inst->notify_task_ready(task_id);
do {
......@@ -95,11 +99,11 @@ void async_cmd_task (void*)
}
//------------------------------------------------------------------------------
async_shell_cmd::async_shell_cmd (void)
async_shell_cmd::async_shell_cmd (oai::cn::util::thread_sched_params& sched_params)
{
Logger::async_cmd().startup( "Starting..." );
if (itti_inst->create_task(TASK_ASYNC_SHELL_CMD, async_cmd_task, nullptr) ) {
if (itti_inst->create_task(TASK_ASYNC_SHELL_CMD, async_cmd_task, &sched_params) ) {
Logger::async_cmd().error( "Cannot create task TASK_ASYNC_SHELL_CMD" );
throw std::runtime_error( "Cannot create task TASK_ASYNC_SHELL_CMD" );
}
......
......@@ -32,6 +32,7 @@
#define FILE_ASYNC_SHELL_CMD_HPP_SEEN
#include "itti_msg.hpp"
#include "thread_sched.hpp"
#include <string>
#include <thread>
......@@ -43,7 +44,7 @@ private:
std::thread thread;
public:
async_shell_cmd();
explicit async_shell_cmd(oai::cn::util::thread_sched_params& sched_params);
~async_shell_cmd() {}
async_shell_cmd(async_shell_cmd const&) = delete;
void operator=(async_shell_cmd const&) = delete;
......
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file thread_sched.c
\brief
\company Eurecom
\email: lionel.gauthier@eurecom.fr
*/
#include "thread_sched.hpp"
//------------------------------------------------------------------------------
void oai::cn::util::thread_sched_params::apply(const int task_id, _Logger& logger) const
{
if (cpu_id >= 0) {
cpu_set_t cpuset;
CPU_SET(cpu_id,&cpuset);
if (int rc = pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset)) {
logger.warn( "Could not set affinity to ITTI task %d, err=%d", task_id, rc);
}
}
struct sched_param sparam;
memset(&sparam, 0, sizeof(sparam));
sparam.sched_priority = sched_priority;
if (int rc = pthread_setschedparam(pthread_self(), sched_policy, &sparam)) {
logger.warn( "Could not set schedparam to ITTI task %d, err=%d", task_id, rc);
}
}
......@@ -19,20 +19,27 @@
* contact@openairinterface.org
*/
/*! \file thread_sched.h
/*! \file thread_sched.hpp
\brief
\company Eurecom
\email: lionel.gauthier@eurecom.fr
*/
#ifndef FILE_THREAD_SCHED_SEEN
#define FILE_THREAD_SCHED_SEEN
#ifndef FILE_THREAD_SCHED_HPP_SEEN
#define FILE_THREAD_SCHED_HPP_SEEN
#include <sched.h>
#include "logger.hpp"
typedef struct thread_sched_params_s {
namespace oai::cn::util {
class thread_sched_params {
public:
int cpu_id;
int sched_policy;
int sched_priority;
} thread_sched_params_t;
#endif /* FILE_COMMON_ROOT_TYPES_SEEN */
void apply(const int task_id, _Logger& logger) const;
};
}
#endif /* FILE_THREAD_SCHED_HPP_SEEN */
......@@ -55,23 +55,13 @@ static std::string string_to_hex(const std::string& input)
return output;
}
//------------------------------------------------------------------------------
void udp_server::udp_read_loop(const thread_sched_params_t& thread_sched_params)
void udp_server::udp_read_loop(const oai::cn::util::thread_sched_params& sched_params)
{
socklen_t r_endpoint_addr_len = 0;
struct sockaddr_storage r_endpoint = {};
size_t bytes_received = 0;
if (thread_sched_params.cpu_id >= 0) {
cpu_set_t cpuset;
CPU_SET(thread_sched_params.cpu_id ,&cpuset);
pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset);
}
struct sched_param sparam;
memset(&sparam, 0, sizeof(sparam));
sparam.sched_priority = thread_sched_params.sched_priority;
pthread_setschedparam(pthread_self(), thread_sched_params.sched_policy, &sparam);
sched_params.apply(TASK_NONE, Logger::udp());
while (1) {
r_endpoint_addr_len = sizeof(struct sockaddr_storage);
......@@ -169,11 +159,11 @@ int udp_server::create_socket (char * address, const uint16_t port_num)
}
}
//------------------------------------------------------------------------------
void udp_server::start_receive(gtpu_l4_stack * gtp_stack, const thread_sched_params_t& thread_sched_params)
void udp_server::start_receive(gtpu_l4_stack * gtp_stack, const oai::cn::util::thread_sched_params& sched_params)
{
app_ = gtp_stack;
Logger::udp().trace( "udp_server::start_receive");
thread_ = thread(&udp_server::udp_read_loop,this, thread_sched_params);
thread_ = thread(&udp_server::udp_read_loop,this, sched_params);
thread_.detach();
}
......@@ -196,7 +186,7 @@ void udp_server::start_receive(gtpu_l4_stack * gtp_stack, const thread_sched_par
//}
//------------------------------------------------------------------------------
gtpu_l4_stack::gtpu_l4_stack(const struct in_addr& address, const uint16_t port_num, const thread_sched_params_t& thread_sched_params) :
gtpu_l4_stack::gtpu_l4_stack(const struct in_addr& address, const uint16_t port_num, const oai::cn::util::thread_sched_params& sched_params) :
udp_s(udp_server(address, port_num))
{
Logger::gtpv1_u().info( "gtpu_l4_stack created listening to %s:%d", oai::cn::core::toString(address).c_str(), port_num);
......@@ -205,10 +195,10 @@ gtpu_l4_stack::gtpu_l4_stack(const struct in_addr& address, const uint16_t port_
srand (time(NULL));
seq_num = rand() & 0x7FFFFFFF;
restart_counter = 0;
udp_s.start_receive(this, thread_sched_params);
udp_s.start_receive(this, sched_params);
}
//------------------------------------------------------------------------------
gtpu_l4_stack::gtpu_l4_stack(const struct in6_addr& address, const uint16_t port_num, const thread_sched_params_t& thread_sched_params) :
gtpu_l4_stack::gtpu_l4_stack(const struct in6_addr& address, const uint16_t port_num, const oai::cn::util::thread_sched_params& sched_params) :
udp_s(udp_server(address, port_num))
{
Logger::gtpv1_u().info( "gtpu_l4_stack created listening to %s:%d", oai::cn::core::toString(address).c_str(), port_num);
......@@ -217,10 +207,10 @@ gtpu_l4_stack::gtpu_l4_stack(const struct in6_addr& address, const uint16_t port
srand (time(NULL));
seq_num = rand() & 0x7FFFFFFF;
restart_counter = 0;
udp_s.start_receive(this, thread_sched_params);
udp_s.start_receive(this, sched_params);
}
//------------------------------------------------------------------------------
gtpu_l4_stack::gtpu_l4_stack(char * address, const uint16_t port_num, const thread_sched_params_t& thread_sched_params) :
gtpu_l4_stack::gtpu_l4_stack(char * address, const uint16_t port_num, const oai::cn::util::thread_sched_params& sched_params) :
udp_s(udp_server(address, port_num))
{
Logger::gtpv1_u().info( "gtpu_l4_stack created listening to %s:%d", address, port_num);
......@@ -229,7 +219,7 @@ gtpu_l4_stack::gtpu_l4_stack(char * address, const uint16_t port_num, const thre
srand (time(NULL));
seq_num = rand() & 0x7FFFFFFF;
restart_counter = 0;
udp_s.start_receive(this, thread_sched_params);
udp_s.start_receive(this, sched_params);
}
......
......@@ -31,7 +31,7 @@
#include "3gpp_29.281.hpp"
#include "itti.hpp"
#include "msg_gtpv1u.hpp"
#include "thread_sched.h"
#include "thread_sched.hpp"
#include <iostream>
#include <map>
......@@ -94,7 +94,7 @@ public:
close(socket_);
}
void udp_read_loop(const thread_sched_params_t& thread_sched_params);
void udp_read_loop(const oai::cn::util::thread_sched_params& thread_sched_params);
void async_send_to(const char* send_buffer, const ssize_t num_bytes, const struct sockaddr_in& peer_addr)
{
......@@ -114,7 +114,7 @@ public:
}
void start_receive(gtpu_l4_stack * gtp_stack, const thread_sched_params_t& thread_sched_params);
void start_receive(gtpu_l4_stack * gtp_stack, const oai::cn::util::thread_sched_params& sched_params);
protected:
int create_socket (const struct in_addr& address, const uint16_t port);
......@@ -162,9 +162,9 @@ protected:
public:
static const uint8_t version = 1;
gtpu_l4_stack(const struct in_addr& address, const uint16_t port_num, const thread_sched_params_t& thread_sched_params);
gtpu_l4_stack(const struct in6_addr& address, const uint16_t port_num, const thread_sched_params_t& thread_sched_params);
gtpu_l4_stack(char * ip_address, const uint16_t port_num, const thread_sched_params_t& thread_sched_params);
gtpu_l4_stack(const struct in_addr& address, const uint16_t port_num, const oai::cn::util::thread_sched_params& sched_params);
gtpu_l4_stack(const struct in6_addr& address, const uint16_t port_num, const oai::cn::util::thread_sched_params& sched_params);
gtpu_l4_stack(char * ip_address, const uint16_t port_num, const oai::cn::util::thread_sched_params& sched_params);
virtual void handle_receive(char* recv_buffer, const std::size_t bytes_transferred, const struct sockaddr_storage& r_endpoint, const socklen_t& r_endpoint_addr_len);
void handle_receive_message_cb(const gtpv1u_msg& msg, const struct sockaddr_storage& r_endpoint, const socklen_t& r_endpoint_addr_len, const core::itti::task_id_t& task_id, bool &error, uint64_t& gtpc_tx_id);
......
......@@ -42,9 +42,10 @@ extern itti_mw *itti_inst;
static itti_timer null_timer(ITTI_INVALID_TIMER_ID, TASK_NONE, 0xFFFFFFFF, 0xFFFFFFFF, 0, 0);
//------------------------------------------------------------------------------
void itti_mw::timer_manager_task(void)
void itti_mw::timer_manager_task(const oai::cn::util::thread_sched_params& sched_params)
{
Logger::itti().info("Starting timer_manager_task");
sched_params.apply(TASK_ITTI_TIMER, Logger::itti());
while (true) {
if (itti_inst->terminate) return;
{
......@@ -109,9 +110,9 @@ itti_mw::~itti_mw() {
}
//------------------------------------------------------------------------------
void itti_mw::start(void) {
void itti_mw::start(const oai::cn::util::thread_sched_params& sched_params) {
Logger::itti().startup( "Starting..." );
timer_thread = thread(timer_manager_task);
timer_thread = thread(timer_manager_task, sched_params);
Logger::itti().startup( "Started" );
}
//------------------------------------------------------------------------------
......
......@@ -41,6 +41,7 @@
#include <chrono>
#include <iomanip>
#include "itti_msg.hpp"
#include "thread_sched.hpp"
namespace oai::cn::core::itti {
......@@ -131,7 +132,7 @@ private:
bool terminate;
static void timer_manager_task(void);
static void timer_manager_task(const oai::cn::util::thread_sched_params& sched_params);
public:
itti_mw();
......@@ -139,7 +140,7 @@ public:
void operator=(itti_mw const&) = delete;
~itti_mw();
void start(void);
void start(const oai::cn::util::thread_sched_params& sched_params);
timer_id_t increment_timer_id ();
unsigned int increment_message_number ();
......
......@@ -82,13 +82,15 @@ int main(int argc, char **argv)
sigaction(SIGINT, &sigIntHandler, NULL);
// Config
spgwu_cfg.load(Options::getlibconfigConfig());
spgwu_cfg.display();
// Inter task Interface
itti_inst = new itti_mw();
itti_inst->start();
itti_inst->start(spgwu_cfg.itti.itti_timer_sched_params);
// system command
async_shell_cmd_inst = new async_shell_cmd();
async_shell_cmd_inst = new async_shell_cmd(spgwu_cfg.itti.async_cmd_sched_params);
// PGW application layer
spgwu_app_inst = new spgwu_app(Options::getlibconfigConfig());
......
......@@ -124,24 +124,11 @@ void pfcp_switch::commit_changes()
}
//------------------------------------------------------------------------------
void pfcp_switch::pdn_read_loop(const thread_sched_params_t& thread_sched_params)
void pfcp_switch::pdn_read_loop(const oai::cn::util::thread_sched_params& sched_params)
{
int bytes_received = 0;
if (thread_sched_params.cpu_id >= 0) {
cpu_set_t cpuset;
CPU_SET(thread_sched_params.cpu_id,&cpuset);
if (int rc = pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset)) {
Logger::pfcp_switch().warn( "Could not set affinity to thread polling SGi interface, err=%d", rc);
}
}
struct sched_param sparam;
memset(&sparam, 0, sizeof(sparam));
sparam.sched_priority = thread_sched_params.sched_priority;
if (int rc = pthread_setschedparam(pthread_self(), thread_sched_params.sched_policy, &sparam)) {
Logger::pfcp_switch().warn( "Could not set schedparam to thread polling SGi interface, err=%d", rc);
}
sched_params.apply(TASK_NONE, Logger::pfcp_switch());
struct msghdr msg = {};
msg.msg_iov = &msg_iov_;
......
......@@ -34,7 +34,7 @@
#include "msg_pfcp.hpp"
#include "pfcp_session.hpp"
#include "uint_generator.hpp"
#include "thread_sched.h"
#include "thread_sched.hpp"
#include <folly/AtomicHashMap.h>
#include <linux/ip.h>
......@@ -109,7 +109,7 @@ private:
//moodycamel::ConcurrentQueue<core::pfcp::pfcp_session*> create_session_q;
void pdn_read_loop(const thread_sched_params_t& thread_sched_params);
void pdn_read_loop(const oai::cn::util::thread_sched_params& sched_params);
int create_pdn_socket (const char * const ifname, const bool promisc, int& if_index);
int create_pdn_socket (const char * const ifname);
void setup_pdn_interfaces();
......
......@@ -55,22 +55,9 @@ void spgwu_s1u_task (void*);
void spgwu_s1u_task (void *args_p)
{
const task_id_t task_id = TASK_SPGWU_S1U;
const thread_sched_params_t* const thread_sched_params = (const thread_sched_params_t* const)args_p;
if (thread_sched_params->cpu_id >= 0) {
cpu_set_t cpuset;
CPU_SET(thread_sched_params->cpu_id,&cpuset);
if (int rc = pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset)) {
Logger::spgwu_s1u().warn( "Could not set affinity to ITTI task TASK_SPGWU_S1U, err=%d", rc);
}
}
struct sched_param sparam;
memset(&sparam, 0, sizeof(sparam));
sparam.sched_priority = thread_sched_params->sched_priority;
if (int rc = pthread_setschedparam(pthread_self(), thread_sched_params->sched_policy, &sparam)) {
Logger::spgwu_s1u().warn( "Could not set schedparam to ITTI task TASK_SPGWU_S1U, err=%d", rc);
}
const oai::cn::util::thread_sched_params* const sched_params = (const oai::cn::util::thread_sched_params* const)args_p;
sched_params->apply(task_id, Logger::spgwu_s1u());
itti_inst->notify_task_ready(task_id);
......
......@@ -58,6 +58,11 @@ void spgwu_app_task (void*);
void spgwu_app_task (void *args_p)
{
const task_id_t task_id = TASK_SPGWU_APP;
const oai::cn::util::thread_sched_params* const sched_params = (const oai::cn::util::thread_sched_params* const)args_p;
sched_params->apply(task_id, Logger::spgwu_app());
itti_inst->notify_task_ready(task_id);
do {
......@@ -111,11 +116,9 @@ void spgwu_app_task (void *args_p)
spgwu_app::spgwu_app (const std::string& config_file)
{
Logger::spgwu_app().startup("Starting...");
spgwu_cfg.load(config_file);
spgwu_cfg.execute();
spgwu_cfg.display();
if (itti_inst->create_task(TASK_SPGWU_APP, spgwu_app_task, nullptr) ) {
if (itti_inst->create_task(TASK_SPGWU_APP, spgwu_app_task, &spgwu_cfg.itti.spgwu_app_sched_params) ) {
Logger::spgwu_app().error( "Cannot create task TASK_SPGWU_APP" );
throw std::runtime_error( "Cannot create task TASK_SPGWU_APP" );
}
......
......@@ -96,7 +96,7 @@ int spgwu_config::get_pfcp_fseid(oai::cn::core::pfcp::fseid_t& fseid)
return rc;
}
//------------------------------------------------------------------------------
int spgwu_config::load_thread_sched_params(const Setting& thread_sched_params_cfg, thread_sched_params_t& cfg)
int spgwu_config::load_thread_sched_params(const Setting& thread_sched_params_cfg, oai::cn::util::thread_sched_params& cfg)
{
thread_sched_params_cfg.lookupValue(SPGWU_CONFIG_STRING_THREAD_RD_CPU_ID, cfg.cpu_id);
......@@ -127,14 +127,21 @@ int spgwu_config::load_thread_sched_params(const Setting& thread_sched_params_cf
//------------------------------------------------------------------------------
int spgwu_config::load_itti(const Setting& itti_cfg, itti_cfg_t& cfg)
{
const Setting& sched_params_cfg = itti_cfg[SPGWU_CONFIG_STRING_SCHED_PARAMS];
load_thread_sched_params(sched_params_cfg, cfg.core_sched_params);
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);
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);
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);
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);
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);
return RETURNok;
}
......@@ -208,7 +215,7 @@ int spgwu_config::load(const string& config_file)
spgwu_cfg.lookupValue(SPGWU_CONFIG_STRING_PID_DIRECTORY, pid_dir);
util::trim(pid_dir);
const Setting& itti_cfg = spgwu_cfg[SPGWU_CONFIG_STRING_ITTI];
const Setting& itti_cfg = spgwu_cfg[SPGWU_CONFIG_STRING_ITTI_TASKS];
load_itti(itti_cfg, itti);
const Setting& nw_if_cfg = spgwu_cfg[SPGWU_CONFIG_STRING_INTERFACES];
......@@ -325,24 +332,57 @@ void spgwu_config::display ()
Logger::spgwu_app().info( "Configuration:");
Logger::spgwu_app().info( "- Instance ..............: %d", instance);
Logger::spgwu_app().info( "- PID dir ...............: %s", pid_dir.c_str());
Logger::spgwu_app().info( "-S1u_S12_S4:");
Logger::spgwu_app().info( "- ITTI tasks:");
Logger::spgwu_app().info( " ITTI Timer task:");
Logger::spgwu_app().info( " CPU ID .........: %d", itti.itti_timer_sched_params.cpu_id);
Logger::spgwu_app().info( " sched policy....: %d", itti.itti_timer_sched_params.sched_policy);
Logger::spgwu_app().info( " sched priority..: %d", itti.itti_timer_sched_params.sched_priority);
Logger::spgwu_app().info( " SPGWU-S1U task:");
Logger::spgwu_app().info( " CPU ID .........: %d", itti.s1u_sched_params.cpu_id);
Logger::spgwu_app().info( " sched policy....: %d", itti.s1u_sched_params.sched_policy);
Logger::spgwu_app().info( " sched priority..: %d", itti.s1u_sched_params.sched_priority);
Logger::spgwu_app().info( " SPGWU-SX task:");
Logger::spgwu_app().info( " CPU ID .........: %d", itti.sx_sched_params.cpu_id);
Logger::spgwu_app().info( " sched policy....: %d", itti.sx_sched_params.sched_policy);
Logger::spgwu_app().info( " sched priority..: %d", itti.sx_sched_params.sched_priority);
Logger::spgwu_app().info( " SPGWU_APP task:");
Logger::spgwu_app().info( " CPU ID .........: %d", itti.spgwu_app_sched_params.cpu_id);
Logger::spgwu_app().info( " sched policy....: %d", itti.spgwu_app_sched_params.sched_policy);
Logger::spgwu_app().info( " sched priority..: %d", itti.spgwu_app_sched_params.sched_priority);
Logger::spgwu_app().info( " ASYNC_SHELL_CMD task:");
Logger::spgwu_app().info( " CPU ID .........: %d", itti.async_cmd_sched_params.cpu_id);
Logger::spgwu_app().info( " sched policy....: %d", itti.async_cmd_sched_params.sched_policy);
Logger::spgwu_app().info( " sched priority..: %d", itti.async_cmd_sched_params.sched_priority);
Logger::spgwu_app().info( "- S1u_S12_S4:");
Logger::spgwu_app().info( " iface ............: %s", s1_up.if_name.c_str());
Logger::spgwu_app().info( " ipv4.addr ........: %s", inet_ntoa (s1_up.addr4));
Logger::spgwu_app().info( " ipv4.mask ........: %s", inet_ntoa (s1_up.network4));
Logger::spgwu_app().info( " mtu ..............: %d", s1_up.mtu);
Logger::spgwu_app().info( " port .............: %d", s1_up.port);
Logger::spgwu_app().info( " Reader thread:");
Logger::spgwu_app().info( " CPU ID .........: %d", s1_up.thread_rd_sched_params.cpu_id);
Logger::spgwu_app().info( " sched policy....: %d", s1_up.thread_rd_sched_params.sched_policy);
Logger::spgwu_app().info( " sched priority..: %d", s1_up.thread_rd_sched_params.sched_priority);
Logger::spgwu_app().info( "- SXA-SXB:");
Logger::spgwu_app().info( " iface ............: %s", sx.if_name.c_str());
Logger::spgwu_app().info( " ipv4.addr ........: %s", inet_ntoa (sx.addr4));
Logger::spgwu_app().info( " ipv4.mask ........: %s", inet_ntoa (sx.network4));
Logger::spgwu_app().info( " mtu ..............: %d", sx.mtu);
Logger::spgwu_app().info( " port .............: %u", sx.port);
Logger::spgwu_app().info( " Reader thread:");
Logger::spgwu_app().info( " CPU ID .........: %d (TODO)", sx.thread_rd_sched_params.cpu_id);
Logger::spgwu_app().info( " sched policy....: %d (TODO)", sx.thread_rd_sched_params.sched_policy);
Logger::spgwu_app().info( " sched priority..: %d (TODO)", sx.thread_rd_sched_params.sched_priority);
Logger::spgwu_app().info( "- SGi:");
Logger::spgwu_app().info( " iface ............: %s", sgi.if_name.c_str());
Logger::spgwu_app().info( " ipv4.addr ........: %s", inet_ntoa (sgi.addr4));
Logger::spgwu_app().info( " ipv4.mask ........: %s", inet_ntoa (sgi.network4));
Logger::spgwu_app().info( " mtu ..............: %d", sgi.mtu);
Logger::spgwu_app().info( " gateway ..........: %s", gateway.c_str());
Logger::spgwu_app().info( " Reader thread:");
Logger::spgwu_app().info( " CPU ID .........: %d", sgi.thread_rd_sched_params.cpu_id);
Logger::spgwu_app().info( " sched policy....: %d", sgi.thread_rd_sched_params.sched_policy);
Logger::spgwu_app().info( " sched priority..: %d", sgi.thread_rd_sched_params.sched_priority);
Logger::spgwu_app().info( "- PDN networks:");
int i = 1;
for (auto it : pdns) {
......
......@@ -29,8 +29,9 @@
#ifndef FILE_SPGWU_CONFIG_HPP_SEEN
#define FILE_SPGWU_CONFIG_HPP_SEEN
#include "3gpp_29.244.h"
#include "thread_sched.h"
#include "thread_sched.hpp"
#include <libconfig.h++>
#include <mutex>
#include <netinet/in.h>
......@@ -49,11 +50,9 @@ namespace oai::cn::nf::spgwu {
#define SPGWU_CONFIG_STRING_IPV4_ADDRESS "IPV4_ADDRESS"
#define SPGWU_CONFIG_STRING_PORT "PORT"
#define SPGWU_CONFIG_STRING_SCHED_PARAMS "SCHED_PARAMS"
#define SPGWU_CONFIG_STRING_S1U_SCHED_PARAMS "S1U_SCHED_PARAMS"
#define SPGWU_CONFIG_STRING_SX_SCHED_PARAMS "SX_SCHED_PARAMS"
#define SPGWU_CONFIG_STRING_THREAD_RD_CPU_ID "THREAD_RD_CPU_ID"
#define SPGWU_CONFIG_STRING_THREAD_RD_SCHED_POLICY "THREAD_RD_SCHED_POLICY"
#define SPGWU_CONFIG_STRING_THREAD_RD_SCHED_PRIORITY "THREAD_RD_SCHED_PRIORITY"
#define SPGWU_CONFIG_STRING_THREAD_RD_CPU_ID "CPU_ID"
#define SPGWU_CONFIG_STRING_THREAD_RD_SCHED_POLICY "SCHED_POLICY"
#define SPGWU_CONFIG_STRING_THREAD_RD_SCHED_PRIORITY "SCHED_PRIORITY"
#define SPGWU_CONFIG_STRING_INTERFACE_SGI "SGI"
#define SPGWU_CONFIG_STRING_INTERFACE_SX "SX"
#define SPGWU_CONFIG_STRING_INTERFACE_S1U_S12_S4_UP "S1U_S12_S4_UP"
......@@ -64,7 +63,12 @@ namespace oai::cn::nf::spgwu {
#define SPGWU_CONFIG_STRING_SNAT "SNAT"
#define SPGWU_CONFIG_STRING_MAX_PFCP_SESSIONS "MAX_PFCP_SESSIONS"
#define SPGWU_CONFIG_STRING_SPGWC_LIST "SPGW-C_LIST"
#define SPGWU_CONFIG_STRING_ITTI "ITTI"
#define SPGWU_CONFIG_STRING_ITTI_TASKS "ITTI_TASKS"
#define SPGWU_CONFIG_STRING_ITTI_TIMER_SCHED_PARAMS "ITTI_TIMER_SCHED_PARAMS"
#define SPGWU_CONFIG_STRING_S1U_SCHED_PARAMS "S1U_SCHED_PARAMS"
#define SPGWU_CONFIG_STRING_SX_SCHED_PARAMS "SX_SCHED_PARAMS"
#define SPGWU_CONFIG_STRING_SPGWU_APP_SCHED_PARAMS "SPGWU_APP_SCHED_PARAMS"
#define SPGWU_CONFIG_STRING_ASYNC_CMD_SCHED_PARAMS "ASYNC_CMD_SCHED_PARAMS"
#define SPGW_ABORT_ON_ERROR true
#define SPGW_WARN_ON_ERROR false
......@@ -76,7 +80,7 @@ typedef struct interface_cfg_s {
struct in6_addr addr6;
unsigned int mtu;
unsigned int port;
thread_sched_params_t thread_rd_sched_params;
oai::cn::util::thread_sched_params thread_rd_sched_params;
} interface_cfg_t;
typedef struct pdn_cfg_s {
......@@ -88,9 +92,11 @@ typedef struct pdn_cfg_s {
} pdn_cfg_t;
typedef struct itti_cfg_s {
thread_sched_params_t core_sched_params;
thread_sched_params_t s1u_sched_params;
thread_sched_params_t sx_sched_params;
oai::cn::util::thread_sched_params itti_timer_sched_params;
oai::cn::util::thread_sched_params s1u_sched_params;
oai::cn::util::thread_sched_params sx_sched_params;
oai::cn::util::thread_sched_params spgwu_app_sched_params;
oai::cn::util::thread_sched_params async_cmd_sched_params;
} itti_cfg_t;
class spgwu_config {
......@@ -99,7 +105,7 @@ private:
int load_itti(const libconfig::Setting& itti_cfg, itti_cfg_t& cfg);
int load_interface(const libconfig::Setting& if_cfg, interface_cfg_t& cfg);
int load_thread_sched_params(const libconfig::Setting& thread_sched_params_cfg, thread_sched_params_t& cfg);
int load_thread_sched_params(const libconfig::Setting& thread_sched_params_cfg, oai::cn::util::thread_sched_params& cfg);
public:
......
......@@ -56,6 +56,10 @@ void spgwu_sx_task (void*);
void spgwu_sx_task (void *args_p)
{
const task_id_t task_id = TASK_SPGWU_SX;
const oai::cn::util::thread_sched_params* const sched_params = (const oai::cn::util::thread_sched_params* const)args_p;
sched_params->apply(task_id, Logger::spgwu_sx());
itti_inst->notify_task_ready(task_id);
do {
......@@ -216,7 +220,7 @@ spgwu_sx::spgwu_sx () : pfcp_l4_stack(std::string(inet_ntoa(spgwu_cfg.sx.addr4))
up_function_features.trace = 0;
up_function_features.frrt = 0;
if (itti_inst->create_task(TASK_SPGWU_SX, spgwu_sx_task, nullptr) ) {
if (itti_inst->create_task(TASK_SPGWU_SX, spgwu_sx_task, &spgwu_cfg.itti.sx_sched_params) ) {
Logger::spgwu_sx().error( "Cannot create task TASK_SPGWU_SX" );
throw std::runtime_error( "Cannot create task TASK_SPGWU_SX" );
}
......
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