[MERGED] openbsc[master]: bsc: count the usage of codec by setting the lchan active

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 Oct 27 10:18:00 UTC 2016


Harald Welte has submitted this change and it was merged.

Change subject: bsc: count the usage of codec by setting the lchan active
......................................................................


bsc: count the usage of codec by setting the lchan active

We count the codec when the channel was successful setted up
Using sign_link->trx->bts instead of msg->trx to get the bts.
Add OSMO_ASSERT for bts within count_codecs()

Change-Id: Ib49c7c337980a7d6f189d7a0551ca2e4c3822f45
---
M openbsc/include/openbsc/gsm_data.h
M openbsc/src/libbsc/abis_rsl.c
2 files changed, 47 insertions(+), 0 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/openbsc/include/openbsc/gsm_data.h b/openbsc/include/openbsc/gsm_data.h
index c7e2347..70c08c3 100644
--- a/openbsc/include/openbsc/gsm_data.h
+++ b/openbsc/include/openbsc/gsm_data.h
@@ -168,6 +168,11 @@
 	BSC_CTR_CHAN_RLL_ERR,
 	BSC_CTR_BTS_OML_FAIL,
 	BSC_CTR_BTS_RSL_FAIL,
+	BSC_CTR_CODEC_AMR_F,
+	BSC_CTR_CODEC_AMR_H,
+	BSC_CTR_CODEC_EFR,
+	BSC_CTR_CODEC_V1_FR,
+	BSC_CTR_CODEC_V1_HR,
 };
 
 static const struct rate_ctr_desc bsc_ctr_description[] = {
@@ -186,6 +191,11 @@
 	[BSC_CTR_CHAN_RLL_ERR] = 		{"chan.rll_err", "Received a RLL failure with T200 cause from BTS."},
 	[BSC_CTR_BTS_OML_FAIL] = 		{"bts.oml_fail", "Received a TEI down on a OML link."},
 	[BSC_CTR_BTS_RSL_FAIL] = 		{"bts.rsl_fail", "Received a TEI down on a OML link."},
+	[BSC_CTR_CODEC_AMR_F] =			{"bts.codec_amr_f", "Count the usage of AMR/F codec by channel mode requested."},
+	[BSC_CTR_CODEC_AMR_H] =			{"bts.codec_amr_h", "Count the usage of AMR/H codec by channel mode requested."},
+	[BSC_CTR_CODEC_EFR] = 			{"bts.codec_efr", "Count the usage of EFR codec by channel mode requested."},
+	[BSC_CTR_CODEC_V1_FR] =			{"bts.codec_fr", "Count the usage of FR codec by channel mode requested."},
+	[BSC_CTR_CODEC_V1_HR] =			{"bts.codec_hr", "Count the usage of HR codec by channel mode requested."},
 };
 
 enum {
diff --git a/openbsc/src/libbsc/abis_rsl.c b/openbsc/src/libbsc/abis_rsl.c
index 316fc3f..9656961 100644
--- a/openbsc/src/libbsc/abis_rsl.c
+++ b/openbsc/src/libbsc/abis_rsl.c
@@ -82,6 +82,41 @@
 	lchan_free(lchan);
 }
 
+static void count_codecs(struct gsm_bts *bts, struct gsm_lchan *lchan)
+{
+	OSMO_ASSERT(bts);
+
+	if (lchan->type == GSM_LCHAN_TCH_H) {
+		switch (lchan->tch_mode) {
+		case GSM48_CMODE_SPEECH_AMR:
+			rate_ctr_inc(&bts->network->bsc_ctrs->ctr[BSC_CTR_CODEC_AMR_H]);
+			break;
+		case GSM48_CMODE_SPEECH_V1:
+			rate_ctr_inc(&bts->network->bsc_ctrs->ctr[BSC_CTR_CODEC_V1_HR]);
+			break;
+		default:
+			break;
+		}
+	} else if (lchan->type == GSM_LCHAN_TCH_F) {
+		switch (lchan->tch_mode) {
+		case GSM48_CMODE_SPEECH_AMR:
+			rate_ctr_inc(&bts->network->bsc_ctrs->ctr[BSC_CTR_CODEC_AMR_F]);
+			break;
+		case GSM48_CMODE_SPEECH_V1:
+			rate_ctr_inc(&bts->network->bsc_ctrs->ctr[BSC_CTR_CODEC_V1_FR]);
+			break;
+		case GSM48_CMODE_SPEECH_EFR:
+			rate_ctr_inc(&bts->network->bsc_ctrs->ctr[BSC_CTR_CODEC_EFR]);
+			break;
+		default:
+			break;
+		}
+	} else {
+		LOGP(DRSL, LOGL_ERROR, "count_codecs unknown lchan->type %x on channel %s\n",
+		     lchan->type, gsm_ts_and_pchan_name(lchan->ts));
+	}
+}
+
 static uint8_t mdisc_by_msgtype(uint8_t msg_type)
 {
 	/* mask off the transparent bit ? */
@@ -1464,6 +1499,7 @@
 	case RSL_MT_CHAN_ACTIV_ACK:
 		DEBUGP(DRSL, "%s CHANNEL ACTIVATE ACK\n", ts_name);
 		rc = rsl_rx_chan_act_ack(msg);
+		count_codecs(sign_link->trx->bts, msg->lchan);
 		break;
 	case RSL_MT_CHAN_ACTIV_NACK:
 		rc = rsl_rx_chan_act_nack(msg);
@@ -1481,6 +1517,7 @@
 		rc = rsl_rx_rf_chan_rel_ack(msg->lchan);
 		break;
 	case RSL_MT_MODE_MODIFY_ACK:
+		count_codecs(sign_link->trx->bts, msg->lchan);
 		DEBUGP(DRSL, "%s CHANNEL MODE MODIFY ACK\n", ts_name);
 		break;
 	case RSL_MT_MODE_MODIFY_NACK:

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ib49c7c337980a7d6f189d7a0551ca2e4c3822f45
Gerrit-PatchSet: 2
Gerrit-Project: openbsc
Gerrit-Branch: master
Gerrit-Owner: lynxis lazus <lynxis at fe80.eu>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Holger Freyther <holger at freyther.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: lynxis lazus <lynxis at fe80.eu>



More information about the gerrit-log mailing list