diff options
author | Pau Espin Pedrol <pespin@sysmocom.de> | 2019-05-24 16:54:19 +0200 |
---|---|---|
committer | Pau Espin Pedrol <pespin@sysmocom.de> | 2019-06-05 12:50:38 +0200 |
commit | 4456b6f132437a95833e3a3d3353836331b9c8a0 (patch) | |
tree | d23d18e603643d08d821e4ba14a5519b77b379de /Transceiver52M/device | |
parent | 76a5013c914a152cd3f7a80488953946ad353441 (diff) |
Add rate_ctr support to store/retrieve SDR errors through VTY
Introduce a unified implementation-agnostic interface for radioDevice to
signal SDR error counters to upper layers and manage them.
This patch only implements counters for osmo-trx-lms (other devices will
show all counters unchanged during time).
Sample use through VTY:
"""
OsmoTRX> show rate-counters
osmo-trx statistics 0:
device:rx_underruns: 0 (0/s 0/m 0/h 0/d) Number of Rx underruns
device:rx_overruns: 0 (0/s 0/m 0/h 0/d) Number of Rx overruns
device:tx_underruns: 0 (0/s 0/m 0/h 0/d) Number of Tx underruns
device:rx_drop_events: 4 (0/s 2/m 3/h 0/d) Number of times Rx samples were dropped by HW
device:rx_drop_samples: 513 (0/s 196/m 425/h 0/d) Number of Rx samples dropped by HW
"""
Change-Id: I78b158141697e5714d04db8b9ccc96f31f34f439
Diffstat (limited to 'Transceiver52M/device')
-rw-r--r-- | Transceiver52M/device/common/radioDevice.h | 10 | ||||
-rw-r--r-- | Transceiver52M/device/lms/LMSDevice.cpp | 76 | ||||
-rw-r--r-- | Transceiver52M/device/lms/LMSDevice.h | 5 |
3 files changed, 54 insertions, 37 deletions
diff --git a/Transceiver52M/device/common/radioDevice.h b/Transceiver52M/device/common/radioDevice.h index 30e0f43..cd378a8 100644 --- a/Transceiver52M/device/common/radioDevice.h +++ b/Transceiver52M/device/common/radioDevice.h @@ -23,6 +23,7 @@ extern "C" { #include "config_defs.h" +#include "osmo_signal.h" } #ifdef HAVE_CONFIG_H @@ -168,13 +169,20 @@ class RadioDevice { size_t chans; double lo_offset; std::vector<std::string> tx_paths, rx_paths; + std::vector<struct device_counters> m_ctr; RadioDevice(size_t tx_sps, size_t rx_sps, InterfaceType type, size_t chans, double offset, const std::vector<std::string>& tx_paths, const std::vector<std::string>& rx_paths): tx_sps(tx_sps), rx_sps(rx_sps), iface(type), chans(chans), lo_offset(offset), tx_paths(tx_paths), rx_paths(rx_paths) - { } + { + m_ctr.resize(chans); + for (size_t i = 0; i < chans; i++) { + memset(&m_ctr[i], 0, sizeof(m_ctr[i])); + m_ctr[i].chan = i; + } + } bool set_antennas() { unsigned int i; diff --git a/Transceiver52M/device/lms/LMSDevice.cpp b/Transceiver52M/device/lms/LMSDevice.cpp index a1ca983..910a6e7 100644 --- a/Transceiver52M/device/lms/LMSDevice.cpp +++ b/Transceiver52M/device/lms/LMSDevice.cpp @@ -25,7 +25,10 @@ #include <lime/LimeSuite.h> +extern "C" { +#include "osmo_signal.h" #include <osmocom/core/utils.h> +} #ifdef HAVE_CONFIG_H #include "config.h" @@ -53,11 +56,6 @@ LMSDevice::LMSDevice(size_t tx_sps, size_t rx_sps, InterfaceType iface, size_t c m_lms_stream_rx.resize(chans); m_lms_stream_tx.resize(chans); - m_last_rx_underruns.resize(chans, 0); - m_last_rx_overruns.resize(chans, 0); - m_last_rx_dropped.resize(chans, 0); - m_last_tx_underruns.resize(chans, 0); - rx_buffers.resize(chans); } @@ -580,32 +578,45 @@ GSM::Time LMSDevice::minLatency() { void LMSDevice::update_stream_stats(size_t chan, bool * underrun, bool * overrun) { lms_stream_status_t status; - if (LMS_GetStreamStatus(&m_lms_stream_rx[chan], &status) == 0) { - if (status.underrun > m_last_rx_underruns[chan]) { - *underrun = true; - LOGCHAN(chan, DDEV, ERROR) << "recv Underrun! (" - << m_last_rx_underruns[chan] << " -> " - << status.underrun << ")"; - } - m_last_rx_underruns[chan] = status.underrun; + bool changed = false; - if (status.overrun > m_last_rx_overruns[chan]) { - *overrun = true; - LOGCHAN(chan, DDEV, ERROR) << "recv Overrun! (" - << m_last_rx_overruns[chan] << " -> " - << status.overrun << ")"; - } - m_last_rx_overruns[chan] = status.overrun; - - if (status.droppedPackets) { - LOGCHAN(chan, DDEV, ERROR) << "recv Dropped packets by HW! (" - << m_last_rx_dropped[chan] << " -> " - << m_last_rx_dropped[chan] + - status.droppedPackets - << ")"; - } - m_last_rx_dropped[chan] += status.droppedPackets; + if (LMS_GetStreamStatus(&m_lms_stream_rx[chan], &status) != 0) { + LOGCHAN(chan, DDEV, ERROR) << "LMS_GetStreamStatus failed"; + return; + } + + if (status.underrun > m_ctr[chan].rx_underruns) { + changed = true; + *underrun = true; + LOGCHAN(chan, DDEV, ERROR) << "recv Underrun! (" + << m_ctr[chan].rx_underruns << " -> " + << status.underrun << ")"; } + m_ctr[chan].rx_underruns = status.underrun; + + if (status.overrun > m_ctr[chan].rx_overruns) { + changed = true; + *overrun = true; + LOGCHAN(chan, DDEV, ERROR) << "recv Overrun! (" + << m_ctr[chan].rx_overruns << " -> " + << status.overrun << ")"; + } + m_ctr[chan].rx_overruns = status.overrun; + + if (status.droppedPackets) { + changed = true; + LOGCHAN(chan, DDEV, ERROR) << "recv Dropped packets by HW! (" + << m_ctr[chan].rx_dropped_samples << " -> " + << m_ctr[chan].rx_dropped_samples + + status.droppedPackets + << ")"; + m_ctr[chan].rx_dropped_events++; + } + m_ctr[chan].rx_dropped_samples += status.droppedPackets; + + if (changed) + osmo_signal_dispatch(SS_DEVICE, S_DEVICE_COUNTER_CHANGE, &m_ctr[chan]); + } // NOTE: Assumes sequential reads @@ -719,9 +730,12 @@ int LMSDevice::writeSamples(std::vector < short *>&bufs, int len, } if (LMS_GetStreamStatus(&m_lms_stream_tx[i], &status) == 0) { - if (status.underrun > m_last_tx_underruns[i]) + if (status.underrun > m_ctr[i].tx_underruns) { *underrun = true; - m_last_tx_underruns[i] = status.underrun; + m_ctr[i].tx_underruns = status.underrun; + osmo_signal_dispatch(SS_DEVICE, S_DEVICE_COUNTER_CHANGE, &m_ctr[i]); + } + } thread_enable_cancel(true); } diff --git a/Transceiver52M/device/lms/LMSDevice.h b/Transceiver52M/device/lms/LMSDevice.h index 2828578..8b5fe93 100644 --- a/Transceiver52M/device/lms/LMSDevice.h +++ b/Transceiver52M/device/lms/LMSDevice.h @@ -49,11 +49,6 @@ private: std::vector<lms_stream_t> m_lms_stream_rx; std::vector<lms_stream_t> m_lms_stream_tx; - std::vector<uint32_t> m_last_rx_underruns; - std::vector<uint32_t> m_last_rx_overruns; - std::vector<uint32_t> m_last_rx_dropped; - std::vector<uint32_t> m_last_tx_underruns; - std::vector<smpl_buf *> rx_buffers; double actualSampleRate; ///< the actual USRP sampling rate |