Change in ...osmo-trx[master]: lms: Drop rx_underruns rate ctr, add tx_drop_* rate ctr

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

pespin gerrit-no-reply at lists.osmocom.org
Mon Jul 29 19:07:43 UTC 2019


pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-trx/+/14989


Change subject: lms: Drop rx_underruns rate ctr, add tx_drop_* rate ctr
......................................................................

lms: Drop rx_underruns rate ctr, add tx_drop_* rate ctr

After discussion in [1] and further look at the code, it became obvios
rx_underrun events are not happening in general for any SDR (don't
exist), so let's drop that counter. Instead, add Tx Dropped Packet counters,
which were not accounted prior to this commit.

[1] https://github.com/osmocom/osmo-trx/commit/bde55afd29fc9aae10eb11f6515821afa39b772d

Change-Id: Iff1535c219a4695a511d383d7c4b06ef6eff959d
---
M CommonLibs/osmo_signal.h
M CommonLibs/trx_rate_ctr.cpp
M CommonLibs/trx_rate_ctr.h
M CommonLibs/trx_vty.c
M Transceiver52M/device/lms/LMSDevice.cpp
M Transceiver52M/device/lms/LMSDevice.h
6 files changed, 80 insertions(+), 40 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-trx refs/changes/89/14989/1

diff --git a/CommonLibs/osmo_signal.h b/CommonLibs/osmo_signal.h
index ee7e2a4..ceb7d6f 100644
--- a/CommonLibs/osmo_signal.h
+++ b/CommonLibs/osmo_signal.h
@@ -48,9 +48,10 @@
 /* signal cb for signal <SS_DEVICE,S_DEVICE_COUNTER_CHANGE> */
 struct device_counters {
 	size_t chan;
-	unsigned int rx_underruns;
 	unsigned int rx_overruns;
 	unsigned int tx_underruns;
 	unsigned int rx_dropped_events;
 	unsigned int rx_dropped_samples;
+	unsigned int tx_dropped_events;
+	unsigned int tx_dropped_samples;
 };
diff --git a/CommonLibs/trx_rate_ctr.cpp b/CommonLibs/trx_rate_ctr.cpp
index 43e4189..a9ef88c 100644
--- a/CommonLibs/trx_rate_ctr.cpp
+++ b/CommonLibs/trx_rate_ctr.cpp
@@ -93,20 +93,22 @@
 };
 
 const struct value_string trx_chan_ctr_names[] = {
-	{ TRX_CTR_RX_UNDERRUNS,	"rx_underruns" },
 	{ TRX_CTR_RX_OVERRUNS,	"rx_overruns" },
 	{ TRX_CTR_TX_UNDERRUNS,	"tx_underruns" },
 	{ TRX_CTR_RX_DROP_EV,	"rx_drop_events" },
 	{ TRX_CTR_RX_DROP_SMPL,	"rx_drop_samples" },
+	{ TRX_CTR_TX_DROP_EV,	"tx_drop_events" },
+	{ TRX_CTR_TX_DROP_SMPL,	"tx_drop_samples" },
 	{ 0, NULL }
 };
 
 static const struct rate_ctr_desc trx_chan_ctr_desc[] = {
-	[TRX_CTR_RX_UNDERRUNS]		= { "device:rx_underruns",	"Number of Rx underruns" },
-	[TRX_CTR_RX_OVERRUNS]		= { "device:rx_overruns",	"Number of Rx overruns" },
-	[TRX_CTR_TX_UNDERRUNS]		= { "device:tx_underruns",	"Number of Tx underruns" },
+	[TRX_CTR_RX_OVERRUNS]		= { "device:rx_overruns",	"Number of Rx overruns in FIFO queue" },
+	[TRX_CTR_TX_UNDERRUNS]		= { "device:tx_underruns",	"Number of Tx underruns in FIFO queue" },
 	[TRX_CTR_RX_DROP_EV]		= { "device:rx_drop_events",	"Number of times Rx samples were dropped by HW" },
 	[TRX_CTR_RX_DROP_SMPL]		= { "device:rx_drop_samples",	"Number of Rx samples dropped by HW" },
+	[TRX_CTR_TX_DROP_EV]		= { "device:tx_drop_events",	"Number of times Tx samples were dropped by HW" },
+	[TRX_CTR_TX_DROP_SMPL]		= { "device:tx_drop_samples",	"Number of Tx samples dropped by HW" }
 };
 
 static const struct rate_ctr_group_desc trx_chan_ctr_group_desc = {
@@ -126,8 +128,6 @@
 		if (ctrs_pending[chan].chan == PENDING_CHAN_NONE)
 			continue;
 		LOGCHAN(chan, DMAIN, INFO) << "rate_ctr update";
-		ctr = &rate_ctrs[chan]->ctr[TRX_CTR_RX_UNDERRUNS];
-		rate_ctr_add(ctr, ctrs_pending[chan].rx_underruns - ctr->current);
 		ctr = &rate_ctrs[chan]->ctr[TRX_CTR_RX_OVERRUNS];
 		rate_ctr_add(ctr, ctrs_pending[chan].rx_overruns - ctr->current);
 		ctr = &rate_ctrs[chan]->ctr[TRX_CTR_TX_UNDERRUNS];
@@ -136,6 +136,10 @@
 		rate_ctr_add(ctr, ctrs_pending[chan].rx_dropped_events - ctr->current);
 		ctr = &rate_ctrs[chan]->ctr[TRX_CTR_RX_DROP_SMPL];
 		rate_ctr_add(ctr, ctrs_pending[chan].rx_dropped_samples - ctr->current);
+		ctr = &rate_ctrs[chan]->ctr[TRX_CTR_TX_DROP_EV];
+		rate_ctr_add(ctr, ctrs_pending[chan].tx_dropped_events - ctr->current);
+		ctr = &rate_ctrs[chan]->ctr[TRX_CTR_TX_DROP_SMPL];
+		rate_ctr_add(ctr, ctrs_pending[chan].tx_dropped_samples - ctr->current);
 
 		/* Mark as done */
 		ctrs_pending[chan].chan = PENDING_CHAN_NONE;
diff --git a/CommonLibs/trx_rate_ctr.h b/CommonLibs/trx_rate_ctr.h
index 6e4fa4d..155f413 100644
--- a/CommonLibs/trx_rate_ctr.h
+++ b/CommonLibs/trx_rate_ctr.h
@@ -4,11 +4,12 @@
 #include <osmocom/vty/command.h>
 
 enum TrxCtr {
-	TRX_CTR_RX_UNDERRUNS,
 	TRX_CTR_RX_OVERRUNS,
 	TRX_CTR_TX_UNDERRUNS,
 	TRX_CTR_RX_DROP_EV,
 	TRX_CTR_RX_DROP_SMPL,
+	TRX_CTR_TX_DROP_EV,
+	TRX_CTR_TX_DROP_SMPL,
 };
 
 struct ctr_threshold {
diff --git a/CommonLibs/trx_vty.c b/CommonLibs/trx_vty.c
index e184f49..bac9653 100644
--- a/CommonLibs/trx_vty.c
+++ b/CommonLibs/trx_vty.c
@@ -384,14 +384,15 @@
 	return -1;
 }
 
-#define THRESHOLD_ARGS "(rx_underruns|rx_overruns|tx_underruns|rx_drop_events|rx_drop_samples)"
+#define THRESHOLD_ARGS "(rx_overruns|tx_underruns|rx_drop_events|rx_drop_samples|tx_drop_events|tx_drop_samples)"
 #define THRESHOLD_STR_VAL(s) "Set threshold value for rate_ctr device:" OSMO_STRINGIFY_VAL(s) "\n"
 #define THRESHOLD_STRS \
-	THRESHOLD_STR_VAL(rx_underruns) \
 	THRESHOLD_STR_VAL(rx_overruns) \
 	THRESHOLD_STR_VAL(tx_underruns) \
 	THRESHOLD_STR_VAL(rx_drop_events) \
-	THRESHOLD_STR_VAL(rx_drop_samples)
+	THRESHOLD_STR_VAL(rx_drop_samples) \
+	THRESHOLD_STR_VAL(tx_drop_events) \
+	THRESHOLD_STR_VAL(tx_drop_samples)
 #define INTV_ARGS "(per-second|per-minute|per-hour|per-day)"
 #define INTV_STR_VAL(s) "Threshold value sampled " OSMO_STRINGIFY_VAL(s) "\n"
 #define INTV_STRS \
diff --git a/Transceiver52M/device/lms/LMSDevice.cpp b/Transceiver52M/device/lms/LMSDevice.cpp
index 0eaf0a3..e027050 100644
--- a/Transceiver52M/device/lms/LMSDevice.cpp
+++ b/Transceiver52M/device/lms/LMSDevice.cpp
@@ -574,38 +574,37 @@
 	/* UNUSED on limesdr (only used on usrp1/2) */
 	return GSM::Time(0,0);
 }
-
-void LMSDevice::update_stream_stats(size_t chan, bool * underrun, bool * overrun)
+/*!
+ * Issue tracking description of several events: https://github.com/myriadrf/LimeSuite/issues/265
+ */
+void LMSDevice::update_stream_stats_rx(size_t chan, bool *overrun)
 {
 	lms_stream_status_t status;
 	bool changed = false;
 
 	if (LMS_GetStreamStatus(&m_lms_stream_rx[chan], &status) != 0) {
-		LOGCHAN(chan, DDEV, ERROR) << "LMS_GetStreamStatus failed";
+		LOGCHAN(chan, DDEV, ERROR) << "Rx LMS_GetStreamStatus failed";
 		return;
 	}
 
-	if (status.underrun) {
-		changed = true;
-		*underrun = true;
-		LOGCHAN(chan, DDEV, ERROR) << "recv Underrun! ("
-					   << m_ctr[chan].rx_underruns << " -> "
-					   << status.underrun << ")";
-	}
-	m_ctr[chan].rx_underruns += status.underrun;
-
+	/* FIFO overrun is counted when Rx FIFO is full but new data comes from
+	   the board and oldest samples in FIFO are overwritte. Value count
+	   since the last call to LMS_GetStreamStatus(stream). */
 	if (status.overrun) {
 		changed = true;
 		*overrun = true;
-		LOGCHAN(chan, DDEV, ERROR) << "recv Overrun! ("
+		LOGCHAN(chan, DDEV, ERROR) << "Rx Overrun! ("
 					   << m_ctr[chan].rx_overruns << " -> "
 					   << status.overrun << ")";
 	}
 	m_ctr[chan].rx_overruns += status.overrun;
 
+	/* Dropped packets in Rx are counted when gaps in Rx timestamps are
+	   detected (likely because buffer oveflow in hardware). Value count
+	   since the last call to LMS_GetStreamStatus(stream). */
 	if (status.droppedPackets) {
 		changed = true;
-		LOGCHAN(chan, DDEV, ERROR) << "recv Dropped packets by HW! ("
+		LOGCHAN(chan, DDEV, ERROR) << "Rx Dropped packets by HW! ("
 					   << m_ctr[chan].rx_dropped_samples << " -> "
 					   << m_ctr[chan].rx_dropped_samples +
 					      status.droppedPackets
@@ -653,7 +652,7 @@
 		while ((avail_smpls = rx_buffers[i]->avail_smpls(timestamp)) < len) {
 			thread_enable_cancel(false);
 			num_smpls = LMS_RecvStream(&m_lms_stream_rx[i], bufs[i], len - avail_smpls, &rx_metadata, 100);
-			update_stream_stats(i, underrun, overrun);
+			update_stream_stats_rx(i, overrun);
 			thread_enable_cancel(true);
 			if (num_smpls <= 0) {
 				LOGCHAN(i, DDEV, ERROR) << "Device receive timed out (" << rc << " vs exp " << len << ").";
@@ -697,13 +696,53 @@
 	return len;
 }
 
+void LMSDevice::update_stream_stats_tx(size_t chan, bool *underrun)
+{
+	lms_stream_status_t status;
+	bool changed = false;
+
+	if (LMS_GetStreamStatus(&m_lms_stream_tx[chan], &status) != 0) {
+		LOGCHAN(chan, DDEV, ERROR) << "Tx LMS_GetStreamStatus failed";
+		return;
+	}
+
+	/* FIFO underrun is counted when Tx is running but FIFO is empty for
+	   >100 ms (500ms in older versions). Value count since the last call to
+	   LMS_GetStreamStatus(stream). */
+	if (status.underrun) {
+		changed = true;
+		*underrun = true;
+		LOGCHAN(chan, DDEV, ERROR) << "Tx Underrun! ("
+					   << m_ctr[chan].tx_underruns << " -> "
+					   << status.underrun << ")";
+	}
+	m_ctr[chan].tx_underruns += status.underrun;
+
+	/* Dropped packets in Tx are counted only when timestamps are enabled
+	   and SDR drops packet because of late timestamp. Value count since the
+	   last call to LMS_GetStreamStatus(stream). */
+	if (status.droppedPackets) {
+		changed = true;
+		LOGCHAN(chan, DDEV, ERROR) << "Tx Dropped packets by HW! ("
+					   << m_ctr[chan].tx_dropped_samples << " -> "
+					   << m_ctr[chan].tx_dropped_samples +
+					      status.droppedPackets
+					   << ")";
+		m_ctr[chan].tx_dropped_events++;
+	}
+	m_ctr[chan].tx_dropped_samples += status.droppedPackets;
+
+	if (changed)
+		osmo_signal_dispatch(SS_DEVICE, S_DEVICE_COUNTER_CHANGE, &m_ctr[chan]);
+
+}
+
 int LMSDevice::writeSamples(std::vector < short *>&bufs, int len,
 			    bool * underrun, unsigned long long timestamp,
 			    bool isControl)
 {
 	int rc = 0;
 	unsigned int i;
-	lms_stream_status_t status;
 	lms_stream_meta_t tx_metadata = {};
 	tx_metadata.flushPartialPacket = false;
 	tx_metadata.waitForTimestamp = true;
@@ -725,19 +764,12 @@
 		LOGCHAN(i, DDEV, DEBUG) << "send buffer of len " << len << " timestamp " << std::hex << tx_metadata.timestamp;
 		thread_enable_cancel(false);
 		rc = LMS_SendStream(&m_lms_stream_tx[i], bufs[i], len, &tx_metadata, 100);
-		if (rc != len) {
-			LOGCHAN(i, DDEV, ERROR) << "LMS: Device send timed out";
-		}
-
-		if (LMS_GetStreamStatus(&m_lms_stream_tx[i], &status) == 0) {
-			if (status.underrun > m_ctr[i].tx_underruns) {
-				*underrun = true;
-				m_ctr[i].tx_underruns = status.underrun;
-				osmo_signal_dispatch(SS_DEVICE, S_DEVICE_COUNTER_CHANGE, &m_ctr[i]);
-			}
-
-		}
+		update_stream_stats_rx(i, underrun);
 		thread_enable_cancel(true);
+		if (rc != len) {
+			LOGCHAN(i, DDEV, ERROR) << "LMS: Device Tx timed out (" << rc << " vs exp " << len << ").";
+			return -1;
+		}
 	}
 
 	return rc;
diff --git a/Transceiver52M/device/lms/LMSDevice.h b/Transceiver52M/device/lms/LMSDevice.h
index 906fbee..bc79f97 100644
--- a/Transceiver52M/device/lms/LMSDevice.h
+++ b/Transceiver52M/device/lms/LMSDevice.h
@@ -65,7 +65,8 @@
 	bool do_filters(size_t chan);
 	int get_ant_idx(const std::string & name, bool dir_tx, size_t chan);
 	bool flush_recv(size_t num_pkts);
-	void update_stream_stats(size_t chan, bool * underrun, bool * overrun);
+	void update_stream_stats_rx(size_t chan, bool *overrun);
+	void update_stream_stats_tx(size_t chan, bool *underrun);
 
 public:
 

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-trx/+/14989
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-Change-Id: Iff1535c219a4695a511d383d7c4b06ef6eff959d
Gerrit-Change-Number: 14989
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190729/32e46771/attachment.htm>


More information about the gerrit-log mailing list