Change in osmo-pcu[master]: encoding: implement handing of hopping parameters

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

fixeria gerrit-no-reply at lists.osmocom.org
Fri Aug 21 21:08:22 UTC 2020


fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-pcu/+/19788 )


Change subject: encoding: implement handing of hopping parameters
......................................................................

encoding: implement handing of hopping parameters

The following test cases verify coding of the hopping parameters:

  + (RR) Immediate Assignment
    - TC_pcuif_fh_imm_ass_ul_egprs,
    - TC_pcuif_fh_imm_ass_ul,
    - TC_pcuif_fh_imm_ass_dl,

  + (RLC/MAC) Packet Uplink/Downlink Assignment:
    - TC_pcuif_fh_pkt_ass_ul,
    - TC_pcuif_fh_pkt_ass_dl,

all of them pass with this (and the upcoming) change applied.

Change-Id: I8adc0cdb1b05a87b4df5d4bc196f6d381283a06f
Related: SYS#4868, OS#4547
---
M src/encoding.cpp
M src/pdch.h
2 files changed, 83 insertions(+), 11 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/88/19788/1

diff --git a/src/encoding.cpp b/src/encoding.cpp
index 33fe196..ef2524b 100644
--- a/src/encoding.cpp
+++ b/src/encoding.cpp
@@ -466,8 +466,15 @@
 	bitvec_write_field(dest, &wp, pdch->ts_no, 3);		// TN
 	bitvec_write_field(dest, &wp, pdch->tsc, 3);		// TSC
 
-	bitvec_write_field(dest, &wp, 0x00, 3);			// spare (non-hopping RF channel configuraion)
-	bitvec_write_field(dest, &wp, pdch->trx->arfcn, 10);	// ARFCN
+	/* RF channel configuraion: hopping or non-hopping */
+	if (pdch->fh.enabled) {
+		bitvec_write_field(dest, &wp, 0x01, 1); /* direct encoding */
+		bitvec_write_field(dest, &wp, pdch->fh.maio, 6);
+		bitvec_write_field(dest, &wp, pdch->fh.hsn, 6);
+	} else {
+		bitvec_write_field(dest, &wp, 0x00, 3);
+		bitvec_write_field(dest, &wp, pdch->trx->arfcn, 10);
+	}
 
 	//10.5.2.30 Request Reference
 	if (((burst_type == GSM_L1_BURST_TYPE_ACCESS_1) ||
@@ -485,9 +492,18 @@
 	bitvec_write_field(dest, &wp,0x0,2); // spare
 	bitvec_write_field(dest, &wp,ta,6);  // Timing Advance value
 
-	// No mobile allocation in non-hopping systems.
-	// A zero-length LV.  Just write L=0.
-	bitvec_write_field(dest, &wp,0,8);
+	/* 10.5.2.21 Mobile Allocation */
+	if (pdch->fh.enabled) {
+		OSMO_ASSERT(pdch->fh.ma_len <= ARRAY_SIZE(pdch->fh.ma));
+		bitvec_write_field(dest, &wp, pdch->fh.ma_len, 8);
+
+		for (int i = 0; i < pdch->fh.ma_len; i++)
+			bitvec_write_field(dest, &wp, pdch->fh.ma[i], 8);
+	} else {
+		// No mobile allocation in non-hopping systems.
+		// A zero-length LV.  Just write L=0.
+		bitvec_write_field(dest, &wp, 0x00, 8);
+	}
 
 	OSMO_ASSERT(wp % 8 == 0);
 
@@ -535,6 +551,55 @@
 	return plen;
 }
 
+/* Prepare to be encoded Frequency Parameters IE (see Table 12.8.1) */
+static void gen_freq_params(Frequency_Parameters_t *freq_params,
+			    const struct gprs_rlcmac_tbf *tbf)
+{
+	const struct gprs_rlcmac_pdch *pdch = NULL;
+	Direct_encoding_1_t fh_params;
+
+	/* Training Sequence Code */
+	freq_params->TSC = tbf->tsc();
+
+	/* Find at least one PDCH, if it's hopping then all other should too */
+	for (unsigned int tn = 0; tn < 8; tn++) {
+		if (tbf->pdch[tn] != NULL) {
+			pdch = tbf->pdch[tn];
+			break;
+		}
+	}
+
+	/* If frequency hopping is not in use, encode a single ARFCN */
+	if (pdch == NULL || !pdch->fh.enabled) {
+		freq_params->UnionType = 0x00;
+		freq_params->u.ARFCN = tbf->trx->arfcn;
+		return;
+	}
+
+	/* Direct encoding 1 (see Table 12.8.1) */
+	freq_params->UnionType = 0x2;
+
+	/* HSN / MAIO */
+	fh_params.MAIO = pdch->fh.maio;
+	fh_params.GPRS_Mobile_Allocation.HSN = pdch->fh.hsn;
+	fh_params.GPRS_Mobile_Allocation.ElementsOf_RFL_NUMBER = 0;
+
+	/* Mobile Allocation bitmap */
+	fh_params.GPRS_Mobile_Allocation.UnionType = 0; /* MA bitmap */
+	fh_params.GPRS_Mobile_Allocation.u.MA.MA_LENGTH = pdch->fh.ma_len; /* in bytes */
+	memcpy(fh_params.GPRS_Mobile_Allocation.u.MA.MA_BITMAP, pdch->fh.ma, pdch->fh.ma_len);
+
+	/* Mobile Allocation bitmap length (in bits) */
+	fh_params.GPRS_Mobile_Allocation.u.MA.MA_BitLength = pdch->fh.ma_len * 8;
+	for (unsigned int i = 0; i < 8; i++) { /* skip redundant bits */
+		if (pdch->fh.ma[0] & (0x80 >> i))
+			break;
+		fh_params.GPRS_Mobile_Allocation.u.MA.MA_BitLength--;
+	}
+
+	freq_params->u.Direct_encoding_1 = fh_params;
+}
+
 /* generate uplink assignment */
 void Encoding::write_packet_uplink_assignment(
 	RlcMacDownlink_t * block, uint8_t old_tfi,
@@ -621,9 +686,7 @@
 	}
 
 	/* Frequency Parameters IE */
-	fp->TSC       = tbf->tsc();  // Training Sequence Code (TSC)
-	fp->UnionType = 0x00;        // Single ARFCN
-	fp->u.ARFCN   = tbf->trx->arfcn;
+	gen_freq_params(fp, tbf);
 
 	/* Dynamic allocation parameters */
 	da->USF_GRANULARITY = 0x00;
@@ -715,9 +778,7 @@
 	block->u.Packet_Downlink_Assignment.Exist_P0_and_BTS_PWR_CTRL_MODE = 0x0;   // POWER CONTROL = off
 
 	block->u.Packet_Downlink_Assignment.Exist_Frequency_Parameters     = 0x1;   // Frequency Parameters = on
-	block->u.Packet_Downlink_Assignment.Frequency_Parameters.TSC       = tbf->tsc();   // Training Sequence Code (TSC)
-	block->u.Packet_Downlink_Assignment.Frequency_Parameters.UnionType = 0x0;   // ARFCN = on
-	block->u.Packet_Downlink_Assignment.Frequency_Parameters.u.ARFCN   = tbf->trx->arfcn; // ARFCN
+	gen_freq_params(&block->u.Packet_Downlink_Assignment.Frequency_Parameters, tbf);
 
 	block->u.Packet_Downlink_Assignment.Exist_DOWNLINK_TFI_ASSIGNMENT  = 0x1;     // DOWNLINK TFI ASSIGNMENT = on
 	block->u.Packet_Downlink_Assignment.DOWNLINK_TFI_ASSIGNMENT        = tbf->tfi(); // TFI
diff --git a/src/pdch.h b/src/pdch.h
index ec35174..6ed4931 100644
--- a/src/pdch.h
+++ b/src/pdch.h
@@ -106,6 +106,17 @@
 	void update_ta(uint8_t tai, uint8_t ta);
 #endif
 
+	/* Frequency hopping parameters */
+	struct {
+		bool enabled;
+		/* 3GPP TS 45.002 HSN / MAIO (6 bit each) */
+		uint8_t hsn;
+		uint8_t maio;
+		/* 3GPP TS 44.018, 10.5.2.21 "Mobile Allocation" */
+		uint8_t ma_len;
+		uint8_t ma[8];
+	} fh;
+
 	/* back pointers */
 	struct gprs_rlcmac_trx *trx;
 	uint8_t ts_no;

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

Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Change-Id: I8adc0cdb1b05a87b4df5d4bc196f6d381283a06f
Gerrit-Change-Number: 19788
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <vyanitskiy at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200821/f12c0a88/attachment.htm>


More information about the gerrit-log mailing list