alloc/tests: Create an allocation test for various scenarious
The allocation in the TBF/BTS code is quite complex. In parts this is due the assignment and requests occuring under differen circumstances. Attempt to re-create the commono scenarios. Remove the bogus msclass check in gprs_rlcmac_tbf::update as the allocation code will check the ms class anyway.
This commit is contained in:
parent
f37e514a96
commit
4af30533f0
|
@ -317,11 +317,6 @@ int gprs_rlcmac_tbf::update()
|
|||
if (direction != GPRS_RLCMAC_DL_TBF)
|
||||
return -EINVAL;
|
||||
|
||||
if (!ms_class) {
|
||||
LOGP(DRLCMAC, LOGL_DEBUG, "- Cannot update, no class\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
ul_tbf = bts->tbf_by_tlli(m_tlli, GPRS_RLCMAC_UL_TBF);
|
||||
|
||||
tbf_unlink_pdch(this);
|
||||
|
|
|
@ -97,6 +97,146 @@ static void test_alloc_a()
|
|||
test_alloc_a(GPRS_RLCMAC_UL_TBF, 7);
|
||||
}
|
||||
|
||||
static void dump_assignment(struct gprs_rlcmac_tbf *tbf, const char *dir)
|
||||
{
|
||||
for (int i = 0; i < ARRAY_SIZE(tbf->pdch); ++i)
|
||||
if (tbf->pdch[i])
|
||||
printf("PDCH[%d] is used for %s\n", i, dir);
|
||||
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);
|
||||
}
|
||||
|
||||
static void test_alloc_b()
|
||||
{
|
||||
printf("Going to test multislot assignment.\n");
|
||||
/*
|
||||
* 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..
|
||||
*/
|
||||
{
|
||||
BTS the_bts;
|
||||
struct gprs_rlcmac_bts *bts;
|
||||
struct gprs_rlcmac_trx *trx;
|
||||
int tfi;
|
||||
uint8_t ts_no, trx_no;
|
||||
|
||||
gprs_rlcmac_tbf *ul_tbf, *dl_tbf;
|
||||
|
||||
printf("Testing UL then DL assignment.\n");
|
||||
|
||||
bts = the_bts.bts_data();
|
||||
bts->alloc_algorithm = alloc_algorithm_b;
|
||||
|
||||
trx = &bts->trx[0];
|
||||
trx->pdch[5].enable();
|
||||
trx->pdch[6].enable();
|
||||
trx->pdch[7].enable();
|
||||
|
||||
tfi = the_bts.tfi_find_free(GPRS_RLCMAC_UL_TBF, &trx_no, -1);
|
||||
OSMO_ASSERT(tfi >= 0);
|
||||
ul_tbf = tbf_alloc(bts, NULL, GPRS_RLCMAC_UL_TBF, tfi, trx_no, 0, 1);
|
||||
OSMO_ASSERT(ul_tbf);
|
||||
dump_assignment(ul_tbf, "UL");
|
||||
|
||||
/* assume final ack has not been sent */
|
||||
tfi = the_bts.tfi_find_free(GPRS_RLCMAC_UL_TBF, &trx_no, -1);
|
||||
OSMO_ASSERT(tfi >= 0);
|
||||
dl_tbf = tbf_alloc(bts, ul_tbf, GPRS_RLCMAC_DL_TBF, tfi, trx_no, 0, 0);
|
||||
OSMO_ASSERT(dl_tbf);
|
||||
dump_assignment(dl_tbf, "DL");
|
||||
|
||||
tbf_free(dl_tbf);
|
||||
tbf_free(ul_tbf);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test with the other order.. first DL and then UL
|
||||
*/
|
||||
{
|
||||
BTS the_bts;
|
||||
struct gprs_rlcmac_bts *bts;
|
||||
struct gprs_rlcmac_trx *trx;
|
||||
int tfi;
|
||||
uint8_t ts_no, trx_no;
|
||||
|
||||
gprs_rlcmac_tbf *ul_tbf, *dl_tbf;
|
||||
|
||||
printf("Testing DL then UL assignment followed by update\n");
|
||||
|
||||
bts = the_bts.bts_data();
|
||||
bts->alloc_algorithm = alloc_algorithm_b;
|
||||
|
||||
trx = &bts->trx[0];
|
||||
trx->pdch[5].enable();
|
||||
trx->pdch[6].enable();
|
||||
trx->pdch[7].enable();
|
||||
|
||||
tfi = the_bts.tfi_find_free(GPRS_RLCMAC_UL_TBF, &trx_no, -1);
|
||||
OSMO_ASSERT(tfi >= 0);
|
||||
dl_tbf = tbf_alloc(bts, NULL, GPRS_RLCMAC_DL_TBF, tfi, trx_no, 0, 1);
|
||||
dl_tbf->m_tlli = 0x23;
|
||||
dl_tbf->m_tlli_valid = true;
|
||||
OSMO_ASSERT(dl_tbf);
|
||||
dump_assignment(dl_tbf, "DL");
|
||||
|
||||
tfi = the_bts.tfi_find_free(GPRS_RLCMAC_UL_TBF, &trx_no, -1);
|
||||
OSMO_ASSERT(tfi >= 0);
|
||||
ul_tbf = tbf_alloc(bts, dl_tbf, GPRS_RLCMAC_UL_TBF, tfi, trx_no, 0, 0);
|
||||
ul_tbf->m_tlli = 0x23;
|
||||
ul_tbf->m_tlli_valid = true;
|
||||
ul_tbf->dir.ul.contention_resolution_done = 1;
|
||||
OSMO_ASSERT(ul_tbf);
|
||||
dump_assignment(ul_tbf, "UL");
|
||||
|
||||
/* now update the dl_tbf */
|
||||
dl_tbf->update();
|
||||
dump_assignment(dl_tbf, "DL");
|
||||
|
||||
tbf_free(dl_tbf);
|
||||
tbf_free(ul_tbf);
|
||||
}
|
||||
|
||||
/* Andreas osmocom-pcu example */
|
||||
{
|
||||
BTS the_bts;
|
||||
struct gprs_rlcmac_bts *bts;
|
||||
struct gprs_rlcmac_trx *trx;
|
||||
int tfi;
|
||||
uint8_t ts_no, trx_no;
|
||||
|
||||
gprs_rlcmac_tbf *ul_tbf, *dl_tbf;
|
||||
|
||||
printf("Testing jolly example\n");
|
||||
|
||||
bts = the_bts.bts_data();
|
||||
bts->alloc_algorithm = alloc_algorithm_b;
|
||||
|
||||
trx = &bts->trx[0];
|
||||
trx->pdch[1].enable();
|
||||
trx->pdch[2].enable();
|
||||
trx->pdch[3].enable();
|
||||
trx->pdch[4].enable();
|
||||
|
||||
tfi = the_bts.tfi_find_free(GPRS_RLCMAC_UL_TBF, &trx_no, -1);
|
||||
OSMO_ASSERT(tfi >= 0);
|
||||
ul_tbf = tbf_alloc(bts, NULL, GPRS_RLCMAC_UL_TBF, tfi, trx_no, 0, 0);
|
||||
OSMO_ASSERT(ul_tbf);
|
||||
dump_assignment(ul_tbf, "UL");
|
||||
|
||||
/* assume final ack has not been sent */
|
||||
tfi = the_bts.tfi_find_free(GPRS_RLCMAC_UL_TBF, &trx_no, -1);
|
||||
OSMO_ASSERT(tfi >= 0);
|
||||
dl_tbf = tbf_alloc(bts, ul_tbf, GPRS_RLCMAC_DL_TBF, tfi, trx_no, 0, 0);
|
||||
OSMO_ASSERT(dl_tbf);
|
||||
dump_assignment(dl_tbf, "DL");
|
||||
|
||||
tbf_free(dl_tbf);
|
||||
tbf_free(ul_tbf);
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
tall_pcu_ctx = talloc_named_const(NULL, 1, "moiji-mobile AllocTest context");
|
||||
|
@ -109,6 +249,7 @@ int main(int argc, char **argv)
|
|||
log_set_print_filename(osmo_stderr_target, 0);
|
||||
|
||||
test_alloc_a();
|
||||
test_alloc_b();
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,2 +1,34 @@
|
|||
Testing alloc_a direction(0)
|
||||
Testing alloc_a direction(1)
|
||||
Going to test multislot assignment.
|
||||
Testing UL then DL assignment.
|
||||
PDCH[6] is used for UL
|
||||
PDCH[6] is control_ts for UL
|
||||
PDCH[6] is first common for UL
|
||||
PDCH[5] is used for DL
|
||||
PDCH[6] is used for DL
|
||||
PDCH[7] is used for DL
|
||||
PDCH[6] is control_ts for DL
|
||||
PDCH[6] is first common for DL
|
||||
Testing DL then UL assignment followed by update
|
||||
PDCH[6] is used for DL
|
||||
PDCH[6] is control_ts for DL
|
||||
PDCH[6] is first common for DL
|
||||
PDCH[6] is used for UL
|
||||
PDCH[6] is control_ts for UL
|
||||
PDCH[6] is first common for UL
|
||||
PDCH[5] is used for DL
|
||||
PDCH[6] is used for DL
|
||||
PDCH[7] is used for DL
|
||||
PDCH[6] is control_ts for DL
|
||||
PDCH[6] is first common for DL
|
||||
Testing jolly example
|
||||
PDCH[3] is used for UL
|
||||
PDCH[3] is control_ts for UL
|
||||
PDCH[3] is first common for UL
|
||||
PDCH[1] is used for DL
|
||||
PDCH[2] is used for DL
|
||||
PDCH[3] is used for DL
|
||||
PDCH[4] is used for DL
|
||||
PDCH[3] is control_ts for DL
|
||||
PDCH[3] is first common for DL
|
||||
|
|
Loading…
Reference in New Issue