aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2013-10-27 09:02:31 +0100
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2013-10-30 21:24:12 +0100
commitf537298ccad65dfb64076c5a68895eb93743c432 (patch)
treef3d9e5da32c0239c13fff3a90eca5d6902d7a723 /src
parent61a0a04d2651211715dc5e379021da334606c229 (diff)
bts: Start creating statistics inside the BTS code
Diffstat (limited to 'src')
-rw-r--r--src/bts.cpp33
-rw-r--r--src/bts.h31
-rw-r--r--src/pcu_vty.c11
3 files changed, 75 insertions, 0 deletions
diff --git a/src/bts.cpp b/src/bts.cpp
index 32d2677..29e5834 100644
--- a/src/bts.cpp
+++ b/src/bts.cpp
@@ -43,6 +43,26 @@ extern void *tall_pcu_ctx;
static BTS s_bts;
+/**
+ * For gcc-4.4 compat do not use extended initializer list but keep the
+ * order from the enum here. Once we support GCC4.7 and up we can change
+ * the code below.
+ */
+static const struct rate_ctr_desc bts_ctr_description[] = {
+ { "tbf.dl.alloc", "TBF DL Allocated "},
+ { "tbf.dl.freed", "TBF DL Freed "},
+ { "tbf.ul.alloc", "TBF UL Allocated "},
+ { "tbf.ul.freed", "TBF UL Freed "},
+ { "decode.errors", "Decode Errors "},
+};
+
+static const struct rate_ctr_group_desc bts_ctrg_desc = {
+ "bts",
+ "BTS Statistics",
+ ARRAY_SIZE(bts_ctr_description),
+ bts_ctr_description,
+};
+
BTS* BTS::main_bts()
{
return &s_bts;
@@ -58,6 +78,11 @@ struct gprs_rlcmac_bts *bts_main_data()
return BTS::main_bts()->bts_data();
}
+struct rate_ctr_group *bts_main_data_stats()
+{
+ return BTS::main_bts()->rate_counters();
+}
+
BTS::BTS()
: m_cur_fn(0)
, m_pollController(*this)
@@ -80,8 +105,16 @@ BTS::BTS()
pdch->trx = trx;
}
}
+
+ m_ratectrs = rate_ctr_group_alloc(tall_pcu_ctx, &bts_ctrg_desc, 0);
}
+BTS::~BTS()
+{
+ rate_ctr_group_free(m_ratectrs);
+}
+
+
void BTS::set_current_frame_number(int fn)
{
m_cur_fn = fn;
diff --git a/src/bts.h b/src/bts.h
index f1df398..af51e47 100644
--- a/src/bts.h
+++ b/src/bts.h
@@ -24,6 +24,7 @@
#ifdef __cplusplus
extern "C" {
#include <osmocom/core/linuxlist.h>
+#include <osmocom/core/rate_ctr.h>
#include <osmocom/core/timer.h>
}
@@ -147,7 +148,16 @@ struct gprs_rlcmac_bts {
*/
struct BTS {
public:
+ enum {
+ CTR_TBF_DL_ALLOCATED,
+ CTR_TBF_DL_FREED,
+ CTR_TBF_UL_ALLOCATED,
+ CTR_TBF_UL_FREED,
+ CTR_DECODE_ERRORS,
+ };
+
BTS();
+ ~BTS();
static BTS* main_bts();
@@ -174,12 +184,27 @@ public:
void trigger_dl_ass(gprs_rlcmac_tbf *tbf, gprs_rlcmac_tbf *old_tbf, const char *imsi);
void snd_dl_ass(gprs_rlcmac_tbf *tbf, uint8_t poll, const char *imsi);
+ /*
+ * Statistics
+ */
+ void tbf_dl_created();
+ void tbf_dl_freed();
+ void tbf_ul_created();
+ void tbf_ul_freed();
+ void decode_error();
+
+ /*
+ * Below for C interface for the VTY
+ */
+ struct rate_ctr_group *rate_counters() const;
+
private:
int m_cur_fn;
struct gprs_rlcmac_bts m_bts;
PollController m_pollController;
SBAController m_sba;
TimingAdvance m_ta;
+ struct rate_ctr_group *m_ratectrs;
private:
/* disable copying to avoid slicing */
@@ -207,6 +232,11 @@ inline BTS *gprs_rlcmac_pdch::bts() const
return trx->bts;
}
+inline struct rate_ctr_group *BTS::rate_counters() const
+{
+ return m_ratectrs;
+}
+
inline gprs_rlcmac_bts *gprs_rlcmac_pdch::bts_data() const
{
return trx->bts->bts_data();
@@ -222,6 +252,7 @@ inline uint8_t gprs_rlcmac_pdch::trx_no() const
extern "C" {
#endif
struct gprs_rlcmac_bts *bts_main_data();
+ struct rate_ctr_group *bts_main_data_stats();
#ifdef __cplusplus
}
diff --git a/src/pcu_vty.c b/src/pcu_vty.c
index 66a351f..77627fc 100644
--- a/src/pcu_vty.c
+++ b/src/pcu_vty.c
@@ -274,6 +274,15 @@ DEFUN(cfg_pcu_gamma,
return CMD_SUCCESS;
}
+DEFUN(show_bts_stats,
+ show_bts_stats_cmd,
+ "show bts statistics",
+ SHOW_STR "BTS related functionality\nStatistics\n")
+{
+ vty_out_rate_ctr_group(vty, "", bts_main_data_stats());
+ return CMD_SUCCESS;
+}
+
static const char pcu_copyright[] =
"Copyright (C) 2012 by Ivan Kluchnikov <kluchnikovi@gmail.com> and \r\n"
" Andreas Eversberg <jolly@eversberg.eu>\r\n"
@@ -311,5 +320,7 @@ int pcu_vty_init(const struct log_info *cat)
install_element(PCU_NODE, &cfg_pcu_gamma_cmd);
install_element(PCU_NODE, &ournode_end_cmd);
+ install_element_ve(&show_bts_stats_cmd);
+
return 0;
}