fixeria submitted this change.

View Change


Approvals: pespin: Looks good to me, but someone else must approve Jenkins Builder: Verified laforge: Looks good to me, approved
gsm_bts_send_c0_power_red(): check if BTS is online first

... and print a proper error message instead of "not supported". We
don't know for sure whether it's supported before the BTS is connected.

Change-Id: I080aa7ef331b76918ae48d555eea6e4290c57120
Related: SYS#6435
---
M src/osmo-bsc/bsc_vty.c
M src/osmo-bsc/bts.c
M src/osmo-bsc/bts_ctrl.c
3 files changed, 31 insertions(+), 8 deletions(-)

diff --git a/src/osmo-bsc/bsc_vty.c b/src/osmo-bsc/bsc_vty.c
index f1bd7c4..34676a2 100644
--- a/src/osmo-bsc/bsc_vty.c
+++ b/src/osmo-bsc/bsc_vty.c
@@ -1426,18 +1426,22 @@
}

rc = gsm_bts_set_c0_power_red(bts, red);
- if (rc == -ENOTSUP) {
+ switch (rc) {
+ case 0: /* success */
+ return CMD_SUCCESS;
+ case -ENOTCONN:
+ vty_out(vty, "%% BTS%u is offline%s", bts_nr, VTY_NEWLINE);
+ return CMD_WARNING;
+ case -ENOTSUP:
vty_out(vty, "%% BCCH carrier power reduction operation mode "
"is not supported for BTS%u%s", bts_nr, VTY_NEWLINE);
return CMD_WARNING;
- } else if (rc != 0) {
+ default:
vty_out(vty, "%% Failed to %sable BCCH carrier power reduction "
"operation mode for BTS%u%s", red ? "en" : "dis",
bts_nr, VTY_NEWLINE);
return CMD_WARNING;
}
-
- return CMD_SUCCESS;
}

/* this command is now hidden, as it's a low-level debug hack, and people should
diff --git a/src/osmo-bsc/bts.c b/src/osmo-bsc/bts.c
index be0516d..1ef9cca 100644
--- a/src/osmo-bsc/bts.c
+++ b/src/osmo-bsc/bts.c
@@ -981,6 +981,8 @@
/* Send the given C0 power reduction value to the BTS */
int gsm_bts_send_c0_power_red(const struct gsm_bts *bts, const uint8_t red)
{
+ if (!bts_is_online(bts))
+ return -ENOTCONN;
if (!osmo_bts_has_feature(&bts->features, BTS_FEAT_BCCH_POWER_RED))
return -ENOTSUP;
if (bts->model->power_ctrl_send_c0_power_red == NULL)
diff --git a/src/osmo-bsc/bts_ctrl.c b/src/osmo-bsc/bts_ctrl.c
index a971fab..5ac1e0d 100644
--- a/src/osmo-bsc/bts_ctrl.c
+++ b/src/osmo-bsc/bts_ctrl.c
@@ -497,15 +497,19 @@
int rc;

rc = gsm_bts_set_c0_power_red(bts, red);
- if (rc == -ENOTSUP) {
+ switch (rc) {
+ case 0: /* success */
+ return get_bts_c0_power_red(cmd, data);
+ case -ENOTCONN:
+ cmd->reply = "BTS is offline";
+ return CTRL_CMD_ERROR;
+ case -ENOTSUP:
cmd->reply = "BCCH carrier power reduction is not supported";
return CTRL_CMD_ERROR;
- } else if (rc != 0) {
+ default:
cmd->reply = "Failed to enable BCCH carrier power reduction";
return CTRL_CMD_ERROR;
}
-
- return get_bts_c0_power_red(cmd, data);
}

CTRL_CMD_DEFINE(bts_c0_power_red, "c0-power-reduction");

To view, visit change 32541. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: I080aa7ef331b76918ae48d555eea6e4290c57120
Gerrit-Change-Number: 32541
Gerrit-PatchSet: 2
Gerrit-Owner: fixeria <vyanitskiy@sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy@sysmocom.de>
Gerrit-Reviewer: laforge <laforge@osmocom.org>
Gerrit-Reviewer: pespin <pespin@sysmocom.de>
Gerrit-MessageType: merged