From d3c75913049cf4d328b322beb532b4adbb302f83 Mon Sep 17 00:00:00 2001 From: Oliver Smith Date: Fri, 9 Jul 2021 16:37:16 +0200 Subject: [PATCH] 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 --- src/Makefile.am | 2 ++ src/bts.cpp | 3 ++ src/bts.h | 4 +++ src/bts_pch_timer.c | 85 +++++++++++++++++++++++++++++++++++++++++++++ src/bts_pch_timer.h | 43 +++++++++++++++++++++++ src/gprs_pcu.c | 1 + src/gprs_rlcmac.cpp | 2 ++ src/tbf_ul.cpp | 2 ++ 8 files changed, 142 insertions(+) create mode 100644 src/bts_pch_timer.c create mode 100644 src/bts_pch_timer.h 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 @@ libgprs_la_SOURCES = \ tbf_ul.cpp \ tbf_dl.cpp \ bts.cpp \ + bts_pch_timer.c \ pdch.cpp \ pdch_ul_controller.c \ encoding.cpp \ @@ -101,6 +102,7 @@ noinst_HEADERS = \ 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 @@ static const struct rate_ctr_desc bts_ctr_description[] = { { "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 @@ struct gprs_rlcmac_bts* bts_alloc(struct gprs_pcu *pcu, uint8_t bts_nr) 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 @@ enum { 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 gprs_rlcmac_bts { 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 + * 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 . + * + */ +#include + +#include +#include +#include +#include + +#include +#include +#include + +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 + * 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 . + */ + +#pragma once + +#include +#include +#include + +#include + +#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 @@ extern "C" { #include #include #include +#include #include #include #include @@ -48,6 +49,7 @@ int gprs_rlcmac_paging_request(struct gprs_rlcmac_bts *bts, const struct osmo_mo 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 +#include #include #include #include @@ -494,6 +495,7 @@ int gprs_rlcmac_ul_tbf::rcv_data_block_acknowledged( "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",