diff options
author | Holger Hans Peter Freyther <holger@moiji-mobile.com> | 2013-10-19 20:11:46 +0200 |
---|---|---|
committer | Holger Hans Peter Freyther <holger@moiji-mobile.com> | 2013-10-30 21:24:10 +0100 |
commit | 621dc2fd010dbcde6c6a202d48d427afbf6a2e1a (patch) | |
tree | 653ede19b8e6cd65e894b358d09b254e23b10340 | |
parent | 111614a9942195f6261be5cf8854d1f6fdbe1479 (diff) |
sba: Move the sba code to a dedicated file
Move the code around and then turn it into an object...
-rw-r--r-- | src/Makefile.am | 3 | ||||
-rw-r--r-- | src/gprs_rlcmac.cpp | 62 | ||||
-rw-r--r-- | src/gprs_rlcmac.h | 2 | ||||
-rw-r--r-- | src/gprs_rlcmac_data.cpp | 9 | ||||
-rw-r--r-- | src/gprs_rlcmac_sched.cpp | 17 | ||||
-rw-r--r-- | src/sba.cpp | 121 |
6 files changed, 125 insertions, 89 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index cbb6de0..813dfbe 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -46,7 +46,8 @@ libgprs_la_SOURCES = \ bts.cpp \ poll_controller.cpp \ encoding.cpp \ - ta.cpp + ta.cpp \ + sba.cpp if ENABLE_SYSMOBTS libgprs_la_SOURCES += \ diff --git a/src/gprs_rlcmac.cpp b/src/gprs_rlcmac.cpp index d1d9bd9..87cb846 100644 --- a/src/gprs_rlcmac.cpp +++ b/src/gprs_rlcmac.cpp @@ -179,68 +179,6 @@ int tfi_find_free(struct gprs_rlcmac_bts *bts, enum gprs_rlcmac_tbf_direction di return -1; } -/* starting time for assigning single slot - * This offset must be a multiple of 13. */ -#define AGCH_START_OFFSET 52 - -LLIST_HEAD(gprs_rlcmac_sbas); - -int sba_alloc(struct gprs_rlcmac_bts *bts, - uint8_t *_trx, uint8_t *_ts, uint32_t *_fn, uint8_t ta) -{ - - struct gprs_rlcmac_pdch *pdch; - struct gprs_rlcmac_sba *sba; - uint8_t trx, ts; - uint32_t fn; - - sba = talloc_zero(tall_pcu_ctx, struct gprs_rlcmac_sba); - if (!sba) - return -ENOMEM; - - for (trx = 0; trx < 8; trx++) { - for (ts = 0; ts < 8; ts++) { - pdch = &bts->trx[trx].pdch[ts]; - if (!pdch->is_enabled()) - continue; - break; - } - if (ts < 8) - break; - } - if (trx == 8) { - LOGP(DRLCMAC, LOGL_NOTICE, "No PDCH available.\n"); - talloc_free(sba); - return -EINVAL; - } - - fn = (pdch->last_rts_fn + AGCH_START_OFFSET) % 2715648; - - sba->trx = trx; - sba->ts = ts; - sba->fn = fn; - sba->ta = ta; - - llist_add(&sba->list, &gprs_rlcmac_sbas); - - *_trx = trx; - *_ts = ts; - *_fn = fn; - return 0; -} - -struct gprs_rlcmac_sba *sba_find(uint8_t trx, uint8_t ts, uint32_t fn) -{ - struct gprs_rlcmac_sba *sba; - - llist_for_each_entry(sba, &gprs_rlcmac_sbas, list) { - if (sba->trx == trx && sba->ts == ts && sba->fn == fn) - return sba; - } - - return NULL; -} - /* received RLC/MAC block from L1 */ int gprs_rlcmac_rcv_block(struct gprs_rlcmac_bts *bts, uint8_t trx, uint8_t ts, uint8_t *data, uint8_t len, diff --git a/src/gprs_rlcmac.h b/src/gprs_rlcmac.h index c514b4e..2232e97 100644 --- a/src/gprs_rlcmac.h +++ b/src/gprs_rlcmac.h @@ -100,6 +100,8 @@ int sba_alloc(struct gprs_rlcmac_bts *bts, uint8_t *_trx, uint8_t *_ts, uint32_t struct gprs_rlcmac_sba *sba_find(uint8_t trx, uint8_t ts, uint32_t fn); +uint32_t sched_sba(uint8_t trx, uint8_t ts, uint32_t fn, uint8_t block_nr); + /* TS 44.060 Section 10.4.7 Table 10.4.7.1: Payload Type field */ enum gprs_rlcmac_block_type { GPRS_RLCMAC_DATA_BLOCK = 0x0, diff --git a/src/gprs_rlcmac_data.cpp b/src/gprs_rlcmac_data.cpp index dc3242d..9eba6bf 100644 --- a/src/gprs_rlcmac_data.cpp +++ b/src/gprs_rlcmac_data.cpp @@ -189,15 +189,6 @@ int gprs_rlcmac_poll_timeout(struct gprs_rlcmac_bts *bts, struct gprs_rlcmac_tbf return 0; } -int gprs_rlcmac_sba_timeout(struct gprs_rlcmac_sba *sba) -{ - LOGP(DRLCMAC, LOGL_NOTICE, "Poll timeout for SBA\n"); - llist_del(&sba->list); - talloc_free(sba); - - return 0; -} - static uint8_t get_ms_class_by_capability(MS_Radio_Access_capability_t *cap) { int i; diff --git a/src/gprs_rlcmac_sched.cpp b/src/gprs_rlcmac_sched.cpp index be699e6..d364adf 100644 --- a/src/gprs_rlcmac_sched.cpp +++ b/src/gprs_rlcmac_sched.cpp @@ -70,23 +70,6 @@ static uint32_t sched_poll(uint8_t trx, uint8_t ts, uint32_t fn, uint8_t block_n return poll_fn; } -uint32_t sched_sba(uint8_t trx, uint8_t ts, uint32_t fn, uint8_t block_nr) -{ - uint32_t sba_fn; - struct gprs_rlcmac_sba *sba; - - /* check special TBF for events */ - sba_fn = fn + 4; - if ((block_nr % 3) == 2) - sba_fn ++; - sba_fn = sba_fn % 2715648; - sba = sba_find(trx, ts, sba_fn); - if (sba) - return sba_fn; - - return 0xffffffff; -} - uint8_t sched_select_uplink(uint8_t trx, uint8_t ts, uint32_t fn, uint8_t block_nr, struct gprs_rlcmac_pdch *pdch) { diff --git a/src/sba.cpp b/src/sba.cpp new file mode 100644 index 0000000..f002649 --- /dev/null +++ b/src/sba.cpp @@ -0,0 +1,121 @@ +/* sba.cpp + * + * Copyright (C) 2012 Ivan Klyuchnikov + * Copyright (C) 2012 Andreas Eversberg <jolly@eversberg.eu> + * Copyright (C) 2013 by Holger Hans Peter Freyther + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * 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 General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include <gprs_rlcmac.h> +#include <gprs_debug.h> +#include <bts.h> + +extern "C" { +#include <osmocom/core/talloc.h> +} + +#include <errno.h> + +extern void *tall_pcu_ctx; + +/* starting time for assigning single slot + * This offset must be a multiple of 13. */ +#define AGCH_START_OFFSET 52 + +LLIST_HEAD(gprs_rlcmac_sbas); + +int sba_alloc(struct gprs_rlcmac_bts *bts, + uint8_t *_trx, uint8_t *_ts, uint32_t *_fn, uint8_t ta) +{ + + struct gprs_rlcmac_pdch *pdch; + struct gprs_rlcmac_sba *sba; + uint8_t trx, ts; + uint32_t fn; + + sba = talloc_zero(tall_pcu_ctx, struct gprs_rlcmac_sba); + if (!sba) + return -ENOMEM; + + for (trx = 0; trx < 8; trx++) { + for (ts = 0; ts < 8; ts++) { + pdch = &bts->trx[trx].pdch[ts]; + if (!pdch->is_enabled()) + continue; + break; + } + if (ts < 8) + break; + } + if (trx == 8) { + LOGP(DRLCMAC, LOGL_NOTICE, "No PDCH available.\n"); + talloc_free(sba); + return -EINVAL; + } + + fn = (pdch->last_rts_fn + AGCH_START_OFFSET) % 2715648; + + sba->trx = trx; + sba->ts = ts; + sba->fn = fn; + sba->ta = ta; + + llist_add(&sba->list, &gprs_rlcmac_sbas); + + *_trx = trx; + *_ts = ts; + *_fn = fn; + return 0; +} + +struct gprs_rlcmac_sba *sba_find(uint8_t trx, uint8_t ts, uint32_t fn) +{ + struct gprs_rlcmac_sba *sba; + + llist_for_each_entry(sba, &gprs_rlcmac_sbas, list) { + if (sba->trx == trx && sba->ts == ts && sba->fn == fn) + return sba; + } + + return NULL; +} + +uint32_t sched_sba(uint8_t trx, uint8_t ts, uint32_t fn, uint8_t block_nr) +{ + uint32_t sba_fn; + struct gprs_rlcmac_sba *sba; + + /* check special TBF for events */ + sba_fn = fn + 4; + if ((block_nr % 3) == 2) + sba_fn ++; + sba_fn = sba_fn % 2715648; + sba = sba_find(trx, ts, sba_fn); + if (sba) + return sba_fn; + + return 0xffffffff; +} + +int gprs_rlcmac_sba_timeout(struct gprs_rlcmac_sba *sba) +{ + LOGP(DRLCMAC, LOGL_NOTICE, "Poll timeout for SBA\n"); + llist_del(&sba->list); + talloc_free(sba); + + return 0; +} + |