diff --git a/src/common/power_control.c b/src/common/power_control.c index 62905bd22..a3334be85 100644 --- a/src/common/power_control.c +++ b/src/common/power_control.c @@ -199,6 +199,7 @@ int lchan_ms_pwr_ctrl(struct gsm_lchan *lchan, uint8_t rxlev_avg; int16_t ul_lqual_cb_avg; const struct gsm_power_ctrl_meas_params *ci_meas; + bool ignore; if (!trx_ms_pwr_ctrl_is_osmo(trx)) return 0; @@ -254,7 +255,29 @@ int lchan_ms_pwr_ctrl(struct gsm_lchan *lchan, return 0; } - if (state->current == new_power_lvl) { + current_dbm = ms_pwr_dbm(band, state->current); + + /* In this Power Control Loop, we infer a new good MS Power Level based + * on the previous MS Power Level announced by the MS (not the previous + * one we requested!) together with the related computed measurements. + * Hence, and since we allow for several good MS Power Levels falling into our + * thresholds, we could finally converge into an oscillation loop where + * the MS bounces between 2 different correct MS Power levels all the + * time, due to the fact that we "accept" and "request back" whatever + * good MS Power Level we received from the MS, but at that time the MS + * will be transmitting using the previous MS Power Level we + * requested, which we will later "accept" and "request back" on next loop + * iteration. As a result MS effectively bounces between those 2 MS + * Power Levels. + * In order to fix this permanent oscillation, if current MS_PWR used/announced + * by MS is good ("ms_dbm == new_dbm", hence within thresholds and no change + * required) but has higher Tx power than the one we last requested, we ignore + * it and keep requesting for one with lower Tx power. This way we converge to + * the lowest good Tx power avoiding oscillating over values within thresholds. + */ + ignore = (ms_dbm == new_dbm && ms_dbm > current_dbm); + + if (state->current == new_power_lvl || ignore) { LOGPLCHAN(lchan, DLOOP, LOGL_INFO, "Keeping MS power at control level %d (%d dBm): " "ms-pwr-lvl[curr %" PRIu8 ", max %" PRIu8 "], RSSI[curr %d, avg %d, thresh %d..%d] dBm," " C/I[curr %d, avg %d, thresh %d..%d] dB\n", @@ -264,7 +287,6 @@ int lchan_ms_pwr_ctrl(struct gsm_lchan *lchan, return 0; } - current_dbm = ms_pwr_dbm(band, state->current); LOGPLCHAN(lchan, DLOOP, LOGL_INFO, "%s MS power control level %d (%d dBm) => %d (%d dBm): " "ms-pwr-lvl[curr %" PRIu8 ", max %" PRIu8 "], RSSI[curr %d, avg %d, thresh %d..%d] dBm," " C/I[curr %d, avg %d, thresh %d..%d] dB\n", diff --git a/tests/power/ms_power_loop_test.c b/tests/power/ms_power_loop_test.c index d8d1c7105..e54d75ff1 100644 --- a/tests/power/ms_power_loop_test.c +++ b/tests/power/ms_power_loop_test.c @@ -398,11 +398,11 @@ static void test_good_threshold_convergence(void) lchan->ms_power_ctrl.current = 10; lchan->ms_power_ctrl.max = 2; - apply_power_test_ext(lchan, 9, good_rxlev, good_lqual, 1, 9); - apply_power_test_ext(lchan, 10, good_rxlev, good_lqual, 1, 10); - apply_power_test_ext(lchan, 9, good_rxlev, good_lqual, 1, 9); - apply_power_test_ext(lchan, 10, good_rxlev, good_lqual, 1, 10); - apply_power_test_ext(lchan, 9, good_rxlev, good_lqual, 1, 9); + apply_power_test_ext(lchan, 9, good_rxlev, good_lqual, 0, 10); + apply_power_test_ext(lchan, 10, good_rxlev, good_lqual, 0, 10); + apply_power_test_ext(lchan, 9, good_rxlev, good_lqual, 0, 10); + apply_power_test_ext(lchan, 10, good_rxlev, good_lqual, 0, 10); + apply_power_test_ext(lchan, 9, good_rxlev, good_lqual, 0, 10); } int main(int argc, char **argv) diff --git a/tests/power/ms_power_loop_test.err b/tests/power/ms_power_loop_test.err index 5a68e3b22..07d90691b 100644 --- a/tests/power/ms_power_loop_test.err +++ b/tests/power/ms_power_loop_test.err @@ -58,8 +58,8 @@ (bts=0,trx=0,ts=0,ss=0) Lowering MS power control level 11 (8 dBm) => 12 (6 dBm): ms-pwr-lvl[curr 11, max 2], RSSI[curr -100, avg -100, thresh -75..-75] dBm, C/I[curr 17, avg 17, thresh 12..16] dB (bts=0,trx=0,ts=0,ss=0) Lowering MS power control level 12 (6 dBm) => 13 (4 dBm): ms-pwr-lvl[curr 12, max 2], RSSI[curr -60, avg -60, thresh -75..-75] dBm, C/I[curr 14, avg 14, thresh 12..16] dB (bts=0,trx=0,ts=0,ss=0) Lowering MS power control level 13 (4 dBm) => 14 (2 dBm): ms-pwr-lvl[curr 13, max 2], RSSI[curr -60, avg -60, thresh -75..-75] dBm, C/I[curr 17, avg 17, thresh 12..16] dB -(bts=0,trx=0,ts=0,ss=0) Raising MS power control level 10 (10 dBm) => 9 (12 dBm): ms-pwr-lvl[curr 9, max 2], RSSI[curr -78, avg -78, thresh -80..-73] dBm, C/I[curr 14, avg 14, thresh 12..16] dB -(bts=0,trx=0,ts=0,ss=0) Lowering MS power control level 9 (12 dBm) => 10 (10 dBm): ms-pwr-lvl[curr 10, max 2], RSSI[curr -78, avg -78, thresh -80..-73] dBm, C/I[curr 14, avg 14, thresh 12..16] dB -(bts=0,trx=0,ts=0,ss=0) Raising MS power control level 10 (10 dBm) => 9 (12 dBm): ms-pwr-lvl[curr 9, max 2], RSSI[curr -78, avg -78, thresh -80..-73] dBm, C/I[curr 14, avg 14, thresh 12..16] dB -(bts=0,trx=0,ts=0,ss=0) Lowering MS power control level 9 (12 dBm) => 10 (10 dBm): ms-pwr-lvl[curr 10, max 2], RSSI[curr -78, avg -78, thresh -80..-73] dBm, C/I[curr 14, avg 14, thresh 12..16] dB -(bts=0,trx=0,ts=0,ss=0) Raising MS power control level 10 (10 dBm) => 9 (12 dBm): ms-pwr-lvl[curr 9, max 2], RSSI[curr -78, avg -78, thresh -80..-73] dBm, C/I[curr 14, avg 14, thresh 12..16] dB +(bts=0,trx=0,ts=0,ss=0) Keeping MS power at control level 9 (12 dBm): ms-pwr-lvl[curr 9, max 2], RSSI[curr -78, avg -78, thresh -80..-73] dBm, C/I[curr 14, avg 14, thresh 12..16] dB +(bts=0,trx=0,ts=0,ss=0) Keeping MS power at control level 10 (10 dBm): ms-pwr-lvl[curr 10, max 2], RSSI[curr -78, avg -78, thresh -80..-73] dBm, C/I[curr 14, avg 14, thresh 12..16] dB +(bts=0,trx=0,ts=0,ss=0) Keeping MS power at control level 9 (12 dBm): ms-pwr-lvl[curr 9, max 2], RSSI[curr -78, avg -78, thresh -80..-73] dBm, C/I[curr 14, avg 14, thresh 12..16] dB +(bts=0,trx=0,ts=0,ss=0) Keeping MS power at control level 10 (10 dBm): ms-pwr-lvl[curr 10, max 2], RSSI[curr -78, avg -78, thresh -80..-73] dBm, C/I[curr 14, avg 14, thresh 12..16] dB +(bts=0,trx=0,ts=0,ss=0) Keeping MS power at control level 9 (12 dBm): ms-pwr-lvl[curr 9, max 2], RSSI[curr -78, avg -78, thresh -80..-73] dBm, C/I[curr 14, avg 14, thresh 12..16] dB diff --git a/tests/power/ms_power_loop_test.ok b/tests/power/ms_power_loop_test.ok index 4dc01e4b4..09e19ad42 100644 --- a/tests/power/ms_power_loop_test.ok +++ b/tests/power/ms_power_loop_test.ok @@ -166,14 +166,14 @@ lchan_ms_pwr_ctrl(RxLvl=-60 dBm) returns 1 (expected 1) MS current power 13 -> 14 (expected 14) Starting test case 'test_good_threshold_convergence' -lchan_ms_pwr_ctrl(RxLvl=-78 dBm) returns 1 (expected 1) - MS current power 9 -> 9 (expected 9) -lchan_ms_pwr_ctrl(RxLvl=-78 dBm) returns 1 (expected 1) +lchan_ms_pwr_ctrl(RxLvl=-78 dBm) returns 0 (expected 0) + MS current power 9 -> 10 (expected 10) +lchan_ms_pwr_ctrl(RxLvl=-78 dBm) returns 0 (expected 0) MS current power 10 -> 10 (expected 10) -lchan_ms_pwr_ctrl(RxLvl=-78 dBm) returns 1 (expected 1) - MS current power 9 -> 9 (expected 9) -lchan_ms_pwr_ctrl(RxLvl=-78 dBm) returns 1 (expected 1) +lchan_ms_pwr_ctrl(RxLvl=-78 dBm) returns 0 (expected 0) + MS current power 9 -> 10 (expected 10) +lchan_ms_pwr_ctrl(RxLvl=-78 dBm) returns 0 (expected 0) MS current power 10 -> 10 (expected 10) -lchan_ms_pwr_ctrl(RxLvl=-78 dBm) returns 1 (expected 1) - MS current power 9 -> 9 (expected 9) +lchan_ms_pwr_ctrl(RxLvl=-78 dBm) returns 0 (expected 0) + MS current power 9 -> 10 (expected 10) Power loop test OK