[PATCH] Update the function for EGPRS immediate assignment

Bhargava Abhyankar Bhargava.Abhyankar at radisys.com
Tue Apr 12 07:22:35 UTC 2016


Encode the EGPRS immediate assignment message in uplink when EGPRS
is enabled.
---
 src/bts.cpp             |  2 +-
 src/encoding.cpp        | 53 +++++++++++++++++++++++++++++++++++++++++--------
 src/encoding.h          |  5 +++--
 tests/edge/EdgeTest.cpp |  3 ++-
 4 files changed, 51 insertions(+), 12 deletions(-)

diff --git a/src/bts.cpp b/src/bts.cpp
index 2166132..2c23192 100644
--- a/src/bts.cpp
+++ b/src/bts.cpp
@@ -536,7 +536,7 @@ int BTS::rcv_rach(uint16_t ra, uint32_t Fn, int16_t qta, uint8_t is_11bit,
 	plen = Encoding::write_immediate_assignment(
 		tbf, immediate_assignment, 0, ra, Fn, ta,
 		m_bts.trx[trx_no].arfcn, ts_no, tsc, usf, 0, sb_fn,
-		m_bts.alpha, m_bts.gamma, -1);
+		m_bts.alpha, m_bts.gamma, -1, burst);
 
 	if (plen >= 0) {
 		pcu_l1if_tx_agch(immediate_assignment, plen);
diff --git a/src/encoding.cpp b/src/encoding.cpp
index 6c50abe..3292c2a 100644
--- a/src/encoding.cpp
+++ b/src/encoding.cpp
@@ -19,9 +19,9 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  */
 
+#include <bts.h>
 #include <encoding.h>
 #include <gprs_rlcmac.h>
-#include <bts.h>
 #include <tbf.h>
 #include <gprs_debug.h>
 
@@ -140,11 +140,48 @@ static int write_ia_rest_egprs_uplink(
 	gprs_rlcmac_ul_tbf *tbf,
 	bitvec * dest, unsigned& wp,
 	uint8_t usf, uint32_t fn,
-	uint8_t alpha, uint8_t gamma, int8_t ta_idx)
+	uint8_t alpha, uint8_t gamma, int8_t ta_idx,
+	enum ph_burst_type burst)
 {
-	LOGP(DRLCMACUL, LOGL_ERROR,
-		"EGPRS Packet Uplink Assignment is not yet implemented\n");
-	return -EINVAL;
+	bitvec_write_field(dest, wp, 1, 2);    /* LH */
+	bitvec_write_field(dest, wp, 0, 2);    /* 0 EGPRS Uplink Assignment */
+	bitvec_write_field(dest, wp, 0, 5);    /* Extended RA **todo** */
+	bitvec_write_field(dest, wp, 0, 1);    /* Access technology Request */
+
+	unsigned int ws_enc = (tbf->m_window.ws() - 64) / 32;
+
+	bitvec_write_field(dest, wp, 1, 1);	/* single block alloc */
+	bitvec_write_field(dest, wp, tbf->tfi(), 5);/* TFI assignment */
+	bitvec_write_field(dest, wp, 0, 1);	/* polling bit */
+	bitvec_write_field(dest, wp, usf, 3);   /* USF bit */
+	bitvec_write_field(dest, wp, 0, 1);     /* USF granularity */
+	bitvec_write_field(dest, wp, 0, 1);	/* P0 */
+
+	if (burst == GSM_L1_BURST_TYPE_ACCESS_1) { /* 8-PSK RACH*/
+		bitvec_write_field(dest, wp, tbf->current_cs().
+			to_num()-1, 4);		/*mcs*/
+	} else {
+		bitvec_write_field(dest, wp, GprsCodingScheme::MCS1, 4); /*mcs*/
+	}
+
+	bitvec_write_field(dest, wp, tbf->tlli(), 1); /* tlli channel block */
+	bitvec_write_field(dest, wp, 0, 1);	/* BEP period present */
+	bitvec_write_field(dest, wp, 0, 1);	/* resegmentation */
+	bitvec_write_field(dest, wp, ws_enc, 5);/* egprs window_size */
+
+	if (alpha) {
+		bitvec_write_field(dest, wp, 0x1, 1);   /* ALPHA =yes */
+		bitvec_write_field(dest, wp, alpha, 4);	/* ALPHA */
+		bitvec_write_field(dest, wp, gamma, 5);	/* GAMMA power contrl */
+	} else {
+		bitvec_write_field(dest, wp, 0x0, 1);   /* ALPHA = no */
+	}
+
+	bitvec_write_field(dest, wp, 0, 1);	/* TIMING_ADVANCE_INDEX */
+	bitvec_write_field(dest, wp, 0, 1);	/* TBF_STARTING_TIME_FLAG */
+	bitvec_write_field(dest, wp, 0, 1);	/* NULL */
+
+	return 0;
 }
 
 /*
@@ -153,10 +190,10 @@ static int write_ia_rest_egprs_uplink(
  */
 int Encoding::write_immediate_assignment(
 	struct gprs_rlcmac_tbf *tbf,
-	bitvec * dest, uint8_t downlink, uint8_t ra,
+	bitvec * dest, uint8_t downlink, uint16_t ra,
 	uint32_t ref_fn, uint8_t ta, uint16_t arfcn, uint8_t ts, uint8_t tsc,
 	uint8_t usf, uint8_t polling, uint32_t fn, uint8_t alpha,
-	uint8_t gamma, int8_t ta_idx)
+	uint8_t gamma, int8_t ta_idx, enum ph_burst_type burst)
 {
 	unsigned wp = 0;
 	int plen;
@@ -209,7 +246,7 @@ int Encoding::write_immediate_assignment(
 	else if (as_ul_tbf(tbf) && as_ul_tbf(tbf)->is_egprs_enabled())
 		rc = write_ia_rest_egprs_uplink(as_ul_tbf(tbf), dest, wp,
 			usf, fn,
-			alpha, gamma, ta_idx);
+			alpha, gamma, ta_idx, burst);
 	else
 		rc = write_ia_rest_uplink(as_ul_tbf(tbf), dest, wp,
 			usf, fn,
diff --git a/src/encoding.h b/src/encoding.h
index 94e9a02..079332d 100644
--- a/src/encoding.h
+++ b/src/encoding.h
@@ -40,11 +40,12 @@ class Encoding {
 public:
 	static int write_immediate_assignment(
 			struct gprs_rlcmac_tbf *tbf,
-			bitvec * dest, uint8_t downlink, uint8_t ra,
+			bitvec * dest, uint8_t downlink, uint16_t ra,
 			uint32_t ref_fn, uint8_t ta, uint16_t arfcn, uint8_t ts,
 			uint8_t tsc, uint8_t usf, uint8_t polling,
 			uint32_t fn, uint8_t alpha, uint8_t gamma,
-			int8_t ta_idx);
+			int8_t ta_idx,
+			enum ph_burst_type burst = GSM_L1_BURST_TYPE_ACCESS_0);
 
 	static void write_packet_uplink_assignment(
 			struct gprs_rlcmac_bts *bts,
diff --git a/tests/edge/EdgeTest.cpp b/tests/edge/EdgeTest.cpp
index 96ea0c1..9138ae7 100644
--- a/tests/edge/EdgeTest.cpp
+++ b/tests/edge/EdgeTest.cpp
@@ -23,7 +23,6 @@
 #include "gprs_debug.h"
 #include "gprs_coding_scheme.h"
 #include "decoding.h"
-#include "encoding.h"
 #include "rlc.h"
 #include "llc.h"
 
@@ -35,10 +34,12 @@ extern "C" {
 #include <osmocom/core/talloc.h>
 #include <osmocom/core/utils.h>
 #include <osmocom/vty/vty.h>
+#include <osmocom/gsm/l1sap.h>
 }
 
 #include <errno.h>
 #include <string.h>
+#include "encoding.h"
 
 void *tall_pcu_ctx;
 int16_t spoof_mnc = 0, spoof_mcc = 0;
-- 
2.5.0




More information about the osmocom-net-gprs mailing list