From cc8c0e225bc495f67a379a757cc01a3fe778620d Mon Sep 17 00:00:00 2001 From: Ido Barnea Date: Tue, 8 Mar 2016 18:22:50 +0200 Subject: Additions and fixes to per flow stats --- src/main_dpdk.cpp | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) (limited to 'src/main_dpdk.cpp') diff --git a/src/main_dpdk.cpp b/src/main_dpdk.cpp index 0d40215a..12670969 100644 --- a/src/main_dpdk.cpp +++ b/src/main_dpdk.cpp @@ -2640,7 +2640,7 @@ public: bool sanity_check(); void update_stats(void); tx_per_flow_t get_flow_tx_stats(uint8_t port, uint16_t hw_id); - void clear_flow_tx_stats(uint8_t port, uint16_t index); + tx_per_flow_t clear_flow_tx_stats(uint8_t port, uint16_t index); void get_stats(CGlobalStats & stats); void dump_post_test_stats(FILE *fd); void dump_config(FILE *fd); @@ -3307,8 +3307,32 @@ tx_per_flow_t CGlobalTRex::get_flow_tx_stats(uint8_t port, uint16_t index) { return m_stats.m_port[port].m_tx_per_flow[index] - m_stats.m_port[port].m_prev_tx_per_flow[index]; } -void CGlobalTRex::clear_flow_tx_stats(uint8_t port, uint16_t index) { +// read stats. Return read value, and clear. +tx_per_flow_t CGlobalTRex::clear_flow_tx_stats(uint8_t port, uint16_t index) { + uint8_t port0; + CFlowGenListPerThread * lpt; + tx_per_flow_t ret; + + m_stats.m_port[port].m_tx_per_flow[index].clear(); + + for (int i=0; i < get_cores_tx(); i++) { + lpt = m_fl.m_threads_info[i]; + port0 = lpt->getDualPortId() * 2; + if (port == port0) { + m_stats.m_port[port0].m_tx_per_flow[index] += + lpt->m_node_gen.m_v_if->m_stats[0].m_tx_per_flow[index]; + } else if (port == port0 + 1) { + m_stats.m_port[port0 + 1].m_tx_per_flow[index] += + lpt->m_node_gen.m_v_if->m_stats[1].m_tx_per_flow[index]; + } + } + + ret = m_stats.m_port[port].m_tx_per_flow[index] - m_stats.m_port[port].m_prev_tx_per_flow[index]; + + // Since we return diff from prev, following "clears" the stats. m_stats.m_port[port].m_prev_tx_per_flow[index] = m_stats.m_port[port].m_tx_per_flow[index]; + + return ret; } void CGlobalTRex::get_stats(CGlobalStats & stats){ @@ -3568,7 +3592,7 @@ CGlobalTRex::publish_async_data(bool sync_now) { m_zmq_publisher.publish_json(json); if (get_is_stateless()) { - if (m_trex_stateless->m_rx_flow_stat.dump_json(json)) + if (m_trex_stateless->m_rx_flow_stat.dump_json(json, sync_now)) m_zmq_publisher.publish_json(json); } } @@ -3930,10 +3954,9 @@ int CPhyEthIF::get_flow_stats(uint64_t *rx_stats, tx_per_flow_t *tx_stats, int m rx_stats[i - min] = m_stats.m_rx_per_flow[i] + diff_stats[i]; } if (tx_stats != NULL) { - tx_stats[i - min] = g_trex.get_flow_tx_stats(m_port_id, i); + tx_stats[i - min] = g_trex.clear_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) { @@ -4911,6 +4934,10 @@ int CTRexExtendedDriverBase40G::configure_rx_filter_rules(CPhyEthIF * _if) { // instead of adding this to rte_ethdev.h extern "C" int rte_eth_fdir_stats_get(uint8_t port_id, uint32_t *stats, uint32_t start, uint32_t len); +// get rx stats on _if, between min and max +// prev_stats should be the previous values read from the hardware. +// Getting changed to be equal to current HW values. +// stats return the diff between prev_stats and current hw values int CTRexExtendedDriverBase40G::get_rx_stats(CPhyEthIF * _if, uint32_t *stats, uint32_t *prev_stats, int min, int max) { uint32_t hw_stats[MAX_FLOW_STATS]; uint32_t port_id = _if->get_port_id(); -- cgit From 5f85bbd057dcf3298c8f1bab7b968952d6ec7693 Mon Sep 17 00:00:00 2001 From: Ido Barnea Date: Wed, 9 Mar 2016 11:25:05 +0200 Subject: Flow stat fix for issue of counting more than 1 stream --- src/main_dpdk.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/main_dpdk.cpp') diff --git a/src/main_dpdk.cpp b/src/main_dpdk.cpp index 12670969..3f53f83c 100644 --- a/src/main_dpdk.cpp +++ b/src/main_dpdk.cpp @@ -4947,13 +4947,13 @@ int CTRexExtendedDriverBase40G::get_rx_stats(CPhyEthIF * _if, uint32_t *stats, u rte_eth_fdir_stats_get(port_id, hw_stats, start, len); for (int i = loop_start; i < loop_start + len; i++) { - if (hw_stats[i] >= prev_stats[i]) { - stats[i] = (uint64_t)(hw_stats[i] - prev_stats[i]); + if (hw_stats[i - min] >= prev_stats[i]) { + stats[i] = (uint64_t)(hw_stats[i - min] - prev_stats[i]); } else { // Wrap around - stats[i] = (uint64_t)((hw_stats[i] + ((uint64_t)1 << 32)) - prev_stats[i]); + stats[i] = (uint64_t)((hw_stats[i - min] + ((uint64_t)1 << 32)) - prev_stats[i]); } - prev_stats[i] = hw_stats[i]; + prev_stats[i] = hw_stats[i - min]; } return 0; -- cgit From 8b0bb76f7987e33ff1b13b5bdf360a9e15f96c68 Mon Sep 17 00:00:00 2001 From: imarom Date: Wed, 9 Mar 2016 18:04:31 +0200 Subject: RX STATS ! --- src/main_dpdk.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src/main_dpdk.cpp') diff --git a/src/main_dpdk.cpp b/src/main_dpdk.cpp index 3f53f83c..2d087c8c 100644 --- a/src/main_dpdk.cpp +++ b/src/main_dpdk.cpp @@ -2307,7 +2307,7 @@ public: public: void Dump(FILE *fd,DumpFormat mode); void DumpAllPorts(FILE *fd); - void dump_json(std::string & json); + void dump_json(std::string & json, bool force_sync); private: std::string get_field(std::string name,float &f); std::string get_field(std::string name,uint64_t &f); @@ -2341,8 +2341,15 @@ std::string CGlobalStats::get_field_port(int port,std::string name,uint64_t &f){ } -void CGlobalStats::dump_json(std::string & json){ - json="{\"name\":\"trex-global\",\"type\":0,\"data\":{"; +void CGlobalStats::dump_json(std::string & json, bool force_sync){ + /* refactor this to JSON */ + + json="{\"name\":\"trex-global\",\"type\":0,"; + if (force_sync) { + json += "\"sync\": true,"; + } + + json +="\"data\":{"; #define GET_FIELD(f) get_field(std::string(#f),f) #define GET_FIELD_PORT(p,f) get_field_port(p,std::string(#f),lp->f) @@ -3565,7 +3572,7 @@ CGlobalTRex::publish_async_data(bool sync_now) { get_stats(m_stats); } - m_stats.dump_json(json); + m_stats.dump_json(json, sync_now); m_zmq_publisher.publish_json(json); /* generator json , all cores are the same just sample the first one */ -- cgit From 3c2f0346b3743d27ef0a02e44726f11fdb73417d Mon Sep 17 00:00:00 2001 From: imarom Date: Thu, 10 Mar 2016 10:21:37 +0200 Subject: RX stats #2 --- src/main_dpdk.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/main_dpdk.cpp') diff --git a/src/main_dpdk.cpp b/src/main_dpdk.cpp index 2d087c8c..1b750bbd 100644 --- a/src/main_dpdk.cpp +++ b/src/main_dpdk.cpp @@ -2307,7 +2307,7 @@ public: public: void Dump(FILE *fd,DumpFormat mode); void DumpAllPorts(FILE *fd); - void dump_json(std::string & json, bool force_sync); + void dump_json(std::string & json, bool baseline); private: std::string get_field(std::string name,float &f); std::string get_field(std::string name,uint64_t &f); @@ -2341,12 +2341,12 @@ std::string CGlobalStats::get_field_port(int port,std::string name,uint64_t &f){ } -void CGlobalStats::dump_json(std::string & json, bool force_sync){ +void CGlobalStats::dump_json(std::string & json, bool baseline){ /* refactor this to JSON */ json="{\"name\":\"trex-global\",\"type\":0,"; - if (force_sync) { - json += "\"sync\": true,"; + if (baseline) { + json += "\"baseline\": true,"; } json +="\"data\":{"; @@ -2638,7 +2638,7 @@ private: public: - void publish_async_data(bool sync_now); + void publish_async_data(bool sync_now, bool baseline = false); void publish_async_barrier(uint32_t key); void dump_stats(FILE *fd, @@ -3563,7 +3563,7 @@ void CGlobalTRex::dump_stats(FILE *fd, CGlobalStats::DumpFormat format){ } void -CGlobalTRex::publish_async_data(bool sync_now) { +CGlobalTRex::publish_async_data(bool sync_now, bool baseline) { std::string json; /* refactor to update, dump, and etc. */ @@ -3572,7 +3572,7 @@ CGlobalTRex::publish_async_data(bool sync_now) { get_stats(m_stats); } - m_stats.dump_json(json, sync_now); + m_stats.dump_json(json, baseline); m_zmq_publisher.publish_json(json); /* generator json , all cores are the same just sample the first one */ @@ -3599,7 +3599,7 @@ CGlobalTRex::publish_async_data(bool sync_now) { m_zmq_publisher.publish_json(json); if (get_is_stateless()) { - if (m_trex_stateless->m_rx_flow_stat.dump_json(json, sync_now)) + if (m_trex_stateless->m_rx_flow_stat.dump_json(json, baseline)) m_zmq_publisher.publish_json(json); } } @@ -5224,8 +5224,8 @@ TrexDpdkPlatformApi::get_interface_info(uint8_t interface_id, intf_info_st &info } void -TrexDpdkPlatformApi::publish_async_data_now(uint32_t key) const { - g_trex.publish_async_data(true); +TrexDpdkPlatformApi::publish_async_data_now(uint32_t key, bool baseline) const { + g_trex.publish_async_data(true, baseline); g_trex.publish_async_barrier(key); } -- cgit