Change in osmo-pcu[master]: Use new stat item/ctr getter APIs

laforge gerrit-no-reply at lists.osmocom.org
Fri Jun 4 19:40:13 UTC 2021


laforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-pcu/+/24546 )

Change subject: Use new stat item/ctr getter APIs
......................................................................

Use new stat item/ctr getter APIs

Patch mostly done with the help of several small spatch snippets.

Change-Id: I600c7a8725f5b229b1a2feb879da7c3b2dce4505
---
M src/bts.h
M src/gprs_bssgp_pcu.c
M src/gprs_rlcmac_sched.cpp
M src/nacc_fsm.c
M src/tbf_dl.cpp
M src/tbf_ul.cpp
6 files changed, 38 insertions(+), 37 deletions(-)

Approvals:
  laforge: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/bts.h b/src/bts.h
index bb91df3..2a7d883 100644
--- a/src/bts.h
+++ b/src/bts.h
@@ -325,16 +325,17 @@
 }
 
 static inline void bts_do_rate_ctr_inc(const struct gprs_rlcmac_bts *bts, unsigned int ctr_id) {
-	rate_ctr_inc(&bts->ratectrs->ctr[ctr_id]);
+	rate_ctr_inc(rate_ctr_group_get_ctr(bts->ratectrs, ctr_id));
 }
 
 static inline void bts_do_rate_ctr_add(const struct gprs_rlcmac_bts *bts, unsigned int ctr_id, int inc) {
-	rate_ctr_add(&bts->ratectrs->ctr[ctr_id], inc);
+	rate_ctr_add(rate_ctr_group_get_ctr(bts->ratectrs, ctr_id), inc);
 }
 
 static inline void bts_stat_item_add(struct gprs_rlcmac_bts *bts, unsigned int stat_id, int inc) {
-	int32_t val = osmo_stat_item_get_last(bts->statg->items[stat_id]);
-	osmo_stat_item_set(bts->statg->items[stat_id], val + inc);
+	struct osmo_stat_item *item = osmo_stat_item_group_get_item(bts->statg, stat_id);
+	int32_t val = osmo_stat_item_get_last(item);
+	osmo_stat_item_set(item, val + inc);
 }
 
 struct gprs_rlcmac_bts *bts_alloc(struct gprs_pcu *pcu, uint8_t bts_nr);
diff --git a/src/gprs_bssgp_pcu.c b/src/gprs_bssgp_pcu.c
index 7ee2e45..0e8e145 100644
--- a/src/gprs_bssgp_pcu.c
+++ b/src/gprs_bssgp_pcu.c
@@ -538,8 +538,8 @@
 	if (bctx)
 	{
 		log_set_context(LOG_CTX_GB_BVC, bctx);
-		rate_ctr_inc(&bctx->ctrg->ctr[BSSGP_CTR_PKTS_IN]);
-		rate_ctr_add(&bctx->ctrg->ctr[BSSGP_CTR_BYTES_IN], msgb_bssgp_len(msg));
+		rate_ctr_inc(rate_ctr_group_get_ctr(bctx->ctrg, BSSGP_CTR_PKTS_IN));
+		rate_ctr_add(rate_ctr_group_get_ctr(bctx->ctrg, BSSGP_CTR_BYTES_IN), msgb_bssgp_len(msg));
 	}
 
 	if (ns_bvci == BVCI_SIGNALLING)
diff --git a/src/gprs_rlcmac_sched.cpp b/src/gprs_rlcmac_sched.cpp
index fa86b76..4c1a6ab 100644
--- a/src/gprs_rlcmac_sched.cpp
+++ b/src/gprs_rlcmac_sched.cpp
@@ -217,7 +217,7 @@
 		LOGPDCH(pdch, DRLCMACSCHED, LOGL_DEBUG, "FN=%" PRIu32
 			" Scheduling control message at RTS for %s\n",
 			fn, tbf_name(tbf));
-		rate_ctr_inc(&tbf->ms()->ctrs->ctr[MS_CTR_DL_CTRL_MSG_SCHED]);
+		rate_ctr_inc(rate_ctr_group_get_ctr(tbf->ms()->ctrs, MS_CTR_DL_CTRL_MSG_SCHED));
 		return msg;
 	}
 
diff --git a/src/nacc_fsm.c b/src/nacc_fsm.c
index 6384fd5..d2702d4 100644
--- a/src/nacc_fsm.c
+++ b/src/nacc_fsm.c
@@ -147,7 +147,7 @@
 		goto free_ret;
 	}
 	LOGP(DNACC, LOGL_DEBUG, "------------------------- TX : Packet Neighbour Cell Data -------------------------\n");
-	rate_ctr_inc(&bts_rate_counters(ms->bts)->ctr[CTR_PKT_NEIGH_CELL_DATA]);
+	rate_ctr_inc(rate_ctr_group_get_ctr(bts_rate_counters(ms->bts), CTR_PKT_NEIGH_CELL_DATA));
 	talloc_free(mac_control_block);
 
 	ctx->container_idx++;
@@ -204,7 +204,7 @@
 		goto free_ret;
 	}
 	LOGP(DNACC, LOGL_DEBUG, "------------------------- TX : Packet Cell Change Continue -------------------------\n");
-	rate_ctr_inc(&bts_rate_counters(ms->bts)->ctr[CTR_PKT_CELL_CHG_CONTINUE]);
+	rate_ctr_inc(rate_ctr_group_get_ctr(bts_rate_counters(ms->bts), CTR_PKT_CELL_CHG_CONTINUE));
 	talloc_free(mac_control_block);
 	tbf_set_polling(tbf, *new_poll_fn, data->ts, PDCH_ULC_POLL_CELL_CHG_CONTINUE);
 	return msg;
diff --git a/src/tbf_dl.cpp b/src/tbf_dl.cpp
index 9ed389d..eb215fe 100644
--- a/src/tbf_dl.cpp
+++ b/src/tbf_dl.cpp
@@ -1137,7 +1137,7 @@
 		ms_update_error_rate(ms(), this, error_rate);
 
 	m_window.update(bts, rbb, first_bsn, &lost, &received);
-	rate_ctr_add(&m_ctrs->ctr[TBF_CTR_RLC_NACKED], lost);
+	rate_ctr_add(rate_ctr_group_get_ctr(m_ctrs, TBF_CTR_RLC_NACKED), lost);
 
 	/* report lost and received packets */
 	gprs_rlcmac_received_lost(this, received, lost);
@@ -1193,7 +1193,7 @@
 
 	m_window.update(bts, show_rbb, ssn,
 			&lost, &received);
-	rate_ctr_add(&m_ctrs->ctr[TBF_CTR_RLC_NACKED], lost);
+	rate_ctr_add(rate_ctr_group_get_ctr(m_ctrs, TBF_CTR_RLC_NACKED), lost);
 
 	/* report lost and received packets */
 	gprs_rlcmac_received_lost(this, received, lost);
@@ -1509,55 +1509,55 @@
 	switch (cs) {
 	case CS1:
 		bts_do_rate_ctr_inc(bts, CTR_GPRS_DL_CS1);
-		rate_ctr_inc(&m_dl_gprs_ctrs->ctr[TBF_CTR_GPRS_DL_CS1]);
+		rate_ctr_inc(rate_ctr_group_get_ctr(m_dl_gprs_ctrs, TBF_CTR_GPRS_DL_CS1));
 		break;
 	case CS2:
 		bts_do_rate_ctr_inc(bts, CTR_GPRS_DL_CS2);
-		rate_ctr_inc(&m_dl_gprs_ctrs->ctr[TBF_CTR_GPRS_DL_CS2]);
+		rate_ctr_inc(rate_ctr_group_get_ctr(m_dl_gprs_ctrs, TBF_CTR_GPRS_DL_CS2));
 		break;
 	case CS3:
 		bts_do_rate_ctr_inc(bts, CTR_GPRS_DL_CS3);
-		rate_ctr_inc(&m_dl_gprs_ctrs->ctr[TBF_CTR_GPRS_DL_CS3]);
+		rate_ctr_inc(rate_ctr_group_get_ctr(m_dl_gprs_ctrs, TBF_CTR_GPRS_DL_CS3));
 		break;
 	case CS4:
 		bts_do_rate_ctr_inc(bts, CTR_GPRS_DL_CS4);
-		rate_ctr_inc(&m_dl_gprs_ctrs->ctr[TBF_CTR_GPRS_DL_CS4]);
+		rate_ctr_inc(rate_ctr_group_get_ctr(m_dl_gprs_ctrs, TBF_CTR_GPRS_DL_CS4));
 		break;
 	case MCS1:
 		bts_do_rate_ctr_inc(bts, CTR_EGPRS_DL_MCS1);
-		rate_ctr_inc(&m_dl_egprs_ctrs->ctr[TBF_CTR_EGPRS_DL_MCS1]);
+		rate_ctr_inc(rate_ctr_group_get_ctr(m_dl_egprs_ctrs, TBF_CTR_EGPRS_DL_MCS1));
 		break;
 	case MCS2:
 		bts_do_rate_ctr_inc(bts, CTR_EGPRS_DL_MCS2);
-		rate_ctr_inc(&m_dl_egprs_ctrs->ctr[TBF_CTR_EGPRS_DL_MCS2]);
+		rate_ctr_inc(rate_ctr_group_get_ctr(m_dl_egprs_ctrs, TBF_CTR_EGPRS_DL_MCS2));
 		break;
 	case MCS3:
 		bts_do_rate_ctr_inc(bts, CTR_EGPRS_DL_MCS3);
-		rate_ctr_inc(&m_dl_egprs_ctrs->ctr[TBF_CTR_EGPRS_DL_MCS3]);
+		rate_ctr_inc(rate_ctr_group_get_ctr(m_dl_egprs_ctrs, TBF_CTR_EGPRS_DL_MCS3));
 		break;
 	case MCS4:
 		bts_do_rate_ctr_inc(bts, CTR_EGPRS_DL_MCS4);
-		rate_ctr_inc(&m_dl_egprs_ctrs->ctr[TBF_CTR_EGPRS_DL_MCS4]);
+		rate_ctr_inc(rate_ctr_group_get_ctr(m_dl_egprs_ctrs, TBF_CTR_EGPRS_DL_MCS4));
 		break;
 	case MCS5:
 		bts_do_rate_ctr_inc(bts, CTR_EGPRS_DL_MCS5);
-		rate_ctr_inc(&m_dl_egprs_ctrs->ctr[TBF_CTR_EGPRS_DL_MCS5]);
+		rate_ctr_inc(rate_ctr_group_get_ctr(m_dl_egprs_ctrs, TBF_CTR_EGPRS_DL_MCS5));
 		break;
 	case MCS6:
 		bts_do_rate_ctr_inc(bts, CTR_EGPRS_DL_MCS6);
-		rate_ctr_inc(&m_dl_egprs_ctrs->ctr[TBF_CTR_EGPRS_DL_MCS6]);
+		rate_ctr_inc(rate_ctr_group_get_ctr(m_dl_egprs_ctrs, TBF_CTR_EGPRS_DL_MCS6));
 		break;
 	case MCS7:
 		bts_do_rate_ctr_inc(bts, CTR_EGPRS_DL_MCS7);
-		rate_ctr_inc(&m_dl_egprs_ctrs->ctr[TBF_CTR_EGPRS_DL_MCS7]);
+		rate_ctr_inc(rate_ctr_group_get_ctr(m_dl_egprs_ctrs, TBF_CTR_EGPRS_DL_MCS7));
 		break;
 	case MCS8:
 		bts_do_rate_ctr_inc(bts, CTR_EGPRS_DL_MCS8);
-		rate_ctr_inc(&m_dl_egprs_ctrs->ctr[TBF_CTR_EGPRS_DL_MCS8]);
+		rate_ctr_inc(rate_ctr_group_get_ctr(m_dl_egprs_ctrs, TBF_CTR_EGPRS_DL_MCS8));
 		break;
 	case MCS9:
 		bts_do_rate_ctr_inc(bts, CTR_EGPRS_DL_MCS9);
-		rate_ctr_inc(&m_dl_egprs_ctrs->ctr[TBF_CTR_EGPRS_DL_MCS9]);
+		rate_ctr_inc(rate_ctr_group_get_ctr(m_dl_egprs_ctrs, TBF_CTR_EGPRS_DL_MCS9));
 		break;
 	default:
 		LOGPTBFDL(this, LOGL_ERROR, "attempting to update rate counters for unsupported (M)CS %s\n",
diff --git a/src/tbf_ul.cpp b/src/tbf_ul.cpp
index 9cbb9fb..b5f9f01 100644
--- a/src/tbf_ul.cpp
+++ b/src/tbf_ul.cpp
@@ -743,55 +743,55 @@
 	switch (cs) {
 	case CS1:
 		bts_do_rate_ctr_inc(bts, CTR_GPRS_UL_CS1);
-		rate_ctr_inc(&m_ul_gprs_ctrs->ctr[TBF_CTR_GPRS_UL_CS1]);
+		rate_ctr_inc(rate_ctr_group_get_ctr(m_ul_gprs_ctrs, TBF_CTR_GPRS_UL_CS1));
 		break;
 	case CS2:
 		bts_do_rate_ctr_inc(bts, CTR_GPRS_UL_CS2);
-		rate_ctr_inc(&m_ul_gprs_ctrs->ctr[TBF_CTR_GPRS_UL_CS2]);
+		rate_ctr_inc(rate_ctr_group_get_ctr(m_ul_gprs_ctrs, TBF_CTR_GPRS_UL_CS2));
 		break;
 	case CS3:
 		bts_do_rate_ctr_inc(bts, CTR_GPRS_UL_CS3);
-		rate_ctr_inc(&m_ul_gprs_ctrs->ctr[TBF_CTR_GPRS_UL_CS3]);
+		rate_ctr_inc(rate_ctr_group_get_ctr(m_ul_gprs_ctrs, TBF_CTR_GPRS_UL_CS3));
 		break;
 	case CS4:
 		bts_do_rate_ctr_inc(bts, CTR_GPRS_UL_CS4);
-		rate_ctr_inc(&m_ul_gprs_ctrs->ctr[TBF_CTR_GPRS_UL_CS4]);
+		rate_ctr_inc(rate_ctr_group_get_ctr(m_ul_gprs_ctrs, TBF_CTR_GPRS_UL_CS4));
 		break;
 	case MCS1:
 		bts_do_rate_ctr_inc(bts, CTR_EGPRS_UL_MCS1);
-		rate_ctr_inc(&m_ul_egprs_ctrs->ctr[TBF_CTR_EGPRS_UL_MCS1]);
+		rate_ctr_inc(rate_ctr_group_get_ctr(m_ul_egprs_ctrs, TBF_CTR_EGPRS_UL_MCS1));
 		break;
 	case MCS2:
 		bts_do_rate_ctr_inc(bts, CTR_EGPRS_UL_MCS2);
-		rate_ctr_inc(&m_ul_egprs_ctrs->ctr[TBF_CTR_EGPRS_UL_MCS2]);
+		rate_ctr_inc(rate_ctr_group_get_ctr(m_ul_egprs_ctrs, TBF_CTR_EGPRS_UL_MCS2));
 		break;
 	case MCS3:
 		bts_do_rate_ctr_inc(bts, CTR_EGPRS_UL_MCS3);
-		rate_ctr_inc(&m_ul_egprs_ctrs->ctr[TBF_CTR_EGPRS_UL_MCS3]);
+		rate_ctr_inc(rate_ctr_group_get_ctr(m_ul_egprs_ctrs, TBF_CTR_EGPRS_UL_MCS3));
 		break;
 	case MCS4:
 		bts_do_rate_ctr_inc(bts, CTR_EGPRS_UL_MCS4);
-		rate_ctr_inc(&m_ul_egprs_ctrs->ctr[TBF_CTR_EGPRS_UL_MCS4]);
+		rate_ctr_inc(rate_ctr_group_get_ctr(m_ul_egprs_ctrs, TBF_CTR_EGPRS_UL_MCS4));
 		break;
 	case MCS5:
 		bts_do_rate_ctr_inc(bts, CTR_EGPRS_UL_MCS5);
-		rate_ctr_inc(&m_ul_egprs_ctrs->ctr[TBF_CTR_EGPRS_UL_MCS5]);
+		rate_ctr_inc(rate_ctr_group_get_ctr(m_ul_egprs_ctrs, TBF_CTR_EGPRS_UL_MCS5));
 		break;
 	case MCS6:
 		bts_do_rate_ctr_inc(bts, CTR_EGPRS_UL_MCS6);
-		rate_ctr_inc(&m_ul_egprs_ctrs->ctr[TBF_CTR_EGPRS_UL_MCS6]);
+		rate_ctr_inc(rate_ctr_group_get_ctr(m_ul_egprs_ctrs, TBF_CTR_EGPRS_UL_MCS6));
 		break;
 	case MCS7:
 		bts_do_rate_ctr_inc(bts, CTR_EGPRS_UL_MCS7);
-		rate_ctr_inc(&m_ul_egprs_ctrs->ctr[TBF_CTR_EGPRS_UL_MCS7]);
+		rate_ctr_inc(rate_ctr_group_get_ctr(m_ul_egprs_ctrs, TBF_CTR_EGPRS_UL_MCS7));
 		break;
 	case MCS8:
 		bts_do_rate_ctr_inc(bts, CTR_EGPRS_UL_MCS8);
-		rate_ctr_inc(&m_ul_egprs_ctrs->ctr[TBF_CTR_EGPRS_UL_MCS8]);
+		rate_ctr_inc(rate_ctr_group_get_ctr(m_ul_egprs_ctrs, TBF_CTR_EGPRS_UL_MCS8));
 		break;
 	case MCS9:
 		bts_do_rate_ctr_inc(bts, CTR_EGPRS_UL_MCS9);
-		rate_ctr_inc(&m_ul_egprs_ctrs->ctr[TBF_CTR_EGPRS_UL_MCS9]);
+		rate_ctr_inc(rate_ctr_group_get_ctr(m_ul_egprs_ctrs, TBF_CTR_EGPRS_UL_MCS9));
 		break;
 	default:
 		LOGPTBFUL(this, LOGL_ERROR, "attempting to update rate counters for unsupported (M)CS %s\n",

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-pcu/+/24546
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Change-Id: I600c7a8725f5b229b1a2feb879da7c3b2dce4505
Gerrit-Change-Number: 24546
Gerrit-PatchSet: 2
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210604/6615d3cb/attachment.htm>


More information about the gerrit-log mailing list