ctrl: Add ms power

This new command allows to control MS power level for a specific
logical channel using net.btsN.trxM.tsI.lchanL.ms-power

This patch also adds a lchan node to the ctrl interface.

Depends: libosmocore.git Ibf2786f668ee7e4f5b6a9ef43f2141cd2d79b4e2
Change-Id: I6f556b66011be6126d6bac31a14101ba37f81cc4
This commit is contained in:
Matan Perelman 2024-01-30 17:06:37 +02:00
parent 6b6714ba13
commit d399e0c927
5 changed files with 96 additions and 0 deletions

View File

@ -12,6 +12,7 @@ struct ctrl_handle *bsc_controlif_setup(struct gsm_network *net, uint16_t port);
int bsc_bts_ctrl_cmds_install(void);
int bsc_bts_trx_ctrl_cmds_install(void);
int bsc_bts_trx_ts_ctrl_cmds_install(void);
int bsc_bts_trx_ts_lchan_ctrl_cmds_install(void);
void ctrl_generate_bts_location_state_trap(struct gsm_bts *bts, struct bsc_msc_data *msc);
void osmo_bsc_send_trap(struct ctrl_cmd *cmd, struct bsc_msc_data *msc_data);

View File

@ -47,6 +47,7 @@ libbsc_la_SOURCES = \
bts_trx.c \
bts_trx_ctrl.c \
bts_trx_ts_ctrl.c \
bts_trx_ts_lchan_ctrl.c \
bts_ericsson_rbs2000.c \
bts_init.c \
bts_ipaccess_nanobts.c \

View File

@ -43,6 +43,7 @@ static int bsc_ctrl_node_lookup(void *data, vector vline, int *node_type,
struct gsm_bts *bts = NULL;
struct gsm_bts_trx *trx = NULL;
struct gsm_bts_trx_ts *ts = NULL;
struct gsm_lchan *lchan = NULL;
struct bsc_msc_data *msc = NULL;
char *token = vector_slot(vline, *i);
long num;
@ -89,6 +90,20 @@ static int bsc_ctrl_node_lookup(void *data, vector vline, int *node_type,
goto err_missing;
*node_data = ts;
*node_type = CTRL_NODE_TS;
} else if (!strcmp(token, "lchan")) {
if (*node_type != CTRL_NODE_TS || !*node_data)
goto err_missing;
ts = *node_data;
(*i)++;
if (!ctrl_parse_get_num(vline, *i, &num))
goto err_index;
if ((num >= 0) && (num < TS_MAX_LCHAN))
lchan = &ts->lchan[num];
if (!lchan)
goto err_missing;
*node_data = lchan;
*node_type = CTRL_NODE_LCHAN;
} else if (!strcmp(token, "msc")) {
if (*node_type != CTRL_NODE_ROOT || !net)
goto err_missing;

View File

@ -102,5 +102,7 @@ int bsc_bts_trx_ts_ctrl_cmds_install(void)
rc |= ctrl_cmd_install(CTRL_NODE_TS, &cmd_ts_hopping_arfcn_add);
rc |= ctrl_cmd_install(CTRL_NODE_TS, &cmd_ts_hopping_arfcn_del);
rc |= bsc_bts_trx_ts_lchan_ctrl_cmds_install();
return rc;
}

View File

@ -0,0 +1,77 @@
/*
* Copyright (C) 2024 by sysmocom s.f.m.c. GmbH
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include <osmocom/ctrl/control_cmd.h>
#include <osmocom/bsc/ctrl.h>
#include <osmocom/bsc/bts.h>
#include <osmocom/bsc/system_information.h>
#include <osmocom/bsc/abis_rsl.h>
static int verify_lchan_ms_power(struct ctrl_cmd *cmd, const char *value, void *_data)
{
int ms_power = atoi(cmd->value);
if (ms_power < 0 || ms_power > 40) {
cmd->reply = "Value is out of range";
return 1;
}
return 0;
}
/* power control management: Get lchan's ms power in dBm
* format: bts.<0-255>.trx.<0-255>.ts.<0-8>.lchan.<0-8>.ms-power */
static int get_lchan_ms_power(struct ctrl_cmd *cmd, void *data)
{
struct gsm_lchan *lchan = cmd->node;
cmd->reply = talloc_asprintf(cmd, "%u", ms_pwr_dbm(lchan->ts->trx->bts->band, lchan->ms_power));
if (!cmd->reply) {
cmd->reply = "OOM";
return CTRL_CMD_ERROR;
}
return CTRL_CMD_REPLY;
}
/* power control management: Set lchan's ms power in dBm.
* For static ms power control it will change the ms tx power.
* For dynamic ms power control it will limit the maximum power level.
* format: bts.<0-255>.trx.<0-255>.ts.<0-8>.lchan.<0-8>.ms-power <ms power>
* ms power is in range 0..40 */
static int set_lchan_ms_power(struct ctrl_cmd *cmd, void *data)
{
struct gsm_lchan *lchan = cmd->node;
lchan->ms_power = ms_pwr_ctl_lvl(lchan->ts->trx->bts->band, atoi(cmd->value));
rsl_chan_ms_power_ctrl(lchan);
cmd->reply = "OK";
return CTRL_CMD_REPLY;
}
CTRL_CMD_DEFINE(lchan_ms_power, "ms-power");
int bsc_bts_trx_ts_lchan_ctrl_cmds_install(void)
{
int rc = 0;
rc |= ctrl_cmd_install(CTRL_NODE_LCHAN, &cmd_lchan_ms_power);
return rc;
}