TBF: move window parameters to UL/DL level

The UL and DL TBF use different classes implementing window
management. Hence it's better to use it explicitly instead of using the
common window management superclass inside common TBF superclass. While
at it, also remove the direct access to window class - use accessor
functions instead.

Related: OS#1759
Change-Id: I0b55aa8947db65f7206adcf53ea32b74a831d9e6
diff --git a/src/tbf.h b/src/tbf.h
index 6d7edbc..21762d3 100644
--- a/src/tbf.h
+++ b/src/tbf.h
@@ -193,8 +193,6 @@
 	GprsMs *ms() const;
 	void set_ms(GprsMs *ms);
 
-	gprs_rlc_window *window();
-
 	uint8_t tsc() const;
 
 	int rlcmac_diag();
@@ -456,7 +454,7 @@
 
 struct gprs_rlcmac_dl_tbf : public gprs_rlcmac_tbf {
 	gprs_rlcmac_dl_tbf(BTS *bts);
-
+	gprs_rlc_dl_window *window();
 	void cleanup();
 	void enable_egprs();
 	/* dispatch Unitdata.DL messages */
@@ -496,7 +494,6 @@
 	 * All states that need reset must be in this struct, so this is why
 	 * variables are in both (dl and ul) structs and not outside union.
 	 */
-	gprs_rlc_dl_window m_window;
 	int32_t m_tx_counter; /* count all transmitted blocks */
 	uint8_t m_wait_confirm; /* wait for CCCH IMM.ASS cnf */
 	bool m_dl_ack_requested;
@@ -547,11 +544,18 @@
 	enum egprs_rlcmac_dl_spb get_egprs_dl_spb(int bsn);
 
 	struct osmo_timer_list m_llc_timer;
+
+	/* Please note that all variables below will be reset when changing
+	 * from WAIT RELEASE back to FLOW state (re-use of TBF).
+	 * All states that need reset must be in this struct, so this is why
+	 * variables are in both (dl and ul) structs and not outside union.
+	 */
+	gprs_rlc_dl_window m_window;
 };
 
 struct gprs_rlcmac_ul_tbf : public gprs_rlcmac_tbf {
 	gprs_rlcmac_ul_tbf(BTS *bts);
-
+	gprs_rlc_ul_window *window();
 	struct msgb *create_ul_ack(uint32_t fn, uint8_t ts);
 	bool ctrl_ack_to_toggle();
 	bool handle_ctrl_ack();
@@ -590,7 +594,6 @@
 	 * All states that need reset must be in this struct, so this is why
 	 * variables are in both (dl and ul) structs and not outside union.
 	 */
-	gprs_rlc_ul_window m_window;
 	int32_t m_rx_counter; /* count all received blocks */
 	uint8_t m_n3103;	/* N3103 counter */
 	uint8_t m_usf[8];	/* list USFs per PDCH (timeslot) */
@@ -602,6 +605,13 @@
 
 protected:
 	void maybe_schedule_uplink_acknack(const gprs_rlc_data_info *rlc);
+
+	/* Please note that all variables below will be reset when changing
+	 * from WAIT RELEASE back to FLOW state (re-use of TBF).
+	 * All states that need reset must be in this struct, so this is why
+	 * variables are in both (dl and ul) structs and not outside union.
+	 */
+	gprs_rlc_ul_window m_window;
 };
 
 #ifdef __cplusplus
@@ -657,14 +667,4 @@
 		return NULL;
 }
 
-inline gprs_rlc_window *gprs_rlcmac_tbf::window()
-{
-	switch (direction)
-	{
-	case GPRS_RLCMAC_UL_TBF: return &as_ul_tbf(this)->m_window;
-	case GPRS_RLCMAC_DL_TBF: return &as_dl_tbf(this)->m_window;
-	}
-	return NULL;
-}
-
 #endif