Change in osmo-ttcn3-hacks[master]: pcu: Add infra to handle multitrx and multits envs

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/.

pespin gerrit-no-reply at lists.osmocom.org
Fri Nov 6 13:08:50 UTC 2020


pespin has submitted this change. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/20968 )

Change subject: pcu: Add infra to handle multitrx and multits envs
......................................................................

pcu: Add infra to handle multitrx and multits envs

ARFCNs are allocated sequentially, so that conversion between
arfcn<->trx_nr is easily done.

Some helper functions are introduced to be able to submit and expect
messages on a given TRX+TS, which is required for setups with several
TRX and PDCH-enabled TS different than the default. These new APIs
will be used in PCU_Tests.ttcn in subsequent patches.

Change-Id: I28430e6d8c77d2b7dc630d186d425a5d82587b82
---
M library/PCUIF_Types.ttcn
M pcu/GPRS_Components.ttcn
M pcu/PCU_Tests.ttcn
3 files changed, 87 insertions(+), 18 deletions(-)

Approvals:
  fixeria: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/library/PCUIF_Types.ttcn b/library/PCUIF_Types.ttcn
index 8af3757..a7a32ab 100644
--- a/library/PCUIF_Types.ttcn
+++ b/library/PCUIF_Types.ttcn
@@ -815,21 +815,21 @@
 
 template (value) PCUIF_InfoV09Trx ts_PCUIF_InfoV09TrxNULL := ts_PCUIF_InfoV09Trx(0, '00000000'B, '00'O);
 
-template (value) PCUIF_InfoTrxs ts_PCUIF_InfoV09Trxs_def := {
+template (value) PCUIF_InfoTrxs ts_PCUIF_InfoV09Trxs_def(uint16_t base_arfcn) := {
 	v09 := {
-		ts_PCUIF_InfoV09Trx, ts_PCUIF_InfoV09TrxNULL,
+		ts_PCUIF_InfoV09Trx(arfcn := base_arfcn + 0), ts_PCUIF_InfoV09TrxNULL,
 		ts_PCUIF_InfoV09TrxNULL, ts_PCUIF_InfoV09TrxNULL,
 		ts_PCUIF_InfoV09TrxNULL, ts_PCUIF_InfoV09TrxNULL,
 		ts_PCUIF_InfoV09TrxNULL, ts_PCUIF_InfoV09TrxNULL
 	}
 };
 
-template (value) PCUIF_InfoTrxs ts_PCUIF_InfoV10Trxs_def := {
+template (value) PCUIF_InfoTrxs ts_PCUIF_InfoV10Trxs_def(uint16_t base_arfcn) := {
 	v10 := {
-		ts_PCUIF_InfoV10Trx(arfcn := 871), ts_PCUIF_InfoV10Trx(arfcn := 872),
-		ts_PCUIF_InfoV10Trx(arfcn := 873), ts_PCUIF_InfoV10Trx(arfcn := 874),
-		ts_PCUIF_InfoV10Trx(arfcn := 875), ts_PCUIF_InfoV10Trx(arfcn := 876),
-		ts_PCUIF_InfoV10Trx(arfcn := 877), ts_PCUIF_InfoV10Trx(arfcn := 878)
+		ts_PCUIF_InfoV10Trx(arfcn := base_arfcn + 0), ts_PCUIF_InfoV10Trx(arfcn := base_arfcn + 1),
+		ts_PCUIF_InfoV10Trx(arfcn := base_arfcn + 2), ts_PCUIF_InfoV10Trx(arfcn := base_arfcn + 3),
+		ts_PCUIF_InfoV10Trx(arfcn := base_arfcn + 4), ts_PCUIF_InfoV10Trx(arfcn := base_arfcn + 5),
+		ts_PCUIF_InfoV10Trx(arfcn := base_arfcn + 6), ts_PCUIF_InfoV10Trx(arfcn := base_arfcn + 7)
 	}
 };
 
@@ -972,12 +972,12 @@
 
 
 /* TODO: remove this as soon as we drop version 9 support */
-function f_PCUIF_ver_INFO_Trxs()
+function f_PCUIF_ver_INFO_Trxs(uint16_t base_arfcn)
 return PCUIF_InfoTrxs {
 	if (PCUIF_Types.mp_pcuif_version >= 10) {
-		return valueof(ts_PCUIF_InfoV10Trxs_def);
+		return valueof(ts_PCUIF_InfoV10Trxs_def(base_arfcn));
 	} else {
-		return valueof(ts_PCUIF_InfoV09Trxs_def);
+		return valueof(ts_PCUIF_InfoV09Trxs_def(base_arfcn));
 	}
 }
 
diff --git a/pcu/GPRS_Components.ttcn b/pcu/GPRS_Components.ttcn
index 9dd4650..f2b0efb 100644
--- a/pcu/GPRS_Components.ttcn
+++ b/pcu/GPRS_Components.ttcn
@@ -29,6 +29,11 @@
 import from PCUIF_Components all;
 import from Native_Functions all;
 
+modulepar {
+	/* ARFCN of 1st TRX. Subsequent TRX are allocated incrementing ARFCNs. Nth TRX => base_arfcn + N-1 */
+	GsmArfcn mp_base_arfcn := 871;
+};
+
 type record TsTrxBtsNum {
 	uint3_t		ts_nr,
 	uint3_t		trx_nr,
@@ -64,7 +69,7 @@
 	GsmRrMessage		rr_imm_ass optional,
 	PacketDlAssignChan	ass optional,
 	uint5_t			tfi,
-	GsmArfcn		arfcn,
+	GsmArfcn		arfcn optional,
 	BIT8                    ts_mask,
 	AckNackDescription	acknack_desc
 };
@@ -79,7 +84,7 @@
 	GsmRrMessage		rr_imm_ass optional,
 	PacketUlAssignChan	ass optional,
 	uint5_t			tfi,
-	GsmArfcn		arfcn,
+	GsmArfcn		arfcn optional,
 	BIT8                    ts_mask,
 	uint3_t			usf[8],
 	boolean			is_egprs,
@@ -124,7 +129,7 @@
 	rr_imm_ass := omit,
 	ass := omit,
 	tfi := 0,
-	arfcn := 0,
+	arfcn := omit,
 	ts_mask := '00000000'B,
 	acknack_desc := t_AckNackDescription_init
 };
@@ -133,7 +138,7 @@
 	rr_imm_ass := omit,
 	ass := omit,
 	tfi := 0,
-	arfcn := 0,
+	arfcn := omit,
 	ts_mask := '00000000'B,
 	usf := { USF_UNUSED, USF_UNUSED, USF_UNUSED, USF_UNUSED, USF_UNUSED, USF_UNUSED, USF_UNUSED, USF_UNUSED },
 	is_egprs := false,
@@ -199,6 +204,18 @@
 	mtc.stop;
 }
 
+function f_arfcn2trxnr(GsmArfcn arfcn) runs on MS_BTS_IFACE_CT return uint3_t {
+	if (arfcn < mp_base_arfcn) {
+		setverdict(fail, "Unable to find TRX NR for arfcn ", arfcn);
+		f_shutdown(__BFILE__, __LINE__);
+	}
+	return arfcn - mp_base_arfcn;
+}
+
+function f_trxnr2arfcn(uint3_t trx_nr) return GsmArfcn {
+	return mp_base_arfcn + trx_nr;
+}
+
 function f_ultbf_new_from_rr_imm_ass(in GsmRrMessage rr_imm_ass)
 runs on MS_BTS_IFACE_CT return UlTbf {
 	var UlTbf ul_tbf := valueof(t_UlTbf_def);
@@ -352,12 +369,63 @@
 	return dl_tbf;
 }
 
+function f_ms_tx_TsTrxBtsNum(inout GprsMS ms)
+runs on MS_BTS_IFACE_CT return TsTrxBtsNum {
+	var uint3_t ts_nr := f_ultbf_next_ts(ms.ul_tbf);
+
+	var uint3_t trx_nr;
+	if (ispresent(ms.ul_tbf.arfcn)) {
+		trx_nr := f_arfcn2trxnr(ms.ul_tbf.arfcn);
+	} else {
+		/* FIXME: implement search by hsn+maio+ma when freq hopping is enabled */
+		setverdict(fail, "Asked for trx_nr but arfcn not available in ms.ul_tbf!");
+		f_shutdown(__BFILE__, __LINE__);
+	}
+	return valueof(ts_TsTrxBtsNum(ts_nr, trx_nr));
+}
+
+function f_dltbf_num_slots(DlTbf dl_tbf)
+runs on MS_BTS_IFACE_CT return integer  {
+	var integer n := 0;
+	for (var integer i := 0; i < lengthof(dl_tbf.ts_mask); i := i + 1) {
+		if (dl_tbf.ts_mask[i] == '1'B) {
+			n := n + 1;
+		}
+	}
+	return n;
+}
+
 function f_ultbf_inc_bsn(inout UlTbf ul_tbf)
 runs on MS_BTS_IFACE_CT {
 	ul_tbf.bsn := ul_tbf.bsn + 1;
 	ul_tbf.bsn := ul_tbf.bsn mod 128; /* FIXME: EGPRS SNS: 2048 */
 }
 
+function f_ultbf_next_ts(UlTbf ul_tbf)
+runs on MS_BTS_IFACE_CT return uint3_t {
+	/* FIXME: in the future we probably want to store last used internally
+	/* and continue from there */
+	for (var integer i := 0; i < lengthof(ul_tbf.ts_mask); i := i + 1) {
+		if (ul_tbf.ts_mask[i] == '1'B) {
+			return i;
+		}
+	}
+	setverdict(fail, "No TS available for tx!");
+	f_shutdown(__BFILE__, __LINE__);
+	return 0;
+}
+
+function f_ultbf_num_slots(UlTbf ul_tbf)
+runs on MS_BTS_IFACE_CT return integer  {
+	var integer n := 0;
+	for (var integer i := 0; i < lengthof(ul_tbf.ts_mask); i := i + 1) {
+		if (ul_tbf.ts_mask[i] == '1'B) {
+			n := n + 1;
+		}
+	}
+	return n;
+}
+
 function f_ms_use_ra(inout GprsMS ms, uint16_t ra, uint8_t ra_is_11bit := 0)
 runs on MS_BTS_IFACE_CT {
 	ms.ra_is_11bit := ra_is_11bit;
@@ -666,7 +734,7 @@
 	BTS.send(ts_PCUIF_RACH_IND(nr.bts_nr, nr.trx_nr, ts_nr := 0,
 				   ra := ra, is_11bit := is_11bit,
 				   burst_type := burst_type,
-				   fn := fn, arfcn := 871,
+				   fn := fn, arfcn := f_trxnr2arfcn(valueof(nr.trx_nr)),
 				   qta := ta * 4));
 
 	/* 3GPP TS 44.018, table 9.1.8.1, note 2b: Request Reference shall be set to 127
@@ -685,7 +753,8 @@
 	var template RAW_PCU_EventParam ev_param := {tdma_fn := ? };
 	BTS.send(ts_PCUIF_DATA_IND(nr.bts_nr, nr.trx_nr, nr.ts_nr, nr.blk_nr,
 				   sapi := PCU_IF_SAPI_PDTCH, data := data,
-				   fn := fn, arfcn := 871, lqual_cb := lqual_cb));
+				   fn := fn, arfcn := f_trxnr2arfcn(valueof(nr.trx_nr)),
+				   lqual_cb := lqual_cb));
 	if (fn != 0) {
 		ev_param := {tdma_fn := fn };
 	}
@@ -698,7 +767,7 @@
 runs on MS_BTS_IFACE_CT {
 	BTS.send(ts_PCUIF_RTS_REQ(nr.bts_nr, nr.trx_nr, nr.ts_nr,
 				  sapi := PCU_IF_SAPI_PDTCH, fn := 0,
-				  arfcn := 871, block_nr := nr.blk_nr));
+				  arfcn := f_trxnr2arfcn(valueof(nr.trx_nr)), block_nr := nr.blk_nr));
 	BTS.receive(tr_PCUIF_DATA_REQ(nr.bts_nr, nr.trx_nr, nr.ts_nr,
 				      sapi := PCU_IF_SAPI_PDTCH)) -> value pcu_msg;
 }
diff --git a/pcu/PCU_Tests.ttcn b/pcu/PCU_Tests.ttcn
index 79a5564..1b5fb78 100644
--- a/pcu/PCU_Tests.ttcn
+++ b/pcu/PCU_Tests.ttcn
@@ -70,7 +70,7 @@
 friend template (value) PCUIF_info_ind ts_PCUIF_INFO_default := {
 	version := PCUIF_Types.mp_pcuif_version,
 	flags := c_PCUIF_Flags_default,
-	trx := f_PCUIF_ver_INFO_Trxs(),
+	trx := f_PCUIF_ver_INFO_Trxs(GPRS_Components.mp_base_arfcn),
 	bsic := 7,
 	mcc := 262,
 	mnc := 42,

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

Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: I28430e6d8c77d2b7dc630d186d425a5d82587b82
Gerrit-Change-Number: 20968
Gerrit-PatchSet: 4
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy at sysmocom.de>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20201106/6443bb2e/attachment.htm>


More information about the gerrit-log mailing list