PCU_Tests_RAW.ttcn: add a test case for continuous Timing Advance control

Unlike the circuit-switched domain, Uplink transmissions on PDCH time-slots
are not continuous and there can be long time gaps between them. This happens
due to a bursty nature of packet data. The actual Timing Advance of a MS may
significantly change between such rare Uplink transmissions, so GPRS introduces
additional mechanisms to control Timing Advance, and thus reduce interference
between neighboring TDMA time-slots.

At the moment of Uplink TBF establishment, initial Timing Advance is measured
from ToA (Timing of Arrival) of an Access Burst. This is covered by another
test case - TC_ta_rach_imm_ass. In response to that Access Burst the network
sends Immediate Assignment on AGCH, which _may_ contain Timing Advance Index
among with the initial Timing Advance value. And here PTCCH comes to play.

PTCCH is a unidirectional channel on which the network can instruct a sub-set
of 16 MS (whether TBFs are active or not) to adjust their Timing Advance
continuously. To ensure continuous measurements of the signal propagation
delay, the MSs shall transmit Access Bursts on Uplink (PTCCH/U) on sub-slots
defined by an assigned Timing Advance Index (see 3GPP TS 45.002).

The purpose of this test case is to verify the assignment of Timing Advance
Index, and the process of Timing Advance notification on PTCCH/D. The MTC
first establishes several Uplink TBFs, but does not transmit any Uplink
blocks on them. During 4 TDMA multi-frame periods the MTC is sending RACH
indications to the PCU, checking the correctness of two received PTCCH/D
messages (period of PTCCH/D is two multi-frames).

At the moment of writing, PTCCH handling is not implemented in OsmoPCU
(neither PTCCH/D messages are correct, nor PTCCH/U bursts are handled).

Additionally, this change introduces a new message type, which is used
for sending commands to the RAW components - RAW_PCU_Command. Commands
can be used to (re)configure components at run-time.

Change-Id: I868f78e3e95a95f8f2e55e237eea700d7d4726a3
Related: SYS#4606
diff --git a/pcu/PCUIF_RAW_Components.ttcn b/pcu/PCUIF_RAW_Components.ttcn
index 2297bbd..7feeca2 100644
--- a/pcu/PCUIF_RAW_Components.ttcn
+++ b/pcu/PCUIF_RAW_Components.ttcn
@@ -97,8 +97,30 @@
 	data := { tdma_fn := ? }
 }
 
+/* Commands are mostly used by the MTC to configure the components
+ * at run-time, e.g. to enable or disable some optional features. */
+type enumerated RAW_PCU_CommandType {
+	TDMA_CMD_ENABLE_PTCCH_UL_FWD	/*!< Enable forwarding of TDMA_EV_PTCCH_UL_BURST to the MTC */
+};
+
+type record RAW_PCU_Command {
+	RAW_PCU_CommandType cmd,
+	anytype data optional
+};
+
+template (value) RAW_PCU_Command ts_RAW_PCU_CMD(RAW_PCU_CommandType cmd) := {
+	cmd := cmd,
+	data := omit
+}
+template RAW_PCU_Command tr_RAW_PCU_CMD(template RAW_PCU_CommandType cmd := ?,
+					template anytype data := *) := {
+	cmd := cmd,
+	data := data
+}
+
 /* Generic port for messages and events */
 type port RAW_PCU_MSG_PT message {
+	inout RAW_PCU_Command;
 	inout RAW_PCU_Event;
 	inout PCUIF_Message;
 } with { extension "internal" };
@@ -191,6 +213,9 @@
 	port RAW_PCU_MSG_PT PCUIF;
 	/* Connection towards the test case */
 	port RAW_PCU_MSG_PT TC;
+
+	/* Whether to forward PTCCH/U burst events to the TC */
+	var boolean cfg_ptcch_burst_fwd := false;
 }
 
 private altstep as_BTS_CT_MsgQueue(integer bts_nr)
@@ -260,6 +285,11 @@
 		PCUIF.send(pcu_msg);
 		repeat;
 		}
+	/* Optional forwarding of PTCCH/U burst indications to the test case */
+	[cfg_ptcch_burst_fwd] CLCK.receive(tr_RAW_PCU_EV(TDMA_EV_PTCCH_UL_BURST)) -> value event {
+		TC.send(event);
+		repeat;
+		}
 	/* Ignore other clock events (and guard against an empty queue) */
 	[] CLCK.receive(tr_RAW_PCU_CLCK_EV) { repeat; }
 }
@@ -267,6 +297,7 @@
 function f_BTS_CT_handler(integer bts_nr, PCUIF_info_ind info_ind)
 runs on RAW_PCU_BTS_CT {
 	var PCUIF_Message pcu_msg;
+	var RAW_PCU_Command cmd;
 	var RAW_PCU_Event event;
 
 	/* Init TDMA clock generator (so we can stop and start it) */
@@ -308,6 +339,17 @@
 	/* TDMA scheduler (clock and queue handling) */
 	[] as_BTS_CT_TDMASched(bts_nr);
 
+	/* Command handling */
+	[] TC.receive(tr_RAW_PCU_CMD(TDMA_CMD_ENABLE_PTCCH_UL_FWD)) {
+		log("Enabling forwarding of PTCCH/U TDMA events to the TC");
+		cfg_ptcch_burst_fwd := true;
+		repeat;
+		}
+	[] TC.receive(tr_RAW_PCU_CMD) -> value cmd {
+		log("Ignore unhandled command: ", cmd);
+		repeat;
+		}
+
 	/* TODO: handle events (e.g. disconnection) from the PCU interface */
 	[] PCUIF.receive(tr_RAW_PCU_EV) -> value event {
 		log("Ignore unhandled event: ", event);