summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/rpc-server/commands/trex_rpc_cmd_stream.cpp10
-rw-r--r--src/stateless/dp/trex_stateless_dp_core.cpp19
-rw-r--r--src/stateless/dp/trex_stream_node.h3
3 files changed, 27 insertions, 5 deletions
diff --git a/src/rpc-server/commands/trex_rpc_cmd_stream.cpp b/src/rpc-server/commands/trex_rpc_cmd_stream.cpp
index 87e205b0..918ff99b 100644
--- a/src/rpc-server/commands/trex_rpc_cmd_stream.cpp
+++ b/src/rpc-server/commands/trex_rpc_cmd_stream.cpp
@@ -57,7 +57,15 @@ TrexRpcCmdAddStream::_run(const Json::Value &params, Json::Value &result) {
stream->m_enabled = parse_bool(section, "enabled", result);
stream->m_self_start = parse_bool(section, "self_start", result);
stream->m_flags = parse_int(section, "flags", result);
- stream->m_action_count = (uint16_t)parse_int(section, "action_count", result);
+ int cnt = parse_int(section, "action_count", result);
+ if (cnt<0 || cnt >= UINT16_MAX) {
+ std::stringstream ss;
+ ss << "bad action_count provided: should be between " << 0 << " and " << UINT16_MAX;
+ printf(" %s \n",ss.str().c_str());
+ delete stream;
+ generate_execute_err(result, ss.str());
+ }
+ stream->m_action_count = (uint16_t)cnt;
/* inter stream gap */
stream->m_isg_usec = parse_double(section, "isg", result);
diff --git a/src/stateless/dp/trex_stateless_dp_core.cpp b/src/stateless/dp/trex_stateless_dp_core.cpp
index a84269ab..39080453 100644
--- a/src/stateless/dp/trex_stateless_dp_core.cpp
+++ b/src/stateless/dp/trex_stateless_dp_core.cpp
@@ -348,9 +348,20 @@ bool TrexStatelessDpCore::set_stateless_next_node(CGenNodeStateless * cur_node,
assert(state != CGenNodeStateless::ss_FREE_RESUSE);
if (state == CGenNodeStateless::ss_INACTIVE ) {
- /* refill start info and scedule, no update in active streams */
- next_node->refresh();
- schedule = true;
+ if (cur_node->m_action_counter > 0) {
+ cur_node->m_action_counter--;
+ if (cur_node->m_action_counter==0) {
+ to_stop_port = lp_port->update_number_of_active_streams(1);
+ }else{
+ /* refill start info and scedule, no update in active streams */
+ next_node->refresh();
+ schedule = true;
+ }
+ }else{
+ /* refill start info and scedule, no update in active streams */
+ next_node->refresh();
+ schedule = true;
+ }
}else{
to_stop_port = lp_port->update_number_of_active_streams(1);
@@ -554,6 +565,8 @@ TrexStatelessDpCore::add_stream(TrexStatelessDpPerPort * lp_port,
node->m_cache_mbuf=0;
node->m_type = CGenNode::STATELESS_PKT;
+ node->m_action_counter = stream->m_action_count;
+
/* clone the stream from control plane memory to DP memory */
node->m_ref_stream_info = stream->clone();
/* no need for this memory anymore on the control plane memory */
diff --git a/src/stateless/dp/trex_stream_node.h b/src/stateless/dp/trex_stream_node.h
index db7f19e8..ab43defe 100644
--- a/src/stateless/dp/trex_stream_node.h
+++ b/src/stateless/dp/trex_stream_node.h
@@ -81,7 +81,8 @@ private:
void * m_cache_mbuf;
double m_next_time_offset; /* in sec */
- uint32_t m_pad11;
+ uint16_t m_action_counter;
+ uint16_t m_pad11;
uint32_t m_pad12;
stream_state_t m_state;