summaryrefslogtreecommitdiffstats
path: root/src/stateless/dp/trex_stateless_dp_core.cpp
diff options
context:
space:
mode:
authorHanoh Haim <hhaim@cisco.com>2016-02-15 14:19:03 +0200
committerHanoh Haim <hhaim@cisco.com>2016-02-15 14:19:03 +0200
commitf6901ca1f2cca419eeba2e1a35a38fe06a6650be (patch)
treeaa998cd7f1005cc3efa192cc88c38b7d5dfcb650 /src/stateless/dp/trex_stateless_dp_core.cpp
parent1f60016f591ebd2e260e501c8c5da10c11d0c7ad (diff)
add support for dp mac replace mode-golden were changed
Diffstat (limited to 'src/stateless/dp/trex_stateless_dp_core.cpp')
-rw-r--r--src/stateless/dp/trex_stateless_dp_core.cpp47
1 files changed, 40 insertions, 7 deletions
diff --git a/src/stateless/dp/trex_stateless_dp_core.cpp b/src/stateless/dp/trex_stateless_dp_core.cpp
index a80efc08..a84269ab 100644
--- a/src/stateless/dp/trex_stateless_dp_core.cpp
+++ b/src/stateless/dp/trex_stateless_dp_core.cpp
@@ -506,6 +506,43 @@ TrexStatelessDpCore::add_port_duration(double duration,
}
+void TrexStatelessDpCore::update_mac_addr(TrexStream * stream,
+ CGenNodeStateless *node,
+ pkt_dir_t dir,
+ char *raw_pkt){
+ bool ov_src = stream->get_override_src_mac_by_pkt_data();
+ TrexStream::stream_dst_mac_t ov_dst = stream->get_override_dst_mac_mode();
+
+
+ if ( (ov_src == true) && (ov_dst == TrexStream::stPKT) ) {
+ /* nothing to do, take from the packet both */
+ return;
+ }
+
+ /* take from cfg_file */
+ if ( (ov_src == false) &&
+ (ov_dst == TrexStream::stCFG_FILE) ){
+
+ m_core->m_node_gen.m_v_if->update_mac_addr_from_global_cfg(dir,(uint8_t*)raw_pkt);
+ return;
+ }
+
+ /* save the pkt*/
+ char tmp_pkt[12];
+ memcpy(tmp_pkt,raw_pkt,12);
+
+ m_core->m_node_gen.m_v_if->update_mac_addr_from_global_cfg(dir,(uint8_t*)raw_pkt);
+
+ if ((ov_src == true) && (ov_dst == TrexStream::stCFG_FILE)) {
+ memcpy(raw_pkt+6,tmp_pkt+6,6);
+ }
+
+ if ((ov_src == false) && (ov_dst == TrexStream::stPKT)) {
+ memcpy(raw_pkt,tmp_pkt,6);
+ }
+}
+
+
void
TrexStatelessDpCore::add_stream(TrexStatelessDpPerPort * lp_port,
TrexStream * stream,
@@ -561,7 +598,6 @@ TrexStatelessDpCore::add_stream(TrexStatelessDpPerPort * lp_port,
node->m_single_burst=0;
node->m_single_burst_refill=0;
node->m_multi_bursts=0;
- node->m_ibg_sec = 0.0;
break;
case TrexStream::stSINGLE_BURST :
@@ -569,14 +605,12 @@ TrexStatelessDpCore::add_stream(TrexStatelessDpPerPort * lp_port,
node->m_single_burst = stream->m_burst_total_pkts;
node->m_single_burst_refill = stream->m_burst_total_pkts;
node->m_multi_bursts = 1; /* single burst in multi burst of 1 */
- node->m_ibg_sec = 0.0;
break;
case TrexStream::stMULTI_BURST :
node->m_single_burst = stream->m_burst_total_pkts;
node->m_single_burst_refill = stream->m_burst_total_pkts;
node->m_multi_bursts = stream->m_num_bursts;
- node->m_ibg_sec = usec_to_sec( stream->m_ibg_usec );
break;
default:
@@ -605,8 +639,7 @@ TrexStatelessDpCore::add_stream(TrexStatelessDpPerPort * lp_port,
/* copy the packet */
memcpy(p,stream_pkt,pkt_size);
- /* TBD repace the mac if req we should add flag */
- m_core->m_node_gen.m_v_if->update_mac_addr_from_global_cfg(dir,(uint8_t*) p);
+ update_mac_addr(stream,node,dir,p);
/* set the packet as a readonly */
node->set_cache_mbuf(m);
@@ -659,8 +692,8 @@ TrexStatelessDpCore::add_stream(TrexStatelessDpPerPort * lp_port,
assert(p);
memcpy(p,stream_pkt , header_size);
- /* TBD repace the mac if req we should add flag */
- m_core->m_node_gen.m_v_if->update_mac_addr_from_global_cfg(dir, p);
+
+ update_mac_addr(stream,node,dir,(char *)p);
}