Change in osmo-bts[master]: power_control: derive calc_delta() from lchan_ms_pwr_ctrl()

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
Tue Dec 1 17:41:35 UTC 2020


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


Change subject: power_control: derive calc_delta() from lchan_ms_pwr_ctrl()
......................................................................

power_control: derive calc_delta() from lchan_ms_pwr_ctrl()

This function will also be used by the BS Power Control logic.

Unfortunately, the unit test expectations have changed because:

  - lchan_ms_pwr_ctrl() has no access to the averaged input value
    anymore, so now the actual input value is printed;
  - one logging statement and early return have been removed,
    so now another logging statement substitutes it.

Change-Id: I2525eb2c3f1fdb3d0847a8ad50b30a44d7741a55
Related: SYS#4918
---
M src/common/power_control.c
M tests/power/power_test.err
2 files changed, 68 insertions(+), 56 deletions(-)



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

diff --git a/src/common/power_control.c b/src/common/power_control.c
index 21f7ce5..592e4f6 100644
--- a/src/common/power_control.c
+++ b/src/common/power_control.c
@@ -34,8 +34,8 @@
 #include <osmo-bts/power_control.h>
 
 /* how many dB do we raise/lower as maximum (1 ms power level = 2 dB) */
-#define MS_RAISE_MAX_DB 4
-#define MS_LOWER_MAX_DB 8
+#define PWR_RAISE_MAX_DB 4
+#define PWR_LOWER_MAX_DB 8
 
 /* We don't want to deal with floating point, so we scale up */
 #define EWMA_SCALE_FACTOR 100
@@ -91,6 +91,55 @@
 	return *Avg100 / EWMA_SCALE_FACTOR;
 }
 
+/* Calculate a 'delta' value (for the given MS/BS power control state and parameters)
+ * to be applied to the current Tx power level to approach the target level. */
+static int calc_delta(const struct bts_power_ctrl_params *params,
+		      struct lchan_power_ctrl_state *state,
+		      const int rxlev_dbm)
+{
+	int rxlev_dbm_avg;
+	int delta;
+
+	/* Filter input value(s) to reduce unnecessary Tx power oscillations */
+	switch (params->pf_algo) {
+	case BTS_PF_ALGO_EWMA:
+		rxlev_dbm_avg = do_pf_ewma(params, state, rxlev_dbm);
+		break;
+	case BTS_PF_ALGO_NONE:
+	default:
+		/* No filtering (pass through) */
+		rxlev_dbm_avg = rxlev_dbm;
+	}
+
+	/* How many dBs measured power should be increased (+) or decreased (-)
+	 * to reach expected power. */
+	delta = params->target - rxlev_dbm_avg;
+
+	/* Tolerate small deviations from 'rx-target' */
+	if (abs(delta) <= params->hysteresis) {
+#if 0
+		LOGPLCHAN(lchan, DLOOP, LOGL_INFO,
+			  "Keeping MS power at control level %d (%d dBm) because diff %d dBm "
+			  "from 'rx-target' %d dBm is not significant (hysteresis %d dBm)\n",
+			  ms_power_lvl, ms_dbm, delta, params->target, params->hysteresis);
+		/* Keep the current power level in sync (just to be sure) */
+		state->current = ms_power_lvl;
+		bts_model_adjst_ms_pwr(lchan);
+#endif
+		return 0;
+	}
+
+	/* Don't ever change more than PWR_{LOWER,RAISE}_MAX_DBM during one loop
+	 * iteration, i.e. reduce the speed at which the MS transmit power can
+	 * change. A higher value means a lower level (and vice versa) */
+	if (delta > PWR_RAISE_MAX_DB)
+		delta = PWR_RAISE_MAX_DB;
+	else if (delta < -PWR_LOWER_MAX_DB)
+		delta = -PWR_LOWER_MAX_DB;
+
+	return delta;
+}
+
  /*! compute the new MS POWER LEVEL communicated to the MS and store it in lchan.
   *  \param lchan logical channel for which to compute (and in which to store) new power value.
   *  \param[in] ms_power_lvl MS Power Level received from Uplink L1 SACCH Header in SACCH block.
@@ -100,13 +149,11 @@
 		      const uint8_t ms_power_lvl,
 		      const int8_t ul_rssi_dbm)
 {
-	int diff;
 	struct gsm_bts_trx *trx = lchan->ts->trx;
 	struct gsm_bts *bts = trx->bts;
 	enum gsm_band band = bts->band;
 	int8_t new_power_lvl; /* TS 05.05 power level */
 	int8_t ms_dbm, new_dbm, current_dbm, bsc_max_dbm;
-	int8_t avg_ul_rssi_dbm;
 
 	const struct bts_power_ctrl_params *params = &bts->ul_power_ctrl;
 	struct lchan_power_ctrl_state *state = &lchan->ms_power_ctrl;
@@ -131,43 +178,8 @@
 		return 0;
 	}
 
-	/* Filter UL RSSI to reduce unnecessary Tx power oscillations */
-	switch (params->pf_algo) {
-	case BTS_PF_ALGO_EWMA:
-		avg_ul_rssi_dbm = do_pf_ewma(params, state, ul_rssi_dbm);
-		break;
-	case BTS_PF_ALGO_NONE:
-	default:
-		/* No filtering (pass through) */
-		avg_ul_rssi_dbm = ul_rssi_dbm;
-	}
-
-	/* How many dBs measured power should be increased (+) or decreased (-)
-	   to reach expected power. */
-	diff = params->target - avg_ul_rssi_dbm;
-
-
-	/* Tolerate small deviations from 'rx-target' */
-	if (abs(diff) <= params->hysteresis) {
-		LOGPLCHAN(lchan, DLOOP, LOGL_INFO,
-			  "Keeping MS power at control level %d (%d dBm) because diff %d dBm "
-			  "from 'rx-target' %d dBm is not significant (hysteresis %d dBm)\n",
-			  ms_power_lvl, ms_dbm, diff, params->target, params->hysteresis);
-		/* Keep the current power level in sync (just to be sure) */
-		state->current = ms_power_lvl;
-		bts_model_adjst_ms_pwr(lchan);
-		return 0;
-	}
-
-	/* don't ever change more than MS_{LOWER,RAISE}_MAX_DBM during one loop
-	   iteration, i.e. reduce the speed at which the MS transmit power can
-	   change. A higher value means a lower level (and vice versa) */
-	if (diff > MS_RAISE_MAX_DB)
-		diff = MS_RAISE_MAX_DB;
-	else if (diff < -MS_LOWER_MAX_DB)
-		diff = -MS_LOWER_MAX_DB;
-
-	new_dbm = ms_dbm + diff;
+	/* Calculate the new Tx power value (in dBm) */
+	new_dbm = ms_dbm + calc_delta(params, state, ul_rssi_dbm);
 
 	/* Make sure new_dbm is never negative. ms_pwr_ctl_lvl() can later on
 	   cope with any unsigned dbm value, regardless of band minimal value. */
@@ -190,7 +202,7 @@
 		LOGPLCHAN(lchan, DLOOP, LOGL_INFO, "Keeping MS power at control level %d, %d dBm "
 			  "(rx-ms-pwr-lvl %" PRIu8 ", max-ms-pwr-lvl %" PRIu8 ", rx-current %d dBm, rx-target %d dBm)\n",
 			  new_power_lvl, new_dbm, ms_power_lvl, state->max,
-			  avg_ul_rssi_dbm, params->target);
+			  ul_rssi_dbm, params->target);
 		return 0;
 	}
 
@@ -199,7 +211,7 @@
 		  "(rx-ms-pwr-lvl %" PRIu8 ", max-ms-pwr-lvl %" PRIu8 ", rx-current %d dBm, rx-target %d dBm)\n",
 		  (new_dbm > current_dbm) ? "Raising" : "Lowering",
 		  state->current, current_dbm, new_power_lvl, new_dbm,
-		  ms_power_lvl, state->max, avg_ul_rssi_dbm, params->target);
+		  ms_power_lvl, state->max, ul_rssi_dbm, params->target);
 
 	/* store the resulting new MS power level in the lchan */
 	state->current = new_power_lvl;
diff --git a/tests/power/power_test.err b/tests/power/power_test.err
index 988b3ba..cf43081 100644
--- a/tests/power/power_test.err
+++ b/tests/power/power_test.err
@@ -4,7 +4,7 @@
 (bts=0,trx=0,ts=0,ss=0) Raising MS power from control level 11 (8 dBm) to 9, 12 dBm (rx-ms-pwr-lvl 11, max-ms-pwr-lvl 2, rx-current -90 dBm, rx-target -75 dBm)
 (bts=0,trx=0,ts=0,ss=0) Raising MS power from control level 9 (12 dBm) to 7, 16 dBm (rx-ms-pwr-lvl 9, max-ms-pwr-lvl 2, rx-current -90 dBm, rx-target -75 dBm)
 (bts=0,trx=0,ts=0,ss=0) Raising MS power from control level 7 (16 dBm) to 5, 20 dBm (rx-ms-pwr-lvl 7, max-ms-pwr-lvl 2, rx-current -90 dBm, rx-target -75 dBm)
-(bts=0,trx=0,ts=0,ss=0) Keeping MS power at control level 5 (20 dBm) because diff 0 dBm from 'rx-target' -75 dBm is not significant (hysteresis 0 dBm)
+(bts=0,trx=0,ts=0,ss=0) Keeping MS power at control level 5, 20 dBm (rx-ms-pwr-lvl 5, max-ms-pwr-lvl 2, rx-current -75 dBm, rx-target -75 dBm)
 (bts=0,trx=0,ts=0,ss=0) Raising MS power from control level 5 (20 dBm) to 3, 24 dBm (rx-ms-pwr-lvl 5, max-ms-pwr-lvl 2, rx-current -90 dBm, rx-target -75 dBm)
 (bts=0,trx=0,ts=0,ss=0) Raising MS power from control level 3 (24 dBm) to 2, 26 dBm (rx-ms-pwr-lvl 3, max-ms-pwr-lvl 2, rx-current -90 dBm, rx-target -75 dBm)
 (bts=0,trx=0,ts=0,ss=0) Keeping MS power at control level 2, 26 dBm (rx-ms-pwr-lvl 2, max-ms-pwr-lvl 2, rx-current -90 dBm, rx-target -75 dBm)
@@ -13,7 +13,7 @@
 (bts=0,trx=0,ts=0,ss=0) Raising MS power from control level 0 (30 dBm) to 30, 34 dBm (rx-ms-pwr-lvl 0, max-ms-pwr-lvl 29, rx-current -90 dBm, rx-target -75 dBm)
 (bts=0,trx=0,ts=0,ss=0) Raising MS power from control level 30 (34 dBm) to 29, 36 dBm (rx-ms-pwr-lvl 30, max-ms-pwr-lvl 29, rx-current -90 dBm, rx-target -75 dBm)
 (bts=0,trx=0,ts=0,ss=0) Keeping MS power at control level 29, 36 dBm (rx-ms-pwr-lvl 29, max-ms-pwr-lvl 29, rx-current -90 dBm, rx-target -75 dBm)
-(bts=0,trx=0,ts=0,ss=0) Keeping MS power at control level 29 (36 dBm) because diff 0 dBm from 'rx-target' -75 dBm is not significant (hysteresis 0 dBm)
+(bts=0,trx=0,ts=0,ss=0) Keeping MS power at control level 29, 36 dBm (rx-ms-pwr-lvl 29, max-ms-pwr-lvl 29, rx-current -75 dBm, rx-target -75 dBm)
 (bts=0,trx=0,ts=0,ss=0) Lowering MS power from control level 29 (36 dBm) to 1, 28 dBm (rx-ms-pwr-lvl 29, max-ms-pwr-lvl 29, rx-current -45 dBm, rx-target -75 dBm)
 (bts=0,trx=0,ts=0,ss=0) Lowering MS power from control level 1 (28 dBm) to 5, 20 dBm (rx-ms-pwr-lvl 1, max-ms-pwr-lvl 29, rx-current -45 dBm, rx-target -75 dBm)
 (bts=0,trx=0,ts=0,ss=0) Lowering MS power from control level 5 (20 dBm) to 9, 12 dBm (rx-ms-pwr-lvl 5, max-ms-pwr-lvl 29, rx-current -45 dBm, rx-target -75 dBm)
@@ -21,17 +21,17 @@
 (bts=0,trx=0,ts=0,ss=0) Raising MS power from control level 10 (10 dBm) to 9, 12 dBm (rx-ms-pwr-lvl 10, max-ms-pwr-lvl 29, rx-current -77 dBm, rx-target -75 dBm)
 (bts=0,trx=0,ts=0,ss=0) Lowering MS power from control level 9 (12 dBm) to 14, 2 dBm (rx-ms-pwr-lvl 9, max-ms-pwr-lvl 14, rx-current -73 dBm, rx-target -75 dBm)
 (bts=0,trx=0,ts=0,ss=0) Lowering MS power from control level 14 (2 dBm) to 15, 0 dBm (rx-ms-pwr-lvl 14, max-ms-pwr-lvl 0, rx-current -40 dBm, rx-target -75 dBm)
-(bts=0,trx=0,ts=0,ss=0) Keeping MS power at control level 15 (0 dBm) because diff 0 dBm from 'rx-target' -75 dBm is not significant (hysteresis 0 dBm)
-(bts=0,trx=0,ts=0,ss=0) Raising MS power from control level 15 (0 dBm) to 13, 3 dBm (rx-ms-pwr-lvl 15, max-ms-pwr-lvl 2, rx-current -78 dBm, rx-target -75 dBm)
-(bts=0,trx=0,ts=0,ss=0) Raising MS power from control level 13 (4 dBm) to 11, 8 dBm (rx-ms-pwr-lvl 13, max-ms-pwr-lvl 2, rx-current -80 dBm, rx-target -75 dBm)
-(bts=0,trx=0,ts=0,ss=0) Raising MS power from control level 11 (8 dBm) to 9, 11 dBm (rx-ms-pwr-lvl 11, max-ms-pwr-lvl 2, rx-current -78 dBm, rx-target -75 dBm)
+(bts=0,trx=0,ts=0,ss=0) Keeping MS power at control level 15, 0 dBm (rx-ms-pwr-lvl 15, max-ms-pwr-lvl 2, rx-current -75 dBm, rx-target -75 dBm)
+(bts=0,trx=0,ts=0,ss=0) Raising MS power from control level 15 (0 dBm) to 13, 3 dBm (rx-ms-pwr-lvl 15, max-ms-pwr-lvl 2, rx-current -90 dBm, rx-target -75 dBm)
+(bts=0,trx=0,ts=0,ss=0) Raising MS power from control level 13 (4 dBm) to 11, 8 dBm (rx-ms-pwr-lvl 13, max-ms-pwr-lvl 2, rx-current -90 dBm, rx-target -75 dBm)
+(bts=0,trx=0,ts=0,ss=0) Raising MS power from control level 11 (8 dBm) to 9, 11 dBm (rx-ms-pwr-lvl 11, max-ms-pwr-lvl 2, rx-current -70 dBm, rx-target -75 dBm)
 (bts=0,trx=0,ts=0,ss=0) Keeping MS power at control level 15, 0 dBm (rx-ms-pwr-lvl 15, max-ms-pwr-lvl 2, rx-current -50 dBm, rx-target -75 dBm)
 (bts=0,trx=0,ts=0,ss=0) Keeping MS power at control level 15, 0 dBm (rx-ms-pwr-lvl 15, max-ms-pwr-lvl 2, rx-current -50 dBm, rx-target -75 dBm)
-(bts=0,trx=0,ts=0,ss=0) Raising MS power from control level 15 (0 dBm) to 13, 4 dBm (rx-ms-pwr-lvl 15, max-ms-pwr-lvl 2, rx-current -92 dBm, rx-target -75 dBm)
-(bts=0,trx=0,ts=0,ss=0) Keeping MS power at control level 15 (0 dBm) because diff 0 dBm from 'rx-target' -75 dBm is not significant (hysteresis 5 dBm)
-(bts=0,trx=0,ts=0,ss=0) Keeping MS power at control level 15 (0 dBm) because diff -3 dBm from 'rx-target' -75 dBm is not significant (hysteresis 5 dBm)
-(bts=0,trx=0,ts=0,ss=0) Keeping MS power at control level 15 (0 dBm) because diff 3 dBm from 'rx-target' -75 dBm is not significant (hysteresis 5 dBm)
-(bts=0,trx=0,ts=0,ss=0) Keeping MS power at control level 15 (0 dBm) because diff 0 dBm from 'rx-target' -75 dBm is not significant (hysteresis 5 dBm)
-(bts=0,trx=0,ts=0,ss=0) Keeping MS power at control level 15 (0 dBm) because diff -5 dBm from 'rx-target' -75 dBm is not significant (hysteresis 5 dBm)
-(bts=0,trx=0,ts=0,ss=0) Keeping MS power at control level 15 (0 dBm) because diff 5 dBm from 'rx-target' -75 dBm is not significant (hysteresis 5 dBm)
+(bts=0,trx=0,ts=0,ss=0) Raising MS power from control level 15 (0 dBm) to 13, 4 dBm (rx-ms-pwr-lvl 15, max-ms-pwr-lvl 2, rx-current -110 dBm, rx-target -75 dBm)
+(bts=0,trx=0,ts=0,ss=0) Keeping MS power at control level 15, 0 dBm (rx-ms-pwr-lvl 15, max-ms-pwr-lvl 2, rx-current -75 dBm, rx-target -75 dBm)
+(bts=0,trx=0,ts=0,ss=0) Keeping MS power at control level 15, 0 dBm (rx-ms-pwr-lvl 15, max-ms-pwr-lvl 2, rx-current -72 dBm, rx-target -75 dBm)
+(bts=0,trx=0,ts=0,ss=0) Keeping MS power at control level 15, 0 dBm (rx-ms-pwr-lvl 15, max-ms-pwr-lvl 2, rx-current -78 dBm, rx-target -75 dBm)
+(bts=0,trx=0,ts=0,ss=0) Keeping MS power at control level 15, 0 dBm (rx-ms-pwr-lvl 15, max-ms-pwr-lvl 2, rx-current -75 dBm, rx-target -75 dBm)
+(bts=0,trx=0,ts=0,ss=0) Keeping MS power at control level 15, 0 dBm (rx-ms-pwr-lvl 15, max-ms-pwr-lvl 2, rx-current -70 dBm, rx-target -75 dBm)
+(bts=0,trx=0,ts=0,ss=0) Keeping MS power at control level 15, 0 dBm (rx-ms-pwr-lvl 15, max-ms-pwr-lvl 2, rx-current -80 dBm, rx-target -75 dBm)
 (bts=0,trx=0,ts=0,ss=0) Raising MS power from control level 15 (0 dBm) to 13, 4 dBm (rx-ms-pwr-lvl 15, max-ms-pwr-lvl 2, rx-current -85 dBm, rx-target -75 dBm)

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

Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Change-Id: I2525eb2c3f1fdb3d0847a8ad50b30a44d7741a55
Gerrit-Change-Number: 21446
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <vyanitskiy at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20201201/7758d8cb/attachment.htm>


More information about the gerrit-log mailing list