[PATCH] osmo-bts[master]: octphy: WIP: fix channel measurement handling

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
Wed May 17 16:38:13 UTC 2017


Hello Jenkins Builder,

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

    https://gerrit.osmocom.org/2417

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

octphy: WIP: fix channel measurement handling

recent octphy firmware versions do no longer compute the channel
measurement results internally. Instead, hand out each frame
and the computation is done in software. This requires a change
to the octphy code. This patch introduces the changes using
ifdef statements in order not to break support for older firmware
versions.

Note: This is still work in progress. We might consider to remove
the ifdef statements again since the old method yielded wrong
measurement results anyway. So it would be ok to drop the old
non working measurement result computation completely.

Change-Id: I0f053bb10b1cb112a8814ee591969d607888e686
---
M src/osmo-bts-octphy/l1_if.c
M src/osmo-bts-octphy/l1_if.h
2 files changed, 73 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/17/2417/3

diff --git a/src/osmo-bts-octphy/l1_if.c b/src/osmo-bts-octphy/l1_if.c
index 92d2025..1d35cfa 100644
--- a/src/osmo-bts-octphy/l1_if.c
+++ b/src/osmo-bts-octphy/l1_if.c
@@ -76,6 +76,20 @@
 /* timeout until which we expect PHY to respond */
 #define CMD_TIMEOUT		5
 
+#if (cOCTVC1_MAIN_VERSION_ID >= cOCTVC1_MAIN_VERSION_ID_FN_PARADIGM_CHG)
+#define sBurstTiming(x) x
+#else
+#define sBurstTiming(x) (x >> 2)
+#endif
+
+#if (cOCTVC1_MAIN_VERSION_ID >= cOCTVC1_MAIN_VERSION_ID_FN_PARADIGM_CHG)
+/* get rssi, rssi is in q8 format */
+#define sRSSIDbm(x) (x >> 4)
+#else
+/* get rssi, rssi is in regular format (older firmware versions) */
+#define sRSSIDbm(x) x
+#endif
+
 /* allocate a msgb for a Layer1 primitive */
 struct msgb *l1p_msgb_alloc(void)
 {
@@ -792,7 +806,8 @@
  ***********************************************************************/
 
 static void process_meas_res(struct gsm_bts_trx *trx, uint8_t chan_nr,
-		     tOCTVC1_GSM_MEASUREMENT_INFO * m)
+			     uint32_t fn, uint32_t data_len,
+			     tOCTVC1_GSM_MEASUREMENT_INFO * m)
 {
 	struct osmo_phsap_prim l1sap;
 
@@ -801,10 +816,40 @@
 		       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_qbits = m->sBurstTiming;
 
+#if (cOCTVC1_MAIN_VERSION_ID >= cOCTVC1_MAIN_VERSION_ID_FN_PARADIGM_CHG)
+	/* Update Timing offset for valid radio block */
+	if (data_len != 0) {
+		/* burst timing in 1x */
+		l1sap.u.info.u.meas_ind.ta_offs_qbits = m->sBurstTiming;
+	} else {
+		/* FIXME, In current implementation, OCTPHY would send DATA_IND
+		 * for all radio blocks (valid or invalid) But timing offset
+		 * is only correct for valid block.  so we need different
+		 * counter to accumulate Timing offset.. even we add zero for
+		 * invalid block.. timing offset average calucation would not
+		 * correct. */
+		l1sap.u.info.u.meas_ind.ta_offs_qbits = 0;
+	}
+
+	if (m->usBERTotalBitCnt != 0) {
+		l1sap.u.info.u.meas_ind.ber10k =
+		    (unsigned int)((m->usBERCnt * BER_10K) /
+				   m->usBERTotalBitCnt);
+	} else {
+		l1sap.u.info.u.meas_ind.ber10k = 0;
+	}
+
+	/* rssi is in q8 format */
+	l1sap.u.info.u.meas_ind.inv_rssi = (uint8_t) ((m->sRSSIDbm >> 8) * -1);
+
+	/* copy logical frame number to MEAS IND data structure */
+	l1sap.u.info.u.meas_ind.fn = fn;
+#else
+	l1sap.u.info.u.meas_ind.ta_offs_qbits = m->sBurstTiming;
 	l1sap.u.info.u.meas_ind.ber10k = (unsigned int)(m->usBERCnt * 100);
 	l1sap.u.info.u.meas_ind.inv_rssi = (uint8_t) (m->sRSSIDbm * -1);
+#endif
 
 	/* l1sap wants to take msgb ownership.  However, as there is no
 	 * msg, it will msgb_free(l1sap.oph.msg == NULL) */
@@ -813,9 +858,17 @@
 
 static void dump_meas_res(int ll, tOCTVC1_GSM_MEASUREMENT_INFO * m)
 {
+#if (cOCTVC1_MAIN_VERSION_ID >= cOCTVC1_MAIN_VERSION_ID_FN_PARADIGM_CHG)
+	LOGPC(DMEAS, ll,
+	      "Meas: RSSI %d dBm, Burst Timing %d Quarter of bits :%d, "
+	      "BER Error Count %d , BER Toatal Bit count %d in last decoded frame\n",
+	      m->sRSSIDbm, m->sBurstTiming, m->sBurstTiming4x, m->usBERCnt,
+	      m->usBERTotalBitCnt);
+#else
 	LOGPC(DL1C, ll, ", Meas: RSSI %d dBm, Burst Timing %d Quarter of bits, "
 	      "BER Error Count %d in last decoded frame, BER Toatal Bit count %d in last decoded frame\n",
 	      m->sRSSIDbm, m->sBurstTiming, m->usBERCnt, m->usBERTotalBitCnt);
+#endif
 }
 
 static int handle_mph_time_ind(struct octphy_hdl *fl1, uint8_t trx_id, uint32_t fn)
@@ -1008,14 +1061,17 @@
 	memset(&l1sap, 0, sizeof(l1sap));
 
 	/* uplink measurement */
-	process_meas_res(trx, chan_nr, &data_ind->MeasurementInfo);
+	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",
+	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,
-			    data_ind->Data.ulDataLength));
+			    data_ind->Data.ulDataLength),
+	       data_ind->Data.ulDataLength);
+
 	dump_meas_res(LOGL_DEBUG, &data_ind->MeasurementInfo);
 
 	/* check for TCH */
@@ -1027,7 +1083,7 @@
 	}
 
 	/* get rssi */
-	rssi = (int8_t) data_ind->MeasurementInfo.sRSSIDbm;
+	rssi = (int8_t) sRSSIDbm(data_ind->MeasurementInfo.sRSSIDbm);
 	/* get data pointer and length */
 	data = data_ind->Data.abyDataContent;
 	len = data_ind->Data.ulDataLength;
@@ -1049,6 +1105,7 @@
 
 #if (cOCTVC1_MAIN_VERSION_ID >= cOCTVC1_MAIN_VERSION_ID_FN_PARADIGM_CHG)
 	if (sapi == cOCTVC1_GSM_SAPI_ENUM_PDTCH) {
+		/* FIXME::PCU is expecting encode frame number*/
 		l1sap->u.data.fn = fn - 3;
 	} else
 		l1sap->u.data.fn = fn;
@@ -1059,8 +1116,15 @@
 	l1sap->u.data.rssi = rssi;
 	b_total = data_ind->MeasurementInfo.usBERTotalBitCnt;
 	b_error =data_ind->MeasurementInfo.usBERCnt;
+#if (cOCTVC1_MAIN_VERSION_ID >= cOCTVC1_MAIN_VERSION_ID_FN_PARADIGM_CHG)
+	l1sap->u.data.ber10k = b_total ? BER_10K * b_error / b_total : 0;
+
+	/* FIXME::burst timing  in 1x but PCU is expecting 4X */
+	l1sap->u.data.ta_offs_qbits = (data_ind->MeasurementInfo.sBurstTiming * 4); 
+#else
 	l1sap->u.data.ber10k = b_total ? 10000 * b_error / b_total : 0;
 	l1sap->u.data.ta_offs_qbits = data_ind->MeasurementInfo.sBurstTiming4x;
+#endif
 	snr = data_ind->MeasurementInfo.sSNRDb;
 	/* FIXME: better converion formulae for SnR -> C / I?
 	l1sap->u.data.lqual_cb = (snr ? snr : (snr - 65536)) * 10 / 256;
@@ -1114,7 +1178,7 @@
 	if (ra_ind->MeasurementInfo.sBurstTiming < 0)
 		acc_delay = 0;
 	else
-		acc_delay = ra_ind->MeasurementInfo.sBurstTiming >> 2;
+		acc_delay = sBurstTiming(ra_ind->MeasurementInfo.sBurstTiming);
 
 	rc = msgb_trim(l1p_msg, sizeof(*l1sap));
 	if (rc < 0)
diff --git a/src/osmo-bts-octphy/l1_if.h b/src/osmo-bts-octphy/l1_if.h
index 2dee178..0960482 100644
--- a/src/osmo-bts-octphy/l1_if.h
+++ b/src/osmo-bts-octphy/l1_if.h
@@ -17,6 +17,8 @@
 
 #include <octphy/octvc1/gsm/octvc1_gsm_api.h>
 
+#define BER_10K	10000
+
 struct octphy_hdl {
 	/* MAC address of the PHY */
 	struct sockaddr_ll phy_addr;

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I0f053bb10b1cb112a8814ee591969d607888e686
Gerrit-PatchSet: 3
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: dexter <pmaier at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder



More information about the gerrit-log mailing list