aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPhilipp Maier <pmaier@sysmocom.de>2020-01-15 11:01:24 +0100
committerlaforge <laforge@osmocom.org>2020-01-20 14:33:49 +0000
commita0403d3769d3027639e35874c09808ce5c0ba860 (patch)
tree2cce8edf58ad8fd11864475886b5028d4d0e1570 /src
parente7d835ca8c704f7cd256702a31a15b79824e21a4 (diff)
ta_control: move timing advance code from osmo-bts-trx to common
The timing advance controller that is implemented in loops.c of osmo-bts-trx only works for osmo-bts-trx and not for any of the phy based bts. Lets move the timing advance controller into the common part and make it available for every bts. Also lets add a unit-test. Change-Id: If7ddf74db3abc9b9872abe620a0aeebe3327e70a Related: SYS#4567
Diffstat (limited to 'src')
-rw-r--r--src/common/Makefile.am2
-rw-r--r--src/common/measurement.c6
-rw-r--r--src/common/ta_control.c55
-rw-r--r--src/osmo-bts-trx/loops.c57
-rw-r--r--src/osmo-bts-trx/loops.h3
-rw-r--r--src/osmo-bts-trx/main.c1
-rw-r--r--src/osmo-bts-trx/scheduler_trx.c6
-rw-r--r--src/osmo-bts-trx/trx_vty.c14
8 files changed, 66 insertions, 78 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);
+}
diff --git a/src/osmo-bts-trx/loops.c b/src/osmo-bts-trx/loops.c
index eb25f64e..823c2d7d 100644
--- a/src/osmo-bts-trx/loops.c
+++ b/src/osmo-bts-trx/loops.c
@@ -35,63 +35,6 @@
#include "l1_if.h"
#include "loops.h"
-/*
- * Timing Advance loop
- */
-
-/* 90% of one bit duration in 1/256 symbols: 256*0.9 */
-#define TOA256_9OPERCENT 230
-
-void ta_val(struct gsm_lchan *lchan, struct l1sched_chan_state *chan_state, int16_t toa256)
-{
- /* check if the current L1 header acks to the current ordered TA */
- if (lchan->meas.l1_info[1] != lchan->rqd_ta)
- return;
-
- /* sum measurement */
- chan_state->meas.toa256_sum += toa256;
- if (++(chan_state->meas.toa_num) < 16)
- return;
-
- /* complete set */
- toa256 = chan_state->meas.toa256_sum / chan_state->meas.toa_num;
-
- /* check for change of TOA */
- if (toa256 < -TOA256_9OPERCENT && lchan->rqd_ta > 0) {
- 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 < 63) {
- 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_INFO, "TOA is correct (%d), keeping current TA of %d\n",
- toa256, lchan->rqd_ta);
-
- chan_state->meas.toa_num = 0;
- chan_state->meas.toa256_sum = 0;
-}
-
-/*! Process a SACCH event as input to the MS power control and TA loop. Function
- * is called once every uplink SACCH block is received.
- * \param l1t L1 TRX instance on which we operate
- * \param chan_nr RSL channel number on which we operate
- * \param chan_state L1 scheduler channel state of the channel on which we operate
- * \param[in] rssi Receive Signal Strength Indication
- * \param[in] toa256 Time of Arrival in 1/256 symbol periods */
-void trx_loop_sacch_input(struct l1sched_trx *l1t, uint8_t chan_nr,
- struct l1sched_chan_state *chan_state, int16_t toa256)
-{
- struct gsm_lchan *lchan = &l1t->trx->ts[L1SAP_CHAN2TS(chan_nr)]
- .lchan[l1sap_chan2ss(chan_nr)];
- struct phy_instance *pinst = trx_phy_instance(l1t->trx);
-
- /* if TA loop is enabled, handle it */
- if (pinst->phy_link->u.osmotrx.trx_ta_loop)
- ta_val(lchan, chan_state, toa256);
-}
-
void trx_loop_amr_input(struct l1sched_trx *l1t, uint8_t chan_nr,
struct l1sched_chan_state *chan_state,
int n_errors, int n_bits_total)
diff --git a/src/osmo-bts-trx/loops.h b/src/osmo-bts-trx/loops.h
index bc87860f..13849603 100644
--- a/src/osmo-bts-trx/loops.h
+++ b/src/osmo-bts-trx/loops.h
@@ -11,9 +11,6 @@
* loops api
*/
-void trx_loop_sacch_input(struct l1sched_trx *l1t, uint8_t chan_nr,
- struct l1sched_chan_state *chan_state, int16_t toa);
-
void trx_loop_amr_input(struct l1sched_trx *l1t, uint8_t chan_nr,
struct l1sched_chan_state *chan_state,
int n_errors, int n_bits_total);
diff --git a/src/osmo-bts-trx/main.c b/src/osmo-bts-trx/main.c
index 00280ceb..6671243f 100644
--- a/src/osmo-bts-trx/main.c
+++ b/src/osmo-bts-trx/main.c
@@ -135,7 +135,6 @@ void bts_model_phy_link_set_defaults(struct phy_link *plink)
plink->u.osmotrx.base_port_remote = 5700;
plink->u.osmotrx.clock_advance = 20;
plink->u.osmotrx.rts_advance = 5;
- plink->u.osmotrx.trx_ta_loop = true;
/* attempt use newest TRXD version by default: */
plink->u.osmotrx.trxd_hdr_ver_max = TRX_DATA_FORMAT_VER;
}
diff --git a/src/osmo-bts-trx/scheduler_trx.c b/src/osmo-bts-trx/scheduler_trx.c
index 2785d097..20d502f0 100644
--- a/src/osmo-bts-trx/scheduler_trx.c
+++ b/src/osmo-bts-trx/scheduler_trx.c
@@ -954,12 +954,6 @@ int rx_data_fn(struct l1sched_trx *l1t, enum trx_chan_type chan,
} else
memset(burst, 0, 58 * 2);
- /* send burst information to loops process */
- if (L1SAP_IS_LINK_SACCH(trx_chan_desc[chan].link_id)) {
- trx_loop_sacch_input(l1t, trx_chan_desc[chan].chan_nr | bi->tn,
- chan_state, bi->toa256);
- }
-
/* wait until complete set of bursts */
if (bid != 3)
return 0;
diff --git a/src/osmo-bts-trx/trx_vty.c b/src/osmo-bts-trx/trx_vty.c
index 5c5e477c..9c67a7f0 100644
--- a/src/osmo-bts-trx/trx_vty.c
+++ b/src/osmo-bts-trx/trx_vty.c
@@ -181,23 +181,19 @@ DEFUN_DEPRECATED(cfg_phy_no_ms_power_loop, cfg_phy_no_ms_power_loop_cmd,
return CMD_SUCCESS;
}
-DEFUN(cfg_phy_timing_advance_loop, cfg_phy_timing_advance_loop_cmd,
+DEFUN_DEPRECATED(cfg_phy_timing_advance_loop, cfg_phy_timing_advance_loop_cmd,
"osmotrx timing-advance-loop", OSMOTRX_STR
"Enable timing advance control loop\n")
{
- struct phy_link *plink = vty->index;
-
- plink->u.osmotrx.trx_ta_loop = true;
+ vty_out (vty, "'osmotrx timing-advance-loop' is deprecated, ta control is now active by default%s", VTY_NEWLINE);
return CMD_SUCCESS;
}
-DEFUN(cfg_phy_no_timing_advance_loop, cfg_phy_no_timing_advance_loop_cmd,
+DEFUN_DEPRECATED(cfg_phy_no_timing_advance_loop, cfg_phy_no_timing_advance_loop_cmd,
"no osmotrx timing-advance-loop",
NO_STR OSMOTRX_STR "Disable timing advance control loop\n")
{
- struct phy_link *plink = vty->index;
-
- plink->u.osmotrx.trx_ta_loop = false;
+ vty_out (vty, "'no osmotrx timing-advance-loop' is deprecated, ta control is now active by default%s", VTY_NEWLINE);
return CMD_SUCCESS;
}
@@ -522,8 +518,6 @@ void bts_model_config_write_phy(struct vty *vty, struct phy_link *plink)
vty_out(vty, " osmotrx ip remote %s%s",
plink->u.osmotrx.remote_ip, VTY_NEWLINE);
- vty_out(vty, " %sosmotrx timing-advance-loop%s", (plink->u.osmotrx.trx_ta_loop) ? "" : "no ", VTY_NEWLINE);
-
if (plink->u.osmotrx.base_port_local)
vty_out(vty, " osmotrx base-port local %"PRIu16"%s",
plink->u.osmotrx.base_port_local, VTY_NEWLINE);