aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/osmo-bsc/codec_pref.c38
-rw-r--r--tests/codec_pref/codec_pref_test.c8
2 files changed, 42 insertions, 4 deletions
diff --git a/src/osmo-bsc/codec_pref.c b/src/osmo-bsc/codec_pref.c
index a741e1115..9f30c7b7f 100644
--- a/src/osmo-bsc/codec_pref.c
+++ b/src/osmo-bsc/codec_pref.c
@@ -176,8 +176,38 @@ static bool test_codec_pref(const struct gsm0808_speech_codec **sc_match,
/* Helper function to check if the given permitted speech value is supported
* by the BTS. (vty option bts->codec-support). */
-static bool test_codec_support_bts(const struct bts_codec_conf *bts_codec, uint8_t perm_spch)
+static bool test_codec_support_bts(const struct gsm_bts *bts, uint8_t perm_spch)
{
+ struct gsm_bts_trx *trx;
+ const struct bts_codec_conf *bts_codec = &bts->codec;
+ unsigned int i;
+ bool full_rate;
+ int rc;
+ enum gsm_phys_chan_config pchan;
+ bool rate_match = false;
+
+ /* Check if the BTS provides a physical channel that matches the
+ * bandwith of the desired codec. */
+ rc = full_rate_from_perm_spch(&full_rate, perm_spch);
+ if (rc < 0)
+ return false;
+ llist_for_each_entry(trx, &bts->trx_list, list) {
+ for (i = 0; i < TRX_NR_TS; i++) {
+ pchan = trx->ts[i].pchan_from_config;
+ if (pchan == GSM_PCHAN_TCH_F_TCH_H_PDCH)
+ rate_match = true;
+ else if (full_rate && pchan == GSM_PCHAN_TCH_F)
+ rate_match = true;
+ else if (full_rate && pchan == GSM_PCHAN_TCH_F_PDCH)
+ rate_match = true;
+ else if (!full_rate && pchan == GSM_PCHAN_TCH_H)
+ rate_match = true;
+ }
+ }
+ if (!rate_match)
+ return false;
+
+ /* Check codec support */
switch (perm_spch) {
case GSM0808_PERM_FR1:
/* GSM-FR is always supported by all BTSs. There is also no way to
@@ -269,7 +299,7 @@ int match_codec_pref(enum gsm48_chan_mode *chan_mode,
/* Check this permitted speech value against the BTS specific parameters.
* if the BTS does not support the codec, try the next one */
- if (!test_codec_support_bts(&bts->codec, perm_spch))
+ if (!test_codec_support_bts(bts, perm_spch))
continue;
/* Match the permitted speech value against the codec lists that were
@@ -345,7 +375,7 @@ void gen_bss_supported_codec_list(struct gsm0808_speech_codec_list *scl,
/* Check this permitted speech value against the BTS specific parameters.
* if the BTS does not support the codec, try the next one */
- if (!test_codec_support_bts(&bts->codec, perm_spch))
+ if (!test_codec_support_bts(bts, perm_spch))
continue;
/* Write item into codec list */
@@ -380,7 +410,7 @@ int check_codec_pref(struct llist_head *mscs)
gen_bss_supported_codec_list(&scl, msc, bts);
if (scl.len <= 0) {
LOGP(DMSC, LOGL_FATAL,
- "codec-support of BTS %u does not intersect with codec-list of MSC %u\n",
+ "codec-support/trx config of BTS %u does not intersect with codec-list of MSC %u\n",
bts->nr, msc->nr);
rc = -1;
}
diff --git a/tests/codec_pref/codec_pref_test.c b/tests/codec_pref/codec_pref_test.c
index e2876e2c8..534b99ef7 100644
--- a/tests/codec_pref/codec_pref_test.c
+++ b/tests/codec_pref/codec_pref_test.c
@@ -294,6 +294,7 @@ static void make_bts_config(struct gsm_bts *bts, uint8_t config_no)
/* Note: FR is supported by all BTSs, so there is no flag for it */
struct gsm48_multi_rate_conf *cfg;
+ static struct gsm_bts_trx trx;
OSMO_ASSERT(config_no < N_CONFIG_VARIANTS);
@@ -324,6 +325,13 @@ static void make_bts_config(struct gsm_bts *bts, uint8_t config_no)
cfg->m10_2 = 0;
cfg->m12_2 = 0;
+ /* Initalize TRX with a TCH/F and a TCH/H channel */
+ memset(&trx, 0, sizeof(trx));
+ INIT_LLIST_HEAD(&bts->trx_list);
+ llist_add(&trx.list, &bts->trx_list);
+ trx.ts[0].pchan_from_config = GSM_PCHAN_TCH_F;
+ trx.ts[1].pchan_from_config = GSM_PCHAN_TCH_H;
+
switch (config_no) {
case 0:
/* FR1 (implicit) only */