<p>dexter has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/c/osmo-bsc/+/19790">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">lchan_fsm: merge lchan_mr_config()<br><br>There are some preperations and checks done before calling<br>lchan_mr_config(), those checks could also be done from inside<br>lchan_mr_config(), so lets merge them into lchan_mr_config()<br><br>Change-Id: I068aadda53b2c3a85ed4fb1e513b17bf9870bd50<br>---<br>M src/osmo-bsc/lchan_fsm.c<br>1 file changed, 21 insertions(+), 20 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/90/19790/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/osmo-bsc/lchan_fsm.c b/src/osmo-bsc/lchan_fsm.c</span><br><span>index 4ed95dd..05fb66f 100644</span><br><span>--- a/src/osmo-bsc/lchan_fsm.c</span><br><span>+++ b/src/osmo-bsc/lchan_fsm.c</span><br><span>@@ -415,8 +415,9 @@</span><br><span> }</span><br><span> </span><br><span> /* Configure the multirate setting on this channel. */</span><br><span style="color: hsl(0, 100%, 40%);">-static int lchan_mr_config(struct gsm_lchan *lchan, const struct gsm48_multi_rate_conf *mr_conf)</span><br><span style="color: hsl(120, 100%, 40%);">+static int lchan_mr_config(struct gsm_lchan *lchan, uint16_t s15_s0)</span><br><span> {</span><br><span style="color: hsl(120, 100%, 40%);">+ struct gsm48_multi_rate_conf mr_conf;</span><br><span>        bool full_rate = (lchan->type == GSM_LCHAN_TCH_F);</span><br><span>        struct gsm_bts *bts = lchan->ts->trx->bts;</span><br><span>  struct bsc_msc_data *msc = lchan->conn->sccp.msc;</span><br><span>@@ -426,6 +427,22 @@</span><br><span>       struct gsm48_multi_rate_conf mr_conf_filtered;</span><br><span>       const struct gsm48_multi_rate_conf *mr_conf_bts;</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+  /* Generate mr conf struct from S15-S0 bits */</span><br><span style="color: hsl(120, 100%, 40%);">+        if (gsm48_mr_cfg_from_gsm0808_sc_cfg(&mr_conf, s15_s0) < 0) {</span><br><span style="color: hsl(120, 100%, 40%);">+          LOG_LCHAN(lchan, LOGL_ERROR,</span><br><span style="color: hsl(120, 100%, 40%);">+                    "can not determine multirate configuration, S15-S0 (%04x) are ambiguous!\n", s15_s0);</span><br><span style="color: hsl(120, 100%, 40%);">+             return -EINVAL;</span><br><span style="color: hsl(120, 100%, 40%);">+       }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   /* Do not include 12.2 kbps rate when S1 is set. */</span><br><span style="color: hsl(120, 100%, 40%);">+   if (lchan->type == GSM_LCHAN_TCH_H && (s15_s0 & GSM0808_SC_CFG_AMR_4_75_5_90_7_40_12_20)) {</span><br><span style="color: hsl(120, 100%, 40%);">+            /* See also 3GPP TS 28.062, chapter 7.11.3.1.3: "In case this Configuration</span><br><span style="color: hsl(120, 100%, 40%);">+               * "Config-NB-Code = 1" is signalled in the TFO Negotiation for the HR_AMR</span><br><span style="color: hsl(120, 100%, 40%);">+           * Codec Type,then it shall be assumed that AMR mode 12.2 kbps is (of course)</span><br><span style="color: hsl(120, 100%, 40%);">+          * not included. */</span><br><span style="color: hsl(120, 100%, 40%);">+           mr_conf.m12_2 = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+    }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>  /* There are two different active sets, depending on the channel rate,</span><br><span>        * make sure the appropate one is selected. */</span><br><span>       if (full_rate)</span><br><span>@@ -438,7 +455,7 @@</span><br><span>          * interface. To ensure that the VTY settings are observed we create</span><br><span>          * a manipulated copy of the mr_conf that ensures forbidden codec rates</span><br><span>       * are not used in the multirate configuration IE. */</span><br><span style="color: hsl(0, 100%, 40%);">-   rc_rate = calc_amr_rate_intersection(&mr_conf_filtered, &msc->amr_conf, mr_conf);</span><br><span style="color: hsl(120, 100%, 40%);">+  rc_rate = calc_amr_rate_intersection(&mr_conf_filtered, &msc->amr_conf, &mr_conf);</span><br><span>    if (rc_rate < 0) {</span><br><span>                LOG_LCHAN(lchan, LOGL_ERROR,</span><br><span>                           "can not encode multirate configuration (invalid amr rate setting, MSC)\n");</span><br><span>@@ -478,6 +495,7 @@</span><br><span>               return -EINVAL;</span><br><span>      }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ lchan->s15_s0 = s15_s0;</span><br><span>   return 0;</span><br><span> }</span><br><span> </span><br><span>@@ -508,7 +526,6 @@</span><br><span> static void lchan_fsm_wait_ts_ready_onenter(struct osmo_fsm_inst *fi, uint32_t prev_state)</span><br><span> {</span><br><span>  struct gsm_lchan *lchan = lchan_fi_lchan(fi);</span><br><span style="color: hsl(0, 100%, 40%);">-   struct gsm48_multi_rate_conf mr_conf;</span><br><span>        struct gsm_bts *bts = lchan->ts->trx->bts;</span><br><span>  struct osmo_mgcpc_ep_ci *use_mgwep_ci;</span><br><span>       struct gsm_lchan *old_lchan = lchan->activate.info.re_use_mgw_endpoint_from_lchan;</span><br><span>@@ -537,26 +554,10 @@</span><br><span>        }</span><br><span> </span><br><span>        if (info->chan_mode == GSM48_CMODE_SPEECH_AMR) {</span><br><span style="color: hsl(0, 100%, 40%);">-             if (gsm48_mr_cfg_from_gsm0808_sc_cfg(&mr_conf, info->s15_s0) < 0) {</span><br><span style="color: hsl(0, 100%, 40%);">-                   lchan_fail("Can not determine multirate configuration, S15-S0 (%04x) are ambiguous!\n",</span><br><span style="color: hsl(0, 100%, 40%);">-                                  info->s15_s0);</span><br><span style="color: hsl(0, 100%, 40%);">-                    return;</span><br><span style="color: hsl(0, 100%, 40%);">-         }</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-               /* Do not include 12.2 kbps rate when S1 is set. */</span><br><span style="color: hsl(0, 100%, 40%);">-             if (lchan->type == GSM_LCHAN_TCH_H && (info->s15_s0 & GSM0808_SC_CFG_AMR_4_75_5_90_7_40_12_20)) {</span><br><span style="color: hsl(0, 100%, 40%);">-                     /* See also 3GPP TS 28.062, chapter 7.11.3.1.3: "In case this Configuration</span><br><span style="color: hsl(0, 100%, 40%);">-                         * "Config-NB-Code = 1" is signalled in the TFO Negotiation for the HR_AMR</span><br><span style="color: hsl(0, 100%, 40%);">-                     * Codec Type,then it shall be assumed that AMR mode 12.2 kbps is (of course)</span><br><span style="color: hsl(0, 100%, 40%);">-                    * not included. */</span><br><span style="color: hsl(0, 100%, 40%);">-                     mr_conf.m12_2 = 0;</span><br><span style="color: hsl(0, 100%, 40%);">-              }</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-               if (lchan_mr_config(lchan, &mr_conf) < 0) {</span><br><span style="color: hsl(120, 100%, 40%);">+            if (lchan_mr_config(lchan, info->s15_s0) < 0) {</span><br><span>                        lchan_fail("Can not generate multirate configuration IE\n");</span><br><span>                       return;</span><br><span>              }</span><br><span style="color: hsl(0, 100%, 40%);">-               lchan->s15_s0 = info->s15_s0;</span><br><span>  }</span><br><span> </span><br><span>        switch (info->chan_mode) {</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/osmo-bsc/+/19790">change 19790</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/c/osmo-bsc/+/19790"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: osmo-bsc </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: I068aadda53b2c3a85ed4fb1e513b17bf9870bd50 </div>
<div style="display:none"> Gerrit-Change-Number: 19790 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: dexter <pmaier@sysmocom.de> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>