summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorimarom <imarom@cisco.com>2016-12-21 14:25:16 +0200
committerimarom <imarom@cisco.com>2016-12-21 14:49:09 +0200
commitfff19c8c2faced0972601ca9956bb36a33aa6e87 (patch)
tree36a120e226f78ad974a7086bbd396d8d26131b41
parentbf7c614dc174697b416eb3dfad515cedb104028b (diff)
watchdog disable for time capability
Signed-off-by: imarom <imarom@cisco.com>
-rw-r--r--scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_port.py8
-rw-r--r--src/trex_watchdog.cpp17
-rw-r--r--src/trex_watchdog.h85
3 files changed, 63 insertions, 47 deletions
diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_port.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_port.py
index 37472cdb..3fe4c198 100644
--- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_port.py
+++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_port.py
@@ -761,17 +761,11 @@ class Port(object):
# invalidates the current ARP
def invalidate_arp (self):
- dest = self.__attr['dest']
-
if not self.is_l3_mode():
return self.err('port is not configured with L3')
- self.set_l3_mode(self.get_src_addr()['ipv4'], self.get_dst_addr()['ipv4'])
+ return self.set_l3_mode(self.get_src_addr()['ipv4'], self.get_dst_addr()['ipv4'])
- if dest['type'] != 'mac':
- return self.set_attr(dest = dest['ipv4'])
- else:
- return self.ok()
def print_profile (self, mult, duration):
diff --git a/src/trex_watchdog.cpp b/src/trex_watchdog.cpp
index 9b6f5865..d2bbeafa 100644
--- a/src/trex_watchdog.cpp
+++ b/src/trex_watchdog.cpp
@@ -126,12 +126,15 @@ static void _callstack_signal_handler(int signr, siginfo_t *info, void *secret)
*************************************/
void TrexMonitor::create(const std::string &name, double timeout_sec) {
- m_active = true;
- m_tid = pthread_self();
- m_name = name;
- m_timeout_sec = timeout_sec;
- m_tickled = true;
- m_ts = 0;
+ m_active_time_sec = now_sec();
+ m_tid = pthread_self();
+ m_name = name;
+ m_timeout_sec = timeout_sec;
+ m_tickled = true;
+ m_ts = 0;
+
+ /* the rare case of m_active_time_sec set out of order with tickled */
+ asm volatile("mfence" ::: "memory");
}
/**************************************
@@ -236,7 +239,7 @@ void TrexWatchDog::_main() {
TrexMonitor *monitor = m_monitors[i];
/* skip non active monitors */
- if (!monitor->is_active()) {
+ if (!monitor->is_active(now)) {
continue;
}
diff --git a/src/trex_watchdog.h b/src/trex_watchdog.h
index af9a3993..f5ea5da2 100644
--- a/src/trex_watchdog.h
+++ b/src/trex_watchdog.h
@@ -36,7 +36,8 @@ limitations under the License.
* @author imarom (19-Jun-16)
*/
class TrexMonitor {
-
+ friend class TrexWatchDog;
+
public:
/**
@@ -52,14 +53,29 @@ public:
void create(const std::string &name, double timeout_sec);
/**
- * disable the monitor - it will be ignored
+ * disable the monitor for 'time_sec'
+ * by default it will disable it for a long period of time
+ * (forever)
*
*/
- void disable() {
- m_active = false;
+ void disable(dsec_t time_sec = 1e9) {
+ /* double writes are atomic on x86_64 (aligned to 8 bytes) */
+ m_active_time_sec = now_sec() + time_sec;
}
/**
+ * re-enable a monitor after it was disabled
+ *
+ */
+ void enable() {
+ /* before enabling - must tickle o.w the watchdog might crash this thread */
+ tickle();
+ /* memory fence - make sure the main thread sees this by order */
+ asm volatile("mfence" ::: "memory");
+ m_active_time_sec = now_sec();
+ }
+
+ /**
* tickle the monitor - this should be called from the thread
* to avoid the watchdog from detecting a stuck thread
*
@@ -72,6 +88,23 @@ public:
}
}
+ const std::string &get_name() const {
+ return m_name;
+ }
+
+ /* return how much time has passed since last tickle */
+ dsec_t get_interval(dsec_t now) const {
+ return (now - m_ts);
+ }
+
+
+ dsec_t get_timeout_sec() const {
+ return m_timeout_sec;
+ }
+
+
+private:
+
/**
* called by the watchdog to reset the monitor for a new round
*
@@ -81,26 +114,14 @@ public:
m_ts = now;
}
-
- /* return how much time has passed since last tickle */
- dsec_t get_interval(dsec_t now) const {
- return (now - m_ts);
- }
-
+
pthread_t get_tid() const {
return m_tid;
}
- const std::string &get_name() const {
- return m_name;
- }
-
- dsec_t get_timeout_sec() const {
- return m_timeout_sec;
- }
-
- volatile bool is_active() const {
- return m_active;
+
+ volatile bool is_active(dsec_t now) const {
+ return ( (now - m_active_time_sec) > 0 );
}
volatile bool is_tickled() const {
@@ -112,16 +133,14 @@ public:
}
-private:
-
/* write fields are first */
- volatile bool m_active;
- volatile bool m_tickled;
- int m_handle;
- dsec_t m_ts;
- double m_timeout_sec;
- pthread_t m_tid;
- std::string m_name;
+ volatile dsec_t m_active_time_sec;
+ volatile bool m_tickled;
+ int m_handle;
+ dsec_t m_ts;
+ double m_timeout_sec;
+ pthread_t m_tid;
+ std::string m_name;
} __rte_cache_aligned;
@@ -179,10 +198,10 @@ public:
private:
TrexWatchDog() {
- m_thread = NULL;
- m_enable = false;
- m_active = false;
- m_mon_count = 0;
+ m_thread = NULL;
+ m_enable = false;
+ m_active = false;
+ m_mon_count = 0;
}
void register_signal();