gprs_rlcmac_sched: fix condition for generating dummy blocks on idle

When a PDCH is idle, then the gaps are filled with dummy blocks. OsmoPCU
supports generating the dummy blocks locally, so that a continous stream of
PDCH blocks is sent to L1. However, some BTS models (the OsmoTRX based models
in particular) are able to generate the idle blocks locally. In this case the
PCU should leave the genration of the dummy blocks to the BTS in order to
save processing time and load on the PCUIF interface.

In gprs_rlcmac_sched we already have a flag to skip idle frames in case we do
not use the so called "direct phy access". A similar mechanism also exists in
pcu_l1_if.cpp in function pcu_rx_rts_req_ptcch().

Unfortunately this check is not implemented correctly. The flag gets set when
the ENABLE_DIRECT_PHY define constant is set. However, this does not say
anything about whether the BTS model supports the generation of idle blocks or
not. The define constant is intended to be used to disable direct phy related
code in on platforms where no direct phy code is used or cannot be used. We
must instead check the BTS model (bts->bts_model) in order to decide whether
this particular BTS type requires the generation of dummy blocks or not.

Related: OS#6191
Change-Id: I7a08d8cc670fa14f7206ffffdbc22351f3668a17
(cherry picked from commit 469584f136061261bb7b05006d674aca42e3b150)
diff --git a/src/bts.h b/src/bts.h
index 1d88cb5..86c161b 100644
--- a/src/bts.h
+++ b/src/bts.h
@@ -278,6 +278,11 @@
 
 	/* BTS hardware model, see pcuif_proto.h */
 	uint8_t bts_model;
+
+	/* When the PDCH is idle, the timeslot is expected to transmit dummy blocks. Some BTS models will generate
+	 * those dummy blocks automatically when no data is transmitted. In contrast, other BTS models may require a
+	 * continuous stream of PDCH blocks that already has the gaps filled with dummy blocks. */
+	bool gen_idle_blocks;
 };
 
 struct paging_req_cs {
diff --git a/src/gprs_rlcmac_sched.cpp b/src/gprs_rlcmac_sched.cpp
index 314fd58..12b9e50 100644
--- a/src/gprs_rlcmac_sched.cpp
+++ b/src/gprs_rlcmac_sched.cpp
@@ -487,11 +487,10 @@
 		const unsigned num_tbfs = pdch->num_tbfs(GPRS_RLCMAC_DL_TBF)
 					+ pdch->num_tbfs(GPRS_RLCMAC_UL_TBF);
 		bool skip_idle = (num_tbfs == 0);
-#ifdef ENABLE_DIRECT_PHY
-		/* In DIRECT_PHY mode we want to always submit something to L1 in
-		 * TRX0, since BTS is not preparing dummy bursts on idle TS for us */
-		skip_idle = skip_idle && trx != 0;
-#endif
+
+		if (bts->gen_idle_blocks)
+			skip_idle = skip_idle && trx != 0;
+
 		if (!skip_idle && (msg = sched_dummy())) {
 			/* increase counter */
 			gsmtap_cat = PCU_GSMTAP_C_DL_DUMMY;
diff --git a/src/pcu_l1_if.cpp b/src/pcu_l1_if.cpp
index a71f321..be8030a 100644
--- a/src/pcu_l1_if.cpp
+++ b/src/pcu_l1_if.cpp
@@ -624,11 +624,10 @@
 	const unsigned num_tbfs = pdch->num_tbfs(GPRS_RLCMAC_DL_TBF)
 				+ pdch->num_tbfs(GPRS_RLCMAC_UL_TBF);
 	bool skip_idle = (num_tbfs == 0);
-#ifdef ENABLE_DIRECT_PHY
-		/* In DIRECT_PHY mode we want to always submit something to L1 in
-		 * TRX0, since BTS is not preparing dummy bursts on idle TS for us: */
+
+	if (bts->gen_idle_blocks)
 		skip_idle = skip_idle && trx != 0;
-#endif
+
 	if (skip_idle) {
 		pcu_l1if_tx_ptcch(bts, trx, ts, bts->trx[trx].arfcn, fn, block_nr,
 				  NULL, 0);
@@ -808,6 +807,27 @@
 	{ 0, NULL }
 };
 
+static bool decide_gen_idle_blocks(struct gprs_rlcmac_bts *bts)
+{
+	switch (bts->bts_model) {
+	case PCU_IF_BTS_MODEL_UNSPEC:
+	case PCU_IF_BTS_MODEL_LC15:
+	case PCU_IF_BTS_MODEL_OC2G:
+	case PCU_IF_BTS_MODEL_OCTPHY:
+	case PCU_IF_BTS_MODEL_SYSMO:
+	case PCU_IF_BTS_MODEL_RBS:
+		/* The BTS models above do not generate dummy blocks by themselves, so OsmoPCU must fill the idle gaps in the
+		 * stream of generated PDCH blocks with dummy blocks. */
+		return true;
+	case PCU_IF_BTS_MODEL_TRX:
+		/* The BTS models above generate dummy blocks by themselves, so OsmoBTS will only generate PDCH bloks that
+		 * actually contain data. On idle, no blocks are generated. */
+	        return false;
+	default:
+		return false;
+	}
+}
+
 static int pcu_rx_info_ind(struct gprs_rlcmac_bts *bts, const struct gsm_pcu_if_info_ind *info_ind)
 {
 	struct gprs_bssgp_pcu *pcu;
@@ -1026,6 +1046,7 @@
 
 	LOGP(DL1IF, LOGL_INFO, "BTS model: %s\n", get_value_string(gsm_pcuif_bts_model_names, info_ind->bts_model));
 	bts->bts_model = info_ind->bts_model;
+	bts->gen_idle_blocks = decide_gen_idle_blocks(bts);
 
 	bts->active = true;
 	return rc;