aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2021-05-19 02:29:05 +0200
committerNeels Hofmeyr <neels@hofmeyr.de>2021-05-31 05:20:03 +0000
commite262919892ab58fe122ae203d745bd2b6a45626e (patch)
tree95a5d556d942ddaf9d9cf83615156968c5dd1d68
parent6f5b1b167596d3075f3616643b8f4ed6293e2dbc (diff)
add fields to reflect nr of lchans in ts struct
So far the number of usable lchans is determined on-the-fly by the physical channel config. With VAMOS, this becomes more complex, namely determining whether the BTS is vamos capable. Instead of calling a function to determine the number of lchans for every use, rather place the number of valid lchans in int members of the timeslot struct, and initialize those during timeslot setup. Actual use of these new fields will follow in a subsequent patch, which introduces the ts_for_n_lchans() macro to replace current lchan iteration macros. Related: SYS#5315 OS#4940 Change-Id: I08027d79db71a23e874b729c4e6173b0f269ee4f
-rw-r--r--include/osmocom/bsc/gsm_data.h6
-rw-r--r--include/osmocom/bsc/timeslot_fsm.h2
-rw-r--r--src/osmo-bsc/bsc_vty.c4
-rw-r--r--src/osmo-bsc/timeslot_fsm.c31
-rw-r--r--tests/handover/handover_test.c8
5 files changed, 35 insertions, 16 deletions
diff --git a/include/osmocom/bsc/gsm_data.h b/include/osmocom/bsc/gsm_data.h
index f2e6cfa63..7bfe3abe6 100644
--- a/include/osmocom/bsc/gsm_data.h
+++ b/include/osmocom/bsc/gsm_data.h
@@ -821,6 +821,12 @@ struct gsm_bts_trx_ts {
} rbs2000;
};
+ /* Maximum number of lchans that could become usable, for example by switching a dynamic timeslot's type or by
+ * enabling VAMOS secondary lchans. This does include the maximum count of possible VAMOS secondary lchans. */
+ uint8_t max_lchans_possible;
+ /* Currently usable lchans, according to the current pchan mode (for dynamic timeslots, this may change).
+ * Does not include count of secondary VAMOS lchans. */
+ uint8_t max_primary_lchans;
struct gsm_lchan lchan[TS_MAX_LCHAN];
};
diff --git a/include/osmocom/bsc/timeslot_fsm.h b/include/osmocom/bsc/timeslot_fsm.h
index da6613600..f5e4b4ccb 100644
--- a/include/osmocom/bsc/timeslot_fsm.h
+++ b/include/osmocom/bsc/timeslot_fsm.h
@@ -51,3 +51,5 @@ bool ts_is_capable_of_lchant(struct gsm_bts_trx_ts *ts, enum gsm_chan_t type);
bool ts_is_lchan_waiting_for_pchan(struct gsm_bts_trx_ts *ts, enum gsm_phys_chan_config *target_pchan);
bool ts_is_pchan_switching(struct gsm_bts_trx_ts *ts, enum gsm_phys_chan_config *target_pchan);
bool ts_usable_as_pchan(struct gsm_bts_trx_ts *ts, enum gsm_phys_chan_config as_pchan, bool allow_pchan_switch);
+
+void ts_set_pchan_is(struct gsm_bts_trx_ts *ts, enum gsm_phys_chan_config pchan_is);
diff --git a/src/osmo-bsc/bsc_vty.c b/src/osmo-bsc/bsc_vty.c
index c91266e21..6252d06e7 100644
--- a/src/osmo-bsc/bsc_vty.c
+++ b/src/osmo-bsc/bsc_vty.c
@@ -6428,9 +6428,9 @@ DEFUN(lchan_mdcx, lchan_mdcx_cmd,
return CMD_WARNING;
}
- if (ss_nr >= pchan_subslots(ts->pchan_is)) {
+ if (ss_nr >= ts->max_primary_lchans) {
vty_out(vty, "%% subslot index %d too large for physical channel %s (%u slots)%s",
- ss_nr, gsm_pchan_name(ts->pchan_is), pchan_subslots(ts->pchan_is),
+ ss_nr, gsm_pchan_name(ts->pchan_is), ts->max_primary_lchans,
VTY_NEWLINE);
return CMD_WARNING;
}
diff --git a/src/osmo-bsc/timeslot_fsm.c b/src/osmo-bsc/timeslot_fsm.c
index 41921cd96..4fe670fea 100644
--- a/src/osmo-bsc/timeslot_fsm.c
+++ b/src/osmo-bsc/timeslot_fsm.c
@@ -187,6 +187,14 @@ static void ts_fsm_err_ready_to_go_in_pdch(struct osmo_fsm_inst *fi, struct gsm_
osmo_fsm_inst_state_name(fi), gsm_lchan_name(lchan));
}
+void ts_set_pchan_is(struct gsm_bts_trx_ts *ts, enum gsm_phys_chan_config pchan_is)
+{
+ ts->pchan_is = pchan_is;
+ ts->max_primary_lchans = pchan_subslots(ts->pchan_is);
+ LOG_TS(ts, LOGL_DEBUG, "pchan_is=%s max_primary_lchans=%d max_lchans_possible=%d\n",
+ gsm_pchan_name(ts->pchan_is), ts->max_primary_lchans, ts->max_lchans_possible);
+}
+
static void ts_setup_lchans(struct gsm_bts_trx_ts *ts)
{
int i, max_lchans;
@@ -196,8 +204,10 @@ static void ts_setup_lchans(struct gsm_bts_trx_ts *ts)
max_lchans = pchan_subslots(ts->pchan_on_init);
LOG_TS(ts, LOGL_DEBUG, "max lchans: %d\n", max_lchans);
+ ts->max_lchans_possible = max_lchans;
+ ts->max_primary_lchans = 0;
- for (i = 0; i < max_lchans; i++) {
+ for (i = 0; i < ts->max_lchans_possible; i++) {
/* If we receive more than one Channel OPSTART ACK, don't fail on the second init. */
if (ts->lchan[i].fi)
continue;
@@ -206,13 +216,13 @@ static void ts_setup_lchans(struct gsm_bts_trx_ts *ts)
switch (ts->pchan_on_init) {
case GSM_PCHAN_TCH_F_TCH_H_PDCH:
- ts->pchan_is = GSM_PCHAN_NONE;
+ ts_set_pchan_is(ts, GSM_PCHAN_NONE);
break;
case GSM_PCHAN_TCH_F_PDCH:
- ts->pchan_is = GSM_PCHAN_TCH_F;
+ ts_set_pchan_is(ts, GSM_PCHAN_TCH_F);
break;
default:
- ts->pchan_is = ts->pchan_on_init;
+ ts_set_pchan_is(ts, ts->pchan_on_init);
break;
}
}
@@ -418,7 +428,7 @@ static void ts_fsm_pdch_onenter(struct osmo_fsm_inst *fi, uint32_t prev_state)
case GSM_PCHAN_TCH_F_TCH_H_PDCH:
case GSM_PCHAN_TCH_F_PDCH:
case GSM_PCHAN_PDCH:
- ts->pchan_is = GSM_PCHAN_PDCH;
+ ts_set_pchan_is(ts, GSM_PCHAN_PDCH);
break;
default:
ts_fsm_error(fi, TS_ST_BORKEN, "pchan %s is incapable of activating PDCH",
@@ -491,10 +501,10 @@ static void ts_fsm_wait_pdch_deact(struct osmo_fsm_inst *fi, uint32_t event, voi
/* Remove pchan = PDCH status, but double check. */
switch (ts->pchan_on_init) {
case GSM_PCHAN_TCH_F_TCH_H_PDCH:
- ts->pchan_is = GSM_PCHAN_NONE;
+ ts_set_pchan_is(ts, GSM_PCHAN_NONE);
break;
case GSM_PCHAN_TCH_F_PDCH:
- ts->pchan_is = GSM_PCHAN_TCH_F;
+ ts_set_pchan_is(ts, GSM_PCHAN_TCH_F);
break;
default:
ts_fsm_error(fi, TS_ST_BORKEN, "pchan %s is incapable of deactivating PDCH",
@@ -616,7 +626,7 @@ static void ts_fsm_in_use_onenter(struct osmo_fsm_inst *fi, uint32_t prev_state)
/* Make sure dyn TS pchan_is is updated. For TCH/F_PDCH, there are only PDCH or TCH/F modes, but
* for Osmocom style TCH/F_TCH/H_PDCH the pchan_is == NONE until an lchan is activated. */
if (ts->pchan_on_init == GSM_PCHAN_TCH_F_TCH_H_PDCH)
- ts->pchan_is = gsm_pchan_by_lchan_type(activating_type);
+ ts_set_pchan_is(ts, gsm_pchan_by_lchan_type(activating_type));
ts_lchans_dispatch(ts, LCHAN_ST_WAIT_TS_READY, LCHAN_EV_TS_READY);
}
@@ -762,7 +772,8 @@ static void ts_fsm_allstate(struct osmo_fsm_inst *fi, uint32_t event, void *data
osmo_fsm_inst_state_chg(fi, TS_ST_NOT_INITIALIZED, 0, 0);
OSMO_ASSERT(fi->state == TS_ST_NOT_INITIALIZED);
ts_terminate_lchan_fsms(ts);
- ts->pchan_is = ts->pchan_on_init = GSM_PCHAN_NONE;
+ ts->pchan_on_init = GSM_PCHAN_NONE;
+ ts_set_pchan_is(ts, GSM_PCHAN_NONE);
ts_fsm_update_id(ts);
break;
@@ -771,7 +782,7 @@ static void ts_fsm_allstate(struct osmo_fsm_inst *fi, uint32_t event, void *data
if (fi->state != TS_ST_NOT_INITIALIZED)
osmo_fsm_inst_state_chg(fi, TS_ST_NOT_INITIALIZED, 0, 0);
OSMO_ASSERT(fi->state == TS_ST_NOT_INITIALIZED);
- ts->pchan_is = GSM_PCHAN_NONE;
+ ts_set_pchan_is(ts, GSM_PCHAN_NONE);
ts_lchans_dispatch(ts, -1, LCHAN_EV_TS_ERROR);
break;
diff --git a/tests/handover/handover_test.c b/tests/handover/handover_test.c
index 0859a0436..006e7910c 100644
--- a/tests/handover/handover_test.c
+++ b/tests/handover/handover_test.c
@@ -271,7 +271,7 @@ static struct gsm_bts *_create_bts(int num_trx, const char * const *ts_args, int
switch (trx->ts[i].pchan_on_init) {
case GSM_PCHAN_TCH_F_TCH_H_PDCH:
case GSM_PCHAN_TCH_F_PDCH:
- trx->ts[i].pchan_is = GSM_PCHAN_PDCH;
+ ts_set_pchan_is(&trx->ts[i], GSM_PCHAN_PDCH);
break;
default:
break;
@@ -392,10 +392,10 @@ struct gsm_lchan *lchan_act(struct gsm_lchan *lchan, int full_rate, const char *
lchan->mgw_endpoint_ci_bts = (void*)1;
if (lchan->ts->pchan_on_init == GSM_PCHAN_TCH_F_TCH_H_PDCH)
- lchan->ts->pchan_is = full_rate ? GSM_PCHAN_TCH_F : GSM_PCHAN_TCH_H;
+ ts_set_pchan_is(lchan->ts, full_rate ? GSM_PCHAN_TCH_F : GSM_PCHAN_TCH_H);
if (lchan->ts->pchan_on_init == GSM_PCHAN_TCH_F_PDCH) {
OSMO_ASSERT(full_rate);
- lchan->ts->pchan_is = GSM_PCHAN_TCH_F;
+ ts_set_pchan_is(lchan->ts, GSM_PCHAN_TCH_F);
}
LOG_LCHAN(lchan, LOGL_DEBUG, "activated by handover_test.c\n");
@@ -731,7 +731,7 @@ int __wrap_abis_rsl_sendmsg(struct msgb *msg)
break;
/* else fall thru */
case GSM_PCHAN_TCH_F:
- lchan->ts->pchan_is = GSM_PCHAN_PDCH;
+ ts_set_pchan_is(lchan->ts, GSM_PCHAN_PDCH);
break;
default:
break;