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


Change subject: shutdown_fsm: Add power_ramp_force() to jump straight to the 
target power
......................................................................

shutdown_fsm: Add power_ramp_force() to jump straight to the target power

Both power_ramp_start() and power_ramp_force() are now small macros around
_power_ramp_start()

The new behavior is:
* ramp down power when stopping bts through Ctrl-C
* the other shutdown causes skip power ramping

This will cause the bts to reconnect faster when the oml link is
dropped and power ramping is enabled.

Change-Id: Ida1d7bbf094958b9142af306dbf84206729a609e
Related: SYS#6237
---
M include/osmo-bts/bts.h
M include/osmo-bts/tx_power.h
M src/common/bts_shutdown_fsm.c
M src/common/main.c
M src/common/tx_power.c
M src/osmo-bts-trx/l1_if.c
6 files changed, 24 insertions(+), 10 deletions(-)



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

diff --git a/include/osmo-bts/bts.h b/include/osmo-bts/bts.h
index b1a594c..0ecec1e 100644
--- a/include/osmo-bts/bts.h
+++ b/include/osmo-bts/bts.h
@@ -374,6 +374,7 @@

        struct osmo_fsm_inst *shutdown_fi; /* FSM instance to manage shutdown 
procedure during process exit */
        bool shutdown_fi_exit_proc; /* exit process when shutdown_fsm is 
finished? */
+       bool shutdown_fi_skip_power_ramp; /* Skip power ramping and change 
power in one step? */
        struct osmo_fsm_inst *abis_link_fi; /* FSM instance to manage abis 
connection during process startup and link failure */
        struct osmo_tdef *T_defs; /* Timer defines */

@@ -396,7 +397,7 @@

 int bts_init(struct gsm_bts *bts);
 void bts_shutdown(struct gsm_bts *bts, const char *reason);
-void bts_shutdown_ext(struct gsm_bts *bts, const char *reason, bool exit_proc);
+void bts_shutdown_ext(struct gsm_bts *bts, const char *reason, bool exit_proc, 
bool skip_power_ramp);

 int bts_link_estab(struct gsm_bts *bts);

diff --git a/include/osmo-bts/tx_power.h b/include/osmo-bts/tx_power.h
index a7f846e..73134c8 100644
--- a/include/osmo-bts/tx_power.h
+++ b/include/osmo-bts/tx_power.h
@@ -77,7 +77,12 @@
 int get_p_trxout_actual_mdBm(const struct gsm_bts_trx *trx, uint8_t 
bs_power_red);
 int get_p_trxout_actual_mdBm_lchan(const struct gsm_lchan *lchan);

-int power_ramp_start(struct gsm_bts_trx *trx, int p_total_tgt_mdBm, int 
bypass, ramp_compl_cb_t ramp_compl_cb);
+int _power_ramp_start(struct gsm_bts_trx *trx, int p_total_tgt_mdBm, int 
bypass_max_power, ramp_compl_cb_t ramp_compl_cb, bool skip_ramping);
+#define power_ramp_start(trx, p_total_tgt_mdBm, bypass_max_power, 
ramp_compl_cb) \
+       _power_ramp_start(trx, p_total_tgt_mdBm, bypass_max_power, 
ramp_compl_cb, false)
+#define power_ramp_force(trx, p_total_tgt_mdBm, bypass_max_power, 
ramp_compl_cb) \
+       _power_ramp_start(trx, p_total_tgt_mdBm, bypass_max_power, 
ramp_compl_cb, true)
+
 void power_ramp_abort(struct gsm_bts_trx *trx);

 void power_trx_change_compl(struct gsm_bts_trx *trx, int p_trxout_cur_mdBm);
diff --git a/src/common/bts_shutdown_fsm.c b/src/common/bts_shutdown_fsm.c
index 0c6d80c..55e0b19 100644
--- a/src/common/bts_shutdown_fsm.c
+++ b/src/common/bts_shutdown_fsm.c
@@ -89,7 +89,10 @@
        llist_for_each_entry(trx, &bts->trx_list, list) {
                if (trx->mo.nm_state.operational != NM_OPSTATE_ENABLED)
                        continue;
-               power_ramp_start(trx, to_mdB(BTS_SHUTDOWN_POWER_RAMP_TGT), 1, 
ramp_down_compl_cb);
+               if (bts->shutdown_fi_skip_power_ramp)
+                       power_ramp_force(trx, 
to_mdB(BTS_SHUTDOWN_POWER_RAMP_TGT), 1, ramp_down_compl_cb);
+               else
+                       power_ramp_start(trx, 
to_mdB(BTS_SHUTDOWN_POWER_RAMP_TGT), 1, ramp_down_compl_cb);
        }
 }

@@ -250,7 +253,7 @@
        return fi->state != BTS_SHUTDOWN_ST_NONE;
 }

-void bts_shutdown_ext(struct gsm_bts *bts, const char *reason, bool exit_proc)
+void bts_shutdown_ext(struct gsm_bts *bts, const char *reason, bool exit_proc, 
bool skip_power_ramp)
 {
        struct osmo_fsm_inst *fi = bts->shutdown_fi;
        if (bts_shutdown_in_progress(bts)) {
@@ -260,6 +263,7 @@
                return;
        }
        bts->shutdown_fi_exit_proc = exit_proc;
+       bts->shutdown_fi_skip_power_ramp = skip_power_ramp;
        LOGPFSML(fi, LOGL_NOTICE, "Shutting down BTS, exit %u, reason: %s\n",
                 exit_proc, reason);
        osmo_fsm_inst_dispatch(fi, BTS_SHUTDOWN_EV_START, NULL);
@@ -267,7 +271,7 @@

 void bts_shutdown(struct gsm_bts *bts, const char *reason)
 {
-       bts_shutdown_ext(bts, reason, true);
+       bts_shutdown_ext(bts, reason, true, true);
 }

 void bts_model_trx_close_cb(struct gsm_bts_trx *trx, int rc)
diff --git a/src/common/main.c b/src/common/main.c
index 954cc34..ea6c61e 100644
--- a/src/common/main.c
+++ b/src/common/main.c
@@ -233,7 +233,7 @@
                        oml_tx_failure_event_rep(&g_bts->mo,
                                                 NM_SEVER_CRITICAL, 
OSMO_EVT_CRIT_PROC_STOP,
                                                 "BTS: SIGINT received -> 
shutdown");
-                       bts_shutdown(g_bts, "SIGINT");
+                       bts_shutdown_ext(g_bts, "SIGINT", true, false);
                }
                quit++;
                break;
diff --git a/src/common/tx_power.c b/src/common/tx_power.c
index 0307422..dd64613 100644
--- a/src/common/tx_power.c
+++ b/src/common/tx_power.c
@@ -239,8 +239,7 @@
        osmo_timer_schedule(&tpp->ramp.step_timer, tpp->ramp.step_interval_sec, 
0);
 }

-
-int power_ramp_start(struct gsm_bts_trx *trx, int p_total_tgt_mdBm, int 
bypass, ramp_compl_cb_t ramp_compl_cb)
+int _power_ramp_start(struct gsm_bts_trx *trx, int p_total_tgt_mdBm, int 
bypass, ramp_compl_cb_t ramp_compl_cb, bool skip_ramping)
 {
        struct trx_power_params *tpp = &trx->power_params;

@@ -265,7 +264,12 @@
        tpp->p_total_tgt_mdBm = p_total_tgt_mdBm;
        tpp->ramp.compl_cb = ramp_compl_cb;

-       if (we_are_ramping_up(trx)) {
+       if (skip_ramping) {
+               /* Jump straight to the target power */
+               tpp->p_total_cur_mdBm = p_total_tgt_mdBm;
+               tpp->ramp.attenuation_mdB = 0;
+               power_ramp_timer_cb(trx);
+       } else if (we_are_ramping_up(trx)) {
                if (tpp->p_total_tgt_mdBm <= tpp->ramp.max_initial_pout_mdBm) {
                        LOGPTRX(trx, DL1C, LOGL_INFO,
                                "target_power (%d mdBm) is below or equal to 
'power ramp max-initial' power (%d mdBm)\n",
diff --git a/src/osmo-bts-trx/l1_if.c b/src/osmo-bts-trx/l1_if.c
index 8c364c3..ae4fe70 100644
--- a/src/osmo-bts-trx/l1_if.c
+++ b/src/osmo-bts-trx/l1_if.c
@@ -195,7 +195,7 @@
 {
        /* Go into shutdown state deactivating transceivers until Abis link
         * becomes up again */
-       bts_shutdown_ext(bts, "Abis close", false);
+       bts_shutdown_ext(bts, "Abis close", false, true);
 }

 int bts_model_adjst_ms_pwr(struct gsm_lchan *lchan)

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

Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Change-Id: Ida1d7bbf094958b9142af306dbf84206729a609e
Gerrit-Change-Number: 30689
Gerrit-PatchSet: 1
Gerrit-Owner: daniel <[email protected]>
Gerrit-MessageType: newchange

Reply via email to