aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2021-01-18 14:05:40 +0100
committerPau Espin Pedrol <pespin@sysmocom.de>2021-01-19 16:28:13 +0100
commit4a5209d8bc21940264754ca1c72f082e8f9052c0 (patch)
treed99532295f784ec8c11d726da1f02aae6cd7a9f3 /src
parent289f90048b04f1a6741ea948cb00d78c07346108 (diff)
Get rid of unused gsm_timer.{cpp,h}
Those files are not really being used other than for calling get_current_fn() which is just a placeholder to call bts_current_frame_number on the global bts object. Change-Id: I6d50a8c15c1de5e2a308a24b313a7776f94ae54f
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am2
-rw-r--r--src/gprs_rlcmac.h1
-rw-r--r--src/gsm_timer.cpp234
-rw-r--r--src/gsm_timer.h90
-rw-r--r--src/pcu_l1_if.cpp10
-rw-r--r--src/pcu_main.cpp5
-rw-r--r--src/tbf.cpp6
-rw-r--r--src/tbf.h2
8 files changed, 7 insertions, 343 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index c9c7aa3d..05fac55f 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -50,7 +50,6 @@ libgprs_la_SOURCES = \
gprs_ms.c \
gprs_ms_storage.cpp \
gprs_pcu.c \
- gsm_timer.cpp \
pcu_l1_if.cpp \
pcu_vty.c \
pcu_vty_functions.cpp \
@@ -87,7 +86,6 @@ noinst_HEADERS = \
gprs_ms_storage.h \
gprs_pcu.h \
pcu_l1_if.h \
- gsm_timer.h \
pcu_vty.h \
pcu_vty_functions.h \
mslot_class.h \
diff --git a/src/gprs_rlcmac.h b/src/gprs_rlcmac.h
index 3d5ea996..d779d089 100644
--- a/src/gprs_rlcmac.h
+++ b/src/gprs_rlcmac.h
@@ -24,7 +24,6 @@
#include <stdbool.h>
#ifdef __cplusplus
-#include <gsm_timer.h>
#include <pcu_l1_if.h>
extern "C" {
diff --git a/src/gsm_timer.cpp b/src/gsm_timer.cpp
deleted file mode 100644
index 0627753c..00000000
--- a/src/gsm_timer.cpp
+++ /dev/null
@@ -1,234 +0,0 @@
-/* gsm_timer.cpp
- *
- * Copyright (C) 2012 Ivan Klyuchnikov
- *
- * 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 General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-/* These store the amount of frame number that we wait until next timer expires. */
-static int nearest;
-static int *nearest_p;
-
-/*! \addtogroup gsm_timer
- * @{
- */
-
-/*! \file gsm_timer.cpp
- */
-
-#include <assert.h>
-#include <string.h>
-#include <limits.h>
-#include <gsm_timer.h>
-#include <pcu_l1_if.h>
-#include <bts.h>
-
-
-static struct rb_root timer_root = RB_ROOT;
-
-/*
- * TODO: make this depend on the BTS. This means that
- * all time functions schedule based on the BTS they
- * are scheduled on.
- */
-int get_current_fn()
-{
- return bts_current_frame_number(the_pcu->bts);
-}
-
-static void __add_gsm_timer(struct osmo_gsm_timer_list *timer)
-{
- struct rb_node **new_node = &(timer_root.rb_node);
- struct rb_node *parent = NULL;
-
- while (*new_node) {
- struct osmo_gsm_timer_list *this_timer;
-
- this_timer = container_of(*new_node, struct osmo_gsm_timer_list, node);
-
- parent = *new_node;
- if (timer->fn < this_timer->fn)
- new_node = &((*new_node)->rb_left);
- else
- new_node = &((*new_node)->rb_right);
- }
-
- rb_link_node(&timer->node, parent, new_node);
- rb_insert_color(&timer->node, &timer_root);
-}
-
-/*! \brief add a new timer to the timer management
- * \param[in] timer the timer that should be added
- */
-void osmo_gsm_timer_add(struct osmo_gsm_timer_list *timer)
-{
- osmo_gsm_timer_del(timer);
- timer->active = 1;
- INIT_LLIST_HEAD(&timer->list);
- __add_gsm_timer(timer);
-}
-
-/*! \brief schedule a gsm timer at a given future relative time
- * \param[in] timer the to-be-added timer
- * \param[in] number of frames from now
- *
- * This function can be used to (re-)schedule a given timer at a
- * specified number of frames in the future. It will
- * internally add it to the timer management data structures, thus
- * osmo_timer_add() is automatically called.
- */
-void
-osmo_gsm_timer_schedule(struct osmo_gsm_timer_list *timer, int fn)
-{
- int current_fn;
-
- current_fn = get_current_fn();
- timer->fn = current_fn + fn;
- osmo_gsm_timer_add(timer);
-}
-
-/*! \brief delete a gsm timer from timer management
- * \param[in] timer the to-be-deleted timer
- *
- * This function can be used to delete a previously added/scheduled
- * timer from the timer management code.
- */
-void osmo_gsm_timer_del(struct osmo_gsm_timer_list *timer)
-{
- if (timer->active) {
- timer->active = 0;
- rb_erase(&timer->node, &timer_root);
- /* make sure this is not already scheduled for removal. */
- if (!llist_empty(&timer->list))
- llist_del_init(&timer->list);
- }
-}
-
-/*! \brief check if given timer is still pending
- * \param[in] timer the to-be-checked timer
- * \return 1 if pending, 0 otherwise
- *
- * This function can be used to determine whether a given timer
- * has alredy expired (returns 0) or is still pending (returns 1)
- */
-int osmo_gsm_timer_pending(struct osmo_gsm_timer_list *timer)
-{
- return timer->active;
-}
-
-/*
- * if we have a nearest frame number return the delta between the current
- * FN and the FN of the nearest timer.
- * If the nearest timer timed out return NULL and then we will
- * dispatch everything after the select
- */
-int *osmo_gsm_timers_nearest(void)
-{
- /* nearest_p is exactly what we need already: NULL if nothing is
- * waiting, {0,0} if we must dispatch immediately, and the correct
- * delay if we need to wait */
- return nearest_p;
-}
-
-static void update_nearest(int *cand, int *current)
-{
- if (*cand > *current)
- nearest = *cand - *current;
- else {
- /* loop again inmediately */
- nearest = 0;
- }
-
- nearest_p = &nearest;
-}
-
-/*
- * Find the nearest FN and update s_nearest_time
- */
-void osmo_gsm_timers_prepare(void)
-{
- struct rb_node *node;
- int current_fn;
-
- current_fn = get_current_fn();
-
- node = rb_first(&timer_root);
- if (node) {
- struct osmo_gsm_timer_list *this_timer;
- this_timer = container_of(node, struct osmo_gsm_timer_list, node);
- update_nearest(&this_timer->fn, &current_fn);
- } else {
- nearest_p = NULL;
- }
-}
-
-/*
- * fire all timers... and remove them
- */
-int osmo_gsm_timers_update(void)
-{
- int current_fn;
- struct rb_node *node;
- struct llist_head timer_eviction_list;
- struct osmo_gsm_timer_list *this_timer;
- int work = 0;
-
- current_fn = get_current_fn();
-
- INIT_LLIST_HEAD(&timer_eviction_list);
- for (node = rb_first(&timer_root); node; node = rb_next(node)) {
- this_timer = container_of(node, struct osmo_gsm_timer_list, node);
-
- if (this_timer->fn > current_fn)
- break;
-
- llist_add(&this_timer->list, &timer_eviction_list);
- }
-
- /*
- * The callbacks might mess with our list and in this case
- * even llist_for_each_entry_safe is not safe to use. To allow
- * osmo_gsm_timer_del to be called from within the callback we need
- * to restart the iteration for each element scheduled for removal.
- *
- * The problematic scenario is the following: Given two timers A
- * and B that have expired at the same time. Thus, they are both
- * in the eviction list in this order: A, then B. If we remove
- * timer B from the A's callback, we continue with B in the next
- * iteration step, leading to an access-after-release.
- */
-restart:
- llist_for_each_entry(this_timer, &timer_eviction_list, list) {
- osmo_gsm_timer_del(this_timer);
- this_timer->cb(this_timer->data);
- work = 1;
- goto restart;
- }
-
- return work;
-}
-
-int osmo_gsm_timers_check(void)
-{
- struct rb_node *node;
- int i = 0;
-
- for (node = rb_first(&timer_root); node; node = rb_next(node)) {
- i++;
- }
- return i;
-}
-
-/*! }@ */
diff --git a/src/gsm_timer.h b/src/gsm_timer.h
deleted file mode 100644
index cfabd0cc..00000000
--- a/src/gsm_timer.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/* gsm_timer.h
- *
- * Copyright (C) 2012 Ivan Klyuchnikov
- *
- * 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 General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-/*! \defgroup timer GSM timers
- * @{
- */
-
-/*! \file gsm_timer.h
- * \brief GSM timer handling routines
- */
-#ifndef GSM_TIMER_H
-#define GSM_TIMER_H
-
-extern "C" {
-#include <osmocom/core/linuxlist.h>
-#include <osmocom/core/linuxrbtree.h>
-}
-/**
- * Timer management:
- * - Create a struct osmo_gsm_timer_list
- * - Fill out timeout and use add_gsm_timer or
- * use schedule_gsm_timer to schedule a timer in
- * x frames from now...
- * - Use del_gsm_timer to remove the timer
- *
- * Internally:
- * - We hook into select.c to give a frame number of the
- * nearest timer. On already passed timers we give
- * it a 0 to immediately fire after the select.
- * - update_gsm_timers will call the callbacks and remove
- * the timers.
- *
- */
-/*! \brief A structure representing a single instance of a gsm timer */
-struct osmo_gsm_timer_list {
- struct rb_node node; /*!< \brief rb-tree node header */
- struct llist_head list; /*!< \brief internal list header */
- int fn; /*!< \brief expiration frame number */
- unsigned int active : 1; /*!< \brief is it active? */
-
- void (*cb)(void*); /*!< \brief call-back called at timeout */
- void *data; /*!< \brief user data for callback */
-};
-
-/**
- * timer management
- */
-
-void osmo_gsm_timer_add(struct osmo_gsm_timer_list *timer);
-
-void osmo_gsm_timer_schedule(struct osmo_gsm_timer_list *timer, int fn);
-
-void osmo_gsm_timer_del(struct osmo_gsm_timer_list *timer);
-
-int osmo_gsm_timer_pending(struct osmo_gsm_timer_list *timer);
-
-
-/*
- * internal timer list management
- */
-int *osmo_gsm_timers_nearest(void);
-void osmo_gsm_timers_prepare(void);
-int osmo_gsm_timers_update(void);
-int osmo_gsm_timers_check(void);
-
-
-/*
- * Get Current Frame Number
- */
-int get_current_fn();
-
-/*! }@ */
-
-#endif // GSM_TIMER_H
diff --git a/src/pcu_l1_if.cpp b/src/pcu_l1_if.cpp
index e5ad1dea..88479601 100644
--- a/src/pcu_l1_if.cpp
+++ b/src/pcu_l1_if.cpp
@@ -173,7 +173,7 @@ static int pcu_tx_data_req(uint8_t trx, uint8_t ts, uint8_t sapi,
struct msgb *msg;
struct gsm_pcu_if *pcu_prim;
struct gsm_pcu_if_data *data_req;
- int current_fn = get_current_fn();
+ int current_fn = bts_current_frame_number(the_pcu->bts);
LOGP(DL1IF, LOGL_DEBUG, "Sending data request: trx=%d ts=%d sapi=%d "
"arfcn=%d fn=%d cur_fn=%d block=%d data=%s\n", trx, ts, sapi, arfcn, fn, current_fn,
@@ -314,7 +314,7 @@ static int pcu_rx_data_ind_bcch(uint8_t *data, uint8_t len)
static int pcu_rx_data_ind(struct gsm_pcu_if_data *data_ind)
{
int rc;
- int current_fn = get_current_fn();
+ int current_fn = bts_current_frame_number(the_pcu->bts);
struct pcu_l1_meas meas = {0};
uint8_t gsmtap_chantype;
@@ -361,7 +361,7 @@ static int pcu_rx_data_ind(struct gsm_pcu_if_data *data_ind)
static int pcu_rx_data_cnf(struct gsm_pcu_if_data *data_cnf)
{
int rc = 0;
- int current_fn = get_current_fn();
+ int current_fn = bts_current_frame_number(the_pcu->bts);
LOGP(DL1IF, LOGL_DEBUG, "Data confirm received: sapi=%d fn=%d cur_fn=%d\n",
data_cnf->sapi, data_cnf->fn, current_fn);
@@ -410,7 +410,7 @@ extern "C" int pcu_rx_rts_req_ptcch(uint8_t trx, uint8_t ts,
static int pcu_rx_rts_req(struct gsm_pcu_if_rts_req *rts_req)
{
int rc = 0;
- int current_fn = get_current_fn();
+ int current_fn = bts_current_frame_number(the_pcu->bts);
LOGP(DL1IF, LOGL_DEBUG, "RTS request received: trx=%d ts=%d sapi=%d "
"arfcn=%d fn=%d cur_fn=%d block=%d\n", rts_req->trx_nr, rts_req->ts_nr,
@@ -454,7 +454,7 @@ extern "C" int pcu_rx_rach_ind_ptcch(uint8_t trx_nr, uint8_t ts_nr, uint32_t fn,
static int pcu_rx_rach_ind(const struct gsm_pcu_if_rach_ind *rach_ind)
{
int rc = 0;
- int current_fn = get_current_fn();
+ int current_fn = bts_current_frame_number(the_pcu->bts);
LOGP(DL1IF, LOGL_INFO, "RACH request received: sapi=%d "
"qta=%d, ra=0x%02x, fn=%u, cur_fn=%d, is_11bit=%d\n", rach_ind->sapi, rach_ind->qta,
diff --git a/src/pcu_main.cpp b/src/pcu_main.cpp
index 8bb7c1fe..23d16a36 100644
--- a/src/pcu_main.cpp
+++ b/src/pcu_main.cpp
@@ -19,7 +19,6 @@
#include <pcu_l1_if.h>
#include <gprs_rlcmac.h>
-#include <gsm_timer.h>
#include <gprs_debug.h>
#include <unistd.h>
#include <stdbool.h>
@@ -331,10 +330,6 @@ int main(int argc, char *argv[])
}
while (!quit) {
- osmo_gsm_timers_check();
- osmo_gsm_timers_prepare();
- osmo_gsm_timers_update();
-
osmo_select_main(0);
}
diff --git a/src/tbf.cpp b/src/tbf.cpp
index 3464242b..859ebcda 100644
--- a/src/tbf.cpp
+++ b/src/tbf.cpp
@@ -34,7 +34,6 @@
#include <pcu_utils.h>
#include <gprs_ms_storage.h>
#include <sba.h>
-#include <gsm_timer.h>
#include <pdch.h>
extern "C" {
@@ -154,7 +153,6 @@ gprs_rlcmac_tbf::gprs_rlcmac_tbf(struct gprs_rlcmac_bts *bts_, GprsMs *ms, gprs_
memset(&pdch, 0, sizeof(pdch));
memset(&Tarr, 0, sizeof(Tarr));
memset(&Narr, 0, sizeof(Narr));
- memset(&gsm_timer, 0, sizeof(gsm_timer));
memset(&m_ms_list, 0, sizeof(m_ms_list));
m_ms_list.entry = this;
@@ -483,7 +481,7 @@ T_CBACK(T3195, true)
void gprs_rlcmac_tbf::t_start(enum tbf_timers t, int T, const char *reason, bool force,
const char *file, unsigned line)
{
- int current_fn = get_current_fn();
+ int current_fn = bts_current_frame_number(bts);
int sec;
int microsec;
struct osmo_tdef *tdef;
@@ -777,7 +775,7 @@ static void tbf_timer_cb(void *_tbf)
void gprs_rlcmac_tbf::handle_timeout()
{
- int current_fn = get_current_fn();
+ int current_fn = bts_current_frame_number(bts);
LOGPTBF(this, LOGL_DEBUG, "timer 0 expired. cur_fn=%d\n", current_fn);
diff --git a/src/tbf.h b/src/tbf.h
index 73266bf4..460de701 100644
--- a/src/tbf.h
+++ b/src/tbf.h
@@ -27,7 +27,6 @@
#include "cxx_linuxlist.h"
#include "pcu_utils.h"
#include <gprs_debug.h>
-#include <gsm_timer.h>
#include <stdint.h>
struct bssgp_bvc_ctx;
@@ -313,7 +312,6 @@ struct gprs_rlcmac_tbf {
gprs_rlc m_rlc;
- struct osmo_gsm_timer_list gsm_timer;
unsigned int fT; /* fTxxxx number */
unsigned int num_fT_exp; /* number of consecutive fT expirations */