Introduce osmo_tdef infra and timer VTY commands

This will allow for configuration of some of the timers by the user,
and allow him to inspect current values being used.
It will be also useful for TTCN3 tests which may want to test some of
the timers without having to wait for lots of time.

Timers are splitted into 2 groups: BTS controlled ones and PCU controlled
ones. The BTS controlled ones are read-only by the user (hence no
"timer" VTY command is provided to change them).

TbfTest.err output changes due to timers being set up correctly as a
consequence of changes. Other application such as pcu_emu.cpp and
pcu_main.cpp had to previosuly set the initial values by hand (and did
so), but apparently TbfTest.c was missing that part, which is now fixed
for free.

Depends: libosmocore.git Id56a1226d724a374f04231df85fe5b49ffd2c43c
Change-Id: I5cfb9ef01706124be262d4536617b9edb4601dd5
diff --git a/src/bts.cpp b/src/bts.cpp
index 60f74dd..a913ca0 100644
--- a/src/bts.cpp
+++ b/src/bts.cpp
@@ -68,6 +68,21 @@
 
 static BTS s_bts;
 
+static struct osmo_tdef T_defs_bts[] = {
+	{ .T=3142, .default_val=20,  .unit=OSMO_TDEF_S,  .desc="timer (s)", .val=0 },
+	{ .T=3169, .default_val=5,   .unit=OSMO_TDEF_S,  .desc="Reuse of USF and TFI(s) after the MS uplink TBF assignment is invalid (s)", .val=0 },
+	{ .T=3191, .default_val=5,   .unit=OSMO_TDEF_S,  .desc="Reuse of TFI(s) after sending (1) last RLC Data Block on TBF(s), or (2) PACKET TBF RELEASE for an MBMS radio bearer (s)", .val=0 },
+	{ .T=3193, .default_val=100, .unit=OSMO_TDEF_MS, .desc="Reuse of TFI(s) after reception of final PACKET DOWNLINK ACK/NACK from MS for TBF (ms)", .val=0 },
+	{ .T=3195, .default_val=5,   .unit=OSMO_TDEF_S,  .desc="Reuse of TFI(s) upon no response from the MS (radio failure or cell change) for TBF/MBMS radio bearer (s)", .val=0 },
+	{}
+};
+static struct osmo_tdef T_defs_pcu[] = {
+	{ .T=-2000, .default_val=2,   .unit=OSMO_TDEF_MS, .desc="Tbf reject for PRR timer (ms)",            .val=0 },
+	{ .T=-2001, .default_val=2,   .unit=OSMO_TDEF_S,  .desc="PACCH assignment timer (s)",               .val=0 },
+	{ .T=-2002, .default_val=200, .unit=OSMO_TDEF_MS, .desc="Waiting after IMM.ASS confirm timer (ms)", .val=0 },
+	{}
+};
+
 /**
  * For gcc-4.4 compat do not use extended initializer list but keep the
  * order from the enum here. Once we support GCC4.7 and up we can change
@@ -217,6 +232,10 @@
 	memset(&m_bts, 0, sizeof(m_bts));
 	m_bts.bts = this;
 	m_bts.dl_tbf_preemptive_retransmission = true;
+	m_bts.T_defs_bts = T_defs_bts;
+	m_bts.T_defs_pcu = T_defs_pcu;
+	osmo_tdefs_reset(m_bts.T_defs_bts);
+	osmo_tdefs_reset(m_bts.T_defs_pcu);
 
 	/* initialize back pointers */
 	for (size_t trx_no = 0; trx_no < ARRAY_SIZE(m_bts.trx); ++trx_no) {
@@ -570,7 +589,7 @@
 	LOGP(DRLCMAC, LOGL_DEBUG, "Got IMM.ASS confirm for TLLI=%08x\n", tlli);
 
 	if (dl_tbf->m_wait_confirm)
-		T_START(dl_tbf, T0, 0, T_ASS_AGCH_USEC, "assignment (AGCH)", true);
+		T_START(dl_tbf, T0, -2002, "assignment (AGCH)", true);
 
 	return 0;
 }
@@ -761,7 +780,7 @@
 			tbf->set_ta(ta);
 			TBF_SET_STATE(tbf, GPRS_RLCMAC_FLOW);
 			TBF_ASS_TYPE_SET(tbf, GPRS_RLCMAC_FLAG_CCCH);
-			T_START(tbf, T3169, m_bts.t3169, 0, "RACH (new UL-TBF)", true);
+			T_START(tbf, T3169, 3169, "RACH (new UL-TBF)", true);
 			LOGPTBF(tbf, LOGL_DEBUG, "[UPLINK] START\n");
 			LOGPTBF(tbf, LOGL_DEBUG, "RX: [PCU <- BTS] RACH "
 					"qbit-ta=%d ra=0x%02x, Fn=%d "