aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax <msuraev@sysmocom.de>2018-01-05 15:53:08 +0100
committerMax <msuraev@sysmocom.de>2018-02-07 17:25:42 +0100
commit137fd59bf4635bd661671c94eb9ac67757493f99 (patch)
tree8155a7e7e30dcf3b86b4cac9754e601fdd1351ec
parentc9ce6f916e92bb2901f39581072db7fe9ccf9ef8 (diff)
RACH: improve single block detection
Replace unreadable if-else ladder in is_single_block() with regular switch-case. This enables implementation of 11-bit RACH support in follow-up patches. Related: OS#1548 Change-Id: I9180478152f9341f11bb3dffe61671da683f24d8
-rw-r--r--src/bts.cpp72
1 files changed, 28 insertions, 44 deletions
diff --git a/src/bts.cpp b/src/bts.cpp
index 3d29ad69..05966d04 100644
--- a/src/bts.cpp
+++ b/src/bts.cpp
@@ -642,55 +642,39 @@ static inline bool is_single_block(bool force_two_phase, uint16_t ra, enum ph_bu
"MS requests single phase access, but we force two phase access [RACH is %s bit]\n",
is_11bit ? "11" : "8");
- if (!is_11bit && (burst_type == GSM_L1_BURST_TYPE_ACCESS_0)) {
+ switch(burst_type) {
+ case GSM_L1_BURST_TYPE_ACCESS_0:
+ if (is_11bit) {
+ LOGP(DRLCMAC, LOGL_ERROR, "Error: GPRS 11 bit RACH not supported\n");
+ return false;
+ }
if ((ra & 0xf8) == 0x70)
- sb = true;
- else if (force_two_phase) {
- LOGP(DRLCMAC, LOGL_DEBUG, "MS requests single "
- "phase access, but we force two phase "
- "access\n");
- sb = true;
- }
+ return true;
- } else if (is_11bit &&
- ((burst_type == GSM_L1_BURST_TYPE_ACCESS_1) ||
- (burst_type == GSM_L1_BURST_TYPE_ACCESS_2))) {
-
- if (!(ra & (1 << 10))) {
- if (force_two_phase) {
- LOGP(DRLCMAC, LOGL_DEBUG, "EGPRS 11 bit RACH "
- "received. MS requests single phase "
- "access but we force two phase "
- "access\n");
- sb = true;
- } else
- sb = false;
- } else {
- LOGP(DRLCMAC, LOGL_DEBUG, "EGPRS 11 bit RACH received."
- "MS requests single block allocation\n");
- sb = true;
- }
+ if (force_two_phase)
+ return true;
+ break;
+ case GSM_L1_BURST_TYPE_ACCESS_1: /* deliberate fall-through */
+ case GSM_L1_BURST_TYPE_ACCESS_2:
+ if (is_11bit) {
+ if (!(ra & (1 << 10))) {
+ if (force_two_phase)
+ return true;
+
+ return false;
+ }
- } else if (is_11bit &&
- (burst_type == GSM_L1_BURST_TYPE_ACCESS_0)) {
- LOGP(DRLCMAC, LOGL_ERROR,
- "Error: GPRS 11 bit RACH not supported\n");
-
- } else if (burst_type == GSM_L1_BURST_TYPE_NONE) {
- LOGP(DRLCMAC, LOGL_DEBUG, "pcu has not received burst type "
- "from bts \n");
-
- if ((ra & 0xf8) == 0x70) {
- LOGP(DRLCMAC, LOGL_DEBUG, "MS requests single block "
- "allocation\n");
- sb = true;
- } else if (force_two_phase) {
- LOGP(DRLCMAC, LOGL_DEBUG, "MS requests single "
- "phase access, but we force two phase "
- "access\n");
- sb = true;
+ return true;
}
+ LOGP(DRLCMAC, LOGL_ERROR, "Unexpected RACH burst type %u for 8-bit RACH\n", burst_type);
+ break;
+ case GSM_L1_BURST_TYPE_NONE:
+ LOGP(DRLCMAC, LOGL_ERROR, "PCU has not received burst type from BTS\n");
+ break;
+ default:
+ LOGP(DRLCMAC, LOGL_ERROR, "Unexpected RACH burst type %u for %s-bit RACH\n",
+ burst_type, is_11bit ? "11" : "8");
}
return sb;