summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorimarom <imarom@cisco.com>2016-05-08 17:32:12 +0300
committerimarom <imarom@cisco.com>2016-05-09 16:48:16 +0300
commitdb9145d248720c633dd4da6c785e071198986326 (patch)
tree86e00a08895f65e2840b2bf8a921b9e9298f11a1 /src
parent75ce59e5652f9094beab854d263a850cfc81a3de (diff)
added duration to remote push
Diffstat (limited to 'src')
-rwxr-xr-xsrc/bp_sim.h16
-rw-r--r--src/main_dpdk.cpp21
-rw-r--r--src/rpc-server/commands/trex_rpc_cmd_general.cpp3
-rw-r--r--src/rpc-server/commands/trex_rpc_cmds.h2
-rw-r--r--src/stateless/cp/trex_stateless_port.cpp10
-rw-r--r--src/stateless/cp/trex_stateless_port.h6
-rw-r--r--src/stateless/dp/trex_stateless_dp_core.cpp20
-rw-r--r--src/stateless/dp/trex_stateless_dp_core.h7
-rw-r--r--src/stateless/dp/trex_stream_node.h4
-rw-r--r--src/stateless/messaging/trex_stateless_messaging.cpp11
-rw-r--r--src/stateless/messaging/trex_stateless_messaging.h5
11 files changed, 85 insertions, 20 deletions
diff --git a/src/bp_sim.h b/src/bp_sim.h
index 132824b3..77101508 100755
--- a/src/bp_sim.h
+++ b/src/bp_sim.h
@@ -1440,7 +1440,9 @@ public:
NODE_FLAGS_LATENCY =0x20, /* got NAT msg */
NODE_FLAGS_INIT_START_FROM_SERVER_SIDE = 0x40,
NODE_FLAGS_ALL_FLOW_SAME_PORT_SIDE = 0x80,
- NODE_FLAGS_INIT_START_FROM_SERVER_SIDE_SERVER_ADDR = 0x100 /* init packet start from server side with server addr */
+ NODE_FLAGS_INIT_START_FROM_SERVER_SIDE_SERVER_ADDR = 0x100, /* init packet start from server side with server addr */
+
+ NODE_FLAGS_SLOW_PATH = 0x200 /* used by the nodes to differ between fast path nodes and slow path nodes */
};
@@ -1479,6 +1481,17 @@ public:
return ( m_socket_id );
}
+ inline void set_slow_path(bool enable) {
+ if (enable) {
+ m_flags |= NODE_FLAGS_SLOW_PATH;
+ } else {
+ m_flags &= ~NODE_FLAGS_SLOW_PATH;
+ }
+ }
+
+ inline bool get_is_slow_path() const {
+ return ( (m_flags & NODE_FLAGS_SLOW_PATH) ? true : false);
+ }
void free_base();
};
@@ -1581,6 +1594,7 @@ public:
return ( (m_flags &NODE_FLAGS_ALL_FLOW_SAME_PORT_SIDE)?true:false );
}
+
/* direction for ip addr */
inline pkt_dir_t cur_pkt_ip_addr_dir();
diff --git a/src/main_dpdk.cpp b/src/main_dpdk.cpp
index 5a383bc6..c8921ba7 100644
--- a/src/main_dpdk.cpp
+++ b/src/main_dpdk.cpp
@@ -1774,6 +1774,7 @@ class CCoreEthIFStateless : public CCoreEthIF {
public:
virtual int send_node(CGenNode * node);
protected:
+ int handle_slow_path_node(CGenNode *node);
int send_pcap_node(CGenNodePCAP *pcap_node);
};
@@ -2002,11 +2003,12 @@ void CCoreEthIF::update_mac_addr(CGenNode * node,uint8_t *p){
int CCoreEthIFStateless::send_node(CGenNode * no) {
- /* slow path - PCAP nodes */
- if (no->m_type == CGenNode::PCAP_PKT) {
- return send_pcap_node((CGenNodePCAP *)no);
+ /* if a node is marked as slow path - single IF to redirect it to slow path */
+ if (no->get_is_slow_path()) {
+ return handle_slow_path_node(no);
}
+
CGenNodeStateless * node_sl=(CGenNodeStateless *) no;
/* check that we have mbuf */
rte_mbuf_t * m=node_sl->get_cache_mbuf();
@@ -2050,6 +2052,19 @@ int CCoreEthIFStateless::send_pcap_node(CGenNodePCAP *pcap_node) {
return (0);
}
+/**
+ * slow path code goes here
+ *
+ */
+int CCoreEthIFStateless::handle_slow_path_node(CGenNode * no) {
+
+ if (no->m_type == CGenNode::PCAP_PKT) {
+ return send_pcap_node((CGenNodePCAP *)no);
+ }
+
+ return (-1);
+}
+
int CCoreEthIF::send_node(CGenNode * node){
diff --git a/src/rpc-server/commands/trex_rpc_cmd_general.cpp b/src/rpc-server/commands/trex_rpc_cmd_general.cpp
index 5fe707af..27376fe4 100644
--- a/src/rpc-server/commands/trex_rpc_cmd_general.cpp
+++ b/src/rpc-server/commands/trex_rpc_cmd_general.cpp
@@ -465,11 +465,12 @@ TrexRpcCmdPushRemote::_run(const Json::Value &params, Json::Value &result) {
double ipg_usec = parse_double(params, "ipg_usec", result);
double speedup = parse_double(params, "speedup", result);
uint32_t count = parse_uint32(params, "count", result);
+ double duration = parse_double(params, "duration", result);
TrexStatelessPort *port = get_stateless_obj()->get_port_by_id(port_id);
try {
- port->push_remote(pcap_filename, ipg_usec, speedup, count);
+ port->push_remote(pcap_filename, ipg_usec, speedup, count, duration);
} catch (const TrexException &ex) {
generate_execute_err(result, ex.what());
}
diff --git a/src/rpc-server/commands/trex_rpc_cmds.h b/src/rpc-server/commands/trex_rpc_cmds.h
index 99c83545..affa65c1 100644
--- a/src/rpc-server/commands/trex_rpc_cmds.h
+++ b/src/rpc-server/commands/trex_rpc_cmds.h
@@ -130,7 +130,7 @@ TREX_RPC_CMD_DEFINE(TrexRpcCmdUpdateTraffic, "update_traffic", 3, true, APIClass
TREX_RPC_CMD_DEFINE(TrexRpcCmdValidate, "validate", 2, false, APIClass::API_CLASS_TYPE_CORE);
-TREX_RPC_CMD_DEFINE(TrexRpcCmdPushRemote, "push_remote", 5, true, APIClass::API_CLASS_TYPE_CORE);
+TREX_RPC_CMD_DEFINE(TrexRpcCmdPushRemote, "push_remote", 6, true, APIClass::API_CLASS_TYPE_CORE);
#endif /* __TREX_RPC_CMD_H__ */
diff --git a/src/stateless/cp/trex_stateless_port.cpp b/src/stateless/cp/trex_stateless_port.cpp
index aa2d43f3..360cc7d6 100644
--- a/src/stateless/cp/trex_stateless_port.cpp
+++ b/src/stateless/cp/trex_stateless_port.cpp
@@ -416,7 +416,12 @@ TrexStatelessPort::update_traffic(const TrexPortMultiplier &mul, bool force) {
}
void
-TrexStatelessPort::push_remote(const std::string &pcap_filename, double ipg_usec, double speedup, uint32_t count) {
+TrexStatelessPort::push_remote(const std::string &pcap_filename,
+ double ipg_usec,
+ double speedup,
+ uint32_t count,
+ double duration) {
+
/* command allowed only on state stream */
verify_state(PORT_STATE_IDLE | PORT_STATE_STREAMS);
@@ -449,7 +454,8 @@ TrexStatelessPort::push_remote(const std::string &pcap_filename, double ipg_usec
pcap_filename,
ipg_usec,
speedup,
- count);
+ count,
+ duration);
send_message_to_dp(tx_core, push_msg);
/* update subscribers */
diff --git a/src/stateless/cp/trex_stateless_port.h b/src/stateless/cp/trex_stateless_port.h
index ccbfad0d..8856b429 100644
--- a/src/stateless/cp/trex_stateless_port.h
+++ b/src/stateless/cp/trex_stateless_port.h
@@ -216,7 +216,11 @@ public:
* push a PCAP file onto the port
*
*/
- void push_remote(const std::string &pcap_filename, double ipg_usec, double speedup, uint32_t count);
+ void push_remote(const std::string &pcap_filename,
+ double ipg_usec,
+ double speedup,
+ uint32_t count,
+ double duration);
/**
* get the port state
diff --git a/src/stateless/dp/trex_stateless_dp_core.cpp b/src/stateless/dp/trex_stateless_dp_core.cpp
index 6450d0f9..dff5285d 100644
--- a/src/stateless/dp/trex_stateless_dp_core.cpp
+++ b/src/stateless/dp/trex_stateless_dp_core.cpp
@@ -301,7 +301,7 @@ bool TrexStatelessDpPerPort::push_pcap(uint8_t port_id,
assert(m_active_pcap_node == NULL);
m_active_pcap_node = pcap_node;
- m_state = TrexStatelessDpPerPort::ppSTATE_TRANSMITTING;
+ m_state = TrexStatelessDpPerPort::ppSTATE_PCAP_TX;
return (true);
}
@@ -898,7 +898,8 @@ TrexStatelessDpCore::push_pcap(uint8_t port_id,
const std::string &pcap_filename,
double ipg_usec,
double speedup,
- uint32_t count) {
+ uint32_t count,
+ double duration) {
TrexStatelessDpPerPort * lp_port = get_port_db(port_id);
@@ -917,13 +918,12 @@ TrexStatelessDpCore::push_pcap(uint8_t port_id,
return;
}
- m_state = TrexStatelessDpCore::STATE_TRANSMITTING;
- #if 0
- if ( duration > 0.0 ){
+ if (duration > 0.0) {
add_port_duration(duration, port_id, event_id);
}
- #endif
+
+ m_state = TrexStatelessDpCore::STATE_PCAP_TX;
}
@@ -1007,6 +1007,9 @@ bool CGenNodePCAP::create(uint8_t port_id,
m_port_id = port_id;
m_count = count;
+ /* mark this node as slow path */
+ set_slow_path(true);
+
if (ipg_usec != -1) {
/* fixed IPG */
m_ipg_sec = usec_to_sec(ipg_usec / speedup);
@@ -1046,6 +1049,11 @@ bool CGenNodePCAP::create(uint8_t port_id,
return true;
}
+/**
+ * cleanup for PCAP node
+ *
+ * @author imarom (08-May-16)
+ */
void CGenNodePCAP::destroy() {
if (m_raw_packet) {
diff --git a/src/stateless/dp/trex_stateless_dp_core.h b/src/stateless/dp/trex_stateless_dp_core.h
index 115f8873..0941f6f3 100644
--- a/src/stateless/dp/trex_stateless_dp_core.h
+++ b/src/stateless/dp/trex_stateless_dp_core.h
@@ -54,7 +54,8 @@ public:
enum state_e {
ppSTATE_IDLE,
ppSTATE_TRANSMITTING,
- ppSTATE_PAUSE
+ ppSTATE_PAUSE,
+ ppSTATE_PCAP_TX,
};
@@ -117,6 +118,7 @@ public:
enum state_e {
STATE_IDLE,
STATE_TRANSMITTING,
+ STATE_PCAP_TX,
STATE_TERMINATE
};
@@ -175,7 +177,8 @@ public:
const std::string &pcap_filename,
double ipg_usec,
double speedup,
- uint32_t count);
+ uint32_t count,
+ double duration);
/**
diff --git a/src/stateless/dp/trex_stream_node.h b/src/stateless/dp/trex_stream_node.h
index a970c1f7..bdbc5084 100644
--- a/src/stateless/dp/trex_stream_node.h
+++ b/src/stateless/dp/trex_stream_node.h
@@ -406,6 +406,10 @@ public:
double speedup,
uint32_t count);
+ /**
+ * destroy the node cleaning up any data
+ *
+ */
void destroy();
/**
diff --git a/src/stateless/messaging/trex_stateless_messaging.cpp b/src/stateless/messaging/trex_stateless_messaging.cpp
index c0151c76..1cbacb6f 100644
--- a/src/stateless/messaging/trex_stateless_messaging.cpp
+++ b/src/stateless/messaging/trex_stateless_messaging.cpp
@@ -187,7 +187,13 @@ TrexStatelessDpUpdate::clone() {
************************/
bool
TrexStatelessDpPushPCAP::handle(TrexStatelessDpCore *dp_core) {
- dp_core->push_pcap(m_port_id, m_event_id, m_pcap_filename, m_ipg_usec, m_speedup, m_count);
+ dp_core->push_pcap(m_port_id,
+ m_event_id,
+ m_pcap_filename,
+ m_ipg_usec,
+ m_speedup,
+ m_count,
+ m_duration);
return true;
}
@@ -198,7 +204,8 @@ TrexStatelessDpPushPCAP::clone() {
m_pcap_filename,
m_ipg_usec,
m_speedup,
- m_count);
+ m_count,
+ m_duration);
return new_msg;
}
diff --git a/src/stateless/messaging/trex_stateless_messaging.h b/src/stateless/messaging/trex_stateless_messaging.h
index c3de82ee..9b1f2e31 100644
--- a/src/stateless/messaging/trex_stateless_messaging.h
+++ b/src/stateless/messaging/trex_stateless_messaging.h
@@ -258,12 +258,14 @@ public:
const std::string &pcap_filename,
double ipg_usec,
double speedup,
- uint32_t count) : m_pcap_filename(pcap_filename) {
+ uint32_t count,
+ double duration) : m_pcap_filename(pcap_filename) {
m_port_id = port_id;
m_event_id = event_id;
m_ipg_usec = ipg_usec;
m_speedup = speedup;
m_count = count;
+ m_duration = duration;
}
virtual bool handle(TrexStatelessDpCore *dp_core);
@@ -275,6 +277,7 @@ private:
int m_event_id;
double m_ipg_usec;
double m_speedup;
+ double m_duration;
uint32_t m_count;
uint8_t m_port_id;
};