From 8c53c59bfb1bc16347a60d5e15113c70d289ac93 Mon Sep 17 00:00:00 2001 From: Alexander Couzens Date: Tue, 23 Aug 2016 06:27:19 +0200 Subject: 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 --- openbsc/src/libbsc/abis_rsl.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'openbsc/src/libbsc/abis_rsl.c') diff --git a/openbsc/src/libbsc/abis_rsl.c b/openbsc/src/libbsc/abis_rsl.c index 316fc3fed..9656961c9 100644 --- a/openbsc/src/libbsc/abis_rsl.c +++ b/openbsc/src/libbsc/abis_rsl.c @@ -82,6 +82,41 @@ static void do_lchan_free(struct gsm_lchan *lchan) 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 @@ static int abis_rsl_rx_dchan(struct msgb *msg) 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 @@ 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(sign_link->trx->bts, msg->lchan); DEBUGP(DRSL, "%s CHANNEL MODE MODIFY ACK\n", ts_name); break; case RSL_MT_MODE_MODIFY_NACK: -- cgit v1.2.3