[PATCH] osmo-pcu[master]: Simplify TS alloc: replace debug printer

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
Wed Sep 20 17:01:20 UTC 2017


Hello Harald Welte, Jenkins Builder, Holger Freyther,

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

    https://gerrit.osmocom.org/3929

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

Simplify TS alloc: replace debug printer

Replace unreadable recursive debug printer with simpler functions.

Note: the new printer also correctly handle reserved TS so Control slot
overrides TS for the bits set for both Uplink and Downlink slots. This
does not change the allocation semantics of course but requires cosmetic
adjustement to TBF tests output.

Change-Id: Ia13855877b2145cb57b1646f5562b2af3b87bcfb
Related: OS#2282
---
M src/gprs_rlcmac_ts_alloc.cpp
M tests/tbf/TbfTest.err
2 files changed, 20 insertions(+), 30 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/29/3929/5

diff --git a/src/gprs_rlcmac_ts_alloc.cpp b/src/gprs_rlcmac_ts_alloc.cpp
index 76a84c7..8451bb2 100644
--- a/src/gprs_rlcmac_ts_alloc.cpp
+++ b/src/gprs_rlcmac_ts_alloc.cpp
@@ -81,18 +81,19 @@
 /* N/A */	{ MS_NA,MS_NA,	MS_NA,	MS_NA,	MS_NA,	MS_NA,	MS_NA,	MS_NA },
 };
 
-static char *set_flag_chars(char *buf, uint8_t val, char set_char, char unset_char = 0)
+static inline void masked_override_with(char *buf, uint8_t mask, char set_char)
 {
 	int i;
-
-	for (i = 0; i < 8; i += 1, val = val >> 1) {
-		if (val & 1)
+	for (i = 0; mask; i++, mask >>= 1)
+		if (mask & 1)
 			buf[i] = set_char;
-		else if (unset_char)
-			buf[i] = unset_char;
-	}
+}
 
-	return buf;
+static void ts_format(char *buf, uint8_t dl_mask, uint8_t ul_mask)
+{
+	snprintf(buf, 9, OSMO_BIT_SPEC, OSMO_BIT_PRINT_EX(dl_mask, 'D'));
+	masked_override_with(buf, ul_mask, 'U');
+	masked_override_with(buf, ul_mask & dl_mask, 'C');
 }
 
 static bool test_and_set_bit(uint32_t *bits, size_t elem)
@@ -587,11 +588,8 @@
 	*dl_slots &= pdch_slots;
 	*ul_slots &= pdch_slots;
 
-	LOGP(DRLCMAC, LOGL_DEBUG, "- Possible DL/UL slots: (TS=0)\"%s\"(TS=7)\n",
-		set_flag_chars(set_flag_chars(set_flag_chars(slot_info,
-				*dl_slots, 'D', '.'),
-				*ul_slots, 'U'),
-				*ul_slots & *dl_slots, 'C'));
+	ts_format(slot_info, *dl_slots, *ul_slots);
+	LOGP(DRLCMAC, LOGL_DEBUG, "- Possible DL/UL slots: (TS=0)\"%s\"(TS=7)\n", slot_info);
 
 	/* Check for each UL (TX) slot */
 
@@ -913,12 +911,10 @@
 	}
 
 	if (tbf->direction == GPRS_RLCMAC_DL_TBF) {
+		snprintf(slot_info, 9, OSMO_BIT_SPEC, OSMO_BIT_PRINT_EX(reserved_dl_slots, 'd'));
+		masked_override_with(slot_info, dl_slots, 'D');
 		LOGP(DRLCMAC, LOGL_DEBUG,
-			"- Selected DL slots: (TS=0)\"%s\"(TS=7)%s\n",
-			set_flag_chars(set_flag_chars(slot_info,
-					reserved_dl_slots, 'd', '.'),
-					dl_slots, 'D'),
-			single ? ", single" : "");
+		     "- Selected DL slots: (TS=0)\"%s\"(TS=7)%s\n", slot_info, single ? ", single" : "");
 
 		/* assign downlink */
 		if (dl_slots == 0) {
@@ -951,12 +947,10 @@
 		ul_slots = 1 << ts;
 		usf[ts] = free_usf;
 
+		snprintf(slot_info, 9, OSMO_BIT_SPEC, OSMO_BIT_PRINT_EX(reserved_ul_slots, 'u'));
+		masked_override_with(slot_info, ul_slots, 'U');
 		LOGP(DRLCMAC, LOGL_DEBUG,
-			"- Selected UL slots: (TS=0)\"%s\"(TS=7)%s\n",
-			set_flag_chars(set_flag_chars(slot_info,
-					reserved_ul_slots, 'u', '.'),
-					ul_slots, 'U'),
-			single ? ", single" : "");
+		     "- Selected UL slots: (TS=0)\"%s\"(TS=7)%s\n",slot_info, single ? ", single" : "");
 
 		slotcount++;
 		first_ts = ts;
@@ -1001,12 +995,8 @@
 		ms_->set_reserved_slots(trx,
 			reserved_ul_slots, reserved_dl_slots);
 
-		LOGP(DRLCMAC, LOGL_DEBUG,
-			"- Reserved DL/UL slots: (TS=0)\"%s\"(TS=7)\n",
-			set_flag_chars(set_flag_chars(set_flag_chars(slot_info,
-				dl_slots, 'D', '.'),
-				ul_slots, 'U'),
-				ul_slots & dl_slots, 'C'));
+		ts_format(slot_info, dl_slots, ul_slots);
+		LOGP(DRLCMAC, LOGL_DEBUG, "- Reserved DL/UL slots: (TS=0)\"%s\"(TS=7)\n", slot_info);
 	}
 
 	tbf_->trx = trx;
diff --git a/tests/tbf/TbfTest.err b/tests/tbf/TbfTest.err
index 602e35b..9016eb1 100644
--- a/tests/tbf/TbfTest.err
+++ b/tests/tbf/TbfTest.err
@@ -6549,7 +6549,7 @@
 - Possible DL/UL slots: (TS=0)"..CCCC.."(TS=7)
 - Selected DL slots: (TS=0)"..ddDd.."(TS=7), single
 Using single slot at TS 4 for DL
-- Reserved DL/UL slots: (TS=0)"....C..."(TS=7)
+- Reserved DL/UL slots: (TS=0)"...DC..."(TS=7)
 - Assigning DL TS 4
 PDCH(TS 4, TRX 0): Attaching TBF(TFI=0 TLLI=0x00000000 DIR=DL STATE=NULL EGPRS), 1 TBFs, USFs = 00, TFIs = 00000001.
 - Setting Control TS 4

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ia13855877b2145cb57b1646f5562b2af3b87bcfb
Gerrit-PatchSet: 5
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Owner: Max <msuraev at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Holger Freyther <holger at freyther.de>
Gerrit-Reviewer: Jenkins Builder



More information about the gerrit-log mailing list