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
This commit is contained in:
Vadim Yanitskiy 2023-05-22 22:34:15 +07:00 committed by fixeria
parent d400126d0f
commit 0ee32177a2
2 changed files with 31 additions and 40 deletions

View File

@ -75,9 +75,16 @@ int rx_tchf_fn(struct l1sched_lchan_state *lchan,
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 @@ int rx_tchf_fn(struct l1sched_lchan_state *lchan,
}
/* 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 @@ int rx_tchf_fn(struct l1sched_lchan_state *lchan,
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 @@ int tx_tchf_fn(struct l1sched_lchan_state *lchan,
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 @@ send_burst:
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;

View File

@ -252,6 +252,14 @@ int rx_tchh_fn(struct l1sched_lchan_state *lchan,
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 @@ int rx_tchh_fn(struct l1sched_lchan_state *lchan,
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 @@ int rx_tchh_fn(struct l1sched_lchan_state *lchan,
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 @@ int rx_tchh_fn(struct l1sched_lchan_state *lchan,
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 @@ int tx_tchh_fn(struct l1sched_lchan_state *lchan,
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;