pcu: Specify (M)CS to use when sending UL rlcmac data blocks

Apply padding and spare bits in the encoder according to CS/MCS format.

Change-Id: I918acac81f550077daeda3374b3de9b426ff3572
diff --git a/library/RLCMAC_Templates.ttcn b/library/RLCMAC_Templates.ttcn
index 9722f43..f016c4d 100644
--- a/library/RLCMAC_Templates.ttcn
+++ b/library/RLCMAC_Templates.ttcn
@@ -38,6 +38,13 @@
 		return (current_fn + f_rrbp_fn_delay(rrbp)) mod 2715648;
 	}
 
+	function f_rlcmac_cs_mcs_is_mcs(CodingScheme cs_mcs) return boolean {
+		if (cs_mcs >= MCS_0) {
+			return true;
+		}
+		return false;
+	}
+
 	function f_rlcmac_mcs2headertype(CodingScheme mcs) return EgprsHeaderType {
 		select (mcs) {
 		case (MCS_0) { return RLCMAC_HDR_TYPE_3; }
@@ -97,7 +104,27 @@
 		return CS_1;
 	}
 
-	/* Minimum CodingScheme required to fit RLCMAC block */
+	function f_rlcmac_cs_mcs2block_len_no_spare_bits(CodingScheme cs_mcs) return uint32_t {
+		select (cs_mcs) {
+		/* 3GPP TS 44.060 Table 10.2.1: RLC data block size, discounting padding in octet */
+		case (CS_1) { return 23; }
+		case (CS_2) { return 33; }
+		case (CS_3) { return 39; }
+		case (CS_4) { return 53; }
+		case (MCS_1) { return 27; }
+		case (MCS_2) { return 33; }
+		case (MCS_3) { return 42; }
+		case (MCS_4) { return 49; }
+		case (MCS_5) { return 61; }
+		case (MCS_6) { return 79; }
+		case (MCS_7) { return 119; }
+		case (MCS_8) { return 143; }
+		case (MCS_9) { return 155; }
+		}
+		return 0;
+	}
+
+	/* Minimum CodingScheme required to fit RLCMAC block. Spare bits not counted. */
 	function f_rlcmac_block_len_required_cs_mcs(uint32_t len, boolean is_mcs) return CodingScheme {
 		if (is_mcs) {
 			if (len <= 27) { return MCS_1; }
@@ -375,10 +402,11 @@
 	}
 
 	/* Template for uplink Data block */
-	template RlcmacUlBlock t_RLCMAC_UL_DATA(template uint5_t tfi, template uint4_t cv, template uint7_t bsn,
+	template RlcmacUlBlock t_RLCMAC_UL_DATA(template CodingScheme cs, template uint5_t tfi,
+						template uint4_t cv, template uint7_t bsn,
 						template LlcBlocks blocks := {}, template boolean stall := false) := {
 		data := {
-			cs := CS_1, /* TODO: make this available to template */
+			cs := cs,
 			mac_hdr := {
 				payload_type := MAC_PT_RLC_DATA,
 				countdown := cv,
@@ -396,10 +424,12 @@
 			blocks := blocks
 		}
 	}
-	template RlcmacUlBlock t_RLCMAC_UL_DATA_TLLI(template uint5_t tfi, template uint4_t cv, template uint7_t bsn,
-						     template LlcBlocks blocks := {}, template boolean stall := false, template GprsTlli tlli) := {
+	template RlcmacUlBlock t_RLCMAC_UL_DATA_TLLI(template CodingScheme cs, template uint5_t tfi,
+						     template uint4_t cv, template uint7_t bsn,
+						     template LlcBlocks blocks := {}, template boolean stall := false,
+						     template GprsTlli tlli) := {
 		data := {
-			cs := CS_1, /* TODO: make this available to template */
+			cs := cs,
 			mac_hdr := {
 				payload_type := MAC_PT_RLC_DATA,
 				countdown := cv,