Fix TCH/F_PDCH: no need to check ts subslots for PDCH

For TCH/F_PDCH in PDCH mode, directly return the lchan to use, in order to
switch it to TCH/F. To check the pchan type in chan_alloc.c, make ts_pchan()
public in gsm_data_shared.h.

Commit c3f72f63af broke TCH/F_PDCH, as a fallout
of setting the GSM_PCHAN_PDCH subslots number to 0. This is sane and correct,
but the chan_alloc code failed to see a ts as available if it has no subslots.

Explanation:

_lc_find_trx() checks each timeslot. For normal, static TCH timeslots we
determine the number of logical subslots contained and check whether one of
them is free. For dynamic TS, we can do the same when in TCH mode, but when in
PDCH mode, we already know that it is available for immediate switchover for
voice and hence can return it right away. TCH/F_TCH/H_PDCH already has a
special check for that. TCH/F_PDCH doesn't, but this worked for TCH/F_PDCH as
long as ts_subslots() returned 1 for PDCH: the for-loop at the bottom of
_lc_find_trx() checked one subslot, which succeeded on an lchan in PDCH mode,
since PDCH lchans are always marked type == NONE and state == NONE. Now we more
accurately acknowledge that a PDCH timeslot has zero subslots and that a
dynamic timeslot in PDCH mode can always be switched to voice immediately,
without checking lchan type or state.

So, above mentioned commit set PDCH to zero subslots, and the for-loop to check
the (zero) subslots never ran and hence never returned the lchan. This fix adds
a special condition for TCH/F_PDCH in PDCH mode, same as TCH/F_TCH/H_PDCH.

(Todo: ts_pchan() can probably be used in other places as well to remove some
code dup. Leaving that for another patch.)

Fixes: OS#1868
Change-Id: I5d555d018a5bcb8d948e54059d32ec4c9b3070d0
This commit is contained in:
Neels Hofmeyr 2016-12-05 16:50:47 +01:00 committed by Harald Welte
parent e14f4b93f2
commit 8825c69409
1 changed files with 7 additions and 0 deletions

View File

@ -151,6 +151,13 @@ _lc_find_trx(struct gsm_bts_trx *trx, enum gsm_phys_chan_config pchan,
check_subslots = ts_subslots(ts);
break;
case GSM_PCHAN_TCH_F_PDCH:
/* Available for voice when in PDCH mode */
if (ts_pchan(ts) != GSM_PCHAN_PDCH)
continue;
/* Subslots of a PDCH ts don't need to be checked. */
return ts->lchan;
default:
/* Not a dynamic channel, there is only one pchan kind: */
check_subslots = ts_subslots(ts);