aboutsummaryrefslogtreecommitdiffstats
path: root/tests/tbf/TbfTest.cpp
diff options
context:
space:
mode:
authorJacob Erlbeck <jerlbeck@sysmocom.de>2015-08-24 11:55:17 +0200
committerJacob Erlbeck <jerlbeck@sysmocom.de>2015-08-24 11:55:17 +0200
commitee31090b2e4204348f7b73d11abe2a07a723d6d8 (patch)
treead34a7b0dac0f7aaabf41434dee4568a98d3e351 /tests/tbf/TbfTest.cpp
parent64921d217badb9f6938453174da6c2172a1e4cc6 (diff)
tbf/test: Simplify RLC block number handling
The block number can always be deduced from the frame number. The current test code handles the block number explicitely, which makes the code more complex and has also led to block number errors cause by not wrapping the numbers (valid block numbers range from 0 to 11). This commit changes send_rlc_block to always compute the block number based on the frame number. It also turns the block_nr into an optionaly output-only parameter. Sponsored-by: On-Waves ehf
Diffstat (limited to 'tests/tbf/TbfTest.cpp')
-rw-r--r--tests/tbf/TbfTest.cpp28
1 files changed, 14 insertions, 14 deletions
diff --git a/tests/tbf/TbfTest.cpp b/tests/tbf/TbfTest.cpp
index f185ad75..2237d569 100644
--- a/tests/tbf/TbfTest.cpp
+++ b/tests/tbf/TbfTest.cpp
@@ -203,15 +203,18 @@ static unsigned fn_add_blocks(unsigned fn, unsigned blocks)
static void send_rlc_block(struct gprs_rlcmac_bts *bts,
uint8_t trx_no, uint8_t ts_no, uint16_t arfcn,
- uint32_t *fn, uint8_t *block_nr)
+ uint32_t *fn, uint8_t *block_nr = NULL)
{
- gprs_rlcmac_rcv_rts_block(bts, trx_no, ts_no, arfcn, *fn, *block_nr);
+ uint8_t bn = fn2bn(*fn);
+ gprs_rlcmac_rcv_rts_block(bts, trx_no, ts_no, arfcn, *fn, bn);
*fn = fn_add_blocks(*fn, 1);
- *block_nr += 1;
+ bn += 1;
+ if (block_nr)
+ *block_nr = bn;
}
static void send_rlc_block(struct gprs_rlcmac_tbf *tbf,
- uint32_t *fn, uint8_t *block_nr)
+ uint32_t *fn, uint8_t *block_nr = NULL)
{
send_rlc_block(tbf->bts->bts_data(), tbf->trx->trx_no,
tbf->control_ts, tbf->trx->arfcn, fn, block_nr);
@@ -254,10 +257,10 @@ static void test_tbf_final_ack(enum test_tbf_final_ack_mode test_mode)
/* Send only a few RLC/MAC blocks */
fn = 0;
- block_nr = 0;
- while (block_nr < 3)
+ do {
/* Request to send one block */
send_rlc_block(dl_tbf, &fn, &block_nr);
+ } while (block_nr < 3);
OSMO_ASSERT(dl_tbf->have_data());
OSMO_ASSERT(dl_tbf->state_is(GPRS_RLCMAC_FLOW));
@@ -299,7 +302,6 @@ static void test_tbf_delayed_release()
unsigned i;
uint8_t ms_class = 45;
uint32_t fn = 0;
- uint8_t block_nr = 0;
uint8_t trx_no;
uint32_t tlli = 0xffeeddcc;
@@ -331,7 +333,7 @@ static void test_tbf_delayed_release()
/* Drain the queue */
while (dl_tbf->have_data())
/* Request to send one RLC/MAC block */
- send_rlc_block(dl_tbf, &fn, &block_nr);
+ send_rlc_block(dl_tbf, &fn);
OSMO_ASSERT(dl_tbf->state_is(GPRS_RLCMAC_FLOW));
@@ -342,7 +344,7 @@ static void test_tbf_delayed_release()
OSMO_ASSERT(dl_tbf->m_window.window_empty());
/* Force sending of a single block containing an LLC dummy command */
- send_rlc_block(dl_tbf, &fn, &block_nr);
+ send_rlc_block(dl_tbf, &fn);
/* Receive an ACK */
dl_tbf->rcvd_dl_ack(0, dl_tbf->m_window.v_s(), rbb);
@@ -350,7 +352,7 @@ static void test_tbf_delayed_release()
/* Timeout (make sure fn % 52 remains valid) */
fn += 52 * ((msecs_to_frames(bts->dl_tbf_idle_msec + 100) + 51)/ 52);
- send_rlc_block(dl_tbf, &fn, &block_nr);
+ send_rlc_block(dl_tbf, &fn);
OSMO_ASSERT(dl_tbf->state_is(GPRS_RLCMAC_FINISHED));
@@ -595,7 +597,6 @@ static gprs_rlcmac_ul_tbf *establish_ul_tbf_two_phase(BTS *the_bts,
GprsMs *ms;
uint32_t rach_fn = *fn - 51;
uint32_t sba_fn = *fn + 52;
- uint8_t rts_bn = fn2bn(*fn);
uint8_t trx_no = 0;
int tfi = 0;
gprs_rlcmac_ul_tbf *ul_tbf;
@@ -608,7 +609,7 @@ static gprs_rlcmac_ul_tbf *establish_ul_tbf_two_phase(BTS *the_bts,
bts = the_bts->bts_data();
/* needed to set last_rts_fn in the PDCH object */
- send_rlc_block(bts, trx_no, ts_no, 0, fn, &rts_bn);
+ send_rlc_block(bts, trx_no, ts_no, 0, fn);
/* simulate RACH, this sends an Immediate Assignment Uplink on the AGCH */
the_bts->rcv_rach(0x73, rach_fn, qta);
@@ -642,8 +643,7 @@ static gprs_rlcmac_ul_tbf *establish_ul_tbf_two_phase(BTS *the_bts,
/* send packet uplink assignment */
*fn = sba_fn;
- rts_bn = fn2bn(*fn);
- send_rlc_block(ul_tbf, fn, &rts_bn);
+ send_rlc_block(ul_tbf, fn);
/* TODO: send real acknowledgement */
/* Fake acknowledgement */