aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2013-10-17 20:12:37 +0200
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2013-10-30 21:20:45 +0100
commitb78adcdd11ef0414c2594bada2a37d498d32f1ef (patch)
treecd0bff850d78d4b4f9c53fee407ac202c6feb854
parent9b30c7f46e2c55aed06cea8d1daa9093f331fb20 (diff)
bts: Introduce a PollController that has the responsibility to poll
For each frame indication received by the BTS the poll controller is asked to expire timedout entries.
-rw-r--r--src/Makefile.am6
-rw-r--r--src/bts.cpp4
-rw-r--r--src/bts.h8
-rw-r--r--src/pcu_l1_if.cpp31
-rw-r--r--src/poll_controller.cpp62
-rw-r--r--src/poll_controller.h46
6 files changed, 124 insertions, 33 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 012f8a9f..272827d0 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -43,7 +43,8 @@ libgprs_la_SOURCES = \
pcu_l1_if.cpp \
pcu_vty.c \
tbf.cpp \
- bts.cpp
+ bts.cpp \
+ poll_controller.cpp
if ENABLE_SYSMOBTS
libgprs_la_SOURCES += \
@@ -77,7 +78,8 @@ noinst_HEADERS = \
sysmo_l1_if.h \
femtobts.h \
tbf.h \
- bts.h
+ bts.h \
+ poll_controller.h
osmo_pcu_SOURCES = pcu_main.cpp
diff --git a/src/bts.cpp b/src/bts.cpp
index b278ecfb..29cd3e5d 100644
--- a/src/bts.cpp
+++ b/src/bts.cpp
@@ -19,6 +19,8 @@
*/
#include <bts.h>
+#include <poll_controller.h>
+
#include <string.h>
static BTS s_bts;
@@ -40,6 +42,7 @@ struct gprs_rlcmac_bts *bts_main_data()
BTS::BTS()
: m_cur_fn(0)
+ , m_pollController(*this)
{
memset(&m_bts, 0, sizeof(m_bts));
m_bts.bts = this;
@@ -48,4 +51,5 @@ BTS::BTS()
void BTS::set_current_frame_number(int fn)
{
m_cur_fn = fn;
+ m_pollController.expireTimedout(m_cur_fn);
}
diff --git a/src/bts.h b/src/bts.h
index 507c79fb..4babd25a 100644
--- a/src/bts.h
+++ b/src/bts.h
@@ -26,6 +26,8 @@ extern "C" {
#include <osmocom/core/linuxlist.h>
#include <osmocom/core/timer.h>
}
+
+#include "poll_controller.h"
#endif
#include <stdint.h>
@@ -113,6 +115,12 @@ public:
private:
int m_cur_fn;
struct gprs_rlcmac_bts m_bts;
+ PollController m_pollController;
+
+private:
+ /* disable copying to avoid slicing */
+ BTS(const BTS&);
+ BTS& operator=(const BTS&);
};
inline int BTS::current_frame_number() const
diff --git a/src/pcu_l1_if.cpp b/src/pcu_l1_if.cpp
index ad0887ea..438bfa86 100644
--- a/src/pcu_l1_if.cpp
+++ b/src/pcu_l1_if.cpp
@@ -494,12 +494,7 @@ bssgp_failed:
static int pcu_rx_time_ind(struct gsm_pcu_if_time_ind *time_ind)
{
- struct gprs_rlcmac_bts *bts = bts_main_data();
- struct gprs_rlcmac_tbf *tbf;
- struct gprs_rlcmac_sba *sba, *sba2;
- uint32_t elapsed;
uint8_t fn13 = time_ind->fn % 13;
- int frame_number = time_ind->fn;
/* omit frame numbers not starting at a MAC block */
if (fn13 != 0 && fn13 != 4 && fn13 != 8)
@@ -509,32 +504,6 @@ static int pcu_rx_time_ind(struct gsm_pcu_if_time_ind *time_ind)
// time_ind->fn % 52);
BTS::main_bts()->set_current_frame_number(time_ind->fn);
-
- /* check for poll timeout */
- llist_for_each_entry(tbf, &gprs_rlcmac_ul_tbfs, list) {
- if (tbf->poll_state == GPRS_RLCMAC_POLL_SCHED) {
- elapsed = (frame_number + 2715648 - tbf->poll_fn)
- % 2715648;
- if (elapsed >= 20 && elapsed < 2715400)
- gprs_rlcmac_poll_timeout(bts, tbf);
- }
- }
- llist_for_each_entry(tbf, &gprs_rlcmac_dl_tbfs, list) {
- if (tbf->poll_state == GPRS_RLCMAC_POLL_SCHED) {
- elapsed = (frame_number + 2715648 - tbf->poll_fn)
- % 2715648;
- if (elapsed >= 20 && elapsed < 2715400)
- gprs_rlcmac_poll_timeout(bts, tbf);
- }
- }
- llist_for_each_entry_safe(sba, sba2, &gprs_rlcmac_sbas, list) {
- elapsed = (frame_number + 2715648 - sba->fn) % 2715648;
- if (elapsed >= 20 && elapsed < 2715400) {
- /* sba will be freed here */
- gprs_rlcmac_sba_timeout(sba);
- }
- }
-
return 0;
}
diff --git a/src/poll_controller.cpp b/src/poll_controller.cpp
new file mode 100644
index 00000000..59eef762
--- /dev/null
+++ b/src/poll_controller.cpp
@@ -0,0 +1,62 @@
+/* poll_controller.h
+ *
+ * Copyright (C) 2012 Andreas Eversberg <jolly@eversberg.eu>
+ * Copyright (C) 2013 by Holger Hans Peter Freyther
+ *
+ * All Rights Reserved
+ *
+ * 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 <poll_controller.h>
+#include <tbf.h>
+
+PollController::PollController(BTS& bts)
+ : m_bts(bts)
+{}
+
+void PollController::expireTimedout(int frame_number)
+{
+ struct gprs_rlcmac_bts *bts = m_bts.bts_data();
+ struct gprs_rlcmac_tbf *tbf;
+ struct gprs_rlcmac_sba *sba, *sba2;
+ uint32_t elapsed;
+
+ /* check for poll timeout */
+ llist_for_each_entry(tbf, &gprs_rlcmac_ul_tbfs, list) {
+ if (tbf->poll_state == GPRS_RLCMAC_POLL_SCHED) {
+ elapsed = (frame_number + 2715648 - tbf->poll_fn)
+ % 2715648;
+ if (elapsed >= 20 && elapsed < 2715400)
+ gprs_rlcmac_poll_timeout(bts, tbf);
+ }
+ }
+ llist_for_each_entry(tbf, &gprs_rlcmac_dl_tbfs, list) {
+ if (tbf->poll_state == GPRS_RLCMAC_POLL_SCHED) {
+ elapsed = (frame_number + 2715648 - tbf->poll_fn)
+ % 2715648;
+ if (elapsed >= 20 && elapsed < 2715400)
+ gprs_rlcmac_poll_timeout(bts, tbf);
+ }
+ }
+ llist_for_each_entry_safe(sba, sba2, &gprs_rlcmac_sbas, list) {
+ elapsed = (frame_number + 2715648 - sba->fn) % 2715648;
+ if (elapsed >= 20 && elapsed < 2715400) {
+ /* sba will be freed here */
+ gprs_rlcmac_sba_timeout(sba);
+ }
+ }
+
+}
diff --git a/src/poll_controller.h b/src/poll_controller.h
new file mode 100644
index 00000000..67af4084
--- /dev/null
+++ b/src/poll_controller.h
@@ -0,0 +1,46 @@
+/* poll_controller.h
+ *
+ * Copyright (C) 2013 by Holger Hans Peter Freyther
+ *
+ * All Rights Reserved
+ *
+ * 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/>.
+ *
+ */
+
+#pragma once
+
+struct gprs_rlcmac_bts;
+
+class BTS;
+
+/**
+ * I belong to a BTS and I am responsible for finding TBFs and
+ * SBAs that should have been polled and execute the timeout
+ * action on them.
+ */
+class PollController {
+public:
+ PollController(BTS& bts);
+
+ void expireTimedout(int frame_number);
+
+private:
+ BTS& m_bts;
+
+private:
+ /* disable copying to avoid slicing */
+ PollController(const PollController&);
+ PollController& operator=(const PollController&);
+};