fixup pcu/GPRS_Components: do not duplicate existing functions

Both f_ms_rx_imm_ass_ccch() and f_ms_establish_ul_tbf() functions
are actually twin brothers of good old f_pcuif_rx_imm_ass() and
f_establish_tbf() with some minor changes.

The former accepts a GprsMS parameter, that is never used. The
latter simply calls f_ultbf_new_from_rr_imm_ass() in the end.

Let's avoid code duplication:

  - call f_establish_tbf() from f_ms_establish_ul_tbf(),
  - remove f_ms_rx_imm_ass_ccch(), use f_pcuif_rx_imm_ass().

After the removal of f_ms_rx_imm_ass_ccch(), the implementation
of TC_ta_idle_dl_tbf_ass() does not need the GprsMS state, so
let's make it look like it was before.

Change-Id: If6c0b8796500e96525b7b1cadb61ab2fc84b4744
diff --git a/pcu/GPRS_Components.ttcn b/pcu/GPRS_Components.ttcn
index 9db13b4..af35f40 100644
--- a/pcu/GPRS_Components.ttcn
+++ b/pcu/GPRS_Components.ttcn
@@ -249,45 +249,6 @@
 	}
 }
 
-function f_ms_rx_imm_ass_ccch(inout GprsMS ms, template PCUIF_Sapi sapi := PCU_IF_SAPI_AGCH, template GsmRrMessage t_imm_ass := ?)
-runs on MS_BTS_IFACE_CT return GsmRrMessage {
-	var PCUIF_Message pcu_msg;
-	var GsmRrMessage rr_imm_ass;
-	var octetstring data;
-	timer T;
-
-	T.start(2.0);
-	alt {
-	[] BTS.receive(tr_PCUIF_DATA_REQ(bts_nr := 0, trx_nr := 0, ts_nr := 0,
-					 sapi := sapi, data := ?)) -> value pcu_msg {
-		/* On PCH the payload is prefixed with paging group (3 octets): skip it.
-		 * TODO: add an additional template parameter, so we can match it. */
-		if (pcu_msg.u.data_req.sapi == PCU_IF_SAPI_PCH) {
-			data := substr(pcu_msg.u.data_req.data, 3, pcu_msg.u.data_req.len - 3);
-		} else {
-			data := pcu_msg.u.data_req.data;
-		}
-
-		rr_imm_ass := dec_GsmRrMessage(data);
-		if (not match(rr_imm_ass, t_imm_ass)) {
-		        /* Not for us? Wait for more. */
-		        repeat;
-		}
-
-		log("Rx Immediate Assignment: ", rr_imm_ass);
-		f_pcuif_tx_data_cnf(pcu_msg);
-		setverdict(pass);
-		return rr_imm_ass;
-		}
-	[] BTS.receive { repeat; }
-	[] T.timeout {
-		setverdict(fail, "Timeout waiting for Immediate Assignment");
-		f_shutdown(__BFILE__, __LINE__);
-		}
-	}
-	return rr_imm_ass; /* make compiler happy */
-}
-
 function f_ms_rx_imm_ass_pacch(inout GprsMS ms, out uint32_t poll_fn, template RlcmacDlBlock t_imm_ass := ?)
 runs on MS_BTS_IFACE_CT return RlcmacDlBlock {
 	var RlcmacDlBlock dl_block;
@@ -318,40 +279,20 @@
 	return dl_block;
 }
 
-function f_ms_establish_ul_tbf(inout GprsMS ms, uint32_t fn := 1337)
+function f_ms_establish_ul_tbf(inout GprsMS ms)
 runs on MS_BTS_IFACE_CT {
 	var GsmRrMessage rr_imm_ass;
-	var uint8_t exp_ra;
 
-	/* Send RACH.ind */
-	log("Sending RACH.ind on fn=", fn, " with RA=", ms.ra, ", TA=", ms.ta);
-	BTS.send(ts_PCUIF_RACH_IND(bts_nr := 0, trx_nr := 0, ts_nr := 0,
-				   ra := ms.ra, is_11bit := ms.ra_is_11bit,
-				   burst_type := ms.burst_type,
-				   fn := fn, arfcn := 871,
-				   qta := ms.ta * 4));
-
-	/* 3GPP TS 44.018, table 9.1.8.1, note 2b: Request Reference shall be set to 127
-	 * when Immediate Assignment is triggered by EGPRS Packet Channel Request. Here
-	 * we assume that 11 bit RA always contains EGPRS Packet Channel Request. */
-	if (ms.ra_is_11bit == 0) {
-		exp_ra := ms.ra;
-	} else {
-		exp_ra := 127;
-	}
-
-	/* Expect Immediate (TBF) Assignment on TS0/AGCH */
-	rr_imm_ass := f_ms_rx_imm_ass_ccch(ms, PCU_IF_SAPI_AGCH,
-	                                   tr_IMM_TBF_ASS(false, exp_ra, fn));
-
+	rr_imm_ass := f_establish_tbf(ms.ra, ms.ra_is_11bit, ms.burst_type, ms.ta);
 	ms.ul_tbf := f_ultbf_new_from_rr_imm_ass(rr_imm_ass);
 }
 
-function f_ms_exp_dl_tbf_ass_ccch(inout GprsMS ms, template PCUIF_Sapi sapi := PCU_IF_SAPI_AGCH, template GsmRrMessage t_imm_ass := tr_IMM_TBF_ASS(true, ?, ?))
+function f_ms_exp_dl_tbf_ass_ccch(inout GprsMS ms, template PCUIF_Sapi sapi := PCU_IF_SAPI_AGCH,
+				  template GsmRrMessage t_imm_ass := tr_IMM_TBF_ASS(true, ?, ?))
 runs on MS_BTS_IFACE_CT {
 	var GsmRrMessage rr_imm_ass;
 
-	rr_imm_ass := f_ms_rx_imm_ass_ccch(ms, sapi, t_imm_ass);
+	rr_imm_ass := f_pcuif_rx_imm_ass(sapi, t_imm_ass);
 	ms.dl_tbf := f_dltbf_new_from_rr_imm_ass(rr_imm_ass, tr_PacketDlAssign(ms.tlli));
 }