fixeria has submitted this change. ( 
https://gerrit.osmocom.org/c/osmo-bts/+/27757 )

Change subject: rsl: use hard-coded defaults if the MultiRate conf IE is absent
......................................................................

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
---
M include/osmo-bts/amr.h
M src/common/amr.c
M src/common/rsl.c
3 files changed, 107 insertions(+), 1 deletion(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, but someone else must approve
  fixeria: Looks good to me, approved



diff --git a/include/osmo-bts/amr.h b/include/osmo-bts/amr.h
index f313287..3fa4b8f 100644
--- a/include/osmo-bts/amr.h
+++ b/include/osmo-bts/amr.h
@@ -14,5 +14,6 @@
 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 837757f..53ce24d 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 @@
                }
        }
 }
+
+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 59bc799..94d0022 100644
--- a/src/common/rsl.c
+++ b/src/common/rsl.c
@@ -1644,7 +1644,9 @@
                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 @@
                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;

--
To view, visit https://gerrit.osmocom.org/c/osmo-bts/+/27757
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Change-Id: Ie96af636105ee1ffe2d9a0bd9eea375faebad149
Gerrit-Change-Number: 27757
Gerrit-PatchSet: 3
Gerrit-Owner: fixeria <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <[email protected]>
Gerrit-Reviewer: laforge <[email protected]>
Gerrit-Reviewer: pespin <[email protected]>
Gerrit-MessageType: merged

Reply via email to