summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorimarom <imarom@cisco.com>2015-11-08 11:39:09 +0200
committerimarom <imarom@cisco.com>2015-11-08 11:39:09 +0200
commitbc7d9ee81604fd33607569ac4f03ca8b91777b29 (patch)
treec1d033860162fd68c76dc5578501c0f5373ae477 /src
parentf6b521fb76e74036c626c10f6ae11ea525ac97b7 (diff)
code review notes:
1. performance improvement for stateless DP core object (direct object) 2. exit scheduler loop is now using a scheduled message and not IF 3. duration for inifinite is negative number 4. fixed stop_traffic scheduled node time
Diffstat (limited to 'src')
-rwxr-xr-xsrc/bp_sim.cpp58
-rwxr-xr-xsrc/bp_sim.h9
-rw-r--r--src/stateless/dp/trex_stateless_dp_core.cpp16
-rw-r--r--src/stateless/dp/trex_stateless_dp_core.h13
-rw-r--r--src/stub/trex_stateless_stub.cpp3
5 files changed, 66 insertions, 33 deletions
diff --git a/src/bp_sim.cpp b/src/bp_sim.cpp
index 842bc478..d59da900 100755
--- a/src/bp_sim.cpp
+++ b/src/bp_sim.cpp
@@ -3203,7 +3203,7 @@ bool CFlowGenListPerThread::Create(uint32_t thread_id,
assert(m_ring_to_rx);
/* create the info required for stateless DP core */
- m_stateless_dp_info = new TrexStatelessDpCore(thread_id, this);
+ m_stateless_dp_info.create(thread_id, this);
return (true);
}
@@ -3353,8 +3353,6 @@ void CFlowGenListPerThread::Delete(){
Clean();
m_cpu_cp_u.Delete();
- delete m_stateless_dp_info;
- m_stateless_dp_info = NULL;
}
@@ -3401,15 +3399,24 @@ int CNodeGenerator::flush_file(dsec_t max_time,
bool done=false;
thread->m_cpu_dp_u.start_work();
- while (!m_p_queue.empty()) {
+
+ /**
+ * if a positive value was given to max time
+ * schedule an exit node
+ */
+ if (max_time > 0) {
+ CGenNode *exit_node = thread->create_node();
+
+ exit_node->m_type = CGenNode::EXIT_SCHED;
+ exit_node->m_time = max_time;
+ add_node(exit_node);
+ }
+
+ while (true) {
+
node = m_p_queue.top();
- n_time = node->m_time+ offset;
+ n_time = node->m_time + offset;
- if (( (n_time) > max_time ) &&
- (always==false) ) {
- /* nothing to do */
- break;
- }
events++;
/*#ifdef VALG
if (events > 1 ) {
@@ -3507,13 +3514,19 @@ int CNodeGenerator::flush_file(dsec_t max_time,
}
}else{
- handle_slow_messages(type,node,thread,always);
+ bool exit_sccheduler = handle_slow_messages(type,node,thread,always);
+ if (exit_sccheduler) {
+ break;
+ }
}
}
}
}
+ /* cleanup */
+ remove_all(thread);
+
if (!always) {
old_offset =offset;
}else{
@@ -3523,10 +3536,14 @@ int CNodeGenerator::flush_file(dsec_t max_time,
return (0);
}
-void CNodeGenerator::handle_slow_messages(uint8_t type,
- CGenNode * node,
- CFlowGenListPerThread * thread,
- bool always){
+bool
+CNodeGenerator::handle_slow_messages(uint8_t type,
+ CGenNode * node,
+ CFlowGenListPerThread * thread,
+ bool always){
+
+ /* should we continue after */
+ bool exit_scheduler = false;
if (unlikely (type == CGenNode::FLOW_DEFER_PORT_RELEASE) ) {
m_p_queue.pop();
@@ -3547,7 +3564,7 @@ void CNodeGenerator::handle_slow_messages(uint8_t type,
m_p_queue.pop();
/* time out, need to free the flow and remove the association , we didn't get convertion yet*/
thread->terminate_nat_flows(node);
- return;
+ return (exit_scheduler);
}else{
flush_one_node_to_file(node);
@@ -3585,14 +3602,15 @@ void CNodeGenerator::handle_slow_messages(uint8_t type,
thread->free_node(node);
}
- /* must be the last section of processing */
} else if ( type == CGenNode::EXIT_SCHED ) {
- remove_all(thread);
+ exit_scheduler = true;
} else {
printf(" ERROR type is not valid %d \n",type);
assert(0);
}
+
+ return exit_scheduler;
}
@@ -3831,7 +3849,7 @@ void CFlowGenListPerThread::handel_nat_msg(CGenNodeNatInfo * msg){
void CFlowGenListPerThread::check_msgs(void) {
/* inlined for performance */
- m_stateless_dp_info->periodic_check_for_cp_messages();
+ m_stateless_dp_info.periodic_check_for_cp_messages();
if ( likely ( m_ring_from_rx->isEmpty() ) ) {
return;
@@ -3908,7 +3926,7 @@ const uint8_t test_udp_pkt[]={
void CFlowGenListPerThread::start_stateless_daemon(){
m_cur_time_sec = 0;
- m_stateless_dp_info->start();
+ m_stateless_dp_info.start();
}
diff --git a/src/bp_sim.h b/src/bp_sim.h
index 75958776..c201cd20 100755
--- a/src/bp_sim.h
+++ b/src/bp_sim.h
@@ -1901,9 +1901,10 @@ private:
return (m_v_if->send_node(node));
}
int update_stats(CGenNode * node);
- FORCE_NO_INLINE void handle_slow_messages(uint8_t type,
- CGenNode * node,
- CFlowGenListPerThread * thread,
+
+ FORCE_NO_INLINE bool handle_slow_messages(uint8_t type,
+ CGenNode * node,
+ CFlowGenListPerThread * thread,
bool always);
@@ -3500,7 +3501,7 @@ private:
flow_id_node_t m_flow_id_to_node_lookup;
- TrexStatelessDpCore *m_stateless_dp_info;
+ TrexStatelessDpCore m_stateless_dp_info;
private:
uint8_t m_cacheline_pad[RTE_CACHE_LINE_SIZE][19]; // improve prefech
diff --git a/src/stateless/dp/trex_stateless_dp_core.cpp b/src/stateless/dp/trex_stateless_dp_core.cpp
index 5f4e553a..35ce43a8 100644
--- a/src/stateless/dp/trex_stateless_dp_core.cpp
+++ b/src/stateless/dp/trex_stateless_dp_core.cpp
@@ -30,7 +30,9 @@ usec_to_sec(double usec) {
return (usec / (1000 * 1000));
}
-TrexStatelessDpCore::TrexStatelessDpCore(uint8_t thread_id, CFlowGenListPerThread *core) {
+
+void
+TrexStatelessDpCore::create(uint8_t thread_id, CFlowGenListPerThread *core) {
m_thread_id = thread_id;
m_core = core;
@@ -73,7 +75,7 @@ TrexStatelessDpCore::start_scheduler() {
m_core->m_node_gen.add_node(node_sync);
double old_offset = 0.0;
- m_core->m_node_gen.flush_file(100000000, 0.0, false, m_core, old_offset);
+ m_core->m_node_gen.flush_file(-1, 0.0, false, m_core, old_offset);
}
void
@@ -176,14 +178,14 @@ TrexStatelessDpCore::stop_traffic(uint8_t port_id) {
m_state = STATE_IDLE;
/* stop the scheduler */
- CGenNode *node = m_core->create_node() ;
+ CGenNode *node = m_core->create_node() ;
- node->m_type = CGenNode::EXIT_SCHED;
+ 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;
+ /* make sure it will be scheduled after the current node */
+ node->m_time = m_core->m_cur_time_sec + 0.0001;
- m_core->m_node_gen.add_node(node);
+ m_core->m_node_gen.add_node(node);
}
}
diff --git a/src/stateless/dp/trex_stateless_dp_core.h b/src/stateless/dp/trex_stateless_dp_core.h
index f3b5ff62..f4dbad08 100644
--- a/src/stateless/dp/trex_stateless_dp_core.h
+++ b/src/stateless/dp/trex_stateless_dp_core.h
@@ -42,7 +42,18 @@ public:
STATE_TRANSMITTING
};
- TrexStatelessDpCore(uint8_t thread_id, CFlowGenListPerThread *core);
+ TrexStatelessDpCore() {
+ m_thread_id = 0;
+ m_core = NULL;
+ }
+
+ /**
+ * "static constructor"
+ *
+ * @param thread_id
+ * @param core
+ */
+ void create(uint8_t thread_id, CFlowGenListPerThread *core);
/**
* launch the stateless DP core code
diff --git a/src/stub/trex_stateless_stub.cpp b/src/stub/trex_stateless_stub.cpp
index de56e57a..199356d8 100644
--- a/src/stub/trex_stateless_stub.cpp
+++ b/src/stub/trex_stateless_stub.cpp
@@ -4,7 +4,8 @@
class CFlowGenListPerThread;
class TrexStatelessCpToDpMsgBase;
-TrexStatelessDpCore::TrexStatelessDpCore(unsigned char, CFlowGenListPerThread*) {
+void
+TrexStatelessDpCore::create(unsigned char, CFlowGenListPerThread*) {
m_thread_id = 0;
m_core = NULL;