[PATCH] osmo-bts[master]: Allow passing low link 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
Fri Jun 30 17:13:50 UTC 2017


Hello Max, Harald Welte, Jenkins Builder,

I'd like you to reexamine a change.  Please visit

    https://gerrit.osmocom.org/3056

to look at the new patch set (#4).

Allow passing low link quality buffers to upper layers

We want to always call l1if_tch_rx and l1sap_up 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.

This patch assumes that we are not lossing data events from the physical
layer and that we receive an event every 20ms, even if the MS is not
transmitting due to DTX.

Depends on libosmocore If4ae20c22b881e94585dad710f17b9e37f77bf82

Change-Id: If5df8940fab833eb4e3ed851880b66987d356031
---
M include/osmo-bts/l1sap.h
M src/common/l1sap.c
M src/common/pcu_sock.c
M src/osmo-bts-litecell15/l1_if.c
M src/osmo-bts-litecell15/tch.c
M src/osmo-bts-octphy/l1_if.c
M src/osmo-bts-octphy/l1_tch.c
M src/osmo-bts-sysmo/l1_if.c
M src/osmo-bts-sysmo/tch.c
9 files changed, 49 insertions(+), 34 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/56/3056/4

diff --git a/include/osmo-bts/l1sap.h b/include/osmo-bts/l1sap.h
index 6373ba8..4e9c9e2 100644
--- a/include/osmo-bts/l1sap.h
+++ b/include/osmo-bts/l1sap.h
@@ -85,7 +85,8 @@
 extern uint8_t gsmtap_sapi_acch;
 
 int add_l1sap_header(struct gsm_bts_trx *trx, struct msgb *rmsg,
-		     struct gsm_lchan *lchan, uint8_t chan_nr, uint32_t fn);
+		     struct gsm_lchan *lchan, uint8_t chan_nr, uint32_t fn,
+		     uint16_t ber10k, int16_t lqual_cb);
 
 #define msgb_l1sap_prim(msg) ((struct osmo_phsap_prim *)(msg)->l1h)
 
diff --git a/src/common/l1sap.c b/src/common/l1sap.c
index 85d1dd1..076222b 100644
--- a/src/common/l1sap.c
+++ b/src/common/l1sap.c
@@ -135,11 +135,12 @@
 }
 
 int add_l1sap_header(struct gsm_bts_trx *trx, struct msgb *rmsg,
-		     struct gsm_lchan *lchan, uint8_t chan_nr, uint32_t fn)
+		     struct gsm_lchan *lchan, uint8_t chan_nr, uint32_t fn,
+		     uint16_t ber10k, int16_t lqual_cb)
 {
 	struct osmo_phsap_prim *l1sap;
 
-	LOGP(DL1C, LOGL_DEBUG, "%s Rx -> RTP: %s\n",
+	LOGP(DL1P, LOGL_DEBUG, "%s Rx -> RTP: %s\n",
 	     gsm_lchan_name(lchan), osmo_hexdump(rmsg->data, rmsg->len));
 
 	rmsg->l2h = rmsg->data;
@@ -150,6 +151,8 @@
 		       rmsg);
 	l1sap->u.tch.chan_nr = chan_nr;
 	l1sap->u.tch.fn = fn;
+	l1sap->u.tch.ber10k = ber10k;
+	l1sap->u.tch.lqual_cb = lqual_cb;
 
 	return l1sap_up(trx, l1sap);
 }
diff --git a/src/common/pcu_sock.c b/src/common/pcu_sock.c
index 2755048..a4ddc05 100644
--- a/src/common/pcu_sock.c
+++ b/src/common/pcu_sock.c
@@ -29,6 +29,7 @@
 #include <assert.h>
 #include <sys/socket.h>
 #include <sys/un.h>
+#include <inttypes.h>
 
 #include <osmocom/core/talloc.h>
 #include <osmocom/core/select.h>
@@ -329,11 +330,18 @@
 	struct gsm_pcu_if *pcu_prim;
 	struct gsm_pcu_if_data *data_ind;
 	struct gsm_bts *bts = ts->trx->bts;
+	struct gsm_bts_role_bts *btsb = bts_role_bts(bts);
 
 	LOGP(DPCU, LOGL_DEBUG, "Sending data indication: is_ptcch=%d arfcn=%d "
 		"block=%d data=%s\n", is_ptcch, arfcn, block_nr,
 		osmo_hexdump(data, len));
 
+	if (lqual / 10 < btsb->min_qual_norm) {
+		LOGP(DPCU, LOGL_DEBUG, "Link quality %"PRId16" is below threshold %f, dropping packet\n",
+			lqual, btsb->min_qual_norm);
+		return 0;
+	}
+
 	msg = pcu_msgb_alloc(PCU_IF_MSG_DATA_IND, bts->nr);
 	if (!msg)
 		return -ENOMEM;
diff --git a/src/osmo-bts-litecell15/l1_if.c b/src/osmo-bts-litecell15/l1_if.c
index bd9e003..66aa21a 100644
--- a/src/osmo-bts-litecell15/l1_if.c
+++ b/src/osmo-bts-litecell15/l1_if.c
@@ -923,7 +923,6 @@
 			      struct msgb *l1p_msg)
 {
 	struct gsm_bts_trx *trx = lc15l1_hdl_trx(fl1);
-	struct gsm_bts_role_bts *btsb = bts_role_bts(trx->bts);
 	uint8_t chan_nr, link_id;
 	struct osmo_phsap_prim *l1sap;
 	uint32_t fn;
@@ -943,12 +942,6 @@
 	link_id =  (data_ind->sapi == GsmL1_Sapi_Sacch) ? LID_SACCH : LID_DEDIC;
 
 	process_meas_res(trx, chan_nr, &data_ind->measParam, fn);
-
-	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),
diff --git a/src/osmo-bts-litecell15/tch.c b/src/osmo-bts-litecell15/tch.c
index a29733f..c61712f 100644
--- a/src/osmo-bts-litecell15/tch.c
+++ b/src/osmo-bts-litecell15/tch.c
@@ -369,9 +369,12 @@
 		return -EAGAIN;
 
 	if (data_ind->msgUnitParam.u8Size < 1) {
-		LOGP(DL1C, LOGL_ERROR, "chan_nr %d Rx Payload size 0\n",
-			chan_nr);
-		return -EINVAL;
+		LOGP(DL1P, LOGL_DEBUG, "chan_nr %d Rx Payload size 0\n", chan_nr);
+		/* Push empty payload to upper layers */
+		rmsg = msgb_alloc_headroom(256, 128, "L1P-to-RTP");
+		return add_l1sap_header(trx, rmsg, lchan, chan_nr, data_ind->u32Fn,
+					data_ind->measParam.fBer * 10000,
+					data_ind->measParam.fLinkQuality * 10);
 	}
 
 	payload_type = data_ind->msgUnitParam.u8Buffer[0];
@@ -459,8 +462,9 @@
 	}
 
 	if (rmsg)
-		return add_l1sap_header(trx, rmsg, lchan, chan_nr,
-					data_ind->u32Fn);
+		return add_l1sap_header(trx, rmsg, lchan, chan_nr, data_ind->u32Fn,
+					data_ind->measParam.fBer * 10000,
+					data_ind->measParam.fLinkQuality * 10);
 
 	return 0;
 
diff --git a/src/osmo-bts-octphy/l1_if.c b/src/osmo-bts-octphy/l1_if.c
index 427acdf..5785b9a 100644
--- a/src/osmo-bts-octphy/l1_if.c
+++ b/src/osmo-bts-octphy/l1_if.c
@@ -1050,8 +1050,6 @@
 	process_meas_res(trx, chan_nr, fn, data_ind->Data.ulDataLength,
 			 &data_ind->MeasurementInfo);
 
-	/* FIXME: check min_qual_norm! */
-
 	DEBUGP(DL1C, "Rx PH-DATA.ind %s: %s data_len:%d \n",
 	       get_value_string(octphy_l1sapi_names, sapi),
 	       osmo_hexdump(data_ind->Data.abyDataContent,
diff --git a/src/osmo-bts-octphy/l1_tch.c b/src/osmo-bts-octphy/l1_tch.c
index 79bf245..38fb9fb 100644
--- a/src/osmo-bts-octphy/l1_tch.c
+++ b/src/osmo-bts-octphy/l1_tch.c
@@ -188,16 +188,25 @@
 	uint32_t payload_type = data_ind->Data.ulPayloadType;
 	uint8_t *payload = data_ind->Data.abyDataContent;
 
+	uint16_t b_total = data_ind->MeasurementInfo.usBERTotalBitCnt;
+	uint16_t b_error = data_ind->MeasurementInfo.usBERCnt;
+	uint16_t ber10k = b_total ? BER_10K * b_error / b_total : 0;
+	int16_t lqual_cb = 0; /* FIXME: check min_qual_norm! */
+
 	uint8_t payload_len;
 	struct msgb *rmsg = NULL;
 	struct gsm_lchan *lchan =
 	    &trx->ts[L1SAP_CHAN2TS(chan_nr)].lchan[l1sap_chan2ss(chan_nr)];
 
 	if (data_ind->Data.ulDataLength < 1) {
-		LOGP(DL1C, LOGL_DEBUG, "chan_nr %d Rx Payload size 0\n",
-		     chan_nr);
-		return -EINVAL;
+		LOGP(DL1P, LOGL_DEBUG, "chan_nr %d Rx Payload size 0\n", chan_nr);
+		/* Push empty payload to upper layers */
+		rmsg = msgb_alloc_headroom(256, 128, "L1P-to-RTP");
+		return add_l1sap_header(trx, rmsg, lchan, chan_nr,
+					data_ind->Data.ulFrameNumber,
+					ber10k, lqual_cb);
 	}
+
 	payload_len = data_ind->Data.ulDataLength;
 
 	switch (payload_type) {
@@ -255,7 +264,8 @@
 
 	if (rmsg)
 		return add_l1sap_header(trx, rmsg, lchan, chan_nr,
-					data_ind->Data.ulFrameNumber);
+					data_ind->Data.ulFrameNumber,
+					ber10k, lqual_cb);
 
 	return 0;
 
diff --git a/src/osmo-bts-sysmo/l1_if.c b/src/osmo-bts-sysmo/l1_if.c
index 837fc5c..299a743 100644
--- a/src/osmo-bts-sysmo/l1_if.c
+++ b/src/osmo-bts-sysmo/l1_if.c
@@ -923,7 +923,6 @@
 			      struct msgb *l1p_msg)
 {
 	struct gsm_bts_trx *trx = femtol1_hdl_trx(fl1);
-	struct gsm_bts_role_bts *btsb = bts_role_bts(trx->bts);
 	uint8_t chan_nr, link_id;
 	struct msgb *sap_msg;
 	struct osmo_phsap_prim *l1sap;
@@ -942,12 +941,6 @@
 	link_id =  (data_ind->sapi == GsmL1_Sapi_Sacch) ? LID_SACCH : LID_DEDIC;
 
 	process_meas_res(trx, chan_nr, fn, &data_ind->measParam);
-
-	if (data_ind->measParam.fLinkQuality < btsb->min_qual_norm
-	 && data_ind->msgUnitParam.u8Size != 0) {
-		msgb_free(l1p_msg);
-		return 0;
-	}
 
 	DEBUGP(DL1P, "Rx PH-DATA.ind %s (hL2 %08x): %s",
 		get_value_string(femtobts_l1sapi_names, data_ind->sapi),
@@ -974,7 +967,7 @@
 	l1sap->u.data.chan_nr = chan_nr;
 	l1sap->u.data.fn = fn;
 	l1sap->u.data.rssi = (int8_t) (data_ind->measParam.fRssi);
-	if (!pcu_direct) {
+	if (!pcu_direct) { /* FIXME: if pcu_direct=1, then this is not set, what to do in pcu_tx_data_ind() in this case ?*/
 		l1sap->u.data.ber10k = data_ind->measParam.fBer * 10000;
 		l1sap->u.data.ta_offs_qbits = data_ind->measParam.i16BurstTiming;
 		l1sap->u.data.lqual_cb = data_ind->measParam.fLinkQuality * 10;
diff --git a/src/osmo-bts-sysmo/tch.c b/src/osmo-bts-sysmo/tch.c
index 6333d19..b65628f 100644
--- a/src/osmo-bts-sysmo/tch.c
+++ b/src/osmo-bts-sysmo/tch.c
@@ -514,9 +514,12 @@
 		return -EAGAIN;
 
 	if (data_ind->msgUnitParam.u8Size < 1) {
-		LOGP(DL1C, LOGL_ERROR, "chan_nr %d Rx Payload size 0\n",
-			chan_nr);
-		return -EINVAL;
+		LOGP(DL1P, LOGL_DEBUG, "chan_nr %d Rx Payload size 0\n", chan_nr);
+		/* Push empty payload to upper layers */
+		rmsg = msgb_alloc_headroom(256, 128, "L1P-to-RTP");
+		return add_l1sap_header(trx, rmsg, lchan, chan_nr, data_ind->u32Fn,
+					data_ind->measParam.fBer * 10000,
+					data_ind->measParam.fLinkQuality * 10);
 	}
 
 	payload_type = data_ind->msgUnitParam.u8Buffer[0];
@@ -605,11 +608,13 @@
 			return 0;
 		rmsg = l1_to_rtppayload_amr(sid_first, len, lchan);
 		break;
+	/* FIXME: what about GsmL1_TchPlType_Amr_SidBad? not well documented. */
 	}
 
 	if (rmsg)
-		return add_l1sap_header(trx, rmsg, lchan, chan_nr,
-					data_ind->u32Fn);
+		return add_l1sap_header(trx, rmsg, lchan, chan_nr, data_ind->u32Fn,
+					data_ind->measParam.fBer * 10000,
+					data_ind->measParam.fLinkQuality * 10);
 
 	return 0;
 

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: If5df8940fab833eb4e3ed851880b66987d356031
Gerrit-PatchSet: 4
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol <pespin at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max <msuraev at sysmocom.de>
Gerrit-Reviewer: Pau Espin Pedrol <pespin at sysmocom.de>



More information about the gerrit-log mailing list