[MERGED] osmo-bts[master]: bts: use feature list instead of speech codec table

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Thu Feb 22 07:58:26 UTC 2018


Harald Welte has submitted this change and it was merged.

Change subject: bts: use feature list instead of speech codec table
......................................................................


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
---
M include/osmo-bts/bts.h
M include/osmo-bts/gsm_data.h
M src/common/bts.c
M src/common/rsl.c
M src/osmo-bts-octphy/l1_if.c
M src/osmo-bts-sysmo/main.c
M src/osmo-bts-trx/main.c
M tests/misc/misc_test.c
8 files changed, 53 insertions(+), 79 deletions(-)

Approvals:
  Vadim Yanitskiy: Looks good to me, but someone else must approve
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/include/osmo-bts/bts.h b/include/osmo-bts/bts.h
index 2f63e37..4d6e347 100644
--- a/include/osmo-bts/bts.h
+++ b/include/osmo-bts/bts.h
@@ -45,8 +45,8 @@
 
 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 853b445..4b834b5 100644
--- a/include/osmo-bts/gsm_data.h
+++ b/include/osmo-bts/gsm_data.h
@@ -33,11 +33,6 @@
 	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 @@
 	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 31afba4..7849d61 100644
--- a/src/common/bts.c
+++ b/src/common/bts.c
@@ -676,32 +676,45 @@
 	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;
+	enum gsm_bts_features feature = _NUM_BTS_FEAT;
 
-	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)
+	/* 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 001d7e0..5bbd61a 100644
--- a/src/common/rsl.c
+++ b/src/common/rsl.c
@@ -1302,7 +1302,7 @@
 	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 e5fcd98..8dc3e8f 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 @@
 	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 6118b60..efcf4a8 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 @@
 	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 38bb881..5a5c97e 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 @@
 
 	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 00744a6..e454235 100644
--- a/tests/misc/misc_test.c
+++ b/tests/misc/misc_test.c
@@ -157,29 +157,29 @@
 	}
 }
 
-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)

-- 
To view, visit https://gerrit.osmocom.org/6644
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I977dc729ba856631245aedf76afd48eac92166f7
Gerrit-PatchSet: 2
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: dexter <pmaier at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Vadim Yanitskiy <axilirator at gmail.com>



More information about the gerrit-log mailing list