[PATCH] osmo-pcu[master]: window: move encoding into functions

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/.

Max gerrit-no-reply at lists.osmocom.org
Thu Dec 14 14:04:26 UTC 2017


Hello Jenkins Builder,

I'd like you to reexamine a change.  Please visit

    https://gerrit.osmocom.org/5336

to look at the new patch set (#2).

window: move encoding into functions

* move window size encoding and writing into separate functions
* introduce necessary TBF wrappers to avoid direct m_window access

This is part of preparation work to move to separate UL/DL windows.

Related: OS#1759
Change-Id: I60184d5049bc7d7b119df5a9eb82d1c4b788c840
---
M src/encoding.cpp
M src/encoding.h
M src/pcu_vty_functions.cpp
M src/tbf.h
M tests/tbf/TbfTest.cpp
5 files changed, 43 insertions(+), 27 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/36/5336/2

diff --git a/src/encoding.cpp b/src/encoding.cpp
index 7bf2859..30de427 100644
--- a/src/encoding.cpp
+++ b/src/encoding.cpp
@@ -60,6 +60,21 @@
 	}
 }
 
+/* 3GPP TS 44.060 Table 12.5.2.1 */
+static inline uint16_t enc_ws(uint16_t ws)
+{
+	return (ws - 64) / 32;
+}
+
+static inline void write_ws(bitvec *dest, unsigned int *write_index, uint16_t ws)
+{
+	dest->cur_bit = *write_index;
+
+	bitvec_set_u64(dest, enc_ws(ws), 5, false);
+
+	*write_index += 5;
+}
+
 /* 3GPP TS 44.060 § 12.12:
    { 0 | 1 < TIMING_ADVANCE_VALUE : bit (6) > }
    { 0 | 1 < TIMING_ADVANCE_INDEX : bit (4) >
@@ -114,9 +129,8 @@
 	//		bitvec_write_field(dest, &wp,,0xb,4);
 	if (tbf->is_egprs_enabled()) {
 		/* see GMS 44.018, 10.5.2.16 */
-		unsigned int ws_enc = (tbf->m_window.ws() - 64) / 32;
 		bitvec_write_field(dest, &wp, 1, 1);  // "H"
-		bitvec_write_field(dest, &wp, ws_enc, 5); // EGPRS Window Size
+		write_ws(dest, &wp, tbf->window_size()); // EGPRS Window Size
 		bitvec_write_field(dest, &wp, 0x0, 2);    // LINK_QUALITY_MEASUREMENT_MODE
 		bitvec_write_field(dest, &wp, 0, 1);      // BEP_PERIOD2 not present
 	}
@@ -178,7 +192,6 @@
 	uint8_t alpha, uint8_t gamma, int8_t ta_idx,
 	enum ph_burst_type burst_type, uint16_t ra)
 {
-	unsigned int ws_enc = 0;
 	uint8_t extended_ra = 0;
 
 	extended_ra = (ra & 0x1F);
@@ -208,9 +221,6 @@
 		bitvec_write_field(dest, &wp, 0, 1);
 
 	} else {
-
-		ws_enc = (tbf->m_window.ws() - 64) / 32;
-
 		bitvec_write_field(dest, &wp, 1, 1);     /* single block alloc */
 		bitvec_write_field(dest, &wp, tbf->tfi(), 5);/* TFI assignment */
 		bitvec_write_field(dest, &wp, 0, 1);     /* polling bit */
@@ -224,7 +234,7 @@
 		bitvec_write_field(dest, &wp, tbf->tlli(), 1);
 		bitvec_write_field(dest, &wp, 0, 1);   /* BEP period present */
 		bitvec_write_field(dest, &wp, 0, 1);   /* resegmentation */
-		bitvec_write_field(dest, &wp, ws_enc, 5);/* egprs window_size */
+		write_ws(dest, &wp, tbf->window_size());/* egprs window_size */
 
 		if (alpha) {
 			bitvec_write_field(dest, &wp, 0x1, 1);   /* ALPHA =yes */
@@ -450,7 +460,6 @@
 		bitvec_write_field(dest, &wp,0x1,1); // TLLI_BLOCK_CHANNEL_CODING
 		write_ta_ie(dest, wp,tbf->ta(), ta_idx, ta_ts);
 	} else { /* EPGRS */
-		unsigned int ws_enc = (tbf->m_window.ws() - 64) / 32;
 		bitvec_write_field(dest, &wp,0x1,1); // Message escape
 		bitvec_write_field(dest, &wp,0x0,2); // EGPRS message contents
 		bitvec_write_field(dest, &wp,0x0,1); // No CONTENTION_RESOLUTION_TLLI
@@ -458,7 +467,7 @@
 		bitvec_write_field(dest, &wp,tbf->current_cs().to_num()-1, 4); // EGPRS Modulation and Coding IE
 		/* 0: no RESEGMENT, 1: Segmentation*/
 		bitvec_write_field(dest, &wp, 0x1, 1);
-		bitvec_write_field(dest, &wp,ws_enc,5); // EGPRS Window Size
+		write_ws(dest, &wp, tbf->window_size()); // EGPRS Window Size
 		bitvec_write_field(dest, &wp,0x0,1); // No Access Technologies Request
 		bitvec_write_field(dest, &wp,0x0,1); // No ARAC RETRANSMISSION REQUEST
 		bitvec_write_field(dest, &wp,0x1,1); // TLLI_BLOCK_CHANNEL_CODING
@@ -509,7 +518,7 @@
 /* generate downlink assignment */
 void Encoding::write_packet_downlink_assignment(RlcMacDownlink_t * block,
 	bool old_tfi_is_valid, uint8_t old_tfi, uint8_t old_downlink,
-	struct gprs_rlcmac_tbf *tbf, uint8_t poll, uint8_t rrbp,
+	struct gprs_rlcmac_dl_tbf *tbf, uint8_t poll, uint8_t rrbp,
 	uint8_t alpha, uint8_t gamma, int8_t ta_idx,
 	uint8_t ta_ts, bool use_egprs)
 {
@@ -518,7 +527,6 @@
 	PDA_AdditionsR99_t *pda_r99;
 
 	uint8_t tn;
-	unsigned int ws_enc;
 
 	block->PAYLOAD_TYPE = 0x1;  // RLC/MAC control block that does not include the optional octets of the RLC/MAC control header
 	block->RRBP         = rrbp;  // 0: N+13
@@ -591,12 +599,10 @@
 		return;
 	}
 
-	ws_enc = (tbf->window()->ws() - 64) / 32;
-
 	block->u.Packet_Downlink_Assignment.Exist_AdditionsR99        = 0x1; // AdditionsR99 = on
 	pda_r99 = &block->u.Packet_Downlink_Assignment.AdditionsR99;
 	pda_r99->Exist_EGPRS_Params = 1;
-	pda_r99->EGPRS_WindowSize = ws_enc; /* see TS 44.060, table 12.5.2.1 */
+	pda_r99->EGPRS_WindowSize = enc_ws(tbf->window_size()); /* see TS 44.060, table 12.5.2.1 */
 	pda_r99->LINK_QUALITY_MEASUREMENT_MODE = 0x0; /* no meas, see TS 44.060, table 11.2.7.2 */
 	pda_r99->Exist_BEP_PERIOD2 = 0; /* No extra EGPRS BEP PERIOD */
 	pda_r99->Exist_Packet_Extended_Timing_Advance = 0;
diff --git a/src/encoding.h b/src/encoding.h
index 6164b89..54cb057 100644
--- a/src/encoding.h
+++ b/src/encoding.h
@@ -68,7 +68,7 @@
 
 	static void write_packet_downlink_assignment(RlcMacDownlink_t * block,
 			bool old_tfi_is_valid, uint8_t old_tfi, uint8_t old_downlink,
-			struct gprs_rlcmac_tbf *tbf, uint8_t poll, uint8_t rrbp,
+			struct gprs_rlcmac_dl_tbf *tbf, uint8_t poll, uint8_t rrbp,
 			uint8_t alpha, uint8_t gamma,
 			int8_t ta_idx, uint8_t ta_ts, bool use_egprs);
 
diff --git a/src/pcu_vty_functions.cpp b/src/pcu_vty_functions.cpp
index 6362281..129959b 100644
--- a/src/pcu_vty_functions.cpp
+++ b/src/pcu_vty_functions.cpp
@@ -70,7 +70,7 @@
 	if (ul_tbf) {
 		gprs_rlc_ul_window *win = ul_tbf->window();
 		vty_out(vty, " WS=%d V(Q)=%d V(R)=%d",
-			ul_tbf->ws(), win->v_q(), win->v_r());
+			ul_tbf->window_size(), win->v_q(), win->v_r());
 		vty_out(vty, "%s", VTY_NEWLINE);
 		vty_out(vty, " TBF Statistics:%s", VTY_NEWLINE);
 		if(GprsCodingScheme::GPRS == tbf->ms()->mode()) {
@@ -82,7 +82,7 @@
 	if (dl_tbf) {
 		gprs_rlc_dl_window *win = dl_tbf->window();
 		vty_out(vty, " WS=%d V(A)=%d V(S)=%d nBSN=%d%s",
-			dl_tbf->ws(), win->v_a(), win->v_s(), win->resend_needed(),
+			dl_tbf->window_size(), win->v_a(), win->v_s(), win->resend_needed(),
 			win->window_stalled() ? " STALLED" : "");
 		vty_out(vty, "%s", VTY_NEWLINE);
 		vty_out_rate_ctr_group(vty, " ", tbf->m_ctrs);
diff --git a/src/tbf.h b/src/tbf.h
index 1499369..40d1380 100644
--- a/src/tbf.h
+++ b/src/tbf.h
@@ -448,7 +448,7 @@
 	bool keep_open(unsigned fn) const;
 	int release();
 	int abort();
-
+	uint16_t window_size() const;
 	void egprs_calc_window_size();
 	void update_coding_scheme_counter_dl(const GprsCodingScheme cs);
 
@@ -552,7 +552,7 @@
 		uint8_t *data, const uint8_t block_idx);
 
 	void egprs_calc_ulwindow_size();
-
+	uint16_t window_size() const;
 	void update_coding_scheme_counter_ul(const GprsCodingScheme cs);
 
 	/* Please note that all variables here will be reset when changing
@@ -595,6 +595,16 @@
 		((int)GPRS_RLCMAC_UL_TBF - (int)dir + (int)GPRS_RLCMAC_DL_TBF);
 }
 
+inline uint16_t gprs_rlcmac_ul_tbf::window_size() const
+{
+	return m_window.ws();
+}
+
+inline uint16_t gprs_rlcmac_dl_tbf::window_size() const
+{
+	return m_window.ws();
+}
+
 inline void gprs_rlcmac_ul_tbf::enable_egprs()
 {
 	m_window.set_sns(RLC_EGPRS_SNS);
diff --git a/tests/tbf/TbfTest.cpp b/tests/tbf/TbfTest.cpp
index 60a1ac3..b950af0 100644
--- a/tests/tbf/TbfTest.cpp
+++ b/tests/tbf/TbfTest.cpp
@@ -2215,9 +2215,9 @@
 	fprintf(stderr, "DL TBF slots: 0x%02x, N: %d, WS: %d\n",
 		dl_tbf->dl_slots(),
 		pcu_bitcount(dl_tbf->dl_slots()),
-		dl_tbf->window()->ws());
+		dl_tbf->window_size());
 	OSMO_ASSERT(pcu_bitcount(dl_tbf->dl_slots()) == 4);
-	OSMO_ASSERT(dl_tbf->window()->ws() == 64);
+	OSMO_ASSERT(dl_tbf->window_size() == 64);
 	tbf_free(dl_tbf);
 
 	/* EGPRS-only */
@@ -2230,9 +2230,9 @@
 	fprintf(stderr, "DL TBF slots: 0x%02x, N: %d, WS: %d\n",
 		dl_tbf->dl_slots(),
 		pcu_bitcount(dl_tbf->dl_slots()),
-		dl_tbf->window()->ws());
+		dl_tbf->window_size());
 	OSMO_ASSERT(pcu_bitcount(dl_tbf->dl_slots()) == 4);
-	OSMO_ASSERT(dl_tbf->window()->ws() == 128 + 4 * 64);
+	OSMO_ASSERT(dl_tbf->window_size() == 128 + 4 * 64);
 	tbf_free(dl_tbf);
 
 	printf("=== end %s ===\n", __func__);
@@ -2274,9 +2274,9 @@
 	fprintf(stderr, "DL TBF slots: 0x%02x, N: %d, WS: %d\n",
 		dl_tbf->dl_slots(),
 		pcu_bitcount(dl_tbf->dl_slots()),
-		dl_tbf->window()->ws());
+		dl_tbf->window_size());
 	OSMO_ASSERT(pcu_bitcount(dl_tbf->dl_slots()) == 1);
-	OSMO_ASSERT(dl_tbf->window()->ws() == 128 + 1 * 64);
+	OSMO_ASSERT(dl_tbf->window_size() == 128 + 1 * 64);
 
 	dl_tbf->update();
 
@@ -2285,9 +2285,9 @@
 	fprintf(stderr, "DL TBF slots: 0x%02x, N: %d, WS: %d\n",
 		dl_tbf->dl_slots(),
 		pcu_bitcount(dl_tbf->dl_slots()),
-		dl_tbf->window()->ws());
+		dl_tbf->window_size());
 	OSMO_ASSERT(pcu_bitcount(dl_tbf->dl_slots()) == 4);
-	OSMO_ASSERT(dl_tbf->window()->ws() == 128 + 4 * 64);
+	OSMO_ASSERT(dl_tbf->window_size() == 128 + 4 * 64);
 
 	tbf_free(dl_tbf);
 

-- 
To view, visit https://gerrit.osmocom.org/5336
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I60184d5049bc7d7b119df5a9eb82d1c4b788c840
Gerrit-PatchSet: 2
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Owner: Max <msuraev at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder



More information about the gerrit-log mailing list