summaryrefslogtreecommitdiffstats
path: root/src/stateless/dp/trex_stateless_dp_core.cpp
diff options
context:
space:
mode:
authorimarom <imarom@cisco.com>2016-03-02 14:37:58 +0200
committerimarom <imarom@cisco.com>2016-03-02 14:37:58 +0200
commit9c62e2a6f114d99a7271e259bad2601a28cd9c4a (patch)
tree49b1358015e3989955c0986c274dc58cc13e8002 /src/stateless/dp/trex_stateless_dp_core.cpp
parent106a9ecd9ef7e353d867aaf00fcc8353ccf000b9 (diff)
brief/deep sleep for DP cores
Diffstat (limited to 'src/stateless/dp/trex_stateless_dp_core.cpp')
-rw-r--r--src/stateless/dp/trex_stateless_dp_core.cpp21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/stateless/dp/trex_stateless_dp_core.cpp b/src/stateless/dp/trex_stateless_dp_core.cpp
index 19eface1..f8d6d828 100644
--- a/src/stateless/dp/trex_stateless_dp_core.cpp
+++ b/src/stateless/dp/trex_stateless_dp_core.cpp
@@ -394,12 +394,27 @@ bool TrexStatelessDpCore::set_stateless_next_node(CGenNodeStateless * cur_node,
void
TrexStatelessDpCore::idle_state_loop() {
+ const int SHORT_DELAY_MS = 2;
+ const int LONG_DELAY_MS = 50;
+ const int DEEP_SLEEP_LIMIT = 2000;
+
+ int counter = 0;
+
while (m_state == STATE_IDLE) {
bool had_msg = periodic_check_for_cp_messages();
- /* if no message - backoff for some time */
- if (!had_msg) {
- delay(200);
+ if (had_msg) {
+ counter = 0;
+ continue;
+ }
+
+ /* enter deep sleep only if enough time had passed */
+ if (counter < DEEP_SLEEP_LIMIT) {
+ delay(SHORT_DELAY_MS);
+ counter++;
+ } else {
+ delay(LONG_DELAY_MS);
}
+
}
}