summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xlinux_dpdk/ws_main.py2
-rw-r--r--src/rpc-server/commands/trex_rpc_cmd_stream.cpp45
-rw-r--r--src/rpc-server/commands/trex_rpc_cmd_test.cpp8
-rw-r--r--src/rpc-server/commands/trex_rpc_cmds.h3
-rw-r--r--src/rpc-server/trex_rpc_cmds_table.cpp1
-rw-r--r--src/stateless/trex_stream.cpp10
-rw-r--r--src/stateless/trex_stream_api.h9
7 files changed, 63 insertions, 15 deletions
diff --git a/linux_dpdk/ws_main.py b/linux_dpdk/ws_main.py
index 60c9a114..e1aa8eaf 100755
--- a/linux_dpdk/ws_main.py
+++ b/linux_dpdk/ws_main.py
@@ -345,8 +345,6 @@ bp =SrcGroups([
main_src,
cmn_src ,
net_src ,
- rpc_server_src,
- json_src,
yaml_src,
version_src
]);
diff --git a/src/rpc-server/commands/trex_rpc_cmd_stream.cpp b/src/rpc-server/commands/trex_rpc_cmd_stream.cpp
index 57fa23d4..cda917ac 100644
--- a/src/rpc-server/commands/trex_rpc_cmd_stream.cpp
+++ b/src/rpc-server/commands/trex_rpc_cmd_stream.cpp
@@ -28,10 +28,10 @@ limitations under the License.
using namespace std;
-/**
+/***************************
* add new stream
*
- */
+ **************************/
trex_rpc_cmd_rc_e
TrexRpcCmdAddStream::_run(const Json::Value &params, Json::Value &result) {
@@ -63,10 +63,23 @@ TrexRpcCmdAddStream::_run(const Json::Value &params, Json::Value &result) {
generate_internal_err(result, "unable to allocate memory");
}
+ /* parse the packet */
for (int i = 0; i < pkt.size(); i++) {
stream->m_pkt[i] = parse_byte(pkt, i, result);
}
+ /* parse RX info */
+ const Json::Value &rx = parse_object(section, "rx_stats", result);
+
+ stream->m_rx_check.m_enable = parse_bool(rx, "enabled", result);
+
+ /* if it is enabled - we need more fields */
+ if (stream->m_rx_check.m_enable) {
+ stream->m_rx_check.m_stream_id = parse_int(rx, "stream_id", result);
+ stream->m_rx_check.m_seq_enabled = parse_bool(rx, "seq_enabled", result);
+ stream->m_rx_check.m_latency = parse_bool(rx, "latency", result);
+ }
+
/* make sure this is a valid stream to add */
validate_stream(stream, result);
@@ -117,6 +130,7 @@ TrexRpcCmdAddStream::allocate_new_stream(const Json::Value &section, Json::Value
generate_parse_err(result, "bad stream type provided: '" + type + "'");
}
+ /* make sure we were able to allocate the memory */
if (!stream) {
generate_internal_err(result, "unable to allocate memory");
}
@@ -157,6 +171,10 @@ TrexRpcCmdAddStream::validate_stream(const TrexStream *stream, Json::Value &resu
}
+/***************************
+ * remove stream
+ *
+ **************************/
trex_rpc_cmd_rc_e
TrexRpcCmdRemoveStream::_run(const Json::Value &params, Json::Value &result) {
uint8_t port_id = parse_byte(params, "port_id", result);
@@ -170,7 +188,7 @@ TrexRpcCmdRemoveStream::_run(const Json::Value &params, Json::Value &result) {
}
TrexStatelessPort *port = get_trex_stateless()->get_port_by_id(port_id);
- TrexStream *stream = port->get_stream_table()->get_stream_by_id(stream_id);
+ TrexStream *stream = port->get_stream_table()->get_stream_by_id(stream_id);
if (!stream) {
std::stringstream ss;
@@ -183,3 +201,24 @@ TrexRpcCmdRemoveStream::_run(const Json::Value &params, Json::Value &result) {
result["result"] = "ACK";
}
+/***************************
+ * remove all streams
+ * for a port
+ *
+ **************************/
+trex_rpc_cmd_rc_e
+TrexRpcCmdRemoveAllStreams::_run(const Json::Value &params, Json::Value &result) {
+ uint8_t port_id = parse_byte(params, "port_id", result);
+
+ if (port_id >= get_trex_stateless()->get_port_count()) {
+ std::stringstream ss;
+ ss << "invalid port id - should be between 0 and " << (int)get_trex_stateless()->get_port_count() - 1;
+ generate_execute_err(result, ss.str());
+ }
+
+ TrexStatelessPort *port = get_trex_stateless()->get_port_by_id(port_id);
+ port->get_stream_table()->remove_and_delete_all_streams();
+
+ result["result"] = "ACK";
+}
+
diff --git a/src/rpc-server/commands/trex_rpc_cmd_test.cpp b/src/rpc-server/commands/trex_rpc_cmd_test.cpp
index 382279ba..3153317e 100644
--- a/src/rpc-server/commands/trex_rpc_cmd_test.cpp
+++ b/src/rpc-server/commands/trex_rpc_cmd_test.cpp
@@ -32,11 +32,8 @@ using namespace std;
trex_rpc_cmd_rc_e
TrexRpcCmdTestAdd::_run(const Json::Value &params, Json::Value &result) {
- const Json::Value &x = params["x"];
- const Json::Value &y = params["y"];
-
result["result"] = parse_int(params, "x", result) + parse_int(params, "y", result);
-
+
return (TREX_RPC_CMD_OK);
}
@@ -48,9 +45,6 @@ TrexRpcCmdTestAdd::_run(const Json::Value &params, Json::Value &result) {
trex_rpc_cmd_rc_e
TrexRpcCmdTestSub::_run(const Json::Value &params, Json::Value &result) {
- const Json::Value &x = params["x"];
- const Json::Value &y = params["y"];
-
result["result"] = parse_int(params, "x", result) - parse_int(params, "y", result);
return (TREX_RPC_CMD_OK);
diff --git a/src/rpc-server/commands/trex_rpc_cmds.h b/src/rpc-server/commands/trex_rpc_cmds.h
index 7ec8aba3..64551fac 100644
--- a/src/rpc-server/commands/trex_rpc_cmds.h
+++ b/src/rpc-server/commands/trex_rpc_cmds.h
@@ -62,7 +62,8 @@ TREX_RPC_CMD_DEFINE(TrexRpcCmdGetStatus, "get_status", 0);
/**
* stream cmds
*/
-TREX_RPC_CMD_DEFINE(TrexRpcCmdRemoveStream, "remove_stream", 2);
+TREX_RPC_CMD_DEFINE(TrexRpcCmdRemoveAllStreams, "remove_all_streams", 1);
+TREX_RPC_CMD_DEFINE(TrexRpcCmdRemoveStream, "remove_stream", 2);
TREX_RPC_CMD_DEFINE_EXTENED(TrexRpcCmdAddStream, "add_stream", 1,
diff --git a/src/rpc-server/trex_rpc_cmds_table.cpp b/src/rpc-server/trex_rpc_cmds_table.cpp
index e586c3d6..7d5d49ae 100644
--- a/src/rpc-server/trex_rpc_cmds_table.cpp
+++ b/src/rpc-server/trex_rpc_cmds_table.cpp
@@ -37,6 +37,7 @@ TrexRpcCommandsTable::TrexRpcCommandsTable() {
/* stream commands */
register_command(new TrexRpcCmdAddStream());
register_command(new TrexRpcCmdRemoveStream());
+ register_command(new TrexRpcCmdRemoveAllStreams());
}
TrexRpcCommandsTable::~TrexRpcCommandsTable() {
diff --git a/src/stateless/trex_stream.cpp b/src/stateless/trex_stream.cpp
index 5bc9421f..1465b1ba 100644
--- a/src/stateless/trex_stream.cpp
+++ b/src/stateless/trex_stream.cpp
@@ -72,6 +72,16 @@ void TrexStreamTable::remove_stream(TrexStream *stream) {
m_stream_table.erase(stream->m_stream_id);
}
+
+void TrexStreamTable::remove_and_delete_all_streams() {
+
+ for (auto stream : m_stream_table) {
+ delete stream.second;
+ }
+
+ m_stream_table.clear();
+}
+
TrexStream * TrexStreamTable::get_stream_by_id(uint32_t stream_id) {
auto search = m_stream_table.find(stream_id);
diff --git a/src/stateless/trex_stream_api.h b/src/stateless/trex_stream_api.h
index bae82862..f57b7aae 100644
--- a/src/stateless/trex_stream_api.h
+++ b/src/stateless/trex_stream_api.h
@@ -66,7 +66,7 @@ private:
/* RX check */
struct {
bool m_enable;
- bool m_seq_enable;
+ bool m_seq_enabled;
bool m_latency;
uint32_t m_stream_id;
@@ -141,11 +141,16 @@ public:
/**
* remove a stream
- *
*/
void remove_stream(TrexStream *stream);
/**
+ * remove all streams on the table
+ * memory will be deleted
+ */
+ void remove_and_delete_all_streams();
+
+ /**
* fetch a stream if exists
* o.w NULL
*