falconia has uploaded this change for review. (
https://gerrit.osmocom.org/c/osmo-bts/+/41047?usp=email )
Change subject: TCH UL path: add out-of-band BFI flag
......................................................................
TCH UL path: add out-of-band BFI flag
In original OsmoBTS architecture prior to Themyscira patches,
BFI (Bad Frame Indication) condition was signaled internally by
zero-length payload passed from BTS model to l1sap, and externally
by absence of RTP output (intentional gap) or a zero-length RTP
payload emitted in 'rtp continuous-streaming' mode. However, this
paradigm is contrary to classic GSM BSS architecture in which BFI
is an out-of-band metadata flag that travels alongside with frame
payload bits, whether the latter are valid or invalid.
Since 2024 OsmoBTS supports the option of TW-TS-001 output for
FR and EFR codecs, which allows the possibility of BFI-with-data
in RTP. OsmoBTS can already emit such BFI-with-data packets when
the BTS model delivered a deemed-good traffic frame, but that frame
was subsequently deemed bad by the link quality check in l1sap -
but there is still no explicit out-of-band BFI flag inside OsmoBTS
TCH UL path.
By introducing an out-of-band BFI flag, we make it possible for BTS
model PHYs to deliver marked-bad traffic frames: when CRC fails
in GSM 05.03 channel decoding step, a PHY that permits modification
(libosmocoding or future FOSS DSP PHY) can be enhanced to preserve
channel-decoded bits while conveying BFI.
The link quality check in l1sap is reworked to use the new OOB BFI
flag. Follow-on patches will introduce further logic that can also
assert BFI at high level, above BTS model PHYs.
While reworking the link quality check in l1sap, restrict it to
speech modes only: per GSM specs, BFI does not exist in CSD.
Change-Id: I8097946429e83eae90f89e49d17ffb8eb0636fcb
---
M include/osmo-bts/msg_utils.h
M src/common/l1sap.c
2 files changed, 48 insertions(+), 20 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/47/41047/1
diff --git a/include/osmo-bts/msg_utils.h b/include/osmo-bts/msg_utils.h
index db7142d..7363bcf 100644
--- a/include/osmo-bts/msg_utils.h
+++ b/include/osmo-bts/msg_utils.h
@@ -13,21 +13,31 @@
struct msgb;
-/* Access 1st part of msgb control buffer */
+/* Control buffer words in struct msgb are used for two purposes in OsmoBTS:
+ *
+ * 1) In the direction from RTP input to TCH DL they are used to transport
+ * RTP header fields and payload preparsing results from RTP Rx callback
+ * function to deeper TCH DL handling code;
+ *
+ * 2) In TCH UL direction, we provide an ability for BTS models to indicate
+ * BFI along with payload bits, and the same BFI flag can then be set
+ * by model-independent functions for higher-level BFI conditions.
+ */
+
+/* Accessor macros for control buffer words in RTP input path */
+
+/* storing RTP header fields */
#define rtpmsg_marker_bit(x) ((x)->cb[0])
-
-/* Access 2nd part of msgb control buffer */
#define rtpmsg_seq(x) ((x)->cb[1])
-
-/* Access 3rd part of msgb control buffer */
#define rtpmsg_ts(x) ((x)->cb[2])
-
-/* Access 4th part of msgb control buffer */
+/* storing payload preparsing results */
#define rtpmsg_is_rfc5993_sid(x) ((x)->cb[3])
-
-/* Access 5th part of msgb control buffer */
#define rtpmsg_csd_align_bits(x) ((x)->cb[4])
+/* Accessor macros for control buffer words in TCH UL path */
+
+#define tch_ul_msg_bfi(x) ((x)->cb[0])
+
/**
* Classification of OML message. ETSI for plain GSM 12.21
* messages and IPA/Osmo for manufacturer messages.
diff --git a/src/common/l1sap.c b/src/common/l1sap.c
index 09f6a90..f4dea35 100644
--- a/src/common/l1sap.c
+++ b/src/common/l1sap.c
@@ -2220,16 +2220,13 @@
/* a helper function for emitting FR/EFR UL in TW-TS-001 format */
static void send_rtp_twts001(struct gsm_lchan *lchan, uint32_t fn,
- struct msgb *msg, bool good_frame)
+ struct msgb *msg)
{
uint8_t teh;
bool send_frame;
if (msg->len == GSM_FR_BYTES || msg->len == GSM_EFR_BYTES) {
- if (good_frame)
- teh = 0xE0;
- else
- teh = 0xE2;
+ teh = 0xE0 | (tch_ul_msg_bfi(msg) << 1);
send_frame = true;
} else {
teh = 0xE6;
@@ -2272,7 +2269,7 @@
lchan->type == GSM_LCHAN_TCH_F &&
(lchan->tch_mode == GSM48_CMODE_SPEECH_V1 ||
lchan->tch_mode == GSM48_CMODE_SPEECH_EFR)) {
- send_rtp_twts001(lchan, fn, msg, false);
+ send_rtp_twts001(lchan, fn, msg);
return;
}
@@ -2345,10 +2342,31 @@
msgb_pull_to_l2(msg);
/* Low level layers always call us when TCH content is expected, even if
- * the content is not available due to decoding issues. Content not
- * available is expected as empty payload. We also check if quality is
- * good enough. */
- if (msg->len && tch_ind->lqual_cb >= bts->min_qual_norm) {
+ * the content is not available due to decoding issues. Content not
+ * available is indicated as empty payload, also termed BFI w/o data.
+ * Alternatively, a BTS model can supply channel-decoded payload bits,
+ * but also set BFI flag, just like in TRAU-UL frames on E1 Abis.
+ *
+ * If the channel mode is speech (not CSD), we also check if quality is
+ * good enough - if it isn't, we set BFI. This quality check is
+ * essential with FRv1 codec and DTXu, otherwise DTXu pauses will be
+ * filled with very unpleasant sounds as channel-decoded radio noise
+ * gets declared as good traffic frames with 1/8 probability given
+ * only a 3-bit CRC. However, this check is restricted to speech
+ * because per the specs, BFI does not exist in CSD: every channel-
+ * decoded frame is passed along, error handling either falls on RLP
+ * or is the responsibility of user applications in Transparent mode.
+ */
+ if ((lchan->rsl_cmode == RSL_CMOD_SPD_SPEECH) &&
+ (tch_ind->lqual_cb < bts->min_qual_norm))
+ tch_ul_msg_bfi(msg) = true;
+
+ /* FR/HR/EFR SID classification, with potential effects on BFI flag,
+ * will go here - further patches in the series. */
+
+ /* Good RTP output happens when we got some payload AND it is not
+ * marked as BFI. */
+ if (msg->len && !tch_ul_msg_bfi(msg)) {
/* feed the good frame to the ECU, if we are applying one */
if (lchan->ecu_state)
osmo_ecu_frame_in(lchan->ecu_state, false, msg->data, msg->len);
@@ -2361,7 +2379,7 @@
lchan->tch_mode == GSM48_CMODE_SPEECH_EFR)) {
/* FR and EFR codecs */
if (lchan->abis_ip.rtp_extensions & OSMO_RTP_EXT_TWTS001)
- send_rtp_twts001(lchan, fn, msg, true);
+ send_rtp_twts001(lchan, fn, msg);
else
send_ul_rtp_packet(lchan, fn, msg->data, msg->len);
} else if (lchan->type == GSM_LCHAN_TCH_H &&
--
To view, visit
https://gerrit.osmocom.org/c/osmo-bts/+/41047?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Change-Id: I8097946429e83eae90f89e49d17ffb8eb0636fcb
Gerrit-Change-Number: 41047
Gerrit-PatchSet: 1
Gerrit-Owner: falconia <falcon(a)freecalypso.org>