summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorHanoh Haim <hhaim@cisco.com>2015-11-23 14:10:19 +0200
committerHanoh Haim <hhaim@cisco.com>2015-11-23 14:10:19 +0200
commit54c1f0fc29b3d4580f7a13cffbe625fe88e37b16 (patch)
tree2651b973d3b24cbf0138dc08509986d470bd0e38 /src
parentbd8b640077591377375f2ab5ec6c542119ead0a2 (diff)
add pause/resume into the console
Diffstat (limited to 'src')
-rw-r--r--src/stateless/cp/trex_stateless_port.cpp25
-rw-r--r--src/stateless/cp/trex_stateless_port.h5
-rw-r--r--src/stateless/cp/trex_streams_compiler.cpp7
-rw-r--r--src/stateless/cp/trex_streams_compiler.h5
-rw-r--r--src/stateless/dp/trex_stateless_dp_core.cpp1
5 files changed, 32 insertions, 11 deletions
diff --git a/src/stateless/cp/trex_stateless_port.cpp b/src/stateless/cp/trex_stateless_port.cpp
index fbc5f7c7..40392e68 100644
--- a/src/stateless/cp/trex_stateless_port.cpp
+++ b/src/stateless/cp/trex_stateless_port.cpp
@@ -127,6 +127,9 @@ TrexStatelessPort::start_traffic(double mul, double duration) {
TrexStatelessCpToDpMsgBase *start_msg = new TrexStatelessDpStart(m_port_id, event_id, compiled_obj, duration);
+ m_last_all_streams_continues = compiled_obj->get_all_streams_continues();
+ m_last_duration =duration;
+
change_state(PORT_STATE_TX);
send_message_to_dp(start_msg);
@@ -143,7 +146,8 @@ TrexStatelessPort::start_traffic(double mul, double duration) {
void
TrexStatelessPort::stop_traffic(void) {
- if (m_port_state != PORT_STATE_TX) {
+ if (!( (m_port_state == PORT_STATE_TX)
+ || (m_port_state ==PORT_STATE_PAUSE) )) {
return;
}
@@ -164,14 +168,18 @@ TrexStatelessPort::pause_traffic(void) {
verify_state(PORT_STATE_TX);
- #if 0
- /* generate a message to all the relevant DP cores to start transmitting */
- TrexStatelessCpToDpMsgBase *stop_msg = new TrexStatelessDpStop(m_port_id);
+ if (m_last_all_streams_continues == false) {
+ throw TrexRpcException(" pause is supported when all streams are in continues mode ");
+ }
+
+ if ( m_last_duration>0.0 ) {
+ throw TrexRpcException(" pause is supported when duration is not enable is start command ");
+ }
+
+ TrexStatelessCpToDpMsgBase *stop_msg = new TrexStatelessDpPause(m_port_id);
send_message_to_dp(stop_msg);
- m_port_state = PORT_STATE_UP_IDLE;
- #endif
change_state(PORT_STATE_PAUSE);
}
@@ -180,14 +188,11 @@ TrexStatelessPort::resume_traffic(void) {
verify_state(PORT_STATE_PAUSE);
- #if 0
/* generate a message to all the relevant DP cores to start transmitting */
- TrexStatelessCpToDpMsgBase *stop_msg = new TrexStatelessDpStop(m_port_id);
+ TrexStatelessCpToDpMsgBase *stop_msg = new TrexStatelessDpResume(m_port_id);
send_message_to_dp(stop_msg);
- m_port_state = PORT_STATE_UP_IDLE;
- #endif
change_state(PORT_STATE_TX);
}
diff --git a/src/stateless/cp/trex_stateless_port.h b/src/stateless/cp/trex_stateless_port.h
index 73157c15..006ec97c 100644
--- a/src/stateless/cp/trex_stateless_port.h
+++ b/src/stateless/cp/trex_stateless_port.h
@@ -207,6 +207,8 @@ public:
return m_dp_events;
}
+
+
private:
@@ -260,6 +262,9 @@ private:
/* holds the DP cores associated with this port */
std::vector<int> m_cores_id_list;
+ bool m_last_all_streams_continues;
+ double m_last_duration;
+
TrexDpPortEvents m_dp_events;
};
diff --git a/src/stateless/cp/trex_streams_compiler.cpp b/src/stateless/cp/trex_streams_compiler.cpp
index bdfc3c01..302863ae 100644
--- a/src/stateless/cp/trex_streams_compiler.cpp
+++ b/src/stateless/cp/trex_streams_compiler.cpp
@@ -136,6 +136,7 @@ private:
* stream compiled object
*************************************/
TrexStreamsCompiledObj::TrexStreamsCompiledObj(uint8_t port_id, double mul) : m_port_id(port_id), m_mul(mul) {
+ m_all_continues=false;
}
TrexStreamsCompiledObj::~TrexStreamsCompiledObj() {
@@ -401,6 +402,7 @@ TrexStreamsCompiler::compile(const std::vector<TrexStream *> &streams,
}
+ bool all_continues=true;
/* for now we do something trivial, */
for (auto stream : streams) {
@@ -408,6 +410,9 @@ TrexStreamsCompiler::compile(const std::vector<TrexStream *> &streams,
if (!stream->m_enabled) {
continue;
}
+ if (stream->get_type() != TrexStream::stCONTINUOUS ) {
+ all_continues=false;
+ }
int new_id= nodes.get(stream->m_stream_id)->m_compressed_stream_id;
assert(new_id>=0);
@@ -423,7 +428,7 @@ TrexStreamsCompiler::compile(const std::vector<TrexStream *> &streams,
my_next_stream_id
);
}
-
+ obj.m_all_continues =all_continues;
return true;
}
diff --git a/src/stateless/cp/trex_streams_compiler.h b/src/stateless/cp/trex_streams_compiler.h
index 200f7ce9..17ca3c74 100644
--- a/src/stateless/cp/trex_streams_compiler.h
+++ b/src/stateless/cp/trex_streams_compiler.h
@@ -64,6 +64,10 @@ public:
return (m_mul);
}
+ bool get_all_streams_continues(){
+ return (m_all_continues);
+ }
+
void Dump(FILE *fd);
private:
@@ -73,6 +77,7 @@ private:
std::vector<obj_st> m_objs;
+ bool m_all_continues;
uint8_t m_port_id;
double m_mul;
};
diff --git a/src/stateless/dp/trex_stateless_dp_core.cpp b/src/stateless/dp/trex_stateless_dp_core.cpp
index 03b13d6c..9b4a6ad9 100644
--- a/src/stateless/dp/trex_stateless_dp_core.cpp
+++ b/src/stateless/dp/trex_stateless_dp_core.cpp
@@ -160,6 +160,7 @@ bool TrexStatelessDpPerPort::stop_traffic(uint8_t port_id,
bool stop_on_id,
int event_id){
+
if (m_state == TrexStatelessDpPerPort::ppSTATE_IDLE) {
assert(m_active_streams==0);
return false;