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/.
laforge gerrit-no-reply at lists.osmocom.orglaforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-bts/+/21907 )
Change subject: power_control: generalize measurement pre-processing state
......................................................................
power_control: generalize measurement pre-processing state
This way EWMA based filtering can also be applied to RxQual.
Change-Id: I439c00b394da670e314f217b3246cc85ce8213c6
Related: SYS#4918, SYS#4917
---
M include/osmo-bts/gsm_data.h
M src/common/power_control.c
M tests/power/ms_power_loop_test.c
3 files changed, 35 insertions(+), 22 deletions(-)
Approvals:
Jenkins Builder: Verified
pespin: Looks good to me, but someone else must approve
laforge: Looks good to me, approved
diff --git a/include/osmo-bts/gsm_data.h b/include/osmo-bts/gsm_data.h
index 6efc717..253b115 100644
--- a/include/osmo-bts/gsm_data.h
+++ b/include/osmo-bts/gsm_data.h
@@ -213,18 +213,28 @@
/* Default MS/BS Power Control parameters */
extern const struct gsm_power_ctrl_params power_ctrl_params_def;
+/* Measurement pre-processing state */
+struct gsm_power_ctrl_meas_proc_state {
+ /* Algorithm specific data */
+ union {
+ struct {
+ /* Scaled up 100 times average value */
+ int Avg100;
+ } ewma;
+ };
+};
+
struct lchan_power_ctrl_state {
/* Dynamic Power Control parameters (NULL in static mode) */
const struct gsm_power_ctrl_params *dpc_params;
+ /* Measurement pre-processing state (for dynamic mode) */
+ struct gsm_power_ctrl_meas_proc_state rxlev_meas_proc;
/* Depending on the context (MS or BS power control), fields 'current' and 'max'
* reflect either the MS power level (magic numbers), or BS Power reduction level
* (attenuation, in dB). */
uint8_t current;
uint8_t max;
-
- /* Scaled up (100 times) average UL/DL RxLev (in dBm) */
- int avg100_rxlev_dbm;
};
struct gsm_lchan {
diff --git a/src/common/power_control.c b/src/common/power_control.c
index e159740..0629630 100644
--- a/src/common/power_control.c
+++ b/src/common/power_control.c
@@ -38,29 +38,29 @@
/* Base Low-Pass Single-Pole IIR Filter (EWMA) formula:
*
- * Avg[n] = a * Pwr[n] + (1 - a) * Avg[n - 1]
+ * Avg[n] = a * Val[n] + (1 - a) * Avg[n - 1]
*
- * where parameter 'a' determines how much weight of the latest UL RSSI measurement
- * result 'Pwr[n]' carries vs the weight of the average 'Avg[n - 1]'. The value of
- * 'a' is usually a float in range 0 .. 1, so:
+ * where parameter 'a' determines how much weight of the latest measurement value
+ * 'Val[n]' carries vs the weight of the accumulated average 'Avg[n - 1]'. The
+ * value of 'a' is usually a float in range 0 .. 1, so:
*
- * - value 0.5 gives equal weight to both 'Pwr[n]' and 'Avg[n - 1]';
+ * - value 0.5 gives equal weight to both 'Val[n]' and 'Avg[n - 1]';
* - value 1.0 means no filtering at all (pass through);
* - value 0.0 makes no sense.
*
* Further optimization:
*
- * Avg[n] = a * Pwr[n] + Avg[n - 1] - a * Avg[n - 1]
+ * Avg[n] = a * Val[n] + Avg[n - 1] - a * Avg[n - 1]
* ^^^^^^ ^^^^^^^^^^
*
* a) this can be implemented in C using '+=' operator:
*
- * Avg += a * Pwr - a * Avg
- * Avg += a * (Pwr - Avg)
+ * Avg += a * Val - a * Avg
+ * Avg += a * (Val - Avg)
*
* b) everything is scaled up by 100 to avoid floating point stuff:
*
- * Avg100 += A * (Pwr - Avg)
+ * Avg100 += A * (Val - Avg)
*
* where 'Avg100' is 'Avg * 100' and 'A' is 'a * 100'.
*
@@ -70,20 +70,20 @@
* https://en.wikipedia.org/wiki/Low-pass_filter#Simple_infinite_impulse_response_filter
* https://tomroelandts.com/articles/low-pass-single-pole-iir-filter
*/
-static int8_t do_pf_ewma(const struct gsm_power_ctrl_meas_params *mp,
- struct lchan_power_ctrl_state *state,
- const int8_t Pwr)
+static int do_pf_ewma(const struct gsm_power_ctrl_meas_params *mp,
+ struct gsm_power_ctrl_meas_proc_state *mps,
+ const int Val)
{
const uint8_t A = mp->ewma.alpha;
- int *Avg100 = &state->avg100_rxlev_dbm;
+ int *Avg100 = &mps->ewma.Avg100;
/* We don't have 'Avg[n - 1]' if this is the first run */
if (*Avg100 == 0) {
- *Avg100 = Pwr * EWMA_SCALE_FACTOR;
- return Pwr;
+ *Avg100 = Val * EWMA_SCALE_FACTOR;
+ return Val;
}
- *Avg100 += A * (Pwr - *Avg100 / EWMA_SCALE_FACTOR);
+ *Avg100 += A * (Val - *Avg100 / EWMA_SCALE_FACTOR);
return *Avg100 / EWMA_SCALE_FACTOR;
}
@@ -104,7 +104,9 @@
/* Filter RxLev value to reduce unnecessary Tx power oscillations */
switch (params->rxlev_meas.algo) {
case GSM_PWR_CTRL_MEAS_AVG_ALGO_OSMO_EWMA:
- rxlev_dbm_avg = do_pf_ewma(¶ms->rxlev_meas, state, rxlev_dbm);
+ rxlev_dbm_avg = do_pf_ewma(¶ms->rxlev_meas,
+ &state->rxlev_meas_proc,
+ rxlev_dbm);
break;
/* TODO: implement other pre-processing methods */
case GSM_PWR_CTRL_MEAS_AVG_ALGO_NONE:
diff --git a/tests/power/ms_power_loop_test.c b/tests/power/ms_power_loop_test.c
index e93a2ef..eb0e3e9 100644
--- a/tests/power/ms_power_loop_test.c
+++ b/tests/power/ms_power_loop_test.c
@@ -164,7 +164,7 @@
init_test(__func__);
lchan = &g_trx->ts[0].lchan[0];
- avg100 = &lchan->ms_power_ctrl.avg100_rxlev_dbm;
+ avg100 = &lchan->ms_power_ctrl.rxlev_meas_proc.ewma.Avg100;
struct gsm_power_ctrl_meas_params *mp = &lchan->ms_dpc_params.rxlev_meas;
mp->algo = GSM_PWR_CTRL_MEAS_AVG_ALGO_OSMO_EWMA;
@@ -204,7 +204,8 @@
mp->ewma.alpha = 70; /* 30% smoothing */
lchan->ms_power_ctrl.current = 15;
- lchan->ms_power_ctrl.avg100_rxlev_dbm = 0;
+ lchan->ms_power_ctrl.rxlev_meas_proc = \
+ (struct gsm_power_ctrl_meas_proc_state) { 0 };
/* This is the first sample, the filter outputs it as-is */
apply_power_test(lchan, -50, 0, 15);
--
To view, visit https://gerrit.osmocom.org/c/osmo-bts/+/21907
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Change-Id: I439c00b394da670e314f217b3246cc85ce8213c6
Gerrit-Change-Number: 21907
Gerrit-PatchSet: 6
Gerrit-Owner: fixeria <vyanitskiy at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
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/20210111/a5c9ef2e/attachment.htm>