diff options
author | Harald Welte <laforge@osmocom.org> | 2021-12-31 17:16:11 +0100 |
---|---|---|
committer | Harald Welte <laforge@osmocom.org> | 2021-12-31 17:20:32 +0100 |
commit | 8ddb22f8c6f464377da39bc26c5709916cc03517 (patch) | |
tree | e632264df4b8b02274fc8005494414b24b2a3a70 /src | |
parent | d4700da1e8fed8f5bd2a2fba045f7db0f599099f (diff) |
e1d: Add watchdog timer to detect dead lines / USB devices
We just found a bug in icE1usb (likely firmware) which was hard to find
as there was zero notification from osmo-e1d that it actually never
received any data from the icE1usb hardware/firmware anymore.
Change-Id: Id22e4110b9067f50b1818eb12295b2d4eb9cdc12
Diffstat (limited to 'src')
-rw-r--r-- | src/e1d.h | 6 | ||||
-rw-r--r-- | src/intf_line.c | 21 | ||||
-rw-r--r-- | src/mux_demux.c | 2 |
3 files changed, 29 insertions, 0 deletions
@@ -123,6 +123,12 @@ struct e1_line { struct osmo_timer_list timer; } ts0; + /* watchdog timer to catch situations where no more USB data is received */ + struct { + struct osmo_timer_list timer; + uint32_t rx_bytes; + } watchdog; + void *e1gen_priv; }; diff --git a/src/intf_line.c b/src/intf_line.c index 5143e45..5659129 100644 --- a/src/intf_line.c +++ b/src/intf_line.c @@ -35,6 +35,7 @@ #include <osmocom/core/utils.h> #include <osmocom/core/stats.h> #include <osmocom/core/rate_ctr.h> +#include <osmocom/core/timer.h> #include <osmocom/e1d/proto.h> #include "e1d.h" @@ -64,6 +65,20 @@ static const struct rate_ctr_group_desc line_ctrg_desc = { .ctr_desc = line_ctr_description, }; +/* watchdog timer, called once per second to check if we still receive data on the line */ +static void line_watchdog_cb(void *data) +{ + struct e1_line *line = data; + + if (line->watchdog.rx_bytes < 240000) { + LOGPLI(line, DE1D, LOGL_ERROR, "Received Only %u bytes/s (expected: 262144): Line dead?\n", + line->watchdog.rx_bytes); + } + + line->watchdog.rx_bytes = 0; + osmo_timer_schedule(&line->watchdog.timer, 1, 0); +} + // --------------------------------------------------------------------------- // e1d structures // --------------------------------------------------------------------------- @@ -196,6 +211,10 @@ e1_line_new(struct e1_intf *intf, void *drv_data) llist_add_tail(&line->list, &intf->lines); + /* start watchdog timer */ + osmo_timer_setup(&line->watchdog.timer, line_watchdog_cb, line); + osmo_timer_schedule(&line->watchdog.timer, 1, 0); + LOGPLI(line, DE1D, LOGL_NOTICE, "Created\n"); return line; @@ -206,6 +225,8 @@ e1_line_destroy(struct e1_line *line) { LOGPLI(line, DE1D, LOGL_NOTICE, "Destroying\n"); + osmo_timer_del(&line->watchdog.timer); + /* close all [peer] file descriptors */ for (int i=0; i<32; i++) e1_ts_stop(&line->ts[i]); diff --git a/src/mux_demux.c b/src/mux_demux.c index 341256a..b0a9cf2 100644 --- a/src/mux_demux.c +++ b/src/mux_demux.c @@ -391,6 +391,8 @@ e1_line_demux_in(struct e1_line *line, const uint8_t *buf, int size, int frame_b return -1; } + line->watchdog.rx_bytes += size; + ftr = size / 32; OSMO_ASSERT(size % 32 == 0); |