get_lchan_by_chan_nr(): Fix resolution of CBCH

The CBCH (as per GSM specs) always maps on sub-slot 2 of either
the SDCCH/4 or SDCCH/8 that it replaces.  However, the way how we
express it as RSL-style channel number (0xC8) doesn't allow room
for any sub-slots.  The top 5 bits are used for expressing CBCH, while
the bottom 3 bits are used for the timeslot number (TN).

So when transforming from channel number to lchan, we must handle the
CBCH case specially by using a hard-coded sub-slot number of 2.

Change-Id: I44e2f763d5d25311167f435f2ca7e030b2a3f009
Related: OS#1617
This commit is contained in:
Harald Welte 2018-09-17 20:45:54 +02:00
parent 3941cf4479
commit 3c87f5c3ea
1 changed files with 12 additions and 1 deletions

View File

@ -58,7 +58,18 @@
struct gsm_lchan *get_lchan_by_chan_nr(struct gsm_bts_trx *trx,
unsigned int chan_nr)
{
return &trx->ts[L1SAP_CHAN2TS(chan_nr)].lchan[l1sap_chan2ss(chan_nr)];
unsigned int tn, ss;
tn = L1SAP_CHAN2TS(chan_nr);
OSMO_ASSERT(tn < ARRAY_SIZE(trx->ts));
if (L1SAP_IS_CHAN_CBCH(chan_nr))
ss = 2; /* CBCH is always on sub-slot 2 */
else
ss = l1sap_chan2ss(chan_nr);
OSMO_ASSERT(ss < ARRAY_SIZE(trx->ts[tn].lchan));
return &trx->ts[tn].lchan[ss];
}
static struct gsm_lchan *