aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2023-05-31 19:36:41 +0200
committerPau Espin Pedrol <pespin@sysmocom.de>2023-05-31 20:49:56 +0200
commitf09056de4648fdf942dd564f70387de5be244964 (patch)
tree6721f4aadaeb19e86c25513cfad204a8385a9cda
parent33cb3d61756834d404b68f537e208d760b3473a8 (diff)
Error trying to obtain FN from RFN if curr_fn not known
This may happen if a RACH.ind is received before any DATA.ind has been received. With usual osmo-bts-trx or osmo-bts-sysmo, this shouldn't happen nowadays, but it is still a problem with osmo-bts-virtual, where lower layers don't submit NOPE.ind in the absence of data, and hence it won't sent DATA.ind to osmo-pcu all the time. This change helps in showcasing confusing scenarios where the RFN generated in the Imm Ass was wrong. Change-Id: I29b7ba828fe890f90e35686bbb04d4abfe56b955
-rw-r--r--src/bts.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/bts.cpp b/src/bts.cpp
index 8d6f1566..6cac93f5 100644
--- a/src/bts.cpp
+++ b/src/bts.cpp
@@ -740,20 +740,27 @@ int bts_rcv_imm_ass_cnf(struct gprs_rlcmac_bts *bts, const uint8_t *data, uint32
/* Determine the full frame number from a relative frame number */
uint32_t bts_rfn_to_fn(const struct gprs_rlcmac_bts *bts, uint32_t rfn)
{
- uint32_t m_cur_rfn;
+ uint32_t m_cur_fn, m_cur_rfn;
uint32_t fn_rounded;
/* Ensure that all following calculations are performed with the
* relative frame number */
OSMO_ASSERT(rfn < RFN_MODULUS);
+ m_cur_fn = bts_current_frame_number(bts);
+ if (m_cur_fn == FN_UNSET) {
+ LOGP(DRLCMAC, LOGL_ERROR, "Unable to calculate full FN from RFN %u: Current FN not known!\n",
+ rfn);
+ return rfn;
+ }
+
/* Compute an internal relative frame number from the full internal
frame number */
- m_cur_rfn = fn2rfn(bts->cur_fn);
+ m_cur_rfn = fn2rfn(m_cur_fn);
/* Compute a "rounded" version of the internal frame number, which
* exactly fits in the RFN_MODULUS raster */
- fn_rounded = GSM_TDMA_FN_SUB(bts->cur_fn, m_cur_rfn);
+ fn_rounded = GSM_TDMA_FN_SUB(m_cur_fn, m_cur_rfn);
/* If the delta between the internal and the external relative frame
* number exceeds a certain limit, we need to assume that the incoming
@@ -762,7 +769,7 @@ uint32_t bts_rfn_to_fn(const struct gprs_rlcmac_bts *bts, uint32_t rfn)
if (GSM_TDMA_FN_DIFF(rfn, m_cur_rfn) > RFN_THRESHOLD) {
LOGP(DRLCMAC, LOGL_DEBUG,
"Race condition between rfn (%u) and m_cur_fn (%u) detected: rfn belongs to the previous modulus %u cycle, wrapping...\n",
- rfn, bts->cur_fn, RFN_MODULUS);
+ rfn, m_cur_fn, RFN_MODULUS);
if (fn_rounded < RFN_MODULUS) {
LOGP(DRLCMAC, LOGL_DEBUG,
"Cornercase detected: wrapping crosses %u border\n",