TBF: unify EGPRS window calculation

Move actual calculation into shared function and use it to set window
size for TBF. TBT test output requires cosmetic adjuestements due to
extended debug output.

Change-Id: Ib9f4a277082da3c71007f5f3b4f2acac8b994540
Related: OS#1759
diff --git a/src/tbf_dl.cpp b/src/tbf_dl.cpp
index 45c9a8f..6b8eda7 100644
--- a/src/tbf_dl.cpp
+++ b/src/tbf_dl.cpp
@@ -1366,23 +1366,11 @@
 	return EGPRS_RLCMAC_DL_NO_RETX;
 }
 
-void gprs_rlcmac_dl_tbf::egprs_calc_window_size()
+void gprs_rlcmac_dl_tbf::set_window_size()
 {
-	struct gprs_rlcmac_bts *bts_data = bts->bts_data();
-	unsigned int num_pdch = pcu_bitcount(dl_slots());
-	unsigned int ws = bts_data->ws_base + num_pdch * bts_data->ws_pdch;
-
-	ws = (ws / 32) * 32;
-	ws = OSMO_MAX(64, ws);
-
-	if (num_pdch == 1)
-		ws = OSMO_MIN(192, ws);
-	else
-		ws = OSMO_MIN(128 * num_pdch, ws);
-
-	LOGP(DRLCMAC, LOGL_INFO, "%s: Setting EGPRS window size to %d\n",
-		name(), ws);
-
+	uint16_t ws = egprs_window_size(bts->bts_data(), dl_slots());
+	LOGP(DRLCMAC, LOGL_INFO, "%s: setting EGPRS DL window size to %u, base(%u) slots(%u) ws_pdch(%u)\n",
+	     name(), ws, bts->bts_data()->ws_base, pcu_bitcount(dl_slots()), bts->bts_data()->ws_pdch);
 	m_window.set_ws(ws);
 }