summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIdo Barnea <ibarnea@cisco.com>2016-04-07 17:23:33 +0300
committerIdo Barnea <ibarnea@cisco.com>2016-04-07 17:23:33 +0300
commit9e59c6af96e177a2ea022da80de6c408286321eb (patch)
tree162f40296bba3ecf945857b09af18dfdc884d435
parent106f14c2026638d9277e2dfc8649e5caa3164da1 (diff)
Do not send RX bytes in json if HW type does not support it
-rw-r--r--src/flow_stat.cpp3
-rw-r--r--src/internal_api/trex_platform_api.h1
-rw-r--r--src/main_dpdk.cpp6
3 files changed, 6 insertions, 4 deletions
diff --git a/src/flow_stat.cpp b/src/flow_stat.cpp
index 13f8eb16..10b0c3ea 100644
--- a/src/flow_stat.cpp
+++ b/src/flow_stat.cpp
@@ -845,7 +845,8 @@ bool CFlowStatRuleMgr::dump_json(std::string & json, bool baseline) {
if (user_id_info->need_to_send_rx(port) || baseline) {
user_id_info->set_no_need_to_send_rx(port);
data_section[str_user_id]["rx_pkts"][str_port] = Json::Value::UInt64(user_id_info->get_rx_counter(port).get_pkts());
- data_section[str_user_id]["rx_bytes"][str_port] = Json::Value::UInt64(user_id_info->get_rx_counter(port).get_bytes());
+ if (m_capabilities & TrexPlatformApi::IF_STAT_RX_BYTES_COUNT)
+ data_section[str_user_id]["rx_bytes"][str_port] = Json::Value::UInt64(user_id_info->get_rx_counter(port).get_bytes());
send_empty = false;
}
if (user_id_info->need_to_send_tx(port) || baseline) {
diff --git a/src/internal_api/trex_platform_api.h b/src/internal_api/trex_platform_api.h
index 90eaa7c7..b8f40df2 100644
--- a/src/internal_api/trex_platform_api.h
+++ b/src/internal_api/trex_platform_api.h
@@ -107,6 +107,7 @@ public:
IF_STAT_IPV4_ID = 1,
IF_STAT_PAYLOAD = 2,
IF_STAT_IPV6_FLOW_LABEL = 4,
+ IF_STAT_RX_BYTES_COUNT = 8, // Card support counting rx bytes
};
enum driver_speed_e {
diff --git a/src/main_dpdk.cpp b/src/main_dpdk.cpp
index a70f4d31..eb6dd1b2 100644
--- a/src/main_dpdk.cpp
+++ b/src/main_dpdk.cpp
@@ -191,7 +191,7 @@ public:
virtual void clear_extended_stats(CPhyEthIF * _if);
virtual int dump_fdir_global_stats(CPhyEthIF * _if, FILE *fd) {return 0;}
virtual int get_stat_counters_num() {return MAX_FLOW_STATS;}
- virtual int get_rx_stat_capabilities() {return TrexPlatformApi::IF_STAT_IPV4_ID;}
+ virtual int get_rx_stat_capabilities() {return TrexPlatformApi::IF_STAT_IPV4_ID | TrexPlatformApi::IF_STAT_RX_BYTES_COUNT;}
virtual int wait_for_stable_link();
virtual void wait_after_link_up();
};
@@ -244,7 +244,7 @@ public:
virtual int wait_for_stable_link();
virtual int get_stat_counters_num() {return MAX_FLOW_STATS;}
- virtual int get_rx_stat_capabilities() {return TrexPlatformApi::IF_STAT_IPV4_ID;}
+ virtual int get_rx_stat_capabilities() {return TrexPlatformApi::IF_STAT_IPV4_ID | TrexPlatformApi::IF_STAT_RX_BYTES_COUNT;}
};
@@ -281,7 +281,7 @@ public:
virtual void clear_extended_stats(CPhyEthIF * _if);
virtual int wait_for_stable_link();
virtual int get_stat_counters_num() {return MAX_FLOW_STATS;}
- virtual int get_rx_stat_capabilities() {return TrexPlatformApi::IF_STAT_IPV4_ID;}
+ virtual int get_rx_stat_capabilities() {return TrexPlatformApi::IF_STAT_IPV4_ID | TrexPlatformApi::IF_STAT_RX_BYTES_COUNT;}
virtual CFlowStatParser *get_flow_stat_parser();
};