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/.
Harald Welte gerrit-no-reply at lists.osmocom.orgHarald Welte has submitted this change and it was merged. ( https://gerrit.osmocom.org/11163 )
Change subject: Fix computing CCCH block number from frame number
......................................................................
Fix computing CCCH block number from frame number
The existing implementation used a simplistic macro, which was wrong
in many ways:
1) it returned a negative value for "fn % 51 < 5" conditions without
raising any error message or asserting
2) it returned a wrong block number for many different input frame
numbers, as it didn't account properly for the FCCH/SCH gaps between
the blocks
Let's replace the simplistic macro with a proper lookup table based on
TS 05.02, and let's OSMO_ASSERT() if this is ever called with non-CCCH
frame numbers.
Change-Id: I11fd6cc558bb61c40c2019e46f56c1fe78ef39f5
Closes: OS#3024
---
M include/osmo-bts/l1sap.h
M src/common/l1sap.c
M src/osmo-bts-litecell15/l1_if.c
M src/osmo-bts-sysmo/l1_if.c
M src/osmo-bts-virtual/scheduler_virtbts.c
5 files changed, 41 insertions(+), 6 deletions(-)
Approvals:
Jenkins Builder: Verified
Harald Welte: Looks good to me, approved
diff --git a/include/osmo-bts/l1sap.h b/include/osmo-bts/l1sap.h
index 3225a60..e2c92fa 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 ac4f0be..0f3cd3a 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 @@
} 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 @@
/* 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 4093225..99852e3 100644
--- a/src/osmo-bts-litecell15/l1_if.c
+++ b/src/osmo-bts-litecell15/l1_if.c
@@ -388,7 +388,7 @@
} 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 372e332..247c371 100644
--- a/src/osmo-bts-sysmo/l1_if.c
+++ b/src/osmo-bts-sysmo/l1_if.c
@@ -385,7 +385,7 @@
} 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 cdbb9c1..997ccbc 100644
--- a/src/osmo-bts-virtual/scheduler_virtbts.c
+++ b/src/osmo-bts-virtual/scheduler_virtbts.c
@@ -79,7 +79,7 @@
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 */
--
To view, visit https://gerrit.osmocom.org/11163
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I11fd6cc558bb61c40c2019e46f56c1fe78ef39f5
Gerrit-Change-Number: 11163
Gerrit-PatchSet: 2
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder (1000002)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180930/de8d3282/attachment.htm>