Holger Hans Peter Freyther | b78adcd | 2013-10-17 20:12:37 +0200 | [diff] [blame] | 1 | /* 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 Freyther | 34bd8bd | 2013-10-19 21:10:38 +0200 | [diff] [blame] | 24 | #include <bts.h> |
Holger Hans Peter Freyther | b78adcd | 2013-10-17 20:12:37 +0200 | [diff] [blame] | 25 | #include <tbf.h> |
Pau Espin Pedrol | 9d1cdb1 | 2019-09-25 17:47:02 +0200 | [diff] [blame] | 26 | #include <tbf_ul.h> |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 27 | #include <tbf_dl.h> |
Max | 1187a77 | 2018-01-26 13:31:42 +0100 | [diff] [blame] | 28 | #include <cxx_linuxlist.h> |
| 29 | #include <sba.h> |
| 30 | |
| 31 | extern "C" { |
| 32 | #include <osmocom/core/linuxlist.h> |
| 33 | #include <osmocom/gsm/gsm_utils.h> |
| 34 | } |
Holger Hans Peter Freyther | b78adcd | 2013-10-17 20:12:37 +0200 | [diff] [blame] | 35 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 36 | PollController::PollController(struct gprs_rlcmac_bts& bts) |
Holger Hans Peter Freyther | b78adcd | 2013-10-17 20:12:37 +0200 | [diff] [blame] | 37 | : m_bts(bts) |
| 38 | {} |
| 39 | |
Max | 9dabfa2 | 2017-05-16 16:10:45 +0200 | [diff] [blame] | 40 | static inline bool elapsed_fn_check(unsigned max_delay, int frame_number, uint32_t from) |
| 41 | { |
| 42 | uint32_t elapsed = (frame_number + GSM_MAX_FN - from) % GSM_MAX_FN; |
| 43 | |
| 44 | if (elapsed > max_delay && elapsed < 2715400) |
| 45 | return true; |
| 46 | |
| 47 | return false; |
| 48 | } |
| 49 | |
Jacob Erlbeck | ac49d09 | 2015-08-27 13:18:24 +0200 | [diff] [blame] | 50 | void PollController::expireTimedout(int frame_number, unsigned max_delay) |
Holger Hans Peter Freyther | b78adcd | 2013-10-17 20:12:37 +0200 | [diff] [blame] | 51 | { |
Daniel Willmann | 93d1711 | 2014-08-07 13:05:43 +0200 | [diff] [blame] | 52 | struct gprs_rlcmac_dl_tbf *dl_tbf; |
| 53 | struct gprs_rlcmac_ul_tbf *ul_tbf; |
Holger Hans Peter Freyther | b78adcd | 2013-10-17 20:12:37 +0200 | [diff] [blame] | 54 | struct gprs_rlcmac_sba *sba, *sba2; |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 55 | struct llist_item *pos; |
Holger Hans Peter Freyther | b78adcd | 2013-10-17 20:12:37 +0200 | [diff] [blame] | 56 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 57 | llist_for_each_entry(pos, &m_bts.ul_tbfs, list) { |
| 58 | ul_tbf = as_ul_tbf((struct gprs_rlcmac_tbf *)pos->entry); |
Max | cac6b66 | 2018-01-24 11:00:17 +0100 | [diff] [blame] | 59 | if (ul_tbf->poll_scheduled()) { |
Max | 9dabfa2 | 2017-05-16 16:10:45 +0200 | [diff] [blame] | 60 | if (elapsed_fn_check(max_delay, frame_number, ul_tbf->poll_fn)) |
Daniel Willmann | 93d1711 | 2014-08-07 13:05:43 +0200 | [diff] [blame] | 61 | ul_tbf->poll_timeout(); |
Holger Hans Peter Freyther | b78adcd | 2013-10-17 20:12:37 +0200 | [diff] [blame] | 62 | } |
| 63 | } |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 64 | llist_for_each_entry(pos, &m_bts.dl_tbfs, list) { |
| 65 | dl_tbf = as_dl_tbf((struct gprs_rlcmac_tbf *)pos->entry); |
Max | cac6b66 | 2018-01-24 11:00:17 +0100 | [diff] [blame] | 66 | if (dl_tbf->poll_scheduled()) { |
Max | 9dabfa2 | 2017-05-16 16:10:45 +0200 | [diff] [blame] | 67 | if (elapsed_fn_check(max_delay, frame_number, dl_tbf->poll_fn)) |
Daniel Willmann | 93d1711 | 2014-08-07 13:05:43 +0200 | [diff] [blame] | 68 | dl_tbf->poll_timeout(); |
Holger Hans Peter Freyther | b78adcd | 2013-10-17 20:12:37 +0200 | [diff] [blame] | 69 | } |
| 70 | } |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 71 | llist_for_each_entry_safe(sba, sba2, &bts_sba(&m_bts)->m_sbas, list) { |
Max | 9dabfa2 | 2017-05-16 16:10:45 +0200 | [diff] [blame] | 72 | if (elapsed_fn_check(max_delay, frame_number, sba->fn)) { |
Holger Hans Peter Freyther | b78adcd | 2013-10-17 20:12:37 +0200 | [diff] [blame] | 73 | /* sba will be freed here */ |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 74 | bts_sba(&m_bts)->timeout(sba); |
Holger Hans Peter Freyther | b78adcd | 2013-10-17 20:12:37 +0200 | [diff] [blame] | 75 | } |
| 76 | } |
| 77 | |
| 78 | } |