Change in osmo-bts[master]: bts_shutdown: Speed up shutdown if no TRX is operational

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.org
Mon Jul 6 15:03:58 UTC 2020


pespin has submitted this change. ( https://gerrit.osmocom.org/c/osmo-bts/+/19108 )

Change subject: bts_shutdown: Speed up shutdown if no TRX is operational
......................................................................

bts_shutdown: Speed up shutdown if no TRX is operational

This change avoids waiting for full ramp down if TRXs are already non
operational.

Change-Id: Ie1c7c3a969e7968075b89edcd1ab2227b178a869
---
M src/common/bts_shutdown_fsm.c
1 file changed, 36 insertions(+), 11 deletions(-)

Approvals:
  Jenkins Builder: Verified
  Hoernchen: Looks good to me, but someone else must approve
  laforge: Looks good to me, approved
  fixeria: Looks good to me, but someone else must approve



diff --git a/src/common/bts_shutdown_fsm.c b/src/common/bts_shutdown_fsm.c
index d8a8d11..d55b1cd 100644
--- a/src/common/bts_shutdown_fsm.c
+++ b/src/common/bts_shutdown_fsm.c
@@ -22,6 +22,7 @@
 
 #include <osmocom/core/fsm.h>
 #include <osmocom/core/tdef.h>
+#include <osmocom/gsm/protocol/gsm_12_21.h>
 
 #include <osmo-bts/bts_shutdown_fsm.h>
 #include <osmo-bts/logging.h>
@@ -38,11 +39,33 @@
 #define bts_shutdown_fsm_state_chg(fi, NEXT_STATE) \
 	osmo_tdef_fsm_inst_state_chg(fi, NEXT_STATE, bts_shutdown_fsm_timeouts, ((struct gsm_bts *)fi->priv)->T_defs, -1)
 
+static unsigned int count_trx_operational(struct gsm_bts *bts) {
+	unsigned int count = 0;
+	struct gsm_bts_trx *trx;
+	llist_for_each_entry(trx, &bts->trx_list, list) {
+		if (trx->mo.nm_state.operational == NM_OPSTATE_ENABLED)
+			count++;
+	}
+	return count;
+}
+
 static void st_none(struct osmo_fsm_inst *fi, uint32_t event, void *data)
 {
+	struct gsm_bts *bts = (struct gsm_bts *)fi->priv;
+	unsigned int count;
 	switch(event) {
 	case BTS_SHUTDOWN_EV_START:
-		bts_shutdown_fsm_state_chg(fi, BTS_SHUTDOWN_ST_WAIT_RAMP_DOWN_COMPL);
+		count = count_trx_operational(bts);
+		if (count) {
+			bts_shutdown_fsm_state_chg(fi, BTS_SHUTDOWN_ST_WAIT_RAMP_DOWN_COMPL);
+		} else {
+			/* we can skip ramp down since no TRX is running anyway.
+			 * Let's jump into WAIT_TRX_CLOSED to make sure we
+			 * tell lower layer to close all TRX in case there's some
+			 * open() WIP */
+			LOGPFSML(fi, LOGL_INFO, "No TRX is operational, skipping power ramp down\n");
+			bts_shutdown_fsm_state_chg(fi, BTS_SHUTDOWN_ST_WAIT_TRX_CLOSED);
+		}
 		break;
 	}
 }
@@ -56,8 +79,11 @@
 	struct gsm_bts *bts = (struct gsm_bts *)fi->priv;
 	struct gsm_bts_trx *trx;
 
-	llist_for_each_entry(trx, &bts->trx_list, list)
+	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(-10), 1, ramp_down_compl_cb);
+	}
 }
 
 static void st_wait_ramp_down_compl(struct osmo_fsm_inst *fi, uint32_t event, void *data)
@@ -72,7 +98,8 @@
 		src_trx = (struct gsm_bts_trx *)data;
 
 		llist_for_each_entry(trx, &bts->trx_list, list) {
-			if (trx->power_params.p_total_cur_mdBm > 0)
+			if (trx->mo.nm_state.operational == NM_OPSTATE_ENABLED &&
+			    trx->power_params.p_total_cur_mdBm > 0)
 				remaining++;
 		}
 
@@ -100,17 +127,13 @@
 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, *trx;
-	unsigned int remaining = 0;
+	struct gsm_bts_trx *src_trx;
+	unsigned int remaining;
 
 	switch(event) {
 	case BTS_SHUTDOWN_EV_TRX_CLOSED:
 		src_trx = (struct gsm_bts_trx *)data;
-
-		llist_for_each_entry(trx, &bts->trx_list, list) {
-			if (trx->mo.nm_state.operational != NM_OPSTATE_DISABLED)
-				remaining++;
-		}
+		remaining = count_trx_operational(bts);
 
 		LOGPFSML(fi, LOGL_INFO, "%s TRX closed, %u TRX remaining\n",
 			 gsm_trx_name(src_trx), remaining);
@@ -130,7 +153,9 @@
 	[BTS_SHUTDOWN_ST_NONE] = {
 		.in_event_mask =
 			X(BTS_SHUTDOWN_EV_START),
-		.out_state_mask = X(BTS_SHUTDOWN_ST_WAIT_RAMP_DOWN_COMPL),
+		.out_state_mask =
+			X(BTS_SHUTDOWN_ST_WAIT_RAMP_DOWN_COMPL) |
+			X(BTS_SHUTDOWN_ST_WAIT_TRX_CLOSED),
 		.name = "NONE",
 		.action = st_none,
 	},

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

Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Change-Id: Ie1c7c3a969e7968075b89edcd1ab2227b178a869
Gerrit-Change-Number: 19108
Gerrit-PatchSet: 2
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-Reviewer: Hoernchen <ewild at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy at sysmocom.de>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200706/b3ee242e/attachment.htm>


More information about the gerrit-log mailing list