Change in osmo-bts[master]: vty: call bts_model_vty_init() from bts_vty_init()

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

fixeria gerrit-no-reply at lists.osmocom.org
Mon Nov 2 18:08:24 UTC 2020


fixeria has submitted this change. ( https://gerrit.osmocom.org/c/osmo-bts/+/21011 )

Change subject: vty: call bts_model_vty_init() from bts_vty_init()
......................................................................

vty: call bts_model_vty_init() from bts_vty_init()

Similar to bts_vty_init(), BTS specific bts_model_vty_init()
requires a pointer to 'struct gsm_bts'.  Not only it's used
as a parent talloc context, but also stored locally, so then
it can be used by some VTY commands.

Let's expose the global 'struct gsm_bts' from main, and pass
the application's talloc context like was done in [1].

This finally makes the BTS model specific options appear in
the automatically generated VTY reference (--vty-ref-xml).

[1] Ic356a950da85de02c82e9882a5fbadaaa6929680

Change-Id: Iee7fee6747dd1e7c0af36f9b27326f651ae37aaf
Related: SYS#4937, OS#3036
---
M include/osmo-bts/bts_model.h
M include/osmo-bts/vty.h
M src/common/main.c
M src/common/vty.c
M src/osmo-bts-litecell15/lc15bts_vty.c
M src/osmo-bts-oc2g/oc2gbts_vty.c
M src/osmo-bts-octphy/octphy_vty.c
M src/osmo-bts-sysmo/sysmobts_vty.c
M src/osmo-bts-trx/trx_vty.c
M src/osmo-bts-virtual/virtualbts_vty.c
10 files changed, 67 insertions(+), 89 deletions(-)

Approvals:
  laforge: Looks good to me, but someone else must approve
  pespin: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/include/osmo-bts/bts_model.h b/include/osmo-bts/bts_model.h
index 568ff00..ef93fda 100644
--- a/include/osmo-bts/bts_model.h
+++ b/include/osmo-bts/bts_model.h
@@ -34,7 +34,7 @@
 /* Implementation should call bts_model_trx_close_cb when done */
 void bts_model_trx_close(struct gsm_bts_trx *trx);
 
-int bts_model_vty_init(struct gsm_bts *bts);
+int bts_model_vty_init(void *ctx);
 
 void bts_model_config_write_bts(struct vty *vty, const struct gsm_bts *bts);
 void bts_model_config_write_trx(struct vty *vty, const struct gsm_bts_trx *trx);
diff --git a/include/osmo-bts/vty.h b/include/osmo-bts/vty.h
index c9840d1..c815c85 100644
--- a/include/osmo-bts/vty.h
+++ b/include/osmo-bts/vty.h
@@ -27,6 +27,7 @@
 struct gsm_network *gsmnet_from_vty(struct vty *v);
 
 extern struct vty_app_info bts_vty_info;
+extern struct gsm_bts *g_bts;
 
 enum bts_vty_cmd_attr {
 	BTS_VTY_ATTR_NEW_LCHAN,
diff --git a/src/common/main.c b/src/common/main.c
index 67aeff3..102bf88 100644
--- a/src/common/main.c
+++ b/src/common/main.c
@@ -211,7 +211,8 @@
 	}
 }
 
-static struct gsm_bts *bts;
+/* FIXME: remove this once we add multi-BTS support */
+struct gsm_bts *g_bts = NULL;
 
 static void signal_handler(int signal)
 {
@@ -221,10 +222,10 @@
 	case SIGINT:
 	case SIGTERM:
 		if (!quit) {
-			oml_tx_failure_event_rep(&bts->mo,
+			oml_tx_failure_event_rep(&g_bts->mo,
 						 NM_SEVER_CRITICAL, OSMO_EVT_CRIT_PROC_STOP,
 						 "BTS: SIGINT received -> shutdown");
-			bts_shutdown(bts, "SIGINT");
+			bts_shutdown(g_bts, "SIGINT");
 		}
 		quit++;
 		break;
@@ -288,8 +289,8 @@
 
 	handle_options(argc, argv);
 
-	bts = gsm_bts_alloc(tall_bts_ctx, 0);
-	if (!bts) {
+	g_bts = gsm_bts_alloc(tall_bts_ctx, 0);
+	if (!g_bts) {
 		fprintf(stderr, "Failed to create BTS structure\n");
 		exit(1);
 	}
@@ -317,12 +318,12 @@
 		gsmtap_source_add_sink(gsmtap);
 	}
 
-	if (bts_init(bts) < 0) {
+	if (bts_init(g_bts) < 0) {
 		fprintf(stderr, "unable to open bts\n");
 		exit(1);
 	}
 
-	abis_init(bts);
+	abis_init(g_bts);
 
 	rc = vty_read_config_file(config_file, NULL);
 	if (rc < 0) {
@@ -336,7 +337,7 @@
 		exit(1);
 	}
 
-	llist_for_each_entry(trx, &bts->trx_list, list) {
+	llist_for_each_entry(trx, &g_bts->trx_list, list) {
 		if (!trx->role_bts.l1h) {
 			fprintf(stderr, "TRX %u has no associated PHY instance\n",
 				trx->nr);
@@ -346,7 +347,7 @@
 
 	write_pid_file("osmo-bts");
 
-	bts_controlif_setup(bts, ctrl_vty_get_bind_addr(), OSMO_CTRL_PORT_BTS);
+	bts_controlif_setup(g_bts, ctrl_vty_get_bind_addr(), OSMO_CTRL_PORT_BTS);
 
 	rc = telnet_init_dynif(tall_bts_ctx, NULL, vty_get_bind_addr(),
 			       g_vty_port_num);
@@ -355,7 +356,7 @@
 		exit(1);
 	}
 
-	if (pcu_sock_init(bts->pcu.sock_path)) {
+	if (pcu_sock_init(g_bts->pcu.sock_path)) {
 		fprintf(stderr, "PCU L1 socket failed\n");
 		exit(1);
 	}
@@ -367,12 +368,12 @@
 	signal(SIGUSR2, &signal_handler);
 	osmo_init_ignore_signals();
 
-	if (!bts->bsc_oml_host) {
+	if (!g_bts->bsc_oml_host) {
 		fprintf(stderr, "Cannot start BTS without knowing BSC OML IP\n");
 		exit(1);
 	}
 
-	line = abis_open(bts, bts->bsc_oml_host, "sysmoBTS");
+	line = abis_open(g_bts, g_bts->bsc_oml_host, "sysmoBTS");
 	if (!line) {
 		fprintf(stderr, "unable to connect to BSC\n");
 		exit(2);
diff --git a/src/common/vty.c b/src/common/vty.c
index 7126458..7baddef 100644
--- a/src/common/vty.c
+++ b/src/common/vty.c
@@ -1921,5 +1921,6 @@
 
 	install_node(&phy_inst_node, config_write_dummy);
 
-	return 0;
+	/* Install variant-specific VTY options */
+	return bts_model_vty_init(ctx);
 }
diff --git a/src/osmo-bts-litecell15/lc15bts_vty.c b/src/osmo-bts-litecell15/lc15bts_vty.c
index 5308d1a..4a9d790 100644
--- a/src/osmo-bts-litecell15/lc15bts_vty.c
+++ b/src/osmo-bts-litecell15/lc15bts_vty.c
@@ -69,8 +69,6 @@
 	TRX_STR
 #define DSP_TRACE_F_STR		"DSP Trace Flag\n"
 
-static struct gsm_bts *vty_bts;
-
 static const struct value_string lc15_diversity_mode_strs[] = {
 	{ LC15_DIVERSITY_SISO_A, "siso-a" },
 	{ LC15_DIVERSITY_SISO_B, "siso-b" },
@@ -146,7 +144,7 @@
 	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 lc15l1_hdl *fl1h;
 	int i;
 
@@ -268,7 +266,7 @@
 	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];
 
@@ -289,7 +287,7 @@
 {
 	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, NULL);
 
@@ -306,7 +304,7 @@
 	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];
 
@@ -325,7 +323,7 @@
 	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];
 
@@ -565,39 +563,37 @@
 #endif
 }
 
-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, lc15bts_tracef_names,
+	dsp_trace_f_cmd.string = vty_cmd_string_from_valstr(ctx, lc15bts_tracef_names,
 						"phy <0-0> dsp-trace-flag (",
 						"|",")", VTY_DO_LOWER);
-	dsp_trace_f_cmd.doc = vty_cmd_string_from_valstr(bts, lc15bts_tracef_docs,
+	dsp_trace_f_cmd.doc = vty_cmd_string_from_valstr(ctx, lc15bts_tracef_docs,
 						TRX_STR DSP_TRACE_F_STR,
 						"\n", "", 0);
 
-	no_dsp_trace_f_cmd.string = vty_cmd_string_from_valstr(bts, lc15bts_tracef_names,
+	no_dsp_trace_f_cmd.string = vty_cmd_string_from_valstr(ctx, lc15bts_tracef_names,
 						"no phy <0-0> dsp-trace-flag (",
 						"|",")", VTY_DO_LOWER);
-	no_dsp_trace_f_cmd.doc = vty_cmd_string_from_valstr(bts, lc15bts_tracef_docs,
+	no_dsp_trace_f_cmd.doc = vty_cmd_string_from_valstr(ctx, lc15bts_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,
 						lc15bts_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,
 						lc15bts_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,
 						lc15bts_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,
 						lc15bts_tracef_docs,
 						NO_STR DSP_TRACE_F_STR,
 						"\n", "", 0);
diff --git a/src/osmo-bts-oc2g/oc2gbts_vty.c b/src/osmo-bts-oc2g/oc2gbts_vty.c
index c12d0bf..c3b2a31 100644
--- a/src/osmo-bts-oc2g/oc2gbts_vty.c
+++ b/src/osmo-bts-oc2g/oc2gbts_vty.c
@@ -69,8 +69,6 @@
 	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" },
@@ -139,7 +137,7 @@
 	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 +259,7 @@
 	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,7 +280,7 @@
 {
 	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, NULL);
 
@@ -299,7 +297,7 @@
 	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 +316,7 @@
 	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];
 
@@ -599,44 +597,42 @@
 			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);
diff --git a/src/osmo-bts-octphy/octphy_vty.c b/src/osmo-bts-octphy/octphy_vty.c
index 8b263fd..308252b 100644
--- a/src/osmo-bts-octphy/octphy_vty.c
+++ b/src/osmo-bts-octphy/octphy_vty.c
@@ -54,8 +54,6 @@
 
 #define OCT_STR	"OCTPHY Um interface\n"
 
-static struct gsm_bts *vty_bts;
-
 /* configuration */
 
 DEFUN(cfg_phy_hwaddr, cfg_phy_hwaddr_cmd,
@@ -437,10 +435,8 @@
 }
 
 
-int bts_model_vty_init(struct gsm_bts *bts)
+int bts_model_vty_init(void *ctx)
 {
-	vty_bts = bts;
-
 	install_element(PHY_NODE, &cfg_phy_hwaddr_cmd);
 	install_element(PHY_NODE, &cfg_phy_netdev_cmd);
 	install_element(PHY_NODE, &cfg_phy_rf_port_idx_cmd);
diff --git a/src/osmo-bts-sysmo/sysmobts_vty.c b/src/osmo-bts-sysmo/sysmobts_vty.c
index b613031..f575884 100644
--- a/src/osmo-bts-sysmo/sysmobts_vty.c
+++ b/src/osmo-bts-sysmo/sysmobts_vty.c
@@ -60,8 +60,6 @@
 	TRX_STR
 #define DSP_TRACE_F_STR		"DSP Trace Flag\n"
 
-static struct gsm_bts *vty_bts;
-
 /* configuration */
 
 DEFUN(cfg_phy_clkcal_eeprom, cfg_phy_clkcal_eeprom_cmd,
@@ -221,7 +219,7 @@
 	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 femtol1_hdl *fl1h;
 	int i;
 
@@ -341,7 +339,7 @@
 	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];
 
@@ -361,7 +359,7 @@
 {
 	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, NULL);
 
@@ -374,7 +372,7 @@
       "RF Clock Information\n" "Reset the counter\n")
 {
 	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 femtol1_hdl *fl1h = trx_femtol1_hdl(trx);
 
 	l1if_rf_clock_info_reset(fl1h);
@@ -387,7 +385,7 @@
       "RF Clock Information\n" "Apply\n")
 {
 	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 femtol1_hdl *fl1h = trx_femtol1_hdl(trx);
 
 	l1if_rf_clock_info_correct(fl1h);
@@ -404,7 +402,7 @@
 	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];
 
@@ -423,7 +421,7 @@
 	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];
 
@@ -475,39 +473,37 @@
 					 pinst->u.sysmobts.clk_src), 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, femtobts_tracef_names,
+	dsp_trace_f_cmd.string = vty_cmd_string_from_valstr(ctx, femtobts_tracef_names,
 						"trx <0-0> dsp-trace-flag (",
 						"|",")", VTY_DO_LOWER);
-	dsp_trace_f_cmd.doc = vty_cmd_string_from_valstr(bts, femtobts_tracef_docs,
+	dsp_trace_f_cmd.doc = vty_cmd_string_from_valstr(ctx, femtobts_tracef_docs,
 						TRX_STR DSP_TRACE_F_STR,
 						"\n", "", 0);
 
-	no_dsp_trace_f_cmd.string = vty_cmd_string_from_valstr(bts, femtobts_tracef_names,
+	no_dsp_trace_f_cmd.string = vty_cmd_string_from_valstr(ctx, femtobts_tracef_names,
 						"no trx <0-0> dsp-trace-flag (",
 						"|",")", VTY_DO_LOWER);
-	no_dsp_trace_f_cmd.doc = vty_cmd_string_from_valstr(bts, femtobts_tracef_docs,
+	no_dsp_trace_f_cmd.doc = vty_cmd_string_from_valstr(ctx, femtobts_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, femtobts_tracef_names,
+		vty_cmd_string_from_valstr(ctx, femtobts_tracef_names,
 					   "dsp-trace-flag (", "|", ")",
 					   VTY_DO_LOWER);
 	cfg_phy_dsp_trace_f_cmd.doc =
-		vty_cmd_string_from_valstr(bts, femtobts_tracef_docs,
+		vty_cmd_string_from_valstr(ctx, femtobts_tracef_docs,
 					   DSP_TRACE_F_STR, "\n", "", 0);
 
 	cfg_phy_no_dsp_trace_f_cmd.string =
-		vty_cmd_string_from_valstr(bts, femtobts_tracef_names,
+		vty_cmd_string_from_valstr(ctx, femtobts_tracef_names,
 					   "no dsp-trace-flag (", "|", ")",
 					   VTY_DO_LOWER);
 	cfg_phy_no_dsp_trace_f_cmd.doc =
-		vty_cmd_string_from_valstr(bts, femtobts_tracef_docs,
+		vty_cmd_string_from_valstr(ctx, femtobts_tracef_docs,
 					   NO_STR DSP_TRACE_F_STR, "\n",
 					   "", 0);
 
diff --git a/src/osmo-bts-trx/trx_vty.c b/src/osmo-bts-trx/trx_vty.c
index 6dc28f6..ceca330 100644
--- a/src/osmo-bts-trx/trx_vty.c
+++ b/src/osmo-bts-trx/trx_vty.c
@@ -52,16 +52,13 @@
 
 #define OSMOTRX_STR	"OsmoTRX Transceiver configuration\n"
 
-static struct gsm_bts *vty_bts;
-
 DEFUN(show_transceiver, show_transceiver_cmd, "show transceiver",
 	SHOW_STR "Display information about transceivers\n")
 {
-	struct gsm_bts *bts = vty_bts;
 	struct gsm_bts_trx *trx;
 	struct trx_l1h *l1h;
 
-	llist_for_each_entry(trx, &bts->trx_list, list) {
+	llist_for_each_entry(trx, &g_bts->trx_list, list) {
 		struct phy_instance *pinst = trx_phy_instance(trx);
 		struct phy_link *plink = pinst->phy_link;
 		char *sname = osmo_sock_get_name(NULL, plink->u.osmotrx.trx_ofd_clk.fd);
@@ -201,7 +198,7 @@
 {
 	vty_out (vty, "'osmotrx ms-power-loop' is deprecated, use 'uplink-power-target' instead%s", VTY_NEWLINE);
 
-	vty_bts->ul_power_target = atoi(argv[0]);
+	g_bts->ul_power_target = atoi(argv[0]);
 
 	return CMD_SUCCESS;
 }
@@ -599,10 +596,8 @@
 			VTY_NEWLINE);
 }
 
-int bts_model_vty_init(struct gsm_bts *bts)
+int bts_model_vty_init(void *ctx)
 {
-	vty_bts = bts;
-
 	install_element_ve(&show_transceiver_cmd);
 	install_element_ve(&show_phy_cmd);
 
diff --git a/src/osmo-bts-virtual/virtualbts_vty.c b/src/osmo-bts-virtual/virtualbts_vty.c
index 9d63242..3933bd2 100644
--- a/src/osmo-bts-virtual/virtualbts_vty.c
+++ b/src/osmo-bts-virtual/virtualbts_vty.c
@@ -50,8 +50,6 @@
 	SHOW_STR				\
 	TRX_STR
 
-static struct gsm_bts *vty_bts;
-
 void bts_model_config_write_bts(struct vty *vty, const struct gsm_bts *bts)
 {
 }
@@ -191,10 +189,8 @@
 	return CMD_SUCCESS;
 }
 
-int bts_model_vty_init(struct gsm_bts *bts)
+int bts_model_vty_init(void *ctx)
 {
-	vty_bts = bts;
-
 	install_element(PHY_NODE, &cfg_phy_ms_mcast_group_cmd);
 	install_element(PHY_NODE, &cfg_phy_ms_mcast_port_cmd);
 	install_element(PHY_NODE, &cfg_phy_bts_mcast_group_cmd);

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-bts/+/21011
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Change-Id: Iee7fee6747dd1e7c0af36f9b27326f651ae37aaf
Gerrit-Change-Number: 21011
Gerrit-PatchSet: 3
Gerrit-Owner: fixeria <vyanitskiy at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy at sysmocom.de>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20201102/c967aa3d/attachment.htm>


More information about the gerrit-log mailing list