edge: Make window size configurable

Currently the window size is fixed to 64 even for EGPRS.

Support dynamic window sizes depending on the number of PDCH. The
WS can be set to b + f * N_PDCH. If the result is not valid according
to TS 44.060, Table 9.1.9.2.1, the value will be corrected to use the
next lower valid value (or 64).

The following VTY commands are added (config-pcu node):

  window-size <0-1024>          set base (b) value and leave f unchanged
  window-size <0-1024> <0-256>  set base (b) and factor (f)

Sponsored-by: On-Waves ehf
diff --git a/src/pcu_vty.c b/src/pcu_vty.c
index 97be4c7..b5ee1b5 100644
--- a/src/pcu_vty.c
+++ b/src/pcu_vty.c
@@ -118,6 +118,9 @@
 				bts->max_mcs_ul, VTY_NEWLINE);
 	}
 
+	vty_out(vty, " window-size %d %d%s", bts->ws_base, bts->ws_pdch,
+		VTY_NEWLINE);
+
 	if (bts->force_llc_lifetime == 0xffff)
 		vty_out(vty, " queue lifetime infinite%s", VTY_NEWLINE);
 	else if (bts->force_llc_lifetime)
@@ -437,6 +440,26 @@
 	return CMD_SUCCESS;
 }
 
+DEFUN(cfg_pcu_window_size,
+      cfg_pcu_window_size_cmd,
+      "window-size <0-1024> [<0-256>]",
+      "Window size configuration (b + N_PDCH * f)\n"
+      "Base value (b)\n"
+      "Factor for number of PDCH (f)")
+{
+	struct gprs_rlcmac_bts *bts = bts_main_data();
+	uint16_t b = atoi(argv[0]);
+
+	bts->ws_base = b;
+	if (argc > 1) {
+		uint16_t f = atoi(argv[1]);
+		bts->ws_pdch = f;
+	}
+
+	return CMD_SUCCESS;
+}
+
+
 #define QUEUE_STR "Packet queue options\n"
 #define LIFETIME_STR "Set lifetime limit of LLC frame in centi-seconds " \
 	"(overrides the value given by SGSN)\n"
@@ -892,6 +915,7 @@
 	install_element(PCU_NODE, &cfg_pcu_cs_lqual_ranges_cmd);
 	install_element(PCU_NODE, &cfg_pcu_mcs_max_cmd);
 	install_element(PCU_NODE, &cfg_pcu_no_mcs_max_cmd);
+	install_element(PCU_NODE, &cfg_pcu_window_size_cmd);
 	install_element(PCU_NODE, &cfg_pcu_queue_lifetime_cmd);
 	install_element(PCU_NODE, &cfg_pcu_queue_lifetime_inf_cmd);
 	install_element(PCU_NODE, &cfg_pcu_no_queue_lifetime_cmd);