aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax <msuraev@sysmocom.de>2018-01-05 15:53:08 +0100
committerNeels Hofmeyr <neels@hofmeyr.de>2018-02-27 22:27:52 +0100
commit7b1087bb0306875e3368077d1befded374192c14 (patch)
tree7197a52a95eb9d6bc15e4854f8fa44ed7643f971
parent48aa75735cf1d051254f6d6a068e06b2c42faddd (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 3d29ad6..05966d0 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;