aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2018-12-20 02:15:03 +0100
committerNeels Hofmeyr <neels@hofmeyr.de>2018-12-21 02:05:08 +0100
commit64a3bbe093107986084a8911155f25eeca56d107 (patch)
treec367c12fd55c0696162a7f7d73c1f3c1e2ccafea
parentaecee598a10fd1dbf7bf1f802aeaf57826015532 (diff)
debug log: log almost all stages of speech codec negotiation
Trying to understand the stages of speech codec limitations, I came up with this logging. Keep it for future problem solving. It looks like this: DCHAN DEBUG test_codec_pref: HR3 matches gsm0808_channel_type->perm_spch[3] (codec_pref.c:146) DCHAN DEBUG test_codec_pref: permitted speech = HR3 corresponds to speech codec type = HR3 (codec_pref.c:174) DCHAN DEBUG test_codec_pref: speech_codec_list[3] matches speech codec type HR3 (codec_pref.c:182) DCHAN DEBUG match_codec_pref: msc->audio_support[0] = HR3: matches channel type and speech codec list (codec_pref.c:329) DCHAN DEBUG match_codec_pref: perm_spch=HR3 corresponds to chan_mode=SPEECH_AMR (codec_pref.c:357) DCHAN DEBUG match_codec_pref: perm_spch=HR3 is AMR (codec_pref.c:363) DCHAN DEBUG gen_bss_supported_amr_s15_s0: HR: bts->mr_half.gsm48_ie[1] = 0x36 ==> amr_cfg_bts=0x0736 (codec_pref.c:267) DCHAN DEBUG match_codec_pref: sc_match=HR3 & amr_s15_s0_supported=0x0600 = 0x0600 (codec_pref.c:376) DCHAN DEBUG Found matching audio type: half rate SPEECH_AMR for channel_type = { ch_indctr=0x1, ch_rate_type=0xa, perm_spch=[ 21 11 01 25 05 ] }, s15_s0=0x0600 (osmo_bsc_bssap.c:737) DCHAN DEBUG perm_spch[0] = 0x21 = FR3 (osmo_bsc_bssap.c:742) DCHAN DEBUG perm_spch[1] = 0x11 = FR2 (osmo_bsc_bssap.c:742) DCHAN DEBUG perm_spch[2] = 0x01 = FR1 (osmo_bsc_bssap.c:742) DCHAN DEBUG perm_spch[3] = 0x25 = HR3 (osmo_bsc_bssap.c:742) DCHAN DEBUG perm_spch[4] = 0x05 = HR1 (osmo_bsc_bssap.c:742) ... DCHAN DEBUG lchan(0-0-2-TCH_F_TCH_H_PDCH-0)[0x612000006520]{WAIT_TS_READY}: (type=TCH_H) AMR rate configurations: MSC=0x8 & BTS=0xa = 0x8 (lchan_fsm.c:455) Change-Id: Ida4e7e0cf27e8c6e502061a5c41e8b51f533d3dd
-rw-r--r--src/osmo-bsc/codec_pref.c48
-rw-r--r--src/osmo-bsc/lchan_fsm.c4
-rw-r--r--src/osmo-bsc/osmo_bsc_bssap.c15
3 files changed, 58 insertions, 9 deletions
diff --git a/src/osmo-bsc/codec_pref.c b/src/osmo-bsc/codec_pref.c
index c99c38335..8bdfa43aa 100644
--- a/src/osmo-bsc/codec_pref.c
+++ b/src/osmo-bsc/codec_pref.c
@@ -142,6 +142,8 @@ static bool test_codec_pref(const struct gsm0808_speech_codec **sc_match,
* codec list of the channel type element */
for (i = 0; i < ct->perm_spch_len; i++) {
if (ct->perm_spch[i] == perm_spch) {
+ LOGP(DCHAN, LOGL_DEBUG, "%s: %s matches gsm0808_channel_type->perm_spch[%d]\n",
+ __func__, gsm0808_permitted_speech_name(perm_spch), i);
match = true;
break;
}
@@ -149,24 +151,35 @@ static bool test_codec_pref(const struct gsm0808_speech_codec **sc_match,
/* If we do not have a speech codec list to test against,
* we just exit early (will be always the case in non-AoIP networks) */
- if (!scl || !scl->len)
+ if (!scl || !scl->len) {
+ LOGP(DCHAN, LOGL_DEBUG, "%s: there is no gsm0808_speech_codec_list\n",
+ __func__);
return match;
+ }
/* If we failed to match until here, there is no
* point in testing further */
- if (match == false)
+ if (match == false) {
+ LOGP(DCHAN, LOGL_DEBUG, "%s: no match for %s\n",
+ __func__, gsm0808_permitted_speech_name(perm_spch));
return false;
+ }
/* Extrapolate speech codec data */
rc = gsm0808_speech_codec_from_chan_type(&sc, perm_spch);
if (rc < 0)
return false;
+ LOGP(DCHAN, LOGL_DEBUG, "%s: permitted speech = %s corresponds to speech codec type = %s\n",
+ __func__, gsm0808_permitted_speech_name(perm_spch), gsm0808_speech_codec_type_name(sc.type));
+
/* Try to find extrapolated speech codec data in
* the speech codec list */
for (i = 0; i < scl->len; i++) {
if (sc.type == scl->codec[i].type) {
*sc_match = &scl->codec[i];
+ LOGP(DCHAN, LOGL_DEBUG, "%s: speech_codec_list[%d] matches speech codec type %s\n",
+ __func__, i, gsm0808_speech_codec_type_name(sc.type));
return true;
}
}
@@ -250,6 +263,8 @@ static uint16_t gen_bss_supported_amr_s15_s0(const struct bsc_msc_data *msc, con
if (hr) {
amr_cfg_bts = (struct gsm48_multi_rate_conf *)&bts->mr_half.gsm48_ie;
amr_s15_s0_bts = gsm0808_sc_cfg_from_gsm48_mr_cfg(amr_cfg_bts, false);
+ LOGP(DCHAN, LOGL_DEBUG, "%s: HR: bts->mr_half.gsm48_ie[1] = 0x%02x ==> amr_cfg_bts=0x%04x\n",
+ __func__, bts->mr_half.gsm48_ie[1], amr_s15_s0_bts);
} else {
amr_cfg_bts = (struct gsm48_multi_rate_conf *)&bts->mr_full.gsm48_ie;
amr_s15_s0_bts = gsm0808_sc_cfg_from_gsm48_mr_cfg(amr_cfg_bts, true);
@@ -299,15 +314,25 @@ int match_codec_pref(enum gsm48_chan_mode *chan_mode,
/* Check this permitted speech value against the BTS specific parameters.
* if the BTS does not support the codec, try the next one */
- if (!test_codec_support_bts(bts, perm_spch))
+ if (!test_codec_support_bts(bts, perm_spch)) {
+ LOGP(DCHAN, LOGL_DEBUG, "%s: msc->audio_support[%d] = %s: not supported by bts%u\n",
+ __func__, i, gsm0808_permitted_speech_name(perm_spch),
+ bts->nr);
continue;
+ }
/* Match the permitted speech value against the codec lists that were
* advertised by the MS and the MSC */
if (test_codec_pref(&sc_match, scl, ct, perm_spch)) {
+ LOGP(DCHAN, LOGL_DEBUG, "%s: msc->audio_support[%d] = %s:"
+ " matches channel type and speech codec list\n",
+ __func__, i, gsm0808_permitted_speech_name(perm_spch));
match = true;
break;
}
+ LOGP(DCHAN, LOGL_DEBUG, "%s: msc->audio_support[%d] = %s:"
+ " does not matches channel type and/or speech codec list\n",
+ __func__, i, gsm0808_permitted_speech_name(perm_spch));
}
/* Exit without result, in case no match can be deteched */
@@ -326,8 +351,16 @@ int match_codec_pref(enum gsm48_chan_mode *chan_mode,
/* Lookup a channel mode for the selected codec */
*chan_mode = gsm88_to_chan_mode(perm_spch);
+ LOGP(DCHAN, LOGL_DEBUG, "%s: perm_spch=%s corresponds to chan_mode=%s\n",
+ __func__,
+ gsm0808_permitted_speech_name(perm_spch),
+ gsm48_chan_mode_name(*chan_mode));
+
/* Special handling for AMR */
if (perm_spch == GSM0808_PERM_HR3 || perm_spch == GSM0808_PERM_FR3) {
+ LOGP(DCHAN, LOGL_DEBUG, "%s: perm_spch=%s is AMR\n",
+ __func__,
+ gsm0808_permitted_speech_name(perm_spch));
/* Normally the MSC should never try to advertise an AMR codec
* configuration that we did not previously advertise as
* supported. However, to ensure that no unsupported AMR codec
@@ -336,10 +369,15 @@ int match_codec_pref(enum gsm48_chan_mode *chan_mode,
* further processing is then done with this intersection
* result */
amr_s15_s0_supported = gen_bss_supported_amr_s15_s0(msc, bts, (perm_spch == GSM0808_PERM_HR3));
- if (sc_match)
+ if (sc_match) {
*s15_s0 = sc_match->cfg & amr_s15_s0_supported;
- else
+ LOGP(DCHAN, LOGL_DEBUG, "%s: sc_match=%s & amr_s15_s0_supported=0x%04x = 0x%04x\n",
+ __func__,
+ gsm0808_speech_codec_type_name(sc_match->type), amr_s15_s0_supported, *s15_s0);
+ } else {
*s15_s0 = amr_s15_s0_supported;
+ LOGP(DCHAN, LOGL_DEBUG, "%s: amr_s15_s0_supported=0x%04x\n", __func__, *s15_s0);
+ }
/* NOTE: The function test_codec_pref() will populate the
* sc_match pointer from the searched speech codec list. For
diff --git a/src/osmo-bsc/lchan_fsm.c b/src/osmo-bsc/lchan_fsm.c
index ac57027c3..6a95d4c57 100644
--- a/src/osmo-bsc/lchan_fsm.c
+++ b/src/osmo-bsc/lchan_fsm.c
@@ -450,6 +450,10 @@ static int lchan_mr_config(struct gsm_lchan *lchan, const struct gsm48_multi_rat
full_rate ? "tch-f" : "tch-h");
return -EINVAL;
}
+ LOG_LCHAN(lchan, LOGL_DEBUG,
+ "AMR rate configurations: MSC=0x%x & BTS=0x%x = 0x%x\n",
+ ((uint8_t*)&msc->amr_conf)[1], ((uint8_t*)mr_conf)[1],
+ ((uint8_t*)&mr_conf_filtered)[1]);
/* The two last codec rates which are defined for AMR do only work with
* full rate channels. We will pinch off those rates für half-rate
diff --git a/src/osmo-bsc/osmo_bsc_bssap.c b/src/osmo-bsc/osmo_bsc_bssap.c
index 60ec5fbf2..5b7b79a8f 100644
--- a/src/osmo-bsc/osmo_bsc_bssap.c
+++ b/src/osmo-bsc/osmo_bsc_bssap.c
@@ -720,7 +720,7 @@ static int bssmap_handle_assignm_req(struct gsm_subscriber_connection *conn,
rc = match_codec_pref(&chan_mode, &full_rate, &s15_s0, &ct, &conn->codec_list,
msc, conn_get_bts(conn));
if (rc < 0) {
- LOGP(DMSC, LOGL_ERROR, "No supported audio type found for channel_type ="
+ LOGP(DCHAN, LOGL_ERROR, "No supported audio type found for channel_type ="
" { ch_indctr=0x%x, ch_rate_type=0x%x, perm_spch=[ %s] }\n",
ct.ch_indctr, ct.ch_rate_type, osmo_hexdump(ct.perm_spch, ct.perm_spch_len));
/* TODO: actually output codec names, e.g. implement
@@ -729,11 +729,18 @@ static int bssmap_handle_assignm_req(struct gsm_subscriber_connection *conn,
goto reject;
}
- DEBUGP(DMSC, "Found matching audio type: %s %s for channel_type ="
- " { ch_indctr=0x%x, ch_rate_type=0x%x, perm_spch=[ %s] }\n",
+ DEBUGP(DCHAN, "Found matching audio type: %s %s for channel_type ="
+ " { ch_indctr=0x%x, ch_rate_type=0x%x, perm_spch=[ %s] }, s15_s0=0x%04x\n",
full_rate? "full rate" : "half rate",
get_value_string(gsm48_chan_mode_names, chan_mode),
- ct.ch_indctr, ct.ch_rate_type, osmo_hexdump(ct.perm_spch, ct.perm_spch_len));
+ ct.ch_indctr, ct.ch_rate_type, osmo_hexdump(ct.perm_spch, ct.perm_spch_len),
+ s15_s0);
+ if (log_check_level(DMSC, LOGL_DEBUG)) {
+ int i;
+ for (i = 0; i < ct.perm_spch_len; i++)
+ LOGP(DCHAN, LOGL_DEBUG, "perm_spch[%d] = 0x%02x = %s\n",
+ i, ct.perm_spch[i], gsm0808_permitted_speech_name(ct.perm_spch[i]));
+ }
req = (struct assignment_request){
.aoip = aoip,