Max has submitted this change and it was merged.

Change subject: RACH: improve single block detection
......................................................................


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
---
M src/bts.cpp
1 file changed, 30 insertions(+), 46 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



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 @@
                     "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;
+
+               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;
+                       }
+
+                       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;
-               }
-
-       } 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;
-               }
+               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;

-- 
To view, visit https://gerrit.osmocom.org/6312
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I9180478152f9341f11bb3dffe61671da683f24d8
Gerrit-PatchSet: 1
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Owner: Max <msur...@sysmocom.de>
Gerrit-Reviewer: Harald Welte <lafo...@gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max <msur...@sysmocom.de>

Reply via email to