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

Change subject: Add counters: pcu.bts.N.pch.requests.timeout
......................................................................

Add counters: pcu.bts.N.pch.requests.timeout

Implement T3113 for paging over PCH with default value of 7s (same as
T3113 in OsmoBSC). Increase the new counter on timeout.

Related: SYS#4878
Change-Id: I97475c3dbe2cf00b9cbfec39e93a3c65cb7f749f
---
M src/Makefile.am
M src/bts.cpp
M src/bts.h
A src/bts_pch_timer.c
A src/bts_pch_timer.h
M src/gprs_pcu.c
M src/gprs_rlcmac.cpp
M src/tbf_ul.cpp
8 files changed, 142 insertions(+), 0 deletions(-)

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



diff --git a/src/Makefile.am b/src/Makefile.am
index 8070fda..f05daaf 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -62,6 +62,7 @@
        tbf_ul.cpp \
        tbf_dl.cpp \
        bts.cpp \
+       bts_pch_timer.c \
        pdch.cpp \
        pdch_ul_controller.c \
        encoding.cpp \
@@ -101,6 +102,7 @@
        tbf_ul.h \
        tbf_dl.h \
        bts.h \
+       bts_pch_timer.h \
        pdch.h \
        pdch_ul_controller.h \
        encoding.h \
diff --git a/src/bts.cpp b/src/bts.cpp
index 4e3b770..a96fe24 100644
--- a/src/bts.cpp
+++ b/src/bts.cpp
@@ -133,6 +133,7 @@
        { "llc:dl_bytes",               "RLC encapsulated PDUs"},
        { "llc:ul_bytes",               "full PDUs received   "},
        { "pch:requests",               "PCH requests sent    "},
+       { "pch:requests:timeout",       "PCH requests timeout "},
        { "rach:requests",              "RACH requests received"},
        { "11bit_rach:requests",        "11BIT_RACH requests received"},
        { "spb:uplink_first_segment",   "First seg of UL SPB  "},
@@ -283,6 +284,8 @@

        llist_add_tail(&bts->list, &pcu->bts_list);

+       INIT_LLIST_HEAD(&bts->pch_timer);
+
        return bts;
 }

diff --git a/src/bts.h b/src/bts.h
index c28bd97..5e45527 100644
--- a/src/bts.h
+++ b/src/bts.h
@@ -126,6 +126,7 @@
        CTR_LLC_DL_BYTES,
        CTR_LLC_UL_BYTES,
        CTR_PCH_REQUESTS,
+       CTR_PCH_REQUESTS_TIMEDOUT,
        CTR_RACH_REQUESTS,
        CTR_11BIT_RACH_REQUESTS,
        CTR_SPB_UL_FIRST_SEGMENT,
@@ -263,6 +264,9 @@
        struct osmo_stat_item_group *statg;

        struct GprsMsStorage *ms_store;
+
+       /* List of struct bts_pch_timer for active PCH pagings */
+       struct llist_head pch_timer;
 };

 #ifdef __cplusplus
diff --git a/src/bts_pch_timer.c b/src/bts_pch_timer.c
new file mode 100644
index 0000000..386a583
--- /dev/null
+++ b/src/bts_pch_timer.c
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2021 by sysmocom - s.f.m.c. GmbH <i...@sysmocom.de>
+ * Author: Oliver Smith
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+#include <string.h>
+
+#include <osmocom/core/logging.h>
+#include <osmocom/core/talloc.h>
+#include <osmocom/core/tdef.h>
+#include <osmocom/core/utils.h>
+
+#include <gprs_debug.h>
+#include <gprs_pcu.h>
+#include <bts_pch_timer.h>
+
+static struct bts_pch_timer *bts_pch_timer_get(struct gprs_rlcmac_bts *bts, 
const char *imsi)
+{
+       struct bts_pch_timer *p;
+
+       llist_for_each_entry(p, &bts->pch_timer, entry) {
+               if (strcmp(p->imsi, imsi) == 0)
+                       return p;
+       }
+
+       return NULL;
+}
+
+static void bts_pch_timer_remove(struct bts_pch_timer *p)
+{
+       osmo_timer_del(&p->T3113);
+       llist_del(&p->entry);
+
+       LOGP(DPCU, LOGL_DEBUG, "PCH paging timer stopped for IMSI=%s\n", 
p->imsi);
+       talloc_free(p);
+}
+
+static void T3113_callback(void *data)
+{
+       struct bts_pch_timer *p = data;
+
+       LOGP(DPCU, LOGL_INFO, "PCH paging timeout for IMSI=%s\n", p->imsi);
+       bts_do_rate_ctr_inc(p->bts, CTR_PCH_REQUESTS_TIMEDOUT);
+       bts_pch_timer_remove(p);
+}
+
+void bts_pch_timer_start(struct gprs_rlcmac_bts *bts, const char *imsi)
+{
+       if (bts_pch_timer_get(bts, imsi))
+               return;
+
+       struct bts_pch_timer *p;
+       p = talloc_zero(bts, struct bts_pch_timer);
+       llist_add_tail(&p->entry, &bts->pch_timer);
+       osmo_strlcpy(p->imsi, imsi, sizeof(p->imsi));
+       p->bts = bts;
+
+       struct osmo_tdef *tdef = osmo_tdef_get_entry(the_pcu->T_defs, 3113);
+       OSMO_ASSERT(tdef);
+       osmo_timer_setup(&p->T3113, T3113_callback, p);
+       osmo_timer_schedule(&p->T3113, tdef->val, 0);
+
+       LOGP(DPCU, LOGL_DEBUG, "PCH paging timer started for IMSI=%s\n", 
p->imsi);
+}
+
+void bts_pch_timer_stop(struct gprs_rlcmac_bts *bts, const char *imsi)
+{
+       struct bts_pch_timer *p = bts_pch_timer_get(bts, imsi);
+
+       if (p)
+               bts_pch_timer_remove(p);
+}
diff --git a/src/bts_pch_timer.h b/src/bts_pch_timer.h
new file mode 100644
index 0000000..91bebed
--- /dev/null
+++ b/src/bts_pch_timer.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2021 by sysmocom - s.f.m.c. GmbH <i...@sysmocom.de>
+ * Author: Oliver Smith
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+#include <osmocom/core/linuxlist.h>
+#include <osmocom/core/timer.h>
+#include <osmocom/gsm/protocol/gsm_23_003.h>
+
+#include <bts.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct bts_pch_timer {
+       struct llist_head entry;
+       struct gprs_rlcmac_bts *bts;
+       struct osmo_timer_list T3113;
+       char imsi[OSMO_IMSI_BUF_SIZE];
+};
+
+void bts_pch_timer_start(struct gprs_rlcmac_bts *bts, const char *imsi);
+void bts_pch_timer_stop(struct gprs_rlcmac_bts *bts, const char *imsi);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/src/gprs_pcu.c b/src/gprs_pcu.c
index 37563ec..a7bab8d 100644
--- a/src/gprs_pcu.c
+++ b/src/gprs_pcu.c
@@ -30,6 +30,7 @@
 struct gprs_pcu *the_pcu;

 static struct osmo_tdef T_defs_pcu[] = {
+       { .T=3113,  .default_val=7, .unit=OSMO_TDEF_S, .desc="Timeout for 
paging", .val=0 },
        { .T=3190,  .default_val=5,   .unit=OSMO_TDEF_S,  .desc="Return to 
packet idle mode after Packet DL Assignment on CCCH (s)", .val=0},
        { .T=3141,  .default_val=10, .unit=OSMO_TDEF_S, .desc="Timeout for 
contention resolution procedure (s)", .val=0 },
        { .T=PCU_TDEF_NEIGH_RESOLVE_TO,    .default_val=1000,  
.unit=OSMO_TDEF_MS,   .desc="[ARFCN+BSIC]->[RAC+CI] resolution timeout (ms)", 
.val=0 },
diff --git a/src/gprs_rlcmac.cpp b/src/gprs_rlcmac.cpp
index ffa656c..22b12df 100644
--- a/src/gprs_rlcmac.cpp
+++ b/src/gprs_rlcmac.cpp
@@ -26,6 +26,7 @@
 #include <pcu_l1_if.h>
 #include <gprs_rlcmac.h>
 #include <bts.h>
+#include <bts_pch_timer.h>
 #include <encoding.h>
 #include <tbf.h>
 #include <gprs_debug.h>
@@ -48,6 +49,7 @@
                return -1;
        }
        bts_do_rate_ctr_inc(bts, CTR_PCH_REQUESTS);
+       bts_pch_timer_start(bts, mi->imsi);
        pcu_l1if_tx_pch(bts, paging_request, plen, pgroup);
        bitvec_free(paging_request);

diff --git a/src/tbf_ul.cpp b/src/tbf_ul.cpp
index b5f9f01..5ca02d9 100644
--- a/src/tbf_ul.cpp
+++ b/src/tbf_ul.cpp
@@ -20,6 +20,7 @@
  */

 #include <bts.h>
+#include <bts_pch_timer.h>
 #include <tbf.h>
 #include <tbf_ul.h>
 #include <rlc.h>
@@ -494,6 +495,7 @@
                                          "Decoded premier TLLI=0x%08x of UL 
DATA TFI=%d.\n",
                                          new_tlli, rlc->tfi);
                                update_ms(new_tlli, GPRS_RLCMAC_UL_TBF);
+                               bts_pch_timer_stop(bts, ms_imsi(ms()));
                        } else if (new_tlli != GSM_RESERVED_TMSI && new_tlli != 
tlli()) {
                                LOGPTBFUL(this, LOGL_NOTICE,
                                          "Decoded TLLI=%08x mismatch on UL 
DATA TFI=%d. (Ignoring due to contention resolution)\n",

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

Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Change-Id: I97475c3dbe2cf00b9cbfec39e93a3c65cb7f749f
Gerrit-Change-Number: 25155
Gerrit-PatchSet: 4
Gerrit-Owner: osmith <osm...@sysmocom.de>
Gerrit-Reviewer: Hoernchen <ew...@sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <dwillm...@sysmocom.de>
Gerrit-Reviewer: dexter <pma...@sysmocom.de>
Gerrit-Reviewer: osmith <osm...@sysmocom.de>
Gerrit-MessageType: merged

Reply via email to