[PATCH] osmo-bts[master]: litecell15: Allow passing low quality buffers to upper layers

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Pau Espin Pedrol gerrit-no-reply at lists.osmocom.org
Thu Jun 29 10:29:09 UTC 2017


Review at  https://gerrit.osmocom.org/3077

litecell15: Allow passing low quality buffers to upper layers

We want to always call l1if_tch_rx in order to avoid losing triggering
events on the upper layer.

With this change, the upper layer will increase correctly seq + ts for
RTP. It will then send an RTP packet with only the header and no payload, which is
not correct but at least we avoid drifting the RTP clock. Upcoming patch
in the series solves this issue.

Change-Id: I3aba5949ce2ecb2ee3d8a8e57a3e6b2108691160
---
M src/osmo-bts-litecell15/l1_if.c
M src/osmo-bts-litecell15/l1_if.h
M src/osmo-bts-litecell15/tch.c
3 files changed, 20 insertions(+), 14 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/77/3077/1

diff --git a/src/osmo-bts-litecell15/l1_if.c b/src/osmo-bts-litecell15/l1_if.c
index 71bb833..6b5fbc6 100644
--- a/src/osmo-bts-litecell15/l1_if.c
+++ b/src/osmo-bts-litecell15/l1_if.c
@@ -929,6 +929,7 @@
 	uint8_t *data, len;
 	int rc = 0;
 	int8_t rssi;
+	bool low_quality = data_ind->measParam.fLinkQuality < btsb->min_qual_norm;
 
 	chan_nr = chan_nr_by_sapi(&trx->ts[data_ind->u8Tn], data_ind->sapi,
 		data_ind->subCh, data_ind->u8Tn, data_ind->u32Fn);
@@ -943,12 +944,6 @@
 
 	process_meas_res(trx, chan_nr, &data_ind->measParam);
 
-	if (data_ind->measParam.fLinkQuality < btsb->min_qual_norm
-	 && data_ind->msgUnitParam.u8Size != 0) {
-		msgb_free(l1p_msg);
-		return 0;
-	}
-
 	DEBUGP(DL1C, "Rx PH-DATA.ind %s (hL2 %08x): %s",
 		get_value_string(lc15bts_l1sapi_names, data_ind->sapi),
 		(uint32_t)data_ind->hLayer2,
@@ -960,9 +955,18 @@
 	if (data_ind->sapi == GsmL1_Sapi_TchF
 	 || data_ind->sapi == GsmL1_Sapi_TchH) {
 		/* TCH speech frame handling */
-		rc = l1if_tch_rx(trx, chan_nr, l1p_msg);
+		rc = l1if_tch_rx(trx, chan_nr, l1p_msg, low_quality);
 		msgb_free(l1p_msg);
 		return rc;
+	}
+
+	/* Discard frames with bad quality payload only after making sure we
+	 * signal upper layers for TCH frames, because it expects to always be
+	 * notified even if the content of the frame is not correct, otherwise
+	 * it losses events and the RTP clock drifts. */
+	if (low_quality && data_ind->msgUnitParam.u8Size != 0) {
+		msgb_free(l1p_msg);
+		return 0;
 	}
 
 	/* get rssi */
@@ -1575,4 +1579,3 @@
 
 	return 0;
 }
-
diff --git a/src/osmo-bts-litecell15/l1_if.h b/src/osmo-bts-litecell15/l1_if.h
index 7feee56..ecf9b6f 100644
--- a/src/osmo-bts-litecell15/l1_if.h
+++ b/src/osmo-bts-litecell15/l1_if.h
@@ -92,7 +92,7 @@
 int l1if_tch_encode(struct gsm_lchan *lchan, uint8_t *data, uint8_t *len,
 		    const uint8_t *rtp_pl, unsigned int rtp_pl_len, uint32_t fn,
 		    bool use_cache, bool marker);
-int l1if_tch_rx(struct gsm_bts_trx *trx, uint8_t chan_nr, struct msgb *l1p_msg);
+int l1if_tch_rx(struct gsm_bts_trx *trx, uint8_t chan_nr, struct msgb *l1p_msg, bool low_quality);
 int l1if_tch_fill(struct gsm_lchan *lchan, uint8_t *l1_buffer);
 struct msgb *gen_empty_tch_msg(struct gsm_lchan *lchan, uint32_t fn);
 
diff --git a/src/osmo-bts-litecell15/tch.c b/src/osmo-bts-litecell15/tch.c
index 8bed695..cccfb05 100644
--- a/src/osmo-bts-litecell15/tch.c
+++ b/src/osmo-bts-litecell15/tch.c
@@ -357,7 +357,7 @@
 }
 
 /*! \brief receive a traffic L1 primitive for a given lchan */
-int l1if_tch_rx(struct gsm_bts_trx *trx, uint8_t chan_nr, struct msgb *l1p_msg)
+int l1if_tch_rx(struct gsm_bts_trx *trx, uint8_t chan_nr, struct msgb *l1p_msg, bool low_quality)
 {
 	GsmL1_Prim_t *l1p = msgb_l1prim(l1p_msg);
 	GsmL1_PhDataInd_t *data_ind = &l1p->u.phDataInd;
@@ -368,10 +368,13 @@
 	if (is_recv_only(lchan->abis_ip.speech_mode))
 		return -EAGAIN;
 
-	if (data_ind->msgUnitParam.u8Size < 1) {
-		LOGP(DL1C, LOGL_ERROR, "chan_nr %d Rx Payload size 0\n",
-			chan_nr);
-		return -EINVAL;
+	if (low_quality || data_ind->msgUnitParam.u8Size < 1) {
+		LOGP(DL1C, LOGL_ERROR, "chan_nr %d Rx Payload size %u low_quality %d\n",
+			chan_nr, data_ind->msgUnitParam.u8Size, low_quality);
+
+		/* Push empty payload to upper layers */
+		rmsg = msgb_alloc_headroom(256, 128, "L1C-to-RTP");
+		return add_l1sap_header(trx, rmsg, lchan, chan_nr, data_ind->u32Fn);
 	}
 
 	payload_type = data_ind->msgUnitParam.u8Buffer[0];

-- 
To view, visit https://gerrit.osmocom.org/3077
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3aba5949ce2ecb2ee3d8a8e57a3e6b2108691160
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol <pespin at sysmocom.de>



More information about the gerrit-log mailing list