Added get_active_pgids
authorIdo Barnea <[email protected]>
Mon, 7 Mar 2016 13:58:03 +0000 (15:58 +0200)
committerIdo Barnea <[email protected]>
Mon, 7 Mar 2016 13:58:31 +0000 (15:58 +0200)
scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py
src/flow_stat.cpp
src/flow_stat.h
src/internal_api/trex_platform_api.h
src/main_dpdk.cpp
src/rpc-server/commands/trex_rpc_cmd_general.cpp
src/rpc-server/commands/trex_rpc_cmds.h
src/rpc-server/trex_rpc_cmds_table.cpp
src/trex_defs.h

index a4e0b51..a13e279 100644 (file)
@@ -1124,6 +1124,16 @@ class STLClient(object):
         if not rc:
             raise STLError(rc)
 
+    @__api_check(True)
+    def get_active_pgids(self):
+        self.logger.pre_cmd( "Getting active packet group ids")
+
+        rc = self._transmit("get_active_pgids")
+
+        self.logger.post_cmd(rc)
+
+        if not rc:
+            raise STLError(rc)
 
 
     """
index 700c584..4d23dc6 100644 (file)
@@ -599,6 +599,16 @@ int CFlowStatRuleMgr::stop_stream(const TrexStream * stream) {
     return 0;
 }
 
+int CFlowStatRuleMgr::get_active_pgids(flow_stat_active_t &result) {
+    flow_stat_user_id_map_it_t it;
+
+    for (it = m_user_id_map.begin(); it != m_user_id_map.end(); it++) {
+        result.insert(it->first);
+    }
+
+    return 0;
+}
+
 // return false if no counters changed since last run. true otherwise
 bool CFlowStatRuleMgr::dump_json(std::string & json) {
     uint64_t rx_stats[MAX_FLOW_STATS];
index eed3b79..6f7671f 100644 (file)
@@ -184,6 +184,7 @@ class CFlowStatRuleMgr {
     int del_stream(const TrexStream * stream);
     int start_stream(TrexStream * stream, uint16_t &ret_hw_id);
     int stop_stream(const TrexStream * stream);
+    int get_active_pgids(flow_stat_active_t &result);
     bool dump_json(std::string & json);
 
  private:
index f6d7278..71ec442 100644 (file)
@@ -26,6 +26,7 @@ limitations under the License.
 #include <vector>
 #include <string>
 #include <string.h>
+#include "trex_defs.h"
 
 /**
  * Global stats
@@ -149,7 +150,7 @@ public:
     virtual void set_promiscuous(uint8_t port_id, bool enabled) const = 0;
     virtual bool get_promiscuous(uint8_t port_id) const = 0;
     virtual void flush_dp_messages() const = 0;
-
+    virtual int get_active_pgids(flow_stat_active_t &result) const = 0;
     virtual ~TrexPlatformApi() {}
 };
 
@@ -178,6 +179,7 @@ public:
     void set_promiscuous(uint8_t port_id, bool enabled) const;
     bool get_promiscuous(uint8_t port_id) const;
     void flush_dp_messages() const;
+    int get_active_pgids(flow_stat_active_t &result) const;
 };
 
 
@@ -238,6 +240,7 @@ public:
 
     void flush_dp_messages() const {
     }
+    int get_active_pgids(flow_stat_active_t &result) {/*??? implement*/ return 0;};
 
 private:
     int m_dp_core_count;
index 92bfda0..5f47f4b 100644 (file)
@@ -5235,3 +5235,7 @@ bool TrexDpdkPlatformApi::get_promiscuous(uint8_t port_id) const {
 void TrexDpdkPlatformApi::flush_dp_messages() const {
     g_trex.check_for_dp_messages();
 }
+
+int TrexDpdkPlatformApi::get_active_pgids(flow_stat_active_t &result) const {
+    return g_trex.m_trex_stateless->m_rx_flow_stat.get_active_pgids(result);
+}
index 88ead3c..dcf74b5 100644 (file)
@@ -40,7 +40,7 @@ using namespace std;
 /**
  * ping command
  */
-trex_rpc_cmd_rc_e 
+trex_rpc_cmd_rc_e
 TrexRpcCmdPing::_run(const Json::Value &params, Json::Value &result) {
 
     result["result"] = Json::objectValue;
@@ -50,7 +50,7 @@ TrexRpcCmdPing::_run(const Json::Value &params, Json::Value &result) {
 /**
  * query command
  */
-trex_rpc_cmd_rc_e 
+trex_rpc_cmd_rc_e
 TrexRpcCmdGetCmds::_run(const Json::Value &params, Json::Value &result) {
     vector<string> cmds;
 
@@ -68,7 +68,7 @@ TrexRpcCmdGetCmds::_run(const Json::Value &params, Json::Value &result) {
 
 /**
  * get version
- * 
+ *
  */
 trex_rpc_cmd_rc_e
 TrexRpcCmdGetVersion::_run(const Json::Value &params, Json::Value &result) {
@@ -94,11 +94,30 @@ TrexRpcCmdGetVersion::_run(const Json::Value &params, Json::Value &result) {
     return (TREX_RPC_CMD_OK);
 }
 
+trex_rpc_cmd_rc_e
+TrexRpcCmdGetActivePGIds::_run(const Json::Value &params, Json::Value &result) {
+    flow_stat_active_t active_flow_stat;
+    flow_stat_active_it_t it;
+    int i = 0;
+
+    Json::Value &section = result["result"];
+    section["ids"] = Json::arrayValue;
+
+    if (get_stateless_obj()->get_platform_api()->get_active_pgids(active_flow_stat) < 0)
+        return TREX_RPC_CMD_INTERNAL_ERR;
+
+    for (it = active_flow_stat.begin(); it != active_flow_stat.end(); it++) {
+        section["ids"][i++] = *it;
+    }
+
+    return (TREX_RPC_CMD_OK);
+}
+
 /**
  * get the CPU model
- * 
+ *
  */
-std::string 
+std::string
 TrexRpcCmdGetSysInfo::get_cpu_model() {
 
     static const string cpu_prefix = "model name";
@@ -141,7 +160,7 @@ TrexRpcCmdGetSysInfo::get_hostname(string &hostname) {
 
 /**
  * get system info
- * 
+ *
  */
 trex_rpc_cmd_rc_e
 TrexRpcCmdGetSysInfo::_run(const Json::Value &params, Json::Value &result) {
@@ -161,7 +180,7 @@ TrexRpcCmdGetSysInfo::_run(const Json::Value &params, Json::Value &result) {
     section["core_type"] = get_cpu_model();
 
     /* ports */
-   
+
 
     section["port_count"] = main->get_port_count();
 
@@ -175,7 +194,7 @@ TrexRpcCmdGetSysInfo::_run(const Json::Value &params, Json::Value &result) {
         string dst_macaddr;
         string pci_addr;
         int numa;
-        
+
         TrexStatelessPort *port = main->get_port_by_id(i);
         port->get_properties(driver, speed);
         port->get_macaddr(hw_macaddr, src_macaddr, dst_macaddr);
@@ -194,7 +213,7 @@ TrexRpcCmdGetSysInfo::_run(const Json::Value &params, Json::Value &result) {
 
         section["ports"][i]["rx"]["caps"]      = port->get_rx_caps();
         section["ports"][i]["rx"]["counters"]  = port->get_rx_count_num();
-            
+
 
         switch (speed) {
         case TrexPlatformApi::SPEED_1G:
@@ -223,13 +242,13 @@ TrexRpcCmdGetSysInfo::_run(const Json::Value &params, Json::Value &result) {
 
 /**
  * set port commands
- * 
+ *
  * @author imarom (24-Feb-16)
- * 
- * @param params 
- * @param result 
- * 
- * @return trex_rpc_cmd_rc_e 
+ *
+ * @param params
+ * @param result
+ *
+ * @return trex_rpc_cmd_rc_e
  */
 trex_rpc_cmd_rc_e
 TrexRpcCmdSetPortAttr::_run(const Json::Value &params, Json::Value &result) {
@@ -246,9 +265,9 @@ TrexRpcCmdSetPortAttr::_run(const Json::Value &params, Json::Value &result) {
         if (name == "promiscuous") {
             bool enabled = parse_bool(attr[name], "enabled", result);
             port->set_promiscuous(enabled);
-        }   
+        }
     }
-    
+
     result["result"] = Json::objectValue;
     return (TREX_RPC_CMD_OK);
 }
@@ -256,13 +275,13 @@ TrexRpcCmdSetPortAttr::_run(const Json::Value &params, Json::Value &result) {
 
 /**
  * returns the current owner of the device
- * 
+ *
  * @author imarom (08-Sep-15)
- * 
- * @param params 
- * @param result 
- * 
- * @return trex_rpc_cmd_rc_e 
+ *
+ * @param params
+ * @param result
+ *
+ * @return trex_rpc_cmd_rc_e
  */
 trex_rpc_cmd_rc_e
 TrexRpcCmdGetOwner::_run(const Json::Value &params, Json::Value &result) {
@@ -278,7 +297,7 @@ TrexRpcCmdGetOwner::_run(const Json::Value &params, Json::Value &result) {
 
 /**
  * acquire device
- * 
+ *
  */
 trex_rpc_cmd_rc_e
 TrexRpcCmdAcquire::_run(const Json::Value &params, Json::Value &result) {
@@ -305,7 +324,7 @@ TrexRpcCmdAcquire::_run(const Json::Value &params, Json::Value &result) {
 
 /**
  * release device
- * 
+ *
  */
 trex_rpc_cmd_rc_e
 TrexRpcCmdRelease::_run(const Json::Value &params, Json::Value &result) {
@@ -327,7 +346,7 @@ TrexRpcCmdRelease::_run(const Json::Value &params, Json::Value &result) {
 
 /**
  * get port stats
- * 
+ *
  */
 trex_rpc_cmd_rc_e
 TrexRpcCmdGetPortStats::_run(const Json::Value &params, Json::Value &result) {
@@ -347,13 +366,13 @@ TrexRpcCmdGetPortStats::_run(const Json::Value &params, Json::Value &result) {
 
 /**
  * fetch the port status
- * 
+ *
  * @author imarom (09-Dec-15)
- * 
- * @param params 
- * @param result 
- * 
- * @return trex_rpc_cmd_rc_e 
+ *
+ * @param params
+ * @param result
+ *
+ * @return trex_rpc_cmd_rc_e
  */
 trex_rpc_cmd_rc_e
 TrexRpcCmdGetPortStatus::_run(const Json::Value &params, Json::Value &result) {
@@ -373,7 +392,7 @@ TrexRpcCmdGetPortStatus::_run(const Json::Value &params, Json::Value &result) {
 
 /**
  * publish async data now (fast flush)
- * 
+ *
  */
 trex_rpc_cmd_rc_e
 TrexRpcPublishNow::_run(const Json::Value &params, Json::Value &result) {
index ac63e39..386ccc2 100644 (file)
@@ -60,6 +60,7 @@ TREX_RPC_CMD_DEFINE(TrexRpcCmdPing,       "ping",                 0, false);
 TREX_RPC_CMD_DEFINE(TrexRpcPublishNow,    "publish_now",          1, false);
 TREX_RPC_CMD_DEFINE(TrexRpcCmdGetCmds,    "get_supported_cmds",   0, false);
 TREX_RPC_CMD_DEFINE(TrexRpcCmdGetVersion, "get_version",          0, false);
+TREX_RPC_CMD_DEFINE(TrexRpcCmdGetActivePGIds, "get_active_pgids",0, false);
 
 TREX_RPC_CMD_DEFINE_EXTENDED(TrexRpcCmdGetSysInfo, "get_system_info", 0, false,
 
index 7b8dfdf..e1bd3ee 100644 (file)
@@ -37,6 +37,7 @@ TrexRpcCommandsTable::TrexRpcCommandsTable() {
     register_command(new TrexRpcPublishNow());
     register_command(new TrexRpcCmdGetCmds());
     register_command(new TrexRpcCmdGetVersion());
+    register_command(new TrexRpcCmdGetActivePGIds());
     register_command(new TrexRpcCmdGetSysInfo());
     register_command(new TrexRpcCmdGetOwner());
     register_command(new TrexRpcCmdAcquire());
index ace3618..4ecee1d 100644 (file)
@@ -13,6 +13,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
 */
+#include <set>
+
 #ifndef __TREX_DEFS_H__
 #define __TREX_DEFS_H__
 
@@ -29,4 +31,7 @@ limitations under the License.
 #endif
 
 
+typedef std::set<uint32_t> flow_stat_active_t;
+typedef std::set<uint32_t>::iterator flow_stat_active_it_t;
+
 #endif