diff options
Diffstat (limited to 'tests/alloc/AllocTest.cpp')
-rw-r--r-- | tests/alloc/AllocTest.cpp | 92 |
1 files changed, 39 insertions, 53 deletions
diff --git a/tests/alloc/AllocTest.cpp b/tests/alloc/AllocTest.cpp index 66bc84f3..b6f263f4 100644 --- a/tests/alloc/AllocTest.cpp +++ b/tests/alloc/AllocTest.cpp @@ -38,13 +38,13 @@ int16_t spoof_mnc = 0, spoof_mcc = 0; static gprs_rlcmac_tbf *tbf_alloc(struct gprs_rlcmac_bts *bts, GprsMs *ms, gprs_rlcmac_tbf_direction dir, - uint8_t tfi, uint8_t trx, + uint8_t use_trx, uint8_t ms_class, uint8_t single_slot) { if (dir == GPRS_RLCMAC_UL_TBF) - return tbf_alloc_ul_tbf(bts, ms, tfi, trx, ms_class, single_slot); + return tbf_alloc_ul_tbf(bts, ms, use_trx, ms_class, single_slot); else - return tbf_alloc_dl_tbf(bts, ms, tfi, trx, ms_class, single_slot); + return tbf_alloc_dl_tbf(bts, ms, use_trx, ms_class, single_slot); } static void check_tfi_usage(BTS *the_bts) @@ -133,9 +133,7 @@ static void test_alloc_a(gprs_rlcmac_tbf_direction dir, * least this part is working okay. */ for (int i = 0; i < count; ++i) { - tfi = the_bts.tfi_find_free(dir, &used_trx, 0); - OSMO_ASSERT(tfi >= 0); - tbfs[i] = tbf_alloc(bts, NULL, dir, tfi, used_trx, 0, 0); + tbfs[i] = tbf_alloc(bts, NULL, dir, -1, 0, 0); OSMO_ASSERT(tbfs[i] != NULL); tfi = the_bts.tfi_find_free(dir, &tmp_trx, used_trx); OSMO_ASSERT(tbfs[i]->tfi() != tfi); @@ -151,16 +149,13 @@ static void test_alloc_a(gprs_rlcmac_tbf_direction dir, OSMO_ASSERT(tfi < 0); break; } - OSMO_ASSERT(!tbf_alloc(bts, NULL, dir, tfi, used_trx, 0, 0)); + OSMO_ASSERT(!tbf_alloc(bts, NULL, dir, -1, 0, 0)); for (size_t i = 0; i < ARRAY_SIZE(tbfs); ++i) if (tbfs[i]) tbf_free(tbfs[i]); - tfi = the_bts.tfi_find_free(dir, &used_trx, 0); - OSMO_ASSERT(tfi >= 0); - - tbfs[tfi] = tbf_alloc(bts, NULL, dir, tfi, used_trx, 0, 0); + tbfs[tfi] = tbf_alloc(bts, NULL, dir, -1, 0, 0); OSMO_ASSERT(tbfs[tfi]); tbf_free(tbfs[tfi]); } @@ -198,7 +193,6 @@ static void test_alloc_b(int ms_class) BTS the_bts; struct gprs_rlcmac_bts *bts; struct gprs_rlcmac_trx *trx; - int tfi; uint8_t trx_no; gprs_rlcmac_tbf *ul_tbf, *dl_tbf; @@ -213,16 +207,15 @@ static void test_alloc_b(int ms_class) 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_ul_tbf(bts, NULL, tfi, trx_no, ms_class, 1); + ul_tbf = tbf_alloc_ul_tbf(bts, NULL, -1, ms_class, 1); OSMO_ASSERT(ul_tbf); + OSMO_ASSERT(ul_tbf->ms()); + OSMO_ASSERT(ul_tbf->ms()->current_trx()); + trx_no = ul_tbf->ms()->current_trx()->trx_no; 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_dl_tbf(bts, ul_tbf->ms(), tfi, trx_no, ms_class, 0); + dl_tbf = tbf_alloc_dl_tbf(bts, ul_tbf->ms(), trx_no, ms_class, 0); OSMO_ASSERT(dl_tbf); dump_assignment(dl_tbf, "DL"); @@ -241,7 +234,6 @@ static void test_alloc_b(int ms_class) BTS the_bts; struct gprs_rlcmac_bts *bts; struct gprs_rlcmac_trx *trx; - int tfi; uint8_t trx_no; gprs_rlcmac_ul_tbf *ul_tbf; @@ -257,16 +249,15 @@ static void test_alloc_b(int ms_class) 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_dl_tbf(bts, NULL, tfi, trx_no, ms_class, 1); + dl_tbf = tbf_alloc_dl_tbf(bts, NULL, -1, ms_class, 1); dl_tbf->update_ms(0x23, GPRS_RLCMAC_DL_TBF); OSMO_ASSERT(dl_tbf); + OSMO_ASSERT(dl_tbf->ms()); + OSMO_ASSERT(dl_tbf->ms()->current_trx()); + trx_no = dl_tbf->ms()->current_trx()->trx_no; 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_ul_tbf(bts, dl_tbf->ms(), tfi, trx_no, ms_class, 0); + ul_tbf = tbf_alloc_ul_tbf(bts, dl_tbf->ms(), trx_no, ms_class, 0); ul_tbf->update_ms(0x23, GPRS_RLCMAC_UL_TBF); ul_tbf->m_contention_resolution_done = 1; OSMO_ASSERT(ul_tbf); @@ -308,14 +299,15 @@ static void test_alloc_b(int ms_class) tfi = the_bts.tfi_find_free(GPRS_RLCMAC_UL_TBF, &trx_no, -1); OSMO_ASSERT(tfi >= 0); - ul_tbf = tbf_alloc_ul_tbf(bts, NULL, tfi, trx_no, ms_class, 0); + ul_tbf = tbf_alloc_ul_tbf(bts, NULL, .1, ms_class, 0); OSMO_ASSERT(ul_tbf); + OSMO_ASSERT(ul_tbf->ms()); + OSMO_ASSERT(ul_tbf->ms()->current_trx()); + trx_no = ul_tbf->ms()->current_trx()->trx_no; 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_dl_tbf(bts, ul_tbf->ms(), tfi, trx_no, ms_class, 0); + dl_tbf = tbf_alloc_dl_tbf(bts, ul_tbf->ms(), trx_no, ms_class, 0); OSMO_ASSERT(dl_tbf); dump_assignment(dl_tbf, "DL"); @@ -353,7 +345,6 @@ static void test_alloc_b(bool ts0, bool ts1, bool ts2, bool ts3, bool ts4, bool BTS the_bts; struct gprs_rlcmac_bts *bts; struct gprs_rlcmac_trx *trx; - int tfi; uint8_t trx_no; gprs_rlcmac_tbf *ul_tbf, *dl_tbf; @@ -371,16 +362,14 @@ static void test_alloc_b(bool ts0, bool ts1, bool ts2, bool ts3, bool ts4, bool ENABLE_PDCH(6, ts6, trx); ENABLE_PDCH(7, ts7, trx); - tfi = the_bts.tfi_find_free(GPRS_RLCMAC_UL_TBF, &trx_no, -1); - - OSMO_ASSERT(tfi >= 0); - ul_tbf = tbf_alloc_ul_tbf(bts, NULL, tfi, trx_no, ms_class, 1); + ul_tbf = tbf_alloc_ul_tbf(bts, NULL, -1, ms_class, 1); + OSMO_ASSERT(ul_tbf->ms()); + OSMO_ASSERT(ul_tbf->ms()->current_trx()); + trx_no = ul_tbf->ms()->current_trx()->trx_no; OSMO_ASSERT(ul_tbf); /* 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_dl_tbf(bts, ul_tbf->ms(), tfi, trx_no, ms_class, 0); + dl_tbf = tbf_alloc_dl_tbf(bts, ul_tbf->ms(), trx_no, ms_class, 0); OSMO_ASSERT(dl_tbf); /* verify that both are on the same ts */ @@ -399,7 +388,6 @@ static void test_alloc_b(bool ts0, bool ts1, bool ts2, bool ts3, bool ts4, bool BTS the_bts; struct gprs_rlcmac_bts *bts; struct gprs_rlcmac_trx *trx; - int tfi; uint8_t trx_no; gprs_rlcmac_ul_tbf *ul_tbf; @@ -418,15 +406,14 @@ static void test_alloc_b(bool ts0, bool ts1, bool ts2, bool ts3, bool ts4, bool ENABLE_PDCH(6, ts6, trx); ENABLE_PDCH(7, ts7, trx); - tfi = the_bts.tfi_find_free(GPRS_RLCMAC_UL_TBF, &trx_no, -1); - OSMO_ASSERT(tfi >= 0); - dl_tbf = tbf_alloc_dl_tbf(bts, NULL, tfi, trx_no, ms_class, 1); + dl_tbf = tbf_alloc_dl_tbf(bts, NULL, -1, ms_class, 1); OSMO_ASSERT(dl_tbf); + OSMO_ASSERT(dl_tbf->ms()); + OSMO_ASSERT(dl_tbf->ms()->current_trx()); + trx_no = dl_tbf->ms()->current_trx()->trx_no; dl_tbf->update_ms(0x23, GPRS_RLCMAC_DL_TBF); - tfi = the_bts.tfi_find_free(GPRS_RLCMAC_UL_TBF, &trx_no, -1); - OSMO_ASSERT(tfi >= 0); - ul_tbf = tbf_alloc_ul_tbf(bts, dl_tbf->ms(), tfi, trx_no, ms_class, 0); + ul_tbf = tbf_alloc_ul_tbf(bts, dl_tbf->ms(), trx_no, ms_class, 0); OSMO_ASSERT(ul_tbf); ul_tbf->update_ms(0x23, GPRS_RLCMAC_UL_TBF); ul_tbf->m_contention_resolution_done = 1; @@ -472,7 +459,8 @@ static void test_alloc_b() typedef int (*algo_t)(struct gprs_rlcmac_bts *bts, struct GprsMs *ms, - struct gprs_rlcmac_tbf *tbf, uint32_t cust, uint8_t single); + struct gprs_rlcmac_tbf *tbf, uint32_t cust, uint8_t single, + int use_trx); static char get_dir_char(uint8_t mask, uint8_t tx, uint8_t rx) { @@ -495,30 +483,28 @@ static GprsMs *alloc_tbfs(BTS *the_bts, GprsMs *ms, unsigned ms_class, enum test_mode mode) { struct gprs_rlcmac_bts *bts; - int tfi; - uint8_t trx_no; + uint8_t trx_no = -1; bts = the_bts->bts_data(); gprs_rlcmac_tbf *tbf = NULL; + if (ms && ms->current_trx()) + trx_no = ms->current_trx()->trx_no; + /* Allocate what is needed first */ switch (mode) { case TEST_MODE_UL_ONLY: case TEST_MODE_DL_AFTER_UL: case TEST_MODE_UL_AND_DL: - tfi = the_bts->tfi_find_free(GPRS_RLCMAC_UL_TBF, &trx_no, -1); - if (tfi < 0) - return NULL; - tbf = tbf_alloc_ul_tbf(bts, ms, tfi, trx_no, ms_class, 0); + tbf = tbf_alloc_ul_tbf(bts, ms, trx_no, ms_class, 0); if (tbf == NULL) return NULL; break; case TEST_MODE_DL_ONLY: case TEST_MODE_UL_AFTER_DL: case TEST_MODE_DL_AND_UL: - tfi = the_bts->tfi_find_free(GPRS_RLCMAC_DL_TBF, &trx_no, -1); - tbf = tbf_alloc_dl_tbf(bts, ms, tfi, trx_no, ms_class, 0); + tbf = tbf_alloc_dl_tbf(bts, ms, trx_no, ms_class, 0); if (tbf == NULL) return NULL; } |