summaryrefslogtreecommitdiffstats
path: root/src/sim
diff options
context:
space:
mode:
authorimarom <imarom@cisco.com>2016-01-05 08:58:42 -0500
committerimarom <imarom@cisco.com>2016-01-05 09:03:53 -0500
commitc905d6b0845e79dbc5d5d37eee560d1dbc58b6ff (patch)
tree91ed37d44cdfe69d31078bd8eb667f82067a9dda /src/sim
parent349d47374639465d58bac37f6e93045a1f9bb718 (diff)
stateless sim - core_index and all cores simulation
Diffstat (limited to 'src/sim')
-rw-r--r--src/sim/trex_sim.h6
-rw-r--r--src/sim/trex_sim_stateless.cpp52
2 files changed, 44 insertions, 14 deletions
diff --git a/src/sim/trex_sim.h b/src/sim/trex_sim.h
index cc02fd75..a541ce01 100644
--- a/src/sim/trex_sim.h
+++ b/src/sim/trex_sim.h
@@ -102,7 +102,8 @@ public:
const std::string &out_filename,
int port_count,
int dp_core_count,
- int dp_core_index);
+ int dp_core_index,
+ int limit);
TrexStateless * get_stateless_obj() {
return m_trex_stateless;
@@ -121,7 +122,7 @@ private:
void execute_json(const std::string &json_filename);
void run_dp(const std::string &out_filename);
- void run_dp_core(int core_index, const std::string &out_filename);
+ uint64_t run_dp_core(int core_index, const std::string &out_filename);
void flush_dp_to_cp_messages_core(int core_index);
@@ -141,6 +142,7 @@ private:
int m_port_count;
int m_dp_core_count;
int m_dp_core_index;
+ uint64_t m_limit;
};
#endif /* __TREX_SIM_H__ */
diff --git a/src/sim/trex_sim_stateless.cpp b/src/sim/trex_sim_stateless.cpp
index 2821644f..2b73f686 100644
--- a/src/sim/trex_sim_stateless.cpp
+++ b/src/sim/trex_sim_stateless.cpp
@@ -120,6 +120,7 @@ SimStateless::SimStateless() {
m_dp_core_count = -1;
m_dp_core_index = -1;
m_port_count = -1;
+ m_limit = 0;
/* override ownership checks */
TrexRpcCommand::test_set_override_ownership(true);
@@ -131,15 +132,18 @@ SimStateless::run(const string &json_filename,
const string &out_filename,
int port_count,
int dp_core_count,
- int dp_core_index) {
+ int dp_core_index,
+ int limit) {
assert(dp_core_count > 0);
- assert(dp_core_index >= 0);
- assert(dp_core_index < dp_core_count);
+
+ /* -1 means its not set or positive value between 0 and the dp core count - 1*/
+ assert( (dp_core_index == -1) || ( (dp_core_index >=0 ) && (dp_core_index < dp_core_count) ) );
m_dp_core_count = dp_core_count;
m_dp_core_index = dp_core_index;
m_port_count = port_count;
+ m_limit = limit;
prepare_dataplane();
prepare_control_plane();
@@ -266,33 +270,57 @@ SimStateless::validate_response(const Json::Value &resp) {
void
SimStateless::run_dp(const std::string &out_filename) {
+ uint64_t pkt_cnt = 0;
- for (int i = 0; i < m_dp_core_count; i++) {
- if (i == m_dp_core_index) {
- run_dp_core(i, out_filename);
+ if (m_dp_core_count == 1) {
+ pkt_cnt = run_dp_core(0, out_filename);
+ } else {
+
+ /* do we have a specific core index to capture ? */
+ if (m_dp_core_index != -1) {
+ for (int i = 0; i < m_dp_core_count; i++) {
+ if (i == m_dp_core_index) {
+ pkt_cnt += run_dp_core(i, out_filename);
+ } else {
+ run_dp_core(i, "/dev/null");
+ }
+ }
} else {
- run_dp_core(i, "/dev/null");
+ for (int i = 0; i < m_dp_core_count; i++) {
+ std::stringstream ss;
+ ss << out_filename << "-" << i;
+ pkt_cnt += run_dp_core(i, ss.str());
+ }
}
+
}
- CFlowGenListPerThread *lpt = m_fl.m_threads_info[m_dp_core_index];
std::cout << "\n";
std::cout << "ports: " << m_port_count << "\n";
std::cout << "cores: " << m_dp_core_count << "\n";
- std::cout << "core index: " << m_dp_core_index << "\n";
- std::cout << "\nwritten " << lpt->m_node_gen.m_cnt << " packets " << "to '" << out_filename << "'\n\n";
+
+ if (m_dp_core_index != -1) {
+ std::cout << "core index: " << m_dp_core_index << "\n";
+ } else {
+ std::cout << "core index: merge all\n";
+ }
+
+ std::cout << "pkt limit: " << m_limit << "\n";
+ std::cout << "\nwritten " << pkt_cnt << " packets " << "to '" << out_filename << "'\n\n";
}
-void
+uint64_t
SimStateless::run_dp_core(int core_index, const std::string &out_filename) {
CFlowGenListPerThread *lpt = m_fl.m_threads_info[core_index];
- lpt->start_stateless_simulation_file((std::string)out_filename, CGlobalInfo::m_options.preview);
+ lpt->start_stateless_simulation_file((std::string)out_filename, CGlobalInfo::m_options.preview, m_limit / m_dp_core_count);
lpt->start_stateless_daemon_simulation();
flush_dp_to_cp_messages_core(core_index);
+
+ return lpt->m_node_gen.m_cnt;
}