<p>Neels Hofmeyr <strong>merged</strong> this change.</p><p><a href="https://gerrit.osmocom.org/9350">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  Jenkins Builder: Verified
  Harald Welte: Looks good to me, approved

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">doc: add msc charts on Assignment/Handover internals<br><br>In doc/, add two message sequence charts with lots of implementation specifics,<br>to clarify the current code state. Mark various problems in red notes.<br><br>This chart and others should help to illustrate future code changes as I go<br>along refactoring handover, lchan allocation and adding inter-BSC handover.<br><br>Change-Id: I20999e938441d4fed2d37462b262b74a696f616d<br>---<br>M doc/Makefile.am<br>A doc/assignment.msc<br>A doc/handover.msc<br>3 files changed, 357 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/doc/Makefile.am b/doc/Makefile.am</span><br><span>index 5a23107..cc2e277 100644</span><br><span>--- a/doc/Makefile.am</span><br><span>+++ b/doc/Makefile.am</span><br><span>@@ -1,3 +1,15 @@</span><br><span> SUBDIRS = \</span><br><span>        examples \</span><br><span>   $(NULL)</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+msc: \</span><br><span style="color: hsl(120, 100%, 40%);">+     $(builddir)/handover.png \</span><br><span style="color: hsl(120, 100%, 40%);">+    $(builddir)/assignment.png \</span><br><span style="color: hsl(120, 100%, 40%);">+  $(NULL)</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+$(builddir)/%.png: $(srcdir)/%.msc</span><br><span style="color: hsl(120, 100%, 40%);">+ mscgen -T png -o $@ $<</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+.PHONY: poll</span><br><span style="color: hsl(120, 100%, 40%);">+poll:</span><br><span style="color: hsl(120, 100%, 40%);">+      while true; do $(MAKE) msc; sleep 1; done</span><br><span>diff --git a/doc/assignment.msc b/doc/assignment.msc</span><br><span>new file mode 100644</span><br><span>index 0000000..e2bdf84</span><br><span>--- /dev/null</span><br><span>+++ b/doc/assignment.msc</span><br><span>@@ -0,0 +1,181 @@</span><br><span style="color: hsl(120, 100%, 40%);">+msc {</span><br><span style="color: hsl(120, 100%, 40%);">+        hscale=3;</span><br><span style="color: hsl(120, 100%, 40%);">+     ms [label="MS"], bts [label="BTS"], bsc[label="BSC"], bsc_gscon[label="BSC conn FSM"], bsc_mgcp[label="BSC mgcp FSM"], mgw[label="MGW"], msc_[label="MSC"];</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   ms note msc_ [label="lchan allocation sequence for BSSMAP Assignment Request"];</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   bsc <= msc_ [label="BSSMAP Assignment Request"];</span><br><span style="color: hsl(120, 100%, 40%);">+ bsc box bsc [label="bssmap_handle_assignm_req()"];</span><br><span style="color: hsl(120, 100%, 40%);">+  bsc -> bsc_gscon [label="GSCON_EV_A_ASSIGNMENT_CMD"];</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+  --- [label="is the chan_mode a speech mode?"];</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+    bsc_gscon abox bsc_gscon [label="ST_WAIT_CRCX_BTS (MGCP_MGW_TIMEOUT = 4s)"];</span><br><span style="color: hsl(120, 100%, 40%);">+        bsc_gscon -> bsc_mgcp [label="mgcp_conn_create()"];</span><br><span style="color: hsl(120, 100%, 40%);">+      bsc_mgcp => mgw [label="CRCX (for BTS)"];</span><br><span style="color: hsl(120, 100%, 40%);">+        bsc_mgcp abox bsc_mgcp [label="ST_CRCX (MGCP_MGW_TIMEOUT = 4s)"];</span><br><span style="color: hsl(120, 100%, 40%);">+   bsc_gscon note bsc_mgcp [label="two timeouts running in parallel"];</span><br><span style="color: hsl(120, 100%, 40%);">+ bsc_gscon note bsc_mgcp [label="note: #define MGCP_MGW_TIMEOUT exists twice,</span><br><span style="color: hsl(120, 100%, 40%);">+                                    once in libosmo-mgcp-client,</span><br><span style="color: hsl(120, 100%, 40%);">+                                  once in bsc_subscr_conn_fsm.c"];</span><br><span style="color: hsl(120, 100%, 40%);">+  bsc_mgcp -> bsc_gscon [label="mgcp_conn_create() exits"];</span><br><span style="color: hsl(120, 100%, 40%);">+        bsc_gscon -> bsc [label="bssmap_handle_assignm_req() exits"];</span><br><span style="color: hsl(120, 100%, 40%);">+    ...;</span><br><span style="color: hsl(120, 100%, 40%);">+  --- [label="On Timeout"];</span><br><span style="color: hsl(120, 100%, 40%);">+   bsc_gscon note bsc_gscon [label="The conn FSM likely timeouts first"];</span><br><span style="color: hsl(120, 100%, 40%);">+      bsc_gscon => msc_ [label="BSSMAP Assignment Failure"];</span><br><span style="color: hsl(120, 100%, 40%);">+   bsc_gscon abox bsc_gscon [label="ST_ACTIVE"];</span><br><span style="color: hsl(120, 100%, 40%);">+       bsc_mgcp note bsc_mgcp [label="The MGCP FSM will timeout right after that, and terminate itself,</span><br><span style="color: hsl(120, 100%, 40%);">+                               emitting the parent_term event set upon mgcp_conn_create():"];</span><br><span style="color: hsl(120, 100%, 40%);">+     bsc_mgcp -> bsc_gscon [label="GSCON_EV_MGW_FAIL_BTS"];</span><br><span style="color: hsl(120, 100%, 40%);">+   bsc_gscon note bsc_gscon [label="GSCON_EV_MGW_FAIL_BTS is handled by the conn FSM allstate</span><br><span style="color: hsl(120, 100%, 40%);">+                                       handler. It sets conn->user_plane.fi_bts = NULL. There is code</span><br><span style="color: hsl(120, 100%, 40%);">+                                     that would emit a BSSMAP Assignment Failure, but not in</span><br><span style="color: hsl(120, 100%, 40%);">+                                       ST_ACTIVE"];</span><br><span style="color: hsl(120, 100%, 40%);">+     --- [label="end: 'On Timeout'"];</span><br><span style="color: hsl(120, 100%, 40%);">+    ...;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+        bsc_mgcp <= mgw [label="CRCX OK (for BTS)"];</span><br><span style="color: hsl(120, 100%, 40%);">+     bsc_mgcp box bsc_mgcp [label="libosmo-mgcp-client fsm_crcx_resp_cb()"];</span><br><span style="color: hsl(120, 100%, 40%);">+     bsc_mgcp -> bsc_gscon [label="GSCON_EV_MGW_CRCX_RESP_BTS"];</span><br><span style="color: hsl(120, 100%, 40%);">+      --- [label="end: 'is the chan_mode a speech mode?'"];</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+     bsc_gscon note bsc_gscon [label="for mode=sign, we're still handling GSCON_EV_A_ASSIGNMENT_CMD;</span><br><span style="color: hsl(120, 100%, 40%);">+                                       for speech mode, we're handling GSCON_EV_MGW_CRCX_RESP_BTS"];</span><br><span style="color: hsl(120, 100%, 40%);">+       bsc <- bsc_gscon [label="gsm0808_assign_req()"];</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+       bsc box bsc [label="lchan_alloc(): pick available lchan"];</span><br><span style="color: hsl(120, 100%, 40%);">+  bsc box bsc [label="rsl_chan_activate_lchan()"];</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+  --- [label="is the chosen lchan on dynamic timeslot that is currently used as PDCH?"];</span><br><span style="color: hsl(120, 100%, 40%);">+      bts <= bsc [label="i) RSL RF Chan Release of PDCH (Osmocom dyn TS)"];</span><br><span style="color: hsl(120, 100%, 40%);">+    bts <= bsc [label="OR ii) RSL PDCH Deact (ip.access dyn TS)"];</span><br><span style="color: hsl(120, 100%, 40%);">+   bsc -> bsc_gscon [label="gsm0808_assign_req() returns early"];</span><br><span style="color: hsl(120, 100%, 40%);">+   bsc_gscon abox bsc_gscon [label="ST_WAIT_ASS_COMPL (GSM0808_T10_VALUE=6s)"];</span><br><span style="color: hsl(120, 100%, 40%);">+        ...;</span><br><span style="color: hsl(120, 100%, 40%);">+  bts note bsc_gscon [linecolor="red",</span><br><span style="color: hsl(120, 100%, 40%);">+          label="There seems to be no timer watching over Chan Release nor dyn TS switchover!"];</span><br><span style="color: hsl(120, 100%, 40%);">+    ...;</span><br><span style="color: hsl(120, 100%, 40%);">+  bts => bsc [label="i) RSL RF Chan Release ACK (Osmocom dyn TS)"];</span><br><span style="color: hsl(120, 100%, 40%);">+        bts => bsc [label="OR ii) RSL PDCH Deact ACK (ip.access dyn TS)"];</span><br><span style="color: hsl(120, 100%, 40%);">+       bsc box bsc [label="rsl_chan_activate_lchan() re-invoked"];</span><br><span style="color: hsl(120, 100%, 40%);">+ bts <= bsc [label="RSL Chan Activ"];</span><br><span style="color: hsl(120, 100%, 40%);">+     --- [label="else (no dyn TS switchover)"];</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+        bts <= bsc [label="RSL Chan Activ"];</span><br><span style="color: hsl(120, 100%, 40%);">+     bsc -> bsc_gscon [label="gsm0808_assign_req() returns"];</span><br><span style="color: hsl(120, 100%, 40%);">+ bsc_gscon abox bsc_gscon [label="ST_WAIT_ASS_COMPL (GSM0808_T10_VALUE=6s)"];</span><br><span style="color: hsl(120, 100%, 40%);">+        ---;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+        ...;</span><br><span style="color: hsl(120, 100%, 40%);">+  --- [label="On Timeout"];</span><br><span style="color: hsl(120, 100%, 40%);">+   bsc_gscon => msc_ [label="BSSMAP Assignment Failure"];</span><br><span style="color: hsl(120, 100%, 40%);">+   bsc_gscon abox bsc_gscon [label="ST_ACTIVE"];</span><br><span style="color: hsl(120, 100%, 40%);">+       bsc_gscon note bsc_mgcp [linecolor="red",</span><br><span style="color: hsl(120, 100%, 40%);">+     label="The mgcp FSM from CRCX above apparently lacks a cleanup action for this case.</span><br><span style="color: hsl(120, 100%, 40%);">+            It should be cleaned up eventually when the conn is torn down, but we should</span><br><span style="color: hsl(120, 100%, 40%);">+          release RTP endpoints as soon as possible."];</span><br><span style="color: hsl(120, 100%, 40%);">+   --- [label="end: 'On Timeout'"];</span><br><span style="color: hsl(120, 100%, 40%);">+    ...;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+        bts => bsc [label="RSL Chan Activ ACK"];</span><br><span style="color: hsl(120, 100%, 40%);">+ bsc box bsc [label="bsc_api.c handle_chan_ack()"];</span><br><span style="color: hsl(120, 100%, 40%);">+  ms <= bsc [label="RR Assignment Command"];</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+     ...;</span><br><span style="color: hsl(120, 100%, 40%);">+  ms note bsc_gscon [label="We rely on the overall conn FSM ST_WAIT_ASS_COMPL timeout."];</span><br><span style="color: hsl(120, 100%, 40%);">+     ...;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+        ms => bsc [label="RR Assignment Complete"];</span><br><span style="color: hsl(120, 100%, 40%);">+      bsc box bsc [label="handle_ass_compl()"];</span><br><span style="color: hsl(120, 100%, 40%);">+   --- [label="Release old lchan"];</span><br><span style="color: hsl(120, 100%, 40%);">+    bsc box bsc [label="_lchan_handle_release(sacch_deact=0)"];</span><br><span style="color: hsl(120, 100%, 40%);">+ bsc box bsc [label="rsl_release_sapis_from(start=1)"];</span><br><span style="color: hsl(120, 100%, 40%);">+      bts <= bsc [label="RSL Release Request (Local End)..."];</span><br><span style="color: hsl(120, 100%, 40%);">+ bts <= bsc [label="...for each SAPI except link_id=0"];</span><br><span style="color: hsl(120, 100%, 40%);">+  bsc box bsc [label="rsl_release_request(link_id=0)"];</span><br><span style="color: hsl(120, 100%, 40%);">+       bts <= bsc [label="RSL Release Request (Local End) for link_id=0"];</span><br><span style="color: hsl(120, 100%, 40%);">+      bsc box bsc [label="_lchan_handle_release() returns here, the remaining release is asynchronous;</span><br><span style="color: hsl(120, 100%, 40%);">+                     see `End: 'Release old lchan'` below."];</span><br><span style="color: hsl(120, 100%, 40%);">+     ...;</span><br><span style="color: hsl(120, 100%, 40%);">+  bts note bsc_gscon [linecolor="red",</span><br><span style="color: hsl(120, 100%, 40%);">+          label="There seems to be no timer watching over RSL Release Request!"];</span><br><span style="color: hsl(120, 100%, 40%);">+   ...;</span><br><span style="color: hsl(120, 100%, 40%);">+  bts => bsc [label="RSL Release Confirm..."];</span><br><span style="color: hsl(120, 100%, 40%);">+     bts => bsc [label="...for each SAPI and link_id=0"];</span><br><span style="color: hsl(120, 100%, 40%);">+     bsc abox bsc [label="start T3111"];</span><br><span style="color: hsl(120, 100%, 40%);">+ ...;</span><br><span style="color: hsl(120, 100%, 40%);">+  bsc box bsc [label="T3111 expires"];</span><br><span style="color: hsl(120, 100%, 40%);">+        bsc abox bsc [label="Start lchan->act_timer with lchan_deact_tmr_cb"];</span><br><span style="color: hsl(120, 100%, 40%);">+   bts <= bsc [label="RSL RF Channel Release"];</span><br><span style="color: hsl(120, 100%, 40%);">+     ...;</span><br><span style="color: hsl(120, 100%, 40%);">+  --- [label="On timeout"];</span><br><span style="color: hsl(120, 100%, 40%);">+   bsc box bsc [label="lchan_deact_tmr_cb()"];</span><br><span style="color: hsl(120, 100%, 40%);">+ bsc box bsc [label="rsl_lchan_mark_broken(): state=LCHAN_S_BROKEN"];</span><br><span style="color: hsl(120, 100%, 40%);">+        bsc box bsc [label="lchan_free()"];</span><br><span style="color: hsl(120, 100%, 40%);">+ bsc -> bsc [label="S_LCHAN_UNEXPECTED_RELEASE"];</span><br><span style="color: hsl(120, 100%, 40%);">+ bsc box bsc [label="bsc_api.c handle_release()"];</span><br><span style="color: hsl(120, 100%, 40%);">+   bsc box bsc [label="bsc->assign_fail()"];</span><br><span style="color: hsl(120, 100%, 40%);">+        bsc -> bsc_gscon [label="GSCON_EV_RR_ASS_FAIL"];</span><br><span style="color: hsl(120, 100%, 40%);">+ bsc note bsc_gscon [linecolor="orange",</span><br><span style="color: hsl(120, 100%, 40%);">+       label="The name 'RR_ASS_FAIL' might suggest the event means an actual RR Assignment</span><br><span style="color: hsl(120, 100%, 40%);">+             Failure message being received. Maybe this should be called GSCON_EV_ASSIGNMENT_ERROR."];</span><br><span style="color: hsl(120, 100%, 40%);">+       ...;</span><br><span style="color: hsl(120, 100%, 40%);">+  bsc box bsc [label="bsc->clear_request()"];</span><br><span style="color: hsl(120, 100%, 40%);">+      bsc box bsc [label="bsc_clear_request encodes a BSSMAP Clear Request message and passes it on</span><br><span style="color: hsl(120, 100%, 40%);">+                        to the conn FSM as data argument via:"];</span><br><span style="color: hsl(120, 100%, 40%);">+     bsc -> bsc_gscon [label="GSCON_EV_TX_SCCP"];</span><br><span style="color: hsl(120, 100%, 40%);">+     bsc_gscon => msc_ [label="BSSMAP Clear Request"];</span><br><span style="color: hsl(120, 100%, 40%);">+        bsc note bsc_gscon [linecolor="red",</span><br><span style="color: hsl(120, 100%, 40%);">+          label="Instead of sending an arbitrary message, the conn FSM should</span><br><span style="color: hsl(120, 100%, 40%);">+             be explicitly instructed to clear the connection, to be able</span><br><span style="color: hsl(120, 100%, 40%);">+          to notice if the MSC failed to respond to the Clear Request.</span><br><span style="color: hsl(120, 100%, 40%);">+          Currently, this relies on the MSC responding with a Clear</span><br><span style="color: hsl(120, 100%, 40%);">+             Command, hopefully, some time later."];</span><br><span style="color: hsl(120, 100%, 40%);">+ --- [label="End: 'On timeout'"];</span><br><span style="color: hsl(120, 100%, 40%);">+    ...;</span><br><span style="color: hsl(120, 100%, 40%);">+  bts => bsc [label="RSL RF Channel Release Ack"];</span><br><span style="color: hsl(120, 100%, 40%);">+ --- [label="End: 'Release old lchan'"];</span><br><span style="color: hsl(120, 100%, 40%);">+     bsc box bsc [label="still in handle_ass_compl()"];</span><br><span style="color: hsl(120, 100%, 40%);">+  bsc note bsc [label="officially take over new lchan: conn->lchan = conn->secondary_lchan"];</span><br><span style="color: hsl(120, 100%, 40%);">+   --- [label="is BTS using IPA Abis? (osmo-bts, ip.access)"];</span><br><span style="color: hsl(120, 100%, 40%);">+ bts <= bsc [label="IPACC CRCX"];</span><br><span style="color: hsl(120, 100%, 40%);">+ ---;</span><br><span style="color: hsl(120, 100%, 40%);">+  bsc -> bsc [label="handle_ass_compl() calls bsc_api->assign_compl()"];</span><br><span style="color: hsl(120, 100%, 40%);">+        --- [label="is BTS using IPA Abis? (osmo-bts, ip.access) && conn->user_plane.rtp_ip"];</span><br><span style="color: hsl(120, 100%, 40%);">+   bsc box bsc [label="bsc_assign_compl()"];</span><br><span style="color: hsl(120, 100%, 40%);">+   bsc note bsc [label="set ass_compl.valid = true,</span><br><span style="color: hsl(120, 100%, 40%);">+                     postponing GSCON_EV_RR_ASS_COMPL until after the</span><br><span style="color: hsl(120, 100%, 40%);">+                      IPACC MDCX ACK received in osmo_bsc_audio.c"];</span><br><span style="color: hsl(120, 100%, 40%);">+       bsc box bsc [label="exit early: bsc_assign_compl()"];</span><br><span style="color: hsl(120, 100%, 40%);">+       bsc box bsc [label="exit early: handle_ass_compl()"];</span><br><span style="color: hsl(120, 100%, 40%);">+       bsc box bsc [label="osmo_bsc_audio.c"];</span><br><span style="color: hsl(120, 100%, 40%);">+     bts => bsc [label="IPACC CRCX ACK"];</span><br><span style="color: hsl(120, 100%, 40%);">+     bts <= bsc [label="IPACC MDCX"];</span><br><span style="color: hsl(120, 100%, 40%);">+ bts => bsc [label="IPACC MDCX ACK"];</span><br><span style="color: hsl(120, 100%, 40%);">+     bsc box bsc [label="handle_abisip_signal()"];</span><br><span style="color: hsl(120, 100%, 40%);">+       bsc -> bsc_gscon [label="GSCON_EV_RR_ASS_COMPL"];</span><br><span style="color: hsl(120, 100%, 40%);">+        --- [label="else"];</span><br><span style="color: hsl(120, 100%, 40%);">+ bsc box bsc [label="bsc_assign_compl()"];</span><br><span style="color: hsl(120, 100%, 40%);">+   bsc -> bsc_gscon [label="GSCON_EV_RR_ASS_COMPL"];</span><br><span style="color: hsl(120, 100%, 40%);">+        --- ;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+       --- [label="is chan_mode a speech mode?"];</span><br><span style="color: hsl(120, 100%, 40%);">+  bsc_gscon abox bsc_gscon [label="ST_WAIT_MDCX_BTS"];</span><br><span style="color: hsl(120, 100%, 40%);">+        bsc_gscon -> bsc_mgcp [label="mgcp_conn_modify()"];</span><br><span style="color: hsl(120, 100%, 40%);">+      bsc_mgcp note bsc_mgcp [label="same mgcp FSM as above, for BTS side"];</span><br><span style="color: hsl(120, 100%, 40%);">+      bsc_mgcp => mgw [label="MDCX (for BTS)"];</span><br><span style="color: hsl(120, 100%, 40%);">+        bsc_mgcp <= mgw [label="MDCX OK"];</span><br><span style="color: hsl(120, 100%, 40%);">+       bsc_mgcp -> bsc_gscon [label="GSCON_EV_MGW_MDCX_RESP_BTS"];</span><br><span style="color: hsl(120, 100%, 40%);">+      bsc_gscon abox bsc_gscon [label="ST_WAIT_CRCX_MSC"];</span><br><span style="color: hsl(120, 100%, 40%);">+        bsc_gscon -> bsc_mgcp [label="mgcp_conn_create()"];</span><br><span style="color: hsl(120, 100%, 40%);">+      bsc_mgcp note bsc_mgcp [label="second mgcp FSM for MSC side"];</span><br><span style="color: hsl(120, 100%, 40%);">+      bsc_mgcp => mgw [label="CRCX (for MSC)"];</span><br><span style="color: hsl(120, 100%, 40%);">+        bsc_mgcp <= mgw [label="CRCX OK (for MSC)"];</span><br><span style="color: hsl(120, 100%, 40%);">+     bsc_gscon <- bsc_mgcp [label="GSCON_EV_MGW_CRCX_RESP_MSC"];</span><br><span style="color: hsl(120, 100%, 40%);">+      ---;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+        bsc_gscon => msc_ [label="BSSMAP Assignment Complete"];</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+        bsc_gscon abox bsc_gscon [label="ST_ACTIVE"];</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span>diff --git a/doc/handover.msc b/doc/handover.msc</span><br><span>new file mode 100644</span><br><span>index 0000000..e5e787c</span><br><span>--- /dev/null</span><br><span>+++ b/doc/handover.msc</span><br><span>@@ -0,0 +1,164 @@</span><br><span style="color: hsl(120, 100%, 40%);">+# Handover between cells, intra-BSC</span><br><span style="color: hsl(120, 100%, 40%);">+msc {</span><br><span style="color: hsl(120, 100%, 40%);">+        hscale=3;</span><br><span style="color: hsl(120, 100%, 40%);">+     ms [label="MS"], bts [label="BTS"], bsc[label="BSC"], bsc_gscon[label="BSC conn FSM"], bsc_mgcp[label="BSC mgcp FSM"], mgw[label="MGW"];</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+        ms note mgw [label="intra-BSC Handover sequence"];</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+        bsc_gscon abox bsc_gscon [label="ST_ACTIVE"];</span><br><span style="color: hsl(120, 100%, 40%);">+       bsc box bsc [label="bsc_handover_start(): init conn->ho"];</span><br><span style="color: hsl(120, 100%, 40%);">+       bsc -> bsc_gscon [label="GSCON_EV_HO_START"];</span><br><span style="color: hsl(120, 100%, 40%);">+    bsc <- bsc_gscon [label="bsc_handover_start_gscon()"];</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ bsc box bsc [label="lchan_alloc(): pick available lchan"];</span><br><span style="color: hsl(120, 100%, 40%);">+  bsc box bsc [label="rsl_chan_activate_lchan()"];</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+  --- [label="is the chosen lchan on dynamic timeslot that is currently used as PDCH?"];</span><br><span style="color: hsl(120, 100%, 40%);">+      bts <= bsc [label="i) RSL RF Chan Release of PDCH (Osmocom dyn TS)"];</span><br><span style="color: hsl(120, 100%, 40%);">+    bts <= bsc [label="OR ii) RSL PDCH Deact (ip.access dyn TS)"];</span><br><span style="color: hsl(120, 100%, 40%);">+   bsc -> bsc_gscon [label="bsc_handover_start_gscon() returns early"];</span><br><span style="color: hsl(120, 100%, 40%);">+     bsc_gscon abox bsc_gscon [label="ST_WAIT_HO_COMPL (no timeout, relies on T3103 below)"];</span><br><span style="color: hsl(120, 100%, 40%);">+    ...;</span><br><span style="color: hsl(120, 100%, 40%);">+  bts note bsc_gscon [linecolor="red",</span><br><span style="color: hsl(120, 100%, 40%);">+          label="There seems to be no timer watching over Chan Release nor dyn TS switchover!"];</span><br><span style="color: hsl(120, 100%, 40%);">+    ...;</span><br><span style="color: hsl(120, 100%, 40%);">+  bts => bsc [label="i) RSL RF Chan Release ACK (Osmocom dyn TS)"];</span><br><span style="color: hsl(120, 100%, 40%);">+        bts => bsc [label="OR ii) RSL PDCH Deact ACK (ip.access dyn TS)"];</span><br><span style="color: hsl(120, 100%, 40%);">+       bsc box bsc [label="rsl_chan_activate_lchan() re-invoked"];</span><br><span style="color: hsl(120, 100%, 40%);">+ bts <= bsc [label="RSL Chan Activ"];</span><br><span style="color: hsl(120, 100%, 40%);">+     --- [label="else (no dyn TS switchover)"];</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+        bts <= bsc [label="RSL Chan Activ"];</span><br><span style="color: hsl(120, 100%, 40%);">+     bsc -> bsc_gscon [label="bsc_handover_start_gscon() returns"];</span><br><span style="color: hsl(120, 100%, 40%);">+   ---;</span><br><span style="color: hsl(120, 100%, 40%);">+  bsc_gscon abox bsc_gscon [label="ST_WAIT_HO_COMPL (no timeout, relies on T3103 below)"];</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+  ...;</span><br><span style="color: hsl(120, 100%, 40%);">+  bts note bsc_gscon [linecolor="red",</span><br><span style="color: hsl(120, 100%, 40%);">+          label="There seems to be no timer watching out for RSL Chan Activ ACK/NACK!"];</span><br><span style="color: hsl(120, 100%, 40%);">+    ...;</span><br><span style="color: hsl(120, 100%, 40%);">+  bts => bsc [label="RSL Chan Activ ACK"];</span><br><span style="color: hsl(120, 100%, 40%);">+ bsc -> bsc [label="S_LCHAN_ACTIVATE_ACK"];</span><br><span style="color: hsl(120, 100%, 40%);">+       bsc box bsc [label="handover_logic.c ho_logic_sig_cb()"];</span><br><span style="color: hsl(120, 100%, 40%);">+   bsc box bsc [label="ho_chan_activ_ack()"];</span><br><span style="color: hsl(120, 100%, 40%);">+  bsc note bsc [label="gsm48_send_ho_cmd()"];</span><br><span style="color: hsl(120, 100%, 40%);">+ ms <= bsc [label="RR Handover Command"];</span><br><span style="color: hsl(120, 100%, 40%);">+ bsc abox bsc [label="start T3103"];</span><br><span style="color: hsl(120, 100%, 40%);">+ --- [label="is BTS using IPA Abis? (osmo-bts, ip.access)"];</span><br><span style="color: hsl(120, 100%, 40%);">+ bts <= bsc [label="IPACC CRCX"];</span><br><span style="color: hsl(120, 100%, 40%);">+ bsc -> bsc [label="ho_chan_activ_ack() returns"];</span><br><span style="color: hsl(120, 100%, 40%);">+        bts note bsc [linecolor="red",</span><br><span style="color: hsl(120, 100%, 40%);">+        label="There seems to be no timer watching over IPACC CRCX ACK/NACK!</span><br><span style="color: hsl(120, 100%, 40%);">+            If no response is received, we simply ignore that fact and carry on as if</span><br><span style="color: hsl(120, 100%, 40%);">+             everything was fine."];</span><br><span style="color: hsl(120, 100%, 40%);">+ ...;</span><br><span style="color: hsl(120, 100%, 40%);">+  bts note bsc [label="The IPACC CRCX and MDCX ACKs may come back at any time:</span><br><span style="color: hsl(120, 100%, 40%);">+                          before or after the Handover Detect, before or after Handover Complete."];</span><br><span style="color: hsl(120, 100%, 40%);">+  bts note bsc_mgcp [linecolor="red",</span><br><span style="color: hsl(120, 100%, 40%);">+   label="The CRCX ACK contains vital information for routing the RTP stream.</span><br><span style="color: hsl(120, 100%, 40%);">+              If the CRCX ACK were very slow, we would not know which RTP/RTPC ports</span><br><span style="color: hsl(120, 100%, 40%);">+                to point the MGW at, below at mgcp_conn_modify()!</span><br><span style="color: hsl(120, 100%, 40%);">+             Even though this being unrealistic, we must make sure to receive a CRCX ACK."];</span><br><span style="color: hsl(120, 100%, 40%);">+ ...;</span><br><span style="color: hsl(120, 100%, 40%);">+  bsc box bsc [label="osmo_bsc_audio.c"];</span><br><span style="color: hsl(120, 100%, 40%);">+     bts => bsc [label="IPACC CRCX ACK"];</span><br><span style="color: hsl(120, 100%, 40%);">+     bts <= bsc [label="IPACC MDCX"];</span><br><span style="color: hsl(120, 100%, 40%);">+ ...;</span><br><span style="color: hsl(120, 100%, 40%);">+  bts note bsc [linecolor="red",</span><br><span style="color: hsl(120, 100%, 40%);">+        label="There seems to be no timer watching over IPACC MDCX ACK/NACK!</span><br><span style="color: hsl(120, 100%, 40%);">+            If no response is received, we simply ignore that fact and carry on as if</span><br><span style="color: hsl(120, 100%, 40%);">+             everything was fine."];</span><br><span style="color: hsl(120, 100%, 40%);">+ ...;</span><br><span style="color: hsl(120, 100%, 40%);">+  bts => bsc [label="IPACC MDCX ACK"];</span><br><span style="color: hsl(120, 100%, 40%);">+     bts note bsc [label="IPACC MDCX ACK triggers no events or actions"];</span><br><span style="color: hsl(120, 100%, 40%);">+        ---;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+        ...;</span><br><span style="color: hsl(120, 100%, 40%);">+  ms => bsc [label="RR Handover Detect"];</span><br><span style="color: hsl(120, 100%, 40%);">+  bsc -> bsc [label="S_LCHAN_HANDOVER_DETECT"];</span><br><span style="color: hsl(120, 100%, 40%);">+    bsc box bsc [label="ho_rsl_detect(): no action, only logging"];</span><br><span style="color: hsl(120, 100%, 40%);">+     bsc note bsc_gscon [label="Handover Detect triggers no events or actions"];</span><br><span style="color: hsl(120, 100%, 40%);">+ bsc note bsc_gscon [linecolor="red",</span><br><span style="color: hsl(120, 100%, 40%);">+          label="upon Handover Detect, we should already start re-routing the RTP!</span><br><span style="color: hsl(120, 100%, 40%);">+                Instead we wait for Handover Complete."];</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+     ...;</span><br><span style="color: hsl(120, 100%, 40%);">+  ms => bsc [label="RR Handover Complete"];</span><br><span style="color: hsl(120, 100%, 40%);">+        bsc -> bsc [label="S_LCHAN_HANDOVER_COMPL"];</span><br><span style="color: hsl(120, 100%, 40%);">+     bsc box bsc [label="handover_logic.c ho_logic_sig_cb()"];</span><br><span style="color: hsl(120, 100%, 40%);">+   bsc box bsc [label="ho_gsm48_ho_compl()"];</span><br><span style="color: hsl(120, 100%, 40%);">+  bsc box bsc [label="stop T3103"];</span><br><span style="color: hsl(120, 100%, 40%);">+   bts note bsc_gscon [label="If anything goes wrong from this point on, we will not move back</span><br><span style="color: hsl(120, 100%, 40%);">+                                 to the old lchan: would be pointless after Handover Complete."];</span><br><span style="color: hsl(120, 100%, 40%);">+      bsc note bsc [label="officially take over new lchan: conn->lchan = ho->new_lchan"];</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ --- [label="Release old lchan"];</span><br><span style="color: hsl(120, 100%, 40%);">+    bsc box bsc [label="_lchan_handle_release(sacch_deact=0)"];</span><br><span style="color: hsl(120, 100%, 40%);">+ bsc box bsc [label="rsl_release_sapis_from(start=1)"];</span><br><span style="color: hsl(120, 100%, 40%);">+      bts <= bsc [label="RSL Release Request (Local End)..."];</span><br><span style="color: hsl(120, 100%, 40%);">+ bts <= bsc [label="...for each SAPI except link_id=0"];</span><br><span style="color: hsl(120, 100%, 40%);">+  bsc box bsc [label="rsl_release_request(link_id=0)"];</span><br><span style="color: hsl(120, 100%, 40%);">+       bts <= bsc [label="RSL Release Request (Local End) for link_id=0"];</span><br><span style="color: hsl(120, 100%, 40%);">+      bsc box bsc [label="_lchan_handle_release() returns here, the remaining release is asynchronous;</span><br><span style="color: hsl(120, 100%, 40%);">+                     see `End: 'Release old lchan'` below."];</span><br><span style="color: hsl(120, 100%, 40%);">+     ...;</span><br><span style="color: hsl(120, 100%, 40%);">+  bts note bsc_gscon [linecolor="red",</span><br><span style="color: hsl(120, 100%, 40%);">+          label="There seems to be no timer watching over RSL Release Request!"];</span><br><span style="color: hsl(120, 100%, 40%);">+   ...;</span><br><span style="color: hsl(120, 100%, 40%);">+  bts => bsc [label="RSL Release Confirm..."];</span><br><span style="color: hsl(120, 100%, 40%);">+     bts => bsc [label="...for each SAPI and link_id=0"];</span><br><span style="color: hsl(120, 100%, 40%);">+     bsc abox bsc [label="start T3111"];</span><br><span style="color: hsl(120, 100%, 40%);">+ ...;</span><br><span style="color: hsl(120, 100%, 40%);">+  bsc box bsc [label="T3111 expires"];</span><br><span style="color: hsl(120, 100%, 40%);">+        bsc abox bsc [label="Start lchan->act_timer with lchan_deact_tmr_cb"];</span><br><span style="color: hsl(120, 100%, 40%);">+   bts <= bsc [label="RSL RF Channel Release"];</span><br><span style="color: hsl(120, 100%, 40%);">+     ...;</span><br><span style="color: hsl(120, 100%, 40%);">+  --- [label="On timeout"];</span><br><span style="color: hsl(120, 100%, 40%);">+   bsc box bsc [label="lchan_deact_tmr_cb()"];</span><br><span style="color: hsl(120, 100%, 40%);">+ bsc box bsc [label="rsl_lchan_mark_broken(): state=LCHAN_S_BROKEN"];</span><br><span style="color: hsl(120, 100%, 40%);">+        bsc box bsc [label="lchan_free()"];</span><br><span style="color: hsl(120, 100%, 40%);">+ bsc -> bsc [label="S_LCHAN_UNEXPECTED_RELEASE"];</span><br><span style="color: hsl(120, 100%, 40%);">+ bsc box bsc [label="bsc_api.c handle_release()"];</span><br><span style="color: hsl(120, 100%, 40%);">+   bsc box bsc [label="bsc->clear_request()"];</span><br><span style="color: hsl(120, 100%, 40%);">+      bsc box bsc [label="bsc_clear_request encodes a BSSMAP Clear Request message and passes it on</span><br><span style="color: hsl(120, 100%, 40%);">+                        to the conn FSM as data argument via:"];</span><br><span style="color: hsl(120, 100%, 40%);">+     bsc -> bsc_gscon [label="GSCON_EV_TX_SCCP"];</span><br><span style="color: hsl(120, 100%, 40%);">+     bsc_gscon rbox bsc_gscon [label="BSSMAP Clear Request to MSC"];</span><br><span style="color: hsl(120, 100%, 40%);">+     bsc note bsc_gscon [linecolor="red",</span><br><span style="color: hsl(120, 100%, 40%);">+          label="During Handover, we actually release the entire conn just because we failed to</span><br><span style="color: hsl(120, 100%, 40%);">+           gracefully release the old lchan. That is obviously nonsense."];</span><br><span style="color: hsl(120, 100%, 40%);">+        bsc note bsc [label="Stop T3101 (but was not active in this code path)"];</span><br><span style="color: hsl(120, 100%, 40%);">+   bsc -> bsc [label="S_CHALLOC_FREED"];</span><br><span style="color: hsl(120, 100%, 40%);">+    --- [label="End: 'On timeout'"];</span><br><span style="color: hsl(120, 100%, 40%);">+    ...;</span><br><span style="color: hsl(120, 100%, 40%);">+  bts => bsc [label="RSL RF Channel Release Ack"];</span><br><span style="color: hsl(120, 100%, 40%);">+ ---;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+        bsc box bsc [label="still in ho_gsm48_ho_compl()"];</span><br><span style="color: hsl(120, 100%, 40%);">+ bsc note bsc [label="handover_free(), conn->ho = NULL"];</span><br><span style="color: hsl(120, 100%, 40%);">+ bsc -> bsc_gscon [label="GSCON_EV_HO_COMPL"];</span><br><span style="color: hsl(120, 100%, 40%);">+    bsc note bsc_gscon [linecolor="orange",</span><br><span style="color: hsl(120, 100%, 40%);">+       label="Handover information is cleared before signalling the conn FSM.</span><br><span style="color: hsl(120, 100%, 40%);">+          That means the conn FSM cannot possibly log sensible information about exactly</span><br><span style="color: hsl(120, 100%, 40%);">+                which Handover has just completed."];</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ bsc_gscon abox bsc_gscon [label="ST_WAIT_MDCX_BTS_HO</span><br><span style="color: hsl(120, 100%, 40%);">+                                      (MGCP_MGW_TIMEOUT=4s with MGCP_MGW_HO_TIMEOUT_TIMER_NR)"];</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+    bsc_gscon -> bsc_mgcp [label="mgcp_conn_modify()"];</span><br><span style="color: hsl(120, 100%, 40%);">+      bsc_mgcp note bsc_mgcp [label="mgcp FSM that was established for old lchan, for BTS side"];</span><br><span style="color: hsl(120, 100%, 40%);">+ bsc_mgcp => mgw [label="MDCX (for BTS)"];</span><br><span style="color: hsl(120, 100%, 40%);">+        ...;</span><br><span style="color: hsl(120, 100%, 40%);">+  bsc_gscon note mgw [</span><br><span style="color: hsl(120, 100%, 40%);">+    label="If we get no MDCX ACK, the MGCP FSM terminates, and emits GSCON_EV_MGW_FAIL_BTS.</span><br><span style="color: hsl(120, 100%, 40%);">+                 Besides invalidating the MGCP FSM pointer, this event has no</span><br><span style="color: hsl(120, 100%, 40%);">+          effect in ST_WAIT_MDCX_BTS_HO, and we rely on above conn FSM</span><br><span style="color: hsl(120, 100%, 40%);">+          timeout instead."];</span><br><span style="color: hsl(120, 100%, 40%);">+     bsc_gscon note bsc_gscon [linecolor="red",</span><br><span style="color: hsl(120, 100%, 40%);">+    label="A timeout of ST_WAIT_MDCX_BTS_HO simply transitions back to ST_ACTIVE!</span><br><span style="color: hsl(120, 100%, 40%);">+           Even though the MGW failed, we carry on as if everything were fine."];</span><br><span style="color: hsl(120, 100%, 40%);">+  ...;</span><br><span style="color: hsl(120, 100%, 40%);">+  bsc_mgcp <= mgw [label="MDCX OK"];</span><br><span style="color: hsl(120, 100%, 40%);">+       bsc_mgcp -> bsc_gscon [label="GSCON_EV_MGW_MDCX_RESP_BTS"];</span><br><span style="color: hsl(120, 100%, 40%);">+      bsc_gscon abox bsc_gscon [label="ST_ACTIVE"];</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/9350">change 9350</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/9350"/><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: merged </div>
<div style="display:none"> Gerrit-Change-Id: I20999e938441d4fed2d37462b262b74a696f616d </div>
<div style="display:none"> Gerrit-Change-Number: 9350 </div>
<div style="display:none"> Gerrit-PatchSet: 3 </div>
<div style="display:none"> Gerrit-Owner: Neels Hofmeyr <nhofmeyr@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: Harald Welte <laforge@gnumonks.org> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins Builder </div>
<div style="display:none"> Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr@sysmocom.de> </div>