Change in osmo-bts[master]: l1sap: merge MEAS IND into PRIM PH DATA / PRIM TCH

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

dexter gerrit-no-reply at lists.osmocom.org
Thu Oct 31 10:38:08 UTC 2019


dexter has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-bts/+/15918 )


Change subject: l1sap: merge MEAS IND into PRIM PH DATA / PRIM TCH
......................................................................

l1sap: merge MEAS IND into PRIM PH DATA / PRIM TCH

The MPH INFO MEAS IND indication, which contains the uplink measurement
data is sent in parallel to the PH DATA and TCH indications as a
separate indications. This makes the overall uplink measurement data
processing unnecessarly complex. So lets put the data that is relevant
for measurement into the PH DATA and TCH indications directly.

This change only affects osmo-bts-trx at the moment. In order to keep
the upper layers (l1sap.c) compatible we add an autodection to switch
between separate measurement indications and included measurement data.

Related: OS#2977
Depends: libosmocore I2c34b02d329f9df190c5035c396403ca0a4f9c42
Change-Id: I710d0b7cf193afa8515807836ee69b8b7db84a84
---
M include/osmo-bts/scheduler_backend.h
M src/common/l1sap.c
M src/common/scheduler.c
M src/osmo-bts-trx/l1_if.c
M src/osmo-bts-trx/l1_if.h
M src/osmo-bts-trx/scheduler_trx.c
6 files changed, 114 insertions(+), 96 deletions(-)



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

diff --git a/include/osmo-bts/scheduler_backend.h b/include/osmo-bts/scheduler_backend.h
index d713900..4959853 100644
--- a/include/osmo-bts/scheduler_backend.h
+++ b/include/osmo-bts/scheduler_backend.h
@@ -52,7 +52,8 @@
 			       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);
+			   enum trx_chan_type chan, uint8_t *tch, uint8_t tch_len,
+			   int16_t ta_offs_256bits, uint16_t ber10k, float rssi);
 
 ubit_t *tx_idle_fn(struct l1sched_trx *l1t, uint8_t tn, uint32_t fn,
 	enum trx_chan_type chan, uint8_t bid, uint16_t *nbits);
diff --git a/src/common/l1sap.c b/src/common/l1sap.c
index 7bf0b09..ec6f287 100644
--- a/src/common/l1sap.c
+++ b/src/common/l1sap.c
@@ -62,6 +62,17 @@
 #define CB_BCCH		-3
 #define CB_IDLE		-4
 
+/* We are capable to use two different sources to receive measurement data from
+ * lower layers. The first source is the MPH INFO MEAS IND, which is an
+ * indication for itsself that is passed up in parallel to the payload data
+ * (see also PRIM_PH_DATA, PRIM_TCH). This idea is obsolete, however it is
+ * still used with some BTS implementations). The second source is to use the
+ * measurement data that is contained inside struct ph_data_param
+ * (PRIM_PH_DATA) and struct ph_tch_param (PRIM_TCH). Which source is used is
+ * determined automatically. Once we receive an MPH INFO MEAS IND, we fall back
+ * to the old (first) source. (See also ticket: OS#2977) */
+static bool tch_data_meas_present = true;
+
 /* according to TS 05.02 Clause 7 Table 3 of 9 an Figure 8a */
 static const int ccch_block_table[51] = {
 	CB_FCCH, CB_SCH,/* 0..1 */
@@ -626,42 +637,81 @@
 }
 
 /* measurement information received from bts model */
-static int l1sap_info_meas_ind(struct gsm_bts_trx *trx,
-	struct osmo_phsap_prim *l1sap,
-	struct info_meas_ind_param *info_meas_ind)
+static void process_l1sap_meas_data(struct gsm_bts_trx *trx,
+				    struct osmo_phsap_prim *l1sap,
+				    enum osmo_ph_prim ind_type)
 {
 	struct bts_ul_meas ulm;
 	struct gsm_lchan *lchan;
+	struct info_meas_ind_param *info_meas_ind = &l1sap->u.info.u.meas_ind;
+	struct ph_data_param *ph_data_ind = &l1sap->u.data;
+	struct ph_tch_param *ph_tch_ind = &l1sap->u.tch;
+	uint8_t chan_nr;
+	uint32_t fn;
+	uint8_t inv_rssi;
+	uint8_t is_sub;
+	int16_t ta_offs_256bits;
+	uint16_t ber10k;
 
-	lchan = get_active_lchan_by_chan_nr(trx, info_meas_ind->chan_nr);
-	if (!lchan) {
-		LOGPFN(DL1P, LOGL_ERROR, info_meas_ind->fn,
-			"No lchan for MPH INFO MEAS IND (chan_nr=%s)\n", rsl_chan_nr_str(info_meas_ind->chan_nr));
-		return 0;
+	switch (ind_type) {
+	case PRIM_MPH_INFO:
+		/* (legacy way, see also OS#2977) */
+		chan_nr = info_meas_ind->chan_nr;
+		fn = info_meas_ind->fn;
+		inv_rssi = info_meas_ind->inv_rssi;
+		is_sub = info_meas_ind->is_sub;
+		ta_offs_256bits = info_meas_ind->ta_offs_256bits;
+		ber10k = info_meas_ind->ber10k;
+		break;
+	case PRIM_TCH:
+		chan_nr = ph_tch_ind->chan_nr;
+		fn = ph_tch_ind->fn;
+		inv_rssi = abs(ph_tch_ind->rssi);
+		is_sub = ph_tch_ind->is_sub;
+		ta_offs_256bits = ph_tch_ind->ta_offs_256bits;
+		ber10k = ph_tch_ind->ber10k;
+		break;
+	case PRIM_PH_DATA:
+		chan_nr = ph_data_ind->chan_nr;
+		fn = ph_data_ind->fn;
+		inv_rssi = abs(ph_data_ind->rssi);
+		is_sub = ph_data_ind->is_sub;
+		ta_offs_256bits = ph_data_ind->ta_offs_256bits;
+		ber10k = ph_data_ind->ber10k;
+		break;
+	default:
+		OSMO_ASSERT(false);
 	}
 
-	DEBUGPFN(DL1P, info_meas_ind->fn,
-		"%s MPH_INFO meas ind, ta_offs_256bits=%d, ber10k=%d, inv_rssi=%u\n",
-		gsm_lchan_name(lchan), info_meas_ind->ta_offs_256bits,
-		info_meas_ind->ber10k, info_meas_ind->inv_rssi);
+	lchan = get_active_lchan_by_chan_nr(trx, chan_nr);
+	if (!lchan) {
+		LOGPFN(DL1P, LOGL_ERROR, fn,
+		       "No lchan for MPH INFO MEAS IND (chan_nr=%s)\n",
+		       rsl_chan_nr_str(chan_nr));
+		return;
+	}
+
+	DEBUGPFN(DL1P, fn,
+		 "%s MPH_INFO meas ind, ta_offs_256bits=%d, ber10k=%d, inv_rssi=%u\n",
+		 gsm_lchan_name(lchan), ta_offs_256bits, ber10k, inv_rssi);
 
 	/* in the GPRS case we are not interested in measurement
 	 * processing.  The PCU will take care of it */
 	if (lchan->type == GSM_LCHAN_PDTCH)
-		return 0;
+		return;
 
 	memset(&ulm, 0, sizeof(ulm));
-	ulm.ta_offs_256bits = info_meas_ind->ta_offs_256bits;
-	ulm.ber10k = info_meas_ind->ber10k;
-	ulm.inv_rssi = info_meas_ind->inv_rssi;
-	ulm.is_sub = info_meas_ind->is_sub;
+	ulm.ta_offs_256bits = ta_offs_256bits;
+	ulm.ber10k = ber10k;
+	ulm.inv_rssi = inv_rssi;
+	ulm.is_sub = is_sub;
 
 	/* we assume that symbol period is 1 bit: */
-	set_ms_to_data(lchan, info_meas_ind->ta_offs_256bits / 256, true);
+	set_ms_to_data(lchan, ta_offs_256bits / 256, true);
 
-	lchan_meas_process_measurement(lchan, &ulm, info_meas_ind->fn);
+	lchan_meas_process_measurement(lchan, &ulm, fn);
 
-	return 0;
+	return;
 }
 
 /* any L1 MPH_INFO indication prim received from bts model */
@@ -682,7 +732,12 @@
 						 &info->u.time_ind);
 		break;
 	case PRIM_INFO_MEAS:
-		rc = l1sap_info_meas_ind(trx, l1sap, &info->u.meas_ind);
+		/* See above */
+		LOGP(DL1P, LOGL_NOTICE, "MPH_INFO MEAS IND received, will now only use data from MEAS IND! (OS#2977)\n");
+	        tch_data_meas_present = false;
+
+		process_l1sap_meas_data(trx, l1sap, PRIM_MPH_INFO);
+		rc = 0;
 		break;
 	default:
 		LOGP(DL1P, LOGL_NOTICE, "unknown MPH_INFO ind type %d\n",
@@ -1197,6 +1252,12 @@
 		return -EINVAL;
 	}
 
+	/* The ph_data_param contained in the l1sap primitive may contain
+	 * measurement data. If this data is present, forward it for
+	 * processing */
+	if (tch_data_meas_present == true)
+		process_l1sap_meas_data(trx, l1sap, PRIM_PH_DATA);
+
 	if (ts_is_pdch(&trx->ts[tn])) {
 		lchan = get_lchan_by_chan_nr(trx, chan_nr);
 		if (!lchan)
@@ -1301,6 +1362,12 @@
 		return 0;
 	}
 
+	/* The ph_tch_param contained in the l1sap primitive may contain
+	 * measurement data. If this data is present, forward it for
+	 * processing */
+	if (tch_data_meas_present == true)
+		process_l1sap_meas_data(trx, l1sap, PRIM_TCH);
+
 	msgb_pull(msg, sizeof(*l1sap));
 
 	/* Low level layers always call us when TCH content is expected, even if
diff --git a/src/common/scheduler.c b/src/common/scheduler.c
index 3adfc49..7155cbb 100644
--- a/src/common/scheduler.c
+++ b/src/common/scheduler.c
@@ -738,7 +738,8 @@
 }
 
 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)
+			   enum trx_chan_type chan, uint8_t *tch, uint8_t tch_len,
+			   int16_t ta_offs_256bits, uint16_t ber10k, float rssi)
 {
 	struct msgb *msg;
 	struct osmo_phsap_prim *l1sap;
@@ -754,6 +755,10 @@
 		PRIM_OP_INDICATION, msg);
 	l1sap->u.tch.chan_nr = chan_nr;
 	l1sap->u.tch.fn = fn;
+	l1sap->u.tch.rssi = (int8_t) (rssi);
+	l1sap->u.tch.ber10k = ber10k;
+	l1sap->u.tch.ta_offs_256bits = ta_offs_256bits;
+
 	msg->l2h = msgb_put(msg, tch_len);
 	if (tch_len)
 		memcpy(msg->l2h, tch, tch_len);
diff --git a/src/osmo-bts-trx/l1_if.c b/src/osmo-bts-trx/l1_if.c
index 38b43b9..b28c894 100644
--- a/src/osmo-bts-trx/l1_if.c
+++ b/src/osmo-bts-trx/l1_if.c
@@ -572,40 +572,6 @@
 	return l1sap_up(bts->c0, &l1sap);
 }
 
-
-static void l1if_fill_meas_res(struct osmo_phsap_prim *l1sap, uint8_t chan_nr, int16_t toa256,
-	float ber, float rssi, uint32_t fn)
-{
-	memset(l1sap, 0, sizeof(*l1sap));
-	osmo_prim_init(&l1sap->oph, SAP_GSM_PH, PRIM_MPH_INFO,
-		PRIM_OP_INDICATION, NULL);
-	l1sap->u.info.type = PRIM_INFO_MEAS;
-	l1sap->u.info.u.meas_ind.chan_nr = chan_nr;
-	l1sap->u.info.u.meas_ind.ta_offs_256bits = toa256;
-	l1sap->u.info.u.meas_ind.ber10k = (unsigned int) (ber * 10000);
-	l1sap->u.info.u.meas_ind.inv_rssi = (uint8_t) (rssi * -1);
-	l1sap->u.info.u.meas_ind.fn = fn;
-}
-
-int l1if_process_meas_res(struct gsm_bts_trx *trx, uint8_t tn, uint32_t fn, uint8_t chan_nr,
-	int n_errors, int n_bits_total, float rssi, int16_t toa256)
-{
-	struct gsm_lchan *lchan = &trx->ts[tn].lchan[l1sap_chan2ss(chan_nr)];
-	struct osmo_phsap_prim l1sap;
-	/* 100% BER is n_bits_total is 0 */
-	float ber = n_bits_total==0 ? 1.0 : (float)n_errors / (float)n_bits_total;
-
-	LOGPFN(DMEAS, LOGL_DEBUG, fn, "RX UL measurement for %s fn=%u chan_nr=0x%02x MS pwr=%ddBm rssi=%.1f dBFS "
-		"ber=%.2f%% (%d/%d bits) L1_ta=%d rqd_ta=%d toa256=%d\n",
-		gsm_lchan_name(lchan), fn, chan_nr, ms_pwr_dbm(lchan->ts->trx->bts->band, lchan->ms_power_ctrl.current),
-		rssi, ber*100, n_errors, n_bits_total, lchan->meas.l1_info[1], lchan->rqd_ta, toa256);
-
-	l1if_fill_meas_res(&l1sap, chan_nr, toa256, ber, rssi, fn);
-
-	return l1sap_up(trx, &l1sap);
-}
-
-
 /* primitive from common part */
 int bts_model_l1sap_down(struct gsm_bts_trx *trx, struct osmo_phsap_prim *l1sap)
 {
diff --git a/src/osmo-bts-trx/l1_if.h b/src/osmo-bts-trx/l1_if.h
index 4ff1f97..7370999 100644
--- a/src/osmo-bts-trx/l1_if.h
+++ b/src/osmo-bts-trx/l1_if.h
@@ -115,8 +115,6 @@
 int l1if_provision_transceiver_trx(struct trx_l1h *l1h);
 int l1if_provision_transceiver(struct gsm_bts *bts);
 int l1if_mph_time_ind(struct gsm_bts *bts, uint32_t fn);
-int l1if_process_meas_res(struct gsm_bts_trx *trx, uint8_t tn, uint32_t fn, uint8_t chan_nr,
-	int n_errors, int n_bits_total, float rssi, int16_t toa256);
 
 static inline struct l1sched_trx *trx_l1sched_hdl(struct gsm_bts_trx *trx)
 {
diff --git a/src/osmo-bts-trx/scheduler_trx.c b/src/osmo-bts-trx/scheduler_trx.c
index 88e4f3a..3f6d604 100644
--- a/src/osmo-bts-trx/scheduler_trx.c
+++ b/src/osmo-bts-trx/scheduler_trx.c
@@ -198,11 +198,6 @@
 		if (++(l1ts->chan_state[chan].lost_frames) > 1) {
 			/* TODO: Should we pass old TOA here? Otherwise we risk
 			 * unnecessary decreasing TA */
-
-			/* Send uplink measurement information to L2 */
-			l1if_process_meas_res(l1t->trx, tn, fn, trx_chan_desc[chan].chan_nr | tn,
-				456, 456, -110, 0);
-			/* 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);
@@ -351,6 +346,9 @@
 	uint8_t rsl_cmode = chan_state->rsl_cmode;
 	uint8_t tch_mode = chan_state->tch_mode;
 	struct osmo_phsap_prim *l1sap;
+	int32_t *toa256_sum = &chan_state->toa256_sum;
+	uint8_t *toa_num = &chan_state->toa_num;
+	int16_t toa256;
 
 	/* handle loss detection of received TCH frames */
 	if (rsl_cmode == RSL_CMOD_SPD_SPEECH
@@ -396,8 +394,14 @@
 			LOGL1S(DL1P, LOGL_ERROR, l1t, tn, chan, fn, "TCH mode invalid, please fix!\n");
 			len = 0;
 		}
-		if (len)
-			_sched_compose_tch_ind(l1t, tn, fn, chan, tch_data, len);
+
+		if (len) {
+			if (*toa_num == 0)
+				toa256 = 0;
+			else
+				toa256 = *toa256_sum / *toa_num;
+			_sched_compose_tch_ind(l1t, tn, fn, chan, tch_data, len, toa256, 10000, 127);
+		}
 	}
 
 	/* get frame and unlink from queue */
@@ -989,11 +993,6 @@
 		l2_len = GSM_MACBLOCK_LEN;
 
 	/* Send uplink measurement information to L2 */
-	l1if_process_meas_res(l1t->trx, bi->tn, *first_fn,
-			      trx_chan_desc[chan].chan_nr | bi->tn,
-			      n_errors, n_bits_total,
-			      *rssi_sum / *rssi_num,
-			      *toa256_sum / *toa_num);
 	lqual_cb = *ci_cb_num ? (*ci_cb_sum / *ci_cb_num) : 0;
 	ber10k = compute_ber10k(n_bits_total, n_errors);
 	return _sched_compose_ph_data_ind(l1t, bi->tn, *first_fn,
@@ -1103,12 +1102,6 @@
 
 
 	/* Send uplink measurement information to L2 */
-	l1if_process_meas_res(l1t->trx, bi->tn, *first_fn,
-		trx_chan_desc[chan].chan_nr | bi->tn,
-		n_errors, n_bits_total,
-		*rssi_sum / *rssi_num,
-		*toa256_sum / *toa_num);
-
 	if (rc <= 0) {
 		LOGL1S(DL1P, LOGL_DEBUG, l1t, bi->tn, chan, bi->fn,
 			"Received bad PDTCH (%u/%u)\n",
@@ -1144,6 +1137,7 @@
 	struct gsm_lchan *lchan =
 		get_lchan_by_chan_nr(l1t->trx, trx_chan_desc[chan].chan_nr | bi->tn);
 	unsigned int fn_begin;
+	uint16_t ber10k;
 
 	/* handle rach, if handover rach detection is turned on */
 	if (chan_state->ho_rach_detect == 1)
@@ -1243,17 +1237,13 @@
 	if (rc != GSM_MACBLOCK_LEN && lchan->ecu_state)
 		osmo_ecu_frame_in(lchan->ecu_state, bfi_flag, tch_data, rc);
 
+	ber10k = compute_ber10k(n_bits_total, n_errors);
 	if (bfi_flag)
 		goto bfi;
 
 	/* FACCH */
 	if (rc == GSM_MACBLOCK_LEN) {
-		uint16_t ber10k = compute_ber10k(n_bits_total, n_errors);
 		fn_begin = gsm0502_fn_remap(bi->fn, FN_REMAP_FACCH_F);
-		l1if_process_meas_res(l1t->trx, bi->tn, fn_begin,
-				      trx_chan_desc[chan].chan_nr | bi->tn,
-				      n_errors, n_bits_total,
-				      bi->rssi, bi->toa256);
 		_sched_compose_ph_data_ind(l1t, bi->tn, fn_begin, chan,
 			tch_data + amr, GSM_MACBLOCK_LEN,
 			/* FIXME: AVG RSSI and ToA256 */
@@ -1314,12 +1304,8 @@
 	/* TCH or BFI */
 compose_l1sap:
 	fn_begin = gsm0502_fn_remap(bi->fn, FN_REMAP_TCH_F);
-	l1if_process_meas_res(l1t->trx, bi->tn, fn_begin,
-			      trx_chan_desc[chan].chan_nr | bi->tn,
-			      n_errors, n_bits_total,
-			      bi->rssi, bi->toa256);
 	return _sched_compose_tch_ind(l1t, bi->tn, fn_begin, chan,
-				      tch_data, rc);
+				      tch_data, rc, bi->toa256, ber10k, bi->rssi);
 }
 
 /*! \brief a single TCH/H burst was received by the PHY, process it */
@@ -1345,6 +1331,7 @@
 	 */
 	int fn_is_odd = (((bi->fn + 26 - 10) % 26) >> 2) & 1;
 	unsigned int fn_begin;
+	uint16_t ber10k;
 
 	/* handle RACH, if handover RACH detection is turned on */
 	if (chan_state->ho_rach_detect == 1)
@@ -1387,6 +1374,8 @@
 	}
 	*mask = 0x0;
 
+        ber10k = compute_ber10k(n_bits_total, n_errors);
+
 	/* skip second of two TCH frames of FACCH was received */
 	if (chan_state->ul_ongoing_facch) {
 		chan_state->ul_ongoing_facch = 0;
@@ -1466,10 +1455,6 @@
 			fn_begin = gsm0502_fn_remap(bi->fn, FN_REMAP_FACCH_H0);
 		else
 			fn_begin = gsm0502_fn_remap(bi->fn, FN_REMAP_FACCH_H1);
-		l1if_process_meas_res(l1t->trx, bi->tn, fn_begin,
-				      trx_chan_desc[chan].chan_nr | bi->tn,
-				      n_errors, n_bits_total, bi->rssi,
-				      bi->toa256);
 		_sched_compose_ph_data_ind(l1t, bi->tn, fn_begin, chan,
 			tch_data + amr, GSM_MACBLOCK_LEN,
 			/* FIXME: AVG both RSSI and ToA */
@@ -1535,12 +1520,8 @@
 		fn_begin = gsm0502_fn_remap(bi->fn, FN_REMAP_TCH_H0);
 	else
 		fn_begin = gsm0502_fn_remap(bi->fn, FN_REMAP_TCH_H1);
-	l1if_process_meas_res(l1t->trx, bi->tn, fn_begin,
-			      trx_chan_desc[chan].chan_nr | bi->tn,
-			      n_errors, n_bits_total, bi->rssi,
-			      bi->toa256);
 	return _sched_compose_tch_ind(l1t, bi->tn, fn_begin, chan,
-				      tch_data, rc);
+				      tch_data, rc, bi->toa256, ber10k, bi->rssi);
 }
 
 /* schedule all frames of all TRX for given FN */

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-bts/+/15918
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Change-Id: I710d0b7cf193afa8515807836ee69b8b7db84a84
Gerrit-Change-Number: 15918
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <pmaier at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20191031/551c2aea/attachment.htm>


More information about the gerrit-log mailing list