summaryrefslogtreecommitdiffstats
path: root/src/bp_sim.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/bp_sim.cpp')
-rwxr-xr-xsrc/bp_sim.cpp60
1 files changed, 50 insertions, 10 deletions
diff --git a/src/bp_sim.cpp b/src/bp_sim.cpp
index 39d46d16..d35ae68a 100755
--- a/src/bp_sim.cpp
+++ b/src/bp_sim.cpp
@@ -26,6 +26,7 @@ limitations under the License.
#include <common/basic_utils.h>
#include <trex_stream_node.h>
+#include <trex_stateless_messaging.h>
#undef VALG
@@ -218,7 +219,7 @@ bool CPlatformSocketInfoConfig::init(){
m_max_threads_per_dual_if = num_threads;
}else{
if (lp->m_threads.size() != num_threads) {
- printf("ERROR number of threads per dual ports should be the same for all dual ports\n");
+ printf("ERROR, the number of threads per dual ports should be the same for all dual ports\n");
exit(1);
}
}
@@ -230,7 +231,7 @@ bool CPlatformSocketInfoConfig::init(){
uint8_t phy_thread = lp->m_threads[j];
if (phy_thread>MAX_THREADS_SUPPORTED) {
- printf("ERROR physical thread id is %d higher than max %d \n",phy_thread,MAX_THREADS_SUPPORTED);
+ printf("ERROR, physical thread id is %d higher than max %d \n",phy_thread,MAX_THREADS_SUPPORTED);
exit(1);
}
@@ -478,8 +479,8 @@ void CPlatformSocketInfo::dump(FILE *fd){
void CRteMemPool::dump_in_case_of_error(FILE *fd){
- fprintf(fd," ERROR ERROR there is no enough memory in socket %d \n",m_pool_id);
- fprintf(fd," Try to enlarge the memory values in the configuration file /etc/trex_cfg.yaml \n");
+ fprintf(fd," ERROR,there is no enough memory in socket %d \n",m_pool_id);
+ fprintf(fd," Try to enlarge the memory values in the configuration file -/etc/trex_cfg.yaml ,see manual for more detail \n");
dump(fd);
}
@@ -3129,6 +3130,13 @@ void CNodeGenerator::remove_all(CFlowGenListPerThread * thread){
while (!m_p_queue.empty()) {
node = m_p_queue.top();
m_p_queue.pop();
+ /* sanity check */
+ if (node->m_type == CGenNode::STATELESS_PKT) {
+ CGenNodeStateless * p=(CGenNodeStateless *)node;
+ /* need to be changed in Pause support */
+ assert(p->is_mask_for_free());
+ }
+
thread->free_node( node);
}
}
@@ -3144,6 +3152,7 @@ int CNodeGenerator::open_file(std::string file_name,
return (0);
}
+
int CNodeGenerator::close_file(CFlowGenListPerThread * thread){
remove_all(thread);
BP_ASSERT(m_v_if);
@@ -3153,7 +3162,7 @@ int CNodeGenerator::close_file(CFlowGenListPerThread * thread){
int CNodeGenerator::update_stl_stats(CGenNodeStateless *node_sl){
if ( m_preview_mode.getVMode() >2 ){
- fprintf(stdout," %llu ,", (unsigned long long)m_cnt);
+ fprintf(stdout," %4lu ,", (ulong)m_cnt);
node_sl->Dump(stdout);
m_cnt++;
}
@@ -3177,6 +3186,7 @@ bool CFlowGenListPerThread::Create(uint32_t thread_id,
uint32_t max_threads){
+ m_terminated_by_master=false;
m_flow_list =flow_list;
m_core_id= core_id;
m_tcp_dpc= 0;
@@ -3515,7 +3525,7 @@ int CNodeGenerator::flush_file(dsec_t max_time,
#endif
/* if the stream has been deactivated - end */
- if (unlikely(!node_sl->is_active())) {
+ if ( unlikely( node_sl->is_mask_for_free() ) ) {
thread->free_node(node);
} else {
node_sl->handle(thread);
@@ -3573,6 +3583,9 @@ int CNodeGenerator::flush_file(dsec_t max_time,
}
}
+ if ( thread->is_terminated_by_master() ) {
+ return (0);
+ }
if (!always) {
old_offset =offset;
@@ -3659,8 +3672,19 @@ CNodeGenerator::handle_slow_messages(uint8_t type,
exit_scheduler = true;
} else {
- printf(" ERROR type is not valid %d \n",type);
- assert(0);
+ if ( type == CGenNode::COMMAND) {
+ m_p_queue.pop();
+ CGenNodeCommand *node_cmd = (CGenNodeCommand *)node;
+ {
+ TrexStatelessCpToDpMsgBase * cmd=node_cmd->m_cmd;
+ cmd->handle(&thread->m_stateless_dp_info);
+ exit_scheduler = cmd->is_quit();
+ thread->free_node((CGenNode *)node_cmd);/* free the node */
+ }
+ }else{
+ printf(" ERROR type is not valid %d \n",type);
+ assert(0);
+ }
}
return exit_scheduler;
@@ -3952,7 +3976,7 @@ void CFlowGenListPerThread::start_stateless_simulation_file(std::string erf_file
}
void CFlowGenListPerThread::stop_stateless_simulation_file(){
- m_node_gen.close_file(this);
+ m_node_gen.m_v_if->close_file();
}
void CFlowGenListPerThread::start_stateless_daemon_simulation(){
@@ -3962,6 +3986,15 @@ void CFlowGenListPerThread::start_stateless_daemon_simulation(){
}
+
+/* return true if we need to shedule next_stream, */
+
+bool CFlowGenListPerThread::set_stateless_next_node( CGenNodeStateless * cur_node,
+ CGenNodeStateless * next_node){
+ return ( m_stateless_dp_info.set_stateless_next_node(cur_node,next_node) );
+}
+
+
void CFlowGenListPerThread::start_stateless_daemon(){
m_cur_time_sec = 0;
m_stateless_dp_info.start();
@@ -4010,11 +4043,13 @@ void CFlowGenListPerThread::start_generate_stateful(std::string erf_file_name,
#endif
m_node_gen.flush_file(c_stop_sec,d_time_flow, false,this,old_offset);
+
+
#ifdef VALG
CALLGRIND_STOP_INSTRUMENTATION;
printf (" %llu \n",os_get_hr_tick_64()-_start_time);
#endif
- if ( !CGlobalInfo::m_options.preview.getNoCleanFlowClose() ){
+ if ( !CGlobalInfo::m_options.preview.getNoCleanFlowClose() && (is_terminated_by_master()==false) ){
/* clean close */
m_node_gen.flush_file(m_cur_time_sec, d_time_flow, true,this,old_offset);
}
@@ -6882,6 +6917,11 @@ void CGenNodeBase::free_base(){
p->free_stl_node();
return;
}
+ if ( m_type == COMMAND ) {
+ CGenNodeCommand* p=(CGenNodeCommand*)this;
+ p->free_command();
+ }
+
}