mirror of
https://gitea.osmocom.org/cellular-infrastructure/osmo-bts.git
synced 2025-10-23 16:23:50 +00:00
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
This commit is contained in:
@@ -13,21 +13,38 @@
|
||||
|
||||
struct msgb;
|
||||
|
||||
/* Access 1st part of msgb control buffer */
|
||||
/****************************************************************
|
||||
* Accessor macros for control buffer words in RTP input path (DL)
|
||||
*****************************************************************/
|
||||
|
||||
/* Storing RTP header fields in the path from RTP and Osmux
|
||||
* Rx callback functions to TCH-RTS.ind handling.
|
||||
* FIXME: do we really need this RTP header info downstream
|
||||
* of the jitter buffer mechanism in the RTP endpoint library?
|
||||
*/
|
||||
#define rtpmsg_marker_bit(x) ((x)->cb[0])
|
||||
#define rtpmsg_seq(x) ((x)->cb[1])
|
||||
#define rtpmsg_ts(x) ((x)->cb[2])
|
||||
|
||||
/* 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 */
|
||||
/* l1sap_rtp_rx_cb() does some preening or preparsing on some
|
||||
* RTP payloads, and in two cases (HR with RFC 5993 input and
|
||||
* CSD NT modes) this preparsing step produces some metadata
|
||||
* that need to be passed to TCH-RTS.ind handling.
|
||||
*/
|
||||
#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
|
||||
*********************************************************/
|
||||
|
||||
/* We provide an ability for BTS models to indicate BFI along with payload
|
||||
* bits just like in GSM 08.60 TRAU-UL frames, and the same BFI flag can
|
||||
* then be set by model-independent functions for higher-level BFI
|
||||
* conditions. This cb word shall act as a Boolean flag.
|
||||
*/
|
||||
#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.
|
||||
|
@@ -2220,16 +2220,15 @@ static void send_rtp_rfc5993(struct gsm_lchan *lchan, uint32_t fn,
|
||||
|
||||
/* 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;
|
||||
if (tch_ul_msg_bfi(msg))
|
||||
teh |= 0x02;
|
||||
send_frame = true;
|
||||
} else {
|
||||
teh = 0xE6;
|
||||
@@ -2272,7 +2271,7 @@ static void tch_ul_bfi_handler(struct gsm_lchan *lchan,
|
||||
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 +2344,31 @@ static int l1sap_tch_ind(struct gsm_bts_trx *trx, struct osmo_phsap_prim *l1sap,
|
||||
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 +2381,7 @@ static int l1sap_tch_ind(struct gsm_bts_trx *trx, struct osmo_phsap_prim *l1sap,
|
||||
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 &&
|
||||
|
Reference in New Issue
Block a user