From 7da06c060930d9b594a4f7564b8c33001f84ec86 Mon Sep 17 00:00:00 2001 From: Vadim Yanitskiy Date: Thu, 27 Aug 2020 20:58:49 +0700 Subject: lapdm: fix SAPI-0/SAPI-3 frame prioritization on DCCH According to 3GPP TS 44.005, section 4.2.2 "Priority": a) on DCCH, a SAPI=0 frame always has higher priority than SAPI=3; b) on ACCH, the priority arrangement is more complex: b1) if a SAPI = 3 frame is awaiting transmission, two SAPI=0 frames shall not be sent in consecutive SACCH frames; b2) on the network side (LAPDM_MODE_BTS), it must also be ensured that any SAPI=3 frame is followed by at least one SAPI=0 frame; b3) a SAPI = 0 frame may be repeated in the next SACCH period if the Repeated SACCH is supported (see 3GPP TS 44.006, section 11). We definitely need to extend our testing coverage to ensure that we implement b) correctly, but for now let's focus on DCCH: a) for DCCH, ensure that SAPI=0 frames preceed SAPI=3 ones; b) for ACCH, re-use the existing round-robin implementation. Change-Id: Ia3780bce1222b312ae2fd2d21496a4d6c5ccb6e0 Related: SYS#5047, OS#4731 --- src/gsm/lapdm.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/gsm/lapdm.c b/src/gsm/lapdm.c index e5fbaf0d..fa928c5e 100644 --- a/src/gsm/lapdm.c +++ b/src/gsm/lapdm.c @@ -380,7 +380,21 @@ static int tx_ph_data_enqueue(struct lapdm_datalink *dl, struct msgb *msg, return le->l1_prim_cb(&pp.oph, le->l1_ctx); } -static struct msgb *tx_dequeue_msgb(struct lapdm_entity *le) +/* Dequeue a Downlink message for DCCH (dedicated channel) */ +static struct msgb *tx_dequeue_dcch_msgb(struct lapdm_entity *le) +{ + struct msgb *msg; + + /* SAPI=0 always has higher priority than SAPI=3 */ + msg = msgb_dequeue(&le->datalink[DL_SAPI0].dl.tx_queue); + if (msg == NULL) /* no SAPI=0 messages, dequeue SAPI=3 (if any) */ + msg = msgb_dequeue(&le->datalink[DL_SAPI3].dl.tx_queue); + + return msg; +} + +/* Dequeue a Downlink message for ACCH (associated channel) */ +static struct msgb *tx_dequeue_acch_msgb(struct lapdm_entity *le) { struct lapdm_datalink *dl; int last = le->last_tx_dequeue; @@ -411,7 +425,12 @@ int lapdm_phsap_dequeue_prim(struct lapdm_entity *le, struct osmo_phsap_prim *pp struct msgb *msg; uint8_t pad; - msg = tx_dequeue_msgb(le); + /* Dequeue depending on channel type: DCCH or ACCH. + * See 3GPP TS 44.005, section 4.2.2 "Priority". */ + if (le == &le->lapdm_ch->lapdm_dcch) + msg = tx_dequeue_dcch_msgb(le); + else + msg = tx_dequeue_acch_msgb(le); if (!msg) return -ENODEV; -- cgit v1.2.3