summaryrefslogtreecommitdiffstats
path: root/src/stateless/cp/trex_stateless.cpp
diff options
context:
space:
mode:
authorimarom <imarom@cisco.com>2015-10-08 17:39:51 +0200
committerimarom <imarom@cisco.com>2015-10-08 17:39:51 +0200
commitd7af282dc1cd629c251a937c9aa88a9a5a47030b (patch)
tree87649c01f9f65bfd9acfbafa61f2f7ca901b6c64 /src/stateless/cp/trex_stateless.cpp
parentd56d0665470dd3c8959c8945162df13827b9d4c6 (diff)
first integration with DPDK layer
Diffstat (limited to 'src/stateless/cp/trex_stateless.cpp')
-rw-r--r--src/stateless/cp/trex_stateless.cpp59
1 files changed, 45 insertions, 14 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() {