diff options
author | imarom <imarom@cisco.com> | 2015-11-17 15:27:46 +0200 |
---|---|---|
committer | imarom <imarom@cisco.com> | 2015-11-17 15:27:46 +0200 |
commit | d9ed62e91c83039521b817779b4bc0197cc8151a (patch) | |
tree | ebdef86ed9e9b07b2982ff6bcfdcef2f42b86370 /src | |
parent | 07e6795a7497151e0920c82337cca6cfb5c3c3cd (diff) | |
parent | aa9bf54e6f892168482ed647a0e67ab10b1cf34a (diff) |
Merge branch 'master' of csi-sceasr-b45:/auto/proj-pcube-b/apps/PL-b/tools/repo//trex-core
Conflicts:
src/main_dpdk.cpp
Diffstat (limited to 'src')
-rwxr-xr-x | src/bp_sim.cpp | 8 | ||||
-rwxr-xr-x | src/bp_sim.h | 8 | ||||
-rwxr-xr-x | src/main_dpdk.cpp | 47 | ||||
-rw-r--r-- | src/stateless/dp/trex_stateless_dp_core.cpp | 12 | ||||
-rw-r--r-- | src/stateless/dp/trex_stateless_dp_core.h | 3 | ||||
-rw-r--r-- | src/stateless/messaging/trex_stateless_messaging.cpp | 20 | ||||
-rw-r--r-- | src/stateless/messaging/trex_stateless_messaging.h | 17 |
7 files changed, 114 insertions, 1 deletions
diff --git a/src/bp_sim.cpp b/src/bp_sim.cpp index 39d46d16..c456e9a3 100755 --- a/src/bp_sim.cpp +++ b/src/bp_sim.cpp @@ -3177,6 +3177,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; @@ -3573,6 +3574,9 @@ int CNodeGenerator::flush_file(dsec_t max_time, } } + if ( thread->is_terminated_by_master() ) { + return (0); + } if (!always) { old_offset =offset; @@ -4010,11 +4014,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); } diff --git a/src/bp_sim.h b/src/bp_sim.h index eef5576b..d218237c 100755 --- a/src/bp_sim.h +++ b/src/bp_sim.h @@ -3400,6 +3400,13 @@ public: uint32_t max_threads); void Delete(); + void set_terminate_mode(bool is_terminate){ + m_terminated_by_master =is_terminate; + } + bool is_terminated_by_master(){ + return (m_terminated_by_master); + } + void set_vif(CVirtualIF * v_if){ m_node_gen.set_vif(v_if); } @@ -3542,6 +3549,7 @@ private: flow_id_node_t m_flow_id_to_node_lookup; TrexStatelessDpCore m_stateless_dp_info; + bool m_terminated_by_master; private: uint8_t m_cacheline_pad[RTE_CACHE_LINE_SIZE][19]; // improve prefech diff --git a/src/main_dpdk.cpp b/src/main_dpdk.cpp index c85256c1..13eca0d2 100755 --- a/src/main_dpdk.cpp +++ b/src/main_dpdk.cpp @@ -59,6 +59,7 @@ limitations under the License. #include <stateless/cp/trex_stateless.h> #include <stateless/dp/trex_stream_node.h> #include <publisher/trex_publisher.h> +#include <stateless/messaging/trex_stateless_messaging.h> #include <../linux_dpdk/version.h> @@ -2757,8 +2758,15 @@ public: int reset_counters(); +public: +private: + /* try to stop all datapath cores */ + void try_stop_all_dp(); + /* send message to all dp cores */ + int send_message_all_dp(TrexStatelessCpToDpMsgBase *msg); public: + int start_send_master(); int start_master_stateless(); @@ -3184,6 +3192,40 @@ bool CGlobalTRex::is_all_links_are_up(bool dump){ } +void CGlobalTRex::try_stop_all_dp(){ + + TrexStatelessDpQuit * msg= new TrexStatelessDpQuit(); + send_message_all_dp(msg); + delete msg; + bool all_core_finished = false; + int i; + for (i=0; i<20; i++) { + if ( is_all_cores_finished() ){ + all_core_finished =true; + break; + } + delay(100); + } + if ( all_core_finished ){ + printf(" All cores stopped !! \n"); + }else{ + printf(" ERROR one of the DP core is stucked !\n"); + } +} + + +int CGlobalTRex::send_message_all_dp(TrexStatelessCpToDpMsgBase *msg){ + + int max_threads=(int)CMsgIns::Ins()->getCpDp()->get_num_threads(); + int i; + + for (i=0; i<max_threads; i++) { + CNodeRing *ring = CMsgIns::Ins()->getCpDp()->getRingCpToDp((uint8_t)i); + ring->Enqueue((CGenNode*)msg->clone()); + } + return (0); +} + int CGlobalTRex::ixgbe_rx_queue_flush(){ int i; @@ -4024,6 +4066,11 @@ int CGlobalTRex::run_in_master(){ } } + if (!is_all_cores_finished()) { + /* probably CLTR-C */ + try_stop_all_dp(); + } + m_mg.stop(); delay(1000); if ( was_stopped ){ diff --git a/src/stateless/dp/trex_stateless_dp_core.cpp b/src/stateless/dp/trex_stateless_dp_core.cpp index 07e03678..0747c1a0 100644 --- a/src/stateless/dp/trex_stateless_dp_core.cpp +++ b/src/stateless/dp/trex_stateless_dp_core.cpp @@ -72,6 +72,14 @@ TrexStatelessDpCore::idle_state_loop() { } } + + +void TrexStatelessDpCore::quit_main_loop(){ + m_core->set_terminate_mode(true); /* mark it as terminated */ + add_duration(0.0001); /* add message to terminate */ +} + + /** * scehduler runs when traffic exists * it will return when no more transmitting is done on this @@ -106,6 +114,10 @@ TrexStatelessDpCore::start() { while (true) { run_once(); + + if ( m_core->is_terminated_by_master() ) { + break; + } } } diff --git a/src/stateless/dp/trex_stateless_dp_core.h b/src/stateless/dp/trex_stateless_dp_core.h index 7448d215..aaa6eed3 100644 --- a/src/stateless/dp/trex_stateless_dp_core.h +++ b/src/stateless/dp/trex_stateless_dp_core.h @@ -109,6 +109,9 @@ public: } + /* quit the main loop, work in both stateless in stateful, don't free memory trigger from master */ + void quit_main_loop(); + private: /** * in idle state loop, the processor most of the time sleeps diff --git a/src/stateless/messaging/trex_stateless_messaging.cpp b/src/stateless/messaging/trex_stateless_messaging.cpp index d8ebc52c..2e3acffd 100644 --- a/src/stateless/messaging/trex_stateless_messaging.cpp +++ b/src/stateless/messaging/trex_stateless_messaging.cpp @@ -76,3 +76,23 @@ TrexStatelessDpStop::clone() { return new_msg; } + + + +TrexStatelessCpToDpMsgBase * +TrexStatelessDpQuit::clone(){ + + TrexStatelessCpToDpMsgBase *new_msg = new TrexStatelessDpQuit(); + + return new_msg; +} + + + +bool TrexStatelessDpQuit::handle(TrexStatelessDpCore *dp_core){ + + /* quit */ + dp_core->quit_main_loop(); + return (true); +} + diff --git a/src/stateless/messaging/trex_stateless_messaging.h b/src/stateless/messaging/trex_stateless_messaging.h index 90897665..6473a6a4 100644 --- a/src/stateless/messaging/trex_stateless_messaging.h +++ b/src/stateless/messaging/trex_stateless_messaging.h @@ -1,5 +1,6 @@ /* Itay Marom + Hanoch Haim Cisco Systems, Inc. */ @@ -99,5 +100,21 @@ private: uint8_t m_port_id; }; +/** + * a message to Quit the datapath traffic. support only stateless for now + * + * @author hhaim + */ +class TrexStatelessDpQuit : public TrexStatelessCpToDpMsgBase { +public: + + TrexStatelessDpQuit() { + } + + virtual bool handle(TrexStatelessDpCore *dp_core); + + virtual TrexStatelessCpToDpMsgBase * clone(); +}; + #endif /* __TREX_STATELESS_MESSAGING_H__ */ |