Disable watchdog for 5 seconds at Mellanox link up/down command 31/5331/1
authorYaroslav Brustinov <[email protected]>
Sun, 25 Dec 2016 13:30:38 +0000 (15:30 +0200)
committerYaroslav Brustinov <[email protected]>
Sun, 25 Dec 2016 13:30:38 +0000 (15:30 +0200)
Change-Id: If19c9c0d3e5d684e6157ab5c71a927e2e89b8211
Signed-off-by: Yaroslav Brustinov <[email protected]>
src/main_dpdk.cpp
src/trex_port_attr.h
src/trex_watchdog.cpp
src/trex_watchdog.h

index 4c44806..320a21d 100644 (file)
@@ -4766,13 +4766,14 @@ int CGlobalTRex::run_in_master() {
             slow_path_counter = 0;
         }
 
+        m_monitor.disable(30); //assume we will wake up
 
         cp_lock.unlock();
         delay(FASTPATH_DELAY_MS);
         slow_path_counter += FASTPATH_DELAY_MS;
         cp_lock.lock();
 
-        m_monitor.tickle();
+        m_monitor.enable();
     }
 
     /* on exit release the lock */
@@ -7466,6 +7467,21 @@ bool DpdkTRexPortAttr::is_loopback() const {
     return g_trex.lookup_port_by_mac(m_layer_cfg.get_ether().get_dst(), port_id);
 }
 
+
+int
+DpdkTRexPortAttrMlnx5G::set_link_up(bool up) {
+    TrexMonitor * cur_monitor = TrexWatchDog::getInstance().get_current_monitor();
+    if (cur_monitor != NULL) {
+        cur_monitor->disable(5); // should take ~2.5 seconds
+    }
+    int result = DpdkTRexPortAttr::set_link_up(up);
+    if (cur_monitor != NULL) {
+        cur_monitor->enable();
+    }
+    return result;
+}
+
+
 /**
  * marks the control plane for a total server shutdown
  *
index 01ffe42..a2fcf7e 100755 (executable)
@@ -350,6 +350,13 @@ private:
 };
 
 
+class DpdkTRexPortAttrMlnx5G : public DpdkTRexPortAttr {
+public:
+    DpdkTRexPortAttrMlnx5G(uint8_t port_id, bool is_virtual, bool fc_change_allowed) : DpdkTRexPortAttr(port_id, is_virtual, fc_change_allowed) {}
+    virtual int set_link_up(bool up);
+};
+
+
 class SimTRexPortAttr : public TRexPortAttr {
 public:
     SimTRexPortAttr() : TRexPortAttr(0) {
index d2bbeaf..f551a78 100644 (file)
@@ -148,6 +148,25 @@ void TrexWatchDog::init(bool enable){
     } 
 }
 
+/**
+ * get pointer to monitor of current thread
+ * (NULL if no monitor)
+ * 
+ */
+TrexMonitor * TrexWatchDog::get_current_monitor() {
+    TrexMonitor * cur_monitor = NULL;
+
+    for (int i = 0; i < m_mon_count; i++) {
+        if ( m_monitors[i]->get_tid() == pthread_self() ) {
+            cur_monitor = m_monitors[i];
+            break;
+        }
+    }
+
+    return cur_monitor;
+}
+
+
 /**
  * register a monitor 
  * this function is thread safe 
@@ -162,12 +181,11 @@ void TrexWatchDog::register_monitor(TrexMonitor *monitor) {
     std::unique_lock<std::mutex> lock(m_lock);
 
     /* sanity - not a must but why not... */
-    for (int i = 0; i < m_mon_count; i++) {
-        if ( (monitor == m_monitors[i]) || (m_monitors[i]->get_tid() == pthread_self()) ) {
-            std::stringstream ss;
-            ss << "WATCHDOG: double register detected\n\n" << Backtrace();
-            throw TrexException(ss.str());
-        }
+    TrexMonitor * cur_monitor = get_current_monitor();
+    if ( cur_monitor != NULL || cur_monitor == monitor ) {
+        std::stringstream ss;
+        ss << "WATCHDOG: double register detected\n\n" << Backtrace();
+        throw TrexException(ss.str());
     }
 
     /* check capacity */
index f5ea5da..390b565 100644 (file)
@@ -168,7 +168,14 @@ public:
     }
 
     void init(bool enable);
-   
+
+    /**
+     * get monitor of current thread if registered
+     * (NULL if not registered)
+     * 
+     */
+    TrexMonitor * get_current_monitor();
+
     /**
      * add a monitor to the watchdog 
      * from now on this monitor will be watched