<p>pespin <strong>submitted</strong> this change.</p><p><a href="https://gerrit.osmocom.org/c/osmo-bsc/+/24876">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  laforge: Looks good to me, but someone else must approve
  daniel: Looks good to me, approved
  Jenkins Builder: Verified

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">Avoid switching dyn ts to sdcch8 if it starves later TCH<br><br>In case an MS requests a channel to establish a voice call, we usuually<br>try to assign an SDCCH to negotiate the call and finally make the MS<br>switch to a TCH. However, it doesn't make much sense to provoke a switch<br>of a dynamic TS into SDCCH8 if that would mean we end up with no TS<br>available for TCH at the next step close in time. In that case, we are<br>better assigning the TCH directly so that the full call can be<br>established successfully.<br><br>Related: SYS#5309<br>Change-Id: I3b32968949a7bdcbebf5a823359295bac51d8e08<br>---<br>M src/osmo-bsc/abis_rsl.c<br>1 file changed, 63 insertions(+), 3 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/osmo-bsc/abis_rsl.c b/src/osmo-bsc/abis_rsl.c</span><br><span>index f941d7e..b41fe79 100644</span><br><span>--- a/src/osmo-bsc/abis_rsl.c</span><br><span>+++ b/src/osmo-bsc/abis_rsl.c</span><br><span>@@ -1912,6 +1912,62 @@</span><br><span>      return true;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+struct gsm_lchan *_select_sdcch_for_call(struct gsm_bts *bts, const struct chan_rqd *rqd, enum gsm_chan_t lctype)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+   struct gsm_lchan *lchan = NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+       int free_tchf, free_tcch;</span><br><span style="color: hsl(120, 100%, 40%);">+     bool needs_dyn_switch;</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%);">+    lchan = lchan_avail_by_type(bts, GSM_LCHAN_SDCCH, false);</span><br><span style="color: hsl(120, 100%, 40%);">+     if (!lchan)</span><br><span style="color: hsl(120, 100%, 40%);">+           return NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+        needs_dyn_switch = lchan->ts->pchan_on_init == GSM_PCHAN_OSMO_DYN &&</span><br><span style="color: hsl(120, 100%, 40%);">+                                    lchan->ts->pchan_is != GSM_PCHAN_SDCCH8_SACCH8C;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+      free_tchf = bts_count_free_ts(bts, GSM_PCHAN_TCH_F);</span><br><span style="color: hsl(120, 100%, 40%);">+  free_tcch = bts_count_free_ts(bts, GSM_PCHAN_TCH_H);</span><br><span style="color: hsl(120, 100%, 40%);">+  if (free_tchf == 0 && free_tcch == 0) {</span><br><span style="color: hsl(120, 100%, 40%);">+               LOG_BTS(bts, DRSL, LOGL_INFO,</span><br><span style="color: hsl(120, 100%, 40%);">+                 "CHAN RQD: 0x%x Requesting %s reason=call but no TCH available\n",</span><br><span style="color: hsl(120, 100%, 40%);">+                  rqd->ref.ra, gsm_lchant_name(lctype));</span><br><span style="color: hsl(120, 100%, 40%);">+             return NULL;</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%);">+   /* There's a TCH available and we'll not switch any of them, so we are fine */</span><br><span style="color: hsl(120, 100%, 40%);">+        if (!needs_dyn_switch)</span><br><span style="color: hsl(120, 100%, 40%);">+                goto select_lchan;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+  /* We need to switch, but there's at least 2 TCH TS available so we are fine: */</span><br><span style="color: hsl(120, 100%, 40%);">+  if (free_tchf > 1 || free_tcch > 2)</span><br><span style="color: hsl(120, 100%, 40%);">+             goto select_lchan;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+  /* At this point (needs_dyn_switch==true), following cases are possible:</span><br><span style="color: hsl(120, 100%, 40%);">+       * [A] H=0, F=1</span><br><span style="color: hsl(120, 100%, 40%);">+        * [B] H=1, F=0</span><br><span style="color: hsl(120, 100%, 40%);">+        * [B] H=1, F=1</span><br><span style="color: hsl(120, 100%, 40%);">+        * [C] H=2, F=1</span><br><span style="color: hsl(120, 100%, 40%);">+        * If condition [C] is met, it means there's 1 dynamic TS and it's the</span><br><span style="color: hsl(120, 100%, 40%);">+         * same as the dynamic TS available for SDCCH requiring switch, so selecting</span><br><span style="color: hsl(120, 100%, 40%);">+   * it would basically leave us without free TCH, so avoid selecting it.</span><br><span style="color: hsl(120, 100%, 40%);">+        * Regarding the other conditions, it basically results in them being</span><br><span style="color: hsl(120, 100%, 40%);">+  * different TS than the one we want to switch, so we are fine selecting</span><br><span style="color: hsl(120, 100%, 40%);">+       * the TS for SDCCH */</span><br><span style="color: hsl(120, 100%, 40%);">+        if (free_tchf == 1 && free_tcch == 2) {</span><br><span style="color: hsl(120, 100%, 40%);">+               LOG_BTS(bts, DRSL, LOGL_INFO,</span><br><span style="color: hsl(120, 100%, 40%);">+                 "CHAN RQD: 0x%x Requesting %s reason=call but dyn TS switch to "</span><br><span style="color: hsl(120, 100%, 40%);">+                    "SDCCH would starve the single available TCH timeslot\n",</span><br><span style="color: hsl(120, 100%, 40%);">+                   rqd->ref.ra, gsm_lchant_name(lctype));</span><br><span style="color: hsl(120, 100%, 40%);">+             return NULL;</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%);">+select_lchan:</span><br><span style="color: hsl(120, 100%, 40%);">+    /* FIXME: we already have lchan, simply do lchan->type = GSM_LCHAN_SDCCH? Split lchan_select_by_type in 2 functions? */</span><br><span style="color: hsl(120, 100%, 40%);">+    lchan = lchan_select_by_type(bts, GSM_LCHAN_SDCCH);</span><br><span style="color: hsl(120, 100%, 40%);">+   return lchan;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> void abis_rsl_chan_rqd_queue_poll(struct gsm_bts *bts)</span><br><span> {</span><br><span>    struct lchan_activate_info info;</span><br><span>@@ -1948,10 +2004,14 @@</span><br><span>    *</span><br><span>    */</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- /* Emergency calls will be put on a free TCH/H or TCH/F directly in the code below, all other channel requests</span><br><span style="color: hsl(0, 100%, 40%);">-   * will get an SDCCH first (if possible). */</span><br><span style="color: hsl(0, 100%, 40%);">-    if (rqd->reason != GSM_CHREQ_REASON_EMERG)</span><br><span style="color: hsl(120, 100%, 40%);">+ if (GSM_CHREQ_REASON_CALL) {</span><br><span style="color: hsl(120, 100%, 40%);">+           lchan = _select_sdcch_for_call(bts, rqd, lctype);</span><br><span style="color: hsl(120, 100%, 40%);">+    } else if (rqd->reason != GSM_CHREQ_REASON_EMERG) {</span><br><span>               lchan = lchan_select_by_type(bts, GSM_LCHAN_SDCCH);</span><br><span style="color: hsl(120, 100%, 40%);">+   }</span><br><span style="color: hsl(120, 100%, 40%);">+     /* else: Emergency calls will be put on a free TCH/H or TCH/F directly</span><br><span style="color: hsl(120, 100%, 40%);">+         * in the code below, all other channel requests will get an SDCCH first</span><br><span style="color: hsl(120, 100%, 40%);">+       * (if possible). */</span><br><span> </span><br><span>     if (!lchan) {</span><br><span>                LOG_BTS(bts, DRSL, LOGL_NOTICE, "CHAN RQD: no resources for %s 0x%x, retrying with %s\n",</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/osmo-bsc/+/24876">change 24876</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/+/24876"/><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: I3b32968949a7bdcbebf5a823359295bac51d8e08 </div>
<div style="display:none"> Gerrit-Change-Number: 24876 </div>
<div style="display:none"> Gerrit-PatchSet: 4 </div>
<div style="display:none"> Gerrit-Owner: pespin <pespin@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins Builder </div>
<div style="display:none"> Gerrit-Reviewer: daniel <dwillmann@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: laforge <laforge@osmocom.org> </div>
<div style="display:none"> Gerrit-Reviewer: neels <nhofmeyr@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: pespin <pespin@sysmocom.de> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>