summaryrefslogtreecommitdiffstats
path: root/src/stateless
diff options
context:
space:
mode:
authorHanoh Haim <hhaim@cisco.com>2016-02-15 14:19:55 +0200
committerHanoh Haim <hhaim@cisco.com>2016-02-15 14:19:55 +0200
commit831557167f13715b0c9b5b456e0756bb9c8af3ab (patch)
treef264d07a5feec83d38afdf9813558e23271db2bb /src/stateless
parent6389df5830584f4ab4f5d83f0c9575f5c154b379 (diff)
parentf6901ca1f2cca419eeba2e1a35a38fe06a6650be (diff)
Add support for mac replacement
Diffstat (limited to 'src/stateless')
-rw-r--r--src/stateless/cp/trex_stream.cpp2
-rw-r--r--src/stateless/cp/trex_stream.h35
-rw-r--r--src/stateless/dp/trex_stateless_dp_core.cpp47
-rw-r--r--src/stateless/dp/trex_stateless_dp_core.h5
-rw-r--r--src/stateless/dp/trex_stream_node.h8
5 files changed, 84 insertions, 13 deletions
diff --git a/src/stateless/cp/trex_stream.cpp b/src/stateless/cp/trex_stream.cpp
index 256f7de8..af35dbe9 100644
--- a/src/stateless/cp/trex_stream.cpp
+++ b/src/stateless/cp/trex_stream.cpp
@@ -130,6 +130,8 @@ TrexStream::TrexStream(uint8_t type,
m_num_bursts=1;
m_ibg_usec=0.0;
m_vm_dp = NULL;
+ m_flags=0;
+ m_stream_count=0;
}
TrexStream::~TrexStream() {
diff --git a/src/stateless/cp/trex_stream.h b/src/stateless/cp/trex_stream.h
index 72e7bb8b..0f2a16c3 100644
--- a/src/stateless/cp/trex_stream.h
+++ b/src/stateless/cp/trex_stream.h
@@ -33,6 +33,8 @@ limitations under the License.
#include <stdio.h>
#include <string.h>
#include <common/captureFile.h>
+#include <common/bitMan.h>
+
class TrexRpcCmdAddStream;
@@ -118,6 +120,15 @@ public:
typedef uint8_t stream_type_t ;
+ enum DST_MAC_TYPE {
+ stCFG_FILE = 0,
+ stPKT = 1,
+ stARP = 2
+ };
+
+ typedef uint8_t stream_dst_mac_t ;
+
+
static std::string get_stream_type_str(stream_type_t stream_type);
public:
@@ -163,8 +174,6 @@ public:
return (true);
}
}
-
-
/* can this stream be split ? */
bool is_splitable(uint8_t dp_core_count) const {
@@ -218,6 +227,8 @@ public:
dp->m_burst_total_pkts = m_burst_total_pkts;
dp->m_num_bursts = m_num_bursts;
dp->m_ibg_usec = m_ibg_usec;
+ dp->m_flags = m_flags;
+ dp->m_stream_count = m_stream_count;
return(dp);
}
@@ -256,10 +267,30 @@ public:
void vm_compile();
public:
+
+ void set_override_src_mac_by_pkt_data(bool enable){
+ btSetMaskBit16(m_flags,0,0,enable?1:0);
+ }
+
+ bool get_override_src_mac_by_pkt_data(){
+ return (btGetMaskBit16(m_flags,0,0) ?true:false);
+ }
+
+ void set_override_dst_mac_mode(stream_dst_mac_t val){
+ btSetMaskBit16(m_flags,2,1,val&0x3);
+ }
+
+ stream_dst_mac_t get_override_dst_mac_mode(){
+ return ((stream_dst_mac_t)btGetMaskBit16(m_flags,2,1));
+ }
+
+public:
/* basic */
uint8_t m_type;
uint8_t m_port_id;
+ uint16_t m_flags;
uint32_t m_stream_id; /* id from RPC can be anything */
+ uint16_t m_stream_count;
/* config fields */
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);
}
diff --git a/src/stateless/dp/trex_stateless_dp_core.h b/src/stateless/dp/trex_stateless_dp_core.h
index c8a5eff5..3d214655 100644
--- a/src/stateless/dp/trex_stateless_dp_core.h
+++ b/src/stateless/dp/trex_stateless_dp_core.h
@@ -271,6 +271,11 @@ private:
void add_global_duration(double duration);
+ void update_mac_addr(TrexStream * stream,
+ CGenNodeStateless *node,
+ uint8_t dir,
+ char *raw_pkt);
+
void add_stream(TrexStatelessDpPerPort * lp_port,
TrexStream * stream,
TrexStreamsCompiledObj *comp);
diff --git a/src/stateless/dp/trex_stream_node.h b/src/stateless/dp/trex_stream_node.h
index dfa4cc13..db7f19e8 100644
--- a/src/stateless/dp/trex_stream_node.h
+++ b/src/stateless/dp/trex_stream_node.h
@@ -81,8 +81,8 @@ private:
void * m_cache_mbuf;
double m_next_time_offset; /* in sec */
- double m_ibg_sec; /* inter burst time in sec */
-
+ uint32_t m_pad11;
+ uint32_t m_pad12;
stream_state_t m_state;
uint8_t m_port_id;
@@ -167,7 +167,7 @@ public:
}
inline double get_multi_ibg_sec(){
- return (m_ibg_sec);
+ return (usec_to_sec(m_ref_stream_info->m_ibg_usec));
}
inline uint32_t get_multi_burst_cnt(){
@@ -222,7 +222,7 @@ public:
}
}else{
- m_time += m_ibg_sec;
+ m_time += get_multi_ibg_sec();
m_single_burst = m_single_burst_refill;
thread->m_node_gen.m_p_queue.push( (CGenNode *)this);
}