diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/osmo-bts-sysmo/Makefile.am | 4 | ||||
-rw-r--r-- | src/osmo-bts-sysmo/oml.c | 19 | ||||
-rw-r--r-- | src/osmo-bts-sysmo/sysmobts_vty.c | 31 | ||||
-rw-r--r-- | src/osmo-bts-sysmo/utils.c | 87 | ||||
-rw-r--r-- | src/osmo-bts-sysmo/utils.h | 10 |
5 files changed, 131 insertions, 20 deletions
diff --git a/src/osmo-bts-sysmo/Makefile.am b/src/osmo-bts-sysmo/Makefile.am index e3a33379..80deed29 100644 --- a/src/osmo-bts-sysmo/Makefile.am +++ b/src/osmo-bts-sysmo/Makefile.am @@ -4,12 +4,12 @@ LDADD = $(LIBOSMOVTY_LIBS) $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) $(LIBOSMOTRAU_ EXTRA_DIST = misc/sysmobts_mgr.h misc/sysmobts_misc.h misc/sysmobts_par.h \ misc/sysmobts_eeprom.h femtobts.h hw_misc.h l1_fwd.h l1_if.h \ - l1_transp.h eeprom.h + l1_transp.h eeprom.h utils.h bin_PROGRAMS = sysmobts sysmobts-remote l1fwd-proxy sysmobts-mgr COMMON_SOURCES = main.c femtobts.c l1_if.c oml.c sysmobts_vty.c tch.c hw_misc.c calib_file.c \ - eeprom.c calib_fixup.c + eeprom.c calib_fixup.c utils.c sysmobts_SOURCES = $(COMMON_SOURCES) l1_transp_hw.c sysmobts_LDADD = $(top_builddir)/src/common/libbts.a $(LDADD) diff --git a/src/osmo-bts-sysmo/oml.c b/src/osmo-bts-sysmo/oml.c index b8c9cd2d..1a15d555 100644 --- a/src/osmo-bts-sysmo/oml.c +++ b/src/osmo-bts-sysmo/oml.c @@ -38,6 +38,7 @@ #include "l1_if.h" #include "femtobts.h" +#include "utils.h" enum sapi_cmd_type { SAPI_CMD_ACTIVATE, @@ -68,22 +69,6 @@ static const enum GsmL1_LogChComb_t pchan_to_logChComb[_GSM_PCHAN_MAX] = { [GSM_PCHAN_UNKNOWN] = GsmL1_LogChComb_0, }; -static int band_osmo2femto(enum gsm_band osmo_band) -{ - switch (osmo_band) { - case GSM_BAND_850: - return GsmL1_FreqBand_850; - case GSM_BAND_900: - return GsmL1_FreqBand_900; - case GSM_BAND_1800: - return GsmL1_FreqBand_1800; - case GSM_BAND_1900: - return GsmL1_FreqBand_1900; - default: - return -1; - } -} - static void *prim_init(GsmL1_Prim_t *prim, GsmL1_PrimId_t id, struct femtol1_hdl *gl1) { prim->id = id; @@ -292,7 +277,7 @@ static int trx_init(struct gsm_bts_trx *trx) //return oml_mo_opstart_nack(&trx->mo, NM_NACK_CANT_PERFORM); } - femto_band = band_osmo2femto(trx->bts->band); + femto_band = sysmobts_select_femto_band(trx->bts, trx->arfcn); if (femto_band < 0) { LOGP(DL1C, LOGL_ERROR, "Unsupported GSM band %s\n", gsm_band_name(trx->bts->band)); diff --git a/src/osmo-bts-sysmo/sysmobts_vty.c b/src/osmo-bts-sysmo/sysmobts_vty.c index 4993c51d..558dcd97 100644 --- a/src/osmo-bts-sysmo/sysmobts_vty.c +++ b/src/osmo-bts-sysmo/sysmobts_vty.c @@ -1,7 +1,7 @@ /* VTY interface for sysmoBTS */ /* (C) 2011 by Harald Welte <laforge@gnumonks.org> - * (C) 2012 by Holger Hans Peter Freyther + * (C) 2012,2013 by Holger Hans Peter Freyther * * All Rights Reserved * @@ -57,6 +57,28 @@ static struct gsm_bts *vty_bts; /* configuration */ +DEFUN(cfg_bts_auto_band, cfg_bts_auto_band_cmd, + "auto-band", + "Automatically select band for ARFCN based on configured band\n") +{ + struct gsm_bts *bts = vty->index; + struct gsm_bts_role_bts *btsb = bts_role_bts(bts); + + btsb->auto_band = 1; + return CMD_SUCCESS; +} + +DEFUN(cfg_bts_no_auto_band, cfg_bts_no_auto_band_cmd, + "no auto-band", + NO_STR "Automatically select band for ARFCN based on configured band\n") +{ + struct gsm_bts *bts = vty->index; + struct gsm_bts_role_bts *btsb = bts_role_bts(bts); + + btsb->auto_band = 0; + return CMD_SUCCESS; +} + DEFUN(cfg_trx_gsmtap_sapi, cfg_trx_gsmtap_sapi_cmd, "HIDDEN", "HIDDEN") { @@ -412,6 +434,10 @@ DEFUN(no_loopback, no_loopback_cmd, void bts_model_config_write_bts(struct vty *vty, struct gsm_bts *bts) { + struct gsm_bts_role_bts *btsb = bts_role_bts(bts); + + if (btsb->auto_band) + vty_out(vty, " auto-band%s", VTY_NEWLINE); } /* FIXME: move to libosmocore ? */ @@ -515,6 +541,9 @@ int bts_model_vty_init(struct gsm_bts *bts) install_element(ENABLE_NODE, &loopback_cmd); install_element(ENABLE_NODE, &no_loopback_cmd); + install_element(BTS_NODE, &cfg_bts_auto_band_cmd); + install_element(BTS_NODE, &cfg_bts_no_auto_band_cmd); + install_element(TRX_NODE, &cfg_trx_clkcal_cmd); install_element(TRX_NODE, &cfg_trx_clkcal_def_cmd); install_element(TRX_NODE, &cfg_trx_clksrc_cmd); diff --git a/src/osmo-bts-sysmo/utils.c b/src/osmo-bts-sysmo/utils.c new file mode 100644 index 00000000..d3ee872c --- /dev/null +++ b/src/osmo-bts-sysmo/utils.c @@ -0,0 +1,87 @@ +/* + * Helper utilities that are used in OML + * + * (C) 2011 by Harald Welte <laforge@gnumonks.org> + * (C) 2013 by Holger Hans Peter Freyther + * + * 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 "utils.h" + +#include <osmo-bts/bts.h> + +#include "femtobts.h" + +static int band_osmo2femto(enum gsm_band osmo_band) +{ + switch (osmo_band) { + case GSM_BAND_850: + return GsmL1_FreqBand_850; + case GSM_BAND_900: + return GsmL1_FreqBand_900; + case GSM_BAND_1800: + return GsmL1_FreqBand_1800; + case GSM_BAND_1900: + return GsmL1_FreqBand_1900; + default: + return -1; + } +} + +/** + * Select the band that matches the ARFCN. In general the ARFCNs + * for GSM1800 and GSM1900 overlap and one needs to specify the + * rightband. When moving between GSM900/GSM1800 and GSM850/1900 + * modifying the BTS configuration is a bit annoying. The auto-band + * configuration allows to ease with this transition. + */ +int sysmobts_select_femto_band(struct gsm_bts *bts, uint16_t arfcn) +{ + enum gsm_band band; + struct gsm_bts_role_bts *btsb = bts_role_bts(bts); + + if (!btsb->auto_band) + return band_osmo2femto(bts->band); + + /* + * We need to check what will happen now. + */ + band = gsm_arfcn2band(arfcn); + + /* if we are already on the right band return */ + if (band == bts->band) + return band_osmo2femto(bts->band); + + /* Check if it is GSM1800/GSM1900 */ + if (band == GSM_BAND_1800 && bts->band == GSM_BAND_1900) + return band_osmo2femto(bts->band); + + /* + * Now to the actual autobauding. We just want DCS/DCS and + * PCS/PCS for PCS we check for 850/1800 though + */ + if ((band == GSM_BAND_900 && bts->band == GSM_BAND_1800) + || (band == GSM_BAND_1800 && bts->band == GSM_BAND_900) + || (band == GSM_BAND_850 && bts->band == GSM_BAND_1900)) + return band_osmo2femto(band); + if (band == GSM_BAND_1800 && bts->band == GSM_BAND_850) + return band_osmo2femto(GSM_BAND_1900); + + /* give up */ + return -1; +} diff --git a/src/osmo-bts-sysmo/utils.h b/src/osmo-bts-sysmo/utils.h new file mode 100644 index 00000000..4574e221 --- /dev/null +++ b/src/osmo-bts-sysmo/utils.h @@ -0,0 +1,10 @@ +#ifndef SYSMOBTS_UTILS_H +#define SYSMOBTS_UTILS_H + +#include <stdint.h> + +struct gsm_bts; + +int sysmobts_select_femto_band(struct gsm_bts *bts, uint16_t arfcn); + +#endif |