pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-bts/+/41792?usp=email )
Change subject: {bs,ms}_power_control: Add helper function to reset state ......................................................................
{bs,ms}_power_control: Add helper function to reset state
This way we can better document and identify places where the state is reset.
Change-Id: I3e010a4ed72ba2574ce6c1316b8460689fc1d482 --- M include/osmo-bts/power_control.h M src/common/power_control.c M src/common/rsl.c 3 files changed, 27 insertions(+), 4 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/92/41792/1
diff --git a/include/osmo-bts/power_control.h b/include/osmo-bts/power_control.h index 0764ba7..031d462 100644 --- a/include/osmo-bts/power_control.h +++ b/include/osmo-bts/power_control.h @@ -81,10 +81,12 @@ void power_ctrl_params_def_reset(struct gsm_power_ctrl_params *params, bool is_bs_pwr);
struct gsm_lchan; +void lchan_ms_pwr_ctrl_reset(struct gsm_lchan *lchan); int lchan_ms_pwr_ctrl(struct gsm_lchan *lchan, const uint8_t ms_power_lvl, const int8_t ul_rssi_dbm, const int16_t ul_lqual_cb);
+void lchan_bs_pwr_ctrl_reset(struct gsm_lchan *lchan); int lchan_bs_pwr_ctrl(struct gsm_lchan *lchan, const struct gsm48_meas_res *mr); diff --git a/src/common/power_control.c b/src/common/power_control.c index 45d8969..0520ed8 100644 --- a/src/common/power_control.c +++ b/src/common/power_control.c @@ -137,6 +137,16 @@ return delta; }
+void lchan_ms_pwr_ctrl_reset(struct gsm_lchan *lchan) +{ + struct lchan_power_ctrl_state *state = &lchan->ms_power_ctrl; + + /* This below implicitly sets: + * state->dpc_params = NULL (static mode). + * state->skip_block_num = 0, so that 1st power input is taken into account. */ + memset(state, 0, sizeof(*state)); +} + /* Shall we skip current block based on configured interval? */ static bool ctrl_interval_skip_block(const struct gsm_power_ctrl_params *params, struct lchan_power_ctrl_state *state) @@ -310,6 +320,16 @@ return 1; }
+void lchan_bs_pwr_ctrl_reset(struct gsm_lchan *lchan) +{ + struct lchan_power_ctrl_state *state = &lchan->bs_power_ctrl; + + /* This below implicitly sets: + * state->dpc_params = NULL (static mode). + * state->skip_block_num = 0, so that 1st power input is taken into account. */ + memset(state, 0, sizeof(*state)); +} + /*! compute the new Downlink attenuation value for the given logical channel. * \param lchan logical channel for which to compute (and in which to store) new power value. * \param[in] mr pointer to a *valid* Measurement Report. diff --git a/src/common/rsl.c b/src/common/rsl.c index ba403bc..cb13977 100644 --- a/src/common/rsl.c +++ b/src/common/rsl.c @@ -58,6 +58,7 @@ #include <osmo-bts/pcuif_proto.h> #include <osmo-bts/notification.h> #include <osmo-bts/asci.h> +#include <osmo-bts/power_control.h> #include <osmo-bts/ta_control.h>
//#define FAKE_CIPH_MODE_COMPL @@ -1764,8 +1765,8 @@ lchan->tch_mode = 0; memset(&lchan->encr, 0, sizeof(lchan->encr)); memset(&lchan->ho, 0, sizeof(lchan->ho)); - memset(&lchan->ms_power_ctrl, 0, sizeof(lchan->ms_power_ctrl)); - memset(&lchan->bs_power_ctrl, 0, sizeof(lchan->bs_power_ctrl)); + lchan_bs_pwr_ctrl_reset(lchan); + lchan_ms_pwr_ctrl_reset(lchan); lchan_ms_ta_ctrl_reset(lchan); copy_sacch_si_to_lchan(lchan); memset(&lchan->tch, 0, sizeof(lchan->tch)); @@ -1989,8 +1990,8 @@ }
/* Initialize MS/BS Power Control state */ - memset(&lchan->ms_power_ctrl, 0, sizeof(lchan->ms_power_ctrl)); - memset(&lchan->bs_power_ctrl, 0, sizeof(lchan->bs_power_ctrl)); + lchan_bs_pwr_ctrl_reset(lchan); + lchan_ms_pwr_ctrl_reset(lchan);
/* 9.3.6 Channel Mode */ if (type != RSL_ACT_OSMO_PDCH) {