2013-10-16 15:29:31 +00:00
|
|
|
/* AllocTest.cpp
|
|
|
|
*
|
|
|
|
* 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 "tbf.h"
|
2019-09-25 15:47:02 +00:00
|
|
|
#include "tbf_ul.h"
|
2013-10-19 19:10:38 +00:00
|
|
|
#include "bts.h"
|
2013-10-16 15:29:31 +00:00
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
extern "C" {
|
2018-01-23 19:57:08 +00:00
|
|
|
#include "mslot_class.h"
|
2013-10-16 15:29:31 +00:00
|
|
|
#include <osmocom/core/application.h>
|
|
|
|
#include <osmocom/core/msgb.h>
|
|
|
|
#include <osmocom/core/talloc.h>
|
|
|
|
#include <osmocom/core/utils.h>
|
|
|
|
}
|
|
|
|
|
|
|
|
/* globals used by the code */
|
|
|
|
void *tall_pcu_ctx;
|
|
|
|
int16_t spoof_mnc = 0, spoof_mcc = 0;
|
2018-02-20 23:39:07 +00:00
|
|
|
bool spoof_mnc_3_digits = false;
|
2013-10-16 15:29:31 +00:00
|
|
|
|
2014-07-16 16:54:10 +00:00
|
|
|
static gprs_rlcmac_tbf *tbf_alloc(struct gprs_rlcmac_bts *bts,
|
2015-06-18 15:16:26 +00:00
|
|
|
GprsMs *ms, gprs_rlcmac_tbf_direction dir,
|
2020-05-08 16:15:59 +00:00
|
|
|
uint8_t use_trx, bool single_slot)
|
2014-07-16 16:54:10 +00:00
|
|
|
{
|
2020-05-08 16:15:59 +00:00
|
|
|
OSMO_ASSERT(ms != NULL);
|
2020-05-08 15:44:33 +00:00
|
|
|
|
2014-07-16 16:54:10 +00:00
|
|
|
if (dir == GPRS_RLCMAC_UL_TBF)
|
2020-05-08 15:44:33 +00:00
|
|
|
return tbf_alloc_ul_tbf(bts, ms, use_trx, single_slot);
|
2014-07-16 16:54:10 +00:00
|
|
|
else
|
2020-05-08 16:15:59 +00:00
|
|
|
return tbf_alloc_dl_tbf(bts, ms, use_trx, single_slot);
|
2014-07-16 16:54:10 +00:00
|
|
|
}
|
|
|
|
|
2015-07-09 09:35:50 +00:00
|
|
|
static void check_tfi_usage(BTS *the_bts)
|
|
|
|
{
|
|
|
|
int pdch_no;
|
|
|
|
|
|
|
|
struct gprs_rlcmac_tbf *tfi_usage[8][8][2][32] = {{{{NULL}}}};
|
2015-12-28 18:15:40 +00:00
|
|
|
LListHead<gprs_rlcmac_tbf> *tbf_lists[2] = {
|
|
|
|
&the_bts->ul_tbfs(),
|
|
|
|
&the_bts->dl_tbfs()
|
2015-07-09 09:35:50 +00:00
|
|
|
};
|
|
|
|
|
2015-12-28 18:15:40 +00:00
|
|
|
LListHead<gprs_rlcmac_tbf> *pos;
|
2015-07-09 09:35:50 +00:00
|
|
|
gprs_rlcmac_tbf *tbf;
|
|
|
|
unsigned list_idx;
|
|
|
|
struct gprs_rlcmac_tbf **tbf_var;
|
|
|
|
|
|
|
|
for (list_idx = 0; list_idx < ARRAY_SIZE(tbf_lists); list_idx += 1)
|
|
|
|
{
|
|
|
|
|
2015-12-28 18:15:40 +00:00
|
|
|
llist_for_each(pos, tbf_lists[list_idx]) {
|
|
|
|
tbf = pos->entry();
|
2015-07-09 09:35:50 +00:00
|
|
|
for (pdch_no = 0; pdch_no < 8; pdch_no += 1) {
|
|
|
|
struct gprs_rlcmac_pdch *pdch = tbf->pdch[pdch_no];
|
|
|
|
if (pdch == NULL)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
tbf_var = &tfi_usage
|
|
|
|
[tbf->trx->trx_no]
|
|
|
|
[pdch_no]
|
|
|
|
[tbf->direction]
|
|
|
|
[tbf->tfi()];
|
|
|
|
|
|
|
|
OSMO_ASSERT(*tbf_var == NULL);
|
|
|
|
if (tbf->direction == GPRS_RLCMAC_DL_TBF) {
|
|
|
|
OSMO_ASSERT(pdch->dl_tbf_by_tfi(
|
|
|
|
tbf->tfi()) == tbf);
|
|
|
|
OSMO_ASSERT(the_bts->dl_tbf_by_tfi(
|
|
|
|
tbf->tfi(),
|
2015-07-10 17:52:37 +00:00
|
|
|
tbf->trx->trx_no,
|
|
|
|
pdch_no) == tbf);
|
2015-07-09 09:35:50 +00:00
|
|
|
} else {
|
|
|
|
OSMO_ASSERT(pdch->ul_tbf_by_tfi(
|
|
|
|
tbf->tfi()) == tbf);
|
|
|
|
OSMO_ASSERT(the_bts->ul_tbf_by_tfi(
|
|
|
|
tbf->tfi(),
|
2015-07-10 17:52:37 +00:00
|
|
|
tbf->trx->trx_no,
|
|
|
|
pdch_no) == tbf);
|
2015-07-09 09:35:50 +00:00
|
|
|
}
|
|
|
|
*tbf_var = tbf;
|
2015-07-08 10:53:16 +00:00
|
|
|
OSMO_ASSERT(pdch->assigned_tfi(tbf->direction) &
|
|
|
|
(1 << tbf->tfi()));
|
2015-07-09 09:35:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-29 10:45:11 +00:00
|
|
|
static void test_alloc_a(gprs_rlcmac_tbf_direction dir,
|
|
|
|
uint8_t slots, const int count)
|
2013-10-16 15:29:31 +00:00
|
|
|
{
|
|
|
|
int tfi;
|
2015-06-29 10:45:11 +00:00
|
|
|
int i;
|
2015-07-09 09:35:50 +00:00
|
|
|
uint8_t used_trx, tmp_trx;
|
2013-10-19 19:10:38 +00:00
|
|
|
BTS the_bts;
|
2020-05-08 16:15:59 +00:00
|
|
|
GprsMs *ms;
|
2013-10-19 19:10:38 +00:00
|
|
|
struct gprs_rlcmac_bts *bts;
|
2015-07-10 10:25:25 +00:00
|
|
|
struct gprs_rlcmac_tbf *tbfs[32*8+1] = { 0, };
|
2013-10-16 15:29:31 +00:00
|
|
|
|
|
|
|
printf("Testing alloc_a direction(%d)\n", dir);
|
|
|
|
|
2013-10-19 19:10:38 +00:00
|
|
|
bts = the_bts.bts_data();
|
|
|
|
bts->alloc_algorithm = alloc_algorithm_a;
|
2013-10-16 15:29:31 +00:00
|
|
|
|
2013-10-19 19:10:38 +00:00
|
|
|
struct gprs_rlcmac_trx *trx = &bts->trx[0];
|
2015-06-29 10:45:11 +00:00
|
|
|
for (i = 0; i < 8; i += 1)
|
|
|
|
if (slots & (1 << i))
|
|
|
|
trx->pdch[i].enable();
|
|
|
|
|
|
|
|
OSMO_ASSERT(count >= 0 && count <= (int)ARRAY_SIZE(tbfs));
|
2013-10-16 15:29:31 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Currently alloc_a will only allocate from the first
|
|
|
|
* PDCH and all possible usf's. We run out of usf's before
|
|
|
|
* we are out of tfi's. Observe this and make sure that at
|
|
|
|
* least this part is working okay.
|
|
|
|
*/
|
2015-07-10 10:25:25 +00:00
|
|
|
for (i = 0; i < (int)ARRAY_SIZE(tbfs); ++i) {
|
2020-05-08 16:15:59 +00:00
|
|
|
ms = bts->bts->ms_alloc(0, 0);
|
|
|
|
tbfs[i] = tbf_alloc(bts, ms, dir, -1, 0);
|
2015-07-10 10:25:25 +00:00
|
|
|
if (tbfs[i] == NULL)
|
|
|
|
break;
|
|
|
|
|
|
|
|
used_trx = tbfs[i]->trx->trx_no;
|
2015-07-09 09:35:50 +00:00
|
|
|
tfi = the_bts.tfi_find_free(dir, &tmp_trx, used_trx);
|
|
|
|
OSMO_ASSERT(tbfs[i]->tfi() != tfi);
|
2013-10-16 15:29:31 +00:00
|
|
|
}
|
|
|
|
|
2015-07-10 10:25:25 +00:00
|
|
|
check_tfi_usage(&the_bts);
|
|
|
|
|
|
|
|
OSMO_ASSERT(i == count);
|
2013-10-16 15:29:31 +00:00
|
|
|
|
2015-07-10 10:25:25 +00:00
|
|
|
for (i = 0; i < count; ++i)
|
2013-10-16 15:29:31 +00:00
|
|
|
if (tbfs[i])
|
|
|
|
tbf_free(tbfs[i]);
|
|
|
|
|
2020-05-08 16:15:59 +00:00
|
|
|
ms = bts->bts->ms_alloc(0, 0);
|
|
|
|
tbfs[0] = tbf_alloc(bts, ms, dir, -1, 0);
|
2016-02-22 14:14:01 +00:00
|
|
|
OSMO_ASSERT(tbfs[0]);
|
|
|
|
tbf_free(tbfs[0]);
|
2013-10-16 15:29:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void test_alloc_a()
|
|
|
|
{
|
2015-06-29 10:45:11 +00:00
|
|
|
/* slots 2 - 3 */
|
2015-07-10 10:25:25 +00:00
|
|
|
test_alloc_a(GPRS_RLCMAC_DL_TBF, 0x0c, 32*2);
|
2015-06-19 14:35:38 +00:00
|
|
|
test_alloc_a(GPRS_RLCMAC_UL_TBF, 0x0c, 14);
|
2015-06-29 10:45:11 +00:00
|
|
|
|
|
|
|
/* slots 1 - 5 */
|
2015-07-10 10:25:25 +00:00
|
|
|
test_alloc_a(GPRS_RLCMAC_DL_TBF, 0x1e, 32*4);
|
2015-06-19 14:35:38 +00:00
|
|
|
test_alloc_a(GPRS_RLCMAC_UL_TBF, 0x1e, 28);
|
2013-10-16 15:29:31 +00:00
|
|
|
}
|
|
|
|
|
2017-11-21 17:13:31 +00:00
|
|
|
static void dump_assignment(struct gprs_rlcmac_tbf *tbf, const char *dir, bool verbose)
|
2013-12-25 18:16:55 +00:00
|
|
|
{
|
2017-11-21 17:13:31 +00:00
|
|
|
if (!verbose)
|
|
|
|
return;
|
|
|
|
|
2015-05-04 06:21:17 +00:00
|
|
|
for (size_t i = 0; i < ARRAY_SIZE(tbf->pdch); ++i)
|
2013-12-25 18:16:55 +00:00
|
|
|
if (tbf->pdch[i])
|
2017-02-08 16:07:40 +00:00
|
|
|
printf("PDCH[%zu] is used for %s\n", i, dir);
|
2013-12-25 18:16:55 +00:00
|
|
|
printf("PDCH[%d] is control_ts for %s\n", tbf->control_ts, dir);
|
|
|
|
printf("PDCH[%d] is first common for %s\n", tbf->first_common_ts, dir);
|
|
|
|
}
|
|
|
|
|
2017-11-21 17:13:31 +00:00
|
|
|
#define ENABLE_PDCH(ts_no, enable_flag, trx) \
|
|
|
|
if (enable_flag) \
|
|
|
|
trx->pdch[ts_no].enable();
|
|
|
|
|
|
|
|
static inline void enable_ts_on_bts(struct gprs_rlcmac_bts *bts,
|
|
|
|
bool ts0, bool ts1, bool ts2, bool ts3, bool ts4, bool ts5, bool ts6, bool ts7)
|
2013-12-25 18:16:55 +00:00
|
|
|
{
|
2017-11-21 17:13:31 +00:00
|
|
|
struct gprs_rlcmac_trx *trx = &bts->trx[0];
|
2013-12-25 18:16:55 +00:00
|
|
|
|
2017-11-21 17:13:31 +00:00
|
|
|
ENABLE_PDCH(0, ts0, trx);
|
|
|
|
ENABLE_PDCH(1, ts1, trx);
|
|
|
|
ENABLE_PDCH(2, ts2, trx);
|
|
|
|
ENABLE_PDCH(3, ts3, trx);
|
|
|
|
ENABLE_PDCH(4, ts4, trx);
|
|
|
|
ENABLE_PDCH(5, ts5, trx);
|
|
|
|
ENABLE_PDCH(6, ts6, trx);
|
|
|
|
ENABLE_PDCH(7, ts7, trx);
|
|
|
|
}
|
2013-12-25 18:16:55 +00:00
|
|
|
|
2017-11-21 17:13:31 +00:00
|
|
|
static inline bool test_alloc_b_ul_dl(bool ts0, bool ts1, bool ts2, bool ts3, bool ts4, bool ts5, bool ts6, bool ts7,
|
|
|
|
uint8_t ms_class, bool verbose)
|
|
|
|
{
|
|
|
|
BTS the_bts;
|
|
|
|
struct gprs_rlcmac_bts *bts = the_bts.bts_data();
|
2020-05-08 15:44:33 +00:00
|
|
|
GprsMs *ms;
|
2017-11-21 17:13:31 +00:00
|
|
|
gprs_rlcmac_ul_tbf *ul_tbf;
|
|
|
|
gprs_rlcmac_dl_tbf *dl_tbf;
|
|
|
|
|
|
|
|
if (verbose)
|
2013-12-25 18:16:55 +00:00
|
|
|
printf("Testing UL then DL assignment.\n");
|
|
|
|
|
2017-11-21 17:13:31 +00:00
|
|
|
bts->alloc_algorithm = alloc_algorithm_b;
|
2013-12-25 18:16:55 +00:00
|
|
|
|
2017-11-21 17:13:31 +00:00
|
|
|
enable_ts_on_bts(bts, ts0, ts1, ts2, ts3, ts4, ts5, ts6, ts7);
|
2013-12-25 18:16:55 +00:00
|
|
|
|
2020-05-08 15:44:33 +00:00
|
|
|
ms = the_bts.ms_alloc(ms_class, 0);
|
|
|
|
ul_tbf = tbf_alloc_ul_tbf(bts, ms, -1, true);
|
2017-11-21 17:13:31 +00:00
|
|
|
if (!ul_tbf)
|
|
|
|
return false;
|
2013-12-25 18:16:55 +00:00
|
|
|
|
2017-11-21 17:13:31 +00:00
|
|
|
OSMO_ASSERT(ul_tbf->ms());
|
Convert GprsMS and helpers classes to C
As we integrate osmo-pcu more and more with libosmocore features, it
becomes really hard to use them since libosmocore relies heavily on C
specific compilation features, which are not available in old C++
compilers (such as designated initializers for complex types in FSMs).
GprsMs is right now a quite simple object since initial design of
osmo-pcu made it optional and most of the logic was placed and stored
duplicated in TBF objects. However, that's changing as we introduce more
features, with the GprsMS class getting more weight. Hence, let's move
it now to be a C struct in order to be able to easily use libosmocore
features there, such as FSMs.
Some helper classes which GprsMs uses are also mostly move to C since
they are mostly structs with methods, so there's no point in having
duplicated APIs for C++ and C for such simple cases.
For some more complex classes, like (ul_,dl_)tbf, C API bindings are
added where needed so that GprsMs can use functionalitites from that
class. Most of those APIs can be kept afterwards and drop the C++ ones
since they provide no benefit in general.
Change-Id: I0b50e3367aaad9dcada76da97b438e452c8b230c
2020-12-16 14:59:45 +00:00
|
|
|
OSMO_ASSERT(ms_current_trx(ul_tbf->ms()));
|
2013-12-25 18:16:55 +00:00
|
|
|
|
2017-11-21 17:13:31 +00:00
|
|
|
dump_assignment(ul_tbf, "UL", verbose);
|
2013-12-25 18:25:10 +00:00
|
|
|
|
2017-11-21 17:13:31 +00:00
|
|
|
/* assume final ack has not been sent */
|
Convert GprsMS and helpers classes to C
As we integrate osmo-pcu more and more with libosmocore features, it
becomes really hard to use them since libosmocore relies heavily on C
specific compilation features, which are not available in old C++
compilers (such as designated initializers for complex types in FSMs).
GprsMs is right now a quite simple object since initial design of
osmo-pcu made it optional and most of the logic was placed and stored
duplicated in TBF objects. However, that's changing as we introduce more
features, with the GprsMS class getting more weight. Hence, let's move
it now to be a C struct in order to be able to easily use libosmocore
features there, such as FSMs.
Some helper classes which GprsMs uses are also mostly move to C since
they are mostly structs with methods, so there's no point in having
duplicated APIs for C++ and C for such simple cases.
For some more complex classes, like (ul_,dl_)tbf, C API bindings are
added where needed so that GprsMs can use functionalitites from that
class. Most of those APIs can be kept afterwards and drop the C++ ones
since they provide no benefit in general.
Change-Id: I0b50e3367aaad9dcada76da97b438e452c8b230c
2020-12-16 14:59:45 +00:00
|
|
|
dl_tbf = tbf_alloc_dl_tbf(bts, ms, ms_current_trx(ms)->trx_no, false);
|
2017-11-21 17:13:31 +00:00
|
|
|
if (!dl_tbf)
|
|
|
|
return false;
|
2015-07-09 09:35:50 +00:00
|
|
|
|
2017-11-21 17:13:31 +00:00
|
|
|
dump_assignment(dl_tbf, "DL", verbose);
|
2013-12-25 18:16:55 +00:00
|
|
|
|
2017-11-21 17:13:31 +00:00
|
|
|
OSMO_ASSERT(dl_tbf->first_common_ts == ul_tbf->first_common_ts);
|
|
|
|
|
|
|
|
check_tfi_usage(&the_bts);
|
|
|
|
|
|
|
|
tbf_free(dl_tbf);
|
|
|
|
tbf_free(ul_tbf);
|
2013-12-25 18:16:55 +00:00
|
|
|
|
2017-11-21 17:13:31 +00:00
|
|
|
return true;
|
|
|
|
}
|
2013-12-25 18:16:55 +00:00
|
|
|
|
2017-11-21 17:13:31 +00:00
|
|
|
static inline bool test_alloc_b_dl_ul(bool ts0, bool ts1, bool ts2, bool ts3, bool ts4, bool ts5, bool ts6, bool ts7,
|
|
|
|
uint8_t ms_class, bool verbose)
|
|
|
|
{
|
|
|
|
BTS the_bts;
|
|
|
|
struct gprs_rlcmac_bts *bts = the_bts.bts_data();
|
2020-05-08 15:44:33 +00:00
|
|
|
GprsMs *ms;
|
2017-11-21 17:13:31 +00:00
|
|
|
gprs_rlcmac_ul_tbf *ul_tbf;
|
|
|
|
gprs_rlcmac_dl_tbf *dl_tbf;
|
|
|
|
|
|
|
|
if (verbose)
|
2013-12-25 18:16:55 +00:00
|
|
|
printf("Testing DL then UL assignment followed by update\n");
|
|
|
|
|
2017-11-21 17:13:31 +00:00
|
|
|
bts->alloc_algorithm = alloc_algorithm_b;
|
2013-12-25 18:16:55 +00:00
|
|
|
|
2017-11-21 17:13:31 +00:00
|
|
|
enable_ts_on_bts(bts, ts0, ts1, ts2, ts3, ts4, ts5, ts6, ts7);
|
2013-12-25 18:16:55 +00:00
|
|
|
|
2020-05-08 16:15:59 +00:00
|
|
|
ms = the_bts.ms_alloc(ms_class, 0);
|
|
|
|
dl_tbf = tbf_alloc_dl_tbf(bts, ms, -1, true);
|
2017-11-21 17:13:31 +00:00
|
|
|
if (!dl_tbf)
|
|
|
|
return false;
|
2013-12-25 18:16:55 +00:00
|
|
|
|
2017-11-21 17:13:31 +00:00
|
|
|
dl_tbf->update_ms(0x23, GPRS_RLCMAC_DL_TBF);
|
2020-05-08 16:15:59 +00:00
|
|
|
OSMO_ASSERT(dl_tbf->ms() == ms);
|
Convert GprsMS and helpers classes to C
As we integrate osmo-pcu more and more with libosmocore features, it
becomes really hard to use them since libosmocore relies heavily on C
specific compilation features, which are not available in old C++
compilers (such as designated initializers for complex types in FSMs).
GprsMs is right now a quite simple object since initial design of
osmo-pcu made it optional and most of the logic was placed and stored
duplicated in TBF objects. However, that's changing as we introduce more
features, with the GprsMS class getting more weight. Hence, let's move
it now to be a C struct in order to be able to easily use libosmocore
features there, such as FSMs.
Some helper classes which GprsMs uses are also mostly move to C since
they are mostly structs with methods, so there's no point in having
duplicated APIs for C++ and C for such simple cases.
For some more complex classes, like (ul_,dl_)tbf, C API bindings are
added where needed so that GprsMs can use functionalitites from that
class. Most of those APIs can be kept afterwards and drop the C++ ones
since they provide no benefit in general.
Change-Id: I0b50e3367aaad9dcada76da97b438e452c8b230c
2020-12-16 14:59:45 +00:00
|
|
|
OSMO_ASSERT(ms_current_trx(dl_tbf->ms()));
|
2013-12-25 18:25:10 +00:00
|
|
|
|
2017-11-21 17:13:31 +00:00
|
|
|
dump_assignment(dl_tbf, "DL", verbose);
|
2013-12-25 18:16:55 +00:00
|
|
|
|
Convert GprsMS and helpers classes to C
As we integrate osmo-pcu more and more with libosmocore features, it
becomes really hard to use them since libosmocore relies heavily on C
specific compilation features, which are not available in old C++
compilers (such as designated initializers for complex types in FSMs).
GprsMs is right now a quite simple object since initial design of
osmo-pcu made it optional and most of the logic was placed and stored
duplicated in TBF objects. However, that's changing as we introduce more
features, with the GprsMS class getting more weight. Hence, let's move
it now to be a C struct in order to be able to easily use libosmocore
features there, such as FSMs.
Some helper classes which GprsMs uses are also mostly move to C since
they are mostly structs with methods, so there's no point in having
duplicated APIs for C++ and C for such simple cases.
For some more complex classes, like (ul_,dl_)tbf, C API bindings are
added where needed so that GprsMs can use functionalitites from that
class. Most of those APIs can be kept afterwards and drop the C++ ones
since they provide no benefit in general.
Change-Id: I0b50e3367aaad9dcada76da97b438e452c8b230c
2020-12-16 14:59:45 +00:00
|
|
|
ul_tbf = tbf_alloc_ul_tbf(bts, ms, ms_current_trx(ms)->trx_no, false);
|
2017-11-21 17:13:31 +00:00
|
|
|
if (!ul_tbf)
|
|
|
|
return false;
|
2015-07-09 09:35:50 +00:00
|
|
|
|
2017-11-21 17:13:31 +00:00
|
|
|
ul_tbf->update_ms(0x23, GPRS_RLCMAC_UL_TBF);
|
|
|
|
ul_tbf->m_contention_resolution_done = 1;
|
2013-12-25 18:16:55 +00:00
|
|
|
|
2017-11-21 17:13:31 +00:00
|
|
|
dump_assignment(ul_tbf, "UL", verbose);
|
2013-12-25 18:16:55 +00:00
|
|
|
|
2017-11-21 17:13:31 +00:00
|
|
|
OSMO_ASSERT(dl_tbf->first_common_ts == ul_tbf->first_common_ts);
|
2013-12-25 18:16:55 +00:00
|
|
|
|
2017-11-21 17:13:31 +00:00
|
|
|
/* now update the dl_tbf */
|
|
|
|
dl_tbf->update();
|
|
|
|
dump_assignment(dl_tbf, "DL", verbose);
|
|
|
|
OSMO_ASSERT(dl_tbf->first_common_ts == ul_tbf->first_common_ts);
|
2013-12-25 18:16:55 +00:00
|
|
|
|
2017-11-21 17:13:31 +00:00
|
|
|
check_tfi_usage(&the_bts);
|
2013-12-25 18:16:55 +00:00
|
|
|
|
2017-11-21 17:13:31 +00:00
|
|
|
tbf_free(dl_tbf);
|
|
|
|
tbf_free(ul_tbf);
|
2013-12-25 18:16:55 +00:00
|
|
|
|
2017-11-21 17:13:31 +00:00
|
|
|
return true;
|
|
|
|
}
|
2013-12-25 18:16:55 +00:00
|
|
|
|
2017-11-21 17:13:31 +00:00
|
|
|
static inline bool test_alloc_b_jolly(uint8_t ms_class)
|
|
|
|
{
|
|
|
|
BTS the_bts;
|
|
|
|
struct gprs_rlcmac_bts *bts = the_bts.bts_data();
|
2020-05-08 15:44:33 +00:00
|
|
|
GprsMs *ms;
|
2017-11-21 17:13:31 +00:00
|
|
|
int tfi;
|
|
|
|
uint8_t trx_no;
|
|
|
|
gprs_rlcmac_tbf *ul_tbf, *dl_tbf;
|
2013-12-25 18:16:55 +00:00
|
|
|
|
2017-11-21 17:13:31 +00:00
|
|
|
printf("Testing jolly example\n");
|
2013-12-25 18:25:10 +00:00
|
|
|
|
2017-11-21 17:13:31 +00:00
|
|
|
bts->alloc_algorithm = alloc_algorithm_b;
|
2015-07-09 09:35:50 +00:00
|
|
|
|
2017-11-21 17:13:31 +00:00
|
|
|
enable_ts_on_bts(bts, false, true, true, true, true, false, false, false);
|
|
|
|
|
|
|
|
tfi = the_bts.tfi_find_free(GPRS_RLCMAC_UL_TBF, &trx_no, -1);
|
|
|
|
OSMO_ASSERT(tfi >= 0);
|
2020-05-08 15:44:33 +00:00
|
|
|
ms = the_bts.ms_alloc(ms_class, 0);
|
|
|
|
ul_tbf = tbf_alloc_ul_tbf(bts, ms, -1, false);
|
2017-11-21 17:13:31 +00:00
|
|
|
if (!ul_tbf)
|
|
|
|
return false;
|
|
|
|
|
2020-05-08 16:15:59 +00:00
|
|
|
OSMO_ASSERT(ul_tbf->ms() == ms);
|
Convert GprsMS and helpers classes to C
As we integrate osmo-pcu more and more with libosmocore features, it
becomes really hard to use them since libosmocore relies heavily on C
specific compilation features, which are not available in old C++
compilers (such as designated initializers for complex types in FSMs).
GprsMs is right now a quite simple object since initial design of
osmo-pcu made it optional and most of the logic was placed and stored
duplicated in TBF objects. However, that's changing as we introduce more
features, with the GprsMS class getting more weight. Hence, let's move
it now to be a C struct in order to be able to easily use libosmocore
features there, such as FSMs.
Some helper classes which GprsMs uses are also mostly move to C since
they are mostly structs with methods, so there's no point in having
duplicated APIs for C++ and C for such simple cases.
For some more complex classes, like (ul_,dl_)tbf, C API bindings are
added where needed so that GprsMs can use functionalitites from that
class. Most of those APIs can be kept afterwards and drop the C++ ones
since they provide no benefit in general.
Change-Id: I0b50e3367aaad9dcada76da97b438e452c8b230c
2020-12-16 14:59:45 +00:00
|
|
|
OSMO_ASSERT(ms_current_trx(ul_tbf->ms()));
|
|
|
|
trx_no = ms_current_trx(ms)->trx_no;
|
2017-11-21 17:13:31 +00:00
|
|
|
dump_assignment(ul_tbf, "UL", true);
|
|
|
|
|
|
|
|
/* assume final ack has not been sent */
|
2020-05-08 16:15:59 +00:00
|
|
|
dl_tbf = tbf_alloc_dl_tbf(bts, ms, trx_no, false);
|
2017-11-21 17:13:31 +00:00
|
|
|
if (!dl_tbf)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
dump_assignment(dl_tbf, "DL", true);
|
|
|
|
|
|
|
|
OSMO_ASSERT(dl_tbf->first_common_ts == ul_tbf->first_common_ts);
|
|
|
|
|
|
|
|
check_tfi_usage(&the_bts);
|
|
|
|
|
|
|
|
tbf_free(dl_tbf);
|
|
|
|
tbf_free(ul_tbf);
|
|
|
|
|
|
|
|
return true;
|
2013-12-25 18:16:55 +00:00
|
|
|
}
|
|
|
|
|
2017-11-21 17:13:31 +00:00
|
|
|
static void test_alloc_b_for_ms(uint8_t ms_class)
|
|
|
|
{
|
|
|
|
bool rc;
|
|
|
|
|
|
|
|
printf("Going to test multislot assignment MS_CLASS=%d\n", ms_class);
|
|
|
|
/*
|
|
|
|
* PDCH is on TS 6,7,8 and we start with a UL allocation and
|
|
|
|
* then follow two DL allocations (once single, once normal).
|
|
|
|
*
|
|
|
|
* Uplink assigned and still available..
|
|
|
|
*/
|
|
|
|
|
|
|
|
rc = test_alloc_b_ul_dl(false, false, false, false, false, true, true, true, ms_class, true);
|
|
|
|
if (!rc)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test with the other order.. first DL and then UL
|
|
|
|
*/
|
|
|
|
rc = test_alloc_b_dl_ul(false, false, false, false, false, true, true, true, ms_class, true);
|
|
|
|
if (!rc)
|
|
|
|
return;
|
2013-12-26 09:19:18 +00:00
|
|
|
|
2017-11-21 17:13:31 +00:00
|
|
|
/* Andreas osmocom-pcu example */
|
|
|
|
test_alloc_b_jolly(ms_class);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_alloc_mass(bool ts0, bool ts1, bool ts2, bool ts3, bool ts4, bool ts5, bool ts6, bool ts7, int ms_class)
|
2013-12-26 09:19:18 +00:00
|
|
|
{
|
2017-11-21 17:13:31 +00:00
|
|
|
bool rc;
|
|
|
|
|
2013-12-26 09:19:18 +00:00
|
|
|
/* we can test the allocation failures differently */
|
|
|
|
if (!ts0 && !ts1 && !ts2 && !ts3 && !ts4 && !ts5 && !ts6 && !ts7)
|
|
|
|
return;
|
|
|
|
|
|
|
|
printf("Mass test: TS0(%c%c%c%c%c%c%c%c)TS7 MS_Class=%d\n",
|
|
|
|
ts0 ? 'O' : 'x',
|
|
|
|
ts1 ? 'O' : 'x',
|
|
|
|
ts2 ? 'O' : 'x',
|
|
|
|
ts3 ? 'O' : 'x',
|
|
|
|
ts4 ? 'O' : 'x',
|
|
|
|
ts5 ? 'O' : 'x',
|
|
|
|
ts6 ? 'O' : 'x',
|
|
|
|
ts7 ? 'O' : 'x', ms_class);
|
|
|
|
fflush(stdout);
|
|
|
|
|
2017-11-21 17:13:31 +00:00
|
|
|
rc = test_alloc_b_ul_dl(ts0, ts1, ts2, ts3, ts4, ts5, ts6, ts7, ms_class, false);
|
|
|
|
if (!rc)
|
|
|
|
return;
|
2013-12-26 09:19:18 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Test with the other order.. first DL and then UL
|
|
|
|
*/
|
2017-11-21 17:13:31 +00:00
|
|
|
test_alloc_b_dl_ul(ts0, ts1, ts2, ts3, ts4, ts5, ts6, ts7, ms_class, false);
|
2013-12-26 09:19:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void test_all_alloc_b()
|
|
|
|
{
|
|
|
|
/* it is a bit crazy... */
|
|
|
|
for (uint8_t ts0 = 0; ts0 < 2; ++ts0)
|
|
|
|
for (uint8_t ts1 = 0; ts1 < 2; ++ts1)
|
|
|
|
for (uint8_t ts2 = 0; ts2 < 2; ++ts2)
|
|
|
|
for (uint8_t ts3 = 0; ts3 < 2; ++ts3)
|
|
|
|
for (uint8_t ts4 = 0; ts4 < 2; ++ts4)
|
|
|
|
for (uint8_t ts5 = 0; ts5 < 2; ++ts5)
|
|
|
|
for (uint8_t ts6 = 0; ts6 < 2; ++ts6)
|
|
|
|
for (uint8_t ts7 = 0; ts7 < 2; ++ts7)
|
2018-01-23 19:57:08 +00:00
|
|
|
for (int ms_class = 0; ms_class < mslot_class_max(); ++ms_class)
|
2017-11-21 17:13:31 +00:00
|
|
|
test_alloc_mass(ts0, ts1, ts2, ts3, ts4, ts5, ts6, ts7, ms_class);
|
2013-12-26 09:19:18 +00:00
|
|
|
}
|
|
|
|
|
2013-12-25 18:25:10 +00:00
|
|
|
static void test_alloc_b()
|
|
|
|
{
|
2018-01-23 19:57:08 +00:00
|
|
|
for (int i = 0; i < mslot_class_max(); ++i)
|
2017-11-21 17:13:31 +00:00
|
|
|
test_alloc_b_for_ms(i);
|
2013-12-26 09:19:18 +00:00
|
|
|
|
|
|
|
test_all_alloc_b();
|
2013-12-25 18:25:10 +00:00
|
|
|
}
|
|
|
|
|
2017-09-28 13:56:05 +00:00
|
|
|
typedef int (*algo_t)(struct gprs_rlcmac_bts *bts, struct GprsMs *ms, struct gprs_rlcmac_tbf *tbf, bool single,
|
|
|
|
int8_t use_trx);
|
2015-06-29 10:19:52 +00:00
|
|
|
|
2015-07-16 16:19:09 +00:00
|
|
|
static char get_dir_char(uint8_t mask, uint8_t tx, uint8_t rx, uint8_t busy)
|
2015-06-29 10:19:52 +00:00
|
|
|
{
|
2015-07-16 16:19:09 +00:00
|
|
|
int offs = busy ? 32 : 0;
|
|
|
|
return (mask & tx & rx) ? 'C' + offs :
|
|
|
|
(mask & tx) ? 'U' + offs :
|
|
|
|
(mask & rx) ? 'D' + offs :
|
2015-06-29 10:19:52 +00:00
|
|
|
'.';
|
|
|
|
}
|
|
|
|
|
|
|
|
enum test_mode {
|
|
|
|
TEST_MODE_UL_ONLY,
|
|
|
|
TEST_MODE_DL_ONLY,
|
|
|
|
TEST_MODE_UL_AND_DL,
|
|
|
|
TEST_MODE_DL_AND_UL,
|
|
|
|
TEST_MODE_DL_AFTER_UL,
|
|
|
|
TEST_MODE_UL_AFTER_DL,
|
|
|
|
};
|
|
|
|
|
2017-11-27 12:21:41 +00:00
|
|
|
static inline char *test_mode_descr(enum test_mode t)
|
|
|
|
{
|
|
|
|
switch (t) {
|
|
|
|
case TEST_MODE_UL_ONLY: return (char*)"UL only";
|
|
|
|
case TEST_MODE_DL_ONLY: return (char*)"DL only";
|
|
|
|
case TEST_MODE_UL_AND_DL: return (char*)"UL and DL";
|
|
|
|
case TEST_MODE_DL_AND_UL: return (char*)"DL and UL";
|
|
|
|
case TEST_MODE_DL_AFTER_UL: return (char*)"DL after UL";
|
|
|
|
case TEST_MODE_UL_AFTER_DL: return (char*)"UL after DL";
|
|
|
|
default: return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Convert GprsMS and helpers classes to C
As we integrate osmo-pcu more and more with libosmocore features, it
becomes really hard to use them since libosmocore relies heavily on C
specific compilation features, which are not available in old C++
compilers (such as designated initializers for complex types in FSMs).
GprsMs is right now a quite simple object since initial design of
osmo-pcu made it optional and most of the logic was placed and stored
duplicated in TBF objects. However, that's changing as we introduce more
features, with the GprsMS class getting more weight. Hence, let's move
it now to be a C struct in order to be able to easily use libosmocore
features there, such as FSMs.
Some helper classes which GprsMs uses are also mostly move to C since
they are mostly structs with methods, so there's no point in having
duplicated APIs for C++ and C for such simple cases.
For some more complex classes, like (ul_,dl_)tbf, C API bindings are
added where needed so that GprsMs can use functionalitites from that
class. Most of those APIs can be kept afterwards and drop the C++ ones
since they provide no benefit in general.
Change-Id: I0b50e3367aaad9dcada76da97b438e452c8b230c
2020-12-16 14:59:45 +00:00
|
|
|
static GprsMs *alloc_tbfs(BTS *the_bts, struct GprsMs *old_ms, enum test_mode mode)
|
2015-06-29 10:19:52 +00:00
|
|
|
{
|
|
|
|
struct gprs_rlcmac_bts *bts;
|
Convert GprsMS and helpers classes to C
As we integrate osmo-pcu more and more with libosmocore features, it
becomes really hard to use them since libosmocore relies heavily on C
specific compilation features, which are not available in old C++
compilers (such as designated initializers for complex types in FSMs).
GprsMs is right now a quite simple object since initial design of
osmo-pcu made it optional and most of the logic was placed and stored
duplicated in TBF objects. However, that's changing as we introduce more
features, with the GprsMS class getting more weight. Hence, let's move
it now to be a C struct in order to be able to easily use libosmocore
features there, such as FSMs.
Some helper classes which GprsMs uses are also mostly move to C since
they are mostly structs with methods, so there's no point in having
duplicated APIs for C++ and C for such simple cases.
For some more complex classes, like (ul_,dl_)tbf, C API bindings are
added where needed so that GprsMs can use functionalitites from that
class. Most of those APIs can be kept afterwards and drop the C++ ones
since they provide no benefit in general.
Change-Id: I0b50e3367aaad9dcada76da97b438e452c8b230c
2020-12-16 14:59:45 +00:00
|
|
|
struct GprsMs *ms, *new_ms;
|
2015-07-10 08:41:36 +00:00
|
|
|
uint8_t trx_no = -1;
|
2015-06-29 10:19:52 +00:00
|
|
|
|
Convert GprsMS and helpers classes to C
As we integrate osmo-pcu more and more with libosmocore features, it
becomes really hard to use them since libosmocore relies heavily on C
specific compilation features, which are not available in old C++
compilers (such as designated initializers for complex types in FSMs).
GprsMs is right now a quite simple object since initial design of
osmo-pcu made it optional and most of the logic was placed and stored
duplicated in TBF objects. However, that's changing as we introduce more
features, with the GprsMS class getting more weight. Hence, let's move
it now to be a C struct in order to be able to easily use libosmocore
features there, such as FSMs.
Some helper classes which GprsMs uses are also mostly move to C since
they are mostly structs with methods, so there's no point in having
duplicated APIs for C++ and C for such simple cases.
For some more complex classes, like (ul_,dl_)tbf, C API bindings are
added where needed so that GprsMs can use functionalitites from that
class. Most of those APIs can be kept afterwards and drop the C++ ones
since they provide no benefit in general.
Change-Id: I0b50e3367aaad9dcada76da97b438e452c8b230c
2020-12-16 14:59:45 +00:00
|
|
|
OSMO_ASSERT(old_ms != NULL);
|
2020-05-08 15:44:33 +00:00
|
|
|
|
2015-06-29 10:19:52 +00:00
|
|
|
bts = the_bts->bts_data();
|
|
|
|
|
|
|
|
gprs_rlcmac_tbf *tbf = NULL;
|
|
|
|
|
Convert GprsMS and helpers classes to C
As we integrate osmo-pcu more and more with libosmocore features, it
becomes really hard to use them since libosmocore relies heavily on C
specific compilation features, which are not available in old C++
compilers (such as designated initializers for complex types in FSMs).
GprsMs is right now a quite simple object since initial design of
osmo-pcu made it optional and most of the logic was placed and stored
duplicated in TBF objects. However, that's changing as we introduce more
features, with the GprsMS class getting more weight. Hence, let's move
it now to be a C struct in order to be able to easily use libosmocore
features there, such as FSMs.
Some helper classes which GprsMs uses are also mostly move to C since
they are mostly structs with methods, so there's no point in having
duplicated APIs for C++ and C for such simple cases.
For some more complex classes, like (ul_,dl_)tbf, C API bindings are
added where needed so that GprsMs can use functionalitites from that
class. Most of those APIs can be kept afterwards and drop the C++ ones
since they provide no benefit in general.
Change-Id: I0b50e3367aaad9dcada76da97b438e452c8b230c
2020-12-16 14:59:45 +00:00
|
|
|
if (ms_current_trx(old_ms))
|
|
|
|
trx_no = ms_current_trx(old_ms)->trx_no;
|
2015-07-10 08:41:36 +00:00
|
|
|
|
Convert GprsMS and helpers classes to C
As we integrate osmo-pcu more and more with libosmocore features, it
becomes really hard to use them since libosmocore relies heavily on C
specific compilation features, which are not available in old C++
compilers (such as designated initializers for complex types in FSMs).
GprsMs is right now a quite simple object since initial design of
osmo-pcu made it optional and most of the logic was placed and stored
duplicated in TBF objects. However, that's changing as we introduce more
features, with the GprsMS class getting more weight. Hence, let's move
it now to be a C struct in order to be able to easily use libosmocore
features there, such as FSMs.
Some helper classes which GprsMs uses are also mostly move to C since
they are mostly structs with methods, so there's no point in having
duplicated APIs for C++ and C for such simple cases.
For some more complex classes, like (ul_,dl_)tbf, C API bindings are
added where needed so that GprsMs can use functionalitites from that
class. Most of those APIs can be kept afterwards and drop the C++ ones
since they provide no benefit in general.
Change-Id: I0b50e3367aaad9dcada76da97b438e452c8b230c
2020-12-16 14:59:45 +00:00
|
|
|
ms_ref(old_ms);
|
2015-07-13 12:38:18 +00:00
|
|
|
|
2015-06-29 10:19:52 +00:00
|
|
|
/* Allocate what is needed first */
|
|
|
|
switch (mode) {
|
|
|
|
case TEST_MODE_UL_ONLY:
|
|
|
|
case TEST_MODE_DL_AFTER_UL:
|
|
|
|
case TEST_MODE_UL_AND_DL:
|
Convert GprsMS and helpers classes to C
As we integrate osmo-pcu more and more with libosmocore features, it
becomes really hard to use them since libosmocore relies heavily on C
specific compilation features, which are not available in old C++
compilers (such as designated initializers for complex types in FSMs).
GprsMs is right now a quite simple object since initial design of
osmo-pcu made it optional and most of the logic was placed and stored
duplicated in TBF objects. However, that's changing as we introduce more
features, with the GprsMS class getting more weight. Hence, let's move
it now to be a C struct in order to be able to easily use libosmocore
features there, such as FSMs.
Some helper classes which GprsMs uses are also mostly move to C since
they are mostly structs with methods, so there's no point in having
duplicated APIs for C++ and C for such simple cases.
For some more complex classes, like (ul_,dl_)tbf, C API bindings are
added where needed so that GprsMs can use functionalitites from that
class. Most of those APIs can be kept afterwards and drop the C++ ones
since they provide no benefit in general.
Change-Id: I0b50e3367aaad9dcada76da97b438e452c8b230c
2020-12-16 14:59:45 +00:00
|
|
|
if (ms_ul_tbf(old_ms))
|
|
|
|
tbf_free(ms_ul_tbf(old_ms));
|
|
|
|
tbf = tbf_alloc_ul_tbf(bts, old_ms, trx_no, false);
|
|
|
|
if (tbf == NULL) {
|
|
|
|
ms_unref(old_ms);
|
2015-06-29 10:19:52 +00:00
|
|
|
return NULL;
|
Convert GprsMS and helpers classes to C
As we integrate osmo-pcu more and more with libosmocore features, it
becomes really hard to use them since libosmocore relies heavily on C
specific compilation features, which are not available in old C++
compilers (such as designated initializers for complex types in FSMs).
GprsMs is right now a quite simple object since initial design of
osmo-pcu made it optional and most of the logic was placed and stored
duplicated in TBF objects. However, that's changing as we introduce more
features, with the GprsMS class getting more weight. Hence, let's move
it now to be a C struct in order to be able to easily use libosmocore
features there, such as FSMs.
Some helper classes which GprsMs uses are also mostly move to C since
they are mostly structs with methods, so there's no point in having
duplicated APIs for C++ and C for such simple cases.
For some more complex classes, like (ul_,dl_)tbf, C API bindings are
added where needed so that GprsMs can use functionalitites from that
class. Most of those APIs can be kept afterwards and drop the C++ ones
since they provide no benefit in general.
Change-Id: I0b50e3367aaad9dcada76da97b438e452c8b230c
2020-12-16 14:59:45 +00:00
|
|
|
}
|
2015-06-29 10:19:52 +00:00
|
|
|
break;
|
|
|
|
case TEST_MODE_DL_ONLY:
|
|
|
|
case TEST_MODE_UL_AFTER_DL:
|
|
|
|
case TEST_MODE_DL_AND_UL:
|
Convert GprsMS and helpers classes to C
As we integrate osmo-pcu more and more with libosmocore features, it
becomes really hard to use them since libosmocore relies heavily on C
specific compilation features, which are not available in old C++
compilers (such as designated initializers for complex types in FSMs).
GprsMs is right now a quite simple object since initial design of
osmo-pcu made it optional and most of the logic was placed and stored
duplicated in TBF objects. However, that's changing as we introduce more
features, with the GprsMS class getting more weight. Hence, let's move
it now to be a C struct in order to be able to easily use libosmocore
features there, such as FSMs.
Some helper classes which GprsMs uses are also mostly move to C since
they are mostly structs with methods, so there's no point in having
duplicated APIs for C++ and C for such simple cases.
For some more complex classes, like (ul_,dl_)tbf, C API bindings are
added where needed so that GprsMs can use functionalitites from that
class. Most of those APIs can be kept afterwards and drop the C++ ones
since they provide no benefit in general.
Change-Id: I0b50e3367aaad9dcada76da97b438e452c8b230c
2020-12-16 14:59:45 +00:00
|
|
|
if (ms_dl_tbf(old_ms))
|
|
|
|
tbf_free(ms_dl_tbf(old_ms));
|
|
|
|
tbf = tbf_alloc_dl_tbf(bts, old_ms, trx_no, false);
|
|
|
|
if (tbf == NULL) {
|
|
|
|
ms_unref(old_ms);
|
2015-06-29 10:19:52 +00:00
|
|
|
return NULL;
|
Convert GprsMS and helpers classes to C
As we integrate osmo-pcu more and more with libosmocore features, it
becomes really hard to use them since libosmocore relies heavily on C
specific compilation features, which are not available in old C++
compilers (such as designated initializers for complex types in FSMs).
GprsMs is right now a quite simple object since initial design of
osmo-pcu made it optional and most of the logic was placed and stored
duplicated in TBF objects. However, that's changing as we introduce more
features, with the GprsMS class getting more weight. Hence, let's move
it now to be a C struct in order to be able to easily use libosmocore
features there, such as FSMs.
Some helper classes which GprsMs uses are also mostly move to C since
they are mostly structs with methods, so there's no point in having
duplicated APIs for C++ and C for such simple cases.
For some more complex classes, like (ul_,dl_)tbf, C API bindings are
added where needed so that GprsMs can use functionalitites from that
class. Most of those APIs can be kept afterwards and drop the C++ ones
since they provide no benefit in general.
Change-Id: I0b50e3367aaad9dcada76da97b438e452c8b230c
2020-12-16 14:59:45 +00:00
|
|
|
}
|
2015-06-29 10:19:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
OSMO_ASSERT(tbf);
|
|
|
|
OSMO_ASSERT(tbf->ms());
|
Convert GprsMS and helpers classes to C
As we integrate osmo-pcu more and more with libosmocore features, it
becomes really hard to use them since libosmocore relies heavily on C
specific compilation features, which are not available in old C++
compilers (such as designated initializers for complex types in FSMs).
GprsMs is right now a quite simple object since initial design of
osmo-pcu made it optional and most of the logic was placed and stored
duplicated in TBF objects. However, that's changing as we introduce more
features, with the GprsMS class getting more weight. Hence, let's move
it now to be a C struct in order to be able to easily use libosmocore
features there, such as FSMs.
Some helper classes which GprsMs uses are also mostly move to C since
they are mostly structs with methods, so there's no point in having
duplicated APIs for C++ and C for such simple cases.
For some more complex classes, like (ul_,dl_)tbf, C API bindings are
added where needed so that GprsMs can use functionalitites from that
class. Most of those APIs can be kept afterwards and drop the C++ ones
since they provide no benefit in general.
Change-Id: I0b50e3367aaad9dcada76da97b438e452c8b230c
2020-12-16 14:59:45 +00:00
|
|
|
OSMO_ASSERT(old_ms == tbf->ms());
|
2015-06-29 10:19:52 +00:00
|
|
|
ms = tbf->ms();
|
|
|
|
|
Convert GprsMS and helpers classes to C
As we integrate osmo-pcu more and more with libosmocore features, it
becomes really hard to use them since libosmocore relies heavily on C
specific compilation features, which are not available in old C++
compilers (such as designated initializers for complex types in FSMs).
GprsMs is right now a quite simple object since initial design of
osmo-pcu made it optional and most of the logic was placed and stored
duplicated in TBF objects. However, that's changing as we introduce more
features, with the GprsMS class getting more weight. Hence, let's move
it now to be a C struct in order to be able to easily use libosmocore
features there, such as FSMs.
Some helper classes which GprsMs uses are also mostly move to C since
they are mostly structs with methods, so there's no point in having
duplicated APIs for C++ and C for such simple cases.
For some more complex classes, like (ul_,dl_)tbf, C API bindings are
added where needed so that GprsMs can use functionalitites from that
class. Most of those APIs can be kept afterwards and drop the C++ ones
since they provide no benefit in general.
Change-Id: I0b50e3367aaad9dcada76da97b438e452c8b230c
2020-12-16 14:59:45 +00:00
|
|
|
ms_ref(ms);
|
|
|
|
new_ms = ms;
|
2015-06-29 10:19:52 +00:00
|
|
|
/* Continue with what is needed next */
|
|
|
|
switch (mode) {
|
|
|
|
case TEST_MODE_UL_ONLY:
|
|
|
|
case TEST_MODE_DL_ONLY:
|
|
|
|
/* We are done */
|
2015-07-07 09:31:28 +00:00
|
|
|
break;
|
2015-06-29 10:19:52 +00:00
|
|
|
|
|
|
|
case TEST_MODE_DL_AFTER_UL:
|
|
|
|
case TEST_MODE_UL_AND_DL:
|
Convert GprsMS and helpers classes to C
As we integrate osmo-pcu more and more with libosmocore features, it
becomes really hard to use them since libosmocore relies heavily on C
specific compilation features, which are not available in old C++
compilers (such as designated initializers for complex types in FSMs).
GprsMs is right now a quite simple object since initial design of
osmo-pcu made it optional and most of the logic was placed and stored
duplicated in TBF objects. However, that's changing as we introduce more
features, with the GprsMS class getting more weight. Hence, let's move
it now to be a C struct in order to be able to easily use libosmocore
features there, such as FSMs.
Some helper classes which GprsMs uses are also mostly move to C since
they are mostly structs with methods, so there's no point in having
duplicated APIs for C++ and C for such simple cases.
For some more complex classes, like (ul_,dl_)tbf, C API bindings are
added where needed so that GprsMs can use functionalitites from that
class. Most of those APIs can be kept afterwards and drop the C++ ones
since they provide no benefit in general.
Change-Id: I0b50e3367aaad9dcada76da97b438e452c8b230c
2020-12-16 14:59:45 +00:00
|
|
|
new_ms = alloc_tbfs(the_bts, ms, TEST_MODE_DL_ONLY);
|
2015-07-07 09:31:28 +00:00
|
|
|
break;
|
2015-06-29 10:19:52 +00:00
|
|
|
|
|
|
|
case TEST_MODE_UL_AFTER_DL:
|
|
|
|
case TEST_MODE_DL_AND_UL:
|
Convert GprsMS and helpers classes to C
As we integrate osmo-pcu more and more with libosmocore features, it
becomes really hard to use them since libosmocore relies heavily on C
specific compilation features, which are not available in old C++
compilers (such as designated initializers for complex types in FSMs).
GprsMs is right now a quite simple object since initial design of
osmo-pcu made it optional and most of the logic was placed and stored
duplicated in TBF objects. However, that's changing as we introduce more
features, with the GprsMS class getting more weight. Hence, let's move
it now to be a C struct in order to be able to easily use libosmocore
features there, such as FSMs.
Some helper classes which GprsMs uses are also mostly move to C since
they are mostly structs with methods, so there's no point in having
duplicated APIs for C++ and C for such simple cases.
For some more complex classes, like (ul_,dl_)tbf, C API bindings are
added where needed so that GprsMs can use functionalitites from that
class. Most of those APIs can be kept afterwards and drop the C++ ones
since they provide no benefit in general.
Change-Id: I0b50e3367aaad9dcada76da97b438e452c8b230c
2020-12-16 14:59:45 +00:00
|
|
|
new_ms = alloc_tbfs(the_bts, ms, TEST_MODE_UL_ONLY);
|
2015-07-07 09:31:28 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Optionally delete the TBF */
|
|
|
|
switch (mode) {
|
|
|
|
case TEST_MODE_DL_AFTER_UL:
|
|
|
|
case TEST_MODE_UL_AFTER_DL:
|
|
|
|
tbf_free(tbf);
|
2015-07-16 16:23:33 +00:00
|
|
|
tbf = NULL;
|
2015-07-07 09:31:28 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2015-06-29 10:19:52 +00:00
|
|
|
}
|
|
|
|
|
Convert GprsMS and helpers classes to C
As we integrate osmo-pcu more and more with libosmocore features, it
becomes really hard to use them since libosmocore relies heavily on C
specific compilation features, which are not available in old C++
compilers (such as designated initializers for complex types in FSMs).
GprsMs is right now a quite simple object since initial design of
osmo-pcu made it optional and most of the logic was placed and stored
duplicated in TBF objects. However, that's changing as we introduce more
features, with the GprsMS class getting more weight. Hence, let's move
it now to be a C struct in order to be able to easily use libosmocore
features there, such as FSMs.
Some helper classes which GprsMs uses are also mostly move to C since
they are mostly structs with methods, so there's no point in having
duplicated APIs for C++ and C for such simple cases.
For some more complex classes, like (ul_,dl_)tbf, C API bindings are
added where needed so that GprsMs can use functionalitites from that
class. Most of those APIs can be kept afterwards and drop the C++ ones
since they provide no benefit in general.
Change-Id: I0b50e3367aaad9dcada76da97b438e452c8b230c
2020-12-16 14:59:45 +00:00
|
|
|
if (!new_ms && tbf)
|
2015-07-16 16:23:33 +00:00
|
|
|
tbf_free(tbf);
|
|
|
|
|
Convert GprsMS and helpers classes to C
As we integrate osmo-pcu more and more with libosmocore features, it
becomes really hard to use them since libosmocore relies heavily on C
specific compilation features, which are not available in old C++
compilers (such as designated initializers for complex types in FSMs).
GprsMs is right now a quite simple object since initial design of
osmo-pcu made it optional and most of the logic was placed and stored
duplicated in TBF objects. However, that's changing as we introduce more
features, with the GprsMS class getting more weight. Hence, let's move
it now to be a C struct in order to be able to easily use libosmocore
features there, such as FSMs.
Some helper classes which GprsMs uses are also mostly move to C since
they are mostly structs with methods, so there's no point in having
duplicated APIs for C++ and C for such simple cases.
For some more complex classes, like (ul_,dl_)tbf, C API bindings are
added where needed so that GprsMs can use functionalitites from that
class. Most of those APIs can be kept afterwards and drop the C++ ones
since they provide no benefit in general.
Change-Id: I0b50e3367aaad9dcada76da97b438e452c8b230c
2020-12-16 14:59:45 +00:00
|
|
|
ms_unref(old_ms);
|
|
|
|
ms_unref(ms);
|
|
|
|
return new_ms;
|
2015-06-29 10:19:52 +00:00
|
|
|
}
|
|
|
|
|
2015-07-13 12:38:18 +00:00
|
|
|
static unsigned alloc_many_tbfs(BTS *the_bts, unsigned min_class,
|
|
|
|
unsigned max_class, enum test_mode mode)
|
2015-06-29 10:19:52 +00:00
|
|
|
{
|
|
|
|
unsigned counter;
|
|
|
|
unsigned ms_class = min_class;
|
|
|
|
|
|
|
|
for (counter = 0; 1; counter += 1) {
|
|
|
|
gprs_rlcmac_tbf *ul_tbf, *dl_tbf;
|
|
|
|
uint8_t ul_slots = 0;
|
|
|
|
uint8_t dl_slots = 0;
|
2015-07-16 16:19:09 +00:00
|
|
|
uint8_t busy_slots = 0;
|
2015-06-29 10:19:52 +00:00
|
|
|
unsigned i;
|
|
|
|
int tfi = -1;
|
2015-07-09 09:35:50 +00:00
|
|
|
int tfi2;
|
2015-07-16 16:19:09 +00:00
|
|
|
uint8_t trx_no2;
|
|
|
|
struct gprs_rlcmac_trx *trx;
|
2015-06-29 10:19:52 +00:00
|
|
|
GprsMs *ms;
|
2015-07-09 09:35:50 +00:00
|
|
|
enum gprs_rlcmac_tbf_direction dir;
|
2015-07-13 12:38:18 +00:00
|
|
|
uint32_t tlli = counter + 0xc0000000;
|
|
|
|
|
|
|
|
ms = the_bts->ms_by_tlli(tlli);
|
2020-05-08 15:44:33 +00:00
|
|
|
if (!ms)
|
|
|
|
ms = the_bts->ms_alloc(0, 0);
|
Convert GprsMS and helpers classes to C
As we integrate osmo-pcu more and more with libosmocore features, it
becomes really hard to use them since libosmocore relies heavily on C
specific compilation features, which are not available in old C++
compilers (such as designated initializers for complex types in FSMs).
GprsMs is right now a quite simple object since initial design of
osmo-pcu made it optional and most of the logic was placed and stored
duplicated in TBF objects. However, that's changing as we introduce more
features, with the GprsMS class getting more weight. Hence, let's move
it now to be a C struct in order to be able to easily use libosmocore
features there, such as FSMs.
Some helper classes which GprsMs uses are also mostly move to C since
they are mostly structs with methods, so there's no point in having
duplicated APIs for C++ and C for such simple cases.
For some more complex classes, like (ul_,dl_)tbf, C API bindings are
added where needed so that GprsMs can use functionalitites from that
class. Most of those APIs can be kept afterwards and drop the C++ ones
since they provide no benefit in general.
Change-Id: I0b50e3367aaad9dcada76da97b438e452c8b230c
2020-12-16 14:59:45 +00:00
|
|
|
ms_set_ms_class(ms, ms_class);
|
2020-05-08 16:15:59 +00:00
|
|
|
ms = alloc_tbfs(the_bts, ms, mode);
|
2015-06-29 10:19:52 +00:00
|
|
|
if (!ms)
|
|
|
|
break;
|
|
|
|
|
Convert GprsMS and helpers classes to C
As we integrate osmo-pcu more and more with libosmocore features, it
becomes really hard to use them since libosmocore relies heavily on C
specific compilation features, which are not available in old C++
compilers (such as designated initializers for complex types in FSMs).
GprsMs is right now a quite simple object since initial design of
osmo-pcu made it optional and most of the logic was placed and stored
duplicated in TBF objects. However, that's changing as we introduce more
features, with the GprsMS class getting more weight. Hence, let's move
it now to be a C struct in order to be able to easily use libosmocore
features there, such as FSMs.
Some helper classes which GprsMs uses are also mostly move to C since
they are mostly structs with methods, so there's no point in having
duplicated APIs for C++ and C for such simple cases.
For some more complex classes, like (ul_,dl_)tbf, C API bindings are
added where needed so that GprsMs can use functionalitites from that
class. Most of those APIs can be kept afterwards and drop the C++ ones
since they provide no benefit in general.
Change-Id: I0b50e3367aaad9dcada76da97b438e452c8b230c
2020-12-16 14:59:45 +00:00
|
|
|
ms_set_tlli(ms, tlli);
|
2015-07-13 12:38:18 +00:00
|
|
|
|
Convert GprsMS and helpers classes to C
As we integrate osmo-pcu more and more with libosmocore features, it
becomes really hard to use them since libosmocore relies heavily on C
specific compilation features, which are not available in old C++
compilers (such as designated initializers for complex types in FSMs).
GprsMs is right now a quite simple object since initial design of
osmo-pcu made it optional and most of the logic was placed and stored
duplicated in TBF objects. However, that's changing as we introduce more
features, with the GprsMS class getting more weight. Hence, let's move
it now to be a C struct in order to be able to easily use libosmocore
features there, such as FSMs.
Some helper classes which GprsMs uses are also mostly move to C since
they are mostly structs with methods, so there's no point in having
duplicated APIs for C++ and C for such simple cases.
For some more complex classes, like (ul_,dl_)tbf, C API bindings are
added where needed so that GprsMs can use functionalitites from that
class. Most of those APIs can be kept afterwards and drop the C++ ones
since they provide no benefit in general.
Change-Id: I0b50e3367aaad9dcada76da97b438e452c8b230c
2020-12-16 14:59:45 +00:00
|
|
|
ul_tbf = ms_ul_tbf(ms);
|
|
|
|
dl_tbf = ms_dl_tbf(ms);
|
|
|
|
trx = ms_current_trx(ms);
|
2015-07-16 16:19:09 +00:00
|
|
|
|
|
|
|
OSMO_ASSERT(ul_tbf || dl_tbf);
|
2015-06-29 10:19:52 +00:00
|
|
|
|
|
|
|
if (ul_tbf) {
|
|
|
|
ul_slots = 1 << ul_tbf->first_common_ts;
|
|
|
|
tfi = ul_tbf->tfi();
|
2015-07-09 09:35:50 +00:00
|
|
|
dir = GPRS_RLCMAC_UL_TBF;
|
2015-07-16 16:19:09 +00:00
|
|
|
} else {
|
2015-06-29 10:19:52 +00:00
|
|
|
ul_slots = 1 << dl_tbf->first_common_ts;
|
|
|
|
tfi = dl_tbf->tfi();
|
2015-07-09 09:35:50 +00:00
|
|
|
dir = GPRS_RLCMAC_DL_TBF;
|
2015-06-29 10:19:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; dl_tbf && i < ARRAY_SIZE(dl_tbf->pdch); i += 1)
|
|
|
|
if (dl_tbf->pdch[i])
|
|
|
|
dl_slots |= 1 << i;
|
|
|
|
|
2017-09-11 08:38:59 +00:00
|
|
|
for (i = 0; ul_tbf && i < ARRAY_SIZE(ul_tbf->pdch); i += 1)
|
|
|
|
if (ul_tbf->pdch[i])
|
|
|
|
ul_slots |= 1 << i;
|
|
|
|
|
2015-07-16 16:19:09 +00:00
|
|
|
for (i = 0; trx && i < ARRAY_SIZE(trx->pdch); i += 1) {
|
|
|
|
struct gprs_rlcmac_pdch *pdch = &trx->pdch[i];
|
|
|
|
|
|
|
|
if (ul_tbf && dl_tbf)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (ul_tbf &&
|
2017-09-20 15:55:28 +00:00
|
|
|
pdch->assigned_tfi(GPRS_RLCMAC_DL_TBF) != NO_FREE_TFI)
|
2015-07-16 16:19:09 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
if (dl_tbf &&
|
2017-09-20 15:55:28 +00:00
|
|
|
pdch->assigned_tfi(GPRS_RLCMAC_UL_TBF) != NO_FREE_TFI)
|
2015-07-16 16:19:09 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
busy_slots |= 1 << i;
|
|
|
|
}
|
|
|
|
|
2017-09-20 15:55:28 +00:00
|
|
|
printf(" TBF[%d] class %d reserves " OSMO_BIT_SPEC "\n",
|
2015-06-29 10:19:52 +00:00
|
|
|
tfi, ms_class,
|
2015-07-16 16:19:09 +00:00
|
|
|
get_dir_char(0x01, ul_slots, dl_slots, busy_slots),
|
|
|
|
get_dir_char(0x02, ul_slots, dl_slots, busy_slots),
|
|
|
|
get_dir_char(0x04, ul_slots, dl_slots, busy_slots),
|
|
|
|
get_dir_char(0x08, ul_slots, dl_slots, busy_slots),
|
|
|
|
get_dir_char(0x10, ul_slots, dl_slots, busy_slots),
|
|
|
|
get_dir_char(0x20, ul_slots, dl_slots, busy_slots),
|
|
|
|
get_dir_char(0x40, ul_slots, dl_slots, busy_slots),
|
|
|
|
get_dir_char(0x80, ul_slots, dl_slots, busy_slots));
|
2015-06-29 10:19:52 +00:00
|
|
|
|
2015-07-09 09:35:50 +00:00
|
|
|
if (tfi >= 0) {
|
Convert GprsMS and helpers classes to C
As we integrate osmo-pcu more and more with libosmocore features, it
becomes really hard to use them since libosmocore relies heavily on C
specific compilation features, which are not available in old C++
compilers (such as designated initializers for complex types in FSMs).
GprsMs is right now a quite simple object since initial design of
osmo-pcu made it optional and most of the logic was placed and stored
duplicated in TBF objects. However, that's changing as we introduce more
features, with the GprsMS class getting more weight. Hence, let's move
it now to be a C struct in order to be able to easily use libosmocore
features there, such as FSMs.
Some helper classes which GprsMs uses are also mostly move to C since
they are mostly structs with methods, so there's no point in having
duplicated APIs for C++ and C for such simple cases.
For some more complex classes, like (ul_,dl_)tbf, C API bindings are
added where needed so that GprsMs can use functionalitites from that
class. Most of those APIs can be kept afterwards and drop the C++ ones
since they provide no benefit in general.
Change-Id: I0b50e3367aaad9dcada76da97b438e452c8b230c
2020-12-16 14:59:45 +00:00
|
|
|
OSMO_ASSERT(ms_current_trx(ms));
|
2015-07-16 16:19:09 +00:00
|
|
|
tfi2 = the_bts->tfi_find_free(dir, &trx_no2,
|
Convert GprsMS and helpers classes to C
As we integrate osmo-pcu more and more with libosmocore features, it
becomes really hard to use them since libosmocore relies heavily on C
specific compilation features, which are not available in old C++
compilers (such as designated initializers for complex types in FSMs).
GprsMs is right now a quite simple object since initial design of
osmo-pcu made it optional and most of the logic was placed and stored
duplicated in TBF objects. However, that's changing as we introduce more
features, with the GprsMS class getting more weight. Hence, let's move
it now to be a C struct in order to be able to easily use libosmocore
features there, such as FSMs.
Some helper classes which GprsMs uses are also mostly move to C since
they are mostly structs with methods, so there's no point in having
duplicated APIs for C++ and C for such simple cases.
For some more complex classes, like (ul_,dl_)tbf, C API bindings are
added where needed so that GprsMs can use functionalitites from that
class. Most of those APIs can be kept afterwards and drop the C++ ones
since they provide no benefit in general.
Change-Id: I0b50e3367aaad9dcada76da97b438e452c8b230c
2020-12-16 14:59:45 +00:00
|
|
|
ms_current_trx(ms)->trx_no);
|
2015-07-09 09:35:50 +00:00
|
|
|
OSMO_ASSERT(tfi != tfi2);
|
2015-07-16 16:28:22 +00:00
|
|
|
OSMO_ASSERT(tfi2 < 0 ||
|
Convert GprsMS and helpers classes to C
As we integrate osmo-pcu more and more with libosmocore features, it
becomes really hard to use them since libosmocore relies heavily on C
specific compilation features, which are not available in old C++
compilers (such as designated initializers for complex types in FSMs).
GprsMs is right now a quite simple object since initial design of
osmo-pcu made it optional and most of the logic was placed and stored
duplicated in TBF objects. However, that's changing as we introduce more
features, with the GprsMS class getting more weight. Hence, let's move
it now to be a C struct in order to be able to easily use libosmocore
features there, such as FSMs.
Some helper classes which GprsMs uses are also mostly move to C since
they are mostly structs with methods, so there's no point in having
duplicated APIs for C++ and C for such simple cases.
For some more complex classes, like (ul_,dl_)tbf, C API bindings are
added where needed so that GprsMs can use functionalitites from that
class. Most of those APIs can be kept afterwards and drop the C++ ones
since they provide no benefit in general.
Change-Id: I0b50e3367aaad9dcada76da97b438e452c8b230c
2020-12-16 14:59:45 +00:00
|
|
|
trx_no2 == ms_current_trx(ms)->trx_no);
|
2015-07-09 09:35:50 +00:00
|
|
|
}
|
|
|
|
|
2015-06-29 10:19:52 +00:00
|
|
|
ms_class += 1;
|
|
|
|
if (ms_class > max_class)
|
|
|
|
ms_class = min_class;
|
|
|
|
}
|
|
|
|
|
2015-07-13 12:38:18 +00:00
|
|
|
return counter;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_successive_allocation(algo_t algo, unsigned min_class,
|
|
|
|
unsigned max_class, enum test_mode mode,
|
|
|
|
unsigned expect_num, const char *text)
|
|
|
|
{
|
|
|
|
BTS the_bts;
|
|
|
|
struct gprs_rlcmac_bts *bts;
|
|
|
|
struct gprs_rlcmac_trx *trx;
|
|
|
|
unsigned counter;
|
|
|
|
|
2017-11-27 12:21:41 +00:00
|
|
|
printf("Going to test assignment with many TBF, algorithm %s class %u..%u (%s)\n",
|
|
|
|
text, min_class, max_class, test_mode_descr(mode));
|
2015-07-13 12:38:18 +00:00
|
|
|
|
|
|
|
bts = the_bts.bts_data();
|
|
|
|
bts->alloc_algorithm = algo;
|
|
|
|
|
|
|
|
trx = &bts->trx[0];
|
|
|
|
trx->pdch[3].enable();
|
|
|
|
trx->pdch[4].enable();
|
|
|
|
trx->pdch[5].enable();
|
|
|
|
trx->pdch[6].enable();
|
|
|
|
trx->pdch[7].enable();
|
|
|
|
|
|
|
|
counter = alloc_many_tbfs(&the_bts, min_class, max_class, mode);
|
|
|
|
|
2017-11-27 12:21:41 +00:00
|
|
|
printf(" Successfully allocated %u UL TBFs, algorithm %s class %u..%u (%s)\n",
|
|
|
|
counter, text, min_class, max_class, test_mode_descr(mode));
|
2015-07-16 13:01:38 +00:00
|
|
|
if (counter != expect_num)
|
2017-11-27 12:21:41 +00:00
|
|
|
fprintf(stderr, " Expected %u TBFs (got %u), algorithm %s class %u..%u (%s)\n",
|
|
|
|
expect_num, counter, text, min_class, max_class, test_mode_descr(mode));
|
2015-07-16 13:01:38 +00:00
|
|
|
|
2015-06-19 14:35:38 +00:00
|
|
|
OSMO_ASSERT(counter == expect_num);
|
2015-07-10 10:25:25 +00:00
|
|
|
|
|
|
|
check_tfi_usage(&the_bts);
|
2015-06-29 10:19:52 +00:00
|
|
|
}
|
|
|
|
|
2015-07-13 12:50:08 +00:00
|
|
|
static void test_many_connections(algo_t algo, unsigned expect_num,
|
|
|
|
const char *text)
|
|
|
|
{
|
|
|
|
BTS the_bts;
|
|
|
|
struct gprs_rlcmac_bts *bts;
|
|
|
|
struct gprs_rlcmac_trx *trx;
|
|
|
|
int counter1, counter2 = -1;
|
|
|
|
unsigned i;
|
|
|
|
enum test_mode mode_seq[] = {
|
|
|
|
TEST_MODE_DL_AFTER_UL,
|
|
|
|
TEST_MODE_UL_ONLY,
|
|
|
|
TEST_MODE_DL_AFTER_UL,
|
|
|
|
TEST_MODE_DL_ONLY,
|
|
|
|
};
|
|
|
|
|
2017-11-27 12:21:41 +00:00
|
|
|
printf("Going to test assignment with many connections, algorithm %s\n", text);
|
2015-07-13 12:50:08 +00:00
|
|
|
|
|
|
|
bts = the_bts.bts_data();
|
|
|
|
bts->alloc_algorithm = algo;
|
|
|
|
|
|
|
|
trx = &bts->trx[0];
|
|
|
|
trx->pdch[3].enable();
|
|
|
|
trx->pdch[4].enable();
|
|
|
|
trx->pdch[5].enable();
|
|
|
|
trx->pdch[6].enable();
|
|
|
|
trx->pdch[7].enable();
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(mode_seq); i += 1) {
|
2018-01-23 19:57:08 +00:00
|
|
|
counter1 = alloc_many_tbfs(&the_bts, 1, mslot_class_max(), mode_seq[i]);
|
2015-07-13 12:50:08 +00:00
|
|
|
fprintf(stderr, " Allocated %d TBFs (previously %d)\n",
|
|
|
|
counter1, counter2);
|
|
|
|
|
|
|
|
check_tfi_usage(&the_bts);
|
|
|
|
|
|
|
|
/* This will stop earlier due to USF shortage */
|
|
|
|
if (mode_seq[i] == TEST_MODE_UL_ONLY)
|
|
|
|
continue;
|
|
|
|
|
2015-07-16 13:01:38 +00:00
|
|
|
if (counter2 >= 0) {
|
|
|
|
if (counter1 < counter2)
|
|
|
|
fprintf(stderr, " Expected %d >= %d in %s\n",
|
|
|
|
counter1, counter2, text);
|
2015-07-13 12:50:08 +00:00
|
|
|
OSMO_ASSERT(counter1 >= counter2);
|
2015-07-16 13:01:38 +00:00
|
|
|
}
|
2015-07-13 12:50:08 +00:00
|
|
|
|
|
|
|
counter2 = counter1;
|
|
|
|
}
|
|
|
|
|
|
|
|
printf(" Successfully allocated %d TBFs\n", counter1);
|
2015-07-16 13:01:38 +00:00
|
|
|
if (counter1 != (int)expect_num)
|
2017-11-27 12:21:41 +00:00
|
|
|
fprintf(stderr, " Expected %d TBFs (got %d) for algorithm %s\n", expect_num, counter1, text);
|
2015-07-13 12:50:08 +00:00
|
|
|
|
|
|
|
OSMO_ASSERT(expect_num == (unsigned)counter1);
|
|
|
|
}
|
|
|
|
|
2017-11-27 12:21:41 +00:00
|
|
|
static inline void test_a_b_dyn(enum test_mode mode, uint8_t exp_A, uint8_t exp_B, uint8_t exp_dyn)
|
2015-06-29 10:19:52 +00:00
|
|
|
{
|
2017-11-27 12:21:41 +00:00
|
|
|
test_successive_allocation(alloc_algorithm_a, 1, 1, mode, exp_A, "A");
|
|
|
|
test_successive_allocation(alloc_algorithm_b, 10, 10, mode, exp_B, "B");
|
|
|
|
test_successive_allocation(alloc_algorithm_dynamic, 10, 10, mode, exp_dyn, "dynamic");
|
2015-06-29 10:19:52 +00:00
|
|
|
}
|
|
|
|
|
2017-11-27 12:21:41 +00:00
|
|
|
static void test_successive_allocations()
|
2015-07-13 12:50:08 +00:00
|
|
|
{
|
2017-11-27 12:21:41 +00:00
|
|
|
test_successive_allocation(alloc_algorithm_a, 1, 1, TEST_MODE_UL_AND_DL, 35, "A");
|
|
|
|
test_successive_allocation(alloc_algorithm_b, 10, 10, TEST_MODE_UL_AND_DL, 32, "B");
|
|
|
|
test_successive_allocation(alloc_algorithm_b, 12, 12, TEST_MODE_UL_AND_DL, 32, "B");
|
|
|
|
|
2018-01-23 19:57:08 +00:00
|
|
|
test_successive_allocation(alloc_algorithm_b, 1, 12, TEST_MODE_UL_AND_DL, 32, "B");
|
2018-01-23 19:58:49 +00:00
|
|
|
test_successive_allocation(alloc_algorithm_b, 1, mslot_class_max(), TEST_MODE_UL_AND_DL, 32, "B");
|
2018-01-23 19:57:08 +00:00
|
|
|
test_successive_allocation(alloc_algorithm_dynamic, 1, mslot_class_max(), TEST_MODE_UL_AND_DL, 35, "dynamic");
|
2017-11-27 12:21:41 +00:00
|
|
|
|
|
|
|
test_a_b_dyn(TEST_MODE_DL_AND_UL, 35, 32, 32);
|
|
|
|
test_a_b_dyn(TEST_MODE_DL_AFTER_UL, 160, 32, 95);
|
|
|
|
test_a_b_dyn(TEST_MODE_UL_AFTER_DL, 35, 32, 35);
|
|
|
|
test_a_b_dyn(TEST_MODE_UL_ONLY, 35, 32, 35);
|
|
|
|
test_a_b_dyn(TEST_MODE_DL_ONLY, 160, 32, 101);
|
2015-07-13 12:50:08 +00:00
|
|
|
}
|
|
|
|
|
2016-09-06 12:45:45 +00:00
|
|
|
static void test_2_consecutive_dl_tbfs()
|
|
|
|
{
|
|
|
|
BTS the_bts;
|
2020-05-08 16:15:59 +00:00
|
|
|
GprsMs *ms;
|
2016-09-06 12:45:45 +00:00
|
|
|
struct gprs_rlcmac_bts *bts;
|
|
|
|
struct gprs_rlcmac_trx *trx;
|
|
|
|
uint8_t ms_class = 11;
|
|
|
|
uint8_t egprs_ms_class = 11;
|
|
|
|
gprs_rlcmac_tbf *dl_tbf1, *dl_tbf2;
|
|
|
|
uint8_t numTs1 = 0, numTs2 = 0;
|
|
|
|
|
|
|
|
printf("Testing DL TS allocation for Multi UEs\n");
|
|
|
|
|
|
|
|
bts = the_bts.bts_data();
|
|
|
|
bts->alloc_algorithm = alloc_algorithm_b;
|
|
|
|
|
|
|
|
trx = &bts->trx[0];
|
|
|
|
trx->pdch[4].enable();
|
|
|
|
trx->pdch[5].enable();
|
|
|
|
trx->pdch[6].enable();
|
|
|
|
trx->pdch[7].enable();
|
|
|
|
|
2020-05-08 16:15:59 +00:00
|
|
|
ms = the_bts.ms_alloc(ms_class, egprs_ms_class);
|
|
|
|
dl_tbf1 = tbf_alloc_dl_tbf(bts, ms, 0, false);
|
2016-09-06 12:45:45 +00:00
|
|
|
OSMO_ASSERT(dl_tbf1);
|
|
|
|
|
|
|
|
for (int i = 0; i < 8; i++) {
|
|
|
|
if (dl_tbf1->pdch[i])
|
|
|
|
numTs1++;
|
|
|
|
}
|
|
|
|
OSMO_ASSERT(numTs1 == 4);
|
|
|
|
printf("TBF1: numTs(%d)\n", numTs1);
|
|
|
|
|
2020-05-08 16:15:59 +00:00
|
|
|
ms = the_bts.ms_alloc(ms_class, egprs_ms_class);
|
|
|
|
dl_tbf2 = tbf_alloc_dl_tbf(bts, ms, 0, false);
|
2016-09-06 12:45:45 +00:00
|
|
|
OSMO_ASSERT(dl_tbf2);
|
|
|
|
|
|
|
|
for (int i = 0; i < 8; i++) {
|
|
|
|
if (dl_tbf2->pdch[i])
|
|
|
|
numTs2++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* TODO: currently 2nd DL TBF gets 3 TS
|
|
|
|
* This behaviour will be fixed in subsequent patch
|
|
|
|
*/
|
|
|
|
printf("TBF2: numTs(%d)\n", numTs2);
|
|
|
|
OSMO_ASSERT(numTs2 == 3);
|
|
|
|
|
|
|
|
tbf_free(dl_tbf1);
|
|
|
|
tbf_free(dl_tbf2);
|
|
|
|
}
|
|
|
|
|
2013-10-16 15:29:31 +00:00
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
tall_pcu_ctx = talloc_named_const(NULL, 1, "moiji-mobile AllocTest context");
|
|
|
|
if (!tall_pcu_ctx)
|
|
|
|
abort();
|
|
|
|
|
2017-02-08 16:07:31 +00:00
|
|
|
msgb_talloc_ctx_init(tall_pcu_ctx, 0);
|
2018-04-01 14:54:40 +00:00
|
|
|
osmo_init_logging2(tall_pcu_ctx, &gprs_log_info);
|
2013-10-16 15:29:31 +00:00
|
|
|
log_set_use_color(osmo_stderr_target, 0);
|
|
|
|
log_set_print_filename(osmo_stderr_target, 0);
|
2020-03-25 11:23:52 +00:00
|
|
|
log_set_category_filter(osmo_stderr_target, DTBF, 1, LOGL_INFO);
|
2015-06-29 11:00:20 +00:00
|
|
|
if (getenv("LOGL_DEBUG"))
|
|
|
|
log_set_log_level(osmo_stderr_target, LOGL_DEBUG);
|
2013-10-16 15:29:31 +00:00
|
|
|
|
|
|
|
test_alloc_a();
|
2013-12-25 18:16:55 +00:00
|
|
|
test_alloc_b();
|
2017-11-27 12:21:41 +00:00
|
|
|
test_successive_allocations();
|
|
|
|
test_many_connections(alloc_algorithm_a, 160, "A");
|
2018-01-23 19:58:49 +00:00
|
|
|
test_many_connections(alloc_algorithm_b, 32, "B");
|
2017-11-27 12:21:41 +00:00
|
|
|
test_many_connections(alloc_algorithm_dynamic, 160, "dynamic");
|
2016-09-06 12:45:45 +00:00
|
|
|
test_2_consecutive_dl_tbfs();
|
2013-10-16 15:29:31 +00:00
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* stubs that should not be reached
|
|
|
|
*/
|
|
|
|
extern "C" {
|
|
|
|
void l1if_pdch_req() { abort(); }
|
|
|
|
void l1if_connect_pdch() { abort(); }
|
|
|
|
void l1if_close_pdch() { abort(); }
|
|
|
|
void l1if_open_pdch() { abort(); }
|
|
|
|
}
|