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/.
Max gerrit-no-reply at lists.osmocom.orgReview at https://gerrit.osmocom.org/1508 DTX AMR HR: fix inhibition Unlike in AMR FR, in AMR HR incoming ONSET have to be treated differently depending on whether we've recently sent SID UPDATE or EMPTY frame. Split ST_SID_U FSM state into 2 states to accommodate for that and make sure that additional states specific to AMR HR are not used for AMR FR. Also, avoid sending E_VOICE and E_SID_U in corresponding states as those do not initiate FSM state transitions anyway. This decrease extra load from FSM signalling which otherwise would be triggered on per-frame basis. Change-Id: I229ba39a38a223fada4881fc9aca35d3639371f8 Related: OS#1801 --- M include/osmo-bts/dtx_dl_amr_fsm.h M src/common/bts.c M src/common/dtx_dl_amr_fsm.c M src/common/msg_utils.c M src/osmo-bts-litecell15/tch.c M src/osmo-bts-sysmo/tch.c 6 files changed, 118 insertions(+), 35 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/08/1508/1 diff --git a/include/osmo-bts/dtx_dl_amr_fsm.h b/include/osmo-bts/dtx_dl_amr_fsm.h index 4fb2f25..9ea3fc2 100644 --- a/include/osmo-bts/dtx_dl_amr_fsm.h +++ b/include/osmo-bts/dtx_dl_amr_fsm.h @@ -14,6 +14,7 @@ ST_SID_F2, ST_F1_INH, ST_U_INH, + ST_U_NOINH, ST_F1_INH_REC, ST_U_INH_REC, ST_SID_U, diff --git a/src/common/bts.c b/src/common/bts.c index 9c2f0e0..d249137 100644 --- a/src/common/bts.c +++ b/src/common/bts.c @@ -45,6 +45,7 @@ #include <osmo-bts/rsl.h> #include <osmo-bts/oml.h> #include <osmo-bts/signal.h> +#include <osmo-bts/dtx_dl_amr_fsm.h> #define MIN_QUAL_RACH 5.0f /* at least 5 dB C/I */ #define MIN_QUAL_NORM -0.5f /* at least -1 dB C/I */ diff --git a/src/common/dtx_dl_amr_fsm.c b/src/common/dtx_dl_amr_fsm.c index d903b0c..1bf1f74 100644 --- a/src/common/dtx_dl_amr_fsm.c +++ b/src/common/dtx_dl_amr_fsm.c @@ -47,7 +47,7 @@ Was observed during testing, let's just ignore it for now */ break; case E_SID_U: - osmo_fsm_inst_state_chg(fi, ST_SID_U, 0, 0); + osmo_fsm_inst_state_chg(fi, ST_U_NOINH, 0, 0); break; case E_VOICE: osmo_fsm_inst_state_chg(fi, ST_VOICE, 0, 0); @@ -74,7 +74,7 @@ void dtx_fsm_sid_f2(struct osmo_fsm_inst *fi, uint32_t event, void *data) { switch (event) { - case E_SID_U: + case E_COMPL: osmo_fsm_inst_state_chg(fi, ST_SID_U, 0, 0); break; case E_VOICE: @@ -145,6 +145,33 @@ } } +void dtx_fsm_u_noinh(struct osmo_fsm_inst *fi, uint32_t event, void *data) +{ + switch (event) { + case E_FACCH: + osmo_fsm_inst_state_chg(fi, ST_ONSET_F, 0, 0); + break; + case E_VOICE: + osmo_fsm_inst_state_chg(fi, ST_VOICE, 0, 0); + break; + case E_COMPL: + osmo_fsm_inst_state_chg(fi, ST_SID_U, 0, 0); + break; + case E_SID_U: + case E_SID_F: +/* FIXME: what shall we do if we get SID-FIRST _after_ sending SID-UPDATE? + Was observed during testing, let's just ignore it for now */ + break; + case E_ONSET: + osmo_fsm_inst_state_chg(fi, ST_ONSET_V, 0, 0); + break; + default: + LOGP(DL1P, LOGL_ERROR, "Unexpected event %d\n", event); + OSMO_ASSERT(0); + break; + } +} + void dtx_fsm_sid_upd(struct osmo_fsm_inst *fi, uint32_t event, void *data) { switch (event) { @@ -159,11 +186,7 @@ break; case E_SID_U: case E_SID_F: -/* FIXME: what shall we do if we get SID-FIRST _after_ sending SID-UPDATE? - Was observed during testing, let's just ignore it for now */ - break; - case E_ONSET: - osmo_fsm_inst_state_chg(fi, ST_ONSET_V, 0, 0); + osmo_fsm_inst_state_chg(fi, ST_U_NOINH, 0, 0); break; default: LOGP(DL1P, LOGL_ERROR, "Unexpected event %d\n", event); @@ -256,14 +279,14 @@ start of silence period (might be interrupted in case of AMR HR) */ [ST_SID_F1]= { .in_event_mask = X(E_SID_F) | X(E_SID_U) | X(E_VOICE) | X(E_FACCH) | X(E_COMPL) | X(E_INHIB) | X(E_ONSET), - .out_state_mask = X(ST_SID_U) | X(ST_VOICE) | X(ST_ONSET_F) | X(ST_SID_F2) | X(ST_F1_INH) | X(ST_ONSET_V), + .out_state_mask = X(ST_U_NOINH) | X(ST_VOICE) | X(ST_ONSET_F) | X(ST_SID_F2) | X(ST_F1_INH) | X(ST_ONSET_V), .name = "SID-FIRST (P1)", .action = dtx_fsm_sid_f1, }, /* SID-FIRST P2 (only for AMR HR): actual start of silence period in case of AMR HR */ [ST_SID_F2]= { - .in_event_mask = X(E_SID_U) | X(E_VOICE) | X(E_FACCH) | X(E_ONSET), + .in_event_mask = X(E_COMPL) | X(E_VOICE) | X(E_FACCH) | X(E_ONSET), .out_state_mask = X(ST_SID_U) | X(ST_VOICE) | X(ST_ONSET_F) | X(ST_ONSET_V), .name = "SID-FIRST (P2)", .action = dtx_fsm_sid_f2, @@ -281,6 +304,13 @@ .out_state_mask = X(ST_U_INH_REC), .name = "SID-UPDATE (Inh)", .action = dtx_fsm_u_inh, + }, + /* SID-UPDATE: Inhibited not allowed (only for AMR HR) */ + [ST_U_NOINH]= { + .in_event_mask = X(E_FACCH) | X(E_VOICE) | X(E_COMPL) | X(E_SID_U) | X(E_SID_F) | X(E_ONSET), + .out_state_mask = X(ST_ONSET_F) | X(ST_VOICE) | X(ST_SID_U) | X(ST_ONSET_V), + .name = "SID-UPDATE (NoInh)", + .action = dtx_fsm_u_noinh, }, /* SID-FIRST Inhibition recursion in progress: Inhibit itself was already sent, now have to send the voice that caused it */ @@ -300,9 +330,9 @@ }, /* Silence period with periodic comfort noise data updates */ [ST_SID_U]= { - .in_event_mask = X(E_FACCH) | X(E_VOICE) | X(E_INHIB) | X(E_SID_U) | X(E_SID_F) | X(E_ONSET), - .out_state_mask = X(ST_ONSET_F) | X(ST_VOICE) | X(ST_U_INH) | X(ST_SID_U) | X(ST_ONSET_V), - .name = "SID-UPDATE", + .in_event_mask = X(E_FACCH) | X(E_VOICE) | X(E_INHIB) | X(E_SID_U) | X(E_SID_F), + .out_state_mask = X(ST_ONSET_F) | X(ST_VOICE) | X(ST_U_INH) | X(ST_U_NOINH), + .name = "SID-UPDATE (AMR/HR)", .action = dtx_fsm_sid_upd, }, /* ONSET - end of silent period due to incoming SPEECH frame */ diff --git a/src/common/msg_utils.c b/src/common/msg_utils.c index 9de9b6d..e7a09f9 100644 --- a/src/common/msg_utils.c +++ b/src/common/msg_utils.c @@ -93,6 +93,28 @@ return type; } +/* check that DTX is in the middle of silence */ +static inline bool dtx_is_update(const struct gsm_lchan *lchan) +{ + if (!dtx_dl_amr_enabled(lchan)) + return false; + if (lchan->tch.dtx.dl_amr_fsm->state == ST_SID_U || + lchan->tch.dtx.dl_amr_fsm->state == ST_U_NOINH) + return true; + return false; +} + +/* check that DTX is in the beginning of silence for AMR HR */ +static inline bool dtx_is_first_p1(const struct gsm_lchan *lchan) +{ + if (!dtx_dl_amr_enabled(lchan)) + return false; + if ((lchan->type == GSM_LCHAN_TCH_H && + lchan->tch.dtx.dl_amr_fsm->state == ST_SID_F1)) + return true; + return false; +} + /* update lchan SID status */ void lchan_set_marker(bool t, struct gsm_lchan *lchan) { @@ -123,9 +145,7 @@ if (update == 0) { lchan->tch.dtx.is_update = false; /* Mark SID FIRST explicitly */ /* for non-AMR case - always update FN for incoming SID FIRST */ - if (!amr || - (dtx_dl_amr_enabled(lchan) && - lchan->tch.dtx.dl_amr_fsm->state != ST_SID_U)) + if (!amr || !dtx_is_update(lchan)) lchan->tch.dtx.fn = fn; /* for AMR case - do not update FN if SID FIRST arrives in a middle of silence: this should not be happening according to @@ -157,12 +177,24 @@ int rc; if (dtx_dl_amr_enabled(lchan)) { - if (lchan->type == GSM_LCHAN_TCH_H && - lchan->tch.dtx.dl_amr_fsm->state == ST_SID_F2 && !rtp_pl) { - *len = 3; /* SID-FIRST P1 -> P2 completion */ - memcpy(l1_payload, lchan->tch.dtx.cache, 2); - dtx_dispatch(lchan, E_SID_U); - return 0; + if (lchan->type == GSM_LCHAN_TCH_H && !rtp_pl) { + /* we're called by gen_empty_tch_msg() to handle states + specific to AMR HR DTX */ + switch (lchan->tch.dtx.dl_amr_fsm->state) { + case ST_SID_F2: + *len = 3; /* SID-FIRST P1 -> P2 completion */ + memcpy(l1_payload, lchan->tch.dtx.cache, 2); + rc = 0; + dtx_dispatch(lchan, E_COMPL); + break; + case ST_SID_U: + rc = -EBADMSG; + dtx_dispatch(lchan, E_SID_U); + break; + default: + rc = -EBADMSG; + } + return rc; } } @@ -171,8 +203,8 @@ rc = osmo_amr_rtp_dec(rtp_pl, rtp_pl_len, &cmr, &cmi, &ft, &bfi, &sti); if (rc < 0) { - LOGP(DRTP, LOGL_ERROR, "failed to decode AMR RTP (length %zu)\n", - rtp_pl_len); + LOGP(DRTP, LOGL_ERROR, "failed to decode AMR RTP (length %zu, " + "%p)\n", rtp_pl_len, rtp_pl); return rc; } @@ -197,19 +229,29 @@ return 0; if (osmo_amr_is_speech(ft)) { - /* AMR HR - Inhibition */ - if (lchan->type == GSM_LCHAN_TCH_H && marker && - lchan->tch.dtx.dl_amr_fsm->state == ST_SID_F1) + /* AMR HR - SID-FIRST_P1 Inhibition */ + if (marker && dtx_is_first_p1(lchan)) return osmo_fsm_inst_dispatch(lchan->tch.dtx.dl_amr_fsm, E_INHIB, (void *)lchan); + + /* AMR HR - SID-UPDATE Inhibition */ + if (marker && lchan->type == GSM_LCHAN_TCH_H && + lchan->tch.dtx.dl_amr_fsm->state == ST_SID_U) + return osmo_fsm_inst_dispatch(lchan->tch.dtx.dl_amr_fsm, + E_INHIB, (void *)lchan); + /* AMR FR & HR - generic */ if (marker && (lchan->tch.dtx.dl_amr_fsm->state == ST_SID_F1 || lchan->tch.dtx.dl_amr_fsm->state == ST_SID_F2 || - lchan->tch.dtx.dl_amr_fsm->state == ST_SID_U )) + lchan->tch.dtx.dl_amr_fsm->state == ST_U_NOINH)) return osmo_fsm_inst_dispatch(lchan->tch.dtx.dl_amr_fsm, E_ONSET, (void *)lchan); - return osmo_fsm_inst_dispatch(lchan->tch.dtx.dl_amr_fsm, E_VOICE, - (void *)lchan); + + if (lchan->tch.dtx.dl_amr_fsm->state != ST_VOICE) + return osmo_fsm_inst_dispatch(lchan->tch.dtx.dl_amr_fsm, + E_VOICE, (void *)lchan); + + return 0; } if (ft == AMR_SID) { @@ -222,6 +264,9 @@ E_SID_F, (void *)lchan); } else dtx_cache_payload(lchan, rtp_pl, rtp_pl_len, fn, sti); + if (lchan->tch.dtx.dl_amr_fsm->state == ST_SID_F2) + return osmo_fsm_inst_dispatch(lchan->tch.dtx.dl_amr_fsm, + E_COMPL, (void *)lchan); return osmo_fsm_inst_dispatch(lchan->tch.dtx.dl_amr_fsm, sti ? E_SID_U : E_SID_F, (void *)lchan); @@ -357,6 +402,7 @@ return false; if (lchan->tch.dtx.dl_amr_fsm->state == ST_U_INH || + lchan->tch.dtx.dl_amr_fsm->state == ST_U_INH_REC || lchan->tch.dtx.dl_amr_fsm->state == ST_F1_INH || lchan->tch.dtx.dl_amr_fsm->state == ST_ONSET_F || lchan->tch.dtx.dl_amr_fsm->state == ST_ONSET_V || @@ -389,9 +435,7 @@ if (!dtx_dl_amr_enabled(lchan)) return; - if ((lchan->type == GSM_LCHAN_TCH_H && - lchan->tch.dtx.dl_amr_fsm->state == ST_SID_F1) || - dtx_recursion(lchan)) + if (dtx_is_first_p1(lchan) || dtx_recursion(lchan)) dtx_dispatch(lchan, E_COMPL); } @@ -425,12 +469,17 @@ osmo_fsm_inst_dispatch(lchan->tch.dtx.dl_amr_fsm, E_SID_U, (void *)lchan); dtx_sti_unset(lchan); - } else if (lchan->tch.dtx.dl_amr_fsm->state == - ST_SID_U) { + } else if (dtx_is_update(lchan)) { /* enforce SID UPDATE for next repetition: it might have been altered by FACCH handling */ dtx_sti_set(lchan); - lchan->tch.dtx.is_update = true; + if (lchan->type == GSM_LCHAN_TCH_H && + lchan->tch.dtx.dl_amr_fsm->state == + ST_U_NOINH) + osmo_fsm_inst_dispatch(lchan->tch.dtx.dl_amr_fsm, + E_COMPL, + (void *)lchan); + lchan->tch.dtx.is_update = true; } } memcpy(dst, lchan->tch.dtx.cache, lchan->tch.dtx.len); diff --git a/src/osmo-bts-litecell15/tch.c b/src/osmo-bts-litecell15/tch.c index de3c7e3..a47a88f 100644 --- a/src/osmo-bts-litecell15/tch.c +++ b/src/osmo-bts-litecell15/tch.c @@ -322,6 +322,7 @@ dtx_cache_payload(lchan, rtp_pl, rtp_pl_len, fn, 0); return 1; case ST_SID_U: + case ST_U_NOINH: return -EAGAIN; case ST_FACCH: return -EBADMSG; diff --git a/src/osmo-bts-sysmo/tch.c b/src/osmo-bts-sysmo/tch.c index 16c2cf3..bc495d9 100644 --- a/src/osmo-bts-sysmo/tch.c +++ b/src/osmo-bts-sysmo/tch.c @@ -420,6 +420,7 @@ dtx_cache_payload(lchan, rtp_pl, rtp_pl_len, fn, 0); return 1; case ST_SID_U: + case ST_U_NOINH: return -EAGAIN; case ST_FACCH: return -EBADMSG; -- To view, visit https://gerrit.osmocom.org/1508 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I229ba39a38a223fada4881fc9aca35d3639371f8 Gerrit-PatchSet: 1 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Max <msuraev at sysmocom.de>