<p>laforge <strong>submitted</strong> this change.</p><p><a href="https://gerrit.osmocom.org/c/osmo-bts/+/21329">View Change</a></p><div style="white-space:pre-wrap">Approvals:
laforge: Looks good to me, approved
Jenkins Builder: Verified
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">sched_lchan_tchh: fix frame number and fill FACCH gap<br><br>The measurement results / TCH indications that are handed when decoding<br>the TCH/H are off by two bursts. Since a measurement result / TCH block<br>is expected every two bursts anyway the problem can only be noticed when<br>a FACCH transmission is going on and the frame numbers of the BFI TCH<br>blocks appear to be missaligned towards the FACCH block.<br><br>The reason is that the incoming bursts are shifted into a 6 burst wide<br>buffer. The decoding functions always look at the beginning of that<br>buffer while the bursts are shifted into the buffer from the end. A<br>facch will always fit exactly in that buffer but TCH/H blocks are only<br>4 bursts wide and thereofre they need two additional bursts until they<br>reach the coverage of the decoding function. Lets fix this by putting<br>the correct frame number (from two bursts before) into the remap<br>functions in order to get the correct beginning of the block.<br><br>Since the FACCH transmission uses six blocks it takes out two TCH<br>blocks. This means that if we count the FACCH block we end up with a gap<br>of one TCH voice block. Lets generate a dummy measurement to compensate<br>the gap. This will also match the behavior of the osmo-bts-sysmo phy.<br><br>Change-Id: I1ad9fa3815feb2b4da608ab7df716a87ba1f2f91<br>Related: OS#4799<br>---<br>M include/osmo-bts/scheduler.h<br>M src/osmo-bts-trx/sched_lchan_tchh.c<br>2 files changed, 51 insertions(+), 8 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/include/osmo-bts/scheduler.h b/include/osmo-bts/scheduler.h</span><br><span>index 6f05756..b1e4294 100644</span><br><span>--- a/include/osmo-bts/scheduler.h</span><br><span>+++ b/include/osmo-bts/scheduler.h</span><br><span>@@ -115,6 +115,8 @@</span><br><span> /* TCH/H */</span><br><span> uint8_t dl_ongoing_facch; /* FACCH/H on downlink */</span><br><span> uint8_t ul_ongoing_facch; /* FACCH/H on uplink */</span><br><span style="color: hsl(120, 100%, 40%);">+ struct l1sched_meas_set meas_avg_facch; /* measurement results for last FACCH */</span><br><span style="color: hsl(120, 100%, 40%);">+ uint16_t ber10k_facch; /* bit error rate for last FACCH */</span><br><span> </span><br><span> /* encryption */</span><br><span> int ul_encr_algo; /* A5/x encry algo downlink */</span><br><span>diff --git a/src/osmo-bts-trx/sched_lchan_tchh.c b/src/osmo-bts-trx/sched_lchan_tchh.c</span><br><span>index c7dac70..378d47a 100644</span><br><span>--- a/src/osmo-bts-trx/sched_lchan_tchh.c</span><br><span>+++ b/src/osmo-bts-trx/sched_lchan_tchh.c</span><br><span>@@ -68,9 +68,11 @@</span><br><span> enum sched_meas_avg_mode meas_avg_mode = SCHED_MEAS_AVG_M_QUAD;</span><br><span> struct l1sched_meas_set meas_avg;</span><br><span> unsigned int fn_begin;</span><br><span style="color: hsl(120, 100%, 40%);">+ unsigned int fn_tch_end;</span><br><span> uint16_t ber10k;</span><br><span> uint8_t is_sub = 0;</span><br><span> uint8_t ft;</span><br><span style="color: hsl(120, 100%, 40%);">+ bool mask_stolen_tch_block = false;</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>@@ -128,6 +130,10 @@</span><br><span> * was decoded (see below), now send the second one. */</span><br><span> ber10k = 0;</span><br><span> memset(&meas_avg, 0, sizeof(meas_avg));</span><br><span style="color: hsl(120, 100%, 40%);">+ /* In order to provide an even stream of measurement reports</span><br><span style="color: hsl(120, 100%, 40%);">+ * we ask the code below to mask the missing TCH/H block</span><br><span style="color: hsl(120, 100%, 40%);">+ * measurement report with the FACCH measurement results. */</span><br><span style="color: hsl(120, 100%, 40%);">+ mask_stolen_tch_block = true;</span><br><span> goto bfi;</span><br><span> }</span><br><span> </span><br><span>@@ -267,6 +273,18 @@</span><br><span> meas_avg.rssi, meas_avg.toa256,</span><br><span> meas_avg.ci_cb, ber10k,</span><br><span> PRES_INFO_UNKNOWN);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ /* Keep a copy of the measurement results of the last FACCH</span><br><span style="color: hsl(120, 100%, 40%);">+ * transmission in order to be able to create a replacement</span><br><span style="color: hsl(120, 100%, 40%);">+ * measurement result for the one missing TCH block</span><br><span style="color: hsl(120, 100%, 40%);">+ * measurement */</span><br><span style="color: hsl(120, 100%, 40%);">+ memcpy(&chan_state->meas_avg_facch, &meas_avg, sizeof(meas_avg));</span><br><span style="color: hsl(120, 100%, 40%);">+ chan_state->ber10k_facch = ber10k;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ /* Invalidate the current measurement result to prevent the</span><br><span style="color: hsl(120, 100%, 40%);">+ * code below from handing up the current measurement a second</span><br><span style="color: hsl(120, 100%, 40%);">+ * time. */</span><br><span style="color: hsl(120, 100%, 40%);">+ memset(&meas_avg, 0, sizeof(meas_avg));</span><br><span> bfi:</span><br><span> /* A FACCH/H frame replaces two speech frames, so we need to send two BFIs.</span><br><span> * One is sent here, another will be sent two bursts later (see above). */</span><br><span>@@ -317,15 +335,38 @@</span><br><span> </span><br><span> compose_l1sap:</span><br><span> /* TCH or BFI */</span><br><span style="color: hsl(0, 100%, 40%);">- /* Note on FN 19 or 20: If we received the last burst of a frame,</span><br><span style="color: hsl(0, 100%, 40%);">- * it actually starts at FN 8 or 9. A burst starting there, overlaps</span><br><span style="color: hsl(0, 100%, 40%);">- * with the slot 12, so an extra FN must be subtracted to get correct</span><br><span style="color: hsl(0, 100%, 40%);">- * start of frame.</span><br><span style="color: hsl(0, 100%, 40%);">- */</span><br><span style="color: hsl(0, 100%, 40%);">- if (lchan->nr == 0)</span><br><span style="color: hsl(0, 100%, 40%);">- fn_begin = gsm0502_fn_remap(bi->fn, FN_REMAP_TCH_H0);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ /* The input to gsm0502_fn_remap() needs to get the frame number we</span><br><span style="color: hsl(120, 100%, 40%);">+ * got two bursts ago. The reason for this is that the burst shift</span><br><span style="color: hsl(120, 100%, 40%);">+ * buffer we use for decoding is 6 bursts wide (one SACCH block) but</span><br><span style="color: hsl(120, 100%, 40%);">+ * TCH/H blocks are only 4 bursts wide. The decoder functions look</span><br><span style="color: hsl(120, 100%, 40%);">+ * at the beginning of the buffer while we shift into it at the end,</span><br><span style="color: hsl(120, 100%, 40%);">+ * this means that TCH/H blocks always decode delayed by two frame</span><br><span style="color: hsl(120, 100%, 40%);">+ * number positions late. To calculatue the ending frame number of</span><br><span style="color: hsl(120, 100%, 40%);">+ * the TCH/H we need to subtract 4 or 5 frames if there was a SACCH</span><br><span style="color: hsl(120, 100%, 40%);">+ * in between. (Note: this is TCH/H, 4 frames ==> 2 bursts) */</span><br><span style="color: hsl(120, 100%, 40%);">+ if (bi->fn % 13 < 4)</span><br><span style="color: hsl(120, 100%, 40%);">+ fn_tch_end = GSM_TDMA_FN_SUB(bi->fn, 5);</span><br><span> else</span><br><span style="color: hsl(0, 100%, 40%);">- fn_begin = gsm0502_fn_remap(bi->fn, FN_REMAP_TCH_H1);</span><br><span style="color: hsl(120, 100%, 40%);">+ fn_tch_end = GSM_TDMA_FN_SUB(bi->fn, 4);</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+ if (lchan->nr == 0)</span><br><span style="color: hsl(120, 100%, 40%);">+ fn_begin = gsm0502_fn_remap(fn_tch_end, FN_REMAP_TCH_H0);</span><br><span style="color: hsl(120, 100%, 40%);">+ else</span><br><span style="color: hsl(120, 100%, 40%);">+ fn_begin = gsm0502_fn_remap(fn_tch_end, FN_REMAP_TCH_H1);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ /* A FACCH/H transmission takes out two TCH/H voice blocks and the</span><br><span style="color: hsl(120, 100%, 40%);">+ * related measurement results. The first measurement result is handed</span><br><span style="color: hsl(120, 100%, 40%);">+ * up directly with the FACCH (see above), the second one needs to be</span><br><span style="color: hsl(120, 100%, 40%);">+ * compensated by filling the gap with the measurement result we got</span><br><span style="color: hsl(120, 100%, 40%);">+ * from the FACCH transmission. */</span><br><span style="color: hsl(120, 100%, 40%);">+ if (mask_stolen_tch_block) {</span><br><span style="color: hsl(120, 100%, 40%);">+ memcpy(&meas_avg, &chan_state->meas_avg_facch, sizeof(meas_avg));</span><br><span style="color: hsl(120, 100%, 40%);">+ ber10k = chan_state->ber10k_facch;</span><br><span style="color: hsl(120, 100%, 40%);">+ memset(&chan_state->meas_avg_facch, 0, sizeof(meas_avg));</span><br><span style="color: hsl(120, 100%, 40%);">+ chan_state->ber10k_facch = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> return _sched_compose_tch_ind(l1t, bi->tn, fn_begin, chan, tch_data, rc,</span><br><span> /* FIXME: what should we use for BFI here? */</span><br><span> bfi_flag ? bi->toa256 : meas_avg.toa256, ber10k,</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/osmo-bts/+/21329">change 21329</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/+/21329"/><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: I1ad9fa3815feb2b4da608ab7df716a87ba1f2f91 </div>
<div style="display:none"> Gerrit-Change-Number: 21329 </div>
<div style="display:none"> Gerrit-PatchSet: 4 </div>
<div style="display:none"> Gerrit-Owner: dexter <pmaier@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-MessageType: merged </div>