aboutsummaryrefslogtreecommitdiffstats
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rw-r--r--src/common/Makefile.am2
-rw-r--r--src/common/measurement.c6
-rw-r--r--src/common/ta_control.c55
3 files changed, 62 insertions, 1 deletions
diff --git a/src/common/Makefile.am b/src/common/Makefile.am
index 113ff2f4..0a10abf7 100644
--- a/src/common/Makefile.am
+++ b/src/common/Makefile.am
@@ -12,6 +12,6 @@ libbts_a_SOURCES = gsm_data_shared.c sysinfo.c logging.c abis.c oml.c bts.c \
load_indication.c pcu_sock.c handover.c msg_utils.c \
tx_power.c bts_ctrl_commands.c bts_ctrl_lookup.c \
l1sap.c cbch.c power_control.c main.c phy_link.c \
- dtx_dl_amr_fsm.c scheduler_mframe.c
+ dtx_dl_amr_fsm.c scheduler_mframe.c ta_control.c
libl1sched_a_SOURCES = scheduler.c
diff --git a/src/common/measurement.c b/src/common/measurement.c
index 3e0daf19..ddc17474 100644
--- a/src/common/measurement.c
+++ b/src/common/measurement.c
@@ -10,6 +10,7 @@
#include <osmo-bts/measurement.h>
#include <osmo-bts/scheduler.h>
#include <osmo-bts/rsl.h>
+#include <osmo-bts/ta_control.h>
/* Tables as per TS 45.008 Section 8.3 */
static const uint8_t ts45008_83_tch_f[] = { 52, 53, 54, 55, 56, 57, 58, 59 };
@@ -696,6 +697,11 @@ int lchan_meas_check_compute(struct gsm_lchan *lchan, uint32_t fn)
lchan_meas_compute_extended(lchan);
+ /* Compute new ta_req value. This has to be done here since the value
+ * in lchan->meas.num_ul_meas together with lchan->meas.ms_toa256
+ * is needed for the computation. */
+ lchan_ms_ta_ctrl(lchan);
+
lchan->meas.num_ul_meas = 0;
/* return 1 to indicate that the computation has been done and the next
diff --git a/src/common/ta_control.c b/src/common/ta_control.c
new file mode 100644
index 00000000..2ccc41a8
--- /dev/null
+++ b/src/common/ta_control.c
@@ -0,0 +1,55 @@
+/* Loop control for Timing Advance */
+
+/* (C) 2013 by Andreas Eversberg <jolly@eversberg.eu>
+ *
+ * All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include <osmo-bts/gsm_data.h>
+#include <osmo-bts/logging.h>
+
+/* 90% of one bit duration in 1/256 symbols: 256*0.9 */
+#define TOA256_9OPERCENT 230
+
+/* rqd_ta value range */
+#define TOA_MIN 0
+#define TOA_MAX 63
+
+void lchan_ms_ta_ctrl(struct gsm_lchan *lchan)
+{
+ int16_t toa256 = lchan->meas.ms_toa256;
+
+ /* Do not perform any computation when the amount of measurement
+ * results is too little. */
+ if (lchan->meas.num_ul_meas < 4)
+ return;
+
+ if (toa256 < -TOA256_9OPERCENT && lchan->rqd_ta > TOA_MIN) {
+ LOGPLCHAN(lchan, DLOOP, LOGL_INFO,
+ "TOA is too early (%d), now lowering TA from %d to %d\n",
+ toa256, lchan->rqd_ta, lchan->rqd_ta - 1);
+ lchan->rqd_ta--;
+ } else if (toa256 > TOA256_9OPERCENT && lchan->rqd_ta < TOA_MAX) {
+ LOGPLCHAN(lchan, DLOOP, LOGL_INFO,
+ "TOA is too late (%d), now raising TA from %d to %d\n",
+ toa256, lchan->rqd_ta, lchan->rqd_ta + 1);
+ lchan->rqd_ta++;
+ } else
+ LOGPLCHAN(lchan, DLOOP, LOGL_DEBUG,
+ "TOA is correct (%d), keeping current TA of %d\n",
+ toa256, lchan->rqd_ta);
+}