Change in osmo-bsc[master]: fix TSC / TSC Set used for Handover

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 Oct 2 11:12:15 UTC 2021


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


Change subject: fix TSC / TSC Set used for Handover
......................................................................

fix TSC / TSC Set used for Handover

>From the nature of the lchan_activate_info.tsc_set and .tsc, it is easy
to forget to set tsc_set,tsc = -1 to use default TSC Set and TSC values.
Handover code is one such instance that forgets to set -1.

Change the semantics of tsc_set and tsc so that this kind of error can
not happen again as easily: use a separate bool to flag whether to use
the default config or explicit values.

Implicitly fix the lchan_activate_infos "launched" in handover_fsm.c as
well as abis_rsl_chan_rqd_queue_poll().

Related: OS#5244 SYS#4895
Related: I1ed6f068c85b01e5a2d7b5f2651498a1521f89af (osmo-ttcn3-hacks)
Change-Id: Iae20df4387c3d75752301bd5daeeea7508966393
---
M include/osmocom/bsc/gsm_data.h
M src/osmo-bsc/abis_rsl.c
M src/osmo-bsc/assignment_fsm.c
M src/osmo-bsc/bsc_vty.c
M src/osmo-bsc/lchan_fsm.c
M src/osmo-bsc/osmo_bsc_bssap.c
6 files changed, 68 insertions(+), 44 deletions(-)



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

diff --git a/include/osmocom/bsc/gsm_data.h b/include/osmocom/bsc/gsm_data.h
index 03f210f..4c7f348 100644
--- a/include/osmocom/bsc/gsm_data.h
+++ b/include/osmocom/bsc/gsm_data.h
@@ -138,6 +138,14 @@
 static inline const char *assign_for_name(enum assign_for assign_for)
 { return get_value_string(assign_for_names, assign_for); }
 
+/* If .use is false, use the default value defined elsewhere. If true, use .val below.
+ * (A practical benefit of this is that the default initialization sets .use to false, so that even if a .val == 0 is a
+ * valid value, a struct containing this as member does not need to explicitly set .val = INVALID_VAL_CONSTANT.) */
+struct optional_val {
+	bool use;
+	int val;
+};
+
 /* Information retrieved during an Assignment Request from the MSC. This is storage of the Assignment instructions
  * parsed from the Assignment Request message, to pass on until the gscon and assignment FSMs have decided whether an
  * Assignment is actually going to be carried out. Should remain unchanged after initial decoding. */
@@ -165,12 +173,12 @@
 	 * target_lchan to it. */
 	struct gsm_lchan *target_lchan;
 
-	/* TSC Set to use, or -1 for automatically determining the TSC Set to use. Valid range is 1 to 4, as described
-	 * in 3GPP TS 45.002. */
-	int tsc_set;
-	/* TSC to use, or -1 for automatically determining the TSC to use. Valid range is 0 to 7, as described in 3GPP
-	 * TS 45.002. */
-	int tsc;
+	/* The TSC Set to use if 'use' is true, otherwise automatically determine the TSC Set value to use. Valid range
+	 * is 1 to 4, as described in 3GPP TS 45.002. */
+	struct optional_val tsc_set;
+	/* The TSC to use if 'use' is true, otherwise automatically determine the TSC value to use. Valid range is 0 to
+	 * 7, as described in 3GPP TS 45.002. */
+	struct optional_val tsc;
 };
 
 /* State of an ongoing Assignment, while the assignment_fsm is still busy. This serves as state separation to keep the
@@ -621,12 +629,12 @@
 	bool ta_known;
 	uint8_t ta;
 
-	/* TSC Set to use, or -1 for automatically determining the TSC Set to use. Valid range is 1 to 4, as described
-	 * in 3GPP TS 45.002. */
-	int tsc_set;
-	/* TSC to use, or -1 for automatically determining the TSC to use. Valid range is 0 to 7, as described in 3GPP
-	 * TS 45.002. */
-	int tsc;
+	/* The TSC Set to use if 'use' is true, otherwise automatically determine the TSC Set value to use. Valid range
+	 * is 1 to 4, as described in 3GPP TS 45.002. */
+	struct optional_val tsc_set;
+	/* The TSC to use if 'use' is true, otherwise automatically determine the TSC value to use. Valid range is 0 to
+	 * 7, as described in 3GPP TS 45.002. */
+	struct optional_val tsc;
 
 	bool vamos;
 
@@ -652,12 +660,12 @@
 	bool requires_voice_stream;
 	uint16_t msc_assigned_cic;
 
-	/* TSC Set to use, or -1 for automatically determining the TSC Set to use. Valid range is 1 to 4, as described
-	 * in 3GPP TS 45.002. */
-	int tsc_set;
-	/* TSC to use, or -1 for automatically determining the TSC to use. Valid range is 0 to 7, as described in 3GPP
-	 * TS 45.002. */
-	int tsc;
+	/* The TSC Set to use if 'use' is true, otherwise automatically determine the TSC Set value to use. Valid range
+	 * is 1 to 4, as described in 3GPP TS 45.002. */
+	struct optional_val tsc_set;
+	/* The TSC to use if 'use' is true, otherwise automatically determine the TSC value to use. Valid range is 0 to
+	 * 7, as described in 3GPP TS 45.002. */
+	struct optional_val tsc;
 
 	bool vamos;
 };
@@ -695,7 +703,9 @@
 		 * occur later, e.g. during release, that we don't send a NACK out of context. */
 		bool concluded;
 		enum gsm0808_cause gsm0808_error_cause;
+		/* Actually used TSC Set. */
 		int tsc_set;
+		/* Actually used TSC. */
 		uint8_t tsc;
 	} activate;
 
@@ -709,7 +719,9 @@
 
 		struct channel_mode_and_rate ch_mode_rate;
 		struct gsm48_multi_rate_conf mr_conf_filtered;
+		/* Actually used TSC Set. */
 		int tsc_set;
+		/* Actually used TSC. */
 		uint8_t tsc;
 		bool concluded;
 	} modify;
diff --git a/src/osmo-bsc/abis_rsl.c b/src/osmo-bsc/abis_rsl.c
index fb8e386..9882252 100644
--- a/src/osmo-bsc/abis_rsl.c
+++ b/src/osmo-bsc/abis_rsl.c
@@ -2087,8 +2087,6 @@
 		},
 		.ta = rqd->ta,
 		.ta_known = true,
-		.tsc_set = -1,
-		.tsc = -1,
 		.imm_ass_time = bts->imm_ass_time,
 	};
 
diff --git a/src/osmo-bsc/assignment_fsm.c b/src/osmo-bsc/assignment_fsm.c
index 97eb335..5a54928 100644
--- a/src/osmo-bsc/assignment_fsm.c
+++ b/src/osmo-bsc/assignment_fsm.c
@@ -452,8 +452,14 @@
 		.n_ch_mode_rate = 1,
 		.ch_mode_rate_list = { lchan->current_ch_mode_rate },
 		.target_lchan = to_lchan,
-		.tsc_set = tsc_set,
-		.tsc = tsc,
+		.tsc_set = {
+			.use = (tsc_set >= 0),
+			.val = tsc_set,
+		},
+		.tsc = {
+			.use = (tsc >= 0),
+			.val = tsc,
+		},
 	};
 
 	if (to_lchan)
@@ -822,8 +828,14 @@
 		.requires_voice_stream = conn->assignment.requires_voice_stream,
 		.msc_assigned_cic = req->msc_assigned_cic,
 		/* keep previous training sequence code */
-		.tsc_set = lchan->tsc_set,
-		.tsc = lchan->tsc,
+		.tsc_set = {
+			.use = true,
+			.val = lchan->tsc_set,
+		},
+		.tsc = {
+			.use = true,
+			.val = lchan->tsc,
+		},
 	};
 	lchan_mode_modify(lchan, &modif_info);
 }
diff --git a/src/osmo-bsc/bsc_vty.c b/src/osmo-bsc/bsc_vty.c
index 5ccd784..572434d 100644
--- a/src/osmo-bsc/bsc_vty.c
+++ b/src/osmo-bsc/bsc_vty.c
@@ -849,6 +849,7 @@
 	return CMD_WARNING;
 }
 
+/* tsc_set and tsc: -1 to automatically determine which TSC Set / which TSC to use. */
 static int trigger_vamos_mode_modify(struct vty *vty, struct gsm_lchan *lchan, bool vamos, int tsc_set, int tsc)
 {
 	struct lchan_modify_info info = {
@@ -856,8 +857,14 @@
 		.ch_mode_rate = lchan->current_ch_mode_rate,
 		.requires_voice_stream = (lchan->fi_rtp != NULL),
 		.vamos = vamos,
-		.tsc_set = tsc_set,
-		.tsc = tsc,
+		.tsc_set = {
+			.use = (tsc_set >= 0),
+			.val = tsc_set,
+		},
+		.tsc = {
+			.use = (tsc >= 0),
+			.val = tsc,
+		},
 	};
 
 	lchan_mode_modify(lchan, &info);
@@ -1540,10 +1547,7 @@
 /* Activate / Deactivate a single lchan with a specific codec mode */
 static int lchan_act_single(struct vty *vty, struct gsm_lchan *lchan, const char *codec_str, int amr_mode, int activate)
 {
-	struct lchan_activate_info info = {
-		.tsc_set = -1,
-		.tsc = -1,
-	};
+	struct lchan_activate_info info = {0};
 	uint16_t amr_modes[8] =
 	    { GSM0808_SC_CFG_AMR_4_75, GSM0808_SC_CFG_AMR_4_75_5_90_7_40_12_20, GSM0808_SC_CFG_AMR_5_90,
 	      GSM0808_SC_CFG_AMR_6_70, GSM0808_SC_CFG_AMR_7_40, GSM0808_SC_CFG_AMR_7_95, GSM0808_SC_CFG_AMR_10_2,
@@ -1612,8 +1616,12 @@
 
 		if (activate == 2 || lchan->vamos.is_secondary) {
 			info.vamos = true;
-			info.tsc_set = lchan->vamos.is_secondary ? 1 : 0;
-			info.tsc = 0;
+			if (lchan->vamos.is_secondary) {
+				info.tsc_set.use = true;
+				info.tsc_set.val = 1;
+			}
+			info.tsc.use = true;
+			info.tsc.val = 0;
 			info.ch_mode_rate.chan_mode = gsm48_chan_mode_to_vamos(info.ch_mode_rate.chan_mode);
 		}
 
diff --git a/src/osmo-bsc/lchan_fsm.c b/src/osmo-bsc/lchan_fsm.c
index 0faafdb..7ebdaa5 100644
--- a/src/osmo-bsc/lchan_fsm.c
+++ b/src/osmo-bsc/lchan_fsm.c
@@ -714,13 +714,13 @@
 
 	/* If enabling VAMOS mode and no specific TSC Set was selected, make sure to select a sane TSC Set by
 	 * default: Set 1 for the primary and Set 2 for the shadow lchan. For non-VAMOS lchans, TSC Set 1. */
-	if (lchan->activate.info.tsc_set > 0)
-		lchan->activate.tsc_set = lchan->activate.info.tsc_set;
+	if (lchan->activate.info.tsc_set.use)
+		lchan->activate.tsc_set = lchan->activate.info.tsc_set.val;
 	else
 		lchan->activate.tsc_set = lchan->vamos.is_secondary ? 2 : 1;
 
 	/* Use the TSC provided in the activation request, if any. Otherwise use the timeslot's configured TSC. */
-	lchan->activate.tsc = (lchan->activate.info.tsc >= 0) ? lchan->activate.info.tsc : gsm_ts_tsc(lchan->ts);
+	lchan->activate.tsc = lchan->activate.info.tsc.use ? lchan->activate.info.tsc.val : gsm_ts_tsc(lchan->ts);
 
 	use_mgwep_ci = lchan_use_mgw_endpoint_ci_bts(lchan);
 
@@ -1095,8 +1095,6 @@
 				.ch_mode_rate = lchan->modify.ch_mode_rate,
 				.requires_voice_stream = true,
 				.msc_assigned_cic = lchan->modify.info.msc_assigned_cic,
-				.tsc_set = -1,
-				.tsc = -1,
 			};
 			if (lchan_activate_set_ch_mode_rate_and_mr_config(lchan))
 				return;
@@ -1250,14 +1248,14 @@
 
 		/* If enabling VAMOS mode and no specific TSC Set was selected, make sure to select a sane TSC Set by
 		 * default: Set 1 for the primary and Set 2 for the shadow lchan. For non-VAMOS lchans, TSC Set 1. */
-		if (lchan->modify.info.tsc_set > 0)
-			lchan->modify.tsc_set = lchan->modify.info.tsc_set;
+		if (lchan->modify.info.tsc_set.use)
+			lchan->modify.tsc_set = lchan->modify.info.tsc_set.val;
 		else
 			lchan->modify.tsc_set = lchan->vamos.is_secondary ? 2 : 1;
 
 		/* Use the TSC provided in the modification request, if any. Otherwise use the timeslot's configured
 		 * TSC. */
-		lchan->modify.tsc = (lchan->modify.info.tsc >= 0) ? lchan->modify.info.tsc : gsm_ts_tsc(lchan->ts);
+		lchan->modify.tsc = lchan->modify.info.tsc.use ? lchan->modify.info.tsc.val : gsm_ts_tsc(lchan->ts);
 
 		LOG_LCHAN(lchan, LOGL_INFO,
 			  "Modification requested: %s voice=%s MGW-ci=%s type=%s tch-mode=%s tsc=%d/%u\n",
diff --git a/src/osmo-bsc/osmo_bsc_bssap.c b/src/osmo-bsc/osmo_bsc_bssap.c
index d786ec6..aab2514 100644
--- a/src/osmo-bsc/osmo_bsc_bssap.c
+++ b/src/osmo-bsc/osmo_bsc_bssap.c
@@ -940,8 +940,6 @@
 			.msc_assigned_cic = cic,
 			.use_osmux = use_osmux,
 			.osmux_cid = osmux_cid,
-			.tsc_set = -1,
-			.tsc = -1,
 		};
 
 		/* Match codec information from the assignment command against the
@@ -968,8 +966,6 @@
 		req = (struct assignment_request){
 			.assign_for = ASSIGN_FOR_BSSMAP_REQ,
 			.aoip = aoip,
-			.tsc_set = -1,
-			.tsc = -1,
 		};
 
 		rc = select_sign_chan(&req, &ct);

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

Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: Iae20df4387c3d75752301bd5daeeea7508966393
Gerrit-Change-Number: 25659
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/20211002/ebcd297e/attachment.htm>


More information about the gerrit-log mailing list