From 402451b3087a004e30d5b774c6a6a82cffbfc5d3 Mon Sep 17 00:00:00 2001 From: Oliver Smith Date: Wed, 8 Sep 2021 09:33:24 +0200 Subject: [PATCH] Add stats: pcu.bts.N.pdch.occupied.gprs/egprs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add stats needed for performance measurements in 3GPP TS 52.402 § B.2.1.54-55. Split m_num_tbfs to count GPRS and EGPRS TBFs separately. Move the code that updates m_num_tbfs and sets the PDCH_OCCUPIED stats to a separate function, as it's mostly the same in the TBF attach and detach. Related: SYS#4878 Change-Id: I0c0a1121b4ae5f031782e7e63a0c28eb0b6c8b42 --- src/bts.cpp | 6 +++++- src/bts.h | 2 ++ src/pdch.cpp | 53 +++++++++++++++++++++++++++++++++++----------------- src/pdch.h | 6 ++++-- src/tbf.cpp | 18 ++++++++++++++++++ src/tbf.h | 6 ------ 6 files changed, 65 insertions(+), 26 deletions(-) diff --git a/src/bts.cpp b/src/bts.cpp index beb626d5..c4636066 100644 --- a/src/bts.cpp +++ b/src/bts.cpp @@ -201,7 +201,11 @@ static const struct osmo_stat_item_desc bts_stat_item_description[] = { OSMO_STAT_ITEM_NO_UNIT, 4, 0}, { "pdch.available", "PDCH available ", OSMO_STAT_ITEM_NO_UNIT, 50, 0}, - { "pdch.occupied", "PDCH occupied ", + { "pdch.occupied", "PDCH occupied (all) ", + OSMO_STAT_ITEM_NO_UNIT, 50, 0}, + { "pdch.occupied.gprs", "PDCH occupied (GPRS) ", + OSMO_STAT_ITEM_NO_UNIT, 50, 0}, + { "pdch.occupied.egprs","PDCH occupied (EGPRS)", OSMO_STAT_ITEM_NO_UNIT, 50, 0}, }; diff --git a/src/bts.h b/src/bts.h index a6e71500..d9a86ebb 100644 --- a/src/bts.h +++ b/src/bts.h @@ -184,6 +184,8 @@ enum { STAT_MS_PRESENT, STAT_PDCH_AVAILABLE, STAT_PDCH_OCCUPIED, + STAT_PDCH_OCCUPIED_GPRS, + STAT_PDCH_OCCUPIED_EGPRS, }; /* RACH.ind parameters (to be parsed) */ diff --git a/src/pdch.cpp b/src/pdch.cpp index e213c28c..d10ee4a7 100644 --- a/src/pdch.cpp +++ b/src/pdch.cpp @@ -1036,6 +1036,33 @@ gprs_rlcmac_tbf *gprs_rlcmac_pdch::tbf_by_tfi(uint8_t tfi, return tbf; } +void gprs_rlcmac_pdch::num_tbfs_update(gprs_rlcmac_tbf *tbf, bool is_attach) +{ + int threshold = is_attach ? 0 : 1; + int inc = is_attach ? 1 : -1; + uint8_t ul_dl_gprs = m_num_tbfs_gprs[GPRS_RLCMAC_UL_TBF] + + m_num_tbfs_gprs[GPRS_RLCMAC_DL_TBF]; + uint8_t ul_dl_egprs = m_num_tbfs_egprs[GPRS_RLCMAC_UL_TBF] + + m_num_tbfs_egprs[GPRS_RLCMAC_DL_TBF]; + + /* Count PDCHs with at least one TBF as "occupied", as in + * 3GPP TS 52.402 § B.2.1.42-44. So if transitioning from 0 (threshold) + * TBFs in this PDCH to 1, increase the counter by 1 (inc). */ + if (ul_dl_gprs + ul_dl_egprs == threshold) + bts_stat_item_add(trx->bts, STAT_PDCH_OCCUPIED, inc); + + /* Update occupied GPRS/EGPRS stats (§ B.2.1.54-55) too */ + if (tbf->is_egprs_enabled() && ul_dl_egprs == threshold) + bts_stat_item_add(trx->bts, STAT_PDCH_OCCUPIED_EGPRS, inc); + else if (!tbf->is_egprs_enabled() && ul_dl_gprs == threshold) + bts_stat_item_add(trx->bts, STAT_PDCH_OCCUPIED_GPRS, inc); + + if (tbf->is_egprs_enabled()) + m_num_tbfs_egprs[tbf->direction] += inc; + else + m_num_tbfs_gprs[tbf->direction] += inc; +} + void gprs_rlcmac_pdch::attach_tbf(gprs_rlcmac_tbf *tbf) { gprs_rlcmac_ul_tbf *ul_tbf; @@ -1045,13 +1072,7 @@ void gprs_rlcmac_pdch::attach_tbf(gprs_rlcmac_tbf *tbf) "%s has not been detached, overwriting it\n", m_tbfs[tbf->direction][tbf->tfi()]->name()); - /* Count PDCHs with at least one TBF as "occupied", as in - * 3GPP TS 52.402 § B.2.1.42-44. So if transitioning from 0 TBFs in - * this PDCH to 1, increase the counter by 1. */ - if (m_num_tbfs[GPRS_RLCMAC_UL_TBF] + m_num_tbfs[GPRS_RLCMAC_DL_TBF] == 0) - bts_stat_item_inc(trx->bts, STAT_PDCH_OCCUPIED); - - m_num_tbfs[tbf->direction] += 1; + num_tbfs_update(tbf, true); if (tbf->direction == GPRS_RLCMAC_UL_TBF) { ul_tbf = as_ul_tbf(tbf); m_assigned_usf |= 1 << ul_tbf->m_usf[ts_no]; @@ -1061,7 +1082,7 @@ void gprs_rlcmac_pdch::attach_tbf(gprs_rlcmac_tbf *tbf) LOGPDCH(this, DRLCMAC, LOGL_INFO, "Attaching %s, %d TBFs, " "USFs = %02x, TFIs = %08x.\n", - tbf->name(), m_num_tbfs[tbf->direction], + tbf->name(), num_tbfs(tbf->direction), m_assigned_usf, m_assigned_tfi[tbf->direction]); } @@ -1069,15 +1090,13 @@ void gprs_rlcmac_pdch::detach_tbf(gprs_rlcmac_tbf *tbf) { gprs_rlcmac_ul_tbf *ul_tbf; - OSMO_ASSERT(m_num_tbfs[tbf->direction] > 0); + if (tbf->is_egprs_enabled()) { + OSMO_ASSERT(m_num_tbfs_egprs[tbf->direction] > 0); + } else { + OSMO_ASSERT(m_num_tbfs_gprs[tbf->direction] > 0); + } - /* Count PDCHs with at least one TBF as "occupied", as in - * 3GPP TS 52.402 § B.2.1.42-44. So if transitioning from 1 TBFs in - * this PDCH to 0, decrease the counter by 1. */ - if (m_num_tbfs[GPRS_RLCMAC_UL_TBF] + m_num_tbfs[GPRS_RLCMAC_DL_TBF] == 1) - bts_stat_item_dec(trx->bts, STAT_PDCH_OCCUPIED); - - m_num_tbfs[tbf->direction] -= 1; + num_tbfs_update(tbf, false); if (tbf->direction == GPRS_RLCMAC_UL_TBF) { ul_tbf = as_ul_tbf(tbf); m_assigned_usf &= ~(1 << ul_tbf->m_usf[ts_no]); @@ -1089,7 +1108,7 @@ void gprs_rlcmac_pdch::detach_tbf(gprs_rlcmac_tbf *tbf) LOGPDCH(this, DRLCMAC, LOGL_INFO, "Detaching %s, %d TBFs, " "USFs = %02x, TFIs = %08x.\n", - tbf->name(), m_num_tbfs[tbf->direction], + tbf->name(), num_tbfs(tbf->direction), m_assigned_usf, m_assigned_tfi[tbf->direction]); } diff --git a/src/pdch.h b/src/pdch.h index 00f0b9d6..94056069 100644 --- a/src/pdch.h +++ b/src/pdch.h @@ -78,6 +78,7 @@ struct gprs_rlcmac_pdch { void detach_tbf(gprs_rlcmac_tbf *tbf); unsigned num_tbfs(enum gprs_rlcmac_tbf_direction dir) const; + void num_tbfs_update(gprs_rlcmac_tbf *tbf, bool is_attach); void reserve(enum gprs_rlcmac_tbf_direction dir); void unreserve(enum gprs_rlcmac_tbf_direction dir); @@ -147,7 +148,8 @@ private: void free_resources(); #endif - uint8_t m_num_tbfs[2]; + uint8_t m_num_tbfs_gprs[2]; + uint8_t m_num_tbfs_egprs[2]; uint8_t m_num_reserved[2]; uint8_t m_assigned_usf; /* bit set */ uint32_t m_assigned_tfi[2]; /* bit set */ @@ -158,7 +160,7 @@ private: inline unsigned gprs_rlcmac_pdch::num_tbfs(enum gprs_rlcmac_tbf_direction dir) const { - return m_num_tbfs[dir]; + return m_num_tbfs_gprs[dir] + m_num_tbfs_egprs[dir]; } inline unsigned gprs_rlcmac_pdch::num_reserved( diff --git a/src/tbf.cpp b/src/tbf.cpp index 4154d501..31dec723 100644 --- a/src/tbf.cpp +++ b/src/tbf.cpp @@ -763,6 +763,24 @@ bool gprs_rlcmac_tbf::is_control_ts(uint8_t ts) const return ts == control_ts; } +void gprs_rlcmac_tbf::enable_egprs() +{ + /* Decrease GPRS TBF count of attached PDCHs */ + for (size_t ts = 0; ts < ARRAY_SIZE(pdch); ts++) { + if (pdch[ts]) + pdch[ts]->num_tbfs_update(this, false); + } + + m_egprs_enabled = true; + window()->set_sns(RLC_EGPRS_SNS); + + /* Increase EGPRS TBF count of attached PDCHs */ + for (size_t ts = 0; ts < ARRAY_SIZE(pdch); ts++) { + if (pdch[ts]) + pdch[ts]->num_tbfs_update(this, true); + } +} + /* C API */ enum tbf_fsm_states tbf_state(const struct gprs_rlcmac_tbf *tbf) { diff --git a/src/tbf.h b/src/tbf.h index 09329333..3aaf9fb0 100644 --- a/src/tbf.h +++ b/src/tbf.h @@ -354,12 +354,6 @@ inline bool gprs_rlcmac_tbf::is_egprs_enabled() const return m_egprs_enabled; } -inline void gprs_rlcmac_tbf::enable_egprs() -{ - m_egprs_enabled = true; - window()->set_sns(RLC_EGPRS_SNS); -} - inline enum gprs_rlcmac_tbf_direction reverse(enum gprs_rlcmac_tbf_direction dir) { return (enum gprs_rlcmac_tbf_direction)