<p>fixeria has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/c/osmocom-bb/+/19201">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">trxcon/scheduler: check TDMA frame order, drop out of order bursts<br><br>When running together with fake_trx.py (mostly used back-end), it<br>is currently possible that Downlink bursts are received in a wrong<br>order if more than one transceiver is configured (multi-trx mode).<br><br>This is how it looks like:<br><br>  20200708201455837 DTRXD DEBUG trx_if.c:612 RX burst tn=3 fn=629 rssi=-86 toa=0<br>  20200708201455837 DSCHD DEBUG sched_lchan_tchf.c:60 Traffic received on TCH/F: fn=629 ts=3 bid=1<br>  20200708201455841 DTRXD DEBUG trx_if.c:612 RX burst tn=3 fn=630 rssi=-86 toa=0<br>  20200708201455841 DSCHD DEBUG sched_lchan_tchf.c:60 Traffic received on TCH/F: fn=630 ts=3 bid=2<br>  20200708201455846 DTRXD DEBUG trx_if.c:612 RX burst tn=3 fn=631 rssi=-86 toa=0<br>  20200708201455846 DSCHD DEBUG sched_lchan_tchf.c:60 Traffic received on TCH/F: fn=631 ts=3 bid=3<br><br>  20200708201455846 DTRXD DEBUG trx_if.c:612 RX burst tn=3 fn=633 (!) rssi=-86 toa=0<br>  20200708201455846 DSCHD NOTICE sched_trx.c:663 Substituting (!) lost TDMA frame 632 on TCH/F<br>  20200708201455846 DSCHD DEBUG sched_lchan_tchf.c:60 Traffic received on TCH/F: fn=632 ts=3 bid=0<br>  20200708201455846 DSCHD DEBUG sched_lchan_tchf.c:60 Traffic received on TCH/F: fn=633 ts=3 bid=1<br><br>  20200708201455849 DTRXD DEBUG trx_if.c:612 RX burst tn=3 fn=632 (!) rssi=-86 toa=0<br>  20200708201455849 DTRXD NOTICE sched_trx.c:640 Too many (>104) contiguous TDMA frames elapsed (2715647)<br>                                                 since the last processed fn=633 (current fn=632)<br><br>so here a burst with TDMA fn=633 was received earlier than a burst<br>with TDMA fn=632.  The burst loss detection logic considered the<br>latter one as lost, and substituted it with a dummy burst.  When<br>finally the out-of-order burst with TDMA fn=632 was received, we<br>got the large number of allegedly elapsed frames:<br><br>  ((632 + 2715648) - 633) % 2715648 == 2715647<br><br>Given that late bursts get substituted, the best thing we can do<br>is to reject them and log an error.  Passing them the the logical<br>channel handler (again) might lead to undefined behaviour.<br><br>Change-Id: I873c8555ea2ca190b1689227bb0fdcba87188772<br>Related: OS#4658, OS#4546<br>---<br>M src/host/trxcon/sched_trx.c<br>1 file changed, 10 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/01/19201/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/host/trxcon/sched_trx.c b/src/host/trxcon/sched_trx.c</span><br><span>index 9195b33..6b872cd 100644</span><br><span>--- a/src/host/trxcon/sched_trx.c</span><br><span>+++ b/src/host/trxcon/sched_trx.c</span><br><span>@@ -719,6 +719,16 @@</span><br><span>       if (!lchan->active)</span><br><span>               return 0;</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ /* Check TDMA frame order (a race condition is possible with fake_trx.py, see OS#4658) */</span><br><span style="color: hsl(120, 100%, 40%);">+     if (fn < lchan->tdma.last_proc) {</span><br><span style="color: hsl(120, 100%, 40%);">+               /* This burst has already been substituted by a dummy burst (all bits set to zero),</span><br><span style="color: hsl(120, 100%, 40%);">+            * so better drop it. Otherwise we risk to get undefined behavior in handler(). */</span><br><span style="color: hsl(120, 100%, 40%);">+            LOGP(DSCHD, LOGL_ERROR, "(%s on TS %u) Rx burst with fn=%u older "</span><br><span style="color: hsl(120, 100%, 40%);">+                                  "than the last processed fn=%u => dropping...\n",</span><br><span style="color: hsl(120, 100%, 40%);">+                     trx_lchan_desc[lchan->type].name, tn, fn, lchan->tdma.last_proc);</span><br><span style="color: hsl(120, 100%, 40%);">+          return -EALREADY;</span><br><span style="color: hsl(120, 100%, 40%);">+     }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>  /* Compensate lost TDMA frames (if any) */</span><br><span>   subst_frame_loss(lchan, handler, fn);</span><br><span> </span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/osmocom-bb/+/19201">change 19201</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/osmocom-bb/+/19201"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: osmocom-bb </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: I873c8555ea2ca190b1689227bb0fdcba87188772 </div>
<div style="display:none"> Gerrit-Change-Number: 19201 </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-MessageType: newchange </div>