From 35f49065f59053364b73f4343103d463ed6ec058 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Sat, 6 Dec 2014 20:30:52 +0100 Subject: power/sysmobts: Add a manual ms power level control Currently the DSP is instructed to achieve a given uplink power target but there are circumstances (e.g. EMV testing) where we need more control over it. The "manual/software/osmo" power control can only be implemented per TRX and not per lchan. Add a very very basic control that checks the MS Power used by the phone, the actual receive level and then adjust the power. The code doesn't take the history into account, if the phone can not reach the requested power level the code will be stuck (e.g. no timeout based on multiframes). It has a mode for a fixed power control but no way to set it yet. The change of the mode requires a restart of the software. Conflicts: include/osmo-bts/bts_model.h src/common/vty.c src/osmo-bts-sysmo/l1_if.c src/osmo-bts-sysmo/l1_if.h src/osmo-bts-sysmo/oml.c tests/sysmobts/sysmobts_test.c --- tests/sysmobts/Makefile.am | 12 ++++++-- tests/sysmobts/sysmobts_test.c | 65 +++++++++++++++++++++++++++++++++++++++++ tests/sysmobts/sysmobts_test.ok | 1 + 3 files changed, 76 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/sysmobts/Makefile.am b/tests/sysmobts/Makefile.am index d884237b..79d13a1e 100644 --- a/tests/sysmobts/Makefile.am +++ b/tests/sysmobts/Makefile.am @@ -5,5 +5,13 @@ LDADD = $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) $(LIBOSMOVTY_LIBS) $(LIBOSMOTRAU_ noinst_PROGRAMS = sysmobts_test EXTRA_DIST = sysmobts_test.ok -sysmobts_test_SOURCES = sysmobts_test.c $(top_srcdir)/src/osmo-bts-sysmo/utils.c -sysmobts_test_LDADD = $(LDADD) +sysmobts_test_SOURCES = sysmobts_test.c $(top_srcdir)/src/osmo-bts-sysmo/utils.c \ + $(top_srcdir)/src/osmo-bts-sysmo/l1_if.c \ + $(top_srcdir)/src/osmo-bts-sysmo/oml.c \ + $(top_srcdir)/src/osmo-bts-sysmo/l1_transp_hw.c \ + $(top_srcdir)/src/osmo-bts-sysmo/tch.c \ + $(top_srcdir)/src/osmo-bts-sysmo/calib_file.c \ + $(top_srcdir)/src/osmo-bts-sysmo/calib_fixup.c \ + $(top_srcdir)/src/osmo-bts-sysmo/misc/sysmobts_par.c \ + $(top_srcdir)/src/osmo-bts-sysmo/eeprom.c +sysmobts_test_LDADD = $(top_builddir)/src/common/libbts.a $(LIBOSMOABIS_LIBS) $(LDADD) diff --git a/tests/sysmobts/sysmobts_test.c b/tests/sysmobts/sysmobts_test.c index 291f6da8..5f8d7133 100644 --- a/tests/sysmobts/sysmobts_test.c +++ b/tests/sysmobts/sysmobts_test.c @@ -125,9 +125,74 @@ static void test_sysmobts_auto_band(void) } } +static void test_sysmobts_loop(void) +{ + struct gsm_bts bts; + struct gsm_bts_trx trx; + struct gsm_bts_trx_ts ts; + struct gsm_lchan *lchan; + int ret; + + memset(&bts, 0, sizeof(bts)); + memset(&trx, 0, sizeof(trx)); + memset(&ts, 0, sizeof(ts)); + + lchan = &ts.lchan[0]; + lchan->ts = &ts; + ts.trx = &trx; + trx.bts = &bts; + bts.band = GSM_BAND_1800; + trx.ms_power_control = 1; + + printf("Testing sysmobts power control\n"); + + /* Simply clamping */ + lchan->state = LCHAN_S_NONE; + lchan->ms_power_ctrl.current = ms_pwr_ctl_lvl(GSM_BAND_1800, 0); + OSMO_ASSERT(lchan->ms_power_ctrl.current == 15); + ret = l1if_ms_pwr_ctrl(lchan, -75, lchan->ms_power_ctrl.current, -60); + OSMO_ASSERT(ret == 0); + OSMO_ASSERT(lchan->ms_power_ctrl.current == 15); + + + /* + * Now 15 dB too little and we should power it up. Could be a + * power level of 7 or 8 for 15 dBm + */ + ret = l1if_ms_pwr_ctrl(lchan, -75, lchan->ms_power_ctrl.current, -90); + OSMO_ASSERT(ret == 1); + OSMO_ASSERT(lchan->ms_power_ctrl.current == 7); + + /* It should be clamped to level 0 and 30 dBm */ + ret = l1if_ms_pwr_ctrl(lchan, -75, lchan->ms_power_ctrl.current, -100); + OSMO_ASSERT(ret == 1); + OSMO_ASSERT(lchan->ms_power_ctrl.current == 0); + + /* Fix it and jump down */ + lchan->ms_power_ctrl.fixed = 1; + ret = l1if_ms_pwr_ctrl(lchan, -75, lchan->ms_power_ctrl.current, -60); + OSMO_ASSERT(ret == 0); + OSMO_ASSERT(lchan->ms_power_ctrl.current == 0); + + /* And leave it again */ + lchan->ms_power_ctrl.fixed = 0; + ret = l1if_ms_pwr_ctrl(lchan, -75, lchan->ms_power_ctrl.current, -40); + OSMO_ASSERT(ret == 1); + OSMO_ASSERT(lchan->ms_power_ctrl.current == 15); +} + int main(int argc, char **argv) { printf("Testing sysmobts routines\n"); test_sysmobts_auto_band(); + test_sysmobts_loop(); return 0; } + +int pcu_direct = 0; +int bts_model_init(struct gsm_bts *bts) +{ return 0; } +void bts_update_status(enum bts_global_status which, int on) +{ } +int bts_model_oml_estab(struct gsm_bts *bts) +{ return 0; } diff --git a/tests/sysmobts/sysmobts_test.ok b/tests/sysmobts/sysmobts_test.ok index 1f534172..07d79fd3 100644 --- a/tests/sysmobts/sysmobts_test.ok +++ b/tests/sysmobts/sysmobts_test.ok @@ -17,3 +17,4 @@ Checking PCS to PCS PCS to PCS band(1) arfcn(512) want(3) got(3) PCS to PCS band(8) arfcn(128) want(0) got(0) PCS to PCS band(2) arfcn(438) want(-1) got(-1) +Testing sysmobts power control -- cgit v1.2.3