From 857bdcf05a920b99e1cf180c700176b04801da00 Mon Sep 17 00:00:00 2001 From: imarom Date: Mon, 4 Jan 2016 09:49:37 -0500 Subject: some additions to the stateless simulation mode --- src/stateless/dp/trex_stateless_dp_core.cpp | 7 +++++-- src/stateless/dp/trex_stateless_dp_core.h | 6 ++++-- 2 files changed, 9 insertions(+), 4 deletions(-) (limited to 'src/stateless/dp') diff --git a/src/stateless/dp/trex_stateless_dp_core.cpp b/src/stateless/dp/trex_stateless_dp_core.cpp index c211b9f5..0a9a88ab 100644 --- a/src/stateless/dp/trex_stateless_dp_core.cpp +++ b/src/stateless/dp/trex_stateless_dp_core.cpp @@ -353,8 +353,11 @@ void TrexStatelessDpCore::idle_state_loop() { while (m_state == STATE_IDLE) { - periodic_check_for_cp_messages(); - delay(200); + bool had_msg = periodic_check_for_cp_messages(); + /* if no message - backoff for some time */ + if (!had_msg) { + delay(200); + } } } diff --git a/src/stateless/dp/trex_stateless_dp_core.h b/src/stateless/dp/trex_stateless_dp_core.h index 7dc4a2b2..efdb364c 100644 --- a/src/stateless/dp/trex_stateless_dp_core.h +++ b/src/stateless/dp/trex_stateless_dp_core.h @@ -185,12 +185,12 @@ public: * * @author imarom (27-Oct-15) */ - void periodic_check_for_cp_messages() { + bool periodic_check_for_cp_messages() { // doing this inline for performance reasons /* fast path */ if ( likely ( m_ring_from_cp->isEmpty() ) ) { - return; + return false; } while ( true ) { @@ -204,6 +204,8 @@ public: handle_cp_msg(msg); } + return true; + } /* quit the main loop, work in both stateless in stateful, don't free memory trigger from master */ -- cgit 1.2.3-korg