aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeels Hofmeyr <nhofmeyr@sysmocom.de>2021-10-02 12:03:19 +0200
committerNeels Hofmeyr <nhofmeyr@sysmocom.de>2021-10-02 12:29:50 +0200
commit72b551ad694ae01289b294cf6ddaf0f1f099c554 (patch)
treeb23e831ad71fe3bfa2280e47aba97aa2b63ba0b0
parenteb67a2fbacd53a1db7c2023846be716fd5cfbb8f (diff)
fix TSC / TSC Set used for Handoverneels/tsc
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 Change-Id: Iae20df4387c3d75752301bd5daeeea7508966393
-rw-r--r--include/osmocom/bsc/gsm_data.h48
-rw-r--r--src/osmo-bsc/abis_rsl.c2
-rw-r--r--src/osmo-bsc/assignment_fsm.c20
-rw-r--r--src/osmo-bsc/bsc_vty.c24
-rw-r--r--src/osmo-bsc/lchan_fsm.c14
-rw-r--r--src/osmo-bsc/osmo_bsc_bssap.c4
6 files changed, 68 insertions, 44 deletions
diff --git a/include/osmocom/bsc/gsm_data.h b/include/osmocom/bsc/gsm_data.h
index 03f210f7d..4c7f3486c 100644
--- a/include/osmocom/bsc/gsm_data.h
+++ b/include/osmocom/bsc/gsm_data.h
@@ -138,6 +138,14 @@ extern const struct value_string assign_for_names[];
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 @@ struct assignment_request {
* 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 @@ struct lchan_activate_info {
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 @@ struct lchan_modify_info {
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 @@ struct gsm_lchan {
* 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 gsm_lchan {
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 fb8e3867a..98822521f 100644
--- a/src/osmo-bsc/abis_rsl.c
+++ b/src/osmo-bsc/abis_rsl.c
@@ -2087,8 +2087,6 @@ void abis_rsl_chan_rqd_queue_poll(struct gsm_bts *bts)
},
.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 97eb335c3..5a5492839 100644
--- a/src/osmo-bsc/assignment_fsm.c
+++ b/src/osmo-bsc/assignment_fsm.c
@@ -452,8 +452,14 @@ static int _reassignment_request(enum assign_for assign_for, struct gsm_lchan *l
.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 @@ static void assignment_fsm_wait_lchan_modified_onenter(struct osmo_fsm_inst *fi,
.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 5ccd78487..572434deb 100644
--- a/src/osmo-bsc/bsc_vty.c
+++ b/src/osmo-bsc/bsc_vty.c
@@ -849,6 +849,7 @@ static int ho_or_as(struct vty *vty, const char *argv[], int argc)
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 @@ static int trigger_vamos_mode_modify(struct vty *vty, struct gsm_lchan *lchan, b
.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 @@ DEFUN(pdch_act, pdch_act_cmd,
/* 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 @@ static int lchan_act_single(struct vty *vty, struct gsm_lchan *lchan, const char
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 0faafdb94..7ebdaa5b3 100644
--- a/src/osmo-bsc/lchan_fsm.c
+++ b/src/osmo-bsc/lchan_fsm.c
@@ -714,13 +714,13 @@ static void lchan_fsm_wait_ts_ready_onenter(struct osmo_fsm_inst *fi, uint32_t p
/* 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 @@ static void lchan_fsm_wait_rsl_chan_mode_modify_ack(struct osmo_fsm_inst *fi, ui
.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 @@ static void lchan_fsm_established(struct osmo_fsm_inst *fi, uint32_t event, void
/* 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 d786ec6ff..aab251424 100644
--- a/src/osmo-bsc/osmo_bsc_bssap.c
+++ b/src/osmo-bsc/osmo_bsc_bssap.c
@@ -940,8 +940,6 @@ static int bssmap_handle_assignm_req(struct gsm_subscriber_connection *conn,
.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 @@ static int bssmap_handle_assignm_req(struct gsm_subscriber_connection *conn,
req = (struct assignment_request){
.assign_for = ASSIGN_FOR_BSSMAP_REQ,
.aoip = aoip,
- .tsc_set = -1,
- .tsc = -1,
};
rc = select_sign_chan(&req, &ct);