aboutsummaryrefslogtreecommitdiffstats
path: root/src/osmo-bts-oc2g/oc2gbts_vty.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/osmo-bts-oc2g/oc2gbts_vty.c')
-rw-r--r--src/osmo-bts-oc2g/oc2gbts_vty.c96
1 files changed, 28 insertions, 68 deletions
diff --git a/src/osmo-bts-oc2g/oc2gbts_vty.c b/src/osmo-bts-oc2g/oc2gbts_vty.c
index 1f092dde..051528ab 100644
--- a/src/osmo-bts-oc2g/oc2gbts_vty.c
+++ b/src/osmo-bts-oc2g/oc2gbts_vty.c
@@ -2,7 +2,7 @@
/* Copyright (C) 2015 by Yves Godin <support@nuranwireless.com>
* Copyright (C) 2016 by Harald Welte <laforge@gnumonks.org>
- *
+ *
* Based on sysmoBTS:
* (C) 2011 by Harald Welte <laforge@gnumonks.org>
* (C) 2012,2013 by Holger Hans Peter Freyther
@@ -47,6 +47,7 @@
#include <osmo-bts/signal.h>
#include <osmo-bts/oml.h>
#include <osmo-bts/bts.h>
+#include <osmo-bts/bts_sm.h>
#include <osmo-bts/gsm_data.h>
#include <osmo-bts/phy_link.h>
@@ -69,8 +70,6 @@ extern int rsl_tx_preproc_meas_res(struct gsm_lchan *lchan);
TRX_STR
#define DSP_TRACE_F_STR "DSP Trace Flag\n"
-static struct gsm_bts *vty_bts;
-
static const struct value_string oc2g_pedestal_mode_strs[] = {
{ OC2G_PEDESTAL_OFF, "off" },
{ OC2G_PEDESTAL_ON, "on" },
@@ -113,7 +112,7 @@ DEFUN(cfg_phy_dsp_trace_f, cfg_phy_dsp_trace_f_cmd,
struct phy_instance *pinst = vty->index;
unsigned int flag;
- flag = get_string_value(oc2gbts_tracef_names, argv[1]);
+ flag = get_string_value(oc2gbts_tracef_names, argv[0]);
pinst->u.oc2g.dsp_trace_f |= flag;
return CMD_SUCCESS;
@@ -125,7 +124,7 @@ DEFUN(cfg_phy_no_dsp_trace_f, cfg_phy_no_dsp_trace_f_cmd,
struct phy_instance *pinst = vty->index;
unsigned int flag;
- flag = get_string_value(oc2gbts_tracef_names, argv[1]);
+ flag = get_string_value(oc2gbts_tracef_names, argv[0]);
pinst->u.oc2g.dsp_trace_f &= ~flag;
return CMD_SUCCESS;
@@ -135,11 +134,11 @@ DEFUN(cfg_phy_no_dsp_trace_f, cfg_phy_no_dsp_trace_f_cmd,
/* runtime */
DEFUN(show_dsp_trace_f, show_dsp_trace_f_cmd,
- "show trx <0-0> dsp-trace-flags",
+ "show dsp-trace-flags trx <0-0>",
SHOW_TRX_STR "Display the current setting of the DSP trace flags")
{
int trx_nr = atoi(argv[0]);
- struct gsm_bts_trx *trx = gsm_bts_trx_num(vty_bts, trx_nr);
+ struct gsm_bts_trx *trx = gsm_bts_trx_num(g_bts, trx_nr);
struct oc2gl1_hdl *fl1h;
int i;
@@ -261,7 +260,7 @@ DEFUN(activate_lchan, activate_lchan_cmd,
int trx_nr = atoi(argv[0]);
int ts_nr = atoi(argv[1]);
int lchan_nr = atoi(argv[3]);
- struct gsm_bts_trx *trx = gsm_bts_trx_num(vty_bts, trx_nr);
+ struct gsm_bts_trx *trx = gsm_bts_trx_num(g_bts, trx_nr);
struct gsm_bts_trx_ts *ts = &trx->ts[ts_nr];
struct gsm_lchan *lchan = &ts->lchan[lchan_nr];
@@ -282,9 +281,9 @@ DEFUN(set_tx_power, set_tx_power_cmd,
{
int trx_nr = atoi(argv[0]);
int power = atoi(argv[1]);
- struct gsm_bts_trx *trx = gsm_bts_trx_num(vty_bts, trx_nr);
+ struct gsm_bts_trx *trx = gsm_bts_trx_num(g_bts, trx_nr);
- power_ramp_start(trx, to_mdB(power), 1);
+ power_ramp_start(trx, to_mdB(power), 1, NULL);
return CMD_SUCCESS;
}
@@ -299,7 +298,7 @@ DEFUN(loopback, loopback_cmd,
int trx_nr = atoi(argv[0]);
int ts_nr = atoi(argv[1]);
int lchan_nr = atoi(argv[2]);
- struct gsm_bts_trx *trx = gsm_bts_trx_num(vty_bts, trx_nr);
+ struct gsm_bts_trx *trx = gsm_bts_trx_num(g_bts, trx_nr);
struct gsm_bts_trx_ts *ts = &trx->ts[ts_nr];
struct gsm_lchan *lchan = &ts->lchan[lchan_nr];
@@ -318,7 +317,7 @@ DEFUN(no_loopback, no_loopback_cmd,
int trx_nr = atoi(argv[0]);
int ts_nr = atoi(argv[1]);
int lchan_nr = atoi(argv[2]);
- struct gsm_bts_trx *trx = gsm_bts_trx_num(vty_bts, trx_nr);
+ struct gsm_bts_trx *trx = gsm_bts_trx_num(g_bts, trx_nr);
struct gsm_bts_trx_ts *ts = &trx->ts[ts_nr];
struct gsm_lchan *lchan = &ts->lchan[lchan_nr];
@@ -335,12 +334,6 @@ DEFUN(cfg_trx_nominal_power, cfg_trx_nominal_power_cmd,
int nominal_power = atoi(argv[0]);
struct gsm_bts_trx *trx = vty->index;
- if (( nominal_power > 25 ) || ( nominal_power < 0 )) {
- vty_out(vty, "Nominal Tx power level must be between 0 and 25 dBm (%d) %s",
- nominal_power, VTY_NEWLINE);
- return CMD_WARNING;
- }
-
trx->nominal_power = nominal_power;
trx->power_params.trx_p_max_out_mdBm = to_mdB(nominal_power);
@@ -354,12 +347,6 @@ DEFUN(cfg_phy_max_cell_size, cfg_phy_max_cell_size_cmd,
struct phy_instance *pinst = vty->index;
int cell_size = (uint8_t)atoi(argv[0]);
- if (( cell_size > 166 ) || ( cell_size < 0 )) {
- vty_out(vty, "Max cell size must be between 0 and 166 qbits (%d) %s",
- cell_size, VTY_NEWLINE);
- return CMD_WARNING;
- }
-
pinst->u.oc2g.max_cell_size = (uint8_t)cell_size;
return CMD_SUCCESS;
}
@@ -372,10 +359,7 @@ DEFUN(cfg_phy_pedestal_mode, cfg_phy_pedestal_mode_cmd,
struct phy_instance *pinst = vty->index;
int val = get_string_value(oc2g_pedestal_mode_strs, argv[0]);
- if((val < OC2G_PEDESTAL_OFF) || (val > OC2G_PEDESTAL_ON)) {
- vty_out(vty, "Invalid unused time-slot transmission mode %d%s", val, VTY_NEWLINE);
- return CMD_WARNING;
- }
+ OSMO_ASSERT(val != -EINVAL);
pinst->u.oc2g.pedestal_mode = (uint8_t)val;
return CMD_SUCCESS;
@@ -388,12 +372,6 @@ DEFUN(cfg_phy_dsp_alive_timer, cfg_phy_dsp_alive_timer_cmd,
struct phy_instance *pinst = vty->index;
uint8_t period = (uint8_t)atoi(argv[0]);
- if (( period > 60 ) || ( period < 0 )) {
- vty_out(vty, "DSP heart beat alive timer period must be between 0 and 60 seconds (%d) %s",
- period, VTY_NEWLINE);
- return CMD_WARNING;
- }
-
pinst->u.oc2g.dsp_alive_period = period;
return CMD_SUCCESS;
}
@@ -405,10 +383,7 @@ DEFUN(cfg_phy_auto_tx_pwr_adj, cfg_phy_auto_tx_pwr_adj_cmd,
struct phy_instance *pinst = vty->index;
int val = get_string_value(oc2g_auto_adj_pwr_strs, argv[0]);
- if((val < OC2G_TX_PWR_ADJ_NONE) || (val > OC2G_TX_PWR_ADJ_AUTO)) {
- vty_out(vty, "Invalid output power adjustment mode %d%s", val, VTY_NEWLINE);
- return CMD_WARNING;
- }
+ OSMO_ASSERT(val != -EINVAL);
pinst->u.oc2g.tx_pwr_adj_mode = (uint8_t)val;
return CMD_SUCCESS;
@@ -421,12 +396,6 @@ DEFUN(cfg_phy_tx_red_pwr_8psk, cfg_phy_tx_red_pwr_8psk_cmd,
struct phy_instance *pinst = vty->index;
int val = atoi(argv[0]);
- if ((val > 40) || (val < 0)) {
- vty_out(vty, "Reduction Tx power level must be between 0 and 40 dB (%d) %s",
- val, VTY_NEWLINE);
- return CMD_WARNING;
- }
-
pinst->u.oc2g.tx_pwr_red_8psk = (uint8_t)val;
return CMD_SUCCESS;
}
@@ -438,19 +407,12 @@ DEFUN(cfg_phy_c0_idle_red_pwr, cfg_phy_c0_idle_red_pwr_cmd,
struct phy_instance *pinst = vty->index;
int val = atoi(argv[0]);
- if ((val > 40) || (val < 0)) {
- vty_out(vty, "Reduction Tx power level must be between 0 and 40 dB (%d) %s",
- val, VTY_NEWLINE);
- return CMD_WARNING;
- }
-
pinst->u.oc2g.tx_c0_idle_pwr_red = (uint8_t)val;
return CMD_SUCCESS;
}
DEFUN(trigger_ho_cause, trigger_ho_cause_cmd, "HIDDEN", TRX_STR)
{
- struct gsm_network *net = gsmnet_from_vty(vty);
struct gsm_bts *bts;
struct gsm_bts_trx *trx;
struct gsm_bts_trx_ts *ts;
@@ -460,7 +422,7 @@ DEFUN(trigger_ho_cause, trigger_ho_cause_cmd, "HIDDEN", TRX_STR)
/* uint8_t old_ho_cause; */
/* get BTS pointer */
- bts = gsm_bts_num(net, 0);
+ bts = gsm_bts_num(g_bts_sm, 0);
if (!bts) {
vty_out(vty, "Can not get BTS node %s", VTY_NEWLINE);
return CMD_WARNING;
@@ -541,7 +503,7 @@ DEFUN(cfg_bts_rtp_drift_threshold, cfg_bts_rtp_drift_threshold_cmd,
}
*/
-void bts_model_config_write_bts(struct vty *vty, struct gsm_bts *bts)
+void bts_model_config_write_bts(struct vty *vty, const struct gsm_bts *bts)
{
/* TODO(oramadan) MERGE
struct gsm_bts_role_bts *btsb = bts_role_bts(bts);
@@ -555,16 +517,16 @@ void bts_model_config_write_bts(struct vty *vty, struct gsm_bts *bts)
}
-void bts_model_config_write_trx(struct vty *vty, struct gsm_bts_trx *trx)
+void bts_model_config_write_trx(struct vty *vty, const struct gsm_bts_trx *trx)
{
vty_out(vty, " nominal-tx-power %d%s", trx->nominal_power,VTY_NEWLINE);
}
-void bts_model_config_write_phy(struct vty *vty, struct phy_link *plink)
+void bts_model_config_write_phy(struct vty *vty, const struct phy_link *plink)
{
}
-void bts_model_config_write_phy_inst(struct vty *vty, struct phy_instance *pinst)
+void bts_model_config_write_phy_inst(struct vty *vty, const struct phy_instance *pinst)
{
int i;
@@ -599,44 +561,42 @@ void bts_model_config_write_phy_inst(struct vty *vty, struct phy_instance *pinst
pinst->u.oc2g.tx_c0_idle_pwr_red, VTY_NEWLINE);
}
-int bts_model_vty_init(struct gsm_bts *bts)
+int bts_model_vty_init(void *ctx)
{
- vty_bts = bts;
-
/* runtime-patch the command strings with debug levels */
- dsp_trace_f_cmd.string = vty_cmd_string_from_valstr(bts, oc2gbts_tracef_names,
+ dsp_trace_f_cmd.string = vty_cmd_string_from_valstr(ctx, oc2gbts_tracef_names,
"phy <0-1> dsp-trace-flag (",
"|",")", VTY_DO_LOWER);
- dsp_trace_f_cmd.doc = vty_cmd_string_from_valstr(bts, oc2gbts_tracef_docs,
+ dsp_trace_f_cmd.doc = vty_cmd_string_from_valstr(ctx, oc2gbts_tracef_docs,
TRX_STR DSP_TRACE_F_STR,
"\n", "", 0);
- no_dsp_trace_f_cmd.string = vty_cmd_string_from_valstr(bts, oc2gbts_tracef_names,
+ no_dsp_trace_f_cmd.string = vty_cmd_string_from_valstr(ctx, oc2gbts_tracef_names,
"no phy <0-1> dsp-trace-flag (",
"|",")", VTY_DO_LOWER);
- no_dsp_trace_f_cmd.doc = vty_cmd_string_from_valstr(bts, oc2gbts_tracef_docs,
+ no_dsp_trace_f_cmd.doc = vty_cmd_string_from_valstr(ctx, oc2gbts_tracef_docs,
NO_STR TRX_STR DSP_TRACE_F_STR,
"\n", "", 0);
- cfg_phy_dsp_trace_f_cmd.string = vty_cmd_string_from_valstr(bts,
+ cfg_phy_dsp_trace_f_cmd.string = vty_cmd_string_from_valstr(ctx,
oc2gbts_tracef_names,
"dsp-trace-flag (",
"|",")", VTY_DO_LOWER);
- cfg_phy_dsp_trace_f_cmd.doc = vty_cmd_string_from_valstr(bts,
+ cfg_phy_dsp_trace_f_cmd.doc = vty_cmd_string_from_valstr(ctx,
oc2gbts_tracef_docs,
DSP_TRACE_F_STR,
"\n", "", 0);
- cfg_phy_no_dsp_trace_f_cmd.string = vty_cmd_string_from_valstr(bts,
+ cfg_phy_no_dsp_trace_f_cmd.string = vty_cmd_string_from_valstr(ctx,
oc2gbts_tracef_names,
"no dsp-trace-flag (",
"|",")", VTY_DO_LOWER);
- cfg_phy_no_dsp_trace_f_cmd.doc = vty_cmd_string_from_valstr(bts,
+ cfg_phy_no_dsp_trace_f_cmd.doc = vty_cmd_string_from_valstr(ctx,
oc2gbts_tracef_docs,
NO_STR DSP_TRACE_F_STR,
"\n", "", 0);
- trigger_ho_cause_cmd.string = vty_cmd_string_from_valstr(bts,
+ trigger_ho_cause_cmd.string = vty_cmd_string_from_valstr(ctx,
oc2gbts_rsl_ho_causes,
"trigger-ho-cause trx <0-1> ts <0-7> lchan <0-1> cause (",
"|",")", VTY_DO_LOWER);