Modify SI 13 field to support 11 bit RACH

System Information 13 field EGPRS PACKET CHANNEL REQUEST is
modified to support 11 bit RACH. Further VTY configuration is added
to enable/disable 11 bit RACH support in EGPRS. By default 11 bit
RACH support is disabled.

Change-Id: I51357bec936c28a26ab9ff5d59e0e30ca3363297
diff --git a/openbsc/include/openbsc/gsm_data_shared.h b/openbsc/include/openbsc/gsm_data_shared.h
index 7241ff0..7036619 100644
--- a/openbsc/include/openbsc/gsm_data_shared.h
+++ b/openbsc/include/openbsc/gsm_data_shared.h
@@ -696,6 +696,7 @@
 
 	/* Not entirely sure how ip.access specific this is */
 	struct {
+		uint8_t supports_egprs_11bit_rach;
 		enum bts_gprs_mode mode;
 		struct {
 			struct gsm_abis_mo mo;
diff --git a/openbsc/include/openbsc/rest_octets.h b/openbsc/include/openbsc/rest_octets.h
index 91413b5..b316228 100644
--- a/openbsc/include/openbsc/rest_octets.h
+++ b/openbsc/include/openbsc/rest_octets.h
@@ -88,6 +88,7 @@
 	uint32_t t3192;	/* in milliseconds */
 	uint32_t drx_timer_max;/* in seconds */
 	uint32_t bs_cv_max;
+	uint8_t  supports_egprs_11bit_rach;
 
 	uint8_t ext_info_present;
 	struct {
diff --git a/openbsc/src/libbsc/bsc_vty.c b/openbsc/src/libbsc/bsc_vty.c
index b0e8764..6584cf0 100644
--- a/openbsc/src/libbsc/bsc_vty.c
+++ b/openbsc/src/libbsc/bsc_vty.c
@@ -448,6 +448,9 @@
 	if (bts->gprs.mode == BTS_GPRS_NONE)
 		return;
 
+	vty_out(vty, "  gprs 11bit_rach_support_for_egprs %u%s",
+		bts->gprs.supports_egprs_11bit_rach, VTY_NEWLINE);
+
 	vty_out(vty, "  gprs routing area %u%s", bts->gprs.rac,
 		VTY_NEWLINE);
 	vty_out(vty, "  gprs network-control-order nc%u%s",
@@ -2724,6 +2727,32 @@
 	return CMD_SUCCESS;
 }
 
+DEFUN(cfg_bts_gprs_11bit_rach_support_for_egprs,
+	cfg_bts_gprs_11bit_rach_support_for_egprs_cmd,
+	"gprs 11bit_rach_support_for_egprs (0|1)",
+	GPRS_TEXT "11 bit RACH options\n"
+	"Disable 11 bit RACH for EGPRS\n"
+	"Enable 11 bit RACH for EGPRS")
+{
+	struct gsm_bts *bts = vty->index;
+
+	bts->gprs.supports_egprs_11bit_rach = atoi(argv[0]);
+
+	if (bts->gprs.supports_egprs_11bit_rach > 1) {
+		vty_out(vty, "Error in RACH type%s", VTY_NEWLINE);
+		return CMD_WARNING;
+	}
+
+	if ((bts->gprs.mode == BTS_GPRS_NONE) &&
+		(bts->gprs.supports_egprs_11bit_rach == 1)) {
+		vty_out(vty, "Error:gprs mode is none and 11bit rach is"
+			" enabled%s", VTY_NEWLINE);
+		return CMD_WARNING;
+	}
+
+	return CMD_SUCCESS;
+}
+
 #define SI_TEXT		"System Information Messages\n"
 #define SI_TYPE_TEXT "(1|2|3|4|5|6|7|8|9|10|13|16|17|18|19|20|2bis|2ter|2quater|5bis|5ter)"
 #define SI_TYPE_HELP 	"System Information Type 1\n"	\
@@ -4085,6 +4114,7 @@
 	install_element(BTS_NODE, &cfg_bts_penalty_time_rsvd_cmd);
 	install_element(BTS_NODE, &cfg_bts_radio_link_timeout_cmd);
 	install_element(BTS_NODE, &cfg_bts_gprs_mode_cmd);
+	install_element(BTS_NODE, &cfg_bts_gprs_11bit_rach_support_for_egprs_cmd);
 	install_element(BTS_NODE, &cfg_bts_gprs_ns_timer_cmd);
 	install_element(BTS_NODE, &cfg_bts_gprs_rac_cmd);
 	install_element(BTS_NODE, &cfg_bts_gprs_net_ctrl_ord_cmd);
diff --git a/openbsc/src/libbsc/rest_octets.c b/openbsc/src/libbsc/rest_octets.c
index 065fb7b..cd7bfd5 100644
--- a/openbsc/src/libbsc/rest_octets.c
+++ b/openbsc/src/libbsc/rest_octets.c
@@ -649,8 +649,15 @@
 			bitvec_set_uint(bv, (1 + 5 + 3)-1, 6);
 			/* EGPRS supported in the cell */
 			bitvec_set_bit(bv, 1);
+
 			/* 1bit EGPRS PACKET CHANNEL REQUEST */
-			bitvec_set_bit(bv, gco->ext_info.use_egprs_p_ch_req);
+			if (gco->supports_egprs_11bit_rach == 0) {
+				bitvec_set_bit(bv,
+					gco->ext_info.use_egprs_p_ch_req);
+			} else {
+				bitvec_set_bit(bv, 0);
+			}
+
 			/* 4bit BEP PERIOD */
 			bitvec_set_uint(bv, gco->ext_info.bep_period, 4);
 		}
diff --git a/openbsc/src/libbsc/system_information.c b/openbsc/src/libbsc/system_information.c
index fd228e3..69d2f7c 100644
--- a/openbsc/src/libbsc/system_information.c
+++ b/openbsc/src/libbsc/system_information.c
@@ -957,6 +957,7 @@
 		.drx_timer_max	= 3,
 		.bs_cv_max	= 15,
 		.ext_info_present = 0,
+		.supports_egprs_11bit_rach = 0,
 		.ext_info = {
 			/* The values below are just guesses ! */
 			.egprs_supported = 0,
@@ -1004,6 +1005,8 @@
 
 	/* Information about the other SIs */
 	si13_default.bcch_change_mark = bts->bcch_change_mark;
+	si13_default.cell_opts.supports_egprs_11bit_rach =
+					bts->gprs.supports_egprs_11bit_rach;
 
 	ret = rest_octets_si13(si13->rest_octets, &si13_default);
 	if (ret < 0)