Change in osmo-bts[master]: rsl_tx_rf_res(): separate interference AVG / band calculation

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

fixeria gerrit-no-reply at lists.osmocom.org
Fri Oct 8 10:48:51 UTC 2021


fixeria has submitted this change. ( https://gerrit.osmocom.org/c/osmo-bts/+/25712 )

Change subject: rsl_tx_rf_res(): separate interference AVG / band calculation
......................................................................

rsl_tx_rf_res(): separate interference AVG / band calculation

It's cleaner from the architectural point of view to have the
interference measurements processed in a separate function.

Change-Id: I3981608e01a50585359cad673c38c8a305027d30
Related: SYS#5313
---
M include/osmo-bts/lchan.h
M src/common/l1sap.c
M src/common/lchan.c
M src/common/rsl.c
4 files changed, 43 insertions(+), 18 deletions(-)

Approvals:
  laforge: Looks good to me, approved
  pespin: Looks good to me, but someone else must approve
  Jenkins Builder: Verified



diff --git a/include/osmo-bts/lchan.h b/include/osmo-bts/lchan.h
index fdb3144..8fcf36a 100644
--- a/include/osmo-bts/lchan.h
+++ b/include/osmo-bts/lchan.h
@@ -226,8 +226,10 @@
 			uint16_t toa256_std_dev;
 		} ext;
 		/* Interference levels reported by PHY (in dBm) */
+		int16_t interf_meas_avg_dbm; /* Average value */
 		int16_t interf_meas_dbm[31]; /* Intave max is 31 */
 		uint8_t interf_meas_num;
+		uint8_t interf_band;
 	} meas;
 	struct {
 		struct amr_multirate_conf amr_mr;
@@ -341,7 +343,7 @@
 				   enum gsm_phys_chan_config as_pchan);
 
 void gsm_lchan_interf_meas_push(struct gsm_lchan *lchan, int dbm);
-int gsm_lchan_interf_meas_calc_band(struct gsm_lchan *lchan);
+void gsm_lchan_interf_meas_calc_avg(struct gsm_lchan *lchan);
 
 int lchan2ecu_codec(const struct gsm_lchan *lchan);
 
diff --git a/src/common/l1sap.c b/src/common/l1sap.c
index a48287c..5c58aff 100644
--- a/src/common/l1sap.c
+++ b/src/common/l1sap.c
@@ -591,6 +591,29 @@
 	return rach_frames_expired;
 }
 
+static void l1sap_interf_meas_calc_avg(struct gsm_bts_trx *trx)
+{
+	unsigned int tn, ln;
+
+	for (tn = 0; tn < ARRAY_SIZE(trx->ts); tn++) {
+		struct gsm_bts_trx_ts *ts = &trx->ts[tn];
+
+		for (ln = 0; ln < ARRAY_SIZE(ts->lchan); ln++) {
+			struct gsm_lchan *lchan = &ts->lchan[ln];
+
+			lchan->meas.interf_meas_avg_dbm = 0;
+			lchan->meas.interf_band = 0;
+
+			/* There must be at least one sample */
+			if (lchan->meas.interf_meas_num == 0)
+				continue;
+
+			/* Average all collected samples */
+			gsm_lchan_interf_meas_calc_avg(lchan);
+		}
+	}
+}
+
 static void l1sap_interf_meas_report(struct gsm_bts *bts)
 {
 	const uint32_t period = bts->interference.intave * 104;
@@ -601,8 +624,12 @@
 	if (bts->gsm_time.fn % period != 0)
 		return;
 
-	llist_for_each_entry(trx, &bts->trx_list, list)
+	llist_for_each_entry(trx, &bts->trx_list, list) {
+		/* Calculate the average of all received samples */
+		l1sap_interf_meas_calc_avg(trx);
+		/* Report to the BSC over the A-bis/RSL */
 		rsl_tx_rf_res(trx);
+	}
 }
 
 /* time information received from bts model */
diff --git a/src/common/lchan.c b/src/common/lchan.c
index 10a375e..f7ee33b 100644
--- a/src/common/lchan.c
+++ b/src/common/lchan.c
@@ -348,15 +348,14 @@
 }
 
 /* Called by the higher layers every Intave * 104 TDMA frames */
-int gsm_lchan_interf_meas_calc_band(struct gsm_lchan *lchan)
+void gsm_lchan_interf_meas_calc_avg(struct gsm_lchan *lchan)
 {
 	const uint8_t meas_num = lchan->meas.interf_meas_num;
 	const struct gsm_bts *bts = lchan->ts->trx->bts;
 	int b, meas_avg, meas_sum = 0;
 
 	/* There must be at least one sample */
-	if (meas_num == 0)
-		return -EAGAIN;
+	OSMO_ASSERT(meas_num > 0);
 
 	/* Calculate the sum of all collected samples (in -x dBm) */
 	while (lchan->meas.interf_meas_num) {
@@ -377,7 +376,8 @@
 		  "Interference AVG: %ddBm (band %d, samples %u)\n",
 		  meas_avg, b, meas_num);
 
-	return b;
+	lchan->meas.interf_meas_avg_dbm = meas_avg;
+	lchan->meas.interf_band = b;
 }
 
 /* determine the ECU codec constant for the codec used by given lchan */
diff --git a/src/common/rsl.c b/src/common/rsl.c
index 229a2af..e4531aa 100644
--- a/src/common/rsl.c
+++ b/src/common/rsl.c
@@ -440,29 +440,25 @@
 	uint8_t *len = msgb_tl_put(nmsg, RSL_IE_RESOURCE_INFO);
 
 	for (tn = 0; tn < ARRAY_SIZE(trx->ts); tn++) {
-		struct gsm_bts_trx_ts *ts = &trx->ts[tn];
+		const struct gsm_bts_trx_ts *ts = &trx->ts[tn];
 
 		for (ln = 0; ln < ARRAY_SIZE(ts->lchan); ln++) {
-			struct gsm_lchan *lchan = &ts->lchan[ln];
+			const struct gsm_lchan *lchan = &ts->lchan[ln];
+
+			/* No average interference value => no band */
+			if (lchan->meas.interf_meas_avg_dbm == 0)
+				continue;
 
 			/* We're not interested in active lchans */
-			if (lchan->state == LCHAN_S_ACTIVE) {
-				/* Avoid potential buffer overflow */
-				lchan->meas.interf_meas_num = 0;
+			if (lchan->state == LCHAN_S_ACTIVE)
 				continue;
-			}
 
 			/* Only for GSM_LCHAN_{SDCCH,TCH_F,TCH_H} */
 			if (!lchan_is_dcch(lchan))
 				continue;
 
-			/* Average all collected samples */
-			int band = gsm_lchan_interf_meas_calc_band(lchan);
-			if (band < 0)
-				continue;
-
 			msgb_v_put(nmsg, gsm_lchan2chan_nr_rsl(lchan));
-			msgb_v_put(nmsg, (band & 0x07) << 5);
+			msgb_v_put(nmsg, (lchan->meas.interf_band & 0x07) << 5);
 		}
 	}
 

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

Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Change-Id: I3981608e01a50585359cad673c38c8a305027d30
Gerrit-Change-Number: 25712
Gerrit-PatchSet: 2
Gerrit-Owner: fixeria <vyanitskiy at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy at sysmocom.de>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20211008/5a585598/attachment.htm>


More information about the gerrit-log mailing list