diff options
author | imarom <imarom@cisco.com> | 2015-11-01 14:28:28 +0200 |
---|---|---|
committer | imarom <imarom@cisco.com> | 2015-11-01 14:28:28 +0200 |
commit | ee2c7f45e0bf973443b70eb8329811bcad44f83a (patch) | |
tree | c3f2cc1db1b090bedfd80979c931d50708053100 /src/stateless/dp/trex_stateless_dp_core.cpp | |
parent | a1971ec3a7f6cbe0aea1393a57aa17bf44deedac (diff) |
stateless cores starts on IDLE - and starts the scheduler only when
traffic is being transmitted
if the traffic stops completely on the core - back to IDLE state
Diffstat (limited to 'src/stateless/dp/trex_stateless_dp_core.cpp')
-rw-r--r-- | src/stateless/dp/trex_stateless_dp_core.cpp | 44 |
1 files changed, 42 insertions, 2 deletions
diff --git a/src/stateless/dp/trex_stateless_dp_core.cpp b/src/stateless/dp/trex_stateless_dp_core.cpp index fd54256d..306b23d0 100644 --- a/src/stateless/dp/trex_stateless_dp_core.cpp +++ b/src/stateless/dp/trex_stateless_dp_core.cpp @@ -37,9 +37,30 @@ TrexStatelessDpCore::TrexStatelessDpCore(uint8_t thread_id, CFlowGenListPerThrea m_state = STATE_IDLE; } -void -TrexStatelessDpCore::start() { +/** + * in idle state loop, the processor most of the time sleeps + * and periodically checks for messages + * + * @author imarom (01-Nov-15) + */ +void +TrexStatelessDpCore::idle_state_loop() { + while (m_state == STATE_IDLE) { + periodic_check_for_cp_messages(); + delay(200); + } +} + +/** + * scehduler runs when traffic exists + * it will return when no more transmitting is done on this + * core + * + * @author imarom (01-Nov-15) + */ +void +TrexStatelessDpCore::start_scheduler() { /* creates a maintenace job using the scheduler */ CGenNode * node_sync = m_core->create_node() ; node_sync->m_type = CGenNode::FLOW_SYNC; @@ -48,7 +69,16 @@ TrexStatelessDpCore::start() { double old_offset = 0.0; m_core->m_node_gen.flush_file(100000000, 0.0, false, m_core, old_offset); +} + +void +TrexStatelessDpCore::start() { + + while (true) { + idle_state_loop(); + start_scheduler(); + } } void @@ -126,6 +156,16 @@ TrexStatelessDpCore::stop_traffic(uint8_t port_id) { if (m_active_nodes.size() == 0) { m_state = STATE_IDLE; + /* stop the scheduler */ + + CGenNode *node = m_core->create_node() ; + + node->m_type = CGenNode::EXIT_SCHED; + + /* make sure it will be scheduled after the current node */ + node->m_time = m_core->m_node_gen.m_p_queue.top()->m_time; + + m_core->m_node_gen.add_node(node); } } |