summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYaroslav Brustinov <ybrustin@cisco.com>2016-03-08 13:38:31 +0200
committerYaroslav Brustinov <ybrustin@cisco.com>2016-03-08 13:38:31 +0200
commit344df4618f219758a6fd005e2ea3e3d1056b5f4b (patch)
treeee55c0b783521655c49200c034bcb115d61aa8df
parentafefddfa387dad83bbcb15812bd279cf3197f583 (diff)
parent8ea0aeb8506b4da6b574700519ff4ca77b833c62 (diff)
Merge remote-tracking branch 'origin/master'
-rw-r--r--scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py10
-rw-r--r--scripts/stl/simple_3st.py48
-rw-r--r--src/dpdk22/drivers/net/enic/base/enic_vnic_wq.h7
-rw-r--r--src/flow_stat.cpp27
-rw-r--r--src/flow_stat.h1
-rw-r--r--src/internal_api/trex_platform_api.h5
-rw-r--r--src/main_dpdk.cpp59
-rw-r--r--src/rpc-server/commands/trex_rpc_cmd_general.cpp85
-rw-r--r--src/rpc-server/commands/trex_rpc_cmds.h1
-rw-r--r--src/rpc-server/trex_rpc_cmds_table.cpp1
-rw-r--r--src/trex_defs.h5
11 files changed, 173 insertions, 76 deletions
diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py
index a4e0b519..a13e2793 100644
--- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py
+++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py
@@ -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)
"""
diff --git a/scripts/stl/simple_3st.py b/scripts/stl/simple_3st.py
new file mode 100644
index 00000000..e47d6e52
--- /dev/null
+++ b/scripts/stl/simple_3st.py
@@ -0,0 +1,48 @@
+from trex_stl_lib.api import *
+
+class STLS1(object):
+
+ def __init__ (self):
+ self.fsize =64; # the size of the packet
+
+
+ def create_stream (self):
+
+ # create a base packet and pad it to size
+ size = self.fsize - 4; # no FCS
+ base_pkt = Ether()/IP(src="16.0.0.1",dst="48.0.0.1")/UDP(dport=12,sport=1025)
+ base_pkt1 = Ether()/IP(src="16.0.0.2",dst="48.0.0.1")/UDP(dport=12,sport=1025)
+ base_pkt2 = Ether()/IP(src="16.0.0.3",dst="48.0.0.1")/UDP(dport=12,sport=1025)
+ pad = max(0, size - len(base_pkt)) * 'x'
+
+
+ return STLProfile( [ STLStream( isg = 1.0, # star in delay in usec
+ packet = STLPktBuilder(pkt = base_pkt/pad),
+ mode = STLTXCont( pps = 10),
+ ),
+
+ STLStream( isg = 2.0,
+ packet = STLPktBuilder(pkt = base_pkt1/pad),
+ mode = STLTXCont( pps = 20),
+ ),
+
+ STLStream( isg = 3.0,
+ packet = STLPktBuilder(pkt = base_pkt2/pad),
+ mode = STLTXCont( pps = 30)
+
+ )
+ ]).get_streams()
+
+
+ def get_streams (self, direction = 0):
+ # create 1 stream
+ return self.create_stream()
+
+
+# dynamic load - used for trex console or simulator
+def register():
+ return STLS1()
+
+
+
+
diff --git a/src/dpdk22/drivers/net/enic/base/enic_vnic_wq.h b/src/dpdk22/drivers/net/enic/base/enic_vnic_wq.h
index e3ea5742..e4a71e39 100644
--- a/src/dpdk22/drivers/net/enic/base/enic_vnic_wq.h
+++ b/src/dpdk22/drivers/net/enic/base/enic_vnic_wq.h
@@ -69,11 +69,12 @@ static inline void enic_vnic_post_wq(struct vnic_wq *wq,
buf->wr_id = wrid;
buf = buf->next;
- if (cq_entry)
- enic_vnic_post_wq_index(wq);
+ wq->ring.desc_avail -= desc_skip_cnt;
wq->to_use = buf;
- wq->ring.desc_avail -= desc_skip_cnt;
+ if (cq_entry)
+ enic_vnic_post_wq_index(wq);
+
}
#endif /* _ENIC_VNIC_WQ_H_ */
diff --git a/src/flow_stat.cpp b/src/flow_stat.cpp
index 700c584b..ef32284b 100644
--- a/src/flow_stat.cpp
+++ b/src/flow_stat.cpp
@@ -522,18 +522,20 @@ int CFlowStatRuleMgr::start_stream(TrexStream * stream, uint16_t &ret_hw_id) {
return 0;
}
+ uint16_t hw_id;
// from here, we know the stream need rx stat
if (m_user_id_map.is_started(stream->m_rx_check.m_pg_id)) {
m_user_id_map.start_stream(stream->m_rx_check.m_pg_id); // just increase ref count;
+ hw_id = m_user_id_map.get_hw_id(stream->m_rx_check.m_pg_id); // can't fail if we got here
} else {
- uint16_t hw_id = m_hw_id_map.find_free_hw_id();
- if (hw_id > m_max_hw_id) {
- m_max_hw_id = hw_id;
- }
+ hw_id = m_hw_id_map.find_free_hw_id();
if (hw_id == FREE_HW_ID) {
printf("Error: %s failed finding free hw_id\n", __func__);
return -1;
} else {
+ if (hw_id > m_max_hw_id) {
+ m_max_hw_id = hw_id;
+ }
uint32_t user_id = stream->m_rx_check.m_pg_id;
m_user_id_map.start_stream(user_id, hw_id);
m_hw_id_map.map(hw_id, user_id);
@@ -541,7 +543,6 @@ int CFlowStatRuleMgr::start_stream(TrexStream * stream, uint16_t &ret_hw_id) {
}
}
- uint16_t hw_id = m_user_id_map.get_hw_id(stream->m_rx_check.m_pg_id); // can't fail if we got here
parser.set_ip_id(IP_ID_RESERVE_BASE + hw_id);
ret_hw_id = hw_id;
@@ -599,13 +600,22 @@ 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];
tx_per_flow_t tx_stats[MAX_FLOW_STATS];
Json::FastWriter writer;
Json::Value root;
- bool ret = false;
if (m_user_id_map.is_empty()) {
return false;
@@ -651,16 +661,15 @@ bool CFlowStatRuleMgr::dump_json(std::string & json) {
if (user_id_info->get_rx_counter(port) != 0) {
data_section[str_user_id]["rx_pkts"][str_port] = Json::Value::UInt64(user_id_info->get_rx_counter(port));
- ret = true;
}
if (user_id_info->get_tx_counter(port).get_pkts() != 0) {
data_section[str_user_id]["tx_pkts"][str_port] = Json::Value::UInt64(user_id_info->get_tx_counter(port).get_pkts());
data_section[str_user_id]["tx_bytes"][str_port] = Json::Value::UInt64(user_id_info->get_tx_counter(port).get_bytes());
- ret = true;
}
}
}
json = writer.write(root);
- return ret;
+ // We always want to publish, even only the timestamp.
+ return true;
}
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..b1cf2fb7 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) const {return 0;}
private:
int m_dp_core_count;
diff --git a/src/main_dpdk.cpp b/src/main_dpdk.cpp
index 92bfda09..0d40215a 100644
--- a/src/main_dpdk.cpp
+++ b/src/main_dpdk.cpp
@@ -18,7 +18,13 @@
See the License for the specific language governing permissions and
limitations under the License.
*/
+#include <assert.h>
+#include <pthread.h>
#include <pwd.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <zmq.h>
#include <rte_common.h>
#include <rte_log.h>
#include <rte_memory.h>
@@ -45,38 +51,27 @@
#include <rte_random.h>
#include <rte_version.h>
#include "bp_sim.h"
-#include "latency.h"
#include "os_time.h"
-#include <common/arg/SimpleGlob.h>
-#include <common/arg/SimpleOpt.h>
-#include <common/basic_utils.h>
-
-#include <stateless/cp/trex_stateless.h>
-#include <stateless/dp/trex_stream_node.h>
-#include <publisher/trex_publisher.h>
-#include <stateless/messaging/trex_stateless_messaging.h>
-
-#include <../linux_dpdk/version.h>
-
+#include "common/arg/SimpleGlob.h"
+#include "common/arg/SimpleOpt.h"
+#include "common/basic_utils.h"
+#include "stateless/cp/trex_stateless.h"
+#include "stateless/dp/trex_stream_node.h"
+#include "stateless/messaging/trex_stateless_messaging.h"
+#include "publisher/trex_publisher.h"
+#include "../linux_dpdk/version.h"
extern "C" {
-#include <dpdk22/drivers/net/ixgbe/base/ixgbe_type.h>
+#include "dpdk22/drivers/net/ixgbe/base/ixgbe_type.h"
}
-#include <dpdk22/drivers/net/e1000/base/e1000_regs.h>
-#include <zmq.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <string.h>
-#include <assert.h>
-#include <pthread.h>
+#include "dpdk22/drivers/net/e1000/base/e1000_regs.h"
#include "global_io_mode.h"
#include "utl_term_io.h"
#include "msg_manager.h"
#include "platform_cfg.h"
#include "latency.h"
-#include "main_dpdk.h"
#include "debug.h"
-
-#include <internal_api/trex_platform_api.h>
+#include "internal_api/trex_platform_api.h"
+#include "main_dpdk.h"
#define RX_CHECK_MIX_SAMPLE_RATE 8
#define RX_CHECK_MIX_SAMPLE_RATE_1G 2
@@ -3918,9 +3913,9 @@ int CPhyEthIF::reset_hw_flow_stats() {
// get/reset flow director counters
// return 0 if OK. -1 if operation not supported.
-// stats - If not NULL, returning counter numbers in it.
-// index - If non negative, get only counter with this index
-// reset - If true, reset counter value after reading
+// rx_stats, tx_stats - arrays of len max - min + 1. Returning rx, tx updated values.
+// min, max - minimum, maximum counters range to get
+// reset - If true, need to reset counter value after reading
int CPhyEthIF::get_flow_stats(uint64_t *rx_stats, tx_per_flow_t *tx_stats, int min, int max, bool reset) {
uint32_t diff_stats[MAX_FLOW_STATS];
@@ -3932,20 +3927,20 @@ int CPhyEthIF::get_flow_stats(uint64_t *rx_stats, tx_per_flow_t *tx_stats, int m
if ( reset ) {
// return value so far, and reset
if (rx_stats != NULL) {
- rx_stats[i] = m_stats.m_rx_per_flow[i] + diff_stats[i];
+ rx_stats[i - min] = m_stats.m_rx_per_flow[i] + diff_stats[i];
}
if (tx_stats != NULL) {
- tx_stats[i] = g_trex.get_flow_tx_stats(m_port_id, i);
+ tx_stats[i - min] = g_trex.get_flow_tx_stats(m_port_id, i);
}
m_stats.m_rx_per_flow[i] = 0;
g_trex.clear_flow_tx_stats(m_port_id, i);
} else {
m_stats.m_rx_per_flow[i] += diff_stats[i];
if (rx_stats != NULL) {
- rx_stats[i] = m_stats.m_rx_per_flow[i];
+ rx_stats[i - min] = m_stats.m_rx_per_flow[i];
}
if (tx_stats != NULL) {
- tx_stats[i] = g_trex.get_flow_tx_stats(m_port_id, i);
+ tx_stats[i - min] = g_trex.get_flow_tx_stats(m_port_id, i);
}
}
}
@@ -5235,3 +5230,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 &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) {
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