<p>Harald Welte has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/12788">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">WIP: Implement CSFB "Fast Return" Handling at RR RELEASE<br><br>When the MSC sends a BSSMAP CLEAR CMD containing a CSFB Indication IE,<br>it lets us know that the to-be-released connection related to a CSFB<br>call.<br><br>We as the BSC then subsequently should include the "Cell Selection<br>Indocator after release of all TCH and SDCCH" IE in the RR RELEASE<br>message sent to the MS/UE.  This IE contains the LTE neighbor cells<br>that we're configured to broadcast in si2quater.<br><br>That in turn will make sure the MS/UE can return very quickly to<br>the LTE cell.<br><br>Change-Id: Ibfbb87e2e16b05032ad1cb91c11fad1b2f76d755<br>Requires: libosmocore Id4bd7f7543f5b0f4f6f876e283bd065039c37646<br>Requires: libosmocore I0e101af316438b56d63d43fc2cb16d7caf563d07<br>---<br>M include/osmocom/bsc/gsm_data.h<br>M src/osmo-bsc/bsc_subscr_conn_fsm.c<br>M src/osmo-bsc/gsm_04_08_rr.c<br>M src/osmo-bsc/osmo_bsc_bssap.c<br>4 files changed, 75 insertions(+), 1 deletion(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/88/12788/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/include/osmocom/bsc/gsm_data.h b/include/osmocom/bsc/gsm_data.h</span><br><span>index 9f7ce8d..58c0541 100644</span><br><span>--- a/include/osmocom/bsc/gsm_data.h</span><br><span>+++ b/include/osmocom/bsc/gsm_data.h</span><br><span>@@ -557,6 +557,9 @@</span><br><span>           /* If a release event is being handled, ignore other ricocheting release events until that</span><br><span>            * release handling has concluded. */</span><br><span>                bool in_release_handler;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+            /* is this release at the end of a CSFB call? */</span><br><span style="color: hsl(120, 100%, 40%);">+              bool is_csfb;</span><br><span>        } release;</span><br><span> </span><br><span>       /* The logical channel type */</span><br><span>diff --git a/src/osmo-bsc/bsc_subscr_conn_fsm.c b/src/osmo-bsc/bsc_subscr_conn_fsm.c</span><br><span>index fc34968..13a5730 100644</span><br><span>--- a/src/osmo-bsc/bsc_subscr_conn_fsm.c</span><br><span>+++ b/src/osmo-bsc/bsc_subscr_conn_fsm.c</span><br><span>@@ -718,6 +718,8 @@</span><br><span>    /* Regular allstate event processing */</span><br><span>      switch (event) {</span><br><span>     case GSCON_EV_A_CLEAR_CMD:</span><br><span style="color: hsl(120, 100%, 40%);">+            if (conn->lchan)</span><br><span style="color: hsl(120, 100%, 40%);">+                   conn->lchan->release.is_csfb = *(bool *)data;</span><br><span>          /* MSC tells us to cleanly shut down */</span><br><span>              if (conn->fi->state != ST_CLEARING)</span><br><span>                    osmo_fsm_inst_state_chg(fi, ST_CLEARING, 60, 999);</span><br><span>diff --git a/src/osmo-bsc/gsm_04_08_rr.c b/src/osmo-bsc/gsm_04_08_rr.c</span><br><span>index f1061ef..5c86d53 100644</span><br><span>--- a/src/osmo-bsc/gsm_04_08_rr.c</span><br><span>+++ b/src/osmo-bsc/gsm_04_08_rr.c</span><br><span>@@ -28,7 +28,9 @@</span><br><span> #include <netinet/in.h></span><br><span> </span><br><span> #include <osmocom/core/msgb.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <osmocom/core/bitvec.h></span><br><span> #include <osmocom/gsm/gsm48.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <osmocom/gsm/sysinfo.h></span><br><span> </span><br><span> #include <osmocom/bsc/abis_rsl.h></span><br><span> #include <osmocom/bsc/debug.h></span><br><span>@@ -40,6 +42,8 @@</span><br><span> #include <osmocom/bsc/assignment_fsm.h></span><br><span> #include <osmocom/bsc/handover_fsm.h></span><br><span> #include <osmocom/bsc/gsm_08_08.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <osmocom/bsc/gsm_data.h></span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> </span><br><span> /* should ip.access BTS use direct RTP streams between each other (1),</span><br><span>  * or should OpenBSC always act as RTP relay/proxy in between (0) ? */</span><br><span>@@ -236,6 +240,46 @@</span><br><span>                        lchan->mr_ms_lv + 1);</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#define CELL_SEL_IND_AFTER_REL_MAX_BITS    (4+MAX_EARFCN_LIST*19)</span><br><span style="color: hsl(120, 100%, 40%);">+#define CELL_SEL_IND_AFTER_REL_MAX_BYTES ((CELL_SEL_IND_AFTER_REL_MAX_BITS/8)+1)</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/* Generate a CSN.1 encoded "Cell Selection Indocator after release of all TCH and SDCCH"</span><br><span style="color: hsl(120, 100%, 40%);">+ * as per TF 44.018 version 15.3.0 Table 10.5.2.1e.1.  This only generates the "value"</span><br><span style="color: hsl(120, 100%, 40%);">+ * part of the IE, not the tag+length wrapper */</span><br><span style="color: hsl(120, 100%, 40%);">+static int generate_cell_sel_ind_after_rel(uint8_t *out, unsigned int out_len, const struct gsm_bts *bts)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+     struct bitvec bv;</span><br><span style="color: hsl(120, 100%, 40%);">+     unsigned int i;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+     bv.data = out;</span><br><span style="color: hsl(120, 100%, 40%);">+        bv.data_len = out_len;</span><br><span style="color: hsl(120, 100%, 40%);">+        bitvec_zero(&bv);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+       /* E-UTRAN Description */</span><br><span style="color: hsl(120, 100%, 40%);">+     bitvec_set_uint(&bv, 3, 3);</span><br><span style="color: hsl(120, 100%, 40%);">+       bitvec_set_bit(&bv, 1);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ for (i = 0; i < MAX_EARFCN_LIST; i++) {</span><br><span style="color: hsl(120, 100%, 40%);">+            const struct osmo_earfcn_si2q *e = &bts->si_common.si2quater_neigh_list;</span><br><span style="color: hsl(120, 100%, 40%);">+               if (e->arfcn[i] == OSMO_EARFCN_INVALID)</span><br><span style="color: hsl(120, 100%, 40%);">+                    continue;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+           if (0/* no more space in bitvec for 19 bits*/)</span><br><span style="color: hsl(120, 100%, 40%);">+                        break;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+              bitvec_set_uint(&bv, e->arfcn[i], 16);</span><br><span style="color: hsl(120, 100%, 40%);">+         /* No "Measurement Bandwidth" */</span><br><span style="color: hsl(120, 100%, 40%);">+            bitvec_set_bit(&bv, 0);</span><br><span style="color: hsl(120, 100%, 40%);">+           /* No "Not Allowed Cells" */</span><br><span style="color: hsl(120, 100%, 40%);">+                bitvec_set_bit(&bv, 0);</span><br><span style="color: hsl(120, 100%, 40%);">+           /* No "TARGET_PCID" */</span><br><span style="color: hsl(120, 100%, 40%);">+              bitvec_set_bit(&bv, 0);</span><br><span style="color: hsl(120, 100%, 40%);">+   }</span><br><span style="color: hsl(120, 100%, 40%);">+     /* return the number of bytes used */</span><br><span style="color: hsl(120, 100%, 40%);">+ return bitvec_used_bytes(&bv);</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> /* 7.1.7 and 9.1.7: RR CHANnel RELease */</span><br><span> int gsm48_send_rr_release(struct gsm_lchan *lchan)</span><br><span> {</span><br><span>@@ -250,6 +294,14 @@</span><br><span>       cause = msgb_put(msg, 1);</span><br><span>    cause[0] = GSM48_RR_CAUSE_NORMAL;</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ if (lchan->release.is_csfb) {</span><br><span style="color: hsl(120, 100%, 40%);">+              uint8_t buf[CELL_SEL_IND_AFTER_REL_MAX_BYTES];</span><br><span style="color: hsl(120, 100%, 40%);">+                int len;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+            len = generate_cell_sel_ind_after_rel(buf, sizeof(buf), lchan->ts->trx->bts);</span><br><span style="color: hsl(120, 100%, 40%);">+                msgb_tlv_put(msg, GSM48_IE_CELL_SEL_IND_AFTER_REL, len, buf);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>  DEBUGP(DRR, "Sending Channel Release: Chan: Number: %d Type: %d\n",</span><br><span>                lchan->nr, lchan->type);</span><br><span> </span><br><span>diff --git a/src/osmo-bsc/osmo_bsc_bssap.c b/src/osmo-bsc/osmo_bsc_bssap.c</span><br><span>index f2ccf2c..ab7f79c 100644</span><br><span>--- a/src/osmo-bsc/osmo_bsc_bssap.c</span><br><span>+++ b/src/osmo-bsc/osmo_bsc_bssap.c</span><br><span>@@ -420,6 +420,23 @@</span><br><span>   return gsm48_send_rr_ciph_mode(conn->lchan, include_imeisv);</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+static int bssmap_handle_clear_cmd(struct gsm_subscriber_connection *conn,</span><br><span style="color: hsl(120, 100%, 40%);">+                             struct msgb *msg, unsigned int length)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+  struct tlv_parsed tp;</span><br><span style="color: hsl(120, 100%, 40%);">+ bool is_csfb = false;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+       tlv_parse(&tp, gsm0808_att_tlvdef(), msg->l4h + 1, length - 1, 0, 0);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+        /* FIXME: Check for mandatory cause IE, and use that in RR RELEASE cause! */</span><br><span style="color: hsl(120, 100%, 40%);">+  if (TLVP_PRESENT(&tp, GSM0808_IE_CSFB_INDICATION))</span><br><span style="color: hsl(120, 100%, 40%);">+                is_csfb = true;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+     osmo_fsm_inst_dispatch(conn->fi, GSCON_EV_A_CLEAR_CMD, &is_csfb);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+    return 0;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> /*</span><br><span>  * GSM 08.08 ยง 3.1.14 cipher mode handling. We will have to pick</span><br><span>  * the cipher to be used for this. In case we are already using</span><br><span>@@ -867,7 +884,7 @@</span><br><span> </span><br><span>       switch (msg->l4h[0]) {</span><br><span>    case BSS_MAP_MSG_CLEAR_CMD:</span><br><span style="color: hsl(0, 100%, 40%);">-             osmo_fsm_inst_dispatch(conn->fi, GSCON_EV_A_CLEAR_CMD, msg);</span><br><span style="color: hsl(120, 100%, 40%);">+               ret = bssmap_handle_clear_cmd(conn, msg, length);</span><br><span>            break;</span><br><span>       case BSS_MAP_MSG_CIPHER_MODE_CMD:</span><br><span>            ret = bssmap_handle_cipher_mode(conn, msg, length);</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/12788">change 12788</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/12788"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: osmo-bsc </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: Ibfbb87e2e16b05032ad1cb91c11fad1b2f76d755 </div>
<div style="display:none"> Gerrit-Change-Number: 12788 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Harald Welte <laforge@gnumonks.org> </div>