From 166e1b639a8cb3d95a6ebae325a4156c6df6c595 Mon Sep 17 00:00:00 2001 From: imarom Date: Tue, 1 Sep 2015 15:14:27 +0300 Subject: draft --- .../client_utils/jsonrpc_client.py | 2 +- .../trex_control_plane/console/trex_status.py | 2 +- src/rpc-server/commands/trex_rpc_cmd_stream.cpp | 25 +++++++++------- src/stateless/trex_stateless_api.h | 9 ++++-- src/stateless/trex_stream.cpp | 9 +++--- src/stateless/trex_stream_api.h | 34 ++++++++++++---------- 6 files changed, 44 insertions(+), 37 deletions(-) diff --git a/scripts/automation/trex_control_plane/client_utils/jsonrpc_client.py b/scripts/automation/trex_control_plane/client_utils/jsonrpc_client.py index 48ff231b..054dc1a2 100644 --- a/scripts/automation/trex_control_plane/client_utils/jsonrpc_client.py +++ b/scripts/automation/trex_control_plane/client_utils/jsonrpc_client.py @@ -12,7 +12,7 @@ class bcolors: GREEN = '\033[32m' YELLOW = '\033[93m' RED = '\033[31m' - MAGENTA = '\033[95m' + MAGENTA = '\033[35m' ENDC = '\033[0m' BOLD = '\033[1m' UNDERLINE = '\033[4m' diff --git a/scripts/automation/trex_control_plane/console/trex_status.py b/scripts/automation/trex_control_plane/console/trex_status.py index 8ee669b5..54853ea3 100644 --- a/scripts/automation/trex_control_plane/console/trex_status.py +++ b/scripts/automation/trex_control_plane/console/trex_status.py @@ -126,7 +126,7 @@ class TrexStatus(): self.max_x = self.stdscr.getmaxyx()[1] # create cls panel - self.main_panel = TrexStatusPanel(int(self.max_y * 0.8), self.max_x / 2, 0,0, "Trex Activity:") + self.main_panel = TrexStatusPanel(int(self.max_y * 0.8), self.max_x / 2, 0,0, "Trex Ports:") self.general_panel = TrexStatusPanel(int(self.max_y * 0.6), self.max_x / 2, 0, self.max_x /2, "General Statistics:") diff --git a/src/rpc-server/commands/trex_rpc_cmd_stream.cpp b/src/rpc-server/commands/trex_rpc_cmd_stream.cpp index 25dee501..57fa23d4 100644 --- a/src/rpc-server/commands/trex_rpc_cmd_stream.cpp +++ b/src/rpc-server/commands/trex_rpc_cmd_stream.cpp @@ -41,14 +41,17 @@ TrexRpcCmdAddStream::_run(const Json::Value ¶ms, Json::Value &result) { const Json::Value &mode = parse_object(section, "mode", result); string type = parse_string(mode, "type", result); + /* allocate a new stream based on the type */ TrexStream *stream = allocate_new_stream(section, result); - /* create a new steram and populate it */ - + /* some fields */ + stream->m_enabled = parse_bool(section, "enabled", result); + stream->m_self_start = parse_bool(section, "self_start", result); + + /* inter stream gap */ stream->m_isg_usec = parse_double(section, "Is", result); stream->m_next_stream_id = parse_int(section, "next_stream_id", result); - stream->m_loop_count = parse_int(section, "loop_count", result); const Json::Value &pkt = parse_array(section, "packet", result); @@ -95,19 +98,19 @@ TrexRpcCmdAddStream::allocate_new_stream(const Json::Value §ion, Json::Value } else if (type == "single_burst") { - uint32_t pps = parse_int(mode, "pps", result); - uint32_t packets = parse_int(type, "packets", result); + uint32_t total_pkts = parse_int(mode, "total_pkts", result); + uint32_t pps = parse_int(mode, "pps", result); - stream = new TrexStreamSingleBurst(port_id, stream_id, pps, packets); + stream = new TrexStreamBurst(port_id, stream_id, total_pkts, pps); } else if (type == "multi_burst") { - uint32_t pps = parse_int(mode, "pps", result); - double ibg_usec = parse_double(mode, "ibg", result); - uint32_t num_bursts = parse_int(mode, "number_of_bursts", result); - uint32_t pkt_per_burst = parse_int(mode, "pkt_per_burst", result); + uint32_t pps = parse_int(mode, "pps", result); + double ibg_usec = parse_double(mode, "ibg", result); + uint32_t num_bursts = parse_int(mode, "number_of_bursts", result); + uint32_t pkts_per_burst = parse_int(mode, "pkts_per_burst", result); - stream = new TrexStreamMultiBurst(port_id, stream_id, pps, ibg_usec, num_bursts, pkt_per_burst); + stream = new TrexStreamMultiBurst(port_id, stream_id, pkts_per_burst, pps, num_bursts, ibg_usec); } else { diff --git a/src/stateless/trex_stateless_api.h b/src/stateless/trex_stateless_api.h index 50cc3947..6406a946 100644 --- a/src/stateless/trex_stateless_api.h +++ b/src/stateless/trex_stateless_api.h @@ -29,7 +29,7 @@ limitations under the License. /** * generic exception for errors - * + * TODO: move this to a better place */ class TrexException : public std::runtime_error { @@ -42,7 +42,7 @@ public: }; /** - * + * describes a stateless port * * @author imarom (31-Aug-15) */ @@ -52,12 +52,15 @@ public: TrexStatelessPort(uint8_t port_id) : m_port_id(port_id) { } + /** + * access the stream table + * + */ TrexStreamTable *get_stream_table() { return &m_stream_table; } private: - /* a stream table per port */ TrexStreamTable m_stream_table; uint8_t m_port_id; }; diff --git a/src/stateless/trex_stream.cpp b/src/stateless/trex_stream.cpp index 1a78ab34..5bc9421f 100644 --- a/src/stateless/trex_stream.cpp +++ b/src/stateless/trex_stream.cpp @@ -27,11 +27,10 @@ limitations under the License. TrexStream::TrexStream(uint8_t port_id, uint32_t stream_id) : m_port_id(port_id), m_stream_id(stream_id) { /* default values */ - m_isg_usec = 0; - m_next_stream_id = -1; - m_loop_count = 0; - m_enable = false; - m_start = false; + m_isg_usec = 0; + m_next_stream_id = -1; + m_enabled = false; + m_self_start = false; m_pkt = NULL; m_pkt_len = 0; diff --git a/src/stateless/trex_stream_api.h b/src/stateless/trex_stream_api.h index 7ae25c6e..bae82862 100644 --- a/src/stateless/trex_stream_api.h +++ b/src/stateless/trex_stream_api.h @@ -39,6 +39,7 @@ public: TrexStream(uint8_t port_id, uint32_t stream_id); virtual ~TrexStream() = 0; + /* defines the min max per packet supported */ static const uint32_t MIN_PKT_SIZE_BYTES = 1; static const uint32_t MAX_PKT_SIZE_BYTES = 9000; @@ -51,11 +52,10 @@ private: /* config fields */ double m_isg_usec; uint32_t m_next_stream_id; - uint32_t m_loop_count; /* indicators */ - bool m_enable; - bool m_start; + bool m_enabled; + bool m_self_start; /* pkt */ uint8_t *m_pkt; @@ -90,35 +90,37 @@ protected: * single burst * */ -class TrexStreamSingleBurst : public TrexStream { +class TrexStreamBurst : public TrexStream { public: - TrexStreamSingleBurst(uint8_t port_id, uint32_t stream_id, uint32_t packets, uint32_t pps) : TrexStream(port_id, stream_id), m_pps(pps), m_packets(packets) { + TrexStreamBurst(uint8_t port_id, uint32_t stream_id, uint32_t total_pkts, uint32_t pps) : + TrexStream(port_id, stream_id), + m_total_pkts(total_pkts), + m_pps(pps) { } + protected: - uint32_t m_pps; - uint32_t m_packets; - + uint32_t m_total_pkts; + uint32_t m_pps; }; /** * multi burst * */ -class TrexStreamMultiBurst : public TrexStream { +class TrexStreamMultiBurst : public TrexStreamBurst { public: - TrexStreamMultiBurst(uint8_t port_id, + TrexStreamMultiBurst(uint8_t port_id, uint32_t stream_id, - uint32_t pps, - double ibg_usec, uint32_t pkts_per_burst, - uint32_t num_bursts) : TrexStream(port_id, stream_id), m_pps(pps), m_ibg_usec(ibg_usec), m_num_bursts(num_bursts), m_pkts_per_burst(pkts_per_burst) { + uint32_t pps, + uint32_t num_bursts, + double ibg_usec) : TrexStreamBurst(port_id, stream_id, pkts_per_burst, pps), m_num_bursts(num_bursts), m_ibg_usec(ibg_usec) { } protected: - uint32_t m_pps; - double m_ibg_usec; uint32_t m_num_bursts; - uint32_t m_pkts_per_burst; + double m_ibg_usec; + }; /** -- cgit 1.2.3-korg