<p>dexter <strong>merged</strong> this change.</p><p><a href="https://gerrit.osmocom.org/11442">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">codec_pref: also check amr codec rates in check_codec_pref()<br><br>The function check_codec_pref() currently only does a basic check over<br>the general codec configuration of bts and msc. However, it does not yet<br>check if the amr codec rate settings for the BTSs contradict the<br>allowed/forbidden amr codec rates of the MSC. When the two settings do<br>contradict AMR would not work, even when everything else is correctly<br>configured. We need to check this on startup to spot configuration<br>problems quickly.<br><br>- Add function to calculate intersections of struct<br>  gsm48_multi_rate_conf variables.<br>- Calculate the intersection between the multi rate config of<br>  each BTS with the one of the MSC<br><br>Change-Id: I3537d1c89e2520d35cc0e150ba8e6d3693e06710<br>Related: OS#3529<br>---<br>M include/osmocom/bsc/codec_pref.h<br>M src/osmo-bsc/codec_pref.c<br>2 files changed, 53 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/include/osmocom/bsc/codec_pref.h b/include/osmocom/bsc/codec_pref.h</span><br><span>index d62d29f..51340c1 100644</span><br><span>--- a/include/osmocom/bsc/codec_pref.h</span><br><span>+++ b/include/osmocom/bsc/codec_pref.h</span><br><span>@@ -22,4 +22,8 @@</span><br><span>                            const struct bsc_msc_data *msc,</span><br><span>                              const struct gsm_bts *bts);</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+int calc_amr_rate_intersection(struct gsm48_multi_rate_conf *c,</span><br><span style="color: hsl(120, 100%, 40%);">+                           const struct gsm48_multi_rate_conf *b,</span><br><span style="color: hsl(120, 100%, 40%);">+                        const struct gsm48_multi_rate_conf *a);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> int check_codec_pref(struct llist_head *mscs);</span><br><span>diff --git a/src/osmo-bsc/codec_pref.c b/src/osmo-bsc/codec_pref.c</span><br><span>index 9f30c7b..c99c383 100644</span><br><span>--- a/src/osmo-bsc/codec_pref.c</span><br><span>+++ b/src/osmo-bsc/codec_pref.c</span><br><span>@@ -393,6 +393,35 @@</span><br><span>   }</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+/*! Calculate the intersection of the rate configuration of two multirate configuration</span><br><span style="color: hsl(120, 100%, 40%);">+ *  IE structures. The result c will be a copy of a, but the rate configuration bits</span><br><span style="color: hsl(120, 100%, 40%);">+ *  will be the intersection of the rate configuration bits in a and b.</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \param[out] c user provided memory to store the result.</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \param[in] a multi rate configuration a.</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \param[in] b multi rate configuration b.</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \returns 0 on success, -1 when the result contains an empty set of modes. */</span><br><span style="color: hsl(120, 100%, 40%);">+int calc_amr_rate_intersection(struct gsm48_multi_rate_conf *c,</span><br><span style="color: hsl(120, 100%, 40%);">+                               const struct gsm48_multi_rate_conf *b,</span><br><span style="color: hsl(120, 100%, 40%);">+                        const struct gsm48_multi_rate_conf *a)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+      struct gsm48_multi_rate_conf res;</span><br><span style="color: hsl(120, 100%, 40%);">+     uint8_t *_a = (uint8_t *) a;</span><br><span style="color: hsl(120, 100%, 40%);">+  uint8_t *_b = (uint8_t *) b;</span><br><span style="color: hsl(120, 100%, 40%);">+  uint8_t *_res = (uint8_t *) & res;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+      memcpy(&res, a, sizeof(res));</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   _res[1] = _a[1] & _b[1];</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+        if (_res[1] == 0x00)</span><br><span style="color: hsl(120, 100%, 40%);">+          return -1;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+  if (c)</span><br><span style="color: hsl(120, 100%, 40%);">+                memcpy(c, &res, sizeof(*c));</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+    return 0;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> /*! Visit the codec settings for the MSC and for each BTS in order to make sure</span><br><span>  *  that the configuration does not contain any combinations that lead into a</span><br><span>  *  mutually exclusive codec configuration (empty intersection).</span><br><span>@@ -404,6 +433,8 @@</span><br><span>         struct gsm_bts *bts;</span><br><span>         struct gsm0808_speech_codec_list scl;</span><br><span>        int rc = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+   int rc_rate;</span><br><span style="color: hsl(120, 100%, 40%);">+  const struct gsm48_multi_rate_conf *bts_gsm48_ie;</span><br><span> </span><br><span>        llist_for_each_entry(msc, mscs, entry) {</span><br><span>             llist_for_each_entry(bts, &msc->network->bts_list, list) {</span><br><span>@@ -414,6 +445,24 @@</span><br><span>                               bts->nr, msc->nr);</span><br><span>                                rc = -1;</span><br><span>                     }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+                   bts_gsm48_ie = (struct gsm48_multi_rate_conf *)&bts->mr_full.gsm48_ie;</span><br><span style="color: hsl(120, 100%, 40%);">+                 rc_rate = calc_amr_rate_intersection(NULL, &msc->amr_conf, bts_gsm48_ie);</span><br><span style="color: hsl(120, 100%, 40%);">+                      if (rc_rate < 0) {</span><br><span style="color: hsl(120, 100%, 40%);">+                         LOGP(DMSC, LOGL_FATAL,</span><br><span style="color: hsl(120, 100%, 40%);">+                                     "network amr tch-f mode config of BTS %u does not intersect with amr-config of MSC %u\n",</span><br><span style="color: hsl(120, 100%, 40%);">+                                   bts->nr, msc->nr);</span><br><span style="color: hsl(120, 100%, 40%);">+                         rc = -1;</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%);">+                   bts_gsm48_ie = (struct gsm48_multi_rate_conf *)&bts->mr_half.gsm48_ie;</span><br><span style="color: hsl(120, 100%, 40%);">+                 rc_rate = calc_amr_rate_intersection(NULL, &msc->amr_conf, bts_gsm48_ie);</span><br><span style="color: hsl(120, 100%, 40%);">+                      if (rc_rate < 0) {</span><br><span style="color: hsl(120, 100%, 40%);">+                         LOGP(DMSC, LOGL_FATAL,</span><br><span style="color: hsl(120, 100%, 40%);">+                                     "network amr tch-h mode config of BTS %u does not intersect with amr-config of MSC %u\n",</span><br><span style="color: hsl(120, 100%, 40%);">+                                   bts->nr, msc->nr);</span><br><span style="color: hsl(120, 100%, 40%);">+                         rc = -1;</span><br><span style="color: hsl(120, 100%, 40%);">+                      }</span><br><span>            }</span><br><span>    }</span><br><span> </span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/11442">change 11442</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/11442"/><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-MessageType: merged </div>
<div style="display:none"> Gerrit-Change-Id: I3537d1c89e2520d35cc0e150ba8e6d3693e06710 </div>
<div style="display:none"> Gerrit-Change-Number: 11442 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </div>
<div style="display:none"> Gerrit-Owner: dexter <pmaier@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: Harald Welte <laforge@gnumonks.org> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins Builder (1000002) </div>
<div style="display:none"> Gerrit-Reviewer: dexter <pmaier@sysmocom.de> </div>