From 73bd4630613cb2f2fcd5c5bca15ec7989f53f526 Mon Sep 17 00:00:00 2001 From: Vadim Yanitskiy Date: Sat, 2 Nov 2019 00:57:23 +0700 Subject: osmo_bsc_main.c: verify the physical channel mapping at startup As per 3GPP TS 45.002, section 3.3.2.3, and table 3 of clause 7, the following limitations apply mapping of CCCH/BCCH channels: - TS0/C0 shall be configured as CCCH/BCCH (optionally combined); - combined CCCH (CCCH+SDCCH4) can only be used on TS0; - additional CCCHs can be on TS2, TS4, and TS6; - additional CCCHs are not allowed if TS0 is combined. Let's make sure that OsmoBSC is properly configured before starring. Change-Id: I758ef80f7884ba35cdf59d671ee30222ffb9d68b --- include/osmocom/bsc/gsm_data.h | 2 ++ src/osmo-bsc/gsm_data.c | 51 ++++++++++++++++++++++++++++++++++++++++++ src/osmo-bsc/osmo_bsc_main.c | 10 +++++++++ 3 files changed, 63 insertions(+) diff --git a/include/osmocom/bsc/gsm_data.h b/include/osmocom/bsc/gsm_data.h index ca9d2946f..23aacd614 100644 --- a/include/osmocom/bsc/gsm_data.h +++ b/include/osmocom/bsc/gsm_data.h @@ -1749,4 +1749,6 @@ void gsm_trx_all_ts_dispatch(struct gsm_bts_trx *trx, uint32_t ts_ev, void *data int bts_count_free_ts(struct gsm_bts *bts, enum gsm_phys_chan_config pchan); +bool trx_has_valid_pchan_config(const struct gsm_bts_trx *trx); + #endif /* _GSM_DATA_H */ diff --git a/src/osmo-bsc/gsm_data.c b/src/osmo-bsc/gsm_data.c index 88981c0e1..e7fe065be 100644 --- a/src/osmo-bsc/gsm_data.c +++ b/src/osmo-bsc/gsm_data.c @@ -1693,3 +1693,54 @@ const struct value_string lchan_activate_mode_names[] = { OSMO_VALUE_STRING(FOR_VTY), {} }; + +bool trx_has_valid_pchan_config(const struct gsm_bts_trx *trx) +{ + bool combined = false; + bool result = true; + unsigned int i; + + /* Iterate over all timeslots */ + for (i = 0; i < 8; i++) { + const struct gsm_bts_trx_ts *ts = &trx->ts[i]; + + switch (ts->pchan_from_config) { + case GSM_PCHAN_CCCH_SDCCH4_CBCH: + case GSM_PCHAN_CCCH_SDCCH4: + /* CCCH+SDCCH4 can only be configured on TS0 */ + if (i > 0) { + LOGP(DNM, LOGL_ERROR, "Combined CCCH is not allowed " + "on TS%u > 0\n", i); + result = false; + } + if (i == 0) + combined = true; + /* fall-through */ + case GSM_PCHAN_CCCH: + /* 3GPP TS 45.002, Table 3, CCCH: TS (0, 2, 4, 6) */ + if (i % 2 != 0) { + LOGP(DNM, LOGL_ERROR, "%s is not allowed on odd TS%u\n", + gsm_pchan_name(ts->pchan_from_config), i); + result = false; + } + + /* There can be no more CCCHs if TS0/C0 is combined */ + if (i > 0 && combined) { + LOGP(DNM, LOGL_ERROR, "%s is not allowed on TS%u, " + "because TS0 is using combined channel configuration\n", + gsm_pchan_name(ts->pchan_from_config), i); + result = false; + } + break; + + default: + /* CCCH on TS0 is mandatory for C0 */ + if (trx->bts->c0 == trx && i == 0) { + LOGP(DNM, LOGL_ERROR, "TS0 on C0 must be CCCH/BCCH\n"); + result = false; + } + } + } + + return result; +} diff --git a/src/osmo-bsc/osmo_bsc_main.c b/src/osmo-bsc/osmo_bsc_main.c index dacd61a08..3acdf300d 100644 --- a/src/osmo-bsc/osmo_bsc_main.c +++ b/src/osmo-bsc/osmo_bsc_main.c @@ -401,6 +401,7 @@ static int inp_sig_cb(unsigned int subsys, unsigned int signal, static int bootstrap_bts(struct gsm_bts *bts) { + struct gsm_bts_trx *trx; int i, n; if (!bts->model) @@ -447,6 +448,15 @@ static int bootstrap_bts(struct gsm_bts *bts) return -EINVAL; } + /* Verify the physical channel mapping */ + llist_for_each_entry(trx, &bts->trx_list, list) { + if (!trx_has_valid_pchan_config(trx)) { + LOGP(DNM, LOGL_ERROR, "TRX %u has invalid timeslot " + "configuration\n", trx->nr); + return -EINVAL; + } + } + /* Control Channel Description is set from vty/config */ /* Set ccch config by looking at ts config */ -- cgit v1.2.3