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

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">l1sap: add repeated uplink SACCH<br><br>3GPP TS 44.006, section 11 describes a method how the uplink<br>SACCH transmission can be repeated to increase transmission<br>reliability.<br><br>Change-Id: I7e4cc33cc010866e41e3b594351a7f7bf93e08ac<br>Related: OS#4795, SYS#5114<br>---<br>M include/osmo-bts/gsm_data.h<br>M include/osmo-bts/scheduler.h<br>M src/common/l1sap.c<br>M src/osmo-bts-trx/sched_lchan_xcch.c<br>4 files changed, 80 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/include/osmo-bts/gsm_data.h b/include/osmo-bts/gsm_data.h</span><br><span>index b5b616e..64102f5 100644</span><br><span>--- a/include/osmo-bts/gsm_data.h</span><br><span>+++ b/include/osmo-bts/gsm_data.h</span><br><span>@@ -326,6 +326,7 @@</span><br><span> </span><br><span>      struct abis_rsl_osmo_rep_acch_cap repeated_acch_capability;</span><br><span>  bool repeated_dl_facch_active;</span><br><span style="color: hsl(120, 100%, 40%);">+        bool repeated_ul_sacch_active;</span><br><span> </span><br><span>   /* Message buffer to store DL-SACCH repeation candidate */</span><br><span>   struct msgb *rep_sacch;</span><br><span>diff --git a/include/osmo-bts/scheduler.h b/include/osmo-bts/scheduler.h</span><br><span>index 6bb0b9b..6f05756 100644</span><br><span>--- a/include/osmo-bts/scheduler.h</span><br><span>+++ b/include/osmo-bts/scheduler.h</span><br><span>@@ -87,6 +87,7 @@</span><br><span>     ubit_t                  *dl_bursts;     /* burst buffer for TX */</span><br><span>    enum trx_burst_type     dl_burst_type;  /* GMSK or 8PSK burst type */</span><br><span>        sbit_t                  *ul_bursts;     /* burst buffer for RX */</span><br><span style="color: hsl(120, 100%, 40%);">+     sbit_t                  *ul_bursts_prev;/* previous burst buffer for RX (repeated SACCH) */</span><br><span>  uint32_t                ul_first_fn;    /* fn of first burst */</span><br><span>      uint8_t                 ul_mask;        /* mask of received bursts */</span><br><span> </span><br><span>diff --git a/src/common/l1sap.c b/src/common/l1sap.c</span><br><span>index 05adbb1..1785e66 100644</span><br><span>--- a/src/common/l1sap.c</span><br><span>+++ b/src/common/l1sap.c</span><br><span>@@ -1131,6 +1131,8 @@</span><br><span>                       p = msgb_put(msg, GSM_MACBLOCK_LEN);</span><br><span>                         /* L1-header, if not set/modified by layer 1 */</span><br><span>                      p[0] = lchan->ms_power_ctrl.current;</span><br><span style="color: hsl(120, 100%, 40%);">+                       if (lchan->repeated_ul_sacch_active)</span><br><span style="color: hsl(120, 100%, 40%);">+                               p[0] |= 0x40; /* See also: 3GPP TS 44.004, section 7.1 */</span><br><span>                    p[1] = lchan->rqd_ta;</span><br><span>                     le = &lchan->lapdm_ch.lapdm_acch;</span><br><span>                     if (lchan->repeated_acch_capability.dl_sacch)</span><br><span>@@ -1394,6 +1396,34 @@</span><br><span>    return check_for_first_ciphrd(lchan, data, len);</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+/* Decide if repeated UL-SACCH should be applied or not. If the BER level, of</span><br><span style="color: hsl(120, 100%, 40%);">+ * the received SACCH blocks rises above a certain threshold UL-SACCH</span><br><span style="color: hsl(120, 100%, 40%);">+ * repetition is enabled */</span><br><span style="color: hsl(120, 100%, 40%);">+static void repeated_ul_sacch_active_decision(struct gsm_lchan *lchan,</span><br><span style="color: hsl(120, 100%, 40%);">+                                        uint16_t ber10k)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+     uint16_t upper = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+   uint16_t lower = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!lchan->repeated_acch_capability.ul_sacch)</span><br><span style="color: hsl(120, 100%, 40%);">+             return;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+     /* convert from RXQUAL value to ber10k vale,</span><br><span style="color: hsl(120, 100%, 40%);">+   * see also GSM 05.08, section 8.2.4 */</span><br><span style="color: hsl(120, 100%, 40%);">+       static const uint16_t ber10k_by_rxqual_upper[] =</span><br><span style="color: hsl(120, 100%, 40%);">+          { 0, 26, 51, 100, 190, 380, 760, 1500 };</span><br><span style="color: hsl(120, 100%, 40%);">+  static const uint16_t ber10k_by_rxqual_lower[] =</span><br><span style="color: hsl(120, 100%, 40%);">+          { 0, 10, 10, 30, 64, 130, 270, 540 };</span><br><span style="color: hsl(120, 100%, 40%);">+     upper = ber10k_by_rxqual_upper[lchan->repeated_acch_capability.rxqual];</span><br><span style="color: hsl(120, 100%, 40%);">+    lower = ber10k_by_rxqual_lower[lchan->repeated_acch_capability.rxqual];</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+  /* If upper/rxqual == 0, then repeated UL-SACCH is always on */</span><br><span style="color: hsl(120, 100%, 40%);">+       if (ber10k >= upper)</span><br><span style="color: hsl(120, 100%, 40%);">+               lchan->repeated_ul_sacch_active = true;</span><br><span style="color: hsl(120, 100%, 40%);">+    else if (ber10k <= lower)</span><br><span style="color: hsl(120, 100%, 40%);">+          lchan->repeated_ul_sacch_active = false;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> /* DATA received from bts model */</span><br><span> static int l1sap_ph_data_ind(struct gsm_bts_trx *trx,</span><br><span>       struct osmo_phsap_prim *l1sap, struct ph_data_param *data_ind)</span><br><span>@@ -1472,6 +1502,9 @@</span><br><span>              return 0;</span><br><span>    }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ if (L1SAP_IS_LINK_SACCH(link_id))</span><br><span style="color: hsl(120, 100%, 40%);">+             repeated_ul_sacch_active_decision(lchan, data_ind->ber10k);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>     /* bad frame */</span><br><span>      if (len == 0) {</span><br><span>              if (L1SAP_IS_LINK_SACCH(link_id)) {</span><br><span>diff --git a/src/osmo-bts-trx/sched_lchan_xcch.c b/src/osmo-bts-trx/sched_lchan_xcch.c</span><br><span>index b96bc0b..90f481a 100644</span><br><span>--- a/src/osmo-bts-trx/sched_lchan_xcch.c</span><br><span>+++ b/src/osmo-bts-trx/sched_lchan_xcch.c</span><br><span>@@ -34,6 +34,17 @@</span><br><span> </span><br><span> #include <sched_utils.h></span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+/* Add two arrays of sbits */</span><br><span style="color: hsl(120, 100%, 40%);">+static void add_sbits(sbit_t * current, const sbit_t * previous)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+       unsigned int i;</span><br><span style="color: hsl(120, 100%, 40%);">+       for (i = 0; i < 464; i++) {</span><br><span style="color: hsl(120, 100%, 40%);">+                *current = (*current) / 2 + (*previous) / 2;</span><br><span style="color: hsl(120, 100%, 40%);">+          current++;</span><br><span style="color: hsl(120, 100%, 40%);">+            previous++;</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%);">+</span><br><span> /*! \brief a single (SDCCH/SACCH) burst was received by the PHY, process it */</span><br><span> int rx_data_fn(struct l1sched_trx *l1t, enum trx_chan_type chan,</span><br><span>                uint8_t bid, const struct trx_ul_burst_ind *bi)</span><br><span>@@ -49,6 +60,8 @@</span><br><span>   int n_bits_total = 0;</span><br><span>        uint16_t ber10k;</span><br><span>     int rc;</span><br><span style="color: hsl(120, 100%, 40%);">+       struct gsm_lchan *lchan = chan_state->lchan;</span><br><span style="color: hsl(120, 100%, 40%);">+       bool rep_sacch = L1SAP_IS_LINK_SACCH(trx_chan_desc[chan].link_id) && lchan->repeated_ul_sacch_active;</span><br><span> </span><br><span>         /* If handover RACH detection is turned on, treat this burst as an Access Burst.</span><br><span>      * Handle NOPE.ind as usually to ensure proper Uplink measurement reporting. */</span><br><span>@@ -65,6 +78,14 @@</span><br><span>                         return -ENOMEM;</span><br><span>      }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ /* UL-SACCH requires additional memory to keep a copy of each previous</span><br><span style="color: hsl(120, 100%, 40%);">+         * burst set. */</span><br><span style="color: hsl(120, 100%, 40%);">+      if (L1SAP_IS_LINK_SACCH(trx_chan_desc[chan].link_id) && !chan_state->ul_bursts_prev) {</span><br><span style="color: hsl(120, 100%, 40%);">+             chan_state->ul_bursts_prev = talloc_zero_size(tall_bts_ctx, 464);</span><br><span style="color: hsl(120, 100%, 40%);">+          if (!chan_state->ul_bursts_prev)</span><br><span style="color: hsl(120, 100%, 40%);">+                   return -ENOMEM;</span><br><span style="color: hsl(120, 100%, 40%);">+       }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>  /* clear burst & store frame number of first burst */</span><br><span>    if (bid == 0) {</span><br><span>              memset(*bursts_p, 0, 464);</span><br><span>@@ -115,10 +136,34 @@</span><br><span>                   "Received bad data (%u/%u)\n",</span><br><span>                     bi->fn % l1ts->mf_period, l1ts->mf_period);</span><br><span>                 l2_len = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+         /* When SACCH Repetition is active, we may try to decode the</span><br><span style="color: hsl(120, 100%, 40%);">+           * current SACCH block by including the information from the</span><br><span style="color: hsl(120, 100%, 40%);">+           * information from the previous SACCH block. See also:</span><br><span style="color: hsl(120, 100%, 40%);">+                * 3GPP TS 44.006, section 11.2 */</span><br><span style="color: hsl(120, 100%, 40%);">+            if (rep_sacch) {</span><br><span style="color: hsl(120, 100%, 40%);">+                      add_sbits(*bursts_p, chan_state->ul_bursts_prev);</span><br><span style="color: hsl(120, 100%, 40%);">+                  rc = gsm0503_xcch_decode(l2, *bursts_p, &n_errors, &n_bits_total);</span><br><span style="color: hsl(120, 100%, 40%);">+                    if (rc) {</span><br><span style="color: hsl(120, 100%, 40%);">+                             LOGL1S(DL1P, LOGL_NOTICE, l1t, bi->tn, chan, bi->fn,</span><br><span style="color: hsl(120, 100%, 40%);">+                                   "Combining current SACCH block with previous SACCH block also yields bad data (%u/%u)\n",</span><br><span style="color: hsl(120, 100%, 40%);">+                                   bi->fn % l1ts->mf_period, l1ts->mf_period);</span><br><span style="color: hsl(120, 100%, 40%);">+                   } else {</span><br><span style="color: hsl(120, 100%, 40%);">+                              LOGL1S(DL1P, LOGL_DEBUG, l1t, bi->tn, chan, bi->fn,</span><br><span style="color: hsl(120, 100%, 40%);">+                                    "Combining current SACCH block with previous SACCH block yields good data (%u/%u)\n",</span><br><span style="color: hsl(120, 100%, 40%);">+                                       bi->fn % l1ts->mf_period, l1ts->mf_period);</span><br><span style="color: hsl(120, 100%, 40%);">+                           l2_len = GSM_MACBLOCK_LEN;</span><br><span style="color: hsl(120, 100%, 40%);">+                    }</span><br><span style="color: hsl(120, 100%, 40%);">+             }</span><br><span>    } else</span><br><span>               l2_len = GSM_MACBLOCK_LEN;</span><br><span> </span><br><span>       ber10k = compute_ber10k(n_bits_total, n_errors);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+    /* Keep a copy to ease decoding in the next repetition pass */</span><br><span style="color: hsl(120, 100%, 40%);">+        if (rep_sacch)</span><br><span style="color: hsl(120, 100%, 40%);">+                memcpy(chan_state->ul_bursts_prev, *bursts_p, 464);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>     return _sched_compose_ph_data_ind(l1t, bi->tn, *first_fn,</span><br><span>                                           chan, l2, l2_len,</span><br><span>                                    meas_avg.rssi, meas_avg.toa256,</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/osmo-bts/+/21185">change 21185</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/+/21185"/><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: I7e4cc33cc010866e41e3b594351a7f7bf93e08ac </div>
<div style="display:none"> Gerrit-Change-Number: 21185 </div>
<div style="display:none"> Gerrit-PatchSet: 5 </div>
<div style="display:none"> Gerrit-Owner: dexter <pmaier@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: Hoernchen <ewild@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: tnt <tnt@246tNt.com> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>