draft
authorimarom <[email protected]>
Tue, 1 Sep 2015 14:16:27 +0000 (17:16 +0300)
committerimarom <[email protected]>
Tue, 1 Sep 2015 14:16:27 +0000 (17:16 +0300)
linux_dpdk/ws_main.py
src/rpc-server/commands/trex_rpc_cmd_stream.cpp
src/rpc-server/commands/trex_rpc_cmd_test.cpp
src/rpc-server/commands/trex_rpc_cmds.h
src/rpc-server/trex_rpc_cmds_table.cpp
src/stateless/trex_stream.cpp
src/stateless/trex_stream_api.h

index 60c9a11..e1aa8ea 100755 (executable)
@@ -345,8 +345,6 @@ bp =SrcGroups([
                 main_src, 
                 cmn_src ,
                 net_src ,
-                rpc_server_src,
-                json_src,
                 yaml_src,
                 version_src
                 ]);
index 57fa23d..cda917a 100644 (file)
@@ -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";
+}
+
index 382279b..3153317 100644 (file)
@@ -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);
index 7ec8aba..64551fa 100644 (file)
@@ -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,
 
index e586c3d..7d5d49a 100644 (file)
@@ -37,6 +37,7 @@ TrexRpcCommandsTable::TrexRpcCommandsTable() {
     /* stream commands */
     register_command(new TrexRpcCmdAddStream());
     register_command(new TrexRpcCmdRemoveStream());
+    register_command(new TrexRpcCmdRemoveAllStreams());
 }
 
 TrexRpcCommandsTable::~TrexRpcCommandsTable() {
index 5bc9421..1465b1b 100644 (file)
@@ -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);
 
index bae8286..f57b7aa 100644 (file)
@@ -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,10 +141,15 @@ 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