Update the function for EGPRS immediate assignment

Submitted by Bhargava Abhyankar on April 12, 2016, 7:22 a.m.

Details

Message ID 1460445755-28819-1-git-send-email-Bhargava.Abhyankar@radisys.com
State Changes Requested
Series "Update the function for EGPRS immediate assignment"
Headers show

Commit Message

Bhargava Abhyankar April 12, 2016, 7:22 a.m.
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(-)

Patch hide | download patch | download mbox

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;

Comments

Harald Welte April 12, 2016, 8:15 a.m.
Dear Bhargava and Radisys team,

can you please explain how you validate / verify the various patches you
are sending?  What is your testing setup?  Before I merge some of the
patches, I would like to understand that you are already doing some very
basic testing to avoid introducing regressions.

If that's not the case, I suggest we push those patches with a positive
review first to a 'radisys/pending' branch until they have been verified
to not cause regressions compared to the behavior in master.

Thanks for your understanding.

Regards,
	Harald
Bhargava Abhyankar April 12, 2016, 2:25 p.m.
Hello Harald,

> On 12 Apr 2016, at 01:45 PM, Harald Welte < laforge@gnumonks.org > wrote:

> can you please explain how you validate / verify the various patches you are sending?  What is your testing setup?  Before I  > merge some of the patches, I would like to understand that you are already doing some very basic testing to avoid  
> introducing regressions.

Currently we validate the source code patches in unit test environment and the source code behavior is verified by GDB tool. Going forward we have planned to test the same source in the integration test setup.

Regards,
Bhargava Abhyankar
Harald Welte April 12, 2016, 9:28 p.m.
Hi Bhargava,

On Tue, Apr 12, 2016 at 02:25:31PM +0000, Bhargava Abhyankar wrote:

> Currently we validate the source code patches in unit test environment
> and the source code behavior is verified by GDB tool. Going forward we
> have planned to test the same source in the integration test setup.

So in other words, this code has not yet been used in practise, by real
MS interfacing with OsmoBTS and OsmoPCU.  I thik this is bad news, and
we will have to go for the 'temporary branch' solution that I proposed.

Patches that look fine in terms of coding style and that have been
reviewed positively could be pushed to something like a
'radisys/reviewed' branch.  They would remain there until they have been
tested in some way beyond the basic unit test.

I hope you can understand that we cannot merge patches where even the
original author / submitter has not tried to use them in a real setup.

I'm not talking about a comprehensive end-to-end regression test, but
just something very basic and simple, like a single type of MS
attaching, establishing a PDP context and doing a file transfer over
GPRS.

Feel free to share what kind of "integration test setup" you have in
mind for further testing of the code.