summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/flow_stat.cpp17
-rw-r--r--src/main_dpdk.cpp55
2 files changed, 33 insertions, 39 deletions
diff --git a/src/flow_stat.cpp b/src/flow_stat.cpp
index 4d23dc60..ef32284b 100644
--- a/src/flow_stat.cpp
+++ b/src/flow_stat.cpp
@@ -522,18 +522,20 @@ int CFlowStatRuleMgr::start_stream(TrexStream * stream, uint16_t &ret_hw_id) {
return 0;
}
+ uint16_t hw_id;
// from here, we know the stream need rx stat
if (m_user_id_map.is_started(stream->m_rx_check.m_pg_id)) {
m_user_id_map.start_stream(stream->m_rx_check.m_pg_id); // just increase ref count;
+ hw_id = m_user_id_map.get_hw_id(stream->m_rx_check.m_pg_id); // can't fail if we got here
} else {
- uint16_t hw_id = m_hw_id_map.find_free_hw_id();
- if (hw_id > m_max_hw_id) {
- m_max_hw_id = hw_id;
- }
+ hw_id = m_hw_id_map.find_free_hw_id();
if (hw_id == FREE_HW_ID) {
printf("Error: %s failed finding free hw_id\n", __func__);
return -1;
} else {
+ if (hw_id > m_max_hw_id) {
+ m_max_hw_id = hw_id;
+ }
uint32_t user_id = stream->m_rx_check.m_pg_id;
m_user_id_map.start_stream(user_id, hw_id);
m_hw_id_map.map(hw_id, user_id);
@@ -541,7 +543,6 @@ int CFlowStatRuleMgr::start_stream(TrexStream * stream, uint16_t &ret_hw_id) {
}
}
- uint16_t hw_id = m_user_id_map.get_hw_id(stream->m_rx_check.m_pg_id); // can't fail if we got here
parser.set_ip_id(IP_ID_RESERVE_BASE + hw_id);
ret_hw_id = hw_id;
@@ -615,7 +616,6 @@ bool CFlowStatRuleMgr::dump_json(std::string & json) {
tx_per_flow_t tx_stats[MAX_FLOW_STATS];
Json::FastWriter writer;
Json::Value root;
- bool ret = false;
if (m_user_id_map.is_empty()) {
return false;
@@ -661,16 +661,15 @@ bool CFlowStatRuleMgr::dump_json(std::string & json) {
if (user_id_info->get_rx_counter(port) != 0) {
data_section[str_user_id]["rx_pkts"][str_port] = Json::Value::UInt64(user_id_info->get_rx_counter(port));
- ret = true;
}
if (user_id_info->get_tx_counter(port).get_pkts() != 0) {
data_section[str_user_id]["tx_pkts"][str_port] = Json::Value::UInt64(user_id_info->get_tx_counter(port).get_pkts());
data_section[str_user_id]["tx_bytes"][str_port] = Json::Value::UInt64(user_id_info->get_tx_counter(port).get_bytes());
- ret = true;
}
}
}
json = writer.write(root);
- return ret;
+ // We always want to publish, even only the timestamp.
+ return true;
}
diff --git a/src/main_dpdk.cpp b/src/main_dpdk.cpp
index 5f47f4bb..0d40215a 100644
--- a/src/main_dpdk.cpp
+++ b/src/main_dpdk.cpp
@@ -18,7 +18,13 @@
See the License for the specific language governing permissions and
limitations under the License.
*/
+#include <assert.h>
+#include <pthread.h>
#include <pwd.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <zmq.h>
#include <rte_common.h>
#include <rte_log.h>
#include <rte_memory.h>
@@ -45,38 +51,27 @@
#include <rte_random.h>
#include <rte_version.h>
#include "bp_sim.h"
-#include "latency.h"
#include "os_time.h"
-#include <common/arg/SimpleGlob.h>
-#include <common/arg/SimpleOpt.h>
-#include <common/basic_utils.h>
-
-#include <stateless/cp/trex_stateless.h>
-#include <stateless/dp/trex_stream_node.h>
-#include <publisher/trex_publisher.h>
-#include <stateless/messaging/trex_stateless_messaging.h>
-
-#include <../linux_dpdk/version.h>
-
+#include "common/arg/SimpleGlob.h"
+#include "common/arg/SimpleOpt.h"
+#include "common/basic_utils.h"
+#include "stateless/cp/trex_stateless.h"
+#include "stateless/dp/trex_stream_node.h"
+#include "stateless/messaging/trex_stateless_messaging.h"
+#include "publisher/trex_publisher.h"
+#include "../linux_dpdk/version.h"
extern "C" {
-#include <dpdk22/drivers/net/ixgbe/base/ixgbe_type.h>
+#include "dpdk22/drivers/net/ixgbe/base/ixgbe_type.h"
}
-#include <dpdk22/drivers/net/e1000/base/e1000_regs.h>
-#include <zmq.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <string.h>
-#include <assert.h>
-#include <pthread.h>
+#include "dpdk22/drivers/net/e1000/base/e1000_regs.h"
#include "global_io_mode.h"
#include "utl_term_io.h"
#include "msg_manager.h"
#include "platform_cfg.h"
#include "latency.h"
-#include "main_dpdk.h"
#include "debug.h"
-
-#include <internal_api/trex_platform_api.h>
+#include "internal_api/trex_platform_api.h"
+#include "main_dpdk.h"
#define RX_CHECK_MIX_SAMPLE_RATE 8
#define RX_CHECK_MIX_SAMPLE_RATE_1G 2
@@ -3918,9 +3913,9 @@ int CPhyEthIF::reset_hw_flow_stats() {
// get/reset flow director counters
// return 0 if OK. -1 if operation not supported.
-// stats - If not NULL, returning counter numbers in it.
-// index - If non negative, get only counter with this index
-// reset - If true, reset counter value after reading
+// rx_stats, tx_stats - arrays of len max - min + 1. Returning rx, tx updated values.
+// min, max - minimum, maximum counters range to get
+// reset - If true, need to reset counter value after reading
int CPhyEthIF::get_flow_stats(uint64_t *rx_stats, tx_per_flow_t *tx_stats, int min, int max, bool reset) {
uint32_t diff_stats[MAX_FLOW_STATS];
@@ -3932,20 +3927,20 @@ int CPhyEthIF::get_flow_stats(uint64_t *rx_stats, tx_per_flow_t *tx_stats, int m
if ( reset ) {
// return value so far, and reset
if (rx_stats != NULL) {
- rx_stats[i] = m_stats.m_rx_per_flow[i] + diff_stats[i];
+ rx_stats[i - min] = m_stats.m_rx_per_flow[i] + diff_stats[i];
}
if (tx_stats != NULL) {
- tx_stats[i] = g_trex.get_flow_tx_stats(m_port_id, i);
+ tx_stats[i - min] = g_trex.get_flow_tx_stats(m_port_id, i);
}
m_stats.m_rx_per_flow[i] = 0;
g_trex.clear_flow_tx_stats(m_port_id, i);
} else {
m_stats.m_rx_per_flow[i] += diff_stats[i];
if (rx_stats != NULL) {
- rx_stats[i] = m_stats.m_rx_per_flow[i];
+ rx_stats[i - min] = m_stats.m_rx_per_flow[i];
}
if (tx_stats != NULL) {
- tx_stats[i] = g_trex.get_flow_tx_stats(m_port_id, i);
+ tx_stats[i - min] = g_trex.get_flow_tx_stats(m_port_id, i);
}
}
}