aboutsummaryrefslogtreecommitdiffstats
path: root/src/common/load_indication.c
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2011-06-27 11:25:35 +0200
committerHarald Welte <laforge@gnumonks.org>2011-06-27 11:25:35 +0200
commitc6b4c87e5d57b91b29894835e7ac8e42f6e67f32 (patch)
tree2dfca5a61c881e88e6f29d03c29bb26e1c643332 /src/common/load_indication.c
parent8e47fb89bfd0e2b54b714393ac2a80ca76df56a9 (diff)
re-work original osmo-bts with support for sysmocom femtobts
This code re-works osmo-bts to add support for the upcoming sysmocom BTS. It also tries to add some level of abstraction between the generic part of a BTS (A-bis, RSL, OML, data structures, paging scheduling, BCCH/AGCH scheduling, etc.) and the actual hardware-specific bits. The hardware-specific bits are currently only implemented for the sysmocom femtobts, but should be (re-)added for osmocom-bb, as well as a virtual BTS for simulation purpose later. The sysmocom bts specific parts require hardware-specific header files which are (at least currently) not publicly distributed.
Diffstat (limited to 'src/common/load_indication.c')
-rw-r--r--src/common/load_indication.c69
1 files changed, 69 insertions, 0 deletions
diff --git a/src/common/load_indication.c b/src/common/load_indication.c
new file mode 100644
index 00000000..12e41e43
--- /dev/null
+++ b/src/common/load_indication.c
@@ -0,0 +1,69 @@
+/* Support for generating RSL Load Indication */
+
+/* (C) 2011 by Harald Welte <laforge@gnumonks.org>
+ *
+ * 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 <rsl.h>
+
+#include <osmocom/core/timer.h>
+
+static void reset_load_counters(void)
+{
+ /* re-set the counters */
+ btsb->load.ccch.pch_used = btsb->load.ccch.pch_total = 0;
+}
+
+static void load_timer_cb(void *data)
+{
+ struct gsm_bts *bts = data;
+ struct gsm_bts_role_bts *btsb = FIXME;
+ unsigned int pch_percent;
+
+ /* compute percentages */
+ pch_percent = (btsb->load.ccch.pch_used * 100) / btsb->load.ccch.pch_total;
+
+ if (pch_percent >= btsb->load.ccch.load_ind_thresh) {
+ /* send RSL load indication message to BSC */
+ uint16_t paging_buffer_space = FIXME;
+ rsl_tx_ccch_load_ind_pch(bts, paging_buffer_space);
+ }
+
+ reset_load_counters();
+
+ /* re-schedule the timer */
+ osmo_timer_schedule(&btsb->load.ccch.timer,
+ btsb->load.ccch.load_ind_period, 0);
+}
+
+static void load_timer_start(struct gsm_bts *bts)
+{
+ struct gsm_bts_role_bts *btsb = FIXME;
+
+ btsb->load.ccch.timer.data = bts;
+ reset_load_counters();
+ osmo_timer_schedule(&btsb->load.ccch.timer,
+ btsb->load.ccch.load_ind_period, 0);
+
+ return 0
+}
+
+static void load_timer_stop(struct gsm_bts *bts)
+{
+ osmo_timer_del(&btsb->load.ccch.timer);
+}