blob: ac79510121dfdf77f331fd31f413fc2ad4d61f76 [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>
Pau Espin Pedrol9d1cdb12019-09-25 17:47:02 +020026#include <tbf_ul.h>
Max1187a772018-01-26 13:31:42 +010027#include <cxx_linuxlist.h>
28#include <sba.h>
29
30extern "C" {
31#include <osmocom/core/linuxlist.h>
32#include <osmocom/gsm/gsm_utils.h>
33}
Holger Hans Peter Freytherb78adcd2013-10-17 20:12:37 +020034
35PollController::PollController(BTS& bts)
36 : m_bts(bts)
37{}
38
Max9dabfa22017-05-16 16:10:45 +020039static inline bool elapsed_fn_check(unsigned max_delay, int frame_number, uint32_t from)
40{
41 uint32_t elapsed = (frame_number + GSM_MAX_FN - from) % GSM_MAX_FN;
42
43 if (elapsed > max_delay && elapsed < 2715400)
44 return true;
45
46 return false;
47}
48
Jacob Erlbeckac49d092015-08-27 13:18:24 +020049void PollController::expireTimedout(int frame_number, unsigned max_delay)
Holger Hans Peter Freytherb78adcd2013-10-17 20:12:37 +020050{
Daniel Willmann93d17112014-08-07 13:05:43 +020051 struct gprs_rlcmac_dl_tbf *dl_tbf;
52 struct gprs_rlcmac_ul_tbf *ul_tbf;
Holger Hans Peter Freytherb78adcd2013-10-17 20:12:37 +020053 struct gprs_rlcmac_sba *sba, *sba2;
Jacob Erlbecked2dbf62015-12-28 19:15:40 +010054 LListHead<gprs_rlcmac_tbf> *pos;
Holger Hans Peter Freytherb78adcd2013-10-17 20:12:37 +020055
Jacob Erlbecked2dbf62015-12-28 19:15:40 +010056 llist_for_each(pos, &m_bts.ul_tbfs()) {
57 ul_tbf = as_ul_tbf(pos->entry());
Maxcac6b662018-01-24 11:00:17 +010058 if (ul_tbf->poll_scheduled()) {
Max9dabfa22017-05-16 16:10:45 +020059 if (elapsed_fn_check(max_delay, frame_number, ul_tbf->poll_fn))
Daniel Willmann93d17112014-08-07 13:05:43 +020060 ul_tbf->poll_timeout();
Holger Hans Peter Freytherb78adcd2013-10-17 20:12:37 +020061 }
62 }
Jacob Erlbecked2dbf62015-12-28 19:15:40 +010063 llist_for_each(pos, &m_bts.dl_tbfs()) {
64 dl_tbf = as_dl_tbf(pos->entry());
Maxcac6b662018-01-24 11:00:17 +010065 if (dl_tbf->poll_scheduled()) {
Max9dabfa22017-05-16 16:10:45 +020066 if (elapsed_fn_check(max_delay, frame_number, dl_tbf->poll_fn))
Daniel Willmann93d17112014-08-07 13:05:43 +020067 dl_tbf->poll_timeout();
Holger Hans Peter Freytherb78adcd2013-10-17 20:12:37 +020068 }
69 }
Holger Hans Peter Freythercedf8902013-10-19 20:47:12 +020070 llist_for_each_entry_safe(sba, sba2, &m_bts.sba()->m_sbas, list) {
Max9dabfa22017-05-16 16:10:45 +020071 if (elapsed_fn_check(max_delay, frame_number, sba->fn)) {
Holger Hans Peter Freytherb78adcd2013-10-17 20:12:37 +020072 /* sba will be freed here */
Holger Hans Peter Freythercedf8902013-10-19 20:47:12 +020073 m_bts.sba()->timeout(sba);
Holger Hans Peter Freytherb78adcd2013-10-17 20:12:37 +020074 }
75 }
76
77}