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

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">measurement: move repeated_dl_facch_active_decision() here<br><br>For the sake of consistency, call repeated_dl_facch_active_decision()<br>from handle_ms_meas_report(), so we have all functions using the<br>measurement results for Downlink executed in a single place.<br><br>Change-Id: Ibd5377ce642e49161f320ac8c33e9f966b3ddfaf<br>Related: SYS#5114, SYS#5319<br>---<br>M include/osmo-bts/l1sap.h<br>M src/common/l1sap.c<br>M src/common/measurement.c<br>M src/common/rsl.c<br>4 files changed, 76 insertions(+), 78 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/include/osmo-bts/l1sap.h b/include/osmo-bts/l1sap.h</span><br><span>index f78d114..93c532f 100644</span><br><span>--- a/include/osmo-bts/l1sap.h</span><br><span>+++ b/include/osmo-bts/l1sap.h</span><br><span>@@ -144,7 +144,4 @@</span><br><span> </span><br><span> int is_ccch_for_agch(struct gsm_bts_trx *trx, uint32_t fn);</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-void repeated_dl_facch_active_decision(struct gsm_lchan *lchan,</span><br><span style="color: hsl(0, 100%, 40%);">-                                  const uint8_t *l3, size_t l3_len);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span> #endif /* L1SAP_H */</span><br><span>diff --git a/src/common/l1sap.c b/src/common/l1sap.c</span><br><span>index f5d2364..a6cd21d 100644</span><br><span>--- a/src/common/l1sap.c</span><br><span>+++ b/src/common/l1sap.c</span><br><span>@@ -1026,80 +1026,6 @@</span><br><span>      return msg;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-/* Decide if repeated FACCH should be applied or not. If RXQUAL level, that the</span><br><span style="color: hsl(0, 100%, 40%);">- * MS reports is high enough, FACCH repetition is not needed. */</span><br><span style="color: hsl(0, 100%, 40%);">-void repeated_dl_facch_active_decision(struct gsm_lchan *lchan, const uint8_t *l3,</span><br><span style="color: hsl(0, 100%, 40%);">-                                  size_t l3_len)</span><br><span style="color: hsl(0, 100%, 40%);">-{</span><br><span style="color: hsl(0, 100%, 40%);">-  const struct gsm48_meas_res *meas_res;</span><br><span style="color: hsl(0, 100%, 40%);">-  uint8_t upper;</span><br><span style="color: hsl(0, 100%, 40%);">-  uint8_t lower;</span><br><span style="color: hsl(0, 100%, 40%);">-  uint8_t rxqual;</span><br><span style="color: hsl(0, 100%, 40%);">- bool prev_repeated_dl_facch_active = lchan->repeated_dl_facch_active;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-        /* This is an optimization so that we exit as quickly as possible if</span><br><span style="color: hsl(0, 100%, 40%);">-     * there are no FACCH repetition capabilities present. However If the</span><br><span style="color: hsl(0, 100%, 40%);">-    * repeated FACCH capabilities vanish for whatever reason, we must be</span><br><span style="color: hsl(0, 100%, 40%);">-    * sure that FACCH repetition is disabled. */</span><br><span style="color: hsl(0, 100%, 40%);">-   if (!lchan->repeated_acch_capability.dl_facch_cmd</span><br><span style="color: hsl(0, 100%, 40%);">-        && !lchan->repeated_acch_capability.dl_facch_all) {</span><br><span style="color: hsl(0, 100%, 40%);">-              lchan->repeated_dl_facch_active = false;</span><br><span style="color: hsl(0, 100%, 40%);">-             goto out;</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%);">-       /* Threshold disabled (always on) */</span><br><span style="color: hsl(0, 100%, 40%);">-    if (lchan->repeated_acch_capability.rxqual == 0) {</span><br><span style="color: hsl(0, 100%, 40%);">-           lchan->repeated_dl_facch_active = true;</span><br><span style="color: hsl(0, 100%, 40%);">-              goto out;</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%);">-       /* When the MS sets the SRR bit in the UL-SACCH L1 header</span><br><span style="color: hsl(0, 100%, 40%);">-        * (repeated SACCH requested) then it makes sense to enable</span><br><span style="color: hsl(0, 100%, 40%);">-      * FACCH repetition too. */</span><br><span style="color: hsl(0, 100%, 40%);">-     if (lchan->meas.l1_info.srr_sro) {</span><br><span style="color: hsl(0, 100%, 40%);">-           lchan->repeated_dl_facch_active = true;</span><br><span style="color: hsl(0, 100%, 40%);">-              goto out;</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%);">-       /* Parse MS measurement results */</span><br><span style="color: hsl(0, 100%, 40%);">-      if (l3_len <= sizeof(struct gsm48_meas_res *) + 2)</span><br><span style="color: hsl(0, 100%, 40%);">-           goto out;</span><br><span style="color: hsl(0, 100%, 40%);">-       if (l3[0] != GSM48_PDISC_RR)</span><br><span style="color: hsl(0, 100%, 40%);">-            goto out;</span><br><span style="color: hsl(0, 100%, 40%);">-       if (l3[1] != GSM48_MT_RR_MEAS_REP)</span><br><span style="color: hsl(0, 100%, 40%);">-              goto out;</span><br><span style="color: hsl(0, 100%, 40%);">-       l3 += 2;</span><br><span style="color: hsl(0, 100%, 40%);">-        meas_res = (struct gsm48_meas_res *)l3;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- /* If the RXQUAL level at the MS drops under a certain threshold</span><br><span style="color: hsl(0, 100%, 40%);">-         * we enable FACCH repetition. */</span><br><span style="color: hsl(0, 100%, 40%);">-       upper = lchan->repeated_acch_capability.rxqual;</span><br><span style="color: hsl(0, 100%, 40%);">-      if (upper > 2)</span><br><span style="color: hsl(0, 100%, 40%);">-               lower = lchan->repeated_acch_capability.rxqual - 2;</span><br><span style="color: hsl(0, 100%, 40%);">-  else</span><br><span style="color: hsl(0, 100%, 40%);">-            lower = 0;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-      /* When downlink DTX is applied, use RXQUAL-SUB, otherwise use</span><br><span style="color: hsl(0, 100%, 40%);">-   * RXQUAL-FULL. */</span><br><span style="color: hsl(0, 100%, 40%);">-      if (meas_res->dtx_used)</span><br><span style="color: hsl(0, 100%, 40%);">-              rxqual = meas_res->rxqual_sub;</span><br><span style="color: hsl(0, 100%, 40%);">-       else</span><br><span style="color: hsl(0, 100%, 40%);">-            rxqual = meas_res->rxqual_full;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-      if (rxqual >= upper)</span><br><span style="color: hsl(0, 100%, 40%);">-         lchan->repeated_dl_facch_active = true;</span><br><span style="color: hsl(0, 100%, 40%);">-      else if (rxqual <= lower)</span><br><span style="color: hsl(0, 100%, 40%);">-            lchan->repeated_dl_facch_active = false;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-out:</span><br><span style="color: hsl(0, 100%, 40%);">- if (lchan->repeated_dl_facch_active == prev_repeated_dl_facch_active)</span><br><span style="color: hsl(0, 100%, 40%);">-                return;</span><br><span style="color: hsl(0, 100%, 40%);">- if (lchan->repeated_dl_facch_active)</span><br><span style="color: hsl(0, 100%, 40%);">-         LOGPLCHAN(lchan, DL1P, LOGL_DEBUG, "DL-FACCH repetition: inactive => active\n");</span><br><span style="color: hsl(0, 100%, 40%);">-   else</span><br><span style="color: hsl(0, 100%, 40%);">-            LOGPLCHAN(lchan, DL1P, LOGL_DEBUG, "DL-FACCH repetition: active => inactive\n");</span><br><span style="color: hsl(0, 100%, 40%);">-}</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span> /* Special dequeueing function with SACCH repetition (3GPP TS 44.006, section 11) */</span><br><span> static inline struct msgb *lapdm_phsap_dequeue_msg_sacch(struct gsm_lchan *lchan, struct lapdm_entity *le)</span><br><span> {</span><br><span>diff --git a/src/common/measurement.c b/src/common/measurement.c</span><br><span>index 0a8a182..3a17869 100644</span><br><span>--- a/src/common/measurement.c</span><br><span>+++ b/src/common/measurement.c</span><br><span>@@ -789,6 +789,80 @@</span><br><span>        return (lchan->ms_t_offs >= 0) || (lchan->p_offs >= 0);</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+/* Decide if repeated FACCH should be applied or not. If RXQUAL level, that the</span><br><span style="color: hsl(120, 100%, 40%);">+ * MS reports is high enough, FACCH repetition is not needed. */</span><br><span style="color: hsl(120, 100%, 40%);">+static void repeated_dl_facch_active_decision(struct gsm_lchan *lchan,</span><br><span style="color: hsl(120, 100%, 40%);">+                                             const struct gsm48_hdr *gh)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+  const struct gsm48_meas_res *meas_res;</span><br><span style="color: hsl(120, 100%, 40%);">+        uint8_t upper;</span><br><span style="color: hsl(120, 100%, 40%);">+        uint8_t lower;</span><br><span style="color: hsl(120, 100%, 40%);">+        uint8_t rxqual;</span><br><span style="color: hsl(120, 100%, 40%);">+       bool prev_repeated_dl_facch_active = lchan->repeated_dl_facch_active;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+    /* This is an optimization so that we exit as quickly as possible if</span><br><span style="color: hsl(120, 100%, 40%);">+   * there are no FACCH repetition capabilities present. However If the</span><br><span style="color: hsl(120, 100%, 40%);">+  * repeated FACCH capabilities vanish for whatever reason, we must be</span><br><span style="color: hsl(120, 100%, 40%);">+  * sure that FACCH repetition is disabled. */</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!lchan->repeated_acch_capability.dl_facch_cmd</span><br><span style="color: hsl(120, 100%, 40%);">+      && !lchan->repeated_acch_capability.dl_facch_all) {</span><br><span style="color: hsl(120, 100%, 40%);">+            lchan->repeated_dl_facch_active = false;</span><br><span style="color: hsl(120, 100%, 40%);">+           goto out;</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%);">+   /* Threshold disabled (always on) */</span><br><span style="color: hsl(120, 100%, 40%);">+  if (lchan->repeated_acch_capability.rxqual == 0) {</span><br><span style="color: hsl(120, 100%, 40%);">+         lchan->repeated_dl_facch_active = true;</span><br><span style="color: hsl(120, 100%, 40%);">+            goto out;</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%);">+   /* When the MS sets the SRR bit in the UL-SACCH L1 header</span><br><span style="color: hsl(120, 100%, 40%);">+      * (repeated SACCH requested) then it makes sense to enable</span><br><span style="color: hsl(120, 100%, 40%);">+    * FACCH repetition too. */</span><br><span style="color: hsl(120, 100%, 40%);">+   if (lchan->meas.l1_info.srr_sro) {</span><br><span style="color: hsl(120, 100%, 40%);">+         lchan->repeated_dl_facch_active = true;</span><br><span style="color: hsl(120, 100%, 40%);">+            goto out;</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%);">+   /* Parse MS measurement results */</span><br><span style="color: hsl(120, 100%, 40%);">+    if (gh == NULL)</span><br><span style="color: hsl(120, 100%, 40%);">+               goto out;</span><br><span style="color: hsl(120, 100%, 40%);">+     /* Check if this is a Measurement Report */</span><br><span style="color: hsl(120, 100%, 40%);">+   if (gh->proto_discr != GSM48_PDISC_RR)</span><br><span style="color: hsl(120, 100%, 40%);">+             goto out;</span><br><span style="color: hsl(120, 100%, 40%);">+     if (gh->msg_type != GSM48_MT_RR_MEAS_REP)</span><br><span style="color: hsl(120, 100%, 40%);">+          goto out;</span><br><span style="color: hsl(120, 100%, 40%);">+     meas_res = (const struct gsm48_meas_res *) gh->data;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+     /* If the RXQUAL level at the MS drops under a certain threshold</span><br><span style="color: hsl(120, 100%, 40%);">+       * we enable FACCH repetition. */</span><br><span style="color: hsl(120, 100%, 40%);">+     upper = lchan->repeated_acch_capability.rxqual;</span><br><span style="color: hsl(120, 100%, 40%);">+    if (upper > 2)</span><br><span style="color: hsl(120, 100%, 40%);">+             lower = lchan->repeated_acch_capability.rxqual - 2;</span><br><span style="color: hsl(120, 100%, 40%);">+        else</span><br><span style="color: hsl(120, 100%, 40%);">+          lower = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+  /* When downlink DTX is applied, use RXQUAL-SUB, otherwise use</span><br><span style="color: hsl(120, 100%, 40%);">+         * RXQUAL-FULL. */</span><br><span style="color: hsl(120, 100%, 40%);">+    if (meas_res->dtx_used)</span><br><span style="color: hsl(120, 100%, 40%);">+            rxqual = meas_res->rxqual_sub;</span><br><span style="color: hsl(120, 100%, 40%);">+     else</span><br><span style="color: hsl(120, 100%, 40%);">+          rxqual = meas_res->rxqual_full;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+  if (rxqual >= upper)</span><br><span style="color: hsl(120, 100%, 40%);">+               lchan->repeated_dl_facch_active = true;</span><br><span style="color: hsl(120, 100%, 40%);">+    else if (rxqual <= lower)</span><br><span style="color: hsl(120, 100%, 40%);">+          lchan->repeated_dl_facch_active = false;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+out:</span><br><span style="color: hsl(120, 100%, 40%);">+   if (lchan->repeated_dl_facch_active == prev_repeated_dl_facch_active)</span><br><span style="color: hsl(120, 100%, 40%);">+              return;</span><br><span style="color: hsl(120, 100%, 40%);">+       if (lchan->repeated_dl_facch_active)</span><br><span style="color: hsl(120, 100%, 40%);">+               LOGPLCHAN(lchan, DL1P, LOGL_DEBUG, "DL-FACCH repetition: inactive => active\n");</span><br><span style="color: hsl(120, 100%, 40%);">+ else</span><br><span style="color: hsl(120, 100%, 40%);">+          LOGPLCHAN(lchan, DL1P, LOGL_DEBUG, "DL-FACCH repetition: active => inactive\n");</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> /* Called every time a Measurement Result (TS 08.58 8.4.8) is received from</span><br><span>  * lower layers and has to be forwarded to BSC */</span><br><span> int handle_ms_meas_report(struct gsm_lchan *lchan,</span><br><span>@@ -853,6 +927,8 @@</span><br><span>   if (gh)</span><br><span>              lchan_bs_pwr_ctrl(lchan, gh);</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+     repeated_dl_facch_active_decision(lchan, gh);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>      /* Reset state for next iteration */</span><br><span>         lchan->tch.dtx.dl_active = false;</span><br><span>         lchan->meas.flags &= ~LC_UL_M_F_OSMO_EXT_VALID;</span><br><span>diff --git a/src/common/rsl.c b/src/common/rsl.c</span><br><span>index 3cbfff6..11f2f86 100644</span><br><span>--- a/src/common/rsl.c</span><br><span>+++ b/src/common/rsl.c</span><br><span>@@ -3586,7 +3586,6 @@</span><br><span>                  return 0;</span><br><span>            }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-           repeated_dl_facch_active_decision(lchan, msgb_l3(msg), msgb_l3len(msg));</span><br><span>             rc = handle_ms_meas_report(lchan, (struct gsm48_hdr *)msgb_l3(msg), msgb_l3len(msg));</span><br><span>                msgb_free(msg);</span><br><span>              return rc;</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/osmo-bts/+/25892">change 25892</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-bts/+/25892"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: osmo-bts </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: Ibd5377ce642e49161f320ac8c33e9f966b3ddfaf </div>
<div style="display:none"> Gerrit-Change-Number: 25892 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: fixeria <vyanitskiy@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins Builder </div>
<div style="display:none"> Gerrit-Reviewer: fixeria <vyanitskiy@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: laforge <laforge@osmocom.org> </div>
<div style="display:none"> Gerrit-Reviewer: pespin <pespin@sysmocom.de> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>