diff options
author | imarom <imarom@cisco.com> | 2015-09-24 17:51:04 +0300 |
---|---|---|
committer | imarom <imarom@cisco.com> | 2015-09-24 17:51:04 +0300 |
commit | 1f90e4ed08414c8aa423693c4ee8fa84e7675230 (patch) | |
tree | c73335567839000807f8db5bf56c1163c068d457 /src | |
parent | 59e080559abe0895bf2f19b156c7245aa98f31cc (diff) |
some improvements to the console
Diffstat (limited to 'src')
-rw-r--r-- | src/rpc-server/commands/trex_rpc_cmd_general.cpp | 18 | ||||
-rw-r--r-- | src/stateless/trex_stateless.cpp | 10 | ||||
-rw-r--r-- | src/stateless/trex_stateless_api.h | 30 |
3 files changed, 39 insertions, 19 deletions
diff --git a/src/rpc-server/commands/trex_rpc_cmd_general.cpp b/src/rpc-server/commands/trex_rpc_cmd_general.cpp index 0c9f2c49..940baf3d 100644 --- a/src/rpc-server/commands/trex_rpc_cmd_general.cpp +++ b/src/rpc-server/commands/trex_rpc_cmd_general.cpp @@ -271,17 +271,17 @@ TrexRpcCmdGetPortStats::_run(const Json::Value ¶ms, Json::Value &result) { result["result"]["status"] = port->get_state_as_string(); - result["result"]["tx_bps"] = Json::Value::UInt64(port->get_port_stats().tx_bps); - result["result"]["tx_pps"] = Json::Value::UInt64(port->get_port_stats().tx_pps); - result["result"]["total_tx_pkts"] = Json::Value::UInt64(port->get_port_stats().total_tx_pkts); - result["result"]["total_tx_bytes"] = Json::Value::UInt64(port->get_port_stats().total_tx_bytes); + result["result"]["tx_bps"] = Json::Value::UInt64(port->get_port_stats().m_stats.tx_bps); + result["result"]["tx_pps"] = Json::Value::UInt64(port->get_port_stats().m_stats.tx_pps); + result["result"]["total_tx_pkts"] = Json::Value::UInt64(port->get_port_stats().m_stats.total_tx_pkts); + result["result"]["total_tx_bytes"] = Json::Value::UInt64(port->get_port_stats().m_stats.total_tx_bytes); - result["result"]["rx_bps"] = Json::Value::UInt64(port->get_port_stats().rx_bps); - result["result"]["rx_pps"] = Json::Value::UInt64(port->get_port_stats().rx_pps); - result["result"]["total_rx_pkts"] = Json::Value::UInt64(port->get_port_stats().total_rx_pkts); - result["result"]["total_rx_bytes"] = Json::Value::UInt64(port->get_port_stats().total_rx_bytes); + result["result"]["rx_bps"] = Json::Value::UInt64(port->get_port_stats().m_stats.rx_bps); + result["result"]["rx_pps"] = Json::Value::UInt64(port->get_port_stats().m_stats.rx_pps); + result["result"]["total_rx_pkts"] = Json::Value::UInt64(port->get_port_stats().m_stats.total_rx_pkts); + result["result"]["total_rx_bytes"] = Json::Value::UInt64(port->get_port_stats().m_stats.total_rx_bytes); - result["result"]["tx_rx_error"] = Json::Value::UInt64(port->get_port_stats().tx_rx_errors); + result["result"]["tx_rx_error"] = Json::Value::UInt64(port->get_port_stats().m_stats.tx_rx_errors); return (TREX_RPC_CMD_OK); } diff --git a/src/stateless/trex_stateless.cpp b/src/stateless/trex_stateless.cpp index 0eb96f05..3ec419ea 100644 --- a/src/stateless/trex_stateless.cpp +++ b/src/stateless/trex_stateless.cpp @@ -73,6 +73,15 @@ uint8_t TrexStateless::get_port_count() { return m_port_count; } + +/*************************** + * trex stateless port stats + * + **************************/ +TrexPortStats::TrexPortStats() { + m_stats = {0}; +} + /*************************** * trex stateless port * @@ -80,7 +89,6 @@ uint8_t TrexStateless::get_port_count() { TrexStatelessPort::TrexStatelessPort(uint8_t port_id) : m_port_id(port_id) { m_port_state = PORT_STATE_UP_IDLE; clear_owner(); - m_stats = {0}; } diff --git a/src/stateless/trex_stateless_api.h b/src/stateless/trex_stateless_api.h index 7a9080aa..ca093e03 100644 --- a/src/stateless/trex_stateless_api.h +++ b/src/stateless/trex_stateless_api.h @@ -42,14 +42,17 @@ public: }; /** - * describes a stateless port + * TRex stateless port stats * - * @author imarom (31-Aug-15) + * @author imarom (24-Sep-15) */ -class TrexStatelessPort { +class TrexPortStats { + public: + TrexPortStats(); - struct TrexPortStats { +public: + struct { uint64_t tx_pps; uint64_t tx_bps; uint64_t total_tx_pkts; @@ -61,7 +64,16 @@ public: uint64_t total_rx_bytes; uint64_t tx_rx_errors; - }; + } m_stats; +}; + +/** + * describes a stateless port + * + * @author imarom (31-Aug-15) + */ +class TrexStatelessPort { +public: /** * port state @@ -171,10 +183,10 @@ public: const TrexPortStats & get_port_stats(void) { /* scrabble */ - m_stats.tx_bps += 1 + rand() % 100; - m_stats.tx_pps += 1 + rand() % 10; - m_stats.total_tx_bytes += 1 + rand() % 10; - m_stats.total_tx_pkts += 1 + rand() % 5; + m_stats.m_stats.tx_bps += 1 + rand() % 100; + m_stats.m_stats.tx_pps += 1 + rand() % 10; + m_stats.m_stats.total_tx_bytes += 1 + rand() % 10; + m_stats.m_stats.total_tx_pkts += 1 + rand() % 5; return m_stats; } |