2013-10-17 18:12:37 +00:00
|
|
|
/* poll_controller.h
|
|
|
|
*
|
|
|
|
* Copyright (C) 2012 Andreas Eversberg <jolly@eversberg.eu>
|
|
|
|
* Copyright (C) 2013 by Holger Hans Peter Freyther
|
|
|
|
*
|
|
|
|
* 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 <poll_controller.h>
|
2013-10-19 19:10:38 +00:00
|
|
|
#include <bts.h>
|
2013-10-17 18:12:37 +00:00
|
|
|
#include <tbf.h>
|
2018-01-26 12:31:42 +00:00
|
|
|
#include <cxx_linuxlist.h>
|
|
|
|
#include <sba.h>
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
#include <osmocom/core/linuxlist.h>
|
|
|
|
#include <osmocom/gsm/gsm_utils.h>
|
|
|
|
}
|
2013-10-17 18:12:37 +00:00
|
|
|
|
|
|
|
PollController::PollController(BTS& bts)
|
|
|
|
: m_bts(bts)
|
|
|
|
{}
|
|
|
|
|
2017-05-16 14:10:45 +00:00
|
|
|
static inline bool elapsed_fn_check(unsigned max_delay, int frame_number, uint32_t from)
|
|
|
|
{
|
|
|
|
uint32_t elapsed = (frame_number + GSM_MAX_FN - from) % GSM_MAX_FN;
|
|
|
|
|
|
|
|
if (elapsed > max_delay && elapsed < 2715400)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-08-27 11:18:24 +00:00
|
|
|
void PollController::expireTimedout(int frame_number, unsigned max_delay)
|
2013-10-17 18:12:37 +00:00
|
|
|
{
|
2014-08-07 11:05:43 +00:00
|
|
|
struct gprs_rlcmac_dl_tbf *dl_tbf;
|
|
|
|
struct gprs_rlcmac_ul_tbf *ul_tbf;
|
2013-10-17 18:12:37 +00:00
|
|
|
struct gprs_rlcmac_sba *sba, *sba2;
|
2015-12-28 18:15:40 +00:00
|
|
|
LListHead<gprs_rlcmac_tbf> *pos;
|
2013-10-17 18:12:37 +00:00
|
|
|
|
2015-12-28 18:15:40 +00:00
|
|
|
llist_for_each(pos, &m_bts.ul_tbfs()) {
|
|
|
|
ul_tbf = as_ul_tbf(pos->entry());
|
2018-01-24 10:00:17 +00:00
|
|
|
if (ul_tbf->poll_scheduled()) {
|
2017-05-16 14:10:45 +00:00
|
|
|
if (elapsed_fn_check(max_delay, frame_number, ul_tbf->poll_fn))
|
2014-08-07 11:05:43 +00:00
|
|
|
ul_tbf->poll_timeout();
|
2013-10-17 18:12:37 +00:00
|
|
|
}
|
|
|
|
}
|
2015-12-28 18:15:40 +00:00
|
|
|
llist_for_each(pos, &m_bts.dl_tbfs()) {
|
|
|
|
dl_tbf = as_dl_tbf(pos->entry());
|
2018-01-24 10:00:17 +00:00
|
|
|
if (dl_tbf->poll_scheduled()) {
|
2017-05-16 14:10:45 +00:00
|
|
|
if (elapsed_fn_check(max_delay, frame_number, dl_tbf->poll_fn))
|
2014-08-07 11:05:43 +00:00
|
|
|
dl_tbf->poll_timeout();
|
2013-10-17 18:12:37 +00:00
|
|
|
}
|
|
|
|
}
|
2013-10-19 18:47:12 +00:00
|
|
|
llist_for_each_entry_safe(sba, sba2, &m_bts.sba()->m_sbas, list) {
|
2017-05-16 14:10:45 +00:00
|
|
|
if (elapsed_fn_check(max_delay, frame_number, sba->fn)) {
|
2013-10-17 18:12:37 +00:00
|
|
|
/* sba will be freed here */
|
2013-10-19 18:47:12 +00:00
|
|
|
m_bts.sba()->timeout(sba);
|
2013-10-17 18:12:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|