fixeria has submitted this change. (
https://gerrit.osmocom.org/c/osmocom-bb/+/32921 )
Change subject: trxcon/l1sched: rework burst buffer shifting for TCH/[FH]
......................................................................
trxcon/l1sched: rework burst buffer shifting for TCH/[FH]
This is how the buffer shifting is implemented in osmo-bts-trx. Keep
trxcon's l1sched implementation as close to osmo-bts-trx as possible
in order to simplify the integration of CSD support.
Change-Id: Idb6e415f37f41b8ab92a3864962dac0a40c2fbaa
Related: OS#4396
---
M src/host/trxcon/src/sched_lchan_tchf.c
M src/host/trxcon/src/sched_lchan_tchh.c
2 files changed, 45 insertions(+), 40 deletions(-)
Approvals:
laforge: Looks good to me, but someone else must approve
fixeria: Looks good to me, approved
pespin: Looks good to me, but someone else must approve
Jenkins Builder: Verified
diff --git a/src/host/trxcon/src/sched_lchan_tchf.c
b/src/host/trxcon/src/sched_lchan_tchf.c
index 691ad5a..a4aa80c 100644
--- a/src/host/trxcon/src/sched_lchan_tchf.c
+++ b/src/host/trxcon/src/sched_lchan_tchf.c
@@ -75,9 +75,16 @@
LOGP_LCHAND(lchan, LOGL_DEBUG,
"Traffic received: fn=%u bid=%u\n", bi->fn, bi->bid);
- /* Align to the first burst of a block */
- if (*mask == 0x00 && bi->bid != 0)
- return 0;
+ if (bi->bid == 0) {
+ /* Shift the burst buffer by 4 bursts leftwards */
+ memcpy(&bursts_p[0], &bursts_p[464], 464);
+ memset(&bursts_p[464], 0, 464);
+ *mask = *mask << 4;
+ } else {
+ /* Align to the first burst of a block */
+ if (*mask == 0x00)
+ return 0;
+ }
/* Update mask */
*mask |= (1 << bi->bid);
@@ -108,9 +115,6 @@
}
- /* Keep the mask updated */
- *mask = *mask << 4;
-
switch (lchan->tch_mode) {
case GSM48_CMODE_SIGN:
case GSM48_CMODE_SPEECH_V1: /* FR */
@@ -157,9 +161,6 @@
return -EINVAL;
}
- /* Shift buffer by 4 bursts for interleaving */
- memcpy(bursts_p, bursts_p + 464, 464);
-
/* Check decoding result */
if (rc < 4) {
LOGP_LCHAND(lchan, LOGL_ERROR,
@@ -227,8 +228,10 @@
if (br->bid > 0)
goto send_burst;
- /* Shift buffer by 4 bursts back for interleaving */
- memcpy(bursts_p, bursts_p + 464, 464);
+ /* Shift the burst buffer by 4 bursts leftwards for interleaving */
+ memcpy(&bursts_p[0], &bursts_p[464], 464);
+ memset(&bursts_p[464], 0, 464);
+ *mask = *mask << 4;
/* populate the buffer with bursts */
switch (lchan->tch_mode) {
@@ -332,12 +335,9 @@
LOGP_LCHAND(lchan, LOGL_DEBUG, "Scheduled fn=%u burst=%u\n", br->fn,
br->bid);
/* If we have sent the last (4/4) burst */
- if (*mask == 0x0f) {
+ if ((*mask & 0x0f) == 0x0f) {
/* Confirm data / traffic sending (pass ownership of the prim) */
l1sched_lchan_emit_data_cnf(lchan, br->fn);
-
- /* Reset mask */
- *mask = 0x00;
}
return 0;
diff --git a/src/host/trxcon/src/sched_lchan_tchh.c
b/src/host/trxcon/src/sched_lchan_tchh.c
index bff9b1b..30d623b 100644
--- a/src/host/trxcon/src/sched_lchan_tchh.c
+++ b/src/host/trxcon/src/sched_lchan_tchh.c
@@ -252,6 +252,14 @@
LOGP_LCHAND(lchan, LOGL_DEBUG,
"Traffic received: fn=%u bid=%u\n", bi->fn, bi->bid);
+ if (bi->bid == 0) {
+ /* Shift the burst buffer by 2 bursts leftwards */
+ memcpy(&bursts_p[0], &bursts_p[232], 232);
+ memcpy(&bursts_p[232], &bursts_p[464], 232);
+ memset(&bursts_p[464], 0, 232);
+ *mask = *mask << 2;
+ }
+
if (*mask == 0x00) {
/* Align to the first burst */
if (bi->bid > 0)
@@ -286,17 +294,17 @@
if (lchan->tch_mode == GSM48_CMODE_SIGN) {
/* FACCH/H is interleaved over 6 bursts */
if ((*mask & 0x3f) != 0x3f)
- goto bfi_shift;
+ goto bfi;
} else {
/* Traffic is interleaved over 4 bursts */
if ((*mask & 0x0f) != 0x0f)
- goto bfi_shift;
+ goto bfi;
}
/* Skip decoding attempt in case of FACCH/H */
if (lchan->dl_ongoing_facch) {
lchan->dl_ongoing_facch = false;
- goto bfi_shift; /* 2/2 BFI */
+ goto bfi; /* 2/2 BFI */
}
switch (lchan->tch_mode) {
@@ -340,13 +348,6 @@
return -EINVAL;
}
- /* Shift buffer by 4 bursts for interleaving */
- memcpy(bursts_p, bursts_p + 232, 232);
- memcpy(bursts_p + 232, bursts_p + 464, 232);
-
- /* Shift burst mask */
- *mask = *mask << 2;
-
/* Check decoding result */
if (rc < 4) {
/* Calculate AVG of the measurements (assuming 4 bursts) */
@@ -384,14 +385,6 @@
return l1sched_lchan_emit_data_ind(lchan, &tch_data[0], tch_data_len,
n_errors, n_bits_total, true);
-bfi_shift:
- /* Shift buffer */
- memcpy(bursts_p, bursts_p + 232, 232);
- memcpy(bursts_p + 232, bursts_p + 464, 232);
-
- /* Shift burst mask */
- *mask = *mask << 2;
-
bfi:
/* Didn't try to decode, fake measurements */
if (n_errors < 0) {
@@ -441,17 +434,15 @@
return 0;
}
- /* Shift buffer by 2 bursts back for interleaving */
- memcpy(bursts_p, bursts_p + 232, 232);
-
- /* Also shift TX burst mask */
+ /* Shift the burst buffer by 2 bursts leftwards for interleaving */
+ memcpy(&bursts_p[0], &bursts_p[232], 232);
+ memcpy(&bursts_p[232], &bursts_p[464], 232);
+ memset(&bursts_p[464], 0, 232);
*mask = *mask << 2;
/* If FACCH/H blocks are still pending */
- if (lchan->ul_facch_blocks > 2) {
- memcpy(bursts_p + 232, bursts_p + 464, 232);
+ if (lchan->ul_facch_blocks > 2)
goto send_burst;
- }
if (msgb_l2len(lchan->prim) == GSM_MACBLOCK_LEN)
lchan->ul_facch_blocks = 6;
--
To view, visit
https://gerrit.osmocom.org/c/osmocom-bb/+/32921
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Change-Id: Idb6e415f37f41b8ab92a3864962dac0a40c2fbaa
Gerrit-Change-Number: 32921
Gerrit-PatchSet: 6
Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: merged