add VTY commands for setting and showing DSP trace flags

This commit is contained in:
Harald Welte 2011-07-05 12:21:27 +02:00
parent ead4863de1
commit 12b647998c
5 changed files with 216 additions and 1 deletions

View File

@ -4,7 +4,7 @@ LDADD = $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) $(LIBOSMOVTY_LIBS)
bin_PROGRAMS = sysmobts sysmobts-remote l1fwd-proxy
COMMON_SOURCES = main.c femtobts.c l1_if.c oml.c bts_model.c
COMMON_SOURCES = main.c femtobts.c l1_if.c oml.c bts_model.c sysmobts_vty.c
sysmobts_SOURCES = $(COMMON_SOURCES) l1_transp_hw.c
sysmobts_LDADD = $(top_builddir)/src/common/libbts.a $(LDADD)

View File

@ -669,6 +669,10 @@ static int reset_compl_cb(struct msgb *resp, void *data)
bts_shutdown(trx->bts, "L1-RESET failure");
}
/* as we cannot get the current DSP trace flags, we simply
* set them to zero (or whatever dsp_trace_f has been initialized to */
l1if_set_trace_flags(fl1h, fl1h->dsp_trace_f);
/* otherwise, request activation of RF board */
l1if_activate_rf(fl1h, 1);
@ -684,6 +688,24 @@ int l1if_reset(struct femtol1_hdl *hdl)
return l1if_req_compl(hdl, msg, 1, reset_compl_cb, hdl);
}
/* set the trace flags within the DSP */
int l1if_set_trace_flags(struct femtol1_hdl *hdl, uint32_t flags)
{
struct msgb *msg = sysp_msgb_alloc();
FemtoBts_Prim_t *sysp = msgb_sysprim(msg);
LOGP(DL1C, LOGL_INFO, "Tx SET-TRACE-FLAGS.req (0x%08x)\n",
flags);
sysp->id = FemtoBts_PrimId_SetTraceFlagsReq;
sysp->u.setTraceFlagsReq.u32Tf = flags;
hdl->dsp_trace_f = flags;
/* There is no confirmation we could wait for */
return osmo_wqueue_enqueue(&hdl->write_q[MQ_SYS_WRITE], msg);
}
struct femtol1_hdl *l1if_open(void *priv)
{
struct femtol1_hdl *fl1h;

View File

@ -20,6 +20,7 @@ enum {
struct femtol1_hdl {
struct gsm_time gsm_time;
uint32_t hLayer1; /* handle to the L1 instance in the DSP */
uint32_t dsp_trace_f;
struct llist_head wlc_list;
void *priv; /* user reference */
@ -41,6 +42,7 @@ struct femtol1_hdl *l1if_open(void *priv);
int l1if_close(struct femtol1_hdl *hdl);
int l1if_reset(struct femtol1_hdl *hdl);
int l1if_activate_rf(struct femtol1_hdl *hdl, int on);
int l1if_set_trace_flags(struct femtol1_hdl *hdl, uint32_t flags);
struct msgb *l1p_msgb_alloc(void);
struct msgb *sysp_msgb_alloc(void);

View File

@ -65,6 +65,8 @@ int bts_model_init(struct gsm_bts *bts)
l1if_reset(fl1h);
femtol1_vty_init(bts);
return 0;
}

View File

@ -0,0 +1,189 @@
/* VTY interface for sysmoBTS */
/* (C) 2011 by Harald Welte <laforge@gnumonks.org>
*
* All Rights Reserved
*
* 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 Affero 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 <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <stdint.h>
#include <arpa/inet.h>
#include <osmocom/core/msgb.h>
#include <osmocom/core/talloc.h>
#include <osmocom/core/select.h>
#include <osmocom/core/rate_ctr.h>
#include <osmocom/gsm/tlv.h>
#include <osmocom/vty/vty.h>
#include <osmocom/vty/command.h>
#include <osmo-bts/gsm_data.h>
#include <osmo-bts/logging.h>
#include "femtobts.h"
#include "l1_if.h"
static struct gsm_bts *vty_bts;
/* This generates the logging command string for VTY. */
const char *vty_cmd_string_from_valstr(const struct value_string *vals,
const char *prefix)
{
int len = 0, offset = 0, ret, i, rem;
int size = strlen(prefix);
const struct value_string *vs;
char *str;
for (vs = vals; vs->value || vs->str; vs++)
size += strlen(vs->str) + 1;
rem = size;
str = talloc_zero_size(vty_bts, size);
if (!str)
return NULL;
ret = snprintf(str + offset, rem, prefix);
if (ret < 0)
goto err;
OSMO_SNPRINTF_RET(ret, rem, offset, len);
for (vs = vals; vs->value || vs->str; vs++) {
if (vs->str) {
int j, name_len = strlen(vs->str)+1;
char name[name_len];
for (j = 0; j < name_len; j++)
name[j] = tolower(vs->str[j]);
name[name_len-1] = '\0';
ret = snprintf(str + offset, rem, "%s|", name);
if (ret < 0)
goto err;
OSMO_SNPRINTF_RET(ret, rem, offset, len);
}
}
offset--; /* to remove the trailing | */
rem++;
ret = snprintf(str + offset, rem, ")");
if (ret < 0)
goto err;
OSMO_SNPRINTF_RET(ret, rem, offset, len);
err:
str[size-1] = '\0';
return str;
}
DEFUN(show_dsp_trace_f, show_dsp_trace_f_cmd,
"show trx <0-0> dsp-trace-flags",
SHOW_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 femtol1_hdl *fl1h;
int i;
if (!trx)
return CMD_WARNING;
fl1h = trx_femtol1_hdl(trx);
vty_out(vty, "Femto L1 DSP trace flags:%s", VTY_NEWLINE);
for (i = 0; i < ARRAY_SIZE(femtobts_tracef_names); i++) {
const char *endis;
if (femtobts_tracef_names[i].value == 0 &&
femtobts_tracef_names[i].str == NULL)
break;
if (fl1h->dsp_trace_f & femtobts_tracef_names[i].value)
endis = "enabled";
else
endis = "disabled";
vty_out(vty, "DSP Trace %-15s %s%s",
femtobts_tracef_names[i].str, endis,
VTY_NEWLINE);
}
return CMD_SUCCESS;
}
DEFUN(dsp_trace_f, dsp_trace_f_cmd, "HIDDEN", "HIDDEN")
{
int trx_nr = atoi(argv[0]);
struct gsm_bts_trx *trx = gsm_bts_trx_num(vty_bts, trx_nr);
struct femtol1_hdl *fl1h;
unsigned int flag ;
if (!trx) {
vty_out(vty, "Cannot find TRX number %u%s",
trx_nr, VTY_NEWLINE);
return CMD_WARNING;
}
fl1h = trx_femtol1_hdl(trx);
flag = get_string_value(femtobts_tracef_names, argv[1]);
l1if_set_trace_flags(fl1h, fl1h->dsp_trace_f | flag);
return CMD_SUCCESS;
}
DEFUN(no_dsp_trace_f, no_dsp_trace_f_cmd, "HIDDEN", "HIDDEN")
{
int trx_nr = atoi(argv[0]);
struct gsm_bts_trx *trx = gsm_bts_trx_num(vty_bts, trx_nr);
struct femtol1_hdl *fl1h;
unsigned int flag ;
if (!trx) {
vty_out(vty, "Cannot find TRX number %u%s",
trx_nr, VTY_NEWLINE);
return CMD_WARNING;
}
fl1h = trx_femtol1_hdl(trx);
flag = get_string_value(femtobts_tracef_names, argv[1]);
l1if_set_trace_flags(fl1h, fl1h->dsp_trace_f & ~flag);
return CMD_SUCCESS;
}
int femtol1_vty_init(struct gsm_bts *bts)
{
vty_bts = bts;
/* runtime-patch the command strings with debug levels */
dsp_trace_f_cmd.string = vty_cmd_string_from_valstr(femtobts_tracef_names,
"trx <0-0> dsp-trace-flag (");
no_dsp_trace_f_cmd.string = vty_cmd_string_from_valstr(femtobts_tracef_names,
"no trx <0-0> dsp-trace-flag (");
install_element_ve(&show_dsp_trace_f_cmd);
install_element_ve(&dsp_trace_f_cmd);
install_element_ve(&no_dsp_trace_f_cmd);
return 0;
}