aboutsummaryrefslogtreecommitdiffstats
path: root/src/common/load_indication.c
blob: 12e41e43a3d875e7e9bd34aed8f716babd2581cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
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);
}