diff options
-rw-r--r-- | include/osmo-bts/l1sap.h | 2 | ||||
-rw-r--r-- | src/common/l1sap.c | 39 | ||||
-rw-r--r-- | src/osmo-bts-litecell15/l1_if.c | 2 | ||||
-rw-r--r-- | src/osmo-bts-sysmo/l1_if.c | 2 | ||||
-rw-r--r-- | src/osmo-bts-virtual/scheduler_virtbts.c | 2 |
5 files changed, 41 insertions, 6 deletions
diff --git a/include/osmo-bts/l1sap.h b/include/osmo-bts/l1sap.h index 3225a60f..e2c92fa2 100644 --- a/include/osmo-bts/l1sap.h +++ b/include/osmo-bts/l1sap.h @@ -29,7 +29,7 @@ #define L1SAP_IS_PACKET_RACH(ra) ((ra & 0xf0) == 0x70 && (ra & 0x0f) != 0x0f) /* CCCH block from frame number */ -#define L1SAP_FN2CCCHBLOCK(fn) ((fn % 51) / 5 - 1) +unsigned int l1sap_fn2ccch_block(uint32_t fn); /* PTCH layout from frame number */ #define L1SAP_FN2MACBLOCK(fn) ((fn % 52) / 4) diff --git a/src/common/l1sap.c b/src/common/l1sap.c index ac4f0bea..0f3cd3a4 100644 --- a/src/common/l1sap.c +++ b/src/common/l1sap.c @@ -55,6 +55,41 @@ #include <osmo-bts/pcuif_proto.h> #include <osmo-bts/cbch.h> + +#define CB_FCCH -1 +#define CB_SCH -2 +#define CB_BCCH -3 +#define CB_IDLE -4 + +/* according to TS 05.02 Clause 7 Table 3 of 9 an Figure 8a */ +static const int ccch_block_table[51] = { + CB_FCCH, CB_SCH,/* 0..1 */ + CB_BCCH, CB_BCCH, CB_BCCH, CB_BCCH, /* 2..5: BCCH */ + 0, 0, 0, 0, /* 6..9: B0 */ + CB_FCCH, CB_SCH,/* 10..11 */ + 1, 1, 1, 1, /* 12..15: B1 */ + 2, 2, 2, 2, /* 16..19: B2 */ + CB_FCCH, CB_SCH,/* 20..21 */ + 3, 3, 3, 3, /* 22..25: B3 */ + 4, 4, 4, 4, /* 26..29: B4 */ + CB_FCCH, CB_SCH,/* 30..31 */ + 5, 5, 5, 5, /* 32..35: B5 */ + 6, 6, 6, 6, /* 36..39: B6 */ + CB_FCCH, CB_SCH,/* 40..41 */ + 7, 7, 7, 7, /* 42..45: B7 */ + 8, 8, 8, 8, /* 46..49: B8 */ + -4 /* 50: Idle */ +}; + +/* determine the CCCH block number based on the frame number */ +unsigned int l1sap_fn2ccch_block(uint32_t fn) +{ + int rc = ccch_block_table[fn%51]; + /* if FN is negative, we were called for something that's not CCCH! */ + OSMO_ASSERT(rc >= 0); + return rc; +} + struct gsm_lchan *get_lchan_by_chan_nr(struct gsm_bts_trx *trx, unsigned int chan_nr) { @@ -273,7 +308,7 @@ static int gsmtap_ph_data(struct osmo_phsap_prim *l1sap, uint8_t *chan_type, } else if (L1SAP_IS_CHAN_AGCH_PCH(chan_nr)) { /* The sapi depends on DSP configuration, not * on the actual SYSTEM INFORMATION 3. */ - if (L1SAP_FN2CCCHBLOCK(fn) >= num_agch) + if (l1sap_fn2ccch_block(fn) >= num_agch) *chan_type = GSMTAP_CHANNEL_PCH; else *chan_type = GSMTAP_CHANNEL_AGCH; @@ -686,7 +721,7 @@ int is_ccch_for_agch(struct gsm_bts_trx *trx, uint32_t fn) { /* Note: The number of available access grant channels is set by the * parameter BS_AG_BLKS_RES via system information type 3. This SI is * transfered to osmo-bts via RSL */ - return L1SAP_FN2CCCHBLOCK(fn) < num_agch(trx, "PH-RTS-IND"); + return l1sap_fn2ccch_block(fn) < num_agch(trx, "PH-RTS-IND"); } /* PH-RTS-IND prim received from bts model */ diff --git a/src/osmo-bts-litecell15/l1_if.c b/src/osmo-bts-litecell15/l1_if.c index 4093225f..99852e39 100644 --- a/src/osmo-bts-litecell15/l1_if.c +++ b/src/osmo-bts-litecell15/l1_if.c @@ -388,7 +388,7 @@ static int ph_data_req(struct gsm_bts_trx *trx, struct msgb *msg, } else if (L1SAP_IS_CHAN_AGCH_PCH(chan_nr)) { /* The sapi depends on DSP configuration, not * on the actual SYSTEM INFORMATION 3. */ - u8BlockNbr = L1SAP_FN2CCCHBLOCK(u32Fn); + u8BlockNbr = l1sap_fn2ccch_block(u32Fn); if (u8BlockNbr >= num_agch(trx, "PH-DATA-REQ")) sapi = GsmL1_Sapi_Pch; else diff --git a/src/osmo-bts-sysmo/l1_if.c b/src/osmo-bts-sysmo/l1_if.c index 372e3322..247c3712 100644 --- a/src/osmo-bts-sysmo/l1_if.c +++ b/src/osmo-bts-sysmo/l1_if.c @@ -385,7 +385,7 @@ static int ph_data_req(struct gsm_bts_trx *trx, struct msgb *msg, } else if (L1SAP_IS_CHAN_AGCH_PCH(chan_nr)) { /* The sapi depends on DSP configuration, not * on the actual SYSTEM INFORMATION 3. */ - u8BlockNbr = L1SAP_FN2CCCHBLOCK(u32Fn); + u8BlockNbr = l1sap_fn2ccch_block(u32Fn); if (u8BlockNbr >= 1) sapi = GsmL1_Sapi_Pch; else diff --git a/src/osmo-bts-virtual/scheduler_virtbts.c b/src/osmo-bts-virtual/scheduler_virtbts.c index cdbb9c1f..997ccbc2 100644 --- a/src/osmo-bts-virtual/scheduler_virtbts.c +++ b/src/osmo-bts-virtual/scheduler_virtbts.c @@ -79,7 +79,7 @@ static void tx_to_virt_um(struct l1sched_trx *l1t, uint8_t tn, uint32_t fn, timeslot = tn; /* in Osmocom, AGCH is only sent on ccch block 0. no idea why. this seems to cause false GSMTAP channel * types for agch and pch. */ - if (rsl_chantype == RSL_CHAN_PCH_AGCH && L1SAP_FN2CCCHBLOCK(fn) == 0) + if (rsl_chantype == RSL_CHAN_PCH_AGCH && l1sap_fn2ccch_block(fn) == 0) gsmtap_chantype = GSMTAP_CHANNEL_PCH; else gsmtap_chantype = chantype_rsl2gsmtap(rsl_chantype, chdesc->link_id); /* the logical channel type */ |