aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilipp <pmaier@sysmocom.de>2016-09-28 12:30:07 +0200
committerHarald Welte <laforge@gnumonks.org>2017-02-01 19:16:17 +0000
commit67bc885c5d85237cc15b47ee2ee6773ea2af28e1 (patch)
tree6b86ff1a2198fb138b2c3704d511e6812815eb5b
parenta760a043c4153770fe9577259989169cb2286a82 (diff)
octphy: Improve OML ADM state handling
Improve state handling for for lock/unlock of OC_RADIO_CARRIER obj class. in bts_model_chg_adm_state() Change-Id: I034114beca95210169429d8ac1eb8648df12fc6c
-rw-r--r--include/osmo-bts/phy_link.h2
-rw-r--r--src/osmo-bts-octphy/l1_oml.c61
2 files changed, 61 insertions, 2 deletions
diff --git a/include/osmo-bts/phy_link.h b/include/osmo-bts/phy_link.h
index 1f8450b8..a7963d05 100644
--- a/include/osmo-bts/phy_link.h
+++ b/include/osmo-bts/phy_link.h
@@ -105,6 +105,8 @@ struct phy_instance {
struct {
/* logical transceiver number within one PHY */
uint32_t trx_id;
+ /* trx lock state variable */
+ int trx_locked;
} octphy;
struct {
/* configuration */
diff --git a/src/osmo-bts-octphy/l1_oml.c b/src/osmo-bts-octphy/l1_oml.c
index 08516ef4..a68169e8 100644
--- a/src/osmo-bts-octphy/l1_oml.c
+++ b/src/osmo-bts-octphy/l1_oml.c
@@ -1539,8 +1539,65 @@ int bts_model_oml_estab(struct gsm_bts *bts)
int bts_model_chg_adm_state(struct gsm_bts *bts, struct gsm_abis_mo *mo,
void *obj, uint8_t adm_state)
{
- /* TODO: implement this properly */
- /* blindly accept all state changes */
+ int rc;
+
+ struct gsm_bts_trx *trx;
+ struct phy_instance *pinst;
+ struct octphy_hdl *fl1h;
+
+ switch (mo->obj_class) {
+ case NM_OC_RADIO_CARRIER:
+
+ trx = ((struct gsm_bts_trx *)obj);
+ pinst = trx_phy_instance(trx);
+ fl1h = pinst->phy_link->u.octphy.hdl;
+
+ if (mo->procedure_pending) {
+ LOGP(DL1C, LOGL_ERROR, "Discarding adm change command: "
+ "pending procedure on TRX %d\n", trx->nr);
+ return 0;
+ }
+ mo->procedure_pending = 1;
+ switch (adm_state) {
+ case NM_STATE_LOCKED:
+
+ pinst->u.octphy.trx_locked = 1;
+
+ /* Stop heartbeat check */
+ osmo_timer_del(&fl1h->alive_timer);
+
+ bts_model_trx_deact_rf(trx);
+
+ /* Close TRX */
+ rc = bts_model_trx_close(trx);
+ if (rc != 0) {
+ LOGP(DL1C, LOGL_ERROR,
+ "Cannot close TRX %d, it is already closed.\n",
+ trx->nr);
+ }
+ break;
+
+ case NM_STATE_UNLOCKED:
+
+ if (pinst->u.octphy.trx_locked) {
+ pinst->u.octphy.trx_locked = 0;
+ l1if_activate_rf(trx, 1);
+ }
+
+ break;
+
+ default:
+ break;
+ }
+
+ mo->procedure_pending = 0;
+ break;
+
+ default:
+ /* blindly accept all state changes */
+ break;
+ }
+
mo->nm_state.administrative = adm_state;
return oml_mo_statechg_ack(mo);
}