From a4bca115557feb0268e6cfda30238ded16328ae6 Mon Sep 17 00:00:00 2001 From: Philipp Maier Date: Wed, 21 Feb 2018 16:58:08 +0100 Subject: bts: use feature list instead of speech codec table osmo-bts has a table of pchan/channel mode combinations for every bts. This table models the codec capabilitys of the BTS hardware. However, having the speech codec apabilities modeled inside the BTS feature list would be much more comfortable and since the feature list is communicated back to the BSC we would get the codec capabilities inside the BSC domain as well. - remove the pchan/channel mode tables - set speech codec variants for each BTS type - fix bts_supports_cm so that it queries the feature list Change-Id: I977dc729ba856631245aedf76afd48eac92166f7 --- include/osmo-bts/bts.h | 4 +-- include/osmo-bts/gsm_data.h | 6 ----- src/common/bts.c | 59 +++++++++++++++++++++++++++------------------ src/common/rsl.c | 2 +- src/osmo-bts-octphy/l1_if.c | 9 ------- src/osmo-bts-sysmo/main.c | 12 --------- src/osmo-bts-trx/main.c | 12 --------- tests/misc/misc_test.c | 30 +++++++++++------------ 8 files changed, 54 insertions(+), 80 deletions(-) diff --git a/include/osmo-bts/bts.h b/include/osmo-bts/bts.h index 2f63e37f..4d6e3479 100644 --- a/include/osmo-bts/bts.h +++ b/include/osmo-bts/bts.h @@ -45,8 +45,8 @@ struct gsm_time *get_time(struct gsm_bts *bts); int bts_main(int argc, char **argv); -int bts_supports_cm(struct gsm_bts_role_bts *bts, - enum gsm_phys_chan_config pchan, enum gsm48_chan_mode cm); +int bts_supports_cm(struct gsm_bts *bts, enum gsm_phys_chan_config pchan, + enum gsm48_chan_mode cm); #endif /* _BTS_H */ diff --git a/include/osmo-bts/gsm_data.h b/include/osmo-bts/gsm_data.h index 853b4454..4b834b54 100644 --- a/include/osmo-bts/gsm_data.h +++ b/include/osmo-bts/gsm_data.h @@ -33,11 +33,6 @@ struct gsm_network { struct pcu_sock_state *pcu_state; }; -struct bts_cm { - enum gsm_phys_chan_config pchan; - enum gsm48_chan_mode cm; -}; - /* data structure for BTS related data specific to the BTS role */ struct gsm_bts_role_bts { struct { @@ -94,7 +89,6 @@ struct gsm_bts_role_bts { bool rtp_jitter_adaptive; struct { uint8_t ciphers; /* flags A5/1==0x1, A5/2==0x2, A5/3==0x4 */ - const struct bts_cm *cm; /* Table with supp. ch rate/mode combinations */ } support; struct { uint8_t tc4_ctr; diff --git a/src/common/bts.c b/src/common/bts.c index 31afba41..7849d616 100644 --- a/src/common/bts.c +++ b/src/common/bts.c @@ -676,32 +676,45 @@ struct gsm_time *get_time(struct gsm_bts *bts) return &btsb->gsm_time; } -int bts_supports_cm(struct gsm_bts_role_bts *bts, - enum gsm_phys_chan_config pchan, enum gsm48_chan_mode cm) +int bts_supports_cm(struct gsm_bts *bts, enum gsm_phys_chan_config pchan, + enum gsm48_chan_mode cm) { - const struct bts_cm *supported; - int i; - - supported = bts->support.cm; - - /* Check if we got a list with supported codec, if not, no list has - * been configured yet for that BTS. In that case we will just skip - * and accept any combination */ - if (supported == NULL) - return 1; - - for (i = 0;; i++) { - /* If we manage to find the given combination in the list, - * we know that the pchan/cm combination is supported */ - if (supported[i].pchan == pchan && supported[i].cm == cm) - return 1; - - /* When we hit the terminator, we know that the given - * pchan/cm combination is not supported because it - * is not in the list. */ - if (supported[i].pchan == _GSM_PCHAN_MAX) + enum gsm_bts_features feature = _NUM_BTS_FEAT; + + /* Before the requested pchan/cm combination can be checked, we need to + * convert it to a feature identifier we can check */ + if (pchan == GSM_PCHAN_TCH_F) { + switch(cm) { + case GSM48_CMODE_SPEECH_V1: + feature = BTS_FEAT_SPEECH_F_V1; + break; + case GSM48_CMODE_SPEECH_EFR: + feature = BTS_FEAT_SPEECH_F_EFR; + break; + case GSM48_CMODE_SPEECH_AMR: + feature = BTS_FEAT_SPEECH_F_AMR; + break; + default: + /* Invalid speech codec type => Not supported! */ return 0; + } + } else if (pchan == GSM_PCHAN_TCH_H) { + switch(cm) { + case GSM48_CMODE_SPEECH_V1: + feature = BTS_FEAT_SPEECH_H_V1; + break; + case GSM48_CMODE_SPEECH_AMR: + feature = BTS_FEAT_SPEECH_H_AMR; + break; + default: + /* Invalid speech codec type => Not supported! */ + return 0; + } } + /* Check if the feature is supported by this BTS */ + if (gsm_bts_has_feature(bts, feature)) + return 1; + return 0; } diff --git a/src/common/rsl.c b/src/common/rsl.c index 001d7e07..5bbd61a1 100644 --- a/src/common/rsl.c +++ b/src/common/rsl.c @@ -1302,7 +1302,7 @@ static int rsl_rx_mode_modif(struct msgb *msg) cm = (struct rsl_ie_chan_mode *) TLVP_VAL(&tp, RSL_IE_CHAN_MODE); lchan_tchmode_from_cmode(lchan, cm); - if (bts_supports_cm(btsb, lchan->ts->pchan, lchan->tch_mode) != 1) { + if (bts_supports_cm(lchan->ts->trx->bts, lchan->ts->pchan, lchan->tch_mode) != 1) { LOGP(DRSL, LOGL_ERROR, "invalid mode/codec instructed by BSC, check BSC configuration.\n"); return rsl_tx_mode_modif_nack(lchan, RSL_ERR_SERV_OPT_UNAVAIL); } diff --git a/src/osmo-bts-octphy/l1_if.c b/src/osmo-bts-octphy/l1_if.c index e5fcd98a..8dc3e8f1 100644 --- a/src/osmo-bts-octphy/l1_if.c +++ b/src/osmo-bts-octphy/l1_if.c @@ -76,14 +76,6 @@ /* timeout until which we expect PHY to respond */ #define CMD_TIMEOUT 5 -/* Table with channel rate / and codec configuration that are supported - * by the hardware bts_supports_cm() */ -static const struct bts_cm bts_model_supported_cm[] = { - { GSM_PCHAN_TCH_F, GSM48_CMODE_SPEECH_V1}, - { GSM_PCHAN_TCH_H, GSM48_CMODE_SPEECH_V1}, - { _GSM_PCHAN_MAX, 0 } -}; - /* allocate a msgb for a Layer1 primitive */ struct msgb *l1p_msgb_alloc(void) { @@ -784,7 +776,6 @@ int bts_model_init(struct gsm_bts *bts) bts->variant = BTS_OSMO_OCTPHY; btsb = bts_role_bts(bts); btsb->support.ciphers = CIPHER_A5(1) | CIPHER_A5(2) | CIPHER_A5(3); - btsb->support.cm = bts_model_supported_cm; /* FIXME: what is the nominal transmit power of the PHY/board? */ bts->c0->nominal_power = 15; diff --git a/src/osmo-bts-sysmo/main.c b/src/osmo-bts-sysmo/main.c index 6118b605..efcf4a8d 100644 --- a/src/osmo-bts-sysmo/main.c +++ b/src/osmo-bts-sysmo/main.c @@ -55,17 +55,6 @@ #include "hw_misc.h" #include "oml_router.h" -/* Table with channel rate / and codec configuration that are supported - * by the hardware bts_supports_cm() */ -static const struct bts_cm bts_model_supported_cm[] = { - { GSM_PCHAN_TCH_F, GSM48_CMODE_SPEECH_V1}, - { GSM_PCHAN_TCH_H, GSM48_CMODE_SPEECH_V1}, - { GSM_PCHAN_TCH_F, GSM48_CMODE_SPEECH_EFR}, - { GSM_PCHAN_TCH_F, GSM48_CMODE_SPEECH_AMR}, - { GSM_PCHAN_TCH_H, GSM48_CMODE_SPEECH_AMR}, - { _GSM_PCHAN_MAX, 0 } -}; - int bts_model_init(struct gsm_bts *bts) { struct gsm_bts_role_bts *btsb; @@ -76,7 +65,6 @@ int bts_model_init(struct gsm_bts *bts) bts->variant = BTS_OSMO_SYSMO; btsb = bts_role_bts(bts); btsb->support.ciphers = CIPHER_A5(1) | CIPHER_A5(2) | CIPHER_A5(3); - btsb->support.cm = bts_model_supported_cm; rc = oml_router_init(bts, OML_ROUTER_PATH, &accept_fd, &read_fd); if (rc < 0) { diff --git a/src/osmo-bts-trx/main.c b/src/osmo-bts-trx/main.c index 38bb881c..5a5c97ec 100644 --- a/src/osmo-bts-trx/main.c +++ b/src/osmo-bts-trx/main.c @@ -59,17 +59,6 @@ #include "l1_if.h" #include "trx_if.h" -/* Table with channel rate / and codec configuration that are supported - * by the hardware bts_supports_cm() */ -static const struct bts_cm bts_model_supported_cm[] = { - { GSM_PCHAN_TCH_F, GSM48_CMODE_SPEECH_V1}, - { GSM_PCHAN_TCH_H, GSM48_CMODE_SPEECH_V1}, - { GSM_PCHAN_TCH_F, GSM48_CMODE_SPEECH_EFR}, - { GSM_PCHAN_TCH_F, GSM48_CMODE_SPEECH_AMR}, - { GSM_PCHAN_TCH_H, GSM48_CMODE_SPEECH_AMR}, - { _GSM_PCHAN_MAX, 0 } -}; - /* dummy, since no direct dsp support */ uint32_t trx_get_hlayer1(struct gsm_bts_trx *trx) { @@ -112,7 +101,6 @@ int bts_model_init(struct gsm_bts *bts) bts->variant = BTS_OSMO_TRX; btsb->support.ciphers = CIPHER_A5(1) | CIPHER_A5(2); - btsb->support.cm = bts_model_supported_cm; /* FIXME: this needs to be overridden with the real hardrware * value */ diff --git a/tests/misc/misc_test.c b/tests/misc/misc_test.c index 00744a6b..e4542354 100644 --- a/tests/misc/misc_test.c +++ b/tests/misc/misc_test.c @@ -157,29 +157,29 @@ static void test_sacch_get(void) } } -static const struct bts_cm bts_model_supported_cm[] = { - {GSM_PCHAN_TCH_F, GSM48_CMODE_SPEECH_V1}, - {GSM_PCHAN_TCH_H, GSM48_CMODE_SPEECH_V1}, - {GSM_PCHAN_TCH_F, GSM48_CMODE_SPEECH_AMR}, - {GSM_PCHAN_TCH_H, GSM48_CMODE_SPEECH_AMR}, - {_GSM_PCHAN_MAX, 0} -}; - static void test_bts_supports_cm(void) { - struct gsm_bts_role_bts bts; - bts.support.cm = bts_model_supported_cm; + struct gsm_bts *bts; + + bts = gsm_bts_alloc(NULL, 0); + + gsm_bts_set_feature(bts, BTS_FEAT_SPEECH_F_V1); + gsm_bts_set_feature(bts, BTS_FEAT_SPEECH_H_V1); + gsm_bts_set_feature(bts, BTS_FEAT_SPEECH_F_AMR); + gsm_bts_set_feature(bts, BTS_FEAT_SPEECH_H_AMR); OSMO_ASSERT(bts_supports_cm - (&bts, GSM_PCHAN_TCH_F, GSM48_CMODE_SPEECH_V1) == 1); + (bts, GSM_PCHAN_TCH_F, GSM48_CMODE_SPEECH_V1) == 1); OSMO_ASSERT(bts_supports_cm - (&bts, GSM_PCHAN_TCH_H, GSM48_CMODE_SPEECH_V1) == 1); + (bts, GSM_PCHAN_TCH_H, GSM48_CMODE_SPEECH_V1) == 1); OSMO_ASSERT(bts_supports_cm - (&bts, GSM_PCHAN_TCH_F, GSM48_CMODE_SPEECH_EFR) == 0); + (bts, GSM_PCHAN_TCH_F, GSM48_CMODE_SPEECH_EFR) == 0); OSMO_ASSERT(bts_supports_cm - (&bts, GSM_PCHAN_TCH_F, GSM48_CMODE_SPEECH_AMR) == 1); + (bts, GSM_PCHAN_TCH_F, GSM48_CMODE_SPEECH_AMR) == 1); OSMO_ASSERT(bts_supports_cm - (&bts, GSM_PCHAN_TCH_H, GSM48_CMODE_SPEECH_AMR) == 1); + (bts, GSM_PCHAN_TCH_H, GSM48_CMODE_SPEECH_AMR) == 1); + + talloc_free(bts); } int main(int argc, char **argv) -- cgit v1.2.3