aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVadim Yanitskiy <vyanitskiy@sysmocom.de>2022-04-12 13:55:52 +0300
committerVadim Yanitskiy <vyanitskiy@sysmocom.de>2022-04-13 18:04:20 +0300
commitcf3d314501a01632e9646825e90932279cf339ea (patch)
tree12326e09c614fddae8b7a60e8319c312e6529194
parentc02876eae2cc8130783bfce4d976c72356855fc7 (diff)
rsl: use hard-coded defaults if the MultiRate conf IE is absent
This configuration will be used as a fall-back when the MultiRate configuration IE is not included in the CHAN ACT/MODIFY messages. Change-Id: Ie96af636105ee1ffe2d9a0bd9eea375faebad149 Related: osmo-bsc.git Ic5f8d55d250976d8d4c9cae2d89480fd52326717 Related: SYS#5917, OS#4984
-rw-r--r--include/osmo-bts/amr.h1
-rw-r--r--src/common/amr.c102
-rw-r--r--src/common/rsl.c5
3 files changed, 107 insertions, 1 deletions
diff --git a/include/osmo-bts/amr.h b/include/osmo-bts/amr.h
index f3132874..3fa4b8f2 100644
--- a/include/osmo-bts/amr.h
+++ b/include/osmo-bts/amr.h
@@ -14,5 +14,6 @@ int amr_parse_mr_conf(struct amr_multirate_conf *amr_mrc,
void amr_set_mode_pref(uint8_t *data, const struct amr_multirate_conf *amr_mrc,
uint8_t cmi, uint8_t cmr);
unsigned int amr_get_initial_mode(struct gsm_lchan *lchan);
+void amr_init_mr_conf_def(struct gsm_lchan *lchan);
#endif /* _OSMO_BTS_AMR_H */
diff --git a/src/common/amr.c b/src/common/amr.c
index 837757fe..53ce24d6 100644
--- a/src/common/amr.c
+++ b/src/common/amr.c
@@ -6,6 +6,85 @@
#include <osmo-bts/logging.h>
#include <osmo-bts/amr.h>
+/* Reasonable defaults for AMR-FR and AMR-HR rate configuration.
+ * The values are taken from 3GPP TS 51.010-1 (version 13.11.0).
+ * See 14.2.19.4.1 and 14.2.20.4.1 for AMR-FR and AMR-HR, respectively.
+ *
+ * ^ C/I (dB) | FR / HR |
+ * | |
+ * | |
+ * MODE4 | |
+ * = | ----+---- THR_MX_Up(3) | 20.5 / 18.0 |
+ * | | |
+ * | = ----+---- THR_MX_Dn(4) | 18.5 / 16.0 |
+ * MODE3 | |
+ * | = ----+---- THR_MX_Up(2) | 14.5 / 14.0 |
+ * | | |
+ * = | ----+---- THR_MX_Dn(3) | 12.5 / 12.0 |
+ * MODE2 | |
+ * = | ----+---- THR_MX_Up(1) | 8.5 / 10.0 |
+ * | | |
+ * | = ----+---- THR_MX_Dn(2) | 6.5 / 8.0 |
+ * MODE1 | |
+ * | |
+ * | |
+ */
+static const struct gsm48_multi_rate_conf amr_fr_mr_cfg_def = {
+ .m4_75 = 1,
+ .m5_90 = 1,
+ .m7_95 = 1,
+ .m12_2 = 1,
+};
+static const struct amr_mode amr_fr_bts_mode_def[] = {
+ {
+ .mode = 0, /* 4.75k */
+ .threshold = 13, /* THR_MX_Dn(2): 6.5 dB */
+ .hysteresis = 4, /* THR_MX_Up(1): 8.5 dB */
+ },
+ {
+ .mode = 2, /* 5.90k */
+ .threshold = 25, /* THR_MX_Dn(3): 12.5 dB */
+ .hysteresis = 4, /* THR_MX_Up(2): 14.5 dB */
+ },
+ {
+ .mode = 5, /* 7.95k */
+ .threshold = 37, /* THR_MX_Dn(4): 18.5 dB */
+ .hysteresis = 4, /* THR_MX_Up(3): 20.5 dB */
+ },
+ {
+ .mode = 7, /* 12.2k */
+ /* this is the last mode, so no threshold */
+ },
+};
+
+static const struct gsm48_multi_rate_conf amr_hr_mr_cfg_def = {
+ .m4_75 = 1,
+ .m5_90 = 1,
+ .m6_70 = 1,
+ .m7_95 = 1,
+};
+static const struct amr_mode amr_hr_bts_mode_def[] = {
+ {
+ .mode = 0, /* 4.75k */
+ .threshold = 16, /* THR_MX_Dn(2): 8.0 dB */
+ .hysteresis = 4, /* THR_MX_Up(1): 10.0 dB */
+ },
+ {
+ .mode = 2, /* 5.90k */
+ .threshold = 24, /* THR_MX_Dn(3): 12.0 dB */
+ .hysteresis = 4, /* THR_MX_Up(2): 14.0 dB */
+ },
+ {
+ .mode = 3, /* 6.70k */
+ .threshold = 32, /* THR_MX_Dn(4): 16.0 dB */
+ .hysteresis = 4, /* THR_MX_Up(3): 18.0 dB */
+ },
+ {
+ .mode = 5, /* 7.95k */
+ /* this is the last mode, so no threshold */
+ },
+};
+
void amr_log_mr_conf(int ss, int logl, const char *pfx,
struct amr_multirate_conf *amr_mrc)
{
@@ -171,3 +250,26 @@ unsigned int amr_get_initial_mode(struct gsm_lchan *lchan)
}
}
}
+
+void amr_init_mr_conf_def(struct gsm_lchan *lchan)
+{
+ const struct gsm48_multi_rate_conf *mr_cfg;
+ const struct amr_mode *bts_mode;
+ unsigned int num_modes;
+
+ if (lchan->type == GSM_LCHAN_TCH_F) {
+ num_modes = ARRAY_SIZE(amr_fr_bts_mode_def);
+ bts_mode = &amr_fr_bts_mode_def[0];
+ mr_cfg = &amr_fr_mr_cfg_def;
+ } else {
+ num_modes = ARRAY_SIZE(amr_hr_bts_mode_def);
+ bts_mode = &amr_hr_bts_mode_def[0];
+ mr_cfg = &amr_hr_mr_cfg_def;
+ }
+
+ memcpy(lchan->tch.amr_mr.gsm48_ie, mr_cfg,
+ sizeof(lchan->tch.amr_mr.gsm48_ie));
+ memcpy(&lchan->tch.amr_mr.bts_mode[0], &bts_mode[0],
+ sizeof(lchan->tch.amr_mr.bts_mode));
+ lchan->tch.amr_mr.num_modes = num_modes;
+}
diff --git a/src/common/rsl.c b/src/common/rsl.c
index 59bc799d..94d00226 100644
--- a/src/common/rsl.c
+++ b/src/common/rsl.c
@@ -1644,7 +1644,9 @@ static int parse_multirate_config(struct gsm_lchan *lchan,
if (lchan->tch_mode == GSM48_CMODE_SPEECH_AMR) {
LOGPLCHAN(lchan, DRSL, LOGL_NOTICE, "Missing MultiRate conf IE "
"(TCH mode is %s)\n", gsm48_chan_mode_name(lchan->tch_mode));
- /* TODO: init lchan->tch.amr_mr with some default values */
+ /* Init lchan->tch.amr_mr with hard-coded default values */
+ amr_init_mr_conf_def(lchan);
+ goto parsed;
}
return 0;
}
@@ -1664,6 +1666,7 @@ static int parse_multirate_config(struct gsm_lchan *lchan,
return -RSL_ERR_IE_CONTENT;
}
+parsed:
amr_log_mr_conf(DRTP, LOGL_DEBUG, gsm_lchan_name(lchan), &lchan->tch.amr_mr);
lchan->tch.last_cmr = AMR_CMR_NONE;
return 0;