From 9582883235743e31800ec7cbfc8af2c16b63cdbb Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Wed, 12 Oct 2011 13:36:22 +0200 Subject: add VTY based way to set clock calibration of sysmobts L1 --- src/common/vty.c | 62 ++++++++++++++++++++++++++++++++++++++- src/osmo-bts-sysmo/l1_if.c | 3 +- src/osmo-bts-sysmo/l1_if.h | 1 + src/osmo-bts-sysmo/main.c | 2 +- src/osmo-bts-sysmo/sysmobts_vty.c | 46 +++++++++++++++++++++++++++++ 5 files changed, 111 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/common/vty.c b/src/common/vty.c index 741899c5..83a3054a 100644 --- a/src/common/vty.c +++ b/src/common/vty.c @@ -47,6 +47,13 @@ enum node_type bts_vty_go_parent(struct vty *vty) { switch (vty->node) { + case TRX_NODE: + vty->node = BTS_NODE; + { + struct gsm_bts_trx *trx = vty->index; + vty->index = trx->bts; + } + break; default: vty->node = CONFIG_NODE; } @@ -56,6 +63,7 @@ enum node_type bts_vty_go_parent(struct vty *vty) int bts_vty_is_config_node(struct vty *vty, int node) { switch (node) { + case TRX_NODE: case BTS_NODE: return 1; default: @@ -67,6 +75,13 @@ gDEFUN(ournode_exit, ournode_exit_cmd, "exit", "Exit current node, go down to provious node") { switch (vty->node) { + case TRX_NODE: + vty->node = BTS_NODE; + { + struct gsm_bts_trx *trx = vty->index; + vty->index = trx->bts; + } + break; default: break; } @@ -128,9 +143,37 @@ static struct cmd_node bts_node = { 1, }; +static struct cmd_node trx_node = { + TRX_NODE, + "%s(trx)#", + 1, +}; + +DEFUN(cfg_bts_trx, cfg_bts_trx_cmd, + "trx <0-0>", + "Select a TRX to configure\n" "TRX number\n") +{ + int trx_nr = atoi(argv[0]); + struct gsm_bts *bts = vty->index; + struct gsm_bts_trx *trx; + + trx = gsm_bts_trx_num(bts, trx_nr); + if (!trx) { + vty_out(vty, "Unknown TRX %u%s", trx_nr, VTY_NEWLINE); + return CMD_WARNING; + } + + vty->index = trx; + vty->index_sub = &trx->description; + vty->node = TRX_NODE; + + return CMD_SUCCESS; +} + static void config_write_bts_single(struct vty *vty, struct gsm_bts *bts) { struct gsm_bts_role_bts *btsb = bts_role_bts(bts); + struct gsm_bts_trx *trx; vty_out(vty, "bts %u%s", bts->nr, VTY_NEWLINE); if (bts->description) @@ -142,9 +185,16 @@ static void config_write_bts_single(struct vty *vty, struct gsm_bts *bts) vty_out(vty, " rtp bind-ip %s%s", btsb->rtp_bind_host, VTY_NEWLINE); vty_out(vty, " rtp jitter-buffer %u%s", btsb->rtp_jitter_buf_ms, VTY_NEWLINE); + + bts_model_config_write_bts(vty, bts); + + llist_for_each_entry(trx, &bts->trx_list, list) { + vty_out(vty, " trx %u%s", trx->nr, VTY_NEWLINE); + bts_model_config_write_trx(vty, trx); + } } -int config_write_bts(struct vty *vty) +static int config_write_bts(struct vty *vty) { struct gsm_network *net = gsmnet_from_vty(vty); struct gsm_bts *bts; @@ -155,6 +205,11 @@ int config_write_bts(struct vty *vty) return CMD_SUCCESS; } +static int config_write_dummy(struct vty *vty) +{ + return CMD_SUCCESS; +} + /* per-BTS configuration */ DEFUN(cfg_bts, cfg_bts_cmd, @@ -418,6 +473,11 @@ int bts_vty_init(const struct log_info *cat) install_element(BTS_NODE, &cfg_description_cmd); install_element(BTS_NODE, &cfg_no_description_cmd); + /* add and link to TRX config node */ + install_element(BTS_NODE, &cfg_bts_trx_cmd); + install_node(&trx_node, config_write_dummy); + install_default(TRX_NODE); + install_element(ENABLE_NODE, &bts_t_t_l_jitter_buf_cmd); return 0; diff --git a/src/osmo-bts-sysmo/l1_if.c b/src/osmo-bts-sysmo/l1_if.c index 59db61fd..39e356f8 100644 --- a/src/osmo-bts-sysmo/l1_if.c +++ b/src/osmo-bts-sysmo/l1_if.c @@ -720,7 +720,7 @@ int l1if_activate_rf(struct femtol1_hdl *hdl, int on) if (on) { sysp->id = FemtoBts_PrimId_ActivateRfReq; - sysp->u.activateRfReq.u12ClkVc = 0xFFFF; + sysp->u.activateRfReq.u12ClkVc = hdl->clk_cal; } else { sysp->id = FemtoBts_PrimId_DeactivateRfReq; } @@ -847,6 +847,7 @@ struct femtol1_hdl *l1if_open(void *priv) INIT_LLIST_HEAD(&fl1h->wlc_list); fl1h->priv = priv; + fl1h->clk_cal = 0xffff; rc = l1if_transport_open(fl1h); if (rc < 0) { diff --git a/src/osmo-bts-sysmo/l1_if.h b/src/osmo-bts-sysmo/l1_if.h index 09f84ef0..1b150d38 100644 --- a/src/osmo-bts-sysmo/l1_if.h +++ b/src/osmo-bts-sysmo/l1_if.h @@ -21,6 +21,7 @@ struct femtol1_hdl { struct gsm_time gsm_time; uint32_t hLayer1; /* handle to the L1 instance in the DSP */ uint32_t dsp_trace_f; + uint16_t clk_cal; struct llist_head wlc_list; void *priv; /* user reference */ diff --git a/src/osmo-bts-sysmo/main.c b/src/osmo-bts-sysmo/main.c index 645cd24a..0ed6e2c8 100644 --- a/src/osmo-bts-sysmo/main.c +++ b/src/osmo-bts-sysmo/main.c @@ -51,7 +51,7 @@ const char *software_version = "0815"; static const char *config_file = "osmo-bts.cfg"; extern const char *osmobts_copyright; static int daemonize = 0; -static unsigned int dsp_trace = 0; +static unsigned int dsp_trace = 0xffffffff; int bts_model_init(struct gsm_bts *bts) { diff --git a/src/osmo-bts-sysmo/sysmobts_vty.c b/src/osmo-bts-sysmo/sysmobts_vty.c index 78ad6c93..93dd024b 100644 --- a/src/osmo-bts-sysmo/sysmobts_vty.c +++ b/src/osmo-bts-sysmo/sysmobts_vty.c @@ -39,6 +39,7 @@ #include #include +#include #include "femtobts.h" #include "l1_if.h" @@ -99,6 +100,35 @@ err: return str; } +/* configuration */ + +DEFUN(cfg_trx_clkcal_def, cfg_trx_clkcal_def_cmd, + "clock-calibration default", + "Set the clock calibration value\n" "Default Clock DAC value\n") +{ + unsigned int clkcal = atoi(argv[0]); + struct gsm_bts_trx *trx = vty->index; + struct femtol1_hdl *fl1h = trx_femtol1_hdl(trx); + + fl1h->clk_cal = 0xffff; + + return CMD_SUCCESS; +} + +DEFUN(cfg_trx_clkcal, cfg_trx_clkcal_cmd, + "clock-calibration <0-4095>", + "Set the clock calibration value\n" "Clock DAC value\n") +{ + unsigned int clkcal = atoi(argv[0]); + struct gsm_bts_trx *trx = vty->index; + struct femtol1_hdl *fl1h = trx_femtol1_hdl(trx); + + fl1h->clk_cal = atoi(argv[0]) & 0xfff; + + return CMD_SUCCESS; +} + +/* runtime */ DEFUN(show_dsp_trace_f, show_dsp_trace_f_cmd, "show trx <0-0> dsp-trace-flags", @@ -210,6 +240,19 @@ DEFUN(show_sys_info, show_sys_info_cmd, return CMD_SUCCESS; } +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) +{ + struct femtol1_hdl *fl1h = trx_femtol1_hdl(trx); + + if (fl1h->clk_cal != 0xffff) { + vty_out(vty, " clock-calibration %u%s", fl1h->clk_cal, + VTY_NEWLINE); + } +} int bts_model_vty_init(struct gsm_bts *bts) { @@ -226,5 +269,8 @@ int bts_model_vty_init(struct gsm_bts *bts) install_element_ve(&dsp_trace_f_cmd); install_element_ve(&no_dsp_trace_f_cmd); + install_element(TRX_NODE, &cfg_trx_clkcal_cmd); + install_element(TRX_NODE, &cfg_trx_clkcal_def_cmd); + return 0; } -- cgit v1.2.3