summaryrefslogtreecommitdiffstats
path: root/src/sim
diff options
context:
space:
mode:
authorimarom <imarom@cisco.com>2016-08-10 17:45:36 +0300
committerimarom <imarom@cisco.com>2016-08-15 16:03:59 +0300
commitba7b5dff853a3b11b0cc2e7b29cfc1cd99e606f7 (patch)
tree25a2d72756217ef5d364a4c9b5a6e5e9a9d165a7 /src/sim
parentce1de344579505665b88c2d548ca8d2acc135988 (diff)
core mask - first phase
Diffstat (limited to 'src/sim')
-rw-r--r--src/sim/trex_sim.h3
-rw-r--r--src/sim/trex_sim_stateless.cpp45
2 files changed, 35 insertions, 13 deletions
diff --git a/src/sim/trex_sim.h b/src/sim/trex_sim.h
index 0c343261..f52ad9b4 100644
--- a/src/sim/trex_sim.h
+++ b/src/sim/trex_sim.h
@@ -143,6 +143,7 @@ private:
void prepare_control_plane();
void prepare_dataplane();
void execute_json(const std::string &json_filename);
+ void find_active_dp_cores();
void run_dp(const std::string &out_filename);
@@ -179,6 +180,8 @@ private:
int m_dp_core_index;
uint64_t m_limit;
bool m_is_dry_run;
+
+ std::vector<uint8_t> m_active_dp_cores;
};
#endif /* __TREX_SIM_H__ */
diff --git a/src/sim/trex_sim_stateless.cpp b/src/sim/trex_sim_stateless.cpp
index 77bd4d70..20041c2b 100644
--- a/src/sim/trex_sim_stateless.cpp
+++ b/src/sim/trex_sim_stateless.cpp
@@ -123,14 +123,14 @@ public:
************************/
SimStateless::SimStateless() {
- m_publisher = NULL;
- m_dp_to_cp_handler = NULL;
- m_verbose = false;
- m_dp_core_count = -1;
- m_dp_core_index = -1;
- m_port_count = -1;
- m_limit = 0;
- m_is_dry_run = false;
+ m_publisher = NULL;
+ m_dp_to_cp_handler = NULL;
+ m_verbose = false;
+ m_dp_core_count = -1;
+ m_dp_core_index = -1;
+ m_port_count = -1;
+ m_limit = 0;
+ m_is_dry_run = false;
/* override ownership checks */
TrexRpcCommand::test_set_override_ownership(true);
@@ -138,6 +138,23 @@ SimStateless::SimStateless() {
}
+/**
+ * on the simulation we first construct CP and then DP
+ * the only way to "assume" which DP will be active during
+ * the run is by checking for pending CP messages on the cores
+ *
+ * @author imarom (8/10/2016)
+ */
+void
+SimStateless::find_active_dp_cores() {
+ for (int core_index = 0; core_index < m_dp_core_count; core_index++) {
+ CFlowGenListPerThread *lpt = m_fl.m_threads_info[core_index];
+ if (lpt->are_any_pending_cp_messages()) {
+ m_active_dp_cores.push_back(core_index);
+ }
+ }
+}
+
int
SimStateless::run(const string &json_filename,
const string &out_filename,
@@ -168,6 +185,8 @@ SimStateless::run(const string &json_filename,
return (-1);
}
+ find_active_dp_cores();
+
run_dp(out_filename);
return 0;
@@ -353,14 +372,14 @@ SimStateless::run_dp(const std::string &out_filename) {
show_intro(out_filename);
if (is_multiple_capture()) {
- for (int i = 0; i < m_dp_core_count; i++) {
+ for (int i : m_active_dp_cores) {
std::stringstream ss;
ss << out_filename << "-" << i;
run_dp_core(i, ss.str(), core_stats, total);
}
} else {
- for (int i = 0; i < m_dp_core_count; i++) {
+ for (int i : m_active_dp_cores) {
run_dp_core(i, out_filename, core_stats, total);
}
}
@@ -414,9 +433,9 @@ SimStateless::get_limit_per_core(int core_index) {
if (m_limit == 0) {
return (0);
} else {
- uint64_t l = std::max((uint64_t)1, m_limit / m_dp_core_count);
- if (core_index == 0) {
- l += (m_limit % m_dp_core_count);
+ uint64_t l = std::max((uint64_t)1, m_limit / m_active_dp_cores.size());
+ if (core_index == m_active_dp_cores[0]) {
+ l += (m_limit % m_active_dp_cores.size());
}
return l;
}