diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/rpc-server/commands/trex_rpc_cmd_stream.cpp | 25 | ||||
-rw-r--r-- | src/stateless/trex_stateless_api.h | 9 | ||||
-rw-r--r-- | src/stateless/trex_stream.cpp | 9 | ||||
-rw-r--r-- | src/stateless/trex_stream_api.h | 34 |
4 files changed, 42 insertions, 35 deletions
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; + }; /** |