summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xsrc/bp_sim.h8
-rw-r--r--src/main_dpdk.cpp18
-rw-r--r--src/trex_watchdog.cpp49
-rw-r--r--src/trex_watchdog.h12
4 files changed, 69 insertions, 18 deletions
diff --git a/src/bp_sim.h b/src/bp_sim.h
index d940080e..3c865eac 100755
--- a/src/bp_sim.h
+++ b/src/bp_sim.h
@@ -670,6 +670,14 @@ public:
return (btGetMaskBit32(m_flags1,4,4) ? true:false);
}
+ /* split mac is enabled */
+ void setWDDisable(bool wd_disable){
+ btSetMaskBit32(m_flags1,6,6,wd_disable?1:0);
+ }
+
+ bool getWDDisable(){
+ return (btGetMaskBit32(m_flags1,6,6) ? true:false);
+ }
diff --git a/src/main_dpdk.cpp b/src/main_dpdk.cpp
index c72af57a..90d08ab0 100644
--- a/src/main_dpdk.cpp
+++ b/src/main_dpdk.cpp
@@ -552,7 +552,8 @@ enum { OPT_HELP,
OPT_VIRT_ONE_TX_RX_QUEUE,
OPT_PREFIX,
OPT_MAC_SPLIT,
- OPT_SEND_DEBUG_PKT
+ OPT_SEND_DEBUG_PKT,
+ OPT_NO_WATCHDOG
};
@@ -614,6 +615,7 @@ static CSimpleOpt::SOption parser_options[] =
{ OPT_MAC_SPLIT, "--mac-spread", SO_REQ_SEP },
{ OPT_SEND_DEBUG_PKT, "--send-debug-pkt", SO_REQ_SEP },
{ OPT_MBUF_FACTOR , "--mbuf-factor", SO_REQ_SEP },
+ { OPT_NO_WATCHDOG , "--no-watchdog", SO_NONE },
SO_END_OF_OPTIONS
@@ -715,6 +717,8 @@ static int usage(){
printf(" --mbuf-factor : factor for packet memory \n");
+ printf(" --no-watchdog : disable watchdog \n");
+
printf("\n simulation mode : \n");
printf(" Using this mode you can generate the traffic into a pcap file and learn how trex works \n");
printf(" With this version you must be SUDO to use this mode ( I know this is not normal ) \n");
@@ -936,6 +940,10 @@ static int parse_options(int argc, char *argv[], CParserOption* po, bool first_t
po->preview.set_1g_mode(true);
break;
+ case OPT_NO_WATCHDOG :
+ po->preview.setWDDisable(true);
+ break;
+
case OPT_LATENCY_PREVIEW :
sscanf(args.OptionArg(),"%d", &po->m_latency_prev);
break;
@@ -3849,6 +3857,7 @@ CGlobalTRex::handle_slow_path(bool &was_stopped) {
if ( CGlobalInfo::m_options.preview.get_no_keyboard() ==false ) {
if ( m_io_modes.handle_io_modes() ) {
+ printf(" CTRL -C ... \n");
was_stopped=true;
return false;
}
@@ -4009,6 +4018,9 @@ int CGlobalTRex::run_in_master() {
/* on exit release the lock */
cp_lock.unlock();
+ /* first stop the WD */
+ m_watchdog.stop();
+
if (!is_all_cores_finished()) {
/* probably CLTR-C */
try_stop_all_cores();
@@ -4016,7 +4028,6 @@ int CGlobalTRex::run_in_master() {
m_mg.stop();
- m_watchdog.stop();
delay(1000);
if ( was_stopped ){
@@ -4769,6 +4780,9 @@ int main_test(int argc , char * argv[]){
g_trex.reset_counters();
}
+ /* disable WD if needed */
+ g_trex.m_watchdog.init(CGlobalInfo::m_options.preview.getWDDisable()?false:true);
+
/* this will give us all cores - master + tx + latency */
g_trex.m_watchdog.mark_pending_monitor(g_trex.m_max_cores);
diff --git a/src/trex_watchdog.cpp b/src/trex_watchdog.cpp
index e78e8e6d..b320a1b3 100644
--- a/src/trex_watchdog.cpp
+++ b/src/trex_watchdog.cpp
@@ -36,7 +36,6 @@ limitations under the License.
#include <iostream>
#include <stdexcept>
-#define DISABLE_WATCHDOG_ON_GDB
static TrexWatchDog::monitor_st *global_monitor;
@@ -122,7 +121,20 @@ static void _callstack_signal_handler(int signr, siginfo_t *info, void *secret)
throw std::runtime_error(ss.str());
}
+
+void TrexWatchDog::init(bool enable){
+ m_enable =enable;
+ if (m_enable) {
+ register_signal();
+ }
+}
+
+
void TrexWatchDog::mark_pending_monitor(int count) {
+ if (!m_enable){
+ return;
+ }
+
std::unique_lock<std::mutex> lock(m_lock);
m_pending += count;
lock.unlock();
@@ -130,6 +142,10 @@ void TrexWatchDog::mark_pending_monitor(int count) {
void TrexWatchDog::block_on_pending(int max_block_time_ms) {
+ if (!m_enable){
+ return;
+ }
+
int timeout_msec = max_block_time_ms;
std::unique_lock<std::mutex> lock(m_lock);
@@ -163,8 +179,12 @@ void TrexWatchDog::block_on_pending(int max_block_time_ms) {
* @return int
*/
int TrexWatchDog::register_monitor(const std::string &name, double timeout_sec) {
+ if (!m_enable){
+ return 0;
+ }
monitor_st monitor;
+
/* cannot add monitors while active */
assert(m_active == false);
@@ -204,6 +224,10 @@ int TrexWatchDog::register_monitor(const std::string &name, double timeout_sec)
*
*/
void TrexWatchDog::disable_monitor(int handle) {
+ if (!m_enable){
+ return ;
+ }
+
assert(handle < m_monitors.size());
m_monitors[handle].active = false;
@@ -214,7 +238,9 @@ void TrexWatchDog::disable_monitor(int handle) {
*
*/
void TrexWatchDog::tickle(int handle) {
-
+ if (!m_enable){
+ return ;
+ }
assert(handle < m_monitors.size());
/* not nesscary but write gets cache invalidate for nothing */
@@ -226,7 +252,6 @@ void TrexWatchDog::tickle(int handle) {
}
void TrexWatchDog::register_signal() {
-
/* do this once */
if (g_signal_init) {
return;
@@ -247,19 +272,15 @@ void TrexWatchDog::register_signal() {
void TrexWatchDog::start() {
+ if (!m_enable){
+ return ;
+ }
+
block_on_pending();
/* no pending monitors */
assert(m_pending == 0);
- /* under GDB - disable the watchdog */
- #ifdef DISABLE_WATCHDOG_ON_GDB
- if (ptrace(PTRACE_TRACEME, 0, NULL, 0) == -1) {
- printf("\n\n*** GDB detected - disabling watchdog... ***\n\n");
- return;
- }
- #endif
-
m_active = true;
m_thread = new std::thread(&TrexWatchDog::_main, this);
if (!m_thread) {
@@ -268,6 +289,10 @@ void TrexWatchDog::start() {
}
void TrexWatchDog::stop() {
+ if (!m_enable){
+ return ;
+ }
+
m_active = false;
if (m_thread) {
@@ -285,6 +310,8 @@ void TrexWatchDog::stop() {
*/
void TrexWatchDog::_main() {
+ assert(m_enable==true);
+
/* reset all the monitors */
for (auto &monitor : m_monitors) {
monitor.tickled = true;
diff --git a/src/trex_watchdog.h b/src/trex_watchdog.h
index 63255180..0c1969b1 100644
--- a/src/trex_watchdog.h
+++ b/src/trex_watchdog.h
@@ -37,10 +37,11 @@ public:
m_thread = NULL;
m_active = false;
m_pending = 0;
-
- register_signal();
+ m_enable = false;
}
+ void init(bool enable);
+
/**
* registering a monitor happens from another thread
* this make sure that start will be able to block until
@@ -119,16 +120,17 @@ public:
/* for for a full cacheline */
uint8_t pad[15];
- };
+ } __rte_cache_aligned ;
private:
void register_signal();
void _main();
+
std::vector<monitor_st> m_monitors __rte_cache_aligned;
std::mutex m_lock;
-
+ bool m_enable;
volatile bool m_active;
std::thread *m_thread;
volatile int m_pending;
@@ -136,6 +138,6 @@ private:
static bool g_signal_init;
};
-static_assert(sizeof(TrexWatchDog::monitor_st) >= RTE_CACHE_LINE_SIZE, "sizeof(monitor_st) != RTE_CACHE_LINE_SIZE" );
+static_assert(sizeof(TrexWatchDog::monitor_st) == RTE_CACHE_LINE_SIZE, "sizeof(monitor_st) != RTE_CACHE_LINE_SIZE" );
#endif /* __TREX_WATCHDOG_H__ */