diff options
Diffstat (limited to 'src/stateless')
-rw-r--r-- | src/stateless/cp/trex_stateless.cpp | 59 | ||||
-rw-r--r-- | src/stateless/cp/trex_stateless.h | 27 |
2 files changed, 68 insertions, 18 deletions
diff --git a/src/stateless/cp/trex_stateless.cpp b/src/stateless/cp/trex_stateless.cpp index 1e7e2dfa..872fdd92 100644 --- a/src/stateless/cp/trex_stateless.cpp +++ b/src/stateless/cp/trex_stateless.cpp @@ -22,6 +22,8 @@ limitations under the License. #include <trex_stateless_port.h> #include <sched.h> +#include <iostream> +#include <unistd.h> using namespace std; @@ -35,10 +37,10 @@ TrexStateless::TrexStateless() { /** - * creates the singleton stateless object + * configure the singleton stateless object * */ -void TrexStateless::create(const TrexStatelessCfg &cfg) { +void TrexStateless::configure(const TrexStatelessCfg &cfg) { TrexStateless& instance = get_instance_internal(); @@ -47,19 +49,9 @@ void TrexStateless::create(const TrexStatelessCfg &cfg) { throw TrexException("re-configuration of stateless object is not allowed"); } - /* pin this process to the current running CPU - any new thread will be called on the same CPU - (control plane restriction) - */ - cpu_set_t mask; - CPU_ZERO(&mask); - CPU_SET(sched_getcpu(), &mask); - sched_setaffinity(0, sizeof(mask), &mask); - - /* start RPC servers */ + /* create RPC servers */ instance.m_rpc_server = new TrexRpcServer(cfg.m_rpc_req_resp_cfg, cfg.m_rpc_async_cfg); instance.m_rpc_server->set_verbose(cfg.m_rpc_server_verbose); - instance.m_rpc_server->start(); /* configure ports */ @@ -69,11 +61,44 @@ void TrexStateless::create(const TrexStatelessCfg &cfg) { instance.m_ports.push_back(new TrexStatelessPort(i)); } + /* cores */ + instance.m_dp_core_count = cfg.m_dp_core_count; + /* done */ instance.m_is_configured = true; } /** + * starts the control plane side + * + */ +void +TrexStateless::launch_control_plane() { + //std::cout << "\n on control/master core \n"; + + /* pin this process to the current running CPU + any new thread will be called on the same CPU + (control plane restriction) + */ + cpu_set_t mask; + CPU_ZERO(&mask); + CPU_SET(sched_getcpu(), &mask); + sched_setaffinity(0, sizeof(mask), &mask); + + /* start RPC server */ + m_rpc_server->start(); +} + +void +TrexStateless::launch_on_dp_core() { + //std::cout << "\n on DP core \n"; + + while (true) { + sleep(1); + } +} + +/** * destroy the singleton and release all memory * * @author imarom (08-Oct-15) @@ -115,10 +140,16 @@ TrexStatelessPort * TrexStateless::get_port_by_id(uint8_t port_id) { } -uint8_t TrexStateless::get_port_count() { +uint8_t +TrexStateless::get_port_count() { return m_port_count; } +uint8_t +TrexStateless::get_dp_core_count() { + return m_dp_core_count; +} + void TrexStateless::update_stats() { diff --git a/src/stateless/cp/trex_stateless.h b/src/stateless/cp/trex_stateless.h index 02eda7e2..5c674fd6 100644 --- a/src/stateless/cp/trex_stateless.h +++ b/src/stateless/cp/trex_stateless.h @@ -83,9 +83,10 @@ class TrexStatelessCfg { public: /* default values */ TrexStatelessCfg() { - m_port_count = 0; - m_rpc_req_resp_cfg = NULL; - m_rpc_async_cfg = NULL; + m_port_count = 0; + m_dp_core_count = 0; + m_rpc_req_resp_cfg = NULL; + m_rpc_async_cfg = NULL; m_rpc_server_verbose = false; } @@ -93,6 +94,7 @@ public: const TrexRpcServerConfig *m_rpc_async_cfg; bool m_rpc_server_verbose; uint8_t m_port_count; + uint8_t m_dp_core_count; }; /** @@ -107,7 +109,7 @@ public: * reconfiguration is not allowed * an exception will be thrown */ - static void create(const TrexStatelessCfg &cfg); + static void configure(const TrexStatelessCfg &cfg); /** * destroy the instance @@ -129,9 +131,23 @@ public: return instance; } + /** + * starts the control plane side + * + */ + void launch_control_plane(); + + /** + * launch on a single DP core + * + */ + void launch_on_dp_core(); + TrexStatelessPort * get_port_by_id(uint8_t port_id); uint8_t get_port_count(); + uint8_t get_dp_core_count(); + /** * update all the stats (deep update) * (include all the ports and global stats) @@ -168,6 +184,9 @@ protected: std::vector <TrexStatelessPort *> m_ports; uint8_t m_port_count; + /* cores */ + uint8_t m_dp_core_count; + /* stats */ TrexStatelessStats m_stats; }; |