diff options
author | Pau Espin Pedrol <pespin@sysmocom.de> | 2020-06-17 19:26:27 +0200 |
---|---|---|
committer | Pau Espin Pedrol <pespin@sysmocom.de> | 2020-06-18 19:11:55 +0200 |
commit | f5e22703e76ee04b8f80911eb71f62a4357d3e64 (patch) | |
tree | 5ab79f922ac732c2d07ea46640621237169cda30 | |
parent | d819a57c60a28dcad4478f041e82b9da818e0373 (diff) |
power_ramp: Add support to get callback when ramping process completes
It will be used in forthcoming commits to feed FSM events once the
ramping process completes.
Change-Id: I778dc215cf6055b93658670cc12e78ad2e51f85e
-rw-r--r-- | include/osmo-bts/tx_power.h | 6 | ||||
-rw-r--r-- | src/common/bts_ctrl_commands.c | 2 | ||||
-rw-r--r-- | src/common/tx_power.c | 8 | ||||
-rw-r--r-- | src/osmo-bts-litecell15/lc15bts_vty.c | 2 | ||||
-rw-r--r-- | src/osmo-bts-litecell15/oml.c | 4 | ||||
-rw-r--r-- | src/osmo-bts-oc2g/oc2gbts_vty.c | 2 | ||||
-rw-r--r-- | src/osmo-bts-oc2g/oml.c | 4 | ||||
-rw-r--r-- | src/osmo-bts-octphy/l1_oml.c | 2 | ||||
-rw-r--r-- | src/osmo-bts-sysmo/oml.c | 4 | ||||
-rw-r--r-- | src/osmo-bts-sysmo/sysmobts_vty.c | 2 | ||||
-rw-r--r-- | src/osmo-bts-trx/l1_if.c | 6 | ||||
-rw-r--r-- | tests/tx_power/tx_power_test.c | 2 |
12 files changed, 26 insertions, 18 deletions
diff --git a/include/osmo-bts/tx_power.h b/include/osmo-bts/tx_power.h index 8f331008..4d0457b3 100644 --- a/include/osmo-bts/tx_power.h +++ b/include/osmo-bts/tx_power.h @@ -20,6 +20,8 @@ struct power_amp { struct pa_calibration calib; }; +typedef void (*ramp_compl_cb_t)(struct gsm_bts_trx *trx); + /* Transmit power related parameters of a transceiver */ struct trx_power_params { /* specified maximum output of TRX at full power, has to be @@ -55,6 +57,8 @@ struct trx_power_params { unsigned int step_size_mdB; unsigned int step_interval_sec; struct osmo_timer_list step_timer; + /* call-back called when target is reached */ + ramp_compl_cb_t compl_cb; } ramp; }; @@ -73,7 +77,7 @@ int get_p_trxout_target_mdBm_lchan(struct gsm_lchan *lchan); int get_p_trxout_actual_mdBm(struct gsm_bts_trx *trx, uint8_t bs_power_red); int get_p_trxout_actual_mdBm_lchan(struct gsm_lchan *lchan); -int power_ramp_start(struct gsm_bts_trx *trx, int p_total_tgt_mdBm, int bypass); +int power_ramp_start(struct gsm_bts_trx *trx, int p_total_tgt_mdBm, int bypass, ramp_compl_cb_t ramp_compl_cb); void power_trx_change_compl(struct gsm_bts_trx *trx, int p_trxout_cur_mdBm); diff --git a/src/common/bts_ctrl_commands.c b/src/common/bts_ctrl_commands.c index 0d318900..faaba6a1 100644 --- a/src/common/bts_ctrl_commands.c +++ b/src/common/bts_ctrl_commands.c @@ -57,7 +57,7 @@ static int set_therm_att(struct ctrl_cmd *cmd, void *data) tpp->thermal_attenuation_mdB = val; - power_ramp_start(trx, tpp->p_total_cur_mdBm, 0); + power_ramp_start(trx, tpp->p_total_cur_mdBm, 0, NULL); return get_therm_att(cmd, data); } diff --git a/src/common/tx_power.c b/src/common/tx_power.c index 705038c5..6469c866 100644 --- a/src/common/tx_power.c +++ b/src/common/tx_power.c @@ -210,8 +210,11 @@ static void power_ramp_do_step(struct gsm_bts_trx *trx, int first) struct trx_power_params *tpp = &trx->power_params; /* we had finished in last loop iteration */ - if (!first && tpp->ramp.attenuation_mdB == 0) + if (!first && tpp->ramp.attenuation_mdB == 0) { + if (tpp->ramp.compl_cb) + tpp->ramp.compl_cb(trx); return; + } if (we_are_ramping_up(trx)) { /* ramp up power -> ramp down attenuation */ @@ -236,7 +239,7 @@ static void power_ramp_do_step(struct gsm_bts_trx *trx, int first) } -int power_ramp_start(struct gsm_bts_trx *trx, int p_total_tgt_mdBm, int bypass) +int power_ramp_start(struct gsm_bts_trx *trx, int p_total_tgt_mdBm, int bypass, ramp_compl_cb_t ramp_compl_cb) { struct trx_power_params *tpp = &trx->power_params; @@ -259,6 +262,7 @@ int power_ramp_start(struct gsm_bts_trx *trx, int p_total_tgt_mdBm, int bypass) /* set the new target */ tpp->p_total_tgt_mdBm = p_total_tgt_mdBm; + tpp->ramp.compl_cb = ramp_compl_cb; if (we_are_ramping_up(trx)) { if (tpp->p_total_tgt_mdBm <= tpp->ramp.max_initial_pout_mdBm) { diff --git a/src/osmo-bts-litecell15/lc15bts_vty.c b/src/osmo-bts-litecell15/lc15bts_vty.c index 50410334..2cc812ca 100644 --- a/src/osmo-bts-litecell15/lc15bts_vty.c +++ b/src/osmo-bts-litecell15/lc15bts_vty.c @@ -291,7 +291,7 @@ DEFUN(set_tx_power, set_tx_power_cmd, int power = atoi(argv[1]); struct gsm_bts_trx *trx = gsm_bts_trx_num(vty_bts, trx_nr); - power_ramp_start(trx, to_mdB(power), 1); + power_ramp_start(trx, to_mdB(power), 1, NULL); return CMD_SUCCESS; } diff --git a/src/osmo-bts-litecell15/oml.c b/src/osmo-bts-litecell15/oml.c index 4efa54d4..2f462b61 100644 --- a/src/osmo-bts-litecell15/oml.c +++ b/src/osmo-bts-litecell15/oml.c @@ -355,7 +355,7 @@ static int trx_init_compl_cb(struct gsm_bts_trx *trx, struct msgb *l1_msg, trx_rf_lock(trx, 1, trx_mute_on_init_cb); /* Begin to ramp up the power */ - power_ramp_start(trx, get_p_target_mdBm(trx, 0), 0); + power_ramp_start(trx, get_p_target_mdBm(trx, 0), 0, NULL); return opstart_compl(&trx->mo, l1_msg); } @@ -1842,7 +1842,7 @@ int bts_model_apply_oml(struct gsm_bts *bts, struct msgb *msg, /* Did we go through MphInit yet? If yes fire and forget */ if (fl1h->hLayer1) { - power_ramp_start(trx, get_p_target_mdBm(trx, 0), 0); + power_ramp_start(trx, get_p_target_mdBm(trx, 0), 0, NULL); #if LITECELL15_API_VERSION >= LITECELL15_API(2,1,7) if (fl1h->phy_inst->u.lc15.tx_pwr_red_8psk != trx->max_power_backoff_8psk) { /* update current Tx power backoff for 8-PSK */ diff --git a/src/osmo-bts-oc2g/oc2gbts_vty.c b/src/osmo-bts-oc2g/oc2gbts_vty.c index 383876fe..8dc4efaa 100644 --- a/src/osmo-bts-oc2g/oc2gbts_vty.c +++ b/src/osmo-bts-oc2g/oc2gbts_vty.c @@ -284,7 +284,7 @@ DEFUN(set_tx_power, set_tx_power_cmd, int power = atoi(argv[1]); struct gsm_bts_trx *trx = gsm_bts_trx_num(vty_bts, trx_nr); - power_ramp_start(trx, to_mdB(power), 1); + power_ramp_start(trx, to_mdB(power), 1, NULL); return CMD_SUCCESS; } diff --git a/src/osmo-bts-oc2g/oml.c b/src/osmo-bts-oc2g/oml.c index 567dd526..cc8d02d6 100644 --- a/src/osmo-bts-oc2g/oml.c +++ b/src/osmo-bts-oc2g/oml.c @@ -371,7 +371,7 @@ static int trx_init_compl_cb(struct gsm_bts_trx *trx, struct msgb *l1_msg, */ /* Begin to ramp up the power */ - power_ramp_start(trx, get_p_target_mdBm(trx, 0), 0); + power_ramp_start(trx, get_p_target_mdBm(trx, 0), 0, NULL); return opstart_compl(&trx->mo, l1_msg); } @@ -1850,7 +1850,7 @@ int bts_model_apply_oml(struct gsm_bts *bts, struct msgb *msg, /* Did we go through MphInit yet? If yes fire and forget */ if (fl1h->hLayer1) { - power_ramp_start(trx, get_p_target_mdBm(trx, 0), 0); + power_ramp_start(trx, get_p_target_mdBm(trx, 0), 0, NULL); if (fl1h->phy_inst->u.oc2g.tx_pwr_red_8psk != trx->max_power_backoff_8psk) { /* update current Tx power backoff for 8-PSK */ diff --git a/src/osmo-bts-octphy/l1_oml.c b/src/osmo-bts-octphy/l1_oml.c index 0f366621..61d56bb6 100644 --- a/src/osmo-bts-octphy/l1_oml.c +++ b/src/osmo-bts-octphy/l1_oml.c @@ -1740,7 +1740,7 @@ int bts_model_apply_oml(struct gsm_bts *bts, struct msgb *msg, struct gsm_bts_trx *trx = obj; /*struct octphy_hdl *fl1h = trx_octphy_hdl(trx); */ - power_ramp_start(trx, get_p_target_mdBm(trx, 0), 0); + power_ramp_start(trx, get_p_target_mdBm(trx, 0), 0, NULL); } return oml_fom_ack_nack(msg, 0); } diff --git a/src/osmo-bts-sysmo/oml.c b/src/osmo-bts-sysmo/oml.c index 3533597f..c3bf8b69 100644 --- a/src/osmo-bts-sysmo/oml.c +++ b/src/osmo-bts-sysmo/oml.c @@ -358,7 +358,7 @@ static int trx_init_compl_cb(struct gsm_bts_trx *trx, struct msgb *l1_msg, #endif /* Begin to ramp up the power */ - power_ramp_start(trx, get_p_target_mdBm(trx, 0), 0); + power_ramp_start(trx, get_p_target_mdBm(trx, 0), 0, NULL); return opstart_compl(&trx->mo, l1_msg); } @@ -1743,7 +1743,7 @@ int bts_model_apply_oml(struct gsm_bts *bts, struct msgb *msg, /* Did we go through MphInit yet? If yes fire and forget */ if (fl1h->hLayer1) - power_ramp_start(trx, get_p_target_mdBm(trx, 0), 0); + power_ramp_start(trx, get_p_target_mdBm(trx, 0), 0, NULL); } /* FIXME: we actually need to send a ACK or NACK for the OML message */ diff --git a/src/osmo-bts-sysmo/sysmobts_vty.c b/src/osmo-bts-sysmo/sysmobts_vty.c index 23f69a04..0653f01b 100644 --- a/src/osmo-bts-sysmo/sysmobts_vty.c +++ b/src/osmo-bts-sysmo/sysmobts_vty.c @@ -362,7 +362,7 @@ DEFUN(set_tx_power, set_tx_power_cmd, int power = atoi(argv[1]); struct gsm_bts_trx *trx = gsm_bts_trx_num(vty_bts, trx_nr); - power_ramp_start(trx, to_mdB(power), 1); + power_ramp_start(trx, to_mdB(power), 1, NULL); return CMD_SUCCESS; } diff --git a/src/osmo-bts-trx/l1_if.c b/src/osmo-bts-trx/l1_if.c index 07f6e7ab..ea3dcfa7 100644 --- a/src/osmo-bts-trx/l1_if.c +++ b/src/osmo-bts-trx/l1_if.c @@ -144,9 +144,9 @@ static void l1if_trx_start_power_ramp(struct gsm_bts_trx *trx) struct trx_l1h *l1h = pinst->u.osmotrx.hdl; if (l1h->config.forced_max_power_red == -1) - power_ramp_start(trx, get_p_nominal_mdBm(trx), 0); + power_ramp_start(trx, get_p_nominal_mdBm(trx), 0, NULL); else - power_ramp_start(trx, get_p_max_out_mdBm(trx) - to_mdB(l1h->config.forced_max_power_red), 1); + power_ramp_start(trx, get_p_max_out_mdBm(trx) - to_mdB(l1h->config.forced_max_power_red), 1, NULL); } /* Sets the nominal power, in dB */ @@ -478,7 +478,7 @@ static uint8_t trx_set_trx(struct gsm_bts_trx *trx) is already running. Otherwise skip, power ramping will be started after TRX is running */ if (plink->u.osmotrx.powered && l1h->config.forced_max_power_red == -1) - power_ramp_start(pinst->trx, get_p_nominal_mdBm(pinst->trx), 0); + power_ramp_start(pinst->trx, get_p_nominal_mdBm(pinst->trx), 0, NULL); return 0; } diff --git a/tests/tx_power/tx_power_test.c b/tests/tx_power/tx_power_test.c index aaa34ea8..02c940ff 100644 --- a/tests/tx_power/tx_power_test.c +++ b/tests/tx_power/tx_power_test.c @@ -200,7 +200,7 @@ static void test_power_ramp(struct gsm_bts_trx *trx, int dBm) trx->power_params.ramp.step_interval_sec = 0; /* speedup test */ trx->max_power_red = 0; - power_ramp_start(trx, to_mdB(dBm), 0); + power_ramp_start(trx, to_mdB(dBm), 0, NULL); } int main(int argc, char **argv) |