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/.
pespin gerrit-no-reply at lists.osmocom.orgpespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-bts/+/18954 ) Change subject: bts_shutdown: Wait until all TRX are closed ...................................................................... bts_shutdown: Wait until all TRX are closed Setting the phy link of a trx to SHUTDOWN sets operative state to DISABLED, so we use operative state as a condition to know whether all TRX are already powered off properly and we can exit. Change-Id: I2bcd211d7edcc8486461a555d6c470a94b166ed7 --- M include/osmo-bts/bts_shutdown_fsm.h M src/common/bts_shutdown_fsm.c 2 files changed, 53 insertions(+), 11 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/54/18954/1 diff --git a/include/osmo-bts/bts_shutdown_fsm.h b/include/osmo-bts/bts_shutdown_fsm.h index 4320b18..b271ea0 100644 --- a/include/osmo-bts/bts_shutdown_fsm.h +++ b/include/osmo-bts/bts_shutdown_fsm.h @@ -28,12 +28,14 @@ enum bts_shutdown_fsm_states { BTS_SHUTDOWN_ST_NONE, BTS_SHUTDOWN_ST_WAIT_RAMP_DOWN_COMPL, + BTS_SHUTDOWN_ST_WAIT_TRX_CLOSED, BTS_SHUTDOWN_ST_EXIT, }; enum bts_shutdown_fsm_events { BTS_SHUTDOWN_EV_START, BTS_SHUTDOWN_EV_TRX_RAMP_COMPL, + BTS_SHUTDOWN_EV_TRX_CLOSED, }; extern struct osmo_fsm bts_shutdown_fsm; diff --git a/src/common/bts_shutdown_fsm.c b/src/common/bts_shutdown_fsm.c index afd6f30..3f79fa3 100644 --- a/src/common/bts_shutdown_fsm.c +++ b/src/common/bts_shutdown_fsm.c @@ -27,13 +27,14 @@ #include <osmo-bts/logging.h> #include <osmo-bts/gsm_data.h> #include <osmo-bts/bts_model.h> +#include <osmo-bts/phy_link.h> #define X(s) (1 << (s)) static const struct osmo_tdef_state_timeout bts_shutdown_fsm_timeouts[32] = { [BTS_SHUTDOWN_ST_NONE] = { }, [BTS_SHUTDOWN_ST_WAIT_RAMP_DOWN_COMPL] = { .T = -1 }, - [BTS_SHUTDOWN_ST_EXIT] = { .T = -2 }, + [BTS_SHUTDOWN_ST_WAIT_TRX_CLOSED] = { .T = -2 }, }; #define bts_shutdown_fsm_state_chg(fi, NEXT_STATE) \ @@ -82,12 +83,12 @@ LOGPFSML(fi, LOGL_INFO, "%s Ramping down complete, %d TRX remaining\n", gsm_trx_name(src_trx), remaining); if (remaining == 0) - bts_shutdown_fsm_state_chg(fi, BTS_SHUTDOWN_ST_EXIT); + bts_shutdown_fsm_state_chg(fi, BTS_SHUTDOWN_ST_WAIT_TRX_CLOSED); break; } } -static void st_exit_on_enter(struct osmo_fsm_inst *fi, uint32_t prev_state) +static void st_wait_trx_closed_on_enter(struct osmo_fsm_inst *fi, uint32_t prev_state) { struct gsm_bts *bts = (struct gsm_bts *)fi->priv; struct gsm_bts_trx *trx; @@ -97,9 +98,37 @@ llist_for_each_entry_reverse(trx, &bts->trx_list, list) { bts_model_trx_close(trx); } - /* There's yet no way to get confirmation from lower layers regarding - state. Allow a few seconds of select() loop and timeout timer will - exit later */ + /* Now wait until all TRX are closed asynchronously, we'll get feedback through events... */ +} + +static void st_wait_trx_closed(struct osmo_fsm_inst *fi, uint32_t event, void *data) +{ + struct gsm_bts *bts = (struct gsm_bts *)fi->priv; + struct gsm_bts_trx *src_trx; + unsigned int i, remaining = 0; + + switch(event) { + case BTS_SHUTDOWN_EV_TRX_CLOSED: + src_trx = (struct gsm_bts_trx *)data; + + for (i = 0; i < bts->num_trx; i++) { + struct gsm_bts_trx *trx = gsm_bts_trx_num(bts, i); + if (trx->mo.nm_state.operational != NM_OPSTATE_DISABLED) + remaining++; + } + + LOGPFSML(fi, LOGL_INFO, "%s TRX closed, %d TRX remaining\n", + gsm_trx_name(src_trx), remaining); + if (remaining == 0) + bts_shutdown_fsm_state_chg(fi, BTS_SHUTDOWN_ST_EXIT); + break; + } +} + +static void st_exit_on_enter(struct osmo_fsm_inst *fi, uint32_t prev_state) +{ + LOGPFSML(fi, LOGL_NOTICE, "Shutdown process completed successfuly, exiting process\n"); + exit(0); } static struct osmo_fsm_state bts_shutdown_fsm_states[] = { @@ -114,11 +143,20 @@ .in_event_mask = X(BTS_SHUTDOWN_EV_TRX_RAMP_COMPL), .out_state_mask = - X(BTS_SHUTDOWN_ST_EXIT), + X(BTS_SHUTDOWN_ST_WAIT_TRX_CLOSED), .name = "WaitRampDownComplete", .onenter = st_wait_ramp_down_compl_on_enter, .action = st_wait_ramp_down_compl, }, + [BTS_SHUTDOWN_ST_WAIT_TRX_CLOSED] = { + .in_event_mask = + X(BTS_SHUTDOWN_EV_TRX_CLOSED), + .out_state_mask = + X(BTS_SHUTDOWN_ST_EXIT), + .name = "WaitTRXClose", + .onenter = st_wait_trx_closed_on_enter, + .action = st_wait_trx_closed, + }, [BTS_SHUTDOWN_ST_EXIT] = { .name = "Exit", .onenter = st_exit_on_enter, @@ -128,6 +166,7 @@ const struct value_string bts_shutdown_fsm_event_names[] = { OSMO_VALUE_STRING(BTS_SHUTDOWN_EV_START), OSMO_VALUE_STRING(BTS_SHUTDOWN_EV_TRX_RAMP_COMPL), + OSMO_VALUE_STRING(BTS_SHUTDOWN_ST_WAIT_TRX_CLOSED), { 0, NULL } }; @@ -136,11 +175,11 @@ switch (fi->state) { case BTS_SHUTDOWN_ST_WAIT_RAMP_DOWN_COMPL: LOGPFSML(fi, LOGL_ERROR, "Timer expired waiting for ramp down complete\n"); - bts_shutdown_fsm_state_chg(fi, BTS_SHUTDOWN_ST_EXIT); + bts_shutdown_fsm_state_chg(fi, BTS_SHUTDOWN_ST_WAIT_TRX_CLOSED); break; - case BTS_SHUTDOWN_ST_EXIT: - LOGPFSML(fi, LOGL_NOTICE, "Shutdown process completed successfuly, exiting process\n"); - exit(0); + case BTS_SHUTDOWN_ST_WAIT_TRX_CLOSED: + LOGPFSML(fi, LOGL_ERROR, "Timer expired waiting for TRX close\n"); + bts_shutdown_fsm_state_chg(fi, BTS_SHUTDOWN_ST_EXIT); break; default: OSMO_ASSERT(false); @@ -178,4 +217,5 @@ { struct osmo_fsm_inst *fi = trx->bts->shutdown_fi; LOGPFSML(fi, LOGL_DEBUG, "%s Received TRX close cb rc=%d\n", gsm_trx_name(trx), rc); + osmo_fsm_inst_dispatch(fi, BTS_SHUTDOWN_EV_TRX_CLOSED, trx); } -- To view, visit https://gerrit.osmocom.org/c/osmo-bts/+/18954 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Change-Id: I2bcd211d7edcc8486461a555d6c470a94b166ed7 Gerrit-Change-Number: 18954 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin at sysmocom.de> Gerrit-MessageType: newchange -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200622/2c6c7970/attachment.htm>