2017-11-01 18:22:25 +00:00
|
|
|
/* MslotTest.cpp
|
|
|
|
*
|
|
|
|
* Copyright (C) 2017 by sysmocom - s.f.m.c. GmbH <info@sysmocom.de>
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "gprs_rlcmac.h"
|
|
|
|
#include "gprs_debug.h"
|
|
|
|
#include "tbf.h"
|
|
|
|
#include "bts.h"
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <errno.h>
|
|
|
|
|
|
|
|
extern "C" {
|
2018-02-05 15:15:30 +00:00
|
|
|
#include "mslot_class.h"
|
2017-11-01 18:22:25 +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;
|
2017-11-01 18:22:25 +00:00
|
|
|
|
|
|
|
static inline void test_all_classes(struct gprs_rlcmac_trx *trx, bool clear_masks)
|
|
|
|
{
|
|
|
|
int i, rc;
|
|
|
|
uint8_t dl_slots = 0, ul_slots = 0;
|
|
|
|
|
|
|
|
for (i = 0; i < 64; i++) {
|
|
|
|
rc = find_multi_slots(trx, i, &ul_slots, &dl_slots);
|
|
|
|
|
|
|
|
printf(" [%s] multislot class %3u - UL: " OSMO_BIT_SPEC " DL: " OSMO_BIT_SPEC " [%d]\n",
|
|
|
|
clear_masks ? "SEQ" : "ACC", i, OSMO_BIT_PRINT(ul_slots), OSMO_BIT_PRINT(dl_slots), rc);
|
|
|
|
|
|
|
|
if (rc == -EINVAL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (clear_masks) {
|
|
|
|
dl_slots = 0;
|
|
|
|
ul_slots = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void test_multislot_total_ascending(bool seq)
|
|
|
|
{
|
2021-01-18 16:14:14 +00:00
|
|
|
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
|
2017-11-01 18:22:25 +00:00
|
|
|
struct gprs_rlcmac_trx *trx;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
printf("%s(): %s\n", __func__, seq ? "sequential" : "accumulative");
|
|
|
|
|
|
|
|
trx = &bts->trx[0];
|
|
|
|
|
|
|
|
for (i = 0; i < 8; i++) {
|
|
|
|
printf(" Enabled PDCH %u for multislot tests...\n", i);
|
|
|
|
trx->pdch[i].enable();
|
|
|
|
|
|
|
|
test_all_classes(trx, seq);
|
|
|
|
}
|
2021-01-14 15:48:38 +00:00
|
|
|
talloc_free(bts);
|
2017-11-01 18:22:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void test_multislot_total_descending(bool seq)
|
|
|
|
{
|
2021-01-18 16:14:14 +00:00
|
|
|
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
|
2017-11-01 18:22:25 +00:00
|
|
|
struct gprs_rlcmac_trx *trx;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
printf("%s(): %s\n", __func__, seq ? "sequential" : "accumulative");
|
|
|
|
|
|
|
|
trx = &bts->trx[0];
|
|
|
|
|
|
|
|
for (i = 7; i >= 0; i--) {
|
|
|
|
printf(" Enabled PDCH %u for multislot tests...\n", i);
|
|
|
|
trx->pdch[i].enable();
|
|
|
|
|
|
|
|
test_all_classes(trx, seq);
|
|
|
|
}
|
2021-01-14 15:48:38 +00:00
|
|
|
talloc_free(bts);
|
2017-11-01 18:22:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void test_multislot_middle(bool seq)
|
|
|
|
{
|
2021-01-18 16:14:14 +00:00
|
|
|
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
|
2017-11-01 18:22:25 +00:00
|
|
|
struct gprs_rlcmac_trx *trx;
|
|
|
|
|
|
|
|
printf("%s(): %s\n", __func__, seq ? "sequential" : "accumulative");
|
|
|
|
|
|
|
|
trx = &bts->trx[0];
|
|
|
|
|
|
|
|
trx->pdch[2].enable();
|
|
|
|
trx->pdch[3].enable();
|
|
|
|
trx->pdch[4].enable();
|
|
|
|
|
|
|
|
test_all_classes(trx, seq);
|
2021-01-14 15:48:38 +00:00
|
|
|
talloc_free(bts);
|
2017-11-01 18:22:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void test_multislot_ends(bool seq)
|
|
|
|
{
|
2021-01-18 16:14:14 +00:00
|
|
|
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
|
2017-11-01 18:22:25 +00:00
|
|
|
struct gprs_rlcmac_trx *trx;
|
|
|
|
|
|
|
|
printf("%s(): %s\n", __func__, seq ? "sequential" : "accumulative");
|
|
|
|
|
|
|
|
trx = &bts->trx[0];
|
|
|
|
|
|
|
|
trx->pdch[0].enable();
|
|
|
|
trx->pdch[7].enable();
|
|
|
|
|
|
|
|
test_all_classes(trx, seq);
|
2021-01-14 15:48:38 +00:00
|
|
|
talloc_free(bts);
|
2017-11-01 18:22:25 +00:00
|
|
|
}
|
|
|
|
|
2018-02-05 15:15:30 +00:00
|
|
|
static inline void test_window_wrapper()
|
|
|
|
{
|
|
|
|
uint16_t i;
|
|
|
|
for (i = 0; i < 256 * 2 + 1; i++)
|
|
|
|
printf("W[%03u] -> %3u %s\n",
|
|
|
|
i, mslot_wrap_window(i), mslot_wrap_window(i) < 256 ? "OK" : "FAIL");
|
|
|
|
}
|
2017-11-01 18:22:25 +00:00
|
|
|
|
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
tall_pcu_ctx = talloc_named_const(NULL, 1, "MslotTest context");
|
|
|
|
if (!tall_pcu_ctx)
|
|
|
|
abort();
|
|
|
|
|
|
|
|
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);
|
2017-11-01 18:22:25 +00:00
|
|
|
log_set_use_color(osmo_stderr_target, 0);
|
2021-02-19 13:01:52 +00:00
|
|
|
log_set_print_filename2(osmo_stderr_target, LOG_FILENAME_NONE);
|
2017-11-01 18:22:25 +00:00
|
|
|
log_set_log_level(osmo_stderr_target, LOGL_DEBUG);
|
|
|
|
|
Split PCU global PCU object from BTS object
Currently the BTS object (and gprs_rlcmac_bts struct) are used to hold
both PCU global fields and BTS specific fields, all mangled together.
The BTS is even accessed in lots of places by means of a singleton.
This patch introduces a new struct gprs_pcu object aimed at holding all
global state, and several fields are already moved from BTS to it. The
new object can be accessed as global variable "the_pcu", reusing and
including an already exisitng "the_pcu" global variable only used for
bssgp related purposes so far.
This is only a first step towards having a complete split global pcu and
BTS, some fields are still kept in BTS and will be moved over follow-up
smaller patches in the future (since this patch is already quite big).
So far, the code still only supports one BTS, which can be accessed
using the_pcu->bts. In the future that field will be replaced with a
list, and the BTS singletons will be removed.
The cur_fn output changes in TbfTest are actually a side effect fix,
since the singleton main_bts() now points internally to the_pcu->bts,
hence the same we allocate and assign in the test. Beforehand, "the_bts"
was allocated in the stack while main_bts() still returned an unrelated
singleton BTS object instance.
Related: OS#4935
Change-Id: I88e3c6471b80245ce3798223f1a61190f14aa840
2021-01-13 17:54:38 +00:00
|
|
|
the_pcu = gprs_pcu_alloc(tall_pcu_ctx);
|
|
|
|
|
2017-11-01 18:22:25 +00:00
|
|
|
test_multislot_total_ascending(true);
|
|
|
|
test_multislot_total_ascending(false);
|
|
|
|
|
|
|
|
test_multislot_total_descending(true);
|
|
|
|
test_multislot_total_descending(false);
|
|
|
|
|
|
|
|
test_multislot_middle(true);
|
|
|
|
test_multislot_middle(false);
|
|
|
|
|
|
|
|
test_multislot_ends(true);
|
|
|
|
test_multislot_ends(false);
|
|
|
|
|
2018-02-05 15:15:30 +00:00
|
|
|
test_window_wrapper();
|
|
|
|
|
Split PCU global PCU object from BTS object
Currently the BTS object (and gprs_rlcmac_bts struct) are used to hold
both PCU global fields and BTS specific fields, all mangled together.
The BTS is even accessed in lots of places by means of a singleton.
This patch introduces a new struct gprs_pcu object aimed at holding all
global state, and several fields are already moved from BTS to it. The
new object can be accessed as global variable "the_pcu", reusing and
including an already exisitng "the_pcu" global variable only used for
bssgp related purposes so far.
This is only a first step towards having a complete split global pcu and
BTS, some fields are still kept in BTS and will be moved over follow-up
smaller patches in the future (since this patch is already quite big).
So far, the code still only supports one BTS, which can be accessed
using the_pcu->bts. In the future that field will be replaced with a
list, and the BTS singletons will be removed.
The cur_fn output changes in TbfTest are actually a side effect fix,
since the singleton main_bts() now points internally to the_pcu->bts,
hence the same we allocate and assign in the test. Beforehand, "the_bts"
was allocated in the stack while main_bts() still returned an unrelated
singleton BTS object instance.
Related: OS#4935
Change-Id: I88e3c6471b80245ce3798223f1a61190f14aa840
2021-01-13 17:54:38 +00:00
|
|
|
talloc_free(the_pcu);
|
|
|
|
|
2017-11-01 18:22:25 +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(); }
|
|
|
|
}
|