aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2023-04-19 18:22:23 +0200
committerPau Espin Pedrol <pespin@sysmocom.de>2023-04-21 14:35:37 +0200
commite1c84579cce3b5373b49535de880d4b864b75512 (patch)
tree98e730e4b444f910acdaf32406552a725b2be7ad
parentf9783c58f77e4d0bb371c6b1bc160be1bf8495bb (diff)
tbf: Move m_ctrs alloc to constructor
Move rate_ctr allocation to the constructor since it's expected not to fail. This simplifies further tbf::setup() function. Change-Id: If64443c38624d159e68eec3a07d8e8caf369467b
-rw-r--r--src/tbf.cpp9
-rw-r--r--src/tbf_ul.cpp3
2 files changed, 4 insertions, 8 deletions
diff --git a/src/tbf.cpp b/src/tbf.cpp
index 797a95de..2f832a5a 100644
--- a/src/tbf.cpp
+++ b/src/tbf.cpp
@@ -129,6 +129,9 @@ gprs_rlcmac_tbf::gprs_rlcmac_tbf(struct gprs_rlcmac_bts *bts_, GprsMs *ms, gprs_
m_created_ts = time(NULL);
/* set timestamp */
osmo_clock_gettime(CLOCK_MONOTONIC, &meas.rssi_tv);
+
+ m_ctrs = rate_ctr_group_alloc(this, &tbf_ctrg_desc, next_tbf_ctr_group_id++);
+ OSMO_ASSERT(m_ctrs);
}
@@ -592,12 +595,6 @@ int gprs_rlcmac_tbf::setup(int8_t use_trx, bool single_slot)
"Allocated: trx = %d, ul_slots = %02x, dl_slots = %02x\n",
this->trx->trx_no, ul_slots(), dl_slots());
- m_ctrs = rate_ctr_group_alloc(this, &tbf_ctrg_desc, next_tbf_ctr_group_id++);
- if (!m_ctrs) {
- LOGPTBF(this, LOGL_ERROR, "Couldn't allocate TBF counters\n");
- return -1;
- }
-
tbf_update_state_fsm_name(this);
ms_attach_tbf(m_ms, this);
diff --git a/src/tbf_ul.cpp b/src/tbf_ul.cpp
index a0e03985..608714d3 100644
--- a/src/tbf_ul.cpp
+++ b/src/tbf_ul.cpp
@@ -168,14 +168,13 @@ struct gprs_rlcmac_ul_tbf *ul_tbf_alloc_rejected(struct gprs_rlcmac_bts *bts, st
/* The only one TS is the common, control TS */
ms_set_first_common_ts(ms, pdch);
tbf_assign_control_ts(ul_tbf);
- ul_tbf->m_ctrs = rate_ctr_group_alloc(ul_tbf, &tbf_ctrg_desc, next_tbf_ctr_group_id++);
ul_tbf->m_ul_egprs_ctrs = rate_ctr_group_alloc(ul_tbf,
&tbf_ul_egprs_ctrg_desc,
ul_tbf->m_ctrs->idx);
ul_tbf->m_ul_gprs_ctrs = rate_ctr_group_alloc(ul_tbf,
&tbf_ul_gprs_ctrg_desc,
ul_tbf->m_ctrs->idx);
- if (!ul_tbf->m_ctrs || !ul_tbf->m_ul_egprs_ctrs || !ul_tbf->m_ul_gprs_ctrs) {
+ if (!ul_tbf->m_ul_egprs_ctrs || !ul_tbf->m_ul_gprs_ctrs) {
LOGPTBF(ul_tbf, LOGL_ERROR, "Could not allocate TBF UL rate counters\n");
talloc_free(ul_tbf);
return NULL;