ms: Add support for slot reservation

In contrast to the slots currently used by existing TBFs, the
reserved slots refer to the time slots that can be used for newly
allocated TBFs without causing conflicts (given that the first common
TS does not change). They correspond to the potential use of the
PDCHs and can be used to achieve a more uniform slot allocation.

This commit adds bit set based methods to GprsMs and gprs_rlcmac_trx
and a counter to gprs_rlcmac_pdch. The current TRX will also be
stored in the MS object.

Sponsored-by: On-Waves ehf
diff --git a/src/bts.cpp b/src/bts.cpp
index 6da8cdd..d14420c 100644
--- a/src/bts.cpp
+++ b/src/bts.cpp
@@ -1147,3 +1147,32 @@
 	LOGP(DRLCMAC, LOGL_INFO, "PDCH(TS %d, TRX %d): Detaching %s, %d TBFs.\n",
 		ts_no, trx_no(), tbf->name(), m_num_tbfs[tbf->direction]);
 }
+
+void gprs_rlcmac_pdch::reserve(enum gprs_rlcmac_tbf_direction dir)
+{
+	m_num_reserved[dir] += 1;
+}
+
+void gprs_rlcmac_pdch::unreserve(enum gprs_rlcmac_tbf_direction dir)
+{
+	OSMO_ASSERT(m_num_reserved[dir] > 0);
+	m_num_reserved[dir] -= 1;
+}
+
+void gprs_rlcmac_trx::reserve_slots(enum gprs_rlcmac_tbf_direction dir,
+	uint8_t slots)
+{
+	unsigned i;
+	for (i = 0; i < ARRAY_SIZE(pdch); i += 1)
+		if (slots & (1 << i))
+			pdch[i].reserve(dir);
+}
+
+void gprs_rlcmac_trx::unreserve_slots(enum gprs_rlcmac_tbf_direction dir,
+	uint8_t slots)
+{
+	unsigned i;
+	for (i = 0; i < ARRAY_SIZE(pdch); i += 1)
+		if (slots & (1 << i))
+			pdch[i].unreserve(dir);
+}