[PATCH] osmo-pcu[master]: PCU: Fix TA adjustment

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

Minh-Quang Nguyen gerrit-no-reply at lists.osmocom.org
Thu Nov 16 15:07:29 UTC 2017


Hello Harald Welte, Jenkins Builder,

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

    https://gerrit.osmocom.org/4678

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

PCU: Fix TA adjustment

Promblem:
 TA provided from L1 PH-DATA-IND is a relative amount of TA adjustment to actual TA
 being used for given TBF. The current TA update algorithm in PCU simply applies the relative
 amount of TA to given TBF but does not take into account of current TA.
 As a result, the PCU will request wrong TA jump for given TBF if the MS is moving away from
 BTS more than 2 km.

 Related issue: http://osmocom.org/issues/2611

Fixes:
- The PCU needs increase or decrease current TA of given TBF on receiving of relative
  amount of TA adjustment provided by PH-DATA-IND from L1
- The PCU needs to set absolute TA of given TBF on receiving absolute TA provided by
  PH-RA-IND from L1.

Change-Id: I65212f8203f1a35278890f51db038d689b2493d5
---
M src/bts.cpp
M src/bts.h
M src/osmo-bts-litecell15/lc15_l1_if.c
M src/osmo-bts-sysmo/sysmo_l1_if.c
M src/pcu_l1_if.h
5 files changed, 84 insertions(+), 13 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/78/4678/3

diff --git a/src/bts.cpp b/src/bts.cpp
index e41b1fa..6bdbb85 100644
--- a/src/bts.cpp
+++ b/src/bts.cpp
@@ -1619,8 +1619,45 @@
 	return rc;
 }
 
-void bts_update_tbf_ta(const char *p, uint32_t fn, uint8_t trx_no, uint8_t ts,
-		       uint8_t ta)
+/* update TA based on TA provided by PH-DATA-IND */
+void update_tbf_ta(struct gprs_rlcmac_ul_tbf *tbf, int8_t ta_delta)
+{
+	int16_t ta_adj;
+	uint8_t ta_target;
+
+	if (ta_delta) {
+		/* adjust TA based on TA provided by PH-DATA-IND */
+		ta_adj = tbf->ta() + ta_delta;
+
+		/* limit target TA in range 0..63 bits */
+		ta_target = ta_limit(ta_adj);
+
+		LOGP(DL1IF, LOGL_INFO, "PH-DATA-IND is updating TLLI=0x%08x: TA %u -> %u on "
+				"TRX = %d, TS = %d, FN = %d\n",
+				tbf->tlli(), tbf->ta(), ta_target,
+				tbf->trx->trx_no , tbf->poll_ts, tbf->poll_fn);
+		tbf->set_ta(ta_target);
+	}
+}
+
+/* set TA based on TA provided by PH-RA-IND */
+void set_tbf_ta(struct gprs_rlcmac_ul_tbf *tbf, uint8_t ta)
+{
+	uint8_t ta_target;
+
+	if (tbf->ta() != ta) {
+		/* limit target TA in range 0..63 bits */
+		ta_target = ta_limit(ta);
+
+		LOGP(DL1IF, LOGL_INFO, "PH-RA-IND is updating TLLI=0x%08x: TA %u -> %u on "
+				"TRX = %d, TS = %d, FN = %d\n",
+				tbf->tlli(), tbf->ta(), ta_target,
+				tbf->trx->trx_no , tbf->poll_ts, tbf->poll_fn);
+		tbf->set_ta(ta_target);
+	}
+}
+
+void bts_update_tbf_ta(const char *p, uint32_t fn, uint8_t trx_no, uint8_t ts, int8_t ta, bool is_rach)
 {
 	struct gprs_rlcmac_ul_tbf *tbf =
 		bts_main_data()->bts->ul_tbf_by_poll_fn(fn, trx_no, ts);
@@ -1628,11 +1665,16 @@
 		LOGP(DL1IF, LOGL_DEBUG, "[%s] update TA = %u ignored due to "
 		     "unknown UL TBF on TRX = %d, TS = %d, FN = %d\n",
 		     p, ta, trx_no, ts, fn);
-	else if (tbf->ta() != ta) {
-		LOGP(DL1IF, LOGL_INFO, "[%s] Updating TA %u -> %u on "
-		     "TRX = %d, TS = %d, FN = %d\n",
-		     p, tbf->ta(), ta, trx_no, ts, fn);
-		tbf->set_ta(ta);
+	else {
+		/* we need to distinguish TA information provided by L1
+		 * from PH-DATA-IND and PHY-RA-IND so that we can properly
+		 * update TA for given TBF
+		 */
+		if (is_rach)
+			set_tbf_ta(tbf, (uint8_t)ta);
+		else
+			update_tbf_ta(tbf, ta);
+
 	}
 }
 
diff --git a/src/bts.h b/src/bts.h
index d65cd2f..aaf81cf 100644
--- a/src/bts.h
+++ b/src/bts.h
@@ -162,8 +162,9 @@
 #ifdef __cplusplus
 extern "C" {
 #endif
-void bts_update_tbf_ta(const char *p, uint32_t fn, uint8_t trx_no, uint8_t ts,
-		       uint8_t ta);
+void bts_update_tbf_ta(const char *p, uint32_t fn, uint8_t trx_no, uint8_t ts, int8_t ta, bool is_rach);
+void update_tbf_ta(struct gprs_rlcmac_ul_tbf *tbf, int8_t ta_delta);
+void set_tbf_ta(struct gprs_rlcmac_ul_tbf *tbf, uint8_t ta);
 #ifdef __cplusplus
 }
 #endif
diff --git a/src/osmo-bts-litecell15/lc15_l1_if.c b/src/osmo-bts-litecell15/lc15_l1_if.c
index 37b7f78..8290a93 100644
--- a/src/osmo-bts-litecell15/lc15_l1_if.c
+++ b/src/osmo-bts-litecell15/lc15_l1_if.c
@@ -203,7 +203,7 @@
 
 	get_meas(&meas, &data_ind->measParam);
 	bts_update_tbf_ta("PH-DATA", data_ind->u32Fn, fl1h->trx_no,
-			  data_ind->u8Tn, qta2ta(meas.bto));
+			  data_ind->u8Tn, sign_qta2ta(meas.bto), false);
 
 	switch (data_ind->sapi) {
 	case GsmL1_Sapi_Pdtch:
@@ -248,7 +248,7 @@
 
 	DEBUGP(DL1IF, "Rx PH-RA.ind");
 	bts_update_tbf_ta("PH-RA", ra_ind->u32Fn, fl1h->trx_no, ra_ind->u8Tn,
-			  qta2ta(ra_ind->measParam.i16BurstTiming));
+			qta2ta(ra_ind->measParam.i16BurstTiming), true);
 
 	return 0;
 }
diff --git a/src/osmo-bts-sysmo/sysmo_l1_if.c b/src/osmo-bts-sysmo/sysmo_l1_if.c
index 1c5ecc9..dfef239 100644
--- a/src/osmo-bts-sysmo/sysmo_l1_if.c
+++ b/src/osmo-bts-sysmo/sysmo_l1_if.c
@@ -188,7 +188,7 @@
 
 	get_meas(&meas, &data_ind->measParam);
 	bts_update_tbf_ta("PH-DATA", data_ind->u32Fn, fl1h->trx_no,
-			  data_ind->u8Tn, qta2ta(meas.bto));
+			  data_ind->u8Tn, sign_qta2ta(meas.bto), false);
 
 	switch (data_ind->sapi) {
 	case GsmL1_Sapi_Pdtch:
@@ -237,7 +237,7 @@
 
 	DEBUGP(DL1IF, "Rx PH-RA.ind");
 	bts_update_tbf_ta("PH-RA", ra_ind->u32Fn, fl1h->trx_no, ra_ind->u8Tn,
-			  qta2ta(ra_ind->measParam.i16BurstTiming));
+			qta2ta(ra_ind->measParam.i16BurstTiming), true);
 
 	return 0;
 }
diff --git a/src/pcu_l1_if.h b/src/pcu_l1_if.h
index 1618260..cb2a6df 100644
--- a/src/pcu_l1_if.h
+++ b/src/pcu_l1_if.h
@@ -43,6 +43,34 @@
 	return qta >> 2;
 }
 
+static inline int8_t sign_qta2ta(int16_t qta)
+{
+	int8_t ta_adj = 0;
+
+	if (qta < -252)
+		qta = -252;
+
+	if (qta > 252)
+		qta = 252;
+
+	/* 1-bit TA adjustment  if TA error reported by L1 is outside +/- 2 qbits */
+	if (qta > 2)
+		ta_adj = 1;
+	if (qta < -2)
+		ta_adj = -1;
+
+	return (qta >> 2) + ta_adj;
+}
+
+static inline uint8_t ta_limit(int16_t ta)
+{
+	if (ta < 0)
+		ta = 0;
+	if (ta > 63)
+		ta = 63;
+	return ta;
+}
+
 /*
  * L1 Measurement values
  */

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I65212f8203f1a35278890f51db038d689b2493d5
Gerrit-PatchSet: 3
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Owner: Minh-Quang Nguyen <minh-quang.nguyen at nutaq.com>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Minh-Quang Nguyen <minh-quang.nguyen at nutaq.com>



More information about the gerrit-log mailing list