diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main_dpdk.cpp | 18 | ||||
-rwxr-xr-x | src/trex_port_attr.h | 7 | ||||
-rw-r--r-- | src/trex_watchdog.cpp | 30 | ||||
-rw-r--r-- | src/trex_watchdog.h | 9 |
4 files changed, 56 insertions, 8 deletions
diff --git a/src/main_dpdk.cpp b/src/main_dpdk.cpp index 4c448063..320a21d3 100644 --- a/src/main_dpdk.cpp +++ b/src/main_dpdk.cpp @@ -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 * diff --git a/src/trex_port_attr.h b/src/trex_port_attr.h index 01ffe424..a2fcf7e9 100755 --- a/src/trex_port_attr.h +++ b/src/trex_port_attr.h @@ -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) { diff --git a/src/trex_watchdog.cpp b/src/trex_watchdog.cpp index d2bbeafa..f551a787 100644 --- a/src/trex_watchdog.cpp +++ b/src/trex_watchdog.cpp @@ -149,6 +149,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 */ diff --git a/src/trex_watchdog.h b/src/trex_watchdog.h index f5ea5da2..390b565c 100644 --- a/src/trex_watchdog.h +++ b/src/trex_watchdog.h @@ -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 |