aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Sperling <ssperling@sysmocom.de>2018-02-14 19:46:33 +0100
committerNeels Hofmeyr <neels@hofmeyr.de>2018-02-27 22:27:52 +0100
commit83d6c2f0e438ec4129bddb9a54ce9dd2777c0748 (patch)
tree69656b0968501e13626b848c48ca81f708bb249e
parent8bba6a29e555fb301c040289912c9d711f8af9bf (diff)
Make osmo-pcu wait for BTS to become available at start-up time.
After the PCU socket becomes available, the BTS might send an INFO_IND message with the 'ACTIVE' flag cleared. If this happens, do not exit immediately, but keep retrying until an INFO_IND message with the 'ACTIVE' flag arrives. Note that this change only affects behaviour at process start-up time. If the BTS switches from active to inactive state then osmo-pcu will still exit. If this behaviour should be changed as well it could be done in a follow-up patch. Tested against osom-bsc + osmo-bts-virtual. Change-Id: Ic42a5601a43b81d260721fef5d9fa52447f9d309 Related: OS#2689
-rw-r--r--src/bts.h1
-rw-r--r--src/osmobts_sock.cpp29
-rw-r--r--src/pcu_l1_if.cpp4
3 files changed, 27 insertions, 7 deletions
diff --git a/src/bts.h b/src/bts.h
index 5679b98..f9f385b 100644
--- a/src/bts.h
+++ b/src/bts.h
@@ -173,6 +173,7 @@ void bts_update_tbf_ta(const char *p, uint32_t fn, uint8_t trx_no, uint8_t ts, i
* we can start to compile pcu_vty.c with c++ and remove the split.
*/
struct gprs_rlcmac_bts {
+ bool active;
uint8_t bsic;
uint8_t fc_interval;
uint16_t fc_bucket_time;
diff --git a/src/osmobts_sock.cpp b/src/osmobts_sock.cpp
index 577d41e..9e4000a 100644
--- a/src/osmobts_sock.cpp
+++ b/src/osmobts_sock.cpp
@@ -55,7 +55,23 @@ struct pcu_sock_state {
struct llist_head upqueue; /* queue for sending messages */
} *pcu_sock_state = NULL;
-static void pcu_sock_timeout(void *_priv);
+static void pcu_sock_timeout(void *_priv)
+{
+ pcu_l1if_open();
+}
+
+static void pcu_tx_txt_retry(void *_priv)
+{
+ struct gprs_rlcmac_bts *bts = bts_main_data();
+ struct pcu_sock_state *state = pcu_sock_state;
+
+ if (bts->active)
+ return;
+
+ LOGP(DL1IF, LOGL_INFO, "Sending version %s to BTS.\n", PACKAGE_VERSION);
+ pcu_tx_txt_ind(PCU_VERSION, "%s", PACKAGE_VERSION);
+ osmo_timer_schedule(&state->timer, 5, 0);
+}
int pcu_sock_send(struct msgb *msg)
{
@@ -268,7 +284,7 @@ int pcu_l1if_open(void)
pcu_sock_state = state;
close(bfd->fd);
bfd->fd = -1;
- state->timer.cb = pcu_sock_timeout;
+ osmo_timer_setup(&state->timer, pcu_sock_timeout, NULL);
osmo_timer_schedule(&state->timer, 5, 0);
return 0;
}
@@ -293,6 +309,10 @@ int pcu_l1if_open(void)
LOGP(DL1IF, LOGL_INFO, "Sending version %s to BTS.\n", PACKAGE_VERSION);
pcu_tx_txt_ind(PCU_VERSION, "%s", PACKAGE_VERSION);
+ /* Schedule a timer so we keep trying until the BTS becomes active. */
+ osmo_timer_setup(&state->timer, pcu_tx_txt_retry, NULL);
+ osmo_timer_schedule(&state->timer, 5, 0);
+
return 0;
}
@@ -312,8 +332,3 @@ void pcu_l1if_close(void)
talloc_free(state);
pcu_sock_state = NULL;
}
-
-static void pcu_sock_timeout(void *_priv)
-{
- pcu_l1if_open();
-}
diff --git a/src/pcu_l1_if.cpp b/src/pcu_l1_if.cpp
index 7112b04..0a9803b 100644
--- a/src/pcu_l1_if.cpp
+++ b/src/pcu_l1_if.cpp
@@ -414,7 +414,10 @@ static int pcu_rx_info_ind(struct gsm_pcu_if_info_ind *info_ind)
if (!(info_ind->flags & PCU_IF_FLAG_ACTIVE)) {
LOGP(DL1IF, LOGL_NOTICE, "BTS not available\n");
+ if (!bts->active)
+ return -EAGAIN;
bssgp_failed:
+ bts->active = false;
/* free all TBF */
for (trx = 0; trx < ARRAY_SIZE(bts->trx); trx++) {
bts->trx[trx].arfcn = info_ind->trx[trx].arfcn;
@@ -562,6 +565,7 @@ bssgp_failed:
}
}
+ bts->active = true;
return rc;
}