Change in osmo-bsc[master]: add fields to reflect nr of lchans in ts struct

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
Sun May 23 23:02:26 UTC 2021


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


Change subject: add fields to reflect nr of lchans in ts struct
......................................................................

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
---
M include/osmocom/bsc/gsm_data.h
M include/osmocom/bsc/timeslot_fsm.h
M src/osmo-bsc/bsc_vty.c
M src/osmo-bsc/timeslot_fsm.c
M tests/handover/handover_test.c
5 files changed, 37 insertions(+), 16 deletions(-)



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

diff --git a/include/osmocom/bsc/gsm_data.h b/include/osmocom/bsc/gsm_data.h
index 4be1daa..f8b8b72 100644
--- a/include/osmocom/bsc/gsm_data.h
+++ b/include/osmocom/bsc/gsm_data.h
@@ -827,6 +827,12 @@
 		} 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 da66136..f5e4b4c 100644
--- a/include/osmocom/bsc/timeslot_fsm.h
+++ b/include/osmocom/bsc/timeslot_fsm.h
@@ -51,3 +51,5 @@
 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 9624e5e..20f7b4c 100644
--- a/src/osmo-bsc/bsc_vty.c
+++ b/src/osmo-bsc/bsc_vty.c
@@ -6434,9 +6434,9 @@
 		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 41921cd..7c6bb78 100644
--- a/src/osmo-bsc/timeslot_fsm.c
+++ b/src/osmo-bsc/timeslot_fsm.c
@@ -187,6 +187,16 @@
 		     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)
+{
+	int i;
+	struct gsm_lchan *lchan;
+	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 +206,10 @@
 
 	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 +218,13 @@
 
 	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 +430,7 @@
 	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 +503,10 @@
 		/* 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 +628,7 @@
 	/* 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 +774,8 @@
 			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 +784,7 @@
 		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 1797e4c..4455c88 100644
--- a/tests/handover/handover_test.c
+++ b/tests/handover/handover_test.c
@@ -271,7 +271,7 @@
 			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 @@
 	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 @@
 					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;

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

Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: I08027d79db71a23e874b729c4e6173b0f269ee4f
Gerrit-Change-Number: 24371
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/20210523/b74e5f93/attachment.htm>


More information about the gerrit-log mailing list