summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorimarom <imarom@cisco.com>2016-12-20 14:58:30 +0200
committerimarom <imarom@cisco.com>2016-12-20 14:58:52 +0200
commitabc0cb8755084ad00e0dc3421f307b0405f54176 (patch)
treeb3d0a060c694b29124496c3b26df6ee414d474de
parent211caa7b0018047c0ff5d94ac762b0799e995b7e (diff)
trex-312 ARP resolution does not work from console at virtual NICs
Signed-off-by: imarom <imarom@cisco.com>
-rwxr-xr-xsrc/bp_gtest.cpp6
-rwxr-xr-xsrc/bp_sim.cpp44
-rwxr-xr-xsrc/bp_sim.h13
-rw-r--r--src/main_dpdk.cpp91
-rwxr-xr-xsrc/nat_check.h9
-rw-r--r--src/stateful_rx_core.cpp2
-rw-r--r--src/stateful_rx_core.h24
-rw-r--r--src/stateless/dp/trex_stateless_dp_core.cpp4
8 files changed, 132 insertions, 61 deletions
diff --git a/src/bp_gtest.cpp b/src/bp_gtest.cpp
index 11bd6235..a3e52bb9 100755
--- a/src/bp_gtest.cpp
+++ b/src/bp_gtest.cpp
@@ -833,7 +833,7 @@ public:
m_port_id=0;
}
- virtual int tx(rte_mbuf_t * m){
+ virtual int tx(rte_mbuf_t *m) {
assert(m_queue==0);
//printf(" tx on port %d \n",m_port_id);
// utl_DumpBuffer(stdout,rte_pktmbuf_mtod(m, uint8_t*),rte_pktmbuf_pkt_len(m),0);
@@ -841,6 +841,10 @@ public:
return (0);
}
+ virtual int tx_latency(rte_mbuf_t *m) {
+ return tx(m);
+ }
+
virtual rte_mbuf_t * rx(){
//printf(" rx on port %d \n",m_port_id);
rte_mbuf_t * m=0;
diff --git a/src/bp_sim.cpp b/src/bp_sim.cpp
index 80297c32..077bef63 100755
--- a/src/bp_sim.cpp
+++ b/src/bp_sim.cpp
@@ -4025,8 +4025,10 @@ void CNodeGenerator::handle_flow_sync(CGenNode *node, CFlowGenListPerThread *thr
void
CNodeGenerator::handle_maintenance(CFlowGenListPerThread *thread) {
- thread->tickle(); /* tickle the watchdog */
- thread->check_msgs(); /* check messages */
+ /* tickle and check messages */
+ thread->tickle();
+ thread->check_msgs();
+
m_v_if->flush_tx_queue(); /* flush pkt each timeout */
/* save last sync time as realtime */
@@ -4296,11 +4298,13 @@ void CFlowGenListPerThread::handle_latency_pkt_msg(CGenNodeLatencyPktInfo * msg)
#endif
/* update timestamp */
- struct rte_mbuf * m;
- m=msg->m_pkt;
- uint8_t *p=rte_pktmbuf_mtod(m, uint8_t*);
- latency_header * h=(latency_header *)(p+msg->m_latency_offset);
- h->time_stamp = os_get_hr_tick_64();
+ if (msg->m_update_ts) {
+ struct rte_mbuf *m = msg->m_pkt;
+ uint8_t *p = rte_pktmbuf_mtod(m, uint8_t*);
+ latency_header * h = (latency_header *)(p+msg->m_latency_offset);
+ h->time_stamp = os_get_hr_tick_64();
+ }
+
m_node_gen.m_v_if->send_one_pkt((pkt_dir_t)msg->m_dir,msg->m_pkt);
}
@@ -4376,13 +4380,9 @@ void CFlowGenListPerThread::handle_nat_msg(CGenNodeNatInfo * msg){
}
}
-void CFlowGenListPerThread::check_msgs(void) {
-
- /* inlined for performance */
- m_stateless_dp_info.periodic_check_for_cp_messages();
-
+bool CFlowGenListPerThread::check_msgs_from_rx() {
if ( likely ( m_ring_from_rx->isEmpty() ) ) {
- return;
+ return false;
}
#ifdef NAT_TRACE_
@@ -4416,6 +4416,24 @@ void CFlowGenListPerThread::check_msgs(void) {
CGlobalInfo::free_node(node);
}
+
+ return true;
+}
+
+bool CFlowGenListPerThread::check_msgs() {
+
+ bool had_msg = false;
+
+ /* inlined for performance */
+ if (m_stateless_dp_info.periodic_check_for_cp_messages()) {
+ had_msg = true;
+ }
+
+ if (check_msgs_from_rx()) {
+ had_msg = true;
+ }
+
+ return had_msg;
}
diff --git a/src/bp_sim.h b/src/bp_sim.h
index 5d7df59d..c9e43ba3 100755
--- a/src/bp_sim.h
+++ b/src/bp_sim.h
@@ -323,7 +323,6 @@ public:
virtual void send_one_pkt(pkt_dir_t dir, rte_mbuf_t *m) {}
/* flush all pending packets into the stream */
virtual int flush_tx_queue(void)=0;
- virtual void handle_rx_queue(void) {};
/* update the source and destination mac-addr of a given mbuf by global database */
virtual int update_mac_addr_from_global_cfg(pkt_dir_t dir, uint8_t * p)=0;
/* translate port_id to the correct dir on the core */
@@ -3753,6 +3752,7 @@ public:
m_monitor.tickle();
}
+
/* return the dual port ID this thread is attached to in 4 ports configuration
there are 2 dual-ports
@@ -3858,9 +3858,13 @@ public:
return ( m_cpu_cp_u.GetVal());
}
+
+ bool check_msgs();
+
private:
- void check_msgs(void);
-
+
+ bool check_msgs_from_rx();
+
void handle_nat_msg(CGenNodeNatInfo * msg);
void handle_latency_pkt_msg(CGenNodeLatencyPktInfo * msg);
@@ -4269,4 +4273,7 @@ class CRXCoreIgnoreStat {
uint64_t m_tot_bytes;
};
+static_assert(sizeof(CGenNodeNatInfo) == sizeof(CGenNode), "sizeof(CGenNodeNatInfo) != sizeof(CGenNode)" );
+static_assert(sizeof(CGenNodeLatencyPktInfo) == sizeof(CGenNode), "sizeof(CGenNodeLatencyPktInfo) != sizeof(CGenNode)" );
+
#endif
diff --git a/src/main_dpdk.cpp b/src/main_dpdk.cpp
index 273ec26f..c9b182af 100644
--- a/src/main_dpdk.cpp
+++ b/src/main_dpdk.cpp
@@ -2519,10 +2519,11 @@ public:
m_tx_queue_id=tx_queue;
m_rx_queue_id=rx_queue;
}
-
- virtual int tx(rte_mbuf_t * m){
- rte_mbuf_t * tx_pkts[2];
- tx_pkts[0]=m;
+
+ virtual int tx(rte_mbuf_t *m) {
+ rte_mbuf_t *tx_pkts[2];
+
+ tx_pkts[0] = m;
if ( likely( CGlobalInfo::m_options.preview.get_vlan_mode_enable() ) ){
/* vlan mode is the default */
/* set the vlan */
@@ -2546,6 +2547,13 @@ public:
return (0);
}
+
+
+ /* nothing special with HW implementation */
+ virtual int tx_latency(rte_mbuf_t *m) {
+ return tx(m);
+ }
+
virtual rte_mbuf_t * rx(){
rte_mbuf_t * rx_pkts[1];
uint16_t cnt=m_port->rx_burst(m_rx_queue_id,rx_pkts,1);
@@ -2556,6 +2564,7 @@ public:
}
}
+
virtual uint16_t rx_burst(struct rte_mbuf **rx_pkts,
uint16_t nb_pkts){
uint16_t cnt=m_port->rx_burst(m_rx_queue_id,rx_pkts,nb_pkts);
@@ -2572,36 +2581,24 @@ private:
class CLatencyVmPort : public CPortLatencyHWBase {
public:
- void Create(uint8_t port_index,CNodeRing * ring,
- CLatencyManager * mgr, CPhyEthIF * p) {
- m_dir = (port_index%2);
+ void Create(uint8_t port_index,
+ CNodeRing *ring,
+ CLatencyManager *mgr,
+ CPhyEthIF *p) {
+
+ m_dir = (port_index % 2);
m_ring_to_dp = ring;
m_mgr = mgr;
- m_port = p;
+ m_port = p;
}
- virtual int tx(rte_mbuf_t * m){
- if ( likely( CGlobalInfo::m_options.preview.get_vlan_mode_enable() ) ){
- /* vlan mode is the default */
- /* set the vlan */
- m->ol_flags = PKT_TX_VLAN_PKT;
- m->vlan_tci =CGlobalInfo::m_options.m_vlan_port[0];
- m->l2_len =14;
- }
-
- /* allocate node */
- CGenNodeLatencyPktInfo * node=(CGenNodeLatencyPktInfo * )CGlobalInfo::create_node();
- if ( node ) {
- node->m_msg_type = CGenNodeMsgBase::LATENCY_PKT;
- node->m_dir = m_dir;
- node->m_pkt = m;
- node->m_latency_offset = m_mgr->get_latency_header_offset();
-
- if ( m_ring_to_dp->Enqueue((CGenNode*)node) ==0 ){
- return (0);
- }
- }
- return (-1);
+
+ virtual int tx(rte_mbuf_t *m) {
+ return tx_common(m, false);
+ }
+
+ virtual int tx_latency(rte_mbuf_t *m) {
+ return tx_common(m, true);
}
virtual rte_mbuf_t * rx() {
@@ -2620,6 +2617,40 @@ public:
}
private:
+ virtual int tx_common(rte_mbuf_t *m, bool fix_timestamp) {
+
+ if ( likely( CGlobalInfo::m_options.preview.get_vlan_mode_enable() ) ){
+ /* vlan mode is the default */
+ /* set the vlan */
+ m->ol_flags = PKT_TX_VLAN_PKT;
+ m->vlan_tci =CGlobalInfo::m_options.m_vlan_port[0];
+ m->l2_len =14;
+ }
+
+ /* allocate node */
+ CGenNodeLatencyPktInfo *node=(CGenNodeLatencyPktInfo * )CGlobalInfo::create_node();
+ if (!node) {
+ return (-1);
+ }
+
+ node->m_msg_type = CGenNodeMsgBase::LATENCY_PKT;
+ node->m_dir = m_dir;
+ node->m_pkt = m;
+
+ if (fix_timestamp) {
+ node->m_latency_offset = m_mgr->get_latency_header_offset();
+ node->m_update_ts = 1;
+ } else {
+ node->m_update_ts = 0;
+ }
+
+ if ( m_ring_to_dp->Enqueue((CGenNode*)node) != 0 ){
+ return (-1);
+ }
+
+ return (0);
+ }
+
CPhyEthIF * m_port;
uint8_t m_dir;
CNodeRing * m_ring_to_dp; /* ring dp -> latency thread */
diff --git a/src/nat_check.h b/src/nat_check.h
index 18add5e0..a8424ae6 100755
--- a/src/nat_check.h
+++ b/src/nat_check.h
@@ -171,10 +171,11 @@ public:
struct CGenNodeLatencyPktInfo : public CGenNodeMsgBase {
uint8_t m_dir;
uint16_t m_latency_offset;
- #if __x86_64__
- uint32_t m_pad3;
-#endif
- struct rte_mbuf * m_pkt;
+
+ uint8_t m_update_ts;
+ uint8_t m_pad3[3];
+
+ struct rte_mbuf *m_pkt;
uint32_t m_pad4[MAX_PKT_MSG_INFO];
};
diff --git a/src/stateful_rx_core.cpp b/src/stateful_rx_core.cpp
index dced7360..be9bfe13 100644
--- a/src/stateful_rx_core.cpp
+++ b/src/stateful_rx_core.cpp
@@ -580,7 +580,7 @@ void CLatencyManager::send_pkt_all_ports(){
uint8_t *p = rte_pktmbuf_mtod(m, uint8_t*);
c_l_pkt_mode->send_debug_print(p + 34);
#endif
- if ( lp->m_io->tx(m) == 0 ){
+ if ( lp->m_io->tx_latency(m) == 0 ){
lp->m_port.m_tx_pkt_ok++;
}else{
lp->m_port.m_tx_pkt_err++;
diff --git a/src/stateful_rx_core.h b/src/stateful_rx_core.h
index 8744a58a..dac3f382 100644
--- a/src/stateful_rx_core.h
+++ b/src/stateful_rx_core.h
@@ -199,13 +199,23 @@ public:
class CPortLatencyHWBase {
- public:
- virtual int tx(rte_mbuf_t * m)=0;
- virtual rte_mbuf_t * rx()=0;
- virtual uint16_t rx_burst(struct rte_mbuf **rx_pkts,
- uint16_t nb_pkts){
- return(0);
- }
+public:
+
+ /**
+ * sends a packet
+ *
+ */
+ virtual int tx(rte_mbuf_t *m) = 0;
+
+ /**
+ * sends a latency packet
+ * if needed, timestamp will be updated
+ *
+ */
+ virtual int tx_latency(rte_mbuf_t *m) = 0;
+
+ virtual rte_mbuf_t * rx() = 0;
+ virtual uint16_t rx_burst(struct rte_mbuf **rx_pkts, uint16_t nb_pkts) = 0;
};
diff --git a/src/stateless/dp/trex_stateless_dp_core.cpp b/src/stateless/dp/trex_stateless_dp_core.cpp
index 6f9376c2..ed130c29 100644
--- a/src/stateless/dp/trex_stateless_dp_core.cpp
+++ b/src/stateless/dp/trex_stateless_dp_core.cpp
@@ -681,8 +681,8 @@ TrexStatelessDpCore::idle_state_loop() {
while (m_state == STATE_IDLE) {
m_core->tickle();
- m_core->m_node_gen.m_v_if->handle_rx_queue();
- bool had_msg = periodic_check_for_cp_messages();
+
+ bool had_msg = m_core->check_msgs();
if (had_msg) {
counter = 0;
continue;