summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Couzens <lynxis@fe80.eu>2016-08-23 06:27:19 +0200
committerAlexander Couzens <lynxis@fe80.eu>2016-10-04 00:55:05 +0200
commit38e9ea3f7f385c6660c5958970af5c71adc1682b (patch)
treed5df1bf0ec407a61cae384743ae5badb049edc91
parenta8f91df851846d4f61a426e113df52faa1fa0144 (diff)
bsc: count the usage of codec by setting the lchan active
we count the codec when the channel was successful setted up Change-Id: Ifc8a406a11dce16b9e7f3310841e470545550a2c
-rw-r--r--openbsc/include/openbsc/gsm_data.h10
-rw-r--r--openbsc/src/libbsc/abis_rsl.c35
2 files changed, 45 insertions, 0 deletions
diff --git a/openbsc/include/openbsc/gsm_data.h b/openbsc/include/openbsc/gsm_data.h
index ffb7dd226..5829c8d11 100644
--- a/openbsc/include/openbsc/gsm_data.h
+++ b/openbsc/include/openbsc/gsm_data.h
@@ -168,6 +168,11 @@ enum {
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 @@ static const struct rate_ctr_desc bsc_ctr_description[] = {
[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 dc4ede294..ae88f8c1d 100644
--- a/openbsc/src/libbsc/abis_rsl.c
+++ b/openbsc/src/libbsc/abis_rsl.c
@@ -82,6 +82,39 @@ static void do_lchan_free(struct gsm_lchan *lchan)
lchan_free(lchan);
}
+static void count_codecs(struct gsm_bts *bts, struct gsm_lchan *lchan)
+{
+ 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 ? */
@@ -1170,6 +1203,7 @@ static int rsl_rx_chan_act_ack(struct msgb *msg)
lchan->rqd_ta = 0;
}
+ count_codecs(msg->trx->bts, lchan);
send_lchan_signal(S_LCHAN_ACTIVATE_ACK, lchan, NULL);
return 0;
@@ -1479,6 +1513,7 @@ static int abis_rsl_rx_dchan(struct msgb *msg)
rc = rsl_rx_rf_chan_rel_ack(msg->lchan);
break;
case RSL_MT_MODE_MODIFY_ACK:
+ count_codecs(msg->trx->bts, msg->lchan);
DEBUGP(DRSL, "%s CHANNEL MODE MODIFY ACK\n", ts_name);
break;
case RSL_MT_MODE_MODIFY_NACK: