Change in osmo-pcu[master]: ms: Replace struct var with rate_ctr

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

laforge gerrit-no-reply at lists.osmocom.org
Tue Jan 12 18:01:53 UTC 2021


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

Change subject: ms: Replace struct var with rate_ctr
......................................................................

ms: Replace struct var with rate_ctr

Let's use usual osmocom rate_ctr instead of having one variable +
setter/getter functions, so we can easily add new counters and also
because it makes code more clear (no need to look at what the "update"
function is doing).

Using rate counter also provides info about how recently the MS has been
interacting with the network.

Related: OS#4907
Change-Id: I744507fde4291955c1dbbb9739b18a12a80145b1
---
M src/gprs_ms.c
M src/gprs_ms.h
M src/gprs_rlcmac_sched.cpp
M src/pcu_vty_functions.cpp
4 files changed, 33 insertions(+), 15 deletions(-)

Approvals:
  laforge: Looks good to me, but someone else must approve
  fixeria: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/gprs_ms.c b/src/gprs_ms.c
index 94f69cd..d57e9b6 100644
--- a/src/gprs_ms.c
+++ b/src/gprs_ms.c
@@ -35,11 +35,25 @@
 #include <osmocom/gsm/protocol/gsm_04_08.h>
 #include <osmocom/gsm/gsm48.h>
 #include <osmocom/core/logging.h>
+#include <osmocom/core/stats.h>
 #include "coding_scheme.h"
 
 #define GPRS_CODEL_SLOW_INTERVAL_MS 4000
 
 extern void *tall_pcu_ctx;
+static unsigned int next_ms_ctr_group_id;
+
+static const struct rate_ctr_desc ms_ctr_description[] = {
+	[MS_CTR_DL_CTRL_MSG_SCHED] = { "ms:dl_ctrl_msg_sched", "Amount of DL CTRL messages scheduled" },
+};
+
+const struct rate_ctr_group_desc ms_ctrg_desc = {
+	.group_name_prefix = "pcu:ms",
+	.group_description = "MS Statistics",
+	.class_id = OSMO_STATS_CLASS_SUBSCRIBER,
+	.num_ctr = ARRAY_SIZE(ms_ctr_description),
+	.ctr_desc = ms_ctr_description,
+};
 
 static int64_t now_msec()
 {
@@ -118,7 +132,15 @@
 	}
 	ms->last_cs_not_low = now_msec();
 	ms->app_info_pending = false;
+
+	ms->ctrs = rate_ctr_group_alloc(ms, &ms_ctrg_desc, next_ms_ctr_group_id++);
+	if (!ms->ctrs)
+		goto free_ret;
+
 	return ms;
+free_ret:
+	talloc_free(ms);
+	return NULL;
 }
 
 static int ms_talloc_destructor(struct GprsMs *ms)
@@ -148,6 +170,9 @@
 	}
 
 	llc_queue_clear(&ms->llc_queue, ms->bts);
+
+	if (ms->ctrs)
+		rate_ctr_group_free(ms->ctrs);
 	return 0;
 }
 
diff --git a/src/gprs_ms.h b/src/gprs_ms.h
index ade3f3b..6391f72 100644
--- a/src/gprs_ms.h
+++ b/src/gprs_ms.h
@@ -34,6 +34,7 @@
 
 #include <osmocom/core/timer.h>
 #include <osmocom/core/linuxlist.h>
+#include <osmocom/core/rate_ctr.h>
 
 #include <osmocom/gsm/protocol/gsm_23_003.h>
 #include <osmocom/gsm/gsm48.h>
@@ -44,6 +45,10 @@
 #include <stddef.h>
 #include <inttypes.h>
 
+enum ms_counter_id {
+	MS_CTR_DL_CTRL_MSG_SCHED,
+};
+
 struct BTS;
 struct gprs_rlcmac_trx;
 struct GprsMs;
@@ -94,7 +99,7 @@
 	struct gprs_codel *codel_state;
 	enum mcs_kind mode;
 
-	unsigned dl_ctrl_msg;
+	struct rate_ctr_group *ctrs;
 };
 
 struct GprsMs *ms_alloc(struct BTS *bts, uint32_t tlli);
@@ -215,16 +220,6 @@
 	return ms->nack_rate_dl;
 }
 
-static inline unsigned ms_dl_ctrl_msg(const struct GprsMs *ms)
-{
-	return ms->dl_ctrl_msg;
-}
-
-static inline void ms_update_dl_ctrl_msg(struct GprsMs *ms)
-{
-	ms->dl_ctrl_msg++;
-}
-
 static inline uint8_t ms_reserved_dl_slots(const struct GprsMs *ms)
 {
 	return ms->reserved_dl_slots;
diff --git a/src/gprs_rlcmac_sched.cpp b/src/gprs_rlcmac_sched.cpp
index d7958c4..924a4de 100644
--- a/src/gprs_rlcmac_sched.cpp
+++ b/src/gprs_rlcmac_sched.cpp
@@ -233,8 +233,7 @@
 		LOGP(DRLCMACSCHED, LOGL_DEBUG, "Scheduling control "
 			"message at RTS for %s (TRX=%d, TS=%d)\n",
 			tbf_name(tbf), trx, ts);
-		/* Updates the dl ctrl msg counter for ms */
-		ms_update_dl_ctrl_msg(tbf->ms());
+		rate_ctr_inc(&tbf->ms()->ctrs->ctr[MS_CTR_DL_CTRL_MSG_SCHED]);
 		return msg;
 	}
 
diff --git a/src/pcu_vty_functions.cpp b/src/pcu_vty_functions.cpp
index 6100b13..92be77b 100644
--- a/src/pcu_vty_functions.cpp
+++ b/src/pcu_vty_functions.cpp
@@ -175,8 +175,6 @@
 			vty_out(vty, "  MS I level (slot %d):    %d dB%s",
 				i, ms->l1_meas.ts[i].ms_i_level, VTY_NEWLINE);
 	}
-	vty_out(vty, "  RLC/MAC DL Control Msg: %d%s", ms_dl_ctrl_msg(ms),
-		VTY_NEWLINE);
 	if (ms_ul_tbf(ms))
 		vty_out(vty, "  Uplink TBF:             TFI=%d, state=%s%s",
 			ms_ul_tbf(ms)->tfi(),
@@ -201,6 +199,7 @@
 			tbf->state_name(),
 			VTY_NEWLINE);
 	}
+	vty_out_rate_ctr_group(vty, "  ", ms->ctrs);
 
 	return CMD_SUCCESS;
 }

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

Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Change-Id: I744507fde4291955c1dbbb9739b18a12a80145b1
Gerrit-Change-Number: 22102
Gerrit-PatchSet: 3
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <dwillmann at sysmocom.de>
Gerrit-Reviewer: fixeria <vyanitskiy at sysmocom.de>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: lynxis lazus <lynxis at fe80.eu>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210112/78db0b91/attachment.htm>


More information about the gerrit-log mailing list