blob: dea75edf95704b84f86760ceef6aff3a9755e806 [file] [log] [blame]
Holger Hans Peter Freytherb78adcd2013-10-17 20:12:37 +02001/* poll_controller.h
2 *
3 * Copyright (C) 2012 Andreas Eversberg <jolly@eversberg.eu>
4 * Copyright (C) 2013 by Holger Hans Peter Freyther
5 *
6 * All Rights Reserved
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU Affero General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU Affero General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 *
21 */
22
23#include <poll_controller.h>
Holger Hans Peter Freyther34bd8bd2013-10-19 21:10:38 +020024#include <bts.h>
Holger Hans Peter Freytherb78adcd2013-10-17 20:12:37 +020025#include <tbf.h>
26
27PollController::PollController(BTS& bts)
28 : m_bts(bts)
29{}
30
31void PollController::expireTimedout(int frame_number)
32{
33 struct gprs_rlcmac_bts *bts = m_bts.bts_data();
34 struct gprs_rlcmac_tbf *tbf;
35 struct gprs_rlcmac_sba *sba, *sba2;
Daniel Willmann1b3864f2014-07-30 13:25:19 +020036 struct llist_pods *lpods;
Holger Hans Peter Freytherb78adcd2013-10-17 20:12:37 +020037 uint32_t elapsed;
38
39 /* check for poll timeout */
Daniel Willmann1b3864f2014-07-30 13:25:19 +020040 llist_pods_for_each_entry(tbf, &bts->ul_tbfs, list, lpods) {
Holger Hans Peter Freytherb78adcd2013-10-17 20:12:37 +020041 if (tbf->poll_state == GPRS_RLCMAC_POLL_SCHED) {
42 elapsed = (frame_number + 2715648 - tbf->poll_fn)
43 % 2715648;
44 if (elapsed >= 20 && elapsed < 2715400)
Holger Hans Peter Freytherd9262b32013-10-26 20:12:59 +020045 tbf->poll_timeout();
Holger Hans Peter Freytherb78adcd2013-10-17 20:12:37 +020046 }
47 }
Daniel Willmann1b3864f2014-07-30 13:25:19 +020048 llist_pods_for_each_entry(tbf, &bts->dl_tbfs, list, lpods) {
Holger Hans Peter Freytherb78adcd2013-10-17 20:12:37 +020049 if (tbf->poll_state == GPRS_RLCMAC_POLL_SCHED) {
50 elapsed = (frame_number + 2715648 - tbf->poll_fn)
51 % 2715648;
52 if (elapsed >= 20 && elapsed < 2715400)
Holger Hans Peter Freytherd9262b32013-10-26 20:12:59 +020053 tbf->poll_timeout();
Holger Hans Peter Freytherb78adcd2013-10-17 20:12:37 +020054 }
55 }
Holger Hans Peter Freythercedf8902013-10-19 20:47:12 +020056 llist_for_each_entry_safe(sba, sba2, &m_bts.sba()->m_sbas, list) {
Holger Hans Peter Freytherb78adcd2013-10-17 20:12:37 +020057 elapsed = (frame_number + 2715648 - sba->fn) % 2715648;
58 if (elapsed >= 20 && elapsed < 2715400) {
59 /* sba will be freed here */
Holger Hans Peter Freythercedf8902013-10-19 20:47:12 +020060 m_bts.sba()->timeout(sba);
Holger Hans Peter Freytherb78adcd2013-10-17 20:12:37 +020061 }
62 }
63
64}