[PATCH] openbsc[master]: dyn TS: fix: ts_subslots() for TCH/F_PDCH in PDCH mode

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

Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Sun Sep 25 15:40:34 UTC 2016


Review at  https://gerrit.osmocom.org/939

dyn TS: fix: ts_subslots() for TCH/F_PDCH in PDCH mode

In gsm_data_shared.c, add ts_pchan() to determine actual pchan type for dynamic
and non-dynamic TS.

Use in ts_subslots() to fix the value returned for TCH/F_PDCH in PDCH mode.
Adjust the assertion in channel_test.c accordingly.

Drop GSM_PCHAN_TCH_F_PDCH, which is now handled in ts_pchan().
Explicitly add GSM_PCHAN_PDCH as zero in subslots_per_pchan[] (cosmetic).
Adjust the comment in subslots_per_pchan[].

The fix for the number of subslots affects only one caller: bts_chan_load() in
chan_alloc.c. Before this, it would always include a TCH/F_PDCH in the
load_counter->total, now it is skipped when in PDCH mode. Whether this is the
way bts_chan_load() should handle dynamic TS is a separate discussion, so far
I'm only making sure that the two dyn TS kinds act in the same way:
TCH/F_TCH/H_PDCH is only counted when in TCH mode, and TCH/F_PDCH should match.

Change-Id: Icd6668667ad2be7ad20866ffd185bf3b8711ccd6
---
M openbsc/src/libcommon/gsm_data_shared.c
M openbsc/tests/channel/channel_test.c
2 files changed, 21 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/39/939/1

diff --git a/openbsc/src/libcommon/gsm_data_shared.c b/openbsc/src/libcommon/gsm_data_shared.c
index c8c9e04..371e479 100644
--- a/openbsc/src/libcommon/gsm_data_shared.c
+++ b/openbsc/src/libcommon/gsm_data_shared.c
@@ -712,24 +712,38 @@
 static const uint8_t subslots_per_pchan[] = {
 	[GSM_PCHAN_NONE] = 0,
 	[GSM_PCHAN_CCCH] = 0,
+	[GSM_PCHAN_PDCH] = 0,
 	[GSM_PCHAN_CCCH_SDCCH4] = 4,
 	[GSM_PCHAN_TCH_F] = 1,
 	[GSM_PCHAN_TCH_H] = 2,
 	[GSM_PCHAN_SDCCH8_SACCH8C] = 8,
-	[GSM_PCHAN_TCH_F_PDCH] = 1,
 	[GSM_PCHAN_CCCH_SDCCH4_CBCH] = 4,
 	[GSM_PCHAN_SDCCH8_SACCH8C_CBCH] = 8,
 	/*
-	 * GSM_PCHAN_TCH_F_TCH_H_PDCH should not be part of this, those TS are
-	 * handled according to their ts->dyn state.
+	 * GSM_PCHAN_TCH_F_PDCH and GSM_PCHAN_TCH_F_TCH_H_PDCH should not be
+	 * part of this, those TS are handled according to their dynamic state.
 	 */
 };
+
+/*! Return the actual pchan type, also heeding dynamic TS. */
+static enum gsm_phys_chan_config ts_pchan(struct gsm_bts_trx_ts *ts)
+{
+	switch (ts->pchan) {
+	case GSM_PCHAN_TCH_F_TCH_H_PDCH:
+		return ts->dyn.pchan_is;
+	case GSM_PCHAN_TCH_F_PDCH:
+		if (ts->flags & TS_F_PDCH_ACTIVE)
+			return GSM_PCHAN_PDCH;
+		else
+			return GSM_PCHAN_TCH_F;
+	default:
+		return ts->pchan;
+	}
+}
 
 /*! According to ts->pchan and possibly ts->dyn_pchan, return the number of
  * logical channels available in the timeslot. */
 uint8_t ts_subslots(struct gsm_bts_trx_ts *ts)
 {
-	if (ts->pchan == GSM_PCHAN_TCH_F_TCH_H_PDCH)
-		return subslots_per_pchan[ts->dyn.pchan_is];
-	return subslots_per_pchan[ts->pchan];
+	return subslots_per_pchan[ts_pchan(ts)];
 }
diff --git a/openbsc/tests/channel/channel_test.c b/openbsc/tests/channel/channel_test.c
index e6d6925..009aa56 100644
--- a/openbsc/tests/channel/channel_test.c
+++ b/openbsc/tests/channel/channel_test.c
@@ -109,7 +109,7 @@
 	ts.flags = 0; /* TCH_F mode */
 	OSMO_ASSERT(ts_subslots(&ts) == 1);
 	ts.flags = TS_F_PDCH_ACTIVE;
-	OSMO_ASSERT(ts_subslots(&ts) == 1 /* SHOULD BE 0 */);
+	OSMO_ASSERT(ts_subslots(&ts) == 0);
 
 	ts.pchan = GSM_PCHAN_TCH_F_TCH_H_PDCH;
 	ts.dyn.pchan_is = GSM_PCHAN_TCH_F;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Icd6668667ad2be7ad20866ffd185bf3b8711ccd6
Gerrit-PatchSet: 1
Gerrit-Project: openbsc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>



More information about the gerrit-log mailing list