From 763f8ed7713077d9c1d8383aa2ac39cf21a7e8a0 Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Tue, 7 Sep 2021 14:43:25 +0200 Subject: add CTRL bts.N.trx.M.rf_locked (RW) Add per-TRX command to lock/unlock single TRX. (Besides the global root-node rf_locked command setting the global RF policy.) Corresponds to VTY command: 'bts N' / 'trx N' / 'rf_locked (0|1)'. Related: SYS#5542 Related: I2bb5096732f75a7341c7e83951e63c5a2038b469 (osmo-ttcn3-hacks) Depends: I4dac826aab00bc1780a5258b6b55d34ce7d50c60 (libosmocore) Change-Id: Ie46fd730797b64fb185d705c3507e36f5f23ef4b --- TODO-RELEASE | 1 + src/osmo-bsc/bsc_ctrl_commands.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/TODO-RELEASE b/TODO-RELEASE index 8585c7bbc..90ec16bba 100644 --- a/TODO-RELEASE +++ b/TODO-RELEASE @@ -14,3 +14,4 @@ libosmo-mgcp-client >1.8.0 need osmo_mgcpc_ep_ci_get_remote_rtp_info() libosmovty >1.5.1 needs vty_read_config_filep() libosmosgsm >1.5.1 needs GSM_PCHAN_OSMO_DYN libosmocore >1.5.1 RSL_IPAC_EIE_OSMO*, struct osmo_preproc_* +libosmocore >1.5.1 needs osmo_str_to_int() diff --git a/src/osmo-bsc/bsc_ctrl_commands.c b/src/osmo-bsc/bsc_ctrl_commands.c index 3b8125a78..c7547b0ff 100644 --- a/src/osmo-bsc/bsc_ctrl_commands.c +++ b/src/osmo-bsc/bsc_ctrl_commands.c @@ -536,6 +536,37 @@ static int verify_net_rf_lock(struct ctrl_cmd *cmd, const char *value, void *dat } CTRL_CMD_DEFINE(net_rf_lock, "rf_locked"); +static int get_trx_rf_locked(struct ctrl_cmd *cmd, void *data) +{ + struct gsm_bts_trx *trx = cmd->node; + /* Return rf_locked = 1 only if it is explicitly locked. If it is in shutdown or null state, do not "trick" the + * caller into thinking that sending "rf_locked 0" is necessary to bring the TRX up. */ + cmd->reply = (trx->mo.nm_state.administrative == NM_STATE_LOCKED) ? "1" : "0"; + return CTRL_CMD_REPLY; +} + +static int set_trx_rf_locked(struct ctrl_cmd *cmd, void *data) +{ + struct gsm_bts_trx *trx = cmd->node; + int locked; + if (osmo_str_to_int(&locked, cmd->value, 10, 0, 1)) { + cmd->reply = "Invalid value"; + return CTRL_CMD_ERROR; + } + + gsm_trx_lock_rf(trx, locked, "ctrl"); + + /* Let's not assume the nm FSM has already switched its state, just return the intended rf_locked value. */ + cmd->reply = locked ? "1" : "0"; + return CTRL_CMD_REPLY; +} + +static int verify_trx_rf_locked(struct ctrl_cmd *cmd, const char *value, void *data) +{ + return osmo_str_to_int(NULL, value, 10, 0, 1); +} +CTRL_CMD_DEFINE(trx_rf_locked, "rf_locked"); + static int get_net_bts_num(struct ctrl_cmd *cmd, void *data) { struct gsm_network *net = cmd->node; @@ -661,6 +692,7 @@ int bsc_base_ctrl_cmds_install(void) rc |= ctrl_cmd_install(CTRL_NODE_TRX, &cmd_trx_max_power); rc |= ctrl_cmd_install(CTRL_NODE_TRX, &cmd_trx_arfcn); + rc |= ctrl_cmd_install(CTRL_NODE_TRX, &cmd_trx_rf_locked); return rc; } -- cgit v1.2.3