From ed9ca9719e7cac0feb8f6414a2b173bf8eeaafd8 Mon Sep 17 00:00:00 2001 From: Pau Espin Pedrol Date: Thu, 11 Mar 2021 20:53:21 +0100 Subject: [PATCH] pcu: Set up PCU TDMA clock by sending initial DATA.ind In recent osmo-pcu commits, initial fn was changed to invalid value -1, in order to be able to detect FN jumps. previously, the initial value was set randomly to 0, which was wrong anyway because first FN received from the BTS could be any other FN counted by the BTS at that time. This makes some tests fail because they send RACH.ind + RTS.ind to receive the Imm Assignment, and the Request reference in the Imm Assign was calculated on the invalid unset FN "-1", hence it won't match test expectancies. In order to fix it, simply make sure the TDMA clock is initiated by sending a DATA.ind to the PCU before tests start doing stuff (f_init_raw() is blocked waiting for BTS_EV_SI13_NEGO). Related: osmo-pcu.git Change-Id I29fb27981597edc69abb976049ba41aa840488cb Related: OS#5020 Change-Id: I00c4dd9133ec9a236bf28fb8cb0afd0615791012 --- pcu/PCUIF_Components.ttcn | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/pcu/PCUIF_Components.ttcn b/pcu/PCUIF_Components.ttcn index 6b0a4124e..76551840c 100644 --- a/pcu/PCUIF_Components.ttcn +++ b/pcu/PCUIF_Components.ttcn @@ -216,10 +216,12 @@ function f_tdma_ptcch_fn2ss(integer fn) return integer return ss; } -function f_ClckGen_CT_handler() +function f_ClckGen_CT_handler(integer start_fn := 0) runs on RAW_PCU_ClckGen_CT { var integer fn104, fn52, fn13; + fn := start_fn; + while (true) { fn104 := fn mod 104; fn52 := fn mod 52; @@ -343,6 +345,32 @@ runs on RAW_PCU_BTS_CT { } } +/* Submit empty data on any available TS, to set up initial TDMA clock */ +private function f_tx_first_data_ind(integer bts_nr, PCUIF_info_ind info_ind, integer start_fn) +runs on RAW_PCU_BTS_CT +{ + var PCUIF_Message pcu_msg; + var PCUIF_InfoV10TrxList trx_list := g_info_ind.trx.v10; + + /* Find an active TS: */ + for (var uint8_t ts_nr := 0; ts_nr < 8; ts_nr := ts_nr + 1) { + for (var integer trx_nr := 0; trx_nr < lengthof(trx_list); trx_nr := trx_nr + 1) { + if (trx_list[trx_nr].pdch_mask[ts_nr] == '0'B) { + continue; /* TRX+TS not activated */ + } + + /* Send empty DATA.ind to set up FN */ + pcu_msg := valueof(ts_PCUIF_DATA_IND(bts_nr, trx_nr, ts_nr, 0 /* FIXME */, + PCU_IF_SAPI_PDTCH, ''O, start_fn, + trx_list[trx_nr].arfcn, + rssi := -80, ber10k := 0, + ta_offs_qbits := 0, lqual_cb := 10)); + PCUIF.send(pcu_msg); + return; + } + } +} + /* Get first message from queue. true if non-empty, false otherwise */ private function f_tx_data_ind_fn(integer bts_nr, integer fn) runs on RAW_PCU_BTS_CT @@ -477,11 +505,16 @@ runs on RAW_PCU_BTS_CT { u := { info_ind := info_ind } }); + var integer start_fn := 0; + if (mp_send_all_data_ind) { + f_tx_first_data_ind(bts_nr, info_ind, start_fn); + } + /* Notify the test case that we're done with SI13 */ TC.send(ts_RAW_PCU_EV(BTS_EV_SI13_NEGO)); /* Start feeding clock to the PCU */ - vc_CLCK_GEN.start(f_ClckGen_CT_handler()); + vc_CLCK_GEN.start(f_ClckGen_CT_handler(start_fn)); repeat; } /* PCU -> TS becomes active */