<p>dexter has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/11296">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">codec_pref: also check physical channels<br><br>At the moment codec_pref only checks the codec configuration, but it<br>does not check if there is actually a matching physical channel<br>available. This should be checked too we must make sure that the codec<br>we select fits the physical channels available on the BTS.<br><br>Change-Id: I2d29dfed450e5ef93c26ed5ec9fdc0730eb3d7dd<br>Related: OS#3503<br>---<br>M src/osmo-bsc/codec_pref.c<br>M tests/codec_pref/codec_pref_test.c<br>2 files changed, 42 insertions(+), 4 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/96/11296/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/osmo-bsc/codec_pref.c b/src/osmo-bsc/codec_pref.c</span><br><span>index a741e11..9f30c7b 100644</span><br><span>--- a/src/osmo-bsc/codec_pref.c</span><br><span>+++ b/src/osmo-bsc/codec_pref.c</span><br><span>@@ -176,8 +176,38 @@</span><br><span> </span><br><span> /* Helper function to check if the given permitted speech value is supported</span><br><span>  * by the BTS. (vty option bts->codec-support). */</span><br><span style="color: hsl(0, 100%, 40%);">-static bool test_codec_support_bts(const struct bts_codec_conf *bts_codec, uint8_t perm_spch)</span><br><span style="color: hsl(120, 100%, 40%);">+static bool test_codec_support_bts(const struct gsm_bts *bts, uint8_t perm_spch)</span><br><span> {</span><br><span style="color: hsl(120, 100%, 40%);">+      struct gsm_bts_trx *trx;</span><br><span style="color: hsl(120, 100%, 40%);">+      const struct bts_codec_conf *bts_codec = &bts->codec;</span><br><span style="color: hsl(120, 100%, 40%);">+  unsigned int i;</span><br><span style="color: hsl(120, 100%, 40%);">+       bool full_rate;</span><br><span style="color: hsl(120, 100%, 40%);">+       int rc;</span><br><span style="color: hsl(120, 100%, 40%);">+       enum gsm_phys_chan_config pchan;</span><br><span style="color: hsl(120, 100%, 40%);">+      bool rate_match = false;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+    /* Check if the BTS provides a physical channel that matches the</span><br><span style="color: hsl(120, 100%, 40%);">+       * bandwith of the desired codec. */</span><br><span style="color: hsl(120, 100%, 40%);">+  rc = full_rate_from_perm_spch(&full_rate, perm_spch);</span><br><span style="color: hsl(120, 100%, 40%);">+     if (rc < 0)</span><br><span style="color: hsl(120, 100%, 40%);">+                return false;</span><br><span style="color: hsl(120, 100%, 40%);">+ llist_for_each_entry(trx, &bts->trx_list, list) {</span><br><span style="color: hsl(120, 100%, 40%);">+              for (i = 0; i < TRX_NR_TS; i++) {</span><br><span style="color: hsl(120, 100%, 40%);">+                  pchan = trx->ts[i].pchan_from_config;</span><br><span style="color: hsl(120, 100%, 40%);">+                      if (pchan == GSM_PCHAN_TCH_F_TCH_H_PDCH)</span><br><span style="color: hsl(120, 100%, 40%);">+                              rate_match = true;</span><br><span style="color: hsl(120, 100%, 40%);">+                    else if (full_rate && pchan == GSM_PCHAN_TCH_F)</span><br><span style="color: hsl(120, 100%, 40%);">+                               rate_match = true;</span><br><span style="color: hsl(120, 100%, 40%);">+                    else if (full_rate && pchan == GSM_PCHAN_TCH_F_PDCH)</span><br><span style="color: hsl(120, 100%, 40%);">+                          rate_match = true;</span><br><span style="color: hsl(120, 100%, 40%);">+                    else if (!full_rate && pchan == GSM_PCHAN_TCH_H)</span><br><span style="color: hsl(120, 100%, 40%);">+                              rate_match = true;</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%);">+     if (!rate_match)</span><br><span style="color: hsl(120, 100%, 40%);">+              return false;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+       /* Check codec support */</span><br><span>    switch (perm_spch) {</span><br><span>         case GSM0808_PERM_FR1:</span><br><span>               /* GSM-FR is always supported by all BTSs. There is also no way to</span><br><span>@@ -269,7 +299,7 @@</span><br><span> </span><br><span>                 /* Check this permitted speech value against the BTS specific parameters.</span><br><span>             * if the BTS does not support the codec, try the next one */</span><br><span style="color: hsl(0, 100%, 40%);">-           if (!test_codec_support_bts(&bts->codec, perm_spch))</span><br><span style="color: hsl(120, 100%, 40%);">+           if (!test_codec_support_bts(bts, perm_spch))</span><br><span>                         continue;</span><br><span> </span><br><span>                /* Match the permitted speech value against the codec lists that were</span><br><span>@@ -345,7 +375,7 @@</span><br><span> </span><br><span>              /* Check this permitted speech value against the BTS specific parameters.</span><br><span>             * if the BTS does not support the codec, try the next one */</span><br><span style="color: hsl(0, 100%, 40%);">-           if (!test_codec_support_bts(&bts->codec, perm_spch))</span><br><span style="color: hsl(120, 100%, 40%);">+           if (!test_codec_support_bts(bts, perm_spch))</span><br><span>                         continue;</span><br><span> </span><br><span>                /* Write item into codec list */</span><br><span>@@ -380,7 +410,7 @@</span><br><span>                       gen_bss_supported_codec_list(&scl, msc, bts);</span><br><span>                    if (scl.len <= 0) {</span><br><span>                               LOGP(DMSC, LOGL_FATAL,</span><br><span style="color: hsl(0, 100%, 40%);">-                               "codec-support of BTS %u does not intersect with codec-list of MSC %u\n",</span><br><span style="color: hsl(120, 100%, 40%);">+                                   "codec-support/trx config of BTS %u does not intersect with codec-list of MSC %u\n",</span><br><span>                               bts->nr, msc->nr);</span><br><span>                                rc = -1;</span><br><span>                     }</span><br><span>diff --git a/tests/codec_pref/codec_pref_test.c b/tests/codec_pref/codec_pref_test.c</span><br><span>index e2876e2..534b99e 100644</span><br><span>--- a/tests/codec_pref/codec_pref_test.c</span><br><span>+++ b/tests/codec_pref/codec_pref_test.c</span><br><span>@@ -294,6 +294,7 @@</span><br><span>         /* Note: FR is supported by all BTSs, so there is no flag for it */</span><br><span> </span><br><span>      struct gsm48_multi_rate_conf *cfg;</span><br><span style="color: hsl(120, 100%, 40%);">+    static struct gsm_bts_trx trx;</span><br><span> </span><br><span>   OSMO_ASSERT(config_no < N_CONFIG_VARIANTS);</span><br><span> </span><br><span>@@ -324,6 +325,13 @@</span><br><span>    cfg->m10_2 = 0;</span><br><span>   cfg->m12_2 = 0;</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+        /* Initalize TRX with a TCH/F and a TCH/H channel */</span><br><span style="color: hsl(120, 100%, 40%);">+  memset(&trx, 0, sizeof(trx));</span><br><span style="color: hsl(120, 100%, 40%);">+     INIT_LLIST_HEAD(&bts->trx_list);</span><br><span style="color: hsl(120, 100%, 40%);">+       llist_add(&trx.list, &bts->trx_list);</span><br><span style="color: hsl(120, 100%, 40%);">+      trx.ts[0].pchan_from_config = GSM_PCHAN_TCH_F;</span><br><span style="color: hsl(120, 100%, 40%);">+        trx.ts[1].pchan_from_config = GSM_PCHAN_TCH_H;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>     switch (config_no) {</span><br><span>         case 0:</span><br><span>              /* FR1 (implicit) only */</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/11296">change 11296</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/11296"/><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: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I2d29dfed450e5ef93c26ed5ec9fdc0730eb3d7dd </div>
<div style="display:none"> Gerrit-Change-Number: 11296 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: dexter <pmaier@sysmocom.de> </div>