summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIdo Barnea <ibarnea@cisco.com>2016-03-31 14:34:43 +0300
committerIdo Barnea <ibarnea@cisco.com>2016-03-31 14:34:43 +0300
commit9f269a00c57683223a11bec20c7b8b69d068e8b7 (patch)
tree3345e95b5f4c09d2dccce809e372b0774ce40d8e
parent422c7c52632ebb6fbc5d5ff638b6ef0e1bc56f6b (diff)
Fix issue of receiving rx packets from previous test iteration
-rw-r--r--src/flow_stat.cpp10
-rw-r--r--src/stateless/rx/trex_stateless_rx_core.cpp25
-rw-r--r--src/stateless/rx/trex_stateless_rx_core.h1
3 files changed, 34 insertions, 2 deletions
diff --git a/src/flow_stat.cpp b/src/flow_stat.cpp
index 49654970..20cab376 100644
--- a/src/flow_stat.cpp
+++ b/src/flow_stat.cpp
@@ -642,6 +642,12 @@ int CFlowStatRuleMgr::start_stream(TrexStream * stream) {
m_user_id_map.start_stream(user_id, hw_id);
m_hw_id_map.map(hw_id, user_id);
add_hw_rule(hw_id, m_user_id_map.l4_proto(user_id));
+ // clear hardware counters. Just in case we have garbage from previous iteration
+ rx_per_flow_t rx_counter;
+ tx_per_flow_t tx_counter;
+ for (uint8_t port = 0; port < m_num_ports; port++) {
+ m_api->get_flow_stats(port, &rx_counter, (void *)&tx_counter, hw_id, hw_id, true);
+ }
}
}
@@ -683,8 +689,8 @@ int CFlowStatRuleMgr::stop_stream(TrexStream * stream) {
throw TrexException("Called stop_stream, but no stream was added");
if (stream->m_rx_check.m_hw_id >= MAX_FLOW_STATS) {
- printf("Trying to stop stream with high hw_id %d\n", stream->m_rx_check.m_hw_id);
- throw TrexException("Trying to stop stream which is not started (maybe stop was called twice?)");
+ // We allow stopping while already stopped. Will not hurt us.
+ return 0;
}
stream->m_rx_check.m_hw_id = HW_ID_FREE;
diff --git a/src/stateless/rx/trex_stateless_rx_core.cpp b/src/stateless/rx/trex_stateless_rx_core.cpp
index 929ad7fa..42889f0a 100644
--- a/src/stateless/rx/trex_stateless_rx_core.cpp
+++ b/src/stateless/rx/trex_stateless_rx_core.cpp
@@ -55,6 +55,7 @@ void CRxCoreStateless::idle_state_loop() {
int counter = 0;
while (m_state == STATE_IDLE) {
+ flush_rx();
bool had_msg = periodic_check_for_cp_messages();
if (had_msg) {
counter = 0;
@@ -162,6 +163,30 @@ void CRxCoreStateless::try_rx_queues() {
}
}
+// exactly the same as try_rx, without the handle_rx_pkt
+// purpose is to flush rx queues when core is in idle state
+void CRxCoreStateless::flush_rx() {
+ rte_mbuf_t * rx_pkts[64];
+ int i, total_pkts = 0;
+ for (i = 0; i < m_max_ports; i++) {
+ CLatencyManagerPerPort * lp = &m_ports[i];
+ rte_mbuf_t * m;
+ m_cpu_dp_u.start_work();
+ /* try to read 64 packets clean up the queue */
+ uint16_t cnt_p = lp->m_io->rx_burst(rx_pkts, 64);
+ total_pkts += cnt_p;
+ if (cnt_p) {
+ int j;
+ for (j = 0; j < cnt_p; j++) {
+ m = rx_pkts[j];
+ rte_pktmbuf_free(m);
+ }
+ /* commit only if there was work to do ! */
+ m_cpu_dp_u.commit();
+ }/* if work */
+ }// all ports
+}
+
int CRxCoreStateless::try_rx() {
rte_mbuf_t * rx_pkts[64];
int i, total_pkts = 0;
diff --git a/src/stateless/rx/trex_stateless_rx_core.h b/src/stateless/rx/trex_stateless_rx_core.h
index 5ab12f4e..81eca38a 100644
--- a/src/stateless/rx/trex_stateless_rx_core.h
+++ b/src/stateless/rx/trex_stateless_rx_core.h
@@ -62,6 +62,7 @@ class CRxCoreStateless {
void idle_state_loop();
void handle_rx_pkt(CLatencyManagerPerPort * lp, rte_mbuf_t * m);
void handle_rx_queue_msgs(uint8_t thread_id, CNodeRing * r);
+ void flush_rx();
int try_rx();
void try_rx_queues();
bool is_flow_stat_id(uint16_t id);