Change in osmo-bsc[master]: RR Channel Release: pass Cause code from BSSMAP Clear to the BTS

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

neels gerrit-no-reply at lists.osmocom.org
Sat Jul 11 01:52:36 UTC 2020


neels has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-bsc/+/19214 )


Change subject: RR Channel Release: pass Cause code from BSSMAP Clear to the BTS
......................................................................

RR Channel Release: pass Cause code from BSSMAP Clear to the BTS

In lchan.release, add 'cause_rr', and set RR Channel Release message's cause
value to lchan.release.cause_rr.

In lchan_release(), do not set lchan.release.rsl_error_cause to the RR cause
value, these are unrelated. Store in new lchan.release.cause_rr instead. The
rsl_error_cause is apparently only used for logging, except for one place in
lchan_fsm_wait_activ_ack() that compares it to RSL_ERR_RCH_ALR_ACTV_ALLOC, so
there should not be a functional difference by this fix.

Propagate the BSSMAP Clear Command cause to the RR Channel Release:

Add struct gscon_clear_cmd_data as event data for GSCON_EV_A_CLEAR_CMD -- so
far it sent the is_csfb flag, add the gsm0808_cause; invoking the event happens
in bssmap_handle_clear_cmd().

Adjust event handling in gscon_fsm_allstate(); there, pass the cause to
gscon_release_lchans(). In gscon_release_lchans(), pass the cause to
gscon_release_lchan(), and then lchan_release(), which sets the new
lchan.release.cause_rr to the passed cause value.

As soon as the lchan FSM enters the proper state, it calls
gsm48_send_rr_release(). There, set the cause value in the encoded message to
lchan.release.cause_rr.

Interworking with osmo-msc: so far, osmo-msc fails to set the Clear Command
cause code for normal release, it just passes 0 which amounts to
GSM0808_CAUSE_RADIO_INTERFACE_MESSAGE_FAILURE. Before this patch, osmo-bsc
always sent GSM48_RR_CAUSE_NORMAL in the RR Channel Release, and after this
patch it will receive 0 == GSM0808_CAUSE_RADIO_INTERFACE_MESSAGE_FAILURE from
osmo-msc and more accurately translate that to GSM48_RR_CAUSE_PROT_ERROR_UNSPC.
This means in practice that we will now see an error cause in RR Channel
Release instead of GSM48_RR_CAUSE_NORMAL when working with osmo-msc. For
changing osmo-msc to send GSM0808_CAUSE_CALL_CONTROL instead (which translates
to GSM48_RR_CAUSE_NORMAL), see OS#4664 and change-id
I1347ed72ae7d7ea73a557b866e764819c5ef8c42 (osmo-msc).

A test for this is in Ie6c99f28b610a67f2d59ec00b3541940e882251b
(osmo-ttcn3-hacks).

Related: SYS#4872
Change-Id: I734cc55c501d61bbdadee81a223b26f9df57f959
---
M include/osmocom/bsc/bsc_subscr_conn_fsm.h
M include/osmocom/bsc/gsm_data.h
M src/osmo-bsc/bsc_subscr_conn_fsm.c
M src/osmo-bsc/gsm_04_08_rr.c
M src/osmo-bsc/gsm_data.c
M src/osmo-bsc/lchan_fsm.c
M src/osmo-bsc/osmo_bsc_bssap.c
7 files changed, 65 insertions(+), 13 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/14/19214/1

diff --git a/include/osmocom/bsc/bsc_subscr_conn_fsm.h b/include/osmocom/bsc/bsc_subscr_conn_fsm.h
index 5475272..1a827d9 100644
--- a/include/osmocom/bsc/bsc_subscr_conn_fsm.h
+++ b/include/osmocom/bsc/bsc_subscr_conn_fsm.h
@@ -1,4 +1,6 @@
 #pragma once
+#include <osmocom/gsm/protocol/gsm_08_08.h>
+#include <osmocom/gsm/protocol/gsm_04_08.h>
 #include <osmocom/core/fsm.h>
 
 enum gscon_fsm_event {
@@ -40,6 +42,11 @@
 	GSCON_EV_FORGET_MGW_ENDPOINT,
 };
 
+struct gscon_clear_cmd_data {
+	enum gsm0808_cause cause_0808;
+	bool is_csfb;
+};
+
 struct gsm_subscriber_connection;
 struct gsm_network;
 struct msgb;
@@ -71,7 +78,7 @@
 			    struct assignment_request *req);
 
 void gscon_change_primary_lchan(struct gsm_subscriber_connection *conn, struct gsm_lchan *new_lchan);
-void gscon_release_lchans(struct gsm_subscriber_connection *conn, bool do_rr_release);
+void gscon_release_lchans(struct gsm_subscriber_connection *conn, bool do_rr_release, enum gsm48_rr_cause cause_rr);
 
 void gscon_lchan_releasing(struct gsm_subscriber_connection *conn, struct gsm_lchan *lchan);
 void gscon_forget_lchan(struct gsm_subscriber_connection *conn, struct gsm_lchan *lchan);
diff --git a/include/osmocom/bsc/gsm_data.h b/include/osmocom/bsc/gsm_data.h
index 0f5fc54..a2e4e2f 100644
--- a/include/osmocom/bsc/gsm_data.h
+++ b/include/osmocom/bsc/gsm_data.h
@@ -572,6 +572,7 @@
 		 * flag, so that the lchan will gracefully release at the next sensible junction. */
 		bool requested;
 		bool do_rr_release;
+		enum gsm48_rr_cause rr_cause;
 
 		/* There is an RSL error cause of value 0, so we need a separate flag. */
 		bool in_error;
@@ -1897,4 +1898,6 @@
 
 bool trx_has_valid_pchan_config(const struct gsm_bts_trx *trx);
 
+enum gsm48_rr_cause bsc_gsm48_rr_cause_from_gsm0808_cause(enum gsm0808_cause c);
+
 #endif /* _GSM_DATA_H */
diff --git a/src/osmo-bsc/bsc_subscr_conn_fsm.c b/src/osmo-bsc/bsc_subscr_conn_fsm.c
index 1d30246..0ed6715 100644
--- a/src/osmo-bsc/bsc_subscr_conn_fsm.c
+++ b/src/osmo-bsc/bsc_subscr_conn_fsm.c
@@ -182,14 +182,14 @@
 	lchan_release(lchan, do_rr_release, err, cause_rr);
 }
 
-void gscon_release_lchans(struct gsm_subscriber_connection *conn, bool do_rr_release)
+void gscon_release_lchans(struct gsm_subscriber_connection *conn, bool do_rr_release, enum gsm48_rr_cause cause_rr)
 {
 	if (conn->ho.fi)
 		handover_end(conn, HO_RESULT_CONN_RELEASE);
 
 	assignment_reset(conn);
 
-	gscon_release_lchan(conn, conn->lchan, do_rr_release, false, 0);
+	gscon_release_lchan(conn, conn->lchan, do_rr_release, false, cause_rr);
 }
 
 static void handle_bssap_n_connect(struct osmo_fsm_inst *fi, struct osmo_scu_prim *scu_prim)
@@ -746,17 +746,20 @@
 static void gscon_fsm_allstate(struct osmo_fsm_inst *fi, uint32_t event, void *data)
 {
 	struct gsm_subscriber_connection *conn = fi->priv;
+	const struct gscon_clear_cmd_data *ccd;
 
 	/* Regular allstate event processing */
 	switch (event) {
 	case GSCON_EV_A_CLEAR_CMD:
+		OSMO_ASSERT(data);
+		ccd = data;
 		if (conn->lchan)
-			conn->lchan->release.is_csfb = *(bool *)data;
+			conn->lchan->release.is_csfb = ccd->is_csfb;
 		/* MSC tells us to cleanly shut down */
 		if (conn->fi->state != ST_CLEARING)
 			osmo_fsm_inst_state_chg(fi, ST_CLEARING, 60, 999);
 		LOGPFSML(fi, LOGL_DEBUG, "Releasing all lchans (if any) after BSSMAP Clear Command\n");
-		gscon_release_lchans(conn, true);
+		gscon_release_lchans(conn, true, bsc_gsm48_rr_cause_from_gsm0808_cause(ccd->cause_0808));
 		/* FIXME: Release all terestrial resources in ST_CLEARING */
 		/* According to 3GPP 48.008 3.1.9.1. "The BSS need not wait for the radio channel
 		 * release to be completed or for the guard timer to expire before returning the
@@ -833,7 +836,9 @@
 	}
 
 	LOGPFSML(fi, LOGL_DEBUG, "Releasing all lchans (if any) because this conn is terminating\n");
-	gscon_release_lchans(conn, true);
+	/* when things go smoothly, the lchan should have been released before FSM instance termination. So if this is
+	 * necessary it's probably "abnormal". */
+	gscon_release_lchans(conn, true, GSM48_RR_CAUSE_ABNORMAL_UNSPEC);
 
 	/* drop pending messages */
 	gscon_dtap_queue_flush(conn, 0);
diff --git a/src/osmo-bsc/gsm_04_08_rr.c b/src/osmo-bsc/gsm_04_08_rr.c
index b5a4284..212ced0 100644
--- a/src/osmo-bsc/gsm_04_08_rr.c
+++ b/src/osmo-bsc/gsm_04_08_rr.c
@@ -302,7 +302,7 @@
 	gh->msg_type = GSM48_MT_RR_CHAN_REL;
 
 	cause = msgb_put(msg, 1);
-	cause[0] = GSM48_RR_CAUSE_NORMAL;
+	cause[0] = lchan->release.rr_cause;
 
 	if (lchan->release.is_csfb) {
 		uint8_t buf[CELL_SEL_IND_AFTER_REL_MAX_BYTES];
diff --git a/src/osmo-bsc/gsm_data.c b/src/osmo-bsc/gsm_data.c
index f790b90..860e236 100644
--- a/src/osmo-bsc/gsm_data.c
+++ b/src/osmo-bsc/gsm_data.c
@@ -1840,3 +1840,30 @@
 
 	return result;
 }
+
+/* This may be specific to RR Channel Release, and the mappings were chosen by pure naive guessing without a proper
+ * specification available. */
+enum gsm48_rr_cause bsc_gsm48_rr_cause_from_gsm0808_cause(enum gsm0808_cause c)
+{
+	switch (c) {
+	case GSM0808_CAUSE_PREEMPTION:
+		return GSM48_RR_CAUSE_PREMPTIVE_REL;
+	case GSM0808_CAUSE_RADIO_INTERFACE_MESSAGE_FAILURE:
+	case GSM0808_CAUSE_INVALID_MESSAGE_CONTENTS:
+	case GSM0808_CAUSE_INFORMATION_ELEMENT_OR_FIELD_MISSING:
+	case GSM0808_CAUSE_INCORRECT_VALUE:
+	case GSM0808_CAUSE_UNKNOWN_MESSAGE_TYPE:
+	case GSM0808_CAUSE_UNKNOWN_INFORMATION_ELEMENT:
+		return GSM48_RR_CAUSE_PROT_ERROR_UNSPC;
+	case GSM0808_CAUSE_CALL_CONTROL:
+	case GSM0808_CAUSE_HANDOVER_SUCCESSFUL:
+	case GSM0808_CAUSE_BETTER_CELL:
+	case GSM0808_CAUSE_DIRECTED_RETRY:
+	case GSM0808_CAUSE_REDUCE_LOAD_IN_SERVING_CELL:
+	case GSM0808_CAUSE_RELOCATION_TRIGGERED:
+	case GSM0808_CAUSE_ALT_CHAN_CONFIG_REQUESTED:
+		return GSM48_RR_CAUSE_NORMAL;
+	default:
+		return GSM48_RR_CAUSE_ABNORMAL_UNSPEC;
+	}
+}
diff --git a/src/osmo-bsc/lchan_fsm.c b/src/osmo-bsc/lchan_fsm.c
index a1bf857..fbda1ac 100644
--- a/src/osmo-bsc/lchan_fsm.c
+++ b/src/osmo-bsc/lchan_fsm.c
@@ -402,6 +402,8 @@
 		.meas_rep_last_seen_nr = 255,
 
 		.last_error = lchan->last_error,
+
+		.release.rr_cause = GSM48_RR_CAUSE_NORMAL,
 	};
 }
 
@@ -1369,8 +1371,8 @@
 	struct osmo_fsm_inst *fi = lchan->fi;
 
 	lchan->release.in_error = err;
-	lchan->release.rsl_error_cause = cause_rr;
 	lchan->release.do_rr_release = do_rr_release;
+	lchan->release.rr_cause = cause_rr;
 
 	/* States waiting for events will notice the desire to release when done waiting, so it is enough
 	 * to mark for release. */
diff --git a/src/osmo-bsc/osmo_bsc_bssap.c b/src/osmo-bsc/osmo_bsc_bssap.c
index 2deb7f4..1cacfe9 100644
--- a/src/osmo-bsc/osmo_bsc_bssap.c
+++ b/src/osmo-bsc/osmo_bsc_bssap.c
@@ -453,15 +453,23 @@
 				   struct msgb *msg, unsigned int length)
 {
 	struct tlv_parsed tp;
-	bool is_csfb = false;
+	struct gscon_clear_cmd_data ccd = {
+		.is_csfb = false,
+	};
 
 	tlv_parse(&tp, gsm0808_att_tlvdef(), msg->l4h + 1, length - 1, 0, 0);
 
-	/* FIXME: Check for mandatory cause IE, and use that in RR RELEASE cause! */
-	if (TLVP_PRESENT(&tp, GSM0808_IE_CSFB_INDICATION))
-		is_csfb = true;
+	ccd.cause_0808 = gsm0808_get_cause(&tp);
+	if (ccd.cause_0808 < 0) {
+		LOGPFSML(conn->fi, LOGL_ERROR, "Clear Command: Mandatory Cause IE not present.\n");
+		/* Clear anyway, but without a proper cause. */
+		ccd.cause_0808 = GSM0808_CAUSE_RADIO_INTERFACE_MESSAGE_FAILURE;
+	}
 
-	osmo_fsm_inst_dispatch(conn->fi, GSCON_EV_A_CLEAR_CMD, &is_csfb);
+	if (TLVP_PRESENT(&tp, GSM0808_IE_CSFB_INDICATION))
+		ccd.is_csfb = true;
+
+	osmo_fsm_inst_dispatch(conn->fi, GSCON_EV_A_CLEAR_CMD, &ccd);
 
 	return 0;
 }

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-bsc/+/19214
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: I734cc55c501d61bbdadee81a223b26f9df57f959
Gerrit-Change-Number: 19214
Gerrit-PatchSet: 1
Gerrit-Owner: neels <nhofmeyr at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200711/76aacfba/attachment.htm>


More information about the gerrit-log mailing list