[MERGED] osmo-bts[master]: octphy: Improve OML ADM state handling

Harald Welte gerrit-no-reply at lists.osmocom.org
Wed Feb 1 19:16:19 UTC 2017


Harald Welte has submitted this change and it was merged.

Change subject: octphy: Improve OML ADM state handling
......................................................................


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
---
M include/osmo-bts/phy_link.h
M src/osmo-bts-octphy/l1_oml.c
2 files changed, 61 insertions(+), 2 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/include/osmo-bts/phy_link.h b/include/osmo-bts/phy_link.h
index 1f8450b..a7963d0 100644
--- a/include/osmo-bts/phy_link.h
+++ b/include/osmo-bts/phy_link.h
@@ -105,6 +105,8 @@
 		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 08516ef..a68169e 100644
--- a/src/osmo-bts-octphy/l1_oml.c
+++ b/src/osmo-bts-octphy/l1_oml.c
@@ -1539,8 +1539,65 @@
 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);
 }

-- 
To view, visit https://gerrit.osmocom.org/906
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I034114beca95210169429d8ac1eb8648df12fc6c
Gerrit-PatchSet: 14
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: dexter <pmaier at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>


More information about the gerrit-log mailing list