diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/flow_stat.cpp | 10 | ||||
-rw-r--r-- | src/flow_stat.h | 1 | ||||
-rw-r--r-- | src/internal_api/trex_platform_api.h | 5 | ||||
-rw-r--r-- | src/main_dpdk.cpp | 4 | ||||
-rw-r--r-- | src/rpc-server/commands/trex_rpc_cmd_general.cpp | 85 | ||||
-rw-r--r-- | src/rpc-server/commands/trex_rpc_cmds.h | 1 | ||||
-rw-r--r-- | src/rpc-server/trex_rpc_cmds_table.cpp | 1 | ||||
-rw-r--r-- | src/trex_defs.h | 5 |
8 files changed, 78 insertions, 34 deletions
diff --git a/src/flow_stat.cpp b/src/flow_stat.cpp index 700c584b..4d23dc60 100644 --- a/src/flow_stat.cpp +++ b/src/flow_stat.cpp @@ -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]; diff --git a/src/flow_stat.h b/src/flow_stat.h index eed3b797..6f7671fd 100644 --- a/src/flow_stat.h +++ b/src/flow_stat.h @@ -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: diff --git a/src/internal_api/trex_platform_api.h b/src/internal_api/trex_platform_api.h index f6d7278e..71ec442a 100644 --- a/src/internal_api/trex_platform_api.h +++ b/src/internal_api/trex_platform_api.h @@ -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; diff --git a/src/main_dpdk.cpp b/src/main_dpdk.cpp index 92bfda09..5f47f4bb 100644 --- a/src/main_dpdk.cpp +++ b/src/main_dpdk.cpp @@ -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); +} diff --git a/src/rpc-server/commands/trex_rpc_cmd_general.cpp b/src/rpc-server/commands/trex_rpc_cmd_general.cpp index 88ead3c2..dcf74b50 100644 --- a/src/rpc-server/commands/trex_rpc_cmd_general.cpp +++ b/src/rpc-server/commands/trex_rpc_cmd_general.cpp @@ -40,7 +40,7 @@ using namespace std; /** * ping command */ -trex_rpc_cmd_rc_e +trex_rpc_cmd_rc_e TrexRpcCmdPing::_run(const Json::Value ¶ms, Json::Value &result) { result["result"] = Json::objectValue; @@ -50,7 +50,7 @@ TrexRpcCmdPing::_run(const Json::Value ¶ms, Json::Value &result) { /** * query command */ -trex_rpc_cmd_rc_e +trex_rpc_cmd_rc_e TrexRpcCmdGetCmds::_run(const Json::Value ¶ms, Json::Value &result) { vector<string> cmds; @@ -68,7 +68,7 @@ TrexRpcCmdGetCmds::_run(const Json::Value ¶ms, Json::Value &result) { /** * get version - * + * */ trex_rpc_cmd_rc_e TrexRpcCmdGetVersion::_run(const Json::Value ¶ms, Json::Value &result) { @@ -94,11 +94,30 @@ TrexRpcCmdGetVersion::_run(const Json::Value ¶ms, Json::Value &result) { return (TREX_RPC_CMD_OK); } +trex_rpc_cmd_rc_e +TrexRpcCmdGetActivePGIds::_run(const Json::Value ¶ms, Json::Value &result) { + flow_stat_active_t active_flow_stat; + flow_stat_active_it_t it; + int i = 0; + + Json::Value §ion = 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 ¶ms, Json::Value &result) { @@ -161,7 +180,7 @@ TrexRpcCmdGetSysInfo::_run(const Json::Value ¶ms, 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 ¶ms, 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 ¶ms, 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 ¶ms, 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 ¶ms, Json::Value &result) { @@ -246,9 +265,9 @@ TrexRpcCmdSetPortAttr::_run(const Json::Value ¶ms, 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 ¶ms, 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 ¶ms, Json::Value &result) { @@ -278,7 +297,7 @@ TrexRpcCmdGetOwner::_run(const Json::Value ¶ms, Json::Value &result) { /** * acquire device - * + * */ trex_rpc_cmd_rc_e TrexRpcCmdAcquire::_run(const Json::Value ¶ms, Json::Value &result) { @@ -305,7 +324,7 @@ TrexRpcCmdAcquire::_run(const Json::Value ¶ms, Json::Value &result) { /** * release device - * + * */ trex_rpc_cmd_rc_e TrexRpcCmdRelease::_run(const Json::Value ¶ms, Json::Value &result) { @@ -327,7 +346,7 @@ TrexRpcCmdRelease::_run(const Json::Value ¶ms, Json::Value &result) { /** * get port stats - * + * */ trex_rpc_cmd_rc_e TrexRpcCmdGetPortStats::_run(const Json::Value ¶ms, Json::Value &result) { @@ -347,13 +366,13 @@ TrexRpcCmdGetPortStats::_run(const Json::Value ¶ms, 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 ¶ms, Json::Value &result) { @@ -373,7 +392,7 @@ TrexRpcCmdGetPortStatus::_run(const Json::Value ¶ms, Json::Value &result) { /** * publish async data now (fast flush) - * + * */ trex_rpc_cmd_rc_e TrexRpcPublishNow::_run(const Json::Value ¶ms, Json::Value &result) { diff --git a/src/rpc-server/commands/trex_rpc_cmds.h b/src/rpc-server/commands/trex_rpc_cmds.h index ac63e39d..386ccc27 100644 --- a/src/rpc-server/commands/trex_rpc_cmds.h +++ b/src/rpc-server/commands/trex_rpc_cmds.h @@ -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, diff --git a/src/rpc-server/trex_rpc_cmds_table.cpp b/src/rpc-server/trex_rpc_cmds_table.cpp index 7b8dfdfc..e1bd3eee 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() { 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()); diff --git a/src/trex_defs.h b/src/trex_defs.h index ace3618d..4ecee1d5 100644 --- a/src/trex_defs.h +++ b/src/trex_defs.h @@ -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 |