openbsc[master]: dyn PDCH: allow allocating TCH/F on TCH/F_PDCH slots

Message ID gerrit.1464868259650.Iddd575873a2fe819fc182a6b3d4186caea1997e5@gerrit.osmocom.org
State New
Headers show

Commit Message

gerrit-no-reply@lists.osmocom.org June 2, 2016, 11:51 a.m.
Review at  https://gerrit.osmocom.org/180

dyn PDCH: allow allocating TCH/F on TCH/F_PDCH slots

See comment added in the code.

Original patch by jolly, but split in two, added comment and flipped the if()
logic for readability by nhofmeyr.

Change-Id: Iddd575873a2fe819fc182a6b3d4186caea1997e5
---
M openbsc/src/libbsc/chan_alloc.c
1 file changed, 10 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/80/180/1

Patch

diff --git a/openbsc/src/libbsc/chan_alloc.c b/openbsc/src/libbsc/chan_alloc.c
index 8600846..cd25bd9 100644
--- a/openbsc/src/libbsc/chan_alloc.c
+++ b/openbsc/src/libbsc/chan_alloc.c
@@ -96,14 +96,16 @@ 
 		ts = &trx->ts[j];
 		if (!ts_is_usable(ts))
 			continue;
-		/* ip.access dynamic TCH/F + PDCH combination */
-		if (ts->pchan == GSM_PCHAN_TCH_F_PDCH &&
-		    pchan == GSM_PCHAN_TCH_F) {
-			/* we can only consider such a dynamic channel
-			 * if the PDCH is currently inactive */
-			if (ts->flags & TS_F_PDCH_MODE)
-				continue;
-		} else if (ts->pchan != pchan)
+		/*
+		 * pchan must match; but when looking for TCH/F, allow a match
+		 * with TCH/F_PDCH, to return dynamic TCH/F_PDCH slots to the
+		 * channel allocator. Thus the channel allocator can pick a
+		 * TCH/F_PDCH time slot and disable its PDCH later on (no need
+		 * to check whether PDCH mode is currently active here).
+		 */
+		if (!(ts->pchan == pchan
+		      || (ts->pchan == GSM_PCHAN_TCH_F_PDCH
+			  && pchan == GSM_PCHAN_TCH_F)))
 			continue;
 		/* check if all sub-slots are allocated yet */
 		for (ss = 0; ss < subslots_per_pchan[pchan]; ss++) {