summaryrefslogtreecommitdiffstats
path: root/src/host/trxcon/sched_lchan_xcch.c
diff options
context:
space:
mode:
authorVadim Yanitskiy <axilirator@gmail.com>2020-03-02 02:55:01 +0700
committerlaforge <laforge@osmocom.org>2020-03-08 22:50:54 +0000
commit2060b5b7cc3b63b64e651d3cda5ed50b44593a05 (patch)
tree754a193733d7132e7f21e31cf4aae2d5552066e6 /src/host/trxcon/sched_lchan_xcch.c
parentd534d43fc16a91ccc36283c72c0f39a3742a307f (diff)
trxcon/scheduler: refactor Downlink measurement processing
So far we used to store the sums of ToA and RSSI measurements in the logical channel state, and after decoding of a block, we did calculate the average. This approach works fine for xCCH and PDTCH, but when it comes to block-diagonal interleaving (which is used on TCH/F and TCH/H channels), the results are incorrect. The problem is that a burst on TCH may carry 57 bits of one encoded frame and 57 bits of another. Instead of calculating the sum of measurements on the fly, let's push them into a circular buffer (the measurement history), and keep them there even after decoding of a block. This would allow us to calculate the average of N last measurements depending on the interleaving type. A single circular buffer can hold up to 8 unique measurements, so the recent measurements would basically override the oldest ones. Change-Id: I211ee3314f0a284112a4deddc0e93028f4a27cef
Diffstat (limited to 'src/host/trxcon/sched_lchan_xcch.c')
-rw-r--r--src/host/trxcon/sched_lchan_xcch.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/host/trxcon/sched_lchan_xcch.c b/src/host/trxcon/sched_lchan_xcch.c
index 34fe5ce8..aa8d4ddd 100644
--- a/src/host/trxcon/sched_lchan_xcch.c
+++ b/src/host/trxcon/sched_lchan_xcch.c
@@ -2,7 +2,7 @@
* OsmocomBB <-> SDR connection bridge
* TDMA scheduler: handlers for DL / UL bursts on logical channels
*
- * (C) 2017 by Vadim Yanitskiy <axilirator@gmail.com>
+ * (C) 2017-2020 by Vadim Yanitskiy <axilirator@gmail.com>
*
* All Rights Reserved
*
@@ -42,7 +42,7 @@
int rx_data_fn(struct trx_instance *trx, struct trx_ts *ts,
struct trx_lchan_state *lchan, uint32_t fn, uint8_t bid,
- sbit_t *bits, int8_t rssi, int16_t toa256)
+ sbit_t *bits, const struct trx_meas_set *meas)
{
const struct trx_lchan_desc *lchan_desc;
uint8_t l2[GSM_MACBLOCK_LEN], *mask;
@@ -61,9 +61,6 @@ int rx_data_fn(struct trx_instance *trx, struct trx_ts *ts,
/* Reset internal state */
if (bid == 0) {
- /* Clean up old measurements */
- memset(&lchan->meas, 0x00, sizeof(lchan->meas));
-
*first_fn = fn;
*mask = 0x0;
}
@@ -71,10 +68,8 @@ int rx_data_fn(struct trx_instance *trx, struct trx_ts *ts,
/* Update mask */
*mask |= (1 << bid);
- /* Update measurements */
- lchan->meas.rssi_sum += rssi;
- lchan->meas.toa256_sum += toa256;
- lchan->meas.num++;
+ /* Store the measurements */
+ sched_trx_meas_push(lchan, meas);
/* Copy burst to buffer of 4 bursts */
offset = buffer + bid * 116;
@@ -85,6 +80,9 @@ int rx_data_fn(struct trx_instance *trx, struct trx_ts *ts,
if (bid != 3)
return 0;
+ /* Calculate AVG of the measurements */
+ sched_trx_meas_avg(lchan, 4);
+
/* Check for complete set of bursts */
if ((*mask & 0xf) != 0xf) {
LOGP(DSCHD, LOGL_ERROR, "Received incomplete (%s) data frame at "