Change in osmo-bts[master]: bts-trx: Time out if no clock ind recvd after RSP POWERON

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
Wed Oct 16 11:13:22 UTC 2019


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

Change subject: bts-trx: Time out if no clock ind recvd after RSP POWERON
......................................................................

bts-trx: Time out if no clock ind recvd after RSP POWERON

Before this patch, if due to whatever reason the TRX started fine (RSP
POWERON 0) and sockets were created but no CLOCK IND was ever received
by the BTS, it wouldn't notice since the timerfd timeouts
(bts_shutdown("no clock")) are only checked after the first CLOCK IND is
sent by the TRX.
As a result, the BTS would be kept on forever saying everything is fine
but it would be sending no DL burst at all to the TRX (tested with a
modfied osmo-trx dropping clock indication).
With this patch, new APIs are added to indicate the scheduler_trx code
the timeframes where clock ind are expected (between RSP POWERON 0 and
RSP POWEROFF 0); if TRX sends clock indications out of that timeframe,
BTs lower layers will drop them (controlled by "powered" bool).
Hence, the scheduler_trx can now place a timeout (reusing same timerfd
because its new use is exclusive in time with its other previous use)
when it is told that CLOCK IND should start appearing, and if none
arrives in considerable time, then the BTS can be shut down to notify
the rest of the network.

Related: OS#4215
Change-Id: Iba5dbe867aff10e70ec73dbf1f7aeeecb15c0a4d
---
M include/osmo-bts/scheduler.h
M src/osmo-bts-trx/l1_if.c
M src/osmo-bts-trx/scheduler_trx.c
3 files changed, 57 insertions(+), 2 deletions(-)

Approvals:
  ipse: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/include/osmo-bts/scheduler.h b/include/osmo-bts/scheduler.h
index e693e3e..3100a1d 100644
--- a/include/osmo-bts/scheduler.h
+++ b/include/osmo-bts/scheduler.h
@@ -175,6 +175,12 @@
 /*! \brief PHY informs us of new (current) GSM frame number */
 int trx_sched_clock(struct gsm_bts *bts, uint32_t fn);
 
+/*! \brief PHY informs us clock indications should start to be received */
+int trx_sched_clock_started(struct gsm_bts *bts);
+
+/*! \brief PHY informs us no more clock indications should be received anymore */
+int trx_sched_clock_stopped(struct gsm_bts *bts);
+
 /*! \brief set multiframe scheduler to given physical channel config */
 int trx_sched_set_pchan(struct l1sched_trx *l1t, uint8_t tn,
         enum gsm_phys_chan_config pchan);
diff --git a/src/osmo-bts-trx/l1_if.c b/src/osmo-bts-trx/l1_if.c
index 1079128..38b43b9 100644
--- a/src/osmo-bts-trx/l1_if.c
+++ b/src/osmo-bts-trx/l1_if.c
@@ -176,10 +176,13 @@
 	plink->u.osmotrx.poweronoff_sent = false;
 
 	if (poweronoff) {
-		if (rc == 0 && pinst->phy_link->state != PHY_LINK_CONNECTED)
+		if (rc == 0 && pinst->phy_link->state != PHY_LINK_CONNECTED) {
+			trx_sched_clock_started(pinst->trx->bts);
 			phy_link_state_set(pinst->phy_link, PHY_LINK_CONNECTED);
-		else if (rc != 0 && pinst->phy_link->state != PHY_LINK_SHUTDOWN)
+		} else if (rc != 0 && pinst->phy_link->state != PHY_LINK_SHUTDOWN) {
+			trx_sched_clock_stopped(pinst->trx->bts);
 			phy_link_state_set(pinst->phy_link, PHY_LINK_SHUTDOWN);
+		}
 	}
 }
 
diff --git a/src/osmo-bts-trx/scheduler_trx.c b/src/osmo-bts-trx/scheduler_trx.c
index af639e2..8662a14 100644
--- a/src/osmo-bts-trx/scheduler_trx.c
+++ b/src/osmo-bts-trx/scheduler_trx.c
@@ -1682,6 +1682,52 @@
 	return -1;
 }
 
+/*! \brief This is the cb of the initial timer set upon start. On timeout, it
+ *  means it wasn't replaced and hence no CLOCK IND was received. */
+static int trx_start_noclockind_to_cb(struct osmo_fd *ofd, unsigned int what)
+{
+	struct gsm_bts *bts = ofd->data;
+	struct bts_trx_priv *bts_trx = (struct bts_trx_priv *)bts->model_priv;
+	struct osmo_trx_clock_state *tcs = &bts_trx->clk_s;
+
+	osmo_fd_close(&tcs->fn_timer_ofd); /* Avoid being called again */
+	bts_shutdown(bts, "No clock since TRX was started");
+	return -1;
+}
+
+/*! \brief PHY informs us clock indications should start to be received */
+int trx_sched_clock_started(struct gsm_bts *bts)
+{
+	struct bts_trx_priv *bts_trx = (struct bts_trx_priv *)bts->model_priv;
+	struct osmo_trx_clock_state *tcs = &bts_trx->clk_s;
+	const struct timespec it_val = {3, 0};
+	const struct timespec it_intval = {0, 0};
+
+	LOGP(DL1C, LOGL_NOTICE, "GSM clock started, waiting for clock indications\n");
+	osmo_fd_close(&tcs->fn_timer_ofd);
+	memset(tcs, 0, sizeof(*tcs));
+	tcs->fn_timer_ofd.fd = -1;
+	/* Set up timeout to shutdown BTS if no clock ind is received in a few
+	 * seconds. Upon clock ind receival, fn_timer_ofd will be reused and
+	 * timeout won't trigger.
+	 */
+	osmo_timerfd_setup(&tcs->fn_timer_ofd, trx_start_noclockind_to_cb, bts);
+	osmo_timerfd_schedule(&tcs->fn_timer_ofd, &it_val, &it_intval);
+	return 0;
+}
+
+/*! \brief PHY informs us no more clock indications should be received anymore */
+int trx_sched_clock_stopped(struct gsm_bts *bts)
+{
+	struct bts_trx_priv *bts_trx = (struct bts_trx_priv *)bts->model_priv;
+	struct osmo_trx_clock_state *tcs = &bts_trx->clk_s;
+
+	LOGP(DL1C, LOGL_NOTICE, "GSM clock stopped\n");
+	osmo_fd_close(&tcs->fn_timer_ofd);
+
+	return 0;
+}
+
 /*! reset clock with current fn and schedule it. Called when trx becomes
  *  available or when max clock skew is reached */
 static int trx_setup_clock(struct gsm_bts *bts, struct osmo_trx_clock_state *tcs,

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

Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Change-Id: Iba5dbe867aff10e70ec73dbf1f7aeeecb15c0a4d
Gerrit-Change-Number: 15706
Gerrit-PatchSet: 3
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <axilirator at gmail.com>
Gerrit-Reviewer: ipse <Alexander.Chemeris at gmail.com>
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/20191016/9df1222c/attachment.htm>


More information about the gerrit-log mailing list