From 3f9b6a6539d487140f6d7e49e8cf9dc06bf040c6 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Mon, 14 Feb 2011 23:27:18 +0100 Subject: rf: Verify that the requested mode is entered and drop OML in error Verify that the BTS is following our orders, if we think there was an error we will drop the OML connection. --- openbsc/src/osmo_bsc_rf.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'openbsc/src/osmo_bsc_rf.c') diff --git a/openbsc/src/osmo_bsc_rf.c b/openbsc/src/osmo_bsc_rf.c index e6b31c71f..b748cc9e7 100644 --- a/openbsc/src/osmo_bsc_rf.c +++ b/openbsc/src/osmo_bsc_rf.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -106,6 +107,30 @@ static void handle_query(struct osmo_bsc_rf_conn *conn) send_resp(conn, send); } +static void rf_check_cb(void *_data) +{ + struct gsm_bts *bts; + struct osmo_bsc_rf *rf = _data; + + llist_for_each_entry(bts, &rf->gsm_network->bts_list, list) { + struct gsm_bts_trx *trx; + + /* don't bother to check a booting or missing BTS */ + if (!bts->oml_link || !is_ipaccess_bts(bts)) + continue; + + llist_for_each_entry(trx, &bts->trx_list, list) { + if (trx->nm_state.availability != NM_AVSTATE_OK || + trx->nm_state.operational != NM_OPSTATE_ENABLED || + trx->nm_state.administrative != NM_STATE_UNLOCKED) { + LOGP(DNM, LOGL_ERROR, "RF activation failed. Starting again.\n"); + ipaccess_drop_oml(bts); + break; + } + } + } +} + static void send_signal(struct osmo_bsc_rf *rf, int val) { struct rf_signal_data sig; @@ -167,6 +192,7 @@ static int rf_read_cmd(struct bsc_fd *fd) break; case RF_CMD_D_OFF: conn->rf->last_state_command = "RF Direct Off"; + bsc_del_timer(&conn->rf->rf_check); bsc_del_timer(&conn->rf->grace_timeout); switch_rf_off(conn->rf); break; @@ -175,9 +201,11 @@ static int rf_read_cmd(struct bsc_fd *fd) bsc_del_timer(&conn->rf->grace_timeout); lock_each_trx(conn->rf->gsm_network, 0); send_signal(conn->rf, S_RF_ON); + bsc_schedule_timer(&conn->rf->rf_check, 3, 0); break; case RF_CMD_OFF: conn->rf->last_state_command = "RF Scheduled Off"; + bsc_del_timer(&conn->rf->rf_check); enter_grace(conn); break; default: @@ -311,6 +339,10 @@ struct osmo_bsc_rf *osmo_bsc_rf_create(const char *path, struct gsm_network *net rf->policy = S_RF_ON; rf->last_state_command = ""; + /* check the rf state */ + rf->rf_check.data = rf; + rf->rf_check.cb = rf_check_cb; + return rf; } -- cgit v1.2.3