From 2060b5b7cc3b63b64e651d3cda5ed50b44593a05 Mon Sep 17 00:00:00 2001 From: Vadim Yanitskiy Date: Mon, 2 Mar 2020 02:55:01 +0700 Subject: 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 --- src/host/trxcon/trx_if.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/host/trxcon/trx_if.c') diff --git a/src/host/trxcon/trx_if.c b/src/host/trxcon/trx_if.c index 55d70341..343c6ca4 100644 --- a/src/host/trxcon/trx_if.c +++ b/src/host/trxcon/trx_if.c @@ -555,6 +555,7 @@ rsp_error: static int trx_data_rx_cb(struct osmo_fd *ofd, unsigned int what) { struct trx_instance *trx = ofd->data; + struct trx_meas_set meas; uint8_t buf[256]; sbit_t bits[148]; int8_t rssi, tn; @@ -595,8 +596,14 @@ static int trx_data_rx_cb(struct osmo_fd *ofd, unsigned int what) LOGP(DTRXD, LOGL_DEBUG, "RX burst tn=%u fn=%u rssi=%d toa=%d\n", tn, fn, rssi, toa256); + /* Group the measurements together */ + meas = (struct trx_meas_set) { + .toa256 = toa256, + .rssi = rssi, + }; + /* Poke scheduler */ - sched_trx_handle_rx_burst(trx, tn, fn, bits, 148, rssi, toa256); + sched_trx_handle_rx_burst(trx, tn, fn, bits, 148, &meas); /* Correct local clock counter */ if (fn % 51 == 0) -- cgit v1.2.3