summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorimarom <imarom@cisco.com>2016-09-08 13:59:27 +0300
committerimarom <imarom@cisco.com>2016-09-08 14:09:01 +0300
commitb87818b8fdb3a73cd5a6247eacada460b57392ff (patch)
tree1c6db4a26c51cfdc0c5df9fca216c03090bd1d29 /src
parent2261b2337b055e516c0ecf331c49eee8a002b5f0 (diff)
dual mode fix: MAC address on the slave port was not updated
Diffstat (limited to 'src')
-rw-r--r--src/stateless/dp/trex_stateless_dp_core.cpp19
-rw-r--r--src/stateless/dp/trex_stream_node.h24
2 files changed, 36 insertions, 7 deletions
diff --git a/src/stateless/dp/trex_stateless_dp_core.cpp b/src/stateless/dp/trex_stateless_dp_core.cpp
index 53e9bbf4..bea52d42 100644
--- a/src/stateless/dp/trex_stateless_dp_core.cpp
+++ b/src/stateless/dp/trex_stateless_dp_core.cpp
@@ -492,13 +492,19 @@ bool TrexStatelessDpPerPort::push_pcap(uint8_t port_id,
pkt_dir_t dir = m_core->m_node_gen.m_v_if->port_id_to_dir(port_id);
socket_id_t socket_id = m_core->m_node_gen.m_socket_id;
+ /* main port */
uint8_t mac_addr[12];
m_core->m_node_gen.m_v_if->update_mac_addr_from_global_cfg(dir, mac_addr);
+ /* for dual */
+ uint8_t slave_mac_addr[12];
+ m_core->m_node_gen.m_v_if->update_mac_addr_from_global_cfg(dir ^ 0x1, slave_mac_addr);
+
bool rc = pcap_node->create(port_id,
dir,
socket_id,
mac_addr,
+ slave_mac_addr,
pcap_filename,
ipg_usec,
speedup,
@@ -1253,6 +1259,7 @@ bool CGenNodePCAP::create(uint8_t port_id,
pkt_dir_t dir,
socket_id_t socket_id,
const uint8_t *mac_addr,
+ const uint8_t *slave_mac_addr,
const std::string &pcap_filename,
double ipg_usec,
double speedup,
@@ -1266,6 +1273,7 @@ bool CGenNodePCAP::create(uint8_t port_id,
m_port_id = port_id;
m_count = count;
m_is_dual = is_dual;
+ m_dir = dir;
/* mark this node as slow path */
set_slow_path(true);
@@ -1282,9 +1290,9 @@ bool CGenNodePCAP::create(uint8_t port_id,
/* copy MAC addr info */
memcpy(m_mac_addr, mac_addr, 12);
+ memcpy(m_slave_mac_addr, slave_mac_addr, 12);
+
- /* set the dir */
- set_mbuf_dir(dir);
set_socket_id(socket_id);
/* create the PCAP reader */
@@ -1300,8 +1308,13 @@ bool CGenNodePCAP::create(uint8_t port_id,
return (false);
}
+ /* set the dir */
+ set_mbuf_dir(dir);
+
+ /* update the direction (for dual mode) */
+ update_pkt_dir();
+
/* this is the reference time */
- //m_base_time = m_raw_packet->get_time();
m_last_pkt_time = m_raw_packet->get_time();
/* ready */
diff --git a/src/stateless/dp/trex_stream_node.h b/src/stateless/dp/trex_stream_node.h
index 5da10d4b..dda3113a 100644
--- a/src/stateless/dp/trex_stream_node.h
+++ b/src/stateless/dp/trex_stream_node.h
@@ -465,6 +465,7 @@ public:
pkt_dir_t dir,
socket_id_t socket_id,
const uint8_t *mac_addr,
+ const uint8_t *slave_mac_addr,
const std::string &pcap_filename,
double ipg_usec,
double speedup,
@@ -510,9 +511,16 @@ public:
}
}
- /* for dual mode - choose the right interface (even or odd) */
+ /* update the packet dir if needed */
+ update_pkt_dir();
+
+ }
+
+
+ inline void update_pkt_dir() {
+ /* if dual mode and the interface is odd - swap the dir */
if (is_dual()) {
- uint8_t dir = m_raw_packet->getInterface() & 0x1;
+ pkt_dir_t dir = (m_raw_packet->getInterface() & 0x1) ? (m_dir ^ 0x1) : m_dir;
set_mbuf_dir(dir);
}
}
@@ -549,7 +557,12 @@ public:
memcpy(p, m_raw_packet->raw, m_raw_packet->getTotalLen());
/* fix the MAC */
- memcpy(p, m_mac_addr, 12);
+ if (get_mbuf_dir() == m_dir) {
+ memcpy(p, m_mac_addr, 12);
+ } else {
+ memcpy(p, m_slave_mac_addr, 12);
+ }
+
return (m);
}
@@ -611,8 +624,11 @@ private:
/* cache line 0 */
/* important stuff here */
uint8_t m_mac_addr[12];
+ uint8_t m_slave_mac_addr[12];
uint8_t m_state;
+ pkt_dir_t m_dir;
+
double m_last_pkt_time;
double m_speedup;
double m_ipg_sec;
@@ -628,7 +644,7 @@ private:
bool m_is_dual;
/* pad to match the size of CGenNode */
- uint8_t m_pad_end[32];
+ uint8_t m_pad_end[19];
} __rte_cache_aligned;