trex-312 ARP resolution does not work from console at virtual NICs 87/5187/1
authorimarom <[email protected]>
Tue, 20 Dec 2016 12:58:30 +0000 (14:58 +0200)
committerimarom <[email protected]>
Tue, 20 Dec 2016 12:58:52 +0000 (14:58 +0200)
Signed-off-by: imarom <[email protected]>
src/bp_gtest.cpp
src/bp_sim.cpp
src/bp_sim.h
src/main_dpdk.cpp
src/nat_check.h
src/stateful_rx_core.cpp
src/stateful_rx_core.h
src/stateless/dp/trex_stateless_dp_core.cpp

index 11bd623..a3e52bb 100755 (executable)
@@ -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;
index 80297c3..077bef6 100755 (executable)
@@ -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;
 }
 
 
index 5d7df59..c9e43ba 100755 (executable)
@@ -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
index 273ec26..c9b182a 100644 (file)
@@ -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 */
index 18add5e..a8424ae 100755 (executable)
@@ -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];
 };
index dced736..be9bfe1 100644 (file)
@@ -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++;
index 8744a58..dac3f38 100644 (file)
@@ -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;
 };
 
 
index 6f9376c..ed130c2 100644 (file)
@@ -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;