[PATCH] osmo-bts[master]: Fill measurements data for L1SAP

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/.

Max gerrit-no-reply at lists.osmocom.org
Thu Aug 4 16:16:29 UTC 2016


Hello Harald Welte, Jenkins Builder,

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

    https://gerrit.osmocom.org/623

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

Fill measurements data for L1SAP

Fill in values for BER, BTO, Link quality in L1SAP and send them to
PCU. Note: this increases the version of BTS <-> PCU protocol. It also
requires corresponding changes in libosmocore.

All BTS models provide measurements data unless direct DSP access for
PCU is enabled. For BTS-specific notes see below.

Octphy: conversion from sSNRDb to Link Quality uses formulae which works
in practice instead of what's documented for sSNRDb value. Subject to
change in future revisions.

TRX: C / I link quality estimator is not computed.

Change-Id: Ic9693a044756fb1c7bd2ff3cfa0db042c3c4e01c
Related: OS#1616
---
M include/osmo-bts/pcu_if.h
M include/osmo-bts/pcuif_proto.h
M include/osmo-bts/scheduler_backend.h
M src/common/l1sap.c
M src/common/pcu_sock.c
M src/common/scheduler.c
M src/osmo-bts-litecell15/l1_if.c
M src/osmo-bts-octphy/l1_if.c
M src/osmo-bts-sysmo/l1_if.c
M src/osmo-bts-trx/scheduler_trx.c
10 files changed, 71 insertions(+), 18 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/23/623/5

diff --git a/include/osmo-bts/pcu_if.h b/include/osmo-bts/pcu_if.h
index 3ce4d0b..efad0c5 100644
--- a/include/osmo-bts/pcu_if.h
+++ b/include/osmo-bts/pcu_if.h
@@ -10,7 +10,7 @@
 	uint16_t arfcn, uint8_t block_nr);
 int pcu_tx_data_ind(struct gsm_bts_trx_ts *ts, uint8_t is_ptcch, uint32_t fn,
 	uint16_t arfcn, uint8_t block_nr, uint8_t *data, uint8_t len,
-	int8_t rssi);
+		    int8_t rssi, uint16_t ber10k, int16_t bto, int16_t lqual);
 int pcu_tx_rach_ind(struct gsm_bts *bts, int16_t qta, uint8_t ra, uint32_t fn);
 int pcu_tx_time_ind(uint32_t fn);
 int pcu_tx_pag_req(const uint8_t *identity_lv, uint8_t chan_needed);
diff --git a/include/osmo-bts/pcuif_proto.h b/include/osmo-bts/pcuif_proto.h
index 9d740ac..07d35f8 100644
--- a/include/osmo-bts/pcuif_proto.h
+++ b/include/osmo-bts/pcuif_proto.h
@@ -1,7 +1,7 @@
 #ifndef _PCUIF_PROTO_H
 #define _PCUIF_PROTO_H
 
-#define PCU_IF_VERSION		0x05
+#define PCU_IF_VERSION		0x06
 
 /* msg_type */
 #define PCU_IF_MSG_DATA_REQ	0x00	/* send data to given channel */
@@ -50,6 +50,9 @@
 	uint8_t		ts_nr;
 	uint8_t		block_nr;
 	int8_t		rssi;
+	uint16_t	ber10k;		/*!< \brief BER in units of 0.01% */
+	int16_t		ta_offs_qbits;	/* !< \brief Burst TA Offset in quarter bits */
+	int16_t		lqual_cb;	/* !< \brief Link quality in centiBel */
 } __attribute__ ((packed));
 
 struct gsm_pcu_if_rts_req {
diff --git a/include/osmo-bts/scheduler_backend.h b/include/osmo-bts/scheduler_backend.h
index 68f0c60..e63b961 100644
--- a/include/osmo-bts/scheduler_backend.h
+++ b/include/osmo-bts/scheduler_backend.h
@@ -43,7 +43,11 @@
 				 enum trx_chan_type chan);
 
 int _sched_compose_ph_data_ind(struct l1sched_trx *l1t, uint8_t tn, uint32_t fn,
-				enum trx_chan_type chan, uint8_t *l2, uint8_t l2_len, float rssi, enum osmo_ph_pres_info_type presence_info);
+			       enum trx_chan_type chan, uint8_t *l2,
+			       uint8_t l2_len, float rssi,
+			       int16_t ta_offs_qbits, int16_t link_qual_cb,
+			       uint16_t ber10k,
+			       enum osmo_ph_pres_info_type presence_info);
 
 int _sched_compose_tch_ind(struct l1sched_trx *l1t, uint8_t tn, uint32_t fn,
 		    enum trx_chan_type chan, uint8_t *tch, uint8_t tch_len);
diff --git a/src/common/l1sap.c b/src/common/l1sap.c
index 7f73e3f..4fc7801 100644
--- a/src/common/l1sap.c
+++ b/src/common/l1sap.c
@@ -812,7 +812,9 @@
 		if (L1SAP_IS_PTCCH(fn)) {
 			pcu_tx_data_ind(&trx->ts[tn], 1, fn,
 				0 /* ARFCN */, L1SAP_FN2PTCCHBLOCK(fn),
-				data, len, rssi);
+					data, len, rssi, data_ind->ber10k,
+					data_ind->ta_offs_qbits,
+					data_ind->lqual_cb);
 
 			return 0;
 		}
@@ -821,7 +823,8 @@
 			return 0;
 		/* PDTCH / PACCH frame handling */
 		pcu_tx_data_ind(&trx->ts[tn], 0, fn, 0 /* ARFCN */,
-			L1SAP_FN2MACBLOCK(fn), data, len, rssi);
+			L1SAP_FN2MACBLOCK(fn), data, len, rssi, data_ind->ber10k,
+				data_ind->ta_offs_qbits, data_ind->lqual_cb);
 
 		return 0;
 	}
diff --git a/src/common/pcu_sock.c b/src/common/pcu_sock.c
index 22b6fab..fed464f 100644
--- a/src/common/pcu_sock.c
+++ b/src/common/pcu_sock.c
@@ -337,7 +337,7 @@
 
 int pcu_tx_data_ind(struct gsm_bts_trx_ts *ts, uint8_t is_ptcch, uint32_t fn,
 	uint16_t arfcn, uint8_t block_nr, uint8_t *data, uint8_t len,
-	int8_t rssi)
+	int8_t rssi, uint16_t ber10k, int16_t bto, int16_t lqual)
 {
 	struct msgb *msg;
 	struct gsm_pcu_if *pcu_prim;
@@ -362,6 +362,9 @@
 	data_ind->ts_nr = ts->nr;
 	data_ind->block_nr = block_nr;
 	data_ind->rssi = rssi;
+	data_ind->ber10k = ber10k;
+	data_ind->ta_offs_qbits = bto;
+	data_ind->lqual_cb = lqual;
 	memcpy(data_ind->data, data, len);
 	data_ind->len = len;
 
diff --git a/src/common/scheduler.c b/src/common/scheduler.c
index eeaf2c1..ec66cfc 100644
--- a/src/common/scheduler.c
+++ b/src/common/scheduler.c
@@ -295,7 +295,11 @@
 }
 
 int _sched_compose_ph_data_ind(struct l1sched_trx *l1t, uint8_t tn, uint32_t fn,
-				enum trx_chan_type chan, uint8_t *l2, uint8_t l2_len, float rssi, enum osmo_ph_pres_info_type presence_info)
+			       enum trx_chan_type chan, uint8_t *l2,
+			       uint8_t l2_len, float rssi,
+			       int16_t ta_offs_qbits, int16_t link_qual_cb,
+			       uint16_t ber10k,
+			       enum osmo_ph_pres_info_type presence_info)
 {
 	struct msgb *msg;
 	struct osmo_phsap_prim *l1sap;
@@ -311,6 +315,9 @@
 	l1sap->u.data.link_id = trx_chan_desc[chan].link_id;
 	l1sap->u.data.fn = fn;
 	l1sap->u.data.rssi = (int8_t) (rssi);
+	l1sap->u.data.ber10k = ber10k;
+	l1sap->u.data.ta_offs_qbits = ta_offs_qbits;
+	l1sap->u.data.lqual_cb = link_qual_cb;
 	l1sap->u.data.pdch_presence_info = presence_info;
 	msg->l2h = msgb_put(msg, l2_len);
 	if (l2_len)
diff --git a/src/osmo-bts-litecell15/l1_if.c b/src/osmo-bts-litecell15/l1_if.c
index a979bd7..dcd25ee 100644
--- a/src/osmo-bts-litecell15/l1_if.c
+++ b/src/osmo-bts-litecell15/l1_if.c
@@ -916,7 +916,11 @@
 	l1sap->u.data.chan_nr = chan_nr;
 	l1sap->u.data.fn = fn;
 	l1sap->u.data.rssi = rssi;
-
+	if (!pcu_direct) {
+		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;
+	}
 	return l1sap_up(trx, l1sap);
 }
 
diff --git a/src/osmo-bts-octphy/l1_if.c b/src/osmo-bts-octphy/l1_if.c
index 760c988..d621bcf 100644
--- a/src/osmo-bts-octphy/l1_if.c
+++ b/src/osmo-bts-octphy/l1_if.c
@@ -961,7 +961,8 @@
 	struct osmo_phsap_prim *l1sap;
 	uint32_t fn;
 	uint8_t *data;
-	uint16_t len;
+	uint16_t len, b_total, b_error;
+	int16_t snr;
 	int8_t rssi;
 	int rc;
 
@@ -1029,6 +1030,16 @@
 	l1sap->u.data.chan_nr = chan_nr;
 	l1sap->u.data.fn = fn;
 	l1sap->u.data.rssi = rssi;
+	b_total = data_ind->MeasurementInfo.usBERTotalBitCnt;
+	b_error =data_ind->MeasurementInfo.usBERCnt;
+	l1sap->u.data.ber10k = b_total ? 10000 * b_error / b_total : 0;
+	l1sap->u.data.ta_offs_qbits = data_ind->MeasurementInfo.sBurstTiming4x;
+	snr = data_ind->MeasurementInfo.sSNRDb;
+	/* FIXME: better converion formulae for SnR -> C / I?
+	l1sap->u.data.lqual_cb = (snr ? snr : (snr - 65536)) * 10 / 256;
+	LOGP(DL1C, LOGL_ERROR, "SnR: raw %d, computed %d\n", snr, l1sap->u.data.lqual_cb);
+	*/
+	l1sap->u.data.lqual_cb = (snr ? snr : (snr - 65536)) * 100;
 	l1sap->u.data.pdch_presence_info = PRES_INFO_BOTH; /* FIXME: consider EDGE support */
 
 	l1sap_up(trx, l1sap);
diff --git a/src/osmo-bts-sysmo/l1_if.c b/src/osmo-bts-sysmo/l1_if.c
index 45de199..f70ccf5 100644
--- a/src/osmo-bts-sysmo/l1_if.c
+++ b/src/osmo-bts-sysmo/l1_if.c
@@ -904,7 +904,11 @@
 	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) {
+		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;
+	}
 	/* copy data from L1 primitive to L1SAP primitive */
 	sap_msg->l2h = msgb_put(sap_msg, data_ind->msgUnitParam.u8Size);
 	memcpy(sap_msg->l2h, data_ind->msgUnitParam.u8Buffer,
diff --git a/src/osmo-bts-trx/scheduler_trx.c b/src/osmo-bts-trx/scheduler_trx.c
index 3a6ede3..e02232b 100644
--- a/src/osmo-bts-trx/scheduler_trx.c
+++ b/src/osmo-bts-trx/scheduler_trx.c
@@ -200,8 +200,10 @@
 			/* Send uplnk measurement information to L2 */
 			l1if_process_meas_res(l1t->trx, tn, fn, trx_chan_desc[chan].chan_nr | tn,
 				456, 456, -110, 0);
-
-			_sched_compose_ph_data_ind(l1t, tn, 0, chan, NULL, 0, -110, PRES_INFO_INVALID);
+			/* FIXME: use actual values for BER etc */
+			_sched_compose_ph_data_ind(l1t, tn, 0, chan, NULL, 0,
+						   -110, 0, 0, 10000,
+						   PRES_INFO_INVALID);
 		}
 	}
 
@@ -886,8 +888,12 @@
 	/* Send uplnk measurement information to L2 */
 	l1if_process_meas_res(l1t->trx, tn, fn, trx_chan_desc[chan].chan_nr | tn,
 		n_errors, n_bits_total, *rssi_sum / *rssi_num, *toa_sum / *toa_num);
-
-	return _sched_compose_ph_data_ind(l1t, tn, *first_fn, chan, l2, l2_len, *rssi_sum / *rssi_num, PRES_INFO_UNKNOWN);
+	uint16_t ber10k =
+		(n_bits_total == 0) ? 10000 : 10000 * n_errors / n_bits_total;
+	return _sched_compose_ph_data_ind(l1t, tn, *first_fn, chan, l2, l2_len,
+					  *rssi_sum / *rssi_num,
+					  4 * (*toa_sum) / *toa_num, 0, ber10k,
+					  PRES_INFO_UNKNOWN);
 }
 
 int rx_pdtch_fn(struct l1sched_trx *l1t, uint8_t tn, uint32_t fn,
@@ -985,9 +991,11 @@
 			l1ts->mf_period, trx_chan_desc[chan].name);
 		return 0;
 	}
-
+	uint16_t ber10k =
+		(n_bits_total == 0) ? 10000 : 10000 * n_errors / n_bits_total;
 	return _sched_compose_ph_data_ind(l1t, tn, (fn + GSM_HYPERFRAME - 3) % GSM_HYPERFRAME, chan,
-		l2, rc, *rssi_sum / *rssi_num, PRES_INFO_BOTH);
+		l2, rc, *rssi_sum / *rssi_num, 4 * (*toa_sum) / *toa_num, 0,
+					  ber10k, PRES_INFO_BOTH);
 }
 
 int rx_tchf_fn(struct l1sched_trx *l1t, uint8_t tn, uint32_t fn,
@@ -1105,8 +1113,11 @@
 
 	/* FACCH */
 	if (rc == GSM_MACBLOCK_LEN) {
+		uint16_t ber10k = (n_bits_total == 0) ? 10000 :
+			10000 * n_errors / n_bits_total;
 		_sched_compose_ph_data_ind(l1t, tn, (fn + GSM_HYPERFRAME - 7) % GSM_HYPERFRAME, chan,
-			tch_data + amr, GSM_MACBLOCK_LEN, rssi, PRES_INFO_UNKNOWN);
+			tch_data + amr, GSM_MACBLOCK_LEN, rssi, 4 * toa, 0,
+					   ber10k, PRES_INFO_UNKNOWN);
 bfi:
 		if (rsl_cmode == RSL_CMOD_SPD_SPEECH) {
 			/* indicate bad frame */
@@ -1275,9 +1286,12 @@
 	/* FACCH */
 	if (rc == GSM_MACBLOCK_LEN) {
 		chan_state->ul_ongoing_facch = 1;
+		uint16_t ber10k =
+		(n_bits_total == 0) ? 10000 : 10000 * n_errors / n_bits_total;
 		_sched_compose_ph_data_ind(l1t, tn,
 			(fn + GSM_HYPERFRAME - 10 - ((fn % 26) >= 19)) % GSM_HYPERFRAME, chan,
-			tch_data + amr, GSM_MACBLOCK_LEN, rssi, PRES_INFO_UNKNOWN);
+			tch_data + amr, GSM_MACBLOCK_LEN, rssi, 4 * toa, 0,
+					   ber10k, PRES_INFO_UNKNOWN);
 bfi:
 		if (rsl_cmode == RSL_CMOD_SPD_SPEECH) {
 			/* indicate bad frame */

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ic9693a044756fb1c7bd2ff3cfa0db042c3c4e01c
Gerrit-PatchSet: 5
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Max <msuraev at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max <msuraev at sysmocom.de>



More information about the gerrit-log mailing list