<p>fixeria has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/c/libosmocore/+/19853">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">lapdm: fix SAPI-0/SAPI-3 frame prioritization on DCCH<br><br>According to 3GPP TS 44.005, section 4.2.2 "Priority":<br><br>  a) on DCCH, a SAPI=0 frame always has higher priority than SAPI=3;<br>  b) on ACCH, the priority arrangement is more complex:<br>    b1) if a SAPI = 3 frame is awaiting transmission, two SAPI=0<br>        frames shall not be sent in consecutive SACCH frames;<br>    b2) on the network side (LAPDM_MODE_BTS), it must also be ensured<br>        that any SAPI=3 frame is followed by at least one SAPI=0 frame;<br>    b3) a SAPI = 0 frame may be repeated in the next SACCH period<br>        if the Repeated SACCH is supported (see 3GPP TS 44.006, section 11).<br><br>We definitely need to extend our testing coverage to ensure that<br>we implement b) correctly, but for now let's focus on DCCH:<br><br>  a) for DCCH, ensure that SAPI=0 frames preceed SAPI=3 ones;<br>  b) for ACCH, re-use the existing round-robin implementation.<br><br>Change-Id: Ia3780bce1222b312ae2fd2d21496a4d6c5ccb6e0<br>Related: SYS#5047, OS#4731<br>---<br>M src/gsm/lapdm.c<br>M tests/lapd/lapd_test.ok<br>2 files changed, 26 insertions(+), 7 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/53/19853/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/gsm/lapdm.c b/src/gsm/lapdm.c</span><br><span>index 21227e3..bfd6d26 100644</span><br><span>--- a/src/gsm/lapdm.c</span><br><span>+++ b/src/gsm/lapdm.c</span><br><span>@@ -380,7 +380,21 @@</span><br><span>        return le->l1_prim_cb(&pp.oph, le->l1_ctx);</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-static struct msgb *tx_dequeue_msgb(struct lapdm_entity *le)</span><br><span style="color: hsl(120, 100%, 40%);">+/* Dequeue a Downlink message for DCCH (dedicated channel) */</span><br><span style="color: hsl(120, 100%, 40%);">+static struct msgb *tx_dequeue_dcch_msgb(struct lapdm_entity *le)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+       struct msgb *msg;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   /* SAPI=0 always has higher priority than SAPI=3 */</span><br><span style="color: hsl(120, 100%, 40%);">+   msg = msgb_dequeue(&le->datalink[DL_SAPI0].dl.tx_queue);</span><br><span style="color: hsl(120, 100%, 40%);">+       if (msg == NULL) /* no SAPI=0 messages, dequeue SAPI=3 (if any) */</span><br><span style="color: hsl(120, 100%, 40%);">+            msg = msgb_dequeue(&le->datalink[DL_SAPI3].dl.tx_queue);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+     return msg;</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%);">+/* Dequeue a Downlink message for ACCH (associated channel) */</span><br><span style="color: hsl(120, 100%, 40%);">+static struct msgb *tx_dequeue_acch_msgb(struct lapdm_entity *le)</span><br><span> {</span><br><span>     struct lapdm_datalink *dl;</span><br><span>   int last = le->last_tx_dequeue;</span><br><span>@@ -411,7 +425,12 @@</span><br><span>    struct msgb *msg;</span><br><span>    uint8_t pad;</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-        msg = tx_dequeue_msgb(le);</span><br><span style="color: hsl(120, 100%, 40%);">+    /* Dequeue depending on channel type: DCCH or ACCH.</span><br><span style="color: hsl(120, 100%, 40%);">+    * See 3GPP TS 44.005, section 4.2.2 "Priority". */</span><br><span style="color: hsl(120, 100%, 40%);">+ if (le == &le->lapdm_ch->lapdm_dcch)</span><br><span style="color: hsl(120, 100%, 40%);">+                msg = tx_dequeue_dcch_msgb(le);</span><br><span style="color: hsl(120, 100%, 40%);">+       else</span><br><span style="color: hsl(120, 100%, 40%);">+          msg = tx_dequeue_acch_msgb(le);</span><br><span>      if (!msg)</span><br><span>            return -ENODEV;</span><br><span> </span><br><span>diff --git a/tests/lapd/lapd_test.ok b/tests/lapd/lapd_test.ok</span><br><span>index 5b95195..065886c 100644</span><br><span>--- a/tests/lapd/lapd_test.ok</span><br><span>+++ b/tests/lapd/lapd_test.ok</span><br><span>@@ -131,13 +131,13 @@</span><br><span> bts_to_ms_dummy_tx_cb: MS->BTS(us) message 22</span><br><span> BTS is establishing a SAPI=3 link</span><br><span> lapdm_phsap_dequeue_prim(): got rc 0: Success</span><br><span style="color: hsl(0, 100%, 40%);">-Took message from DCCH queue: L2 header size 3, L3 size 20, SAP 0x1000000, 0/0, Link 0x03</span><br><span style="color: hsl(0, 100%, 40%);">-Message: [L2]> 0f 3f 01 [L3]> 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b </span><br><span style="color: hsl(0, 100%, 40%);">-lapdm_phsap_dequeue_prim(): got rc 0: Success</span><br><span> Took message from DCCH queue: L2 header size 3, L3 size 20, SAP 0x1000000, 0/0, Link 0x00</span><br><span> Message: [L2]> 01 73 35 [L3]> 06 27 07 03 50 58 92 05 f4 44 59 ba 63 2b 2b 2b 2b 2b 2b 2b </span><br><span style="color: hsl(0, 100%, 40%);">-Checking the func=UA message: FAIL</span><br><span style="color: hsl(0, 100%, 40%);">-Checking the func=SABM message: FAIL</span><br><span style="color: hsl(120, 100%, 40%);">+lapdm_phsap_dequeue_prim(): got rc 0: Success</span><br><span style="color: hsl(120, 100%, 40%);">+Took message from DCCH queue: L2 header size 3, L3 size 20, SAP 0x1000000, 0/0, Link 0x03</span><br><span style="color: hsl(120, 100%, 40%);">+Message: [L2]> 0f 3f 01 [L3]> 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b </span><br><span style="color: hsl(120, 100%, 40%);">+Checking the func=UA message: OK</span><br><span style="color: hsl(120, 100%, 40%);">+Checking the func=SABM message: OK</span><br><span> </span><br><span> Checking whether the DCCH/SACCH queues are empty</span><br><span> lapdm_phsap_dequeue_prim(): got rc -19: No such device</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/libosmocore/+/19853">change 19853</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/libosmocore/+/19853"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: libosmocore </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: Ia3780bce1222b312ae2fd2d21496a4d6c5ccb6e0 </div>
<div style="display:none"> Gerrit-Change-Number: 19853 </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>