Change in osmo-pcu[master]: tbf: Make window() available to tbf base class

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

pespin gerrit-no-reply at lists.osmocom.org
Fri Oct 23 20:42:52 UTC 2020


pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-pcu/+/20856 )


Change subject: tbf: Make window() available to tbf base class
......................................................................

tbf: Make window() available to tbf base class

Return an interface to the window base class so that the tbf base class
can access the common window methods, such as set_ws(). It will be used
in next commit to get rid of duplicated function enable_egprs in both
dl_tbf and ul_tbf subclasses.

The user of the function can then decide to access more specific
functionaltiites of the window class by static casting it to the
specific direction (which is known by the caller since it operates on a
ul_tbf or a dl_tbf).

Change-Id: Ia2e1decf91be1184668e28297c2126affb9c7ae4
---
M src/encoding.cpp
M src/gprs_rlcmac_sched.cpp
M src/pcu_vty_functions.cpp
M src/pdch.cpp
M src/tbf.h
M src/tbf_dl.cpp
M src/tbf_dl.h
M src/tbf_ul.cpp
M src/tbf_ul.h
M tests/tbf/TbfTest.cpp
M tests/types/TypesTest.cpp
11 files changed, 38 insertions(+), 27 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/56/20856/1

diff --git a/src/encoding.cpp b/src/encoding.cpp
index d581fe9..ecfca51 100644
--- a/src/encoding.cpp
+++ b/src/encoding.cpp
@@ -886,9 +886,10 @@
 	bitvec * dest, unsigned& wp,
 	struct gprs_rlcmac_ul_tbf *tbf, bool is_final)
 {
+	gprs_rlc_ul_window *window = static_cast<gprs_rlc_ul_window *>(tbf->window());
 
 	bitvec_write_field(dest, &wp, mcs_chan_code(tbf->current_cs()), 2); // CHANNEL_CODING_COMMAND
-	write_packet_ack_nack_desc_gprs(dest, wp, tbf->window(), is_final);
+	write_packet_ack_nack_desc_gprs(dest, wp, window, is_final);
 
 	bitvec_write_field(dest, &wp, 1, 1); // 1: have CONTENTION_RESOLUTION_TLLI
 	bitvec_write_field(dest, &wp, tbf->tlli(), 32); // CONTENTION_RESOLUTION_TLLI
@@ -1061,6 +1062,8 @@
 	bitvec * dest, unsigned& wp,
 	struct gprs_rlcmac_ul_tbf *tbf, bool is_final)
 {
+	gprs_rlc_ul_window *window = static_cast<gprs_rlc_ul_window *>(tbf->window());
+
 	bitvec_write_field(dest, &wp, 0, 2); // fixed 00
 	/* CHANNEL_CODING_COMMAND */
 	bitvec_write_field(dest, &wp,
@@ -1080,7 +1083,7 @@
 
 	/* -2 for last bit 0 mandatory and REL5 not supported */
 	unsigned bits_ack_nack = dest->data_len * 8 - wp - 2;
-	write_packet_ack_nack_desc_egprs(dest, wp, tbf->window(), is_final, bits_ack_nack);
+	write_packet_ack_nack_desc_egprs(dest, wp, window, is_final, bits_ack_nack);
 
 	bitvec_write_field(dest, &wp, 0, 1); // fixed 0
 	bitvec_write_field(dest, &wp, 0, 1); // 0: don't have REL 5
diff --git a/src/gprs_rlcmac_sched.cpp b/src/gprs_rlcmac_sched.cpp
index 3db3365..40b2f91 100644
--- a/src/gprs_rlcmac_sched.cpp
+++ b/src/gprs_rlcmac_sched.cpp
@@ -247,7 +247,7 @@
 static inline enum tbf_dl_prio tbf_compute_priority(const struct gprs_rlcmac_bts *bts, struct gprs_rlcmac_dl_tbf *tbf,
 						    uint8_t ts, uint32_t fn, int age)
 {
-	const gprs_rlc_dl_window *w = tbf->window();
+	const gprs_rlc_dl_window *w = static_cast<gprs_rlc_dl_window *>(tbf->window());
 	unsigned long msecs_t3190 = osmo_tdef_get(bts->T_defs_pcu, 3190, OSMO_TDEF_MS, -1);
 	unsigned long dl_tbf_idle_msec = osmo_tdef_get(bts->T_defs_pcu, -2031, OSMO_TDEF_MS, -1);
 	int age_thresh1 = msecs_to_frames(200);
diff --git a/src/pcu_vty_functions.cpp b/src/pcu_vty_functions.cpp
index 33a4637..28a1559 100644
--- a/src/pcu_vty_functions.cpp
+++ b/src/pcu_vty_functions.cpp
@@ -74,7 +74,7 @@
 	vty_out(vty, " CS=%s", mcs_name(tbf->current_cs()));
 
 	if (ul_tbf) {
-		gprs_rlc_ul_window *win = ul_tbf->window();
+		gprs_rlc_ul_window *win = static_cast<gprs_rlc_ul_window *>(ul_tbf->window());
 		vty_out(vty, " WS=%u V(Q)=%d V(R)=%d",
 			ul_tbf->window_size(), win->v_q(), win->v_r());
 		vty_out(vty, "%s", VTY_NEWLINE);
@@ -86,7 +86,7 @@
 		}
 	}
 	if (dl_tbf) {
-		gprs_rlc_dl_window *win = dl_tbf->window();
+		gprs_rlc_dl_window *win = static_cast<gprs_rlc_dl_window *>(dl_tbf->window());
 		vty_out(vty, " WS=%u V(A)=%d V(S)=%d nBSN=%d%s",
 			dl_tbf->window_size(), win->v_a(), win->v_s(), win->resend_needed(),
 			win->window_stalled() ? " STALLED" : "");
diff --git a/src/pdch.cpp b/src/pdch.cpp
index 7986373..26604bc 100644
--- a/src/pdch.cpp
+++ b/src/pdch.cpp
@@ -436,7 +436,7 @@
 
 	num_blocks = Decoding::decode_gprs_acknack_bits(
 		&ack_nack->Ack_Nack_Description, &bits,
-		&bsn_begin, &bsn_end, tbf->window());
+		&bsn_begin, &bsn_end, static_cast<gprs_rlc_dl_window *>(tbf->window()));
 
 	LOGP(DRLCMAC, LOGL_DEBUG,
 		"Got GPRS DL ACK bitmap: SSN: %d, BSN %d to %d - 1 (%d blocks), "
@@ -467,6 +467,7 @@
 {
 	int8_t tfi = 0; /* must be signed */
 	struct gprs_rlcmac_dl_tbf *tbf;
+	gprs_rlc_dl_window *window;
 	int rc;
 	int num_blocks;
 	uint8_t bits_data[RLC_EGPRS_MAX_WS/8];
@@ -497,6 +498,7 @@
 	LOGPTBF(tbf, LOGL_DEBUG,
 		"RX: [PCU <- BTS] EGPRS Packet Downlink Ack/Nack\n");
 
+	window = static_cast<gprs_rlc_dl_window *>(tbf->window());
 	LOGP(DRLCMAC, LOGL_DEBUG, "EGPRS ACK/NACK: "
 		"ut: %d, final: %d, bow: %d, eow: %d, ssn: %d, have_crbb: %d, "
 		"urbb_len:%d, %p, %p, %d, %d, win: %d-%d, urbb: %s\n",
@@ -511,8 +513,8 @@
 		(void *)&ack_nack->EGPRS_AckNack.Desc,
 		(int)offsetof(EGPRS_AckNack_t, Desc),
 		(int)offsetof(EGPRS_AckNack_w_len_t, Desc),
-		tbf->window()->v_a(),
-		tbf->window()->v_s(),
+		window->v_a(),
+		window->v_s(),
 		osmo_hexdump((const uint8_t *)&ack_nack->EGPRS_AckNack.Desc.URBB,
 			sizeof(ack_nack->EGPRS_AckNack.Desc.URBB)));
 
@@ -522,7 +524,7 @@
 
 	num_blocks = Decoding::decode_egprs_acknack_bits(
 		&ack_nack->EGPRS_AckNack.Desc, &bits,
-		&bsn_begin, &bsn_end, tbf->window());
+		&bsn_begin, &bsn_end, window);
 
 	LOGP(DRLCMAC, LOGL_DEBUG,
 		"Got EGPRS DL ACK bitmap: SSN: %d, BSN %d to %d - 1 (%d blocks), "
diff --git a/src/tbf.h b/src/tbf.h
index 936ff65..bf51a8d 100644
--- a/src/tbf.h
+++ b/src/tbf.h
@@ -185,6 +185,8 @@
 	static void free_all(struct gprs_rlcmac_trx *trx);
 	static void free_all(struct gprs_rlcmac_pdch *pdch);
 
+	virtual gprs_rlc_window *window() = 0;
+
 	bool state_is(enum gprs_rlcmac_tbf_state rhs) const;
 	bool state_is_not(enum gprs_rlcmac_tbf_state rhs) const;
 	bool dl_ass_state_is(enum gprs_rlcmac_tbf_dl_ass_state rhs) const;
diff --git a/src/tbf_dl.cpp b/src/tbf_dl.cpp
index fc03c0b..cbefb1b 100644
--- a/src/tbf_dl.cpp
+++ b/src/tbf_dl.cpp
@@ -1000,7 +1000,7 @@
 	return lost * 100 / (lost + received);
 }
 
-gprs_rlc_dl_window *gprs_rlcmac_dl_tbf::window()
+gprs_rlc_window *gprs_rlcmac_dl_tbf::window()
 {
 	return &m_window;
 }
diff --git a/src/tbf_dl.h b/src/tbf_dl.h
index bac524a..51e170a 100644
--- a/src/tbf_dl.h
+++ b/src/tbf_dl.h
@@ -40,7 +40,7 @@
 
 struct gprs_rlcmac_dl_tbf : public gprs_rlcmac_tbf {
 	gprs_rlcmac_dl_tbf(BTS *bts);
-	gprs_rlc_dl_window *window();
+	gprs_rlc_window *window();
 	void cleanup();
 	void enable_egprs();
 	/* dispatch Unitdata.DL messages */
diff --git a/src/tbf_ul.cpp b/src/tbf_ul.cpp
index 39e4e95..c347885 100644
--- a/src/tbf_ul.cpp
+++ b/src/tbf_ul.cpp
@@ -615,7 +615,7 @@
 	m_window.set_ws(ws);
 }
 
-gprs_rlc_ul_window *gprs_rlcmac_ul_tbf::window()
+gprs_rlc_window *gprs_rlcmac_ul_tbf::window()
 {
 	return &m_window;
 }
diff --git a/src/tbf_ul.h b/src/tbf_ul.h
index c6df0cd..cbaffa5 100644
--- a/src/tbf_ul.h
+++ b/src/tbf_ul.h
@@ -51,7 +51,7 @@
 
 struct gprs_rlcmac_ul_tbf : public gprs_rlcmac_tbf {
 	gprs_rlcmac_ul_tbf(BTS *bts);
-	gprs_rlc_ul_window *window();
+	gprs_rlc_window *window();
 	struct msgb *create_ul_ack(uint32_t fn, uint8_t ts);
 	bool ctrl_ack_to_toggle();
 	bool handle_ctrl_ack();
diff --git a/tests/tbf/TbfTest.cpp b/tests/tbf/TbfTest.cpp
index 15a79d0..2b5bda5 100644
--- a/tests/tbf/TbfTest.cpp
+++ b/tests/tbf/TbfTest.cpp
@@ -322,10 +322,11 @@
 }
 
 /* Receive an ACK */
-#define RCV_ACK(fin, tbf, rbb) do {					\
-		tbf->rcvd_dl_ack(fin, tbf->window()->v_s(), rbb);	\
+#define RCV_ACK(fin, tbf, rbb) do { \
+		gprs_rlc_dl_window *w = static_cast<gprs_rlc_dl_window *>(tbf->window());	\
+		tbf->rcvd_dl_ack(fin, w->v_s(), rbb);	\
 		if (!fin)						\
-			OSMO_ASSERT(tbf->window()->window_empty());	\
+			OSMO_ASSERT(w->window_empty());	\
 	} while(0)
 
 static void test_tbf_delayed_release()
@@ -1748,7 +1749,7 @@
 	print_ta_tlli(ul_tbf, true);
 	send_dl_data(&the_bts, tlli, imsi, test_data, sizeof(test_data));
 
-	ul_tbf->window()->reset_state();
+	static_cast<gprs_rlc_ul_window *>(ul_tbf->window())->reset_state();
 	/* Function to generate URBB with length */
 	ul_tbf = establish_ul_tbf_two_phase_puan_URBB_with_length(&the_bts, ts_no, tlli, &fn,
 		qta, ms_class, egprs_ms_class, ul_tbf);
@@ -1756,7 +1757,7 @@
 	print_ta_tlli(ul_tbf, true);
 	send_dl_data(&the_bts, tlli, imsi, test_data, sizeof(test_data));
 
-	ul_tbf->window()->reset_state();
+	static_cast<gprs_rlc_ul_window *>(ul_tbf->window())->reset_state();
 	/* Function to generate CRBB */
 	bts->ws_base = 128;
 	bts->ws_pdch = 64;
@@ -2529,7 +2530,7 @@
 
 	dl_tbf = create_dl_tbf(&the_bts, ms_class, egprs_ms_class, &trx_no);
 	dl_tbf->update_ms(tlli, GPRS_RLCMAC_DL_TBF);
-	prlcdlwindow = dl_tbf->window();
+	prlcdlwindow = static_cast<gprs_rlc_dl_window *>(dl_tbf->window());
 	prlcmvb = &prlcdlwindow->m_v_b;
 	prlcdlwindow->m_v_s = 1288;
 	prlcdlwindow->m_v_a = 1176;
@@ -2562,7 +2563,7 @@
 
 	Decoding::decode_egprs_acknack_bits(
 		&ack_nack->EGPRS_AckNack.Desc, &bits,
-		&bsn_begin, &bsn_end, dl_tbf->window());
+		&bsn_begin, &bsn_end, prlcdlwindow);
 
 	dl_tbf->rcvd_dl_ack(
 		ack_nack->EGPRS_AckNack.Desc.FINAL_ACK_INDICATION,
@@ -2747,17 +2748,20 @@
 }
 
 #define NACK(tbf, x) do {					\
-		tbf->window()->m_v_b.mark_nacked(x);		\
-		OSMO_ASSERT(tbf->window()->m_v_b.is_nacked(x));	\
+		gprs_rlc_dl_window *w = static_cast<gprs_rlc_dl_window *>(tbf->window());	\
+		w->m_v_b.mark_nacked(x);		\
+		OSMO_ASSERT(w->m_v_b.is_nacked(x));	\
 	} while(0)
 
 #define CHECK_UNACKED(tbf, cs, bsn) do {				             \
-		OSMO_ASSERT(tbf->window()->m_v_b.is_unacked(bsn));	             \
+		gprs_rlc_dl_window *w = static_cast<gprs_rlc_dl_window *>(tbf->window());	\
+		OSMO_ASSERT(w->m_v_b.is_unacked(bsn));	             \
 		OSMO_ASSERT(mcs_chan_code(tbf->m_rlc.block(bsn)->cs_current_trans) == cs - 1); \
 	} while(0)
 
 #define CHECK_NACKED(tbf, cs, bsn) do {					             \
-		OSMO_ASSERT(tbf->window()->m_v_b.is_nacked(bsn));	             \
+		gprs_rlc_dl_window *w = static_cast<gprs_rlc_dl_window *>(tbf->window());	\
+		OSMO_ASSERT(w->m_v_b.is_nacked(bsn));	             \
 		OSMO_ASSERT(mcs_chan_code(tbf->m_rlc.block(bsn)->cs_current_trans) == cs - 1); \
 	} while(0)
 
diff --git a/tests/types/TypesTest.cpp b/tests/types/TypesTest.cpp
index 353d821..1c846e1 100644
--- a/tests/types/TypesTest.cpp
+++ b/tests/types/TypesTest.cpp
@@ -559,7 +559,7 @@
 
 	*ssn = bitvec_get_uint(dest, 11);
 	if (bow) {
-		OSMO_ASSERT(*ssn == tbf->window()->v_q() + 1);
+		OSMO_ASSERT(*ssn == static_cast<gprs_rlc_ul_window *>(tbf->window())->v_q() + 1);
 	}
 
 	crbb_test->has_crbb = bitvec_get_uint(dest, 1);
@@ -596,7 +596,7 @@
 
 static void check_egprs_bitmap(struct gprs_rlcmac_ul_tbf *tbf, uint16_t ssn, struct crbb_test *crbb_test, bitvec *urbb, unsigned int *rbb_size)
 {
-	gprs_rlc_ul_window *win = tbf->window();
+	gprs_rlc_ul_window *win = static_cast<gprs_rlc_ul_window *>(tbf->window());
 	uint8_t rbb_should[RLC_EGPRS_MAX_WS] = {0};
 	bitvec rbb_should_bv;
 	rbb_should_bv.data = rbb_should;
@@ -680,7 +680,7 @@
 	bitvec *rbb = NULL;
 	unsigned int rbb_size;
 	uint16_t ssn = 0;
-	gprs_rlc_ul_window *win = tbf->window();
+	gprs_rlc_ul_window *win = static_cast<gprs_rlc_ul_window *>(tbf->window());
 
 	fprintf(stderr, "************** Test with empty window\n");
 	win->reset_state();

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-pcu/+/20856
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Change-Id: Ia2e1decf91be1184668e28297c2126affb9c7ae4
Gerrit-Change-Number: 20856
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20201023/c8d33e37/attachment.htm>


More information about the gerrit-log mailing list