[MERGED] openbsc[master]: Make TRX rf locking more visible

Harald Welte gerrit-no-reply at lists.osmocom.org
Mon Oct 23 17:53:49 UTC 2017


Harald Welte has submitted this change and it was merged.

Change subject: Make TRX rf locking more visible
......................................................................


Make TRX rf locking more visible

* log administrative state transitions
* log what's caused it
* while at it, mark boolean variable as such

Cherry-picked from osmo-bsc be356ed32fbd28dc8d1460371d9e47511b20ac63

Change-Id: I3e25a19fac4d0b4886d825c9876771b1f66efe58
Related: SYS#3864
---
M openbsc/include/openbsc/gsm_data.h
M openbsc/src/libbsc/abis_nm.c
M openbsc/src/libbsc/bsc_rf_ctrl.c
M openbsc/src/libbsc/bsc_vty.c
4 files changed, 12 insertions(+), 8 deletions(-)

Approvals:
  Max: Looks good to me, but someone else must approve
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/openbsc/include/openbsc/gsm_data.h b/openbsc/include/openbsc/gsm_data.h
index 4035b39..57fa301 100644
--- a/openbsc/include/openbsc/gsm_data.h
+++ b/openbsc/include/openbsc/gsm_data.h
@@ -578,7 +578,7 @@
 void set_ts_e1link(struct gsm_bts_trx_ts *ts, uint8_t e1_nr,
 		   uint8_t e1_ts, uint8_t e1_ts_ss);
 
-void gsm_trx_lock_rf(struct gsm_bts_trx *trx, int locked);
+void gsm_trx_lock_rf(struct gsm_bts_trx *trx, bool locked, const char *reason);
 bool gsm_btsmodel_has_feature(struct gsm_bts_model *model, enum gsm_bts_features feat);
 struct gsm_bts_trx *gsm_bts_trx_by_nr(struct gsm_bts *bts, int nr);
 int gsm_bts_trx_set_system_infos(struct gsm_bts_trx *trx);
diff --git a/openbsc/src/libbsc/abis_nm.c b/openbsc/src/libbsc/abis_nm.c
index cf20d7c..f24f6bf 100644
--- a/openbsc/src/libbsc/abis_nm.c
+++ b/openbsc/src/libbsc/abis_nm.c
@@ -2791,9 +2791,13 @@
 	*((uint16_t *)(buf + 5)) = htons(bts->cell_identity);
 }
 
-void gsm_trx_lock_rf(struct gsm_bts_trx *trx, int locked)
+void gsm_trx_lock_rf(struct gsm_bts_trx *trx, bool locked, const char *reason)
 {
-	int new_state = locked ? NM_STATE_LOCKED : NM_STATE_UNLOCKED;
+	uint8_t new_state = locked ? NM_STATE_LOCKED : NM_STATE_UNLOCKED;
+
+	LOGP(DNM, LOGL_NOTICE, "(bts=%d,trx=%d) Changing adm. state %s -> %s [%s]\n", trx->bts->nr, trx->nr,
+	     get_value_string(abis_nm_adm_state_names, trx->mo.nm_state.administrative),
+	     get_value_string(abis_nm_adm_state_names, new_state), reason);
 
 	trx->mo.nm_state.administrative = new_state;
 	if (!trx->bts || !trx->bts->oml_link)
diff --git a/openbsc/src/libbsc/bsc_rf_ctrl.c b/openbsc/src/libbsc/bsc_rf_ctrl.c
index b7b6fc8..0e28600 100644
--- a/openbsc/src/libbsc/bsc_rf_ctrl.c
+++ b/openbsc/src/libbsc/bsc_rf_ctrl.c
@@ -123,7 +123,7 @@
 	}
 }
 
-static int lock_each_trx(struct gsm_network *net, int lock)
+static int lock_each_trx(struct gsm_network *net, bool lock)
 {
 	struct gsm_bts *bts;
 
@@ -138,7 +138,7 @@
 		}
 
 		llist_for_each_entry(trx, &bts->trx_list, list) {
-			gsm_trx_lock_rf(trx, lock);
+			gsm_trx_lock_rf(trx, lock, "ctrl");
 		}
 	}
 
@@ -245,7 +245,7 @@
 
 static int switch_rf_off(struct osmo_bsc_rf *rf)
 {
-	lock_each_trx(rf->gsm_network, 1);
+	lock_each_trx(rf->gsm_network, true);
 	send_signal(rf, S_RF_OFF);
 
 	return 0;
@@ -289,7 +289,7 @@
 	case RF_CMD_ON:
 		rf->last_state_command = "RF Direct On";
 		osmo_timer_del(&rf->grace_timeout);
-		lock_each_trx(rf->gsm_network, 0);
+		lock_each_trx(rf->gsm_network, false);
 		send_signal(rf, S_RF_ON);
 		osmo_timer_schedule(&rf->rf_check, 3, 0);
 		break;
diff --git a/openbsc/src/libbsc/bsc_vty.c b/openbsc/src/libbsc/bsc_vty.c
index f50ebd8..5fb1c5d 100644
--- a/openbsc/src/libbsc/bsc_vty.c
+++ b/openbsc/src/libbsc/bsc_vty.c
@@ -3562,7 +3562,7 @@
 	int locked = atoi(argv[0]);
 	struct gsm_bts_trx *trx = vty->index;
 
-	gsm_trx_lock_rf(trx, locked);
+	gsm_trx_lock_rf(trx, locked, "vty");
 	return CMD_SUCCESS;
 }
 

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I3e25a19fac4d0b4886d825c9876771b1f66efe58
Gerrit-PatchSet: 2
Gerrit-Project: openbsc
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol <pespin at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max <msuraev at sysmocom.de>


More information about the gerrit-log mailing list